(self.webpackChunkpanda_player=self.webpackChunkpanda_player||[]).push([[216],{2799:(t,e,i)=>{"use strict";if(i.d(e,{W:()=>n}),179==i.j)var s=i(3842);function n(t,e){e.silentMultipleInit||s.jf.error(`${t} is already initialized.`)}},8678:(t,e,i)=>{"use strict";if(i.d(e,{r:()=>a,y:()=>o}),179==i.j)var s=i(812);if(179==i.j)var n=i(4933);if(179==i.j)var r=i(3842);function a(t){const e={version:"6.18.1",onReady(t){t()},...t};return Object.defineProperty(e,"_setDebug",{get:()=>n.yD,enumerable:!1}),e}function o(t,e,i){const n=t[e];n&&!n.q&&n.version&&r.jf.warn("SDK is loaded more than once. This is unsupported and might have unexpected behavior."),t[e]=i,n&&n.q&&n.q.forEach((t=>(0,s.Z)(t,"onReady callback threw an error:")()))}},3206:(t,e,i)=>{"use strict";if(i.d(e,{O:()=>r,y:()=>a}),179==i.j)var s=i(4933);if(179==i.j)var n=i(9693);function r(t,e,i,s,n){return a(t,e,[i],s,n)}function a(t,e,i,r,{once:a,capture:o,passive:l}={}){const c=(0,s.zk)((e=>{(e.isTrusted||e.__ddIsTrusted||t.allowUntrustedEvents)&&(a&&f(),r(e))})),u=l?{capture:o,passive:l}:o,d=window.EventTarget&&e instanceof EventTarget?window.EventTarget.prototype:e,h=(0,n.I)(d,"addEventListener");function f(){const t=(0,n.I)(d,"removeEventListener");i.forEach((i=>t.call(e,i,c,u)))}return i.forEach((t=>h.call(e,t,c,u))),{stop:f}}},9647:(t,e,i)=>{"use strict";if(i.d(e,{OC:()=>u,WQ:()=>f,d8:()=>a,ej:()=>o,oX:()=>h}),179==i.j)var s=i(3842);if(179==i.j)var n=i(5026);if(179==i.j)var r=i(8129);function a(t,e,i=0,s){const n=new Date;n.setTime(n.getTime()+i);const r=`expires=${n.toUTCString()}`,a=s&&s.crossSite?"none":"strict",o=s&&s.domain?`;domain=${s.domain}`:"",l=s&&s.secure?";secure":"",c=s&&s.partitioned?";partitioned":"";document.cookie=`${t}=${e};${r};path=/;samesite=${a}${o}${l}${c}`}function o(t){return(0,r.MY)(document.cookie,t)}let l,c;function u(t){return l||(l=(0,r.kq)(document.cookie)),l.get(t)}function d(t,e){a(t,"",0,e)}function h(t){if(void 0===document.cookie||null===document.cookie)return!1;try{const e=`dd_cookie_test_${(0,r.DO)()}`,i="test";a(e,i,n.yR,t);const s=o(e)===i;return d(e,t),s}catch(t){return s.jf.error(t),!1}}function f(){if(void 0===c){const t=`dd_site_test_${(0,r.DO)()}`,e="test",i=window.location.hostname.split(".");let s=i.pop();for(;i.length&&!o(t);)s=`${i.pop()}.${s}`,a(t,e,n.WT,{domain:s});d(t,{domain:s}),c=s}return c}},8679:(t,e,i)=>{"use strict";if(i.d(e,{y:()=>c}),179==i.j)var s=i(5801);if(179==i.j)var n=i(4933);if(179==i.j)var r=i(3473);if(179==i.j)var a=i(5026);if(179==i.j)var o=i(170);let l;function c(){return l||(l=new r.y$((t=>{if(!window.fetch)return;const{stop:e}=(0,s.S)(window,"fetch",(e=>function({parameters:t,onPostCall:e,handlingStack:i},s){const[r,l]=t;let c=l&&l.method;void 0===c&&r instanceof Request&&(c=r.method);const u=void 0!==c?String(c).toUpperCase():"GET",d=r instanceof Request?r.url:(0,o.D5)(String(r)),h={state:"start",init:l,input:r,method:u,startClocks:(0,a.$I)(),url:d,handlingStack:i};s.notify(h),t[0]=h.input,t[1]=h.init,e((t=>function(t,e,i){const s=i;function r(e){s.state="resolve",Object.assign(s,e),t.notify(s)}e.then((0,n.zk)((t=>{r({response:t,responseType:t.type,status:t.status,isAborted:!1})})),(0,n.zk)((t=>{var e,i;r({status:0,isAborted:(null===(i=null===(e=s.init)||void 0===e?void 0:e.signal)||void 0===i?void 0:i.aborted)||t instanceof DOMException&&t.code===DOMException.ABORT_ERR,error:t})})))}(s,t,h)))}(e,t)),{computeHandlingStack:!0});return e}))),l}},7581:(t,e,i)=>{"use strict";if(i.d(e,{FP:()=>o,PT:()=>l,k$:()=>a}),179==i.j)var s=i(3473);if(179==i.j)var n=i(4776);if(179==i.j)var r=i(3206);const a={HIDDEN:"visibility_hidden",UNLOADING:"before_unload",PAGEHIDE:"page_hide",FROZEN:"page_frozen"};function o(t){return new s.y$((e=>{const{stop:i}=(0,r.y)(t,window,["visibilitychange","freeze"],(t=>{"visibilitychange"===t.type&&"hidden"===document.visibilityState?e.notify({reason:a.HIDDEN}):"freeze"===t.type&&e.notify({reason:a.FROZEN})}),{capture:!0}),s=(0,r.O)(t,window,"beforeunload",(()=>{e.notify({reason:a.UNLOADING})})).stop;return()=>{i(),s()}}))}function l(t){return(0,n.TT)(a).includes(t)}},193:(t,e,i)=>{"use strict";if(i.d(e,{T:()=>r,_:()=>a}),179==i.j)var s=i(251);if(179==i.j)var n=i(3206);function r(t,e,i){if(document.readyState===e||"complete"===document.readyState)return i(),{stop:s.Z};const r="complete"===e?"load":"DOMContentLoaded";return(0,n.O)(t,window,r,i,{once:!0})}function a(t,e){return new Promise((i=>{r(t,e,i)}))}},5343:(t,e,i)=>{"use strict";if(i.d(e,{S:()=>d}),179==i.j)var s=i(5801);if(179==i.j)var n=i(3473);if(179==i.j)var r=i(5026);if(179==i.j)var a=i(170);if(179==i.j)var o=i(4162);if(179==i.j)var l=i(3206);let c;const u=new WeakMap;function d(t){return c||(c=function(t){return new n.y$((e=>{const{stop:i}=(0,s.S)(XMLHttpRequest.prototype,"open",h),{stop:n}=(0,s.S)(XMLHttpRequest.prototype,"send",(i=>{!function({target:t,handlingStack:e},i,n){const a=u.get(t);if(!a)return;const c=a;c.state="start",c.startClocks=(0,r.$I)(),c.isAborted=!1,c.xhr=t,c.handlingStack=e;let d=!1;const{stop:h}=(0,s.S)(t,"onreadystatechange",(()=>{t.readyState===XMLHttpRequest.DONE&&f()})),f=()=>{if(p(),h(),d)return;d=!0;const e=a;e.state="complete",e.duration=(0,r._J)(c.startClocks.timeStamp,(0,r.n$)()),e.status=t.status,n.notify((0,o.mv)(e))},{stop:p}=(0,l.O)(i,t,"loadend",f);n.notify(c)}(i,t,e)}),{computeHandlingStack:!0}),{stop:a}=(0,s.S)(XMLHttpRequest.prototype,"abort",f);return()=>{i(),n(),a()}}))}(t)),c}function h({target:t,parameters:[e,i]}){u.set(t,{state:"open",method:String(e).toUpperCase(),url:(0,a.D5)(String(i))})}function f({target:t}){const e=u.get(t);e&&(e.isAborted=!0)}},4138:(t,e,i)=>{"use strict";if(i.d(e,{l3:()=>c}),179==i.j)var s=i(3842);if(179==i.j)var n=i(5562);if(179==i.j)var r=i(6676);if(179==i.j)var a=i(7198);const o="Running the Browser SDK in a Web extension content script is discouraged and will be forbidden in a future major release unless the `allowedTrackingOrigins` option is provided.",l="SDK initialized on a non-allowed domain.";function c(t,e=("undefined"!=typeof location?location.origin:""),i=(new Error).stack){const c=t.allowedTrackingOrigins;if(!c){if((0,r.UI)(e,i)){s.jf.warn(o);const t=(0,r.L0)(i);(0,a.eJ)(o,{extensionUrl:t||"unknown"})}return!0}const u=(0,n.v)(c,e);return u||s.jf.error(l),u}},5673:(t,e,i)=>{"use strict";if(i.d(e,{Q:()=>a}),179==i.j)var s=i(3473);if(179==i.j)var n=i(1315);const r=500;function a(t=n.Lp){const e=new s.fk(r),i=t().subscribe((t=>{e.notify({type:0,error:t})}));return{observable:e,stop:()=>{i.unsubscribe()}}}},7063:(t,e,i)=>{"use strict";if(i.d(e,{JZ:()=>v,Jj:()=>f,RJ:()=>m,fP:()=>y,tg:()=>p}),179==i.j)var s=i(812);if(179==i.j)var n=i(3842);if(179==i.j)var r=i(5026);if(179==i.j)var a=i(3603);if(179==i.j)var o=i(1962);if(179==i.j)var l=i(4162);if(179==i.j)var c=i(7479);if(179==i.j)var u=i(2988);if(179==i.j)var d=i(4138);if(179==i.j)var h=i(5039);const f={ALLOW:"allow",MASK:"mask",MASK_USER_INPUT:"mask-user-input"},p={ALL:"all",SAMPLED:"sampled"};function g(t,e){return null==t||"string"==typeof t||(n.jf.error(`${e} must be defined as a string`),!1)}function m(t,e){return!(void 0!==t&&!(0,a.zz)(t)&&(n.jf.error(`${e} Sample Rate should be a number between 0 and 100`),1))}function y(t){var e,i,a,f,p,y,v,b,_,E;if(t&&t.clientToken)if(void 0===t.allowedTrackingOrigins||Array.isArray(t.allowedTrackingOrigins)){if((!(T=t.site)||"string"!=typeof T||/(datadog|ddog|datad0g|dd0g)/.test(T)||(n.jf.error(`Site should be a valid Datadog site. ${n.IA} ${n.aA}/getting_started/site/.`),0))&&m(t.sessionSampleRate,"Session")&&m(t.telemetrySampleRate,"Telemetry")&&m(t.telemetryConfigurationSampleRate,"Telemetry Configuration")&&m(t.telemetryUsageSampleRate,"Telemetry Usage")&&g(t.version,"Version")&&g(t.env,"Env")&&g(t.service,"Service")&&(0,d.l3)(t)){var T;if(void 0===t.trackingConsent||(0,l.E5)(u.h,t.trackingConsent))return{beforeSend:t.beforeSend&&(0,s.Z)(t.beforeSend,"beforeSend threw an error:"),sessionStoreStrategyType:(0,c.hB)(t),sessionSampleRate:null!==(e=t.sessionSampleRate)&&void 0!==e?e:100,telemetrySampleRate:null!==(i=t.telemetrySampleRate)&&void 0!==i?i:20,telemetryConfigurationSampleRate:null!==(a=t.telemetryConfigurationSampleRate)&&void 0!==a?a:5,telemetryUsageSampleRate:null!==(f=t.telemetryUsageSampleRate)&&void 0!==f?f:5,service:null!==(p=t.service)&&void 0!==p?p:void 0,env:null!==(y=t.env)&&void 0!==y?y:void 0,version:null!==(v=t.version)&&void 0!==v?v:void 0,datacenter:null!==(b=t.datacenter)&&void 0!==b?b:void 0,silentMultipleInit:!!t.silentMultipleInit,allowUntrustedEvents:!!t.allowUntrustedEvents,trackingConsent:null!==(_=t.trackingConsent)&&void 0!==_?_:u.h.GRANTED,trackAnonymousUser:null===(E=t.trackAnonymousUser)||void 0===E||E,storeContextsAcrossPages:!!t.storeContextsAcrossPages,batchBytesLimit:16*o.Hi,eventRateLimiterThreshold:3e3,maxTelemetryEventsPerPage:15,flushTimeout:30*r.WT,batchMessagesLimit:50,messageBytesLimit:256*o.Hi,...(0,h.h)(t)};n.jf.error('Tracking Consent should be either "granted" or "not-granted"')}}else n.jf.error("Allowed Tracking Origins must be an array");else n.jf.error("Client Token is not configured, we will not send any data.")}function v(t){return{session_sample_rate:t.sessionSampleRate,telemetry_sample_rate:t.telemetrySampleRate,telemetry_configuration_sample_rate:t.telemetryConfigurationSampleRate,telemetry_usage_sample_rate:t.telemetryUsageSampleRate,use_before_send:!!t.beforeSend,use_partitioned_cross_site_session_cookie:t.usePartitionedCrossSiteSessionCookie,use_secure_session_cookie:t.useSecureSessionCookie,use_proxy:!!t.proxy,silent_multiple_init:t.silentMultipleInit,track_session_across_subdomains:t.trackSessionAcrossSubdomains,track_anonymous_user:t.trackAnonymousUser,session_persistence:t.sessionPersistence,allow_fallback_to_local_storage:!!t.allowFallbackToLocalStorage,store_contexts_across_pages:!!t.storeContextsAcrossPages,allow_untrusted_events:!!t.allowUntrustedEvents,tracking_consent:t.trackingConsent,use_allowed_tracking_origins:Array.isArray(t.allowedTrackingOrigins)}}},9176:(t,e,i)=>{"use strict";if(i.d(e,{E:()=>o,_:()=>l}),179==i.j)var s=i(5026);if(179==i.j)var n=i(170);if(179==i.j)var r=i(8129);if(179==i.j)var a=i(3909);function o(t,e,i){const a=function(t,e){const i=`/api/v2/${e}`,s=t.proxy;if("string"==typeof s){const t=(0,n.D5)(s);return e=>`${t}?ddforward=${encodeURIComponent(`${i}?${e}`)}`}if("function"==typeof s)return t=>s({path:i,parameters:t});const r=l(e,t);return t=>`https://${r}${i}?${t}`}(t,e);return{build(n,o){const l=function({clientToken:t,internalAnalyticsSubdomain:e},i,n,{retry:a,encoding:o},l=[]){const c=["ddsource=browser",`dd-api-key=${t}`,`dd-evp-origin-version=${encodeURIComponent("6.18.1")}`,"dd-evp-origin=browser",`dd-request-id=${(0,r.DO)()}`].concat(l);return o&&c.push(`dd-evp-encoding=${o}`),"rum"===i&&(c.push(`batch_time=${(0,s.n$)()}`,`_dd.api=${n}`),a&&c.push(`_dd.retry_count=${a.count}`,`_dd.retry_after=${a.lastFailureStatus}`)),e&&c.reverse(),c.join("&")}(t,e,n,o,i);return a(l)},trackType:e}}function l(t,e){const{site:i=a.D_,internalAnalyticsSubdomain:s}=e;if("logs"===t&&e.usePciIntake&&i===a.D_)return a.iL;if(s&&i===a.D_)return`${s}.${a.D_}`;if(i===a.by)return`http-intake.logs.${i}`;const n=i.split("."),r=n.pop();return`browser-intake-${n.join("-")}.${r}`}},5528:(t,e,i)=>{"use strict";if(i.d(e,{MS:()=>r}),179==i.j)var s=i(3842);const n=200;function r(t){const{env:e,service:i,version:s,datacenter:n}=t,r=[a("sdk_version","6.18.1")];return e&&r.push(a("env",e)),i&&r.push(a("service",i)),s&&r.push(a("version",s)),n&&r.push(a("datacenter",n)),r}function a(t,e){const i=e?`${t}:${e}`:t;return(i.length>n||function(t){return!!function(){try{return new RegExp("[\\p{Ll}]","u"),!0}catch(t){return!1}}()&&new RegExp("[^\\p{Ll}\\p{Lo}0-9_:./-]","u").test(t)}(i))&&s.jf.warn(`Tag ${i} doesn't meet tag requirements and will be sanitized. ${s.IA} ${s.aA}/getting_started/tagging/#defining-tags`),function(t){return t.replace(/,/g,"_")}(i)}},5039:(t,e,i)=>{"use strict";if(i.d(e,{h:()=>r,i:()=>a}),179==i.j)var s=i(3909);if(179==i.j)var n=i(9176);function r(t){const e=t.site||s.D_,i=function(t){return{logsEndpointBuilder:(0,n.E)(t,"logs"),rumEndpointBuilder:(0,n.E)(t,"rum"),profilingEndpointBuilder:(0,n.E)(t,"profile"),sessionReplayEndpointBuilder:(0,n.E)(t,"replay"),exposuresEndpointBuilder:(0,n.E)(t,"exposures")}}(t),r=function(t){if(!t.replica)return;const e={...t,site:s.D_,clientToken:t.replica.clientToken};return{logsEndpointBuilder:(0,n.E)(e,"logs"),rumEndpointBuilder:(0,n.E)(e,"rum",[`application.id=${t.replica.applicationId}`])}}(t);return{replica:r,site:e,...i}}function a(t){return s.Rg.every((e=>t.includes(e)))}},8826:(t,e,i)=>{"use strict";function s(){var t;const e=window.navigator;return{status:e.onLine?"connected":"not_connected",interfaces:e.connection&&e.connection.type?[e.connection.type]:void 0,effective_type:null===(t=e.connection)||void 0===t?void 0:t.effectiveType}}i.d(e,{T:()=>s})},6296:(t,e,i)=>{"use strict";if(i.d(e,{a:()=>p}),179==i.j)var s=i(5242);if(179==i.j)var n=i(3473);if(179==i.j)var r=i(3842);if(179==i.j)var a=i(4933);if(179==i.j)var o=i(8566);if(179==i.j)var l=i(9012);if(179==i.j)var c=i(2419);if(179==i.j)var u=i(2685);if(179==i.j)var d=i(4507);if(179==i.j)var h=i(5026);let f={};function p(t){const e=t.map((t=>(f[t]||(f[t]=function(t){return new n.y$((e=>{const i=r.jG[t];return r.jG[t]=(...n)=>{i.apply(console,n);const f=(0,d.Xp)("console error");(0,a.L6)((()=>{e.notify(function(t,e,i){const n=t.map((t=>function(t){return"string"==typeof t?(0,o.N)(t):(0,s.VZ)(t)?(0,d.jN)((0,u._)(t)):(0,l.l)((0,o.N)(t),void 0,2)}(t))).join(" ");if(e===r.vA.error){const r=t.find(s.VZ),a=(0,s.AP)({originalError:r,handlingStack:i,startClocks:(0,h.$I)(),source:c.z.CONSOLE,handling:"handled",nonErrorPrefix:"Provided",useFallbackStack:!1});return a.message=n,{api:e,message:n,handlingStack:i,error:a}}return{api:e,message:n,error:void 0,handlingStack:i}}(n,t,f))}))},()=>{r.jG[t]=i}}))}(t)),f[t])));return(0,n.$Z)(...e)}},254:(t,e,i)=>{"use strict";i.d(e,{O:()=>n,g:()=>s});const s={userContext:"userContext",globalContext:"globalContext",accountContext:"accountContext"},n={getContext:"getContext",setContext:"setContext",setContextProperty:"setContextProperty",removeContextProperty:"removeContextProperty",clearContext:"clearContext"}},6129:(t,e,i)=>{"use strict";if(i.d(e,{W:()=>u}),179==i.j)var s=i(2904);if(179==i.j)var n=i(8566);if(179==i.j)var r=i(3473);if(179==i.j)var a=i(3842);if(179==i.j)var o=i(9196);function l(t,e,i){const s={...t};for(const[t,{required:n,type:r}]of Object.entries(e))"string"!==r||c(s[t])||(s[t]=String(s[t])),n&&c(s[t])&&a.jf.warn(`The property ${t} of ${i} is required; context will not be sent to the intake.`);return s}function c(t){return null==t||""===t}function u(t="",{propertiesConfig:e={}}={}){let i={};const a=new r.y$,c={getContext:()=>(0,s.I8)(i),setContext:s=>{(0,o.J)(s)?i=(0,n.N)(l(s,e,t)):c.clearContext(),a.notify()},setContextProperty:(s,r)=>{i=(0,n.N)(l({...i,[s]:r},e,t)),a.notify()},removeContextProperty:s=>{delete i[s],l(i,e,t),a.notify()},clearContext:()=>{i={},a.notify()},changeObservable:a};return c}},9196:(t,e,i)=>{"use strict";if(i.d(e,{J:()=>r}),179==i.j)var s=i(3842);if(179==i.j)var n=i(3234);function r(t){const e="object"===(0,n.o)(t);return e||s.jf.error("Unsupported context:",t),e}},1214:(t,e,i)=>{"use strict";if(i.d(e,{z:()=>r}),179==i.j)var s=i(7198);if(179==i.j)var n=i(4933);function r(t,e,i,r){return(0,n.zk)(((...n)=>(r&&(0,s.eG)({feature:r}),t()[e][i](...n))))}},3150:(t,e,i)=>{"use strict";if(i.d(e,{ue:()=>l}),179==i.j)var s=i(3206);if(179==i.j)var n=i(2904);if(179==i.j)var r=i(4162);const a="_dd_c",o=179==i.j?[]:null;function l(t,e,i,l){const c=function(t,e){return`${a}_${t}_${e}`}(i,l);o.push((0,s.O)(t,window,"storage",(({key:t})=>{c===t&&e.setContext(d())}))),e.changeObservable.subscribe((function(){localStorage.setItem(c,JSON.stringify(e.getContext()))}));const u=(0,n.$e)(d(),e.getContext());function d(){const t=localStorage.getItem(c);return t?JSON.parse(t):{}}(0,r.Qr)(u)||e.setContext(u)}},9598:(t,e,i)=>{"use strict";if(i.d(e,{d:()=>l,p:()=>o}),179==i.j)var s=i(3150);if(179==i.j)var n=i(9643);if(179==i.j)var r=i(4162);if(179==i.j)var a=i(6129);function o(t,e,i){const a=l();return e.storeContextsAcrossPages&&(0,s.ue)(e,a,i,4),t.register(0,(()=>{const t=a.getContext();return(0,r.Qr)(t)||!t.id?n.kb:{account:t}})),a}function l(){return(0,a.W)("account",{propertiesConfig:{id:{type:"string",required:!0},name:{type:"string"}}})}},3127:(t,e,i)=>{"use strict";if(i.d(e,{$:()=>r,N:()=>a}),179==i.j)var s=i(3150);if(179==i.j)var n=i(6129);function r(t,e,i,n){const r=a();return e.storeContextsAcrossPages&&(0,s.ue)(e,r,i,2),t.register(0,(()=>{const t=r.getContext();return n?{context:t}:t})),r}function a(){return(0,n.W)("global context")}},2027:(t,e,i)=>{"use strict";if(i.d(e,{c:()=>o,f:()=>l}),179==i.j)var s=i(3150);if(179==i.j)var n=i(9643);if(179==i.j)var r=i(6129);if(179==i.j)var a=i(4162);function o(t,e,i,r){const o=l();return e.storeContextsAcrossPages&&(0,s.ue)(e,o,r,1),t.register(0,(({eventType:t,startTime:s})=>{const r=o.getContext(),l=i.findTrackedSession(s);return l&&l.anonymousId&&!r.anonymous_id&&e.trackAnonymousUser&&(r.anonymous_id=l.anonymousId),(0,a.Qr)(r)?n.kb:{type:t,usr:r}})),t.register(1,(({startTime:t})=>{var e;return{anonymous_id:null===(e=i.findTrackedSession(t))||void 0===e?void 0:e.anonymousId}})),o}function l(){return(0,r.W)("user",{propertiesConfig:{id:{type:"string"},name:{type:"string"},email:{type:"string"}}})}},5242:(t,e,i)=>{"use strict";if(i.d(e,{AP:()=>l,K$:()=>o,VZ:()=>h}),179==i.j)var s=i(8566);if(179==i.j)var n=i(9012);if(179==i.j)var r=i(2685);if(179==i.j)var a=i(4507);const o="No stack, consider using an instance of Error";function l({stackTrace:t,originalError:e,handlingStack:i,componentStack:s,startClocks:n,nonErrorPrefix:l,useFallbackStack:p=!0,source:g,handling:m}){const y=h(e);return!t&&y&&(t=(0,r._)(e)),{startClocks:n,source:g,handling:m,handlingStack:i,componentStack:s,originalError:e,type:t?t.name:void 0,message:c(t,y,l,e),stack:t?(0,a.P3)(t):p?o:void 0,causes:y?f(e,g):void 0,fingerprint:u(e),context:d(e)}}function c(t,e,i,r){return(null==t?void 0:t.message)&&(null==t?void 0:t.name)?t.message:e?"Empty message":`${i} ${(0,n.l)((0,s.N)(r))}`}function u(t){return h(t)&&"dd_fingerprint"in t?String(t.dd_fingerprint):void 0}function d(t){if(null!==t&&"object"==typeof t&&"dd_context"in t)return t.dd_context}function h(t){return t instanceof Error||"[object Error]"===Object.prototype.toString.call(t)}function f(t,e){let i=t;const s=[];for(;h(null==i?void 0:i.cause)&&s.length<10;){const t=(0,r._)(i.cause);s.push({message:i.cause.message,source:e,type:null==t?void 0:t.name,stack:t&&(0,a.P3)(t)}),i=i.cause}return s.length?s:void 0}},2419:(t,e,i)=>{"use strict";i.d(e,{z:()=>s});const s={AGENT:"agent",CONSOLE:"console",CUSTOM:"custom",LOGGER:"logger",NETWORK:"network",SOURCE:"source",REPORT:"report"}},1315:(t,e,i)=>{"use strict";if(i.d(e,{Lp:()=>u}),179==i.j)var s=i(5801);if(179==i.j)var n=i(3473);if(179==i.j)var r=i(5026);if(179==i.j)var a=i(2685);if(179==i.j)var o=i(9271);if(179==i.j)var l=i(5242);if(179==i.j)var c=i(2419);function u(){return new n.y$((t=>{const e=(e,i)=>{const s=(0,l.AP)({stackTrace:i,originalError:e,startClocks:(0,r.$I)(),nonErrorPrefix:"Uncaught",source:c.z.SOURCE,handling:"unhandled"});t.notify(s)},{stop:i}=(n=e,(0,s.S)((0,o.R)(),"onerror",(({parameters:[t,e,i,s,r]})=>{let o;(0,l.VZ)(r)||(o=(0,a.f)(t,e,i,s)),n(null!=r?r:t,o)})));var n;const{stop:u}=function(t){return(0,s.S)((0,o.R)(),"onunhandledrejection",(({parameters:[e]})=>{t(e.reason||"Empty reason")}))}(e);return()=>{i(),u()}}))}},5123:(t,e,i)=>{"use strict";if(i.d(e,{K:()=>a}),179==i.j)var s=i(5483);if(179==i.j)var n=i(5026);if(179==i.j)var r=i(2419);function a(t,e,i){let a=0,o=!1;return{isLimitReached(){if(0===a&&(0,s.iK)((()=>{a=0}),n.yR),a+=1,a<=e||o)return o=!1,!1;if(a===e+1){o=!0;try{i({message:`Reached max number of ${t}s by minute: ${e}`,source:r.z.AGENT,startClocks:(0,n.$I)()})}finally{o=!1}}return!0}}}},6676:(t,e,i)=>{"use strict";i.d(e,{L0:()=>a,UI:()=>r});const s=179==i.j?["chrome-extension://","moz-extension://"]:null;function n(t){return s.some((e=>t.includes(e)))}function r(t,e=""){return!n(t)&&n(e)}function a(t=""){for(const e of s){const i=t.match(new RegExp(`${e}[^/]+`));if(i)return i[0]}}},3909:(t,e,i)=>{"use strict";i.d(e,{DZ:()=>s,D_:()=>r,Ds:()=>a,Rg:()=>c,by:()=>n,iL:()=>l,y7:()=>o});const s="datad0g.com",n="dd0g-gov.com",r="datadoghq.com",a="datadoghq.eu",o="ddog-gov.com",l="pci.browser-intake-datadoghq.com",c=179==i.j?["ddsource","dd-api-key","dd-request-id"]:null},3670:(t,e,i)=>{"use strict";if(i.d(e,{_:()=>u,v:()=>d}),179==i.j)var s=i(4507);if(179==i.j)var n=i(4933);if(179==i.j)var r=i(3473);if(179==i.j)var a=i(3206);if(179==i.j)var o=i(8129);if(179==i.j)var l=i(2419);if(179==i.j)var c=i(5026);const u={intervention:"intervention",deprecation:"deprecation",cspViolation:"csp_violation"};function d(t,e){const i=[];e.includes(u.cspViolation)&&i.push(function(t){return new r.y$((e=>{const{stop:i}=(0,a.O)(t,document,"securitypolicyviolation",(t=>{e.notify(function(t){const e=`'${t.blockedURI}' blocked by '${t.effectiveDirective}' directive`;return h({type:t.effectiveDirective,message:`${u.cspViolation}: ${e}`,originalError:t,csp:{disposition:t.disposition},stack:f(t.effectiveDirective,t.originalPolicy?`${e} of the policy "${(0,o._z)(t.originalPolicy,100,"...")}"`:"no policy",t.sourceFile,t.lineNumber,t.columnNumber)})}(t))}));return i}))}(t));const s=e.filter((t=>t!==u.cspViolation));return s.length&&i.push(function(t){return new r.y$((e=>{if(!window.ReportingObserver)return;const i=(0,n.zk)(((t,i)=>t.forEach((t=>e.notify(function(t){const{type:e,body:i}=t;return h({type:i.id,message:`${e}: ${i.message}`,originalError:t,stack:f(i.id,i.message,i.sourceFile,i.lineNumber,i.columnNumber)})}(t)))))),s=new window.ReportingObserver(i,{types:t,buffered:!0});return s.observe(),()=>{s.disconnect()}}))}(s)),(0,r.$Z)(...i)}function h(t){return{startClocks:(0,c.$I)(),source:l.z.REPORT,handling:"unhandled",...t}}function f(t,e,i,n,r){return i?(0,s.P3)({name:t,message:e,stack:[{func:"?",url:i,line:null!=n?n:void 0,column:null!=r?r:void 0}]}):void 0}},8300:(t,e,i)=>{"use strict";i.d(e,{_:()=>s,x:()=>n});const s={DOCUMENT:"document",XHR:"xhr",BEACON:"beacon",FETCH:"fetch",CSS:"css",JS:"js",IMAGE:"image",FONT:"font",MEDIA:"media",OTHER:"other"},n={FETCH:s.FETCH,XHR:s.XHR}},9739:(t,e,i)=>{"use strict";if(i.d(e,{TK:()=>d}),179==i.j)var s=i(9647);if(179==i.j)var n=i(4942);if(179==i.j)var r=i(8336);const a="_dd",o="_dd_r",l="_dd_l",c="rum",u="logs";function d(t){if(!(0,s.OC)(n.H)){const e=(0,s.OC)(a),i=(0,s.OC)(o),n=(0,s.OC)(l),d={};e&&(d.id=e),n&&/^[01]$/.test(n)&&(d[u]=n),i&&/^[012]$/.test(i)&&(d[c]=i),(0,r.Qw)(d)&&((0,r.Il)(d),t.persistSession(d))}}},8981:(t,e,i)=>{"use strict";i.d(e,{TN:()=>n,_q:()=>l,m8:()=>o,sr:()=>r,uY:()=>a});var s=i(5026);const n=4*s.dV,r=15*s.yR,a=179==i.j?s.P5:null,o="0",l={COOKIE:"cookie",LOCAL_STORAGE:"local-storage"}},5135:(t,e,i)=>{"use strict";if(i.d(e,{HX:()=>y}),179==i.j)var s=i(3473);if(179==i.j)var n=i(9029);if(179==i.j)var r=i(5026);if(179==i.j)var a=i(3206);if(179==i.j)var o=i(5483);if(179==i.j)var l=i(7198);if(179==i.j)var c=i(9262);if(179==i.j)var u=i(9647);if(179==i.j)var d=i(8981);if(179==i.j)var h=i(7479);if(179==i.j)var f=i(1010);const p=179==i.j?r.yR:null,g=179==i.j?d.TN:null;let m=179==i.j?[]:null;function y(t,e,i,y){const v=new s.y$,b=new s.y$,_=(0,h.vH)(t.sessionStoreStrategyType,t,e,i);m.push((()=>_.stop()));const E=(0,n.p)({expireDelay:g});function T(){const t=_.getSession();return t?{id:t.id,trackingType:t[e],isReplayForced:!!t.forcedReplay,anonymousId:t.anonymousId}:(async function(){const t=(0,f.JP)();let e=[];e="cookieStore"in window?await window.cookieStore.getAll("_dd_s"):document.cookie.split(/\s*;\s*/).filter((t=>t.startsWith("_dd_s"))),(0,l.eJ)("Unexpected session state",{session:t,isSyntheticsTest:(0,c.m)(),createdTimestamp:null==t?void 0:t.created,expireTimestamp:null==t?void 0:t.expire,cookie:{count:e.length,domain:(0,u.WQ)(),...e},currentDomain:`${window.location.protocol}//${window.location.hostname}`})}().catch((()=>{})),{id:"invalid",trackingType:d.m8,isReplayForced:!1,anonymousId:void 0})}return m.push((()=>E.stop())),_.renewObservable.subscribe((()=>{E.add(T(),(0,r._q)()),v.notify()})),_.expireObservable.subscribe((()=>{b.notify(),E.closeActive((0,r._q)())})),_.expandOrRenewSession(),E.add(T(),(0,r.cQ)().relative),y.observable.subscribe((()=>{y.isGranted()?_.expandOrRenewSession():_.expire()})),function(t,e){const{stop:i}=(0,a.y)(t,window,["click","touchstart","keydown","scroll"],(()=>{y.isGranted()&&_.expandOrRenewSession()}),{capture:!0,passive:!0});m.push(i)}(t),function(t,e){const i=()=>{"visible"===document.visibilityState&&_.expandSession()},{stop:s}=(0,a.O)(t,document,"visibilitychange",i);m.push(s);const n=(0,o.Zi)(i,p);m.push((()=>{(0,o.cv)(n)}))}(t),function(t,e){const{stop:i}=(0,a.O)(t,window,"resume",(()=>_.restartSession()),{capture:!0});m.push(i)}(t),{findSession:(t,e)=>E.find(t,e),renewObservable:v,expireObservable:b,sessionStateUpdateObservable:_.sessionStateUpdateObservable,expire:_.expire,updateSessionState:_.updateSessionState}}},8336:(t,e,i)=>{"use strict";if(i.d(e,{Ey:()=>f,Il:()=>p,NK:()=>u,Qw:()=>h,Tm:()=>d,q1:()=>m,u_:()=>g}),179==i.j)var s=i(4162);if(179==i.j)var n=i(4776);if(179==i.j)var r=i(5026);if(179==i.j)var a=i(8129);if(179==i.j)var o=i(8981);if(179==i.j)var l=i(6254);const c="1";function u(t,e){const i={isExpired:c};return e.trackAnonymousUser&&((null==t?void 0:t.anonymousId)?i.anonymousId=null==t?void 0:t.anonymousId:i.anonymousId=(0,a.DO)()),i}function d(t){return(0,s.Qr)(t)}function h(t){return!d(t)}function f(t){return void 0!==t.isExpired||!((void 0===(e=t).created||(0,r.m6)()-Number(e.created)"anonymousId"===t?`aid=${e}`:`${t}=${e}`)).join(l.SL)}function m(t){const e={};return(0,l.$B)(t)&&t.split(l.SL).forEach((t=>{const i=l.tY.exec(t);if(null!==i){const[,t,s]=i;"aid"===t?e.anonymousId=s:e[t]=s}})),e}},6254:(t,e,i)=>{"use strict";i.d(e,{$B:()=>r,SL:()=>n,tY:()=>s});const s=/^([a-zA-Z]+)=([a-z0-9-]+)$/,n="&";function r(t){return!!t&&(-1!==t.indexOf(n)||s.test(t))}},7479:(t,e,i)=>{"use strict";if(i.d(e,{hB:()=>g,vH:()=>m}),179==i.j)var s=i(5483);if(179==i.j)var n=i(3473);if(179==i.j)var r=i(5026);if(179==i.j)var a=i(251);if(179==i.j)var o=i(8129);if(179==i.j)var l=i(3842);if(179==i.j)var c=i(1010);if(179==i.j)var u=i(8336);if(179==i.j)var d=i(5485);if(179==i.j)var h=i(3739);if(179==i.j)var f=i(8981);const p=179==i.j?r.WT:null;function g(t){switch(t.sessionPersistence){case f._q.COOKIE:return(0,c.XR)(t);case f._q.LOCAL_STORAGE:return(0,d.u)();case void 0:{let e=(0,c.XR)(t);return!e&&t.allowFallbackToLocalStorage&&(e=(0,d.u)()),e}default:l.jf.error(`Invalid session persistence '${String(t.sessionPersistence)}'`)}}function m(t,e,i,l,g=function(t,e){return t.type===f._q.COOKIE?(0,c.h$)(e,t.cookieOptions):(0,d.m)(e)}(t,e)){const m=new n.y$,y=new n.y$,v=new n.y$,b=(0,s.Zi)((function(){const t=g.retrieveSession();(0,u.Ey)(t)?(0,h.ax)({process:t=>(0,u.Ey)(t)?(0,u.NK)(t,e):void 0,after:S},g):S(t)}),p);let _;k();const{throttled:E,cancel:T}=(0,a.P)((()=>{(0,h.ax)({process:t=>{if((0,u.Tm)(t))return;const e=S(t);return function(t){if((0,u.Tm)(t))return!1;const e=l(t[i]);t[i]=e,delete t.isExpired,e===f.m8||t.id||(t.id=(0,o.DO)(),t.created=String((0,r.m6)()))}(e),e},after:t=>{(0,u.Qw)(t)&&!w()&&function(t){_=t,m.notify()}(t),_=t}},g)}),p);function S(t){return(0,u.Ey)(t)&&(t=(0,u.NK)(t,e)),w()&&(function(t){return _.id!==t.id||_[i]!==t[i]}(t)?(_=(0,u.NK)(_,e),y.notify()):(v.notify({previousState:_,newState:t}),_=t)),t}function k(){(0,h.ax)({process:t=>{if((0,u.Tm)(t))return(0,u.NK)(t,e)},after:t=>{_=t}},g)}function w(){return void 0!==(null==_?void 0:_[i])}return{expandOrRenewSession:E,expandSession:function(){(0,h.ax)({process:t=>w()?S(t):void 0},g)},getSession:()=>_,renewObservable:m,expireObservable:y,sessionStateUpdateObservable:v,restartSession:k,expire:()=>{T(),g.expireSession(_),S((0,u.NK)(_,e))},stop:()=>{(0,s.cv)(b)},updateSessionState:function(t){(0,h.ax)({process:e=>({...e,...t}),after:S},g)}}}},3739:(t,e,i)=>{"use strict";if(i.d(e,{ax:()=>p}),179==i.j)var s=i(5483);if(179==i.j)var n=i(8129);if(179==i.j)var r=i(5026);if(179==i.j)var a=i(7198);if(179==i.j)var o=i(8336);const l=10,c=100,u=179==i.j?r.WT:null,d="--",h=179==i.j?[]:null;let f;function p(t,e,i=0){var s;const{isLockEnabled:l,persistSession:u,expireSession:p}=e,v=t=>u({...t,lock:_}),b=()=>{const{lock:t,...i}=e.retrieveSession();return{session:i,lock:t&&!y(t)?t:void 0}};if(f||(f=t),t!==f)return void h.push(t);if(l&&i>=c)return(0,a.eJ)("Aborted session operation after max lock retries",{currentStore:b()}),void m(e);let _,E=b();if(l){if(E.lock)return void g(t,e,i);if(_=(0,n.DO)()+d+(0,r.n$)(),v(E.session),E=b(),E.lock!==_)return void g(t,e,i)}let T=t.process(E.session);if(l&&(E=b(),E.lock!==_))g(t,e,i);else{if(T&&((0,o.Ey)(T)?p(T):((0,o.Il)(T),l?v(T):u(T))),l&&(!T||!(0,o.Ey)(T))){if(E=b(),E.lock!==_)return void g(t,e,i);u(E.session),T=E.session}null===(s=t.after)||void 0===s||s.call(t,T||E.session),m(e)}}function g(t,e,i){(0,s.iK)((()=>{p(t,e,i+1)}),l)}function m(t){f=void 0;const e=h.shift();e&&p(e,t)}function y(t){const[,e]=t.split(d);return!e||(0,r._J)(Number(e),(0,r.n$)())>u}},1010:(t,e,i)=>{"use strict";if(i.d(e,{JP:()=>h,XR:()=>c,h$:()=>u}),179==i.j)var s=i(2172);if(179==i.j)var n=i(9647);if(179==i.j)var r=i(9739);if(179==i.j)var a=i(8981);if(179==i.j)var o=i(8336);if(179==i.j)var l=i(4942);function c(t){const e=function(t){const e={};return e.secure=!!t.useSecureSessionCookie||!!t.usePartitionedCrossSiteSessionCookie,e.crossSite=!!t.usePartitionedCrossSiteSessionCookie,e.partitioned=!!t.usePartitionedCrossSiteSessionCookie,t.trackSessionAcrossSubdomains&&(e.domain=(0,n.WQ)()),e}(t);return(0,n.oX)(e)?{type:a._q.COOKIE,cookieOptions:e}:void 0}function u(t,e){const i={isLockEnabled:(0,s.mJ)(),persistSession:i=>d(e,t,i,a.sr),retrieveSession:h,expireSession:i=>d(e,t,(0,o.NK)(i,t),a.TN)};return(0,r.TK)(i),i}function d(t,e,i,s){(0,n.d8)(l.H,(0,o.u_)(i),e.trackAnonymousUser?a.uY:s,t)}function h(){const t=(0,n.ej)(l.H);return(0,o.q1)(t)}},5485:(t,e,i)=>{"use strict";if(i.d(e,{m:()=>c,u:()=>l}),179==i.j)var s=i(8129);if(179==i.j)var n=i(8981);if(179==i.j)var r=i(8336);if(179==i.j)var a=i(4942);const o="_dd_test_";function l(){try{const t=(0,s.DO)(),e=`${o}${t}`;localStorage.setItem(e,t);const i=localStorage.getItem(e);return localStorage.removeItem(e),t===i?{type:n._q.LOCAL_STORAGE}:void 0}catch(t){return}}function c(t){return{isLockEnabled:!1,persistSession:u,retrieveSession:d,expireSession:e=>function(t,e){u((0,r.NK)(t,e))}(e,t)}}function u(t){localStorage.setItem(a.H,(0,r.u_)(t))}function d(){const t=localStorage.getItem(a.H);return(0,r.q1)(t)}},4942:(t,e,i)=>{"use strict";i.d(e,{H:()=>s});const s="_dd_s"},9262:(t,e,i)=>{"use strict";if(i.d(e,{L7:()=>l,QB:()=>c,Y9:()=>o,m:()=>u}),179==i.j)var s=i(9647);const n="datadog-synthetics-public-id",r="datadog-synthetics-result-id",a="datadog-synthetics-injects-rum";function o(){return Boolean(window._DATADOG_SYNTHETICS_INJECTS_RUM||(0,s.OC)(a))}function l(){const t=window._DATADOG_SYNTHETICS_PUBLIC_ID||(0,s.OC)(n);return"string"==typeof t?t:void 0}function c(){const t=window._DATADOG_SYNTHETICS_RESULT_ID||(0,s.OC)(r);return"string"==typeof t?t:void 0}function u(){return Boolean(l()&&c())}},9711:(t,e,i)=>{"use strict";i.d(e,{c:()=>s});const s={LOG:"log",CONFIGURATION:"configuration",USAGE:"usage"}},7198:(t,e,i)=>{"use strict";if(i.d(e,{Sz:()=>I,Uo:()=>C,VL:()=>R,eG:()=>x,eJ:()=>L,qZ:()=>D}),179==i.j)var s=i(3842);if(179==i.j)var n=i(5242);if(179==i.j)var r=i(4507);if(179==i.j)var a=i(7549);var o=i(3909);if(179==i.j)var l=i(3473);if(179==i.j)var c=i(5026);if(179==i.j)var u=i(4933);if(179==i.j)var d=i(8971);if(179==i.j)var h=i(3603);if(179==i.j)var f=i(9012);if(179==i.j)var p=i(2904);if(179==i.j)var g=i(2685);if(179==i.j)var m=i(8826);if(179==i.j)var y=i(6876);if(179==i.j)var v=i(3789);if(179==i.j)var b=i(2097);if(179==i.j)var _=i(5419);if(179==i.j)var E=i(9643);if(179==i.j)var T=i(9711);const S=179==i.j?["https://www.datadoghq-browser-agent.com","https://www.datad0g-browser-agent.com","https://d3uc069fcn7uxw.cloudfront.net","https://d20xtzwzcl0ceb.cloudfront.net","http://localhost",""]:null,k=[o.y7];let w;function A(){return w||(w=new l.fk(100)),w}function R(t,e,i,s,n,r){const g=new l.y$,{stop:S}=function(t,e,i,s,n){const r=[];if((0,y.xT)()){const t=(0,y.Ad)(),e=n.subscribe((e=>t.send("internal_telemetry",e)));r.push(e.unsubscribe)}else{const a=[t.rumEndpointBuilder];t.replica&&function(t){return t.site===o.DZ}(t)&&a.push(t.replica.rumEndpointBuilder);const c=(0,v.n)({encoder:s(4),request:(0,b.UF)(a,t.batchBytesLimit,e),flushController:(0,_.r)({messagesLimit:t.batchMessagesLimit,bytesLimit:t.batchBytesLimit,durationLimit:t.flushTimeout,pageMayExitObservable:i,sessionExpireObservable:new l.y$}),messageBytesLimit:t.messageBytesLimit});r.push(c.stop);const u=n.subscribe(c.add);r.push(u.unsubscribe)}return{stop:()=>r.forEach((t=>t()))}}(e,s,n,r,g),{enabled:w}=function(t,e,i,s){const n={},r=!k.includes(e.site)&&(0,h.y7)(e.telemetrySampleRate),o={[T.c.LOG]:r,[T.c.CONFIGURATION]:r&&(0,h.y7)(e.telemetryConfigurationSampleRate),[T.c.USAGE]:r&&(0,h.y7)(e.telemetryUsageSampleRate)},l={is_local_file:"file:"===window.location.protocol,is_worker:"WorkerGlobalScope"in self},g=A();return g.subscribe((({rawEvent:r,kind:u})=>{if(!o[r.type])return;let h=n[u];if(h||(h=n[u]=new Set),h.size>=e.maxTelemetryEventsPerPage)return;const g=(0,f.l)(r);if(h.has(g))return;const y=i.triggerHook(1,{startTime:(0,c.$I)().relative});if(y===E.C_)return;const v=function(t,e,i,s){const n={type:"telemetry",date:(0,c.$I)().timeStamp,service:e,version:"6.18.1",source:"browser",_dd:{format_version:2},telemetry:(0,p.$e)(i,{runtime_env:s,connectivity:(0,m.T)(),sdk_setup:"npm"}),experimental_features:Array.from((0,a.u0)())};return(0,p.$e)(n,t)}(y,t,r,l);s.notify(v),(0,d.j)("telemetry",v),h.add(g)})),g.unbuffer(),(0,u.P_)(I),{enabled:r}}(t,e,i,g);return{stop:S,enabled:w}}function L(t,e){(0,u.DV)(s.vA.debug,t,e),A().notify({rawEvent:{type:T.c.LOG,message:t,status:"debug",...e},kind:"debug"})}function I(t,e){A().notify({rawEvent:{type:T.c.LOG,status:"error",...P(t),...e},kind:"error"})}function C(t){A().notify({rawEvent:{type:T.c.CONFIGURATION,configuration:t},kind:T.c.CONFIGURATION})}function D(t,e){A().notify({rawEvent:{type:T.c.LOG,message:t,status:"debug",...e},kind:t})}function x(t){A().notify({rawEvent:{type:T.c.USAGE,usage:t},kind:T.c.USAGE})}function P(t){if((0,n.VZ)(t)){const e=(0,g._)(t);return{error:{kind:e.name,stack:(0,r.P3)(O(e))},message:e.message}}return{error:{stack:n.K$},message:`Uncaught ${(0,f.l)(t)}`}}function O(t){return t.stack=t.stack.filter((t=>!t.url||S.some((e=>t.url.startsWith(e))))),t}},2988:(t,e,i)=>{"use strict";if(i.d(e,{H:()=>r,h:()=>n}),179==i.j)var s=i(3473);const n={GRANTED:"granted",NOT_GRANTED:"not-granted"};function r(t){const e=new s.y$;return{tryToInit(e){t||(t=e)},update(i){t=i,e.notify()},isGranted:()=>t===n.GRANTED,observable:e}}},9643:(t,e,i)=>{"use strict";if(i.d(e,{C_:()=>n,kb:()=>r,uR:()=>a}),179==i.j)var s=i(2904);const n="DISCARDED",r="SKIPPED";function a(){const t={};return{register:(e,i)=>(t[e]||(t[e]=[]),t[e].push(i),{unregister:()=>{t[e]=t[e].filter((t=>t!==i))}}),triggerHook(e,i){const a=t[e]||[],o=[];for(const t of a){const e=t(i);if(e===n)return n;e!==r&&o.push(e)}return(0,s.$e)(...o)}}}},9307:(t,e,i)=>{"use strict";i.d(e,{l:()=>s});class s{constructor(){this.callbacks={}}notify(t,e){const i=this.callbacks[t];i&&i.forEach((t=>t(e)))}subscribe(t,e){return this.callbacks[t]||(this.callbacks[t]=[]),this.callbacks[t].push(e),{unsubscribe:()=>{this.callbacks[t]=this.callbacks[t].filter((t=>e!==t))}}}}},8783:(t,e,i)=>{"use strict";if(i.d(e,{D:()=>r}),179==i.j)var s=i(3214);const n=500;function r(){const t=[];return{add:e=>{t.push(e)>n&&t.splice(0,1)},remove:e=>{(0,s.c)(t,e)},drain:e=>{t.forEach((t=>t(e))),t.length=0}}}},812:(t,e,i)=>{"use strict";if(i.d(e,{Z:()=>n}),179==i.j)var s=i(3842);function n(t,e){return(...i)=>{try{return t(...i)}catch(t){s.jf.error(e,t)}}}},3842:(t,e,i)=>{"use strict";i.d(e,{IA:()=>u,Qo:()=>c,aA:()=>l,jG:()=>n,jf:()=>o,vA:()=>s});const s={log:"log",debug:"debug",info:"info",warn:"warn",error:"error"},n=console,r={};Object.keys(s).forEach((t=>{r[t]=n[t]}));const a="Datadog Browser SDK:",o={debug:r.debug.bind(n,a),log:r.log.bind(n,a),info:r.info.bind(n,a),warn:r.warn.bind(n,a),error:r.error.bind(n,a)},l="https://docs.datadoghq.com",c=`${l}/real_user_monitoring/browser/troubleshooting`,u="More details:"},3895:(t,e,i)=>{"use strict";if(i.d(e,{G:()=>n}),179==i.j)var s=i(1962);function n(){let t="",e=0;return{isAsync:!1,get isEmpty(){return!t},write(i,n){const r=(0,s.qt)(i);e+=r,t+=i,n&&n(r)},finish(t){t(this.finishSync())},finishSync(){const i={output:t,outputBytesCount:e,rawBytesCount:e,pendingData:""};return t="",e=0,i},estimateEncodedBytesCount:t=>t.length}}},7549:(t,e,i)=>{"use strict";if(i.d(e,{W_:()=>o,fG:()=>a,u0:()=>l,uh:()=>n}),179==i.j)var s=i(4162);var n;!function(t){t.TRACK_INTAKE_REQUESTS="track_intake_requests",t.WRITABLE_RESOURCE_GRAPHQL="writable_resource_graphql",t.EARLY_REQUEST_COLLECTION="early_request_collection",t.WATCH_COOKIE_WITHOUT_LOCK="watch_cookie_without_lock",t.USE_TREE_WALKER_FOR_ACTION_NAME="use_tree_walker_for_action_name"}(n||(n={}));const r=new Set;function a(t){Array.isArray(t)&&t.filter((t=>(0,s.E5)(n,t))).forEach((t=>{r.add(t)}))}function o(t){return r.has(t)}function l(){return r}},9271:(t,e,i)=>{"use strict";function s(){if("object"==typeof globalThis)return globalThis;Object.defineProperty(Object.prototype,"_dd_temp_",{get(){return this},configurable:!0});let t=_dd_temp_;return delete Object.prototype._dd_temp_,"object"!=typeof t&&(t="object"==typeof self?self:"object"==typeof window?window:{}),t}i.d(e,{R:()=>s})},9693:(t,e,i)=>{"use strict";if(i.d(e,{I:()=>n}),179==i.j)var s=i(9271);function n(t,e){const i=(0,s.R)();let n;return i.Zone&&"function"==typeof i.Zone.__symbol__&&(n=t[i.Zone.__symbol__(e)]),n||(n=t[e]),n}},5801:(t,e,i)=>{"use strict";if(i.d(e,{S:()=>o,X:()=>l}),179==i.j)var s=i(5483);if(179==i.j)var n=i(4933);if(179==i.j)var r=i(251);if(179==i.j)var a=i(4507);function o(t,e,i,{computeHandlingStack:s}={}){let o=t[e];if("function"!=typeof o){if(!(e in t)||!e.startsWith("on"))return{stop:r.Z};o=r.Z}let l=!1;const c=function(){if(l)return o.apply(this,arguments);const t=Array.from(arguments);let e;(0,n.L6)(i,null,[{target:this,parameters:t,onPostCall:t=>{e=t},handlingStack:s?(0,a.Xp)("instrumented method"):void 0}]);const r=o.apply(this,t);return e&&(0,n.L6)(e,null,[r]),r};return t[e]=c,{stop:()=>{l=!0,t[e]===c&&(t[e]=o)}}}function l(t,e,i){const n=Object.getOwnPropertyDescriptor(t,e);if(!n||!n.set||!n.configurable)return{stop:r.Z};const a=r.Z;let o=(t,e)=>{(0,s.iK)((()=>{o!==a&&i(t,e)}),0)};const l=function(t){n.set.call(this,t),o(this,t)};return Object.defineProperty(t,e,{set:l}),{stop:()=>{var i;(null===(i=Object.getOwnPropertyDescriptor(t,e))||void 0===i?void 0:i.set)===l&&Object.defineProperty(t,e,n),o=a}}}},5562:(t,e,i)=>{"use strict";if(i.d(e,{o:()=>r,v:()=>a}),179==i.j)var s=i(3842);if(179==i.j)var n=i(3234);function r(t){const e=(0,n.o)(t);return"string"===e||"function"===e||t instanceof RegExp}function a(t,e,i=!1){return t.some((t=>{try{if("function"==typeof t)return t(e);if(t instanceof RegExp)return t.test(e);if("string"==typeof t)return i?e.startsWith(t):t===e}catch(t){s.jf.error(t)}return!1}))}},2904:(t,e,i)=>{"use strict";if(i.d(e,{$e:()=>a,I8:()=>r}),179==i.j)var s=i(3234);function n(t,e,i=function(){if("undefined"!=typeof WeakSet){const t=new WeakSet;return{hasAlreadyBeenSeen(e){const i=t.has(e);return i||t.add(e),i}}}const t=[];return{hasAlreadyBeenSeen(e){const i=t.indexOf(e)>=0;return i||t.push(e),i}}}()){if(void 0===e)return t;if("object"!=typeof e||null===e)return e;if(e instanceof Date)return new Date(e.getTime());if(e instanceof RegExp){const t=e.flags||[e.global?"g":"",e.ignoreCase?"i":"",e.multiline?"m":"",e.sticky?"y":"",e.unicode?"u":""].join("");return new RegExp(e.source,t)}if(i.hasAlreadyBeenSeen(e))return;if(Array.isArray(e)){const s=Array.isArray(t)?t:[];for(let t=0;t{"use strict";if(i.d(e,{$y:()=>u,DV:()=>d,L6:()=>c,P_:()=>a,yD:()=>o,zk:()=>l}),179==i.j)var s=i(3842);let n,r=!1;function a(t){n=t}function o(t){r=t}function l(t){return function(){return c(t,this,arguments)}}function c(t,e,i){try{return t.apply(e,i)}catch(t){u(t)}}function u(t){if(d(t),n)try{n(t)}catch(t){d(t)}}function d(...t){r&&s.jf.error("[MONITOR]",...t)}},3473:(t,e,i)=>{"use strict";if(i.d(e,{$Z:()=>r,fk:()=>a,y$:()=>n}),179==i.j)var s=i(3455);class n{constructor(t){this.onFirstSubscribe=t,this.observers=[]}subscribe(t){return this.addObserver(t),{unsubscribe:()=>this.removeObserver(t)}}notify(t){this.observers.forEach((e=>e(t)))}addObserver(t){this.observers.push(t),1===this.observers.length&&this.onFirstSubscribe&&(this.onLastUnsubscribe=this.onFirstSubscribe(this)||void 0)}removeObserver(t){this.observers=this.observers.filter((e=>t!==e)),!this.observers.length&&this.onLastUnsubscribe&&this.onLastUnsubscribe()}}function r(...t){return new n((e=>{const i=t.map((t=>t.subscribe((t=>e.notify(t)))));return()=>i.forEach((t=>t.unsubscribe()))}))}class a extends(179==i.j?n:null){constructor(t){super(),this.maxBufferSize=t,this.buffer=[]}notify(t){this.buffer.push(t),this.buffer.length>this.maxBufferSize&&this.buffer.shift(),super.notify(t)}subscribe(t){let e=!1;const i={unsubscribe:()=>{e=!0,this.removeObserver(t)}};return(0,s.Y)((()=>{for(const i of this.buffer){if(e)return;t(i)}e||this.addObserver(t)})),i}unbuffer(){(0,s.Y)((()=>{this.maxBufferSize=this.buffer.length=0}))}}},3455:(t,e,i)=>{"use strict";if(i.d(e,{Y:()=>n}),179==i.j)var s=i(4933);function n(t){const e=window.queueMicrotask;"function"==typeof e?e((0,s.zk)(t)):Promise.resolve().then((0,s.zk)(t))}},8057:(t,e,i)=>{"use strict";if(i.d(e,{n:()=>r}),179==i.j)var s=i(4933);if(179==i.j)var n=i(251);function r(t,e,i){const r=t.getReader(),a=[];let o=0;function l(){let t,s;if(r.cancel().catch(n.Z),i.collectStreamBody){let e;if(1===a.length)e=a[0];else{e=new Uint8Array(o);let t=0;a.forEach((i=>{e.set(i,t),t+=i.length}))}t=e.slice(0,i.bytesLimit),s=e.length>i.bytesLimit}e(void 0,t,s)}!function t(){r.read().then((0,s.zk)((e=>{e.done?l():(i.collectStreamBody&&a.push(e.value),o+=e.value.length,o>i.bytesLimit?l():t())})),(0,s.zk)((t=>e(t))))}()}},1337:(t,e,i)=>{"use strict";if(i.d(e,{Kk:()=>a}),179==i.j)var s=i(5483);if(179==i.j)var n=i(4933);if(179==i.j)var r=i(5026);function a(t,e){if(window.requestIdleCallback&&window.cancelIdleCallback){const i=window.requestIdleCallback((0,n.zk)(t),e);return()=>window.cancelIdleCallback(i)}return function(t){const e=(0,r.m6)(),i=(0,s.iK)((()=>{t({didTimeout:!1,timeRemaining:()=>Math.max(0,o-((0,r.m6)()-e))})}),0);return()=>(0,s.gr)(i)}(t)}const o=50},8971:(t,e,i)=>{"use strict";function s(t,e){const i=window.__ddBrowserSdkExtensionCallback;i&&i({type:t,payload:e})}i.d(e,{j:()=>s})},9012:(t,e,i)=>{"use strict";if(i.d(e,{l:()=>n,y:()=>r}),179==i.j)var s=i(251);function n(t,e,i){if("object"!=typeof t||null===t)return JSON.stringify(t);const s=r(Object.prototype),n=r(Array.prototype),a=r(Object.getPrototypeOf(t)),o=r(t);try{return JSON.stringify(t,e,i)}catch(t){return""}finally{s(),n(),a(),o()}}function r(t){const e=t,i=e.toJSON;return i?(delete e.toJSON,()=>{e.toJSON=i}):s.Z}},8566:(t,e,i)=>{"use strict";if(i.d(e,{N:()=>c}),179==i.j)var s=i(3842);var n=i(1962);if(179==i.j)var r=i(9012);const a=220*n.Hi,o="$",l=3;function c(t,e=a){const i=(0,r.y)(Object.prototype),s=(0,r.y)(Array.prototype),n=[],c=new WeakMap,d=u(t,o,void 0,n,c),f=JSON.stringify(d);let p=f?f.length:0;if(!(p>e)){for(;n.length>0&&pe){h(e,"truncated",t);break}i.target[r]=a}else for(const r in i.source)if(Object.prototype.hasOwnProperty.call(i.source,r)){const a=u(i.source[r],i.path,r,n,c);if(void 0!==a&&(p+=JSON.stringify(a).length+s+r.length+l,s=1),p>e){h(e,"truncated",t);break}i.target[r]=a}}return i(),s(),d}h(e,"discarded",t)}function u(t,e,i,s,n){const r=function(t){const e=t;if(e&&"function"==typeof e.toJSON)try{return e.toJSON()}catch(t){}return t}(t);if(!r||"object"!=typeof r)return"bigint"==typeof(a=r)?`[BigInt] ${a.toString()}`:"function"==typeof a?`[Function] ${a.name||"unknown"}`:"symbol"==typeof a?`[Symbol] ${a.description||a.toString()}`:a;var a;const o=d(r);if("[Object]"!==o&&"[Array]"!==o&&"[Error]"!==o)return o;const l=t;if(n.has(l))return`[Reference seen at ${n.get(l)}]`;const c=void 0!==i?`${e}.${i}`:e,u=Array.isArray(r)?[]:{};return n.set(l,c),s.push({source:r,target:u,path:c}),u}function d(t){try{if(t instanceof Event)return{type:(e=t).type,isTrusted:e.isTrusted,currentTarget:e.currentTarget?d(e.currentTarget):null,target:e.target?d(e.target):null};if(t instanceof RegExp)return`[RegExp] ${t.toString()}`;const i=Object.prototype.toString.call(t).match(/\[object (.*)\]/);if(i&&i[1])return`[${i[1]}]`}catch(t){}var e;return"[Unserializable]"}function h(t,e,i){s.jf.warn(`The data provided has been ${e} as it is over the limit of ${t} characters:`,i)}},2685:(t,e,i)=>{"use strict";i.d(e,{_:()=>n,f:()=>p});const s="?";function n(t){var e,i;const n=[];let r=f(t,"stack");const a=String(t);if(r&&r.startsWith(a)&&(r=r.slice(a.length)),r&&r.split("\n").forEach((t=>{const e=function(t){const e=o.exec(t);if(!e)return;const i=e[2]&&0===e[2].indexOf("native"),n=e[2]&&0===e[2].indexOf("eval"),r=l.exec(e[2]);return n&&r&&(e[2]=r[1],e[3]=r[2],e[4]=r[3]),{args:i?[e[2]]:[],column:e[4]?+e[4]:void 0,func:e[1]||s,line:e[3]?+e[3]:void 0,url:i?void 0:e[2]}}(t)||function(t){const e=c.exec(t);if(e)return{args:[],column:e[3]?+e[3]:void 0,func:s,line:e[2]?+e[2]:void 0,url:e[1]}}(t)||function(t){const e=u.exec(t);if(e)return{args:[],column:e[4]?+e[4]:void 0,func:e[1]||s,line:+e[3],url:e[2]}}(t)||function(t){const e=d.exec(t);if(!e)return;const i=e[3]&&e[3].indexOf(" > eval")>-1,n=h.exec(e[3]);return i&&n&&(e[3]=n[1],e[4]=n[2],e[5]=void 0),{args:e[2]?e[2].split(","):[],column:e[5]?+e[5]:void 0,func:e[1]||s,line:e[4]?+e[4]:void 0,url:e[3]}}(t);e&&(!e.func&&e.line&&(e.func=s),n.push(e))})),n.length>0&&function(){if(void 0!==y)return y;class t extends Error{constructor(){super(),this.name="Error"}}const[e,i]=[t,Error].map((t=>new t));return y=m(Object.getPrototypeOf(e))&&i.stack!==e.stack,y}()&&t instanceof Error){const r=[];let a=t;for(;(a=Object.getPrototypeOf(a))&&m(a);){const t=(null===(e=a.constructor)||void 0===e?void 0:e.name)||s;r.push(t)}for(let t=r.length-1;t>=0&&(null===(i=n[0])||void 0===i?void 0:i.func)===r[t];t--)n.shift()}return{message:f(t,"message"),name:f(t,"name"),stack:n}}const r="((?:file|https?|blob|chrome-extension|electron|native|eval|webpack|snippet||\\w+\\.|\\/).*?)",a="(?::(\\d+))",o=new RegExp(`^\\s*at (.*?) ?\\(${r}${a}?${a}?\\)?\\s*$`,"i"),l=new RegExp(`\\((\\S*)${a}${a}\\)`),c=new RegExp(`^\\s*at ?${r}${a}?${a}??\\s*$`,"i"),u=/^\s*at (?:((?:\[object object\])?.+) )?\(?((?:file|ms-appx|https?|webpack|blob):.*?):(\d+)(?::(\d+))?\)?\s*$/i,d=/^\s*(.*?)(?:\((.*?)\))?(?:(?:(?:^|@)((?:file|https?|blob|chrome|webpack|resource|capacitor|\[native).*?|[^@]*bundle|\[wasm code\])(?::(\d+))?(?::(\d+))?)|@)\s*$/i,h=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i;function f(t,e){if("object"!=typeof t||!t||!(e in t))return;const i=t[e];return"string"==typeof i?i:void 0}function p(t,e,i,s){if(void 0===e)return;const{name:n,message:r}=function(t){let e,i;return"[object String]"==={}.toString.call(t)&&([,e,i]=g.exec(t)),{name:e,message:i}}(t);return{name:n,message:r,stack:[{url:e,column:s,line:i}]}}const g=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?([\s\S]*)$/;function m(t){return String(t.constructor).startsWith("class ")}let y},4507:(t,e,i)=>{"use strict";if(i.d(e,{P3:()=>a,Xp:()=>r,jN:()=>o}),179==i.j)var s=i(4933);if(179==i.j)var n=i(2685);function r(t){const e=new Error(t);let i;return e.name="HandlingStack",(0,s.L6)((()=>{const t=(0,n._)(e);t.stack=t.stack.slice(2),i=a(t)})),i}function a(t){let e=o(t);return t.stack.forEach((t=>{const i="?"===t.func?"":t.func,s=t.args&&t.args.length>0?`(${t.args.join(", ")})`:"",n=t.line?`:${t.line}`:"",r=t.line&&t.column?`:${t.column}`:"";e+=`\n at ${i}${s} @ ${t.url}${n}${r}`})),e}function o(t){return`${t.name||"Error"}: ${t.message}`}},49:(t,e,i)=>{"use strict";if(i.d(e,{y:()=>o}),179==i.j)var s=i(5026);if(179==i.j)var n=i(1337);const r=179==i.j?s.WT:null,a=30;function o(){const t=[];function e(e){let s;if(e.didTimeout){const t=performance.now();s=()=>a-(performance.now()-t)}else s=e.timeRemaining.bind(e);for(;s()>0&&t.length;)t.shift()();t.length&&i()}function i(){(0,n.Kk)(e,{timeout:r})}return{push(e){1===t.push(e)&&i()}}}},5483:(t,e,i)=>{"use strict";if(i.d(e,{Zi:()=>l,cv:()=>c,gr:()=>o,iK:()=>a}),179==i.j)var s=i(9693);if(179==i.j)var n=i(4933);if(179==i.j)var r=i(9271);function a(t,e){return(0,s.I)((0,r.R)(),"setTimeout")((0,n.zk)(t),e)}function o(t){(0,s.I)((0,r.R)(),"clearTimeout")(t)}function l(t,e){return(0,s.I)((0,r.R)(),"setInterval")((0,n.zk)(t),e)}function c(t){(0,s.I)((0,r.R)(),"clearInterval")(t)}},3214:(t,e,i)=>{"use strict";function s(t,e){const i=t.indexOf(e);i>=0&&t.splice(i,1)}i.d(e,{c:()=>s})},2172:(t,e,i)=>{"use strict";function s(){return 0===a()}function n(){return 1===a()}let r;function a(){return null!=r?r:r=function(t=window){var e;const i=t.navigator.userAgent;return t.chrome||/HeadlessChrome/.test(i)?0:0===(null===(e=t.navigator.vendor)||void 0===e?void 0:e.indexOf("Apple"))||/safari/i.test(i)&&!/chrome|android/i.test(i)?1:2}()}i.d(e,{G6:()=>n,mJ:()=>s})},1962:(t,e,i)=>{"use strict";i.d(e,{Hi:()=>s,Kb:()=>o,X9:()=>n,qt:()=>a});const s=1024,n=1024*s,r=/[^\u0000-\u007F]/;function a(t){return r.test(t)?void 0!==window.TextEncoder?(new TextEncoder).encode(t).length:new Blob([t]).size:t.length}function o(t){const e=t.reduce(((t,e)=>t+e.length),0),i=new Uint8Array(e);let s=0;for(const e of t)i.set(e,s),s+=e.length;return i}},251:(t,e,i)=>{"use strict";if(i.d(e,{P:()=>n,Z:()=>r}),179==i.j)var s=i(5483);function n(t,e,i){const n=!i||void 0===i.leading||i.leading,r=!i||void 0===i.trailing||i.trailing;let a,o,l=!1;return{throttled:(...i)=>{l?a=i:(n?t(...i):a=i,l=!0,o=(0,s.iK)((()=>{r&&a&&t(...a),l=!1,a=void 0}),e))},cancel:()=>{(0,s.gr)(o),l=!1,a=void 0}}}function r(){}},3603:(t,e,i)=>{"use strict";function s(t){return 0!==t&&100*Math.random()<=t}function n(t,e){return+t.toFixed(e)}function r(t){return a(t)&&t>=0&&t<=100}function a(t){return"number"==typeof t}i.d(e,{NM:()=>n,hj:()=>a,y7:()=>s,zz:()=>r})},4162:(t,e,i)=>{"use strict";function s(t){return{...t}}function n(t,e){return Object.keys(t).some((i=>t[i]===e))}function r(t){return 0===Object.keys(t).length}function a(t,e){const i={};for(const s of Object.keys(t))i[s]=e(t[s]);return i}i.d(e,{E5:()=>n,Q8:()=>a,Qr:()=>r,mv:()=>s})},4776:(t,e,i)=>{"use strict";function s(t,e){for(let i=t.length-1;i>=0;i-=1){const s=t[i];if(e(s,i,t))return s}}function n(t){return Object.values(t)}function r(t){return Object.entries(t)}i.d(e,{TT:()=>n,dF:()=>s,qP:()=>r})},9100:(t,e,i)=>{"use strict";function s(t){return t>=500}function n(t){try{return t.clone()}catch(t){return}}i.d(e,{o:()=>s,u:()=>n})},8129:(t,e,i)=>{"use strict";function s(t){return t?(parseInt(t,10)^16*Math.random()>>parseInt(t,10)/4).toString(16):"10000000-1000-4000-8000-100000000000".replace(/[018]/g,s)}i.d(e,{DO:()=>s,MY:()=>r,_z:()=>o,kq:()=>a});const n=/([\w-]+)\s*=\s*([^;]+)/g;function r(t,e){for(n.lastIndex=0;;){const i=n.exec(t);if(!i)break;if(i[1]===e)return i[2]}}function a(t){const e=new Map;for(n.lastIndex=0;;){const i=n.exec(t);if(!i)break;e.set(i[1],i[2])}return e}function o(t,e,i=""){const s=t.charCodeAt(e-1),n=s>=55296&&s<=56319?e+1:e;return t.length<=n?t:`${t.slice(0,n)}${i}`}},5026:(t,e,i)=>{"use strict";if(i.d(e,{$I:()=>m,Cn:()=>E,DY:()=>l,P5:()=>o,QA:()=>d,WK:()=>b,WT:()=>n,_J:()=>v,_q:()=>g,c0:()=>h,cQ:()=>y,dV:()=>a,lO:()=>c,m6:()=>f,n$:()=>p,ni:()=>_,yR:()=>r}),179==i.j)var s=i(3603);const n=1e3,r=60*n,a=60*r,o=24*a*365;function l(t){return{relative:t,timeStamp:u(t)}}function c(t){return{relative:_(t),timeStamp:t}}function u(t){const e=f()-performance.now();return e>S()?Math.round(b(e,t)):function(t){return Math.round(b(S(),t))}(t)}function d(){return Math.round(f()-b(S(),performance.now()))}function h(t){return(0,s.hj)(t)?(0,s.NM)(1e6*t,0):t}function f(){return(new Date).getTime()}function p(){return f()}function g(){return performance.now()}function m(){return{relative:g(),timeStamp:p()}}function y(){return{relative:0,timeStamp:S()}}function v(t,e){return e-t}function b(t,e){return t+e}function _(t){return t-S()}function E(t){return t{"use strict";function s(){try{return(new Intl.DateTimeFormat).resolvedOptions().timeZone}catch(t){return}}i.d(e,{Z:()=>s})},3234:(t,e,i)=>{"use strict";function s(t){return null===t?"null":Array.isArray(t)?"array":typeof t}i.d(e,{o:()=>s})},170:(t,e,i)=>{"use strict";if(i.d(e,{D5:()=>n,Q2:()=>o,jv:()=>r,ye:()=>a}),179==i.j)var s=i(9012);function n(t){return o(t,location.href).href}function r(t){try{return!!o(t)}catch(t){return!1}}function a(t){const e=o(t).pathname;return"/"===e[0]?e:`/${e}`}function o(t,e){const{URL:i}=function(){if(!l){let t,e;try{t=document.createElement("iframe"),t.style.display="none",document.body.appendChild(t),e=t.contentWindow}catch(t){e=window}l={URL:e.URL},null==t||t.remove()}return l}();try{return void 0!==e?new i(t,e):new i(t)}catch(i){throw new Error(`Failed to construct URL: ${String(i)} ${(0,s.l)({url:t,base:e})}`)}}let l},9029:(t,e,i)=>{"use strict";if(i.d(e,{p:()=>u}),179==i.j)var s=i(5483);if(179==i.j)var n=i(3214);if(179==i.j)var r=i(5026);const a=1/0,o=179==i.j?r.yR:null;let l=null;const c=new Set;function u({expireDelay:t,maxEntries:e}){let i=[];l||(l=(0,s.Zi)((()=>{c.forEach((t=>t()))}),o));const u=()=>{const e=(0,r._q)()-t;for(;i.length>0&&i[i.length-1].endTime{(0,n.c)(i,r)},close:t=>{r.endTime=t}};return e&&i.length>=e&&i.pop(),i.unshift(r),r},find:function(t=a,e={returnInactive:!1}){for(const s of i)if(s.startTime<=t){if(e.returnInactive||t<=s.endTime)return s.value;break}},closeActive:function(t){const e=i[0];e&&e.endTime===a&&e.close(t)},findAll:function(t=a,e=0){const s=(0,r.WK)(t,e);return i.filter((e=>e.startTime<=s&&t<=e.endTime)).map((t=>t.value))},reset:function(){i=[]},stop:function(){c.delete(u),0===c.size&&l&&((0,s.cv)(l),l=null)}}}},3789:(t,e,i)=>{"use strict";if(i.d(e,{n:()=>l}),179==i.j)var s=i(3842);if(179==i.j)var n=i(4776);if(179==i.j)var r=i(7581);if(179==i.j)var a=i(9012);if(179==i.j)var o=i(1962);function l({encoder:t,request:e,flushController:i,messageBytesLimit:l}){let u={};const d=i.flushObservable.subscribe((i=>function(i){const s=(0,n.TT)(u).join("\n");u={};const a=(0,r.PT)(i.reason),l=a?e.sendOnExit:e.send;if(a&&t.isAsync){const e=t.finishSync();e.outputBytesCount&&l(c(e));const i=[e.pendingData,s].filter(Boolean).join("\n");i&&l({data:i,bytesCount:(0,o.qt)(i)})}else s&&t.write(t.isEmpty?s:`\n${s}`),t.finish((t=>{l(c(t))}))}(i)));function h(e,n){const r=(0,a.l)(e),o=t.estimateEncodedBytesCount(r);o>=l?s.jf.warn(`Discarded a message whose size was bigger than the maximum allowed size ${l}KB. ${s.IA} ${s.Qo}/#technical-limitations`):(function(t){return void 0!==t&&void 0!==u[t]}(n)&&function(e){const s=u[e];delete u[e];const n=t.estimateEncodedBytesCount(s);i.notifyAfterRemoveMessage(n)}(n),function(e,s,n){i.notifyBeforeAddMessage(s),void 0!==n?(u[n]=e,i.notifyAfterAddMessage()):t.write(t.isEmpty?e:`\n${e}`,(t=>{i.notifyAfterAddMessage(t-s)}))}(r,o,n))}return{flushController:i,add:h,upsert:h,stop:d.unsubscribe}}function c(t){let e;return e="string"==typeof t.output?t.output:new Blob([t.output],{type:"text/plain"}),{data:e,bytesCount:t.outputBytesCount,encoding:t.encoding}}},6876:(t,e,i)=>{"use strict";if(i.d(e,{Ad:()=>n,ke:()=>r,xT:()=>a}),179==i.j)var s=i(9271);function n(){const t=(0,s.R)().DatadogEventBridge;if(t)return{getCapabilities(){var e;return JSON.parse((null===(e=t.getCapabilities)||void 0===e?void 0:e.call(t))||"[]")},getPrivacyLevel(){var e;return null===(e=t.getPrivacyLevel)||void 0===e?void 0:e.call(t)},getAllowedWebViewHosts:()=>JSON.parse(t.getAllowedWebViewHosts()),send(e,i,s){const n=s?{id:s}:void 0;t.send(JSON.stringify({eventType:e,event:i,view:n}))}}}function r(t){const e=n();return!!e&&e.getCapabilities().includes(t)}function a(t){var e;void 0===t&&(t=null===(e=(0,s.R)().location)||void 0===e?void 0:e.hostname);const i=n();return!!i&&i.getAllowedWebViewHosts().some((e=>t===e||t.endsWith(`.${e}`)))}},5419:(t,e,i)=>{"use strict";if(i.d(e,{r:()=>r}),179==i.j)var s=i(3473);if(179==i.j)var n=i(5483);function r({messagesLimit:t,bytesLimit:e,durationLimit:i,pageMayExitObservable:r,sessionExpireObservable:a}){const o=r.subscribe((t=>f(t.reason))),l=a.subscribe((()=>f("session_expire"))),c=new s.y$((()=>()=>{o.unsubscribe(),l.unsubscribe()}));let u,d=0,h=0;function f(t){if(0===h)return;const e=h,i=d;h=0,d=0,p(),c.notify({reason:t,messagesCount:e,bytesCount:i})}function p(){(0,n.gr)(u),u=void 0}return{flushObservable:c,get messagesCount(){return h},notifyBeforeAddMessage(t){d+t>=e&&f("bytes_limit"),h+=1,d+=t,void 0===u&&(u=(0,n.iK)((()=>{f("duration_limit")}),i))},notifyAfterAddMessage(i=0){d+=i,h>=t?f("messages_limit"):d>=e&&f("bytes_limit")},notifyAfterRemoveMessage(t){d-=t,h-=1,0===h&&p()}}}},2097:(t,e,i)=>{"use strict";if(i.d(e,{UF:()=>a}),179==i.j)var s=i(4933);if(179==i.j)var n=i(3473);if(179==i.j)var r=i(7825);function a(t,e,i){const s=new n.y$,a=(0,r.Fj)();return{observable:s,send:n=>{for(const o of t)(0,r.BT)(n,a,((t,i)=>c(o,e,t,i)),o.trackType,i,s)},sendOnExit:i=>{for(const s of t)o(s,e,i)}}}function o(t,e,i){if(navigator.sendBeacon&&i.bytesCountnull==n?void 0:n({status:t.status,type:t.type})))).catch((0,s.zk)((()=>u(t,i,n))))}else u(t,i,n)}function u(t,e,i){const n=t.build("fetch",e);fetch(n,{method:"POST",body:e.data,mode:"cors"}).then((0,s.zk)((t=>null==i?void 0:i({status:t.status,type:t.type})))).catch((0,s.zk)((()=>null==i?void 0:i({status:0}))))}},7825:(t,e,i)=>{"use strict";if(i.d(e,{BT:()=>f,Fj:()=>y}),179==i.j)var s=i(5483);if(179==i.j)var n=i(5026);var r=i(1962);if(179==i.j)var a=i(9100);if(179==i.j)var o=i(2419);const l=80*r.Hi,c=32,u=3*r.X9,d=179==i.j?n.yR:null,h=179==i.j?n.WT:null;function f(t,e,i,s,n,r){0===e.transportStatus&&0===e.queuedPayloads.size()&&e.bandwidthMonitor.canHandle(t)?g(t,e,i,r,{onSuccess:()=>m(0,e,i,s,n,r),onFailure:()=>{e.queuedPayloads.enqueue(t)||r.notify({type:"queue-full",bandwidth:e.bandwidthMonitor.stats(),payload:t}),p(e,i,s,n,r)}}):e.queuedPayloads.enqueue(t)||r.notify({type:"queue-full",bandwidth:e.bandwidthMonitor.stats(),payload:t})}function p(t,e,i,n,r){2===t.transportStatus&&(0,s.iK)((()=>{g(t.queuedPayloads.first(),t,e,r,{onSuccess:()=>{t.queuedPayloads.dequeue(),t.currentBackoffTime=h,m(1,t,e,i,n,r)},onFailure:()=>{t.currentBackoffTime=Math.min(d,2*t.currentBackoffTime),p(t,e,i,n,r)}})}),t.currentBackoffTime)}function g(t,e,i,s,{onSuccess:n,onFailure:r}){e.bandwidthMonitor.add(t),i(t,(i=>{e.bandwidthMonitor.remove(t),function(t){return"opaque"!==t.type&&(0===t.status&&!navigator.onLine||408===t.status||429===t.status||(0,a.o)(t.status))}(i)?(e.transportStatus=e.bandwidthMonitor.ongoingRequestCount>0?1:2,t.retry={count:t.retry?t.retry.count+1:1,lastFailureStatus:i.status},s.notify({type:"failure",bandwidth:e.bandwidthMonitor.stats(),payload:t}),r()):(e.transportStatus=0,s.notify({type:"success",bandwidth:e.bandwidthMonitor.stats(),payload:t}),n())}))}function m(t,e,i,s,a,l){0===t&&e.queuedPayloads.isFull()&&!e.queueFullReported&&(a({message:`Reached max ${s} events size queued for upload: ${u/r.X9}MiB`,source:o.z.AGENT,startClocks:(0,n.$I)()}),e.queueFullReported=!0);const c=e.queuedPayloads;for(e.queuedPayloads=v();c.size()>0;)f(c.dequeue(),e,i,s,a,l)}function y(){return{transportStatus:0,currentBackoffTime:h,bandwidthMonitor:{ongoingRequestCount:0,ongoingByteCount:0,canHandle(t){return 0===this.ongoingRequestCount||this.ongoingByteCount+t.bytesCount<=l&&this.ongoingRequestCountt[0],dequeue(){const e=t.shift();return e&&(this.bytesCount-=e.bytesCount),e},size:()=>t.length,isFull(){return this.bytesCount>=u}}}},9744:(t,e,i)=>{"use strict";if(i.d(e,{k:()=>l}),179==i.j)var s=i(3473);if(179==i.j)var n=i(3206);if(179==i.j)var r=i(5026);if(179==i.j)var a=i(8129);if(179==i.j)var o=i(5483);function l(t,e){const i=window.cookieStore?function(t){return(e,i)=>(0,n.O)(t,window.cookieStore,"change",(t=>{const s=t.changed.find((t=>t.name===e))||t.deleted.find((t=>t.name===e));s&&i(s.value)})).stop}(t):u;return new s.y$((t=>i(e,(e=>t.notify(e)))))}const c=179==i.j?r.WT:null;function u(t,e){const i=(0,a.MY)(document.cookie,t),s=(0,o.Zi)((()=>{const s=(0,a.MY)(document.cookie,t);s!==i&&e(s)}),c);return()=>{(0,o.cv)(s)}}},4250:(t,e,i)=>{"use strict";if(i.d(e,{q:()=>l,y:()=>o}),179==i.j)var s=i(3473);if(179==i.j)var n=i(4933);if(179==i.j)var r=i(9693);if(179==i.j)var a=i(251);function o(){const t=l();return new s.y$((e=>{if(!t)return;const i=new t((0,n.zk)((t=>e.notify(t))));return i.observe(document,{attributes:!0,characterData:!0,childList:!0,subtree:!0}),()=>i.disconnect()}))}function l(){let t;const e=window;if(e.Zone&&(t=(0,r.I)(e,"MutationObserver"),e.MutationObserver&&t===e.MutationObserver)){const i=new e.MutationObserver(a.Z),s=(0,r.I)(i,"originalInstance");t=s&&s.constructor}return t||(t=e.MutationObserver),t}},7569:(t,e,i)=>{"use strict";if(i.d(e,{X:()=>r}),179==i.j)var s=i(5026);if(179==i.j)var n=i(3206);function r(t,e){const i=(0,s.m6)();let r=!1;const{stop:a}=(0,n.y)(t,window,["click","mousedown","keydown","touchstart","pointerdown"],(e=>{if(!e.cancelable)return;const i={entryType:"first-input",processingStart:(0,s._q)(),processingEnd:(0,s._q)(),startTime:e.timeStamp,duration:0,name:"",cancelable:!1,target:null,toJSON:()=>({})};"pointerdown"===e.type?function(t,e){(0,n.y)(t,window,["pointerup","pointercancel"],(t=>{"pointerup"===t.type&&o(e)}),{once:!0})}(t,i):o(i)}),{passive:!0,capture:!0});return{stop:a};function o(t){if(!r){r=!0,a();const n=t.processingStart-t.startTime;n>=0&&n<(0,s.m6)()-i&&e(t)}}}},3644:(t,e,i)=>{"use strict";function s(t){return t.nodeType===Node.TEXT_NODE}function n(t){return t.nodeType===Node.COMMENT_NODE}function r(t){return t.nodeType===Node.ELEMENT_NODE}function a(t){return r(t)&&Boolean(t.shadowRoot)}function o(t){const e=t;return!!e.host&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&r(e.host)}function l(t){return t.childNodes.length>0||a(t)}function c(t,e){let i=t.firstChild;for(;i;)e(i),i=i.nextSibling;a(t)&&e(t.shadowRoot)}function u(t){return o(t)?t.host:t.parentNode}i.d(e,{BM:()=>s,Ow:()=>u,Sn:()=>l,Tv:()=>r,Uo:()=>c,VO:()=>o,aT:()=>a,dI:()=>n})},3766:(t,e,i)=>{"use strict";if(i.d(e,{t:()=>o}),179==i.j)var s=i(4162);if(179==i.j)var n=i(3473);if(179==i.j)var r=i(5801);if(179==i.j)var a=i(3206);function o(t,e){let i=(0,s.mv)(e);return new n.y$((n=>{const{stop:o}=function(t,e){const{stop:i}=(0,r.S)(l("pushState"),"pushState",(({onPostCall:t})=>{t(e)})),{stop:s}=(0,r.S)(l("replaceState"),"replaceState",(({onPostCall:t})=>{t(e)})),{stop:n}=(0,a.O)(t,window,"popstate",e);return{stop:()=>{i(),s(),n()}}}(t,u),{stop:c}=function(t,e){return(0,a.O)(t,window,"hashchange",e)}(t,u);function u(){if(i.href===e.href)return;const t=(0,s.mv)(e);n.notify({newLocation:t,oldLocation:i}),i=t}return()=>{o(),c()}}))}function l(t){return Object.prototype.hasOwnProperty.call(history,t)?history:History.prototype}},247:(t,e,i)=>{"use strict";function s(){let t;const e=window.visualViewport;return t=e?e.pageLeft-e.offsetLeft:void 0!==window.scrollX?window.scrollX:window.pageXOffset||0,Math.round(t)}function n(){let t;const e=window.visualViewport;return t=e?e.pageTop-e.offsetTop:void 0!==window.scrollY?window.scrollY:window.pageYOffset||0,Math.round(t)}i.d(e,{$:()=>s,X:()=>n})},5788:(t,e,i)=>{"use strict";if(i.d(e,{AX:()=>o,PA:()=>l}),179==i.j)var s=i(3473);if(179==i.j)var n=i(251);if(179==i.j)var r=i(3206);let a;function o(t){return a||(a=function(t){return new s.y$((e=>{const{throttled:i}=(0,n.P)((()=>{e.notify(l())}),200);return(0,r.O)(t,window,"resize",i,{capture:!0,passive:!0}).stop}))}(t)),a}function l(){const t=window.visualViewport;return t?{width:Number(t.width*t.scale),height:Number(t.height*t.scale)}:{width:Number(window.innerWidth||0),height:Number(window.innerHeight||0)}}},4967:(t,e,i)=>{"use strict";if(i.d(e,{M:()=>r}),179==i.j)var s=i(3473);if(179==i.j)var n=i(5801);function r(){const t=new s.y$,{stop:e}=(0,n.S)(window,"open",(()=>t.notify()));return{observable:t,stop:e}}},6508:(t,e,i)=>{"use strict";if(i.d(e,{bl:()=>o}),179==i.j)var s=i(5026);if(179==i.j)var n=i(5483);const r=179==i.j?s.WT:null,a=100;function o(t,e){const i=[];let s,o=0;function l(t){t.stopObservable.subscribe(c),i.push(t),(0,n.gr)(s),s=(0,n.iK)(u,r)}function c(){1===o&&i.every((t=>t.isStopped()))&&(o=2,e(i))}function u(){(0,n.gr)(s),0===o&&(o=1,c())}return l(t),{tryAppend:t=>{return 0===o&&(i.length>0&&(e=i[i.length-1].event,s=t.event,!(e.target===s.target&&(n=e,c=s,Math.sqrt(Math.pow(n.clientX-c.clientX,2)+Math.pow(n.clientY-c.clientY,2))<=a)&&e.timeStamp-s.timeStamp<=r))?(u(),!1):(l(t),!0));var e,s,n,c},stop:()=>{u()}}}},8124:(t,e,i)=>{"use strict";if(i.d(e,{u:()=>n}),179==i.j)var s=i(3206);function n(t,{onPointerDown:e,onPointerUp:i}){let n,o,l={selection:!1,input:!1,scroll:!1};const c=[(0,s.O)(t,window,"pointerdown",(t=>{a(t)&&(n=r(),l={selection:!1,input:!1,scroll:!1},o=e(t))}),{capture:!0}),(0,s.O)(t,window,"selectionchange",(()=>{n&&r()||(l.selection=!0)}),{capture:!0}),(0,s.O)(t,window,"scroll",(()=>{l.scroll=!0}),{capture:!0,passive:!0}),(0,s.O)(t,window,"pointerup",(t=>{if(a(t)&&o){const e=l;i(o,t,(()=>e)),o=void 0}}),{capture:!0}),(0,s.O)(t,window,"input",(()=>{l.input=!0}),{capture:!0})];return{stop:()=>{c.forEach((t=>t.stop()))}}}function r(){const t=window.getSelection();return!t||t.isCollapsed}function a(t){return t.target instanceof Element&&!1!==t.isPrimary}},1093:(t,e,i)=>{"use strict";if(i.d(e,{ir:()=>l}),179==i.j)var s=i(3842);if(179==i.j)var n=i(4162);if(179==i.j)var r=i(9176);const a="v1",o=179==i.j?["applicationId","service","env","version","sessionSampleRate","sessionReplaySampleRate","defaultPrivacyLevel","enablePrivacyForActionName","traceSampleRate","trackSessionAcrossSubdomains","allowedTracingUrls","allowedTrackingOrigins"]:null;async function l(t){const e=await async function(t){let e;try{e=await fetch(function(t){return t.remoteConfigurationProxy?t.remoteConfigurationProxy:`https://sdk-configuration.${(0,r._)("rum",t)}/${a}/${encodeURIComponent(t.remoteConfigurationId)}.json`}(t))}catch(t){e=void 0}if(!e||!e.ok)return{ok:!1,error:new Error("Error fetching the remote configuration.")};const i=await e.json();return i.rum?{ok:!0,value:i.rum}:{ok:!1,error:new Error("No remote configuration for RUM.")}}(t);if(e.ok)return function(t,e){const i={...t};return o.forEach((t=>{t in e&&(i[t]=c(e[t]))})),i}(t,e.value);s.jf.error(e.error)}function c(t){if(Array.isArray(t))return t.map(c);if(function(t){return"object"==typeof t&&null!==t}(t)){if("rcSerializedType"in t){const e=t.rcSerializedType;switch(e){case"string":return t.value;case"regex":return function(t){try{return new RegExp(t)}catch(e){s.jf.error(`Invalid regex in the remote configuration: '${t}'`)}}(t.value);default:return void s.jf.error(`Unsupported remote configuration: "rcSerializedType": "${e}"`)}}return(0,n.Q8)(t,c)}return t}},5747:(t,e,i)=>{"use strict";if(i.d(e,{z:()=>o}),179==i.j)var s=i(9647);if(179==i.j)var n=i(9643);if(179==i.j)var r=i(9744);const a="datadog-ci-visibility-test-execution-id";function o(t,e,i=(0,r.k)(t,a)){var o;let l=(0,s.OC)(a)||(null===(o=window.Cypress)||void 0===o?void 0:o.env("traceId"));const c=i.subscribe((t=>{l=t}));return e.register(0,(({eventType:t})=>"string"!=typeof l?n.kb:{type:t,session:{type:"ci_test"},ci_test:{test_execution_id:l}})),{stop:()=>{c.unsubscribe()}}}},3583:(t,e,i)=>{"use strict";if(i.d(e,{d:()=>n}),179==i.j)var s=i(8826);function n(t){t.register(0,(({eventType:t})=>({type:t,connectivity:(0,s.T)()})))}},1545:(t,e,i)=>{"use strict";if(i.d(e,{Y:()=>a}),179==i.j)var s=i(5026);if(179==i.j)var n=i(3603);if(179==i.j)var r=i(6876);function a(t,e,i){t.register(0,(({eventType:t})=>({type:t,_dd:{format_version:2,drift:(0,s.QA)(),configuration:{session_sample_rate:(0,n.NM)(e.sessionSampleRate,3),session_replay_sample_rate:(0,n.NM)(e.sessionReplaySampleRate,3),profiling_sample_rate:(0,n.NM)(e.profilingSampleRate,3)},browser_sdk_version:(0,r.xT)()?"6.18.1":void 0,sdk_name:i},application:{id:e.applicationId},date:(0,s.n$)(),source:"browser"}))),t.register(1,(()=>({application:{id:e.applicationId}})))}},354:(t,e,i)=>{"use strict";if(i.d(e,{Z:()=>r}),179==i.j)var s=i(4933);if(179==i.j)var n=i(5788);function r(t,e){let i;const r=requestAnimationFrame((0,s.zk)((()=>{i=(0,n.PA)()}))),a=(0,n.AX)(e).subscribe((t=>{i=t})).unsubscribe;return t.register(0,(({eventType:t})=>({type:t,display:i?{viewport:i}:void 0}))),{stop:()=>{a(),r&&cancelAnimationFrame(r)}}}},1762:(t,e,i)=>{"use strict";function s(t,e,i,s,n){return{get:r=>{const a=i.findView(r),o=n.findUrl(r),l=e.findTrackedSession(r);if(l&&a&&o){const e=s.findActionId(r);return{application_id:t,session_id:l.id,user_action:e?{id:e}:void 0,view:{id:a.id,name:a.name,referrer:o.referrer,url:o.url}}}}}}i.d(e,{A:()=>s})},4208:(t,e,i)=>{"use strict";if(i.d(e,{E:()=>r}),179==i.j)var s=i(9262);if(179==i.j)var n=i(9643);function r(t){t.register(0,(({eventType:t})=>(0,s.m)()?{type:t,session:{type:"synthetics"},synthetics:{test_id:(0,s.L7)(),result_id:(0,s.QB)(),injected:(0,s.Y9)()}}:n.kb))}},2582:(t,e,i)=>{"use strict";if(i.d(e,{I:()=>n}),179==i.j)var s=i(9643);function n(t,e){t.register(1,(()=>e.isGranted()?s.kb:s.C_))}},6593:(t,e,i)=>{"use strict";if(i.d(e,{Y:()=>l}),179==i.j)var s=i(8981);if(179==i.j)var n=i(9029);if(179==i.j)var r=i(5026);if(179==i.j)var a=i(9643);const o=179==i.j?s.TN:null;function l(t,e,i,s){const l=(0,n.p)({expireDelay:o});let c;t.subscribe(1,(({startClocks:t})=>{const e=s.href;l.add(d({url:e,referrer:c||document.referrer}),t.relative),c=e})),t.subscribe(6,(({endClocks:t})=>{l.closeActive(t.relative)}));const u=i.subscribe((({newLocation:t})=>{const e=l.find();if(e){const i=(0,r._q)();l.closeActive(i),l.add(d({url:t.href,referrer:e.referrer}),i)}}));function d({url:t,referrer:e}){return{url:t,referrer:e}}return e.register(0,(({startTime:t,eventType:e})=>{const i=l.find(t);return i?{type:e,view:{url:i.url,referrer:i.referrer}}:a.C_})),{findUrl:t=>l.find(t),stop:()=>{u.unsubscribe(),l.stop()}}}},1503:(t,e,i)=>{"use strict";if(i.d(e,{O:()=>a}),179==i.j)var s=i(8981);if(179==i.j)var n=i(9029);const r=179==i.j?s.TN:null;function a(t){const e=(0,n.p)({expireDelay:r});return t.subscribe(1,(t=>{e.add(function(t){return{service:t.service,version:t.version,context:t.context,id:t.id,name:t.name,startClocks:t.startClocks}}(t),t.startClocks.relative)})),t.subscribe(6,(({endClocks:t})=>{e.closeActive(t.relative)})),t.subscribe(3,(t=>{const i=e.find(t.startClocks.relative);i&&(t.name&&(i.name=t.name),t.context&&(i.context=t.context),i.sessionIsActive=t.sessionIsActive)})),t.subscribe(10,(()=>{e.reset()})),{findView:t=>e.find(t),stop:()=>{e.stop()}}}},8748:(t,e,i)=>{"use strict";if(i.d(e,{J:()=>n}),179==i.j)var s=i(3603);function n(t){return(0,s.hj)(t)&&t<0?void 0:t}},8455:(t,e,i)=>{"use strict";if(i.d(e,{U:()=>r}),179==i.j)var s=i(6296);if(179==i.j)var n=i(3842);function r(t){const e=(0,s.a)([n.vA.error]).subscribe((e=>t.notify(e.error)));return{stop:()=>{e.unsubscribe()}}}},1939:(t,e,i)=>{"use strict";if(i.d(e,{x:()=>n}),179==i.j)var s=i(3670);function n(t,e){const i=(0,s.v)(t,[s._.cspViolation,s._.intervention]).subscribe((t=>e.notify(t)));return{stop:()=>{i.unsubscribe()}}}},2475:(t,e,i)=>{"use strict";if(i.d(e,{G:()=>n}),179==i.j)var s=i(3909);function n(t,{session:e,viewContext:i,errorType:n}){const r=e?e.id:"no-session-id",a=[];void 0!==n&&a.push(`error-type=${n}`),i&&(a.push(`seed=${i.id}`),a.push(`from=${i.startClocks.timeStamp}`));const o=function(t){const e=t.site,i=t.subdomain||function(t){switch(t.site){case s.D_:case s.Ds:return"app";case s.DZ:return"dd";default:return}}(t);return`https://${i?`${i}.`:""}${e}`}(t);return`${o}/rum/replay/sessions/${r}?${a.join("&")}`}},769:(t,e,i)=>{"use strict";if(i.d(e,{H:()=>n}),179==i.j)var s=i(9643);const n=179==i.j?s.uR:null},5689:(t,e,i)=>{"use strict";if(i.d(e,{j:()=>n}),179==i.j)var s=i(9307);const n=179==i.j?s.l:null},1802:(t,e,i)=>{"use strict";if(i.d(e,{O:()=>o}),179==i.j)var s=i(2904);if(179==i.j)var n=i(4776);if(179==i.j)var r=i(3234);if(179==i.j)var a=i(8566);function o(t,e,i){const r=(0,s.I8)(t),a=i(r);return(0,n.qP)(e).forEach((([e,i])=>l(t,r,e.split(/\.|(?=\[\])/),i))),a}function l(t,e,i,s){const[n,...o]=i;if("[]"!==n){if(c(t)&&c(e))return o.length>0?l(t[n],e[n],o,s):void function(t,e,i,s){const n=(0,r.o)(i);n===s?t[e]=(0,a.N)(i):"object"!==s||"undefined"!==n&&"null"!==n||(t[e]={})}(t,n,e[n],s)}else Array.isArray(t)&&Array.isArray(e)&&t.forEach(((t,i)=>l(t,e[i],o,s)))}function c(t){return"object"===(0,r.o)(t)}},604:(t,e,i)=>{"use strict";function s(t,e,i){if(t)for(const s of t){const t=s[e];t&&t(i)}}i.d(e,{n:()=>s})},7655:(t,e,i)=>{"use strict";if(i.d(e,{t:()=>r}),179==i.j)var s=i(7198);const n=1e3;function r(t){const e=new Set,i=t.subscribe(8,(t=>{e.add(t),e.size>n&&((0,s.eJ)("Too many requests"),e.delete(e.values().next().value))}));return{getMatchingRequest(t){let i,s=1/0;for(const n of e){const e=t.startTime-n.startClocks.relative;0<=e&&e{"use strict";if(i.d(e,{j5:()=>u,oi:()=>c}),179==i.j)var s=i(5135);if(179==i.j)var n=i(6876);if(179==i.j)var r=i(251);if(179==i.j)var a=i(3473);if(179==i.j)var o=i(3603);const l="rum";function c(t,e,i){const n=(0,s.HX)(t,l,(e=>function(t,e){return"0"===(i=e)||"1"===i||"2"===i?e:(0,o.y7)(t.sessionSampleRate)?(0,o.y7)(t.sessionReplaySampleRate)?"1":"2":"0";var i}(t,e)),i);return n.expireObservable.subscribe((()=>{e.notify(9)})),n.renewObservable.subscribe((()=>{e.notify(10)})),n.sessionStateUpdateObservable.subscribe((({previousState:t,newState:e})=>{if(!t.forcedReplay&&e.forcedReplay){const t=n.findSession();t&&(t.isReplayForced=!0)}})),{findTrackedSession:t=>{const e=n.findSession(t);if(e&&"0"!==e.trackingType)return{id:e.id,sessionReplay:"1"===e.trackingType?1:e.isReplayForced?2:0,anonymousId:e.anonymousId}},expire:n.expire,expireObservable:n.expireObservable,setForcedReplay:()=>n.updateSessionState({forcedReplay:"1"})}}function u(){const t={id:"00000000-aaaa-0000-aaaa-000000000000",sessionReplay:(0,n.ke)("records")?1:0};return{findTrackedSession:()=>t,expire:r.Z,expireObservable:new a.y$,setForcedReplay:r.Z}}},1601:(t,e,i)=>{"use strict";function s(){return r(64)}function n(){return r(63)}function r(t){const e=crypto.getRandomValues(new Uint32Array(2));return 63===t&&(e[e.length-1]>>>=1),{toString(t=10){let i=e[1],s=e[0],n="";do{const e=i%t*4294967296+s;i=Math.floor(i/t),s=Math.floor(e/t),n=(e%t).toString(t)+n}while(i||s);return n}}}function a(t){return t.toString(16).padStart(16,"0")}i.d(e,{LV:()=>s,Nu:()=>n,vz:()=>a})},9725:(t,e,i)=>{"use strict";if(i.d(e,{T:()=>n}),179==i.j)var s=i(3206);function n(t,e){const{stop:i}=(0,s.O)(t,window,"pageshow",(t=>{t.persisted&&e(t)}),{capture:!0});return i}},5533:(t,e,i)=>{"use strict";i.d(e,{S:()=>n});const s=(t,e)=>t*e,n=t=>s(t.previousRect.width,t.previousRect.height)+s(t.currentRect.width,t.currentRect.height)-((t,e)=>{const i=Math.max(t.left,e.left),n=Math.max(t.top,e.top),r=Math.min(t.right,e.right),a=Math.min(t.bottom,e.bottom);return i>=r||n>=a?0:s(r-i,a-n)})(t.previousRect,t.currentRect)},4408:(t,e,i)=>{"use strict";if(i.d(e,{j:()=>o}),179==i.j)var s=i(3603);if(179==i.j)var n=i(251);if(179==i.j)var r=i(7198);const a="Initial view metrics";function o(t,e,i){if(!i.enabled||!(0,s.y7)(t.initialViewMetricsTelemetrySampleRate))return{stop:n.Z};const{unsubscribe:o}=e.subscribe(4,(({initialViewMetrics:t})=>{var e,i;t.largestContentfulPaint&&t.navigationTimings&&((0,r.qZ)(a,{metrics:(e=t.largestContentfulPaint,i=t.navigationTimings,{lcp:{value:e.value},navigation:{domComplete:i.domComplete,domContentLoaded:i.domContentLoaded,domInteractive:i.domInteractive,firstByte:i.firstByte,loadEvent:i.loadEvent}})}),o())}));return{stop:o}}},1358:(t,e,i)=>{"use strict";if(i.d(e,{_X:()=>d}),179==i.j)var s=i(5026);if(179==i.j)var n=i(3473);if(179==i.j)var r=i(251);if(179==i.j)var a=i(4933);if(179==i.j)var o=i(3206);if(179==i.j)var l=i(247);if(179==i.j)var c=i(5788);const u=179==i.j?s.WT:null;function d(t,e,i,d=function(t,e=u){return new n.y$((i=>{if(window.ResizeObserver){const s=(0,r.P)((function(){i.notify(function(){const t=(0,l.X)(),{height:e}=(0,c.PA)();return{scrollHeight:Math.round((document.scrollingElement||document.documentElement).scrollHeight),scrollDepth:Math.round(e+t),scrollTop:t}}())}),e,{leading:!1,trailing:!0}),n=document.scrollingElement||document.documentElement,u=new ResizeObserver((0,a.zk)(s.throttled));n&&u.observe(n);const d=(0,o.O)(t,window,"scroll",s.throttled,{passive:!0});return()=>{s.cancel(),u.disconnect(),d.stop()}}}))}(t)){let h=0,f=0,p=0;const g=d.subscribe((({scrollDepth:t,scrollTop:n,scrollHeight:r})=>{let a=!1;if(t>h&&(h=t,a=!0),r>f){f=r;const t=(0,s._q)();p=(0,s._J)(e.relative,t),a=!0}a&&i({maxDepth:Math.min(h,f),maxDepthScrollTop:n,maxScrollHeight:f,maxScrollHeightTime:p})}));return{stop:()=>g.unsubscribe()}}},782:(t,e,i)=>{"use strict";i.d(e,{Us:()=>b,Xn:()=>te,k6:()=>Zt,zx:()=>Wt,$n:()=>Xt,nw:()=>Jt,D$:()=>m,uo:()=>Nt,YO:()=>Te,Uo:()=>Gt.Uo,q5:()=>et.q,IE:()=>ie,SZ:()=>ne,Ow:()=>Gt.Ow,$1:()=>Ts.$,X_:()=>Ts.X,Gm:()=>Ss.G,FB:()=>le,PA:()=>Es.PA,Sn:()=>Gt.Sn,AX:()=>Es.AX,aT:()=>Gt.aT,VO:()=>Gt.VO,HR:()=>V,_r:()=>Q,Ch:()=>se,Pu:()=>Rt,gR:()=>re,iB:()=>_s,wM:()=>jt});var s=i(2988),n=i(5673),r=i(3895),a=i(4933),o=i(7198),l=i(8678),c=i(2904),u=i(4507),d=i(8566),h=i(5026),f=i(1214),p=i(254),g=i(2799);const m={ACTION:"action",ERROR:"error",LONG_TASK:"long_task",VIEW:"view",RESOURCE:"resource",VITAL:"vital"},y={LONG_TASK:"long-task",LONG_ANIMATION_FRAME:"long-animation-frame"},v={INITIAL_LOAD:"initial_load",ROUTE_CHANGE:"route_change",BF_CACHE:"bf_cache"},b={CLICK:"click",CUSTOM:"custom"},_={RAGE_CLICK:"rage_click",ERROR_CLICK:"error_click",DEAD_CLICK:"dead_click"},E={DURATION:"duration"};var T=i(8129);function S({vitalsByName:t,vitalsByReference:e},i,s={}){const n={name:i,startClocks:(0,h.$I)(),context:s.context,description:s.description},r={__dd_vital_reference:!0};return t.set(i,n),e.set(r,n),r}function k(t,{vitalsByName:e,vitalsByReference:i},s,n={}){const r="string"==typeof s?e.get(s):i.get(s);r&&(t(function(t,e,i,s){var n;return{name:t.name,type:E.DURATION,startClocks:e,duration:(0,h._J)(e.timeStamp,s.timeStamp),context:(0,c.$e)(t.context,i.context),description:null!==(n=i.description)&&void 0!==n?n:t.description}}(r,r.startClocks,n,(0,h.$I)())),"string"==typeof s?e.delete(s):i.delete(s))}var w=i(604),A=i(8783),R=i(3127),L=i(2027),I=i(9598),C=i(6876),D=i(3842),x=i(251),P=i(8679),O=i(7549),N=i(9262),M=i(7063),F=i(3603),$=i(4162),U=i(5562),B=i(3234),j=i(4776);const G=new Map;function V(t,e){if(100===e)return!0;if(0===e)return!1;const i=G.get(e);if(i&&t===i.sessionId)return i.decision;let s;return s=window.BigInt?function(t,e){const i=BigInt("1111111111111111111"),s=BigInt("0x10000000000000000");return Number(t*i%s)<=e/100*Number(s)}(BigInt(`0x${t.split("-")[4]}`),e):(0,F.y7)(e),G.set(e,{sessionId:t,decision:s}),s}var H=i(1601);function K(t){0!==t.status||t.isAborted||(t.traceId=void 0,t.spanId=void 0,t.traceSampled=void 0)}function Y(t,e,i,s,n,r){const a=i.findTrackedSession();if(!a)return;const o=t.allowedTracingUrls.find((t=>(0,U.v)([t.match],e.url,!0)));if(!o)return;const l=V(a.id,t.traceSampleRate);(l||t.traceContextInjection===M.tg.ALL)&&(e.traceSampled=l,e.traceId=(0,H.LV)(),e.spanId=(0,H.Nu)(),r(function(t,e,i,s,n,r,a,o){const l={};if(n.forEach((s=>{switch(s){case"datadog":Object.assign(l,{"x-datadog-origin":"rum","x-datadog-parent-id":e.toString(),"x-datadog-sampling-priority":i?"1":"0","x-datadog-trace-id":t.toString()});break;case"tracecontext":Object.assign(l,{traceparent:`00-0000000000000000${(0,H.vz)(t)}-${(0,H.vz)(e)}-0${i?"1":"0"}`,tracestate:`dd=s:${i?"1":"0"};o:rum`});break;case"b3":Object.assign(l,{b3:`${(0,H.vz)(t)}-${(0,H.vz)(e)}-${i?"1":"0"}`});break;case"b3multi":Object.assign(l,{"X-B3-TraceId":(0,H.vz)(t),"X-B3-SpanId":(0,H.vz)(e),"X-B3-Sampled":i?"1":"0"})}})),o.propagateTraceBaggage){const t={"session.id":s},e=r.getContext().id;"string"==typeof e&&(t["user.id"]=e);const i=a.getContext().id;"string"==typeof i&&(t["account.id"]=i);const n=Object.entries(t).map((([t,e])=>`${t}=${encodeURIComponent(e)}`)).join(",");n&&(l.baggage=n)}return l}(e.traceId,e.spanId,e.traceSampled,a.id,o.propagatorTypes,s,n,t)))}const q=["tracecontext","datadog"];function z(t){const e=new Set;return Array.isArray(t.allowedTracingUrls)&&t.allowedTracingUrls.length>0&&t.allowedTracingUrls.forEach((t=>{(0,U.o)(t)?q.forEach((t=>e.add(t))):"object"===(0,B.o)(t)&&Array.isArray(t.propagatorTypes)&&t.propagatorTypes.forEach((t=>e.add(t)))})),Array.from(e)}var W=i(1093);function X({ignoreInitIfSyntheticsWillInjectRum:t=!0,startDeflateWorker:e},i,s,n){const r=(0,A.D)(),l=(0,R.N)();J(l,p.g.globalContext,r);const c=(0,L.f)();J(c,p.g.userContext,r);const u=(0,I.d)();let d,f,m,y;J(u,p.g.accountContext,r);const v=i.observable.subscribe(_),b={};function _(){if(!m||!y||!i.isGranted())return;let t;if(v.unsubscribe(),y.trackViewsManually){if(!d)return;r.remove(d.callback),t=d.options}const e=n(y,f,t);r.drain(e)}function E(t){const s=(0,C.xT)();if(s&&(t=function(t){var e,i;return{...t,applicationId:"00000000-aaaa-0000-aaaa-000000000000",clientToken:"empty",sessionSampleRate:100,defaultPrivacyLevel:null!==(e=t.defaultPrivacyLevel)&&void 0!==e?e:null===(i=(0,C.Ad)())||void 0===i?void 0:i.getPrivacyLevel()}}(t)),m=t,(0,o.Uo)(function(t){var e;const i=(0,M.JZ)(t);return{session_replay_sample_rate:t.sessionReplaySampleRate,start_session_replay_recording_manually:t.startSessionReplayRecordingManually,trace_sample_rate:t.traceSampleRate,trace_context_injection:t.traceContextInjection,action_name_attribute:t.actionNameAttribute,use_allowed_tracing_urls:Array.isArray(t.allowedTracingUrls)&&t.allowedTracingUrls.length>0,selected_tracing_propagators:z(t),default_privacy_level:t.defaultPrivacyLevel,enable_privacy_for_action_name:t.enablePrivacyForActionName,use_excluded_activity_urls:Array.isArray(t.excludedActivityUrls)&&t.excludedActivityUrls.length>0,use_worker_url:!!t.workerUrl,compress_intake_requests:t.compressIntakeRequests,track_views_manually:t.trackViewsManually,track_user_interactions:t.trackUserInteractions,track_resources:t.trackResources,track_long_task:t.trackLongTasks,track_bfcache_views:t.trackBfcacheViews,plugins:null===(e=t.plugins)||void 0===e?void 0:e.map((t=>{var e;return{name:t.name,...null===(e=t.getConfigurationTelemetry)||void 0===e?void 0:e.call(t)}})),track_feature_flags_for_events:t.trackFeatureFlagsForEvents,...i}}(t)),y)return void(0,g.W)("DD_RUM",t);const n=function(t){var e,i,s,n,r,a,o;if(void 0===t.trackFeatureFlagsForEvents||Array.isArray(t.trackFeatureFlagsForEvents)||D.jf.warn("trackFeatureFlagsForEvents should be an array"),!t.applicationId)return void D.jf.error("Application ID is not configured, no RUM data will be collected.");if(!(0,M.RJ)(t.sessionReplaySampleRate,"Session Replay")||!(0,M.RJ)(t.traceSampleRate,"Trace"))return;if(void 0!==t.excludedActivityUrls&&!Array.isArray(t.excludedActivityUrls))return void D.jf.error("Excluded Activity Urls should be an array");const l=function(t){if(void 0===t.allowedTracingUrls)return[];if(!Array.isArray(t.allowedTracingUrls))return void D.jf.error("Allowed Tracing URLs should be an array");if(0!==t.allowedTracingUrls.length&&void 0===t.service)return void D.jf.error("Service needs to be configured when tracing is enabled");const e=[];return t.allowedTracingUrls.forEach((t=>{(0,U.o)(t)?e.push({match:t,propagatorTypes:q}):function(t){const e=t;return"object"===(0,B.o)(e)&&(0,U.o)(e.match)&&Array.isArray(e.propagatorTypes)}(t)?e.push(t):D.jf.warn("Allowed Tracing Urls parameters should be a string, RegExp, function, or an object. Ignoring parameter",t)})),e}(t);if(!l)return;const c=(0,M.fP)(t);if(!c)return;const u=null!==(e=t.sessionReplaySampleRate)&&void 0!==e?e:0;return{applicationId:t.applicationId,actionNameAttribute:t.actionNameAttribute,sessionReplaySampleRate:u,startSessionReplayRecordingManually:void 0!==t.startSessionReplayRecordingManually?!!t.startSessionReplayRecordingManually:0===u,traceSampleRate:null!==(i=t.traceSampleRate)&&void 0!==i?i:100,rulePsr:(0,F.hj)(t.traceSampleRate)?t.traceSampleRate/100:void 0,allowedTracingUrls:l,excludedActivityUrls:null!==(s=t.excludedActivityUrls)&&void 0!==s?s:[],workerUrl:t.workerUrl,compressIntakeRequests:!!t.compressIntakeRequests,trackUserInteractions:!(null!==(n=t.trackUserInteractions)&&void 0!==n&&!n),trackViewsManually:!!t.trackViewsManually,trackResources:!(null!==(r=t.trackResources)&&void 0!==r&&!r),trackLongTasks:!(null!==(a=t.trackLongTasks)&&void 0!==a&&!a),trackBfcacheViews:!!t.trackBfcacheViews,subdomain:t.subdomain,defaultPrivacyLevel:(0,$.E5)(M.Jj,t.defaultPrivacyLevel)?t.defaultPrivacyLevel:M.Jj.MASK,enablePrivacyForActionName:!!t.enablePrivacyForActionName,customerDataTelemetrySampleRate:1,initialViewMetricsTelemetrySampleRate:1,replayTelemetrySampleRate:1,traceContextInjection:(0,$.E5)(M.tg,t.traceContextInjection)?t.traceContextInjection:M.tg.SAMPLED,plugins:t.plugins||[],trackFeatureFlagsForEvents:t.trackFeatureFlagsForEvents||[],profilingSampleRate:null!==(o=t.profilingSampleRate)&&void 0!==o?o:0,propagateTraceBaggage:!!t.propagateTraceBaggage,...c}}(t);n&&(s||n.sessionStoreStrategyType?n.compressIntakeRequests&&!s&&e&&(f=e(n,"Datadog RUM",x.Z),!f)||(y=n,(0,P.y)().subscribe(x.Z),i.tryToInit(n.trackingConsent),_()):D.jf.warn("No storage available for session. We will not send any data."))}const T=t=>{r.add((e=>e.addDurationVital(t)))};return{init(e,i){e?((0,O.fG)(e.enableExperimentalFeatures),m=e,t&&(0,N.Y9)()||((0,w.n)(e.plugins,"onInit",{initConfiguration:e,publicApi:i}),e.remoteConfigurationId?(0,W.ir)(e).then((t=>{t&&E(t)})).catch(a.$y):E(e))):D.jf.error("Missing configuration")},get initConfiguration(){return m},getInternalContext:x.Z,stopSession:x.Z,addTiming(t,e=(0,h.n$)()){r.add((i=>i.addTiming(t,e)))},startView(t,e=(0,h.$I)()){const i=i=>{i.startView(t,e)};r.add(i),d||(d={options:t,callback:i},_())},setViewName(t){r.add((e=>e.setViewName(t)))},setViewContext(t){r.add((e=>e.setViewContext(t)))},setViewContextProperty(t,e){r.add((i=>i.setViewContextProperty(t,e)))},getViewContext:()=>b,globalContext:l,userContext:c,accountContext:u,addAction(t){r.add((e=>e.addAction(t)))},addError(t){r.add((e=>e.addError(t)))},addFeatureFlagEvaluation(t,e){r.add((i=>i.addFeatureFlagEvaluation(t,e)))},startDurationVital:(t,e)=>S(s,t,e),stopDurationVital(t,e){k(T,s,t,e)},addDurationVital:T}}function J(t,e,i){t.changeObservable.subscribe((()=>{const s=t.getContext();i.add((t=>t[e].setContext(s)))}))}function Q(t,e,i,m={}){const y=(0,s.H)(),v={vitalsByName:new Map,vitalsByReference:new WeakMap},_=(0,n.Q)().observable;let T=X(m,y,v,((s,n,a)=>{const o=t(s,e,i,a,n&&m.createDeflateEncoder?t=>m.createDeflateEncoder(s,n,t):r.G,y,v,_,m.sdkName);return e.onRumStart(o.lifeCycle,s,o.session,o.viewHistory,n,o.telemetry),i.onRumStart(o.lifeCycle,o.hooks,s,o.session,o.viewHistory),T=function(t,e){return{init:t=>{(0,g.W)("DD_RUM",t)},initConfiguration:t.initConfiguration,...e}}(T,o),(0,w.n)(s.plugins,"onRumStart",{strategy:T,addEvent:o.addEvent}),o}));const S=()=>T,k=(0,a.zk)((t=>{const e="object"==typeof t?t:{name:t};T.startView(e),(0,o.eG)({feature:"start-view"})})),A=(0,l.r)({init:(0,a.zk)((t=>{T.init(t,A)})),setTrackingConsent:(0,a.zk)((t=>{y.update(t),(0,o.eG)({feature:"set-tracking-consent",tracking_consent:t})})),setViewName:(0,a.zk)((t=>{T.setViewName(t),(0,o.eG)({feature:"set-view-name"})})),setViewContext:(0,a.zk)((t=>{T.setViewContext(t),(0,o.eG)({feature:"set-view-context"})})),setViewContextProperty:(0,a.zk)(((t,e)=>{T.setViewContextProperty(t,e),(0,o.eG)({feature:"set-view-context-property"})})),getViewContext:(0,a.zk)((()=>((0,o.eG)({feature:"set-view-context-property"}),T.getViewContext()))),getInternalContext:(0,a.zk)((t=>T.getInternalContext(t))),getInitConfiguration:(0,a.zk)((()=>(0,c.I8)(T.initConfiguration))),addAction:(t,e)=>{const i=(0,u.Xp)("action");(0,a.L6)((()=>{T.addAction({name:(0,d.N)(t),context:(0,d.N)(e),startClocks:(0,h.$I)(),type:b.CUSTOM,handlingStack:i}),(0,o.eG)({feature:"add-action"})}))},addError:(t,e)=>{const i=(0,u.Xp)("error");(0,a.L6)((()=>{T.addError({error:t,handlingStack:i,context:(0,d.N)(e),startClocks:(0,h.$I)()}),(0,o.eG)({feature:"add-error"})}))},addTiming:(0,a.zk)(((t,e)=>{T.addTiming((0,d.N)(t),e)})),setGlobalContext:(0,f.z)(S,p.g.globalContext,p.O.setContext,"set-global-context"),getGlobalContext:(0,f.z)(S,p.g.globalContext,p.O.getContext,"get-global-context"),setGlobalContextProperty:(0,f.z)(S,p.g.globalContext,p.O.setContextProperty,"set-global-context-property"),removeGlobalContextProperty:(0,f.z)(S,p.g.globalContext,p.O.removeContextProperty,"remove-global-context-property"),clearGlobalContext:(0,f.z)(S,p.g.globalContext,p.O.clearContext,"clear-global-context"),setUser:(0,f.z)(S,p.g.userContext,p.O.setContext,"set-user"),getUser:(0,f.z)(S,p.g.userContext,p.O.getContext,"get-user"),setUserProperty:(0,f.z)(S,p.g.userContext,p.O.setContextProperty,"set-user-property"),removeUserProperty:(0,f.z)(S,p.g.userContext,p.O.removeContextProperty,"remove-user-property"),clearUser:(0,f.z)(S,p.g.userContext,p.O.clearContext,"clear-user"),setAccount:(0,f.z)(S,p.g.accountContext,p.O.setContext,"set-account"),getAccount:(0,f.z)(S,p.g.accountContext,p.O.getContext,"get-account"),setAccountProperty:(0,f.z)(S,p.g.accountContext,p.O.setContextProperty,"set-account-property"),removeAccountProperty:(0,f.z)(S,p.g.accountContext,p.O.removeContextProperty,"remove-account-property"),clearAccount:(0,f.z)(S,p.g.accountContext,p.O.clearContext,"clear-account"),startView:k,stopSession:(0,a.zk)((()=>{T.stopSession(),(0,o.eG)({feature:"stop-session"})})),addFeatureFlagEvaluation:(0,a.zk)(((t,e)=>{T.addFeatureFlagEvaluation((0,d.N)(t),(0,d.N)(e)),(0,o.eG)({feature:"add-feature-flag-evaluation"})})),getSessionReplayLink:(0,a.zk)((()=>e.getSessionReplayLink())),startSessionReplayRecording:(0,a.zk)((t=>{e.start(t),(0,o.eG)({feature:"start-session-replay-recording",force:t&&t.force})})),stopSessionReplayRecording:(0,a.zk)((()=>e.stop())),addDurationVital:(0,a.zk)(((t,e)=>{(0,o.eG)({feature:"add-duration-vital"}),T.addDurationVital({name:(0,d.N)(t),type:E.DURATION,startClocks:(0,h.lO)(e.startTime),duration:e.duration,context:(0,d.N)(e&&e.context),description:(0,d.N)(e&&e.description)})})),startDurationVital:(0,a.zk)(((t,e)=>((0,o.eG)({feature:"start-duration-vital"}),T.startDurationVital((0,d.N)(t),{context:(0,d.N)(e&&e.context),description:(0,d.N)(e&&e.description)})))),stopDurationVital:(0,a.zk)(((t,e)=>{(0,o.eG)({feature:"stop-duration-vital"}),T.stopDurationVital("string"==typeof t?(0,d.N)(t):t,{context:(0,d.N)(e&&e.context),description:(0,d.N)(e&&e.description)})}))});return A}var Z=i(8971),tt=i(7581),et=i(4250),it=i(4967),st=i(1762),nt=i(5689),rt=i(1503),at=i(5343),ot=i(8300),lt=i(9100),ct=i(8057),ut=i(170),dt=i(5039);const ht="initial_document",ft=[[ot._.DOCUMENT,t=>ht===t],[ot._.XHR,t=>"xmlhttprequest"===t],[ot._.FETCH,t=>"fetch"===t],[ot._.BEACON,t=>"beacon"===t],[ot._.CSS,(t,e)=>/\.css$/i.test(e)],[ot._.JS,(t,e)=>/\.js$/i.test(e)],[ot._.IMAGE,(t,e)=>["image","img","icon"].includes(t)||null!==/\.(gif|jpg|jpeg|tiff|png|svg|ico)$/i.exec(e)],[ot._.FONT,(t,e)=>null!==/\.(woff|eot|woff2|ttf)$/i.exec(e)],[ot._.MEDIA,(t,e)=>["audio","video"].includes(t)||null!==/\.(mp3|mp4)$/i.exec(e)]];function pt(t){const e=t.name;if(!(0,ut.jv)(e))return(0,o.eJ)(`Failed to construct URL for "${t.name}"`),ot._.OTHER;const i=(0,ut.ye)(e);for(const[e,s]of ft)if(s(t.initiatorType,i))return e;return ot._.OTHER}function gt(...t){for(let e=1;et[e])return!1;return!0}function mt(t){return"xmlhttprequest"===t.initiatorType||"fetch"===t.initiatorType}function yt(t){if(!bt(t))return;const{startTime:e,fetchStart:i,workerStart:s,redirectStart:n,redirectEnd:r,domainLookupStart:a,domainLookupEnd:o,connectStart:l,secureConnectionStart:c,connectEnd:u,requestStart:d,responseStart:h,responseEnd:f}=t,p={download:_t(e,h,f),first_byte:_t(e,d,h)};return 0=0}function bt(t){const e=gt(t.startTime,t.fetchStart,t.domainLookupStart,t.domainLookupEnd,t.connectStart,t.connectEnd,t.requestStart,t.responseStart,t.responseEnd),i=!function(t){return t.redirectEnd>t.startTime}(t)||gt(t.startTime,t.redirectStart,t.redirectEnd,t.fetchStart);return e&&i}function _t(t,e,i){if(t<=e&&e<=i)return{duration:(0,h.c0)((0,h._J)(e,i)),start:(0,h.c0)((0,h._J)(t,e))}}function Et(t){return""===t.nextHopProtocol?void 0:t.nextHopProtocol}function Tt(t){return""===t.deliveryType?"other":t.deliveryType}function St(t){if(t.startTime{var n;if("view"!==t.type&&"vital"!==t.type&&e(t))switch(t.type){case m.ERROR:s.errorCount+=1,i();break;case m.ACTION:s.actionCount+=1,t.action.frustration&&(s.frustrationCount+=t.action.frustration.type.length),i();break;case m.LONG_TASK:s.longTaskCount+=1,i();break;case m.RESOURCE:(null===(n=t._dd)||void 0===n?void 0:n.discarded)||(s.resourceCount+=1,i())}}));return{stop:()=>{n.unsubscribe()},eventCounts:s}}var Nt,Mt=i(5483),Ft=i(3206),$t=i(7569);function Ut(t,e){return new Pt.y$((i=>{if(!window.PerformanceObserver)return;const s=t=>{const e=function(t){return t.filter((t=>!function(t){return!(t.entryType!==Nt.RESOURCE||kt(t.name)&&vt(t))}(t)))}(t);e.length>0&&i.notify(e)};let n,r=!0;const o=new PerformanceObserver((0,a.zk)((t=>{r?n=(0,Mt.iK)((()=>s(t.getEntries()))):s(t.getEntries())})));try{o.observe(e)}catch(t){if([Nt.RESOURCE,Nt.NAVIGATION,Nt.LONG_TASK,Nt.PAINT].includes(e.type)){e.buffered&&(n=(0,Mt.iK)((()=>s(performance.getEntriesByType(e.type)))));try{o.observe({entryTypes:[e.type]})}catch(t){return}}}let l;return r=!1,function(t){!Bt&&void 0!==window.performance&&"getEntries"in performance&&"addEventListener"in performance&&(Bt=(0,Ft.O)(t,performance,"resourcetimingbufferfull",(()=>{performance.clearResourceTimings()})))}(t),jt(Nt.FIRST_INPUT)||e.type!==Nt.FIRST_INPUT||({stop:l}=(0,$t.X)(t,(t=>{s([t])}))),()=>{o.disconnect(),l&&l(),(0,Mt.gr)(n)}}))}let Bt;function jt(t){return window.PerformanceObserver&&void 0!==PerformanceObserver.supportedEntryTypes&&PerformanceObserver.supportedEntryTypes.includes(t)}!function(t){t.EVENT="event",t.FIRST_INPUT="first-input",t.LARGEST_CONTENTFUL_PAINT="largest-contentful-paint",t.LAYOUT_SHIFT="layout-shift",t.LONG_TASK="longtask",t.LONG_ANIMATION_FRAME="long-animation-frame",t.NAVIGATION="navigation",t.PAINT="paint",t.RESOURCE="resource",t.VISIBILITY_STATE="visibility-state"}(Nt||(Nt={}));var Gt=i(3644);const Vt=100,Ht=100,Kt="data-dd-excluded-activity-mutations";function Yt(t,e,i,s,n,r){const o=function(t,e,i,s){return new Pt.y$((n=>{const r=[];let a,o=0;return r.push(e.subscribe((t=>{t.every(zt)||l()})),i.subscribe(l),Ut(s,{type:Nt.RESOURCE}).subscribe((t=>{t.some((t=>!qt(s,t.name)))&&l()})),t.subscribe(7,(t=>{qt(s,t.url)||(void 0===a&&(a=t.requestIndex),o+=1,l())})),t.subscribe(8,(t=>{qt(s,t.url)||void 0===a||t.requestIndex{r.forEach((t=>t.unsubscribe()))};function l(){n.notify({isBusy:o>0})}}))}(t,e,i,s);return function(t,e,i){let s,n=!1;const r=(0,Mt.iK)((0,a.zk)((()=>u({hadActivity:!1}))),Vt),o=void 0!==i?(0,Mt.iK)((0,a.zk)((()=>u({hadActivity:!0,end:(0,h.n$)()}))),i):void 0,l=t.subscribe((({isBusy:t})=>{(0,Mt.gr)(r),(0,Mt.gr)(s);const e=(0,h.n$)();t||(s=(0,Mt.iK)((0,a.zk)((()=>u({hadActivity:!0,end:e}))),Ht))})),c=()=>{n=!0,(0,Mt.gr)(r),(0,Mt.gr)(s),(0,Mt.gr)(o),l.unsubscribe()};function u(t){n||(c(),e(t))}return{stop:c}}(o,n,r)}function qt(t,e){return(0,U.v)(t.excludedActivityUrls,e)}function zt(t){const e="characterData"===t.type?t.target.parentElement:t.target;return Boolean(e&&(0,Gt.Tv)(e)&&e.matches(`[${Kt}], [${Kt}] *`))}const Wt={IGNORE:"ignore",HIDDEN:"hidden",ALLOW:M.Jj.ALLOW,MASK:M.Jj.MASK,MASK_USER_INPUT:M.Jj.MASK_USER_INPUT},Xt="data-dd-privacy",Jt="hidden",Qt="dd-privacy-",Zt="***",te="data:image/gif;base64,R0lGODlhAQABAIAAAMLCwgAAACH5BAAAAAAALAAAAAABAAEAAAICRAEAOw==",ee={INPUT:!0,OUTPUT:!0,TEXTAREA:!0,SELECT:!0,OPTION:!0,DATALIST:!0,OPTGROUP:!0};function ie(t,e,i){if(i&&i.has(t))return i.get(t);const s=(0,Gt.Ow)(t),n=s?ie(s,e,i):e,r=se(ne(t),n);return i&&i.set(t,r),r}function se(t,e){switch(e){case Wt.HIDDEN:case Wt.IGNORE:return e}switch(t){case Wt.ALLOW:case Wt.MASK:case Wt.MASK_USER_INPUT:case Wt.HIDDEN:case Wt.IGNORE:return t;default:return e}}function ne(t){if((0,Gt.Tv)(t)){if("BASE"===t.tagName)return Wt.ALLOW;if("INPUT"===t.tagName){const e=t;if("password"===e.type||"email"===e.type||"tel"===e.type)return Wt.MASK;if("hidden"===e.type)return Wt.MASK;const i=e.getAttribute("autocomplete");if(i&&(i.startsWith("cc-")||i.endsWith("-password")))return Wt.MASK}return t.matches(ce(Wt.HIDDEN))?Wt.HIDDEN:t.matches(ce(Wt.MASK))?Wt.MASK:t.matches(ce(Wt.MASK_USER_INPUT))?Wt.MASK_USER_INPUT:t.matches(ce(Wt.ALLOW))?Wt.ALLOW:function(t){if("SCRIPT"===t.nodeName)return!0;if("LINK"===t.nodeName){const t=e("rel");return/preload|prefetch/i.test(t)&&"script"===e("as")||"shortcut icon"===t||"icon"===t}if("META"===t.nodeName){const i=e("name"),s=e("rel"),n=e("property");return/^msapplication-tile(image|color)$/.test(i)||"application-name"===i||"icon"===s||"apple-touch-icon"===s||"shortcut icon"===s||"keywords"===i||"description"===i||/^(og|twitter|fb):/.test(n)||/^(og|twitter):/.test(i)||"pinterest"===i||"robots"===i||"googlebot"===i||"bingbot"===i||t.hasAttribute("http-equiv")||"author"===i||"generator"===i||"framework"===i||"publisher"===i||"progid"===i||/^article:/.test(n)||/^product:/.test(n)||"google-site-verification"===i||"yandex-verification"===i||"csrf-token"===i||"p:domain_verify"===i||"verify-v1"===i||"verification"===i||"shopify-checkout-api-token"===i}function e(e){return(t.getAttribute(e)||"").toLowerCase()}return!1}(t)?Wt.IGNORE:void 0}}function re(t,e){switch(e){case Wt.MASK:case Wt.HIDDEN:case Wt.IGNORE:return!0;case Wt.MASK_USER_INPUT:return(0,Gt.BM)(t)?ae(t.parentNode):ae(t);default:return!1}}function ae(t){if(!t||t.nodeType!==t.ELEMENT_NODE)return!1;const e=t;if("INPUT"===e.tagName)switch(e.type){case"button":case"color":case"reset":case"submit":return!1}return!!ee[e.tagName]}const oe=t=>t.replace(/\S/g,"x");function le(t,e,i){var s;const n=null===(s=t.parentElement)||void 0===s?void 0:s.tagName;let r=t.textContent||"";if(e&&!r.trim())return;const a=i;if("SCRIPT"===n)r=Zt;else if(a===Wt.HIDDEN)r=Zt;else if(re(t,a))if("DATALIST"===n||"SELECT"===n||"OPTGROUP"===n){if(!r.trim())return}else r="OPTION"===n?Zt:oe(r);return r}function ce(t){return`[${Xt}="${t}"], .${Qt}${t}`}const ue="data-dd-action-name",de="Masked Element";function he(t,e){const i=t.closest(`[${e}]`);if(i)return ve(ye(i.getAttribute(e).trim()))}const fe=[(t,e,i)=>{if("labels"in t&&t.labels&&t.labels.length>0)return _e(t.labels[0],e,i)},t=>{if("INPUT"===t.nodeName){const e=t,i=e.getAttribute("type");if("button"===i||"submit"===i||"reset"===i)return{name:e.value,nameSource:"text_content"}}},(t,e,i)=>{if("BUTTON"===t.nodeName||"LABEL"===t.nodeName||"button"===t.getAttribute("role"))return _e(t,e,i)},t=>be(t,"aria-label"),(t,e,i)=>{const s=t.getAttribute("aria-labelledby");if(s)return{name:s.split(/\s+/).map((e=>function(t,e){return t.ownerDocument?t.ownerDocument.getElementById(e):null}(t,e))).filter((t=>Boolean(t))).map((t=>Ee(t,e,i))).join(" "),nameSource:"text_content"}},t=>be(t,"alt"),t=>be(t,"name"),t=>be(t,"title"),t=>be(t,"placeholder"),(t,e,i)=>{if("options"in t&&t.options.length>0)return _e(t.options[0],e,i)}],pe=[(t,e,i)=>_e(t,e,i)],ge=10;function me(t,e,i,s){let n=t,r=0;for(;r<=ge&&n&&"BODY"!==n.nodeName&&"HTML"!==n.nodeName&&"HEAD"!==n.nodeName;){for(const t of i){const i=t(n,e,s);if(i){const{name:t,nameSource:e}=i,s=t&&t.trim();if(s)return{name:ve(ye(s)),nameSource:e}}}if("FORM"===n.nodeName)break;n=n.parentElement,r+=1}}function ye(t){return t.replace(/\s+/g," ")}function ve(t){return t.length>100?`${(0,T._z)(t,100)} [...]`:t}function be(t,e){return{name:t.getAttribute(e)||"",nameSource:"standard_attribute"}}function _e(t,e,i){return{name:Ee(t,e,i)||"",nameSource:"text_content"}}function Ee(t,e,i){if(!t.isContentEditable){if((0,O.W_)(O.uh.USE_TREE_WALKER_FOR_ACTION_NAME))return function(t,e,i){const s=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT,(function(t){if((0,Gt.Tv)(t)){const s=ne(t);if(t.hasAttribute(ue)||e&&t.hasAttribute(e)||i&&s&&re(t,s))return NodeFilter.FILTER_REJECT;const n=getComputedStyle(t);if("visible"!==n.visibility||"none"===n.display||n.contentVisibility&&"visible"!==n.contentVisibility)return NodeFilter.FILTER_REJECT}return NodeFilter.FILTER_ACCEPT}));let n="";for(;s.nextNode();){const t=s.currentNode;(0,Gt.Tv)(t)?("BR"===t.nodeName||"P"===t.nodeName||["block","flex","grid","list-item","table","table-caption"].includes(getComputedStyle(t).display))&&(n+=" "):n+=t.textContent||""}return n.replace(/\s+/g," ").trim()}(t,e,i);if("innerText"in t){let s=t.innerText;const n=e=>{const i=t.querySelectorAll(e);for(let t=0;t0&&(s=s.replace(t,""))}}};return n(`[${ue}]`),e&&n(`[${e}]`),i&&n(`${ce(Wt.HIDDEN)}, ${ce(Wt.MASK)}`),s}return t.textContent}}const Te=[ue,"data-testid","data-test","data-qa","data-cy","data-test-id","data-qa-id","data-testing","data-component","data-element","data-source-file"],Se=[Re,function(t){if(t.id&&!Ae(t.id))return`#${CSS.escape(t.id)}`}],ke=[Re,function(t){if("BODY"===t.tagName)return;const e=t.classList;for(let i=0;it.matches(e);else{const t=xe(`${e}:scope`,i);s=e=>null!==e.querySelector(t)}let n=t.parentElement.firstElementChild;for(;n;){if(n!==t&&s(n))return!1;n=n.nextElementSibling}return!0}function xe(t,e){return e?`${t}>${e}`:t}var Pe=i(6508),Oe=i(8124);const Ne=3;const Me='input:not([type="checkbox"]):not([type="radio"]):not([type="button"]):not([type="submit"]):not([type="reset"]):not([type="range"]),textarea,select,[contenteditable],[contenteditable] *,canvas,a[href],a[href] *';function Fe(t){if(t.hasPageActivity||t.getUserActivity().input||t.getUserActivity().scroll)return!1;let e=t.event.target;return"LABEL"===e.tagName&&e.hasAttribute("for")&&(e=document.getElementById(e.getAttribute("for"))),!e||!e.matches(Me)}const $e=10*h.WT,Ue=new Map;function Be(t,e){Ue.set(t,e),Ue.forEach(((t,e)=>{(0,h._J)(e,(0,h._q)())>$e&&Ue.delete(e)}))}const je=5*h.yR;function Ge(t,e,i,s){const n=(0,xt.p)({expireDelay:je}),r=new Pt.y$;let a;t.subscribe(10,(()=>{n.reset()})),t.subscribe(5,c),t.subscribe(11,(t=>{t.reason===tt.k$.UNLOADING&&c()}));const{stop:o}=(0,Oe.u)(s,{onPointerDown:n=>function(t,e,i,s,n){const r=t.enablePrivacyForActionName?ie(s.target,t.defaultPrivacyLevel):Wt.ALLOW;if(r===Wt.HIDDEN)return;const a=function(t,e,i){const s=t.target.getBoundingClientRect(),n=we(t.target,i.actionNameAttribute);n&&Be(t.timeStamp,n);const r=function(t,{enablePrivacyForActionName:e,actionNameAttribute:i},s=Wt.ALLOW){const n=he(t,ue)||i&&he(t,i);return n?{name:n,nameSource:"custom_attribute"}:s===Wt.MASK?{name:de,nameSource:"mask_placeholder"}:me(t,i,fe,e)||me(t,i,pe,e)||{name:"",nameSource:"blank"}}(t.target,i,e);return{type:b.CLICK,target:{width:Math.round(s.width),height:Math.round(s.height),selector:n},position:{x:Math.round(t.clientX-s.left),y:Math.round(t.clientY-s.top)},name:r.name,nameSource:r.nameSource}}(s,r,t);let o=!1;return Yt(e,i,n,t,(t=>{o=t.hadActivity}),Vt),{clickActionBase:a,hadActivityOnPointerDown:()=>o}}(s,t,e,n,i),onPointerUp:({clickActionBase:a,hadActivityOnPointerDown:o},c,u)=>{!function(t,e,i,s,n,r,a,o,l,c,u){var d;const h=Ve(e,n,c,o,l);a(h);const f=null===(d=null==o?void 0:o.target)||void 0===d?void 0:d.selector;f&&Be(l.timeStamp,f);const{stop:p}=Yt(e,i,s,t,(t=>{t.hadActivity&&t.end{h.stop(t.timeStamp)})),m=r.subscribe((()=>{h.stop()}));h.stopObservable.subscribe((()=>{g.unsubscribe(),p(),m.unsubscribe()}))}(s,t,e,i,n,r,l,a,c,u,o)}});return{stop:()=>{c(),r.notify(),o()},actionContexts:{findActionId:t=>n.findAll(t)}};function l(t){if(!a||!a.tryAppend(t)){const e=t.clone();a=(0,Pe.bl)(t,(t=>{!function(t,e){const{isRage:i}=function(t,e){if(function(t){if(t.some((t=>t.getUserActivity().selection||t.getUserActivity().scroll)))return!1;for(let e=0;et.getUserActivity().selection));return t.forEach((t=>{t.hasError&&t.addFrustration(_.ERROR_CLICK),Fe(t)&&!i&&t.addFrustration(_.DEAD_CLICK)})),{isRage:!1}}(t,e);i?(t.forEach((t=>t.discard())),e.stop((0,h.n$)()),e.validate(t.map((t=>t.event)))):(e.discard(),t.forEach((t=>t.validate())))}(t,e)}))}}function c(){a&&a.stop()}}function Ve(t,e,i,s,n){const r=(0,T.DO)(),a=(0,h.$I)(),o=e.add(r,a.relative),l=Ot({lifeCycle:t,isChildEvent:t=>void 0!==t.action&&(Array.isArray(t.action.id)?t.action.id.includes(r):t.action.id===r)});let c,u=0;const d=[],f=new Pt.y$;function p(t){0===u&&(c=t,u=1,c?o.close((0,h.ni)(c)):o.remove(),l.stop(),f.notify())}return{event:n,stop:p,stopObservable:f,get hasError(){return l.eventCounts.errorCount>0},get hasPageActivity(){return void 0!==c},getUserActivity:i,addFrustration:t=>{d.push(t)},startClocks:a,isStopped:()=>1===u||2===u,clone:()=>Ve(t,e,i,s,n),validate:e=>{if(p(),1!==u)return;const{resourceCount:i,errorCount:o,longTaskCount:f}=l.eventCounts,g={duration:c&&(0,h._J)(a.timeStamp,c),startClocks:a,id:r,frustrationTypes:d,counts:{resourceCount:i,errorCount:o,longTaskCount:f},events:null!=e?e:[n],event:n,...s};t.notify(0,g),u=2},discard:()=>{p(),u=2}}}function He(t){const e=Ke(t)?{action:{id:t.id,loading_time:(0,Dt.J)((0,h.c0)(t.duration)),frustration:{type:t.frustrationTypes},error:{count:t.counts.errorCount},long_task:{count:t.counts.longTaskCount},resource:{count:t.counts.resourceCount}},_dd:{action:{target:t.target,position:t.position,name_source:t.nameSource}}}:{context:t.context},i=(0,c.$e)({action:{id:(0,T.DO)(),target:{name:t.name},type:t.type},date:t.startClocks.timeStamp,type:m.ACTION},e),s=Ke(t)?t.duration:void 0,n=Ke(t)?{events:t.events}:{handlingStack:t.handlingStack};return{rawRumEvent:i,duration:s,startTime:t.startClocks.relative,domainContext:n}}function Ke(t){return t.type!==b.CUSTOM}var Ye=i(5242),qe=i(2419),ze=i(8455),We=i(1939);var Xe=i(49);const Je=new WeakSet;function Qe(t){return(0,h.WK)(t.startTime,t.duration)}var Ze=i(193);const ti=2*h.yR;function ei(t){const e=function(t){const e=t.querySelector("meta[name=dd-trace-id]"),i=t.querySelector("meta[name=dd-trace-time]");return ii(e&&e.content,i&&i.content)}(t)||function(t){const e=function(t){for(let e=0;e=0;e-=1){const i=t.body.childNodes[e],s=si(i);if(s)return s;if(!(0,Gt.BM)(i))break}}(t);if(e)return ii((0,T.MY)(e,"trace-id"),(0,T.MY)(e,"trace-time"))}(t);if(e&&!(e.traceTime<=(0,h.m6)()-ti))return e.traceId}function ii(t,e){const i=e&&Number(e);if(t&&i)return{traceId:t,traceTime:i}}function si(t){if(t&&(0,Gt.dI)(t)){const e=/^\s*DATADOG;(.*?)\s*$/.exec(t.data);if(e)return e[1]}}function ni(){if(jt(Nt.NAVIGATION)){const t=performance.getEntriesByType(Nt.NAVIGATION)[0];if(t)return t}const t=function(){const t={},e=performance.timing;for(const i in e)if((0,F.hj)(e[i])){const s=i,n=e[s];t[s]=0===n?0:(0,h.ni)(n)}return t}(),e={entryType:Nt.NAVIGATION,initiatorType:"navigation",name:window.location.href,startTime:0,duration:t.loadEventEnd,decodedBodySize:0,encodedBodySize:0,transferSize:0,workerStart:0,toJSON:()=>({...e,toJSON:void 0}),...t};return e}function ri(t,e,i=ni){(0,Ze.T)(t,"interactive",(()=>{const t=i(),s=Object.assign(t.toJSON(),{entryType:Nt.RESOURCE,initiatorType:ht,duration:t.responseEnd,traceId:ei(document),toJSON:()=>({...s,toJSON:void 0})});e(s)}))}var ai=i(7655);function oi(t,e,i,s=(0,Xe.y)(),n=ri){let r;const a=(0,O.W_)(O.uh.EARLY_REQUEST_COLLECTION);a?r=(0,ai.t)(t):t.subscribe(8,(t=>{l((()=>function(t,e,i){const s=function(t){if(!performance||!("getEntriesByName"in performance))return;const e=performance.getEntriesByName(t.url,"resource");if(!e.length||!("toJSON"in e[0]))return;const i=e.filter((t=>!Je.has(t))).filter((t=>vt(t)&&bt(t))).filter((e=>{return i=e,s=t.startClocks.relative,n=Qe({startTime:t.startClocks.relative,duration:t.duration}),i.startTime>=s-1&&Qe(i)<=(0,h.WK)(n,1);var i,s,n}));return 1===i.length?(Je.add(i[0]),i[0].toJSON()):void 0}(t);return ci(s,t,i,e)}(t,e,i)))}));const o=Ut(e,{type:Nt.RESOURCE,buffered:!0}).subscribe((t=>{for(const s of t)!a&&mt(s)||l((()=>li(s,e,i,r)))}));function l(e){s.push((()=>{const i=e();i&&t.notify(12,i)}))}return n(e,(t=>{l((()=>li(t,e,i,r)))})),{stop:()=>{o.unsubscribe()}}}function li(t,e,i,s){return ci(t,mt(t)&&s?s.getMatchingRequest(t):void 0,i,e)}function ci(t,e,i,s){if(!t&&!e)return;const n=e?function(t,e){if(t.traceSampled&&t.traceId&&t.spanId)return{_dd:{span_id:t.spanId.toString(),trace_id:t.traceId.toString(),rule_psr:e.rulePsr}}}(e,s):function(t,e){if(t.traceId)return{_dd:{trace_id:t.traceId,span_id:(0,H.Nu)().toString(),rule_psr:e.rulePsr}}}(t,s);if(!s.trackResources&&!n)return;const r=t?(0,h.DY)(t.startTime):e.startClocks,a=t?function(t){const{duration:e,startTime:i,responseEnd:s}=t;return 0===e&&i"hidden"===t.name)).find((t=>t.startTime>=e.relative));if(t)return{timeStamp:t.startTime,stop:x.Z}}let s=1/0;const{stop:n}=(0,Ft.y)(t,i,["pagehide","visibilitychange"],(t=>{"pagehide"!==t.type&&"hidden"!==document.visibilityState||(s=t.timeStamp,n())}),{capture:!0});return{get timeStamp(){return s},stop:n}}function mi(t,e,i,s){const n={},{stop:r}=function(t,e,i=ni){return function(t,e){let i;const{stop:s}=(0,Ze.T)(t,"complete",(()=>{i=(0,Mt.iK)((()=>e()))}));return{stop:()=>{s(),(0,Mt.gr)(i)}}}(t,(()=>{const t=i();(function(t){return t.loadEventEnd<=0})(t)||e(function(t){return{domComplete:t.domComplete,domContentLoaded:t.domContentLoadedEventEnd,domInteractive:t.domInteractive,loadEvent:t.loadEventEnd,firstByte:t.responseStart>=0&&t.responseStart<=(0,h._q)()?t.responseStart:void 0}}(t))}))}(t,(t=>{i(t.loadEvent),n.navigationTimings=t,s()})),a=gi(t,e),{stop:o}=function(t,e,i){return{stop:Ut(t,{type:Nt.PAINT,buffered:!0}).subscribe((t=>{const i=t.find((t=>"first-contentful-paint"===t.name&&t.startTime{a=t.timeStamp}),{capture:!0,once:!0});let l=0;const c=Ut(t,{type:Nt.LARGEST_CONTENTFUL_PAINT,buffered:!0}).subscribe((i=>{const r=(0,j.dF)(i,(t=>t.entryType===Nt.LARGEST_CONTENTFUL_PAINT&&t.startTimel));if(r){let e;r.element&&(e=we(r.element,t.actionNameAttribute)),o={value:r.startTime,targetSelector:e,resourceUrl:(c=r,""===c.url?void 0:c.url)},n.largestContentfulPaint=o,s(),l=r.size}var o,c}));return{stop:()=>{o(),c.unsubscribe()}}}(t,a,window),{stop:c}=function(t,e,i){const r=Ut(t,{type:Nt.FIRST_INPUT,buffered:!0}).subscribe((i=>{const r=i.find((t=>t.startTime=0?e:0,time:r.startTime,targetSelector:i},n.firstInput=a,s()}var a}));return{stop:()=>{r.unsubscribe()}}}(t,a);return{stop:function(){r(),o(),l(),c(),a.stop()},initialViewMetrics:n}}var yi=i(5533);function vi(t){let e;for(const i of t)if(i.node&&(0,Gt.Tv)(i.node)){const t=(0,yi.S)(i);(!e||(0,yi.S)(e)Ti?Si:window.performance.interactionCount||0,Ri=10,Li=1*h.yR;var Ii=i(1358);function Ci(t,e,i,s,n,r,o){const l={},{stop:c,setLoadEvent:u}=function(t,e,i,s,r,a,o){let c=r===v.INITIAL_LOAD,u=!0;const d=[],f=gi(s,a);function p(){if(!u&&!c&&d.length>0){const e=Math.max(...d);e{u&&(u=!1,t.hadActivity&&d.push((0,h._J)(a.timeStamp,t.end)),p())}));return{stop:()=>{g(),f.stop()},setLoadEvent:t=>{c&&(c=!1,d.push(t),p())}}}(t,e,i,s,r,o),{stop:d}=(0,Ii._X)(s,o,(t=>{l.scroll=t})),{stop:f}=function(t,e,i){if(!jt(Nt.LAYOUT_SHIFT)||!("WeakRef"in window))return{stop:x.Z};let s,n=0;i({value:0});const r=function(){let t,e,i=0,s=0;return{update:n=>{let r;return void 0===t||n.startTime-e>=Ei||n.startTime-t>=_i?(t=e=n.startTime,s=i=n.value,r=!0):(i+=n.value,e=n.startTime,r=n.value>s,r&&(s=n.value)),{cumulatedValue:i,isMaxValue:r}}}}(),a=Ut(t,{type:Nt.LAYOUT_SHIFT,buffered:!0}).subscribe((a=>{var o;for(const l of a){if(l.hadRecentInput||l.startTimen){n=a;const e=null===(o=null==s?void 0:s.target)||void 0===o?void 0:o.deref();i({value:(0,F.NM)(n,4),targetSelector:e&&we(e,t.actionNameAttribute),time:null==s?void 0:s.time,previousRect:(null==s?void 0:s.previousRect)?bi(s.previousRect):void 0,currentRect:(null==s?void 0:s.currentRect)?bi(s.currentRect):void 0,devicePixelRatio:null==s?void 0:s.devicePixelRatio})}}}));return{stop:()=>{a.unsubscribe()}}}(s,o.relative,(t=>{l.cumulativeLayoutShift=t,n()})),{stop:p,getInteractionToNextPaint:g,setViewEnd:m}=function(t,e,i){if(!(jt(Nt.EVENT)&&window.PerformanceEventTiming&&"interactionId"in PerformanceEventTiming.prototype))return{getInteractionToNextPaint:()=>{},setViewEnd:x.Z,stop:x.Z};const{getViewInteractionCount:s,stopViewInteractionCount:n}=function(t){"interactionCount"in performance||Ti||(Ti=new window.PerformanceObserver((0,a.zk)((t=>{t.getEntries().forEach((t=>{const e=t;e.interactionId&&(ki=Math.min(ki,e.interactionId),wi=Math.max(wi,e.interactionId),Si=(wi-ki)/7+1)}))}))),Ti.observe({type:"event",buffered:!0,durationThreshold:0}));const e=t===v.INITIAL_LOAD?0:Ai();let i={stopped:!1};function s(){return Ai()-e}return{getViewInteractionCount:()=>i.stopped?i.interactionCount:s(),stopViewInteractionCount:()=>{i={stopped:!0,interactionCount:s()}}}}(i);let r=1/0;const o=function(t){const e=[];function i(){e.sort(((t,e)=>e.duration-t.duration)).splice(Ri)}return{process(t){const s=e.findIndex((e=>t.interactionId===e.interactionId)),n=e[e.length-1];-1!==s?t.duration>e[s].duration&&(e[s]=t,i()):(e.lengthn.duration)&&(e.push(t),i())},estimateP98Interaction(){const i=Math.min(e.length-1,Math.floor(t()/50));return e[i]}}}(s);let l,c,u=-1;function d(i){for(const t of i)t.interactionId&&t.startTime>=e&&t.startTime<=r&&o.process(t);const s=o.estimateP98Interaction();s&&s.duration!==u&&(u=s.duration,c=(0,h._J)(e,s.startTime),l=function(t){const e=Ue.get(t);return Ue.delete(t),e}(s.startTime),!l&&s.target&&(0,Gt.Tv)(s.target)&&(l=we(s.target,t.actionNameAttribute)))}const f=Ut(t,{type:Nt.FIRST_INPUT,buffered:!0}).subscribe(d),p=Ut(t,{type:Nt.EVENT,durationThreshold:40,buffered:!0}).subscribe(d);return{getInteractionToNextPaint:()=>u>=0?{value:Math.min(u,Li),targetSelector:l,time:c}:s()?{value:0}:void 0,setViewEnd:t=>{r=t,n()},stop:()=>{p.unsubscribe(),f.unsubscribe()}}}(s,o.relative,r);return{stop:()=>{c(),f(),d()},stopINPTracking:p,setLoadEvent:u,setViewEnd:m,getCommonViewMetrics:()=>(l.interactionToNextPaint=g(),l)}}var Di=i(9725);const xi=3e3,Pi=5*h.yR,Oi=5*h.yR;function Ni(t,e,i,s,n,r,a,o){const l=new Set;let c,u,d=f(v.INITIAL_LOAD,(0,h.cQ)(),o);function f(r,a,o){const c=function(t,e,i,s,n,r,a=(0,h.$I)(),o){const l=(0,T.DO)(),c=new Pt.y$,u={};let d,f=0;const p=(0,$.mv)(n),g=(0,hi.W)();let m=!0,y=null==o?void 0:o.name;const b=(null==o?void 0:o.service)||s.service,_=(null==o?void 0:o.version)||s.version,E=null==o?void 0:o.context;E&&g.setContext(E);const S={id:l,name:y,startClocks:a,service:b,version:_,context:E};t.notify(1,S),t.notify(2,S);const{throttled:k,cancel:w}=(0,x.P)(G,xi,{leading:!1}),{setLoadEvent:A,setViewEnd:R,stop:L,stopINPTracking:I,getCommonViewMetrics:C}=Ci(t,e,i,s,j,r,a),{stop:P,initialViewMetrics:O}=r===v.INITIAL_LOAD?mi(s,a,A,j):{stop:x.Z,initialViewMetrics:{}};r===v.BF_CACHE&&function(t,e,i){var s,n;s=t.relative,n=t=>{e.firstContentfulPaint=t,e.largestContentfulPaint={value:t},i()},requestAnimationFrame((()=>{requestAnimationFrame((()=>{n((0,h._J)(s,(0,h._q)()))}))}))}(a,O,j);const{stop:N,eventCounts:M}=function(t,e,i){const{stop:s,eventCounts:n}=Ot({lifeCycle:t,isChildEvent:t=>t.view.id===e,onChange:i});return{stop:s,eventCounts:n}}(t,l,j),F=(0,Mt.Zi)(G,Pi),U=t.subscribe(11,(t=>{t.reason===tt.k$.UNLOADING&&G()}));function B(){t.notify(3,{id:l,name:y,context:g.getContext(),startClocks:a,sessionIsActive:m})}function j(){B(),k()}function G(){w(),B(),f+=1;const e=void 0===d?(0,h.n$)():d.timeStamp;t.notify(4,{customTimings:u,documentVersion:f,id:l,name:y,service:b,version:_,context:g.getContext(),loadingType:r,location:p,startClocks:a,commonViewMetrics:C(),initialViewMetrics:O,duration:(0,h._J)(a.timeStamp,e),isActive:void 0===d,sessionIsActive:m,eventCounts:M})}return G(),g.changeObservable.subscribe(j),{get name(){return y},service:b,version:_,contextManager:g,stopObservable:c,end(e={}){var i,s;d||(d=null!==(i=e.endClocks)&&void 0!==i?i:(0,h.$I)(),m=null===(s=e.sessionIsActive)||void 0===s||s,t.notify(5,{endClocks:d}),t.notify(6,{endClocks:d}),(0,Mt.cv)(F),R(d.relative),L(),U.unsubscribe(),G(),(0,Mt.iK)((()=>{this.stop()}),Oi))},stop(){P(),N(),I(),c.notify()},addTiming(t,e){if(d)return;const i=(0,h.Cn)(e)?e:(0,h._J)(a.timeStamp,e);u[function(t){const e=t.replace(/[^a-zA-Z0-9-_.@$]/g,"_");return e!==t&&D.jf.warn(`Invalid timing name: ${t}, sanitized to: ${e}`),e}(t)]=i,j()},setViewName(t){y=t,G()}}}(e,i,s,n,t,r,a,o);return l.add(c),c.stopObservable.subscribe((()=>{l.delete(c)})),c}return e.subscribe(10,(()=>{d=f(v.ROUTE_CHANGE,void 0,{name:d.name,service:d.service,version:d.version,context:d.contextManager.getContext()})})),e.subscribe(9,(()=>{d.end({sessionIsActive:!1})})),a&&(u=function(t){return t.subscribe((({oldLocation:t,newLocation:e})=>{var i,s;s=e,((i=t).pathname!==s.pathname||!function(t){const e=t.substring(1);return""!==e&&!!document.getElementById(e)}(s.hash)&&Mi(s.hash)!==Mi(i.hash))&&(d.end(),d=f(v.ROUTE_CHANGE))}))}(r),n.trackBfcacheViews&&(c=(0,Di.T)(n,(t=>{d.end();const e=(0,h.DY)(t.timeStamp);d=f(v.BF_CACHE,e,void 0)})))),{addTiming:(t,e=(0,h.n$)())=>{d.addTiming(t,e)},startView:(t,e)=>{d.end({endClocks:e}),d=f(v.ROUTE_CHANGE,e,t)},setViewContext:t=>{d.contextManager.setContext(t)},setViewContextProperty:(t,e)=>{d.contextManager.setContextProperty(t,e)},setViewName:t=>{d.setViewName(t)},getViewContext:()=>d.contextManager.getContext(),stop:()=>{u&&u.unsubscribe(),c&&c(),d.end(),l.forEach((t=>t.stop()))}}}function Mi(t){const e=t.indexOf("?");return e<0?t:t.slice(0,e)}function Fi({cumulativeLayoutShift:t,interactionToNextPaint:e},{firstContentfulPaint:i,firstInput:s,largestContentfulPaint:n}){return{cls:t&&{score:t.value,timestamp:(0,h.c0)(t.time),target_selector:t.targetSelector,previous_rect:t.previousRect,current_rect:t.currentRect},fcp:i&&{timestamp:(0,h.c0)(i)},fid:s&&{duration:(0,h.c0)(s.delay),timestamp:(0,h.c0)(s.time),target_selector:s.targetSelector},inp:e&&{duration:(0,h.c0)(e.value),timestamp:(0,h.c0)(e.time),target_selector:e.targetSelector},lcp:n&&{timestamp:(0,h.c0)(n.value),target_selector:n.targetSelector,resource_url:n.resourceUrl}}}var $i=i(4717),Ui=i(3789),Bi=i(2097),ji=i(5419),Gi=i(8387),Vi=i(6593),Hi=i(3766),Ki=i(8981);const Yi=Ki.TN,qi=10*h.WT;let zi,Wi;function Xi(){0!==zi.batchCount&&((0,o.qZ)("Customer data measures",zi),Qi())}function Ji(t,e){t.sum+=e,t.min=Math.min(t.min,e),t.max=Math.max(t.max,e)}function Qi(){zi={batchCount:0,batchBytesCount:{min:1/0,max:0,sum:0},batchMessagesCount:{min:1/0,max:0,sum:0}}}const Zi=4e3,ts=500,es=Ki.TN;function is(t,e,i){if(0!==t.length)return t.slice(-i).reverse().map((({state:t,startTime:i})=>({state:t,start:(0,h.c0)((0,h._J)(e,i))})))}function ss(){return"hidden"===document.visibilityState?"hidden":document.hasFocus()?"active":"passive"}var ns=i(354),rs=i(5747),as=i(4208),os=i(5123),ls=i(5528),cs=i(1802);const us={"view.name":"string","view.url":"string","view.referrer":"string"},ds={context:"object"},hs={service:"string",version:"string"};let fs;var ps=i(3583),gs=i(1545),ms=i(2582),ys=i(769);const vs=[m.ACTION,m.ERROR,m.LONG_TASK,m.RESOURCE,m.VITAL];var bs=i(4408);function _s(t,e,i,s,n,r,a,l,u){const d=[],f=new nt.j,p=(0,ys.H)();f.subscribe(13,(t=>(0,Z.j)("rum",t)));const g=t=>{f.notify(14,{error:t}),(0,o.eJ)("Error reported to customer",{"error.message":t.message})},v=(0,tt.FP)(t),b=v.subscribe((t=>{f.notify(11,t)}));d.push((()=>b.unsubscribe()));const _=(0,o.VL)("browser-rum-sdk",t,p,g,v,n);d.push(_.stop);const E=(0,C.xT)()?(0,$i.j5)():(0,$i.oi)(t,f,r);if((0,C.xT)())(0,Gi.i)(f);else{const e=function(t,e,i,s,n,r){const a=[t.rumEndpointBuilder];t.replica&&a.push(t.replica.rumEndpointBuilder);const o=(0,Ui.n)({encoder:r(2),request:(0,Bi.UF)(a,t.batchBytesLimit,i),flushController:(0,ji.r)({messagesLimit:t.batchMessagesLimit,bytesLimit:t.batchBytesLimit,durationLimit:t.flushTimeout,pageMayExitObservable:s,sessionExpireObservable:n}),messageBytesLimit:t.messageBytesLimit});return e.subscribe(13,(t=>{t.type===m.VIEW?o.upsert(t,t.view.id):o.add(t)})),o}(t,f,g,v,E.expireObservable,n);d.push((()=>e.stop())),function(t,e,i,s){e.enabled&&(0,F.y7)(t.customerDataTelemetrySampleRate)&&(Qi(),Wi=!1,i.subscribe(13,(()=>{Wi=!0})),s.subscribe((({bytesCount:t,messagesCount:e})=>{Wi&&(Wi=!1,zi.batchCount+=1,Ji(zi.batchBytesCount,t),Ji(zi.batchMessagesCount,e))})),(0,Mt.Zi)(Xi,qi))}(t,_,f,e.flushController.flushObservable)}const w=(0,et.y)(),A=(0,Hi.t)(t,location),{observable:N,stop:M}=(0,it.M)();d.push(M),(0,gs.Y)(p,t,u);const U=function(t,e,i=ts){const s=(0,xt.p)({expireDelay:es,maxEntries:Zi});let n;jt(Nt.VISIBILITY_STATE)&&performance.getEntriesByType(Nt.VISIBILITY_STATE).forEach((t=>{a("hidden"===t.name?"hidden":"active",t.startTime)})),a(ss(),(0,h._q)());const{stop:r}=(0,Ft.y)(e,window,["pageshow","focus","blur","visibilitychange","resume","freeze","pagehide"],(t=>{a(function(t){return"freeze"===t.type?"frozen":"pagehide"===t.type?t.persisted?"frozen":"terminated":ss()}(t),t.timeStamp)}),{capture:!0});function a(t,e=(0,h._q)()){t!==n&&(n=t,s.closeActive(e),s.add({state:n,startTime:e},e))}function o(t,e,i){return s.findAll(e,i).some((e=>e.state===t))}return t.register(0,(({startTime:t,duration:e=0,eventType:n})=>n===m.VIEW?{type:n,_dd:{page_states:is(s.findAll(t,e),t,i)}}:n===m.ACTION||n===m.ERROR?{type:n,view:{in_foreground:o("active",t,0)}}:Ct.kb)),{wasInPageStateDuringPeriod:o,addPageState:a,stop:()=>{r(),s.stop()}}}(p,t),B=(0,rt.O)(f);d.push((()=>B.stop()));const G=(0,Vi.Y)(f,p,A,location);d.push((()=>G.stop()));const V=function(t,e,i){const s=(0,xt.p)({expireDelay:Yi});return t.subscribe(1,(({startClocks:t})=>{s.add({},t.relative)})),t.subscribe(6,(({endClocks:t})=>{s.closeActive(t.relative)})),e.register(0,(({startTime:t,eventType:e})=>{if(!i.trackFeatureFlagsForEvents.concat([m.VIEW,m.ERROR]).includes(e))return Ct.kb;const n=s.find(t);return!n||(0,$.Qr)(n)?Ct.kb:{type:e,feature_flags:n}})),{addFeatureFlagEvaluation:(t,e)=>{const i=s.find();i&&(i[t]=e)}}}(f,p,t);!function(t,e,i,s){t.register(0,(({eventType:t,startTime:n})=>{const r=e.findTrackedSession(n),a=s.findView(n);if(!r||!a)return Ct.C_;let o,l,c;return t===m.VIEW?(o=!!i.getReplayStats(a.id)||void 0,l=1===r.sessionReplay,c=!!a.sessionIsActive&&void 0):o=!!i.isRecording()||void 0,{type:t,session:{id:r.id,type:"user",has_replay:o,sampled_for_replay:l,is_active:c}}})),t.register(1,(({startTime:t})=>{const i=e.findTrackedSession(t);return i?{session:{id:i.id}}:Ct.kb}))}(p,E,e,B),(0,ps.d)(p),(0,ms.I)(p,r);const H=(0,R.$)(p,t,"rum",!0),q=(0,L.c)(p,t,E,"rum"),z=(0,I.p)(p,t,"rum"),{actionContexts:W,addAction:X,addEvent:J,stop:Q}=function(t,e,i,s,n,r,a){const o=function(t,e,i,s,n){t.subscribe(0,(e=>t.notify(12,He(e)))),e.register(0,(({startTime:t,eventType:e})=>{if(e!==m.ERROR&&e!==m.RESOURCE&&e!==m.LONG_TASK)return Ct.kb;const i=r.findActionId(t);return i?{type:e,action:{id:i}}:Ct.kb})),e.register(1,(({startTime:t})=>({action:{id:r.findActionId(t)}})));let r={findActionId:x.Z},a=x.Z;return n.trackUserInteractions&&({actionContexts:r,stop:a}=Ge(t,i,s,n)),{addAction:e=>{t.notify(12,He(e))},actionContexts:r,stop:a}}(t,e,n,r,i),l=function(t){return{addEvent:(e,i,s,n)=>{vs.includes(i.type)&&t.notify(12,{startTime:e,rawRumEvent:i,domainContext:s,duration:n})}}}(t),u=(0,ns.Z)(e,i),d=(0,rs.z)(i,e);return(0,as.E)(e),function(t,e,i,s){fs={[m.VIEW]:{"view.performance.lcp.resource_url":"string",...ds,...us,...hs},[m.ERROR]:{"error.message":"string","error.stack":"string","error.resource.url":"string","error.fingerprint":"string",...ds,...us,...hs},[m.RESOURCE]:{"resource.url":"string",...(0,O.W_)(O.uh.WRITABLE_RESOURCE_GRAPHQL)?{"resource.graphql":"object"}:{},...ds,...us,...hs},[m.ACTION]:{"action.target.name":"string",...ds,...us,...hs},[m.LONG_TASK]:{"long_task.scripts[].source_url":"string","long_task.scripts[].invoker":"string",...ds,...us,...hs},[m.VITAL]:{...ds,...us,...hs}};const n={[m.ERROR]:(0,os.K)(m.ERROR,t.eventRateLimiterThreshold,s),[m.ACTION]:(0,os.K)(m.ACTION,t.eventRateLimiterThreshold,s),[m.VITAL]:(0,os.K)(m.VITAL,t.eventRateLimiterThreshold,s)};e.subscribe(12,(({startTime:s,duration:r,rawRumEvent:a,domainContext:o})=>{const l=i.triggerHook(0,{eventType:a.type,startTime:s,duration:r});if(l===Ct.C_)return;const u=(0,c.$e)(l,a,{ddtags:(0,ls.MS)(t).join(",")});(function(t,e,i,s){var n;if(e){const s=(0,cs.O)(t,fs[t.type],(t=>e(t,i)));if(!1===s&&t.type!==m.VIEW)return!1;!1===s&&D.jf.warn("Can't dismiss view events using beforeSend!")}return!(null===(n=s[t.type])||void 0===n?void 0:n.isLimitReached())})(u,t.beforeSend,o,n)&&((0,$.Qr)(u.context)&&delete u.context,e.notify(13,u))}))}(i,t,e,a),{pageStateHistory:s,addAction:o.addAction,addEvent:l.addEvent,actionContexts:o.actionContexts,stop:()=>{o.stop(),d.stop(),u.stop(),s.stop()}}}(f,p,t,U,w,N,g);d.push(Q);const{addTiming:ut,startView:dt,setViewName:ht,setViewContext:ft,setViewContextProperty:pt,getViewContext:gt,stop:mt}=function(t,e,i,s,n,r,a,o,l,c){return t.subscribe(4,(e=>t.notify(12,function(t,e,i){var s,n,r,a,o,l,c,u,d,f,p,g,y,v,b,_,E,T;const S=i.getReplayStats(t.id),k=null===(n=null===(s=t.commonViewMetrics)||void 0===s?void 0:s.cumulativeLayoutShift)||void 0===n?void 0:n.devicePixelRatio,w={_dd:{document_version:t.documentVersion,replay_stats:S,cls:k?{device_pixel_ratio:k}:void 0,configuration:{start_session_replay_recording_manually:e.startSessionReplayRecordingManually}},date:t.startClocks.timeStamp,type:m.VIEW,view:{action:{count:t.eventCounts.actionCount},frustration:{count:t.eventCounts.frustrationCount},cumulative_layout_shift:null===(r=t.commonViewMetrics.cumulativeLayoutShift)||void 0===r?void 0:r.value,cumulative_layout_shift_time:(0,h.c0)(null===(a=t.commonViewMetrics.cumulativeLayoutShift)||void 0===a?void 0:a.time),cumulative_layout_shift_target_selector:null===(o=t.commonViewMetrics.cumulativeLayoutShift)||void 0===o?void 0:o.targetSelector,first_byte:(0,h.c0)(null===(l=t.initialViewMetrics.navigationTimings)||void 0===l?void 0:l.firstByte),dom_complete:(0,h.c0)(null===(c=t.initialViewMetrics.navigationTimings)||void 0===c?void 0:c.domComplete),dom_content_loaded:(0,h.c0)(null===(u=t.initialViewMetrics.navigationTimings)||void 0===u?void 0:u.domContentLoaded),dom_interactive:(0,h.c0)(null===(d=t.initialViewMetrics.navigationTimings)||void 0===d?void 0:d.domInteractive),error:{count:t.eventCounts.errorCount},first_contentful_paint:(0,h.c0)(t.initialViewMetrics.firstContentfulPaint),first_input_delay:(0,h.c0)(null===(f=t.initialViewMetrics.firstInput)||void 0===f?void 0:f.delay),first_input_time:(0,h.c0)(null===(p=t.initialViewMetrics.firstInput)||void 0===p?void 0:p.time),first_input_target_selector:null===(g=t.initialViewMetrics.firstInput)||void 0===g?void 0:g.targetSelector,interaction_to_next_paint:(0,h.c0)(null===(y=t.commonViewMetrics.interactionToNextPaint)||void 0===y?void 0:y.value),interaction_to_next_paint_time:(0,h.c0)(null===(v=t.commonViewMetrics.interactionToNextPaint)||void 0===v?void 0:v.time),interaction_to_next_paint_target_selector:null===(b=t.commonViewMetrics.interactionToNextPaint)||void 0===b?void 0:b.targetSelector,is_active:t.isActive,name:t.name,largest_contentful_paint:(0,h.c0)(null===(_=t.initialViewMetrics.largestContentfulPaint)||void 0===_?void 0:_.value),largest_contentful_paint_target_selector:null===(E=t.initialViewMetrics.largestContentfulPaint)||void 0===E?void 0:E.targetSelector,load_event:(0,h.c0)(null===(T=t.initialViewMetrics.navigationTimings)||void 0===T?void 0:T.loadEvent),loading_time:(0,Dt.J)((0,h.c0)(t.commonViewMetrics.loadingTime)),loading_type:t.loadingType,long_task:{count:t.eventCounts.longTaskCount},performance:Fi(t.commonViewMetrics,t.initialViewMetrics),resource:{count:t.eventCounts.resourceCount},time_spent:(0,h.c0)(t.duration)},display:t.commonViewMetrics.scroll?{scroll:{max_depth:t.commonViewMetrics.scroll.maxDepth,max_depth_scroll_top:t.commonViewMetrics.scroll.maxDepthScrollTop,max_scroll_height:t.commonViewMetrics.scroll.maxScrollHeight,max_scroll_height_time:(0,h.c0)(t.commonViewMetrics.scroll.maxScrollHeightTime)}}:void 0,privacy:{replay_level:e.defaultPrivacyLevel},device:{locale:navigator.language,locales:navigator.languages,time_zone:(0,di.Z)()}};return(0,$.Qr)(t.customTimings)||(w.view.custom_timings=(0,$.Q8)(t.customTimings,h.c0)),{rawRumEvent:w,startTime:t.startClocks.relative,duration:t.duration,domainContext:{location:t.location}}}(e,i,o)))),e.register(0,(({startTime:t,eventType:e})=>{const i=l.findView(t);return i?{type:e,service:i.service,version:i.version,context:i.context,view:{id:i.id,name:i.name}}:Ct.C_})),e.register(1,(({startTime:t})=>{var e;return{view:{id:null===(e=l.findView(t))||void 0===e?void 0:e.id}}})),Ni(s,t,n,r,i,a,!i.trackViewsManually,c)}(f,p,t,location,w,N,A,e,B,s);d.push(mt);const{stop:yt}=(0,bs.j)(t,f,_);d.push(yt);const{stop:vt}=oi(f,t,U);if(d.push(vt),t.trackLongTasks)if(jt(Nt.LONG_ANIMATION_FRAME)){const{stop:e}=function(t,e){const i=Ut(e,{type:Nt.LONG_ANIMATION_FRAME,buffered:!0}).subscribe((e=>{for(const i of e){const e=(0,h.DY)(i.startTime),s={date:e.timeStamp,long_task:{id:(0,T.DO)(),entry_type:y.LONG_ANIMATION_FRAME,duration:(0,h.c0)(i.duration),blocking_duration:(0,h.c0)(i.blockingDuration),first_ui_event_timestamp:(0,h.c0)(i.firstUIEventTimestamp),render_start:(0,h.c0)(i.renderStart),style_and_layout_start:(0,h.c0)(i.styleAndLayoutStart),start_time:(0,h.c0)(i.startTime),scripts:i.scripts.map((t=>({duration:(0,h.c0)(t.duration),pause_duration:(0,h.c0)(t.pauseDuration),forced_style_and_layout_duration:(0,h.c0)(t.forcedStyleAndLayoutDuration),start_time:(0,h.c0)(t.startTime),execution_start:(0,h.c0)(t.executionStart),source_url:t.sourceURL,source_function_name:t.sourceFunctionName,source_char_position:t.sourceCharPosition,invoker:t.invoker,invoker_type:t.invokerType,window_attribution:t.windowAttribution})))},type:m.LONG_TASK,_dd:{discarded:!1}};t.notify(12,{rawRumEvent:s,startTime:e.relative,duration:i.duration,domainContext:{performanceEntry:i}})}}));return{stop:()=>i.unsubscribe()}}(f,t);d.push(e)}else!function(t,e){Ut(e,{type:Nt.LONG_TASK,buffered:!0}).subscribe((i=>{for(const s of i){if(s.entryType!==Nt.LONG_TASK)break;if(!e.trackLongTasks)break;const i=(0,h.DY)(s.startTime),n={date:i.timeStamp,long_task:{id:(0,T.DO)(),entry_type:y.LONG_TASK,duration:(0,h.c0)(s.duration)},type:m.LONG_TASK,_dd:{discarded:!1}};t.notify(12,{rawRumEvent:n,startTime:i.relative,duration:s.duration,domainContext:{performanceEntry:s}})}}))}(f,t);const{addError:bt}=function(t,e,i){const s=new Pt.y$;return i.subscribe((t=>{0===t.type&&s.notify(t.error)})),(0,ze.U)(s),(0,We.x)(e,s),s.subscribe((e=>t.notify(14,{error:e}))),function(t){return t.subscribe(14,(({error:e})=>{t.notify(12,function(t){const e={date:t.startClocks.timeStamp,error:{id:(0,T.DO)(),message:t.message,source:t.source,stack:t.stack,handling_stack:t.handlingStack,component_stack:t.componentStack,type:t.type,handling:t.handling,causes:t.causes,source_type:"browser",fingerprint:t.fingerprint,csp:t.csp},type:m.ERROR,context:t.context},i={error:t.originalError,handlingStack:t.handlingStack};return{rawRumEvent:e,startTime:t.startClocks.relative,domainContext:i}}(e))})),{addError:({error:e,handlingStack:i,componentStack:s,startClocks:n,context:r})=>{const a=(0,Ye.AP)({originalError:e,handlingStack:i,componentStack:s,startClocks:n,nonErrorPrefix:"Provided",source:qe.z.CUSTOM,handling:"handled"});a.context=(0,c.$e)(a.context,r),t.notify(14,{error:a})}}}(t)}(f,t,l);l.unbuffer(),function(t,e,i,s,n){const r=function(t,e,i,s){return{clearTracingIfNeeded:K,traceFetch:n=>Y(t,n,e,i,s,(t=>{var e;if(n.input instanceof Request&&!(null===(e=n.init)||void 0===e?void 0:e.headers))n.input=new Request(n.input),Object.keys(t).forEach((e=>{n.input.headers.append(e,t[e])}));else{n.init=(0,$.mv)(n.init);const e=[];n.init.headers instanceof Headers?n.init.headers.forEach(((t,i)=>{e.push([i,t])})):Array.isArray(n.init.headers)?n.init.headers.forEach((t=>{e.push(t)})):n.init.headers&&Object.keys(n.init.headers).forEach((t=>{e.push([t,n.init.headers[t]])})),n.init.headers=e.concat((0,j.qP)(t))}})),traceXhr:(n,r)=>Y(t,n,e,i,s,(t=>{Object.keys(t).forEach((e=>{r.setRequestHeader(e,t[e])}))}))}}(e,i,s,n);!function(t,e,i){(0,at.S)(e).subscribe((e=>{const s=e;if(kt(s.url))switch(s.state){case"start":i.traceXhr(s,s.xhr),s.requestIndex=It(),t.notify(7,{requestIndex:s.requestIndex,url:s.url});break;case"complete":i.clearTracingIfNeeded(s),t.notify(8,{duration:s.duration,method:s.method,requestIndex:s.requestIndex,spanId:s.spanId,startClocks:s.startClocks,status:s.status,traceId:s.traceId,traceSampled:s.traceSampled,type:ot.x.XHR,url:s.url,xhr:s.xhr,isAborted:s.isAborted,handlingStack:s.handlingStack})}}))}(t,e,r),function(t,e){(0,P.y)().subscribe((i=>{const s=i;if(kt(s.url))switch(s.state){case"start":e.traceFetch(s),s.requestIndex=It(),t.notify(7,{requestIndex:s.requestIndex,url:s.url});break;case"resolve":!function(t,e){const i=t.response&&(0,lt.u)(t.response);i&&i.body?(0,ct.n)(i.body,(()=>{e((0,h._J)(t.startClocks.timeStamp,(0,h.n$)()))}),{bytesLimit:Number.POSITIVE_INFINITY,collectStreamBody:!1}):e((0,h._J)(t.startClocks.timeStamp,(0,h.n$)()))}(s,(i=>{e.clearTracingIfNeeded(s),t.notify(8,{duration:i,method:s.method,requestIndex:s.requestIndex,responseType:s.responseType,spanId:s.spanId,startClocks:s.startClocks,status:s.status,traceId:s.traceId,traceSampled:s.traceSampled,type:ot.x.FETCH,url:s.url,response:s.response,init:s.init,input:s.input,isAborted:s.isAborted,handlingStack:s.handlingStack})}))}}))}(t,r)}(f,t,E,q,z);const _t=function(t,e,i){function s(i){(function(t){return!e.wasInPageStateDuringPeriod("frozen",t.startClocks.relative,t.duration)})(i)&&t.notify(12,function(t,e){return{rawRumEvent:{date:t.startClocks.timeStamp,vital:{id:(0,T.DO)(),type:t.type,name:t.name,duration:(0,h.c0)(t.duration),description:t.description},type:m.VITAL,context:t.context,_dd:{vital:{computed_value:!0}}},startTime:t.startClocks.relative,duration:t.duration,domainContext:{}}}(i))}return{addDurationVital:s,startDurationVital:(t,e={})=>S(i,t,e),stopDurationVital:(t,e={})=>{k(s,i,t,e)}}}(f,U,a),Et=(0,st.A)(t.applicationId,E,B,W,G);return d.push((()=>i.stop())),{addAction:X,addEvent:J,addError:bt,addTiming:ut,addFeatureFlagEvaluation:V.addFeatureFlagEvaluation,startView:dt,setViewContext:ft,setViewContextProperty:pt,getViewContext:gt,setViewName:ht,lifeCycle:f,viewHistory:B,session:E,stopSession:()=>E.expire(),getInternalContext:Et.get,startDurationVital:_t.startDurationVital,stopDurationVital:_t.stopDurationVital,addDurationVital:_t.addDurationVital,globalContext:H,userContext:q,accountContext:z,telemetry:_,stop:()=>{d.forEach((t=>t()))},hooks:p}}var Es=i(5788),Ts=i(247),Ss=i(2475)},8387:(t,e,i)=>{"use strict";if(i.d(e,{i:()=>n}),179==i.j)var s=i(6876);function n(t){const e=(0,s.Ad)();t.subscribe(13,(t=>{e.send("rum",t)}))}},8259:(t,e,i)=>{"use strict";function s(){return"function"==typeof Array.from&&"function"==typeof CSSSupportsRule&&"function"==typeof URL.createObjectURL&&"forEach"in NodeList.prototype}i.d(e,{T:()=>s})},4903:(t,e,i)=>{"use strict";if(i.d(e,{n:()=>n}),179==i.j)var s=i(9833);async function n(t=r){try{return await t()}catch(t){(0,s.j)({error:t,source:"Profiler",scriptType:"module"})}}async function r(){return(await i.e(216).then(i.bind(i,8478))).createRumProfiler}},2910:(t,e,i)=>{"use strict";if(i.d(e,{w:()=>n}),179==i.j)var s=i(251);function n(){let t=0;return{strategy:{start(){t=1},stop(){t=2},isRecording:()=>!1,getSessionReplayLink:s.Z},shouldStartImmediately:e=>1===t||0===t&&!e.startSessionReplayRecordingManually}}},1061:(t,e,i)=>{"use strict";i.r(e),i.d(e,{startRecording:()=>kt});var s=i(7198),n=i(2097),r=i(6876),a=i(8971),o=i(8290),l=i(251),c=i(3206),u=i(170),d=i(782);const h=new WeakMap;function f(t){return h.has(t)}function p(t){return h.get(t)}function g(t,e){const i=t.tagName,s=t.value;if((0,d.gR)(t,e)){const e=t.type;if("INPUT"===i&&("button"===e||"submit"===e||"reset"===e))return s;if(!s||"OPTION"===i)return;return d.k6}return"OPTION"===i||"SELECT"===i?t.value:"INPUT"===i||"TEXTAREA"===i?s:void 0}const m=/url\((?:(')([^']*)'|(")([^"]*)"|([^)]*))\)/gm,y=/^[A-Za-z]+:|^\/\//,v=/^["']?data:.*,/i;const b=/[^a-z1-6-_]/;function _(t){const e=t.toLowerCase().trim();return b.test(e)?"div":e}function E(t,e){return`data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='${t}' height='${e}' style='background-color:silver'%3E%3C/svg%3E`}var T=i(5026);const S={FullSnapshot:2,IncrementalSnapshot:3,Meta:4,Focus:6,ViewEnd:7,VisualViewport:8,FrustrationRecord:9},k={Document:0,DocumentType:1,Element:2,Text:3,CDATA:4,DocumentFragment:11},w={Mutation:0,MouseMove:1,MouseInteraction:2,Scroll:3,ViewportResize:4,Input:5,TouchMove:6,MediaInteraction:7,StyleSheetRule:8},A={MouseUp:0,MouseDown:1,Click:2,ContextMenu:3,DblClick:4,Focus:5,Blur:6,TouchStart:7,TouchEnd:9},R={Play:0,Pause:1};var L=i(6084),I=i(2172);const C=1e6;function D(t,e,i,s){if(e===d.zx.HIDDEN)return null;const n=t.getAttribute(i);if(e===d.zx.MASK&&i!==d.$n&&!d.YO.includes(i)&&i!==s.actionNameAttribute){const e=t.tagName;switch(i){case"title":case"alt":case"placeholder":return d.k6}if("IMG"===e&&("src"===i||"srcset"===i)){const e=t;if(e.naturalWidth>0)return E(e.naturalWidth,e.naturalHeight);const{width:i,height:s}=t.getBoundingClientRect();return i>0||s>0?E(i,s):d.Xn}if("SOURCE"===e&&("src"===i||"srcset"===i))return d.Xn;if("A"===e&&"href"===i)return d.k6;if(n&&i.startsWith("data-"))return d.k6;if("IFRAME"===e&&"srcdoc"===i)return d.k6}return n&&"string"==typeof n?(0,d.Pu)(n,C):n}var x=i(1612);function P(t){if(!t)return null;let e;try{e=t.rules||t.cssRules}catch(t){}return e?(i=Array.from(e,(0,I.G6)()?O:N).join(""),s=t.href,i.replace(m,((t,e,i,n,r,a)=>{const o=i||r||a;if(!s||!o||y.test(o)||v.test(o))return t;const l=e||n||"";return`url(${l}${function(t,e){try{return(0,u.Q2)(t,e).href}catch(e){return t}}(o,s)}${l})`}))):null;var i,s}function O(t){if(function(t){return"selectorText"in t}(t)&&t.selectorText.includes(":")){const e=/(\[[\w-]+[^\\])(:[^\]]+\])/g;return t.cssText.replace(e,"$1\\$2")}return N(t)}function N(t){return function(t){return"styleSheet"in t}(t)&&P(t.styleSheet)||t.cssText}function M(t,e){const i=function(t,e){switch(t.nodeType){case t.DOCUMENT_NODE:return function(t,e){return{type:k.Document,childNodes:$(t,e),adoptedStyleSheets:(0,L.x)(t.adoptedStyleSheets)}}(t,e);case t.DOCUMENT_FRAGMENT_NODE:return function(t,e){const i=(0,d.VO)(t);return i&&e.serializationContext.shadowRootsController.addShadowRoot(t),{type:k.DocumentFragment,childNodes:$(t,e),isShadowRoot:i,adoptedStyleSheets:i?(0,L.x)(t.adoptedStyleSheets):void 0}}(t,e);case t.DOCUMENT_TYPE_NODE:return i=t,{type:k.DocumentType,name:i.name,publicId:i.publicId,systemId:i.systemId};case t.ELEMENT_NODE:return function(t,e){const i=_(t.tagName),s="svg"===(r=t).tagName||r instanceof SVGElement||void 0,n=(0,d.Ch)((0,d.SZ)(t),e.parentNodePrivacyLevel);var r;if(n===d.zx.HIDDEN){const{width:e,height:n}=t.getBoundingClientRect();return{type:k.Element,tagName:i,attributes:{rr_width:`${e}px`,rr_height:`${n}px`,[d.$n]:d.nw},childNodes:[],isSVG:s}}if(n===d.zx.IGNORE)return;const a=function(t,e,i){if(e===d.zx.HIDDEN)return{};const s={},n=_(t.tagName),r=t.ownerDocument;for(let n=0;ne.href===t.href)),n=P(e);n&&e&&((0,x.ik)(i.serializationContext.serializationStats,"cssText",n.length),s._cssText=n)}if("style"===n&&t.sheet){const e=P(t.sheet);e&&((0,x.ik)(i.serializationContext.serializationStats,"cssText",e.length),s._cssText=e)}const a=t;if("input"!==n||"radio"!==a.type&&"checkbox"!==a.type||(e===d.zx.ALLOW?s.checked=!!a.checked:(0,d.gR)(a,e)&&delete s.checked),"audio"===n||"video"===n){const e=t;s.rr_mediaState=e.paused?"paused":"played"}let o,l;const c=i.serializationContext;switch(c.status){case 0:o=Math.round(t.scrollTop),l=Math.round(t.scrollLeft),(o||l)&&c.elementsScrollPositions.set(t,{scrollTop:o,scrollLeft:l});break;case 1:c.elementsScrollPositions.has(t)&&({scrollTop:o,scrollLeft:l}=c.elementsScrollPositions.get(t))}return l&&(s.rr_scrollLeft=l),o&&(s.rr_scrollTop=o),s}(t,n,e);let o=[];if((0,d.Sn)(t)&&"style"!==i){let s;s=e.parentNodePrivacyLevel===n&&e.ignoreWhiteSpace===("head"===i)?e:{...e,parentNodePrivacyLevel:n,ignoreWhiteSpace:"head"===i},o=$(t,s)}return{type:k.Element,tagName:i,attributes:a,childNodes:o,isSVG:s}}(t,e);case t.TEXT_NODE:return function(t,e){const i=(0,d.FB)(t,e.ignoreWhiteSpace||!1,e.parentNodePrivacyLevel);if(void 0!==i)return{type:k.Text,textContent:i}}(t,e);case t.CDATA_SECTION_NODE:return{type:k.CDATA,textContent:""}}var i}(t,e);if(!i)return null;const s=p(t)||F++,n=i;return n.id=s,function(t,e){h.set(t,e)}(t,s),e.serializedNodeIds&&e.serializedNodeIds.add(s),n}let F=1;function $(t,e){const i=[];return(0,d.Uo)(t,(t=>{const s=M(t,e);s&&i.push(s)})),i}function U(t,e,i){const s=(0,T.n$)(),n=M(t,{serializationContext:i,parentNodePrivacyLevel:e.defaultPrivacyLevel,configuration:e});return(0,x.ik)(i.serializationStats,"serializationDuration",(0,T._J)(s,(0,T.n$)())),n}function B(t){return Boolean(t.changedTouches)}function j(t){return!0===t.composed&&(0,d.aT)(t.target)?t.composedPath()[0]:t.target}var G=i(5523);function V(t,e){return{data:{source:t,...e},type:S.IncrementalSnapshot,timestamp:(0,T.n$)()}}const H=50;function K(t,e){const{throttled:i,cancel:s}=(0,l.P)((t=>{const i=j(t);if(f(i)){const s=Y(t);if(!s)return;const n={id:p(i),timeOffset:0,x:s.x,y:s.y};e(V(B(t)?w.TouchMove:w.MouseMove,{positions:[n]}))}}),H,{trailing:!1}),{stop:n}=(0,c.y)(t,document,["mousemove","touchmove"],i,{capture:!0,passive:!0});return{stop:()=>{n(),s()}}}function Y(t){let{clientX:e,clientY:i}=B(t)?t.changedTouches[0]:t;if(window.visualViewport){const{visualViewportX:t,visualViewportY:s}=(0,G.n)(e,i);e=t,i=s}if(Number.isFinite(e)&&Number.isFinite(i))return{x:e,y:i};t.isTrusted&&(0,s.eJ)("mouse/touch event without x/y")}const q={pointerup:A.MouseUp,mousedown:A.MouseDown,click:A.Click,contextmenu:A.ContextMenu,dblclick:A.DblClick,focus:A.Focus,blur:A.Blur,touchstart:A.TouchStart,touchend:A.TouchEnd};function z(t,e,i){return(0,c.y)(t,document,Object.keys(q),(s=>{const n=j(s);if((0,d.IE)(n,t.defaultPrivacyLevel)===d.zx.HIDDEN||!f(n))return;const r=p(n),a=q[s.type];let o;if(a!==A.Blur&&a!==A.Focus){const t=Y(s);if(!t)return;o={id:r,type:a,x:t.x,y:t.y}}else o={id:r,type:a};const l={id:i.getIdForEvent(s),...V(w.MouseInteraction,o)};e(l)}),{capture:!0,passive:!0})}const W=100;function X(t,e,i,s=document){const{throttled:n,cancel:r}=(0,l.P)((s=>{const n=j(s);if(!n||(0,d.IE)(n,t.defaultPrivacyLevel)===d.zx.HIDDEN||!f(n))return;const r=p(n),a=n===document?{scrollTop:(0,d.X_)(),scrollLeft:(0,d.$1)()}:{scrollTop:Math.round(n.scrollTop),scrollLeft:Math.round(n.scrollLeft)};i.set(n,a),e(V(w.Scroll,{id:r,x:a.scrollLeft,y:a.scrollTop}))}),W),{stop:a}=(0,c.O)(t,s,"scroll",n,{capture:!0,passive:!0});return{stop:()=>{a(),r()}}}const J=200;function Q(t,e){const i=(0,d.AX)(t).subscribe((t=>{e(V(w.ViewportResize,t))}));return{stop:()=>{i.unsubscribe()}}}function Z(t,e){const i=window.visualViewport;if(!i)return{stop:l.Z};const{throttled:s,cancel:n}=(0,l.P)((()=>{e({data:(0,G.m)(i),type:S.VisualViewport,timestamp:(0,T.n$)()})}),J,{trailing:!1}),{stop:r}=(0,c.y)(t,i,["resize","scroll"],s,{capture:!0,passive:!0});return{stop:()=>{r(),n()}}}function tt(t,e){return(0,c.y)(t,document,["play","pause"],(i=>{const s=j(i);s&&(0,d.IE)(s,t.defaultPrivacyLevel)!==d.zx.HIDDEN&&f(s)&&e(V(w.MediaInteraction,{id:p(s),type:"play"===i.type?R.Play:R.Pause}))}),{capture:!0,passive:!0})}var et=i(5801);function it(t){function e(t,e){t&&f(t.ownerNode)&&e(p(t.ownerNode))}const i=[(0,et.S)(CSSStyleSheet.prototype,"insertRule",(({target:i,parameters:[s,n]})=>{e(i,(e=>t(V(w.StyleSheetRule,{id:e,adds:[{rule:s,index:n}]}))))})),(0,et.S)(CSSStyleSheet.prototype,"deleteRule",(({target:i,parameters:[s]})=>{e(i,(e=>t(V(w.StyleSheetRule,{id:e,removes:[{index:s}]}))))}))];function s(s){i.push((0,et.S)(s.prototype,"insertRule",(({target:i,parameters:[s,n]})=>{e(i.parentStyleSheet,(e=>{const r=st(i);r&&(r.push(n||0),t(V(w.StyleSheetRule,{id:e,adds:[{rule:s,index:r}]})))}))})),(0,et.S)(s.prototype,"deleteRule",(({target:i,parameters:[s]})=>{e(i.parentStyleSheet,(e=>{const n=st(i);n&&(n.push(s),t(V(w.StyleSheetRule,{id:e,removes:[{index:n}]})))}))})))}return"undefined"!=typeof CSSGroupingRule?s(CSSGroupingRule):(s(CSSMediaRule),s(CSSSupportsRule)),{stop:()=>{i.forEach((t=>t.stop()))}}}function st(t){const e=[];let i=t;for(;i.parentRule;){const t=Array.from(i.parentRule.cssRules).indexOf(i);e.unshift(t),i=i.parentRule}if(!i.parentStyleSheet)return;const s=Array.from(i.parentStyleSheet.cssRules).indexOf(i);return e.unshift(s),e}function nt(t,e){return(0,c.y)(t,window,["focus","blur"],(()=>{e({data:{has_focus:document.hasFocus()},type:S.Focus,timestamp:(0,T.n$)()})}))}function rt(t,e,i){const s=t.subscribe(12,(t=>{var s,n;t.rawRumEvent.type===d.D$.ACTION&&t.rawRumEvent.action.type===d.Us.CLICK&&(null===(n=null===(s=t.rawRumEvent.action.frustration)||void 0===s?void 0:s.type)||void 0===n?void 0:n.length)&&"events"in t.domainContext&&t.domainContext.events&&t.domainContext.events.length&&e({timestamp:t.rawRumEvent.date,type:S.FrustrationRecord,data:{frustrationTypes:t.rawRumEvent.action.frustration.type,recordIds:t.domainContext.events.map((t=>i.getIdForEvent(t)))}})}));return{stop:()=>{s.unsubscribe()}}}function at(t,e){const i=t.subscribe(5,(()=>{e({timestamp:(0,T.n$)(),type:S.ViewEnd})}));return{stop:()=>{i.unsubscribe()}}}function ot(t,e,i=document){const s=t.defaultPrivacyLevel,n=new WeakMap,r=i!==document,{stop:a}=(0,c.y)(t,i,r?["change"]:["input","change"],(t=>{const e=j(t);(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement)&&u(e)}),{capture:!0,passive:!0});let o;if(r)o=l.Z;else{const t=[(0,et.X)(HTMLInputElement.prototype,"value",u),(0,et.X)(HTMLInputElement.prototype,"checked",u),(0,et.X)(HTMLSelectElement.prototype,"value",u),(0,et.X)(HTMLTextAreaElement.prototype,"value",u),(0,et.X)(HTMLSelectElement.prototype,"selectedIndex",u)];o=()=>{t.forEach((t=>t.stop()))}}return{stop:()=>{o(),a()}};function u(t){const e=(0,d.IE)(t,s);if(e===d.zx.HIDDEN)return;const i=t.type;let n;if("radio"===i||"checkbox"===i){if((0,d.gR)(t,e))return;n={isChecked:t.checked}}else{const i=g(t,e);if(void 0===i)return;n={text:i}}h(t,n);const r=t.name;"radio"===i&&r&&t.checked&&document.querySelectorAll(`input[type="radio"][name="${CSS.escape(r)}"]`).forEach((e=>{e!==t&&h(e,{isChecked:!1})}))}function h(t,i){if(!f(t))return;const s=n.get(t);s&&s.text===i.text&&s.isChecked===i.isChecked||(n.set(t,i),e(V(w.Input,{id:p(t),...i})))}}var lt=i(4933),ct=i(3156);function ut(t,e,i,s){const n=(0,d.q5)();if(!n)return{stop:l.Z,flush:l.Z};const r=(0,ct.W)((s=>{!function(t,e,i,s){const n=new Map;t.filter((t=>"childList"===t.type)).forEach((t=>{t.removedNodes.forEach((t=>{dt(t,s.removeShadowRoot)}))}));const r=t.filter((t=>t.target.isConnected&&function(t){let e=t;for(;e;){if(!f(e)&&!(0,d.VO)(e))return!1;e=(0,d.Ow)(e)}return!0}(t.target)&&(0,d.IE)(t.target,i.defaultPrivacyLevel,n)!==d.zx.HIDDEN)),a=(0,x.mk)(),{adds:o,removes:l,hasBeenSerialized:c}=function(t,e,i,s,n){const r=new Set,a=new Map;for(const e of t)e.addedNodes.forEach((t=>{r.add(t)})),e.removedNodes.forEach((t=>{r.has(t)||a.set(t,e.target),r.delete(t)}));const o=Array.from(r);o.sort(((t,e)=>{const i=t.compareDocumentPosition(e);return i&Node.DOCUMENT_POSITION_CONTAINED_BY?-1:i&Node.DOCUMENT_POSITION_CONTAINS||i&Node.DOCUMENT_POSITION_FOLLOWING?1:i&Node.DOCUMENT_POSITION_PRECEDING?-1:0}));const l=new Set,c={status:2,serializationStats:i,shadowRootsController:s},u=[];for(const t of o){if(g(t))continue;const s=(0,d.IE)(t.parentNode,e.defaultPrivacyLevel,n);if(s===d.zx.HIDDEN||s===d.zx.IGNORE)continue;const r=(0,T.n$)(),a=M(t,{serializedNodeIds:l,parentNodePrivacyLevel:s,serializationContext:c,configuration:e});if((0,x.ik)(i,"serializationDuration",(0,T._J)(r,(0,T.n$)())),!a)continue;const o=(0,d.Ow)(t);u.push({nextId:m(t),parentId:p(o),node:a})}const h=[];return a.forEach(((t,e)=>{f(e)&&h.push({parentId:p(t),id:p(e)})})),{adds:u,removes:h,hasBeenSerialized:g};function g(t){return f(t)&&l.has(p(t))}function m(t){let e=t.nextSibling;for(;e;){if(f(e))return p(e);e=e.nextSibling}return null}}(r.filter((t=>"childList"===t.type)),i,a,s,n),u=function(t,e,i){var s;const n=[],r=new Set,a=t.filter((t=>!r.has(t.target)&&(r.add(t.target),!0)));for(const t of a){if(t.target.textContent===t.oldValue)continue;const r=(0,d.IE)((0,d.Ow)(t.target),e.defaultPrivacyLevel,i);r!==d.zx.HIDDEN&&r!==d.zx.IGNORE&&n.push({id:p(t.target),value:null!==(s=(0,d.FB)(t.target,!1,r))&&void 0!==s?s:null})}return n}(r.filter((t=>"characterData"===t.type&&!c(t.target))),i,n),h=function(t,e,i){const s=[],n=new Map,r=t.filter((t=>{const e=n.get(t.target);return!(e&&e.has(t.attributeName)||(e?e.add(t.attributeName):n.set(t.target,new Set([t.attributeName])),0))})),a=new Map;for(const t of r){if(t.target.getAttribute(t.attributeName)===t.oldValue)continue;const n=(0,d.IE)(t.target,e.defaultPrivacyLevel,i),r=D(t.target,n,t.attributeName,e);let o;if("value"===t.attributeName){const e=g(t.target,n);if(void 0===e)continue;o=e}else o="string"==typeof r?r:null;let l=a.get(t.target);l||(l={id:p(t.target),attributes:{}},s.push(l),a.set(t.target,l)),l.attributes[t.attributeName]=o}return s}(r.filter((t=>"attributes"===t.type&&!c(t.target))),i,n);(u.length||h.length||l.length||o.length)&&e(V(w.Mutation,{adds:o,removes:l,texts:u,attributes:h}),a)}(s.concat(a.takeRecords()),t,e,i)})),a=new n((0,lt.zk)(r.addMutations));return a.observe(s,{attributeOldValue:!0,attributes:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0}),{stop:()=>{a.disconnect(),r.stop()},flush:()=>{r.flush()}}}function dt(t,e){(0,d.aT)(t)&&e(t.shadowRoot),(0,d.Uo)(t,(t=>dt(t,e)))}var ht=i(5159);const ft=(t,e,i)=>{const s=new Map,n={addShadowRoot:r=>{if(s.has(r))return;const a=ut(e,t,n,r),o=ot(t,e,r),l=X(t,e,i,r);s.set(r,{flush:()=>a.flush(),stop:()=>{a.stop(),o.stop(),l.stop()}})},removeShadowRoot:t=>{const e=s.get(t);e&&(e.stop(),s.delete(t))},stop:()=>{s.forEach((({stop:t})=>t()))},flush:()=>{s.forEach((({flush:t})=>t()))}};return n};var pt=i(9411);var gt=i(7581),mt=i(5483),yt=i(76);function vt({context:t,creationReason:e,encoder:i}){let s=0;const n=t.view.id,r={start:1/0,end:-1/0,creation_reason:e,records_count:0,has_full_snapshot:!1,index_in_view:o.FT(n),source:"browser",...t},a=(0,x.mk)();return o.ui(n),{addRecord:function(t,e,n){r.start=Math.min(r.start,t.timestamp),r.end=Math.max(r.end,t.timestamp),r.records_count+=1,r.has_full_snapshot||(r.has_full_snapshot=t.type===S.FullSnapshot),e&&(0,x.mH)(a,e);const o=i.isEmpty?'{"records":[':",";i.write(o+JSON.stringify(t),(t=>{s+=t,n(s)}))},flush:function(t){if(i.isEmpty)throw new Error("Empty segment flushed");i.write(`],${JSON.stringify(r).slice(1)}\n`),i.finish((e=>{o.pk(r.view.id,e.rawBytesCount),t(r,a,e)}))}}}const bt=5*T.WT;let _t=6e4;function Et(t,e,i,s,n,r){return function(t,n,r,a){let o={status:0,nextSegmentCreationReason:"init"};const{unsubscribe:l}=t.subscribe(2,(()=>{u("view_change")})),{unsubscribe:c}=t.subscribe(11,(t=>{u(t.reason)}));function u(t){1===o.status&&(o.segment.flush(((e,i,s)=>{const n=(0,yt.H)(s.output,e,i,s.rawBytesCount);(0,gt.PT)(t)?r.sendOnExit(n):r.send(n)})),(0,mt.gr)(o.expirationTimeoutId)),o="stop"!==t?{status:0,nextSegmentCreationReason:t}:{status:2}}return{addRecord:(t,n)=>{if(2!==o.status){if(0===o.status){const t=function(t,e,i){const s=e.findTrackedSession(),n=i.findView();if(s&&n)return{application:{id:t},session:{id:s.id},view:{id:n.id}}}(e.applicationId,i,s);if(!t)return;o={status:1,segment:vt({encoder:a,context:t,creationReason:o.nextSegmentCreationReason}),expirationTimeoutId:(0,mt.iK)((()=>{u("segment_duration_limit")}),bt)}}o.segment.addRecord(t,n,(t=>{t>_t&&u("segment_bytes_limit")}))}},stop:()=>{u("stop"),l(),c()}}}(t,0,n,r)}var Tt=i(1946),St=i(9317);function kt(t,e,i,l,c,u,h){const f=[],p=h||(0,n.UF)([e.sessionReplayEndpointBuilder],_t,(e=>{t.notify(14,{error:e}),(0,s.eJ)("Error reported to customer",{"error.message":e.message})}));let g;if((0,r.xT)())({addRecord:g}=(0,St.d)(l));else{const s=Et(t,e,i,l,p,c);g=s.addRecord,f.push(s.stop);const n=(0,Tt.I)(e,u,p.observable);f.push(n.stop)}const{stop:m}=function(t){const{emit:e,configuration:i,lifeCycle:s}=t;if(!e)throw new Error("emit function is required");const n=(i,s)=>{e(i,s),(0,a.j)("record",{record:i});const n=t.viewHistory.findView();o.xK(n.id)},r=(0,ht.N)(),l=ft(i,n,r),{stop:c}=function(t,e,i,s,n,r){const a=(i,n)=>{const{width:a,height:o}=(0,d.PA)();r({data:{height:o,href:window.location.href,width:a},type:S.Meta,timestamp:i}),r({data:{has_focus:document.hasFocus()},type:S.Focus,timestamp:i});const l=(0,x.mk)();r({data:{node:U(document,s,{status:n,elementsScrollPositions:t,serializationStats:l,shadowRootsController:e}),initialOffset:{left:(0,d.$1)(),top:(0,d.X_)()}},type:S.FullSnapshot,timestamp:i},l),window.visualViewport&&r({data:(0,G.m)(window.visualViewport),type:S.VisualViewport,timestamp:i})};a((0,T.n$)(),0);const{unsubscribe:o}=i.subscribe(2,(t=>{n(),a(t.startClocks.timeStamp,1)}));return{stop:o}}(r,l,s,i,u,n);function u(){l.flush(),f.flush()}const h=(0,pt.b)(),f=ut(n,i,l,document),p=[f,K(i,n),z(i,n,h),X(i,n,r,document),Q(i,n),ot(i,n),tt(i,n),it(n),nt(i,n),Z(i,n),rt(s,n,h),at(s,(t=>{u(),n(t)}))];return{stop:()=>{l.stop(),p.forEach((t=>t.stop())),c()},flushMutations:u,shadowRootsController:l}}({emit:g,configuration:e,lifeCycle:t,viewHistory:l});return f.push(m),{stop:()=>{f.forEach((t=>t()))}}}},4376:(t,e,i)=>{"use strict";if(i.d(e,{x:()=>a}),179==i.j)var s=i(3206);if(179==i.j)var n=i(7198);if(179==i.j)var r=i(1962);function a(t,e,i){let a,o=0,l=[],c=0;const u=[],{stop:d}=(0,s.O)(t,e,"message",(({data:t})=>{if("wrote"!==t.type||t.streamId!==i)return;o+=t.additionalBytesCount,l.push(t.result),a=t.trailer;const e=u.shift();e&&e.id===t.id?e.writeCallback?e.writeCallback(t.result.byteLength):e.finishCallback&&e.finishCallback():(d(),(0,n.eJ)("Worker responses received out of order."))}));function h(){const t=0===l.length?new Uint8Array(0):(0,r.Kb)(l.concat(a)),e={rawBytesCount:o,output:t,outputBytesCount:t.byteLength,encoding:"deflate"};return o=0,l=[],e}function f(){c>0&&(e.postMessage({action:"reset",streamId:i}),c=0)}return{isAsync:!0,get isEmpty(){return 0===c},write(t,s){e.postMessage({action:"write",id:c,data:t,streamId:i}),u.push({id:c,writeCallback:s,data:t}),c+=1},finish(t){f(),u.length?(u.forEach((t=>{delete t.writeCallback})),u[u.length-1].finishCallback=()=>t(h())):t(h())},finishSync(){f();const t=u.map((t=>(delete t.writeCallback,delete t.finishCallback,t.data))).join("");return{...h(),pendingData:t}},estimateEncodedBytesCount:t=>t.length/8,stop(){d()}}}},8478:(t,e,i)=>{"use strict";i.r(e),i.d(e,{DEFAULT_RUM_PROFILER_CONFIGURATION:()=>y,createRumProfiler:()=>v});var s=i(3206),n=i(5026),r=i(9271),a=i(4933),o=i(3842),l=i(5483),c=i(782),u=i(8873);const d=new Map;function h(t){for(const e of d.keys())e{const{profilingEndpointBuilder:s,applicationId:r}=e,a=function(t,e,i){const s=(0,p.MS)(e),r=function(t,e,i){const s={application:{id:e}};i&&(s.session={id:i});const n=Array.from(new Set(t.views.map((t=>t.viewId))));n.length&&(s.view={id:n});const r=t.longTasks.map((t=>t.id)).filter((t=>void 0!==t));return r.length&&(s.long_task={id:r}),s}(t,e.applicationId,i),a=function(t){return t.concat(["language:javascript","runtime:chrome","family:chrome","host:browser"])}(s);return{...r,attachments:["wall-time.json"],start:new Date(t.startClocks.timeStamp).toISOString(),end:new Date(t.endClocks.timeStamp).toISOString(),family:"chrome",runtime:"chrome",format:"json",version:4,tags_profiler:a.join(","),_dd:{clock_drift:(0,n.QA)()}}}(t,e,i),o=function(t,e){const i=new Blob([JSON.stringify(t)],{type:"application/json"}),s=new FormData;return s.append("event",new Blob([JSON.stringify(e)],{type:"application/json"}),"event.json"),s.append("wall-time.json",i,"wall-time.json"),{data:s,bytesCount:0}}(t,a),l=s.build("fetch",o);return(0,f.eJ)("Sending profile to public profiling intake",{profilingIntakeURL:l,applicationId:r,sessionId:i}),fetch(l,{body:o.data,method:"POST"})}};var m=i(4996);const y={sampleIntervalMs:10,collectIntervalMs:6e4,minProfileDurationMs:5e3,minNumberOfSamples:50};function v(t,e,i,f,p=y){const v=(0,c.wM)(c.uo.LONG_ANIMATION_FRAME);let b;const _=[];let E={state:"stopped"};function T(){const i=(0,r.R)().Profiler;if(!i)throw f.set({status:"error",error_reason:"not-supported-by-browser"}),new Error("RUM Profiler is not supported in this browser.");S(E).catch(a.$y);const{cleanupTasks:s,observer:u}=function(i){if("running"===i.state)return{cleanupTasks:i.cleanupTasks,observer:i.observer};const s=[];let n;if(t.trackLongTasks){n=new PerformanceObserver(R),n.observe({entryTypes:[v?"long-animation-frame":"longtask"]});const t=e.subscribe(12,(t=>{!function({rawRumEvent:t,startTime:e}){t.type===c.D$.LONG_TASK&&function(t,e){d.set(e,t)}(t.long_task.id,e)}(t)}));s.push((()=>null==n?void 0:n.disconnect())),s.push(t.unsubscribe)}const r=e.subscribe(2,(t=>{const e={viewId:t.id,viewName:(0,m.M)(t.name,document.location.pathname),startClocks:t.startClocks};w(e),b=e}));return s.push(r.unsubscribe),{cleanupTasks:s,observer:n}}(E);let h;try{h=new i({sampleInterval:p.sampleIntervalMs,maxBufferSize:Math.round(1.5*p.collectIntervalMs/p.sampleIntervalMs)})}catch(t){return void(t instanceof Error&&t.message.includes("disabled by Document Policy")?(o.jf.warn("[DD_RUM] Profiler startup failed. Ensure your server includes the `Document-Policy: js-profiling` response header when serving HTML pages.",t),f.set({status:"error",error_reason:"missing-document-policy-header"})):f.set({status:"error",error_reason:"unexpected-exception"}))}f.set({status:"running",error_reason:void 0}),E={state:"running",startClocks:(0,n.$I)(),profiler:h,timeoutId:(0,l.iK)(T,p.collectIntervalMs),longTasks:[],views:[],cleanupTasks:s,observer:u},w(b),h.addEventListener("samplebufferfull",A)}async function S(e){var s,r;if("running"!==e.state)return;L(null!==(r=null===(s=e.observer)||void 0===s?void 0:s.takeRecords())&&void 0!==r?r:[]),(0,l.gr)(e.timeoutId),e.profiler.removeEventListener("samplebufferfull",A);const{startClocks:o,longTasks:c,views:d}=e,f=(0,n.$I)();await e.profiler.stop().then((e=>{const s=(0,n.$I)(),r=c.length>0,l=(0,n._J)(o.timeStamp,s.timeStamp)t())),await S(E),E={state:t})}function w(t){"running"===E.state&&t&&E.views.push(t)}function A(){T()}function R(t){L(t.getEntries())}function L(t){var e;if("running"===E.state)for(const i of t){if(i.durationt())),h((0,n.$I)().relative),f.set({status:"stopped",error_reason:void 0})},isStopped:function(){return"stopped"===E.state},isRunning:function(){return"running"===E.state},isPaused:function(){return"paused"===E.state}}}},8491:(t,e,i)=>{"use strict";if(i.d(e,{Y:()=>n}),179==i.j)var s=i(9271);function n(){return void 0!==(0,s.R)().Profiler}},4996:(t,e,i)=>{"use strict";if(i.d(e,{M:()=>n}),179==i.j)var s=i(7593);const n=(t,e)=>t||(0,s.D)(e)},7593:(t,e,i)=>{"use strict";i.d(e,{D:()=>n});const s=/\/(?![vV]\d{1,2}\/)([^/\d?]*\d+[^/?]*)/g;function n(t){return t?t.replace(s,"/?"):"/"}},8873:(t,e,i)=>{"use strict";function s(t){let e=0;for(const i of t)void 0!==i.stackId&&e++;return e}i.d(e,{G:()=>s})},5159:(t,e,i)=>{"use strict";function s(){const t=new WeakMap;return{set(e,i){(e!==document||document.scrollingElement)&&t.set(e===document?document.scrollingElement:e,i)},get:e=>t.get(e),has:e=>t.has(e)}}i.d(e,{N:()=>s})},3156:(t,e,i)=>{"use strict";if(i.d(e,{W:()=>o}),179==i.j)var s=i(251);if(179==i.j)var n=i(1337);const r=100,a=16;function o(t){let e=s.Z,i=[];function o(){e(),t(i),i=[]}const{throttled:l,cancel:c}=(0,s.P)(o,a,{leading:!1});return{addMutations:t=>{0===i.length&&(e=(0,n.Kk)(l,{timeout:r})),i.push(...t)},flush:o,stop:()=>{e(),c()}}}},9411:(t,e,i)=>{"use strict";function s(){const t=new WeakMap;let e=1;return{getIdForEvent:i=>(t.has(i)||t.set(i,e++),t.get(i))}}i.d(e,{b:()=>s})},1612:(t,e,i)=>{"use strict";function s(){return{cssText:{count:0,max:0,sum:0},serializationDuration:{count:0,max:0,sum:0}}}function n(t,e,i){t[e].count+=1,t[e].max=Math.max(t[e].max,i),t[e].sum+=i}function r(t,e){for(const i of["cssText","serializationDuration"])t[i].count+=e[i].count,t[i].max=Math.max(t[i].max,e[i].max),t[i].sum+=e[i].sum}i.d(e,{ik:()=>n,mH:()=>r,mk:()=>s})},6084:(t,e,i)=>{"use strict";function s(t){if(void 0!==t&&0!==t.length)return t.map((t=>{const e=t.cssRules||t.rules;return{cssRules:Array.from(e,(t=>t.cssText)),disabled:t.disabled||void 0,media:t.media.length>0?Array.from(t.media):void 0}}))}i.d(e,{x:()=>s})},5523:(t,e,i)=>{"use strict";i.d(e,{m:()=>n,n:()=>s});const s=(t,e)=>{const i=window.visualViewport,s={layoutViewportX:t,layoutViewportY:e,visualViewportX:t,visualViewportY:e};return i?(function(t){return Math.abs(t.pageTop-t.offsetTop-window.scrollY)>25||Math.abs(t.pageLeft-t.offsetLeft-window.scrollX)>25}(i)?(s.layoutViewportX=Math.round(t+i.offsetLeft),s.layoutViewportY=Math.round(e+i.offsetTop)):(s.visualViewportX=Math.round(t-i.offsetLeft),s.visualViewportY=Math.round(e-i.offsetTop)),s):s},n=t=>({scale:t.scale,offsetLeft:t.offsetLeft,offsetTop:t.offsetTop,pageLeft:t.pageLeft,pageTop:t.pageTop,height:t.height,width:t.width})},8290:(t,e,i)=>{"use strict";i.d(e,{FT:()=>r,MA:()=>c,pk:()=>l,ui:()=>a,xK:()=>o});const s=1e3;let n;function r(t){return u(t).segments_count}function a(t){u(t).segments_count+=1}function o(t){u(t).records_count+=1}function l(t,e){u(t).segments_total_raw_size+=e}function c(t){return null==n?void 0:n.get(t)}function u(t){let e;return n||(n=new Map),n.has(t)?e=n.get(t):(e={records_count:0,segments_count:0,segments_total_raw_size:0},n.set(t,e),n.size>s&&function(){if(!n)return;const t=n.keys().next().value;t&&n.delete(t)}()),e}},9833:(t,e,i)=>{"use strict";if(i.d(e,{j:()=>r}),179==i.j)var s=i(3842);if(179==i.j)var n=i(7198);function r({configuredUrl:t,error:e,source:i,scriptType:r}){if(s.jf.error(`${i} failed to start: an error occurred while initializing the ${r}:`,e),e instanceof Event||e instanceof Error&&((a=e.message).includes("Content Security Policy")||a.includes("requires 'TrustedScriptURL'"))){let e;e=t?`Please make sure the ${r} URL ${t} is correct and CSP is correctly configured.`:"Please make sure CSP is correctly configured.",s.jf.error(`${e} See documentation at ${s.aA}/integrations/content_security_policy_logs/#use-csp-with-real-user-monitoring-and-session-replay`)}else"worker"===r&&(0,n.Sz)(e);var a}},76:(t,e,i)=>{"use strict";function s(t,e,i,s){const n=new FormData;n.append("segment",new Blob([t],{type:"application/octet-stream"}),`${e.session.id}-${e.start}`);const r={raw_segment_size:s,compressed_segment_size:t.byteLength,...e},a=JSON.stringify(r);return n.append("event",new Blob([a],{type:"application/json"})),{data:n,bytesCount:t.byteLength,cssText:i.cssText,isFullSnapshot:0===e.index_in_view,rawSize:s,recordCount:e.records_count,serializationDuration:i.serializationDuration}}i.d(e,{H:()=>s})},1946:(t,e,i)=>{"use strict";if(i.d(e,{I:()=>o}),179==i.j)var s=i(3603);if(179==i.j)var n=i(251);if(179==i.j)var r=i(7198);const a="Segment network request metrics";function o(t,e,i){if(!e.enabled||!(0,s.y7)(t.replayTelemetrySampleRate))return{stop:n.Z};const{unsubscribe:o}=i.subscribe((t=>{if("failure"===t.type||"queue-full"===t.type||"success"===t.type&&t.payload.isFullSnapshot){const n=(e=t.type,i=t.bandwidth,{cssText:{count:(s=t.payload).cssText.count,max:s.cssText.max,sum:s.cssText.sum},isFullSnapshot:s.isFullSnapshot,ongoingRequests:{count:i.ongoingRequestCount,totalSize:i.ongoingByteCount},recordCount:s.recordCount,result:e,serializationDuration:{count:s.serializationDuration.count,max:s.serializationDuration.max,sum:s.serializationDuration.sum},size:{compressed:s.bytesCount,raw:s.rawSize}});(0,r.qZ)(a,{metrics:n})}var e,i,s}));return{stop:o}}},9317:(t,e,i)=>{"use strict";if(i.d(e,{d:()=>n}),179==i.j)var s=i(6876);function n(t){const e=(0,s.Ad)();return{addRecord:i=>{const s=t.findView();e.send("record",i,s.id)}}}},9031:(t,e,i)=>{"use strict";if(i.d(e,{M:()=>l}),179==i.j)var s=i(3603);if(179==i.j)var n=i(251);if(179==i.j)var r=i(5026);if(179==i.j)var a=i(7198);const o="Recorder init metrics";function l(t,e,i){if(!e.enabled||!(0,s.y7)(t.replayTelemetrySampleRate))return{stop:n.Z};let l,c,u;const{unsubscribe:d}=i.subscribe((t=>{switch(t.type){case"start":l={forced:t.forced,timestamp:(0,r.n$)()},c=void 0,u=void 0;break;case"document-ready":l&&(c=(0,r._J)(l.timestamp,(0,r.n$)()));break;case"recorder-settled":l&&(u=(0,r._J)(l.timestamp,(0,r.n$)()));break;case"aborted":case"deflate-encoder-load-failed":case"recorder-load-failed":case"succeeded":d(),l&&(0,a.qZ)(o,{metrics:(e=l.forced,i=u,s=(0,r._J)(l.timestamp,(0,r.n$)()),n=t.type,h=c,{forced:e,loadRecorderModuleDuration:i,recorderInitDuration:s,result:n,waitForDocReadyDuration:h})})}var e,i,s,n,h}));return{stop:d}}},5751:(t,e,i)=>{"use strict";i.d(e,{v:()=>M});var s=i(8678),n=i(9271),r=i(782),a=i(6876),o=i(251),l=i(8290),c=i(4376),u=i(5026),d=i(3206),h=i(5483),f=i(3842),p=i(7198),g=i(9833);const m=30*u.WT;function y(t){return new Worker(t.workerUrl||URL.createObjectURL(new Blob(['(()=>{function t(t){const e=t.reduce((t,e)=>t+e.length,0),a=new Uint8Array(e);let n=0;for(const e of t)a.set(e,n),n+=e.length;return a}function e(t){for(var e=t.length;--e>=0;)t[e]=0}var a=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),n=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),r=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),i=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),s=Array(576);e(s);var h=Array(60);e(h);var l=Array(512);e(l);var _=Array(256);e(_);var o=Array(29);e(o);var d,u,f,c=Array(30);function p(t,e,a,n,r){this.static_tree=t,this.extra_bits=e,this.extra_base=a,this.elems=n,this.max_length=r,this.has_stree=t&&t.length}function g(t,e){this.dyn_tree=t,this.max_code=0,this.stat_desc=e}e(c);var v=function(t){return t<256?l[t]:l[256+(t>>>7)]},w=function(t,e){t.pending_buf[t.pending++]=255&e,t.pending_buf[t.pending++]=e>>>8&255},m=function(t,e,a){t.bi_valid>16-a?(t.bi_buf|=e<>16-t.bi_valid,t.bi_valid+=a-16):(t.bi_buf|=e<>>=1,a<<=1}while(--e>0);return a>>>1},z=function(t,e,a){var n,r,i=Array(16),s=0;for(n=1;n<=15;n++)i[n]=s=s+a[n-1]<<1;for(r=0;r<=e;r++){var h=t[2*r+1];0!==h&&(t[2*r]=y(i[h]++,h))}},k=function(t){var e;for(e=0;e<286;e++)t.dyn_ltree[2*e]=0;for(e=0;e<30;e++)t.dyn_dtree[2*e]=0;for(e=0;e<19;e++)t.bl_tree[2*e]=0;t.dyn_ltree[512]=1,t.opt_len=t.static_len=0,t.last_lit=t.matches=0},x=function(t){t.bi_valid>8?w(t,t.bi_buf):t.bi_valid>0&&(t.pending_buf[t.pending++]=t.bi_buf),t.bi_buf=0,t.bi_valid=0},A=function(t,e,a,n){var r=2*e,i=2*a;return t[r]>1;a>=1;a--)U(t,i,a);r=l;do{a=t.heap[1],t.heap[1]=t.heap[t.heap_len--],U(t,i,1),n=t.heap[1],t.heap[--t.heap_max]=a,t.heap[--t.heap_max]=n,i[2*r]=i[2*a]+i[2*n],t.depth[r]=(t.depth[a]>=t.depth[n]?t.depth[a]:t.depth[n])+1,i[2*a+1]=i[2*n+1]=r,t.heap[1]=r++,U(t,i,1)}while(t.heap_len>=2);t.heap[--t.heap_max]=t.heap[1],function(t,e){var a,n,r,i,s,h,l=e.dyn_tree,_=e.max_code,o=e.stat_desc.static_tree,d=e.stat_desc.has_stree,u=e.stat_desc.extra_bits,f=e.stat_desc.extra_base,c=e.stat_desc.max_length,p=0;for(i=0;i<=15;i++)t.bl_count[i]=0;for(l[2*t.heap[t.heap_max]+1]=0,a=t.heap_max+1;a<573;a++)(i=l[2*l[2*(n=t.heap[a])+1]+1]+1)>c&&(i=c,p++),l[2*n+1]=i,n>_||(t.bl_count[i]++,s=0,n>=f&&(s=u[n-f]),h=l[2*n],t.opt_len+=h*(i+s),d&&(t.static_len+=h*(o[2*n+1]+s)));if(0!==p){do{for(i=c-1;0===t.bl_count[i];)i--;t.bl_count[i]--,t.bl_count[i+1]+=2,t.bl_count[c]--,p-=2}while(p>0);for(i=c;0!==i;i--)for(n=t.bl_count[i];0!==n;)(r=t.heap[--a])>_||(l[2*r+1]!==i&&(t.opt_len+=(i-l[2*r+1])*l[2*r],l[2*r+1]=i),n--)}}(t,e),z(i,_,t.bl_count)},E=function(t,e,a){var n,r,i=-1,s=e[1],h=0,l=7,_=4;for(0===s&&(l=138,_=3),e[2*(a+1)+1]=65535,n=0;n<=a;n++)r=s,s=e[2*(n+1)+1],++h>>16&65535,s=0;0!==a;){a-=s=a>2e3?2e3:a;do{i=i+(r=r+e[n++]|0)|0}while(--s);r%=65521,i%=65521}return r|i<<16},S=new Uint32Array(function(){for(var t,e=[],a=0;a<256;a++){t=a;for(var n=0;n<8;n++)t=1&t?3988292384^t>>>1:t>>>1;e[a]=t}return e}()),T=function(t,e,a,n){var r=S,i=n+a;t^=-1;for(var s=n;s>>8^r[255&(t^e[s])];return-1^t},O={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},q=j,F=function(t,e,a){return t.pending_buf[t.d_buf+2*t.last_lit]=e>>>8&255,t.pending_buf[t.d_buf+2*t.last_lit+1]=255&e,t.pending_buf[t.l_buf+t.last_lit]=255&a,t.last_lit++,0===e?t.dyn_ltree[2*a]++:(t.matches++,e--,t.dyn_ltree[2*(_[a]+256+1)]++,t.dyn_dtree[2*v(e)]++),t.last_lit===t.lit_bufsize-1},G=-2,H=258,J=262,K=103,N=113,P=666,Q=function(t,e){return t.msg=O[e],e},R=function(t){return(t<<1)-(t>4?9:0)},V=function(t){for(var e=t.length;--e>=0;)t[e]=0},W=function(t,e,a){return(e<t.avail_out&&(a=t.avail_out),0!==a&&(t.output.set(e.pending_buf.subarray(e.pending_out,e.pending_out+a),t.next_out),t.next_out+=a,e.pending_out+=a,t.total_out+=a,t.avail_out-=a,e.pending-=a,0===e.pending&&(e.pending_out=0))},Y=function(t,e){(function(t,e,a,n){var r,l,_=0;t.level>0?(2===t.strm.data_type&&(t.strm.data_type=function(t){var e,a=4093624447;for(e=0;e<=31;e++,a>>>=1)if(1&a&&0!==t.dyn_ltree[2*e])return 0;if(0!==t.dyn_ltree[18]||0!==t.dyn_ltree[20]||0!==t.dyn_ltree[26])return 1;for(e=32;e<256;e++)if(0!==t.dyn_ltree[2*e])return 1;return 0}(t)),I(t,t.l_desc),I(t,t.d_desc),_=function(t){var e;for(E(t,t.dyn_ltree,t.l_desc.max_code),E(t,t.dyn_dtree,t.d_desc.max_code),I(t,t.bl_desc),e=18;e>=3&&0===t.bl_tree[2*i[e]+1];e--);return t.opt_len+=3*(e+1)+5+5+4,e}(t),r=t.opt_len+3+7>>>3,(l=t.static_len+3+7>>>3)<=r&&(r=l)):r=l=a+5,a+4<=r&&-1!==e?M(t,e,a,n):4===t.strategy||l===r?(m(t,2+(n?1:0),3),B(t,s,h)):(m(t,4+(n?1:0),3),function(t,e,a,n){var r;for(m(t,e-257,5),m(t,a-1,5),m(t,n-4,4),r=0;r=0?t.block_start:-1,t.strstart-t.block_start,e),t.block_start=t.strstart,X(t.strm)},Z=function(t,e){t.pending_buf[t.pending++]=e},$=function(t,e){t.pending_buf[t.pending++]=e>>>8&255,t.pending_buf[t.pending++]=255&e},tt=function(t,e,a,n){var r=t.avail_in;return r>n&&(r=n),0===r?0:(t.avail_in-=r,e.set(t.input.subarray(t.next_in,t.next_in+r),a),1===t.state.wrap?t.adler=L(t.adler,e,r,a):2===t.state.wrap&&(t.adler=T(t.adler,e,r,a)),t.next_in+=r,t.total_in+=r,r)},et=function(t,e){var a,n,r=t.max_chain_length,i=t.strstart,s=t.prev_length,h=t.nice_match,l=t.strstart>t.w_size-J?t.strstart-(t.w_size-J):0,_=t.window,o=t.w_mask,d=t.prev,u=t.strstart+H,f=_[i+s-1],c=_[i+s];t.prev_length>=t.good_match&&(r>>=2),h>t.lookahead&&(h=t.lookahead);do{if(_[(a=e)+s]===c&&_[a+s-1]===f&&_[a]===_[i]&&_[++a]===_[i+1]){i+=2,a++;do{}while(_[++i]===_[++a]&&_[++i]===_[++a]&&_[++i]===_[++a]&&_[++i]===_[++a]&&_[++i]===_[++a]&&_[++i]===_[++a]&&_[++i]===_[++a]&&_[++i]===_[++a]&&is){if(t.match_start=e,s=n,n>=h)break;f=_[i+s-1],c=_[i+s]}}}while((e=d[e&o])>l&&0!==--r);return s<=t.lookahead?s:t.lookahead},at=function(t){var e,a,n,r,i,s=t.w_size;do{if(r=t.window_size-t.lookahead-t.strstart,t.strstart>=s+(s-J)){t.window.set(t.window.subarray(s,s+s),0),t.match_start-=s,t.strstart-=s,t.block_start-=s,e=a=t.hash_size;do{n=t.head[--e],t.head[e]=n>=s?n-s:0}while(--a);e=a=s;do{n=t.prev[--e],t.prev[e]=n>=s?n-s:0}while(--a);r+=s}if(0===t.strm.avail_in)break;if(a=tt(t.strm,t.window,t.strstart+t.lookahead,r),t.lookahead+=a,t.lookahead+t.insert>=3)for(i=t.strstart-t.insert,t.ins_h=t.window[i],t.ins_h=W(t,t.ins_h,t.window[i+1]);t.insert&&(t.ins_h=W(t,t.ins_h,t.window[i+3-1]),t.prev[i&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=i,i++,t.insert--,!(t.lookahead+t.insert<3)););}while(t.lookahead=3&&(t.ins_h=W(t,t.ins_h,t.window[t.strstart+3-1]),a=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),0!==a&&t.strstart-a<=t.w_size-J&&(t.match_length=et(t,a)),t.match_length>=3)if(n=F(t,t.strstart-t.match_start,t.match_length-3),t.lookahead-=t.match_length,t.match_length<=t.max_lazy_match&&t.lookahead>=3){t.match_length--;do{t.strstart++,t.ins_h=W(t,t.ins_h,t.window[t.strstart+3-1]),a=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart}while(0!==--t.match_length);t.strstart++}else t.strstart+=t.match_length,t.match_length=0,t.ins_h=t.window[t.strstart],t.ins_h=W(t,t.ins_h,t.window[t.strstart+1]);else n=F(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++;if(n&&(Y(t,!1),0===t.strm.avail_out))return 1}return t.insert=t.strstart<2?t.strstart:2,4===e?(Y(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(Y(t,!1),0===t.strm.avail_out)?1:2},rt=function(t,e){for(var a,n,r;;){if(t.lookahead=3&&(t.ins_h=W(t,t.ins_h,t.window[t.strstart+3-1]),a=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),t.prev_length=t.match_length,t.prev_match=t.match_start,t.match_length=2,0!==a&&t.prev_length4096)&&(t.match_length=2)),t.prev_length>=3&&t.match_length<=t.prev_length){r=t.strstart+t.lookahead-3,n=F(t,t.strstart-1-t.prev_match,t.prev_length-3),t.lookahead-=t.prev_length-1,t.prev_length-=2;do{++t.strstart<=r&&(t.ins_h=W(t,t.ins_h,t.window[t.strstart+3-1]),a=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart)}while(0!==--t.prev_length);if(t.match_available=0,t.match_length=2,t.strstart++,n&&(Y(t,!1),0===t.strm.avail_out))return 1}else if(t.match_available){if((n=F(t,0,t.window[t.strstart-1]))&&Y(t,!1),t.strstart++,t.lookahead--,0===t.strm.avail_out)return 1}else t.match_available=1,t.strstart++,t.lookahead--}return t.match_available&&(n=F(t,0,t.window[t.strstart-1]),t.match_available=0),t.insert=t.strstart<2?t.strstart:2,4===e?(Y(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(Y(t,!1),0===t.strm.avail_out)?1:2};function it(t,e,a,n,r){this.good_length=t,this.max_lazy=e,this.nice_length=a,this.max_chain=n,this.func=r}var st=[new it(0,0,0,0,function(t,e){var a=65535;for(a>t.pending_buf_size-5&&(a=t.pending_buf_size-5);;){if(t.lookahead<=1){if(at(t),0===t.lookahead&&0===e)return 1;if(0===t.lookahead)break}t.strstart+=t.lookahead,t.lookahead=0;var n=t.block_start+a;if((0===t.strstart||t.strstart>=n)&&(t.lookahead=t.strstart-n,t.strstart=n,Y(t,!1),0===t.strm.avail_out))return 1;if(t.strstart-t.block_start>=t.w_size-J&&(Y(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,4===e?(Y(t,!0),0===t.strm.avail_out?3:4):(t.strstart>t.block_start&&(Y(t,!1),t.strm.avail_out),1)}),new it(4,4,8,4,nt),new it(4,5,16,8,nt),new it(4,6,32,32,nt),new it(4,4,16,16,rt),new it(8,16,32,32,rt),new it(8,16,128,128,rt),new it(8,32,128,256,rt),new it(32,128,258,1024,rt),new it(32,258,258,4096,rt)];function ht(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=8,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(1146),this.dyn_dtree=new Uint16Array(122),this.bl_tree=new Uint16Array(78),V(this.dyn_ltree),V(this.dyn_dtree),V(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(16),this.heap=new Uint16Array(573),V(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),V(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}for(var lt=function(t){var e,i=function(t){if(!t||!t.state)return Q(t,G);t.total_in=t.total_out=0,t.data_type=2;var e=t.state;return e.pending=0,e.pending_out=0,e.wrap<0&&(e.wrap=-e.wrap),e.status=e.wrap?42:N,t.adler=2===e.wrap?0:1,e.last_flush=0,function(t){D||(function(){var t,e,i,g,v,w=Array(16);for(i=0,g=0;g<28;g++)for(o[g]=i,t=0;t<1<>=7;g<30;g++)for(c[g]=v<<7,t=0;t<1<5||e<0)return t?Q(t,G):G;var r=t.state;if(!t.output||!t.input&&0!==t.avail_in||r.status===P&&4!==e)return Q(t,0===t.avail_out?-5:G);r.strm=t;var i=r.last_flush;if(r.last_flush=e,42===r.status)if(2===r.wrap)t.adler=0,Z(r,31),Z(r,139),Z(r,8),r.gzhead?(Z(r,(r.gzhead.text?1:0)+(r.gzhead.hcrc?2:0)+(r.gzhead.extra?4:0)+(r.gzhead.name?8:0)+(r.gzhead.comment?16:0)),Z(r,255&r.gzhead.time),Z(r,r.gzhead.time>>8&255),Z(r,r.gzhead.time>>16&255),Z(r,r.gzhead.time>>24&255),Z(r,9===r.level?2:r.strategy>=2||r.level<2?4:0),Z(r,255&r.gzhead.os),r.gzhead.extra&&r.gzhead.extra.length&&(Z(r,255&r.gzhead.extra.length),Z(r,r.gzhead.extra.length>>8&255)),r.gzhead.hcrc&&(t.adler=T(t.adler,r.pending_buf,r.pending,0)),r.gzindex=0,r.status=69):(Z(r,0),Z(r,0),Z(r,0),Z(r,0),Z(r,0),Z(r,9===r.level?2:r.strategy>=2||r.level<2?4:0),Z(r,3),r.status=N);else{var h=8+(r.w_bits-8<<4)<<8;h|=(r.strategy>=2||r.level<2?0:r.level<6?1:6===r.level?2:3)<<6,0!==r.strstart&&(h|=32),h+=31-h%31,r.status=N,$(r,h),0!==r.strstart&&($(r,t.adler>>>16),$(r,65535&t.adler)),t.adler=1}if(69===r.status)if(r.gzhead.extra){for(a=r.pending;r.gzindex<(65535&r.gzhead.extra.length)&&(r.pending!==r.pending_buf_size||(r.gzhead.hcrc&&r.pending>a&&(t.adler=T(t.adler,r.pending_buf,r.pending-a,a)),X(t),a=r.pending,r.pending!==r.pending_buf_size));)Z(r,255&r.gzhead.extra[r.gzindex]),r.gzindex++;r.gzhead.hcrc&&r.pending>a&&(t.adler=T(t.adler,r.pending_buf,r.pending-a,a)),r.gzindex===r.gzhead.extra.length&&(r.gzindex=0,r.status=73)}else r.status=73;if(73===r.status)if(r.gzhead.name){a=r.pending;do{if(r.pending===r.pending_buf_size&&(r.gzhead.hcrc&&r.pending>a&&(t.adler=T(t.adler,r.pending_buf,r.pending-a,a)),X(t),a=r.pending,r.pending===r.pending_buf_size)){n=1;break}n=r.gzindexa&&(t.adler=T(t.adler,r.pending_buf,r.pending-a,a)),0===n&&(r.gzindex=0,r.status=91)}else r.status=91;if(91===r.status)if(r.gzhead.comment){a=r.pending;do{if(r.pending===r.pending_buf_size&&(r.gzhead.hcrc&&r.pending>a&&(t.adler=T(t.adler,r.pending_buf,r.pending-a,a)),X(t),a=r.pending,r.pending===r.pending_buf_size)){n=1;break}n=r.gzindexa&&(t.adler=T(t.adler,r.pending_buf,r.pending-a,a)),0===n&&(r.status=K)}else r.status=K;if(r.status===K&&(r.gzhead.hcrc?(r.pending+2>r.pending_buf_size&&X(t),r.pending+2<=r.pending_buf_size&&(Z(r,255&t.adler),Z(r,t.adler>>8&255),t.adler=0,r.status=N)):r.status=N),0!==r.pending){if(X(t),0===t.avail_out)return r.last_flush=-1,0}else if(0===t.avail_in&&R(e)<=R(i)&&4!==e)return Q(t,-5);if(r.status===P&&0!==t.avail_in)return Q(t,-5);if(0!==t.avail_in||0!==r.lookahead||0!==e&&r.status!==P){var l=2===r.strategy?function(t,e){for(var a;;){if(0===t.lookahead&&(at(t),0===t.lookahead)){if(0===e)return 1;break}if(t.match_length=0,a=F(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++,a&&(Y(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,4===e?(Y(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(Y(t,!1),0===t.strm.avail_out)?1:2}(r,e):3===r.strategy?function(t,e){for(var a,n,r,i,s=t.window;;){if(t.lookahead<=H){if(at(t),t.lookahead<=H&&0===e)return 1;if(0===t.lookahead)break}if(t.match_length=0,t.lookahead>=3&&t.strstart>0&&(n=s[r=t.strstart-1])===s[++r]&&n===s[++r]&&n===s[++r]){i=t.strstart+H;do{}while(n===s[++r]&&n===s[++r]&&n===s[++r]&&n===s[++r]&&n===s[++r]&&n===s[++r]&&n===s[++r]&&n===s[++r]&&rt.lookahead&&(t.match_length=t.lookahead)}if(t.match_length>=3?(a=F(t,1,t.match_length-3),t.lookahead-=t.match_length,t.strstart+=t.match_length,t.match_length=0):(a=F(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++),a&&(Y(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,4===e?(Y(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(Y(t,!1),0===t.strm.avail_out)?1:2}(r,e):st[r.level].func(r,e);if(3!==l&&4!==l||(r.status=P),1===l||3===l)return 0===t.avail_out&&(r.last_flush=-1),0;if(2===l&&(1===e?function(t){m(t,2,3),b(t,256,s),function(t){16===t.bi_valid?(w(t,t.bi_buf),t.bi_buf=0,t.bi_valid=0):t.bi_valid>=8&&(t.pending_buf[t.pending++]=255&t.bi_buf,t.bi_buf>>=8,t.bi_valid-=8)}(t)}(r):5!==e&&(q(r,0,0,!1),3===e&&(V(r.head),0===r.lookahead&&(r.strstart=0,r.block_start=0,r.insert=0))),X(t),0===t.avail_out))return r.last_flush=-1,0}return 4!==e?0:r.wrap<=0?1:(2===r.wrap?(Z(r,255&t.adler),Z(r,t.adler>>8&255),Z(r,t.adler>>16&255),Z(r,t.adler>>24&255),Z(r,255&t.total_in),Z(r,t.total_in>>8&255),Z(r,t.total_in>>16&255),Z(r,t.total_in>>24&255)):($(r,t.adler>>>16),$(r,65535&t.adler)),X(t),r.wrap>0&&(r.wrap=-r.wrap),0!==r.pending?0:1)},ot=function(t){if(!t||!t.state)return G;var e=t.state.status;return 42!==e&&69!==e&&73!==e&&91!==e&&e!==K&&e!==N&&e!==P?Q(t,G):(t.state=null,e===N?Q(t,-3):0)},dt=new Uint8Array(256),ut=0;ut<256;ut++)dt[ut]=ut>=252?6:ut>=248?5:ut>=240?4:ut>=224?3:ut>=192?2:1;dt[254]=dt[254]=1;var ft=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0},ct=Object.prototype.toString;function pt(){this.options={level:-1,method:8,chunkSize:16384,windowBits:15,memLevel:8,strategy:0};var t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new ft,this.strm.avail_out=0;var e,a,n=function(t,e,a,n,r,i){if(!t)return G;var s=1;if(-1===e&&(e=6),n<0?(s=0,n=-n):n>15&&(s=2,n-=16),r<1||r>9||8!==a||n<8||n>15||e<0||e>9||i<0||i>4)return Q(t,G);8===n&&(n=9);var h=new ht;return t.state=h,h.strm=t,h.wrap=s,h.gzhead=null,h.w_bits=n,h.w_size=1<=n.w_size){0===r&&(V(n.head),n.strstart=0,n.block_start=0,n.insert=0);var i=new Uint8Array(n.w_size);i.set(e.subarray(a-n.w_size,a),0),e=i,a=n.w_size}var s=t.avail_in,h=t.next_in,l=t.input;for(t.avail_in=a,t.next_in=0,t.input=e,at(n);n.lookahead>=3;){var _=n.strstart,o=n.lookahead-2;do{n.ins_h=W(n,n.ins_h,n.window[_+3-1]),n.prev[_&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=_,_++}while(--o);n.strstart=_,n.lookahead=2,at(n)}return n.strstart+=n.lookahead,n.block_start=n.strstart,n.insert=n.lookahead,n.lookahead=0,n.match_length=n.prev_length=2,n.match_available=0,t.next_in=h,t.input=l,t.avail_in=s,n.wrap=r,0}(this.strm,r)))throw Error(O[n]);this._dict_set=!0}}function gt(t,e,a){try{t.postMessage({type:"errored",error:e,streamId:a})}catch(n){t.postMessage({type:"errored",error:e+"",streamId:a})}}function vt(t){const e=t.strm.adler;return new Uint8Array([3,0,e>>>24&255,e>>>16&255,e>>>8&255,255&e])}pt.prototype.push=function(t,e){var a,n,r=this.strm,i=this.options.chunkSize;if(this.ended)return!1;for(n=e===~~e?e:!0===e?4:0,"[object ArrayBuffer]"===ct.call(t)?r.input=new Uint8Array(t):r.input=t,r.next_in=0,r.avail_in=r.input.length;;)if(0===r.avail_out&&(r.output=new Uint8Array(i),r.next_out=0,r.avail_out=i),(2===n||3===n)&&r.avail_out<=6)this.onData(r.output.subarray(0,r.next_out)),r.avail_out=0;else{if(1===(a=_t(r,n)))return r.next_out>0&&this.onData(r.output.subarray(0,r.next_out)),a=ot(this.strm),this.onEnd(a),this.ended=!0,0===a;if(0!==r.avail_out){if(n>0&&r.next_out>0)this.onData(r.output.subarray(0,r.next_out)),r.avail_out=0;else if(0===r.avail_in)break}else this.onData(r.output)}return!0},pt.prototype.onData=function(t){this.chunks.push(t)},pt.prototype.onEnd=function(t){0===t&&(this.result=function(t){for(var e=0,a=0,n=t.length;a{try{const r=function(e,a){switch(a.action){case"init":return{type:"initialized",version:"6.18.1"};case"write":{let n=e.get(a.streamId);n||(n=new pt,e.set(a.streamId,n));const r=n.chunks.length,i=function(t){if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(t);let e,a,n,r,i,s=t.length,h=0;for(r=0;r>>6,e[i++]=128|63&a):a<65536?(e[i++]=224|a>>>12,e[i++]=128|a>>>6&63,e[i++]=128|63&a):(e[i++]=240|a>>>18,e[i++]=128|a>>>12&63,e[i++]=128|a>>>6&63,e[i++]=128|63&a);return e}(a.data);return n.push(i,2),{type:"wrote",id:a.id,streamId:a.streamId,result:t(n.chunks.slice(r)),trailer:vt(n),additionalBytesCount:i.length}}case"reset":e.delete(a.streamId)}}(a,n.data);r&&e.postMessage(r)}catch(t){gt(e,t,n.data&&"streamId"in n.data?n.data.streamId:void 0)}})}catch(t){gt(e,t)}}()})();'])))}let v={status:0};function b(t,e,i,s=y){switch(0===v.status&&function(t,e,i=y){try{const s=i(t),{stop:n}=(0,d.O)(t,s,"error",(i=>{E(t,e,i)})),{stop:r}=(0,d.O)(t,s,"message",(({data:i})=>{var s;"errored"===i.type?E(t,e,i.error,i.streamId):"initialized"===i.type&&(s=i.version,1===v.status&&(v={status:3,worker:v.worker,stop:v.stop,version:s}))}));s.postMessage({action:"init"}),(0,h.iK)((()=>function(t){1===v.status&&(f.jf.error(`${t} failed to start: a timeout occurred while initializing the Worker`),v.initializationFailureCallbacks.forEach((t=>t())),v={status:2})}(e)),m),v={status:1,worker:s,stop:()=>{n(),r()},initializationFailureCallbacks:[]}}catch(i){E(t,e,i)}}(t,e,s),v.status){case 1:return v.initializationFailureCallbacks.push(i),v.worker;case 3:return v.worker}}function _(){return v.status}function E(t,e,i,s){1===v.status||0===v.status?((0,g.j)({configuredUrl:t.workerUrl,error:i,source:e,scriptType:"worker"}),1===v.status&&v.initializationFailureCallbacks.forEach((t=>t())),v={status:2}):(0,p.Sz)(i,{worker_version:3===v.status&&v.version,stream_id:s})}var T=i(8259),S=i(3473),k=i(193),w=i(4933);var A=i(9031);function R(t,e,i,s,n,a,o){let l,c=0;e.subscribe(9,(()=>{2!==c&&3!==c||(f(),c=1)})),e.subscribe(10,(()=>{1===c&&h()}));const u=new S.y$;(0,A.M)(t,o,u);const d=async r=>{u.notify({type:"start",forced:r});const[d]=await Promise.all([L(u,{type:"recorder-settled"},n()),L(u,{type:"document-ready"},(0,k._)(t,"interactive"))]);if(2!==c)return void u.notify({type:"aborted"});if(!d)return c=0,void u.notify({type:"recorder-load-failed"});const h=a();if(!h)return c=0,void u.notify({type:"deflate-encoder-load-failed"});({stop:l}=d(e,t,i,s,h,o)),c=3,u.notify({type:"succeeded"})};function h(t){const e=i.findTrackedSession();if(function(t,e){return!t||0===t.sessionReplay&&(!e||!e.force)}(e,t))return void(c=1);if(function(t){return 2===t||3===t}(c))return;c=2;const s=function(t,e){return e&&e.force&&0===t.sessionReplay}(e,t)||!1;d(s).catch(w.$y),s&&i.setForcedReplay()}function f(){3===c&&(null==l||l()),c=0}return{start:h,stop:f,getSessionReplayLink:()=>function(t,e,i,s){const n=e.findTrackedSession(),a=function(t,e){return(0,T.T)()?t?0===t.sessionReplay?"incorrect-session-plan":e?void 0:"replay-not-started":"rum-not-tracked":"browser-not-supported"}(n,s),o=i.findView();return(0,r.Gm)(t,{viewContext:o,errorType:a,session:n})}(t,i,s,0!==c),isRecording:()=>3===c}}async function L(t,e,i){try{return await i}finally{t.notify(e)}}var I=i(2910);async function C(){return(await i.e(216).then(i.bind(i,1061))).startRecording}var D=i(8491),x=i(9643),P=i(4903);const O=function(t,e){if((0,a.xT)()&&!(0,a.ke)("records")||!(0,T.T)())return{start:o.Z,stop:o.Z,getReplayStats:()=>{},onRumStart:o.Z,isRecording:()=>!1,getSessionReplayLink:()=>{}};let{strategy:i,shouldStartImmediately:s}=(0,I.w)();return{start:t=>i.start(t),stop:()=>i.stop(),getSessionReplayLink:()=>i.getSessionReplayLink(),onRumStart:function(e,n,r,a,o,l){let u;i=R(n,e,r,a,t,(function(){return u||(null!=o||(o=b(n,"Datadog Session Replay",(()=>{i.stop()}),undefined)),o&&(u=(0,c.x)(n,o,1))),u}),l),s(n)&&i.start()},isRecording:()=>3===_()&&i.isRecording(),getReplayStats:t=>3===_()?(0,l.MA)(t):void 0}}((async function(t=C){try{return await t()}catch(t){(0,g.j)({error:t,source:"Recorder",scriptType:"module"})}})),N=function(){let t;return{onRumStart:function(e,i,s,n,a){const o=n.findTrackedSession();if(!o)return;if(!(0,r.HR)(o.id,s.profilingSampleRate))return;const l=(t=>{let e={status:"starting"};return t.register(0,(({eventType:t})=>t!==r.D$.VIEW&&t!==r.D$.LONG_TASK?x.kb:{type:t,_dd:{profiling:e}})),{get:()=>e,set:t=>{e=t}}})(i);(0,D.Y)()?(0,P.n)().then((i=>{if(!i)return(0,p.eJ)("[DD_RUM] Failed to lazy load the RUM Profiler"),void l.set({status:"error",error_reason:"failed-to-lazy-load"});t=i(s,e,n,l),t.start(a.findView())})).catch(w.$y):l.set({status:"error",error_reason:"not-supported-by-browser"})},stop:()=>{null==t||t.stop().catch(w.$y)}}}(),M=(0,r._r)(r.iB,O,N,{startDeflateWorker:b,createDeflateEncoder:c.x,sdkName:"rum"});(0,s.y)((0,n.R)(),"DD_RUM",M)},9921:(t,e,i)=>{"use strict";if(i.d(e,{j:()=>a}),179==i.j)var s=i(9791);if(179==i.j)var n=i(2343);if(179==i.j)var r=i(3821);function a(){r.m&&r.m.document?r.m.document.addEventListener("visibilitychange",(()=>{const t=(0,s.x1)();if(r.m.document.hidden&&t){const e="cancelled";("undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__)&&n.kg.log(`[Tracing] Transaction: ${e} -> since tab moved to the background, op: ${t.op}`),t.status||t.setStatus(e),t.setTag("visibilitychange","document.hidden"),t.finish()}})):("undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__)&&n.kg.warn("[Tracing] Could not set up background tab detection due to lack of global document")}},3956:(t,e,i)=>{"use strict";i.d(e,{gE:()=>A});var s=i(5544),n=i(3332),r=i(9791),a=i(2343),o=i(7638),l=i(8464),c=i(9921),u=i(7938),d=i(7522),h=i(5659),f=i(454),p=i(9732),g=i(1170),m=i(7321),y=i(9181),v=i(7597);const b=["localhost",/^\/(?!\/)/],_={traceFetch:!0,traceXHR:!0,enableHTTPTimings:!0,tracingOrigins:b,tracePropagationTargets:b};function E(t){const e=t.data.url,i=new PerformanceObserver((s=>{s.getEntries().forEach((s=>{"fetch"!==s.initiatorType&&"xmlhttprequest"!==s.initiatorType||!s.name.endsWith(e)||(function(t){const{name:e,version:i}=function(t){let e="unknown",i="unknown",s="";for(const n of t){if("/"===n){[e,i]=t.split("/");break}if(!isNaN(Number(n))){e="h"===s?"http":s,i=t.split(s)[1];break}s+=n}return s===t&&(e=s),{name:e,version:i}}(t.nextHopProtocol),s=[];return s.push(["network.protocol.version",i],["network.protocol.name",e]),g.Z1?[...s,["http.request.redirect_start",T(t.redirectStart)],["http.request.fetch_start",T(t.fetchStart)],["http.request.domain_lookup_start",T(t.domainLookupStart)],["http.request.domain_lookup_end",T(t.domainLookupEnd)],["http.request.connect_start",T(t.connectStart)],["http.request.secure_connection_start",T(t.secureConnectionStart)],["http.request.connection_end",T(t.connectEnd)],["http.request.request_start",T(t.requestStart)],["http.request.response_start",T(t.responseStart)],["http.request.response_end",T(t.responseEnd)]]:s}(s).forEach((e=>t.setData(...e))),i.disconnect())}))}));i.observe({entryTypes:["resource"]})}function T(t){return((g.Z1||performance.timeOrigin)+t)/1e3}function S(t,e,i){try{t.setRequestHeader("sentry-trace",e),i&&t.setRequestHeader(y.bU,i)}catch(t){}}var k=i(3821);const w={...s.AT,markBackgroundTransactions:!0,routingInstrumentation:function(t,e=!0,i=!0){if(!k.m||!k.m.location)return void(("undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__)&&a.kg.warn("Could not initialize routing instrumentation due to invalid location"));let s,n=k.m.location.href;e&&(s=t({name:k.m.location.pathname,startTimestamp:g.Z1?g.Z1/1e3:void 0,op:"pageload",metadata:{source:"url"}})),i&&(0,p.oq)("history",(({to:e,from:i})=>{void 0===i&&n&&-1!==n.indexOf(e)?n=void 0:i!==e&&(n=void 0,s&&(("undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__)&&a.kg.log(`[Tracing] Finishing current transaction with op: ${s.op}`),s.finish()),s=t({name:k.m.location.pathname,op:"navigation",metadata:{source:"url"}}))}))},startTransactionOnLocationChange:!0,startTransactionOnPageLoad:!0,enableLongTask:!0,_experiments:{},..._};class A{constructor(t){this.name="BrowserTracing",this._hasSetTracePropagationTargets=!1,(0,n.T)(),("undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__)&&(this._hasSetTracePropagationTargets=!(!t||!t.tracePropagationTargets&&!t.tracingOrigins)),this.options={...w,...t},void 0!==this.options._experiments.enableLongTask&&(this.options.enableLongTask=this.options._experiments.enableLongTask),t&&!t.tracePropagationTargets&&t.tracingOrigins&&(this.options.tracePropagationTargets=t.tracingOrigins),this._collectWebVitals=(0,u.PR)(),this.options.enableLongTask&&(0,u.Fv)(),this.options._experiments.enableInteractions&&(0,u.sn)()}setupOnce(t,e){this._getCurrentHub=e;const i=e().getClient(),s=i&&i.getOptions(),{routingInstrumentation:n,startTransactionOnLocationChange:r,startTransactionOnPageLoad:l,markBackgroundTransactions:u,traceFetch:g,traceXHR:T,shouldCreateSpanForRequest:k,enableHTTPTimings:w,_experiments:A}=this.options,R=s&&s.tracePropagationTargets,L=R||this.options.tracePropagationTargets;("undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__)&&this._hasSetTracePropagationTargets&&R&&a.kg.warn("[Tracing] The `tracePropagationTargets` option was set in the BrowserTracing integration and top level `Sentry.init`. The top level `Sentry.init` value is being used."),n((t=>{const i=this._createRouteTransaction(t);return this.options._experiments.onStartRouteTransaction&&this.options._experiments.onStartRouteTransaction(i,t,e),i}),l,r),u&&(0,c.j)(),A.enableInteractions&&this._registerInteractionListener(),function(t){const{traceFetch:e,traceXHR:i,tracePropagationTargets:s,tracingOrigins:n,shouldCreateSpanForRequest:r,enableHTTPTimings:a}={traceFetch:_.traceFetch,traceXHR:_.traceXHR,...t},l="function"==typeof r?r:t=>!0,c=t=>function(t,e){return(0,m.U0)(t,e||b)}(t,s||n),u={};e&&(0,p.oq)("fetch",(t=>{const e=function(t,e,i,s){if(!(0,d.z)()||!t.fetchData)return;const n=e(t.fetchData.url);if(t.endTimestamp&&n){const e=t.fetchData.__span;if(!e)return;const i=s[e];if(i){if(t.response){i.setHttpStatus(t.response.status);const e=t.response&&t.response.headers&&t.response.headers.get("content-length"),s=parseInt(e);s>0&&i.setData("http.response_content_length",s)}else t.error&&i.setStatus("internal_error");i.finish(),delete s[e]}return}const r=(0,h.Gd)(),a=r.getScope(),l=r.getClient(),c=a.getSpan(),{method:u,url:p}=t.fetchData,g=n&&c?c.startChild({data:{url:p,type:"fetch","http.method":u},description:`${u} ${p}`,op:"http.client"}):void 0;if(g&&(t.fetchData.__span=g.spanId,s[g.spanId]=g),i(t.fetchData.url)&&l){const e=t.args[0];t.args[1]=t.args[1]||{};const i=t.args[1];i.headers=function(t,e,i,s,n){const r=n||i.getSpan(),a=r&&r.transaction,{traceId:l,sampled:c,dsc:u}=i.getPropagationContext(),d=r?r.toTraceparent():(0,o.$p)(l,void 0,c),h=a?a.getDynamicSamplingContext():u||(0,f._)(l,e,i),p=(0,y.IQ)(h),g="undefined"!=typeof Request&&(0,v.V9)(t,Request)?t.headers:s.headers;if(g){if("undefined"!=typeof Headers&&(0,v.V9)(g,Headers)){const t=new Headers(g);return t.append("sentry-trace",d),p&&t.append(y.bU,p),t}if(Array.isArray(g)){const t=[...g,["sentry-trace",d]];return p&&t.push([y.bU,p]),t}{const t="baggage"in g?g.baggage:void 0,e=[];return Array.isArray(t)?e.push(...t):t&&e.push(t),p&&e.push(p),{...g,"sentry-trace":d,baggage:e.length>0?e.join(","):void 0}}}return{"sentry-trace":d,baggage:p}}(e,l,a,i,g)}return g}(t,l,c,u);a&&e&&E(e)})),i&&(0,p.oq)("xhr",(t=>{const e=function(t,e,i,s){const n=t.xhr,r=n&&n[p.xU];if(!(0,d.z)()||n&&n.__sentry_own_request__||!n||!r)return;const a=e(r.url);if(t.endTimestamp&&a){const t=n.__sentry_xhr_span_id__;if(!t)return;const e=s[t];return void(e&&(e.setHttpStatus(r.status_code),e.finish(),delete s[t]))}const l=(0,h.Gd)(),c=l.getScope(),u=c.getSpan(),g=a&&u?u.startChild({data:{...r.data,type:"xhr","http.method":r.method,url:r.url},description:`${r.method} ${r.url}`,op:"http.client"}):void 0;if(g&&(n.__sentry_xhr_span_id__=g.spanId,s[n.__sentry_xhr_span_id__]=g),n.setRequestHeader&&i(r.url))if(g){const t=g&&g.transaction,e=t&&t.getDynamicSamplingContext(),i=(0,y.IQ)(e);S(n,g.toTraceparent(),i)}else{const t=l.getClient(),{traceId:e,sampled:i,dsc:s}=c.getPropagationContext(),r=(0,o.$p)(e,void 0,i),a=s||(t?(0,f._)(e,t,c):void 0);S(n,r,(0,y.IQ)(a))}return g}(t,l,c,u);a&&e&&E(e)}))}({traceFetch:g,traceXHR:T,tracePropagationTargets:L,shouldCreateSpanForRequest:k,enableHTTPTimings:w})}_createRouteTransaction(t){if(!this._getCurrentHub)return void(("undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__)&&a.kg.warn(`[Tracing] Did not create ${t.op} transaction because _getCurrentHub is invalid.`));const e=this._getCurrentHub(),{beforeNavigate:i,idleTimeout:s,finalTimeout:r,heartbeatInterval:l}=this.options,c="pageload"===t.op,d=c?R("sentry-trace"):"",h=c?R("baggage"):"",{traceparentData:f,dynamicSamplingContext:p,propagationContext:g}=(0,o.KA)(d,h),m={...t,...f,metadata:{...t.metadata,dynamicSamplingContext:f&&!p?{}:p},trimEnd:!0},y="function"==typeof i?i(m):m,v=void 0===y?{...m,sampled:!1}:y;v.metadata=v.name!==m.name?{...v.metadata,source:"custom"}:v.metadata,this._latestRouteName=v.name,this._latestRouteSource=v.metadata&&v.metadata.source,!1===v.sampled&&("undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__)&&a.kg.log(`[Tracing] Will not send ${v.op} transaction because of beforeNavigate.`),("undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__)&&a.kg.log(`[Tracing] Starting ${v.op} transaction on scope`);const{location:b}=k.m,_=(0,n.l)(e,v,s,r,!0,{location:b},l),E=e.getScope();return c&&f?E.setPropagationContext(g):E.setPropagationContext({traceId:_.traceId,spanId:_.spanId,parentSpanId:_.parentSpanId,sampled:!!_.sampled}),_.registerBeforeFinishCallback((t=>{this._collectWebVitals(),(0,u.f7)(t)})),_}_registerInteractionListener(){let t;const e=()=>{const{idleTimeout:e,finalTimeout:i,heartbeatInterval:s}=this.options,o="ui.action.click",l=(0,r.x1)();if(l&&l.op&&["navigation","pageload"].includes(l.op))return void(("undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__)&&a.kg.warn(`[Tracing] Did not create ${o} transaction because a pageload or navigation transaction is in progress.`));if(t&&(t.setFinishReason("interactionInterrupted"),t.finish(),t=void 0),!this._getCurrentHub)return void(("undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__)&&a.kg.warn(`[Tracing] Did not create ${o} transaction because _getCurrentHub is invalid.`));if(!this._latestRouteName)return void(("undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__)&&a.kg.warn(`[Tracing] Did not create ${o} transaction because _latestRouteName is missing.`));const c=this._getCurrentHub(),{location:u}=k.m,d={name:this._latestRouteName,op:o,trimEnd:!0,metadata:{source:this._latestRouteSource||"url"}};t=(0,n.l)(c,d,e,i,!0,{location:u},s)};["click"].forEach((t=>{addEventListener(t,e,{once:!1,capture:!0})}))}}function R(t){const e=(0,l.qT)(`meta[name=${t}]`);return e?e.getAttribute("content"):void 0}},7938:(t,e,i)=>{"use strict";if(i.d(e,{Fv:()=>E,PR:()=>_,f7:()=>S,sn:()=>T}),179==i.j)var s=i(9791);if(179==i.j)var n=i(1170);if(179==i.j)var r=i(8464);if(179==i.j)var a=i(2343);if(179==i.j)var o=i(3821);if(179==i.j)var l=i(7882);if(179==i.j)var c=i(6794);if(179==i.j)var u=i(5236);if(179==i.j)var d=i(5029);if(179==i.j)var h=i(5792);if(179==i.j)var f=i(2349);function p(t){return t/1e3}function g(){return o.m&&o.m.addEventListener&&o.m.performance}let m,y,v=0,b={};function _(){const t=g();if(t&&n.Z1){t.mark&&o.m.performance.mark("sentry-tracing-init"),(0,c.F)((t=>{const e=t.entries.pop();if(!e)return;const i=p(n.Z1),s=p(e.startTime);("undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__)&&a.kg.log("[Measurements] Adding FID"),b.fid={value:t.value,unit:"millisecond"},b["mark.fid"]={value:i+s,unit:"second"}}));const e=(0,l.m)((t=>{const e=t.entries.pop();e&&(("undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__)&&a.kg.log("[Measurements] Adding CLS"),b.cls={value:t.value,unit:""},y=e)})),i=(0,u.N)((t=>{const e=t.entries.pop();e&&(("undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__)&&a.kg.log("[Measurements] Adding LCP"),b.lcp={value:t.value,unit:"millisecond"},m=e)}));return()=>{e&&e(),i&&i()}}return()=>{}}function E(){(0,h.N)("longtask",(t=>{for(const e of t){const t=(0,s.x1)();if(!t)return;const i=p(n.Z1+e.startTime),r=p(e.duration);t.startChild({description:"Main UI thread blocked",op:"ui.long-task",startTimestamp:i,endTimestamp:i+r})}}))}function T(){(0,h.N)("event",(t=>{for(const e of t){const t=(0,s.x1)();if(!t)return;if("click"===e.name){const i=p(n.Z1+e.startTime),s=p(e.duration);t.startChild({description:(0,r.Rt)(e.target),op:`ui.interaction.${e.name}`,startTimestamp:i,endTimestamp:i+s})}}}),{durationThreshold:0})}function S(t){const e=g();if(!e||!o.m.performance.getEntries||!n.Z1)return;("undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__)&&a.kg.log("[Tracing] Adding & adjusting spans using Performance API");const i=p(n.Z1),s=e.getEntries();let l,c;if(s.slice(v).forEach((e=>{const s=p(e.startTime),n=p(e.duration);if(!("navigation"===t.op&&i+s{k(t,e,s,i)})),k(t,e,"secureConnection",i,"TLS/SSL","connectEnd"),k(t,e,"fetch",i,"cache","domainLookupStart"),k(t,e,"domainLookup",i,"DNS"),function(t,e,i){(0,f.H)(t,{op:"browser",description:"request",startTimestamp:i+p(e.requestStart),endTimestamp:i+p(e.responseEnd)}),(0,f.H)(t,{op:"browser",description:"response",startTimestamp:i+p(e.responseStart),endTimestamp:i+p(e.responseEnd)})}(t,e,i)}(t,e,i),l=i+p(e.responseStart),c=i+p(e.requestStart);break;case"mark":case"paint":case"measure":{!function(t,e,i,s,n){const r=n+i,a=r+s;(0,f.H)(t,{description:e.name,endTimestamp:a,op:e.entryType,startTimestamp:r})}(t,e,s,n,i);const r=(0,d.Y)(),o=e.startTime{if(!b[e]||i>=t.startTimestamp)return;const s=b[e].value,n=i+p(s),r=Math.abs(1e3*(n-t.startTimestamp)),o=r-s;("undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__)&&a.kg.log(`[Measurements] Normalized ${e} from ${s} to ${r} (${o})`),b[e].value=r}));const e=b["mark.fid"];e&&b.fid&&((0,f.H)(t,{description:"first input delay",endTimestamp:e.value+p(b.fid.value),op:"ui.action",startTimestamp:e.value}),delete b["mark.fid"]),"fcp"in b||delete b.cls,Object.keys(b).forEach((e=>{t.setMeasurement(e,b[e].value,b[e].unit)})),function(t){m&&(("undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__)&&a.kg.log("[Measurements] Adding LCP Data"),m.element&&t.setTag("lcp.element",(0,r.Rt)(m.element)),m.id&&t.setTag("lcp.id",m.id),m.url&&t.setTag("lcp.url",m.url.trim().slice(0,200)),t.setTag("lcp.size",m.size)),y&&y.sources&&(("undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__)&&a.kg.log("[Measurements] Adding CLS Data"),y.sources.forEach(((e,i)=>t.setTag(`cls.source.${i+1}`,(0,r.Rt)(e.node)))))}(t)}m=void 0,y=void 0,b={}}function k(t,e,i,s,n,r){const a=r?e[r]:e[`${i}End`],o=e[`${i}Start`];o&&a&&(0,f.H)(t,{op:"browser",description:n||i,startTimestamp:s+p(o),endTimestamp:s+p(a)})}},2349:(t,e,i)=>{"use strict";function s(t){return"number"==typeof t&&isFinite(t)}function n(t,{startTimestamp:e,...i}){return e&&t.startTimestamp>e&&(t.startTimestamp=e),t.startChild({startTimestamp:e,...i})}i.d(e,{H:()=>n,n:()=>s})},3821:(t,e,i)=>{"use strict";if(i.d(e,{m:()=>n}),179==i.j)var s=i(1235);const n=179==i.j?s.n2:null},7882:(t,e,i)=>{"use strict";if(i.d(e,{m:()=>o}),179==i.j)var s=i(3076);if(179==i.j)var n=i(935);if(179==i.j)var r=i(5792);if(179==i.j)var a=i(188);const o=t=>{const e=(0,n.I)("CLS",0);let i,o=0,l=[];const c=t=>{t.forEach((t=>{if(!t.hadRecentInput){const s=l[0],n=l[l.length-1];o&&0!==l.length&&t.startTime-n.startTime<1e3&&t.startTime-s.startTime<5e3?(o+=t.value,l.push(t)):(o=t.value,l=[t]),o>e.value&&(e.value=o,e.entries=l,i&&i())}}))},u=(0,r.N)("layout-shift",c);if(u){i=(0,s._)(t,e);const n=()=>{c(u.takeRecords()),i(!0)};return(0,a.u)(n),n}}},6794:(t,e,i)=>{"use strict";if(i.d(e,{F:()=>l}),179==i.j)var s=i(3076);if(179==i.j)var n=i(5029);if(179==i.j)var r=i(935);if(179==i.j)var a=i(5792);if(179==i.j)var o=i(188);const l=t=>{const e=(0,n.Y)(),i=(0,r.I)("FID");let l;const c=t=>{t.startTime{t.forEach(c)},d=(0,a.N)("first-input",u);l=(0,s._)(t,i),d&&(0,o.u)((()=>{u(d.takeRecords()),d.disconnect()}),!0)}},5236:(t,e,i)=>{"use strict";if(i.d(e,{N:()=>u}),179==i.j)var s=i(3076);if(179==i.j)var n=i(4574);if(179==i.j)var r=i(5029);if(179==i.j)var a=i(935);if(179==i.j)var o=i(5792);if(179==i.j)var l=i(188);const c={},u=t=>{const e=(0,r.Y)(),i=(0,a.I)("LCP");let u;const d=t=>{const s=t[t.length-1];if(s){const t=Math.max(s.startTime-(0,n.A)(),0);t{c[i.id]||(d(h.takeRecords()),h.disconnect(),c[i.id]=!0,u(!0))};return["keydown","click"].forEach((t=>{addEventListener(t,e,{once:!0,capture:!0})})),(0,l.u)(e,!0),e}}},3076:(t,e,i)=>{"use strict";i.d(e,{_:()=>s});const s=(t,e,i)=>{let s,n;return r=>{e.value>=0&&(r||i)&&(n=e.value-(s||0),(n||void 0===s)&&(s=e.value,e.delta=n,t(e)))}}},752:(t,e,i)=>{"use strict";i.d(e,{f:()=>s});const s=()=>`v3-${Date.now()}-${Math.floor(8999999999999*Math.random())+1e12}`},4574:(t,e,i)=>{"use strict";if(i.d(e,{A:()=>n}),179==i.j)var s=i(9961);const n=()=>{const t=(0,s.W)();return t&&t.activationStart||0}},9961:(t,e,i)=>{"use strict";if(i.d(e,{W:()=>n}),179==i.j)var s=i(3821);const n=()=>s.m.__WEB_VITALS_POLYFILL__?s.m.performance&&(performance.getEntriesByType&&performance.getEntriesByType("navigation")[0]||(()=>{const t=s.m.performance.timing,e=s.m.performance.navigation.type,i={entryType:"navigation",startTime:0,type:2==e?"back_forward":1===e?"reload":"navigate"};for(const e in t)"navigationStart"!==e&&"toJSON"!==e&&(i[e]=Math.max(t[e]-t.navigationStart,0));return i})()):s.m.performance&&performance.getEntriesByType&&performance.getEntriesByType("navigation")[0]},5029:(t,e,i)=>{"use strict";if(i.d(e,{Y:()=>a}),179==i.j)var s=i(3821);if(179==i.j)var n=i(188);let r=179==i.j?-1:null;const a=()=>(r<0&&(r="hidden"!==s.m.document.visibilityState||s.m.document.prerendering?1/0:0,(0,n.u)((({timeStamp:t})=>{r=t}),!0)),{get firstHiddenTime(){return r}})},935:(t,e,i)=>{"use strict";if(i.d(e,{I:()=>o}),179==i.j)var s=i(3821);if(179==i.j)var n=i(752);if(179==i.j)var r=i(4574);if(179==i.j)var a=i(9961);const o=(t,e)=>{const i=(0,a.W)();let o="navigate";return i&&(o=s.m.document.prerendering||(0,r.A)()>0?"prerender":i.type.replace(/_/g,"-")),{name:t,value:void 0===e?-1:e,rating:"good",delta:0,entries:[],id:(0,n.f)(),navigationType:o}}},5792:(t,e,i)=>{"use strict";i.d(e,{N:()=>s});const s=(t,e,i)=>{try{if(PerformanceObserver.supportedEntryTypes.includes(t)){const s=new PerformanceObserver((t=>{e(t.getEntries())}));return s.observe(Object.assign({type:t,buffered:!0},i||{})),s}}catch(t){}}},188:(t,e,i)=>{"use strict";if(i.d(e,{u:()=>n}),179==i.j)var s=i(3821);const n=(t,e)=>{const i=n=>{"pagehide"!==n.type&&"hidden"!==s.m.document.visibilityState||(t(n),e&&(removeEventListener("visibilitychange",i,!0),removeEventListener("pagehide",i,!0)))};addEventListener("visibilitychange",i,!0),addEventListener("pagehide",i,!0)}},9680:(t,e,i)=>{"use strict";if(i.d(e,{R:()=>f}),179==i.j)var s=i(4219);if(179==i.j)var n=i(105);if(179==i.j)var r=i(8518);if(179==i.j)var a=i(2343);if(179==i.j)var o=i(7165);if(179==i.j)var l=i(292);if(179==i.j)var c=i(4773);if(179==i.j)var u=i(6891);if(179==i.j)var d=i(7729);if(179==i.j)var h=i(911);class f extends(179==i.j?s.W:null){constructor(t){const e=u.m9.SENTRY_SDK_SOURCE||(0,r.S)();t._metadata=t._metadata||{},t._metadata.sdk=t._metadata.sdk||{name:"sentry.javascript.browser",packages:[{name:`${e}:@sentry/browser`,version:n.J}],version:n.J},super(t),t.sendClientReports&&u.m9.document&&u.m9.document.addEventListener("visibilitychange",(()=>{"hidden"===u.m9.document.visibilityState&&this._flushOutcomes()}))}eventFromException(t,e){return(0,c.dr)(this._options.stackParser,t,e,this._options.attachStacktrace)}eventFromMessage(t,e="info",i){return(0,c.aB)(this._options.stackParser,t,e,i,this._options.attachStacktrace)}sendEvent(t,e){const i=this.getIntegrationById(d.p);i&&i.addSentryBreadcrumb&&i.addSentryBreadcrumb(t),super.sendEvent(t,e)}captureUserFeedback(t){if(!this._isEnabled())return void(("undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__)&&a.kg.warn("SDK not enabled, will not capture user feedback."));const e=(0,h.r)(t,{metadata:this.getSdkMetadata(),dsn:this.getDsn(),tunnel:this.getOptions().tunnel});this._sendEnvelope(e)}_prepareEvent(t,e,i){return t.platform=t.platform||"javascript",super._prepareEvent(t,e,i)}_flushOutcomes(){const t=this._clearOutcomes();if(0===t.length)return void(("undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__)&&a.kg.log("No outcomes to send"));if(!this._dsn)return void(("undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__)&&a.kg.log("No dsn provided, will not send outcomes"));("undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__)&&a.kg.log("Sending outcomes:",t);const e=(0,o.y)(t,this._options.tunnel&&(0,l.RA)(this._dsn));this._sendEnvelope(e)}}},4773:(t,e,i)=>{"use strict";if(i.d(e,{GJ:()=>c,ME:()=>m,aB:()=>g,dr:()=>p}),179==i.j)var s=i(5659);if(179==i.j)var n=i(7597);if(179==i.j)var r=i(322);if(179==i.j)var a=i(2844);if(179==i.j)var o=i(6893);if(179==i.j)var l=i(535);function c(t,e){const i=d(t,e),s={type:e&&e.name,value:f(e)};return i.length&&(s.stacktrace={frames:i}),void 0===s.type&&""===s.value&&(s.value="Unrecoverable error caught"),s}function u(t,e){return{exception:{values:[c(t,e)]}}}function d(t,e){const i=e.stacktrace||e.stack||"",s=function(t){if(t){if("number"==typeof t.framesToPop)return t.framesToPop;if(h.test(t.message))return 1}return 0}(e);try{return t(i,s)}catch(t){}return[]}const h=/Minified React error #\d+;/i;function f(t){const e=t&&t.message;return e?e.error&&"string"==typeof e.error.message?e.error.message:e:"No error message"}function p(t,e,i,s){const n=m(t,e,i&&i.syntheticException||void 0,s);return(0,a.EG)(n),n.level="error",i&&i.event_id&&(n.event_id=i.event_id),(0,o.WD)(n)}function g(t,e,i="info",s,n){const r=y(t,e,s&&s.syntheticException||void 0,n);return r.level=i,s&&s.event_id&&(r.event_id=s.event_id),(0,o.WD)(r)}function m(t,e,i,o,l){let c;if((0,n.VW)(e)&&e.error)return u(t,e.error);if((0,n.TX)(e)||(0,n.fm)(e)){const s=e;if("stack"in e)c=u(t,e);else{const e=s.name||((0,n.TX)(s)?"DOMError":"DOMException"),r=s.message?`${e}: ${s.message}`:e;c=y(t,r,i,o),(0,a.Db)(c,r)}return"code"in s&&(c.tags={...c.tags,"DOMException.code":`${s.code}`}),c}return(0,n.VZ)(e)?u(t,e):(0,n.PO)(e)||(0,n.cO)(e)?(c=function(t,e,i,a){const o=(0,s.Gd)().getClient(),l=o&&o.getOptions().normalizeDepth,c={exception:{values:[{type:(0,n.cO)(e)?e.constructor.name:a?"UnhandledRejection":"Error",value:v(e,{isUnhandledRejection:a})}]},extra:{__serialized__:(0,r.Qy)(e,l)}};if(i){const e=d(t,i);e.length&&(c.exception.values[0].stacktrace={frames:e})}return c}(t,e,i,l),(0,a.EG)(c,{synthetic:!0}),c):(c=y(t,e,i,o),(0,a.Db)(c,`${e}`,void 0),(0,a.EG)(c,{synthetic:!0}),c)}function y(t,e,i,s){const n={message:e};if(s&&i){const s=d(t,i);s.length&&(n.exception={values:[{value:e,stacktrace:{frames:s}}]})}return n}function v(t,{isUnhandledRejection:e}){const i=(0,l.zf)(t),s=e?"promise rejection":"exception";return(0,n.VW)(t)?`Event \`ErrorEvent\` captured as ${s} with message \`${t.message}\``:(0,n.cO)(t)?`Event \`${function(t){try{const e=Object.getPrototypeOf(t);return e?e.constructor.name:void 0}catch(t){}}(t)}\` (type=${t.type}) captured as ${s}`:`Object captured as ${s} with keys: ${i}`}},6891:(t,e,i)=>{"use strict";if(i.d(e,{Wz:()=>c,m9:()=>o,re:()=>u}),179==i.j)var s=i(4487);if(179==i.j)var n=i(1235);if(179==i.j)var r=i(535);if(179==i.j)var a=i(2844);const o=179==i.j?n.n2:null;let l=0;function c(){return l>0}function u(t,e={},i){if("function"!=typeof t)return t;try{const e=t.__sentry_wrapped__;if(e)return e;if((0,r.HK)(t))return t}catch(e){return t}const n=function(){const n=Array.prototype.slice.call(arguments);try{i&&"function"==typeof i&&i.apply(this,arguments);const s=n.map((t=>u(t,e)));return t.apply(this,s)}catch(t){throw l++,setTimeout((()=>{l--})),(0,s.$e)((i=>{i.addEventProcessor((t=>(e.mechanism&&((0,a.Db)(t,void 0,void 0),(0,a.EG)(t,e.mechanism)),t.extra={...t.extra,arguments:n},t))),(0,s.Tb)(t)})),t}};try{for(const e in t)Object.prototype.hasOwnProperty.call(t,e)&&(n[e]=t[e])}catch(t){}(0,r.$Q)(n,t),(0,r.xp)(t,"__sentry_wrapped__",n);try{Object.getOwnPropertyDescriptor(n,"name").configurable&&Object.defineProperty(n,"name",{get:()=>t.name})}catch(t){}return n}},7729:(t,e,i)=>{"use strict";i.d(e,{p:()=>h,O:()=>f});var s=i(5659);const n=["fatal","error","warning","log","info","debug"];function r(t){if(!t)return{};const e=t.match(/^(([^:/?#]+):)?(\/\/([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/);if(!e)return{};const i=e[6]||"",s=e[8]||"";return{host:e[4],path:e[5],protocol:e[2],search:i,hash:s,relative:e[5]+i+s}}var a=i(9732),o=i(2844),l=i(2343),c=i(8464),u=i(7321),d=i(6891);const h="Breadcrumbs";class f{static __initStatic(){this.id=h}constructor(t){this.name=f.id,this.options={console:!0,dom:!0,fetch:!0,history:!0,sentry:!0,xhr:!0,...t}}setupOnce(){var t;this.options.console&&(0,a.oq)("console",p),this.options.dom&&(0,a.oq)("dom",(t=this.options.dom,function(e){let i,n="object"==typeof t?t.serializeAttribute:void 0,r="object"==typeof t&&"number"==typeof t.maxStringLength?t.maxStringLength:void 0;r&&r>1024&&(("undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__)&&l.kg.warn(`\`dom.maxStringLength\` cannot exceed 1024, but a value of ${r} was configured. Sentry will use 1024 instead.`),r=1024),"string"==typeof n&&(n=[n]);try{const t=e.event;i=function(t){return!!t&&!!t.target}(t)?(0,c.Rt)(t.target,{keyAttrs:n,maxStringLength:r}):(0,c.Rt)(t,{keyAttrs:n,maxStringLength:r})}catch(t){i=""}0!==i.length&&(0,s.Gd)().addBreadcrumb({category:`ui.${e.name}`,message:i},{event:e.event,name:e.name,global:e.global})})),this.options.xhr&&(0,a.oq)("xhr",g),this.options.fetch&&(0,a.oq)("fetch",m),this.options.history&&(0,a.oq)("history",y)}addSentryBreadcrumb(t){this.options.sentry&&(0,s.Gd)().addBreadcrumb({category:"sentry."+("transaction"===t.type?"transaction":"event"),event_id:t.event_id,level:t.level,message:(0,o.jH)(t)},{event:t})}}function p(t){for(let e=0;e{"use strict";i.d(e,{S1:()=>Z});var s=i(2343),n=i(2844),r=i(7321);const a=[/^Script error\.?$/,/^Javascript error: Script error\.? on line 0$/],o=[/^.*healthcheck.*$/,/^.*healthy.*$/,/^.*live.*$/,/^.*ready.*$/,/^.*heartbeat.*$/,/^.*\/health$/,/^.*\/healthz$/];class l{static __initStatic(){this.id="InboundFilters"}constructor(t={}){this.name=l.id,this._options=t}setupOnce(t,e){const i=t=>{const i=e();if(i){const e=i.getIntegration(l);if(e){const l=i.getClient(),u=l?l.getOptions():{},d=function(t={},e={}){return{allowUrls:[...t.allowUrls||[],...e.allowUrls||[]],denyUrls:[...t.denyUrls||[],...e.denyUrls||[]],ignoreErrors:[...t.ignoreErrors||[],...e.ignoreErrors||[],...t.disableErrorDefaults?[]:a],ignoreTransactions:[...t.ignoreTransactions||[],...e.ignoreTransactions||[],...t.disableTransactionDefaults?[]:o],ignoreInternal:void 0===t.ignoreInternal||t.ignoreInternal}}(e._options,u);return function(t,e){return e.ignoreInternal&&function(t){try{return"SentryError"===t.exception.values[0].type}catch(t){}return!1}(t)?(("undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__)&&s.kg.warn(`Event dropped due to being internal Sentry Error.\nEvent: ${(0,n.jH)(t)}`),!0):function(t,e){return!(t.type||!e||!e.length)&&function(t){if(t.message)return[t.message];if(t.exception){const{values:e}=t.exception;try{const{type:t="",value:i=""}=e&&e[e.length-1]||{};return[`${i}`,`${t}: ${i}`]}catch(e){return("undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__)&&s.kg.error(`Cannot extract message for event ${(0,n.jH)(t)}`),[]}}return[]}(t).some((t=>(0,r.U0)(t,e)))}(t,e.ignoreErrors)?(("undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__)&&s.kg.warn(`Event dropped due to being matched by \`ignoreErrors\` option.\nEvent: ${(0,n.jH)(t)}`),!0):function(t,e){if("transaction"!==t.type||!e||!e.length)return!1;const i=t.transaction;return!!i&&(0,r.U0)(i,e)}(t,e.ignoreTransactions)?(("undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__)&&s.kg.warn(`Event dropped due to being matched by \`ignoreTransactions\` option.\nEvent: ${(0,n.jH)(t)}`),!0):function(t,e){if(!e||!e.length)return!1;const i=c(t);return!!i&&(0,r.U0)(i,e)}(t,e.denyUrls)?(("undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__)&&s.kg.warn(`Event dropped due to being matched by \`denyUrls\` option.\nEvent: ${(0,n.jH)(t)}.\nUrl: ${c(t)}`),!0):!function(t,e){if(!e||!e.length)return!0;const i=c(t);return!i||(0,r.U0)(i,e)}(t,e.allowUrls)&&(("undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__)&&s.kg.warn(`Event dropped due to not being matched by \`allowUrls\` option.\nEvent: ${(0,n.jH)(t)}.\nUrl: ${c(t)}`),!0)}(t,d)?null:t}}return t};i.id=this.name,t(i)}}function c(t){try{let e;try{e=t.exception.values[0].stacktrace.frames}catch(t){}return e?function(t=[]){for(let e=t.length-1;e>=0;e--){const i=t[e];if(i&&""!==i.filename&&"[native code]"!==i.filename)return i.filename||null}return null}(e):null}catch(e){return("undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__)&&s.kg.error(`Cannot extract url for event ${(0,n.jH)(t)}`),null}}l.__initStatic();var u=i(535);let d;class h{static __initStatic(){this.id="FunctionToString"}constructor(){this.name=h.id}setupOnce(){d=Function.prototype.toString;try{Function.prototype.toString=function(...t){const e=(0,u.HK)(this)||this;return d.apply(e,t)}}catch(t){}}}h.__initStatic();var f=i(2967),p=i(7966),g=i(5659),m=i(360),y=i(8823),v=i(9732),b=i(9680),_=i(6891),E=i(7597),T=i(8464),S=i(4773);class k{static __initStatic(){this.id="GlobalHandlers"}constructor(t){this.name=k.id,this._options={onerror:!0,onunhandledrejection:!0,...t},this._installFunc={onerror:w,onunhandledrejection:A}}setupOnce(){Error.stackTraceLimit=50;const t=this._options;for(const i in t){const n=this._installFunc[i];n&&t[i]&&(e=i,("undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__)&&s.kg.log(`Global Handler attached: ${e}`),n(),this._installFunc[i]=void 0)}var e}}function w(){(0,v.oq)("error",(t=>{const[e,i,s]=I();if(!e.getIntegration(k))return;const{msg:n,url:r,line:a,column:o,error:l}=t;if((0,_.Wz)()||l&&l.__sentry_own_request__)return;const c=void 0===l&&(0,E.HD)(n)?function(t,e,i,s){let n=(0,E.VW)(t)?t.message:t,r="Error";const a=n.match(/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i);a&&(r=a[1],n=a[2]);return R({exception:{values:[{type:r,value:n}]}},e,i,s)}(n,r,a,o):R((0,S.ME)(i,l||n,void 0,s,!1),r,a,o);c.level="error",L(e,l,c,"onerror")}))}function A(){(0,v.oq)("unhandledrejection",(t=>{const[e,i,s]=I();if(!e.getIntegration(k))return;let n=t;try{"reason"in t?n=t.reason:"detail"in t&&"reason"in t.detail&&(n=t.detail.reason)}catch(t){}if((0,_.Wz)()||n&&n.__sentry_own_request__)return!0;const r=(0,E.pt)(n)?{exception:{values:[{type:"UnhandledRejection",value:`Non-Error promise rejection captured with value: ${String(n)}`}]}}:(0,S.ME)(i,n,void 0,s,!0);r.level="error",L(e,n,r,"onunhandledrejection")}))}function R(t,e,i,s){const n=t.exception=t.exception||{},r=n.values=n.values||[],a=r[0]=r[0]||{},o=a.stacktrace=a.stacktrace||{},l=o.frames=o.frames||[],c=isNaN(parseInt(s,10))?void 0:s,u=isNaN(parseInt(i,10))?void 0:i,d=(0,E.HD)(e)&&e.length>0?e:(0,T.l4)();return 0===l.length&&l.push({colno:c,filename:d,function:"?",in_app:!0,lineno:u}),t}function L(t,e,i,s){(0,n.EG)(i,{handled:!1,type:s}),t.captureEvent(i,{originalException:e})}function I(){const t=(0,g.Gd)(),e=t.getClient(),i=e&&e.getOptions()||{stackParser:()=>[],attachStacktrace:!1};return[t,i.stackParser,i.attachStacktrace]}k.__initStatic();const C=["EventTarget","Window","Node","ApplicationCache","AudioTrackList","ChannelMergerNode","CryptoOperation","EventSource","FileReader","HTMLUnknownElement","IDBDatabase","IDBRequest","IDBTransaction","KeyOperation","MediaController","MessagePort","ModalWindow","Notification","SVGElementInstance","Screen","TextTrack","TextTrackCue","TextTrackList","WebSocket","WebSocketWorker","Worker","XMLHttpRequest","XMLHttpRequestEventTarget","XMLHttpRequestUpload"];class D{static __initStatic(){this.id="TryCatch"}constructor(t){this.name=D.id,this._options={XMLHttpRequest:!0,eventTarget:!0,requestAnimationFrame:!0,setInterval:!0,setTimeout:!0,...t}}setupOnce(){this._options.setTimeout&&(0,u.hl)(_.m9,"setTimeout",x),this._options.setInterval&&(0,u.hl)(_.m9,"setInterval",x),this._options.requestAnimationFrame&&(0,u.hl)(_.m9,"requestAnimationFrame",P),this._options.XMLHttpRequest&&"XMLHttpRequest"in _.m9&&(0,u.hl)(XMLHttpRequest.prototype,"send",O);const t=this._options.eventTarget;t&&(Array.isArray(t)?t:C).forEach(N)}}function x(t){return function(...e){const i=e[0];return e[0]=(0,_.re)(i,{mechanism:{data:{function:(0,m.$P)(t)},handled:!0,type:"instrument"}}),t.apply(this,e)}}function P(t){return function(e){return t.apply(this,[(0,_.re)(e,{mechanism:{data:{function:"requestAnimationFrame",handler:(0,m.$P)(t)},handled:!0,type:"instrument"}})])}}function O(t){return function(...e){const i=this;return["onload","onerror","onprogress","onreadystatechange"].forEach((t=>{t in i&&"function"==typeof i[t]&&(0,u.hl)(i,t,(function(e){const i={mechanism:{data:{function:t,handler:(0,m.$P)(e)},handled:!0,type:"instrument"}},s=(0,u.HK)(e);return s&&(i.mechanism.data.handler=(0,m.$P)(s)),(0,_.re)(e,i)}))})),t.apply(this,e)}}function N(t){const e=_.m9,i=e[t]&&e[t].prototype;i&&i.hasOwnProperty&&i.hasOwnProperty("addEventListener")&&((0,u.hl)(i,"addEventListener",(function(e){return function(i,s,n){try{"function"==typeof s.handleEvent&&(s.handleEvent=(0,_.re)(s.handleEvent,{mechanism:{data:{function:"handleEvent",handler:(0,m.$P)(s),target:t},handled:!0,type:"instrument"}}))}catch(t){}return e.apply(this,[i,(0,_.re)(s,{mechanism:{data:{function:"addEventListener",handler:(0,m.$P)(s),target:t},handled:!0,type:"instrument"}}),n])}})),(0,u.hl)(i,"removeEventListener",(function(t){return function(e,i,s){const n=i;try{const i=n&&n.__sentry_wrapped__;i&&t.call(this,e,i,s)}catch(t){}return t.call(this,e,n,s)}})))}D.__initStatic();var M=i(7729);function F(t,e,i=250,s,n,a,o){if(!(a.exception&&a.exception.values&&o&&(0,E.V9)(o.originalException,Error)))return;const l=a.exception.values.length>0?a.exception.values[a.exception.values.length-1]:void 0;var c,u;l&&(a.exception.values=(c=$(t,e,n,o.originalException,s,a.exception.values,l,0),u=i,c.map((t=>(t.value&&(t.value=(0,r.$G)(t.value,u)),t)))))}function $(t,e,i,s,n,r,a,o){if(r.length>=i+1)return r;let l=[...r];if((0,E.V9)(s[n],Error)){U(a,o);const r=t(e,s[n]),c=l.length;B(r,n,c,o),l=$(t,e,i,s[n],n,[r,...l],r,c)}return Array.isArray(s.errors)&&s.errors.forEach(((s,r)=>{if((0,E.V9)(s,Error)){U(a,o);const c=t(e,s),u=l.length;B(c,`errors[${r}]`,u,o),l=$(t,e,i,s,n,[c,...l],c,u)}})),l}function U(t,e){t.mechanism=t.mechanism||{type:"generic",handled:!0},t.mechanism={...t.mechanism,is_exception_group:!0,exception_id:e}}function B(t,e,i,s){t.mechanism=t.mechanism||{type:"generic",handled:!0},t.mechanism={...t.mechanism,type:"chained",source:e,exception_id:i,parent_id:s}}class j{static __initStatic(){this.id="LinkedErrors"}constructor(t={}){this.name=j.id,this._key=t.key||"cause",this._limit=t.limit||5}setupOnce(t,e){t(((t,i)=>{const s=e(),n=s.getClient(),r=s.getIntegration(j);if(!n||!r)return t;const a=n.getOptions();return F(S.GJ,a.stackParser,a.maxValueLength,r._key,r._limit,t,i),t}))}}j.__initStatic();var G=i(350);class V{static __initStatic(){this.id="HttpContext"}constructor(){this.name=V.id}setupOnce(){(0,G.c)((t=>{if((0,g.Gd)().getIntegration(V)){if(!_.m9.navigator&&!_.m9.location&&!_.m9.document)return t;const e=t.request&&t.request.url||_.m9.location&&_.m9.location.href,{referrer:i}=_.m9.document||{},{userAgent:s}=_.m9.navigator||{},n={...t.request&&t.request.headers,...i&&{Referer:i},...s&&{"User-Agent":s}},r={...t.request,...e&&{url:e},headers:n};return{...t,request:r}}return t}))}}V.__initStatic();class H{static __initStatic(){this.id="Dedupe"}constructor(){this.name=H.id}setupOnce(t,e){const i=t=>{if(t.type)return t;const i=e().getIntegration(H);if(i){try{if(function(t,e){return!!e&&(!!function(t,e){const i=t.message,s=e.message;return!(!i&&!s)&&(!(i&&!s||!i&&s)&&(i===s&&(!!Y(t,e)&&!!K(t,e))))}(t,e)||!!function(t,e){const i=q(e),s=q(t);return!(!i||!s)&&(i.type===s.type&&i.value===s.value&&(!!Y(t,e)&&!!K(t,e)))}(t,e))}(t,i._previousEvent))return("undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__)&&s.kg.warn("Event dropped due to being a duplicate of previously captured event."),null}catch(e){return i._previousEvent=t}return i._previousEvent=t}return t};i.id=this.name,t(i)}}function K(t,e){let i=z(t),s=z(e);if(!i&&!s)return!0;if(i&&!s||!i&&s)return!1;if(s.length!==i.length)return!1;for(let t=0;t{void 0!==t&&t!==e&&tt((0,g.Gd)())})))}()}function tt(t){t.startSession({ignoreDuration:!0}),t.captureSession()}},4469:(t,e,i)=>{"use strict";i.d(e,{Dt:()=>h});var s=i(360);const n="?";function r(t,e,i,s){const n={filename:t,function:e,in_app:!0};return void 0!==i&&(n.lineno=i),void 0!==s&&(n.colno=s),n}const a=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,o=/\((\S*)(?::(\d+))(?::(\d+))\)/,l=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,c=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,u=/^\s*at (?:((?:\[object object\])?.+) )?\(?((?:[-a-z]+):.*?):(\d+)(?::(\d+))?\)?\s*$/i,d=[[30,t=>{const e=a.exec(t);if(e){if(e[2]&&0===e[2].indexOf("eval")){const t=o.exec(e[2]);t&&(e[2]=t[1],e[3]=t[2],e[4]=t[3])}const[t,i]=f(e[1]||n,e[2]);return r(i,t,e[3]?+e[3]:void 0,e[4]?+e[4]:void 0)}}],[50,t=>{const e=l.exec(t);if(e){if(e[3]&&e[3].indexOf(" > eval")>-1){const t=c.exec(e[3]);t&&(e[1]=e[1]||"eval",e[3]=t[1],e[4]=t[2],e[5]="")}let t=e[3],i=e[1]||n;return[i,t]=f(i,t),r(t,i,e[4]?+e[4]:void 0,e[5]?+e[5]:void 0)}}],[40,t=>{const e=u.exec(t);return e?r(e[2],e[1]||n,+e[3],e[4]?+e[4]:void 0):void 0}]],h=(0,s.pE)(...d),f=(t,e)=>{const i=-1!==t.indexOf("safari-extension"),s=-1!==t.indexOf("safari-web-extension");return i||s?[-1!==t.indexOf("@")?t.split("@")[0]:n,i?`safari-extension:${e}`:`safari-web-extension:${e}`]:[t,e]}},8690:(t,e,i)=>{"use strict";if(i.d(e,{f:()=>a}),179==i.j)var s=i(5431);if(179==i.j)var n=i(6893);if(179==i.j)var r=i(7050);function a(t,e=(0,r.x)()){let i=0,a=0;return(0,s.q)(t,(function(s){const o=s.body.length;i+=o,a++;const l={body:s.body,method:"POST",referrerPolicy:"origin",headers:t.headers,keepalive:i<=6e4&&a<15,...t.fetchOptions};try{return e(t.url,l).then((t=>(i-=o,a--,{statusCode:t.status,headers:{"x-sentry-rate-limits":t.headers.get("X-Sentry-Rate-Limits"),"retry-after":t.headers.get("Retry-After")}})))}catch(t){return(0,r.c)(),i-=o,a--,(0,n.$2)(t)}}))}},7050:(t,e,i)=>{"use strict";if(i.d(e,{c:()=>l,x:()=>o}),179==i.j)var s=i(8823);if(179==i.j)var n=i(2343);if(179==i.j)var r=i(6891);let a=179==i.j?void 0:null;function o(){if(a)return a;if((0,s.Du)(r.m9.fetch))return a=r.m9.fetch.bind(r.m9);const t=r.m9.document;let e=r.m9.fetch;if(t&&"function"==typeof t.createElement)try{const i=t.createElement("iframe");i.hidden=!0,t.head.appendChild(i);const s=i.contentWindow;s&&s.fetch&&(e=s.fetch),t.head.removeChild(i)}catch(t){("undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__)&&n.kg.warn("Could not create sandbox iframe for pure fetch check, bailing to window.fetch: ",t)}return a=e.bind(r.m9)}function l(){a=void 0}},8131:(t,e,i)=>{"use strict";if(i.d(e,{K:()=>a}),179==i.j)var s=i(5431);if(179==i.j)var n=i(6893);const r=4;function a(t){return(0,s.q)(t,(function(e){return new n.cW(((i,s)=>{const n=new XMLHttpRequest;n.onerror=s,n.onreadystatechange=()=>{n.readyState===r&&i({statusCode:n.status,headers:{"x-sentry-rate-limits":n.getResponseHeader("X-Sentry-Rate-Limits"),"retry-after":n.getResponseHeader("Retry-After")}})},n.open("POST",t.url);for(const e in t.headers)Object.prototype.hasOwnProperty.call(t.headers,e)&&n.setRequestHeader(e,t.headers[e]);n.send(e.body)}))}))}},911:(t,e,i)=>{"use strict";if(i.d(e,{r:()=>r}),179==i.j)var s=i(292);if(179==i.j)var n=i(8725);function r(t,{metadata:e,tunnel:i,dsn:r}){const a={event_id:t.event_id,sent_at:(new Date).toISOString(),...e&&e.sdk&&{sdk:{name:e.sdk.name,version:e.sdk.version}},...!!i&&!!r&&{dsn:(0,s.RA)(r)}},o=function(t){return[{type:"user_report"},t]}(t);return(0,n.Jd)(a,[o])}},1984:(t,e,i)=>{"use strict";if(i.d(e,{U:()=>r}),179==i.j)var s=i(535);const n="7";function r(t,e={}){const i="string"==typeof e?e:e.tunnel,r="string"!=typeof e&&e._metadata?e._metadata.sdk:void 0;return i||`${function(t){return`${function(t){const e=t.protocol?`${t.protocol}:`:"",i=t.port?`:${t.port}`:"";return`${e}//${t.host}${i}${t.path?`/${t.path}`:""}/api/`}(t)}${t.projectId}/envelope/`}(t)}?${function(t,e){return(0,s._j)({sentry_key:t.publicKey,sentry_version:n,...e&&{sentry_client:`${e.name}/${e.version}`}})}(t,r)}`}},4219:(t,e,i)=>{"use strict";if(i.d(e,{W:()=>y}),179==i.j)var s=i(292);if(179==i.j)var n=i(2343);if(179==i.j)var r=i(2844);if(179==i.j)var a=i(7597);if(179==i.j)var o=i(6893);if(179==i.j)var l=i(8725);if(179==i.j)var c=i(409);if(179==i.j)var u=i(1984);if(179==i.j)var d=i(8656);if(179==i.j)var h=i(2967);if(179==i.j)var f=i(9015);if(179==i.j)var p=i(454);if(179==i.j)var g=i(8942);const m="Not capturing exception because it's already been captured.";class y{constructor(t){if(this._options=t,this._integrations={},this._integrationsInitialized=!1,this._numProcessing=0,this._outcomes={},this._hooks={},t.dsn?this._dsn=(0,s.vK)(t.dsn):("undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__)&&n.kg.warn("No DSN provided, client will not do anything."),this._dsn){const e=(0,u.U)(this._dsn,t);this._transport=t.transport({recordDroppedEvent:this.recordDroppedEvent.bind(this),...t.transportOptions,url:e})}}captureException(t,e,i){if((0,r.YO)(t))return void(("undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__)&&n.kg.log(m));let s=e&&e.event_id;return this._process(this.eventFromException(t,e).then((t=>this._captureEvent(t,e,i))).then((t=>{s=t}))),s}captureMessage(t,e,i,s){let n=i&&i.event_id;const r=(0,a.pt)(t)?this.eventFromMessage(String(t),e,i):this.eventFromException(t,i);return this._process(r.then((t=>this._captureEvent(t,i,s))).then((t=>{n=t}))),n}captureEvent(t,e,i){if(e&&e.originalException&&(0,r.YO)(e.originalException))return void(("undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__)&&n.kg.log(m));let s=e&&e.event_id;return this._process(this._captureEvent(t,e,i).then((t=>{s=t}))),s}captureSession(t){this._isEnabled()?"string"!=typeof t.release?("undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__)&&n.kg.warn("Discarded session because of missing or non-string release"):(this.sendSession(t),(0,f.CT)(t,{init:!1})):("undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__)&&n.kg.warn("SDK not enabled, will not capture session.")}getDsn(){return this._dsn}getOptions(){return this._options}getSdkMetadata(){return this._options._metadata}getTransport(){return this._transport}flush(t){const e=this._transport;return e?this._isClientDoneProcessing(t).then((i=>e.flush(t).then((t=>i&&t)))):(0,o.WD)(!0)}close(t){return this.flush(t).then((t=>(this.getOptions().enabled=!1,t)))}setupIntegrations(){this._isEnabled()&&!this._integrationsInitialized&&(this._integrations=(0,h.q4)(this._options.integrations),this._integrationsInitialized=!0)}getIntegrationById(t){return this._integrations[t]}getIntegration(t){try{return this._integrations[t.id]||null}catch(e){return("undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__)&&n.kg.warn(`Cannot retrieve integration ${t.id} from the current Client`),null}}addIntegration(t){(0,h.m7)(t,this._integrations)}sendEvent(t,e={}){if(this._dsn){let i=(0,d.M)(t,this._dsn,this._options._metadata,this._options.tunnel);for(const t of e.attachments||[])i=(0,l.BO)(i,(0,l.zQ)(t,this._options.transportOptions&&this._options.transportOptions.textEncoder));const s=this._sendEnvelope(i);s&&s.then((e=>this.emit("afterSendEvent",t,e)),null)}}sendSession(t){if(this._dsn){const e=(0,d.Q)(t,this._dsn,this._options._metadata,this._options.tunnel);this._sendEnvelope(e)}}recordDroppedEvent(t,e,i){if(this._options.sendClientReports){const i=`${t}:${e}`;("undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__)&&n.kg.log(`Adding outcome: "${i}"`),this._outcomes[i]=this._outcomes[i]+1||1}}on(t,e){this._hooks[t]||(this._hooks[t]=[]),this._hooks[t].push(e)}emit(t,...e){this._hooks[t]&&this._hooks[t].forEach((t=>t(...e)))}_updateSessionFromEvent(t,e){let i=!1,s=!1;const n=e.exception&&e.exception.values;if(n){s=!0;for(const t of n){const e=t.mechanism;if(e&&!1===e.handled){i=!0;break}}}const r="ok"===t.status;(r&&0===t.errors||r&&i)&&((0,f.CT)(t,{...i&&{status:"crashed"},errors:t.errors||Number(s||i)}),this.captureSession(t))}_isClientDoneProcessing(t){return new o.cW((e=>{let i=0;const s=setInterval((()=>{0==this._numProcessing?(clearInterval(s),e(!0)):(i+=1,t&&i>=t&&(clearInterval(s),e(!1)))}),1)}))}_isEnabled(){return!1!==this.getOptions().enabled&&void 0!==this._dsn}_prepareEvent(t,e,i){const s=this.getOptions(),n=Object.keys(this._integrations);return!e.integrations&&n.length>0&&(e.integrations=n),(0,g.R)(s,t,e,i).then((t=>{if(null===t)return t;const{propagationContext:e}=t.sdkProcessingMetadata||{};if((!t.contexts||!t.contexts.trace)&&e){const{traceId:s,spanId:n,parentSpanId:r,dsc:a}=e;t.contexts={trace:{trace_id:s,span_id:n,parent_span_id:r},...t.contexts};const o=a||(0,p._)(s,this,i);t.sdkProcessingMetadata={dynamicSamplingContext:o,...t.sdkProcessingMetadata}}return t}))}_captureEvent(t,e={},i){return this._processEvent(t,e,i).then((t=>t.event_id),(t=>{if("undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__){const e=t;"log"===e.logLevel?n.kg.log(e.message):n.kg.warn(e)}}))}_processEvent(t,e,i){const s=this.getOptions(),{sampleRate:n}=s;if(!this._isEnabled())return(0,o.$2)(new c.b("SDK not enabled, will not capture event.","log"));const r=b(t),l=v(t),u=t.type||"error",d=`before send for type \`${u}\``;if(l&&"number"==typeof n&&Math.random()>n)return this.recordDroppedEvent("sample_rate","error",t),(0,o.$2)(new c.b(`Discarding event because it's not included in the random sample (sampling rate = ${n})`,"log"));const h="replay_event"===u?"replay":u;return this._prepareEvent(t,e,i).then((i=>{if(null===i)throw this.recordDroppedEvent("event_processor",h,t),new c.b("An event processor returned `null`, will not send event.","log");if(e.data&&!0===e.data.__sentry__)return i;const n=function(t,e,i){const{beforeSend:s,beforeSendTransaction:n}=t;return v(e)&&s?s(e,i):b(e)&&n?n(e,i):e}(s,i,e);return function(t,e){const i=`${e} must return \`null\` or a valid event.`;if((0,a.J8)(t))return t.then((t=>{if(!(0,a.PO)(t)&&null!==t)throw new c.b(i);return t}),(t=>{throw new c.b(`${e} rejected with ${t}`)}));if(!(0,a.PO)(t)&&null!==t)throw new c.b(i);return t}(n,d)})).then((s=>{if(null===s)throw this.recordDroppedEvent("before_send",h,t),new c.b(`${d} returned \`null\`, will not send event.`,"log");const n=i&&i.getSession();!r&&n&&this._updateSessionFromEvent(n,s);const a=s.transaction_info;if(r&&a&&s.transaction!==t.transaction){const t="custom";s.transaction_info={...a,source:t}}return this.sendEvent(s,e),s})).then(null,(t=>{if(t instanceof c.b)throw t;throw this.captureException(t,{data:{__sentry__:!0},originalException:t}),new c.b(`Event processing pipeline threw an error, original event will not be sent. Details have been sent as a new event.\nReason: ${t}`)}))}_process(t){this._numProcessing++,t.then((t=>(this._numProcessing--,t)),(t=>(this._numProcessing--,t)))}_sendEnvelope(t){if(this._transport&&this._dsn)return this.emit("beforeEnvelope",t),this._transport.send(t).then(null,(t=>{("undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__)&&n.kg.error("Error while sending event:",t)}));("undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__)&&n.kg.error("Transport disabled")}_clearOutcomes(){const t=this._outcomes;return this._outcomes={},Object.keys(t).map((e=>{const[i,s]=e.split(":");return{reason:i,category:s,quantity:t[e]}}))}}function v(t){return void 0===t.type}function b(t){return"transaction"===t.type}},1131:(t,e,i)=>{"use strict";i.d(e,{J:()=>s});const s="production"},8656:(t,e,i)=>{"use strict";if(i.d(e,{M:()=>a,Q:()=>r}),179==i.j)var s=i(8725);if(179==i.j)var n=i(292);function r(t,e,i,r){const a=(0,s.HY)(i),o={sent_at:(new Date).toISOString(),...a&&{sdk:a},...!!r&&{dsn:(0,n.RA)(e)}},l="aggregates"in t?[{type:"sessions"},t]:[{type:"session"},t.toJSON()];return(0,s.Jd)(o,[l])}function a(t,e,i,n){const r=(0,s.HY)(i),a=t.type&&"replay_event"!==t.type?t.type:"event";!function(t,e){e&&(t.sdk=t.sdk||{},t.sdk.name=t.sdk.name||e.name,t.sdk.version=t.sdk.version||e.version,t.sdk.integrations=[...t.sdk.integrations||[],...e.integrations||[]],t.sdk.packages=[...t.sdk.packages||[],...e.packages||[]])}(t,i&&i.sdk);const o=(0,s.Cd)(t,r,n,e);delete t.sdkProcessingMetadata;const l=[{type:a},t];return(0,s.Jd)(o,[l])}},4487:(t,e,i)=>{"use strict";if(i.d(e,{$e:()=>a,Tb:()=>n,n_:()=>r}),179==i.j)var s=i(5659);function n(t,e){return(0,s.Gd)().captureException(t,{captureContext:e})}function r(t){(0,s.Gd)().addBreadcrumb(t)}function a(t){(0,s.Gd)().withScope(t)}},5659:(t,e,i)=>{"use strict";if(i.d(e,{Gd:()=>g,cu:()=>f}),179==i.j)var s=i(2844);if(179==i.j)var n=i(1170);if(179==i.j)var r=i(2343);if(179==i.j)var a=i(1235);if(179==i.j)var o=i(1131);if(179==i.j)var l=i(350);if(179==i.j)var c=i(9015);const u=4,d=100;class h{constructor(t,e=new l.s,i=u){this._version=i,this._stack=[{scope:e}],t&&this.bindClient(t)}isOlderThan(t){return this._version{s.captureException(t,{originalException:t,syntheticException:n,...e,event_id:i},r)})),i}captureMessage(t,e,i){const n=this._lastEventId=i&&i.event_id?i.event_id:(0,s.DM)(),r=new Error(t);return this._withClient(((s,a)=>{s.captureMessage(t,e,{originalException:t,syntheticException:r,...i,event_id:n},a)})),n}captureEvent(t,e){const i=e&&e.event_id?e.event_id:(0,s.DM)();return t.type||(this._lastEventId=i),this._withClient(((s,n)=>{s.captureEvent(t,{...e,event_id:i},n)})),i}lastEventId(){return this._lastEventId}addBreadcrumb(t,e){const{scope:i,client:s}=this.getStackTop();if(!s)return;const{beforeBreadcrumb:a=null,maxBreadcrumbs:o=d}=s.getOptions&&s.getOptions()||{};if(o<=0)return;const l={timestamp:(0,n.yW)(),...t},c=a?(0,r.Cf)((()=>a(l,e))):l;null!==c&&(s.emit&&s.emit("beforeAddBreadcrumb",c,e),i.addBreadcrumb(c,o))}setUser(t){this.getScope().setUser(t)}setTags(t){this.getScope().setTags(t)}setExtras(t){this.getScope().setExtras(t)}setTag(t,e){this.getScope().setTag(t,e)}setExtra(t,e){this.getScope().setExtra(t,e)}setContext(t,e){this.getScope().setContext(t,e)}configureScope(t){const{scope:e,client:i}=this.getStackTop();i&&t(e)}run(t){const e=p(this);try{t(this)}finally{p(e)}}getIntegration(t){const e=this.getClient();if(!e)return null;try{return e.getIntegration(t)}catch(e){return("undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__)&&r.kg.warn(`Cannot retrieve integration ${t.id} from the current Hub`),null}}startTransaction(t,e){const i=this._callExtensionMethod("startTransaction",t,e);return"undefined"!=typeof __SENTRY_DEBUG__&&!__SENTRY_DEBUG__||i||console.warn("Tracing extension 'startTransaction' has not been added. Call 'addTracingExtensions' before calling 'init':\nSentry.addTracingExtensions();\nSentry.init({...});\n"),i}traceHeaders(){return this._callExtensionMethod("traceHeaders")}captureSession(t=!1){if(t)return this.endSession();this._sendSessionUpdate()}endSession(){const t=this.getStackTop().scope,e=t.getSession();e&&(0,c.RJ)(e),this._sendSessionUpdate(),t.setSession()}startSession(t){const{scope:e,client:i}=this.getStackTop(),{release:s,environment:n=o.J}=i&&i.getOptions()||{},{userAgent:r}=a.n2.navigator||{},l=(0,c.Hv)({release:s,environment:n,user:e.getUser(),...r&&{userAgent:r},...t}),u=e.getSession&&e.getSession();return u&&"ok"===u.status&&(0,c.CT)(u,{status:"exited"}),this.endSession(),e.setSession(l),l}shouldSendDefaultPii(){const t=this.getClient(),e=t&&t.getOptions();return Boolean(e&&e.sendDefaultPii)}_sendSessionUpdate(){const{scope:t,client:e}=this.getStackTop(),i=t.getSession();i&&e&&e.captureSession&&e.captureSession(i)}_withClient(t){const{scope:e,client:i}=this.getStackTop();i&&t(i,e)}_callExtensionMethod(t,...e){const i=f().__SENTRY__;if(i&&i.extensions&&"function"==typeof i.extensions[t])return i.extensions[t].apply(this,e);("undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__)&&r.kg.warn(`Extension method ${t} couldn't be found, doing nothing.`)}}function f(){return a.n2.__SENTRY__=a.n2.__SENTRY__||{extensions:{},hub:void 0},a.n2}function p(t){const e=f(),i=m(e);return y(e,t),i}function g(){const t=f();if(t.__SENTRY__&&t.__SENTRY__.acs){const e=t.__SENTRY__.acs.getCurrentHub();if(e)return e}return function(t=f()){return e=t,!!(e&&e.__SENTRY__&&e.__SENTRY__.hub)&&!m(t).isOlderThan(u)||y(t,new h),m(t);var e}(t)}function m(t){return(0,a.YO)("hub",(()=>new h),t)}function y(t,e){return!!t&&((t.__SENTRY__=t.__SENTRY__||{}).hub=e,!0)}},2967:(t,e,i)=>{"use strict";if(i.d(e,{m7:()=>u,m8:()=>l,q4:()=>c}),179==i.j)var s=i(2844);if(179==i.j)var n=i(2343);if(179==i.j)var r=i(5659);if(179==i.j)var a=i(350);const o=179==i.j?[]:null;function l(t){const e=t.defaultIntegrations||[],i=t.integrations;let n;e.forEach((t=>{t.isDefaultInstance=!0})),n=Array.isArray(i)?[...e,...i]:"function"==typeof i?(0,s.lE)(i(e)):e;const r=function(t){const e={};return t.forEach((t=>{const{name:i}=t,s=e[i];s&&!s.isDefaultInstance&&t.isDefaultInstance||(e[i]=t)})),Object.keys(e).map((t=>e[t]))}(n),a=function(t,e){for(let e=0;e{t&&u(t,e)})),e}function u(t,e){e[t.name]=t,-1===o.indexOf(t.name)&&(t.setupOnce(a.c,r.Gd),o.push(t.name),("undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__)&&n.kg.log(`Integration installed: ${t.name}`))}},350:(t,e,i)=>{"use strict";if(i.d(e,{c:()=>h,s:()=>u}),179==i.j)var s=i(7597);if(179==i.j)var n=i(1170);if(179==i.j)var r=i(6893);if(179==i.j)var a=i(2343);if(179==i.j)var o=i(2844);if(179==i.j)var l=i(1235);if(179==i.j)var c=i(9015);class u{constructor(){this._notifyingListeners=!1,this._scopeListeners=[],this._eventProcessors=[],this._breadcrumbs=[],this._attachments=[],this._user={},this._tags={},this._extra={},this._contexts={},this._sdkProcessingMetadata={},this._propagationContext=f()}static clone(t){const e=new u;return t&&(e._breadcrumbs=[...t._breadcrumbs],e._tags={...t._tags},e._extra={...t._extra},e._contexts={...t._contexts},e._user=t._user,e._level=t._level,e._span=t._span,e._session=t._session,e._transactionName=t._transactionName,e._fingerprint=t._fingerprint,e._eventProcessors=[...t._eventProcessors],e._requestSession=t._requestSession,e._attachments=[...t._attachments],e._sdkProcessingMetadata={...t._sdkProcessingMetadata},e._propagationContext={...t._propagationContext}),e}addScopeListener(t){this._scopeListeners.push(t)}addEventProcessor(t){return this._eventProcessors.push(t),this}setUser(t){return this._user=t||{},this._session&&(0,c.CT)(this._session,{user:t}),this._notifyScopeListeners(),this}getUser(){return this._user}getRequestSession(){return this._requestSession}setRequestSession(t){return this._requestSession=t,this}setTags(t){return this._tags={...this._tags,...t},this._notifyScopeListeners(),this}setTag(t,e){return this._tags={...this._tags,[t]:e},this._notifyScopeListeners(),this}setExtras(t){return this._extra={...this._extra,...t},this._notifyScopeListeners(),this}setExtra(t,e){return this._extra={...this._extra,[t]:e},this._notifyScopeListeners(),this}setFingerprint(t){return this._fingerprint=t,this._notifyScopeListeners(),this}setLevel(t){return this._level=t,this._notifyScopeListeners(),this}setTransactionName(t){return this._transactionName=t,this._notifyScopeListeners(),this}setContext(t,e){return null===e?delete this._contexts[t]:this._contexts[t]=e,this._notifyScopeListeners(),this}setSpan(t){return this._span=t,this._notifyScopeListeners(),this}getSpan(){return this._span}getTransaction(){const t=this.getSpan();return t&&t.transaction}setSession(t){return t?this._session=t:delete this._session,this._notifyScopeListeners(),this}getSession(){return this._session}update(t){if(!t)return this;if("function"==typeof t){const e=t(this);return e instanceof u?e:this}return t instanceof u?(this._tags={...this._tags,...t._tags},this._extra={...this._extra,...t._extra},this._contexts={...this._contexts,...t._contexts},t._user&&Object.keys(t._user).length&&(this._user=t._user),t._level&&(this._level=t._level),t._fingerprint&&(this._fingerprint=t._fingerprint),t._requestSession&&(this._requestSession=t._requestSession),t._propagationContext&&(this._propagationContext=t._propagationContext)):(0,s.PO)(t)&&(this._tags={...this._tags,...t.tags},this._extra={...this._extra,...t.extra},this._contexts={...this._contexts,...t.contexts},t.user&&(this._user=t.user),t.level&&(this._level=t.level),t.fingerprint&&(this._fingerprint=t.fingerprint),t.requestSession&&(this._requestSession=t.requestSession),t.propagationContext&&(this._propagationContext=t.propagationContext)),this}clear(){return this._breadcrumbs=[],this._tags={},this._extra={},this._user={},this._contexts={},this._level=void 0,this._transactionName=void 0,this._fingerprint=void 0,this._requestSession=void 0,this._span=void 0,this._session=void 0,this._notifyScopeListeners(),this._attachments=[],this._propagationContext=f(),this}addBreadcrumb(t,e){const i="number"==typeof e?e:100;if(i<=0)return this;const s={timestamp:(0,n.yW)(),...t};return this._breadcrumbs=[...this._breadcrumbs,s].slice(-i),this._notifyScopeListeners(),this}getLastBreadcrumb(){return this._breadcrumbs[this._breadcrumbs.length-1]}clearBreadcrumbs(){return this._breadcrumbs=[],this._notifyScopeListeners(),this}addAttachment(t){return this._attachments.push(t),this}getAttachments(){return this._attachments}clearAttachments(){return this._attachments=[],this}applyToEvent(t,e={}){if(this._extra&&Object.keys(this._extra).length&&(t.extra={...this._extra,...t.extra}),this._tags&&Object.keys(this._tags).length&&(t.tags={...this._tags,...t.tags}),this._user&&Object.keys(this._user).length&&(t.user={...this._user,...t.user}),this._contexts&&Object.keys(this._contexts).length&&(t.contexts={...this._contexts,...t.contexts}),this._level&&(t.level=this._level),this._transactionName&&(t.transaction=this._transactionName),this._span){t.contexts={trace:this._span.getTraceContext(),...t.contexts};const e=this._span.transaction;if(e){t.sdkProcessingMetadata={dynamicSamplingContext:e.getDynamicSamplingContext(),...t.sdkProcessingMetadata};const i=e.name;i&&(t.tags={transaction:i,...t.tags})}}return this._applyFingerprint(t),t.breadcrumbs=[...t.breadcrumbs||[],...this._breadcrumbs],t.breadcrumbs=t.breadcrumbs.length>0?t.breadcrumbs:void 0,t.sdkProcessingMetadata={...t.sdkProcessingMetadata,...this._sdkProcessingMetadata,propagationContext:this._propagationContext},this._notifyEventProcessors([...d(),...this._eventProcessors],t,e)}setSDKProcessingMetadata(t){return this._sdkProcessingMetadata={...this._sdkProcessingMetadata,...t},this}setPropagationContext(t){return this._propagationContext=t,this}getPropagationContext(){return this._propagationContext}_notifyEventProcessors(t,e,i,n=0){return new r.cW(((r,o)=>{const l=t[n];if(null===e||"function"!=typeof l)r(e);else{const c=l({...e},i);("undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__)&&l.id&&null===c&&a.kg.log(`Event processor "${l.id}" dropped event`),(0,s.J8)(c)?c.then((e=>this._notifyEventProcessors(t,e,i,n+1).then(r))).then(null,o):this._notifyEventProcessors(t,c,i,n+1).then(r).then(null,o)}}))}_notifyScopeListeners(){this._notifyingListeners||(this._notifyingListeners=!0,this._scopeListeners.forEach((t=>{t(this)})),this._notifyingListeners=!1)}_applyFingerprint(t){t.fingerprint=t.fingerprint?(0,o.lE)(t.fingerprint):[],this._fingerprint&&(t.fingerprint=t.fingerprint.concat(this._fingerprint)),t.fingerprint&&!t.fingerprint.length&&delete t.fingerprint}}function d(){return(0,l.YO)("globalEventProcessors",(()=>[]))}function h(t){d().push(t)}function f(){return{traceId:(0,o.DM)(),spanId:(0,o.DM)().substring(16),sampled:!1}}},7966:(t,e,i)=>{"use strict";if(i.d(e,{M:()=>r}),179==i.j)var s=i(2343);if(179==i.j)var n=i(5659);function r(t,e){!0===e.debug&&("undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__?s.kg.enable():console.warn("[Sentry] Cannot initialize SDK with `debug` option using a non-debug bundle."));const i=(0,n.Gd)();i.getScope().update(e.initialScope);const r=new t(e);i.bindClient(r)}},9015:(t,e,i)=>{"use strict";if(i.d(e,{CT:()=>o,Hv:()=>a,RJ:()=>l}),179==i.j)var s=i(1170);if(179==i.j)var n=i(2844);if(179==i.j)var r=i(535);function a(t){const e=(0,s.ph)(),i={sid:(0,n.DM)(),init:!0,timestamp:e,started:e,duration:0,status:"ok",errors:0,ignoreDuration:!1,toJSON:()=>function(t){return(0,r.Jr)({sid:`${t.sid}`,init:t.init,started:new Date(1e3*t.started).toISOString(),timestamp:new Date(1e3*t.timestamp).toISOString(),status:t.status,errors:t.errors,did:"number"==typeof t.did||"string"==typeof t.did?`${t.did}`:void 0,duration:t.duration,attrs:{release:t.release,environment:t.environment,ip_address:t.ipAddress,user_agent:t.userAgent}})}(i)};return t&&o(i,t),i}function o(t,e={}){if(e.user&&(!t.ipAddress&&e.user.ip_address&&(t.ipAddress=e.user.ip_address),t.did||e.did||(t.did=e.user.id||e.user.email||e.user.username)),t.timestamp=e.timestamp||(0,s.ph)(),e.ignoreDuration&&(t.ignoreDuration=e.ignoreDuration),e.sid&&(t.sid=32===e.sid.length?e.sid:(0,n.DM)()),void 0!==e.init&&(t.init=e.init),!t.did&&e.did&&(t.did=`${e.did}`),"number"==typeof e.started&&(t.started=e.started),t.ignoreDuration)t.duration=void 0;else if("number"==typeof e.duration)t.duration=e.duration;else{const e=t.timestamp-t.started;t.duration=e>=0?e:0}e.release&&(t.release=e.release),e.environment&&(t.environment=e.environment),!t.ipAddress&&e.ipAddress&&(t.ipAddress=e.ipAddress),!t.userAgent&&e.userAgent&&(t.userAgent=e.userAgent),"number"==typeof e.errors&&(t.errors=e.errors),e.status&&(t.status=e.status)}function l(t,e){let i={};e?i={status:e}:"ok"===t.status&&(i={status:"exited"}),o(t,i)}},454:(t,e,i)=>{"use strict";if(i.d(e,{_:()=>r}),179==i.j)var s=i(535);if(179==i.j)var n=i(1131);function r(t,e,i){const r=e.getOptions(),{publicKey:a}=e.getDsn()||{},{segment:o}=i&&i.getUser()||{},l=(0,s.Jr)({environment:r.environment||n.J,release:r.release,user_segment:o,public_key:a,trace_id:t});return e.emit&&e.emit("createDsc",l),l}},6188:(t,e,i)=>{"use strict";if(i.d(e,{e:()=>o}),179==i.j)var s=i(9732);var n=i(2343),r=i(9791);let a=!1;function o(){a||(a=!0,(0,s.oq)("error",l),(0,s.oq)("unhandledrejection",l))}function l(){const t=(0,r.x1)();if(t){const e="internal_error";("undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__)&&n.kg.log(`[Tracing] Transaction: ${e} -> Global error occured`),t.setStatus(e)}}l.tag="sentry_tracingErrorCallback"},3332:(t,e,i)=>{"use strict";if(i.d(e,{T:()=>p,l:()=>f}),179==i.j)var s=i(2343);if(179==i.j)var n=i(7597);if(179==i.j)var r=i(5659);if(179==i.j)var a=i(7522);if(179==i.j)var o=i(6188);if(179==i.j)var l=i(5544);if(179==i.j)var c=i(8069);function u(){const t=this.getScope().getSpan();return t?{"sentry-trace":t.toTraceparent()}:{}}function d(t,e,i){if(!(0,a.z)(e))return t.sampled=!1,t;if(void 0!==t.sampled)return t.setMetadata({sampleRate:Number(t.sampled)}),t;let r;return"function"==typeof e.tracesSampler?(r=e.tracesSampler(i),t.setMetadata({sampleRate:Number(r)})):void 0!==i.parentSampled?r=i.parentSampled:void 0!==e.tracesSampleRate?(r=e.tracesSampleRate,t.setMetadata({sampleRate:Number(r)})):(r=1,t.setMetadata({sampleRate:r})),o=r,((0,n.i2)(o)||"number"!=typeof o&&"boolean"!=typeof o?(("undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__)&&s.kg.warn(`[Tracing] Given sample rate is invalid. Sample rate must be a boolean or a number between 0 and 1. Got ${JSON.stringify(o)} of type ${JSON.stringify(typeof o)}.`),0):!(o<0||o>1)||(("undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__)&&s.kg.warn(`[Tracing] Given sample rate is invalid. Sample rate must be between 0 and 1. Got ${o}.`),0))?r?(t.sampled=Math.random(){"use strict";if(i.d(e,{AT:()=>o,io:()=>u}),179==i.j)var s=i(1170);if(179==i.j)var n=i(2343);if(179==i.j)var r=i(8903);if(179==i.j)var a=i(8069);const o={idleTimeout:1e3,finalTimeout:3e4,heartbeatInterval:5e3},l=179==i.j?["heartbeatFailed","idleTimeout","documentHidden","finalTimeout","externalFinish","cancelled"]:null;class c extends(179==i.j?r.gB:null){constructor(t,e,i,s){super(s),this._pushActivity=t,this._popActivity=e,this.transactionSpanId=i}add(t){t.spanId!==this.transactionSpanId&&(t.finish=e=>{t.endTimestamp="number"==typeof e?e:(0,s.ph)(),this._popActivity(t.spanId)},void 0===t.endTimestamp&&this._pushActivity(t.spanId)),super.add(t)}}class u extends(179==i.j?a.Y:null){constructor(t,e,i=o.idleTimeout,s=o.finalTimeout,r=o.heartbeatInterval,a=!1){super(t,e),this._idleHub=e,this._idleTimeout=i,this._finalTimeout=s,this._heartbeatInterval=r,this._onScope=a,this.activities={},this._heartbeatCounter=0,this._finished=!1,this._idleTimeoutCanceledPermanently=!1,this._beforeFinishCallbacks=[],this._finishReason=l[4],a&&(("undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__)&&n.kg.log(`Setting idle transaction on scope. Span ID: ${this.spanId}`),e.configureScope((t=>t.setSpan(this)))),this._restartIdleTimeout(),setTimeout((()=>{this._finished||(this.setStatus("deadline_exceeded"),this._finishReason=l[3],this.finish())}),this._finalTimeout)}finish(t=(0,s.ph)()){if(this._finished=!0,this.activities={},"ui.action.click"===this.op&&this.setTag("finishReason",this._finishReason),this.spanRecorder){("undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__)&&n.kg.log("[Tracing] finishing IdleTransaction",new Date(1e3*t).toISOString(),this.op);for(const e of this._beforeFinishCallbacks)e(this,t);this.spanRecorder.spans=this.spanRecorder.spans.filter((e=>{if(e.spanId===this.spanId)return!0;e.endTimestamp||(e.endTimestamp=t,e.setStatus("cancelled"),("undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__)&&n.kg.log("[Tracing] cancelling span since transaction ended early",JSON.stringify(e,void 0,2)));const i=e.startTimestamp{this._finished||this._pushActivity(t)},i=t=>{this._finished||this._popActivity(t)};this.spanRecorder=new c(e,i,this.spanId,t),("undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__)&&n.kg.log("Starting heartbeat"),this._pingHeartbeat()}this.spanRecorder.add(this)}cancelIdleTimeout(t,{restartOnChildSpanChange:e}={restartOnChildSpanChange:!0}){this._idleTimeoutCanceledPermanently=!1===e,this._idleTimeoutID&&(clearTimeout(this._idleTimeoutID),this._idleTimeoutID=void 0,0===Object.keys(this.activities).length&&this._idleTimeoutCanceledPermanently&&(this._finishReason=l[5],this.finish(t)))}setFinishReason(t){this._finishReason=t}_restartIdleTimeout(t){this.cancelIdleTimeout(),this._idleTimeoutID=setTimeout((()=>{this._finished||0!==Object.keys(this.activities).length||(this._finishReason=l[1],this.finish(t))}),this._idleTimeout)}_pushActivity(t){this.cancelIdleTimeout(void 0,{restartOnChildSpanChange:!this._idleTimeoutCanceledPermanently}),("undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__)&&n.kg.log(`[Tracing] pushActivity: ${t}`),this.activities[t]=!0,("undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__)&&n.kg.log("[Tracing] new activities count",Object.keys(this.activities).length)}_popActivity(t){if(this.activities[t]&&(("undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__)&&n.kg.log(`[Tracing] popActivity ${t}`),delete this.activities[t],("undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__)&&n.kg.log("[Tracing] new activities count",Object.keys(this.activities).length)),0===Object.keys(this.activities).length){const t=(0,s.ph)();this._idleTimeoutCanceledPermanently?(this._finishReason=l[5],this.finish(t)):this._restartIdleTimeout(t+this._idleTimeout/1e3)}}_beat(){if(this._finished)return;const t=Object.keys(this.activities).join("");t===this._prevHeartbeatString?this._heartbeatCounter++:this._heartbeatCounter=1,this._prevHeartbeatString=t,this._heartbeatCounter>=3?(("undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__)&&n.kg.log("[Tracing] Transaction finished because of no change for 3 heart beats"),this.setStatus("deadline_exceeded"),this._finishReason=l[0],this.finish()):this._pingHeartbeat()}_pingHeartbeat(){("undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__)&&n.kg.log(`pinging Heartbeat -> current counter: ${this._heartbeatCounter}`),setTimeout((()=>{this._beat()}),this._heartbeatInterval)}}},8903:(t,e,i)=>{"use strict";if(i.d(e,{Dr:()=>c,gB:()=>l}),179==i.j)var s=i(2844);if(179==i.j)var n=i(1170);if(179==i.j)var r=i(2343);if(179==i.j)var a=i(7638);if(179==i.j)var o=i(535);class l{constructor(t=1e3){this._maxlen=t,this.spans=[]}add(t){this.spans.length>this._maxlen?t.spanRecorder=void 0:this.spans.push(t)}}class c{constructor(t){if(this.traceId=(0,s.DM)(),this.spanId=(0,s.DM)().substring(16),this.startTimestamp=(0,n.ph)(),this.tags={},this.data={},this.instrumenter="sentry",!t)return this;t.traceId&&(this.traceId=t.traceId),t.spanId&&(this.spanId=t.spanId),t.parentSpanId&&(this.parentSpanId=t.parentSpanId),"sampled"in t&&(this.sampled=t.sampled),t.op&&(this.op=t.op),t.description&&(this.description=t.description),t.data&&(this.data=t.data),t.tags&&(this.tags=t.tags),t.status&&(this.status=t.status),t.startTimestamp&&(this.startTimestamp=t.startTimestamp),t.endTimestamp&&(this.endTimestamp=t.endTimestamp),t.instrumenter&&(this.instrumenter=t.instrumenter)}startChild(t){const e=new c({...t,parentSpanId:this.spanId,sampled:this.sampled,traceId:this.traceId});if(e.spanRecorder=this.spanRecorder,e.spanRecorder&&e.spanRecorder.add(e),e.transaction=this.transaction,("undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__)&&e.transaction){const i=`[Tracing] Starting '${t&&t.op||"< unknown op >"}' span on transaction '${e.transaction.name||"< unknown name >"}' (${e.transaction.spanId}).`;e.transaction.metadata.spanMetadata[e.spanId]={logMessage:i},r.kg.log(i)}return e}setTag(t,e){return this.tags={...this.tags,[t]:e},this}setData(t,e){return this.data={...this.data,[t]:e},this}setStatus(t){return this.status=t,this}setHttpStatus(t){this.setTag("http.status_code",String(t)),this.setData("http.response.status_code",t);const e=function(t){if(t<400&&t>=100)return"ok";if(t>=400&&t<500)switch(t){case 401:return"unauthenticated";case 403:return"permission_denied";case 404:return"not_found";case 409:return"already_exists";case 413:return"failed_precondition";case 429:return"resource_exhausted";default:return"invalid_argument"}if(t>=500&&t<600)switch(t){case 501:return"unimplemented";case 503:return"unavailable";case 504:return"deadline_exceeded";default:return"internal_error"}return"unknown_error"}(t);return"unknown_error"!==e&&this.setStatus(e),this}isSuccess(){return"ok"===this.status}finish(t){if(("undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__)&&this.transaction&&this.transaction.spanId!==this.spanId){const{logMessage:t}=this.transaction.metadata.spanMetadata[this.spanId];t&&r.kg.log(t.replace("Starting","Finishing"))}this.endTimestamp="number"==typeof t?t:(0,n.ph)()}toTraceparent(){return(0,a.$p)(this.traceId,this.spanId,this.sampled)}toContext(){return(0,o.Jr)({data:this.data,description:this.description,endTimestamp:this.endTimestamp,op:this.op,parentSpanId:this.parentSpanId,sampled:this.sampled,spanId:this.spanId,startTimestamp:this.startTimestamp,status:this.status,tags:this.tags,traceId:this.traceId})}updateWithContext(t){return this.data=t.data||{},this.description=t.description,this.endTimestamp=t.endTimestamp,this.op=t.op,this.parentSpanId=t.parentSpanId,this.sampled=t.sampled,this.spanId=t.spanId||this.spanId,this.startTimestamp=t.startTimestamp||this.startTimestamp,this.status=t.status,this.tags=t.tags||{},this.traceId=t.traceId||this.traceId,this}getTraceContext(){return(0,o.Jr)({data:Object.keys(this.data).length>0?this.data:void 0,description:this.description,op:this.op,parent_span_id:this.parentSpanId,span_id:this.spanId,status:this.status,tags:Object.keys(this.tags).length>0?this.tags:void 0,trace_id:this.traceId})}toJSON(){return(0,o.Jr)({data:Object.keys(this.data).length>0?this.data:void 0,description:this.description,op:this.op,parent_span_id:this.parentSpanId,span_id:this.spanId,start_timestamp:this.startTimestamp,status:this.status,tags:Object.keys(this.tags).length>0?this.tags:void 0,timestamp:this.endTimestamp,trace_id:this.traceId})}}},8069:(t,e,i)=>{"use strict";if(i.d(e,{Y:()=>l}),179==i.j)var s=i(2343);if(179==i.j)var n=i(535);if(179==i.j)var r=i(5659);if(179==i.j)var a=i(454);if(179==i.j)var o=i(8903);class l extends(179==i.j?o.Dr:null){constructor(t,e){super(t),this._measurements={},this._contexts={},this._hub=e||(0,r.Gd)(),this._name=t.name||"",this.metadata={source:"custom",...t.metadata,spanMetadata:{}},this._trimEnd=t.trimEnd,this.transaction=this;const i=this.metadata.dynamicSamplingContext;i&&(this._frozenDynamicSamplingContext={...i})}get name(){return this._name}set name(t){this.setName(t)}setName(t,e="custom"){this._name=t,this.metadata.source=e}initSpanRecorder(t=1e3){this.spanRecorder||(this.spanRecorder=new o.gB(t)),this.spanRecorder.add(this)}setContext(t,e){null===e?delete this._contexts[t]:this._contexts[t]=e}setMeasurement(t,e,i=""){this._measurements[t]={value:e,unit:i}}setMetadata(t){this.metadata={...this.metadata,...t}}finish(t){if(void 0!==this.endTimestamp)return;this.name||(("undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__)&&s.kg.warn("Transaction has no name, falling back to ``."),this.name=""),super.finish(t);const e=this._hub.getClient();if(e&&e.emit&&e.emit("finishTransaction",this),!0!==this.sampled)return("undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__)&&s.kg.log("[Tracing] Discarding transaction because its trace was not chosen to be sampled."),void(e&&e.recordDroppedEvent("sample_rate","transaction"));const i=this.spanRecorder?this.spanRecorder.spans.filter((t=>t!==this&&t.endTimestamp)):[];this._trimEnd&&i.length>0&&(this.endTimestamp=i.reduce(((t,e)=>t.endTimestamp&&e.endTimestamp?t.endTimestamp>e.endTimestamp?t:e:t)).endTimestamp);const n=this.metadata,r={contexts:{...this._contexts,trace:this.getTraceContext()},spans:i,start_timestamp:this.startTimestamp,tags:this.tags,timestamp:this.endTimestamp,transaction:this.name,type:"transaction",sdkProcessingMetadata:{...n,dynamicSamplingContext:this.getDynamicSamplingContext()},...n.source&&{transaction_info:{source:n.source}}};return Object.keys(this._measurements).length>0&&(("undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__)&&s.kg.log("[Measurements] Adding measurements to transaction",JSON.stringify(this._measurements,void 0,2)),r.measurements=this._measurements),("undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__)&&s.kg.log(`[Tracing] Finishing ${this.op} transaction: ${this.name}.`),this._hub.captureEvent(r)}toContext(){const t=super.toContext();return(0,n.Jr)({...t,name:this.name,trimEnd:this._trimEnd})}updateWithContext(t){return super.updateWithContext(t),this.name=t.name||"",this._trimEnd=t.trimEnd,this}getDynamicSamplingContext(){if(this._frozenDynamicSamplingContext)return this._frozenDynamicSamplingContext;const t=this._hub||(0,r.Gd)(),e=t.getClient();if(!e)return{};const i=t.getScope(),s=(0,a._)(this.traceId,e,i),n=this.metadata.sampleRate;void 0!==n&&(s.sample_rate=`${n}`);const o=this.metadata.source;return o&&"url"!==o&&(s.transaction=this.name),void 0!==this.sampled&&(s.sampled=String(this.sampled)),s}setHub(t){this._hub=t}}},9791:(t,e,i)=>{"use strict";if(i.d(e,{x1:()=>n}),179==i.j)var s=i(5659);function n(t){return(t||(0,s.Gd)()).getScope().getTransaction()}},5431:(t,e,i)=>{"use strict";if(i.d(e,{q:()=>u}),179==i.j)var s=i(1227);if(179==i.j)var n=i(8725);if(179==i.j)var r=i(228);if(179==i.j)var a=i(6893);if(179==i.j)var o=i(2343);if(179==i.j)var l=i(409);const c=30;function u(t,e,i=(0,s.x)(t.bufferSize||c)){let u={};function h(s){const c=[];if((0,n.gv)(s,((e,i)=>{const s=(0,n.mL)(i);if((0,r.Q)(u,s)){const n=d(e,i);t.recordDroppedEvent("ratelimit_backoff",s,n)}else c.push(e)})),0===c.length)return(0,a.WD)();const h=(0,n.Jd)(s[0],c),f=e=>{(0,n.gv)(h,((i,s)=>{const r=d(i,s);t.recordDroppedEvent(e,(0,n.mL)(s),r)}))};return i.add((()=>e({body:(0,n.V$)(h,t.textEncoder)}).then((t=>(void 0!==t.statusCode&&(t.statusCode<200||t.statusCode>=300)&&("undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__)&&o.kg.warn(`Sentry responded with status code ${t.statusCode} to sent event.`),u=(0,r.WG)(u,t),t)),(t=>{throw f("network_error"),t})))).then((t=>t),(t=>{if(t instanceof l.b)return("undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__)&&o.kg.error("Skipped sending event because buffer is full."),f("queue_overflow"),(0,a.WD)();throw t}))}return h.__sentry__baseTransport__=!0,{send:h,flush:t=>i.drain(t)}}function d(t,e){if("event"===e||"transaction"===e)return Array.isArray(t)?t[1]:void 0}},7522:(t,e,i)=>{"use strict";if(i.d(e,{z:()=>n}),179==i.j)var s=i(5659);function n(t){if("boolean"==typeof __SENTRY_TRACING__&&!__SENTRY_TRACING__)return!1;const e=(0,s.Gd)().getClient(),i=t||e&&e.getOptions();return!!i&&(i.enableTracing||"tracesSampleRate"in i||"tracesSampler"in i)}},8942:(t,e,i)=>{"use strict";if(i.d(e,{R:()=>d}),179==i.j)var s=i(2844);if(179==i.j)var n=i(1170);if(179==i.j)var r=i(6893);if(179==i.j)var a=i(7321);if(179==i.j)var o=i(1235);if(179==i.j)var l=i(322);if(179==i.j)var c=i(1131);if(179==i.j)var u=i(350);function d(t,e,i,d){const{normalizeDepth:f=3,normalizeMaxBreadth:p=1e3}=t,g={...e,event_id:e.event_id||i.event_id||(0,s.DM)(),timestamp:e.timestamp||(0,n.yW)()},m=i.integrations||t.integrations.map((t=>t.name));!function(t,e){const{environment:i,release:s,dist:n,maxValueLength:r=250}=e;"environment"in t||(t.environment="environment"in e?i:c.J),void 0===t.release&&void 0!==s&&(t.release=s),void 0===t.dist&&void 0!==n&&(t.dist=n),t.message&&(t.message=(0,a.$G)(t.message,r));const o=t.exception&&t.exception.values&&t.exception.values[0];o&&o.value&&(o.value=(0,a.$G)(o.value,r));const l=t.request;l&&l.url&&(l.url=(0,a.$G)(l.url,r))}(g,t),function(t,e){e.length>0&&(t.sdk=t.sdk||{},t.sdk.integrations=[...t.sdk.integrations||[],...e])}(g,m),void 0===e.type&&function(t,e){const i=o.n2._sentryDebugIds;if(!i)return;let s;const n=h.get(e);n?s=n:(s=new Map,h.set(e,s));const r=Object.keys(i).reduce(((t,n)=>{let r;const a=s.get(n);a?r=a:(r=e(n),s.set(n,r));for(let e=r.length-1;e>=0;e--){const s=r[e];if(s.filename){t[s.filename]=i[n];break}}return t}),{});try{t.exception.values.forEach((t=>{t.stacktrace.frames.forEach((t=>{t.filename&&(t.debug_id=r[t.filename])}))}))}catch(t){}}(g,t.stackParser);let y=d;i.captureContext&&(y=u.s.clone(y).update(i.captureContext));let v=(0,r.WD)(g);if(y){if(y.getAttachments){const t=[...i.attachments||[],...y.getAttachments()];t.length&&(i.attachments=t)}v=y.applyToEvent(g,i)}return v.then((t=>(t&&function(t){const e={};try{t.exception.values.forEach((t=>{t.stacktrace.frames.forEach((t=>{t.debug_id&&(t.abs_path?e[t.abs_path]=t.debug_id:t.filename&&(e[t.filename]=t.debug_id),delete t.debug_id)}))}))}catch(t){}if(0===Object.keys(e).length)return;t.debug_meta=t.debug_meta||{},t.debug_meta.images=t.debug_meta.images||[];const i=t.debug_meta.images;Object.keys(e).forEach((t=>{i.push({type:"sourcemap",code_file:t,debug_id:e[t]})}))}(t),"number"==typeof f&&f>0?function(t,e,i){if(!t)return null;const s={...t,...t.breadcrumbs&&{breadcrumbs:t.breadcrumbs.map((t=>({...t,...t.data&&{data:(0,l.Fv)(t.data,e,i)}})))},...t.user&&{user:(0,l.Fv)(t.user,e,i)},...t.contexts&&{contexts:(0,l.Fv)(t.contexts,e,i)},...t.extra&&{extra:(0,l.Fv)(t.extra,e,i)}};return t.contexts&&t.contexts.trace&&s.contexts&&(s.contexts.trace=t.contexts.trace,t.contexts.trace.data&&(s.contexts.trace.data=(0,l.Fv)(t.contexts.trace.data,e,i))),t.spans&&(s.spans=t.spans.map((t=>(t.data&&(t.data=(0,l.Fv)(t.data,e,i)),t)))),s}(t,f,p):t)))}const h=new WeakMap},105:(t,e,i)=>{"use strict";i.d(e,{J:()=>s});const s="7.61.1"},9181:(t,e,i)=>{"use strict";if(i.d(e,{EN:()=>c,IQ:()=>u,bU:()=>r}),179==i.j)var s=i(7597);if(179==i.j)var n=i(2343);const r="baggage",a="sentry-",o=/^sentry-/,l=8192;function c(t){if(!(0,s.HD)(t)&&!Array.isArray(t))return;let e={};if(Array.isArray(t))e=t.reduce(((t,e)=>({...t,...d(e)})),{});else{if(!t)return;e=d(t)}const i=Object.entries(e).reduce(((t,[e,i])=>(e.match(o)&&(t[e.slice(a.length)]=i),t)),{});return Object.keys(i).length>0?i:void 0}function u(t){if(t)return function(t){if(0!==Object.keys(t).length)return Object.entries(t).reduce(((t,[e,i],s)=>{const r=`${encodeURIComponent(e)}=${encodeURIComponent(i)}`,a=0===s?r:`${t},${r}`;return a.length>l?(("undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__)&&n.kg.warn(`Not adding key: ${e} with val: ${i} to baggage header due to exceeding baggage size limits.`),t):a}),"")}(Object.entries(t).reduce(((t,[e,i])=>(i&&(t[`${a}${e}`]=i),t)),{}))}function d(t){return t.split(",").map((t=>t.split("=").map((t=>decodeURIComponent(t.trim()))))).reduce(((t,[e,i])=>(t[e]=i,t)),{})}},8464:(t,e,i)=>{"use strict";if(i.d(e,{Rt:()=>a,l4:()=>l,qT:()=>c}),179==i.j)var s=i(7597);const n=(0,i(1235).Rf)(),r=80;function a(t,e={}){try{let i=t;const s=5,n=[];let a=0,l=0;const c=" > ",u=c.length;let d;const h=Array.isArray(e)?e:e.keyAttrs,f=!Array.isArray(e)&&e.maxStringLength||r;for(;i&&a++1&&l+n.length*u+d.length>=f));)n.push(d),l+=d.length,i=i.parentNode;return n.reverse().join(c)}catch(t){return""}}function o(t,e){const i=t,n=[];let r,a,o,l,c;if(!i||!i.tagName)return"";n.push(i.tagName.toLowerCase());const u=e&&e.length?e.filter((t=>i.getAttribute(t))).map((t=>[t,i.getAttribute(t)])):null;if(u&&u.length)u.forEach((t=>{n.push(`[${t[0]}="${t[1]}"]`)}));else if(i.id&&n.push(`#${i.id}`),r=i.className,r&&(0,s.HD)(r))for(a=r.split(/\s+/),c=0;c{"use strict";if(i.d(e,{y:()=>r}),179==i.j)var s=i(8725);if(179==i.j)var n=i(1170);function r(t,e,i){const r=[{type:"client_report"},{timestamp:i||(0,n.yW)(),discarded_events:t}];return(0,s.Jd)(e?{dsn:e}:{},[r])}},292:(t,e,i)=>{"use strict";if(i.d(e,{RA:()=>r,vK:()=>o}),179==i.j)var s=i(2343);const n=/^(?:(\w+):)\/\/(?:(\w+)(?::(\w+)?)?@)([\w.-]+)(?::(\d+))?\/(.+)/;function r(t,e=!1){const{host:i,path:s,pass:n,port:r,projectId:a,protocol:o,publicKey:l}=t;return`${o}://${l}${e&&n?`:${n}`:""}@${i}${r?`:${r}`:""}/${s?`${s}/`:s}${a}`}function a(t){return{protocol:t.protocol,publicKey:t.publicKey||"",pass:t.pass||"",host:t.host,port:t.port||"",path:t.path||"",projectId:t.projectId}}function o(t){const e="string"==typeof t?function(t){const e=n.exec(t);if(!e)return void console.error(`Invalid Sentry Dsn: ${t}`);const[i,s,r="",o,l="",c]=e.slice(1);let u="",d=c;const h=d.split("/");if(h.length>1&&(u=h.slice(0,-1).join("/"),d=h.pop()),d){const t=d.match(/^\d+/);t&&(d=t[0])}return a({host:o,pass:r,path:u,projectId:d,port:l,protocol:i,publicKey:s})}(t):a(t);if(e&&function(t){if("undefined"!=typeof __SENTRY_DEBUG__&&!__SENTRY_DEBUG__)return!0;const{port:e,projectId:i,protocol:n}=t;return!(["protocol","publicKey","host","projectId"].find((e=>!t[e]&&(s.kg.error(`Invalid Sentry Dsn: ${e} missing`),!0)))||(i.match(/^\d+$/)?function(t){return"http"===t||"https"===t}(n)?e&&isNaN(parseInt(e,10))&&(s.kg.error(`Invalid Sentry Dsn: Invalid port ${e}`),1):(s.kg.error(`Invalid Sentry Dsn: Invalid protocol ${n}`),1):(s.kg.error(`Invalid Sentry Dsn: Invalid projectId ${i}`),1)))}(e))return e}},8518:(t,e,i)=>{"use strict";function s(){return"undefined"!=typeof __SENTRY_BROWSER_BUNDLE__&&!!__SENTRY_BROWSER_BUNDLE__}function n(){return"npm"}i.d(e,{S:()=>n,n:()=>s})},8725:(t,e,i)=>{"use strict";if(i.d(e,{BO:()=>o,Cd:()=>g,HY:()=>p,Jd:()=>a,V$:()=>u,gv:()=>l,mL:()=>f,zQ:()=>d}),179==i.j)var s=i(292);if(179==i.j)var n=i(322);if(179==i.j)var r=i(535);function a(t,e=[]){return[t,e]}function o(t,e){const[i,s]=t;return[i,[...s,e]]}function l(t,e){const i=t[1];for(const t of i)if(e(t,t[0].type))return!0;return!1}function c(t,e){return(e||new TextEncoder).encode(t)}function u(t,e){const[i,s]=t;let r=JSON.stringify(i);function a(t){"string"==typeof r?r="string"==typeof t?r+t:[c(r,e),t]:r.push("string"==typeof t?c(t,e):t)}for(const t of s){const[e,i]=t;if(a(`\n${JSON.stringify(e)}\n`),"string"==typeof i||i instanceof Uint8Array)a(i);else{let t;try{t=JSON.stringify(i)}catch(e){t=JSON.stringify((0,n.Fv)(i))}a(t)}}return"string"==typeof r?r:function(t){const e=t.reduce(((t,e)=>t+e.length),0),i=new Uint8Array(e);let s=0;for(const e of t)i.set(e,s),s+=e.length;return i}(r)}function d(t,e){const i="string"==typeof t.data?c(t.data,e):t.data;return[(0,r.Jr)({type:"attachment",length:i.length,filename:t.filename,content_type:t.contentType,attachment_type:t.attachmentType}),i]}const h={session:"session",sessions:"session",attachment:"attachment",transaction:"transaction",event:"error",client_report:"internal",user_report:"default",profile:"profile",replay_event:"replay",replay_recording:"replay",check_in:"monitor"};function f(t){return h[t]}function p(t){if(!t||!t.sdk)return;const{name:e,version:i}=t.sdk;return{name:e,version:i}}function g(t,e,i,n){const a=t.sdkProcessingMetadata&&t.sdkProcessingMetadata.dynamicSamplingContext;return{event_id:t.event_id,sent_at:(new Date).toISOString(),...e&&{sdk:e},...!!i&&{dsn:(0,s.RA)(n)},...a&&{trace:(0,r.Jr)({...a})}}}},409:(t,e,i)=>{"use strict";i.d(e,{b:()=>s});class s extends Error{constructor(t,e="warn"){super(t),this.message=t,this.name=new.target.prototype.constructor.name,Object.setPrototypeOf(this,new.target.prototype),this.logLevel=e}}},9732:(t,e,i)=>{"use strict";if(i.d(e,{oq:()=>p,xU:()=>d}),179==i.j)var s=i(7597);if(179==i.j)var n=i(2343);if(179==i.j)var r=i(535);if(179==i.j)var a=i(360);if(179==i.j)var o=i(8823);var l=i(1235);if(179==i.j)var c=i(9781);const u=(0,l.Rf)(),d="__sentry_xhr_v2__",h={},f={};function p(t,e){h[t]=h[t]||[],h[t].push(e),function(t){if(!f[t])switch(f[t]=!0,t){case"console":"console"in u&&n.RU.forEach((function(t){t in u.console&&(0,r.hl)(u.console,t,(function(e){return function(...i){g("console",{args:i,level:t}),e&&e.apply(u.console,i)}}))}));break;case"dom":!function(){if(!("document"in u))return;const t=g.bind(null,"dom"),e=T(t,!0);u.document.addEventListener("click",e,!1),u.document.addEventListener("keypress",e,!1),["EventTarget","Node"].forEach((e=>{const i=u[e]&&u[e].prototype;i&&i.hasOwnProperty&&i.hasOwnProperty("addEventListener")&&((0,r.hl)(i,"addEventListener",(function(e){return function(i,s,n){if("click"===i||"keypress"==i)try{const s=this,r=s.__sentry_instrumentation_handlers__=s.__sentry_instrumentation_handlers__||{},a=r[i]=r[i]||{refCount:0};if(!a.handler){const s=T(t);a.handler=s,e.call(this,i,s,n)}a.refCount++}catch(t){}return e.call(this,i,s,n)}})),(0,r.hl)(i,"removeEventListener",(function(t){return function(e,i,s){if("click"===e||"keypress"==e)try{const i=this,n=i.__sentry_instrumentation_handlers__||{},r=n[e];r&&(r.refCount--,r.refCount<=0&&(t.call(this,e,r.handler,s),r.handler=void 0,delete n[e]),0===Object.keys(n).length&&delete i.__sentry_instrumentation_handlers__)}catch(t){}return t.call(this,e,i,s)}})))}))}();break;case"xhr":!function(){if(!("XMLHttpRequest"in u))return;const t=XMLHttpRequest.prototype;(0,r.hl)(t,"open",(function(t){return function(...e){const i=e[1],n=this[d]={method:(0,s.HD)(e[0])?e[0].toUpperCase():e[0],url:e[1],request_headers:{}};(0,s.HD)(i)&&"POST"===n.method&&i.match(/sentry_key/)&&(this.__sentry_own_request__=!0);const a=()=>{const t=this[d];if(t&&4===this.readyState){try{t.status_code=this.status}catch(t){}g("xhr",{args:e,endTimestamp:Date.now(),startTimestamp:Date.now(),xhr:this})}};return"onreadystatechange"in this&&"function"==typeof this.onreadystatechange?(0,r.hl)(this,"onreadystatechange",(function(t){return function(...e){return a(),t.apply(this,e)}})):this.addEventListener("readystatechange",a),(0,r.hl)(this,"setRequestHeader",(function(t){return function(...e){const[i,s]=e,n=this[d];return n&&(n.request_headers[i.toLowerCase()]=s),t.apply(this,e)}})),t.apply(this,e)}})),(0,r.hl)(t,"send",(function(t){return function(...e){const i=this[d];return i&&void 0!==e[0]&&(i.body=e[0]),g("xhr",{args:e,startTimestamp:Date.now(),xhr:this}),t.apply(this,e)}}))}();break;case"fetch":(0,o.t$)()&&(0,r.hl)(u,"fetch",(function(t){return function(...e){const{method:i,url:s}=function(t){if(0===t.length)return{method:"GET",url:""};if(2===t.length){const[e,i]=t;return{url:y(e),method:m(i,"method")?String(i.method).toUpperCase():"GET"}}const e=t[0];return{url:y(e),method:m(e,"method")?String(e.method).toUpperCase():"GET"}}(e),n={args:e,fetchData:{method:i,url:s},startTimestamp:Date.now()};return g("fetch",{...n}),t.apply(u,e).then((t=>(g("fetch",{...n,endTimestamp:Date.now(),response:t}),t)),(t=>{throw g("fetch",{...n,endTimestamp:Date.now(),error:t}),t}))}}));break;case"history":!function(){if(!(0,c.B)())return;const t=u.onpopstate;function e(t){return function(...e){const i=e.length>2?e[2]:void 0;if(i){const t=v,e=String(i);v=e,g("history",{from:t,to:e})}return t.apply(this,e)}}u.onpopstate=function(...e){const i=u.location.href,s=v;if(v=i,g("history",{from:s,to:i}),t)try{return t.apply(this,e)}catch(t){}},(0,r.hl)(u.history,"pushState",e),(0,r.hl)(u.history,"replaceState",e)}();break;case"error":S=u.onerror,u.onerror=function(t,e,i,s,n){return g("error",{column:s,error:n,line:i,msg:t,url:e}),!(!S||S.__SENTRY_LOADER__)&&S.apply(this,arguments)},u.onerror.__SENTRY_INSTRUMENTED__=!0;break;case"unhandledrejection":k=u.onunhandledrejection,u.onunhandledrejection=function(t){return g("unhandledrejection",t),!(k&&!k.__SENTRY_LOADER__)||k.apply(this,arguments)},u.onunhandledrejection.__SENTRY_INSTRUMENTED__=!0;break;default:("undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__)&&n.kg.warn("unknown instrumentation type:",t)}}(t)}function g(t,e){if(t&&h[t])for(const i of h[t]||[])try{i(e)}catch(e){("undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__)&&n.kg.error(`Error while triggering instrumentation handler.\nType: ${t}\nName: ${(0,a.$P)(i)}\nError:`,e)}}function m(t,e){return!!t&&"object"==typeof t&&!!t[e]}function y(t){return"string"==typeof t?t:t?m(t,"url")?t.url:t.toString?t.toString():"":""}let v;const b=1e3;let _,E;function T(t,e=!1){return i=>{if(!i||E===i)return;if(function(t){if("keypress"!==t.type)return!1;try{const e=t.target;if(!e||!e.tagName)return!0;if("INPUT"===e.tagName||"TEXTAREA"===e.tagName||e.isContentEditable)return!1}catch(t){}return!0}(i))return;const s="keypress"===i.type?"input":i.type;(void 0===_||function(t,e){if(!t)return!0;if(t.type!==e.type)return!0;try{if(t.target!==e.target)return!0}catch(t){}return!1}(E,i))&&(t({event:i,name:s,global:e}),E=i),clearTimeout(_),_=u.setTimeout((()=>{_=void 0}),b)}}let S=null,k=null},7597:(t,e,i)=>{"use strict";i.d(e,{Cy:()=>m,HD:()=>c,J8:()=>g,Kj:()=>p,PO:()=>d,TX:()=>o,V9:()=>v,VW:()=>a,VZ:()=>n,cO:()=>h,fm:()=>l,i2:()=>y,kK:()=>f,pt:()=>u});const s=Object.prototype.toString;function n(t){switch(s.call(t)){case"[object Error]":case"[object Exception]":case"[object DOMException]":return!0;default:return v(t,Error)}}function r(t,e){return s.call(t)===`[object ${e}]`}function a(t){return r(t,"ErrorEvent")}function o(t){return r(t,"DOMError")}function l(t){return r(t,"DOMException")}function c(t){return r(t,"String")}function u(t){return null===t||"object"!=typeof t&&"function"!=typeof t}function d(t){return r(t,"Object")}function h(t){return"undefined"!=typeof Event&&v(t,Event)}function f(t){return"undefined"!=typeof Element&&v(t,Element)}function p(t){return r(t,"RegExp")}function g(t){return Boolean(t&&t.then&&"function"==typeof t.then)}function m(t){return d(t)&&"nativeEvent"in t&&"preventDefault"in t&&"stopPropagation"in t}function y(t){return"number"==typeof t&&t!=t}function v(t,e){try{return t instanceof e}catch(t){return!1}}},2343:(t,e,i)=>{"use strict";i.d(e,{Cf:()=>r,RU:()=>n,kg:()=>o});var s=i(1235);const n=["debug","info","warn","error","log","assert","trace"];function r(t){if(!("console"in s.n2))return t();const e=s.n2.console,i={};n.forEach((t=>{const s=e[t]&&e[t].__sentry_original__;t in e&&s&&(i[t]=e[t],e[t]=s)}));try{return t()}finally{Object.keys(i).forEach((t=>{e[t]=i[t]}))}}function a(){let t=!1;const e={enable:()=>{t=!0},disable:()=>{t=!1}};return"undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__?n.forEach((i=>{e[i]=(...e)=>{t&&r((()=>{s.n2.console[i](`Sentry Logger [${i}]:`,...e)}))}})):n.forEach((t=>{e[t]=()=>{}})),e}let o;o="undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__?(0,s.YO)("logger",a):a()},2004:(t,e,i)=>{"use strict";function s(){const t="function"==typeof WeakSet,e=t?new WeakSet:[];return[function(i){if(t)return!!e.has(i)||(e.add(i),!1);for(let t=0;ts})},2844:(t,e,i)=>{"use strict";if(i.d(e,{DM:()=>r,Db:()=>l,EG:()=>c,YO:()=>u,jH:()=>o,lE:()=>d}),179==i.j)var s=i(535);if(179==i.j)var n=i(1235);function r(){const t=n.n2,e=t.crypto||t.msCrypto;if(e&&e.randomUUID)return e.randomUUID().replace(/-/g,"");const i=e&&e.getRandomValues?()=>e.getRandomValues(new Uint8Array(1))[0]:()=>16*Math.random();return([1e7]+1e3+4e3+8e3+1e11).replace(/[018]/g,(t=>(t^(15&i())>>t/4).toString(16)))}function a(t){return t.exception&&t.exception.values?t.exception.values[0]:void 0}function o(t){const{message:e,event_id:i}=t;if(e)return e;const s=a(t);return s?s.type&&s.value?`${s.type}: ${s.value}`:s.type||s.value||i||"":i||""}function l(t,e,i){const s=t.exception=t.exception||{},n=s.values=s.values||[],r=n[0]=n[0]||{};r.value||(r.value=e||""),r.type||(r.type=i||"Error")}function c(t,e){const i=a(t);if(!i)return;const s=i.mechanism;if(i.mechanism={type:"generic",handled:!0,...s,...e},e&&"data"in e){const t={...s&&s.data,...e.data};i.mechanism.data=t}}function u(t){if(t&&t.__sentry_captured__)return!0;try{(0,s.xp)(t,"__sentry_captured__",!0)}catch(t){}return!1}function d(t){return Array.isArray(t)?t:[t]}},1422:(t,e,i)=>{"use strict";if(i.d(e,{KV:()=>n,l$:()=>r}),179==i.j)var s=i(8518);function n(){return!(0,s.n)()&&"[object process]"===Object.prototype.toString.call("undefined"!=typeof process?process:0)}function r(t,e){return t.require(e)}t=i.hmd(t)},322:(t,e,i)=>{"use strict";if(i.d(e,{Fv:()=>o,Qy:()=>l}),179==i.j)var s=i(7597);if(179==i.j)var n=i(2004);if(179==i.j)var r=i(535);if(179==i.j)var a=i(360);function o(t,e=100,i=1/0){try{return c("",t,e,i)}catch(t){return{ERROR:`**non-serializable** (${t})`}}}function l(t,e=3,i=102400){const s=o(t,e);return n=s,function(t){return~-encodeURI(t).split(/%..|./).length}(JSON.stringify(n))>i?l(t,e-1,i):s;var n}function c(t,e,o=1/0,l=1/0,u=(0,n.i)()){const[d,h]=u;if(null==e||["number","boolean","string"].includes(typeof e)&&!(0,s.i2)(e))return e;const f=function(t,e){try{if("domain"===t&&e&&"object"==typeof e&&e._events)return"[Domain]";if("domainEmitter"===t)return"[DomainEmitter]";if(void 0!==i.g&&e===i.g)return"[Global]";if("undefined"!=typeof window&&e===window)return"[Window]";if("undefined"!=typeof document&&e===document)return"[Document]";if((0,s.Cy)(e))return"[SyntheticEvent]";if("number"==typeof e&&e!=e)return"[NaN]";if("function"==typeof e)return`[Function: ${(0,a.$P)(e)}]`;if("symbol"==typeof e)return`[${String(e)}]`;if("bigint"==typeof e)return`[BigInt: ${String(e)}]`;const n=function(t){const e=Object.getPrototypeOf(t);return e?e.constructor.name:"null prototype"}(e);return/^HTML(\w*)Element$/.test(n)?`[HTMLElement: ${n}]`:`[object ${n}]`}catch(t){return`**non-serializable** (${t})`}}(t,e);if(!f.startsWith("[object "))return f;if(e.__sentry_skip_normalization__)return e;const p="number"==typeof e.__sentry_override_normalization_depth__?e.__sentry_override_normalization_depth__:o;if(0===p)return f.replace("object ","");if(d(e))return"[Circular ~]";const g=e;if(g&&"function"==typeof g.toJSON)try{return c("",g.toJSON(),p-1,l,u)}catch(t){}const m=Array.isArray(e)?[]:{};let y=0;const v=(0,r.Sh)(e);for(const t in v){if(!Object.prototype.hasOwnProperty.call(v,t))continue;if(y>=l){m[t]="[MaxProperties ~]";break}const e=v[t];m[t]=c(t,e,p-1,l,u),y++}return h(e),m}},535:(t,e,i)=>{"use strict";if(i.d(e,{$Q:()=>l,HK:()=>c,Jr:()=>g,Sh:()=>d,_j:()=>u,hl:()=>a,xp:()=>o,zf:()=>p}),179==i.j)var s=i(8464);if(179==i.j)var n=i(7597);if(179==i.j)var r=i(7321);function a(t,e,i){if(!(e in t))return;const s=t[e],n=i(s);if("function"==typeof n)try{l(n,s)}catch(t){}t[e]=n}function o(t,e,i){Object.defineProperty(t,e,{value:i,writable:!0,configurable:!0})}function l(t,e){const i=e.prototype||{};t.prototype=e.prototype=i,o(t,"__sentry_original__",e)}function c(t){return t.__sentry_original__}function u(t){return Object.keys(t).map((e=>`${encodeURIComponent(e)}=${encodeURIComponent(t[e])}`)).join("&")}function d(t){if((0,n.VZ)(t))return{message:t.message,name:t.name,stack:t.stack,...f(t)};if((0,n.cO)(t)){const e={type:t.type,target:h(t.target),currentTarget:h(t.currentTarget),...f(t)};return"undefined"!=typeof CustomEvent&&(0,n.V9)(t,CustomEvent)&&(e.detail=t.detail),e}return t}function h(t){try{return(0,n.kK)(t)?(0,s.Rt)(t):Object.prototype.toString.call(t)}catch(t){return""}}function f(t){if("object"==typeof t&&null!==t){const e={};for(const i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}return{}}function p(t,e=40){const i=Object.keys(d(t));if(i.sort(),!i.length)return"[object has no keys]";if(i[0].length>=e)return(0,r.$G)(i[0],e);for(let t=i.length;t>0;t--){const s=i.slice(0,t).join(", ");if(!(s.length>e))return t===i.length?s:(0,r.$G)(s,e)}return""}function g(t){return m(t,new Map)}function m(t,e){if((0,n.PO)(t)){const i=e.get(t);if(void 0!==i)return i;const s={};e.set(t,s);for(const i of Object.keys(t))void 0!==t[i]&&(s[i]=m(t[i],e));return s}if(Array.isArray(t)){const i=e.get(t);if(void 0!==i)return i;const s=[];return e.set(t,s),t.forEach((t=>{s.push(m(t,e))})),s}return t}},1227:(t,e,i)=>{"use strict";if(i.d(e,{x:()=>r}),179==i.j)var s=i(409);if(179==i.j)var n=i(6893);function r(t){const e=[];function i(t){return e.splice(e.indexOf(t),1)[0]}return{$:e,add:function(r){if(!(void 0===t||e.lengthi(a))).then(null,(()=>i(a).then(null,(()=>{})))),a},drain:function(t){return new n.cW(((i,s)=>{let r=e.length;if(!r)return i(!0);const a=setTimeout((()=>{t&&t>0&&i(!1)}),t);e.forEach((t=>{(0,n.WD)(t).then((()=>{--r||(clearTimeout(a),i(!0))}),s)}))}))}}}},228:(t,e,i)=>{"use strict";i.d(e,{Q:()=>n,WG:()=>r});const s=179==i.j?6e4:null;function n(t,e,i=Date.now()){return function(t,e){return t[e]||t.all||0}(t,e)>i}function r(t,{statusCode:e,headers:i},n=Date.now()){const r={...t},a=i&&i["x-sentry-rate-limits"],o=i&&i["retry-after"];if(a)for(const t of a.trim().split(",")){const[e,i]=t.split(":",2),s=parseInt(e,10),a=1e3*(isNaN(s)?60:s);if(i)for(const t of i.split(";"))r[t]=n+a;else r.all=n+a}else o?r.all=n+function(t,e=Date.now()){const i=parseInt(`${t}`,10);if(!isNaN(i))return 1e3*i;const n=Date.parse(`${t}`);return isNaN(n)?s:n-e}(o,n):429===e&&(r.all=n+6e4);return r}},360:(t,e,i)=>{"use strict";i.d(e,{$P:()=>c,Sq:()=>o,pE:()=>a});const s=50,n=/\(error: (.*)\)/,r=/captureMessage|captureException/;function a(...t){const e=t.sort(((t,e)=>t[0]-e[0])).map((t=>t[1]));return(t,i=0)=>{const a=[],o=t.split("\n");for(let t=i;t1024)continue;const r=n.test(i)?i.replace(n,"$1"):i;if(!r.match(/\S*Error: /)){for(const t of e){const e=t(r);if(e){a.push(e);break}}if(a.length>=s)break}}return function(t){if(!t.length)return[];const e=Array.from(t);return/sentryWrapped/.test(e[e.length-1].function||"")&&e.pop(),e.reverse(),r.test(e[e.length-1].function||"")&&(e.pop(),r.test(e[e.length-1].function||"")&&e.pop()),e.slice(0,s).map((t=>({...t,filename:t.filename||e[e.length-1].filename,function:t.function||"?"})))}(a)}}function o(t){return Array.isArray(t)?a(...t):t}const l="";function c(t){try{return t&&"function"==typeof t&&t.name||l}catch(t){return l}}},7321:(t,e,i)=>{"use strict";if(i.d(e,{$G:()=>n,U0:()=>a,nK:()=>r}),179==i.j)var s=i(7597);function n(t,e=0){return"string"!=typeof t||0===e||t.length<=e?t:`${t.slice(0,e)}...`}function r(t,e){if(!Array.isArray(t))return"";const i=[];for(let e=0;efunction(t,e,i=!1){return!!(0,s.HD)(t)&&((0,s.Kj)(e)?e.test(t):!!(0,s.HD)(e)&&(i?t===e:t.includes(e)))}(t,e,i)))}},8823:(t,e,i)=>{"use strict";if(i.d(e,{Ak:()=>r,Du:()=>a,t$:()=>o}),179==i.j)var s=i(2343);const n=(0,i(1235).Rf)();function r(){if(!("fetch"in n))return!1;try{return new Headers,new Request("http://www.example.com"),new Response,!0}catch(t){return!1}}function a(t){return t&&/^function fetch\(\)\s+\{\s+\[native code\]\s+\}$/.test(t.toString())}function o(){if(!r())return!1;if(a(n.fetch))return!0;let t=!1;const e=n.document;if(e&&"function"==typeof e.createElement)try{const i=e.createElement("iframe");i.hidden=!0,e.head.appendChild(i),i.contentWindow&&i.contentWindow.fetch&&(t=a(i.contentWindow.fetch)),e.head.removeChild(i)}catch(t){("undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__)&&s.kg.warn("Could not create sandbox iframe for pure fetch check, bailing to window.fetch: ",t)}return t}},6893:(t,e,i)=>{"use strict";if(i.d(e,{$2:()=>a,WD:()=>r,cW:()=>o}),179==i.j)var s=i(7597);var n;function r(t){return new o((e=>{e(t)}))}function a(t){return new o(((e,i)=>{i(t)}))}!function(t){t[t.PENDING=0]="PENDING",t[t.RESOLVED=1]="RESOLVED",t[t.REJECTED=2]="REJECTED"}(n||(n={}));class o{constructor(t){o.prototype.__init.call(this),o.prototype.__init2.call(this),o.prototype.__init3.call(this),o.prototype.__init4.call(this),this._state=n.PENDING,this._handlers=[];try{t(this._resolve,this._reject)}catch(t){this._reject(t)}}then(t,e){return new o(((i,s)=>{this._handlers.push([!1,e=>{if(t)try{i(t(e))}catch(t){s(t)}else i(e)},t=>{if(e)try{i(e(t))}catch(t){s(t)}else s(t)}]),this._executeHandlers()}))}catch(t){return this.then((t=>t),t)}finally(t){return new o(((e,i)=>{let s,n;return this.then((e=>{n=!1,s=e,t&&t()}),(e=>{n=!0,s=e,t&&t()})).then((()=>{n?i(s):e(s)}))}))}__init(){this._resolve=t=>{this._setResult(n.RESOLVED,t)}}__init2(){this._reject=t=>{this._setResult(n.REJECTED,t)}}__init3(){this._setResult=(t,e)=>{this._state===n.PENDING&&((0,s.J8)(e)?e.then(this._resolve,this._reject):(this._state=t,this._value=e,this._executeHandlers()))}}__init4(){this._executeHandlers=()=>{if(this._state===n.PENDING)return;const t=this._handlers.slice();this._handlers=[],t.forEach((t=>{t[0]||(this._state===n.RESOLVED&&t[1](this._value),this._state===n.REJECTED&&t[2](this._value),t[0]=!0)}))}}}},1170:(t,e,i)=>{"use strict";i.d(e,{Z1:()=>h,ph:()=>u,yW:()=>c});var s=i(1422),n=i(1235);t=i.hmd(t);const r=(0,n.Rf)(),a={nowSeconds:()=>Date.now()/1e3},o=(0,s.KV)()?function(){try{return(0,s.l$)(t,"perf_hooks").performance}catch(t){return}}():function(){const{performance:t}=r;if(t&&t.now)return{now:()=>t.now(),timeOrigin:Date.now()-t.now()}}(),l=void 0===o?a:{nowSeconds:()=>(o.timeOrigin+o.now())/1e3},c=a.nowSeconds.bind(a),u=l.nowSeconds.bind(l);let d;const h=(()=>{const{performance:t}=r;if(!t||!t.now)return void(d="none");const e=36e5,i=t.now(),s=Date.now(),n=t.timeOrigin?Math.abs(t.timeOrigin+i-s):e,a=n{"use strict";if(i.d(e,{$p:()=>o,KA:()=>a}),179==i.j)var s=i(9181);if(179==i.j)var n=i(2844);const r=179==i.j?new RegExp("^[ \\t]*([0-9a-f]{32})?-?([0-9a-f]{16})?-?([01])?[ \\t]*$"):null;function a(t,e){const i=function(t){if(!t)return;const e=t.match(r);if(!e)return;let i;return"1"===e[3]?i=!0:"0"===e[3]&&(i=!1),{traceId:e[1],parentSampled:i,parentSpanId:e[2]}}(t),a=(0,s.EN)(e),{traceId:o,parentSpanId:l,parentSampled:c}=i||{},u={traceId:o||(0,n.DM)(),spanId:(0,n.DM)().substring(16),sampled:void 0!==c&&c};return l&&(u.parentSpanId=l),a&&(u.dsc=a),{traceparentData:i,dynamicSamplingContext:a,propagationContext:u}}function o(t=(0,n.DM)(),e=(0,n.DM)().substring(16),i){let s="";return void 0!==i&&(s=i?"-1":"-0"),`${t}-${e}${s}`}},9781:(t,e,i)=>{"use strict";i.d(e,{B:()=>n});const s=(0,i(1235).Rf)();function n(){const t=s.chrome,e=t&&t.app&&t.app.runtime,i="history"in s&&!!s.history.pushState&&!!s.history.replaceState;return!e&&i}},1235:(t,e,i)=>{"use strict";function s(t){return t&&t.Math==Math?t:void 0}i.d(e,{Rf:()=>r,YO:()=>a,n2:()=>n});const n="object"==typeof globalThis&&s(globalThis)||"object"==typeof window&&s(window)||"object"==typeof self&&s(self)||"object"==typeof i.g&&s(i.g)||function(){return this}()||{};function r(){return n}function a(t,e,i){const s=i||n,r=s.__SENTRY__=s.__SENTRY__||{};return r[t]||(r[t]=e())}},1443:function(t,e,i){"object"==typeof navigator&&(t.exports=function(){"use strict";function t(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function e(t,e){for(var i=0;i(i=100/l.width*(n.clientX-l.left))?i=0:100i?i-=(100-2*i)*c:50e){var i=function(t){var e="".concat(t).match(/(?:\.(\d+))?(?:[eE]([+-]?\d+))?$/);return e?Math.max(0,(e[1]?e[1].length:0)-(e[2]?+e[2]:0)):0}(e);return parseFloat(t.toFixed(i))}return Math.round(t/e)*e}(i/100*(a-r),o)}},{key:"set",value:function(e){t.enabled&&m(e)&&!e.target.disabled&&(e.preventDefault(),e.target.value=this.get(e),function(t,e){if(t&&e){var i=new Event(e,{bubbles:!0});t.dispatchEvent(i)}}(e.target,"touchend"===e.type?"change":"input"))}}],[{key:"setup",value:function(e){var i=1null!=t?t.constructor:null,_=(t,e)=>Boolean(t&&e&&t instanceof e),E=t=>null==t,T=t=>b(t)===Object,S=t=>b(t)===String,k=t=>"function"==typeof t,w=t=>Array.isArray(t),A=t=>_(t,NodeList),R=t=>E(t)||(S(t)||w(t)||A(t))&&!t.length||T(t)&&!Object.keys(t).length;var L=E,I=T,C=t=>b(t)===Number&&!Number.isNaN(t),D=S,x=t=>b(t)===Boolean,P=k,O=w,N=A,M=t=>null!==t&&"object"==typeof t&&1===t.nodeType&&"object"==typeof t.style&&"object"==typeof t.ownerDocument,F=t=>_(t,Event),$=t=>_(t,KeyboardEvent),U=t=>_(t,TextTrack)||!E(t)&&S(t.kind),B=t=>{if(_(t,window.URL))return!0;if(!S(t))return!1;let e=t;t.startsWith("http://")&&t.startsWith("https://")||(e=`http://${t}`);try{return!R(new URL(e).hostname)}catch(t){return!1}},j=R;const G=(()=>{const t=document.createElement("span"),e={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"oTransitionEnd otransitionend",transition:"transitionend"},i=Object.keys(e).find((e=>void 0!==t.style[e]));return!!D(i)&&e[i]})();function V(t,e){setTimeout((()=>{try{t.hidden=!0,t.offsetHeight,t.hidden=!1}catch(t){}}),e)}const H={isIE:Boolean(window.document.documentMode),isEdge:/Edge/g.test(navigator.userAgent),isWebkit:"WebkitAppearance"in document.documentElement.style&&!/Edge/g.test(navigator.userAgent),isIPhone:/iPhone|iPod/gi.test(navigator.userAgent)&&navigator.maxTouchPoints>1,isIos:/iPad|iPhone|iPod/gi.test(navigator.userAgent)&&navigator.maxTouchPoints>1};function K(t,e){return e.split(".").reduce(((t,e)=>t&&t[e]),t)}function Y(t={},...e){if(!e.length)return t;const i=e.shift();return I(i)?(Object.keys(i).forEach((e=>{I(i[e])?(Object.keys(t).includes(e)||Object.assign(t,{[e]:{}}),Y(t[e],i[e])):Object.assign(t,{[e]:i[e]})})),Y(t,...e)):t}function q(t,e){const i=t.length?t:[t];Array.from(i).reverse().forEach(((t,i)=>{const s=i>0?e.cloneNode(!0):e,n=t.parentNode,r=t.nextSibling;s.appendChild(t),r?n.insertBefore(s,r):n.appendChild(s)}))}function z(t,e){M(t)&&!j(e)&&Object.entries(e).filter((([,t])=>!L(t))).forEach((([e,i])=>t.setAttribute(e,i)))}function W(t,e,i){const s=document.createElement(t);return I(e)&&z(s,e),D(i)&&(s.innerText=i),s}function X(t,e,i,s){M(e)&&e.appendChild(W(t,i,s))}function J(t){N(t)||O(t)?Array.from(t).forEach(J):M(t)&&M(t.parentNode)&&t.parentNode.removeChild(t)}function Q(t){if(!M(t))return;let{length:e}=t.childNodes;for(;e>0;)t.removeChild(t.lastChild),e-=1}function Z(t,e){return M(e)&&M(e.parentNode)&&M(t)?(e.parentNode.replaceChild(t,e),t):null}function tt(t,e){if(!D(t)||j(t))return{};const i={},s=Y({},e);return t.split(",").forEach((t=>{const e=t.trim(),n=e.replace(".",""),r=e.replace(/[[\]]/g,"").split("="),[a]=r,o=r.length>1?r[1].replace(/["']/g,""):"";switch(e.charAt(0)){case".":D(s.class)?i.class=`${s.class} ${n}`:i.class=n;break;case"#":i.id=e.replace("#","");break;case"[":i[a]=o}})),Y(s,i)}function et(t,e){if(!M(t))return;let i=e;x(i)||(i=!t.hidden),t.hidden=i}function it(t,e,i){if(N(t))return Array.from(t).map((t=>it(t,e,i)));if(M(t)){let s="toggle";return void 0!==i&&(s=i?"add":"remove"),t.classList[s](e),t.classList.contains(e)}return!1}function st(t,e){return M(t)&&t.classList.contains(e)}function nt(t,e){const{prototype:i}=Element;return(i.matches||i.webkitMatchesSelector||i.mozMatchesSelector||i.msMatchesSelector||function(){return Array.from(document.querySelectorAll(e)).includes(this)}).call(t,e)}function rt(t){return this.elements.container.querySelectorAll(t)}function at(t){return this.elements.container.querySelector(t)}function ot(t=null,e=!1){M(t)&&(t.focus({preventScroll:!0}),e&&it(t,this.config.classNames.tabFocus))}const lt={"audio/ogg":"vorbis","audio/wav":"1","video/webm":"vp8, vorbis","video/mp4":"avc1.42E01E, mp4a.40.2","video/ogg":"theora"},ct={audio:"canPlayType"in document.createElement("audio"),video:"canPlayType"in document.createElement("video"),check(t,e,i){const s=H.isIPhone&&i&&ct.playsinline,n=ct[t]||"html5"!==e;return{api:n,ui:n&&ct.rangeInput&&("video"!==t||!H.isIPhone||s)}},pip:!(H.isIPhone||!P(W("video").webkitSetPresentationMode)&&(!document.pictureInPictureEnabled||W("video").disablePictureInPicture)),airplay:P(window.WebKitPlaybackTargetAvailabilityEvent),playsinline:"playsInline"in document.createElement("video"),mime(t){if(j(t))return!1;const[e]=t.split("/");let i=t;if(!this.isHTML5||e!==this.type)return!1;Object.keys(lt).includes(i)&&(i+=`; codecs="${lt[t]}"`);try{return Boolean(i&&this.media.canPlayType(i).replace(/no/,""))}catch(t){return!1}},textTracks:"textTracks"in document.createElement("video"),rangeInput:(()=>{const t=document.createElement("input");return t.type="range","range"===t.type})(),touch:"ontouchstart"in document.documentElement,transitions:!1!==G,reducedMotion:"matchMedia"in window&&window.matchMedia("(prefers-reduced-motion)").matches},ut=(()=>{let t=!1;try{const e=Object.defineProperty({},"passive",{get:()=>(t=!0,null)});window.addEventListener("test",null,e),window.removeEventListener("test",null,e)}catch(t){}return t})();function dt(t,e,i,s=!1,n=!0,r=!1){if(!t||!("addEventListener"in t)||j(e)||!P(i))return;const a=e.split(" ");let o=r;ut&&(o={passive:n,capture:r}),a.forEach((e=>{this&&this.eventListeners&&s&&this.eventListeners.push({element:t,type:e,callback:i,options:o}),t[s?"addEventListener":"removeEventListener"](e,i,o)}))}function ht(t,e="",i,s=!0,n=!1){dt.call(this,t,e,i,!0,s,n)}function ft(t,e="",i,s=!0,n=!1){dt.call(this,t,e,i,!1,s,n)}function pt(t,e="",i,s=!0,n=!1){const r=(...a)=>{ft(t,e,r,s,n),i.apply(this,a)};dt.call(this,t,e,r,!0,s,n)}function gt(t,e="",i=!1,s={}){if(!M(t)||j(e))return;const n=new CustomEvent(e,{bubbles:i,detail:{...s,plyr:this}});t.dispatchEvent(n)}function mt(){this&&this.eventListeners&&(this.eventListeners.forEach((t=>{const{element:e,type:i,callback:s,options:n}=t;e.removeEventListener(i,s,n)})),this.eventListeners=[])}function yt(){return new Promise((t=>this.ready?setTimeout(t,0):ht.call(this,this.elements.container,"ready",t))).then((()=>{}))}function vt(t){(t=>_(t,Promise)&&k(t.then))(t)&&t.then(null,(()=>{}))}function bt(t){return O(t)?t.filter(((e,i)=>t.indexOf(e)===i)):t}function _t(t,e){return O(t)&&t.length?t.reduce(((t,i)=>Math.abs(i-e)({...t,[e/i]:[e,i]})),{});function St(t){return!!(O(t)||D(t)&&t.includes(":"))&&(O(t)?t:t.split(":")).map(Number).every(C)}function kt(t){if(!O(t)||!t.every(C))return null;const[e,i]=t,s=(t,e)=>0===e?t:s(e,t%e),n=s(e,i);return[e/n,i/n]}function wt(t){const e=t=>St(t)?t.split(":").map(Number):null;let i=e(t);if(null===i&&(i=e(this.config.ratio)),null===i&&!j(this.embed)&&O(this.embed.ratio)&&({ratio:i}=this.embed),null===i&&this.isHTML5){const{videoWidth:t,videoHeight:e}=this.media;i=[t,e]}return kt(i)}function At(t){if(!this.isVideo)return{};const{wrapper:e}=this.elements,i=wt.call(this,t);if(!O(i))return{};const[s,n]=kt(i),r=100/s*n;if(Et(`aspect-ratio: ${s}/${n}`)?e.style.aspectRatio=`${s}/${n}`:e.style.paddingBottom=`${r}%`,this.isVimeo&&!this.config.vimeo.premium&&this.supported.ui){const t=100/this.media.offsetWidth*parseInt(window.getComputedStyle(this.media).paddingBottom,10),i=(t-r)/(t/50);this.fullscreen.active?e.style.paddingBottom=null:this.media.style.transform=`translateY(-${i}%)`}else this.isHTML5&&e.classList.add(this.config.classNames.videoFixedRatio);return{padding:r,ratio:i}}function Rt(t,e,i=.05){const s=t/e,n=_t(Object.keys(Tt),s);return Math.abs(n-s)<=i?Tt[n]:[t,e]}const Lt={getSources(){return this.isHTML5?Array.from(this.media.querySelectorAll("source")).filter((t=>{const e=t.getAttribute("type");return!!j(e)||ct.mime.call(this,e)})):[]},getQualityOptions(){return this.config.quality.forced?this.config.quality.options:Lt.getSources.call(this).map((t=>Number(t.getAttribute("size")))).filter(Boolean)},setup(){if(!this.isHTML5)return;const t=this;t.options.speed=t.config.speed.options,j(this.config.ratio)||At.call(t),Object.defineProperty(t.media,"quality",{get(){const e=Lt.getSources.call(t).find((e=>e.getAttribute("src")===t.source));return e&&Number(e.getAttribute("size"))},set(e){if(t.quality!==e){if(t.config.quality.forced&&P(t.config.quality.onChange))t.config.quality.onChange(e);else{const i=Lt.getSources.call(t).find((t=>Number(t.getAttribute("size"))===e));if(!i)return;const{currentTime:s,paused:n,preload:r,readyState:a,playbackRate:o}=t.media;t.media.src=i.getAttribute("src"),("none"!==r||a)&&(t.once("loadedmetadata",(()=>{t.speed=o,t.currentTime=s,n||vt(t.play())})),t.media.load())}gt.call(t,t.media,"qualitychange",!1,{quality:e})}}})},cancelRequests(){this.isHTML5&&(J(Lt.getSources.call(this)),this.media.setAttribute("src",this.config.blankVideo),this.media.load(),this.debug.log("Cancelled network requests"))}};function It(t,...e){return j(t)?t:t.toString().replace(/{(\d+)}/g,((t,i)=>e[i].toString()))}const Ct=(t="",e="",i="")=>t.replace(new RegExp(e.toString().replace(/([.*+?^=!:${}()|[\]/\\])/g,"\\$1"),"g"),i.toString()),Dt=(t="")=>t.toString().replace(/\w\S*/g,(t=>t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()));function xt(t){const e=document.createElement("div");return e.appendChild(t),e.innerHTML}const Pt={pip:"PIP",airplay:"AirPlay",html5:"HTML5",vimeo:"Vimeo",youtube:"YouTube"},Ot={get(t="",e={}){if(j(t)||j(e))return"";let i=K(e.i18n,t);if(j(i))return Object.keys(Pt).includes(t)?Pt[t]:"";const s={"{seektime}":e.seekTime,"{title}":e.title};return Object.entries(s).forEach((([t,e])=>{i=Ct(i,t,e)})),i}};class Nt{constructor(e){t(this,"get",(t=>{if(!Nt.supported||!this.enabled)return null;const e=window.localStorage.getItem(this.key);if(j(e))return null;const i=JSON.parse(e);return D(t)&&t.length?i[t]:i})),t(this,"set",(t=>{if(!Nt.supported||!this.enabled)return;if(!I(t))return;let e=this.get();j(e)&&(e={}),Y(e,t);try{window.localStorage.setItem(this.key,JSON.stringify(e))}catch(t){}})),this.enabled=e.config.storage.enabled,this.key=e.config.storage.key}static get supported(){try{if(!("localStorage"in window))return!1;const t="___test";return window.localStorage.setItem(t,t),window.localStorage.removeItem(t),!0}catch(t){return!1}}}function Mt(t,e="text"){return new Promise(((i,s)=>{try{const s=new XMLHttpRequest;if(!("withCredentials"in s))return;s.addEventListener("load",(()=>{if("text"===e)try{i(JSON.parse(s.responseText))}catch(t){i(s.responseText)}else i(s.response)})),s.addEventListener("error",(()=>{throw new Error(s.status)})),s.open("GET",t,!0),s.responseType=e,s.send()}catch(t){s(t)}}))}function Ft(t,e){if(!D(t))return;const i=D(e);let s=!1;const n=()=>null!==document.getElementById(e),r=(t,e)=>{t.innerHTML=e,i&&n()||document.body.insertAdjacentElement("afterbegin",t)};if(!i||!n()){const n=Nt.supported,a=document.createElement("div");if(a.setAttribute("hidden",""),i&&a.setAttribute("id",e),n){const t=window.localStorage.getItem(`cache-${e}`);if(s=null!==t,s){const e=JSON.parse(t);r(a,e.content)}}Mt(t).then((t=>{if(!j(t)){if(n)try{window.localStorage.setItem(`cache-${e}`,JSON.stringify({content:t}))}catch(t){}r(a,t)}})).catch((()=>{}))}}const $t=t=>Math.trunc(t/60/60%60,10);function Ut(t=0,e=!1,i=!1){if(!C(t))return Ut(void 0,e,i);const s=t=>`0${t}`.slice(-2);let n=$t(t);const r=(a=t,Math.trunc(a/60%60,10));var a;const o=(t=>Math.trunc(t%60,10))(t);return n=e||n>0?`${n}:`:"",`${i&&t>0?"-":""}${n}${s(r)}:${s(o)}`}const Bt={getIconUrl(){const t=new URL(this.config.iconUrl,window.location),e=window.location.host?window.location.host:window.top.location.host,i=t.host!==e||H.isIE&&!window.svg4everybody;return{url:this.config.iconUrl,cors:i}},findElements(){try{return this.elements.controls=at.call(this,this.config.selectors.controls.wrapper),this.elements.buttons={play:rt.call(this,this.config.selectors.buttons.play),pause:at.call(this,this.config.selectors.buttons.pause),restart:at.call(this,this.config.selectors.buttons.restart),rewind:at.call(this,this.config.selectors.buttons.rewind),fastForward:at.call(this,this.config.selectors.buttons.fastForward),mute:at.call(this,this.config.selectors.buttons.mute),pip:at.call(this,this.config.selectors.buttons.pip),airplay:at.call(this,this.config.selectors.buttons.airplay),settings:at.call(this,this.config.selectors.buttons.settings),captions:at.call(this,this.config.selectors.buttons.captions),fullscreen:at.call(this,this.config.selectors.buttons.fullscreen)},this.elements.progress=at.call(this,this.config.selectors.progress),this.elements.inputs={seek:at.call(this,this.config.selectors.inputs.seek),volume:at.call(this,this.config.selectors.inputs.volume)},this.elements.display={buffer:at.call(this,this.config.selectors.display.buffer),currentTime:at.call(this,this.config.selectors.display.currentTime),duration:at.call(this,this.config.selectors.display.duration)},M(this.elements.progress)&&(this.elements.display.seekTooltip=this.elements.progress.querySelector(`.${this.config.classNames.tooltip}`)),!0}catch(t){return this.debug.warn("It looks like there is a problem with your custom controls HTML",t),this.toggleNativeControls(!0),!1}},createIcon(t,e){const i="http://www.w3.org/2000/svg",s=Bt.getIconUrl.call(this),n=`${s.cors?"":s.url}#${this.config.iconPrefix}`,r=document.createElementNS(i,"svg");z(r,Y(e,{"aria-hidden":"true",focusable:"false"}));const a=document.createElementNS(i,"use"),o=`${n}-${t}`;return"href"in a&&a.setAttributeNS("http://www.w3.org/1999/xlink","href",o),a.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",o),r.appendChild(a),r},createLabel(t,e={}){const i=Ot.get(t,this.config);return W("span",{...e,class:[e.class,this.config.classNames.hidden].filter(Boolean).join(" ")},i)},createBadge(t){if(j(t))return null;const e=W("span",{class:this.config.classNames.menu.value});return e.appendChild(W("span",{class:this.config.classNames.menu.badge},t)),e},createButton(t,e){const i=Y({},e);let s=function(t=""){let e=t.toString();return e=function(t=""){let e=t.toString();return e=Ct(e,"-"," "),e=Ct(e,"_"," "),e=Dt(e),Ct(e," ","")}(e),e.charAt(0).toLowerCase()+e.slice(1)}(t);const n={element:"button",toggle:!1,label:null,icon:null,labelPressed:null,iconPressed:null};switch(["element","icon","label"].forEach((t=>{Object.keys(i).includes(t)&&(n[t]=i[t],delete i[t])})),"button"!==n.element||Object.keys(i).includes("type")||(i.type="button"),Object.keys(i).includes("class")?i.class.split(" ").some((t=>t===this.config.classNames.control))||Y(i,{class:`${i.class} ${this.config.classNames.control}`}):i.class=this.config.classNames.control,t){case"play":n.toggle=!0,n.label="play",n.labelPressed="pause",n.icon="play",n.iconPressed="pause";break;case"mute":n.toggle=!0,n.label="mute",n.labelPressed="unmute",n.icon="volume",n.iconPressed="muted";break;case"captions":n.toggle=!0,n.label="enableCaptions",n.labelPressed="disableCaptions",n.icon="captions-off",n.iconPressed="captions-on";break;case"fullscreen":n.toggle=!0,n.label="enterFullscreen",n.labelPressed="exitFullscreen",n.icon="enter-fullscreen",n.iconPressed="exit-fullscreen";break;case"play-large":i.class+=` ${this.config.classNames.control}--overlaid`,s="play",n.label="play",n.icon="play";break;default:j(n.label)&&(n.label=s),j(n.icon)&&(n.icon=t)}const r=W(n.element);return n.toggle?(r.appendChild(Bt.createIcon.call(this,n.iconPressed,{class:"icon--pressed"})),r.appendChild(Bt.createIcon.call(this,n.icon,{class:"icon--not-pressed"})),r.appendChild(Bt.createLabel.call(this,n.labelPressed,{class:"label--pressed"})),r.appendChild(Bt.createLabel.call(this,n.label,{class:"label--not-pressed"}))):(r.appendChild(Bt.createIcon.call(this,n.icon)),r.appendChild(Bt.createLabel.call(this,n.label))),Y(i,tt(this.config.selectors.buttons[s],i)),z(r,i),"play"===s?(O(this.elements.buttons[s])||(this.elements.buttons[s]=[]),this.elements.buttons[s].push(r)):this.elements.buttons[s]=r,r},createRange(t,e){const i=W("input",Y(tt(this.config.selectors.inputs[t]),{type:"range",min:0,max:100,step:.01,value:0,autocomplete:"off",role:"slider","aria-label":Ot.get(t,this.config),"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":0},e));return this.elements.inputs[t]=i,Bt.updateRangeFill.call(this,i),v.setup(i),i},createProgress(t,e){const i=W("progress",Y(tt(this.config.selectors.display[t]),{min:0,max:100,value:0,role:"progressbar","aria-hidden":!0},e));if("volume"!==t){i.appendChild(W("span",null,"0"));const e={played:"played",buffer:"buffered"}[t],s=e?Ot.get(e,this.config):"";i.innerText=`% ${s.toLowerCase()}`}return this.elements.display[t]=i,i},createTime(t,e){const i=tt(this.config.selectors.display[t],e),s=W("div",Y(i,{class:`${i.class?i.class:""} ${this.config.classNames.display.time} `.trim(),"aria-label":Ot.get(t,this.config)}),"00:00");return this.elements.display[t]=s,s},bindMenuItemShortcuts(t,e){ht.call(this,t,"keydown keyup",(i=>{if(!["Space","ArrowUp","ArrowDown","ArrowRight"].includes(i.key))return;if(i.preventDefault(),i.stopPropagation(),"keydown"===i.type)return;const s=nt(t,'[role="menuitemradio"]');if(!s&&["Space","ArrowRight"].includes(i.key))Bt.showMenuPanel.call(this,e,!0);else{let e;"Space"!==i.key&&("ArrowDown"===i.key||s&&"ArrowRight"===i.key?(e=t.nextElementSibling,M(e)||(e=t.parentNode.firstElementChild)):(e=t.previousElementSibling,M(e)||(e=t.parentNode.lastElementChild)),ot.call(this,e,!0))}}),!1),ht.call(this,t,"keyup",(t=>{"Return"===t.key&&Bt.focusFirstMenuItem.call(this,null,!0)}))},createMenuItem({value:t,list:e,type:i,title:s,badge:n=null,checked:r=!1}){const a=tt(this.config.selectors.inputs[i]),o=W("button",Y(a,{type:"button",role:"menuitemradio",class:`${this.config.classNames.control} ${a.class?a.class:""}`.trim(),"aria-checked":r,value:t})),l=W("span");l.innerHTML=s,M(n)&&l.appendChild(n),o.appendChild(l),Object.defineProperty(o,"checked",{enumerable:!0,get:()=>"true"===o.getAttribute("aria-checked"),set(t){t&&Array.from(o.parentNode.children).filter((t=>nt(t,'[role="menuitemradio"]'))).forEach((t=>t.setAttribute("aria-checked","false"))),o.setAttribute("aria-checked",t?"true":"false")}}),this.listeners.bind(o,"click keyup",(e=>{if(!$(e)||"Space"===e.key){switch(e.preventDefault(),e.stopPropagation(),o.checked=!0,i){case"language":this.currentTrack=Number(t);break;case"quality":this.quality=t;break;case"speed":this.speed=parseFloat(t)}Bt.showMenuPanel.call(this,"home",$(e))}}),i,!1),Bt.bindMenuItemShortcuts.call(this,o,i),e.appendChild(o)},formatTime(t=0,e=!1){return C(t)?Ut(t,$t(this.duration)>0,e):t},updateTimeDisplay(t=null,e=0,i=!1){M(t)&&C(e)&&(t.innerText=Bt.formatTime(e,i))},updateVolume(){this.supported.ui&&(M(this.elements.inputs.volume)&&Bt.setRange.call(this,this.elements.inputs.volume,this.muted?0:this.volume),M(this.elements.buttons.mute)&&(this.elements.buttons.mute.pressed=this.muted||0===this.volume))},setRange(t,e=0){M(t)&&(t.value=e,Bt.updateRangeFill.call(this,t))},updateProgress(t){if(!this.supported.ui||!F(t))return;let e=0;const i=(t,e)=>{const i=C(e)?e:0,s=M(t)?t:this.elements.display.buffer;if(M(s)){s.value=i;const t=s.getElementsByTagName("span")[0];M(t)&&(t.childNodes[0].nodeValue=i)}};if(t)switch(t.type){case"timeupdate":case"seeking":case"seeked":s=this.currentTime,n=this.duration,e=0===s||0===n||Number.isNaN(s)||Number.isNaN(n)?0:(s/n*100).toFixed(2),"timeupdate"===t.type&&Bt.setRange.call(this,this.elements.inputs.seek,e);break;case"playing":case"progress":i(this.elements.display.buffer,100*this.buffered)}var s,n},updateRangeFill(t){const e=F(t)?t.target:t;if(M(e)&&"range"===e.getAttribute("type")){if(nt(e,this.config.selectors.inputs.seek)){e.setAttribute("aria-valuenow",this.currentTime);const t=Bt.formatTime(this.currentTime),i=Bt.formatTime(this.duration),s=Ot.get("seekLabel",this.config);e.setAttribute("aria-valuetext",s.replace("{currentTime}",t).replace("{duration}",i))}else if(nt(e,this.config.selectors.inputs.volume)){const t=100*e.value;e.setAttribute("aria-valuenow",t),e.setAttribute("aria-valuetext",`${t.toFixed(1)}%`)}else e.setAttribute("aria-valuenow",e.value);H.isWebkit&&e.style.setProperty("--value",e.value/e.max*100+"%")}},updateSeekTooltip(t){var e,i;if(!this.config.tooltips.seek||!M(this.elements.inputs.seek)||!M(this.elements.display.seekTooltip)||0===this.duration)return;const s=this.elements.display.seekTooltip,n=`${this.config.classNames.tooltip}--visible`,r=t=>it(s,n,t);if(this.touch)return void r(!1);let a=0;const o=this.elements.progress.getBoundingClientRect();if(F(t))a=100/o.width*(t.pageX-o.left);else{if(!st(s,n))return;a=parseFloat(s.style.left,10)}a<0?a=0:a>100&&(a=100);const l=this.duration/100*a;s.innerText=Bt.formatTime(l);const c=null===(e=this.config.markers)||void 0===e||null===(i=e.points)||void 0===i?void 0:i.find((({time:t})=>t===Math.round(l)));c&&s.insertAdjacentHTML("afterbegin",`${c.label}
`),s.style.left=`${a}%`,F(t)&&["mouseenter","mouseleave"].includes(t.type)&&r("mouseenter"===t.type)},timeUpdate(t){const e=!M(this.elements.display.duration)&&this.config.invertTime;Bt.updateTimeDisplay.call(this,this.elements.display.currentTime,e?this.duration-this.currentTime:this.currentTime,e),t&&"timeupdate"===t.type&&this.media.seeking||Bt.updateProgress.call(this,t)},durationUpdate(){if(!this.supported.ui||!this.config.invertTime&&this.currentTime)return;if(this.duration>=2**32)return et(this.elements.display.currentTime,!0),void et(this.elements.progress,!0);M(this.elements.inputs.seek)&&this.elements.inputs.seek.setAttribute("aria-valuemax",this.duration);const t=M(this.elements.display.duration);!t&&this.config.displayDuration&&this.paused&&Bt.updateTimeDisplay.call(this,this.elements.display.currentTime,this.duration),t&&Bt.updateTimeDisplay.call(this,this.elements.display.duration,this.duration),this.config.markers.enabled&&Bt.setMarkers.call(this),Bt.updateSeekTooltip.call(this)},toggleMenuButton(t,e){et(this.elements.settings.buttons[t],!e)},updateSetting(t,e,i){const s=this.elements.settings.panels[t];let n=null,r=e;if("captions"===t)n=this.currentTrack;else{if(n=j(i)?this[t]:i,j(n)&&(n=this.config[t].default),!j(this.options[t])&&!this.options[t].includes(n))return void this.debug.warn(`Unsupported value of '${n}' for ${t}`);if(!this.config[t].options.includes(n))return void this.debug.warn(`Disabled value of '${n}' for ${t}`)}if(M(r)||(r=s&&s.querySelector('[role="menu"]')),!M(r))return;this.elements.settings.buttons[t].querySelector(`.${this.config.classNames.menu.value}`).innerHTML=Bt.getLabel.call(this,t,n);const a=r&&r.querySelector(`[value="${n}"]`);M(a)&&(a.checked=!0)},getLabel(t,e){switch(t){case"speed":return 1===e?Ot.get("normal",this.config):`${e}×`;case"quality":if(C(e)){const t=Ot.get(`qualityLabel.${e}`,this.config);return t.length?t:`${e}p`}return Dt(e);case"captions":return Vt.getLabel.call(this);default:return null}},setQualityMenu(t){if(!M(this.elements.settings.panels.quality))return;const e="quality",i=this.elements.settings.panels.quality.querySelector('[role="menu"]');O(t)&&(this.options.quality=bt(t).filter((t=>this.config.quality.options.includes(t))));const s=!j(this.options.quality)&&this.options.quality.length>1;if(Bt.toggleMenuButton.call(this,e,s),Q(i),Bt.checkMenu.call(this),!s)return;const n=t=>{const e=Ot.get(`qualityBadge.${t}`,this.config);return e.length?Bt.createBadge.call(this,e):null};this.options.quality.sort(((t,e)=>{const i=this.config.quality.options;return i.indexOf(t)>i.indexOf(e)?1:-1})).forEach((t=>{Bt.createMenuItem.call(this,{value:t,list:i,type:e,title:Bt.getLabel.call(this,"quality",t),badge:n(t)})})),Bt.updateSetting.call(this,e,i)},setCaptionsMenu(){if(!M(this.elements.settings.panels.captions))return;const t="captions",e=this.elements.settings.panels.captions.querySelector('[role="menu"]'),i=Vt.getTracks.call(this),s=Boolean(i.length);if(Bt.toggleMenuButton.call(this,t,s),Q(e),Bt.checkMenu.call(this),!s)return;const n=i.map(((t,i)=>({value:i,checked:this.captions.toggled&&this.currentTrack===i,title:Vt.getLabel.call(this,t),badge:t.language&&Bt.createBadge.call(this,t.language.toUpperCase()),list:e,type:"language"})));n.unshift({value:-1,checked:!this.captions.toggled,title:Ot.get("disabled",this.config),list:e,type:"language"}),n.forEach(Bt.createMenuItem.bind(this)),Bt.updateSetting.call(this,t,e)},setSpeedMenu(){if(!M(this.elements.settings.panels.speed))return;const t="speed",e=this.elements.settings.panels.speed.querySelector('[role="menu"]');this.options.speed=this.options.speed.filter((t=>t>=this.minimumSpeed&&t<=this.maximumSpeed));const i=!j(this.options.speed)&&this.options.speed.length>1;Bt.toggleMenuButton.call(this,t,i),Q(e),Bt.checkMenu.call(this),i&&(this.options.speed.forEach((i=>{Bt.createMenuItem.call(this,{value:i,list:e,type:t,title:Bt.getLabel.call(this,"speed",i)})})),Bt.updateSetting.call(this,t,e))},checkMenu(){const{buttons:t}=this.elements.settings,e=!j(t)&&Object.values(t).some((t=>!t.hidden));et(this.elements.settings.menu,!e)},focusFirstMenuItem(t,e=!1){if(this.elements.settings.popup.hidden)return;let i=t;M(i)||(i=Object.values(this.elements.settings.panels).find((t=>!t.hidden)));const s=i.querySelector('[role^="menuitem"]');ot.call(this,s,e)},toggleMenu(t){const{popup:e}=this.elements.settings,i=this.elements.buttons.settings;if(!M(e)||!M(i))return;const{hidden:s}=e;let n=s;if(x(t))n=t;else if($(t)&&"Escape"===t.key)n=!1;else if(F(t)){const s=P(t.composedPath)?t.composedPath()[0]:t.target,r=e.contains(s);if(r||!r&&t.target!==i&&n)return}i.setAttribute("aria-expanded",n),et(e,!n),it(this.elements.container,this.config.classNames.menu.open,n),n&&$(t)?Bt.focusFirstMenuItem.call(this,null,!0):n||s||ot.call(this,i,$(t))},getMenuSize(t){const e=t.cloneNode(!0);e.style.position="absolute",e.style.opacity=0,e.removeAttribute("hidden"),t.parentNode.appendChild(e);const i=e.scrollWidth,s=e.scrollHeight;return J(e),{width:i,height:s}},showMenuPanel(t="",e=!1){const i=this.elements.container.querySelector(`#plyr-settings-${this.id}-${t}`);if(!M(i))return;const s=i.parentNode,n=Array.from(s.children).find((t=>!t.hidden));if(ct.transitions&&!ct.reducedMotion){s.style.width=`${n.scrollWidth}px`,s.style.height=`${n.scrollHeight}px`;const t=Bt.getMenuSize.call(this,i),e=t=>{t.target===s&&["width","height"].includes(t.propertyName)&&(s.style.width="",s.style.height="",ft.call(this,s,G,e))};ht.call(this,s,G,e),s.style.width=`${t.width}px`,s.style.height=`${t.height}px`}et(n,!0),et(i,!1),Bt.focusFirstMenuItem.call(this,i,e)},setDownloadUrl(){const t=this.elements.buttons.download;M(t)&&t.setAttribute("href",this.download)},create(t){const{bindMenuItemShortcuts:e,createButton:i,createProgress:s,createRange:n,createTime:r,setQualityMenu:a,setSpeedMenu:o,showMenuPanel:l}=Bt;this.elements.controls=null,O(this.config.controls)&&this.config.controls.includes("play-large")&&this.elements.container.appendChild(i.call(this,"play-large"));const c=W("div",tt(this.config.selectors.controls.wrapper));this.elements.controls=c;const u={class:"plyr__controls__item"};return bt(O(this.config.controls)?this.config.controls:[]).forEach((a=>{if("restart"===a&&c.appendChild(i.call(this,"restart",u)),"rewind"===a&&c.appendChild(i.call(this,"rewind",u)),"play"===a&&c.appendChild(i.call(this,"play",u)),"fast-forward"===a&&c.appendChild(i.call(this,"fast-forward",u)),"progress"===a){const e=W("div",{class:`${u.class} plyr__progress__container`}),i=W("div",tt(this.config.selectors.progress));if(i.appendChild(n.call(this,"seek",{id:`plyr-seek-${t.id}`})),i.appendChild(s.call(this,"buffer")),this.config.tooltips.seek){const t=W("span",{class:this.config.classNames.tooltip},"00:00");i.appendChild(t),this.elements.display.seekTooltip=t}this.elements.progress=i,e.appendChild(this.elements.progress),c.appendChild(e)}if("current-time"===a&&c.appendChild(r.call(this,"currentTime",u)),"duration"===a&&c.appendChild(r.call(this,"duration",u)),"mute"===a||"volume"===a){let{volume:e}=this.elements;if(M(e)&&c.contains(e)||(e=W("div",Y({},u,{class:`${u.class} plyr__volume`.trim()})),this.elements.volume=e,c.appendChild(e)),"mute"===a&&e.appendChild(i.call(this,"mute")),"volume"===a&&!H.isIos){const i={max:1,step:.05,value:this.config.volume};e.appendChild(n.call(this,"volume",Y(i,{id:`plyr-volume-${t.id}`})))}}if("captions"===a&&c.appendChild(i.call(this,"captions",u)),"settings"===a&&!j(this.config.settings)){const s=W("div",Y({},u,{class:`${u.class} plyr__menu`.trim(),hidden:""}));s.appendChild(i.call(this,"settings",{"aria-haspopup":!0,"aria-controls":`plyr-settings-${t.id}`,"aria-expanded":!1}));const n=W("div",{class:"plyr__menu__container",id:`plyr-settings-${t.id}`,hidden:""}),r=W("div"),a=W("div",{id:`plyr-settings-${t.id}-home`}),o=W("div",{role:"menu"});a.appendChild(o),r.appendChild(a),this.elements.settings.panels.home=a,this.config.settings.forEach((i=>{const s=W("button",Y(tt(this.config.selectors.buttons.settings),{type:"button",class:`${this.config.classNames.control} ${this.config.classNames.control}--forward`,role:"menuitem","aria-haspopup":!0,hidden:""}));e.call(this,s,i),ht.call(this,s,"click",(()=>{l.call(this,i,!1)}));const n=W("span",null,Ot.get(i,this.config)),a=W("span",{class:this.config.classNames.menu.value});a.innerHTML=t[i],n.appendChild(a),s.appendChild(n),o.appendChild(s);const c=W("div",{id:`plyr-settings-${t.id}-${i}`,hidden:""}),u=W("button",{type:"button",class:`${this.config.classNames.control} ${this.config.classNames.control}--back`});u.appendChild(W("span",{"aria-hidden":!0},Ot.get(i,this.config))),u.appendChild(W("span",{class:this.config.classNames.hidden},Ot.get("menuBack",this.config))),ht.call(this,c,"keydown",(t=>{"ArrowLeft"===t.key&&(t.preventDefault(),t.stopPropagation(),l.call(this,"home",!0))}),!1),ht.call(this,u,"click",(()=>{l.call(this,"home",!1)})),c.appendChild(u),c.appendChild(W("div",{role:"menu"})),r.appendChild(c),this.elements.settings.buttons[i]=s,this.elements.settings.panels[i]=c})),n.appendChild(r),s.appendChild(n),c.appendChild(s),this.elements.settings.popup=n,this.elements.settings.menu=s}if("pip"===a&&ct.pip&&c.appendChild(i.call(this,"pip",u)),"airplay"===a&&ct.airplay&&c.appendChild(i.call(this,"airplay",u)),"download"===a){const t=Y({},u,{element:"a",href:this.download,target:"_blank"});this.isHTML5&&(t.download="");const{download:e}=this.config.urls;!B(e)&&this.isEmbed&&Y(t,{icon:`logo-${this.provider}`,label:this.provider}),c.appendChild(i.call(this,"download",t))}"fullscreen"===a&&c.appendChild(i.call(this,"fullscreen",u))})),this.isHTML5&&a.call(this,Lt.getQualityOptions.call(this)),o.call(this),c},inject(){if(this.config.loadSprite){const t=Bt.getIconUrl.call(this);t.cors&&Ft(t.url,"sprite-plyr")}this.id=Math.floor(1e4*Math.random());let t=null;this.elements.controls=null;const e={id:this.id,seektime:this.config.seekTime,title:this.config.title};let i,s=!0;if(P(this.config.controls)&&(this.config.controls=this.config.controls.call(this,e)),this.config.controls||(this.config.controls=[]),M(this.config.controls)||D(this.config.controls)?t=this.config.controls:(t=Bt.create.call(this,{id:this.id,seektime:this.config.seekTime,speed:this.speed,quality:this.quality,captions:Vt.getLabel.call(this)}),s=!1),s&&D(this.config.controls)&&(t=(t=>{let i=t;return Object.entries(e).forEach((([t,e])=>{i=Ct(i,`{${t}}`,e)})),i})(t)),D(this.config.selectors.controls.container)&&(i=document.querySelector(this.config.selectors.controls.container)),M(i)||(i=this.elements.container),i[M(t)?"insertAdjacentElement":"insertAdjacentHTML"]("afterbegin",t),M(this.elements.controls)||Bt.findElements.call(this),!j(this.elements.buttons)){const t=t=>{const e=this.config.classNames.controlPressed;t.setAttribute("aria-pressed","false"),Object.defineProperty(t,"pressed",{configurable:!0,enumerable:!0,get:()=>st(t,e),set(i=!1){it(t,e,i),t.setAttribute("aria-pressed",i?"true":"false")}})};Object.values(this.elements.buttons).filter(Boolean).forEach((e=>{O(e)||N(e)?Array.from(e).filter(Boolean).forEach(t):t(e)}))}if(H.isEdge&&V(i),this.config.tooltips.controls){const{classNames:t,selectors:e}=this.config,i=`${e.controls.wrapper} ${e.labels} .${t.hidden}`,s=rt.call(this,i);Array.from(s).forEach((t=>{it(t,this.config.classNames.hidden,!1),it(t,this.config.classNames.tooltip,!0)}))}},setMediaMetadata(){try{"mediaSession"in navigator&&(navigator.mediaSession.metadata=new window.MediaMetadata({title:this.config.mediaMetadata.title,artist:this.config.mediaMetadata.artist,album:this.config.mediaMetadata.album,artwork:this.config.mediaMetadata.artwork}))}catch(t){}},setMarkers(){var t,e;if(!this.duration||this.elements.markers)return;const i=null===(t=this.config.markers)||void 0===t||null===(e=t.points)||void 0===e?void 0:e.filter((({time:t})=>t>0&&tit(r,a,t);i.forEach((t=>{const e=W("span",{class:this.config.classNames.marker},""),i=t.time/this.duration*100+"%";r&&(e.addEventListener("mouseenter",(()=>{t.label||(r.style.left=i,r.innerHTML=t.label,o(!0))})),e.addEventListener("mouseleave",(()=>{o(!1)}))),e.addEventListener("click",(()=>{this.currentTime=t.time})),e.style.left=i,n.appendChild(e)})),s.appendChild(n),this.config.tooltips.seek||(r=W("span",{class:this.config.classNames.tooltip},""),s.appendChild(r)),this.elements.markers={points:n,tip:r},this.elements.progress.appendChild(s)}};function jt(t,e=!0){let i=t;if(e){const t=document.createElement("a");t.href=i,i=t.href}try{return new URL(i)}catch(t){return null}}function Gt(t){const e=new URLSearchParams;return I(t)&&Object.entries(t).forEach((([t,i])=>{e.set(t,i)})),e}const Vt={setup(){if(!this.supported.ui)return;if(!this.isVideo||this.isYouTube||this.isHTML5&&!ct.textTracks)return void(O(this.config.controls)&&this.config.controls.includes("settings")&&this.config.settings.includes("captions")&&Bt.setCaptionsMenu.call(this));var t,e;if(M(this.elements.captions)||(this.elements.captions=W("div",tt(this.config.selectors.captions)),this.elements.captions.setAttribute("dir","auto"),t=this.elements.captions,e=this.elements.wrapper,M(t)&&M(e)&&e.parentNode.insertBefore(t,e.nextSibling)),H.isIE&&window.URL){const t=this.media.querySelectorAll("track");Array.from(t).forEach((t=>{const e=t.getAttribute("src"),i=jt(e);null!==i&&i.hostname!==window.location.href.hostname&&["http:","https:"].includes(i.protocol)&&Mt(e,"blob").then((e=>{t.setAttribute("src",window.URL.createObjectURL(e))})).catch((()=>{J(t)}))}))}const i=bt((navigator.languages||[navigator.language||navigator.userLanguage||"en"]).map((t=>t.split("-")[0])));let s=(this.storage.get("language")||this.config.captions.language||"auto").toLowerCase();"auto"===s&&([s]=i);let n=this.storage.get("captions");if(x(n)||({active:n}=this.config.captions),Object.assign(this.captions,{toggled:!1,active:n,language:s,languages:i}),this.isHTML5){const t=this.config.captions.update?"addtrack removetrack":"removetrack";ht.call(this,this.media.textTracks,t,Vt.update.bind(this))}setTimeout(Vt.update.bind(this),0)},update(){const t=Vt.getTracks.call(this,!0),{active:e,language:i,meta:s,currentTrackNode:n}=this.captions,r=Boolean(t.find((t=>t.language===i)));this.isHTML5&&this.isVideo&&t.filter((t=>!s.get(t))).forEach((t=>{this.debug.log("Track added",t),s.set(t,{default:"showing"===t.mode}),"showing"===t.mode&&(t.mode="hidden"),ht.call(this,t,"cuechange",(()=>Vt.updateCues.call(this)))})),(r&&this.language!==i||!t.includes(n))&&(Vt.setLanguage.call(this,i),Vt.toggle.call(this,e&&r)),this.elements&&it(this.elements.container,this.config.classNames.captions.enabled,!j(t)),O(this.config.controls)&&this.config.controls.includes("settings")&&this.config.settings.includes("captions")&&Bt.setCaptionsMenu.call(this)},toggle(t,e=!0){if(!this.supported.ui)return;const{toggled:i}=this.captions,s=this.config.classNames.captions.active,n=L(t)?!i:t;if(n!==i){if(e||(this.captions.active=n,this.storage.set({captions:n})),!this.language&&n&&!e){const t=Vt.getTracks.call(this),e=Vt.findTrack.call(this,[this.captions.language,...this.captions.languages],!0);return this.captions.language=e.language,void Vt.set.call(this,t.indexOf(e))}this.elements.buttons.captions&&(this.elements.buttons.captions.pressed=n),it(this.elements.container,s,n),this.captions.toggled=n,Bt.updateSetting.call(this,"captions"),gt.call(this,this.media,n?"captionsenabled":"captionsdisabled")}setTimeout((()=>{n&&this.captions.toggled&&(this.captions.currentTrackNode.mode="hidden")}))},set(t,e=!0){const i=Vt.getTracks.call(this);if(-1!==t)if(C(t))if(t in i){if(this.captions.currentTrack!==t){this.captions.currentTrack=t;const s=i[t],{language:n}=s||{};this.captions.currentTrackNode=s,Bt.updateSetting.call(this,"captions"),e||(this.captions.language=n,this.storage.set({language:n})),this.isVimeo&&this.embed.enableTextTrack(n),gt.call(this,this.media,"languagechange")}Vt.toggle.call(this,!0,e),this.isHTML5&&this.isVideo&&Vt.updateCues.call(this)}else this.debug.warn("Track not found",t);else this.debug.warn("Invalid caption argument",t);else Vt.toggle.call(this,!1,e)},setLanguage(t,e=!0){if(!D(t))return void this.debug.warn("Invalid language argument",t);const i=t.toLowerCase();this.captions.language=i;const s=Vt.getTracks.call(this),n=Vt.findTrack.call(this,[i]);Vt.set.call(this,s.indexOf(n),e)},getTracks(t=!1){return Array.from((this.media||{}).textTracks||[]).filter((e=>!this.isHTML5||t||this.captions.meta.has(e))).filter((t=>["captions","subtitles"].includes(t.kind)))},findTrack(t,e=!1){const i=Vt.getTracks.call(this),s=t=>Number((this.captions.meta.get(t)||{}).default),n=Array.from(i).sort(((t,e)=>s(e)-s(t)));let r;return t.every((t=>(r=n.find((e=>e.language===t)),!r))),r||(e?n[0]:void 0)},getCurrentTrack(){return Vt.getTracks.call(this)[this.currentTrack]},getLabel(t){let e=t;return!U(e)&&ct.textTracks&&this.captions.toggled&&(e=Vt.getCurrentTrack.call(this)),U(e)?j(e.label)?j(e.language)?Ot.get("enabled",this.config):t.language.toUpperCase():e.label:Ot.get("disabled",this.config)},updateCues(t){if(!this.supported.ui)return;if(!M(this.elements.captions))return void this.debug.warn("No captions element to render to");if(!L(t)&&!Array.isArray(t))return void this.debug.warn("updateCues: Invalid input",t);let e=t;if(!e){const t=Vt.getCurrentTrack.call(this);e=Array.from((t||{}).activeCues||[]).map((t=>t.getCueAsHTML())).map(xt)}const i=e.map((t=>t.trim())).join("\n");if(i!==this.elements.captions.innerHTML){Q(this.elements.captions);const t=W("span",tt(this.config.selectors.caption));t.innerHTML=i,this.elements.captions.appendChild(t),gt.call(this,this.media,"cuechange")}}},Ht={enabled:!0,title:"",debug:!1,autoplay:!1,autopause:!0,playsinline:!0,seekTime:10,volume:1,muted:!1,duration:null,displayDuration:!0,invertTime:!0,toggleInvert:!0,ratio:null,clickToPlay:!0,hideControls:!0,resetOnEnd:!1,disableContextMenu:!0,loadSprite:!0,iconPrefix:"plyr",iconUrl:"https://cdn.plyr.io/3.7.3/plyr.svg",blankVideo:"https://cdn.plyr.io/static/blank.mp4",quality:{default:576,options:[4320,2880,2160,1440,1080,720,576,480,360,240],forced:!1,onChange:null},loop:{active:!1},speed:{selected:1,options:[.5,.75,1,1.25,1.5,1.75,2,4]},keyboard:{focused:!0,global:!1},tooltips:{controls:!1,seek:!0},captions:{active:!1,language:"auto",update:!1},fullscreen:{enabled:!0,fallback:!0,iosNative:!1},storage:{enabled:!0,key:"plyr"},controls:["play-large","play","progress","current-time","mute","volume","captions","settings","pip","airplay","fullscreen"],settings:["captions","quality","speed"],i18n:{restart:"Restart",rewind:"Rewind {seektime}s",play:"Play",pause:"Pause",fastForward:"Forward {seektime}s",seek:"Seek",seekLabel:"{currentTime} of {duration}",played:"Played",buffered:"Buffered",currentTime:"Current time",duration:"Duration",volume:"Volume",mute:"Mute",unmute:"Unmute",enableCaptions:"Enable captions",disableCaptions:"Disable captions",download:"Download",enterFullscreen:"Enter fullscreen",exitFullscreen:"Exit fullscreen",frameTitle:"Player for {title}",captions:"Captions",settings:"Settings",pip:"PIP",menuBack:"Go back to previous menu",speed:"Speed",normal:"Normal",quality:"Quality",loop:"Loop",start:"Start",end:"End",all:"All",reset:"Reset",disabled:"Disabled",enabled:"Enabled",advertisement:"Ad",qualityBadge:{2160:"4K",1440:"HD",1080:"HD",720:"HD",576:"SD",480:"SD"}},urls:{download:null,vimeo:{sdk:"https://player.vimeo.com/api/player.js",iframe:"https://player.vimeo.com/video/{0}?{1}",api:"https://vimeo.com/api/oembed.json?url={0}"},youtube:{sdk:"https://www.youtube.com/iframe_api",api:"https://noembed.com/embed?url=https://www.youtube.com/watch?v={0}"},googleIMA:{sdk:"https://imasdk.googleapis.com/js/sdkloader/ima3.js"}},listeners:{seek:null,play:null,pause:null,restart:null,rewind:null,fastForward:null,mute:null,volume:null,captions:null,download:null,fullscreen:null,pip:null,airplay:null,speed:null,quality:null,loop:null,language:null},events:["ended","progress","stalled","playing","waiting","canplay","canplaythrough","loadstart","loadeddata","loadedmetadata","timeupdate","volumechange","play","pause","error","seeking","seeked","emptied","ratechange","cuechange","download","enterfullscreen","exitfullscreen","captionsenabled","captionsdisabled","languagechange","controlshidden","controlsshown","ready","statechange","qualitychange","adsloaded","adscontentpause","adscontentresume","adstarted","adsmidpoint","adscomplete","adsallcomplete","adsimpression","adsclick"],selectors:{editable:"input, textarea, select, [contenteditable]",container:".plyr",controls:{container:null,wrapper:".plyr__controls"},labels:"[data-plyr]",buttons:{play:'[data-plyr="play"]',pause:'[data-plyr="pause"]',restart:'[data-plyr="restart"]',rewind:'[data-plyr="rewind"]',fastForward:'[data-plyr="fast-forward"]',mute:'[data-plyr="mute"]',captions:'[data-plyr="captions"]',download:'[data-plyr="download"]',fullscreen:'[data-plyr="fullscreen"]',pip:'[data-plyr="pip"]',airplay:'[data-plyr="airplay"]',settings:'[data-plyr="settings"]',loop:'[data-plyr="loop"]'},inputs:{seek:'[data-plyr="seek"]',volume:'[data-plyr="volume"]',speed:'[data-plyr="speed"]',language:'[data-plyr="language"]',quality:'[data-plyr="quality"]'},display:{currentTime:".plyr__time--current",duration:".plyr__time--duration",buffer:".plyr__progress__buffer",loop:".plyr__progress__loop",volume:".plyr__volume--display"},progress:".plyr__progress",captions:".plyr__captions",caption:".plyr__caption"},classNames:{type:"plyr--{0}",provider:"plyr--{0}",video:"plyr__video-wrapper",embed:"plyr__video-embed",videoFixedRatio:"plyr__video-wrapper--fixed-ratio",embedContainer:"plyr__video-embed__container",poster:"plyr__poster",posterEnabled:"plyr__poster-enabled",ads:"plyr__ads",control:"plyr__control",controlPressed:"plyr__control--pressed",playing:"plyr--playing",paused:"plyr--paused",stopped:"plyr--stopped",loading:"plyr--loading",hover:"plyr--hover",tooltip:"plyr__tooltip",cues:"plyr__cues",marker:"plyr__progress__marker",hidden:"plyr__sr-only",hideControls:"plyr--hide-controls",isIos:"plyr--is-ios",isTouch:"plyr--is-touch",uiSupported:"plyr--full-ui",noTransition:"plyr--no-transition",display:{time:"plyr__time"},menu:{value:"plyr__menu__value",badge:"plyr__badge",open:"plyr--menu-open"},captions:{enabled:"plyr--captions-enabled",active:"plyr--captions-active"},fullscreen:{enabled:"plyr--fullscreen-enabled",fallback:"plyr--fullscreen-fallback"},pip:{supported:"plyr--pip-supported",active:"plyr--pip-active"},airplay:{supported:"plyr--airplay-supported",active:"plyr--airplay-active"},tabFocus:"plyr__tab-focus",previewThumbnails:{thumbContainer:"plyr__preview-thumb",thumbContainerShown:"plyr__preview-thumb--is-shown",imageContainer:"plyr__preview-thumb__image-container",timeContainer:"plyr__preview-thumb__time-container",scrubbingContainer:"plyr__preview-scrubbing",scrubbingContainerShown:"plyr__preview-scrubbing--is-shown"}},attributes:{embed:{provider:"data-plyr-provider",id:"data-plyr-embed-id",hash:"data-plyr-embed-hash"}},ads:{enabled:!1,publisherId:"",tagUrl:""},previewThumbnails:{enabled:!1,src:""},vimeo:{byline:!1,portrait:!1,title:!1,speed:!0,transparent:!1,customControls:!0,referrerPolicy:null,premium:!1},youtube:{rel:0,showinfo:0,iv_load_policy:3,modestbranding:1,customControls:!0,noCookie:!1},mediaMetadata:{title:"",artist:"",album:"",artwork:[]},markers:{enabled:!1,points:[]}},Kt="picture-in-picture",Yt={html5:"html5",youtube:"youtube",vimeo:"vimeo"},qt="video",zt=()=>{};class Wt{constructor(t=!1){this.enabled=window.console&&t,this.enabled&&this.log("Debugging enabled")}get log(){return this.enabled?Function.prototype.bind.call(console.log,console):zt}get warn(){return this.enabled?Function.prototype.bind.call(console.warn,console):zt}get error(){return this.enabled?Function.prototype.bind.call(console.error,console):zt}}class Xt{constructor(e){t(this,"onChange",(()=>{if(!this.enabled)return;const t=this.player.elements.buttons.fullscreen;M(t)&&(t.pressed=this.active);const e=this.target===this.player.media?this.target:this.player.elements.container;gt.call(this.player,e,this.active?"enterfullscreen":"exitfullscreen",!0)})),t(this,"toggleFallback",((t=!1)=>{if(t?this.scrollPosition={x:window.scrollX||0,y:window.scrollY||0}:window.scrollTo(this.scrollPosition.x,this.scrollPosition.y),document.body.style.overflow=t?"hidden":"",it(this.target,this.player.config.classNames.fullscreen.fallback,t),H.isIos){let e=document.head.querySelector('meta[name="viewport"]');const i="viewport-fit=cover";e||(e=document.createElement("meta"),e.setAttribute("name","viewport"));const s=D(e.content)&&e.content.includes(i);t?(this.cleanupViewport=!s,s||(e.content+=`,${i}`)):this.cleanupViewport&&(e.content=e.content.split(",").filter((t=>t.trim()!==i)).join(","))}this.onChange()})),t(this,"trapFocus",(t=>{if(H.isIos||!this.active||"Tab"!==t.key)return;const e=document.activeElement,i=rt.call(this.player,"a[href], button:not(:disabled), input:not(:disabled), [tabindex]"),[s]=i,n=i[i.length-1];e!==n||t.shiftKey?e===s&&t.shiftKey&&(n.focus(),t.preventDefault()):(s.focus(),t.preventDefault())})),t(this,"update",(()=>{if(this.enabled){let t;t=this.forceFallback?"Fallback (forced)":Xt.native?"Native":"Fallback",this.player.debug.log(`${t} fullscreen enabled`)}else this.player.debug.log("Fullscreen not supported and fallback disabled");it(this.player.elements.container,this.player.config.classNames.fullscreen.enabled,this.enabled)})),t(this,"enter",(()=>{this.enabled&&(H.isIos&&this.player.config.fullscreen.iosNative?this.player.isVimeo?this.player.embed.requestFullscreen():this.target.webkitEnterFullscreen():!Xt.native||this.forceFallback?this.toggleFallback(!0):this.prefix?j(this.prefix)||this.target[`${this.prefix}Request${this.property}`]():this.target.requestFullscreen({navigationUI:"hide"}))})),t(this,"exit",(()=>{if(this.enabled)if(H.isIos&&this.player.config.fullscreen.iosNative)this.target.webkitExitFullscreen(),vt(this.player.play());else if(!Xt.native||this.forceFallback)this.toggleFallback(!1);else if(this.prefix){if(!j(this.prefix)){const t="moz"===this.prefix?"Cancel":"Exit";document[`${this.prefix}${t}${this.property}`]()}}else(document.cancelFullScreen||document.exitFullscreen).call(document)})),t(this,"toggle",(()=>{this.active?this.exit():this.enter()})),this.player=e,this.prefix=Xt.prefix,this.property=Xt.property,this.scrollPosition={x:0,y:0},this.forceFallback="force"===e.config.fullscreen.fallback,this.player.elements.fullscreen=e.config.fullscreen.container&&function(t,e){const{prototype:i}=Element;return(i.closest||function(){let t=this;do{if(nt.matches(t,e))return t;t=t.parentElement||t.parentNode}while(null!==t&&1===t.nodeType);return null}).call(t,e)}(this.player.elements.container,e.config.fullscreen.container),ht.call(this.player,document,"ms"===this.prefix?"MSFullscreenChange":`${this.prefix}fullscreenchange`,(()=>{this.onChange()})),ht.call(this.player,this.player.elements.container,"dblclick",(t=>{M(this.player.elements.controls)&&this.player.elements.controls.contains(t.target)||this.player.listeners.proxy(t,this.toggle,"fullscreen")})),ht.call(this,this.player.elements.container,"keydown",(t=>this.trapFocus(t))),this.update()}static get native(){return!!(document.fullscreenEnabled||document.webkitFullscreenEnabled||document.mozFullScreenEnabled||document.msFullscreenEnabled)}get usingNative(){return Xt.native&&!this.forceFallback}static get prefix(){if(P(document.exitFullscreen))return"";let t="";return["webkit","moz","ms"].some((e=>!(!P(document[`${e}ExitFullscreen`])&&!P(document[`${e}CancelFullScreen`])||(t=e,0)))),t}static get property(){return"moz"===this.prefix?"FullScreen":"Fullscreen"}get enabled(){return(Xt.native||this.player.config.fullscreen.fallback)&&this.player.config.fullscreen.enabled&&this.player.supported.ui&&this.player.isVideo}get active(){if(!this.enabled)return!1;if(!Xt.native||this.forceFallback)return st(this.target,this.player.config.classNames.fullscreen.fallback);const t=this.prefix?this.target.getRootNode()[`${this.prefix}${this.property}Element`]:this.target.getRootNode().fullscreenElement;return t&&t.shadowRoot?t===this.target.getRootNode().host:t===this.target}get target(){return H.isIos&&this.player.config.fullscreen.iosNative?this.player.media:this.player.elements.fullscreen||this.player.elements.container}}function Jt(t,e=1){return new Promise(((i,s)=>{const n=new Image,r=()=>{delete n.onload,delete n.onerror,(n.naturalWidth>=e?i:s)(n)};Object.assign(n,{onload:r,onerror:r,src:t})}))}const Qt={addStyleHook(){it(this.elements.container,this.config.selectors.container.replace(".",""),!0),it(this.elements.container,this.config.classNames.uiSupported,this.supported.ui)},toggleNativeControls(t=!1){t&&this.isHTML5?this.media.setAttribute("controls",""):this.media.removeAttribute("controls")},build(){if(this.listeners.media(),!this.supported.ui)return this.debug.warn(`Basic support only for ${this.provider} ${this.type}`),void Qt.toggleNativeControls.call(this,!0);M(this.elements.controls)||(Bt.inject.call(this),this.listeners.controls()),Qt.toggleNativeControls.call(this),this.isHTML5&&Vt.setup.call(this),this.volume=null,this.muted=null,this.loop=null,this.quality=null,this.speed=null,Bt.updateVolume.call(this),Bt.timeUpdate.call(this),Bt.durationUpdate.call(this),Qt.checkPlaying.call(this),it(this.elements.container,this.config.classNames.pip.supported,ct.pip&&this.isHTML5&&this.isVideo),it(this.elements.container,this.config.classNames.airplay.supported,ct.airplay&&this.isHTML5),it(this.elements.container,this.config.classNames.isIos,H.isIos),it(this.elements.container,this.config.classNames.isTouch,this.touch),this.ready=!0,setTimeout((()=>{gt.call(this,this.media,"ready")}),0),Qt.setTitle.call(this),this.poster&&Qt.setPoster.call(this,this.poster,!1).catch((()=>{})),this.config.duration&&Bt.durationUpdate.call(this),this.config.mediaMetadata&&Bt.setMediaMetadata.call(this)},setTitle(){let t=Ot.get("play",this.config);if(D(this.config.title)&&!j(this.config.title)&&(t+=`, ${this.config.title}`),Array.from(this.elements.buttons.play||[]).forEach((e=>{e.setAttribute("aria-label",t)})),this.isEmbed){const t=at.call(this,"iframe");if(!M(t))return;const e=j(this.config.title)?"video":this.config.title,i=Ot.get("frameTitle",this.config);t.setAttribute("title",i.replace("{title}",e))}},togglePoster(t){it(this.elements.container,this.config.classNames.posterEnabled,t)},setPoster(t,e=!0){return e&&this.poster?Promise.reject(new Error("Poster already set")):(this.media.setAttribute("data-poster",t),this.elements.poster.removeAttribute("hidden"),yt.call(this).then((()=>Jt(t))).catch((e=>{throw t===this.poster&&Qt.togglePoster.call(this,!1),e})).then((()=>{if(t!==this.poster)throw new Error("setPoster cancelled by later call to setPoster")})).then((()=>(Object.assign(this.elements.poster.style,{backgroundImage:`url('${t}')`,backgroundSize:""}),Qt.togglePoster.call(this,!0),t))))},checkPlaying(t){it(this.elements.container,this.config.classNames.playing,this.playing),it(this.elements.container,this.config.classNames.paused,this.paused),it(this.elements.container,this.config.classNames.stopped,this.stopped),Array.from(this.elements.buttons.play||[]).forEach((t=>{Object.assign(t,{pressed:this.playing}),t.setAttribute("aria-label",Ot.get(this.playing?"pause":"play",this.config))})),F(t)&&"timeupdate"===t.type||Qt.toggleControls.call(this)},checkLoading(t){this.loading=["stalled","waiting"].includes(t.type),clearTimeout(this.timers.loading),this.timers.loading=setTimeout((()=>{it(this.elements.container,this.config.classNames.loading,this.loading),Qt.toggleControls.call(this)}),this.loading?250:0)},toggleControls(t){const{controls:e}=this.elements;if(e&&this.config.hideControls){const i=this.touch&&this.lastSeekTime+2e3>Date.now();this.toggleControls(Boolean(t||this.loading||this.paused||e.pressed||e.hover||i))}},migrateStyles(){Object.values({...this.media.style}).filter((t=>!j(t)&&D(t)&&t.startsWith("--plyr"))).forEach((t=>{this.elements.container.style.setProperty(t,this.media.style.getPropertyValue(t)),this.media.style.removeProperty(t)})),j(this.media.style)&&this.media.removeAttribute("style")}};class Zt{constructor(e){t(this,"firstTouch",(()=>{const{player:t}=this,{elements:e}=t;t.touch=!0,it(e.container,t.config.classNames.isTouch,!0)})),t(this,"setTabFocus",(t=>{const{player:e}=this,{elements:i}=e,{key:s,type:n,timeStamp:r}=t;if(clearTimeout(this.focusTimer),"keydown"===n&&"Tab"!==s)return;"keydown"===n&&(this.lastKeyDown=r);const a=r-this.lastKeyDown<=20;("focus"!==n||a)&&((()=>{const t=e.config.classNames.tabFocus;it(rt.call(e,`.${t}`),t,!1)})(),"focusout"!==n&&(this.focusTimer=setTimeout((()=>{const t=document.activeElement;i.container.contains(t)&&it(document.activeElement,e.config.classNames.tabFocus,!0)}),10)))})),t(this,"global",((t=!0)=>{const{player:e}=this;e.config.keyboard.global&&dt.call(e,window,"keydown keyup",this.handleKey,t,!1),dt.call(e,document.body,"click",this.toggleMenu,t),pt.call(e,document.body,"touchstart",this.firstTouch),dt.call(e,document.body,"keydown focus blur focusout",this.setTabFocus,t,!1,!0)})),t(this,"container",(()=>{const{player:t}=this,{config:e,elements:i,timers:s}=t;!e.keyboard.global&&e.keyboard.focused&&ht.call(t,i.container,"keydown keyup",this.handleKey,!1),ht.call(t,i.container,"mousemove mouseleave touchstart touchmove enterfullscreen exitfullscreen",(e=>{const{controls:n}=i;n&&"enterfullscreen"===e.type&&(n.pressed=!1,n.hover=!1);let r=0;["touchstart","touchmove","mousemove"].includes(e.type)&&(Qt.toggleControls.call(t,!0),r=t.touch?3e3:2e3),clearTimeout(s.controls),s.controls=setTimeout((()=>Qt.toggleControls.call(t,!1)),r)}));const n=()=>{if(!t.isVimeo||t.config.vimeo.premium)return;const e=i.wrapper,{active:s}=t.fullscreen,[n,r]=wt.call(t),a=Et(`aspect-ratio: ${n} / ${r}`);if(!s)return void(a?(e.style.width=null,e.style.height=null):(e.style.maxWidth=null,e.style.margin=null));const[o,l]=[Math.max(document.documentElement.clientWidth||0,window.innerWidth||0),Math.max(document.documentElement.clientHeight||0,window.innerHeight||0)],c=o/l>n/r;a?(e.style.width=c?"auto":"100%",e.style.height=c?"100%":"auto"):(e.style.maxWidth=c?l/r*n+"px":null,e.style.margin=c?"0 auto":null)},r=()=>{clearTimeout(s.resized),s.resized=setTimeout(n,50)};ht.call(t,i.container,"enterfullscreen exitfullscreen",(e=>{const{target:s}=t.fullscreen;s===i.container&&(!t.isEmbed&&j(t.config.ratio)||(n(),("enterfullscreen"===e.type?ht:ft).call(t,window,"resize",r)))}))})),t(this,"media",(()=>{const{player:t}=this,{elements:e}=t;if(ht.call(t,t.media,"timeupdate seeking seeked",(e=>Bt.timeUpdate.call(t,e))),ht.call(t,t.media,"durationchange loadeddata loadedmetadata",(e=>Bt.durationUpdate.call(t,e))),ht.call(t,t.media,"ended",(()=>{t.isHTML5&&t.isVideo&&t.config.resetOnEnd&&(t.restart(),t.pause())})),ht.call(t,t.media,"progress playing seeking seeked",(e=>Bt.updateProgress.call(t,e))),ht.call(t,t.media,"volumechange",(e=>Bt.updateVolume.call(t,e))),ht.call(t,t.media,"playing play pause ended emptied timeupdate",(e=>Qt.checkPlaying.call(t,e))),ht.call(t,t.media,"waiting canplay seeked playing",(e=>Qt.checkLoading.call(t,e))),t.supported.ui&&t.config.clickToPlay&&!t.isAudio){const i=at.call(t,`.${t.config.classNames.video}`);if(!M(i))return;ht.call(t,e.container,"click",(s=>{([e.container,i].includes(s.target)||i.contains(s.target))&&(t.touch&&t.config.hideControls||(t.ended?(this.proxy(s,t.restart,"restart"),this.proxy(s,(()=>{vt(t.play())}),"play")):this.proxy(s,(()=>{vt(t.togglePlay())}),"play")))}))}t.supported.ui&&t.config.disableContextMenu&&ht.call(t,e.wrapper,"contextmenu",(t=>{t.preventDefault()}),!1),ht.call(t,t.media,"volumechange",(()=>{t.storage.set({volume:t.volume,muted:t.muted})})),ht.call(t,t.media,"ratechange",(()=>{Bt.updateSetting.call(t,"speed"),t.storage.set({speed:t.speed})})),ht.call(t,t.media,"qualitychange",(e=>{Bt.updateSetting.call(t,"quality",null,e.detail.quality)})),ht.call(t,t.media,"ready qualitychange",(()=>{Bt.setDownloadUrl.call(t)}));const i=t.config.events.concat(["keyup","keydown"]).join(" ");ht.call(t,t.media,i,(i=>{let{detail:s={}}=i;"error"===i.type&&(s=t.media.error),gt.call(t,e.container,i.type,!0,s)}))})),t(this,"proxy",((t,e,i)=>{const{player:s}=this,n=s.config.listeners[i];let r=!0;P(n)&&(r=n.call(s,t)),!1!==r&&P(e)&&e.call(s,t)})),t(this,"bind",((t,e,i,s,n=!0)=>{const{player:r}=this,a=r.config.listeners[s],o=P(a);ht.call(r,t,e,(t=>this.proxy(t,i,s)),n&&!o)})),t(this,"controls",(()=>{const{player:t}=this,{elements:e}=t,i=H.isIE?"change":"input";if(e.buttons.play&&Array.from(e.buttons.play).forEach((e=>{this.bind(e,"click",(()=>{vt(t.togglePlay())}),"play")})),this.bind(e.buttons.restart,"click",t.restart,"restart"),this.bind(e.buttons.rewind,"click",(()=>{t.lastSeekTime=Date.now(),t.rewind()}),"rewind"),this.bind(e.buttons.fastForward,"click",(()=>{t.lastSeekTime=Date.now(),t.forward()}),"fastForward"),this.bind(e.buttons.mute,"click",(()=>{t.muted=!t.muted}),"mute"),this.bind(e.buttons.captions,"click",(()=>t.toggleCaptions())),this.bind(e.buttons.download,"click",(()=>{gt.call(t,t.media,"download")}),"download"),this.bind(e.buttons.fullscreen,"click",(()=>{t.fullscreen.toggle()}),"fullscreen"),this.bind(e.buttons.pip,"click",(()=>{t.pip="toggle"}),"pip"),this.bind(e.buttons.airplay,"click",t.airplay,"airplay"),this.bind(e.buttons.settings,"click",(e=>{e.stopPropagation(),e.preventDefault(),Bt.toggleMenu.call(t,e)}),null,!1),this.bind(e.buttons.settings,"keyup",(e=>{["Space","Enter"].includes(e.key)&&("Enter"!==e.key?(e.preventDefault(),e.stopPropagation(),Bt.toggleMenu.call(t,e)):Bt.focusFirstMenuItem.call(t,null,!0))}),null,!1),this.bind(e.settings.menu,"keydown",(e=>{"Escape"===e.key&&Bt.toggleMenu.call(t,e)})),this.bind(e.inputs.seek,"mousedown mousemove",(t=>{const i=e.progress.getBoundingClientRect(),s=100/i.width*(t.pageX-i.left);t.currentTarget.setAttribute("seek-value",s)})),this.bind(e.inputs.seek,"mousedown mouseup keydown keyup touchstart touchend",(e=>{const i=e.currentTarget,s="play-on-seeked";if($(e)&&!["ArrowLeft","ArrowRight"].includes(e.key))return;t.lastSeekTime=Date.now();const n=i.hasAttribute(s),r=["mouseup","touchend","keyup"].includes(e.type);n&&r?(i.removeAttribute(s),vt(t.play())):!r&&t.playing&&(i.setAttribute(s,""),t.pause())})),H.isIos){const e=rt.call(t,'input[type="range"]');Array.from(e).forEach((t=>this.bind(t,i,(t=>V(t.target)))))}this.bind(e.inputs.seek,i,(e=>{const i=e.currentTarget;let s=i.getAttribute("seek-value");j(s)&&(s=i.value),i.removeAttribute("seek-value"),t.currentTime=s/i.max*t.duration}),"seek"),this.bind(e.progress,"mouseenter mouseleave mousemove",(e=>Bt.updateSeekTooltip.call(t,e))),this.bind(e.progress,"mousemove touchmove",(e=>{const{previewThumbnails:i}=t;i&&i.loaded&&i.startMove(e)})),this.bind(e.progress,"mouseleave touchend click",(()=>{const{previewThumbnails:e}=t;e&&e.loaded&&e.endMove(!1,!0)})),this.bind(e.progress,"mousedown touchstart",(e=>{const{previewThumbnails:i}=t;i&&i.loaded&&i.startScrubbing(e)})),this.bind(e.progress,"mouseup touchend",(e=>{const{previewThumbnails:i}=t;i&&i.loaded&&i.endScrubbing(e)})),H.isWebkit&&Array.from(rt.call(t,'input[type="range"]')).forEach((e=>{this.bind(e,"input",(e=>Bt.updateRangeFill.call(t,e.target)))})),t.config.toggleInvert&&!M(e.display.duration)&&this.bind(e.display.currentTime,"click",(()=>{0!==t.currentTime&&(t.config.invertTime=!t.config.invertTime,Bt.timeUpdate.call(t))})),this.bind(e.inputs.volume,i,(e=>{t.volume=e.target.value}),"volume"),this.bind(e.controls,"mouseenter mouseleave",(i=>{e.controls.hover=!t.touch&&"mouseenter"===i.type})),e.fullscreen&&Array.from(e.fullscreen.children).filter((t=>!t.contains(e.container))).forEach((i=>{this.bind(i,"mouseenter mouseleave",(i=>{e.controls&&(e.controls.hover=!t.touch&&"mouseenter"===i.type)}))})),this.bind(e.controls,"mousedown mouseup touchstart touchend touchcancel",(t=>{e.controls.pressed=["mousedown","touchstart"].includes(t.type)})),this.bind(e.controls,"focusin",(()=>{const{config:i,timers:s}=t;it(e.controls,i.classNames.noTransition,!0),Qt.toggleControls.call(t,!0),setTimeout((()=>{it(e.controls,i.classNames.noTransition,!1)}),0);const n=this.touch?3e3:4e3;clearTimeout(s.controls),s.controls=setTimeout((()=>Qt.toggleControls.call(t,!1)),n)})),this.bind(e.inputs.volume,"wheel",(e=>{const i=e.webkitDirectionInvertedFromDevice,[s,n]=[e.deltaX,-e.deltaY].map((t=>i?-t:t)),r=Math.sign(Math.abs(s)>Math.abs(n)?s:n);t.increaseVolume(r/50);const{volume:a}=t.media;(1===r&&a<1||-1===r&&a>0)&&e.preventDefault()}),"volume",!1)})),this.player=e,this.lastKey=null,this.focusTimer=null,this.lastKeyDown=null,this.handleKey=this.handleKey.bind(this),this.toggleMenu=this.toggleMenu.bind(this),this.setTabFocus=this.setTabFocus.bind(this),this.firstTouch=this.firstTouch.bind(this)}handleKey(t){const{player:e}=this,{elements:i}=e,{key:s,type:n,altKey:r,ctrlKey:a,metaKey:o,shiftKey:l}=t,c="keydown"===n,u=c&&s===this.lastKey;var d;if(!(r||a||o||l)&&s)if(c){const n=document.activeElement;if(M(n)){const{editable:s}=e.config.selectors,{seek:r}=i.inputs;if(n!==r&&nt(n,s))return;if("Space"===t.key&&nt(n,'button, [role^="menuitem"]'))return}switch(["Space","ArrowLeft","ArrowUp","ArrowRight","ArrowDown","0","1","2","3","4","5","6","7","8","9","c","f","k","l","m"].includes(s)&&(t.preventDefault(),t.stopPropagation()),s){case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":u||(d=parseInt(s,10),e.currentTime=e.duration/10*d);break;case"Space":case"k":u||vt(e.togglePlay());break;case"ArrowUp":e.increaseVolume(.1);break;case"ArrowDown":e.decreaseVolume(.1);break;case"m":u||(e.muted=!e.muted);break;case"ArrowRight":e.forward();break;case"ArrowLeft":e.rewind();break;case"f":e.fullscreen.toggle();break;case"c":u||e.toggleCaptions();break;case"l":e.loop=!e.loop}"Escape"===s&&!e.fullscreen.usingNative&&e.fullscreen.active&&e.fullscreen.toggle(),this.lastKey=s}else this.lastKey=null}toggleMenu(t){Bt.toggleMenu.call(this.player,t)}}"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:void 0!==i.g?i.g:"undefined"!=typeof self&&self;var te=function(t,e){return function(t,e){t.exports=function(){var t=function(){},e={},i={},s={};function n(t,e){t=t.push?t:[t];var n,r,a,o=[],l=t.length,c=l;for(n=function(t,i){i.length&&o.push(t),--c||e(o)};l--;)r=t[l],(a=i[r])?n(r,a):(s[r]=s[r]||[]).push(n)}function r(t,e){if(t){var n=s[t];if(i[t]=e,n)for(;n.length;)n[0](t,e),n.splice(0,1)}}function a(e,i){e.call&&(e={success:e}),i.length?(e.error||t)(i):(e.success||t)(e)}function o(e,i,s,n){var r,a,l=document,c=s.async,u=(s.numRetries||0)+1,d=s.before||t,h=e.replace(/[\?|#].*$/,""),f=e.replace(/^(css|img)!/,"");n=n||0,/(^css!|\.css$)/.test(h)?((a=l.createElement("link")).rel="stylesheet",a.href=f,(r="hideFocus"in a)&&a.relList&&(r=0,a.rel="preload",a.as="style")):/(^img!|\.(png|gif|jpg|svg|webp)$)/.test(h)?(a=l.createElement("img")).src=f:((a=l.createElement("script")).src=e,a.async=void 0===c||c),a.onload=a.onerror=a.onbeforeload=function(t){var l=t.type[0];if(r)try{a.sheet.cssText.length||(l="e")}catch(t){18!=t.code&&(l="e")}if("e"==l){if((n+=1){te(t,{success:e,error:i})}))}function ie(t){t&&!this.embed.hasPlayed&&(this.embed.hasPlayed=!0),this.media.paused===t&&(this.media.paused=!t,gt.call(this,this.media,t?"play":"pause"))}const se={setup(){const t=this;it(t.elements.wrapper,t.config.classNames.embed,!0),t.options.speed=t.config.speed.options,At.call(t),I(window.Vimeo)?se.ready.call(t):ee(t.config.urls.vimeo.sdk).then((()=>{se.ready.call(t)})).catch((e=>{t.debug.warn("Vimeo SDK (player.js) failed to load",e)}))},ready(){const t=this,e=t.config.vimeo,{premium:i,referrerPolicy:s,...n}=e;let r=t.media.getAttribute("src"),a="";j(r)?(r=t.media.getAttribute(t.config.attributes.embed.id),a=t.media.getAttribute(t.config.attributes.embed.hash)):a=function(t){const e=t.match(/^.*(vimeo.com\/|video\/)(\d+)(\?.*&*h=|\/)+([\d,a-f]+)/);return e&&5===e.length?e[4]:null}(r);const o=a?{h:a}:{};i&&Object.assign(n,{controls:!1,sidedock:!1});const l=Gt({loop:t.config.loop.active,autoplay:t.autoplay,muted:t.muted,gesture:"media",playsinline:!this.config.fullscreen.iosNative,...o,...n}),c=j(u=r)?null:C(Number(u))?u:u.match(/^.*(vimeo.com\/|video\/)(\d+).*/)?RegExp.$2:u;var u;const d=W("iframe"),h=It(t.config.urls.vimeo.iframe,c,l);if(d.setAttribute("src",h),d.setAttribute("allowfullscreen",""),d.setAttribute("allow",["autoplay","fullscreen","picture-in-picture","encrypted-media","accelerometer","gyroscope"].join("; ")),j(s)||d.setAttribute("referrerPolicy",s),i||!e.customControls)d.setAttribute("data-poster",t.poster),t.media=Z(d,t.media);else{const e=W("div",{class:t.config.classNames.embedContainer,"data-poster":t.poster});e.appendChild(d),t.media=Z(e,t.media)}e.customControls||Mt(It(t.config.urls.vimeo.api,h)).then((e=>{!j(e)&&e.thumbnail_url&&Qt.setPoster.call(t,e.thumbnail_url).catch((()=>{}))})),t.embed=new window.Vimeo.Player(d,{autopause:t.config.autopause,muted:t.muted}),t.media.paused=!0,t.media.currentTime=0,t.supported.ui&&t.embed.disableTextTrack(),t.media.play=()=>(ie.call(t,!0),t.embed.play()),t.media.pause=()=>(ie.call(t,!1),t.embed.pause()),t.media.stop=()=>{t.pause(),t.currentTime=0};let{currentTime:f}=t.media;Object.defineProperty(t.media,"currentTime",{get:()=>f,set(e){const{embed:i,media:s,paused:n,volume:r}=t,a=n&&!i.hasPlayed;s.seeking=!0,gt.call(t,s,"seeking"),Promise.resolve(a&&i.setVolume(0)).then((()=>i.setCurrentTime(e))).then((()=>a&&i.pause())).then((()=>a&&i.setVolume(r))).catch((()=>{}))}});let p=t.config.speed.selected;Object.defineProperty(t.media,"playbackRate",{get:()=>p,set(e){t.embed.setPlaybackRate(e).then((()=>{p=e,gt.call(t,t.media,"ratechange")})).catch((()=>{t.options.speed=[1]}))}});let{volume:g}=t.config;Object.defineProperty(t.media,"volume",{get:()=>g,set(e){t.embed.setVolume(e).then((()=>{g=e,gt.call(t,t.media,"volumechange")}))}});let{muted:m}=t.config;Object.defineProperty(t.media,"muted",{get:()=>m,set(e){const i=!!x(e)&&e;t.embed.setVolume(i?0:t.config.volume).then((()=>{m=i,gt.call(t,t.media,"volumechange")}))}});let y,{loop:v}=t.config;Object.defineProperty(t.media,"loop",{get:()=>v,set(e){const i=x(e)?e:t.config.loop.active;t.embed.setLoop(i).then((()=>{v=i}))}}),t.embed.getVideoUrl().then((e=>{y=e,Bt.setDownloadUrl.call(t)})).catch((t=>{this.debug.warn(t)})),Object.defineProperty(t.media,"currentSrc",{get:()=>y}),Object.defineProperty(t.media,"ended",{get:()=>t.currentTime===t.duration}),Promise.all([t.embed.getVideoWidth(),t.embed.getVideoHeight()]).then((e=>{const[i,s]=e;t.embed.ratio=Rt(i,s),At.call(this)})),t.embed.setAutopause(t.config.autopause).then((e=>{t.config.autopause=e})),t.embed.getVideoTitle().then((e=>{t.config.title=e,Qt.setTitle.call(this)})),t.embed.getCurrentTime().then((e=>{f=e,gt.call(t,t.media,"timeupdate")})),t.embed.getDuration().then((e=>{t.media.duration=e,gt.call(t,t.media,"durationchange")})),t.embed.getTextTracks().then((e=>{t.media.textTracks=e,Vt.setup.call(t)})),t.embed.on("cuechange",(({cues:e=[]})=>{const i=e.map((t=>function(t){const e=document.createDocumentFragment(),i=document.createElement("div");return e.appendChild(i),i.innerHTML=t,e.firstChild.innerText}(t.text)));Vt.updateCues.call(t,i)})),t.embed.on("loaded",(()=>{t.embed.getPaused().then((e=>{ie.call(t,!e),e||gt.call(t,t.media,"playing")})),M(t.embed.element)&&t.supported.ui&&t.embed.element.setAttribute("tabindex",-1)})),t.embed.on("bufferstart",(()=>{gt.call(t,t.media,"waiting")})),t.embed.on("bufferend",(()=>{gt.call(t,t.media,"playing")})),t.embed.on("play",(()=>{ie.call(t,!0),gt.call(t,t.media,"playing")})),t.embed.on("pause",(()=>{ie.call(t,!1)})),t.embed.on("timeupdate",(e=>{t.media.seeking=!1,f=e.seconds,gt.call(t,t.media,"timeupdate")})),t.embed.on("progress",(e=>{t.media.buffered=e.percent,gt.call(t,t.media,"progress"),1===parseInt(e.percent,10)&>.call(t,t.media,"canplaythrough"),t.embed.getDuration().then((e=>{e!==t.media.duration&&(t.media.duration=e,gt.call(t,t.media,"durationchange"))}))})),t.embed.on("seeked",(()=>{t.media.seeking=!1,gt.call(t,t.media,"seeked")})),t.embed.on("ended",(()=>{t.media.paused=!0,gt.call(t,t.media,"ended")})),t.embed.on("error",(e=>{t.media.error=e,gt.call(t,t.media,"error")})),e.customControls&&setTimeout((()=>Qt.build.call(t)),0)}};function ne(t){t&&!this.embed.hasPlayed&&(this.embed.hasPlayed=!0),this.media.paused===t&&(this.media.paused=!t,gt.call(this,this.media,t?"play":"pause"))}function re(t){return t.noCookie?"https://www.youtube-nocookie.com":"http:"===window.location.protocol?"http://www.youtube.com":void 0}const ae={setup(){if(it(this.elements.wrapper,this.config.classNames.embed,!0),I(window.YT)&&P(window.YT.Player))ae.ready.call(this);else{const t=window.onYouTubeIframeAPIReady;window.onYouTubeIframeAPIReady=()=>{P(t)&&t(),ae.ready.call(this)},ee(this.config.urls.youtube.sdk).catch((t=>{this.debug.warn("YouTube API failed to load",t)}))}},getTitle(t){Mt(It(this.config.urls.youtube.api,t)).then((t=>{if(I(t)){const{title:e,height:i,width:s}=t;this.config.title=e,Qt.setTitle.call(this),this.embed.ratio=Rt(s,i)}At.call(this)})).catch((()=>{At.call(this)}))},ready(){const t=this,e=t.config.youtube,i=t.media&&t.media.getAttribute("id");if(!j(i)&&i.startsWith("youtube-"))return;let s=t.media.getAttribute("src");j(s)&&(s=t.media.getAttribute(this.config.attributes.embed.id));const n=j(r=s)?null:r.match(/^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|&v=)([^#&?]*).*/)?RegExp.$2:r;var r;const a=W("div",{id:`${t.provider}-${Math.floor(1e4*Math.random())}`,"data-poster":e.customControls?t.poster:void 0});if(t.media=Z(a,t.media),e.customControls){const e=t=>`https://i.ytimg.com/vi/${n}/${t}default.jpg`;Jt(e("maxres"),121).catch((()=>Jt(e("sd"),121))).catch((()=>Jt(e("hq")))).then((e=>Qt.setPoster.call(t,e.src))).then((e=>{e.includes("maxres")||(t.elements.poster.style.backgroundSize="cover")})).catch((()=>{}))}t.embed=new window.YT.Player(t.media,{videoId:n,host:re(e),playerVars:Y({},{autoplay:t.config.autoplay?1:0,hl:t.config.hl,controls:t.supported.ui&&e.customControls?0:1,disablekb:1,playsinline:t.config.fullscreen.iosNative?0:1,cc_load_policy:t.captions.active?1:0,cc_lang_pref:t.config.captions.language,widget_referrer:window?window.location.href:null},e),events:{onError(e){if(!t.media.error){const i=e.data,s={2:"The request contains an invalid parameter value. For example, this error occurs if you specify a video ID that does not have 11 characters, or if the video ID contains invalid characters, such as exclamation points or asterisks.",5:"The requested content cannot be played in an HTML5 player or another error related to the HTML5 player has occurred.",100:"The video requested was not found. This error occurs when a video has been removed (for any reason) or has been marked as private.",101:"The owner of the requested video does not allow it to be played in embedded players.",150:"The owner of the requested video does not allow it to be played in embedded players."}[i]||"An unknown error occured";t.media.error={code:i,message:s},gt.call(t,t.media,"error")}},onPlaybackRateChange(e){const i=e.target;t.media.playbackRate=i.getPlaybackRate(),gt.call(t,t.media,"ratechange")},onReady(i){if(P(t.media.play))return;const s=i.target;ae.getTitle.call(t,n),t.media.play=()=>{ne.call(t,!0),s.playVideo()},t.media.pause=()=>{ne.call(t,!1),s.pauseVideo()},t.media.stop=()=>{s.stopVideo()},t.media.duration=s.getDuration(),t.media.paused=!0,t.media.currentTime=0,Object.defineProperty(t.media,"currentTime",{get:()=>Number(s.getCurrentTime()),set(e){t.paused&&!t.embed.hasPlayed&&t.embed.mute(),t.media.seeking=!0,gt.call(t,t.media,"seeking"),s.seekTo(e)}}),Object.defineProperty(t.media,"playbackRate",{get:()=>s.getPlaybackRate(),set(t){s.setPlaybackRate(t)}});let{volume:r}=t.config;Object.defineProperty(t.media,"volume",{get:()=>r,set(e){r=e,s.setVolume(100*r),gt.call(t,t.media,"volumechange")}});let{muted:a}=t.config;Object.defineProperty(t.media,"muted",{get:()=>a,set(e){const i=x(e)?e:a;a=i,s[i?"mute":"unMute"](),s.setVolume(100*r),gt.call(t,t.media,"volumechange")}}),Object.defineProperty(t.media,"currentSrc",{get:()=>s.getVideoUrl()}),Object.defineProperty(t.media,"ended",{get:()=>t.currentTime===t.duration});const o=s.getAvailablePlaybackRates();t.options.speed=o.filter((e=>t.config.speed.options.includes(e))),t.supported.ui&&e.customControls&&t.media.setAttribute("tabindex",-1),gt.call(t,t.media,"timeupdate"),gt.call(t,t.media,"durationchange"),clearInterval(t.timers.buffering),t.timers.buffering=setInterval((()=>{t.media.buffered=s.getVideoLoadedFraction(),(null===t.media.lastBuffered||t.media.lastBufferedQt.build.call(t)),50)},onStateChange(i){const s=i.target;switch(clearInterval(t.timers.playing),t.media.seeking&&[1,2].includes(i.data)&&(t.media.seeking=!1,gt.call(t,t.media,"seeked")),i.data){case-1:gt.call(t,t.media,"timeupdate"),t.media.buffered=s.getVideoLoadedFraction(),gt.call(t,t.media,"progress");break;case 0:ne.call(t,!1),t.media.loop?(s.stopVideo(),s.playVideo()):gt.call(t,t.media,"ended");break;case 1:e.customControls&&!t.config.autoplay&&t.media.paused&&!t.embed.hasPlayed?t.media.pause():(ne.call(t,!0),gt.call(t,t.media,"playing"),t.timers.playing=setInterval((()=>{gt.call(t,t.media,"timeupdate")}),50),t.media.duration!==s.getDuration()&&(t.media.duration=s.getDuration(),gt.call(t,t.media,"durationchange")));break;case 2:t.muted||t.embed.unMute(),ne.call(t,!1);break;case 3:gt.call(t,t.media,"waiting")}gt.call(t,t.elements.container,"statechange",!1,{code:i.data})}}})}},oe={setup(){this.media?(it(this.elements.container,this.config.classNames.type.replace("{0}",this.type),!0),it(this.elements.container,this.config.classNames.provider.replace("{0}",this.provider),!0),this.isEmbed&&it(this.elements.container,this.config.classNames.type.replace("{0}","video"),!0),this.isVideo&&(this.elements.wrapper=W("div",{class:this.config.classNames.video}),q(this.media,this.elements.wrapper),this.elements.poster=W("div",{class:this.config.classNames.poster}),this.elements.wrapper.appendChild(this.elements.poster)),this.isHTML5?Lt.setup.call(this):this.isYouTube?ae.setup.call(this):this.isVimeo&&se.setup.call(this)):this.debug.warn("No media element found!")}};class le{constructor(e){t(this,"load",(()=>{this.enabled&&(I(window.google)&&I(window.google.ima)?this.ready():ee(this.player.config.urls.googleIMA.sdk).then((()=>{this.ready()})).catch((()=>{this.trigger("error",new Error("Google IMA SDK failed to load"))})))})),t(this,"ready",(()=>{var t;this.enabled||((t=this).manager&&t.manager.destroy(),t.elements.displayContainer&&t.elements.displayContainer.destroy(),t.elements.container.remove()),this.startSafetyTimer(12e3,"ready()"),this.managerPromise.then((()=>{this.clearSafetyTimer("onAdsManagerLoaded()")})),this.listeners(),this.setupIMA()})),t(this,"setupIMA",(()=>{this.elements.container=W("div",{class:this.player.config.classNames.ads}),this.player.elements.container.appendChild(this.elements.container),google.ima.settings.setVpaidMode(google.ima.ImaSdkSettings.VpaidMode.ENABLED),google.ima.settings.setLocale(this.player.config.ads.language),google.ima.settings.setDisableCustomPlaybackForIOS10Plus(this.player.config.playsinline),this.elements.displayContainer=new google.ima.AdDisplayContainer(this.elements.container,this.player.media),this.loader=new google.ima.AdsLoader(this.elements.displayContainer),this.loader.addEventListener(google.ima.AdsManagerLoadedEvent.Type.ADS_MANAGER_LOADED,(t=>this.onAdsManagerLoaded(t)),!1),this.loader.addEventListener(google.ima.AdErrorEvent.Type.AD_ERROR,(t=>this.onAdError(t)),!1),this.requestAds()})),t(this,"requestAds",(()=>{const{container:t}=this.player.elements;try{const e=new google.ima.AdsRequest;e.adTagUrl=this.tagUrl,e.linearAdSlotWidth=t.offsetWidth,e.linearAdSlotHeight=t.offsetHeight,e.nonLinearAdSlotWidth=t.offsetWidth,e.nonLinearAdSlotHeight=t.offsetHeight,e.forceNonLinearFullSlot=!1,e.setAdWillPlayMuted(!this.player.muted),this.loader.requestAds(e)}catch(t){this.onAdError(t)}})),t(this,"pollCountdown",((t=!1)=>{if(!t)return clearInterval(this.countdownTimer),void this.elements.container.removeAttribute("data-badge-text");this.countdownTimer=setInterval((()=>{const t=Ut(Math.max(this.manager.getRemainingTime(),0)),e=`${Ot.get("advertisement",this.player.config)} - ${t}`;this.elements.container.setAttribute("data-badge-text",e)}),100)})),t(this,"onAdsManagerLoaded",(t=>{if(!this.enabled)return;const e=new google.ima.AdsRenderingSettings;e.restoreCustomPlaybackStateOnAdBreakComplete=!0,e.enablePreloading=!0,this.manager=t.getAdsManager(this.player,e),this.cuePoints=this.manager.getCuePoints(),this.manager.addEventListener(google.ima.AdErrorEvent.Type.AD_ERROR,(t=>this.onAdError(t))),Object.keys(google.ima.AdEvent.Type).forEach((t=>{this.manager.addEventListener(google.ima.AdEvent.Type[t],(t=>this.onAdEvent(t)))})),this.trigger("loaded")})),t(this,"addCuePoints",(()=>{j(this.cuePoints)||this.cuePoints.forEach((t=>{if(0!==t&&-1!==t&&t{const{container:e}=this.player.elements,i=t.getAd(),s=t.getAdData();switch((t=>{gt.call(this.player,this.player.media,`ads${t.replace(/_/g,"").toLowerCase()}`)})(t.type),t.type){case google.ima.AdEvent.Type.LOADED:this.trigger("loaded"),this.pollCountdown(!0),i.isLinear()||(i.width=e.offsetWidth,i.height=e.offsetHeight);break;case google.ima.AdEvent.Type.STARTED:this.manager.setVolume(this.player.volume);break;case google.ima.AdEvent.Type.ALL_ADS_COMPLETED:this.player.ended?this.loadAds():this.loader.contentComplete();break;case google.ima.AdEvent.Type.CONTENT_PAUSE_REQUESTED:this.pauseContent();break;case google.ima.AdEvent.Type.CONTENT_RESUME_REQUESTED:this.pollCountdown(),this.resumeContent();break;case google.ima.AdEvent.Type.LOG:s.adError&&this.player.debug.warn(`Non-fatal ad error: ${s.adError.getMessage()}`)}})),t(this,"onAdError",(t=>{this.cancel(),this.player.debug.warn("Ads error",t)})),t(this,"listeners",(()=>{const{container:t}=this.player.elements;let e;this.player.on("canplay",(()=>{this.addCuePoints()})),this.player.on("ended",(()=>{this.loader.contentComplete()})),this.player.on("timeupdate",(()=>{e=this.player.currentTime})),this.player.on("seeked",(()=>{const t=this.player.currentTime;j(this.cuePoints)||this.cuePoints.forEach(((i,s)=>{e{this.manager&&this.manager.resize(t.offsetWidth,t.offsetHeight,google.ima.ViewMode.NORMAL)}))})),t(this,"play",(()=>{const{container:t}=this.player.elements;this.managerPromise||this.resumeContent(),this.managerPromise.then((()=>{this.manager.setVolume(this.player.volume),this.elements.displayContainer.initialize();try{this.initialized||(this.manager.init(t.offsetWidth,t.offsetHeight,google.ima.ViewMode.NORMAL),this.manager.start()),this.initialized=!0}catch(t){this.onAdError(t)}})).catch((()=>{}))})),t(this,"resumeContent",(()=>{this.elements.container.style.zIndex="",this.playing=!1,vt(this.player.media.play())})),t(this,"pauseContent",(()=>{this.elements.container.style.zIndex=3,this.playing=!0,this.player.media.pause()})),t(this,"cancel",(()=>{this.initialized&&this.resumeContent(),this.trigger("error"),this.loadAds()})),t(this,"loadAds",(()=>{this.managerPromise.then((()=>{this.manager&&this.manager.destroy(),this.managerPromise=new Promise((t=>{this.on("loaded",t),this.player.debug.log(this.manager)})),this.initialized=!1,this.requestAds()})).catch((()=>{}))})),t(this,"trigger",((t,...e)=>{const i=this.events[t];O(i)&&i.forEach((t=>{P(t)&&t.apply(this,e)}))})),t(this,"on",((t,e)=>(O(this.events[t])||(this.events[t]=[]),this.events[t].push(e),this))),t(this,"startSafetyTimer",((t,e)=>{this.player.debug.log(`Safety timer invoked from: ${e}`),this.safetyTimer=setTimeout((()=>{this.cancel(),this.clearSafetyTimer("startSafetyTimer()")}),t)})),t(this,"clearSafetyTimer",(t=>{L(this.safetyTimer)||(this.player.debug.log(`Safety timer cleared from: ${t}`),clearTimeout(this.safetyTimer),this.safetyTimer=null)})),this.player=e,this.config=e.config.ads,this.playing=!1,this.initialized=!1,this.elements={container:null,displayContainer:null},this.manager=null,this.loader=null,this.cuePoints=null,this.events={},this.safetyTimer=null,this.countdownTimer=null,this.managerPromise=new Promise(((t,e)=>{this.on("loaded",t),this.on("error",e)})),this.load()}get enabled(){const{config:t}=this;return this.player.isHTML5&&this.player.isVideo&&t.enabled&&(!j(t.publisherId)||B(t.tagUrl))}get tagUrl(){const{config:t}=this;return B(t.tagUrl)?t.tagUrl:`https://go.aniview.com/api/adserver6/vast/?${Gt({AV_PUBLISHERID:"58c25bb0073ef448b1087ad6",AV_CHANNELID:"5a0458dc28a06145e4519d21",AV_URL:window.location.hostname,cb:Date.now(),AV_WIDTH:640,AV_HEIGHT:480,AV_CDIM2:t.publisherId})}`}}function ce(t=0,e=0,i=255){return Math.min(Math.max(t,e),i)}const ue=t=>{const e=[];return t.split(/\r\n\r\n|\n\n|\r\r/).forEach((t=>{const i={};t.split(/\r\n|\n|\r/).forEach((t=>{if(C(i.startTime)){if(!j(t.trim())&&j(i.text)){const e=t.trim().split("#xywh=");[i.text]=e,e[1]&&([i.x,i.y,i.w,i.h]=e[1].split(","))}}else{const e=t.match(/([0-9]{2})?:?([0-9]{2}):([0-9]{2}).([0-9]{2,3})( ?--> ?)([0-9]{2})?:?([0-9]{2}):([0-9]{2}).([0-9]{2,3})/);e&&(i.startTime=60*Number(e[1]||0)*60+60*Number(e[2])+Number(e[3])+Number(`0.${e[4]}`),i.endTime=60*Number(e[6]||0)*60+60*Number(e[7])+Number(e[8])+Number(`0.${e[9]}`))}})),i.text&&e.push(i)})),e},de=(t,e)=>{const i={};return t>e.width/e.height?(i.width=e.width,i.height=1/t*e.width):(i.height=e.height,i.width=t*e.height),i};class he{constructor(e){t(this,"load",(()=>{this.player.elements.display.seekTooltip&&(this.player.elements.display.seekTooltip.hidden=this.enabled),this.enabled&&this.getThumbnails().then((()=>{this.enabled&&(this.render(),this.determineContainerAutoSizing(),this.loaded=!0)}))})),t(this,"getThumbnails",(()=>new Promise((t=>{const{src:e}=this.player.config.previewThumbnails;if(j(e))throw new Error("Missing previewThumbnails.src config attribute");const i=()=>{this.thumbnails.sort(((t,e)=>t.height-e.height)),this.player.debug.log("Preview thumbnails",this.thumbnails),t()};if(P(e))e((t=>{this.thumbnails=t,i()}));else{const t=(D(e)?[e]:e).map((t=>this.getThumbnail(t)));Promise.all(t).then(i)}})))),t(this,"getThumbnail",(t=>new Promise((e=>{Mt(t).then((i=>{const s={frames:ue(i),height:null,urlPrefix:""};s.frames[0].text.startsWith("/")||s.frames[0].text.startsWith("http://")||s.frames[0].text.startsWith("https://")||(s.urlPrefix=t.substring(0,t.lastIndexOf("/")+1));const n=new Image;n.onload=()=>{s.height=n.naturalHeight,s.width=n.naturalWidth,this.thumbnails.push(s),e()},n.src=s.urlPrefix+s.frames[0].text}))})))),t(this,"startMove",(t=>{if(this.loaded&&F(t)&&["touchmove","mousemove"].includes(t.type)&&this.player.media.duration){if("touchmove"===t.type)this.seekTime=this.player.media.duration*(this.player.elements.inputs.seek.value/100);else{var e,i;const s=this.player.elements.progress.getBoundingClientRect(),n=100/s.width*(t.pageX-s.left);this.seekTime=this.player.media.duration*(n/100),this.seekTime<0&&(this.seekTime=0),this.seekTime>this.player.media.duration-1&&(this.seekTime=this.player.media.duration-1),this.mousePosX=t.pageX,this.elements.thumb.time.innerText=Ut(this.seekTime);const r=null===(e=this.player.config.markers)||void 0===e||null===(i=e.points)||void 0===i?void 0:i.find((({time:t})=>t===Math.round(this.seekTime)));r&&this.elements.thumb.time.insertAdjacentHTML("afterbegin",`${r.label}
`)}this.showImageAtCurrentTime()}})),t(this,"endMove",(()=>{this.toggleThumbContainer(!1,!0)})),t(this,"startScrubbing",(t=>{(L(t.button)||!1===t.button||0===t.button)&&(this.mouseDown=!0,this.player.media.duration&&(this.toggleScrubbingContainer(!0),this.toggleThumbContainer(!1,!0),this.showImageAtCurrentTime()))})),t(this,"endScrubbing",(()=>{this.mouseDown=!1,Math.ceil(this.lastTime)===Math.ceil(this.player.media.currentTime)?this.toggleScrubbingContainer(!1):pt.call(this.player,this.player.media,"timeupdate",(()=>{this.mouseDown||this.toggleScrubbingContainer(!1)}))})),t(this,"listeners",(()=>{this.player.on("play",(()=>{this.toggleThumbContainer(!1,!0)})),this.player.on("seeked",(()=>{this.toggleThumbContainer(!1)})),this.player.on("timeupdate",(()=>{this.lastTime=this.player.media.currentTime}))})),t(this,"render",(()=>{this.elements.thumb.container=W("div",{class:this.player.config.classNames.previewThumbnails.thumbContainer}),this.elements.thumb.imageContainer=W("div",{class:this.player.config.classNames.previewThumbnails.imageContainer}),this.elements.thumb.container.appendChild(this.elements.thumb.imageContainer);const t=W("div",{class:this.player.config.classNames.previewThumbnails.timeContainer});this.elements.thumb.time=W("span",{},"00:00"),t.appendChild(this.elements.thumb.time),this.elements.thumb.imageContainer.appendChild(t),M(this.player.elements.progress)&&this.player.elements.progress.appendChild(this.elements.thumb.container),this.elements.scrubbing.container=W("div",{class:this.player.config.classNames.previewThumbnails.scrubbingContainer}),this.player.elements.wrapper.appendChild(this.elements.scrubbing.container)})),t(this,"destroy",(()=>{this.elements.thumb.container&&this.elements.thumb.container.remove(),this.elements.scrubbing.container&&this.elements.scrubbing.container.remove()})),t(this,"showImageAtCurrentTime",(()=>{this.mouseDown?this.setScrubbingContainerSize():this.setThumbContainerSizeAndPos();const t=this.thumbnails[0].frames.findIndex((t=>this.seekTime>=t.startTime&&this.seekTime<=t.endTime)),e=t>=0;let i=0;this.mouseDown||this.toggleThumbContainer(e),e&&(this.thumbnails.forEach(((e,s)=>{this.loadedImages.includes(e.frames[t].text)&&(i=s)})),t!==this.showingThumb&&(this.showingThumb=t,this.loadImage(i)))})),t(this,"loadImage",((t=0)=>{const e=this.showingThumb,i=this.thumbnails[t],{urlPrefix:s}=i,n=i.frames[e],r=i.frames[e].text,a=s+r;if(this.currentImageElement&&this.currentImageElement.dataset.filename===r)this.showImage(this.currentImageElement,n,t,e,r,!1),this.currentImageElement.dataset.index=e,this.removeOldImages(this.currentImageElement);else{this.loadingImage&&this.usingSprites&&(this.loadingImage.onload=null);const i=new Image;i.src=a,i.dataset.index=e,i.dataset.filename=r,this.showingThumbFilename=r,this.player.debug.log(`Loading image: ${a}`),i.onload=()=>this.showImage(i,n,t,e,r,!0),this.loadingImage=i,this.removeOldImages(i)}})),t(this,"showImage",((t,e,i,s,n,r=!0)=>{this.player.debug.log(`Showing thumb: ${n}. num: ${s}. qual: ${i}. newimg: ${r}`),this.setImageSizeAndOffset(t,e),r&&(this.currentImageContainer.appendChild(t),this.currentImageElement=t,this.loadedImages.includes(n)||this.loadedImages.push(n)),this.preloadNearby(s,!0).then(this.preloadNearby(s,!1)).then(this.getHigherQuality(i,t,e,n))})),t(this,"removeOldImages",(t=>{Array.from(this.currentImageContainer.children).forEach((e=>{if("img"!==e.tagName.toLowerCase())return;const i=this.usingSprites?500:1e3;if(e.dataset.index!==t.dataset.index&&!e.dataset.deleting){e.dataset.deleting=!0;const{currentImageContainer:t}=this;setTimeout((()=>{t.removeChild(e),this.player.debug.log(`Removing thumb: ${e.dataset.filename}`)}),i)}}))})),t(this,"preloadNearby",((t,e=!0)=>new Promise((i=>{setTimeout((()=>{const s=this.thumbnails[0].frames[t].text;if(this.showingThumbFilename===s){let n;n=e?this.thumbnails[0].frames.slice(t):this.thumbnails[0].frames.slice(0,t).reverse();let r=!1;n.forEach((t=>{const e=t.text;if(e!==s&&!this.loadedImages.includes(e)){r=!0,this.player.debug.log(`Preloading thumb filename: ${e}`);const{urlPrefix:t}=this.thumbnails[0],s=t+e,n=new Image;n.src=s,n.onload=()=>{this.player.debug.log(`Preloaded thumb filename: ${e}`),this.loadedImages.includes(e)||this.loadedImages.push(e),i()}}})),r||i()}}),300)})))),t(this,"getHigherQuality",((t,e,i,s)=>{if(t{this.showingThumbFilename===s&&(this.player.debug.log(`Showing higher quality thumb for: ${s}`),this.loadImage(t+1))}),300)}})),t(this,"toggleThumbContainer",((t=!1,e=!1)=>{const i=this.player.config.classNames.previewThumbnails.thumbContainerShown;this.elements.thumb.container.classList.toggle(i,t),!t&&e&&(this.showingThumb=null,this.showingThumbFilename=null)})),t(this,"toggleScrubbingContainer",((t=!1)=>{const e=this.player.config.classNames.previewThumbnails.scrubbingContainerShown;this.elements.scrubbing.container.classList.toggle(e,t),t||(this.showingThumb=null,this.showingThumbFilename=null)})),t(this,"determineContainerAutoSizing",(()=>{(this.elements.thumb.imageContainer.clientHeight>20||this.elements.thumb.imageContainer.clientWidth>20)&&(this.sizeSpecifiedInCSS=!0)})),t(this,"setThumbContainerSizeAndPos",(()=>{const{imageContainer:t}=this.elements.thumb;if(this.sizeSpecifiedInCSS){if(t.clientHeight>20&&t.clientWidth<20){const e=Math.floor(t.clientHeight*this.thumbAspectRatio);t.style.width=`${e}px`}else if(t.clientHeight<20&&t.clientWidth>20){const e=Math.floor(t.clientWidth/this.thumbAspectRatio);t.style.height=`${e}px`}}else{const e=Math.floor(this.thumbContainerHeight*this.thumbAspectRatio);t.style.height=`${this.thumbContainerHeight}px`,t.style.width=`${e}px`}this.setThumbContainerPos()})),t(this,"setThumbContainerPos",(()=>{const t=this.player.elements.progress.getBoundingClientRect(),e=this.player.elements.container.getBoundingClientRect(),{container:i}=this.elements.thumb,s=e.left-t.left+10,n=e.right-t.left-i.clientWidth-10,r=this.mousePosX-t.left-i.clientWidth/2,a=ce(r,s,n);i.style.left=`${a}px`,i.style.setProperty("--preview-arrow-offset",r-a+"px")})),t(this,"setScrubbingContainerSize",(()=>{const{width:t,height:e}=de(this.thumbAspectRatio,{width:this.player.media.clientWidth,height:this.player.media.clientHeight});this.elements.scrubbing.container.style.width=`${t}px`,this.elements.scrubbing.container.style.height=`${e}px`})),t(this,"setImageSizeAndOffset",((t,e)=>{if(!this.usingSprites)return;const i=this.thumbContainerHeight/e.h;t.style.height=t.naturalHeight*i+"px",t.style.width=t.naturalWidth*i+"px",t.style.left=`-${e.x*i}px`,t.style.top=`-${e.y*i}px`})),this.player=e,this.thumbnails=[],this.loaded=!1,this.lastMouseMoveTime=Date.now(),this.mouseDown=!1,this.loadedImages=[],this.elements={thumb:{},scrubbing:{}},this.load()}get enabled(){return this.player.isHTML5&&this.player.isVideo&&this.player.config.previewThumbnails.enabled}get currentImageContainer(){return this.mouseDown?this.elements.scrubbing.container:this.elements.thumb.imageContainer}get usingSprites(){return Object.keys(this.thumbnails[0].frames[0]).includes("w")}get thumbAspectRatio(){return this.usingSprites?this.thumbnails[0].frames[0].w/this.thumbnails[0].frames[0].h:this.thumbnails[0].width/this.thumbnails[0].height}get thumbContainerHeight(){if(this.mouseDown){const{height:t}=de(this.thumbAspectRatio,{width:this.player.media.clientWidth,height:this.player.media.clientHeight});return t}return this.sizeSpecifiedInCSS?this.elements.thumb.imageContainer.clientHeight:Math.floor(this.player.media.clientWidth/this.thumbAspectRatio/4)}get currentImageElement(){return this.mouseDown?this.currentScrubbingImageElement:this.currentThumbnailImageElement}set currentImageElement(t){this.mouseDown?this.currentScrubbingImageElement=t:this.currentThumbnailImageElement=t}}const fe={insertElements(t,e){D(e)?X(t,this.media,{src:e}):O(e)&&e.forEach((e=>{X(t,this.media,e)}))},change(t){K(t,"sources.length")?(Lt.cancelRequests.call(this),this.destroy.call(this,(()=>{this.options.quality=[],J(this.media),this.media=null,M(this.elements.container)&&this.elements.container.removeAttribute("class");const{sources:e,type:i}=t,[{provider:s=Yt.html5,src:n}]=e,r="html5"===s?i:"div",a="html5"===s?{}:{src:n};Object.assign(this,{provider:s,type:i,supported:ct.check(i,s,this.config.playsinline),media:W(r,a)}),this.elements.container.appendChild(this.media),x(t.autoplay)&&(this.config.autoplay=t.autoplay),this.isHTML5&&(this.config.crossorigin&&this.media.setAttribute("crossorigin",""),this.config.autoplay&&this.media.setAttribute("autoplay",""),j(t.poster)||(this.poster=t.poster),this.config.loop.active&&this.media.setAttribute("loop",""),this.config.muted&&this.media.setAttribute("muted",""),this.config.playsinline&&this.media.setAttribute("playsinline","")),Qt.addStyleHook.call(this),this.isHTML5&&fe.insertElements.call(this,"source",e),this.config.title=t.title,oe.setup.call(this),this.isHTML5&&Object.keys(t).includes("tracks")&&fe.insertElements.call(this,"track",t.tracks),(this.isHTML5||this.isEmbed&&!this.supported.ui)&&Qt.build.call(this),this.isHTML5&&this.media.load(),j(t.previewThumbnails)||(Object.assign(this.config.previewThumbnails,t.previewThumbnails),this.previewThumbnails&&this.previewThumbnails.loaded&&(this.previewThumbnails.destroy(),this.previewThumbnails=null),this.config.previewThumbnails.enabled&&(this.previewThumbnails=new he(this))),this.fullscreen.update()}),!0)):this.debug.warn("Invalid source format")}};class pe{constructor(e,i){if(t(this,"play",(()=>P(this.media.play)?(this.ads&&this.ads.enabled&&this.ads.managerPromise.then((()=>this.ads.play())).catch((()=>vt(this.media.play()))),this.media.play()):null)),t(this,"pause",(()=>this.playing&&P(this.media.pause)?this.media.pause():null)),t(this,"togglePlay",(t=>(x(t)?t:!this.playing)?this.play():this.pause())),t(this,"stop",(()=>{this.isHTML5?(this.pause(),this.restart()):P(this.media.stop)&&this.media.stop()})),t(this,"restart",(()=>{this.currentTime=0})),t(this,"rewind",(t=>{this.currentTime-=C(t)?t:this.config.seekTime})),t(this,"forward",(t=>{this.currentTime+=C(t)?t:this.config.seekTime})),t(this,"increaseVolume",(t=>{const e=this.media.muted?0:this.volume;this.volume=e+(C(t)?t:0)})),t(this,"decreaseVolume",(t=>{this.increaseVolume(-t)})),t(this,"airplay",(()=>{ct.airplay&&this.media.webkitShowPlaybackTargetPicker()})),t(this,"toggleControls",(t=>{if(this.supported.ui&&!this.isAudio){const e=st(this.elements.container,this.config.classNames.hideControls),i=void 0===t?void 0:!t,s=it(this.elements.container,this.config.classNames.hideControls,i);if(s&&O(this.config.controls)&&this.config.controls.includes("settings")&&!j(this.config.settings)&&Bt.toggleMenu.call(this,!1),s!==e){const t=s?"controlshidden":"controlsshown";gt.call(this,this.media,t)}return!s}return!1})),t(this,"on",((t,e)=>{ht.call(this,this.elements.container,t,e)})),t(this,"once",((t,e)=>{pt.call(this,this.elements.container,t,e)})),t(this,"off",((t,e)=>{ft(this.elements.container,t,e)})),t(this,"destroy",((t,e=!1)=>{if(!this.ready)return;const i=()=>{document.body.style.overflow="",this.embed=null,e?(Object.keys(this.elements).length&&(J(this.elements.buttons.play),J(this.elements.captions),J(this.elements.controls),J(this.elements.wrapper),this.elements.buttons.play=null,this.elements.captions=null,this.elements.controls=null,this.elements.wrapper=null),P(t)&&t()):(mt.call(this),Lt.cancelRequests.call(this),Z(this.elements.original,this.elements.container),gt.call(this,this.elements.original,"destroyed",!0),P(t)&&t.call(this.elements.original),this.ready=!1,setTimeout((()=>{this.elements=null,this.media=null}),200))};this.stop(),clearTimeout(this.timers.loading),clearTimeout(this.timers.controls),clearTimeout(this.timers.resized),this.isHTML5?(Qt.toggleNativeControls.call(this,!0),i()):this.isYouTube?(clearInterval(this.timers.buffering),clearInterval(this.timers.playing),null!==this.embed&&P(this.embed.destroy)&&this.embed.destroy(),i()):this.isVimeo&&(null!==this.embed&&this.embed.unload().then(i),setTimeout(i,200))})),t(this,"supports",(t=>ct.mime.call(this,t))),this.timers={},this.ready=!1,this.loading=!1,this.failed=!1,this.touch=ct.touch,this.media=e,D(this.media)&&(this.media=document.querySelectorAll(this.media)),(window.jQuery&&this.media instanceof jQuery||N(this.media)||O(this.media))&&(this.media=this.media[0]),this.config=Y({},Ht,pe.defaults,i||{},(()=>{try{return JSON.parse(this.media.getAttribute("data-plyr-config"))}catch(t){return{}}})()),this.elements={container:null,fullscreen:null,captions:null,buttons:{},display:{},progress:{},inputs:{},settings:{popup:null,menu:null,panels:{},buttons:{}}},this.captions={active:null,currentTrack:-1,meta:new WeakMap},this.fullscreen={active:!1},this.options={speed:[],quality:[]},this.debug=new Wt(this.config.debug),this.debug.log("Config",this.config),this.debug.log("Support",ct),L(this.media)||!M(this.media))return void this.debug.error("Setup failed: no suitable element passed");if(this.media.plyr)return void this.debug.warn("Target already setup");if(!this.config.enabled)return void this.debug.error("Setup failed: disabled by config");if(!ct.check().api)return void this.debug.error("Setup failed: no support");const s=this.media.cloneNode(!0);s.autoplay=!1,this.elements.original=s;const n=this.media.tagName.toLowerCase();let r=null,a=null;switch(n){case"div":if(r=this.media.querySelector("iframe"),M(r)){if(a=jt(r.getAttribute("src")),this.provider=function(t){return/^(https?:\/\/)?(www\.)?(youtube\.com|youtube-nocookie\.com|youtu\.?be)\/.+$/.test(t)?Yt.youtube:/^https?:\/\/player.vimeo.com\/video\/\d{0,9}(?=\b|\/)/.test(t)?Yt.vimeo:null}(a.toString()),this.elements.container=this.media,this.media=r,this.elements.container.className="",a.search.length){const t=["1","true"];t.includes(a.searchParams.get("autoplay"))&&(this.config.autoplay=!0),t.includes(a.searchParams.get("loop"))&&(this.config.loop.active=!0),this.isYouTube?(this.config.playsinline=t.includes(a.searchParams.get("playsinline")),this.config.youtube.hl=a.searchParams.get("hl")):this.config.playsinline=!0}}else this.provider=this.media.getAttribute(this.config.attributes.embed.provider),this.media.removeAttribute(this.config.attributes.embed.provider);if(j(this.provider)||!Object.values(Yt).includes(this.provider))return void this.debug.error("Setup failed: Invalid provider");this.type=qt;break;case"video":case"audio":this.type=n,this.provider=Yt.html5,this.media.hasAttribute("crossorigin")&&(this.config.crossorigin=!0),this.media.hasAttribute("autoplay")&&(this.config.autoplay=!0),(this.media.hasAttribute("playsinline")||this.media.hasAttribute("webkit-playsinline"))&&(this.config.playsinline=!0),this.media.hasAttribute("muted")&&(this.config.muted=!0),this.media.hasAttribute("loop")&&(this.config.loop.active=!0);break;default:return void this.debug.error("Setup failed: unsupported type")}this.supported=ct.check(this.type,this.provider,this.config.playsinline),this.supported.api?(this.eventListeners=[],this.listeners=new Zt(this),this.storage=new Nt(this),this.media.plyr=this,M(this.elements.container)||(this.elements.container=W("div",{tabindex:0}),q(this.media,this.elements.container)),Qt.migrateStyles.call(this),Qt.addStyleHook.call(this),oe.setup.call(this),this.config.debug&&ht.call(this,this.elements.container,this.config.events.join(" "),(t=>{this.debug.log(`event: ${t.type}`)})),this.fullscreen=new Xt(this),(this.isHTML5||this.isEmbed&&!this.supported.ui)&&Qt.build.call(this),this.listeners.container(),this.listeners.global(),this.config.ads.enabled&&(this.ads=new le(this)),this.isHTML5&&this.config.autoplay&&this.once("canplay",(()=>vt(this.play()))),this.lastSeekTime=0,this.config.previewThumbnails.enabled&&(this.previewThumbnails=new he(this))):this.debug.error("Setup failed: no support")}get isHTML5(){return this.provider===Yt.html5}get isEmbed(){return this.isYouTube||this.isVimeo}get isYouTube(){return this.provider===Yt.youtube}get isVimeo(){return this.provider===Yt.vimeo}get isVideo(){return this.type===qt}get isAudio(){return"audio"===this.type}get playing(){return Boolean(this.ready&&!this.paused&&!this.ended)}get paused(){return Boolean(this.media.paused)}get stopped(){return Boolean(this.paused&&0===this.currentTime)}get ended(){return Boolean(this.media.ended)}set currentTime(t){if(!this.duration)return;const e=C(t)&&t>0;this.media.currentTime=e?Math.min(t,this.duration):0,this.debug.log(`Seeking to ${this.currentTime} seconds`)}get currentTime(){return Number(this.media.currentTime)}get buffered(){const{buffered:t}=this.media;return C(t)?t:t&&t.length&&this.duration>0?t.end(0)/this.duration:0}get seeking(){return Boolean(this.media.seeking)}get duration(){const t=parseFloat(this.config.duration),e=(this.media||{}).duration,i=C(e)&&e!==1/0?e:0;return t||i}set volume(t){let e=t;D(e)&&(e=Number(e)),C(e)||(e=this.storage.get("volume")),C(e)||({volume:e}=this.config),e>1&&(e=1),e<0&&(e=0),this.config.volume=e,this.media.volume=e,!j(t)&&this.muted&&e>0&&(this.muted=!1)}get volume(){return Number(this.media.volume)}set muted(t){let e=t;x(e)||(e=this.storage.get("muted")),x(e)||(e=this.config.muted),this.config.muted=e,this.media.muted=e}get muted(){return Boolean(this.media.muted)}get hasAudio(){return!this.isHTML5||!!this.isAudio||Boolean(this.media.mozHasAudio)||Boolean(this.media.webkitAudioDecodedByteCount)||Boolean(this.media.audioTracks&&this.media.audioTracks.length)}set speed(t){let e=null;C(t)&&(e=t),C(e)||(e=this.storage.get("speed")),C(e)||(e=this.config.speed.selected);const{minimumSpeed:i,maximumSpeed:s}=this;e=ce(e,i,s),this.config.speed.selected=e,setTimeout((()=>{this.media&&(this.media.playbackRate=e)}),0)}get speed(){return Number(this.media.playbackRate)}get minimumSpeed(){return this.isYouTube?Math.min(...this.options.speed):this.isVimeo?.5:.0625}get maximumSpeed(){return this.isYouTube?Math.max(...this.options.speed):this.isVimeo?2:16}set quality(t){const e=this.config.quality,i=this.options.quality;if(!i.length)return;let s=[!j(t)&&Number(t),this.storage.get("quality"),e.selected,e.default].find(C),n=!0;if(!i.includes(s)){const t=_t(i,s);this.debug.warn(`Unsupported quality option: ${s}, using ${t} instead`),s=t,n=!1}e.selected=s,this.media.quality=s,n&&this.storage.set({quality:s})}get quality(){return this.media.quality}set loop(t){const e=x(t)?t:this.config.loop.active;this.config.loop.active=e,this.media.loop=e}get loop(){return Boolean(this.media.loop)}set source(t){fe.change.call(this,t)}get source(){return this.media.currentSrc}get download(){const{download:t}=this.config.urls;return B(t)?t:this.source}set download(t){B(t)&&(this.config.urls.download=t,Bt.setDownloadUrl.call(this))}set poster(t){this.isVideo?Qt.setPoster.call(this,t,!1).catch((()=>{})):this.debug.warn("Poster can only be set for video")}get poster(){return this.isVideo?this.media.getAttribute("poster")||this.media.getAttribute("data-poster"):null}get ratio(){if(!this.isVideo)return null;const t=kt(wt.call(this));return O(t)?t.join(":"):t}set ratio(t){this.isVideo?D(t)&&St(t)?(this.config.ratio=kt(t),At.call(this)):this.debug.error(`Invalid aspect ratio specified (${t})`):this.debug.warn("Aspect ratio can only be set for video")}set autoplay(t){this.config.autoplay=x(t)?t:this.config.autoplay}get autoplay(){return Boolean(this.config.autoplay)}toggleCaptions(t){Vt.toggle.call(this,t,!1)}set currentTrack(t){Vt.set.call(this,t,!1),Vt.setup.call(this)}get currentTrack(){const{toggled:t,currentTrack:e}=this.captions;return t?e:-1}set language(t){Vt.setLanguage.call(this,t,!1)}get language(){return(Vt.getCurrentTrack.call(this)||{}).language}set pip(t){if(!ct.pip)return;const e=x(t)?t:!this.pip;P(this.media.webkitSetPresentationMode)&&this.media.webkitSetPresentationMode(e?Kt:"inline"),P(this.media.requestPictureInPicture)&&(!this.pip&&e?this.media.requestPictureInPicture():this.pip&&!e&&document.exitPictureInPicture())}get pip(){return ct.pip?j(this.media.webkitPresentationMode)?this.media===document.pictureInPictureElement:this.media.webkitPresentationMode===Kt:null}setPreviewThumbnails(t){this.previewThumbnails&&this.previewThumbnails.loaded&&(this.previewThumbnails.destroy(),this.previewThumbnails=null),Object.assign(this.config.previewThumbnails,t),this.config.previewThumbnails.enabled&&(this.previewThumbnails=new he(this))}static supported(t,e,i){return ct.check(t,e,i)}static loadSprite(t,e){return Ft(t,e)}static setup(t,e={}){let i=null;return D(t)?i=Array.from(document.querySelectorAll(t)):N(t)?i=Array.from(t):O(t)&&(i=t.filter(M)),j(i)?null:i.map((t=>new pe(t,e)))}}var ge;return pe.defaults=(ge=Ht,JSON.parse(JSON.stringify(ge))),pe}())},6242:(t,e,i)=>{"use strict";i.d(e,{Z:()=>s});const s={categoriesLabel:"Categorias",emojiUnsupportedMessage:"Seu navegador não suporta emojis coloridos.",favoritesLabel:"Favoritos",loadingMessage:"Carregando…",networkErrorMessage:"Não foi possível carregar o emoji.",regionLabel:"Seletor de emoji",searchDescription:"Quando os resultados da pesquisa estiverem disponíveis, pressione para cima ou para baixo para selecionar e “enter” para escolher.",searchLabel:"Procurar",searchResultsLabel:"Resultados da pesquisa",skinToneDescription:"Quando expandido, pressione para cima ou para baixo para selecionar e “enter” para escolher.",skinToneLabel:"Escolha um tom de pele (atualmente {skinTone})",skinTonesLabel:"Tons de pele",skinTones:["Padrão","Claro","Claro médio","Médio","Escuro médio","Escuro"],categories:{custom:"Personalizar","smileys-emotion":"Carinhas e emoticons","people-body":"Pessoas e corpo","animals-nature":"Animais e natureza","food-drink":"Alimentos e bebidas","travel-places":"Viagem e lugares",activities:"Atividades",objects:"Objetos",symbols:"Símbolos",flags:"Bandeiras"}}},8014:(t,e,i)=>{"use strict";function s(t){if("string"!=typeof t||!t)throw new Error("expected a non-empty string, got: "+t)}function n(t){if("number"!=typeof t)throw new Error("expected a number, got: "+t)}i.d(e,{Z:()=>It});const r="emoji",a="keyvalue",o="favorites",l="tokens",c="count",u="group-order",d="eTag",h="url",f="skinTone",p="readonly",g="readwrite",m="skinUnicodes";function y(t){return function(t,e){const i=new Set,s=[];for(const e of t){const t=e.unicode;i.has(t)||(i.add(t),s.push(e))}return s}(t)}const v={},b={},_={};function E(t,e,i){i.onerror=()=>e(i.error),i.onblocked=()=>e(new Error("IDB blocked")),i.onsuccess=()=>t(i.result)}function T(t,e,i,s){return new Promise(((n,r)=>{const a=t.transaction(e,i,{durability:"relaxed"}),o="string"==typeof e?a.objectStore(e):e.map((t=>a.objectStore(t)));let l;s(o,a,(t=>{l=t})),a.oncomplete=()=>n(l),a.onerror=()=>r(a.error)}))}function S(t){const e=v[t],i=e&&e.result;if(i){i.close();const e=_[t];if(e)for(const t of e)t()}delete v[t],delete b[t],delete _[t]}const k=new Set([":D","XD",":'D","O:)",":X",":P",";P","XP",":L",":Z",":j","8D","XO","8)",":B",":O",":S",":'o","Dx","X(","D:",":C",">0)",":3","!t.match(/\w/)||k.has(t)?t.toLowerCase():t.replace(/[)(:,]/g,"").replace(/’/g,"'").toLowerCase())).filter(Boolean)}const A=2;function R(t){return t.filter(Boolean).map((t=>t.toLowerCase())).filter((t=>t.length>=A))}function L(t,e,i,s){t[e](i).onsuccess=t=>s&&s(t.target.result)}function I(t,e,i){L(t,"get",e,i)}function C(t,e,i){L(t,"getAll",e,i)}function D(t){t.commit&&t.commit()}function x(t,e){const i=function(t,e){let i=t[0];for(let s=1;se(n)&&(i=n)}return i}(t,(t=>t.length)),s=[];for(const n of i)t.some((t=>-1===t.findIndex((t=>e(t)===e(n)))))||s.push(n);return s}async function P(t,e,i,s){try{const n=function(t){return t.map((({annotation:t,emoticon:e,group:i,order:s,shortcodes:n,skins:r,tags:a,emoji:o,version:l})=>{const c=[...new Set(R([...(n||[]).map(w).flat(),...a.map(w).flat(),...w(t),e]))].sort(),u={annotation:t,group:i,order:s,tags:a,tokens:c,unicode:o,version:l};if(e&&(u.emoticon=e),n&&(u.shortcodes=n),r){u.skinTones=[],u.skinUnicodes=[],u.skinVersions=[];for(const{tone:t,emoji:e,version:i}of r)u.skinTones.push(t),u.skinUnicodes.push(e),u.skinVersions.push(i)}return u}))}(e);await T(t,[r,a],g,(([t,e],r)=>{let a,o,l=0;function c(){2==++l&&function(){if(a!==s||o!==i){t.clear();for(const e of n)t.put(e);e.put(s,d),e.put(i,h),D(r)}}()}I(e,d,(t=>{a=t,c()})),I(e,h,(t=>{o=t,c()}))}))}finally{}}async function O(t,e){const i=R(w(e));return i.length?T(t,r,p,((t,e,s)=>{const n=[],r=()=>{const t=x(n,(t=>t.unicode));s(t.sort(((t,e)=>t.order{n.push(t),n.length===i.length&&r()}))}})):[]}function N(t,e,i){return T(t,e,p,((t,e,s)=>I(t,i,s)))}const M=["name","url"];function F(t){!function(t){const e=t&&Array.isArray(t),i=e&&t.length&&(!t[0]||M.some((e=>!(e in t[0]))));if(!e||i)throw new Error("Custom emojis are in the wrong format")}(t);const e=(t,e)=>t.name.toLowerCase()w(t))).flat())];for(const s of t){let t=i;for(let e=0;e{let s=i;for(let e=0;et[0]s(t,!0),r=t=>s(t,!1),a=new Map,o=new Map;for(const e of t){o.set(e.name.toLowerCase(),e);for(const t of e.shortcodes||[])a.set(t.toLowerCase(),e)}return{all:i,search:t=>{const i=w(t);return x(i.map(((t,e)=>(et.name)).sort(e)},byShortcode:t=>a.get(t.toLowerCase()),byName:t=>o.get(t.toLowerCase())}}const $="undefined"!=typeof wrappedJSObject;function U(t){if(!t)return t;if($&&(t=structuredClone(t)),delete t.tokens,t.skinTones){const e=t.skinTones.length;t.skins=Array(e);for(let i=0;i!(e in t[0]))))throw new Error("Emoji data is in the wrong format")}(s),[i,s]}async function H(t){const e=function(t){for(var e=t.length,i=new ArrayBuffer(e),s=new Uint8Array(i),n=-1;++n{const s=indexedDB.open(t,1);v[t]=s,s.onupgradeneeded=t=>{t.oldVersion<1&&function(t){function e(e,i,s){const n=i?t.createObjectStore(e,{keyPath:i}):t.createObjectStore(e);if(s)for(const[t,[e,i]]of Object.entries(s))n.createIndex(t,e,{multiEntry:i});return n}e(a),e(r,"unicode",{[l]:["tokens",!0],[u]:[["group","order"]],[m]:["skinUnicodes",!0]}),e(o,void 0,{[c]:[""]})}(s.result)},E(e,i,s)}));return e.onclose=()=>S(t),e}(e)),b[e]);var e;!function(t,e){let i=_[t];i||(i=_[t]=[]),i.push(e)}(this._dbName,this._clear);const i=this.dataSource,s=await async function(t){return!await N(t,a,h)}(t);s?await async function(t,e){let[i,s]=await V(e);i||(i=await H(s)),await P(t,s,e,i)}(t,i):this._lazyUpdate=async function(t,e){let i,s=await async function(t){const e=await fetch(t,{method:"HEAD"});G(e,t);const i=e.headers.get("etag");return B(i),i}(e);if(!s){const t=await V(e);s=t[0],i=t[1],s||(s=await H(i))}await async function(t,e,i){const[s,n]=await Promise.all([d,h].map((e=>N(t,a,e))));return s===i&&n===e}(t,e,s)||(i||(i=(await V(e))[1]),await P(t,i,e,s))}(t,i)}async ready(){const t=async()=>(this._ready||(this._ready=this._init()),this._ready);await t(),this._db||await t()}async getEmojiByGroup(t){return n(t),await this.ready(),y(await async function(t,e){return T(t,r,p,((t,i,s)=>{const n=IDBKeyRange.bound([e,0],[e+1,0],!1,!0);C(t.index(u),n,s)}))}(this._db,t)).map(U)}async getEmojiBySearchQuery(t){return s(t),await this.ready(),[...this._custom.search(t),...y(await O(this._db,t)).map(U)]}async getEmojiByShortcode(t){s(t),await this.ready();return this._custom.byShortcode(t)||U(await async function(t,e){const i=await O(t,e);if(!i.length){const i=t=>(t.shortcodes||[]).includes(e.toLowerCase());return await async function(t,e){return T(t,r,p,((t,i,s)=>{let n;const r=()=>{t.getAll(n&&IDBKeyRange.lowerBound(n,!0),50).onsuccess=t=>{const i=t.target.result;for(const t of i)if(n=t.unicode,e(t))return s(t);if(i.length<50)return s();r()}};r()}))}(t,i)||null}return i.filter((t=>{const i=(t.shortcodes||[]).map((t=>t.toLowerCase()));return i.includes(e.toLowerCase())}))[0]||null}(this._db,t))}async getEmojiByUnicodeOrName(t){s(t),await this.ready();return this._custom.byName(t)||U(await async function(t,e){return T(t,r,p,((t,i,s)=>I(t,e,(i=>{if(i)return s(i);I(t.index(m),e,(t=>s(t||null)))}))))}(this._db,t))}async getPreferredSkinTone(){return await this.ready(),await N(this._db,a,f)||0}async setPreferredSkinTone(t){return n(t),await this.ready(),e=this._db,i=f,s=t,T(e,a,g,((t,e)=>{t.put(s,i),D(e)}));var e,i,s}async incrementFavoriteEmojiCount(t){return s(t),await this.ready(),e=this._db,i=t,T(e,o,g,((t,e)=>I(t,i,(s=>{t.put((s||0)+1,i),D(e)}))));var e,i}async getTopFavoriteEmoji(t){return n(t),await this.ready(),(await function(t,e,i){return 0===i?[]:T(t,[o,r],p,(([t,s],n,r)=>{const a=[];t.index(c).openCursor(void 0,"prev").onsuccess=t=>{const n=t.target.result;if(!n)return r(a);function o(t){if(a.push(t),a.length===i)return r(a);n.continue()}const l=n.primaryKey,c=e.byName(l);if(c)return o(c);I(s,l,(t=>{if(t)return o(t);n.continue()}))}}))}(this._db,this._custom,t)).map(U)}set customEmoji(t){this._custom=F(t)}get customEmoji(){return this._custom.all}async _shutdown(){await this.ready();try{await this._lazyUpdate}catch(t){}}_clear(){this._db=this._ready=this._lazyUpdate=void 0}async close(){await this._shutdown(),await S(this._dbName)}async delete(){var t;await this._shutdown(),await(t=this._dbName,new Promise(((e,i)=>{S(t),E(e,i,indexedDB.deleteDatabase(t))})))}}const Y=[[-1,"✨","custom"],[0,"😀","smileys-emotion"],[1,"👋","people-body"],[3,"🐱","animals-nature"],[4,"🍎","food-drink"],[5,"🏠️","travel-places"],[6,"⚽","activities"],[7,"📝","objects"],[8,"⛔️","symbols"],[9,"🏁","flags"]].map((([t,e,i])=>({id:t,emoji:e,name:i}))),q=Y.slice(1),z="function"==typeof requestIdleCallback?requestIdleCallback:setTimeout;function W(t){return t.unicode.includes("‍")}const X={"🫨":15.1,"🫠":14,"🥲":13.1,"🥻":12.1,"🥰":11,"🤩":5,"👱‍♀️":4,"🤣":3,"👁️‍🗨️":2,"😀":1,"😐️":.7,"😃":.6},J=["😊","😒","❤️","👍️","😍","😂","😭","☺️","😔","😩","😏","💕","🙌","😘"],Q='"Twemoji Mozilla","Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji","EmojiOne Color","Android Emoji",sans-serif',Z=(t,e)=>te?1:0,tt=(t,e)=>{const i=document.createElement("canvas");i.width=i.height=1;const s=i.getContext("2d");return s.textBaseline="top",s.font=`100px ${Q}`,s.fillStyle=e,s.scale(.01,.01),s.fillText(t,0,0),s.getImageData(0,0,1,1).data};function et(t){const e=tt(t,"#000"),i=tt(t,"#fff");return e&&i&&((t,e)=>{const i=[...t].join(",");return i===[...e].join(",")&&!i.startsWith("0,0,0,")})(e,i)}let it;const st=()=>(it||(it=new Promise((t=>z((()=>t(function(){const t=Object.entries(X);try{for(const[e,i]of t)if(et(e))return i}catch(t){}return t[0][1]}())))))),it),nt=new Map;function rt(t){t.preventDefault(),t.stopPropagation()}function at(t,e,i){return(e+=t?-1:1)<0?e=i.length-1:e>=i.length&&(e=0),e}function ot(t,e){const i=new Set,s=[];for(const n of t){const t=e(n);i.has(t)||(i.add(t),s.push(n))}return s}const lt=requestAnimationFrame;let ct,ut="function"==typeof ResizeObserver;function dt(t){{const e=document.createRange();return e.selectNode(t.firstChild),e.getBoundingClientRect().width}}function ht(t,e,i){let s=t.get(e);return s||(s=i(),t.set(e,s)),s}function ft(t){return""+t}const pt=new WeakMap,gt=new WeakMap,mt=Symbol("un-keyed"),yt="replaceChildren"in Element.prototype;function vt(t,e){const{targetNode:i}=e;let{targetParentNode:s}=e,n=!1;s?n=function(t,e){let i=t.firstChild,s=0;for(;i;){if(e[s]!==i)return!0;i=i.nextSibling,s++}return s!==e.length}(s,t):(n=!0,e.targetNode=void 0,e.targetParentNode=s=i.parentNode),n&&function(t,e){yt?t.replaceChildren(...e):(t.innerHTML="",t.append(...e))}(s,t)}function bt(t,e){let i=t.firstChild;for(;i;){if(i.nodeType===Node.COMMENT_NODE&&i.nodeValue===ft(e))return i;i=i.nextSibling}}function _t(t){const{template:e,elementsToBindings:i}=ht(pt,t,(()=>function(t){let e="",i=!1,s=!1,n=-1;const r=new Map,a=[];for(let o=0,l=t.length;o":i=!1,s=!1;break;case"=":s=!0}const u=ht(r,a[a.length-1],(()=>[]));let d,h,f;if(s){const e=/(\S+)="?([^"=]*)$/.exec(c);d=e[1],h=e[2],f=/^[^">]*/.exec(t[o+1])[0]}const p={attributeName:d,attributeValuePre:h,attributeValuePost:f,expressionIndex:o};u.push(p),e+=i||s?"":`\x3c!--${u.length-1}--\x3e`}const o=function(t){const e=document.createElement("template");return e.innerHTML=t,e}(e);return{template:o,elementsToBindings:r}}(t))),s=e.cloneNode(!0).content.firstElementChild,n=function(t,e){const i=[],s=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT);let n=t,r=-1;do{const t=e.get(++r);if(t)for(let e=0;ePromise.resolve().then(t);function Tt(t,e,i){if(t.length!==e.length)return!1;for(let s=0;s{if(i)return;const t=[...n];n.clear();try{for(const e of t)e()}finally{r=!1,n.size&&(r=!0,Et(a))}},o=new Proxy({},{get(t,i){if(e){let t=s.get(i);t||(t=new Set,s.set(i,t)),t.add(e)}return t[i]},set(t,e,i){t[e]=i;const o=s.get(e);if(o){for(const t of o)n.add(t);r||(r=!0,Et(a))}return!0}});return t.addEventListener("abort",(()=>{i=!0})),{state:o,createEffect:t=>{const i=()=>{const s=e;e=i;try{return t()}finally{e=s}};return i()}}}(n);kt(r,{skinToneEmoji:void 0,i18n:void 0,database:void 0,customEmoji:void 0,customCategorySorting:void 0,emojiVersion:void 0}),kt(r,e),kt(r,{initialLoad:!0,currentEmojis:[],currentEmojisWithCategories:[],rawSearchText:"",searchText:"",searchMode:!1,activeSearchItem:-1,message:void 0,skinTonePickerExpanded:!1,skinTonePickerExpandedAfterAnimation:!1,currentSkinTone:0,activeSkinTone:0,skinToneButtonText:void 0,pickerStyle:void 0,skinToneButtonLabel:"",skinTones:[],currentFavorites:[],defaultFavoriteEmojis:void 0,numColumns:8,isRtl:!1,scrollbarWidth:0,currentGroupIndex:0,groups:q,databaseLoaded:!1,activeSearchItemId:void 0}),a((()=>{r.currentGroup!==r.groups[r.currentGroupIndex]&&(r.currentGroup=r.groups[r.currentGroupIndex])}));const o=e=>{t.getElementById(e).focus()},l=e=>t.getElementById(`emo-${e.id}`),c=(t,e)=>{i.rootElement.dispatchEvent(new CustomEvent(t,{detail:e,bubbles:!0,composed:!0}))},u=(t,e)=>t.id===e.id,d=(t,e)=>{const{category:i,emojis:s}=t,{category:n,emojis:r}=e;return i===n&&Tt(s,r,u)},h=t=>{Tt(r.currentEmojis,t,u)||(r.currentEmojis=t)},f=t=>{r.searchMode!==t&&(r.searchMode=t)},p=(t,e)=>e&&t.skins&&t.skins[e]||t.unicode,g={labelWithSkin:(t,e)=>{return(i=[t.name||p(t,e),t.annotation,...t.shortcodes||St].filter(Boolean),ot(i,(t=>t))).join(", ");var i},titleForEmoji:t=>t.annotation||(t.shortcodes||St).join(", "),unicodeWithSkin:p},m={onClickSkinToneButton:function(t){r.skinTonePickerExpanded=!r.skinTonePickerExpanded,r.activeSkinTone=r.currentSkinTone,r.skinTonePickerExpanded&&(rt(t),lt((()=>o("skintone-list"))))},onEmojiClick:async function(t){const{target:e}=t;e.classList.contains("emoji")&&(rt(t),S(e.id.substring(4)))},onNavClick:function(t){const{target:e}=t,s=e.closest(".nav-button");if(!s)return;const n=parseInt(s.dataset.groupId,10);i.searchElement.value="",r.rawSearchText="",r.searchText="",r.activeSearchItem=-1,r.currentGroupIndex=r.groups.findIndex((t=>t.id===n))},onNavKeydown:function(t){const{target:e,key:i}=t,s=e=>{e&&(rt(t),e.focus())};switch(i){case"ArrowLeft":return s(e.previousElementSibling);case"ArrowRight":return s(e.nextElementSibling);case"Home":return s(e.parentElement.firstElementChild);case"End":return s(e.parentElement.lastElementChild)}},onSearchKeydown:function(t){if(!r.searchMode||!r.currentEmojis.length)return;const e=e=>{rt(t),r.activeSearchItem=at(e,r.activeSearchItem,r.currentEmojis)};switch(t.key){case"ArrowDown":return e(!1);case"ArrowUp":return e(!0);case"Enter":if(-1!==r.activeSearchItem)return rt(t),S(r.currentEmojis[r.activeSearchItem].id);r.activeSearchItem=0}},onSkinToneOptionsClick:function(t){const{target:{id:e}}=t,i=e&&e.match(/^skintone-(\d)/);i&&(rt(t),k(parseInt(i[1],10)))},onSkinToneOptionsFocusOut:async function(t){const{relatedTarget:e}=t;e&&"skintone-list"===e.id||(r.skinTonePickerExpanded=!1)},onSkinToneOptionsKeydown:function(t){if(!r.skinTonePickerExpanded)return;const e=async e=>{rt(t),r.activeSkinTone=e};switch(t.key){case"ArrowUp":return e(at(!0,r.activeSkinTone,r.skinTones));case"ArrowDown":return e(at(!1,r.activeSkinTone,r.skinTones));case"Home":return e(0);case"End":return e(r.skinTones.length-1);case"Enter":return rt(t),k(r.activeSkinTone);case"Escape":return rt(t),r.skinTonePickerExpanded=!1,o("skintone-button")}},onSkinToneOptionsKeyup:function(t){if(r.skinTonePickerExpanded)return" "===t.key?(rt(t),k(r.activeSkinTone)):void 0},onSearchInput:function(t){r.rawSearchText=t.target.value}},y={calculateEmojiGridStyle:function(t){!function(t,e,i){let s;ut?(s=new ResizeObserver((t=>i(t[0].contentRect.width))),s.observe(t)):lt((()=>i(t.getBoundingClientRect().width))),e.addEventListener("abort",(()=>{s&&s.disconnect()}))}(t,n,(e=>{{const s=getComputedStyle(i.rootElement),n=parseInt(s.getPropertyValue("--num-columns"),10),a="rtl"===s.getPropertyValue("direction"),o=t.parentElement.getBoundingClientRect().width-e;r.numColumns=n,r.scrollbarWidth=o,r.isRtl=a}}))}};let v=!0;function b(){r.database.customEmoji=r.customEmoji||St}function _(t){return!t.unicode||!W(t)||nt.get(t.unicode)}async function E(t){const e=r.emojiVersion||await st();return t.filter((({version:t})=>!t||t<=e))}async function T(t){return function(t,e){const i=t=>{const i={};for(const s of t)"number"==typeof s.tone&&s.version<=e&&(i[s.tone]=s.unicode);return i};return t.map((({unicode:t,skins:e,shortcodes:s,url:n,name:r,category:a,annotation:o})=>({unicode:t,name:r,shortcodes:s,url:n,category:a,annotation:o,id:t||r,skins:e&&i(e)})))}(t,r.emojiVersion||await st())}async function S(t){const e=await r.database.getEmojiByUnicodeOrName(t),i=[...r.currentEmojis,...r.currentFavorites].find((e=>e.id===t)),s=i.unicode&&p(i,r.currentSkinTone);await r.database.incrementFavoriteEmojiCount(t),c("emoji-click",{emoji:e,skinTone:r.currentSkinTone,...s&&{unicode:s},...i.name&&{name:i.name}})}function k(t){r.currentSkinTone=t,r.skinTonePickerExpanded=!1,o("skintone-button"),c("skin-tone-change",{skinTone:t}),r.database.setPreferredSkinTone(t)}return a((()=>{(function(t,e,i,s,n,r,a,o){const{labelWithSkin:l,titleForEmoji:c,unicodeWithSkin:u}=i,{html:d,map:h}=function(t){const e=ht(gt,t,(()=>new Map));let i=mt;return{map:function(t,e,s){return t.map(((t,n)=>{const r=i;i=s(t);try{return e(t,n)}finally{i=r}}))},html:function(t,...s){const n=ht(e,t,(()=>new Map));return ht(n,i,(()=>_t(t)))(s)}}}(e);function f(t,i,s){return h(t,((t,n)=>d``),(t=>`${s}-${t.id}`))}const p=d`
${e.i18n.searchDescription}
${e.i18n.skinToneDescription}
${h(e.skinTones,((t,i)=>d`
${t}
`),(t=>t))}
${h(e.currentEmojisWithCategories,((t,i)=>d`
${f(t.emojis,e.searchMode,"emo")}
`),(t=>t.category))}
`;if(o){t.appendChild(p);const e=(e,i)=>{for(const s of t.querySelectorAll(`[${e}]`))i(s,s.getAttribute(e))};for(const t of["click","focusout","input","keydown","keyup"])e(`data-on-${t}`,((e,i)=>{e.addEventListener(t,s[i])}));e("data-ref",((t,e)=>{r[e]=t})),e("data-action",((t,e)=>{n[e](t)})),a.addEventListener("abort",(()=>{t.removeChild(p)}))}})(t,r,g,m,y,i,n,v),v=!1})),r.emojiVersion||st().then((t=>{t||(r.message=r.i18n.emojiUnsupportedMessage)})),a((()=>{r.database&&async function(){let t=!1;const e=setTimeout((()=>{t=!0,r.message=r.i18n.loadingMessage}),1e3);try{await r.database.ready(),r.databaseLoaded=!0}catch(t){console.error(t),r.message=r.i18n.networkErrorMessage}finally{clearTimeout(e),t&&(t=!1,r.message="")}}()})),a((()=>{r.pickerStyle=`\n --num-groups: ${r.groups.length}; \n --indicator-opacity: ${r.searchMode?0:1}; \n --num-skintones: 6;`})),a((()=>{r.customEmoji&&r.database&&b()})),a((()=>{r.customEmoji&&r.customEmoji.length?r.groups!==Y&&(r.groups=Y):r.groups!==q&&(r.currentGroupIndex&&r.currentGroupIndex--,r.groups=q)})),a((()=>{!async function(){r.databaseLoaded&&(r.currentSkinTone=await r.database.getPreferredSkinTone())}()})),a((()=>{r.skinTones=Array(6).fill().map(((t,e)=>function(t,e){if(0===e)return t;const i=t.indexOf("‍");return-1!==i?t.substring(0,i)+String.fromCodePoint(127995+e-1)+t.substring(i):(t.endsWith("️")&&(t=t.substring(0,t.length-1)),t+"\ud83c"+String.fromCodePoint(57339+e-1))}(r.skinToneEmoji,e)))})),a((()=>{r.skinToneButtonText=r.skinTones[r.currentSkinTone]})),a((()=>{r.skinToneButtonLabel=r.i18n.skinToneLabel.replace("{skinTone}",r.i18n.skinTones[r.currentSkinTone])})),a((()=>{r.databaseLoaded&&async function(){const{database:t}=r,e=(await Promise.all(J.map((e=>t.getEmojiByUnicodeOrName(e))))).filter(Boolean);r.defaultFavoriteEmojis=e}()})),a((()=>{r.databaseLoaded&&r.defaultFavoriteEmojis&&async function(){b();const{database:t,defaultFavoriteEmojis:e,numColumns:i}=r,s=await t.getTopFavoriteEmoji(i),n=await T(ot([...s,...e],(t=>t.unicode||t.name)).slice(0,i));r.currentFavorites=n}()})),a((()=>{!async function(){const{searchText:t,currentGroup:e,databaseLoaded:i,customEmoji:s}=r;if(i)if(t.length>=2){const e=await async function(t){return T(await E(await r.database.getEmojiBySearchQuery(t)))}(t);r.searchText===t&&(h(e),f(!0))}else{const{id:t}=e;if(-1!==t||s&&s.length){const e=await async function(t){const e=-1===t?r.customEmoji:await r.database.getEmojiByGroup(t);return T(await E(e))}(t);r.currentGroup.id===t&&(h(e),f(!1))}}else r.currentEmojis=[],r.searchMode=!1}()})),a((()=>{const{currentEmojis:t,emojiVersion:e}=r,s=t.filter((t=>t.unicode)).filter((t=>W(t)&&!nt.has(t.unicode)));if(!e&&s.length)h(t),lt((()=>function(t){(function(t,e,i){for(const s of t){const t=dt(i(s));void 0===ct&&(ct=dt(e));const n=t/1.8{var t;(t=i.tabpanelElement)&&(t.scrollTop=0)}))}})),a((()=>{})),a((()=>{var t;t=function(){const{searchMode:t,currentEmojis:e}=r;if(t)return[{category:"",emojis:e}];const i=new Map;for(const t of e){const e=t.category||"";let s=i.get(e);s||(s=[],i.set(e,s)),s.push(t)}return[...i.entries()].map((([t,e])=>({category:t,emojis:e}))).sort(((t,e)=>r.customCategorySorting(t.category,e.category)))}(),Tt(r.currentEmojisWithCategories,t,d)||(r.currentEmojisWithCategories=t)})),a((()=>{r.activeSearchItemId=-1!==r.activeSearchItem&&r.currentEmojis[r.activeSearchItem].id})),a((()=>{const{rawSearchText:t}=r;z((()=>{r.searchText=(t||"").trim(),r.activeSearchItem=-1}))})),a((()=>{r.skinTonePickerExpanded?i.skinToneDropdown.addEventListener("transitionend",(()=>{r.skinTonePickerExpandedAfterAnimation=!0}),{once:!0}):r.skinTonePickerExpandedAfterAnimation=!1})),{$set(t){kt(r,t)},$destroy(){s.abort()}}}var At={categoriesLabel:"Categories",emojiUnsupportedMessage:"Your browser does not support color emoji.",favoritesLabel:"Favorites",loadingMessage:"Loading…",networkErrorMessage:"Could not load emoji.",regionLabel:"Emoji picker",searchDescription:"When search results are available, press up or down to select and enter to choose.",searchLabel:"Search",searchResultsLabel:"Search results",skinToneDescription:"When expanded, press up or down to select and enter to choose.",skinToneLabel:"Choose a skin tone (currently {skinTone})",skinTonesLabel:"Skin tones",skinTones:["Default","Light","Medium-Light","Medium","Medium-Dark","Dark"],categories:{custom:"Custom","smileys-emotion":"Smileys and emoticons","people-body":"People and body","animals-nature":"Animals and nature","food-drink":"Food and drink","travel-places":"Travel and places",activities:"Activities",objects:"Objects",symbols:"Symbols",flags:"Flags"}};const Rt=["customEmoji","customCategorySorting","database","dataSource","i18n","locale","skinToneEmoji","emojiVersion"],Lt=`:host{--emoji-font-family:${Q}}`;class It extends HTMLElement{constructor(t){super(),this.attachShadow({mode:"open"});const e=document.createElement("style");e.textContent=":host{--emoji-size:1.375rem;--emoji-padding:0.5rem;--category-emoji-size:var(--emoji-size);--category-emoji-padding:var(--emoji-padding);--indicator-height:3px;--input-border-radius:0.5rem;--input-border-size:1px;--input-font-size:1rem;--input-line-height:1.5;--input-padding:0.25rem;--num-columns:8;--outline-size:2px;--border-size:1px;--skintone-border-radius:1rem;--category-font-size:1rem;display:flex;width:min-content;height:400px}:host,:host(.light){color-scheme:light;--background:#fff;--border-color:#e0e0e0;--indicator-color:#385ac1;--input-border-color:#999;--input-font-color:#111;--input-placeholder-color:#999;--outline-color:#999;--category-font-color:#111;--button-active-background:#e6e6e6;--button-hover-background:#d9d9d9}:host(.dark){color-scheme:dark;--background:#222;--border-color:#444;--indicator-color:#5373ec;--input-border-color:#ccc;--input-font-color:#efefef;--input-placeholder-color:#ccc;--outline-color:#fff;--category-font-color:#efefef;--button-active-background:#555555;--button-hover-background:#484848}@media (prefers-color-scheme:dark){:host{color-scheme:dark;--background:#222;--border-color:#444;--indicator-color:#5373ec;--input-border-color:#ccc;--input-font-color:#efefef;--input-placeholder-color:#ccc;--outline-color:#fff;--category-font-color:#efefef;--button-active-background:#555555;--button-hover-background:#484848}}:host([hidden]){display:none}button{margin:0;padding:0;border:0;background:0 0;box-shadow:none;-webkit-tap-highlight-color:transparent}button::-moz-focus-inner{border:0}input{padding:0;margin:0;line-height:1.15;font-family:inherit}input[type=search]{-webkit-appearance:none}:focus{outline:var(--outline-color) solid var(--outline-size);outline-offset:calc(-1*var(--outline-size))}:host([data-js-focus-visible]) :focus:not([data-focus-visible-added]){outline:0}:focus:not(:focus-visible){outline:0}.hide-focus{outline:0}*{box-sizing:border-box}.picker{contain:content;display:flex;flex-direction:column;background:var(--background);border:var(--border-size) solid var(--border-color);width:100%;height:100%;overflow:hidden;--total-emoji-size:calc(var(--emoji-size) + (2 * var(--emoji-padding)));--total-category-emoji-size:calc(var(--category-emoji-size) + (2 * var(--category-emoji-padding)))}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);border:0}.hidden{opacity:0;pointer-events:none}.abs-pos{position:absolute;left:0;top:0}.gone{display:none!important}.skintone-button-wrapper,.skintone-list{background:var(--background);z-index:3}.skintone-button-wrapper.expanded{z-index:1}.skintone-list{position:absolute;inset-inline-end:0;top:0;z-index:2;overflow:visible;border-bottom:var(--border-size) solid var(--border-color);border-radius:0 0 var(--skintone-border-radius) var(--skintone-border-radius);will-change:transform;transition:transform .2s ease-in-out;transform-origin:center 0}@media (prefers-reduced-motion:reduce){.skintone-list{transition-duration:.001s}}@supports not (inset-inline-end:0){.skintone-list{right:0}}.skintone-list.no-animate{transition:none}.tabpanel{overflow-y:auto;-webkit-overflow-scrolling:touch;will-change:transform;min-height:0;flex:1;contain:content}.emoji-menu{display:grid;grid-template-columns:repeat(var(--num-columns),var(--total-emoji-size));justify-content:space-around;align-items:flex-start;width:100%}.category{padding:var(--emoji-padding);font-size:var(--category-font-size);color:var(--category-font-color)}.custom-emoji,.emoji,button.emoji{height:var(--total-emoji-size);width:var(--total-emoji-size)}.emoji,button.emoji{font-size:var(--emoji-size);display:flex;align-items:center;justify-content:center;border-radius:100%;line-height:1;overflow:hidden;font-family:var(--emoji-font-family);cursor:pointer}@media (hover:hover) and (pointer:fine){.emoji:hover,button.emoji:hover{background:var(--button-hover-background)}}.emoji.active,.emoji:active,button.emoji.active,button.emoji:active{background:var(--button-active-background)}.custom-emoji{padding:var(--emoji-padding);object-fit:contain;pointer-events:none;background-repeat:no-repeat;background-position:center center;background-size:var(--emoji-size) var(--emoji-size)}.nav,.nav-button{align-items:center}.nav{display:grid;justify-content:space-between;contain:content}.nav-button{display:flex;justify-content:center}.nav-emoji{font-size:var(--category-emoji-size);width:var(--total-category-emoji-size);height:var(--total-category-emoji-size)}.indicator-wrapper{display:flex;border-bottom:1px solid var(--border-color)}.indicator{width:calc(100%/var(--num-groups));height:var(--indicator-height);opacity:var(--indicator-opacity);background-color:var(--indicator-color);will-change:transform,opacity;transition:opacity .1s linear,transform .25s ease-in-out}@media (prefers-reduced-motion:reduce){.indicator{will-change:opacity;transition:opacity .1s linear}}.pad-top,input.search{background:var(--background);width:100%}.pad-top{height:var(--emoji-padding);z-index:3}.search-row{display:flex;align-items:center;position:relative;padding-inline-start:var(--emoji-padding);padding-bottom:var(--emoji-padding)}.search-wrapper{flex:1;min-width:0}input.search{padding:var(--input-padding);border-radius:var(--input-border-radius);border:var(--input-border-size) solid var(--input-border-color);color:var(--input-font-color);font-size:var(--input-font-size);line-height:var(--input-line-height)}input.search::placeholder{color:var(--input-placeholder-color)}.favorites{display:flex;flex-direction:row;border-top:var(--border-size) solid var(--border-color);contain:content}.message{padding:var(--emoji-padding)}"+Lt,this.shadowRoot.appendChild(e),this._ctx={locale:"en",dataSource:"https://cdn.jsdelivr.net/npm/emoji-picker-element-data@^1/en/emojibase/data.json",skinToneEmoji:"🖐️",customCategorySorting:Z,customEmoji:null,i18n:At,emojiVersion:null,...t};for(const t of Rt)"database"!==t&&Object.prototype.hasOwnProperty.call(this,t)&&(this._ctx[t]=this[t],delete this[t]);this._dbFlush()}connectedCallback(){this._cmp||(this._cmp=wt(this.shadowRoot,this._ctx))}disconnectedCallback(){Et((()=>{if(!this.isConnected&&this._cmp){this._cmp.$destroy(),this._cmp=void 0;const{database:t}=this._ctx;t.close().catch((t=>console.error(t)))}}))}static get observedAttributes(){return["locale","data-source","skin-tone-emoji","emoji-version"]}attributeChangedCallback(t,e,i){this._set(t.replace(/-([a-z])/g,((t,e)=>e.toUpperCase())),"emoji-version"===t?parseFloat(i):i)}_set(t,e){this._ctx[t]=e,this._cmp&&this._cmp.$set({[t]:e}),["locale","dataSource"].includes(t)&&this._dbFlush()}_dbCreate(){const{locale:t,dataSource:e,database:i}=this._ctx;i&&i.locale===t&&i.dataSource===e||this._set("database",new K({locale:t,dataSource:e}))}_dbFlush(){Et((()=>this._dbCreate()))}}const Ct={};for(const t of Rt)Ct[t]={get(){return"database"===t&&this._dbCreate(),this._ctx[t]},set(e){if("database"===t)throw new Error("database is read-only");this._set(t,e)}};Object.defineProperties(It.prototype,Ct),customElements.get("emoji-picker")||customElements.define("emoji-picker",It)},3859:(t,e,i)=>{"use strict";function s(t){let e="";for(let i in t)t.hasOwnProperty(i)&&(e.length&&(e+="&"),e+=encodeURIComponent(i)+"="+encodeURIComponent(t[i]));return e}function n(t){let e={},i=t.split("&");for(let t=0,s=i.length;tn,c:()=>s})},1928:(t,e,i)=>{"use strict";i.d(e,{Q:()=>r});const s=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,n=179!=i.j?["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"]:null;function r(t){if(t.length>2e3)throw"URI too long";const e=t,i=t.indexOf("["),r=t.indexOf("]");-1!=i&&-1!=r&&(t=t.substring(0,i)+t.substring(i,r).replace(/:/g,";")+t.substring(r,t.length));let a=s.exec(t||""),o={},l=14;for(;l--;)o[n[l]]=a[l]||"";return-1!=i&&-1!=r&&(o.source=e,o.host=o.host.substring(1,o.host.length-1).replace(/;/g,":"),o.authority=o.authority.replace("[","").replace("]","").replace(/;/g,":"),o.ipv6uri=!0),o.pathNames=function(t,e){const i=e.replace(/\/{2,9}/g,"/").split("/");return"/"!=e.slice(0,1)&&0!==e.length||i.splice(0,1),"/"==e.slice(-1)&&i.splice(i.length-1,1),i}(0,o.path),o.queryKey=function(t,e){const i={};return e.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,(function(t,e,s){e&&(i[e]=s)})),i}(0,o.query),o}},3041:(t,e,i)=>{"use strict";i.d(e,{ZP:()=>io});const s=Number.isFinite||function(t){return"number"==typeof t&&isFinite(t)},n=Number.isSafeInteger||function(t){return"number"==typeof t&&Math.abs(t)<=r},r=Number.MAX_SAFE_INTEGER||9007199254740991;let a=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}({}),o=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.KEY_SYSTEM_DESTROY_MEDIA_KEYS_ERROR="keySystemDestroyMediaKeysError",t.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR="keySystemDestroyCloseSessionError",t.KEY_SYSTEM_DESTROY_REMOVE_SESSION_ERROR="keySystemDestroyRemoveSessionError",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.ASSET_LIST_LOAD_ERROR="assetListLoadError",t.ASSET_LIST_LOAD_TIMEOUT="assetListLoadTimeout",t.ASSET_LIST_PARSING_ERROR="assetListParsingError",t.INTERSTITIAL_ASSET_ITEM_ERROR="interstitialAssetItemError",t.INTERNAL_EXCEPTION="internalException",t.INTERNAL_ABORTED="aborted",t.ATTACH_MEDIA_ERROR="attachMediaError",t.UNKNOWN="unknown",t}({}),l=function(t){return t.MEDIA_ATTACHING="hlsMediaAttaching",t.MEDIA_ATTACHED="hlsMediaAttached",t.MEDIA_DETACHING="hlsMediaDetaching",t.MEDIA_DETACHED="hlsMediaDetached",t.MEDIA_ENDED="hlsMediaEnded",t.STALL_RESOLVED="hlsStallResolved",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.BUFFERED_TO_END="hlsBufferedToEnd",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.AUDIO_TRACK_UPDATED="hlsAudioTrackUpdated",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_TRACK_UPDATED="hlsSubtitleTrackUpdated",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.MAX_AUTO_LEVEL_UPDATED="hlsMaxAutoLevelUpdated",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.STEERING_MANIFEST_LOADED="hlsSteeringManifestLoaded",t.ASSET_LIST_LOADING="hlsAssetListLoading",t.ASSET_LIST_LOADED="hlsAssetListLoaded",t.INTERSTITIALS_UPDATED="hlsInterstitialsUpdated",t.INTERSTITIALS_BUFFERED_TO_BOUNDARY="hlsInterstitialsBufferedToBoundary",t.INTERSTITIAL_ASSET_PLAYER_CREATED="hlsInterstitialAssetPlayerCreated",t.INTERSTITIAL_STARTED="hlsInterstitialStarted",t.INTERSTITIAL_ASSET_STARTED="hlsInterstitialAssetStarted",t.INTERSTITIAL_ASSET_ENDED="hlsInterstitialAssetEnded",t.INTERSTITIAL_ASSET_ERROR="hlsInterstitialAssetError",t.INTERSTITIAL_ENDED="hlsInterstitialEnded",t.INTERSTITIALS_PRIMARY_RESUMED="hlsInterstitialsPrimaryResumed",t.PLAYOUT_LIMIT_REACHED="hlsPlayoutLimitReached",t.EVENT_CUE_ENTER="hlsEventCueEnter",t}({});var c="manifest",u="level",d="audioTrack",h="subtitleTrack",f="main",p="audio",g="subtitle";class m{constructor(t,e=0,i=0){this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=t,this.alpha_=t?Math.exp(Math.log(.5)/t):0,this.estimate_=e,this.totalWeight_=i}sample(t,e){const i=Math.pow(this.alpha_,t);this.estimate_=e*(1-i)+i*this.estimate_,this.totalWeight_+=t}getTotalWeight(){return this.totalWeight_}getEstimate(){if(this.alpha_){const t=1-Math.pow(this.alpha_,this.totalWeight_);if(t)return this.estimate_/t}return this.estimate_}}class y{constructor(t,e,i,s=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_=new m(t),this.fast_=new m(e),this.defaultTTFB_=s,this.ttfb_=new m(t)}update(t,e){const{slow_:i,fast_:s,ttfb_:n}=this;i.halfLife!==t&&(this.slow_=new m(t,i.getEstimate(),i.getTotalWeight())),s.halfLife!==e&&(this.fast_=new m(e,s.getEstimate(),s.getTotalWeight())),n.halfLife!==t&&(this.ttfb_=new m(t,n.getEstimate(),n.getTotalWeight()))}sample(t,e){const i=(t=Math.max(t,this.minDelayMs_))/1e3,s=8*e/i;this.fast_.sample(i,s),this.slow_.sample(i,s)}sampleTTFB(t){const e=t/1e3,i=Math.sqrt(2)*Math.exp(-Math.pow(e,2)/2);this.ttfb_.sample(i,Math.max(t,5))}canEstimate(){return this.fast_.getTotalWeight()>=this.minWeight_}getEstimate(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_}getEstimateTTFB(){return this.ttfb_.getTotalWeight()>=this.minWeight_?this.ttfb_.getEstimate():this.defaultTTFB_}get defaultEstimate(){return this.defaultEstimate_}destroy(){}}function v(t,e,i){return(e=function(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var s=i.call(t,e);if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t,"string");return"symbol"==typeof e?e:e+""}(e))in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function b(){return b=Object.assign?Object.assign.bind():function(t){for(var e=1;e`):S}(t,i)}const R=w(),L=R;function I(t=!0){if("undefined"!=typeof self)return(t||!self.MediaSource)&&self.ManagedMediaSource||self.MediaSource||self.WebKitMediaSource}function C(t,e){const i=Object.keys(t),s=Object.keys(e),n=i.length,r=s.length;return!n||!r||n===r&&!i.some((t=>-1===s.indexOf(t)))}function D(t,e=!1){if("undefined"!=typeof TextDecoder){const i=new TextDecoder("utf-8").decode(t);if(e){const t=i.indexOf("\0");return-1!==t?i.substring(0,t):i}return i.replace(/\0/g,"")}const i=t.length;let s,n,r,a="",o=0;for(;o>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:a+=String.fromCharCode(s);break;case 12:case 13:n=t[o++],a+=String.fromCharCode((31&s)<<6|63&n);break;case 14:n=t[o++],r=t[o++],a+=String.fromCharCode((15&s)<<12|(63&n)<<6|(63&r)<<0)}}return a}const x=function(t){let e="";for(let i=0;i1||1===e&&this.levelkeys[t[0]].encrypted)return!0}return!1}get programDateTime(){return null===this._programDateTime&&this.rawProgramDateTime&&(this.programDateTime=Date.parse(this.rawProgramDateTime)),this._programDateTime}set programDateTime(t){s(t)?this._programDateTime=t:this._programDateTime=this.rawProgramDateTime=null}get ref(){return q(this)?(this._ref||(this._ref={base:this.base,start:this.start,duration:this.duration,sn:this.sn,programDateTime:this.programDateTime}),this._ref):null}addStart(t){this.setStart(this.start+t)}setStart(t){this.start=t,this._ref&&(this._ref.start=t)}setDuration(t){this.duration=t,this._ref&&(this._ref.duration=t)}setKeyFormat(t){if(this.levelkeys){const e=this.levelkeys[t];e&&!this._decryptdata&&(this._decryptdata=e.getDecryptData(this.sn))}}abortRequests(){var t,e;null==(t=this.loader)||t.abort(),null==(e=this.keyLoader)||e.abort()}setElementaryStreamInfo(t,e,i,s,n,r=!1){const{elementaryStreams:a}=this,o=a[t];o?(o.startPTS=Math.min(o.startPTS,e),o.endPTS=Math.max(o.endPTS,i),o.startDTS=Math.min(o.startDTS,s),o.endDTS=Math.max(o.endDTS,n)):a[t]={startPTS:e,endPTS:i,startDTS:s,endDTS:n,partial:r}}}class W extends Y{constructor(t,e,i,s,n){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.duration=t.decimalFloatingPoint("DURATION"),this.gap=t.bool("GAP"),this.independent=t.bool("INDEPENDENT"),this.relurl=t.enumeratedString("URI"),this.fragment=e,this.index=s;const r=t.enumeratedString("BYTERANGE");r&&this.setByteRange(r,n),n&&(this.fragOffset=n.fragOffset+n.duration)}get start(){return this.fragment.start+this.fragOffset}get end(){return this.start+this.duration}get loaded(){const{elementaryStreams:t}=this;return!!(t.audio||t.video||t.audiovideo)}}function X(t,e){const i=Object.getPrototypeOf(t);if(i){return Object.getOwnPropertyDescriptor(i,e)||X(i,e)}}const J=Math.pow(2,32)-1,Q=[].push,Z={video:1,audio:2,id3:3,text:4};function tt(t){return String.fromCharCode.apply(null,t)}function et(t,e){const i=t[e]<<8|t[e+1];return i<0?65536+i:i}function it(t,e){const i=nt(t,e);return i<0?4294967296+i:i}function st(t,e){let i=it(t,e);return i*=Math.pow(2,32),i+=it(t,e+4),i}function nt(t,e){return t[e]<<24|t[e+1]<<16|t[e+2]<<8|t[e+3]}function rt(t,e,i){t[e]=i>>24,t[e+1]=i>>16&255,t[e+2]=i>>8&255,t[e+3]=255&i}function at(t,e){const i=[];if(!e.length)return i;const s=t.byteLength;for(let n=0;n1?n+r:s;if(tt(t.subarray(n+4,n+8))===e[0])if(1===e.length)i.push(t.subarray(n+8,a));else{const s=at(t.subarray(n+8,a),e.slice(1));s.length&&Q.apply(i,s)}n=a}return i}function ot(t){const e=[],i=t[0];let s=8;const n=it(t,s);s+=4;let r=0,a=0;0===i?(r=it(t,s),a=it(t,s+4),s+=8):(r=st(t,s),a=st(t,s+8),s+=16),s+=2;let o=t.length+a;const l=et(t,s);s+=2;for(let i=0;i>>31)return L.warn("SIDX has hierarchical references (not supported)"),null;const l=it(t,i);i+=4,e.push({referenceSize:a,subsegmentDuration:l,info:{duration:l/n,start:o,end:o+a-1}}),o+=a,i+=4,s=i}return{earliestPresentationTime:r,timescale:n,version:i,referencesCount:l,references:e}}function lt(t){const e=[],i=at(t,["moov","trak"]);for(let t=0;t{const i=it(t,4),s=e[i];s&&(s.default={duration:it(t,12),flags:it(t,20)})})),e}function ct(t){const e=t.subarray(8),i=e.subarray(86),s=tt(e.subarray(4,8));let n,r=s;const a="enca"===s||"encv"===s;if(a){const t=at(e,[s])[0];at(t.subarray("enca"===s?28:78),["sinf"]).forEach((t=>{const e=at(t,["schm"])[0];if(e){const i=tt(e.subarray(4,8));if("cbcs"===i||"cenc"===i){const e=at(t,["frma"])[0];e&&(r=tt(e))}}}))}const o=r;switch(r){case"avc1":case"avc2":case"avc3":case"avc4":{const t=at(i,["avcC"])[0];t&&t.length>3&&(r+="."+ht(t[1])+ht(t[2])+ht(t[3]),n=ut("avc1"===o?"dva1":"dvav",i));break}case"mp4a":{const t=at(e,[s])[0],i=at(t.subarray(28),["esds"])[0];if(i&&i.length>7){let t=4;if(3!==i[t++])break;t=dt(i,t),t+=2;const e=i[t++];if(128&e&&(t+=2),64&e&&(t+=i[t++]),4!==i[t++])break;t=dt(i,t);const s=i[t++];if(64!==s)break;if(r+="."+ht(s),t+=12,5!==i[t++])break;t=dt(i,t);const n=i[t++];let a=(248&n)>>3;31===a&&(a+=1+((7&n)<<3)+((224&i[t])>>5)),r+="."+a}break}case"hvc1":case"hev1":{const t=at(i,["hvcC"])[0];if(t&&t.length>12){const e=t[1],i=["","A","B","C"][e>>6],s=31&e,n=it(t,2),a=(32&e)>>5?"H":"L",o=t[12],l=t.subarray(6,12);r+="."+i+s,r+="."+n.toString(16).toUpperCase(),r+="."+a+o;let c="";for(let t=l.length;t--;){const e=l[t];(e||c)&&(c="."+e.toString(16).toUpperCase()+c)}r+=c}n=ut("hev1"==o?"dvhe":"dvh1",i);break}case"dvh1":case"dvhe":case"dvav":case"dva1":case"dav1":r=ut(r,i)||r;break;case"vp09":{const t=at(i,["vpcC"])[0];if(t&&t.length>6){const e=t[4],i=t[5],s=t[6]>>4&15;r+="."+ft(e)+"."+ft(i)+"."+ft(s)}break}case"av01":{const t=at(i,["av1C"])[0];if(t&&t.length>2){const e=t[1]>>>5,s=31&t[1],a=t[2]>>>7?"H":"M",o=(64&t[2])>>6,l=(32&t[2])>>5,c=2===e&&o?l?12:10:o?10:8,u=(16&t[2])>>4,d=(8&t[2])>>3,h=(4&t[2])>>2,f=3&t[2],p=1,g=1,m=1,y=0;r+="."+e+"."+ft(s)+a+"."+ft(c)+"."+u+"."+d+h+f+"."+ft(p)+"."+ft(g)+"."+ft(m)+"."+y,n=ut("dav1",i)}break}}return{codec:r,encrypted:a,supplemental:n}}function ut(t,e){const i=at(e,["dvvC"]),s=i.length?i[0]:at(e,["dvcC"])[0];if(s){const e=s[2]>>1&127,i=s[2]<<5&32|s[3]>>3&31;return t+"."+ft(e)+"."+ft(i)}}function dt(t,e){const i=e+5;for(;128&t[e++]&&e{const l=o.byteOffset-8;at(o,["traf"]).map((o=>{const c=at(o,["tfdt"]).map((t=>{const e=t[0];let i=it(t,4);return 1===e&&(i*=Math.pow(2,32),i+=it(t,8)),i/n}))[0];return void 0!==c&&(t=c),at(o,["tfhd"]).map((c=>{const u=it(c,4),d=16777215&it(c,0);let h=0;const f=0!=(16&d);let p=0;const g=0!=(32&d);let m=8;u===r&&(0!=(1&d)&&(m+=8),0!=(2&d)&&(m+=4),0!=(8&d)&&(h=it(c,m),m+=4),f&&(p=it(c,m),m+=4),g&&(m+=4),"video"===e.type&&(a=vt(e.codec)),at(o,["trun"]).map((r=>{const o=r[0],c=16777215&it(r,0),u=0!=(1&c);let d=0;const f=0!=(4&c),g=0!=(256&c);let m=0;const y=0!=(512&c);let v=0;const b=0!=(1024&c),_=0!=(2048&c);let E=0;const T=it(r,4);let S=8;u&&(d=it(r,S),S+=4),f&&(S+=4);let k=d+l;for(let l=0;l>1&63;return 39===t||40===t}return 6==(31&e)}function _t(t,e,i,s){const n=Et(t);let r=0;r+=e;let a=0,o=0,l=0;for(;r=n.length)break;l=n[r++],a+=l}while(255===l);o=0;do{if(r>=n.length)break;l=n[r++],o+=l}while(255===l);const t=n.length-r;let e=r;if(ot){L.error(`Malformed SEI payload. ${o} is too small, only ${t} bytes left to parse.`);break}if(4===a){if(181===n[e++]){const t=et(n,e);if(e+=2,49===t){const t=it(n,e);if(e+=4,1195456820===t){const t=n[e++];if(3===t){const r=n[e++],o=64&r,l=o?2+3*(31&r):0,c=new Uint8Array(l);if(o){c[0]=r;for(let t=1;t16){const t=[];for(let i=0;i<16;i++){const s=n[e++].toString(16);t.push(1==s.length?"0"+s:s),3!==i&&5!==i&&7!==i&&9!==i||t.push("-")}const r=o-16,l=new Uint8Array(r);for(let t=0;t>>24;if(0!==n&&1!==n)return{offset:i,size:e};const r=t.buffer,a=x(new Uint8Array(r,i+12,16)),o=t.getUint32(28);let l=null,c=null;if(0===n){if(e-32/\(Windows.+Firefox\//i.test(navigator.userAgent),kt={audio:{a3ds:1,"ac-3":.95,"ac-4":1,alac:.9,alaw:1,dra1:1,"dts+":1,"dts-":1,dtsc:1,dtse:1,dtsh:1,"ec-3":.9,enca:1,fLaC:.9,flac:.9,FLAC:.9,g719:1,g726:1,m4ae:1,mha1:1,mha2:1,mhm1:1,mhm2:1,mlpa:1,mp4a:1,"raw ":1,Opus:1,opus:1,samr:1,sawb:1,sawp:1,sevc:1,sqcp:1,ssmv:1,twos:1,ulaw:1},video:{avc1:1,avc2:1,avc3:1,avc4:1,avcp:1,av01:.8,dav1:.8,drac:1,dva1:1,dvav:1,dvh1:.7,dvhe:.7,encv:1,hev1:.75,hvc1:.75,mjp2:1,mp4v:1,mvc1:1,mvc2:1,mvc3:1,mvc4:1,resv:1,rv60:1,s263:1,svc1:1,svc2:1,"vc-1":1,vp08:1,vp09:.9},text:{stpp:1,wvtt:1}};function wt(t,e){const i=kt[e];return!!i&&!!i[t.slice(0,4)]}function At(t,e,i=!0){return!t.split(",").some((t=>!Rt(t,e,i)))}function Rt(t,e,i=!0){var s;const n=I(i);return null!=(s=null==n?void 0:n.isTypeSupported(Lt(t,e)))&&s}function Lt(t,e){return`${e}/mp4;codecs=${t}`}function It(t){if(t){const e=t.substring(0,4);return kt.video[e]}return 2}function Ct(t){const e=St();return t.split(",").reduce(((t,i)=>{const s=e&&vt(i)?9:kt.video[i];return s?(2*s+t)/(t?3:2):(kt.audio[i]+t)/(t?2:1)}),0)}const Dt={},xt=/flac|opus|mp4a\.40\.34/i;function Pt(t,e=!0){return t.replace(xt,(t=>function(t,e=!0){if(Dt[t])return Dt[t];const i={flac:["flac","fLaC","FLAC"],opus:["opus","Opus"],"mp4a.40.34":["mp3"]}[t];for(let n=0;n4||-1!==["ac-3","ec-3","alac","fLaC","Opus"].indexOf(t)))return t;if(e){const i=e.split(",");if(i.length>1){if(t)for(let e=i.length;e--;)if(i[e].substring(0,4)===t.substring(0,4))return i[e];return i[0]}}return e||t}function Nt(t){if(t.startsWith("av01.")){const e=t.split("."),i=["0","111","01","01","01","0"];for(let t=e.length;t>4&&t<10;t++)e[t]=i[t-4];return e.join(".")}return t}function Mt(t){const e=I(t)||{isTypeSupported:()=>!1};return{mpeg:e.isTypeSupported("audio/mpeg"),mp3:e.isTypeSupported('audio/mp4; codecs="mp3"'),ac3:e.isTypeSupported('audio/mp4; codecs="ac-3"')}}function Ft(t){return t.replace(/^.+codecs=["']?([^"']+).*$/,"$1")}const $t={supported:!0,configurations:[],decodingInfoResults:[{supported:!0,powerEfficient:!0,smooth:!0}]};function Ut(t,e){return{supported:!1,configurations:e,decodingInfoResults:[{supported:!1,smooth:!1,powerEfficient:!1}],error:t}}const Bt={};function jt(t,e,i,n,r,a){const o=t.audioCodec?t.audioGroups:null,l=null==a?void 0:a.audioCodec,c=null==a?void 0:a.channels,u=c?parseInt(c):l?1/0:2;let d=null;if(null!=o&&o.length)try{d=1===o.length&&o[0]?e.groups[o[0]].channels:o.reduce(((t,i)=>{if(i){const s=e.groups[i];if(!s)throw new Error(`Audio track group ${i} not found`);Object.keys(s.channels).forEach((e=>{t[e]=(t[e]||0)+s.channels[e]}))}return t}),{2:0})}catch(t){return!0}return void 0!==t.videoCodec&&(t.width>1920&&t.height>1088||t.height>1920&&t.width>1088||t.frameRate>Math.max(n,30)||"SDR"!==t.videoRange&&t.videoRange!==i||t.bitrate>Math.max(r,8e6))||!!d&&s(u)&&Object.keys(d).some((t=>parseInt(t)>u))}function Gt(t,e,i){const n=t.videoCodec,r=t.audioCodec;if(!n&&!r||!i)return Promise.resolve($t);const a=[];if(n){const e={width:t.width,height:t.height,bitrate:Math.ceil(Math.max(.9*t.bitrate,t.averageBitrate)),framerate:t.frameRate||30},i=t.videoRange;"SDR"!==i&&(e.transferFunction=i.toLowerCase());const s=n.split(","),r=navigator.userAgent;if(s.some((t=>vt(t)))&&St())return Promise.resolve(Ut(new Error(`Overriding Windows Firefox HEVC MediaCapabilities result based on user-agent sting: (${r})`),a));a.push.apply(a,s.map((t=>({type:"media-source",video:E(E({},e),{},{contentType:Lt(Nt(t),"video")})}))))}return r&&t.audioGroups&&t.audioGroups.forEach((t=>{var i;t&&(null==(i=e.groups[t])||i.tracks.forEach((e=>{if(e.groupId===t){const t=e.channels||"",i=parseFloat(t);s(i)&&i>2&&a.push.apply(a,r.split(",").map((t=>({type:"media-source",audio:{contentType:Lt(t,"audio"),channels:""+i}}))))}})))})),Promise.all(a.map((t=>{const e=function(t){const{audio:e,video:i}=t,s=i||e;if(s){const t=Ft(s.contentType);if(i)return`r${i.height}x${i.width}f${Math.ceil(i.framerate)}${i.transferFunction||"sd"}_${t}_${Math.ceil(i.bitrate/1e5)}`;if(e)return`c${e.channels}${e.spatialRendering?"s":"n"}_${t}`}return""}(t);return Bt[e]||(Bt[e]=i.decodingInfo(t))}))).then((t=>({supported:!t.some((t=>!t.supported)),configurations:a,decodingInfoResults:t}))).catch((t=>({supported:!1,configurations:a,decodingInfoResults:[],error:t})))}const Vt=["NONE","TYPE-0","TYPE-1",null],Ht=["SDR","PQ","HLG"];function Kt(t){const{canSkipUntil:e,canSkipDateRanges:i,age:s}=t;return e&&s!!t)).map((t=>t.substring(0,4))).join(","),"supplemental"in t){var e;this.supplemental=t.supplemental;const i=null==(e=t.supplemental)?void 0:e.videoCodec;i&&i!==t.videoCodec&&(this.codecSet+=`,${i.substring(0,4)}`)}this.addGroupId("audio",t.attrs.AUDIO),this.addGroupId("text",t.attrs.SUBTITLES)}get maxBitrate(){return Math.max(this.realBitrate,this.bitrate)}get averageBitrate(){return this._avgBitrate||this.realBitrate||this.bitrate}get attrs(){return this._attrs[0]}get codecs(){return this.attrs.CODECS||""}get pathwayId(){return this.attrs["PATHWAY-ID"]||"."}get videoRange(){return this.attrs["VIDEO-RANGE"]||"SDR"}get score(){return this.attrs.optionalFloat("SCORE",0)}get uri(){return this.url[0]||""}hasAudioGroup(t){return zt(this._audioGroups,t)}hasSubtitleGroup(t){return zt(this._subtitleGroups,t)}get audioGroups(){return this._audioGroups}get subtitleGroups(){return this._subtitleGroups}addGroupId(t,e){if(e)if("audio"===t){let t=this._audioGroups;t||(t=this._audioGroups=[]),-1===t.indexOf(e)&&t.push(e)}else if("text"===t){let t=this._subtitleGroups;t||(t=this._subtitleGroups=[]),-1===t.indexOf(e)&&t.push(e)}}get urlId(){return 0}set urlId(t){}get audioGroupIds(){return this.audioGroups?[this.audioGroupId]:void 0}get textGroupIds(){return this.subtitleGroups?[this.textGroupId]:void 0}get audioGroupId(){var t;return null==(t=this.audioGroups)?void 0:t[0]}get textGroupId(){var t;return null==(t=this.subtitleGroups)?void 0:t[0]}addFallback(){}}function zt(t,e){return!(!e||!t)&&-1!==t.indexOf(e)}const Wt=(t,e)=>JSON.stringify(t,(t=>{const e=new WeakSet;return(i,s)=>{if(t&&(s=t(i,s)),"object"==typeof s&&null!==s){if(e.has(s))return;e.add(s)}return s}})(e));function Xt(t,e){L.log(`[abr] start candidates with "${t}" ignored because ${e}`)}function Jt(t){return t.reduce(((t,e)=>{let i=t.groups[e.groupId];i||(i=t.groups[e.groupId]={tracks:[],channels:{2:0},hasDefault:!1,hasAutoSelect:!1}),i.tracks.push(e);const s=e.channels||"2";return i.channels[s]=(i.channels[s]||0)+1,i.hasDefault=i.hasDefault||e.default,i.hasAutoSelect=i.hasAutoSelect||e.autoselect,i.hasDefault&&(t.hasDefaultAudio=!0),i.hasAutoSelect&&(t.hasAutoSelectAudio=!0),t}),{hasDefaultAudio:!1,hasAutoSelectAudio:!1,groups:{}})}function Qt(t){if(!t)return t;const{lang:e,assocLang:i,characteristics:s,channels:n,audioCodec:r}=t;return{lang:e,assocLang:i,characteristics:s,channels:n,audioCodec:r}}function Zt(t,e,i){if("attrs"in t){const i=e.indexOf(t);if(-1!==i)return i}for(let s=0;s-1===s.indexOf(t)))}(t.characteristics||"",e.characteristics))&&(void 0===i||i(t,e))}function ee(t,e){const{audioCodec:i,channels:s}=t;return!(void 0!==i&&(e.audioCodec||"").substring(0,4)!==i.substring(0,4)||void 0!==s&&s!==(e.channels||"2"))}function ie(t,e,i){for(let s=e;s>-1;s--)if(i(t[s]))return s;for(let s=e+1;s0)i=n+1;else{if(!(a<0))return r;s=n-1}}return null};function re(t,e,i=0,s=0,n=.005){let r=null;if(t){r=e[1+t.sn-e[0].sn]||null;const s=t.endDTS-i;s>0&&s<15e-7&&(i+=15e-7),r&&t.level!==r.level&&r.end<=t.end&&(r=e[2+t.sn-e[0].sn]||null)}else 0===i&&0===e[0].start&&(r=e[0]);if(r&&((!t||t.level===r.level)&&0===ae(i,s,r)||function(t,e,i){if(e&&0===e.start&&e.level0){const s=e.tagList.reduce(((t,e)=>("INF"===e[0]&&(t+=parseFloat(e[1])),t)),i);return t.start<=s}return!1}(r,t,Math.min(n,s))))return r;const a=ne(e,ae.bind(null,i,s));return!a||a===t&&r?r:a}function ae(t=0,e=0,i){if(i.start<=t&&i.start+i.duration>t)return 0;const s=Math.min(e,i.duration+(i.deltaPTS?i.deltaPTS:0));return i.start+i.duration-s<=t?1:i.start-s>t&&i.start?-1:0}function oe(t,e,i){const s=1e3*Math.min(e,i.duration+(i.deltaPTS?i.deltaPTS:0));return(i.endProgramDateTime||0)-s>t}function le(t,e){return ne(t,(t=>t.cce?-1:0))}function ce(t){switch(t.details){case o.FRAG_LOAD_TIMEOUT:case o.KEY_LOAD_TIMEOUT:case o.LEVEL_LOAD_TIMEOUT:case o.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function ue(t,e){const i=ce(e);return t.default[(i?"timeout":"error")+"Retry"]}function de(t,e){const i="linear"===t.backoff?1:Math.pow(2,e);return Math.min(i*t.retryDelayMs,t.maxRetryDelayMs)}function he(t){return E(E({},t),{errorRetry:null,timeoutRetry:null})}function fe(t,e,i,s){if(!t)return!1;const n=null==s?void 0:s.code,r=e499)}(n)||!!i);return t.shouldRetry?t.shouldRetry(t,e,i,s,r):r}function pe(t){const e={action:0,flags:0};return t&&(e.resolved=!0),e}var ge="NOT_LOADED",me="APPENDING",ye="PARTIAL",ve="OK";class be{constructor(t){this.activePartLists=Object.create(null),this.endListFragments=Object.create(null),this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hasGaps=!1,this.hls=t,this._registerListeners()}_registerListeners(){const{hls:t}=this;t.on(l.MANIFEST_LOADING,this.onManifestLoading,this),t.on(l.BUFFER_APPENDED,this.onBufferAppended,this),t.on(l.FRAG_BUFFERED,this.onFragBuffered,this),t.on(l.FRAG_LOADED,this.onFragLoaded,this)}_unregisterListeners(){const{hls:t}=this;t.off(l.MANIFEST_LOADING,this.onManifestLoading,this),t.off(l.BUFFER_APPENDED,this.onBufferAppended,this),t.off(l.FRAG_BUFFERED,this.onFragBuffered,this),t.off(l.FRAG_LOADED,this.onFragLoaded,this)}destroy(){this._unregisterListeners(),this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null}getAppendedFrag(t,e){const i=this.activePartLists[e];if(i)for(let e=i.length;e--;){const s=i[e];if(!s)break;const n=s.end;if(s.start<=t&&null!==n&&t<=n)return s}return this.getBufferedFrag(t,e)}getBufferedFrag(t,e){return this.getFragAtPos(t,e,!0)}getFragAtPos(t,e,i){const{fragments:s}=this,n=Object.keys(s);for(let r=n.length;r--;){const a=s[n[r]];if((null==a?void 0:a.body.type)===e&&(!i||a.buffered)){const e=a.body;if(e.start<=t&&t<=e.end)return e}}return null}detectEvictedFragments(t,e,i,s,n){this.timeRanges&&(this.timeRanges[t]=e);const r=(null==s?void 0:s.fragment.sn)||-1;Object.keys(this.fragments).forEach((s=>{const a=this.fragments[s];if(!a)return;if(r>=a.body.sn)return;if(!a.buffered&&(!a.loaded||n))return void(a.body.type===i&&this.removeFragment(a.body));const o=a.range[t];o&&(0!==o.time.length?o.time.some((t=>{const i=!this.isTimeBuffered(t.startPTS,t.endPTS,e);return i&&this.removeFragment(a.body),i})):this.removeFragment(a.body))}))}detectPartialFragments(t){const e=this.timeRanges;if(!e||"initSegment"===t.frag.sn)return;const i=t.frag,s=Ee(i),n=this.fragments[s];if(!n||n.buffered&&i.gap)return;const r=!i.relurl;Object.keys(e).forEach((s=>{const a=i.elementaryStreams[s];if(!a)return;const o=e[s],l=r||!0===a.partial;n.range[s]=this.getBufferedTimes(i,t.part,l,o)})),n.loaded=null,Object.keys(n.range).length?(n.buffered=!0,(n.body.endList=i.endList||n.body.endList)&&(this.endListFragments[n.body.type]=n),_e(n)||this.removeParts(i.sn-1,i.type)):this.removeFragment(n.body)}removeParts(t,e){const i=this.activePartLists[e];i&&(this.activePartLists[e]=i.filter((e=>e.fragment.sn>=t)))}fragBuffered(t,e){const i=Ee(t);let s=this.fragments[i];!s&&e&&(s=this.fragments[i]={body:t,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},t.gap&&(this.hasGaps=!0)),s&&(s.loaded=null,s.buffered=!0)}getBufferedTimes(t,e,i,s){const n={time:[],partial:i},r=t.start,a=t.end,o=t.minEndPTS||a,l=t.maxStartPTS||r;for(let t=0;t=e&&o<=i){n.time.push({startPTS:Math.max(r,s.start(t)),endPTS:Math.min(a,s.end(t))});break}if(re){const e=Math.max(r,s.start(t)),i=Math.min(a,s.end(t));i>e&&(n.partial=!0,n.time.push({startPTS:e,endPTS:i}))}else if(a<=e)break}return n}getPartialFragment(t){let e,i,s,n=null,r=0;const{bufferPadding:a,fragments:o}=this;return Object.keys(o).forEach((l=>{const c=o[l];c&&_e(c)&&(i=c.body.start-a,s=c.body.end+a,t>=i&&t<=s&&(e=Math.min(t-i,s-t),r<=e&&(n=c.body,r=e)))})),n}isEndListAppended(t){const e=this.endListFragments[t];return void 0!==e&&(e.buffered||_e(e))}getState(t){const e=Ee(t),i=this.fragments[e];return i?i.buffered?_e(i)?ye:ve:me:ge}isTimeBuffered(t,e,i){let s,n;for(let r=0;r=s&&e<=n)return!0;if(e<=s)return!1}return!1}onManifestLoading(){this.removeAllFragments()}onFragLoaded(t,e){if("initSegment"===e.frag.sn||e.frag.bitrateTest)return;const i=e.frag,s=e.part?null:e,n=Ee(i);this.fragments[n]={body:i,appendedPTS:null,loaded:s,buffered:!1,range:Object.create(null)}}onBufferAppended(t,e){const{frag:i,part:s,timeRanges:n,type:r}=e;if("initSegment"===i.sn)return;const a=i.type;if(s){let t=this.activePartLists[a];t||(this.activePartLists[a]=t=[]),t.push(s)}this.timeRanges=n;const o=n[r];this.detectEvictedFragments(r,o,a,s)}onFragBuffered(t,e){this.detectPartialFragments(e)}hasFragment(t){const e=Ee(t);return!!this.fragments[e]}hasFragments(t){const{fragments:e}=this,i=Object.keys(e);if(!t)return i.length>0;for(let s=i.length;s--;){const n=e[i[s]];if((null==n?void 0:n.body.type)===t)return!0}return!1}hasParts(t){var e;return!(null==(e=this.activePartLists[t])||!e.length)}removeFragmentsInRange(t,e,i,s,n){s&&!this.hasGaps||Object.keys(this.fragments).forEach((r=>{const a=this.fragments[r];if(!a)return;const o=a.body;o.type!==i||s&&!o.gap||o.startt&&(a.buffered||n)&&this.removeFragment(o)}))}removeFragment(t){const e=Ee(t);t.clearElementaryStreamInfo();const i=this.activePartLists[t.type];if(i){const e=t.sn;this.activePartLists[t.type]=i.filter((t=>t.fragment.sn!==e))}delete this.fragments[e],t.endList&&delete this.endListFragments[t.type]}removeAllFragments(){var t,e;this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=!1;const i=null==(t=this.hls)||null==(e=t.latestLevelDetails)?void 0:e.partList;i&&i.forEach((t=>t.clearElementaryStreamInfo()))}}function _e(t){var e,i,s;return t.buffered&&(t.body.gap||(null==(e=t.range.video)?void 0:e.partial)||(null==(i=t.range.audio)?void 0:i.partial)||(null==(s=t.range.audiovideo)?void 0:s.partial))}function Ee(t){return`${t.type}_${t.level}_${t.sn}`}class Te{constructor(t,e,i){this.subtle=void 0,this.aesIV=void 0,this.aesMode=void 0,this.subtle=t,this.aesIV=e,this.aesMode=i}decrypt(t,e){switch(this.aesMode){case 0:return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},e,t);case 1:return this.subtle.decrypt({name:"AES-CTR",counter:this.aesIV,length:64},e,t);default:throw new Error(`[AESCrypto] invalid aes mode ${this.aesMode}`)}}}class Se{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_(t){const e=new DataView(t),i=new Uint32Array(4);for(let t=0;t<4;t++)i[t]=e.getUint32(4*t);return i}initTable(){const t=this.sBox,e=this.invSBox,i=this.subMix,s=i[0],n=i[1],r=i[2],a=i[3],o=this.invSubMix,l=o[0],c=o[1],u=o[2],d=o[3],h=new Uint32Array(256);let f=0,p=0,g=0;for(g=0;g<256;g++)h[g]=g<128?g<<1:g<<1^283;for(g=0;g<256;g++){let i=p^p<<1^p<<2^p<<3^p<<4;i=i>>>8^255&i^99,t[f]=i,e[i]=f;const o=h[f],g=h[o],m=h[g];let y=257*h[i]^16843008*i;s[f]=y<<24|y>>>8,n[f]=y<<16|y>>>16,r[f]=y<<8|y>>>24,a[f]=y,y=16843009*m^65537*g^257*o^16843008*f,l[i]=y<<24|y>>>8,c[i]=y<<16|y>>>16,u[i]=y<<8|y>>>24,d[i]=y,f?(f=o^h[h[h[m^o]]],p^=h[h[p]]):f=p=1}}expandKey(t){const e=this.uint8ArrayToUint32Array_(t);let i=!0,s=0;for(;s{const a=ArrayBuffer.isView(t)?t:new Uint8Array(t);this.softwareDecrypt(a,e,i,s);const o=this.flush();o?n(o.buffer):r(new Error("[softwareDecrypt] Failed to decrypt data"))})):this.webCryptoDecrypt(new Uint8Array(t),e,i,s)}softwareDecrypt(t,e,i,s){const{currentIV:n,currentResult:r,remainderData:a}=this;if(0!==s||16!==e.byteLength)return L.warn("SoftwareDecrypt: can only handle AES-128-CBC"),null;this.logOnce("JS AES decrypt"),a&&(t=mt(a,t),this.remainderData=null);const o=this.getValidChunk(t);if(!o.length)return null;n&&(i=n);let l=this.softwareDecrypter;l||(l=this.softwareDecrypter=new Se),l.expandKey(e);const c=r;return this.currentResult=l.decrypt(o.buffer,0,i),this.currentIV=o.slice(-16).buffer,c||null}webCryptoDecrypt(t,e,i,s){if(this.key!==e||!this.fastAesKey){if(!this.subtle)return Promise.resolve(this.onWebCryptoError(t,e,i,s));this.key=e,this.fastAesKey=new ke(this.subtle,e,s)}return this.fastAesKey.expandKey().then((e=>this.subtle?(this.logOnce("WebCrypto AES decrypt"),new Te(this.subtle,new Uint8Array(i),s).decrypt(t.buffer,e)):Promise.reject(new Error("web crypto not initialized")))).catch((n=>(L.warn(`[decrypter]: WebCrypto Error, disable WebCrypto API, ${n.name}: ${n.message}`),this.onWebCryptoError(t,e,i,s))))}onWebCryptoError(t,e,i,s){const n=this.enableSoftwareAES;if(n){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(t,e,i,s);const n=this.flush();if(n)return n.buffer}throw new Error("WebCrypto"+(n?" and softwareDecrypt":"")+": failed to decrypt data")}getValidChunk(t){let e=t;const i=t.length-t.length%16;return i!==t.length&&(e=t.slice(0,i),this.remainderData=t.slice(i)),e}logOnce(t){this.logEnabled&&(L.log(`[decrypter]: ${t}`),this.logEnabled=!1)}}const Ae=Math.pow(2,17);class Re{constructor(t){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=t}destroy(){this.loader&&(this.loader.destroy(),this.loader=null)}abort(){this.loader&&this.loader.abort()}load(t,e){const i=t.url;if(!i)return Promise.reject(new Ce({type:a.NETWORK_ERROR,details:o.FRAG_LOAD_ERROR,fatal:!1,frag:t,error:new Error("Fragment does not have a "+(i?"part list":"url")),networkDetails:null}));this.abort();const s=this.config,n=s.fLoader,r=s.loader;return new Promise(((l,c)=>{if(this.loader&&this.loader.destroy(),t.gap){if(t.tagList.some((t=>"GAP"===t[0])))return void c(Ie(t));t.gap=!1}const u=this.loader=n?new n(s):new r(s),d=Le(t);t.loader=u;const h=he(s.fragLoadPolicy.default),f={loadPolicy:h,timeout:h.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:"initSegment"===t.sn?1/0:Ae};t.stats=u.stats;const p={onSuccess:(e,i,s,n)=>{this.resetLoader(t,u);let r=e.data;s.resetIV&&t.decryptdata&&(t.decryptdata.iv=new Uint8Array(r.slice(0,16)),r=r.slice(16)),l({frag:t,part:null,payload:r,networkDetails:n})},onError:(e,s,n,r)=>{this.resetLoader(t,u),c(new Ce({type:a.NETWORK_ERROR,details:o.FRAG_LOAD_ERROR,fatal:!1,frag:t,response:E({url:i,data:void 0},e),error:new Error(`HTTP Error ${e.code} ${e.text}`),networkDetails:n,stats:r}))},onAbort:(e,i,s)=>{this.resetLoader(t,u),c(new Ce({type:a.NETWORK_ERROR,details:o.INTERNAL_ABORTED,fatal:!1,frag:t,error:new Error("Aborted"),networkDetails:s,stats:e}))},onTimeout:(e,i,s)=>{this.resetLoader(t,u),c(new Ce({type:a.NETWORK_ERROR,details:o.FRAG_LOAD_TIMEOUT,fatal:!1,frag:t,error:new Error(`Timeout after ${f.timeout}ms`),networkDetails:s,stats:e}))}};e&&(p.onProgress=(i,s,n,r)=>e({frag:t,part:null,payload:n,networkDetails:r})),u.load(d,f,p)}))}loadPart(t,e,i){this.abort();const s=this.config,n=s.fLoader,r=s.loader;return new Promise(((l,c)=>{if(this.loader&&this.loader.destroy(),t.gap||e.gap)return void c(Ie(t,e));const u=this.loader=n?new n(s):new r(s),d=Le(t,e);t.loader=u;const h=he(s.fragLoadPolicy.default),f={loadPolicy:h,timeout:h.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:Ae};e.stats=u.stats,u.load(d,f,{onSuccess:(s,n,r,a)=>{this.resetLoader(t,u),this.updateStatsFromPart(t,e);const o={frag:t,part:e,payload:s.data,networkDetails:a};i(o),l(o)},onError:(i,s,n,r)=>{this.resetLoader(t,u),c(new Ce({type:a.NETWORK_ERROR,details:o.FRAG_LOAD_ERROR,fatal:!1,frag:t,part:e,response:E({url:d.url,data:void 0},i),error:new Error(`HTTP Error ${i.code} ${i.text}`),networkDetails:n,stats:r}))},onAbort:(i,s,n)=>{t.stats.aborted=e.stats.aborted,this.resetLoader(t,u),c(new Ce({type:a.NETWORK_ERROR,details:o.INTERNAL_ABORTED,fatal:!1,frag:t,part:e,error:new Error("Aborted"),networkDetails:n,stats:i}))},onTimeout:(i,s,n)=>{this.resetLoader(t,u),c(new Ce({type:a.NETWORK_ERROR,details:o.FRAG_LOAD_TIMEOUT,fatal:!1,frag:t,part:e,error:new Error(`Timeout after ${f.timeout}ms`),networkDetails:n,stats:i}))}})}))}updateStatsFromPart(t,e){const i=t.stats,s=e.stats,n=s.total;if(i.loaded+=s.loaded,n){const s=Math.round(t.duration/e.duration),r=Math.min(Math.round(i.loaded/n),s),a=(s-r)*Math.round(i.loaded/r);i.total=i.loaded+a}else i.total=Math.max(i.loaded,i.total);const r=i.loading,a=s.loading;r.start?r.first+=a.first-a.start:(r.start=a.start,r.first=a.first),r.end=a.end}resetLoader(t,e){t.loader=null,this.loader===e&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),e.destroy()}}function Le(t,e=null){const i=e||t,n={frag:t,part:e,responseType:"arraybuffer",url:i.url,headers:{},rangeStart:0,rangeEnd:0},r=i.byteRangeStartOffset,a=i.byteRangeEndOffset;if(s(r)&&s(a)){var o;let e=r,i=a;if("initSegment"===t.sn&&("AES-128"===(l=null==(o=t.decryptdata)?void 0:o.method)||"AES-256"===l)){const t=a-r;t%16&&(i=a+(16-t%16)),0!==r&&(n.resetIV=!0,e=r-16)}n.rangeStart=e,n.rangeEnd=i}var l;return n}function Ie(t,e){const i=new Error(`GAP ${t.gap?"tag":"attribute"} found`),s={type:a.MEDIA_ERROR,details:o.FRAG_GAP,fatal:!1,frag:t,error:i,networkDetails:null};return e&&(s.part=e),(e||t).stats.aborted=!0,new Ce(s)}class Ce extends Error{constructor(t){super(t.error.message),this.data=void 0,this.data=t}}class De extends T{constructor(t,e){super(t,e),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(t){return!this._tickInterval&&(this._tickCallCount=0,this._tickInterval=self.setInterval(this._boundTick,t),!0)}clearInterval(){return!!this._tickInterval&&(self.clearInterval(this._tickInterval),this._tickInterval=null,!0)}clearNextTick(){return!!this._tickTimer&&(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0)}tick(){this._tickCallCount++,1===this._tickCallCount&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)}tickImmediate(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)}doTick(){}}class xe{constructor(t,e,i,s=0,n=-1,r=!1){this.level=void 0,this.sn=void 0,this.part=void 0,this.id=void 0,this.size=void 0,this.partial=void 0,this.transmuxing={start:0,executeStart:0,executeEnd:0,end:0},this.buffering={audio:{start:0,executeStart:0,executeEnd:0,end:0},video:{start:0,executeStart:0,executeEnd:0,end:0},audiovideo:{start:0,executeStart:0,executeEnd:0,end:0}},this.level=t,this.sn=e,this.id=i,this.size=s,this.part=n,this.partial=r}}const Pe={length:0,start:()=>0,end:()=>0};class Oe{static isBuffered(t,e){if(t){const i=Oe.getBuffered(t);for(let t=i.length;t--;)if(e>=i.start(t)&&e<=i.end(t))return!0}return!1}static bufferedRanges(t){if(t){const e=Oe.getBuffered(t);return Oe.timeRangesToArray(e)}return[]}static timeRangesToArray(t){const e=[];for(let i=0;i1&&t.sort(((t,e)=>t.start-e.start||e.end-t.end));let s=-1,n=[];if(i)for(let r=0;r=t[r].start&&e<=t[r].end&&(s=r);const a=n.length;if(a){const e=n[a-1].end;t[r].start-ee&&(n[a-1].end=t[r].end):n.push(t[r])}else n.push(t[r])}else n=t;let r,a=0,o=e,l=e;for(let t=0;t=c&&e<=u&&(s=t),e+i>=c&&e{const s=e.substring(2,e.length-1),n=null==i?void 0:i[s];return void 0===n?(t.playlistParsingError||(t.playlistParsingError=new Error(`Missing preceding EXT-X-DEFINE tag for Variable Reference: "${s}"`)),e):n}))}return e}function $e(t,e,i){let s,n,r=t.variableList;if(r||(t.variableList=r={}),"QUERYPARAM"in e){s=e.QUERYPARAM;try{const t=new self.URL(i).searchParams;if(!t.has(s))throw new Error(`"${s}" does not match any query parameter in URI: "${i}"`);n=t.get(s)}catch(e){t.playlistParsingError||(t.playlistParsingError=new Error(`EXT-X-DEFINE QUERYPARAM: ${e.message}`))}}else s=e.NAME,n=e.VALUE;s in r?t.playlistParsingError||(t.playlistParsingError=new Error(`EXT-X-DEFINE duplicate Variable Name declarations: "${s}"`)):r[s]=n||""}function Ue(t,e,i){const s=e.IMPORT;if(i&&s in i){let e=t.variableList;e||(t.variableList=e={}),e[s]=i[s]}else t.playlistParsingError||(t.playlistParsingError=new Error(`EXT-X-DEFINE IMPORT attribute not found in Multivariant Playlist: "${s}"`))}const Be=/^(\d+)x(\d+)$/,je=/(.+?)=(".*?"|.*?)(?:,|$)/g;class Ge{constructor(t,e){"string"==typeof t&&(t=Ge.parseAttrList(t,e)),b(this,t)}get clientAttrs(){return Object.keys(this).filter((t=>"X-"===t.substring(0,2)))}decimalInteger(t){const e=parseInt(this[t],10);return e>Number.MAX_SAFE_INTEGER?1/0:e}hexadecimalInteger(t){if(this[t]){let e=(this[t]||"0x").slice(2);e=(1&e.length?"0":"")+e;const i=new Uint8Array(e.length/2);for(let t=0;tNumber.MAX_SAFE_INTEGER?1/0:e}decimalFloatingPoint(t){return parseFloat(this[t])}optionalFloat(t,e){const i=this[t];return i?parseFloat(i):e}enumeratedString(t){return this[t]}enumeratedStringList(t,e){const i=this[t];return(i?i.split(/[ ,]+/):[]).reduce(((t,e)=>(t[e.toLowerCase()]=!0,t)),e)}bool(t){return"YES"===this[t]}decimalResolution(t){const e=Be.exec(this[t]);if(null!==e)return{width:parseInt(e[1],10),height:parseInt(e[2],10)}}static parseAttrList(t,e){let i;const s={};for(je.lastIndex=0;null!==(i=je.exec(t));){const n=i[1].trim();let r=i[2];const a=0===r.indexOf('"')&&r.lastIndexOf('"')===r.length-1;let o=!1;if(a)r=r.slice(1,-1);else switch(n){case"IV":case"SCTE35-CMD":case"SCTE35-IN":case"SCTE35-OUT":o=!0}if(e&&(a||o))r=Fe(e,r);else if(!o&&!a)switch(n){case"CLOSED-CAPTIONS":if("NONE"===r)break;case"ALLOWED-CPC":case"CLASS":case"ASSOC-LANGUAGE":case"AUDIO":case"BYTERANGE":case"CHANNELS":case"CHARACTERISTICS":case"CODECS":case"DATA-ID":case"END-DATE":case"GROUP-ID":case"ID":case"IMPORT":case"INSTREAM-ID":case"KEYFORMAT":case"KEYFORMATVERSIONS":case"LANGUAGE":case"NAME":case"PATHWAY-ID":case"QUERYPARAM":case"RECENTLY-REMOVED-DATERANGES":case"SERVER-URI":case"STABLE-RENDITION-ID":case"STABLE-VARIANT-ID":case"START-DATE":case"SUBTITLES":case"SUPPLEMENTAL-CODECS":case"URI":case"VALUE":case"VIDEO":case"X-ASSET-LIST":case"X-ASSET-URI":L.warn(`${t}: attribute ${n} is missing quotes`)}s[n]=r}return s}}function Ve(t){return"SCTE35-OUT"===t||"SCTE35-IN"===t||"SCTE35-CMD"===t}class He{constructor(t,e,i=0){var n;if(this.attr=void 0,this.tagAnchor=void 0,this.tagOrder=void 0,this._startDate=void 0,this._endDate=void 0,this._dateAtEnd=void 0,this._cue=void 0,this._badValueForSameId=void 0,this.tagAnchor=(null==e?void 0:e.tagAnchor)||null,this.tagOrder=null!=(n=null==e?void 0:e.tagOrder)?n:i,e){const i=e.attr;for(const e in i)if(Object.prototype.hasOwnProperty.call(t,e)&&t[e]!==i[e]){L.warn(`DATERANGE tag attribute: "${e}" does not match for tags with ID: "${t.ID}"`),this._badValueForSameId=e;break}t=b(new Ge({}),i,t)}if(this.attr=t,e?(this._startDate=e._startDate,this._cue=e._cue,this._endDate=e._endDate,this._dateAtEnd=e._dateAtEnd):this._startDate=new Date(t["START-DATE"]),"END-DATE"in this.attr){const t=(null==e?void 0:e.endDate)||new Date(this.attr["END-DATE"]);s(t.getTime())&&(this._endDate=t)}}get id(){return this.attr.ID}get class(){return this.attr.CLASS}get cue(){const t=this._cue;return void 0===t?this._cue=this.attr.enumeratedStringList(this.attr.CUE?"CUE":"X-CUE",{pre:!1,post:!1,once:!1}):t}get startTime(){const{tagAnchor:t}=this;return null===t||null===t.programDateTime?(L.warn(`Expected tagAnchor Fragment with PDT set for DateRange "${this.id}": ${t}`),NaN):t.start+(this.startDate.getTime()-t.programDateTime)/1e3}get startDate(){return this._startDate}get endDate(){const t=this._endDate||this._dateAtEnd;if(t)return t;const e=this.duration;return null!==e?this._dateAtEnd=new Date(this._startDate.getTime()+1e3*e):null}get duration(){if("DURATION"in this.attr){const t=this.attr.decimalFloatingPoint("DURATION");if(s(t))return t}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}get plannedDuration(){return"PLANNED-DURATION"in this.attr?this.attr.decimalFloatingPoint("PLANNED-DURATION"):null}get endOnNext(){return this.attr.bool("END-ON-NEXT")}get isInterstitial(){return"com.apple.hls.interstitial"===this.class}get isValid(){return!!this.id&&!this._badValueForSameId&&s(this.startDate.getTime())&&(null===this.duration||this.duration>=0)&&(!this.endOnNext||!!this.class)&&(!this.attr.CUE||!this.cue.pre&&!this.cue.post||this.cue.pre!==this.cue.post)&&(!this.isInterstitial||"X-ASSET-URI"in this.attr||"X-ASSET-LIST"in this.attr)}}class Ke{constructor(t){this.PTSKnown=!1,this.alignedSliding=!1,this.averagetargetduration=void 0,this.endCC=0,this.endSN=0,this.fragments=void 0,this.fragmentHint=void 0,this.partList=null,this.dateRanges=void 0,this.dateRangeTagCount=0,this.live=!0,this.requestScheduled=-1,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.misses=0,this.startCC=0,this.startSN=0,this.startTimeOffset=null,this.targetduration=0,this.totalduration=0,this.type=null,this.url=void 0,this.m3u8="",this.version=null,this.canBlockReload=!1,this.canSkipUntil=0,this.canSkipDateRanges=!1,this.skippedSegments=0,this.recentlyRemovedDateranges=void 0,this.partHoldBack=0,this.holdBack=0,this.partTarget=0,this.preloadHint=void 0,this.renditionReports=void 0,this.tuneInGoal=0,this.deltaUpdateFailed=void 0,this.driftStartTime=0,this.driftEndTime=0,this.driftStart=0,this.driftEnd=0,this.encryptedFragments=void 0,this.playlistParsingError=null,this.variableList=null,this.hasVariableRefs=!1,this.appliedTimelineOffset=void 0,this.fragments=[],this.encryptedFragments=[],this.dateRanges={},this.url=t}reloaded(t){if(!t)return this.advanced=!0,void(this.updated=!0);const e=this.lastPartSn-t.lastPartSn,i=this.lastPartIndex-t.lastPartIndex;this.updated=this.endSN!==t.endSN||!!i||!!e||!this.live,this.advanced=this.endSN>t.endSN||e>0||0===e&&i>0,this.updated||this.advanced?this.misses=Math.floor(.6*t.misses):this.misses=t.misses+1}get hasProgramDateTime(){return!!this.fragments.length&&s(this.fragments[this.fragments.length-1].programDateTime)}get levelTargetDuration(){return this.averagetargetduration||this.targetduration||10}get drift(){const t=this.driftEndTime-this.driftStartTime;return t>0?1e3*(this.driftEnd-this.driftStart)/t:1}get edge(){return this.partEnd||this.fragmentEnd}get partEnd(){var t;return null!=(t=this.partList)&&t.length?this.partList[this.partList.length-1].end:this.fragmentEnd}get fragmentEnd(){var t;return null!=(t=this.fragments)&&t.length?this.fragments[this.fragments.length-1].end:0}get fragmentStart(){var t;return null!=(t=this.fragments)&&t.length?this.fragments[0].start:0}get age(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}get lastPartIndex(){var t;return null!=(t=this.partList)&&t.length?this.partList[this.partList.length-1].index:-1}get maxPartIndex(){const t=this.partList;if(t){const e=this.lastPartIndex;if(-1!==e){for(let i=t.length;i--;)if(t[i].index>e)return t[i].index;return e}}return 0}get lastPartSn(){var t;return null!=(t=this.partList)&&t.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}get expired(){if(this.live&&this.age&&this.misses<3){const t=this.partEnd-this.fragmentStart;return this.age>Math.max(t,this.totalduration)+this.levelTargetDuration}return!1}}function Ye(t){return"AES-128"===t||"AES-256"===t||"AES-256-CTR"===t}function qe(t){switch(t){case"AES-128":case"AES-256":return 0;case"AES-256-CTR":return 1;default:throw new Error(`invalid full segment method ${t}`)}}function ze(t){return Uint8Array.from(atob(t),(t=>t.charCodeAt(0)))}function We(t){return Uint8Array.from(unescape(encodeURIComponent(t)),(t=>t.charCodeAt(0)))}const Xe="undefined"!=typeof self?self:void 0;var Je={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},Qe="org.w3.clearkey",Ze="com.apple.streamingkeydelivery",ti="com.microsoft.playready",ei="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed";function ii(t){switch(t){case Ze:return Je.FAIRPLAY;case ti:return Je.PLAYREADY;case ei:return Je.WIDEVINE;case Qe:return Je.CLEARKEY}}function si(t){return"edef8ba979d64acea3c827dcd51d21ed"===t?Je.WIDEVINE:"9a04f07998404286ab92e65be0885f95"===t?Je.PLAYREADY:"1077efecc0b24d02ace33c1e52e2fb4b"===t||"e2719d58a985b3c9781ab030af78d30e"===t?Je.CLEARKEY:void 0}function ni(t){switch(t){case Je.FAIRPLAY:return Ze;case Je.PLAYREADY:return ti;case Je.WIDEVINE:return ei;case Je.CLEARKEY:return Qe}}function ri(t){const{drmSystems:e,widevineLicenseUrl:i}=t,s=e?[Je.FAIRPLAY,Je.WIDEVINE,Je.PLAYREADY,Je.CLEARKEY].filter((t=>!!e[t])):[];return!s[Je.WIDEVINE]&&i&&s.push(Je.WIDEVINE),s}const ai=null!=Xe&&null!=(oi=Xe.navigator)&&oi.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null;var oi;function li(t){const e=new Uint16Array(t.buffer,t.byteOffset,t.byteLength/2),i=String.fromCharCode.apply(null,Array.from(e)),s=i.substring(i.indexOf("<"),i.length),n=(new DOMParser).parseFromString(s,"text/xml").getElementsByTagName("KID")[0];if(n){const t=n.childNodes[0]?n.childNodes[0].nodeValue:n.getAttribute("VALUE");if(t){const e=ze(t).subarray(0,16);return function(t){const e=function(t,e,i){const s=t[e];t[e]=t[i],t[i]=s};e(t,0,3),e(t,1,2),e(t,4,5),e(t,6,7)}(e),e}}return null}let ci={};class ui{static clearKeyUriToKeyIdMap(){ci={}}constructor(t,e,i,s=[1],n=null){this.uri=void 0,this.method=void 0,this.keyFormat=void 0,this.keyFormatVersions=void 0,this.encrypted=void 0,this.isCommonEncryption=void 0,this.iv=null,this.key=null,this.keyId=null,this.pssh=null,this.method=t,this.uri=e,this.keyFormat=i,this.keyFormatVersions=s,this.iv=n,this.encrypted=!!t&&"NONE"!==t,this.isCommonEncryption=this.encrypted&&!Ye(t)}isSupported(){if(this.method){if(Ye(this.method)||"NONE"===this.method)return!0;if("identity"===this.keyFormat)return"SAMPLE-AES"===this.method;switch(this.keyFormat){case Ze:case ei:case ti:case Qe:return-1!==["ISO-23001-7","SAMPLE-AES","SAMPLE-AES-CENC","SAMPLE-AES-CTR"].indexOf(this.method)}}return!1}getDecryptData(t){if(!this.encrypted||!this.uri)return null;if(Ye(this.method)&&this.uri&&!this.iv){"number"!=typeof t&&(L.warn(`missing IV for initialization segment with method="${this.method}" - compliance issue`),t=0);const e=function(t){const e=new Uint8Array(16);for(let i=12;i<16;i++)e[i]=t>>8*(15-i)&255;return e}(t);return new ui(this.method,this.uri,"identity",this.keyFormatVersions,e)}const e=function(t){const e=t.split(":");let i=null;if("data"===e[0]&&2===e.length){const t=e[1].split(";"),s=t[t.length-1].split(",");if(2===s.length){const e="base64"===s[0],n=s[1];e?(t.splice(-1,1),i=ze(n)):i=function(t){const e=We(t).subarray(0,16),i=new Uint8Array(16);return i.set(e,16-e.length),i}(n)}}return i}(this.uri);if(e)switch(this.keyFormat){case ei:this.pssh=e,e.length>=22&&(this.keyId=e.subarray(e.length-22,e.length-6));break;case ti:{const t=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=function(t,e,i){if(16!==t.byteLength)throw new RangeError("Invalid system id");let s,n,r;s=0,n=new Uint8Array,r=new Uint8Array;const a=new Uint8Array(4);return i&&i.byteLength>0&&new DataView(a.buffer).setUint32(0,i.byteLength,!1),function(t,...e){const i=e.length;let s=8,n=i;for(;n--;)s+=e[n].byteLength;const r=new Uint8Array(s);for(r[0]=s>>24&255,r[1]=s>>16&255,r[2]=s>>8&255,r[3]=255&s,r.set(t,4),n=0,s=8;n0&&s.length({id:t.attrs.AUDIO,audioCodec:t.audioCodec}))),SUBTITLES:r.map((t=>({id:t.attrs.SUBTITLES,textCodec:t.textCodec}))),"CLOSED-CAPTIONS":[]};let o=0;for(hi.lastIndex=0;null!==(s=hi.exec(t));){const t=new Ge(s[1],i),r=t.TYPE;if(r){const i=a[r],s=n[r]||[];n[r]=s;const l=t.LANGUAGE,c=t["ASSOC-LANGUAGE"],u=t.CHANNELS,d=t.CHARACTERISTICS,h=t["INSTREAM-ID"],f={attrs:t,bitrate:0,id:o++,groupId:t["GROUP-ID"]||"",name:t.NAME||l||"",type:r,default:t.bool("DEFAULT"),autoselect:t.bool("AUTOSELECT"),forced:t.bool("FORCED"),lang:l,url:t.URI?mi.resolve(t.URI,e):""};if(c&&(f.assocLang=c),u&&(f.channels=u),d&&(f.characteristics=d),h&&(f.instreamId=h),null!=i&&i.length){const t=mi.findGroup(i,f.groupId)||i[0];Ti(f,t,"audioCodec"),Ti(f,t,"textCodec")}s.push(f)}}return n}static parseLevelPlaylist(t,e,i,n,r,a){var o;const l={url:e},c=new Ke(e),u=c.fragments,d=[];let h,f,p,g,m=null,y=0,v=0,_=0,E=0,T=0,S=null,k=new z(n,l),w=-1,A=!1,R=null;if(pi.lastIndex=0,c.m3u8=t,c.hasVariableRefs=Me(t),"#EXTM3U"!==(null==(o=pi.exec(t))?void 0:o[0]))return c.playlistParsingError=new Error("Missing format identifier #EXTM3U"),c;for(;null!==(h=pi.exec(t));){A&&(A=!1,k=new z(n,l),k.playlistOffset=_,k.start=_,k.sn=y,k.cc=E,T&&(k.bitrate=T),k.level=i,m&&(k.initSegment=m,m.rawProgramDateTime&&(k.rawProgramDateTime=m.rawProgramDateTime,m.rawProgramDateTime=null),R&&(k.setByteRange(R),R=null)));const t=h[1];if(t){k.duration=parseFloat(t);const e=(" "+h[2]).slice(1);k.title=e||null,k.tagList.push(e?["INF",t,e]:["INF",t])}else if(h[3]){if(s(k.duration)){k.playlistOffset=_,k.start=_,p&&wi(k,p,c),k.sn=y,k.level=i,k.cc=E,u.push(k);const t=(" "+h[3]).slice(1);k.relurl=Fe(c,t),Si(k,S,d),S=k,_+=k.duration,y++,v=0,A=!0}}else{if(h=h[0].match(gi),!h){L.warn("No matches on slow regex match for level playlist!");continue}for(f=1;f0&&Ri(c,t,h),y=c.startSN=parseInt(r);break;case"SKIP":{c.skippedSegments&&Ai(c,t,h);const e=new Ge(r,c),i=e.decimalInteger("SKIPPED-SEGMENTS");if(s(i)){c.skippedSegments+=i;for(let t=i;t--;)u.push(null);y+=i}const n=e.enumeratedString("RECENTLY-REMOVED-DATERANGES");n&&(c.recentlyRemovedDateranges=(c.recentlyRemovedDateranges||[]).concat(n.split("\t")));break}case"TARGETDURATION":0!==c.targetduration&&Ai(c,t,h),c.targetduration=Math.max(parseInt(r),1);break;case"VERSION":null!==c.version&&Ai(c,t,h),c.version=parseInt(r);break;case"INDEPENDENT-SEGMENTS":break;case"ENDLIST":c.live||Ai(c,t,h),c.live=!1;break;case"#":(r||o)&&k.tagList.push(o?[r,o]:[r]);break;case"DISCONTINUITY":E++,k.tagList.push(["DIS"]);break;case"GAP":k.gap=!0,k.tagList.push([t]);break;case"BITRATE":k.tagList.push([t,r]),T=1e3*parseInt(r),s(T)?k.bitrate=T:T=0;break;case"DATERANGE":{const t=new Ge(r,c),e=new He(t,c.dateRanges[t.ID],c.dateRangeTagCount);c.dateRangeTagCount++,e.isValid||c.skippedSegments?c.dateRanges[e.id]=e:L.warn(`Ignoring invalid DATERANGE tag: "${r}"`),k.tagList.push(["EXT-X-DATERANGE",r]);break}case"DEFINE":{const t=new Ge(r,c);"IMPORT"in t?Ue(c,t,a):$e(c,t,e)}break;case"DISCONTINUITY-SEQUENCE":0!==c.startCC?Ai(c,t,h):u.length>0&&Ri(c,t,h),c.startCC=E=parseInt(r);break;case"KEY":{const t=bi(r,e,c);if(t.isSupported()){if("NONE"===t.method){p=void 0;break}p||(p={}),p[t.keyFormat]&&(p=b({},p)),p[t.keyFormat]=t}else L.warn(`[Keys] Ignoring invalid EXT-X-KEY tag: "${r}"`);break}case"START":c.startTimeOffset=_i(r);break;case"MAP":{const t=new Ge(r,c);if(k.duration){const e=new z(n,l);ki(e,t,i,p),m=e,k.initSegment=m,m.rawProgramDateTime&&!k.rawProgramDateTime&&(k.rawProgramDateTime=m.rawProgramDateTime)}else{const e=k.byteRangeEndOffset;if(e){const t=k.byteRangeStartOffset;R=`${e-t}@${t}`}else R=null;ki(k,t,i,p),m=k,A=!0}m.cc=E;break}case"SERVER-CONTROL":g&&Ai(c,t,h),g=new Ge(r),c.canBlockReload=g.bool("CAN-BLOCK-RELOAD"),c.canSkipUntil=g.optionalFloat("CAN-SKIP-UNTIL",0),c.canSkipDateRanges=c.canSkipUntil>0&&g.bool("CAN-SKIP-DATERANGES"),c.partHoldBack=g.optionalFloat("PART-HOLD-BACK",0),c.holdBack=g.optionalFloat("HOLD-BACK",0);break;case"PART-INF":{c.partTarget&&Ai(c,t,h);const e=new Ge(r);c.partTarget=e.decimalFloatingPoint("PART-TARGET");break}case"PART":{let t=c.partList;t||(t=c.partList=[]);const e=v>0?t[t.length-1]:void 0,i=v++,s=new Ge(r,c),n=new W(s,k,l,i,e);t.push(n),k.duration+=n.duration;break}case"PRELOAD-HINT":{const t=new Ge(r,c);c.preloadHint=t;break}case"RENDITION-REPORT":{const t=new Ge(r,c);c.renditionReports=c.renditionReports||[],c.renditionReports.push(t);break}default:L.warn(`line parsed but not handled: ${h}`)}}}S&&!S.relurl?(u.pop(),_-=S.duration,c.partList&&(c.fragmentHint=S)):c.partList&&(Si(k,S,d),k.cc=E,c.fragmentHint=k,p&&wi(k,p,c)),c.targetduration||(c.playlistParsingError=new Error("#EXT-X-TARGETDURATION is required"));const I=u.length,C=u[0],D=u[I-1];if(_+=c.skippedSegments*c.targetduration,_>0&&I&&D){c.averagetargetduration=_/I;const t=D.sn;c.endSN="initSegment"!==t?t:0,c.live||(D.endList=!0),C&&void 0===c.startCC&&(c.startCC=C.cc),w>0&&(function(t,e){let i=t[e];for(let s=e;s--;){const e=t[s];if(!e)return;e.programDateTime=i.programDateTime-1e3*e.duration,i=e}}(u,w),C&&d.unshift(C))}else c.endSN=0,c.startCC=0;return c.fragmentHint&&(_+=c.fragmentHint.duration),c.totalduration=_,d.length&&c.dateRangeTagCount&&C&&yi(d,c),c.endCC=E,c}}function yi(t,e){const i=t.length,s=t[i-1],n=e.live?1/0:e.totalduration,r=Object.keys(e.dateRanges);for(let a=r.length;a--;){const o=e.dateRanges[r[a]],l=o.startDate.getTime();o.tagAnchor=s.ref;for(let s=i;s--;){const i=vi(e,l,t,s,n);if(-1!==i){o.tagAnchor=e.fragments[i].ref;break}}}}function vi(t,e,i,s,n){const r=i[s];if(r){const o=r.programDateTime;var a;if(e>=o||0===s)if(e<=o+1e3*(((null==(a=i[s+1])?void 0:a.start)||n)-r.start)){const n=i[s].sn-t.startSN,r=t.fragments;if(r.length>i.length)for(let a=(i[s+1]||r[r.length-1]).sn-t.startSN;a>n;a--){const t=r[a].programDateTime;if(e>=t&&et));["video","audio","text"].forEach((t=>{const s=i.filter((e=>wt(e,t)));s.length&&(e[`${t}Codec`]=s.map((t=>t.split("/")[0])).join(","),i=i.filter((t=>-1===s.indexOf(t))))})),e.unknownCodecs=i}function Ti(t,e,i){const s=e[i];s&&(t[i]=s)}function Si(t,e,i){t.rawProgramDateTime?i.push(t):null!=e&&e.programDateTime&&(t.programDateTime=e.endProgramDateTime)}function ki(t,e,i,s){t.relurl=e.URI,e.BYTERANGE&&t.setByteRange(e.BYTERANGE),t.level=i,t.sn="initSegment",s&&(t.levelkeys=s),t.initSegment=null}function wi(t,e,i){t.levelkeys=e;const{encryptedFragments:s}=i;s.length&&s[s.length-1].levelkeys===e||!Object.keys(e).some((t=>e[t].isCommonEncryption))||s.push(t)}function Ai(t,e,i){t.playlistParsingError=new Error(`#EXT-X-${e} must not appear more than once (${i[0]})`)}function Ri(t,e,i){t.playlistParsingError=new Error(`#EXT-X-${e} must appear before the first Media Segment (${i[0]})`)}function Li(t,e){const i=e.startPTS;if(s(i)){let s,n=0;e.sn>t.sn?(n=i-t.start,s=t):(n=t.start-i,s=e),s.duration!==n&&s.setDuration(n)}else e.sn>t.sn?t.cc===e.cc&&t.minEndPTS?e.setStart(t.start+(t.minEndPTS-t.start)):e.setStart(t.start+t.duration):e.setStart(Math.max(t.start-e.duration,0))}function Ii(t,e,i,n,r,a){n-i<=0&&(L.warn("Fragment should have a positive duration",e),n=i+e.duration,a=r+e.duration);let o=i,l=n;const c=e.startPTS,u=e.endPTS;if(s(c)){const t=Math.abs(c-i);s(e.deltaPTS)?e.deltaPTS=Math.max(t,e.deltaPTS):e.deltaPTS=t,o=Math.max(i,c),i=Math.min(i,c),r=Math.min(r,e.startDTS),l=Math.min(n,u),n=Math.max(n,u),a=Math.max(a,e.endDTS)}const d=i-e.start;0!==e.start&&e.setStart(i),e.setDuration(n-e.start),e.startPTS=i,e.maxStartPTS=o,e.startDTS=r,e.endPTS=n,e.minEndPTS=l,e.endDTS=a;const h=e.sn;if(!t||ht.endSN)return 0;let f;const p=h-t.startSN,g=t.fragments;for(g[p]=e,f=p;f>0;f--)Li(g[f],g[f-1]);for(f=p;f=0;let a=0;if(r&&se){const t=1e3*s[s.length-1].duration;t{var i;null==(i=t.details)||i.fragments.forEach((t=>{t.level=e,t.initSegment&&(t.initSegment.level=e)}))}))}function Fi(t,e){for(let s=0,n=t.length;st.startCC)}(e,t))return;const i=Math.min(e.endCC,t.endCC),s=Fi(e.fragments,i),n=Fi(t.fragments,i);s&&n&&(L.log(`Aligning playlist at start of dicontinuity sequence ${i}`),Ui(s.start-n.start,t))}function ji(t,e){if(!t.hasProgramDateTime||!e.hasProgramDateTime)return;const i=t.fragments,s=e.fragments;if(!i.length||!s.length)return;let n,r;const a=Math.min(e.endCC,t.endCC);e.startCC{const{config:t,fragCurrent:e,media:i,mediaBuffer:n,state:r}=this,a=i?i.currentTime:0,o=Oe.bufferInfo(n||i,a,t.maxBufferHole);if(this.log(`media seeking to ${s(a)?a.toFixed(3):a}, state: ${r}`),this.state===Gi.ENDED)this.resetLoadingState();else if(e){const i=t.maxFragLookUpTolerance,s=e.start-i,n=e.start+e.duration+i;if(!o.len||no.end){const t=a>n;(athis.lastCurrentTime&&(this.lastCurrentTime=a),!this.loadingParts)){const t=Math.max(o.end,a),e=this.shouldLoadParts(this.getLevelDetails(),t);e&&(this.log(`LL-Part loading ON after seeking to ${a.toFixed(2)} with buffer @${t.toFixed(2)}`),this.loadingParts=e)}this.hls.hasEnoughToStart||o.len||(this.log(`setting startPosition to ${a} because of seek before start`),this.nextLoadPosition=this.startPosition=a),this.tickImmediate()},this.onMediaEnded=()=>{this.log("setting startPosition to 0 because media ended"),this.startPosition=this.lastCurrentTime=0},this.playlistType=r,this.hls=t,this.fragmentLoader=new Re(t.config),this.keyLoader=i,this.fragmentTracker=e,this.config=t.config,this.decrypter=new we(t.config)}registerListeners(){const{hls:t}=this;t.on(l.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(l.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(l.MANIFEST_LOADING,this.onManifestLoading,this),t.on(l.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(l.ERROR,this.onError,this)}unregisterListeners(){const{hls:t}=this;t.off(l.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(l.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(l.MANIFEST_LOADING,this.onManifestLoading,this),t.off(l.MANIFEST_LOADED,this.onManifestLoaded,this),t.off(l.ERROR,this.onError,this)}doTick(){this.onTickEnd()}onTickEnd(){}startLoad(t){}stopLoad(){if(this.state===Gi.STOPPED)return;this.fragmentLoader.abort(),this.keyLoader.abort(this.playlistType);const t=this.fragCurrent;null!=t&&t.loader&&(t.abortRequests(),this.fragmentTracker.removeFragment(t)),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=Gi.STOPPED}get startPositionValue(){const{nextLoadPosition:t,startPosition:e}=this;return-1===e&&t?t:e}get bufferingEnabled(){return this.buffering}pauseBuffering(){this.buffering=!1}resumeBuffering(){this.buffering=!0}get inFlightFrag(){return{frag:this.fragCurrent,state:this.state}}_streamEnded(t,e){if(e.live||!this.media)return!1;const i=t.end||0,s=this.config.timelineOffset||0;if(i<=s)return!1;const n=t.nextStart;if(n&&n>s&&n{const e=t.frag;if(this.fragContextChanged(e))return this.warn(`${e.type} sn: ${e.sn}${t.part?" part: "+t.part.index:""} of ${this.fragInfo(e,!1,t.part)}) was dropped during download.`),void this.fragmentTracker.removeFragment(e);e.stats.chunkCount++,this._handleFragmentLoadProgress(t)})).then((t=>{if(!t)return;const e=this.state,i=t.frag;this.fragContextChanged(i)?(e===Gi.FRAG_LOADING||!this.fragCurrent&&e===Gi.PARSING)&&(this.fragmentTracker.removeFragment(i),this.state=Gi.IDLE):("payload"in t&&(this.log(`Loaded ${i.type} sn: ${i.sn} of ${this.playlistLabel()} ${i.level}`),this.hls.trigger(l.FRAG_LOADED,t)),this._handleFragmentLoadComplete(t))})).catch((e=>{this.state!==Gi.STOPPED&&this.state!==Gi.ERROR&&(this.warn(`Frag error: ${(null==e?void 0:e.message)||e}`),this.resetFragmentLoading(t))}))}clearTrackerIfNeeded(t){var e;const{fragmentTracker:i}=this;if(i.getState(t)===me){const e=t.type,s=this.getFwdBufferInfo(this.mediaBuffer,e),n=Math.max(t.duration,s?s.len:this.config.maxBufferLength),r=this.backtrackFragment;(1==(r?t.sn-r.sn:0)||this.reduceMaxBufferLength(n,t.duration))&&i.removeFragment(t)}else 0===(null==(e=this.mediaBuffer)?void 0:e.buffered.length)?i.removeAllFragments():i.hasParts(t.type)&&(i.detectPartialFragments({frag:t,part:null,stats:t.stats,id:t.type}),i.getState(t)===ye&&i.removeFragment(t))}checkLiveUpdate(t){if(t.updated&&!t.live){const e=t.fragments[t.fragments.length-1];this.fragmentTracker.detectPartialFragments({frag:e,part:null,stats:e.stats,id:e.type})}t.fragments[0]||(t.deltaUpdateFailed=!0)}waitForLive(t){const e=t.details;return(null==e?void 0:e.live)&&"EVENT"!==e.type&&(this.levelLastLoaded!==t||e.expired)}flushMainBuffer(t,e,i=null){if(!(t-e))return;const s={startOffset:t,endOffset:e,type:i};this.hls.trigger(l.BUFFER_FLUSHING,s)}_loadInitSegment(t,e){this._doFragLoad(t,e).then((t=>{const e=null==t?void 0:t.frag;if(!e||this.fragContextChanged(e)||!this.levels)throw new Error("init load aborted");return t})).then((t=>{const{hls:e}=this,{frag:i,payload:s}=t,n=i.decryptdata;if(s&&s.byteLength>0&&null!=n&&n.key&&n.iv&&Ye(n.method)){const r=self.performance.now();return this.decrypter.decrypt(new Uint8Array(s),n.key.buffer,n.iv.buffer,qe(n.method)).catch((t=>{throw e.trigger(l.ERROR,{type:a.MEDIA_ERROR,details:o.FRAG_DECRYPT_ERROR,fatal:!1,error:t,reason:t.message,frag:i}),t})).then((s=>{const n=self.performance.now();return e.trigger(l.FRAG_DECRYPTED,{frag:i,payload:s,stats:{tstart:r,tdecrypt:n}}),t.payload=s,this.completeInitSegmentLoad(t)}))}return this.completeInitSegmentLoad(t)})).catch((e=>{this.state!==Gi.STOPPED&&this.state!==Gi.ERROR&&(this.warn(e),this.resetFragmentLoading(t))}))}completeInitSegmentLoad(t){const{levels:e}=this;if(!e)throw new Error("init load aborted, missing levels");const i=t.frag.stats;this.state!==Gi.STOPPED&&(this.state=Gi.IDLE),t.frag.data=new Uint8Array(t.payload),i.parsing.start=i.buffering.start=self.performance.now(),i.parsing.end=i.buffering.end=self.performance.now(),this.tick()}fragContextChanged(t){const{fragCurrent:e}=this;return!t||!e||t.sn!==e.sn||t.level!==e.level}fragBufferedComplete(t,e){const i=this.mediaBuffer?this.mediaBuffer:this.media;if(this.log(`Buffered ${t.type} sn: ${t.sn}${e?" part: "+e.index:""} of ${this.fragInfo(t,!1,e)} > buffer:${i?function(t){let e="";const i=t.length;for(let s=0;s!!e[t])))return void(this.state=Gi.IDLE)}const e=null==(s=this.levels)?void 0:s[t.level];null!=e&&e.fragmentError&&(this.log(`Resetting level fragment error count of ${e.fragmentError} on frag buffered`),e.fragmentError=0)}this.state=Gi.IDLE}_handleFragmentLoadComplete(t){const{transmuxer:e}=this;if(!e)return;const{frag:i,part:s,partsLoaded:n}=t,r=!n||0===n.length||n.some((t=>!t)),a=new xe(i.level,i.sn,i.stats.chunkCount+1,0,s?s.index:-1,!r);e.flush(a)}_handleFragmentLoadProgress(t){}_doFragLoad(t,e,i=null,n){var r;this.fragCurrent=t;const a=null==e?void 0:e.details;if(!this.levels||!a)throw new Error(`frag load aborted, missing level${a?"":" detail"}s`);let o=null;!t.encrypted||null!=(r=t.decryptdata)&&r.key?!t.encrypted&&a.encryptedFragments.length&&this.keyLoader.loadClear(t,a.encryptedFragments):(this.log(`Loading key for ${t.sn} of [${a.startSN}-${a.endSN}], ${this.playlistLabel()} ${t.level}`),this.state=Gi.KEY_LOADING,this.fragCurrent=t,o=this.keyLoader.load(t).then((t=>{if(!this.fragContextChanged(t.frag))return this.hls.trigger(l.KEY_LOADED,t),this.state===Gi.KEY_LOADING&&(this.state=Gi.IDLE),t})),this.hls.trigger(l.KEY_LOADING,{frag:t}),null===this.fragCurrent&&(o=Promise.reject(new Error("frag load aborted, context changed in KEY_LOADING"))));const c=this.fragPrevious;if(q(t)&&(!c||t.sn!==c.sn)){const i=this.shouldLoadParts(e.details,t.end);i!==this.loadingParts&&(this.log(`LL-Part loading ${i?"ON":"OFF"} loading sn ${null==c?void 0:c.sn}->${t.sn}`),this.loadingParts=i)}if(i=Math.max(t.start,i||0),this.loadingParts&&q(t)){const s=a.partList;if(s&&n){i>t.end&&a.fragmentHint&&(t=a.fragmentHint);const r=this.getNextPart(s,t,i);if(r>-1){const c=s[r];let u;return t=this.fragCurrent=c.fragment,this.log(`Loading ${t.type} sn: ${t.sn} part: ${c.index} (${r}/${s.length-1}) of ${this.fragInfo(t,!1,c)}) cc: ${t.cc} [${a.startSN}-${a.endSN}], target: ${parseFloat(i.toFixed(3))}`),this.nextLoadPosition=c.start+c.duration,this.state=Gi.FRAG_LOADING,u=o?o.then((i=>!i||this.fragContextChanged(i.frag)?null:this.doFragPartsLoad(t,c,e,n))).catch((t=>this.handleFragLoadError(t))):this.doFragPartsLoad(t,c,e,n).catch((t=>this.handleFragLoadError(t))),this.hls.trigger(l.FRAG_LOADING,{frag:t,part:c,targetBufferTime:i}),null===this.fragCurrent?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):u}if(!t.url||this.loadedEndOfParts(s,i))return Promise.resolve(null)}}if(q(t)&&this.loadingParts)this.log(`LL-Part loading OFF after next part miss @${i.toFixed(2)}`),this.loadingParts=!1;else if(!t.url)return Promise.resolve(null);this.log(`Loading ${t.type} sn: ${t.sn} of ${this.fragInfo(t,!1)}) cc: ${t.cc} ${a?"["+a.startSN+"-"+a.endSN+"]":""}, target: ${parseFloat(i.toFixed(3))}`),s(t.sn)&&!this.bitrateTest&&(this.nextLoadPosition=t.start+t.duration),this.state=Gi.FRAG_LOADING;const u=this.config.progressive;let d;return d=u&&o?o.then((e=>!e||this.fragContextChanged(null==e?void 0:e.frag)?null:this.fragmentLoader.load(t,n))).catch((t=>this.handleFragLoadError(t))):Promise.all([this.fragmentLoader.load(t,u?n:void 0),o]).then((([t])=>(!u&&t&&n&&n(t),t))).catch((t=>this.handleFragLoadError(t))),this.hls.trigger(l.FRAG_LOADING,{frag:t,targetBufferTime:i}),null===this.fragCurrent?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):d}doFragPartsLoad(t,e,i,s){return new Promise(((n,r)=>{var a;const o=[],c=null==(a=i.details)?void 0:a.partList,u=e=>{this.fragmentLoader.loadPart(t,e,s).then((s=>{o[e.index]=s;const r=s.part;this.hls.trigger(l.FRAG_LOADED,s);const a=Oi(i.details,t.sn,e.index+1)||Ni(c,t.sn,e.index+1);if(!a)return n({frag:t,part:r,partsLoaded:o});u(a)})).catch(r)};u(e)}))}handleFragLoadError(t){if("data"in t){const e=t.data;t.data&&e.details===o.INTERNAL_ABORTED?this.handleFragLoadAborted(e.frag,e.part):this.hls.trigger(l.ERROR,e)}else this.hls.trigger(l.ERROR,{type:a.OTHER_ERROR,details:o.INTERNAL_EXCEPTION,err:t,error:t,fatal:!0});return null}_handleTransmuxerFlush(t){const e=this.getCurrentContext(t);if(!e||this.state!==Gi.PARSING)return void(this.fragCurrent||this.state===Gi.STOPPED||this.state===Gi.ERROR||(this.state=Gi.IDLE));const{frag:i,part:s,level:n}=e,r=self.performance.now();i.stats.parsing.end=r,s&&(s.stats.parsing.end=r);const a=this.getLevelDetails(),o=a&&i.sn>a.endSN||this.shouldLoadParts(a,i.end);o!==this.loadingParts&&(this.log(`LL-Part loading ${o?"ON":"OFF"} after parsing segment ending @${i.end.toFixed(2)}`),this.loadingParts=o),this.updateLevelTiming(i,s,n,t.partial)}shouldLoadParts(t,e){if(this.config.lowLatencyMode){if(!t)return this.loadingParts;if(null!=t&&t.partList){var i;const n=t.partList[0];var s;if(e>=n.end+((null==(i=t.fragmentHint)?void 0:i.duration)||0))if((this.hls.hasEnoughToStart?(null==(s=this.media)?void 0:s.currentTime)||this.lastCurrentTime:this.getLoadPosition())>n.start-n.fragment.duration)return!0}}return!1}getCurrentContext(t){const{levels:e,fragCurrent:i}=this,{level:s,sn:n,part:r}=t;if(null==e||!e[s])return this.warn(`Levels object was unset while buffering fragment ${n} of ${this.playlistLabel()} ${s}. The current chunk will not be buffered.`),null;const a=e[s],o=a.details,l=r>-1?Oi(o,n,r):null,c=l?l.fragment:function(t,e,i){if(!t)return null;let s=t.fragments[e-t.startSN];return s||(s=t.fragmentHint,s&&s.sn===e?s:er&&this.flushMainBuffer(a,t.start)}getFwdBufferInfo(t,e){var i;const n=this.getLoadPosition();if(!s(n))return null;const r=this.lastCurrentTime>n||null!=(i=this.media)&&i.paused?0:this.config.maxBufferHole;return this.getFwdBufferInfoAtPos(t,n,e,r)}getFwdBufferInfoAtPos(t,e,i,s){const n=Oe.bufferInfo(t,e,s);if(0===n.len&&void 0!==n.nextStart){const r=this.fragmentTracker.getBufferedFrag(e,i);if(r&&(n.nextStart<=r.end||r.gap)){const i=Math.max(Math.min(n.nextStart,r.end)-e,s);return Oe.bufferInfo(t,e,i)}}return n}getMaxBufferLength(t){const{config:e}=this;let i;return i=t?Math.max(8*e.maxBufferSize/t,e.maxBufferLength):e.maxBufferLength,Math.min(i,e.maxMaxBufferLength)}reduceMaxBufferLength(t,e){const i=this.config,s=Math.max(Math.min(t-e,i.maxBufferLength),e),n=Math.max(t-3*e,i.maxMaxBufferLength/2,s);return n>=s&&(i.maxMaxBufferLength=n,this.warn(`Reduce max buffer length to ${n}s`),!0)}getAppendedFrag(t,e=f){var i;const s=null==(i=this.fragmentTracker)?void 0:i.getAppendedFrag(t,e);return s&&"fragment"in s?s.fragment:s}getNextFragment(t,e){const i=e.fragments,s=i.length;if(!s)return null;const{config:n}=this,r=i[0].start,a=n.lowLatencyMode&&!!e.partList;let o=null;if(e.live){const c=n.initialLiveManifestSize;if(s=r?s:n)||o.start:t;this.log(`Setting startPosition to ${c} to match start frag at live edge. mainStart: ${s} liveSyncPosition: ${n} frag.start: ${null==(l=o)?void 0:l.start}`),this.startPosition=this.nextLoadPosition=c}}else t<=r&&(o=i[0]);if(!o){const i=this.loadingParts?e.partEnd:e.fragmentEnd;o=this.getFragmentAtPosition(t,i,e)}let c=this.filterReplacedPrimary(o,e);if(!c&&o){const t=o.sn-e.startSN;c=this.filterReplacedPrimary(i[t+1]||null,e)}return this.mapToInitFragWhenRequired(c)}isLoopLoading(t,e){const i=this.fragmentTracker.getState(t);return(i===ve||i===ye&&!!t.gap)&&this.nextLoadPosition>e}getNextFragmentLoopLoading(t,e,i,s,n){let r=null;if(t.gap&&(r=this.getNextFragment(this.nextLoadPosition,e),r&&!r.gap&&i.nextStart)){const t=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,i.nextStart,s,0);if(null!==t&&i.len+t.len>=n){const t=r.sn;return this.loopSn!==t&&(this.log(`buffer full after gaps in "${s}" playlist starting at sn: ${t}`),this.loopSn=t),null}}return this.loopSn=void 0,r}get primaryPrefetch(){var t,e;if(Hi(this.hls.config)&&(null==(t=this.hls.interstitialsManager)||null==(e=t.playingItem)?void 0:e.event))return!0;return!1}filterReplacedPrimary(t,e){if(!t)return t;if(Hi(this.hls.config)&&t.type!==g){const i=this.hls.interstitialsManager,s=null==i?void 0:i.bufferingItem;if(s){const i=s.event;if(i){if(i.appendInPlace||Math.abs(t.start-s.start)>1||0===s.start)return null}else{if(t.end<=s.start&&!1===(null==e?void 0:e.live))return null;if(t.start>s.end&&s.nextEvent&&(s.nextEvent.appendInPlace||t.start-s.end>1))return null}}const n=null==i?void 0:i.playerQueue;if(n)for(let e=n.length;e--;){const i=n[e].interstitial;if(i.appendInPlace&&t.start>=i.startTime&&t.end<=i.resumeTime)return null}}return t}mapToInitFragWhenRequired(t){return null==t||!t.initSegment||null!=t&&t.initSegment.data||this.bitrateTest?t:t.initSegment}getNextPart(t,e,i){let s=-1,n=!1,r=!0;for(let a=0,o=t.length;a-1&&ii.start&&i.loaded}getInitialLiveFragment(t,e){const i=this.fragPrevious;let n=null;if(i){if(t.hasProgramDateTime&&(this.log(`Live playlist, switching playlist, load frag with same PDT: ${i.programDateTime}`),n=function(t,e,i){if(null===e||!Array.isArray(t)||!t.length||!s(e))return null;if(e<(t[0].programDateTime||0))return null;if(e>=(t[t.length-1].endProgramDateTime||0))return null;i=i||0;for(let s=0;s=t.startSN&&s<=t.endSN){const r=e[s-t.startSN];i.cc===r.cc&&(n=r,this.log(`Live playlist, switching playlist, load frag with next SN: ${n.sn}`))}n||(n=le(e,i.cc),n&&this.log(`Live playlist, switching playlist, load frag with same CC: ${n.sn}`))}}else{const e=this.hls.liveSyncPosition;null!==e&&(n=this.getFragmentAtPosition(e,this.bitrateTest?t.fragmentEnd:t.edge,t))}return n}getFragmentAtPosition(t,e,i){const{config:s}=this;let{fragPrevious:n}=this,{fragments:r,endSN:a}=i;const{fragmentHint:o}=i,{maxFragLookUpTolerance:l}=s,c=i.partList,u=!!(this.loadingParts&&null!=c&&c.length&&o);let d;var h;(u&&o&&!this.bitrateTest&&c[c.length-1].fragment.sn===o.sn&&(r=r.concat(o),a=o.sn),te-l||null!=(h=this.media)&&h.paused||!this.startFragRequested?0:l):d=r[r.length-1];if(d){const t=d.sn-i.startSN,e=this.fragmentTracker.getState(d);if((e===ve||e===ye&&d.gap)&&(n=d),n&&d.sn===n.sn&&(!u||c[0].fragment.sn>d.sn||!i.live&&!u)&&n&&d.level===n.level){const e=r[t+1];d=d.sn${t.startSN} fragments: ${n}`),s}return r}waitForCdnTuneIn(t){return t.live&&t.canBlockReload&&t.partTarget&&t.tuneInGoal>Math.max(t.partHoldBack,3*t.partTarget)}setStartPosition(t,e){let i=this.startPosition;i=0&&(i=this.nextLoadPosition),i}handleFragLoadAborted(t,e){this.transmuxer&&t.type===this.playlistType&&q(t)&&t.stats.aborted&&(this.warn(`Fragment ${t.sn}${e?" part "+e.index:""} of ${this.playlistLabel()} ${t.level} was aborted`),this.resetFragmentLoading(t))}resetFragmentLoading(t){this.fragCurrent&&(this.fragContextChanged(t)||this.state===Gi.FRAG_LOADING_WAITING_RETRY)||(this.state=Gi.IDLE)}onFragmentOrKeyLoadError(t,e){if(e.chunkMeta&&!e.frag){const t=this.getCurrentContext(e.chunkMeta);t&&(e.frag=t.frag)}const i=e.frag;if(!i||i.type!==t||!this.levels)return;var s;if(this.fragContextChanged(i))return void this.warn(`Frag load error must match current frag to retry ${i.url} > ${null==(s=this.fragCurrent)?void 0:s.url}`);const n=e.details===o.FRAG_GAP;n&&this.fragmentTracker.fragBuffered(i,!0);const r=e.errorAction,{action:a,flags:l,retryCount:c=0,retryConfig:u}=r||{},d=!!r&&!!u,h=d&&5===a,f=d&&!r.resolved&&1===l;if(!h&&f&&q(i)&&!i.endList)this.resetFragmentErrors(t),this.treatAsGap(i),r.resolved=!0;else if((h||f)&&c.5;n&&this.reduceMaxBufferLength(s.len,(null==e?void 0:e.duration)||10);const r=!n;return r&&this.warn(`Buffer full error while media.currentTime is not buffered, flush ${i} buffer`),e&&(this.fragmentTracker.removeFragment(e),this.nextLoadPosition=e.start),this.resetLoadingState(),r}return!1}resetFragmentErrors(t){t===p&&(this.fragCurrent=null),this.hls.hasEnoughToStart||(this.startFragRequested=!1),this.state!==Gi.STOPPED&&(this.state=Gi.IDLE)}afterBufferFlushed(t,e,i){if(!t)return;const s=Oe.getBuffered(t);this.fragmentTracker.detectEvictedFragments(e,s,i),this.state===Gi.ENDED&&this.resetLoadingState()}resetLoadingState(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state!==Gi.STOPPED&&(this.state=Gi.IDLE)}resetStartWhenNotLoaded(t){if(!this.hls.hasEnoughToStart){this.startFragRequested=!1;const e=t?t.details:null;null!=e&&e.live?(this.log("resetting startPosition for live start"),this.startPosition=-1,this.setStartPosition(e,e.fragmentStart),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}}resetWhenMissingContext(t){this.warn(`The loading context changed while buffering fragment ${t.sn} of ${this.playlistLabel()} ${t.level}. This chunk will not be buffered.`),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded(this.levelLastLoaded),this.resetLoadingState()}removeUnbufferedFrags(t=0){this.fragmentTracker.removeFragmentsInRange(t,1/0,this.playlistType,!1,!0)}updateLevelTiming(t,e,i,s){const n=i.details;if(n){var r;if(!Object.keys(t.elementaryStreams).reduce(((e,r)=>{const a=t.elementaryStreams[r];if(a){const o=a.endPTS-a.startPTS;if(o<=0)return this.warn(`Could not parse fragment ${t.sn} ${r} duration reliably (${o})`),e||!1;const c=s?0:Ii(n,t,a.startPTS,a.endPTS,a.startDTS,a.endDTS);return this.hls.trigger(l.LEVEL_PTS_UPDATED,{details:n,level:i,drift:c,type:r,frag:t,start:a.startPTS,end:a.endPTS}),!0}return e}),!1)&&(0===i.fragmentError&&this.treatAsGap(t,i),null===(null==(r=this.transmuxer)?void 0:r.error))){const e=new Error(`Found no media in fragment ${t.sn} of ${this.playlistLabel()} ${t.level} resetting transmuxer to fallback to playlist timing`);if(this.warn(e.message),this.hls.trigger(l.ERROR,{type:a.MEDIA_ERROR,details:o.FRAG_PARSING_ERROR,fatal:!1,error:e,frag:t,reason:`Found no media in msn ${t.sn} of ${this.playlistLabel()} "${i.url}"`}),!this.hls)return;this.resetTransmuxer()}this.state=Gi.PARSED,this.log(`Parsed ${t.type} sn: ${t.sn}${e?" part: "+e.index:""} of ${this.fragInfo(t,!1,e)})`),this.hls.trigger(l.FRAG_PARSED,{frag:t,part:e})}else this.warn("level.details undefined")}playlistLabel(){return this.playlistType===f?"level":"track"}fragInfo(t,e=!0,i){var s,n;return`${this.playlistLabel()} ${t.level} (${i?"part":"frag"}:[${(null!=(s=e&&!i?t.startPTS:(i||t).start)?s:NaN).toFixed(3)}-${(null!=(n=e&&!i?t.endPTS:(i||t).end)?n:NaN).toFixed(3)}]${i&&"main"===t.type?"INDEPENDENT="+(i.independent?"YES":"NO"):""}`}treatAsGap(t,e){e&&e.fragmentError++,t.gap=!0,this.fragmentTracker.removeFragment(t),this.fragmentTracker.fragBuffered(t,!0)}resetTransmuxer(){var t;null==(t=this.transmuxer)||t.reset()}recoverWorkerError(t){"demuxerWorker"===t.event&&(this.fragmentTracker.removeAllFragments(),this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null),this.resetStartWhenNotLoaded(this.levelLastLoaded),this.resetLoadingState())}set state(t){const e=this._state;e!==t&&(this._state=t,this.log(`${e}->${t}`))}get state(){return this._state}}function Hi(t){return!!t.interstitialsController&&!1!==t.enableInterstitialPlayback}class Ki{constructor(){this.chunks=[],this.dataLength=0}push(t){this.chunks.push(t),this.dataLength+=t.length}flush(){const{chunks:t,dataLength:e}=this;let i;return t.length?(i=1===t.length?t[0]:function(t,e){const i=new Uint8Array(e);let s=0;for(let e=0;e0)return t.subarray(i,i+s)}function is(t,e){return 255===t[e]&&240==(246&t[e+1])}function ss(t,e){return 1&t[e+1]?7:9}function ns(t,e){return(3&t[e+3])<<11|t[e+4]<<3|(224&t[e+5])>>>5}function rs(t,e){return e+1=t.length)return!1;const s=ns(t,e);if(s<=i)return!1;const n=e+s;return n===t.length||rs(t,n)}return!1}function os(t,e,i,s,n){if(!t.samplerate){const r=function(t,e,i,s){const n=e[i+2],r=n>>2&15;if(r>12){const e=new Error(`invalid ADTS sampling index:${r}`);return void t.emit(l.ERROR,l.ERROR,{type:a.MEDIA_ERROR,details:o.FRAG_PARSING_ERROR,fatal:!0,error:e,reason:e.message})}const c=1+(n>>6&3),u=e[i+3]>>6&3|(1&n)<<2,d="mp4a.40."+c,h=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350][r];let f=r;5!==c&&29!==c||(f-=3);const p=[c<<3|(14&f)>>1,(1&f)<<7|u<<3];return L.log(`manifest codec:${s}, parsed codec:${d}, channels:${u}, rate:${h} (ADTS object type:${c} sampling index:${r})`),{config:p,samplerate:h,channelCount:u,codec:d,parsedCodec:d,manifestCodec:s}}(e,i,s,n);if(!r)return;b(t,r)}}function ls(t){return 9216e4/t}function cs(t,e,i,s,n){const r=s+n*ls(t.samplerate),a=function(t,e){const i=ss(t,e);if(e+i<=t.length){const s=ns(t,e)-i;if(s>0)return{headerLength:i,frameLength:s}}}(e,i);let o;if(a){const{frameLength:s,headerLength:n}=a,l=n+s,c=Math.max(0,i+l-e.length);c?(o=new Uint8Array(l-n),o.set(e.subarray(i+n,e.length),0)):o=e.subarray(i+n,i+l);const u={unit:o,pts:r};return c||t.samples.push(u),{sample:u,length:l,missing:c}}const l=e.length-i;return o=new Uint8Array(l),o.set(e.subarray(i,e.length),0),{sample:{unit:o,pts:r},length:l,missing:-1}}function us(t,e){return Zi(t,e)&&ts(t,e+6)+10<=t.length-e}function ds(t,e){if(t<0)return-ds(-t,e);const i=Math.pow(10,e);if(Math.abs(t*i%1-.5)>6&1&&(e+=gs),e+=gs;const n=e+s;for(;e+ms0&&o.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:n,type:Es.audioId3,duration:Number.POSITIVE_INFINITY});rs(t)?90*t:9e4*e+(i?9e4*i.baseTime/i.timescale:0);let ws=null;const As=[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],Rs=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],Ls=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],Is=[0,1,1,4];function Cs(t,e,i,s,n){if(i+24>e.length)return;const r=Ds(e,i);if(r&&i+r.frameLength<=e.length){const a=s+n*(9e4*r.samplesPerFrame/r.sampleRate),o={unit:e.subarray(i,i+r.frameLength),pts:a,dts:a};return t.config=[],t.channelCount=r.channelCount,t.samplerate=r.sampleRate,t.samples.push(o),{sample:o,length:r.frameLength,missing:0}}}function Ds(t,e){const i=t[e+1]>>3&3,s=t[e+1]>>1&3,n=t[e+2]>>4&15,r=t[e+2]>>2&3;if(1!==i&&0!==n&&15!==n&&3!==r){const a=t[e+2]>>1&1,o=t[e+3]>>6,l=1e3*As[14*(3===i?3-s:3===s?3:4)+n-1],c=Rs[3*(3===i?0:2===i?1:2)+r],u=3===o?1:2,d=Ls[i][s],h=Is[s],f=8*d*h,p=Math.floor(d*l/c+a)*h;if(null===ws){const t=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);ws=t?parseInt(t[1]):0}return!!ws&&ws<=87&&2===s&&l>=224e3&&0===o&&(t[e+3]=128|t[e+3]),{sampleRate:c,channelCount:u,frameLength:p,samplesPerFrame:f}}}function xs(t,e){return 255===t[e]&&224==(224&t[e+1])&&0!=(6&t[e+1])}function Ps(t,e){return e+1{let i=0,s=5;e+=s;const n=new Uint32Array(1),r=new Uint32Array(1),a=new Uint8Array(1);for(;s>0;){a[0]=t[e];const o=Math.min(s,8),l=8-o;r[0]=4278190080>>>24+l<>l,i=i?i<e.length)return-1;if(11!==e[i]||119!==e[i+1])return-1;const r=e[i+4]>>6;if(r>=3)return-1;const a=[48e3,44100,32e3][r],o=63&e[i+4],l=2*[64,69,96,64,70,96,80,87,120,80,88,120,96,104,144,96,105,144,112,121,168,112,122,168,128,139,192,128,140,192,160,174,240,160,175,240,192,208,288,192,209,288,224,243,336,224,244,336,256,278,384,256,279,384,320,348,480,320,349,480,384,417,576,384,418,576,448,487,672,448,488,672,512,557,768,512,558,768,640,696,960,640,697,960,768,835,1152,768,836,1152,896,975,1344,896,976,1344,1024,1114,1536,1024,1115,1536,1152,1253,1728,1152,1254,1728,1280,1393,1920,1280,1394,1920][3*o+r];if(i+l>e.length)return-1;const c=e[i+6]>>5;let u=0;2===c?u+=2:(1&c&&1!==c&&(u+=2),4&c&&(u+=2));const d=(e[i+6]<<8|e[i+7])>>12-u&1,h=[2,1,2,3,3,4,4,5][c]+d,f=e[i+5]>>3,p=7&e[i+5],g=new Uint8Array([r<<6|f<<1|p>>2,(3&p)<<6|c<<3|d<<2|o>>4,o<<4&224]),m=s+n*(1536/a*9e4),y=e.subarray(i,i+l);return t.config=g,t.channelCount=h,t.samplerate=a,t.samples.push({unit:y,pts:m}),l}const Fs=/\/emsg[-/]ID3/i;function $s(t,e){return s(t.presentationTime)?t.presentationTime/t.timeScale:e+t.presentationTimeDelta/t.timeScale}class Us{constructor(t,e,i){this.keyData=void 0,this.decrypter=void 0,this.keyData=i,this.decrypter=new we(e,{removePKCS7Padding:!1})}decryptBuffer(t){return this.decrypter.decrypt(t,this.keyData.key.buffer,this.keyData.iv.buffer,0)}decryptAacSample(t,e,i){const s=t[e].unit;if(s.length<=16)return;const n=s.subarray(16,s.length-s.length%16),r=n.buffer.slice(n.byteOffset,n.byteOffset+n.length);this.decryptBuffer(r).then((n=>{const r=new Uint8Array(n);s.set(r,16),this.decrypter.isSync()||this.decryptAacSamples(t,e+1,i)}))}decryptAacSamples(t,e,i){for(;;e++){if(e>=t.length)return void i();if(!(t[e].unit.length<32||(this.decryptAacSample(t,e,i),this.decrypter.isSync())))return}}getAvcEncryptedData(t){const e=16*Math.floor((t.length-48)/160)+16,i=new Int8Array(e);let s=0;for(let e=32;e{n.data=this.getAvcDecryptedUnit(r,a),this.decrypter.isSync()||this.decryptAvcSamples(t,e,i+1,s)}))}decryptAvcSamples(t,e,i,s){if(t instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;e++,i=0){if(e>=t.length)return void s();const n=t[e].units;for(;!(i>=n.length);i++){const r=n[i];if(!(r.data.length<=48||1!==r.type&&5!==r.type||(this.decryptAvcSample(t,e,i,s,r),this.decrypter.isSync())))return}}}}class Bs{constructor(){this.VideoSample=null}createVideoSample(t,e,i){return{key:t,frame:!1,pts:e,dts:i,units:[],length:0}}getLastNalUnit(t){var e;let i,s=this.VideoSample;if(s&&0!==s.units.length||(s=t[t.length-1]),null!=(e=s)&&e.units){const t=s.units;i=t[t.length-1]}return i}pushAccessUnit(t,e){if(t.units.length&&t.frame){if(void 0===t.pts){const i=e.samples,s=i.length;if(!s)return void e.dropped++;{const e=i[s-1];t.pts=e.pts,t.dts=e.dts}}e.samples.push(t)}}parseNALu(t,e,i){const s=e.byteLength;let n=t.naluState||0;const r=n,a=[];let o,l,c,u=0,d=-1,h=0;for(-1===n&&(d=0,h=this.getNALuType(e,0),n=0,u=1);u=0){const t={data:e.subarray(d,l),type:h};a.push(t)}else{const i=this.getLastNalUnit(t.samples);i&&(r&&u<=4-r&&i.state&&(i.data=i.data.subarray(0,i.data.byteLength-r)),l>0&&(i.data=mt(i.data,e.subarray(0,l)),i.state=0))}u=0&&n>=0){const t={data:e.subarray(d,s),type:h,state:n};a.push(t)}if(0===a.length){const i=this.getLastNalUnit(t.samples);i&&(i.data=mt(i.data,e))}return t.naluState=n,a}}class js{constructor(t){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=t,this.bytesAvailable=t.byteLength,this.word=0,this.bitsAvailable=0}loadWord(){const t=this.data,e=this.bytesAvailable,i=t.byteLength-e,s=new Uint8Array(4),n=Math.min(4,e);if(0===n)throw new Error("no bytes available");s.set(t.subarray(i,i+n)),this.word=new DataView(s.buffer).getUint32(0),this.bitsAvailable=8*n,this.bytesAvailable-=n}skipBits(t){let e;t=Math.min(t,8*this.bytesAvailable+this.bitsAvailable),this.bitsAvailable>t?(this.word<<=t,this.bitsAvailable-=t):(e=(t-=this.bitsAvailable)>>3,t-=e<<3,this.bytesAvailable-=e,this.loadWord(),this.word<<=t,this.bitsAvailable-=t)}readBits(t){let e=Math.min(this.bitsAvailable,t);const i=this.word>>>32-e;if(t>32&&L.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=e,this.bitsAvailable>0)this.word<<=e;else{if(!(this.bytesAvailable>0))throw new Error("no bits available");this.loadWord()}return e=t-e,e>0&&this.bitsAvailable?i<>>t))return this.word<<=t,this.bitsAvailable-=t,t;return this.loadWord(),t+this.skipLZ()}skipUEG(){this.skipBits(1+this.skipLZ())}skipEG(){this.skipBits(1+this.skipLZ())}readUEG(){const t=this.skipLZ();return this.readBits(t+1)-1}readEG(){const t=this.readUEG();return 1&t?1+t>>>1:-1*(t>>>1)}readBoolean(){return 1===this.readBits(1)}readUByte(){return this.readBits(8)}readUShort(){return this.readBits(16)}readUInt(){return this.readBits(32)}}class Gs extends Bs{parsePES(t,e,i,s){const n=this.parseNALu(t,i.data,s);let r,a=this.VideoSample,o=!1;i.data=null,a&&n.length&&!t.audFound&&(this.pushAccessUnit(a,t),a=this.VideoSample=this.createVideoSample(!1,i.pts,i.dts)),n.forEach((s=>{var n,l;switch(s.type){case 1:{let e=!1;r=!0;const n=s.data;if(o&&n.length>4){const t=this.readSliceType(n);2!==t&&4!==t&&7!==t&&9!==t||(e=!0)}var c;e&&null!=(c=a)&&c.frame&&!a.key&&(this.pushAccessUnit(a,t),a=this.VideoSample=null),a||(a=this.VideoSample=this.createVideoSample(!0,i.pts,i.dts)),a.frame=!0,a.key=e;break}case 5:r=!0,null!=(n=a)&&n.frame&&!a.key&&(this.pushAccessUnit(a,t),a=this.VideoSample=null),a||(a=this.VideoSample=this.createVideoSample(!0,i.pts,i.dts)),a.key=!0,a.frame=!0;break;case 6:r=!0,_t(s.data,1,i.pts,e.samples);break;case 7:{var u,d;r=!0,o=!0;const e=s.data,i=this.readSPS(e);if(!t.sps||t.width!==i.width||t.height!==i.height||(null==(u=t.pixelRatio)?void 0:u[0])!==i.pixelRatio[0]||(null==(d=t.pixelRatio)?void 0:d[1])!==i.pixelRatio[1]){t.width=i.width,t.height=i.height,t.pixelRatio=i.pixelRatio,t.sps=[e];const s=e.subarray(1,4);let n="avc1.";for(let t=0;t<3;t++){let e=s[t].toString(16);e.length<2&&(e="0"+e),n+=e}t.codec=n}break}case 8:r=!0,t.pps=[s.data];break;case 9:r=!0,t.audFound=!0,null!=(l=a)&&l.frame&&(this.pushAccessUnit(a,t),a=null),a||(a=this.VideoSample=this.createVideoSample(!1,i.pts,i.dts));break;case 12:r=!0;break;default:r=!1}a&&r&&a.units.push(s)})),s&&a&&(this.pushAccessUnit(a,t),this.VideoSample=null)}getNALuType(t,e){return 31&t[e]}readSliceType(t){const e=new js(t);return e.readUByte(),e.readUEG(),e.readUEG()}skipScalingList(t,e){let i,s=8,n=8;for(let r=0;r{var n,l;switch(s.type){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:case 9:a||(a=this.VideoSample=this.createVideoSample(!1,i.pts,i.dts)),a.frame=!0,r=!0;break;case 16:case 17:case 18:case 21:var c;r=!0,o&&null!=(c=a)&&c.frame&&!a.key&&(this.pushAccessUnit(a,t),a=this.VideoSample=null),a||(a=this.VideoSample=this.createVideoSample(!0,i.pts,i.dts)),a.key=!0,a.frame=!0;break;case 19:case 20:r=!0,null!=(n=a)&&n.frame&&!a.key&&(this.pushAccessUnit(a,t),a=this.VideoSample=null),a||(a=this.VideoSample=this.createVideoSample(!0,i.pts,i.dts)),a.key=!0,a.frame=!0;break;case 39:r=!0,_t(s.data,2,i.pts,e.samples);break;case 32:r=!0,t.vps||("object"!=typeof t.params&&(t.params={}),t.params=b(t.params,this.readVPS(s.data)),this.initVPS=s.data),t.vps=[s.data];break;case 33:if(r=!0,o=!0,void 0===t.vps||t.vps[0]===this.initVPS||void 0===t.sps||this.matchSPS(t.sps[0],s.data)||(this.initVPS=t.vps[0],t.sps=t.pps=void 0),!t.sps){const e=this.readSPS(s.data);t.width=e.width,t.height=e.height,t.pixelRatio=e.pixelRatio,t.codec=e.codecString,t.sps=[],"object"!=typeof t.params&&(t.params={});for(const i in e.params)t.params[i]=e.params[i]}this.pushParameterSet(t.sps,s.data,t.vps),a||(a=this.VideoSample=this.createVideoSample(!0,i.pts,i.dts)),a.key=!0;break;case 34:if(r=!0,"object"==typeof t.params){if(!t.pps){t.pps=[];const e=this.readPPS(s.data);for(const i in e)t.params[i]=e[i]}this.pushParameterSet(t.pps,s.data,t.vps)}break;case 35:r=!0,t.audFound=!0,null!=(l=a)&&l.frame&&(this.pushAccessUnit(a,t),a=null),a||(a=this.VideoSample=this.createVideoSample(!1,i.pts,i.dts));break;default:r=!1}a&&r&&a.units.push(s)})),s&&a&&(this.pushAccessUnit(a,t),this.VideoSample=null)}pushParameterSet(t,e,i){(i&&i[0]===this.initVPS||!i&&!t.length)&&t.push(e)}getNALuType(t,e){return(126&t[e])>>>1}ebsp2rbsp(t){const e=new Uint8Array(t.byteLength);let i=0;for(let s=0;s=2&&3===t[s]&&0===t[s-1]&&0===t[s-2]||(e[i]=t[s],i++);return new Uint8Array(e.buffer,0,i)}pushAccessUnit(t,e){super.pushAccessUnit(t,e),this.initVPS&&(this.initVPS=null)}readVPS(t){const e=new js(t);return e.readUByte(),e.readUByte(),e.readBits(4),e.skipBits(2),e.readBits(6),{numTemporalLayers:e.readBits(3)+1,temporalIdNested:e.readBoolean()}}readSPS(t){const e=new js(this.ebsp2rbsp(t));e.readUByte(),e.readUByte(),e.readBits(4);const i=e.readBits(3);e.readBoolean();const s=e.readBits(2),n=e.readBoolean(),r=e.readBits(5),a=e.readUByte(),o=e.readUByte(),l=e.readUByte(),c=e.readUByte(),u=e.readUByte(),d=e.readUByte(),h=e.readUByte(),f=e.readUByte(),p=e.readUByte(),g=e.readUByte(),m=e.readUByte(),y=[],v=[];for(let t=0;t0)for(let t=i;t<8;t++)e.readBits(2);for(let t=0;t1&&e.readEG();for(let t=0;t0&&t<16?(P=[1,12,10,16,40,24,20,32,80,18,15,64,160,4,3,2][t-1],O=[1,11,11,11,33,11,11,11,33,11,11,33,99,3,2,1][t-1]):255===t&&(P=e.readBits(16),O=e.readBits(16))}if(e.readBoolean()&&e.readBoolean(),e.readBoolean()&&(e.readBits(3),e.readBoolean(),e.readBoolean()&&(e.readUByte(),e.readUByte(),e.readUByte())),e.readBoolean()&&(e.readUEG(),e.readUEG()),e.readBoolean(),e.readBoolean(),e.readBoolean(),$=e.readBoolean(),$&&(S+=e.readUEG(),k+=e.readUEG(),w+=e.readUEG(),A+=e.readUEG()),e.readBoolean()&&(M=e.readBits(32),F=e.readBits(32),e.readBoolean()&&e.readUEG(),e.readBoolean())){const t=e.readBoolean(),s=e.readBoolean();let n=!1;(t||s)&&(n=e.readBoolean(),n&&(e.readUByte(),e.readBits(5),e.readBoolean(),e.readBits(5)),e.readBits(4),e.readBits(4),n&&e.readBits(4),e.readBits(5),e.readBits(5),e.readBits(5));for(let r=0;r<=i;r++){N=e.readBoolean();let i=!1;N||e.readBoolean()?e.readEG():i=e.readBoolean();const r=i?1:e.readUEG()+1;if(t)for(let t=0;t>t&1)<<31-t)>>>0;let H=V.toString(16);return 1===r&&"2"===H&&(H="6"),{codecString:`hvc1.${j}${r}.${H}.${n?"H":"L"}${m}.B0`,params:{general_tier_flag:n,general_profile_idc:r,general_profile_space:s,general_profile_compatibility_flags:[a,o,l,c],general_constraint_indicator_flags:[u,d,h,f,p,g],general_level_idc:m,bit_depth:R+8,bit_depth_luma_minus8:R,bit_depth_chroma_minus8:L,min_spatial_segmentation_idc:x,chroma_format_idc:b,frame_rate:{fixed:N,fps:F/M}},width:U,height:B,pixelRatio:[P,O]}}readPPS(t){const e=new js(this.ebsp2rbsp(t));e.readUByte(),e.readUByte(),e.skipUEG(),e.skipUEG(),e.skipBits(2),e.skipBits(3),e.skipBits(2),e.skipUEG(),e.skipUEG(),e.skipEG(),e.skipBits(2),e.readBoolean()&&e.skipUEG(),e.skipEG(),e.skipEG(),e.skipBits(4);const i=e.readBoolean(),s=e.readBoolean();let n=1;return s&&i?n=0:s?n=3:i&&(n=2),{parallelismType:n}}matchSPS(t,e){return String.fromCharCode.apply(null,t).substr(3)===String.fromCharCode.apply(null,e).substr(3)}}const Hs=188;class Ks{constructor(t,e,i,s){this.logger=void 0,this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.sampleAes=null,this.pmtParsed=!1,this.audioCodec=void 0,this.videoCodec=void 0,this._pmtId=-1,this._videoTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.remainderData=null,this.videoParser=void 0,this.observer=t,this.config=e,this.typeSupported=i,this.logger=s,this.videoParser=null}static probe(t,e){const i=Ks.syncOffset(t);return i>0&&e.warn(`MPEG2-TS detected but first sync word found @ offset ${i}`),-1!==i}static syncOffset(t){const e=t.length;let i=Math.min(940,e-Hs)+1,s=0;for(;s1&&(0===r&&a>2||o+Hs>i))return r}s++}return-1}static createTrack(t,e){return{container:"video"===t||"audio"===t?"video/mp2t":void 0,type:t,id:Z[t],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:"audio"===t?e:void 0}}resetInitSegment(t,e,i,s){this.pmtParsed=!1,this._pmtId=-1,this._videoTrack=Ks.createTrack("video"),this._videoTrack.duration=s,this._audioTrack=Ks.createTrack("audio",s),this._id3Track=Ks.createTrack("id3"),this._txtTrack=Ks.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.remainderData=null,this.audioCodec=e,this.videoCodec=i}resetTimeStamp(){}resetContiguity(){const{_audioTrack:t,_videoTrack:e,_id3Track:i}=this;t&&(t.pesData=null),e&&(e.pesData=null),i&&(i.pesData=null),this.aacOverFlow=null,this.remainderData=null}demux(t,e,i=!1,s=!1){let n;i||(this.sampleAes=null);const r=this._videoTrack,a=this._audioTrack,o=this._id3Track,l=this._txtTrack;let c=r.pid,u=r.pesData,d=a.pid,h=o.pid,f=a.pesData,p=o.pesData,g=null,m=this.pmtParsed,y=this._pmtId,v=t.length;if(this.remainderData&&(v=(t=mt(this.remainderData,t)).length,this.remainderData=null),v>4>1){if(_=e+5+t[e+4],_===e+Hs)continue}else _=e+4;switch(v){case c:if(s){if(u&&(n=Js(u,this.logger))){if(null===this.videoParser)switch(r.segmentCodec){case"avc":this.videoParser=new Gs;break;case"hevc":this.videoParser=new Vs}null!==this.videoParser&&this.videoParser.parsePES(r,l,n,!1)}u={data:[],size:0}}u&&(u.data.push(t.subarray(_,e+Hs)),u.size+=e+Hs-_);break;case d:if(s){if(f&&(n=Js(f,this.logger)))switch(a.segmentCodec){case"aac":this.parseAACPES(a,n);break;case"mp3":this.parseMPEGPES(a,n);break;case"ac3":this.parseAC3PES(a,n)}f={data:[],size:0}}f&&(f.data.push(t.subarray(_,e+Hs)),f.size+=e+Hs-_);break;case h:s&&(p&&(n=Js(p,this.logger))&&this.parseID3PES(o,n),p={data:[],size:0}),p&&(p.data.push(t.subarray(_,e+Hs)),p.size+=e+Hs-_);break;case 0:s&&(_+=t[_]+1),y=this._pmtId=qs(t,_);break;case y:{s&&(_+=t[_]+1);const n=zs(t,_,this.typeSupported,i,this.observer,this.logger);c=n.videoPid,c>0&&(r.pid=c,r.segmentCodec=n.segmentVideoCodec),d=n.audioPid,d>0&&(a.pid=d,a.segmentCodec=n.segmentAudioCodec),h=n.id3Pid,h>0&&(o.pid=h),null===g||m||(this.logger.warn(`MPEG-TS PMT found at ${e} after unknown PID '${g}'. Backtracking to sync byte @${b} to parse all TS packets.`),g=null,e=b-188),m=this.pmtParsed=!0;break}case 17:case 8191:break;default:g=v}}else _++;_>0&&Ws(this.observer,new Error(`Found ${_} TS packet/s that do not start with 0x47`),void 0,this.logger),r.pesData=u,a.pesData=f,o.pesData=p;const E={audioTrack:a,videoTrack:r,id3Track:o,textTrack:l};return s&&this.extractRemainingSamples(E),E}flush(){const{remainderData:t}=this;let e;return this.remainderData=null,e=t?this.demux(t,-1,!1,!0):{videoTrack:this._videoTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(e),this.sampleAes?this.decrypt(e,this.sampleAes):e}extractRemainingSamples(t){const{audioTrack:e,videoTrack:i,id3Track:s,textTrack:n}=t,r=i.pesData,a=e.pesData,o=s.pesData;let l;if(r&&(l=Js(r,this.logger))){if(null===this.videoParser)switch(i.segmentCodec){case"avc":this.videoParser=new Gs;break;case"hevc":this.videoParser=new Vs}null!==this.videoParser&&(this.videoParser.parsePES(i,n,l,!0),i.pesData=null)}else i.pesData=r;if(a&&(l=Js(a,this.logger))){switch(e.segmentCodec){case"aac":this.parseAACPES(e,l);break;case"mp3":this.parseMPEGPES(e,l);break;case"ac3":this.parseAC3PES(e,l)}e.pesData=null}else null!=a&&a.size&&this.logger.log("last AAC PES packet truncated,might overlap between fragments"),e.pesData=a;o&&(l=Js(o,this.logger))?(this.parseID3PES(s,l),s.pesData=null):s.pesData=o}demuxSampleAes(t,e,i){const s=this.demux(t,i,!0,!this.config.progressive),n=this.sampleAes=new Us(this.observer,this.config,e);return this.decrypt(s,n)}decrypt(t,e){return new Promise((i=>{const{audioTrack:s,videoTrack:n}=t;s.samples&&"aac"===s.segmentCodec?e.decryptAacSamples(s.samples,0,(()=>{n.samples?e.decryptAvcSamples(n.samples,0,0,(()=>{i(t)})):i(t)})):n.samples&&e.decryptAvcSamples(n.samples,0,0,(()=>{i(t)}))}))}destroy(){this.observer&&this.observer.removeAllListeners(),this.config=this.logger=this.observer=null,this.aacOverFlow=this.videoParser=this.remainderData=this.sampleAes=null,this._videoTrack=this._audioTrack=this._id3Track=this._txtTrack=void 0}parseAACPES(t,e){let i=0;const s=this.aacOverFlow;let n,r,a,o=e.data;if(s){this.aacOverFlow=null;const e=s.missing,n=s.sample.unit.byteLength;if(-1===e)o=mt(s.sample.unit,o);else{const r=n-e;s.sample.unit.set(o.subarray(0,e),r),t.samples.push(s.sample),i=s.missing}}for(n=i,r=o.length;n0;)o+=r}}parseID3PES(t,e){if(void 0===e.pts)return void this.logger.warn("[tsdemuxer]: ID3 PES unknown PTS");const i=b({},e,{type:this._videoTrack?Es.emsg:Es.audioId3,duration:Number.POSITIVE_INFINITY});t.samples.push(i)}}function Ys(t,e){return((31&t[e+1])<<8)+t[e+2]}function qs(t,e){return(31&t[e+10])<<8|t[e+11]}function zs(t,e,i,s,n,r){const a={audioPid:-1,videoPid:-1,id3Pid:-1,segmentVideoCodec:"avc",segmentAudioCodec:"aac"},o=e+3+((15&t[e+1])<<8|t[e+2])-4;for(e+=12+((15&t[e+10])<<8|t[e+11]);e0){let s=e+5,n=l;for(;n>2;){106===t[s]&&(!0!==i.ac3?r.log("AC-3 audio found, not supported in this browser for now"):(a.audioPid=o,a.segmentAudioCodec="ac3"));const e=t[s+1]+2;s+=e,n-=e}}break;case 194:case 135:return Ws(n,new Error("Unsupported EC-3 in M2TS found"),void 0,r),a;case 36:-1===a.videoPid&&(a.videoPid=o,a.segmentVideoCodec="hevc",r.log("HEVC in M2TS found"))}e+=l+5}return a}function Ws(t,e,i,s){s.warn(`parsing error: ${e.message}`),t.emit(l.ERROR,l.ERROR,{type:a.MEDIA_ERROR,details:o.FRAG_PARSING_ERROR,fatal:!1,levelRetry:i,error:e,reason:e.message})}function Xs(t,e){e.log(`${t} with AES-128-CBC encryption found in unencrypted stream`)}function Js(t,e){let i,s,n,r,a,o=0;const l=t.data;if(!t||0===t.size)return null;for(;l[0].length<19&&l.length>1;)l[0]=mt(l[0],l[1]),l.splice(1,1);if(i=l[0],1===(i[0]<<16)+(i[1]<<8)+i[2]){if(s=(i[4]<<8)+i[5],s&&s>t.size-6)return null;const c=i[7];192&c&&(r=536870912*(14&i[9])+4194304*(255&i[10])+16384*(254&i[11])+128*(255&i[12])+(254&i[13])/2,64&c?(a=536870912*(14&i[14])+4194304*(255&i[15])+16384*(254&i[16])+128*(255&i[17])+(254&i[18])/2,r-a>54e5&&(e.warn(`${Math.round((r-a)/9e4)}s delta between PTS and DTS, align them`),r=a)):a=r),n=i[8];let u=n+9;if(t.size<=u)return null;t.size-=u;const d=new Uint8Array(t.size);for(let t=0,e=l.length;te){u-=e;continue}i=i.subarray(u),e-=u,u=0}d.set(i,o),o+=e}return s&&(s-=n+3),{data:d,pts:r,dts:a,len:s}}return null}class Qs{static getSilentFrame(t,e){if("mp4a.40.2"===t){if(1===e)return new Uint8Array([0,200,0,128,35,128]);if(2===e)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(3===e)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(4===e)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(5===e)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(6===e)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224])}else{if(1===e)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(2===e)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(3===e)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94])}}}const Zs=Math.pow(2,32)-1;class tn{static init(){let t;for(t in tn.types={avc1:[],avcC:[],hvc1:[],hvcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],dac3:[],"ac-3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]},tn.types)tn.types.hasOwnProperty(t)&&(tn.types[t]=[t.charCodeAt(0),t.charCodeAt(1),t.charCodeAt(2),t.charCodeAt(3)]);const e=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]);tn.HDLR_TYPES={video:e,audio:i};const s=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),n=new Uint8Array([0,0,0,0,0,0,0,0]);tn.STTS=tn.STSC=tn.STCO=n,tn.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),tn.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),tn.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),tn.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);const r=new Uint8Array([105,115,111,109]),a=new Uint8Array([97,118,99,49]),o=new Uint8Array([0,0,0,1]);tn.FTYP=tn.box(tn.types.ftyp,r,o,r,a),tn.DINF=tn.box(tn.types.dinf,tn.box(tn.types.dref,s))}static box(t,...e){let i=8,s=e.length;const n=s;for(;s--;)i+=e[s].byteLength;const r=new Uint8Array(i);for(r[0]=i>>24&255,r[1]=i>>16&255,r[2]=i>>8&255,r[3]=255&i,r.set(t,4),s=0,i=8;s>24&255,t>>16&255,t>>8&255,255&t,i>>24,i>>16&255,i>>8&255,255&i,s>>24,s>>16&255,s>>8&255,255&s,85,196,0,0]))}static mdia(t){return tn.box(tn.types.mdia,tn.mdhd(t.timescale||0,t.duration||0),tn.hdlr(t.type),tn.minf(t))}static mfhd(t){return tn.box(tn.types.mfhd,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t]))}static minf(t){return"audio"===t.type?tn.box(tn.types.minf,tn.box(tn.types.smhd,tn.SMHD),tn.DINF,tn.stbl(t)):tn.box(tn.types.minf,tn.box(tn.types.vmhd,tn.VMHD),tn.DINF,tn.stbl(t))}static moof(t,e,i){return tn.box(tn.types.moof,tn.mfhd(t),tn.traf(i,e))}static moov(t){let e=t.length;const i=[];for(;e--;)i[e]=tn.trak(t[e]);return tn.box.apply(null,[tn.types.moov,tn.mvhd(t[0].timescale||0,t[0].duration||0)].concat(i).concat(tn.mvex(t)))}static mvex(t){let e=t.length;const i=[];for(;e--;)i[e]=tn.trex(t[e]);return tn.box.apply(null,[tn.types.mvex,...i])}static mvhd(t,e){e*=t;const i=Math.floor(e/(Zs+1)),s=Math.floor(e%(Zs+1)),n=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,255&t,i>>24,i>>16&255,i>>8&255,255&i,s>>24,s>>16&255,s>>8&255,255&s,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 tn.box(tn.types.mvhd,n)}static sdtp(t){const e=t.samples||[],i=new Uint8Array(4+e.length);let s,n;for(s=0;s>>8&255),n.push(255&s),n=n.concat(Array.prototype.slice.call(i));for(e=0;e>>8&255),r.push(255&s),r=r.concat(Array.prototype.slice.call(i));const a=tn.box(tn.types.avcC,new Uint8Array([1,n[3],n[4],n[5],255,224|t.sps.length].concat(n).concat([t.pps.length]).concat(r))),o=t.width,l=t.height,c=t.pixelRatio[0],u=t.pixelRatio[1];return tn.box(tn.types.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,o>>8&255,255&o,l>>8&255,255&l,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),a,tn.box(tn.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),tn.box(tn.types.pasp,new Uint8Array([c>>24,c>>16&255,c>>8&255,255&c,u>>24,u>>16&255,u>>8&255,255&u])))}static esds(t){const e=t.config;return new Uint8Array([0,0,0,0,3,25,0,1,0,4,17,64,21,0,0,0,0,0,0,0,0,0,0,0,5,2,...e,6,1,2])}static audioStsd(t){const e=t.samplerate||0;return new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t.channelCount||0,0,16,0,0,0,0,e>>8&255,255&e,0,0])}static mp4a(t){return tn.box(tn.types.mp4a,tn.audioStsd(t),tn.box(tn.types.esds,tn.esds(t)))}static mp3(t){return tn.box(tn.types[".mp3"],tn.audioStsd(t))}static ac3(t){return tn.box(tn.types["ac-3"],tn.audioStsd(t),tn.box(tn.types.dac3,t.config))}static stsd(t){const{segmentCodec:e}=t;if("audio"===t.type){if("aac"===e)return tn.box(tn.types.stsd,tn.STSD,tn.mp4a(t));if("ac3"===e&&t.config)return tn.box(tn.types.stsd,tn.STSD,tn.ac3(t));if("mp3"===e&&"mp3"===t.codec)return tn.box(tn.types.stsd,tn.STSD,tn.mp3(t))}else{if(!t.pps||!t.sps)throw new Error("video track missing pps or sps");if("avc"===e)return tn.box(tn.types.stsd,tn.STSD,tn.avc1(t));if("hevc"===e&&t.vps)return tn.box(tn.types.stsd,tn.STSD,tn.hvc1(t))}throw new Error(`unsupported ${t.type} segment codec (${e}/${t.codec})`)}static tkhd(t){const e=t.id,i=(t.duration||0)*(t.timescale||0),s=t.width||0,n=t.height||0,r=Math.floor(i/(Zs+1)),a=Math.floor(i%(Zs+1));return tn.box(tn.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,255&e,0,0,0,0,r>>24,r>>16&255,r>>8&255,255&r,a>>24,a>>16&255,a>>8&255,255&a,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,s>>8&255,255&s,0,0,n>>8&255,255&n,0,0]))}static traf(t,e){const i=tn.sdtp(t),s=t.id,n=Math.floor(e/(Zs+1)),r=Math.floor(e%(Zs+1));return tn.box(tn.types.traf,tn.box(tn.types.tfhd,new Uint8Array([0,0,0,0,s>>24,s>>16&255,s>>8&255,255&s])),tn.box(tn.types.tfdt,new Uint8Array([1,0,0,0,n>>24,n>>16&255,n>>8&255,255&n,r>>24,r>>16&255,r>>8&255,255&r])),tn.trun(t,i.length+16+20+8+16+8+8),i)}static trak(t){return t.duration=t.duration||4294967295,tn.box(tn.types.trak,tn.tkhd(t),tn.mdia(t))}static trex(t){const e=t.id;return tn.box(tn.types.trex,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,255&e,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))}static trun(t,e){const i=t.samples||[],s=i.length,n=12+16*s,r=new Uint8Array(n);let a,o,l,c,u,d;for(e+=8+n,r.set(["video"===t.type?1:0,0,15,1,s>>>24&255,s>>>16&255,s>>>8&255,255&s,e>>>24&255,e>>>16&255,e>>>8&255,255&e],0),a=0;a>>24&255,l>>>16&255,l>>>8&255,255&l,c>>>24&255,c>>>16&255,c>>>8&255,255&c,u.isLeading<<2|u.dependsOn,u.isDependedOn<<6|u.hasRedundancy<<4|u.paddingValue<<1|u.isNonSync,61440&u.degradPrio,15&u.degradPrio,d>>>24&255,d>>>16&255,d>>>8&255,255&d],12+16*a);return tn.box(tn.types.trun,r)}static initSegment(t){tn.types||tn.init();const e=tn.moov(t);return mt(tn.FTYP,e)}static hvc1(t){const e=t.params,i=[t.vps,t.sps,t.pps],s=new Uint8Array([1,e.general_profile_space<<6|(e.general_tier_flag?32:0)|e.general_profile_idc,e.general_profile_compatibility_flags[0],e.general_profile_compatibility_flags[1],e.general_profile_compatibility_flags[2],e.general_profile_compatibility_flags[3],e.general_constraint_indicator_flags[0],e.general_constraint_indicator_flags[1],e.general_constraint_indicator_flags[2],e.general_constraint_indicator_flags[3],e.general_constraint_indicator_flags[4],e.general_constraint_indicator_flags[5],e.general_level_idc,240|e.min_spatial_segmentation_idc>>8,255&e.min_spatial_segmentation_idc,252|e.parallelismType,252|e.chroma_format_idc,248|e.bit_depth_luma_minus8,248|e.bit_depth_chroma_minus8,0,parseInt(e.frame_rate.fps),3|e.temporal_id_nested<<2|e.num_temporal_layers<<3|(e.frame_rate.fixed?64:0),i.length]);let n=s.length;for(let t=0;t>8,255&i[t][e].length]),n),n+=2,r.set(i[t][e],n),n+=i[t][e].length}const o=tn.box(tn.types.hvcC,r),l=t.width,c=t.height,u=t.pixelRatio[0],d=t.pixelRatio[1];return tn.box(tn.types.hvc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,l>>8&255,255&l,c>>8&255,255&c,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),o,tn.box(tn.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),tn.box(tn.types.pasp,new Uint8Array([u>>24,u>>16&255,u>>8&255,255&u,d>>24,d>>16&255,d>>8&255,255&d])))}}tn.types=void 0,tn.HDLR_TYPES=void 0,tn.STTS=void 0,tn.STSC=void 0,tn.STCO=void 0,tn.STSZ=void 0,tn.VMHD=void 0,tn.SMHD=void 0,tn.STSD=void 0,tn.FTYP=void 0,tn.DINF=void 0;function en(t,e,i=1,s=!1){const n=t*e*i;return s?Math.round(n):n}function sn(t,e=!1){return en(t,1e3,1/9e4,e)}let nn,rn=null,an=null;function on(t,e,i,s){return{duration:e,size:i,cts:s,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:t?2:1,isNonSync:t?0:1}}}class ln{constructor(t,e,i,s){if(this.logger=void 0,this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=null,this._initDTS=null,this.nextAvcDts=null,this.nextAudioPts=null,this.videoSampleDuration=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.videoTrackConfig=void 0,this.observer=t,this.config=e,this.typeSupported=i,this.logger=s,this.ISGenerated=!1,null===rn){const t=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);rn=t?parseInt(t[1]):0}if(null===an){const t=navigator.userAgent.match(/Safari\/(\d+)/i);an=t?parseInt(t[1]):0}}destroy(){this.config=this.videoTrackConfig=this._initPTS=this._initDTS=null}resetTimeStamp(t){this.logger.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=t}resetNextTimestamp(){this.logger.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1}resetInitSegment(){this.logger.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1,this.videoTrackConfig=void 0}getVideoStartPts(t){let e=!1;const i=t[0].pts,s=t.reduce(((t,s)=>{let n=s.pts,r=n-t;return r<-4294967296&&(e=!0,n=cn(n,i),r=n-t),r>0?t:n}),i);return e&&this.logger.debug("PTS rollover detected"),s}remux(t,e,i,s,n,r,a,o){let l,c,u,d,h,f,g=n,m=n;const y=t.pid>-1,v=e.pid>-1,b=e.samples.length,_=t.samples.length>0,E=a&&b>0||b>1;if((!y||_)&&(!v||E)||this.ISGenerated||a){if(this.ISGenerated){var T,S,k,w;const t=this.videoTrackConfig;(t&&(e.width!==t.width||e.height!==t.height||(null==(T=e.pixelRatio)?void 0:T[0])!==(null==(S=t.pixelRatio)?void 0:S[0])||(null==(k=e.pixelRatio)?void 0:k[1])!==(null==(w=t.pixelRatio)?void 0:w[1]))||!t&&E||null===this.nextAudioPts&&_)&&this.resetInitSegment()}this.ISGenerated||(u=this.generateIS(t,e,n,r));const i=this.isVideoContiguous;let s,a=-1;if(E&&(a=function(t){for(let e=0;e0){this.logger.warn(`[mp4-remuxer]: Dropped ${a} out of ${b} video samples due to a missing keyframe`);const t=this.getVideoStartPts(e.samples);e.samples=e.samples.slice(a),e.dropped+=a,m+=(e.samples[0].pts-t)/e.inputTimeScale,s=m}else-1===a&&(this.logger.warn(`[mp4-remuxer]: No keyframe found out of ${b} video samples`),f=!1);if(this.ISGenerated){if(_&&E){const i=this.getVideoStartPts(e.samples),s=(cn(t.samples[0].pts,i)-i)/e.inputTimeScale;g+=Math.max(0,s),m+=Math.max(0,-s)}if(_){if(t.samplerate||(this.logger.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),u=this.generateIS(t,e,n,r)),c=this.remuxAudio(t,g,this.isAudioContiguous,r,v||E||o===p?m:void 0),E){const s=c?c.endPTS-c.startPTS:0;e.inputTimeScale||(this.logger.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),u=this.generateIS(t,e,n,r)),l=this.remuxVideo(e,m,i,s)}}else E&&(l=this.remuxVideo(e,m,i,0));l&&(l.firstKeyFrame=a,l.independent=-1!==a,l.firstKeyFramePTS=s)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(i.samples.length&&(h=un(i,n,this._initPTS,this._initDTS)),s.samples.length&&(d=dn(s,n,this._initPTS))),{audio:c,video:l,initSegment:u,independent:f,text:d,id3:h}}generateIS(t,e,i,s){const n=t.samples,r=e.samples,a=this.typeSupported,o={},l=this._initPTS;let c,u,d,h=!l||s,f="audio/mp4";if(h&&(c=u=1/0),t.config&&n.length){switch(t.timescale=t.samplerate,t.segmentCodec){case"mp3":a.mpeg?(f="audio/mpeg",t.codec=""):a.mp3&&(t.codec="mp3");break;case"ac3":t.codec="ac-3"}o.audio={id:"audio",container:f,codec:t.codec,initSegment:"mp3"===t.segmentCodec&&a.mpeg?new Uint8Array(0):tn.initSegment([t]),metadata:{channelCount:t.channelCount}},h&&(d=t.inputTimeScale,l&&d===l.timescale?h=!1:c=u=n[0].pts-Math.round(d*i))}if(e.sps&&e.pps&&r.length){if(e.timescale=e.inputTimeScale,o.video={id:"main",container:"video/mp4",codec:e.codec,initSegment:tn.initSegment([e]),metadata:{width:e.width,height:e.height}},h)if(d=e.inputTimeScale,l&&d===l.timescale)h=!1;else{const t=this.getVideoStartPts(r),e=Math.round(d*i);u=Math.min(u,cn(r[0].dts,t)-e),c=Math.min(c,t-e)}this.videoTrackConfig={width:e.width,height:e.height,pixelRatio:e.pixelRatio}}if(Object.keys(o).length)return this.ISGenerated=!0,h?(this._initPTS={baseTime:c,timescale:d},this._initDTS={baseTime:u,timescale:d}):c=d=void 0,{tracks:o,initPTS:c,timescale:d}}remuxVideo(t,e,i,s){const n=t.inputTimeScale,r=t.samples,c=[],u=r.length,d=this._initPTS;let h,f,p=this.nextAvcDts,g=8,m=this.videoSampleDuration,y=Number.POSITIVE_INFINITY,v=Number.NEGATIVE_INFINITY,_=!1;if(!i||null===p){const t=e*n,s=r[0].pts-cn(r[0].dts,r[0].pts);rn&&null!==p&&Math.abs(t-s-p)<15e3?i=!0:p=t-s}const E=d.baseTime*n/d.timescale;for(let t=0;t0?t-1:t].dts&&(_=!0)}_&&r.sort((function(t,e){const i=t.dts-e.dts,s=t.pts-e.pts;return i||s})),h=r[0].dts,f=r[r.length-1].dts;const T=f-h,S=T?Math.round(T/(u-1)):m||t.inputTimeScale/30;if(i){const i=h-p,s=i>S,n=i<-1;if((s||n)&&(s?this.logger.warn(`${(t.segmentCodec||"").toUpperCase()}: ${sn(i,!0)} ms (${i}dts) hole between fragments detected at ${e.toFixed(3)}`):this.logger.warn(`${(t.segmentCodec||"").toUpperCase()}: ${sn(-i,!0)} ms (${i}dts) overlapping between fragments detected at ${e.toFixed(3)}`),!n||p>=r[0].pts||rn)){h=p;const t=r[0].pts-i;if(s)r[0].dts=h,r[0].pts=t;else{let e=!0;for(let s=0;st&&e);s++){const t=r[s].pts;if(r[s].dts-=i,r[s].pts-=i,s0?e.dts-r[t-1].dts:S;if(a=t>0?e.pts-r[t-1].pts:S,i.stretchShortVideoTrack&&null!==this.nextAudioPts){const t=Math.floor(i.maxBufferHole*n),r=(s?y+s*n:this.nextAudioPts)-e.pts;r>t?(m=r-o,m<0?m=o:C=!0,this.logger.log(`[mp4-remuxer]: It is approximately ${r/90} ms to the next segment; using duration ${m/90} ms for the last video frame.`)):m=o}else m=o}const l=Math.round(e.pts-e.dts);D=Math.min(D,m),P=Math.max(P,m),x=Math.min(x,a),O=Math.max(O,a),c.push(on(e.key,m,o,l))}if(c.length)if(rn){if(rn<70){const t=c[0].flags;t.dependsOn=2,t.isNonSync=0}}else if(an&&O-x0&&(s&&Math.abs(_-v)<9e3||Math.abs(cn(m[0].pts-E,_)-v)<20*d),m.forEach((function(t){t.pts=cn(t.pts-E,_)})),!i||v<0){if(m=m.filter((t=>t.pts>=0)),!m.length)return;v=0===n?0:s&&!g?Math.max(0,_):m[0].pts}if("aac"===t.segmentCodec){const e=this.config.maxAudioFramesDrift;for(let i=0,s=v;i=e*d&&l<1e4&&g){let e=Math.round(o/d);s=a-e*d,s<0&&(e--,s+=d),0===i&&(this.nextAudioPts=v=s),this.logger.warn(`[mp4-remuxer]: Injecting ${e} audio frame @ ${(s/r).toFixed(3)}s due to ${Math.round(1e3*o/r)} ms gap.`);for(let r=0;r0))return;w+=y;try{T=new Uint8Array(w)}catch(t){return void this.observer.emit(l.ERROR,l.ERROR,{type:a.MUX_ERROR,details:o.REMUX_ALLOC_ERROR,fatal:!1,error:t,bytes:w,reason:`fail allocating audio mdat ${w}`})}f||(new DataView(T.buffer).setUint32(0,w),T.set(tn.types.mdat,4))}T.set(n,y);const d=n.byteLength;y+=d,p.push(on(!0,u,d,0)),k=r}const R=p.length;if(!R)return;const L=p[p.length-1];this.nextAudioPts=v=k+c*L.duration;const I=f?new Uint8Array(0):tn.moof(t.sequenceNumber++,S/c,b({},t,{samples:p}));t.samples=[];const C=S/r,D=v/r,x={data1:I,data2:T,startPTS:C,endPTS:D,startDTS:C,endDTS:D,type:"audio",hasAudio:!0,hasVideo:!1,nb:R};return this.isAudioContiguous=!0,x}}function cn(t,e){let i;if(null===e)return t;for(i=e4294967296;)t+=i;return t}function un(t,e,i,s){const n=t.samples.length;if(!n)return;const r=t.inputTimeScale;for(let a=0;at.pts-e.pts));const r=t.samples;return t.samples=[],{samples:r}}function hn(t,e){const i=null==t?void 0:t.codec;return i&&i.length>4?i:e===V?"ec-3"===i||"ac-3"===i||"alac"===i?i:"fLaC"===i||"Opus"===i?Pt(i,!1):(L.warn(`Unhandled audio codec "${i}" in mp4 MAP`),i||"mp4a"):(L.warn(`Unhandled video codec "${i}" in mp4 MAP`),i||"avc1")}try{nn=self.performance.now.bind(self.performance)}catch(t){nn=Date.now}const fn=[{demux:class{constructor(t,e){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=e}resetTimeStamp(){}resetInitSegment(t,e,i,s){const n=this.videoTrack=Ts("video",1),r=this.audioTrack=Ts("audio",1),a=this.txtTrack=Ts("text",1);if(this.id3Track=Ts("id3",1),this.timeOffset=0,null==t||!t.byteLength)return;const o=lt(t);if(o.video){const{id:t,timescale:e,codec:i,supplemental:s}=o.video;n.id=t,n.timescale=a.timescale=e,n.codec=i,n.supplemental=s}if(o.audio){const{id:t,timescale:e,codec:i}=o.audio;r.id=t,r.timescale=e,r.codec=i}a.id=Z.text,n.sampleDuration=0,n.duration=r.duration=s}resetContiguity(){this.remainderData=null}static probe(t){return function(t){const e=t.byteLength;for(let i=0;i8&&109===t[i+4]&&111===t[i+5]&&111===t[i+6]&&102===t[i+7])return!0;i=s>1?i+s:e}return!1}(t)}demux(t,e){this.timeOffset=e;let i=t;const s=this.videoTrack,n=this.txtTrack;if(this.config.progressive){this.remainderData&&(i=mt(this.remainderData,t));const e=function(t){const e={valid:null,remainder:null},i=at(t,["moof"]);if(i.length<2)return e.remainder=t,e;const s=i[i.length-1];return e.valid=t.slice(0,s.byteOffset-8),e.remainder=t.slice(s.byteOffset-8),e}(i);this.remainderData=e.remainder,s.samples=e.valid||new Uint8Array}else s.samples=i;const r=this.extractID3Track(s,e);return n.samples=yt(e,s),{videoTrack:s,audioTrack:this.audioTrack,id3Track:r,textTrack:this.txtTrack}}flush(){const t=this.timeOffset,e=this.videoTrack,i=this.txtTrack;e.samples=this.remainderData||new Uint8Array,this.remainderData=null;const s=this.extractID3Track(e,this.timeOffset);return i.samples=yt(t,e),{videoTrack:e,audioTrack:Ts(),id3Track:s,textTrack:Ts()}}extractID3Track(t,e){const i=this.id3Track;if(t.samples.length){const s=at(t.samples,["emsg"]);s&&s.forEach((t=>{const s=function(t){const e=t[0];let i="",s="",r=0,a=0,o=0,l=0,c=0,u=0;if(0===e){for(;"\0"!==tt(t.subarray(u,u+1));)i+=tt(t.subarray(u,u+1)),u+=1;for(i+=tt(t.subarray(u,u+1)),u+=1;"\0"!==tt(t.subarray(u,u+1));)s+=tt(t.subarray(u,u+1)),u+=1;s+=tt(t.subarray(u,u+1)),u+=1,r=it(t,12),a=it(t,16),l=it(t,20),c=it(t,24),u=28}else if(1===e){u+=4,r=it(t,u),u+=4;const e=it(t,u);u+=4;const a=it(t,u);for(u+=4,o=2**32*e+a,n(o)||(o=Number.MAX_SAFE_INTEGER,L.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),l=it(t,u),u+=4,c=it(t,u),u+=4;"\0"!==tt(t.subarray(u,u+1));)i+=tt(t.subarray(u,u+1)),u+=1;for(i+=tt(t.subarray(u,u+1)),u+=1;"\0"!==tt(t.subarray(u,u+1));)s+=tt(t.subarray(u,u+1)),u+=1;s+=tt(t.subarray(u,u+1)),u+=1}return{schemeIdUri:i,value:s,timeScale:r,presentationTime:o,presentationTimeDelta:a,eventDuration:l,id:c,payload:t.subarray(u,t.byteLength)}}(t);if(Fs.test(s.schemeIdUri)){const t=$s(s,e);let n=4294967295===s.eventDuration?Number.POSITIVE_INFINITY:s.eventDuration/s.timeScale;n<=.001&&(n=Number.POSITIVE_INFINITY);const r=s.payload;i.samples.push({data:r,len:r.byteLength,dts:t,pts:t,type:Es.emsg,duration:n})}else if(this.config.enableEmsgKLVMetadata&&s.schemeIdUri.startsWith("urn:misb:KLV:bin:1910.1")){const t=$s(s,e);i.samples.push({data:s.payload,len:s.payload.byteLength,dts:t,pts:t,type:Es.misbklv,duration:Number.POSITIVE_INFINITY})}}))}return i}demuxSampleAes(t,e,i){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))}destroy(){this.config=null,this.remainderData=null,this.videoTrack=this.audioTrack=this.id3Track=this.txtTrack=void 0}},remux:class{constructor(t,e,i,s){this.logger=void 0,this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=null,this.initTracks=void 0,this.lastEndTime=null,this.logger=s}destroy(){}resetTimeStamp(t){this.initPTS=t,this.lastEndTime=null}resetNextTimestamp(){this.lastEndTime=null}resetInitSegment(t,e,i,s){this.audioCodec=e,this.videoCodec=i,this.generateInitSegment(function(t,e){if(!t||!e)return t;const i=e.keyId;return i&&e.isCommonEncryption&&at(t,["moov","trak"]).forEach((t=>{const e=at(t,["mdia","minf","stbl","stsd"])[0].subarray(8);let s=at(e,["enca"]);const n=s.length>0;n||(s=at(e,["encv"])),s.forEach((t=>{at(n?t.subarray(28):t.subarray(78),["sinf"]).forEach((t=>{const e=pt(t);if(e){const t=e.subarray(8,24);t.some((t=>0!==t))||(L.log(`[eme] Patching keyId in 'enc${n?"a":"v"}>sinf>>tenc' box: ${x(t)} -> ${x(i)}`),e.set(i,8))}}))}))})),t}(t,s)),this.emitInitSegment=!0}generateInitSegment(t){let{audioCodec:e,videoCodec:i}=this;if(null==t||!t.byteLength)return this.initTracks=void 0,void(this.initData=void 0);const s=this.initData=lt(t);s.audio&&(e=hn(s.audio,V)),s.video&&(i=hn(s.video,H));const n={};s.audio&&s.video?n.audiovideo={container:"video/mp4",codec:e+","+i,supplemental:s.video.supplemental,initSegment:t,id:"main"}:s.audio?n.audio={container:"audio/mp4",codec:e,initSegment:t,id:"audio"}:s.video?n.video={container:"video/mp4",codec:i,supplemental:s.video.supplemental,initSegment:t,id:"main"}:this.logger.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=n}remux(t,e,i,n,r,a){var o,l;let{initPTS:c,lastEndTime:u}=this;const d={audio:void 0,video:void 0,text:n,id3:i,initSegment:void 0};s(u)||(u=this.lastEndTime=r||0);const h=e.samples;if(null==h||!h.length)return d;const f={initPTS:void 0,timescale:1};let p=this.initData;if(null!=(o=p)&&o.length||(this.generateInitSegment(h),p=this.initData),null==(l=p)||!l.length)return this.logger.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),d;this.emitInitSegment&&(f.tracks=this.initTracks,this.emitInitSegment=!1);const g=function(t,e){let i=0,n=0,r=0;const a=at(t,["moof","traf"]);for(let t=0;tt+e.info.duration||0),0);i=Math.max(i,t+s.earliestPresentationTime/s.timescale),n=i-e}}if(n&&s(n))return n}return n||r}(h,p),m=function(t,e){return at(e,["moof","traf"]).reduce(((e,i)=>{const n=at(i,["tfdt"])[0],r=n[0],a=at(i,["tfhd"]).reduce(((e,i)=>{const a=it(i,4),o=t[a];if(o){let t=it(n,4);if(1===r){if(t===J)return L.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"),e;t*=J+1,t+=it(n,8)}const i=t/(o.timescale||9e4);if(s(i)&&(null===e||in}(c,y,r,g)&&f.timescale===c.timescale||(f.initPTS=y-r,c&&1===c.timescale&&this.logger.warn(`Adjusting initPTS @${r} from ${c.baseTime/c.timescale} to ${f.initPTS}`),this.initPTS=c={baseTime:f.initPTS,timescale:1});const v=t?y-c.baseTime/c.timescale:u,b=v+g;!function(t,e,i){at(e,["moof","traf"]).forEach((e=>{at(e,["tfhd"]).forEach((s=>{const n=it(s,4),r=t[n];if(!r)return;const a=r.timescale||9e4;at(e,["tfdt"]).forEach((t=>{const e=t[0],s=i*a;if(s){let i=it(t,4);if(0===e)i-=s,i=Math.max(i,0),rt(t,4,i);else{i*=Math.pow(2,32),i+=it(t,8),i-=s,i=Math.max(i,0);const e=Math.floor(i/(J+1)),n=Math.floor(i%(J+1));rt(t,4,e),rt(t,8,n)}}}))}))}))}(p,h,c.baseTime/c.timescale),g>0?this.lastEndTime=b:(this.logger.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());const _=!!p.audio,E=!!p.video;let T="";_&&(T+="audio"),E&&(T+="video");const S={data1:h,startPTS:v,startDTS:v,endPTS:b,endDTS:b,type:T,hasAudio:_,hasVideo:E,nb:1,dropped:0};return d.audio="audio"===S.type?S:void 0,d.video="audio"!==S.type?S:void 0,d.initSegment=f,d.id3=un(i,r,c,c),n.samples.length&&(d.text=dn(n,r,c)),d}}},{demux:Ks,remux:ln},{demux:class extends Ss{constructor(t,e){super(),this.observer=void 0,this.config=void 0,this.observer=t,this.config=e}resetInitSegment(t,e,i,s){super.resetInitSegment(t,e,i,s),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:e,duration:s,inputTimeScale:9e4,dropped:0}}static probe(t,e){if(!t)return!1;const i=es(t,0);let s=(null==i?void 0:i.length)||0;if(Os(t,s))return!1;for(let i=t.length;s0&&null!=(null==e?void 0:e.key)&&null!==e.iv&&null!=e.method&&(i=e),i}(r,e);if(T&&Ye(T.method)){const t=this.getDecrypter(),e=qe(T.method);if(!t.isSync())return this.asyncResult=!0,this.decryptionPromise=t.webCryptoDecrypt(r,T.key.buffer,T.iv.buffer,e).then((t=>{const e=this.push(t,null,i);return this.decryptionPromise=null,e})),this.decryptionPromise;{let s=t.softwareDecrypt(r,T.key.buffer,T.iv.buffer,e);if(i.part>-1){const e=t.flush();s=e?e.buffer:e}if(!s)return n.executeEnd=nn(),gn(i);r=new Uint8Array(s)}}const S=this.needsProbing(h,f);if(S){const t=this.configureTransmuxer(r);if(t)return this.logger.warn(`[transmuxer] ${t.message}`),this.observer.emit(l.ERROR,l.ERROR,{type:a.MEDIA_ERROR,details:o.FRAG_PARSING_ERROR,fatal:!1,error:t,reason:t.message}),n.executeEnd=nn(),gn(i)}(h||f||m||S)&&this.resetInitSegment(E,y,v,_,e),(h||m||S)&&this.resetInitialTimestamp(b),d||this.resetContiguity();const k=this.transmux(r,T,g,p,i);this.asyncResult=mn(k);const w=this.currentTransmuxState;return w.contiguous=!0,w.discontinuity=!1,w.trackSwitch=!1,n.executeEnd=nn(),k}flush(t){const e=t.transmuxing;e.executeStart=nn();const{decrypter:i,currentTransmuxState:s,decryptionPromise:n}=this;if(n)return this.asyncResult=!0,n.then((()=>this.flush(t)));const r=[],{timeOffset:a}=s;if(i){const e=i.flush();e&&r.push(this.push(e.buffer,null,t))}const{demuxer:o,remuxer:l}=this;if(!o||!l){e.executeEnd=nn();const i=[gn(t)];return this.asyncResult?Promise.resolve(i):i}const c=o.flush(a);return mn(c)?(this.asyncResult=!0,c.then((e=>(this.flushRemux(r,e,t),r)))):(this.flushRemux(r,c,t),this.asyncResult?Promise.resolve(r):r)}flushRemux(t,e,i){const{audioTrack:s,videoTrack:n,id3Track:r,textTrack:a}=e,{accurateTimeOffset:o,timeOffset:l}=this.currentTransmuxState;this.logger.log(`[transmuxer.ts]: Flushed ${this.id} sn: ${i.sn}${i.part>-1?" part: "+i.part:""} of ${this.id===f?"level":"track"} ${i.level}`);const c=this.remuxer.remux(s,n,r,a,l,o,!0,this.id);t.push({remuxResult:c,chunkMeta:i}),i.transmuxing.executeEnd=nn()}resetInitialTimestamp(t){const{demuxer:e,remuxer:i}=this;e&&i&&(e.resetTimeStamp(t),i.resetTimeStamp(t))}resetContiguity(){const{demuxer:t,remuxer:e}=this;t&&e&&(t.resetContiguity(),e.resetNextTimestamp())}resetInitSegment(t,e,i,s,n){const{demuxer:r,remuxer:a}=this;r&&a&&(r.resetInitSegment(t,e,i,s),a.resetInitSegment(t,e,i,n))}destroy(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)}transmux(t,e,i,s,n){let r;return r=e&&"SAMPLE-AES"===e.method?this.transmuxSampleAes(t,e,i,s,n):this.transmuxUnencrypted(t,i,s,n),r}transmuxUnencrypted(t,e,i,s){const{audioTrack:n,videoTrack:r,id3Track:a,textTrack:o}=this.demuxer.demux(t,e,!1,!this.config.progressive);return{remuxResult:this.remuxer.remux(n,r,a,o,e,i,!1,this.id),chunkMeta:s}}transmuxSampleAes(t,e,i,s,n){return this.demuxer.demuxSampleAes(t,e,i).then((t=>({remuxResult:this.remuxer.remux(t.audioTrack,t.videoTrack,t.id3Track,t.textTrack,i,s,!1,this.id),chunkMeta:n})))}configureTransmuxer(t){const{config:e,observer:i,typeSupported:s}=this;let n;for(let e=0,i=fn.length;e({remuxResult:{},chunkMeta:t});function mn(t){return"then"in t&&t.then instanceof Function}class yn{constructor(t,e,i,s,n){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=t,this.videoCodec=e,this.initSegmentData=i,this.duration=s,this.defaultInitPts=n||null}}class vn{constructor(t,e,i,s,n,r){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=t,this.contiguous=e,this.accurateTimeOffset=i,this.trackSwitch=s,this.timeOffset=n,this.initSegmentChange=r}}let bn=0;class _n{constructor(t,e,i,s){this.error=null,this.hls=void 0,this.id=void 0,this.instanceNo=bn++,this.observer=void 0,this.frag=null,this.part=null,this.useWorker=void 0,this.workerContext=null,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0,this.onWorkerMessage=t=>{const e=t.data,i=this.hls;if(i&&null!=e&&e.event&&e.instanceNo===this.instanceNo)switch(e.event){case"init":{var s;const t=null==(s=this.workerContext)?void 0:s.objectURL;t&&self.URL.revokeObjectURL(t);break}case"transmuxComplete":this.handleTransmuxComplete(e.data);break;case"flush":this.onFlush(e.data);break;case"workerLog":i.logger[e.data.logType]&&i.logger[e.data.logType](e.data.message);break;default:e.data=e.data||{},e.data.frag=this.frag,e.data.part=this.part,e.data.id=this.id,i.trigger(e.event,e.data)}},this.onWorkerError=t=>{if(!this.hls)return;const e=new Error(`${t.message} (${t.filename}:${t.lineno})`);this.hls.config.enableWorker=!1,this.hls.logger.warn(`Error in "${this.id}" Web Worker, fallback to inline`),this.hls.trigger(l.ERROR,{type:a.OTHER_ERROR,details:o.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:e})};const n=t.config;this.hls=t,this.id=e,this.useWorker=!!n.enableWorker,this.onTransmuxComplete=i,this.onFlush=s;const r=(t,e)=>{(e=e||{}).frag=this.frag||void 0,t===l.ERROR&&(e.parent=this.id,e.part=this.part,this.error=e.error),this.hls.trigger(t,e)};this.observer=new Wi,this.observer.on(l.FRAG_DECRYPTED,r),this.observer.on(l.ERROR,r);const c=Mt(n.preferManagedMediaSource);if(this.useWorker&&"undefined"!=typeof Worker){const i=this.hls.logger;if(n.workerPath||"function"==typeof __HLS_WORKER_BUNDLE__){try{n.workerPath?(i.log(`loading Web Worker ${n.workerPath} for "${e}"`),this.workerContext=function(t){const e=Ji[t];if(e)return e.clientCount++,e;const i=new self.URL(t,self.location.href).href,s={worker:new self.Worker(i),scriptURL:i,clientCount:1};return Ji[t]=s,s}(n.workerPath)):(i.log(`injecting Web Worker for "${e}"`),this.workerContext=function(){const t=Ji[Xi];if(t)return t.clientCount++,t;const e=new self.Blob([`var exports={};var module={exports:exports};function define(f){f()};define.amd=true;(${__HLS_WORKER_BUNDLE__.toString()})(true);`],{type:"text/javascript"}),i=self.URL.createObjectURL(e),s={worker:new self.Worker(i),objectURL:i,clientCount:1};return Ji[Xi]=s,s}());const{worker:t}=this.workerContext;t.addEventListener("message",this.onWorkerMessage),t.addEventListener("error",this.onWorkerError),t.postMessage({instanceNo:this.instanceNo,cmd:"init",typeSupported:c,id:e,config:Wt(n)})}catch(s){i.warn(`Error setting up "${e}" Web Worker, fallback to inline`,s),this.terminateWorker(),this.error=null,this.transmuxer=new pn(this.observer,c,n,"",e,t.logger)}return}}this.transmuxer=new pn(this.observer,c,n,"",e,t.logger)}reset(){if(this.frag=null,this.part=null,this.workerContext){const t=this.instanceNo;this.instanceNo=bn++;const e=this.hls.config,i=Mt(e.preferManagedMediaSource);this.workerContext.worker.postMessage({instanceNo:this.instanceNo,cmd:"reset",resetNo:t,typeSupported:i,id:this.id,config:Wt(e)})}}terminateWorker(){if(this.workerContext){const{worker:t}=this.workerContext;this.workerContext=null,t.removeEventListener("message",this.onWorkerMessage),t.removeEventListener("error",this.onWorkerError),function(t){const e=Ji[t||Xi];if(e&&1==e.clientCount--){const{worker:i,objectURL:s}=e;delete Ji[t||Xi],s&&self.URL.revokeObjectURL(s),i.terminate()}}(this.hls.config.workerPath)}}destroy(){if(this.workerContext)this.terminateWorker(),this.onWorkerMessage=this.onWorkerError=null;else{const t=this.transmuxer;t&&(t.destroy(),this.transmuxer=null)}const t=this.observer;t&&t.removeAllListeners(),this.frag=null,this.part=null,this.observer=null,this.hls=null}push(t,e,i,s,n,r,a,o,l,c){var u,d;l.transmuxing.start=self.performance.now();const{instanceNo:h,transmuxer:p}=this,g=r?r.start:n.start,m=n.decryptdata,y=this.frag,v=!(y&&n.cc===y.cc),b=!(y&&l.level===y.level),_=y?l.sn-y.sn:-1,E=this.part?l.part-this.part.index:-1,T=0===_&&l.id>1&&l.id===(null==y?void 0:y.stats.chunkCount),S=!b&&(1===_||0===_&&(1===E||T&&E<=0)),k=self.performance.now();(b||_||0===n.stats.parsing.start)&&(n.stats.parsing.start=k),!r||!E&&S||(r.stats.parsing.start=k);const w=!(y&&(null==(u=n.initSegment)?void 0:u.url)===(null==(d=y.initSegment)?void 0:d.url)),A=new vn(v,S,o,b,g,w);if(!S||v||w){this.hls.logger.log(`[transmuxer-interface]: Starting new transmux session for ${n.type} sn: ${l.sn}${l.part>-1?" part: "+l.part:""} ${this.id===f?"level":"track"}: ${l.level} id: ${l.id}\n discontinuity: ${v}\n trackSwitch: ${b}\n contiguous: ${S}\n accurateTimeOffset: ${o}\n timeOffset: ${g}\n initSegmentChange: ${w}`);const t=new yn(i,s,e,a,c);this.configureTransmuxer(t)}if(this.frag=n,this.part=r,this.workerContext)this.workerContext.worker.postMessage({instanceNo:h,cmd:"demux",data:t,decryptdata:m,chunkMeta:l,state:A},t instanceof ArrayBuffer?[t]:[]);else if(p){const e=p.push(t,m,l,A);mn(e)?e.then((t=>{this.handleTransmuxComplete(t)})).catch((t=>{this.transmuxerError(t,l,"transmuxer-interface push error")})):this.handleTransmuxComplete(e)}}flush(t){t.transmuxing.start=self.performance.now();const{instanceNo:e,transmuxer:i}=this;if(this.workerContext)this.workerContext.worker.postMessage({instanceNo:e,cmd:"flush",chunkMeta:t});else if(i){const e=i.flush(t);mn(e)?e.then((e=>{this.handleFlushResult(e,t)})).catch((e=>{this.transmuxerError(e,t,"transmuxer-interface flush error")})):this.handleFlushResult(e,t)}}transmuxerError(t,e,i){this.hls&&(this.error=t,this.hls.trigger(l.ERROR,{type:a.MEDIA_ERROR,details:o.FRAG_PARSING_ERROR,chunkMeta:e,frag:this.frag||void 0,part:this.part||void 0,fatal:!1,error:t,err:t,reason:i}))}handleFlushResult(t,e){t.forEach((t=>{this.handleTransmuxComplete(t)})),this.onFlush(e)}configureTransmuxer(t){const{instanceNo:e,transmuxer:i}=this;this.workerContext?this.workerContext.worker.postMessage({instanceNo:e,cmd:"configure",config:t}):i&&i.configure(t)}handleTransmuxComplete(t){t.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(t)}}class En extends T{constructor(t,e){super(e,t.logger),this.hls=void 0,this.canLoad=!1,this.timer=-1,this.hls=t}destroy(){this.clearTimer(),this.hls=this.log=this.warn=null}clearTimer(){-1!==this.timer&&(self.clearTimeout(this.timer),this.timer=-1)}startLoad(){this.canLoad=!0,this.loadPlaylist()}stopLoad(){this.canLoad=!1,this.clearTimer()}switchParams(t,e,i){const s=null==e?void 0:e.renditionReports;if(s){let n=-1;for(let i=0;i=0&&t>e.partTarget&&(a+=1)}const o=i&&Kt(i);return new Yt(r,a>=0?a:void 0,o)}}}loadPlaylist(t){this.clearTimer()}loadingPlaylist(t,e){this.clearTimer()}shouldLoadPlaylist(t){return this.canLoad&&!!t&&!!t.url&&(!t.details||t.details.live)}getUrlWithDirectives(t,e){if(e)try{return e.addDirectives(t)}catch(t){this.warn(`Could not construct new URL with HLS Delivery Directives: ${t}`)}return t}playlistLoaded(t,e,i){const{details:n,stats:r}=e,c=self.performance.now(),u=r.loading.first?Math.max(0,c-r.loading.first):0;n.advancedDateTime=Date.now()-u;const d=this.hls.config.timelineOffset;if(d!==n.appliedTimelineOffset){const t=Math.max(d||0,0);n.appliedTimelineOffset=t,n.fragments.forEach((e=>{e.start=e.playlistOffset+t}))}if(n.live||null!=i&&i.live){const d="levelInfo"in e?e.levelInfo:e.track;if(n.reloaded(i),i&&n.fragments.length>0){!function(t,e){if(t===e)return;let i=null;const n=t.fragments;for(let t=n.length-1;t>=0;t--){const e=n[t].initSegment;if(e){i=e;break}}let r;t.fragmentHint&&delete t.fragmentHint.endPTS,function(t,e,i){const s=e.skippedSegments,n=Math.max(t.startSN,e.startSN)-e.startSN,r=(t.fragmentHint?1:0)+(s?e.endSN:Math.min(t.endSN,e.endSN))-e.startSN,a=e.startSN-t.startSN,o=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 n=l[a+c];let r=o[c];if(s&&!r&&n&&(r=e.fragments[c]=n),n&&r){if(i(n,r,c,o),n.url&&n.url!==r.url)return void(e.playlistParsingError=Ci(`media sequence mismatch ${r.sn}:`,t,e,0,r));if(n.cc!==r.cc)return void(e.playlistParsingError=Ci(`discontinuity sequence mismatch (${n.cc}!=${r.cc})`,t,e,0,r))}}}(t,e,((t,n,a,o)=>{if(e.skippedSegments&&n.cc!==t.cc){const e=t.cc-n.cc;for(let t=a;t{var e;!t||t.initSegment&&t.initSegment.relurl!==(null==(e=i)?void 0:e.relurl)||(t.initSegment=i)})),e.skippedSegments)if(e.deltaUpdateFailed=a.some((t=>!t)),e.deltaUpdateFailed){L.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(let t=e.skippedSegments;t--;)a.shift();e.startSN=a[0].sn}else{e.endCC=a[a.length-1].cc,e.canSkipDateRanges&&(e.dateRanges=function(t,e){const{dateRanges:i,recentlyRemovedDateranges:s}=e,n=b({},t);s&&s.forEach((t=>{delete n[t]}));const r=Object.keys(n).length;return r&&Object.keys(i).forEach((t=>{const e=n[t],s=new He(i[t].attr,e);s.isValid?(n[t]=s,e||(s.tagOrder+=r)):L.warn(`Ignoring invalid Playlist Delta Update DATERANGE tag: "${Wt(i[t].attr)}"`)})),n}(t.dateRanges,e));const i=t.fragments.filter((t=>t.rawProgramDateTime));if(t.hasProgramDateTime&&!e.hasProgramDateTime)for(let t=1;t{e.elementaryStreams=t.elementaryStreams,e.stats=t.stats})),r?Ii(e,r,r.startPTS,r.endPTS,r.startDTS,r.endDTS):Di(t,e),a.length&&(e.totalduration=e.edge-a[0].start),e.driftStartTime=t.driftStartTime,e.driftStart=t.driftStart;const l=e.advancedDateTime;if(e.advanced&&l){const t=e.edge;e.driftStart||(e.driftStartTime=l,e.driftStart=t),e.driftEndTime=l,e.driftEnd=t}else e.driftEndTime=t.driftEndTime,e.driftEnd=t.driftEnd,e.advancedDateTime=t.advancedDateTime;-1===e.requestScheduled&&(e.requestScheduled=t.requestScheduled)}(i,n);const t=n.playlistParsingError;if(t){this.warn(t);const i=this.hls;if(!i.config.ignorePlaylistParsingErrors){var h;const{networkDetails:s}=e;return void i.trigger(l.ERROR,{type:a.NETWORK_ERROR,details:o.LEVEL_PARSING_ERROR,fatal:!1,url:n.url,error:t,reason:t.message,level:e.level||void 0,parent:null==(h=n.fragments[0])?void 0:h.type,networkDetails:s,stats:r})}n.playlistParsingError=null}}-1===n.requestScheduled&&(n.requestScheduled=r.loading.start);const f=this.hls.mainForwardBufferInfo,p=f?f.end-f.len:0,g=Pi(n,1e3*(n.edge-p));if(n.requestScheduled+g0){if(u>3*n.targetduration)this.log(`Playlist last advanced ${l.toFixed(2)}s ago. Omitting segment and part directives.`),y=void 0,v=void 0;else if(null!=i&&i.tuneInGoal&&u-n.partTarget>i.tuneInGoal)this.warn(`CDN Tune-in goal increased from: ${i.tuneInGoal} to: ${h} with playlist age: ${n.age}`),h=0;else{const t=Math.floor(h/n.targetduration);y+=t,void 0!==v&&(v+=Math.round(h%n.targetduration/n.partTarget)),this.log(`CDN Tune-in age: ${n.ageHeader}s last advanced ${l.toFixed(2)}s goal: ${h} skip sn ${t} to part ${v}`)}n.tuneInGoal=h}if(m=this.getDeliveryDirectives(n,e.deliveryDirectives,y,v),t||!o)return n.requestScheduled=c,void this.loadingPlaylist(d,m)}else(n.canBlockReload||n.canSkipUntil)&&(m=this.getDeliveryDirectives(n,e.deliveryDirectives,y,v));m&&void 0!==y&&n.canBlockReload&&(n.requestScheduled=r.loading.first+Math.max(g-2*u,g/2)),this.scheduleLoading(d,m,n)}else this.clearTimer()}scheduleLoading(t,e,i){const s=i||t.details;if(!s)return void this.loadingPlaylist(t,e);const n=self.performance.now(),r=s.requestScheduled;if(n>=r)return void this.loadingPlaylist(t,e);const a=r-n;this.log(`reload live playlist ${t.name||t.bitrate+"bps"} in ${Math.round(a)} ms`),this.clearTimer(),this.timer=self.setTimeout((()=>this.loadingPlaylist(t,e)),a)}getDeliveryDirectives(t,e,i,s){let n=Kt(t);return null!=e&&e.skip&&t.deltaUpdateFailed&&(i=e.msn,s=e.part,n=""),new Yt(i,s,n)}checkRetry(t){const e=t.details,i=ce(t),s=t.errorAction,{action:n,retryCount:r=0,retryConfig:a}=s||{},o=!!s&&!!a&&(5===n||!s.resolved&&2===n);if(o){var l;if(r>=a.maxNumRetry)return!1;if(i&&null!=(l=t.context)&&l.deliveryDirectives)this.warn(`Retrying playlist loading ${r+1}/${a.maxNumRetry} after "${e}" without delivery-directives`),this.loadPlaylist();else{const t=de(a,r);this.clearTimer(),this.timer=self.setTimeout((()=>this.loadPlaylist()),t),this.warn(`Retrying playlist loading ${r+1}/${a.maxNumRetry} after "${e}" in ${t}ms`)}t.levelRetry=!0,s.resolved=!0}return o}}function Tn(t,e){if(t.length!==e.length)return!1;for(let i=0;it[i]!==e[i]))}function kn(t,e){return e.label.toLowerCase()===t.name.toLowerCase()&&(!e.language||e.language.toLowerCase()===(t.lang||"").toLowerCase())}class wn{constructor(t){this.tracks=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.tracks=t}destroy(){this.tracks=this.queues=null}append(t,e,i){if(null===this.queues||null===this.tracks)return;const s=this.queues[e];s.push(t),1!==s.length||i||this.executeNext(e)}appendBlocker(t){return new Promise((e=>{const i={label:"async-blocker",execute:e,onStart:()=>{},onComplete:()=>{},onError:()=>{}};this.append(i,t)}))}prependBlocker(t){return new Promise((e=>{if(this.queues){const i={label:"async-blocker-prepend",execute:e,onStart:()=>{},onComplete:()=>{},onError:()=>{}};this.queues[t].unshift(i)}}))}removeBlockers(){null!==this.queues&&[this.queues.video,this.queues.audio,this.queues.audiovideo].forEach((t=>{var e;const i=null==(e=t[0])?void 0:e.label;"async-blocker"!==i&&"async-blocker-prepend"!==i||(t[0].execute(),t.splice(0,1))}))}unblockAudio(t){null!==this.queues&&this.queues.audio[0]===t&&this.shiftAndExecuteNext("audio")}executeNext(t){if(null===this.queues||null===this.tracks)return;const e=this.queues[t];if(e.length){const s=e[0];try{s.execute()}catch(e){var i;if(s.onError(e),null===this.queues||null===this.tracks)return;const n=null==(i=this.tracks[t])?void 0:i.buffer;null!=n&&n.updating||this.shiftAndExecuteNext(t)}}}shiftAndExecuteNext(t){null!==this.queues&&(this.queues[t].shift(),this.executeNext(t))}current(t){var e;return(null==(e=this.queues)?void 0:e[t][0])||null}toString(){const{queues:t,tracks:e}=this;return null===t||null===e?"":`\n${this.list("video")}\n${this.list("audio")}\n${this.list("audiovideo")}}`}list(t){var e,i;return null!=(e=this.queues)&&e[t]||null!=(i=this.tracks)&&i[t]?`${t}: (${this.listSbInfo(t)}) ${this.listOps(t)}`:""}listSbInfo(t){var e;const i=null==(e=this.tracks)?void 0:e[t],s=null==i?void 0:i.buffer;return s?`SourceBuffer${s.updating?" updating":""}${i.ended?" ended":""}${i.ending?" ending":""}`:"none"}listOps(t){var e;return(null==(e=this.queues)?void 0:e[t].map((t=>t.label)).join(", "))||""}}const An=/(avc[1234]|hvc1|hev1|dvh[1e]|vp09|av01)(?:\.[^.,]+)+/,Rn="HlsJsTrackRemovedError";class Ln extends Error{constructor(t){super(t),this.name=Rn}}function In(t){const e=t.querySelectorAll("source");[].slice.call(e).forEach((e=>{t.removeChild(e)}))}function Cn(t){return"audio"===t?1:0}class Dn{constructor(t){this.hls=void 0,this.autoLevelCapping=void 0,this.firstLevel=void 0,this.media=void 0,this.restrictedLevels=void 0,this.timer=void 0,this.clientRect=void 0,this.streamController=void 0,this.hls=t,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}setStreamController(t){this.streamController=t}destroy(){this.hls&&this.unregisterListener(),this.timer&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null}registerListeners(){const{hls:t}=this;t.on(l.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),t.on(l.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(l.MANIFEST_PARSED,this.onManifestParsed,this),t.on(l.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on(l.BUFFER_CODECS,this.onBufferCodecs,this),t.on(l.MEDIA_DETACHING,this.onMediaDetaching,this)}unregisterListener(){const{hls:t}=this;t.off(l.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),t.off(l.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(l.MANIFEST_PARSED,this.onManifestParsed,this),t.off(l.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off(l.BUFFER_CODECS,this.onBufferCodecs,this),t.off(l.MEDIA_DETACHING,this.onMediaDetaching,this)}onFpsDropLevelCapping(t,e){const i=this.hls.levels[e.droppedLevel];this.isLevelAllowed(i)&&this.restrictedLevels.push({bitrate:i.bitrate,height:i.height,width:i.width})}onMediaAttaching(t,e){this.media=e.media instanceof HTMLVideoElement?e.media:null,this.clientRect=null,this.timer&&this.hls.levels.length&&this.detectPlayerSize()}onManifestParsed(t,e){const i=this.hls;this.restrictedLevels=[],this.firstLevel=e.firstLevel,i.config.capLevelToPlayerSize&&e.video&&this.startCapping()}onLevelsUpdated(t,e){this.timer&&s(this.autoLevelCapping)&&this.detectPlayerSize()}onBufferCodecs(t,e){this.hls.config.capLevelToPlayerSize&&e.video&&this.startCapping()}onMediaDetaching(){this.stopCapping(),this.media=null}detectPlayerSize(){if(this.media){if(this.mediaHeight<=0||this.mediaWidth<=0)return void(this.clientRect=null);const t=this.hls.levels;if(t.length){const e=this.hls,i=this.getMaxLevel(t.length-1);i!==this.autoLevelCapping&&e.logger.log(`Setting autoLevelCapping to ${i}: ${t[i].height}p@${t[i].bitrate} for media ${this.mediaWidth}x${this.mediaHeight}`),e.autoLevelCapping=i,e.autoLevelEnabled&&e.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=e.autoLevelCapping}}}getMaxLevel(t){const e=this.hls.levels;if(!e.length)return-1;const i=e.filter(((e,i)=>this.isLevelAllowed(e)&&i<=t));return this.clientRect=null,Dn.getMaxLevelByMediaSize(i,this.mediaWidth,this.mediaHeight)}startCapping(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())}stopCapping(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)}getDimensions(){if(this.clientRect)return this.clientRect;const t=this.media,e={width:0,height:0};if(t){const i=t.getBoundingClientRect();e.width=i.width,e.height=i.height,e.width||e.height||(e.width=i.right-i.left||t.width||0,e.height=i.bottom-i.top||t.height||0)}return this.clientRect=e,e}get mediaWidth(){return this.getDimensions().width*this.contentScaleFactor}get mediaHeight(){return this.getDimensions().height*this.contentScaleFactor}get contentScaleFactor(){let t=1;if(!this.hls.config.ignoreDevicePixelRatio)try{t=self.devicePixelRatio}catch(t){}return Math.min(t,this.hls.config.maxDevicePixelRatio)}isLevelAllowed(t){return!this.restrictedLevels.some((e=>t.bitrate===e.bitrate&&t.width===e.width&&t.height===e.height))}static getMaxLevelByMediaSize(t,e,i){if(null==t||!t.length)return-1;let s=t.length-1;const n=Math.max(e,i);for(let e=0;e=n||i.height>=n)&&(r=i,!(a=t[e+1])||r.width!==a.width||r.height!==a.height)){s=e;break}}var r,a;return s}}const xn="m",Pn="a",On="v",Nn="av",Mn="i",Fn="tt",$n="h",Un="CMCD-Request",Bn={["CMCD-Object"]:["br","d","ot","tb"],[Un]:["bl","dl","mtp","nor","nrr","su"],["CMCD-Session"]:["cid","pr","sf","sid","st","v"],["CMCD-Status"]:["bs","rtp"]};class jn{constructor(t,e){Array.isArray(t)&&(t=t.map((t=>t instanceof jn?t:new jn(t)))),this.value=t,this.params=e}}const Gn="Dict";function Vn(t,e,i){return function(t,e,i,s){return new Error(`failed to ${t} "${n=e,Array.isArray(n)?JSON.stringify(n):n instanceof Map?"Map{}":n instanceof Set?"Set{}":"object"==typeof n?JSON.stringify(n):String(n)}" as ${i}`,{cause:s});var n}("serialize",t,e,i)}class Hn{constructor(t){this.description=t}}const Kn="Bare Item",Yn="Boolean",qn="Byte Sequence";const zn="Integer";function Wn(t){if(function(t){return t<-999999999999999||99999999999999912)throw Vn(t,Xn);const i=e.toString();return i.includes(".")?i:`${i}.0`}const Qn="String",Zn=/[\x00-\x1f\x7f]+/,tr="Token";function er(t){const e=(i=t).description||i.toString().slice(7,-1);var i;if(!1===/^([a-zA-Z*])([!#$%&'*+\-.^_`|~\w:/]*)$/.test(e))throw Vn(e,tr);return e}function ir(t){switch(typeof t){case"number":if(!s(t))throw Vn(t,Kn);return Number.isInteger(t)?Wn(t):Jn(t);case"string":return function(t){if(Zn.test(t))throw Vn(t,Qn);return`"${t.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}(t);case"symbol":return er(t);case"boolean":return function(t){if("boolean"!=typeof t)throw Vn(t,Yn);return t?"?1":"?0"}(t);case"object":if(t instanceof Date)return function(t){return`@${Wn(t.getTime()/1e3)}`}(t);if(t instanceof Uint8Array)return function(t){if(!1===ArrayBuffer.isView(t))throw Vn(t,qn);return`:${e=t,btoa(String.fromCharCode(...e))}:`;var e}(t);if(t instanceof Hn)return er(t);default:throw Vn(t,Kn)}}const sr="Key";function nr(t){if(!1===/^[a-z*][a-z0-9\-_.*]*$/.test(t))throw Vn(t,sr);return t}function rr(t){return null==t?"":Object.entries(t).map((([t,e])=>!0===e?`;${nr(t)}`:`;${nr(t)}=${ir(e)}`)).join("")}function ar(t){return t instanceof jn?`${ir(t.value)}${rr(t.params)}`:ir(t)}const or=t=>Math.round(t),lr=t=>100*or(t/100),cr={br:or,d:or,bl:lr,dl:lr,mtp:lr,nor:(t,e)=>((null==e?void 0:e.baseUrl)&&(t=function(t,e){const i=new URL(t),s=new URL(e);if(i.origin!==s.origin)return t;const n=i.pathname.split("/").slice(1),r=s.pathname.split("/").slice(1,-1);for(;n[0]===r[0];)n.shift(),r.shift();for(;r.length;)r.shift(),n.unshift("..");return n.join("/")}(t,e.baseUrl)),encodeURIComponent(t)),rtp:lr,tb:or};function ur(t,e={}){return t?function(t,e){return function(t,e={whitespace:!0}){if("object"!=typeof t)throw Vn(t,Gn);const i=t instanceof Map?t.entries():Object.entries(t),s=(null==e?void 0:e.whitespace)?" ":"";return Array.from(i).map((([t,e])=>{e instanceof jn==0&&(e=new jn(e));let i=nr(t);var s;return!0===e.value?i+=rr(e.params):(i+="=",Array.isArray(e.value)?i+=`(${(s=e).value.map(ar).join(" ")})${rr(s.params)}`:i+=ar(e)),i})).join(`,${s}`)}(t,e)}(function(t,e){const i={};if(null==t||"object"!=typeof t)return i;const n=Object.keys(t).sort(),r=b({},cr,null==e?void 0:e.formatters),a=null==e?void 0:e.filter;return n.forEach((n=>{if(null==a?void 0:a(n))return;let o=t[n];const l=r[n];l&&(o=l(o,e)),"v"===n&&1===o||"pr"==n&&1===o||function(t){return"number"==typeof t?s(t):null!=t&&""!==t&&!1!==t}(o)&&(function(t){return"ot"===t||"sf"===t||"st"===t}(n)&&"string"==typeof o&&(o=new Hn(o)),i[n]=o)})),i}(t,e),b({whitespace:!1},e)):""}const dr=/CMCD=[^&#]+/;function hr(t,e,i,s){t&&Object.keys(e).forEach((n=>{const r=t.filter((t=>t.groupId===n)).map((t=>{const r=b({},t);return r.details=void 0,r.attrs=new Ge(r.attrs),r.url=r.attrs.URI=fr(t.url,t.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",i),r.groupId=r.attrs["GROUP-ID"]=e[n],r.attrs["PATHWAY-ID"]=s,r}));t.push(...r)}))}function fr(t,e,i,s){const{HOST:n,PARAMS:r,[i]:a}=s;let o;e&&(o=null==a?void 0:a[e],o&&(t=o));const l=new self.URL(t);return n&&!o&&(l.host=n),r&&Object.keys(r).sort().forEach((t=>{t&&l.searchParams.set(t,r[t])})),l.href}class pr extends T{constructor(t){super("eme",t.logger),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=pr.CDMCleanupPromise?[pr.CDMCleanupPromise]:[],this.onMediaEncrypted=t=>{const{initDataType:e,initData:i}=t,s=`"${t.type}" event: init data type: "${e}"`;if(this.debug(s),null!==i){if(!this.keyFormatPromise){let t=Object.keys(this.keySystemAccessPromises);t.length||(t=ri(this.config));const e=t.map(ni).filter((t=>!!t));this.keyFormatPromise=this.getKeyFormatPromise(e)}this.keyFormatPromise.then((n=>{const r=ii(n);let a,o;if("sinf"===e){if(r!==Je.FAIRPLAY)return void this.warn(`Ignoring unexpected "${t.type}" event with init data type: "${e}" for selected key-system ${r}`);const n=tt(new Uint8Array(i));try{const t=pt(ze(JSON.parse(n).sinf));if(!t)throw new Error("'schm' box missing or not cbcs/cenc with schi > tenc");a=new Uint8Array(t.subarray(8,24)),o=Je.FAIRPLAY}catch(t){return void this.warn(`${s} Failed to parse sinf: ${t}`)}}else{if(r!==Je.WIDEVINE&&r!==Je.PLAYREADY)return void this.warn(`Ignoring unexpected "${t.type}" event with init data type: "${e}" for selected key-system ${r}`);const n=function(t){const e=[];if(t instanceof ArrayBuffer){const i=t.byteLength;let s=0;for(;s+32!!t.systemId&&si(t.systemId)===r));l.length>1&&this.warn(`${s} Using first of ${l.length} pssh found for selected key-system ${r}`);const c=l[0];if(!c)return void(0===n.length||n.some((t=>!t.systemId))?this.warn(`${s} contains incomplete or invalid pssh data`):this.log(`ignoring ${s} for ${n.map((t=>si(t.systemId))).join(",")} pssh data in favor of playlist keys`));if(o=si(c.systemId),0===c.version&&c.data)if(o===Je.WIDEVINE){const t=c.data.length-22;a=new Uint8Array(c.data.subarray(t,t+16))}else o===Je.PLAYREADY&&(a=li(c.data))}if(!o||!a)return;const l=x(a),{keyIdToKeySessionPromise:c,mediaKeySessions:u}=this;let d=c[l];for(let t=0;tthis.generateRequestWithPreferredKeySession(s,e,i,"encrypted-event-key-match"))),d.catch((t=>this.handleError(t)));break}}if(!d){if(o!==r)return void this.log(`Ignoring "${t.type}" event with ${o} init data for selected key-system ${r}`);d=c[l]=this.getKeySystemSelectionPromise([o]).then((({keySystem:t,mediaKeys:s})=>{var n;this.throwIfDestroyed();const r=new ui("ISO-23001-7",l,null!=(n=ni(t))?n:"");return r.pssh=new Uint8Array(i),r.keyId=a,this.attemptSetMediaKeys(t,s).then((()=>{this.throwIfDestroyed();const n=this.createMediaKeySessionContext({decryptdata:r,keySystem:t,mediaKeys:s});return this.generateRequestWithPreferredKeySession(n,e,i,"encrypted-event-no-match")}))})),d.catch((t=>this.handleError(t)))}}))}},this.onWaitingForKey=t=>{this.log(`"${t.type}" event`)},this.hls=t,this.config=t.config,this.registerListeners()}destroy(){const t=this.media;this.unregisterListeners(),this.onMediaDetached(),this._clear(t);const e=this.config;e.requestMediaKeySystemAccessFunc=null,e.licenseXhrSetup=e.licenseResponseCallback=void 0,e.drmSystems=e.drmSystemOptions={},this.hls=this.config=this.keyIdToKeySessionPromise=null,this.onMediaEncrypted=this.onWaitingForKey=null}registerListeners(){this.hls.on(l.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(l.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(l.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(l.MANIFEST_LOADED,this.onManifestLoaded,this)}unregisterListeners(){this.hls.off(l.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(l.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(l.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(l.MANIFEST_LOADED,this.onManifestLoaded,this)}getLicenseServerUrl(t){const{drmSystems:e,widevineLicenseUrl:i}=this.config,s=e[t];return s?s.licenseUrl:t===Je.WIDEVINE&&i?i:void 0}getLicenseServerUrlOrThrow(t){const e=this.getLicenseServerUrl(t);if(void 0===e)throw new Error(`no license server URL configured for key-system "${t}"`);return e}getServerCertificateUrl(t){const{drmSystems:e}=this.config,i=e[t];if(i)return i.serverCertificateUrl;this.log(`No Server Certificate in config.drmSystems["${t}"]`)}attemptKeySystemAccess(t){const e=this.hls.levels,i=(t,e,i)=>!!t&&i.indexOf(t)===e,s=e.map((t=>t.audioCodec)).filter(i),n=e.map((t=>t.videoCodec)).filter(i);return s.length+n.length===0&&n.push("avc1.42e01e"),new Promise(((e,i)=>{const r=t=>{const l=t.shift();this.getMediaKeysPromise(l,s,n).then((t=>e({keySystem:l,mediaKeys:t}))).catch((e=>{t.length?r(t):i(e instanceof gr?e:new gr({type:a.KEY_SYSTEM_ERROR,details:o.KEY_SYSTEM_NO_ACCESS,error:e,fatal:!0},e.message))}))};r(t)}))}requestMediaKeySystemAccess(t,e){const{requestMediaKeySystemAccessFunc:i}=this.config;if("function"!=typeof i){let t=`Configured requestMediaKeySystemAccess is not a function ${i}`;return null===ai&&"http:"===self.location.protocol&&(t=`navigator.requestMediaKeySystemAccess is not available over insecure protocol ${location.protocol}`),Promise.reject(new Error(t))}return i(t,e)}getMediaKeysPromise(t,e,i){const s=function(t,e,i,s){let n;switch(t){case Je.FAIRPLAY:n=["cenc","sinf"];break;case Je.WIDEVINE:case Je.PLAYREADY:n=["cenc"];break;case Je.CLEARKEY:n=["cenc","keyids"];break;default:throw new Error(`Unknown key-system: ${t}`)}return function(t,e,i,s){return[{initDataTypes:t,persistentState:s.persistentState||"optional",distinctiveIdentifier:s.distinctiveIdentifier||"optional",sessionTypes:s.sessionTypes||[s.sessionType||"temporary"],audioCapabilities:e.map((t=>({contentType:`audio/mp4; codecs=${t}`,robustness:s.audioRobustness||"",encryptionScheme:s.audioEncryptionScheme||null}))),videoCapabilities:i.map((t=>({contentType:`video/mp4; codecs=${t}`,robustness:s.videoRobustness||"",encryptionScheme:s.videoEncryptionScheme||null})))}]}(n,e,i,s)}(t,e,i,this.config.drmSystemOptions),n=this.keySystemAccessPromises[t];let r=null==n?void 0:n.keySystemAccess;if(!r){this.log(`Requesting encrypted media "${t}" key-system access with config: ${Wt(s)}`),r=this.requestMediaKeySystemAccess(t,s);const e=this.keySystemAccessPromises[t]={keySystemAccess:r};return r.catch((e=>{this.log(`Failed to obtain access to key-system "${t}": ${e}`)})),r.then((i=>{this.log(`Access for key-system "${i.keySystem}" obtained`);const s=this.fetchServerCertificate(t);return this.log(`Create media-keys for "${t}"`),e.mediaKeys=i.createMediaKeys().then((e=>(this.log(`Media-keys created for "${t}"`),s.then((i=>i?this.setMediaKeysServerCertificate(e,t,i):e))))),e.mediaKeys.catch((e=>{this.error(`Failed to create media-keys for "${t}"}: ${e}`)})),e.mediaKeys}))}return r.then((()=>n.mediaKeys))}createMediaKeySessionContext({decryptdata:t,keySystem:e,mediaKeys:i}){this.log(`Creating key-system session "${e}" keyId: ${x(t.keyId||[])}`);const s=i.createSession(),n={decryptdata:t,keySystem:e,mediaKeys:i,mediaKeysSession:s,keyStatus:"status-pending"};return this.mediaKeySessions.push(n),n}renewKeySession(t){const e=t.decryptdata;if(e.pssh){const i=this.createMediaKeySessionContext(t),s=this.getKeyIdString(e),n="cenc";this.keyIdToKeySessionPromise[s]=this.generateRequestWithPreferredKeySession(i,n,e.pssh.buffer,"expired")}else this.warn("Could not renew expired session. Missing pssh initData.");this.removeSession(t)}getKeyIdString(t){if(!t)throw new Error("Could not read keyId of undefined decryptdata");if(null===t.keyId)throw new Error("keyId is null");return x(t.keyId)}updateKeySession(t,e){var i;const s=t.mediaKeysSession;return this.log(`Updating key-session "${s.sessionId}" for keyID ${x((null==(i=t.decryptdata)?void 0:i.keyId)||[])}\n } (data length: ${e?e.byteLength:e})`),s.update(e)}selectKeySystemFormat(t){const e=Object.keys(t.levelkeys||{});return this.keyFormatPromise||(this.log(`Selecting key-system from fragment (sn: ${t.sn} ${t.type}: ${t.level}) key formats ${e.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(e)),this.keyFormatPromise}getKeyFormatPromise(t){return new Promise(((e,i)=>{const s=ri(this.config),n=t.map(ii).filter((t=>!!t&&-1!==s.indexOf(t)));return this.getKeySystemSelectionPromise(n).then((({keySystem:t})=>{const s=ni(t);s?e(s):i(new Error(`Unable to find format for key-system "${t}"`))})).catch(i)}))}loadKey(t){const e=t.keyInfo.decryptdata,i=this.getKeyIdString(e),s=`(keyId: ${i} format: "${e.keyFormat}" method: ${e.method} uri: ${e.uri})`;this.log(`Starting session for key ${s}`);let n=this.keyIdToKeySessionPromise[i];return n||(n=this.getKeySystemForKeyPromise(e).then((({keySystem:i,mediaKeys:n})=>(this.throwIfDestroyed(),this.log(`Handle encrypted media sn: ${t.frag.sn} ${t.frag.type}: ${t.frag.level} using key ${s}`),this.attemptSetMediaKeys(i,n).then((()=>(this.throwIfDestroyed(),this.createMediaKeySessionContext({keySystem:i,mediaKeys:n,decryptdata:e}))))))),(this.keyIdToKeySessionPromise[i]=n.then((t=>{const i=e.pssh?e.pssh.buffer:null;return this.generateRequestWithPreferredKeySession(t,"cenc",i,"playlist-key")}))).catch((t=>this.handleError(t)))),n}throwIfDestroyed(t="Invalid state"){if(!this.hls)throw new Error("invalid state")}handleError(t){this.hls&&(this.error(t.message),t instanceof gr?this.hls.trigger(l.ERROR,t.data):this.hls.trigger(l.ERROR,{type:a.KEY_SYSTEM_ERROR,details:o.KEY_SYSTEM_NO_KEYS,error:t,fatal:!0}))}getKeySystemForKeyPromise(t){const e=this.getKeyIdString(t),i=this.keyIdToKeySessionPromise[e];if(!i){const e=ii(t.keyFormat),i=e?[e]:ri(this.config);return this.attemptKeySystemAccess(i)}return i}getKeySystemSelectionPromise(t){if(t.length||(t=ri(this.config)),0===t.length)throw new gr({type:a.KEY_SYSTEM_ERROR,details:o.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},`Missing key-system license configuration options ${Wt({drmSystems:this.config.drmSystems})}`);return this.attemptKeySystemAccess(t)}attemptSetMediaKeys(t,e){const i=this.setMediaKeysQueue.slice();this.log(`Setting media-keys for "${t}"`);const s=Promise.all(i).then((()=>{if(!this.media)throw new Error("Attempted to set mediaKeys without media element attached");return this.media.setMediaKeys(e)}));return this.setMediaKeysQueue.push(s),s.then((()=>{this.log(`Media-keys set for "${t}"`),i.push(s),this.setMediaKeysQueue=this.setMediaKeysQueue.filter((t=>-1===i.indexOf(t)))}))}generateRequestWithPreferredKeySession(t,e,i,s){var n,r;const l=null==(n=this.config.drmSystems)||null==(r=n[t.keySystem])?void 0:r.generateRequest;if(l)try{const s=l.call(this.hls,e,i,t);if(!s)throw new Error("Invalid response from configured generateRequest filter");e=s.initDataType,i=s.initData?s.initData:null,t.decryptdata.pssh=i?new Uint8Array(i):null}catch(t){var c;if(this.warn(t.message),null!=(c=this.hls)&&c.config.debug)throw t}if(null===i)return this.log(`Skipping key-session request for "${s}" (no initData)`),Promise.resolve(t);const u=this.getKeyIdString(t.decryptdata);this.log(`Generating key-session request for "${s}": ${u} (init data type: ${e} length: ${i?i.byteLength:null})`);const d=new Wi,h=t._onmessage=e=>{const i=t.mediaKeysSession;if(!i)return void d.emit("error",new Error("invalid state"));const{messageType:s,message:n}=e;this.log(`"${s}" message event for session "${i.sessionId}" message size: ${n.byteLength}`),"license-request"===s||"license-renewal"===s?this.renewLicense(t,n).catch((t=>{d.eventNames().length?d.emit("error",t):this.handleError(t)})):"license-release"===s?t.keySystem===Je.FAIRPLAY&&(this.updateKeySession(t,We("acknowledged")),this.removeSession(t)):this.warn(`unhandled media key message type "${s}"`)},f=t._onkeystatuseschange=e=>{if(!t.mediaKeysSession)return void d.emit("error",new Error("invalid state"));this.onKeyStatusChange(t);const i=t.keyStatus;d.emit("keyStatus",i),"expired"===i&&(this.warn(`${t.keySystem} expired for key ${u}`),this.renewKeySession(t))};t.mediaKeysSession.addEventListener("message",h),t.mediaKeysSession.addEventListener("keystatuseschange",f);const p=new Promise(((t,e)=>{d.on("error",e),d.on("keyStatus",(i=>{i.startsWith("usable")?t():"output-restricted"===i?e(new gr({type:a.KEY_SYSTEM_ERROR,details:o.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED,fatal:!1},"HDCP level output restricted")):"internal-error"===i?e(new gr({type:a.KEY_SYSTEM_ERROR,details:o.KEY_SYSTEM_STATUS_INTERNAL_ERROR,fatal:!0},`key status changed to "${i}"`)):"expired"===i?e(new Error("key expired while generating request")):this.warn(`unhandled key status change "${i}"`)}))}));return t.mediaKeysSession.generateRequest(e,i).then((()=>{var e;this.log(`Request generated for key-session "${null==(e=t.mediaKeysSession)?void 0:e.sessionId}" keyId: ${u}`)})).catch((t=>{throw new gr({type:a.KEY_SYSTEM_ERROR,details:o.KEY_SYSTEM_NO_SESSION,error:t,fatal:!1},`Error generating key-session request: ${t}`)})).then((()=>p)).catch((e=>{throw d.removeAllListeners(),this.removeSession(t),e})).then((()=>(d.removeAllListeners(),t)))}onKeyStatusChange(t){t.mediaKeysSession.keyStatuses.forEach(((e,i)=>{if("string"==typeof i&&"object"==typeof e){const t=i;i=e,e=t}this.log(`key status change "${e}" for keyStatuses keyId: ${x("buffer"in i?new Uint8Array(i.buffer,i.byteOffset,i.byteLength):new Uint8Array(i))} session keyId: ${x(new Uint8Array(t.decryptdata.keyId||[]))} uri: ${t.decryptdata.uri}`),t.keyStatus=e}))}fetchServerCertificate(t){const e=this.config,i=new(0,e.loader)(e),s=this.getServerCertificateUrl(t);return s?(this.log(`Fetching server certificate for "${t}"`),new Promise(((n,r)=>{const l={responseType:"arraybuffer",url:s},c=e.certLoadPolicy.default,u={loadPolicy:c,timeout:c.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},d={onSuccess:(t,e,i,s)=>{n(t.data)},onError:(e,i,n,c)=>{r(new gr({type:a.KEY_SYSTEM_ERROR,details:o.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:n,response:E({url:l.url,data:void 0},e)},`"${t}" certificate request failed (${s}). Status: ${e.code} (${e.text})`))},onTimeout:(e,i,n)=>{r(new gr({type:a.KEY_SYSTEM_ERROR,details:o.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:n,response:{url:l.url,data:void 0}},`"${t}" certificate request timed out (${s})`))},onAbort:(t,e,i)=>{r(new Error("aborted"))}};i.load(l,u,d)}))):Promise.resolve()}setMediaKeysServerCertificate(t,e,i){return new Promise(((s,n)=>{t.setServerCertificate(i).then((n=>{this.log(`setServerCertificate ${n?"success":"not supported by CDM"} (${null==i?void 0:i.byteLength}) on "${e}"`),s(t)})).catch((t=>{n(new gr({type:a.KEY_SYSTEM_ERROR,details:o.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED,error:t,fatal:!0},t.message))}))}))}renewLicense(t,e){return this.requestLicense(t,new Uint8Array(e)).then((e=>this.updateKeySession(t,new Uint8Array(e)).catch((t=>{throw new gr({type:a.KEY_SYSTEM_ERROR,details:o.KEY_SYSTEM_SESSION_UPDATE_FAILED,error:t,fatal:!0},t.message)}))))}unpackPlayReadyKeyMessage(t,e){const i=String.fromCharCode.apply(null,new Uint16Array(e.buffer));if(!i.includes("PlayReadyKeyMessage"))return t.setRequestHeader("Content-Type","text/xml; charset=utf-8"),e;const s=(new DOMParser).parseFromString(i,"application/xml"),n=s.querySelectorAll("HttpHeader");if(n.length>0){let e;for(let i=0,s=n.length;i in key message");return We(atob(l))}setupLicenseXHR(t,e,i,s){const n=this.config.licenseXhrSetup;return n?Promise.resolve().then((()=>{if(!i.decryptdata)throw new Error("Key removed");return n.call(this.hls,t,e,i,s)})).catch((r=>{if(!i.decryptdata)throw r;return t.open("POST",e,!0),n.call(this.hls,t,e,i,s)})).then((i=>(t.readyState||t.open("POST",e,!0),{xhr:t,licenseChallenge:i||s}))):(t.open("POST",e,!0),Promise.resolve({xhr:t,licenseChallenge:s}))}requestLicense(t,e){const i=this.config.keyLoadPolicy.default;return new Promise(((s,n)=>{const r=this.getLicenseServerUrlOrThrow(t.keySystem);this.log(`Sending license request to URL: ${r}`);const l=new XMLHttpRequest;l.responseType="arraybuffer",l.onreadystatechange=()=>{if(!this.hls||!t.mediaKeysSession)return n(new Error("invalid state"));if(4===l.readyState)if(200===l.status){this._requestLicenseFailureCount=0;let e=l.response;this.log(`License received ${e instanceof ArrayBuffer?e.byteLength:e}`);const i=this.config.licenseResponseCallback;if(i)try{e=i.call(this.hls,l,r,t)}catch(t){this.error(t)}s(e)}else{const c=i.errorRetry,u=c?c.maxNumRetry:0;if(this._requestLicenseFailureCount++,this._requestLicenseFailureCount>u||l.status>=400&&l.status<500)n(new gr({type:a.KEY_SYSTEM_ERROR,details:o.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0,networkDetails:l,response:{url:r,data:void 0,code:l.status,text:l.statusText}},`License Request XHR failed (${r}). Status: ${l.status} (${l.statusText})`));else{const i=u-this._requestLicenseFailureCount+1;this.warn(`Retrying license request, ${i} attempts left`),this.requestLicense(t,e).then(s,n)}}},t.licenseXhr&&t.licenseXhr.readyState!==XMLHttpRequest.DONE&&t.licenseXhr.abort(),t.licenseXhr=l,this.setupLicenseXHR(l,r,t,e).then((({xhr:e,licenseChallenge:i})=>{t.keySystem==Je.PLAYREADY&&(i=this.unpackPlayReadyKeyMessage(e,i)),e.send(i)}))}))}onMediaAttached(t,e){if(!this.config.emeEnabled)return;const i=e.media;this.media=i,i.removeEventListener("encrypted",this.onMediaEncrypted),i.removeEventListener("waitingforkey",this.onWaitingForKey),i.addEventListener("encrypted",this.onMediaEncrypted),i.addEventListener("waitingforkey",this.onWaitingForKey)}onMediaDetached(){const t=this.media;t&&(t.removeEventListener("encrypted",this.onMediaEncrypted),t.removeEventListener("waitingforkey",this.onWaitingForKey),this.media=null)}_clear(t){var e;const i=this.mediaKeySessions;this._requestLicenseFailureCount=0,this.setMediaKeysQueue=[],this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},ui.clearKeyUriToKeyIdMap();const s=i.length;pr.CDMCleanupPromise=Promise.all(i.map((t=>this.removeSession(t))).concat(null==t||null==(e=t.setMediaKeys(null))?void 0:e.catch((t=>{var e;this.log(`Could not clear media keys: ${t}`),null==(e=this.hls)||e.trigger(l.ERROR,{type:a.OTHER_ERROR,details:o.KEY_SYSTEM_DESTROY_MEDIA_KEYS_ERROR,fatal:!1,error:new Error(`Could not clear media keys: ${t}`)})})))).then((()=>{s&&(this.log("finished closing key sessions and clearing media keys"),i.length=0)})).catch((t=>{var e;this.log(`Could not close sessions and clear media keys: ${t}`),null==(e=this.hls)||e.trigger(l.ERROR,{type:a.OTHER_ERROR,details:o.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR,fatal:!1,error:new Error(`Could not close sessions and clear media keys: ${t}`)})}))}onManifestLoading(){this.keyFormatPromise=null}onManifestLoaded(t,{sessionKeys:e}){if(e&&this.config.emeEnabled&&!this.keyFormatPromise){const t=e.reduce(((t,e)=>(-1===t.indexOf(e.keyFormat)&&t.push(e.keyFormat),t)),[]);this.log(`Selecting key-system from session-keys ${t.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(t)}}removeSession(t){const{mediaKeysSession:e,licenseXhr:i}=t;if(e){this.log(`Remove licenses and keys and close session ${e.sessionId}`),t._onmessage&&(e.removeEventListener("message",t._onmessage),t._onmessage=void 0),t._onkeystatuseschange&&(e.removeEventListener("keystatuseschange",t._onkeystatuseschange),t._onkeystatuseschange=void 0),i&&i.readyState!==XMLHttpRequest.DONE&&i.abort(),t.mediaKeysSession=t.decryptdata=t.licenseXhr=void 0;const s=this.mediaKeySessions.indexOf(t);s>-1&&this.mediaKeySessions.splice(s,1);const{drmSystemOptions:n}=this.config,r=function(t){var e;return"persistent-license"===t.sessionType||!(null==(e=t.sessionTypes)||!e.some((t=>"persistent-license"===t)))}(n)?new Promise(((t,i)=>{self.setTimeout((()=>i(new Error("MediaKeySession.remove() timeout"))),8e3),e.remove().then(t)})):Promise.resolve();return r.catch((t=>{var e;this.log(`Could not remove session: ${t}`),null==(e=this.hls)||e.trigger(l.ERROR,{type:a.OTHER_ERROR,details:o.KEY_SYSTEM_DESTROY_REMOVE_SESSION_ERROR,fatal:!1,error:new Error(`Could not remove session: ${t}`)})})).then((()=>e.close())).catch((t=>{var e;this.log(`Could not close session: ${t}`),null==(e=this.hls)||e.trigger(l.ERROR,{type:a.OTHER_ERROR,details:o.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR,fatal:!1,error:new Error(`Could not close session: ${t}`)})}))}}}pr.CDMCleanupPromise=void 0;class gr extends Error{constructor(t,e){super(e),this.data=void 0,t.error||(t.error=new Error(e)),this.data=t,t.err=t.error}}function mr(t,e){let i;try{i=new Event("addtrack")}catch(t){i=document.createEvent("Event"),i.initEvent("addtrack",!1,!1)}i.track=t,e.dispatchEvent(i)}function yr(t,e){const i=t.mode;if("disabled"===i&&(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){L.debug(`[texttrack-utils]: ${i}`);try{const i=new self.TextTrackCue(e.startTime,e.endTime,e.text);i.id=e.id,t.addCue(i)}catch(t){L.debug(`[texttrack-utils]: Legacy TextTrackCue fallback failed: ${t}`)}}"disabled"===i&&(t.mode=i)}function vr(t,e){const i=t.mode;if("disabled"===i&&(t.mode="hidden"),t.cues)for(let i=t.cues.length;i--;)e&&t.cues[i].removeEventListener("enter",e),t.removeCue(t.cues[i]);"disabled"===i&&(t.mode=i)}function br(t,e,i,s){const n=t.mode;if("disabled"===n&&(t.mode="hidden"),t.cues&&t.cues.length>0){const n=function(t,e,i){const s=[],n=function(t,e){if(e<=t[0].startTime)return 0;const i=t.length-1;if(e>t[i].endTime)return-1;let s,n=0,r=i;for(;n<=r;)if(s=Math.floor((r+n)/2),et[s].startTime&&n-1)for(let r=n,a=t.length;r=e&&n.endTime<=i)s.push(n);else if(n.startTime>i)return s}return s}(t.cues,e,i);for(let e=0;e>>0).toString()}const Tr=.025;let Sr=function(t){return t[t.Point=0]="Point",t[t.Range=1]="Range",t}({});function kr(t,e,i){return`${t.identifier}-${i+1}-${Er(e)}`}class wr{constructor(t,e){this.base=void 0,this._duration=null,this._timelineStart=null,this.appendInPlaceDisabled=void 0,this.appendInPlaceStarted=void 0,this.dateRange=void 0,this.hasPlayed=!1,this.cumulativeDuration=0,this.resumeOffset=NaN,this.playoutLimit=NaN,this.restrictions={skip:!1,jump:!1},this.snapOptions={out:!1,in:!1},this.assetList=[],this.assetListLoader=void 0,this.assetListResponse=null,this.resumeAnchor=void 0,this.error=void 0,this.resetOnResume=void 0,this.base=e,this.dateRange=t,this.setDateRange(t)}setDateRange(t){this.dateRange=t,this.resumeOffset=t.attr.optionalFloat("X-RESUME-OFFSET",this.resumeOffset),this.playoutLimit=t.attr.optionalFloat("X-PLAYOUT-LIMIT",this.playoutLimit),this.restrictions=t.attr.enumeratedStringList("X-RESTRICT",this.restrictions),this.snapOptions=t.attr.enumeratedStringList("X-SNAP",this.snapOptions)}reset(){var t;this.appendInPlaceStarted=!1,null==(t=this.assetListLoader)||t.destroy(),this.assetListLoader=void 0,this.supplementsPrimary||(this.assetListResponse=null,this.assetList=[],this._duration=null)}isAssetPastPlayoutLimit(t){if(t>=this.assetList.length)return!0;const e=this.playoutLimit;return!(t<=0||isNaN(e))&&this.assetList[t].startOffset>e}findAssetIndex(t){return this.assetList.indexOf(t)}get identifier(){return this.dateRange.id}get startDate(){return this.dateRange.startDate}get startTime(){const t=this.dateRange.startTime;if(this.snapOptions.out){const e=this.dateRange.tagAnchor;if(e)return Ar(t,e)}return t}get startOffset(){return this.cue.pre?0:this.startTime}get startIsAligned(){if(0===this.startTime||this.snapOptions.out)return!0;const t=this.dateRange.tagAnchor;if(t){const e=this.dateRange.startTime;return e-Ar(e,t)<.1}return!1}get resumptionOffset(){const t=this.resumeOffset,e=s(t)?t:this.duration;return this.cumulativeDuration+e}get resumeTime(){const t=this.startOffset+this.resumptionOffset;if(this.snapOptions.in){const e=this.resumeAnchor;if(e)return Ar(t,e)}return t}get appendInPlace(){return!!this.appendInPlaceStarted||!this.appendInPlaceDisabled&&!(this.cue.once||this.cue.pre||!this.startIsAligned||!(isNaN(this.playoutLimit)&&isNaN(this.resumeOffset)||this.resumeOffset&&this.duration&&Math.abs(this.resumeOffset-this.duration)0||null!==this.assetListResponse}toString(){return`["${(t=this).identifier}" ${t.cue.pre?"
":t.cue.post?"":""}${t.timelineStart.toFixed(2)}-${t.resumeTime.toFixed(2)}]`;var t}}function Ar(t,e){return t-e.start{const t=this.interstitial.playoutLimit,e=this.currentTime;this.startOffset+e>=t&&this.hls.trigger(l.PLAYOUT_LIMIT_REACHED,{})};const n=this.hls=new t(e);this.interstitial=i,this.assetItem=s;let r=s.uri;try{r=Rr(r,n.sessionId).href}catch(t){}n.loadSource(r);const a=()=>{this.hasDetails=!0};n.once(l.LEVEL_LOADED,a),n.once(l.AUDIO_TRACK_LOADED,a),n.once(l.SUBTITLE_TRACK_LOADED,a),n.on(l.MEDIA_ATTACHING,((t,{media:e})=>{this.removeMediaListeners(),this.mediaAttached=e,this.interstitial.playoutLimit&&e.addEventListener("timeupdate",this.checkPlayout)}))}bufferedInPlaceToEnd(t){var e;if(!this.interstitial.appendInPlace)return!1;if(null!=(e=this.hls)&&e.bufferedToEnd)return!0;if(!t||!this._bufferedEosTime)return!1;const i=this.timelineOffset,s=Oe.bufferInfo(t,i,0);return this.getAssetTime(s.end)>=this._bufferedEosTime-.02}get destroyed(){var t;return!(null!=(t=this.hls)&&t.userConfig)}get assetId(){return this.assetItem.identifier}get interstitialId(){return this.assetItem.parentIdentifier}get media(){var t;return(null==(t=this.hls)?void 0:t.media)||null}get bufferedEnd(){const t=this.media||this.mediaAttached;if(!t)return this._bufferedEosTime?this._bufferedEosTime:this.currentTime;const e=Oe.bufferInfo(t,t.currentTime,.001);return this.getAssetTime(e.end)}get currentTime(){const t=this.media||this.mediaAttached;return t?this.getAssetTime(t.currentTime):this._currentTime||0}get duration(){return this.assetItem.duration||0}get remaining(){const t=this.duration;return t?Math.max(0,t-this.currentTime):0}get startOffset(){return this.assetItem.startOffset}get timelineOffset(){var t;return(null==(t=this.hls)?void 0:t.config.timelineOffset)||0}set timelineOffset(t){const e=this.timelineOffset;if(t!==e){const i=t-e;if(Math.abs(i)>1/9e4){if(this.hasDetails)throw new Error("Cannot set timelineOffset after playlists are loaded");this.hls.config.timelineOffset=t}}}getAssetTime(t){const e=this.timelineOffset,i=this.duration;return Math.min(Math.max(0,t-e),i)}removeMediaListeners(){const t=this.mediaAttached;t&&(this._currentTime=t.currentTime,this.bufferSnapShot(),t.removeEventListener("timeupdate",this.checkPlayout))}bufferSnapShot(){var t;this.mediaAttached&&null!=(t=this.hls)&&t.bufferedToEnd&&(this._bufferedEosTime=this.bufferedEnd)}destroy(){this.removeMediaListeners(),this.hls.destroy(),this.hls=this.interstitial=null,this.tracks=this.mediaAttached=this.checkPlayout=null}attachMedia(t){this.hls.attachMedia(t)}detachMedia(){this.removeMediaListeners(),this.mediaAttached=null,this.hls.detachMedia()}resumeBuffering(){this.hls.resumeBuffering()}pauseBuffering(){this.hls.pauseBuffering()}transferMedia(){return this.bufferSnapShot(),this.hls.transferMedia()}on(t,e,i){this.hls.on(t,e)}once(t,e,i){this.hls.once(t,e)}off(t,e,i){this.hls.off(t,e)}toString(){var t,e;return`HlsAssetPlayer: ${Lr(this.assetItem)} ${null==(t=this.hls)?void 0:t.sessionId} ${null!=(e=this.interstitial)&&e.appendInPlace?"append-in-place":""}`}}class Cr extends T{constructor(t,e){super("interstitials-sched",e),this.onScheduleUpdate=void 0,this.eventMap={},this.events=null,this.items=null,this.durations={primary:0,playout:0,integrated:0},this.onScheduleUpdate=t}destroy(){this.reset(),this.onScheduleUpdate=null}reset(){this.eventMap={},this.setDurations(0,0,0),this.events&&this.events.forEach((t=>t.reset())),this.events=this.items=null}resetErrorsInRange(t,e){return this.events?this.events.reduce(((i,s)=>t<=s.startOffset&&e>s.startOffset?(delete s.error,i+1):i),0):0}get duration(){const t=this.items;return t?t[t.length-1].end:0}get length(){return this.items?this.items.length:0}getEvent(t){return t&&this.eventMap[t]||null}hasEvent(t){return t in this.eventMap}findItemIndex(t,e){if(t.event)return this.findEventIndex(t.event.identifier);let i=-1;t.nextEvent?i=this.findEventIndex(t.nextEvent.identifier)-1:t.previousEvent&&(i=this.findEventIndex(t.previousEvent.identifier)+1);const s=this.items;if(s)for(s[i]||(void 0===e&&(e=t.start),i=this.findItemIndexAtTime(e));i>=0&&null!=(n=s[i])&&n.event;){var n;i--}return i}findItemIndexAtTime(t,e){const i=this.items;if(i)for(let s=0;sn.start&&t1)for(let t=0;ti&&e!a.includes(t.identifier))):[];r.length&&r.sort(((t,e)=>{const i=t.cue.pre,s=t.cue.post,n=e.cue.pre,r=e.cue.post;if(i&&!n)return-1;if(n&&!i)return 1;if(s&&!r)return 1;if(r&&!s)return-1;if(!(i||n||s||r)){const i=t.startTime,s=e.startTime;if(i!==s)return i-s}return t.dateRange.tagOrder-e.dateRange.tagOrder})),this.events=r,o.forEach((t=>{this.removeEvent(t)})),this.updateSchedule(t,o)}updateSchedule(t,e=[]){const i=this.events||[];if(i.length||e.length||this.length<2){const s=this.items,n=this.parseSchedule(i,t);(e.length||(null==s?void 0:s.length)!==n.length||n.some(((t,e)=>Math.abs(t.playout.start-s[e].playout.start)>.005||Math.abs(t.playout.end-s[e].playout.end)>.005)))&&(this.items=n,this.onScheduleUpdate(e,s))}}parseDateRanges(t,e,i){const s=[],n=Object.keys(t);for(let r=0;r!(t.error||t.cue.once&&t.hasPlayed)))).length){this.resolveOffsets(t,e);let s=0,o=0;if(t.forEach(((e,a)=>{const l=e.cue.pre,c=e.cue.post,u=t[a-1]||null,d=e.appendInPlace,h=c?n:e.startOffset,f=e.duration,p=e.timelineOccupancy===Sr.Range?f:0,g=e.resumptionOffset,m=(null==u?void 0:u.startTime)===h,y=h+e.cumulativeDuration;let v=d?y+f:h+g;if(l||!c&&h<=0){const t=o;o+=p,e.timelineStart=y;const s=r;r+=f,i.push({event:e,start:y,end:v,playout:{start:s,end:r},integrated:{start:t,end:o}})}else{if(!(h<=n))return;{if(!m){const n=h-s;if(n>.033){const l=s,c=o;o+=n;const u=r;r+=n;const d={previousEvent:t[a-1]||null,nextEvent:e,start:l,end:l+n,playout:{start:u,end:r},integrated:{start:c,end:o}};i.push(d)}else n>0&&u&&(u.cumulativeDuration+=n,i[i.length-1].end=h)}c&&(v=y),e.timelineStart=y;const n=o;o+=p;const l=r;r+=f,i.push({event:e,start:y,end:v,playout:{start:l,end:r},integrated:{start:n,end:o}})}}const b=e.resumeTime;s=c||b>n?n:b})),s{const c=o.cue.pre,u=o.cue.post,d=c?0:u?n:o.startTime;this.updateAssetDurations(o),a===d?o.cumulativeDuration=r:(r=0,a=d),!u&&o.snapOptions.in&&(o.resumeAnchor=re(null,i.fragments,o.startOffset+o.resumptionOffset,0,0)||void 0),o.appendInPlace&&!o.appendInPlaceStarted&&(this.primaryCanResumeInPlaceAt(o,e)||(o.appendInPlace=!1)),!o.appendInPlace&&l+1Tr?(this.log(`"${t.identifier}" resumption ${i} not aligned with estimated timeline end ${s}`),!1):e?!Object.keys(e).some((s=>{const n=e[s].details,r=n.edge;if(i>=r)return this.log(`"${t.identifier}" resumption ${i} past ${s} playlist end ${r}`),!1;const a=re(null,n.fragments,i);if(!a)return this.log(`"${t.identifier}" resumption ${i} does not align with any fragments in ${s} playlist (${n.fragStart}-${n.fragmentEnd})`),!0;const o="audio"===s?.175:0;return!(Math.abs(a.start-i){const a=e+i;t.startOffset=i,t.timelineStart=a,s||(s=null===t.duration),n||(n=!!t.error);const o=t.error?0:t.duration||0;i+=o})),t.duration=s&&!n?Math.max(i,t.duration):i}removeEvent(t){t.reset(),delete this.eventMap[t.identifier]}}function Dr(t){return`[${t.event?'"'+t.event.identifier+'"':"primary"}: ${t.start.toFixed(2)}-${t.end.toFixed(2)}]`}class xr{constructor(t){this.hls=void 0,this.hls=t}destroy(){this.hls=null}loadAssetList(t,e){const i=t.assetListUrl;let s;try{s=Rr(i,this.hls.sessionId,t.baseUrl)}catch(e){const s=this.assignAssetListError(t,o.ASSET_LIST_LOAD_ERROR,e,i);return void this.hls.trigger(l.ERROR,s)}e&&"data:"!==s.protocol&&s.searchParams.set("_HLS_start_offset",""+e);const n=this.hls.config,r=new(0,n.loader)(n),a={responseType:"json",url:s.href},c=n.interstitialAssetListLoadPolicy.default,u={loadPolicy:c,timeout:c.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},d={onSuccess:(e,i,s,n)=>{const r=e.data,a=null==r?void 0:r.ASSETS;if(Array.isArray(a))t.assetListResponse=r,this.hls.trigger(l.ASSET_LIST_LOADED,{event:t,assetListResponse:r,networkDetails:n});else{const e=this.assignAssetListError(t,o.ASSET_LIST_PARSING_ERROR,new Error("Invalid interstitial asset list"),s.url,i,n);this.hls.trigger(l.ERROR,e)}},onError:(e,i,s,n)=>{const r=this.assignAssetListError(t,o.ASSET_LIST_LOAD_ERROR,new Error(`Error loading X-ASSET-LIST: HTTP status ${e.code} ${e.text} (${i.url})`),i.url,n,s);this.hls.trigger(l.ERROR,r)},onTimeout:(e,i,s)=>{const n=this.assignAssetListError(t,o.ASSET_LIST_LOAD_TIMEOUT,new Error(`Timeout loading X-ASSET-LIST (${i.url})`),i.url,e,s);this.hls.trigger(l.ERROR,n)}};return r.load(a,u,d),this.hls.trigger(l.ASSET_LIST_LOADING,{event:t}),r}assignAssetListError(t,e,i,s,n,r){return t.error=i,{type:a.NETWORK_ERROR,details:e,fatal:!1,interstitial:t,url:s,error:i,networkDetails:r,stats:n}}}function Pr(t,e,i){Or(t,e,i),t.addEventListener(e,i)}function Or(t,e,i){t.removeEventListener(e,i)}function Nr(t){null==t||t.play().catch((()=>{}))}class Mr{constructor(t){this.buffered=void 0;const e=(e,i,s)=>{if((i>>>=0)>s-1)throw new DOMException(`Failed to execute '${e}' on 'TimeRanges': The index provided (${i}) is greater than the maximum bound (${s})`);return t[i][e]};this.buffered={get length(){return t.length},end:i=>e("end",i,t.length),start:i=>e("start",i,t.length)}}}const Fr={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},$r=t=>String.fromCharCode(Fr[t]||t),Ur=15,Br=100,jr={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},Gr={17:2,18:4,21:6,22:8,23:10,19:13,20:15},Vr={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},Hr={25:2,26:4,29:6,30:8,31:10,27:13,28:15},Kr=["white","green","blue","cyan","red","yellow","magenta","black","transparent"];class Yr{constructor(){this.time=null,this.verboseLevel=0}log(t,e){if(this.verboseLevel>=t){const i="function"==typeof e?e():e;L.log(`${this.time} [${t}] ${i}`)}}}const qr=function(t){const e=[];for(let i=0;iBr&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=Br)}moveCursor(t){const e=this.pos+t;if(t>1)for(let t=this.pos+1;t=144&&this.backSpace();const e=$r(t);this.pos>=Br?this.logger.log(0,(()=>"Cannot insert "+t.toString(16)+" ("+e+") at position "+this.pos+". Skipping it!")):(this.chars[this.pos].setChar(e,this.currPenState),this.moveCursor(1))}clearFromPos(t){let e;for(e=t;e"pacData = "+Wt(t)));let e=t.row-1;if(this.nrRollUpRows&&e"bkgData = "+Wt(t))),this.backSpace(),this.setPen(t),this.insertChar(32)}setRollUpRows(t){this.nrRollUpRows=t}rollUp(){if(null===this.nrRollUpRows)return void this.logger.log(3,"roll_up but nrRollUpRows not set yet");this.logger.log(1,(()=>this.getDisplayText()));const t=this.currRow+1-this.nrRollUpRows,e=this.rows.splice(t,1)[0];e.clear(),this.rows.splice(this.currRow,0,e),this.logger.log(2,"Rolling up")}getDisplayText(t){t=t||!1;const e=[];let i="",s=-1;for(let i=0;i0&&(i=t?"["+e.join(" | ")+"]":e.join("\n")),i}getTextAndFormat(){return this.rows}}class Qr{constructor(t,e,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=t,this.outputFilter=e,this.mode=null,this.verbose=0,this.displayedMemory=new Jr(i),this.nonDisplayedMemory=new Jr(i),this.lastOutputScreen=new Jr(i),this.currRollUpRow=this.displayedMemory.rows[14],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[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null}getHandler(){return this.outputFilter}setHandler(t){this.outputFilter=t}setPAC(t){this.writeScreen.setPAC(t)}setBkgData(t){this.writeScreen.setBkgData(t)}setMode(t){t!==this.mode&&(this.mode=t,this.logger.log(2,(()=>"MODE="+t)),"MODE_POP-ON"===this.mode?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),"MODE_ROLL-UP"!==this.mode&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=t)}insertChars(t){for(let e=0;ee+": "+this.writeScreen.getDisplayText(!0))),"MODE_PAINT-ON"!==this.mode&&"MODE_ROLL-UP"!==this.mode||(this.logger.log(1,(()=>"DISPLAYED: "+this.displayedMemory.getDisplayText(!0))),this.outputDataUpdate())}ccRCL(){this.logger.log(2,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")}ccBS(){this.logger.log(2,"BS - BackSpace"),"MODE_TEXT"!==this.mode&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate())}ccAOF(){}ccAON(){}ccDER(){this.logger.log(2,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()}ccRU(t){this.logger.log(2,"RU("+t+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(t)}ccFON(){this.logger.log(2,"FON - Flash On"),this.writeScreen.setPen({flash:!0})}ccRDC(){this.logger.log(2,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")}ccTR(){this.logger.log(2,"TR"),this.setMode("MODE_TEXT")}ccRTD(){this.logger.log(2,"RTD"),this.setMode("MODE_TEXT")}ccEDM(){this.logger.log(2,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)}ccCR(){this.logger.log(2,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)}ccENM(){this.logger.log(2,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()}ccEOC(){if(this.logger.log(2,"EOC - End Of Caption"),"MODE_POP-ON"===this.mode){const t=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=t,this.writeScreen=this.nonDisplayedMemory,this.logger.log(1,(()=>"DISP: "+this.displayedMemory.getDisplayText()))}this.outputDataUpdate(!0)}ccTO(t){this.logger.log(2,"TO("+t+") - Tab Offset"),this.writeScreen.moveCursor(t)}ccMIDROW(t){const e={flash:!1};if(e.underline=t%2==1,e.italics=t>=46,e.italics)e.foreground="white";else{const i=Math.floor(t/2)-16,s=["white","green","blue","cyan","red","yellow","magenta"];e.foreground=s[i]}this.logger.log(2,"MIDROW: "+Wt(e)),this.writeScreen.setPen(e)}outputDataUpdate(t=!1){const e=this.logger.time;null!==e&&this.outputFilter&&(null!==this.cueStartTime||this.displayedMemory.isEmpty()?this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,e,this.lastOutputScreen),t&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:e):this.cueStartTime=e,this.lastOutputScreen.copy(this.displayedMemory))}cueSplitAtTime(t){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,t,this.displayedMemory),this.cueStartTime=t))}}class Zr{constructor(t,e,i){this.channels=void 0,this.currentChannel=0,this.cmdHistory={a:null,b:null},this.logger=void 0;const s=this.logger=new Yr;this.channels=[null,new Qr(t,e,s),new Qr(t+1,i,s)]}getHandler(t){return this.channels[t].getHandler()}setHandler(t,e){this.channels[t].setHandler(e)}addData(t,e){this.logger.time=t;for(let t=0;t"["+qr([e[t],e[t+1]])+"] -> ("+qr([i,s])+")"));const a=this.cmdHistory;if(i>=16&&i<=31){if(ea(i,s,a)){ta(null,null,a),this.logger.log(3,(()=>"Repeated command ("+qr([i,s])+") is dropped"));continue}ta(i,s,this.cmdHistory),n=this.parseCmd(i,s),n||(n=this.parseMidrow(i,s)),n||(n=this.parsePAC(i,s)),n||(n=this.parseBackgroundAttributes(i,s))}else ta(null,null,a);if(!n&&(r=this.parseChars(i,s),r)){const t=this.currentChannel;t&&t>0?this.channels[t].insertChars(r):this.logger.log(2,"No channel found yet. TEXT-MODE?")}n||r||this.logger.log(2,(()=>"Couldn't parse cleaned data "+qr([i,s])+" orig: "+qr([e[t],e[t+1]])))}}parseCmd(t,e){if(!((20===t||28===t||21===t||29===t)&&e>=32&&e<=47||(23===t||31===t)&&e>=33&&e<=35))return!1;const i=20===t||21===t||23===t?1:2,s=this.channels[i];return 20===t||21===t||28===t||29===t?32===e?s.ccRCL():33===e?s.ccBS():34===e?s.ccAOF():35===e?s.ccAON():36===e?s.ccDER():37===e?s.ccRU(2):38===e?s.ccRU(3):39===e?s.ccRU(4):40===e?s.ccFON():41===e?s.ccRDC():42===e?s.ccTR():43===e?s.ccRTD():44===e?s.ccEDM():45===e?s.ccCR():46===e?s.ccENM():47===e&&s.ccEOC():s.ccTO(e-32),this.currentChannel=i,!0}parseMidrow(t,e){let i=0;if((17===t||25===t)&&e>=32&&e<=47){if(i=17===t?1:2,i!==this.currentChannel)return this.logger.log(0,"Mismatch channel in midrow parsing"),!1;const s=this.channels[i];return!!s&&(s.ccMIDROW(e),this.logger.log(3,(()=>"MIDROW ("+qr([t,e])+")")),!0)}return!1}parsePAC(t,e){let i;if(!((t>=17&&t<=23||t>=25&&t<=31)&&e>=64&&e<=127||(16===t||24===t)&&e>=64&&e<=95))return!1;const s=t<=23?1:2;i=e>=64&&e<=95?1===s?jr[t]:Vr[t]:1===s?Gr[t]:Hr[t];const n=this.channels[s];return!!n&&(n.setPAC(this.interpretPAC(i,e)),this.currentChannel=s,!0)}interpretPAC(t,e){let i;const s={color:null,italics:!1,indent:null,underline:!1,row:t};return i=e>95?e-96:e-64,s.underline=1==(1&i),i<=13?s.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(i/2)]:i<=15?(s.italics=!0,s.color="white"):s.indent=4*Math.floor((i-16)/2),s}parseChars(t,e){let i,s=null,n=null;if(t>=25?(i=2,n=t-8):(i=1,n=t),n>=17&&n<=19){let t;t=17===n?e+80:18===n?e+112:e+144,this.logger.log(2,(()=>"Special char '"+$r(t)+"' in channel "+i)),s=[t]}else t>=32&&t<=127&&(s=0===e?[t]:[t,e]);return s&&this.logger.log(3,(()=>"Char codes =  "+qr(s).join(","))),s}parseBackgroundAttributes(t,e){if(!((16===t||24===t)&&e>=32&&e<=47||(23===t||31===t)&&e>=45&&e<=47))return!1;let i;const s={};16===t||24===t?(i=Math.floor((e-32)/2),s.background=Kr[i],e%2==1&&(s.background=s.background+"_semi")):45===e?s.background="transparent":(s.foreground="black",47===e&&(s.underline=!0));const n=t<=23?1:2;return this.channels[n].setBkgData(s),!0}reset(){for(let t=0;t100)throw new Error("Position must be between 0 and 100.");b=t,this.hasBeenReset=!0}})),Object.defineProperty(o,"positionAlign",n({},l,{get:function(){return _},set:function(t){const e=s(t);if(!e)throw new SyntaxError("An invalid or illegal string was specified.");_=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"size",n({},l,{get:function(){return E},set:function(t){if(t<0||t>100)throw new Error("Size must be between 0 and 100.");E=t,this.hasBeenReset=!0}})),Object.defineProperty(o,"align",n({},l,{get:function(){return T},set:function(t){const e=s(t);if(!e)throw new SyntaxError("An invalid or illegal string was specified.");T=e,this.hasBeenReset=!0}})),o.displayState=void 0}return r.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},r}();class sa{decode(t,e){if(!t)return"";if("string"!=typeof t)throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(t))}}function na(t){function e(t,e,i,s){return 3600*(0|t)+60*(0|e)+(0|i)+parseFloat(s||0)}const i=t.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return i?parseFloat(i[2])>59?e(i[2],i[3],0,i[4]):e(i[1],i[2],i[3],i[4]):null}class ra{constructor(){this.values=Object.create(null)}set(t,e){this.get(t)||""===e||(this.values[t]=e)}get(t,e,i){return i?this.has(t)?this.values[t]:e[i]:this.has(t)?this.values[t]:e}has(t){return t in this.values}alt(t,e,i){for(let s=0;s=0&&i<=100)return this.set(t,i),!0}return!1}}function aa(t,e,i,s){const n=s?t.split(s):[t];for(const t in n){if("string"!=typeof n[t])continue;const s=n[t].split(i);2===s.length&&e(s[0],s[1])}}const oa=new ia(0,0,""),la="middle"===oa.align?"middle":"center";function ca(t,e,i){const s=t;function n(){const e=na(t);if(null===e)throw new Error("Malformed timestamp: "+s);return t=t.replace(/^[^\sa-zA-Z-]+/,""),e}function r(){t=t.replace(/^\s+/,"")}if(r(),e.startTime=n(),r(),"--\x3e"!==t.slice(0,3))throw new Error("Malformed time stamp (time stamps must be separated by '--\x3e'): "+s);t=t.slice(3),r(),e.endTime=n(),r(),function(t,e){const s=new ra;aa(t,(function(t,e){let n;switch(t){case"region":for(let n=i.length-1;n>=0;n--)if(i[n].id===e){s.set(t,i[n].region);break}break;case"vertical":s.alt(t,e,["rl","lr"]);break;case"line":n=e.split(","),s.integer(t,n[0]),s.percent(t,n[0])&&s.set("snapToLines",!1),s.alt(t,n[0],["auto"]),2===n.length&&s.alt("lineAlign",n[1],["start",la,"end"]);break;case"position":n=e.split(","),s.percent(t,n[0]),2===n.length&&s.alt("positionAlign",n[1],["start",la,"end","line-left","line-right","auto"]);break;case"size":s.percent(t,e);break;case"align":s.alt(t,e,["start",la,"end","left","right"])}}),/:/,/\s/),e.region=s.get("region",null),e.vertical=s.get("vertical","");let n=s.get("line","auto");"auto"===n&&-1===oa.line&&(n=-1),e.line=n,e.lineAlign=s.get("lineAlign","start"),e.snapToLines=s.get("snapToLines",!0),e.size=s.get("size",100),e.align=s.get("align",la);let r=s.get("position","auto");"auto"===r&&50===oa.position&&(r="start"===e.align||"left"===e.align?0:"end"===e.align||"right"===e.align?100:50),e.position=r}(t,e)}function ua(t){return t.replace(//gi,"\n")}class da{constructor(){this.state="INITIAL",this.buffer="",this.decoder=new sa,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}parse(t){const e=this;function i(){let t=e.buffer,i=0;for(t=ua(t);iD(t))),a=function(t,e,i=1,s=!1){return en(t,e,1/i,s)}(e.baseTime,1,e.timescale);try{r.forEach((t=>i(function(t,e){const i=(new DOMParser).parseFromString(t,"text/xml").getElementsByTagName("tt")[0];if(!i)throw new Error("Invalid ttml");const s={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},n=Object.keys(s).reduce(((t,e)=>(t[e]=i.getAttribute(`ttp:${e}`)||s[e],t)),{}),r="preserve"!==i.getAttribute("xml:space"),a=Ea(_a(i,"styling","style")),o=Ea(_a(i,"layout","region")),l=_a(i,"body","[begin]");return[].map.call(l,(t=>{const i=Ta(t,r);if(!i||!t.hasAttribute("begin"))return null;const s=wa(t.getAttribute("begin"),n),l=wa(t.getAttribute("dur"),n);let c=wa(t.getAttribute("end"),n);if(null===s)throw ka(t);if(null===c){if(null===l)throw ka(t);c=s+l}const u=new ia(s-e,c-e,i);u.id=pa(u.startTime,u.endTime,u.text);const d=function(t,e,i){const s="http://www.w3.org/ns/ttml#styling";let n=null;const r=null!=t&&t.hasAttribute("style")?t.getAttribute("style"):null;return r&&i.hasOwnProperty(r)&&(n=i[r]),["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"].reduce(((i,r)=>{const a=Sa(e,s,r)||Sa(t,s,r)||Sa(n,s,r);return a&&(i[r]=a),i}),{})}(o[t.getAttribute("region")],a[t.getAttribute("style")],a),{textAlign:h}=d;if(h){const t=va[h];t&&(u.lineAlign=t),u.align=h}return b(u,d),u})).filter((t=>null!==t))}(t,a))))}catch(t){s(t)}}function _a(t,e,i){const s=t.getElementsByTagName(e)[0];return s?[].slice.call(s.querySelectorAll(i)):[]}function Ea(t){return t.reduce(((t,e)=>{const i=e.getAttribute("xml:id");return i&&(t[i]=e),t}),{})}function Ta(t,e){return[].slice.call(t.childNodes).reduce(((t,i,s)=>{var n;return"br"===i.nodeName&&s?t+"\n":null!=(n=i.childNodes)&&n.length?Ta(i,e):e?t+i.textContent.trim().replace(/\s+/g," "):t+i.textContent}),"")}function Sa(t,e,i){return t&&t.hasAttributeNS(e,i)?t.getAttributeNS(e,i):null}function ka(t){return new Error(`Could not parse ttml timestamp ${t}`)}function wa(t,e){if(!t)return null;let i=na(t);return null===i&&(ma.test(t)?i=function(t,e){const i=ma.exec(t),s=(0|i[4])+(0|i[5])/e.subFrameRate;return 3600*(0|i[1])+60*(0|i[2])+(0|i[3])+s/e.frameRate}(t,e):ya.test(t)&&(i=function(t,e){const i=ya.exec(t),s=Number(i[1]);switch(i[2]){case"h":return 3600*s;case"m":return 60*s;case"ms":return 1e3*s;case"f":return s/e.frameRate;case"t":return s/e.tickRate}return s}(t,e))),i}class Aa{constructor(t,e){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=t,this.trackName=e}dispatchCue(){null!==this.startTime&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)}newCue(t,e,i){(null===this.startTime||this.startTime>t)&&(this.startTime=t),this.endTime=e,this.screen=i,this.timelineController.createCaptionsTrack(this.trackName)}reset(){this.cueRanges=[],this.startTime=null}}function Ra(t){return t.characteristics&&/transcribes-spoken-dialog/gi.test(t.characteristics)&&/describes-music-and-sound/gi.test(t.characteristics)?"captions":"subtitles"}function La(t,e){return!!t&&t.kind===Ra(e)&&kn(e,t)}const Ia=/\s/,Ca={newCue(t,e,i,s){const n=[];let r,a,o,l,c;const u=self.VTTCue||self.TextTrackCue;for(let h=0;h=16?l--:l++;const s=ua(c.trim()),f=pa(e,i,s);null!=t&&null!=(d=t.cues)&&d.getCueById(f)||(a=new u(e,i,s),a.id=f,a.line=h+1,a.align="left",a.position=10+Math.min(80,10*Math.floor(8*l/32)),n.push(a))}return t&&n.length&&(n.sort(((t,e)=>"auto"===t.line||"auto"===e.line?0:t.line>8&&e.line>8?e.line-t.line:t.line-e.line)),n.forEach((e=>yr(t,e)))),n}},Da=/(\d+)-(\d+)\/(\d+)/;class xa{constructor(t){this.fetchSetup=void 0,this.requestTimeout=void 0,this.request=null,this.response=null,this.controller=void 0,this.context=null,this.config=null,this.callbacks=null,this.stats=void 0,this.loader=null,this.fetchSetup=t.fetchSetup||Pa,this.controller=new self.AbortController,this.stats=new G}destroy(){this.loader=this.callbacks=this.context=this.config=this.request=null,this.abortInternal(),this.response=null,this.fetchSetup=this.controller=this.stats=null}abortInternal(){this.controller&&!this.stats.loading.end&&(this.stats.aborted=!0,this.controller.abort())}abort(){var t;this.abortInternal(),null!=(t=this.callbacks)&&t.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)}load(t,e,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=function(t,e){const i={method:"GET",mode:"cors",credentials:"same-origin",signal:e,headers:new self.Headers(b({},t.headers))};return t.rangeEnd&&i.headers.set("Range","bytes="+t.rangeStart+"-"+String(t.rangeEnd-1)),i}(t,this.controller.signal),a="arraybuffer"===t.responseType,o=a?"byteLength":"length",{maxTimeToFirstByteMs:l,maxLoadTimeMs:c}=e.loadPolicy;this.context=t,this.config=e,this.callbacks=i,this.request=this.fetchSetup(t,r),self.clearTimeout(this.requestTimeout),e.timeout=l&&s(l)?l:c,this.requestTimeout=self.setTimeout((()=>{this.callbacks&&(this.abortInternal(),this.callbacks.onTimeout(n,t,this.response))}),e.timeout),(mn(this.request)?this.request.then(self.fetch):self.fetch(this.request)).then((i=>{var r;this.response=this.loader=i;const o=Math.max(self.performance.now(),n.loading.start);if(self.clearTimeout(this.requestTimeout),e.timeout=c,this.requestTimeout=self.setTimeout((()=>{this.callbacks&&(this.abortInternal(),this.callbacks.onTimeout(n,t,this.response))}),c-(o-n.loading.start)),!i.ok){const{status:t,statusText:e}=i;throw new Oa(e||"fetch, bad network response",t,i)}n.loading.first=o,n.total=function(t){const e=t.get("Content-Range");if(e){const t=function(t){const e=Da.exec(t);if(e)return parseInt(e[2])-parseInt(e[1])+1}(e);if(s(t))return t}const i=t.get("Content-Length");if(i)return parseInt(i)}(i.headers)||n.total;const l=null==(r=this.callbacks)?void 0:r.onProgress;return l&&s(e.highWaterMark)?this.loadProgressively(i,n,t,e.highWaterMark,l):a?i.arrayBuffer():"json"===t.responseType?i.json():i.text()})).then((i=>{var r,a;const l=this.response;if(!l)throw new Error("loader destroyed");self.clearTimeout(this.requestTimeout),n.loading.end=Math.max(self.performance.now(),n.loading.first);const c=i[o];c&&(n.loaded=n.total=c);const u={url:l.url,data:i,code:l.status},d=null==(r=this.callbacks)?void 0:r.onProgress;d&&!s(e.highWaterMark)&&d(n,t,i,l),null==(a=this.callbacks)||a.onSuccess(u,n,t,l)})).catch((e=>{var i;if(self.clearTimeout(this.requestTimeout),n.aborted)return;const s=e&&e.code||0,r=e?e.message:null;null==(i=this.callbacks)||i.onError({code:s,text:r},t,e?e.details:null,n)}))}getCacheAge(){let t=null;if(this.response){const e=this.response.headers.get("age");t=e?parseFloat(e):null}return t}getResponseHeader(t){return this.response?this.response.headers.get(t):null}loadProgressively(t,e,i,s=0,n){const r=new Ki,a=t.body.getReader(),o=()=>a.read().then((a=>{if(a.done)return r.dataLength&&n(e,i,r.flush().buffer,t),Promise.resolve(new ArrayBuffer(0));const l=a.value,c=l.length;return e.loaded+=c,c=s&&n(e,i,r.flush().buffer,t)):n(e,i,l.buffer,t),o()})).catch((()=>Promise.reject()));return o()}}function Pa(t,e){return new self.Request(t.url,e)}class Oa extends Error{constructor(t,e,i){super(t),this.code=void 0,this.details=void 0,this.code=e,this.details=i}}const Na=/^age:\s*[\d.]+\s*$/im;class Ma{constructor(t){this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=null,this.loader=null,this.stats=void 0,this.xhrSetup=t&&t.xhrSetup||null,this.stats=new G,this.retryDelay=0}destroy(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null,this.context=null,this.xhrSetup=null}abortInternal(){const t=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),t&&(t.onreadystatechange=null,t.onprogress=null,4!==t.readyState&&(this.stats.aborted=!0,t.abort()))}abort(){var t;this.abortInternal(),null!=(t=this.callbacks)&&t.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)}load(t,e,i){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=t,this.config=e,this.callbacks=i,this.loadInternal()}loadInternal(){const{config:t,context:e}=this;if(!t||!e)return;const i=this.loader=new self.XMLHttpRequest,s=this.stats;s.loading.first=0,s.loaded=0,s.aborted=!1;const n=this.xhrSetup;n?Promise.resolve().then((()=>{if(this.loader===i&&!this.stats.aborted)return n(i,e.url)})).catch((t=>{if(this.loader===i&&!this.stats.aborted)return i.open("GET",e.url,!0),n(i,e.url)})).then((()=>{this.loader!==i||this.stats.aborted||this.openAndSendXhr(i,e,t)})).catch((t=>{var n;null==(n=this.callbacks)||n.onError({code:i.status,text:t.message},e,i,s)})):this.openAndSendXhr(i,e,t)}openAndSendXhr(t,e,i){t.readyState||t.open("GET",e.url,!0);const n=e.headers,{maxTimeToFirstByteMs:r,maxLoadTimeMs:a}=i.loadPolicy;if(n)for(const e in n)t.setRequestHeader(e,n[e]);e.rangeEnd&&t.setRequestHeader("Range","bytes="+e.rangeStart+"-"+(e.rangeEnd-1)),t.onreadystatechange=this.readystatechange.bind(this),t.onprogress=this.loadprogress.bind(this),t.responseType=e.responseType,self.clearTimeout(this.requestTimeout),i.timeout=r&&s(r)?r:a,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),i.timeout),t.send()}readystatechange(){const{context:t,loader:e,stats:i}=this;if(!t||!e)return;const s=e.readyState,n=this.config;if(!i.aborted&&s>=2&&(0===i.loading.first&&(i.loading.first=Math.max(self.performance.now(),i.loading.start),n.timeout!==n.loadPolicy.maxLoadTimeMs&&(self.clearTimeout(this.requestTimeout),n.timeout=n.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),n.loadPolicy.maxLoadTimeMs-(i.loading.first-i.loading.start)))),4===s)){self.clearTimeout(this.requestTimeout),e.onreadystatechange=null,e.onprogress=null;const s=e.status,l="text"===e.responseType?e.responseText:null;if(s>=200&&s<300){const n=null!=l?l:e.response;if(null!=n){var r,a;i.loading.end=Math.max(self.performance.now(),i.loading.first);const o="arraybuffer"===e.responseType?n.byteLength:n.length;i.loaded=i.total=o,i.bwEstimate=8e3*i.total/(i.loading.end-i.loading.first);const l=null==(r=this.callbacks)?void 0:r.onProgress;l&&l(i,t,n,e);const c={url:e.responseURL,data:n,code:s};return void(null==(a=this.callbacks)||a.onSuccess(c,i,t,e))}}const c=n.loadPolicy.errorRetry;var o;fe(c,i.retry,!1,{url:t.url,data:void 0,code:s})?this.retry(c):(L.error(`${s} while loading ${t.url}`),null==(o=this.callbacks)||o.onError({code:s,text:e.statusText},t,e,i))}}loadtimeout(){if(!this.config)return;const t=this.config.loadPolicy.timeoutRetry;if(fe(t,this.stats.retry,!0))this.retry(t);else{var e;L.warn(`timeout while loading ${null==(e=this.context)?void 0:e.url}`);const t=this.callbacks;t&&(this.abortInternal(),t.onTimeout(this.stats,this.context,this.loader))}}retry(t){const{context:e,stats:i}=this;this.retryDelay=de(t,i.retry),i.retry++,L.warn(`${status?"HTTP Status "+status:"Timeout"} while loading ${null==e?void 0:e.url}, retrying ${i.retry}/${t.maxNumRetry} in ${this.retryDelay}ms`),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay)}loadprogress(t){const e=this.stats;e.loaded=t.loaded,t.lengthComputable&&(e.total=t.total)}getCacheAge(){let t=null;if(this.loader&&Na.test(this.loader.getAllResponseHeaders())){const e=this.loader.getResponseHeader("age");t=e?parseFloat(e):null}return t}getResponseHeader(t){return this.loader&&new RegExp(`^${t}:\\s*[\\d.]+\\s*$`,"im").test(this.loader.getAllResponseHeaders())?this.loader.getResponseHeader(t):null}}const Fa=E(E({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,maxDevicePixelRatio:Number.POSITIVE_INFINITY,preferManagedMediaSource:!0,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,frontBufferFlushThreshold:1/0,maxBufferSize:6e7,maxFragLookUpTolerance:.25,maxBufferHole:.1,detectStallWithCurrentTimeMs:1250,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,nudgeOnVideoHole:!0,liveSyncDurationCount:3,liveSyncOnStallIncrease:1,liveMaxLatencyDurationCount:1/0,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,maxLiveSyncPlaybackRate:1,liveDurationInfinity:!1,liveBackBufferLength:null,maxMaxBufferLength:600,enableWorker:!0,workerPath:null,enableSoftwareAES:!0,startLevel:void 0,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,ignorePlaylistParsingErrors:!1,loader:Ma,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:class extends T{constructor(t){super("abr",t.logger),this.hls=void 0,this.lastLevelLoadSec=0,this.lastLoadedFragLevel=-1,this.firstSelection=-1,this._nextAutoLevel=-1,this.nextAutoLevelKey="",this.audioTracksByGroup=null,this.codecTiers=null,this.timer=-1,this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.rebufferNotice=-1,this.bwEstimator=void 0,this._abandonRulesCheck=t=>{var e;const{fragCurrent:i,partCurrent:n,hls:r}=this,{autoLevelEnabled:a,media:o}=r;if(!i||!o)return;const c=performance.now(),u=n?n.stats:i.stats,d=n?n.duration:i.duration,h=c-u.loading.start,f=r.minAutoLevel,p=i.level,g=this._nextAutoLevel;if(u.aborted||u.loaded&&u.loaded===u.total||p<=f)return this.clearTimer(),void(this._nextAutoLevel=-1);if(!a)return;const m=g>-1&&g!==p,y=!!t||m;if(!y&&(o.paused||!o.playbackRate||!o.readyState))return;const v=r.mainForwardBufferInfo;if(!y&&null===v)return;const b=this.bwEstimator.getEstimateTTFB(),_=Math.abs(o.playbackRate);if(h<=Math.max(b,d/(2*_)*1e3))return;const E=v?v.len/_:0,T=u.loading.first?u.loading.first-u.loading.start:-1,S=u.loaded&&T>-1,k=this.getBwEstimate(),w=r.levels,A=w[p],R=Math.max(u.loaded,Math.round(d*(i.bitrate||A.averageBitrate)/8));let L=S?h-T:h;L<1&&S&&(L=Math.min(h,8*u.loaded/k));const I=S?1e3*u.loaded/L:0,C=b/1e3,D=I?(R-u.loaded)/I:8*R/k+C;if(D<=E)return;const x=I?8*I:k,P=!0===(null==(e=(null==t?void 0:t.details)||this.hls.latestLevelDetails)?void 0:e.live),O=this.hls.config.abrBandWidthUpFactor;let N,M=Number.POSITIVE_INFINITY;for(N=p-1;N>f;N--){const t=w[N].maxBitrate,e=!w[N].details||P;if(M=this.getTimeToLoadFrag(C,x,d*t,e),M=D)return;if(M>10*d)return;S?this.bwEstimator.sample(h-Math.min(b,T),u.loaded):this.bwEstimator.sampleTTFB(h);const F=w[N].maxBitrate;this.getBwEstimate()*O>F&&this.resetEstimator(F);const $=this.findBestLevel(F,f,N,0,E,1,1);$>-1&&(N=$),this.warn(`Fragment ${i.sn}${n?" part "+n.index:""} of level ${p} is loading too slowly;\n      Fragment duration: ${i.duration.toFixed(3)}\n      Time to underbuffer: ${E.toFixed(3)} s\n      Estimated load time for current fragment: ${D.toFixed(3)} s\n      Estimated load time for down switch fragment: ${M.toFixed(3)} s\n      TTFB estimate: ${0|T} ms\n      Current BW estimate: ${s(k)?0|k:"Unknown"} bps\n      New BW estimate: ${0|this.getBwEstimate()} bps\n      Switching to level ${N} @ ${0|F} bps`),r.nextLoadLevel=r.nextAutoLevel=N,this.clearTimer();const U=()=>{if(this.clearTimer(),this.fragCurrent===i&&this.hls.loadLevel===N&&N>0){const t=this.getStarvationDelay();if(this.warn(`Aborting inflight request ${N>0?"and switching down":""}\n      Fragment duration: ${i.duration.toFixed(3)} s\n      Time to underbuffer: ${t.toFixed(3)} s`),i.abortRequests(),this.fragCurrent=this.partCurrent=null,N>f){let e=this.findBestLevel(this.hls.levels[f].bitrate,f,N,0,t,1,1);-1===e&&(e=f),this.hls.nextLoadLevel=this.hls.nextAutoLevel=e,this.resetEstimator(this.hls.levels[e].bitrate)}}};m||D>2*M?U():this.timer=self.setInterval(U,1e3*M),r.trigger(l.FRAG_LOAD_EMERGENCY_ABORTED,{frag:i,part:n,stats:u})},this.hls=t,this.bwEstimator=this.initEstimator(),this.registerListeners()}resetEstimator(t){t&&(this.log(`setting initial bwe to ${t}`),this.hls.config.abrEwmaDefaultEstimate=t),this.firstSelection=-1,this.bwEstimator=this.initEstimator()}initEstimator(){const t=this.hls.config;return new y(t.abrEwmaSlowVoD,t.abrEwmaFastVoD,t.abrEwmaDefaultEstimate)}registerListeners(){const{hls:t}=this;t.on(l.MANIFEST_LOADING,this.onManifestLoading,this),t.on(l.FRAG_LOADING,this.onFragLoading,this),t.on(l.FRAG_LOADED,this.onFragLoaded,this),t.on(l.FRAG_BUFFERED,this.onFragBuffered,this),t.on(l.LEVEL_SWITCHING,this.onLevelSwitching,this),t.on(l.LEVEL_LOADED,this.onLevelLoaded,this),t.on(l.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on(l.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),t.on(l.ERROR,this.onError,this)}unregisterListeners(){const{hls:t}=this;t&&(t.off(l.MANIFEST_LOADING,this.onManifestLoading,this),t.off(l.FRAG_LOADING,this.onFragLoading,this),t.off(l.FRAG_LOADED,this.onFragLoaded,this),t.off(l.FRAG_BUFFERED,this.onFragBuffered,this),t.off(l.LEVEL_SWITCHING,this.onLevelSwitching,this),t.off(l.LEVEL_LOADED,this.onLevelLoaded,this),t.off(l.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off(l.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),t.off(l.ERROR,this.onError,this))}destroy(){this.unregisterListeners(),this.clearTimer(),this.hls=this._abandonRulesCheck=null,this.fragCurrent=this.partCurrent=null}onManifestLoading(t,e){this.lastLoadedFragLevel=-1,this.firstSelection=-1,this.lastLevelLoadSec=0,this.fragCurrent=this.partCurrent=null,this.onLevelsUpdated(),this.clearTimer()}onLevelsUpdated(){this.lastLoadedFragLevel>-1&&this.fragCurrent&&(this.lastLoadedFragLevel=this.fragCurrent.level),this._nextAutoLevel=-1,this.onMaxAutoLevelUpdated(),this.codecTiers=null,this.audioTracksByGroup=null}onMaxAutoLevelUpdated(){this.firstSelection=-1,this.nextAutoLevelKey=""}onFragLoading(t,e){const i=e.frag;var s;this.ignoreFragment(i)||(i.bitrateTest||(this.fragCurrent=i,this.partCurrent=null!=(s=e.part)?s:null),this.clearTimer(),this.timer=self.setInterval(this._abandonRulesCheck,100))}onLevelSwitching(t,e){this.clearTimer()}onError(t,e){if(!e.fatal)switch(e.details){case o.BUFFER_ADD_CODEC_ERROR:case o.BUFFER_APPEND_ERROR:this.lastLoadedFragLevel=-1,this.firstSelection=-1;break;case o.FRAG_LOAD_TIMEOUT:{const t=e.frag,{fragCurrent:i,partCurrent:s}=this;if(t&&i&&t.sn===i.sn&&t.level===i.level){const e=performance.now(),i=s?s.stats:t.stats,n=e-i.loading.start,r=i.loading.first?i.loading.first-i.loading.start:-1;if(i.loaded&&r>-1){const t=this.bwEstimator.getEstimateTTFB();this.bwEstimator.sample(n-Math.min(t,r),i.loaded)}else this.bwEstimator.sampleTTFB(n)}break}}}getTimeToLoadFrag(t,e,i,s){return t+i/e+(s?t+this.lastLevelLoadSec:0)}onLevelLoaded(t,e){const i=this.hls.config,{loading:n}=e.stats,r=n.end-n.first;s(r)&&(this.lastLevelLoadSec=r/1e3),e.details.live?this.bwEstimator.update(i.abrEwmaSlowLive,i.abrEwmaFastLive):this.bwEstimator.update(i.abrEwmaSlowVoD,i.abrEwmaFastVoD),this.timer>-1&&this._abandonRulesCheck(e.levelInfo)}onFragLoaded(t,{frag:e,part:i}){const s=i?i.stats:e.stats;if(e.type===f&&this.bwEstimator.sampleTTFB(s.loading.first-s.loading.start),!this.ignoreFragment(e)){if(this.clearTimer(),e.level===this._nextAutoLevel&&(this._nextAutoLevel=-1),this.firstSelection=-1,this.hls.config.abrMaxWithRealBitrate){const t=i?i.duration:e.duration,n=this.hls.levels[e.level],r=(n.loaded?n.loaded.bytes:0)+s.loaded,a=(n.loaded?n.loaded.duration:0)+t;n.loaded={bytes:r,duration:a},n.realBitrate=Math.round(8*r/a)}if(e.bitrateTest){const t={stats:s,frag:e,part:i,id:e.type};this.onFragBuffered(l.FRAG_BUFFERED,t),e.bitrateTest=!1}else this.lastLoadedFragLevel=e.level}}onFragBuffered(t,e){const{frag:i,part:s}=e,n=null!=s&&s.stats.loaded?s.stats:i.stats;if(n.aborted)return;if(this.ignoreFragment(i))return;const r=n.parsing.end-n.loading.start-Math.min(n.loading.first-n.loading.start,this.bwEstimator.getEstimateTTFB());this.bwEstimator.sample(r,n.loaded),n.bwEstimate=this.getBwEstimate(),i.bitrateTest?this.bitrateTestDelay=r/1e3:this.bitrateTestDelay=0}ignoreFragment(t){return t.type!==f||"initSegment"===t.sn}clearTimer(){this.timer>-1&&(self.clearInterval(this.timer),this.timer=-1)}get firstAutoLevel(){const{maxAutoLevel:t,minAutoLevel:e}=this.hls,i=this.getBwEstimate(),s=this.hls.config.maxStarvationDelay,n=this.findBestLevel(i,e,t,0,s,1,1);if(n>-1)return n;const r=this.hls.firstLevel,a=Math.min(Math.max(r,e),t);return this.warn(`Could not find best starting auto level. Defaulting to first in playlist ${r} clamped to ${a}`),a}get forcedAutoLevel(){return this.nextAutoLevelKey?-1:this._nextAutoLevel}get nextAutoLevel(){const t=this.forcedAutoLevel,e=this.bwEstimator.canEstimate(),i=this.lastLoadedFragLevel>-1;if(!(-1===t||e&&i&&this.nextAutoLevelKey!==this.getAutoLevelKey()))return t;const s=e&&i?this.getNextABRAutoLevel():this.firstAutoLevel;if(-1!==t){const e=this.hls.levels;if(e.length>Math.max(t,s)&&e[t].loadError<=e[s].loadError)return t}return this._nextAutoLevel=s,this.nextAutoLevelKey=this.getAutoLevelKey(),s}getAutoLevelKey(){return`${this.getBwEstimate()}_${this.getStarvationDelay().toFixed(2)}`}getNextABRAutoLevel(){const{fragCurrent:t,partCurrent:e,hls:i}=this;if(i.levels.length<=1)return i.loadLevel;const{maxAutoLevel:s,config:n,minAutoLevel:r}=i,a=e?e.duration:t?t.duration:0,o=this.getBwEstimate(),l=this.getStarvationDelay();let c=n.abrBandWidthFactor,u=n.abrBandWidthUpFactor;if(l){const t=this.findBestLevel(o,r,s,l,0,c,u);if(t>=0)return this.rebufferNotice=-1,t}let d=a?Math.min(a,n.maxStarvationDelay):n.maxStarvationDelay;if(!l){const t=this.bitrateTestDelay;t&&(d=(a?Math.min(a,n.maxLoadingDelay):n.maxLoadingDelay)-t,this.info(`bitrate test took ${Math.round(1e3*t)}ms, set first fragment max fetchDuration to ${Math.round(1e3*d)} ms`),c=u=1)}const h=this.findBestLevel(o,r,s,l,d,c,u);if(this.rebufferNotice!==h&&(this.rebufferNotice=h,this.info(`${l?"rebuffering expected":"buffer is empty"}, optimal quality level ${h}`)),h>-1)return h;const f=i.levels[r],p=i.loadLevelObj;return p&&(null==f?void 0:f.bitrate){if(!i.codecSet)return t;const n=i.audioGroups;let r=t[i.codecSet];r||(t[i.codecSet]=r={minBitrate:1/0,minHeight:1/0,minFramerate:1/0,minIndex:s,maxScore:0,videoRanges:{SDR:0},channels:{2:0},hasDefaultAudio:!n,fragmentError:0}),r.minBitrate=Math.min(r.minBitrate,i.bitrate);const a=Math.min(i.height,i.width);return r.minHeight=Math.min(r.minHeight,a),r.minFramerate=Math.min(r.minFramerate,i.frameRate),r.minIndex=Math.min(r.minIndex,s),r.maxScore=Math.max(r.maxScore,i.score),r.fragmentError+=i.fragmentError,r.videoRanges[i.videoRange]=(r.videoRanges[i.videoRange]||0)+1,n&&n.forEach((t=>{if(!t)return;const i=e.groups[t];i&&(r.hasDefaultAudio=r.hasDefaultAudio||e.hasDefaultAudio?i.hasDefault:i.hasAutoSelect||!e.hasDefaultAudio&&!e.hasAutoSelectAudio,Object.keys(i.channels).forEach((t=>{r.channels[t]=(r.channels[t]||0)+i.channels[t]})))})),t}),{})}(p,A,e,i)),r=function(t,e,i,n,r){const a=Object.keys(t),o=null==n?void 0:n.channels,l=null==n?void 0:n.audioCodec,c=null==r?void 0:r.videoCodec,u=o&&2===parseInt(o);let d=!1,h=!1,f=1/0,p=1/0,g=1/0,m=1/0,y=0,v=[];const{preferHDR:b,allowedVideoRanges:_}=function(t,e){let i=!1,s=[];if(t&&(i="SDR"!==t,s=[t]),e){s=e.allowedVideoRanges||Ht.slice(0);const t="SDR"!==s.join("")&&!e.videoCodec;i=void 0!==e.preferHDR?e.preferHDR:t&&function(){if("function"==typeof matchMedia){const t=matchMedia("(dynamic-range: high)"),e=matchMedia("bad query");if(t.media!==e.media)return!0===t.matches}return!1}(),i||(s=["SDR"])}return{preferHDR:i,allowedVideoRanges:s}}(e,r);for(let e=a.length;e--;){const i=t[a[e]];d||(d=i.channels[2]>0),f=Math.min(f,i.minHeight),p=Math.min(p,i.minFramerate),g=Math.min(g,i.minBitrate),_.filter((t=>i.videoRanges[t]>0)).length>0&&(h=!0)}f=s(f)?f:0,p=s(p)?p:0;const E=Math.max(1080,f),T=Math.max(30,p);g=s(g)?g:i,i=Math.max(g,i),h||(e=void 0);const S=a.length>1;return{codecSet:a.reduce(((e,s)=>{const n=t[s];if(s===e)return e;if(v=h?_.filter((t=>n.videoRanges[t]>0)):[],S){if(n.minBitrate>i)return Xt(s,`min bitrate of ${n.minBitrate} > current estimate of ${i}`),e;if(!n.hasDefaultAudio)return Xt(s,"no renditions with default or auto-select sound found"),e;if(l&&s.indexOf(l.substring(0,4))%5!=0)return Xt(s,`audio codec preference "${l}" not found`),e;if(o&&!u){if(!n.channels[o])return Xt(s,`no renditions with ${o} channel sound found (channels options: ${Object.keys(n.channels)})`),e}else if((!l||u)&&d&&0===n.channels[2])return Xt(s,"no renditions with stereo sound found"),e;if(n.minHeight>E)return Xt(s,`min resolution of ${n.minHeight} > maximum of ${E}`),e;if(n.minFramerate>T)return Xt(s,`min framerate of ${n.minFramerate} > maximum of ${T}`),e;if(!v.some((t=>n.videoRanges[t]>0)))return Xt(s,`no variants with VIDEO-RANGE of ${Wt(v)} found`),e;if(c&&s.indexOf(c.substring(0,4))%5!=0)return Xt(s,`video codec preference "${c}" not found`),e;if(n.maxScore=Ct(e)||n.fragmentError>t[e].fragmentError)?e:(m=n.minIndex,y=n.maxScore,s)}),void 0),videoRanges:v,preferHDR:b,minFramerate:p,minBitrate:g,minIndex:m}}(n,T,t,k,w),{codecSet:a,videoRanges:o,minFramerate:l,minBitrate:c,minIndex:u,preferHDR:d}=r;R=u,E=a,T=d?o[o.length-1]:o[0],S=l,t=Math.max(t,c),this.log(`picked start tier ${Wt(r)}`)}else E=null==v?void 0:v.codecSet,T=null==v?void 0:v.videoRange;const L=f?f.duration:h?h.duration:0,I=this.bwEstimator.getEstimateTTFB()/1e3,C=[];for(let l=i;l>=e;l--){var D;const e=p[l],h=l>d;if(!e)continue;if(y.useMediaCapabilities&&!e.supportedResult&&!e.supportedPromise){const i=navigator.mediaCapabilities;"function"==typeof(null==i?void 0:i.decodingInfo)&&(jt(e,A,T,S,t,k)||vt(e.videoCodec))?(e.supportedPromise=Gt(e,A,i),e.supportedPromise.then((t=>{if(!this.hls)return;e.supportedResult=t;const i=this.hls.levels,s=i.indexOf(e);t.error?this.warn(`MediaCapabilities decodingInfo error: "${t.error}" for level ${s} ${Wt(t)}`):t.supported||(this.warn(`Unsupported MediaCapabilities decodingInfo result for level ${s} ${Wt(t)}`),s>-1&&i.length>1&&(this.log(`Removing unsupported level ${s}`),this.hls.removeLevel(s),-1===this.hls.loadLevel&&(this.hls.nextLoadLevel=0)))}))):e.supportedResult=$t}if((E&&e.codecSet!==E||T&&e.videoRange!==T||h&&S>e.frameRate||!h&&S>0&&S=2*L&&0===r?e.averageBitrate:e.maxBitrate,P=this.getTimeToLoadFrag(I,w,x*v,void 0===g);if(w>=x&&(l===u||0===e.loadError&&0===e.fragmentError)&&(P<=I||!s(P)||b&&!this.bitrateTestDelay||P${l} adjustedbw(${Math.round(w)})-bitrate=${Math.round(w-x)} ttfb:${I.toFixed(1)} avgDuration:${v.toFixed(1)} maxFetchDuration:${c.toFixed(1)} fetchDuration:${P.toFixed(1)} firstSelection:${_} codecSet:${e.codecSet} videoRange:${e.videoRange} hls.loadLevel:${m}`)),_&&(this.firstSelection=l),l}}return-1}set nextAutoLevel(t){const e=this.deriveNextAutoLevel(t);this._nextAutoLevel!==e&&(this.nextAutoLevelKey="",this._nextAutoLevel=e)}deriveNextAutoLevel(t){const{maxAutoLevel:e,minAutoLevel:i}=this.hls;return Math.min(Math.max(t,i),e)}},bufferController:class extends T{constructor(t,e){var i;super("buffer-controller",t.logger),this.hls=void 0,this.fragmentTracker=void 0,this.details=null,this._objectUrl=null,this.operationQueue=null,this.bufferCodecEventsTotal=0,this.media=null,this.mediaSource=null,this.lastMpegAudioChunk=null,this.blockedAudioAppend=null,this.lastVideoAppendEnd=0,this.appendSource=void 0,this.transferData=void 0,this.overrides=void 0,this.appendErrors={audio:0,video:0,audiovideo:0},this.tracks={},this.sourceBuffers=[[null,null],[null,null]],this._onEndStreaming=t=>{var e;this.hls&&"open"===(null==(e=this.mediaSource)?void 0:e.readyState)&&this.hls.pauseBuffering()},this._onStartStreaming=t=>{this.hls&&this.hls.resumeBuffering()},this._onMediaSourceOpen=t=>{const{media:e,mediaSource:i}=this;t&&this.log("Media source opened"),e&&i&&(i.removeEventListener("sourceopen",this._onMediaSourceOpen),e.removeEventListener("emptied",this._onMediaEmptied),this.updateDuration(),this.hls.trigger(l.MEDIA_ATTACHED,{media:e,mediaSource:i}),null!==this.mediaSource&&this.checkPendingTracks())},this._onMediaSourceClose=()=>{this.log("Media source closed")},this._onMediaSourceEnded=()=>{this.log("Media source ended")},this._onMediaEmptied=()=>{const{mediaSrc:t,_objectUrl:e}=this;t!==e&&this.error(`Media element src was set while attaching MediaSource (${e} > ${t})`)},this.hls=t,this.fragmentTracker=e,this.appendSource=(i=I(t.config.preferManagedMediaSource),"undefined"!=typeof self&&i===self.ManagedMediaSource),this.initTracks(),this.registerListeners()}hasSourceTypes(){return Object.keys(this.tracks).length>0}destroy(){this.unregisterListeners(),this.details=null,this.lastMpegAudioChunk=this.blockedAudioAppend=null,this.transferData=this.overrides=void 0,this.operationQueue&&(this.operationQueue.destroy(),this.operationQueue=null),this.hls=this.fragmentTracker=null,this._onMediaSourceOpen=this._onMediaSourceClose=null,this._onMediaSourceEnded=null,this._onStartStreaming=this._onEndStreaming=null}registerListeners(){const{hls:t}=this;t.on(l.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(l.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(l.MANIFEST_LOADING,this.onManifestLoading,this),t.on(l.MANIFEST_PARSED,this.onManifestParsed,this),t.on(l.BUFFER_RESET,this.onBufferReset,this),t.on(l.BUFFER_APPENDING,this.onBufferAppending,this),t.on(l.BUFFER_CODECS,this.onBufferCodecs,this),t.on(l.BUFFER_EOS,this.onBufferEos,this),t.on(l.BUFFER_FLUSHING,this.onBufferFlushing,this),t.on(l.LEVEL_UPDATED,this.onLevelUpdated,this),t.on(l.FRAG_PARSED,this.onFragParsed,this),t.on(l.FRAG_CHANGED,this.onFragChanged,this),t.on(l.ERROR,this.onError,this)}unregisterListeners(){const{hls:t}=this;t.off(l.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(l.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(l.MANIFEST_LOADING,this.onManifestLoading,this),t.off(l.MANIFEST_PARSED,this.onManifestParsed,this),t.off(l.BUFFER_RESET,this.onBufferReset,this),t.off(l.BUFFER_APPENDING,this.onBufferAppending,this),t.off(l.BUFFER_CODECS,this.onBufferCodecs,this),t.off(l.BUFFER_EOS,this.onBufferEos,this),t.off(l.BUFFER_FLUSHING,this.onBufferFlushing,this),t.off(l.LEVEL_UPDATED,this.onLevelUpdated,this),t.off(l.FRAG_PARSED,this.onFragParsed,this),t.off(l.FRAG_CHANGED,this.onFragChanged,this),t.off(l.ERROR,this.onError,this)}transferMedia(){const{media:t,mediaSource:e}=this;if(!t)return null;const i={};if(this.operationQueue){const t=this.isUpdating();t||this.operationQueue.removeBlockers();const e=this.isQueued();(t||e)&&this.warn(`Transfering MediaSource with${e?" operations in queue":""}${t?" updating SourceBuffer(s)":""} ${this.operationQueue}`),this.operationQueue.destroy()}const s=this.transferData;return!this.sourceBufferCount&&s&&s.mediaSource===e?b(i,s.tracks):this.sourceBuffers.forEach((t=>{const[e]=t;e&&(i[e]=b({},this.tracks[e]),this.removeBuffer(e)),t[0]=t[1]=null})),{media:t,mediaSource:e,tracks:i}}initTracks(){this.sourceBuffers=[[null,null],[null,null]],this.tracks={},this.resetQueue(),this.resetAppendErrors(),this.lastMpegAudioChunk=this.blockedAudioAppend=null,this.lastVideoAppendEnd=0}onManifestLoading(){this.bufferCodecEventsTotal=0,this.details=null}onManifestParsed(t,e){var i;let s=2;(e.audio&&!e.video||!e.altAudio)&&(s=1),this.bufferCodecEventsTotal=s,this.log(`${s} bufferCodec event(s) expected.`),null!=(i=this.transferData)&&i.mediaSource&&this.sourceBufferCount&&s&&this.bufferCreated()}onMediaAttaching(t,e){const i=this.media=e.media,s=I(this.appendSource);if(this.transferData=this.overrides=void 0,i&&s){const t=!!e.mediaSource;(t||e.overrides)&&(this.transferData=e,this.overrides=e.overrides);const n=this.mediaSource=e.mediaSource||new s;if(this.assignMediaSource(n),t)this._objectUrl=i.src,this.attachTransferred();else{const t=this._objectUrl=self.URL.createObjectURL(n);if(this.appendSource)try{i.removeAttribute("src");const e=self.ManagedMediaSource;i.disableRemotePlayback=i.disableRemotePlayback||e&&n instanceof e,In(i),function(t,e){const i=self.document.createElement("source");i.type="video/mp4",i.src=e,t.appendChild(i)}(i,t),i.load()}catch(e){i.src=t}else i.src=t}i.addEventListener("emptied",this._onMediaEmptied)}}assignMediaSource(t){var e,i;this.log(`${(null==(e=this.transferData)?void 0:e.mediaSource)===t?"transferred":"created"} media source: ${null==(i=t.constructor)?void 0:i.name}`),t.addEventListener("sourceopen",this._onMediaSourceOpen),t.addEventListener("sourceended",this._onMediaSourceEnded),t.addEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(t.addEventListener("startstreaming",this._onStartStreaming),t.addEventListener("endstreaming",this._onEndStreaming))}attachTransferred(){const t=this.media,e=this.transferData;if(!e||!t)return;const i=this.tracks,s=e.tracks,n=s?Object.keys(s):null,r=n?n.length:0,a=()=>{this.media&&this.mediaSourceOpenOrEnded&&this._onMediaSourceOpen()};if(s&&n&&r){if(!this.tracksReady)return this.hls.config.startFragPrefetch=!0,void this.log("attachTransferred: waiting for SourceBuffer track info");if(this.log(`attachTransferred: (bufferCodecEventsTotal ${this.bufferCodecEventsTotal})\nrequired tracks: ${Wt(i,((t,e)=>"initSegment"===t?void 0:e))};\ntransfer tracks: ${Wt(s,((t,e)=>"initSegment"===t?void 0:e))}}`),!C(s,i)){e.mediaSource=null,e.tracks=void 0;const n=t.currentTime,r=this.details,a=Math.max(n,(null==r?void 0:r.fragments[0].start)||0);return a-n>1?void this.log(`attachTransferred: waiting for playback to reach new tracks start time ${n} -> ${a}`):(this.warn(`attachTransferred: resetting MediaSource for incompatible tracks ("${Object.keys(s)}"->"${Object.keys(i)}") start time: ${a} currentTime: ${n}`),this.onMediaDetaching(l.MEDIA_DETACHING,{}),this.onMediaAttaching(l.MEDIA_ATTACHING,e),void(t.currentTime=a))}this.transferData=void 0,n.forEach((t=>{const e=t,i=s[e];if(i){const t=i.buffer;if(t){const s=this.fragmentTracker,n=i.id;if(s.hasFragments(n)||s.hasParts(n)){const i=Oe.getBuffered(t);s.detectEvictedFragments(e,i,n,null,!0)}const r=Cn(e),a=[e,t];this.sourceBuffers[r]=a,t.updating&&this.operationQueue&&this.operationQueue.prependBlocker(e),this.trackSourceBuffer(e,i)}}})),a(),this.bufferCreated()}else this.log("attachTransferred: MediaSource w/o SourceBuffers"),a()}get mediaSourceOpenOrEnded(){var t;const e=null==(t=this.mediaSource)?void 0:t.readyState;return"open"===e||"ended"===e}onMediaDetaching(t,e){const i=!!e.transferMedia;this.transferData=this.overrides=void 0;const{media:s,mediaSource:n,_objectUrl:r}=this;if(n){if(this.log("media source "+(i?"transferring":"detaching")),i)this.sourceBuffers.forEach((([t])=>{t&&this.removeBuffer(t)})),this.resetQueue();else{if(this.mediaSourceOpenOrEnded){const t="open"===n.readyState;try{const e=n.sourceBuffers;for(let i=e.length;i--;)t&&e[i].abort(),n.removeSourceBuffer(e[i]);t&&n.endOfStream()}catch(t){this.warn(`onMediaDetaching: ${t.message} while calling endOfStream`)}}this.sourceBufferCount&&this.onBufferReset()}n.removeEventListener("sourceopen",this._onMediaSourceOpen),n.removeEventListener("sourceended",this._onMediaSourceEnded),n.removeEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(n.removeEventListener("startstreaming",this._onStartStreaming),n.removeEventListener("endstreaming",this._onEndStreaming)),this.mediaSource=null,this._objectUrl=null}s&&(s.removeEventListener("emptied",this._onMediaEmptied),i||(r&&self.URL.revokeObjectURL(r),this.mediaSrc===r?(s.removeAttribute("src"),this.appendSource&&In(s),s.load()):this.warn("media|source.src was changed by a third party - skip cleanup")),this.media=null),this.hls.trigger(l.MEDIA_DETACHED,e)}onBufferReset(){this.sourceBuffers.forEach((([t])=>{t&&this.resetBuffer(t)})),this.initTracks()}resetBuffer(t){var e;const i=null==(e=this.tracks[t])?void 0:e.buffer;if(this.removeBuffer(t),i)try{var s;null!=(s=this.mediaSource)&&s.sourceBuffers.length&&this.mediaSource.removeSourceBuffer(i)}catch(e){this.warn(`onBufferReset ${t}`,e)}delete this.tracks[t]}removeBuffer(t){this.removeBufferListeners(t),this.sourceBuffers[Cn(t)]=[null,null];const e=this.tracks[t];e&&(e.buffer=void 0)}resetQueue(){this.operationQueue&&this.operationQueue.destroy(),this.operationQueue=new wn(this.tracks)}onBufferCodecs(t,e){const i=this.tracks,s=Object.keys(e);this.log(`BUFFER_CODECS: "${s}" (current SB count ${this.sourceBufferCount})`);const n="audiovideo"in e&&(i.audio||i.video)||i.audiovideo&&("audio"in e||"video"in e),r=!n&&this.sourceBufferCount&&this.media&&s.some((t=>!i[t]));n||r?this.warn(`Unsupported transition between "${Object.keys(i)}" and "${s}" SourceBuffers`):(s.forEach((t=>{var s,n,r;const a=e[t],{id:o,codec:l,levelCodec:c,container:u,metadata:d,supplemental:h}=a;let f=i[t];const p=null==(s=this.transferData)||null==(n=s.tracks)?void 0:n[t],g=null!=p&&p.buffer?p:f,m=(null==g?void 0:g.pendingCodec)||(null==g?void 0:g.codec),y=null==g?void 0:g.levelCodec;f||(f=i[t]={buffer:void 0,listeners:[],codec:l,supplemental:h,container:u,levelCodec:c,metadata:d,id:o});const v=Ot(m,y),b=null==v?void 0:v.replace(An,"$1");let _=Ot(l,c);const E=null==(r=_)?void 0:r.replace(An,"$1");_&&v&&b!==E&&("audio"===t.slice(0,5)&&(_=Pt(_,this.appendSource)),this.log(`switching codec ${m} to ${_}`),_!==(f.pendingCodec||f.codec)&&(f.pendingCodec=_),f.container=u,this.appendChangeType(t,u,_))})),(this.tracksReady||this.sourceBufferCount)&&(e.tracks=this.sourceBufferTracks),this.sourceBufferCount||this.mediaSourceOpenOrEnded&&this.checkPendingTracks())}get sourceBufferTracks(){return Object.keys(this.tracks).reduce(((t,e)=>{const i=this.tracks[e];return t[e]={id:i.id,container:i.container,codec:i.codec,levelCodec:i.levelCodec},t}),{})}appendChangeType(t,e,i){const s=`${e};codecs=${i}`,n={label:`change-type=${s}`,execute:()=>{const n=this.tracks[t];if(n){const r=n.buffer;null!=r&&r.changeType&&(this.log(`changing ${t} sourceBuffer type to ${s}`),r.changeType(s),n.codec=i,n.container=e)}this.shiftAndExecuteNext(t)},onStart:()=>{},onComplete:()=>{},onError:e=>{this.warn(`Failed to change ${t} SourceBuffer type`,e)}};this.append(n,t,this.isPending(this.tracks[t]))}blockAudio(t){var e;const i=t.start,s=i+.05*t.duration;if(!0===(null==(e=this.fragmentTracker.getAppendedFrag(i,f))?void 0:e.gap))return;const n={label:"block-audio",execute:()=>{var t;const e=this.tracks.video;(this.lastVideoAppendEnd>s||null!=e&&e.buffer&&Oe.isBuffered(e.buffer,s)||!0===(null==(t=this.fragmentTracker.getAppendedFrag(s,f))?void 0:t.gap))&&(this.blockedAudioAppend=null,this.shiftAndExecuteNext("audio"))},onStart:()=>{},onComplete:()=>{},onError:t=>{this.warn("Error executing block-audio operation",t)}};this.blockedAudioAppend={op:n,frag:t},this.append(n,"audio",!0)}unblockAudio(){const{blockedAudioAppend:t,operationQueue:e}=this;t&&e&&(this.blockedAudioAppend=null,e.unblockAudio(t.op))}onBufferAppending(t,e){const{tracks:i}=this,{data:s,type:n,parent:r,frag:c,part:u,chunkMeta:d}=e,h=d.buffering[n],f=c.sn,p=self.performance.now();h.start=p;const g=c.stats.buffering,m=u?u.stats.buffering:null;0===g.start&&(g.start=p),m&&0===m.start&&(m.start=p);const y=i.audio;let v=!1;"audio"===n&&"audio/mpeg"===(null==y?void 0:y.container)&&(v=!this.lastMpegAudioChunk||1===d.id||this.lastMpegAudioChunk.sn!==d.sn,this.lastMpegAudioChunk=d);const b=this.tracks.video,_=null==b?void 0:b.buffer;if(_&&"initSegment"!==f){const t=u||c,e=this.blockedAudioAppend;if("audio"!==n||"main"===r||this.blockedAudioAppend){if("video"===n){const i=t.end;if(e){const t=e.frag.start;(i>t||i{if(h.executeStart=self.performance.now(),v){const t=this.tracks[n];if(t){const e=t.buffer;if(e){const t=E-e.timestampOffset;Math.abs(t)>=.1&&(this.log(`Updating audio SourceBuffer timestampOffset to ${E} (delta: ${t}) sn: ${f})`),e.timestampOffset=E)}}}this.appendExecutor(s,n)},onStart:()=>{},onComplete:()=>{const t=self.performance.now();h.executeEnd=h.end=t,0===g.first&&(g.first=t),m&&0===m.first&&(m.first=t);const e={};this.sourceBuffers.forEach((([t,i])=>{t&&(e[t]=Oe.getBuffered(i))})),this.appendErrors[n]=0,"audio"===n||"video"===n?this.appendErrors.audiovideo=0:(this.appendErrors.audio=0,this.appendErrors.video=0),this.hls.trigger(l.BUFFER_APPENDED,{type:n,frag:c,part:u,chunkMeta:d,parent:c.type,timeRanges:e})},onError:t=>{var e;const i={type:a.MEDIA_ERROR,parent:c.type,details:o.BUFFER_APPEND_ERROR,sourceBufferName:n,frag:c,part:u,chunkMeta:d,error:t,err:t,fatal:!1},s=null==(e=this.media)?void 0:e.error;if(t.code===DOMException.QUOTA_EXCEEDED_ERR)i.details=o.BUFFER_FULL_ERROR;else if(t.code===DOMException.INVALID_STATE_ERR&&this.mediaSourceOpenOrEnded&&!s)i.errorAction=pe(!0);else if(t.name===Rn&&0===this.sourceBufferCount)i.errorAction=pe(!0);else{const t=++this.appendErrors[n];this.warn(`Failed ${t}/${this.hls.config.appendErrorMaxRetry} times to append segment in "${n}" sourceBuffer (${s||"no media error"})`),(t>=this.hls.config.appendErrorMaxRetry||s)&&(i.fatal=!0)}this.hls.trigger(l.ERROR,i)}};this.append(T,n,this.isPending(this.tracks[n]))}getFlushOp(t,e,i){return this.log(`queuing "${t}" remove ${e}-${i}`),{label:"remove",execute:()=>{this.removeExecutor(t,e,i)},onStart:()=>{},onComplete:()=>{this.hls.trigger(l.BUFFER_FLUSHED,{type:t})},onError:s=>{this.warn(`Failed to remove ${e}-${i} from "${t}" SourceBuffer`,s)}}}onBufferFlushing(t,e){const{type:i,startOffset:s,endOffset:n}=e;i?this.append(this.getFlushOp(i,s,n),i):this.sourceBuffers.forEach((([t])=>{t&&this.append(this.getFlushOp(t,s,n),t)}))}onFragParsed(t,e){const{frag:i,part:s}=e,n=[],r=s?s.elementaryStreams:i.elementaryStreams;r[K]?n.push("audiovideo"):(r[V]&&n.push("audio"),r[H]&&n.push("video")),0===n.length&&this.warn(`Fragments must have at least one ElementaryStreamType set. type: ${i.type} level: ${i.level} sn: ${i.sn}`),this.blockBuffers((()=>{const t=self.performance.now();i.stats.buffering.end=t,s&&(s.stats.buffering.end=t);const e=s?s.stats:i.stats;this.hls.trigger(l.FRAG_BUFFERED,{frag:i,part:s,stats:e,id:i.type})}),n).catch((t=>{this.warn(`Fragment buffered callback ${t}`),this.stepOperationQueue(this.sourceBufferTypes)}))}onFragChanged(t,e){this.trimBuffers()}get bufferedToEnd(){return this.sourceBufferCount>0&&!this.sourceBuffers.some((([t])=>{var e,i;return t&&(!(null!=(e=this.tracks[t])&&e.ended)||(null==(i=this.tracks[t])?void 0:i.ending))}))}onBufferEos(t,e){var i;this.sourceBuffers.forEach((([t])=>{if(t){const i=this.tracks[t];e.type&&e.type!==t||(i.ending=!0,i.ended||(i.ended=!0,this.log(`${t} buffer reached EOS`)))}}));const s=!1!==(null==(i=this.overrides)?void 0:i.endOfStream);this.sourceBufferCount>0&&!this.sourceBuffers.some((([t])=>{var e;return t&&!(null!=(e=this.tracks[t])&&e.ended)}))&&(s?(this.log("Queueing EOS"),this.blockUntilOpen((()=>{this.tracksEnded();const{mediaSource:t}=this;t&&"open"===t.readyState?(this.log("Calling mediaSource.endOfStream()"),t.endOfStream(),this.hls.trigger(l.BUFFERED_TO_END,void 0)):t&&this.log(`Could not call mediaSource.endOfStream(). mediaSource.readyState: ${t.readyState}`)}))):(this.tracksEnded(),this.hls.trigger(l.BUFFERED_TO_END,void 0)))}tracksEnded(){this.sourceBuffers.forEach((([t])=>{if(null!==t){const e=this.tracks[t];e&&(e.ending=!1)}}))}onLevelUpdated(t,{details:e}){e.fragments.length&&(this.details=e,this.updateDuration())}updateDuration(){const t=this.getDurationAndRange();t&&this.blockUntilOpen((()=>this.updateMediaSource(t)))}onError(t,e){if(e.details===o.BUFFER_APPEND_ERROR&&e.frag){var i;const t=null==(i=e.errorAction)?void 0:i.nextAutoLevel;s(t)&&t!==e.frag.level&&this.resetAppendErrors()}}resetAppendErrors(){this.appendErrors={audio:0,video:0,audiovideo:0}}trimBuffers(){const{hls:t,details:e,media:i}=this;if(!i||null===e)return;if(!this.sourceBufferCount)return;const n=t.config,r=i.currentTime,a=e.levelTargetDuration,o=e.live&&null!==n.liveBackBufferLength?n.liveBackBufferLength:n.backBufferLength;if(s(o)&&o>=0){const t=Math.max(o,a),e=Math.floor(r/a)*a-t;this.flushBackBuffer(r,a,e)}if(s(n.frontBufferFlushThreshold)&&n.frontBufferFlushThreshold>0){const t=Math.max(n.maxBufferLength,n.frontBufferFlushThreshold),e=Math.max(t,a),i=Math.floor(r/a)*a+e;this.flushFrontBuffer(r,a,i)}}flushBackBuffer(t,e,i){this.sourceBuffers.forEach((([t,e])=>{if(e){const n=Oe.getBuffered(e);if(n.length>0&&i>n.start(0)){var s;this.hls.trigger(l.BACK_BUFFER_REACHED,{bufferEnd:i});const e=this.tracks[t];if(null!=(s=this.details)&&s.live)this.hls.trigger(l.LIVE_BACK_BUFFER_REACHED,{bufferEnd:i});else if(null!=e&&e.ended)return void this.log(`Cannot flush ${t} back buffer while SourceBuffer is in ended state`);this.hls.trigger(l.BUFFER_FLUSHING,{startOffset:0,endOffset:i,type:t})}}}))}flushFrontBuffer(t,e,i){this.sourceBuffers.forEach((([e,s])=>{if(s){const n=Oe.getBuffered(s),r=n.length;if(r<2)return;const a=n.start(r-1),o=n.end(r-1);if(i>a||t>=a&&t<=o)return;this.hls.trigger(l.BUFFER_FLUSHING,{startOffset:a,endOffset:1/0,type:e})}}))}getDurationAndRange(){var t;const{details:e,mediaSource:i}=this;if(!e||!this.media||"open"!==(null==i?void 0:i.readyState))return null;const n=e.edge;if(e.live&&this.hls.config.liveDurationInfinity){if(e.fragments.length&&e.live&&i.setLiveSeekableRange){const t=Math.max(0,e.fragmentStart);return{duration:1/0,start:t,end:Math.max(t,n)}}return{duration:1/0}}const r=null==(t=this.overrides)?void 0:t.duration;if(r)return s(r)?{duration:r}:null;const a=this.media.duration;return n>(s(i.duration)?i.duration:0)&&n>a||!s(a)?{duration:n}:null}updateMediaSource({duration:t,start:e,end:i}){const n=this.mediaSource;this.media&&n&&"open"===n.readyState&&(n.duration!==t&&(s(t)&&this.log(`Updating MediaSource duration to ${t.toFixed(3)}`),n.duration=t),void 0!==e&&void 0!==i&&(this.log(`MediaSource duration is set to ${n.duration}. Setting seekable range to ${e}-${i}.`),n.setLiveSeekableRange(e,i)))}get tracksReady(){const t=this.pendingTrackCount;return t>0&&(t>=this.bufferCodecEventsTotal||this.isPending(this.tracks.audiovideo))}checkPendingTracks(){const{bufferCodecEventsTotal:t,pendingTrackCount:e,tracks:i}=this;if(this.log(`checkPendingTracks (pending: ${e} codec events expected: ${t}) ${Wt(i)}`),this.tracksReady){var s;const t=null==(s=this.transferData)?void 0:s.tracks;t&&Object.keys(t).length?this.attachTransferred():this.createSourceBuffers()}}bufferCreated(){if(this.sourceBufferCount){const t={};this.sourceBuffers.forEach((([e,i])=>{if(e){const s=this.tracks[e];t[e]={buffer:i,container:s.container,codec:s.codec,supplemental:s.supplemental,levelCodec:s.levelCodec,id:s.id,metadata:s.metadata}}})),this.hls.trigger(l.BUFFER_CREATED,{tracks:t}),this.log(`SourceBuffers created. Running queue: ${this.operationQueue}`),this.sourceBuffers.forEach((([t])=>{this.executeNext(t)}))}else{const t=new Error("could not create source buffer for media codec(s)");this.hls.trigger(l.ERROR,{type:a.MEDIA_ERROR,details:o.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:t,reason:t.message})}}createSourceBuffers(){const{tracks:t,sourceBuffers:e,mediaSource:i}=this;if(!i)throw new Error("createSourceBuffers called when mediaSource was null");for(const n in t){const r=n,c=t[r];if(this.isPending(c)){const t=this.getTrackCodec(c,r),n=`${c.container};codecs=${t}`;c.codec=t,this.log(`creating sourceBuffer(${n})${this.currentOp(r)?" Queued":""} ${Wt(c)}`);try{const t=i.addSourceBuffer(n),s=Cn(r),a=[r,t];e[s]=a,c.buffer=t}catch(t){var s;return this.error(`error while trying to add sourceBuffer: ${t.message}`),this.shiftAndExecuteNext(r),null==(s=this.operationQueue)||s.removeBlockers(),delete this.tracks[r],void this.hls.trigger(l.ERROR,{type:a.MEDIA_ERROR,details:o.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:t,sourceBufferName:r,mimeType:n,parent:c.id})}this.trackSourceBuffer(r,c)}}this.bufferCreated()}getTrackCodec(t,e){const i=t.supplemental;let s=t.codec;i&&("video"===e||"audiovideo"===e)&&At(i,"video")&&(s=function(t,e){const i=[];if(t){const e=t.split(",");for(let t=0;t{const i=e.removedRanges;null!=i&&i.length&&this.hls.trigger(l.BUFFER_FLUSHED,{type:t})}))}get mediaSrc(){var t,e;const i=(null==(t=this.media)||null==(e=t.querySelector)?void 0:e.call(t,"source"))||this.media;return null==i?void 0:i.src}onSBUpdateStart(t){const e=this.currentOp(t);e&&e.onStart()}onSBUpdateEnd(t){var e;if("closed"===(null==(e=this.mediaSource)?void 0:e.readyState))return void this.resetBuffer(t);const i=this.currentOp(t);i&&(i.onComplete(),this.shiftAndExecuteNext(t))}onSBUpdateError(t,e){var i;const s=new Error(`${t} SourceBuffer error. MediaSource readyState: ${null==(i=this.mediaSource)?void 0:i.readyState}`);this.error(`${s}`,e),this.hls.trigger(l.ERROR,{type:a.MEDIA_ERROR,details:o.BUFFER_APPENDING_ERROR,sourceBufferName:t,error:s,fatal:!1});const n=this.currentOp(t);n&&n.onError(s)}removeExecutor(t,e,i){const{media:n,mediaSource:r}=this,a=this.tracks[t],o=null==a?void 0:a.buffer;if(!n||!r||!o)return this.warn(`Attempting to remove from the ${t} SourceBuffer, but it does not exist`),void this.shiftAndExecuteNext(t);const l=s(n.duration)?n.duration:1/0,c=s(r.duration)?r.duration:1/0,u=Math.max(0,e),d=Math.min(i,l,c);d>u&&(!a.ending||a.ended)?(a.ended=!1,this.log(`Removing [${u},${d}] from the ${t} SourceBuffer`),o.remove(u,d)):this.shiftAndExecuteNext(t)}appendExecutor(t,e){const i=this.tracks[e],s=null==i?void 0:i.buffer;if(!s)throw new Ln(`Attempting to append to the ${e} SourceBuffer, but it does not exist`);i.ending=!1,i.ended=!1,s.appendBuffer(t)}blockUntilOpen(t){if(this.isUpdating()||this.isQueued())this.blockBuffers(t).catch((t=>{this.warn(`SourceBuffer blocked callback ${t}`),this.stepOperationQueue(this.sourceBufferTypes)}));else try{t()}catch(t){this.warn(`Callback run without blocking ${this.operationQueue} ${t}`)}}isUpdating(){return this.sourceBuffers.some((([t,e])=>t&&e.updating))}isQueued(){return this.sourceBuffers.some((([t])=>t&&!!this.currentOp(t)))}isPending(t){return!!t&&!t.buffer}blockBuffers(t,e=this.sourceBufferTypes){if(!e.length)return this.log("Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(t);const{operationQueue:i}=this,s=e.map((t=>this.appendBlocker(t)));return e.length>1&&!!this.blockedAudioAppend&&this.unblockAudio(),Promise.all(s).then((e=>{i===this.operationQueue&&(t(),this.stepOperationQueue(this.sourceBufferTypes))}))}stepOperationQueue(t){t.forEach((t=>{var e;const i=null==(e=this.tracks[t])?void 0:e.buffer;i&&!i.updating&&this.shiftAndExecuteNext(t)}))}append(t,e,i){this.operationQueue&&this.operationQueue.append(t,e,i)}appendBlocker(t){if(this.operationQueue)return this.operationQueue.appendBlocker(t)}currentOp(t){return this.operationQueue?this.operationQueue.current(t):null}executeNext(t){t&&this.operationQueue&&this.operationQueue.executeNext(t)}shiftAndExecuteNext(t){this.operationQueue&&this.operationQueue.shiftAndExecuteNext(t)}get pendingTrackCount(){return Object.keys(this.tracks).reduce(((t,e)=>t+(this.isPending(this.tracks[e])?1:0)),0)}get sourceBufferCount(){return this.sourceBuffers.reduce(((t,[e])=>t+(e?1:0)),0)}get sourceBufferTypes(){return this.sourceBuffers.map((([t])=>t)).filter((t=>!!t))}addBufferListener(t,e,i){const s=this.tracks[t];if(!s)return;const n=s.buffer;if(!n)return;const r=i.bind(this,t);s.listeners.push({event:e,listener:r}),n.addEventListener(e,r)}removeBufferListeners(t){const e=this.tracks[t];if(!e)return;const i=e.buffer;i&&(e.listeners.forEach((t=>{i.removeEventListener(t.event,t.listener)})),e.listeners.length=0)}},capLevelController:Dn,errorController:class extends T{constructor(t){super("error-controller",t.logger),this.hls=void 0,this.playlistError=0,this.penalizedRenditions={},this.hls=t,this.registerListeners()}registerListeners(){const t=this.hls;t.on(l.ERROR,this.onError,this),t.on(l.MANIFEST_LOADING,this.onManifestLoading,this),t.on(l.LEVEL_UPDATED,this.onLevelUpdated,this)}unregisterListeners(){const t=this.hls;t&&(t.off(l.ERROR,this.onError,this),t.off(l.ERROR,this.onErrorOut,this),t.off(l.MANIFEST_LOADING,this.onManifestLoading,this),t.off(l.LEVEL_UPDATED,this.onLevelUpdated,this))}destroy(){this.unregisterListeners(),this.hls=null,this.penalizedRenditions={}}startLoad(t){}stopLoad(){this.playlistError=0}getVariantLevelIndex(t){return(null==t?void 0:t.type)===f?t.level:this.hls.loadLevel}onManifestLoading(){this.playlistError=0,this.penalizedRenditions={}}onLevelUpdated(){this.playlistError=0}onError(t,e){var i;if(e.fatal)return;const s=this.hls,n=e.context;switch(e.details){case o.FRAG_LOAD_ERROR:case o.FRAG_LOAD_TIMEOUT:case o.KEY_LOAD_ERROR:case o.KEY_LOAD_TIMEOUT:return void(e.errorAction=this.getFragRetryOrSwitchAction(e));case o.FRAG_PARSING_ERROR:if(null!=(i=e.frag)&&i.gap)return void(e.errorAction=pe());case o.FRAG_GAP:case o.FRAG_DECRYPT_ERROR:return e.errorAction=this.getFragRetryOrSwitchAction(e),void(e.errorAction.action=2);case o.LEVEL_EMPTY_ERROR:case o.LEVEL_PARSING_ERROR:{var r,l;const t=e.parent===f?e.level:s.loadLevel;e.details===o.LEVEL_EMPTY_ERROR&&null!=(r=e.context)&&null!=(l=r.levelDetails)&&l.live?e.errorAction=this.getPlaylistRetryOrSwitchAction(e,t):(e.levelRetry=!1,e.errorAction=this.getLevelSwitchAction(e,t))}return;case o.LEVEL_LOAD_ERROR:case o.LEVEL_LOAD_TIMEOUT:return void("number"==typeof(null==n?void 0:n.level)&&(e.errorAction=this.getPlaylistRetryOrSwitchAction(e,n.level)));case o.AUDIO_TRACK_LOAD_ERROR:case o.AUDIO_TRACK_LOAD_TIMEOUT:case o.SUBTITLE_LOAD_ERROR:case o.SUBTITLE_TRACK_LOAD_TIMEOUT:if(n){const t=s.loadLevelObj;if(t&&(n.type===d&&t.hasAudioGroup(n.groupId)||n.type===h&&t.hasSubtitleGroup(n.groupId)))return e.errorAction=this.getPlaylistRetryOrSwitchAction(e,s.loadLevel),e.errorAction.action=2,void(e.errorAction.flags=1)}return;case o.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:{const t=s.loadLevelObj,i=null==t?void 0:t.attrs["HDCP-LEVEL"];i?e.errorAction={action:2,flags:2,hdcpLevel:i}:this.keySystemError(e)}return;case o.BUFFER_ADD_CODEC_ERROR:case o.REMUX_ALLOC_ERROR:case o.BUFFER_APPEND_ERROR:var c;return void(e.errorAction||(e.errorAction=this.getLevelSwitchAction(e,null!=(c=e.level)?c:s.loadLevel)));case o.INTERNAL_EXCEPTION:case o.BUFFER_APPENDING_ERROR:case o.BUFFER_FULL_ERROR:case o.LEVEL_SWITCH_ERROR:case o.BUFFER_STALLED_ERROR:case o.BUFFER_SEEK_OVER_HOLE:case o.BUFFER_NUDGE_ON_STALL:return void(e.errorAction=pe())}e.type===a.KEY_SYSTEM_ERROR&&this.keySystemError(e)}keySystemError(t){const e=this.getVariantLevelIndex(t.frag);t.levelRetry=!1,t.errorAction=this.getLevelSwitchAction(t,e)}getPlaylistRetryOrSwitchAction(t,e){const i=ue(this.hls.config.playlistLoadPolicy,t),s=this.playlistError++;if(fe(i,s,ce(t),t.response))return{action:5,flags:0,retryConfig:i,retryCount:s};const n=this.getLevelSwitchAction(t,e);return i&&(n.retryConfig=i,n.retryCount=s),n}getFragRetryOrSwitchAction(t){const e=this.hls,i=this.getVariantLevelIndex(t.frag),s=e.levels[i],{fragLoadPolicy:n,keyLoadPolicy:r}=e.config,a=ue(t.details.startsWith("key")?r:n,t),l=e.levels.reduce(((t,e)=>t+e.fragmentError),0);if(s&&(t.details!==o.FRAG_GAP&&s.fragmentError++,fe(a,l,ce(t),t.response)))return{action:5,flags:0,retryConfig:a,retryCount:l};const c=this.getLevelSwitchAction(t,i);return a&&(c.retryConfig=a,c.retryCount=l),c}getLevelSwitchAction(t,e){const i=this.hls;null==e&&(e=i.loadLevel);const s=this.hls.levels[e];if(s){var n,r;const e=t.details;s.loadError++,e===o.BUFFER_APPEND_ERROR&&s.fragmentError++;let c=-1;const{levels:u,loadLevel:m,minAutoLevel:y,maxAutoLevel:v}=i;i.autoLevelEnabled||(i.loadLevel=-1);const b=null==(n=t.frag)?void 0:n.type,_=(b===p&&e===o.FRAG_PARSING_ERROR||"audio"===t.sourceBufferName&&(e===o.BUFFER_ADD_CODEC_ERROR||e===o.BUFFER_APPEND_ERROR))&&u.some((({audioCodec:t})=>s.audioCodec!==t)),E="video"===t.sourceBufferName&&(e===o.BUFFER_ADD_CODEC_ERROR||e===o.BUFFER_APPEND_ERROR)&&u.some((({codecSet:t,audioCodec:e})=>s.codecSet!==t&&s.audioCodec===e)),{type:T,groupId:S}=null!=(r=t.context)?r:{};for(let i=u.length;i--;){const n=(i+m)%u.length;if(n!==m&&n>=y&&n<=v&&0===u[n].loadError){var a,l;const i=u[n];if(e===o.FRAG_GAP&&b===f&&t.frag){const e=u[n].details;if(e){const i=re(t.frag,e.fragments,t.frag.start);if(null!=i&&i.gap)continue}}else{if(T===d&&i.hasAudioGroup(S)||T===h&&i.hasSubtitleGroup(S))continue;if(b===p&&null!=(a=s.audioGroups)&&a.some((t=>i.hasAudioGroup(t)))||b===g&&null!=(l=s.subtitleGroups)&&l.some((t=>i.hasSubtitleGroup(t)))||_&&s.audioCodec===i.audioCodec||!_&&s.audioCodec!==i.audioCodec||E&&s.codecSet===i.codecSet)continue}c=n;break}}if(c>-1&&i.loadLevel!==c)return t.levelRetry=!0,this.playlistError=0,{action:2,flags:0,nextAutoLevel:c}}return{action:2,flags:1}}onErrorOut(t,e){var i;switch(null==(i=e.errorAction)?void 0:i.action){case 0:break;case 2:this.sendAlternateToPenaltyBox(e),e.errorAction.resolved||e.details===o.FRAG_GAP?/MediaSource readyState: ended/.test(e.error.message)&&(this.warn(`MediaSource ended after "${e.sourceBufferName}" sourceBuffer append error. Attempting to recover from media error.`),this.hls.recoverMediaError()):e.fatal=!0}e.fatal&&this.hls.stopLoad()}sendAlternateToPenaltyBox(t){const e=this.hls,i=t.errorAction;if(!i)return;const{flags:s,hdcpLevel:n,nextAutoLevel:r}=i;switch(s){case 0:this.switchLevel(t,r);break;case 2:n&&(e.maxHdcpLevel=Vt[Vt.indexOf(n)-1],i.resolved=!0),this.warn(`Restricting playback to HDCP-LEVEL of "${e.maxHdcpLevel}" or lower`)}i.resolved||this.switchLevel(t,r)}switchLevel(t,e){if(void 0!==e&&t.errorAction&&(this.warn(`switching to level ${e} after ${t.details}`),this.hls.nextAutoLevel=e,t.errorAction.resolved=!0,this.hls.nextLoadLevel=this.hls.nextAutoLevel,t.details===o.BUFFER_ADD_CODEC_ERROR&&t.mimeType&&"audiovideo"!==t.sourceBufferName)){const e=Ft(t.mimeType),i=this.hls.levels;for(let s=i.length;s--;)i[s][`${t.sourceBufferName}Codec`]===e&&this.hls.removeLevel(s)}}},fpsController:class{constructor(t){this.hls=void 0,this.isVideoPlaybackQualityAvailable=!1,this.timer=void 0,this.media=null,this.lastTime=void 0,this.lastDroppedFrames=0,this.lastDecodedFrames=0,this.streamController=void 0,this.hls=t,this.registerListeners()}setStreamController(t){this.streamController=t}registerListeners(){this.hls.on(l.MEDIA_ATTACHING,this.onMediaAttaching,this),this.hls.on(l.MEDIA_DETACHING,this.onMediaDetaching,this)}unregisterListeners(){this.hls.off(l.MEDIA_ATTACHING,this.onMediaAttaching,this),this.hls.off(l.MEDIA_DETACHING,this.onMediaDetaching,this)}destroy(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null}onMediaAttaching(t,e){const i=this.hls.config;if(i.capLevelOnFPSDrop){const t=e.media instanceof self.HTMLVideoElement?e.media:null;this.media=t,t&&"function"==typeof t.getVideoPlaybackQuality&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),i.fpsDroppedMonitoringPeriod)}}onMediaDetaching(){this.media=null}checkFPS(t,e,i){const s=performance.now();if(e){if(this.lastTime){const t=s-this.lastTime,n=i-this.lastDroppedFrames,r=e-this.lastDecodedFrames,a=1e3*n/t,o=this.hls;if(o.trigger(l.FPS_DROP,{currentDropped:n,currentDecoded:r,totalDroppedFrames:i}),a>0&&n>o.config.fpsDroppedMonitoringThreshold*r){let t=o.currentLevel;o.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+t),t>0&&(-1===o.autoLevelCapping||o.autoLevelCapping>=t)&&(t-=1,o.trigger(l.FPS_DROP_LEVEL_CAPPING,{level:t,droppedLevel:o.currentLevel}),o.autoLevelCapping=t,this.streamController.nextLevelSwitch())}}this.lastTime=s,this.lastDroppedFrames=i,this.lastDecodedFrames=e}}checkFPSInterval(){const t=this.media;if(t)if(this.isVideoPlaybackQualityAvailable){const e=t.getVideoPlaybackQuality();this.checkFPS(t,e.totalVideoFrames,e.droppedVideoFrames)}else this.checkFPS(t,t.webkitDecodedFrameCount,t.webkitDroppedFrameCount)}},stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrEwmaDefaultEstimateMax:5e6,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystems:{},drmSystemOptions:{},requestMediaKeySystemAccessFunc:ai,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableEmsgKLVMetadata:!1,enableID3MetadataCues:!0,enableInterstitialPlayback:!0,interstitialAppendInPlace:!0,interstitialLiveLookAhead:10,useMediaCapabilities:!0,certLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null}},keyLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"},errorRetry:{maxNumRetry:8,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"}}},manifestLoadPolicy:{default:{maxTimeToFirstByteMs:1/0,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},playlistLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:2,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},fragLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:12e4,timeoutRetry:{maxNumRetry:4,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:6,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},steeringManifestLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},interstitialAssetListLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:3e4,timeoutRetry:{maxNumRetry:0,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:0,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3},{cueHandler:Ca,enableWebVTT:!0,enableIMSC1:!0,enableCEA708Captions:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}),{},{subtitleStreamController:class extends Vi{constructor(t,e,i){super(t,e,i,"subtitle-stream-controller",g),this.currentTrackId=-1,this.tracksBuffered=[],this.mainDetails=null,this.registerListeners()}onHandlerDestroying(){this.unregisterListeners(),super.onHandlerDestroying(),this.mainDetails=null}registerListeners(){super.registerListeners();const{hls:t}=this;t.on(l.LEVEL_LOADED,this.onLevelLoaded,this),t.on(l.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.on(l.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),t.on(l.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.on(l.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),t.on(l.BUFFER_FLUSHING,this.onBufferFlushing,this)}unregisterListeners(){super.unregisterListeners();const{hls:t}=this;t.off(l.LEVEL_LOADED,this.onLevelLoaded,this),t.off(l.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.off(l.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),t.off(l.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.off(l.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),t.off(l.BUFFER_FLUSHING,this.onBufferFlushing,this)}startLoad(t,e){this.stopLoad(),this.state=Gi.IDLE,this.setInterval(500),this.nextLoadPosition=this.lastCurrentTime=t+this.timelineOffset,this.startPosition=e?-1:t,this.tick()}onManifestLoading(){super.onManifestLoading(),this.mainDetails=null}onMediaDetaching(t,e){this.tracksBuffered=[],super.onMediaDetaching(t,e)}onLevelLoaded(t,e){this.mainDetails=e.details}onSubtitleFragProcessed(t,e){const{frag:i,success:s}=e;if(q(i)&&(this.fragPrevious=i),this.state=Gi.IDLE,!s)return;const n=this.tracksBuffered[this.currentTrackId];if(!n)return;let r;const a=i.start;for(let t=0;t=n[t].start&&a<=n[t].end){r=n[t];break}const o=i.start+i.duration;r?r.end=o:(r={start:a,end:o},n.push(r)),this.fragmentTracker.fragBuffered(i),this.fragBufferedComplete(i,null),this.media&&this.tick()}onBufferFlushing(t,e){const{startOffset:i,endOffset:s}=e;if(0===i&&s!==Number.POSITIVE_INFINITY){const t=s-1;if(t<=0)return;e.endOffsetSubtitles=Math.max(0,t),this.tracksBuffered.forEach((e=>{for(let i=0;inew qt(t))):(this.tracksBuffered=[],this.levels=e.map((t=>{const e=new qt(t);return this.tracksBuffered[e.id]=[],e})),this.fragmentTracker.removeFragmentsInRange(0,Number.POSITIVE_INFINITY,g),this.fragPrevious=null,this.mediaBuffer=null)}onSubtitleTrackSwitch(t,e){var i;if(this.currentTrackId=e.id,null==(i=this.levels)||!i.length||-1===this.currentTrackId)return void this.clearInterval();const s=this.levels[this.currentTrackId];null!=s&&s.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,s&&this.state!==Gi.STOPPED&&this.setInterval(500)}onSubtitleTrackLoaded(t,e){var i;const{currentTrackId:s,levels:n}=this,{details:r,id:a}=e;if(!n)return void this.warn(`Subtitle tracks were reset while loading level ${a}`);const o=n[a];if(a>=n.length||!o)return;this.log(`Subtitle track ${a} loaded [${r.startSN},${r.endSN}]${r.lastPartSn?`[part-${r.lastPartSn}-${r.lastPartIndex}]`:""},duration:${r.totalduration}`),this.mediaBuffer=this.mediaBufferTimeRanges;let c=0;if(r.live||null!=(i=o.details)&&i.live){const t=this.mainDetails;if(r.deltaUpdateFailed||!t)return;const e=t.fragments[0];var u;o.details?(c=this.alignPlaylists(r,o.details,null==(u=this.levelLastLoaded)?void 0:u.details),0===c&&e&&(c=e.start,xi(r,c))):r.hasProgramDateTime&&t.hasProgramDateTime?(ji(r,t),c=r.fragmentStart):e&&(c=e.start,xi(r,c))}o.details=r,this.levelLastLoaded=o,a===s&&(this.hls.trigger(l.SUBTITLE_TRACK_UPDATED,{details:r,id:a,groupId:e.groupId}),this.tick(),r.live&&!this.fragCurrent&&this.media&&this.state===Gi.IDLE)&&(re(null,r.fragments,this.media.currentTime,0)||(this.warn("Subtitle playlist not aligned with playback"),o.details=void 0))}_handleFragmentLoadComplete(t){const{frag:e,payload:i}=t,s=e.decryptdata,n=this.hls;if(!this.fragContextChanged(e)&&i&&i.byteLength>0&&null!=s&&s.key&&s.iv&&Ye(s.method)){const t=performance.now();this.decrypter.decrypt(new Uint8Array(i),s.key.buffer,s.iv.buffer,qe(s.method)).catch((t=>{throw n.trigger(l.ERROR,{type:a.MEDIA_ERROR,details:o.FRAG_DECRYPT_ERROR,fatal:!1,error:t,reason:t.message,frag:e}),t})).then((i=>{const s=performance.now();n.trigger(l.FRAG_DECRYPTED,{frag:e,payload:i,stats:{tstart:t,tdecrypt:s}})})).catch((t=>{this.warn(`${t.name}: ${t.message}`),this.state=Gi.IDLE}))}}doTick(){if(this.media){if(this.state===Gi.IDLE){const{currentTrackId:t,levels:e}=this,i=null==e?void 0:e[t];if(!i||!e.length||!i.details)return;if(this.waitForLive(i))return;const{config:s}=this,n=this.getLoadPosition(),r=Oe.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],n,s.maxBufferHole),{end:a,len:o}=r,l=i.details;if(o>this.hls.maxBufferLength+l.levelTargetDuration)return;const c=l.fragments,u=c.length,d=l.edge;let h=null;const f=this.fragPrevious;if(ad-t?0:t;h=re(f,c,Math.max(c[0].start,a),e),!h&&f&&f.startthis.pollTrackChange(0),this.onTextTracksChanged=()=>{if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!this.media||!this.hls.config.renderTextTracksNatively)return;let t=null;const e=_r(this.media.textTracks);for(let i=0;i-1&&this.toggleTrackModes()}registerListeners(){const{hls:t}=this;t.on(l.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(l.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(l.MANIFEST_LOADING,this.onManifestLoading,this),t.on(l.MANIFEST_PARSED,this.onManifestParsed,this),t.on(l.LEVEL_LOADING,this.onLevelLoading,this),t.on(l.LEVEL_SWITCHING,this.onLevelSwitching,this),t.on(l.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.on(l.ERROR,this.onError,this)}unregisterListeners(){const{hls:t}=this;t.off(l.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(l.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(l.MANIFEST_LOADING,this.onManifestLoading,this),t.off(l.MANIFEST_PARSED,this.onManifestParsed,this),t.off(l.LEVEL_LOADING,this.onLevelLoading,this),t.off(l.LEVEL_SWITCHING,this.onLevelSwitching,this),t.off(l.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.off(l.ERROR,this.onError,this)}onMediaAttached(t,e){this.media=e.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(t){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.onTextTracksChanged,t)}onMediaDetaching(t,e){const i=this.media;if(!i)return;const s=!!e.transferMedia;self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||i.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId),this.subtitleTrack=-1,this.media=null,s||_r(i.textTracks).forEach((t=>{vr(t)}))}onManifestLoading(){this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0}onManifestParsed(t,e){this.tracks=e.subtitleTracks}onSubtitleTrackLoaded(t,e){const{id:i,groupId:s,details:n}=e,r=this.tracksInGroup[i];if(!r||r.groupId!==s)return void this.warn(`Subtitle track with id:${i} and group:${s} not found in active group ${null==r?void 0:r.groupId}`);const a=r.details;r.details=e.details,this.log(`Subtitle track ${i} "${r.name}" lang:${r.lang} group:${s} loaded [${n.startSN}-${n.endSN}]`),i===this.trackId&&this.playlistLoaded(i,e,a)}onLevelLoading(t,e){this.switchLevel(e.level)}onLevelSwitching(t,e){this.switchLevel(e.level)}switchLevel(t){const e=this.hls.levels[t];if(!e)return;const i=e.subtitleGroups||null,s=this.groupIds;let n=this.currentTrack;if(!i||(null==s?void 0:s.length)!==(null==i?void 0:i.length)||null!=i&&i.some((t=>-1===(null==s?void 0:s.indexOf(t))))){this.groupIds=i,this.trackId=-1,this.currentTrack=null;const t=this.tracks.filter((t=>!i||-1!==i.indexOf(t.groupId)));if(t.length)this.selectDefaultTrack&&!t.some((t=>t.default))&&(this.selectDefaultTrack=!1),t.forEach(((t,e)=>{t.id=e}));else if(!n&&!this.tracksInGroup.length)return;this.tracksInGroup=t;const e=this.hls.config.subtitlePreference;if(!n&&e){this.selectDefaultTrack=!1;const i=Zt(e,t);if(i>-1)n=t[i];else{const t=Zt(e,this.tracks);n=this.tracks[t]}}let s=this.findTrackId(n);-1===s&&n&&(s=this.findTrackId(null));const r={subtitleTracks:t};this.log(`Updating subtitle tracks, ${t.length} track(s) found in "${null==i?void 0:i.join(",")}" group-id`),this.hls.trigger(l.SUBTITLE_TRACKS_UPDATED,r),-1!==s&&-1===this.trackId&&this.setSubtitleTrack(s)}}findTrackId(t){const e=this.tracksInGroup,i=this.selectDefaultTrack;for(let s=0;s-1){const t=this.tracksInGroup[s];return this.setSubtitleTrack(s),t}if(i)return null;{const i=Zt(t,e);if(i>-1)return e[i]}}}return null}loadPlaylist(t){super.loadPlaylist(),this.shouldLoadPlaylist(this.currentTrack)&&this.scheduleLoading(this.currentTrack,t)}loadingPlaylist(t,e){super.loadingPlaylist(t,e);const i=t.id,s=t.groupId,n=this.getUrlWithDirectives(t.url,e),r=t.details,a=null==r?void 0:r.age;this.log(`Loading subtitle ${i} "${t.name}" lang:${t.lang} group:${s}${void 0!==(null==e?void 0:e.msn)?" at sn "+e.msn+" part "+e.part:""}${a&&r.live?" age "+a.toFixed(1)+(r.type?" "+r.type||0:""):""} ${n}`),this.hls.trigger(l.SUBTITLE_TRACK_LOADING,{url:n,id:i,groupId:s,deliveryDirectives:e||null,track:t})}toggleTrackModes(){const{media:t}=this;if(!t)return;const e=_r(t.textTracks),i=this.currentTrack;let s;if(i&&(s=e.filter((t=>kn(i,t)))[0],s||this.warn(`Unable to find subtitle TextTrack with name "${i.name}" and language "${i.lang}"`)),[].slice.call(e).forEach((t=>{"disabled"!==t.mode&&t!==s&&(t.mode="disabled")})),s){const t=this.subtitleDisplay?"showing":"hidden";s.mode!==t&&(s.mode=t)}}setSubtitleTrack(t){const e=this.tracksInGroup;if(!this.media)return void(this.queuedDefaultTrack=t);if(t<-1||t>=e.length||!s(t))return void this.warn(`Invalid subtitle track id: ${t}`);this.selectDefaultTrack=!1;const i=this.currentTrack,n=e[t]||null;if(this.trackId=t,this.currentTrack=n,this.toggleTrackModes(),!n)return void this.hls.trigger(l.SUBTITLE_TRACK_SWITCH,{id:t});const r=!!n.details&&!n.details.live;if(t===this.trackId&&n===i&&r)return;this.log(`Switching to subtitle-track ${t}`+(n?` "${n.name}" lang:${n.lang} group:${n.groupId}`:""));const{id:a,groupId:o="",name:c,type:u,url:d}=n;this.hls.trigger(l.SUBTITLE_TRACK_SWITCH,{id:a,groupId:o,name:c,type:u,url:d});const h=this.switchParams(n.url,null==i?void 0:i.details,n.details);this.loadPlaylist(h)}},timelineController:class{constructor(t){this.hls=void 0,this.media=null,this.config=void 0,this.enabled=!0,this.Cues=void 0,this.textTracks=[],this.tracks=[],this.initPTS=[],this.unparsedVttFrags=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.cea608Parser1=void 0,this.cea608Parser2=void 0,this.lastCc=-1,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs={ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}},this.captionsProperties=void 0,this.hls=t,this.config=t.config,this.Cues=t.config.cueHandler,this.captionsProperties={textTrack1:{label:this.config.captionsTextTrack1Label,languageCode:this.config.captionsTextTrack1LanguageCode},textTrack2:{label:this.config.captionsTextTrack2Label,languageCode:this.config.captionsTextTrack2LanguageCode},textTrack3:{label:this.config.captionsTextTrack3Label,languageCode:this.config.captionsTextTrack3LanguageCode},textTrack4:{label:this.config.captionsTextTrack4Label,languageCode:this.config.captionsTextTrack4LanguageCode}},t.on(l.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(l.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(l.MANIFEST_LOADING,this.onManifestLoading,this),t.on(l.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(l.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.on(l.FRAG_LOADING,this.onFragLoading,this),t.on(l.FRAG_LOADED,this.onFragLoaded,this),t.on(l.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),t.on(l.FRAG_DECRYPTED,this.onFragDecrypted,this),t.on(l.INIT_PTS_FOUND,this.onInitPtsFound,this),t.on(l.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),t.on(l.BUFFER_FLUSHING,this.onBufferFlushing,this)}destroy(){const{hls:t}=this;t.off(l.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(l.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(l.MANIFEST_LOADING,this.onManifestLoading,this),t.off(l.MANIFEST_LOADED,this.onManifestLoaded,this),t.off(l.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.off(l.FRAG_LOADING,this.onFragLoading,this),t.off(l.FRAG_LOADED,this.onFragLoaded,this),t.off(l.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),t.off(l.FRAG_DECRYPTED,this.onFragDecrypted,this),t.off(l.INIT_PTS_FOUND,this.onInitPtsFound,this),t.off(l.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),t.off(l.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.media=null,this.cea608Parser1=this.cea608Parser2=void 0}initCea608Parsers(){const t=new Aa(this,"textTrack1"),e=new Aa(this,"textTrack2"),i=new Aa(this,"textTrack3"),s=new Aa(this,"textTrack4");this.cea608Parser1=new Zr(1,t,e),this.cea608Parser2=new Zr(3,i,s)}addCues(t,e,i,s,n){let r=!1;for(let t=n.length;t--;){const s=n[t],l=(a=s[0],o=s[1],c=e,u=i,Math.min(o,u)-Math.max(a,c));if(l>=0&&(s[0]=Math.min(s[0],e),s[1]=Math.max(s[1],i),r=!0,l/(i-e)>.5))return}var a,o,c,u;if(r||n.push([e,i]),this.config.renderTextTracksNatively){const n=this.captionsTracks[t];this.Cues.newCue(n,e,i,s)}else{const n=this.Cues.newCue(null,e,i,s);this.hls.trigger(l.CUES_PARSED,{type:"captions",cues:n,track:t})}}onInitPtsFound(t,{frag:e,id:i,initPTS:s,timescale:n}){const{unparsedVttFrags:r}=this;i===f&&(this.initPTS[e.cc]={baseTime:s,timescale:n}),r.length&&(this.unparsedVttFrags=[],r.forEach((t=>{this.onFragLoaded(l.FRAG_LOADED,t)})))}getExistingTrack(t,e){const{media:i}=this;if(i)for(let s=0;s{vr(s[t]),delete s[t]})),this.nonNativeCaptionsTracks={}}onManifestLoading(){this.lastCc=-1,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs={ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}},this._cleanTracks(),this.tracks=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.textTracks=[],this.unparsedVttFrags=[],this.initPTS=[],this.cea608Parser1&&this.cea608Parser2&&(this.cea608Parser1.reset(),this.cea608Parser2.reset())}_cleanTracks(){const{media:t}=this;if(!t)return;const e=t.textTracks;if(e)for(let t=0;tt.textCodec===ga));if(this.config.enableWebVTT||s&&this.config.enableIMSC1){if(Tn(this.tracks,i))return void(this.tracks=i);if(this.textTracks=[],this.tracks=i,this.config.renderTextTracksNatively){const t=this.media,e=t?_r(t.textTracks):null;if(this.tracks.forEach(((t,i)=>{let s;if(e){let i=null;for(let s=0;snull!==t)).map((t=>t.label));t.length&&this.hls.logger.warn(`Media element contains unused subtitle tracks: ${t.join(", ")}. Replace media element for each source to clear TextTracks and captions menu.`)}}else if(this.tracks.length){const t=this.tracks.map((t=>({label:t.name,kind:t.type.toLowerCase(),default:t.default,subtitleTrack:t})));this.hls.trigger(l.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:t})}}}onManifestLoaded(t,e){this.config.enableCEA708Captions&&e.captions&&e.captions.forEach((t=>{const e=/(?:CC|SERVICE)([1-4])/.exec(t.instreamId);if(!e)return;const i=`textTrack${e[1]}`,s=this.captionsProperties[i];s&&(s.label=t.name,t.lang&&(s.languageCode=t.lang),s.media=t)}))}closedCaptionsForLevel(t){const e=this.hls.levels[t.level];return null==e?void 0:e.attrs["CLOSED-CAPTIONS"]}onFragLoading(t,e){if(this.enabled&&e.frag.type===f){var i,s;const{cea608Parser1:t,cea608Parser2:n,lastSn:r}=this,{cc:a,sn:o}=e.frag,l=null!=(i=null==(s=e.part)?void 0:s.index)?i:-1;t&&n&&(o!==r+1||o===r&&l!==this.lastPartIndex+1||a!==this.lastCc)&&(t.reset(),n.reset()),this.lastCc=a,this.lastSn=o,this.lastPartIndex=l}}onFragLoaded(t,e){const{frag:i,payload:s}=e;if(i.type===g)if(s.byteLength){const t=i.decryptdata,n="stats"in e;if(null==t||!t.encrypted||n){const t=this.tracks[i.level],n=this.vttCCs;n[i.cc]||(n[i.cc]={start:i.start,prevCC:this.prevCC,new:!0},this.prevCC=i.cc),t&&t.textCodec===ga?this._parseIMSC1(i,s):this._parseVTTs(e)}}else this.hls.trigger(l.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:i,error:new Error("Empty subtitle payload")})}_parseIMSC1(t,e){const i=this.hls;ba(e,this.initPTS[t.cc],(e=>{this._appendCues(e,t.level),i.trigger(l.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:t})}),(e=>{i.logger.log(`Failed to parse IMSC1: ${e}`),i.trigger(l.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:t,error:e})}))}_parseVTTs(t){var e;const{frag:i,payload:n}=t,{initPTS:r,unparsedVttFrags:a}=this,o=r.length-1;if(!r[i.cc]&&-1===o)return void a.push(t);const c=this.hls;!function(t,e,i,n,r,a,o){const l=new da,c=D(new Uint8Array(t)).trim().replace(ha,"\n").split("\n"),u=[],d=e?function(t,e=1){return en(t,9e4,1/e)}(e.baseTime,e.timescale):0;let h,f="00:00.000",p=0,g=0,m=!0;l.oncue=function(t){const s=i[n];let a=i.ccOffset;const o=(p-d)/9e4;if(null!=s&&s.new&&(void 0!==g?a=i.ccOffset=s.start:function(t,e,i){let s=t[e],n=t[s.prevCC];if(!n||!n.new&&s.new)return t.ccOffset=t.presentationOffset=s.start,void(s.new=!1);for(;null!=(r=n)&&r.new;){var r;t.ccOffset+=s.start-n.start,s.new=!1,s=n,n=t[s.prevCC]}t.presentationOffset=i}(i,n,o)),o){if(!e)return void(h=new Error("Missing initPTS for VTT MPEGTS"));a=o-i.presentationOffset}const l=t.endTime-t.startTime,c=cn(9e4*(t.startTime+a-g),9e4*r)/9e4;t.startTime=Math.max(c,0),t.endTime=Math.max(c+l,0);const f=t.text.trim();t.text=decodeURIComponent(encodeURIComponent(f)),t.id||(t.id=pa(t.startTime,t.endTime,f)),t.endTime>0&&u.push(t)},l.onparsingerror=function(t){h=t},l.onflush=function(){h?o(h):a(u)},c.forEach((t=>{if(m){if(fa(t,"X-TIMESTAMP-MAP=")){m=!1,t.slice(16).split(",").forEach((t=>{fa(t,"LOCAL:")?f=t.slice(6):fa(t,"MPEGTS:")&&(p=parseInt(t.slice(7)))}));try{g=function(t){let e=parseInt(t.slice(-3));const i=parseInt(t.slice(-6,-4)),n=parseInt(t.slice(-9,-7)),r=t.length>9?parseInt(t.substring(0,t.indexOf(":"))):0;if(!(s(e)&&s(i)&&s(n)&&s(r)))throw Error(`Malformed X-TIMESTAMP-MAP: Local:${t}`);return e+=1e3*i,e+=6e4*n,e+=36e5*r,e}(f)/1e3}catch(t){h=t}return}""===t&&(m=!1)}l.parse(t+"\n")})),l.flush()}(null!=(e=i.initSegment)&&e.data?mt(i.initSegment.data,new Uint8Array(n)).buffer:n,this.initPTS[i.cc],this.vttCCs,i.cc,i.start,(t=>{this._appendCues(t,i.level),c.trigger(l.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:i})}),(e=>{const s="Missing initPTS for VTT MPEGTS"===e.message;s?a.push(t):this._fallbackToIMSC1(i,n),c.logger.log(`Failed to parse VTT cue: ${e}`),s&&o>i.cc||c.trigger(l.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:i,error:e})}))}_fallbackToIMSC1(t,e){const i=this.tracks[t.level];i.textCodec||ba(e,this.initPTS[t.cc],(()=>{i.textCodec=ga,this._parseIMSC1(t,e)}),(()=>{i.textCodec="wvtt"}))}_appendCues(t,e){const i=this.hls;if(this.config.renderTextTracksNatively){const i=this.textTracks[e];if(!i||"disabled"===i.mode)return;t.forEach((t=>yr(i,t)))}else{const s=this.tracks[e];if(!s)return;const n=s.default?"default":"subtitles"+e;i.trigger(l.CUES_PARSED,{type:"subtitles",cues:t,track:n})}}onFragDecrypted(t,e){const{frag:i}=e;i.type===g&&this.onFragLoaded(l.FRAG_LOADED,e)}onSubtitleTracksCleared(){this.tracks=[],this.captionsTracks={}}onFragParsingUserdata(t,e){if(!this.enabled||!this.config.enableCEA708Captions)return;const{frag:i,samples:s}=e;if(i.type!==f||"NONE"!==this.closedCaptionsForLevel(i))for(let t=0;tbr(t[s],e,i)))}if(this.config.renderTextTracksNatively&&0===e&&void 0!==s){const{textTracks:t}=this;Object.keys(t).forEach((i=>br(t[i],e,s)))}}}extractCea608Data(t){const e=[[],[]],i=31&t[0];let s=2;for(let n=0;n=e){const s=i.start,n=i.end;let r=t.fragments;if(!i.relurl){const{fragmentHint:e}=t;e&&(r=r.concat(e))}return ne(r,(t=>t.cce||t.start>=n?-1:0))}return null}(e,i,t)||e&&le(e.fragments,i)||t}startLoad(t,e){if(!this.levels)return this.startPosition=t,void(this.state=Gi.STOPPED);const i=this.lastCurrentTime;this.stopLoad(),this.setInterval(100),i>0&&-1===t?(this.log(`Override startPosition with lastCurrentTime @${i.toFixed(3)}`),t=i,this.state=Gi.IDLE):this.state=Gi.WAITING_TRACK,this.nextLoadPosition=this.lastCurrentTime=t+this.timelineOffset,this.startPosition=e?-1:t,this.tick()}doTick(){switch(this.state){case Gi.IDLE:this.doTickIdle();break;case Gi.WAITING_TRACK:{const{levels:t,trackId:e}=this,i=null==t?void 0:t[e],s=null==i?void 0:i.details;if(s&&!this.waitForLive(i)){if(this.waitForCdnTuneIn(s))break;this.state=Gi.WAITING_INIT_PTS}break}case Gi.FRAG_LOADING_WAITING_RETRY:{var t;const e=performance.now(),i=this.retryDate;if(!i||e>=i||null!=(t=this.media)&&t.seeking){const{levels:t,trackId:e}=this;this.log("RetryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded((null==t?void 0:t[e])||null),this.state=Gi.IDLE}break}case Gi.WAITING_INIT_PTS:{const t=this.waitingData;if(t){const{frag:e,part:i,cache:s,complete:n}=t,r=this.mainAnchor;if(void 0!==this.initPTS[e.cc]){this.waitingData=null,this.state=Gi.FRAG_LOADING;const t={frag:e,part:i,payload:s.flush().buffer,networkDetails:null};this._handleFragmentLoadProgress(t),n&&super._handleFragmentLoadComplete(t)}else r&&r.cc!==t.frag.cc&&(this.log(`Waiting fragment cc (${e.cc}) cancelled because video is at cc ${r.cc}`),this.nextLoadPosition=this.findSyncFrag(r).start,this.clearWaitingFragment())}else this.state=Gi.IDLE}}this.onTickEnd()}clearWaitingFragment(){const t=this.waitingData;t&&(this.hls.hasEnoughToStart||(this.startFragRequested=!1),this.fragmentTracker.removeFragment(t.frag),this.waitingData=null,this.state!==Gi.STOPPED&&(this.state=Gi.IDLE))}resetLoadingState(){this.clearWaitingFragment(),super.resetLoadingState()}onTickEnd(){const{media:t}=this;null!=t&&t.readyState&&(this.lastCurrentTime=t.currentTime)}doTickIdle(){var t;const{hls:e,levels:i,media:s,trackId:n}=this,r=e.config;if(!this.buffering||!s&&!this.primaryPrefetch&&(this.startFragRequested||!r.startFragPrefetch)||null==i||!i[n])return;const a=i[n],o=a.details;if(!o||this.waitForLive(a)||this.waitForCdnTuneIn(o))return this.state=Gi.WAITING_TRACK,void(this.startFragRequested=!1);const c=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&c&&(this.bufferFlushed=!1,this.afterBufferFlushed(c,V,p));const u=this.getFwdBufferInfo(c,p);if(null===u)return;if(!this.switchingTrack&&this._streamEnded(u,o))return e.trigger(l.BUFFER_EOS,{type:"audio"}),void(this.state=Gi.ENDED);const d=u.len,h=e.maxBufferLength,g=o.fragments,m=g[0].start,y=this.getLoadPosition(),v=this.flushing?y:u.end;if(this.switchingTrack&&s){const t=y;o.PTSKnown&&tm||u.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),s.currentTime=m+.05)}if(d>=h&&!this.switchingTrack&&v_.end){const t=this.fragmentTracker.getFragAtPos(v,f);t&&t.end>_.end&&(_=t,this.mainFragLoading={frag:t,targetBufferTime:null})}if(b.start>_.end)return}this.loadFragment(b,a,v)}onMediaDetaching(t,e){this.bufferFlushed=this.flushing=!1,super.onMediaDetaching(t,e)}onAudioTracksUpdated(t,{audioTracks:e}){this.resetTransmuxer(),this.levels=e.map((t=>new qt(t)))}onAudioTrackSwitching(t,e){const i=!!e.url;this.trackId=e.id;const{fragCurrent:s}=this;s&&(s.abortRequests(),this.removeUnbufferedFrags(s.start)),this.resetLoadingState(),i?(this.switchingTrack=e,this.flushAudioIfNeeded(e),this.state!==Gi.STOPPED&&(this.setInterval(100),this.state=Gi.IDLE,this.tick())):(this.resetTransmuxer(),this.switchingTrack=null,this.bufferedTrack=e,this.clearInterval())}onManifestLoading(){super.onManifestLoading(),this.bufferFlushed=this.flushing=this.audioOnly=!1,this.resetItem(),this.trackId=-1}onLevelLoaded(t,e){this.mainDetails=e.details;const i=this.cachedTrackLoadedData;i&&(this.cachedTrackLoadedData=null,this.onAudioTrackLoaded(l.AUDIO_TRACK_LOADED,i))}onAudioTrackLoaded(t,e){var i;const{levels:s}=this,{details:n,id:r,groupId:a,track:o}=e;if(!s)return void this.warn(`Audio tracks reset while loading track ${r} "${o.name}" of "${a}"`);const c=this.mainDetails;if(!c||n.endCC>c.endCC||c.expired)return this.cachedTrackLoadedData=e,void(this.state!==Gi.STOPPED&&(this.state=Gi.WAITING_TRACK));this.cachedTrackLoadedData=null,this.log(`Audio track ${r} "${o.name}" of "${a}" loaded [${n.startSN},${n.endSN}]${n.lastPartSn?`[part-${n.lastPartSn}-${n.lastPartIndex}]`:""},duration:${n.totalduration}`);const u=s[r];let d=0;if(n.live||null!=(i=u.details)&&i.live){if(this.checkLiveUpdate(n),n.deltaUpdateFailed)return;var h;u.details&&(d=this.alignPlaylists(n,u.details,null==(h=this.levelLastLoaded)?void 0:h.details)),n.alignedSliding||(Bi(n,c),n.alignedSliding||ji(n,c),d=n.fragmentStart)}u.details=n,this.levelLastLoaded=u,this.startFragRequested||this.setStartPosition(c,d),this.hls.trigger(l.AUDIO_TRACK_UPDATED,{details:n,id:r,groupId:e.groupId}),this.state!==Gi.WAITING_TRACK||this.waitForCdnTuneIn(n)||(this.state=Gi.IDLE),this.tick()}_handleFragmentLoadProgress(t){var e;const i=t.frag,{part:s,payload:n}=t,{config:r,trackId:a,levels:o}=this;if(!o)return void this.warn(`Audio tracks were reset while fragment load was in progress. Fragment ${i.sn} of level ${i.level} will not be buffered`);const l=o[a];if(!l)return void this.warn("Audio track is undefined on fragment load progress");const c=l.details;if(!c)return this.warn("Audio track details undefined on fragment load progress"),void this.removeUnbufferedFrags(i.start);const u=r.defaultAudioCodec||l.audioCodec||"mp4a.40.2";let d=this.transmuxer;d||(d=this.transmuxer=new _n(this.hls,p,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));const h=this.initPTS[i.cc],f=null==(e=i.initSegment)?void 0:e.data;if(void 0!==h){const t=!1,e=s?s.index:-1,r=-1!==e,a=new xe(i.level,i.sn,i.stats.chunkCount,n.byteLength,e,r);d.push(n,f,u,"",i,s,c.totalduration,t,a,h)}else{this.log(`Unknown video PTS for cc ${i.cc}, waiting for video PTS before demuxing audio frag ${i.sn} of [${c.startSN} ,${c.endSN}],track ${a}`);const{cache:t}=this.waitingData=this.waitingData||{frag:i,part:s,cache:new Ki,complete:!1};t.push(new Uint8Array(n)),this.state!==Gi.STOPPED&&(this.state=Gi.WAITING_INIT_PTS)}}_handleFragmentLoadComplete(t){this.waitingData?this.waitingData.complete=!0:super._handleFragmentLoadComplete(t)}onBufferReset(){this.mediaBuffer=null}onBufferCreated(t,e){this.bufferFlushed=this.flushing=!1;const i=e.tracks.audio;i&&(this.mediaBuffer=i.buffer||null)}onFragLoading(t,e){!this.audioOnly&&e.frag.type===f&&q(e.frag)&&(this.mainFragLoading=e,this.state===Gi.IDLE&&this.tick())}onFragBuffered(t,e){const{frag:i,part:s}=e;if(i.type===p)if(this.fragContextChanged(i))this.warn(`Fragment ${i.sn}${s?" p: "+s.index:""} of level ${i.level} finished buffering, but was aborted. state: ${this.state}, audioSwitch: ${this.switchingTrack?this.switchingTrack.name:"false"}`);else{if(q(i)){this.fragPrevious=i;const t=this.switchingTrack;t&&(this.bufferedTrack=t,this.switchingTrack=null,this.hls.trigger(l.AUDIO_TRACK_SWITCHED,E({},t)))}this.fragBufferedComplete(i,s),this.media&&this.tick()}else this.audioOnly||i.type!==f||i.elementaryStreams.video||i.elementaryStreams.audiovideo||(this.audioOnly=!0,this.mainFragLoading=null)}onError(t,e){var i;if(e.fatal)this.state=Gi.ERROR;else switch(e.details){case o.FRAG_GAP:case o.FRAG_PARSING_ERROR:case o.FRAG_DECRYPT_ERROR:case o.FRAG_LOAD_ERROR:case o.FRAG_LOAD_TIMEOUT:case o.KEY_LOAD_ERROR:case o.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(p,e);break;case o.AUDIO_TRACK_LOAD_ERROR:case o.AUDIO_TRACK_LOAD_TIMEOUT:case o.LEVEL_PARSING_ERROR:e.levelRetry||this.state!==Gi.WAITING_TRACK||(null==(i=e.context)?void 0:i.type)!==d||(this.state=Gi.IDLE);break;case o.BUFFER_ADD_CODEC_ERROR:case o.BUFFER_APPEND_ERROR:if("audio"!==e.parent)return;this.resetLoadingState();break;case o.BUFFER_FULL_ERROR:if("audio"!==e.parent)return;this.reduceLengthAndFlushBuffer(e)&&(this.bufferedTrack=null,super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio"));break;case o.INTERNAL_EXCEPTION:this.recoverWorkerError(e)}}onBufferFlushing(t,{type:e}){e!==H&&(this.flushing=!0)}onBufferFlushed(t,{type:e}){if(e!==H){this.flushing=!1,this.bufferFlushed=!0,this.state===Gi.ENDED&&(this.state=Gi.IDLE);const t=this.mediaBuffer||this.media;t&&(this.afterBufferFlushed(t,e,p),this.tick())}}_handleTransmuxComplete(t){var e;const i="audio",{hls:s}=this,{remuxResult:n,chunkMeta:r}=t,a=this.getCurrentContext(r);if(!a)return void this.resetWhenMissingContext(r);const{frag:o,part:c,level:u}=a,{details:d}=u,{audio:h,text:f,id3:p,initSegment:g}=n;if(!this.fragContextChanged(o)&&d){if(this.state=Gi.PARSING,this.switchingTrack&&h&&this.completeAudioSwitch(this.switchingTrack),null!=g&&g.tracks){const t=o.initSegment||o;this._bufferInitSegment(u,g.tracks,t,r),s.trigger(l.FRAG_PARSING_INIT_SEGMENT,{frag:t,id:i,tracks:g.tracks})}if(h){const{startPTS:t,endPTS:e,startDTS:i,endDTS:s}=h;c&&(c.elementaryStreams[V]={startPTS:t,endPTS:e,startDTS:i,endDTS:s}),o.setElementaryStreamInfo(V,t,e,i,s),this.bufferFragmentData(h,o,c,r)}if(null!=p&&null!=(e=p.samples)&&e.length){const t=b({id:i,frag:o,details:d},p);s.trigger(l.FRAG_PARSING_METADATA,t)}if(f){const t=b({id:i,frag:o,details:d},f);s.trigger(l.FRAG_PARSING_USERDATA,t)}}else this.fragmentTracker.removeFragment(o)}_bufferInitSegment(t,e,i,s){if(this.state!==Gi.PARSING)return;if(e.video&&delete e.video,e.audiovideo&&delete e.audiovideo,!e.audio)return;const n=e.audio;n.id=p;const r=t.audioCodec;this.log(`Init audio buffer, container:${n.container}, codecs[level/parsed]=[${r}/${n.codec}]`),r&&1===r.split(",").length&&(n.levelCodec=r),this.hls.trigger(l.BUFFER_CODECS,e);const a=n.initSegment;if(null!=a&&a.byteLength){const t={type:"audio",frag:i,part:null,chunkMeta:s,parent:i.type,data:a};this.hls.trigger(l.BUFFER_APPENDING,t)}this.tickImmediate()}loadFragment(t,e,i){const s=this.fragmentTracker.getState(t);var n;if(this.switchingTrack||s===ge||s===ye)if(q(t))if(null!=(n=e.details)&&n.live&&!this.initPTS[t.cc]){this.log(`Waiting for video PTS in continuity counter ${t.cc} of live stream before loading audio fragment ${t.sn} of level ${this.trackId}`),this.state=Gi.WAITING_INIT_PTS;const i=this.mainDetails;i&&i.fragmentStart!==e.details.fragmentStart&&ji(e.details,i)}else super.loadFragment(t,e,i);else this._loadInitSegment(t,e);else this.clearTrackerIfNeeded(t)}flushAudioIfNeeded(t){if(this.media&&this.bufferedTrack){const{name:e,lang:i,assocLang:s,characteristics:n,audioCodec:r,channels:a}=this.bufferedTrack;te({name:e,lang:i,assocLang:s,characteristics:n,audioCodec:r,channels:a},t,ee)||(se(t.url,this.hls)?(this.log("Switching audio track : flushing all audio"),super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio"),this.bufferedTrack=null):this.bufferedTrack=t)}}completeAudioSwitch(t){const{hls:e}=this;this.flushAudioIfNeeded(t),this.bufferedTrack=t,this.switchingTrack=null,e.trigger(l.AUDIO_TRACK_SWITCHED,E({},t))}},audioTrackController:class extends En{constructor(t){super(t,"audio-track-controller"),this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0,this.registerListeners()}registerListeners(){const{hls:t}=this;t.on(l.MANIFEST_LOADING,this.onManifestLoading,this),t.on(l.MANIFEST_PARSED,this.onManifestParsed,this),t.on(l.LEVEL_LOADING,this.onLevelLoading,this),t.on(l.LEVEL_SWITCHING,this.onLevelSwitching,this),t.on(l.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.on(l.ERROR,this.onError,this)}unregisterListeners(){const{hls:t}=this;t.off(l.MANIFEST_LOADING,this.onManifestLoading,this),t.off(l.MANIFEST_PARSED,this.onManifestParsed,this),t.off(l.LEVEL_LOADING,this.onLevelLoading,this),t.off(l.LEVEL_SWITCHING,this.onLevelSwitching,this),t.off(l.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.off(l.ERROR,this.onError,this)}destroy(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,super.destroy()}onManifestLoading(){this.tracks=[],this.tracksInGroup=[],this.groupIds=null,this.currentTrack=null,this.trackId=-1,this.selectDefaultTrack=!0}onManifestParsed(t,e){this.tracks=e.audioTracks||[]}onAudioTrackLoaded(t,e){const{id:i,groupId:s,details:n}=e,r=this.tracksInGroup[i];if(!r||r.groupId!==s)return void this.warn(`Audio track with id:${i} and group:${s} not found in active group ${null==r?void 0:r.groupId}`);const a=r.details;r.details=e.details,this.log(`Audio track ${i} "${r.name}" lang:${r.lang} group:${s} loaded [${n.startSN}-${n.endSN}]`),i===this.trackId&&this.playlistLoaded(i,e,a)}onLevelLoading(t,e){this.switchLevel(e.level)}onLevelSwitching(t,e){this.switchLevel(e.level)}switchLevel(t){const e=this.hls.levels[t];if(!e)return;const i=e.audioGroups||null,s=this.groupIds;let n=this.currentTrack;if(!i||(null==s?void 0:s.length)!==(null==i?void 0:i.length)||null!=i&&i.some((t=>-1===(null==s?void 0:s.indexOf(t))))){this.groupIds=i,this.trackId=-1,this.currentTrack=null;const t=this.tracks.filter((t=>!i||-1!==i.indexOf(t.groupId)));if(t.length)this.selectDefaultTrack&&!t.some((t=>t.default))&&(this.selectDefaultTrack=!1),t.forEach(((t,e)=>{t.id=e}));else if(!n&&!this.tracksInGroup.length)return;this.tracksInGroup=t;const e=this.hls.config.audioPreference;if(!n&&e){const i=Zt(e,t,ee);if(i>-1)n=t[i];else{const t=Zt(e,this.tracks);n=this.tracks[t]}}let s=this.findTrackId(n);-1===s&&n&&(s=this.findTrackId(null));const c={audioTracks:t};this.log(`Updating audio tracks, ${t.length} track(s) found in group(s): ${null==i?void 0:i.join(",")}`),this.hls.trigger(l.AUDIO_TRACKS_UPDATED,c);const u=this.trackId;if(-1!==s&&-1===u)this.setAudioTrack(s);else if(t.length&&-1===u){var r;const e=new Error(`No audio track selected for current audio group-ID(s): ${null==(r=this.groupIds)?void 0:r.join(",")} track count: ${t.length}`);this.warn(e.message),this.hls.trigger(l.ERROR,{type:a.MEDIA_ERROR,details:o.AUDIO_TRACK_LOAD_ERROR,fatal:!0,error:e})}}}onError(t,e){!e.fatal&&e.context&&(e.context.type!==d||e.context.id!==this.trackId||this.groupIds&&-1===this.groupIds.indexOf(e.context.groupId)||this.checkRetry(e))}get allAudioTracks(){return this.tracks}get audioTracks(){return this.tracksInGroup}get audioTrack(){return this.trackId}set audioTrack(t){this.selectDefaultTrack=!1,this.setAudioTrack(t)}setAudioOption(t){const e=this.hls;if(e.config.audioPreference=t,t){const i=this.allAudioTracks;if(this.selectDefaultTrack=!1,i.length){const s=this.currentTrack;if(s&&te(t,s,ee))return s;const n=Zt(t,this.tracksInGroup,ee);if(n>-1){const t=this.tracksInGroup[n];return this.setAudioTrack(n),t}if(s){let s=e.loadLevel;-1===s&&(s=e.firstAutoLevel);const n=function(t,e,i,s,n){const r=e[s],a=e.reduce(((t,e,i)=>{const s=e.uri;return(t[s]||(t[s]=[])).push(i),t}),{})[r.uri];a.length>1&&(s=Math.max.apply(Math,a));const o=r.videoRange,l=r.frameRate,c=r.codecSet.substring(0,4),u=ie(e,s,(e=>{if(e.videoRange!==o||e.frameRate!==l||e.codecSet.substring(0,4)!==c)return!1;const s=e.audioGroups,r=i.filter((t=>!s||-1!==s.indexOf(t.groupId)));return Zt(t,r,n)>-1}));return u>-1?u:ie(e,s,(e=>{const s=e.audioGroups,r=i.filter((t=>!s||-1!==s.indexOf(t.groupId)));return Zt(t,r,n)>-1}))}(t,e.levels,i,s,ee);if(-1===n)return null;e.nextLoadLevel=n}if(t.channels||t.audioCodec){const e=Zt(t,i);if(e>-1)return i[e]}}}return null}setAudioTrack(t){const e=this.tracksInGroup;if(t<0||t>=e.length)return void this.warn(`Invalid audio track id: ${t}`);this.selectDefaultTrack=!1;const i=this.currentTrack,s=e[t],n=s.details&&!s.details.live;if(t===this.trackId&&s===i&&n)return;if(this.log(`Switching to audio-track ${t} "${s.name}" lang:${s.lang} group:${s.groupId} channels:${s.channels}`),this.trackId=t,this.currentTrack=s,this.hls.trigger(l.AUDIO_TRACK_SWITCHING,E({},s)),n)return;const r=this.switchParams(s.url,null==i?void 0:i.details,s.details);this.loadPlaylist(r)}findTrackId(t){const e=this.tracksInGroup;for(let i=0;i{this.initialized&&(this.starved=!0),this.buffering=!0},this.onPlaying=()=>{this.initialized||(this.initialized=!0),this.buffering=!1},this.applyPlaylistData=t=>{try{this.apply(t,{ot:xn,su:!this.initialized})}catch(t){this.hls.logger.warn("Could not generate manifest CMCD data.",t)}},this.applyFragmentData=t=>{try{const{frag:e,part:i}=t,s=this.hls.levels[e.level],n=this.getObjectType(e),r={d:1e3*(i||e).duration,ot:n};n!==On&&n!==Pn&&n!=Nn||(r.br=s.bitrate/1e3,r.tb=this.getTopBandwidth(n)/1e3,r.bl=this.getBufferLength(n));const a=i?this.getNextPart(i):this.getNextFrag(e);null!=a&&a.url&&a.url!==e.url&&(r.nor=a.url),this.apply(t,r)}catch(t){this.hls.logger.warn("Could not generate segment CMCD data.",t)}},this.hls=t;const e=this.config=t.config,{cmcd:i}=e;null!=i&&(e.pLoader=this.createPlaylistLoader(),e.fLoader=this.createFragmentLoader(),this.sid=i.sessionId||t.sessionId,this.cid=i.contentId,this.useHeaders=!0===i.useHeaders,this.includeKeys=i.includeKeys,this.registerListeners())}registerListeners(){const t=this.hls;t.on(l.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(l.MEDIA_DETACHED,this.onMediaDetached,this),t.on(l.BUFFER_CREATED,this.onBufferCreated,this)}unregisterListeners(){const t=this.hls;t.off(l.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(l.MEDIA_DETACHED,this.onMediaDetached,this),t.off(l.BUFFER_CREATED,this.onBufferCreated,this)}destroy(){this.unregisterListeners(),this.onMediaDetached(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null,this.onWaiting=this.onPlaying=this.media=null}onMediaAttached(t,e){this.media=e.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(t,e){var i,s;this.audioBuffer=null==(i=e.tracks.audio)?void 0:i.buffer,this.videoBuffer=null==(s=e.tracks.video)?void 0:s.buffer}createData(){var t;return{v:1,sf:$n,sid:this.sid,cid:this.cid,pr:null==(t=this.media)?void 0:t.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}}apply(t,e={}){b(e,this.createData());const i=e.ot===Mn||e.ot===On||e.ot===Nn;this.starved&&i&&(e.bs=!0,e.su=!0,this.starved=!1),null==e.su&&(e.su=this.buffering);const{includeKeys:s}=this;s&&(e=Object.keys(e).reduce(((t,i)=>(s.includes(i)&&(t[i]=e[i]),t)),{}));const n={baseUrl:t.url};this.useHeaders?(t.headers||(t.headers={}),function(t,e,i){b(t,function(t,e={}){const i={};if(!t)return i;const s=Object.entries(t),n=Object.entries(Bn).concat(Object.entries((null==e?void 0:e.customHeaderMap)||{})),r=s.reduce(((t,e)=>{var i,s;const[r,a]=e,o=(null===(i=n.find((t=>t[1].includes(r))))||void 0===i?void 0:i[0])||Un;return null!==(s=t[o])&&void 0!==s||(t[o]={}),t[o][r]=a,t}),{});return Object.entries(r).reduce(((t,[i,s])=>(t[i]=ur(s,e),t)),i)}(e,i))}(t.headers,e,n)):t.url=function(t,e,i){const s=function(t,e={}){if(!t)return"";const i=ur(t,e);return`CMCD=${encodeURIComponent(i)}`}(e,i);if(!s)return t;if(dr.test(t))return t.replace(dr,s);const n=t.includes("?")?"&":"?";return`${t}${n}${s}`}(t.url,e,n)}getNextFrag(t){var e;const i=null==(e=this.hls.levels[t.level])?void 0:e.details;if(i){const e=t.sn-i.startSN;return i.fragments[e+1]}}getNextPart(t){var e,i;const{index:s,fragment:n}=t,r=null==(e=this.hls.levels[n.level])||null==(i=e.details)?void 0:i.partList;if(r){const{sn:t}=n;for(let e=r.length-1;e>=0;e--){const i=r[e];if(i.index===s&&i.fragment.sn===t)return r[e+1]}}}getObjectType(t){const{type:e}=t;return"subtitle"===e?Fn:"initSegment"===t.sn?Mn:"audio"===e?Pn:"main"===e?this.hls.audioTracks.length?On:Nn:void 0}getTopBandwidth(t){let e,i=0;const s=this.hls;if(t===Pn)e=s.audioTracks;else{const t=s.maxAutoLevel,i=t>-1?t+1:s.levels.length;e=s.levels.slice(0,i)}for(const t of e)t.bitrate>i&&(i=t.bitrate);return i>0?i:NaN}getBufferLength(t){const e=this.media,i=t===Pn?this.audioBuffer:this.videoBuffer;return i&&e?1e3*Oe.bufferInfo(i,e.currentTime,this.config.maxBufferHole).len:NaN}createPlaylistLoader(){const{pLoader:t}=this.config,e=this.applyPlaylistData,i=t||this.config.loader;return class{constructor(t){this.loader=void 0,this.loader=new i(t)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(t,i,s){e(t),this.loader.load(t,i,s)}}}createFragmentLoader(){const{fLoader:t}=this.config,e=this.applyFragmentData,i=t||this.config.loader;return class{constructor(t){this.loader=void 0,this.loader=new i(t)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(t,i,s){e(t),this.loader.load(t,i,s)}}}},contentSteeringController:class extends T{constructor(t){super("content-steering",t.logger),this.hls=void 0,this.loader=null,this.uri=null,this.pathwayId=".",this._pathwayPriority=null,this.timeToLoad=300,this.reloadTimer=-1,this.updated=0,this.started=!1,this.enabled=!0,this.levels=null,this.audioTracks=null,this.subtitleTracks=null,this.penalizedPathways={},this.hls=t,this.registerListeners()}registerListeners(){const t=this.hls;t.on(l.MANIFEST_LOADING,this.onManifestLoading,this),t.on(l.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(l.MANIFEST_PARSED,this.onManifestParsed,this),t.on(l.ERROR,this.onError,this)}unregisterListeners(){const t=this.hls;t&&(t.off(l.MANIFEST_LOADING,this.onManifestLoading,this),t.off(l.MANIFEST_LOADED,this.onManifestLoaded,this),t.off(l.MANIFEST_PARSED,this.onManifestParsed,this),t.off(l.ERROR,this.onError,this))}pathways(){return(this.levels||[]).reduce(((t,e)=>(-1===t.indexOf(e.pathwayId)&&t.push(e.pathwayId),t)),[])}get pathwayPriority(){return this._pathwayPriority}set pathwayPriority(t){this.updatePathwayPriority(t)}startLoad(){if(this.started=!0,this.clearTimeout(),this.enabled&&this.uri){if(this.updated){const t=1e3*this.timeToLoad-(performance.now()-this.updated);if(t>0)return void this.scheduleRefresh(this.uri,t)}this.loadSteeringManifest(this.uri)}}stopLoad(){this.started=!1,this.loader&&(this.loader.destroy(),this.loader=null),this.clearTimeout()}clearTimeout(){-1!==this.reloadTimer&&(self.clearTimeout(this.reloadTimer),this.reloadTimer=-1)}destroy(){this.unregisterListeners(),this.stopLoad(),this.hls=null,this.levels=this.audioTracks=this.subtitleTracks=null}removeLevel(t){const e=this.levels;e&&(this.levels=e.filter((e=>e!==t)))}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(t,e){const{contentSteering:i}=e;null!==i&&(this.pathwayId=i.pathwayId,this.uri=i.uri,this.started&&this.startLoad())}onManifestParsed(t,e){this.audioTracks=e.audioTracks,this.subtitleTracks=e.subtitleTracks}onError(t,e){const{errorAction:i}=e;if(2===(null==i?void 0:i.action)&&1===i.flags){const t=this.levels;let s=this._pathwayPriority,n=this.pathwayId;if(e.context){const{groupId:i,pathwayId:s,type:r}=e.context;i&&t?n=this.getPathwayForGroupId(i,r,n):s&&(n=s)}n in this.penalizedPathways||(this.penalizedPathways[n]=performance.now()),!s&&t&&(s=this.pathways()),s&&s.length>1&&(this.updatePathwayPriority(s),i.resolved=this.pathwayId!==n),i.resolved||this.warn(`Could not resolve ${e.details} ("${e.error.message}") with content-steering for Pathway: ${n} levels: ${t?t.length:t} priorities: ${Wt(s)} penalized: ${Wt(this.penalizedPathways)}`)}}filterParsedLevels(t){this.levels=t;let e=this.getLevelsForPathway(this.pathwayId);if(0===e.length){const i=t[0].pathwayId;this.log(`No levels found in Pathway ${this.pathwayId}. Setting initial Pathway to "${i}"`),e=this.getLevelsForPathway(i),this.pathwayId=i}return e.length!==t.length&&this.log(`Found ${e.length}/${t.length} levels in Pathway "${this.pathwayId}"`),e}getLevelsForPathway(t){return null===this.levels?[]:this.levels.filter((e=>t===e.pathwayId))}updatePathwayPriority(t){let e;this._pathwayPriority=t;const i=this.penalizedPathways,s=performance.now();Object.keys(i).forEach((t=>{s-i[t]>3e5&&delete i[t]}));for(let s=0;s0){this.log(`Setting Pathway to "${n}"`),this.pathwayId=n,Mi(e),this.hls.trigger(l.LEVELS_UPDATED,{levels:e});const t=this.hls.levels[r];a&&t&&this.levels&&(t.attrs["STABLE-VARIANT-ID"]!==a.attrs["STABLE-VARIANT-ID"]&&t.bitrate!==a.bitrate&&this.log(`Unstable Pathways change from bitrate ${a.bitrate} to ${t.bitrate}`),this.hls.nextLoadLevel=r);break}}}getPathwayForGroupId(t,e,i){const s=this.getLevelsForPathway(i).concat(this.levels||[]);for(let i=0;i{const{ID:n,"BASE-ID":r,"URI-REPLACEMENT":a}=t;if(e.some((t=>t.pathwayId===n)))return;const o=this.getLevelsForPathway(r).map((t=>{const e=new Ge(t.attrs);e["PATHWAY-ID"]=n;const r=e.AUDIO&&`${e.AUDIO}_clone_${n}`,o=e.SUBTITLES&&`${e.SUBTITLES}_clone_${n}`;r&&(i[e.AUDIO]=r,e.AUDIO=r),o&&(s[e.SUBTITLES]=o,e.SUBTITLES=o);const l=fr(t.uri,e["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",a),c=new qt({attrs:e,audioCodec:t.audioCodec,bitrate:t.bitrate,height:t.height,name:t.name,url:l,videoCodec:t.videoCodec,width:t.width});if(t.audioGroups)for(let e=1;e{this.log(`Loaded steering manifest: "${s}"`);const r=t.data;if(1!==(null==r?void 0:r.VERSION))return void this.log(`Steering VERSION ${r.VERSION} not supported!`);this.updated=performance.now(),this.timeToLoad=r.TTL;const{"RELOAD-URI":a,"PATHWAY-CLONES":o,"PATHWAY-PRIORITY":c}=r;if(a)try{this.uri=new self.URL(a,s).href}catch(t){return this.enabled=!1,void this.log(`Failed to parse Steering Manifest RELOAD-URI: ${a}`)}this.scheduleRefresh(this.uri||i.url),o&&this.clonePathways(o);const u={steeringManifest:r,url:s.toString()};this.hls.trigger(l.STEERING_MANIFEST_LOADED,u),c&&this.updatePathwayPriority(c)},onError:(t,e,i,s)=>{if(this.log(`Error loading steering manifest: ${t.code} ${t.text} (${e.url})`),this.stopLoad(),410===t.code)return this.enabled=!1,void this.log(`Steering manifest ${e.url} no longer available`);let n=1e3*this.timeToLoad;if(429!==t.code)this.scheduleRefresh(this.uri||e.url,n);else{const t=this.loader;if("function"==typeof(null==t?void 0:t.getResponseHeader)){const e=t.getResponseHeader("Retry-After");e&&(n=1e3*parseFloat(e))}this.log(`Steering manifest ${e.url} rate limited`)}},onTimeout:(t,e,i)=>{this.log(`Timeout loading steering manifest (${e.url})`),this.scheduleRefresh(this.uri||e.url)}};this.log(`Requesting steering manifest: ${s}`),this.loader.load(n,o,c)}scheduleRefresh(t,e=1e3*this.timeToLoad){this.clearTimeout(),this.reloadTimer=self.setTimeout((()=>{var e;const i=null==(e=this.hls)?void 0:e.media;!i||i.ended?this.scheduleRefresh(t,1e3*this.timeToLoad):this.loadSteeringManifest(t)}),e)}},interstitialsController:class extends T{constructor(t,e){super("interstitials",t.logger),this.HlsPlayerClass=void 0,this.hls=void 0,this.assetListLoader=void 0,this.mediaSelection=null,this.altSelection=null,this.media=null,this.detachedData=null,this.requiredTracks=null,this.manager=null,this.playerQueue=[],this.bufferedPos=-1,this.timelinePos=-1,this.schedule=void 0,this.playingItem=null,this.bufferingItem=null,this.waitingItem=null,this.endedItem=null,this.playingAsset=null,this.endedAsset=null,this.bufferingAsset=null,this.shouldPlay=!1,this.onPlay=()=>{this.shouldPlay=!0},this.onPause=()=>{this.shouldPlay=!1},this.onSeeking=()=>{const t=this.currentTime;if(void 0===t||this.playbackDisabled)return;const e=t-this.timelinePos;if(Math.abs(e)<1/7056e5)return;const i=e<=-.01;this.timelinePos=t,this.bufferedPos=t;const s=this.playingItem;if(!s)return void this.checkBuffer();if(i&&this.schedule.resetErrorsInRange(t,t-e)&&this.updateSchedule(),this.checkBuffer(),i&&t=s.end){var n;const t=this.schedule.findItemIndexAtTime(this.timelinePos);if(!this.isInterstitial(s)&&null!=(n=this.media)&&n.paused&&(this.shouldPlay=!1),!i){const e=this.findItemIndex(s);if(t>e){const i=this.schedule.findJumpRestrictedIndex(e+1,t);if(i>e)return void this.setSchedulePosition(i)}}return void this.setSchedulePosition(t)}const r=this.playingAsset;if(!r){if(this.playingLastItem&&this.isInterstitial(s)){const e=s.event.assetList[0];e&&(this.endedItem=this.playingItem,this.playingItem=null,this.setScheduleToAssetAtTime(t,e))}return}const a=r.timelineStart,o=r.duration||0;(i&&t=a+o)&&this.setScheduleToAssetAtTime(t,r)},this.onTimeupdate=()=>{const t=this.currentTime;if(void 0===t||this.playbackDisabled)return;if(!(t>this.timelinePos))return;this.timelinePos=t,t>this.bufferedPos&&this.checkBuffer();const e=this.playingItem;if(!e||this.playingLastItem)return;if(t>=e.end){this.timelinePos=e.end;const t=this.findItemIndex(e);this.setSchedulePosition(t+1)}const i=this.playingAsset;i&&t>=i.timelineStart+(i.duration||0)&&this.setScheduleToAssetAtTime(t,i)},this.onScheduleUpdate=(t,e)=>{const i=this.schedule,s=this.playingItem,n=i.events||[],r=i.items||[],a=i.durations,o=t.map((t=>t.identifier)),c=!(!n.length&&!o.length);if(c&&this.log(`INTERSTITIALS_UPDATED (${n.length}): ${n}\nSchedule: ${r.map((t=>Dr(t)))}`),o.length&&this.log(`Removed events ${o}`),this.playerQueue.forEach((t=>{if(t.interstitial.appendInPlace){const e=t.assetItem.timelineStart,i=t.timelineOffset-e;if(i)try{t.timelineOffset=e}catch(s){Math.abs(i)>Tr&&this.warn(`${s} ("${t.assetId}" ${t.timelineOffset}->${e})`)}}})),s){const t=this.updateItem(s,this.timelinePos);this.itemsMatch(s,t)&&(this.playingItem=t,this.waitingItem=this.endedItem=null)}else this.waitingItem=this.updateItem(this.waitingItem),this.endedItem=this.updateItem(this.endedItem);const u=this.bufferingItem;if(u){const t=this.updateItem(u,this.bufferedPos);this.itemsMatch(u,t)?this.bufferingItem=t:u.event&&(this.bufferingItem=this.playingItem,this.clearInterstitial(u.event,null))}if(t.forEach((t=>{t.assetList.forEach((t=>{this.clearAssetPlayer(t.identifier,null)}))})),c||e){if(this.hls.trigger(l.INTERSTITIALS_UPDATED,{events:n.slice(0),schedule:r.slice(0),durations:a,removedIds:o}),this.isInterstitial(s)&&o.includes(s.event.identifier))return this.warn(`Interstitial "${s.event.identifier}" removed while playing`),void this.primaryFallback(s.event);this.checkBuffer()}},this.hls=t,this.HlsPlayerClass=e,this.assetListLoader=new xr(t),this.schedule=new Cr(this.onScheduleUpdate,t.logger),this.registerListeners()}registerListeners(){const t=this.hls;t.on(l.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(l.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(l.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(l.MANIFEST_LOADING,this.onManifestLoading,this),t.on(l.LEVEL_UPDATED,this.onLevelUpdated,this),t.on(l.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.on(l.AUDIO_TRACK_UPDATED,this.onAudioTrackUpdated,this),t.on(l.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),t.on(l.SUBTITLE_TRACK_UPDATED,this.onSubtitleTrackUpdated,this),t.on(l.EVENT_CUE_ENTER,this.onInterstitialCueEnter,this),t.on(l.ASSET_LIST_LOADED,this.onAssetListLoaded,this),t.on(l.BUFFER_APPENDED,this.onBufferAppended,this),t.on(l.BUFFER_FLUSHED,this.onBufferFlushed,this),t.on(l.BUFFERED_TO_END,this.onBufferedToEnd,this),t.on(l.MEDIA_ENDED,this.onMediaEnded,this),t.on(l.ERROR,this.onError,this),t.on(l.DESTROYING,this.onDestroying,this)}unregisterListeners(){const t=this.hls;t&&(t.off(l.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(l.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(l.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(l.MANIFEST_LOADING,this.onManifestLoading,this),t.off(l.LEVEL_UPDATED,this.onLevelUpdated,this),t.off(l.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.off(l.AUDIO_TRACK_UPDATED,this.onAudioTrackUpdated,this),t.off(l.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),t.off(l.SUBTITLE_TRACK_UPDATED,this.onSubtitleTrackUpdated,this),t.off(l.EVENT_CUE_ENTER,this.onInterstitialCueEnter,this),t.off(l.ASSET_LIST_LOADED,this.onAssetListLoaded,this),t.off(l.BUFFER_CODECS,this.onBufferCodecs,this),t.off(l.BUFFER_APPENDED,this.onBufferAppended,this),t.off(l.BUFFER_FLUSHED,this.onBufferFlushed,this),t.off(l.BUFFERED_TO_END,this.onBufferedToEnd,this),t.off(l.MEDIA_ENDED,this.onMediaEnded,this),t.off(l.ERROR,this.onError,this),t.off(l.DESTROYING,this.onDestroying,this))}startLoad(){this.resumeBuffering()}stopLoad(){this.pauseBuffering()}resumeBuffering(){var t;null==(t=this.getBufferingPlayer())||t.resumeBuffering()}pauseBuffering(){var t;null==(t=this.getBufferingPlayer())||t.pauseBuffering()}destroy(){this.unregisterListeners(),this.stopLoad(),this.assetListLoader&&this.assetListLoader.destroy(),this.emptyPlayerQueue(),this.clearScheduleState(),this.schedule&&this.schedule.destroy(),this.media=this.detachedData=this.mediaSelection=this.requiredTracks=this.altSelection=this.manager=null,this.hls=this.HlsPlayerClass=this.schedule=this.log=null,this.assetListLoader=null,this.onPlay=this.onPause=this.onSeeking=this.onTimeupdate=null,this.onScheduleUpdate=null}onDestroying(){const t=this.primaryMedia||this.media;t&&this.removeMediaListeners(t)}removeMediaListeners(t){Or(t,"play",this.onPlay),Or(t,"pause",this.onPause),Or(t,"seeking",this.onSeeking),Or(t,"timeupdate",this.onTimeupdate)}onMediaAttaching(t,e){const i=this.media=e.media;Pr(i,"seeking",this.onSeeking),Pr(i,"timeupdate",this.onTimeupdate),Pr(i,"play",this.onPlay),Pr(i,"pause",this.onPause)}onMediaAttached(t,e){const i=this.effectivePlayingItem,s=this.detachedData;if(this.detachedData=null,null===i)this.checkStart();else if(!s){this.clearScheduleState();const t=this.findItemIndex(i);this.setSchedulePosition(t)}}clearScheduleState(){this.playingItem=this.bufferingItem=this.waitingItem=this.endedItem=this.playingAsset=this.endedAsset=this.bufferingAsset=null}onMediaDetaching(t,e){const i=!!e.transferMedia,s=this.media;if(this.media=null,!i&&(s&&this.removeMediaListeners(s),this.detachedData)){const t=this.getBufferingPlayer();t&&(this.playingAsset=this.endedAsset=this.bufferingAsset=this.bufferingItem=this.waitingItem=this.detachedData=null,t.detachMedia()),this.shouldPlay=!1}}get interstitialsManager(){if(!this.manager){if(!this.hls)return null;const t=this,e=()=>t.bufferingItem||t.waitingItem,i=e=>e?t.getAssetPlayer(e.identifier):e,s=(e,s,n,a,o)=>{if(e){let l=e[s].start;const c=e.event;if(c){if("playout"===s||c.timelineOccupancy!==Sr.Point){const t=i(n);(null==t?void 0:t.interstitial)===c&&(l+=t.assetItem.startOffset+t[o])}}else l+=("bufferedPos"===a?r():t[a])-e.start;return l}return 0},n=(e,i)=>{if(0!==e&&"primary"!==i&&t.schedule.length){var s;const n=t.schedule.findItemIndexAtTime(e),r=null==(s=t.schedule.items)?void 0:s[n];if(r)return e+(r[i].start-r.start)}return e},r=()=>{const e=t.bufferedPos;return e===Number.MAX_VALUE?a("primary"):Math.max(e,0)},a=e=>{var i;return null!=(i=t.primaryDetails)&&i.live?t.primaryDetails.edge:t.schedule.durations[e]},o=(e,n)=>{var r,a;const o=t.effectivePlayingItem;if(null!=o&&null!=(r=o.event)&&r.restrictions.skip)return;t.log(`seek to ${e} "${n}"`);const l=t.effectivePlayingItem,c=t.schedule.findItemIndexAtTime(e,n),u=null==(a=t.schedule.items)?void 0:a[c],d=t.getBufferingPlayer(),h=null==d?void 0:d.interstitial,f=null==h?void 0:h.appendInPlace,p=l&&t.itemsMatch(l,u);if(l&&(f||p)){const r=i(t.playingAsset),a=(null==r?void 0:r.media)||t.primaryMedia;if(a){const i="primary"===n?a.currentTime:s(l,n,t.playingAsset,"timelinePos","currentTime"),o=e-i,c=(f?i:a.currentTime)+o;if(c>=0&&(!r||f||c<=r.duration))return void(a.currentTime=c)}}if(u){let i=e;if("primary"!==n){const t=e-u[n].start;i=u.start+t}const s=!t.isInterstitial(u);if(t.isInterstitial(l)&&!l.event.appendInPlace||!s&&!u.event.appendInPlace){if(l){const r=t.findItemIndex(l);if(c>r){const e=t.schedule.findJumpRestrictedIndex(r+1,c);if(e>r)return void t.setSchedulePosition(e)}let a=0;if(s)t.timelinePos=i,t.checkBuffer();else{var g;const t=null==u||null==(g=u.event)?void 0:g.assetList;if(t){const i=e-(u[n]||u).start;for(let e=t.length;e--;){const s=t[e];if(s.duration&&i>=s.startOffset&&i{const i=t.effectivePlayingItem;if(t.isInterstitial(i))return i;const s=e();return t.isInterstitial(s)?s:null},c={get currentTime(){const e=l(),i=t.effectivePlayingItem;return i&&i===e?s(i,"playout",t.effectivePlayingAsset,"timelinePos","currentTime")-i.playout.start:0},set currentTime(e){const i=l(),s=t.effectivePlayingItem;s&&s===i&&o(e+s.playout.start,"playout")},get duration(){const t=l();return t?t.playout.end-t.playout.start:0},get assetPlayers(){var e;const i=null==(e=l())?void 0:e.event.assetList;return i?i.map((e=>t.getAssetPlayer(e.identifier))):[]},get playingIndex(){var e;const i=null==(e=l())?void 0:e.event;return i&&t.effectivePlayingAsset?i.findAssetIndex(t.effectivePlayingAsset):-1},get scheduleItem(){return l()}};this.manager={get events(){var e,i;return(null==(e=t.schedule)||null==(i=e.events)?void 0:i.slice(0))||[]},get schedule(){var e,i;return(null==(e=t.schedule)||null==(i=e.items)?void 0:i.slice(0))||[]},get interstitialPlayer(){return l()?c:null},get playerQueue(){return t.playerQueue.slice(0)},get bufferingAsset(){return t.bufferingAsset},get bufferingItem(){return e()},get bufferingIndex(){const i=e();return t.findItemIndex(i)},get playingAsset(){return t.effectivePlayingAsset},get playingItem(){return t.effectivePlayingItem},get playingIndex(){const e=t.effectivePlayingItem;return t.findItemIndex(e)},primary:{get bufferedEnd(){return r()},get currentTime(){const e=t.timelinePos;return e>0?e:0},set currentTime(t){o(t,"primary")},get duration(){return a("primary")},get seekableStart(){var e;return(null==(e=t.primaryDetails)?void 0:e.fragmentStart)||0}},integrated:{get bufferedEnd(){return s(e(),"integrated",t.bufferingAsset,"bufferedPos","bufferedEnd")},get currentTime(){return s(t.effectivePlayingItem,"integrated",t.effectivePlayingAsset,"timelinePos","currentTime")},set currentTime(t){o(t,"integrated")},get duration(){return a("integrated")},get seekableStart(){var e;return n((null==(e=t.primaryDetails)?void 0:e.fragmentStart)||0,"integrated")}},skip:()=>{const e=t.effectivePlayingItem,i=null==e?void 0:e.event;if(i&&!i.restrictions.skip){const s=t.findItemIndex(e);if(i.appendInPlace){const t=e.playout.start+e.event.duration;o(t+.001,"playout")}else t.advanceAfterAssetEnded(i,s,1/0)}}}}return this.manager}get effectivePlayingItem(){return this.waitingItem||this.playingItem||this.endedItem}get effectivePlayingAsset(){return this.playingAsset||this.endedAsset}get playingLastItem(){var t;const e=this.playingItem,i=null==(t=this.schedule)?void 0:t.items;return!!(this.playbackStarted&&e&&i)&&this.findItemIndex(e)===i.length-1}get playbackStarted(){return null!==this.effectivePlayingItem}get currentTime(){var t,e,i;if(null===this.mediaSelection)return;const n=this.waitingItem||this.playingItem;if(this.isInterstitial(n)&&!n.event.appendInPlace)return;let r=this.media;!r&&null!=(t=this.bufferingItem)&&null!=(e=t.event)&&e.appendInPlace&&(r=this.primaryMedia);const a=null==(i=r)?void 0:i.currentTime;return void 0!==a&&s(a)?a:void 0}get primaryMedia(){var t;return this.media||(null==(t=this.detachedData)?void 0:t.media)||null}isInterstitial(t){return!(null==t||!t.event)}retreiveMediaSource(t,e){const i=this.getAssetPlayer(t);i&&this.transferMediaFromPlayer(i,e)}transferMediaFromPlayer(t,e){const i=t.interstitial.appendInPlace,s=t.media;if(i&&s===this.primaryMedia){if(this.bufferingAsset=null,(!e||this.isInterstitial(e)&&!e.event.appendInPlace)&&e&&s)return void(this.detachedData={media:s});const i=t.transferMedia();this.log(`transfer MediaSource from ${t} ${Wt(i)}`),this.detachedData=i}else e&&s&&(this.shouldPlay||(this.shouldPlay=!s.paused))}transferMediaTo(t,e){var i,s;if(t.media===e)return;let n=null;const r=this.hls,a=t!==r,o=a&&t.interstitial.appendInPlace,l=null==(i=this.detachedData)?void 0:i.mediaSource;let c;if(r.media)o&&(n=r.transferMedia(),this.detachedData=n),c="Primary";else if(l){const t=this.getBufferingPlayer();t?(n=t.transferMedia(),c=`${t}`):c="detached MediaSource"}else c="detached media";if(!n)if(l)n=this.detachedData,this.log(`using detachedData: MediaSource ${Wt(n)}`);else if(!this.detachedData||r.media===e){const t=this.playerQueue;t.length>1&&t.forEach((t=>{if(a&&t.interstitial.appendInPlace!==o){const e=t.interstitial;this.clearInterstitial(t.interstitial,null),e.appendInPlace=!1,e.appendInPlace&&this.warn(`Could not change append strategy for queued assets ${e}`)}})),this.hls.detachMedia(),this.detachedData={media:e}}const u=n&&"mediaSource"in n&&"closed"!==(null==(s=n.mediaSource)?void 0:s.readyState),d=u&&n?n:e;if(this.log(`${u?"transfering MediaSource":"attaching media"} to ${a?t:"Primary"} from ${c}`),d===n){const e=a&&t.assetId===this.schedule.assetIdAtEnd;d.overrides={duration:this.schedule.duration,endOfStream:!a||e,cueRemoval:!a}}t.attachMedia(d)}onInterstitialCueEnter(){this.onTimeupdate()}checkStart(){const t=this.schedule,e=t.events;if(!e||this.playbackDisabled||!this.media)return;-1===this.bufferedPos&&(this.bufferedPos=0);const i=this.timelinePos,s=this.effectivePlayingItem;if(-1===i){const i=this.hls.startPosition;if(this.timelinePos=i,e.length&&e[0].cue.pre){const i=t.findEventIndex(e[0].identifier);this.setSchedulePosition(i)}else if(i>=0||!this.primaryLive){const e=this.timelinePos=i>0?i:0,s=t.findItemIndexAtTime(e);this.setSchedulePosition(s)}}else if(s&&!this.playingItem){const e=t.findItemIndex(s);this.setSchedulePosition(e)}}advanceAfterAssetEnded(t,e,i){const s=i+1;if(t.isAssetPastPlayoutLimit(s)||t.assetList[s].error){const i=this.schedule.items;if(i){const s=e+1;if(s>=i.length)return void this.setSchedulePosition(-1);const n=t.resumeTime;this.timelinePos=0?i[t]:null,n=this.playingItem,r=this.playingLastItem;if(this.isInterstitial(n)){var a;const c=n.event,u=this.playingAsset,d=null==u?void 0:u.identifier,h=d?this.getAssetPlayer(d):null;if(h&&d&&(!this.eventItemsMatch(n,s)||void 0!==e&&d!==(null==(a=c.assetList)?void 0:a[e].identifier))){var o;const e=c.findAssetIndex(u);this.log(`INTERSTITIAL_ASSET_ENDED ${e+1}/${c.assetList.length} ${Lr(u)}`),this.endedAsset=u,this.playingAsset=null,this.hls.trigger(l.INTERSTITIAL_ASSET_ENDED,{asset:u,assetListIndex:e,event:c,schedule:i.slice(0),scheduleIndex:t,player:h}),this.retreiveMediaSource(d,s),!h.media||null!=(o=this.detachedData)&&o.mediaSource||h.detachMedia()}if(!this.eventItemsMatch(n,s)&&(this.endedItem=n,this.playingItem=null,this.log(`INTERSTITIAL_ENDED ${c} ${Dr(n)}`),c.hasPlayed=!0,this.hls.trigger(l.INTERSTITIAL_ENDED,{event:c,schedule:i.slice(0),scheduleIndex:t}),c.cue.once)){this.updateSchedule();const t=this.schedule.items;if(s&&t){const i=this.schedule.findItemIndex(s);this.advanceSchedule(i,t,e,n,r)}return}}this.advanceSchedule(t,i,e,n,r)}advanceSchedule(t,e,i,s,n){const r=t>=0?e[t]:null,a=this.primaryMedia,o=this.playerQueue;if(o.length&&o.forEach((e=>{const i=e.interstitial,s=this.schedule.findEventIndex(i.identifier);(st+1)&&this.clearInterstitial(i,r)})),this.isInterstitial(r)){this.timelinePos=Math.min(Math.max(this.timelinePos,r.start),r.end);const n=r.event;void 0===i&&(i=this.schedule.findAssetIndex(n,this.timelinePos));const o=this.waitingItem;this.assetsBuffered(r,a)||this.setBufferingItem(r);let c=this.preloadAssets(n,i);if(this.eventItemsMatch(r,o||s)||(this.waitingItem=r,this.log(`INTERSTITIAL_STARTED ${Dr(r)} ${n.appendInPlace?"append in place":""}`),this.hls.trigger(l.INTERSTITIAL_STARTED,{event:n,schedule:e.slice(0),scheduleIndex:t})),!n.assetListLoaded)return void this.log(`Waiting for ASSET-LIST to complete loading ${n}`);if(n.assetListLoader&&(n.assetListLoader.destroy(),n.assetListLoader=void 0),!a)return void this.log(`Waiting for attachMedia to start Interstitial ${n}`);this.waitingItem=this.endedItem=null,this.playingItem=r;const u=n.assetList[i];if(!u){const s=e[t+1],r=this.media;return s&&r&&!this.isInterstitial(s)&&r.currentTime=t.end)&&(i=this.getPrimaryResumption(t,e),this.timelinePos=i),this.attachPrimary(i,t)}if(!i)return;const n=this.schedule.items;n&&(this.log(`resumed ${Dr(t)}`),this.hls.trigger(l.INTERSTITIALS_PRIMARY_RESUMED,{schedule:n.slice(0),scheduleIndex:e}),this.checkBuffer())}getPrimaryResumption(t,e){const i=t.start;if(this.primaryLive){const t=this.primaryDetails;if(0===e)return this.hls.startPosition;if(t&&(it.edge))return this.hls.liveSyncPosition||-1}return i}isAssetBuffered(t){const e=this.getAssetPlayer(t.identifier);return null!=e&&e.hls?e.hls.bufferedToEnd:Oe.bufferInfo(this.primaryMedia,this.timelinePos,0).end+1>=t.timelineStart+(t.duration||0)}attachPrimary(t,e,i){e?this.setBufferingItem(e):this.bufferingItem=this.playingItem,this.bufferingAsset=null;const s=this.primaryMedia;if(!s)return;const n=this.hls;n.media?this.checkBuffer():(this.transferMediaTo(n,s),i&&this.startLoadingPrimaryAt(t,i)),i||(this.timelinePos=t,this.startLoadingPrimaryAt(t,i))}startLoadingPrimaryAt(t,e){var i;const s=this.hls;!s.loadingEnabled||!s.media||Math.abs(((null==(i=s.mainForwardBufferInfo)?void 0:i.start)||s.media.currentTime)-t)>.5?s.startLoad(t,e):s.bufferingEnabled||s.resumeBuffering()}onManifestLoading(){this.stopLoad(),this.schedule.reset(),this.emptyPlayerQueue(),this.clearScheduleState(),this.shouldPlay=!1,this.bufferedPos=this.timelinePos=-1,this.mediaSelection=this.altSelection=this.manager=this.requiredTracks=null,this.hls.off(l.BUFFER_CODECS,this.onBufferCodecs,this),this.hls.on(l.BUFFER_CODECS,this.onBufferCodecs,this)}onLevelUpdated(t,e){if(-1===e.level)return;const i=this.hls.levels[e.level],s=E(E({},this.mediaSelection||this.altSelection),{},{main:i});this.mediaSelection=s,this.schedule.parseInterstitialDateRanges(s,this.hls.config.interstitialAppendInPlace),!this.effectivePlayingItem&&this.schedule.items&&this.checkStart()}onAudioTrackUpdated(t,e){const i=this.hls.audioTracks[e.id],s=this.mediaSelection;if(!s)return void(this.altSelection=E(E({},this.altSelection),{},{audio:i}));const n=E(E({},s),{},{audio:i});this.mediaSelection=n}onSubtitleTrackUpdated(t,e){const i=this.hls.subtitleTracks[e.id],s=this.mediaSelection;if(!s)return void(this.altSelection=E(E({},this.altSelection),{},{subtitles:i}));const n=E(E({},s),{},{subtitles:i});this.mediaSelection=n}onAudioTrackSwitching(t,e){const i=Qt(e);this.playerQueue.forEach((t=>t.hls.setAudioOption(e)||t.hls.setAudioOption(i)))}onSubtitleTrackSwitch(t,e){const i=Qt(e);this.playerQueue.forEach((t=>t.hls.setSubtitleOption(e)||-1!==e.id&&t.hls.setSubtitleOption(i)))}onBufferCodecs(t,e){const i=e.tracks;i&&(this.requiredTracks=i)}onBufferAppended(t,e){this.checkBuffer()}onBufferFlushed(t,e){const i=this.playingItem;if(i&&!this.itemsMatch(i,this.bufferingItem)&&!this.isInterstitial(i)){const t=this.timelinePos;this.bufferedPos=t,this.checkBuffer()}}onBufferedToEnd(t){const e=this.schedule.events;if(this.bufferedPost)return;if(1===e.length&&this.itemsMatch(e[0],n))return void(this.bufferedPos=t);const r=this.playingItem,a=this.findItemIndex(r);let o=s.findItemIndexAtTime(t);if(this.bufferedPos=n.end||null!=(l=r.event)&&l.appendInPlace&&t+.01>=r.start)&&(o=s),s-a>1&&!1===(null==n||null==(c=n.event)?void 0:c.appendInPlace))return;if(this.bufferedPos=t,o>i&&o>a)this.bufferedToItem(r);else{const e=this.primaryDetails;this.primaryLive&&e&&t>e.edge-e.targetduration&&r.start{const i=this.getAssetPlayer(t.identifier);return!(null!=i&&i.bufferedInPlaceToEnd(e))}))}setBufferingItem(t){const e=this.bufferingItem,i=this.schedule;if(this.itemsMatch(t,e))this.bufferingItem!==t&&(this.bufferingItem=t);else{const{items:s,events:n}=i;if(!s||!n)return e;const r=this.isInterstitial(t),a=this.getBufferingPlayer();if(this.bufferingItem=t,this.bufferedPos=Math.max(t.start,Math.min(t.end,this.timelinePos)),!this.playbackDisabled){const i=a?a.remaining:e?e.end-this.timelinePos:0;this.log(`buffered to boundary ${Dr(t)}`+(e?` (${i.toFixed(2)} remaining)`:"")),r?t.event.assetList.forEach((t=>{const e=this.getAssetPlayer(t.identifier);e&&e.resumeBuffering()})):(this.hls.resumeBuffering(),this.playerQueue.forEach((t=>t.pauseBuffering())))}this.hls.trigger(l.INTERSTITIALS_BUFFERED_TO_BOUNDARY,{events:n.slice(0),schedule:s.slice(0),bufferingIndex:this.findItemIndex(t),playingIndex:this.findItemIndex(this.playingItem)})}return e}bufferedToItem(t,e=0){const i=this.setBufferingItem(t);if(!this.playbackDisabled)if(this.isInterstitial(t))this.bufferedToEvent(t,e);else if(null!==i){this.bufferingAsset=null;const e=this.detachedData;if(e)if(e.mediaSource){const e=!0;this.attachPrimary(t.start,t,e)}else this.preloadPrimary(t);else this.preloadPrimary(t)}}preloadPrimary(t){const e=this.findItemIndex(t),i=this.getPrimaryResumption(t,e);this.startLoadingPrimaryAt(i)}bufferedToEvent(t,e){const i=t.event,s=0===i.assetList.length&&!i.assetListLoader,n=i.cue.once;if(s||!n){const t=this.preloadAssets(i,e);if(null!=t&&t.interstitial.appendInPlace){const s=i.assetList[e],n=this.primaryMedia;s&&n&&this.bufferAssetPlayer(t,n)}}}preloadAssets(t,e){const i=t.assetUrl,s=t.assetList.length,n=0===s&&!t.assetListLoader,r=t.cue.once;if(n){const n=t.timelineStart;if(t.appendInPlace){var a;const e=this.playingItem;this.isInterstitial(e)||(null==e||null==(a=e.nextEvent)?void 0:a.identifier)!==t.identifier||this.flushFrontBuffer(n+.25)}let r,o=0;if(!this.playingItem&&this.primaryLive&&(o=this.hls.startPosition,-1===o&&(o=this.hls.liveSyncPosition||0)),o&&!t.cue.pre&&!t.cue.post){const t=o-n;t>0&&(r=Math.round(1e3*t)/1e3)}if(this.log(`Load interstitial asset ${e+1}/${i?1:s} ${t}${r?` live-start: ${o} start-offset: ${r}`:""}`),i)return this.createAsset(t,0,0,n,t.duration,i);const l=this.assetListLoader.loadAssetList(t,r);l&&(t.assetListLoader=l)}else if(!r&&s){for(let i=e;i{this.hls.trigger(l.BUFFER_FLUSHING,{startOffset:t,endOffset:1/0,type:e})})))}getAssetPlayerQueueIndex(t){const e=this.playerQueue;for(let i=0;i1){const i=e.duration;i&&t{if(s.live){const e=new Error(`Interstitials MUST be VOD assets ${t}`),s={fatal:!0,type:a.OTHER_ERROR,details:o.INTERSTITIAL_ASSET_ITEM_ERROR,error:e};return void this.handleAssetItemError(s,t,this.schedule.findEventIndex(t.identifier),i,e.message)}const n=s.edge-s.fragmentStart,r=e.duration;(null===r||n>r)&&(this.log(`Interstitial asset "${f}" duration change ${r} > ${n}`),e.duration=n,this.updateSchedule())};m.on(l.LEVEL_UPDATED,((t,{details:e})=>y(e))),m.on(l.LEVEL_PTS_UPDATED,((t,{details:e})=>y(e)));const v=(t,e)=>{const i=this.getAssetPlayer(f);if(i&&e.tracks){i.off(l.BUFFER_CODECS,v),i.tracks=e.tracks;const t=this.primaryMedia;this.bufferingAsset===i.assetItem&&t&&!i.media&&this.bufferAssetPlayer(i,t)}};m.on(l.BUFFER_CODECS,v);const _=()=>{var i;const s=this.getAssetPlayer(f);if(this.log(`buffered to end of asset ${s}`),!s)return;const n=this.schedule.findEventIndex(t.identifier),r=t.findAssetIndex(e),a=r+1,o=null==(i=this.schedule.items)?void 0:i[n];if(this.isInterstitial(o))if(-1===r||t.isAssetPastPlayoutLimit(a)||t.assetList[a].error){var l;const t=null==(l=this.schedule.items)?void 0:l[n+1];t&&this.bufferedToItem(t)}else this.bufferedToItem(o,a)};m.on(l.BUFFERED_TO_END,_);const T=e=>()=>{if(!this.getAssetPlayer(f))return;this.shouldPlay=!0;const i=this.schedule.findEventIndex(t.identifier);this.advanceAfterAssetEnded(t,i,e)};return m.once(l.MEDIA_ENDED,T(i)),m.once(l.PLAYOUT_LIMIT_REACHED,T(1/0)),m.on(l.ERROR,((e,s)=>{const n=this.getAssetPlayer(f);if(s.details!==o.BUFFER_STALLED_ERROR)this.handleAssetItemError(s,t,this.schedule.findEventIndex(t.identifier),i,`Asset player error ${s.error} ${t}`);else if(null!=n&&n.media){const e=n.currentTime,i=n.duration-e;e&&t.appendInPlace&&i/n.media.playbackRate<.5?(this.log(`Advancing buffer past end of asset ${f} ${t} at ${n.media.currentTime}`),_()):(this.warn(`Stalled at ${e} of ${e+i} in asset ${f} ${t}`),this.onTimeupdate(),this.checkBuffer(!0))}})),m.on(l.DESTROYING,(()=>{if(!this.getAssetPlayer(f))return;const e=new Error(`Asset player destroyed unexpectedly ${f}`),s={fatal:!0,type:a.OTHER_ERROR,details:o.INTERSTITIAL_ASSET_ITEM_ERROR,error:e};this.handleAssetItemError(s,t,this.schedule.findEventIndex(t.identifier),i,e.message)})),this.hls.trigger(l.INTERSTITIAL_ASSET_PLAYER_CREATED,{asset:e,assetListIndex:i,event:t,player:m}),m}clearInterstitial(t,e){t.assetList.forEach((t=>{this.clearAssetPlayer(t.identifier,e)})),t.reset()}clearAssetPlayer(t,e){const i=this.getAssetPlayerQueueIndex(t);if(-1!==i){this.log(`clearAssetPlayer "${t}" toSegment: ${e?Dr(e):e}`);const s=this.playerQueue[i];this.transferMediaFromPlayer(s,e),this.playerQueue.splice(i,1),s.destroy()}}emptyPlayerQueue(){let t;for(;t=this.playerQueue.pop();)t.destroy();this.playerQueue=[]}startAssetPlayer(t,e,i,s,n){const{interstitial:r,assetItem:a,assetId:o}=t,c=r.assetList.length,u=this.playingAsset;this.endedAsset=null,this.playingAsset=a,u&&u.identifier===o||(u&&(this.clearAssetPlayer(u.identifier,i[s]),delete u.error),this.log(`INTERSTITIAL_ASSET_STARTED ${e+1}/${c} ${t}`),this.hls.trigger(l.INTERSTITIAL_ASSET_STARTED,{asset:a,assetListIndex:e,event:r,schedule:i.slice(0),scheduleIndex:s,player:t})),this.bufferAssetPlayer(t,n)}bufferAssetPlayer(t,e){var i,s;const{interstitial:n,assetItem:r,assetId:l}=t,c=this.schedule.findEventIndex(n.identifier),u=null==(i=this.schedule.items)?void 0:i[c];if(!u)return;this.setBufferingItem(u),this.bufferingAsset=r;const d=this.getBufferingPlayer();if(d===t)return;const h=n.appendInPlace;if(h&&!1===(null==d?void 0:d.interstitial.appendInPlace))return;const f=(null==d?void 0:d.tracks)||(null==(s=this.detachedData)?void 0:s.tracks)||this.requiredTracks;if(h&&r!==this.playingAsset){if(!t.tracks)return;if(f&&!C(f,t.tracks)){const e=new Error(`Asset "${l}" SourceBuffer tracks ('${Object.keys(t.tracks)}') are not compatible with primary content tracks ('${Object.keys(f)}')`),i={fatal:!0,type:a.OTHER_ERROR,details:o.INTERSTITIAL_ASSET_ITEM_ERROR,error:e},s=n.findAssetIndex(r);return void this.handleAssetItemError(i,n,c,s,e.message)}}this.transferMediaTo(t,e)}handleAssetItemError(t,e,i,s,n){if(t.details===o.BUFFER_STALLED_ERROR)return;const r=e.assetList[s]||null;let a=null;if(r){const t=this.getAssetPlayerQueueIndex(r.identifier);a=this.playerQueue[t]||null}const c=this.schedule.items,u=b({},t,{fatal:!1,errorAction:pe(!0),asset:r,assetListIndex:s,event:e,schedule:c,scheduleIndex:i,player:a});if(this.warn(`Asset item error: ${t.error}`),this.hls.trigger(l.INTERSTITIAL_ASSET_ERROR,u),!t.fatal)return;const d=new Error(n);r&&(this.playingAsset!==r&&this.clearAssetPlayer(r.identifier,null),r.error=d),e.assetList.some((t=>!t.error))?e.appendInPlace&&(e.error=d):e.error=d,this.primaryFallback(e)}primaryFallback(t){const e=t.timelineStart,i=this.effectivePlayingItem;if(this.updateSchedule(),i){this.log(`Fallback to primary from event "${t.identifier}" start: ${e} pos: ${this.timelinePos} playing: ${i?Dr(i):""} error: ${t.error}`),t.appendInPlace&&(this.attachPrimary(e,null),this.flushFrontBuffer(e));let s=this.timelinePos;-1===s&&(s=this.hls.startPosition);const n=this.updateItem(i,s);if(this.itemsMatch(i,n))this.clearInterstitial(t,null);else{const t=this.schedule.findItemIndexAtTime(s);this.setSchedulePosition(t)}}else this.checkStart()}onAssetListLoaded(t,e){var i;const s=e.event,n=s.identifier,r=e.assetListResponse.ASSETS;if(!this.schedule.hasEvent(n))return;const a=s.timelineStart,o=s.duration;let l=0;r.forEach(((t,e)=>{const i=parseFloat(t.DURATION);this.createAsset(s,e,l,a+l,i,t.URI),l+=i})),s.duration=l,this.log(`Loaded asset-list with duration: ${l} (was: ${o}) ${s}`);const c=this.waitingItem,u=(null==c?void 0:c.event.identifier)===n;this.updateSchedule();const d=null==(i=this.bufferingItem)?void 0:i.event;if(u){var h;const t=this.schedule.findEventIndex(n),e=null==(h=this.schedule.items)?void 0:h[t];if(e){if(!this.playingItem&&this.timelinePos>e.end&&this.schedule.findItemIndexAtTime(this.timelinePos)!==t)return s.error=new Error(`Interstitial no longer within playback range ${this.timelinePos} ${s}`),void this.primaryFallback(s);this.setBufferingItem(e)}this.setSchedulePosition(t)}else if((null==d?void 0:d.identifier)===n&&d.appendInPlace){const t=s.assetList[0],e=this.getAssetPlayer(t.identifier),i=this.primaryMedia;t&&e&&i&&this.bufferAssetPlayer(e,i)}}onError(t,e){switch(e.details){case o.ASSET_LIST_PARSING_ERROR:case o.ASSET_LIST_LOAD_ERROR:case o.ASSET_LIST_LOAD_TIMEOUT:{const t=e.interstitial;t&&this.primaryFallback(t);break}case o.BUFFER_STALLED_ERROR:this.onTimeupdate(),this.checkBuffer(!0)}}}});function $a(t){return t&&"object"==typeof t?Array.isArray(t)?t.map($a):Object.keys(t).reduce(((e,i)=>(e[i]=$a(t[i]),e)),{}):t}class Ua extends De{constructor(t,e){super("gap-controller",t.logger),this.hls=null,this.fragmentTracker=null,this.media=null,this.mediaSource=void 0,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1,this.buffered={},this.lastCurrentTime=0,this.ended=0,this.waiting=0,this.onMediaPlaying=()=>{this.ended=0,this.waiting=0},this.onMediaWaiting=()=>{var t;null!=(t=this.media)&&t.seeking||(this.waiting=self.performance.now(),this.tick())},this.onMediaEnded=()=>{var t;this.hls&&(this.ended=(null==(t=this.media)?void 0:t.currentTime)||1,this.hls.trigger(l.MEDIA_ENDED,{stalled:!1}))},this.hls=t,this.fragmentTracker=e,this.registerListeners()}registerListeners(){const{hls:t}=this;t&&(t.on(l.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(l.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(l.BUFFER_APPENDED,this.onBufferAppended,this))}unregisterListeners(){const{hls:t}=this;t&&(t.off(l.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(l.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(l.BUFFER_APPENDED,this.onBufferAppended,this))}destroy(){super.destroy(),this.unregisterListeners(),this.media=this.hls=this.fragmentTracker=null,this.mediaSource=void 0}onMediaAttached(t,e){this.setInterval(100),this.mediaSource=e.mediaSource;const i=this.media=e.media;Pr(i,"playing",this.onMediaPlaying),Pr(i,"waiting",this.onMediaWaiting),Pr(i,"ended",this.onMediaEnded)}onMediaDetaching(t,e){this.clearInterval();const{media:i}=this;i&&(Or(i,"playing",this.onMediaPlaying),Or(i,"waiting",this.onMediaWaiting),Or(i,"ended",this.onMediaEnded),this.media=null),this.mediaSource=void 0}onBufferAppended(t,e){this.buffered=e.timeRanges}get hasBuffered(){return Object.keys(this.buffered).length>0}tick(){var t;if(null==(t=this.media)||!t.readyState||!this.hasBuffered)return;const e=this.media.currentTime;this.poll(e,this.lastCurrentTime),this.lastCurrentTime=e}poll(t,e){var i,s;const n=null==(i=this.hls)?void 0:i.config;if(!n)return;const{media:r,stalled:a}=this;if(!r)return;const{seeking:o}=r,c=this.seeking&&!o,u=!this.seeking&&o,d=r.paused&&!o||r.ended||0===r.playbackRate;if(this.seeking=o,t!==e)return e&&(this.ended=0),this.moved=!0,o||(this.nudgeRetry=0,n.nudgeOnVideoHole&&!d&&t>e&&this.nudgeOnVideoHole(t,e)),void(0===this.waiting&&this.stallResolved(t));if(u||c)return void(c&&this.stallResolved(t));if(d)return this.nudgeRetry=0,this.stallResolved(t),void(!this.ended&&r.ended&&this.hls&&(this.ended=t||1,this.hls.trigger(l.MEDIA_ENDED,{stalled:!1})));if(!Oe.getBuffered(r).length)return void(this.nudgeRetry=0);const h=Oe.bufferInfo(r,t,0),f=h.nextStart||0,p=this.fragmentTracker;if(o&&p&&this.hls){const e=Ba(this.hls.inFlightFragments,t),i=h.len>2,s=!f||e||f-t>2&&!p.getPartialFragment(t);if(i||s)return;this.moved=!1}const g=null==(s=this.hls)?void 0:s.latestLevelDetails;if(!this.moved&&null!==this.stalled&&p){if(!(h.len>0||f))return;const e=Math.max(f,h.start||0)-t,i=null!=g&&g.live?2*g.targetduration:2,s=p.getPartialFragment(t);if(e>0&&(e<=i||s))return void(r.paused||this._trySkipBufferHole(s))}const m=n.detectStallWithCurrentTimeMs,y=self.performance.now(),v=this.waiting;if(null===a)return void(this.stalled=v>0&&y-v=m||v)&&this.hls){var _;if("ended"===(null==(_=this.mediaSource)?void 0:_.readyState)&&(null==g||!g.live)&&Math.abs(t-((null==g?void 0:g.edge)||0))<1){if(this.ended)return;return this.ended=t||1,void this.hls.trigger(l.MEDIA_ENDED,{stalled:!0})}if(this._reportStall(h),!this.media||!this.hls)return}const E=Oe.bufferInfo(r,t,n.maxBufferHole);this._tryFixBufferStall(E,b)}stallResolved(t){const e=this.stalled;if(e&&this.hls&&(this.stalled=null,this.stallReported)){const i=self.performance.now()-e;this.log(`playback not stuck anymore @${t}, after ${Math.round(i)}ms`),this.stallReported=!1,this.waiting=0,this.hls.trigger(l.STALL_RESOLVED,{})}}nudgeOnVideoHole(t,e){var i;const s=this.buffered.video;if(this.hls&&this.media&&this.fragmentTracker&&null!=(i=this.buffered.audio)&&i.length&&s&&s.length>1&&t>s.end(0)){const i=Oe.bufferedInfo(Oe.timeRangesToArray(this.buffered.audio),t,0);if(i.len>1&&e>=i.start){const i=Oe.timeRangesToArray(s),n=Oe.bufferedInfo(i,e,0).bufferedIndex;if(n>-1&&nn)&&r-s<1&&t-s<2){const i=new Error(`nudging playhead to flush pipeline after video hole. currentTime: ${t} hole: ${s} -> ${r} buffered index: ${e}`);this.warn(i.message),this.media.currentTime+=1e-6;const n=this.fragmentTracker.getPartialFragment(t)||void 0,c=Oe.bufferInfo(this.media,t,0);this.hls.trigger(l.ERROR,{type:a.MEDIA_ERROR,details:o.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:i,reason:i.message,frag:n,buffer:c.len,bufferInfo:c})}}}}}_tryFixBufferStall(t,e){var i,s;const{fragmentTracker:n,media:r}=this,a=null==(i=this.hls)?void 0:i.config;if(!r||!n||!a)return;const o=r.currentTime,l=null==(s=this.hls)?void 0:s.latestLevelDetails,c=n.getPartialFragment(o);if((c||null!=l&&l.live&&o1&&t.len>a.maxBufferHole||t.nextStart&&t.nextStart-o1e3*a.highBufferWatchdogPeriod||this.waiting)&&(this.warn("Trying to nudge playhead over buffer-hole"),this._tryNudgeBuffer(t))}_reportStall(t){const{hls:e,media:i,stallReported:s,stalled:n}=this;if(!s&&null!==n&&i&&e){this.stallReported=!0;const s=new Error(`Playback stalling at @${i.currentTime} due to low buffer (${Wt(t)})`);this.warn(s.message),e.trigger(l.ERROR,{type:a.MEDIA_ERROR,details:o.BUFFER_STALLED_ERROR,fatal:!1,error:s,buffer:t.len,bufferInfo:t,stalled:{start:n}})}}_trySkipBufferHole(t){var e;const{fragmentTracker:i,media:s}=this,n=null==(e=this.hls)?void 0:e.config;if(!s||!i||!n)return 0;const r=s.currentTime,c=Oe.bufferInfo(s,r,0),u=r0&&c.len<1&&s.readyState<3,p=u-r;if(p>0&&(e||h)){if(p>n.maxBufferHole){let e=!1;if(0===r){const t=i.getAppendedFrag(0,f);t&&u{const t=Ga();try{t&&new t(0,Number.POSITIVE_INFINITY,"")}catch(t){return Number.MAX_VALUE}return Number.POSITIVE_INFINITY})();class Ka{constructor(t){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.removeCues=!0,this.onEventCueEnter=()=>{this.hls&&this.hls.trigger(l.EVENT_CUE_ENTER,{})},this.hls=t,this._registerListeners()}destroy(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=this.onEventCueEnter=null}_registerListeners(){const{hls:t}=this;t.on(l.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(l.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(l.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(l.MANIFEST_LOADING,this.onManifestLoading,this),t.on(l.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),t.on(l.BUFFER_FLUSHING,this.onBufferFlushing,this),t.on(l.LEVEL_UPDATED,this.onLevelUpdated,this),t.on(l.LEVEL_PTS_UPDATED,this.onLevelPtsUpdated,this)}_unregisterListeners(){const{hls:t}=this;t.off(l.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(l.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(l.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(l.MANIFEST_LOADING,this.onManifestLoading,this),t.off(l.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),t.off(l.BUFFER_FLUSHING,this.onBufferFlushing,this),t.off(l.LEVEL_UPDATED,this.onLevelUpdated,this),t.off(l.LEVEL_PTS_UPDATED,this.onLevelPtsUpdated,this)}onMediaAttaching(t,e){var i;this.media=e.media,!1===(null==(i=e.overrides)?void 0:i.cueRemoval)&&(this.removeCues=!1)}onMediaAttached(){const t=this.hls.latestLevelDetails;t&&this.updateDateRangeCues(t)}onMediaDetaching(t,e){this.media=null,e.transferMedia||(this.id3Track&&(this.removeCues&&vr(this.id3Track,this.onEventCueEnter),this.id3Track=null),this.dateRangeCuesAppended={})}onManifestLoading(){this.dateRangeCuesAppended={}}createTrack(t){const e=this.getID3Track(t.textTracks);return e.mode="hidden",e}getID3Track(t){if(this.media){for(let e=0;eHa&&(s=Ha),s-i<=0&&(s=i+.25);for(let t=0;tt.type===Es.audioId3&&o:"video"===s?t=>t.type===Es.emsg&&a:t=>t.type===Es.audioId3&&o||t.type===Es.emsg&&a,br(n,e,i,t)}}onLevelUpdated(t,{details:e}){this.updateDateRangeCues(e,!0)}onLevelPtsUpdated(t,e){Math.abs(e.drift)>.01&&this.updateDateRangeCues(e.details)}updateDateRangeCues(t,e){if(!this.media||!t.hasProgramDateTime||!this.hls.config.enableDateRangeMetadataCues)return;const{id3Track:i}=this,{dateRanges:n}=t,r=Object.keys(n);let a=this.dateRangeCuesAppended;var o;if(i&&e)if(null!=(o=i.cues)&&o.length){const t=Object.keys(a).filter((t=>!r.includes(t)));for(let e=t.length;e--;){const s=t[e],n=a[s].cues;delete a[s],Object.keys(n).forEach((t=>{try{const e=n[t];e.removeEventListener("enter",this.onEventCueEnter),i.removeCue(e)}catch(t){}}))}}else a=this.dateRangeCuesAppended={};const l=t.fragments[t.fragments.length-1];if(0===r.length||!s(null==l?void 0:l.programDateTime))return;this.id3Track||(this.id3Track=this.createTrack(this.media));const c=Ga();for(let t=0;t{if(e!==i.id){const s=n[e];if(s.class===i.class&&s.startDate>i.startDate&&(!t||i.startDate.01&&(r.startTime=s,r.endTime=f);else if(c){let t=i.attr[n];Ve(n)&&(u=t,t=Uint8Array.from(u.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer);const r=Va(c,s,f,{key:n,data:t},Es.dateRange);r&&(r.id=e,this.id3Track.addCue(r),l[n]=r,this.hls.config.interstitialsController&&("X-ASSET-LIST"!==n&&"X-ASSET-URL"!==n||r.addEventListener("enter",this.onEventCueEnter)))}}a[e]={cues:l,dateRange:i,durationKnown:h}}var u,d}}class Ya{constructor(t){this.hls=void 0,this.config=void 0,this.media=null,this.currentTime=0,this.stallCount=0,this._latency=null,this._targetLatencyUpdated=!1,this.onTimeupdate=()=>{const{media:t}=this,e=this.levelDetails;if(!t||!e)return;this.currentTime=t.currentTime;const i=this.computeLatency();if(null===i)return;this._latency=i;const{lowLatencyMode:s,maxLiveSyncPlaybackRate:n}=this.config;if(!s||1===n||!e.live)return;const r=this.targetLatency;if(null===r)return;const a=i-r;if(a.05&&this.forwardBufferLength>1){const e=Math.min(2,Math.max(1,n)),i=Math.round(2/(1+Math.exp(-.75*a-this.edgeStalled))*20)/20,s=Math.min(e,Math.max(1,i));this.changeMediaPlaybackRate(t,s)}else 1!==t.playbackRate&&0!==t.playbackRate&&this.changeMediaPlaybackRate(t,1)},this.hls=t,this.config=t.config,this.registerListeners()}get levelDetails(){var t;return(null==(t=this.hls)?void 0:t.latestLevelDetails)||null}get latency(){return this._latency||0}get maxLatency(){const{config:t}=this;if(void 0!==t.liveMaxLatencyDuration)return t.liveMaxLatencyDuration;const e=this.levelDetails;return e?t.liveMaxLatencyDurationCount*e.targetduration:0}get targetLatency(){const t=this.levelDetails;if(null===t||null===this.hls)return null;const{holdBack:e,partHoldBack:i,targetduration:s}=t,{liveSyncDuration:n,liveSyncDurationCount:r,lowLatencyMode:a}=this.config,o=this.hls.userConfig;let l=a&&i||e;(this._targetLatencyUpdated||o.liveSyncDuration||o.liveSyncDurationCount||0===l)&&(l=void 0!==n?n:r*s);const c=s;return l+Math.min(this.stallCount*this.config.liveSyncOnStallIncrease,c)}set targetLatency(t){this.stallCount=0,this.config.liveSyncDuration=t,this._targetLatencyUpdated=!0}get liveSyncPosition(){const t=this.estimateLiveEdge(),e=this.targetLatency;if(null===t||null===e)return null;const i=this.levelDetails;if(null===i)return null;const s=i.edge,n=t-e-this.edgeStalled,r=s-i.totalduration,a=s-(this.config.lowLatencyMode&&i.partTarget||i.targetduration);return Math.min(Math.max(r,n),a)}get drift(){const t=this.levelDetails;return null===t?1:t.drift}get edgeStalled(){const t=this.levelDetails;if(null===t)return 0;const e=3*(this.config.lowLatencyMode&&t.partTarget||t.targetduration);return Math.max(t.age-e,0)}get forwardBufferLength(){const{media:t}=this,e=this.levelDetails;if(!t||!e)return 0;const i=t.buffered.length;return(i?t.buffered.end(i-1):e.edge)-this.currentTime}destroy(){this.unregisterListeners(),this.onMediaDetaching(),this.hls=null}registerListeners(){const{hls:t}=this;t&&(t.on(l.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(l.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(l.MANIFEST_LOADING,this.onManifestLoading,this),t.on(l.LEVEL_UPDATED,this.onLevelUpdated,this),t.on(l.ERROR,this.onError,this))}unregisterListeners(){const{hls:t}=this;t&&(t.off(l.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(l.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(l.MANIFEST_LOADING,this.onManifestLoading,this),t.off(l.LEVEL_UPDATED,this.onLevelUpdated,this),t.off(l.ERROR,this.onError,this))}onMediaAttached(t,e){this.media=e.media,this.media.addEventListener("timeupdate",this.onTimeupdate)}onMediaDetaching(){this.media&&(this.media.removeEventListener("timeupdate",this.onTimeupdate),this.media=null)}onManifestLoading(){this._latency=null,this.stallCount=0}onLevelUpdated(t,{details:e}){e.advanced&&this.onTimeupdate(),!e.live&&this.media&&this.media.removeEventListener("timeupdate",this.onTimeupdate)}onError(t,e){var i;e.details===o.BUFFER_STALLED_ERROR&&(this.stallCount++,this.hls&&null!=(i=this.levelDetails)&&i.live&&this.hls.logger.warn("[latency-controller]: Stall detected, adjusting target latency"))}changeMediaPlaybackRate(t,e){var i,s;t.playbackRate!==e&&(null==(i=this.hls)||i.logger.debug(`[latency-controller]: latency=${this.latency.toFixed(3)}, targetLatency=${null==(s=this.targetLatency)?void 0:s.toFixed(3)}, forwardBufferLength=${this.forwardBufferLength.toFixed(3)}: adjusting playback rate from ${t.playbackRate} to ${e}`),t.playbackRate=e)}estimateLiveEdge(){const t=this.levelDetails;return null===t?null:t.edge+t.age}computeLatency(){const t=this.estimateLiveEdge();return null===t?null:t-this.currentTime}}class qa extends En{constructor(t,e){super(t,"level-controller"),this._levels=[],this._firstLevel=-1,this._maxAutoLevel=-1,this._startLevel=void 0,this.currentLevel=null,this.currentLevelIndex=-1,this.manualLevelIndex=-1,this.steering=void 0,this.onParsedComplete=void 0,this.steering=e,this._registerListeners()}_registerListeners(){const{hls:t}=this;t.on(l.MANIFEST_LOADING,this.onManifestLoading,this),t.on(l.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(l.LEVEL_LOADED,this.onLevelLoaded,this),t.on(l.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on(l.FRAG_BUFFERED,this.onFragBuffered,this),t.on(l.ERROR,this.onError,this)}_unregisterListeners(){const{hls:t}=this;t.off(l.MANIFEST_LOADING,this.onManifestLoading,this),t.off(l.MANIFEST_LOADED,this.onManifestLoaded,this),t.off(l.LEVEL_LOADED,this.onLevelLoaded,this),t.off(l.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off(l.FRAG_BUFFERED,this.onFragBuffered,this),t.off(l.ERROR,this.onError,this)}destroy(){this._unregisterListeners(),this.steering=null,this.resetLevels(),super.destroy()}stopLoad(){this._levels.forEach((t=>{t.loadError=0,t.fragmentError=0})),super.stopLoad()}resetLevels(){this._startLevel=void 0,this.manualLevelIndex=-1,this.currentLevelIndex=-1,this.currentLevel=null,this._levels=[],this._maxAutoLevel=-1}onManifestLoading(t,e){this.resetLevels()}onManifestLoaded(t,e){const i=this.hls.config.preferManagedMediaSource,s=[],n={},r={};let a=!1,o=!1,l=!1;e.levels.forEach((t=>{var e;const c=t.attrs;let{audioCodec:u,videoCodec:d}=t;u&&(t.audioCodec=u=Pt(u,i)||void 0),0===(null==(e=d)?void 0:e.indexOf("avc1"))&&(d=t.videoCodec=function(t){const e=t.split(",");for(let t=0;t2){let s=i.shift()+".";s+=parseInt(i.shift()).toString(16),s+=("000"+parseInt(i.shift()).toString(16)).slice(-4),e[t]=s}}return e.join(",")}(d));const{width:h,height:f,unknownCodecs:p}=t;let g=p?p.length:0;if(p)for(let e=g;e--;){const i=p[e];this.isAudioSupported(i)?(t.audioCodec=u=u?`${u},${i}`:i,g--,kt.audio[u.substring(0,4)]=2):this.isVideoSupported(i)&&(t.videoCodec=d=d?`${d},${i}`:i,g--,kt.video[d.substring(0,4)]=2)}if(a||(a=!(!h||!f)),o||(o=!!d),l||(l=!!u),g||u&&!this.isAudioSupported(u)||d&&!this.isVideoSupported(d))return void this.log(`Some or all CODECS not supported "${c.CODECS}"`);const{CODECS:m,"FRAME-RATE":y,"HDCP-LEVEL":v,"PATHWAY-ID":b,RESOLUTION:_,"VIDEO-RANGE":E}=c,T=`${b||"."}-${t.bitrate}-${_}-${y}-${m}-${E}-${v}`;if(n[T])if(n[T].uri===t.url||t.attrs["PATHWAY-ID"])n[T].addGroupId("audio",c.AUDIO),n[T].addGroupId("text",c.SUBTITLES);else{const e=r[T]+=1;t.attrs["PATHWAY-ID"]=new Array(e+1).join(".");const i=this.createLevel(t);n[T]=i,s.push(i)}else{const e=this.createLevel(t);n[T]=e,r[T]=1,s.push(e)}})),this.filterAndSortMediaOptions(s,e,a,o,l)}createLevel(t){const e=new qt(t),i=t.supplemental;if(null!=i&&i.videoCodec&&!this.isVideoSupported(i.videoCodec)){const t=new Error(`SUPPLEMENTAL-CODECS not supported "${i.videoCodec}"`);this.log(t.message),e.supportedResult=Ut(t,[])}return e}isAudioSupported(t){return At(t,"audio",this.hls.config.preferManagedMediaSource)}isVideoSupported(t){return At(t,"video",this.hls.config.preferManagedMediaSource)}filterAndSortMediaOptions(t,e,i,s,n){let r=[],c=[],u=t;if((i||s)&&n&&(u=u.filter((({videoCodec:t,videoRange:e,width:i,height:s})=>{return(!!t||!(!i||!s))&&!!(n=e)&&Ht.indexOf(n)>-1;var n}))),0===u.length)return void Promise.resolve().then((()=>{if(this.hls){let t="no level with compatible codecs found in manifest",i=t;e.levels.length&&(i=`one or more CODECS in variant not supported: ${Wt(e.levels.map((t=>t.attrs.CODECS)).filter(((t,e,i)=>i.indexOf(t)===e)))}`,this.warn(i),t+=` (${i})`);const s=new Error(t);this.hls.trigger(l.ERROR,{type:a.MEDIA_ERROR,details:o.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:e.url,error:s,reason:i})}}));e.audioTracks&&(r=e.audioTracks.filter((t=>!t.audioCodec||this.isAudioSupported(t.audioCodec))),za(r)),e.subtitles&&(c=e.subtitles,za(c));const d=u.slice(0);u.sort(((t,e)=>{if(t.attrs["HDCP-LEVEL"]!==e.attrs["HDCP-LEVEL"])return(t.attrs["HDCP-LEVEL"]||"")>(e.attrs["HDCP-LEVEL"]||"")?1:-1;if(i&&t.height!==e.height)return t.height-e.height;if(t.frameRate!==e.frameRate)return t.frameRate-e.frameRate;if(t.videoRange!==e.videoRange)return Ht.indexOf(t.videoRange)-Ht.indexOf(e.videoRange);if(t.videoCodec!==e.videoCodec){const i=It(t.videoCodec),s=It(e.videoCodec);if(i!==s)return s-i}if(t.uri===e.uri&&t.codecSet!==e.codecSet){const i=Ct(t.codecSet),s=Ct(e.codecSet);if(i!==s)return s-i}return t.averageBitrate!==e.averageBitrate?t.averageBitrate-e.averageBitrate:0}));let h=d[0];if(this.steering&&(u=this.steering.filterParsedLevels(u),u.length!==d.length))for(let t=0;ti&&i===this.hls.abrEwmaDefaultEstimate&&(this.hls.bandwidthEstimate=t)}break}const p=n&&!s,g=this.hls.config,m=!(!g.audioStreamController||!g.audioTrackController),y={levels:u,audioTracks:r,subtitleTracks:c,sessionData:e.sessionData,sessionKeys:e.sessionKeys,firstLevel:this._firstLevel,stats:e.stats,audio:n,video:s,altAudio:m&&!p&&r.some((t=>!!t.url))};this.hls.trigger(l.MANIFEST_PARSED,y)}get levels(){return 0===this._levels.length?null:this._levels}get loadLevelObj(){return this.currentLevel}get level(){return this.currentLevelIndex}set level(t){const e=this._levels;if(0===e.length)return;if(t<0||t>=e.length){const i=new Error("invalid level idx"),s=t<0;if(this.hls.trigger(l.ERROR,{type:a.OTHER_ERROR,details:o.LEVEL_SWITCH_ERROR,level:t,fatal:s,error:i,reason:i.message}),s)return;t=Math.min(t,e.length-1)}const i=this.currentLevelIndex,s=this.currentLevel,n=s?s.attrs["PATHWAY-ID"]:void 0,r=e[t],c=r.attrs["PATHWAY-ID"];if(this.currentLevelIndex=t,this.currentLevel=r,i===t&&s&&n===c)return;this.log(`Switching to level ${t} (${r.height?r.height+"p ":""}${r.videoRange?r.videoRange+" ":""}${r.codecSet?r.codecSet+" ":""}@${r.bitrate})${c?" with Pathway "+c:""} from level ${i}${n?" with Pathway "+n:""}`);const u={level:t,attrs:r.attrs,details:r.details,bitrate:r.bitrate,averageBitrate:r.averageBitrate,maxBitrate:r.maxBitrate,realBitrate:r.realBitrate,width:r.width,height:r.height,codecSet:r.codecSet,audioCodec:r.audioCodec,videoCodec:r.videoCodec,audioGroups:r.audioGroups,subtitleGroups:r.subtitleGroups,loaded:r.loaded,loadError:r.loadError,fragmentError:r.fragmentError,name:r.name,id:r.id,uri:r.uri,url:r.url,urlId:0,audioGroupIds:r.audioGroupIds,textGroupIds:r.textGroupIds};this.hls.trigger(l.LEVEL_SWITCHING,u);const d=r.details;if(!d||d.live){const t=this.switchParams(r.uri,null==s?void 0:s.details,d);this.loadPlaylist(t)}}get manualLevel(){return this.manualLevelIndex}set manualLevel(t){this.manualLevelIndex=t,void 0===this._startLevel&&(this._startLevel=t),-1!==t&&(this.level=t)}get firstLevel(){return this._firstLevel}set firstLevel(t){this._firstLevel=t}get startLevel(){if(void 0===this._startLevel){const t=this.hls.config.startLevel;return void 0!==t?t:this.hls.firstAutoLevel}return this._startLevel}set startLevel(t){this._startLevel=t}get pathways(){return this.steering?this.steering.pathways():[]}get pathwayPriority(){return this.steering?this.steering.pathwayPriority:null}set pathwayPriority(t){if(this.steering){const e=this.steering.pathways(),i=t.filter((t=>-1!==e.indexOf(t)));if(t.length<1)return void this.warn(`pathwayPriority ${t} should contain at least one pathway from list: ${e}`);this.steering.pathwayPriority=i}}onError(t,e){!e.fatal&&e.context&&e.context.type===u&&e.context.level===this.level&&this.checkRetry(e)}onFragBuffered(t,{frag:e}){if(void 0!==e&&e.type===f){const t=e.elementaryStreams;if(!Object.keys(t).some((e=>!!t[e])))return;const i=this._levels[e.level];null!=i&&i.loadError&&(this.log(`Resetting level error count of ${i.loadError} on frag buffered`),i.loadError=0)}}onLevelLoaded(t,e){var i;const{level:s,details:n}=e,r=e.levelInfo;var a;if(!r)return this.warn(`Invalid level index ${s}`),void(null!=(a=e.deliveryDirectives)&&a.skip&&(n.deltaUpdateFailed=!0));if(r===this.currentLevel||e.withoutMultiVariant){0===r.fragmentError&&(r.loadError=0);let t=r.details;t===e.details&&t.advanced&&(t=void 0),this.playlistLoaded(s,e,t)}else null!=(i=e.deliveryDirectives)&&i.skip&&(n.deltaUpdateFailed=!0)}loadPlaylist(t){super.loadPlaylist(),this.shouldLoadPlaylist(this.currentLevel)&&this.scheduleLoading(this.currentLevel,t)}loadingPlaylist(t,e){super.loadingPlaylist(t,e);const i=this.getUrlWithDirectives(t.uri,e),s=this.currentLevelIndex,n=t.attrs["PATHWAY-ID"],r=t.details,a=null==r?void 0:r.age;this.log(`Loading level index ${s}${void 0!==(null==e?void 0:e.msn)?" at sn "+e.msn+" part "+e.part:""}${n?" Pathway "+n:""}${a&&r.live?" age "+a.toFixed(1)+(r.type?" "+r.type||0:""):""} ${i}`),this.hls.trigger(l.LEVEL_LOADING,{url:i,level:s,levelInfo:t,pathwayId:t.attrs["PATHWAY-ID"],id:0,deliveryDirectives:e||null})}get nextLoadLevel(){return-1!==this.manualLevelIndex?this.manualLevelIndex:this.hls.nextAutoLevel}set nextLoadLevel(t){this.level=t,-1===this.manualLevelIndex&&(this.hls.nextAutoLevel=t)}removeLevel(t){var e;if(1===this._levels.length)return;const i=this._levels.filter(((e,i)=>i!==t||(this.steering&&this.steering.removeLevel(e),e===this.currentLevel&&(this.currentLevel=null,this.currentLevelIndex=-1,e.details&&e.details.fragments.forEach((t=>t.level=-1))),!1)));Mi(i),this._levels=i,this.currentLevelIndex>-1&&null!=(e=this.currentLevel)&&e.details&&(this.currentLevelIndex=this.currentLevel.details.fragments[0].level),this.manualLevelIndex>-1&&(this.manualLevelIndex=this.currentLevelIndex);const s=i.length-1;this._firstLevel=Math.min(this._firstLevel,s),this._startLevel&&(this._startLevel=Math.min(this._startLevel,s)),this.hls.trigger(l.LEVELS_UPDATED,{levels:i})}onLevelsUpdated(t,{levels:e}){this._levels=e}checkMaxAutoUpdated(){const{autoLevelCapping:t,maxAutoLevel:e,maxHdcpLevel:i}=this.hls;this._maxAutoLevel!==e&&(this._maxAutoLevel=e,this.hls.trigger(l.MAX_AUTO_LEVEL_UPDATED,{autoLevelCapping:t,levels:this.levels,maxAutoLevel:e,minAutoLevel:this.hls.minAutoLevel,maxHdcpLevel:i}))}}function za(t){const e={};t.forEach((t=>{const i=t.groupId||"";t.id=e[i]=e[i]||0,e[i]++}))}function Wa(){return self.SourceBuffer||self.WebKitSourceBuffer}function Xa(){if(!I())return!1;const t=Wa();return!t||t.prototype&&"function"==typeof t.prototype.appendBuffer&&"function"==typeof t.prototype.remove}class Ja extends Vi{constructor(t,e,i){super(t,e,i,"stream-controller",f),this.audioCodecSwap=!1,this.level=-1,this._forceStartLoad=!1,this._hasEnoughToStart=!1,this.altAudio=0,this.audioOnly=!1,this.fragPlaying=null,this.fragLastKbps=0,this.couldBacktrack=!1,this.backtrackFragment=null,this.audioCodecSwitch=!1,this.videoBuffer=null,this.onMediaPlaying=()=>{this.tick()},this.onMediaSeeked=()=>{const t=this.media,e=t?t.currentTime:null;if(null===e||!s(e))return;if(this.log(`Media seeked to ${e.toFixed(3)}`),!this.getBufferedFrag(e))return;const i=this.getFwdBufferInfoAtPos(t,e,f,0);null!==i&&0!==i.len?this.tick():this.warn(`Main forward buffer length at ${e} on "seeked" event ${i?i.len:"empty"})`)},this.registerListeners()}registerListeners(){super.registerListeners();const{hls:t}=this;t.on(l.MANIFEST_PARSED,this.onManifestParsed,this),t.on(l.LEVEL_LOADING,this.onLevelLoading,this),t.on(l.LEVEL_LOADED,this.onLevelLoaded,this),t.on(l.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),t.on(l.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.on(l.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.on(l.BUFFER_CREATED,this.onBufferCreated,this),t.on(l.BUFFER_FLUSHED,this.onBufferFlushed,this),t.on(l.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on(l.FRAG_BUFFERED,this.onFragBuffered,this)}unregisterListeners(){super.unregisterListeners();const{hls:t}=this;t.off(l.MANIFEST_PARSED,this.onManifestParsed,this),t.off(l.LEVEL_LOADED,this.onLevelLoaded,this),t.off(l.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),t.off(l.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.off(l.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.off(l.BUFFER_CREATED,this.onBufferCreated,this),t.off(l.BUFFER_FLUSHED,this.onBufferFlushed,this),t.off(l.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off(l.FRAG_BUFFERED,this.onFragBuffered,this)}onHandlerDestroying(){this.onMediaPlaying=this.onMediaSeeked=null,this.unregisterListeners(),super.onHandlerDestroying()}startLoad(t,e){if(this.levels){const{lastCurrentTime:i,hls:s}=this;if(this.stopLoad(),this.setInterval(100),this.level=-1,!this.startFragRequested){let t=s.startLevel;-1===t&&(s.config.testBandwidth&&this.levels.length>1?(t=0,this.bitrateTest=!0):t=s.firstAutoLevel),s.nextLoadLevel=t,this.level=s.loadLevel,this._hasEnoughToStart=!!e}i>0&&-1===t&&!e&&(this.log(`Override startPosition with lastCurrentTime @${i.toFixed(3)}`),t=i),this.state=Gi.IDLE,this.nextLoadPosition=this.lastCurrentTime=t+this.timelineOffset,this.startPosition=e?-1:t,this.tick()}else this._forceStartLoad=!0,this.state=Gi.STOPPED}stopLoad(){this._forceStartLoad=!1,super.stopLoad()}doTick(){switch(this.state){case Gi.WAITING_LEVEL:{const{levels:t,level:e}=this,i=null==t?void 0:t[e],s=null==i?void 0:i.details;if(s&&(!s.live||this.levelLastLoaded===i&&!this.waitForLive(i))){if(this.waitForCdnTuneIn(s))break;this.state=Gi.IDLE;break}if(this.hls.nextLoadLevel!==this.level){this.state=Gi.IDLE;break}break}case Gi.FRAG_LOADING_WAITING_RETRY:{var t;const e=self.performance.now(),i=this.retryDate;if(!i||e>=i||null!=(t=this.media)&&t.seeking){const{levels:t,level:e}=this,i=null==t?void 0:t[e];this.resetStartWhenNotLoaded(i||null),this.state=Gi.IDLE}}}this.state===Gi.IDLE&&this.doTickIdle(),this.onTickEnd()}onTickEnd(){var t;super.onTickEnd(),null!=(t=this.media)&&t.readyState&&!1===this.media.seeking&&(this.lastCurrentTime=this.media.currentTime),this.checkFragmentChanged()}doTickIdle(){const{hls:t,levelLastLoaded:e,levels:i,media:s}=this;if(null===e||!s&&!this.primaryPrefetch&&(this.startFragRequested||!t.config.startFragPrefetch))return;if(this.altAudio&&this.audioOnly)return;const n=this.buffering?t.nextLoadLevel:t.loadLevel;if(null==i||!i[n])return;const r=i[n],a=this.getMainFwdBufferInfo();if(null===a)return;const o=this.getLevelDetails();if(o&&this._streamEnded(a,o)){const t={};return 2===this.altAudio&&(t.type="video"),this.hls.trigger(l.BUFFER_EOS,t),void(this.state=Gi.ENDED)}if(!this.buffering)return;t.loadLevel!==n&&-1===t.manualLevel&&this.log(`Adapting to level ${n} from level ${this.level}`),this.level=t.nextLoadLevel=n;const c=r.details;if(!c||this.state===Gi.WAITING_LEVEL||this.waitForLive(r))return this.level=n,this.state=Gi.WAITING_LEVEL,void(this.startFragRequested=!1);const u=a.len,d=this.getMaxBufferLength(r.maxBitrate);if(u>=d)return;this.backtrackFragment&&this.backtrackFragment.start>a.end&&(this.backtrackFragment=null);const h=this.backtrackFragment?this.backtrackFragment.start:a.end;let p=this.getNextFragment(h,c);if(this.couldBacktrack&&!this.fragPrevious&&p&&q(p)&&this.fragmentTracker.getState(p)!==ve){var g;const t=(null!=(g=this.backtrackFragment)?g:p).sn-c.startSN,e=c.fragments[t-1];e&&p.cc===e.cc&&(p=e,this.fragmentTracker.removeFragment(e))}else this.backtrackFragment&&a.len&&(this.backtrackFragment=null);if(p&&this.isLoopLoading(p,h)){if(!p.gap){const t=this.audioOnly&&!this.altAudio?V:H,e=(t===H?this.videoBuffer:this.mediaBuffer)||this.media;e&&this.afterBufferFlushed(e,t,f)}p=this.getNextFragmentLoopLoading(p,c,a,f,d)}p&&(!p.initSegment||p.initSegment.data||this.bitrateTest||(p=p.initSegment),this.loadFragment(p,r,h))}loadFragment(t,e,i){const s=this.fragmentTracker.getState(t);s===ge||s===ye?q(t)?this.bitrateTest?(this.log(`Fragment ${t.sn} of level ${t.level} is being downloaded to test bitrate and will not be buffered`),this._loadBitrateTestFrag(t,e)):super.loadFragment(t,e,i):this._loadInitSegment(t,e):this.clearTrackerIfNeeded(t)}getBufferedFrag(t){return this.fragmentTracker.getBufferedFrag(t,f)}followingBufferedFrag(t){return t?this.getBufferedFrag(t.end+.5):null}immediateLevelSwitch(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)}nextLevelSwitch(){const{levels:t,media:e}=this;if(null!=e&&e.readyState){let i;const s=this.getAppendedFrag(e.currentTime);s&&s.start>1&&this.flushMainBuffer(0,s.start-1);const n=this.getLevelDetails();if(null!=n&&n.live){const t=this.getMainFwdBufferInfo();if(!t||t.len<2*n.targetduration)return}if(!e.paused&&t){const e=t[this.hls.nextLoadLevel],s=this.fragLastKbps;i=s&&this.fragCurrent?this.fragCurrent.duration*e.maxBitrate/(1e3*s)+1:0}else i=0;const r=this.getBufferedFrag(e.currentTime+i);if(r){const t=this.followingBufferedFrag(r);if(t){this.abortCurrentFrag();const e=t.maxStartPTS?t.maxStartPTS:t.start,i=t.duration,s=Math.max(r.end,e+Math.min(Math.max(i-this.config.maxFragLookUpTolerance,i*(this.couldBacktrack?.5:.125)),i*(this.couldBacktrack?.75:.25)));this.flushMainBuffer(s,Number.POSITIVE_INFINITY)}}}}abortCurrentFrag(){const t=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,t&&(t.abortRequests(),this.fragmentTracker.removeFragment(t)),this.state){case Gi.KEY_LOADING:case Gi.FRAG_LOADING:case Gi.FRAG_LOADING_WAITING_RETRY:case Gi.PARSING:case Gi.PARSED:this.state=Gi.IDLE}this.nextLoadPosition=this.getLoadPosition()}flushMainBuffer(t,e){super.flushMainBuffer(t,e,2===this.altAudio?"video":null)}onMediaAttached(t,e){super.onMediaAttached(t,e);const i=e.media;Pr(i,"playing",this.onMediaPlaying),Pr(i,"seeked",this.onMediaSeeked)}onMediaDetaching(t,e){const{media:i}=this;i&&(Or(i,"playing",this.onMediaPlaying),Or(i,"seeked",this.onMediaSeeked)),this.videoBuffer=null,this.fragPlaying=null,super.onMediaDetaching(t,e),e.transferMedia||(this._hasEnoughToStart=!1)}onManifestLoading(){super.onManifestLoading(),this.log("Trigger BUFFER_RESET"),this.hls.trigger(l.BUFFER_RESET,void 0),this.couldBacktrack=!1,this.fragLastKbps=0,this.fragPlaying=this.backtrackFragment=null,this.altAudio=0,this.audioOnly=!1}onManifestParsed(t,e){let i=!1,s=!1;e.levels.forEach((t=>{const e=t.audioCodec;e&&(i=i||-1!==e.indexOf("mp4a.40.2"),s=s||-1!==e.indexOf("mp4a.40.5"))})),this.audioCodecSwitch=i&&s&&!function(){var t;const e=Wa();return"function"==typeof(null==e||null==(t=e.prototype)?void 0:t.changeType)}(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=e.levels,this.startFragRequested=!1}onLevelLoading(t,e){const{levels:i}=this;if(!i||this.state!==Gi.IDLE)return;const s=e.levelInfo;(!s.details||s.details.live&&(this.levelLastLoaded!==s||s.details.expired)||this.waitForCdnTuneIn(s.details))&&(this.state=Gi.WAITING_LEVEL)}onLevelLoaded(t,e){var i;const{levels:s,startFragRequested:n}=this,r=e.level,a=e.details,o=a.totalduration;if(!s)return void this.warn(`Levels were reset while loading level ${r}`);this.log(`Level ${r} loaded [${a.startSN},${a.endSN}]${a.lastPartSn?`[part-${a.lastPartSn}-${a.lastPartIndex}]`:""}, cc [${a.startCC}, ${a.endCC}] duration:${o}`);const c=e.levelInfo,u=this.fragCurrent;!u||this.state!==Gi.FRAG_LOADING&&this.state!==Gi.FRAG_LOADING_WAITING_RETRY||u.level!==e.level&&u.loader&&this.abortCurrentFrag();let d=0;if(a.live||null!=(i=c.details)&&i.live){var h;if(this.checkLiveUpdate(a),a.deltaUpdateFailed)return;d=this.alignPlaylists(a,c.details,null==(h=this.levelLastLoaded)?void 0:h.details)}if(c.details=a,this.levelLastLoaded=c,n||this.setStartPosition(a,d),this.hls.trigger(l.LEVEL_UPDATED,{details:a,level:r}),this.state===Gi.WAITING_LEVEL){if(this.waitForCdnTuneIn(a))return;this.state=Gi.IDLE}n&&a.live&&this.synchronizeToLiveEdge(a),this.tick()}synchronizeToLiveEdge(t){const{config:e,media:i}=this;if(!i)return;const s=this.hls.liveSyncPosition,n=this.getLoadPosition(),r=t.fragmentStart,a=t.edge,o=n>=r-e.maxFragLookUpTolerance&&n<=a;if(null!==s&&i.duration>s&&(n{var t;null==(t=this.hls)||t.trigger(l.AUDIO_TRACK_SWITCHED,e)})),void i.trigger(l.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null});i.trigger(l.AUDIO_TRACK_SWITCHED,e)}}onAudioTrackSwitched(t,e){const i=se(e.url,this.hls);if(i){const t=this.videoBuffer;t&&this.mediaBuffer!==t&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=t)}this.altAudio=i?2:0,this.tick()}onBufferCreated(t,e){const i=e.tracks;let s,n,r=!1;for(const t in i){const e=i[t];if("main"===e.id){if(n=t,s=e,"video"===t){const e=i[t];e&&(this.videoBuffer=e.buffer)}}else r=!0}r&&s?(this.log(`Alternate track found, use ${n}.buffered to schedule main fragment loading`),this.mediaBuffer=s.buffer):this.mediaBuffer=this.media}onFragBuffered(t,e){const{frag:i,part:s}=e,n=i.type===f;if(n){if(this.fragContextChanged(i))return this.warn(`Fragment ${i.sn}${s?" p: "+s.index:""} of level ${i.level} finished buffering, but was aborted. state: ${this.state}`),void(this.state===Gi.PARSED&&(this.state=Gi.IDLE));const t=s?s.stats:i.stats;this.fragLastKbps=Math.round(8*t.total/(t.buffering.end-t.loading.first)),q(i)&&(this.fragPrevious=i),this.fragBufferedComplete(i,s)}const r=this.media;r&&(!this._hasEnoughToStart&&Oe.getBuffered(r).length&&(this._hasEnoughToStart=!0,this.seekToStartPos()),n&&this.tick())}get hasEnoughToStart(){return this._hasEnoughToStart}onError(t,e){var i;if(e.fatal)this.state=Gi.ERROR;else switch(e.details){case o.FRAG_GAP:case o.FRAG_PARSING_ERROR:case o.FRAG_DECRYPT_ERROR:case o.FRAG_LOAD_ERROR:case o.FRAG_LOAD_TIMEOUT:case o.KEY_LOAD_ERROR:case o.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(f,e);break;case o.LEVEL_LOAD_ERROR:case o.LEVEL_LOAD_TIMEOUT:case o.LEVEL_PARSING_ERROR:e.levelRetry||this.state!==Gi.WAITING_LEVEL||(null==(i=e.context)?void 0:i.type)!==u||(this.state=Gi.IDLE);break;case o.BUFFER_ADD_CODEC_ERROR:case o.BUFFER_APPEND_ERROR:if("main"!==e.parent)return;this.resetLoadingState();break;case o.BUFFER_FULL_ERROR:if("main"!==e.parent)return;this.reduceLengthAndFlushBuffer(e)&&this.flushMainBuffer(0,Number.POSITIVE_INFINITY);break;case o.INTERNAL_EXCEPTION:this.recoverWorkerError(e)}}onFragLoadEmergencyAborted(){this.state=Gi.IDLE,this._hasEnoughToStart||(this.startFragRequested=!1,this.nextLoadPosition=this.lastCurrentTime),this.tickImmediate()}onBufferFlushed(t,{type:e}){if(e!==V||!this.altAudio){const t=(e===H?this.videoBuffer:this.mediaBuffer)||this.media;t&&(this.afterBufferFlushed(t,e,f),this.tick())}}onLevelsUpdated(t,e){this.level>-1&&this.fragCurrent&&(this.level=this.fragCurrent.level,-1===this.level&&this.resetWhenMissingContext(this.fragCurrent)),this.levels=e.levels}swapAudioCodec(){this.audioCodecSwap=!this.audioCodecSwap}seekToStartPos(){const{media:t}=this;if(!t)return;const e=t.currentTime;let i=this.startPosition;if(i>=0&&e0&&(o{const{hls:i}=this,s=null==t?void 0:t.frag;if(!s||this.fragContextChanged(s))return;e.fragmentError=0,this.state=Gi.IDLE,this.startFragRequested=!1,this.bitrateTest=!1;const n=s.stats;n.parsing.start=n.parsing.end=n.buffering.start=n.buffering.end=self.performance.now(),i.trigger(l.FRAG_LOADED,t),s.bitrateTest=!1}))}_handleTransmuxComplete(t){var e;const i=this.playlistType,{hls:n}=this,{remuxResult:r,chunkMeta:a}=t,o=this.getCurrentContext(a);if(!o)return void this.resetWhenMissingContext(a);const{frag:c,part:u,level:d}=o,{video:h,text:f,id3:p,initSegment:g}=r,{details:m}=d,y=this.altAudio?void 0:r.audio;if(this.fragContextChanged(c))this.fragmentTracker.removeFragment(c);else{if(this.state=Gi.PARSING,g){if(null!=g&&g.tracks){const t=c.initSegment||c;this._bufferInitSegment(d,g.tracks,t,a),n.trigger(l.FRAG_PARSING_INIT_SEGMENT,{frag:t,id:i,tracks:g.tracks})}const t=g.initPTS,e=g.timescale;s(t)&&(this.initPTS[c.cc]={baseTime:t,timescale:e},n.trigger(l.INIT_PTS_FOUND,{frag:c,id:i,initPTS:t,timescale:e}))}if(h&&m){y||"audiovideo"!==h.type||this.logMuxedErr(c);const t=m.fragments[c.sn-1-m.startSN],e=c.sn===m.startSN,i=!t||c.cc>t.cc;if(!1!==r.independent){const{startPTS:t,endPTS:s,startDTS:n,endDTS:r}=h;if(u)u.elementaryStreams[h.type]={startPTS:t,endPTS:s,startDTS:n,endDTS:r};else if(h.firstKeyFrame&&h.independent&&1===a.id&&!i&&(this.couldBacktrack=!0),h.dropped&&h.independent){const n=this.getMainFwdBufferInfo(),a=(n?n.end:this.getLoadPosition())+this.config.maxBufferHole,o=h.firstKeyFramePTS?h.firstKeyFramePTS:t;if(!e&&a2&&(c.gap=!0);c.setElementaryStreamInfo(h.type,t,s,n,r),this.backtrackFragment&&(this.backtrackFragment=c),this.bufferFragmentData(h,c,u,a,e||i)}else{if(!e&&!i)return void this.backtrack(c);c.gap=!0}}if(y){const{startPTS:t,endPTS:e,startDTS:i,endDTS:s}=y;u&&(u.elementaryStreams[V]={startPTS:t,endPTS:e,startDTS:i,endDTS:s}),c.setElementaryStreamInfo(V,t,e,i,s),this.bufferFragmentData(y,c,u,a)}if(m&&null!=p&&null!=(e=p.samples)&&e.length){const t={id:i,frag:c,details:m,samples:p.samples};n.trigger(l.FRAG_PARSING_METADATA,t)}if(m&&f){const t={id:i,frag:c,details:m,samples:f.samples};n.trigger(l.FRAG_PARSING_USERDATA,t)}}}logMuxedErr(t){this.warn(`${q(t)?"Media":"Init"} segment with muxed audiovideo where only video expected: ${t.url}`)}_bufferInitSegment(t,e,i,s){if(this.state!==Gi.PARSING)return;this.audioOnly=!!e.audio&&!e.video,this.altAudio&&!this.audioOnly&&(delete e.audio,e.audiovideo&&this.logMuxedErr(i));const{audio:n,video:r,audiovideo:a}=e;if(n){let i=Ot(n.codec,t.audioCodec);"mp4a"===i&&(i="mp4a.40.5");const s=navigator.userAgent.toLowerCase();if(this.audioCodecSwitch){i&&(i=-1!==i.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5");const t=n.metadata;t&&"channelCount"in t&&1!==(t.channelCount||1)&&-1===s.indexOf("firefox")&&(i="mp4a.40.5")}i&&-1!==i.indexOf("mp4a.40.5")&&-1!==s.indexOf("android")&&"audio/mpeg"!==n.container&&(i="mp4a.40.2",this.log(`Android: force audio codec to ${i}`)),t.audioCodec&&t.audioCodec!==i&&this.log(`Swapping manifest audio codec "${t.audioCodec}" for "${i}"`),n.levelCodec=i,n.id=f,this.log(`Init audio buffer, container:${n.container}, codecs[selected/level/parsed]=[${i||""}/${t.audioCodec||""}/${n.codec}]`),delete e.audiovideo}if(r){r.levelCodec=t.videoCodec,r.id=f;const i=r.codec;if(4===(null==i?void 0:i.length))switch(i){case"hvc1":case"hev1":r.codec="hvc1.1.6.L120.90";break;case"av01":r.codec="av01.0.04M.08";break;case"avc1":r.codec="avc1.42e01e"}this.log(`Init video buffer, container:${r.container}, codecs[level/parsed]=[${t.videoCodec||""}/${i}]${r.codec!==i?" parsed-corrected="+r.codec:""}${r.supplemental?" supplemental="+r.supplemental:""}`),delete e.audiovideo}a&&(this.log(`Init audiovideo buffer, container:${a.container}, codecs[level/parsed]=[${t.codecs}/${a.codec}]`),delete e.video,delete e.audio);const o=Object.keys(e);if(o.length){if(this.hls.trigger(l.BUFFER_CODECS,e),!this.hls)return;o.forEach((t=>{const n=e[t].initSegment;null!=n&&n.byteLength&&this.hls.trigger(l.BUFFER_APPENDING,{type:t,data:n,frag:i,part:null,chunkMeta:s,parent:i.type})}))}this.tickImmediate()}getMainFwdBufferInfo(){const t=this.mediaBuffer&&2===this.altAudio?this.mediaBuffer:this.media;return this.getFwdBufferInfo(t,f)}get maxBufferLength(){const{levels:t,level:e}=this,i=null==t?void 0:t[e];return i?this.getMaxBufferLength(i.maxBitrate):this.config.maxBufferLength}backtrack(t){this.couldBacktrack=!0,this.backtrackFragment=t,this.resetTransmuxer(),this.flushBufferGap(t),this.fragmentTracker.removeFragment(t),this.fragPrevious=null,this.nextLoadPosition=t.start,this.state=Gi.IDLE}checkFragmentChanged(){const t=this.media;let e=null;if(t&&t.readyState>1&&!1===t.seeking){const i=t.currentTime;if(Oe.isBuffered(t,i)?e=this.getAppendedFrag(i):Oe.isBuffered(t,i+.1)&&(e=this.getAppendedFrag(i+.1)),e){this.backtrackFragment=null;const t=this.fragPlaying,i=e.level;t&&e.sn===t.sn&&t.level===i||(this.fragPlaying=e,this.hls.trigger(l.FRAG_CHANGED,{frag:e}),t&&t.level===i||this.hls.trigger(l.LEVEL_SWITCHED,{level:i}))}}}get nextLevel(){const t=this.nextBufferedFrag;return t?t.level:-1}get currentFrag(){var t;if(this.fragPlaying)return this.fragPlaying;const e=(null==(t=this.media)?void 0:t.currentTime)||this.lastCurrentTime;return s(e)?this.getAppendedFrag(e):null}get currentProgramDateTime(){var t;const e=(null==(t=this.media)?void 0:t.currentTime)||this.lastCurrentTime;if(s(e)){const t=this.getLevelDetails(),i=this.currentFrag||(t?re(null,t.fragments,e):null);if(i){const t=i.programDateTime;if(null!==t){const s=t+1e3*(e-i.start);return new Date(s)}}}return null}get currentLevel(){const t=this.currentFrag;return t?t.level:-1}get nextBufferedFrag(){const t=this.currentFrag;return t?this.followingBufferedFrag(t):null}get forceStartLoad(){return this._forceStartLoad}}class Qa{constructor(t){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=t}abort(t){for(const i in this.keyUriToKeyInfo){const s=this.keyUriToKeyInfo[i].loader;if(s){var e;if(t&&t!==(null==(e=s.context)?void 0:e.frag.type))return;s.abort()}}}detach(){for(const t in this.keyUriToKeyInfo){const e=this.keyUriToKeyInfo[t];(e.mediaKeySessionContext||e.decryptdata.isCommonEncryption)&&delete this.keyUriToKeyInfo[t]}}destroy(){this.detach();for(const t in this.keyUriToKeyInfo){const e=this.keyUriToKeyInfo[t].loader;e&&e.destroy()}this.keyUriToKeyInfo={}}createKeyLoadError(t,e=o.KEY_LOAD_ERROR,i,s,n){return new Ce({type:a.NETWORK_ERROR,details:e,fatal:!1,frag:t,response:n,error:i,networkDetails:s})}loadClear(t,e){if(this.emeController&&this.config.emeEnabled){const{sn:i,cc:s}=t;for(let t=0;t{n.setKeyFormat(t)}));break}}}}load(t){return!t.decryptdata&&t.encrypted&&this.emeController&&this.config.emeEnabled?this.emeController.selectKeySystemFormat(t).then((e=>this.loadInternal(t,e))):this.loadInternal(t)}loadInternal(t,e){var i,s;e&&t.setKeyFormat(e);const n=t.decryptdata;if(!n){const i=new Error(e?`Expected frag.decryptdata to be defined after setting format ${e}`:"Missing decryption data on fragment in onKeyLoading");return Promise.reject(this.createKeyLoadError(t,o.KEY_LOAD_ERROR,i))}const r=n.uri;if(!r)return Promise.reject(this.createKeyLoadError(t,o.KEY_LOAD_ERROR,new Error(`Invalid key URI: "${r}"`)));let a=this.keyUriToKeyInfo[r];if(null!=(i=a)&&i.decryptdata.key)return n.key=a.decryptdata.key,Promise.resolve({frag:t,keyInfo:a});var l;if(null!=(s=a)&&s.keyLoadPromise)switch(null==(l=a.mediaKeySessionContext)?void 0:l.keyStatus){case void 0:case"status-pending":case"usable":case"usable-in-future":return a.keyLoadPromise.then((e=>(n.key=e.keyInfo.decryptdata.key,{frag:t,keyInfo:a})))}switch(a=this.keyUriToKeyInfo[r]={decryptdata:n,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},n.method){case"ISO-23001-7":case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return"identity"===n.keyFormat?this.loadKeyHTTP(a,t):this.loadKeyEME(a,t);case"AES-128":case"AES-256":case"AES-256-CTR":return this.loadKeyHTTP(a,t);default:return Promise.reject(this.createKeyLoadError(t,o.KEY_LOAD_ERROR,new Error(`Key supplied with unsupported METHOD: "${n.method}"`)))}}loadKeyEME(t,e){const i={frag:e,keyInfo:t};if(this.emeController&&this.config.emeEnabled){const e=this.emeController.loadKey(i);if(e)return(t.keyLoadPromise=e.then((e=>(t.mediaKeySessionContext=e,i)))).catch((e=>{throw t.keyLoadPromise=null,e}))}return Promise.resolve(i)}loadKeyHTTP(t,e){const i=this.config,s=new(0,i.loader)(i);return e.keyLoader=t.loader=s,t.keyLoadPromise=new Promise(((n,r)=>{const a={keyInfo:t,frag:e,responseType:"arraybuffer",url:t.decryptdata.uri},l=i.keyLoadPolicy.default,c={loadPolicy:l,timeout:l.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},u={onSuccess:(t,e,i,s)=>{const{frag:a,keyInfo:l,url:c}=i;if(!a.decryptdata||l!==this.keyUriToKeyInfo[c])return r(this.createKeyLoadError(a,o.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),s));l.decryptdata.key=a.decryptdata.key=new Uint8Array(t.data),a.keyLoader=null,l.loader=null,n({frag:a,keyInfo:l})},onError:(t,i,s,n)=>{this.resetLoader(i),r(this.createKeyLoadError(e,o.KEY_LOAD_ERROR,new Error(`HTTP Error ${t.code} loading key ${t.text}`),s,E({url:a.url,data:void 0},t)))},onTimeout:(t,i,s)=>{this.resetLoader(i),r(this.createKeyLoadError(e,o.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),s))},onAbort:(t,i,s)=>{this.resetLoader(i),r(this.createKeyLoadError(e,o.INTERNAL_ABORTED,new Error("key loading aborted"),s))}};s.load(a,c,u)}))}resetLoader(t){const{frag:e,keyInfo:i,url:s}=t,n=i.loader;e.keyLoader===n&&(e.keyLoader=null,i.loader=null),delete this.keyUriToKeyInfo[s],n&&n.destroy()}}function Za(t){const{type:e}=t;switch(e){case d:return p;case h:return g;default:return f}}function to(t,e){let i=t.url;return void 0!==i&&0!==i.indexOf("data:")||(i=e.url),i}class eo{constructor(t){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.onManifestLoaded=this.checkAutostartLoad,this.hls=t,this.registerListeners()}startLoad(t){}stopLoad(){this.destroyInternalLoaders()}registerListeners(){const{hls:t}=this;t.on(l.MANIFEST_LOADING,this.onManifestLoading,this),t.on(l.LEVEL_LOADING,this.onLevelLoading,this),t.on(l.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),t.on(l.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this),t.on(l.LEVELS_UPDATED,this.onLevelsUpdated,this)}unregisterListeners(){const{hls:t}=this;t.off(l.MANIFEST_LOADING,this.onManifestLoading,this),t.off(l.LEVEL_LOADING,this.onLevelLoading,this),t.off(l.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),t.off(l.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this),t.off(l.LEVELS_UPDATED,this.onLevelsUpdated,this)}createInternalLoader(t){const e=this.hls.config,i=e.pLoader,s=e.loader,n=new(i||s)(e);return this.loaders[t.type]=n,n}getInternalLoader(t){return this.loaders[t.type]}resetInternalLoader(t){this.loaders[t]&&delete this.loaders[t]}destroyInternalLoaders(){for(const t in this.loaders){const e=this.loaders[t];e&&e.destroy(),this.resetInternalLoader(t)}}destroy(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()}onManifestLoading(t,e){const{url:i}=e;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:c,url:i,deliveryDirectives:null,levelOrTrack:null})}onLevelLoading(t,e){const{id:i,level:s,pathwayId:n,url:r,deliveryDirectives:a,levelInfo:o}=e;this.load({id:i,level:s,pathwayId:n,responseType:"text",type:u,url:r,deliveryDirectives:a,levelOrTrack:o})}onAudioTrackLoading(t,e){const{id:i,groupId:s,url:n,deliveryDirectives:r,track:a}=e;this.load({id:i,groupId:s,level:null,responseType:"text",type:d,url:n,deliveryDirectives:r,levelOrTrack:a})}onSubtitleTrackLoading(t,e){const{id:i,groupId:s,url:n,deliveryDirectives:r,track:a}=e;this.load({id:i,groupId:s,level:null,responseType:"text",type:h,url:n,deliveryDirectives:r,levelOrTrack:a})}onLevelsUpdated(t,e){const i=this.loaders[u];if(i){const t=i.context;t&&!e.levels.some((e=>e===t.levelOrTrack))&&(i.abort(),delete this.loaders[u])}}load(t){var e;const i=this.hls.config;let n,r=this.getInternalLoader(t);if(r){const e=this.hls.logger,i=r.context;if(i&&i.levelOrTrack===t.levelOrTrack&&(i.url===t.url||i.deliveryDirectives&&!t.deliveryDirectives))return void(i.url===t.url?e.log(`[playlist-loader]: ignore ${t.url} ongoing request`):e.log(`[playlist-loader]: ignore ${t.url} in favor of ${i.url}`));e.log(`[playlist-loader]: aborting previous loader for type: ${t.type}`),r.abort()}if(n=t.type===c?i.manifestLoadPolicy.default:b({},i.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),r=this.createInternalLoader(t),s(null==(e=t.deliveryDirectives)?void 0:e.part)){let e;if(t.type===u&&null!==t.level?e=this.hls.levels[t.level].details:t.type===d&&null!==t.id?e=this.hls.audioTracks[t.id].details:t.type===h&&null!==t.id&&(e=this.hls.subtitleTracks[t.id].details),e){const t=e.partTarget,i=e.targetduration;if(t&&i){const e=1e3*Math.max(3*t,.8*i);n=b({},n,{maxTimeToFirstByteMs:Math.min(e,n.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(e,n.maxTimeToFirstByteMs)})}}}const a=n.errorRetry||n.timeoutRetry||{},o={loadPolicy:n,timeout:n.maxLoadTimeMs,maxRetry:a.maxNumRetry||0,retryDelay:a.retryDelayMs||0,maxRetryDelay:a.maxRetryDelayMs||0},l={onSuccess:(t,e,i,s)=>{const n=this.getInternalLoader(i);this.resetInternalLoader(i.type);const r=t.data;0===r.indexOf("#EXTM3U")?(e.parsing.start=performance.now(),mi.isMediaPlaylist(r)||i.type!==c?this.handleTrackOrLevelPlaylist(t,e,i,s||null,n):this.handleMasterPlaylist(t,e,i,s)):this.handleManifestParsingError(t,i,new Error("no EXTM3U delimiter"),s||null,e)},onError:(t,e,i,s)=>{this.handleNetworkError(e,i,!1,t,s)},onTimeout:(t,e,i)=>{this.handleNetworkError(e,i,!0,void 0,t)}};r.load(t,o,l)}checkAutostartLoad(){if(!this.hls)return;const{config:{autoStartLoad:t,startPosition:e},forceStartLoad:i}=this.hls;(t||i)&&(this.hls.logger.log(`${t?"auto":"force"} startLoad with configured startPosition ${e}`),this.hls.startLoad(e))}handleMasterPlaylist(t,e,i,s){const n=this.hls,r=t.data,a=to(t,i),o=mi.parseMasterPlaylist(r,a);if(o.playlistParsingError)return void this.handleManifestParsingError(t,i,o.playlistParsingError,s,e);const{contentSteering:c,levels:u,sessionData:d,sessionKeys:h,startTimeOffset:f,variableList:p}=o;this.variableList=p;const{AUDIO:g=[],SUBTITLES:m,"CLOSED-CAPTIONS":y}=mi.parseMasterPlaylistMedia(r,a,o);g.length&&(g.some((t=>!t.url))||!u[0].audioCodec||u[0].attrs.AUDIO||(this.hls.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),g.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new Ge({}),bitrate:0,url:""}))),n.trigger(l.MANIFEST_LOADED,{levels:u,audioTracks:g,subtitles:m,captions:y,contentSteering:c,url:a,stats:e,networkDetails:s,sessionData:d,sessionKeys:h,startTimeOffset:f,variableList:p})}handleTrackOrLevelPlaylist(t,e,i,n,r){const a=this.hls,{id:o,level:u,type:d}=i,h=to(t,i),f=s(u)?u:s(o)?o:0,p=Za(i),g=mi.parseLevelPlaylist(t.data,h,f,p,0,this.variableList);if(d===c){const t={attrs:new Ge({}),bitrate:0,details:g,name:"",url:h};g.requestScheduled=e.loading.start+Pi(g,0),a.trigger(l.MANIFEST_LOADED,{levels:[t],audioTracks:[],url:h,stats:e,networkDetails:n,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}e.parsing.end=performance.now(),i.levelDetails=g,this.handlePlaylistLoaded(g,t,e,i,n,r)}handleManifestParsingError(t,e,i,s,n){this.hls.trigger(l.ERROR,{type:a.NETWORK_ERROR,details:o.MANIFEST_PARSING_ERROR,fatal:e.type===c,url:t.url,err:i,error:i,reason:i.message,response:t,context:e,networkDetails:s,stats:n})}handleNetworkError(t,e,i=!1,s,n){let r=`A network ${i?"timeout":"error"+(s?" (status "+s.code+")":"")} occurred while loading ${t.type}`;t.type===u?r+=`: ${t.level} id: ${t.id}`:t.type!==d&&t.type!==h||(r+=` id: ${t.id} group-id: "${t.groupId}"`);const f=new Error(r);this.hls.logger.warn(`[playlist-loader]: ${r}`);let p=o.UNKNOWN,g=!1;const m=this.getInternalLoader(t);switch(t.type){case c:p=i?o.MANIFEST_LOAD_TIMEOUT:o.MANIFEST_LOAD_ERROR,g=!0;break;case u:p=i?o.LEVEL_LOAD_TIMEOUT:o.LEVEL_LOAD_ERROR,g=!1;break;case d:p=i?o.AUDIO_TRACK_LOAD_TIMEOUT:o.AUDIO_TRACK_LOAD_ERROR,g=!1;break;case h:p=i?o.SUBTITLE_TRACK_LOAD_TIMEOUT:o.SUBTITLE_LOAD_ERROR,g=!1}m&&this.resetInternalLoader(t.type);const y={type:a.NETWORK_ERROR,details:p,fatal:g,url:t.url,loader:m,context:t,error:f,networkDetails:e,stats:n};if(s){const i=(null==e?void 0:e.url)||t.url;y.response=E({url:i,data:void 0},s)}this.hls.trigger(l.ERROR,y)}handlePlaylistLoaded(t,e,i,s,n,r){const p=this.hls,{type:g,level:m,id:y,groupId:v,deliveryDirectives:b}=s,_=to(e,s),E=Za(s),T="number"==typeof s.level&&E===f?m:void 0;if(!t.fragments.length){const r=t.playlistParsingError=new Error("No Segments found in Playlist");return void p.trigger(l.ERROR,{type:a.NETWORK_ERROR,details:o.LEVEL_EMPTY_ERROR,fatal:!1,url:_,error:r,reason:r.message,response:e,context:s,level:T,parent:E,networkDetails:n,stats:i})}t.targetduration||(t.playlistParsingError=new Error("Missing Target Duration"));const S=t.playlistParsingError;if(S){if(this.hls.logger.warn(S),!p.config.ignorePlaylistParsingErrors)return void p.trigger(l.ERROR,{type:a.NETWORK_ERROR,details:o.LEVEL_PARSING_ERROR,fatal:!1,url:_,error:S,reason:S.message,response:e,context:s,level:T,parent:E,networkDetails:n,stats:i});t.playlistParsingError=null}switch(t.live&&r&&(r.getCacheAge&&(t.ageHeader=r.getCacheAge()||0),r.getCacheAge&&!isNaN(t.ageHeader)||(t.ageHeader=0)),g){case c:case u:p.trigger(l.LEVEL_LOADED,{details:t,levelInfo:s.levelOrTrack||p.levels[0],level:T||0,id:y||0,stats:i,networkDetails:n,deliveryDirectives:b,withoutMultiVariant:g===c});break;case d:p.trigger(l.AUDIO_TRACK_LOADED,{details:t,track:s.levelOrTrack,id:y||0,groupId:v||"",stats:i,networkDetails:n,deliveryDirectives:b});break;case h:p.trigger(l.SUBTITLE_TRACK_LOADED,{details:t,track:s.levelOrTrack,id:y||0,groupId:v||"",stats:i,networkDetails:n,deliveryDirectives:b})}}}class io{static get version(){return Xi}static isMSESupported(){return Xa()}static isSupported(){return function(){if(!Xa())return!1;const t=I();return"function"==typeof(null==t?void 0:t.isTypeSupported)&&(["avc1.42E01E,mp4a.40.2","av01.0.01M.08","vp09.00.50.08"].some((e=>t.isTypeSupported(Lt(e,"video"))))||["mp4a.40.2","fLaC"].some((e=>t.isTypeSupported(Lt(e,"audio")))))}()}static getMediaSource(){return I()}static get Events(){return l}static get MetadataSchema(){return Es}static get ErrorTypes(){return a}static get ErrorDetails(){return o}static get DefaultConfig(){return io.defaultConfig?io.defaultConfig:Fa}static set DefaultConfig(t){io.defaultConfig=t}constructor(t={}){this.config=void 0,this.userConfig=void 0,this.logger=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new Wi,this._autoLevelCapping=-1,this._maxHdcpLevel=null,this.abrController=void 0,this.bufferController=void 0,this.capLevelController=void 0,this.latencyController=void 0,this.levelController=void 0,this.streamController=void 0,this.audioStreamController=void 0,this.subtititleStreamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.interstitialsController=void 0,this.gapController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this._url=null,this._sessionId=void 0,this.triggeringException=void 0,this.started=!1;const e=this.logger=function(t,e,i){const s=w();if("object"==typeof console&&!0===t||"object"==typeof t){const e=["debug","log","info","warn","error"];e.forEach((e=>{s[e]=A(e,t,i)}));try{s.log('Debug logs enabled for "Hls instance" in hls.js version 1.6.1')}catch(t){return w()}e.forEach((e=>{R[e]=A(e,t)}))}else b(R,s);return s}(t.debug||!1,0,t.assetPlayerId),i=this.config=function(t,e,i){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(void 0!==e.liveMaxLatencyDurationCount&&(void 0===e.liveSyncDurationCount||e.liveMaxLatencyDurationCount<=e.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(void 0!==e.liveMaxLatencyDuration&&(void 0===e.liveSyncDuration||e.liveMaxLatencyDuration<=e.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');const s=$a(t),n=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return["manifest","level","frag"].forEach((t=>{const r=`${"level"===t?"playlist":t}LoadPolicy`,a=void 0===e[r],o=[];n.forEach((i=>{const n=`${t}Loading${i}`,l=e[n];if(void 0!==l&&a){o.push(n);const t=s[r].default;switch(e[r]={default:t},i){case"TimeOut":t.maxLoadTimeMs=l,t.maxTimeToFirstByteMs=l;break;case"MaxRetry":t.errorRetry.maxNumRetry=l,t.timeoutRetry.maxNumRetry=l;break;case"RetryDelay":t.errorRetry.retryDelayMs=l,t.timeoutRetry.retryDelayMs=l;break;case"MaxRetryTimeout":t.errorRetry.maxRetryDelayMs=l,t.timeoutRetry.maxRetryDelayMs=l}}})),o.length&&i.warn(`hls.js config: "${o.join('", "')}" setting(s) are deprecated, use "${r}": ${Wt(e[r])}`)})),E(E({},s),e)}(io.DefaultConfig,t,e);this.userConfig=t,i.progressive&&function(t,e){const i=t.loader;i!==xa&&i!==Ma?(e.log("[config]: Custom loader detected, cannot enable progressive streaming"),t.progressive=!1):function(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch(t){}return!1}()&&(t.loader=xa,t.progressive=!0,t.enableSoftwareAES=!0,e.log("[config]: Progressive streaming enabled, using FetchLoader"))}(i,e);const{abrController:s,bufferController:n,capLevelController:r,errorController:a,fpsController:o}=i,c=new a(this),u=this.abrController=new s(this),d=new be(this),h=i.interstitialsController,f=h?this.interstitialsController=new h(this,io):null,p=this.bufferController=new n(this,d),g=this.capLevelController=new r(this),m=new o(this),y=new eo(this),v=i.contentSteeringController,_=v?new v(this):null,T=this.levelController=new qa(this,_),S=new Ka(this),k=new Qa(this.config),L=this.streamController=new Ja(this,d,k),I=this.gapController=new Ua(this,d);g.setStreamController(L),m.setStreamController(L);const C=[y,T,L];f&&C.splice(1,0,f),_&&C.splice(1,0,_),this.networkControllers=C;const D=[u,p,I,g,m,S,d];this.audioTrackController=this.createController(i.audioTrackController,C);const x=i.audioStreamController;x&&C.push(this.audioStreamController=new x(this,d,k)),this.subtitleTrackController=this.createController(i.subtitleTrackController,C);const P=i.subtitleStreamController;P&&C.push(this.subtititleStreamController=new P(this,d,k)),this.createController(i.timelineController,D),k.emeController=this.emeController=this.createController(i.emeController,D),this.cmcdController=this.createController(i.cmcdController,D),this.latencyController=this.createController(Ya,D),this.coreComponents=D,C.push(c);const O=c.onErrorOut;"function"==typeof O&&this.on(l.ERROR,O,c),this.on(l.MANIFEST_LOADED,y.onManifestLoaded,y)}createController(t,e){if(t){const i=new t(this);return e&&e.push(i),i}return null}on(t,e,i=this){this._emitter.on(t,e,i)}once(t,e,i=this){this._emitter.once(t,e,i)}removeAllListeners(t){this._emitter.removeAllListeners(t)}off(t,e,i=this,s){this._emitter.off(t,e,i,s)}listeners(t){return this._emitter.listeners(t)}emit(t,e,i){return this._emitter.emit(t,e,i)}trigger(t,e){if(this.config.debug)return this.emit(t,t,e);try{return this.emit(t,t,e)}catch(e){if(this.logger.error("An internal error happened while handling event "+t+'. Error message: "'+e.message+'". Here is a stacktrace:',e),!this.triggeringException){this.triggeringException=!0;const i=t===l.ERROR;this.trigger(l.ERROR,{type:a.OTHER_ERROR,details:o.INTERNAL_EXCEPTION,fatal:i,event:t,error:e}),this.triggeringException=!1}}return!1}listenerCount(t){return this._emitter.listenerCount(t)}destroy(){this.logger.log("destroy"),this.trigger(l.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this._url=null,this.networkControllers.forEach((t=>t.destroy())),this.networkControllers.length=0,this.coreComponents.forEach((t=>t.destroy())),this.coreComponents.length=0;const t=this.config;t.xhrSetup=t.fetchSetup=void 0,this.userConfig=null}attachMedia(t){if(!t||"media"in t&&!t.media){const e=new Error(`attachMedia failed: invalid argument (${t})`);return void this.trigger(l.ERROR,{type:a.OTHER_ERROR,details:o.ATTACH_MEDIA_ERROR,fatal:!0,error:e})}this.logger.log("attachMedia"),this._media&&(this.logger.warn("media must be detached before attaching"),this.detachMedia());const e="media"in t,i=e?t.media:t,s=e?t:{media:i};this._media=i,this.trigger(l.MEDIA_ATTACHING,s)}detachMedia(){this.logger.log("detachMedia"),this.trigger(l.MEDIA_DETACHING,{}),this._media=null}transferMedia(){this._media=null;const t=this.bufferController.transferMedia();return this.trigger(l.MEDIA_DETACHING,{transferMedia:t}),t}loadSource(t){this.stopLoad();const e=this.media,i=this._url,s=this._url=j.buildAbsoluteURL(self.location.href,t,{alwaysNormalize:!0});this._autoLevelCapping=-1,this._maxHdcpLevel=null,this.logger.log(`loadSource:${s}`),e&&i&&(i!==s||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(e)),this.trigger(l.MANIFEST_LOADING,{url:t})}get url(){return this._url}get hasEnoughToStart(){return this.streamController.hasEnoughToStart}get startPosition(){return this.streamController.startPositionValue}startLoad(t=-1,e){this.logger.log(`startLoad(${t+(e?", ":"")})`),this.started=!0,this.resumeBuffering();for(let i=0;i{t.resumeBuffering&&t.resumeBuffering()})))}pauseBuffering(){this.bufferingEnabled&&(this.logger.log("pause buffering"),this.networkControllers.forEach((t=>{t.pauseBuffering&&t.pauseBuffering()})))}get inFlightFragments(){const t={[f]:this.streamController.inFlightFrag};return this.audioStreamController&&(t[p]=this.audioStreamController.inFlightFrag),this.subtititleStreamController&&(t[g]=this.subtititleStreamController.inFlightFrag),t}swapAudioCodec(){this.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()}recoverMediaError(){this.logger.log("recoverMediaError");const t=this._media,e=null==t?void 0:t.currentTime;this.detachMedia(),t&&(this.attachMedia(t),e&&this.startLoad(e))}removeLevel(t){this.levelController.removeLevel(t)}get sessionId(){let t=this._sessionId;return t||(t=this._sessionId=function(){try{return crypto.randomUUID()}catch(t){try{const t=URL.createObjectURL(new Blob),e=t.toString();return URL.revokeObjectURL(t),e.slice(e.lastIndexOf("/")+1)}catch(t){let e=(new Date).getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(t=>{const i=(e+16*Math.random())%16|0;return e=Math.floor(e/16),("x"==t?i:3&i|8).toString(16)}))}}}()),t}get levels(){return this.levelController.levels||[]}get latestLevelDetails(){return this.streamController.getLevelDetails()||null}get loadLevelObj(){return this.levelController.loadLevelObj}get currentLevel(){return this.streamController.currentLevel}set currentLevel(t){this.logger.log(`set currentLevel:${t}`),this.levelController.manualLevel=t,this.streamController.immediateLevelSwitch()}get nextLevel(){return this.streamController.nextLevel}set nextLevel(t){this.logger.log(`set nextLevel:${t}`),this.levelController.manualLevel=t,this.streamController.nextLevelSwitch()}get loadLevel(){return this.levelController.level}set loadLevel(t){this.logger.log(`set loadLevel:${t}`),this.levelController.manualLevel=t}get nextLoadLevel(){return this.levelController.nextLoadLevel}set nextLoadLevel(t){this.levelController.nextLoadLevel=t}get firstLevel(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)}set firstLevel(t){this.logger.log(`set firstLevel:${t}`),this.levelController.firstLevel=t}get startLevel(){const t=this.levelController.startLevel;return-1===t&&this.abrController.forcedAutoLevel>-1?this.abrController.forcedAutoLevel:t}set startLevel(t){this.logger.log(`set startLevel:${t}`),-1!==t&&(t=Math.max(t,this.minAutoLevel)),this.levelController.startLevel=t}get capLevelToPlayerSize(){return this.config.capLevelToPlayerSize}set capLevelToPlayerSize(t){const e=!!t;e!==this.config.capLevelToPlayerSize&&(e?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=e)}get autoLevelCapping(){return this._autoLevelCapping}get bandwidthEstimate(){const{bwEstimator:t}=this.abrController;return t?t.getEstimate():NaN}set bandwidthEstimate(t){this.abrController.resetEstimator(t)}get abrEwmaDefaultEstimate(){const{bwEstimator:t}=this.abrController;return t?t.defaultEstimate:NaN}get ttfbEstimate(){const{bwEstimator:t}=this.abrController;return t?t.getEstimateTTFB():NaN}set autoLevelCapping(t){this._autoLevelCapping!==t&&(this.logger.log(`set autoLevelCapping:${t}`),this._autoLevelCapping=t,this.levelController.checkMaxAutoUpdated())}get maxHdcpLevel(){return this._maxHdcpLevel}set maxHdcpLevel(t){(function(t){return Vt.indexOf(t)>-1})(t)&&this._maxHdcpLevel!==t&&(this._maxHdcpLevel=t,this.levelController.checkMaxAutoUpdated())}get autoLevelEnabled(){return-1===this.levelController.manualLevel}get manualLevel(){return this.levelController.manualLevel}get minAutoLevel(){const{levels:t,config:{minAutoBitrate:e}}=this;if(!t)return 0;const i=t.length;for(let s=0;s=e)return s;return 0}get maxAutoLevel(){const{levels:t,autoLevelCapping:e,maxHdcpLevel:i}=this;let s;if(s=-1===e&&null!=t&&t.length?t.length-1:e,i)for(let e=s;e--;){const s=t[e].attrs["HDCP-LEVEL"];if(s&&s<=i)return e}return s}get firstAutoLevel(){return this.abrController.firstAutoLevel}get nextAutoLevel(){return this.abrController.nextAutoLevel}set nextAutoLevel(t){this.abrController.nextAutoLevel=t}get playingDate(){return this.streamController.currentProgramDateTime}get mainForwardBufferInfo(){return this.streamController.getMainFwdBufferInfo()}get maxBufferLength(){return this.streamController.maxBufferLength}setAudioOption(t){var e;return(null==(e=this.audioTrackController)?void 0:e.setAudioOption(t))||null}setSubtitleOption(t){var e;return(null==(e=this.subtitleTrackController)?void 0:e.setSubtitleOption(t))||null}get allAudioTracks(){const t=this.audioTrackController;return t?t.allAudioTracks:[]}get audioTracks(){const t=this.audioTrackController;return t?t.audioTracks:[]}get audioTrack(){const t=this.audioTrackController;return t?t.audioTrack:-1}set audioTrack(t){const e=this.audioTrackController;e&&(e.audioTrack=t)}get allSubtitleTracks(){const t=this.subtitleTrackController;return t?t.allSubtitleTracks:[]}get subtitleTracks(){const t=this.subtitleTrackController;return t?t.subtitleTracks:[]}get subtitleTrack(){const t=this.subtitleTrackController;return t?t.subtitleTrack:-1}get media(){return this._media}set subtitleTrack(t){const e=this.subtitleTrackController;e&&(e.subtitleTrack=t)}get subtitleDisplay(){const t=this.subtitleTrackController;return!!t&&t.subtitleDisplay}set subtitleDisplay(t){const e=this.subtitleTrackController;e&&(e.subtitleDisplay=t)}get lowLatencyMode(){return this.config.lowLatencyMode}set lowLatencyMode(t){this.config.lowLatencyMode=t}get liveSyncPosition(){return this.latencyController.liveSyncPosition}get latency(){return this.latencyController.latency}get maxLatency(){return this.latencyController.maxLatency}get targetLatency(){return this.latencyController.targetLatency}set targetLatency(t){this.latencyController.targetLatency=t}get drift(){return this.latencyController.drift}get forceStartLoad(){return this.streamController.forceStartLoad}get pathways(){return this.levelController.pathways}get pathwayPriority(){return this.levelController.pathwayPriority}set pathwayPriority(t){this.levelController.pathwayPriority=t}get bufferedToEnd(){var t;return!(null==(t=this.bufferController)||!t.bufferedToEnd)}get interstitialsManager(){var t;return(null==(t=this.interstitialsController)?void 0:t.interstitialsManager)||null}getMediaDecodingInfo(t,e=this.allAudioTracks){return Gt(t,Jt(e),navigator.mediaCapabilities)}}io.defaultConfig=void 0},5132:(t,e,i)=>{"use strict";i.d(e,{ZP:()=>St});var s={};i.r(s),i.d(s,{Decoder:()=>gt,Encoder:()=>ft,PacketType:()=>ht,protocol:()=>dt});const n=Object.create(null);n.open="0",n.close="1",n.ping="2",n.pong="3",n.message="4",n.upgrade="5",n.noop="6";const r=Object.create(null);Object.keys(n).forEach((t=>{r[n[t]]=t}));const a={type:"error",data:"parser error"},o="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===Object.prototype.toString.call(Blob),l="function"==typeof ArrayBuffer,c=t=>"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(t):t&&t.buffer instanceof ArrayBuffer,u=({type:t,data:e},i,s)=>o&&e instanceof Blob?i?s(e):d(e,s):l&&(e instanceof ArrayBuffer||c(e))?i?s(e):d(new Blob([e]),s):s(n[t]+(e||"")),d=(t,e)=>{const i=new FileReader;return i.onload=function(){const t=i.result.split(",")[1];e("b"+(t||""))},i.readAsDataURL(t)};function h(t){return t instanceof Uint8Array?t:t instanceof ArrayBuffer?new Uint8Array(t):new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}let f;const p="undefined"==typeof Uint8Array?[]:new Uint8Array(256);for(let t=0;t<64;t++)p["ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charCodeAt(t)]=t;const g="function"==typeof ArrayBuffer,m=(t,e)=>{if("string"!=typeof t)return{type:"message",data:v(t,e)};const i=t.charAt(0);return"b"===i?{type:"message",data:y(t.substring(1),e)}:r[i]?t.length>1?{type:r[i],data:t.substring(1)}:{type:r[i]}:a},y=(t,e)=>{if(g){const i=(t=>{let e,i,s,n,r,a=.75*t.length,o=t.length,l=0;"="===t[t.length-1]&&(a--,"="===t[t.length-2]&&a--);const c=new ArrayBuffer(a),u=new Uint8Array(c);for(e=0;e>4,u[l++]=(15&s)<<4|n>>2,u[l++]=(3&n)<<6|63&r;return c})(t);return v(i,e)}return{base64:!0,data:t}},v=(t,e)=>"blob"===e?t instanceof Blob?t:new Blob([t]):t instanceof ArrayBuffer?t:t.buffer,b=String.fromCharCode(30);let _;function E(t){return t.reduce(((t,e)=>t+e.length),0)}function T(t,e){if(t[0].length===e)return t.shift();const i=new Uint8Array(e);let s=0;for(let n=0;n(t.hasOwnProperty(i)&&(e[i]=t[i]),e)),{})}const A=k.setTimeout,R=k.clearTimeout;function L(t,e){e.useNativeTimers?(t.setTimeoutFn=A.bind(k),t.clearTimeoutFn=R.bind(k)):(t.setTimeoutFn=k.setTimeout.bind(k),t.clearTimeoutFn=k.clearTimeout.bind(k))}var I=i(3859);class C extends Error{constructor(t,e,i){super(t),this.description=e,this.context=i,this.type="TransportError"}}class D extends S{constructor(t){super(),this.writable=!1,L(this,t),this.opts=t,this.query=t.query,this.socket=t.socket}onError(t,e,i){return super.emitReserved("error",new C(t,e,i)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return"opening"!==this.readyState&&"open"!==this.readyState||(this.doClose(),this.onClose()),this}send(t){"open"===this.readyState&&this.write(t)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(t){const e=m(t,this.socket.binaryType);this.onPacket(e)}onPacket(t){super.emitReserved("packet",t)}onClose(t){this.readyState="closed",super.emitReserved("close",t)}pause(t){}createUri(t,e={}){return t+"://"+this._hostname()+this._port()+this.opts.path+this._query(e)}_hostname(){const t=this.opts.hostname;return-1===t.indexOf(":")?t:"["+t+"]"}_port(){return this.opts.port&&(this.opts.secure&&Number(443!==this.opts.port)||!this.opts.secure&&80!==Number(this.opts.port))?":"+this.opts.port:""}_query(t){const e=(0,I.c)(t);return e.length?"?"+e:""}}const x="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),P=64,O={};let N,M=0,F=0;function $(t){let e="";do{e=x[t%P]+e,t=Math.floor(t/P)}while(t>0);return e}function U(){const t=$(+new Date);return t!==N?(M=0,N=t):t+"."+$(M++)}for(;F{var t;3===i.readyState&&(null===(t=this.opts.cookieJar)||void 0===t||t.parseCookies(i)),4===i.readyState&&(200===i.status||1223===i.status?this.onLoad():this.setTimeoutFn((()=>{this.onError("number"==typeof i.status?i.status:0)}),0))},i.send(this.data)}catch(t){return void this.setTimeoutFn((()=>{this.onError(t)}),0)}"undefined"!=typeof document&&(this.index=K.requestsCount++,K.requests[this.index]=this)}onError(t){this.emitReserved("error",t,this.xhr),this.cleanup(!0)}cleanup(t){if(void 0!==this.xhr&&null!==this.xhr){if(this.xhr.onreadystatechange=V,t)try{this.xhr.abort()}catch(t){}"undefined"!=typeof document&&delete K.requests[this.index],this.xhr=null}}onLoad(){const t=this.xhr.responseText;null!==t&&(this.emitReserved("data",t),this.emitReserved("success"),this.cleanup())}abort(){this.cleanup()}}function Y(){for(let t in K.requests)K.requests.hasOwnProperty(t)&&K.requests[t].abort()}K.requestsCount=0,K.requests={},"undefined"!=typeof document&&("function"==typeof attachEvent?attachEvent("onunload",Y):"function"==typeof addEventListener&&addEventListener("onpagehide"in k?"pagehide":"unload",Y,!1));const q="function"==typeof Promise&&"function"==typeof Promise.resolve?t=>Promise.resolve().then(t):(t,e)=>e(t,0),z=k.WebSocket||k.MozWebSocket,W="undefined"!=typeof navigator&&"string"==typeof navigator.product&&"reactnative"===navigator.product.toLowerCase(),X={websocket:class extends D{constructor(t){super(t),this.supportsBinary=!t.forceBase64}get name(){return"websocket"}doOpen(){if(!this.check())return;const t=this.uri(),e=this.opts.protocols,i=W?{}:w(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(i.headers=this.opts.extraHeaders);try{this.ws=W?new z(t,e,i):e?new z(t,e):new z(t)}catch(t){return this.emitReserved("error",t)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=t=>this.onClose({description:"websocket connection closed",context:t}),this.ws.onmessage=t=>this.onData(t.data),this.ws.onerror=t=>this.onError("websocket error",t)}write(t){this.writable=!1;for(let e=0;e{try{this.ws.send(t)}catch(t){}s&&q((()=>{this.writable=!0,this.emitReserved("drain")}),this.setTimeoutFn)}))}}doClose(){void 0!==this.ws&&(this.ws.close(),this.ws=null)}uri(){const t=this.opts.secure?"wss":"ws",e=this.query||{};return this.opts.timestampRequests&&(e[this.opts.timestampParam]=U()),this.supportsBinary||(e.b64=1),this.createUri(t,e)}check(){return!!z}},webtransport:class extends D{get name(){return"webtransport"}doOpen(){"function"==typeof WebTransport&&(this.transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name]),this.transport.closed.then((()=>{this.onClose()})).catch((t=>{this.onError("webtransport error",t)})),this.transport.ready.then((()=>{this.transport.createBidirectionalStream().then((t=>{const e=function(t,e){_||(_=new TextDecoder);const i=[];let s=0,n=-1,r=!1;return new TransformStream({transform(o,l){for(i.push(o);;){if(0===s){if(E(i)<1)break;const t=T(i,1);r=128==(128&t[0]),n=127&t[0],s=n<126?3:126===n?1:2}else if(1===s){if(E(i)<2)break;const t=T(i,2);n=new DataView(t.buffer,t.byteOffset,t.length).getUint16(0),s=3}else if(2===s){if(E(i)<8)break;const t=T(i,8),e=new DataView(t.buffer,t.byteOffset,t.length),r=e.getUint32(0);if(r>Math.pow(2,21)-1){l.enqueue(a);break}n=r*Math.pow(2,32)+e.getUint32(4),s=3}else{if(E(i)t){l.enqueue(a);break}}}})}(Number.MAX_SAFE_INTEGER,this.socket.binaryType),i=t.readable.pipeThrough(e).getReader(),s=new TransformStream({transform(t,e){!function(t,e){o&&t.data instanceof Blob?t.data.arrayBuffer().then(h).then(e):l&&(t.data instanceof ArrayBuffer||c(t.data))?e(h(t.data)):u(t,!1,(t=>{f||(f=new TextEncoder),e(f.encode(t))}))}(t,(i=>{const s=i.length;let n;if(s<126)n=new Uint8Array(1),new DataView(n.buffer).setUint8(0,s);else if(s<65536){n=new Uint8Array(3);const t=new DataView(n.buffer);t.setUint8(0,126),t.setUint16(1,s)}else{n=new Uint8Array(9);const t=new DataView(n.buffer);t.setUint8(0,127),t.setBigUint64(1,BigInt(s))}t.data&&"string"!=typeof t.data&&(n[0]|=128),e.enqueue(n),e.enqueue(i)}))}});s.readable.pipeTo(t.writable),this.writer=s.writable.getWriter();const n=()=>{i.read().then((({done:t,value:e})=>{t||(this.onPacket(e),n())})).catch((t=>{}))};n();const r={type:"open"};this.query.sid&&(r.data=`{"sid":"${this.query.sid}"}`),this.writer.write(r).then((()=>this.onOpen()))}))})))}write(t){this.writable=!1;for(let e=0;e{s&&q((()=>{this.writable=!0,this.emitReserved("drain")}),this.setTimeoutFn)}))}}doClose(){var t;null===(t=this.transport)||void 0===t||t.close()}},polling:class extends D{constructor(t){if(super(t),this.polling=!1,"undefined"!=typeof location){const e="https:"===location.protocol;let i=location.port;i||(i=e?"443":"80"),this.xd="undefined"!=typeof location&&t.hostname!==location.hostname||i!==t.port}const e=t&&t.forceBase64;this.supportsBinary=H&&!e,this.opts.withCredentials&&(this.cookieJar=void 0)}get name(){return"polling"}doOpen(){this.poll()}pause(t){this.readyState="pausing";const e=()=>{this.readyState="paused",t()};if(this.polling||!this.writable){let t=0;this.polling&&(t++,this.once("pollComplete",(function(){--t||e()}))),this.writable||(t++,this.once("drain",(function(){--t||e()})))}else e()}poll(){this.polling=!0,this.doPoll(),this.emitReserved("poll")}onData(t){((t,e)=>{const i=t.split(b),s=[];for(let t=0;t{if("opening"===this.readyState&&"open"===t.type&&this.onOpen(),"close"===t.type)return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(t)})),"closed"!==this.readyState&&(this.polling=!1,this.emitReserved("pollComplete"),"open"===this.readyState&&this.poll())}doClose(){const t=()=>{this.write([{type:"close"}])};"open"===this.readyState?t():this.once("open",t)}write(t){this.writable=!1,((t,e)=>{const i=t.length,s=new Array(i);let n=0;t.forEach(((t,r)=>{u(t,!1,(t=>{s[r]=t,++n===i&&e(s.join(b))}))}))})(t,(t=>{this.doWrite(t,(()=>{this.writable=!0,this.emitReserved("drain")}))}))}uri(){const t=this.opts.secure?"https":"http",e=this.query||{};return!1!==this.opts.timestampRequests&&(e[this.opts.timestampParam]=U()),this.supportsBinary||e.sid||(e.b64=1),this.createUri(t,e)}request(t={}){return Object.assign(t,{xd:this.xd,cookieJar:this.cookieJar},this.opts),new K(this.uri(),t)}doWrite(t,e){const i=this.request({method:"POST",data:t});i.on("success",e),i.on("error",((t,e)=>{this.onError("xhr post error",t,e)}))}doPoll(){const t=this.request();t.on("data",this.onData.bind(this)),t.on("error",((t,e)=>{this.onError("xhr poll error",t,e)})),this.pollXhr=t}}};var J=i(1928);class Q extends S{constructor(t,e={}){super(),this.binaryType="arraybuffer",this.writeBuffer=[],t&&"object"==typeof t&&(e=t,t=null),t?(t=(0,J.Q)(t),e.hostname=t.host,e.secure="https"===t.protocol||"wss"===t.protocol,e.port=t.port,t.query&&(e.query=t.query)):e.host&&(e.hostname=(0,J.Q)(e.host).host),L(this,e),this.secure=null!=e.secure?e.secure:"undefined"!=typeof location&&"https:"===location.protocol,e.hostname&&!e.port&&(e.port=this.secure?"443":"80"),this.hostname=e.hostname||("undefined"!=typeof location?location.hostname:"localhost"),this.port=e.port||("undefined"!=typeof location&&location.port?location.port:this.secure?"443":"80"),this.transports=e.transports||["polling","websocket","webtransport"],this.writeBuffer=[],this.prevBufferLen=0,this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},e),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),"string"==typeof this.opts.query&&(this.opts.query=(0,I.J)(this.opts.query)),this.id=null,this.upgrades=null,this.pingInterval=null,this.pingTimeout=null,this.pingTimeoutTimer=null,"function"==typeof addEventListener&&(this.opts.closeOnBeforeunload&&(this.beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this.beforeunloadEventListener,!1)),"localhost"!==this.hostname&&(this.offlineEventListener=()=>{this.onClose("transport close",{description:"network connection lost"})},addEventListener("offline",this.offlineEventListener,!1))),this.open()}createTransport(t){const e=Object.assign({},this.opts.query);e.EIO=4,e.transport=t,this.id&&(e.sid=this.id);const i=Object.assign({},this.opts,{query:e,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[t]);return new X[t](i)}open(){let t;if(this.opts.rememberUpgrade&&Q.priorWebsocketSuccess&&-1!==this.transports.indexOf("websocket"))t="websocket";else{if(0===this.transports.length)return void this.setTimeoutFn((()=>{this.emitReserved("error","No transports available")}),0);t=this.transports[0]}this.readyState="opening";try{t=this.createTransport(t)}catch(t){return this.transports.shift(),void this.open()}t.open(),this.setTransport(t)}setTransport(t){this.transport&&this.transport.removeAllListeners(),this.transport=t,t.on("drain",this.onDrain.bind(this)).on("packet",this.onPacket.bind(this)).on("error",this.onError.bind(this)).on("close",(t=>this.onClose("transport close",t)))}probe(t){let e=this.createTransport(t),i=!1;Q.priorWebsocketSuccess=!1;const s=()=>{i||(e.send([{type:"ping",data:"probe"}]),e.once("packet",(t=>{if(!i)if("pong"===t.type&&"probe"===t.data){if(this.upgrading=!0,this.emitReserved("upgrading",e),!e)return;Q.priorWebsocketSuccess="websocket"===e.name,this.transport.pause((()=>{i||"closed"!==this.readyState&&(c(),this.setTransport(e),e.send([{type:"upgrade"}]),this.emitReserved("upgrade",e),e=null,this.upgrading=!1,this.flush())}))}else{const t=new Error("probe error");t.transport=e.name,this.emitReserved("upgradeError",t)}})))};function n(){i||(i=!0,c(),e.close(),e=null)}const r=t=>{const i=new Error("probe error: "+t);i.transport=e.name,n(),this.emitReserved("upgradeError",i)};function a(){r("transport closed")}function o(){r("socket closed")}function l(t){e&&t.name!==e.name&&n()}const c=()=>{e.removeListener("open",s),e.removeListener("error",r),e.removeListener("close",a),this.off("close",o),this.off("upgrading",l)};e.once("open",s),e.once("error",r),e.once("close",a),this.once("close",o),this.once("upgrading",l),-1!==this.upgrades.indexOf("webtransport")&&"webtransport"!==t?this.setTimeoutFn((()=>{i||e.open()}),200):e.open()}onOpen(){if(this.readyState="open",Q.priorWebsocketSuccess="websocket"===this.transport.name,this.emitReserved("open"),this.flush(),"open"===this.readyState&&this.opts.upgrade){let t=0;const e=this.upgrades.length;for(;t{this.onClose("ping timeout")}),this.pingInterval+this.pingTimeout),this.opts.autoUnref&&this.pingTimeoutTimer.unref()}onDrain(){this.writeBuffer.splice(0,this.prevBufferLen),this.prevBufferLen=0,0===this.writeBuffer.length?this.emitReserved("drain"):this.flush()}flush(){if("closed"!==this.readyState&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const t=this.getWritablePackets();this.transport.send(t),this.prevBufferLen=t.length,this.emitReserved("flush")}}getWritablePackets(){if(!(this.maxPayload&&"polling"===this.transport.name&&this.writeBuffer.length>1))return this.writeBuffer;let t=1;for(let i=0;i=57344?i+=3:(s++,i+=4);return i}(e):Math.ceil(1.33*(e.byteLength||e.size))),i>0&&t>this.maxPayload)return this.writeBuffer.slice(0,i);t+=2}var e;return this.writeBuffer}write(t,e,i){return this.sendPacket("message",t,e,i),this}send(t,e,i){return this.sendPacket("message",t,e,i),this}sendPacket(t,e,i,s){if("function"==typeof e&&(s=e,e=void 0),"function"==typeof i&&(s=i,i=null),"closing"===this.readyState||"closed"===this.readyState)return;(i=i||{}).compress=!1!==i.compress;const n={type:t,data:e,options:i};this.emitReserved("packetCreate",n),this.writeBuffer.push(n),s&&this.once("flush",s),this.flush()}close(){const t=()=>{this.onClose("forced close"),this.transport.close()},e=()=>{this.off("upgrade",e),this.off("upgradeError",e),t()},i=()=>{this.once("upgrade",e),this.once("upgradeError",e)};return"opening"!==this.readyState&&"open"!==this.readyState||(this.readyState="closing",this.writeBuffer.length?this.once("drain",(()=>{this.upgrading?i():t()})):this.upgrading?i():t()),this}onError(t){Q.priorWebsocketSuccess=!1,this.emitReserved("error",t),this.onClose("transport error",t)}onClose(t,e){"opening"!==this.readyState&&"open"!==this.readyState&&"closing"!==this.readyState||(this.clearTimeoutFn(this.pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),"function"==typeof removeEventListener&&(removeEventListener("beforeunload",this.beforeunloadEventListener,!1),removeEventListener("offline",this.offlineEventListener,!1)),this.readyState="closed",this.id=null,this.emitReserved("close",t,e),this.writeBuffer=[],this.prevBufferLen=0)}filterUpgrades(t){const e=[];let i=0;const s=t.length;for(;i"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(t):t.buffer instanceof ArrayBuffer,et=Object.prototype.toString,it="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===et.call(Blob),st="function"==typeof File||"undefined"!=typeof File&&"[object FileConstructor]"===et.call(File);function nt(t){return Z&&(t instanceof ArrayBuffer||tt(t))||it&&t instanceof Blob||st&&t instanceof File}function rt(t,e){if(!t||"object"!=typeof t)return!1;if(Array.isArray(t)){for(let e=0,i=t.length;e=0&&t.num{delete this.acks[t];for(let e=0;e{this.io.clearTimeoutFn(n),e.apply(this,[null,...t])}}emitWithAck(t,...e){const i=void 0!==this.flags.timeout||void 0!==this._opts.ackTimeout;return new Promise(((s,n)=>{e.push(((t,e)=>i?t?n(t):s(e):s(t))),this.emit(t,...e)}))}_addToQueue(t){let e;"function"==typeof t[t.length-1]&&(e=t.pop());const i={id:this._queueSeq++,tryCount:0,pending:!1,args:t,flags:Object.assign({fromQueue:!0},this.flags)};t.push(((t,...s)=>{if(i===this._queue[0])return null!==t?i.tryCount>this._opts.retries&&(this._queue.shift(),e&&e(t)):(this._queue.shift(),e&&e(null,...s)),i.pending=!1,this._drainQueue()})),this._queue.push(i),this._drainQueue()}_drainQueue(t=!1){if(!this.connected||0===this._queue.length)return;const e=this._queue[0];e.pending&&!t||(e.pending=!0,e.tryCount++,this.flags=e.flags,this.emit.apply(this,e.args))}packet(t){t.nsp=this.nsp,this.io._packet(t)}onopen(){"function"==typeof this.auth?this.auth((t=>{this._sendConnectPacket(t)})):this._sendConnectPacket(this.auth)}_sendConnectPacket(t){this.packet({type:ht.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},t):t})}onerror(t){this.connected||this.emitReserved("connect_error",t)}onclose(t,e){this.connected=!1,delete this.id,this.emitReserved("disconnect",t,e)}onpacket(t){if(t.nsp===this.nsp)switch(t.type){case ht.CONNECT:t.data&&t.data.sid?this.onconnect(t.data.sid,t.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case ht.EVENT:case ht.BINARY_EVENT:this.onevent(t);break;case ht.ACK:case ht.BINARY_ACK:this.onack(t);break;case ht.DISCONNECT:this.ondisconnect();break;case ht.CONNECT_ERROR:this.destroy();const e=new Error(t.data.message);e.data=t.data.data,this.emitReserved("connect_error",e)}}onevent(t){const e=t.data||[];null!=t.id&&e.push(this.ack(t.id)),this.connected?this.emitEvent(e):this.receiveBuffer.push(Object.freeze(e))}emitEvent(t){if(this._anyListeners&&this._anyListeners.length){const e=this._anyListeners.slice();for(const i of e)i.apply(this,t)}super.emit.apply(this,t),this._pid&&t.length&&"string"==typeof t[t.length-1]&&(this._lastOffset=t[t.length-1])}ack(t){const e=this;let i=!1;return function(...s){i||(i=!0,e.packet({type:ht.ACK,id:t,data:s}))}}onack(t){const e=this.acks[t.id];"function"==typeof e&&(e.apply(this,t.data),delete this.acks[t.id])}onconnect(t,e){this.id=t,this.recovered=e&&this._pid===e,this._pid=e,this.connected=!0,this.emitBuffered(),this.emitReserved("connect"),this._drainQueue(!0)}emitBuffered(){this.receiveBuffer.forEach((t=>this.emitEvent(t))),this.receiveBuffer=[],this.sendBuffer.forEach((t=>{this.notifyOutgoingListeners(t),this.packet(t)})),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach((t=>t())),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:ht.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(t){return this.flags.compress=t,this}get volatile(){return this.flags.volatile=!0,this}timeout(t){return this.flags.timeout=t,this}onAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(t),this}prependAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(t),this}offAny(t){if(!this._anyListeners)return this;if(t){const e=this._anyListeners;for(let i=0;i0&&t.jitter<=1?t.jitter:0,this.attempts=0}_t.prototype.duration=function(){var t=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var e=Math.random(),i=Math.floor(e*this.jitter*t);t=0==(1&Math.floor(10*e))?t-i:t+i}return 0|Math.min(t,this.max)},_t.prototype.reset=function(){this.attempts=0},_t.prototype.setMin=function(t){this.ms=t},_t.prototype.setMax=function(t){this.max=t},_t.prototype.setJitter=function(t){this.jitter=t};class Et extends S{constructor(t,e){var i;super(),this.nsps={},this.subs=[],t&&"object"==typeof t&&(e=t,t=void 0),(e=e||{}).path=e.path||"/socket.io",this.opts=e,L(this,e),this.reconnection(!1!==e.reconnection),this.reconnectionAttempts(e.reconnectionAttempts||1/0),this.reconnectionDelay(e.reconnectionDelay||1e3),this.reconnectionDelayMax(e.reconnectionDelayMax||5e3),this.randomizationFactor(null!==(i=e.randomizationFactor)&&void 0!==i?i:.5),this.backoff=new _t({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(null==e.timeout?2e4:e.timeout),this._readyState="closed",this.uri=t;const n=e.parser||s;this.encoder=new n.Encoder,this.decoder=new n.Decoder,this._autoConnect=!1!==e.autoConnect,this._autoConnect&&this.open()}reconnection(t){return arguments.length?(this._reconnection=!!t,this):this._reconnection}reconnectionAttempts(t){return void 0===t?this._reconnectionAttempts:(this._reconnectionAttempts=t,this)}reconnectionDelay(t){var e;return void 0===t?this._reconnectionDelay:(this._reconnectionDelay=t,null===(e=this.backoff)||void 0===e||e.setMin(t),this)}randomizationFactor(t){var e;return void 0===t?this._randomizationFactor:(this._randomizationFactor=t,null===(e=this.backoff)||void 0===e||e.setJitter(t),this)}reconnectionDelayMax(t){var e;return void 0===t?this._reconnectionDelayMax:(this._reconnectionDelayMax=t,null===(e=this.backoff)||void 0===e||e.setMax(t),this)}timeout(t){return arguments.length?(this._timeout=t,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&0===this.backoff.attempts&&this.reconnect()}open(t){if(~this._readyState.indexOf("open"))return this;this.engine=new Q(this.uri,this.opts);const e=this.engine,i=this;this._readyState="opening",this.skipReconnect=!1;const s=(0,yt.on)(e,"open",(function(){i.onopen(),t&&t()})),n=e=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",e),t?t(e):this.maybeReconnectOnOpen()},r=(0,yt.on)(e,"error",n);if(!1!==this._timeout){const t=this._timeout,i=this.setTimeoutFn((()=>{s(),n(new Error("timeout")),e.close()}),t);this.opts.autoUnref&&i.unref(),this.subs.push((()=>{this.clearTimeoutFn(i)}))}return this.subs.push(s),this.subs.push(r),this}connect(t){return this.open(t)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const t=this.engine;this.subs.push((0,yt.on)(t,"ping",this.onping.bind(this)),(0,yt.on)(t,"data",this.ondata.bind(this)),(0,yt.on)(t,"error",this.onerror.bind(this)),(0,yt.on)(t,"close",this.onclose.bind(this)),(0,yt.on)(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(t){try{this.decoder.add(t)}catch(t){this.onclose("parse error",t)}}ondecoded(t){q((()=>{this.emitReserved("packet",t)}),this.setTimeoutFn)}onerror(t){this.emitReserved("error",t)}socket(t,e){let i=this.nsps[t];return i?this._autoConnect&&!i.active&&i.connect():(i=new bt(this,t,e),this.nsps[t]=i),i}_destroy(t){const e=Object.keys(this.nsps);for(const t of e)if(this.nsps[t].active)return;this._close()}_packet(t){const e=this.encoder.encode(t);for(let i=0;it())),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close"),this.engine&&this.engine.close()}disconnect(){return this._close()}onclose(t,e){this.cleanup(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",t,e),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const t=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const e=this.backoff.duration();this._reconnecting=!0;const i=this.setTimeoutFn((()=>{t.skipReconnect||(this.emitReserved("reconnect_attempt",t.backoff.attempts),t.skipReconnect||t.open((e=>{e?(t._reconnecting=!1,t.reconnect(),this.emitReserved("reconnect_error",e)):t.onreconnect()})))}),e);this.opts.autoUnref&&i.unref(),this.subs.push((()=>{this.clearTimeoutFn(i)}))}}onreconnect(){const t=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",t)}}const Tt={};function St(t,e){"object"==typeof t&&(e=t,t=void 0);const i=function(t,e="",i){let s=t;i=i||"undefined"!=typeof location&&location,null==t&&(t=i.protocol+"//"+i.host),"string"==typeof t&&("/"===t.charAt(0)&&(t="/"===t.charAt(1)?i.protocol+t:i.host+t),/^(https?|wss?):\/\//.test(t)||(t=void 0!==i?i.protocol+"//"+t:"https://"+t),s=(0,J.Q)(t)),s.port||(/^(http|ws)$/.test(s.protocol)?s.port="80":/^(http|ws)s$/.test(s.protocol)&&(s.port="443")),s.path=s.path||"/";const n=-1!==s.host.indexOf(":")?"["+s.host+"]":s.host;return s.id=s.protocol+"://"+n+":"+s.port+e,s.href=s.protocol+"://"+n+(i&&i.port===s.port?"":":"+s.port),s}(t,(e=e||{}).path||"/socket.io"),s=i.source,n=i.id,r=i.path,a=Tt[n]&&r in Tt[n].nsps;let o;return e.forceNew||e["force new connection"]||!1===e.multiplex||a?o=new Et(s,e):(Tt[n]||(Tt[n]=new Et(s,e)),o=Tt[n]),i.query&&!e.query&&(e.query=i.queryKey),o.socket(i.path,e)}Object.assign(St,{Manager:Et,Socket:bt,io:St,connect:St})},5901:(t,e,i)=>{"use strict";function s(t,e,i){return t.on(e,i),function(){t.off(e,i)}}i.d(e,{on:()=>s})}}]);