@namiml/web-sdk 3.4.6-dev.202607162357 → 3.4.6-dev.202607171421
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/nami-web.cjs +2 -3
- package/dist/nami-web.mjs +2 -3
- package/dist/nami-web.umd.js +3 -4
- package/package.json +2 -2
package/dist/nami-web.umd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).NamiWebSdk={})}(this,function(e){"use strict";function t(e,t){this.v=e,this.k=t}function n(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=Array(t);n<t;n++)i[n]=e[n];return i}function i(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function a(e){return new t(e,0)}function r(e,t,n){return t=v(t),b(e,g()?Reflect.construct(t,n||[],v(e).constructor):t.apply(e,n))}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function s(e,t){if(!{}.hasOwnProperty.call(e,t))throw new TypeError("attempted to use private field on non-instance");return e}(()=>{if("undefined"==typeof globalThis){var e="undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:Function("return this")();Object.defineProperty(e,"globalThis",{value:e,writable:!0,enumerable:!1,configurable:!0})}})(),"undefined"!=typeof Element&&"function"!=typeof Element.prototype.getAttributeNames&&(Element.prototype.getAttributeNames=function(){for(var e=this.attributes,t=new Array(e.length),n=0;n<e.length;n+=1)t[n]=e[n].name;return t});var u=0;function l(e){return"__private_"+u+++"_"+e}function d(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,_(i.key),i)}}function c(e,t,n){return t&&d(e.prototype,t),n&&d(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function h(e,t){var i="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(i)return(i=i.call(e)).next.bind(i);if(Array.isArray(e)||(i=function(e,t){if(e){if("string"==typeof e)return n(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?n(e,t):void 0}}(e))||t){i&&(e=i);var a=0;return function(){return a>=e.length?{done:!0}:{done:!1,value:e[a++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function m(){return m=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)({}).hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},m.apply(null,arguments)}function f(){return f="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,n){var i=function(e,t){for(;!{}.hasOwnProperty.call(e,t)&&null!==(e=v(e)););return e}(e,t);if(i){var a=Object.getOwnPropertyDescriptor(i,t);return a.get?a.get.call(arguments.length<3?e:n):a.value}},f.apply(null,arguments)}function v(e){return v=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},v(e)}function p(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&P(e,t)}function g(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(g=function(){return!!e})()}function y(e,t){if(null==e)return{};var n={};for(var i in e)if({}.hasOwnProperty.call(e,i)){if(-1!==t.indexOf(i))continue;n[i]=e[i]}return n}function b(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return i(e)}function w(){var e,t,n="function"==typeof Symbol?Symbol:{},i=n.iterator||"@@iterator",a=n.toStringTag||"@@toStringTag";function r(n,i,a,r){var u=i&&i.prototype instanceof s?i:s,l=Object.create(u.prototype);return E(l,"_invoke",function(n,i,a){var r,s,u,l=0,d=a||[],c=!1,h={p:0,n:0,v:e,a:m,f:m.bind(e,4),d:function(t,n){return r=t,s=0,u=e,h.n=n,o}};function m(n,i){for(s=n,u=i,t=0;!c&&l&&!a&&t<d.length;t++){var a,r=d[t],m=h.p,f=r[2];n>3?(a=f===i)&&(u=r[(s=r[4])?5:(s=3,3)],r[4]=r[5]=e):r[0]<=m&&((a=n<2&&m<r[1])?(s=0,h.v=i,h.n=r[1]):m<f&&(a=n<3||r[0]>i||i>f)&&(r[4]=n,r[5]=i,h.n=f,s=0))}if(a||n>1)return o;throw c=!0,i}return function(a,d,f){if(l>1)throw TypeError("Generator is already running");for(c&&1===d&&m(d,f),s=d,u=f;(t=s<2?e:u)||!c;){r||(s?s<3?(s>1&&(h.n=-1),m(s,u)):h.n=u:h.v=u);try{if(l=2,r){if(s||(a="next"),t=r[a]){if(!(t=t.call(r,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,s<2&&(s=0)}else 1===s&&(t=r.return)&&t.call(r),s<2&&(u=TypeError("The iterator does not provide a '"+a+"' method"),s=1);r=e}else if((t=(c=h.n<0)?u:n.call(i,h))!==o)break}catch(t){r=e,s=1,u=t}finally{l=1}}return{value:t,done:c}}}(n,a,r),!0),l}var o={};function s(){}function u(){}function l(){}t=Object.getPrototypeOf;var d=[][i]?t(t([][i]())):(E(t={},i,function(){return this}),t),c=l.prototype=s.prototype=Object.create(d);function h(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,l):(e.__proto__=l,E(e,a,"GeneratorFunction")),e.prototype=Object.create(c),e}return u.prototype=l,E(c,"constructor",l),E(l,"constructor",u),u.displayName="GeneratorFunction",E(l,a,"GeneratorFunction"),E(c),E(c,a,"Generator"),E(c,i,function(){return this}),E(c,"toString",function(){return"[object Generator]"}),(w=function(){return{w:r,m:h}})()}function k(e,t,n,i,a){var r=function(e,t,n,i,a){return new S(w().w(e,t,n,i),a||Promise)}(e,t,n,i,a);return r.next().then(function(e){return e.done?e.value:r.next()})}function S(e,n){function i(a,r,o,s){try{var u=e[a](r),l=u.value;return l instanceof t?n.resolve(l.v).then(function(e){i("next",e,o,s)},function(e){i("throw",e,o,s)}):n.resolve(l).then(function(e){u.value=e,o(u)},function(e){return i("throw",e,o,s)})}catch(e){s(e)}}var a;this.next||(E(S.prototype),E(S.prototype,"function"==typeof Symbol&&Symbol.asyncIterator||"@asyncIterator",function(){return this})),E(this,"_invoke",function(e,t,r){function o(){return new n(function(t,n){i(e,r,t,n)})}return a=a?a.then(o,o):o()},!0)}function E(e,t,n,i){var a=Object.defineProperty;try{a({},"",{})}catch(e){a=0}E=function(e,t,n,i){function r(t,n){E(e,t,function(e){return this._invoke(t,n,e)})}t?a?a(e,t,{value:n,enumerable:!i,configurable:!i,writable:!i}):e[t]=n:(r("next",0),r("throw",1),r("return",2))},E(e,t,n,i)}function P(e,t){return P=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},P(e,t)}function T(e,t,n,i){var a=f(v(e.prototype),t,n);return"function"==typeof a?function(e){return a.apply(n,e)}:a}function _(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,t);if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e,"string");return"symbol"==typeof t?t:t+""}function M(e){var t="function"==typeof Map?new Map:void 0;return M=function(e){if(null===e||!function(e){try{return-1!==Function.toString.call(e).indexOf("[native code]")}catch(t){return"function"==typeof e}}(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return function(e,t,n){if(g())return Reflect.construct.apply(null,arguments);var i=[null];i.push.apply(i,t);var a=new(e.bind.apply(e,i));return n&&P(a,n.prototype),a}(e,arguments,v(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),P(n,e)},M(e)}var A,D,x,C,I,L,R,F,O,$,N,W,j=function(){return c(function e(t){o(this,e),this.ariaActiveDescendantElement=null,this.ariaAtomic="",this.ariaAutoComplete="",this.ariaBrailleLabel="",this.ariaBrailleRoleDescription="",this.ariaBusy="",this.ariaChecked="",this.ariaColCount="",this.ariaColIndex="",this.ariaColIndexText="",this.ariaColSpan="",this.ariaControlsElements=null,this.ariaCurrent="",this.ariaDescribedByElements=null,this.ariaDescription="",this.ariaDetailsElements=null,this.ariaDisabled="",this.ariaErrorMessageElements=null,this.ariaExpanded="",this.ariaFlowToElements=null,this.ariaHasPopup="",this.ariaHidden="",this.ariaInvalid="",this.ariaKeyShortcuts="",this.ariaLabel="",this.ariaLabelledByElements=null,this.ariaLevel="",this.ariaLive="",this.ariaModal="",this.ariaMultiLine="",this.ariaMultiSelectable="",this.ariaOrientation="",this.ariaOwnsElements=null,this.ariaPlaceholder="",this.ariaPosInSet="",this.ariaPressed="",this.ariaReadOnly="",this.ariaRelevant="",this.ariaRequired="",this.ariaRoleDescription="",this.ariaRowCount="",this.ariaRowIndex="",this.ariaRowIndexText="",this.ariaRowSpan="",this.ariaSelected="",this.ariaSetSize="",this.ariaSort="",this.ariaValueMax="",this.ariaValueMin="",this.ariaValueNow="",this.ariaValueText="",this.role="",this.form=null,this.labels=[],this.states=new Set,this.validationMessage="",this.validity={},this.willValidate=!0,this.__host=t},[{key:"shadowRoot",get:function(){return this.__host.__shadowRoot}},{key:"checkValidity",value:function(){return console.warn("`ElementInternals.checkValidity()` was called on the server.This method always returns true."),!0}},{key:"reportValidity",value:function(){return!0}},{key:"setFormValue",value:function(){}},{key:"setValidity",value:function(){}}])}(),B=function(e,t,n,i,a){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!a)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!a:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?a.call(e,n):a?a.value=n:t.set(e,n),n},z=function(e,t,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(e):i?i.value:t.get(e)},U={__proto__:null,enumerable:!0};Object.freeze(U);var H=($=function(){return c(function e(t,n={}){if(o(this,e),A.set(this,!1),D.set(this,!1),x.set(this,!1),C.set(this,!1),I.set(this,Date.now()),L.set(this,!1),R.set(this,void 0),F.set(this,void 0),O.set(this,void 0),this.NONE=0,this.CAPTURING_PHASE=1,this.AT_TARGET=2,this.BUBBLING_PHASE=3,0===arguments.length)throw new Error("The type argument must be specified");if("object"!=typeof n||!n)throw new Error('The "options" argument must be an object');var i=n.bubbles,a=n.cancelable,r=n.composed;B(this,A,!!a,"f"),B(this,D,!!i,"f"),B(this,x,!!r,"f"),B(this,R,`${t}`,"f"),B(this,F,null,"f"),B(this,O,!1,"f")},[{key:"initEvent",value:function(e,t,n){throw new Error("Method not implemented.")}},{key:"stopImmediatePropagation",value:function(){this.stopPropagation()}},{key:"preventDefault",value:function(){B(this,C,!0,"f")}},{key:"target",get:function(){return z(this,F,"f")}},{key:"currentTarget",get:function(){return z(this,F,"f")}},{key:"srcElement",get:function(){return z(this,F,"f")}},{key:"type",get:function(){return z(this,R,"f")}},{key:"cancelable",get:function(){return z(this,A,"f")}},{key:"defaultPrevented",get:function(){return z(this,A,"f")&&z(this,C,"f")}},{key:"timeStamp",get:function(){return z(this,I,"f")}},{key:"composedPath",value:function(){return z(this,O,"f")?[z(this,F,"f")]:[]}},{key:"returnValue",get:function(){return!z(this,A,"f")||!z(this,C,"f")}},{key:"bubbles",get:function(){return z(this,D,"f")}},{key:"composed",get:function(){return z(this,x,"f")}},{key:"eventPhase",get:function(){return z(this,O,"f")?$.AT_TARGET:$.NONE}},{key:"cancelBubble",get:function(){return z(this,L,"f")},set:function(e){e&&B(this,L,!0,"f")}},{key:"stopPropagation",value:function(){B(this,L,!0,"f")}},{key:"isTrusted",get:function(){return!1}}])}(),A=new WeakMap,D=new WeakMap,x=new WeakMap,C=new WeakMap,I=new WeakMap,L=new WeakMap,R=new WeakMap,F=new WeakMap,O=new WeakMap,$.NONE=0,$.CAPTURING_PHASE=1,$.AT_TARGET=2,$.BUBBLING_PHASE=3,$);Object.defineProperties(H.prototype,{initEvent:U,stopImmediatePropagation:U,preventDefault:U,target:U,currentTarget:U,srcElement:U,type:U,cancelable:U,defaultPrevented:U,timeStamp:U,composedPath:U,returnValue:U,bubbles:U,composed:U,eventPhase:U,cancelBubble:U,stopPropagation:U,isTrusted:U});var G=(W=function(e){function t(e,n={}){var i,a;return o(this,t),a=r(this,t,[e,n]),N.set(a,void 0),B(a,N,null!==(i=null==n?void 0:n.detail)&&void 0!==i?i:null,"f"),a}return p(t,e),c(t,[{key:"initCustomEvent",value:function(e,t,n,i){throw new Error("Method not implemented.")}},{key:"detail",get:function(){return z(this,N,"f")}}])}(H),N=new WeakMap,W);Object.defineProperties(G.prototype,{detail:U});var V,K,X,Y,q=H,J=G;(V=function(){return c(function e(){o(this,e),this.STYLE_RULE=1,this.CHARSET_RULE=2,this.IMPORT_RULE=3,this.MEDIA_RULE=4,this.FONT_FACE_RULE=5,this.PAGE_RULE=6,this.NAMESPACE_RULE=10,this.KEYFRAMES_RULE=7,this.KEYFRAME_RULE=8,this.SUPPORTS_RULE=12,this.COUNTER_STYLE_RULE=11,this.FONT_FEATURE_VALUES_RULE=14,this.MARGIN_RULE=9,this.__parentStyleSheet=null,this.cssText=""},[{key:"parentRule",get:function(){return null}},{key:"parentStyleSheet",get:function(){return this.__parentStyleSheet}},{key:"type",get:function(){return 0}}])}()).STYLE_RULE=1,V.CHARSET_RULE=2,V.IMPORT_RULE=3,V.MEDIA_RULE=4,V.FONT_FACE_RULE=5,V.PAGE_RULE=6,V.NAMESPACE_RULE=10,V.KEYFRAMES_RULE=7,V.KEYFRAME_RULE=8,V.SUPPORTS_RULE=12,V.COUNTER_STYLE_RULE=11,V.FONT_FEATURE_VALUES_RULE=14,V.MARGIN_RULE=9,null!==(K=globalThis.Event)&&void 0!==K||(globalThis.Event=q),null!==(X=globalThis.CustomEvent)&&void 0!==X||(globalThis.CustomEvent=J);var Q=Symbol(),Z=e=>{var t;return"boolean"==typeof e?e:null!==(t=null==e?void 0:e.capture)&&void 0!==t&&t},ee={__proto__:null,enumerable:!0};Object.freeze(ee);var te=function(){return c(function e(){o(this,e),this.__eventListeners=new Map,this.__captureEventListeners=new Map},[{key:"addEventListener",value:function(e,t,n){var i;if(null!=t){var a=Z(n)?this.__captureEventListeners:this.__eventListeners,r=a.get(e);if(void 0===r)r=new Map,a.set(e,r);else if(r.has(t))return;var o="object"==typeof n&&n?n:{};null===(i=o.signal)||void 0===i||i.addEventListener("abort",()=>this.removeEventListener(e,t,n)),r.set(t,null!=o?o:{})}}},{key:"removeEventListener",value:function(e,t,n){if(null!=t){var i=Z(n)?this.__captureEventListeners:this.__eventListeners,a=i.get(e);void 0!==a&&(a.delete(t),a.size||i.delete(e))}}},{key:"dispatchEvent",value:function(e){var t=this.__resolveFullEventPath();!e.composed&&this.__host&&(t=t.slice(0,t.indexOf(this.__host)));var n=!1,i=!1,a=q.NONE,r=null,o=null,s=null,u=e.stopPropagation,l=e.stopImmediatePropagation;Object.defineProperties(e,{target:m({get:()=>null!=r?r:o},ee),srcElement:m({get:()=>e.target},ee),currentTarget:m({get:()=>s},ee),eventPhase:m({get:()=>a},ee),composedPath:m({value:()=>t},ee),stopPropagation:m({value:()=>{n=!0,u.call(e)}},ee),stopImmediatePropagation:m({value:()=>{i=!0,l.call(e)}},ee)});var d=(t,n,i)=>{"function"==typeof t?t(e):"function"==typeof(null==t?void 0:t.handleEvent)&&t.handleEvent(e),n.once&&i.delete(t)},c=()=>(s=null,a=q.NONE,!e.defaultPrevented),f=t.slice().reverse();r=this.__host&&e.composed?null:this;for(var v,p=e=>{for(o=this;o.__host&&e.includes(o.__host);)o=o.__host},g=h(f);!(v=g()).done;){var y=v.value;r||o&&o!==y.__host||p(f.slice(f.indexOf(y))),s=y,a=y===e.target?q.AT_TARGET:q.CAPTURING_PHASE;var b=y.__captureEventListeners.get(e.type);if(b)for(var w,k=h(b);!(w=k()).done;){var S=w.value;if(d(S[0],S[1],b),i)return c()}if(n)return c()}var E=e.bubbles?t:[this];o=null;for(var P,T=h(E);!(P=T()).done;){var _=P.value;r||o&&_!==o.__host||p(E.slice(0,E.indexOf(_)+1)),s=_,a=_===e.target?q.AT_TARGET:q.BUBBLING_PHASE;var M=_.__eventListeners.get(e.type);if(M)for(var A,D=h(M);!(A=D()).done;){var x=A.value;if(d(x[0],x[1],M),i)return c()}if(n)return c()}return c()}},{key:"__resolveFullEventPath",value:function(){return this.__eventPathCache?this.__eventPathCache:this.__eventTargetParent?this.__eventPathCache=[this,...this.__eventTargetParent.__resolveFullEventPath()]:this.__eventPathCache=[this,oe,pe]}}])}(),ne=new WeakMap,ie=e=>{var t=ne.get(e);return void 0===t&&ne.set(e,t=new Map),t},ae=function(e){function t(){return o(this,t),r(this,t,arguments)}return p(t,e),c(t,[{key:"getRootNode",value:function(e){var t;if(null!=e&&e.composed)return se;var n=this.__host;return null!==(t=null==n?void 0:n.__shadowRoot)&&void 0!==t?t:se}}])}(te),re=function(e){function t(){return o(this,t),r(this,t,arguments)}return p(t,e),c(t,[{key:"adoptedStyleSheets",get:function(){return[]}},{key:"createTreeWalker",value:function(){return{}}},{key:"createTextNode",value:function(){return{}}},{key:"createElement",value:function(){return{}}}])}(ae),oe=new re,se=oe,ue=function(e){function t(e){var n;if(o(this,t),n=r(this,t),e!==Q)throw new TypeError("Illegal constructor");return Object.assign(n,globalThis,{CustomElementRegistry:fe,customElements:ve,document:se,Document:re,Element:le,EventTarget:te,HTMLElement:de,Node:ae,ShadowRoot:he,window:n,Window:ue}),n}return p(t,e),c(t)}(ae),le=function(e){function t(){var e;return o(this,t),(e=r(this,t,arguments)).__shadowRootMode=null,e.__shadowRoot=null,e.__internals=null,e}return p(t,e),c(t,[{key:"attributes",get:function(){return Array.from(ie(this)).map(([e,t])=>({name:e,value:t}))}},{key:"shadowRoot",get:function(){return"closed"===this.__shadowRootMode?null:this.__shadowRoot}},{key:"localName",get:function(){return this.constructor.__localName}},{key:"tagName",get:function(){var e;return null===(e=this.localName)||void 0===e?void 0:e.toUpperCase()}},{key:"setAttribute",value:function(e,t){ie(this).set(e,String(t))}},{key:"removeAttribute",value:function(e){ie(this).delete(e)}},{key:"toggleAttribute",value:function(e,t){return this.hasAttribute(e)?!(void 0===t||!t)||(this.removeAttribute(e),!1):!(void 0!==t&&!t)&&(this.setAttribute(e,""),!0)}},{key:"hasAttribute",value:function(e){return ie(this).has(e)}},{key:"attachShadow",value:function(e){this.__shadowRootMode=e.mode;var t=new he(Q,e);return t.__eventTargetParent=this,t.__host=this,this.__shadowRoot=t}},{key:"attachInternals",value:function(){if(null!==this.__internals)throw new Error("Failed to execute 'attachInternals' on 'HTMLElement': ElementInternals for the specified element was already attached.");var e=new j(this);return this.__internals=e,e}},{key:"getAttribute",value:function(e){var t=ie(this).get(e);return null!=t?t:null}}])}(ae),de=function(e){function t(){return o(this,t),r(this,t,arguments)}return p(t,e),c(t)}(le),ce=de,he=function(e){function t(e,n){var i;if(o(this,t),i=r(this,t),e!=e)throw new TypeError("Illegal constructor");return i.mode=n.mode,i}return p(t,e),c(t,[{key:"host",get:function(){return this.__host}}])}(ae);function me(){var e,t;return{promise:new Promise((n,i)=>{e=n,t=i}),resolve:e,reject:t}}null!==(Y=globalThis.litServerRoot)&&void 0!==Y||(globalThis.litServerRoot=Object.defineProperty(new ce,"localName",{get:()=>"lit-server-root"}));var fe=function(){return c(function e(){o(this,e),this.__definitions=new Map,this.__reverseDefinitions=new Map,this.__pendingWhenDefineds=new Map},[{key:"define",value:function(e,t){var n,i;if(this.__definitions.has(e)){if("development"!==process.env.NODE_ENV)throw new Error(`Failed to execute 'define' on 'CustomElementRegistry': the name "${e}" has already been used with this registry`);console.warn(`'CustomElementRegistry' already has "${e}" defined. This may have been caused by live reload or hot module replacement in which case it can be safely ignored.\nMake sure to test your application with a production build as repeat registrations will throw in production.`)}if(this.__reverseDefinitions.has(t))throw new Error(`Failed to execute 'define' on 'CustomElementRegistry': the constructor has already been used with this registry for the tag name ${this.__reverseDefinitions.get(t)}`);t.__localName=e,this.__definitions.set(e,{ctor:t,observedAttributes:null!==(n=t.observedAttributes)&&void 0!==n?n:[]}),this.__reverseDefinitions.set(t,e),null===(i=this.__pendingWhenDefineds.get(e))||void 0===i||i.resolve(t),this.__pendingWhenDefineds.delete(e)}},{key:"get",value:function(e){var t=this.__definitions.get(e);return null==t?void 0:t.ctor}},{key:"getName",value:function(e){var t;return null!==(t=this.__reverseDefinitions.get(e))&&void 0!==t?t:null}},{key:"initialize",value:function(e){throw new Error("customElements.initialize is not currently supported in SSR. Please file a bug if you need it.")}},{key:"upgrade",value:function(e){throw new Error("customElements.upgrade is not currently supported in SSR. Please file a bug if you need it.")}},{key:"whenDefined",value:function(e){var t,n;return k(function(i){for(;;)switch(i.n){case 0:if(!(t=this.__definitions.get(e))){i.n=1;break}return i.a(2,t.ctor);case 1:return(n=this.__pendingWhenDefineds.get(e))||(n=me(),this.__pendingWhenDefineds.set(e,n)),i.a(2,n.promise)}},null,this,null,Promise)}}])}(),ve=new fe,pe=new ue(Q);"undefined"==typeof HTMLElement&&(globalThis.HTMLElement=ce);var ge=["action"],ye=null;var be={storage:{getItem:()=>null,setItem:()=>{},removeItem:()=>{},clear:()=>{},getAllKeys:()=>[]},device:{getDeviceData:()=>({os_version:"",os_name:"",browser_name:"",browser_version:"",sdk_client:"",sdk_version:"",language:"en"}),getDeviceFormFactor:()=>"desktop",getDeviceScaleFactor:()=>1,generateUUID:()=>{throw new Error("No platform adapter registered — call registerPlatformAdapters() before Nami.configure()")},getScreenInfo:()=>({width:0,height:0,scale:1}),getLanguage:()=>"en"},ui:{createPaywall:()=>null,reRenderPaywall:()=>{},flowNavigateToScreen:()=>{}}};function we(){return null!=ye?ye:be}function ke(e,t,n,i){var a,r=arguments.length,o=r<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,n,i);else for(var s=e.length-1;s>=0;s--)(a=e[s])&&(o=(r<3?a(o):r>3?a(t,n,o):a(t,n))||o);return r>3&&o&&Object.defineProperty(t,n,o),o}function Se(e,t,n,i){if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(e):i?i.value:t.get(e)}function Ee(e,t,n,i,a){if("function"==typeof t||!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return t.set(e,n),n}"function"==typeof SuppressedError&&SuppressedError;var Pe;!function(e){e.SDK="sdk",e.ML="ml",e.THIRD_PARTY_ANALYTICS="third_party_analytics",e.THIRD_PARTY_TRANSACTIONS="third_party_transactions",e.PAYWALL_PERSONALIZATION="paywall_personalization",e.ANONYMOUS_MODE_CAPABILITY="anonymous_allowed",e.LANGUAGE_MANAGEMENT="language_management",e.ENTITLEMENT_MANAGEMENT="entitlement_management"}(Pe||(Pe={}));var Te,_e={},Me=_e.NAMI_SDK_VERSION,Ae=void 0===Me?"3.4.6":Me,De=_e.NAMI_SDK_PACKAGE_VERSION,xe=void 0===De?"3.4.6-dev.202607162357":De,Ce=_e.PLATFORM_ID_REQUIRED,Ie=void 0===Ce?"Platform ID is required":Ce,Le=_e.DEVICE_ID_REQUIRED,Re=void 0===Le?"Device ID is required":Le,Fe=_e.EXTERNAL_ID_REQUIRED,Oe=void 0===Fe?"External ID is required":Fe,$e=_e.SDK_NOT_INITIALIZED,Ne=void 0===$e?"SDK has not been initialized. Make sure to call Nami.configure() first!":$e,We=_e.CAMPAIGN_NOT_AVAILABLE,je=void 0===We?"Campaign is not available":We,Be=_e.FLOW_SCREENS_NOT_AVAILABLE,ze=void 0===Be?"Flow screens not available":Be,Ue=_e.UNABLE_TO_UPDATE_CDP_ID,He=void 0===Ue?"Unable to update CDP id in anonymous mode":Ue,Ge=_e.ANONYMOUS_MODE_ALREADY_ON,Ve=void 0===Ge?"Anonymous mode is already turned on.":Ge,Ke=_e.ANONYMOUS_MODE_ALREADY_OFF,Xe=void 0===Ke?"Anonymous mode is already turned off.":Ke,Ye=_e.DEVICE_ID_NOT_SET,qe=void 0===Ye?"Nami Device ID is not set":Ye,Je=_e.AUTH_DEVICE,Qe=void 0===Je?"nami_auth_device":Je,Ze=_e.NAMI_CONFIGURATION,et=void 0===Ze?"nami_configuration":Ze,tt=_e.NAMI_PROFILE,nt=void 0===tt?"nami_profile":tt,it=_e.API_CONFIG,at=void 0===it?"api_config":it,rt=_e.API_CAMPAIGN_RULES,ot=void 0===rt?"api_campaign_rules":rt,st=_e.API_PAYWALLS,ut=void 0===st?"api_paywalls":st,lt=_e.API_CAMPAIGN_SESSION_TIMESTAMP,dt=void 0===lt?"api_campaign_session_timestamp":lt,ct=_e.API_PRODUCTS,ht=void 0===ct?"api_products":ct,mt=_e.API_ACTIVE_ENTITLEMENTS,ft=void 0===mt?"api_active_entitlements":mt,vt=_e.SERVER_NAMI_ENTITLEMENTS,pt=void 0===vt?"server_active_entitlements":vt,gt=_e.INITIAL_APP_CONFIG,yt=void 0===gt?"initial_app_config":gt,bt=_e.INITIAL_CAMPAIGN_RULES,wt=void 0===bt?"initial_campaign_rules":bt,kt=_e.INITIAL_PAYWALLS,St=void 0===kt?"initial_paywalls":kt,Et=_e.INITIAL_PRODUCTS,Pt=void 0===Et?"initial_products":Et,Tt=_e.LOCAL_NAMI_ENTITLEMENTS,_t=void 0===Tt?"local_active_entitlements":Tt,Mt=_e.CUSTOMER_ATTRIBUTES_KEY_PREFIX,At=void 0===Mt?"nami_cmr_attributes_":Mt,Dt=_e.NAMI_CUSTOMER_JOURNEY_STATE,xt=void 0===Dt?"nami_customer_journey_state":Dt,Ct=_e.ANONYMOUS_MODE,It=void 0===Ct?"nami_anonymous_mode_v2":Ct,Lt=_e.ANONYMOUS_UUID,Rt=void 0===Lt?"nami_anonymous_uuid":Lt,Ft=_e.KEY_SESSION_COUNTER,Ot=void 0===Ft?"nami_session_counter":Ft,$t=_e.INITIAL_SESSION_COUNTER_VALUE,Nt=void 0===$t?1:$t,Wt=_e.NAMI_LAST_IMPRESSION_ID,jt=void 0===Wt?"nami_last_impression_id":Wt,Bt=_e.NAMI_PURCHASE_IMPRESSION_ID,zt=void 0===Bt?"nami_purchase_impression_id":Bt,Ut=_e.NAMI_LAUNCH_ID,Ht=void 0===Ut?"nami_launch_id":Ut,Gt=_e.NAMI_SESSION_ID,Vt=void 0===Gt?"nami_session_id":Gt,Kt=_e.NAMI_LANGUAGE_CODE,Xt=void 0===Kt?"nami_language_code":Kt,Yt=_e.NAMI_PURCHASE_CHANNEL,qt=void 0===Yt?"nami_purchase_channel":Yt,Jt=_e.API_VERSION,Qt=_e.BASE_URL_PATH,Zt=void 0===Qt?`sdk/${void 0===Jt?"v3":Jt}/platform`:Qt,en=_e.BASE_URL,tn=void 0===en?"https://app.namiml.com":en,nn=_e.BASE_STAGING_URL,an=void 0===nn?"https://app-staging.namiml.com":nn,rn=_e.CUSTOM_HOST_PREFIX,on=void 0===rn?"namiAPIHost=":rn,sn=_e.USE_STAGING_API,un=void 0===sn?"useStagingAPI":sn,ln=_e.EXTENDED_CLIENT_INFO_PREFIX,dn=void 0===ln?"extendedClientInfo":ln,cn=_e.EXTENDED_CLIENT_INFO_DELIMITER,hn=void 0===cn?":":cn,mn=_e.VALIDATE_PRODUCT_GROUPS,fn=void 0===mn?"validateProductGroups":mn,vn=_e.LOG_HTTP_REQUESTS,pn=void 0===vn?"logHTTPRequests":vn,gn=_e.LOG_HTTP_TRAFFIC,yn=void 0===gn?"logHTTPTraffic":gn,bn=_e.STARTUP_TELEMETRY,wn=void 0===bn?"startupTelemetry":bn,kn=_e.API_MAX_CALLS_LIMIT,Sn=void 0===kn?2:kn,En=_e.API_RETRY_DELAY_SEC,Pn=void 0===En?2:En,Tn=_e.API_TIMEOUT_LIMIT,_n=void 0===Tn?2e4:Tn,Mn=_e.DEVICE_API_TIMEOUT_LIMIT,An=void 0===Mn?2e3:Mn,Dn=_e.STATUS_BAD_REQUEST,xn=void 0===Dn?400:Dn,Cn=_e.STATUS_NOT_FOUND,In=void 0===Cn?404:Cn,Ln=_e.STATUS_CONFLICT,Rn=void 0===Ln?409:Ln,Fn=_e.STATUS_INTERNAL_SERVER_ERROR,On=void 0===Fn?500:Fn,$n=_e.INITIAL_SUCCESS,Nn=void 0===$n?"Initial success":$n,Wn=_e.RECONFIG_SUCCESS,jn=void 0===Wn?"Reconfig success":Wn,Bn=_e.ALREADY_CONFIGURED,zn=void 0===Bn?"Already configured":Bn,Un=_e.AVAILABLE_CAMPAIGNS_CHANGED,Hn=void 0===Un?"AvailableCampaignsChanged":Un,Gn=_e.PAYWALL_ACTION_EVENT,Vn=void 0===Gn?"PaywallActionEvent":Gn,Kn=_e.AVAILABLE_ACTIVE_ENTITLEMENTS_CHANGED,Xn=void 0===Kn?"AvailableActiveEntitlementsChanged":Kn,Yn=_e.CUSTOMER_JOURNEY_STATE_CHANGED,qn=void 0===Yn?"CustomerJourneyStateChanged":Yn,Jn=_e.SKU_TEXT_REGEX,Qn=void 0===Jn?/\$\{sku\.(\w+)(:\d+)?\}/g:Jn,Zn=_e.VAR_REGEX,ei=void 0===Zn?/\$\{\s*(\w+(\.[a-zA-Z\d_:${}-]{0,99})*?)\s*}/g:Zn,ti=_e.SMART_TEXT_PATTERN,ni=void 0===ti?"${":ti,ii=_e.LIQUID_VARIABLE_REGEX,ai=void 0===ii?/\${[A-Za-z0-9.]+}/g:ii,ri=[Qe,et,nt,at,ot,ut,dt,ht,ft,pt,yt,wt,St,Pt,_t,xt,It,Rt,Ot,jt,zt,Ht,Vt,Xt,qt];e.LogLevel=void 0,(Te=e.LogLevel||(e.LogLevel={}))[Te.DEBUG=1]="DEBUG",Te[Te.INFO=2]="INFO",Te[Te.WARN=3]="WARN",Te[Te.ERROR=4]="ERROR";var oi={debug:e.LogLevel.DEBUG,info:e.LogLevel.INFO,warn:e.LogLevel.WARN,error:e.LogLevel.ERROR},si=function(){return c(function t(){o(this,t),this.currentLogLevel=e.LogLevel.DEBUG,this.setLogger=t=>{this.currentLogLevel=t?oi[t]:e.LogLevel.WARN}},[{key:"debug",value:function(t,...n){this.shouldLog(e.LogLevel.DEBUG)&&console.debug(this.formatMessage(e.LogLevel.DEBUG,t,...n))}},{key:"info",value:function(t,...n){this.shouldLog(e.LogLevel.INFO)&&console.info(this.formatMessage(e.LogLevel.INFO,t,...n))}},{key:"warn",value:function(t,...n){this.shouldLog(e.LogLevel.WARN)&&console.warn(this.formatMessage(e.LogLevel.WARN,t,...n))}},{key:"error",value:function(t,...n){this.shouldLog(e.LogLevel.ERROR)&&console.error(this.formatMessage(e.LogLevel.ERROR,t,...n))}},{key:"shouldLog",value:function(e){return e>=this.currentLogLevel}},{key:"formatMessage",value:function(t,n,...i){var a=e.LogLevel[t];return`[${(new Date).toISOString()}] [${a}] ${n} ${i=i.map(e=>"object"==typeof e?JSON.stringify(e):e)}`}}])}(),ui=new si;function li(e){for(var t=-1,n=null==e?0:e.length,i=0,a=[];++t<n;){var r=e[t];r&&(a[i++]=r)}return a}function di(e,t){return e===t||e!=e&&t!=t}function ci(e,t){for(var n=e.length;n--;)if(di(e[n][0],t))return n;return-1}var hi=Array.prototype.splice;function mi(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var i=e[t];this.set(i[0],i[1])}}mi.prototype.clear=function(){this.__data__=[],this.size=0},mi.prototype.delete=function(e){var t=this.__data__,n=ci(t,e);return!(n<0)&&(n==t.length-1?t.pop():hi.call(t,n,1),--this.size,!0)},mi.prototype.get=function(e){var t=this.__data__,n=ci(t,e);return n<0?void 0:t[n][1]},mi.prototype.has=function(e){return ci(this.__data__,e)>-1},mi.prototype.set=function(e,t){var n=this.__data__,i=ci(n,e);return i<0?(++this.size,n.push([e,t])):n[i][1]=t,this};var fi="object"==typeof global&&global&&global.Object===Object&&global,vi="object"==typeof self&&self&&self.Object===Object&&self,pi=fi||vi||Function("return this")(),gi=pi.Symbol,yi=Object.prototype,bi=yi.hasOwnProperty,wi=yi.toString,ki=gi?gi.toStringTag:void 0;var Si=Object.prototype.toString;var Ei=gi?gi.toStringTag:void 0;function Pi(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":Ei&&Ei in Object(e)?function(e){var t=bi.call(e,ki),n=e[ki];try{e[ki]=void 0;var i=!0}catch(e){}var a=wi.call(e);return i&&(t?e[ki]=n:delete e[ki]),a}(e):function(e){return Si.call(e)}(e)}function Ti(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function _i(e){if(!Ti(e))return!1;var t=Pi(e);return"[object Function]"==t||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t}var Mi,Ai=pi["__core-js_shared__"],Di=(Mi=/[^.]+$/.exec(Ai&&Ai.keys&&Ai.keys.IE_PROTO||""))?"Symbol(src)_1."+Mi:"";var xi=Function.prototype.toString;function Ci(e){if(null!=e){try{return xi.call(e)}catch(e){}try{return e+""}catch(e){}}return""}var Ii=/^\[object .+?Constructor\]$/,Li=Function.prototype,Ri=Object.prototype,Fi=Li.toString,Oi=Ri.hasOwnProperty,$i=RegExp("^"+Fi.call(Oi).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Ni(e){return!(!Ti(e)||(t=e,Di&&Di in t))&&(_i(e)?$i:Ii).test(Ci(e));var t}function Wi(e,t){var n=function(e,t){return null==e?void 0:e[t]}(e,t);return Ni(n)?n:void 0}var ji=Wi(pi,"Map"),Bi=Wi(Object,"create");var zi=Object.prototype.hasOwnProperty;var Ui=Object.prototype.hasOwnProperty;function Hi(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var i=e[t];this.set(i[0],i[1])}}function Gi(e,t){var n,i,a=e.__data__;return("string"==(i=typeof(n=t))||"number"==i||"symbol"==i||"boolean"==i?"__proto__"!==n:null===n)?a["string"==typeof t?"string":"hash"]:a.map}function Vi(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var i=e[t];this.set(i[0],i[1])}}Hi.prototype.clear=function(){this.__data__=Bi?Bi(null):{},this.size=0},Hi.prototype.delete=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},Hi.prototype.get=function(e){var t=this.__data__;if(Bi){var n=t[e];return"__lodash_hash_undefined__"===n?void 0:n}return zi.call(t,e)?t[e]:void 0},Hi.prototype.has=function(e){var t=this.__data__;return Bi?void 0!==t[e]:Ui.call(t,e)},Hi.prototype.set=function(e,t){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=Bi&&void 0===t?"__lodash_hash_undefined__":t,this},Vi.prototype.clear=function(){this.size=0,this.__data__={hash:new Hi,map:new(ji||mi),string:new Hi}},Vi.prototype.delete=function(e){var t=Gi(this,e).delete(e);return this.size-=t?1:0,t},Vi.prototype.get=function(e){return Gi(this,e).get(e)},Vi.prototype.has=function(e){return Gi(this,e).has(e)},Vi.prototype.set=function(e,t){var n=Gi(this,e),i=n.size;return n.set(e,t),this.size+=n.size==i?0:1,this};function Ki(e){var t=this.__data__=new mi(e);this.size=t.size}Ki.prototype.clear=function(){this.__data__=new mi,this.size=0},Ki.prototype.delete=function(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n},Ki.prototype.get=function(e){return this.__data__.get(e)},Ki.prototype.has=function(e){return this.__data__.has(e)},Ki.prototype.set=function(e,t){var n=this.__data__;if(n instanceof mi){var i=n.__data__;if(!ji||i.length<199)return i.push([e,t]),this.size=++n.size,this;n=this.__data__=new Vi(i)}return n.set(e,t),this.size=n.size,this};function Xi(e){var t=-1,n=null==e?0:e.length;for(this.__data__=new Vi;++t<n;)this.add(e[t])}function Yi(e,t){for(var n=-1,i=null==e?0:e.length;++n<i;)if(t(e[n],n,e))return!0;return!1}function qi(e,t){return e.has(t)}Xi.prototype.add=Xi.prototype.push=function(e){return this.__data__.set(e,"__lodash_hash_undefined__"),this},Xi.prototype.has=function(e){return this.__data__.has(e)};function Ji(e,t,n,i,a,r){var o=1&n,s=e.length,u=t.length;if(s!=u&&!(o&&u>s))return!1;var l=r.get(e),d=r.get(t);if(l&&d)return l==t&&d==e;var c=-1,h=!0,m=2&n?new Xi:void 0;for(r.set(e,t),r.set(t,e);++c<s;){var f=e[c],v=t[c];if(i)var p=o?i(v,f,c,t,e,r):i(f,v,c,e,t,r);if(void 0!==p){if(p)continue;h=!1;break}if(m){if(!Yi(t,function(e,t){if(!qi(m,t)&&(f===e||a(f,e,n,i,r)))return m.push(t)})){h=!1;break}}else if(f!==v&&!a(f,v,n,i,r)){h=!1;break}}return r.delete(e),r.delete(t),h}var Qi=pi.Uint8Array;function Zi(e){var t=-1,n=Array(e.size);return e.forEach(function(e,i){n[++t]=[i,e]}),n}function ea(e){var t=-1,n=Array(e.size);return e.forEach(function(e){n[++t]=e}),n}var ta=gi?gi.prototype:void 0,na=ta?ta.valueOf:void 0;var ia=Array.isArray;var aa=Object.prototype.propertyIsEnumerable,ra=Object.getOwnPropertySymbols,oa=ra?function(e){return null==e?[]:(e=Object(e),function(e,t){for(var n=-1,i=null==e?0:e.length,a=0,r=[];++n<i;){var o=e[n];t(o,n,e)&&(r[a++]=o)}return r}(ra(e),function(t){return aa.call(e,t)}))}:function(){return[]};function sa(e){return null!=e&&"object"==typeof e}function ua(e){return sa(e)&&"[object Arguments]"==Pi(e)}var la=Object.prototype,da=la.hasOwnProperty,ca=la.propertyIsEnumerable,ha=ua(function(){return arguments}())?ua:function(e){return sa(e)&&da.call(e,"callee")&&!ca.call(e,"callee")};var ma="object"==typeof e&&e&&!e.nodeType&&e,fa=ma&&"object"==typeof module&&module&&!module.nodeType&&module,va=fa&&fa.exports===ma?pi.Buffer:void 0,pa=(va?va.isBuffer:void 0)||function(){return!1},ga=/^(?:0|[1-9]\d*)$/;function ya(e,t){var n=typeof e;return!!(t=t??9007199254740991)&&("number"==n||"symbol"!=n&&ga.test(e))&&e>-1&&e%1==0&&e<t}function ba(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991}var wa={};function ka(e){return function(t){return e(t)}}wa["[object Float32Array]"]=wa["[object Float64Array]"]=wa["[object Int8Array]"]=wa["[object Int16Array]"]=wa["[object Int32Array]"]=wa["[object Uint8Array]"]=wa["[object Uint8ClampedArray]"]=wa["[object Uint16Array]"]=wa["[object Uint32Array]"]=!0,wa["[object Arguments]"]=wa["[object Array]"]=wa["[object ArrayBuffer]"]=wa["[object Boolean]"]=wa["[object DataView]"]=wa["[object Date]"]=wa["[object Error]"]=wa["[object Function]"]=wa["[object Map]"]=wa["[object Number]"]=wa["[object Object]"]=wa["[object RegExp]"]=wa["[object Set]"]=wa["[object String]"]=wa["[object WeakMap]"]=!1;var Sa="object"==typeof e&&e&&!e.nodeType&&e,Ea=Sa&&"object"==typeof module&&module&&!module.nodeType&&module,Pa=Ea&&Ea.exports===Sa&&fi.process,Ta=function(){try{var e=Ea&&Ea.require&&Ea.require("util").types;return e||Pa&&Pa.binding&&Pa.binding("util")}catch(e){}}(),_a=Ta&&Ta.isTypedArray,Ma=_a?ka(_a):function(e){return sa(e)&&ba(e.length)&&!!wa[Pi(e)]},Aa=Object.prototype.hasOwnProperty;function Da(e,t){var n=ia(e),i=!n&&ha(e),a=!n&&!i&&pa(e),r=!n&&!i&&!a&&Ma(e),o=n||i||a||r,s=o?function(e,t){for(var n=-1,i=Array(e);++n<e;)i[n]=t(n);return i}(e.length,String):[],u=s.length;for(var l in e)!Aa.call(e,l)||o&&("length"==l||a&&("offset"==l||"parent"==l)||r&&("buffer"==l||"byteLength"==l||"byteOffset"==l)||ya(l,u))||s.push(l);return s}var xa=Object.prototype;function Ca(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||xa)}function Ia(e,t){return function(n){return e(t(n))}}var La=Ia(Object.keys,Object),Ra=Object.prototype.hasOwnProperty;function Fa(e){return null!=(t=e)&&ba(t.length)&&!_i(t)?Da(e):function(e){if(!Ca(e))return La(e);var t=[];for(var n in Object(e))Ra.call(e,n)&&"constructor"!=n&&t.push(n);return t}(e);var t}function Oa(e){return function(e,t,n){var i=t(e);return ia(e)?i:function(e,t){for(var n=-1,i=t.length,a=e.length;++n<i;)e[a+n]=t[n];return e}(i,n(e))}(e,Fa,oa)}var $a=Object.prototype.hasOwnProperty;var Na=Wi(pi,"DataView"),Wa=Wi(pi,"Promise"),ja=Wi(pi,"Set"),Ba=Wi(pi,"WeakMap"),za="[object Map]",Ua="[object Promise]",Ha="[object Set]",Ga="[object WeakMap]",Va="[object DataView]",Ka=Ci(Na),Xa=Ci(ji),Ya=Ci(Wa),qa=Ci(ja),Ja=Ci(Ba),Qa=Pi;(Na&&Qa(new Na(new ArrayBuffer(1)))!=Va||ji&&Qa(new ji)!=za||Wa&&Qa(Wa.resolve())!=Ua||ja&&Qa(new ja)!=Ha||Ba&&Qa(new Ba)!=Ga)&&(Qa=function(e){var t=Pi(e),n="[object Object]"==t?e.constructor:void 0,i=n?Ci(n):"";if(i)switch(i){case Ka:return Va;case Xa:return za;case Ya:return Ua;case qa:return Ha;case Ja:return Ga}return t});var Za="[object Arguments]",er="[object Array]",tr="[object Object]",nr=Object.prototype.hasOwnProperty;function ir(e,t,n,i,a,r){var o=ia(e),s=ia(t),u=o?er:Qa(e),l=s?er:Qa(t),d=(u=u==Za?tr:u)==tr,c=(l=l==Za?tr:l)==tr,h=u==l;if(h&&pa(e)){if(!pa(t))return!1;o=!0,d=!1}if(h&&!d)return r||(r=new Ki),o||Ma(e)?Ji(e,t,n,i,a,r):function(e,t,n,i,a,r,o){switch(n){case"[object DataView]":if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case"[object ArrayBuffer]":return!(e.byteLength!=t.byteLength||!r(new Qi(e),new Qi(t)));case"[object Boolean]":case"[object Date]":case"[object Number]":return di(+e,+t);case"[object Error]":return e.name==t.name&&e.message==t.message;case"[object RegExp]":case"[object String]":return e==t+"";case"[object Map]":var s=Zi;case"[object Set]":var u=1&i;if(s||(s=ea),e.size!=t.size&&!u)return!1;var l=o.get(e);if(l)return l==t;i|=2,o.set(e,t);var d=Ji(s(e),s(t),i,a,r,o);return o.delete(e),d;case"[object Symbol]":if(na)return na.call(e)==na.call(t)}return!1}(e,t,u,n,i,a,r);if(!(1&n)){var m=d&&nr.call(e,"__wrapped__"),f=c&&nr.call(t,"__wrapped__");if(m||f){var v=m?e.value():e,p=f?t.value():t;return r||(r=new Ki),a(v,p,n,i,r)}}return!!h&&(r||(r=new Ki),function(e,t,n,i,a,r){var o=1&n,s=Oa(e),u=s.length;if(u!=Oa(t).length&&!o)return!1;for(var l=u;l--;){var d=s[l];if(!(o?d in t:$a.call(t,d)))return!1}var c=r.get(e),h=r.get(t);if(c&&h)return c==t&&h==e;var m=!0;r.set(e,t),r.set(t,e);for(var f=o;++l<u;){var v=e[d=s[l]],p=t[d];if(i)var g=o?i(p,v,d,t,e,r):i(v,p,d,e,t,r);if(!(void 0===g?v===p||a(v,p,n,i,r):g)){m=!1;break}f||(f="constructor"==d)}if(m&&!f){var y=e.constructor,b=t.constructor;y==b||!("constructor"in e)||!("constructor"in t)||"function"==typeof y&&y instanceof y&&"function"==typeof b&&b instanceof b||(m=!1)}return r.delete(e),r.delete(t),m}(e,t,n,i,a,r))}function ar(e,t,n,i,a){return e===t||(null==e||null==t||!sa(e)&&!sa(t)?e!=e&&t!=t:ir(e,t,n,i,ar,a))}function rr(e){return e==e&&!Ti(e)}function or(e,t){return function(n){return null!=n&&(n[e]===t&&(void 0!==t||e in Object(n)))}}function sr(e){var t=function(e){for(var t=Fa(e),n=t.length;n--;){var i=t[n],a=e[i];t[n]=[i,a,rr(a)]}return t}(e);return 1==t.length&&t[0][2]?or(t[0][0],t[0][1]):function(n){return n===e||function(e,t,n,i){var a=n.length,r=a;if(null==e)return!r;for(e=Object(e);a--;){var o=n[a];if(o[2]?o[1]!==e[o[0]]:!(o[0]in e))return!1}for(;++a<r;){var s=(o=n[a])[0],u=e[s],l=o[1];if(o[2]){if(void 0===u&&!(s in e))return!1}else if(!ar(l,u,3,i,new Ki))return!1}return!0}(n,0,t)}}function ur(e){return"symbol"==typeof e||sa(e)&&"[object Symbol]"==Pi(e)}var lr=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,dr=/^\w*$/;function cr(e,t){if(ia(e))return!1;var n=typeof e;return!("number"!=n&&"symbol"!=n&&"boolean"!=n&&null!=e&&!ur(e))||(dr.test(e)||!lr.test(e)||null!=t&&e in Object(t))}function hr(e,t){if("function"!=typeof e||null!=t&&"function"!=typeof t)throw new TypeError("Expected a function");var n=function(){var i=arguments,a=t?t.apply(this,i):i[0],r=n.cache;if(r.has(a))return r.get(a);var o=e.apply(this,i);return n.cache=r.set(a,o)||r,o};return n.cache=new(hr.Cache||Vi),n}hr.Cache=Vi;var mr,fr,vr,pr=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,gr=/\\(\\)?/g,yr=(mr=function(e){var t=[];return 46===e.charCodeAt(0)&&t.push(""),e.replace(pr,function(e,n,i,a){t.push(i?a.replace(gr,"$1"):n||e)}),t},fr=hr(mr,function(e){return 500===vr.size&&vr.clear(),e}),vr=fr.cache,fr);var br=gi?gi.prototype:void 0,wr=br?br.toString:void 0;function kr(e){if("string"==typeof e)return e;if(ia(e))return function(e,t){for(var n=-1,i=null==e?0:e.length,a=Array(i);++n<i;)a[n]=t(e[n],n,e);return a}(e,kr)+"";if(ur(e))return wr?wr.call(e):"";var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}function Sr(e,t){return ia(e)?e:cr(e,t)?[e]:yr(function(e){return null==e?"":kr(e)}(e))}function Er(e){if("string"==typeof e||ur(e))return e;var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}function Pr(e,t){for(var n=0,i=(t=Sr(t,e)).length;null!=e&&n<i;)e=e[Er(t[n++])];return n&&n==i?e:void 0}function Tr(e,t){return null!=e&&t in Object(e)}function _r(e,t){return null!=e&&function(e,t,n){for(var i=-1,a=(t=Sr(t,e)).length,r=!1;++i<a;){var o=Er(t[i]);if(!(r=null!=e&&n(e,o)))break;e=e[o]}return r||++i!=a?r:!!(a=null==e?0:e.length)&&ba(a)&&ya(o,a)&&(ia(e)||ha(e))}(e,t,Tr)}function Mr(e,t){return cr(e)&&rr(t)?or(Er(e),t):function(n){var i=function(e,t,n){var i=null==e?void 0:Pr(e,t);return void 0===i?n:i}(n,e);return void 0===i&&i===t?_r(n,e):ar(t,i,3)}}function Ar(e){return e}function Dr(e){return cr(e)?(t=Er(e),function(e){return null==e?void 0:e[t]}):function(e){return function(t){return Pr(t,e)}}(e);var t}function xr(e){return e!=e}function Cr(e,t){return!!(null==e?0:e.length)&&function(e,t,n){return t==t?function(e,t,n){for(var i=n-1,a=e.length;++i<a;)if(e[i]===t)return i;return-1}(e,t,n):function(e,t,n){for(var i=e.length,a=n+-1;++a<i;)if(t(e[a],a,e))return a;return-1}(e,xr,n)}(e,t,0)>-1}var Ir=ja&&1/ea(new ja([,-0]))[1]==1/0?function(e){return new ja(e)}:function(){};function Lr(e,t){return e&&e.length?function(e,t,n){var i=-1,a=Cr,r=e.length,o=!0,s=[],u=s;if(r>=200){var l=t?null:Ir(e);if(l)return ea(l);o=!1,a=qi,u=new Xi}else u=t?[]:s;e:for(;++i<r;){var d=e[i],c=t?t(d):d;if(d=0!==d?d:0,o&&c==c){for(var h=u.length;h--;)if(u[h]===c)continue e;t&&u.push(c),s.push(d)}else a(u,c,n)||(u!==s&&u.push(c),s.push(d))}return s}(e,"function"==typeof(n=t)?n:null==n?Ar:"object"==typeof n?ia(n)?Mr(n[0],n[1]):sr(n):Dr(n)):[];var n}var Rr=function(){return c(function e(){o(this,e),this.memoryStore={}},[{key:"storage",get:function(){return we().storage}},{key:"setDevice",value:function(e){this.setItem(Qe,e)}},{key:"getDevice",value:function(){return this.getItem(Qe)}},{key:"resetDevice",value:function(){this.resetItem(Qe)}},{key:"getAnonymousMode",value:function(){return this.getItem(It)||!1}},{key:"setAnonymousMode",value:function(e){this.setItem(It,e)}},{key:"clearAnonymousMode",value:function(){this.resetItem(It)}},{key:"setAppConfig",value:function(e,t){this.setItem(e,t)}},{key:"getAppConfig",value:function(e){return this.getItem(e)}},{key:"setLanguageCode",value:function(e){this.setItem(Xt,e||"en")}},{key:"getLanguageCode",value:function(){return this.getItem(Xt)||"en"}},{key:"setCampaignRules",value:function(e,t){e!==wt?e!==ot||0!==this.getCampaignCacheTtl()?this.setItem(e,t):this.memoryStore[ot]=JSON.stringify(t):this.memoryStore[wt]=JSON.stringify(t)}},{key:"getCampaignRules",value:function(e){if(e===wt)return this.memoryStore[wt]?JSON.parse(this.memoryStore[wt]):null;if(e===ot){var t=this.memoryStore[ot];if(null!=t)return JSON.parse(t);var n=this.getItem(ot);if(null===n)return null;if("string"==typeof n)try{n=JSON.parse(n)}catch(e){return n}return this.isLegacyTimestampedCache(n)?n.data:n}return this.getItem(e)}},{key:"setPaywalls",value:function(e,t){e!==St?e!==ut||0!==this.getCampaignCacheTtl()?this.setItem(e,t):this.memoryStore[ut]=JSON.stringify(t):this.memoryStore[St]=JSON.stringify(t)}},{key:"getPaywalls",value:function(e){if(e===St)return this.memoryStore[St]?JSON.parse(this.memoryStore[St]):null;if(e===ut){var t=this.memoryStore[ut];if(null!=t)return JSON.parse(t);var n=this.getItem(ut);if(null===n)return null;if("string"==typeof n)try{n=JSON.parse(n)}catch(e){return n}return this.isLegacyTimestampedCache(n)?n.data:n}return this.getItem(e)}},{key:"setActiveEntitlements",value:function(e,t){this.setItem(e,t)}},{key:"getActiveEntitlements",value:function(e){return this.getItem(e)||[]}},{key:"setNamiEntitlements",value:function(e,t){this.setItem(e,t)}},{key:"getNamiEntitlements",value:function(e){return this.getItem(e)||[]}},{key:"setProducts",value:function(e,t){this.setItem(e,t)}},{key:"getProducts",value:function(e){return this.getItem(e)}},{key:"getCachedProducts",value:function(){var e,t,n=null!==(e=this.getItem(ht))&&void 0!==e?e:[];return Lr(li([...null!==(t=this.getItem(Pt))&&void 0!==t?t:[],...n]),"sku_ref_id")}},{key:"setNamiConfig",value:function(e){this.setItem(et,e)}},{key:"getNamiConfig",value:function(){return this.getItem(et)}},{key:"setCustomerAttribute",value:function(e,t){this.setItem(At+e,t)}},{key:"getCustomerAttribute",value:function(e){return this.getItem(At+e)}},{key:"getAllCustomerAttributes",value:function(){return this.storage.getAllKeys().map(e=>[e,this.storage.getItem(e)]).filter(([e])=>e.includes(At)).map(([e,t])=>e.replace(At,"")+":"+t)}},{key:"getAllCustomerAttributesKeys",value:function(){return this.storage.getAllKeys().filter(e=>e.includes(At)).map(e=>e.replace(At,""))}},{key:"getAllCustomerAttributesMap",value:function(){var e={};return this.getAllCustomerAttributesKeys().forEach(t=>{var n=this.getCustomerAttribute(t);null!=n&&(e[t]=String(n))}),e}},{key:"clearCustomerAttribute",value:function(e){var t=At+e,n=this.getItem(t);return n&&this.resetItem(t),!!n}},{key:"clearAllCustomerAttributes",value:function(){this.storage.getAllKeys().filter(e=>e.includes(At)).map(e=>this.resetItem(e))}},{key:"setNamiProfile",value:function(e){this.setItem(nt,e)}},{key:"getNamiProfile",value:function(){return this.getItem(nt)}},{key:"removeNamiProfile",value:function(){this.resetItem(nt)}},{key:"setCustomerJourneyState",value:function(e){this.setItem(xt,e)}},{key:"getCustomerJourneyState",value:function(){return this.getItem(xt)}},{key:"setSessionCounter",value:function(){var e=this.getItem(Ot),t=e?parseInt(e):Nt||Nt;this.setItem(Ot,t+1)}},{key:"getSessionCounter",value:function(){var e=this.getItem(Ot);return e?parseInt(e):Nt}},{key:"setLastImpressionId",value:function(e){this.setItem(jt,e)}},{key:"getLastImpressionId",value:function(){var e;return null!==(e=this.getItem(jt))&&void 0!==e?e:""}},{key:"setPurchaseImpression",value:function(){var e,t=null!==(e=this.getLastImpressionId())&&void 0!==e?e:"";this.setItem(zt,t)}},{key:"getPurchaseImpression",value:function(){var e;return null!==(e=this.getItem(zt))&&void 0!==e?e:""}},{key:"setSessionId",value:function(e){e&&this.setItem(Vt,e)}},{key:"getSessionId",value:function(){var e;return null!==(e=this.getItem(Vt))&&void 0!==e?e:""}},{key:"clearSessionId",value:function(){this.resetItem(Vt)}},{key:"setLaunchId",value:function(e){e&&this.setItem(Ht,e)}},{key:"getLaunchId",value:function(){var e;return null!==(e=this.getItem(Ht))&&void 0!==e?e:""}},{key:"clearLaunchId",value:function(){this.resetItem(Ht)}},{key:"setPurchaseChannel",value:function(e){e&&this.setItem(qt,e)}},{key:"getPurchaseChannel",value:function(){return this.getItem(qt)}},{key:"getAnonymousUUID",value:function(){return this.getItem(Rt)}},{key:"setAnonymousUUID",value:function(e){this.setItem(Rt,e)}},{key:"clearAnonymousUUID",value:function(){this.resetItem(Rt)}},{key:"setApiCampaignSessionTimestamp",value:function(){this.setItem(dt,Date.now())}},{key:"getApiCampaignSessionTimestamp",value:function(){return this.getItem(dt)}},{key:"purgeApiCampaignCache",value:function(){this.resetItem(ut),this.resetItem(ot),this.resetItem(dt)}},{key:"getCampaignCacheTtl",value:function(){var e,t=this.getAppConfig(at)||this.getAppConfig(yt);return null!==(e=null==t?void 0:t.campaign_cache_ttl)&&void 0!==e?e:null}},{key:"isLegacyTimestampedCache",value:function(e){return"object"==typeof e&&null!==e&&"cachedAt"in e&&"data"in e}},{key:"setItem",value:function(e,t){var n;try{n=JSON.stringify(t)}catch(t){return void ui.error(`Serialization failed for ${e}`,t)}try{this.storage.setItem(e,n)}catch(t){ui.error("Error setting item in localStorage:",t),this.resetItem(e),this.memoryStore[e]=n}}},{key:"getItem",value:function(e){try{var t=this.storage.getItem(e);if(null!==t)return JSON.parse(t)}catch(t){ui.error("Error getting item from localStorage:",e,": ",t)}var n=this.memoryStore[e];return null!=n?JSON.parse(n):null}},{key:"resetItem",value:function(e){try{this.storage.removeItem(e)}catch(t){ui.error("Error removing item from localStorage:",e,": ",t)}delete this.memoryStore[e]}},{key:"clearAll",value:function(){ri.forEach(e=>this.resetItem(e)),this.clearAllCustomerAttributes(),this.memoryStore={}}},{key:"clear",value:function(){try{this.storage.clear()}catch(e){ui.error("Error clearing localStorage:",e)}this.memoryStore={}}}])}(),Fr=new Rr,Or=function(e){function t(e,n){var i;return o(this,t),(i=r(this,t,[n])).statusCode=e,i.status=e,i.message=`RetryLimitExceededError: ${i.message}`,i}return p(t,e),c(t)}(M(Error)),$r=function(e){function t(){return o(this,t),r(this,t,arguments)}return p(t,e),c(t)}(M(Error)),Nr=function(e){function t(){var e;return o(this,t),(e=r(this,t)).status=409,e.name="ConflictError",e.message="ConflictError: Server responded with conflict",e}return p(t,e),c(t)}($r),Wr=function(e){function t(){return o(this,t),r(this,t,[Ne])}return p(t,e),c(t)}(M(Error)),jr=function(e){function t(){return o(this,t),r(this,t,[Ie])}return p(t,e),c(t)}(M(Error)),Br=function(e){function t(){return o(this,t),r(this,t,[Re])}return p(t,e),c(t)}(M(Error)),zr=function(e){function t(){return o(this,t),r(this,t,[Oe])}return p(t,e),c(t)}(M(Error)),Ur=function(e){function t(){return o(this,t),r(this,t,[je])}return p(t,e),c(t)}(M(Error)),Hr=function(e){function t(){return o(this,t),r(this,t,[ze])}return p(t,e),c(t)}(M(Error)),Gr=function(e){function t(){return o(this,t),r(this,t,[Ve])}return p(t,e),c(t)}(M(Error)),Vr=function(e){function t(){return o(this,t),r(this,t,[Xe])}return p(t,e),c(t)}(M(Error)),Kr=function(e){function t(){return o(this,t),r(this,t,[Xe])}return p(t,e),c(t)}(M(Error)),Xr=function(e){function t(){return o(this,t),r(this,t,[He])}return p(t,e),c(t)}(M(Error)),Yr=function(e){function t(e){var n;return o(this,t),(n=r(this,t,[e])).message=`BadRequestError: ${n.message}`,n}return p(t,e),c(t)}($r),qr=function(e){function t(e){var n;return o(this,t),(n=r(this,t,[e])).message=`NotFoundError: ${n.message}`,n}return p(t,e),c(t)}($r),Jr=function(e){function t(e,n){var i;return o(this,t),(i=r(this,t,[n])).statusCode=e,i.message=`ClientError: ${i.message}`,i}return p(t,e),c(t)}($r),Qr=function(e){function t(e){var n;return o(this,t),(n=r(this,t,[e])).message=`ServerError: ${n.message}`,n}return p(t,e),c(t)}($r),Zr=(e,t)=>{if(e==xn)throw new Yr(t);if(e==In)throw new qr(t);if(e==Rn)throw new Nr;if(e>xn&&e<On)throw new Jr(e,t);if(e>=On)throw new Qr(t)};function eo(e){for(var t=e.length;--t>=0;)e[t]=0}eo(new Array(576)),eo(new Array(60)),eo(new Array(512)),eo(new Array(256)),eo(new Array(29)),eo(new Array(30));var to=(e,t,n,i)=>{for(var a=65535&e,r=e>>>16&65535,o=0;0!==n;){n-=o=n>2e3?2e3:n;do{r=r+(a=a+t[i++]|0)|0}while(--o);a%=65521,r%=65521}return a|r<<16},no=new Uint32Array((()=>{for(var e,t=[],n=0;n<256;n++){e=n;for(var i=0;i<8;i++)e=1&e?3988292384^e>>>1:e>>>1;t[n]=e}return t})()),io=(e,t,n,i)=>{var a=no,r=i+n;e^=-1;for(var o=i;o<r;o++)e=e>>>8^a[255&(e^t[o])];return-1^e},ao={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"},ro=0,oo=4,so=5,uo=6,lo=0,co=1,ho=2,mo=-2,fo=-3,vo=-4,po=-5,go=8,yo=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),bo=function(e){for(var t=Array.prototype.slice.call(arguments,1);t.length;){var n=t.shift();if(n){if("object"!=typeof n)throw new TypeError(n+"must be non-object");for(var i in n)yo(n,i)&&(e[i]=n[i])}}return e},wo=e=>{for(var t=0,n=0,i=e.length;n<i;n++)t+=e[n].length;for(var a=new Uint8Array(t),r=0,o=0,s=e.length;r<s;r++){var u=e[r];a.set(u,o),o+=u.length}return a},ko=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(e){ko=!1}for(var So=new Uint8Array(256),Eo=0;Eo<256;Eo++)So[Eo]=Eo>=252?6:Eo>=248?5:Eo>=240?4:Eo>=224?3:Eo>=192?2:1;So[254]=So[254]=1;var Po=e=>{if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(e);var t,n,i,a,r,o=e.length,s=0;for(a=0;a<o;a++)55296==(64512&(n=e.charCodeAt(a)))&&a+1<o&&56320==(64512&(i=e.charCodeAt(a+1)))&&(n=65536+(n-55296<<10)+(i-56320),a++),s+=n<128?1:n<2048?2:n<65536?3:4;for(t=new Uint8Array(s),r=0,a=0;r<s;a++)55296==(64512&(n=e.charCodeAt(a)))&&a+1<o&&56320==(64512&(i=e.charCodeAt(a+1)))&&(n=65536+(n-55296<<10)+(i-56320),a++),n<128?t[r++]=n:n<2048?(t[r++]=192|n>>>6,t[r++]=128|63&n):n<65536?(t[r++]=224|n>>>12,t[r++]=128|n>>>6&63,t[r++]=128|63&n):(t[r++]=240|n>>>18,t[r++]=128|n>>>12&63,t[r++]=128|n>>>6&63,t[r++]=128|63&n);return t},To=(e,t)=>{var n,i,a=t||e.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(e.subarray(0,t));var r=new Array(2*a);for(i=0,n=0;n<a;){var o=e[n++];if(o<128)r[i++]=o;else{var s=So[o];if(s>4)r[i++]=65533,n+=s-1;else{for(o&=2===s?31:3===s?15:7;s>1&&n<a;)o=o<<6|63&e[n++],s--;s>1?r[i++]=65533:o<65536?r[i++]=o:(o-=65536,r[i++]=55296|o>>10&1023,r[i++]=56320|1023&o)}}}return((e,t)=>{if(t<65534&&e.subarray&&ko)return String.fromCharCode.apply(null,e.length===t?e:e.subarray(0,t));for(var n="",i=0;i<t;i++)n+=String.fromCharCode(e[i]);return n})(r,i)},_o=(e,t)=>{(t=t||e.length)>e.length&&(t=e.length);for(var n=t-1;n>=0&&128==(192&e[n]);)n--;return n<0||0===n?t:n+So[e[n]]>t?n:t};var Mo=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},Ao=16209,Do=function(e,t){var n,i,a,r,o,s,u,l,d,c,h,m,f,v,p,g,y,b,w,k,S,E,P,T,_=e.state;n=e.next_in,P=e.input,i=n+(e.avail_in-5),a=e.next_out,T=e.output,r=a-(t-e.avail_out),o=a+(e.avail_out-257),s=_.dmax,u=_.wsize,l=_.whave,d=_.wnext,c=_.window,h=_.hold,m=_.bits,f=_.lencode,v=_.distcode,p=(1<<_.lenbits)-1,g=(1<<_.distbits)-1;e:do{m<15&&(h+=P[n++]<<m,m+=8,h+=P[n++]<<m,m+=8),y=f[h&p];t:for(;;){if(h>>>=b=y>>>24,m-=b,0===(b=y>>>16&255))T[a++]=65535&y;else{if(!(16&b)){if(64&b){if(32&b){_.mode=16191;break e}e.msg="invalid literal/length code",_.mode=Ao;break e}y=f[(65535&y)+(h&(1<<b)-1)];continue t}for(w=65535&y,(b&=15)&&(m<b&&(h+=P[n++]<<m,m+=8),w+=h&(1<<b)-1,h>>>=b,m-=b),m<15&&(h+=P[n++]<<m,m+=8,h+=P[n++]<<m,m+=8),y=v[h&g];;){if(h>>>=b=y>>>24,m-=b,16&(b=y>>>16&255)){if(k=65535&y,m<(b&=15)&&(h+=P[n++]<<m,(m+=8)<b&&(h+=P[n++]<<m,m+=8)),(k+=h&(1<<b)-1)>s){e.msg="invalid distance too far back",_.mode=Ao;break e}if(h>>>=b,m-=b,k>(b=a-r)){if((b=k-b)>l&&_.sane){e.msg="invalid distance too far back",_.mode=Ao;break e}if(S=0,E=c,0===d){if(S+=u-b,b<w){w-=b;do{T[a++]=c[S++]}while(--b);S=a-k,E=T}}else if(d<b){if(S+=u+d-b,(b-=d)<w){w-=b;do{T[a++]=c[S++]}while(--b);if(S=0,d<w){w-=b=d;do{T[a++]=c[S++]}while(--b);S=a-k,E=T}}}else if(S+=d-b,b<w){w-=b;do{T[a++]=c[S++]}while(--b);S=a-k,E=T}for(;w>2;)T[a++]=E[S++],T[a++]=E[S++],T[a++]=E[S++],w-=3;w&&(T[a++]=E[S++],w>1&&(T[a++]=E[S++]))}else{S=a-k;do{T[a++]=T[S++],T[a++]=T[S++],T[a++]=T[S++],w-=3}while(w>2);w&&(T[a++]=T[S++],w>1&&(T[a++]=T[S++]))}break}if(64&b){e.msg="invalid distance code",_.mode=Ao;break e}y=v[(65535&y)+(h&(1<<b)-1)]}}break}}while(n<i&&a<o);n-=w=m>>3,h&=(1<<(m-=w<<3))-1,e.next_in=n,e.next_out=a,e.avail_in=n<i?i-n+5:5-(n-i),e.avail_out=a<o?o-a+257:257-(a-o),_.hold=h,_.bits=m},xo=15,Co=new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0]),Io=new Uint8Array([16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78]),Lo=new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0]),Ro=new Uint8Array([16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64]),Fo=(e,t,n,i,a,r,o,s)=>{var u,l,d,c,h,m,f,v,p,g=s.bits,y=0,b=0,w=0,k=0,S=0,E=0,P=0,T=0,_=0,M=0,A=null,D=new Uint16Array(16),x=new Uint16Array(16),C=null;for(y=0;y<=xo;y++)D[y]=0;for(b=0;b<i;b++)D[t[n+b]]++;for(S=g,k=xo;k>=1&&0===D[k];k--);if(S>k&&(S=k),0===k)return a[r++]=20971520,a[r++]=20971520,s.bits=1,0;for(w=1;w<k&&0===D[w];w++);for(S<w&&(S=w),T=1,y=1;y<=xo;y++)if(T<<=1,(T-=D[y])<0)return-1;if(T>0&&(0===e||1!==k))return-1;for(x[1]=0,y=1;y<xo;y++)x[y+1]=x[y]+D[y];for(b=0;b<i;b++)0!==t[n+b]&&(o[x[t[n+b]]++]=b);if(0===e?(A=C=o,m=20):1===e?(A=Co,C=Io,m=257):(A=Lo,C=Ro,m=0),M=0,b=0,y=w,h=r,E=S,P=0,d=-1,c=(_=1<<S)-1,1===e&&_>852||2===e&&_>592)return 1;for(;;){f=y-P,o[b]+1<m?(v=0,p=o[b]):o[b]>=m?(v=C[o[b]-m],p=A[o[b]-m]):(v=96,p=0),u=1<<y-P,w=l=1<<E;do{a[h+(M>>P)+(l-=u)]=f<<24|v<<16|p}while(0!==l);for(u=1<<y-1;M&u;)u>>=1;if(0!==u?(M&=u-1,M+=u):M=0,b++,0===--D[y]){if(y===k)break;y=t[n+o[b]]}if(y>S&&(M&c)!==d){for(0===P&&(P=S),h+=w,T=1<<(E=y-P);E+P<k&&!((T-=D[E+P])<=0);)E++,T<<=1;if(_+=1<<E,1===e&&_>852||2===e&&_>592)return 1;a[d=M&c]=S<<24|E<<16|h-r}}return 0!==M&&(a[h+M]=y-P<<24|64<<16),s.bits=S,0},Oo=oo,$o=so,No=uo,Wo=lo,jo=co,Bo=ho,zo=mo,Uo=fo,Ho=vo,Go=po,Vo=go,Ko=16180,Xo=16190,Yo=16191,qo=16192,Jo=16194,Qo=16199,Zo=16200,es=16206,ts=16209,ns=e=>(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24);function is(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}var as,rs,os=e=>{if(!e)return 1;var t=e.state;return!t||t.strm!==e||t.mode<Ko||t.mode>16211?1:0},ss=e=>{if(os(e))return zo;var t=e.state;return e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=Ko,t.last=0,t.havedict=0,t.flags=-1,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(852),t.distcode=t.distdyn=new Int32Array(592),t.sane=1,t.back=-1,Wo},us=e=>{if(os(e))return zo;var t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,ss(e)},ls=(e,t)=>{var n;if(os(e))return zo;var i=e.state;return t<0?(n=0,t=-t):(n=5+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?zo:(null!==i.window&&i.wbits!==t&&(i.window=null),i.wrap=n,i.wbits=t,us(e))},ds=(e,t)=>{if(!e)return zo;var n=new is;e.state=n,n.strm=e,n.window=null,n.mode=Ko;var i=ls(e,t);return i!==Wo&&(e.state=null),i},cs=!0,hs=e=>{if(cs){as=new Int32Array(512),rs=new Int32Array(32);for(var t=0;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(Fo(1,e.lens,0,288,as,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;Fo(2,e.lens,0,32,rs,0,e.work,{bits:5}),cs=!1}e.lencode=as,e.lenbits=9,e.distcode=rs,e.distbits=5},ms=(e,t,n,i)=>{var a,r=e.state;return null===r.window&&(r.wsize=1<<r.wbits,r.wnext=0,r.whave=0,r.window=new Uint8Array(r.wsize)),i>=r.wsize?(r.window.set(t.subarray(n-r.wsize,n),0),r.wnext=0,r.whave=r.wsize):((a=r.wsize-r.wnext)>i&&(a=i),r.window.set(t.subarray(n-i,n-i+a),r.wnext),(i-=a)?(r.window.set(t.subarray(n-i,n),0),r.wnext=i,r.whave=r.wsize):(r.wnext+=a,r.wnext===r.wsize&&(r.wnext=0),r.whave<r.wsize&&(r.whave+=a))),0},fs=(e,t)=>{var n,i,a,r,o,s,u,l,d,c,h,m,f,v,p,g,y,b,w,k,S,E,P,T,_=0,M=new Uint8Array(4),A=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(os(e)||!e.output||!e.input&&0!==e.avail_in)return zo;(n=e.state).mode===Yo&&(n.mode=qo),o=e.next_out,a=e.output,u=e.avail_out,r=e.next_in,i=e.input,s=e.avail_in,l=n.hold,d=n.bits,c=s,h=u,E=Wo;e:for(;;)switch(n.mode){case Ko:if(0===n.wrap){n.mode=qo;break}for(;d<16;){if(0===s)break e;s--,l+=i[r++]<<d,d+=8}if(2&n.wrap&&35615===l){0===n.wbits&&(n.wbits=15),n.check=0,M[0]=255&l,M[1]=l>>>8&255,n.check=io(n.check,M,2,0),l=0,d=0,n.mode=16181;break}if(n.head&&(n.head.done=!1),!(1&n.wrap)||(((255&l)<<8)+(l>>8))%31){e.msg="incorrect header check",n.mode=ts;break}if((15&l)!==Vo){e.msg="unknown compression method",n.mode=ts;break}if(d-=4,S=8+(15&(l>>>=4)),0===n.wbits&&(n.wbits=S),S>15||S>n.wbits){e.msg="invalid window size",n.mode=ts;break}n.dmax=1<<n.wbits,n.flags=0,e.adler=n.check=1,n.mode=512&l?16189:Yo,l=0,d=0;break;case 16181:for(;d<16;){if(0===s)break e;s--,l+=i[r++]<<d,d+=8}if(n.flags=l,(255&n.flags)!==Vo){e.msg="unknown compression method",n.mode=ts;break}if(57344&n.flags){e.msg="unknown header flags set",n.mode=ts;break}n.head&&(n.head.text=l>>8&1),512&n.flags&&4&n.wrap&&(M[0]=255&l,M[1]=l>>>8&255,n.check=io(n.check,M,2,0)),l=0,d=0,n.mode=16182;case 16182:for(;d<32;){if(0===s)break e;s--,l+=i[r++]<<d,d+=8}n.head&&(n.head.time=l),512&n.flags&&4&n.wrap&&(M[0]=255&l,M[1]=l>>>8&255,M[2]=l>>>16&255,M[3]=l>>>24&255,n.check=io(n.check,M,4,0)),l=0,d=0,n.mode=16183;case 16183:for(;d<16;){if(0===s)break e;s--,l+=i[r++]<<d,d+=8}n.head&&(n.head.xflags=255&l,n.head.os=l>>8),512&n.flags&&4&n.wrap&&(M[0]=255&l,M[1]=l>>>8&255,n.check=io(n.check,M,2,0)),l=0,d=0,n.mode=16184;case 16184:if(1024&n.flags){for(;d<16;){if(0===s)break e;s--,l+=i[r++]<<d,d+=8}n.length=l,n.head&&(n.head.extra_len=l),512&n.flags&&4&n.wrap&&(M[0]=255&l,M[1]=l>>>8&255,n.check=io(n.check,M,2,0)),l=0,d=0}else n.head&&(n.head.extra=null);n.mode=16185;case 16185:if(1024&n.flags&&((m=n.length)>s&&(m=s),m&&(n.head&&(S=n.head.extra_len-n.length,n.head.extra||(n.head.extra=new Uint8Array(n.head.extra_len)),n.head.extra.set(i.subarray(r,r+m),S)),512&n.flags&&4&n.wrap&&(n.check=io(n.check,i,m,r)),s-=m,r+=m,n.length-=m),n.length))break e;n.length=0,n.mode=16186;case 16186:if(2048&n.flags){if(0===s)break e;m=0;do{S=i[r+m++],n.head&&S&&n.length<65536&&(n.head.name+=String.fromCharCode(S))}while(S&&m<s);if(512&n.flags&&4&n.wrap&&(n.check=io(n.check,i,m,r)),s-=m,r+=m,S)break e}else n.head&&(n.head.name=null);n.length=0,n.mode=16187;case 16187:if(4096&n.flags){if(0===s)break e;m=0;do{S=i[r+m++],n.head&&S&&n.length<65536&&(n.head.comment+=String.fromCharCode(S))}while(S&&m<s);if(512&n.flags&&4&n.wrap&&(n.check=io(n.check,i,m,r)),s-=m,r+=m,S)break e}else n.head&&(n.head.comment=null);n.mode=16188;case 16188:if(512&n.flags){for(;d<16;){if(0===s)break e;s--,l+=i[r++]<<d,d+=8}if(4&n.wrap&&l!==(65535&n.check)){e.msg="header crc mismatch",n.mode=ts;break}l=0,d=0}n.head&&(n.head.hcrc=n.flags>>9&1,n.head.done=!0),e.adler=n.check=0,n.mode=Yo;break;case 16189:for(;d<32;){if(0===s)break e;s--,l+=i[r++]<<d,d+=8}e.adler=n.check=ns(l),l=0,d=0,n.mode=Xo;case Xo:if(0===n.havedict)return e.next_out=o,e.avail_out=u,e.next_in=r,e.avail_in=s,n.hold=l,n.bits=d,Bo;e.adler=n.check=1,n.mode=Yo;case Yo:if(t===$o||t===No)break e;case qo:if(n.last){l>>>=7&d,d-=7&d,n.mode=es;break}for(;d<3;){if(0===s)break e;s--,l+=i[r++]<<d,d+=8}switch(n.last=1&l,d-=1,3&(l>>>=1)){case 0:n.mode=16193;break;case 1:if(hs(n),n.mode=Qo,t===No){l>>>=2,d-=2;break e}break;case 2:n.mode=16196;break;case 3:e.msg="invalid block type",n.mode=ts}l>>>=2,d-=2;break;case 16193:for(l>>>=7&d,d-=7&d;d<32;){if(0===s)break e;s--,l+=i[r++]<<d,d+=8}if((65535&l)!=(l>>>16^65535)){e.msg="invalid stored block lengths",n.mode=ts;break}if(n.length=65535&l,l=0,d=0,n.mode=Jo,t===No)break e;case Jo:n.mode=16195;case 16195:if(m=n.length){if(m>s&&(m=s),m>u&&(m=u),0===m)break e;a.set(i.subarray(r,r+m),o),s-=m,r+=m,u-=m,o+=m,n.length-=m;break}n.mode=Yo;break;case 16196:for(;d<14;){if(0===s)break e;s--,l+=i[r++]<<d,d+=8}if(n.nlen=257+(31&l),l>>>=5,d-=5,n.ndist=1+(31&l),l>>>=5,d-=5,n.ncode=4+(15&l),l>>>=4,d-=4,n.nlen>286||n.ndist>30){e.msg="too many length or distance symbols",n.mode=ts;break}n.have=0,n.mode=16197;case 16197:for(;n.have<n.ncode;){for(;d<3;){if(0===s)break e;s--,l+=i[r++]<<d,d+=8}n.lens[A[n.have++]]=7&l,l>>>=3,d-=3}for(;n.have<19;)n.lens[A[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,P={bits:n.lenbits},E=Fo(0,n.lens,0,19,n.lencode,0,n.work,P),n.lenbits=P.bits,E){e.msg="invalid code lengths set",n.mode=ts;break}n.have=0,n.mode=16198;case 16198:for(;n.have<n.nlen+n.ndist;){for(;g=(_=n.lencode[l&(1<<n.lenbits)-1])>>>16&255,y=65535&_,!((p=_>>>24)<=d);){if(0===s)break e;s--,l+=i[r++]<<d,d+=8}if(y<16)l>>>=p,d-=p,n.lens[n.have++]=y;else{if(16===y){for(T=p+2;d<T;){if(0===s)break e;s--,l+=i[r++]<<d,d+=8}if(l>>>=p,d-=p,0===n.have){e.msg="invalid bit length repeat",n.mode=ts;break}S=n.lens[n.have-1],m=3+(3&l),l>>>=2,d-=2}else if(17===y){for(T=p+3;d<T;){if(0===s)break e;s--,l+=i[r++]<<d,d+=8}d-=p,S=0,m=3+(7&(l>>>=p)),l>>>=3,d-=3}else{for(T=p+7;d<T;){if(0===s)break e;s--,l+=i[r++]<<d,d+=8}d-=p,S=0,m=11+(127&(l>>>=p)),l>>>=7,d-=7}if(n.have+m>n.nlen+n.ndist){e.msg="invalid bit length repeat",n.mode=ts;break}for(;m--;)n.lens[n.have++]=S}}if(n.mode===ts)break;if(0===n.lens[256]){e.msg="invalid code -- missing end-of-block",n.mode=ts;break}if(n.lenbits=9,P={bits:n.lenbits},E=Fo(1,n.lens,0,n.nlen,n.lencode,0,n.work,P),n.lenbits=P.bits,E){e.msg="invalid literal/lengths set",n.mode=ts;break}if(n.distbits=6,n.distcode=n.distdyn,P={bits:n.distbits},E=Fo(2,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,P),n.distbits=P.bits,E){e.msg="invalid distances set",n.mode=ts;break}if(n.mode=Qo,t===No)break e;case Qo:n.mode=Zo;case Zo:if(s>=6&&u>=258){e.next_out=o,e.avail_out=u,e.next_in=r,e.avail_in=s,n.hold=l,n.bits=d,Do(e,h),o=e.next_out,a=e.output,u=e.avail_out,r=e.next_in,i=e.input,s=e.avail_in,l=n.hold,d=n.bits,n.mode===Yo&&(n.back=-1);break}for(n.back=0;g=(_=n.lencode[l&(1<<n.lenbits)-1])>>>16&255,y=65535&_,!((p=_>>>24)<=d);){if(0===s)break e;s--,l+=i[r++]<<d,d+=8}if(g&&!(240&g)){for(b=p,w=g,k=y;g=(_=n.lencode[k+((l&(1<<b+w)-1)>>b)])>>>16&255,y=65535&_,!(b+(p=_>>>24)<=d);){if(0===s)break e;s--,l+=i[r++]<<d,d+=8}l>>>=b,d-=b,n.back+=b}if(l>>>=p,d-=p,n.back+=p,n.length=y,0===g){n.mode=16205;break}if(32&g){n.back=-1,n.mode=Yo;break}if(64&g){e.msg="invalid literal/length code",n.mode=ts;break}n.extra=15&g,n.mode=16201;case 16201:if(n.extra){for(T=n.extra;d<T;){if(0===s)break e;s--,l+=i[r++]<<d,d+=8}n.length+=l&(1<<n.extra)-1,l>>>=n.extra,d-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=16202;case 16202:for(;g=(_=n.distcode[l&(1<<n.distbits)-1])>>>16&255,y=65535&_,!((p=_>>>24)<=d);){if(0===s)break e;s--,l+=i[r++]<<d,d+=8}if(!(240&g)){for(b=p,w=g,k=y;g=(_=n.distcode[k+((l&(1<<b+w)-1)>>b)])>>>16&255,y=65535&_,!(b+(p=_>>>24)<=d);){if(0===s)break e;s--,l+=i[r++]<<d,d+=8}l>>>=b,d-=b,n.back+=b}if(l>>>=p,d-=p,n.back+=p,64&g){e.msg="invalid distance code",n.mode=ts;break}n.offset=y,n.extra=15&g,n.mode=16203;case 16203:if(n.extra){for(T=n.extra;d<T;){if(0===s)break e;s--,l+=i[r++]<<d,d+=8}n.offset+=l&(1<<n.extra)-1,l>>>=n.extra,d-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){e.msg="invalid distance too far back",n.mode=ts;break}n.mode=16204;case 16204:if(0===u)break e;if(m=h-u,n.offset>m){if((m=n.offset-m)>n.whave&&n.sane){e.msg="invalid distance too far back",n.mode=ts;break}m>n.wnext?(m-=n.wnext,f=n.wsize-m):f=n.wnext-m,m>n.length&&(m=n.length),v=n.window}else v=a,f=o-n.offset,m=n.length;m>u&&(m=u),u-=m,n.length-=m;do{a[o++]=v[f++]}while(--m);0===n.length&&(n.mode=Zo);break;case 16205:if(0===u)break e;a[o++]=n.length,u--,n.mode=Zo;break;case es:if(n.wrap){for(;d<32;){if(0===s)break e;s--,l|=i[r++]<<d,d+=8}if(h-=u,e.total_out+=h,n.total+=h,4&n.wrap&&h&&(e.adler=n.check=n.flags?io(n.check,a,h,o-h):to(n.check,a,h,o-h)),h=u,4&n.wrap&&(n.flags?l:ns(l))!==n.check){e.msg="incorrect data check",n.mode=ts;break}l=0,d=0}n.mode=16207;case 16207:if(n.wrap&&n.flags){for(;d<32;){if(0===s)break e;s--,l+=i[r++]<<d,d+=8}if(4&n.wrap&&l!==(4294967295&n.total)){e.msg="incorrect length check",n.mode=ts;break}l=0,d=0}n.mode=16208;case 16208:E=jo;break e;case ts:E=Uo;break e;case 16210:return Ho;default:return zo}return e.next_out=o,e.avail_out=u,e.next_in=r,e.avail_in=s,n.hold=l,n.bits=d,(n.wsize||h!==e.avail_out&&n.mode<ts&&(n.mode<es||t!==Oo))&&ms(e,e.output,e.next_out,h-e.avail_out),c-=e.avail_in,h-=e.avail_out,e.total_in+=c,e.total_out+=h,n.total+=h,4&n.wrap&&h&&(e.adler=n.check=n.flags?io(n.check,a,h,e.next_out-h):to(n.check,a,h,e.next_out-h)),e.data_type=n.bits+(n.last?64:0)+(n.mode===Yo?128:0)+(n.mode===Qo||n.mode===Jo?256:0),(0===c&&0===h||t===Oo)&&E===Wo&&(E=Go),E},vs={inflateReset:us,inflateReset2:ls,inflateResetKeep:ss,inflateInit:e=>ds(e,15),inflateInit2:ds,inflate:fs,inflateEnd:e=>{if(os(e))return zo;var t=e.state;return t.window&&(t.window=null),e.state=null,Wo},inflateGetHeader:(e,t)=>{if(os(e))return zo;var n=e.state;return 2&n.wrap?(n.head=t,t.done=!1,Wo):zo},inflateSetDictionary:(e,t)=>{var n,i=t.length;return os(e)||0!==(n=e.state).wrap&&n.mode!==Xo?zo:n.mode===Xo&&to(1,t,i,0)!==n.check?Uo:ms(e,t,i,i)?(n.mode=16210,Ho):(n.havedict=1,Wo)},inflateInfo:"pako inflate (from Nodeca project)"};var ps=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1},gs=Object.prototype.toString,ys=ro,bs=oo,ws=lo,ks=co,Ss=ho,Es=mo,Ps=fo,Ts=vo;function _s(e){this.options=bo({chunkSize:65536,windowBits:15,to:""},e||{});var t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),!(t.windowBits>=0&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&(15&t.windowBits||(t.windowBits|=15)),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Mo,this.strm.avail_out=0;var n=vs.inflateInit2(this.strm,t.windowBits);if(n!==ws)throw new Error(ao[n]);if(this.header=new ps,vs.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=Po(t.dictionary):"[object ArrayBuffer]"===gs.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(n=vs.inflateSetDictionary(this.strm,t.dictionary))!==ws))throw new Error(ao[n])}_s.prototype.push=function(e,t){var n,i,a,r=this.strm,o=this.options.chunkSize,s=this.options.dictionary;if(this.ended)return!1;for(i=t===~~t?t:!0===t?bs:ys,"[object ArrayBuffer]"===gs.call(e)?r.input=new Uint8Array(e):r.input=e,r.next_in=0,r.avail_in=r.input.length;;){for(0===r.avail_out&&(r.output=new Uint8Array(o),r.next_out=0,r.avail_out=o),(n=vs.inflate(r,i))===Ss&&s&&((n=vs.inflateSetDictionary(r,s))===ws?n=vs.inflate(r,i):n===Ps&&(n=Ss));r.avail_in>0&&n===ks&&r.state.wrap>0&&0!==e[r.next_in];)vs.inflateReset(r),n=vs.inflate(r,i);switch(n){case Es:case Ps:case Ss:case Ts:return this.onEnd(n),this.ended=!0,!1}if(a=r.avail_out,r.next_out&&(0===r.avail_out||n===ks))if("string"===this.options.to){var u=_o(r.output,r.next_out),l=r.next_out-u,d=To(r.output,u);r.next_out=l,r.avail_out=o-l,l&&r.output.set(r.output.subarray(u,u+l),0),this.onData(d)}else this.onData(r.output.length===r.next_out?r.output:r.output.subarray(0,r.next_out));if(n!==ws||0!==a){if(n===ks)return n=vs.inflateEnd(this.strm),this.onEnd(n),this.ended=!0,!0;if(0===r.avail_in)break}}return!0},_s.prototype.onData=function(e){this.chunks.push(e)},_s.prototype.onEnd=function(e){e===ws&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=wo(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var Ms={ungzip:function(e,t){var n=new _s(t);if(n.push(e),n.err)throw n.msg||ao[n.err];return n.result}}.ungzip,As=e=>{var t;if(null!=e&&e.includes(un))t=an;else{var n=null==e?void 0:e.find(e=>e.includes(on));t=n?n.split("=")[1]:tn}return(t=t.replace(/\/$/,""))+"/"+Zt},Ds=e=>{var t,n,i=Fr.getAppConfig(at)||Fr.getAppConfig(yt);return null!==(t=null==i||null===(n=i.capabilities)||void 0===n?void 0:n.includes(e))&&void 0!==t&&t},xs=()=>{var e,t,n=(t=Fr.getAppConfig(at)||Fr.getAppConfig(yt),null!==(e=null==t?void 0:t.campaign_cache_ttl)&&void 0!==e?e:null);if(null!==n)if(0!==n){var i=Fr.getApiCampaignSessionTimestamp();if(null!==i)(Date.now()-i)/1e3>=n&&Fr.purgeApiCampaignCache()}else Fr.purgeApiCampaignCache()},Cs=e=>{var t=!Ds(Pe.THIRD_PARTY_TRANSACTIONS);return e&&!t&&ui.info(`[${e}] Your plan does not have purchase management features.`),t},Is=()=>{var e,t,n=null===(e=Fr.getNamiConfig())||void 0===e?void 0:e.namiCommands;return null!==(t=null==n?void 0:n.includes(pn))&&void 0!==t&&t},Ls=()=>{var e,t,n=null===(e=Fr.getNamiConfig())||void 0===e?void 0:e.namiCommands;return null!==(t=null==n?void 0:n.includes(yn))&&void 0!==t&&t};function Rs(e){try{var t=function(e){if("undefined"!=typeof Buffer)return new Uint8Array(Buffer.from(e,"base64"));for(var t=atob(e),n=t.length,i=new Uint8Array(n),a=0;a<n;a++)i[a]=t.charCodeAt(a);return i}(e.trim()),n=Ms(t),i=(new TextDecoder).decode(n);return JSON.parse(i)}catch(e){return}}function Fs(e,t,n=_n,i=Sn){var r,o,s,u,l,d,c;return k(function(h){for(;;)switch(h.n){case 0:return o=0,s=Is(),u=Ls(),l=null!==(r=null==t?void 0:t.method)&&void 0!==r?r:"GET",d=()=>{var r,c,h,m;return k(function(f){for(;;)switch(f.n){case 0:return(s||u)&&ui.debug(`[HTTP] ${l} ${e}`),u&&null!=t&&t.body&&ui.debug(`[HTTP] Request body: ${t.body}`),f.n=1,a(Os(e,t,n));case 1:if((r=f.v).ok){f.n=7;break}if(!u){f.n=3;break}return f.n=2,a(r.clone().text());case 2:c=f.v,ui.debug(`[HTTP] Response ${r.status}: ${c}`);case 3:if(r.status!=Rn){f.n=4;break}throw new Nr;case 4:if(!(++o<=i)){f.n=6;break}return h=1e3*(o+Pn),f.n=5,a(new Promise(e=>setTimeout(e,h)));case 5:return f.a(2,d());case 6:throw new Or(r.status,`Request failed after ${i} retries`);case 7:if(!u){f.n=9;break}return f.n=8,a(r.clone().text());case 8:m=f.v,ui.debug(`[HTTP] Response ${r.status}: ${m}`);case 9:return f.a(2,r)}},null,null,null,Promise)},h.n=1,a(d());case 1:return c=h.v,h.a(2,c.json())}},null,null,null,Promise)}function Os(e,t={},n){var i,r,o;return k(function(s){for(;;)switch(s.n){case 0:return i=new AbortController,r=setTimeout(()=>i.abort(),n),t.signal=i.signal,s.n=1,a(fetch(e,t));case 1:return o=s.v,clearTimeout(r),s.a(2,o)}},null,null,null,Promise)}function $s(e,t,n){var i=n.value;return n.value=function(...e){if(!this.platformID)throw new jr;return i.apply(this,e)},n}function Ns(e,t,n){var i=n.value;return n.value=function(...e){var t=Fr.getDevice();if(null==t||!t.id)throw new Br;return i.apply(this,e)},n}var Ws,js=function(){function e(){o(this,e);var t=Fr.getNamiConfig();!this.platformID&&t&&this.configure(t)}return c(e,[{key:"deviceID",get:function(){var e;return null===(e=Fr.getDevice())||void 0===e?void 0:e.id}},{key:"configure",value:function(e){this.baseURL=As(e.namiCommands),this.platformID=e.appPlatformID}},{key:"reset",value:function(){this.baseURL=void 0,this.platformID=void 0}},{key:"login",value:function(e){var t,n;return k(function(i){for(;;)switch(i.n){case 0:if(e){i.n=1;break}throw new zr;case 1:return t=`device/${this.deviceID}/login/`,n={external_id:e},i.n=2,a(this.requestBodyAPI(t,n,"PUT"));case 2:return i.a(2,i.v)}},null,this,null,Promise)}},{key:"logout",value:function(){var e;return k(function(t){for(;;)switch(t.n){case 0:return e=`device/${this.deviceID}/logout/`,t.n=1,a(this.requestBodyAPI(e,{},"PUT"));case 1:return t.a(2,t.v)}},null,this,null,Promise)}},{key:"startSession",value:function(e){var t,n;return k(function(i){for(;;)switch(i.n){case 0:return t=`device/${this.deviceID}/session/`,i.n=1,a(this.requestBodyAPI(t,{start_time:e,app_env:"production"}));case 1:n=i.v,Fr.setSessionCounter(),n.id&&Fr.setSessionId(n.id);case 2:return i.a(2)}},null,this,null,Promise)}},{key:"postImpression",value:function(t){var n,i,r;return k(function(o){for(;;)switch(o.n){case 0:return n=`device/${this.deviceID}/impression/`,o.n=1,a(this.requestBodyAPI(n,t,"POST",!0));case 1:(i=o.v).id&&(Fr.setLastImpressionId(i.id),null===(r=e.impressionListener)||void 0===r||r.call(e,i.id));case 2:return o.a(2)}},null,this,null,Promise)}},{key:"patchImpressionCompletion",value:function(e,t,n){var i;return k(function(r){for(;;)switch(r.n){case 0:return i=`device/${this.deviceID}/impression/${e}/`,r.n=1,a(this.requestBodyAPI(i,{completion_result:t,completion_result_date:n},"PATCH",!0));case 1:return r.a(2)}},null,this,null,Promise)}},{key:"postConversion",value:function(e){var t;return k(function(n){for(;;)switch(n.n){case 0:return t=`device/${this.deviceID}/transaction/`,n.n=1,a(this.requestBodyAPI(t,e,"POST",!0));case 1:return n.a(2)}},null,this,null,Promise)}},{key:"purchaseValidation",value:function(e){var t;return k(function(n){for(;;)switch(n.n){case 0:return t=`device/${this.deviceID}/purchase_event/`,n.n=1,a(this.requestBodyAPI(t,e,"PUT"));case 1:return n.a(2)}},null,this,null,Promise)}},{key:"fetchAPI",value:function(e,t,n){var i;return k(function(r){for(;;)switch(r.n){case 0:return i=`${this.baseURL}/${this.platformID}/`+e,r.n=1,a(Fs(i,void 0,t,n));case 1:return r.a(2,r.v)}},null,this,null,Promise)}},{key:"requestBodyAPI",value:function(e,t,n="POST",i=!1,r,o){var s,u;return k(function(l){for(;;)switch(l.n){case 0:return s=`${this.baseURL}/${this.platformID}/`+e,u={method:n,headers:{"Content-Type":"application/json"},body:JSON.stringify(t),keepalive:i},l.n=1,a(Fs(s,u,r,o));case 1:return l.a(2,l.v)}},null,this,null,Promise)}}],[{key:"configure",value:function(e){this.instance.configure(e)}},{key:"reset",value:function(){this.instance.reset()}}])}();function Bs(e){return null!=(null==e?void 0:e.flow)}js.instance=new js,ke([Ns],js.prototype,"login",null),ke([Ns],js.prototype,"logout",null),ke([Ns],js.prototype,"startSession",null),ke([Ns],js.prototype,"postImpression",null),ke([Ns],js.prototype,"patchImpressionCompletion",null),ke([Ns],js.prototype,"postConversion",null),ke([Ns],js.prototype,"purchaseValidation",null),ke([$s],js.prototype,"fetchAPI",null),ke([$s],js.prototype,"requestBodyAPI",null),e.NamiCampaignRuleType=void 0,(Ws=e.NamiCampaignRuleType||(e.NamiCampaignRuleType={})).DEFAULT="default",Ws.LABEL="label",Ws.UNKNOWN="unknown",Ws.URL="url";var zs=()=>{var e;return null!==(e=Fr.getPaywalls(St))&&void 0!==e?e:[]},Us=()=>{var e;return null!==(e=Fr.getPaywalls(ut))&&void 0!==e?e:[]},Hs=()=>Lr(li([...Us(),...zs()]),"id"),Gs=e=>Hs().find(t=>t.id===e),Vs=e=>{var t=Hs(),n=new Set(t.map(e=>e.id));return e.every(e=>n.has(e))},Ks="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof global?global:{},Xs="function"==typeof Ks.BigInt,Ys=Xs?Ks.BigInt.bind(Ks):void 0,qs=Xs?Ys("0xffffffffffffffffffffffffffffffff"):null,Js=Xs?Ys("0x100000000000000000000000000000000"):null,Qs=Xs?Ys(0):null,Zs=Xs?Ys(1):null,eu=Xs?Ys(8):null,tu=Xs?Ys(1e4):null,nu=Ks.crypto,iu="function"==typeof(null==nu?void 0:nu.getRandomValues),au=1/16,ru=e=>we().device.getDeviceData(e),ou=()=>{var e=Fr.getNamiConfig();return e&&e.formFactor?e.formFactor:we().device.getDeviceFormFactor()};function su(){return we().device.generateUUID()}function uu(e){if(!Xs||!qs)return cu(e);try{var t=qs,n=function(e){if(!Ys)throw new Error("BigInt is not supported in this environment");var t=e.replace(/-/g,"");return Ys("0x"+t)}(e);return Number(n)/Number(t)*100}catch(t){throw ui.error(`Error calculating audience split position for UUID ${e}`,t),new Error(`Invalid UUID format: ${e}`)}}function lu(e){if(!Ys)throw new Error("BigInt is not supported in this environment");var t=e.toString(16).padStart(32,"0");t=t.substring(0,12)+"4"+t.substring(13);var n=3&parseInt(t[16],16)|8;return(t=t.substring(0,16)+n.toString(16)+t.substring(17)).slice(0,8)+"-"+t.slice(8,12)+"-"+t.slice(12,16)+"-"+t.slice(16,20)+"-"+t.slice(20)}function du(e,t=.5){if(!Number.isFinite(e))throw new Error("Invalid target");if(!Number.isFinite(t))throw new Error("Invalid tolerance");var n=Math.max(0,Math.min(100,e)),i=Math.max(0,Math.min(50,t)),a=e=>Math.round(100*e),r=Math.max(0,a(n-i)),o=Math.min(1e4,a(n+i));if(!(Xs&&qs&&Ys&&tu))return function(e,t){for(var n=Math.max(0,Math.min(100,e-t)),i=Math.min(100,Math.max(0,e+t)),a=su(),r=Number.POSITIVE_INFINITY,o=50,s=0;s<o;s++){var u=su(),l=cu(u);if(l>=n&&l<=i)return u;var d=hu(l,n,i);d<r&&(r=d,a=u)}return a}(n,i);var s=qs,u=Ys,l=tu,d=e=>s*u(e)/l,c=d(r),m=d(o);if(m<=c)return lu(c);var f=c+function(e){if(!Ys||null===Js||null===Zs||null===Qs||null===eu)throw new Error("BigInt is not supported in this environment");var t=Ys,n=Qs,i=Zs,a=eu,r=Js;if(e<n)throw new Error("n must be non-negative");if(e===n)return n;for(var o=new Uint8Array(16),s=e+i,u=r/s*s-i,l=0,d=!1;l<10;){if(iu)nu.getRandomValues(o);else{d||(d=!0,ui.warn("randomBigInt: crypto.getRandomValues unavailable, using Math.random fallback"));for(var c=0;c<o.length;c++)o[c]=Math.floor(256*Math.random())}for(var m,f=n,v=h(o);!(m=v()).done;)f=f<<a|t(m.value);if(f<=u)return f%s;l++}if(iu)try{nu.getRandomValues(o);for(var p,g=n,y=h(o);!(p=y()).done;)g=g<<a|t(p.value);var b=g%s;return ui.warn("randomBigInt: reached max rejection attempts, using modulo fallback",{n:e.toString(),attempts:l}),b}catch(e){throw ui.error("randomBigInt: failed to generate random values",e),new Error("randomBigInt: unable to generate random value")}for(var w,k=n,S=h(o);!(w=S()).done;)k=k<<a|t(w.value);return ui.warn("randomBigInt: reached max rejection attempts without crypto, using modulo fallback",{n:e.toString(),attempts:l}),k%s}(m-c);return lu(f)}function cu(e){var t=function(e){var t=e.replace(/-/g,"").toLowerCase();if(!/^[0-9a-f]{32}$/.test(t))throw new Error(`Invalid UUID format: ${e}`);for(var n=0,i=t.length-1;i>=0;i--){n=(n+parseInt(t[i],16))*au}return n}(e);return 100*t}function hu(e,t,n){return e<t?t-e:e>n?e-n:0}new Intl.DateTimeFormat("en-US",{hourCycle:"h23",timeZone:"America/New_York",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}).format(new Date("2014-06-25T04:00:00.123Z"));var mu,fu=e=>{try{return!isNaN(new Date(e).getTime())}catch(e){return!1}},vu=(e,t,n=new Date)=>{var i=n.getTime(),a=!e||!fu(e)||new Date(e).getTime()<i,r=!t||!fu(t)||new Date(t).getTime()>i;return a&&r},pu=e=>{try{var t=new URL(e);return("http:"===t.protocol||"https:"===t.protocol)&&!!t.hostname}catch(e){return!1}},gu=e=>{try{var t=new URL(e),n=t.origin+t.pathname,i=new Set;return t.searchParams.forEach((e,t)=>{i.add(`${t}=${e}`)}),{basePath:n,params:i}}catch(e){return}},yu=(e,t,n)=>e?e.flatMap(e=>{var i;if(i="string"==typeof n?e.segments.filter(e=>e.form_factors.some(e=>e.form_factor===n)):e.segments,0===i.length)return[];var a=((e,t)=>{for(var n,i=[...e].sort((e,t)=>e.split-t.split),a=h(i);!(n=a()).done;){var r=n.value;if(t<=r.split)return r}return i[i.length-1]})(i,t);return{form_factors:a.form_factors,paywall:a.paywall,paywall_url:a.paywall_url,page_urls:a.page_urls,flow:a.flow,segment:a.segment,split:a.split,conversion_event_type:a.conversion_event_type,conversion_event_url:a.conversion_event_url,rule:e.rule,name:e.name,type:e.type,value:e.value,external_segment:e.external_segment}}):[],bu=()=>{var e,t,n=null!==(e=Fr.getCampaignRules(ot))&&void 0!==e?e:[],i=null!==(t=Fr.getCampaignRules(wt))&&void 0!==t?t:[],a=ou(),r=li([...n,...i]).filter(e=>{var t;return null===(t=e.form_factors)||void 0===t?void 0:t.some(e=>e.form_factor===a)}).filter(e=>vu(e.not_before,e.expires_at)),o=new Set;return r.filter(e=>{var t,n,i=`${null!==(t=e.type)&&void 0!==t?t:""}::${null!==(n=e.value)&&void 0!==n?n:""}`;return!o.has(i)&&(o.add(i),!0)})},wu=e=>{var t,n=null!==(t=Fr.getCampaignRules(e))&&void 0!==t?t:[],i=ou();return li(n).filter(e=>{var t;return null===(t=e.form_factors)||void 0===t?void 0:t.some(e=>e.form_factor===i)}).filter(e=>vu(e.not_before,e.expires_at))},ku=()=>wu(wt),Su=()=>wu(ot),Eu=(t,n,i,a)=>{var r=(()=>{if(!a)return t().find(t=>t.type==e.NamiCampaignRuleType.DEFAULT);if(a===e.NamiCampaignRuleType.URL){var n=t().filter(t=>t.type==e.NamiCampaignRuleType.URL);return((e,t)=>{var n,i,a,r=gu(e);if(r){for(var o,s,u,l=h(t);!(u=l()).done;){var d=u.value,c=d.value;if(c){var m=gu(c);if(m&&m.basePath===r.basePath){var f=m.params.size;if(0!==f){for(var v,p=0,g=h(m.params);!(v=g()).done;){var y=v.value;r.params.has(y)&&p++}p===f?(!o||f>o.totalParams)&&(o={campaign:d,totalParams:f}):o||(!s||p>s.score||p===s.score&&f>s.totalParams)&&(s={campaign:d,score:p,totalParams:f})}else o||s||(s={campaign:d,score:0,totalParams:0})}}}return null!==(n=null===(i=o)||void 0===i?void 0:i.campaign)&&void 0!==n?n:null===(a=s)||void 0===a?void 0:a.campaign}})(i,n)}return t().find(e=>e.type==a&&e.value==i)})();if(!r)return{};var o=n().find(e=>(null==r?void 0:r.paywall)===e.id);return{campaign:r,paywall:o}},Pu=(e,t)=>{var n=Eu(Su,Us,e,t);if(n.campaign&&n.paywall)return{campaign:n.campaign,paywall:n.paywall};var i=Eu(ku,zs,e,t);return i.campaign&&i.paywall?{campaign:i.campaign,paywall:i.paywall}:n.campaign||n.paywall?{campaign:n.campaign,paywall:n.paywall}:{campaign:i.campaign,paywall:i.paywall}},Tu="object"==typeof Reflect?Reflect:null,_u=Tu&&"function"==typeof Tu.apply?Tu.apply:function(e,t,n){return Function.prototype.apply.call(e,t,n)};mu=Tu&&"function"==typeof Tu.ownKeys?Tu.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var Mu=Number.isNaN||function(e){return e!=e};function Au(){Au.init.call(this)}Au.EventEmitter=Au,Au.prototype._events=void 0,Au.prototype._eventsCount=0,Au.prototype._maxListeners=void 0;var Du=10;function xu(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function Cu(e){return void 0===e._maxListeners?Au.defaultMaxListeners:e._maxListeners}function Iu(e,t,n,i){var a,r,o,s;if(xu(n),void 0===(r=e._events)?(r=e._events=Object.create(null),e._eventsCount=0):(void 0!==r.newListener&&(e.emit("newListener",t,n.listener?n.listener:n),r=e._events),o=r[t]),void 0===o)o=r[t]=n,++e._eventsCount;else if("function"==typeof o?o=r[t]=i?[n,o]:[o,n]:i?o.unshift(n):o.push(n),(a=Cu(e))>0&&o.length>a&&!o.warned){o.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=o.length,s=u,console&&console.warn&&console.warn(s)}return e}function Lu(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function Ru(e,t,n){var i={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},a=Lu.bind(i);return a.listener=n,i.wrapFn=a,a}function Fu(e,t,n){var i=e._events;if(void 0===i)return[];var a=i[t];return void 0===a?[]:"function"==typeof a?n?[a.listener||a]:[a]:n?function(e){for(var t=new Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}(a):$u(a,a.length)}function Ou(e){var t=this._events;if(void 0!==t){var n=t[e];if("function"==typeof n)return 1;if(void 0!==n)return n.length}return 0}function $u(e,t){for(var n=new Array(t),i=0;i<t;++i)n[i]=e[i];return n}Object.defineProperty(Au,"defaultMaxListeners",{enumerable:!0,get:function(){return Du},set:function(e){if("number"!=typeof e||e<0||Mu(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");Du=e}}),Au.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},Au.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||Mu(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},Au.prototype.getMaxListeners=function(){return Cu(this)},Au.prototype.emit=function(e){for(var t=[],n=1;n<arguments.length;n++)t.push(arguments[n]);var i="error"===e,a=this._events;if(void 0!==a)i=i&&void 0===a.error;else if(!i)return!1;if(i){var r;if(t.length>0&&(r=t[0]),r instanceof Error)throw r;var o=new Error("Unhandled error."+(r?" ("+r.message+")":""));throw o.context=r,o}var s=a[e];if(void 0===s)return!1;if("function"==typeof s)_u(s,this,t);else for(var u=s.length,l=$u(s,u),d=0;d<u;++d)_u(l[d],this,t);return!0},Au.prototype.addListener=function(e,t){return Iu(this,e,t,!1)},Au.prototype.on=Au.prototype.addListener,Au.prototype.prependListener=function(e,t){return Iu(this,e,t,!0)},Au.prototype.once=function(e,t){return xu(t),this.on(e,Ru(this,e,t)),this},Au.prototype.prependOnceListener=function(e,t){return xu(t),this.prependListener(e,Ru(this,e,t)),this},Au.prototype.removeListener=function(e,t){var n,i,a,r,o;if(xu(t),void 0===(i=this._events))return this;if(void 0===(n=i[e]))return this;if(n===t||n.listener===t)0===--this._eventsCount?this._events=Object.create(null):(delete i[e],i.removeListener&&this.emit("removeListener",e,n.listener||t));else if("function"!=typeof n){for(a=-1,r=n.length-1;r>=0;r--)if(n[r]===t||n[r].listener===t){o=n[r].listener,a=r;break}if(a<0)return this;0===a?n.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(n,a),1===n.length&&(i[e]=n[0]),void 0!==i.removeListener&&this.emit("removeListener",e,o||t)}return this},Au.prototype.off=Au.prototype.removeListener,Au.prototype.removeAllListeners=function(e){var t,n,i;if(void 0===(n=this._events))return this;if(void 0===n.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==n[e]&&(0===--this._eventsCount?this._events=Object.create(null):delete n[e]),this;if(0===arguments.length){var a,r=Object.keys(n);for(i=0;i<r.length;++i)"removeListener"!==(a=r[i])&&this.removeAllListeners(a);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=n[e]))this.removeListener(e,t);else if(void 0!==t)for(i=t.length-1;i>=0;i--)this.removeListener(e,t[i]);return this},Au.prototype.listeners=function(e){return Fu(this,e,!0)},Au.prototype.rawListeners=function(e){return Fu(this,e,!1)},Au.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):Ou.call(e,t)},Au.prototype.listenerCount=Ou,Au.prototype.eventNames=function(){return this._eventsCount>0?mu(this._events):[]};var Nu=function(){function e(){o(this,e),this.emitter=new Au}return c(e,[{key:"on",value:function(e,t){this.emitter.on(e,t)}},{key:"off",value:function(e,t){this.emitter.off(e,t)}},{key:"emit",value:function(e,...t){this.emitter.emit(e,...t)}},{key:"addListener",value:function(e,t){this.emitter.addListener(e,t)}},{key:"removeListener",value:function(e,t){this.emitter.removeListener(e,t)}},{key:"removeAllListeners",value:function(e){e?this.emitter.removeAllListeners(e):this.emitter.removeAllListeners()}},{key:"listeners",value:function(e){return this.emitter.listeners(e)}},{key:"listenerCount",value:function(e){return this.emitter.listenerCount(e)}}],[{key:"getInstance",value:function(){return this.instance||(this.instance=new e),this.instance}}])}(),Wu=function(){return c(function e(){o(this,e),this.disableCampaignUpdates=!1,this.useLegacyPaywallFetch=!1,this.currentFormFactor=ou()},[{key:"configure",value:function(e,t,n=[]){this.currentFormFactor=e,this.splitPosition=t,this.disableCampaignUpdates=n.includes("disableCampaignUpdates"),this.useLegacyPaywallFetch=n.includes("useLegacyPaywallFetch")}},{key:"reset",value:function(){this.currentFormFactor=ou(),this.splitPosition=void 0,this.disableCampaignUpdates=!1,this.useLegacyPaywallFetch=!1}},{key:"fetchCampaignRules",value:function(e){var t,n,i,r;return k(function(o){for(;;)switch(o.n){case 0:if(i=Fr.getDevice(),!this.disableCampaignUpdates){o.n=1;break}return ui.info("Campaign updates disabled by configuration. Skipping fetch."),o.a(2,[]);case 1:if(null!=i&&i.id){o.n=3;break}return o.n=2,a(this.getAnonymousCampaigns());case 2:r=o.v,o.n=5;break;case 3:return o.n=4,a(this.getCampaigns(i.id));case 4:r=o.v;case 5:return r=null===(t=r)||void 0===t?void 0:t.filter(e=>{var t;return e.paywall&&e.form_factors.some(e=>e.form_factor===this.currentFormFactor)||e.flow&&(null===(t=e.form_factors)||void 0===t?void 0:t.some(e=>e.form_factor===this.currentFormFactor))}),r=null===(n=r)||void 0===n?void 0:n.filter(t=>{if(t.paywall){var n=e.find(e=>e.id==t.paywall);if(n)return t}else if(t.flow)return t}),Fr.setCampaignRules(ot,r),Fr.setApiCampaignSessionTimestamp(),this.invokeAvailableCampaignsResponseHandler(),o.a(2,r)}},null,this,null,Promise)}},{key:"fetchCampaignRulesRaw",value:function(){var e,t,n;return k(function(i){for(;;)switch(i.n){case 0:if(t=Fr.getDevice(),!this.disableCampaignUpdates){i.n=1;break}return ui.info("Campaign updates disabled by configuration. Skipping fetch."),i.a(2,[]);case 1:if(null!=t&&t.id){i.n=3;break}return i.n=2,a(this.getAnonymousCampaigns());case 2:n=i.v,i.n=5;break;case 3:return i.n=4,a(this.getCampaigns(t.id));case 4:n=i.v;case 5:return n=null===(e=n)||void 0===e?void 0:e.filter(e=>{var t;return e.paywall&&e.form_factors.some(e=>e.form_factor===this.currentFormFactor)||e.flow&&(null===(t=e.form_factors)||void 0===t?void 0:t.some(e=>e.form_factor===this.currentFormFactor))}),i.a(2,n)}},null,this,null,Promise)}},{key:"finalizeCampaignRules",value:function(e,t){var n=new Set([...t.map(e=>e.id),...zs().map(e=>e.id)]),i=null==e?void 0:e.filter(e=>{return e.paywall?t.find(t=>t.id==e.paywall):!!e.flow&&(!!e.flow.object&&(null!==(i=e.flow.object.screens)&&void 0!==i?i:[]).every(e=>n.has(e)));var i});return Fr.setCampaignRules(ot,i),Fr.setApiCampaignSessionTimestamp(),this.invokeAvailableCampaignsResponseHandler(),i}},{key:"invokeAvailableCampaignsResponseHandler",value:function(){var e=Nu.getInstance().listeners(Hn),t=bu();e.forEach(e=>e(t))}},{key:"getAnonymousCampaigns",value:function(e=Ae){var t,n,i,r,o;return k(function(s){for(;;)switch(s.p=s.n){case 0:return t=`campaign_rules/?sdk_version=${e}`,s.p=1,s.n=2,a(js.instance.fetchAPI(t));case 2:return i=s.v,s.a(2,yu(null!==(n=i.results)&&void 0!==n?n:[],this.splitPosition,this.currentFormFactor));case 3:if(s.p=3,o=s.v,r=this.fallbackData()){s.n=4;break}throw ui.error(Zr(o.status,t)),o;case 4:return s.a(2,r.results)}},null,this,[[1,3]],Promise)}},{key:"getCampaigns",value:function(e){var t,n,i,r;return k(function(o){for(;;)switch(o.p=o.n){case 0:return n=`device/${e}/campaign_rules/`,o.p=1,o.n=2,a(js.instance.fetchAPI(n));case 2:i=o.v,o.n=4;break;case 3:if(o.p=3,r=o.v,i=this.fallbackData()){o.n=4;break}throw ui.error(Zr(r.status,n)),r;case 4:return o.a(2,(null===(t=i)||void 0===t?void 0:t.results)||[])}},null,this,[[1,3]],Promise)}},{key:"fallbackData",value:function(){var e=Fr.getCampaignRules(ot)||Fr.getCampaignRules(wt);return e?{count:e.length,results:e}:null}}],[{key:"extractPaywallUrls",value:function(e){for(var t,n=[],i=h(e);!(t=i()).done;){var a,r=t.value;r.paywall_url&&n.push(r.paywall_url),r.page_urls&&n.push(...Object.values(r.page_urls)),null!==(a=r.flow)&&void 0!==a&&a.page_urls&&n.push(...Object.values(r.flow.page_urls))}return n}},{key:"hasPaywallUrls",value:function(e){return e.some(e=>{var t;return e.paywall_url||e.page_urls||(null===(t=e.flow)||void 0===t?void 0:t.page_urls)})}}])}();function ju(e,t){return ar(e,t)}Wu.instance=new Wu;var Bu=function(){return c(function e(){o(this,e)},[{key:"createOrUpdateDevice",value:function(e,t,n){var i=Fr.getDevice();if(null==i||!i.id){var a,r=m({},e,{id:null!==(a=null!=t?t:this.getAnonymousUUID())&&void 0!==a?a:su()});return{id:r.id,device:this.createDevice(r,n)}}return this.isEqualDevices(i,e)?{id:i.id,device:Promise.resolve(i)}:(this.updateDevice(i.id,e),{id:i.id,device:null})}},{key:"createDevice",value:function(e,t){var n,i;return k(function(r){for(;;)switch(r.p=r.n){case 0:return r.p=0,r.n=1,a(this.requestAPIData("device/",e,void 0,void 0,0));case 1:if(!(n=r.v)){r.n=2;break}Fr.setDevice(n),r.n=3;break;case 2:return ui.info("Device creation returned null, switching to anon mode for this session"),null==t||t.setInMemoryAnonymousMode(!0),r.a(2,null);case 3:return r.a(2,n);case 4:if(r.p=4,i=r.v,console.error("Error creating device:",i),!(i instanceof Or)){r.n=5;break}return ui.info("Retry limit exceeded, switching to anon mode for this session"),null==t||t.setInMemoryAnonymousMode(!0),r.a(2,null);case 5:throw i;case 6:return r.a(2)}},null,this,[[0,4]],Promise)}},{key:"updateDevice",value:function(e,t){var n;return k(function(i){for(;;)switch(i.n){case 0:return i.n=1,a(this.requestAPIData(`device/${e}/`,t,"PUT"));case 1:return(n=i.v)&&Fr.setDevice(n),i.a(2,n)}},null,this,null,Promise)}},{key:"updateDeviceField",value:function(e,t){var n,i,r;return k(function(o){for(;;)switch(o.n){case 0:if(n={[e]:t},null!=(i=Fr.getDevice())&&i.id){o.n=1;break}throw new Br;case 1:return o.n=2,a(this.requestAPIData(`device/${i.id}/`,n,"PATCH"));case 2:return(r=o.v)&&Fr.setDevice(r),o.a(2,r)}},null,this,null,Promise)}},{key:"requestAPIData",value:function(e,t,n="POST",i=An,r){var o,s;return k(function(u){for(;;)switch(u.p=u.n){case 0:return u.p=0,u.n=1,a(js.instance.requestBodyAPI(e,t,n,!1,i,r));case 1:o=u.v,u.n=5;break;case 2:if(u.p=2,!((s=u.v)instanceof jr)){u.n=3;break}throw s;case 3:if(!("device/"===e&&s instanceof Or)){u.n=4;break}throw s;case 4:if(o=Fr.getDevice()){u.n=5;break}return ui.error(Zr(s.status,e)),u.a(2,null);case 5:return u.a(2,o)}},null,null,[[0,2]],Promise)}},{key:"isEqualDevices",value:function(e,t){var n=m({},e,t),i=Object.keys(e).reduce((e,t)=>(e[t]=n[t],e),{});return ju(i,e)}},{key:"getOrCreateAnonymousUUID",value:function(){var e=Fr.getAnonymousUUID();return e||(e=su(),Fr.setAnonymousUUID(e)),e}},{key:"getAnonymousUUID",value:function(){var e=Fr.getAnonymousUUID();return e?(Fr.clearAnonymousUUID(),e):null}}])}();Bu.instance=new Bu;var zu=function(){return c(function e(){o(this,e)},[{key:"fetchProducts",value:function(){var e,t,n,i;return k(function(r){for(;;)switch(r.p=r.n){case 0:if(!Ds(Pe.THIRD_PARTY_TRANSACTIONS)){r.n=1;break}return r.a(2,[]);case 1:return r.p=1,r.n=2,a(js.instance.fetchAPI("products/"));case 2:n=r.v,r.n=4;break;case 3:if(r.p=3,i=r.v,n=this.fallbackData()){r.n=4;break}throw ui.error(Zr(i.status,"products/")),i;case 4:return null!==(e=n)&&void 0!==e&&e.results&&Fr.setProducts(ht,n.results),r.a(2,(null===(t=n)||void 0===t?void 0:t.results)||[])}},null,this,[[1,3]],Promise)}},{key:"fallbackData",value:function(){var e=Fr.getProducts(ht)||Fr.getProducts(Pt);return e?{count:e.length,results:e}:null}}])}();zu.instance=new zu;var Uu=3,Hu=200,Gu=2e3,Vu=5e3,Ku=2e4,Xu=new Set([408,425,429]),Yu=new Set(["ECONNRESET","ECONNREFUSED","ENOTFOUND","ETIMEDOUT"]),qu=function(e){function t(e,n){var i;return o(this,t),(i=r(this,t,[`CDN fetch failed with non-retryable status ${e} for ${n}`])).name="NonRetryableHttpError",i.status=e,i.url=n,i}return p(t,e),c(t)}(M(Error)),Ju=function(e){function t(e,n,i){var a;return o(this,t),(a=r(this,t,[`CDN fetch exhausted ${n} attempts for ${e}${void 0!==i?` (last status ${i})`:""}`])).name="RetryExhaustedError",a.url=e,a.attempts=n,a.lastStatus=i,a}return p(t,e),c(t)}(M(Error));function Qu(e,t){if("number"==typeof t)return Xu.has(t)||t>=500;if(e&&"object"==typeof e){var n=e;if("AbortError"===n.name)return!0;if(n.code&&Yu.has(n.code))return!0;if(e instanceof TypeError)return!0}return!1}function Zu(e,t){var n,i;return k(function(r){for(;;)switch(r.p=r.n){case 0:return n=new AbortController,i=setTimeout(()=>n.abort(),t),r.p=1,r.n=2,a(fetch(e,{signal:n.signal}));case 2:return r.a(2,r.v);case 3:return r.p=3,clearTimeout(i),r.f(3);case 4:return r.a(2)}},null,null,[[1,,3,4]],Promise)}var el=e=>new Promise(t=>setTimeout(t,e));function tl(e,t={}){var n,i,r,o,s,u,l,d,c,h,m,f,v,p,g,y,b,w,S,E,P,T,_,M,A,D,x,C,I,L;return k(function(k){for(;;)switch(k.p=k.n){case 0:d=null!==(n=t.maxAttempts)&&void 0!==n?n:Uu,c=null!==(i=t.baseDelayMs)&&void 0!==i?i:Hu,h=null!==(r=t.maxDelayMs)&&void 0!==r?r:Gu,m=null!==(o=t.budgetMs)&&void 0!==o?o:Ku,f=null!==(s=t.timeoutMs)&&void 0!==s?s:Vu,v=null!==(u=t.randomFn)&&void 0!==u?u:Math.random,p=null!==(l=t.sleepFn)&&void 0!==l?l:el,g=Is(),y=Ls(),b=Date.now(),w=0;case 1:if(!(w<d)){k.n=16;break}if(!(w>0)){k.n=4;break}if(!((P=Date.now()-b)>=m)){k.n=2;break}return k.a(3,16);case 2:return T=Math.min(c*Math.pow(2,w-1),h),_=T*(v()-.5),M=Math.max(0,m-P),A=Math.min(Math.max(0,T+_),M),k.n=3,a(p(A));case 3:if(!(Date.now()-b>=m)){k.n=4;break}return k.a(3,16);case 4:return k.p=4,(g||y)&&ui.debug(`[HTTP] GET ${e} (cdn attempt ${w+1}/${d})`),k.n=5,a(Zu(e,f));case 5:if((D=k.v).ok){k.n=9;break}if(!y){k.n=7;break}return k.n=6,a(D.clone().text());case 6:x=k.v,ui.debug(`[HTTP] Response ${D.status}: ${x}`);case 7:if(S=D.status,!Qu(void 0,D.status)){k.n=8;break}return w++,k.a(3,1);case 8:throw new qu(D.status,e);case 9:if(!y){k.n=11;break}return k.n=10,a(D.clone().text());case 10:C=k.v,ui.debug(`[HTTP] Response ${D.status}: ${C}`);case 11:return k.n=12,a(D.json());case 12:return I=k.v,k.a(2,{data:I,retryCount:w});case 13:if(k.p=13,!((L=k.v)instanceof qu)){k.n=14;break}throw L;case 14:if(!Qu(L)){k.n=15;break}return E=L,w++,k.a(3,1);case 15:throw L;case 16:if(void 0!==S||void 0===E){k.n=17;break}throw E;case 17:throw new Ju(e,w,S);case 18:return k.a(2)}},null,null,[[4,13]],Promise)}var nl=function(){return c(function e(){o(this,e)},[{key:"fetchPaywalls",value:function(){var e,t,n;return k(function(i){for(;;)switch(i.n){case 0:if(null!=(e=Fr.getDevice())&&e.id){i.n=2;break}return i.n=1,a(this.getAnonymousPaywalls());case 1:t=i.v,i.n=4;break;case 2:return i.n=3,a(this.getPaywalls(e.id));case 3:t=i.v;case 4:if(!t){i.n=5;break}return(n=this.validatePaywalls(t)).length>0&&Fr.setPaywalls(ut,n),i.a(2,n);case 5:return i.a(2,t)}},null,this,null,Promise)}},{key:"getAnonymousPaywalls",value:function(e=Ae){var t,n,i,r;return k(function(o){for(;;)switch(o.p=o.n){case 0:return n=`paywalls/?sdk_version=${e}`,i=null,o.p=1,o.n=2,a(js.instance.fetchAPI(n));case 2:i=o.v,o.n=4;break;case 3:if(o.p=3,r=o.v,i=this.fallbackData()){o.n=4;break}throw ui.error(Zr(r.status,n)),r;case 4:return o.a(2,(null===(t=i)||void 0===t?void 0:t.results)||[])}},null,this,[[1,3]],Promise)}},{key:"getPaywalls",value:function(e){var t,n,i,r;return k(function(o){for(;;)switch(o.p=o.n){case 0:return n=`device/${e}/paywalls/`,o.p=1,o.n=2,a(js.instance.fetchAPI(n));case 2:i=o.v,o.n=4;break;case 3:if(o.p=3,r=o.v,i=this.fallbackData()){o.n=4;break}throw ui.error(Zr(r.status,n)),r;case 4:return o.a(2,(null===(t=i)||void 0===t?void 0:t.results)||[])}},null,this,[[1,3]],Promise)}},{key:"fetchPaywallByUrl",value:function(e){return k(function(t){for(;;)if(0===t.n)return t.a(2,tl(e))},null,null,null,Promise)}},{key:"fetchPaywallsByUrls",value:function(e){var t,n,i,r,o,s,u,l;return k(function(d){for(;;)switch(d.n){case 0:return t=[...new Set(e)],d.n=1,a(Promise.allSettled(t.map(e=>this.fetchPaywallByUrl(e))));case 1:for(n=d.v,i=[],r=0,o=h(n);!(s=o()).done;)"fulfilled"===(u=s.value).status?(i.push(u.value.data),r+=u.value.retryCount):ui.error(`Failed to fetch individual paywall: ${u.reason}`);if(!(i.length>0)){d.n=2;break}return(l=this.validatePaywalls(i)).length>0&&Fr.setPaywalls(ut,l),d.a(2,{paywalls:l,retryCount:r});case 2:return d.a(2,{paywalls:i,retryCount:r})}},null,this,null,Promise)}},{key:"validatePaywalls",value:function(e){return e.filter(e=>{var t,n=null===(t=e.template)||void 0===t?void 0:t.pages;return!(!Array.isArray(n)||0===n.length)||(ui.warn(`Dropping paywall "${e.id}" from cache: template.pages is missing or empty`),!1)})}},{key:"fallbackData",value:function(){var e=Fr.getPaywalls(ut)||Fr.getPaywalls(St);return e?{count:e.length,results:e}:null}}])}();nl.instance=new nl;var il=function(){return c(function e(){o(this,e)},[{key:"fetchConfig",value:function(){var e,t;return k(function(n){for(;;)switch(n.p=n.n){case 0:return n.p=0,n.n=1,a(js.instance.fetchAPI("config/"));case 1:e=n.v,n.n=3;break;case 2:if(n.p=2,t=n.v,e=Fr.getAppConfig(at)||Fr.getAppConfig(yt)){n.n=3;break}throw ui.error(Zr(t.status,"config/")),t;case 3:return e&&Fr.setAppConfig(at,e),n.a(2,e)}},null,null,[[0,2]],Promise)}}])}();il.instance=new il;var al=null;function rl(){al&&al.setInMemoryAnonymousMode(!1)}function ol(){return!!Fr.getAnonymousMode()||!!al&&al.isInMemoryAnonymousMode()}var sl=function(){return c(function e(){o(this,e)},[{key:"startSession",value:function(){var e;return k(function(t){for(;;)switch(t.p=t.n){case 0:if(!ol()){t.n=1;break}return ui.debug("Skipping session start call - anonymous mode"),t.a(2);case 1:return t.p=1,t.n=2,a(js.instance.startSession(new Date));case 2:t.n=4;break;case 3:t.p=3,e=t.v,ui.error("error on start session: ",e);case 4:return t.a(2)}},null,null,[[1,3]],Promise)}}])}();sl.instance=new sl;var ul=function(){return c(function e(){o(this,e)},null,[{key:"allPurchases",value:function(){return[]}}])}();ul.instance=new ul;var ll={en:{nami_day:"day",nami_day_plural:"days",nami_week:"week",nami_week_plural:"weeks",nami_month:"month",nami_month_plural:"months",nami_year:"year",nami_year_plural:"years",nami_day_abbrev:"day",nami_day_abbrev_plural:"days",nami_week_abbrev:"wk",nami_week_abbrev_plural:"wks",nami_month_abbrev:"mo",nami_month_abbrev_plural:"mos",nami_year_abbrev:"yr",nami_year_abbrev_plural:"yrs",nami_daily:"daily",nami_weekly:"weekly",nami_biweekly:"bi-weekly",nami_monthly:"monthly",nami_bimonthly:"bi-monthly",nami_quarterly:"quarterly",nami_biannually:"bi-annually",nami_yearly:"yearly"},af:{nami_day_abbrev:"dag",nami_day_abbrev_plural:"dae",nami_week_abbrev:"week",nami_week_abbrev_plural:"weke",nami_month_abbrev:"ma",nami_month_abbrev_plural:"maande",nami_year_abbrev:"jr",nami_year_abbrev_plural:"jare",nami_daily:"daagliks",nami_weekly:"weekliks",nami_biweekly:"tweeweekliks",nami_monthly:"maandeliks",nami_bimonthly:"tweemaandeliks",nami_quarterly:"kwartaalliks",nami_biannually:"tweejaarliks",nami_yearly:"jaarliks"},am:{nami_day_abbrev:"ቀን",nami_day_abbrev_plural:"ቀናት",nami_week_abbrev:"ሳምንት",nami_week_abbrev_plural:"ሳምንታት",nami_month_abbrev:"ወር",nami_month_abbrev_plural:"ሞስ",nami_year_abbrev:"ዓመት",nami_year_abbrev_plural:"ዓመታት",nami_daily:"በየቀኑ",nami_weekly:"ሳምንታዊ",nami_biweekly:"በየሁለት ሳምንቱ",nami_monthly:"ወርሃዊ",nami_bimonthly:"በየሁለት ወሩ",nami_quarterly:"በየሩብ ዓመቱ",nami_biannually:"በየሁለት ዓመቱ",nami_yearly:"ዓመታዊ"},ar:{nami_day_abbrev:"يوم",nami_day_abbrev_plural:"أيام",nami_week_abbrev:"أسبوع",nami_week_abbrev_plural:"أسابيع",nami_month_abbrev:"شهر",nami_month_abbrev_plural:"موس",nami_year_abbrev:"سنة",nami_year_abbrev_plural:"سنوات",nami_daily:"يوميًا",nami_weekly:"أسبوعي",nami_biweekly:"كل أسبوعين",nami_monthly:"شهريا",nami_bimonthly:"كل شهرين",nami_quarterly:"ربع سنوي",nami_biannually:"مرتين في السنة",nami_yearly:"سنوي"},bg:{nami_day_abbrev:"ден",nami_day_abbrev_plural:"дни",nami_week_abbrev:"седмица",nami_week_abbrev_plural:"седмици",nami_month_abbrev:"мо",nami_month_abbrev_plural:"мос",nami_year_abbrev:"год.",nami_year_abbrev_plural:"години",nami_daily:"ежедневно",nami_weekly:"седмично",nami_biweekly:"двуседмичен",nami_monthly:"месечно",nami_bimonthly:"двумесечно",nami_quarterly:"тримесечно",nami_biannually:"два пъти годишно",nami_yearly:"годишно"},ca:{nami_day_abbrev:"dia",nami_day_abbrev_plural:"dies",nami_week_abbrev:"setmana",nami_week_abbrev_plural:"setmanes",nami_month_abbrev:"mes",nami_month_abbrev_plural:"mesos",nami_year_abbrev:"any",nami_year_abbrev_plural:"anys",nami_daily:"diàriament",nami_weekly:"setmanal",nami_biweekly:"quinzenal",nami_monthly:"mensual",nami_bimonthly:"bimensual",nami_quarterly:"trimestral",nami_biannually:"bianualment",nami_yearly:"anual"},cs:{nami_day_abbrev:"den",nami_day_abbrev_plural:"dny",nami_week_abbrev:"týden",nami_week_abbrev_plural:"týdny",nami_month_abbrev:"měsíc",nami_month_abbrev_plural:"měsíce",nami_year_abbrev:"rok",nami_year_abbrev_plural:"roky",nami_daily:"denní",nami_weekly:"týdně",nami_biweekly:"dvoutýdenní",nami_monthly:"měsíční",nami_bimonthly:"dvouměsíčník",nami_quarterly:"čtvrtletní",nami_biannually:"pololetně",nami_yearly:"roční"},de:{nami_day_abbrev:"Tag",nami_day_abbrev_plural:"Tage",nami_week_abbrev:"Woche",nami_week_abbrev_plural:"Wochen",nami_month_abbrev:"Monat",nami_month_abbrev_plural:"Monate",nami_year_abbrev:"Jahr",nami_year_abbrev_plural:"Jahre",nami_daily:"täglich",nami_weekly:"wöchentlich",nami_biweekly:"zweiwöchentlich",nami_monthly:"monatlich",nami_bimonthly:"zweimonatlich",nami_quarterly:"vierteljährlich",nami_biannually:"halbjährlich",nami_yearly:"jährlich"},el:{nami_day_abbrev:"ημέρα",nami_day_abbrev_plural:"ημέρες",nami_week_abbrev:"εβδομάδα",nami_week_abbrev_plural:"εβδομάδες",nami_month_abbrev:"μήνα",nami_month_abbrev_plural:"μην",nami_year_abbrev:"έτος",nami_year_abbrev_plural:"χρόνια",nami_daily:"καθημερινά",nami_weekly:"εβδομαδιαίος",nami_biweekly:"ανά δύο εβδομάδες",nami_monthly:"μηνιαίος",nami_bimonthly:"διμηνιαίος",nami_quarterly:"τριμηνιαίος",nami_biannually:"ανά εξάμηνο",nami_yearly:"ετήσια"},es:{nami_day_abbrev:"día",nami_day_abbrev_plural:"días",nami_week_abbrev:"semana",nami_week_abbrev_plural:"semanas",nami_month_abbrev:"mes",nami_month_abbrev_plural:"meses",nami_year_abbrev:"año",nami_year_abbrev_plural:"años",nami_daily:"diario",nami_weekly:"semanal",nami_biweekly:"quincenal",nami_monthly:"mensual",nami_bimonthly:"bimensual",nami_quarterly:"trimestral",nami_biannually:"semestral",nami_yearly:"anual"},et:{nami_day_abbrev:"päev",nami_day_abbrev_plural:"päevad",nami_week_abbrev:"nädal",nami_week_abbrev_plural:"nädalat",nami_month_abbrev:"kuu",nami_month_abbrev_plural:"kuud",nami_year_abbrev:"aasta",nami_year_abbrev_plural:"aastat",nami_daily:"iga päev",nami_weekly:"iganädalane",nami_biweekly:"iga kahe nädala tagant",nami_monthly:"igakuine",nami_bimonthly:"kaks korda kuus",nami_quarterly:"kvartali",nami_biannually:"kaks korda aastas",nami_yearly:"iga-aastane"},fa:{nami_day_abbrev:"روز",nami_day_abbrev_plural:"روزها",nami_week_abbrev:"هفته",nami_week_abbrev_plural:"هفتهها",nami_month_abbrev:"مو",nami_month_abbrev_plural:"موش",nami_year_abbrev:"سال",nami_year_abbrev_plural:"سال",nami_daily:"روزانه",nami_weekly:"هفتگی",nami_biweekly:"دو هفتهای",nami_monthly:"ماهانه",nami_bimonthly:"دوماهه",nami_quarterly:"سه ماهه",nami_biannually:"دوسالانه",nami_yearly:"سالانه"},fi:{nami_day_abbrev:"päivä",nami_day_abbrev_plural:"päivää",nami_week_abbrev:"viikko",nami_week_abbrev_plural:"viikkoa",nami_month_abbrev:"kuukausi",nami_month_abbrev_plural:"kuukaudet",nami_year_abbrev:"vuosi",nami_year_abbrev_plural:"vuotta",nami_daily:"päivittäin",nami_weekly:"viikoittain",nami_biweekly:"joka toinen viikko",nami_monthly:"kuukausittain",nami_bimonthly:"kahdesti kuussa",nami_quarterly:"neljännesvuosittain",nami_biannually:"puolivuosittain",nami_yearly:"vuosittain"},fr:{nami_day_abbrev:"jour",nami_day_abbrev_plural:"jours",nami_week_abbrev:"semaine",nami_week_abbrev_plural:"semaines",nami_month_abbrev:"mois",nami_month_abbrev_plural:"mois",nami_year_abbrev:"année",nami_year_abbrev_plural:"ans",nami_daily:"tous les jours",nami_weekly:"hebdomadaire",nami_biweekly:"bihebdomadaire",nami_monthly:"mensuel",nami_bimonthly:"bimensuel",nami_quarterly:"trimestriel",nami_biannually:"bisannuel",nami_yearly:"annuel"},hi:{nami_day_abbrev:"दिन",nami_day_abbrev_plural:"दिन",nami_week_abbrev:"सप्त",nami_week_abbrev_plural:"सप्त",nami_month_abbrev:"महीना",nami_month_abbrev_plural:"महीने",nami_year_abbrev:"साल",nami_year_abbrev_plural:"वर्षीय",nami_daily:"दैनिक",nami_weekly:"साप्ताहिक",nami_biweekly:"द्वि-साप्ताहिक",nami_monthly:"महीने के",nami_bimonthly:"द्विमासिक",nami_quarterly:"त्रैमासिक",nami_biannually:"द्वि-वार्षिक रूप",nami_yearly:"वार्षिक"},hr:{nami_day_abbrev:"dan",nami_day_abbrev_plural:"dana",nami_week_abbrev:"tjedan",nami_week_abbrev_plural:"tjedni",nami_month_abbrev:"mjesec",nami_month_abbrev_plural:"mjeseca",nami_year_abbrev:"god.",nami_year_abbrev_plural:"godina",nami_daily:"dnevno",nami_weekly:"tjedno",nami_biweekly:"dvotjedno",nami_monthly:"mjesečno",nami_bimonthly:"dvomjesečno",nami_quarterly:"tromjesečno",nami_biannually:"dvogodišnje",nami_yearly:"godišnje"},hu:{nami_day_abbrev:"nap",nami_day_abbrev_plural:"napok",nami_week_abbrev:"hét",nami_week_abbrev_plural:"hetek",nami_month_abbrev:"hónap",nami_month_abbrev_plural:"hónap",nami_year_abbrev:"év",nami_year_abbrev_plural:"év",nami_daily:"napi",nami_weekly:"heti",nami_biweekly:"kéthetente",nami_monthly:"havi",nami_bimonthly:"kéthavonta",nami_quarterly:"negyedévenként",nami_biannually:"félévente",nami_yearly:"évi"},id:{nami_day_abbrev:"hari",nami_day_abbrev_plural:"hari",nami_week_abbrev:"minggu",nami_week_abbrev_plural:"minggu",nami_month_abbrev:"bulan",nami_month_abbrev_plural:"bulan",nami_year_abbrev:"tahun",nami_year_abbrev_plural:"tahun",nami_daily:"sehari-hari",nami_weekly:"mingguan",nami_biweekly:"dua kali seminggu",nami_monthly:"bulanan",nami_bimonthly:"dua bulanan",nami_quarterly:"triwulanan",nami_biannually:"dua tahunan",nami_yearly:"tahunan"},it:{nami_day_abbrev:"giorno",nami_day_abbrev_plural:"giorni",nami_week_abbrev:"settimana",nami_week_abbrev_plural:"settimane",nami_month_abbrev:"mese",nami_month_abbrev_plural:"mesi",nami_year_abbrev:"anno",nami_year_abbrev_plural:"anni",nami_daily:"quotidiano",nami_weekly:"settimanale",nami_biweekly:"bisettimanale",nami_monthly:"mensile",nami_bimonthly:"bimestrale",nami_quarterly:"trimestrale",nami_biannually:"semestralmente",nami_yearly:"annuale"},he:{nami_day_abbrev:"יְוֹם",nami_day_abbrev_plural:"ימים",nami_week_abbrev:"שבוע",nami_week_abbrev_plural:"שבועות",nami_month_abbrev:"מו",nami_month_abbrev_plural:"מוֹס",nami_year_abbrev:"שנה",nami_year_abbrev_plural:"שנים",nami_daily:"יוֹמִי",nami_weekly:"שְׁבוּעִי",nami_biweekly:"דו-שבועי",nami_monthly:"יַרחוֹן",nami_bimonthly:"דו-חודשי",nami_quarterly:"רִבעוֹן",nami_biannually:"דו-שנתי",nami_yearly:"שְׁנָתִי"},ja:{nami_day_abbrev:"日",nami_day_abbrev_plural:"日",nami_week_abbrev:"週",nami_week_abbrev_plural:"週",nami_month_abbrev:"モ",nami_month_abbrev_plural:"モス",nami_year_abbrev:"年",nami_year_abbrev_plural:"年",nami_daily:"毎日",nami_weekly:"毎週",nami_biweekly:"隔週",nami_monthly:"毎月",nami_bimonthly:"隔月",nami_quarterly:"四半期ごと",nami_biannually:"半年ごと",nami_yearly:"毎年"},ko:{nami_day_abbrev:"낮",nami_day_abbrev_plural:"날",nami_week_abbrev:"주",nami_week_abbrev_plural:"주",nami_month_abbrev:"모",nami_month_abbrev_plural:"모스",nami_year_abbrev:"년",nami_year_abbrev_plural:"년",nami_daily:"일일",nami_weekly:"주간",nami_biweekly:"격주 간행물",nami_monthly:"월간 간행물",nami_bimonthly:"격월",nami_quarterly:"계간지",nami_biannually:"반년마다",nami_yearly:"매년"},lt:{nami_day_abbrev:"diena",nami_day_abbrev_plural:"dienos",nami_week_abbrev:"savaitė",nami_week_abbrev_plural:"savaitės",nami_month_abbrev:"mėn.",nami_month_abbrev_plural:"mėn.",nami_year_abbrev:"metai",nami_year_abbrev_plural:"metų",nami_daily:"kasdien",nami_weekly:"kas savaitę",nami_biweekly:"kas dvi savaites",nami_monthly:"mėnesinis",nami_bimonthly:"kas du mėnesius",nami_quarterly:"ketvirtinis",nami_biannually:"kas du kartus per metus",nami_yearly:"kasmet"},lv:{nami_day_abbrev:"diena",nami_day_abbrev_plural:"dienas",nami_week_abbrev:"nedēļa",nami_week_abbrev_plural:"nedēļas",nami_month_abbrev:"mēn.",nami_month_abbrev_plural:"mēn.",nami_year_abbrev:"gads",nami_year_abbrev_plural:"gadi",nami_daily:"ikdienas",nami_weekly:"iknedēļas",nami_biweekly:"divreiz nedēļā",nami_monthly:"ikmēneša",nami_bimonthly:"divreiz mēnesī",nami_quarterly:"ceturksnī",nami_biannually:"divreiz gadā",nami_yearly:"katru gadu"},ms:{nami_day_abbrev:"hari",nami_day_abbrev_plural:"hari",nami_week_abbrev:"minggu",nami_week_abbrev_plural:"minggu",nami_month_abbrev:"bulan",nami_month_abbrev_plural:"bulan",nami_year_abbrev:"tahun",nami_year_abbrev_plural:"tahun",nami_daily:"setiap hari",nami_weekly:"mingguan",nami_biweekly:"dua minggu sekali",nami_monthly:"bulanan",nami_bimonthly:"dua kali sebulan",nami_quarterly:"suku tahunan",nami_biannually:"dua kali setahun",nami_yearly:"tahunan"},nl:{nami_day_abbrev:"dag",nami_day_abbrev_plural:"dagen",nami_week_abbrev:"week",nami_week_abbrev_plural:"weken",nami_month_abbrev:"maand",nami_month_abbrev_plural:"maanden",nami_year_abbrev:"jaar",nami_year_abbrev_plural:"jaren",nami_daily:"dagelijks",nami_weekly:"wekelijks",nami_biweekly:"tweewekelijks",nami_monthly:"maandelijks",nami_bimonthly:"tweemaandelijks",nami_quarterly:"kwartaal",nami_biannually:"halfjaarlijks",nami_yearly:"jaarlijks"},no:{nami_day_abbrev:"dag",nami_day_abbrev_plural:"dager",nami_week_abbrev:"uke",nami_week_abbrev_plural:"uker",nami_month_abbrev:"måned",nami_month_abbrev_plural:"måned",nami_year_abbrev:"år",nami_year_abbrev_plural:"år",nami_daily:"daglig",nami_weekly:"ukentlig",nami_biweekly:"annenhver uke",nami_monthly:"månedlig",nami_bimonthly:"annenhver måned",nami_quarterly:"kvartalsvis",nami_biannually:"to ganger i året",nami_yearly:"årlig"},pl:{nami_day_abbrev:"dzień",nami_day_abbrev_plural:"dni",nami_week_abbrev:"tydzień",nami_week_abbrev_plural:"tygodni",nami_month_abbrev:"miesiąc",nami_month_abbrev_plural:"miesiące",nami_year_abbrev:"rok",nami_year_abbrev_plural:"lat",nami_daily:"codziennie",nami_weekly:"tygodnik",nami_biweekly:"dwutygodniowy",nami_monthly:"miesięczny",nami_bimonthly:"dwumiesięczny",nami_quarterly:"kwartalny",nami_biannually:"dwa razy w roku",nami_yearly:"rocznie"},pt:{nami_day_abbrev:"dia",nami_day_abbrev_plural:"dias",nami_week_abbrev:"semana",nami_week_abbrev_plural:"semanas",nami_month_abbrev:"mês",nami_month_abbrev_plural:"meses",nami_year_abbrev:"ano",nami_year_abbrev_plural:"anos",nami_daily:"diário",nami_weekly:"semanalmente",nami_biweekly:"quinzenal",nami_monthly:"mensal",nami_bimonthly:"bimestral",nami_quarterly:"trimestral",nami_biannually:"bianualmente",nami_yearly:"anual"},ro:{nami_day_abbrev:"zi",nami_day_abbrev_plural:"zile",nami_week_abbrev:"săptămână",nami_week_abbrev_plural:"săptămâni",nami_month_abbrev:"lună",nami_month_abbrev_plural:"luni",nami_year_abbrev:"an",nami_year_abbrev_plural:"ani",nami_daily:"zilnic",nami_weekly:"săptămânal",nami_biweekly:"la două săptămâni",nami_monthly:"lunar",nami_bimonthly:"bilunar",nami_quarterly:"trimestrial",nami_biannually:"bianual",nami_yearly:"anual"},ru:{nami_day_abbrev:"день",nami_day_abbrev_plural:"дни",nami_week_abbrev:"нед",nami_week_abbrev_plural:"недели",nami_month_abbrev:"мо",nami_month_abbrev_plural:"мос",nami_year_abbrev:"год",nami_year_abbrev_plural:"лет",nami_daily:"ежедневно",nami_weekly:"еженедельный",nami_biweekly:"раз в две недели",nami_monthly:"ежемесячно",nami_bimonthly:"раз в два месяца",nami_quarterly:"ежеквартальный",nami_biannually:"раз в два года",nami_yearly:"ежегодно"},sk:{nami_day_abbrev:"deň",nami_day_abbrev_plural:"dni",nami_week_abbrev:"týždeň",nami_week_abbrev_plural:"týždne",nami_month_abbrev:"mesiac",nami_month_abbrev_plural:"mesiacov",nami_year_abbrev:"rok",nami_year_abbrev_plural:"rokov",nami_daily:"denne",nami_weekly:"týždenne",nami_biweekly:"dvojtýždenne",nami_monthly:"mesačne",nami_bimonthly:"dvojmesačne",nami_quarterly:"štvrťročne",nami_biannually:"polročne",nami_yearly:"ročne"},sl:{nami_day_abbrev:"dan",nami_day_abbrev_plural:"dni",nami_week_abbrev:"teden",nami_week_abbrev_plural:"tedni",nami_month_abbrev:"mesec",nami_month_abbrev_plural:"mesecev",nami_year_abbrev:"leto",nami_year_abbrev_plural:"let",nami_daily:"dnevno",nami_weekly:"tedensko",nami_biweekly:"dvotedensko",nami_monthly:"mesečno",nami_bimonthly:"dvomesečno",nami_quarterly:"četrtletno",nami_biannually:"polletno",nami_yearly:"letno"},sr:{nami_day_abbrev:"дан",nami_day_abbrev_plural:"дана",nami_week_abbrev:"недеља",nami_week_abbrev_plural:"недеље",nami_month_abbrev:"мо",nami_month_abbrev_plural:"мос",nami_year_abbrev:"год.",nami_year_abbrev_plural:"године",nami_daily:"свакодневно",nami_weekly:"недељно",nami_biweekly:"двонедељно",nami_monthly:"месечно",nami_bimonthly:"двомесечно",nami_quarterly:"квартално",nami_biannually:"два пута годишње",nami_yearly:"годишње"},sv:{nami_day_abbrev:"dag",nami_day_abbrev_plural:"dagar",nami_week_abbrev:"vecka",nami_week_abbrev_plural:"veckor",nami_month_abbrev:"mån",nami_month_abbrev_plural:"månader",nami_year_abbrev:"år",nami_year_abbrev_plural:"år",nami_daily:"dagligen",nami_weekly:"varje vecka",nami_biweekly:"som utkommer varannan vecka",nami_monthly:"månatlig",nami_bimonthly:"varannan månad",nami_quarterly:"kvartalsvis",nami_biannually:"vartannat år",nami_yearly:"årlig"},sw:{nami_day_abbrev:"siku",nami_day_abbrev_plural:"siku",nami_week_abbrev:"wiki",nami_week_abbrev_plural:"wiki",nami_month_abbrev:"mwezi",nami_month_abbrev_plural:"miezi",nami_year_abbrev:"mwaka",nami_year_abbrev_plural:"miaka",nami_daily:"kila siku",nami_weekly:"kila wiki",nami_biweekly:"kila wiki mbili",nami_monthly:"kila mwezi",nami_bimonthly:"kila baada ya miezi miwili",nami_quarterly:"robo mwaka",nami_biannually:"kila baada ya miaka miwili",nami_yearly:"kila mwaka"},th:{nami_day_abbrev:"วัน",nami_day_abbrev_plural:"วัน",nami_week_abbrev:"สัปดาห์",nami_week_abbrev_plural:"สัปดาห์",nami_month_abbrev:"โม",nami_month_abbrev_plural:"มอส",nami_year_abbrev:"ปี",nami_year_abbrev_plural:"ปี",nami_daily:"รายวัน",nami_weekly:"รายสัปดาห์",nami_biweekly:"สองสัปดาห์ครั้ง",nami_monthly:"รายเดือน",nami_bimonthly:"สองเดือนครั้ง",nami_quarterly:"ไตรมาส",nami_biannually:"ทุกสองปี",nami_yearly:"ทุกปี"},tr:{nami_day_abbrev:"gün",nami_day_abbrev_plural:"günler",nami_week_abbrev:"hafta",nami_week_abbrev_plural:"haftalar",nami_month_abbrev:"ay",nami_month_abbrev_plural:"aylar",nami_year_abbrev:"yıl",nami_year_abbrev_plural:"yıllar",nami_daily:"günlük",nami_weekly:"haftalık",nami_biweekly:"iki haftada bir",nami_monthly:"aylık",nami_bimonthly:"iki ayda bir",nami_quarterly:"üç aylık",nami_biannually:"iki yılda bir",nami_yearly:"yıllık"},uk:{nami_day_abbrev:"день",nami_day_abbrev_plural:"дні",nami_week_abbrev:"тиждень",nami_week_abbrev_plural:"тижні",nami_month_abbrev:"місяць",nami_month_abbrev_plural:"мос",nami_year_abbrev:"рік",nami_year_abbrev_plural:"років",nami_daily:"щоденно",nami_weekly:"щотижня",nami_biweekly:"раз на два тижні",nami_monthly:"щомісяця",nami_bimonthly:"раз на два місяці",nami_quarterly:"щоквартально",nami_biannually:"раз на півроку",nami_yearly:"щорічно"},vi:{nami_day_abbrev:"ngày",nami_day_abbrev_plural:"ngày",nami_week_abbrev:"tuần",nami_week_abbrev_plural:"tuần",nami_month_abbrev:"tháng",nami_month_abbrev_plural:"tháng",nami_year_abbrev:"năm",nami_year_abbrev_plural:"năm",nami_daily:"hằng ngày",nami_weekly:"hàng tuần",nami_biweekly:"hai tuần một lần",nami_monthly:"hàng tháng",nami_bimonthly:"hai tháng một lần",nami_quarterly:"hàng quý",nami_biannually:"hai năm một lần",nami_yearly:"hàng năm"},"zh-CN":{nami_day_abbrev:"天",nami_day_abbrev_plural:"天",nami_week_abbrev:"周",nami_week_abbrev_plural:"周",nami_month_abbrev:"莫",nami_month_abbrev_plural:"莫斯",nami_year_abbrev:"年",nami_year_abbrev_plural:"年",nami_daily:"日常的",nami_weekly:"每周",nami_biweekly:"每两周一次",nami_monthly:"月度",nami_bimonthly:"双月刊",nami_quarterly:"季刊",nami_biannually:"每半年",nami_yearly:"每年"},"zh-TW":{nami_day_abbrev:"天",nami_day_abbrev_plural:"天",nami_week_abbrev:"週",nami_week_abbrev_plural:"週",nami_month_abbrev:"莫",nami_month_abbrev_plural:"莫斯",nami_year_abbrev:"年",nami_year_abbrev_plural:"年",nami_daily:"日常的",nami_weekly:"每週",nami_biweekly:"每兩週一次",nami_monthly:"每月",nami_bimonthly:"雙月刊",nami_quarterly:"季刊",nami_biannually:"每半年",nami_yearly:"每年"},zu:{nami_day_abbrev:"usuku",nami_day_abbrev_plural:"izinsuku",nami_week_abbrev:"isonto",nami_week_abbrev_plural:"amasonto",nami_month_abbrev:"inyanga",nami_month_abbrev_plural:"i-mos",nami_year_abbrev:"unyaka",nami_year_abbrev_plural:"iminyaka",nami_daily:"nsuku zonke",nami_weekly:"masonto onke",nami_biweekly:"kabili ngesonto",nami_monthly:"nyanga zonke",nami_bimonthly:"kabili ngenyanga",nami_quarterly:"njalo ngekota",nami_biannually:"kabili ngonyaka",nami_yearly:"minyaka yonke"}},dl="en";function cl(e){var t,n,i=function(e){if(!e)return dl;var t=e.trim();if(ll[t])return t;var n=t.toLowerCase(),i=n.split("-")[0];return ll[i]?i:"zh"===i?n.includes("tw")||n.includes("hk")?"zh-TW":"zh-CN":dl}(Fr.getLanguageCode()),a=null!==(t=ll[i])&&void 0!==t?t:ll[dl];return null!==(n=null==a?void 0:a[e])&&void 0!==n?n:e}function hl(e){if("subscription"===(null==e?void 0:e.product_type)){var t=fl(e);if(t.length>0)return t[0].billingPeriod}return null}function ml(e){var t=function(e){if(!e)return[];var t=e.offers.filter(e=>"promo"===e.offer_type);return vl(t,e.subscription_period)}(e).find(e=>0===e.priceAmountMicros);return(null==t?void 0:t.billingPeriod)||null}function fl(e){return e?vl(e.offers.filter(e=>"default"===e.offer_type),e.subscription_period):[]}function vl(e,t){return e.map(e=>pl(e,t))}function pl(e,t){var n,i,a,r,o,s,u,l;if(!e)return{};var d=null!==(n=null===(i=e.promo_period)||void 0===i?void 0:i.count)&&void 0!==n?n:null==t?void 0:t.count,c=null!==(a=null===(r=e.promo_period)||void 0===r?void 0:r.type)&&void 0!==a?a:null==t?void 0:t.type,h=null!==(o=null===(s=e.promo_price)||void 0===s?void 0:s.price)&&void 0!==o?o:e.price,m=null!==(u=null===(l=e.promo_price)||void 0===l?void 0:l.currency)&&void 0!==u?u:e.currency;return{priceAmountMicros:1e6*h,priceCurrencyCode:m,billingPeriod:c?`P${d}${c[0].toUpperCase()}`:"",formattedPrice:bl(m).format(h)}}function gl(e,t=!1,n=!1,i=!1,a=!1){if(!e)return null;var r=e.match(/P(?:(\d+)Y)?(?:(\d+)M)?(?:(\d+)W)?(?:(\d+)D)?/);if(!r)return null;var o=r.slice(1).map(e=>parseInt(e)),s=o[0],u=o[1],l=o[2],d=o[3],c=(e,t,n,i,r)=>{var o=(e=>a?`${e}_abbrev`:e)(r),s=(e=>a?`${e}_abbrev_plural`:`${e}_plural`)(r),u=cl(o),l=cl(s);return a||u!==o||(u=cl(`${r}_abbrev`)),a||l!==s||(l=cl(`${r}_abbrev_plural`)),i?e.toString():n?1===e||t?u:l:1===e||t?`${e} ${u}`:`${e} ${l}`};switch(e.at(-1)){case"D":return c(d,t,n,i,"nami_day");case"W":return c(l,t,n,i,"nami_week");case"M":return c(u,t,n,i,"nami_month");case"Y":return c(s,t,n,i,"nami_year")}return null}function yl(e){var t;if(!e||e.length<2)return!1;var n=null===(t=e.at(-1))||void 0===t?void 0:t.toUpperCase();return"M"===n||"Y"===n}function bl(e){var t={maximumFractionDigits:2,minimumFractionDigits:0},n=we().device.getLanguage();try{return new Intl.NumberFormat(n,m({},t,{style:"currency",currency:e}))}catch(e){return new Intl.NumberFormat(n,m({},t,{style:"currency",currency:"USD"}))}}var wl=(e,t,n)=>e&&t&&n?n.format(e-t):null,kl=(e,t,n,i)=>{if(e&&t&&n&&i){var a=100*(1-e/(n/i*t));return`${Math.round(a)}%`}return null},Sl=(e,t)=>{if(""!=t){var n=parseInt(t)-1;return n>=0&&n<(null==e?void 0:e.length)?e[n]:null==e?void 0:e.find(e=>e.sku_ref_id===t)}},El=e=>Tl(e.priceAmountMicros)/Pl(e.billingPeriod),Pl=e=>{var t=parseInt(e[1]);return e.includes("Y")&&(t*=12),t},Tl=e=>e/1e6;function _l(e){return parseFloat((Math.round(e)/100).toFixed(2))}var Ml=(e,t,n=[])=>({price:()=>Dl(e),name:()=>null==e?void 0:e.name,title:()=>null==e?void 0:e.name,description:()=>null==e?void 0:e.description,duration:()=>xl(e),durationSingular:()=>xl(e,!0),period:()=>xl(e,!1,!0),periodNumber:()=>xl(e,!1,!1,!0),freeTrialDuration:()=>Cl(e),freeTrialDurationSingular:()=>Cl(e,!0),freeTrialPeriod:()=>Cl(e,!1,!0),freeTrialPeriodNumber:()=>Cl(e,!1,!1,!0),pricePerMonth:()=>Il(e),pricePerMonthRounded:()=>Il(e,!0),periodInMonths:()=>Ll(e),durationInMonths:()=>Rl(e),durationInMonthsSingular:()=>Rl(e,!0),periodNumberInMonths:()=>Fl(e),percentagePriceDifferenceFromSku:()=>Ol(e,t,n),priceDifferenceFromSku:()=>$l(e,t,n),promoEligible:()=>null===Nl(e)&&null!==Wl(e,t),freeTrialEligible:()=>null!==Nl(e),promo:()=>{var n;return null===(n=Wl(e,t))||void 0===n?void 0:n.offer_ref_id},promoCode:()=>"XXXXX",promoPrice:()=>{var n;return null===(n=jl(e,t))||void 0===n?void 0:n.formattedPrice},promoPeriod:()=>Bl(e,t,!1,!0),promoPeriodNumber:()=>Bl(e,t,!1,!1,!0),promoDuration:()=>Bl(e,t),promoDurationSingular:()=>Bl(e,t,!0),introEligible:()=>!1,pricePerDay:()=>zl(e),pricePerWeek:()=>Ul(e),pricePerWeekRounded:()=>Ul(e,!0),introductoryPrice:()=>Hl(e,t),introductoryPeriod:()=>Gl(e,t,!1,!0),introductoryPeriodNumber:()=>Gl(e,t,!1,!1,!0),introductoryDuration:()=>Gl(e,t),introductoryDurationSingular:()=>Gl(e,t,!0),introductoryPricePerMonth:()=>Vl(e,t),introductoryPricePerMonthRounded:()=>Vl(e,t,!0),durationAbbrev:()=>xl(e,!1,!1,!1,!0),freeTrialDurationAbbrev:()=>Cl(e,!1,!1,!1,!0),introductoryDurationAbbrev:()=>Gl(e,t,!1,!1,!1,!0),promoDurationAbbrev:()=>Bl(e,t,!1,!1,!1,!0),promoDurationPhase2Abbrev:()=>Bl(e,t,!0,!0,!1,!0),durationInMonthsAbbrev:()=>Rl(e,!1,!1,!1,!0),durationSingularAbbrev:()=>xl(e,!0,!1,!1,!0),freeTrialDurationSingularAbbrev:()=>Cl(e,!0,!1,!1,!0),introductoryDurationSingularAbbrev:()=>Gl(e,t,!0,!1,!1,!0),promoDurationSingularAbbrev:()=>Bl(e,t,!0,!1,!1,!0),promoDurationSingularPhase2Abbrev:()=>Bl(e,t,!0,!0,!1,!0),durationInMonthsSingularAbbrev:()=>Rl(e,!0,!1,!1,!0),periodAbbrev:()=>xl(e,!1,!0,!1,!0),freeTrialPeriodAbbrev:()=>Cl(e,!1,!0,!1,!0),introductoryPeriodAbbrev:()=>Gl(e,t,!1,!0,!1,!0),promoPeriodAbbrev:()=>Bl(e,t,!1,!0,!1,!0),promoPeriodPhase2Abbrev:()=>Bl(e,t,!1,!0,!0,!0),periodInMonthsAbbrev:()=>Rl(e,!1,!0,!1,!0),periodly:()=>function(e){if(!e)return null;var t=e.match(/P(?:(\d+)Y)?(?:(\d+)M)?(?:(\d+)W)?(?:(\d+)D)?/);if(!t)return null;var n=t[1],i=t[2],a=t[3],r=t[4],o=void 0!==n?parseInt(n,10):0,s=void 0!==i?parseInt(i,10):0,u=void 0!==a?parseInt(a,10):0;return(void 0!==r?parseInt(r,10):0)>0?null:u>0?1===u?cl("nami_weekly"):2===u?cl("nami_biweekly"):null:s>0?cl(1===s?"nami_monthly":2===s?"nami_bimonthly":3===s?"nami_quarterly":6===s?"nami_biannually":12===s?"nami_yearly":"nami_monthly"):o>0?cl("nami_yearly"):null}(hl(e)),iso_subscription_duration:()=>Xl(e),invalid:()=>!1,unavailable:()=>!1}),Al=(e,t,n,i=[])=>{if(!t)return null;var a=Ml(t,n,i);return a[e]?a[e]():null},Dl=e=>{var t=fl(e);return t&&t.length?t[0].formattedPrice:null},xl=(e,t,n,i,a)=>gl(hl(e),t,n,i,a),Cl=(e,t,n,i,a)=>gl(ml(e),t,n,i,a),Il=(e,t)=>{var n=fl(e);if(!n||0===n.length)return null;var i=El(n[0]);return i?bl(n[0].priceCurrencyCode).format(t?Math.round(i):i):null},Ll=(e,t)=>{var n=fl(e);if(!n||0===n.length)return null;var i=n[0].billingPeriod;return yl(i)?gl("P1Y"===i?"P12M":i,!1,!1,!1,t):null},Rl=(e,t,n,i,a)=>{var r=fl(e);if(!r||0===r.length)return null;var o=r[0].billingPeriod;return yl(o)?gl("P1Y"===o?"P12M":o,t,n,i,a):null},Fl=e=>{if(!e)return 0;var t=fl(e);return t&&t.length?Pl(t[0].billingPeriod):0},Ol=(e,t,n=[])=>{var i,a=fl(e);if(!a||0===a.length)return null;var r=null===(i=Sl(n,null!=t?t:""))||void 0===i?void 0:i.product_details;if(!t||!r)return kl(_l(a[0].priceAmountMicros),Fl(e));var o=fl(r);return kl(_l(a[0].priceAmountMicros),Fl(e),(null==o?void 0:o.length)>0?_l(o[0].priceAmountMicros):0,Fl(r))},$l=(e,t,n=[])=>{var i,a=fl(e);if(!a||0===a.length)return null;var r=null===(i=Sl(n,null!=t?t:""))||void 0===i?void 0:i.product_details;if(!t||!r)return wl(El(a[0]));var o=fl(r);return wl(El(a[0]),El(o[0]),bl(o[0].priceCurrencyCode))},Nl=e=>ml(e),Wl=(e,t)=>{if(!e)return null;var n=e.offers.filter(e=>"promo"===e.offer_type);if(!t)return n[0]||null;var i=n[parseInt(t)];return i?i||null:n.find(e=>e.offer_ref_id===t)||null},jl=(e,t)=>e?pl(Wl(e,t),e.subscription_period):null,Bl=(e,t,n,i,a,r)=>{var o=jl(e,t);return gl((null==o?void 0:o.billingPeriod)||null,n,i,a,r)},zl=(e,t)=>{var n=fl(e);if(!n||0===n.length)return null;var i,a,r=Tl(n[0].priceAmountMicros)/(i=n[0].billingPeriod,(a=Pl(i))?30.437*a:1);return r?bl(n[0].priceCurrencyCode).format(r):null},Ul=(e,t)=>{var n=fl(e);if(!n||0===n.length)return null;var i,a,r=Tl(n[0].priceAmountMicros)/(i=n[0].billingPeriod,(a=Pl(i))?52*a/12:1);return r?bl(n[0].priceCurrencyCode).format(t?Math.round(r):r):null},Hl=(e,t)=>{var n=Kl(e,t);return(null==n?void 0:n.formattedPrice)||null},Gl=(e,t,n,i,a,r)=>{var o=Kl(e,t);return gl((null==o?void 0:o.billingPeriod)||null,n,i,a,r)},Vl=(e,t,n)=>{var i=Kl(e,t);if(i){var a=Tl(i.priceAmountMicros),r=Pl(i.billingPeriod),o=n?Math.round(a/r):a/r;return bl(i.priceCurrencyCode).format(o)}},Kl=(e,t)=>{return e?(t?(n=e.offers[parseInt(t)])||(n=e.offers.find(e=>e.offer_ref_id===t)||null):n=e.offers[0],pl(n,e.subscription_period)):null;var n},Xl=e=>{var t=hl(e);return t?"P7D"===t?"P1W":t:null};function Yl(e,t,n,i){var a=n.flatMap(e=>e.products).find(e=>e.id===t.selectedProducts[t.currentGroupId]);return Jl(ed(e,null==a?void 0:a.sku_ref_id),a,i)}function ql(e,t,n){var i,a,r=null!==(i=null===(a=t.find(e=>e.id===n))||void 0===a?void 0:a.products)&&void 0!==i?i:[];return r.forEach(t=>{t.product_details=ed(e,t.sku_ref_id||""),t.variables=Jl(t.product_details,t,r)}),r}function Jl(e,t,n){if(!t)return{};var i=t.variables;if(!i)return m({},t);Object.keys(i).forEach(t=>{if("string"==typeof(r=i[t])&&r.includes(ni)){var a=Ql(i[t],e,n);i[t]=function(e){if(!e||e.includes("null")||e.includes("undefined"))return"";if(/\$\{\s*(launch\.customAttributes\.|sku\.)\w+\s*}/.test(e))return"";return e}(a)}var r});var a={};return Object.keys(Ml({})).forEach(t=>{if(void 0===i[t]){var r=Al(t,e,void 0,n);null!==r&&(a[t]=r)}}),m({},t,a,i)}var Ql=(e,t,n)=>e.replace(Qn,(i,a)=>{var r,o,s,u,l=(null===(r=Qn.exec(e))||void 0===r?void 0:r.slice(1))||[];a=null!==(o=l[0])&&void 0!==o?o:a;var d=null!==(s=null===(u=l[1])||void 0===u?void 0:u.replace(":",""))&&void 0!==s?s:"";return Al(a,t,d,n)});function Zl(e,t){return t.flatMap(e=>e.products).some(t=>1==Al("freeTrialEligible",ed(e,t.sku_ref_id)))}function ed(e=[],t=""){return e.find(e=>e.product_ref_id===t)||null}var td=function(){try{var e=Wi(Object,"defineProperty");return e({},"",{}),e}catch(e){}}();var nd=Object.prototype.hasOwnProperty;function id(e,t,n){var i=e[t];nd.call(e,t)&&di(i,n)&&(void 0!==n||t in e)||function(e,t,n){"__proto__"==t&&td?td(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[t]=n}(e,t,n)}var ad="object"==typeof e&&e&&!e.nodeType&&e,rd=ad&&"object"==typeof module&&module&&!module.nodeType&&module,od=rd&&rd.exports===ad?pi.Buffer:void 0;od&&od.allocUnsafe;var sd=Ia(Object.getPrototypeOf,Object),ud=Object.prototype.hasOwnProperty;function ld(e){var t=new e.constructor(e.byteLength);return new Qi(t).set(new Qi(e)),t}var dd=/\w*$/;var cd=gi?gi.prototype:void 0,hd=cd?cd.valueOf:void 0;function md(e,t,n){var i,a,r,o=e.constructor;switch(t){case"[object ArrayBuffer]":return ld(e);case"[object Boolean]":case"[object Date]":return new o(+e);case"[object DataView]":return r=ld((a=e).buffer),new a.constructor(r,a.byteOffset,a.byteLength);case"[object Float32Array]":case"[object Float64Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":return function(e){var t=ld(e.buffer);return new e.constructor(t,e.byteOffset,e.length)}(e);case"[object Map]":case"[object Set]":return new o;case"[object Number]":case"[object String]":return new o(e);case"[object RegExp]":return function(e){var t=new e.constructor(e.source,dd.exec(e));return t.lastIndex=e.lastIndex,t}(e);case"[object Symbol]":return i=e,hd?Object(hd.call(i)):{}}}var fd=Object.create,vd=function(){function e(){}return function(t){if(!Ti(t))return{};if(fd)return fd(t);e.prototype=t;var n=new e;return e.prototype=void 0,n}}();var pd=Ta&&Ta.isMap,gd=pd?ka(pd):function(e){return sa(e)&&"[object Map]"==Qa(e)};var yd=Ta&&Ta.isSet,bd=yd?ka(yd):function(e){return sa(e)&&"[object Set]"==Qa(e)},wd="[object Arguments]",kd="[object Function]",Sd="[object Object]",Ed={};function Pd(e,t,n,i,a,r){var o;if(void 0!==o)return o;if(!Ti(e))return e;var s=ia(e);if(s)o=function(e){var t=e.length,n=new e.constructor(t);return t&&"string"==typeof e[0]&&ud.call(e,"index")&&(n.index=e.index,n.input=e.input),n}(e);else{var u=Qa(e),l=u==kd||"[object GeneratorFunction]"==u;if(pa(e))return e.slice();if(u==Sd||u==wd||l&&!a)o=l?{}:function(e){return"function"!=typeof e.constructor||Ca(e)?{}:vd(sd(e))}(e);else{if(!Ed[u])return a?e:{};o=md(e,u)}}r||(r=new Ki);var d=r.get(e);if(d)return d;r.set(e,o),bd(e)?e.forEach(function(i){o.add(Pd(i,t,n,i,e,r))}):gd(e)&&e.forEach(function(i,a){o.set(a,Pd(i,t,n,a,e,r))});var c=s?void 0:Oa(e);return function(e,t){for(var n=-1,i=null==e?0:e.length;++n<i&&!1!==t(e[n],n,e););}(c||e,function(i,a){c&&(i=e[a=i]),id(o,a,Pd(i,t,n,a,e,r))}),o}Ed[wd]=Ed["[object Array]"]=Ed["[object ArrayBuffer]"]=Ed["[object DataView]"]=Ed["[object Boolean]"]=Ed["[object Date]"]=Ed["[object Float32Array]"]=Ed["[object Float64Array]"]=Ed["[object Int8Array]"]=Ed["[object Int16Array]"]=Ed["[object Int32Array]"]=Ed["[object Map]"]=Ed["[object Number]"]=Ed[Sd]=Ed["[object RegExp]"]=Ed["[object Set]"]=Ed["[object String]"]=Ed["[object Symbol]"]=Ed["[object Uint8Array]"]=Ed["[object Uint8ClampedArray]"]=Ed["[object Uint16Array]"]=Ed["[object Uint32Array]"]=!0,Ed["[object Error]"]=Ed[kd]=Ed["[object WeakMap]"]=!1;var Td=e=>"object"==typeof e&&null!==e&&"handleEvent"in e,_d=(e,t,n)=>{var i=Object.getOwnPropertyDescriptor(e,t);if(!i||i.configurable)try{Object.defineProperty(e,t,{configurable:!0,enumerable:!1,value:n,writable:!1})}catch(i){try{e[t]=n}catch(e){}}},Md=function(){return c(function e(){o(this,e),this.listeners=new Map},[{key:"addEventListener",value:function(e,t,n){var i;if(t){var a=(e=>"boolean"==typeof e?{capture:e}:null!=e?e:{})(n),r=null!==(i=this.listeners.get(e))&&void 0!==i?i:[];if(!r.some(e=>e.listener===t)){var o={listener:t,once:Boolean(a.once)};if(a.signal){if(a.signal.aborted)return;o.signal=a.signal,o.abortHandler=()=>this.removeEventListener(e,t),a.signal.addEventListener("abort",o.abortHandler,{once:!0})}r.push(o),this.listeners.set(e,r)}}}},{key:"removeEventListener",value:function(e,t){if(t){var n=this.listeners.get(e);if(n&&0!==n.length){for(var i=n.length-1;i>=0;i-=1){var a=n[i];a.listener===t&&(a.signal&&a.abortHandler&&a.signal.removeEventListener("abort",a.abortHandler),n.splice(i,1))}0===n.length&&this.listeners.delete(e)}}}},{key:"dispatchEvent",value:function(e){var t,n;if(!e||"string"!=typeof e.type)throw new TypeError('Failed to execute "dispatchEvent": event type must be a string.');var i=this.listeners.get(e.type);if(!i||0===i.length)return!0;_d(e,"target",this);var a=!1,r=null===(t=e.stopImmediatePropagation)||void 0===t?void 0:t.bind(e),o=null===(n=e.stopPropagation)||void 0===n?void 0:n.bind(e),s=()=>{a=!0,null==r||r()},u=()=>{e.cancelBubble=!0,null==o||o()};e.stopImmediatePropagation=s,e.stopPropagation=u;for(var l,d=h(i.slice());!(l=d()).done;){var c=l.value;if(a)break;_d(e,"currentTarget",this),"function"==typeof c.listener?c.listener.call(this,e):Td(c.listener)&&c.listener.handleEvent.call(c.listener,e),c.once&&this.removeEventListener(e.type,c.listener)}if(r)e.stopImmediatePropagation=r;else try{delete e.stopImmediatePropagation}catch(t){e.stopImmediatePropagation=s}if(o)e.stopPropagation=o;else try{delete e.stopPropagation}catch(t){e.stopPropagation=u}return _d(e,"currentTarget",null),!e.defaultPrevented}}])}(),Ad=[];var Dd={paywallId:"",livePaywalls:[],selectedPaywall:void 0,selectedCampaign:void 0,campaignRules:[],anySkuHasTrialOffer:!1,anySkuHasIntroOffer:!1,anySkuHasPromoOffer:!1,isLoggedIn:!1,darkMode:!1,safeAreaTop:0,groups:[],selectedProducts:{},formStates:{},formFieldErrors:{},formFieldValidators:{},timerStates:{},currentPage:"page1",pageHistory:["page1"],currentGroupId:"",currentGroupName:"",fullScreenPresentation:!1,launch:{productGroups:[],customAttributes:{},customObject:{},currentGroup:""},sku:{},orientation:"portrait",focusedState:!1,platformId:"",mediaList:{},skuItems:[],customer:{},hasNotch:!1,purchaseInProgress:!1,formFactor:"desktop",slides:{},userInteractionEnabled:!0,currentSlideIndex:void 0},xd=function(t){function n(e,t,i){var a;o(this,n),(a=r(this,n)).subscribers=new Set,a.productDetails=Ad,a.filteredSkuMenus=[],a.state=Pd(Dd,5);var s=Fr.getNamiProfile();return a.state.isLoggedIn=!(null==s||!s.externalId),a.state.customer=m({},a.state.customer,Fr.getAllCustomerAttributesMap()),a.setPaywall(e,t,i),a.subscribers=new Set,a}return p(n,t),c(n,[{key:"onStateChanged",value:function(){}},{key:"subscribe",value:function(e){return this.subscribers.add(e),()=>this.unsubscribe(e)}},{key:"unsubscribe",value:function(e){this.subscribers.delete(e)}},{key:"emitEvent",value:function(e,t){this.dispatchEvent(function(e,t){if("function"==typeof Event){var n=new Event(e);return Object.defineProperty(n,"detail",{configurable:!0,enumerable:!1,value:t,writable:!1}),n}return{type:e,detail:t,bubbles:!1,cancelBubble:!1,cancelable:!1,composed:!1,currentTarget:null,defaultPrevented:!1,eventPhase:0,isTrusted:!1,returnValue:!0,srcElement:null,target:null,timeStamp:Date.now(),NONE:0,CAPTURING_PHASE:1,AT_TARGET:2,BUBBLING_PHASE:3,composedPath:()=>[],initEvent:()=>{},preventDefault:()=>{},stopImmediatePropagation:()=>{},stopPropagation:()=>{}}}(e,t))}},{key:"onEvent",value:function(e,t){var n=e=>t(e.detail);return this.addEventListener(e,n),()=>this.removeEventListener(e,n)}},{key:"setState",value:function(e){this.state=e,this.subscribers.forEach(e=>e()),this.onStateChanged()}},{key:"setProductDetails",value:function(e){this.productDetails=e}},{key:"getProductDetails",value:function(){return this.productDetails}},{key:"setCurrentGroupData",value:function(e,t){var n=Yl(this.productDetails,this.state,this.filteredSkuMenus,ql(this.productDetails,this.filteredSkuMenus,this.state.currentGroupId));this.setState(m({},this.state,{currentGroupId:e,currentGroupName:t,sku:n}))}},{key:"setFormState",value:function(e,t){this.setState(m({},this.state,{formStates:m({},this.state.formStates,{[e]:t})}))}},{key:"registerFormFieldValidator",value:function(e,t){this.setState(m({},this.state,{formFieldValidators:m({},this.state.formFieldValidators,{[e]:t})}))}},{key:"getFormFieldValidators",value:function(){return this.state.formFieldValidators}},{key:"setFormFieldErrors",value:function(e){this.setState(m({},this.state,{formFieldErrors:m({},e)}))}},{key:"setFormFieldError",value:function(e,t){this.setState(m({},this.state,{formFieldErrors:m({},this.state.formFieldErrors,{[e]:t})}))}},{key:"clearFormFieldError",value:function(e){var t=m({},this.state.formFieldErrors);delete t[e],this.setState(m({},this.state,{formFieldErrors:t}))}},{key:"getFormFieldErrors",value:function(){return this.state.formFieldErrors}},{key:"setTimerState",value:function(e,t,n,i){this.setState(m({},this.state,{timerStates:m({},this.state.timerStates,{[e]:{remainingSeconds:t,savedAt:n,hasEmittedCompletion:i}})}))}},{key:"getTimerState",value:function(e){return this.state.timerStates[e]}},{key:"getCurrentGroupId",value:function(){return this.state.currentGroupId}},{key:"getCurrentGroupName",value:function(){return this.state.currentGroupName}},{key:"setCurrentFormId",value:function(e,t){var n=this.state.formStates||{},i=m({},n,{[e]:t||!n[e]});this.setState(m({},this.state,{formStates:i}))}},{key:"getCurrentFormId",value:function(e){return this.state.formStates[e]}},{key:"setSelectedProducts",value:function(e){var t=Yl(this.productDetails,this.state,this.filteredSkuMenus,ql(this.productDetails,this.filteredSkuMenus,this.state.currentGroupId));this.setState(m({},this.state,{selectedProducts:e,sku:t}))}},{key:"selectedProducts",value:function(){return this.state.selectedProducts}},{key:"setPaywall",value:function(e,t,n){var i,a,r,o,s,u=m({},this.state,{formFactor:ou(),selectedPaywall:e,selectedCampaign:n}),l=function(e,t,n=[]){var i,a,r=null!==(i=t.productGroups)&&void 0!==i&&i.length?t.productGroups:n.map(e=>e.ref);return{customAttributes:t.customAttributes,productGroups:r,customObject:m({},e.customObject,t.customObject),currentGroup:null!==(a=t.currentGroup)&&void 0!==a?a:""}}((u=m({},u,null===(i=e.template)||void 0===i?void 0:i.initialState)).launch,t,e.sku_menus);(this.filteredSkuMenus=null!==(a=e.sku_menus)&&void 0!==a?a:[],l.productGroups.length&&(this.filteredSkuMenus=this.filteredSkuMenus.filter(e=>l.productGroups.includes(e.ref))),""!==l.currentGroup&&u.groups.length&&null!==(r=e.template)&&void 0!==r&&r.displaySingleGroup)&&(u.currentGroupId=null!==(o=null===(s=u.groups.find(e=>e.ref==l.currentGroup))||void 0===s?void 0:s.id)&&void 0!==o?o:"");if(""===u.currentGroupId&&1===this.filteredSkuMenus.length){var d,c=u.groups.find(e=>e.ref==this.filteredSkuMenus[0].ref);u.currentGroupId=null!==(d=null==c?void 0:c.id)&&void 0!==d?d:u.currentGroupId}var h=ql(this.productDetails,this.filteredSkuMenus,u.currentGroupId);u.skuItems=h,u.launch=l,u.anySkuHasTrialOffer=Zl(this.productDetails,this.filteredSkuMenus),u.anySkuHasPromoOffer=function(e,t){return!Zl(e,t)&&t.flatMap(e=>e.products).some(t=>1==Al("promoEligible",ed(e,t.sku_ref_id)))}(this.productDetails,this.filteredSkuMenus),u.paywallId=e.id,u.sku=Yl(this.productDetails,u,this.filteredSkuMenus,h),u.pageHistory=[u.currentPage],this.setState(u)}},{key:"getSelectedPaywall",value:function(){return this.state.selectedPaywall}},{key:"getSelectedCampaign",value:function(){return this.state.selectedCampaign}},{key:"getCurrentPlacementLabel",value:function(){var e,t;return null!==(e=this.state.selectedCampaign)&&void 0!==e&&e.value?this.state.selectedCampaign.value:null!==(t=this.flow)&&void 0!==t&&null!==(t=t.campaign)&&void 0!==t&&t.value?this.flow.campaign.value:void 0}},{key:"getPaywallActionEventData",value:function(){var t,n,i,a,r,o,s,u,l,d=this.state.selectedCampaign,c=this.state.selectedPaywall;return{paywallId:null!==(t=null==c?void 0:c.id)&&void 0!==t?t:"",paywallName:null!==(n=null==c?void 0:c.name)&&void 0!==n?n:"",campaignId:null!==(i=null==d?void 0:d.rule)&&void 0!==i?i:"",campaignName:null!==(a=null==d?void 0:d.name)&&void 0!==a?a:"",campaignType:null!==(r=null==d?void 0:d.type)&&void 0!==r?r:"",campaignLabel:null!==(o=null==d?void 0:d.value)&&void 0!==o?o:"",campaignUrl:(null==d?void 0:d.type)===e.NamiCampaignRuleType.URL&&null!==(s=null==d?void 0:d.value)&&void 0!==s?s:"",segmentId:null!==(u=null==d?void 0:d.segment)&&void 0!==u?u:"",externalSegmentId:null!==(l=null==d?void 0:d.external_segment)&&void 0!==l?l:""}}},{key:"paywallId",value:function(){return this.state.paywallId}},{key:"setCurrentPage",value:function(e){if(e&&e!==this.state.currentPage){var t=this.state.pageHistory&&this.state.pageHistory.length?this.state.pageHistory:[this.state.currentPage];this.setState(m({},this.state,{currentPage:e,pageHistory:[...t,e]}))}}},{key:"canGoBackPage",value:function(){var e,t;return(null!==(e=null===(t=this.state.pageHistory)||void 0===t?void 0:t.length)&&void 0!==e?e:0)>1}},{key:"goBackPage",value:function(){var e=this.state.pageHistory&&this.state.pageHistory.length?[...this.state.pageHistory]:[this.state.currentPage];if(e.length<=1)return!1;e.pop();var t=e[e.length-1];return!!t&&(this.setState(m({},this.state,{currentPage:t,pageHistory:e})),!0)}},{key:"setCustomerAttribute",value:function(e){this.setState(m({},this.state,{customer:m({},this.state.customer,e)}))}},{key:"removeCustomerAttribute",value:function(e){var t=m({},this.state.customer);delete t[e],this.setState(m({},this.state,{customer:t}))}},{key:"setIsLoggedIn",value:function(e){this.setState(m({},this.state,{isLoggedIn:e}))}},{key:"setMediaList",value:function(e){this.setState(m({},this.state,{mediaList:e.reduce((e,t)=>m({},e,{[t.name]:t}))}))}},{key:"setSafeAreaTop",value:function(e){this.setState(m({},this.state,{safeAreaTop:e}))}},{key:"setFullScreenPresentation",value:function(e){this.setState(m({},this.state,{fullScreenPresentation:e}))}},{key:"setFormFactor",value:function(e){this.setState(m({},this.state,{formFactor:e}))}},{key:"getFormFactor",value:function(){return this.state.formFactor}},{key:"setPurchaseInProgress",value:function(e){this.setState(m({},this.state,{purchaseInProgress:e}))}},{key:"setPurchase",value:function(e,t){this.setState(m({},this.state,{purchaseInProgress:e,productBeingPurchased:t}))}},{key:"setTimeSpentOnPaywall",value:function(e){this.setState(m({},this.state,{timeSpentOnPaywall:e}))}},{key:"setAppSuppliedVideoDetails",value:function({url:e,name:t}){this.setState(m({},this.state,{appSuppliedVideoUrl:e,appSuppliedVideoName:t}))}},{key:"resetAppSuppliedVideoDetails",value:function(){var e=m({},this.state);delete e.appSuppliedVideoUrl,delete e.appSuppliedVideoName,this.setState(e)}},{key:"setLaunchDetails",value:function(e,t){this.setState(m({},this.state,{launchValue:e,launchType:t}))}},{key:"setOpenHeaderIds",value:function(e,t){e=null!=t&&t.skuId?`${e}_${t.skuId}`:e;var n=[...this.state.openHeaderIds],i=n.indexOf(e);-1!==i?n.splice(i,1):n.push(e),this.setState(m({},this.state,{openHeaderIds:n,currentCollapsibleSku:null!=t?t:null}))}},{key:"getCurrentCollapsibleSku",value:function(){return this.state.currentCollapsibleSku}},{key:"setFlow",value:function(e){this.flow=e}},{key:"setUserInteractionEnabled",value:function(e){this.setState(m({},this.state,{userInteractionEnabled:e})),this.emitEvent("user-interaction-changed",{enabled:e})}},{key:"setUserTags",value:function(e){this.setState(m({},this.state,{customer:m({},this.state.customer,e)}))}},{key:"setCurrentSlideIndex",value:function(e){this.setState(m({},this.state,{currentSlideIndex:e}))}}],[{key:"create",value:function(e,t,i){var a=new n(e,t,i);return this.providers.push(a),a}},{key:"remove",value:function(e){this.providers=this.providers.filter(t=>t!==e)}},{key:"reset",value:function(){this.providers=[]}},{key:"currentProvider",get:function(){return n.providers[0]}},{key:"setCustomerAttribute",value:function(e){this.providers.forEach(t=>{t.setCustomerAttribute(e)})}},{key:"removeCustomerAttribute",value:function(e){this.providers.forEach(t=>{t.removeCustomerAttribute(e)})}},{key:"setAppSuppliedVideoDetails",value:function(e){this.providers.forEach(t=>{t.setAppSuppliedVideoDetails(e)})}},{key:"getSelectedPaywall",value:function(){var e;return null===(e=this.providers[0])||void 0===e?void 0:e.getSelectedPaywall()}},{key:"setUserInteractionEnabled",value:function(e){this.providers.forEach(t=>{t.setUserInteractionEnabled(e)})}},{key:"setUserTags",value:function(e){this.providers.forEach(t=>{t.setUserTags(e)})}},{key:"setProductDetails",value:function(e){this.providers.forEach(t=>{t.setProductDetails(e)}),Ad=e}},{key:"setPurchaseInProgress",value:function(e){this.providers.forEach(t=>{t.setPurchaseInProgress(e)})}},{key:"setIsLoggedIn",value:function(e){this.providers.forEach(t=>{t.setIsLoggedIn(e)})}},{key:"setPurchase",value:function(e,t){this.providers.forEach(n=>{n.setPurchase(e,t)})}},{key:"getSelectedSlideIndex",value:function(){var e;return null===(e=this.providers[0])||void 0===e?void 0:e.state.currentSlideIndex}}])}(Md);xd.providers=[];var Cd=c(function e(){o(this,e),this.refIdToPurchasedSKUs={},this.refIdToRelatedSKUs={},this.refIdToActivePurchases={}});Cd.instance=new Cd;var Id=()=>Lr(li([...Fr.getNamiEntitlements(pt),...Fr.getNamiEntitlements(_t)]),"referenceId"),Ld=()=>{Nu.getInstance().emit(Xn,Id())};function Rd(e){return{id:e.id,skuId:e.sku_ref_id,name:e.name,type:e.sku_type||"unknown",entitlements:e.entitlements,productDetails:"product_details"in e?e.product_details:null}}var Fd=function(){return c(function e(){o(this,e)},[{key:"fetchActiveEntitlements",value:function(){var e,t,n;return k(function(i){for(;;)switch(i.n){case 0:if(e=null,ol()||Ds(Pe.THIRD_PARTY_TRANSACTIONS)||!Ds(Pe.ENTITLEMENT_MANAGEMENT)){i.n=3;break}if(null==(t=Fr.getDevice())||!t.id){i.n=2;break}return i.n=1,a(this.getAPIEntitlements(t.id));case 1:n=i.v,(e=null==n?void 0:n.results)&&(Fr.setActiveEntitlements(ft,e),this.invokeActiveEntitlementsHandler(e));case 2:i.n=4;break;case 3:ol()&&ui.debug("Skipping active entitlements update - anonymous mode");case 4:return i.a(2,e)}},null,this,null,Promise)}},{key:"getAPIEntitlements",value:function(e){var t,n,i;return k(function(r){for(;;)switch(r.p=r.n){case 0:return t=`device/${e}/active_entitlements/`,n={},r.p=1,r.n=2,a(js.instance.fetchAPI(t));case 2:n=r.v,r.n=4;break;case 3:throw r.p=3,i=r.v,ui.error(Zr(i.status,t)),i;case 4:return r.a(2,n)}},null,null,[[1,3]],Promise)}},{key:"invokeActiveEntitlementsHandler",value:function(e){Cs()&&(e=>{Fr.setNamiEntitlements(pt,e);var t=Fr.getNamiEntitlements(_t),n=new Set(e.map(e=>e.referenceId)),i=t.filter(e=>{var t=n.has(e.referenceId);return t&&ui.debug(`Server granted verified entitlement for ${e.referenceId}, so replacing provisional entitlement grant.`),!t});i.length!==t.length&&Fr.setNamiEntitlements(_t,i),Ld()})(e.map(e=>(e=>{var t=e.entitlement_ref_id;return{name:e.name||"",desc:e.description||"",namiId:"",referenceId:t,relatedSkus:Cd.instance.refIdToRelatedSKUs[t]||[],activePurchases:Cd.instance.refIdToActivePurchases[t]||[],purchasedSkus:Cd.instance.refIdToPurchasedSKUs[t]||[],expires:e.expires?new Date(e.expires).valueOf():0}})(e)))}}])}();Fd.instance=new Fd;var Od=function(){return c(function e(){o(this,e)},[{key:"fetchCustomerJourneyState",value:function(){var e,t,n,i;return k(function(r){for(;;)switch(r.p=r.n){case 0:if(!ol()){r.n=1;break}return ui.debug("Skipping customer journey state update - anonymous mode"),r.a(2,null);case 1:if(null!=(e=Fr.getDevice())&&e.id){r.n=2;break}return r.a(2,null);case 2:return t=`device/${e.id}/profile/`,n=null,r.p=3,r.n=4,a(js.instance.fetchAPI(t,void 0,0));case 4:n=r.v,r.n=6;break;case 5:throw r.p=5,i=r.v,ui.error(Zr(i.status,t)),i;case 6:if(!n){r.n=7;break}return Fr.setCustomerJourneyState(n.customer_journey_state),r.a(2,n.customer_journey_state);case 7:return r.a(2,null)}},null,null,[[3,5]],Promise)}}])}();Od.instance=new Od;var $d="[NamiStartup]",Nd=function(){return c(function e(){o(this,e),this.enabled=!1,this.t0=0,this.lastMark=0,this.decodeDuration=0,this.processDuration=0,this.placements=0,this.firstLaunchLogged=!1},[{key:"start",value:function(e){var t;this.enabled=null!==(t=null==e?void 0:e.includes(wn))&&void 0!==t&&t,this.enabled&&(this.t0=Date.now(),this.lastMark=this.t0,this.decodeDuration=0,this.processDuration=0,this.placements=0,this.firstLaunchLogged=!1)}},{key:"mark",value:function(e,t){if(this.enabled){var n=Date.now(),i=n-this.lastMark;this.lastMark=n,"initial_config_decoded"===e?this.decodeDuration=i:"initial_processed"===e&&(this.processDuration=i,void 0!==(null==t?void 0:t.count)&&(this.placements=t.count));var a=t?" "+Object.entries(t).map(([e,t])=>`${e}=${t}`).join(" "):"";if("ready"===e){var r=n-this.t0;ui.info(`${$d} phase=${e} ms=${i} total_to_ready=${r}${a}`),ui.info(`${$d} SUMMARY total_to_ready=${r} decode=${this.decodeDuration} process=${this.processDuration} placements=${this.placements}`)}else ui.info(`${$d} phase=${e} ms=${i}${a}`)}}},{key:"firstLaunchLookup",value:function(e,t){if(!this.enabled||this.firstLaunchLogged)return t();this.firstLaunchLogged=!0;var n=Date.now(),i=t(),a=Date.now()-n;return ui.info(`${$d} phase=first_launch_lookup ms=${a} label=${e}`),i}},{key:"serverFetch",value:function(e){var t,n,i;return k(function(r){for(;;)switch(r.n){case 0:if(this.enabled){r.n=1;break}return r.a(2,e());case 1:return t=Date.now(),r.n=2,a(e());case 2:return n=r.v,i=Date.now()-t,ui.info(`${$d} phase=server_fetch ms=${i} campaigns=${n.length}`),r.a(2,n)}},null,this,null,Promise)}}])}(),Wd=new Nd,jd=function(){return c(function e(){o(this,e),this.inMemoryAnonymousMode=!1,this.isFirstSession=!1,al=this},[{key:"setInMemoryAnonymousMode",value:function(e){this.inMemoryAnonymousMode=e,ui.info(`In-memory anonymous mode ${e?"enabled":"disabled"} due to failed device registration`)}},{key:"isInMemoryAnonymousMode",value:function(){return this.inMemoryAnonymousMode}},{key:"isAnonymousMode",value:function(){return Fr.getAnonymousMode()||this.inMemoryAnonymousMode}},{key:"getIsFirstSession",value:function(){return this.isFirstSession}},{key:"init",value:function(e){return k(function(t){for(;;)switch(t.n){case 0:return this.isFirstSession=null===Fr.getDevice()&&!Fr.getAnonymousMode(),this.setInitialValues(e),il.instance.fetchConfig(),t.n=1,a(this.initAndFetchRequiredData(e));case 1:sl.instance.startSession();case 2:return t.a(2)}},null,this,null,Promise)}},{key:"setInitialValues",value:function(e){var t=m({},e);delete t.initialConfig,Fr.clearSessionId(),Fr.setNamiConfig(t),Fr.setLanguageCode(e.namiLanguageCode),Fr.setPurchaseChannel(e.purchaseChannel);var n=e.initialConfig;if(n.appConfig||n.platform_config){var i=(null==n?void 0:n.appConfig)||(null==n?void 0:n.platform_config);i&&Fr.setAppConfig(yt,i)}null!=n&&n.paywalls&&Fr.setPaywalls(St,n.paywalls),null!=n&&n.products&&Fr.setProducts(Pt,n.products)}},{key:"initAnonymousDevice",value:function(){return{deviceId:Bu.instance.getOrCreateAnonymousUUID(),deviceTask:null}}},{key:"initIdentifiedDevice",value:function(e){var t=m({},ru(e.namiCommands),e.formFactor?{form_factor:e.formFactor}:{}),n=function(e){if(e){var t=e.find(e=>e.startsWith("splitPosition="));if(t){var n=t.split("=")[1],i=Number(n);return n&&!isNaN(i)?du(i):void 0}}}(e.namiCommands),i=Bu.instance.createOrUpdateDevice(t,n,this);return{deviceId:i.id,deviceTask:i.device}}},{key:"initAndFetchRequiredData",value:function(e,t=0,n=1){var i,r,o,s,u,l,d,c,h,m,f,v;return k(function(p){for(;;)switch(p.n){case 0:if(s=e.initialConfig,u=null!==(i=e.formFactor)&&void 0!==i?i:ou(),l=this.isAnonymousMode(),d=l?this.initAnonymousDevice():this.initIdentifiedDevice(e),c=d.deviceId,h=d.deviceTask,m=uu(c),s.campaign_rules&&(f=yu(s.campaign_rules,m,u),Fr.setCampaignRules(wt,f),Wd.mark("initial_processed",{count:f.length})),!h){p.n=1;break}return p.n=1,a(h);case 1:if(Wu.instance.configure(u,m,e.namiCommands),xs(),v=Promise.all([zu.instance.fetchProducts(),Od.instance.fetchCustomerJourneyState(),Fd.instance.fetchActiveEntitlements(),Wd.serverFetch(()=>this.fetchCampaignsAndPaywalls())]).catch(i=>{var r;return k(function(o){for(;;)switch(o.n){case 0:if(!(i instanceof Nr)){o.n=3;break}if(Fr.resetDevice(),!(t<n)){o.n=2;break}return r=100*Math.pow(2,t),o.n=1,a(new Promise(e=>setTimeout(e,r)));case 1:return o.a(2,this.initAndFetchRequiredData(e,t+1,n));case 2:if(l){o.n=3;break}return ui.warn(`Max retries reached for ConflictError. ${i.message}`),this.setInMemoryAnonymousMode(!0),o.a(2,this.initAndFetchRequiredData(e,0,n));case 3:throw i;case 4:return o.a(2)}},null,this,null,Promise)}),null!==(r=s.campaign_rules)&&void 0!==r&&r.length&&null!==(o=s.paywalls)&&void 0!==o&&o.length){p.n=2;break}return p.n=2,a(v);case 2:v.then(()=>this.reRenderPaywall());case 3:return p.a(2)}},null,this,null,Promise)}},{key:"fetchCampaignsAndPaywalls",value:function(){var e,t,n,i,r,o,s,u,l,d,c,h,m,f;return k(function(v){for(;;)switch(v.n){case 0:return e=Wu.instance,t=nl.instance,n=Date.now(),i=Date.now(),v.n=1,a(e.fetchCampaignRulesRaw());case 1:return r=v.v,o=Date.now()-i,v.n=2,a(Promise.all(r.filter(e=>{var t;return(null===(t=e.flow)||void 0===t?void 0:t.url)&&!e.flow.object}).map(e=>{var t,n;return k(function(i){for(;;)switch(i.p=i.n){case 0:return i.p=0,i.n=1,a(tl(e.flow.url));case 1:t=i.v,e.flow.object=t.data,i.n=3;break;case 2:i.p=2,n=i.v,ui.warn(`Error fetching flow object from ${e.flow.url}: ${n}`);case 3:return i.a(2)}},null,null,[[0,2]],Promise)})));case 2:if(s=!e.useLegacyPaywallFetch&&Wu.hasPaywallUrls(r),l=0,d=Date.now(),!s){v.n=4;break}return c=Wu.extractPaywallUrls(r),v.n=3,a(t.fetchPaywallsByUrls(c));case 3:h=v.v,u=h.paywalls,l=h.retryCount,v.n=6;break;case 4:return v.n=5,a(t.fetchPaywalls());case 5:u=v.v;case 6:return m=Date.now()-d,f=Date.now()-n,Vd.instance.maxLogging&&ui.info(`Paywall fetch telemetry: strategy=${s?"individual":"bulk"}, count=${u.length}, total=${f}ms, campaigns=${o}ms, paywalls=${m}ms`+(s?`, retry_count=${l}`:"")),v.a(2,e.finalizeCampaignRules(r,u))}},null,null,null,Promise)}},{key:"reRenderPaywall",value:function(){we().ui.reRenderPaywall()}}])}();function Bd(e){return Array.isArray(e)?e.map(Bd):e&&"object"==typeof e?Object.entries(e).reduce((e,[t,n])=>(void 0!==n&&(e[t]=Bd(n)),e),{}):e}function zd(e,t){return ju(Bd(e),Bd(t))}jd.instance=new jd;var Ud=function(){return c(function e(){o(this,e),this.load()},[{key:"setExternalId",value:function(e){return this.externalId=e,this}},{key:"getExternalId",value:function(){return this.externalId}},{key:"isLoggedIn",value:function(){return!!this.externalId}},{key:"save",value:function(){return this.externalId?Fr.setNamiProfile({externalId:this.externalId}):Fr.removeNamiProfile(),this}},{key:"load",value:function(){var e=Fr.getNamiProfile();e&&(this.externalId=e.externalId),xd.setIsLoggedIn(!!this.externalId)}},{key:"loginLocal",value:function(e){this.setExternalId(e).save(),xd.setIsLoggedIn(!0)}},{key:"loginRemote",value:function(e){var t;return k(function(n){for(;;)switch(n.n){case 0:return n.n=1,a(js.instance.login(e));case 1:(t=n.v).external_id&&t.external_id!==this.externalId&&this.setExternalId(t.external_id).save();case 2:return n.a(2)}},null,this,null,Promise)}},{key:"logoutLocal",value:function(){this.setExternalId(void 0).save(),xd.setIsLoggedIn(!1)}},{key:"logoutRemote",value:function(){return k(function(e){for(;;)switch(e.n){case 0:return e.n=1,a(js.instance.logout());case 1:return e.a(2)}},null,null,null,Promise)}},{key:"login",value:function(e){return k(function(t){for(;;)switch(t.n){case 0:return this.loginLocal(e),t.n=1,a(this.loginRemote(e));case 1:return t.a(2)}},null,this,null,Promise)}},{key:"logout",value:function(){return k(function(e){for(;;)switch(e.n){case 0:return this.logoutLocal(),e.n=1,a(this.logoutRemote());case 1:return e.a(2)}},null,this,null,Promise)}}])}();Ud.instance=new Ud;var Hd,Gd=function(){function e(){o(this,e)}return c(e,[{key:"previous",get:function(){return this._previous}},{key:"record",value:function(e){this._previous=this._current,this._current=e}},{key:"reset",value:function(){this._current=void 0,this._previous=void 0}}],[{key:"shared",get:function(){return this._shared||(this._shared=new e),this._shared}}])}(),Vd=function(){function e(){o(this,e),Hd.set(this,!1),this.maxLogging=!1}return c(e,[{key:"isInitialized",get:function(){return Se(this,Hd,"f")||null!=Fr.getNamiConfig()}},{key:"initializeSDK",value:function(t){var n,i,r,o,s,u,l,d,c,h;return k(function(f){for(;;)switch(f.n){case 0:if(o=!1,s=!1,u=Se(this,Hd,"f")?Fr.getNamiConfig():null,ui.setLogger(t.logLevel),e.instance.maxLogging=null!==(n=t.maxLogging)&&void 0!==n&&n,null===u){f.n=3;break}if(delete(l=m({},t)).initialConfig,!zd(l,u)){f.n=1;break}return ui.warn("Nami SDK is already configured, ignoring this configure call."),f.a(2,{sdkInitialized:!0,configureState:zn});case 1:s=!0;case 2:d=As(t.namiCommands),c=As(u.namiCommands),t.appPlatformID==u.appPlatformID&&d==c||(o=!0),t.namiLanguageCode===u.namiLanguageCode&&t.logLevel==u.logLevel||(s=!0);case 3:return o&&(ui.info("SDK full reconfigure called"),Fr.resetDevice()),Ee(this,Hd,!0),js.configure(t),f.n=4,a(jd.instance.init(t));case 4:return ui.info("SDK successfully initialized!"),h=s||o?jn:Nn,null===(i=(r=we().ui).postConfigure)||void 0===i||i.call(r),Wd.mark("ready"),f.a(2,{sdkInitialized:!0,configureState:h})}},null,this,null,Promise)}}],[{key:"sdkVersion",value:function(){return Ae}},{key:"sdkPackageVersion",value:function(){return xe}},{key:"reset",value:function(){var t,n,i;return k(function(r){for(;;)switch(r.n){case 0:return Fr.clearAll(),rl(),Ee(e.instance,Hd,!1),Ud.instance.setExternalId(void 0),xd.reset(),js.reset(),Wu.instance.reset(),Gd.shared.reset(),r.n=1,a(Promise.resolve().then(function(){return eh}));case 1:i=r.v,i.NamiFlowManager.reset(),null===(t=(n=we().ui).onReset)||void 0===t||t.call(n);case 2:return r.a(2)}},null,null,null,Promise)}},{key:"configure",value:function(t){return k(function(n){for(;;)switch(n.n){case 0:if(Wd.start(t.namiCommands),t.appPlatformID){n.n=1;break}throw new jr;case 1:return this.setInitialConfig(t),Wd.mark("initial_config_decoded"),n.n=2,a(e.instance.initializeSDK(t));case 2:return n.a(2,n.v)}},null,this,null,Promise)}},{key:"setInitialConfig",value:function(e){if(null!=e.initialConfig){if("string"==typeof e.initialConfig){ui.debug("[DEPRECATED] NamiConfiguration.initialConfig should be an object");var t=function(e){var t=e.trim();if(t.startsWith("{")||t.startsWith("["))try{return JSON.parse(t)}catch(e){return}}(e.initialConfig);if(!t)return ui.error("Failed to parse NamiConfiguration.initialConfig"),void(e.initialConfig={});e.initialConfig=t}if("object"!=typeof e.initialConfig)e.initialConfig={};else if((e=>"object"==typeof e&&"initial_config"in e)(e.initialConfig)){var n=Rs(e.initialConfig.initial_config);n?e.initialConfig=n:(e.initialConfig={},ui.error("Failed to parse NamiConfiguration.initialConfig as base64-gzipped JSON"))}}else e.initialConfig={}}}])}();Hd=new WeakMap,Vd.instance=new Vd;var Kd,Xd,Yd,qd=new Set(["fullscreen","sheet","compact_sheet","modal"]);e.NamiPaywallManagerEvents=void 0,(Kd=e.NamiPaywallManagerEvents||(e.NamiPaywallManagerEvents={})).BuySku="RegisterBuySKU",Kd.Close="PaywallCloseRequested",Kd.SignIn="PaywallSignInRequested",Kd.Restore="PaywallRestoreRequested",Kd.DeeplinkAction="PaywallDeeplinkAction",e.NamiPaywallAction=void 0,(Xd=e.NamiPaywallAction||(e.NamiPaywallAction={})).BUY_SKU="BUY_SKU",Xd.SELECT_SKU="SELECT_SKU",Xd.RESTORE_PURCHASES="RESTORE_PURCHASES",Xd.SIGN_IN="SIGN_IN",Xd.CLOSE_PAYWALL="CLOSE_PAYWALL",Xd.SHOW_PAYWALL="SHOW_PAYWALL",Xd.PURCHASE_SELECTED_SKU="PURCHASE_SELECTED_SKU",Xd.PURCHASE_SUCCESS="PURCHASE_SUCCESS",Xd.PURCHASE_FAILED="PURCHASE_FAILED",Xd.PURCHASE_CANCELLED="PURCHASE_CANCELLED",Xd.PURCHASE_PENDING="PURCHASE_PENDING",Xd.PURCHASE_UNKNOWN="PURCHASE_UNKNOWN",Xd.PURCHASE_DEFERRED="PURCHASE_DEFERRED",Xd.DEEPLINK="DEEPLINK",Xd.TOGGLE_CHANGE="TOGGLE_CHANGE",Xd.PAGE_CHANGE="PAGE_CHANGE",Xd.SLIDE_CHANGE="SLIDE_CHANGE",Xd.COLLAPSIBLE_DRAWER_OPEN="COLLAPSIBLE_DRAWER_OPEN",Xd.COLLAPSIBLE_DRAWER_CLOSE="COLLAPSIBLE_DRAWER_CLOSE",Xd.VIDEO_STARTED="VIDEO_STARTED",Xd.VIDEO_PAUSED="VIDEO_PAUSED",Xd.VIDEO_RESUMED="VIDEO_RESUMED",Xd.VIDEO_ENDED="VIDEO_ENDED",Xd.VIDEO_CHANGED="VIDEO_CHANGED",Xd.VIDEO_MUTED="VIDEO_MUTED",Xd.VIDEO_UNMUTED="VIDEO_UNMUTED",Xd.COUNTDOWN_TIMER_COMPLETED="COUNTDOWN_TIMER_COMPLETED",Xd.UNKNOWN="UNKNOWN",e.LaunchCampaignError=void 0,(Yd=e.LaunchCampaignError||(e.LaunchCampaignError={})).DEFAULT_CAMPAIGN_NOT_FOUND="Default campaign not found",Yd.LABELED_CAMPAIGN_NOT_FOUND="Labeled campaign not found",Yd.CAMPAIGN_DATA_NOT_FOUND="Campaign data not found",Yd.PAYWALL_ALREADY_DISPLAYED="Paywall is already being displayed",Yd.SDK_NOT_INITIALIZED="SDK has not been initialized",Yd.PAYWALL_COULD_NOT_DISPLAY="Failed to display paywall",Yd.URL_CAMPAIGN_NOT_FOUND="URL campaign not found",Yd.PRODUCT_DATA_NOT_FOUND="Product data not found",Yd.PRODUCT_GROUPS_NOT_FOUND="Product groups not found",Yd.FLOW_SCREEN_DATA_UNAVILABLE="Flow unavailable due to missing screen data";var Jd,Qd="entry",Zd="screen",ec="branch",tc="exit",nc="unknown";!function(e){e.NAVIGATE="flowNav",e.BACK="flowPrev",e.NEXT="flowNext",e.FINISHED="flowDone",e.DISMISS="flowDismiss",e.EXIT="flowExit",e.HANDOFF="flowHandoff",e.TRACK="trackEvent",e.LOG="logEvent",e.SET_VIDEO="setVideo",e.FLOW_EVENT="flowEvent",e.BLOCK_BACK="blockBackToStep",e.FLOW_ENABLED="flowInteractionEnabled",e.FLOW_DISABLED="flowInteractionDisabled",e.SET_TAGS="setTags",e.SET_TAGS_FROM_FORM="setTagsFromForm",e.PAUSE="flowPause",e.RESUME="flowResume",e.SET_LAUNCH_CONTEXT="setLaunchContext",e.SET_FLOW_PATH="setFlowPath"}(Jd||(Jd={}));var ic="__handoff_sequence__",ac={Push:"push",Location:"location",Tracking:"att",Deeplink:"deeplink",Complete:"complete",SignIn:"signin",Restore:"restore",SignInMvpd:"signin_mvpd",BuySku:"buysku",UserData:"userdata"};var rc={Push:"push",Location:"location",Tracking:"tracking",Camera:"camera",Microphone:"microphone",Photos:"photos",Contacts:"contacts",Bluetooth:"bluetooth",Calendar:"calendar",Biometrics:"biometrics",Health:"health",Motion:"motion",Speech:"speech",LocalNetwork:"localNetwork"},oc={[rc.Push]:"push_authorized",[rc.Location]:"location_authorized",[rc.Tracking]:"tracking_authorized"},sc="__buy_sku__",uc="__default__",lc="__appear__",dc="__disappear__",cc="__login_success__",hc="__login_failure__",mc="__logout_success__",fc="__logout_failure__",vc="__purchase_success__",pc="__purchase_failure__",gc="__remoteback__",yc="__tag_update__",bc="__permission_granted__",wc="and",kc="or",Sc="i_contains",Ec="equals",Pc="i_equals",Tc="not_equals",_c="not_i_equals",Mc="not_contains",Ac="contains",Dc="set",xc="not_set",Cc="greater_than",Ic="greater_than_or_equal_to",Lc="less_than",Rc="less_than_or_equal_to";function Fc(e){if("boolean"==typeof e)return null;if("number"==typeof e)return Number.isFinite(e)?e:null;if("string"==typeof e){var t=e.trim();if(""===t)return null;var n=Number(t);return Number.isFinite(n)?n:null}return null}var Oc=function(){function e(){o(this,e),this.resolvers=new Map,this.namespaceResolvers=new Map}return c(e,[{key:"registerNamespaceResolver",value:function(e,t){this.namespaceResolvers.set(e,t)}},{key:"resetResolvers",value:function(){this.resolvers.clear()}},{key:"evaluate",value:function(e){var t,n=null!==(t=e.filter)&&void 0!==t?t:[];if(0===n.length)return!0;var i=n.map(e=>this.evaluateFilter(e));switch(e.operator){case wc:return i.every(e=>e);case kc:return i.some(e=>e);default:return i.every(e=>e)}}},{key:"evaluateOrdered",value:function(e){var t;if(!e)return!0;var n=null!==(t=e.filter)&&void 0!==t?t:[];if(0===n.length)return!0;switch(e.operator){case wc:for(var i,a=h(n);!(i=a()).done;){var r=i.value;if(!this.evaluateFilter(r))return!1}return!0;case kc:for(var o,s=h(n);!(o=s()).done;){var u=o.value;if(this.evaluateFilter(u))return!0}return!1;default:for(var l,d=h(n);!(l=d()).done;){var c=l.value;if(!this.evaluateFilter(c))return!1}return!0}}},{key:"evaluateFilter",value:function(e){var t=this.resolve(e.identifier);if(Vd.instance.maxLogging&&ui.debug(`[NamiConditionEvaluator] resolve(${e.identifier}) → ${JSON.stringify(t)} (type: ${typeof t})`),e.operator===Dc)return null!=t;if(e.operator===xc)return null==t;if(null==t)return Vd.instance.maxLogging&&ui.debug(`[NamiConditionEvaluator] ${e.identifier} resolved to null — registeredNamespaces: [${[...this.namespaceResolvers.keys()].join(", ")}]`),!![Tc,_c,Mc].includes(e.operator);switch(e.operator){case Sc:return Array.isArray(t)?e.values.some(e=>"string"==typeof e&&t.some(t=>0===t.localeCompare(e,void 0,{sensitivity:"accent"}))):(this.log("Resolved value is not an array of strings for i_contains."),!1);case Ec:return e.values.some(e=>this.strictEquals(t,e,!1));case Pc:return e.values.some(e=>this.strictEquals(t,e,!0));case Tc:return e.values.every(e=>!this.strictEquals(t,e,!1));case _c:return e.values.every(e=>!this.strictEquals(t,e,!0));case Ac:return!(!Array.isArray(t)&&"string"!=typeof t)&&e.values.some(e=>"string"==typeof e&&t.includes(e));case Mc:return Array.isArray(t)?e.values.every(e=>!("string"==typeof e&&t.includes(e))):e.values.every(e=>"string"!=typeof t||"string"!=typeof e||!t.includes(e));case Cc:case Ic:case Lc:case Rc:var n=Fc(t);return null===n?(this.log(`Resolved value is not numerically comparable for ${e.operator}`),!1):e.values.some(t=>{var i=Fc(t);if(null===i)return!1;switch(e.operator){case Cc:return n>i;case Ic:return n>=i;case Lc:return n<i;default:return n<=i}});default:return this.log(`Unsupported operator: ${e.operator}`),!1}}},{key:"strictEquals",value:function(e,t,n){return"string"==typeof e&&"string"==typeof t?n?0===e.localeCompare(t,void 0,{sensitivity:"accent"}):e===t:("boolean"==typeof e&&"boolean"==typeof t||"number"==typeof e&&"number"==typeof t)&&e===t}},{key:"resolve",value:function(e){var t=this.resolveRaw(e);if(void 0!==t)return Vd.instance.maxLogging&&ui.debug(`[NamiConditionEvaluator] resolve(${e}) — exact hit: ${JSON.stringify(t)}`),t;var n=e.lastIndexOf(".");if(-1===n);else{var i=e.slice(0,n),a=e.slice(n+1),r=this.resolveRaw(i);if(void 0!==r){var o=this.extractProperty(a,r);return Vd.instance.maxLogging&&ui.debug(`[NamiConditionEvaluator] resolve(${e}) — fallback: base=${i} → ${typeof r}, extract(.${a}) → ${JSON.stringify(o)}`),o}this.log(`Could not resolve base identifier: ${i}`)}}},{key:"resolveRaw",value:function(e){for(var t,n=[...this.namespaceResolvers.keys()].sort((e,t)=>t.length-e.length),i=h(n);!(t=i()).done;){var a=t.value;if(e.startsWith(a)){var r=this.namespaceResolvers.get(a);if(r){var o=r(e);return Vd.instance.maxLogging&&ui.debug(`[NamiConditionEvaluator] resolveRaw(${e}) — ns=${a} → ${JSON.stringify(o)}`),o}}}}},{key:"extractProperty",value:function(e,t){switch(e){case"last":if(Array.isArray(t))return t[t.length-1];break;case"first":if(Array.isArray(t))return t[0];break;case"count":if(Array.isArray(t))return t.length;if(t&&"object"==typeof t)return Object.keys(t).length;break;default:return}this.log(`Could not extract .${e} from type ${typeof t}`)}},{key:"log",value:function(e){ui.debug(`[NamiConditionEvaluator] ${e}`)}}],[{key:"shared",get:function(){return e.instance||(e.instance=new e),e.instance}}])}(),$c=function(){return c(function e(){o(this,e)},[{key:"register",value:function(){Oc.shared.registerNamespaceResolver(this.namespace,e=>{var t=e.replace(new RegExp(`^${this.namespace}\\.`),"");return this.resolveValue(t)})}},{key:"resolveKeyPath",value:function(e,t){for(var n,i=t,a=h(e.replace(/\[(\w+)\]/g,".$1").split(".").filter(Boolean));!(n=a()).done;){var r=n.value;if(null==i||"object"!=typeof i)return;i=i[r]}return i}}])}(),Nc=function(e){function t(e,n){var i;return o(this,t),(i=r(this,t)).namespace="LaunchContext",i.context=e,i.campaign=n,i.register(),i}return p(t,e),c(t,[{key:"resolveValue",value:function(e){var t,n,i,a;if("placement"===e)return null!==(t=null===(n=this.campaign)||void 0===n?void 0:n.value)&&void 0!==t?t:void 0;if("tags"===e)return null!==(i=null===(a=this.campaign)||void 0===a?void 0:a.placement_tags)&&void 0!==i?i:void 0;if(e.startsWith("customAttributes.")){var r=e.substring(17);return this.resolveKeyPath(r,this.context.customAttributes)}if(e.startsWith("customObject.")){var o=e.substring(13);return this.resolveKeyPath(o,this.context.customObject)}return this.resolveKeyPath(e,{customAttributes:this.context.customAttributes,customObject:this.context.customObject,productGroups:this.context.productGroups})}}])}($c),Wc=function(e){function t(){var e,n,i,a;o(this,t),(a=r(this,t)).namespace="Device";var s=Intl.DateTimeFormat().resolvedOptions().locale.split("-")[1]||"",u=Intl.DateTimeFormat().resolvedOptions().timeZone,l=ru(),d=we().device.getScreenInfo();return a.context={osName:l.os_name,osVersion:l.os_version,appVersion:l.extended_platform_version,sdkVersion:l.sdk_version,deviceModel:l.device_model,screenWidth:Math.round(d.width),screenHeight:Math.round(d.height),formFactor:l.form_factor,tvQuality:a.tvQuality(null!==(e=l.form_factor)&&void 0!==e?e:"desktop",d),tvResolution:a.tvResolution(null!==(n=l.form_factor)&&void 0!==n?n:"desktop",d),screenSize:a.screenSizeTier(null!==(i=l.form_factor)&&void 0!==i?i:"desktop",d),language:l.language,country:s,timezone:u},a.register(),a}return p(t,e),c(t,[{key:"screenSizeTier",value:function(e,t){var n=Math.round(t.width*t.scale),i=Math.round(t.height*t.scale),a=Math.max(n,i);switch(e){case"phone":return a<1136?"tiny":a<1334?"small":a<1920?"medium":a<2560?"large":"huge";case"tablet":return a<2048?"medium":a<2732?"large":"huge";case"television":return a<1920?"medium":a<3840?"large":"huge";case"desktop":return a<1440?"small":a<2560?"medium":a<3840?"large":"huge";default:return"medium"}}},{key:"tvQuality",value:function(e,t){if("television"!==e)return"";var n=Math.round(t.width*t.scale),i=Math.round(t.height*t.scale),a=Math.max(n,i),r=Math.min(n,i);return a>=3840||r>=2160?"4K":a>=1920||r>=1080?"1080p":"720p"}},{key:"tvResolution",value:function(e,t){if("television"!==e)return"";var n=Math.round(t.width*t.scale),i=Math.round(t.height*t.scale),a=Math.max(n,i),r=Math.min(n,i);return r<720&&a<1280?"SD":r>=720&&r<1080&&a>=1280&&a<1920?"720p":r>=1080&&r<1440&&a>=1920&&a<2560?"1080p":r>=1440&&r<2160&&a>=2560&&a<3840?"1440p":r>=2160&&r<3e3&&a>=3840&&a<5e3?"4K":r>=3e3&&a>=5e3?"8K":"Unknown"}},{key:"resolveValue",value:function(e){return this.resolveKeyPath(e,this.context)}}])}($c),jc=[/(^|_)api(_|$)?key/i,/^key$/i,/^token$/i,/id[_-]?token/i,/access[_-]?token/i,/^auth/i,/password/i,/secret/i,/signature/i,/hmac/i,/^jwt$/i,/^code$/i,/redirect[_-]?uri/i,/return[_-]?url/i,/^state$/i,/^session$/i,/^sid$/i,/^sso$/i,/assertion/i],Bc=function(){function e(){o(this,e),this.params={},"undefined"!=typeof window&&this.setSearchParams()}return c(e,[{key:"setSearchParams",value:function(){this.params=this.extractSafeParams()}},{key:"safeValue",value:function(e){if(!e)return null;try{var t=decodeURIComponent(e).trim();return!t||/^null|undefined$/i.test(t)||((e=>e.includes("://")||/^\/.*\?/.test(e))(t)||(e=>/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+$/.test(e))(t)||(e=>/^[A-Za-z0-9_-]{40,}$/.test(e)||/^[A-Fa-f0-9]{40,}$/.test(e)||/^ya29\./.test(e)||/^sk_/.test(e)||/^ghp_/.test(e))(t))?null:((e,t=128)=>e.length>t?e.slice(0,t):e)(t)}catch(e){return null}}},{key:"extractSafeParams",value:function(){var e=window.location,t={},n=new Set;try{for(var i,a=new URLSearchParams(e.search),r=(e,i)=>{var a=(e=>e.replace(/([a-z])([A-Z])/g,"$1_$2").replace(/[-\s]/g,"_").toLowerCase())(e);if(!(n.size>=10||(e=>jc.some(t=>t.test(e)))(a))){var r=this.safeValue(i);r&&(t[a]=r,n.add(a))}},o=h(a.entries());!(i=o()).done;){var s=i.value;r(s[0],s[1])}}catch(e){}return t}}],[{key:"instance",get:function(){return e._instance||(e._instance=new e),e._instance}},{key:"refresh",value:function(){"undefined"!=typeof window&&this.instance.setSearchParams()}}])}();Bc._instance=null;var zc=()=>Bc.instance.params;function Uc(e){if(null!=e&&""!==e){if("boolean"==typeof e)return e?"true":"false";if("number"==typeof e){if(!Number.isFinite(e))return;return String(e)}return String(e)}}var Hc,Gc=/\{\{\s*([^}]+?)\s*\}\}/g,Vc=function(){return c(function e(t){o(this,e),this.flowManager=t,this.urlParams=zc()},[{key:"resolve",value:function(e){var t,n,i,a,r,o,s,u,l,d,c,h,m=this.flowManager.currentFlow,f=null==m?void 0:m.component;if(e.startsWith("launchContext.")){var v,p=null===(v=this.flowManager.currentFlow)||void 0===v?void 0:v.context;if(p){var g=e.substring(14),y=new Nc(p).resolveValue(g);return null==y?void 0:y.toString()}}else{if(e.startsWith("form.")){var b,w=e.substring(5);return Uc(null===(b=xd.currentProvider)||void 0===b?void 0:b.state.formStates[w])}switch(e){case"campaignId":return null==f||null===(t=f.campaign)||void 0===t?void 0:t.rule;case"campaignName":return null==f||null===(n=f.campaign)||void 0===n?void 0:n.name;case"campaignLabel":case"campaignPlacement":return null!==(i=null==f||null===(a=f.campaign)||void 0===a?void 0:a.value)&&void 0!==i?i:void 0;case"campaignSegment":case"campaignSegmentId":return null==f||null===(r=f.campaign)||void 0===r?void 0:r.segment;case"campaignExternalSegment":case"campaignExternalSegmentId":return null!==(o=null==f||null===(s=f.campaign)||void 0===s?void 0:s.external_segment)&&void 0!==o?o:void 0;case"pageName":return null==f||null===(u=f.paywall)||void 0===u?void 0:u.name;case"pageId":return null==f||null===(l=f.paywall)||void 0===l?void 0:l.id;case"flowName":return null==m?void 0:m.name;case"flowId":return null==m?void 0:m.id;case"objectId":return null==f||null===(d=f.campaign)||void 0===d||null===(d=d.flow)||void 0===d?void 0:d.object_id;case"stepName":return null==m||null===(c=m.currentFlowStep)||void 0===c?void 0:c.name;case"buttonText":var k=null==m?void 0:m.currentButton;if(!k)return;var S=k.firstTextValue;if("function"!=typeof S)return;return S.call(k);case"slideNumber":var E=null==f?void 0:f.getSelectedSlideIndexForCurrentCarousel();return null!=E?`${E+1}`:void 0;case"productGroupId":return(null===(h=xd.currentProvider)||void 0===h?void 0:h.state.currentGroupId)||void 0;case"productGroupName":var P,T,_,M=null===(P=xd.currentProvider)||void 0===P?void 0:P.state;return null!==(T=null==M||null===(_=M.groups)||void 0===_||null===(_=_.find(e=>e.id===M.currentGroupId))||void 0===_?void 0:_.displayName)&&void 0!==T?T:void 0;case"productGroupRef":var A,D,x,C=null===(A=xd.currentProvider)||void 0===A?void 0:A.state;return null!==(D=null==C||null===(x=C.groups)||void 0===x||null===(x=x.find(e=>e.id===C.currentGroupId))||void 0===x?void 0:x.ref)&&void 0!==D?D:void 0;case"flowPath":return null==m?void 0:m.flowPath;default:return}}}},{key:"interpolateLiquidVariables",value:function(e){return e.replace(Gc,(e,t)=>{var n,i=null!==(n=this.resolve(t))&&void 0!==n?n:this.urlParams[t];return null!=i?i:""})}},{key:"interpolateDeep",value:function(e){return"string"==typeof e?this.interpolateLiquidVariables(e):Array.isArray(e)?e.map(e=>this.interpolateDeep(e)):e&&"object"==typeof e?Object.entries(e).reduce((e,[t,n])=>m({},e,{[t]:this.interpolateDeep(n)}),{}):e}}])}(),Kc=function(e){function t(){var e;return o(this,t),(e=r(this,t)).namespace="urlParams",e.context=zc(),e.register(),e}return p(t,e),c(t,[{key:"resolveValue",value:function(e){return ui.debug("[URLParamsResolver]","Resolving keyPath",e),this.resolveKeyPath(e,this.context)}}])}($c),Xc=function(e){function t(){var e;return o(this,t),(e=r(this,t)).namespace="state",e.register(),e}return p(t,e),c(t,[{key:"getContextProvider",value:function(){var e=xd.providers;if(0!==e.length){var t=e.find(e=>e.flow);return t||e[e.length-1]}}},{key:"resolveValue",value:function(e){var t=this.getContextProvider();if(t){if(e.startsWith("formStates.")){var n=e.substring(11);return t.getCurrentFormId(n)}return this.resolveKeyPath(e,t.state)}}}])}($c),Yc=function(e){function t(e){var n;return o(this,t),(n=r(this,t)).namespace="Placement",n.campaign=e,n.register(),n}return p(t,e),c(t,[{key:"resolveValue",value:function(e){var t;if("label"===e){if(this.campaign&&void 0!==this.campaign.value&&null!==this.campaign.value)return this.campaign.value;var n=xd.providers;if(0!==n.length){var i=n.find(e=>e.flow);return i?i.getCurrentPlacementLabel():null===(t=n[n.length-1])||void 0===t?void 0:t.getCurrentPlacementLabel()}}}}])}($c),qc=function(e){function t(){var e;return o(this,t),(e=r(this,t,arguments)).namespace="LastLaunchContext",e}return p(t,e),c(t,[{key:"register",value:function(){T(t,"register",this)([])}},{key:"resolveValue",value:function(e){var t=Gd.shared.previous;if(t){if("placement"===e)return t.placementLabel;if("tags"===e)return t.tags;if(e.startsWith("customAttributes.")){var n=e.substring(17);return this.resolveKeyPath(n,t.customAttributes)}}}}])}($c);!function(e){e.LOGIN="login",e.LOGOUT="logout",e.ADVERTISING_ID_SET="advertising_id_set",e.ADVERTISING_ID_CLEARED="advertising_id_cleared",e.VENDOR_ID_SET="vendor_id_set",e.VENDOR_ID_CLEARED="vendor_id_cleared",e.CUSTOMER_DATA_PLATFORM_ID_SET="customer_data_platform_id_set",e.CUSTOMER_DATA_PLATFORM_ID_CLEARED="customer_data_platform_id_cleared",e.ANONYMOUS_MODE_ON="anonymous_mode_on",e.ANONYMOUS_MODE_OFF="anonymous_mode_off",e.NAMI_DEVICE_ID_SET="nami_device_id_set",e.NAMI_DEVICE_ID_CLEARED="nami_device_id_cleared"}(Hc||(Hc={}));var Jc=e=>{var t;return k(function(n){for(;;)switch(n.p=n.n){case 0:if(!ol()){n.n=1;break}return ui.info("Skipping transaction post - anonymous mode"),n.a(2);case 1:return n.p=1,n.n=2,a(js.instance.postConversion(e));case 2:n.n=4;break;case 3:n.p=3,t=n.v,ui.error("Error posting conversion",t);case 4:return n.a(2)}},null,null,[[1,3]],Promise)},Qc=function(){return c(function e(){o(this,e),this.emitter=Nu.getInstance()},[{key:"sdkInitialized",get:function(){return Vd.instance.isInitialized}}],[{key:"allPaywalls",value:function(){if(!this.instance.sdkInitialized)throw new Wr;return Hs()}},{key:"setProductDetails",value:function(e){this.instance.productDetails=e,xd.setProductDetails(e)}},{key:"registerSignInHandler",value:function(t){return this.instance.emitter.addListener(e.NamiPaywallManagerEvents.SignIn,t),()=>{this.instance.emitter.removeListener(e.NamiPaywallManagerEvents.SignIn,t)}}},{key:"registerCloseHandler",value:function(t){return this.instance.emitter.addListener(e.NamiPaywallManagerEvents.Close,t),()=>{this.instance.emitter.removeListener(e.NamiPaywallManagerEvents.Close,t)}}},{key:"registerDeeplinkActionHandler",value:function(t){return this.instance.emitter.addListener(e.NamiPaywallManagerEvents.DeeplinkAction,t),()=>{this.instance.emitter.removeListener(e.NamiPaywallManagerEvents.DeeplinkAction,t)}}},{key:"registerBuySkuHandler",value:function(t){return Cs()&&ui.debug("This handler will not be invoked because this account's plan includes built-in purchase management. Contact support@namiml.com for details."),this.instance.emitter.addListener(e.NamiPaywallManagerEvents.BuySku,t),()=>{this.instance.emitter.removeListener(e.NamiPaywallManagerEvents.BuySku,t)}}},{key:"registerRestoreHandler",value:function(t){return this.instance.emitter.addListener(e.NamiPaywallManagerEvents.Restore,t),()=>{this.instance.emitter.removeListener(e.NamiPaywallManagerEvents.Restore,t)}}},{key:"buySkuComplete",value:function(e){var t,n,i,r,o,s;return k(function(u){for(;;)switch(u.p=u.n){case 0:if(xd.setPurchaseInProgress(!1),Zc.instance.flowOpen&&(t=Zc.instance.currentFlow,n=null==t?void 0:t.currentFlowStep,t&&n&&t.executeLifecycle(n,vc)),!nh.inAnonymousMode()){u.n=1;break}return ui.debug("Skipping purchase validation - anonymous mode"),u.a(2);case 1:if(i=Fr.getSessionId(),r=Fr.getPurchaseImpression()){u.n=2;break}return ui.debug("Not sending paywall conversion call complete due to unknown impression"),u.a(2);case 2:return u.p=2,u.n=3,a(Jc({purchase_env:"production",app_env:"production",impression:r,session:i,amount:e.amount,currency:e.currency,transaction_id:e.transactionId,sku:e.skuId}));case 3:u.n=5;break;case 4:u.p=4,o=u.v,ui.error("Error posting conversion",o);case 5:if(Ds(Pe.THIRD_PARTY_TRANSACTIONS)){u.n=9;break}return u.p=6,u.n=7,a(js.instance.purchaseValidation({app_env:"production",payload:"",sku:e.skuId}));case 7:u.n=9;break;case 8:u.p=8,s=u.v,ui.error("Error validating purchase",s);case 9:return u.a(2)}},null,null,[[6,8],[2,4]],Promise)}},{key:"buySkuCancel",value:function(){Ds(Pe.THIRD_PARTY_TRANSACTIONS)?xd.setPurchase(!1):ui.warn("Call this method is not needed for this app because Nami is responsible for purchase management. Contact support@nami.ml for details.")}},{key:"setAppSuppliedVideoDetails",value:function(e,t){pu(e)?(ui.debug(`NamiPaywallManager: setAppSuppliedVideoDetails received valid url ${e}`),xd.setAppSuppliedVideoDetails({url:e,name:t})):ui.debug(`NamiPaywallManager: setAppSuppliedVideoDetails received invalid url ${e}`)}},{key:"allowUserInteraction",value:function(e){ui.debug(`NamiPaywallManager: allowUserInteraction called with ${e}`),xd.setUserInteractionEnabled(e)}}])}();Qc.instance=new Qc,Qc.emitter=Nu.getInstance();var Zc=function(){function e(){o(this,e),this.flowOpen=!1,this.lastAnimatedFlowProgress=new Map,this.navGraphCache=new WeakMap}return c(e,[{key:"hasHandoffHandler",get:function(){return!!this.handoffStepHandler}},{key:"deliverHandoff",value:function(t,n){var i=this.handoffStepHandler;if(i){var a={tag:t,completed:!1};this.pendingHandoff=a;i(t,n,n=>{if(a.completed)ui.warn(`[NamiFlowManager] complete() called more than once for handoff '${t}' — ignored`);else{var i=e.instance.pendingHandoff;i&&i!==a?ui.warn(`[NamiFlowManager] stale complete() for handoff '${t}' — a newer handoff ('${i.tag}') is pending; ignored`):(a.completed=!0,this.pendingHandoff===a&&(this.pendingHandoff=void 0),e.routeHandoffOutcome(null!=n?n:{kind:"done"}),e.resume())}})}}},{key:"resume",value:function(){e.resume()}},{key:"presentFlow",value:function(t,n,i){var a=new dh(t,n,this,i);return this.flowOpen=!0,this.currentFlow=a,js.impressionListener=t=>{var n;null===(n=e.instance.currentFlow)||void 0===n||n.bindImpression(t)},a}},{key:"finishFlow",value:function(){Vd.instance.maxLogging&&ui.debug("[NamiFlowManager] finishFlow() — closing flow"),this.flowOpen=!1,this.currentFlow=void 0,this.lastAnimatedFlowProgress.clear()}},{key:"getLastAnimatedFlowProgress",value:function(e){var t;return null!==(t=this.lastAnimatedFlowProgress.get(e))&&void 0!==t?t:0}},{key:"setLastAnimatedFlowProgress",value:function(e,t){this.currentFlow&&this.lastAnimatedFlowProgress.set(e,t)}},{key:"getCurrentFlowProgress",value:function(e){if(!this.currentFlow)return 1;if(!this.currentFlow.currentFlowStep)return 0;var t=this.currentFlow.steps.filter(e=>e.type===Zd);if(0===t.length)return 0;var n=this.currentFlow.stepcrumbs.filter(e=>e.type===Zd);if(0===n.length)return 0;var i=this.buildNavGraph(this.currentFlow),a=this.currentFlow.currentFlowStep,r=this.findBranchPoint(t,i),o=0;if(r)o=this.calculateBranchingProgress(n,t,a,r,i);else{var s=t.findIndex(e=>e.id===a.id);o=s>=0?(s+1)/t.length:0}return o=Math.max(0,Math.min(1,o)),e&&this.setLastAnimatedFlowProgress(e,o),o}},{key:"findBranchPoint",value:function(e,t){for(var n,i=h(e);!(n=i()).done;){var a=n.value;if(this.hasBranching(a,e,t))return a}return null}},{key:"calculateBranchingProgress",value:function(e,t,n,i,a){var r=e.length,o=t.findIndex(e=>e.id===i.id),s=e.findIndex(e=>e.id===i.id),u=t.findIndex(e=>e.id===n.id);if(-1===s||n.id===i.id)return(u+1)/(o+2);var l=this.countForwardScreens(n,t,a),d=r+l;return ui.debug(`Branching progress: visited=${r}, remaining=${l}, total=${d}, step=${n.id}`),r/d}},{key:"countForwardScreens",value:function(e,t,n){var i=t.findIndex(t=>t.id===e.id);if(-1===i)return 0;var a=new Set,r=0,o=(e,s)=>{if(!a.has(e)){a.add(e);var u=(n.get(e)||[]).filter(e=>{var n=t.findIndex(t=>t.id===e);return n>i});if(0!==u.length)for(var l,d=h(u);!(l=d()).done;){var c=l.value;o(c,s+1)}else r=Math.max(r,s)}};return o(e.id,0),r}},{key:"hasBranching",value:function(e,t,n){var i=t.findIndex(t=>t.id===e.id);if(-1===i)return!1;var a=(n.get(e.id)||[]).filter(e=>{var n=t.findIndex(t=>t.id===e);return n>i});return a.length>1}},{key:"buildNavGraph",value:function(e){var t=this.navGraphCache.get(e);if(t)return t;var n=new Map;e.steps.forEach(e=>{e.actions&&Object.values(e.actions).forEach(t=>{Array.isArray(t)&&t.forEach(t=>{t.action&&t.action.forEach(t=>{if("flowNav"===t.function){var i,a=null===(i=t.parameters)||void 0===i?void 0:i.step;a&&(n.has(e.id)||n.set(e.id,new Set),n.get(e.id).add(a))}})})})});var i=new Map;return n.forEach((e,t)=>{i.set(t,Array.from(e))}),this.navGraphCache.set(e,i),i}},{key:"getCurrentFlowStepAutoAdvanceDelay",value:function(){var e,t,n=null===(e=this.currentFlow)||void 0===e?void 0:e.currentFlowStep;if(!n)return null;var i=null===(t=n.actions)||void 0===t?void 0:t[lc];if(!i)return null;for(var a,r=h(i);!(a=r()).done;)for(var o,s,u=h(null!==(o=a.value.action)&&void 0!==o?o:[]);!(s=u()).done;){var l,d=s.value;if((d.function===Jd.NAVIGATE||d.function===Jd.NEXT)&&null!=(null===(l=d.parameters)||void 0===l?void 0:l.delay)){var c=d.parameters.delay,m=Number(c);if(!isNaN(m)&&m>0)return m/1e3}}return null}}],[{key:"instance",get:function(){return e._instance||(e._instance=new e),e._instance}},{key:"reset",value:function(){var t=e.instance;t.currentFlow=void 0,t.flowOpen=!1,t.lastAnimatedFlowProgress=new Map,t.navGraphCache=new WeakMap,t.pendingHandoff=void 0}},{key:"registerStepHandoff",value:function(e){this.instance.handoffStepHandler=e;var t=e;return()=>{this.instance.handoffStepHandler===t&&(this.instance.handoffStepHandler=void 0)}}},{key:"routeHandoffOutcome",value:function(t){var n=e.instance.currentFlow,i=null==n?void 0:n.currentFlowStep;switch(t.kind){case"done":return;case"permission":if(!n)return;if(n.handoffState.permissions[t.permission]=t.granted,!t.granted)return;i&&n.executeLifecycle(i,bc);var a=oc[t.permission];return void(a?n.completionSignal(a):ui.debug(`[NamiFlowManager] permission '${t.permission}' granted — no completion_result mapping yet (state/lifecycle only)`));case"purchase":return void("success"===t.result?Qc.buySkuComplete(t.details):(xd.setPurchase(!1),n&&i&&n.executeLifecycle(i,pc)));case"login":if("success"===t.result){var r,o,s=t.details;if(n)n.handoffState.login=m({},null!==(o=s.attributes)&&void 0!==o?o:{});nh.loggedInId()===s.loginId?n&&i&&n.executeLifecycle(i,cc):Promise.resolve(nh.login(s.loginId)).catch(e=>{ui.error("[NamiFlowManager] login from handoff outcome failed",e)});var u=null===(r=Fr.getDevice())||void 0===r?void 0:r.customer_data_platform_id;s.cdpId&&s.cdpId!==u&&Promise.resolve(nh.setCustomerDataPlatformId(s.cdpId)).catch(e=>{ui.error("[NamiFlowManager] CDP id write-through from handoff outcome failed",e)})}else n&&i&&n.executeLifecycle(i,hc);return}}},{key:"registerEventHandler",value:function(e){this.instance.eventHandler=e;var t=e;return()=>{this.instance.eventHandler===t&&(this.instance.eventHandler=void 0)}}},{key:"resume",value:function(){var t,n,i,a=e.instance,r=a.flowOpen,o=a.currentFlow;Vd.instance.maxLogging&&ui.debug(`[NamiFlowManager] resume() — flowOpen=${r}, hasFlow=${!!o}, currentStep=${null!==(t=null==o||null===(n=o.currentFlowStep)||void 0===n?void 0:n.id)&&void 0!==t?t:"none"}, isPaused=${null!==(i=null==o?void 0:o.isPaused)&&void 0!==i?i:"N/A"}`);var s=e.instance.pendingHandoff;if(s&&!s.completed&&(s.completed=!0,e.instance.pendingHandoff=void 0,ui.warn(`[NamiFlowManager] resume() called during handoff '${s.tag}' with a v2 handler registered — treated as complete({kind:'done'}); prefer complete(outcome)`)),r&&o&&o.currentFlowStep){if(o.activeHandoffSequence)return ui.debug(`Resuming flow at handoff sequence ${o.currentFlowStep.id}`),void o.resumeNextHandoff();ui.debug(`Resuming flow at step ${o.currentFlowStep.id}`),o.executeLifecycle(o.currentFlowStep,"__resume__")}else ui.warn("Cannot resume: no active flow or current step")}},{key:"finish",value:function(){var t=e.instance,n=t.flowOpen,i=t.currentFlow;n&&i&&i.currentFlowStep?(ui.debug(`Finishing flow programmatically at step ${i.currentFlowStep.id}`),i.dismiss()):ui.debug("Cannot finish: no active flow or current step")}},{key:"pause",value:function(){var t=e.instance,n=t.flowOpen,i=t.currentFlow;n&&i&&i.currentFlowStep?!0===i.resumeFromBookmark?i.pause():ui.warn("This flow cannot be paused"):ui.warn("Cannot pause: no active flow or current step")}},{key:"isFlowOpen",value:function(){return e.instance.flowOpen}},{key:"getLastAnimatedFlowProgress",value:function(e){return this.instance.getLastAnimatedFlowProgress(e)}},{key:"setLastAnimatedFlowProgress",value:function(e,t){this.instance.setLastAnimatedFlowProgress(e,t)}},{key:"getCurrentFlowProgress",value:function(e){return this.instance.getCurrentFlowProgress(e)}},{key:"getCurrentFlowStepAutoAdvanceDelay",value:function(){return this.instance.getCurrentFlowStepAutoAdvanceDelay()}}])}(),eh=Object.freeze({__proto__:null,NamiFlowManager:Zc}),th=()=>{var e,t;return null!==(e=null===(t=Fr.getNamiConfig())||void 0===t||null===(t=t.namiCommands)||void 0===t?void 0:t.includes("disableAsyncLoginLogout"))&&void 0!==e&&e},nh=function(){return c(function e(){o(this,e),this.emitter=Nu.getInstance(),Oc.shared.registerNamespaceResolver("UserTags",t=>{var n,i=t.replace("UserTags.","");return null!==(n=e.getCustomerAttribute(i))&&void 0!==n?n:null})},[{key:"isSDKInitialized",get:function(){return Vd.instance.isInitialized}}],[{key:"isLoggedIn",value:function(){return Ud.instance.isLoggedIn()}},{key:"loggedInId",value:function(){return this.instance.isSDKInitialized||ui.debug(Ne),Ud.instance.getExternalId()}},{key:"login",value:function(e){var t,n,i,r,o,s,u,l,d;return k(function(c){for(;;)switch(c.p=c.n){case 0:if(this.instance.isSDKInitialized){c.n=1;break}throw t=new Wr,this.invokeStateHandler(Hc.LOGIN,!1,t),t;case 1:if(!this.inAnonymousMode()){c.n=2;break}throw n=new Kr,this.invokeStateHandler(Hc.LOGIN,!1,n),n;case 2:if(th()){c.n=3;break}return Ud.instance.loginLocal(e),this.invokeStateHandler(Hc.LOGIN,!0),Zc.instance.flowOpen&&(i=Zc.instance.currentFlow,(r=null==i?void 0:i.currentFlowStep)&&(Vd.instance.maxLogging&&ui.debug(`[NamiCustomerManager] async login success — triggering __login_success__ on step ${r.id}`),i.executeLifecycle(r,cc))),Ud.instance.loginRemote(e).catch(e=>{ui.error("[NamiCustomerManager] async login API failed",e)}),Fd.instance.fetchActiveEntitlements().catch(e=>{ui.error("[NamiCustomerManager] async login entitlement refresh failed",e)}),c.a(2);case 3:return c.p=3,c.n=4,a(Ud.instance.login(e));case 4:return c.n=5,a(Fd.instance.fetchActiveEntitlements());case 5:this.invokeStateHandler(Hc.LOGIN,!0),Zc.instance.flowOpen&&(o=Zc.instance.currentFlow,(s=null==o?void 0:o.currentFlowStep)&&(Vd.instance.maxLogging&&ui.debug(`[NamiCustomerManager] login success — triggering __login_success__ on step ${s.id}`),o.executeLifecycle(s,cc))),c.n=7;break;case 6:throw c.p=6,d=c.v,this.invokeStateHandler(Hc.LOGIN,!1,d),Zc.instance.flowOpen&&(u=Zc.instance.currentFlow,(l=null==u?void 0:u.currentFlowStep)&&(Vd.instance.maxLogging&&ui.debug(`[NamiCustomerManager] login failure — triggering __login_failure__ on step ${l.id}`),u.executeLifecycle(l,hc))),d;case 7:return c.a(2)}},null,this,[[3,6]],Promise)}},{key:"logout",value:function(){var e,t,n,i,r,o,s,u,l;return k(function(d){for(;;)switch(d.p=d.n){case 0:if(this.instance.isSDKInitialized){d.n=1;break}throw e=new Wr,this.invokeStateHandler(Hc.LOGOUT,!1,e),e;case 1:if(!this.inAnonymousMode()){d.n=2;break}throw t=new Kr,this.invokeStateHandler(Hc.LOGOUT,!1,t),t;case 2:if(th()){d.n=3;break}return Ud.instance.logoutLocal(),this.invokeStateHandler(Hc.LOGOUT,!0),Zc.instance.flowOpen&&(n=Zc.instance.currentFlow,(i=null==n?void 0:n.currentFlowStep)&&(Vd.instance.maxLogging&&ui.debug(`[NamiCustomerManager] async logout success — triggering __logout_success__ on step ${i.id}`),n.executeLifecycle(i,mc))),Ud.instance.logoutRemote().catch(e=>{ui.error("[NamiCustomerManager] async logout API failed",e)}),Fd.instance.fetchActiveEntitlements().catch(e=>{ui.error("[NamiCustomerManager] async logout entitlement refresh failed",e)}),d.a(2);case 3:return d.p=3,d.n=4,a(Ud.instance.logout());case 4:return d.n=5,a(Fd.instance.fetchActiveEntitlements());case 5:this.invokeStateHandler(Hc.LOGOUT,!0),Zc.instance.flowOpen&&(r=Zc.instance.currentFlow,(o=null==r?void 0:r.currentFlowStep)&&r.executeLifecycle(o,mc)),d.n=7;break;case 6:throw d.p=6,l=d.v,this.invokeStateHandler(Hc.LOGOUT,!1,l),Zc.instance.flowOpen&&(s=Zc.instance.currentFlow,(u=null==s?void 0:s.currentFlowStep)&&s.executeLifecycle(u,fc)),l;case 7:return d.a(2)}},null,this,[[3,6]],Promise)}},{key:"setCustomerDataPlatformId",value:function(e){return k(function(t){for(;;)switch(t.n){case 0:return t.n=1,a(this.updateCustomerDataPlatformId(e));case 1:return t.a(2)}},null,this,null,Promise)}},{key:"clearCustomerDataPlatformId",value:function(){return k(function(e){for(;;)switch(e.n){case 0:return e.n=1,a(this.updateCustomerDataPlatformId(null));case 1:return e.a(2)}},null,this,null,Promise)}},{key:"registerAccountStateHandler",value:function(e){return this.instance.emitter.on("accountStateChange",e),()=>{this.instance.emitter.off("accountStateChange",e)}}},{key:"setAnonymousMode",value:function(e){var t,n,i,r,o;return k(function(s){for(;;)switch(s.n){case 0:if(t=e?Hc.ANONYMOUS_MODE_ON:Hc.ANONYMOUS_MODE_OFF,this.instance.isSDKInitialized){s.n=1;break}throw n=new Wr,this.invokeStateHandler(t,!1,n),n;case 1:if(this.anonymousModeCapability()){s.n=2;break}return ui.warn("Anonymous mode feature is not enabled for your Nami account. Contact support@nami.ml for details."),s.a(2);case 2:if(this.inAnonymousMode()!==e){s.n=3;break}return i=e?new Gr:new Vr,this.invokeStateHandler(t,!1,i),s.a(2);case 3:if(!e){s.n=4;break}Fr.setAnonymousMode(e),Fr.resetDevice(),this.refetchConfig(),this.invokeStateHandler(Hc.ANONYMOUS_MODE_ON,!0),s.n=6;break;case 4:return Fr.clearAnonymousMode(),rl(),o=null===(r=Fr.getNamiConfig())||void 0===r?void 0:r.namiCommands,s.n=5,a(Bu.instance.createOrUpdateDevice(ru(o)));case 5:Fr.clearAnonymousUUID(),this.refetchConfig(),this.invokeStateHandler(Hc.ANONYMOUS_MODE_OFF,!0);case 6:return s.a(2)}},null,this,null,Promise)}},{key:"inAnonymousMode",value:function(){return!!this.instance.isSDKInitialized&&ol()}},{key:"setCustomerAttribute",value:function(e,t){if(!this.instance.isSDKInitialized)throw new Wr;if(Fr.setCustomerAttribute(e,t),Ds(Pe.PAYWALL_PERSONALIZATION)?(xd.setCustomerAttribute({[e]:t}),ui.debug(`This customer attribute you set is now available for paywall personalization using the smart text variable: ${e}`)):ui.warn(`The customer attribute ${e} is not available for using on a paywall, because your account's plan does not include paywall personalization. Contact support@nami.ml for details.`),Zc.instance.flowOpen){var n=Zc.instance.currentFlow;if(n){var i=n.currentFlowStep;i&&n.executeLifecycle(i,yc)}}}},{key:"getCustomerAttribute",value:function(e){if(!this.instance.isSDKInitialized)throw new Wr;var t=Fr.getCustomerAttribute(e);return null!=t?Ds(Pe.PAYWALL_PERSONALIZATION)?ui.debug(`Found customer attribute. ${e} is available for paywall personalization on this device.`):ui.warn(`Found customer attribute. ${e} is not available for use on a paywall because paywall personalization is not included in your account's plan. Contact support@nami.ml for details.`):ui.debug(`No ${e} customer attribute found.`),t}},{key:"getAllCustomerAttributes",value:function(){if(!this.instance.isSDKInitialized)throw new Wr;return Fr.getAllCustomerAttributes()}},{key:"clearCustomerAttribute",value:function(e){if(!this.instance.isSDKInitialized)throw new Wr;Fr.clearCustomerAttribute(e)?(xd.removeCustomerAttribute(e),ui.warn(`This customer attribute has been cleared. ${e} is no longer available for paywall personalization on this device. A default value will be used if set in the Nami Control Center.`)):ui.warn(`No value to clear for attribute ${e}.`)}},{key:"clearAllCustomerAttributes",value:function(){if(!this.instance.isSDKInitialized)throw new Wr;Fr.getAllCustomerAttributesKeys().forEach(e=>{xd.removeCustomerAttribute(e)}),Fr.clearAllCustomerAttributes(),ui.warn("All customer attribute have been cleared. customer's smart text will no longer be personalized for this device. A default value will be used if set in the Nami Control Center.")}},{key:"journeyState",value:function(){if(!this.instance.isSDKInitialized)throw new Wr;return Fr.getCustomerJourneyState()}},{key:"deviceId",value:function(){var e,t;return this.instance.isSDKInitialized&&null!==(e=null===(t=Fr.getDevice())||void 0===t?void 0:t.id)&&void 0!==e?e:qe}},{key:"registerJourneyStateHandler",value:function(e){if(Cs("NamiCustomerManager.registerJourneyStateHandler"))return this.instance.emitter.addListener(qn,e),()=>{this.instance.emitter.removeListener(qn,e)}}},{key:"invokeStateHandler",value:function(e,t,n){this.instance.emitter.emit("accountStateChange",e,t,n)}},{key:"updateCustomerDataPlatformId",value:function(e){var t,n,i,r;return k(function(o){for(;;)switch(o.p=o.n){case 0:if(this.instance.isSDKInitialized){o.n=1;break}throw t=new Wr,this.invokeStateHandler(Hc.CUSTOMER_DATA_PLATFORM_ID_SET,!1,t),t;case 1:if(this.inAnonymousMode()){o.n=6;break}return o.p=2,o.n=3,a(Bu.instance.updateDeviceField("customer_data_platform_id",e));case 3:this.invokeStateHandler(Hc.CUSTOMER_DATA_PLATFORM_ID_SET,!0),o.n=5;break;case 4:o.p=4,r=o.v,this.invokeStateHandler(Hc.CUSTOMER_DATA_PLATFORM_ID_SET,!1,r);case 5:o.n=7;break;case 6:return ui.info("Unable to set CDP ID in anonymous mode",{deviceId:null===(n=Fr.getDevice())||void 0===n?void 0:n.id,anonymousMode:!0}),i=new Xr,this.invokeStateHandler(Hc.CUSTOMER_DATA_PLATFORM_ID_SET,!1,i),o.a(2);case 7:return o.a(2)}},null,this,[[2,4]],Promise)}},{key:"anonymousModeCapability",value:function(){if(!this.instance.isSDKInitialized)return!1;var e=Ds(Pe.ANONYMOUS_MODE_CAPABILITY),t=Ds(Pe.THIRD_PARTY_TRANSACTIONS);return e&&t}},{key:"refetchConfig",value:function(){return k(function(e){for(;;)switch(e.n){case 0:if(!this.instance.isSDKInitialized){e.n=1;break}return e.n=1,a(Promise.all([zu.instance.fetchProducts(),nl.instance.fetchPaywalls().then(e=>Wu.instance.fetchCampaignRules(e))]));case 1:return e.a(2)}},null,this,null,Promise)}}])}();nh.instance=new nh;var ih="This field is required",ah="Please enter a valid email address",rh="Please enter at least 2 characters",oh=/^[^\s@]+@[^\s@]+\.[^\s@]+$/;function sh(e,t,n){var i=("string"==typeof n?n:null==n?"":String(n)).trim();return t&&0===i.length?ih:0!==i.length?"email"!==e||oh.test(i)?"name"===e&&i.length<2?rh:void 0:ah:void 0}var uh=/^([^:]+)::(.+)$/,lh=function(){return c(function e(t={}){var n,i,a,r,s;o(this,e),this.id=null!==(n=t.id)&&void 0!==n?n:"",this.name=null!==(i=t.name)&&void 0!==i?i:"",this.steps=null!==(a=t.steps)&&void 0!==a?a:[],this.screens=null!==(r=t.screens)&&void 0!==r?r:[],this.resumeFromBookmark=Boolean(t.resume_from_bookmark),this.transition=null!==(s=t.transition)&&void 0!==s?s:"none"},[{key:"allScreensAvailable",get:function(){return this.screens.length>0&&Vs(this.screens)}}])}(),dh=function(e){function t(e,n,i,a){var s,u;o(this,t),(u=r(this,t,[null!==(s=e.flow.object)&&void 0!==s?s:{}])).stepcrumbs=[],u.branchcrumbs=[],u.activeHandoffSequence=null,u.currentScreenState=null,u.isPaused=!1,u.flowPath="",u.timerStates={},u.handoffState={permissions:{}},u.campaign=e,u.component=n,u.context=a,u.manager=i,u.branchcrumbs=[],u.stepcrumbs=[],u.registerResolvers(a);var l=u.findStepByType(Qd);return l&&u.forward(l.id),u}return p(t,e),c(t,[{key:"applyLaunchContextAttributes",value:function(e){var t,n;this.context||(this.context={customAttributes:{}},new Nc(this.context,this.campaign)),null!==(n=(t=this.context).customAttributes)&&void 0!==n||(t.customAttributes={}),Object.assign(this.context.customAttributes,e)}},{key:"registerResolvers",value:function(e){e&&new Nc(e,this.campaign),new Wc,new Kc,new Xc,new Yc(this.campaign),(new qc).register(),Oc.shared.registerNamespaceResolver("Flow",e=>{switch(e){case"Flow.stepcrumbs":return this.stepcrumbs.map(e=>e.id);case"Flow.branchcrumbs":return this.branchcrumbs;default:return}}),Oc.shared.registerNamespaceResolver("login",e=>{var t,n=e.replace(/^login\./,"");return null===(t=this.handoffState.login)||void 0===t?void 0:t[n]}),Oc.shared.registerNamespaceResolver("permissions",e=>{var t=e.replace(/^permissions\./,"");return this.handoffState.permissions[t]}),Oc.shared.registerNamespaceResolver("__first_session__",()=>jd.instance.getIsFirstSession())}},{key:"currentFlowStep",get:function(){return this.stepcrumbs.at(-1)}},{key:"nextStepAvailable",get:function(){return void 0!==this.nextFlowStep}},{key:"previousStepAvailable",get:function(){var e,t=!!this.previousFlowStep,n=!1!==(null===(e=this.previousFlowStep)||void 0===e?void 0:e.allow_back_to),i=this.stepcrumbs.slice(0,-1).some(e=>"screen"===e.type);return t&&n&&i}},{key:"previousFlowStep",get:function(){var e=this.stepcrumbs.length-2;return e>=0?this.stepcrumbs[e]:void 0}},{key:"nextFlowStep",get:function(){return this.nextStep(this.currentFlowStep)}},{key:"getStep",value:function(e){return this.steps.find(t=>t.id===e)}},{key:"findStepByType",value:function(e){return this.steps.find(t=>t.type===e)}},{key:"isStepActive",value:function(e){return!e.branch_tags||!e.branch_tags.length||e.branch_tags.some(e=>this.branchcrumbs.includes(e))}},{key:"flowLog",value:function(e,...t){Vd.instance.maxLogging&&ui.debug(`[NamiFlow] ${e}`,...t)}},{key:"finished",value:function(){var e;this.flowLog(`finished() — closing flow, isPaused=${this.isPaused}, step=${null===(e=this.currentFlowStep)||void 0===e?void 0:e.id}`),this.manager.finishFlow()}},{key:"dismiss",value:function(){this.signalNonCompletion("dismiss_page"),this.finished()}},{key:"back",value:function(){var e;if(!1!==(null===(e=this.previousFlowStep)||void 0===e?void 0:e.allow_back_to)){if(!this.stepcrumbs.slice(0,-1).some(e=>"screen"===e.type))return this.flowLog("back() — no previous screen step, dismissing flow"),void this.dismiss();this.backToPreviousScreenStep()}else ui.debug(`Not allowed to go back to ${this.previousFlowStep.id}`)}},{key:"bindImpression",value:function(e){var t=this.currentFlowStep;if(t){var n=this.completionContext;n&&n.stepId===t.id&&!n.impressionId?n.impressionId=e:this.completionContext={stepId:t.id,impressionId:e,resultSent:!1,pending:[]};var i=t.completion_step;null!=i&&i.enabled&&"page_view"===i.condition&&this.completionSignal("page_view");var a=this.completionContext.pending;this.completionContext.pending=[],a.forEach(e=>this.completionSignal(e))}}},{key:"completionSignal",value:function(e){var t=this.currentFlowStep,n=null==t?void 0:t.completion_step;if(t&&null!=n&&n.enabled&&n.condition===e){var i=this.completionContext;i&&i.stepId===t.id||(i=this.completionContext={stepId:t.id,resultSent:!1,pending:[]}),i.resultSent||(i.impressionId?(i.resultSent=!0,this.patchCompletion(i.impressionId,e)):i.pending.includes(e)||i.pending.push(e))}}},{key:"signalNonCompletion",value:function(e){var t=this.completionContext;t&&t.impressionId&&!t.resultSent&&(t.resultSent=!0,this.patchCompletion(t.impressionId,e))}},{key:"patchCompletion",value:function(e,t){var n,i;return k(function(r){for(;;)switch(r.p=r.n){case 0:return this.flowLog(`patchCompletion(${t}) — impression=${e}, step=${null===(n=this.currentFlowStep)||void 0===n?void 0:n.id}`),r.p=1,r.n=2,a(js.instance.patchImpressionCompletion(e,t,(new Date).toISOString()));case 2:r.n=4;break;case 3:r.p=3,i=r.v,ui.error(`[NamiFlow] completion PATCH failed for '${t}'`,i);case 4:return r.a(2)}},null,this,[[1,3]],Promise)}},{key:"next",value:function(){var e=this.nextFlowStep;e&&this.forward(e.id)}},{key:"backToPreviousScreenStep",value:function(){var e;if(!1!==(null===(e=this.previousFlowStep)||void 0===e?void 0:e.allow_back_to)){for(var t=this.stepcrumbs.length-2;t>=0;t--){var n=this.stepcrumbs[t];if(this.stepcrumbs.pop(),"branch"===n.type&&this.branchcrumbs.length>0&&this.branchcrumbs.pop(),"screen"===n.type&&n.screen){var i,a,r=Gs(n.screen);return r&&we().ui.flowNavigateToScreen(r,{transition:this.transition,direction:"backward"}),void(this.currentScreenState=null!==(i=null===(a=xd.currentProvider)||void 0===a?void 0:a.state)&&void 0!==i?i:null)}}ui.warn("No previous screen step found to return to")}else ui.warn(`Not allowed to go back to ${this.previousFlowStep.id}`)}},{key:"forward",value:function(e){var t=this.getStep(e);if(t)if(this.isStepActive(t))switch(this.flowLog(`forward(${e}) — type=${t.type}, name=${t.name}, isPaused=${this.isPaused}`),t.type){case Qd:case tc:return this.stepcrumbs.push(t),void this.executeLifecycle(t,uc);case ec:return void this.handleBranchStep(t);case Zd:return void this.handleScreenStep(t);case nc:return}else this.flowLog(`forward(${e}) — step not active (branch_tags=${JSON.stringify(t.branch_tags)}, branchcrumbs=${JSON.stringify(this.branchcrumbs)})`);else ui.error(`No step found with id: ${e}`)}},{key:"pause",value:function(){var e;this.isPaused?ui.info("Flow is already paused"):(this.isPaused=!0,this.pausedStepID=null===(e=this.currentFlowStep)||void 0===e?void 0:e.id,this.flowLog(`pause() — pausedStepID=${this.pausedStepID}`),ui.info("Flow paused"))}},{key:"resumeFromPause",value:function(){if(this.isPaused)if(this.isPaused=!1,this.pausedStepID){var e=this.pausedStepID;this.pausedStepID=void 0,this.flowLog(`resumeFromPause() — resuming from step ${e}`),ui.info(`Flow resumed from step ${e}`),this.forward(e)}else ui.warn("No step to resume from");else ui.info("Flow is not paused")}},{key:"executeLifecycle",value:function(e,t,n){t===vc?this.completionSignal("purchase_success"):t===cc&&this.completionSignal("login_success");var i=e.actions[t];i?(this.flowLog(`executeLifecycle(${t}) — step=${e.id}, isPaused=${this.isPaused}, ${i.length} lifecycle(s)`),this.executeFullLifecycles(i,n)):this.flowLog(`executeLifecycle(${t}) — no actions on step ${e.id}`)}},{key:"lifecycles",value:function(e){if(this.currentFlowStep){var t=this.currentFlowStep.actions[e];if(t)return t;ui.info(`No actions found for button ${e} on step ${this.currentFlowStep.id}`)}}},{key:"isFormSubmitLifecycle",value:function(e){var t=[Jd.SET_TAGS_FROM_FORM,Jd.NEXT,Jd.NAVIGATE];return e.some(e=>[e.before,e.action,e.after].some(e=>null==e?void 0:e.some(e=>t.includes(e.function))))}},{key:"triggerActions",value:function(e,t,n){var i,a,r,o=this.lifecycles(e);if(o){this.flowLog(`triggerActions(${e}) — step=${null===(i=this.currentFlowStep)||void 0===i?void 0:i.id}, isPaused=${this.isPaused}`),this.currentButton=t;var s=null!==(a=null===(r=xd.currentProvider)||void 0===r?void 0:r.state.formFieldValidators)&&void 0!==a?a:{};if(this.isFormSubmitLifecycle(o)&&Object.keys(s).length){var u,l=function(e,t){for(var n={},i=0,a=Object.entries(e);i<a.length;i++){var r,o=a[i],s=o[0],u=o[1],l=sh(u.type,u.required,t[s]);void 0!==l&&(n[s]=null!==(r=u.message)&&void 0!==r?r:l)}return n}(s,this.getFormData());if(null===(u=xd.currentProvider)||void 0===u||u.setFormFieldErrors(l),Object.keys(l).length)return void this.flowLog(`triggerActions(${e}) — HALTED by form validation: ${JSON.stringify(l)}`)}this.executeFullLifecycles(o,n)}}},{key:"executeFullLifecycles",value:function(e,t){for(var n,i=this,a=function(){var e=n.value,a=["before","action","after"];[e.before,e.action,e.after].forEach((e,n)=>null==e?void 0:e.forEach(e=>{var r=i.shouldRun(e);i.flowLog(` ${a[n]}: ${e.function}${e.id?` (${e.id})`:""} — shouldRun=${r}`),r&&i.performAction(e,t)}))},r=h(e);!(n=r()).done;)a()}},{key:"triggerBeforeActions",value:function(e,t,n){var i=this.lifecycles(e);if(i){this.currentButton=t;for(var a,r=h(i);!(a=r()).done;){var o;null===(o=a.value.before)||void 0===o||o.forEach(e=>this.shouldRun(e)&&this.performAction(e,n))}}}},{key:"triggerAfterActions",value:function(e,t,n){var i=this.lifecycles(e);if(i){this.currentButton=t;for(var a,r=h(i);!(a=r()).done;){var o;null===(o=a.value.after)||void 0===o||o.forEach(e=>this.shouldRun(e)&&this.performAction(e,n))}}}},{key:"currentStepHasHoistedPrimaryActions",value:function(e){var t=this.lifecycles(e);return!!t&&t.some(e=>{var t;return null===(t=e.action)||void 0===t?void 0:t.length})}},{key:"shouldRun",value:function(e){if(!e.conditions)return!0;var t=e.conditions.every(e=>{var t=Oc.shared.evaluate(e);if(Vd.instance.maxLogging){var n,i,a,r=null!==(n=null===(i=e.filter)||void 0===i?void 0:i.map(e=>`${e.identifier} ${e.operator} ${JSON.stringify(e.values)}`).join(", "))&&void 0!==n?n:"none";ui.debug(`[NamiFlow] condition: [${r}] op=${null!==(a=e.operator)&&void 0!==a?a:"default"} → ${t}`)}return t});return t}},{key:"performAction",value:function(e,t){var n,i;if(this.currentFlowStep){var a=(null!==(n=e.parameters)&&void 0!==n&&n.delay?+e.parameters.delay:0)||0;this.flowLog(`performAction(${e.function}) — step=${this.currentFlowStep.id}, delay=${a}, params=${JSON.stringify(null!==(i=e.parameters)&&void 0!==i?i:{})}`);var r=n=>{var i,a,r,o,s,u,l,d,c;if((null===(i=this.currentFlowStep)||void 0===i?void 0:i.id)===n)switch(e.function){case Jd.BACK:this.back();break;case Jd.NEXT:null!==(a=e.parameters)&&void 0!==a&&a.customAttributes&&this.applyLaunchContextAttributes(e.parameters.customAttributes),null!==(r=e.parameters)&&void 0!==r&&r.step?this.forward(e.parameters.step):this.next();break;case Jd.NAVIGATE:var h;if(null!==(o=e.parameters)&&void 0!==o&&o.customAttributes&&this.applyLaunchContextAttributes(e.parameters.customAttributes),null!==(s=e.parameters)&&void 0!==s&&s.step)(null===(h=this.previousFlowStep)||void 0===h?void 0:h.id)===e.parameters.step?this.back():this.forward(e.parameters.step);else this.next();break;case Jd.FINISHED:this.finished();break;case Jd.DISMISS:this.dismiss();break;case Jd.EXIT:this.signalNonCompletion("skip_page");var m=this.steps.find(e=>e.type===tc);m&&this.forward(m.id);break;case Jd.PAUSE:this.pause();break;case Jd.RESUME:this.resumeFromPause();break;case Jd.HANDOFF:var f,v,p,g,y,b,w=null===(f=e.parameters)||void 0===f?void 0:f.handoffTag;if(!w)break;if(null!==(v=e.parameters)&&void 0!==v&&v.handoffFormId&&this.completionSignal("form_submitted"),w.startsWith("__")){var k;w===ic&&null!==(k=e.parameters)&&void 0!==k&&k.handoffFormId?this.flowHandoffFormSequence():(ui.warn(`Ignoring reserved handoff tag '${w}' — resuming flow`),this.manager.resume());break}if(!this.manager.hasHandoffHandler){ui.debug("No handoffStepHandler found",e);break}if(w===ac.UserData&&null!==(p=e.parameters)&&void 0!==p&&p.handoffFormId){this.manager.deliverHandoff(w,this.buildUserDataEnvelope(e.parameters.handoffFormId));break}null!==(g=e.parameters)&&void 0!==g&&g.handoffData?b=e.parameters.handoffData:t?b=t:null!==(y=e.parameters)&&void 0!==y&&y.handoffFormId&&(b=this.getFormData()),ui.debug(`Invoking handoff handler with ${w}${b?` ${JSON.stringify(b)}`:" and no data"}`),this.manager.deliverHandoff(w,b);break;case Jd.LOG:var S;if(null!==(u=e.parameters)&&void 0!==u&&u.eventName)ui.info(`logEvent → ${e.parameters.eventName}`);else ui.warn(`Missing 'eventName' in logEvent action ${null!==(S=e.id)&&void 0!==S?S:"unknown"}`);break;case Jd.TRACK:var E;if(null!==(l=e.parameters)&&void 0!==l&&l.eventName)ui.info(`trackEvent → ${e.parameters.eventName}`);else ui.warn(`Missing 'eventName' in logEvent action ${null!==(E=e.id)&&void 0!==E?E:"unknown"}`);break;case Jd.SET_VIDEO:null!==(d=e.parameters)&&void 0!==d&&d.name&&e.parameters.url?xd.setAppSuppliedVideoDetails({name:e.parameters.name,url:e.parameters.url}):ui.warn("Missing name, url for setting video details");break;case Jd.BLOCK_BACK:var P,T=null===(P=e.parameters)||void 0===P?void 0:P.step,_=T?this.getStep(T):void 0;_?_.allow_back_to=!1:this.currentFlowStep?this.currentFlowStep.allow_back_to=!1:ui.warn("Missing step for blocking back");break;case Jd.FLOW_EVENT:var M,A=new Vc(this.manager),D=Object.fromEntries(Object.entries(null!==(M=e.parameters)&&void 0!==M?M:{}).map(([e,t])=>[e,A.interpolateDeep(t)]));this.manager.eventHandler?this.manager.eventHandler(D):ui.warn("Missing event handler",D);break;case Jd.FLOW_ENABLED:xd.setUserInteractionEnabled(!0);break;case Jd.FLOW_DISABLED:xd.setUserInteractionEnabled(!1);break;case Jd.SET_TAGS:e.parameters&&(xd.setUserTags(e.parameters),Object.entries(e.parameters).forEach(([e,t])=>{nh.setCustomerAttribute(e,t)}));break;case Jd.SET_TAGS_FROM_FORM:var x,C=null===(x=e.parameters)||void 0===x?void 0:x.include,I=Array.isArray(C)?new Set(C):void 0,L=this.getFormData(),R={};Object.entries(L).forEach(([e,t])=>{if(!I||I.has(e)){var n=Uc(t);void 0!==n&&(R[e]=n,nh.setCustomerAttribute(e,n))}}),Object.keys(R).length&&xd.setUserTags(R);break;case Jd.SET_LAUNCH_CONTEXT:var F=e.parameters;null!=F&&F.customAttributes?this.applyLaunchContextAttributes(F.customAttributes):void 0!==(null==F?void 0:F.key)&&void 0!==(null==F?void 0:F.value)&&this.applyLaunchContextAttributes({[F.key]:F.value});break;case Jd.SET_FLOW_PATH:var O,$=null===(O=e.parameters)||void 0===O?void 0:O.flowPath;"string"==typeof $&&(this.flowPath=$);break;default:ui.warn(`Missing action handler for ${e.function}`,e)}else this.flowLog(`performAction(${e.function}) — SKIPPED stale step ${n}, current=${null===(c=this.currentFlowStep)||void 0===c?void 0:c.id}`)};a?setTimeout(r.bind(this,this.currentFlowStep.id),a):r(this.currentFlowStep.id)}else ui.warn("No current flow step")}},{key:"nextStep",value:function(e){if(e){var t=this.steps.findIndex(t=>t.id===e.id);if(-1!==t){for(var n,i=h(this.steps.slice(t+1));!(n=i()).done;){var a=n.value;if(this.isStepActive(a))return a}ui.debug(`No active next step found after ${e.id}`)}else ui.error(`Could not find next step for step ${e.id}`)}else ui.error("Next step not found")}},{key:"handleScreenStep",value:function(e){var t,n=Gs(null!==(t=e.screen)&&void 0!==t?t:"");e.screen&&n&&this.campaign?(this.stepcrumbs.push(e),we().ui.flowNavigateToScreen(n,{transition:this.transition,direction:"forward"})):ui.error("No paywall or campaign found for next step")}},{key:"handleBranchStep",value:function(e){this.stepcrumbs.push(e);for(var t=0,n=Object.entries(e.actions);t<n.length;t++){var i=n[t],a=i[0],r=i[1];if(r)for(var o,s=h(r);!(o=s()).done;){var u=o.value;if(u.action)for(var l,d=h(u.action);!(l=d()).done;){var c,m,f=l.value;if(this.shouldRun(f))return this.branchcrumbs.push(a),null===(c=u.before)||void 0===c||c.forEach(e=>{this.performAction(e)}),u.action.forEach(e=>{this.shouldRun(e)&&this.performAction(e)}),void(null===(m=u.after)||void 0===m||m.forEach(e=>{this.performAction(e)}))}else ui.warn(`No actions defined for branch tag ${a}`)}}ui.warn(`No matching branch condition matched for step ${e.id}`)}},{key:"getFormData",value:function(){var e,t;return m({},null!==(e=null===(t=xd.currentProvider)||void 0===t||null===(t=t.state)||void 0===t?void 0:t.formStates)&&void 0!==e?e:{})}},{key:"buildUserDataEnvelope",value:function(e){var t,n;return{form_id:e,step_id:null!==(t=null===(n=this.currentFlowStep)||void 0===n?void 0:n.id)&&void 0!==t?t:"",collected_at:(new Date).toISOString(),fields:this.getFormData()}}},{key:"flowHandoffFormSequence",value:function(){var e,t=null===(e=this.currentScreenState)||void 0===e?void 0:e.formStates;if(t){var n=Object.keys(t);if(0!==n.length){if(n.some(e=>uh.test(e))){var i=this.buildHandoffGroups(t);return 0===i.length?(ui.info("No handoff groups after grouping"),void this.manager.resume()):(this.activeHandoffSequence={groups:i},void this.resumeNextHandoff())}var a=n.sort().filter(e=>!0===t[e]);if(0===a.length)return ui.info("No eligible handoff keys after filtering"),void this.manager.resume();this.activeHandoffSequence={formStates:m({},t),remainingKeys:[...a]},this.resumeNextHandoff()}else ui.warn("formStates is empty, no handoffs to perform")}else ui.warn("No formStates available for handoff sequence")}},{key:"buildHandoffGroups",value:function(e){for(var t=new Map,n=0,i=Object.keys(e);n<i.length;n++){var a=i[n],r=a.match(uh);if(r){var o=r[1],s=r[2];o.startsWith("__")?ui.warn(`Ignoring reserved handoff group tag '${o}'`):(t.has(o)||t.set(o,{}),t.get(o)[s]=e[a])}}return Array.from(t,([e,t])=>({tag:e,data:t})).filter(e=>Object.values(e.data).some(e=>!0===e)).sort((e,t)=>e.tag.localeCompare(t.tag))}},{key:"resumeNextHandoff",value:function(){var e=this.activeHandoffSequence;if(!e)return ui.warn("No active handoff sequence to resume"),void this.manager.resume();if("groups"in e){if(0===e.groups.length)return ui.info("All handoffs in the sequence are complete"),this.activeHandoffSequence=null,void this.manager.resume();var t=e.groups.shift();return function(e){return Object.values(ac).includes(e)}(t.tag)||ui.warn(`handoff group tag '${t.tag}' is outside the NamiHandoffTag vocabulary — passing through`),this.activeHandoffSequence=e,ui.debug(`Starting grouped handoff for '${t.tag}' → ${JSON.stringify(t.data)}`),void this.manager.deliverHandoff(t.tag,t.data)}if(0===e.remainingKeys.length)return ui.info("All handoffs in the sequence are complete"),this.activeHandoffSequence=null,void this.manager.resume();var n=e.remainingKeys.shift(),i=e.formStates[n];ui.debug(`Starting handoff for ${n} → ${String(i)}`),this.activeHandoffSequence=e,this.manager.deliverHandoff(`${n}`,void 0)}}])}(lh),ch=function(){return c(function e(){o(this,e),this.emitter=Nu.getInstance()},[{key:"sdkInitialized",get:function(){return Vd.instance.isInitialized}},{key:"campaignTypeAndLabel",value:function(t,n){var i,a="";return t&&!n&&pu(t)?(a=t,i=e.NamiCampaignRuleType.URL):t?(a=t,i=e.NamiCampaignRuleType.LABEL):n&&(a=n,i=e.NamiCampaignRuleType.URL),{type:i,value:a}}}],[{key:"allCampaigns",value:function(){if(!this.instance.sdkInitialized)throw new Wr;return bu()}},{key:"isCampaignAvailable",value:function(e){if(!this.instance.sdkInitialized)throw new Wr;var t=this.instance.campaignTypeAndLabel(e),n=t.type,i=t.value,a=Pu(i,n),r=a.campaign,o=a.paywall;return null!=r&&r.flow?new lh(r.flow.object).allScreensAvailable:Boolean(r&&o)}},{key:"isFlow",value:function(e,t){if(!this.instance.sdkInitialized)throw new Wr;var n=this.instance.campaignTypeAndLabel(e,t),i=n.type,a=n.value;return Bs(Pu(a,i).campaign)}},{key:"refresh",value:function(){return k(function(e){for(;;)switch(e.n){case 0:if(this.instance.sdkInitialized){e.n=1;break}throw new Wr;case 1:return xs(),e.n=2,a(jd.instance.fetchCampaignsAndPaywalls());case 2:return e.a(2,bu())}},null,this,null,Promise)}},{key:"registerAvailableCampaignsHandler",value:function(e){return this.instance.emitter.addListener(Hn,e),()=>{this.instance.emitter.removeListener(Hn,e)}}},{key:"launch",value:function(t,n,i,a,r){var o,s,u,l,d,c,h,f,v,p;a=null!=a?a:()=>{},i=null!=i?i:{customAttributes:{}};var g=this.instance.campaignTypeAndLabel(t,n),b=g.type,w=g.value;if(!this.instance.sdkInitialized)throw a(!1,e.LaunchCampaignError.SDK_NOT_INITIALIZED),new Wr;var k,S=Wd.firstLaunchLookup(w,()=>Pu(w,b)),E=S.paywall,P=S.campaign,T=!P||!E&&!P.flow;T&&(k=t||n?t?e.LaunchCampaignError.LABELED_CAMPAIGN_NOT_FOUND:n?e.LaunchCampaignError.URL_CAMPAIGN_NOT_FOUND:e.LaunchCampaignError.CAMPAIGN_DATA_NOT_FOUND:e.LaunchCampaignError.DEFAULT_CAMPAIGN_NOT_FOUND,a(!1,k),E={});var _={campaignId:null!==(o=null==P?void 0:P.rule)&&void 0!==o?o:"",campaignName:null!==(s=null==P?void 0:P.name)&&void 0!==s?s:"",campaignType:null!==(u=null==P?void 0:P.type)&&void 0!==u?u:"",campaignLabel:t?w:"",campaignUrl:n?w:"",paywallId:null!=P&&P.flow?void 0:(null===(l=E)||void 0===l?void 0:l.id)||"",paywallName:null!=P&&P.flow?void 0:(null===(d=E)||void 0===d?void 0:d.name)||"",segmentId:null==P?void 0:P.segment,externalSegmentId:null!==(c=null==P?void 0:P.external_segment)&&void 0!==c?c:null,action:e.NamiPaywallAction.UNKNOWN},M=Fr.getPurchaseChannel();M&&(_=m({},_,{purchaseChannel:M}));var A,D,x,C,I,L,R,F,O=null===(h=i)||void 0===h?void 0:h.productGroups,$=null===(f=E)||void 0===f||null===(f=f.sku_menus)||void 0===f?void 0:f.map(e=>e.ref);if((x=null===(A=Fr.getNamiConfig())||void 0===A?void 0:A.namiCommands,null!==(D=null==x?void 0:x.includes(fn))&&void 0!==D&&D&&null!=O&&O.length&&null!=$)&&0==(null==$?void 0:$.filter(e=>null==O?void 0:O.some(t=>t===e))).length)throw a(!1,e.LaunchCampaignError.PRODUCT_GROUPS_NOT_FOUND),new Ur;if(null!=P&&P.flow&&!Vs(null!==(v=null===(p=P.flow.object)||void 0===p?void 0:p.screens)&&void 0!==v?v:[]))throw a(!1,e.LaunchCampaignError.FLOW_SCREEN_DATA_UNAVILABLE),new Hr;T||Gd.shared.record({placementLabel:null!==(C=null!==(I=null==P?void 0:P.value)&&void 0!==I?I:w)&&void 0!==C?C:"",tags:null!==(L=null==P?void 0:P.placement_tags)&&void 0!==L?L:[],customAttributes:null!==(R=null===(F=i)||void 0===F?void 0:F.customAttributes)&&void 0!==R?R:{}});var N=we().ui.createPaywall(b,w,i),W=su();return Fr.setLaunchId(W),r&&this.instance.emitter.addListener(Vn,t=>{var n=t.action,i=y(t,ge);r(m({},_,i,{action:null!=n?n:e.NamiPaywallAction.UNKNOWN}))}),setTimeout(()=>a(!0),0),N}},{key:"getProductGroups",value:function(e,t){var n,i,a=this.instance.campaignTypeAndLabel(e,t),r=a.type,o=a.value;return null!==(n=null===(i=Pu(o,r).paywall)||void 0===i||null===(i=i.sku_menus)||void 0===i?void 0:i.map(e=>e.ref))&&void 0!==n?n:[]}},{key:"getAllProducts",value:function(e,t){var n,i,a=this.instance.campaignTypeAndLabel(e,t),r=a.type,o=a.value;return null!==(n=null===(i=Pu(o,r).paywall)||void 0===i||null===(i=i.sku_menus)||void 0===i?void 0:i.flatMap(e=>{var t,n;return null!==(t=null===(n=e.products)||void 0===n?void 0:n.map(e=>e.sku_ref_id))&&void 0!==t?t:[]}))&&void 0!==n?n:[]}},{key:"getCurrentProducts",value:function(e,t){var n,i,a=this.instance.campaignTypeAndLabel(e,t),r=a.type,o=a.value,s=Pu(o,r),u=xd.currentProvider,l=null==u?void 0:u.getCurrentGroupId();return l&&null!==(n=null===(i=s.paywall)||void 0===i||null===(i=i.sku_menus)||void 0===i?void 0:i.filter(e=>e.id===l).flatMap(e=>{var t,n;return null!==(t=null===(n=e.products)||void 0===n?void 0:n.map(e=>e.sku_ref_id))&&void 0!==t?t:[]}))&&void 0!==n?n:[]}}])}();ch.instance=new ch;var hh=ch,mh=nh,fh=function(){return c(function e(){o(this,e),this.emitter=Nu.getInstance()},[{key:"sdkInitialized",get:function(){return Vd.instance.isInitialized}}],[{key:"active",value:function(){return Cs(),Id()}},{key:"isEntitlementActive",value:function(e){return!!Cs("NamiEntitlementManager.isEntitlementActive")&&this.active().some(t=>t.referenceId==e)}},{key:"refresh",value:function(){return k(function(e){for(;;)switch(e.n){case 0:if(this.instance.sdkInitialized){e.n=1;break}throw new Wr;case 1:if(Cs("NamiEntitlementManager.refresh")){e.n=2;break}return e.a(2,[]);case 2:return e.n=3,a(Fd.instance.fetchActiveEntitlements());case 3:return e.a(2,Id())}},null,this,null,Promise)}},{key:"registerActiveEntitlementsHandler",value:function(e){if(Cs("NamiEntitlementManager.registerActiveEntitlementsHandler"))return this.instance.emitter.addListener(Xn,e),()=>{this.instance.emitter.removeListener(Xn,e)}}},{key:"clearProvisionalEntitlementGrants",value:function(){var e=Id();e=e.filter(e=>e.expires&&e.expires>(new Date).valueOf()),Fr.setNamiEntitlements(_t,e),this.instance.emitter.emit(Xn)}}])}();fh.instance=new fh;var vh,ph,gh=fh,yh=Zc,bh=Qc,wh=ul,kh={upperLeft:"border-top-left-radius",upperRight:"border-top-right-radius",lowerLeft:"border-bottom-left-radius",lowerRight:"border-bottom-right-radius"},Sh={left:"border-left-style",right:"border-right-style",top:"border-top-style",bottom:"border-bottom-style"},Eh="wave",Ph="pulse",Th="none";function _h(e){var t,n=null!==(t=e.match(/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/))&&void 0!==t?t:[],i=n[0],a=n[1],r=n[2],o=n[3],s=n[4],u=n[5];return{semver:i,major:Number.parseInt(a)||3,minor:Number.parseInt(r)||0,patch:Number.parseInt(o)||0,prerelease:s,buildmetadata:u}}function Mh(e,t){e&&(function(e,t){return e.major!==t.major?e.major>t.major?1:-1:e.minor!==t.minor?e.minor>t.minor?1:-1:e.patch!==t.patch?e.patch>t.patch?1:-1:0}(_h(Ae),e)>=0||ui.warn(`Component ${t} requires SDK version ${e.semver} or higher, but current SDK version is ${Ae}`))}function Ah(e){return!e||"object"==typeof e&&0==Object.keys(e).length}!function(e){e.DEFAULT="default",e.LABEL="label",e.URL="url"}(vh||(vh={})),function(e){e.DEEPLINK="deeplink",e.IN_APP="in_app"}(ph||(ph={}));var Dh=hh,xh=mh,Ch=bh,Ih=gh,Lh=yh,Rh=wh,Fh=Ud,Oh=Object.freeze({__proto__:null,NamiCampaignManager:Dh,NamiCustomerManager:xh,NamiEntitlementManager:Ih,NamiFlowManager:Lh,NamiPaywallManager:Ch,NamiProfileManager:Fh,NamiPurchaseManager:Rh}),$h=function(){return c(function e(){o(this,e)},[{key:"getItem",value:function(e){try{return localStorage.getItem(e)}catch(e){return null}}},{key:"setItem",value:function(e,t){try{localStorage.setItem(e,t)}catch(e){}}},{key:"removeItem",value:function(e){try{localStorage.removeItem(e)}catch(e){}}},{key:"clear",value:function(){try{localStorage.clear()}catch(e){}}},{key:"getAllKeys",value:function(){try{return Object.keys(localStorage)}catch(e){return[]}}}])}();function Nh(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Wh,jh={exports:{}};var Bh=(Wh||(Wh=1,function(e){e.exports=function(e){var t={};function n(i){if(t[i])return t[i].exports;var a=t[i]={i,l:!1,exports:{}};return e[i].call(a.exports,a,a.exports,n),a.l=!0,a.exports}return n.m=e,n.c=t,n.d=function(e,t,i){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:i})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)n.d(i,a,function(t){return e[t]}.bind(null,a));return i},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=90)}({17:function(e,t,n){t.__esModule=!0,t.default=void 0;var i=n(18),a=function(){function e(){}return e.getFirstMatch=function(e,t){var n=t.match(e);return n&&n.length>0&&n[1]||""},e.getSecondMatch=function(e,t){var n=t.match(e);return n&&n.length>1&&n[2]||""},e.matchAndReturnConst=function(e,t,n){if(e.test(t))return n},e.getWindowsVersionName=function(e){switch(e){case"NT":return"NT";case"XP":case"NT 5.1":return"XP";case"NT 5.0":return"2000";case"NT 5.2":return"2003";case"NT 6.0":return"Vista";case"NT 6.1":return"7";case"NT 6.2":return"8";case"NT 6.3":return"8.1";case"NT 10.0":return"10";default:return}},e.getMacOSVersionName=function(e){var t=e.split(".").splice(0,2).map(function(e){return parseInt(e,10)||0});t.push(0);var n=t[0],i=t[1];if(10===n)switch(i){case 5:return"Leopard";case 6:return"Snow Leopard";case 7:return"Lion";case 8:return"Mountain Lion";case 9:return"Mavericks";case 10:return"Yosemite";case 11:return"El Capitan";case 12:return"Sierra";case 13:return"High Sierra";case 14:return"Mojave";case 15:return"Catalina";default:return}switch(n){case 11:return"Big Sur";case 12:return"Monterey";case 13:return"Ventura";case 14:return"Sonoma";case 15:return"Sequoia";default:return}},e.getAndroidVersionName=function(e){var t=e.split(".").splice(0,2).map(function(e){return parseInt(e,10)||0});if(t.push(0),!(1===t[0]&&t[1]<5))return 1===t[0]&&t[1]<6?"Cupcake":1===t[0]&&t[1]>=6?"Donut":2===t[0]&&t[1]<2?"Eclair":2===t[0]&&2===t[1]?"Froyo":2===t[0]&&t[1]>2?"Gingerbread":3===t[0]?"Honeycomb":4===t[0]&&t[1]<1?"Ice Cream Sandwich":4===t[0]&&t[1]<4?"Jelly Bean":4===t[0]&&t[1]>=4?"KitKat":5===t[0]?"Lollipop":6===t[0]?"Marshmallow":7===t[0]?"Nougat":8===t[0]?"Oreo":9===t[0]?"Pie":void 0},e.getVersionPrecision=function(e){return e.split(".").length},e.compareVersions=function(t,n,i){void 0===i&&(i=!1);var a=e.getVersionPrecision(t),r=e.getVersionPrecision(n),o=Math.max(a,r),s=0,u=e.map([t,n],function(t){var n=o-e.getVersionPrecision(t),i=t+new Array(n+1).join(".0");return e.map(i.split("."),function(e){return new Array(20-e.length).join("0")+e}).reverse()});for(i&&(s=o-Math.min(a,r)),o-=1;o>=s;){if(u[0][o]>u[1][o])return 1;if(u[0][o]===u[1][o]){if(o===s)return 0;o-=1}else if(u[0][o]<u[1][o])return-1}},e.map=function(e,t){var n,i=[];if(Array.prototype.map)return Array.prototype.map.call(e,t);for(n=0;n<e.length;n+=1)i.push(t(e[n]));return i},e.find=function(e,t){var n,i;if(Array.prototype.find)return Array.prototype.find.call(e,t);for(n=0,i=e.length;n<i;n+=1){var a=e[n];if(t(a,n))return a}},e.assign=function(e){for(var t,n,i=e,a=arguments.length,r=new Array(a>1?a-1:0),o=1;o<a;o++)r[o-1]=arguments[o];if(Object.assign)return Object.assign.apply(Object,[e].concat(r));var s=function(){var e=r[t];"object"==typeof e&&null!==e&&Object.keys(e).forEach(function(t){i[t]=e[t]})};for(t=0,n=r.length;t<n;t+=1)s();return e},e.getBrowserAlias=function(e){return i.BROWSER_ALIASES_MAP[e]},e.getBrowserTypeByAlias=function(e){return i.BROWSER_MAP[e]||""},e}();t.default=a,e.exports=t.default},18:function(e,t,n){t.__esModule=!0,t.ENGINE_MAP=t.OS_MAP=t.PLATFORMS_MAP=t.BROWSER_MAP=t.BROWSER_ALIASES_MAP=void 0,t.BROWSER_ALIASES_MAP={AmazonBot:"amazonbot","Amazon Silk":"amazon_silk","Android Browser":"android",BaiduSpider:"baiduspider",Bada:"bada",BingCrawler:"bingcrawler",Brave:"brave",BlackBerry:"blackberry","ChatGPT-User":"chatgpt_user",Chrome:"chrome",ClaudeBot:"claudebot",Chromium:"chromium",Diffbot:"diffbot",DuckDuckBot:"duckduckbot",DuckDuckGo:"duckduckgo",Electron:"electron",Epiphany:"epiphany",FacebookExternalHit:"facebookexternalhit",Firefox:"firefox",Focus:"focus",Generic:"generic","Google Search":"google_search",Googlebot:"googlebot",GPTBot:"gptbot","Internet Explorer":"ie",InternetArchiveCrawler:"internetarchivecrawler","K-Meleon":"k_meleon",LibreWolf:"librewolf",Linespider:"linespider",Maxthon:"maxthon","Meta-ExternalAds":"meta_externalads","Meta-ExternalAgent":"meta_externalagent","Meta-ExternalFetcher":"meta_externalfetcher","Meta-WebIndexer":"meta_webindexer","Microsoft Edge":"edge","MZ Browser":"mz","NAVER Whale Browser":"naver","OAI-SearchBot":"oai_searchbot",Omgilibot:"omgilibot",Opera:"opera","Opera Coast":"opera_coast","Pale Moon":"pale_moon",PerplexityBot:"perplexitybot","Perplexity-User":"perplexity_user",PhantomJS:"phantomjs",PingdomBot:"pingdombot",Puffin:"puffin",QQ:"qq",QQLite:"qqlite",QupZilla:"qupzilla",Roku:"roku",Safari:"safari",Sailfish:"sailfish","Samsung Internet for Android":"samsung_internet",SlackBot:"slackbot",SeaMonkey:"seamonkey",Sleipnir:"sleipnir","Sogou Browser":"sogou",Swing:"swing",Tizen:"tizen","UC Browser":"uc",Vivaldi:"vivaldi","WebOS Browser":"webos",WeChat:"wechat",YahooSlurp:"yahooslurp","Yandex Browser":"yandex",YandexBot:"yandexbot",YouBot:"youbot"},t.BROWSER_MAP={amazonbot:"AmazonBot",amazon_silk:"Amazon Silk",android:"Android Browser",baiduspider:"BaiduSpider",bada:"Bada",bingcrawler:"BingCrawler",blackberry:"BlackBerry",brave:"Brave",chatgpt_user:"ChatGPT-User",chrome:"Chrome",claudebot:"ClaudeBot",chromium:"Chromium",diffbot:"Diffbot",duckduckbot:"DuckDuckBot",duckduckgo:"DuckDuckGo",edge:"Microsoft Edge",electron:"Electron",epiphany:"Epiphany",facebookexternalhit:"FacebookExternalHit",firefox:"Firefox",focus:"Focus",generic:"Generic",google_search:"Google Search",googlebot:"Googlebot",gptbot:"GPTBot",ie:"Internet Explorer",internetarchivecrawler:"InternetArchiveCrawler",k_meleon:"K-Meleon",librewolf:"LibreWolf",linespider:"Linespider",maxthon:"Maxthon",meta_externalads:"Meta-ExternalAds",meta_externalagent:"Meta-ExternalAgent",meta_externalfetcher:"Meta-ExternalFetcher",meta_webindexer:"Meta-WebIndexer",mz:"MZ Browser",naver:"NAVER Whale Browser",oai_searchbot:"OAI-SearchBot",omgilibot:"Omgilibot",opera:"Opera",opera_coast:"Opera Coast",pale_moon:"Pale Moon",perplexitybot:"PerplexityBot",perplexity_user:"Perplexity-User",phantomjs:"PhantomJS",pingdombot:"PingdomBot",puffin:"Puffin",qq:"QQ Browser",qqlite:"QQ Browser Lite",qupzilla:"QupZilla",roku:"Roku",safari:"Safari",sailfish:"Sailfish",samsung_internet:"Samsung Internet for Android",seamonkey:"SeaMonkey",slackbot:"SlackBot",sleipnir:"Sleipnir",sogou:"Sogou Browser",swing:"Swing",tizen:"Tizen",uc:"UC Browser",vivaldi:"Vivaldi",webos:"WebOS Browser",wechat:"WeChat",yahooslurp:"YahooSlurp",yandex:"Yandex Browser",yandexbot:"YandexBot",youbot:"YouBot"},t.PLATFORMS_MAP={bot:"bot",desktop:"desktop",mobile:"mobile",tablet:"tablet",tv:"tv"},t.OS_MAP={Android:"Android",Bada:"Bada",BlackBerry:"BlackBerry",ChromeOS:"Chrome OS",HarmonyOS:"HarmonyOS",iOS:"iOS",Linux:"Linux",MacOS:"macOS",PlayStation4:"PlayStation 4",Roku:"Roku",Tizen:"Tizen",WebOS:"WebOS",Windows:"Windows",WindowsPhone:"Windows Phone"},t.ENGINE_MAP={Blink:"Blink",EdgeHTML:"EdgeHTML",Gecko:"Gecko",Presto:"Presto",Trident:"Trident",WebKit:"WebKit"}},90:function(e,t,n){t.__esModule=!0,t.default=void 0;var i,a=(i=n(91))&&i.__esModule?i:{default:i},r=n(18);function o(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var s=function(){function e(){}var t,n,i;return e.getParser=function(e,t,n){if(void 0===t&&(t=!1),void 0===n&&(n=null),"string"!=typeof e)throw new Error("UserAgent should be a string");return new a.default(e,t,n)},e.parse=function(e,t){return void 0===t&&(t=null),new a.default(e,t).getResult()},t=e,i=[{key:"BROWSER_MAP",get:function(){return r.BROWSER_MAP}},{key:"ENGINE_MAP",get:function(){return r.ENGINE_MAP}},{key:"OS_MAP",get:function(){return r.OS_MAP}},{key:"PLATFORMS_MAP",get:function(){return r.PLATFORMS_MAP}}],(n=null)&&o(t.prototype,n),i&&o(t,i),e}();t.default=s,e.exports=t.default},91:function(e,t,n){t.__esModule=!0,t.default=void 0;var i=u(n(92)),a=u(n(93)),r=u(n(94)),o=u(n(95)),s=u(n(17));function u(e){return e&&e.__esModule?e:{default:e}}var l=function(){function e(e,t,n){if(void 0===t&&(t=!1),void 0===n&&(n=null),null==e||""===e)throw new Error("UserAgent parameter can't be empty");this._ua=e;var i=!1;"boolean"==typeof t?(i=t,this._hints=n):this._hints=null!=t&&"object"==typeof t?t:null,this.parsedResult={},!0!==i&&this.parse()}var t=e.prototype;return t.getHints=function(){return this._hints},t.hasBrand=function(e){if(!this._hints||!Array.isArray(this._hints.brands))return!1;var t=e.toLowerCase();return this._hints.brands.some(function(e){return e.brand&&e.brand.toLowerCase()===t})},t.getBrandVersion=function(e){if(this._hints&&Array.isArray(this._hints.brands)){var t=e.toLowerCase(),n=this._hints.brands.find(function(e){return e.brand&&e.brand.toLowerCase()===t});return n?n.version:void 0}},t.getUA=function(){return this._ua},t.test=function(e){return e.test(this._ua)},t.parseBrowser=function(){var e=this;this.parsedResult.browser={};var t=s.default.find(i.default,function(t){if("function"==typeof t.test)return t.test(e);if(Array.isArray(t.test))return t.test.some(function(t){return e.test(t)});throw new Error("Browser's test function is not valid")});return t&&(this.parsedResult.browser=t.describe(this.getUA(),this)),this.parsedResult.browser},t.getBrowser=function(){return this.parsedResult.browser?this.parsedResult.browser:this.parseBrowser()},t.getBrowserName=function(e){return e?String(this.getBrowser().name).toLowerCase()||"":this.getBrowser().name||""},t.getBrowserVersion=function(){return this.getBrowser().version},t.getOS=function(){return this.parsedResult.os?this.parsedResult.os:this.parseOS()},t.parseOS=function(){var e=this;this.parsedResult.os={};var t=s.default.find(a.default,function(t){if("function"==typeof t.test)return t.test(e);if(Array.isArray(t.test))return t.test.some(function(t){return e.test(t)});throw new Error("Browser's test function is not valid")});return t&&(this.parsedResult.os=t.describe(this.getUA())),this.parsedResult.os},t.getOSName=function(e){var t=this.getOS().name;return e?String(t).toLowerCase()||"":t||""},t.getOSVersion=function(){return this.getOS().version},t.getPlatform=function(){return this.parsedResult.platform?this.parsedResult.platform:this.parsePlatform()},t.getPlatformType=function(e){void 0===e&&(e=!1);var t=this.getPlatform().type;return e?String(t).toLowerCase()||"":t||""},t.parsePlatform=function(){var e=this;this.parsedResult.platform={};var t=s.default.find(r.default,function(t){if("function"==typeof t.test)return t.test(e);if(Array.isArray(t.test))return t.test.some(function(t){return e.test(t)});throw new Error("Browser's test function is not valid")});return t&&(this.parsedResult.platform=t.describe(this.getUA())),this.parsedResult.platform},t.getEngine=function(){return this.parsedResult.engine?this.parsedResult.engine:this.parseEngine()},t.getEngineName=function(e){return e?String(this.getEngine().name).toLowerCase()||"":this.getEngine().name||""},t.parseEngine=function(){var e=this;this.parsedResult.engine={};var t=s.default.find(o.default,function(t){if("function"==typeof t.test)return t.test(e);if(Array.isArray(t.test))return t.test.some(function(t){return e.test(t)});throw new Error("Browser's test function is not valid")});return t&&(this.parsedResult.engine=t.describe(this.getUA())),this.parsedResult.engine},t.parse=function(){return this.parseBrowser(),this.parseOS(),this.parsePlatform(),this.parseEngine(),this},t.getResult=function(){return s.default.assign({},this.parsedResult)},t.satisfies=function(e){var t=this,n={},i=0,a={},r=0;if(Object.keys(e).forEach(function(t){var o=e[t];"string"==typeof o?(a[t]=o,r+=1):"object"==typeof o&&(n[t]=o,i+=1)}),i>0){var o=Object.keys(n),u=s.default.find(o,function(e){return t.isOS(e)});if(u){var l=this.satisfies(n[u]);if(void 0!==l)return l}var d=s.default.find(o,function(e){return t.isPlatform(e)});if(d){var c=this.satisfies(n[d]);if(void 0!==c)return c}}if(r>0){var h=Object.keys(a),m=s.default.find(h,function(e){return t.isBrowser(e,!0)});if(void 0!==m)return this.compareVersion(a[m])}},t.isBrowser=function(e,t){void 0===t&&(t=!1);var n=this.getBrowserName().toLowerCase(),i=e.toLowerCase(),a=s.default.getBrowserTypeByAlias(i);return t&&a&&(i=a.toLowerCase()),i===n},t.compareVersion=function(e){var t=[0],n=e,i=!1,a=this.getBrowserVersion();if("string"==typeof a)return">"===e[0]||"<"===e[0]?(n=e.substr(1),"="===e[1]?(i=!0,n=e.substr(2)):t=[],">"===e[0]?t.push(1):t.push(-1)):"="===e[0]?n=e.substr(1):"~"===e[0]&&(i=!0,n=e.substr(1)),t.indexOf(s.default.compareVersions(a,n,i))>-1},t.isOS=function(e){return this.getOSName(!0)===String(e).toLowerCase()},t.isPlatform=function(e){return this.getPlatformType(!0)===String(e).toLowerCase()},t.isEngine=function(e){return this.getEngineName(!0)===String(e).toLowerCase()},t.is=function(e,t){return void 0===t&&(t=!1),this.isBrowser(e,t)||this.isOS(e)||this.isPlatform(e)},t.some=function(e){var t=this;return void 0===e&&(e=[]),e.some(function(e){return t.is(e)})},e}();t.default=l,e.exports=t.default},92:function(e,t,n){t.__esModule=!0,t.default=void 0;var i,a=(i=n(17))&&i.__esModule?i:{default:i},r=/version\/(\d+(\.?_?\d+)+)/i,o=[{test:[/gptbot/i],describe:function(e){var t={name:"GPTBot"},n=a.default.getFirstMatch(/gptbot\/(\d+(\.\d+)+)/i,e)||a.default.getFirstMatch(r,e);return n&&(t.version=n),t}},{test:[/chatgpt-user/i],describe:function(e){var t={name:"ChatGPT-User"},n=a.default.getFirstMatch(/chatgpt-user\/(\d+(\.\d+)+)/i,e)||a.default.getFirstMatch(r,e);return n&&(t.version=n),t}},{test:[/oai-searchbot/i],describe:function(e){var t={name:"OAI-SearchBot"},n=a.default.getFirstMatch(/oai-searchbot\/(\d+(\.\d+)+)/i,e)||a.default.getFirstMatch(r,e);return n&&(t.version=n),t}},{test:[/claudebot/i,/claude-web/i,/claude-user/i,/claude-searchbot/i],describe:function(e){var t={name:"ClaudeBot"},n=a.default.getFirstMatch(/(?:claudebot|claude-web|claude-user|claude-searchbot)\/(\d+(\.\d+)+)/i,e)||a.default.getFirstMatch(r,e);return n&&(t.version=n),t}},{test:[/omgilibot/i,/webzio-extended/i],describe:function(e){var t={name:"Omgilibot"},n=a.default.getFirstMatch(/(?:omgilibot|webzio-extended)\/(\d+(\.\d+)+)/i,e)||a.default.getFirstMatch(r,e);return n&&(t.version=n),t}},{test:[/diffbot/i],describe:function(e){var t={name:"Diffbot"},n=a.default.getFirstMatch(/diffbot\/(\d+(\.\d+)+)/i,e)||a.default.getFirstMatch(r,e);return n&&(t.version=n),t}},{test:[/perplexitybot/i],describe:function(e){var t={name:"PerplexityBot"},n=a.default.getFirstMatch(/perplexitybot\/(\d+(\.\d+)+)/i,e)||a.default.getFirstMatch(r,e);return n&&(t.version=n),t}},{test:[/perplexity-user/i],describe:function(e){var t={name:"Perplexity-User"},n=a.default.getFirstMatch(/perplexity-user\/(\d+(\.\d+)+)/i,e)||a.default.getFirstMatch(r,e);return n&&(t.version=n),t}},{test:[/youbot/i],describe:function(e){var t={name:"YouBot"},n=a.default.getFirstMatch(/youbot\/(\d+(\.\d+)+)/i,e)||a.default.getFirstMatch(r,e);return n&&(t.version=n),t}},{test:[/meta-webindexer/i],describe:function(e){var t={name:"Meta-WebIndexer"},n=a.default.getFirstMatch(/meta-webindexer\/(\d+(\.\d+)+)/i,e)||a.default.getFirstMatch(r,e);return n&&(t.version=n),t}},{test:[/meta-externalads/i],describe:function(e){var t={name:"Meta-ExternalAds"},n=a.default.getFirstMatch(/meta-externalads\/(\d+(\.\d+)+)/i,e)||a.default.getFirstMatch(r,e);return n&&(t.version=n),t}},{test:[/meta-externalagent/i],describe:function(e){var t={name:"Meta-ExternalAgent"},n=a.default.getFirstMatch(/meta-externalagent\/(\d+(\.\d+)+)/i,e)||a.default.getFirstMatch(r,e);return n&&(t.version=n),t}},{test:[/meta-externalfetcher/i],describe:function(e){var t={name:"Meta-ExternalFetcher"},n=a.default.getFirstMatch(/meta-externalfetcher\/(\d+(\.\d+)+)/i,e)||a.default.getFirstMatch(r,e);return n&&(t.version=n),t}},{test:[/googlebot/i],describe:function(e){var t={name:"Googlebot"},n=a.default.getFirstMatch(/googlebot\/(\d+(\.\d+))/i,e)||a.default.getFirstMatch(r,e);return n&&(t.version=n),t}},{test:[/linespider/i],describe:function(e){var t={name:"Linespider"},n=a.default.getFirstMatch(/(?:linespider)(?:-[-\w]+)?[\s/](\d+(\.\d+)+)/i,e)||a.default.getFirstMatch(r,e);return n&&(t.version=n),t}},{test:[/amazonbot/i],describe:function(e){var t={name:"AmazonBot"},n=a.default.getFirstMatch(/amazonbot\/(\d+(\.\d+)+)/i,e)||a.default.getFirstMatch(r,e);return n&&(t.version=n),t}},{test:[/bingbot/i],describe:function(e){var t={name:"BingCrawler"},n=a.default.getFirstMatch(/bingbot\/(\d+(\.\d+)+)/i,e)||a.default.getFirstMatch(r,e);return n&&(t.version=n),t}},{test:[/baiduspider/i],describe:function(e){var t={name:"BaiduSpider"},n=a.default.getFirstMatch(/baiduspider\/(\d+(\.\d+)+)/i,e)||a.default.getFirstMatch(r,e);return n&&(t.version=n),t}},{test:[/duckduckbot/i],describe:function(e){var t={name:"DuckDuckBot"},n=a.default.getFirstMatch(/duckduckbot\/(\d+(\.\d+)+)/i,e)||a.default.getFirstMatch(r,e);return n&&(t.version=n),t}},{test:[/ia_archiver/i],describe:function(e){var t={name:"InternetArchiveCrawler"},n=a.default.getFirstMatch(/ia_archiver\/(\d+(\.\d+)+)/i,e)||a.default.getFirstMatch(r,e);return n&&(t.version=n),t}},{test:[/facebookexternalhit/i,/facebookcatalog/i],describe:function(){return{name:"FacebookExternalHit"}}},{test:[/slackbot/i,/slack-imgProxy/i],describe:function(e){var t={name:"SlackBot"},n=a.default.getFirstMatch(/(?:slackbot|slack-imgproxy)(?:-[-\w]+)?[\s/](\d+(\.\d+)+)/i,e)||a.default.getFirstMatch(r,e);return n&&(t.version=n),t}},{test:[/yahoo!?[\s/]*slurp/i],describe:function(){return{name:"YahooSlurp"}}},{test:[/yandexbot/i,/yandexmobilebot/i],describe:function(){return{name:"YandexBot"}}},{test:[/pingdom/i],describe:function(){return{name:"PingdomBot"}}},{test:[/opera/i],describe:function(e){var t={name:"Opera"},n=a.default.getFirstMatch(r,e)||a.default.getFirstMatch(/(?:opera)[\s/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/opr\/|opios/i],describe:function(e){var t={name:"Opera"},n=a.default.getFirstMatch(/(?:opr|opios)[\s/](\S+)/i,e)||a.default.getFirstMatch(r,e);return n&&(t.version=n),t}},{test:[/SamsungBrowser/i],describe:function(e){var t={name:"Samsung Internet for Android"},n=a.default.getFirstMatch(r,e)||a.default.getFirstMatch(/(?:SamsungBrowser)[\s/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/Whale/i],describe:function(e){var t={name:"NAVER Whale Browser"},n=a.default.getFirstMatch(r,e)||a.default.getFirstMatch(/(?:whale)[\s/](\d+(?:\.\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/PaleMoon/i],describe:function(e){var t={name:"Pale Moon"},n=a.default.getFirstMatch(r,e)||a.default.getFirstMatch(/(?:PaleMoon)[\s/](\d+(?:\.\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/MZBrowser/i],describe:function(e){var t={name:"MZ Browser"},n=a.default.getFirstMatch(/(?:MZBrowser)[\s/](\d+(?:\.\d+)+)/i,e)||a.default.getFirstMatch(r,e);return n&&(t.version=n),t}},{test:[/focus/i],describe:function(e){var t={name:"Focus"},n=a.default.getFirstMatch(/(?:focus)[\s/](\d+(?:\.\d+)+)/i,e)||a.default.getFirstMatch(r,e);return n&&(t.version=n),t}},{test:[/swing/i],describe:function(e){var t={name:"Swing"},n=a.default.getFirstMatch(/(?:swing)[\s/](\d+(?:\.\d+)+)/i,e)||a.default.getFirstMatch(r,e);return n&&(t.version=n),t}},{test:[/coast/i],describe:function(e){var t={name:"Opera Coast"},n=a.default.getFirstMatch(r,e)||a.default.getFirstMatch(/(?:coast)[\s/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/opt\/\d+(?:.?_?\d+)+/i],describe:function(e){var t={name:"Opera Touch"},n=a.default.getFirstMatch(/(?:opt)[\s/](\d+(\.?_?\d+)+)/i,e)||a.default.getFirstMatch(r,e);return n&&(t.version=n),t}},{test:[/yabrowser/i],describe:function(e){var t={name:"Yandex Browser"},n=a.default.getFirstMatch(/(?:yabrowser)[\s/](\d+(\.?_?\d+)+)/i,e)||a.default.getFirstMatch(r,e);return n&&(t.version=n),t}},{test:[/ucbrowser/i],describe:function(e){var t={name:"UC Browser"},n=a.default.getFirstMatch(r,e)||a.default.getFirstMatch(/(?:ucbrowser)[\s/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/Maxthon|mxios/i],describe:function(e){var t={name:"Maxthon"},n=a.default.getFirstMatch(r,e)||a.default.getFirstMatch(/(?:Maxthon|mxios)[\s/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/epiphany/i],describe:function(e){var t={name:"Epiphany"},n=a.default.getFirstMatch(r,e)||a.default.getFirstMatch(/(?:epiphany)[\s/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/puffin/i],describe:function(e){var t={name:"Puffin"},n=a.default.getFirstMatch(r,e)||a.default.getFirstMatch(/(?:puffin)[\s/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/sleipnir/i],describe:function(e){var t={name:"Sleipnir"},n=a.default.getFirstMatch(r,e)||a.default.getFirstMatch(/(?:sleipnir)[\s/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/k-meleon/i],describe:function(e){var t={name:"K-Meleon"},n=a.default.getFirstMatch(r,e)||a.default.getFirstMatch(/(?:k-meleon)[\s/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/micromessenger/i],describe:function(e){var t={name:"WeChat"},n=a.default.getFirstMatch(/(?:micromessenger)[\s/](\d+(\.?_?\d+)+)/i,e)||a.default.getFirstMatch(r,e);return n&&(t.version=n),t}},{test:[/qqbrowser/i],describe:function(e){var t={name:/qqbrowserlite/i.test(e)?"QQ Browser Lite":"QQ Browser"},n=a.default.getFirstMatch(/(?:qqbrowserlite|qqbrowser)[/](\d+(\.?_?\d+)+)/i,e)||a.default.getFirstMatch(r,e);return n&&(t.version=n),t}},{test:[/msie|trident/i],describe:function(e){var t={name:"Internet Explorer"},n=a.default.getFirstMatch(/(?:msie |rv:)(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/\sedg\//i],describe:function(e){var t={name:"Microsoft Edge"},n=a.default.getFirstMatch(/\sedg\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/edg([ea]|ios)/i],describe:function(e){var t={name:"Microsoft Edge"},n=a.default.getSecondMatch(/edg([ea]|ios)\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/vivaldi/i],describe:function(e){var t={name:"Vivaldi"},n=a.default.getFirstMatch(/vivaldi\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/seamonkey/i],describe:function(e){var t={name:"SeaMonkey"},n=a.default.getFirstMatch(/seamonkey\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/sailfish/i],describe:function(e){var t={name:"Sailfish"},n=a.default.getFirstMatch(/sailfish\s?browser\/(\d+(\.\d+)?)/i,e);return n&&(t.version=n),t}},{test:[/silk/i],describe:function(e){var t={name:"Amazon Silk"},n=a.default.getFirstMatch(/silk\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/phantom/i],describe:function(e){var t={name:"PhantomJS"},n=a.default.getFirstMatch(/phantomjs\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/slimerjs/i],describe:function(e){var t={name:"SlimerJS"},n=a.default.getFirstMatch(/slimerjs\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/blackberry|\bbb\d+/i,/rim\stablet/i],describe:function(e){var t={name:"BlackBerry"},n=a.default.getFirstMatch(r,e)||a.default.getFirstMatch(/blackberry[\d]+\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/(web|hpw)[o0]s/i],describe:function(e){var t={name:"WebOS Browser"},n=a.default.getFirstMatch(r,e)||a.default.getFirstMatch(/w(?:eb)?[o0]sbrowser\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/bada/i],describe:function(e){var t={name:"Bada"},n=a.default.getFirstMatch(/dolfin\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/tizen/i],describe:function(e){var t={name:"Tizen"},n=a.default.getFirstMatch(/(?:tizen\s?)?browser\/(\d+(\.?_?\d+)+)/i,e)||a.default.getFirstMatch(r,e);return n&&(t.version=n),t}},{test:[/qupzilla/i],describe:function(e){var t={name:"QupZilla"},n=a.default.getFirstMatch(/(?:qupzilla)[\s/](\d+(\.?_?\d+)+)/i,e)||a.default.getFirstMatch(r,e);return n&&(t.version=n),t}},{test:[/librewolf/i],describe:function(e){var t={name:"LibreWolf"},n=a.default.getFirstMatch(/(?:librewolf)[\s/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/firefox|iceweasel|fxios/i],describe:function(e){var t={name:"Firefox"},n=a.default.getFirstMatch(/(?:firefox|iceweasel|fxios)[\s/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/electron/i],describe:function(e){var t={name:"Electron"},n=a.default.getFirstMatch(/(?:electron)\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/sogoumobilebrowser/i,/metasr/i,/se 2\.[x]/i],describe:function(e){var t={name:"Sogou Browser"},n=a.default.getFirstMatch(/(?:sogoumobilebrowser)[\s/](\d+(\.?_?\d+)+)/i,e),i=a.default.getFirstMatch(/(?:chrome|crios|crmo)\/(\d+(\.?_?\d+)+)/i,e),r=a.default.getFirstMatch(/se ([\d.]+)x/i,e),o=n||i||r;return o&&(t.version=o),t}},{test:[/MiuiBrowser/i],describe:function(e){var t={name:"Miui"},n=a.default.getFirstMatch(/(?:MiuiBrowser)[\s/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:function(e){return!!e.hasBrand("DuckDuckGo")||e.test(/\sDdg\/[\d.]+$/i)},describe:function(e,t){var n={name:"DuckDuckGo"};if(t){var i=t.getBrandVersion("DuckDuckGo");if(i)return n.version=i,n}var r=a.default.getFirstMatch(/\sDdg\/([\d.]+)$/i,e);return r&&(n.version=r),n}},{test:function(e){return e.hasBrand("Brave")},describe:function(e,t){var n={name:"Brave"};if(t){var i=t.getBrandVersion("Brave");if(i)return n.version=i,n}return n}},{test:[/chromium/i],describe:function(e){var t={name:"Chromium"},n=a.default.getFirstMatch(/(?:chromium)[\s/](\d+(\.?_?\d+)+)/i,e)||a.default.getFirstMatch(r,e);return n&&(t.version=n),t}},{test:[/chrome|crios|crmo/i],describe:function(e){var t={name:"Chrome"},n=a.default.getFirstMatch(/(?:chrome|crios|crmo)\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/GSA/i],describe:function(e){var t={name:"Google Search"},n=a.default.getFirstMatch(/(?:GSA)\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:function(e){var t=!e.test(/like android/i),n=e.test(/android/i);return t&&n},describe:function(e){var t={name:"Android Browser"},n=a.default.getFirstMatch(r,e);return n&&(t.version=n),t}},{test:[/playstation 4/i],describe:function(e){var t={name:"PlayStation 4"},n=a.default.getFirstMatch(r,e);return n&&(t.version=n),t}},{test:[/safari|applewebkit/i],describe:function(e){var t={name:"Safari"},n=a.default.getFirstMatch(r,e);return n&&(t.version=n),t}},{test:[/.*/i],describe:function(e){var t=-1!==e.search("\\(")?/^(.*)\/(.*)[ \t]\((.*)/:/^(.*)\/(.*) /;return{name:a.default.getFirstMatch(t,e),version:a.default.getSecondMatch(t,e)}}}];t.default=o,e.exports=t.default},93:function(e,t,n){t.__esModule=!0,t.default=void 0;var i,a=(i=n(17))&&i.__esModule?i:{default:i},r=n(18),o=[{test:[/Roku\/DVP/],describe:function(e){var t=a.default.getFirstMatch(/Roku\/DVP-(\d+\.\d+)/i,e);return{name:r.OS_MAP.Roku,version:t}}},{test:[/windows phone/i],describe:function(e){var t=a.default.getFirstMatch(/windows phone (?:os)?\s?(\d+(\.\d+)*)/i,e);return{name:r.OS_MAP.WindowsPhone,version:t}}},{test:[/windows /i],describe:function(e){var t=a.default.getFirstMatch(/Windows ((NT|XP)( \d\d?.\d)?)/i,e),n=a.default.getWindowsVersionName(t);return{name:r.OS_MAP.Windows,version:t,versionName:n}}},{test:[/Macintosh(.*?) FxiOS(.*?)\//],describe:function(e){var t={name:r.OS_MAP.iOS},n=a.default.getSecondMatch(/(Version\/)(\d[\d.]+)/,e);return n&&(t.version=n),t}},{test:[/macintosh/i],describe:function(e){var t=a.default.getFirstMatch(/mac os x (\d+(\.?_?\d+)+)/i,e).replace(/[_\s]/g,"."),n=a.default.getMacOSVersionName(t),i={name:r.OS_MAP.MacOS,version:t};return n&&(i.versionName=n),i}},{test:[/(ipod|iphone|ipad)/i],describe:function(e){var t=a.default.getFirstMatch(/os (\d+([_\s]\d+)*) like mac os x/i,e).replace(/[_\s]/g,".");return{name:r.OS_MAP.iOS,version:t}}},{test:[/OpenHarmony/i],describe:function(e){var t=a.default.getFirstMatch(/OpenHarmony\s+(\d+(\.\d+)*)/i,e);return{name:r.OS_MAP.HarmonyOS,version:t}}},{test:function(e){var t=!e.test(/like android/i),n=e.test(/android/i);return t&&n},describe:function(e){var t=a.default.getFirstMatch(/android[\s/-](\d+(\.\d+)*)/i,e),n=a.default.getAndroidVersionName(t),i={name:r.OS_MAP.Android,version:t};return n&&(i.versionName=n),i}},{test:[/(web|hpw)[o0]s/i],describe:function(e){var t=a.default.getFirstMatch(/(?:web|hpw)[o0]s\/(\d+(\.\d+)*)/i,e),n={name:r.OS_MAP.WebOS};return t&&t.length&&(n.version=t),n}},{test:[/blackberry|\bbb\d+/i,/rim\stablet/i],describe:function(e){var t=a.default.getFirstMatch(/rim\stablet\sos\s(\d+(\.\d+)*)/i,e)||a.default.getFirstMatch(/blackberry\d+\/(\d+([_\s]\d+)*)/i,e)||a.default.getFirstMatch(/\bbb(\d+)/i,e);return{name:r.OS_MAP.BlackBerry,version:t}}},{test:[/bada/i],describe:function(e){var t=a.default.getFirstMatch(/bada\/(\d+(\.\d+)*)/i,e);return{name:r.OS_MAP.Bada,version:t}}},{test:[/tizen/i],describe:function(e){var t=a.default.getFirstMatch(/tizen[/\s](\d+(\.\d+)*)/i,e);return{name:r.OS_MAP.Tizen,version:t}}},{test:[/linux/i],describe:function(){return{name:r.OS_MAP.Linux}}},{test:[/CrOS/],describe:function(){return{name:r.OS_MAP.ChromeOS}}},{test:[/PlayStation 4/],describe:function(e){var t=a.default.getFirstMatch(/PlayStation 4[/\s](\d+(\.\d+)*)/i,e);return{name:r.OS_MAP.PlayStation4,version:t}}}];t.default=o,e.exports=t.default},94:function(e,t,n){t.__esModule=!0,t.default=void 0;var i,a=(i=n(17))&&i.__esModule?i:{default:i},r=n(18),o=[{test:[/googlebot/i],describe:function(){return{type:r.PLATFORMS_MAP.bot,vendor:"Google"}}},{test:[/linespider/i],describe:function(){return{type:r.PLATFORMS_MAP.bot,vendor:"Line"}}},{test:[/amazonbot/i],describe:function(){return{type:r.PLATFORMS_MAP.bot,vendor:"Amazon"}}},{test:[/gptbot/i],describe:function(){return{type:r.PLATFORMS_MAP.bot,vendor:"OpenAI"}}},{test:[/chatgpt-user/i],describe:function(){return{type:r.PLATFORMS_MAP.bot,vendor:"OpenAI"}}},{test:[/oai-searchbot/i],describe:function(){return{type:r.PLATFORMS_MAP.bot,vendor:"OpenAI"}}},{test:[/baiduspider/i],describe:function(){return{type:r.PLATFORMS_MAP.bot,vendor:"Baidu"}}},{test:[/bingbot/i],describe:function(){return{type:r.PLATFORMS_MAP.bot,vendor:"Bing"}}},{test:[/duckduckbot/i],describe:function(){return{type:r.PLATFORMS_MAP.bot,vendor:"DuckDuckGo"}}},{test:[/claudebot/i,/claude-web/i,/claude-user/i,/claude-searchbot/i],describe:function(){return{type:r.PLATFORMS_MAP.bot,vendor:"Anthropic"}}},{test:[/omgilibot/i,/webzio-extended/i],describe:function(){return{type:r.PLATFORMS_MAP.bot,vendor:"Webz.io"}}},{test:[/diffbot/i],describe:function(){return{type:r.PLATFORMS_MAP.bot,vendor:"Diffbot"}}},{test:[/perplexitybot/i],describe:function(){return{type:r.PLATFORMS_MAP.bot,vendor:"Perplexity AI"}}},{test:[/perplexity-user/i],describe:function(){return{type:r.PLATFORMS_MAP.bot,vendor:"Perplexity AI"}}},{test:[/youbot/i],describe:function(){return{type:r.PLATFORMS_MAP.bot,vendor:"You.com"}}},{test:[/ia_archiver/i],describe:function(){return{type:r.PLATFORMS_MAP.bot,vendor:"Internet Archive"}}},{test:[/meta-webindexer/i],describe:function(){return{type:r.PLATFORMS_MAP.bot,vendor:"Meta"}}},{test:[/meta-externalads/i],describe:function(){return{type:r.PLATFORMS_MAP.bot,vendor:"Meta"}}},{test:[/meta-externalagent/i],describe:function(){return{type:r.PLATFORMS_MAP.bot,vendor:"Meta"}}},{test:[/meta-externalfetcher/i],describe:function(){return{type:r.PLATFORMS_MAP.bot,vendor:"Meta"}}},{test:[/facebookexternalhit/i,/facebookcatalog/i],describe:function(){return{type:r.PLATFORMS_MAP.bot,vendor:"Meta"}}},{test:[/slackbot/i,/slack-imgProxy/i],describe:function(){return{type:r.PLATFORMS_MAP.bot,vendor:"Slack"}}},{test:[/yahoo/i],describe:function(){return{type:r.PLATFORMS_MAP.bot,vendor:"Yahoo"}}},{test:[/yandexbot/i,/yandexmobilebot/i],describe:function(){return{type:r.PLATFORMS_MAP.bot,vendor:"Yandex"}}},{test:[/pingdom/i],describe:function(){return{type:r.PLATFORMS_MAP.bot,vendor:"Pingdom"}}},{test:[/huawei/i],describe:function(e){var t=a.default.getFirstMatch(/(can-l01)/i,e)&&"Nova",n={type:r.PLATFORMS_MAP.mobile,vendor:"Huawei"};return t&&(n.model=t),n}},{test:[/nexus\s*(?:7|8|9|10).*/i],describe:function(){return{type:r.PLATFORMS_MAP.tablet,vendor:"Nexus"}}},{test:[/ipad/i],describe:function(){return{type:r.PLATFORMS_MAP.tablet,vendor:"Apple",model:"iPad"}}},{test:[/Macintosh(.*?) FxiOS(.*?)\//],describe:function(){return{type:r.PLATFORMS_MAP.tablet,vendor:"Apple",model:"iPad"}}},{test:[/kftt build/i],describe:function(){return{type:r.PLATFORMS_MAP.tablet,vendor:"Amazon",model:"Kindle Fire HD 7"}}},{test:[/silk/i],describe:function(){return{type:r.PLATFORMS_MAP.tablet,vendor:"Amazon"}}},{test:[/tablet(?! pc)/i],describe:function(){return{type:r.PLATFORMS_MAP.tablet}}},{test:function(e){var t=e.test(/ipod|iphone/i),n=e.test(/like (ipod|iphone)/i);return t&&!n},describe:function(e){var t=a.default.getFirstMatch(/(ipod|iphone)/i,e);return{type:r.PLATFORMS_MAP.mobile,vendor:"Apple",model:t}}},{test:[/nexus\s*[0-6].*/i,/galaxy nexus/i],describe:function(){return{type:r.PLATFORMS_MAP.mobile,vendor:"Nexus"}}},{test:[/Nokia/i],describe:function(e){var t=a.default.getFirstMatch(/Nokia\s+([0-9]+(\.[0-9]+)?)/i,e),n={type:r.PLATFORMS_MAP.mobile,vendor:"Nokia"};return t&&(n.model=t),n}},{test:[/[^-]mobi/i],describe:function(){return{type:r.PLATFORMS_MAP.mobile}}},{test:function(e){return"blackberry"===e.getBrowserName(!0)},describe:function(){return{type:r.PLATFORMS_MAP.mobile,vendor:"BlackBerry"}}},{test:function(e){return"bada"===e.getBrowserName(!0)},describe:function(){return{type:r.PLATFORMS_MAP.mobile}}},{test:function(e){return"windows phone"===e.getBrowserName()},describe:function(){return{type:r.PLATFORMS_MAP.mobile,vendor:"Microsoft"}}},{test:function(e){var t=Number(String(e.getOSVersion()).split(".")[0]);return"android"===e.getOSName(!0)&&t>=3},describe:function(){return{type:r.PLATFORMS_MAP.tablet}}},{test:function(e){return"android"===e.getOSName(!0)},describe:function(){return{type:r.PLATFORMS_MAP.mobile}}},{test:[/smart-?tv|smarttv/i],describe:function(){return{type:r.PLATFORMS_MAP.tv}}},{test:[/netcast/i],describe:function(){return{type:r.PLATFORMS_MAP.tv}}},{test:function(e){return"macos"===e.getOSName(!0)},describe:function(){return{type:r.PLATFORMS_MAP.desktop,vendor:"Apple"}}},{test:function(e){return"windows"===e.getOSName(!0)},describe:function(){return{type:r.PLATFORMS_MAP.desktop}}},{test:function(e){return"linux"===e.getOSName(!0)},describe:function(){return{type:r.PLATFORMS_MAP.desktop}}},{test:function(e){return"playstation 4"===e.getOSName(!0)},describe:function(){return{type:r.PLATFORMS_MAP.tv}}},{test:function(e){return"roku"===e.getOSName(!0)},describe:function(){return{type:r.PLATFORMS_MAP.tv}}}];t.default=o,e.exports=t.default},95:function(e,t,n){t.__esModule=!0,t.default=void 0;var i,a=(i=n(17))&&i.__esModule?i:{default:i},r=n(18),o=[{test:function(e){return"microsoft edge"===e.getBrowserName(!0)},describe:function(e){if(/\sedg\//i.test(e))return{name:r.ENGINE_MAP.Blink};var t=a.default.getFirstMatch(/edge\/(\d+(\.?_?\d+)+)/i,e);return{name:r.ENGINE_MAP.EdgeHTML,version:t}}},{test:[/trident/i],describe:function(e){var t={name:r.ENGINE_MAP.Trident},n=a.default.getFirstMatch(/trident\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:function(e){return e.test(/presto/i)},describe:function(e){var t={name:r.ENGINE_MAP.Presto},n=a.default.getFirstMatch(/presto\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:function(e){var t=e.test(/gecko/i),n=e.test(/like gecko/i);return t&&!n},describe:function(e){var t={name:r.ENGINE_MAP.Gecko},n=a.default.getFirstMatch(/gecko\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/(apple)?webkit\/537\.36/i],describe:function(){return{name:r.ENGINE_MAP.Blink}}},{test:[/(apple)?webkit/i],describe:function(e){var t={name:r.ENGINE_MAP.WebKit},n=a.default.getFirstMatch(/webkit\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}}];t.default=o,e.exports=t.default}})}(jh)),jh.exports),zh=Nh(Bh),Uh={tablet:"tablet",mobile:"phone",tv:"television",desktop:"desktop"},Hh={"1280x720":.67,"1920x1080":1,"3840x2160":2,"7680x4320":4},Gh=function(){return c(function e(){o(this,e)},[{key:"getDeviceData",value:function(e){if("undefined"==typeof window)return{os_version:"X.X.X",os_name:"Server",browser_name:"Unknown",browser_version:"X.X.X",sdk_client:"web",sdk_version:Ae,language:"en"};var t=zh.getParser(window.navigator.userAgent),n=t.getPlatform(),i={os_version:t.getOSVersion(),os_name:t.getOSName(),browser_name:t.getBrowserName(),browser_version:t.getBrowserVersion(),sdk_client:"web",sdk_version:Ae,language:window.navigator.language};if(n.type&&(i.form_factor=Uh[n.type]),n.model&&(i.device_model=n.model),e&&e.length>0){var a=(e=>{var t=e.find(e=>e.includes(dn)),n={platform:"",version:""};if(t){var i=t.split(hn);n.platform=i[1],n.version=i[2]}return n})(e);i.extended_platform=a.platform,i.extended_platform_version=a.version}return i}},{key:"getDeviceFormFactor",value:function(){if("undefined"==typeof window)return"desktop";var e=zh.getParser(window.navigator.userAgent).getPlatform();return e.type&&Uh[e.type]||"desktop"}},{key:"getDeviceScaleFactor",value:function(e){var t;if(e||(e=this.getDeviceFormFactor()),"television"!==e)return 1;var n=window,i=n.innerWidth,a=n.innerHeight,r=i.toString()+"x"+a.toString();return null!==(t=Hh[r])&&void 0!==t?t:Math.min(i/1920,a/1080)||1}},{key:"getScreenInfo",value:function(){var e,t,n,i;return"undefined"==typeof window?{width:1920,height:1080,scale:1}:{width:null!==(e=null===(t=window.screen)||void 0===t?void 0:t.width)&&void 0!==e?e:window.innerWidth,height:null!==(n=null===(i=window.screen)||void 0===i?void 0:i.height)&&void 0!==n?n:window.innerHeight,scale:window.devicePixelRatio||1}}},{key:"getLanguage",value:function(){return"undefined"==typeof window?"en":window.navigator.language||"en"}},{key:"generateUUID",value:function(){return"undefined"!=typeof crypto&&"function"==typeof crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})}}])}();function Vh(e,t,n,i){var a,r=arguments.length,o=r<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,n,i);else for(var s=e.length-1;s>=0;s--)(a=e[s])&&(o=(r<3?a(o):r>3?a(t,n,o):a(t,n))||o);return r>3&&o&&Object.defineProperty(t,n,o),o}"function"==typeof SuppressedError&&SuppressedError;var Kh,Xh,Yh,qh=globalThis,Jh=qh.ShadowRoot&&(void 0===qh.ShadyCSS||qh.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Qh=Symbol(),Zh=new WeakMap,em=function(){return c(function e(t,n,i){if(o(this,e),this._$cssResult$=!0,i!==Qh)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=n},[{key:"styleSheet",get:function(){var e=this.o,t=this.t;if(Jh&&void 0===e){var n=void 0!==t&&1===t.length;n&&(e=Zh.get(t)),void 0===e&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),n&&Zh.set(t,e))}return e}},{key:"toString",value:function(){return this.cssText}}])}(),tm=e=>new em("string"==typeof e?e:e+"",void 0,Qh),nm=(e,...t)=>{var n=1===e.length?e[0]:t.reduce((t,n,i)=>t+(e=>{if(!0===e._$cssResult$)return e.cssText;if("number"==typeof e)return e;throw Error("Value passed to 'css' function must be a 'css' function result: "+e+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(n)+e[i+1],e[0]);return new em(n,e,Qh)},im=Jh?e=>e:e=>e instanceof CSSStyleSheet?(e=>{for(var t,n="",i=h(e.cssRules);!(t=i()).done;){n+=t.value.cssText}return tm(n)})(e):e,am=Object.is,rm=Object.defineProperty,om=Object.getOwnPropertyDescriptor,sm=Object.getOwnPropertyNames,um=Object.getOwnPropertySymbols,lm=Object.getPrototypeOf,dm=globalThis,cm=dm.trustedTypes,hm=cm?cm.emptyScript:"",mm=dm.reactiveElementPolyfillSupport,fm=(e,t)=>e,vm={toAttribute(e,t){switch(t){case Boolean:e=e?hm:null;break;case Object:case Array:e=null==e?e:JSON.stringify(e)}return e},fromAttribute(e,t){var n=e;switch(t){case Boolean:n=null!==e;break;case Number:n=null===e?null:Number(e);break;case Object:case Array:try{n=JSON.parse(e)}catch(e){n=null}}return n}},pm=(e,t)=>!am(e,t),gm={attribute:!0,type:String,converter:vm,reflect:!1,useDefault:!1,hasChanged:pm};null!==(Kh=Symbol.metadata)&&void 0!==Kh||(Symbol.metadata=Symbol("metadata")),null!==(Xh=dm.litPropertyMetadata)&&void 0!==Xh||(dm.litPropertyMetadata=new WeakMap);var ym,bm=function(e){function t(){var e;return o(this,t),(e=r(this,t))._$Ep=void 0,e.isUpdatePending=!1,e.hasUpdated=!1,e._$Em=null,e._$Ev(),e}return p(t,e),c(t,[{key:"_$Ev",value:function(){var e;this._$ES=new Promise(e=>this.enableUpdating=e),this._$AL=new Map,this._$E_(),this.requestUpdate(),null===(e=this.constructor.l)||void 0===e||e.forEach(e=>e(this))}},{key:"addController",value:function(e){var t,n;(null!==(t=this._$EO)&&void 0!==t?t:this._$EO=new Set).add(e),void 0!==this.renderRoot&&this.isConnected&&(null===(n=e.hostConnected)||void 0===n||n.call(e))}},{key:"removeController",value:function(e){var t;null===(t=this._$EO)||void 0===t||t.delete(e)}},{key:"_$E_",value:function(){for(var e,t=new Map,n=h(this.constructor.elementProperties.keys());!(e=n()).done;){var i=e.value;this.hasOwnProperty(i)&&(t.set(i,this[i]),delete this[i])}t.size>0&&(this._$Ep=t)}},{key:"createRenderRoot",value:function(){var e,t=null!==(e=this.shadowRoot)&&void 0!==e?e:this.attachShadow(this.constructor.shadowRootOptions);return((e,t)=>{if(Jh)e.adoptedStyleSheets=t.map(e=>e instanceof CSSStyleSheet?e:e.styleSheet);else for(var n,i=h(t);!(n=i()).done;){var a=n.value,r=document.createElement("style"),o=qh.litNonce;void 0!==o&&r.setAttribute("nonce",o),r.textContent=a.cssText,e.appendChild(r)}})(t,this.constructor.elementStyles),t}},{key:"connectedCallback",value:function(){var e,t;null!==(e=this.renderRoot)&&void 0!==e||(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),null===(t=this._$EO)||void 0===t||t.forEach(e=>{var t;return null===(t=e.hostConnected)||void 0===t?void 0:t.call(e)})}},{key:"enableUpdating",value:function(e){}},{key:"disconnectedCallback",value:function(){var e;null===(e=this._$EO)||void 0===e||e.forEach(e=>{var t;return null===(t=e.hostDisconnected)||void 0===t?void 0:t.call(e)})}},{key:"attributeChangedCallback",value:function(e,t,n){this._$AK(e,n)}},{key:"_$ET",value:function(e,t){var n=this.constructor.elementProperties.get(e),i=this.constructor._$Eu(e,n);if(void 0!==i&&!0===n.reflect){var a,r=(void 0!==(null===(a=n.converter)||void 0===a?void 0:a.toAttribute)?n.converter:vm).toAttribute(t,n.type);this._$Em=e,null==r?this.removeAttribute(i):this.setAttribute(i,r),this._$Em=null}}},{key:"_$AK",value:function(e,t){var n=this.constructor,i=n._$Eh.get(e);if(void 0!==i&&this._$Em!==i){var a,r,o,s=n.getPropertyOptions(i),u="function"==typeof s.converter?{fromAttribute:s.converter}:void 0!==(null===(a=s.converter)||void 0===a?void 0:a.fromAttribute)?s.converter:vm;this._$Em=i;var l=u.fromAttribute(t,s.type);this[i]=null!==(r=null!=l?l:null===(o=this._$Ej)||void 0===o?void 0:o.get(i))&&void 0!==r?r:l,this._$Em=null}}},{key:"requestUpdate",value:function(e,t,n,i=!1,a){if(void 0!==e){var r,o,s=this.constructor;if(!1===i&&(a=this[e]),null!=n||(n=s.getPropertyOptions(e)),!((null!==(r=n.hasChanged)&&void 0!==r?r:pm)(a,t)||n.useDefault&&n.reflect&&a===(null===(o=this._$Ej)||void 0===o?void 0:o.get(e))&&!this.hasAttribute(s._$Eu(e,n))))return;this.C(e,t,n)}!1===this.isUpdatePending&&(this._$ES=this._$EP())}},{key:"C",value:function(e,t,{useDefault:n,reflect:i,wrapped:a},r){var o,s,u;n&&!(null!==(o=this._$Ej)&&void 0!==o?o:this._$Ej=new Map).has(e)&&(this._$Ej.set(e,null!==(s=null!=r?r:t)&&void 0!==s?s:this[e]),!0!==a||void 0!==r)||(this._$AL.has(e)||(this.hasUpdated||n||(t=void 0),this._$AL.set(e,t)),!0===i&&this._$Em!==e&&(null!==(u=this._$Eq)&&void 0!==u?u:this._$Eq=new Set).add(e))}},{key:"_$EP",value:function(){var e,t;return k(function(n){for(;;)switch(n.p=n.n){case 0:return this.isUpdatePending=!0,n.p=1,n.n=2,a(this._$ES);case 2:n.n=4;break;case 3:n.p=3,t=n.v,Promise.reject(t);case 4:if(e=this.scheduleUpdate(),!(null!=e)){n.n=5;break}return n.n=5,a(e);case 5:return n.a(2,!this.isUpdatePending)}},null,this,[[1,3]],Promise)}},{key:"scheduleUpdate",value:function(){return this.performUpdate()}},{key:"performUpdate",value:function(){if(this.isUpdatePending){if(!this.hasUpdated){var e;if(null!==(e=this.renderRoot)&&void 0!==e||(this.renderRoot=this.createRenderRoot()),this._$Ep){for(var t,n=h(this._$Ep);!(t=n()).done;){var i=t.value,a=i[0],r=i[1];this[a]=r}this._$Ep=void 0}var o=this.constructor.elementProperties;if(o.size>0)for(var s,u=h(o);!(s=u()).done;){var l=s.value,d=l[0],c=l[1],m=c.wrapped,f=this[d];!0!==m||this._$AL.has(d)||void 0===f||this.C(d,void 0,c,f)}}var v=!1,p=this._$AL;try{var g;(v=this.shouldUpdate(p))?(this.willUpdate(p),null!==(g=this._$EO)&&void 0!==g&&g.forEach(e=>{var t;return null===(t=e.hostUpdate)||void 0===t?void 0:t.call(e)}),this.update(p)):this._$EM()}catch(p){throw v=!1,this._$EM(),p}v&&this._$AE(p)}}},{key:"willUpdate",value:function(e){}},{key:"_$AE",value:function(e){var t;null!==(t=this._$EO)&&void 0!==t&&t.forEach(e=>{var t;return null===(t=e.hostUpdated)||void 0===t?void 0:t.call(e)}),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}},{key:"_$EM",value:function(){this._$AL=new Map,this.isUpdatePending=!1}},{key:"updateComplete",get:function(){return this.getUpdateComplete()}},{key:"getUpdateComplete",value:function(){return this._$ES}},{key:"shouldUpdate",value:function(e){return!0}},{key:"update",value:function(e){this._$Eq&&(this._$Eq=this._$Eq.forEach(e=>this._$ET(e,this[e]))),this._$EM()}},{key:"updated",value:function(e){}},{key:"firstUpdated",value:function(e){}}],[{key:"addInitializer",value:function(e){var t;this._$Ei(),(null!==(t=this.l)&&void 0!==t?t:this.l=[]).push(e)}},{key:"observedAttributes",get:function(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}},{key:"createProperty",value:function(e,t=gm){if(t.state&&(t.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(e)&&((t=Object.create(t)).wrapped=!0),this.elementProperties.set(e,t),!t.noAccessor){var n=Symbol(),i=this.getPropertyDescriptor(e,n,t);void 0!==i&&rm(this.prototype,e,i)}}},{key:"getPropertyDescriptor",value:function(e,t,n){var i,a=null!==(i=om(this.prototype,e))&&void 0!==i?i:{get(){return this[t]},set(e){this[t]=e}},r=a.get,o=a.set;return{get:r,set(t){var i=null==r?void 0:r.call(this);null!=o&&o.call(this,t),this.requestUpdate(e,i,n)},configurable:!0,enumerable:!0}}},{key:"getPropertyOptions",value:function(e){var t;return null!==(t=this.elementProperties.get(e))&&void 0!==t?t:gm}},{key:"_$Ei",value:function(){if(!this.hasOwnProperty(fm("elementProperties"))){var e=lm(this);e.finalize(),void 0!==e.l&&(this.l=[...e.l]),this.elementProperties=new Map(e.elementProperties)}}},{key:"finalize",value:function(){if(!this.hasOwnProperty(fm("finalized"))){if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(fm("properties")))for(var e=this.properties,t=0,n=[...sm(e),...um(e)];t<n.length;t++){var i=n[t];this.createProperty(i,e[i])}var a=this[Symbol.metadata];if(null!==a){var r=litPropertyMetadata.get(a);if(void 0!==r)for(var o,s=h(r);!(o=s()).done;){var u=o.value,l=u[0],d=u[1];this.elementProperties.set(l,d)}}this._$Eh=new Map;for(var c,m=h(this.elementProperties);!(c=m()).done;){var f=c.value,v=f[0],p=f[1],g=this._$Eu(v,p);void 0!==g&&this._$Eh.set(g,v)}this.elementStyles=this.finalizeStyles(this.styles)}}},{key:"finalizeStyles",value:function(e){var t=[];if(Array.isArray(e))for(var n,i=h(new Set(e.flat(1/0).reverse()));!(n=i()).done;){var a=n.value;t.unshift(im(a))}else void 0!==e&&t.push(im(e));return t}},{key:"_$Eu",value:function(e,t){var n=t.attribute;return!1===n?void 0:"string"==typeof n?n:"string"==typeof e?e.toLowerCase():void 0}}])}(M(HTMLElement));bm.elementStyles=[],bm.shadowRootOptions={mode:"open"},bm[fm("elementProperties")]=new Map,bm[fm("finalized")]=new Map,null!=mm&&mm({ReactiveElement:bm}),(null!==(Yh=dm.reactiveElementVersions)&&void 0!==Yh?Yh:dm.reactiveElementVersions=[]).push("2.1.2");var wm=globalThis,km=e=>e,Sm=wm.trustedTypes,Em=Sm?Sm.createPolicy("lit-html",{createHTML:e=>e}):void 0,Pm="$lit$",Tm=`lit$${Math.random().toFixed(9).slice(2)}$`,_m="?"+Tm,Mm=`<${_m}>`,Am=document,Dm=()=>Am.createComment(""),xm=e=>null===e||"object"!=typeof e&&"function"!=typeof e,Cm=Array.isArray,Im="[ \t\n\f\r]",Lm=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Rm=/-->/g,Fm=/>/g,Om=RegExp(`>|${Im}(?:([^\\s"'>=/]+)(${Im}*=${Im}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),$m=/'/g,Nm=/"/g,Wm=/^(?:script|style|textarea|title)$/i,jm=e=>(t,...n)=>({_$litType$:e,strings:t,values:n}),Bm=jm(1),zm=jm(2),Um=Symbol.for("lit-noChange"),Hm=Symbol.for("lit-nothing"),Gm=new WeakMap,Vm=Am.createTreeWalker(Am,129);function Km(e,t){if(!Cm(e)||!e.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==Em?Em.createHTML(t):t}var Xm=function(){return c(function e({strings:t,_$litType$:n},i){var a;o(this,e),this.parts=[];var r=0,s=0,u=t.length-1,l=this.parts,d=((e,t)=>{for(var n,i=e.length-1,a=[],r=2===t?"<svg>":3===t?"<math>":"",o=Lm,s=0;s<i;s++){for(var u=e[s],l=void 0,d=void 0,c=-1,h=0;h<u.length&&(o.lastIndex=h,null!==(d=o.exec(u)));)h=o.lastIndex,o===Lm?"!--"===d[1]?o=Rm:void 0!==d[1]?o=Fm:void 0!==d[2]?(Wm.test(d[2])&&(n=RegExp("</"+d[2],"g")),o=Om):void 0!==d[3]&&(o=Om):o===Om?">"===d[0]?(o=null!=n?n:Lm,c=-1):void 0===d[1]?c=-2:(c=o.lastIndex-d[2].length,l=d[1],o=void 0===d[3]?Om:'"'===d[3]?Nm:$m):o===Nm||o===$m?o=Om:o===Rm||o===Fm?o=Lm:(o=Om,n=void 0);var m=o===Om&&e[s+1].startsWith("/>")?" ":"";r+=o===Lm?u+Mm:c>=0?(a.push(l),u.slice(0,c)+Pm+u.slice(c)+Tm+m):u+Tm+(-2===c?s:m)}return[Km(e,r+(e[i]||"<?>")+(2===t?"</svg>":3===t?"</math>":"")),a]})(t,n),c=d[0],m=d[1];if(this.el=e.createElement(c,i),Vm.currentNode=this.el.content,2===n||3===n){var f=this.el.content.firstChild;f.replaceWith(...f.childNodes)}for(;null!==(a=Vm.nextNode())&&l.length<u;){if(1===a.nodeType){if(a.hasAttributes())for(var v,p=h(a.getAttributeNames());!(v=p()).done;){var g=v.value;if(g.endsWith(Pm)){var y=m[s++],b=a.getAttribute(g).split(Tm),w=/([.?@])?(.*)/.exec(y);l.push({type:1,index:r,name:w[2],strings:b,ctor:"."===w[1]?Zm:"?"===w[1]?ef:"@"===w[1]?tf:Qm}),a.removeAttribute(g)}else g.startsWith(Tm)&&(l.push({type:6,index:r}),a.removeAttribute(g))}if(Wm.test(a.tagName)){var k=a.textContent.split(Tm),S=k.length-1;if(S>0){a.textContent=Sm?Sm.emptyScript:"";for(var E=0;E<S;E++)a.append(k[E],Dm()),Vm.nextNode(),l.push({type:2,index:++r});a.append(k[S],Dm())}}}else if(8===a.nodeType)if(a.data===_m)l.push({type:2,index:r});else for(var P=-1;-1!==(P=a.data.indexOf(Tm,P+1));)l.push({type:7,index:r}),P+=Tm.length-1;r++}},null,[{key:"createElement",value:function(e,t){var n=Am.createElement("template");return n.innerHTML=e,n}}])}();function Ym(e,t,n=e,i){var a,r,o,s,u;if(t===Um)return t;var l=void 0!==i?null===(a=n._$Co)||void 0===a?void 0:a[i]:n._$Cl,d=xm(t)?void 0:t._$litDirective$;return(null===(r=l)||void 0===r?void 0:r.constructor)!==d&&(null!==(o=l)&&void 0!==o&&null!==(s=o._$AO)&&void 0!==s&&s.call(o,!1),void 0===d?l=void 0:(l=new d(e))._$AT(e,n,i),void 0!==i?(null!==(u=n._$Co)&&void 0!==u?u:n._$Co=[])[i]=l:n._$Cl=l),void 0!==l&&(t=Ym(e,l._$AS(e,t.values),l,i)),t}var qm=function(){return c(function e(t,n){o(this,e),this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=n},[{key:"parentNode",get:function(){return this._$AM.parentNode}},{key:"_$AU",get:function(){return this._$AM._$AU}},{key:"u",value:function(e){var t,n=this._$AD,i=n.el.content,a=n.parts,r=(null!==(t=null==e?void 0:e.creationScope)&&void 0!==t?t:Am).importNode(i,!0);Vm.currentNode=r;for(var o=Vm.nextNode(),s=0,u=0,l=a[0];void 0!==l;){var d;if(s===l.index){var c=void 0;2===l.type?c=new Jm(o,o.nextSibling,this,e):1===l.type?c=new l.ctor(o,l.name,l.strings,this,e):6===l.type&&(c=new nf(o,this,e)),this._$AV.push(c),l=a[++u]}s!==(null===(d=l)||void 0===d?void 0:d.index)&&(o=Vm.nextNode(),s++)}return Vm.currentNode=Am,r}},{key:"p",value:function(e){for(var t,n=0,i=h(this._$AV);!(t=i()).done;){var a=t.value;void 0!==a&&(void 0!==a.strings?(a._$AI(e,a,n),n+=a.strings.length-2):a._$AI(e[n])),n++}}}])}(),Jm=function(){return c(function e(t,n,i,a){var r;o(this,e),this.type=2,this._$AH=Hm,this._$AN=void 0,this._$AA=t,this._$AB=n,this._$AM=i,this.options=a,this._$Cv=null===(r=null==a?void 0:a.isConnected)||void 0===r||r},[{key:"_$AU",get:function(){var e,t;return null!==(e=null===(t=this._$AM)||void 0===t?void 0:t._$AU)&&void 0!==e?e:this._$Cv}},{key:"parentNode",get:function(){var e,t=this._$AA.parentNode,n=this._$AM;return void 0!==n&&11===(null===(e=t)||void 0===e?void 0:e.nodeType)&&(t=n.parentNode),t}},{key:"startNode",get:function(){return this._$AA}},{key:"endNode",get:function(){return this._$AB}},{key:"_$AI",value:function(e,t=this){e=Ym(this,e,t),xm(e)?e===Hm||null==e||""===e?(this._$AH!==Hm&&this._$AR(),this._$AH=Hm):e!==this._$AH&&e!==Um&&this._(e):void 0!==e._$litType$?this.$(e):void 0!==e.nodeType?this.T(e):(e=>Cm(e)||"function"==typeof(null==e?void 0:e[Symbol.iterator]))(e)?this.k(e):this._(e)}},{key:"O",value:function(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}},{key:"T",value:function(e){this._$AH!==e&&(this._$AR(),this._$AH=this.O(e))}},{key:"_",value:function(e){this._$AH!==Hm&&xm(this._$AH)?this._$AA.nextSibling.data=e:this.T(Am.createTextNode(e)),this._$AH=e}},{key:"$",value:function(e){var t,n=e.values,i=e._$litType$,a="number"==typeof i?this._$AC(e):(void 0===i.el&&(i.el=Xm.createElement(Km(i.h,i.h[0]),this.options)),i);if((null===(t=this._$AH)||void 0===t?void 0:t._$AD)===a)this._$AH.p(n);else{var r=new qm(a,this),o=r.u(this.options);r.p(n),this.T(o),this._$AH=r}}},{key:"_$AC",value:function(e){var t=Gm.get(e.strings);return void 0===t&&Gm.set(e.strings,t=new Xm(e)),t}},{key:"k",value:function(e){Cm(this._$AH)||(this._$AH=[],this._$AR());for(var t,n,i=this._$AH,a=0,r=h(e);!(n=r()).done;){var o=n.value;a===i.length?i.push(t=new _k(this.O(Dm()),this.O(Dm()),this,this.options)):t=i[a],t._$AI(o),a++}a<i.length&&(this._$AR(t&&t._$AB.nextSibling,a),i.length=a)}},{key:"_$AR",value:function(e=this._$AA.nextSibling,t){for(null===(n=this._$AP)||void 0===n||n.call(this,!1,!0,t);e!==this._$AB;){var n,i=km(e).nextSibling;km(e).remove(),e=i}}},{key:"setConnected",value:function(e){var t;void 0===this._$AM&&(this._$Cv=e,null===(t=this._$AP)||void 0===t||t.call(this,e))}}])}(),Qm=function(){return c(function e(t,n,i,a,r){o(this,e),this.type=1,this._$AH=Hm,this._$AN=void 0,this.element=t,this.name=n,this._$AM=a,this.options=r,i.length>2||""!==i[0]||""!==i[1]?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=Hm},[{key:"tagName",get:function(){return this.element.tagName}},{key:"_$AU",get:function(){return this._$AM._$AU}},{key:"_$AI",value:function(e,t=this,n,i){var a=this.strings,r=!1;if(void 0===a)e=Ym(this,e,t,0),(r=!xm(e)||e!==this._$AH&&e!==Um)&&(this._$AH=e);else{var o,s,u=e;for(e=a[0],o=0;o<a.length-1;o++)(s=Ym(this,u[n+o],t,o))===Um&&(s=this._$AH[o]),r||(r=!xm(s)||s!==this._$AH[o]),s===Hm?e=Hm:e!==Hm&&(e+=(null!=s?s:"")+a[o+1]),this._$AH[o]=s}r&&!i&&this.j(e)}},{key:"j",value:function(e){e===Hm?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,null!=e?e:"")}}])}(),Zm=function(e){function t(){var e;return o(this,t),(e=r(this,t,arguments)).type=3,e}return p(t,e),c(t,[{key:"j",value:function(e){this.element[this.name]=e===Hm?void 0:e}}])}(Qm),ef=function(e){function t(){var e;return o(this,t),(e=r(this,t,arguments)).type=4,e}return p(t,e),c(t,[{key:"j",value:function(e){this.element.toggleAttribute(this.name,!!e&&e!==Hm)}}])}(Qm),tf=function(e){function t(e,n,i,a,s){var u;return o(this,t),(u=r(this,t,[e,n,i,a,s])).type=5,u}return p(t,e),c(t,[{key:"_$AI",value:function(e,t=this){var n;if((e=null!==(n=Ym(this,e,t,0))&&void 0!==n?n:Hm)!==Um){var i=this._$AH,a=e===Hm&&i!==Hm||e.capture!==i.capture||e.once!==i.once||e.passive!==i.passive,r=e!==Hm&&(i===Hm||a);a&&this.element.removeEventListener(this.name,this,i),r&&this.element.addEventListener(this.name,this,e),this._$AH=e}}},{key:"handleEvent",value:function(e){var t,n;"function"==typeof this._$AH?this._$AH.call(null!==(t=null===(n=this.options)||void 0===n?void 0:n.host)&&void 0!==t?t:this.element,e):this._$AH.handleEvent(e)}}])}(Qm),nf=function(){return c(function e(t,n,i){o(this,e),this.element=t,this.type=6,this._$AN=void 0,this._$AM=n,this.options=i},[{key:"_$AU",get:function(){return this._$AM._$AU}},{key:"_$AI",value:function(e){Ym(this,e)}}])}(),af={I:Jm},rf=wm.litHtmlPolyfillSupport;null!=rf&&rf(Xm,Jm),(null!==(ym=wm.litHtmlVersions)&&void 0!==ym?ym:wm.litHtmlVersions=[]).push("3.3.3");var of,sf,uf=globalThis,lf=function(e){function t(){var e;return o(this,t),(e=r(this,t,arguments)).renderOptions={host:i(e)},e._$Do=void 0,e}return p(t,e),c(t,[{key:"createRenderRoot",value:function(){var e,n,i=T(t,"createRenderRoot",this)([]);return null!==(n=(e=this.renderOptions).renderBefore)&&void 0!==n||(e.renderBefore=i.firstChild),i}},{key:"update",value:function(e){var n=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),T(t,"update",this)([e]),this._$Do=((e,t,n)=>{var i,a=null!==(i=null==n?void 0:n.renderBefore)&&void 0!==i?i:t,r=a._$litPart$;if(void 0===r){var o,s=null!==(o=null==n?void 0:n.renderBefore)&&void 0!==o?o:null;a._$litPart$=r=new Jm(t.insertBefore(Dm(),s),s,void 0,null!=n?n:{})}return r._$AI(e),r})(n,this.renderRoot,this.renderOptions)}},{key:"connectedCallback",value:function(){var e;T(t,"connectedCallback",this)([]),null===(e=this._$Do)||void 0===e||e.setConnected(!0)}},{key:"disconnectedCallback",value:function(){var e;T(t,"disconnectedCallback",this)([]),null===(e=this._$Do)||void 0===e||e.setConnected(!1)}},{key:"render",value:function(){return Um}}])}(bm);lf._$litElement$=!0,lf.finalized=!0,null===(of=uf.litElementHydrateSupport)||void 0===of||of.call(uf,{LitElement:lf});var df=uf.litElementPolyfillSupport;null==df||df({LitElement:lf}),(null!==(sf=uf.litElementVersions)&&void 0!==sf?sf:uf.litElementVersions=[]).push("4.2.2");var cf,hf,mf=nm(cf||(cf=(e=>e)`
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).NamiWebSdk={})}(this,function(e){"use strict";function t(e,t){this.v=e,this.k=t}function n(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=Array(t);n<t;n++)i[n]=e[n];return i}function i(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function a(e){return new t(e,0)}function r(e,t,n){return t=v(t),b(e,g()?Reflect.construct(t,n||[],v(e).constructor):t.apply(e,n))}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function s(e,t){if(!{}.hasOwnProperty.call(e,t))throw new TypeError("attempted to use private field on non-instance");return e}(()=>{if("undefined"==typeof globalThis){var e="undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:Function("return this")();Object.defineProperty(e,"globalThis",{value:e,writable:!0,enumerable:!1,configurable:!0})}})(),"undefined"!=typeof Element&&"function"!=typeof Element.prototype.getAttributeNames&&(Element.prototype.getAttributeNames=function(){for(var e=this.attributes,t=new Array(e.length),n=0;n<e.length;n+=1)t[n]=e[n].name;return t});var u=0;function l(e){return"__private_"+u+++"_"+e}function d(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,_(i.key),i)}}function c(e,t,n){return t&&d(e.prototype,t),n&&d(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function h(e,t){var i="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(i)return(i=i.call(e)).next.bind(i);if(Array.isArray(e)||(i=function(e,t){if(e){if("string"==typeof e)return n(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?n(e,t):void 0}}(e))||t){i&&(e=i);var a=0;return function(){return a>=e.length?{done:!0}:{done:!1,value:e[a++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function m(){return m=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)({}).hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},m.apply(null,arguments)}function f(){return f="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,n){var i=function(e,t){for(;!{}.hasOwnProperty.call(e,t)&&null!==(e=v(e)););return e}(e,t);if(i){var a=Object.getOwnPropertyDescriptor(i,t);return a.get?a.get.call(arguments.length<3?e:n):a.value}},f.apply(null,arguments)}function v(e){return v=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},v(e)}function p(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&P(e,t)}function g(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(g=function(){return!!e})()}function y(e,t){if(null==e)return{};var n={};for(var i in e)if({}.hasOwnProperty.call(e,i)){if(-1!==t.indexOf(i))continue;n[i]=e[i]}return n}function b(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return i(e)}function w(){var e,t,n="function"==typeof Symbol?Symbol:{},i=n.iterator||"@@iterator",a=n.toStringTag||"@@toStringTag";function r(n,i,a,r){var u=i&&i.prototype instanceof s?i:s,l=Object.create(u.prototype);return E(l,"_invoke",function(n,i,a){var r,s,u,l=0,d=a||[],c=!1,h={p:0,n:0,v:e,a:m,f:m.bind(e,4),d:function(t,n){return r=t,s=0,u=e,h.n=n,o}};function m(n,i){for(s=n,u=i,t=0;!c&&l&&!a&&t<d.length;t++){var a,r=d[t],m=h.p,f=r[2];n>3?(a=f===i)&&(u=r[(s=r[4])?5:(s=3,3)],r[4]=r[5]=e):r[0]<=m&&((a=n<2&&m<r[1])?(s=0,h.v=i,h.n=r[1]):m<f&&(a=n<3||r[0]>i||i>f)&&(r[4]=n,r[5]=i,h.n=f,s=0))}if(a||n>1)return o;throw c=!0,i}return function(a,d,f){if(l>1)throw TypeError("Generator is already running");for(c&&1===d&&m(d,f),s=d,u=f;(t=s<2?e:u)||!c;){r||(s?s<3?(s>1&&(h.n=-1),m(s,u)):h.n=u:h.v=u);try{if(l=2,r){if(s||(a="next"),t=r[a]){if(!(t=t.call(r,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,s<2&&(s=0)}else 1===s&&(t=r.return)&&t.call(r),s<2&&(u=TypeError("The iterator does not provide a '"+a+"' method"),s=1);r=e}else if((t=(c=h.n<0)?u:n.call(i,h))!==o)break}catch(t){r=e,s=1,u=t}finally{l=1}}return{value:t,done:c}}}(n,a,r),!0),l}var o={};function s(){}function u(){}function l(){}t=Object.getPrototypeOf;var d=[][i]?t(t([][i]())):(E(t={},i,function(){return this}),t),c=l.prototype=s.prototype=Object.create(d);function h(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,l):(e.__proto__=l,E(e,a,"GeneratorFunction")),e.prototype=Object.create(c),e}return u.prototype=l,E(c,"constructor",l),E(l,"constructor",u),u.displayName="GeneratorFunction",E(l,a,"GeneratorFunction"),E(c),E(c,a,"Generator"),E(c,i,function(){return this}),E(c,"toString",function(){return"[object Generator]"}),(w=function(){return{w:r,m:h}})()}function k(e,t,n,i,a){var r=function(e,t,n,i,a){return new S(w().w(e,t,n,i),a||Promise)}(e,t,n,i,a);return r.next().then(function(e){return e.done?e.value:r.next()})}function S(e,n){function i(a,r,o,s){try{var u=e[a](r),l=u.value;return l instanceof t?n.resolve(l.v).then(function(e){i("next",e,o,s)},function(e){i("throw",e,o,s)}):n.resolve(l).then(function(e){u.value=e,o(u)},function(e){return i("throw",e,o,s)})}catch(e){s(e)}}var a;this.next||(E(S.prototype),E(S.prototype,"function"==typeof Symbol&&Symbol.asyncIterator||"@asyncIterator",function(){return this})),E(this,"_invoke",function(e,t,r){function o(){return new n(function(t,n){i(e,r,t,n)})}return a=a?a.then(o,o):o()},!0)}function E(e,t,n,i){var a=Object.defineProperty;try{a({},"",{})}catch(e){a=0}E=function(e,t,n,i){function r(t,n){E(e,t,function(e){return this._invoke(t,n,e)})}t?a?a(e,t,{value:n,enumerable:!i,configurable:!i,writable:!i}):e[t]=n:(r("next",0),r("throw",1),r("return",2))},E(e,t,n,i)}function P(e,t){return P=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},P(e,t)}function T(e,t,n,i){var a=f(v(e.prototype),t,n);return"function"==typeof a?function(e){return a.apply(n,e)}:a}function _(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,t);if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e,"string");return"symbol"==typeof t?t:t+""}function M(e){var t="function"==typeof Map?new Map:void 0;return M=function(e){if(null===e||!function(e){try{return-1!==Function.toString.call(e).indexOf("[native code]")}catch(t){return"function"==typeof e}}(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return function(e,t,n){if(g())return Reflect.construct.apply(null,arguments);var i=[null];i.push.apply(i,t);var a=new(e.bind.apply(e,i));return n&&P(a,n.prototype),a}(e,arguments,v(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),P(n,e)},M(e)}var A,D,x,C,I,L,R,F,O,$,N,W,j=function(){return c(function e(t){o(this,e),this.ariaActiveDescendantElement=null,this.ariaAtomic="",this.ariaAutoComplete="",this.ariaBrailleLabel="",this.ariaBrailleRoleDescription="",this.ariaBusy="",this.ariaChecked="",this.ariaColCount="",this.ariaColIndex="",this.ariaColIndexText="",this.ariaColSpan="",this.ariaControlsElements=null,this.ariaCurrent="",this.ariaDescribedByElements=null,this.ariaDescription="",this.ariaDetailsElements=null,this.ariaDisabled="",this.ariaErrorMessageElements=null,this.ariaExpanded="",this.ariaFlowToElements=null,this.ariaHasPopup="",this.ariaHidden="",this.ariaInvalid="",this.ariaKeyShortcuts="",this.ariaLabel="",this.ariaLabelledByElements=null,this.ariaLevel="",this.ariaLive="",this.ariaModal="",this.ariaMultiLine="",this.ariaMultiSelectable="",this.ariaOrientation="",this.ariaOwnsElements=null,this.ariaPlaceholder="",this.ariaPosInSet="",this.ariaPressed="",this.ariaReadOnly="",this.ariaRelevant="",this.ariaRequired="",this.ariaRoleDescription="",this.ariaRowCount="",this.ariaRowIndex="",this.ariaRowIndexText="",this.ariaRowSpan="",this.ariaSelected="",this.ariaSetSize="",this.ariaSort="",this.ariaValueMax="",this.ariaValueMin="",this.ariaValueNow="",this.ariaValueText="",this.role="",this.form=null,this.labels=[],this.states=new Set,this.validationMessage="",this.validity={},this.willValidate=!0,this.__host=t},[{key:"shadowRoot",get:function(){return this.__host.__shadowRoot}},{key:"checkValidity",value:function(){return console.warn("`ElementInternals.checkValidity()` was called on the server.This method always returns true."),!0}},{key:"reportValidity",value:function(){return!0}},{key:"setFormValue",value:function(){}},{key:"setValidity",value:function(){}}])}(),B=function(e,t,n,i,a){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!a)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!a:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?a.call(e,n):a?a.value=n:t.set(e,n),n},z=function(e,t,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(e):i?i.value:t.get(e)},U={__proto__:null,enumerable:!0};Object.freeze(U);var H=($=function(){return c(function e(t,n={}){if(o(this,e),A.set(this,!1),D.set(this,!1),x.set(this,!1),C.set(this,!1),I.set(this,Date.now()),L.set(this,!1),R.set(this,void 0),F.set(this,void 0),O.set(this,void 0),this.NONE=0,this.CAPTURING_PHASE=1,this.AT_TARGET=2,this.BUBBLING_PHASE=3,0===arguments.length)throw new Error("The type argument must be specified");if("object"!=typeof n||!n)throw new Error('The "options" argument must be an object');var i=n.bubbles,a=n.cancelable,r=n.composed;B(this,A,!!a,"f"),B(this,D,!!i,"f"),B(this,x,!!r,"f"),B(this,R,`${t}`,"f"),B(this,F,null,"f"),B(this,O,!1,"f")},[{key:"initEvent",value:function(e,t,n){throw new Error("Method not implemented.")}},{key:"stopImmediatePropagation",value:function(){this.stopPropagation()}},{key:"preventDefault",value:function(){B(this,C,!0,"f")}},{key:"target",get:function(){return z(this,F,"f")}},{key:"currentTarget",get:function(){return z(this,F,"f")}},{key:"srcElement",get:function(){return z(this,F,"f")}},{key:"type",get:function(){return z(this,R,"f")}},{key:"cancelable",get:function(){return z(this,A,"f")}},{key:"defaultPrevented",get:function(){return z(this,A,"f")&&z(this,C,"f")}},{key:"timeStamp",get:function(){return z(this,I,"f")}},{key:"composedPath",value:function(){return z(this,O,"f")?[z(this,F,"f")]:[]}},{key:"returnValue",get:function(){return!z(this,A,"f")||!z(this,C,"f")}},{key:"bubbles",get:function(){return z(this,D,"f")}},{key:"composed",get:function(){return z(this,x,"f")}},{key:"eventPhase",get:function(){return z(this,O,"f")?$.AT_TARGET:$.NONE}},{key:"cancelBubble",get:function(){return z(this,L,"f")},set:function(e){e&&B(this,L,!0,"f")}},{key:"stopPropagation",value:function(){B(this,L,!0,"f")}},{key:"isTrusted",get:function(){return!1}}])}(),A=new WeakMap,D=new WeakMap,x=new WeakMap,C=new WeakMap,I=new WeakMap,L=new WeakMap,R=new WeakMap,F=new WeakMap,O=new WeakMap,$.NONE=0,$.CAPTURING_PHASE=1,$.AT_TARGET=2,$.BUBBLING_PHASE=3,$);Object.defineProperties(H.prototype,{initEvent:U,stopImmediatePropagation:U,preventDefault:U,target:U,currentTarget:U,srcElement:U,type:U,cancelable:U,defaultPrevented:U,timeStamp:U,composedPath:U,returnValue:U,bubbles:U,composed:U,eventPhase:U,cancelBubble:U,stopPropagation:U,isTrusted:U});var G=(W=function(e){function t(e,n={}){var i,a;return o(this,t),a=r(this,t,[e,n]),N.set(a,void 0),B(a,N,null!==(i=null==n?void 0:n.detail)&&void 0!==i?i:null,"f"),a}return p(t,e),c(t,[{key:"initCustomEvent",value:function(e,t,n,i){throw new Error("Method not implemented.")}},{key:"detail",get:function(){return z(this,N,"f")}}])}(H),N=new WeakMap,W);Object.defineProperties(G.prototype,{detail:U});var V,K,X,Y,q=H,J=G;(V=function(){return c(function e(){o(this,e),this.STYLE_RULE=1,this.CHARSET_RULE=2,this.IMPORT_RULE=3,this.MEDIA_RULE=4,this.FONT_FACE_RULE=5,this.PAGE_RULE=6,this.NAMESPACE_RULE=10,this.KEYFRAMES_RULE=7,this.KEYFRAME_RULE=8,this.SUPPORTS_RULE=12,this.COUNTER_STYLE_RULE=11,this.FONT_FEATURE_VALUES_RULE=14,this.MARGIN_RULE=9,this.__parentStyleSheet=null,this.cssText=""},[{key:"parentRule",get:function(){return null}},{key:"parentStyleSheet",get:function(){return this.__parentStyleSheet}},{key:"type",get:function(){return 0}}])}()).STYLE_RULE=1,V.CHARSET_RULE=2,V.IMPORT_RULE=3,V.MEDIA_RULE=4,V.FONT_FACE_RULE=5,V.PAGE_RULE=6,V.NAMESPACE_RULE=10,V.KEYFRAMES_RULE=7,V.KEYFRAME_RULE=8,V.SUPPORTS_RULE=12,V.COUNTER_STYLE_RULE=11,V.FONT_FEATURE_VALUES_RULE=14,V.MARGIN_RULE=9,null!==(K=globalThis.Event)&&void 0!==K||(globalThis.Event=q),null!==(X=globalThis.CustomEvent)&&void 0!==X||(globalThis.CustomEvent=J);var Q=Symbol(),Z=e=>{var t;return"boolean"==typeof e?e:null!==(t=null==e?void 0:e.capture)&&void 0!==t&&t},ee={__proto__:null,enumerable:!0};Object.freeze(ee);var te=function(){return c(function e(){o(this,e),this.__eventListeners=new Map,this.__captureEventListeners=new Map},[{key:"addEventListener",value:function(e,t,n){var i;if(null!=t){var a=Z(n)?this.__captureEventListeners:this.__eventListeners,r=a.get(e);if(void 0===r)r=new Map,a.set(e,r);else if(r.has(t))return;var o="object"==typeof n&&n?n:{};null===(i=o.signal)||void 0===i||i.addEventListener("abort",()=>this.removeEventListener(e,t,n)),r.set(t,null!=o?o:{})}}},{key:"removeEventListener",value:function(e,t,n){if(null!=t){var i=Z(n)?this.__captureEventListeners:this.__eventListeners,a=i.get(e);void 0!==a&&(a.delete(t),a.size||i.delete(e))}}},{key:"dispatchEvent",value:function(e){var t=this.__resolveFullEventPath();!e.composed&&this.__host&&(t=t.slice(0,t.indexOf(this.__host)));var n=!1,i=!1,a=q.NONE,r=null,o=null,s=null,u=e.stopPropagation,l=e.stopImmediatePropagation;Object.defineProperties(e,{target:m({get:()=>null!=r?r:o},ee),srcElement:m({get:()=>e.target},ee),currentTarget:m({get:()=>s},ee),eventPhase:m({get:()=>a},ee),composedPath:m({value:()=>t},ee),stopPropagation:m({value:()=>{n=!0,u.call(e)}},ee),stopImmediatePropagation:m({value:()=>{i=!0,l.call(e)}},ee)});var d=(t,n,i)=>{"function"==typeof t?t(e):"function"==typeof(null==t?void 0:t.handleEvent)&&t.handleEvent(e),n.once&&i.delete(t)},c=()=>(s=null,a=q.NONE,!e.defaultPrevented),f=t.slice().reverse();r=this.__host&&e.composed?null:this;for(var v,p=e=>{for(o=this;o.__host&&e.includes(o.__host);)o=o.__host},g=h(f);!(v=g()).done;){var y=v.value;r||o&&o!==y.__host||p(f.slice(f.indexOf(y))),s=y,a=y===e.target?q.AT_TARGET:q.CAPTURING_PHASE;var b=y.__captureEventListeners.get(e.type);if(b)for(var w,k=h(b);!(w=k()).done;){var S=w.value;if(d(S[0],S[1],b),i)return c()}if(n)return c()}var E=e.bubbles?t:[this];o=null;for(var P,T=h(E);!(P=T()).done;){var _=P.value;r||o&&_!==o.__host||p(E.slice(0,E.indexOf(_)+1)),s=_,a=_===e.target?q.AT_TARGET:q.BUBBLING_PHASE;var M=_.__eventListeners.get(e.type);if(M)for(var A,D=h(M);!(A=D()).done;){var x=A.value;if(d(x[0],x[1],M),i)return c()}if(n)return c()}return c()}},{key:"__resolveFullEventPath",value:function(){return this.__eventPathCache?this.__eventPathCache:this.__eventTargetParent?this.__eventPathCache=[this,...this.__eventTargetParent.__resolveFullEventPath()]:this.__eventPathCache=[this,oe,pe]}}])}(),ne=new WeakMap,ie=e=>{var t=ne.get(e);return void 0===t&&ne.set(e,t=new Map),t},ae=function(e){function t(){return o(this,t),r(this,t,arguments)}return p(t,e),c(t,[{key:"getRootNode",value:function(e){var t;if(null!=e&&e.composed)return se;var n=this.__host;return null!==(t=null==n?void 0:n.__shadowRoot)&&void 0!==t?t:se}}])}(te),re=function(e){function t(){return o(this,t),r(this,t,arguments)}return p(t,e),c(t,[{key:"adoptedStyleSheets",get:function(){return[]}},{key:"createTreeWalker",value:function(){return{}}},{key:"createTextNode",value:function(){return{}}},{key:"createElement",value:function(){return{}}}])}(ae),oe=new re,se=oe,ue=function(e){function t(e){var n;if(o(this,t),n=r(this,t),e!==Q)throw new TypeError("Illegal constructor");return Object.assign(n,globalThis,{CustomElementRegistry:fe,customElements:ve,document:se,Document:re,Element:le,EventTarget:te,HTMLElement:de,Node:ae,ShadowRoot:he,window:n,Window:ue}),n}return p(t,e),c(t)}(ae),le=function(e){function t(){var e;return o(this,t),(e=r(this,t,arguments)).__shadowRootMode=null,e.__shadowRoot=null,e.__internals=null,e}return p(t,e),c(t,[{key:"attributes",get:function(){return Array.from(ie(this)).map(([e,t])=>({name:e,value:t}))}},{key:"shadowRoot",get:function(){return"closed"===this.__shadowRootMode?null:this.__shadowRoot}},{key:"localName",get:function(){return this.constructor.__localName}},{key:"tagName",get:function(){var e;return null===(e=this.localName)||void 0===e?void 0:e.toUpperCase()}},{key:"setAttribute",value:function(e,t){ie(this).set(e,String(t))}},{key:"removeAttribute",value:function(e){ie(this).delete(e)}},{key:"toggleAttribute",value:function(e,t){return this.hasAttribute(e)?!(void 0===t||!t)||(this.removeAttribute(e),!1):!(void 0!==t&&!t)&&(this.setAttribute(e,""),!0)}},{key:"hasAttribute",value:function(e){return ie(this).has(e)}},{key:"attachShadow",value:function(e){this.__shadowRootMode=e.mode;var t=new he(Q,e);return t.__eventTargetParent=this,t.__host=this,this.__shadowRoot=t}},{key:"attachInternals",value:function(){if(null!==this.__internals)throw new Error("Failed to execute 'attachInternals' on 'HTMLElement': ElementInternals for the specified element was already attached.");var e=new j(this);return this.__internals=e,e}},{key:"getAttribute",value:function(e){var t=ie(this).get(e);return null!=t?t:null}}])}(ae),de=function(e){function t(){return o(this,t),r(this,t,arguments)}return p(t,e),c(t)}(le),ce=de,he=function(e){function t(e,n){var i;if(o(this,t),i=r(this,t),e!=e)throw new TypeError("Illegal constructor");return i.mode=n.mode,i}return p(t,e),c(t,[{key:"host",get:function(){return this.__host}}])}(ae);function me(){var e,t;return{promise:new Promise((n,i)=>{e=n,t=i}),resolve:e,reject:t}}null!==(Y=globalThis.litServerRoot)&&void 0!==Y||(globalThis.litServerRoot=Object.defineProperty(new ce,"localName",{get:()=>"lit-server-root"}));var fe=function(){return c(function e(){o(this,e),this.__definitions=new Map,this.__reverseDefinitions=new Map,this.__pendingWhenDefineds=new Map},[{key:"define",value:function(e,t){var n,i;if(this.__definitions.has(e)){if("development"!==process.env.NODE_ENV)throw new Error(`Failed to execute 'define' on 'CustomElementRegistry': the name "${e}" has already been used with this registry`);console.warn(`'CustomElementRegistry' already has "${e}" defined. This may have been caused by live reload or hot module replacement in which case it can be safely ignored.\nMake sure to test your application with a production build as repeat registrations will throw in production.`)}if(this.__reverseDefinitions.has(t))throw new Error(`Failed to execute 'define' on 'CustomElementRegistry': the constructor has already been used with this registry for the tag name ${this.__reverseDefinitions.get(t)}`);t.__localName=e,this.__definitions.set(e,{ctor:t,observedAttributes:null!==(n=t.observedAttributes)&&void 0!==n?n:[]}),this.__reverseDefinitions.set(t,e),null===(i=this.__pendingWhenDefineds.get(e))||void 0===i||i.resolve(t),this.__pendingWhenDefineds.delete(e)}},{key:"get",value:function(e){var t=this.__definitions.get(e);return null==t?void 0:t.ctor}},{key:"getName",value:function(e){var t;return null!==(t=this.__reverseDefinitions.get(e))&&void 0!==t?t:null}},{key:"initialize",value:function(e){throw new Error("customElements.initialize is not currently supported in SSR. Please file a bug if you need it.")}},{key:"upgrade",value:function(e){throw new Error("customElements.upgrade is not currently supported in SSR. Please file a bug if you need it.")}},{key:"whenDefined",value:function(e){var t,n;return k(function(i){for(;;)switch(i.n){case 0:if(!(t=this.__definitions.get(e))){i.n=1;break}return i.a(2,t.ctor);case 1:return(n=this.__pendingWhenDefineds.get(e))||(n=me(),this.__pendingWhenDefineds.set(e,n)),i.a(2,n.promise)}},null,this,null,Promise)}}])}(),ve=new fe,pe=new ue(Q);"undefined"==typeof HTMLElement&&(globalThis.HTMLElement=ce);var ge=["action"],ye=null;var be={storage:{getItem:()=>null,setItem:()=>{},removeItem:()=>{},clear:()=>{},getAllKeys:()=>[]},device:{getDeviceData:()=>({os_version:"",os_name:"",browser_name:"",browser_version:"",sdk_client:"",sdk_version:"",language:"en"}),getDeviceFormFactor:()=>"desktop",getDeviceScaleFactor:()=>1,generateUUID:()=>{throw new Error("No platform adapter registered — call registerPlatformAdapters() before Nami.configure()")},getScreenInfo:()=>({width:0,height:0,scale:1}),getLanguage:()=>"en"},ui:{createPaywall:()=>null,reRenderPaywall:()=>{},flowNavigateToScreen:()=>{}}};function we(){return null!=ye?ye:be}function ke(e,t,n,i){var a,r=arguments.length,o=r<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,n,i);else for(var s=e.length-1;s>=0;s--)(a=e[s])&&(o=(r<3?a(o):r>3?a(t,n,o):a(t,n))||o);return r>3&&o&&Object.defineProperty(t,n,o),o}function Se(e,t,n,i){if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(e):i?i.value:t.get(e)}function Ee(e,t,n,i,a){if("function"==typeof t||!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return t.set(e,n),n}"function"==typeof SuppressedError&&SuppressedError;var Pe;!function(e){e.SDK="sdk",e.ML="ml",e.THIRD_PARTY_ANALYTICS="third_party_analytics",e.THIRD_PARTY_TRANSACTIONS="third_party_transactions",e.PAYWALL_PERSONALIZATION="paywall_personalization",e.ANONYMOUS_MODE_CAPABILITY="anonymous_allowed",e.LANGUAGE_MANAGEMENT="language_management",e.ENTITLEMENT_MANAGEMENT="entitlement_management"}(Pe||(Pe={}));var Te,_e={},Me=_e.NAMI_SDK_VERSION,Ae=void 0===Me?"3.4.6":Me,De=_e.NAMI_SDK_PACKAGE_VERSION,xe=void 0===De?"3.4.6-dev.202607171421":De,Ce=_e.PLATFORM_ID_REQUIRED,Ie=void 0===Ce?"Platform ID is required":Ce,Le=_e.DEVICE_ID_REQUIRED,Re=void 0===Le?"Device ID is required":Le,Fe=_e.EXTERNAL_ID_REQUIRED,Oe=void 0===Fe?"External ID is required":Fe,$e=_e.SDK_NOT_INITIALIZED,Ne=void 0===$e?"SDK has not been initialized. Make sure to call Nami.configure() first!":$e,We=_e.CAMPAIGN_NOT_AVAILABLE,je=void 0===We?"Campaign is not available":We,Be=_e.FLOW_SCREENS_NOT_AVAILABLE,ze=void 0===Be?"Flow screens not available":Be,Ue=_e.UNABLE_TO_UPDATE_CDP_ID,He=void 0===Ue?"Unable to update CDP id in anonymous mode":Ue,Ge=_e.ANONYMOUS_MODE_ALREADY_ON,Ve=void 0===Ge?"Anonymous mode is already turned on.":Ge,Ke=_e.ANONYMOUS_MODE_ALREADY_OFF,Xe=void 0===Ke?"Anonymous mode is already turned off.":Ke,Ye=_e.DEVICE_ID_NOT_SET,qe=void 0===Ye?"Nami Device ID is not set":Ye,Je=_e.AUTH_DEVICE,Qe=void 0===Je?"nami_auth_device":Je,Ze=_e.NAMI_CONFIGURATION,et=void 0===Ze?"nami_configuration":Ze,tt=_e.NAMI_PROFILE,nt=void 0===tt?"nami_profile":tt,it=_e.API_CONFIG,at=void 0===it?"api_config":it,rt=_e.API_CAMPAIGN_RULES,ot=void 0===rt?"api_campaign_rules":rt,st=_e.API_PAYWALLS,ut=void 0===st?"api_paywalls":st,lt=_e.API_CAMPAIGN_SESSION_TIMESTAMP,dt=void 0===lt?"api_campaign_session_timestamp":lt,ct=_e.API_PRODUCTS,ht=void 0===ct?"api_products":ct,mt=_e.API_ACTIVE_ENTITLEMENTS,ft=void 0===mt?"api_active_entitlements":mt,vt=_e.SERVER_NAMI_ENTITLEMENTS,pt=void 0===vt?"server_active_entitlements":vt,gt=_e.INITIAL_APP_CONFIG,yt=void 0===gt?"initial_app_config":gt,bt=_e.INITIAL_CAMPAIGN_RULES,wt=void 0===bt?"initial_campaign_rules":bt,kt=_e.INITIAL_PAYWALLS,St=void 0===kt?"initial_paywalls":kt,Et=_e.INITIAL_PRODUCTS,Pt=void 0===Et?"initial_products":Et,Tt=_e.LOCAL_NAMI_ENTITLEMENTS,_t=void 0===Tt?"local_active_entitlements":Tt,Mt=_e.CUSTOMER_ATTRIBUTES_KEY_PREFIX,At=void 0===Mt?"nami_cmr_attributes_":Mt,Dt=_e.NAMI_CUSTOMER_JOURNEY_STATE,xt=void 0===Dt?"nami_customer_journey_state":Dt,Ct=_e.ANONYMOUS_MODE,It=void 0===Ct?"nami_anonymous_mode_v2":Ct,Lt=_e.ANONYMOUS_UUID,Rt=void 0===Lt?"nami_anonymous_uuid":Lt,Ft=_e.KEY_SESSION_COUNTER,Ot=void 0===Ft?"nami_session_counter":Ft,$t=_e.INITIAL_SESSION_COUNTER_VALUE,Nt=void 0===$t?1:$t,Wt=_e.NAMI_LAST_IMPRESSION_ID,jt=void 0===Wt?"nami_last_impression_id":Wt,Bt=_e.NAMI_PURCHASE_IMPRESSION_ID,zt=void 0===Bt?"nami_purchase_impression_id":Bt,Ut=_e.NAMI_LAUNCH_ID,Ht=void 0===Ut?"nami_launch_id":Ut,Gt=_e.NAMI_SESSION_ID,Vt=void 0===Gt?"nami_session_id":Gt,Kt=_e.NAMI_LANGUAGE_CODE,Xt=void 0===Kt?"nami_language_code":Kt,Yt=_e.NAMI_PURCHASE_CHANNEL,qt=void 0===Yt?"nami_purchase_channel":Yt,Jt=_e.API_VERSION,Qt=_e.BASE_URL_PATH,Zt=void 0===Qt?`sdk/${void 0===Jt?"v3":Jt}/platform`:Qt,en=_e.BASE_URL,tn=void 0===en?"https://app.namiml.com":en,nn=_e.BASE_STAGING_URL,an=void 0===nn?"https://app-staging.namiml.com":nn,rn=_e.CUSTOM_HOST_PREFIX,on=void 0===rn?"namiAPIHost=":rn,sn=_e.USE_STAGING_API,un=void 0===sn?"useStagingAPI":sn,ln=_e.EXTENDED_CLIENT_INFO_PREFIX,dn=void 0===ln?"extendedClientInfo":ln,cn=_e.EXTENDED_CLIENT_INFO_DELIMITER,hn=void 0===cn?":":cn,mn=_e.VALIDATE_PRODUCT_GROUPS,fn=void 0===mn?"validateProductGroups":mn,vn=_e.LOG_HTTP_REQUESTS,pn=void 0===vn?"logHTTPRequests":vn,gn=_e.LOG_HTTP_TRAFFIC,yn=void 0===gn?"logHTTPTraffic":gn,bn=_e.STARTUP_TELEMETRY,wn=void 0===bn?"startupTelemetry":bn,kn=_e.API_MAX_CALLS_LIMIT,Sn=void 0===kn?2:kn,En=_e.API_RETRY_DELAY_SEC,Pn=void 0===En?2:En,Tn=_e.API_TIMEOUT_LIMIT,_n=void 0===Tn?2e4:Tn,Mn=_e.DEVICE_API_TIMEOUT_LIMIT,An=void 0===Mn?2e3:Mn,Dn=_e.STATUS_BAD_REQUEST,xn=void 0===Dn?400:Dn,Cn=_e.STATUS_NOT_FOUND,In=void 0===Cn?404:Cn,Ln=_e.STATUS_CONFLICT,Rn=void 0===Ln?409:Ln,Fn=_e.STATUS_INTERNAL_SERVER_ERROR,On=void 0===Fn?500:Fn,$n=_e.INITIAL_SUCCESS,Nn=void 0===$n?"Initial success":$n,Wn=_e.RECONFIG_SUCCESS,jn=void 0===Wn?"Reconfig success":Wn,Bn=_e.ALREADY_CONFIGURED,zn=void 0===Bn?"Already configured":Bn,Un=_e.AVAILABLE_CAMPAIGNS_CHANGED,Hn=void 0===Un?"AvailableCampaignsChanged":Un,Gn=_e.PAYWALL_ACTION_EVENT,Vn=void 0===Gn?"PaywallActionEvent":Gn,Kn=_e.AVAILABLE_ACTIVE_ENTITLEMENTS_CHANGED,Xn=void 0===Kn?"AvailableActiveEntitlementsChanged":Kn,Yn=_e.CUSTOMER_JOURNEY_STATE_CHANGED,qn=void 0===Yn?"CustomerJourneyStateChanged":Yn,Jn=_e.SKU_TEXT_REGEX,Qn=void 0===Jn?/\$\{sku\.(\w+)(:\d+)?\}/g:Jn,Zn=_e.VAR_REGEX,ei=void 0===Zn?/\$\{\s*(\w+(\.[a-zA-Z\d_:${}-]{0,99})*?)\s*}/g:Zn,ti=_e.SMART_TEXT_PATTERN,ni=void 0===ti?"${":ti,ii=_e.LIQUID_VARIABLE_REGEX,ai=void 0===ii?/\${[A-Za-z0-9.]+}/g:ii,ri=[Qe,et,nt,at,ot,ut,dt,ht,ft,pt,yt,wt,St,Pt,_t,xt,It,Rt,Ot,jt,zt,Ht,Vt,Xt,qt];e.LogLevel=void 0,(Te=e.LogLevel||(e.LogLevel={}))[Te.DEBUG=1]="DEBUG",Te[Te.INFO=2]="INFO",Te[Te.WARN=3]="WARN",Te[Te.ERROR=4]="ERROR";var oi={debug:e.LogLevel.DEBUG,info:e.LogLevel.INFO,warn:e.LogLevel.WARN,error:e.LogLevel.ERROR},si=function(){return c(function t(){o(this,t),this.currentLogLevel=e.LogLevel.DEBUG,this.setLogger=t=>{this.currentLogLevel=t?oi[t]:e.LogLevel.WARN}},[{key:"debug",value:function(t,...n){this.shouldLog(e.LogLevel.DEBUG)&&console.debug(this.formatMessage(e.LogLevel.DEBUG,t,...n))}},{key:"info",value:function(t,...n){this.shouldLog(e.LogLevel.INFO)&&console.info(this.formatMessage(e.LogLevel.INFO,t,...n))}},{key:"warn",value:function(t,...n){this.shouldLog(e.LogLevel.WARN)&&console.warn(this.formatMessage(e.LogLevel.WARN,t,...n))}},{key:"error",value:function(t,...n){this.shouldLog(e.LogLevel.ERROR)&&console.error(this.formatMessage(e.LogLevel.ERROR,t,...n))}},{key:"shouldLog",value:function(e){return e>=this.currentLogLevel}},{key:"formatMessage",value:function(t,n,...i){var a=e.LogLevel[t];return`[${(new Date).toISOString()}] [${a}] ${n} ${i=i.map(e=>"object"==typeof e?JSON.stringify(e):e)}`}}])}(),ui=new si;function li(e){for(var t=-1,n=null==e?0:e.length,i=0,a=[];++t<n;){var r=e[t];r&&(a[i++]=r)}return a}function di(e,t){return e===t||e!=e&&t!=t}function ci(e,t){for(var n=e.length;n--;)if(di(e[n][0],t))return n;return-1}var hi=Array.prototype.splice;function mi(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var i=e[t];this.set(i[0],i[1])}}mi.prototype.clear=function(){this.__data__=[],this.size=0},mi.prototype.delete=function(e){var t=this.__data__,n=ci(t,e);return!(n<0)&&(n==t.length-1?t.pop():hi.call(t,n,1),--this.size,!0)},mi.prototype.get=function(e){var t=this.__data__,n=ci(t,e);return n<0?void 0:t[n][1]},mi.prototype.has=function(e){return ci(this.__data__,e)>-1},mi.prototype.set=function(e,t){var n=this.__data__,i=ci(n,e);return i<0?(++this.size,n.push([e,t])):n[i][1]=t,this};var fi="object"==typeof global&&global&&global.Object===Object&&global,vi="object"==typeof self&&self&&self.Object===Object&&self,pi=fi||vi||Function("return this")(),gi=pi.Symbol,yi=Object.prototype,bi=yi.hasOwnProperty,wi=yi.toString,ki=gi?gi.toStringTag:void 0;var Si=Object.prototype.toString;var Ei=gi?gi.toStringTag:void 0;function Pi(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":Ei&&Ei in Object(e)?function(e){var t=bi.call(e,ki),n=e[ki];try{e[ki]=void 0;var i=!0}catch(e){}var a=wi.call(e);return i&&(t?e[ki]=n:delete e[ki]),a}(e):function(e){return Si.call(e)}(e)}function Ti(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function _i(e){if(!Ti(e))return!1;var t=Pi(e);return"[object Function]"==t||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t}var Mi,Ai=pi["__core-js_shared__"],Di=(Mi=/[^.]+$/.exec(Ai&&Ai.keys&&Ai.keys.IE_PROTO||""))?"Symbol(src)_1."+Mi:"";var xi=Function.prototype.toString;function Ci(e){if(null!=e){try{return xi.call(e)}catch(e){}try{return e+""}catch(e){}}return""}var Ii=/^\[object .+?Constructor\]$/,Li=Function.prototype,Ri=Object.prototype,Fi=Li.toString,Oi=Ri.hasOwnProperty,$i=RegExp("^"+Fi.call(Oi).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Ni(e){return!(!Ti(e)||(t=e,Di&&Di in t))&&(_i(e)?$i:Ii).test(Ci(e));var t}function Wi(e,t){var n=function(e,t){return null==e?void 0:e[t]}(e,t);return Ni(n)?n:void 0}var ji=Wi(pi,"Map"),Bi=Wi(Object,"create");var zi=Object.prototype.hasOwnProperty;var Ui=Object.prototype.hasOwnProperty;function Hi(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var i=e[t];this.set(i[0],i[1])}}function Gi(e,t){var n,i,a=e.__data__;return("string"==(i=typeof(n=t))||"number"==i||"symbol"==i||"boolean"==i?"__proto__"!==n:null===n)?a["string"==typeof t?"string":"hash"]:a.map}function Vi(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var i=e[t];this.set(i[0],i[1])}}Hi.prototype.clear=function(){this.__data__=Bi?Bi(null):{},this.size=0},Hi.prototype.delete=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},Hi.prototype.get=function(e){var t=this.__data__;if(Bi){var n=t[e];return"__lodash_hash_undefined__"===n?void 0:n}return zi.call(t,e)?t[e]:void 0},Hi.prototype.has=function(e){var t=this.__data__;return Bi?void 0!==t[e]:Ui.call(t,e)},Hi.prototype.set=function(e,t){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=Bi&&void 0===t?"__lodash_hash_undefined__":t,this},Vi.prototype.clear=function(){this.size=0,this.__data__={hash:new Hi,map:new(ji||mi),string:new Hi}},Vi.prototype.delete=function(e){var t=Gi(this,e).delete(e);return this.size-=t?1:0,t},Vi.prototype.get=function(e){return Gi(this,e).get(e)},Vi.prototype.has=function(e){return Gi(this,e).has(e)},Vi.prototype.set=function(e,t){var n=Gi(this,e),i=n.size;return n.set(e,t),this.size+=n.size==i?0:1,this};function Ki(e){var t=this.__data__=new mi(e);this.size=t.size}Ki.prototype.clear=function(){this.__data__=new mi,this.size=0},Ki.prototype.delete=function(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n},Ki.prototype.get=function(e){return this.__data__.get(e)},Ki.prototype.has=function(e){return this.__data__.has(e)},Ki.prototype.set=function(e,t){var n=this.__data__;if(n instanceof mi){var i=n.__data__;if(!ji||i.length<199)return i.push([e,t]),this.size=++n.size,this;n=this.__data__=new Vi(i)}return n.set(e,t),this.size=n.size,this};function Xi(e){var t=-1,n=null==e?0:e.length;for(this.__data__=new Vi;++t<n;)this.add(e[t])}function Yi(e,t){for(var n=-1,i=null==e?0:e.length;++n<i;)if(t(e[n],n,e))return!0;return!1}function qi(e,t){return e.has(t)}Xi.prototype.add=Xi.prototype.push=function(e){return this.__data__.set(e,"__lodash_hash_undefined__"),this},Xi.prototype.has=function(e){return this.__data__.has(e)};function Ji(e,t,n,i,a,r){var o=1&n,s=e.length,u=t.length;if(s!=u&&!(o&&u>s))return!1;var l=r.get(e),d=r.get(t);if(l&&d)return l==t&&d==e;var c=-1,h=!0,m=2&n?new Xi:void 0;for(r.set(e,t),r.set(t,e);++c<s;){var f=e[c],v=t[c];if(i)var p=o?i(v,f,c,t,e,r):i(f,v,c,e,t,r);if(void 0!==p){if(p)continue;h=!1;break}if(m){if(!Yi(t,function(e,t){if(!qi(m,t)&&(f===e||a(f,e,n,i,r)))return m.push(t)})){h=!1;break}}else if(f!==v&&!a(f,v,n,i,r)){h=!1;break}}return r.delete(e),r.delete(t),h}var Qi=pi.Uint8Array;function Zi(e){var t=-1,n=Array(e.size);return e.forEach(function(e,i){n[++t]=[i,e]}),n}function ea(e){var t=-1,n=Array(e.size);return e.forEach(function(e){n[++t]=e}),n}var ta=gi?gi.prototype:void 0,na=ta?ta.valueOf:void 0;var ia=Array.isArray;var aa=Object.prototype.propertyIsEnumerable,ra=Object.getOwnPropertySymbols,oa=ra?function(e){return null==e?[]:(e=Object(e),function(e,t){for(var n=-1,i=null==e?0:e.length,a=0,r=[];++n<i;){var o=e[n];t(o,n,e)&&(r[a++]=o)}return r}(ra(e),function(t){return aa.call(e,t)}))}:function(){return[]};function sa(e){return null!=e&&"object"==typeof e}function ua(e){return sa(e)&&"[object Arguments]"==Pi(e)}var la=Object.prototype,da=la.hasOwnProperty,ca=la.propertyIsEnumerable,ha=ua(function(){return arguments}())?ua:function(e){return sa(e)&&da.call(e,"callee")&&!ca.call(e,"callee")};var ma="object"==typeof e&&e&&!e.nodeType&&e,fa=ma&&"object"==typeof module&&module&&!module.nodeType&&module,va=fa&&fa.exports===ma?pi.Buffer:void 0,pa=(va?va.isBuffer:void 0)||function(){return!1},ga=/^(?:0|[1-9]\d*)$/;function ya(e,t){var n=typeof e;return!!(t=t??9007199254740991)&&("number"==n||"symbol"!=n&&ga.test(e))&&e>-1&&e%1==0&&e<t}function ba(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991}var wa={};function ka(e){return function(t){return e(t)}}wa["[object Float32Array]"]=wa["[object Float64Array]"]=wa["[object Int8Array]"]=wa["[object Int16Array]"]=wa["[object Int32Array]"]=wa["[object Uint8Array]"]=wa["[object Uint8ClampedArray]"]=wa["[object Uint16Array]"]=wa["[object Uint32Array]"]=!0,wa["[object Arguments]"]=wa["[object Array]"]=wa["[object ArrayBuffer]"]=wa["[object Boolean]"]=wa["[object DataView]"]=wa["[object Date]"]=wa["[object Error]"]=wa["[object Function]"]=wa["[object Map]"]=wa["[object Number]"]=wa["[object Object]"]=wa["[object RegExp]"]=wa["[object Set]"]=wa["[object String]"]=wa["[object WeakMap]"]=!1;var Sa="object"==typeof e&&e&&!e.nodeType&&e,Ea=Sa&&"object"==typeof module&&module&&!module.nodeType&&module,Pa=Ea&&Ea.exports===Sa&&fi.process,Ta=function(){try{var e=Ea&&Ea.require&&Ea.require("util").types;return e||Pa&&Pa.binding&&Pa.binding("util")}catch(e){}}(),_a=Ta&&Ta.isTypedArray,Ma=_a?ka(_a):function(e){return sa(e)&&ba(e.length)&&!!wa[Pi(e)]},Aa=Object.prototype.hasOwnProperty;function Da(e,t){var n=ia(e),i=!n&&ha(e),a=!n&&!i&&pa(e),r=!n&&!i&&!a&&Ma(e),o=n||i||a||r,s=o?function(e,t){for(var n=-1,i=Array(e);++n<e;)i[n]=t(n);return i}(e.length,String):[],u=s.length;for(var l in e)!Aa.call(e,l)||o&&("length"==l||a&&("offset"==l||"parent"==l)||r&&("buffer"==l||"byteLength"==l||"byteOffset"==l)||ya(l,u))||s.push(l);return s}var xa=Object.prototype;function Ca(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||xa)}function Ia(e,t){return function(n){return e(t(n))}}var La=Ia(Object.keys,Object),Ra=Object.prototype.hasOwnProperty;function Fa(e){return null!=(t=e)&&ba(t.length)&&!_i(t)?Da(e):function(e){if(!Ca(e))return La(e);var t=[];for(var n in Object(e))Ra.call(e,n)&&"constructor"!=n&&t.push(n);return t}(e);var t}function Oa(e){return function(e,t,n){var i=t(e);return ia(e)?i:function(e,t){for(var n=-1,i=t.length,a=e.length;++n<i;)e[a+n]=t[n];return e}(i,n(e))}(e,Fa,oa)}var $a=Object.prototype.hasOwnProperty;var Na=Wi(pi,"DataView"),Wa=Wi(pi,"Promise"),ja=Wi(pi,"Set"),Ba=Wi(pi,"WeakMap"),za="[object Map]",Ua="[object Promise]",Ha="[object Set]",Ga="[object WeakMap]",Va="[object DataView]",Ka=Ci(Na),Xa=Ci(ji),Ya=Ci(Wa),qa=Ci(ja),Ja=Ci(Ba),Qa=Pi;(Na&&Qa(new Na(new ArrayBuffer(1)))!=Va||ji&&Qa(new ji)!=za||Wa&&Qa(Wa.resolve())!=Ua||ja&&Qa(new ja)!=Ha||Ba&&Qa(new Ba)!=Ga)&&(Qa=function(e){var t=Pi(e),n="[object Object]"==t?e.constructor:void 0,i=n?Ci(n):"";if(i)switch(i){case Ka:return Va;case Xa:return za;case Ya:return Ua;case qa:return Ha;case Ja:return Ga}return t});var Za="[object Arguments]",er="[object Array]",tr="[object Object]",nr=Object.prototype.hasOwnProperty;function ir(e,t,n,i,a,r){var o=ia(e),s=ia(t),u=o?er:Qa(e),l=s?er:Qa(t),d=(u=u==Za?tr:u)==tr,c=(l=l==Za?tr:l)==tr,h=u==l;if(h&&pa(e)){if(!pa(t))return!1;o=!0,d=!1}if(h&&!d)return r||(r=new Ki),o||Ma(e)?Ji(e,t,n,i,a,r):function(e,t,n,i,a,r,o){switch(n){case"[object DataView]":if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case"[object ArrayBuffer]":return!(e.byteLength!=t.byteLength||!r(new Qi(e),new Qi(t)));case"[object Boolean]":case"[object Date]":case"[object Number]":return di(+e,+t);case"[object Error]":return e.name==t.name&&e.message==t.message;case"[object RegExp]":case"[object String]":return e==t+"";case"[object Map]":var s=Zi;case"[object Set]":var u=1&i;if(s||(s=ea),e.size!=t.size&&!u)return!1;var l=o.get(e);if(l)return l==t;i|=2,o.set(e,t);var d=Ji(s(e),s(t),i,a,r,o);return o.delete(e),d;case"[object Symbol]":if(na)return na.call(e)==na.call(t)}return!1}(e,t,u,n,i,a,r);if(!(1&n)){var m=d&&nr.call(e,"__wrapped__"),f=c&&nr.call(t,"__wrapped__");if(m||f){var v=m?e.value():e,p=f?t.value():t;return r||(r=new Ki),a(v,p,n,i,r)}}return!!h&&(r||(r=new Ki),function(e,t,n,i,a,r){var o=1&n,s=Oa(e),u=s.length;if(u!=Oa(t).length&&!o)return!1;for(var l=u;l--;){var d=s[l];if(!(o?d in t:$a.call(t,d)))return!1}var c=r.get(e),h=r.get(t);if(c&&h)return c==t&&h==e;var m=!0;r.set(e,t),r.set(t,e);for(var f=o;++l<u;){var v=e[d=s[l]],p=t[d];if(i)var g=o?i(p,v,d,t,e,r):i(v,p,d,e,t,r);if(!(void 0===g?v===p||a(v,p,n,i,r):g)){m=!1;break}f||(f="constructor"==d)}if(m&&!f){var y=e.constructor,b=t.constructor;y==b||!("constructor"in e)||!("constructor"in t)||"function"==typeof y&&y instanceof y&&"function"==typeof b&&b instanceof b||(m=!1)}return r.delete(e),r.delete(t),m}(e,t,n,i,a,r))}function ar(e,t,n,i,a){return e===t||(null==e||null==t||!sa(e)&&!sa(t)?e!=e&&t!=t:ir(e,t,n,i,ar,a))}function rr(e){return e==e&&!Ti(e)}function or(e,t){return function(n){return null!=n&&(n[e]===t&&(void 0!==t||e in Object(n)))}}function sr(e){var t=function(e){for(var t=Fa(e),n=t.length;n--;){var i=t[n],a=e[i];t[n]=[i,a,rr(a)]}return t}(e);return 1==t.length&&t[0][2]?or(t[0][0],t[0][1]):function(n){return n===e||function(e,t,n,i){var a=n.length,r=a;if(null==e)return!r;for(e=Object(e);a--;){var o=n[a];if(o[2]?o[1]!==e[o[0]]:!(o[0]in e))return!1}for(;++a<r;){var s=(o=n[a])[0],u=e[s],l=o[1];if(o[2]){if(void 0===u&&!(s in e))return!1}else if(!ar(l,u,3,i,new Ki))return!1}return!0}(n,0,t)}}function ur(e){return"symbol"==typeof e||sa(e)&&"[object Symbol]"==Pi(e)}var lr=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,dr=/^\w*$/;function cr(e,t){if(ia(e))return!1;var n=typeof e;return!("number"!=n&&"symbol"!=n&&"boolean"!=n&&null!=e&&!ur(e))||(dr.test(e)||!lr.test(e)||null!=t&&e in Object(t))}function hr(e,t){if("function"!=typeof e||null!=t&&"function"!=typeof t)throw new TypeError("Expected a function");var n=function(){var i=arguments,a=t?t.apply(this,i):i[0],r=n.cache;if(r.has(a))return r.get(a);var o=e.apply(this,i);return n.cache=r.set(a,o)||r,o};return n.cache=new(hr.Cache||Vi),n}hr.Cache=Vi;var mr,fr,vr,pr=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,gr=/\\(\\)?/g,yr=(mr=function(e){var t=[];return 46===e.charCodeAt(0)&&t.push(""),e.replace(pr,function(e,n,i,a){t.push(i?a.replace(gr,"$1"):n||e)}),t},fr=hr(mr,function(e){return 500===vr.size&&vr.clear(),e}),vr=fr.cache,fr);var br=gi?gi.prototype:void 0,wr=br?br.toString:void 0;function kr(e){if("string"==typeof e)return e;if(ia(e))return function(e,t){for(var n=-1,i=null==e?0:e.length,a=Array(i);++n<i;)a[n]=t(e[n],n,e);return a}(e,kr)+"";if(ur(e))return wr?wr.call(e):"";var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}function Sr(e,t){return ia(e)?e:cr(e,t)?[e]:yr(function(e){return null==e?"":kr(e)}(e))}function Er(e){if("string"==typeof e||ur(e))return e;var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}function Pr(e,t){for(var n=0,i=(t=Sr(t,e)).length;null!=e&&n<i;)e=e[Er(t[n++])];return n&&n==i?e:void 0}function Tr(e,t){return null!=e&&t in Object(e)}function _r(e,t){return null!=e&&function(e,t,n){for(var i=-1,a=(t=Sr(t,e)).length,r=!1;++i<a;){var o=Er(t[i]);if(!(r=null!=e&&n(e,o)))break;e=e[o]}return r||++i!=a?r:!!(a=null==e?0:e.length)&&ba(a)&&ya(o,a)&&(ia(e)||ha(e))}(e,t,Tr)}function Mr(e,t){return cr(e)&&rr(t)?or(Er(e),t):function(n){var i=function(e,t,n){var i=null==e?void 0:Pr(e,t);return void 0===i?n:i}(n,e);return void 0===i&&i===t?_r(n,e):ar(t,i,3)}}function Ar(e){return e}function Dr(e){return cr(e)?(t=Er(e),function(e){return null==e?void 0:e[t]}):function(e){return function(t){return Pr(t,e)}}(e);var t}function xr(e){return e!=e}function Cr(e,t){return!!(null==e?0:e.length)&&function(e,t,n){return t==t?function(e,t,n){for(var i=n-1,a=e.length;++i<a;)if(e[i]===t)return i;return-1}(e,t,n):function(e,t,n){for(var i=e.length,a=n+-1;++a<i;)if(t(e[a],a,e))return a;return-1}(e,xr,n)}(e,t,0)>-1}var Ir=ja&&1/ea(new ja([,-0]))[1]==1/0?function(e){return new ja(e)}:function(){};function Lr(e,t){return e&&e.length?function(e,t,n){var i=-1,a=Cr,r=e.length,o=!0,s=[],u=s;if(r>=200){var l=t?null:Ir(e);if(l)return ea(l);o=!1,a=qi,u=new Xi}else u=t?[]:s;e:for(;++i<r;){var d=e[i],c=t?t(d):d;if(d=0!==d?d:0,o&&c==c){for(var h=u.length;h--;)if(u[h]===c)continue e;t&&u.push(c),s.push(d)}else a(u,c,n)||(u!==s&&u.push(c),s.push(d))}return s}(e,"function"==typeof(n=t)?n:null==n?Ar:"object"==typeof n?ia(n)?Mr(n[0],n[1]):sr(n):Dr(n)):[];var n}var Rr=function(){return c(function e(){o(this,e),this.memoryStore={}},[{key:"storage",get:function(){return we().storage}},{key:"setDevice",value:function(e){this.setItem(Qe,e)}},{key:"getDevice",value:function(){return this.getItem(Qe)}},{key:"resetDevice",value:function(){this.resetItem(Qe)}},{key:"getAnonymousMode",value:function(){return this.getItem(It)||!1}},{key:"setAnonymousMode",value:function(e){this.setItem(It,e)}},{key:"clearAnonymousMode",value:function(){this.resetItem(It)}},{key:"setAppConfig",value:function(e,t){this.setItem(e,t)}},{key:"getAppConfig",value:function(e){return this.getItem(e)}},{key:"setLanguageCode",value:function(e){this.setItem(Xt,e||"en")}},{key:"getLanguageCode",value:function(){return this.getItem(Xt)||"en"}},{key:"setCampaignRules",value:function(e,t){e!==wt?e!==ot||0!==this.getCampaignCacheTtl()?this.setItem(e,t):this.memoryStore[ot]=JSON.stringify(t):this.memoryStore[wt]=JSON.stringify(t)}},{key:"getCampaignRules",value:function(e){if(e===wt)return this.memoryStore[wt]?JSON.parse(this.memoryStore[wt]):null;if(e===ot){var t=this.memoryStore[ot];if(null!=t)return JSON.parse(t);var n=this.getItem(ot);if(null===n)return null;if("string"==typeof n)try{n=JSON.parse(n)}catch(e){return n}return this.isLegacyTimestampedCache(n)?n.data:n}return this.getItem(e)}},{key:"setPaywalls",value:function(e,t){e!==St?e!==ut||0!==this.getCampaignCacheTtl()?this.setItem(e,t):this.memoryStore[ut]=JSON.stringify(t):this.memoryStore[St]=JSON.stringify(t)}},{key:"getPaywalls",value:function(e){if(e===St)return this.memoryStore[St]?JSON.parse(this.memoryStore[St]):null;if(e===ut){var t=this.memoryStore[ut];if(null!=t)return JSON.parse(t);var n=this.getItem(ut);if(null===n)return null;if("string"==typeof n)try{n=JSON.parse(n)}catch(e){return n}return this.isLegacyTimestampedCache(n)?n.data:n}return this.getItem(e)}},{key:"setActiveEntitlements",value:function(e,t){this.setItem(e,t)}},{key:"getActiveEntitlements",value:function(e){return this.getItem(e)||[]}},{key:"setNamiEntitlements",value:function(e,t){this.setItem(e,t)}},{key:"getNamiEntitlements",value:function(e){return this.getItem(e)||[]}},{key:"setProducts",value:function(e,t){this.setItem(e,t)}},{key:"getProducts",value:function(e){return this.getItem(e)}},{key:"getCachedProducts",value:function(){var e,t,n=null!==(e=this.getItem(ht))&&void 0!==e?e:[];return Lr(li([...null!==(t=this.getItem(Pt))&&void 0!==t?t:[],...n]),"sku_ref_id")}},{key:"setNamiConfig",value:function(e){this.setItem(et,e)}},{key:"getNamiConfig",value:function(){return this.getItem(et)}},{key:"setCustomerAttribute",value:function(e,t){this.setItem(At+e,t)}},{key:"getCustomerAttribute",value:function(e){return this.getItem(At+e)}},{key:"getAllCustomerAttributes",value:function(){return this.storage.getAllKeys().map(e=>[e,this.storage.getItem(e)]).filter(([e])=>e.includes(At)).map(([e,t])=>e.replace(At,"")+":"+t)}},{key:"getAllCustomerAttributesKeys",value:function(){return this.storage.getAllKeys().filter(e=>e.includes(At)).map(e=>e.replace(At,""))}},{key:"getAllCustomerAttributesMap",value:function(){var e={};return this.getAllCustomerAttributesKeys().forEach(t=>{var n=this.getCustomerAttribute(t);null!=n&&(e[t]=String(n))}),e}},{key:"clearCustomerAttribute",value:function(e){var t=At+e,n=this.getItem(t);return n&&this.resetItem(t),!!n}},{key:"clearAllCustomerAttributes",value:function(){this.storage.getAllKeys().filter(e=>e.includes(At)).map(e=>this.resetItem(e))}},{key:"setNamiProfile",value:function(e){this.setItem(nt,e)}},{key:"getNamiProfile",value:function(){return this.getItem(nt)}},{key:"removeNamiProfile",value:function(){this.resetItem(nt)}},{key:"setCustomerJourneyState",value:function(e){this.setItem(xt,e)}},{key:"getCustomerJourneyState",value:function(){return this.getItem(xt)}},{key:"setSessionCounter",value:function(){var e=this.getItem(Ot),t=e?parseInt(e):Nt||Nt;this.setItem(Ot,t+1)}},{key:"getSessionCounter",value:function(){var e=this.getItem(Ot);return e?parseInt(e):Nt}},{key:"setLastImpressionId",value:function(e){this.setItem(jt,e)}},{key:"getLastImpressionId",value:function(){var e;return null!==(e=this.getItem(jt))&&void 0!==e?e:""}},{key:"setPurchaseImpression",value:function(){var e,t=null!==(e=this.getLastImpressionId())&&void 0!==e?e:"";this.setItem(zt,t)}},{key:"getPurchaseImpression",value:function(){var e;return null!==(e=this.getItem(zt))&&void 0!==e?e:""}},{key:"setSessionId",value:function(e){e&&this.setItem(Vt,e)}},{key:"getSessionId",value:function(){var e;return null!==(e=this.getItem(Vt))&&void 0!==e?e:""}},{key:"clearSessionId",value:function(){this.resetItem(Vt)}},{key:"setLaunchId",value:function(e){e&&this.setItem(Ht,e)}},{key:"getLaunchId",value:function(){var e;return null!==(e=this.getItem(Ht))&&void 0!==e?e:""}},{key:"clearLaunchId",value:function(){this.resetItem(Ht)}},{key:"setPurchaseChannel",value:function(e){e&&this.setItem(qt,e)}},{key:"getPurchaseChannel",value:function(){return this.getItem(qt)}},{key:"getAnonymousUUID",value:function(){return this.getItem(Rt)}},{key:"setAnonymousUUID",value:function(e){this.setItem(Rt,e)}},{key:"clearAnonymousUUID",value:function(){this.resetItem(Rt)}},{key:"setApiCampaignSessionTimestamp",value:function(){this.setItem(dt,Date.now())}},{key:"getApiCampaignSessionTimestamp",value:function(){return this.getItem(dt)}},{key:"purgeApiCampaignCache",value:function(){this.resetItem(ut),this.resetItem(ot),this.resetItem(dt)}},{key:"getCampaignCacheTtl",value:function(){var e,t=this.getAppConfig(at)||this.getAppConfig(yt);return null!==(e=null==t?void 0:t.campaign_cache_ttl)&&void 0!==e?e:null}},{key:"isLegacyTimestampedCache",value:function(e){return"object"==typeof e&&null!==e&&"cachedAt"in e&&"data"in e}},{key:"setItem",value:function(e,t){var n;try{n=JSON.stringify(t)}catch(t){return void ui.error(`Serialization failed for ${e}`,t)}try{this.storage.setItem(e,n)}catch(t){ui.error("Error setting item in localStorage:",t),this.resetItem(e),this.memoryStore[e]=n}}},{key:"getItem",value:function(e){try{var t=this.storage.getItem(e);if(null!==t)return JSON.parse(t)}catch(t){ui.error("Error getting item from localStorage:",e,": ",t)}var n=this.memoryStore[e];return null!=n?JSON.parse(n):null}},{key:"resetItem",value:function(e){try{this.storage.removeItem(e)}catch(t){ui.error("Error removing item from localStorage:",e,": ",t)}delete this.memoryStore[e]}},{key:"clearAll",value:function(){ri.forEach(e=>this.resetItem(e)),this.clearAllCustomerAttributes(),this.memoryStore={}}},{key:"clear",value:function(){try{this.storage.clear()}catch(e){ui.error("Error clearing localStorage:",e)}this.memoryStore={}}}])}(),Fr=new Rr,Or=function(e){function t(e,n){var i;return o(this,t),(i=r(this,t,[n])).statusCode=e,i.status=e,i.message=`RetryLimitExceededError: ${i.message}`,i}return p(t,e),c(t)}(M(Error)),$r=function(e){function t(){return o(this,t),r(this,t,arguments)}return p(t,e),c(t)}(M(Error)),Nr=function(e){function t(){var e;return o(this,t),(e=r(this,t)).status=409,e.name="ConflictError",e.message="ConflictError: Server responded with conflict",e}return p(t,e),c(t)}($r),Wr=function(e){function t(){return o(this,t),r(this,t,[Ne])}return p(t,e),c(t)}(M(Error)),jr=function(e){function t(){return o(this,t),r(this,t,[Ie])}return p(t,e),c(t)}(M(Error)),Br=function(e){function t(){return o(this,t),r(this,t,[Re])}return p(t,e),c(t)}(M(Error)),zr=function(e){function t(){return o(this,t),r(this,t,[Oe])}return p(t,e),c(t)}(M(Error)),Ur=function(e){function t(){return o(this,t),r(this,t,[je])}return p(t,e),c(t)}(M(Error)),Hr=function(e){function t(){return o(this,t),r(this,t,[ze])}return p(t,e),c(t)}(M(Error)),Gr=function(e){function t(){return o(this,t),r(this,t,[Ve])}return p(t,e),c(t)}(M(Error)),Vr=function(e){function t(){return o(this,t),r(this,t,[Xe])}return p(t,e),c(t)}(M(Error)),Kr=function(e){function t(){return o(this,t),r(this,t,[Xe])}return p(t,e),c(t)}(M(Error)),Xr=function(e){function t(){return o(this,t),r(this,t,[He])}return p(t,e),c(t)}(M(Error)),Yr=function(e){function t(e){var n;return o(this,t),(n=r(this,t,[e])).message=`BadRequestError: ${n.message}`,n}return p(t,e),c(t)}($r),qr=function(e){function t(e){var n;return o(this,t),(n=r(this,t,[e])).message=`NotFoundError: ${n.message}`,n}return p(t,e),c(t)}($r),Jr=function(e){function t(e,n){var i;return o(this,t),(i=r(this,t,[n])).statusCode=e,i.message=`ClientError: ${i.message}`,i}return p(t,e),c(t)}($r),Qr=function(e){function t(e){var n;return o(this,t),(n=r(this,t,[e])).message=`ServerError: ${n.message}`,n}return p(t,e),c(t)}($r),Zr=(e,t)=>{if(e==xn)throw new Yr(t);if(e==In)throw new qr(t);if(e==Rn)throw new Nr;if(e>xn&&e<On)throw new Jr(e,t);if(e>=On)throw new Qr(t)};function eo(e){for(var t=e.length;--t>=0;)e[t]=0}eo(new Array(576)),eo(new Array(60)),eo(new Array(512)),eo(new Array(256)),eo(new Array(29)),eo(new Array(30));var to=(e,t,n,i)=>{for(var a=65535&e,r=e>>>16&65535,o=0;0!==n;){n-=o=n>2e3?2e3:n;do{r=r+(a=a+t[i++]|0)|0}while(--o);a%=65521,r%=65521}return a|r<<16},no=new Uint32Array((()=>{for(var e,t=[],n=0;n<256;n++){e=n;for(var i=0;i<8;i++)e=1&e?3988292384^e>>>1:e>>>1;t[n]=e}return t})()),io=(e,t,n,i)=>{var a=no,r=i+n;e^=-1;for(var o=i;o<r;o++)e=e>>>8^a[255&(e^t[o])];return-1^e},ao={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"},ro=0,oo=4,so=5,uo=6,lo=0,co=1,ho=2,mo=-2,fo=-3,vo=-4,po=-5,go=8,yo=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),bo=function(e){for(var t=Array.prototype.slice.call(arguments,1);t.length;){var n=t.shift();if(n){if("object"!=typeof n)throw new TypeError(n+"must be non-object");for(var i in n)yo(n,i)&&(e[i]=n[i])}}return e},wo=e=>{for(var t=0,n=0,i=e.length;n<i;n++)t+=e[n].length;for(var a=new Uint8Array(t),r=0,o=0,s=e.length;r<s;r++){var u=e[r];a.set(u,o),o+=u.length}return a},ko=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(e){ko=!1}for(var So=new Uint8Array(256),Eo=0;Eo<256;Eo++)So[Eo]=Eo>=252?6:Eo>=248?5:Eo>=240?4:Eo>=224?3:Eo>=192?2:1;So[254]=So[254]=1;var Po=e=>{if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(e);var t,n,i,a,r,o=e.length,s=0;for(a=0;a<o;a++)55296==(64512&(n=e.charCodeAt(a)))&&a+1<o&&56320==(64512&(i=e.charCodeAt(a+1)))&&(n=65536+(n-55296<<10)+(i-56320),a++),s+=n<128?1:n<2048?2:n<65536?3:4;for(t=new Uint8Array(s),r=0,a=0;r<s;a++)55296==(64512&(n=e.charCodeAt(a)))&&a+1<o&&56320==(64512&(i=e.charCodeAt(a+1)))&&(n=65536+(n-55296<<10)+(i-56320),a++),n<128?t[r++]=n:n<2048?(t[r++]=192|n>>>6,t[r++]=128|63&n):n<65536?(t[r++]=224|n>>>12,t[r++]=128|n>>>6&63,t[r++]=128|63&n):(t[r++]=240|n>>>18,t[r++]=128|n>>>12&63,t[r++]=128|n>>>6&63,t[r++]=128|63&n);return t},To=(e,t)=>{var n,i,a=t||e.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(e.subarray(0,t));var r=new Array(2*a);for(i=0,n=0;n<a;){var o=e[n++];if(o<128)r[i++]=o;else{var s=So[o];if(s>4)r[i++]=65533,n+=s-1;else{for(o&=2===s?31:3===s?15:7;s>1&&n<a;)o=o<<6|63&e[n++],s--;s>1?r[i++]=65533:o<65536?r[i++]=o:(o-=65536,r[i++]=55296|o>>10&1023,r[i++]=56320|1023&o)}}}return((e,t)=>{if(t<65534&&e.subarray&&ko)return String.fromCharCode.apply(null,e.length===t?e:e.subarray(0,t));for(var n="",i=0;i<t;i++)n+=String.fromCharCode(e[i]);return n})(r,i)},_o=(e,t)=>{(t=t||e.length)>e.length&&(t=e.length);for(var n=t-1;n>=0&&128==(192&e[n]);)n--;return n<0||0===n?t:n+So[e[n]]>t?n:t};var Mo=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},Ao=16209,Do=function(e,t){var n,i,a,r,o,s,u,l,d,c,h,m,f,v,p,g,y,b,w,k,S,E,P,T,_=e.state;n=e.next_in,P=e.input,i=n+(e.avail_in-5),a=e.next_out,T=e.output,r=a-(t-e.avail_out),o=a+(e.avail_out-257),s=_.dmax,u=_.wsize,l=_.whave,d=_.wnext,c=_.window,h=_.hold,m=_.bits,f=_.lencode,v=_.distcode,p=(1<<_.lenbits)-1,g=(1<<_.distbits)-1;e:do{m<15&&(h+=P[n++]<<m,m+=8,h+=P[n++]<<m,m+=8),y=f[h&p];t:for(;;){if(h>>>=b=y>>>24,m-=b,0===(b=y>>>16&255))T[a++]=65535&y;else{if(!(16&b)){if(64&b){if(32&b){_.mode=16191;break e}e.msg="invalid literal/length code",_.mode=Ao;break e}y=f[(65535&y)+(h&(1<<b)-1)];continue t}for(w=65535&y,(b&=15)&&(m<b&&(h+=P[n++]<<m,m+=8),w+=h&(1<<b)-1,h>>>=b,m-=b),m<15&&(h+=P[n++]<<m,m+=8,h+=P[n++]<<m,m+=8),y=v[h&g];;){if(h>>>=b=y>>>24,m-=b,16&(b=y>>>16&255)){if(k=65535&y,m<(b&=15)&&(h+=P[n++]<<m,(m+=8)<b&&(h+=P[n++]<<m,m+=8)),(k+=h&(1<<b)-1)>s){e.msg="invalid distance too far back",_.mode=Ao;break e}if(h>>>=b,m-=b,k>(b=a-r)){if((b=k-b)>l&&_.sane){e.msg="invalid distance too far back",_.mode=Ao;break e}if(S=0,E=c,0===d){if(S+=u-b,b<w){w-=b;do{T[a++]=c[S++]}while(--b);S=a-k,E=T}}else if(d<b){if(S+=u+d-b,(b-=d)<w){w-=b;do{T[a++]=c[S++]}while(--b);if(S=0,d<w){w-=b=d;do{T[a++]=c[S++]}while(--b);S=a-k,E=T}}}else if(S+=d-b,b<w){w-=b;do{T[a++]=c[S++]}while(--b);S=a-k,E=T}for(;w>2;)T[a++]=E[S++],T[a++]=E[S++],T[a++]=E[S++],w-=3;w&&(T[a++]=E[S++],w>1&&(T[a++]=E[S++]))}else{S=a-k;do{T[a++]=T[S++],T[a++]=T[S++],T[a++]=T[S++],w-=3}while(w>2);w&&(T[a++]=T[S++],w>1&&(T[a++]=T[S++]))}break}if(64&b){e.msg="invalid distance code",_.mode=Ao;break e}y=v[(65535&y)+(h&(1<<b)-1)]}}break}}while(n<i&&a<o);n-=w=m>>3,h&=(1<<(m-=w<<3))-1,e.next_in=n,e.next_out=a,e.avail_in=n<i?i-n+5:5-(n-i),e.avail_out=a<o?o-a+257:257-(a-o),_.hold=h,_.bits=m},xo=15,Co=new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0]),Io=new Uint8Array([16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78]),Lo=new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0]),Ro=new Uint8Array([16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64]),Fo=(e,t,n,i,a,r,o,s)=>{var u,l,d,c,h,m,f,v,p,g=s.bits,y=0,b=0,w=0,k=0,S=0,E=0,P=0,T=0,_=0,M=0,A=null,D=new Uint16Array(16),x=new Uint16Array(16),C=null;for(y=0;y<=xo;y++)D[y]=0;for(b=0;b<i;b++)D[t[n+b]]++;for(S=g,k=xo;k>=1&&0===D[k];k--);if(S>k&&(S=k),0===k)return a[r++]=20971520,a[r++]=20971520,s.bits=1,0;for(w=1;w<k&&0===D[w];w++);for(S<w&&(S=w),T=1,y=1;y<=xo;y++)if(T<<=1,(T-=D[y])<0)return-1;if(T>0&&(0===e||1!==k))return-1;for(x[1]=0,y=1;y<xo;y++)x[y+1]=x[y]+D[y];for(b=0;b<i;b++)0!==t[n+b]&&(o[x[t[n+b]]++]=b);if(0===e?(A=C=o,m=20):1===e?(A=Co,C=Io,m=257):(A=Lo,C=Ro,m=0),M=0,b=0,y=w,h=r,E=S,P=0,d=-1,c=(_=1<<S)-1,1===e&&_>852||2===e&&_>592)return 1;for(;;){f=y-P,o[b]+1<m?(v=0,p=o[b]):o[b]>=m?(v=C[o[b]-m],p=A[o[b]-m]):(v=96,p=0),u=1<<y-P,w=l=1<<E;do{a[h+(M>>P)+(l-=u)]=f<<24|v<<16|p}while(0!==l);for(u=1<<y-1;M&u;)u>>=1;if(0!==u?(M&=u-1,M+=u):M=0,b++,0===--D[y]){if(y===k)break;y=t[n+o[b]]}if(y>S&&(M&c)!==d){for(0===P&&(P=S),h+=w,T=1<<(E=y-P);E+P<k&&!((T-=D[E+P])<=0);)E++,T<<=1;if(_+=1<<E,1===e&&_>852||2===e&&_>592)return 1;a[d=M&c]=S<<24|E<<16|h-r}}return 0!==M&&(a[h+M]=y-P<<24|64<<16),s.bits=S,0},Oo=oo,$o=so,No=uo,Wo=lo,jo=co,Bo=ho,zo=mo,Uo=fo,Ho=vo,Go=po,Vo=go,Ko=16180,Xo=16190,Yo=16191,qo=16192,Jo=16194,Qo=16199,Zo=16200,es=16206,ts=16209,ns=e=>(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24);function is(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}var as,rs,os=e=>{if(!e)return 1;var t=e.state;return!t||t.strm!==e||t.mode<Ko||t.mode>16211?1:0},ss=e=>{if(os(e))return zo;var t=e.state;return e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=Ko,t.last=0,t.havedict=0,t.flags=-1,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(852),t.distcode=t.distdyn=new Int32Array(592),t.sane=1,t.back=-1,Wo},us=e=>{if(os(e))return zo;var t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,ss(e)},ls=(e,t)=>{var n;if(os(e))return zo;var i=e.state;return t<0?(n=0,t=-t):(n=5+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?zo:(null!==i.window&&i.wbits!==t&&(i.window=null),i.wrap=n,i.wbits=t,us(e))},ds=(e,t)=>{if(!e)return zo;var n=new is;e.state=n,n.strm=e,n.window=null,n.mode=Ko;var i=ls(e,t);return i!==Wo&&(e.state=null),i},cs=!0,hs=e=>{if(cs){as=new Int32Array(512),rs=new Int32Array(32);for(var t=0;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(Fo(1,e.lens,0,288,as,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;Fo(2,e.lens,0,32,rs,0,e.work,{bits:5}),cs=!1}e.lencode=as,e.lenbits=9,e.distcode=rs,e.distbits=5},ms=(e,t,n,i)=>{var a,r=e.state;return null===r.window&&(r.wsize=1<<r.wbits,r.wnext=0,r.whave=0,r.window=new Uint8Array(r.wsize)),i>=r.wsize?(r.window.set(t.subarray(n-r.wsize,n),0),r.wnext=0,r.whave=r.wsize):((a=r.wsize-r.wnext)>i&&(a=i),r.window.set(t.subarray(n-i,n-i+a),r.wnext),(i-=a)?(r.window.set(t.subarray(n-i,n),0),r.wnext=i,r.whave=r.wsize):(r.wnext+=a,r.wnext===r.wsize&&(r.wnext=0),r.whave<r.wsize&&(r.whave+=a))),0},fs=(e,t)=>{var n,i,a,r,o,s,u,l,d,c,h,m,f,v,p,g,y,b,w,k,S,E,P,T,_=0,M=new Uint8Array(4),A=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(os(e)||!e.output||!e.input&&0!==e.avail_in)return zo;(n=e.state).mode===Yo&&(n.mode=qo),o=e.next_out,a=e.output,u=e.avail_out,r=e.next_in,i=e.input,s=e.avail_in,l=n.hold,d=n.bits,c=s,h=u,E=Wo;e:for(;;)switch(n.mode){case Ko:if(0===n.wrap){n.mode=qo;break}for(;d<16;){if(0===s)break e;s--,l+=i[r++]<<d,d+=8}if(2&n.wrap&&35615===l){0===n.wbits&&(n.wbits=15),n.check=0,M[0]=255&l,M[1]=l>>>8&255,n.check=io(n.check,M,2,0),l=0,d=0,n.mode=16181;break}if(n.head&&(n.head.done=!1),!(1&n.wrap)||(((255&l)<<8)+(l>>8))%31){e.msg="incorrect header check",n.mode=ts;break}if((15&l)!==Vo){e.msg="unknown compression method",n.mode=ts;break}if(d-=4,S=8+(15&(l>>>=4)),0===n.wbits&&(n.wbits=S),S>15||S>n.wbits){e.msg="invalid window size",n.mode=ts;break}n.dmax=1<<n.wbits,n.flags=0,e.adler=n.check=1,n.mode=512&l?16189:Yo,l=0,d=0;break;case 16181:for(;d<16;){if(0===s)break e;s--,l+=i[r++]<<d,d+=8}if(n.flags=l,(255&n.flags)!==Vo){e.msg="unknown compression method",n.mode=ts;break}if(57344&n.flags){e.msg="unknown header flags set",n.mode=ts;break}n.head&&(n.head.text=l>>8&1),512&n.flags&&4&n.wrap&&(M[0]=255&l,M[1]=l>>>8&255,n.check=io(n.check,M,2,0)),l=0,d=0,n.mode=16182;case 16182:for(;d<32;){if(0===s)break e;s--,l+=i[r++]<<d,d+=8}n.head&&(n.head.time=l),512&n.flags&&4&n.wrap&&(M[0]=255&l,M[1]=l>>>8&255,M[2]=l>>>16&255,M[3]=l>>>24&255,n.check=io(n.check,M,4,0)),l=0,d=0,n.mode=16183;case 16183:for(;d<16;){if(0===s)break e;s--,l+=i[r++]<<d,d+=8}n.head&&(n.head.xflags=255&l,n.head.os=l>>8),512&n.flags&&4&n.wrap&&(M[0]=255&l,M[1]=l>>>8&255,n.check=io(n.check,M,2,0)),l=0,d=0,n.mode=16184;case 16184:if(1024&n.flags){for(;d<16;){if(0===s)break e;s--,l+=i[r++]<<d,d+=8}n.length=l,n.head&&(n.head.extra_len=l),512&n.flags&&4&n.wrap&&(M[0]=255&l,M[1]=l>>>8&255,n.check=io(n.check,M,2,0)),l=0,d=0}else n.head&&(n.head.extra=null);n.mode=16185;case 16185:if(1024&n.flags&&((m=n.length)>s&&(m=s),m&&(n.head&&(S=n.head.extra_len-n.length,n.head.extra||(n.head.extra=new Uint8Array(n.head.extra_len)),n.head.extra.set(i.subarray(r,r+m),S)),512&n.flags&&4&n.wrap&&(n.check=io(n.check,i,m,r)),s-=m,r+=m,n.length-=m),n.length))break e;n.length=0,n.mode=16186;case 16186:if(2048&n.flags){if(0===s)break e;m=0;do{S=i[r+m++],n.head&&S&&n.length<65536&&(n.head.name+=String.fromCharCode(S))}while(S&&m<s);if(512&n.flags&&4&n.wrap&&(n.check=io(n.check,i,m,r)),s-=m,r+=m,S)break e}else n.head&&(n.head.name=null);n.length=0,n.mode=16187;case 16187:if(4096&n.flags){if(0===s)break e;m=0;do{S=i[r+m++],n.head&&S&&n.length<65536&&(n.head.comment+=String.fromCharCode(S))}while(S&&m<s);if(512&n.flags&&4&n.wrap&&(n.check=io(n.check,i,m,r)),s-=m,r+=m,S)break e}else n.head&&(n.head.comment=null);n.mode=16188;case 16188:if(512&n.flags){for(;d<16;){if(0===s)break e;s--,l+=i[r++]<<d,d+=8}if(4&n.wrap&&l!==(65535&n.check)){e.msg="header crc mismatch",n.mode=ts;break}l=0,d=0}n.head&&(n.head.hcrc=n.flags>>9&1,n.head.done=!0),e.adler=n.check=0,n.mode=Yo;break;case 16189:for(;d<32;){if(0===s)break e;s--,l+=i[r++]<<d,d+=8}e.adler=n.check=ns(l),l=0,d=0,n.mode=Xo;case Xo:if(0===n.havedict)return e.next_out=o,e.avail_out=u,e.next_in=r,e.avail_in=s,n.hold=l,n.bits=d,Bo;e.adler=n.check=1,n.mode=Yo;case Yo:if(t===$o||t===No)break e;case qo:if(n.last){l>>>=7&d,d-=7&d,n.mode=es;break}for(;d<3;){if(0===s)break e;s--,l+=i[r++]<<d,d+=8}switch(n.last=1&l,d-=1,3&(l>>>=1)){case 0:n.mode=16193;break;case 1:if(hs(n),n.mode=Qo,t===No){l>>>=2,d-=2;break e}break;case 2:n.mode=16196;break;case 3:e.msg="invalid block type",n.mode=ts}l>>>=2,d-=2;break;case 16193:for(l>>>=7&d,d-=7&d;d<32;){if(0===s)break e;s--,l+=i[r++]<<d,d+=8}if((65535&l)!=(l>>>16^65535)){e.msg="invalid stored block lengths",n.mode=ts;break}if(n.length=65535&l,l=0,d=0,n.mode=Jo,t===No)break e;case Jo:n.mode=16195;case 16195:if(m=n.length){if(m>s&&(m=s),m>u&&(m=u),0===m)break e;a.set(i.subarray(r,r+m),o),s-=m,r+=m,u-=m,o+=m,n.length-=m;break}n.mode=Yo;break;case 16196:for(;d<14;){if(0===s)break e;s--,l+=i[r++]<<d,d+=8}if(n.nlen=257+(31&l),l>>>=5,d-=5,n.ndist=1+(31&l),l>>>=5,d-=5,n.ncode=4+(15&l),l>>>=4,d-=4,n.nlen>286||n.ndist>30){e.msg="too many length or distance symbols",n.mode=ts;break}n.have=0,n.mode=16197;case 16197:for(;n.have<n.ncode;){for(;d<3;){if(0===s)break e;s--,l+=i[r++]<<d,d+=8}n.lens[A[n.have++]]=7&l,l>>>=3,d-=3}for(;n.have<19;)n.lens[A[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,P={bits:n.lenbits},E=Fo(0,n.lens,0,19,n.lencode,0,n.work,P),n.lenbits=P.bits,E){e.msg="invalid code lengths set",n.mode=ts;break}n.have=0,n.mode=16198;case 16198:for(;n.have<n.nlen+n.ndist;){for(;g=(_=n.lencode[l&(1<<n.lenbits)-1])>>>16&255,y=65535&_,!((p=_>>>24)<=d);){if(0===s)break e;s--,l+=i[r++]<<d,d+=8}if(y<16)l>>>=p,d-=p,n.lens[n.have++]=y;else{if(16===y){for(T=p+2;d<T;){if(0===s)break e;s--,l+=i[r++]<<d,d+=8}if(l>>>=p,d-=p,0===n.have){e.msg="invalid bit length repeat",n.mode=ts;break}S=n.lens[n.have-1],m=3+(3&l),l>>>=2,d-=2}else if(17===y){for(T=p+3;d<T;){if(0===s)break e;s--,l+=i[r++]<<d,d+=8}d-=p,S=0,m=3+(7&(l>>>=p)),l>>>=3,d-=3}else{for(T=p+7;d<T;){if(0===s)break e;s--,l+=i[r++]<<d,d+=8}d-=p,S=0,m=11+(127&(l>>>=p)),l>>>=7,d-=7}if(n.have+m>n.nlen+n.ndist){e.msg="invalid bit length repeat",n.mode=ts;break}for(;m--;)n.lens[n.have++]=S}}if(n.mode===ts)break;if(0===n.lens[256]){e.msg="invalid code -- missing end-of-block",n.mode=ts;break}if(n.lenbits=9,P={bits:n.lenbits},E=Fo(1,n.lens,0,n.nlen,n.lencode,0,n.work,P),n.lenbits=P.bits,E){e.msg="invalid literal/lengths set",n.mode=ts;break}if(n.distbits=6,n.distcode=n.distdyn,P={bits:n.distbits},E=Fo(2,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,P),n.distbits=P.bits,E){e.msg="invalid distances set",n.mode=ts;break}if(n.mode=Qo,t===No)break e;case Qo:n.mode=Zo;case Zo:if(s>=6&&u>=258){e.next_out=o,e.avail_out=u,e.next_in=r,e.avail_in=s,n.hold=l,n.bits=d,Do(e,h),o=e.next_out,a=e.output,u=e.avail_out,r=e.next_in,i=e.input,s=e.avail_in,l=n.hold,d=n.bits,n.mode===Yo&&(n.back=-1);break}for(n.back=0;g=(_=n.lencode[l&(1<<n.lenbits)-1])>>>16&255,y=65535&_,!((p=_>>>24)<=d);){if(0===s)break e;s--,l+=i[r++]<<d,d+=8}if(g&&!(240&g)){for(b=p,w=g,k=y;g=(_=n.lencode[k+((l&(1<<b+w)-1)>>b)])>>>16&255,y=65535&_,!(b+(p=_>>>24)<=d);){if(0===s)break e;s--,l+=i[r++]<<d,d+=8}l>>>=b,d-=b,n.back+=b}if(l>>>=p,d-=p,n.back+=p,n.length=y,0===g){n.mode=16205;break}if(32&g){n.back=-1,n.mode=Yo;break}if(64&g){e.msg="invalid literal/length code",n.mode=ts;break}n.extra=15&g,n.mode=16201;case 16201:if(n.extra){for(T=n.extra;d<T;){if(0===s)break e;s--,l+=i[r++]<<d,d+=8}n.length+=l&(1<<n.extra)-1,l>>>=n.extra,d-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=16202;case 16202:for(;g=(_=n.distcode[l&(1<<n.distbits)-1])>>>16&255,y=65535&_,!((p=_>>>24)<=d);){if(0===s)break e;s--,l+=i[r++]<<d,d+=8}if(!(240&g)){for(b=p,w=g,k=y;g=(_=n.distcode[k+((l&(1<<b+w)-1)>>b)])>>>16&255,y=65535&_,!(b+(p=_>>>24)<=d);){if(0===s)break e;s--,l+=i[r++]<<d,d+=8}l>>>=b,d-=b,n.back+=b}if(l>>>=p,d-=p,n.back+=p,64&g){e.msg="invalid distance code",n.mode=ts;break}n.offset=y,n.extra=15&g,n.mode=16203;case 16203:if(n.extra){for(T=n.extra;d<T;){if(0===s)break e;s--,l+=i[r++]<<d,d+=8}n.offset+=l&(1<<n.extra)-1,l>>>=n.extra,d-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){e.msg="invalid distance too far back",n.mode=ts;break}n.mode=16204;case 16204:if(0===u)break e;if(m=h-u,n.offset>m){if((m=n.offset-m)>n.whave&&n.sane){e.msg="invalid distance too far back",n.mode=ts;break}m>n.wnext?(m-=n.wnext,f=n.wsize-m):f=n.wnext-m,m>n.length&&(m=n.length),v=n.window}else v=a,f=o-n.offset,m=n.length;m>u&&(m=u),u-=m,n.length-=m;do{a[o++]=v[f++]}while(--m);0===n.length&&(n.mode=Zo);break;case 16205:if(0===u)break e;a[o++]=n.length,u--,n.mode=Zo;break;case es:if(n.wrap){for(;d<32;){if(0===s)break e;s--,l|=i[r++]<<d,d+=8}if(h-=u,e.total_out+=h,n.total+=h,4&n.wrap&&h&&(e.adler=n.check=n.flags?io(n.check,a,h,o-h):to(n.check,a,h,o-h)),h=u,4&n.wrap&&(n.flags?l:ns(l))!==n.check){e.msg="incorrect data check",n.mode=ts;break}l=0,d=0}n.mode=16207;case 16207:if(n.wrap&&n.flags){for(;d<32;){if(0===s)break e;s--,l+=i[r++]<<d,d+=8}if(4&n.wrap&&l!==(4294967295&n.total)){e.msg="incorrect length check",n.mode=ts;break}l=0,d=0}n.mode=16208;case 16208:E=jo;break e;case ts:E=Uo;break e;case 16210:return Ho;default:return zo}return e.next_out=o,e.avail_out=u,e.next_in=r,e.avail_in=s,n.hold=l,n.bits=d,(n.wsize||h!==e.avail_out&&n.mode<ts&&(n.mode<es||t!==Oo))&&ms(e,e.output,e.next_out,h-e.avail_out),c-=e.avail_in,h-=e.avail_out,e.total_in+=c,e.total_out+=h,n.total+=h,4&n.wrap&&h&&(e.adler=n.check=n.flags?io(n.check,a,h,e.next_out-h):to(n.check,a,h,e.next_out-h)),e.data_type=n.bits+(n.last?64:0)+(n.mode===Yo?128:0)+(n.mode===Qo||n.mode===Jo?256:0),(0===c&&0===h||t===Oo)&&E===Wo&&(E=Go),E},vs={inflateReset:us,inflateReset2:ls,inflateResetKeep:ss,inflateInit:e=>ds(e,15),inflateInit2:ds,inflate:fs,inflateEnd:e=>{if(os(e))return zo;var t=e.state;return t.window&&(t.window=null),e.state=null,Wo},inflateGetHeader:(e,t)=>{if(os(e))return zo;var n=e.state;return 2&n.wrap?(n.head=t,t.done=!1,Wo):zo},inflateSetDictionary:(e,t)=>{var n,i=t.length;return os(e)||0!==(n=e.state).wrap&&n.mode!==Xo?zo:n.mode===Xo&&to(1,t,i,0)!==n.check?Uo:ms(e,t,i,i)?(n.mode=16210,Ho):(n.havedict=1,Wo)},inflateInfo:"pako inflate (from Nodeca project)"};var ps=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1},gs=Object.prototype.toString,ys=ro,bs=oo,ws=lo,ks=co,Ss=ho,Es=mo,Ps=fo,Ts=vo;function _s(e){this.options=bo({chunkSize:65536,windowBits:15,to:""},e||{});var t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),!(t.windowBits>=0&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&(15&t.windowBits||(t.windowBits|=15)),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Mo,this.strm.avail_out=0;var n=vs.inflateInit2(this.strm,t.windowBits);if(n!==ws)throw new Error(ao[n]);if(this.header=new ps,vs.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=Po(t.dictionary):"[object ArrayBuffer]"===gs.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(n=vs.inflateSetDictionary(this.strm,t.dictionary))!==ws))throw new Error(ao[n])}_s.prototype.push=function(e,t){var n,i,a,r=this.strm,o=this.options.chunkSize,s=this.options.dictionary;if(this.ended)return!1;for(i=t===~~t?t:!0===t?bs:ys,"[object ArrayBuffer]"===gs.call(e)?r.input=new Uint8Array(e):r.input=e,r.next_in=0,r.avail_in=r.input.length;;){for(0===r.avail_out&&(r.output=new Uint8Array(o),r.next_out=0,r.avail_out=o),(n=vs.inflate(r,i))===Ss&&s&&((n=vs.inflateSetDictionary(r,s))===ws?n=vs.inflate(r,i):n===Ps&&(n=Ss));r.avail_in>0&&n===ks&&r.state.wrap>0&&0!==e[r.next_in];)vs.inflateReset(r),n=vs.inflate(r,i);switch(n){case Es:case Ps:case Ss:case Ts:return this.onEnd(n),this.ended=!0,!1}if(a=r.avail_out,r.next_out&&(0===r.avail_out||n===ks))if("string"===this.options.to){var u=_o(r.output,r.next_out),l=r.next_out-u,d=To(r.output,u);r.next_out=l,r.avail_out=o-l,l&&r.output.set(r.output.subarray(u,u+l),0),this.onData(d)}else this.onData(r.output.length===r.next_out?r.output:r.output.subarray(0,r.next_out));if(n!==ws||0!==a){if(n===ks)return n=vs.inflateEnd(this.strm),this.onEnd(n),this.ended=!0,!0;if(0===r.avail_in)break}}return!0},_s.prototype.onData=function(e){this.chunks.push(e)},_s.prototype.onEnd=function(e){e===ws&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=wo(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var Ms={ungzip:function(e,t){var n=new _s(t);if(n.push(e),n.err)throw n.msg||ao[n.err];return n.result}}.ungzip,As=e=>{var t;if(null!=e&&e.includes(un))t=an;else{var n=null==e?void 0:e.find(e=>e.includes(on));t=n?n.split("=")[1]:tn}return(t=t.replace(/\/$/,""))+"/"+Zt},Ds=e=>{var t,n,i=Fr.getAppConfig(at)||Fr.getAppConfig(yt);return null!==(t=null==i||null===(n=i.capabilities)||void 0===n?void 0:n.includes(e))&&void 0!==t&&t},xs=()=>{var e,t,n=(t=Fr.getAppConfig(at)||Fr.getAppConfig(yt),null!==(e=null==t?void 0:t.campaign_cache_ttl)&&void 0!==e?e:null);if(null!==n)if(0!==n){var i=Fr.getApiCampaignSessionTimestamp();if(null!==i)(Date.now()-i)/1e3>=n&&Fr.purgeApiCampaignCache()}else Fr.purgeApiCampaignCache()},Cs=e=>{var t=!Ds(Pe.THIRD_PARTY_TRANSACTIONS);return e&&!t&&ui.info(`[${e}] Your plan does not have purchase management features.`),t},Is=()=>{var e,t,n=null===(e=Fr.getNamiConfig())||void 0===e?void 0:e.namiCommands;return null!==(t=null==n?void 0:n.includes(pn))&&void 0!==t&&t},Ls=()=>{var e,t,n=null===(e=Fr.getNamiConfig())||void 0===e?void 0:e.namiCommands;return null!==(t=null==n?void 0:n.includes(yn))&&void 0!==t&&t};function Rs(e){try{var t=function(e){if("undefined"!=typeof Buffer)return new Uint8Array(Buffer.from(e,"base64"));for(var t=atob(e),n=t.length,i=new Uint8Array(n),a=0;a<n;a++)i[a]=t.charCodeAt(a);return i}(e.trim()),n=Ms(t),i=(new TextDecoder).decode(n);return JSON.parse(i)}catch(e){return}}function Fs(e,t,n=_n,i=Sn){var r,o,s,u,l,d,c;return k(function(h){for(;;)switch(h.n){case 0:return o=0,s=Is(),u=Ls(),l=null!==(r=null==t?void 0:t.method)&&void 0!==r?r:"GET",d=()=>{var r,c,h,m;return k(function(f){for(;;)switch(f.n){case 0:return(s||u)&&ui.debug(`[HTTP] ${l} ${e}`),u&&null!=t&&t.body&&ui.debug(`[HTTP] Request body: ${t.body}`),f.n=1,a(Os(e,t,n));case 1:if((r=f.v).ok){f.n=7;break}if(!u){f.n=3;break}return f.n=2,a(r.clone().text());case 2:c=f.v,ui.debug(`[HTTP] Response ${r.status}: ${c}`);case 3:if(r.status!=Rn){f.n=4;break}throw new Nr;case 4:if(!(++o<=i)){f.n=6;break}return h=1e3*(o+Pn),f.n=5,a(new Promise(e=>setTimeout(e,h)));case 5:return f.a(2,d());case 6:throw new Or(r.status,`Request failed after ${i} retries`);case 7:if(!u){f.n=9;break}return f.n=8,a(r.clone().text());case 8:m=f.v,ui.debug(`[HTTP] Response ${r.status}: ${m}`);case 9:return f.a(2,r)}},null,null,null,Promise)},h.n=1,a(d());case 1:return c=h.v,h.a(2,c.json())}},null,null,null,Promise)}function Os(e,t={},n){var i,r,o;return k(function(s){for(;;)switch(s.n){case 0:return i=new AbortController,r=setTimeout(()=>i.abort(),n),t.signal=i.signal,s.n=1,a(fetch(e,t));case 1:return o=s.v,clearTimeout(r),s.a(2,o)}},null,null,null,Promise)}function $s(e,t,n){var i=n.value;return n.value=function(...e){if(!this.platformID)throw new jr;return i.apply(this,e)},n}function Ns(e,t,n){var i=n.value;return n.value=function(...e){var t=Fr.getDevice();if(null==t||!t.id)throw new Br;return i.apply(this,e)},n}var Ws,js=function(){function e(){o(this,e);var t=Fr.getNamiConfig();!this.platformID&&t&&this.configure(t)}return c(e,[{key:"deviceID",get:function(){var e;return null===(e=Fr.getDevice())||void 0===e?void 0:e.id}},{key:"configure",value:function(e){this.baseURL=As(e.namiCommands),this.platformID=e.appPlatformID}},{key:"reset",value:function(){this.baseURL=void 0,this.platformID=void 0}},{key:"login",value:function(e){var t,n;return k(function(i){for(;;)switch(i.n){case 0:if(e){i.n=1;break}throw new zr;case 1:return t=`device/${this.deviceID}/login/`,n={external_id:e},i.n=2,a(this.requestBodyAPI(t,n,"PUT"));case 2:return i.a(2,i.v)}},null,this,null,Promise)}},{key:"logout",value:function(){var e;return k(function(t){for(;;)switch(t.n){case 0:return e=`device/${this.deviceID}/logout/`,t.n=1,a(this.requestBodyAPI(e,{},"PUT"));case 1:return t.a(2,t.v)}},null,this,null,Promise)}},{key:"startSession",value:function(e){var t,n;return k(function(i){for(;;)switch(i.n){case 0:return t=`device/${this.deviceID}/session/`,i.n=1,a(this.requestBodyAPI(t,{start_time:e,app_env:"production"}));case 1:n=i.v,Fr.setSessionCounter(),n.id&&Fr.setSessionId(n.id);case 2:return i.a(2)}},null,this,null,Promise)}},{key:"postImpression",value:function(t){var n,i,r;return k(function(o){for(;;)switch(o.n){case 0:return n=`device/${this.deviceID}/impression/`,o.n=1,a(this.requestBodyAPI(n,t,"POST",!0));case 1:(i=o.v).id&&(Fr.setLastImpressionId(i.id),null===(r=e.impressionListener)||void 0===r||r.call(e,i.id));case 2:return o.a(2)}},null,this,null,Promise)}},{key:"patchImpressionCompletion",value:function(e,t,n){var i;return k(function(r){for(;;)switch(r.n){case 0:return i=`device/${this.deviceID}/impression/${e}/`,r.n=1,a(this.requestBodyAPI(i,{completion_result:t,completion_result_date:n},"PATCH",!0));case 1:return r.a(2)}},null,this,null,Promise)}},{key:"postConversion",value:function(e){var t;return k(function(n){for(;;)switch(n.n){case 0:return t=`device/${this.deviceID}/transaction/`,n.n=1,a(this.requestBodyAPI(t,e,"POST",!0));case 1:return n.a(2)}},null,this,null,Promise)}},{key:"purchaseValidation",value:function(e){var t;return k(function(n){for(;;)switch(n.n){case 0:return t=`device/${this.deviceID}/purchase_event/`,n.n=1,a(this.requestBodyAPI(t,e,"PUT"));case 1:return n.a(2)}},null,this,null,Promise)}},{key:"fetchAPI",value:function(e,t,n){var i;return k(function(r){for(;;)switch(r.n){case 0:return i=`${this.baseURL}/${this.platformID}/`+e,r.n=1,a(Fs(i,void 0,t,n));case 1:return r.a(2,r.v)}},null,this,null,Promise)}},{key:"requestBodyAPI",value:function(e,t,n="POST",i=!1,r,o){var s,u;return k(function(l){for(;;)switch(l.n){case 0:return s=`${this.baseURL}/${this.platformID}/`+e,u={method:n,headers:{"Content-Type":"application/json"},body:JSON.stringify(t),keepalive:i},l.n=1,a(Fs(s,u,r,o));case 1:return l.a(2,l.v)}},null,this,null,Promise)}}],[{key:"configure",value:function(e){this.instance.configure(e)}},{key:"reset",value:function(){this.instance.reset()}}])}();function Bs(e){return null!=(null==e?void 0:e.flow)}js.instance=new js,ke([Ns],js.prototype,"login",null),ke([Ns],js.prototype,"logout",null),ke([Ns],js.prototype,"startSession",null),ke([Ns],js.prototype,"postImpression",null),ke([Ns],js.prototype,"patchImpressionCompletion",null),ke([Ns],js.prototype,"postConversion",null),ke([Ns],js.prototype,"purchaseValidation",null),ke([$s],js.prototype,"fetchAPI",null),ke([$s],js.prototype,"requestBodyAPI",null),e.NamiCampaignRuleType=void 0,(Ws=e.NamiCampaignRuleType||(e.NamiCampaignRuleType={})).DEFAULT="default",Ws.LABEL="label",Ws.UNKNOWN="unknown",Ws.URL="url";var zs=()=>{var e;return null!==(e=Fr.getPaywalls(St))&&void 0!==e?e:[]},Us=()=>{var e;return null!==(e=Fr.getPaywalls(ut))&&void 0!==e?e:[]},Hs=()=>Lr(li([...Us(),...zs()]),"id"),Gs=e=>Hs().find(t=>t.id===e),Vs=e=>{var t=Hs(),n=new Set(t.map(e=>e.id));return e.every(e=>n.has(e))},Ks="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof global?global:{},Xs="function"==typeof Ks.BigInt,Ys=Xs?Ks.BigInt.bind(Ks):void 0,qs=Xs?Ys("0xffffffffffffffffffffffffffffffff"):null,Js=Xs?Ys("0x100000000000000000000000000000000"):null,Qs=Xs?Ys(0):null,Zs=Xs?Ys(1):null,eu=Xs?Ys(8):null,tu=Xs?Ys(1e4):null,nu=Ks.crypto,iu="function"==typeof(null==nu?void 0:nu.getRandomValues),au=1/16,ru=e=>we().device.getDeviceData(e),ou=()=>{var e=Fr.getNamiConfig();return e&&e.formFactor?e.formFactor:we().device.getDeviceFormFactor()};function su(){return we().device.generateUUID()}function uu(e){if(!Xs||!qs)return cu(e);try{var t=qs,n=function(e){if(!Ys)throw new Error("BigInt is not supported in this environment");var t=e.replace(/-/g,"");return Ys("0x"+t)}(e);return Number(n)/Number(t)*100}catch(t){throw ui.error(`Error calculating audience split position for UUID ${e}`,t),new Error(`Invalid UUID format: ${e}`)}}function lu(e){if(!Ys)throw new Error("BigInt is not supported in this environment");var t=e.toString(16).padStart(32,"0");t=t.substring(0,12)+"4"+t.substring(13);var n=3&parseInt(t[16],16)|8;return(t=t.substring(0,16)+n.toString(16)+t.substring(17)).slice(0,8)+"-"+t.slice(8,12)+"-"+t.slice(12,16)+"-"+t.slice(16,20)+"-"+t.slice(20)}function du(e,t=.5){if(!Number.isFinite(e))throw new Error("Invalid target");if(!Number.isFinite(t))throw new Error("Invalid tolerance");var n=Math.max(0,Math.min(100,e)),i=Math.max(0,Math.min(50,t)),a=e=>Math.round(100*e),r=Math.max(0,a(n-i)),o=Math.min(1e4,a(n+i));if(!(Xs&&qs&&Ys&&tu))return function(e,t){for(var n=Math.max(0,Math.min(100,e-t)),i=Math.min(100,Math.max(0,e+t)),a=su(),r=Number.POSITIVE_INFINITY,o=50,s=0;s<o;s++){var u=su(),l=cu(u);if(l>=n&&l<=i)return u;var d=hu(l,n,i);d<r&&(r=d,a=u)}return a}(n,i);var s=qs,u=Ys,l=tu,d=e=>s*u(e)/l,c=d(r),m=d(o);if(m<=c)return lu(c);var f=c+function(e){if(!Ys||null===Js||null===Zs||null===Qs||null===eu)throw new Error("BigInt is not supported in this environment");var t=Ys,n=Qs,i=Zs,a=eu,r=Js;if(e<n)throw new Error("n must be non-negative");if(e===n)return n;for(var o=new Uint8Array(16),s=e+i,u=r/s*s-i,l=0,d=!1;l<10;){if(iu)nu.getRandomValues(o);else{d||(d=!0,ui.warn("randomBigInt: crypto.getRandomValues unavailable, using Math.random fallback"));for(var c=0;c<o.length;c++)o[c]=Math.floor(256*Math.random())}for(var m,f=n,v=h(o);!(m=v()).done;)f=f<<a|t(m.value);if(f<=u)return f%s;l++}if(iu)try{nu.getRandomValues(o);for(var p,g=n,y=h(o);!(p=y()).done;)g=g<<a|t(p.value);var b=g%s;return ui.warn("randomBigInt: reached max rejection attempts, using modulo fallback",{n:e.toString(),attempts:l}),b}catch(e){throw ui.error("randomBigInt: failed to generate random values",e),new Error("randomBigInt: unable to generate random value")}for(var w,k=n,S=h(o);!(w=S()).done;)k=k<<a|t(w.value);return ui.warn("randomBigInt: reached max rejection attempts without crypto, using modulo fallback",{n:e.toString(),attempts:l}),k%s}(m-c);return lu(f)}function cu(e){var t=function(e){var t=e.replace(/-/g,"").toLowerCase();if(!/^[0-9a-f]{32}$/.test(t))throw new Error(`Invalid UUID format: ${e}`);for(var n=0,i=t.length-1;i>=0;i--){n=(n+parseInt(t[i],16))*au}return n}(e);return 100*t}function hu(e,t,n){return e<t?t-e:e>n?e-n:0}new Intl.DateTimeFormat("en-US",{hourCycle:"h23",timeZone:"America/New_York",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}).format(new Date("2014-06-25T04:00:00.123Z"));var mu,fu=e=>{try{return!isNaN(new Date(e).getTime())}catch(e){return!1}},vu=(e,t,n=new Date)=>{var i=n.getTime(),a=!e||!fu(e)||new Date(e).getTime()<i,r=!t||!fu(t)||new Date(t).getTime()>i;return a&&r},pu=e=>{try{var t=new URL(e);return("http:"===t.protocol||"https:"===t.protocol)&&!!t.hostname}catch(e){return!1}},gu=e=>{try{var t=new URL(e),n=t.origin+t.pathname,i=new Set;return t.searchParams.forEach((e,t)=>{i.add(`${t}=${e}`)}),{basePath:n,params:i}}catch(e){return}},yu=(e,t,n)=>e?e.flatMap(e=>{var i;if(i="string"==typeof n?e.segments.filter(e=>e.form_factors.some(e=>e.form_factor===n)):e.segments,0===i.length)return[];var a=((e,t)=>{for(var n,i=[...e].sort((e,t)=>e.split-t.split),a=h(i);!(n=a()).done;){var r=n.value;if(t<=r.split)return r}return i[i.length-1]})(i,t);return{form_factors:a.form_factors,paywall:a.paywall,paywall_url:a.paywall_url,page_urls:a.page_urls,flow:a.flow,segment:a.segment,split:a.split,conversion_event_type:a.conversion_event_type,conversion_event_url:a.conversion_event_url,rule:e.rule,name:e.name,type:e.type,value:e.value,external_segment:e.external_segment}}):[],bu=()=>{var e,t,n=null!==(e=Fr.getCampaignRules(ot))&&void 0!==e?e:[],i=null!==(t=Fr.getCampaignRules(wt))&&void 0!==t?t:[],a=ou(),r=li([...n,...i]).filter(e=>{var t;return null===(t=e.form_factors)||void 0===t?void 0:t.some(e=>e.form_factor===a)}).filter(e=>vu(e.not_before,e.expires_at)),o=new Set;return r.filter(e=>{var t,n,i=`${null!==(t=e.type)&&void 0!==t?t:""}::${null!==(n=e.value)&&void 0!==n?n:""}`;return!o.has(i)&&(o.add(i),!0)})},wu=e=>{var t,n=null!==(t=Fr.getCampaignRules(e))&&void 0!==t?t:[],i=ou();return li(n).filter(e=>{var t;return null===(t=e.form_factors)||void 0===t?void 0:t.some(e=>e.form_factor===i)}).filter(e=>vu(e.not_before,e.expires_at))},ku=()=>wu(wt),Su=()=>wu(ot),Eu=(t,n,i,a)=>{var r=(()=>{if(!a)return t().find(t=>t.type==e.NamiCampaignRuleType.DEFAULT);if(a===e.NamiCampaignRuleType.URL){var n=t().filter(t=>t.type==e.NamiCampaignRuleType.URL);return((e,t)=>{var n,i,a,r=gu(e);if(r){for(var o,s,u,l=h(t);!(u=l()).done;){var d=u.value,c=d.value;if(c){var m=gu(c);if(m&&m.basePath===r.basePath){var f=m.params.size;if(0!==f){for(var v,p=0,g=h(m.params);!(v=g()).done;){var y=v.value;r.params.has(y)&&p++}p===f?(!o||f>o.totalParams)&&(o={campaign:d,totalParams:f}):o||(!s||p>s.score||p===s.score&&f>s.totalParams)&&(s={campaign:d,score:p,totalParams:f})}else o||s||(s={campaign:d,score:0,totalParams:0})}}}return null!==(n=null===(i=o)||void 0===i?void 0:i.campaign)&&void 0!==n?n:null===(a=s)||void 0===a?void 0:a.campaign}})(i,n)}return t().find(e=>e.type==a&&e.value==i)})();if(!r)return{};var o=n().find(e=>(null==r?void 0:r.paywall)===e.id);return{campaign:r,paywall:o}},Pu=(e,t)=>{var n=Eu(Su,Us,e,t);if(n.campaign&&n.paywall)return{campaign:n.campaign,paywall:n.paywall};var i=Eu(ku,zs,e,t);return i.campaign&&i.paywall?{campaign:i.campaign,paywall:i.paywall}:n.campaign||n.paywall?{campaign:n.campaign,paywall:n.paywall}:{campaign:i.campaign,paywall:i.paywall}},Tu="object"==typeof Reflect?Reflect:null,_u=Tu&&"function"==typeof Tu.apply?Tu.apply:function(e,t,n){return Function.prototype.apply.call(e,t,n)};mu=Tu&&"function"==typeof Tu.ownKeys?Tu.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var Mu=Number.isNaN||function(e){return e!=e};function Au(){Au.init.call(this)}Au.EventEmitter=Au,Au.prototype._events=void 0,Au.prototype._eventsCount=0,Au.prototype._maxListeners=void 0;var Du=10;function xu(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function Cu(e){return void 0===e._maxListeners?Au.defaultMaxListeners:e._maxListeners}function Iu(e,t,n,i){var a,r,o,s;if(xu(n),void 0===(r=e._events)?(r=e._events=Object.create(null),e._eventsCount=0):(void 0!==r.newListener&&(e.emit("newListener",t,n.listener?n.listener:n),r=e._events),o=r[t]),void 0===o)o=r[t]=n,++e._eventsCount;else if("function"==typeof o?o=r[t]=i?[n,o]:[o,n]:i?o.unshift(n):o.push(n),(a=Cu(e))>0&&o.length>a&&!o.warned){o.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=o.length,s=u,console&&console.warn&&console.warn(s)}return e}function Lu(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function Ru(e,t,n){var i={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},a=Lu.bind(i);return a.listener=n,i.wrapFn=a,a}function Fu(e,t,n){var i=e._events;if(void 0===i)return[];var a=i[t];return void 0===a?[]:"function"==typeof a?n?[a.listener||a]:[a]:n?function(e){for(var t=new Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}(a):$u(a,a.length)}function Ou(e){var t=this._events;if(void 0!==t){var n=t[e];if("function"==typeof n)return 1;if(void 0!==n)return n.length}return 0}function $u(e,t){for(var n=new Array(t),i=0;i<t;++i)n[i]=e[i];return n}Object.defineProperty(Au,"defaultMaxListeners",{enumerable:!0,get:function(){return Du},set:function(e){if("number"!=typeof e||e<0||Mu(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");Du=e}}),Au.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},Au.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||Mu(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},Au.prototype.getMaxListeners=function(){return Cu(this)},Au.prototype.emit=function(e){for(var t=[],n=1;n<arguments.length;n++)t.push(arguments[n]);var i="error"===e,a=this._events;if(void 0!==a)i=i&&void 0===a.error;else if(!i)return!1;if(i){var r;if(t.length>0&&(r=t[0]),r instanceof Error)throw r;var o=new Error("Unhandled error."+(r?" ("+r.message+")":""));throw o.context=r,o}var s=a[e];if(void 0===s)return!1;if("function"==typeof s)_u(s,this,t);else for(var u=s.length,l=$u(s,u),d=0;d<u;++d)_u(l[d],this,t);return!0},Au.prototype.addListener=function(e,t){return Iu(this,e,t,!1)},Au.prototype.on=Au.prototype.addListener,Au.prototype.prependListener=function(e,t){return Iu(this,e,t,!0)},Au.prototype.once=function(e,t){return xu(t),this.on(e,Ru(this,e,t)),this},Au.prototype.prependOnceListener=function(e,t){return xu(t),this.prependListener(e,Ru(this,e,t)),this},Au.prototype.removeListener=function(e,t){var n,i,a,r,o;if(xu(t),void 0===(i=this._events))return this;if(void 0===(n=i[e]))return this;if(n===t||n.listener===t)0===--this._eventsCount?this._events=Object.create(null):(delete i[e],i.removeListener&&this.emit("removeListener",e,n.listener||t));else if("function"!=typeof n){for(a=-1,r=n.length-1;r>=0;r--)if(n[r]===t||n[r].listener===t){o=n[r].listener,a=r;break}if(a<0)return this;0===a?n.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(n,a),1===n.length&&(i[e]=n[0]),void 0!==i.removeListener&&this.emit("removeListener",e,o||t)}return this},Au.prototype.off=Au.prototype.removeListener,Au.prototype.removeAllListeners=function(e){var t,n,i;if(void 0===(n=this._events))return this;if(void 0===n.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==n[e]&&(0===--this._eventsCount?this._events=Object.create(null):delete n[e]),this;if(0===arguments.length){var a,r=Object.keys(n);for(i=0;i<r.length;++i)"removeListener"!==(a=r[i])&&this.removeAllListeners(a);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=n[e]))this.removeListener(e,t);else if(void 0!==t)for(i=t.length-1;i>=0;i--)this.removeListener(e,t[i]);return this},Au.prototype.listeners=function(e){return Fu(this,e,!0)},Au.prototype.rawListeners=function(e){return Fu(this,e,!1)},Au.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):Ou.call(e,t)},Au.prototype.listenerCount=Ou,Au.prototype.eventNames=function(){return this._eventsCount>0?mu(this._events):[]};var Nu=function(){function e(){o(this,e),this.emitter=new Au}return c(e,[{key:"on",value:function(e,t){this.emitter.on(e,t)}},{key:"off",value:function(e,t){this.emitter.off(e,t)}},{key:"emit",value:function(e,...t){this.emitter.emit(e,...t)}},{key:"addListener",value:function(e,t){this.emitter.addListener(e,t)}},{key:"removeListener",value:function(e,t){this.emitter.removeListener(e,t)}},{key:"removeAllListeners",value:function(e){e?this.emitter.removeAllListeners(e):this.emitter.removeAllListeners()}},{key:"listeners",value:function(e){return this.emitter.listeners(e)}},{key:"listenerCount",value:function(e){return this.emitter.listenerCount(e)}}],[{key:"getInstance",value:function(){return this.instance||(this.instance=new e),this.instance}}])}(),Wu=function(){return c(function e(){o(this,e),this.disableCampaignUpdates=!1,this.useLegacyPaywallFetch=!1,this.currentFormFactor=ou()},[{key:"configure",value:function(e,t,n=[]){this.currentFormFactor=e,this.splitPosition=t,this.disableCampaignUpdates=n.includes("disableCampaignUpdates"),this.useLegacyPaywallFetch=n.includes("useLegacyPaywallFetch")}},{key:"reset",value:function(){this.currentFormFactor=ou(),this.splitPosition=void 0,this.disableCampaignUpdates=!1,this.useLegacyPaywallFetch=!1}},{key:"fetchCampaignRules",value:function(e){var t,n,i,r;return k(function(o){for(;;)switch(o.n){case 0:if(i=Fr.getDevice(),!this.disableCampaignUpdates){o.n=1;break}return ui.info("Campaign updates disabled by configuration. Skipping fetch."),o.a(2,[]);case 1:if(null!=i&&i.id){o.n=3;break}return o.n=2,a(this.getAnonymousCampaigns());case 2:r=o.v,o.n=5;break;case 3:return o.n=4,a(this.getCampaigns(i.id));case 4:r=o.v;case 5:return r=null===(t=r)||void 0===t?void 0:t.filter(e=>{var t;return e.paywall&&e.form_factors.some(e=>e.form_factor===this.currentFormFactor)||e.flow&&(null===(t=e.form_factors)||void 0===t?void 0:t.some(e=>e.form_factor===this.currentFormFactor))}),r=null===(n=r)||void 0===n?void 0:n.filter(t=>{if(t.paywall){var n=e.find(e=>e.id==t.paywall);if(n)return t}else if(t.flow)return t}),Fr.setCampaignRules(ot,r),Fr.setApiCampaignSessionTimestamp(),this.invokeAvailableCampaignsResponseHandler(),o.a(2,r)}},null,this,null,Promise)}},{key:"fetchCampaignRulesRaw",value:function(){var e,t,n;return k(function(i){for(;;)switch(i.n){case 0:if(t=Fr.getDevice(),!this.disableCampaignUpdates){i.n=1;break}return ui.info("Campaign updates disabled by configuration. Skipping fetch."),i.a(2,[]);case 1:if(null!=t&&t.id){i.n=3;break}return i.n=2,a(this.getAnonymousCampaigns());case 2:n=i.v,i.n=5;break;case 3:return i.n=4,a(this.getCampaigns(t.id));case 4:n=i.v;case 5:return n=null===(e=n)||void 0===e?void 0:e.filter(e=>{var t;return e.paywall&&e.form_factors.some(e=>e.form_factor===this.currentFormFactor)||e.flow&&(null===(t=e.form_factors)||void 0===t?void 0:t.some(e=>e.form_factor===this.currentFormFactor))}),i.a(2,n)}},null,this,null,Promise)}},{key:"finalizeCampaignRules",value:function(e,t){var n=new Set([...t.map(e=>e.id),...zs().map(e=>e.id)]),i=null==e?void 0:e.filter(e=>{return e.paywall?t.find(t=>t.id==e.paywall):!!e.flow&&(!!e.flow.object&&(null!==(i=e.flow.object.screens)&&void 0!==i?i:[]).every(e=>n.has(e)));var i});return Fr.setCampaignRules(ot,i),Fr.setApiCampaignSessionTimestamp(),this.invokeAvailableCampaignsResponseHandler(),i}},{key:"invokeAvailableCampaignsResponseHandler",value:function(){var e=Nu.getInstance().listeners(Hn),t=bu();e.forEach(e=>e(t))}},{key:"getAnonymousCampaigns",value:function(e=Ae){var t,n,i,r,o;return k(function(s){for(;;)switch(s.p=s.n){case 0:return t=`campaign_rules/?sdk_version=${e}`,s.p=1,s.n=2,a(js.instance.fetchAPI(t));case 2:return i=s.v,s.a(2,yu(null!==(n=i.results)&&void 0!==n?n:[],this.splitPosition,this.currentFormFactor));case 3:if(s.p=3,o=s.v,r=this.fallbackData()){s.n=4;break}throw ui.error(Zr(o.status,t)),o;case 4:return s.a(2,r.results)}},null,this,[[1,3]],Promise)}},{key:"getCampaigns",value:function(e){var t,n,i,r;return k(function(o){for(;;)switch(o.p=o.n){case 0:return n=`device/${e}/campaign_rules/`,o.p=1,o.n=2,a(js.instance.fetchAPI(n));case 2:i=o.v,o.n=4;break;case 3:if(o.p=3,r=o.v,i=this.fallbackData()){o.n=4;break}throw ui.error(Zr(r.status,n)),r;case 4:return o.a(2,(null===(t=i)||void 0===t?void 0:t.results)||[])}},null,this,[[1,3]],Promise)}},{key:"fallbackData",value:function(){var e=Fr.getCampaignRules(ot)||Fr.getCampaignRules(wt);return e?{count:e.length,results:e}:null}}],[{key:"extractPaywallUrls",value:function(e){for(var t,n=[],i=h(e);!(t=i()).done;){var a,r=t.value;r.paywall_url&&n.push(r.paywall_url),r.page_urls&&n.push(...Object.values(r.page_urls)),null!==(a=r.flow)&&void 0!==a&&a.page_urls&&n.push(...Object.values(r.flow.page_urls))}return n}},{key:"hasPaywallUrls",value:function(e){return e.some(e=>{var t;return e.paywall_url||e.page_urls||(null===(t=e.flow)||void 0===t?void 0:t.page_urls)})}}])}();function ju(e,t){return ar(e,t)}Wu.instance=new Wu;var Bu=function(){return c(function e(){o(this,e)},[{key:"createOrUpdateDevice",value:function(e,t,n){var i=Fr.getDevice();if(null==i||!i.id){var a,r=m({},e,{id:null!==(a=null!=t?t:this.getAnonymousUUID())&&void 0!==a?a:su()});return{id:r.id,device:this.createDevice(r,n)}}return this.isEqualDevices(i,e)?{id:i.id,device:Promise.resolve(i)}:(this.updateDevice(i.id,e),{id:i.id,device:null})}},{key:"createDevice",value:function(e,t){var n,i;return k(function(r){for(;;)switch(r.p=r.n){case 0:return r.p=0,r.n=1,a(this.requestAPIData("device/",e,void 0,void 0,0));case 1:if(!(n=r.v)){r.n=2;break}Fr.setDevice(n),r.n=3;break;case 2:return ui.info("Device creation returned null, switching to anon mode for this session"),null==t||t.setInMemoryAnonymousMode(!0),r.a(2,null);case 3:return r.a(2,n);case 4:if(r.p=4,i=r.v,console.error("Error creating device:",i),!(i instanceof Or)){r.n=5;break}return ui.info("Retry limit exceeded, switching to anon mode for this session"),null==t||t.setInMemoryAnonymousMode(!0),r.a(2,null);case 5:throw i;case 6:return r.a(2)}},null,this,[[0,4]],Promise)}},{key:"updateDevice",value:function(e,t){var n;return k(function(i){for(;;)switch(i.n){case 0:return i.n=1,a(this.requestAPIData(`device/${e}/`,t,"PUT"));case 1:return(n=i.v)&&Fr.setDevice(n),i.a(2,n)}},null,this,null,Promise)}},{key:"updateDeviceField",value:function(e,t){var n,i,r;return k(function(o){for(;;)switch(o.n){case 0:if(n={[e]:t},null!=(i=Fr.getDevice())&&i.id){o.n=1;break}throw new Br;case 1:return o.n=2,a(this.requestAPIData(`device/${i.id}/`,n,"PATCH"));case 2:return(r=o.v)&&Fr.setDevice(r),o.a(2,r)}},null,this,null,Promise)}},{key:"requestAPIData",value:function(e,t,n="POST",i=An,r){var o,s;return k(function(u){for(;;)switch(u.p=u.n){case 0:return u.p=0,u.n=1,a(js.instance.requestBodyAPI(e,t,n,!1,i,r));case 1:o=u.v,u.n=5;break;case 2:if(u.p=2,!((s=u.v)instanceof jr)){u.n=3;break}throw s;case 3:if(!("device/"===e&&s instanceof Or)){u.n=4;break}throw s;case 4:if(o=Fr.getDevice()){u.n=5;break}return ui.error(Zr(s.status,e)),u.a(2,null);case 5:return u.a(2,o)}},null,null,[[0,2]],Promise)}},{key:"isEqualDevices",value:function(e,t){var n=m({},e,t),i=Object.keys(e).reduce((e,t)=>(e[t]=n[t],e),{});return ju(i,e)}},{key:"getOrCreateAnonymousUUID",value:function(){var e=Fr.getAnonymousUUID();return e||(e=su(),Fr.setAnonymousUUID(e)),e}},{key:"getAnonymousUUID",value:function(){var e=Fr.getAnonymousUUID();return e?(Fr.clearAnonymousUUID(),e):null}}])}();Bu.instance=new Bu;var zu=function(){return c(function e(){o(this,e)},[{key:"fetchProducts",value:function(){var e,t,n,i;return k(function(r){for(;;)switch(r.p=r.n){case 0:if(!Ds(Pe.THIRD_PARTY_TRANSACTIONS)){r.n=1;break}return r.a(2,[]);case 1:return r.p=1,r.n=2,a(js.instance.fetchAPI("products/"));case 2:n=r.v,r.n=4;break;case 3:if(r.p=3,i=r.v,n=this.fallbackData()){r.n=4;break}throw ui.error(Zr(i.status,"products/")),i;case 4:return null!==(e=n)&&void 0!==e&&e.results&&Fr.setProducts(ht,n.results),r.a(2,(null===(t=n)||void 0===t?void 0:t.results)||[])}},null,this,[[1,3]],Promise)}},{key:"fallbackData",value:function(){var e=Fr.getProducts(ht)||Fr.getProducts(Pt);return e?{count:e.length,results:e}:null}}])}();zu.instance=new zu;var Uu=3,Hu=200,Gu=2e3,Vu=5e3,Ku=2e4,Xu=new Set([408,425,429]),Yu=new Set(["ECONNRESET","ECONNREFUSED","ENOTFOUND","ETIMEDOUT"]),qu=function(e){function t(e,n){var i;return o(this,t),(i=r(this,t,[`CDN fetch failed with non-retryable status ${e} for ${n}`])).name="NonRetryableHttpError",i.status=e,i.url=n,i}return p(t,e),c(t)}(M(Error)),Ju=function(e){function t(e,n,i){var a;return o(this,t),(a=r(this,t,[`CDN fetch exhausted ${n} attempts for ${e}${void 0!==i?` (last status ${i})`:""}`])).name="RetryExhaustedError",a.url=e,a.attempts=n,a.lastStatus=i,a}return p(t,e),c(t)}(M(Error));function Qu(e,t){if("number"==typeof t)return Xu.has(t)||t>=500;if(e&&"object"==typeof e){var n=e;if("AbortError"===n.name)return!0;if(n.code&&Yu.has(n.code))return!0;if(e instanceof TypeError)return!0}return!1}function Zu(e,t){var n,i;return k(function(r){for(;;)switch(r.p=r.n){case 0:return n=new AbortController,i=setTimeout(()=>n.abort(),t),r.p=1,r.n=2,a(fetch(e,{signal:n.signal}));case 2:return r.a(2,r.v);case 3:return r.p=3,clearTimeout(i),r.f(3);case 4:return r.a(2)}},null,null,[[1,,3,4]],Promise)}var el=e=>new Promise(t=>setTimeout(t,e));function tl(e,t={}){var n,i,r,o,s,u,l,d,c,h,m,f,v,p,g,y,b,w,S,E,P,T,_,M,A,D,x,C,I,L;return k(function(k){for(;;)switch(k.p=k.n){case 0:d=null!==(n=t.maxAttempts)&&void 0!==n?n:Uu,c=null!==(i=t.baseDelayMs)&&void 0!==i?i:Hu,h=null!==(r=t.maxDelayMs)&&void 0!==r?r:Gu,m=null!==(o=t.budgetMs)&&void 0!==o?o:Ku,f=null!==(s=t.timeoutMs)&&void 0!==s?s:Vu,v=null!==(u=t.randomFn)&&void 0!==u?u:Math.random,p=null!==(l=t.sleepFn)&&void 0!==l?l:el,g=Is(),y=Ls(),b=Date.now(),w=0;case 1:if(!(w<d)){k.n=16;break}if(!(w>0)){k.n=4;break}if(!((P=Date.now()-b)>=m)){k.n=2;break}return k.a(3,16);case 2:return T=Math.min(c*Math.pow(2,w-1),h),_=T*(v()-.5),M=Math.max(0,m-P),A=Math.min(Math.max(0,T+_),M),k.n=3,a(p(A));case 3:if(!(Date.now()-b>=m)){k.n=4;break}return k.a(3,16);case 4:return k.p=4,(g||y)&&ui.debug(`[HTTP] GET ${e} (cdn attempt ${w+1}/${d})`),k.n=5,a(Zu(e,f));case 5:if((D=k.v).ok){k.n=9;break}if(!y){k.n=7;break}return k.n=6,a(D.clone().text());case 6:x=k.v,ui.debug(`[HTTP] Response ${D.status}: ${x}`);case 7:if(S=D.status,!Qu(void 0,D.status)){k.n=8;break}return w++,k.a(3,1);case 8:throw new qu(D.status,e);case 9:if(!y){k.n=11;break}return k.n=10,a(D.clone().text());case 10:C=k.v,ui.debug(`[HTTP] Response ${D.status}: ${C}`);case 11:return k.n=12,a(D.json());case 12:return I=k.v,k.a(2,{data:I,retryCount:w});case 13:if(k.p=13,!((L=k.v)instanceof qu)){k.n=14;break}throw L;case 14:if(!Qu(L)){k.n=15;break}return E=L,w++,k.a(3,1);case 15:throw L;case 16:if(void 0!==S||void 0===E){k.n=17;break}throw E;case 17:throw new Ju(e,w,S);case 18:return k.a(2)}},null,null,[[4,13]],Promise)}var nl=function(){return c(function e(){o(this,e)},[{key:"fetchPaywalls",value:function(){var e,t,n;return k(function(i){for(;;)switch(i.n){case 0:if(null!=(e=Fr.getDevice())&&e.id){i.n=2;break}return i.n=1,a(this.getAnonymousPaywalls());case 1:t=i.v,i.n=4;break;case 2:return i.n=3,a(this.getPaywalls(e.id));case 3:t=i.v;case 4:if(!t){i.n=5;break}return(n=this.validatePaywalls(t)).length>0&&Fr.setPaywalls(ut,n),i.a(2,n);case 5:return i.a(2,t)}},null,this,null,Promise)}},{key:"getAnonymousPaywalls",value:function(e=Ae){var t,n,i,r;return k(function(o){for(;;)switch(o.p=o.n){case 0:return n=`paywalls/?sdk_version=${e}`,i=null,o.p=1,o.n=2,a(js.instance.fetchAPI(n));case 2:i=o.v,o.n=4;break;case 3:if(o.p=3,r=o.v,i=this.fallbackData()){o.n=4;break}throw ui.error(Zr(r.status,n)),r;case 4:return o.a(2,(null===(t=i)||void 0===t?void 0:t.results)||[])}},null,this,[[1,3]],Promise)}},{key:"getPaywalls",value:function(e){var t,n,i,r;return k(function(o){for(;;)switch(o.p=o.n){case 0:return n=`device/${e}/paywalls/`,o.p=1,o.n=2,a(js.instance.fetchAPI(n));case 2:i=o.v,o.n=4;break;case 3:if(o.p=3,r=o.v,i=this.fallbackData()){o.n=4;break}throw ui.error(Zr(r.status,n)),r;case 4:return o.a(2,(null===(t=i)||void 0===t?void 0:t.results)||[])}},null,this,[[1,3]],Promise)}},{key:"fetchPaywallByUrl",value:function(e){return k(function(t){for(;;)if(0===t.n)return t.a(2,tl(e))},null,null,null,Promise)}},{key:"fetchPaywallsByUrls",value:function(e){var t,n,i,r,o,s,u,l;return k(function(d){for(;;)switch(d.n){case 0:return t=[...new Set(e)],d.n=1,a(Promise.allSettled(t.map(e=>this.fetchPaywallByUrl(e))));case 1:for(n=d.v,i=[],r=0,o=h(n);!(s=o()).done;)"fulfilled"===(u=s.value).status?(i.push(u.value.data),r+=u.value.retryCount):ui.error(`Failed to fetch individual paywall: ${u.reason}`);if(!(i.length>0)){d.n=2;break}return(l=this.validatePaywalls(i)).length>0&&Fr.setPaywalls(ut,l),d.a(2,{paywalls:l,retryCount:r});case 2:return d.a(2,{paywalls:i,retryCount:r})}},null,this,null,Promise)}},{key:"validatePaywalls",value:function(e){return e.filter(e=>{var t,n=null===(t=e.template)||void 0===t?void 0:t.pages;return!(!Array.isArray(n)||0===n.length)||(ui.warn(`Dropping paywall "${e.id}" from cache: template.pages is missing or empty`),!1)})}},{key:"fallbackData",value:function(){var e=Fr.getPaywalls(ut)||Fr.getPaywalls(St);return e?{count:e.length,results:e}:null}}])}();nl.instance=new nl;var il=function(){return c(function e(){o(this,e)},[{key:"fetchConfig",value:function(){var e,t;return k(function(n){for(;;)switch(n.p=n.n){case 0:return n.p=0,n.n=1,a(js.instance.fetchAPI("config/"));case 1:e=n.v,n.n=3;break;case 2:if(n.p=2,t=n.v,e=Fr.getAppConfig(at)||Fr.getAppConfig(yt)){n.n=3;break}throw ui.error(Zr(t.status,"config/")),t;case 3:return e&&Fr.setAppConfig(at,e),n.a(2,e)}},null,null,[[0,2]],Promise)}}])}();il.instance=new il;var al=null;function rl(){al&&al.setInMemoryAnonymousMode(!1)}function ol(){return!!Fr.getAnonymousMode()||!!al&&al.isInMemoryAnonymousMode()}var sl=function(){return c(function e(){o(this,e)},[{key:"startSession",value:function(){var e;return k(function(t){for(;;)switch(t.p=t.n){case 0:if(!ol()){t.n=1;break}return ui.debug("Skipping session start call - anonymous mode"),t.a(2);case 1:return t.p=1,t.n=2,a(js.instance.startSession(new Date));case 2:t.n=4;break;case 3:t.p=3,e=t.v,ui.error("error on start session: ",e);case 4:return t.a(2)}},null,null,[[1,3]],Promise)}}])}();sl.instance=new sl;var ul=function(){return c(function e(){o(this,e)},null,[{key:"allPurchases",value:function(){return[]}}])}();ul.instance=new ul;var ll={en:{nami_day:"day",nami_day_plural:"days",nami_week:"week",nami_week_plural:"weeks",nami_month:"month",nami_month_plural:"months",nami_year:"year",nami_year_plural:"years",nami_day_abbrev:"day",nami_day_abbrev_plural:"days",nami_week_abbrev:"wk",nami_week_abbrev_plural:"wks",nami_month_abbrev:"mo",nami_month_abbrev_plural:"mos",nami_year_abbrev:"yr",nami_year_abbrev_plural:"yrs",nami_daily:"daily",nami_weekly:"weekly",nami_biweekly:"bi-weekly",nami_monthly:"monthly",nami_bimonthly:"bi-monthly",nami_quarterly:"quarterly",nami_biannually:"bi-annually",nami_yearly:"yearly"},af:{nami_day_abbrev:"dag",nami_day_abbrev_plural:"dae",nami_week_abbrev:"week",nami_week_abbrev_plural:"weke",nami_month_abbrev:"ma",nami_month_abbrev_plural:"maande",nami_year_abbrev:"jr",nami_year_abbrev_plural:"jare",nami_daily:"daagliks",nami_weekly:"weekliks",nami_biweekly:"tweeweekliks",nami_monthly:"maandeliks",nami_bimonthly:"tweemaandeliks",nami_quarterly:"kwartaalliks",nami_biannually:"tweejaarliks",nami_yearly:"jaarliks"},am:{nami_day_abbrev:"ቀን",nami_day_abbrev_plural:"ቀናት",nami_week_abbrev:"ሳምንት",nami_week_abbrev_plural:"ሳምንታት",nami_month_abbrev:"ወር",nami_month_abbrev_plural:"ሞስ",nami_year_abbrev:"ዓመት",nami_year_abbrev_plural:"ዓመታት",nami_daily:"በየቀኑ",nami_weekly:"ሳምንታዊ",nami_biweekly:"በየሁለት ሳምንቱ",nami_monthly:"ወርሃዊ",nami_bimonthly:"በየሁለት ወሩ",nami_quarterly:"በየሩብ ዓመቱ",nami_biannually:"በየሁለት ዓመቱ",nami_yearly:"ዓመታዊ"},ar:{nami_day_abbrev:"يوم",nami_day_abbrev_plural:"أيام",nami_week_abbrev:"أسبوع",nami_week_abbrev_plural:"أسابيع",nami_month_abbrev:"شهر",nami_month_abbrev_plural:"موس",nami_year_abbrev:"سنة",nami_year_abbrev_plural:"سنوات",nami_daily:"يوميًا",nami_weekly:"أسبوعي",nami_biweekly:"كل أسبوعين",nami_monthly:"شهريا",nami_bimonthly:"كل شهرين",nami_quarterly:"ربع سنوي",nami_biannually:"مرتين في السنة",nami_yearly:"سنوي"},bg:{nami_day_abbrev:"ден",nami_day_abbrev_plural:"дни",nami_week_abbrev:"седмица",nami_week_abbrev_plural:"седмици",nami_month_abbrev:"мо",nami_month_abbrev_plural:"мос",nami_year_abbrev:"год.",nami_year_abbrev_plural:"години",nami_daily:"ежедневно",nami_weekly:"седмично",nami_biweekly:"двуседмичен",nami_monthly:"месечно",nami_bimonthly:"двумесечно",nami_quarterly:"тримесечно",nami_biannually:"два пъти годишно",nami_yearly:"годишно"},ca:{nami_day_abbrev:"dia",nami_day_abbrev_plural:"dies",nami_week_abbrev:"setmana",nami_week_abbrev_plural:"setmanes",nami_month_abbrev:"mes",nami_month_abbrev_plural:"mesos",nami_year_abbrev:"any",nami_year_abbrev_plural:"anys",nami_daily:"diàriament",nami_weekly:"setmanal",nami_biweekly:"quinzenal",nami_monthly:"mensual",nami_bimonthly:"bimensual",nami_quarterly:"trimestral",nami_biannually:"bianualment",nami_yearly:"anual"},cs:{nami_day_abbrev:"den",nami_day_abbrev_plural:"dny",nami_week_abbrev:"týden",nami_week_abbrev_plural:"týdny",nami_month_abbrev:"měsíc",nami_month_abbrev_plural:"měsíce",nami_year_abbrev:"rok",nami_year_abbrev_plural:"roky",nami_daily:"denní",nami_weekly:"týdně",nami_biweekly:"dvoutýdenní",nami_monthly:"měsíční",nami_bimonthly:"dvouměsíčník",nami_quarterly:"čtvrtletní",nami_biannually:"pololetně",nami_yearly:"roční"},de:{nami_day_abbrev:"Tag",nami_day_abbrev_plural:"Tage",nami_week_abbrev:"Woche",nami_week_abbrev_plural:"Wochen",nami_month_abbrev:"Monat",nami_month_abbrev_plural:"Monate",nami_year_abbrev:"Jahr",nami_year_abbrev_plural:"Jahre",nami_daily:"täglich",nami_weekly:"wöchentlich",nami_biweekly:"zweiwöchentlich",nami_monthly:"monatlich",nami_bimonthly:"zweimonatlich",nami_quarterly:"vierteljährlich",nami_biannually:"halbjährlich",nami_yearly:"jährlich"},el:{nami_day_abbrev:"ημέρα",nami_day_abbrev_plural:"ημέρες",nami_week_abbrev:"εβδομάδα",nami_week_abbrev_plural:"εβδομάδες",nami_month_abbrev:"μήνα",nami_month_abbrev_plural:"μην",nami_year_abbrev:"έτος",nami_year_abbrev_plural:"χρόνια",nami_daily:"καθημερινά",nami_weekly:"εβδομαδιαίος",nami_biweekly:"ανά δύο εβδομάδες",nami_monthly:"μηνιαίος",nami_bimonthly:"διμηνιαίος",nami_quarterly:"τριμηνιαίος",nami_biannually:"ανά εξάμηνο",nami_yearly:"ετήσια"},es:{nami_day_abbrev:"día",nami_day_abbrev_plural:"días",nami_week_abbrev:"semana",nami_week_abbrev_plural:"semanas",nami_month_abbrev:"mes",nami_month_abbrev_plural:"meses",nami_year_abbrev:"año",nami_year_abbrev_plural:"años",nami_daily:"diario",nami_weekly:"semanal",nami_biweekly:"quincenal",nami_monthly:"mensual",nami_bimonthly:"bimensual",nami_quarterly:"trimestral",nami_biannually:"semestral",nami_yearly:"anual"},et:{nami_day_abbrev:"päev",nami_day_abbrev_plural:"päevad",nami_week_abbrev:"nädal",nami_week_abbrev_plural:"nädalat",nami_month_abbrev:"kuu",nami_month_abbrev_plural:"kuud",nami_year_abbrev:"aasta",nami_year_abbrev_plural:"aastat",nami_daily:"iga päev",nami_weekly:"iganädalane",nami_biweekly:"iga kahe nädala tagant",nami_monthly:"igakuine",nami_bimonthly:"kaks korda kuus",nami_quarterly:"kvartali",nami_biannually:"kaks korda aastas",nami_yearly:"iga-aastane"},fa:{nami_day_abbrev:"روز",nami_day_abbrev_plural:"روزها",nami_week_abbrev:"هفته",nami_week_abbrev_plural:"هفتهها",nami_month_abbrev:"مو",nami_month_abbrev_plural:"موش",nami_year_abbrev:"سال",nami_year_abbrev_plural:"سال",nami_daily:"روزانه",nami_weekly:"هفتگی",nami_biweekly:"دو هفتهای",nami_monthly:"ماهانه",nami_bimonthly:"دوماهه",nami_quarterly:"سه ماهه",nami_biannually:"دوسالانه",nami_yearly:"سالانه"},fi:{nami_day_abbrev:"päivä",nami_day_abbrev_plural:"päivää",nami_week_abbrev:"viikko",nami_week_abbrev_plural:"viikkoa",nami_month_abbrev:"kuukausi",nami_month_abbrev_plural:"kuukaudet",nami_year_abbrev:"vuosi",nami_year_abbrev_plural:"vuotta",nami_daily:"päivittäin",nami_weekly:"viikoittain",nami_biweekly:"joka toinen viikko",nami_monthly:"kuukausittain",nami_bimonthly:"kahdesti kuussa",nami_quarterly:"neljännesvuosittain",nami_biannually:"puolivuosittain",nami_yearly:"vuosittain"},fr:{nami_day_abbrev:"jour",nami_day_abbrev_plural:"jours",nami_week_abbrev:"semaine",nami_week_abbrev_plural:"semaines",nami_month_abbrev:"mois",nami_month_abbrev_plural:"mois",nami_year_abbrev:"année",nami_year_abbrev_plural:"ans",nami_daily:"tous les jours",nami_weekly:"hebdomadaire",nami_biweekly:"bihebdomadaire",nami_monthly:"mensuel",nami_bimonthly:"bimensuel",nami_quarterly:"trimestriel",nami_biannually:"bisannuel",nami_yearly:"annuel"},hi:{nami_day_abbrev:"दिन",nami_day_abbrev_plural:"दिन",nami_week_abbrev:"सप्त",nami_week_abbrev_plural:"सप्त",nami_month_abbrev:"महीना",nami_month_abbrev_plural:"महीने",nami_year_abbrev:"साल",nami_year_abbrev_plural:"वर्षीय",nami_daily:"दैनिक",nami_weekly:"साप्ताहिक",nami_biweekly:"द्वि-साप्ताहिक",nami_monthly:"महीने के",nami_bimonthly:"द्विमासिक",nami_quarterly:"त्रैमासिक",nami_biannually:"द्वि-वार्षिक रूप",nami_yearly:"वार्षिक"},hr:{nami_day_abbrev:"dan",nami_day_abbrev_plural:"dana",nami_week_abbrev:"tjedan",nami_week_abbrev_plural:"tjedni",nami_month_abbrev:"mjesec",nami_month_abbrev_plural:"mjeseca",nami_year_abbrev:"god.",nami_year_abbrev_plural:"godina",nami_daily:"dnevno",nami_weekly:"tjedno",nami_biweekly:"dvotjedno",nami_monthly:"mjesečno",nami_bimonthly:"dvomjesečno",nami_quarterly:"tromjesečno",nami_biannually:"dvogodišnje",nami_yearly:"godišnje"},hu:{nami_day_abbrev:"nap",nami_day_abbrev_plural:"napok",nami_week_abbrev:"hét",nami_week_abbrev_plural:"hetek",nami_month_abbrev:"hónap",nami_month_abbrev_plural:"hónap",nami_year_abbrev:"év",nami_year_abbrev_plural:"év",nami_daily:"napi",nami_weekly:"heti",nami_biweekly:"kéthetente",nami_monthly:"havi",nami_bimonthly:"kéthavonta",nami_quarterly:"negyedévenként",nami_biannually:"félévente",nami_yearly:"évi"},id:{nami_day_abbrev:"hari",nami_day_abbrev_plural:"hari",nami_week_abbrev:"minggu",nami_week_abbrev_plural:"minggu",nami_month_abbrev:"bulan",nami_month_abbrev_plural:"bulan",nami_year_abbrev:"tahun",nami_year_abbrev_plural:"tahun",nami_daily:"sehari-hari",nami_weekly:"mingguan",nami_biweekly:"dua kali seminggu",nami_monthly:"bulanan",nami_bimonthly:"dua bulanan",nami_quarterly:"triwulanan",nami_biannually:"dua tahunan",nami_yearly:"tahunan"},it:{nami_day_abbrev:"giorno",nami_day_abbrev_plural:"giorni",nami_week_abbrev:"settimana",nami_week_abbrev_plural:"settimane",nami_month_abbrev:"mese",nami_month_abbrev_plural:"mesi",nami_year_abbrev:"anno",nami_year_abbrev_plural:"anni",nami_daily:"quotidiano",nami_weekly:"settimanale",nami_biweekly:"bisettimanale",nami_monthly:"mensile",nami_bimonthly:"bimestrale",nami_quarterly:"trimestrale",nami_biannually:"semestralmente",nami_yearly:"annuale"},he:{nami_day_abbrev:"יְוֹם",nami_day_abbrev_plural:"ימים",nami_week_abbrev:"שבוע",nami_week_abbrev_plural:"שבועות",nami_month_abbrev:"מו",nami_month_abbrev_plural:"מוֹס",nami_year_abbrev:"שנה",nami_year_abbrev_plural:"שנים",nami_daily:"יוֹמִי",nami_weekly:"שְׁבוּעִי",nami_biweekly:"דו-שבועי",nami_monthly:"יַרחוֹן",nami_bimonthly:"דו-חודשי",nami_quarterly:"רִבעוֹן",nami_biannually:"דו-שנתי",nami_yearly:"שְׁנָתִי"},ja:{nami_day_abbrev:"日",nami_day_abbrev_plural:"日",nami_week_abbrev:"週",nami_week_abbrev_plural:"週",nami_month_abbrev:"モ",nami_month_abbrev_plural:"モス",nami_year_abbrev:"年",nami_year_abbrev_plural:"年",nami_daily:"毎日",nami_weekly:"毎週",nami_biweekly:"隔週",nami_monthly:"毎月",nami_bimonthly:"隔月",nami_quarterly:"四半期ごと",nami_biannually:"半年ごと",nami_yearly:"毎年"},ko:{nami_day_abbrev:"낮",nami_day_abbrev_plural:"날",nami_week_abbrev:"주",nami_week_abbrev_plural:"주",nami_month_abbrev:"모",nami_month_abbrev_plural:"모스",nami_year_abbrev:"년",nami_year_abbrev_plural:"년",nami_daily:"일일",nami_weekly:"주간",nami_biweekly:"격주 간행물",nami_monthly:"월간 간행물",nami_bimonthly:"격월",nami_quarterly:"계간지",nami_biannually:"반년마다",nami_yearly:"매년"},lt:{nami_day_abbrev:"diena",nami_day_abbrev_plural:"dienos",nami_week_abbrev:"savaitė",nami_week_abbrev_plural:"savaitės",nami_month_abbrev:"mėn.",nami_month_abbrev_plural:"mėn.",nami_year_abbrev:"metai",nami_year_abbrev_plural:"metų",nami_daily:"kasdien",nami_weekly:"kas savaitę",nami_biweekly:"kas dvi savaites",nami_monthly:"mėnesinis",nami_bimonthly:"kas du mėnesius",nami_quarterly:"ketvirtinis",nami_biannually:"kas du kartus per metus",nami_yearly:"kasmet"},lv:{nami_day_abbrev:"diena",nami_day_abbrev_plural:"dienas",nami_week_abbrev:"nedēļa",nami_week_abbrev_plural:"nedēļas",nami_month_abbrev:"mēn.",nami_month_abbrev_plural:"mēn.",nami_year_abbrev:"gads",nami_year_abbrev_plural:"gadi",nami_daily:"ikdienas",nami_weekly:"iknedēļas",nami_biweekly:"divreiz nedēļā",nami_monthly:"ikmēneša",nami_bimonthly:"divreiz mēnesī",nami_quarterly:"ceturksnī",nami_biannually:"divreiz gadā",nami_yearly:"katru gadu"},ms:{nami_day_abbrev:"hari",nami_day_abbrev_plural:"hari",nami_week_abbrev:"minggu",nami_week_abbrev_plural:"minggu",nami_month_abbrev:"bulan",nami_month_abbrev_plural:"bulan",nami_year_abbrev:"tahun",nami_year_abbrev_plural:"tahun",nami_daily:"setiap hari",nami_weekly:"mingguan",nami_biweekly:"dua minggu sekali",nami_monthly:"bulanan",nami_bimonthly:"dua kali sebulan",nami_quarterly:"suku tahunan",nami_biannually:"dua kali setahun",nami_yearly:"tahunan"},nl:{nami_day_abbrev:"dag",nami_day_abbrev_plural:"dagen",nami_week_abbrev:"week",nami_week_abbrev_plural:"weken",nami_month_abbrev:"maand",nami_month_abbrev_plural:"maanden",nami_year_abbrev:"jaar",nami_year_abbrev_plural:"jaren",nami_daily:"dagelijks",nami_weekly:"wekelijks",nami_biweekly:"tweewekelijks",nami_monthly:"maandelijks",nami_bimonthly:"tweemaandelijks",nami_quarterly:"kwartaal",nami_biannually:"halfjaarlijks",nami_yearly:"jaarlijks"},no:{nami_day_abbrev:"dag",nami_day_abbrev_plural:"dager",nami_week_abbrev:"uke",nami_week_abbrev_plural:"uker",nami_month_abbrev:"måned",nami_month_abbrev_plural:"måned",nami_year_abbrev:"år",nami_year_abbrev_plural:"år",nami_daily:"daglig",nami_weekly:"ukentlig",nami_biweekly:"annenhver uke",nami_monthly:"månedlig",nami_bimonthly:"annenhver måned",nami_quarterly:"kvartalsvis",nami_biannually:"to ganger i året",nami_yearly:"årlig"},pl:{nami_day_abbrev:"dzień",nami_day_abbrev_plural:"dni",nami_week_abbrev:"tydzień",nami_week_abbrev_plural:"tygodni",nami_month_abbrev:"miesiąc",nami_month_abbrev_plural:"miesiące",nami_year_abbrev:"rok",nami_year_abbrev_plural:"lat",nami_daily:"codziennie",nami_weekly:"tygodnik",nami_biweekly:"dwutygodniowy",nami_monthly:"miesięczny",nami_bimonthly:"dwumiesięczny",nami_quarterly:"kwartalny",nami_biannually:"dwa razy w roku",nami_yearly:"rocznie"},pt:{nami_day_abbrev:"dia",nami_day_abbrev_plural:"dias",nami_week_abbrev:"semana",nami_week_abbrev_plural:"semanas",nami_month_abbrev:"mês",nami_month_abbrev_plural:"meses",nami_year_abbrev:"ano",nami_year_abbrev_plural:"anos",nami_daily:"diário",nami_weekly:"semanalmente",nami_biweekly:"quinzenal",nami_monthly:"mensal",nami_bimonthly:"bimestral",nami_quarterly:"trimestral",nami_biannually:"bianualmente",nami_yearly:"anual"},ro:{nami_day_abbrev:"zi",nami_day_abbrev_plural:"zile",nami_week_abbrev:"săptămână",nami_week_abbrev_plural:"săptămâni",nami_month_abbrev:"lună",nami_month_abbrev_plural:"luni",nami_year_abbrev:"an",nami_year_abbrev_plural:"ani",nami_daily:"zilnic",nami_weekly:"săptămânal",nami_biweekly:"la două săptămâni",nami_monthly:"lunar",nami_bimonthly:"bilunar",nami_quarterly:"trimestrial",nami_biannually:"bianual",nami_yearly:"anual"},ru:{nami_day_abbrev:"день",nami_day_abbrev_plural:"дни",nami_week_abbrev:"нед",nami_week_abbrev_plural:"недели",nami_month_abbrev:"мо",nami_month_abbrev_plural:"мос",nami_year_abbrev:"год",nami_year_abbrev_plural:"лет",nami_daily:"ежедневно",nami_weekly:"еженедельный",nami_biweekly:"раз в две недели",nami_monthly:"ежемесячно",nami_bimonthly:"раз в два месяца",nami_quarterly:"ежеквартальный",nami_biannually:"раз в два года",nami_yearly:"ежегодно"},sk:{nami_day_abbrev:"deň",nami_day_abbrev_plural:"dni",nami_week_abbrev:"týždeň",nami_week_abbrev_plural:"týždne",nami_month_abbrev:"mesiac",nami_month_abbrev_plural:"mesiacov",nami_year_abbrev:"rok",nami_year_abbrev_plural:"rokov",nami_daily:"denne",nami_weekly:"týždenne",nami_biweekly:"dvojtýždenne",nami_monthly:"mesačne",nami_bimonthly:"dvojmesačne",nami_quarterly:"štvrťročne",nami_biannually:"polročne",nami_yearly:"ročne"},sl:{nami_day_abbrev:"dan",nami_day_abbrev_plural:"dni",nami_week_abbrev:"teden",nami_week_abbrev_plural:"tedni",nami_month_abbrev:"mesec",nami_month_abbrev_plural:"mesecev",nami_year_abbrev:"leto",nami_year_abbrev_plural:"let",nami_daily:"dnevno",nami_weekly:"tedensko",nami_biweekly:"dvotedensko",nami_monthly:"mesečno",nami_bimonthly:"dvomesečno",nami_quarterly:"četrtletno",nami_biannually:"polletno",nami_yearly:"letno"},sr:{nami_day_abbrev:"дан",nami_day_abbrev_plural:"дана",nami_week_abbrev:"недеља",nami_week_abbrev_plural:"недеље",nami_month_abbrev:"мо",nami_month_abbrev_plural:"мос",nami_year_abbrev:"год.",nami_year_abbrev_plural:"године",nami_daily:"свакодневно",nami_weekly:"недељно",nami_biweekly:"двонедељно",nami_monthly:"месечно",nami_bimonthly:"двомесечно",nami_quarterly:"квартално",nami_biannually:"два пута годишње",nami_yearly:"годишње"},sv:{nami_day_abbrev:"dag",nami_day_abbrev_plural:"dagar",nami_week_abbrev:"vecka",nami_week_abbrev_plural:"veckor",nami_month_abbrev:"mån",nami_month_abbrev_plural:"månader",nami_year_abbrev:"år",nami_year_abbrev_plural:"år",nami_daily:"dagligen",nami_weekly:"varje vecka",nami_biweekly:"som utkommer varannan vecka",nami_monthly:"månatlig",nami_bimonthly:"varannan månad",nami_quarterly:"kvartalsvis",nami_biannually:"vartannat år",nami_yearly:"årlig"},sw:{nami_day_abbrev:"siku",nami_day_abbrev_plural:"siku",nami_week_abbrev:"wiki",nami_week_abbrev_plural:"wiki",nami_month_abbrev:"mwezi",nami_month_abbrev_plural:"miezi",nami_year_abbrev:"mwaka",nami_year_abbrev_plural:"miaka",nami_daily:"kila siku",nami_weekly:"kila wiki",nami_biweekly:"kila wiki mbili",nami_monthly:"kila mwezi",nami_bimonthly:"kila baada ya miezi miwili",nami_quarterly:"robo mwaka",nami_biannually:"kila baada ya miaka miwili",nami_yearly:"kila mwaka"},th:{nami_day_abbrev:"วัน",nami_day_abbrev_plural:"วัน",nami_week_abbrev:"สัปดาห์",nami_week_abbrev_plural:"สัปดาห์",nami_month_abbrev:"โม",nami_month_abbrev_plural:"มอส",nami_year_abbrev:"ปี",nami_year_abbrev_plural:"ปี",nami_daily:"รายวัน",nami_weekly:"รายสัปดาห์",nami_biweekly:"สองสัปดาห์ครั้ง",nami_monthly:"รายเดือน",nami_bimonthly:"สองเดือนครั้ง",nami_quarterly:"ไตรมาส",nami_biannually:"ทุกสองปี",nami_yearly:"ทุกปี"},tr:{nami_day_abbrev:"gün",nami_day_abbrev_plural:"günler",nami_week_abbrev:"hafta",nami_week_abbrev_plural:"haftalar",nami_month_abbrev:"ay",nami_month_abbrev_plural:"aylar",nami_year_abbrev:"yıl",nami_year_abbrev_plural:"yıllar",nami_daily:"günlük",nami_weekly:"haftalık",nami_biweekly:"iki haftada bir",nami_monthly:"aylık",nami_bimonthly:"iki ayda bir",nami_quarterly:"üç aylık",nami_biannually:"iki yılda bir",nami_yearly:"yıllık"},uk:{nami_day_abbrev:"день",nami_day_abbrev_plural:"дні",nami_week_abbrev:"тиждень",nami_week_abbrev_plural:"тижні",nami_month_abbrev:"місяць",nami_month_abbrev_plural:"мос",nami_year_abbrev:"рік",nami_year_abbrev_plural:"років",nami_daily:"щоденно",nami_weekly:"щотижня",nami_biweekly:"раз на два тижні",nami_monthly:"щомісяця",nami_bimonthly:"раз на два місяці",nami_quarterly:"щоквартально",nami_biannually:"раз на півроку",nami_yearly:"щорічно"},vi:{nami_day_abbrev:"ngày",nami_day_abbrev_plural:"ngày",nami_week_abbrev:"tuần",nami_week_abbrev_plural:"tuần",nami_month_abbrev:"tháng",nami_month_abbrev_plural:"tháng",nami_year_abbrev:"năm",nami_year_abbrev_plural:"năm",nami_daily:"hằng ngày",nami_weekly:"hàng tuần",nami_biweekly:"hai tuần một lần",nami_monthly:"hàng tháng",nami_bimonthly:"hai tháng một lần",nami_quarterly:"hàng quý",nami_biannually:"hai năm một lần",nami_yearly:"hàng năm"},"zh-CN":{nami_day_abbrev:"天",nami_day_abbrev_plural:"天",nami_week_abbrev:"周",nami_week_abbrev_plural:"周",nami_month_abbrev:"莫",nami_month_abbrev_plural:"莫斯",nami_year_abbrev:"年",nami_year_abbrev_plural:"年",nami_daily:"日常的",nami_weekly:"每周",nami_biweekly:"每两周一次",nami_monthly:"月度",nami_bimonthly:"双月刊",nami_quarterly:"季刊",nami_biannually:"每半年",nami_yearly:"每年"},"zh-TW":{nami_day_abbrev:"天",nami_day_abbrev_plural:"天",nami_week_abbrev:"週",nami_week_abbrev_plural:"週",nami_month_abbrev:"莫",nami_month_abbrev_plural:"莫斯",nami_year_abbrev:"年",nami_year_abbrev_plural:"年",nami_daily:"日常的",nami_weekly:"每週",nami_biweekly:"每兩週一次",nami_monthly:"每月",nami_bimonthly:"雙月刊",nami_quarterly:"季刊",nami_biannually:"每半年",nami_yearly:"每年"},zu:{nami_day_abbrev:"usuku",nami_day_abbrev_plural:"izinsuku",nami_week_abbrev:"isonto",nami_week_abbrev_plural:"amasonto",nami_month_abbrev:"inyanga",nami_month_abbrev_plural:"i-mos",nami_year_abbrev:"unyaka",nami_year_abbrev_plural:"iminyaka",nami_daily:"nsuku zonke",nami_weekly:"masonto onke",nami_biweekly:"kabili ngesonto",nami_monthly:"nyanga zonke",nami_bimonthly:"kabili ngenyanga",nami_quarterly:"njalo ngekota",nami_biannually:"kabili ngonyaka",nami_yearly:"minyaka yonke"}},dl="en";function cl(e){var t,n,i=function(e){if(!e)return dl;var t=e.trim();if(ll[t])return t;var n=t.toLowerCase(),i=n.split("-")[0];return ll[i]?i:"zh"===i?n.includes("tw")||n.includes("hk")?"zh-TW":"zh-CN":dl}(Fr.getLanguageCode()),a=null!==(t=ll[i])&&void 0!==t?t:ll[dl];return null!==(n=null==a?void 0:a[e])&&void 0!==n?n:e}function hl(e){if("subscription"===(null==e?void 0:e.product_type)){var t=fl(e);if(t.length>0)return t[0].billingPeriod}return null}function ml(e){var t=function(e){if(!e)return[];var t=e.offers.filter(e=>"promo"===e.offer_type);return vl(t,e.subscription_period)}(e).find(e=>0===e.priceAmountMicros);return(null==t?void 0:t.billingPeriod)||null}function fl(e){return e?vl(e.offers.filter(e=>"default"===e.offer_type),e.subscription_period):[]}function vl(e,t){return e.map(e=>pl(e,t))}function pl(e,t){var n,i,a,r,o,s,u,l;if(!e)return{};var d=null!==(n=null===(i=e.promo_period)||void 0===i?void 0:i.count)&&void 0!==n?n:null==t?void 0:t.count,c=null!==(a=null===(r=e.promo_period)||void 0===r?void 0:r.type)&&void 0!==a?a:null==t?void 0:t.type,h=null!==(o=null===(s=e.promo_price)||void 0===s?void 0:s.price)&&void 0!==o?o:e.price,m=null!==(u=null===(l=e.promo_price)||void 0===l?void 0:l.currency)&&void 0!==u?u:e.currency;return{priceAmountMicros:1e6*h,priceCurrencyCode:m,billingPeriod:c?`P${d}${c[0].toUpperCase()}`:"",formattedPrice:bl(m).format(h)}}function gl(e,t=!1,n=!1,i=!1,a=!1){if(!e)return null;var r=e.match(/P(?:(\d+)Y)?(?:(\d+)M)?(?:(\d+)W)?(?:(\d+)D)?/);if(!r)return null;var o=r.slice(1).map(e=>parseInt(e)),s=o[0],u=o[1],l=o[2],d=o[3],c=(e,t,n,i,r)=>{var o=(e=>a?`${e}_abbrev`:e)(r),s=(e=>a?`${e}_abbrev_plural`:`${e}_plural`)(r),u=cl(o),l=cl(s);return a||u!==o||(u=cl(`${r}_abbrev`)),a||l!==s||(l=cl(`${r}_abbrev_plural`)),i?e.toString():n?1===e||t?u:l:1===e||t?`${e} ${u}`:`${e} ${l}`};switch(e.at(-1)){case"D":return c(d,t,n,i,"nami_day");case"W":return c(l,t,n,i,"nami_week");case"M":return c(u,t,n,i,"nami_month");case"Y":return c(s,t,n,i,"nami_year")}return null}function yl(e){var t;if(!e||e.length<2)return!1;var n=null===(t=e.at(-1))||void 0===t?void 0:t.toUpperCase();return"M"===n||"Y"===n}function bl(e){var t={maximumFractionDigits:2,minimumFractionDigits:0},n=we().device.getLanguage();try{return new Intl.NumberFormat(n,m({},t,{style:"currency",currency:e}))}catch(e){return new Intl.NumberFormat(n,m({},t,{style:"currency",currency:"USD"}))}}var wl=(e,t,n)=>e&&t&&n?n.format(e-t):null,kl=(e,t,n,i)=>{if(e&&t&&n&&i){var a=100*(1-e/(n/i*t));return`${Math.round(a)}%`}return null},Sl=(e,t)=>{if(""!=t){var n=parseInt(t)-1;return n>=0&&n<(null==e?void 0:e.length)?e[n]:null==e?void 0:e.find(e=>e.sku_ref_id===t)}},El=e=>Tl(e.priceAmountMicros)/Pl(e.billingPeriod),Pl=e=>{var t=parseInt(e[1]);return e.includes("Y")&&(t*=12),t},Tl=e=>e/1e6;function _l(e){return parseFloat((Math.round(e)/100).toFixed(2))}var Ml=(e,t,n=[])=>({price:()=>Dl(e),name:()=>null==e?void 0:e.name,title:()=>null==e?void 0:e.name,description:()=>null==e?void 0:e.description,duration:()=>xl(e),durationSingular:()=>xl(e,!0),period:()=>xl(e,!1,!0),periodNumber:()=>xl(e,!1,!1,!0),freeTrialDuration:()=>Cl(e),freeTrialDurationSingular:()=>Cl(e,!0),freeTrialPeriod:()=>Cl(e,!1,!0),freeTrialPeriodNumber:()=>Cl(e,!1,!1,!0),pricePerMonth:()=>Il(e),pricePerMonthRounded:()=>Il(e,!0),periodInMonths:()=>Ll(e),durationInMonths:()=>Rl(e),durationInMonthsSingular:()=>Rl(e,!0),periodNumberInMonths:()=>Fl(e),percentagePriceDifferenceFromSku:()=>Ol(e,t,n),priceDifferenceFromSku:()=>$l(e,t,n),promoEligible:()=>null===Nl(e)&&null!==Wl(e,t),freeTrialEligible:()=>null!==Nl(e),promo:()=>{var n;return null===(n=Wl(e,t))||void 0===n?void 0:n.offer_ref_id},promoCode:()=>"XXXXX",promoPrice:()=>{var n;return null===(n=jl(e,t))||void 0===n?void 0:n.formattedPrice},promoPeriod:()=>Bl(e,t,!1,!0),promoPeriodNumber:()=>Bl(e,t,!1,!1,!0),promoDuration:()=>Bl(e,t),promoDurationSingular:()=>Bl(e,t,!0),introEligible:()=>!1,pricePerDay:()=>zl(e),pricePerWeek:()=>Ul(e),pricePerWeekRounded:()=>Ul(e,!0),introductoryPrice:()=>Hl(e,t),introductoryPeriod:()=>Gl(e,t,!1,!0),introductoryPeriodNumber:()=>Gl(e,t,!1,!1,!0),introductoryDuration:()=>Gl(e,t),introductoryDurationSingular:()=>Gl(e,t,!0),introductoryPricePerMonth:()=>Vl(e,t),introductoryPricePerMonthRounded:()=>Vl(e,t,!0),durationAbbrev:()=>xl(e,!1,!1,!1,!0),freeTrialDurationAbbrev:()=>Cl(e,!1,!1,!1,!0),introductoryDurationAbbrev:()=>Gl(e,t,!1,!1,!1,!0),promoDurationAbbrev:()=>Bl(e,t,!1,!1,!1,!0),promoDurationPhase2Abbrev:()=>Bl(e,t,!0,!0,!1,!0),durationInMonthsAbbrev:()=>Rl(e,!1,!1,!1,!0),durationSingularAbbrev:()=>xl(e,!0,!1,!1,!0),freeTrialDurationSingularAbbrev:()=>Cl(e,!0,!1,!1,!0),introductoryDurationSingularAbbrev:()=>Gl(e,t,!0,!1,!1,!0),promoDurationSingularAbbrev:()=>Bl(e,t,!0,!1,!1,!0),promoDurationSingularPhase2Abbrev:()=>Bl(e,t,!0,!0,!1,!0),durationInMonthsSingularAbbrev:()=>Rl(e,!0,!1,!1,!0),periodAbbrev:()=>xl(e,!1,!0,!1,!0),freeTrialPeriodAbbrev:()=>Cl(e,!1,!0,!1,!0),introductoryPeriodAbbrev:()=>Gl(e,t,!1,!0,!1,!0),promoPeriodAbbrev:()=>Bl(e,t,!1,!0,!1,!0),promoPeriodPhase2Abbrev:()=>Bl(e,t,!1,!0,!0,!0),periodInMonthsAbbrev:()=>Rl(e,!1,!0,!1,!0),periodly:()=>function(e){if(!e)return null;var t=e.match(/P(?:(\d+)Y)?(?:(\d+)M)?(?:(\d+)W)?(?:(\d+)D)?/);if(!t)return null;var n=t[1],i=t[2],a=t[3],r=t[4],o=void 0!==n?parseInt(n,10):0,s=void 0!==i?parseInt(i,10):0,u=void 0!==a?parseInt(a,10):0;return(void 0!==r?parseInt(r,10):0)>0?null:u>0?1===u?cl("nami_weekly"):2===u?cl("nami_biweekly"):null:s>0?cl(1===s?"nami_monthly":2===s?"nami_bimonthly":3===s?"nami_quarterly":6===s?"nami_biannually":12===s?"nami_yearly":"nami_monthly"):o>0?cl("nami_yearly"):null}(hl(e)),iso_subscription_duration:()=>Xl(e),invalid:()=>!1,unavailable:()=>!1}),Al=(e,t,n,i=[])=>{if(!t)return null;var a=Ml(t,n,i);return a[e]?a[e]():null},Dl=e=>{var t=fl(e);return t&&t.length?t[0].formattedPrice:null},xl=(e,t,n,i,a)=>gl(hl(e),t,n,i,a),Cl=(e,t,n,i,a)=>gl(ml(e),t,n,i,a),Il=(e,t)=>{var n=fl(e);if(!n||0===n.length)return null;var i=El(n[0]);return i?bl(n[0].priceCurrencyCode).format(t?Math.round(i):i):null},Ll=(e,t)=>{var n=fl(e);if(!n||0===n.length)return null;var i=n[0].billingPeriod;return yl(i)?gl("P1Y"===i?"P12M":i,!1,!1,!1,t):null},Rl=(e,t,n,i,a)=>{var r=fl(e);if(!r||0===r.length)return null;var o=r[0].billingPeriod;return yl(o)?gl("P1Y"===o?"P12M":o,t,n,i,a):null},Fl=e=>{if(!e)return 0;var t=fl(e);return t&&t.length?Pl(t[0].billingPeriod):0},Ol=(e,t,n=[])=>{var i,a=fl(e);if(!a||0===a.length)return null;var r=null===(i=Sl(n,null!=t?t:""))||void 0===i?void 0:i.product_details;if(!t||!r)return kl(_l(a[0].priceAmountMicros),Fl(e));var o=fl(r);return kl(_l(a[0].priceAmountMicros),Fl(e),(null==o?void 0:o.length)>0?_l(o[0].priceAmountMicros):0,Fl(r))},$l=(e,t,n=[])=>{var i,a=fl(e);if(!a||0===a.length)return null;var r=null===(i=Sl(n,null!=t?t:""))||void 0===i?void 0:i.product_details;if(!t||!r)return wl(El(a[0]));var o=fl(r);return wl(El(a[0]),El(o[0]),bl(o[0].priceCurrencyCode))},Nl=e=>ml(e),Wl=(e,t)=>{if(!e)return null;var n=e.offers.filter(e=>"promo"===e.offer_type);if(!t)return n[0]||null;var i=n[parseInt(t)];return i?i||null:n.find(e=>e.offer_ref_id===t)||null},jl=(e,t)=>e?pl(Wl(e,t),e.subscription_period):null,Bl=(e,t,n,i,a,r)=>{var o=jl(e,t);return gl((null==o?void 0:o.billingPeriod)||null,n,i,a,r)},zl=(e,t)=>{var n=fl(e);if(!n||0===n.length)return null;var i,a,r=Tl(n[0].priceAmountMicros)/(i=n[0].billingPeriod,(a=Pl(i))?30.437*a:1);return r?bl(n[0].priceCurrencyCode).format(r):null},Ul=(e,t)=>{var n=fl(e);if(!n||0===n.length)return null;var i,a,r=Tl(n[0].priceAmountMicros)/(i=n[0].billingPeriod,(a=Pl(i))?52*a/12:1);return r?bl(n[0].priceCurrencyCode).format(t?Math.round(r):r):null},Hl=(e,t)=>{var n=Kl(e,t);return(null==n?void 0:n.formattedPrice)||null},Gl=(e,t,n,i,a,r)=>{var o=Kl(e,t);return gl((null==o?void 0:o.billingPeriod)||null,n,i,a,r)},Vl=(e,t,n)=>{var i=Kl(e,t);if(i){var a=Tl(i.priceAmountMicros),r=Pl(i.billingPeriod),o=n?Math.round(a/r):a/r;return bl(i.priceCurrencyCode).format(o)}},Kl=(e,t)=>{return e?(t?(n=e.offers[parseInt(t)])||(n=e.offers.find(e=>e.offer_ref_id===t)||null):n=e.offers[0],pl(n,e.subscription_period)):null;var n},Xl=e=>{var t=hl(e);return t?"P7D"===t?"P1W":t:null};function Yl(e,t,n,i){var a=n.flatMap(e=>e.products).find(e=>e.id===t.selectedProducts[t.currentGroupId]);return Jl(ed(e,null==a?void 0:a.sku_ref_id),a,i)}function ql(e,t,n){var i,a,r=null!==(i=null===(a=t.find(e=>e.id===n))||void 0===a?void 0:a.products)&&void 0!==i?i:[];return r.forEach(t=>{t.product_details=ed(e,t.sku_ref_id||""),t.variables=Jl(t.product_details,t,r)}),r}function Jl(e,t,n){if(!t)return{};var i=t.variables;if(!i)return m({},t);Object.keys(i).forEach(t=>{if("string"==typeof(r=i[t])&&r.includes(ni)){var a=Ql(i[t],e,n);i[t]=function(e){if(!e||e.includes("null")||e.includes("undefined"))return"";if(/\$\{\s*(launch\.customAttributes\.|sku\.)\w+\s*}/.test(e))return"";return e}(a)}var r});var a={};return Object.keys(Ml({})).forEach(t=>{if(void 0===i[t]){var r=Al(t,e,void 0,n);null!==r&&(a[t]=r)}}),m({},t,a,i)}var Ql=(e,t,n)=>e.replace(Qn,(i,a)=>{var r,o,s,u,l=(null===(r=Qn.exec(e))||void 0===r?void 0:r.slice(1))||[];a=null!==(o=l[0])&&void 0!==o?o:a;var d=null!==(s=null===(u=l[1])||void 0===u?void 0:u.replace(":",""))&&void 0!==s?s:"";return Al(a,t,d,n)});function Zl(e,t){return t.flatMap(e=>e.products).some(t=>1==Al("freeTrialEligible",ed(e,t.sku_ref_id)))}function ed(e=[],t=""){return e.find(e=>e.product_ref_id===t)||null}var td=function(){try{var e=Wi(Object,"defineProperty");return e({},"",{}),e}catch(e){}}();var nd=Object.prototype.hasOwnProperty;function id(e,t,n){var i=e[t];nd.call(e,t)&&di(i,n)&&(void 0!==n||t in e)||function(e,t,n){"__proto__"==t&&td?td(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[t]=n}(e,t,n)}var ad="object"==typeof e&&e&&!e.nodeType&&e,rd=ad&&"object"==typeof module&&module&&!module.nodeType&&module,od=rd&&rd.exports===ad?pi.Buffer:void 0;od&&od.allocUnsafe;var sd=Ia(Object.getPrototypeOf,Object),ud=Object.prototype.hasOwnProperty;function ld(e){var t=new e.constructor(e.byteLength);return new Qi(t).set(new Qi(e)),t}var dd=/\w*$/;var cd=gi?gi.prototype:void 0,hd=cd?cd.valueOf:void 0;function md(e,t,n){var i,a,r,o=e.constructor;switch(t){case"[object ArrayBuffer]":return ld(e);case"[object Boolean]":case"[object Date]":return new o(+e);case"[object DataView]":return r=ld((a=e).buffer),new a.constructor(r,a.byteOffset,a.byteLength);case"[object Float32Array]":case"[object Float64Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":return function(e){var t=ld(e.buffer);return new e.constructor(t,e.byteOffset,e.length)}(e);case"[object Map]":case"[object Set]":return new o;case"[object Number]":case"[object String]":return new o(e);case"[object RegExp]":return function(e){var t=new e.constructor(e.source,dd.exec(e));return t.lastIndex=e.lastIndex,t}(e);case"[object Symbol]":return i=e,hd?Object(hd.call(i)):{}}}var fd=Object.create,vd=function(){function e(){}return function(t){if(!Ti(t))return{};if(fd)return fd(t);e.prototype=t;var n=new e;return e.prototype=void 0,n}}();var pd=Ta&&Ta.isMap,gd=pd?ka(pd):function(e){return sa(e)&&"[object Map]"==Qa(e)};var yd=Ta&&Ta.isSet,bd=yd?ka(yd):function(e){return sa(e)&&"[object Set]"==Qa(e)},wd="[object Arguments]",kd="[object Function]",Sd="[object Object]",Ed={};function Pd(e,t,n,i,a,r){var o;if(void 0!==o)return o;if(!Ti(e))return e;var s=ia(e);if(s)o=function(e){var t=e.length,n=new e.constructor(t);return t&&"string"==typeof e[0]&&ud.call(e,"index")&&(n.index=e.index,n.input=e.input),n}(e);else{var u=Qa(e),l=u==kd||"[object GeneratorFunction]"==u;if(pa(e))return e.slice();if(u==Sd||u==wd||l&&!a)o=l?{}:function(e){return"function"!=typeof e.constructor||Ca(e)?{}:vd(sd(e))}(e);else{if(!Ed[u])return a?e:{};o=md(e,u)}}r||(r=new Ki);var d=r.get(e);if(d)return d;r.set(e,o),bd(e)?e.forEach(function(i){o.add(Pd(i,t,n,i,e,r))}):gd(e)&&e.forEach(function(i,a){o.set(a,Pd(i,t,n,a,e,r))});var c=s?void 0:Oa(e);return function(e,t){for(var n=-1,i=null==e?0:e.length;++n<i&&!1!==t(e[n],n,e););}(c||e,function(i,a){c&&(i=e[a=i]),id(o,a,Pd(i,t,n,a,e,r))}),o}Ed[wd]=Ed["[object Array]"]=Ed["[object ArrayBuffer]"]=Ed["[object DataView]"]=Ed["[object Boolean]"]=Ed["[object Date]"]=Ed["[object Float32Array]"]=Ed["[object Float64Array]"]=Ed["[object Int8Array]"]=Ed["[object Int16Array]"]=Ed["[object Int32Array]"]=Ed["[object Map]"]=Ed["[object Number]"]=Ed[Sd]=Ed["[object RegExp]"]=Ed["[object Set]"]=Ed["[object String]"]=Ed["[object Symbol]"]=Ed["[object Uint8Array]"]=Ed["[object Uint8ClampedArray]"]=Ed["[object Uint16Array]"]=Ed["[object Uint32Array]"]=!0,Ed["[object Error]"]=Ed[kd]=Ed["[object WeakMap]"]=!1;var Td=e=>"object"==typeof e&&null!==e&&"handleEvent"in e,_d=(e,t,n)=>{var i=Object.getOwnPropertyDescriptor(e,t);if(!i||i.configurable)try{Object.defineProperty(e,t,{configurable:!0,enumerable:!1,value:n,writable:!1})}catch(i){try{e[t]=n}catch(e){}}},Md=function(){return c(function e(){o(this,e),this.listeners=new Map},[{key:"addEventListener",value:function(e,t,n){var i;if(t){var a=(e=>"boolean"==typeof e?{capture:e}:null!=e?e:{})(n),r=null!==(i=this.listeners.get(e))&&void 0!==i?i:[];if(!r.some(e=>e.listener===t)){var o={listener:t,once:Boolean(a.once)};if(a.signal){if(a.signal.aborted)return;o.signal=a.signal,o.abortHandler=()=>this.removeEventListener(e,t),a.signal.addEventListener("abort",o.abortHandler,{once:!0})}r.push(o),this.listeners.set(e,r)}}}},{key:"removeEventListener",value:function(e,t){if(t){var n=this.listeners.get(e);if(n&&0!==n.length){for(var i=n.length-1;i>=0;i-=1){var a=n[i];a.listener===t&&(a.signal&&a.abortHandler&&a.signal.removeEventListener("abort",a.abortHandler),n.splice(i,1))}0===n.length&&this.listeners.delete(e)}}}},{key:"dispatchEvent",value:function(e){var t,n;if(!e||"string"!=typeof e.type)throw new TypeError('Failed to execute "dispatchEvent": event type must be a string.');var i=this.listeners.get(e.type);if(!i||0===i.length)return!0;_d(e,"target",this);var a=!1,r=null===(t=e.stopImmediatePropagation)||void 0===t?void 0:t.bind(e),o=null===(n=e.stopPropagation)||void 0===n?void 0:n.bind(e),s=()=>{a=!0,null==r||r()},u=()=>{e.cancelBubble=!0,null==o||o()};e.stopImmediatePropagation=s,e.stopPropagation=u;for(var l,d=h(i.slice());!(l=d()).done;){var c=l.value;if(a)break;_d(e,"currentTarget",this),"function"==typeof c.listener?c.listener.call(this,e):Td(c.listener)&&c.listener.handleEvent.call(c.listener,e),c.once&&this.removeEventListener(e.type,c.listener)}if(r)e.stopImmediatePropagation=r;else try{delete e.stopImmediatePropagation}catch(t){e.stopImmediatePropagation=s}if(o)e.stopPropagation=o;else try{delete e.stopPropagation}catch(t){e.stopPropagation=u}return _d(e,"currentTarget",null),!e.defaultPrevented}}])}(),Ad=[];var Dd={paywallId:"",livePaywalls:[],selectedPaywall:void 0,selectedCampaign:void 0,campaignRules:[],anySkuHasTrialOffer:!1,anySkuHasIntroOffer:!1,anySkuHasPromoOffer:!1,isLoggedIn:!1,darkMode:!1,safeAreaTop:0,groups:[],selectedProducts:{},formStates:{},formFieldErrors:{},formFieldValidators:{},timerStates:{},currentPage:"page1",pageHistory:["page1"],currentGroupId:"",currentGroupName:"",fullScreenPresentation:!1,launch:{productGroups:[],customAttributes:{},customObject:{},currentGroup:""},sku:{},orientation:"portrait",focusedState:!1,platformId:"",mediaList:{},skuItems:[],customer:{},hasNotch:!1,purchaseInProgress:!1,formFactor:"desktop",slides:{},userInteractionEnabled:!0,currentSlideIndex:void 0},xd=function(t){function n(e,t,i){var a;o(this,n),(a=r(this,n)).subscribers=new Set,a.productDetails=Ad,a.filteredSkuMenus=[],a.state=Pd(Dd,5);var s=Fr.getNamiProfile();return a.state.isLoggedIn=!(null==s||!s.externalId),a.state.customer=m({},a.state.customer,Fr.getAllCustomerAttributesMap()),a.setPaywall(e,t,i),a.subscribers=new Set,a}return p(n,t),c(n,[{key:"onStateChanged",value:function(){}},{key:"subscribe",value:function(e){return this.subscribers.add(e),()=>this.unsubscribe(e)}},{key:"unsubscribe",value:function(e){this.subscribers.delete(e)}},{key:"emitEvent",value:function(e,t){this.dispatchEvent(function(e,t){if("function"==typeof Event){var n=new Event(e);return Object.defineProperty(n,"detail",{configurable:!0,enumerable:!1,value:t,writable:!1}),n}return{type:e,detail:t,bubbles:!1,cancelBubble:!1,cancelable:!1,composed:!1,currentTarget:null,defaultPrevented:!1,eventPhase:0,isTrusted:!1,returnValue:!0,srcElement:null,target:null,timeStamp:Date.now(),NONE:0,CAPTURING_PHASE:1,AT_TARGET:2,BUBBLING_PHASE:3,composedPath:()=>[],initEvent:()=>{},preventDefault:()=>{},stopImmediatePropagation:()=>{},stopPropagation:()=>{}}}(e,t))}},{key:"onEvent",value:function(e,t){var n=e=>t(e.detail);return this.addEventListener(e,n),()=>this.removeEventListener(e,n)}},{key:"setState",value:function(e){this.state=e,this.subscribers.forEach(e=>e()),this.onStateChanged()}},{key:"setProductDetails",value:function(e){this.productDetails=e}},{key:"getProductDetails",value:function(){return this.productDetails}},{key:"setCurrentGroupData",value:function(e,t){var n=Yl(this.productDetails,this.state,this.filteredSkuMenus,ql(this.productDetails,this.filteredSkuMenus,this.state.currentGroupId));this.setState(m({},this.state,{currentGroupId:e,currentGroupName:t,sku:n}))}},{key:"setFormState",value:function(e,t){this.setState(m({},this.state,{formStates:m({},this.state.formStates,{[e]:t})}))}},{key:"registerFormFieldValidator",value:function(e,t){this.setState(m({},this.state,{formFieldValidators:m({},this.state.formFieldValidators,{[e]:t})}))}},{key:"getFormFieldValidators",value:function(){return this.state.formFieldValidators}},{key:"setFormFieldErrors",value:function(e){this.setState(m({},this.state,{formFieldErrors:m({},e)}))}},{key:"setFormFieldError",value:function(e,t){this.setState(m({},this.state,{formFieldErrors:m({},this.state.formFieldErrors,{[e]:t})}))}},{key:"clearFormFieldError",value:function(e){var t=m({},this.state.formFieldErrors);delete t[e],this.setState(m({},this.state,{formFieldErrors:t}))}},{key:"getFormFieldErrors",value:function(){return this.state.formFieldErrors}},{key:"setTimerState",value:function(e,t,n,i){this.setState(m({},this.state,{timerStates:m({},this.state.timerStates,{[e]:{remainingSeconds:t,savedAt:n,hasEmittedCompletion:i}})}))}},{key:"getTimerState",value:function(e){return this.state.timerStates[e]}},{key:"getCurrentGroupId",value:function(){return this.state.currentGroupId}},{key:"getCurrentGroupName",value:function(){return this.state.currentGroupName}},{key:"setCurrentFormId",value:function(e,t){var n=this.state.formStates||{},i=m({},n,{[e]:t||!n[e]});this.setState(m({},this.state,{formStates:i}))}},{key:"getCurrentFormId",value:function(e){return this.state.formStates[e]}},{key:"setSelectedProducts",value:function(e){var t=Yl(this.productDetails,this.state,this.filteredSkuMenus,ql(this.productDetails,this.filteredSkuMenus,this.state.currentGroupId));this.setState(m({},this.state,{selectedProducts:e,sku:t}))}},{key:"selectedProducts",value:function(){return this.state.selectedProducts}},{key:"setPaywall",value:function(e,t,n){var i,a,r,o,s,u=m({},this.state,{formFactor:ou(),selectedPaywall:e,selectedCampaign:n}),l=function(e,t,n=[]){var i,a,r=null!==(i=t.productGroups)&&void 0!==i&&i.length?t.productGroups:n.map(e=>e.ref);return{customAttributes:t.customAttributes,productGroups:r,customObject:m({},e.customObject,t.customObject),currentGroup:null!==(a=t.currentGroup)&&void 0!==a?a:""}}((u=m({},u,null===(i=e.template)||void 0===i?void 0:i.initialState)).launch,t,e.sku_menus);(this.filteredSkuMenus=null!==(a=e.sku_menus)&&void 0!==a?a:[],l.productGroups.length&&(this.filteredSkuMenus=this.filteredSkuMenus.filter(e=>l.productGroups.includes(e.ref))),""!==l.currentGroup&&u.groups.length&&null!==(r=e.template)&&void 0!==r&&r.displaySingleGroup)&&(u.currentGroupId=null!==(o=null===(s=u.groups.find(e=>e.ref==l.currentGroup))||void 0===s?void 0:s.id)&&void 0!==o?o:"");if(""===u.currentGroupId&&1===this.filteredSkuMenus.length){var d,c=u.groups.find(e=>e.ref==this.filteredSkuMenus[0].ref);u.currentGroupId=null!==(d=null==c?void 0:c.id)&&void 0!==d?d:u.currentGroupId}var h=ql(this.productDetails,this.filteredSkuMenus,u.currentGroupId);u.skuItems=h,u.launch=l,u.anySkuHasTrialOffer=Zl(this.productDetails,this.filteredSkuMenus),u.anySkuHasPromoOffer=function(e,t){return!Zl(e,t)&&t.flatMap(e=>e.products).some(t=>1==Al("promoEligible",ed(e,t.sku_ref_id)))}(this.productDetails,this.filteredSkuMenus),u.paywallId=e.id,u.sku=Yl(this.productDetails,u,this.filteredSkuMenus,h),u.pageHistory=[u.currentPage],this.setState(u)}},{key:"getSelectedPaywall",value:function(){return this.state.selectedPaywall}},{key:"getSelectedCampaign",value:function(){return this.state.selectedCampaign}},{key:"getCurrentPlacementLabel",value:function(){var e,t;return null!==(e=this.state.selectedCampaign)&&void 0!==e&&e.value?this.state.selectedCampaign.value:null!==(t=this.flow)&&void 0!==t&&null!==(t=t.campaign)&&void 0!==t&&t.value?this.flow.campaign.value:void 0}},{key:"getPaywallActionEventData",value:function(){var t,n,i,a,r,o,s,u,l,d=this.state.selectedCampaign,c=this.state.selectedPaywall;return{paywallId:null!==(t=null==c?void 0:c.id)&&void 0!==t?t:"",paywallName:null!==(n=null==c?void 0:c.name)&&void 0!==n?n:"",campaignId:null!==(i=null==d?void 0:d.rule)&&void 0!==i?i:"",campaignName:null!==(a=null==d?void 0:d.name)&&void 0!==a?a:"",campaignType:null!==(r=null==d?void 0:d.type)&&void 0!==r?r:"",campaignLabel:null!==(o=null==d?void 0:d.value)&&void 0!==o?o:"",campaignUrl:(null==d?void 0:d.type)===e.NamiCampaignRuleType.URL&&null!==(s=null==d?void 0:d.value)&&void 0!==s?s:"",segmentId:null!==(u=null==d?void 0:d.segment)&&void 0!==u?u:"",externalSegmentId:null!==(l=null==d?void 0:d.external_segment)&&void 0!==l?l:""}}},{key:"paywallId",value:function(){return this.state.paywallId}},{key:"setCurrentPage",value:function(e){if(e&&e!==this.state.currentPage){var t=this.state.pageHistory&&this.state.pageHistory.length?this.state.pageHistory:[this.state.currentPage];this.setState(m({},this.state,{currentPage:e,pageHistory:[...t,e]}))}}},{key:"canGoBackPage",value:function(){var e,t;return(null!==(e=null===(t=this.state.pageHistory)||void 0===t?void 0:t.length)&&void 0!==e?e:0)>1}},{key:"goBackPage",value:function(){var e=this.state.pageHistory&&this.state.pageHistory.length?[...this.state.pageHistory]:[this.state.currentPage];if(e.length<=1)return!1;e.pop();var t=e[e.length-1];return!!t&&(this.setState(m({},this.state,{currentPage:t,pageHistory:e})),!0)}},{key:"setCustomerAttribute",value:function(e){this.setState(m({},this.state,{customer:m({},this.state.customer,e)}))}},{key:"removeCustomerAttribute",value:function(e){var t=m({},this.state.customer);delete t[e],this.setState(m({},this.state,{customer:t}))}},{key:"setIsLoggedIn",value:function(e){this.setState(m({},this.state,{isLoggedIn:e}))}},{key:"setMediaList",value:function(e){this.setState(m({},this.state,{mediaList:e.reduce((e,t)=>m({},e,{[t.name]:t}))}))}},{key:"setSafeAreaTop",value:function(e){this.setState(m({},this.state,{safeAreaTop:e}))}},{key:"setFullScreenPresentation",value:function(e){this.setState(m({},this.state,{fullScreenPresentation:e}))}},{key:"setFormFactor",value:function(e){this.setState(m({},this.state,{formFactor:e}))}},{key:"getFormFactor",value:function(){return this.state.formFactor}},{key:"setPurchaseInProgress",value:function(e){this.setState(m({},this.state,{purchaseInProgress:e}))}},{key:"setPurchase",value:function(e,t){this.setState(m({},this.state,{purchaseInProgress:e,productBeingPurchased:t}))}},{key:"setTimeSpentOnPaywall",value:function(e){this.setState(m({},this.state,{timeSpentOnPaywall:e}))}},{key:"setAppSuppliedVideoDetails",value:function({url:e,name:t}){this.setState(m({},this.state,{appSuppliedVideoUrl:e,appSuppliedVideoName:t}))}},{key:"resetAppSuppliedVideoDetails",value:function(){var e=m({},this.state);delete e.appSuppliedVideoUrl,delete e.appSuppliedVideoName,this.setState(e)}},{key:"setLaunchDetails",value:function(e,t){this.setState(m({},this.state,{launchValue:e,launchType:t}))}},{key:"setOpenHeaderIds",value:function(e,t){e=null!=t&&t.skuId?`${e}_${t.skuId}`:e;var n=[...this.state.openHeaderIds],i=n.indexOf(e);-1!==i?n.splice(i,1):n.push(e),this.setState(m({},this.state,{openHeaderIds:n,currentCollapsibleSku:null!=t?t:null}))}},{key:"getCurrentCollapsibleSku",value:function(){return this.state.currentCollapsibleSku}},{key:"setFlow",value:function(e){this.flow=e}},{key:"setUserInteractionEnabled",value:function(e){this.setState(m({},this.state,{userInteractionEnabled:e})),this.emitEvent("user-interaction-changed",{enabled:e})}},{key:"setUserTags",value:function(e){this.setState(m({},this.state,{customer:m({},this.state.customer,e)}))}},{key:"setCurrentSlideIndex",value:function(e){this.setState(m({},this.state,{currentSlideIndex:e}))}}],[{key:"create",value:function(e,t,i){var a=new n(e,t,i);return this.providers.push(a),a}},{key:"remove",value:function(e){this.providers=this.providers.filter(t=>t!==e)}},{key:"reset",value:function(){this.providers=[]}},{key:"currentProvider",get:function(){return n.providers[0]}},{key:"setCustomerAttribute",value:function(e){this.providers.forEach(t=>{t.setCustomerAttribute(e)})}},{key:"removeCustomerAttribute",value:function(e){this.providers.forEach(t=>{t.removeCustomerAttribute(e)})}},{key:"setAppSuppliedVideoDetails",value:function(e){this.providers.forEach(t=>{t.setAppSuppliedVideoDetails(e)})}},{key:"getSelectedPaywall",value:function(){var e;return null===(e=this.providers[0])||void 0===e?void 0:e.getSelectedPaywall()}},{key:"setUserInteractionEnabled",value:function(e){this.providers.forEach(t=>{t.setUserInteractionEnabled(e)})}},{key:"setUserTags",value:function(e){this.providers.forEach(t=>{t.setUserTags(e)})}},{key:"setProductDetails",value:function(e){this.providers.forEach(t=>{t.setProductDetails(e)}),Ad=e}},{key:"setPurchaseInProgress",value:function(e){this.providers.forEach(t=>{t.setPurchaseInProgress(e)})}},{key:"setIsLoggedIn",value:function(e){this.providers.forEach(t=>{t.setIsLoggedIn(e)})}},{key:"setPurchase",value:function(e,t){this.providers.forEach(n=>{n.setPurchase(e,t)})}},{key:"getSelectedSlideIndex",value:function(){var e;return null===(e=this.providers[0])||void 0===e?void 0:e.state.currentSlideIndex}}])}(Md);xd.providers=[];var Cd=c(function e(){o(this,e),this.refIdToPurchasedSKUs={},this.refIdToRelatedSKUs={},this.refIdToActivePurchases={}});Cd.instance=new Cd;var Id=()=>Lr(li([...Fr.getNamiEntitlements(pt),...Fr.getNamiEntitlements(_t)]),"referenceId"),Ld=()=>{Nu.getInstance().emit(Xn,Id())};function Rd(e){return{id:e.id,skuId:e.sku_ref_id,name:e.name,type:e.sku_type||"unknown",entitlements:e.entitlements,productDetails:"product_details"in e?e.product_details:null}}var Fd=function(){return c(function e(){o(this,e)},[{key:"fetchActiveEntitlements",value:function(){var e,t,n;return k(function(i){for(;;)switch(i.n){case 0:if(e=null,ol()||Ds(Pe.THIRD_PARTY_TRANSACTIONS)||!Ds(Pe.ENTITLEMENT_MANAGEMENT)){i.n=3;break}if(null==(t=Fr.getDevice())||!t.id){i.n=2;break}return i.n=1,a(this.getAPIEntitlements(t.id));case 1:n=i.v,(e=null==n?void 0:n.results)&&(Fr.setActiveEntitlements(ft,e),this.invokeActiveEntitlementsHandler(e));case 2:i.n=4;break;case 3:ol()&&ui.debug("Skipping active entitlements update - anonymous mode");case 4:return i.a(2,e)}},null,this,null,Promise)}},{key:"getAPIEntitlements",value:function(e){var t,n,i;return k(function(r){for(;;)switch(r.p=r.n){case 0:return t=`device/${e}/active_entitlements/`,n={},r.p=1,r.n=2,a(js.instance.fetchAPI(t));case 2:n=r.v,r.n=4;break;case 3:throw r.p=3,i=r.v,ui.error(Zr(i.status,t)),i;case 4:return r.a(2,n)}},null,null,[[1,3]],Promise)}},{key:"invokeActiveEntitlementsHandler",value:function(e){Cs()&&(e=>{Fr.setNamiEntitlements(pt,e);var t=Fr.getNamiEntitlements(_t),n=new Set(e.map(e=>e.referenceId)),i=t.filter(e=>{var t=n.has(e.referenceId);return t&&ui.debug(`Server granted verified entitlement for ${e.referenceId}, so replacing provisional entitlement grant.`),!t});i.length!==t.length&&Fr.setNamiEntitlements(_t,i),Ld()})(e.map(e=>(e=>{var t=e.entitlement_ref_id;return{name:e.name||"",desc:e.description||"",namiId:"",referenceId:t,relatedSkus:Cd.instance.refIdToRelatedSKUs[t]||[],activePurchases:Cd.instance.refIdToActivePurchases[t]||[],purchasedSkus:Cd.instance.refIdToPurchasedSKUs[t]||[],expires:e.expires?new Date(e.expires).valueOf():0}})(e)))}}])}();Fd.instance=new Fd;var Od=function(){return c(function e(){o(this,e)},[{key:"fetchCustomerJourneyState",value:function(){var e,t,n,i;return k(function(r){for(;;)switch(r.p=r.n){case 0:if(!ol()){r.n=1;break}return ui.debug("Skipping customer journey state update - anonymous mode"),r.a(2,null);case 1:if(null!=(e=Fr.getDevice())&&e.id){r.n=2;break}return r.a(2,null);case 2:return t=`device/${e.id}/profile/`,n=null,r.p=3,r.n=4,a(js.instance.fetchAPI(t,void 0,0));case 4:n=r.v,r.n=6;break;case 5:throw r.p=5,i=r.v,ui.error(Zr(i.status,t)),i;case 6:if(!n){r.n=7;break}return Fr.setCustomerJourneyState(n.customer_journey_state),r.a(2,n.customer_journey_state);case 7:return r.a(2,null)}},null,null,[[3,5]],Promise)}}])}();Od.instance=new Od;var $d="[NamiStartup]",Nd=function(){return c(function e(){o(this,e),this.enabled=!1,this.t0=0,this.lastMark=0,this.decodeDuration=0,this.processDuration=0,this.placements=0,this.firstLaunchLogged=!1},[{key:"start",value:function(e){var t;this.enabled=null!==(t=null==e?void 0:e.includes(wn))&&void 0!==t&&t,this.enabled&&(this.t0=Date.now(),this.lastMark=this.t0,this.decodeDuration=0,this.processDuration=0,this.placements=0,this.firstLaunchLogged=!1)}},{key:"mark",value:function(e,t){if(this.enabled){var n=Date.now(),i=n-this.lastMark;this.lastMark=n,"initial_config_decoded"===e?this.decodeDuration=i:"initial_processed"===e&&(this.processDuration=i,void 0!==(null==t?void 0:t.count)&&(this.placements=t.count));var a=t?" "+Object.entries(t).map(([e,t])=>`${e}=${t}`).join(" "):"";if("ready"===e){var r=n-this.t0;ui.info(`${$d} phase=${e} ms=${i} total_to_ready=${r}${a}`),ui.info(`${$d} SUMMARY total_to_ready=${r} decode=${this.decodeDuration} process=${this.processDuration} placements=${this.placements}`)}else ui.info(`${$d} phase=${e} ms=${i}${a}`)}}},{key:"firstLaunchLookup",value:function(e,t){if(!this.enabled||this.firstLaunchLogged)return t();this.firstLaunchLogged=!0;var n=Date.now(),i=t(),a=Date.now()-n;return ui.info(`${$d} phase=first_launch_lookup ms=${a} label=${e}`),i}},{key:"serverFetch",value:function(e){var t,n,i;return k(function(r){for(;;)switch(r.n){case 0:if(this.enabled){r.n=1;break}return r.a(2,e());case 1:return t=Date.now(),r.n=2,a(e());case 2:return n=r.v,i=Date.now()-t,ui.info(`${$d} phase=server_fetch ms=${i} campaigns=${n.length}`),r.a(2,n)}},null,this,null,Promise)}}])}(),Wd=new Nd,jd=function(){return c(function e(){o(this,e),this.inMemoryAnonymousMode=!1,this.isFirstSession=!1,al=this},[{key:"setInMemoryAnonymousMode",value:function(e){this.inMemoryAnonymousMode=e,ui.info(`In-memory anonymous mode ${e?"enabled":"disabled"} due to failed device registration`)}},{key:"isInMemoryAnonymousMode",value:function(){return this.inMemoryAnonymousMode}},{key:"isAnonymousMode",value:function(){return Fr.getAnonymousMode()||this.inMemoryAnonymousMode}},{key:"getIsFirstSession",value:function(){return this.isFirstSession}},{key:"init",value:function(e){return k(function(t){for(;;)switch(t.n){case 0:return this.isFirstSession=null===Fr.getDevice()&&!Fr.getAnonymousMode(),this.setInitialValues(e),il.instance.fetchConfig(),t.n=1,a(this.initAndFetchRequiredData(e));case 1:sl.instance.startSession();case 2:return t.a(2)}},null,this,null,Promise)}},{key:"setInitialValues",value:function(e){var t=m({},e);delete t.initialConfig,Fr.clearSessionId(),Fr.setNamiConfig(t),Fr.setLanguageCode(e.namiLanguageCode),Fr.setPurchaseChannel(e.purchaseChannel);var n=e.initialConfig;if(n.appConfig||n.platform_config){var i=(null==n?void 0:n.appConfig)||(null==n?void 0:n.platform_config);i&&Fr.setAppConfig(yt,i)}null!=n&&n.paywalls&&Fr.setPaywalls(St,n.paywalls),null!=n&&n.products&&Fr.setProducts(Pt,n.products)}},{key:"initAnonymousDevice",value:function(){return{deviceId:Bu.instance.getOrCreateAnonymousUUID(),deviceTask:null}}},{key:"initIdentifiedDevice",value:function(e){var t=m({},ru(e.namiCommands),e.formFactor?{form_factor:e.formFactor}:{}),n=function(e){if(e){var t=e.find(e=>e.startsWith("splitPosition="));if(t){var n=t.split("=")[1],i=Number(n);return n&&!isNaN(i)?du(i):void 0}}}(e.namiCommands),i=Bu.instance.createOrUpdateDevice(t,n,this);return{deviceId:i.id,deviceTask:i.device}}},{key:"initAndFetchRequiredData",value:function(e,t=0,n=1){var i,r,o,s,u,l,d,c,h,m,f,v;return k(function(p){for(;;)switch(p.n){case 0:if(s=e.initialConfig,u=null!==(i=e.formFactor)&&void 0!==i?i:ou(),l=this.isAnonymousMode(),d=l?this.initAnonymousDevice():this.initIdentifiedDevice(e),c=d.deviceId,h=d.deviceTask,m=uu(c),s.campaign_rules&&(f=yu(s.campaign_rules,m,u),Fr.setCampaignRules(wt,f),Wd.mark("initial_processed",{count:f.length})),!h){p.n=1;break}return p.n=1,a(h);case 1:if(Wu.instance.configure(u,m,e.namiCommands),xs(),v=Promise.all([zu.instance.fetchProducts(),Od.instance.fetchCustomerJourneyState(),Fd.instance.fetchActiveEntitlements(),Wd.serverFetch(()=>this.fetchCampaignsAndPaywalls())]).catch(i=>{var r;return k(function(o){for(;;)switch(o.n){case 0:if(!(i instanceof Nr)){o.n=3;break}if(Fr.resetDevice(),!(t<n)){o.n=2;break}return r=100*Math.pow(2,t),o.n=1,a(new Promise(e=>setTimeout(e,r)));case 1:return o.a(2,this.initAndFetchRequiredData(e,t+1,n));case 2:if(l){o.n=3;break}return ui.warn(`Max retries reached for ConflictError. ${i.message}`),this.setInMemoryAnonymousMode(!0),o.a(2,this.initAndFetchRequiredData(e,0,n));case 3:throw i;case 4:return o.a(2)}},null,this,null,Promise)}),null!==(r=s.campaign_rules)&&void 0!==r&&r.length&&null!==(o=s.paywalls)&&void 0!==o&&o.length){p.n=2;break}return p.n=2,a(v);case 2:v.then(()=>this.reRenderPaywall());case 3:return p.a(2)}},null,this,null,Promise)}},{key:"fetchCampaignsAndPaywalls",value:function(){var e,t,n,i,r,o,s,u,l,d,c,h,m,f;return k(function(v){for(;;)switch(v.n){case 0:return e=Wu.instance,t=nl.instance,n=Date.now(),i=Date.now(),v.n=1,a(e.fetchCampaignRulesRaw());case 1:return r=v.v,o=Date.now()-i,v.n=2,a(Promise.all(r.filter(e=>{var t;return(null===(t=e.flow)||void 0===t?void 0:t.url)&&!e.flow.object}).map(e=>{var t,n;return k(function(i){for(;;)switch(i.p=i.n){case 0:return i.p=0,i.n=1,a(tl(e.flow.url));case 1:t=i.v,e.flow.object=t.data,i.n=3;break;case 2:i.p=2,n=i.v,ui.warn(`Error fetching flow object from ${e.flow.url}: ${n}`);case 3:return i.a(2)}},null,null,[[0,2]],Promise)})));case 2:if(s=!e.useLegacyPaywallFetch&&Wu.hasPaywallUrls(r),l=0,d=Date.now(),!s){v.n=4;break}return c=Wu.extractPaywallUrls(r),v.n=3,a(t.fetchPaywallsByUrls(c));case 3:h=v.v,u=h.paywalls,l=h.retryCount,v.n=6;break;case 4:return v.n=5,a(t.fetchPaywalls());case 5:u=v.v;case 6:return m=Date.now()-d,f=Date.now()-n,Vd.instance.maxLogging&&ui.info(`Paywall fetch telemetry: strategy=${s?"individual":"bulk"}, count=${u.length}, total=${f}ms, campaigns=${o}ms, paywalls=${m}ms`+(s?`, retry_count=${l}`:"")),v.a(2,e.finalizeCampaignRules(r,u))}},null,null,null,Promise)}},{key:"reRenderPaywall",value:function(){we().ui.reRenderPaywall()}}])}();function Bd(e){return Array.isArray(e)?e.map(Bd):e&&"object"==typeof e?Object.entries(e).reduce((e,[t,n])=>(void 0!==n&&(e[t]=Bd(n)),e),{}):e}function zd(e,t){return ju(Bd(e),Bd(t))}jd.instance=new jd;var Ud=function(){return c(function e(){o(this,e),this.load()},[{key:"setExternalId",value:function(e){return this.externalId=e,this}},{key:"getExternalId",value:function(){return this.externalId}},{key:"isLoggedIn",value:function(){return!!this.externalId}},{key:"save",value:function(){return this.externalId?Fr.setNamiProfile({externalId:this.externalId}):Fr.removeNamiProfile(),this}},{key:"load",value:function(){var e=Fr.getNamiProfile();e&&(this.externalId=e.externalId),xd.setIsLoggedIn(!!this.externalId)}},{key:"loginLocal",value:function(e){this.setExternalId(e).save(),xd.setIsLoggedIn(!0)}},{key:"loginRemote",value:function(e){var t;return k(function(n){for(;;)switch(n.n){case 0:return n.n=1,a(js.instance.login(e));case 1:(t=n.v).external_id&&t.external_id!==this.externalId&&this.setExternalId(t.external_id).save();case 2:return n.a(2)}},null,this,null,Promise)}},{key:"logoutLocal",value:function(){this.setExternalId(void 0).save(),xd.setIsLoggedIn(!1)}},{key:"logoutRemote",value:function(){return k(function(e){for(;;)switch(e.n){case 0:return e.n=1,a(js.instance.logout());case 1:return e.a(2)}},null,null,null,Promise)}},{key:"login",value:function(e){return k(function(t){for(;;)switch(t.n){case 0:return this.loginLocal(e),t.n=1,a(this.loginRemote(e));case 1:return t.a(2)}},null,this,null,Promise)}},{key:"logout",value:function(){return k(function(e){for(;;)switch(e.n){case 0:return this.logoutLocal(),e.n=1,a(this.logoutRemote());case 1:return e.a(2)}},null,this,null,Promise)}}])}();Ud.instance=new Ud;var Hd,Gd=function(){function e(){o(this,e)}return c(e,[{key:"previous",get:function(){return this._previous}},{key:"record",value:function(e){this._previous=this._current,this._current=e}},{key:"reset",value:function(){this._current=void 0,this._previous=void 0}}],[{key:"shared",get:function(){return this._shared||(this._shared=new e),this._shared}}])}(),Vd=function(){function e(){o(this,e),Hd.set(this,!1),this.maxLogging=!1}return c(e,[{key:"isInitialized",get:function(){return Se(this,Hd,"f")||null!=Fr.getNamiConfig()}},{key:"initializeSDK",value:function(t){var n,i,r,o,s,u,l,d,c,h;return k(function(f){for(;;)switch(f.n){case 0:if(o=!1,s=!1,u=Se(this,Hd,"f")?Fr.getNamiConfig():null,ui.setLogger(t.logLevel),e.instance.maxLogging=null!==(n=t.maxLogging)&&void 0!==n&&n,null===u){f.n=3;break}if(delete(l=m({},t)).initialConfig,!zd(l,u)){f.n=1;break}return ui.warn("Nami SDK is already configured, ignoring this configure call."),f.a(2,{sdkInitialized:!0,configureState:zn});case 1:s=!0;case 2:d=As(t.namiCommands),c=As(u.namiCommands),t.appPlatformID==u.appPlatformID&&d==c||(o=!0),t.namiLanguageCode===u.namiLanguageCode&&t.logLevel==u.logLevel||(s=!0);case 3:return o&&(ui.info("SDK full reconfigure called"),Fr.resetDevice()),Ee(this,Hd,!0),js.configure(t),f.n=4,a(jd.instance.init(t));case 4:return ui.info("SDK successfully initialized!"),h=s||o?jn:Nn,null===(i=(r=we().ui).postConfigure)||void 0===i||i.call(r),Wd.mark("ready"),f.a(2,{sdkInitialized:!0,configureState:h})}},null,this,null,Promise)}}],[{key:"sdkVersion",value:function(){return Ae}},{key:"sdkPackageVersion",value:function(){return xe}},{key:"reset",value:function(){var t,n,i;return k(function(r){for(;;)switch(r.n){case 0:return Fr.clearAll(),rl(),Ee(e.instance,Hd,!1),Ud.instance.setExternalId(void 0),xd.reset(),js.reset(),Wu.instance.reset(),Gd.shared.reset(),r.n=1,a(Promise.resolve().then(function(){return eh}));case 1:i=r.v,i.NamiFlowManager.reset(),null===(t=(n=we().ui).onReset)||void 0===t||t.call(n);case 2:return r.a(2)}},null,null,null,Promise)}},{key:"configure",value:function(t){return k(function(n){for(;;)switch(n.n){case 0:if(Wd.start(t.namiCommands),t.appPlatformID){n.n=1;break}throw new jr;case 1:return this.setInitialConfig(t),Wd.mark("initial_config_decoded"),n.n=2,a(e.instance.initializeSDK(t));case 2:return n.a(2,n.v)}},null,this,null,Promise)}},{key:"setInitialConfig",value:function(e){if(null!=e.initialConfig){if("string"==typeof e.initialConfig){ui.debug("[DEPRECATED] NamiConfiguration.initialConfig should be an object");var t=function(e){var t=e.trim();if(t.startsWith("{")||t.startsWith("["))try{return JSON.parse(t)}catch(e){return}}(e.initialConfig);if(!t)return ui.error("Failed to parse NamiConfiguration.initialConfig"),void(e.initialConfig={});e.initialConfig=t}if("object"!=typeof e.initialConfig)e.initialConfig={};else if((e=>"object"==typeof e&&"initial_config"in e)(e.initialConfig)){var n=Rs(e.initialConfig.initial_config);n?e.initialConfig=n:(e.initialConfig={},ui.error("Failed to parse NamiConfiguration.initialConfig as base64-gzipped JSON"))}}else e.initialConfig={}}}])}();Hd=new WeakMap,Vd.instance=new Vd;var Kd,Xd,Yd,qd=new Set(["fullscreen","sheet","compact_sheet","modal"]);e.NamiPaywallManagerEvents=void 0,(Kd=e.NamiPaywallManagerEvents||(e.NamiPaywallManagerEvents={})).BuySku="RegisterBuySKU",Kd.Close="PaywallCloseRequested",Kd.SignIn="PaywallSignInRequested",Kd.Restore="PaywallRestoreRequested",Kd.DeeplinkAction="PaywallDeeplinkAction",e.NamiPaywallAction=void 0,(Xd=e.NamiPaywallAction||(e.NamiPaywallAction={})).BUY_SKU="BUY_SKU",Xd.SELECT_SKU="SELECT_SKU",Xd.RESTORE_PURCHASES="RESTORE_PURCHASES",Xd.SIGN_IN="SIGN_IN",Xd.CLOSE_PAYWALL="CLOSE_PAYWALL",Xd.SHOW_PAYWALL="SHOW_PAYWALL",Xd.PURCHASE_SELECTED_SKU="PURCHASE_SELECTED_SKU",Xd.PURCHASE_SUCCESS="PURCHASE_SUCCESS",Xd.PURCHASE_FAILED="PURCHASE_FAILED",Xd.PURCHASE_CANCELLED="PURCHASE_CANCELLED",Xd.PURCHASE_PENDING="PURCHASE_PENDING",Xd.PURCHASE_UNKNOWN="PURCHASE_UNKNOWN",Xd.PURCHASE_DEFERRED="PURCHASE_DEFERRED",Xd.DEEPLINK="DEEPLINK",Xd.TOGGLE_CHANGE="TOGGLE_CHANGE",Xd.PAGE_CHANGE="PAGE_CHANGE",Xd.SLIDE_CHANGE="SLIDE_CHANGE",Xd.COLLAPSIBLE_DRAWER_OPEN="COLLAPSIBLE_DRAWER_OPEN",Xd.COLLAPSIBLE_DRAWER_CLOSE="COLLAPSIBLE_DRAWER_CLOSE",Xd.VIDEO_STARTED="VIDEO_STARTED",Xd.VIDEO_PAUSED="VIDEO_PAUSED",Xd.VIDEO_RESUMED="VIDEO_RESUMED",Xd.VIDEO_ENDED="VIDEO_ENDED",Xd.VIDEO_CHANGED="VIDEO_CHANGED",Xd.VIDEO_MUTED="VIDEO_MUTED",Xd.VIDEO_UNMUTED="VIDEO_UNMUTED",Xd.COUNTDOWN_TIMER_COMPLETED="COUNTDOWN_TIMER_COMPLETED",Xd.UNKNOWN="UNKNOWN",e.LaunchCampaignError=void 0,(Yd=e.LaunchCampaignError||(e.LaunchCampaignError={})).DEFAULT_CAMPAIGN_NOT_FOUND="Default campaign not found",Yd.LABELED_CAMPAIGN_NOT_FOUND="Labeled campaign not found",Yd.CAMPAIGN_DATA_NOT_FOUND="Campaign data not found",Yd.PAYWALL_ALREADY_DISPLAYED="Paywall is already being displayed",Yd.SDK_NOT_INITIALIZED="SDK has not been initialized",Yd.PAYWALL_COULD_NOT_DISPLAY="Failed to display paywall",Yd.URL_CAMPAIGN_NOT_FOUND="URL campaign not found",Yd.PRODUCT_DATA_NOT_FOUND="Product data not found",Yd.PRODUCT_GROUPS_NOT_FOUND="Product groups not found",Yd.FLOW_SCREEN_DATA_UNAVILABLE="Flow unavailable due to missing screen data";var Jd,Qd="entry",Zd="screen",ec="branch",tc="exit",nc="unknown";!function(e){e.NAVIGATE="flowNav",e.BACK="flowPrev",e.NEXT="flowNext",e.FINISHED="flowDone",e.DISMISS="flowDismiss",e.EXIT="flowExit",e.HANDOFF="flowHandoff",e.TRACK="trackEvent",e.LOG="logEvent",e.SET_VIDEO="setVideo",e.FLOW_EVENT="flowEvent",e.BLOCK_BACK="blockBackToStep",e.FLOW_ENABLED="flowInteractionEnabled",e.FLOW_DISABLED="flowInteractionDisabled",e.SET_TAGS="setTags",e.SET_TAGS_FROM_FORM="setTagsFromForm",e.PAUSE="flowPause",e.RESUME="flowResume",e.SET_LAUNCH_CONTEXT="setLaunchContext",e.SET_FLOW_PATH="setFlowPath"}(Jd||(Jd={}));var ic="__handoff_sequence__",ac={Push:"push",Location:"location",Tracking:"att",Deeplink:"deeplink",Complete:"complete",SignIn:"signin",Restore:"restore",SignInMvpd:"signin_mvpd",BuySku:"buysku",UserData:"userdata"};var rc={Push:"push",Location:"location",Tracking:"tracking",Camera:"camera",Microphone:"microphone",Photos:"photos",Contacts:"contacts",Bluetooth:"bluetooth",Calendar:"calendar",Biometrics:"biometrics",Health:"health",Motion:"motion",Speech:"speech",LocalNetwork:"localNetwork"},oc={[rc.Push]:"push_authorized",[rc.Location]:"location_authorized",[rc.Tracking]:"tracking_authorized"},sc="__buy_sku__",uc="__default__",lc="__appear__",dc="__disappear__",cc="__login_success__",hc="__login_failure__",mc="__logout_success__",fc="__logout_failure__",vc="__purchase_success__",pc="__purchase_failure__",gc="__remoteback__",yc="__tag_update__",bc="__permission_granted__",wc="and",kc="or",Sc="i_contains",Ec="equals",Pc="i_equals",Tc="not_equals",_c="not_i_equals",Mc="not_contains",Ac="contains",Dc="set",xc="not_set",Cc="greater_than",Ic="greater_than_or_equal_to",Lc="less_than",Rc="less_than_or_equal_to";function Fc(e){if("boolean"==typeof e)return null;if("number"==typeof e)return Number.isFinite(e)?e:null;if("string"==typeof e){var t=e.trim();if(""===t)return null;var n=Number(t);return Number.isFinite(n)?n:null}return null}var Oc=function(){function e(){o(this,e),this.resolvers=new Map,this.namespaceResolvers=new Map}return c(e,[{key:"registerNamespaceResolver",value:function(e,t){this.namespaceResolvers.set(e,t)}},{key:"resetResolvers",value:function(){this.resolvers.clear()}},{key:"evaluate",value:function(e){var t,n=null!==(t=e.filter)&&void 0!==t?t:[];if(0===n.length)return!0;var i=n.map(e=>this.evaluateFilter(e));switch(e.operator){case wc:return i.every(e=>e);case kc:return i.some(e=>e);default:return i.every(e=>e)}}},{key:"evaluateOrdered",value:function(e){var t;if(!e)return!0;var n=null!==(t=e.filter)&&void 0!==t?t:[];if(0===n.length)return!0;switch(e.operator){case wc:for(var i,a=h(n);!(i=a()).done;){var r=i.value;if(!this.evaluateFilter(r))return!1}return!0;case kc:for(var o,s=h(n);!(o=s()).done;){var u=o.value;if(this.evaluateFilter(u))return!0}return!1;default:for(var l,d=h(n);!(l=d()).done;){var c=l.value;if(!this.evaluateFilter(c))return!1}return!0}}},{key:"evaluateFilter",value:function(e){var t=this.resolve(e.identifier);if(Vd.instance.maxLogging&&ui.debug(`[NamiConditionEvaluator] resolve(${e.identifier}) → ${JSON.stringify(t)} (type: ${typeof t})`),e.operator===Dc)return null!=t;if(e.operator===xc)return null==t;if(null==t)return Vd.instance.maxLogging&&ui.debug(`[NamiConditionEvaluator] ${e.identifier} resolved to null — registeredNamespaces: [${[...this.namespaceResolvers.keys()].join(", ")}]`),!![Tc,_c,Mc].includes(e.operator);switch(e.operator){case Sc:return Array.isArray(t)?e.values.some(e=>"string"==typeof e&&t.some(t=>0===t.localeCompare(e,void 0,{sensitivity:"accent"}))):(this.log("Resolved value is not an array of strings for i_contains."),!1);case Ec:return e.values.some(e=>this.strictEquals(t,e,!1));case Pc:return e.values.some(e=>this.strictEquals(t,e,!0));case Tc:return e.values.every(e=>!this.strictEquals(t,e,!1));case _c:return e.values.every(e=>!this.strictEquals(t,e,!0));case Ac:return!(!Array.isArray(t)&&"string"!=typeof t)&&e.values.some(e=>"string"==typeof e&&t.includes(e));case Mc:return Array.isArray(t)?e.values.every(e=>!("string"==typeof e&&t.includes(e))):e.values.every(e=>"string"!=typeof t||"string"!=typeof e||!t.includes(e));case Cc:case Ic:case Lc:case Rc:var n=Fc(t);return null===n?(this.log(`Resolved value is not numerically comparable for ${e.operator}`),!1):e.values.some(t=>{var i=Fc(t);if(null===i)return!1;switch(e.operator){case Cc:return n>i;case Ic:return n>=i;case Lc:return n<i;default:return n<=i}});default:return this.log(`Unsupported operator: ${e.operator}`),!1}}},{key:"strictEquals",value:function(e,t,n){return"string"==typeof e&&"string"==typeof t?n?0===e.localeCompare(t,void 0,{sensitivity:"accent"}):e===t:("boolean"==typeof e&&"boolean"==typeof t||"number"==typeof e&&"number"==typeof t)&&e===t}},{key:"resolve",value:function(e){var t=this.resolveRaw(e);if(void 0!==t)return Vd.instance.maxLogging&&ui.debug(`[NamiConditionEvaluator] resolve(${e}) — exact hit: ${JSON.stringify(t)}`),t;var n=e.lastIndexOf(".");if(-1===n);else{var i=e.slice(0,n),a=e.slice(n+1),r=this.resolveRaw(i);if(void 0!==r){var o=this.extractProperty(a,r);return Vd.instance.maxLogging&&ui.debug(`[NamiConditionEvaluator] resolve(${e}) — fallback: base=${i} → ${typeof r}, extract(.${a}) → ${JSON.stringify(o)}`),o}this.log(`Could not resolve base identifier: ${i}`)}}},{key:"resolveRaw",value:function(e){for(var t,n=[...this.namespaceResolvers.keys()].sort((e,t)=>t.length-e.length),i=h(n);!(t=i()).done;){var a=t.value;if(e.startsWith(a)){var r=this.namespaceResolvers.get(a);if(r){var o=r(e);return Vd.instance.maxLogging&&ui.debug(`[NamiConditionEvaluator] resolveRaw(${e}) — ns=${a} → ${JSON.stringify(o)}`),o}}}}},{key:"extractProperty",value:function(e,t){switch(e){case"last":if(Array.isArray(t))return t[t.length-1];break;case"first":if(Array.isArray(t))return t[0];break;case"count":if(Array.isArray(t))return t.length;if(t&&"object"==typeof t)return Object.keys(t).length;break;default:return}this.log(`Could not extract .${e} from type ${typeof t}`)}},{key:"log",value:function(e){ui.debug(`[NamiConditionEvaluator] ${e}`)}}],[{key:"shared",get:function(){return e.instance||(e.instance=new e),e.instance}}])}(),$c=function(){return c(function e(){o(this,e)},[{key:"register",value:function(){Oc.shared.registerNamespaceResolver(this.namespace,e=>{var t=e.replace(new RegExp(`^${this.namespace}\\.`),"");return this.resolveValue(t)})}},{key:"resolveKeyPath",value:function(e,t){for(var n,i=t,a=h(e.replace(/\[(\w+)\]/g,".$1").split(".").filter(Boolean));!(n=a()).done;){var r=n.value;if(null==i||"object"!=typeof i)return;i=i[r]}return i}}])}(),Nc=function(e){function t(e,n){var i;return o(this,t),(i=r(this,t)).namespace="LaunchContext",i.context=e,i.campaign=n,i.register(),i}return p(t,e),c(t,[{key:"resolveValue",value:function(e){var t,n,i,a;if("placement"===e)return null!==(t=null===(n=this.campaign)||void 0===n?void 0:n.value)&&void 0!==t?t:void 0;if("tags"===e)return null!==(i=null===(a=this.campaign)||void 0===a?void 0:a.placement_tags)&&void 0!==i?i:void 0;if(e.startsWith("customAttributes.")){var r=e.substring(17);return this.resolveKeyPath(r,this.context.customAttributes)}if(e.startsWith("customObject.")){var o=e.substring(13);return this.resolveKeyPath(o,this.context.customObject)}return this.resolveKeyPath(e,{customAttributes:this.context.customAttributes,customObject:this.context.customObject,productGroups:this.context.productGroups})}}])}($c),Wc=function(e){function t(){var e,n,i,a;o(this,t),(a=r(this,t)).namespace="Device";var s=Intl.DateTimeFormat().resolvedOptions().locale.split("-")[1]||"",u=Intl.DateTimeFormat().resolvedOptions().timeZone,l=ru(),d=we().device.getScreenInfo();return a.context={osName:l.os_name,osVersion:l.os_version,appVersion:l.extended_platform_version,sdkVersion:l.sdk_version,deviceModel:l.device_model,screenWidth:Math.round(d.width),screenHeight:Math.round(d.height),formFactor:l.form_factor,tvQuality:a.tvQuality(null!==(e=l.form_factor)&&void 0!==e?e:"desktop",d),tvResolution:a.tvResolution(null!==(n=l.form_factor)&&void 0!==n?n:"desktop",d),screenSize:a.screenSizeTier(null!==(i=l.form_factor)&&void 0!==i?i:"desktop",d),language:l.language,country:s,timezone:u},a.register(),a}return p(t,e),c(t,[{key:"screenSizeTier",value:function(e,t){var n=Math.round(t.width*t.scale),i=Math.round(t.height*t.scale),a=Math.max(n,i);switch(e){case"phone":return a<1136?"tiny":a<1334?"small":a<1920?"medium":a<2560?"large":"huge";case"tablet":return a<2048?"medium":a<2732?"large":"huge";case"television":return a<1920?"medium":a<3840?"large":"huge";case"desktop":return a<1440?"small":a<2560?"medium":a<3840?"large":"huge";default:return"medium"}}},{key:"tvQuality",value:function(e,t){if("television"!==e)return"";var n=Math.round(t.width*t.scale),i=Math.round(t.height*t.scale),a=Math.max(n,i),r=Math.min(n,i);return a>=3840||r>=2160?"4K":a>=1920||r>=1080?"1080p":"720p"}},{key:"tvResolution",value:function(e,t){if("television"!==e)return"";var n=Math.round(t.width*t.scale),i=Math.round(t.height*t.scale),a=Math.max(n,i),r=Math.min(n,i);return r<720&&a<1280?"SD":r>=720&&r<1080&&a>=1280&&a<1920?"720p":r>=1080&&r<1440&&a>=1920&&a<2560?"1080p":r>=1440&&r<2160&&a>=2560&&a<3840?"1440p":r>=2160&&r<3e3&&a>=3840&&a<5e3?"4K":r>=3e3&&a>=5e3?"8K":"Unknown"}},{key:"resolveValue",value:function(e){return this.resolveKeyPath(e,this.context)}}])}($c),jc=[/(^|_)api(_|$)?key/i,/^key$/i,/^token$/i,/id[_-]?token/i,/access[_-]?token/i,/^auth/i,/password/i,/secret/i,/signature/i,/hmac/i,/^jwt$/i,/^code$/i,/redirect[_-]?uri/i,/return[_-]?url/i,/^state$/i,/^session$/i,/^sid$/i,/^sso$/i,/assertion/i],Bc=function(){function e(){o(this,e),this.params={},"undefined"!=typeof window&&this.setSearchParams()}return c(e,[{key:"setSearchParams",value:function(){this.params=this.extractSafeParams()}},{key:"safeValue",value:function(e){if(!e)return null;try{var t=decodeURIComponent(e).trim();return!t||/^null|undefined$/i.test(t)||((e=>e.includes("://")||/^\/.*\?/.test(e))(t)||(e=>/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+$/.test(e))(t)||(e=>/^[A-Za-z0-9_-]{40,}$/.test(e)||/^[A-Fa-f0-9]{40,}$/.test(e)||/^ya29\./.test(e)||/^sk_/.test(e)||/^ghp_/.test(e))(t))?null:((e,t=128)=>e.length>t?e.slice(0,t):e)(t)}catch(e){return null}}},{key:"extractSafeParams",value:function(){var e=window.location,t={},n=new Set;try{for(var i,a=new URLSearchParams(e.search),r=(e,i)=>{var a=(e=>e.replace(/([a-z])([A-Z])/g,"$1_$2").replace(/[-\s]/g,"_").toLowerCase())(e);if(!(n.size>=10||(e=>jc.some(t=>t.test(e)))(a))){var r=this.safeValue(i);r&&(t[a]=r,n.add(a))}},o=h(a.entries());!(i=o()).done;){var s=i.value;r(s[0],s[1])}}catch(e){}return t}}],[{key:"instance",get:function(){return e._instance||(e._instance=new e),e._instance}},{key:"refresh",value:function(){"undefined"!=typeof window&&this.instance.setSearchParams()}}])}();Bc._instance=null;var zc=()=>Bc.instance.params;function Uc(e){if(null!=e&&""!==e){if("boolean"==typeof e)return e?"true":"false";if("number"==typeof e){if(!Number.isFinite(e))return;return String(e)}return String(e)}}var Hc,Gc=/\{\{\s*([^}]+?)\s*\}\}/g,Vc=function(){return c(function e(t){o(this,e),this.flowManager=t,this.urlParams=zc()},[{key:"resolve",value:function(e){var t,n,i,a,r,o,s,u,l,d,c,h,m=this.flowManager.currentFlow,f=null==m?void 0:m.component;if(e.startsWith("launchContext.")){var v,p=null===(v=this.flowManager.currentFlow)||void 0===v?void 0:v.context;if(p){var g=e.substring(14),y=new Nc(p).resolveValue(g);return null==y?void 0:y.toString()}}else{if(e.startsWith("form.")){var b,w=e.substring(5);return Uc(null===(b=xd.currentProvider)||void 0===b?void 0:b.state.formStates[w])}switch(e){case"campaignId":return null==f||null===(t=f.campaign)||void 0===t?void 0:t.rule;case"campaignName":return null==f||null===(n=f.campaign)||void 0===n?void 0:n.name;case"campaignLabel":case"campaignPlacement":return null!==(i=null==f||null===(a=f.campaign)||void 0===a?void 0:a.value)&&void 0!==i?i:void 0;case"campaignSegment":case"campaignSegmentId":return null==f||null===(r=f.campaign)||void 0===r?void 0:r.segment;case"campaignExternalSegment":case"campaignExternalSegmentId":return null!==(o=null==f||null===(s=f.campaign)||void 0===s?void 0:s.external_segment)&&void 0!==o?o:void 0;case"pageName":return null==f||null===(u=f.paywall)||void 0===u?void 0:u.name;case"pageId":return null==f||null===(l=f.paywall)||void 0===l?void 0:l.id;case"flowName":return null==m?void 0:m.name;case"flowId":return null==m?void 0:m.id;case"objectId":return null==f||null===(d=f.campaign)||void 0===d||null===(d=d.flow)||void 0===d?void 0:d.object_id;case"stepName":return null==m||null===(c=m.currentFlowStep)||void 0===c?void 0:c.name;case"buttonText":var k=null==m?void 0:m.currentButton;if(!k)return;var S=k.firstTextValue;if("function"!=typeof S)return;return S.call(k);case"slideNumber":var E=null==f?void 0:f.getSelectedSlideIndexForCurrentCarousel();return null!=E?`${E+1}`:void 0;case"productGroupId":return(null===(h=xd.currentProvider)||void 0===h?void 0:h.state.currentGroupId)||void 0;case"productGroupName":var P,T,_,M=null===(P=xd.currentProvider)||void 0===P?void 0:P.state;return null!==(T=null==M||null===(_=M.groups)||void 0===_||null===(_=_.find(e=>e.id===M.currentGroupId))||void 0===_?void 0:_.displayName)&&void 0!==T?T:void 0;case"productGroupRef":var A,D,x,C=null===(A=xd.currentProvider)||void 0===A?void 0:A.state;return null!==(D=null==C||null===(x=C.groups)||void 0===x||null===(x=x.find(e=>e.id===C.currentGroupId))||void 0===x?void 0:x.ref)&&void 0!==D?D:void 0;case"flowPath":return null==m?void 0:m.flowPath;default:return}}}},{key:"interpolateLiquidVariables",value:function(e){return e.replace(Gc,(e,t)=>{var n,i=null!==(n=this.resolve(t))&&void 0!==n?n:this.urlParams[t];return null!=i?i:""})}},{key:"interpolateDeep",value:function(e){return"string"==typeof e?this.interpolateLiquidVariables(e):Array.isArray(e)?e.map(e=>this.interpolateDeep(e)):e&&"object"==typeof e?Object.entries(e).reduce((e,[t,n])=>m({},e,{[t]:this.interpolateDeep(n)}),{}):e}}])}(),Kc=function(e){function t(){var e;return o(this,t),(e=r(this,t)).namespace="urlParams",e.context=zc(),e.register(),e}return p(t,e),c(t,[{key:"resolveValue",value:function(e){return ui.debug("[URLParamsResolver]","Resolving keyPath",e),this.resolveKeyPath(e,this.context)}}])}($c),Xc=function(e){function t(){var e;return o(this,t),(e=r(this,t)).namespace="state",e.register(),e}return p(t,e),c(t,[{key:"getContextProvider",value:function(){var e=xd.providers;if(0!==e.length){var t=e.find(e=>e.flow);return t||e[e.length-1]}}},{key:"resolveValue",value:function(e){var t=this.getContextProvider();if(t){if(e.startsWith("formStates.")){var n=e.substring(11);return t.getCurrentFormId(n)}return this.resolveKeyPath(e,t.state)}}}])}($c),Yc=function(e){function t(e){var n;return o(this,t),(n=r(this,t)).namespace="Placement",n.campaign=e,n.register(),n}return p(t,e),c(t,[{key:"resolveValue",value:function(e){var t;if("label"===e){if(this.campaign&&void 0!==this.campaign.value&&null!==this.campaign.value)return this.campaign.value;var n=xd.providers;if(0!==n.length){var i=n.find(e=>e.flow);return i?i.getCurrentPlacementLabel():null===(t=n[n.length-1])||void 0===t?void 0:t.getCurrentPlacementLabel()}}}}])}($c),qc=function(e){function t(){var e;return o(this,t),(e=r(this,t,arguments)).namespace="LastLaunchContext",e}return p(t,e),c(t,[{key:"register",value:function(){T(t,"register",this)([])}},{key:"resolveValue",value:function(e){var t=Gd.shared.previous;if(t){if("placement"===e)return t.placementLabel;if("tags"===e)return t.tags;if(e.startsWith("customAttributes.")){var n=e.substring(17);return this.resolveKeyPath(n,t.customAttributes)}}}}])}($c);!function(e){e.LOGIN="login",e.LOGOUT="logout",e.ADVERTISING_ID_SET="advertising_id_set",e.ADVERTISING_ID_CLEARED="advertising_id_cleared",e.VENDOR_ID_SET="vendor_id_set",e.VENDOR_ID_CLEARED="vendor_id_cleared",e.CUSTOMER_DATA_PLATFORM_ID_SET="customer_data_platform_id_set",e.CUSTOMER_DATA_PLATFORM_ID_CLEARED="customer_data_platform_id_cleared",e.ANONYMOUS_MODE_ON="anonymous_mode_on",e.ANONYMOUS_MODE_OFF="anonymous_mode_off",e.NAMI_DEVICE_ID_SET="nami_device_id_set",e.NAMI_DEVICE_ID_CLEARED="nami_device_id_cleared"}(Hc||(Hc={}));var Jc=e=>{var t;return k(function(n){for(;;)switch(n.p=n.n){case 0:if(!ol()){n.n=1;break}return ui.info("Skipping transaction post - anonymous mode"),n.a(2);case 1:return n.p=1,n.n=2,a(js.instance.postConversion(e));case 2:n.n=4;break;case 3:n.p=3,t=n.v,ui.error("Error posting conversion",t);case 4:return n.a(2)}},null,null,[[1,3]],Promise)},Qc=function(){return c(function e(){o(this,e),this.emitter=Nu.getInstance()},[{key:"sdkInitialized",get:function(){return Vd.instance.isInitialized}}],[{key:"allPaywalls",value:function(){if(!this.instance.sdkInitialized)throw new Wr;return Hs()}},{key:"setProductDetails",value:function(e){this.instance.productDetails=e,xd.setProductDetails(e)}},{key:"registerSignInHandler",value:function(t){return this.instance.emitter.addListener(e.NamiPaywallManagerEvents.SignIn,t),()=>{this.instance.emitter.removeListener(e.NamiPaywallManagerEvents.SignIn,t)}}},{key:"registerCloseHandler",value:function(t){return this.instance.emitter.addListener(e.NamiPaywallManagerEvents.Close,t),()=>{this.instance.emitter.removeListener(e.NamiPaywallManagerEvents.Close,t)}}},{key:"registerDeeplinkActionHandler",value:function(t){return this.instance.emitter.addListener(e.NamiPaywallManagerEvents.DeeplinkAction,t),()=>{this.instance.emitter.removeListener(e.NamiPaywallManagerEvents.DeeplinkAction,t)}}},{key:"registerBuySkuHandler",value:function(t){return Cs()&&ui.debug("This handler will not be invoked because this account's plan includes built-in purchase management. Contact support@namiml.com for details."),this.instance.emitter.addListener(e.NamiPaywallManagerEvents.BuySku,t),()=>{this.instance.emitter.removeListener(e.NamiPaywallManagerEvents.BuySku,t)}}},{key:"registerRestoreHandler",value:function(t){return this.instance.emitter.addListener(e.NamiPaywallManagerEvents.Restore,t),()=>{this.instance.emitter.removeListener(e.NamiPaywallManagerEvents.Restore,t)}}},{key:"buySkuComplete",value:function(e){var t,n,i,r,o,s;return k(function(u){for(;;)switch(u.p=u.n){case 0:if(xd.setPurchaseInProgress(!1),Zc.instance.flowOpen&&(t=Zc.instance.currentFlow,n=null==t?void 0:t.currentFlowStep,t&&n&&t.executeLifecycle(n,vc)),!nh.inAnonymousMode()){u.n=1;break}return ui.debug("Skipping purchase validation - anonymous mode"),u.a(2);case 1:if(i=Fr.getSessionId(),r=Fr.getPurchaseImpression()){u.n=2;break}return ui.debug("Not sending paywall conversion call complete due to unknown impression"),u.a(2);case 2:return u.p=2,u.n=3,a(Jc({purchase_env:"production",app_env:"production",impression:r,session:i,amount:e.amount,currency:e.currency,transaction_id:e.transactionId,sku:e.skuId}));case 3:u.n=5;break;case 4:u.p=4,o=u.v,ui.error("Error posting conversion",o);case 5:if(Ds(Pe.THIRD_PARTY_TRANSACTIONS)){u.n=9;break}return u.p=6,u.n=7,a(js.instance.purchaseValidation({app_env:"production",payload:"",sku:e.skuId}));case 7:u.n=9;break;case 8:u.p=8,s=u.v,ui.error("Error validating purchase",s);case 9:return u.a(2)}},null,null,[[6,8],[2,4]],Promise)}},{key:"buySkuCancel",value:function(){Ds(Pe.THIRD_PARTY_TRANSACTIONS)?xd.setPurchase(!1):ui.warn("Call this method is not needed for this app because Nami is responsible for purchase management. Contact support@nami.ml for details.")}},{key:"setAppSuppliedVideoDetails",value:function(e,t){pu(e)?(ui.debug(`NamiPaywallManager: setAppSuppliedVideoDetails received valid url ${e}`),xd.setAppSuppliedVideoDetails({url:e,name:t})):ui.debug(`NamiPaywallManager: setAppSuppliedVideoDetails received invalid url ${e}`)}},{key:"allowUserInteraction",value:function(e){ui.debug(`NamiPaywallManager: allowUserInteraction called with ${e}`),xd.setUserInteractionEnabled(e)}}])}();Qc.instance=new Qc,Qc.emitter=Nu.getInstance();var Zc=function(){function e(){o(this,e),this.flowOpen=!1,this.lastAnimatedFlowProgress=new Map,this.navGraphCache=new WeakMap}return c(e,[{key:"hasHandoffHandler",get:function(){return!!this.handoffStepHandler}},{key:"deliverHandoff",value:function(t,n){var i=this.handoffStepHandler;if(i){var a={tag:t,completed:!1};this.pendingHandoff=a;i(t,n,n=>{if(a.completed)ui.warn(`[NamiFlowManager] complete() called more than once for handoff '${t}' — ignored`);else{var i=e.instance.pendingHandoff;i&&i!==a?ui.warn(`[NamiFlowManager] stale complete() for handoff '${t}' — a newer handoff ('${i.tag}') is pending; ignored`):(a.completed=!0,this.pendingHandoff===a&&(this.pendingHandoff=void 0),e.routeHandoffOutcome(null!=n?n:{kind:"done"}),e.resume())}})}}},{key:"resume",value:function(){e.resume()}},{key:"presentFlow",value:function(t,n,i){var a=new dh(t,n,this,i);return this.flowOpen=!0,this.currentFlow=a,js.impressionListener=t=>{var n;null===(n=e.instance.currentFlow)||void 0===n||n.bindImpression(t)},a}},{key:"finishFlow",value:function(){Vd.instance.maxLogging&&ui.debug("[NamiFlowManager] finishFlow() — closing flow"),this.flowOpen=!1,this.currentFlow=void 0,this.lastAnimatedFlowProgress.clear()}},{key:"getLastAnimatedFlowProgress",value:function(e){var t;return null!==(t=this.lastAnimatedFlowProgress.get(e))&&void 0!==t?t:0}},{key:"setLastAnimatedFlowProgress",value:function(e,t){this.currentFlow&&this.lastAnimatedFlowProgress.set(e,t)}},{key:"getCurrentFlowProgress",value:function(e){if(!this.currentFlow)return 1;if(!this.currentFlow.currentFlowStep)return 0;var t=this.currentFlow.steps.filter(e=>e.type===Zd);if(0===t.length)return 0;var n=this.currentFlow.stepcrumbs.filter(e=>e.type===Zd);if(0===n.length)return 0;var i=this.buildNavGraph(this.currentFlow),a=this.currentFlow.currentFlowStep,r=this.findBranchPoint(t,i),o=0;if(r)o=this.calculateBranchingProgress(n,t,a,r,i);else{var s=t.findIndex(e=>e.id===a.id);o=s>=0?(s+1)/t.length:0}return o=Math.max(0,Math.min(1,o)),e&&this.setLastAnimatedFlowProgress(e,o),o}},{key:"findBranchPoint",value:function(e,t){for(var n,i=h(e);!(n=i()).done;){var a=n.value;if(this.hasBranching(a,e,t))return a}return null}},{key:"calculateBranchingProgress",value:function(e,t,n,i,a){var r=e.length,o=t.findIndex(e=>e.id===i.id),s=e.findIndex(e=>e.id===i.id),u=t.findIndex(e=>e.id===n.id);if(-1===s||n.id===i.id)return(u+1)/(o+2);var l=this.countForwardScreens(n,t,a),d=r+l;return ui.debug(`Branching progress: visited=${r}, remaining=${l}, total=${d}, step=${n.id}`),r/d}},{key:"countForwardScreens",value:function(e,t,n){var i=t.findIndex(t=>t.id===e.id);if(-1===i)return 0;var a=new Set,r=0,o=(e,s)=>{if(!a.has(e)){a.add(e);var u=(n.get(e)||[]).filter(e=>{var n=t.findIndex(t=>t.id===e);return n>i});if(0!==u.length)for(var l,d=h(u);!(l=d()).done;){var c=l.value;o(c,s+1)}else r=Math.max(r,s)}};return o(e.id,0),r}},{key:"hasBranching",value:function(e,t,n){var i=t.findIndex(t=>t.id===e.id);if(-1===i)return!1;var a=(n.get(e.id)||[]).filter(e=>{var n=t.findIndex(t=>t.id===e);return n>i});return a.length>1}},{key:"buildNavGraph",value:function(e){var t=this.navGraphCache.get(e);if(t)return t;var n=new Map;e.steps.forEach(e=>{e.actions&&Object.values(e.actions).forEach(t=>{Array.isArray(t)&&t.forEach(t=>{t.action&&t.action.forEach(t=>{if("flowNav"===t.function){var i,a=null===(i=t.parameters)||void 0===i?void 0:i.step;a&&(n.has(e.id)||n.set(e.id,new Set),n.get(e.id).add(a))}})})})});var i=new Map;return n.forEach((e,t)=>{i.set(t,Array.from(e))}),this.navGraphCache.set(e,i),i}},{key:"getCurrentFlowStepAutoAdvanceDelay",value:function(){var e,t,n=null===(e=this.currentFlow)||void 0===e?void 0:e.currentFlowStep;if(!n)return null;var i=null===(t=n.actions)||void 0===t?void 0:t[lc];if(!i)return null;for(var a,r=h(i);!(a=r()).done;)for(var o,s,u=h(null!==(o=a.value.action)&&void 0!==o?o:[]);!(s=u()).done;){var l,d=s.value;if((d.function===Jd.NAVIGATE||d.function===Jd.NEXT)&&null!=(null===(l=d.parameters)||void 0===l?void 0:l.delay)){var c=d.parameters.delay,m=Number(c);if(!isNaN(m)&&m>0)return m/1e3}}return null}}],[{key:"instance",get:function(){return e._instance||(e._instance=new e),e._instance}},{key:"reset",value:function(){var t=e.instance;t.currentFlow=void 0,t.flowOpen=!1,t.lastAnimatedFlowProgress=new Map,t.navGraphCache=new WeakMap,t.pendingHandoff=void 0}},{key:"registerStepHandoff",value:function(e){this.instance.handoffStepHandler=e;var t=e;return()=>{this.instance.handoffStepHandler===t&&(this.instance.handoffStepHandler=void 0)}}},{key:"routeHandoffOutcome",value:function(t){var n=e.instance.currentFlow,i=null==n?void 0:n.currentFlowStep;switch(t.kind){case"done":return;case"permission":if(!n)return;if(n.handoffState.permissions[t.permission]=t.granted,!t.granted)return;i&&n.executeLifecycle(i,bc);var a=oc[t.permission];return void(a?n.completionSignal(a):ui.debug(`[NamiFlowManager] permission '${t.permission}' granted — no completion_result mapping yet (state/lifecycle only)`));case"purchase":return void("success"===t.result?Qc.buySkuComplete(t.details):(xd.setPurchase(!1),n&&i&&n.executeLifecycle(i,pc)));case"login":if("success"===t.result){var r,o,s=t.details;if(n)n.handoffState.login=m({},null!==(o=s.attributes)&&void 0!==o?o:{});nh.loggedInId()===s.loginId?n&&i&&n.executeLifecycle(i,cc):Promise.resolve(nh.login(s.loginId)).catch(e=>{ui.error("[NamiFlowManager] login from handoff outcome failed",e)});var u=null===(r=Fr.getDevice())||void 0===r?void 0:r.customer_data_platform_id;s.cdpId&&s.cdpId!==u&&Promise.resolve(nh.setCustomerDataPlatformId(s.cdpId)).catch(e=>{ui.error("[NamiFlowManager] CDP id write-through from handoff outcome failed",e)})}else n&&i&&n.executeLifecycle(i,hc);return}}},{key:"registerEventHandler",value:function(e){this.instance.eventHandler=e;var t=e;return()=>{this.instance.eventHandler===t&&(this.instance.eventHandler=void 0)}}},{key:"resume",value:function(){var t,n,i,a=e.instance,r=a.flowOpen,o=a.currentFlow;Vd.instance.maxLogging&&ui.debug(`[NamiFlowManager] resume() — flowOpen=${r}, hasFlow=${!!o}, currentStep=${null!==(t=null==o||null===(n=o.currentFlowStep)||void 0===n?void 0:n.id)&&void 0!==t?t:"none"}, isPaused=${null!==(i=null==o?void 0:o.isPaused)&&void 0!==i?i:"N/A"}`);var s=e.instance.pendingHandoff;if(s&&!s.completed&&(s.completed=!0,e.instance.pendingHandoff=void 0,ui.warn(`[NamiFlowManager] resume() called during handoff '${s.tag}' with a v2 handler registered — treated as complete({kind:'done'}); prefer complete(outcome)`)),r&&o&&o.currentFlowStep){if(o.activeHandoffSequence)return ui.debug(`Resuming flow at handoff sequence ${o.currentFlowStep.id}`),void o.resumeNextHandoff();ui.debug(`Resuming flow at step ${o.currentFlowStep.id}`),o.executeLifecycle(o.currentFlowStep,"__resume__")}else ui.warn("Cannot resume: no active flow or current step")}},{key:"finish",value:function(){var t=e.instance,n=t.flowOpen,i=t.currentFlow;n&&i&&i.currentFlowStep?(ui.debug(`Finishing flow programmatically at step ${i.currentFlowStep.id}`),i.dismiss()):ui.debug("Cannot finish: no active flow or current step")}},{key:"pause",value:function(){var t=e.instance,n=t.flowOpen,i=t.currentFlow;n&&i&&i.currentFlowStep?!0===i.resumeFromBookmark?i.pause():ui.warn("This flow cannot be paused"):ui.warn("Cannot pause: no active flow or current step")}},{key:"isFlowOpen",value:function(){return e.instance.flowOpen}},{key:"getLastAnimatedFlowProgress",value:function(e){return this.instance.getLastAnimatedFlowProgress(e)}},{key:"setLastAnimatedFlowProgress",value:function(e,t){this.instance.setLastAnimatedFlowProgress(e,t)}},{key:"getCurrentFlowProgress",value:function(e){return this.instance.getCurrentFlowProgress(e)}},{key:"getCurrentFlowStepAutoAdvanceDelay",value:function(){return this.instance.getCurrentFlowStepAutoAdvanceDelay()}}])}(),eh=Object.freeze({__proto__:null,NamiFlowManager:Zc}),th=()=>{var e,t;return null!==(e=null===(t=Fr.getNamiConfig())||void 0===t||null===(t=t.namiCommands)||void 0===t?void 0:t.includes("disableAsyncLoginLogout"))&&void 0!==e&&e},nh=function(){return c(function e(){o(this,e),this.emitter=Nu.getInstance(),Oc.shared.registerNamespaceResolver("UserTags",t=>{var n,i=t.replace("UserTags.","");return null!==(n=e.getCustomerAttribute(i))&&void 0!==n?n:null})},[{key:"isSDKInitialized",get:function(){return Vd.instance.isInitialized}}],[{key:"isLoggedIn",value:function(){return Ud.instance.isLoggedIn()}},{key:"loggedInId",value:function(){return this.instance.isSDKInitialized||ui.debug(Ne),Ud.instance.getExternalId()}},{key:"login",value:function(e){var t,n,i,r,o,s,u,l,d;return k(function(c){for(;;)switch(c.p=c.n){case 0:if(this.instance.isSDKInitialized){c.n=1;break}throw t=new Wr,this.invokeStateHandler(Hc.LOGIN,!1,t),t;case 1:if(!this.inAnonymousMode()){c.n=2;break}throw n=new Kr,this.invokeStateHandler(Hc.LOGIN,!1,n),n;case 2:if(th()){c.n=3;break}return Ud.instance.loginLocal(e),this.invokeStateHandler(Hc.LOGIN,!0),Zc.instance.flowOpen&&(i=Zc.instance.currentFlow,(r=null==i?void 0:i.currentFlowStep)&&(Vd.instance.maxLogging&&ui.debug(`[NamiCustomerManager] async login success — triggering __login_success__ on step ${r.id}`),i.executeLifecycle(r,cc))),Ud.instance.loginRemote(e).catch(e=>{ui.error("[NamiCustomerManager] async login API failed",e)}),Fd.instance.fetchActiveEntitlements().catch(e=>{ui.error("[NamiCustomerManager] async login entitlement refresh failed",e)}),c.a(2);case 3:return c.p=3,c.n=4,a(Ud.instance.login(e));case 4:return c.n=5,a(Fd.instance.fetchActiveEntitlements());case 5:this.invokeStateHandler(Hc.LOGIN,!0),Zc.instance.flowOpen&&(o=Zc.instance.currentFlow,(s=null==o?void 0:o.currentFlowStep)&&(Vd.instance.maxLogging&&ui.debug(`[NamiCustomerManager] login success — triggering __login_success__ on step ${s.id}`),o.executeLifecycle(s,cc))),c.n=7;break;case 6:throw c.p=6,d=c.v,this.invokeStateHandler(Hc.LOGIN,!1,d),Zc.instance.flowOpen&&(u=Zc.instance.currentFlow,(l=null==u?void 0:u.currentFlowStep)&&(Vd.instance.maxLogging&&ui.debug(`[NamiCustomerManager] login failure — triggering __login_failure__ on step ${l.id}`),u.executeLifecycle(l,hc))),d;case 7:return c.a(2)}},null,this,[[3,6]],Promise)}},{key:"logout",value:function(){var e,t,n,i,r,o,s,u,l;return k(function(d){for(;;)switch(d.p=d.n){case 0:if(this.instance.isSDKInitialized){d.n=1;break}throw e=new Wr,this.invokeStateHandler(Hc.LOGOUT,!1,e),e;case 1:if(!this.inAnonymousMode()){d.n=2;break}throw t=new Kr,this.invokeStateHandler(Hc.LOGOUT,!1,t),t;case 2:if(th()){d.n=3;break}return Ud.instance.logoutLocal(),this.invokeStateHandler(Hc.LOGOUT,!0),Zc.instance.flowOpen&&(n=Zc.instance.currentFlow,(i=null==n?void 0:n.currentFlowStep)&&(Vd.instance.maxLogging&&ui.debug(`[NamiCustomerManager] async logout success — triggering __logout_success__ on step ${i.id}`),n.executeLifecycle(i,mc))),Ud.instance.logoutRemote().catch(e=>{ui.error("[NamiCustomerManager] async logout API failed",e)}),Fd.instance.fetchActiveEntitlements().catch(e=>{ui.error("[NamiCustomerManager] async logout entitlement refresh failed",e)}),d.a(2);case 3:return d.p=3,d.n=4,a(Ud.instance.logout());case 4:return d.n=5,a(Fd.instance.fetchActiveEntitlements());case 5:this.invokeStateHandler(Hc.LOGOUT,!0),Zc.instance.flowOpen&&(r=Zc.instance.currentFlow,(o=null==r?void 0:r.currentFlowStep)&&r.executeLifecycle(o,mc)),d.n=7;break;case 6:throw d.p=6,l=d.v,this.invokeStateHandler(Hc.LOGOUT,!1,l),Zc.instance.flowOpen&&(s=Zc.instance.currentFlow,(u=null==s?void 0:s.currentFlowStep)&&s.executeLifecycle(u,fc)),l;case 7:return d.a(2)}},null,this,[[3,6]],Promise)}},{key:"setCustomerDataPlatformId",value:function(e){return k(function(t){for(;;)switch(t.n){case 0:return t.n=1,a(this.updateCustomerDataPlatformId(e));case 1:return t.a(2)}},null,this,null,Promise)}},{key:"clearCustomerDataPlatformId",value:function(){return k(function(e){for(;;)switch(e.n){case 0:return e.n=1,a(this.updateCustomerDataPlatformId(null));case 1:return e.a(2)}},null,this,null,Promise)}},{key:"registerAccountStateHandler",value:function(e){return this.instance.emitter.on("accountStateChange",e),()=>{this.instance.emitter.off("accountStateChange",e)}}},{key:"setAnonymousMode",value:function(e){var t,n,i,r,o;return k(function(s){for(;;)switch(s.n){case 0:if(t=e?Hc.ANONYMOUS_MODE_ON:Hc.ANONYMOUS_MODE_OFF,this.instance.isSDKInitialized){s.n=1;break}throw n=new Wr,this.invokeStateHandler(t,!1,n),n;case 1:if(this.anonymousModeCapability()){s.n=2;break}return ui.warn("Anonymous mode feature is not enabled for your Nami account. Contact support@nami.ml for details."),s.a(2);case 2:if(this.inAnonymousMode()!==e){s.n=3;break}return i=e?new Gr:new Vr,this.invokeStateHandler(t,!1,i),s.a(2);case 3:if(!e){s.n=4;break}Fr.setAnonymousMode(e),Fr.resetDevice(),this.refetchConfig(),this.invokeStateHandler(Hc.ANONYMOUS_MODE_ON,!0),s.n=6;break;case 4:return Fr.clearAnonymousMode(),rl(),o=null===(r=Fr.getNamiConfig())||void 0===r?void 0:r.namiCommands,s.n=5,a(Bu.instance.createOrUpdateDevice(ru(o)));case 5:Fr.clearAnonymousUUID(),this.refetchConfig(),this.invokeStateHandler(Hc.ANONYMOUS_MODE_OFF,!0);case 6:return s.a(2)}},null,this,null,Promise)}},{key:"inAnonymousMode",value:function(){return!!this.instance.isSDKInitialized&&ol()}},{key:"setCustomerAttribute",value:function(e,t){if(!this.instance.isSDKInitialized)throw new Wr;if(Fr.setCustomerAttribute(e,t),Ds(Pe.PAYWALL_PERSONALIZATION)?(xd.setCustomerAttribute({[e]:t}),ui.debug(`This customer attribute you set is now available for paywall personalization using the smart text variable: ${e}`)):ui.warn(`The customer attribute ${e} is not available for using on a paywall, because your account's plan does not include paywall personalization. Contact support@nami.ml for details.`),Zc.instance.flowOpen){var n=Zc.instance.currentFlow;if(n){var i=n.currentFlowStep;i&&n.executeLifecycle(i,yc)}}}},{key:"getCustomerAttribute",value:function(e){if(!this.instance.isSDKInitialized)throw new Wr;var t=Fr.getCustomerAttribute(e);return null!=t?Ds(Pe.PAYWALL_PERSONALIZATION)?ui.debug(`Found customer attribute. ${e} is available for paywall personalization on this device.`):ui.warn(`Found customer attribute. ${e} is not available for use on a paywall because paywall personalization is not included in your account's plan. Contact support@nami.ml for details.`):ui.debug(`No ${e} customer attribute found.`),t}},{key:"getAllCustomerAttributes",value:function(){if(!this.instance.isSDKInitialized)throw new Wr;return Fr.getAllCustomerAttributes()}},{key:"clearCustomerAttribute",value:function(e){if(!this.instance.isSDKInitialized)throw new Wr;Fr.clearCustomerAttribute(e)?(xd.removeCustomerAttribute(e),ui.warn(`This customer attribute has been cleared. ${e} is no longer available for paywall personalization on this device. A default value will be used if set in the Nami Control Center.`)):ui.warn(`No value to clear for attribute ${e}.`)}},{key:"clearAllCustomerAttributes",value:function(){if(!this.instance.isSDKInitialized)throw new Wr;Fr.getAllCustomerAttributesKeys().forEach(e=>{xd.removeCustomerAttribute(e)}),Fr.clearAllCustomerAttributes(),ui.warn("All customer attribute have been cleared. customer's smart text will no longer be personalized for this device. A default value will be used if set in the Nami Control Center.")}},{key:"journeyState",value:function(){if(!this.instance.isSDKInitialized)throw new Wr;return Fr.getCustomerJourneyState()}},{key:"deviceId",value:function(){var e,t;return this.instance.isSDKInitialized&&null!==(e=null===(t=Fr.getDevice())||void 0===t?void 0:t.id)&&void 0!==e?e:qe}},{key:"registerJourneyStateHandler",value:function(e){if(Cs("NamiCustomerManager.registerJourneyStateHandler"))return this.instance.emitter.addListener(qn,e),()=>{this.instance.emitter.removeListener(qn,e)}}},{key:"invokeStateHandler",value:function(e,t,n){this.instance.emitter.emit("accountStateChange",e,t,n)}},{key:"updateCustomerDataPlatformId",value:function(e){var t,n,i,r;return k(function(o){for(;;)switch(o.p=o.n){case 0:if(this.instance.isSDKInitialized){o.n=1;break}throw t=new Wr,this.invokeStateHandler(Hc.CUSTOMER_DATA_PLATFORM_ID_SET,!1,t),t;case 1:if(this.inAnonymousMode()){o.n=6;break}return o.p=2,o.n=3,a(Bu.instance.updateDeviceField("customer_data_platform_id",e));case 3:this.invokeStateHandler(Hc.CUSTOMER_DATA_PLATFORM_ID_SET,!0),o.n=5;break;case 4:o.p=4,r=o.v,this.invokeStateHandler(Hc.CUSTOMER_DATA_PLATFORM_ID_SET,!1,r);case 5:o.n=7;break;case 6:return ui.info("Unable to set CDP ID in anonymous mode",{deviceId:null===(n=Fr.getDevice())||void 0===n?void 0:n.id,anonymousMode:!0}),i=new Xr,this.invokeStateHandler(Hc.CUSTOMER_DATA_PLATFORM_ID_SET,!1,i),o.a(2);case 7:return o.a(2)}},null,this,[[2,4]],Promise)}},{key:"anonymousModeCapability",value:function(){if(!this.instance.isSDKInitialized)return!1;var e=Ds(Pe.ANONYMOUS_MODE_CAPABILITY),t=Ds(Pe.THIRD_PARTY_TRANSACTIONS);return e&&t}},{key:"refetchConfig",value:function(){return k(function(e){for(;;)switch(e.n){case 0:if(!this.instance.isSDKInitialized){e.n=1;break}return e.n=1,a(Promise.all([zu.instance.fetchProducts(),nl.instance.fetchPaywalls().then(e=>Wu.instance.fetchCampaignRules(e))]));case 1:return e.a(2)}},null,this,null,Promise)}}])}();nh.instance=new nh;var ih="This field is required",ah="Please enter a valid email address",rh="Please enter at least 2 characters",oh=/^[^\s@]+@[^\s@]+\.[^\s@]+$/;function sh(e,t,n){var i=("string"==typeof n?n:null==n?"":String(n)).trim();return t&&0===i.length?ih:0!==i.length?"email"!==e||oh.test(i)?"name"===e&&i.length<2?rh:void 0:ah:void 0}var uh=/^([^:]+)::(.+)$/,lh=function(){return c(function e(t={}){var n,i,a,r,s;o(this,e),this.id=null!==(n=t.id)&&void 0!==n?n:"",this.name=null!==(i=t.name)&&void 0!==i?i:"",this.steps=null!==(a=t.steps)&&void 0!==a?a:[],this.screens=null!==(r=t.screens)&&void 0!==r?r:[],this.resumeFromBookmark=Boolean(t.resume_from_bookmark),this.transition=null!==(s=t.transition)&&void 0!==s?s:"none"},[{key:"allScreensAvailable",get:function(){return this.screens.length>0&&Vs(this.screens)}}])}(),dh=function(e){function t(e,n,i,a){var s,u;o(this,t),(u=r(this,t,[null!==(s=e.flow.object)&&void 0!==s?s:{}])).stepcrumbs=[],u.branchcrumbs=[],u.activeHandoffSequence=null,u.currentScreenState=null,u.isPaused=!1,u.flowPath="",u.timerStates={},u.handoffState={permissions:{}},u.campaign=e,u.component=n,u.context=a,u.manager=i,u.branchcrumbs=[],u.stepcrumbs=[],u.registerResolvers(a);var l=u.findStepByType(Qd);return l&&u.forward(l.id),u}return p(t,e),c(t,[{key:"applyLaunchContextAttributes",value:function(e){var t,n;this.context||(this.context={customAttributes:{}},new Nc(this.context,this.campaign)),null!==(n=(t=this.context).customAttributes)&&void 0!==n||(t.customAttributes={}),Object.assign(this.context.customAttributes,e)}},{key:"registerResolvers",value:function(e){e&&new Nc(e,this.campaign),new Wc,new Kc,new Xc,new Yc(this.campaign),(new qc).register(),Oc.shared.registerNamespaceResolver("Flow",e=>{switch(e){case"Flow.stepcrumbs":return this.stepcrumbs.map(e=>e.id);case"Flow.branchcrumbs":return this.branchcrumbs;default:return}}),Oc.shared.registerNamespaceResolver("login",e=>{var t,n=e.replace(/^login\./,"");return null===(t=this.handoffState.login)||void 0===t?void 0:t[n]}),Oc.shared.registerNamespaceResolver("permissions",e=>{var t=e.replace(/^permissions\./,"");return this.handoffState.permissions[t]}),Oc.shared.registerNamespaceResolver("__first_session__",()=>jd.instance.getIsFirstSession())}},{key:"currentFlowStep",get:function(){return this.stepcrumbs.at(-1)}},{key:"nextStepAvailable",get:function(){return void 0!==this.nextFlowStep}},{key:"previousStepAvailable",get:function(){var e,t=!!this.previousFlowStep,n=!1!==(null===(e=this.previousFlowStep)||void 0===e?void 0:e.allow_back_to),i=this.stepcrumbs.slice(0,-1).some(e=>"screen"===e.type);return t&&n&&i}},{key:"previousFlowStep",get:function(){var e=this.stepcrumbs.length-2;return e>=0?this.stepcrumbs[e]:void 0}},{key:"nextFlowStep",get:function(){return this.nextStep(this.currentFlowStep)}},{key:"getStep",value:function(e){return this.steps.find(t=>t.id===e)}},{key:"findStepByType",value:function(e){return this.steps.find(t=>t.type===e)}},{key:"isStepActive",value:function(e){return!e.branch_tags||!e.branch_tags.length||e.branch_tags.some(e=>this.branchcrumbs.includes(e))}},{key:"flowLog",value:function(e,...t){Vd.instance.maxLogging&&ui.debug(`[NamiFlow] ${e}`,...t)}},{key:"finished",value:function(){var e;this.flowLog(`finished() — closing flow, isPaused=${this.isPaused}, step=${null===(e=this.currentFlowStep)||void 0===e?void 0:e.id}`),this.manager.finishFlow()}},{key:"dismiss",value:function(){this.signalNonCompletion("dismiss_page"),this.finished()}},{key:"back",value:function(){var e;if(!1!==(null===(e=this.previousFlowStep)||void 0===e?void 0:e.allow_back_to)){if(!this.stepcrumbs.slice(0,-1).some(e=>"screen"===e.type))return this.flowLog("back() — no previous screen step, dismissing flow"),void this.dismiss();this.backToPreviousScreenStep()}else ui.debug(`Not allowed to go back to ${this.previousFlowStep.id}`)}},{key:"bindImpression",value:function(e){var t=this.currentFlowStep;if(t){var n=this.completionContext;n&&n.stepId===t.id&&!n.impressionId?n.impressionId=e:this.completionContext={stepId:t.id,impressionId:e,resultSent:!1,pending:[]};var i=t.completion_step;null!=i&&i.enabled&&"page_view"===i.condition&&this.completionSignal("page_view");var a=this.completionContext.pending;this.completionContext.pending=[],a.forEach(e=>this.completionSignal(e))}}},{key:"completionSignal",value:function(e){var t=this.currentFlowStep,n=null==t?void 0:t.completion_step;if(t&&null!=n&&n.enabled&&n.condition===e){var i=this.completionContext;i&&i.stepId===t.id||(i=this.completionContext={stepId:t.id,resultSent:!1,pending:[]}),i.resultSent||(i.impressionId?(i.resultSent=!0,this.patchCompletion(i.impressionId,e)):i.pending.includes(e)||i.pending.push(e))}}},{key:"signalNonCompletion",value:function(e){var t=this.completionContext;t&&t.impressionId&&!t.resultSent&&(t.resultSent=!0,this.patchCompletion(t.impressionId,e))}},{key:"patchCompletion",value:function(e,t){var n,i;return k(function(r){for(;;)switch(r.p=r.n){case 0:return this.flowLog(`patchCompletion(${t}) — impression=${e}, step=${null===(n=this.currentFlowStep)||void 0===n?void 0:n.id}`),r.p=1,r.n=2,a(js.instance.patchImpressionCompletion(e,t,(new Date).toISOString()));case 2:r.n=4;break;case 3:r.p=3,i=r.v,ui.error(`[NamiFlow] completion PATCH failed for '${t}'`,i);case 4:return r.a(2)}},null,this,[[1,3]],Promise)}},{key:"next",value:function(){var e=this.nextFlowStep;e&&this.forward(e.id)}},{key:"backToPreviousScreenStep",value:function(){var e;if(!1!==(null===(e=this.previousFlowStep)||void 0===e?void 0:e.allow_back_to)){for(var t=this.stepcrumbs.length-2;t>=0;t--){var n=this.stepcrumbs[t];if(this.stepcrumbs.pop(),"branch"===n.type&&this.branchcrumbs.length>0&&this.branchcrumbs.pop(),"screen"===n.type&&n.screen){var i,a,r=Gs(n.screen);return r&&we().ui.flowNavigateToScreen(r,{transition:this.transition,direction:"backward"}),void(this.currentScreenState=null!==(i=null===(a=xd.currentProvider)||void 0===a?void 0:a.state)&&void 0!==i?i:null)}}ui.warn("No previous screen step found to return to")}else ui.warn(`Not allowed to go back to ${this.previousFlowStep.id}`)}},{key:"forward",value:function(e){var t=this.getStep(e);if(t)if(this.isStepActive(t))switch(this.flowLog(`forward(${e}) — type=${t.type}, name=${t.name}, isPaused=${this.isPaused}`),t.type){case Qd:case tc:return this.stepcrumbs.push(t),void this.executeLifecycle(t,uc);case ec:return void this.handleBranchStep(t);case Zd:return void this.handleScreenStep(t);case nc:return}else this.flowLog(`forward(${e}) — step not active (branch_tags=${JSON.stringify(t.branch_tags)}, branchcrumbs=${JSON.stringify(this.branchcrumbs)})`);else ui.error(`No step found with id: ${e}`)}},{key:"pause",value:function(){var e;this.isPaused?ui.info("Flow is already paused"):(this.isPaused=!0,this.pausedStepID=null===(e=this.currentFlowStep)||void 0===e?void 0:e.id,this.flowLog(`pause() — pausedStepID=${this.pausedStepID}`),ui.info("Flow paused"))}},{key:"resumeFromPause",value:function(){if(this.isPaused)if(this.isPaused=!1,this.pausedStepID){var e=this.pausedStepID;this.pausedStepID=void 0,this.flowLog(`resumeFromPause() — resuming from step ${e}`),ui.info(`Flow resumed from step ${e}`),this.forward(e)}else ui.warn("No step to resume from");else ui.info("Flow is not paused")}},{key:"executeLifecycle",value:function(e,t,n){t===vc?this.completionSignal("purchase_success"):t===cc&&this.completionSignal("login_success");var i=e.actions[t];i?(this.flowLog(`executeLifecycle(${t}) — step=${e.id}, isPaused=${this.isPaused}, ${i.length} lifecycle(s)`),this.executeFullLifecycles(i,n)):this.flowLog(`executeLifecycle(${t}) — no actions on step ${e.id}`)}},{key:"lifecycles",value:function(e){if(this.currentFlowStep){var t=this.currentFlowStep.actions[e];if(t)return t;ui.info(`No actions found for button ${e} on step ${this.currentFlowStep.id}`)}}},{key:"isFormSubmitLifecycle",value:function(e){var t=[Jd.SET_TAGS_FROM_FORM,Jd.NEXT,Jd.NAVIGATE];return e.some(e=>[e.before,e.action,e.after].some(e=>null==e?void 0:e.some(e=>t.includes(e.function))))}},{key:"triggerActions",value:function(e,t,n){var i,a,r,o=this.lifecycles(e);if(o){this.flowLog(`triggerActions(${e}) — step=${null===(i=this.currentFlowStep)||void 0===i?void 0:i.id}, isPaused=${this.isPaused}`),this.currentButton=t;var s=null!==(a=null===(r=xd.currentProvider)||void 0===r?void 0:r.state.formFieldValidators)&&void 0!==a?a:{};if(this.isFormSubmitLifecycle(o)&&Object.keys(s).length){var u,l=function(e,t){for(var n={},i=0,a=Object.entries(e);i<a.length;i++){var r,o=a[i],s=o[0],u=o[1],l=sh(u.type,u.required,t[s]);void 0!==l&&(n[s]=null!==(r=u.message)&&void 0!==r?r:l)}return n}(s,this.getFormData());if(null===(u=xd.currentProvider)||void 0===u||u.setFormFieldErrors(l),Object.keys(l).length)return void this.flowLog(`triggerActions(${e}) — HALTED by form validation: ${JSON.stringify(l)}`)}this.executeFullLifecycles(o,n)}}},{key:"executeFullLifecycles",value:function(e,t){for(var n,i=this,a=function(){var e=n.value,a=["before","action","after"];[e.before,e.action,e.after].forEach((e,n)=>null==e?void 0:e.forEach(e=>{var r=i.shouldRun(e);i.flowLog(` ${a[n]}: ${e.function}${e.id?` (${e.id})`:""} — shouldRun=${r}`),r&&i.performAction(e,t)}))},r=h(e);!(n=r()).done;)a()}},{key:"triggerBeforeActions",value:function(e,t,n){var i=this.lifecycles(e);if(i){this.currentButton=t;for(var a,r=h(i);!(a=r()).done;){var o;null===(o=a.value.before)||void 0===o||o.forEach(e=>this.shouldRun(e)&&this.performAction(e,n))}}}},{key:"triggerAfterActions",value:function(e,t,n){var i=this.lifecycles(e);if(i){this.currentButton=t;for(var a,r=h(i);!(a=r()).done;){var o;null===(o=a.value.after)||void 0===o||o.forEach(e=>this.shouldRun(e)&&this.performAction(e,n))}}}},{key:"currentStepHasHoistedPrimaryActions",value:function(e){var t=this.lifecycles(e);return!!t&&t.some(e=>{var t;return null===(t=e.action)||void 0===t?void 0:t.length})}},{key:"shouldRun",value:function(e){if(!e.conditions)return!0;var t=e.conditions.every(e=>{var t=Oc.shared.evaluate(e);if(Vd.instance.maxLogging){var n,i,a,r=null!==(n=null===(i=e.filter)||void 0===i?void 0:i.map(e=>`${e.identifier} ${e.operator} ${JSON.stringify(e.values)}`).join(", "))&&void 0!==n?n:"none";ui.debug(`[NamiFlow] condition: [${r}] op=${null!==(a=e.operator)&&void 0!==a?a:"default"} → ${t}`)}return t});return t}},{key:"performAction",value:function(e,t){var n,i;if(this.currentFlowStep){var a=(null!==(n=e.parameters)&&void 0!==n&&n.delay?+e.parameters.delay:0)||0;this.flowLog(`performAction(${e.function}) — step=${this.currentFlowStep.id}, delay=${a}, params=${JSON.stringify(null!==(i=e.parameters)&&void 0!==i?i:{})}`);var r=n=>{var i,a,r,o,s,u,l,d,c;if((null===(i=this.currentFlowStep)||void 0===i?void 0:i.id)===n)switch(e.function){case Jd.BACK:this.back();break;case Jd.NEXT:null!==(a=e.parameters)&&void 0!==a&&a.customAttributes&&this.applyLaunchContextAttributes(e.parameters.customAttributes),null!==(r=e.parameters)&&void 0!==r&&r.step?this.forward(e.parameters.step):this.next();break;case Jd.NAVIGATE:var h;if(null!==(o=e.parameters)&&void 0!==o&&o.customAttributes&&this.applyLaunchContextAttributes(e.parameters.customAttributes),null!==(s=e.parameters)&&void 0!==s&&s.step)(null===(h=this.previousFlowStep)||void 0===h?void 0:h.id)===e.parameters.step?this.back():this.forward(e.parameters.step);else this.next();break;case Jd.FINISHED:this.finished();break;case Jd.DISMISS:this.dismiss();break;case Jd.EXIT:this.signalNonCompletion("skip_page");var m=this.steps.find(e=>e.type===tc);m&&this.forward(m.id);break;case Jd.PAUSE:this.pause();break;case Jd.RESUME:this.resumeFromPause();break;case Jd.HANDOFF:var f,v,p,g,y,b,w=null===(f=e.parameters)||void 0===f?void 0:f.handoffTag;if(!w)break;if(null!==(v=e.parameters)&&void 0!==v&&v.handoffFormId&&this.completionSignal("form_submitted"),w.startsWith("__")){var k;w===ic&&null!==(k=e.parameters)&&void 0!==k&&k.handoffFormId?this.flowHandoffFormSequence():(ui.warn(`Ignoring reserved handoff tag '${w}' — resuming flow`),this.manager.resume());break}if(!this.manager.hasHandoffHandler){ui.debug("No handoffStepHandler found",e);break}if(w===ac.UserData&&null!==(p=e.parameters)&&void 0!==p&&p.handoffFormId){this.manager.deliverHandoff(w,this.buildUserDataEnvelope(e.parameters.handoffFormId));break}null!==(g=e.parameters)&&void 0!==g&&g.handoffData?b=e.parameters.handoffData:t?b=t:null!==(y=e.parameters)&&void 0!==y&&y.handoffFormId&&(b=this.getFormData()),ui.debug(`Invoking handoff handler with ${w}${b?` ${JSON.stringify(b)}`:" and no data"}`),this.manager.deliverHandoff(w,b);break;case Jd.LOG:var S;if(null!==(u=e.parameters)&&void 0!==u&&u.eventName)ui.info(`logEvent → ${e.parameters.eventName}`);else ui.warn(`Missing 'eventName' in logEvent action ${null!==(S=e.id)&&void 0!==S?S:"unknown"}`);break;case Jd.TRACK:var E;if(null!==(l=e.parameters)&&void 0!==l&&l.eventName)ui.info(`trackEvent → ${e.parameters.eventName}`);else ui.warn(`Missing 'eventName' in logEvent action ${null!==(E=e.id)&&void 0!==E?E:"unknown"}`);break;case Jd.SET_VIDEO:null!==(d=e.parameters)&&void 0!==d&&d.name&&e.parameters.url?xd.setAppSuppliedVideoDetails({name:e.parameters.name,url:e.parameters.url}):ui.warn("Missing name, url for setting video details");break;case Jd.BLOCK_BACK:var P,T=null===(P=e.parameters)||void 0===P?void 0:P.step,_=T?this.getStep(T):void 0;_?_.allow_back_to=!1:this.currentFlowStep?this.currentFlowStep.allow_back_to=!1:ui.warn("Missing step for blocking back");break;case Jd.FLOW_EVENT:var M,A=new Vc(this.manager),D=Object.fromEntries(Object.entries(null!==(M=e.parameters)&&void 0!==M?M:{}).map(([e,t])=>[e,A.interpolateDeep(t)]));this.manager.eventHandler?this.manager.eventHandler(D):ui.warn("Missing event handler",D);break;case Jd.FLOW_ENABLED:xd.setUserInteractionEnabled(!0);break;case Jd.FLOW_DISABLED:xd.setUserInteractionEnabled(!1);break;case Jd.SET_TAGS:e.parameters&&(xd.setUserTags(e.parameters),Object.entries(e.parameters).forEach(([e,t])=>{nh.setCustomerAttribute(e,t)}));break;case Jd.SET_TAGS_FROM_FORM:var x,C=null===(x=e.parameters)||void 0===x?void 0:x.include,I=Array.isArray(C)?new Set(C):void 0,L=this.getFormData(),R={};Object.entries(L).forEach(([e,t])=>{if(!I||I.has(e)){var n=Uc(t);void 0!==n&&(R[e]=n,nh.setCustomerAttribute(e,n))}}),Object.keys(R).length&&xd.setUserTags(R);break;case Jd.SET_LAUNCH_CONTEXT:var F=e.parameters;null!=F&&F.customAttributes?this.applyLaunchContextAttributes(F.customAttributes):void 0!==(null==F?void 0:F.key)&&void 0!==(null==F?void 0:F.value)&&this.applyLaunchContextAttributes({[F.key]:F.value});break;case Jd.SET_FLOW_PATH:var O,$=null===(O=e.parameters)||void 0===O?void 0:O.flowPath;"string"==typeof $&&(this.flowPath=$);break;default:ui.warn(`Missing action handler for ${e.function}`,e)}else this.flowLog(`performAction(${e.function}) — SKIPPED stale step ${n}, current=${null===(c=this.currentFlowStep)||void 0===c?void 0:c.id}`)};a?setTimeout(r.bind(this,this.currentFlowStep.id),a):r(this.currentFlowStep.id)}else ui.warn("No current flow step")}},{key:"nextStep",value:function(e){if(e){var t=this.steps.findIndex(t=>t.id===e.id);if(-1!==t){for(var n,i=h(this.steps.slice(t+1));!(n=i()).done;){var a=n.value;if(this.isStepActive(a))return a}ui.debug(`No active next step found after ${e.id}`)}else ui.error(`Could not find next step for step ${e.id}`)}else ui.error("Next step not found")}},{key:"handleScreenStep",value:function(e){var t,n=Gs(null!==(t=e.screen)&&void 0!==t?t:"");e.screen&&n&&this.campaign?(this.stepcrumbs.push(e),we().ui.flowNavigateToScreen(n,{transition:this.transition,direction:"forward"})):ui.error("No paywall or campaign found for next step")}},{key:"handleBranchStep",value:function(e){this.stepcrumbs.push(e);for(var t=0,n=Object.entries(e.actions);t<n.length;t++){var i=n[t],a=i[0],r=i[1];if(r)for(var o,s=h(r);!(o=s()).done;){var u=o.value;if(u.action)for(var l,d=h(u.action);!(l=d()).done;){var c,m,f=l.value;if(this.shouldRun(f))return this.branchcrumbs.push(a),null===(c=u.before)||void 0===c||c.forEach(e=>{this.performAction(e)}),u.action.forEach(e=>{this.shouldRun(e)&&this.performAction(e)}),void(null===(m=u.after)||void 0===m||m.forEach(e=>{this.performAction(e)}))}else ui.warn(`No actions defined for branch tag ${a}`)}}ui.warn(`No matching branch condition matched for step ${e.id}`)}},{key:"getFormData",value:function(){var e,t;return m({},null!==(e=null===(t=xd.currentProvider)||void 0===t||null===(t=t.state)||void 0===t?void 0:t.formStates)&&void 0!==e?e:{})}},{key:"buildUserDataEnvelope",value:function(e){var t,n;return{form_id:e,step_id:null!==(t=null===(n=this.currentFlowStep)||void 0===n?void 0:n.id)&&void 0!==t?t:"",collected_at:(new Date).toISOString(),fields:this.getFormData()}}},{key:"flowHandoffFormSequence",value:function(){var e,t=null===(e=this.currentScreenState)||void 0===e?void 0:e.formStates;if(t){var n=Object.keys(t);if(0!==n.length){if(n.some(e=>uh.test(e))){var i=this.buildHandoffGroups(t);return 0===i.length?(ui.info("No handoff groups after grouping"),void this.manager.resume()):(this.activeHandoffSequence={groups:i},void this.resumeNextHandoff())}var a=n.sort().filter(e=>!0===t[e]);if(0===a.length)return ui.info("No eligible handoff keys after filtering"),void this.manager.resume();this.activeHandoffSequence={formStates:m({},t),remainingKeys:[...a]},this.resumeNextHandoff()}else ui.warn("formStates is empty, no handoffs to perform")}else ui.warn("No formStates available for handoff sequence")}},{key:"buildHandoffGroups",value:function(e){for(var t=new Map,n=0,i=Object.keys(e);n<i.length;n++){var a=i[n],r=a.match(uh);if(r){var o=r[1],s=r[2];o.startsWith("__")?ui.warn(`Ignoring reserved handoff group tag '${o}'`):(t.has(o)||t.set(o,{}),t.get(o)[s]=e[a])}}return Array.from(t,([e,t])=>({tag:e,data:t})).filter(e=>Object.values(e.data).some(e=>!0===e)).sort((e,t)=>e.tag.localeCompare(t.tag))}},{key:"resumeNextHandoff",value:function(){var e=this.activeHandoffSequence;if(!e)return ui.warn("No active handoff sequence to resume"),void this.manager.resume();if("groups"in e){if(0===e.groups.length)return ui.info("All handoffs in the sequence are complete"),this.activeHandoffSequence=null,void this.manager.resume();var t=e.groups.shift();return function(e){return Object.values(ac).includes(e)}(t.tag)||ui.warn(`handoff group tag '${t.tag}' is outside the NamiHandoffTag vocabulary — passing through`),this.activeHandoffSequence=e,ui.debug(`Starting grouped handoff for '${t.tag}' → ${JSON.stringify(t.data)}`),void this.manager.deliverHandoff(t.tag,t.data)}if(0===e.remainingKeys.length)return ui.info("All handoffs in the sequence are complete"),this.activeHandoffSequence=null,void this.manager.resume();var n=e.remainingKeys.shift(),i=e.formStates[n];ui.debug(`Starting handoff for ${n} → ${String(i)}`),this.activeHandoffSequence=e,this.manager.deliverHandoff(`${n}`,void 0)}}])}(lh),ch=function(){return c(function e(){o(this,e),this.emitter=Nu.getInstance()},[{key:"sdkInitialized",get:function(){return Vd.instance.isInitialized}},{key:"campaignTypeAndLabel",value:function(t,n){var i,a="";return t&&!n&&pu(t)?(a=t,i=e.NamiCampaignRuleType.URL):t?(a=t,i=e.NamiCampaignRuleType.LABEL):n&&(a=n,i=e.NamiCampaignRuleType.URL),{type:i,value:a}}}],[{key:"allCampaigns",value:function(){if(!this.instance.sdkInitialized)throw new Wr;return bu()}},{key:"isCampaignAvailable",value:function(e){if(!this.instance.sdkInitialized)throw new Wr;var t=this.instance.campaignTypeAndLabel(e),n=t.type,i=t.value,a=Pu(i,n),r=a.campaign,o=a.paywall;return null!=r&&r.flow?new lh(r.flow.object).allScreensAvailable:Boolean(r&&o)}},{key:"isFlow",value:function(e,t){if(!this.instance.sdkInitialized)throw new Wr;var n=this.instance.campaignTypeAndLabel(e,t),i=n.type,a=n.value;return Bs(Pu(a,i).campaign)}},{key:"refresh",value:function(){return k(function(e){for(;;)switch(e.n){case 0:if(this.instance.sdkInitialized){e.n=1;break}throw new Wr;case 1:return xs(),e.n=2,a(jd.instance.fetchCampaignsAndPaywalls());case 2:return e.a(2,bu())}},null,this,null,Promise)}},{key:"registerAvailableCampaignsHandler",value:function(e){return this.instance.emitter.addListener(Hn,e),()=>{this.instance.emitter.removeListener(Hn,e)}}},{key:"launch",value:function(t,n,i,a,r){var o,s,u,l,d,c,h,f,v,p;a=null!=a?a:()=>{},i=null!=i?i:{customAttributes:{}};var g=this.instance.campaignTypeAndLabel(t,n),b=g.type,w=g.value;if(!this.instance.sdkInitialized)throw a(!1,e.LaunchCampaignError.SDK_NOT_INITIALIZED),new Wr;var k,S=Wd.firstLaunchLookup(w,()=>Pu(w,b)),E=S.paywall,P=S.campaign,T=!P||!E&&!P.flow;T&&(k=t||n?t?e.LaunchCampaignError.LABELED_CAMPAIGN_NOT_FOUND:n?e.LaunchCampaignError.URL_CAMPAIGN_NOT_FOUND:e.LaunchCampaignError.CAMPAIGN_DATA_NOT_FOUND:e.LaunchCampaignError.DEFAULT_CAMPAIGN_NOT_FOUND,a(!1,k),E={});var _={campaignId:null!==(o=null==P?void 0:P.rule)&&void 0!==o?o:"",campaignName:null!==(s=null==P?void 0:P.name)&&void 0!==s?s:"",campaignType:null!==(u=null==P?void 0:P.type)&&void 0!==u?u:"",campaignLabel:t?w:"",campaignUrl:n?w:"",paywallId:null!=P&&P.flow?void 0:(null===(l=E)||void 0===l?void 0:l.id)||"",paywallName:null!=P&&P.flow?void 0:(null===(d=E)||void 0===d?void 0:d.name)||"",segmentId:null==P?void 0:P.segment,externalSegmentId:null!==(c=null==P?void 0:P.external_segment)&&void 0!==c?c:null,action:e.NamiPaywallAction.UNKNOWN},M=Fr.getPurchaseChannel();M&&(_=m({},_,{purchaseChannel:M}));var A,D,x,C,I,L,R,F,O=null===(h=i)||void 0===h?void 0:h.productGroups,$=null===(f=E)||void 0===f||null===(f=f.sku_menus)||void 0===f?void 0:f.map(e=>e.ref);if((x=null===(A=Fr.getNamiConfig())||void 0===A?void 0:A.namiCommands,null!==(D=null==x?void 0:x.includes(fn))&&void 0!==D&&D&&null!=O&&O.length&&null!=$)&&0==(null==$?void 0:$.filter(e=>null==O?void 0:O.some(t=>t===e))).length)throw a(!1,e.LaunchCampaignError.PRODUCT_GROUPS_NOT_FOUND),new Ur;if(null!=P&&P.flow&&!Vs(null!==(v=null===(p=P.flow.object)||void 0===p?void 0:p.screens)&&void 0!==v?v:[]))throw a(!1,e.LaunchCampaignError.FLOW_SCREEN_DATA_UNAVILABLE),new Hr;T||Gd.shared.record({placementLabel:null!==(C=null!==(I=null==P?void 0:P.value)&&void 0!==I?I:w)&&void 0!==C?C:"",tags:null!==(L=null==P?void 0:P.placement_tags)&&void 0!==L?L:[],customAttributes:null!==(R=null===(F=i)||void 0===F?void 0:F.customAttributes)&&void 0!==R?R:{}});var N=we().ui.createPaywall(b,w,i),W=su();return Fr.setLaunchId(W),r&&this.instance.emitter.addListener(Vn,t=>{var n=t.action,i=y(t,ge);r(m({},_,i,{action:null!=n?n:e.NamiPaywallAction.UNKNOWN}))}),setTimeout(()=>a(!0),0),N}},{key:"getProductGroups",value:function(e,t){var n,i,a=this.instance.campaignTypeAndLabel(e,t),r=a.type,o=a.value;return null!==(n=null===(i=Pu(o,r).paywall)||void 0===i||null===(i=i.sku_menus)||void 0===i?void 0:i.map(e=>e.ref))&&void 0!==n?n:[]}},{key:"getAllProducts",value:function(e,t){var n,i,a=this.instance.campaignTypeAndLabel(e,t),r=a.type,o=a.value;return null!==(n=null===(i=Pu(o,r).paywall)||void 0===i||null===(i=i.sku_menus)||void 0===i?void 0:i.flatMap(e=>{var t,n;return null!==(t=null===(n=e.products)||void 0===n?void 0:n.map(e=>e.sku_ref_id))&&void 0!==t?t:[]}))&&void 0!==n?n:[]}},{key:"getCurrentProducts",value:function(e,t){var n,i,a=this.instance.campaignTypeAndLabel(e,t),r=a.type,o=a.value,s=Pu(o,r),u=xd.currentProvider,l=null==u?void 0:u.getCurrentGroupId();return l&&null!==(n=null===(i=s.paywall)||void 0===i||null===(i=i.sku_menus)||void 0===i?void 0:i.filter(e=>e.id===l).flatMap(e=>{var t,n;return null!==(t=null===(n=e.products)||void 0===n?void 0:n.map(e=>e.sku_ref_id))&&void 0!==t?t:[]}))&&void 0!==n?n:[]}}])}();ch.instance=new ch;var hh=ch,mh=nh,fh=function(){return c(function e(){o(this,e),this.emitter=Nu.getInstance()},[{key:"sdkInitialized",get:function(){return Vd.instance.isInitialized}}],[{key:"active",value:function(){return Cs(),Id()}},{key:"isEntitlementActive",value:function(e){return!!Cs("NamiEntitlementManager.isEntitlementActive")&&this.active().some(t=>t.referenceId==e)}},{key:"refresh",value:function(){return k(function(e){for(;;)switch(e.n){case 0:if(this.instance.sdkInitialized){e.n=1;break}throw new Wr;case 1:if(Cs("NamiEntitlementManager.refresh")){e.n=2;break}return e.a(2,[]);case 2:return e.n=3,a(Fd.instance.fetchActiveEntitlements());case 3:return e.a(2,Id())}},null,this,null,Promise)}},{key:"registerActiveEntitlementsHandler",value:function(e){if(Cs("NamiEntitlementManager.registerActiveEntitlementsHandler"))return this.instance.emitter.addListener(Xn,e),()=>{this.instance.emitter.removeListener(Xn,e)}}},{key:"clearProvisionalEntitlementGrants",value:function(){var e=Id();e=e.filter(e=>e.expires&&e.expires>(new Date).valueOf()),Fr.setNamiEntitlements(_t,e),this.instance.emitter.emit(Xn)}}])}();fh.instance=new fh;var vh,ph,gh=fh,yh=Zc,bh=Qc,wh=ul,kh={upperLeft:"border-top-left-radius",upperRight:"border-top-right-radius",lowerLeft:"border-bottom-left-radius",lowerRight:"border-bottom-right-radius"},Sh={left:"border-left-style",right:"border-right-style",top:"border-top-style",bottom:"border-bottom-style"},Eh="wave",Ph="pulse",Th="none";function _h(e){var t,n=null!==(t=e.match(/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/))&&void 0!==t?t:[],i=n[0],a=n[1],r=n[2],o=n[3],s=n[4],u=n[5];return{semver:i,major:Number.parseInt(a)||3,minor:Number.parseInt(r)||0,patch:Number.parseInt(o)||0,prerelease:s,buildmetadata:u}}function Mh(e,t){e&&(function(e,t){return e.major!==t.major?e.major>t.major?1:-1:e.minor!==t.minor?e.minor>t.minor?1:-1:e.patch!==t.patch?e.patch>t.patch?1:-1:0}(_h(Ae),e)>=0||ui.warn(`Component ${t} requires SDK version ${e.semver} or higher, but current SDK version is ${Ae}`))}function Ah(e){return!e||"object"==typeof e&&0==Object.keys(e).length}!function(e){e.DEFAULT="default",e.LABEL="label",e.URL="url"}(vh||(vh={})),function(e){e.DEEPLINK="deeplink",e.IN_APP="in_app"}(ph||(ph={}));var Dh=hh,xh=mh,Ch=bh,Ih=gh,Lh=yh,Rh=wh,Fh=Ud,Oh=Object.freeze({__proto__:null,NamiCampaignManager:Dh,NamiCustomerManager:xh,NamiEntitlementManager:Ih,NamiFlowManager:Lh,NamiPaywallManager:Ch,NamiProfileManager:Fh,NamiPurchaseManager:Rh}),$h=function(){return c(function e(){o(this,e)},[{key:"getItem",value:function(e){try{return localStorage.getItem(e)}catch(e){return null}}},{key:"setItem",value:function(e,t){try{localStorage.setItem(e,t)}catch(e){}}},{key:"removeItem",value:function(e){try{localStorage.removeItem(e)}catch(e){}}},{key:"clear",value:function(){try{localStorage.clear()}catch(e){}}},{key:"getAllKeys",value:function(){try{return Object.keys(localStorage)}catch(e){return[]}}}])}();function Nh(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Wh,jh={exports:{}};var Bh=(Wh||(Wh=1,function(e){e.exports=function(e){var t={};function n(i){if(t[i])return t[i].exports;var a=t[i]={i,l:!1,exports:{}};return e[i].call(a.exports,a,a.exports,n),a.l=!0,a.exports}return n.m=e,n.c=t,n.d=function(e,t,i){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:i})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)n.d(i,a,function(t){return e[t]}.bind(null,a));return i},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=90)}({17:function(e,t,n){t.__esModule=!0,t.default=void 0;var i=n(18),a=function(){function e(){}return e.getFirstMatch=function(e,t){var n=t.match(e);return n&&n.length>0&&n[1]||""},e.getSecondMatch=function(e,t){var n=t.match(e);return n&&n.length>1&&n[2]||""},e.matchAndReturnConst=function(e,t,n){if(e.test(t))return n},e.getWindowsVersionName=function(e){switch(e){case"NT":return"NT";case"XP":case"NT 5.1":return"XP";case"NT 5.0":return"2000";case"NT 5.2":return"2003";case"NT 6.0":return"Vista";case"NT 6.1":return"7";case"NT 6.2":return"8";case"NT 6.3":return"8.1";case"NT 10.0":return"10";default:return}},e.getMacOSVersionName=function(e){var t=e.split(".").splice(0,2).map(function(e){return parseInt(e,10)||0});t.push(0);var n=t[0],i=t[1];if(10===n)switch(i){case 5:return"Leopard";case 6:return"Snow Leopard";case 7:return"Lion";case 8:return"Mountain Lion";case 9:return"Mavericks";case 10:return"Yosemite";case 11:return"El Capitan";case 12:return"Sierra";case 13:return"High Sierra";case 14:return"Mojave";case 15:return"Catalina";default:return}switch(n){case 11:return"Big Sur";case 12:return"Monterey";case 13:return"Ventura";case 14:return"Sonoma";case 15:return"Sequoia";default:return}},e.getAndroidVersionName=function(e){var t=e.split(".").splice(0,2).map(function(e){return parseInt(e,10)||0});if(t.push(0),!(1===t[0]&&t[1]<5))return 1===t[0]&&t[1]<6?"Cupcake":1===t[0]&&t[1]>=6?"Donut":2===t[0]&&t[1]<2?"Eclair":2===t[0]&&2===t[1]?"Froyo":2===t[0]&&t[1]>2?"Gingerbread":3===t[0]?"Honeycomb":4===t[0]&&t[1]<1?"Ice Cream Sandwich":4===t[0]&&t[1]<4?"Jelly Bean":4===t[0]&&t[1]>=4?"KitKat":5===t[0]?"Lollipop":6===t[0]?"Marshmallow":7===t[0]?"Nougat":8===t[0]?"Oreo":9===t[0]?"Pie":void 0},e.getVersionPrecision=function(e){return e.split(".").length},e.compareVersions=function(t,n,i){void 0===i&&(i=!1);var a=e.getVersionPrecision(t),r=e.getVersionPrecision(n),o=Math.max(a,r),s=0,u=e.map([t,n],function(t){var n=o-e.getVersionPrecision(t),i=t+new Array(n+1).join(".0");return e.map(i.split("."),function(e){return new Array(20-e.length).join("0")+e}).reverse()});for(i&&(s=o-Math.min(a,r)),o-=1;o>=s;){if(u[0][o]>u[1][o])return 1;if(u[0][o]===u[1][o]){if(o===s)return 0;o-=1}else if(u[0][o]<u[1][o])return-1}},e.map=function(e,t){var n,i=[];if(Array.prototype.map)return Array.prototype.map.call(e,t);for(n=0;n<e.length;n+=1)i.push(t(e[n]));return i},e.find=function(e,t){var n,i;if(Array.prototype.find)return Array.prototype.find.call(e,t);for(n=0,i=e.length;n<i;n+=1){var a=e[n];if(t(a,n))return a}},e.assign=function(e){for(var t,n,i=e,a=arguments.length,r=new Array(a>1?a-1:0),o=1;o<a;o++)r[o-1]=arguments[o];if(Object.assign)return Object.assign.apply(Object,[e].concat(r));var s=function(){var e=r[t];"object"==typeof e&&null!==e&&Object.keys(e).forEach(function(t){i[t]=e[t]})};for(t=0,n=r.length;t<n;t+=1)s();return e},e.getBrowserAlias=function(e){return i.BROWSER_ALIASES_MAP[e]},e.getBrowserTypeByAlias=function(e){return i.BROWSER_MAP[e]||""},e}();t.default=a,e.exports=t.default},18:function(e,t,n){t.__esModule=!0,t.ENGINE_MAP=t.OS_MAP=t.PLATFORMS_MAP=t.BROWSER_MAP=t.BROWSER_ALIASES_MAP=void 0,t.BROWSER_ALIASES_MAP={AmazonBot:"amazonbot","Amazon Silk":"amazon_silk","Android Browser":"android",BaiduSpider:"baiduspider",Bada:"bada",BingCrawler:"bingcrawler",Brave:"brave",BlackBerry:"blackberry","ChatGPT-User":"chatgpt_user",Chrome:"chrome",ClaudeBot:"claudebot",Chromium:"chromium",Diffbot:"diffbot",DuckDuckBot:"duckduckbot",DuckDuckGo:"duckduckgo",Electron:"electron",Epiphany:"epiphany",FacebookExternalHit:"facebookexternalhit",Firefox:"firefox",Focus:"focus",Generic:"generic","Google Search":"google_search",Googlebot:"googlebot",GPTBot:"gptbot","Internet Explorer":"ie",InternetArchiveCrawler:"internetarchivecrawler","K-Meleon":"k_meleon",LibreWolf:"librewolf",Linespider:"linespider",Maxthon:"maxthon","Meta-ExternalAds":"meta_externalads","Meta-ExternalAgent":"meta_externalagent","Meta-ExternalFetcher":"meta_externalfetcher","Meta-WebIndexer":"meta_webindexer","Microsoft Edge":"edge","MZ Browser":"mz","NAVER Whale Browser":"naver","OAI-SearchBot":"oai_searchbot",Omgilibot:"omgilibot",Opera:"opera","Opera Coast":"opera_coast","Pale Moon":"pale_moon",PerplexityBot:"perplexitybot","Perplexity-User":"perplexity_user",PhantomJS:"phantomjs",PingdomBot:"pingdombot",Puffin:"puffin",QQ:"qq",QQLite:"qqlite",QupZilla:"qupzilla",Roku:"roku",Safari:"safari",Sailfish:"sailfish","Samsung Internet for Android":"samsung_internet",SlackBot:"slackbot",SeaMonkey:"seamonkey",Sleipnir:"sleipnir","Sogou Browser":"sogou",Swing:"swing",Tizen:"tizen","UC Browser":"uc",Vivaldi:"vivaldi","WebOS Browser":"webos",WeChat:"wechat",YahooSlurp:"yahooslurp","Yandex Browser":"yandex",YandexBot:"yandexbot",YouBot:"youbot"},t.BROWSER_MAP={amazonbot:"AmazonBot",amazon_silk:"Amazon Silk",android:"Android Browser",baiduspider:"BaiduSpider",bada:"Bada",bingcrawler:"BingCrawler",blackberry:"BlackBerry",brave:"Brave",chatgpt_user:"ChatGPT-User",chrome:"Chrome",claudebot:"ClaudeBot",chromium:"Chromium",diffbot:"Diffbot",duckduckbot:"DuckDuckBot",duckduckgo:"DuckDuckGo",edge:"Microsoft Edge",electron:"Electron",epiphany:"Epiphany",facebookexternalhit:"FacebookExternalHit",firefox:"Firefox",focus:"Focus",generic:"Generic",google_search:"Google Search",googlebot:"Googlebot",gptbot:"GPTBot",ie:"Internet Explorer",internetarchivecrawler:"InternetArchiveCrawler",k_meleon:"K-Meleon",librewolf:"LibreWolf",linespider:"Linespider",maxthon:"Maxthon",meta_externalads:"Meta-ExternalAds",meta_externalagent:"Meta-ExternalAgent",meta_externalfetcher:"Meta-ExternalFetcher",meta_webindexer:"Meta-WebIndexer",mz:"MZ Browser",naver:"NAVER Whale Browser",oai_searchbot:"OAI-SearchBot",omgilibot:"Omgilibot",opera:"Opera",opera_coast:"Opera Coast",pale_moon:"Pale Moon",perplexitybot:"PerplexityBot",perplexity_user:"Perplexity-User",phantomjs:"PhantomJS",pingdombot:"PingdomBot",puffin:"Puffin",qq:"QQ Browser",qqlite:"QQ Browser Lite",qupzilla:"QupZilla",roku:"Roku",safari:"Safari",sailfish:"Sailfish",samsung_internet:"Samsung Internet for Android",seamonkey:"SeaMonkey",slackbot:"SlackBot",sleipnir:"Sleipnir",sogou:"Sogou Browser",swing:"Swing",tizen:"Tizen",uc:"UC Browser",vivaldi:"Vivaldi",webos:"WebOS Browser",wechat:"WeChat",yahooslurp:"YahooSlurp",yandex:"Yandex Browser",yandexbot:"YandexBot",youbot:"YouBot"},t.PLATFORMS_MAP={bot:"bot",desktop:"desktop",mobile:"mobile",tablet:"tablet",tv:"tv"},t.OS_MAP={Android:"Android",Bada:"Bada",BlackBerry:"BlackBerry",ChromeOS:"Chrome OS",HarmonyOS:"HarmonyOS",iOS:"iOS",Linux:"Linux",MacOS:"macOS",PlayStation4:"PlayStation 4",Roku:"Roku",Tizen:"Tizen",WebOS:"WebOS",Windows:"Windows",WindowsPhone:"Windows Phone"},t.ENGINE_MAP={Blink:"Blink",EdgeHTML:"EdgeHTML",Gecko:"Gecko",Presto:"Presto",Trident:"Trident",WebKit:"WebKit"}},90:function(e,t,n){t.__esModule=!0,t.default=void 0;var i,a=(i=n(91))&&i.__esModule?i:{default:i},r=n(18);function o(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var s=function(){function e(){}var t,n,i;return e.getParser=function(e,t,n){if(void 0===t&&(t=!1),void 0===n&&(n=null),"string"!=typeof e)throw new Error("UserAgent should be a string");return new a.default(e,t,n)},e.parse=function(e,t){return void 0===t&&(t=null),new a.default(e,t).getResult()},t=e,i=[{key:"BROWSER_MAP",get:function(){return r.BROWSER_MAP}},{key:"ENGINE_MAP",get:function(){return r.ENGINE_MAP}},{key:"OS_MAP",get:function(){return r.OS_MAP}},{key:"PLATFORMS_MAP",get:function(){return r.PLATFORMS_MAP}}],(n=null)&&o(t.prototype,n),i&&o(t,i),e}();t.default=s,e.exports=t.default},91:function(e,t,n){t.__esModule=!0,t.default=void 0;var i=u(n(92)),a=u(n(93)),r=u(n(94)),o=u(n(95)),s=u(n(17));function u(e){return e&&e.__esModule?e:{default:e}}var l=function(){function e(e,t,n){if(void 0===t&&(t=!1),void 0===n&&(n=null),null==e||""===e)throw new Error("UserAgent parameter can't be empty");this._ua=e;var i=!1;"boolean"==typeof t?(i=t,this._hints=n):this._hints=null!=t&&"object"==typeof t?t:null,this.parsedResult={},!0!==i&&this.parse()}var t=e.prototype;return t.getHints=function(){return this._hints},t.hasBrand=function(e){if(!this._hints||!Array.isArray(this._hints.brands))return!1;var t=e.toLowerCase();return this._hints.brands.some(function(e){return e.brand&&e.brand.toLowerCase()===t})},t.getBrandVersion=function(e){if(this._hints&&Array.isArray(this._hints.brands)){var t=e.toLowerCase(),n=this._hints.brands.find(function(e){return e.brand&&e.brand.toLowerCase()===t});return n?n.version:void 0}},t.getUA=function(){return this._ua},t.test=function(e){return e.test(this._ua)},t.parseBrowser=function(){var e=this;this.parsedResult.browser={};var t=s.default.find(i.default,function(t){if("function"==typeof t.test)return t.test(e);if(Array.isArray(t.test))return t.test.some(function(t){return e.test(t)});throw new Error("Browser's test function is not valid")});return t&&(this.parsedResult.browser=t.describe(this.getUA(),this)),this.parsedResult.browser},t.getBrowser=function(){return this.parsedResult.browser?this.parsedResult.browser:this.parseBrowser()},t.getBrowserName=function(e){return e?String(this.getBrowser().name).toLowerCase()||"":this.getBrowser().name||""},t.getBrowserVersion=function(){return this.getBrowser().version},t.getOS=function(){return this.parsedResult.os?this.parsedResult.os:this.parseOS()},t.parseOS=function(){var e=this;this.parsedResult.os={};var t=s.default.find(a.default,function(t){if("function"==typeof t.test)return t.test(e);if(Array.isArray(t.test))return t.test.some(function(t){return e.test(t)});throw new Error("Browser's test function is not valid")});return t&&(this.parsedResult.os=t.describe(this.getUA())),this.parsedResult.os},t.getOSName=function(e){var t=this.getOS().name;return e?String(t).toLowerCase()||"":t||""},t.getOSVersion=function(){return this.getOS().version},t.getPlatform=function(){return this.parsedResult.platform?this.parsedResult.platform:this.parsePlatform()},t.getPlatformType=function(e){void 0===e&&(e=!1);var t=this.getPlatform().type;return e?String(t).toLowerCase()||"":t||""},t.parsePlatform=function(){var e=this;this.parsedResult.platform={};var t=s.default.find(r.default,function(t){if("function"==typeof t.test)return t.test(e);if(Array.isArray(t.test))return t.test.some(function(t){return e.test(t)});throw new Error("Browser's test function is not valid")});return t&&(this.parsedResult.platform=t.describe(this.getUA())),this.parsedResult.platform},t.getEngine=function(){return this.parsedResult.engine?this.parsedResult.engine:this.parseEngine()},t.getEngineName=function(e){return e?String(this.getEngine().name).toLowerCase()||"":this.getEngine().name||""},t.parseEngine=function(){var e=this;this.parsedResult.engine={};var t=s.default.find(o.default,function(t){if("function"==typeof t.test)return t.test(e);if(Array.isArray(t.test))return t.test.some(function(t){return e.test(t)});throw new Error("Browser's test function is not valid")});return t&&(this.parsedResult.engine=t.describe(this.getUA())),this.parsedResult.engine},t.parse=function(){return this.parseBrowser(),this.parseOS(),this.parsePlatform(),this.parseEngine(),this},t.getResult=function(){return s.default.assign({},this.parsedResult)},t.satisfies=function(e){var t=this,n={},i=0,a={},r=0;if(Object.keys(e).forEach(function(t){var o=e[t];"string"==typeof o?(a[t]=o,r+=1):"object"==typeof o&&(n[t]=o,i+=1)}),i>0){var o=Object.keys(n),u=s.default.find(o,function(e){return t.isOS(e)});if(u){var l=this.satisfies(n[u]);if(void 0!==l)return l}var d=s.default.find(o,function(e){return t.isPlatform(e)});if(d){var c=this.satisfies(n[d]);if(void 0!==c)return c}}if(r>0){var h=Object.keys(a),m=s.default.find(h,function(e){return t.isBrowser(e,!0)});if(void 0!==m)return this.compareVersion(a[m])}},t.isBrowser=function(e,t){void 0===t&&(t=!1);var n=this.getBrowserName().toLowerCase(),i=e.toLowerCase(),a=s.default.getBrowserTypeByAlias(i);return t&&a&&(i=a.toLowerCase()),i===n},t.compareVersion=function(e){var t=[0],n=e,i=!1,a=this.getBrowserVersion();if("string"==typeof a)return">"===e[0]||"<"===e[0]?(n=e.substr(1),"="===e[1]?(i=!0,n=e.substr(2)):t=[],">"===e[0]?t.push(1):t.push(-1)):"="===e[0]?n=e.substr(1):"~"===e[0]&&(i=!0,n=e.substr(1)),t.indexOf(s.default.compareVersions(a,n,i))>-1},t.isOS=function(e){return this.getOSName(!0)===String(e).toLowerCase()},t.isPlatform=function(e){return this.getPlatformType(!0)===String(e).toLowerCase()},t.isEngine=function(e){return this.getEngineName(!0)===String(e).toLowerCase()},t.is=function(e,t){return void 0===t&&(t=!1),this.isBrowser(e,t)||this.isOS(e)||this.isPlatform(e)},t.some=function(e){var t=this;return void 0===e&&(e=[]),e.some(function(e){return t.is(e)})},e}();t.default=l,e.exports=t.default},92:function(e,t,n){t.__esModule=!0,t.default=void 0;var i,a=(i=n(17))&&i.__esModule?i:{default:i},r=/version\/(\d+(\.?_?\d+)+)/i,o=[{test:[/gptbot/i],describe:function(e){var t={name:"GPTBot"},n=a.default.getFirstMatch(/gptbot\/(\d+(\.\d+)+)/i,e)||a.default.getFirstMatch(r,e);return n&&(t.version=n),t}},{test:[/chatgpt-user/i],describe:function(e){var t={name:"ChatGPT-User"},n=a.default.getFirstMatch(/chatgpt-user\/(\d+(\.\d+)+)/i,e)||a.default.getFirstMatch(r,e);return n&&(t.version=n),t}},{test:[/oai-searchbot/i],describe:function(e){var t={name:"OAI-SearchBot"},n=a.default.getFirstMatch(/oai-searchbot\/(\d+(\.\d+)+)/i,e)||a.default.getFirstMatch(r,e);return n&&(t.version=n),t}},{test:[/claudebot/i,/claude-web/i,/claude-user/i,/claude-searchbot/i],describe:function(e){var t={name:"ClaudeBot"},n=a.default.getFirstMatch(/(?:claudebot|claude-web|claude-user|claude-searchbot)\/(\d+(\.\d+)+)/i,e)||a.default.getFirstMatch(r,e);return n&&(t.version=n),t}},{test:[/omgilibot/i,/webzio-extended/i],describe:function(e){var t={name:"Omgilibot"},n=a.default.getFirstMatch(/(?:omgilibot|webzio-extended)\/(\d+(\.\d+)+)/i,e)||a.default.getFirstMatch(r,e);return n&&(t.version=n),t}},{test:[/diffbot/i],describe:function(e){var t={name:"Diffbot"},n=a.default.getFirstMatch(/diffbot\/(\d+(\.\d+)+)/i,e)||a.default.getFirstMatch(r,e);return n&&(t.version=n),t}},{test:[/perplexitybot/i],describe:function(e){var t={name:"PerplexityBot"},n=a.default.getFirstMatch(/perplexitybot\/(\d+(\.\d+)+)/i,e)||a.default.getFirstMatch(r,e);return n&&(t.version=n),t}},{test:[/perplexity-user/i],describe:function(e){var t={name:"Perplexity-User"},n=a.default.getFirstMatch(/perplexity-user\/(\d+(\.\d+)+)/i,e)||a.default.getFirstMatch(r,e);return n&&(t.version=n),t}},{test:[/youbot/i],describe:function(e){var t={name:"YouBot"},n=a.default.getFirstMatch(/youbot\/(\d+(\.\d+)+)/i,e)||a.default.getFirstMatch(r,e);return n&&(t.version=n),t}},{test:[/meta-webindexer/i],describe:function(e){var t={name:"Meta-WebIndexer"},n=a.default.getFirstMatch(/meta-webindexer\/(\d+(\.\d+)+)/i,e)||a.default.getFirstMatch(r,e);return n&&(t.version=n),t}},{test:[/meta-externalads/i],describe:function(e){var t={name:"Meta-ExternalAds"},n=a.default.getFirstMatch(/meta-externalads\/(\d+(\.\d+)+)/i,e)||a.default.getFirstMatch(r,e);return n&&(t.version=n),t}},{test:[/meta-externalagent/i],describe:function(e){var t={name:"Meta-ExternalAgent"},n=a.default.getFirstMatch(/meta-externalagent\/(\d+(\.\d+)+)/i,e)||a.default.getFirstMatch(r,e);return n&&(t.version=n),t}},{test:[/meta-externalfetcher/i],describe:function(e){var t={name:"Meta-ExternalFetcher"},n=a.default.getFirstMatch(/meta-externalfetcher\/(\d+(\.\d+)+)/i,e)||a.default.getFirstMatch(r,e);return n&&(t.version=n),t}},{test:[/googlebot/i],describe:function(e){var t={name:"Googlebot"},n=a.default.getFirstMatch(/googlebot\/(\d+(\.\d+))/i,e)||a.default.getFirstMatch(r,e);return n&&(t.version=n),t}},{test:[/linespider/i],describe:function(e){var t={name:"Linespider"},n=a.default.getFirstMatch(/(?:linespider)(?:-[-\w]+)?[\s/](\d+(\.\d+)+)/i,e)||a.default.getFirstMatch(r,e);return n&&(t.version=n),t}},{test:[/amazonbot/i],describe:function(e){var t={name:"AmazonBot"},n=a.default.getFirstMatch(/amazonbot\/(\d+(\.\d+)+)/i,e)||a.default.getFirstMatch(r,e);return n&&(t.version=n),t}},{test:[/bingbot/i],describe:function(e){var t={name:"BingCrawler"},n=a.default.getFirstMatch(/bingbot\/(\d+(\.\d+)+)/i,e)||a.default.getFirstMatch(r,e);return n&&(t.version=n),t}},{test:[/baiduspider/i],describe:function(e){var t={name:"BaiduSpider"},n=a.default.getFirstMatch(/baiduspider\/(\d+(\.\d+)+)/i,e)||a.default.getFirstMatch(r,e);return n&&(t.version=n),t}},{test:[/duckduckbot/i],describe:function(e){var t={name:"DuckDuckBot"},n=a.default.getFirstMatch(/duckduckbot\/(\d+(\.\d+)+)/i,e)||a.default.getFirstMatch(r,e);return n&&(t.version=n),t}},{test:[/ia_archiver/i],describe:function(e){var t={name:"InternetArchiveCrawler"},n=a.default.getFirstMatch(/ia_archiver\/(\d+(\.\d+)+)/i,e)||a.default.getFirstMatch(r,e);return n&&(t.version=n),t}},{test:[/facebookexternalhit/i,/facebookcatalog/i],describe:function(){return{name:"FacebookExternalHit"}}},{test:[/slackbot/i,/slack-imgProxy/i],describe:function(e){var t={name:"SlackBot"},n=a.default.getFirstMatch(/(?:slackbot|slack-imgproxy)(?:-[-\w]+)?[\s/](\d+(\.\d+)+)/i,e)||a.default.getFirstMatch(r,e);return n&&(t.version=n),t}},{test:[/yahoo!?[\s/]*slurp/i],describe:function(){return{name:"YahooSlurp"}}},{test:[/yandexbot/i,/yandexmobilebot/i],describe:function(){return{name:"YandexBot"}}},{test:[/pingdom/i],describe:function(){return{name:"PingdomBot"}}},{test:[/opera/i],describe:function(e){var t={name:"Opera"},n=a.default.getFirstMatch(r,e)||a.default.getFirstMatch(/(?:opera)[\s/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/opr\/|opios/i],describe:function(e){var t={name:"Opera"},n=a.default.getFirstMatch(/(?:opr|opios)[\s/](\S+)/i,e)||a.default.getFirstMatch(r,e);return n&&(t.version=n),t}},{test:[/SamsungBrowser/i],describe:function(e){var t={name:"Samsung Internet for Android"},n=a.default.getFirstMatch(r,e)||a.default.getFirstMatch(/(?:SamsungBrowser)[\s/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/Whale/i],describe:function(e){var t={name:"NAVER Whale Browser"},n=a.default.getFirstMatch(r,e)||a.default.getFirstMatch(/(?:whale)[\s/](\d+(?:\.\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/PaleMoon/i],describe:function(e){var t={name:"Pale Moon"},n=a.default.getFirstMatch(r,e)||a.default.getFirstMatch(/(?:PaleMoon)[\s/](\d+(?:\.\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/MZBrowser/i],describe:function(e){var t={name:"MZ Browser"},n=a.default.getFirstMatch(/(?:MZBrowser)[\s/](\d+(?:\.\d+)+)/i,e)||a.default.getFirstMatch(r,e);return n&&(t.version=n),t}},{test:[/focus/i],describe:function(e){var t={name:"Focus"},n=a.default.getFirstMatch(/(?:focus)[\s/](\d+(?:\.\d+)+)/i,e)||a.default.getFirstMatch(r,e);return n&&(t.version=n),t}},{test:[/swing/i],describe:function(e){var t={name:"Swing"},n=a.default.getFirstMatch(/(?:swing)[\s/](\d+(?:\.\d+)+)/i,e)||a.default.getFirstMatch(r,e);return n&&(t.version=n),t}},{test:[/coast/i],describe:function(e){var t={name:"Opera Coast"},n=a.default.getFirstMatch(r,e)||a.default.getFirstMatch(/(?:coast)[\s/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/opt\/\d+(?:.?_?\d+)+/i],describe:function(e){var t={name:"Opera Touch"},n=a.default.getFirstMatch(/(?:opt)[\s/](\d+(\.?_?\d+)+)/i,e)||a.default.getFirstMatch(r,e);return n&&(t.version=n),t}},{test:[/yabrowser/i],describe:function(e){var t={name:"Yandex Browser"},n=a.default.getFirstMatch(/(?:yabrowser)[\s/](\d+(\.?_?\d+)+)/i,e)||a.default.getFirstMatch(r,e);return n&&(t.version=n),t}},{test:[/ucbrowser/i],describe:function(e){var t={name:"UC Browser"},n=a.default.getFirstMatch(r,e)||a.default.getFirstMatch(/(?:ucbrowser)[\s/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/Maxthon|mxios/i],describe:function(e){var t={name:"Maxthon"},n=a.default.getFirstMatch(r,e)||a.default.getFirstMatch(/(?:Maxthon|mxios)[\s/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/epiphany/i],describe:function(e){var t={name:"Epiphany"},n=a.default.getFirstMatch(r,e)||a.default.getFirstMatch(/(?:epiphany)[\s/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/puffin/i],describe:function(e){var t={name:"Puffin"},n=a.default.getFirstMatch(r,e)||a.default.getFirstMatch(/(?:puffin)[\s/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/sleipnir/i],describe:function(e){var t={name:"Sleipnir"},n=a.default.getFirstMatch(r,e)||a.default.getFirstMatch(/(?:sleipnir)[\s/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/k-meleon/i],describe:function(e){var t={name:"K-Meleon"},n=a.default.getFirstMatch(r,e)||a.default.getFirstMatch(/(?:k-meleon)[\s/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/micromessenger/i],describe:function(e){var t={name:"WeChat"},n=a.default.getFirstMatch(/(?:micromessenger)[\s/](\d+(\.?_?\d+)+)/i,e)||a.default.getFirstMatch(r,e);return n&&(t.version=n),t}},{test:[/qqbrowser/i],describe:function(e){var t={name:/qqbrowserlite/i.test(e)?"QQ Browser Lite":"QQ Browser"},n=a.default.getFirstMatch(/(?:qqbrowserlite|qqbrowser)[/](\d+(\.?_?\d+)+)/i,e)||a.default.getFirstMatch(r,e);return n&&(t.version=n),t}},{test:[/msie|trident/i],describe:function(e){var t={name:"Internet Explorer"},n=a.default.getFirstMatch(/(?:msie |rv:)(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/\sedg\//i],describe:function(e){var t={name:"Microsoft Edge"},n=a.default.getFirstMatch(/\sedg\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/edg([ea]|ios)/i],describe:function(e){var t={name:"Microsoft Edge"},n=a.default.getSecondMatch(/edg([ea]|ios)\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/vivaldi/i],describe:function(e){var t={name:"Vivaldi"},n=a.default.getFirstMatch(/vivaldi\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/seamonkey/i],describe:function(e){var t={name:"SeaMonkey"},n=a.default.getFirstMatch(/seamonkey\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/sailfish/i],describe:function(e){var t={name:"Sailfish"},n=a.default.getFirstMatch(/sailfish\s?browser\/(\d+(\.\d+)?)/i,e);return n&&(t.version=n),t}},{test:[/silk/i],describe:function(e){var t={name:"Amazon Silk"},n=a.default.getFirstMatch(/silk\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/phantom/i],describe:function(e){var t={name:"PhantomJS"},n=a.default.getFirstMatch(/phantomjs\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/slimerjs/i],describe:function(e){var t={name:"SlimerJS"},n=a.default.getFirstMatch(/slimerjs\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/blackberry|\bbb\d+/i,/rim\stablet/i],describe:function(e){var t={name:"BlackBerry"},n=a.default.getFirstMatch(r,e)||a.default.getFirstMatch(/blackberry[\d]+\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/(web|hpw)[o0]s/i],describe:function(e){var t={name:"WebOS Browser"},n=a.default.getFirstMatch(r,e)||a.default.getFirstMatch(/w(?:eb)?[o0]sbrowser\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/bada/i],describe:function(e){var t={name:"Bada"},n=a.default.getFirstMatch(/dolfin\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/tizen/i],describe:function(e){var t={name:"Tizen"},n=a.default.getFirstMatch(/(?:tizen\s?)?browser\/(\d+(\.?_?\d+)+)/i,e)||a.default.getFirstMatch(r,e);return n&&(t.version=n),t}},{test:[/qupzilla/i],describe:function(e){var t={name:"QupZilla"},n=a.default.getFirstMatch(/(?:qupzilla)[\s/](\d+(\.?_?\d+)+)/i,e)||a.default.getFirstMatch(r,e);return n&&(t.version=n),t}},{test:[/librewolf/i],describe:function(e){var t={name:"LibreWolf"},n=a.default.getFirstMatch(/(?:librewolf)[\s/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/firefox|iceweasel|fxios/i],describe:function(e){var t={name:"Firefox"},n=a.default.getFirstMatch(/(?:firefox|iceweasel|fxios)[\s/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/electron/i],describe:function(e){var t={name:"Electron"},n=a.default.getFirstMatch(/(?:electron)\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/sogoumobilebrowser/i,/metasr/i,/se 2\.[x]/i],describe:function(e){var t={name:"Sogou Browser"},n=a.default.getFirstMatch(/(?:sogoumobilebrowser)[\s/](\d+(\.?_?\d+)+)/i,e),i=a.default.getFirstMatch(/(?:chrome|crios|crmo)\/(\d+(\.?_?\d+)+)/i,e),r=a.default.getFirstMatch(/se ([\d.]+)x/i,e),o=n||i||r;return o&&(t.version=o),t}},{test:[/MiuiBrowser/i],describe:function(e){var t={name:"Miui"},n=a.default.getFirstMatch(/(?:MiuiBrowser)[\s/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:function(e){return!!e.hasBrand("DuckDuckGo")||e.test(/\sDdg\/[\d.]+$/i)},describe:function(e,t){var n={name:"DuckDuckGo"};if(t){var i=t.getBrandVersion("DuckDuckGo");if(i)return n.version=i,n}var r=a.default.getFirstMatch(/\sDdg\/([\d.]+)$/i,e);return r&&(n.version=r),n}},{test:function(e){return e.hasBrand("Brave")},describe:function(e,t){var n={name:"Brave"};if(t){var i=t.getBrandVersion("Brave");if(i)return n.version=i,n}return n}},{test:[/chromium/i],describe:function(e){var t={name:"Chromium"},n=a.default.getFirstMatch(/(?:chromium)[\s/](\d+(\.?_?\d+)+)/i,e)||a.default.getFirstMatch(r,e);return n&&(t.version=n),t}},{test:[/chrome|crios|crmo/i],describe:function(e){var t={name:"Chrome"},n=a.default.getFirstMatch(/(?:chrome|crios|crmo)\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/GSA/i],describe:function(e){var t={name:"Google Search"},n=a.default.getFirstMatch(/(?:GSA)\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:function(e){var t=!e.test(/like android/i),n=e.test(/android/i);return t&&n},describe:function(e){var t={name:"Android Browser"},n=a.default.getFirstMatch(r,e);return n&&(t.version=n),t}},{test:[/playstation 4/i],describe:function(e){var t={name:"PlayStation 4"},n=a.default.getFirstMatch(r,e);return n&&(t.version=n),t}},{test:[/safari|applewebkit/i],describe:function(e){var t={name:"Safari"},n=a.default.getFirstMatch(r,e);return n&&(t.version=n),t}},{test:[/.*/i],describe:function(e){var t=-1!==e.search("\\(")?/^(.*)\/(.*)[ \t]\((.*)/:/^(.*)\/(.*) /;return{name:a.default.getFirstMatch(t,e),version:a.default.getSecondMatch(t,e)}}}];t.default=o,e.exports=t.default},93:function(e,t,n){t.__esModule=!0,t.default=void 0;var i,a=(i=n(17))&&i.__esModule?i:{default:i},r=n(18),o=[{test:[/Roku\/DVP/],describe:function(e){var t=a.default.getFirstMatch(/Roku\/DVP-(\d+\.\d+)/i,e);return{name:r.OS_MAP.Roku,version:t}}},{test:[/windows phone/i],describe:function(e){var t=a.default.getFirstMatch(/windows phone (?:os)?\s?(\d+(\.\d+)*)/i,e);return{name:r.OS_MAP.WindowsPhone,version:t}}},{test:[/windows /i],describe:function(e){var t=a.default.getFirstMatch(/Windows ((NT|XP)( \d\d?.\d)?)/i,e),n=a.default.getWindowsVersionName(t);return{name:r.OS_MAP.Windows,version:t,versionName:n}}},{test:[/Macintosh(.*?) FxiOS(.*?)\//],describe:function(e){var t={name:r.OS_MAP.iOS},n=a.default.getSecondMatch(/(Version\/)(\d[\d.]+)/,e);return n&&(t.version=n),t}},{test:[/macintosh/i],describe:function(e){var t=a.default.getFirstMatch(/mac os x (\d+(\.?_?\d+)+)/i,e).replace(/[_\s]/g,"."),n=a.default.getMacOSVersionName(t),i={name:r.OS_MAP.MacOS,version:t};return n&&(i.versionName=n),i}},{test:[/(ipod|iphone|ipad)/i],describe:function(e){var t=a.default.getFirstMatch(/os (\d+([_\s]\d+)*) like mac os x/i,e).replace(/[_\s]/g,".");return{name:r.OS_MAP.iOS,version:t}}},{test:[/OpenHarmony/i],describe:function(e){var t=a.default.getFirstMatch(/OpenHarmony\s+(\d+(\.\d+)*)/i,e);return{name:r.OS_MAP.HarmonyOS,version:t}}},{test:function(e){var t=!e.test(/like android/i),n=e.test(/android/i);return t&&n},describe:function(e){var t=a.default.getFirstMatch(/android[\s/-](\d+(\.\d+)*)/i,e),n=a.default.getAndroidVersionName(t),i={name:r.OS_MAP.Android,version:t};return n&&(i.versionName=n),i}},{test:[/(web|hpw)[o0]s/i],describe:function(e){var t=a.default.getFirstMatch(/(?:web|hpw)[o0]s\/(\d+(\.\d+)*)/i,e),n={name:r.OS_MAP.WebOS};return t&&t.length&&(n.version=t),n}},{test:[/blackberry|\bbb\d+/i,/rim\stablet/i],describe:function(e){var t=a.default.getFirstMatch(/rim\stablet\sos\s(\d+(\.\d+)*)/i,e)||a.default.getFirstMatch(/blackberry\d+\/(\d+([_\s]\d+)*)/i,e)||a.default.getFirstMatch(/\bbb(\d+)/i,e);return{name:r.OS_MAP.BlackBerry,version:t}}},{test:[/bada/i],describe:function(e){var t=a.default.getFirstMatch(/bada\/(\d+(\.\d+)*)/i,e);return{name:r.OS_MAP.Bada,version:t}}},{test:[/tizen/i],describe:function(e){var t=a.default.getFirstMatch(/tizen[/\s](\d+(\.\d+)*)/i,e);return{name:r.OS_MAP.Tizen,version:t}}},{test:[/linux/i],describe:function(){return{name:r.OS_MAP.Linux}}},{test:[/CrOS/],describe:function(){return{name:r.OS_MAP.ChromeOS}}},{test:[/PlayStation 4/],describe:function(e){var t=a.default.getFirstMatch(/PlayStation 4[/\s](\d+(\.\d+)*)/i,e);return{name:r.OS_MAP.PlayStation4,version:t}}}];t.default=o,e.exports=t.default},94:function(e,t,n){t.__esModule=!0,t.default=void 0;var i,a=(i=n(17))&&i.__esModule?i:{default:i},r=n(18),o=[{test:[/googlebot/i],describe:function(){return{type:r.PLATFORMS_MAP.bot,vendor:"Google"}}},{test:[/linespider/i],describe:function(){return{type:r.PLATFORMS_MAP.bot,vendor:"Line"}}},{test:[/amazonbot/i],describe:function(){return{type:r.PLATFORMS_MAP.bot,vendor:"Amazon"}}},{test:[/gptbot/i],describe:function(){return{type:r.PLATFORMS_MAP.bot,vendor:"OpenAI"}}},{test:[/chatgpt-user/i],describe:function(){return{type:r.PLATFORMS_MAP.bot,vendor:"OpenAI"}}},{test:[/oai-searchbot/i],describe:function(){return{type:r.PLATFORMS_MAP.bot,vendor:"OpenAI"}}},{test:[/baiduspider/i],describe:function(){return{type:r.PLATFORMS_MAP.bot,vendor:"Baidu"}}},{test:[/bingbot/i],describe:function(){return{type:r.PLATFORMS_MAP.bot,vendor:"Bing"}}},{test:[/duckduckbot/i],describe:function(){return{type:r.PLATFORMS_MAP.bot,vendor:"DuckDuckGo"}}},{test:[/claudebot/i,/claude-web/i,/claude-user/i,/claude-searchbot/i],describe:function(){return{type:r.PLATFORMS_MAP.bot,vendor:"Anthropic"}}},{test:[/omgilibot/i,/webzio-extended/i],describe:function(){return{type:r.PLATFORMS_MAP.bot,vendor:"Webz.io"}}},{test:[/diffbot/i],describe:function(){return{type:r.PLATFORMS_MAP.bot,vendor:"Diffbot"}}},{test:[/perplexitybot/i],describe:function(){return{type:r.PLATFORMS_MAP.bot,vendor:"Perplexity AI"}}},{test:[/perplexity-user/i],describe:function(){return{type:r.PLATFORMS_MAP.bot,vendor:"Perplexity AI"}}},{test:[/youbot/i],describe:function(){return{type:r.PLATFORMS_MAP.bot,vendor:"You.com"}}},{test:[/ia_archiver/i],describe:function(){return{type:r.PLATFORMS_MAP.bot,vendor:"Internet Archive"}}},{test:[/meta-webindexer/i],describe:function(){return{type:r.PLATFORMS_MAP.bot,vendor:"Meta"}}},{test:[/meta-externalads/i],describe:function(){return{type:r.PLATFORMS_MAP.bot,vendor:"Meta"}}},{test:[/meta-externalagent/i],describe:function(){return{type:r.PLATFORMS_MAP.bot,vendor:"Meta"}}},{test:[/meta-externalfetcher/i],describe:function(){return{type:r.PLATFORMS_MAP.bot,vendor:"Meta"}}},{test:[/facebookexternalhit/i,/facebookcatalog/i],describe:function(){return{type:r.PLATFORMS_MAP.bot,vendor:"Meta"}}},{test:[/slackbot/i,/slack-imgProxy/i],describe:function(){return{type:r.PLATFORMS_MAP.bot,vendor:"Slack"}}},{test:[/yahoo/i],describe:function(){return{type:r.PLATFORMS_MAP.bot,vendor:"Yahoo"}}},{test:[/yandexbot/i,/yandexmobilebot/i],describe:function(){return{type:r.PLATFORMS_MAP.bot,vendor:"Yandex"}}},{test:[/pingdom/i],describe:function(){return{type:r.PLATFORMS_MAP.bot,vendor:"Pingdom"}}},{test:[/huawei/i],describe:function(e){var t=a.default.getFirstMatch(/(can-l01)/i,e)&&"Nova",n={type:r.PLATFORMS_MAP.mobile,vendor:"Huawei"};return t&&(n.model=t),n}},{test:[/nexus\s*(?:7|8|9|10).*/i],describe:function(){return{type:r.PLATFORMS_MAP.tablet,vendor:"Nexus"}}},{test:[/ipad/i],describe:function(){return{type:r.PLATFORMS_MAP.tablet,vendor:"Apple",model:"iPad"}}},{test:[/Macintosh(.*?) FxiOS(.*?)\//],describe:function(){return{type:r.PLATFORMS_MAP.tablet,vendor:"Apple",model:"iPad"}}},{test:[/kftt build/i],describe:function(){return{type:r.PLATFORMS_MAP.tablet,vendor:"Amazon",model:"Kindle Fire HD 7"}}},{test:[/silk/i],describe:function(){return{type:r.PLATFORMS_MAP.tablet,vendor:"Amazon"}}},{test:[/tablet(?! pc)/i],describe:function(){return{type:r.PLATFORMS_MAP.tablet}}},{test:function(e){var t=e.test(/ipod|iphone/i),n=e.test(/like (ipod|iphone)/i);return t&&!n},describe:function(e){var t=a.default.getFirstMatch(/(ipod|iphone)/i,e);return{type:r.PLATFORMS_MAP.mobile,vendor:"Apple",model:t}}},{test:[/nexus\s*[0-6].*/i,/galaxy nexus/i],describe:function(){return{type:r.PLATFORMS_MAP.mobile,vendor:"Nexus"}}},{test:[/Nokia/i],describe:function(e){var t=a.default.getFirstMatch(/Nokia\s+([0-9]+(\.[0-9]+)?)/i,e),n={type:r.PLATFORMS_MAP.mobile,vendor:"Nokia"};return t&&(n.model=t),n}},{test:[/[^-]mobi/i],describe:function(){return{type:r.PLATFORMS_MAP.mobile}}},{test:function(e){return"blackberry"===e.getBrowserName(!0)},describe:function(){return{type:r.PLATFORMS_MAP.mobile,vendor:"BlackBerry"}}},{test:function(e){return"bada"===e.getBrowserName(!0)},describe:function(){return{type:r.PLATFORMS_MAP.mobile}}},{test:function(e){return"windows phone"===e.getBrowserName()},describe:function(){return{type:r.PLATFORMS_MAP.mobile,vendor:"Microsoft"}}},{test:function(e){var t=Number(String(e.getOSVersion()).split(".")[0]);return"android"===e.getOSName(!0)&&t>=3},describe:function(){return{type:r.PLATFORMS_MAP.tablet}}},{test:function(e){return"android"===e.getOSName(!0)},describe:function(){return{type:r.PLATFORMS_MAP.mobile}}},{test:[/smart-?tv|smarttv/i],describe:function(){return{type:r.PLATFORMS_MAP.tv}}},{test:[/netcast/i],describe:function(){return{type:r.PLATFORMS_MAP.tv}}},{test:function(e){return"macos"===e.getOSName(!0)},describe:function(){return{type:r.PLATFORMS_MAP.desktop,vendor:"Apple"}}},{test:function(e){return"windows"===e.getOSName(!0)},describe:function(){return{type:r.PLATFORMS_MAP.desktop}}},{test:function(e){return"linux"===e.getOSName(!0)},describe:function(){return{type:r.PLATFORMS_MAP.desktop}}},{test:function(e){return"playstation 4"===e.getOSName(!0)},describe:function(){return{type:r.PLATFORMS_MAP.tv}}},{test:function(e){return"roku"===e.getOSName(!0)},describe:function(){return{type:r.PLATFORMS_MAP.tv}}}];t.default=o,e.exports=t.default},95:function(e,t,n){t.__esModule=!0,t.default=void 0;var i,a=(i=n(17))&&i.__esModule?i:{default:i},r=n(18),o=[{test:function(e){return"microsoft edge"===e.getBrowserName(!0)},describe:function(e){if(/\sedg\//i.test(e))return{name:r.ENGINE_MAP.Blink};var t=a.default.getFirstMatch(/edge\/(\d+(\.?_?\d+)+)/i,e);return{name:r.ENGINE_MAP.EdgeHTML,version:t}}},{test:[/trident/i],describe:function(e){var t={name:r.ENGINE_MAP.Trident},n=a.default.getFirstMatch(/trident\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:function(e){return e.test(/presto/i)},describe:function(e){var t={name:r.ENGINE_MAP.Presto},n=a.default.getFirstMatch(/presto\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:function(e){var t=e.test(/gecko/i),n=e.test(/like gecko/i);return t&&!n},describe:function(e){var t={name:r.ENGINE_MAP.Gecko},n=a.default.getFirstMatch(/gecko\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/(apple)?webkit\/537\.36/i],describe:function(){return{name:r.ENGINE_MAP.Blink}}},{test:[/(apple)?webkit/i],describe:function(e){var t={name:r.ENGINE_MAP.WebKit},n=a.default.getFirstMatch(/webkit\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}}];t.default=o,e.exports=t.default}})}(jh)),jh.exports),zh=Nh(Bh),Uh={tablet:"tablet",mobile:"phone",tv:"television",desktop:"desktop"},Hh={"1280x720":.67,"1920x1080":1,"3840x2160":2,"7680x4320":4},Gh=function(){return c(function e(){o(this,e)},[{key:"getDeviceData",value:function(e){if("undefined"==typeof window)return{os_version:"X.X.X",os_name:"Server",browser_name:"Unknown",browser_version:"X.X.X",sdk_client:"web",sdk_version:Ae,language:"en"};var t=zh.getParser(window.navigator.userAgent),n=t.getPlatform(),i={os_version:t.getOSVersion(),os_name:t.getOSName(),browser_name:t.getBrowserName(),browser_version:t.getBrowserVersion(),sdk_client:"web",sdk_version:Ae,language:window.navigator.language};if(n.type&&(i.form_factor=Uh[n.type]),n.model&&(i.device_model=n.model),e&&e.length>0){var a=(e=>{var t=e.find(e=>e.includes(dn)),n={platform:"",version:""};if(t){var i=t.split(hn);n.platform=i[1],n.version=i[2]}return n})(e);i.extended_platform=a.platform,i.extended_platform_version=a.version}return i}},{key:"getDeviceFormFactor",value:function(){if("undefined"==typeof window)return"desktop";var e=zh.getParser(window.navigator.userAgent).getPlatform();return e.type&&Uh[e.type]||"desktop"}},{key:"getDeviceScaleFactor",value:function(e){var t;if(e||(e=this.getDeviceFormFactor()),"television"!==e)return 1;var n=window,i=n.innerWidth,a=n.innerHeight,r=i.toString()+"x"+a.toString();return null!==(t=Hh[r])&&void 0!==t?t:Math.min(i/1920,a/1080)||1}},{key:"getScreenInfo",value:function(){var e,t,n,i;return"undefined"==typeof window?{width:1920,height:1080,scale:1}:{width:null!==(e=null===(t=window.screen)||void 0===t?void 0:t.width)&&void 0!==e?e:window.innerWidth,height:null!==(n=null===(i=window.screen)||void 0===i?void 0:i.height)&&void 0!==n?n:window.innerHeight,scale:window.devicePixelRatio||1}}},{key:"getLanguage",value:function(){return"undefined"==typeof window?"en":window.navigator.language||"en"}},{key:"generateUUID",value:function(){return"undefined"!=typeof crypto&&"function"==typeof crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})}}])}();function Vh(e,t,n,i){var a,r=arguments.length,o=r<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,n,i);else for(var s=e.length-1;s>=0;s--)(a=e[s])&&(o=(r<3?a(o):r>3?a(t,n,o):a(t,n))||o);return r>3&&o&&Object.defineProperty(t,n,o),o}"function"==typeof SuppressedError&&SuppressedError;var Kh,Xh,Yh,qh=globalThis,Jh=qh.ShadowRoot&&(void 0===qh.ShadyCSS||qh.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Qh=Symbol(),Zh=new WeakMap,em=function(){return c(function e(t,n,i){if(o(this,e),this._$cssResult$=!0,i!==Qh)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=n},[{key:"styleSheet",get:function(){var e=this.o,t=this.t;if(Jh&&void 0===e){var n=void 0!==t&&1===t.length;n&&(e=Zh.get(t)),void 0===e&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),n&&Zh.set(t,e))}return e}},{key:"toString",value:function(){return this.cssText}}])}(),tm=e=>new em("string"==typeof e?e:e+"",void 0,Qh),nm=(e,...t)=>{var n=1===e.length?e[0]:t.reduce((t,n,i)=>t+(e=>{if(!0===e._$cssResult$)return e.cssText;if("number"==typeof e)return e;throw Error("Value passed to 'css' function must be a 'css' function result: "+e+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(n)+e[i+1],e[0]);return new em(n,e,Qh)},im=Jh?e=>e:e=>e instanceof CSSStyleSheet?(e=>{for(var t,n="",i=h(e.cssRules);!(t=i()).done;){n+=t.value.cssText}return tm(n)})(e):e,am=Object.is,rm=Object.defineProperty,om=Object.getOwnPropertyDescriptor,sm=Object.getOwnPropertyNames,um=Object.getOwnPropertySymbols,lm=Object.getPrototypeOf,dm=globalThis,cm=dm.trustedTypes,hm=cm?cm.emptyScript:"",mm=dm.reactiveElementPolyfillSupport,fm=(e,t)=>e,vm={toAttribute(e,t){switch(t){case Boolean:e=e?hm:null;break;case Object:case Array:e=null==e?e:JSON.stringify(e)}return e},fromAttribute(e,t){var n=e;switch(t){case Boolean:n=null!==e;break;case Number:n=null===e?null:Number(e);break;case Object:case Array:try{n=JSON.parse(e)}catch(e){n=null}}return n}},pm=(e,t)=>!am(e,t),gm={attribute:!0,type:String,converter:vm,reflect:!1,useDefault:!1,hasChanged:pm};null!==(Kh=Symbol.metadata)&&void 0!==Kh||(Symbol.metadata=Symbol("metadata")),null!==(Xh=dm.litPropertyMetadata)&&void 0!==Xh||(dm.litPropertyMetadata=new WeakMap);var ym,bm=function(e){function t(){var e;return o(this,t),(e=r(this,t))._$Ep=void 0,e.isUpdatePending=!1,e.hasUpdated=!1,e._$Em=null,e._$Ev(),e}return p(t,e),c(t,[{key:"_$Ev",value:function(){var e;this._$ES=new Promise(e=>this.enableUpdating=e),this._$AL=new Map,this._$E_(),this.requestUpdate(),null===(e=this.constructor.l)||void 0===e||e.forEach(e=>e(this))}},{key:"addController",value:function(e){var t,n;(null!==(t=this._$EO)&&void 0!==t?t:this._$EO=new Set).add(e),void 0!==this.renderRoot&&this.isConnected&&(null===(n=e.hostConnected)||void 0===n||n.call(e))}},{key:"removeController",value:function(e){var t;null===(t=this._$EO)||void 0===t||t.delete(e)}},{key:"_$E_",value:function(){for(var e,t=new Map,n=h(this.constructor.elementProperties.keys());!(e=n()).done;){var i=e.value;this.hasOwnProperty(i)&&(t.set(i,this[i]),delete this[i])}t.size>0&&(this._$Ep=t)}},{key:"createRenderRoot",value:function(){var e,t=null!==(e=this.shadowRoot)&&void 0!==e?e:this.attachShadow(this.constructor.shadowRootOptions);return((e,t)=>{if(Jh)e.adoptedStyleSheets=t.map(e=>e instanceof CSSStyleSheet?e:e.styleSheet);else for(var n,i=h(t);!(n=i()).done;){var a=n.value,r=document.createElement("style"),o=qh.litNonce;void 0!==o&&r.setAttribute("nonce",o),r.textContent=a.cssText,e.appendChild(r)}})(t,this.constructor.elementStyles),t}},{key:"connectedCallback",value:function(){var e,t;null!==(e=this.renderRoot)&&void 0!==e||(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),null===(t=this._$EO)||void 0===t||t.forEach(e=>{var t;return null===(t=e.hostConnected)||void 0===t?void 0:t.call(e)})}},{key:"enableUpdating",value:function(e){}},{key:"disconnectedCallback",value:function(){var e;null===(e=this._$EO)||void 0===e||e.forEach(e=>{var t;return null===(t=e.hostDisconnected)||void 0===t?void 0:t.call(e)})}},{key:"attributeChangedCallback",value:function(e,t,n){this._$AK(e,n)}},{key:"_$ET",value:function(e,t){var n=this.constructor.elementProperties.get(e),i=this.constructor._$Eu(e,n);if(void 0!==i&&!0===n.reflect){var a,r=(void 0!==(null===(a=n.converter)||void 0===a?void 0:a.toAttribute)?n.converter:vm).toAttribute(t,n.type);this._$Em=e,null==r?this.removeAttribute(i):this.setAttribute(i,r),this._$Em=null}}},{key:"_$AK",value:function(e,t){var n=this.constructor,i=n._$Eh.get(e);if(void 0!==i&&this._$Em!==i){var a,r,o,s=n.getPropertyOptions(i),u="function"==typeof s.converter?{fromAttribute:s.converter}:void 0!==(null===(a=s.converter)||void 0===a?void 0:a.fromAttribute)?s.converter:vm;this._$Em=i;var l=u.fromAttribute(t,s.type);this[i]=null!==(r=null!=l?l:null===(o=this._$Ej)||void 0===o?void 0:o.get(i))&&void 0!==r?r:l,this._$Em=null}}},{key:"requestUpdate",value:function(e,t,n,i=!1,a){if(void 0!==e){var r,o,s=this.constructor;if(!1===i&&(a=this[e]),null!=n||(n=s.getPropertyOptions(e)),!((null!==(r=n.hasChanged)&&void 0!==r?r:pm)(a,t)||n.useDefault&&n.reflect&&a===(null===(o=this._$Ej)||void 0===o?void 0:o.get(e))&&!this.hasAttribute(s._$Eu(e,n))))return;this.C(e,t,n)}!1===this.isUpdatePending&&(this._$ES=this._$EP())}},{key:"C",value:function(e,t,{useDefault:n,reflect:i,wrapped:a},r){var o,s,u;n&&!(null!==(o=this._$Ej)&&void 0!==o?o:this._$Ej=new Map).has(e)&&(this._$Ej.set(e,null!==(s=null!=r?r:t)&&void 0!==s?s:this[e]),!0!==a||void 0!==r)||(this._$AL.has(e)||(this.hasUpdated||n||(t=void 0),this._$AL.set(e,t)),!0===i&&this._$Em!==e&&(null!==(u=this._$Eq)&&void 0!==u?u:this._$Eq=new Set).add(e))}},{key:"_$EP",value:function(){var e,t;return k(function(n){for(;;)switch(n.p=n.n){case 0:return this.isUpdatePending=!0,n.p=1,n.n=2,a(this._$ES);case 2:n.n=4;break;case 3:n.p=3,t=n.v,Promise.reject(t);case 4:if(e=this.scheduleUpdate(),!(null!=e)){n.n=5;break}return n.n=5,a(e);case 5:return n.a(2,!this.isUpdatePending)}},null,this,[[1,3]],Promise)}},{key:"scheduleUpdate",value:function(){return this.performUpdate()}},{key:"performUpdate",value:function(){if(this.isUpdatePending){if(!this.hasUpdated){var e;if(null!==(e=this.renderRoot)&&void 0!==e||(this.renderRoot=this.createRenderRoot()),this._$Ep){for(var t,n=h(this._$Ep);!(t=n()).done;){var i=t.value,a=i[0],r=i[1];this[a]=r}this._$Ep=void 0}var o=this.constructor.elementProperties;if(o.size>0)for(var s,u=h(o);!(s=u()).done;){var l=s.value,d=l[0],c=l[1],m=c.wrapped,f=this[d];!0!==m||this._$AL.has(d)||void 0===f||this.C(d,void 0,c,f)}}var v=!1,p=this._$AL;try{var g;(v=this.shouldUpdate(p))?(this.willUpdate(p),null!==(g=this._$EO)&&void 0!==g&&g.forEach(e=>{var t;return null===(t=e.hostUpdate)||void 0===t?void 0:t.call(e)}),this.update(p)):this._$EM()}catch(p){throw v=!1,this._$EM(),p}v&&this._$AE(p)}}},{key:"willUpdate",value:function(e){}},{key:"_$AE",value:function(e){var t;null!==(t=this._$EO)&&void 0!==t&&t.forEach(e=>{var t;return null===(t=e.hostUpdated)||void 0===t?void 0:t.call(e)}),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}},{key:"_$EM",value:function(){this._$AL=new Map,this.isUpdatePending=!1}},{key:"updateComplete",get:function(){return this.getUpdateComplete()}},{key:"getUpdateComplete",value:function(){return this._$ES}},{key:"shouldUpdate",value:function(e){return!0}},{key:"update",value:function(e){this._$Eq&&(this._$Eq=this._$Eq.forEach(e=>this._$ET(e,this[e]))),this._$EM()}},{key:"updated",value:function(e){}},{key:"firstUpdated",value:function(e){}}],[{key:"addInitializer",value:function(e){var t;this._$Ei(),(null!==(t=this.l)&&void 0!==t?t:this.l=[]).push(e)}},{key:"observedAttributes",get:function(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}},{key:"createProperty",value:function(e,t=gm){if(t.state&&(t.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(e)&&((t=Object.create(t)).wrapped=!0),this.elementProperties.set(e,t),!t.noAccessor){var n=Symbol(),i=this.getPropertyDescriptor(e,n,t);void 0!==i&&rm(this.prototype,e,i)}}},{key:"getPropertyDescriptor",value:function(e,t,n){var i,a=null!==(i=om(this.prototype,e))&&void 0!==i?i:{get(){return this[t]},set(e){this[t]=e}},r=a.get,o=a.set;return{get:r,set(t){var i=null==r?void 0:r.call(this);null!=o&&o.call(this,t),this.requestUpdate(e,i,n)},configurable:!0,enumerable:!0}}},{key:"getPropertyOptions",value:function(e){var t;return null!==(t=this.elementProperties.get(e))&&void 0!==t?t:gm}},{key:"_$Ei",value:function(){if(!this.hasOwnProperty(fm("elementProperties"))){var e=lm(this);e.finalize(),void 0!==e.l&&(this.l=[...e.l]),this.elementProperties=new Map(e.elementProperties)}}},{key:"finalize",value:function(){if(!this.hasOwnProperty(fm("finalized"))){if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(fm("properties")))for(var e=this.properties,t=0,n=[...sm(e),...um(e)];t<n.length;t++){var i=n[t];this.createProperty(i,e[i])}var a=this[Symbol.metadata];if(null!==a){var r=litPropertyMetadata.get(a);if(void 0!==r)for(var o,s=h(r);!(o=s()).done;){var u=o.value,l=u[0],d=u[1];this.elementProperties.set(l,d)}}this._$Eh=new Map;for(var c,m=h(this.elementProperties);!(c=m()).done;){var f=c.value,v=f[0],p=f[1],g=this._$Eu(v,p);void 0!==g&&this._$Eh.set(g,v)}this.elementStyles=this.finalizeStyles(this.styles)}}},{key:"finalizeStyles",value:function(e){var t=[];if(Array.isArray(e))for(var n,i=h(new Set(e.flat(1/0).reverse()));!(n=i()).done;){var a=n.value;t.unshift(im(a))}else void 0!==e&&t.push(im(e));return t}},{key:"_$Eu",value:function(e,t){var n=t.attribute;return!1===n?void 0:"string"==typeof n?n:"string"==typeof e?e.toLowerCase():void 0}}])}(M(HTMLElement));bm.elementStyles=[],bm.shadowRootOptions={mode:"open"},bm[fm("elementProperties")]=new Map,bm[fm("finalized")]=new Map,null!=mm&&mm({ReactiveElement:bm}),(null!==(Yh=dm.reactiveElementVersions)&&void 0!==Yh?Yh:dm.reactiveElementVersions=[]).push("2.1.2");var wm=globalThis,km=e=>e,Sm=wm.trustedTypes,Em=Sm?Sm.createPolicy("lit-html",{createHTML:e=>e}):void 0,Pm="$lit$",Tm=`lit$${Math.random().toFixed(9).slice(2)}$`,_m="?"+Tm,Mm=`<${_m}>`,Am=document,Dm=()=>Am.createComment(""),xm=e=>null===e||"object"!=typeof e&&"function"!=typeof e,Cm=Array.isArray,Im="[ \t\n\f\r]",Lm=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Rm=/-->/g,Fm=/>/g,Om=RegExp(`>|${Im}(?:([^\\s"'>=/]+)(${Im}*=${Im}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),$m=/'/g,Nm=/"/g,Wm=/^(?:script|style|textarea|title)$/i,jm=e=>(t,...n)=>({_$litType$:e,strings:t,values:n}),Bm=jm(1),zm=jm(2),Um=Symbol.for("lit-noChange"),Hm=Symbol.for("lit-nothing"),Gm=new WeakMap,Vm=Am.createTreeWalker(Am,129);function Km(e,t){if(!Cm(e)||!e.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==Em?Em.createHTML(t):t}var Xm=function(){return c(function e({strings:t,_$litType$:n},i){var a;o(this,e),this.parts=[];var r=0,s=0,u=t.length-1,l=this.parts,d=((e,t)=>{for(var n,i=e.length-1,a=[],r=2===t?"<svg>":3===t?"<math>":"",o=Lm,s=0;s<i;s++){for(var u=e[s],l=void 0,d=void 0,c=-1,h=0;h<u.length&&(o.lastIndex=h,null!==(d=o.exec(u)));)h=o.lastIndex,o===Lm?"!--"===d[1]?o=Rm:void 0!==d[1]?o=Fm:void 0!==d[2]?(Wm.test(d[2])&&(n=RegExp("</"+d[2],"g")),o=Om):void 0!==d[3]&&(o=Om):o===Om?">"===d[0]?(o=null!=n?n:Lm,c=-1):void 0===d[1]?c=-2:(c=o.lastIndex-d[2].length,l=d[1],o=void 0===d[3]?Om:'"'===d[3]?Nm:$m):o===Nm||o===$m?o=Om:o===Rm||o===Fm?o=Lm:(o=Om,n=void 0);var m=o===Om&&e[s+1].startsWith("/>")?" ":"";r+=o===Lm?u+Mm:c>=0?(a.push(l),u.slice(0,c)+Pm+u.slice(c)+Tm+m):u+Tm+(-2===c?s:m)}return[Km(e,r+(e[i]||"<?>")+(2===t?"</svg>":3===t?"</math>":"")),a]})(t,n),c=d[0],m=d[1];if(this.el=e.createElement(c,i),Vm.currentNode=this.el.content,2===n||3===n){var f=this.el.content.firstChild;f.replaceWith(...f.childNodes)}for(;null!==(a=Vm.nextNode())&&l.length<u;){if(1===a.nodeType){if(a.hasAttributes())for(var v,p=h(a.getAttributeNames());!(v=p()).done;){var g=v.value;if(g.endsWith(Pm)){var y=m[s++],b=a.getAttribute(g).split(Tm),w=/([.?@])?(.*)/.exec(y);l.push({type:1,index:r,name:w[2],strings:b,ctor:"."===w[1]?Zm:"?"===w[1]?ef:"@"===w[1]?tf:Qm}),a.removeAttribute(g)}else g.startsWith(Tm)&&(l.push({type:6,index:r}),a.removeAttribute(g))}if(Wm.test(a.tagName)){var k=a.textContent.split(Tm),S=k.length-1;if(S>0){a.textContent=Sm?Sm.emptyScript:"";for(var E=0;E<S;E++)a.append(k[E],Dm()),Vm.nextNode(),l.push({type:2,index:++r});a.append(k[S],Dm())}}}else if(8===a.nodeType)if(a.data===_m)l.push({type:2,index:r});else for(var P=-1;-1!==(P=a.data.indexOf(Tm,P+1));)l.push({type:7,index:r}),P+=Tm.length-1;r++}},null,[{key:"createElement",value:function(e,t){var n=Am.createElement("template");return n.innerHTML=e,n}}])}();function Ym(e,t,n=e,i){var a,r,o,s,u;if(t===Um)return t;var l=void 0!==i?null===(a=n._$Co)||void 0===a?void 0:a[i]:n._$Cl,d=xm(t)?void 0:t._$litDirective$;return(null===(r=l)||void 0===r?void 0:r.constructor)!==d&&(null!==(o=l)&&void 0!==o&&null!==(s=o._$AO)&&void 0!==s&&s.call(o,!1),void 0===d?l=void 0:(l=new d(e))._$AT(e,n,i),void 0!==i?(null!==(u=n._$Co)&&void 0!==u?u:n._$Co=[])[i]=l:n._$Cl=l),void 0!==l&&(t=Ym(e,l._$AS(e,t.values),l,i)),t}var qm=function(){return c(function e(t,n){o(this,e),this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=n},[{key:"parentNode",get:function(){return this._$AM.parentNode}},{key:"_$AU",get:function(){return this._$AM._$AU}},{key:"u",value:function(e){var t,n=this._$AD,i=n.el.content,a=n.parts,r=(null!==(t=null==e?void 0:e.creationScope)&&void 0!==t?t:Am).importNode(i,!0);Vm.currentNode=r;for(var o=Vm.nextNode(),s=0,u=0,l=a[0];void 0!==l;){var d;if(s===l.index){var c=void 0;2===l.type?c=new Jm(o,o.nextSibling,this,e):1===l.type?c=new l.ctor(o,l.name,l.strings,this,e):6===l.type&&(c=new nf(o,this,e)),this._$AV.push(c),l=a[++u]}s!==(null===(d=l)||void 0===d?void 0:d.index)&&(o=Vm.nextNode(),s++)}return Vm.currentNode=Am,r}},{key:"p",value:function(e){for(var t,n=0,i=h(this._$AV);!(t=i()).done;){var a=t.value;void 0!==a&&(void 0!==a.strings?(a._$AI(e,a,n),n+=a.strings.length-2):a._$AI(e[n])),n++}}}])}(),Jm=function(){return c(function e(t,n,i,a){var r;o(this,e),this.type=2,this._$AH=Hm,this._$AN=void 0,this._$AA=t,this._$AB=n,this._$AM=i,this.options=a,this._$Cv=null===(r=null==a?void 0:a.isConnected)||void 0===r||r},[{key:"_$AU",get:function(){var e,t;return null!==(e=null===(t=this._$AM)||void 0===t?void 0:t._$AU)&&void 0!==e?e:this._$Cv}},{key:"parentNode",get:function(){var e,t=this._$AA.parentNode,n=this._$AM;return void 0!==n&&11===(null===(e=t)||void 0===e?void 0:e.nodeType)&&(t=n.parentNode),t}},{key:"startNode",get:function(){return this._$AA}},{key:"endNode",get:function(){return this._$AB}},{key:"_$AI",value:function(e,t=this){e=Ym(this,e,t),xm(e)?e===Hm||null==e||""===e?(this._$AH!==Hm&&this._$AR(),this._$AH=Hm):e!==this._$AH&&e!==Um&&this._(e):void 0!==e._$litType$?this.$(e):void 0!==e.nodeType?this.T(e):(e=>Cm(e)||"function"==typeof(null==e?void 0:e[Symbol.iterator]))(e)?this.k(e):this._(e)}},{key:"O",value:function(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}},{key:"T",value:function(e){this._$AH!==e&&(this._$AR(),this._$AH=this.O(e))}},{key:"_",value:function(e){this._$AH!==Hm&&xm(this._$AH)?this._$AA.nextSibling.data=e:this.T(Am.createTextNode(e)),this._$AH=e}},{key:"$",value:function(e){var t,n=e.values,i=e._$litType$,a="number"==typeof i?this._$AC(e):(void 0===i.el&&(i.el=Xm.createElement(Km(i.h,i.h[0]),this.options)),i);if((null===(t=this._$AH)||void 0===t?void 0:t._$AD)===a)this._$AH.p(n);else{var r=new qm(a,this),o=r.u(this.options);r.p(n),this.T(o),this._$AH=r}}},{key:"_$AC",value:function(e){var t=Gm.get(e.strings);return void 0===t&&Gm.set(e.strings,t=new Xm(e)),t}},{key:"k",value:function(e){Cm(this._$AH)||(this._$AH=[],this._$AR());for(var t,n,i=this._$AH,a=0,r=h(e);!(n=r()).done;){var o=n.value;a===i.length?i.push(t=new _k(this.O(Dm()),this.O(Dm()),this,this.options)):t=i[a],t._$AI(o),a++}a<i.length&&(this._$AR(t&&t._$AB.nextSibling,a),i.length=a)}},{key:"_$AR",value:function(e=this._$AA.nextSibling,t){for(null===(n=this._$AP)||void 0===n||n.call(this,!1,!0,t);e!==this._$AB;){var n,i=km(e).nextSibling;km(e).remove(),e=i}}},{key:"setConnected",value:function(e){var t;void 0===this._$AM&&(this._$Cv=e,null===(t=this._$AP)||void 0===t||t.call(this,e))}}])}(),Qm=function(){return c(function e(t,n,i,a,r){o(this,e),this.type=1,this._$AH=Hm,this._$AN=void 0,this.element=t,this.name=n,this._$AM=a,this.options=r,i.length>2||""!==i[0]||""!==i[1]?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=Hm},[{key:"tagName",get:function(){return this.element.tagName}},{key:"_$AU",get:function(){return this._$AM._$AU}},{key:"_$AI",value:function(e,t=this,n,i){var a=this.strings,r=!1;if(void 0===a)e=Ym(this,e,t,0),(r=!xm(e)||e!==this._$AH&&e!==Um)&&(this._$AH=e);else{var o,s,u=e;for(e=a[0],o=0;o<a.length-1;o++)(s=Ym(this,u[n+o],t,o))===Um&&(s=this._$AH[o]),r||(r=!xm(s)||s!==this._$AH[o]),s===Hm?e=Hm:e!==Hm&&(e+=(null!=s?s:"")+a[o+1]),this._$AH[o]=s}r&&!i&&this.j(e)}},{key:"j",value:function(e){e===Hm?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,null!=e?e:"")}}])}(),Zm=function(e){function t(){var e;return o(this,t),(e=r(this,t,arguments)).type=3,e}return p(t,e),c(t,[{key:"j",value:function(e){this.element[this.name]=e===Hm?void 0:e}}])}(Qm),ef=function(e){function t(){var e;return o(this,t),(e=r(this,t,arguments)).type=4,e}return p(t,e),c(t,[{key:"j",value:function(e){this.element.toggleAttribute(this.name,!!e&&e!==Hm)}}])}(Qm),tf=function(e){function t(e,n,i,a,s){var u;return o(this,t),(u=r(this,t,[e,n,i,a,s])).type=5,u}return p(t,e),c(t,[{key:"_$AI",value:function(e,t=this){var n;if((e=null!==(n=Ym(this,e,t,0))&&void 0!==n?n:Hm)!==Um){var i=this._$AH,a=e===Hm&&i!==Hm||e.capture!==i.capture||e.once!==i.once||e.passive!==i.passive,r=e!==Hm&&(i===Hm||a);a&&this.element.removeEventListener(this.name,this,i),r&&this.element.addEventListener(this.name,this,e),this._$AH=e}}},{key:"handleEvent",value:function(e){var t,n;"function"==typeof this._$AH?this._$AH.call(null!==(t=null===(n=this.options)||void 0===n?void 0:n.host)&&void 0!==t?t:this.element,e):this._$AH.handleEvent(e)}}])}(Qm),nf=function(){return c(function e(t,n,i){o(this,e),this.element=t,this.type=6,this._$AN=void 0,this._$AM=n,this.options=i},[{key:"_$AU",get:function(){return this._$AM._$AU}},{key:"_$AI",value:function(e){Ym(this,e)}}])}(),af={I:Jm},rf=wm.litHtmlPolyfillSupport;null!=rf&&rf(Xm,Jm),(null!==(ym=wm.litHtmlVersions)&&void 0!==ym?ym:wm.litHtmlVersions=[]).push("3.3.3");var of,sf,uf=globalThis,lf=function(e){function t(){var e;return o(this,t),(e=r(this,t,arguments)).renderOptions={host:i(e)},e._$Do=void 0,e}return p(t,e),c(t,[{key:"createRenderRoot",value:function(){var e,n,i=T(t,"createRenderRoot",this)([]);return null!==(n=(e=this.renderOptions).renderBefore)&&void 0!==n||(e.renderBefore=i.firstChild),i}},{key:"update",value:function(e){var n=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),T(t,"update",this)([e]),this._$Do=((e,t,n)=>{var i,a=null!==(i=null==n?void 0:n.renderBefore)&&void 0!==i?i:t,r=a._$litPart$;if(void 0===r){var o,s=null!==(o=null==n?void 0:n.renderBefore)&&void 0!==o?o:null;a._$litPart$=r=new Jm(t.insertBefore(Dm(),s),s,void 0,null!=n?n:{})}return r._$AI(e),r})(n,this.renderRoot,this.renderOptions)}},{key:"connectedCallback",value:function(){var e;T(t,"connectedCallback",this)([]),null===(e=this._$Do)||void 0===e||e.setConnected(!0)}},{key:"disconnectedCallback",value:function(){var e;T(t,"disconnectedCallback",this)([]),null===(e=this._$Do)||void 0===e||e.setConnected(!1)}},{key:"render",value:function(){return Um}}])}(bm);lf._$litElement$=!0,lf.finalized=!0,null===(of=uf.litElementHydrateSupport)||void 0===of||of.call(uf,{LitElement:lf});var df=uf.litElementPolyfillSupport;null==df||df({LitElement:lf}),(null!==(sf=uf.litElementVersions)&&void 0!==sf?sf:uf.litElementVersions=[]).push("4.2.2");var cf,hf,mf=nm(cf||(cf=(e=>e)`
|
|
2
2
|
/* ——— keyframes ——— */
|
|
3
3
|
@keyframes nami-slide-up {
|
|
4
4
|
from { transform: translateY(100%); }
|
|
@@ -468,9 +468,8 @@
|
|
|
468
468
|
|
|
469
469
|
/>
|
|
470
470
|
<label for="${0}">${0}</label>`),this.component.text,this.component.text,this.component.text,this._isActive,this.component.text,this.component.text)}}])}(Gw);Vh([yf({type:Object})],s$.prototype,"component",void 0),Vh([yf({type:Boolean})],s$.prototype,"inFocusedState",void 0),Vh([yf({type:Number})],s$.prototype,"scaleFactor",void 0),Vh([bf()],s$.prototype,"_isActive",void 0),Vh([bf()],s$.prototype,"_isFocused",void 0),s$=Vh([vf("nami-segment-picker-item")],s$);var u$=Number.isFinite||function(e){return"number"==typeof e&&isFinite(e)},l$=Number.isSafeInteger||function(e){return"number"==typeof e&&Math.abs(e)<=d$},d$=Number.MAX_SAFE_INTEGER||9007199254740991,c$=function(e){return e.NETWORK_ERROR="networkError",e.MEDIA_ERROR="mediaError",e.KEY_SYSTEM_ERROR="keySystemError",e.MUX_ERROR="muxError",e.OTHER_ERROR="otherError",e}({}),h$=function(e){return e.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",e.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",e.KEY_SYSTEM_NO_SESSION="keySystemNoSession",e.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",e.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",e.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",e.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",e.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",e.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",e.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",e.KEY_SYSTEM_DESTROY_MEDIA_KEYS_ERROR="keySystemDestroyMediaKeysError",e.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR="keySystemDestroyCloseSessionError",e.KEY_SYSTEM_DESTROY_REMOVE_SESSION_ERROR="keySystemDestroyRemoveSessionError",e.MANIFEST_LOAD_ERROR="manifestLoadError",e.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",e.MANIFEST_PARSING_ERROR="manifestParsingError",e.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",e.LEVEL_EMPTY_ERROR="levelEmptyError",e.LEVEL_LOAD_ERROR="levelLoadError",e.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",e.LEVEL_PARSING_ERROR="levelParsingError",e.LEVEL_SWITCH_ERROR="levelSwitchError",e.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",e.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",e.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",e.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",e.FRAG_LOAD_ERROR="fragLoadError",e.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",e.FRAG_DECRYPT_ERROR="fragDecryptError",e.FRAG_PARSING_ERROR="fragParsingError",e.FRAG_GAP="fragGap",e.REMUX_ALLOC_ERROR="remuxAllocError",e.KEY_LOAD_ERROR="keyLoadError",e.KEY_LOAD_TIMEOUT="keyLoadTimeOut",e.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",e.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",e.BUFFER_APPEND_ERROR="bufferAppendError",e.BUFFER_APPENDING_ERROR="bufferAppendingError",e.BUFFER_STALLED_ERROR="bufferStalledError",e.BUFFER_FULL_ERROR="bufferFullError",e.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",e.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",e.ASSET_LIST_LOAD_ERROR="assetListLoadError",e.ASSET_LIST_LOAD_TIMEOUT="assetListLoadTimeout",e.ASSET_LIST_PARSING_ERROR="assetListParsingError",e.INTERSTITIAL_ASSET_ITEM_ERROR="interstitialAssetItemError",e.INTERNAL_EXCEPTION="internalException",e.INTERNAL_ABORTED="aborted",e.ATTACH_MEDIA_ERROR="attachMediaError",e.UNKNOWN="unknown",e}({}),m$=function(e){return e.MEDIA_ATTACHING="hlsMediaAttaching",e.MEDIA_ATTACHED="hlsMediaAttached",e.MEDIA_DETACHING="hlsMediaDetaching",e.MEDIA_DETACHED="hlsMediaDetached",e.MEDIA_ENDED="hlsMediaEnded",e.STALL_RESOLVED="hlsStallResolved",e.BUFFER_RESET="hlsBufferReset",e.BUFFER_CODECS="hlsBufferCodecs",e.BUFFER_CREATED="hlsBufferCreated",e.BUFFER_APPENDING="hlsBufferAppending",e.BUFFER_APPENDED="hlsBufferAppended",e.BUFFER_EOS="hlsBufferEos",e.BUFFERED_TO_END="hlsBufferedToEnd",e.BUFFER_FLUSHING="hlsBufferFlushing",e.BUFFER_FLUSHED="hlsBufferFlushed",e.MANIFEST_LOADING="hlsManifestLoading",e.MANIFEST_LOADED="hlsManifestLoaded",e.MANIFEST_PARSED="hlsManifestParsed",e.LEVEL_SWITCHING="hlsLevelSwitching",e.LEVEL_SWITCHED="hlsLevelSwitched",e.LEVEL_LOADING="hlsLevelLoading",e.LEVEL_LOADED="hlsLevelLoaded",e.LEVEL_UPDATED="hlsLevelUpdated",e.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",e.LEVELS_UPDATED="hlsLevelsUpdated",e.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",e.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",e.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",e.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",e.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",e.AUDIO_TRACK_UPDATED="hlsAudioTrackUpdated",e.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",e.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",e.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",e.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",e.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",e.SUBTITLE_TRACK_UPDATED="hlsSubtitleTrackUpdated",e.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",e.CUES_PARSED="hlsCuesParsed",e.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",e.INIT_PTS_FOUND="hlsInitPtsFound",e.FRAG_LOADING="hlsFragLoading",e.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",e.FRAG_LOADED="hlsFragLoaded",e.FRAG_DECRYPTED="hlsFragDecrypted",e.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",e.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",e.FRAG_PARSING_METADATA="hlsFragParsingMetadata",e.FRAG_PARSED="hlsFragParsed",e.FRAG_BUFFERED="hlsFragBuffered",e.FRAG_CHANGED="hlsFragChanged",e.FPS_DROP="hlsFpsDrop",e.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",e.MAX_AUTO_LEVEL_UPDATED="hlsMaxAutoLevelUpdated",e.ERROR="hlsError",e.DESTROYING="hlsDestroying",e.KEY_LOADING="hlsKeyLoading",e.KEY_LOADED="hlsKeyLoaded",e.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",e.BACK_BUFFER_REACHED="hlsBackBufferReached",e.STEERING_MANIFEST_LOADED="hlsSteeringManifestLoaded",e.ASSET_LIST_LOADING="hlsAssetListLoading",e.ASSET_LIST_LOADED="hlsAssetListLoaded",e.INTERSTITIALS_UPDATED="hlsInterstitialsUpdated",e.INTERSTITIALS_BUFFERED_TO_BOUNDARY="hlsInterstitialsBufferedToBoundary",e.INTERSTITIAL_ASSET_PLAYER_CREATED="hlsInterstitialAssetPlayerCreated",e.INTERSTITIAL_STARTED="hlsInterstitialStarted",e.INTERSTITIAL_ASSET_STARTED="hlsInterstitialAssetStarted",e.INTERSTITIAL_ASSET_ENDED="hlsInterstitialAssetEnded",e.INTERSTITIAL_ASSET_ERROR="hlsInterstitialAssetError",e.INTERSTITIAL_ENDED="hlsInterstitialEnded",e.INTERSTITIALS_PRIMARY_RESUMED="hlsInterstitialsPrimaryResumed",e.PLAYOUT_LIMIT_REACHED="hlsPlayoutLimitReached",e.EVENT_CUE_ENTER="hlsEventCueEnter",e}({}),f$="manifest",v$="level",p$="audioTrack",g$="subtitleTrack",y$="main",b$="audio",w$="subtitle",k$=function(){return c(function e(t,n=0,i=0){o(this,e),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_=n,this.totalWeight_=i},[{key:"sample",value:function(e,t){var n=Math.pow(this.alpha_,e);this.estimate_=t*(1-n)+n*this.estimate_,this.totalWeight_+=e}},{key:"getTotalWeight",value:function(){return this.totalWeight_}},{key:"getEstimate",value:function(){if(this.alpha_){var e=1-Math.pow(this.alpha_,this.totalWeight_);if(e)return this.estimate_/e}return this.estimate_}}])}(),S$=function(){return c(function e(t,n,i,a=100){o(this,e),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 k$(t),this.fast_=new k$(n),this.defaultTTFB_=a,this.ttfb_=new k$(t)},[{key:"update",value:function(e,t){var n=this.slow_,i=this.fast_,a=this.ttfb_;n.halfLife!==e&&(this.slow_=new k$(e,n.getEstimate(),n.getTotalWeight())),i.halfLife!==t&&(this.fast_=new k$(t,i.getEstimate(),i.getTotalWeight())),a.halfLife!==e&&(this.ttfb_=new k$(e,a.getEstimate(),a.getTotalWeight()))}},{key:"sample",value:function(e,t){var n=(e=Math.max(e,this.minDelayMs_))/1e3,i=8*t/n;this.fast_.sample(n,i),this.slow_.sample(n,i)}},{key:"sampleTTFB",value:function(e){var t=e/1e3,n=Math.sqrt(2)*Math.exp(-Math.pow(t,2)/2);this.ttfb_.sample(n,Math.max(e,5))}},{key:"canEstimate",value:function(){return this.fast_.getTotalWeight()>=this.minWeight_}},{key:"getEstimate",value:function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_}},{key:"getEstimateTTFB",value:function(){return this.ttfb_.getTotalWeight()>=this.minWeight_?this.ttfb_.getEstimate():this.defaultTTFB_}},{key:"defaultEstimate",get:function(){return this.defaultEstimate_}},{key:"destroy",value:function(){}}])}();function E$(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,t);if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function P$(){return P$=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)({}).hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},P$.apply(null,arguments)}function T$(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,i)}return n}function _$(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?T$(Object(n),!0).forEach(function(t){E$(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):T$(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var M$=c(function e(t,n){o(this,e),this.trace=void 0,this.debug=void 0,this.log=void 0,this.warn=void 0,this.info=void 0,this.error=void 0;var i=`[${t}]:`;this.trace=A$,this.debug=n.debug.bind(null,i),this.log=n.log.bind(null,i),this.warn=n.warn.bind(null,i),this.info=n.info.bind(null,i),this.error=n.error.bind(null,i)}),A$=function(){},D$={trace:A$,debug:A$,log:A$,warn:A$,info:A$,error:A$};function x$(){return P$({},D$)}function C$(e,t,n){return t[e]?t[e].bind(t):function(e,t){var n=self.console[e];return n?n.bind(self.console,`${t?"["+t+"] ":""}[${e}] >`):A$}(e,n)}var I$=x$();var L$=I$;function R$(e=!0){if("undefined"!=typeof self)return(e||!self.MediaSource)&&self.ManagedMediaSource||self.MediaSource||self.WebKitMediaSource}function F$(e,t){var n=Object.keys(e),i=Object.keys(t),a=n.length,r=i.length;return!a||!r||a===r&&!n.some(e=>-1===i.indexOf(e))}function O$(e,t=!1){if("undefined"!=typeof TextDecoder){var n=new TextDecoder("utf-8").decode(e);if(t){var i=n.indexOf("\0");return-1!==i?n.substring(0,i):n}return n.replace(/\0/g,"")}for(var a,r,o,s=e.length,u="",l=0;l<s;){if(0===(a=e[l++])&&t)return u;if(0!==a&&3!==a)switch(a>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:u+=String.fromCharCode(a);break;case 12:case 13:r=e[l++],u+=String.fromCharCode((31&a)<<6|63&r);break;case 14:r=e[l++],o=e[l++],u+=String.fromCharCode((15&a)<<12|(63&r)<<6|63&o)}}return u}function $$(e){for(var t="",n=0;n<e.length;n++){var i=e[n].toString(16);i.length<2&&(i="0"+i),t+=i}return t}function N$(e){return Uint8Array.from(e.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}function W$(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var j$,B$={exports:{}};var z$=(j$||(j$=1,function(e){var t,n,i,a,r;t=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,n=/^(?=([^\/?#]*))\1([^]*)$/,i=/(?:\/|^)\.(?=\/)/g,a=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,r={buildAbsoluteURL:function(e,t,i){if(i=i||{},e=e.trim(),!(t=t.trim())){if(!i.alwaysNormalize)return e;var a=r.parseURL(e);if(!a)throw new Error("Error trying to parse base URL.");return a.path=r.normalizePath(a.path),r.buildURLFromParts(a)}var o=r.parseURL(t);if(!o)throw new Error("Error trying to parse relative URL.");if(o.scheme)return i.alwaysNormalize?(o.path=r.normalizePath(o.path),r.buildURLFromParts(o)):t;var s=r.parseURL(e);if(!s)throw new Error("Error trying to parse base URL.");if(!s.netLoc&&s.path&&"/"!==s.path[0]){var u=n.exec(s.path);s.netLoc=u[1],s.path=u[2]}s.netLoc&&!s.path&&(s.path="/");var l={scheme:s.scheme,netLoc:o.netLoc,path:null,params:o.params,query:o.query,fragment:o.fragment};if(!o.netLoc&&(l.netLoc=s.netLoc,"/"!==o.path[0]))if(o.path){var d=s.path,c=d.substring(0,d.lastIndexOf("/")+1)+o.path;l.path=r.normalizePath(c)}else l.path=s.path,o.params||(l.params=s.params,o.query||(l.query=s.query));return null===l.path&&(l.path=i.alwaysNormalize?r.normalizePath(o.path):o.path),r.buildURLFromParts(l)},parseURL:function(e){var n=t.exec(e);return n?{scheme:n[1]||"",netLoc:n[2]||"",path:n[3]||"",params:n[4]||"",query:n[5]||"",fragment:n[6]||""}:null},normalizePath:function(e){for(e=e.split("").reverse().join("").replace(i,"");e.length!==(e=e.replace(a,"")).length;);return e.split("").reverse().join("")},buildURLFromParts:function(e){return e.scheme+e.netLoc+e.path+e.params+e.query+e.fragment}},e.exports=r}(B$)),B$.exports),U$=c(function e(){o(this,e),this.aborted=!1,this.loaded=0,this.retry=0,this.total=0,this.chunkCount=0,this.bwEstimate=0,this.loading={start:0,first:0,end:0},this.parsing={start:0,end:0},this.buffering={start:0,first:0,end:0}}),H$="audio",G$="video",V$="audiovideo",K$=function(){return c(function e(t){o(this,e),this._byteRange=null,this._url=null,this._stats=null,this._streams=null,this.base=void 0,this.relurl=void 0,"string"==typeof t&&(t={url:t}),this.base=t,function(e,t){var n=J$(e,t);n&&(n.enumerable=!0,Object.defineProperty(e,t,n))}(this,"stats")},[{key:"setByteRange",value:function(e,t){var n,i=e.split("@",2);n=1===i.length?(null==t?void 0:t.byteRangeEndOffset)||0:parseInt(i[1]),this._byteRange=[n,parseInt(i[0])+n]}},{key:"baseurl",get:function(){return this.base.url}},{key:"byteRange",get:function(){return null===this._byteRange?[]:this._byteRange}},{key:"byteRangeStartOffset",get:function(){return this.byteRange[0]}},{key:"byteRangeEndOffset",get:function(){return this.byteRange[1]}},{key:"elementaryStreams",get:function(){return null===this._streams&&(this._streams={[H$]:null,[G$]:null,[V$]:null}),this._streams},set:function(e){this._streams=e}},{key:"hasStats",get:function(){return null!==this._stats}},{key:"hasStreams",get:function(){return null!==this._streams}},{key:"stats",get:function(){return null===this._stats&&(this._stats=new U$),this._stats},set:function(e){this._stats=e}},{key:"url",get:function(){return!this._url&&this.baseurl&&this.relurl&&(this._url=z$.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(e){this._url=e}},{key:"clearElementaryStreamInfo",value:function(){var e=this.elementaryStreams;e[H$]=null,e[G$]=null,e[V$]=null}}])}();function X$(e){return"initSegment"!==e.sn}var Y$=function(e){function t(e,n){var i;return o(this,t),(i=r(this,t,[n]))._decryptdata=null,i._programDateTime=null,i._ref=null,i._bitrate=void 0,i.rawProgramDateTime=null,i.tagList=[],i.duration=0,i.sn=0,i.levelkeys=void 0,i.type=void 0,i.loader=null,i.keyLoader=null,i.level=-1,i.cc=0,i.startPTS=void 0,i.endPTS=void 0,i.startDTS=void 0,i.endDTS=void 0,i.start=0,i.playlistOffset=0,i.deltaPTS=void 0,i.maxStartPTS=void 0,i.minEndPTS=void 0,i.data=void 0,i.bitrateTest=!1,i.title=null,i.initSegment=null,i.endList=void 0,i.gap=void 0,i.urlId=0,i.type=e,i}return p(t,e),c(t,[{key:"byteLength",get:function(){if(this.hasStats){var e=this.stats.total;if(e)return e}if(this.byteRange.length){var t=this.byteRange[0],n=this.byteRange[1];if(u$(t)&&u$(n))return n-t}return null}},{key:"bitrate",get:function(){return this.byteLength?8*this.byteLength/this.duration:this._bitrate?this._bitrate:null},set:function(e){this._bitrate=e}},{key:"decryptdata",get:function(){var e,t=this.levelkeys;if(!t||t.NONE)return null;if(t.identity)this._decryptdata||(this._decryptdata=t.identity.getDecryptData(this.sn));else if(null==(e=this._decryptdata)||!e.keyId){var n=Object.keys(t);if(1===n.length){var i=this._decryptdata=t[n[0]]||null;i&&(this._decryptdata=i.getDecryptData(this.sn,t))}}return this._decryptdata}},{key:"end",get:function(){return this.start+this.duration}},{key:"endProgramDateTime",get:function(){if(null===this.programDateTime)return null;var e=u$(this.duration)?this.duration:0;return this.programDateTime+1e3*e}},{key:"encrypted",get:function(){var e;if(null!=(e=this._decryptdata)&&e.encrypted)return!0;if(this.levelkeys){var t,n=Object.keys(this.levelkeys),i=n.length;if(i>1||1===i&&null!=(t=this.levelkeys[n[0]])&&t.encrypted)return!0}return!1}},{key:"programDateTime",get:function(){return null===this._programDateTime&&this.rawProgramDateTime&&(this.programDateTime=Date.parse(this.rawProgramDateTime)),this._programDateTime},set:function(e){u$(e)?this._programDateTime=e:this._programDateTime=this.rawProgramDateTime=null}},{key:"ref",get:function(){return X$(this)?(this._ref||(this._ref={base:this.base,start:this.start,duration:this.duration,sn:this.sn,programDateTime:this.programDateTime}),this._ref):null}},{key:"addStart",value:function(e){this.setStart(this.start+e)}},{key:"setStart",value:function(e){this.start=e,this._ref&&(this._ref.start=e)}},{key:"setDuration",value:function(e){this.duration=e,this._ref&&(this._ref.duration=e)}},{key:"setKeyFormat",value:function(e){var t=this.levelkeys;if(t){var n,i=t[e];!i||null!=(n=this._decryptdata)&&n.keyId||(this._decryptdata=i.getDecryptData(this.sn,t))}}},{key:"abortRequests",value:function(){var e,t;null==(e=this.loader)||e.abort(),null==(t=this.keyLoader)||t.abort()}},{key:"setElementaryStreamInfo",value:function(e,t,n,i,a,r=!1){var o=this.elementaryStreams,s=o[e];s?(s.startPTS=Math.min(s.startPTS,t),s.endPTS=Math.max(s.endPTS,n),s.startDTS=Math.min(s.startDTS,i),s.endDTS=Math.max(s.endDTS,a)):o[e]={startPTS:t,endPTS:n,startDTS:i,endDTS:a,partial:r}}}])}(K$),q$=function(e){function t(e,n,i,a,s){var u;o(this,t),(u=r(this,t,[i])).fragOffset=0,u.duration=0,u.gap=!1,u.independent=!1,u.relurl=void 0,u.fragment=void 0,u.index=void 0,u.duration=e.decimalFloatingPoint("DURATION"),u.gap=e.bool("GAP"),u.independent=e.bool("INDEPENDENT"),u.relurl=e.enumeratedString("URI"),u.fragment=n,u.index=a;var l=e.enumeratedString("BYTERANGE");return l&&u.setByteRange(l,s),s&&(u.fragOffset=s.fragOffset+s.duration),u}return p(t,e),c(t,[{key:"start",get:function(){return this.fragment.start+this.fragOffset}},{key:"end",get:function(){return this.start+this.duration}},{key:"loaded",get:function(){var e=this.elementaryStreams;return!!(e.audio||e.video||e.audiovideo)}}])}(K$);function J$(e,t){var n=Object.getPrototypeOf(e);if(n){var i=Object.getOwnPropertyDescriptor(n,t);return i||J$(n,t)}}var Q$=Math.pow(2,32)-1,Z$=[].push,eN={video:1,audio:2,id3:3,text:4};function tN(e){return String.fromCharCode.apply(null,e)}function nN(e,t){var n=e[t]<<8|e[t+1];return n<0?65536+n:n}function iN(e,t){var n=rN(e,t);return n<0?4294967296+n:n}function aN(e,t){var n=iN(e,t);return n*=Math.pow(2,32),n+=iN(e,t+4)}function rN(e,t){return e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3]}function oN(e,t){var n=[];if(!t.length)return n;for(var i=e.byteLength,a=0;a<i;){var r=iN(e,a),o=r>1?a+r:i;if(tN(e.subarray(a+4,a+8))===t[0])if(1===t.length)n.push(e.subarray(a+8,o));else{var s=oN(e.subarray(a+8,o),t.slice(1));s.length&&Z$.apply(n,s)}a=o}return n}function sN(e){var t=[],n=e[0],i=8,a=iN(e,i);i+=4;var r=0,o=0;0===n?(r=iN(e,i),o=iN(e,i+4),i+=8):(r=aN(e,i),o=aN(e,i+8),i+=16),i+=2;var s=e.length+o,u=nN(e,i);i+=2;for(var l=0;l<u;l++){var d=i,c=iN(e,d);d+=4;var h=2147483647&c;if(1===(2147483648&c)>>>31)return L$.warn("SIDX has hierarchical references (not supported)"),null;var m=iN(e,d);d+=4,t.push({referenceSize:h,subsegmentDuration:m,info:{duration:m/a,start:s,end:s+h-1}}),s+=h,i=d+=4}return{earliestPresentationTime:r,timescale:a,version:n,referencesCount:u,references:t}}function uN(e){for(var t=[],n=oN(e,["moov","trak"]),i=0;i<n.length;i++){var a=n[i],r=oN(a,["tkhd"])[0];if(r){var o=r[0],s=iN(r,0===o?12:20),u=oN(a,["mdia","mdhd"])[0];if(u){var l=iN(u,0===(o=u[0])?12:20),d=oN(a,["mdia","hdlr"])[0];if(d){var c=tN(d.subarray(8,12)),h={soun:H$,vide:G$}[c],m=lN(oN(a,["mdia","minf","stbl","stsd"])[0]);h?(t[s]={timescale:l,type:h,stsd:m},t[h]=_$({timescale:l,id:s},m)):t[s]={timescale:l,type:c,stsd:m}}}}}return oN(e,["moov","mvex","trex"]).forEach(e=>{var n=iN(e,4),i=t[n];i&&(i.default={duration:iN(e,12),flags:iN(e,20)})}),t}function lN(e){var t,n=e.subarray(8),i=n.subarray(86),a=tN(n.subarray(4,8)),r=a,o="enca"===a||"encv"===a;if(o){var s=oN(n,[a])[0];oN(s.subarray("enca"===a?28:78),["sinf"]).forEach(e=>{var t=oN(e,["schm"])[0];if(t){var n=tN(t.subarray(4,8));if("cbcs"===n||"cenc"===n){var i=oN(e,["frma"])[0];i&&(r=tN(i))}}})}var u=r;switch(r){case"avc1":case"avc2":case"avc3":case"avc4":var l=oN(i,["avcC"])[0];l&&l.length>3&&(r+="."+hN(l[1])+hN(l[2])+hN(l[3]),t=dN("avc1"===u?"dva1":"dvav",i));break;case"mp4a":var d=oN(n,[a])[0],c=oN(d.subarray(28),["esds"])[0];if(c&&c.length>7){var h=4;if(3!==c[h++])break;h=cN(c,h),h+=2;var m=c[h++];if(128&m&&(h+=2),64&m&&(h+=c[h++]),4!==c[h++])break;h=cN(c,h);var f=c[h++];if(64!==f)break;if(r+="."+hN(f),h+=12,5!==c[h++])break;h=cN(c,h);var v=c[h++],p=(248&v)>>3;31===p&&(p+=1+((7&v)<<3)+((224&c[h])>>5)),r+="."+p}break;case"hvc1":case"hev1":var g=oN(i,["hvcC"])[0];if(g&&g.length>12){var y=g[1],b=["","A","B","C"][y>>6],w=31&y,k=iN(g,2),S=(32&y)>>5?"H":"L",E=g[12],P=g.subarray(6,12);r+="."+b+w,r+="."+function(e){for(var t=0,n=0;n<32;n++)t|=(e>>n&1)<<31-n;return t>>>0}(k).toString(16).toUpperCase(),r+="."+S+E;for(var T="",_=P.length;_--;){var M=P[_];if(M||T)T="."+M.toString(16).toUpperCase()+T}r+=T}t=dN("hev1"==u?"dvhe":"dvh1",i);break;case"dvh1":case"dvhe":case"dvav":case"dva1":case"dav1":r=dN(r,i)||r;break;case"vp09":var A=oN(i,["vpcC"])[0];if(A&&A.length>6){var D=A[4],x=A[5],C=A[6]>>4&15;r+="."+mN(D)+"."+mN(x)+"."+mN(C)}break;case"av01":var I=oN(i,["av1C"])[0];if(I&&I.length>2){var L=I[1]>>>5,R=31&I[1],F=I[2]>>>7?"H":"M",O=(64&I[2])>>6,$=(32&I[2])>>5,N=2===L&&O?$?12:10:O?10:8,W=(16&I[2])>>4,j=(8&I[2])>>3,B=(4&I[2])>>2,z=3&I[2];r+="."+L+"."+mN(R)+F+"."+mN(N)+"."+W+"."+j+B+z+"."+mN(1)+"."+mN(1)+"."+mN(1)+".0",t=dN("dav1",i)}}return{codec:r,encrypted:o,supplemental:t}}function dN(e,t){var n=oN(t,["dvvC"]),i=n.length?n[0]:oN(t,["dvcC"])[0];if(i){var a=i[2]>>1&127,r=i[2]<<5&32|i[3]>>3&31;return e+"."+mN(a)+"."+mN(r)}}function cN(e,t){for(var n=t+5;128&e[t++]&&t<n;);return t}function hN(e){return("0"+e.toString(16).toUpperCase()).slice(-2)}function mN(e){return(e<10?"0":"")+e}function fN(e,t){oN(e,["moov","trak"]).forEach(e=>{var n=oN(e,["mdia","minf","stbl","stsd"])[0];if(n){var i=n.subarray(8),a=oN(i,["enca"]),r=a.length>0;r||(a=oN(i,["encv"])),a.forEach(e=>{oN(r?e.subarray(28):e.subarray(78),["sinf"]).forEach(e=>{var n=vN(e);n&&t(n,r)})})}})}function vN(e){var t=oN(e,["schm"])[0];if(t){var n=tN(t.subarray(4,8));if("cbcs"===n||"cenc"===n){var i=oN(e,["schi","tenc"])[0];if(i)return i}}}function pN(e,t){var n=new Uint8Array(e.length+t.length);return n.set(e),n.set(t,e.length),n}function gN(e,t){var n=[],i=t.samples,a=t.timescale,r=t.id,o=!1;return oN(i,["moof"]).map(s=>{var u=s.byteOffset-8;oN(s,["traf"]).map(s=>{var l=oN(s,["tfdt"]).map(e=>{var t=e[0],n=iN(e,4);return 1===t&&(n*=Math.pow(2,32),n+=iN(e,8)),n/a})[0];return void 0!==l&&(e=l),oN(s,["tfhd"]).map(l=>{var d=iN(l,4),c=16777215&iN(l,0),h=0,m=!!(16&c),f=0,v=!!(32&c),p=8;d===r&&(!!(1&c)&&(p+=8),!!(2&c)&&(p+=4),!!(8&c)&&(h=iN(l,p),p+=4),m&&(f=iN(l,p),p+=4),v&&(p+=4),"video"===t.type&&(o=yN(t.codec)),oN(s,["trun"]).map(r=>{var s=r[0],l=16777215&iN(r,0),d=!!(1&l),c=0,m=!!(4&l),v=!!(256&l),p=0,g=!!(512&l),y=0,b=!!(1024&l),w=!!(2048&l),k=0,S=iN(r,4),E=8;d&&(c=iN(r,E),E+=4),m&&(E+=4);for(var P=c+u,T=0;T<S;T++){if(v?(p=iN(r,E),E+=4):p=h,g?(y=iN(r,E),E+=4):y=f,b&&(E+=4),w&&(k=0===s?iN(r,E):rN(r,E),E+=4),t.type===G$)for(var _=0;_<y;){var M=iN(i,P);if(bN(o,i[P+=4]))wN(i.subarray(P,P+M),o?2:1,e+k/a,n);P+=M,_+=M+4}e+=p/a}}))})})}),n}function yN(e){if(!e)return!1;var t=e.substring(0,4);return"hvc1"===t||"hev1"===t||"dvh1"===t||"dvhe"===t}function bN(e,t){if(e){var n=t>>1&63;return 39===n||40===n}return 6===(31&t)}function wN(e,t,n,i){var a=kN(e),r=0;r+=t;for(var o=0,s=0,u=0;r<a.length;){o=0;do{if(r>=a.length)break;o+=u=a[r++]}while(255===u);s=0;do{if(r>=a.length)break;s+=u=a[r++]}while(255===u);var l=a.length-r,d=r;if(s<l)r+=s;else if(s>l){L$.error(`Malformed SEI payload. ${s} is too small, only ${l} bytes left to parse.`);break}if(4===o){if(181===a[d++]){var c=nN(a,d);if(d+=2,49===c){var h=iN(a,d);if(d+=4,1195456820===h){var m=a[d++];if(3===m){var f=a[d++],v=64&f,p=v?2+3*(31&f):0,g=new Uint8Array(p);if(v){g[0]=f;for(var y=1;y<p;y++)g[y]=a[d++]}i.push({type:m,payloadType:o,pts:n,bytes:g})}}}}}else if(5===o&&s>16){for(var b=[],w=0;w<16;w++){var k=a[d++].toString(16);b.push(1==k.length?"0"+k:k),3!==w&&5!==w&&7!==w&&9!==w||b.push("-")}for(var S=s-16,E=new Uint8Array(S),P=0;P<S;P++)E[P]=a[d++];i.push({payloadType:o,pts:n,uuid:b.join(""),userData:O$(E),userDataBytes:E})}}}function kN(e){for(var t=e.byteLength,n=[],i=1;i<t-2;)0===e[i]&&0===e[i+1]&&3===e[i+2]?(n.push(i+2),i+=2):i++;if(0===n.length)return e;var a=t-n.length,r=new Uint8Array(a),o=0;for(i=0;i<a;o++,i++)o===n[0]&&(o++,n.shift()),r[i]=e[o];return r}function SN(e,t,n){if(16!==e.byteLength)throw new RangeError("Invalid system id");var i,a;i=new Uint8Array,a=new Uint8Array;var r=new Uint8Array(4);return n.byteLength>0&&new DataView(r.buffer).setUint32(0,n.byteLength,!1),function(e,...t){for(var n=t.length,i=8,a=n;a--;)i+=t[a].byteLength;var 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(e,4),a=0,i=8;a<n;a++)r.set(t[a],i),i+=t[a].byteLength;return r}([112,115,115,104],new Uint8Array([0,0,0,0]),e,a,i,r,n)}function EN(e){var t=e.getUint32(0),n=e.byteOffset,i=e.byteLength;if(i<t)return{offset:n,size:i};if(1886614376!==e.getUint32(4))return{offset:n,size:t};var a=e.getUint32(8)>>>24;if(0!==a&&1!==a)return{offset:n,size:t};var r=e.buffer,o=$$(new Uint8Array(r,n+12,16)),s=null,u=0;if(0===a)u=28;else{var l=e.getUint32(28);if(!l||i<32+16*l)return{offset:n,size:t};s=[];for(var d=0;d<l;d++)s.push(new Uint8Array(r,n+32+16*d,16));u=32+16*l}if(!u)return{offset:n,size:t};var c=e.getUint32(u);return t-32<c?{offset:n,size:t}:{version:a,systemId:o,kids:s,data:new Uint8Array(r,n+u+4,c),offset:n,size:t}}var PN=()=>/\(Windows.+Firefox\//i.test(navigator.userAgent),TN={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 _N(e,t){var n=TN[t];return!!n&&!!n[e.slice(0,4)]}function MN(e,t,n=!0){return!e.split(",").some(e=>!AN(e,t,n))}function AN(e,t,n=!0){var i,a=R$(n);return null!=(i=null==a?void 0:a.isTypeSupported(DN(e,t)))&&i}function DN(e,t){return`${t}/mp4;codecs=${e}`}function xN(e){if(e){var t=e.substring(0,4);return TN.video[t]}return 2}function CN(e){var t=PN();return e.split(",").reduce((e,n)=>{var i=t&&yN(n)?9:TN.video[n];return i?(2*i+e)/(e?3:2):(TN.audio[n]+e)/(e?2:1)},0)}var IN={};var LN=/flac|opus|mp4a\.40\.34/i;function RN(e,t=!0){return e.replace(LN,e=>function(e,t=!0){if(IN[e])return IN[e];for(var n={flac:["flac","fLaC","FLAC"],opus:["opus","Opus"],"mp4a.40.34":["mp3"]}[e],i=0;i<n.length;i++){var a;if(AN(n[i],"audio",t))return IN[e]=n[i],n[i];if("mp3"===n[i]&&null!=(a=R$(t))&&a.isTypeSupported("audio/mpeg"))return""}return e}(e.toLowerCase(),t))}function FN(e,t){if(e&&(e.length>4||-1!==["ac-3","ec-3","alac","fLaC","Opus"].indexOf(e))&&(ON(e,"audio")||ON(e,"video")))return e;if(t){var n=t.split(",");if(n.length>1){if(e)for(var i=n.length;i--;)if(n[i].substring(0,4)===e.substring(0,4))return n[i];return n[0]}}return t||e}function ON(e,t){return _N(e,t)&&AN(e,t)}function $N(e){if(e.startsWith("av01.")){for(var t=e.split("."),n=["0","111","01","01","01","0"],i=t.length;i>4&&i<10;i++)t[i]=n[i-4];return t.join(".")}return e}function NN(e){var t=R$(e)||{isTypeSupported:()=>!1};return{mpeg:t.isTypeSupported("audio/mpeg"),mp3:t.isTypeSupported('audio/mp4; codecs="mp3"'),ac3:t.isTypeSupported('audio/mp4; codecs="ac-3"')}}function WN(e){return e.replace(/^.+codecs=["']?([^"']+).*$/,"$1")}var jN={supported:!1,smooth:!1,powerEfficient:!1},BN={supported:!0,configurations:[],decodingInfoResults:[{supported:!0,powerEfficient:!0,smooth:!0}]};function zN(e,t){return{supported:!1,configurations:t,decodingInfoResults:[jN],error:e}}function UN(e,t,n,i={}){var a=e.videoCodec;if(!a&&!e.audioCodec||!n)return Promise.resolve(BN);for(var r=[],o=function(e){var t,n=null==(t=e.videoCodec)?void 0:t.split(","),i=GN(e),a=e.width||640,r=e.height||480,o=e.frameRate||30,s=e.videoRange.toLowerCase();return n?n.map(e=>{var t={contentType:DN($N(e),"video"),width:a,height:r,bitrate:i,framerate:o};return"sdr"!==s&&(t.transferFunction=s),t}):[]}(e),s=o.length,u=function(e,t,n){var i,a=null==(i=e.audioCodec)?void 0:i.split(","),r=GN(e);if(a&&e.audioGroups)return e.audioGroups.reduce((e,i)=>{var o,s=i?null==(o=t.groups[i])?void 0:o.tracks:null;return s?s.reduce((e,t)=>{if(t.groupId===i){var o=parseFloat(t.channels||"");a.forEach(t=>{var i={contentType:DN(t,"audio"),bitrate:n?HN(t,r):r};o&&(i.channels=""+o),e.push(i)})}return e},e):e},[]);return[]}(e,t,s>0),l=u.length,d=s||1*l||1;d--;){var c={type:"media-source"};if(s&&(c.video=o[d%s]),l){c.audio=u[d%l];var h=c.audio.bitrate;c.video&&h&&(c.video.bitrate-=h)}r.push(c)}if(a){var m=navigator.userAgent;if(a.split(",").some(e=>yN(e))&&PN())return Promise.resolve(zN(new Error(`Overriding Windows Firefox HEVC MediaCapabilities result based on user-agent string: (${m})`),r))}return Promise.all(r.map(e=>{var t=function(e){var t="",n=e.audio,i=e.video;if(i){t+=`${WN(i.contentType)}_r${i.height}x${i.width}f${Math.ceil(i.framerate)}${i.transferFunction||"sd"}_${Math.ceil(i.bitrate/1e5)}`}if(n){t+=`${i?"_":""}${WN(n.contentType)}_c${n.channels}`}return t}(e);return i[t]||(i[t]=n.decodingInfo(e))})).then(e=>({supported:!e.some(e=>!e.supported),configurations:r,decodingInfoResults:e})).catch(e=>({supported:!1,configurations:r,decodingInfoResults:[],error:e}))}function HN(e,t){if(t<=1)return 1;var n=128e3;return"ec-3"===e?n=768e3:"ac-3"===e&&(n=64e4),Math.min(t/2,n)}function GN(e){return 1e3*Math.ceil(Math.max(.9*e.bitrate,e.averageBitrate)/1e3)||1}var VN=["NONE","TYPE-0","TYPE-1",null];var KN=["SDR","PQ","HLG"];var XN="",YN="YES",qN="v2";function JN(e){var t=e.canSkipUntil,n=e.canSkipDateRanges,i=e.age;return t&&i<t/2?n?qN:YN:XN}var QN=function(){return c(function e(t,n,i){o(this,e),this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=t,this.part=n,this.skip=i},[{key:"addDirectives",value:function(e){var t=new self.URL(e);return void 0!==this.msn&&t.searchParams.set("_HLS_msn",this.msn.toString()),void 0!==this.part&&t.searchParams.set("_HLS_part",this.part.toString()),this.skip&&t.searchParams.set("_HLS_skip",this.skip),t.href}}])}(),ZN=function(){return c(function e(t){if(o(this,e),this._attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.url=void 0,this.frameRate=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.supplemental=void 0,this.videoCodec=void 0,this.width=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.supportedPromise=void 0,this.supportedResult=void 0,this._avgBitrate=0,this._audioGroups=void 0,this._subtitleGroups=void 0,this._urlId=0,this.url=[t.url],this._attrs=[t.attrs],this.bitrate=t.bitrate,t.details&&(this.details=t.details),this.id=t.id||0,this.name=t.name,this.width=t.width||0,this.height=t.height||0,this.frameRate=t.attrs.optionalFloat("FRAME-RATE",0),this._avgBitrate=t.attrs.decimalInteger("AVERAGE-BANDWIDTH"),this.audioCodec=t.audioCodec,this.videoCodec=t.videoCodec,this.codecSet=[t.videoCodec,t.audioCodec].filter(e=>!!e).map(e=>e.substring(0,4)).join(","),"supplemental"in t){var n;this.supplemental=t.supplemental;var i=null==(n=t.supplemental)?void 0:n.videoCodec;i&&i!==t.videoCodec&&(this.codecSet+=`,${i.substring(0,4)}`)}this.addGroupId("audio",t.attrs.AUDIO),this.addGroupId("text",t.attrs.SUBTITLES)},[{key:"maxBitrate",get:function(){return Math.max(this.realBitrate,this.bitrate)}},{key:"averageBitrate",get:function(){return this._avgBitrate||this.realBitrate||this.bitrate}},{key:"attrs",get:function(){return this._attrs[0]}},{key:"codecs",get:function(){return this.attrs.CODECS||""}},{key:"pathwayId",get:function(){return this.attrs["PATHWAY-ID"]||"."}},{key:"videoRange",get:function(){return this.attrs["VIDEO-RANGE"]||"SDR"}},{key:"score",get:function(){return this.attrs.optionalFloat("SCORE",0)}},{key:"uri",get:function(){return this.url[0]||""}},{key:"hasAudioGroup",value:function(e){return eW(this._audioGroups,e)}},{key:"hasSubtitleGroup",value:function(e){return eW(this._subtitleGroups,e)}},{key:"audioGroups",get:function(){return this._audioGroups}},{key:"subtitleGroups",get:function(){return this._subtitleGroups}},{key:"addGroupId",value:function(e,t){if(t)if("audio"===e){var n=this._audioGroups;n||(n=this._audioGroups=[]),-1===n.indexOf(t)&&n.push(t)}else if("text"===e){var i=this._subtitleGroups;i||(i=this._subtitleGroups=[]),-1===i.indexOf(t)&&i.push(t)}}},{key:"urlId",get:function(){return 0},set:function(e){}},{key:"audioGroupIds",get:function(){return this.audioGroups?[this.audioGroupId]:void 0}},{key:"textGroupIds",get:function(){return this.subtitleGroups?[this.textGroupId]:void 0}},{key:"audioGroupId",get:function(){var e;return null==(e=this.audioGroups)?void 0:e[0]}},{key:"textGroupId",get:function(){var e;return null==(e=this.subtitleGroups)?void 0:e[0]}},{key:"addFallback",value:function(){}}])}();function eW(e,t){return!(!t||!e)&&-1!==e.indexOf(t)}function tW(e,t){var n=!1,i=[];if(e&&(n="SDR"!==e,i=[e]),t){var a="SDR"!==(i=t.allowedVideoRanges||KN.slice(0)).join("")&&!t.videoCodec;(n=void 0!==t.preferHDR?t.preferHDR:a&&function(){if("function"==typeof matchMedia){var e=matchMedia("(dynamic-range: high)"),t=matchMedia("bad query");if(e.media!==t.media)return!0===e.matches}return!1}())||(i=["SDR"])}return{preferHDR:n,allowedVideoRanges:i}}var nW=(e,t)=>JSON.stringify(e,(e=>{var t=new WeakSet;return(n,i)=>{if(e&&(i=e(n,i)),"object"==typeof i&&null!==i){if(t.has(i))return;t.add(i)}return i}})(t));function iW(e,t){L$.log(`[abr] start candidates with "${e}" ignored because ${t}`)}function aW(e){return e.reduce((e,t)=>{var n=e.groups[t.groupId];n||(n=e.groups[t.groupId]={tracks:[],channels:{2:0},hasDefault:!1,hasAutoSelect:!1}),n.tracks.push(t);var i=t.channels||"2";return n.channels[i]=(n.channels[i]||0)+1,n.hasDefault=n.hasDefault||t.default,n.hasAutoSelect=n.hasAutoSelect||t.autoselect,n.hasDefault&&(e.hasDefaultAudio=!0),n.hasAutoSelect&&(e.hasAutoSelectAudio=!0),e},{hasDefaultAudio:!1,hasAutoSelectAudio:!1,groups:{}})}function rW(e){return e?{lang:e.lang,assocLang:e.assocLang,characteristics:e.characteristics,channels:e.channels,audioCodec:e.audioCodec}:e}function oW(e,t,n){if("attrs"in e){var i=t.indexOf(e);if(-1!==i)return i}for(var a=0;a<t.length;a++){if(sW(e,t[a],n))return a}return-1}function sW(e,t,n){var i=e.groupId,a=e.name,r=e.lang,o=e.assocLang,s=e.default,u=e.forced;return(void 0===i||t.groupId===i)&&(void 0===a||t.name===a)&&(void 0===r||function(e,t="--"){if(e.length===t.length)return e===t;return e.startsWith(t)||t.startsWith(e)}(r,t.lang))&&(void 0===r||t.assocLang===o)&&(void 0===s||t.default===s)&&(void 0===u||t.forced===u)&&(!("characteristics"in e)||function(e,t=""){var n=e.split(","),i=t.split(",");return n.length===i.length&&!n.some(e=>-1===i.indexOf(e))}(e.characteristics||"",t.characteristics))&&(void 0===n||n(e,t))}function uW(e,t){var n=e.audioCodec,i=e.channels;return!(void 0!==n&&(t.audioCodec||"").substring(0,4)!==n.substring(0,4)||void 0!==i&&i!==(t.channels||"2"))}function lW(e,t,n){for(var i=t;i>-1;i--)if(n(e[i]))return i;for(var a=t+1;a<e.length;a++)if(n(e[a]))return a;return-1}function dW(e,t){var n;return!!e&&e!==(null==(n=t.loadLevelObj)?void 0:n.uri)}var cW=function(e){function t(e){var n;return o(this,t),(n=r(this,t,["abr",e.logger])).hls=void 0,n.lastLevelLoadSec=0,n.lastLoadedFragLevel=-1,n.firstSelection=-1,n._nextAutoLevel=-1,n.nextAutoLevelKey="",n.audioTracksByGroup=null,n.codecTiers=null,n.timer=-1,n.fragCurrent=null,n.partCurrent=null,n.bitrateTestDelay=0,n.rebufferNotice=-1,n.supportedCache={},n.bwEstimator=void 0,n._abandonRulesCheck=e=>{var t,i=n,a=i.fragCurrent,r=i.partCurrent,o=i.hls,s=o.autoLevelEnabled,u=o.media;if(a&&u){var l=performance.now(),d=r?r.stats:a.stats,c=r?r.duration:a.duration,h=l-d.loading.start,m=o.minAutoLevel,f=a.level,v=n._nextAutoLevel;if(d.aborted||d.loaded&&d.loaded===d.total||f<=m)return n.clearTimer(),void(n._nextAutoLevel=-1);if(s){var p=v>-1&&v!==f,g=!!e||p;if(g||!u.paused&&u.playbackRate&&u.readyState){var y=o.mainForwardBufferInfo;if(g||null!==y){var b=n.bwEstimator.getEstimateTTFB(),w=Math.abs(u.playbackRate);if(!(h<=Math.max(b,c/(2*w)*1e3))){var k=y?y.len/w:0,S=d.loading.first?d.loading.first-d.loading.start:-1,E=d.loaded&&S>-1,P=n.getBwEstimate(),T=o.levels,_=T[f],M=Math.max(d.loaded,Math.round(c*(a.bitrate||_.averageBitrate)/8)),A=E?h-S:h;A<1&&E&&(A=Math.min(h,8*d.loaded/P));var D=E?1e3*d.loaded/A:0,x=b/1e3,C=D?(M-d.loaded)/D:8*M/P+x;if(!(C<=k)){var I,L=D?8*D:P,R=!0===(null==(t=(null==e?void 0:e.details)||n.hls.latestLevelDetails)?void 0:t.live),F=n.hls.config.abrBandWidthUpFactor,O=Number.POSITIVE_INFINITY;for(I=f-1;I>m;I--){var $=T[I].maxBitrate,N=!T[I].details||R;if((O=n.getTimeToLoadFrag(x,L,c*$,N))<Math.min(k,c+x))break}if(!(O>=C||O>10*c)){E?n.bwEstimator.sample(h-Math.min(b,S),d.loaded):n.bwEstimator.sampleTTFB(h);var W=T[I].maxBitrate;n.getBwEstimate()*F>W&&n.resetEstimator(W);var j=n.findBestLevel(W,m,I,0,k,1,1);j>-1&&(I=j),n.warn(`Fragment ${a.sn}${r?" part "+r.index:""} of level ${f} is loading too slowly;\n Fragment duration: ${a.duration.toFixed(3)}\n Time to underbuffer: ${k.toFixed(3)} s\n Estimated load time for current fragment: ${C.toFixed(3)} s\n Estimated load time for down switch fragment: ${O.toFixed(3)} s\n TTFB estimate: ${0|S} ms\n Current BW estimate: ${u$(P)?0|P:"Unknown"} bps\n New BW estimate: ${0|n.getBwEstimate()} bps\n Switching to level ${I} @ ${0|W} bps`),o.nextLoadLevel=o.nextAutoLevel=I,n.clearTimer();var B=()=>{if(n.clearTimer(),n.fragCurrent===a&&n.hls.loadLevel===I&&I>0){var e=n.getStarvationDelay();if(n.warn(`Aborting inflight request ${I>0?"and switching down":""}\n Fragment duration: ${a.duration.toFixed(3)} s\n Time to underbuffer: ${e.toFixed(3)} s`),a.abortRequests(),n.fragCurrent=n.partCurrent=null,I>m){var t=n.findBestLevel(n.hls.levels[m].bitrate,m,I,0,e,1,1);-1===t&&(t=m),n.hls.nextLoadLevel=n.hls.nextAutoLevel=t,n.resetEstimator(n.hls.levels[t].bitrate)}}};p||C>2*O?B():n.timer=self.setInterval(B,1e3*O),o.trigger(m$.FRAG_LOAD_EMERGENCY_ABORTED,{frag:a,part:r,stats:d})}}}}}}}},n.hls=e,n.bwEstimator=n.initEstimator(),n.registerListeners(),n}return p(t,e),c(t,[{key:"resetEstimator",value:function(e){e&&(this.log(`setting initial bwe to ${e}`),this.hls.config.abrEwmaDefaultEstimate=e),this.firstSelection=-1,this.bwEstimator=this.initEstimator()}},{key:"initEstimator",value:function(){var e=this.hls.config;return new S$(e.abrEwmaSlowVoD,e.abrEwmaFastVoD,e.abrEwmaDefaultEstimate)}},{key:"registerListeners",value:function(){var e=this.hls;e.on(m$.MANIFEST_LOADING,this.onManifestLoading,this),e.on(m$.FRAG_LOADING,this.onFragLoading,this),e.on(m$.FRAG_LOADED,this.onFragLoaded,this),e.on(m$.FRAG_BUFFERED,this.onFragBuffered,this),e.on(m$.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(m$.LEVEL_LOADED,this.onLevelLoaded,this),e.on(m$.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(m$.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.on(m$.ERROR,this.onError,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e&&(e.off(m$.MANIFEST_LOADING,this.onManifestLoading,this),e.off(m$.FRAG_LOADING,this.onFragLoading,this),e.off(m$.FRAG_LOADED,this.onFragLoaded,this),e.off(m$.FRAG_BUFFERED,this.onFragBuffered,this),e.off(m$.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(m$.LEVEL_LOADED,this.onLevelLoaded,this),e.off(m$.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(m$.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.off(m$.ERROR,this.onError,this))}},{key:"destroy",value:function(){this.unregisterListeners(),this.clearTimer(),this.hls=this._abandonRulesCheck=this.supportedCache=null,this.fragCurrent=this.partCurrent=null}},{key:"onManifestLoading",value:function(e,t){this.lastLoadedFragLevel=-1,this.firstSelection=-1,this.lastLevelLoadSec=0,this.supportedCache={},this.fragCurrent=this.partCurrent=null,this.onLevelsUpdated(),this.clearTimer()}},{key:"onLevelsUpdated",value:function(){this.lastLoadedFragLevel>-1&&this.fragCurrent&&(this.lastLoadedFragLevel=this.fragCurrent.level),this._nextAutoLevel=-1,this.onMaxAutoLevelUpdated(),this.codecTiers=null,this.audioTracksByGroup=null}},{key:"onMaxAutoLevelUpdated",value:function(){this.firstSelection=-1,this.nextAutoLevelKey=""}},{key:"onFragLoading",value:function(e,t){var n=t.frag;if(!this.ignoreFragment(n)){var i;if(!n.bitrateTest)this.fragCurrent=n,this.partCurrent=null!=(i=t.part)?i:null;this.clearTimer(),this.timer=self.setInterval(this._abandonRulesCheck,100)}}},{key:"onLevelSwitching",value:function(e,t){this.clearTimer()}},{key:"onError",value:function(e,t){if(!t.fatal)switch(t.details){case h$.BUFFER_ADD_CODEC_ERROR:case h$.BUFFER_APPEND_ERROR:this.lastLoadedFragLevel=-1,this.firstSelection=-1;break;case h$.FRAG_LOAD_TIMEOUT:var n=t.frag,i=this.fragCurrent,a=this.partCurrent;if(n&&i&&n.sn===i.sn&&n.level===i.level){var r=performance.now(),o=a?a.stats:n.stats,s=r-o.loading.start,u=o.loading.first?o.loading.first-o.loading.start:-1;if(o.loaded&&u>-1){var l=this.bwEstimator.getEstimateTTFB();this.bwEstimator.sample(s-Math.min(l,u),o.loaded)}else this.bwEstimator.sampleTTFB(s)}}}},{key:"getTimeToLoadFrag",value:function(e,t,n,i){return e+n/t+(i?e+this.lastLevelLoadSec:0)}},{key:"onLevelLoaded",value:function(e,t){var n=this.hls.config,i=t.stats.loading,a=i.end-i.first;u$(a)&&(this.lastLevelLoadSec=a/1e3),t.details.live?this.bwEstimator.update(n.abrEwmaSlowLive,n.abrEwmaFastLive):this.bwEstimator.update(n.abrEwmaSlowVoD,n.abrEwmaFastVoD),this.timer>-1&&this._abandonRulesCheck(t.levelInfo)}},{key:"onFragLoaded",value:function(e,{frag:t,part:n}){var i=n?n.stats:t.stats;if(t.type===y$&&this.bwEstimator.sampleTTFB(i.loading.first-i.loading.start),!this.ignoreFragment(t)){if(this.clearTimer(),t.level===this._nextAutoLevel&&(this._nextAutoLevel=-1),this.firstSelection=-1,this.hls.config.abrMaxWithRealBitrate){var a=n?n.duration:t.duration,r=this.hls.levels[t.level],o=(r.loaded?r.loaded.bytes:0)+i.loaded,s=(r.loaded?r.loaded.duration:0)+a;r.loaded={bytes:o,duration:s},r.realBitrate=Math.round(8*o/s)}if(t.bitrateTest){var u={stats:i,frag:t,part:n,id:t.type};this.onFragBuffered(m$.FRAG_BUFFERED,u),t.bitrateTest=!1}else this.lastLoadedFragLevel=t.level}}},{key:"onFragBuffered",value:function(e,t){var n=t.frag,i=t.part,a=null!=i&&i.stats.loaded?i.stats:n.stats;if(!a.aborted&&!this.ignoreFragment(n)){var r=a.parsing.end-a.loading.start-Math.min(a.loading.first-a.loading.start,this.bwEstimator.getEstimateTTFB());this.bwEstimator.sample(r,a.loaded),a.bwEstimate=this.getBwEstimate(),n.bitrateTest?this.bitrateTestDelay=r/1e3:this.bitrateTestDelay=0}}},{key:"ignoreFragment",value:function(e){return e.type!==y$||"initSegment"===e.sn}},{key:"clearTimer",value:function(){this.timer>-1&&(self.clearInterval(this.timer),this.timer=-1)}},{key:"firstAutoLevel",get:function(){var e=this.hls,t=e.maxAutoLevel,n=e.minAutoLevel,i=this.getBwEstimate(),a=this.hls.config.maxStarvationDelay,r=this.findBestLevel(i,n,t,0,a,1,1);if(r>-1)return r;var o=this.hls.firstLevel,s=Math.min(Math.max(o,n),t);return this.warn(`Could not find best starting auto level. Defaulting to first in playlist ${o} clamped to ${s}`),s}},{key:"forcedAutoLevel",get:function(){return this.nextAutoLevelKey?-1:this._nextAutoLevel}},{key:"nextAutoLevel",get:function(){var e=this.forcedAutoLevel,t=this.bwEstimator.canEstimate(),n=this.lastLoadedFragLevel>-1;if(!(-1===e||t&&n&&this.nextAutoLevelKey!==this.getAutoLevelKey()))return e;var i=t&&n?this.getNextABRAutoLevel():this.firstAutoLevel;if(-1!==e){var a=this.hls.levels;if(a.length>Math.max(e,i)&&a[e].loadError<=a[i].loadError)return e}return this._nextAutoLevel=i,this.nextAutoLevelKey=this.getAutoLevelKey(),i},set:function(e){var t=this.deriveNextAutoLevel(e);this._nextAutoLevel!==t&&(this.nextAutoLevelKey="",this._nextAutoLevel=t)}},{key:"getAutoLevelKey",value:function(){return`${this.getBwEstimate()}_${this.getStarvationDelay().toFixed(2)}`}},{key:"getNextABRAutoLevel",value:function(){var e=this.fragCurrent,t=this.partCurrent,n=this.hls;if(n.levels.length<=1)return n.loadLevel;var i=n.maxAutoLevel,a=n.config,r=n.minAutoLevel,o=t?t.duration:e?e.duration:0,s=this.getBwEstimate(),u=this.getStarvationDelay(),l=a.abrBandWidthFactor,d=a.abrBandWidthUpFactor;if(u){var c=this.findBestLevel(s,r,i,u,0,l,d);if(c>=0)return this.rebufferNotice=-1,c}var h=o?Math.min(o,a.maxStarvationDelay):a.maxStarvationDelay;if(!u){var m=this.bitrateTestDelay;if(m)h=(o?Math.min(o,a.maxLoadingDelay):a.maxLoadingDelay)-m,this.info(`bitrate test took ${Math.round(1e3*m)}ms, set first fragment max fetchDuration to ${Math.round(1e3*h)} ms`),l=d=1}var f=this.findBestLevel(s,r,i,u,h,l,d);if(this.rebufferNotice!==f&&(this.rebufferNotice=f,this.info(`${u?"rebuffering expected":"buffer is empty"}, optimal quality level ${f}`)),f>-1)return f;var v=n.levels[r],p=n.loadLevelObj;return p&&(null==v?void 0:v.bitrate)<p.bitrate?r:n.loadLevel}},{key:"getStarvationDelay",value:function(){var e=this.hls,t=e.media;if(!t)return 1/0;var n=t&&0!==t.playbackRate?Math.abs(t.playbackRate):1,i=e.mainForwardBufferInfo;return(i?i.len:0)/n}},{key:"getBwEstimate",value:function(){return this.bwEstimator.canEstimate()?this.bwEstimator.getEstimate():this.hls.config.abrEwmaDefaultEstimate}},{key:"findBestLevel",value:function(e,t,n,i,a,r,o){var s,u=this,l=i+a,d=this.lastLoadedFragLevel,c=-1===d?this.hls.firstLevel:d,h=this.fragCurrent,m=this.partCurrent,f=this.hls,v=f.levels,p=f.allAudioTracks,g=f.loadLevel,y=f.config;if(1===v.length)return 0;var b,w=v[c],k=!(null==(s=this.hls.latestLevelDetails)||!s.live),S=-1===g||-1===d,E="SDR",P=(null==w?void 0:w.frameRate)||0,T=y.audioPreference,_=y.videoPreference,M=this.audioTracksByGroup||(this.audioTracksByGroup=aW(p)),A=-1;if(S){if(-1!==this.firstSelection)return this.firstSelection;var D=this.codecTiers||(this.codecTiers=function(e,t,n,i){return e.slice(n,i+1).reduce((e,n,i)=>{if(!n.codecSet)return e;var a=n.audioGroups,r=e[n.codecSet];r||(e[n.codecSet]=r={minBitrate:1/0,minHeight:1/0,minFramerate:1/0,minIndex:i,maxScore:0,videoRanges:{SDR:0},channels:{2:0},hasDefaultAudio:!a,fragmentError:0}),r.minBitrate=Math.min(r.minBitrate,n.bitrate);var o=Math.min(n.height,n.width);return r.minHeight=Math.min(r.minHeight,o),r.minFramerate=Math.min(r.minFramerate,n.frameRate),r.minIndex=Math.min(r.minIndex,i),r.maxScore=Math.max(r.maxScore,n.score),r.fragmentError+=n.fragmentError,r.videoRanges[n.videoRange]=(r.videoRanges[n.videoRange]||0)+1,a&&a.forEach(e=>{if(e){var n=t.groups[e];n&&(r.hasDefaultAudio=r.hasDefaultAudio||t.hasDefaultAudio?n.hasDefault:n.hasAutoSelect||!t.hasDefaultAudio&&!t.hasAutoSelectAudio,Object.keys(n.channels).forEach(e=>{r.channels[e]=(r.channels[e]||0)+n.channels[e]}))}}),e},{})}(v,M,t,n)),x=function(e,t,n,i,a){for(var r=Object.keys(e),o=null==i?void 0:i.channels,s=null==i?void 0:i.audioCodec,u=null==a?void 0:a.videoCodec,l=o&&2===parseInt(o),d=!1,c=!1,h=1/0,m=1/0,f=1/0,v=1/0,p=0,g=[],y=tW(t,a),b=y.preferHDR,w=y.allowedVideoRanges,k=function(){var t=e[r[S]];d||(d=t.channels[2]>0),h=Math.min(h,t.minHeight),m=Math.min(m,t.minFramerate),f=Math.min(f,t.minBitrate),w.filter(e=>t.videoRanges[e]>0).length>0&&(c=!0)},S=r.length;S--;)k();h=u$(h)?h:0,m=u$(m)?m:0;var E=Math.max(1080,h),P=Math.max(30,m);f=u$(f)?f:n,n=Math.max(f,n),c||(t=void 0);var T=r.length>1;return{codecSet:r.reduce((t,i)=>{var a=e[i];if(i===t)return t;if(g=c?w.filter(e=>a.videoRanges[e]>0):[],T){if(a.minBitrate>n)return iW(i,`min bitrate of ${a.minBitrate} > current estimate of ${n}`),t;if(!a.hasDefaultAudio)return iW(i,"no renditions with default or auto-select sound found"),t;if(s&&i.indexOf(s.substring(0,4))%5!=0)return iW(i,`audio codec preference "${s}" not found`),t;if(o&&!l){if(!a.channels[o])return iW(i,`no renditions with ${o} channel sound found (channels options: ${Object.keys(a.channels)})`),t}else if((!s||l)&&d&&0===a.channels[2])return iW(i,"no renditions with stereo sound found"),t;if(a.minHeight>E)return iW(i,`min resolution of ${a.minHeight} > maximum of ${E}`),t;if(a.minFramerate>P)return iW(i,`min framerate of ${a.minFramerate} > maximum of ${P}`),t;if(!g.some(e=>a.videoRanges[e]>0))return iW(i,`no variants with VIDEO-RANGE of ${nW(g)} found`),t;if(u&&i.indexOf(u.substring(0,4))%5!=0)return iW(i,`video codec preference "${u}" not found`),t;if(a.maxScore<p)return iW(i,`max score of ${a.maxScore} < selected max of ${p}`),t}return t&&(CN(i)>=CN(t)||a.fragmentError>e[t].fragmentError)?t:(v=a.minIndex,p=a.maxScore,i)},void 0),videoRanges:g,preferHDR:b,minFramerate:m,minBitrate:f,minIndex:v}}(D,E,e,T,_),C=x.codecSet,I=x.videoRanges,L=x.minFramerate,R=x.minBitrate,F=x.minIndex,O=x.preferHDR;A=F,b=C,E=O?I[I.length-1]:I[0],P=L,e=Math.max(e,R),this.log(`picked start tier ${nW(x)}`)}else b=null==w?void 0:w.codecSet,E=null==w?void 0:w.videoRange;for(var $,N,W=m?m.duration:h?h.duration:0,j=this.bwEstimator.getEstimateTTFB()/1e3,B=[],z=function(){var t=v[U],s=U>c;if(!t)return 0;if(y.useMediaCapabilities&&!t.supportedResult&&!t.supportedPromise){var h=navigator.mediaCapabilities;"function"==typeof(null==h?void 0:h.decodingInfo)&&function(e,t,n,i,a,r){var o=e.videoCodec,s=e.audioCodec?e.audioGroups:null,u=null==r?void 0:r.audioCodec,l=null==r?void 0:r.channels,d=l?parseInt(l):u?1/0:2,c=null;if(null!=s&&s.length)try{c=1===s.length&&s[0]?t.groups[s[0]].channels:s.reduce((e,n)=>{if(n){var i=t.groups[n];if(!i)throw new Error(`Audio track group ${n} not found`);Object.keys(i.channels).forEach(t=>{e[t]=(e[t]||0)+i.channels[t]})}return e},{2:0})}catch(e){return!0}return void 0!==o&&(o.split(",").some(e=>yN(e))||e.width>1920&&e.height>1088||e.height>1920&&e.width>1088||e.frameRate>Math.max(i,30)||"SDR"!==e.videoRange&&e.videoRange!==n||e.bitrate>Math.max(a,8e6))||!!c&&u$(d)&&Object.keys(c).some(e=>parseInt(e)>d)}(t,M,E,P,e,T)?(t.supportedPromise=UN(t,M,h,u.supportedCache),t.supportedPromise.then(e=>{if(u.hls){t.supportedResult=e;var n=u.hls.levels,i=n.indexOf(t);e.error?u.warn(`MediaCapabilities decodingInfo error: "${e.error}" for level ${i} ${nW(e)}`):e.supported?e.decodingInfoResults.some(e=>!1===e.smooth||!1===e.powerEfficient)&&u.log(`MediaCapabilities decodingInfo for level ${i} not smooth or powerEfficient: ${nW(e)}`):(u.warn(`Unsupported MediaCapabilities decodingInfo result for level ${i} ${nW(e)}`),i>-1&&n.length>1&&(u.log(`Removing unsupported level ${i}`),u.hls.removeLevel(i),-1===u.hls.loadLevel&&(u.hls.nextLoadLevel=0)))}}).catch(e=>{u.warn(`Error handling MediaCapabilities decodingInfo: ${e}`)})):t.supportedResult=BN}if((b&&t.codecSet!==b||E&&t.videoRange!==E||s&&P>t.frameRate||!s&&P>0&&P<t.frameRate||null!=($=t.supportedResult)&&null!=($=$.decodingInfoResults)&&$.some(e=>!1===e.smooth))&&(!S||U!==A))return B.push(U),0;var f,p=t.details,w=(m?null==p?void 0:p.partTarget:null==p?void 0:p.averagetargetduration)||W;f=s?o*e:r*e;var _=W&&i>=2*W&&0===a?t.averageBitrate:t.maxBitrate,D=u.getTimeToLoadFrag(j,f,_*w,void 0===p);if(f>=_&&(U===d||0===t.loadError&&0===t.fragmentError)&&(D<=j||!u$(D)||k&&!u.bitrateTestDelay||D<l)){var x=u.forcedAutoLevel;return U===g||-1!==x&&x===g||(B.length&&u.trace(`Skipped level(s) ${B.join(",")} of ${n} max with CODECS and VIDEO-RANGE:"${v[B[0]].codecs}" ${v[B[0]].videoRange}; not compatible with "${b}" ${E}`),u.info(`switch candidate:${c}->${U} adjustedbw(${Math.round(f)})-bitrate=${Math.round(f-_)} ttfb:${j.toFixed(1)} avgDuration:${w.toFixed(1)} maxFetchDuration:${l.toFixed(1)} fetchDuration:${D.toFixed(1)} firstSelection:${S} codecSet:${t.codecSet} videoRange:${t.videoRange} hls.loadLevel:${g}`)),S&&(u.firstSelection=U),{v:U}}},U=n;U>=t;U--)if(0!==(N=z())&&N)return N.v;return-1}},{key:"deriveNextAutoLevel",value:function(e){var t=this.hls,n=t.maxAutoLevel,i=t.minAutoLevel;return Math.min(Math.max(e,i),n)}}])}(M$),hW=function(e,t){for(var n=0,i=e.length-1,a=null,r=null;n<=i;){var o=t(r=e[a=(n+i)/2|0]);if(o>0)n=a+1;else{if(!(o<0))return r;i=a-1}}return null};function mW(e,t,n=0,i=0,a=.005){var r=null;if(e){r=t[1+e.sn-t[0].sn]||null;var o=e.endDTS-n;o>0&&o<15e-7&&(n+=15e-7),r&&e.level!==r.level&&r.end<=e.end&&(r=t[2+e.sn-t[0].sn]||null)}else 0===n&&0===t[0].start&&(r=t[0]);if(r&&((!e||e.level===r.level)&&0===fW(n,i,r)||function(e,t,n){if(t&&0===t.start&&t.level<e.level&&(t.endPTS||0)>0){var i=t.tagList.reduce((e,t)=>("INF"===t[0]&&(e+=parseFloat(t[1])),e),n);return e.start<=i}return!1}(r,e,Math.min(a,i))))return r;var s=hW(t,fW.bind(null,n,i));return!s||s===e&&r?r:s}function fW(e=0,t=0,n){if(n.start<=e&&n.start+n.duration>e)return 0;var i=Math.min(t,n.duration+(n.deltaPTS?n.deltaPTS:0));return n.start+n.duration-i<=e?1:n.start-i>e&&n.start?-1:0}function vW(e,t,n){var i=1e3*Math.min(t,n.duration+(n.deltaPTS?n.deltaPTS:0));return(n.endProgramDateTime||0)-i>e}function pW(e,t,n){if(e&&e.startCC<=t&&e.endCC>=t){var i,a=e.fragments,r=e.fragmentHint;return r&&(a=a.concat(r)),hW(a,e=>e.cc<t?1:e.cc>t?-1:(i=e,e.end<=n?1:e.start>n?-1:0)),i||null}return null}function gW(e){switch(e.details){case h$.FRAG_LOAD_TIMEOUT:case h$.KEY_LOAD_TIMEOUT:case h$.LEVEL_LOAD_TIMEOUT:case h$.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function yW(e){return e.details.startsWith("key")}function bW(e){return yW(e)&&!!e.frag&&!e.frag.decryptdata}function wW(e,t){var n=gW(t);return e.default[(n?"timeout":"error")+"Retry"]}function kW(e,t){var n="linear"===e.backoff?1:Math.pow(2,t);return Math.min(n*e.retryDelayMs,e.maxRetryDelayMs)}function SW(e){return _$(_$({},e),{errorRetry:null,timeoutRetry:null})}function EW(e,t,n,i){if(!e)return!1;var a=null==i?void 0:i.code,r=t<e.maxNumRetry&&(function(e){return PW(e)||!!e&&(e<400||e>499)}(a)||!!n);return e.shouldRetry?e.shouldRetry(e,t,n,i,r):r}function PW(e){return 0===e&&!1===navigator.onLine}var TW=0,_W=2,MW=3,AW=5,DW=0,xW=1,CW=2,IW=4,LW=function(e){function t(e){var n;return o(this,t),(n=r(this,t,["error-controller",e.logger])).hls=void 0,n.playlistError=0,n.hls=e,n.registerListeners(),n}return p(t,e),c(t,[{key:"registerListeners",value:function(){var e=this.hls;e.on(m$.ERROR,this.onError,this),e.on(m$.MANIFEST_LOADING,this.onManifestLoading,this),e.on(m$.LEVEL_UPDATED,this.onLevelUpdated,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e&&(e.off(m$.ERROR,this.onError,this),e.off(m$.ERROR,this.onErrorOut,this),e.off(m$.MANIFEST_LOADING,this.onManifestLoading,this),e.off(m$.LEVEL_UPDATED,this.onLevelUpdated,this))}},{key:"destroy",value:function(){this.unregisterListeners(),this.hls=null}},{key:"startLoad",value:function(e){}},{key:"stopLoad",value:function(){this.playlistError=0}},{key:"getVariantLevelIndex",value:function(e){return(null==e?void 0:e.type)===y$?e.level:this.getVariantIndex()}},{key:"getVariantIndex",value:function(){var e,t=this.hls,n=t.currentLevel;return null!=(e=t.loadLevelObj)&&e.details||-1===n?t.loadLevel:n}},{key:"variantHasKey",value:function(e,t){if(e){var n;if(null!=(n=e.details)&&n.hasKey(t))return!0;var i=e.audioGroups;if(i)return this.hls.allAudioTracks.filter(e=>i.indexOf(e.groupId)>=0).some(e=>{var n;return null==(n=e.details)?void 0:n.hasKey(t)})}return!1}},{key:"onManifestLoading",value:function(){this.playlistError=0}},{key:"onLevelUpdated",value:function(){this.playlistError=0}},{key:"onError",value:function(e,t){var n;if(!t.fatal){var i=this.hls,a=t.context;switch(t.details){case h$.FRAG_LOAD_ERROR:case h$.FRAG_LOAD_TIMEOUT:case h$.KEY_LOAD_ERROR:case h$.KEY_LOAD_TIMEOUT:return void(t.errorAction=this.getFragRetryOrSwitchAction(t));case h$.FRAG_PARSING_ERROR:if(null!=(n=t.frag)&&n.gap)return void(t.errorAction=RW());case h$.FRAG_GAP:case h$.FRAG_DECRYPT_ERROR:return t.errorAction=this.getFragRetryOrSwitchAction(t),void(t.errorAction.action=_W);case h$.LEVEL_EMPTY_ERROR:case h$.LEVEL_PARSING_ERROR:var r,o=t.parent===y$?t.level:i.loadLevel;return void(t.details===h$.LEVEL_EMPTY_ERROR&&null!=(r=t.context)&&null!=(r=r.levelDetails)&&r.live?t.errorAction=this.getPlaylistRetryOrSwitchAction(t,o):(t.levelRetry=!1,t.errorAction=this.getLevelSwitchAction(t,o)));case h$.LEVEL_LOAD_ERROR:case h$.LEVEL_LOAD_TIMEOUT:return void("number"==typeof(null==a?void 0:a.level)&&(t.errorAction=this.getPlaylistRetryOrSwitchAction(t,a.level)));case h$.AUDIO_TRACK_LOAD_ERROR:case h$.AUDIO_TRACK_LOAD_TIMEOUT:case h$.SUBTITLE_LOAD_ERROR:case h$.SUBTITLE_TRACK_LOAD_TIMEOUT:if(a){var s=i.loadLevelObj;if(s&&(a.type===p$&&s.hasAudioGroup(a.groupId)||a.type===g$&&s.hasSubtitleGroup(a.groupId)))return t.errorAction=this.getPlaylistRetryOrSwitchAction(t,i.loadLevel),t.errorAction.action=_W,void(t.errorAction.flags=xW)}return;case h$.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:return void(t.errorAction={action:_W,flags:CW});case h$.KEY_SYSTEM_SESSION_UPDATE_FAILED:case h$.KEY_SYSTEM_STATUS_INTERNAL_ERROR:case h$.KEY_SYSTEM_NO_SESSION:return void(t.errorAction={action:_W,flags:IW});case h$.BUFFER_ADD_CODEC_ERROR:case h$.REMUX_ALLOC_ERROR:case h$.BUFFER_APPEND_ERROR:var u;if(!t.errorAction)t.errorAction=this.getLevelSwitchAction(t,null!=(u=t.level)?u:i.loadLevel);return;case h$.INTERNAL_EXCEPTION:case h$.BUFFER_APPENDING_ERROR:case h$.BUFFER_FULL_ERROR:case h$.LEVEL_SWITCH_ERROR:case h$.BUFFER_STALLED_ERROR:case h$.BUFFER_SEEK_OVER_HOLE:case h$.BUFFER_NUDGE_ON_STALL:return void(t.errorAction=RW())}t.type===c$.KEY_SYSTEM_ERROR&&(t.levelRetry=!1,t.errorAction=RW())}}},{key:"getPlaylistRetryOrSwitchAction",value:function(e,t){var n=wW(this.hls.config.playlistLoadPolicy,e),i=this.playlistError++;if(EW(n,i,gW(e),e.response))return{action:AW,flags:DW,retryConfig:n,retryCount:i};var a=this.getLevelSwitchAction(e,t);return n&&(a.retryConfig=n,a.retryCount=i),a}},{key:"getFragRetryOrSwitchAction",value:function(e){var t=this.hls,n=this.getVariantLevelIndex(e.frag),i=t.levels[n],a=t.config,r=a.fragLoadPolicy,o=a.keyLoadPolicy,s=wW(yW(e)?o:r,e),u=t.levels.reduce((e,t)=>e+t.fragmentError,0);if(i&&(e.details!==h$.FRAG_GAP&&i.fragmentError++,!bW(e)&&EW(s,u,gW(e),e.response)))return{action:AW,flags:DW,retryConfig:s,retryCount:u};var l=this.getLevelSwitchAction(e,n);return s&&(l.retryConfig=s,l.retryCount=u),l}},{key:"getLevelSwitchAction",value:function(e,t){var n=this.hls;null==t&&(t=n.loadLevel);var i=this.hls.levels[t];if(i){var a,r,o=e.details;i.loadError++,o===h$.BUFFER_APPEND_ERROR&&i.fragmentError++;var s=-1,u=n.levels,l=n.loadLevel,d=n.minAutoLevel,c=n.maxAutoLevel;n.autoLevelEnabled||n.config.preserveManualLevelOnError||(n.loadLevel=-1);for(var h,m,f,v=null==(a=e.frag)?void 0:a.type,p=(v===b$&&o===h$.FRAG_PARSING_ERROR||"audio"===e.sourceBufferName&&(o===h$.BUFFER_ADD_CODEC_ERROR||o===h$.BUFFER_APPEND_ERROR))&&u.some(({audioCodec:e})=>i.audioCodec!==e),g="video"===e.sourceBufferName&&(o===h$.BUFFER_ADD_CODEC_ERROR||o===h$.BUFFER_APPEND_ERROR)&&u.some(({codecSet:e,audioCodec:t})=>i.codecSet!==e&&i.audioCodec===t),y=null!=(r=e.context)?r:{},b=y.type,w=y.groupId,k=function(){var t=(S+l)%u.length;if(t!==l&&t>=d&&t<=c&&0===u[t].loadError){var n=u[t];if(o===h$.FRAG_GAP&&v===y$&&e.frag){var a=u[t].details;if(a){var r=mW(e.frag,a.fragments,e.frag.start);if(null!=r&&r.gap)return 0}}else{if(b===p$&&n.hasAudioGroup(w)||b===g$&&n.hasSubtitleGroup(w))return 0;if(v===b$&&null!=(h=i.audioGroups)&&h.some(e=>n.hasAudioGroup(e))||v===w$&&null!=(m=i.subtitleGroups)&&m.some(e=>n.hasSubtitleGroup(e))||p&&i.audioCodec===n.audioCodec||g&&i.codecSet===n.codecSet||!p&&i.codecSet!==n.codecSet)return 0}return s=t,1}},S=u.length;S--&&(0===(f=k())||1!==f););if(s>-1&&n.loadLevel!==s)return e.levelRetry=!0,this.playlistError=0,{action:_W,flags:DW,nextAutoLevel:s}}return{action:_W,flags:xW}}},{key:"onErrorOut",value:function(e,t){var n;switch(null==(n=t.errorAction)?void 0:n.action){case TW:break;case _W:this.sendAlternateToPenaltyBox(t),t.errorAction.resolved||t.details===h$.FRAG_GAP?/MediaSource readyState: ended/.test(t.error.message)&&(this.warn(`MediaSource ended after "${t.sourceBufferName}" sourceBuffer append error. Attempting to recover from media error.`),this.hls.recoverMediaError()):t.fatal=!0}t.fatal&&this.hls.stopLoad()}},{key:"sendAlternateToPenaltyBox",value:function(e){var t=this.hls,n=e.errorAction;if(n){var i=n.flags,a=n.nextAutoLevel;switch(i){case DW:this.switchLevel(e,a);break;case CW:var r=this.getVariantLevelIndex(e.frag),o=t.levels[r],s=null==o?void 0:o.attrs["HDCP-LEVEL"];if(n.hdcpLevel=s,"NONE"===s)this.warn("HDCP policy resticted output with HDCP-LEVEL=NONE");else if(s){t.maxHdcpLevel=VN[VN.indexOf(s)-1],n.resolved=!0,this.warn(`Restricting playback to HDCP-LEVEL of "${t.maxHdcpLevel}" or lower`);break}case IW:var u=e.decryptdata;if(u){for(var l=this.hls.levels,d=l.length,c=d;c--;){var h,m;if(this.variantHasKey(l[c],u))this.log(`Banned key found in level ${c} (${l[c].bitrate}bps) or audio group "${null==(h=l[c].audioGroups)?void 0:h.join(",")}" (${null==(m=e.frag)?void 0:m.type} fragment) ${$$(u.keyId||[])}`),l[c].fragmentError++,l[c].loadError++,this.log(`Removing level ${c} with key error (${e.error})`),this.hls.removeLevel(c)}var f=e.frag;if(this.hls.levels.length<d)n.resolved=!0;else if(f&&f.type!==y$){var v=f.decryptdata;v&&!u.matches(v)&&(n.resolved=!0)}}}n.resolved||this.switchLevel(e,a)}}},{key:"switchLevel",value:function(e,t){if(void 0!==t&&e.errorAction&&(this.warn(`switching to level ${t} after ${e.details}`),this.hls.nextAutoLevel=t,e.errorAction.resolved=!0,this.hls.nextLoadLevel=this.hls.nextAutoLevel,e.details===h$.BUFFER_ADD_CODEC_ERROR&&e.mimeType&&"audiovideo"!==e.sourceBufferName))for(var n=WN(e.mimeType),i=this.hls.levels,a=i.length;a--;)i[a][`${e.sourceBufferName}Codec`]===n&&(this.log(`Removing level ${a} for ${e.details} ("${n}" not supported)`),this.hls.removeLevel(a))}}])}(M$);function RW(e){var t={action:TW,flags:DW};return e&&(t.resolved=!0),t}var FW="NOT_LOADED",OW="APPENDING",$W="PARTIAL",NW="OK",WW=function(){return c(function e(t){o(this,e),this.activePartLists=Object.create(null),this.endListFragments=Object.create(null),this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hasGaps=!1,this.hls=t,this._registerListeners()},[{key:"_registerListeners",value:function(){var e=this.hls;e&&(e.on(m$.MANIFEST_LOADING,this.onManifestLoading,this),e.on(m$.BUFFER_APPENDED,this.onBufferAppended,this),e.on(m$.FRAG_BUFFERED,this.onFragBuffered,this),e.on(m$.FRAG_LOADED,this.onFragLoaded,this))}},{key:"_unregisterListeners",value:function(){var e=this.hls;e&&(e.off(m$.MANIFEST_LOADING,this.onManifestLoading,this),e.off(m$.BUFFER_APPENDED,this.onBufferAppended,this),e.off(m$.FRAG_BUFFERED,this.onFragBuffered,this),e.off(m$.FRAG_LOADED,this.onFragLoaded,this))}},{key:"destroy",value:function(){this._unregisterListeners(),this.hls=this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null}},{key:"getAppendedFrag",value:function(e,t){var n=this.activePartLists[t];if(n)for(var i=n.length;i--;){var a=n[i];if(!a)break;if(a.start<=e&&e<=a.end&&a.loaded)return a}return this.getBufferedFrag(e,t)}},{key:"getBufferedFrag",value:function(e,t){return this.getFragAtPos(e,t,!0)}},{key:"getFragAtPos",value:function(e,t,n){for(var i=this.fragments,a=Object.keys(i),r=a.length;r--;){var o=i[a[r]];if((null==o?void 0:o.body.type)===t&&(!n||o.buffered)){var s=o.body;if(s.start<=e&&e<=s.end)return s}}return null}},{key:"detectEvictedFragments",value:function(e,t,n,i,a){this.timeRanges&&(this.timeRanges[e]=t);var r=(null==i?void 0:i.fragment.sn)||-1;Object.keys(this.fragments).forEach(i=>{var o=this.fragments[i];if(o&&!(r>=o.body.sn))if(o.buffered||o.loaded&&!a){var s=o.range[e];s&&(0!==s.time.length?s.time.some(e=>{var n=!this.isTimeBuffered(e.startPTS,e.endPTS,t);return n&&this.removeFragment(o.body),n}):this.removeFragment(o.body))}else o.body.type===n&&this.removeFragment(o.body)})}},{key:"detectPartialFragments",value:function(e){var t=this.timeRanges;if(t&&"initSegment"!==e.frag.sn){var n=e.frag,i=BW(n),a=this.fragments[i];if(!(!a||a.buffered&&n.gap)){var r=!n.relurl;Object.keys(t).forEach(i=>{var o=n.elementaryStreams[i];if(o){var s=t[i],u=r||!0===o.partial;a.range[i]=this.getBufferedTimes(n,e.part,u,s)}}),a.loaded=null,Object.keys(a.range).length?(this.bufferedEnd(a,n),jW(a)||this.removeParts(n.sn-1,n.type)):this.removeFragment(a.body)}}}},{key:"bufferedEnd",value:function(e,t){e.buffered=!0,(e.body.endList=t.endList||e.body.endList)&&(this.endListFragments[e.body.type]=e)}},{key:"removeParts",value:function(e,t){var n=this.activePartLists[t];n&&(this.activePartLists[t]=zW(n,t=>t.fragment.sn>=e))}},{key:"fragBuffered",value:function(e,t){var n=BW(e),i=this.fragments[n];!i&&t&&(i=this.fragments[n]={body:e,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},e.gap&&(this.hasGaps=!0)),i&&(i.loaded=null,this.bufferedEnd(i,e))}},{key:"getBufferedTimes",value:function(e,t,n,i){for(var a={time:[],partial:n},r=e.start,o=e.end,s=e.minEndPTS||o,u=e.maxStartPTS||r,l=0;l<i.length;l++){var d=i.start(l)-this.bufferPadding,c=i.end(l)+this.bufferPadding;if(u>=d&&s<=c){a.time.push({startPTS:Math.max(r,i.start(l)),endPTS:Math.min(o,i.end(l))});break}if(r<c&&o>d){var h=Math.max(r,i.start(l)),m=Math.min(o,i.end(l));m>h&&(a.partial=!0,a.time.push({startPTS:h,endPTS:m}))}else if(o<=d)break}return a}},{key:"getPartialFragment",value:function(e){var t,n,i,a=null,r=0,o=this.bufferPadding,s=this.fragments;return Object.keys(s).forEach(u=>{var l=s[u];l&&jW(l)&&(n=l.body.start-o,i=l.body.end+o,e>=n&&e<=i&&(t=Math.min(e-n,i-e),r<=t&&(a=l.body,r=t)))}),a}},{key:"isEndListAppended",value:function(e){var t=this.endListFragments[e];return void 0!==t&&(t.buffered||jW(t))}},{key:"getState",value:function(e){var t=BW(e),n=this.fragments[t];return n?n.buffered?jW(n)?$W:NW:OW:FW}},{key:"isTimeBuffered",value:function(e,t,n){for(var i,a,r=0;r<n.length;r++){if(i=n.start(r)-this.bufferPadding,a=n.end(r)+this.bufferPadding,e>=i&&t<=a)return!0;if(t<=i)return!1}return!1}},{key:"onManifestLoading",value:function(){this.removeAllFragments()}},{key:"onFragLoaded",value:function(e,t){if("initSegment"!==t.frag.sn&&!t.frag.bitrateTest){var n=t.frag,i=t.part?null:t,a=BW(n);this.fragments[a]={body:n,appendedPTS:null,loaded:i,buffered:!1,range:Object.create(null)}}}},{key:"onBufferAppended",value:function(e,t){var n=t.frag,i=t.part,a=t.timeRanges,r=t.type;if("initSegment"!==n.sn){var o=n.type;if(i){var s=this.activePartLists[o];s||(this.activePartLists[o]=s=[]),s.push(i)}this.timeRanges=a;var u=a[r];this.detectEvictedFragments(r,u,o,i)}}},{key:"onFragBuffered",value:function(e,t){this.detectPartialFragments(t)}},{key:"hasFragment",value:function(e){var t=BW(e);return!!this.fragments[t]}},{key:"hasFragments",value:function(e){var t=this.fragments,n=Object.keys(t);if(!e)return n.length>0;for(var i=n.length;i--;){var a=t[n[i]];if((null==a?void 0:a.body.type)===e)return!0}return!1}},{key:"hasParts",value:function(e){var t;return!(null==(t=this.activePartLists[e])||!t.length)}},{key:"removeFragmentsInRange",value:function(e,t,n,i,a){i&&!this.hasGaps||Object.keys(this.fragments).forEach(r=>{var o=this.fragments[r];if(o){var s=o.body;s.type!==n||i&&!s.gap||s.start<t&&s.end>e&&(o.buffered||a)&&this.removeFragment(s)}})}},{key:"removeFragment",value:function(e){var t=BW(e);e.clearElementaryStreamInfo();var n=this.activePartLists[e.type];if(n){var i=e.sn;this.activePartLists[e.type]=zW(n,e=>e.fragment.sn!==i)}delete this.fragments[t],e.endList&&delete this.endListFragments[e.type]}},{key:"removeAllFragments",value:function(){var e;this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=!1;var t=null==(e=this.hls)||null==(e=e.latestLevelDetails)?void 0:e.partList;t&&t.forEach(e=>e.clearElementaryStreamInfo())}}])}();function jW(e){var t,n,i;return e.buffered&&!!(e.body.gap||null!=(t=e.range.video)&&t.partial||null!=(n=e.range.audio)&&n.partial||null!=(i=e.range.audiovideo)&&i.partial)}function BW(e){return`${e.type}_${e.level}_${e.sn}`}function zW(e,t){return e.filter(e=>{var n=t(e);return n||e.clearElementaryStreamInfo(),n})}var UW=0,HW=1,GW=function(){return c(function e(t,n,i){o(this,e),this.subtle=void 0,this.aesIV=void 0,this.aesMode=void 0,this.subtle=t,this.aesIV=n,this.aesMode=i},[{key:"decrypt",value:function(e,t){switch(this.aesMode){case UW:return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},t,e);case HW:return this.subtle.decrypt({name:"AES-CTR",counter:this.aesIV,length:64},t,e);default:throw new Error(`[AESCrypto] invalid aes mode ${this.aesMode}`)}}}])}();var VW=function(){return c(function e(){o(this,e),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()},[{key:"uint8ArrayToUint32Array_",value:function(e){for(var t=new DataView(e),n=new Uint32Array(4),i=0;i<4;i++)n[i]=t.getUint32(4*i);return n}},{key:"initTable",value:function(){var e=this.sBox,t=this.invSBox,n=this.subMix,i=n[0],a=n[1],r=n[2],o=n[3],s=this.invSubMix,u=s[0],l=s[1],d=s[2],c=s[3],h=new Uint32Array(256),m=0,f=0,v=0;for(v=0;v<256;v++)h[v]=v<128?v<<1:v<<1^283;for(v=0;v<256;v++){var p=f^f<<1^f<<2^f<<3^f<<4;p=p>>>8^255&p^99,e[m]=p,t[p]=m;var g=h[m],y=h[g],b=h[y],w=257*h[p]^16843008*p;i[m]=w<<24|w>>>8,a[m]=w<<16|w>>>16,r[m]=w<<8|w>>>24,o[m]=w,w=16843009*b^65537*y^257*g^16843008*m,u[p]=w<<24|w>>>8,l[p]=w<<16|w>>>16,d[p]=w<<8|w>>>24,c[p]=w,m?(m=g^h[h[h[b^g]]],f^=h[h[f]]):m=f=1}}},{key:"expandKey",value:function(e){for(var t=this.uint8ArrayToUint32Array_(e),n=!0,i=0;i<t.length&&n;)n=t[i]===this.key[i],i++;if(!n){this.key=t;var a=this.keySize=t.length;if(4!==a&&6!==a&&8!==a)throw new Error("Invalid aes key size="+a);var r,o,s,u,l=this.ksRows=4*(a+6+1),d=this.keySchedule=new Uint32Array(l),c=this.invKeySchedule=new Uint32Array(l),h=this.sBox,m=this.rcon,f=this.invSubMix,v=f[0],p=f[1],g=f[2],y=f[3];for(r=0;r<l;r++)r<a?s=d[r]=t[r]:(u=s,r%a===0?(u=h[(u=u<<8|u>>>24)>>>24]<<24|h[u>>>16&255]<<16|h[u>>>8&255]<<8|h[255&u],u^=m[r/a|0]<<24):a>6&&r%a===4&&(u=h[u>>>24]<<24|h[u>>>16&255]<<16|h[u>>>8&255]<<8|h[255&u]),d[r]=s=(d[r-a]^u)>>>0);for(o=0;o<l;o++)r=l-o,u=3&o?d[r]:d[r-4],c[o]=o<4||r<=4?u:v[h[u>>>24]]^p[h[u>>>16&255]]^g[h[u>>>8&255]]^y[h[255&u]],c[o]=c[o]>>>0}}},{key:"networkToHostOrderSwap",value:function(e){return e<<24|(65280&e)<<8|(16711680&e)>>8|e>>>24}},{key:"decrypt",value:function(e,t,n){for(var i,a,r,o,s,u,l,d,c,h,m,f,v,p,g=this.keySize+6,y=this.invKeySchedule,b=this.invSBox,w=this.invSubMix,k=w[0],S=w[1],E=w[2],P=w[3],T=this.uint8ArrayToUint32Array_(n),_=T[0],M=T[1],A=T[2],D=T[3],x=new Int32Array(e),C=new Int32Array(x.length),I=this.networkToHostOrderSwap;t<x.length;){for(c=I(x[t]),h=I(x[t+1]),m=I(x[t+2]),f=I(x[t+3]),s=c^y[0],u=f^y[1],l=m^y[2],d=h^y[3],v=4,p=1;p<g;p++)i=k[s>>>24]^S[u>>16&255]^E[l>>8&255]^P[255&d]^y[v],a=k[u>>>24]^S[l>>16&255]^E[d>>8&255]^P[255&s]^y[v+1],r=k[l>>>24]^S[d>>16&255]^E[s>>8&255]^P[255&u]^y[v+2],o=k[d>>>24]^S[s>>16&255]^E[u>>8&255]^P[255&l]^y[v+3],s=i,u=a,l=r,d=o,v+=4;i=b[s>>>24]<<24^b[u>>16&255]<<16^b[l>>8&255]<<8^b[255&d]^y[v],a=b[u>>>24]<<24^b[l>>16&255]<<16^b[d>>8&255]<<8^b[255&s]^y[v+1],r=b[l>>>24]<<24^b[d>>16&255]<<16^b[s>>8&255]<<8^b[255&u]^y[v+2],o=b[d>>>24]<<24^b[s>>16&255]<<16^b[u>>8&255]<<8^b[255&l]^y[v+3],C[t]=I(i^_),C[t+1]=I(o^M),C[t+2]=I(r^A),C[t+3]=I(a^D),_=c,M=h,A=m,D=f,t+=4}return C.buffer}}])}(),KW=function(){return c(function e(t,n,i){o(this,e),this.subtle=void 0,this.key=void 0,this.aesMode=void 0,this.subtle=t,this.key=n,this.aesMode=i},[{key:"expandKey",value:function(){var e=function(e){switch(e){case UW:return"AES-CBC";case HW:return"AES-CTR";default:throw new Error(`[FastAESKey] invalid aes mode ${e}`)}}(this.aesMode);return this.subtle.importKey("raw",this.key,{name:e},!1,["encrypt","decrypt"])}}])}();var XW=function(){return c(function e(t,{removePKCS7Padding:n=!0}={}){if(o(this,e),this.logEnabled=!0,this.removePKCS7Padding=void 0,this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null,this.useSoftware=void 0,this.enableSoftwareAES=void 0,this.enableSoftwareAES=t.enableSoftwareAES,this.removePKCS7Padding=n,n)try{var i=self.crypto;i&&(this.subtle=i.subtle||i.webkitSubtle)}catch(e){}this.useSoftware=!this.subtle},[{key:"destroy",value:function(){this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null}},{key:"isSync",value:function(){return this.useSoftware}},{key:"flush",value:function(){var e=this.currentResult,t=this.remainderData;if(!e||t)return this.reset(),null;var n,i,a,r=new Uint8Array(e);return this.reset(),this.removePKCS7Padding?(i=(n=r).byteLength,(a=i&&new DataView(n.buffer).getUint8(i-1))?n.slice(0,i-a):n):r}},{key:"reset",value:function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)}},{key:"decrypt",value:function(e,t,n,i){return this.useSoftware?new Promise((a,r)=>{var o=ArrayBuffer.isView(e)?e:new Uint8Array(e);this.softwareDecrypt(o,t,n,i);var s=this.flush();s?a(s.buffer):r(new Error("[softwareDecrypt] Failed to decrypt data"))}):this.webCryptoDecrypt(new Uint8Array(e),t,n,i)}},{key:"softwareDecrypt",value:function(e,t,n,i){var a=this.currentIV,r=this.currentResult,o=this.remainderData;if(i!==UW||16!==t.byteLength)return L$.warn("SoftwareDecrypt: can only handle AES-128-CBC"),null;this.logOnce("JS AES decrypt"),o&&(e=pN(o,e),this.remainderData=null);var s=this.getValidChunk(e);if(!s.length)return null;a&&(n=a);var u=this.softwareDecrypter;u||(u=this.softwareDecrypter=new VW),u.expandKey(t);var l=r;return this.currentResult=u.decrypt(s.buffer,0,n),this.currentIV=s.slice(-16).buffer,l||null}},{key:"webCryptoDecrypt",value:function(e,t,n,i){if(this.key!==t||!this.fastAesKey){if(!this.subtle)return Promise.resolve(this.onWebCryptoError(e,t,n,i));this.key=t,this.fastAesKey=new KW(this.subtle,t,i)}return this.fastAesKey.expandKey().then(t=>this.subtle?(this.logOnce("WebCrypto AES decrypt"),new GW(this.subtle,new Uint8Array(n),i).decrypt(e.buffer,t)):Promise.reject(new Error("web crypto not initialized"))).catch(a=>(L$.warn(`[decrypter]: WebCrypto Error, disable WebCrypto API, ${a.name}: ${a.message}`),this.onWebCryptoError(e,t,n,i)))}},{key:"onWebCryptoError",value:function(e,t,n,i){var a=this.enableSoftwareAES;if(a){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(e,t,n,i);var r=this.flush();if(r)return r.buffer}throw new Error("WebCrypto"+(a?" and softwareDecrypt":"")+": failed to decrypt data")}},{key:"getValidChunk",value:function(e){var t=e,n=e.length-e.length%16;return n!==e.length&&(t=e.slice(0,n),this.remainderData=e.slice(n)),t}},{key:"logOnce",value:function(e){this.logEnabled&&(L$.log(`[decrypter]: ${e}`),this.logEnabled=!1)}}])}(),YW=Math.pow(2,17),qW=function(){return c(function e(t){o(this,e),this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=t},[{key:"destroy",value:function(){this.loader&&(this.loader.destroy(),this.loader=null)}},{key:"abort",value:function(){this.loader&&this.loader.abort()}},{key:"load",value:function(e,t){var n=e.url;if(!n)return Promise.reject(new ZW({type:c$.NETWORK_ERROR,details:h$.FRAG_LOAD_ERROR,fatal:!1,frag:e,error:new Error("Fragment does not have a "+(n?"part list":"url")),networkDetails:null}));this.abort();var i=this.config,a=i.fLoader,r=i.loader;return new Promise((o,s)=>{if(this.loader&&this.loader.destroy(),e.gap){if(e.tagList.some(e=>"GAP"===e[0]))return void s(QW(e));e.gap=!1}var u=this.loader=a?new a(i):new r(i),l=JW(e);e.loader=u;var d=SW(i.fragLoadPolicy.default),c={loadPolicy:d,timeout:d.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:"initSegment"===e.sn?1/0:YW};e.stats=u.stats;var h={onSuccess:(t,n,i,a)=>{this.resetLoader(e,u);var r=t.data;i.resetIV&&e.decryptdata&&(e.decryptdata.iv=new Uint8Array(r.slice(0,16)),r=r.slice(16)),o({frag:e,part:null,payload:r,networkDetails:a})},onError:(t,i,a,r)=>{this.resetLoader(e,u),s(new ZW({type:c$.NETWORK_ERROR,details:h$.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:_$({url:n,data:void 0},t),error:new Error(`HTTP Error ${t.code} ${t.text}`),networkDetails:a,stats:r}))},onAbort:(t,n,i)=>{this.resetLoader(e,u),s(new ZW({type:c$.NETWORK_ERROR,details:h$.INTERNAL_ABORTED,fatal:!1,frag:e,error:new Error("Aborted"),networkDetails:i,stats:t}))},onTimeout:(t,n,i)=>{this.resetLoader(e,u),s(new ZW({type:c$.NETWORK_ERROR,details:h$.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,error:new Error(`Timeout after ${c.timeout}ms`),networkDetails:i,stats:t}))}};t&&(h.onProgress=(n,i,a,r)=>t({frag:e,part:null,payload:a,networkDetails:r})),u.load(l,c,h)})}},{key:"loadPart",value:function(e,t,n){this.abort();var i=this.config,a=i.fLoader,r=i.loader;return new Promise((o,s)=>{if(this.loader&&this.loader.destroy(),e.gap||t.gap)s(QW(e,t));else{var u=this.loader=a?new a(i):new r(i),l=JW(e,t);e.loader=u;var d=SW(i.fragLoadPolicy.default),c={loadPolicy:d,timeout:d.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:YW};t.stats=u.stats,u.load(l,c,{onSuccess:(i,a,r,s)=>{this.resetLoader(e,u),this.updateStatsFromPart(e,t);var l={frag:e,part:t,payload:i.data,networkDetails:s};n(l),o(l)},onError:(n,i,a,r)=>{this.resetLoader(e,u),s(new ZW({type:c$.NETWORK_ERROR,details:h$.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:t,response:_$({url:l.url,data:void 0},n),error:new Error(`HTTP Error ${n.code} ${n.text}`),networkDetails:a,stats:r}))},onAbort:(n,i,a)=>{e.stats.aborted=t.stats.aborted,this.resetLoader(e,u),s(new ZW({type:c$.NETWORK_ERROR,details:h$.INTERNAL_ABORTED,fatal:!1,frag:e,part:t,error:new Error("Aborted"),networkDetails:a,stats:n}))},onTimeout:(n,i,a)=>{this.resetLoader(e,u),s(new ZW({type:c$.NETWORK_ERROR,details:h$.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,part:t,error:new Error(`Timeout after ${c.timeout}ms`),networkDetails:a,stats:n}))}})}})}},{key:"updateStatsFromPart",value:function(e,t){var n=e.stats,i=t.stats,a=i.total;if(n.loaded+=i.loaded,a){var r=Math.round(e.duration/t.duration),o=Math.min(Math.round(n.loaded/a),r),s=(r-o)*Math.round(n.loaded/o);n.total=n.loaded+s}else n.total=Math.max(n.loaded,n.total);var u=n.loading,l=i.loading;u.start?u.first+=l.first-l.start:(u.start=l.start,u.first=l.first),u.end=l.end}},{key:"resetLoader",value:function(e,t){e.loader=null,this.loader===t&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),t.destroy()}}])}();function JW(e,t=null){var n,i=t||e,a={frag:e,part:t,responseType:"arraybuffer",url:i.url,headers:{},rangeStart:0,rangeEnd:0},r=i.byteRangeStartOffset,o=i.byteRangeEndOffset;if(u$(r)&&u$(o)){var s,u=r,l=o;if("initSegment"===e.sn&&("AES-128"===(n=null==(s=e.decryptdata)?void 0:s.method)||"AES-256"===n)){var d=o-r;d%16&&(l=o+(16-d%16)),0!==r&&(a.resetIV=!0,u=r-16)}a.rangeStart=u,a.rangeEnd=l}return a}function QW(e,t){var n=new Error(`GAP ${e.gap?"tag":"attribute"} found`),i={type:c$.MEDIA_ERROR,details:h$.FRAG_GAP,fatal:!1,frag:e,error:n,networkDetails:null};return t&&(i.part=t),(t||e).stats.aborted=!0,new ZW(i)}var ZW=function(e){function t(e){var n;return o(this,t),(n=r(this,t,[e.error.message])).data=void 0,n.data=e,n}return p(t,e),c(t)}(M(Error)),ej=function(e){function t(e,n){var i;return o(this,t),(i=r(this,t,[e,n]))._boundTick=void 0,i._tickTimer=null,i._tickInterval=null,i._tickCallCount=0,i._boundTick=i.tick.bind(i),i}return p(t,e),c(t,[{key:"destroy",value:function(){this.onHandlerDestroying(),this.onHandlerDestroyed()}},{key:"onHandlerDestroying",value:function(){this.clearNextTick(),this.clearInterval()}},{key:"onHandlerDestroyed",value:function(){}},{key:"hasInterval",value:function(){return!!this._tickInterval}},{key:"hasNextTick",value:function(){return!!this._tickTimer}},{key:"setInterval",value:function(e){return!this._tickInterval&&(this._tickCallCount=0,this._tickInterval=self.setInterval(this._boundTick,e),!0)}},{key:"clearInterval",value:function(){return!!this._tickInterval&&(self.clearInterval(this._tickInterval),this._tickInterval=null,!0)}},{key:"clearNextTick",value:function(){return!!this._tickTimer&&(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0)}},{key:"tick",value:function(){this._tickCallCount++,1===this._tickCallCount&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)}},{key:"tickImmediate",value:function(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)}},{key:"doTick",value:function(){}}])}(M$),tj=c(function e(t,n,i,a=0,r=-1,s=!1){o(this,e),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=n,this.id=i,this.size=a,this.part=r,this.partial=s});var nj={length:0,start:()=>0,end:()=>0},ij=function(){function e(){o(this,e)}return c(e,null,[{key:"isBuffered",value:function(t,n){if(t)for(var i=e.getBuffered(t),a=i.length;a--;)if(n>=i.start(a)&&n<=i.end(a))return!0;return!1}},{key:"bufferedRanges",value:function(t){if(t){var n=e.getBuffered(t);return e.timeRangesToArray(n)}return[]}},{key:"timeRangesToArray",value:function(e){for(var t=[],n=0;n<e.length;n++)t.push({start:e.start(n),end:e.end(n)});return t}},{key:"bufferInfo",value:function(t,n,i){if(t){var a=e.bufferedRanges(t);if(a.length)return e.bufferedInfo(a,n,i)}return{len:0,start:n,end:n,bufferedIndex:-1}}},{key:"bufferedInfo",value:function(e,t,n){t=Math.max(0,t),e.length>1&&e.sort((e,t)=>e.start-t.start||t.end-e.end);var i=-1,a=[];if(n)for(var r=0;r<e.length;r++){t>=e[r].start&&t<=e[r].end&&(i=r);var o=a.length;if(o){var s=a[o-1].end;e[r].start-s<n?e[r].end>s&&(a[o-1].end=e[r].end):a.push(e[r])}else a.push(e[r])}else a=e;for(var u,l=0,d=t,c=t,h=0;h<a.length;h++){var m=a[h].start,f=a[h].end;if(-1===i&&t>=m&&t<=f&&(i=h),t+n>=m&&t<f)d=m,l=(c=f)-t;else if(t+n<m){u=m;break}}return{len:l,start:d||0,end:c||0,nextStart:u,buffered:e,bufferedIndex:i}}},{key:"getBuffered",value:function(e){try{return e.buffered||nj}catch(e){return L$.log("failed to get media.buffered",e),nj}}}])}(),aj=/\{\$([a-zA-Z0-9-_]+)\}/g;function rj(e){return aj.test(e)}function oj(e,t){if(null!==e.variableList||e.hasVariableRefs){var n=e.variableList;return t.replace(aj,t=>{var i=t.substring(2,t.length-1),a=null==n?void 0:n[i];return void 0===a?(e.playlistParsingError||(e.playlistParsingError=new Error(`Missing preceding EXT-X-DEFINE tag for Variable Reference: "${i}"`)),t):a})}return t}function sj(e,t,n){var i,a,r=e.variableList;if(r||(e.variableList=r={}),"QUERYPARAM"in t){i=t.QUERYPARAM;try{var o=new self.URL(n).searchParams;if(!o.has(i))throw new Error(`"${i}" does not match any query parameter in URI: "${n}"`);a=o.get(i)}catch(t){e.playlistParsingError||(e.playlistParsingError=new Error(`EXT-X-DEFINE QUERYPARAM: ${t.message}`))}}else i=t.NAME,a=t.VALUE;i in r?e.playlistParsingError||(e.playlistParsingError=new Error(`EXT-X-DEFINE duplicate Variable Name declarations: "${i}"`)):r[i]=a||""}function uj(e,t,n){var i=t.IMPORT;if(n&&i in n){var a=e.variableList;a||(e.variableList=a={}),a[i]=n[i]}else e.playlistParsingError||(e.playlistParsingError=new Error(`EXT-X-DEFINE IMPORT attribute not found in Multivariant Playlist: "${i}"`))}var lj=/^(\d+)x(\d+)$/,dj=/(.+?)=(".*?"|.*?)(?:,|$)/g,cj=function(){return c(function e(t,n){o(this,e),"string"==typeof t&&(t=e.parseAttrList(t,n)),P$(this,t)},[{key:"clientAttrs",get:function(){return Object.keys(this).filter(e=>"X-"===e.substring(0,2))}},{key:"decimalInteger",value:function(e){var t=parseInt(this[e],10);return t>Number.MAX_SAFE_INTEGER?1/0:t}},{key:"hexadecimalInteger",value:function(e){if(this[e]){var t=(this[e]||"0x").slice(2);t=(1&t.length?"0":"")+t;for(var n=new Uint8Array(t.length/2),i=0;i<t.length/2;i++)n[i]=parseInt(t.slice(2*i,2*i+2),16);return n}return null}},{key:"hexadecimalIntegerAsNumber",value:function(e){var t=parseInt(this[e],16);return t>Number.MAX_SAFE_INTEGER?1/0:t}},{key:"decimalFloatingPoint",value:function(e){return parseFloat(this[e])}},{key:"optionalFloat",value:function(e,t){var n=this[e];return n?parseFloat(n):t}},{key:"enumeratedString",value:function(e){return this[e]}},{key:"enumeratedStringList",value:function(e,t){var n=this[e];return(n?n.split(/[ ,]+/):[]).reduce((e,t)=>(e[t.toLowerCase()]=!0,e),t)}},{key:"bool",value:function(e){return"YES"===this[e]}},{key:"decimalResolution",value:function(e){var t=lj.exec(this[e]);if(null!==t)return{width:parseInt(t[1],10),height:parseInt(t[2],10)}}}],[{key:"parseAttrList",value:function(e,t){var n,i={};for(dj.lastIndex=0;null!==(n=dj.exec(e));){var a=n[1].trim(),r=n[2],o=0===r.indexOf('"')&&r.lastIndexOf('"')===r.length-1,s=!1;if(o)r=r.slice(1,-1);else switch(a){case"IV":case"SCTE35-CMD":case"SCTE35-IN":case"SCTE35-OUT":s=!0}if(t&&(o||s))r=oj(t,r);else if(!s&&!o)switch(a){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(`${e}: attribute ${a} is missing quotes`)}i[a]=r}return i}}])}();function hj(e){return"ID"!==e&&"CLASS"!==e&&"CUE"!==e&&"START-DATE"!==e&&"DURATION"!==e&&"END-DATE"!==e&&"END-ON-NEXT"!==e}function mj(e){return"SCTE35-OUT"===e||"SCTE35-IN"===e||"SCTE35-CMD"===e}var fj=function(){return c(function e(t,n,i=0){var a;if(o(this,e),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==n?void 0:n.tagAnchor)||null,this.tagOrder=null!=(a=null==n?void 0:n.tagOrder)?a:i,n){var r=n.attr;for(var s in r)if(Object.prototype.hasOwnProperty.call(t,s)&&t[s]!==r[s]){L$.warn(`DATERANGE tag attribute: "${s}" does not match for tags with ID: "${t.ID}"`),this._badValueForSameId=s;break}t=P$(new cj({}),r,t)}if(this.attr=t,n?(this._startDate=n._startDate,this._cue=n._cue,this._endDate=n._endDate,this._dateAtEnd=n._dateAtEnd):this._startDate=new Date(t["START-DATE"]),"END-DATE"in this.attr){var u=(null==n?void 0:n.endDate)||new Date(this.attr["END-DATE"]);u$(u.getTime())&&(this._endDate=u)}},[{key:"id",get:function(){return this.attr.ID}},{key:"class",get:function(){return this.attr.CLASS}},{key:"cue",get:function(){var e=this._cue;return void 0===e?this._cue=this.attr.enumeratedStringList(this.attr.CUE?"CUE":"X-CUE",{pre:!1,post:!1,once:!1}):e}},{key:"startTime",get:function(){var e=this.tagAnchor;return null===e||null===e.programDateTime?(L$.warn(`Expected tagAnchor Fragment with PDT set for DateRange "${this.id}": ${e}`),NaN):e.start+(this.startDate.getTime()-e.programDateTime)/1e3}},{key:"startDate",get:function(){return this._startDate}},{key:"endDate",get:function(){var e=this._endDate||this._dateAtEnd;if(e)return e;var t=this.duration;return null!==t?this._dateAtEnd=new Date(this._startDate.getTime()+1e3*t):null}},{key:"duration",get:function(){if("DURATION"in this.attr){var e=this.attr.decimalFloatingPoint("DURATION");if(u$(e))return e}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}},{key:"plannedDuration",get:function(){return"PLANNED-DURATION"in this.attr?this.attr.decimalFloatingPoint("PLANNED-DURATION"):null}},{key:"endOnNext",get:function(){return this.attr.bool("END-ON-NEXT")}},{key:"isInterstitial",get:function(){return"com.apple.hls.interstitial"===this.class}},{key:"isValid",get:function(){return!!this.id&&!this._badValueForSameId&&u$(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)}}])}(),vj=function(){return c(function e(t){o(this,e),this.PTSKnown=!1,this.alignedSliding=!1,this.averagetargetduration=void 0,this.endCC=0,this.endSN=0,this.fragments=void 0,this.fragmentHint=void 0,this.partList=null,this.dateRanges=void 0,this.dateRangeTagCount=0,this.live=!0,this.requestScheduled=-1,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.misses=0,this.startCC=0,this.startSN=0,this.startTimeOffset=null,this.targetduration=0,this.totalduration=0,this.type=null,this.url=void 0,this.m3u8="",this.version=null,this.canBlockReload=!1,this.canSkipUntil=0,this.canSkipDateRanges=!1,this.skippedSegments=0,this.recentlyRemovedDateranges=void 0,this.partHoldBack=0,this.holdBack=0,this.partTarget=0,this.preloadHint=void 0,this.renditionReports=void 0,this.tuneInGoal=0,this.deltaUpdateFailed=void 0,this.driftStartTime=0,this.driftEndTime=0,this.driftStart=0,this.driftEnd=0,this.encryptedFragments=void 0,this.playlistParsingError=null,this.variableList=null,this.hasVariableRefs=!1,this.appliedTimelineOffset=void 0,this.fragments=[],this.encryptedFragments=[],this.dateRanges={},this.url=t},[{key:"reloaded",value:function(e){if(!e)return this.advanced=!0,void(this.updated=!0);var t=this.lastPartSn-e.lastPartSn,n=this.lastPartIndex-e.lastPartIndex;this.updated=this.endSN!==e.endSN||!!n||!!t||!this.live,this.advanced=this.endSN>e.endSN||t>0||0===t&&n>0,this.updated||this.advanced?this.misses=Math.floor(.6*e.misses):this.misses=e.misses+1}},{key:"hasKey",value:function(e){return this.encryptedFragments.some(t=>{var n=t.decryptdata;return n||(t.setKeyFormat(e.keyFormat),n=t.decryptdata),!!n&&e.matches(n)})}},{key:"hasProgramDateTime",get:function(){return!!this.fragments.length&&u$(this.fragments[this.fragments.length-1].programDateTime)}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||10}},{key:"drift",get:function(){var e=this.driftEndTime-this.driftStartTime;return e>0?1e3*(this.driftEnd-this.driftStart)/e:1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var e;return null!=(e=this.partList)&&e.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){return this.fragments.length?this.fragments[this.fragments.length-1].end:0}},{key:"fragmentStart",get:function(){return this.fragments.length?this.fragments[0].start:0}},{key:"age",get:function(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}},{key:"lastPartIndex",get:function(){var e;return null!=(e=this.partList)&&e.length?this.partList[this.partList.length-1].index:-1}},{key:"maxPartIndex",get:function(){var e=this.partList;if(e){var t=this.lastPartIndex;if(-1!==t){for(var n=e.length;n--;)if(e[n].index>t)return e[n].index;return t}}return 0}},{key:"lastPartSn",get:function(){var e;return null!=(e=this.partList)&&e.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}},{key:"expired",get:function(){if(this.live&&this.age&&this.misses<3){var e=this.partEnd-this.fragmentStart;return this.age>Math.max(e,this.totalduration)+this.levelTargetDuration}return!1}}])}();function pj(e,t){return e.length===t.length&&!e.some((e,n)=>e!==t[n])}function gj(e,t){return!e&&!t||!(!e||!t)&&pj(e,t)}function yj(e){return"AES-128"===e||"AES-256"===e||"AES-256-CTR"===e}function bj(e){switch(e){case"AES-128":case"AES-256":return UW;case"AES-256-CTR":return HW;default:throw new Error(`invalid full segment method ${e}`)}}function wj(e){return Uint8Array.from(atob(e),e=>e.charCodeAt(0))}function kj(e){return Uint8Array.from(unescape(encodeURIComponent(e)),e=>e.charCodeAt(0))}function Sj(e){var t=function(e,t,n){var i=e[t];e[t]=e[n],e[n]=i};t(e,0,3),t(e,1,2),t(e,4,5),t(e,6,7)}function Ej(e){var t,n,i=e.split(":"),a=null;if("data"===i[0]&&2===i.length){var r=i[1].split(";"),o=r[r.length-1].split(",");if(2===o.length){var s="base64"===o[0],u=o[1];s?(r.splice(-1,1),a=wj(u)):(t=kj(u).subarray(0,16),(n=new Uint8Array(16)).set(t,16-t.length),a=n)}}return a}var Pj="undefined"!=typeof self?self:void 0,Tj={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},_j="org.w3.clearkey",Mj="com.apple.streamingkeydelivery",Aj="com.microsoft.playready",Dj="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed";function xj(e){switch(e){case Mj:return Tj.FAIRPLAY;case Aj:return Tj.PLAYREADY;case Dj:return Tj.WIDEVINE;case _j:return Tj.CLEARKEY}}function Cj(e){switch(e){case Tj.FAIRPLAY:return Mj;case Tj.PLAYREADY:return Aj;case Tj.WIDEVINE:return Dj;case Tj.CLEARKEY:return _j}}function Ij(e){var t=e.drmSystems,n=e.widevineLicenseUrl,i=t?[Tj.FAIRPLAY,Tj.WIDEVINE,Tj.PLAYREADY,Tj.CLEARKEY].filter(e=>!!t[e]):[];return!i[Tj.WIDEVINE]&&n&&i.push(Tj.WIDEVINE),i}var Lj,Rj=null!=Pj&&null!=(Lj=Pj.navigator)&&Lj.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null;function Fj(e){var t=new Uint16Array(e.buffer,e.byteOffset,e.byteLength/2),n=String.fromCharCode.apply(null,Array.from(t)),i=n.substring(n.indexOf("<"),n.length),a=(new DOMParser).parseFromString(i,"text/xml").getElementsByTagName("KID")[0];if(a){var r=a.childNodes[0]?a.childNodes[0].nodeValue:a.getAttribute("VALUE");if(r){var o=wj(r).subarray(0,16);return Sj(o),o}}return null}var Oj={},$j=function(){function e(t,n,i,a=[1],r=null,s){o(this,e),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=n,this.keyFormat=i,this.keyFormatVersions=a,this.iv=r,this.encrypted=!!t&&"NONE"!==t,this.isCommonEncryption=this.encrypted&&!yj(t),null!=s&&s.startsWith("0x")&&(this.keyId=new Uint8Array(N$(s)))}return c(e,[{key:"matches",value:function(e){return e.uri===this.uri&&e.method===this.method&&e.encrypted===this.encrypted&&e.keyFormat===this.keyFormat&&pj(e.keyFormatVersions,this.keyFormatVersions)&&gj(e.iv,this.iv)&&gj(e.keyId,this.keyId)}},{key:"isSupported",value:function(){if(this.method){if(yj(this.method)||"NONE"===this.method)return!0;if("identity"===this.keyFormat)return"SAMPLE-AES"===this.method;switch(this.keyFormat){case Mj:case Dj:case Aj:case _j:return-1!==["SAMPLE-AES","SAMPLE-AES-CENC","SAMPLE-AES-CTR"].indexOf(this.method)}}return!1}},{key:"getDecryptData",value:function(t,n){if(!this.encrypted||!this.uri)return null;if(yj(this.method)){var i=this.iv;return i||("number"!=typeof t&&(L$.warn(`missing IV for initialization segment with method="${this.method}" - compliance issue`),t=0),i=function(e){for(var t=new Uint8Array(16),n=12;n<16;n++)t[n]=e>>8*(15-n)&255;return t}(t)),new e(this.method,this.uri,"identity",this.keyFormatVersions,i)}if(this.keyId){var a=Oj[this.uri];if(a&&!pj(this.keyId,a)&&e.setKeyIdForUri(this.uri,this.keyId),this.pssh)return this}var r,o=Ej(this.uri);if(o)switch(this.keyFormat){case Dj:if(this.pssh=o,!this.keyId){var s=function(e){var t=[];if(e instanceof ArrayBuffer)for(var n=e.byteLength,i=0;i+32<n;){var a=EN(new DataView(e,i));t.push(a),i+=a.size}return t}(o.buffer);if(s.length){var u,l=s[0];this.keyId=null!=(u=l.kids)&&u.length?l.kids[0]:null}}this.keyId||(this.keyId=Nj(n));break;case Aj:var d=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=SN(d,0,o),this.keyId=Fj(o);break;default:var c=o.subarray(0,16);if(16!==c.length){var h=new Uint8Array(16);h.set(c,16-c.length),c=h}this.keyId=c}this.keyId&&16===this.keyId.byteLength||(r=function(e){var t=null==e?void 0:e[Dj];if(t)return t.keyId;return null}(n),r||(r=Nj(n))||(r=Oj[this.uri]),r&&(this.keyId=r,e.setKeyIdForUri(this.uri,r)));return this}}],[{key:"clearKeyUriToKeyIdMap",value:function(){Oj={}}},{key:"setKeyIdForUri",value:function(e,t){Oj[e]=t}},{key:"addKeyIdForUri",value:function(e){var t=Object.keys(Oj).length%Number.MAX_SAFE_INTEGER,n=new Uint8Array(16);return new DataView(n.buffer,12,4).setUint32(0,t),Oj[e]=n,n}}])}();function Nj(e){var t=null==e?void 0:e[Aj];if(t){var n=Ej(t.uri);if(n)return Fj(n)}return null}var Wj=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-(SESSION-DATA|SESSION-KEY|DEFINE|CONTENT-STEERING|START):([^\r\n]*)[\r\n]+/g,jj=/#EXT-X-MEDIA:(.*)/g,Bj=/^#EXT(?:INF|-X-TARGETDURATION):/m,zj=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[^\r\n]*)/.source,/#.*/.source].join("|"),"g"),Uj=new RegExp([/#EXT-X-(PROGRAM-DATE-TIME|BYTERANGE|DATERANGE|DEFINE|KEY|MAP|PART|PART-INF|PLAYLIST-TYPE|PRELOAD-HINT|RENDITION-REPORT|SERVER-CONTROL|SKIP|START):(.+)/.source,/#EXT-X-(BITRATE|DISCONTINUITY-SEQUENCE|MEDIA-SEQUENCE|TARGETDURATION|VERSION): *(\d+)/.source,/#EXT-X-(DISCONTINUITY|ENDLIST|GAP|INDEPENDENT-SEGMENTS)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|")),Hj=function(){function e(){o(this,e)}return c(e,null,[{key:"findGroup",value:function(e,t){for(var n=0;n<e.length;n++){var i=e[n];if(i.id===t)return i}}},{key:"resolve",value:function(e,t){return z$.buildAbsoluteURL(t,e,{alwaysNormalize:!0})}},{key:"isMediaPlaylist",value:function(e){return Bj.test(e)}},{key:"parseMasterPlaylist",value:function(t,n){var i,a={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:rj(t)},r=[];if(Wj.lastIndex=0,!t.startsWith("#EXTM3U"))return a.playlistParsingError=new Error("no EXTM3U delimiter"),a;for(;null!=(i=Wj.exec(t));)if(i[1]){var o,s=new cj(i[1],a),u=oj(a,i[2]),l={attrs:s,bitrate:s.decimalInteger("BANDWIDTH")||s.decimalInteger("AVERAGE-BANDWIDTH"),name:s.NAME,url:e.resolve(u,n)},d=s.decimalResolution("RESOLUTION");d&&(l.width=d.width,l.height=d.height),Yj(s.CODECS,l);var c=s["SUPPLEMENTAL-CODECS"];c&&(l.supplemental={},Yj(c,l.supplemental)),null!=(o=l.unknownCodecs)&&o.length||r.push(l),a.levels.push(l)}else if(i[3]){var h=i[3],m=i[4];switch(h){case"SESSION-DATA":var f=new cj(m,a),v=f["DATA-ID"];v&&(null===a.sessionData&&(a.sessionData={}),a.sessionData[v]=f);break;case"SESSION-KEY":var p=Kj(m,n,a);p.encrypted&&p.isSupported()?(null===a.sessionKeys&&(a.sessionKeys=[]),a.sessionKeys.push(p)):L$.warn(`[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "${m}"`);break;case"DEFINE":sj(a,new cj(m,a),n);break;case"CONTENT-STEERING":var g=new cj(m,a);a.contentSteering={uri:e.resolve(g["SERVER-URI"],n),pathwayId:g["PATHWAY-ID"]||"."};break;case"START":a.startTimeOffset=Xj(m)}}var y=r.length>0&&r.length<a.levels.length;return a.levels=y?r:a.levels,0===a.levels.length&&(a.playlistParsingError=new Error("no levels found in manifest")),a}},{key:"parseMasterPlaylistMedia",value:function(t,n,i){var a,r={},o=i.levels,s={AUDIO:o.map(e=>({id:e.attrs.AUDIO,audioCodec:e.audioCodec})),SUBTITLES:o.map(e=>({id:e.attrs.SUBTITLES,textCodec:e.textCodec})),"CLOSED-CAPTIONS":[]},u=0;for(jj.lastIndex=0;null!==(a=jj.exec(t));){var l=new cj(a[1],i),d=l.TYPE;if(d){var c=s[d],h=r[d]||[];r[d]=h;var m=l.LANGUAGE,f=l["ASSOC-LANGUAGE"],v=l.CHANNELS,p=l.CHARACTERISTICS,g=l["INSTREAM-ID"],y={attrs:l,bitrate:0,id:u++,groupId:l["GROUP-ID"]||"",name:l.NAME||m||"",type:d,default:l.bool("DEFAULT"),autoselect:l.bool("AUTOSELECT"),forced:l.bool("FORCED"),lang:m,url:l.URI?e.resolve(l.URI,n):""};if(f&&(y.assocLang=f),v&&(y.channels=v),p&&(y.characteristics=p),g&&(y.instreamId=g),null!=c&&c.length){var b=e.findGroup(c,y.groupId)||c[0];qj(y,b,"audioCodec"),qj(y,b,"textCodec")}h.push(y)}}return r}},{key:"parseLevelPlaylist",value:function(e,t,n,i,a,r){var o,s,u,l,d,c={url:t},h=new vj(t),m=h.fragments,f=[],v=null,p=0,g=0,y=0,b=0,w=0,k=null,S=new Y$(i,c),E=-1,P=!1,T=null;if(zj.lastIndex=0,h.m3u8=e,h.hasVariableRefs=rj(e),"#EXTM3U"!==(null==(o=zj.exec(e))?void 0:o[0]))return h.playlistParsingError=new Error("Missing format identifier #EXTM3U"),h;for(;null!==(s=zj.exec(e));){P&&(P=!1,(S=new Y$(i,c)).playlistOffset=y,S.setStart(y),S.sn=p,S.cc=b,w&&(S.bitrate=w),S.level=n,v&&(S.initSegment=v,v.rawProgramDateTime&&(S.rawProgramDateTime=v.rawProgramDateTime,v.rawProgramDateTime=null),T&&(S.setByteRange(T),T=null)));var _=s[1];if(_){S.duration=parseFloat(_);var M=(" "+s[2]).slice(1);S.title=M||null,S.tagList.push(M?["INF",_,M]:["INF",_])}else if(s[3]){if(u$(S.duration)){S.playlistOffset=y,S.setStart(y),l&&Zj(S,l,h),S.sn=p,S.level=n,S.cc=b,m.push(S);var A=(" "+s[3]).slice(1);S.relurl=oj(h,A),Jj(S,k,f),k=S,y+=S.duration,p++,g=0,P=!0}}else{if(!(s=s[0].match(Uj))){L$.warn("No matches on slow regex match for level playlist!");continue}for(u=1;u<s.length&&void 0===s[u];u++);var D=(" "+s[u]).slice(1),x=(" "+s[u+1]).slice(1),C=s[u+2]?(" "+s[u+2]).slice(1):null;switch(D){case"BYTERANGE":k?S.setByteRange(x,k):S.setByteRange(x);break;case"PROGRAM-DATE-TIME":S.rawProgramDateTime=x,S.tagList.push(["PROGRAM-DATE-TIME",x]),-1===E&&(E=m.length);break;case"PLAYLIST-TYPE":h.type&&eB(h,D,s),h.type=x.toUpperCase();break;case"MEDIA-SEQUENCE":0!==h.startSN?eB(h,D,s):m.length>0&&tB(h,D,s),p=h.startSN=parseInt(x);break;case"SKIP":h.skippedSegments&&eB(h,D,s);var I=new cj(x,h),L=I.decimalInteger("SKIPPED-SEGMENTS");if(u$(L)){h.skippedSegments+=L;for(var R=L;R--;)m.push(null);p+=L}var F=I.enumeratedString("RECENTLY-REMOVED-DATERANGES");F&&(h.recentlyRemovedDateranges=(h.recentlyRemovedDateranges||[]).concat(F.split("\t")));break;case"TARGETDURATION":0!==h.targetduration&&eB(h,D,s),h.targetduration=Math.max(parseInt(x),1);break;case"VERSION":null!==h.version&&eB(h,D,s),h.version=parseInt(x);break;case"INDEPENDENT-SEGMENTS":break;case"ENDLIST":h.live||eB(h,D,s),h.live=!1;break;case"#":(x||C)&&S.tagList.push(C?[x,C]:[x]);break;case"DISCONTINUITY":b++,S.tagList.push(["DIS"]);break;case"GAP":S.gap=!0,S.tagList.push([D]);break;case"BITRATE":S.tagList.push([D,x]),w=1e3*parseInt(x),u$(w)?S.bitrate=w:w=0;break;case"DATERANGE":var O=new cj(x,h),$=new fj(O,h.dateRanges[O.ID],h.dateRangeTagCount);h.dateRangeTagCount++,$.isValid||h.skippedSegments?h.dateRanges[$.id]=$:L$.warn(`Ignoring invalid DATERANGE tag: "${x}"`),S.tagList.push(["EXT-X-DATERANGE",x]);break;case"DEFINE":var N=new cj(x,h);"IMPORT"in N?uj(h,N,r):sj(h,N,t);break;case"DISCONTINUITY-SEQUENCE":0!==h.startCC?eB(h,D,s):m.length>0&&tB(h,D,s),h.startCC=b=parseInt(x);break;case"KEY":var W=Kj(x,t,h);if(W.isSupported()){if("NONE"===W.method){l=void 0;break}l||(l={});var j=l[W.keyFormat];null!=j&&j.matches(W)||(j&&(l=P$({},l)),l[W.keyFormat]=W)}else L$.warn(`[Keys] Ignoring unsupported EXT-X-KEY tag: "${x}"`);break;case"START":h.startTimeOffset=Xj(x);break;case"MAP":var B=new cj(x,h);if(S.duration){var z=new Y$(i,c);Qj(z,B,n,l),v=z,S.initSegment=v,v.rawProgramDateTime&&!S.rawProgramDateTime&&(S.rawProgramDateTime=v.rawProgramDateTime)}else{var U=S.byteRangeEndOffset;if(U){var H=S.byteRangeStartOffset;T=`${U-H}@${H}`}else T=null;Qj(S,B,n,l),v=S,P=!0}v.cc=b;break;case"SERVER-CONTROL":d&&eB(h,D,s),d=new cj(x),h.canBlockReload=d.bool("CAN-BLOCK-RELOAD"),h.canSkipUntil=d.optionalFloat("CAN-SKIP-UNTIL",0),h.canSkipDateRanges=h.canSkipUntil>0&&d.bool("CAN-SKIP-DATERANGES"),h.partHoldBack=d.optionalFloat("PART-HOLD-BACK",0),h.holdBack=d.optionalFloat("HOLD-BACK",0);break;case"PART-INF":h.partTarget&&eB(h,D,s);var G=new cj(x);h.partTarget=G.decimalFloatingPoint("PART-TARGET");break;case"PART":var V=h.partList;V||(V=h.partList=[]);var K=g>0?V[V.length-1]:void 0,X=g++,Y=new cj(x,h),q=new q$(Y,S,c,X,K);V.push(q),S.duration+=q.duration;break;case"PRELOAD-HINT":var J=new cj(x,h);h.preloadHint=J;break;case"RENDITION-REPORT":var Q=new cj(x,h);h.renditionReports=h.renditionReports||[],h.renditionReports.push(Q);break;default:L$.warn(`line parsed but not handled: ${s}`)}}}k&&!k.relurl?(m.pop(),y-=k.duration,h.partList&&(h.fragmentHint=k)):h.partList&&(Jj(S,k,f),S.cc=b,h.fragmentHint=S,l&&Zj(S,l,h)),h.targetduration||(h.playlistParsingError=new Error("Missing Target Duration"));var Z=m.length,ee=m[0],te=m[Z-1];if((y+=h.skippedSegments*h.targetduration)>0&&Z&&te){h.averagetargetduration=y/Z;var ne=te.sn;h.endSN="initSegment"!==ne?ne:0,h.live||(te.endList=!0),E>0&&(!function(e,t){for(var n=e[t],i=t;i--;){var a=e[i];if(!a)return;a.programDateTime=n.programDateTime-1e3*a.duration,n=a}}(m,E),ee&&f.unshift(ee))}return h.fragmentHint&&(y+=h.fragmentHint.duration),h.totalduration=y,f.length&&h.dateRangeTagCount&&ee&&Gj(f,h),h.endCC=b,h}}])}();function Gj(e,t){var n=e.length;if(!n){if(!t.hasProgramDateTime)return;var i=t.fragments[t.fragments.length-1];e.push(i),n++}for(var a=e[n-1],r=t.live?1/0:t.totalduration,o=Object.keys(t.dateRanges),s=o.length;s--;){var u=t.dateRanges[o[s]],l=u.startDate.getTime();u.tagAnchor=a.ref;for(var d=n;d--;){var c;if((null==(c=e[d])?void 0:c.sn)<t.startSN)break;var h=Vj(t,l,e,d,r);if(-1!==h){u.tagAnchor=t.fragments[h].ref;break}}}}function Vj(e,t,n,i,a){var r=n[i];if(r){var o,s=r.programDateTime;if(t>=s||0===i)if(t<=s+1e3*(((null==(o=n[i+1])?void 0:o.start)||a)-r.start)){var u=n[i].sn-e.startSN;if(u<0)return-1;var l=e.fragments;if(l.length>n.length)for(var d=(n[i+1]||l[l.length-1]).sn-e.startSN;d>u;d--){var c=l[d].programDateTime;if(t>=c&&t<c+1e3*l[d].duration)return d}return u}}return-1}function Kj(e,t,n){var i,a,r=new cj(e,n),o=null!=(i=r.METHOD)?i:"",s=r.URI,u=r.hexadecimalInteger("IV"),l=r.KEYFORMATVERSIONS,d=null!=(a=r.KEYFORMAT)?a:"identity";s&&r.IV&&!u&&L$.error(`Invalid IV: ${r.IV}`);var c=s?Hj.resolve(s,t):"",h=(l||"1").split("/").map(Number).filter(Number.isFinite);return new $j(o,c,d,h,u,r.KEYID)}function Xj(e){var t=new cj(e).decimalFloatingPoint("TIME-OFFSET");return u$(t)?t:null}function Yj(e,t){var n=(e||"").split(/[ ,]+/).filter(e=>e);["video","audio","text"].forEach(e=>{var i=n.filter(t=>_N(t,e));i.length&&(t[`${e}Codec`]=i.map(e=>e.split("/")[0]).join(","),n=n.filter(e=>-1===i.indexOf(e)))}),t.unknownCodecs=n}function qj(e,t,n){var i=t[n];i&&(e[n]=i)}function Jj(e,t,n){e.rawProgramDateTime?n.push(e):null!=t&&t.programDateTime&&(e.programDateTime=t.endProgramDateTime)}function Qj(e,t,n,i){e.relurl=t.URI,t.BYTERANGE&&e.setByteRange(t.BYTERANGE),e.level=n,e.sn="initSegment",i&&(e.levelkeys=i),e.initSegment=null}function Zj(e,t,n){e.levelkeys=t;var i=n.encryptedFragments;i.length&&i[i.length-1].levelkeys===t||!Object.keys(t).some(e=>t[e].isCommonEncryption)||i.push(e)}function eB(e,t,n){e.playlistParsingError=new Error(`#EXT-X-${t} must not appear more than once (${n[0]})`)}function tB(e,t,n){e.playlistParsingError=new Error(`#EXT-X-${t} must appear before the first Media Segment (${n[0]})`)}function nB(e,t){var n=t.startPTS;if(u$(n)){var i,a=0;t.sn>e.sn?(a=n-e.start,i=e):(a=e.start-n,i=t),i.duration!==a&&i.setDuration(a)}else if(t.sn>e.sn){e.cc===t.cc&&e.minEndPTS?t.setStart(e.start+(e.minEndPTS-e.start)):t.setStart(e.start+e.duration)}else t.setStart(Math.max(e.start-t.duration,0))}function iB(e,t,n,i,a,r,o){i-n<=0&&(o.warn("Fragment should have a positive duration",t),i=n+t.duration,r=a+t.duration);var s=n,u=i,l=t.startPTS,d=t.endPTS;if(u$(l)){var c=Math.abs(l-n);e&&c>e.totalduration?o.warn(`media timestamps and playlist times differ by ${c}s for level ${t.level} ${e.url}`):u$(t.deltaPTS)?t.deltaPTS=Math.max(c,t.deltaPTS):t.deltaPTS=c,s=Math.max(n,l),n=Math.min(n,l),a=void 0!==t.startDTS?Math.min(a,t.startDTS):a,u=Math.min(i,d),i=Math.max(i,d),r=void 0!==t.endDTS?Math.max(r,t.endDTS):r}var h=n-t.start;0!==t.start&&t.setStart(n),t.setDuration(i-t.start),t.startPTS=n,t.maxStartPTS=s,t.startDTS=a,t.endPTS=i,t.minEndPTS=u,t.endDTS=r;var m,f=t.sn;if(!e||f<e.startSN||f>e.endSN)return 0;var v=f-e.startSN,p=e.fragments;for(p[v]=t,m=v;m>0;m--)nB(p[m],p[m-1]);for(m=v;m<p.length-1;m++)nB(p[m],p[m+1]);return e.fragmentHint&&nB(p[p.length-1],e.fragmentHint),e.PTSKnown=e.alignedSliding=!0,h}function aB(e,t,n){if(e!==t){for(var i,a=null,r=e.fragments,o=r.length-1;o>=0;o--){var s=r[o].initSegment;if(s){a=s;break}}e.fragmentHint&&delete e.fragmentHint.endPTS,function(e,t,n){for(var i=t.skippedSegments,a=Math.max(e.startSN,t.startSN)-t.startSN,r=(e.fragmentHint?1:0)+(i?t.endSN:Math.min(e.endSN,t.endSN))-t.startSN,o=t.startSN-e.startSN,s=t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments,u=e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments,l=a;l<=r;l++){var d=u[o+l],c=s[l];if(i&&!c&&d&&(c=t.fragments[l]=d),d&&c){n(d,c,l,s);var h=d.relurl,m=c.relurl;if(h&&mB(h,m))return void(t.playlistParsingError=rB(`media sequence mismatch ${c.sn}:`,e,t,d,c));if(d.cc!==c.cc)return void(t.playlistParsingError=rB(`discontinuity sequence mismatch (${d.cc}!=${c.cc})`,e,t,d,c))}}}(e,t,(e,n,r,o)=>{if((!t.startCC||t.skippedSegments)&&n.cc!==e.cc){for(var s=e.cc-n.cc,u=r;u<o.length;u++)o[u].cc+=s;t.endCC=o[o.length-1].cc}u$(e.startPTS)&&u$(e.endPTS)&&(n.setStart(n.startPTS=e.startPTS),n.startDTS=e.startDTS,n.maxStartPTS=e.maxStartPTS,n.endPTS=e.endPTS,n.endDTS=e.endDTS,n.minEndPTS=e.minEndPTS,n.setDuration(e.endPTS-e.startPTS),n.duration&&(i=n),t.PTSKnown=t.alignedSliding=!0),e.hasStreams&&(n.elementaryStreams=e.elementaryStreams),n.loader=e.loader,e.hasStats&&(n.stats=e.stats),e.initSegment&&(n.initSegment=e.initSegment,a=e.initSegment)});var u=t.fragments,l=t.fragmentHint?u.concat(t.fragmentHint):u;if(a&&l.forEach(e=>{var t;!e||e.initSegment&&e.initSegment.relurl!==(null==(t=a)?void 0:t.relurl)||(e.initSegment=a)}),t.skippedSegments){if(t.deltaUpdateFailed=u.some(e=>!e),t.deltaUpdateFailed){n.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var d=t.skippedSegments;d--;)u.shift();t.startSN=u[0].sn}else{t.canSkipDateRanges&&(t.dateRanges=function(e,t,n){var i=t.dateRanges,a=t.recentlyRemovedDateranges,r=P$({},e);a&&a.forEach(e=>{delete r[e]});var o=Object.keys(r).length;if(!o)return i;return Object.keys(i).forEach(e=>{var t=r[e],a=new fj(i[e].attr,t);a.isValid?(r[e]=a,t||(a.tagOrder+=o)):n.warn(`Ignoring invalid Playlist Delta Update DATERANGE tag: "${nW(i[e].attr)}"`)}),r}(e.dateRanges,t,n));var c=e.fragments.filter(e=>e.rawProgramDateTime);if(e.hasProgramDateTime&&!t.hasProgramDateTime)for(var h=1;h<l.length;h++)null===l[h].programDateTime&&Jj(l[h],l[h-1],c);Gj(c,t)}t.endCC=u[u.length-1].cc}if(!t.startCC){var m,f=lB(e,t.startSN-1);t.startCC=null!=(m=null==f?void 0:f.cc)?m:u[0].cc}!function(e,t,n){if(e&&t)for(var i=0,a=0,r=e.length;a<=r;a++){var o=e[a],s=t[a+i];o&&s&&o.index===s.index&&o.fragment.sn===s.fragment.sn?n(o,s):i--}}(e.partList,t.partList,(e,t)=>{t.elementaryStreams=e.elementaryStreams,t.stats=e.stats}),i?iB(t,i,i.startPTS,i.endPTS,i.startDTS,i.endDTS,n):oB(e,t),u.length&&(t.totalduration=t.edge-u[0].start),t.driftStartTime=e.driftStartTime,t.driftStart=e.driftStart;var v=t.advancedDateTime;if(t.advanced&&v){var p=t.edge;t.driftStart||(t.driftStartTime=v,t.driftStart=p),t.driftEndTime=v,t.driftEnd=p}else t.driftEndTime=e.driftEndTime,t.driftEnd=e.driftEnd,t.advancedDateTime=e.advancedDateTime;-1===t.requestScheduled&&(t.requestScheduled=e.requestScheduled)}}function rB(e,t,n,i,a){return new Error(`${e} ${a.url}\nPlaylist starting @${t.startSN}\n${t.m3u8}\n\nPlaylist starting @${n.startSN}\n${n.m3u8}`)}function oB(e,t,n=!0){var i=t.startSN+t.skippedSegments-e.startSN,a=e.fragments,r=i>=0,o=0;if(r&&i<a.length)o=a[i].start;else if(r&&t.startSN===e.endSN+1)o=e.fragmentEnd;else if(r&&n)o=e.fragmentStart+i*t.levelTargetDuration;else{if(t.skippedSegments||0!==t.fragmentStart)return;o=e.fragmentStart}sB(t,o)}function sB(e,t){if(t){for(var n=e.fragments,i=e.skippedSegments;i<n.length;i++)n[i].addStart(t);e.fragmentHint&&e.fragmentHint.addStart(t)}}function uB(e,t=1/0){var n=1e3*e.targetduration;if(e.updated){var i=e.fragments;if(i.length&&4*n>t){var a=1e3*i[i.length-1].duration;a<n&&(n=a)}}else n/=2;return Math.round(n)}function lB(e,t,n){if(!e)return null;var i=e.fragments[t-e.startSN];return i||((i=e.fragmentHint)&&i.sn===t?i:t<e.startSN&&n&&n.sn===t?n:null)}function dB(e,t,n){return e?cB(e.partList,t,n):null}function cB(e,t,n){if(e)for(var i=e.length;i--;){var a=e[i];if(a.index===n&&a.fragment.sn===t)return a}return null}function hB(e){e.forEach((e,t)=>{var n;null==(n=e.details)||n.fragments.forEach(e=>{e.level=t,e.initSegment&&(e.initSegment.level=t)})})}function mB(e,t){return!(e===t||!t)&&fB(e)!==fB(t)}function fB(e){return e.replace(/\?[^?]*$/,"")}function vB(e,t){for(var n=0,i=e.length;n<i;n++){var a;if((null==(a=e[n])?void 0:a.cc)===t)return e[n]}return null}function pB(e,t){var n=e.start+t;e.startPTS=n,e.setStart(n),e.endPTS=n+e.duration}function gB(e,t){for(var n=t.fragments,i=0,a=n.length;i<a;i++)pB(n[i],e);t.fragmentHint&&pB(t.fragmentHint,e),t.alignedSliding=!0}function yB(e,t){if(function(e,t){return!!(e&&t.startCC<e.endCC&&t.endCC>e.startCC)}(t,e)){var n=Math.min(t.endCC,e.endCC),i=vB(t.fragments,n),a=vB(e.fragments,n);if(i&&a)L$.log(`Aligning playlist at start of dicontinuity sequence ${n}`),gB(i.start-a.start,e)}}function bB(e,t){if(e.hasProgramDateTime&&t.hasProgramDateTime){var n=e.fragments,i=t.fragments;if(n.length&&i.length){var a,r,o=Math.min(t.endCC,e.endCC);t.startCC<o&&e.startCC<o&&(a=vB(i,o),r=vB(n,o)),a&&r||(r=vB(n,(a=i[Math.floor(i.length/2)]).cc)||n[Math.floor(n.length/2)]);var s=a.programDateTime,u=r.programDateTime;if(s&&u)gB((u-s)/1e3-(r.start-a.start),e)}}}function wB(e,t,n){kB(e,t,n),e.addEventListener(t,n)}function kB(e,t,n){e.removeEventListener(t,n)}var SB=function(e){for(var t="",n=e.length,i=0;i<n;i++)t+=`[${e.start(i).toFixed(3)}-${e.end(i).toFixed(3)}]`;return t},EB="STOPPED",PB="IDLE",TB="KEY_LOADING",_B="FRAG_LOADING",MB="FRAG_LOADING_WAITING_RETRY",AB="WAITING_TRACK",DB="PARSING",xB="PARSED",CB="ENDED",IB="ERROR",LB="WAITING_INIT_PTS",RB="WAITING_LEVEL",FB=function(e){function t(e,n,i,a,s){var u;return o(this,t),(u=r(this,t,[a,e.logger])).hls=void 0,u.fragPrevious=null,u.fragCurrent=null,u.fragmentTracker=void 0,u.transmuxer=null,u._state=EB,u.playlistType=void 0,u.media=null,u.mediaBuffer=null,u.config=void 0,u.bitrateTest=!1,u.lastCurrentTime=0,u.nextLoadPosition=0,u.startPosition=0,u.startTimeOffset=null,u.retryDate=0,u.levels=null,u.fragmentLoader=void 0,u.keyLoader=void 0,u.levelLastLoaded=null,u.startFragRequested=!1,u.decrypter=void 0,u.initPTS=[],u.buffering=!0,u.loadingParts=!1,u.loopSn=void 0,u.onMediaSeeking=()=>{var e=u,t=e.config,n=e.fragCurrent,i=e.media,a=e.mediaBuffer,r=e.state,o=i?i.currentTime:0,s=ij.bufferInfo(a||i,o,t.maxBufferHole),l=!s.len;if(u.log(`Media seeking to ${u$(o)?o.toFixed(3):o}, state: ${r}, ${l?"out of":"in"} buffer`),u.state===CB)u.resetLoadingState();else if(n){var d=t.maxFragLookUpTolerance,c=n.start-d,h=n.start+n.duration+d;if(l||h<s.start||c>s.end){var m=o>h;(o<c||m)&&(m&&n.loader&&(u.log(`Cancelling fragment load for seek (sn: ${n.sn})`),n.abortRequests(),u.resetLoadingState()),u.fragPrevious=null)}}if(i&&(u.fragmentTracker.removeFragmentsInRange(o,1/0,u.playlistType,!0),o>u.lastCurrentTime&&(u.lastCurrentTime=o),!u.loadingParts)){var f=Math.max(s.end,o),v=u.shouldLoadParts(u.getLevelDetails(),f);v&&(u.log(`LL-Part loading ON after seeking to ${o.toFixed(2)} with buffer @${f.toFixed(2)}`),u.loadingParts=v)}u.hls.hasEnoughToStart||(u.log(`Setting ${l?"startPosition":"nextLoadPosition"} to ${o} for seek without enough to start`),u.nextLoadPosition=o,l&&(u.startPosition=o)),l&&u.state===PB&&u.tickImmediate()},u.onMediaEnded=()=>{u.log("setting startPosition to 0 because media ended"),u.startPosition=u.lastCurrentTime=0},u.playlistType=s,u.hls=e,u.fragmentLoader=new qW(e.config),u.keyLoader=i,u.fragmentTracker=n,u.config=e.config,u.decrypter=new XW(e.config),u}return p(t,e),c(t,[{key:"registerListeners",value:function(){var e=this.hls;e.on(m$.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(m$.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(m$.MANIFEST_LOADING,this.onManifestLoading,this),e.on(m$.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(m$.ERROR,this.onError,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e.off(m$.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(m$.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(m$.MANIFEST_LOADING,this.onManifestLoading,this),e.off(m$.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(m$.ERROR,this.onError,this)}},{key:"doTick",value:function(){this.onTickEnd()}},{key:"onTickEnd",value:function(){}},{key:"startLoad",value:function(e){}},{key:"stopLoad",value:function(){if(this.state!==EB){this.fragmentLoader.abort(),this.keyLoader.abort(this.playlistType);var e=this.fragCurrent;null!=e&&e.loader&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=EB}}},{key:"startPositionValue",get:function(){var e=this.nextLoadPosition,t=this.startPosition;return-1===t&&e?e:t}},{key:"bufferingEnabled",get:function(){return this.buffering}},{key:"pauseBuffering",value:function(){this.buffering=!1}},{key:"resumeBuffering",value:function(){this.buffering=!0}},{key:"inFlightFrag",get:function(){return{frag:this.fragCurrent,state:this.state}}},{key:"_streamEnded",value:function(e,t){if(t.live||!this.media)return!1;var n=e.end||0,i=this.config.timelineOffset||0;if(n<=i)return!1;var a=e.buffered;this.config.maxBufferHole&&a&&a.length>1&&(e=ij.bufferedInfo(a,e.start,0));var r=e.nextStart;if(r&&r>i&&r<t.edge)return!1;if(this.media.currentTime<e.start)return!1;var o=t.partList;if(null!=o&&o.length){var s=o[o.length-1];return ij.isBuffered(this.media,s.start+s.duration/2)}var u=t.fragments[t.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(u)}},{key:"getLevelDetails",value:function(){if(this.levels&&null!==this.levelLastLoaded)return this.levelLastLoaded.details}},{key:"timelineOffset",get:function(){var e,t=this.config.timelineOffset;return t?(null==(e=this.getLevelDetails())?void 0:e.appliedTimelineOffset)||t:0}},{key:"onMediaAttached",value:function(e,t){var n=this.media=this.mediaBuffer=t.media;wB(n,"seeking",this.onMediaSeeking),wB(n,"ended",this.onMediaEnded);var i=this.config;this.levels&&i.autoStartLoad&&this.state===EB&&this.startLoad(i.startPosition)}},{key:"onMediaDetaching",value:function(e,t){var n=!!t.transferMedia,i=this.media;if(null!==i){if(i.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),kB(i,"seeking",this.onMediaSeeking),kB(i,"ended",this.onMediaEnded),this.keyLoader&&!n&&this.keyLoader.detach(),this.media=this.mediaBuffer=null,this.loopSn=void 0,n)return this.resetLoadingState(),void this.resetTransmuxer();this.loadingParts=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()}}},{key:"onManifestLoading",value:function(){this.initPTS=[],this.levels=this.levelLastLoaded=this.fragCurrent=null,this.lastCurrentTime=this.startPosition=0,this.startFragRequested=!1}},{key:"onError",value:function(e,t){}},{key:"onManifestLoaded",value:function(e,t){this.startTimeOffset=t.startTimeOffset}},{key:"onHandlerDestroying",value:function(){this.stopLoad(),this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null),T(t,"onHandlerDestroying",this)([]),this.hls=this.onMediaSeeking=this.onMediaEnded=null}},{key:"onHandlerDestroyed",value:function(){this.state=EB,this.fragmentLoader&&this.fragmentLoader.destroy(),this.keyLoader&&this.keyLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.log=this.warn=this.decrypter=this.keyLoader=this.fragmentLoader=this.fragmentTracker=null,T(t,"onHandlerDestroyed",this)([])}},{key:"loadFragment",value:function(e,t,n){this.startFragRequested=!0,this._loadFragForPlayback(e,t,n)}},{key:"_loadFragForPlayback",value:function(e,t,n){this._doFragLoad(e,t,n,e=>{var t=e.frag;if(this.fragContextChanged(t))return this.warn(`${t.type} sn: ${t.sn}${e.part?" part: "+e.part.index:""} of ${this.fragInfo(t,!1,e.part)}) was dropped during download.`),void this.fragmentTracker.removeFragment(t);t.stats.chunkCount++,this._handleFragmentLoadProgress(e)}).then(e=>{if(e){var t=this.state,n=e.frag;this.fragContextChanged(n)?(t===_B||!this.fragCurrent&&t===DB)&&(this.fragmentTracker.removeFragment(n),this.state=PB):("payload"in e&&(this.log(`Loaded ${n.type} sn: ${n.sn} of ${this.playlistLabel()} ${n.level}`),this.hls.trigger(m$.FRAG_LOADED,e)),this._handleFragmentLoadComplete(e))}}).catch(t=>{this.state!==EB&&this.state!==IB&&(this.warn(`Frag error: ${(null==t?void 0:t.message)||t}`),this.resetFragmentLoading(e))})}},{key:"clearTrackerIfNeeded",value:function(e){var t,n=this.fragmentTracker;if(n.getState(e)===OW){var i=e.type,a=this.getFwdBufferInfo(this.mediaBuffer,i),r=Math.max(e.duration,a?a.len:this.config.maxBufferLength),o=this.backtrackFragment;(1===(o?e.sn-o.sn:0)||this.reduceMaxBufferLength(r,e.duration))&&n.removeFragment(e)}else 0===(null==(t=this.mediaBuffer)?void 0:t.buffered.length)?n.removeAllFragments():n.hasParts(e.type)&&(n.detectPartialFragments({frag:e,part:null,stats:e.stats,id:e.type}),n.getState(e)===$W&&n.removeFragment(e))}},{key:"checkLiveUpdate",value:function(e){if(e.updated&&!e.live){var t=e.fragments[e.fragments.length-1];this.fragmentTracker.detectPartialFragments({frag:t,part:null,stats:t.stats,id:t.type})}e.fragments[0]||(e.deltaUpdateFailed=!0)}},{key:"waitForLive",value:function(e){var t=e.details;return(null==t?void 0:t.live)&&"EVENT"!==t.type&&(this.levelLastLoaded!==e||t.expired)}},{key:"flushMainBuffer",value:function(e,t,n=null){if(e-t){var i={startOffset:e,endOffset:t,type:n};this.hls.trigger(m$.BUFFER_FLUSHING,i)}}},{key:"_loadInitSegment",value:function(e,t){this._doFragLoad(e,t).then(e=>{var t=null==e?void 0:e.frag;if(!t||this.fragContextChanged(t)||!this.levels)throw new Error("init load aborted");return e}).then(e=>{var t=this.hls,n=e.frag,i=e.payload,a=n.decryptdata;if(i&&i.byteLength>0&&null!=a&&a.key&&a.iv&&yj(a.method)){var r=self.performance.now();return this.decrypter.decrypt(new Uint8Array(i),a.key.buffer,a.iv.buffer,bj(a.method)).catch(e=>{throw t.trigger(m$.ERROR,{type:c$.MEDIA_ERROR,details:h$.FRAG_DECRYPT_ERROR,fatal:!1,error:e,reason:e.message,frag:n}),e}).then(i=>{var a=self.performance.now();return t.trigger(m$.FRAG_DECRYPTED,{frag:n,payload:i,stats:{tstart:r,tdecrypt:a}}),e.payload=i,this.completeInitSegmentLoad(e)})}return this.completeInitSegmentLoad(e)}).catch(t=>{this.state!==EB&&this.state!==IB&&(this.warn(t),this.resetFragmentLoading(e))})}},{key:"completeInitSegmentLoad",value:function(e){if(!this.levels)throw new Error("init load aborted, missing levels");var t=e.frag.stats;this.state!==EB&&(this.state=PB),e.frag.data=new Uint8Array(e.payload),t.parsing.start=t.buffering.start=self.performance.now(),t.parsing.end=t.buffering.end=self.performance.now(),this.tick()}},{key:"unhandledEncryptionError",value:function(e,t){var n,i,a=e.tracks;if(a&&!t.encrypted&&(null!=(n=a.audio)&&n.encrypted||null!=(i=a.video)&&i.encrypted)&&(!this.config.emeEnabled||!this.keyLoader.emeController)){var r=this.media,o=new Error(`Encrypted track with no key in ${this.fragInfo(t)} (media ${r?"attached mediaKeys: "+r.mediaKeys:"detached"})`);return this.warn(o.message),!r||r.mediaKeys?!1:(this.hls.trigger(m$.ERROR,{type:c$.KEY_SYSTEM_ERROR,details:h$.KEY_SYSTEM_NO_KEYS,fatal:!1,error:o,frag:t}),this.resetTransmuxer(),!0)}return!1}},{key:"fragContextChanged",value:function(e){var t=this.fragCurrent;return!e||!t||e.sn!==t.sn||e.level!==t.level}},{key:"fragBufferedComplete",value:function(e,t){var n=this.mediaBuffer?this.mediaBuffer:this.media;if(this.log(`Buffered ${e.type} sn: ${e.sn}${t?" part: "+t.index:""} of ${this.fragInfo(e,!1,t)} > buffer:${n?SB(ij.getBuffered(n)):"(detached)"})`),X$(e)){var i;if(e.type!==w$){var a=e.elementaryStreams;if(!Object.keys(a).some(e=>!!a[e]))return void(this.state=PB)}var r=null==(i=this.levels)?void 0:i[e.level];null!=r&&r.fragmentError&&(this.log(`Resetting level fragment error count of ${r.fragmentError} on frag buffered`),r.fragmentError=0)}this.state=PB}},{key:"_handleFragmentLoadComplete",value:function(e){var t=this.transmuxer;if(t){var n=e.frag,i=e.part,a=e.partsLoaded,r=!a||0===a.length||a.some(e=>!e),o=new tj(n.level,n.sn,n.stats.chunkCount+1,0,i?i.index:-1,!r);t.flush(o)}}},{key:"_handleFragmentLoadProgress",value:function(e){}},{key:"_doFragLoad",value:function(e,t,n=null,i){var a;this.fragCurrent=e;var r=t.details;if(!this.levels||!r)throw new Error(`frag load aborted, missing level${r?"":" detail"}s`);var o=null;if(!e.encrypted||null!=(a=e.decryptdata)&&a.key)e.encrypted||(o=this.keyLoader.loadClear(e,r.encryptedFragments,this.startFragRequested))&&this.log("[eme] blocking frag load until media-keys acquired");else if(this.log(`Loading key for ${e.sn} of [${r.startSN}-${r.endSN}], ${this.playlistLabel()} ${e.level}`),this.state=TB,this.fragCurrent=e,o=this.keyLoader.load(e).then(e=>{if(!this.fragContextChanged(e.frag))return this.hls.trigger(m$.KEY_LOADED,e),this.state===TB&&(this.state=PB),e}),this.hls.trigger(m$.KEY_LOADING,{frag:e}),null===this.fragCurrent)return this.log("context changed in KEY_LOADING"),Promise.resolve(null);var s,u=this.fragPrevious;if(X$(e)&&(!u||e.sn!==u.sn)){var l=this.shouldLoadParts(t.details,e.end);l!==this.loadingParts&&(this.log(`LL-Part loading ${l?"ON":"OFF"} loading sn ${null==u?void 0:u.sn}->${e.sn}`),this.loadingParts=l)}if(n=Math.max(e.start,n||0),this.loadingParts&&X$(e)){var d=r.partList;if(d&&i){n>r.fragmentEnd&&r.fragmentHint&&(e=r.fragmentHint);var c=this.getNextPart(d,e,n);if(c>-1){var h,m=d[c];return e=this.fragCurrent=m.fragment,this.log(`Loading ${e.type} sn: ${e.sn} part: ${m.index} (${c}/${d.length-1}) of ${this.fragInfo(e,!1,m)}) cc: ${e.cc} [${r.startSN}-${r.endSN}], target: ${parseFloat(n.toFixed(3))}`),this.nextLoadPosition=m.start+m.duration,this.state=_B,h=o?o.then(n=>!n||this.fragContextChanged(n.frag)?null:this.doFragPartsLoad(e,m,t,i)).catch(e=>this.handleFragLoadError(e)):this.doFragPartsLoad(e,m,t,i).catch(e=>this.handleFragLoadError(e)),this.hls.trigger(m$.FRAG_LOADING,{frag:e,part:m,targetBufferTime:n}),null===this.fragCurrent?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):h}if(!e.url||this.loadedEndOfParts(d,n))return Promise.resolve(null)}}if(X$(e)&&this.loadingParts)this.log(`LL-Part loading OFF after next part miss @${n.toFixed(2)} Check buffer at sn: ${e.sn} loaded parts: ${null==(s=r.partList)?void 0:s.filter(e=>e.loaded).map(e=>`[${e.start}-${e.end}]`)}`),this.loadingParts=!1;else if(!e.url)return Promise.resolve(null);this.log(`Loading ${e.type} sn: ${e.sn} of ${this.fragInfo(e,!1)}) cc: ${e.cc} ${"["+r.startSN+"-"+r.endSN+"]"}, target: ${parseFloat(n.toFixed(3))}`),u$(e.sn)&&!this.bitrateTest&&(this.nextLoadPosition=e.start+e.duration),this.state=_B;var f,v=this.config.progressive&&e.type!==w$;return f=v&&o?o.then(t=>!t||this.fragContextChanged(t.frag)?null:this.fragmentLoader.load(e,i)).catch(e=>this.handleFragLoadError(e)):Promise.all([this.fragmentLoader.load(e,v?i:void 0),o]).then(([e])=>(!v&&i&&i(e),e)).catch(e=>this.handleFragLoadError(e)),this.hls.trigger(m$.FRAG_LOADING,{frag:e,targetBufferTime:n}),null===this.fragCurrent?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):f}},{key:"doFragPartsLoad",value:function(e,t,n,i){return new Promise((a,r)=>{var o,s=[],u=null==(o=n.details)?void 0:o.partList,l=t=>{this.fragmentLoader.loadPart(e,t,i).then(i=>{s[t.index]=i;var r=i.part;this.hls.trigger(m$.FRAG_LOADED,i);var o=dB(n.details,e.sn,t.index+1)||cB(u,e.sn,t.index+1);if(!o)return a({frag:e,part:r,partsLoaded:s});l(o)}).catch(r)};l(t)})}},{key:"handleFragLoadError",value:function(e){if("data"in e){var t=e.data;t.frag&&t.details===h$.INTERNAL_ABORTED?this.handleFragLoadAborted(t.frag,t.part):t.frag&&t.type===c$.KEY_SYSTEM_ERROR?(t.frag.abortRequests(),this.resetStartWhenNotLoaded(),this.resetFragmentLoading(t.frag)):this.hls.trigger(m$.ERROR,t)}else this.hls.trigger(m$.ERROR,{type:c$.OTHER_ERROR,details:h$.INTERNAL_EXCEPTION,err:e,error:e,fatal:!0});return null}},{key:"_handleTransmuxerFlush",value:function(e){var t=this.getCurrentContext(e);if(t&&this.state===DB){var n=t.frag,i=t.part,a=t.level,r=self.performance.now();n.stats.parsing.end=r,i&&(i.stats.parsing.end=r);var o=this.getLevelDetails(),s=o&&n.sn>o.endSN||this.shouldLoadParts(o,n.end);s!==this.loadingParts&&(this.log(`LL-Part loading ${s?"ON":"OFF"} after parsing segment ending @${n.end.toFixed(2)}`),this.loadingParts=s),this.updateLevelTiming(n,i,a,e.partial)}else this.fragCurrent||this.state===EB||this.state===IB||(this.state=PB)}},{key:"shouldLoadParts",value:function(e,t){if(this.config.lowLatencyMode){if(!e)return this.loadingParts;if(e.partList){var n,i,a=e.partList[0];if(a.fragment.type===w$)return!1;if(t>=a.end+((null==(n=e.fragmentHint)?void 0:n.duration)||0))if((this.hls.hasEnoughToStart?(null==(i=this.media)?void 0:i.currentTime)||this.lastCurrentTime:this.getLoadPosition())>a.start-a.fragment.duration)return!0}}return!1}},{key:"getCurrentContext",value:function(e){var t=this.levels,n=this.fragCurrent,i=e.level,a=e.sn,r=e.part;if(null==t||!t[i])return this.warn(`Levels object was unset while buffering fragment ${a} of ${this.playlistLabel()} ${i}. The current chunk will not be buffered.`),null;var o=t[i],s=o.details,u=r>-1?dB(s,a,r):null,l=u?u.fragment:lB(s,a,n);return l?(n&&n!==l&&(l.stats=n.stats),{frag:l,part:u,level:o}):null}},{key:"bufferFragmentData",value:function(e,t,n,i,a){if(this.state===DB){var r=e.data1,o=e.data2,s=r;if(o&&(s=pN(r,o)),s.length){var u=this.initPTS[t.cc],l=u?-u.baseTime/u.timescale:void 0,d={type:e.type,frag:t,part:n,chunkMeta:i,offset:l,parent:t.type,data:s};if(this.hls.trigger(m$.BUFFER_APPENDING,d),e.dropped&&e.independent&&!n){if(a)return;this.flushBufferGap(t)}}}}},{key:"flushBufferGap",value:function(e){var t=this.media;if(t)if(ij.isBuffered(t,t.currentTime)){var n=t.currentTime,i=ij.bufferInfo(t,n,0),a=e.duration,r=Math.min(2*this.config.maxFragLookUpTolerance,.25*a),o=Math.max(Math.min(e.start-r,i.end-r),n+r);e.start-o>r&&this.flushMainBuffer(o,e.start)}else this.flushMainBuffer(0,e.start)}},{key:"getFwdBufferInfo",value:function(e,t){var n,i=this.getLoadPosition();if(!u$(i))return null;var a=this.lastCurrentTime>i||null!=(n=this.media)&&n.paused?0:this.config.maxBufferHole;return this.getFwdBufferInfoAtPos(e,i,t,a)}},{key:"getFwdBufferInfoAtPos",value:function(e,t,n,i){var a=ij.bufferInfo(e,t,i);if(0===a.len&&void 0!==a.nextStart){var r=this.fragmentTracker.getBufferedFrag(t,n);if(r&&(a.nextStart<=r.end||r.gap)){var o=Math.max(Math.min(a.nextStart,r.end)-t,i);return ij.bufferInfo(e,t,o)}}return a}},{key:"getMaxBufferLength",value:function(e){var t,n=this.config;return t=e?Math.max(8*n.maxBufferSize/e,n.maxBufferLength):n.maxBufferLength,Math.min(t,n.maxMaxBufferLength)}},{key:"exceedsMaxBuffer",value:function(e,t,n){var i=e.nextStart;if(i&&n.start>i){var a=e.buffered;if(a){for(var r=e.len,o=e.bufferedIndex,s=a.length-1;s>o;s--)a[s].start<n.start&&(r+=a[s].end-a[s].start);return r>=t}}return!1}},{key:"reduceMaxBufferLength",value:function(e,t){var n=this.config,i=Math.max(Math.min(e-t,n.maxBufferLength),t),a=Math.max(e-3*t,n.maxMaxBufferLength/2,i);return a>=i&&(n.maxMaxBufferLength=a,this.warn(`Reduce max buffer length to ${a}s`),!0)}},{key:"getAppendedFrag",value:function(e,t=y$){var n=this.fragmentTracker?this.fragmentTracker.getAppendedFrag(e,t):null;return n&&"fragment"in n?n.fragment:n}},{key:"getNextFragment",value:function(e,t){var n=t.fragments,i=n.length;if(!i)return null;var a=this.config,r=t.fragmentStart,o=a.lowLatencyMode&&!!t.partList,s=null;if(t.live){var u=a.initialLiveManifestSize;if(i<u)return this.warn(`Not enough fragments to start playback (have: ${i}, need: ${u})`),null;if(!t.PTSKnown&&!this.startFragRequested&&-1===this.startPosition||e<r){var l;o&&!this.loadingParts&&(this.log("LL-Part loading ON for initial live fragment"),this.loadingParts=!0),s=this.getInitialLiveFragment(t);var d,c,h=this.config.startPosition,m=this.hls.startPosition,f=this.hls.liveSyncPosition,v=(null==(l=s)?void 0:l.start)||0;-1!==m&&m>=r?(d=m,c=m===h?"config":"next load start"):null!==f?(d=f,c="live edge"):(d=e,c="buffer pos"),d<v&&(d=v,c="live frag start"),d<r&&(d=r,c="playlist start"),this.startPosition==d&&this.nextLoadPosition==d||(this.log(`Setting startPosition to ${d.toFixed(3)} ${-1===m?"":`(from ${h}) `}based on ${c}. live edge: ${f} live frag start: ${v.toFixed(3)} playlist start: ${r.toFixed(3)} buffer pos: ${e}`),this.startPosition=this.nextLoadPosition=d)}}else e<=r&&(s=n[0]);if(!s){var p=this.loadingParts?t.partEnd:t.fragmentEnd;s=this.getFragmentAtPosition(e,p,t)}var g=this.filterReplacedPrimary(s,t);if(!g&&s){var y=s.sn-t.startSN;g=this.filterReplacedPrimary(n[y+1]||null,t)}return this.mapToInitFragWhenRequired(g)}},{key:"isLoopLoading",value:function(e,t){if(this.nextLoadPosition<=t)return!1;var n=this.fragmentTracker.getState(e);return n===NW||n===$W&&!!e.gap}},{key:"getNextFragmentLoopLoading",value:function(e,t,n,i,a){var r=null;if(e.gap&&(r=this.getNextFragment(this.nextLoadPosition,t))&&!r.gap&&n.nextStart){var o=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,n.nextStart,i,0);if(null!==o&&n.len+o.len>=a){var s=r.sn;return this.loopSn!==s&&(this.log(`buffer full after gaps in "${i}" playlist starting at sn: ${s}`),this.loopSn=s),null}}return this.loopSn=void 0,r}},{key:"primaryPrefetch",get:function(){var e;if(OB(this.config)&&(null==(e=this.hls.interstitialsManager)||null==(e=e.playingItem)?void 0:e.event))return!0;return!1}},{key:"filterReplacedPrimary",value:function(e,t){if(!e)return e;if(OB(this.config)&&e.type!==w$){var n=this.hls.interstitialsManager,i=null==n?void 0:n.bufferingItem;if(i){var a=i.event;if(a){if(a.appendInPlace||Math.abs(e.start-i.start)>1||0===i.start)return null}else{if(e.end<=i.start&&!1===(null==t?void 0:t.live))return null;if(e.start>i.end&&i.nextEvent&&(i.nextEvent.appendInPlace||e.start-i.end>1))return null}}var r=null==n?void 0:n.playerQueue;if(r)for(var o=r.length;o--;){var s=r[o].interstitial;if(s.appendInPlace&&e.start>=s.startTime&&e.end<=s.resumeTime)return null}}return e}},{key:"mapToInitFragWhenRequired",value:function(e){return null==e||!e.initSegment||e.initSegment.data||this.bitrateTest?e:e.initSegment}},{key:"getNextPart",value:function(e,t,n){for(var i=-1,a=!1,r=!0,o=0,s=e.length;o<s;o++){var u=e[o];if(r=r&&!u.independent,i>-1&&n<u.start)break;var l=u.loaded;l?i=-1:(a||(u.independent||r)&&u.fragment===t)&&(u.fragment!==t&&this.warn(`Need buffer at ${n} but next unloaded part starts at ${u.start}`),i=o),a=l}return i}},{key:"loadedEndOfParts",value:function(e,t){for(var n,i=e.length;i--;){if(!(n=e[i]).loaded)return!1;if(t>n.start)return!0}return!1}},{key:"getInitialLiveFragment",value:function(e){var t=e.fragments,n=this.fragPrevious,i=null;if(n){if(e.hasProgramDateTime&&(i=function(e,t,n){if(null===t||!Array.isArray(e)||!e.length||!u$(t))return null;if(t<(e[0].programDateTime||0))return null;if(t>=(e[e.length-1].endProgramDateTime||0))return null;for(var i=0;i<e.length;++i){var a=e[i];if(vW(t,n,a))return a}return null}(t,n.endProgramDateTime,this.config.maxFragLookUpTolerance),i&&this.log(`Live playlist, switching playlist, load frag with same PDT: ${n.programDateTime}`)),!i){var a=n.sn+1;if(a>=e.startSN&&a<=e.endSN){var r=t[a-e.startSN];n.cc===r.cc&&(i=r,this.log(`Live playlist, switching playlist, load frag with next SN: ${i.sn}`))}i||(i=pW(e,n.cc,n.end))&&this.log(`Live playlist, switching playlist, load frag with same CC: ${i.sn}`)}}else{var o=this.hls.liveSyncPosition;null!==o&&(i=this.getFragmentAtPosition(o,this.bitrateTest?e.fragmentEnd:e.edge,e))}return i}},{key:"getFragmentAtPosition",value:function(e,t,n){var i,a,r=this.config,o=this.fragPrevious,s=n.fragments,u=n.endSN,l=n.fragmentHint,d=r.maxFragLookUpTolerance,c=n.partList,h=!!(this.loadingParts&&null!=c&&c.length&&l);(h&&!this.bitrateTest&&c[c.length-1].fragment.sn===l.sn&&(s=s.concat(l),u=l.sn),e<t)?i=mW(o,s,e,e<this.lastCurrentTime||e>t-d||null!=(a=this.media)&&a.paused||!this.startFragRequested?0:d):i=s[s.length-1];if(i){var m=i.sn-n.startSN,f=this.fragmentTracker.getState(i);if((f===NW||f===$W&&i.gap)&&(o=i),o&&i.sn===o.sn&&(!h||c[0].fragment.sn>i.sn||!n.live))if(i.level===o.level){var v=s[m+1];i=i.sn<u&&this.fragmentTracker.getState(v)!==NW?v:null}}return i}},{key:"alignPlaylists",value:function(e,t,n){var i=e.fragments.length;if(!i)return this.warn("No fragments in live playlist"),0;var a=e.fragmentStart,r=!t,o=e.alignedSliding&&u$(a);if(r||!o&&!a){!function(e,t){e&&(yB(t,e),t.alignedSliding||bB(t,e),t.alignedSliding||t.skippedSegments||oB(e,t,!1))}(n,e);var s=e.fragmentStart;return this.log(`Live playlist sliding: ${s.toFixed(2)} start-sn: ${t?t.startSN:"na"}->${e.startSN} fragments: ${i}`),s}return a}},{key:"waitForCdnTuneIn",value:function(e){return e.live&&e.canBlockReload&&e.partTarget&&e.tuneInGoal>Math.max(e.partHoldBack,3*e.partTarget)}},{key:"setStartPosition",value:function(e,t){var n=this.startPosition;n<t&&(n=-1);var i=this.timelineOffset;if(-1===n){var a=null!==this.startTimeOffset,r=a?this.startTimeOffset:e.startTimeOffset;null!==r&&u$(r)?(n=t+r,r<0&&(n+=e.edge),n=Math.min(Math.max(t,n),t+e.totalduration),this.log(`Setting startPosition to ${n} for start time offset ${r} found in ${a?"multivariant":"media"} playlist`),this.startPosition=n):e.live?(n=this.hls.liveSyncPosition||t,this.log(`Setting startPosition to -1 to start at live edge ${n}`),this.startPosition=-1):(this.log("setting startPosition to 0 by default"),this.startPosition=n=0),this.lastCurrentTime=n+i}this.nextLoadPosition=n+i}},{key:"getLoadPosition",value:function(){var e,t=this.media,n=0;return null!=(e=this.hls)&&e.hasEnoughToStart&&t?n=t.currentTime:this.nextLoadPosition>=0&&(n=this.nextLoadPosition),n}},{key:"handleFragLoadAborted",value:function(e,t){this.transmuxer&&e.type===this.playlistType&&X$(e)&&e.stats.aborted&&(this.log(`Fragment ${e.sn}${t?" part "+t.index:""} of ${this.playlistLabel()} ${e.level} was aborted`),this.resetFragmentLoading(e))}},{key:"resetFragmentLoading",value:function(e){this.fragCurrent&&(this.fragContextChanged(e)||this.state===MB)||(this.state=PB)}},{key:"onFragmentOrKeyLoadError",value:function(e,t){var n;if(t.chunkMeta&&!t.frag){var i=this.getCurrentContext(t.chunkMeta);i&&(t.frag=i.frag)}var a=t.frag;if(a&&a.type===e&&this.levels)if(this.fragContextChanged(a)){var r;this.warn(`Frag load error must match current frag to retry ${a.url} > ${null==(r=this.fragCurrent)?void 0:r.url}`)}else{var o=t.details===h$.FRAG_GAP;o&&this.fragmentTracker.fragBuffered(a,!0);var s=t.errorAction;if(s){var u=s.action,l=s.flags,d=s.retryCount,c=void 0===d?0:d,h=s.retryConfig,m=!!h,f=m&&u===AW,v=m&&!s.resolved&&l===xW,p=null==(n=this.hls.latestLevelDetails)?void 0:n.live;if(!f&&v&&X$(a)&&!a.endList&&p&&!bW(t))this.resetFragmentErrors(e),this.treatAsGap(a),s.resolved=!0;else if((f||v)&&c<h.maxNumRetry){var g,y=PW(null==(g=t.response)?void 0:g.code),b=kW(h,c);if(this.resetStartWhenNotLoaded(),this.retryDate=self.performance.now()+b,this.state=MB,s.resolved=!0,y)return this.log("Waiting for connection (offline)"),this.retryDate=1/0,void(t.reason="offline");this.warn(`Fragment ${a.sn} of ${e} ${a.level} errored with ${t.details}, retrying loading ${c+1}/${h.maxNumRetry} in ${b}ms`)}else if(h){if(this.resetFragmentErrors(e),!(c<h.maxNumRetry))return void this.warn(`${t.details} reached or exceeded max retry (${c})`);o||u===MW||(s.resolved=!0)}else this.state=u===_W?RB:IB;this.tickImmediate()}else this.state=IB}}},{key:"checkRetryDate",value:function(){var e=self.performance.now(),t=this.retryDate,n=t===1/0;(!t||e>=t||n&&!PW(0))&&(n&&this.log("Connection restored (online)"),this.resetStartWhenNotLoaded(),this.state=PB)}},{key:"reduceLengthAndFlushBuffer",value:function(e){if(this.state===DB||this.state===xB){var t=e.frag,n=e.parent,i=this.getFwdBufferInfo(this.mediaBuffer,n),a=i&&i.len>.5;a&&this.reduceMaxBufferLength(i.len,(null==t?void 0:t.duration)||10);var r=!a;return r&&this.warn(`Buffer full error while media.currentTime (${this.getLoadPosition()}) is not buffered, flush ${n} buffer`),t&&(this.fragmentTracker.removeFragment(t),this.nextLoadPosition=t.start),this.resetLoadingState(),r}return!1}},{key:"resetFragmentErrors",value:function(e){e===b$&&(this.fragCurrent=null),this.hls.hasEnoughToStart||(this.startFragRequested=!1),this.state!==EB&&(this.state=PB)}},{key:"afterBufferFlushed",value:function(e,t,n){if(e){var i=ij.getBuffered(e);this.fragmentTracker.detectEvictedFragments(t,i,n),this.state===CB&&this.resetLoadingState()}}},{key:"resetLoadingState",value:function(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state!==EB&&(this.state=PB)}},{key:"resetStartWhenNotLoaded",value:function(){if(!this.hls.hasEnoughToStart){this.startFragRequested=!1;var e=this.levelLastLoaded,t=e?e.details:null;null!=t&&t.live?(this.log("resetting startPosition for live start"),this.startPosition=-1,this.setStartPosition(t,t.fragmentStart),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}}},{key:"resetWhenMissingContext",value:function(e){this.log(`Loading context changed while buffering sn ${e.sn} of ${this.playlistLabel()} ${-1===e.level?"<removed>":e.level}. This chunk will not be buffered.`),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded(),this.resetLoadingState()}},{key:"removeUnbufferedFrags",value:function(e=0){this.fragmentTracker.removeFragmentsInRange(e,1/0,this.playlistType,!1,!0)}},{key:"updateLevelTiming",value:function(e,t,n,i){var a=n.details;if(a){var r=Object.keys(e.elementaryStreams).reduce((t,r)=>{var o=e.elementaryStreams[r];if(o){var s=o.endPTS-o.startPTS;if(s<=0)return this.warn(`Could not parse fragment ${e.sn} ${r} duration reliably (${s})`),t||!1;var u=i?0:iB(a,e,o.startPTS,o.endPTS,o.startDTS,o.endDTS,this);return this.hls.trigger(m$.LEVEL_PTS_UPDATED,{details:a,level:n,drift:u,type:r,frag:e,start:o.startPTS,end:o.endPTS}),!0}return t},!1);if(!r){var o,s=null===(null==(o=this.transmuxer)?void 0:o.error);if((0===n.fragmentError||s&&(n.fragmentError<2||e.endList))&&this.treatAsGap(e,n),s){var u=new Error(`Found no media in fragment ${e.sn} of ${this.playlistLabel()} ${e.level} resetting transmuxer to fallback to playlist timing`);if(this.warn(u.message),this.hls.trigger(m$.ERROR,{type:c$.MEDIA_ERROR,details:h$.FRAG_PARSING_ERROR,fatal:!1,error:u,frag:e,reason:`Found no media in msn ${e.sn} of ${this.playlistLabel()} "${n.url}"`}),!this.hls)return;this.resetTransmuxer()}}this.state=xB,this.log(`Parsed ${e.type} sn: ${e.sn}${t?" part: "+t.index:""} of ${this.fragInfo(e,!1,t)})`),this.hls.trigger(m$.FRAG_PARSED,{frag:e,part:t})}else this.warn("level.details undefined")}},{key:"playlistLabel",value:function(){return this.playlistType===y$?"level":"track"}},{key:"fragInfo",value:function(e,t=!0,n){var i,a;return`${this.playlistLabel()} ${e.level} (${n?"part":"frag"}:[${(null!=(i=t&&!n?e.startPTS:(n||e).start)?i:NaN).toFixed(3)}-${(null!=(a=t&&!n?e.endPTS:(n||e).end)?a:NaN).toFixed(3)}]${n&&"main"===e.type?"INDEPENDENT="+(n.independent?"YES":"NO"):""}`}},{key:"treatAsGap",value:function(e,t){t&&t.fragmentError++,e.gap=!0,this.fragmentTracker.removeFragment(e),this.fragmentTracker.fragBuffered(e,!0)}},{key:"resetTransmuxer",value:function(){var e;null==(e=this.transmuxer)||e.reset()}},{key:"recoverWorkerError",value:function(e){"demuxerWorker"===e.event&&(this.fragmentTracker.removeAllFragments(),this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null),this.resetStartWhenNotLoaded(),this.resetLoadingState())}},{key:"state",get:function(){return this._state},set:function(e){var t=this._state;t!==e&&(this._state=e,this.log(`${t}->${e}`))}}])}(ej);function OB(e){return!!e.interstitialsController&&!1!==e.enableInterstitialPlayback}var $B=function(){return c(function e(){o(this,e),this.chunks=[],this.dataLength=0},[{key:"push",value:function(e){this.chunks.push(e),this.dataLength+=e.length}},{key:"flush",value:function(){var e,t=this.chunks,n=this.dataLength;return t.length?(e=1===t.length?t[0]:function(e,t){for(var n=new Uint8Array(t),i=0,a=0;a<e.length;a++){var r=e[a];n.set(r,i),i+=r.length}return n}(t,n),this.reset(),e):new Uint8Array(0)}},{key:"reset",value:function(){this.chunks.length=0,this.dataLength=0}}])}();var NB,WB={exports:{}};var jB=(NB||(NB=1,function(e){var t=Object.prototype.hasOwnProperty,n="~";function i(){}function a(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function r(e,t,i,r,o){if("function"!=typeof i)throw new TypeError("The listener must be a function");var s=new a(i,r||e,o),u=n?n+t:t;return e._events[u]?e._events[u].fn?e._events[u]=[e._events[u],s]:e._events[u].push(s):(e._events[u]=s,e._eventsCount++),e}function o(e,t){0===--e._eventsCount?e._events=new i:delete e._events[t]}function s(){this._events=new i,this._eventsCount=0}Object.create&&(i.prototype=Object.create(null),(new i).__proto__||(n=!1)),s.prototype.eventNames=function(){var e,i,a=[];if(0===this._eventsCount)return a;for(i in e=this._events)t.call(e,i)&&a.push(n?i.slice(1):i);return Object.getOwnPropertySymbols?a.concat(Object.getOwnPropertySymbols(e)):a},s.prototype.listeners=function(e){var t=n?n+e:e,i=this._events[t];if(!i)return[];if(i.fn)return[i.fn];for(var a=0,r=i.length,o=new Array(r);a<r;a++)o[a]=i[a].fn;return o},s.prototype.listenerCount=function(e){var t=n?n+e:e,i=this._events[t];return i?i.fn?1:i.length:0},s.prototype.emit=function(e,t,i,a,r,o){var s=n?n+e:e;if(!this._events[s])return!1;var u,l,d=this._events[s],c=arguments.length;if(d.fn){switch(d.once&&this.removeListener(e,d.fn,void 0,!0),c){case 1:return d.fn.call(d.context),!0;case 2:return d.fn.call(d.context,t),!0;case 3:return d.fn.call(d.context,t,i),!0;case 4:return d.fn.call(d.context,t,i,a),!0;case 5:return d.fn.call(d.context,t,i,a,r),!0;case 6:return d.fn.call(d.context,t,i,a,r,o),!0}for(l=1,u=new Array(c-1);l<c;l++)u[l-1]=arguments[l];d.fn.apply(d.context,u)}else{var h,m=d.length;for(l=0;l<m;l++)switch(d[l].once&&this.removeListener(e,d[l].fn,void 0,!0),c){case 1:d[l].fn.call(d[l].context);break;case 2:d[l].fn.call(d[l].context,t);break;case 3:d[l].fn.call(d[l].context,t,i);break;case 4:d[l].fn.call(d[l].context,t,i,a);break;default:if(!u)for(h=1,u=new Array(c-1);h<c;h++)u[h-1]=arguments[h];d[l].fn.apply(d[l].context,u)}}return!0},s.prototype.on=function(e,t,n){return r(this,e,t,n,!1)},s.prototype.once=function(e,t,n){return r(this,e,t,n,!0)},s.prototype.removeListener=function(e,t,i,a){var r=n?n+e:e;if(!this._events[r])return this;if(!t)return o(this,r),this;var s=this._events[r];if(s.fn)s.fn!==t||a&&!s.once||i&&s.context!==i||o(this,r);else{for(var u=0,l=[],d=s.length;u<d;u++)(s[u].fn!==t||a&&!s[u].once||i&&s[u].context!==i)&&l.push(s[u]);l.length?this._events[r]=1===l.length?l[0]:l:o(this,r)}return this},s.prototype.removeAllListeners=function(e){var t;return e?(t=n?n+e:e,this._events[t]&&o(this,t)):(this._events=new i,this._eventsCount=0),this},s.prototype.off=s.prototype.removeListener,s.prototype.addListener=s.prototype.on,s.prefixed=n,s.EventEmitter=s,e.exports=s}(WB)),WB.exports),BB=W$(jB),zB="1.6.16",UB={};function HB(e,t){return t+10<=e.length&&51===e[t]&&68===e[t+1]&&73===e[t+2]&&e[t+3]<255&&e[t+4]<255&&e[t+6]<128&&e[t+7]<128&&e[t+8]<128&&e[t+9]<128}function GB(e,t){return t+10<=e.length&&73===e[t]&&68===e[t+1]&&51===e[t+2]&&e[t+3]<255&&e[t+4]<255&&e[t+6]<128&&e[t+7]<128&&e[t+8]<128&&e[t+9]<128}function VB(e,t){var n=0;return n=(127&e[t])<<21,n|=(127&e[t+1])<<14,n|=(127&e[t+2])<<7,n|=127&e[t+3]}function KB(e,t){for(var n=t,i=0;GB(e,t);){i+=10,i+=VB(e,t+6),HB(e,t+10)&&(i+=10),t+=i}if(i>0)return e.subarray(n,n+i)}function XB(e,t){return 255===e[t]&&240==(246&e[t+1])}function YB(e,t){return 1&e[t+1]?7:9}function qB(e,t){return(3&e[t+3])<<11|e[t+4]<<3|(224&e[t+5])>>>5}function JB(e,t){return t+1<e.length&&XB(e,t)}function QB(e,t){if(JB(e,t)){var n=YB(e,t);if(t+n>=e.length)return!1;var i=qB(e,t);if(i<=n)return!1;var a=t+i;return a===e.length||JB(e,a)}return!1}function ZB(e,t,n,i,a){if(!e.samplerate){var r=function(e,t,n,i){var a=t[n+2],r=a>>2&15;if(!(r>12)){var o=1+(a>>6&3),s=t[n+3]>>6&3|(1&a)<<2,u="mp4a.40."+o,l=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350][r],d=r;5!==o&&29!==o||(d-=3);var c=[o<<3|(14&d)>>1,(1&d)<<7|s<<3];return L$.log(`manifest codec:${i}, parsed codec:${u}, channels:${s}, rate:${l} (ADTS object type:${o} sampling index:${r})`),{config:c,samplerate:l,channelCount:s,codec:u,parsedCodec:u,manifestCodec:i}}var h=new Error(`invalid ADTS sampling index:${r}`);e.emit(m$.ERROR,m$.ERROR,{type:c$.MEDIA_ERROR,details:h$.FRAG_PARSING_ERROR,fatal:!0,error:h,reason:h.message})}(t,n,i,a);if(!r)return;P$(e,r)}}function ez(e){return 9216e4/e}function tz(e,t,n,i,a){var r,o=i+a*ez(e.samplerate),s=function(e,t){var n=YB(e,t);if(t+n<=e.length){var i=qB(e,t)-n;if(i>0)return{headerLength:n,frameLength:i}}}(t,n);if(s){var u=s.frameLength,l=s.headerLength,d=l+u,c=Math.max(0,n+d-t.length);c?(r=new Uint8Array(d-l)).set(t.subarray(n+l,t.length),0):r=t.subarray(n+l,n+d);var h={unit:r,pts:o};return c||e.samples.push(h),{sample:h,length:d,missing:c}}var m=t.length-n;return(r=new Uint8Array(m)).set(t.subarray(n,t.length),0),{sample:{unit:r,pts:o},length:m,missing:-1}}function nz(e,t){return GB(e,t)&&VB(e,t+6)+10<=e.length-t}function iz(e,t=0,n=1/0){return function(e,t,n,i){var a=function(e){return e instanceof ArrayBuffer?e:e.buffer}(e),r=1;"BYTES_PER_ELEMENT"in i&&(r=i.BYTES_PER_ELEMENT);var o=(c=e,c&&c.buffer instanceof ArrayBuffer&&void 0!==c.byteLength&&void 0!==c.byteOffset?e.byteOffset:0),s=(o+e.byteLength)/r,u=(o+t)/r,l=Math.floor(Math.max(0,Math.min(u,s))),d=Math.floor(Math.min(l+Math.max(n,0),s));var c;return new i(a,l,d-l)}(e,t,n,Uint8Array)}function az(e){var t={key:e.type,description:"",data:"",mimeType:null,pictureType:null};if(!(e.size<2))if(3===e.data[0]){var n=e.data.subarray(1).indexOf(0);if(-1!==n){var i=O$(iz(e.data,1,n)),a=e.data[2+n],r=e.data.subarray(3+n).indexOf(0);if(-1!==r){var o,s=O$(iz(e.data,3+n,r));return o="--\x3e"===i?O$(iz(e.data,4+n+r)):function(e){return e instanceof ArrayBuffer?e:0==e.byteOffset&&e.byteLength==e.buffer.byteLength?e.buffer:new Uint8Array(e).buffer}(e.data.subarray(4+n+r)),t.mimeType=i,t.pictureType=a,t.description=s,t.data=o,t}}}else console.log("Ignore frame with unrecognized character encoding")}function rz(e){return"PRIV"===e.type?function(e){if(!(e.size<2)){var t=O$(e.data,!0),n=new Uint8Array(e.data.subarray(t.length+1));return{key:e.type,info:t,data:n.buffer}}}(e):"W"===e.type[0]?function(e){if("WXXX"===e.type){if(e.size<2)return;var t=1,n=O$(e.data.subarray(t),!0);t+=n.length+1;var i=O$(e.data.subarray(t));return{key:e.type,info:n,data:i}}var a=O$(e.data);return{key:e.type,info:"",data:a}}(e):"APIC"===e.type?az(e):function(e){if(!(e.size<2)){if("TXXX"===e.type){var t=1,n=O$(e.data.subarray(t),!0);t+=n.length+1;var i=O$(e.data.subarray(t));return{key:e.type,info:n,data:i}}var a=O$(e.data.subarray(1));return{key:e.type,info:"",data:a}}}(e)}function oz(e){var t=String.fromCharCode(e[0],e[1],e[2],e[3]),n=VB(e,4);return{type:t,size:n,data:e.subarray(10,10+n)}}function sz(e){for(var t=0,n=[];GB(e,t);){var i=VB(e,t+6);e[t+5]>>6&1&&(t+=10);for(var a=(t+=10)+i;t+10<a;){var r=oz(e.subarray(t)),o=rz(r);o&&n.push(o),t+=r.size+10}HB(e,t)&&(t+=10)}return n}function uz(e){return e&&"PRIV"===e.key&&"com.apple.streaming.transportStreamTimestamp"===e.info}function lz(e){if(8===e.data.byteLength){var t=new Uint8Array(e.data),n=1&t[3],i=(t[4]<<23)+(t[5]<<15)+(t[6]<<7)+t[7];return i/=45,n&&(i+=47721858.84),Math.round(i)}}function dz(e){for(var t=sz(e),n=0;n<t.length;n++){var i=t[n];if(uz(i))return lz(i)}}var cz=function(e){return e.audioId3="org.id3",e.dateRange="com.apple.quicktime.HLS",e.emsg="https://aomedia.org/emsg/ID3",e.misbklv="urn:misb:KLV:bin:1910.1",e}({});function hz(e="",t=9e4){return{type:e,id:-1,pid:-1,inputTimeScale:t,sequenceNumber:-1,samples:[],dropped:0}}var mz=function(){return c(function e(){o(this,e),this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null},[{key:"resetInitSegment",value:function(e,t,n,i){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}}},{key:"resetTimeStamp",value:function(e){this.initPTS=e,this.resetContiguity()}},{key:"resetContiguity",value:function(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0}},{key:"canParse",value:function(e,t){return!1}},{key:"appendFrame",value:function(e,t,n){}},{key:"demux",value:function(e,t){this.cachedData&&(e=pN(this.cachedData,e),this.cachedData=null);var n,i=KB(e,0),a=i?i.length:0,r=this._audioTrack,o=this._id3Track,s=i?dz(i):void 0,u=e.length;for((null===this.basePTS||0===this.frameIndex&&u$(s))&&(this.basePTS=fz(s,t,this.initPTS),this.lastPTS=this.basePTS),null===this.lastPTS&&(this.lastPTS=this.basePTS),i&&i.length>0&&o.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:cz.audioId3,duration:Number.POSITIVE_INFINITY});a<u;){if(this.canParse(e,a)){var l=this.appendFrame(r,e,a);l?(this.frameIndex++,this.lastPTS=l.sample.pts,n=a+=l.length):a=u}else nz(e,a)?(i=KB(e,a),o.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:cz.audioId3,duration:Number.POSITIVE_INFINITY}),n=a+=i.length):a++;if(a===u&&n!==u){var d=e.slice(n);this.cachedData?this.cachedData=pN(this.cachedData,d):this.cachedData=d}}return{audioTrack:r,videoTrack:hz(),id3Track:o,textTrack:hz()}}},{key:"demuxSampleAes",value:function(e,t,n){return Promise.reject(new Error(`[${this}] This demuxer does not support Sample-AES decryption`))}},{key:"flush",value:function(e){var t=this.cachedData;return t&&(this.cachedData=null,this.demux(t,0)),{audioTrack:this._audioTrack,videoTrack:hz(),id3Track:this._id3Track,textTrack:hz()}}},{key:"destroy",value:function(){this.cachedData=null,this._audioTrack=this._id3Track=void 0}}])}(),fz=(e,t,n)=>u$(e)?90*e:9e4*t+(n?9e4*n.baseTime/n.timescale:0),vz=null,pz=[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],gz=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],yz=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],bz=[0,1,1,4];function wz(e,t,n,i,a){if(!(n+24>t.length)){var r=kz(t,n);if(r&&n+r.frameLength<=t.length){var o=i+a*(9e4*r.samplesPerFrame/r.sampleRate),s={unit:t.subarray(n,n+r.frameLength),pts:o,dts:o};return e.config=[],e.channelCount=r.channelCount,e.samplerate=r.sampleRate,e.samples.push(s),{sample:s,length:r.frameLength,missing:0}}}}function kz(e,t){var n=e[t+1]>>3&3,i=e[t+1]>>1&3,a=e[t+2]>>4&15,r=e[t+2]>>2&3;if(1!==n&&0!==a&&15!==a&&3!==r){var o=e[t+2]>>1&1,s=e[t+3]>>6,u=1e3*pz[14*(3===n?3-i:3===i?3:4)+a-1],l=gz[3*(3===n?0:2===n?1:2)+r],d=3===s?1:2,c=yz[n][i],h=bz[i],m=8*c*h,f=Math.floor(c*u/l+o)*h;if(null===vz){var v=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);vz=v?parseInt(v[1]):0}return!!vz&&vz<=87&&2===i&&u>=224e3&&0===s&&(e[t+3]=128|e[t+3]),{sampleRate:l,channelCount:d,frameLength:f,samplesPerFrame:m}}}function Sz(e,t){return!(255!==e[t]||224&~e[t+1]||!(6&e[t+1]))}function Ez(e,t){return t+1<e.length&&Sz(e,t)}function Pz(e,t){if(t+1<e.length&&Sz(e,t)){var n=kz(e,t),i=4;null!=n&&n.frameLength&&(i=n.frameLength);var a=t+i;return a===e.length||Ez(e,a)}return!1}var Tz=function(e){function t(e,n){var i;return o(this,t),(i=r(this,t)).observer=void 0,i.config=void 0,i.observer=e,i.config=n,i}return p(t,e),c(t,[{key:"resetInitSegment",value:function(e,n,i,a){T(t,"resetInitSegment",this)([e,n,i,a]),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:n,duration:a,inputTimeScale:9e4,dropped:0}}},{key:"canParse",value:function(e,t){return function(e,t){return function(e,t){return t+5<e.length}(e,t)&&XB(e,t)&&qB(e,t)<=e.length-t}(e,t)}},{key:"appendFrame",value:function(e,t,n){ZB(e,this.observer,t,n,e.manifestCodec);var i=tz(e,t,n,this.basePTS,this.frameIndex);if(i&&0===i.missing)return i}}],[{key:"probe",value:function(e,t){if(!e)return!1;var n=KB(e,0),i=(null==n?void 0:n.length)||0;if(Pz(e,i))return!1;for(var a=e.length;i<a;i++)if(QB(e,i))return t.log("ADTS sync word found !"),!0;return!1}}])}(mz),_z=(e,t)=>{var n=0,i=5;t+=i;for(var a=new Uint32Array(1),r=new Uint32Array(1),o=new Uint8Array(1);i>0;){o[0]=e[t];var s=Math.min(i,8),u=8-s;r[0]=4278190080>>>24+u<<u,a[0]=(o[0]&r[0])>>u,n=n?n<<s|a[0]:a[0],t+=1,i-=s}return n},Mz=function(e){function t(e){var n;return o(this,t),(n=r(this,t)).observer=void 0,n.observer=e,n}return p(t,e),c(t,[{key:"resetInitSegment",value:function(e,n,i,a){T(t,"resetInitSegment",this)([e,n,i,a]),this._audioTrack={container:"audio/ac-3",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"ac3",samples:[],manifestCodec:n,duration:a,inputTimeScale:9e4,dropped:0}}},{key:"canParse",value:function(e,t){return t+64<e.length}},{key:"appendFrame",value:function(e,t,n){var i=Az(e,t,n,this.basePTS,this.frameIndex);if(-1!==i)return{sample:e.samples[e.samples.length-1],length:i,missing:0}}}],[{key:"probe",value:function(e){if(!e)return!1;var t=KB(e,0);if(!t)return!1;var n=t.length;return 11===e[n]&&119===e[n+1]&&void 0!==dz(t)&&_z(e,n)<16}}])}(mz);function Az(e,t,n,i,a){if(n+8>t.length)return-1;if(11!==t[n]||119!==t[n+1])return-1;var r=t[n+4]>>6;if(r>=3)return-1;var o=[48e3,44100,32e3][r],s=63&t[n+4],u=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*s+r];if(n+u>t.length)return-1;var l=t[n+6]>>5,d=0;2===l?d+=2:(1&l&&1!==l&&(d+=2),4&l&&(d+=2));var c=(t[n+6]<<8|t[n+7])>>12-d&1,h=[2,1,2,3,3,4,4,5][l]+c,m=t[n+5]>>3,f=7&t[n+5],v=new Uint8Array([r<<6|m<<1|f>>2,(3&f)<<6|l<<3|c<<2|s>>4,s<<4&224]),p=i+a*(1536/o*9e4),g=t.subarray(n,n+u);return e.config=v,e.channelCount=h,e.samplerate=o,e.samples.push({unit:g,pts:p}),u}var Dz=function(e){function t(){return o(this,t),r(this,t,arguments)}return p(t,e),c(t,[{key:"resetInitSegment",value:function(e,n,i,a){T(t,"resetInitSegment",this)([e,n,i,a]),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:n,duration:a,inputTimeScale:9e4,dropped:0}}},{key:"canParse",value:function(e,t){return function(e,t){return Sz(e,t)&&4<=e.length-t}(e,t)}},{key:"appendFrame",value:function(e,t,n){if(null!==this.basePTS)return wz(e,t,n,this.basePTS,this.frameIndex)}}],[{key:"probe",value:function(e){if(!e)return!1;var t=KB(e,0),n=(null==t?void 0:t.length)||0;if(t&&11===e[n]&&119===e[n+1]&&void 0!==dz(t)&&_z(e,n)<=16)return!1;for(var i=e.length;n<i;n++)if(Pz(e,n))return L$.log("MPEG Audio sync word found !"),!0;return!1}}])}(mz),xz=/\/emsg[-/]ID3/i,Cz=function(){return c(function e(t,n){o(this,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=n},[{key:"resetTimeStamp",value:function(){}},{key:"resetInitSegment",value:function(e,t,n,i){var a=this.videoTrack=hz("video",1),r=this.audioTrack=hz("audio",1),o=this.txtTrack=hz("text",1);if(this.id3Track=hz("id3",1),this.timeOffset=0,null!=e&&e.byteLength){var s=uN(e);if(s.video){var u=s.video,l=u.id,d=u.timescale,c=u.codec,h=u.supplemental;a.id=l,a.timescale=o.timescale=d,a.codec=c,a.supplemental=h}if(s.audio){var m=s.audio,f=m.id,v=m.timescale,p=m.codec;r.id=f,r.timescale=v,r.codec=p}o.id=eN.text,a.sampleDuration=0,a.duration=r.duration=i}}},{key:"resetContiguity",value:function(){this.remainderData=null}},{key:"demux",value:function(e,t){this.timeOffset=t;var n=e,i=this.videoTrack,a=this.txtTrack;if(this.config.progressive){this.remainderData&&(n=pN(this.remainderData,e));var r=function(e){var t={valid:null,remainder:null},n=oN(e,["moof"]);if(n.length<2)return t.remainder=e,t;var i=n[n.length-1];return t.valid=e.slice(0,i.byteOffset-8),t.remainder=e.slice(i.byteOffset-8),t}(n);this.remainderData=r.remainder,i.samples=r.valid||new Uint8Array}else i.samples=n;var o=this.extractID3Track(i,t);return a.samples=gN(t,i),{videoTrack:i,audioTrack:this.audioTrack,id3Track:o,textTrack:this.txtTrack}}},{key:"flush",value:function(){var e=this.timeOffset,t=this.videoTrack,n=this.txtTrack;t.samples=this.remainderData||new Uint8Array,this.remainderData=null;var i=this.extractID3Track(t,this.timeOffset);return n.samples=gN(e,t),{videoTrack:t,audioTrack:hz(),id3Track:i,textTrack:hz()}}},{key:"extractID3Track",value:function(e,t){var n=this.id3Track;if(e.samples.length){var i=oN(e.samples,["emsg"]);i&&i.forEach(e=>{var i=function(e){var t=e[0],n="",i="",a=0,r=0,o=0,s=0,u=0,l=0;if(0===t){for(;"\0"!==tN(e.subarray(l,l+1));)n+=tN(e.subarray(l,l+1)),l+=1;for(n+=tN(e.subarray(l,l+1)),l+=1;"\0"!==tN(e.subarray(l,l+1));)i+=tN(e.subarray(l,l+1)),l+=1;i+=tN(e.subarray(l,l+1)),l+=1,a=iN(e,12),r=iN(e,16),s=iN(e,20),u=iN(e,24),l=28}else if(1===t){a=iN(e,l+=4);var d=iN(e,l+=4),c=iN(e,l+=4);for(l+=4,l$(o=2**32*d+c)||(o=Number.MAX_SAFE_INTEGER,L$.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),s=iN(e,l),u=iN(e,l+=4),l+=4;"\0"!==tN(e.subarray(l,l+1));)n+=tN(e.subarray(l,l+1)),l+=1;for(n+=tN(e.subarray(l,l+1)),l+=1;"\0"!==tN(e.subarray(l,l+1));)i+=tN(e.subarray(l,l+1)),l+=1;i+=tN(e.subarray(l,l+1)),l+=1}return{schemeIdUri:n,value:i,timeScale:a,presentationTime:o,presentationTimeDelta:r,eventDuration:s,id:u,payload:e.subarray(l,e.byteLength)}}(e);if(xz.test(i.schemeIdUri)){var a=Iz(i,t),r=4294967295===i.eventDuration?Number.POSITIVE_INFINITY:i.eventDuration/i.timeScale;r<=.001&&(r=Number.POSITIVE_INFINITY);var o=i.payload;n.samples.push({data:o,len:o.byteLength,dts:a,pts:a,type:cz.emsg,duration:r})}else if(this.config.enableEmsgKLVMetadata&&i.schemeIdUri.startsWith("urn:misb:KLV:bin:1910.1")){var s=Iz(i,t);n.samples.push({data:i.payload,len:i.payload.byteLength,dts:s,pts:s,type:cz.misbklv,duration:Number.POSITIVE_INFINITY})}})}return n}},{key:"demuxSampleAes",value:function(e,t,n){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))}},{key:"destroy",value:function(){this.config=null,this.remainderData=null,this.videoTrack=this.audioTrack=this.id3Track=this.txtTrack=void 0}}],[{key:"probe",value:function(e){return function(e){for(var t=e.byteLength,n=0;n<t;){var i=iN(e,n);if(i>8&&109===e[n+4]&&111===e[n+5]&&111===e[n+6]&&102===e[n+7])return!0;n=i>1?n+i:t}return!1}(e)}}])}();function Iz(e,t){return u$(e.presentationTime)?e.presentationTime/e.timeScale:t+e.presentationTimeDelta/e.timeScale}var Lz=function(){return c(function e(t,n,i){o(this,e),this.keyData=void 0,this.decrypter=void 0,this.keyData=i,this.decrypter=new XW(n,{removePKCS7Padding:!1})},[{key:"decryptBuffer",value:function(e){return this.decrypter.decrypt(e,this.keyData.key.buffer,this.keyData.iv.buffer,UW)}},{key:"decryptAacSample",value:function(e,t,n){var i=e[t].unit;if(!(i.length<=16)){var a=i.subarray(16,i.length-i.length%16),r=a.buffer.slice(a.byteOffset,a.byteOffset+a.length);this.decryptBuffer(r).then(a=>{var r=new Uint8Array(a);i.set(r,16),this.decrypter.isSync()||this.decryptAacSamples(e,t+1,n)}).catch(n)}}},{key:"decryptAacSamples",value:function(e,t,n){for(;;t++){if(t>=e.length)return void n();if(!(e[t].unit.length<32)&&(this.decryptAacSample(e,t,n),!this.decrypter.isSync()))return}}},{key:"getAvcEncryptedData",value:function(e){for(var t=16*Math.floor((e.length-48)/160)+16,n=new Int8Array(t),i=0,a=32;a<e.length-16;a+=160,i+=16)n.set(e.subarray(a,a+16),i);return n}},{key:"getAvcDecryptedUnit",value:function(e,t){for(var n=new Uint8Array(t),i=0,a=32;a<e.length-16;a+=160,i+=16)e.set(n.subarray(i,i+16),a);return e}},{key:"decryptAvcSample",value:function(e,t,n,i,a){var r=kN(a.data),o=this.getAvcEncryptedData(r);this.decryptBuffer(o.buffer).then(o=>{a.data=this.getAvcDecryptedUnit(r,o),this.decrypter.isSync()||this.decryptAvcSamples(e,t,n+1,i)}).catch(i)}},{key:"decryptAvcSamples",value:function(e,t,n,i){if(e instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;t++,n=0){if(t>=e.length)return void i();for(var a=e[t].units;!(n>=a.length);n++){var r=a[n];if(!(r.data.length<=48||1!==r.type&&5!==r.type||(this.decryptAvcSample(e,t,n,i,r),this.decrypter.isSync())))return}}}}])}(),Rz=function(){return c(function e(){o(this,e),this.VideoSample=null},[{key:"createVideoSample",value:function(e,t,n){return{key:e,frame:!1,pts:t,dts:n,units:[],length:0}}},{key:"getLastNalUnit",value:function(e){var t,n,i=this.VideoSample;if(i&&0!==i.units.length||(i=e[e.length-1]),null!=(t=i)&&t.units){var a=i.units;n=a[a.length-1]}return n}},{key:"pushAccessUnit",value:function(e,t){if(e.units.length&&e.frame){if(void 0===e.pts){var n=t.samples,i=n.length;if(!i)return void t.dropped++;var a=n[i-1];e.pts=a.pts,e.dts=a.dts}t.samples.push(e)}}},{key:"parseNALu",value:function(e,t,n){var i,a,r=t.byteLength,o=e.naluState||0,s=o,u=[],l=0,d=-1,c=0;for(-1===o&&(d=0,c=this.getNALuType(t,0),o=0,l=1);l<r;)if(i=t[l++],o)if(1!==o)if(i)if(1===i){if(a=l-o-1,d>=0){var h={data:t.subarray(d,a),type:c};u.push(h)}else{var m=this.getLastNalUnit(e.samples);m&&(s&&l<=4-s&&m.state&&(m.data=m.data.subarray(0,m.data.byteLength-s)),a>0&&(m.data=pN(m.data,t.subarray(0,a)),m.state=0))}l<r?(d=l,c=this.getNALuType(t,l),o=0):o=-1}else o=0;else o=3;else o=i?0:2;else o=i?0:1;if(d>=0&&o>=0){var f={data:t.subarray(d,r),type:c,state:o};u.push(f)}if(0===u.length){var v=this.getLastNalUnit(e.samples);v&&(v.data=pN(v.data,t))}return e.naluState=o,u}}])}(),Fz=function(){return c(function e(t){o(this,e),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},[{key:"loadWord",value:function(){var e=this.data,t=this.bytesAvailable,n=e.byteLength-t,i=new Uint8Array(4),a=Math.min(4,t);if(0===a)throw new Error("no bytes available");i.set(e.subarray(n,n+a)),this.word=new DataView(i.buffer).getUint32(0),this.bitsAvailable=8*a,this.bytesAvailable-=a}},{key:"skipBits",value:function(e){var t;e=Math.min(e,8*this.bytesAvailable+this.bitsAvailable),this.bitsAvailable>e?(this.word<<=e,this.bitsAvailable-=e):(e-=this.bitsAvailable,e-=(t=e>>3)<<3,this.bytesAvailable-=t,this.loadWord(),this.word<<=e,this.bitsAvailable-=e)}},{key:"readBits",value:function(e){var t=Math.min(this.bitsAvailable,e),n=this.word>>>32-t;if(e>32&&L$.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=t,this.bitsAvailable>0)this.word<<=t;else{if(!(this.bytesAvailable>0))throw new Error("no bits available");this.loadWord()}return(t=e-t)>0&&this.bitsAvailable?n<<t|this.readBits(t):n}},{key:"skipLZ",value:function(){var e;for(e=0;e<this.bitsAvailable;++e)if(this.word&2147483648>>>e)return this.word<<=e,this.bitsAvailable-=e,e;return this.loadWord(),e+this.skipLZ()}},{key:"skipUEG",value:function(){this.skipBits(1+this.skipLZ())}},{key:"skipEG",value:function(){this.skipBits(1+this.skipLZ())}},{key:"readUEG",value:function(){var e=this.skipLZ();return this.readBits(e+1)-1}},{key:"readEG",value:function(){var e=this.readUEG();return 1&e?1+e>>>1:-1*(e>>>1)}},{key:"readBoolean",value:function(){return 1===this.readBits(1)}},{key:"readUByte",value:function(){return this.readBits(8)}},{key:"readUShort",value:function(){return this.readBits(16)}},{key:"readUInt",value:function(){return this.readBits(32)}}])}(),Oz=function(e){function t(){return o(this,t),r(this,t,arguments)}return p(t,e),c(t,[{key:"parsePES",value:function(e,t,n,i){var a,r=this.parseNALu(e,n.data,i),o=this.VideoSample,s=!1;n.data=null,o&&r.length&&!e.audFound&&(this.pushAccessUnit(o,e),o=this.VideoSample=this.createVideoSample(!1,n.pts,n.dts)),r.forEach(i=>{var r,u;switch(i.type){case 1:var l=!1;a=!0;var d,c=i.data;if(s&&c.length>4){var h=this.readSliceType(c);2!==h&&4!==h&&7!==h&&9!==h||(l=!0)}if(l)null!=(d=o)&&d.frame&&!o.key&&(this.pushAccessUnit(o,e),o=this.VideoSample=null);o||(o=this.VideoSample=this.createVideoSample(!0,n.pts,n.dts)),o.frame=!0,o.key=l;break;case 5:a=!0,null!=(r=o)&&r.frame&&!o.key&&(this.pushAccessUnit(o,e),o=this.VideoSample=null),o||(o=this.VideoSample=this.createVideoSample(!0,n.pts,n.dts)),o.key=!0,o.frame=!0;break;case 6:a=!0,wN(i.data,1,n.pts,t.samples);break;case 7:var m,f;a=!0,s=!0;var v=i.data,p=this.readSPS(v);if(!e.sps||e.width!==p.width||e.height!==p.height||(null==(m=e.pixelRatio)?void 0:m[0])!==p.pixelRatio[0]||(null==(f=e.pixelRatio)?void 0:f[1])!==p.pixelRatio[1]){e.width=p.width,e.height=p.height,e.pixelRatio=p.pixelRatio,e.sps=[v];for(var g=v.subarray(1,4),y="avc1.",b=0;b<3;b++){var w=g[b].toString(16);w.length<2&&(w="0"+w),y+=w}e.codec=y}break;case 8:a=!0,e.pps=[i.data];break;case 9:a=!0,e.audFound=!0,null!=(u=o)&&u.frame&&(this.pushAccessUnit(o,e),o=null),o||(o=this.VideoSample=this.createVideoSample(!1,n.pts,n.dts));break;case 12:a=!0;break;default:a=!1}o&&a&&o.units.push(i)}),i&&o&&(this.pushAccessUnit(o,e),this.VideoSample=null)}},{key:"getNALuType",value:function(e,t){return 31&e[t]}},{key:"readSliceType",value:function(e){var t=new Fz(e);return t.readUByte(),t.readUEG(),t.readUEG()}},{key:"skipScalingList",value:function(e,t){for(var n=8,i=8,a=0;a<e;a++)0!==i&&(i=(n+t.readEG()+256)%256),n=0===i?n:i}},{key:"readSPS",value:function(e){var t,n,i,a=new Fz(e),r=0,o=0,s=0,u=0,l=a.readUByte.bind(a),d=a.readBits.bind(a),c=a.readUEG.bind(a),h=a.readBoolean.bind(a),m=a.skipBits.bind(a),f=a.skipEG.bind(a),v=a.skipUEG.bind(a),p=this.skipScalingList.bind(this);l();var g=l();if(d(5),m(3),l(),v(),100===g||110===g||122===g||244===g||44===g||83===g||86===g||118===g||128===g){var y=c();if(3===y&&m(1),v(),v(),m(1),h())for(n=3!==y?8:12,i=0;i<n;i++)h()&&p(i<6?16:64,a)}v();var b=c();if(0===b)c();else if(1===b)for(m(1),f(),f(),t=c(),i=0;i<t;i++)f();v(),m(1);var w=c(),k=c(),S=d(1);0===S&&m(1),m(1),h()&&(r=c(),o=c(),s=c(),u=c());var E=[1,1];if(h()&&h())switch(l()){case 1:E=[1,1];break;case 2:E=[12,11];break;case 3:E=[10,11];break;case 4:E=[16,11];break;case 5:E=[40,33];break;case 6:E=[24,11];break;case 7:E=[20,11];break;case 8:E=[32,11];break;case 9:E=[80,33];break;case 10:E=[18,11];break;case 11:E=[15,11];break;case 12:E=[64,33];break;case 13:E=[160,99];break;case 14:E=[4,3];break;case 15:E=[3,2];break;case 16:E=[2,1];break;case 255:E=[l()<<8|l(),l()<<8|l()]}return{width:Math.ceil(16*(w+1)-2*r-2*o),height:(2-S)*(k+1)*16-(S?2:4)*(s+u),pixelRatio:E}}}])}(Rz),$z=function(e){function t(...e){var n;return o(this,t),(n=r(this,t,[...e])).initVPS=null,n}return p(t,e),c(t,[{key:"parsePES",value:function(e,t,n,i){var a,r=this.parseNALu(e,n.data,i),o=this.VideoSample,s=!1;n.data=null,o&&r.length&&!e.audFound&&(this.pushAccessUnit(o,e),o=this.VideoSample=this.createVideoSample(!1,n.pts,n.dts)),r.forEach(i=>{var r,u;switch(i.type){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:case 9:o||(o=this.VideoSample=this.createVideoSample(!1,n.pts,n.dts)),o.frame=!0,a=!0;break;case 16:case 17:case 18:case 21:var l;if(a=!0,s)null!=(l=o)&&l.frame&&!o.key&&(this.pushAccessUnit(o,e),o=this.VideoSample=null);o||(o=this.VideoSample=this.createVideoSample(!0,n.pts,n.dts)),o.key=!0,o.frame=!0;break;case 19:case 20:a=!0,null!=(r=o)&&r.frame&&!o.key&&(this.pushAccessUnit(o,e),o=this.VideoSample=null),o||(o=this.VideoSample=this.createVideoSample(!0,n.pts,n.dts)),o.key=!0,o.frame=!0;break;case 39:a=!0,wN(i.data,2,n.pts,t.samples);break;case 32:a=!0,e.vps||("object"!=typeof e.params&&(e.params={}),e.params=P$(e.params,this.readVPS(i.data)),this.initVPS=i.data),e.vps=[i.data];break;case 33:if(a=!0,s=!0,void 0===e.vps||e.vps[0]===this.initVPS||void 0===e.sps||this.matchSPS(e.sps[0],i.data)||(this.initVPS=e.vps[0],e.sps=e.pps=void 0),!e.sps){var d=this.readSPS(i.data);for(var c in e.width=d.width,e.height=d.height,e.pixelRatio=d.pixelRatio,e.codec=d.codecString,e.sps=[],"object"!=typeof e.params&&(e.params={}),d.params)e.params[c]=d.params[c]}this.pushParameterSet(e.sps,i.data,e.vps),o||(o=this.VideoSample=this.createVideoSample(!0,n.pts,n.dts)),o.key=!0;break;case 34:if(a=!0,"object"==typeof e.params){if(!e.pps){e.pps=[];var h=this.readPPS(i.data);for(var m in h)e.params[m]=h[m]}this.pushParameterSet(e.pps,i.data,e.vps)}break;case 35:a=!0,e.audFound=!0,null!=(u=o)&&u.frame&&(this.pushAccessUnit(o,e),o=null),o||(o=this.VideoSample=this.createVideoSample(!1,n.pts,n.dts));break;default:a=!1}o&&a&&o.units.push(i)}),i&&o&&(this.pushAccessUnit(o,e),this.VideoSample=null)}},{key:"pushParameterSet",value:function(e,t,n){(n&&n[0]===this.initVPS||!n&&!e.length)&&e.push(t)}},{key:"getNALuType",value:function(e,t){return(126&e[t])>>>1}},{key:"ebsp2rbsp",value:function(e){for(var t=new Uint8Array(e.byteLength),n=0,i=0;i<e.byteLength;i++)i>=2&&3===e[i]&&0===e[i-1]&&0===e[i-2]||(t[n]=e[i],n++);return new Uint8Array(t.buffer,0,n)}},{key:"pushAccessUnit",value:function(e,n){T(t,"pushAccessUnit",this)([e,n]),this.initVPS&&(this.initVPS=null)}},{key:"readVPS",value:function(e){var t=new Fz(e);return t.readUByte(),t.readUByte(),t.readBits(4),t.skipBits(2),t.readBits(6),{numTemporalLayers:t.readBits(3)+1,temporalIdNested:t.readBoolean()}}},{key:"readSPS",value:function(e){var t=new Fz(this.ebsp2rbsp(e));t.readUByte(),t.readUByte(),t.readBits(4);var n=t.readBits(3);t.readBoolean();for(var i=t.readBits(2),a=t.readBoolean(),r=t.readBits(5),o=t.readUByte(),s=t.readUByte(),u=t.readUByte(),l=t.readUByte(),d=t.readUByte(),c=t.readUByte(),h=t.readUByte(),m=t.readUByte(),f=t.readUByte(),v=t.readUByte(),p=t.readUByte(),g=[],y=[],b=0;b<n;b++)g.push(t.readBoolean()),y.push(t.readBoolean());if(n>0)for(var w=n;w<8;w++)t.readBits(2);for(var k=0;k<n;k++)g[k]&&(t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte()),y[k]&&t.readUByte();t.readUEG();var S=t.readUEG();3==S&&t.skipBits(1);var E=t.readUEG(),P=t.readUEG(),T=t.readBoolean(),_=0,M=0,A=0,D=0;T&&(_+=t.readUEG(),M+=t.readUEG(),A+=t.readUEG(),D+=t.readUEG());for(var x=t.readUEG(),C=t.readUEG(),I=t.readUEG(),L=t.readBoolean()?0:n;L<=n;L++)t.skipUEG(),t.skipUEG(),t.skipUEG();if((t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG(),t.readBoolean())&&t.readBoolean())for(var R=0;R<4;R++)for(var F=0;F<(3===R?2:6);F++){if(t.readBoolean()){var O=Math.min(64,1<<4+(R<<1));R>1&&t.readEG();for(var $=0;$<O;$++)t.readEG()}else t.readUEG()}t.readBoolean(),t.readBoolean(),t.readBoolean()&&(t.readUByte(),t.skipUEG(),t.skipUEG(),t.readBoolean());for(var N=t.readUEG(),W=0,j=0;j<N;j++){var B=!1;if(0!==j&&(B=t.readBoolean()),B){j===N&&t.readUEG(),t.readBoolean(),t.readUEG();for(var z=0,U=0;U<=W;U++){var H=t.readBoolean(),G=!1;H||(G=t.readBoolean()),(H||G)&&z++}W=z}else{var V=t.readUEG(),K=t.readUEG();W=V+K;for(var X=0;X<V;X++)t.readUEG(),t.readBoolean();for(var Y=0;Y<K;Y++)t.readUEG(),t.readBoolean()}}if(t.readBoolean())for(var q=t.readUEG(),J=0;J<q;J++){for(var Q=0;Q<I+4;Q++)t.readBits(1);t.readBits(1)}var Z=0,ee=1,te=1,ne=!0,ie=1,ae=0;t.readBoolean(),t.readBoolean();if(t.readBoolean()){if(t.readBoolean()){var re=t.readUByte();re>0&&re<16?(ee=[1,12,10,16,40,24,20,32,80,18,15,64,160,4,3,2][re-1],te=[1,11,11,11,33,11,11,11,33,11,11,33,99,3,2,1][re-1]):255===re&&(ee=t.readBits(16),te=t.readBits(16))}if(t.readBoolean()&&t.readBoolean(),t.readBoolean())t.readBits(3),t.readBoolean(),t.readBoolean()&&(t.readUByte(),t.readUByte(),t.readUByte());if(t.readBoolean()&&(t.readUEG(),t.readUEG()),t.readBoolean(),t.readBoolean(),t.readBoolean(),t.readBoolean()&&(t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG()),t.readBoolean())if(ie=t.readBits(32),ae=t.readBits(32),t.readBoolean()&&t.readUEG(),t.readBoolean()){var oe=t.readBoolean(),se=t.readBoolean(),ue=!1;(oe||se)&&((ue=t.readBoolean())&&(t.readUByte(),t.readBits(5),t.readBoolean(),t.readBits(5)),t.readBits(4),t.readBits(4),ue&&t.readBits(4),t.readBits(5),t.readBits(5),t.readBits(5));for(var le=0;le<=n;le++){var de=!1;(ne=t.readBoolean())||t.readBoolean()?t.readEG():de=t.readBoolean();var ce=de?1:t.readUEG()+1;if(oe)for(var he=0;he<ce;he++)t.readUEG(),t.readUEG(),ue&&(t.readUEG(),t.readUEG()),t.skipBits(1);if(se)for(var me=0;me<ce;me++)t.readUEG(),t.readUEG(),ue&&(t.readUEG(),t.readUEG()),t.skipBits(1)}}t.readBoolean()&&(t.readBoolean(),t.readBoolean(),t.readBoolean(),Z=t.readUEG())}var fe=E,ve=P;if(T){var pe=1,ge=1;1===S?pe=ge=2:2==S&&(pe=2),fe=E-pe*M-pe*_,ve=P-ge*D-ge*A}for(var ye=i?["A","B","C"][i]:"",be=o<<24|s<<16|u<<8|l,we=0,ke=0;ke<32;ke++)we=(we|(be>>ke&1)<<31-ke)>>>0;var Se=we.toString(16);return 1===r&&"2"===Se&&(Se="6"),{codecString:`hvc1.${ye}${r}.${Se}.${a?"H":"L"}${p}.B0`,params:{general_tier_flag:a,general_profile_idc:r,general_profile_space:i,general_profile_compatibility_flags:[o,s,u,l],general_constraint_indicator_flags:[d,c,h,m,f,v],general_level_idc:p,bit_depth:x+8,bit_depth_luma_minus8:x,bit_depth_chroma_minus8:C,min_spatial_segmentation_idc:Z,chroma_format_idc:S,frame_rate:{fixed:ne,fps:ae/ie}},width:fe,height:ve,pixelRatio:[ee,te]}}},{key:"readPPS",value:function(e){var t=new Fz(this.ebsp2rbsp(e));t.readUByte(),t.readUByte(),t.skipUEG(),t.skipUEG(),t.skipBits(2),t.skipBits(3),t.skipBits(2),t.skipUEG(),t.skipUEG(),t.skipEG(),t.skipBits(2),t.readBoolean()&&t.skipUEG(),t.skipEG(),t.skipEG(),t.skipBits(4);var n=t.readBoolean(),i=t.readBoolean(),a=1;return i&&n?a=0:i?a=3:n&&(a=2),{parallelismType:a}}},{key:"matchSPS",value:function(e,t){return String.fromCharCode.apply(null,e).substr(3)===String.fromCharCode.apply(null,t).substr(3)}}])}(Rz),Nz=188,Wz=function(){function e(t,n,i,a){o(this,e),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=n,this.typeSupported=i,this.logger=a,this.videoParser=null}return c(e,[{key:"resetInitSegment",value:function(t,n,i,a){this.pmtParsed=!1,this._pmtId=-1,this._videoTrack=e.createTrack("video"),this._videoTrack.duration=a,this._audioTrack=e.createTrack("audio",a),this._id3Track=e.createTrack("id3"),this._txtTrack=e.createTrack("text"),this._audioTrack.segmentCodec="aac",this.videoParser=null,this.aacOverFlow=null,this.remainderData=null,this.audioCodec=n,this.videoCodec=i}},{key:"resetTimeStamp",value:function(){}},{key:"resetContiguity",value:function(){var e=this._audioTrack,t=this._videoTrack,n=this._id3Track;e&&(e.pesData=null),t&&(t.pesData=null),n&&(n.pesData=null),this.aacOverFlow=null,this.remainderData=null}},{key:"demux",value:function(t,n,i=!1,a=!1){var r;i||(this.sampleAes=null);var o=this._videoTrack,s=this._audioTrack,u=this._id3Track,l=this._txtTrack,d=o.pid,c=o.pesData,h=s.pid,m=u.pid,f=s.pesData,v=u.pesData,p=null,g=this.pmtParsed,y=this._pmtId,b=t.length;if(this.remainderData&&(b=(t=pN(this.remainderData,t)).length,this.remainderData=null),b<Nz&&!a)return this.remainderData=t,{audioTrack:s,videoTrack:o,id3Track:u,textTrack:l};var w=Math.max(0,e.syncOffset(t));(b-=(b-w)%Nz)<t.byteLength&&!a&&(this.remainderData=new Uint8Array(t.buffer,b,t.buffer.byteLength-b));for(var k=0,S=w;S<b;S+=Nz)if(71===t[S]){var E=!!(64&t[S+1]),P=jz(t,S),T=void 0;if((48&t[S+3])>>4>1){if((T=S+5+t[S+4])===S+Nz)continue}else T=S+4;switch(P){case d:E&&(c&&(r=Gz(c,this.logger))&&(this.readyVideoParser(o.segmentCodec),null!==this.videoParser&&this.videoParser.parsePES(o,l,r,!1)),c={data:[],size:0}),c&&(c.data.push(t.subarray(T,S+Nz)),c.size+=S+Nz-T);break;case h:if(E){if(f&&(r=Gz(f,this.logger)))switch(s.segmentCodec){case"aac":this.parseAACPES(s,r);break;case"mp3":this.parseMPEGPES(s,r);break;case"ac3":this.parseAC3PES(s,r)}f={data:[],size:0}}f&&(f.data.push(t.subarray(T,S+Nz)),f.size+=S+Nz-T);break;case m:E&&(v&&(r=Gz(v,this.logger))&&this.parseID3PES(u,r),v={data:[],size:0}),v&&(v.data.push(t.subarray(T,S+Nz)),v.size+=S+Nz-T);break;case 0:E&&(T+=t[T]+1),y=this._pmtId=Bz(t,T);break;case y:E&&(T+=t[T]+1);var _=zz(t,T,this.typeSupported,i,this.observer,this.logger);(d=_.videoPid)>0&&(o.pid=d,o.segmentCodec=_.segmentVideoCodec),(h=_.audioPid)>0&&(s.pid=h,s.segmentCodec=_.segmentAudioCodec),(m=_.id3Pid)>0&&(u.pid=m),null===p||g||(this.logger.warn(`MPEG-TS PMT found at ${S} after unknown PID '${p}'. Backtracking to sync byte @${w} to parse all TS packets.`),p=null,S=w-188),g=this.pmtParsed=!0;break;case 17:case 8191:break;default:p=P}}else k++;k>0&&Uz(this.observer,new Error(`Found ${k} TS packet/s that do not start with 0x47`),void 0,this.logger),o.pesData=c,s.pesData=f,u.pesData=v;var M={audioTrack:s,videoTrack:o,id3Track:u,textTrack:l};return a&&this.extractRemainingSamples(M),M}},{key:"flush",value:function(){var e,t=this.remainderData;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}},{key:"extractRemainingSamples",value:function(e){var t,n=e.audioTrack,i=e.videoTrack,a=e.id3Track,r=e.textTrack,o=i.pesData,s=n.pesData,u=a.pesData;if(o&&(t=Gz(o,this.logger))?(this.readyVideoParser(i.segmentCodec),null!==this.videoParser&&(this.videoParser.parsePES(i,r,t,!0),i.pesData=null)):i.pesData=o,s&&(t=Gz(s,this.logger))){switch(n.segmentCodec){case"aac":this.parseAACPES(n,t);break;case"mp3":this.parseMPEGPES(n,t);break;case"ac3":this.parseAC3PES(n,t)}n.pesData=null}else null!=s&&s.size&&this.logger.log("last AAC PES packet truncated,might overlap between fragments"),n.pesData=s;u&&(t=Gz(u,this.logger))?(this.parseID3PES(a,t),a.pesData=null):a.pesData=u}},{key:"demuxSampleAes",value:function(e,t,n){var i=this.demux(e,n,!0,!this.config.progressive),a=this.sampleAes=new Lz(this.observer,this.config,t);return this.decrypt(i,a)}},{key:"readyVideoParser",value:function(e){null===this.videoParser&&("avc"===e?this.videoParser=new Oz:"hevc"===e&&(this.videoParser=new $z))}},{key:"decrypt",value:function(e,t){return new Promise(n=>{var i=e.audioTrack,a=e.videoTrack;i.samples&&"aac"===i.segmentCodec?t.decryptAacSamples(i.samples,0,()=>{a.samples?t.decryptAvcSamples(a.samples,0,0,()=>{n(e)}):n(e)}):a.samples&&t.decryptAvcSamples(a.samples,0,0,()=>{n(e)})})}},{key:"destroy",value:function(){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}},{key:"parseAACPES",value:function(e,t){var n,i,a,r=0,o=this.aacOverFlow,s=t.data;if(o){this.aacOverFlow=null;var u=o.missing,l=o.sample.unit.byteLength;if(-1===u)s=pN(o.sample.unit,s);else{var d=l-u;o.sample.unit.set(s.subarray(0,u),d),e.samples.push(o.sample),r=o.missing}}for(n=r,i=s.length;n<i-1&&!JB(s,n);n++);if(n!==r){var c,h=n<i-1;if(c=h?`AAC PES did not start with ADTS header,offset:${n}`:"No ADTS header found in AAC PES",Uz(this.observer,new Error(c),h,this.logger),!h)return}if(ZB(e,this.observer,s,n,this.audioCodec),void 0!==t.pts)a=t.pts;else{if(!o)return void this.logger.warn("[tsdemuxer]: AAC PES unknown PTS");var m=ez(e.samplerate);a=o.sample.pts+m}for(var f,v=0;n<i;){if(n+=(f=tz(e,s,n,a,v)).length,f.missing){this.aacOverFlow=f;break}for(v++;n<i-1&&!JB(s,n);n++);}}},{key:"parseMPEGPES",value:function(e,t){var n=t.data,i=n.length,a=0,r=0,o=t.pts;if(void 0!==o)for(;r<i;)if(Ez(n,r)){var s=wz(e,n,r,o,a);if(!s)break;r+=s.length,a++}else r++;else this.logger.warn("[tsdemuxer]: MPEG PES unknown PTS")}},{key:"parseAC3PES",value:function(e,t){var n=t.data,i=t.pts;if(void 0!==i)for(var a,r=n.length,o=0,s=0;s<r&&(a=Az(e,n,s,i,o++))>0;)s+=a;else this.logger.warn("[tsdemuxer]: AC3 PES unknown PTS")}},{key:"parseID3PES",value:function(e,t){if(void 0!==t.pts){var n=P$({},t,{type:this._videoTrack?cz.emsg:cz.audioId3,duration:Number.POSITIVE_INFINITY});e.samples.push(n)}else this.logger.warn("[tsdemuxer]: ID3 PES unknown PTS")}}],[{key:"probe",value:function(t,n){var i=e.syncOffset(t);return i>0&&n.warn(`MPEG2-TS detected but first sync word found @ offset ${i}`),-1!==i}},{key:"syncOffset",value:function(e){for(var t=e.length,n=Math.min(940,t-Nz)+1,i=0;i<n;){for(var a=!1,r=-1,o=0,s=i;s<t;s+=Nz){if(71!==e[s]||t-s!==Nz&&71!==e[s+Nz]){if(o)return-1;break}if(o++,-1===r&&0!==(r=s)&&(n=Math.min(r+18612,e.length-Nz)+1),a||(a=0===jz(e,s)),a&&o>1&&(0===r&&o>2||s+Nz>n))return r}i++}return-1}},{key:"createTrack",value:function(e,t){return{container:"video"===e||"audio"===e?"video/mp2t":void 0,type:e,id:eN[e],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:"audio"===e?t:void 0}}}])}();function jz(e,t){return((31&e[t+1])<<8)+e[t+2]}function Bz(e,t){return(31&e[t+10])<<8|e[t+11]}function zz(e,t,n,i,a,r){var o={audioPid:-1,videoPid:-1,id3Pid:-1,segmentVideoCodec:"avc",segmentAudioCodec:"aac"},s=t+3+((15&e[t+1])<<8|e[t+2])-4;for(t+=12+((15&e[t+10])<<8|e[t+11]);t<s;){var u=jz(e,t),l=(15&e[t+3])<<8|e[t+4];switch(e[t]){case 207:if(!i){Hz("ADTS AAC",r);break}case 15:-1===o.audioPid&&(o.audioPid=u);break;case 21:-1===o.id3Pid&&(o.id3Pid=u);break;case 219:if(!i){Hz("H.264",r);break}case 27:-1===o.videoPid&&(o.videoPid=u);break;case 3:case 4:n.mpeg||n.mp3?-1===o.audioPid&&(o.audioPid=u,o.segmentAudioCodec="mp3"):r.log("MPEG audio found, not supported in this browser");break;case 193:if(!i){Hz("AC-3",r);break}case 129:n.ac3?-1===o.audioPid&&(o.audioPid=u,o.segmentAudioCodec="ac3"):r.log("AC-3 audio found, not supported in this browser");break;case 6:if(-1===o.audioPid&&l>0)for(var d=t+5,c=l;c>2;){if(106===e[d])!0!==n.ac3?r.log("AC-3 audio found, not supported in this browser for now"):(o.audioPid=u,o.segmentAudioCodec="ac3");var h=e[d+1]+2;d+=h,c-=h}break;case 194:case 135:return Uz(a,new Error("Unsupported EC-3 in M2TS found"),void 0,r),o;case 36:-1===o.videoPid&&(o.videoPid=u,o.segmentVideoCodec="hevc",r.log("HEVC in M2TS found"))}t+=l+5}return o}function Uz(e,t,n,i){i.warn(`parsing error: ${t.message}`),e.emit(m$.ERROR,m$.ERROR,{type:c$.MEDIA_ERROR,details:h$.FRAG_PARSING_ERROR,fatal:!1,levelRetry:n,error:t,reason:t.message})}function Hz(e,t){t.log(`${e} with AES-128-CBC encryption found in unencrypted stream`)}function Gz(e,t){var n,i,a,r,o,s=0,u=e.data;if(!e||0===e.size)return null;for(;u[0].length<19&&u.length>1;)u[0]=pN(u[0],u[1]),u.splice(1,1);if(1===((n=u[0])[0]<<16)+(n[1]<<8)+n[2]){if((i=(n[4]<<8)+n[5])&&i>e.size-6)return null;var l=n[7];192&l&&(r=536870912*(14&n[9])+4194304*(255&n[10])+16384*(254&n[11])+128*(255&n[12])+(254&n[13])/2,64&l?r-(o=536870912*(14&n[14])+4194304*(255&n[15])+16384*(254&n[16])+128*(255&n[17])+(254&n[18])/2)>54e5&&(t.warn(`${Math.round((r-o)/9e4)}s delta between PTS and DTS, align them`),r=o):o=r);var d=(a=n[8])+9;if(e.size<=d)return null;e.size-=d;for(var c=new Uint8Array(e.size),h=0,m=u.length;h<m;h++){var f=(n=u[h]).byteLength;if(d){if(d>f){d-=f;continue}n=n.subarray(d),f-=d,d=0}c.set(n,s),s+=f}return i&&(i-=a+3),{data:c,pts:r,dts:o,len:i}}return null}var Vz=function(){return c(function e(){o(this,e)},null,[{key:"getSilentFrame",value:function(e,t){if("mp4a.40.2"===e){if(1===t)return new Uint8Array([0,200,0,128,35,128]);if(2===t)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(3===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(4===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(5===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(6===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224])}else{if(1===t)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(2===t)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(3===t)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94])}}}])}(),Kz=Math.pow(2,32)-1,Xz=function(){function e(){o(this,e)}return c(e,null,[{key:"init",value:function(){var t;for(t in e.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:[]},e.types)e.types.hasOwnProperty(t)&&(e.types[t]=[t.charCodeAt(0),t.charCodeAt(1),t.charCodeAt(2),t.charCodeAt(3)]);var n=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]);e.HDLR_TYPES={video:n,audio:i};var a=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),r=new Uint8Array([0,0,0,0,0,0,0,0]);e.STTS=e.STSC=e.STCO=r,e.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),e.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),e.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),e.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var o=new Uint8Array([105,115,111,109]),s=new Uint8Array([97,118,99,49]),u=new Uint8Array([0,0,0,1]);e.FTYP=e.box(e.types.ftyp,o,u,o,s),e.DINF=e.box(e.types.dinf,e.box(e.types.dref,a))}},{key:"box",value:function(e,...t){for(var n=8,i=t.length,a=i;i--;)n+=t[i].byteLength;var r=new Uint8Array(n);for(r[0]=n>>24&255,r[1]=n>>16&255,r[2]=n>>8&255,r[3]=255&n,r.set(e,4),i=0,n=8;i<a;i++)r.set(t[i],n),n+=t[i].byteLength;return r}},{key:"hdlr",value:function(t){return e.box(e.types.hdlr,e.HDLR_TYPES[t])}},{key:"mdat",value:function(t){return e.box(e.types.mdat,t)}},{key:"mdhd",value:function(t,n){n*=t;var i=Math.floor(n/(Kz+1)),a=Math.floor(n%(Kz+1));return e.box(e.types.mdhd,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,a>>24,a>>16&255,a>>8&255,255&a,85,196,0,0]))}},{key:"mdia",value:function(t){return e.box(e.types.mdia,e.mdhd(t.timescale||0,t.duration||0),e.hdlr(t.type),e.minf(t))}},{key:"mfhd",value:function(t){return e.box(e.types.mfhd,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t]))}},{key:"minf",value:function(t){return"audio"===t.type?e.box(e.types.minf,e.box(e.types.smhd,e.SMHD),e.DINF,e.stbl(t)):e.box(e.types.minf,e.box(e.types.vmhd,e.VMHD),e.DINF,e.stbl(t))}},{key:"moof",value:function(t,n,i){return e.box(e.types.moof,e.mfhd(t),e.traf(i,n))}},{key:"moov",value:function(t){for(var n=t.length,i=[];n--;)i[n]=e.trak(t[n]);return e.box.apply(null,[e.types.moov,e.mvhd(t[0].timescale||0,t[0].duration||0)].concat(i).concat(e.mvex(t)))}},{key:"mvex",value:function(t){for(var n=t.length,i=[];n--;)i[n]=e.trex(t[n]);return e.box.apply(null,[e.types.mvex,...i])}},{key:"mvhd",value:function(t,n){n*=t;var i=Math.floor(n/(Kz+1)),a=Math.floor(n%(Kz+1)),r=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,a>>24,a>>16&255,a>>8&255,255&a,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 e.box(e.types.mvhd,r)}},{key:"sdtp",value:function(t){var n,i,a=t.samples||[],r=new Uint8Array(4+a.length);for(n=0;n<a.length;n++)i=a[n].flags,r[n+4]=i.dependsOn<<4|i.isDependedOn<<2|i.hasRedundancy;return e.box(e.types.sdtp,r)}},{key:"stbl",value:function(t){return e.box(e.types.stbl,e.stsd(t),e.box(e.types.stts,e.STTS),e.box(e.types.stsc,e.STSC),e.box(e.types.stsz,e.STSZ),e.box(e.types.stco,e.STCO))}},{key:"avc1",value:function(t){var n,i,a,r=[],o=[];for(n=0;n<t.sps.length;n++)a=(i=t.sps[n]).byteLength,r.push(a>>>8&255),r.push(255&a),r=r.concat(Array.prototype.slice.call(i));for(n=0;n<t.pps.length;n++)a=(i=t.pps[n]).byteLength,o.push(a>>>8&255),o.push(255&a),o=o.concat(Array.prototype.slice.call(i));var s=e.box(e.types.avcC,new Uint8Array([1,r[3],r[4],r[5],255,224|t.sps.length].concat(r).concat([t.pps.length]).concat(o))),u=t.width,l=t.height,d=t.pixelRatio[0],c=t.pixelRatio[1];return e.box(e.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,u>>8&255,255&u,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]),s,e.box(e.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),e.box(e.types.pasp,new Uint8Array([d>>24,d>>16&255,d>>8&255,255&d,c>>24,c>>16&255,c>>8&255,255&c])))}},{key:"esds",value:function(e){var t=e.config;return new Uint8Array([0,0,0,0,3,25,0,1,0,4,17,64,21,0,0,0,0,0,0,0,0,0,0,0,5,2,...t,6,1,2])}},{key:"audioStsd",value:function(e){var t=e.samplerate||0;return new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channelCount||0,0,16,0,0,0,0,t>>8&255,255&t,0,0])}},{key:"mp4a",value:function(t){return e.box(e.types.mp4a,e.audioStsd(t),e.box(e.types.esds,e.esds(t)))}},{key:"mp3",value:function(t){return e.box(e.types[".mp3"],e.audioStsd(t))}},{key:"ac3",value:function(t){return e.box(e.types["ac-3"],e.audioStsd(t),e.box(e.types.dac3,t.config))}},{key:"stsd",value:function(t){var n=t.segmentCodec;if("audio"===t.type){if("aac"===n)return e.box(e.types.stsd,e.STSD,e.mp4a(t));if("ac3"===n&&t.config)return e.box(e.types.stsd,e.STSD,e.ac3(t));if("mp3"===n&&"mp3"===t.codec)return e.box(e.types.stsd,e.STSD,e.mp3(t))}else{if(!t.pps||!t.sps)throw new Error("video track missing pps or sps");if("avc"===n)return e.box(e.types.stsd,e.STSD,e.avc1(t));if("hevc"===n&&t.vps)return e.box(e.types.stsd,e.STSD,e.hvc1(t))}throw new Error(`unsupported ${t.type} segment codec (${n}/${t.codec})`)}},{key:"tkhd",value:function(t){var n=t.id,i=(t.duration||0)*(t.timescale||0),a=t.width||0,r=t.height||0,o=Math.floor(i/(Kz+1)),s=Math.floor(i%(Kz+1));return e.box(e.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,n>>24&255,n>>16&255,n>>8&255,255&n,0,0,0,0,o>>24,o>>16&255,o>>8&255,255&o,s>>24,s>>16&255,s>>8&255,255&s,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,a>>8&255,255&a,0,0,r>>8&255,255&r,0,0]))}},{key:"traf",value:function(t,n){var i=e.sdtp(t),a=t.id,r=Math.floor(n/(Kz+1)),o=Math.floor(n%(Kz+1));return e.box(e.types.traf,e.box(e.types.tfhd,new Uint8Array([0,0,0,0,a>>24,a>>16&255,a>>8&255,255&a])),e.box(e.types.tfdt,new Uint8Array([1,0,0,0,r>>24,r>>16&255,r>>8&255,255&r,o>>24,o>>16&255,o>>8&255,255&o])),e.trun(t,i.length+16+20+8+16+8+8),i)}},{key:"trak",value:function(t){return t.duration=t.duration||4294967295,e.box(e.types.trak,e.tkhd(t),e.mdia(t))}},{key:"trex",value:function(t){var n=t.id;return e.box(e.types.trex,new Uint8Array([0,0,0,0,n>>24,n>>16&255,n>>8&255,255&n,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))}},{key:"trun",value:function(t,n){var i,a,r,o,s,u,l=t.samples||[],d=l.length,c=12+16*d,h=new Uint8Array(c);for(n+=8+c,h.set(["video"===t.type?1:0,0,15,1,d>>>24&255,d>>>16&255,d>>>8&255,255&d,n>>>24&255,n>>>16&255,n>>>8&255,255&n],0),i=0;i<d;i++)r=(a=l[i]).duration,o=a.size,s=a.flags,u=a.cts,h.set([r>>>24&255,r>>>16&255,r>>>8&255,255&r,o>>>24&255,o>>>16&255,o>>>8&255,255&o,s.isLeading<<2|s.dependsOn,s.isDependedOn<<6|s.hasRedundancy<<4|s.paddingValue<<1|s.isNonSync,61440&s.degradPrio,15&s.degradPrio,u>>>24&255,u>>>16&255,u>>>8&255,255&u],12+16*i);return e.box(e.types.trun,h)}},{key:"initSegment",value:function(t){e.types||e.init();var n=e.moov(t);return pN(e.FTYP,n)}},{key:"hvc1",value:function(t){for(var n=t.params,i=[t.vps,t.sps,t.pps],a=new Uint8Array([1,n.general_profile_space<<6|(n.general_tier_flag?32:0)|n.general_profile_idc,n.general_profile_compatibility_flags[0],n.general_profile_compatibility_flags[1],n.general_profile_compatibility_flags[2],n.general_profile_compatibility_flags[3],n.general_constraint_indicator_flags[0],n.general_constraint_indicator_flags[1],n.general_constraint_indicator_flags[2],n.general_constraint_indicator_flags[3],n.general_constraint_indicator_flags[4],n.general_constraint_indicator_flags[5],n.general_level_idc,240|n.min_spatial_segmentation_idc>>8,255&n.min_spatial_segmentation_idc,252|n.parallelismType,252|n.chroma_format_idc,248|n.bit_depth_luma_minus8,248|n.bit_depth_chroma_minus8,0,parseInt(n.frame_rate.fps),3|n.temporal_id_nested<<2|n.num_temporal_layers<<3|(n.frame_rate.fixed?64:0),i.length]),r=a.length,o=0;o<i.length;o+=1){r+=3;for(var s=0;s<i[o].length;s+=1)r+=2+i[o][s].length}var u=new Uint8Array(r);u.set(a,0),r=a.length;for(var l=i.length-1,d=0;d<i.length;d+=1){u.set(new Uint8Array([32+d|(d===l?128:0),0,i[d].length]),r),r+=3;for(var c=0;c<i[d].length;c+=1)u.set(new Uint8Array([i[d][c].length>>8,255&i[d][c].length]),r),r+=2,u.set(i[d][c],r),r+=i[d][c].length}var h=e.box(e.types.hvcC,u),m=t.width,f=t.height,v=t.pixelRatio[0],p=t.pixelRatio[1];return e.box(e.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,m>>8&255,255&m,f>>8&255,255&f,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]),h,e.box(e.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),e.box(e.types.pasp,new Uint8Array([v>>24,v>>16&255,v>>8&255,255&v,p>>24,p>>16&255,p>>8&255,255&p])))}}])}();Xz.types=void 0,Xz.HDLR_TYPES=void 0,Xz.STTS=void 0,Xz.STSC=void 0,Xz.STCO=void 0,Xz.STSZ=void 0,Xz.VMHD=void 0,Xz.SMHD=void 0,Xz.STSD=void 0,Xz.FTYP=void 0,Xz.DINF=void 0;function Yz(e,t,n=1,i=!1){var a=e*t*n;return i?Math.round(a):a}function qz(e,t=!1){return Yz(e,1e3,1/9e4,t)}function Jz(e){var t=e.baseTime,n=e.timescale;return`${t/n} (${t}/${n}) trackId: ${e.trackId}`}var Qz=null,Zz=null;function eU(e,t,n,i){return{duration:t,size:n,cts:i,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:e?2:1,isNonSync:e?0:1}}}var tU=function(e){function t(e,n,i,a){var s;if(o(this,t),(s=r(this,t,["mp4-remuxer",a])).observer=void 0,s.config=void 0,s.typeSupported=void 0,s.ISGenerated=!1,s._initPTS=null,s._initDTS=null,s.nextVideoTs=null,s.nextAudioTs=null,s.videoSampleDuration=null,s.isAudioContiguous=!1,s.isVideoContiguous=!1,s.videoTrackConfig=void 0,s.observer=e,s.config=n,s.typeSupported=i,s.ISGenerated=!1,null===Qz){var u=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Qz=u?parseInt(u[1]):0}if(null===Zz){var l=navigator.userAgent.match(/Safari\/(\d+)/i);Zz=l?parseInt(l[1]):0}return s}return p(t,e),c(t,[{key:"destroy",value:function(){this.config=this.videoTrackConfig=this._initPTS=this._initDTS=null}},{key:"resetTimeStamp",value:function(e){var t=this._initPTS;t&&e&&e.trackId===t.trackId&&e.baseTime===t.baseTime&&e.timescale===t.timescale||this.log(`Reset initPTS: ${t?Jz(t):t} > ${e?Jz(e):e}`),this._initPTS=this._initDTS=e}},{key:"resetNextTimestamp",value:function(){this.log("reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1}},{key:"resetInitSegment",value:function(){this.log("ISGenerated flag reset"),this.ISGenerated=!1,this.videoTrackConfig=void 0}},{key:"getVideoStartPts",value:function(e){var t=!1,n=e[0].pts,i=e.reduce((e,i)=>{var a=i.pts,r=a-e;return r<-4294967296&&(t=!0,r=(a=nU(a,n))-e),r>0?e:a},n);return t&&this.debug("PTS rollover detected"),i}},{key:"remux",value:function(e,t,n,i,a,r,o,s){var u,l,d,c,h,m,f=a,v=a,p=e.pid>-1,g=t.pid>-1,y=t.samples.length,b=e.samples.length>0,w=o&&y>0||y>1;if((!p||b)&&(!g||w)||this.ISGenerated||o){if(this.ISGenerated){var k,S,E,P,T=this.videoTrackConfig;(T&&(t.width!==T.width||t.height!==T.height||(null==(k=t.pixelRatio)?void 0:k[0])!==(null==(S=T.pixelRatio)?void 0:S[0])||(null==(E=t.pixelRatio)?void 0:E[1])!==(null==(P=T.pixelRatio)?void 0:P[1]))||!T&&w||null===this.nextAudioTs&&b)&&this.resetInitSegment()}this.ISGenerated||(d=this.generateIS(e,t,a,r));var _,M=this.isVideoContiguous,A=-1;if(w&&(A=function(e){for(var t=0;t<e.length;t++)if(e[t].key)return t;return-1}(t.samples),!M&&this.config.forceKeyFrameOnDiscontinuity))if(m=!0,A>0){this.warn(`Dropped ${A} out of ${y} video samples due to a missing keyframe`);var D=this.getVideoStartPts(t.samples);t.samples=t.samples.slice(A),t.dropped+=A,_=v+=(t.samples[0].pts-D)/t.inputTimeScale}else-1===A&&(this.warn(`No keyframe found out of ${y} video samples`),m=!1);if(this.ISGenerated){if(b&&w){var x=this.getVideoStartPts(t.samples),C=(nU(e.samples[0].pts,x)-x)/t.inputTimeScale;f+=Math.max(0,C),v+=Math.max(0,-C)}if(b){if(e.samplerate||(this.warn("regenerate InitSegment as audio detected"),d=this.generateIS(e,t,a,r)),l=this.remuxAudio(e,f,this.isAudioContiguous,r,g||w||s===b$?v:void 0),w){var I=l?l.endPTS-l.startPTS:0;t.inputTimeScale||(this.warn("regenerate InitSegment as video detected"),d=this.generateIS(e,t,a,r)),u=this.remuxVideo(t,v,M,I)}}else w&&(u=this.remuxVideo(t,v,M,0));u&&(u.firstKeyFrame=A,u.independent=-1!==A,u.firstKeyFramePTS=_)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(n.samples.length&&(h=iU(n,a,this._initPTS,this._initDTS)),i.samples.length&&(c=aU(i,a,this._initPTS))),{audio:l,video:u,initSegment:d,independent:m,text:c,id3:h}}},{key:"computeInitPts",value:function(e,t,n,i){var a=Math.round(n*t),r=nU(e,a);if(r<a+t)for(this.log(`Adjusting PTS for rollover in timeline near ${(a-r)/t} ${i}`);r<a+t;)r+=8589934592;return r-a}},{key:"generateIS",value:function(e,t,n,i){var a,r,o,s=e.samples,u=t.samples,l=this.typeSupported,d={},c=this._initPTS,h=!c||i,m="audio/mp4",f=-1;if(h&&(a=r=1/0),e.config&&s.length){switch(e.timescale=e.samplerate,e.segmentCodec){case"mp3":l.mpeg?(m="audio/mpeg",e.codec=""):l.mp3&&(e.codec="mp3");break;case"ac3":e.codec="ac-3"}d.audio={id:"audio",container:m,codec:e.codec,initSegment:"mp3"===e.segmentCodec&&l.mpeg?new Uint8Array(0):Xz.initSegment([e]),metadata:{channelCount:e.channelCount}},h&&(f=e.id,o=e.inputTimeScale,c&&o===c.timescale?h=!1:a=r=this.computeInitPts(s[0].pts,o,n,"audio"))}if(t.sps&&t.pps&&u.length){if(t.timescale=t.inputTimeScale,d.video={id:"main",container:"video/mp4",codec:t.codec,initSegment:Xz.initSegment([t]),metadata:{width:t.width,height:t.height}},h)if(f=t.id,o=t.inputTimeScale,c&&o===c.timescale)h=!1;else{var v=this.getVideoStartPts(u),p=nU(u[0].dts,v),g=this.computeInitPts(p,o,n,"video"),y=this.computeInitPts(v,o,n,"video");r=Math.min(r,g),a=Math.min(a,y)}this.videoTrackConfig={width:t.width,height:t.height,pixelRatio:t.pixelRatio}}if(Object.keys(d).length)return this.ISGenerated=!0,h?(c&&this.warn(`Timestamps at playlist time: ${i?"":"~"}${n} ${a/o} != initPTS: ${c.baseTime/c.timescale} (${c.baseTime}/${c.timescale}) trackId: ${c.trackId}`),this.log(`Found initPTS at playlist time: ${n} offset: ${a/o} (${a}/${o}) trackId: ${f}`),this._initPTS={baseTime:a,timescale:o,trackId:f},this._initDTS={baseTime:r,timescale:o,trackId:f}):a=o=void 0,{tracks:d,initPTS:a,timescale:o,trackId:f}}},{key:"remuxVideo",value:function(e,t,n,i){var a,r,o=e.inputTimeScale,s=e.samples,u=[],l=s.length,d=this._initPTS,c=d.baseTime*o/d.timescale,h=this.nextVideoTs,m=8,f=this.videoSampleDuration,v=Number.POSITIVE_INFINITY,p=Number.NEGATIVE_INFINITY,g=!1;if(!n||null===h){var y=c+t*o,b=s[0].pts-nU(s[0].dts,s[0].pts);Qz&&null!==h&&Math.abs(y-b-(h+c))<15e3?n=!0:h=y-b-c}for(var w=h+c,k=0;k<l;k++){var S=s[k];S.pts=nU(S.pts,w),S.dts=nU(S.dts,w),S.dts<s[k>0?k-1:k].dts&&(g=!0)}g&&s.sort(function(e,t){var n=e.dts-t.dts,i=e.pts-t.pts;return n||i}),a=s[0].dts;var E=(r=s[s.length-1].dts)-a,P=E?Math.round(E/(l-1)):f||e.inputTimeScale/30;if(n){var T=a-w,_=T>P,M=T<-1;if((_||M)&&(_?this.warn(`${(e.segmentCodec||"").toUpperCase()}: ${qz(T,!0)} ms (${T}dts) hole between fragments detected at ${t.toFixed(3)}`):this.warn(`${(e.segmentCodec||"").toUpperCase()}: ${qz(-T,!0)} ms (${T}dts) overlapping between fragments detected at ${t.toFixed(3)}`),!M||w>=s[0].pts||Qz)){a=w;var A=s[0].pts-T;if(_)s[0].dts=a,s[0].pts=A;else for(var D=!0,x=0;x<s.length&&!(s[x].dts>A&&D);x++){var C=s[x].pts;if(s[x].dts-=T,s[x].pts-=T,x<s.length-1){var I=s[x+1].pts;D=I<=s[x].pts==I<=C}}this.log(`Video: Initial PTS/DTS adjusted: ${qz(A,!0)}/${qz(a,!0)}, delta: ${qz(T,!0)} ms`)}}for(var L=0,R=0,F=a=Math.max(0,a),O=0;O<l;O++){for(var $=s[O],N=$.units,W=N.length,j=0,B=0;B<W;B++)j+=N[B].data.length;R+=j,L+=W,$.length=j,$.dts<F?($.dts=F,F+=P/4|0||1):F=$.dts,v=Math.min($.pts,v),p=Math.max($.pts,p)}r=s[l-1].dts;var z,U=R+4*L+8;try{z=new Uint8Array(U)}catch(e){return void this.observer.emit(m$.ERROR,m$.ERROR,{type:c$.MUX_ERROR,details:h$.REMUX_ALLOC_ERROR,fatal:!1,error:e,bytes:U,reason:`fail allocating video mdat ${U}`})}var H=new DataView(z.buffer);H.setUint32(0,U),z.set(Xz.types.mdat,4);for(var G=!1,V=Number.POSITIVE_INFINITY,K=Number.POSITIVE_INFINITY,X=Number.NEGATIVE_INFINITY,Y=Number.NEGATIVE_INFINITY,q=0;q<l;q++){for(var J=s[q],Q=J.units,Z=0,ee=0,te=Q.length;ee<te;ee++){var ne=Q[ee],ie=ne.data,ae=ne.data.byteLength;H.setUint32(m,ae),m+=4,z.set(ie,m),m+=ae,Z+=4+ae}var re=void 0;if(q<l-1)f=s[q+1].dts-J.dts,re=s[q+1].pts-J.pts;else{var oe=this.config,se=q>0?J.dts-s[q-1].dts:P;if(re=q>0?J.pts-s[q-1].pts:P,oe.stretchShortVideoTrack&&null!==this.nextAudioTs){var ue=Math.floor(oe.maxBufferHole*o),le=(i?v+i*o:this.nextAudioTs+c)-J.pts;le>ue?((f=le-se)<0?f=se:G=!0,this.log(`It is approximately ${le/90} ms to the next segment; using duration ${f/90} ms for the last video frame.`)):f=se}else f=se}var de=Math.round(J.pts-J.dts);V=Math.min(V,f),X=Math.max(X,f),K=Math.min(K,re),Y=Math.max(Y,re),u.push(eU(J.key,f,Z,de))}if(u.length)if(Qz){if(Qz<70){var ce=u[0].flags;ce.dependsOn=2,ce.isNonSync=0}}else if(Zz&&Y-K<X-V&&P/X<.025&&0===u[0].cts){this.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");for(var he=a,me=0,fe=u.length;me<fe;me++){var ve=he+u[me].duration,pe=he+u[me].cts;if(me<fe-1){var ge=ve+u[me+1].cts;u[me].duration=ge-pe}else u[me].duration=me?u[me-1].duration:P;u[me].cts=0,he=ve}}var ye=r+(f=G||!f?P:f);this.nextVideoTs=h=ye-c,this.videoSampleDuration=f,this.isVideoContiguous=!0;var be={data1:Xz.moof(e.sequenceNumber++,a,P$(e,{samples:u})),data2:z,startPTS:(v-c)/o,endPTS:(p+f-c)/o,startDTS:(a-c)/o,endDTS:h/o,type:"video",hasAudio:!1,hasVideo:!0,nb:u.length,dropped:e.dropped};return e.samples=[],e.dropped=0,be}},{key:"getSamplesPerFrame",value:function(e){switch(e.segmentCodec){case"mp3":return 1152;case"ac3":return 1536;default:return 1024}}},{key:"remuxAudio",value:function(e,t,n,i,a){var r=e.inputTimeScale,o=r/(e.samplerate?e.samplerate:r),s=this.getSamplesPerFrame(e),u=s*o,l=this._initPTS,d="mp3"===e.segmentCodec&&this.typeSupported.mpeg,c=[],h=void 0!==a,m=e.samples,f=d?0:8,v=this.nextAudioTs||-1,p=l.baseTime*r/l.timescale,g=p+t*r;if(this.isAudioContiguous=n=n||m.length&&v>0&&(i&&Math.abs(g-(v+p))<9e3||Math.abs(nU(m[0].pts,g)-(v+p))<20*u),m.forEach(function(e){e.pts=nU(e.pts,g)}),!n||v<0){var y=m.length;if(m=m.filter(e=>e.pts>=0),y!==m.length&&this.warn(`Removed ${m.length-y} of ${y} samples (initPTS ${p} / ${r})`),!m.length)return;v=0===a?0:i&&!h?Math.max(0,g-p):m[0].pts-p}if("aac"===e.segmentCodec)for(var b=this.config.maxAudioFramesDrift,w=0,k=v+p;w<m.length;w++){var S=m[w],E=S.pts,P=E-k,T=Math.abs(1e3*P/r);if(P<=-b*u&&h)0===w&&(this.warn(`Audio frame @ ${(E/r).toFixed(3)}s overlaps marker by ${Math.round(1e3*P/r)} ms.`),this.nextAudioTs=v=E-p,k=E);else if(P>=b*u&&T<1e4&&h){var _=Math.round(P/u);for(k=E-_*u;k<0&&_&&u;)_--,k+=u;0===w&&(this.nextAudioTs=v=k-p),this.warn(`Injecting ${_} audio frames @ ${((k-p)/r).toFixed(3)}s due to ${Math.round(1e3*P/r)} ms gap.`);for(var M=0;M<_;M++){var A=Vz.getSilentFrame(e.parsedCodec||e.manifestCodec||e.codec,e.channelCount);A||(this.log("Unable to get silent frame for given audio codec; duplicating last frame instead."),A=S.unit.subarray()),m.splice(w,0,{unit:A,pts:k}),k+=u,w++}}S.pts=k,k+=u}for(var D,x=null,C=null,I=0,L=m.length;L--;)I+=m[L].unit.byteLength;for(var R=0,F=m.length;R<F;R++){var O=m[R],$=O.unit,N=O.pts;if(null!==C){c[R-1].duration=Math.round((N-C)/o)}else{if(n&&"aac"===e.segmentCodec&&(N=v+p),x=N,!(I>0))return;I+=f;try{D=new Uint8Array(I)}catch(e){return void this.observer.emit(m$.ERROR,m$.ERROR,{type:c$.MUX_ERROR,details:h$.REMUX_ALLOC_ERROR,fatal:!1,error:e,bytes:I,reason:`fail allocating audio mdat ${I}`})}d||(new DataView(D.buffer).setUint32(0,I),D.set(Xz.types.mdat,4))}D.set($,f);var W=$.byteLength;f+=W,c.push(eU(!0,s,W,0)),C=N}var j=c.length;if(j){var B=c[c.length-1];v=C-p,this.nextAudioTs=v+o*B.duration;var z=d?new Uint8Array(0):Xz.moof(e.sequenceNumber++,x/o,P$({},e,{samples:c}));e.samples=[];var U=(x-p)/r,H=this.nextAudioTs/r,G={data1:z,data2:D,startPTS:U,endPTS:H,startDTS:U,endDTS:H,type:"audio",hasAudio:!0,hasVideo:!1,nb:j};return this.isAudioContiguous=!0,G}}}])}(M$);function nU(e,t){var n;if(null===t)return e;for(n=t<e?-8589934592:8589934592;Math.abs(e-t)>4294967296;)e+=n;return e}function iU(e,t,n,i){var a=e.samples.length;if(a){for(var r=e.inputTimeScale,o=0;o<a;o++){var s=e.samples[o];s.pts=nU(s.pts-n.baseTime*r/n.timescale,t*r)/r,s.dts=nU(s.dts-i.baseTime*r/i.timescale,t*r)/r}var u=e.samples;return e.samples=[],{samples:u}}}function aU(e,t,n){var i=e.samples.length;if(i){for(var a=e.inputTimeScale,r=0;r<i;r++){var o=e.samples[r];o.pts=nU(o.pts-n.baseTime*a/n.timescale,t*a)/a}e.samples.sort((e,t)=>e.pts-t.pts);var s=e.samples;return e.samples=[],{samples:s}}}var rU,oU=function(e){function t(e,n,i,a){var s;return o(this,t),(s=r(this,t,["passthrough-remuxer",a])).emitInitSegment=!1,s.audioCodec=void 0,s.videoCodec=void 0,s.initData=void 0,s.initPTS=null,s.initTracks=void 0,s.lastEndTime=null,s.isVideoContiguous=!1,s}return p(t,e),c(t,[{key:"destroy",value:function(){}},{key:"resetTimeStamp",value:function(e){this.lastEndTime=null;var t=this.initPTS;t&&e&&t.baseTime===e.baseTime&&t.timescale===e.timescale||(this.initPTS=e)}},{key:"resetNextTimestamp",value:function(){this.isVideoContiguous=!1,this.lastEndTime=null}},{key:"resetInitSegment",value:function(e,t,n,i){this.audioCodec=t,this.videoCodec=n,this.generateInitSegment(e,i),this.emitInitSegment=!0}},{key:"generateInitSegment",value:function(e,t){var n=this.audioCodec,i=this.videoCodec;if(null==e||!e.byteLength)return this.initTracks=void 0,void(this.initData=void 0);var a=this.initData=uN(e),r=a.audio,o=a.video;if(t)!function(e,t){if(e&&t){var n=t.keyId;n&&t.isCommonEncryption&&fN(e,(e,t)=>{var i=e.subarray(8,24);i.some(e=>0!==e)||(L$.log(`[eme] Patching keyId in 'enc${t?"a":"v"}>sinf>>tenc' box: ${$$(i)} -> ${$$(n)}`),e.set(n,8))})}}(e,t);else{var s=r||o;null!=s&&s.encrypted&&this.warn(`Init segment with encrypted track with has no key ("${s.codec}")!`)}r&&(n=uU(r,H$,this)),o&&(i=uU(o,G$,this));var u={};r&&o?u.audiovideo={container:"video/mp4",codec:n+","+i,supplemental:o.supplemental,encrypted:o.encrypted,initSegment:e,id:"main"}:r?u.audio={container:"audio/mp4",codec:n,encrypted:r.encrypted,initSegment:e,id:"audio"}:o?u.video={container:"video/mp4",codec:i,supplemental:o.supplemental,encrypted:o.encrypted,initSegment:e,id:"main"}:this.warn("initSegment does not contain moov or trak boxes."),this.initTracks=u}},{key:"remux",value:function(e,t,n,i,a,r){var o,s,u=this.initPTS,l=this.lastEndTime,d={audio:void 0,video:void 0,text:i,id3:n,initSegment:void 0};u$(l)||(l=this.lastEndTime=a||0);var c=t.samples;if(!c.length)return d;var h={initPTS:void 0,timescale:void 0,trackId:void 0},m=this.initData;if(null!=(o=m)&&o.length||(this.generateInitSegment(c),m=this.initData),null==(s=m)||!s.length)return this.warn("Failed to generate initSegment."),d;this.emitInitSegment&&(h.tracks=this.initTracks,this.emitInitSegment=!1);var f=function(e,t,n){for(var i={},a=oN(e,["moof","traf"]),r=0;r<a.length;r++){var o=a[r],s=oN(o,["tfhd"])[0],u=iN(s,4),l=t[u];if(l){i[u]||(i[u]={start:NaN,duration:0,sampleCount:0,timescale:l.timescale,type:l.type});var d=i[u],c=oN(o,["tfdt"])[0];if(c){var h=c[0],m=iN(c,4);1===h&&(m===Q$?n.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"):(m*=Q$+1,m+=iN(c,8))),u$(m)&&(!u$(d.start)||m<d.start)&&(d.start=m)}var f=l.default,v=iN(s,0)|(null==f?void 0:f.flags),p=(null==f?void 0:f.duration)||0;8&v&&(p=iN(s,2&v?12:8));for(var g=oN(o,["trun"]),y=d.start||0,b=0,w=p,k=0;k<g.length;k++){var S=g[k],E=iN(S,4),P=d.sampleCount;d.sampleCount+=E;var T=1&S[3],_=4&S[3],M=1&S[2],A=2&S[2],D=4&S[2],x=8&S[2],C=8,I=E;for(T&&(C+=4),_&&E&&(1&S[C+1]||void 0!==d.keyFrameIndex||(d.keyFrameIndex=P),C+=4,M?(w=iN(S,C),C+=4):w=p,A&&(C+=4),x&&(C+=4),y+=w,b+=w,I--);I--;)M?(w=iN(S,C),C+=4):w=p,A&&(C+=4),D&&(1&S[C+1]||void 0===d.keyFrameIndex&&(d.keyFrameIndex=d.sampleCount-(I+1),d.keyFrameStart=y),C+=4),x&&(C+=4),y+=w,b+=w;!b&&p&&(b+=p*E)}d.duration+=b}}if(!Object.keys(i).some(e=>i[e].duration)){for(var L=1/0,R=0,F=oN(e,["sidx"]),O=0;O<F.length;O++){var $=sN(F[O]);if(null!=$&&$.references){L=Math.min(L,$.earliestPresentationTime/$.timescale);var N=$.references.reduce((e,t)=>e+t.info.duration||0,0);R=Math.max(R,N+$.earliestPresentationTime/$.timescale)}}R&&u$(R)&&Object.keys(i).forEach(e=>{i[e].duration||(i[e].duration=R*i[e].timescale-i[e].start)})}return i}(c,m,this),v=m.audio?f[m.audio.id]:null,p=m.video?f[m.video.id]:null,g=sU(p,1/0),y=sU(v,1/0),b=sU(p,0,!0),w=sU(v,0,!0),k=a,S=0,E=v&&(!p||!u&&y<g||u&&u.trackId===m.audio.id),P=E?v:p;if(P){var T=P.timescale,_=P.start-a*T,M=E?m.audio.id:m.video.id;k=P.start/T,S=E?w-y:b-g,!r&&u||!function(e,t,n,i){if(null===e)return!0;var a=Math.max(i,1),r=t-e.baseTime/e.timescale;return Math.abs(r-n)>a}(u,k,a,S)&&T===u.timescale||(u&&this.warn(`Timestamps at playlist time: ${r?"":"~"}${a} ${_/T} != initPTS: ${u.baseTime/u.timescale} (${u.baseTime}/${u.timescale}) trackId: ${u.trackId}`),this.log(`Found initPTS at playlist time: ${a} offset: ${k-a} (${_}/${T}) trackId: ${M}`),u=null,h.initPTS=_,h.timescale=T,h.trackId=M)}else this.warn(`No audio or video samples found for initPTS at playlist time: ${a}`);u?(h.initPTS=u.baseTime,h.timescale=u.timescale,h.trackId=u.trackId):(h.timescale&&void 0!==h.trackId&&void 0!==h.initPTS||(this.warn("Could not set initPTS"),h.initPTS=k,h.timescale=1,h.trackId=-1),this.initPTS=u={baseTime:h.initPTS,timescale:h.timescale,trackId:h.trackId});var A=k-u.baseTime/u.timescale,D=A+S;S>0?this.lastEndTime=D:(this.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var x=!!m.audio,C=!!m.video,I="";x&&(I+="audio"),C&&(I+="video");var L={data1:c,startPTS:A,startDTS:A,endPTS:D,endDTS:D,type:I,hasAudio:x,hasVideo:C,nb:1,dropped:0,encrypted:!!m.audio&&m.audio.encrypted||!!m.video&&m.video.encrypted};d.audio=x&&!C?L:void 0,d.video=C?L:void 0;var R=null==p?void 0:p.sampleCount;if(R){var F=p.keyFrameIndex,O=-1!==F;L.nb=R,L.dropped=0===F||this.isVideoContiguous?0:O?F:R,L.independent=O,L.firstKeyFrame=F,O&&p.keyFrameStart&&(L.firstKeyFramePTS=(p.keyFrameStart-u.baseTime)/u.timescale),this.isVideoContiguous||(d.independent=O),this.isVideoContiguous||(this.isVideoContiguous=O),L.dropped&&this.warn(`fmp4 does not start with IDR: firstIDR ${F}/${R} dropped: ${L.dropped} start: ${L.firstKeyFramePTS||"NA"}`)}return d.initSegment=h,d.id3=iU(n,a,u,u),i.samples.length&&(d.text=aU(i,a,u)),d}}])}(M$);function sU(e,t,n=!1){return void 0!==(null==e?void 0:e.start)?(e.start+(n?e.duration:0))/e.timescale:t}function uU(e,t,n){var i=e.codec;if(i&&i.length>4)return i;if(t===H$){if("ec-3"===i||"ac-3"===i||"alac"===i)return i;if("fLaC"===i||"Opus"===i){return RN(i,!1)}return n.warn(`Unhandled audio codec "${i}" in mp4 MAP`),i||"mp4a"}return n.warn(`Unhandled video codec "${i}" in mp4 MAP`),i||"avc1"}try{rU=self.performance.now.bind(self.performance)}catch(e){rU=Date.now}var lU=[{demux:Cz,remux:oU},{demux:Wz,remux:tU},{demux:Tz,remux:tU},{demux:Dz,remux:tU}];lU.splice(2,0,{demux:Mz,remux:tU});var dU=function(){return c(function e(t,n,i,a,r,s){o(this,e),this.asyncResult=!1,this.logger=void 0,this.observer=void 0,this.typeSupported=void 0,this.config=void 0,this.id=void 0,this.demuxer=void 0,this.remuxer=void 0,this.decrypter=void 0,this.probe=void 0,this.decryptionPromise=null,this.transmuxConfig=void 0,this.currentTransmuxState=void 0,this.observer=t,this.typeSupported=n,this.config=i,this.id=r,this.logger=s},[{key:"configure",value:function(e){this.transmuxConfig=e,this.decrypter&&this.decrypter.reset()}},{key:"push",value:function(e,t,n,i){var a=n.transmuxing;a.executeStart=rU();var r=new Uint8Array(e),o=this.currentTransmuxState,s=this.transmuxConfig;i&&(this.currentTransmuxState=i);var u=i||o,l=u.contiguous,d=u.discontinuity,c=u.trackSwitch,h=u.accurateTimeOffset,m=u.timeOffset,f=u.initSegmentChange,v=s.audioCodec,p=s.videoCodec,g=s.defaultInitPts,y=s.duration,b=s.initSegmentData,w=function(e,t){var n=null;e.byteLength>0&&null!=(null==t?void 0:t.key)&&null!==t.iv&&null!=t.method&&(n=t);return n}(r,t);if(w&&yj(w.method)){var k=this.getDecrypter(),S=bj(w.method);if(!k.isSync())return this.asyncResult=!0,this.decryptionPromise=k.webCryptoDecrypt(r,w.key.buffer,w.iv.buffer,S).then(e=>{var t=this.push(e,null,n);return this.decryptionPromise=null,t}),this.decryptionPromise;var E=k.softwareDecrypt(r,w.key.buffer,w.iv.buffer,S);if(n.part>-1){var P=k.flush();E=P?P.buffer:P}if(!E)return a.executeEnd=rU(),cU(n);r=new Uint8Array(E)}var T=this.needsProbing(d,c);if(T){var _=this.configureTransmuxer(r);if(_)return this.logger.warn(`[transmuxer] ${_.message}`),this.observer.emit(m$.ERROR,m$.ERROR,{type:c$.MEDIA_ERROR,details:h$.FRAG_PARSING_ERROR,fatal:!1,error:_,reason:_.message}),a.executeEnd=rU(),cU(n)}(d||c||f||T)&&this.resetInitSegment(b,v,p,y,t),(d||f||T)&&this.resetInitialTimestamp(g),l||this.resetContiguity();var M=this.transmux(r,w,m,h,n);this.asyncResult=hU(M);var A=this.currentTransmuxState;return A.contiguous=!0,A.discontinuity=!1,A.trackSwitch=!1,a.executeEnd=rU(),M}},{key:"flush",value:function(e){var t=e.transmuxing;t.executeStart=rU();var n=this.decrypter,i=this.currentTransmuxState,a=this.decryptionPromise;if(a)return this.asyncResult=!0,a.then(()=>this.flush(e));var r=[],o=i.timeOffset;if(n){var s=n.flush();s&&r.push(this.push(s.buffer,null,e))}var u=this.demuxer,l=this.remuxer;if(!u||!l){t.executeEnd=rU();var d=[cU(e)];return this.asyncResult?Promise.resolve(d):d}var c=u.flush(o);return hU(c)?(this.asyncResult=!0,c.then(t=>(this.flushRemux(r,t,e),r))):(this.flushRemux(r,c,e),this.asyncResult?Promise.resolve(r):r)}},{key:"flushRemux",value:function(e,t,n){var i=t.audioTrack,a=t.videoTrack,r=t.id3Track,o=t.textTrack,s=this.currentTransmuxState,u=s.accurateTimeOffset,l=s.timeOffset;this.logger.log(`[transmuxer.ts]: Flushed ${this.id} sn: ${n.sn}${n.part>-1?" part: "+n.part:""} of ${this.id===y$?"level":"track"} ${n.level}`);var d=this.remuxer.remux(i,a,r,o,l,u,!0,this.id);e.push({remuxResult:d,chunkMeta:n}),n.transmuxing.executeEnd=rU()}},{key:"resetInitialTimestamp",value:function(e){var t=this.demuxer,n=this.remuxer;t&&n&&(t.resetTimeStamp(e),n.resetTimeStamp(e))}},{key:"resetContiguity",value:function(){var e=this.demuxer,t=this.remuxer;e&&t&&(e.resetContiguity(),t.resetNextTimestamp())}},{key:"resetInitSegment",value:function(e,t,n,i,a){var r=this.demuxer,o=this.remuxer;r&&o&&(r.resetInitSegment(e,t,n,i),o.resetInitSegment(e,t,n,a))}},{key:"destroy",value:function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)}},{key:"transmux",value:function(e,t,n,i,a){return t&&"SAMPLE-AES"===t.method?this.transmuxSampleAes(e,t,n,i,a):this.transmuxUnencrypted(e,n,i,a)}},{key:"transmuxUnencrypted",value:function(e,t,n,i){var a=this.demuxer.demux(e,t,!1,!this.config.progressive),r=a.audioTrack,o=a.videoTrack,s=a.id3Track,u=a.textTrack;return{remuxResult:this.remuxer.remux(r,o,s,u,t,n,!1,this.id),chunkMeta:i}}},{key:"transmuxSampleAes",value:function(e,t,n,i,a){return this.demuxer.demuxSampleAes(e,t,n).then(e=>({remuxResult:this.remuxer.remux(e.audioTrack,e.videoTrack,e.id3Track,e.textTrack,n,i,!1,this.id),chunkMeta:a}))}},{key:"configureTransmuxer",value:function(e){for(var t,n=this.config,i=this.observer,a=this.typeSupported,r=0,o=lU.length;r<o;r++){var s;if(null!=(s=lU[r].demux)&&s.probe(e,this.logger)){t=lU[r];break}}if(!t)return new Error("Failed to find demuxer by probing fragment data");var u=this.demuxer,l=this.remuxer,d=t.remux,c=t.demux;l&&l instanceof d||(this.remuxer=new d(i,n,a,this.logger)),u&&u instanceof c||(this.demuxer=new c(i,n,a,this.logger),this.probe=c.probe)}},{key:"needsProbing",value:function(e,t){return!this.demuxer||!this.remuxer||e||t}},{key:"getDecrypter",value:function(){var e=this.decrypter;return e||(e=this.decrypter=new XW(this.config)),e}}])}();var cU=e=>({remuxResult:{},chunkMeta:e});function hU(e){return"then"in e&&e.then instanceof Function}var mU=c(function e(t,n,i,a,r){o(this,e),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=n,this.initSegmentData=i,this.duration=a,this.defaultInitPts=r||null}),fU=c(function e(t,n,i,a,r,s){o(this,e),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=n,this.accurateTimeOffset=i,this.trackSwitch=a,this.timeOffset=r,this.initSegmentChange=s}),vU=0,pU=function(){return c(function e(t,n,i,a){o(this,e),this.error=null,this.hls=void 0,this.id=void 0,this.instanceNo=vU++,this.observer=void 0,this.frag=null,this.part=null,this.useWorker=void 0,this.workerContext=null,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0,this.onWorkerMessage=e=>{var t=e.data,n=this.hls;if(n&&null!=t&&t.event&&t.instanceNo===this.instanceNo)switch(t.event){case"init":var i,a=null==(i=this.workerContext)?void 0:i.objectURL;a&&self.URL.revokeObjectURL(a);break;case"transmuxComplete":this.handleTransmuxComplete(t.data);break;case"flush":this.onFlush(t.data);break;case"workerLog":n.logger[t.data.logType]&&n.logger[t.data.logType](t.data.message);break;default:t.data=t.data||{},t.data.frag=this.frag,t.data.part=this.part,t.data.id=this.id,n.trigger(t.event,t.data)}},this.onWorkerError=e=>{if(this.hls){var t=new Error(`${e.message} (${e.filename}:${e.lineno})`);this.hls.config.enableWorker=!1,this.hls.logger.warn(`Error in "${this.id}" Web Worker, fallback to inline`),this.hls.trigger(m$.ERROR,{type:c$.OTHER_ERROR,details:h$.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:t})}};var r=t.config;this.hls=t,this.id=n,this.useWorker=!!r.enableWorker,this.onTransmuxComplete=i,this.onFlush=a;var s=(e,t)=>{(t=t||{}).frag=this.frag||void 0,e===m$.ERROR&&(t.parent=this.id,t.part=this.part,this.error=t.error),this.hls.trigger(e,t)};this.observer=new BB,this.observer.on(m$.FRAG_DECRYPTED,s),this.observer.on(m$.ERROR,s);var u=NN(r.preferManagedMediaSource);if(this.useWorker&&"undefined"!=typeof Worker){var l=this.hls.logger;if(r.workerPath||"function"==typeof __HLS_WORKER_BUNDLE__){try{r.workerPath?(l.log(`loading Web Worker ${r.workerPath} for "${n}"`),this.workerContext=function(e){var t=UB[e];if(t)return t.clientCount++,t;var n=new self.URL(e,self.location.href).href,i={worker:new self.Worker(n),scriptURL:n,clientCount:1};return UB[e]=i,i}(r.workerPath)):(l.log(`injecting Web Worker for "${n}"`),this.workerContext=function(){var e=UB[zB];if(e)return e.clientCount++,e;var t=new self.Blob([`var exports={};var module={exports:exports};function define(f){f()};define.amd=true;(${__HLS_WORKER_BUNDLE__.toString()})(true);`],{type:"text/javascript"}),n=self.URL.createObjectURL(t),i={worker:new self.Worker(n),objectURL:n,clientCount:1};return UB[zB]=i,i}());var d=this.workerContext.worker;d.addEventListener("message",this.onWorkerMessage),d.addEventListener("error",this.onWorkerError),d.postMessage({instanceNo:this.instanceNo,cmd:"init",typeSupported:u,id:n,config:nW(r)})}catch(e){l.warn(`Error setting up "${n}" Web Worker, fallback to inline`,e),this.terminateWorker(),this.error=null,this.transmuxer=new dU(this.observer,u,r,"",n,t.logger)}return}}this.transmuxer=new dU(this.observer,u,r,"",n,t.logger)},[{key:"reset",value:function(){if(this.frag=null,this.part=null,this.workerContext){var e=this.instanceNo;this.instanceNo=vU++;var t=this.hls.config,n=NN(t.preferManagedMediaSource);this.workerContext.worker.postMessage({instanceNo:this.instanceNo,cmd:"reset",resetNo:e,typeSupported:n,id:this.id,config:nW(t)})}}},{key:"terminateWorker",value:function(){if(this.workerContext){var e=this.workerContext.worker;this.workerContext=null,e.removeEventListener("message",this.onWorkerMessage),e.removeEventListener("error",this.onWorkerError),function(e){var t=UB[e||zB];if(t&&1===t.clientCount--){var n=t.worker,i=t.objectURL;delete UB[e||zB],i&&self.URL.revokeObjectURL(i),n.terminate()}}(this.hls.config.workerPath)}}},{key:"destroy",value:function(){if(this.workerContext)this.terminateWorker(),this.onWorkerMessage=this.onWorkerError=null;else{var e=this.transmuxer;e&&(e.destroy(),this.transmuxer=null)}var t=this.observer;t&&t.removeAllListeners(),this.frag=null,this.part=null,this.observer=null,this.hls=null}},{key:"push",value:function(e,t,n,i,a,r,o,s,u,l){var d,c;u.transmuxing.start=self.performance.now();var h=this.instanceNo,m=this.transmuxer,f=r?r.start:a.start,v=a.decryptdata,p=this.frag,g=!(p&&a.cc===p.cc),y=!(p&&u.level===p.level),b=p?u.sn-p.sn:-1,w=this.part?u.part-this.part.index:-1,k=0===b&&u.id>1&&u.id===(null==p?void 0:p.stats.chunkCount),S=!y&&(1===b||0===b&&(1===w||k&&w<=0)),E=self.performance.now();(y||b||0===a.stats.parsing.start)&&(a.stats.parsing.start=E),!r||!w&&S||(r.stats.parsing.start=E);var P=!(p&&(null==(d=a.initSegment)?void 0:d.url)===(null==(c=p.initSegment)?void 0:c.url)),T=new fU(g,S,s,y,f,P);if(!S||g||P){this.hls.logger.log(`[transmuxer-interface]: Starting new transmux session for ${a.type} sn: ${u.sn}${u.part>-1?" part: "+u.part:""} ${this.id===y$?"level":"track"}: ${u.level} id: ${u.id}\n discontinuity: ${g}\n trackSwitch: ${y}\n contiguous: ${S}\n accurateTimeOffset: ${s}\n timeOffset: ${f}\n initSegmentChange: ${P}`);var _=new mU(n,i,t,o,l);this.configureTransmuxer(_)}if(this.frag=a,this.part=r,this.workerContext)this.workerContext.worker.postMessage({instanceNo:h,cmd:"demux",data:e,decryptdata:v,chunkMeta:u,state:T},e instanceof ArrayBuffer?[e]:[]);else if(m){var M=m.push(e,v,u,T);hU(M)?M.then(e=>{this.handleTransmuxComplete(e)}).catch(e=>{this.transmuxerError(e,u,"transmuxer-interface push error")}):this.handleTransmuxComplete(M)}}},{key:"flush",value:function(e){e.transmuxing.start=self.performance.now();var t=this.instanceNo,n=this.transmuxer;if(this.workerContext)this.workerContext.worker.postMessage({instanceNo:t,cmd:"flush",chunkMeta:e});else if(n){var i=n.flush(e);hU(i)?i.then(t=>{this.handleFlushResult(t,e)}).catch(t=>{this.transmuxerError(t,e,"transmuxer-interface flush error")}):this.handleFlushResult(i,e)}}},{key:"transmuxerError",value:function(e,t,n){this.hls&&(this.error=e,this.hls.trigger(m$.ERROR,{type:c$.MEDIA_ERROR,details:h$.FRAG_PARSING_ERROR,chunkMeta:t,frag:this.frag||void 0,part:this.part||void 0,fatal:!1,error:e,err:e,reason:n}))}},{key:"handleFlushResult",value:function(e,t){e.forEach(e=>{this.handleTransmuxComplete(e)}),this.onFlush(t)}},{key:"configureTransmuxer",value:function(e){var t=this.instanceNo,n=this.transmuxer;this.workerContext?this.workerContext.worker.postMessage({instanceNo:t,cmd:"configure",config:e}):n&&n.configure(e)}},{key:"handleTransmuxComplete",value:function(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e)}}])}(),gU=function(e){function t(e,n,i){var a;return o(this,t),(a=r(this,t,[e,n,i,"audio-stream-controller",b$])).mainAnchor=null,a.mainFragLoading=null,a.audioOnly=!1,a.bufferedTrack=null,a.switchingTrack=null,a.trackId=-1,a.waitingData=null,a.mainDetails=null,a.flushing=!1,a.bufferFlushed=!1,a.cachedTrackLoadedData=null,a.registerListeners(),a}return p(t,e),c(t,[{key:"onHandlerDestroying",value:function(){this.unregisterListeners(),T(t,"onHandlerDestroying",this)([]),this.resetItem()}},{key:"resetItem",value:function(){this.mainDetails=this.mainAnchor=this.mainFragLoading=this.bufferedTrack=this.switchingTrack=this.waitingData=this.cachedTrackLoadedData=null}},{key:"registerListeners",value:function(){T(t,"registerListeners",this)([]);var e=this.hls;e.on(m$.LEVEL_LOADED,this.onLevelLoaded,this),e.on(m$.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.on(m$.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(m$.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(m$.BUFFER_RESET,this.onBufferReset,this),e.on(m$.BUFFER_CREATED,this.onBufferCreated,this),e.on(m$.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(m$.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(m$.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(m$.FRAG_LOADING,this.onFragLoading,this),e.on(m$.FRAG_BUFFERED,this.onFragBuffered,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e&&(T(t,"unregisterListeners",this)([]),e.off(m$.LEVEL_LOADED,this.onLevelLoaded,this),e.off(m$.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.off(m$.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(m$.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(m$.BUFFER_RESET,this.onBufferReset,this),e.off(m$.BUFFER_CREATED,this.onBufferCreated,this),e.off(m$.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(m$.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(m$.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(m$.FRAG_LOADING,this.onFragLoading,this),e.off(m$.FRAG_BUFFERED,this.onFragBuffered,this))}},{key:"onInitPtsFound",value:function(e,{frag:t,id:n,initPTS:i,timescale:a,trackId:r}){if(n===y$){var o=t.cc,s=this.fragCurrent;if(this.initPTS[o]={baseTime:i,timescale:a,trackId:r},this.log(`InitPTS for cc: ${o} found from main: ${i/a} (${i}/${a}) trackId: ${r}`),this.mainAnchor=t,this.state===LB){var u=this.waitingData;(!u&&!this.loadingParts||u&&u.frag.cc!==o)&&this.syncWithAnchor(t,null==u?void 0:u.frag)}else!this.hls.hasEnoughToStart&&s&&s.cc!==o?(s.abortRequests(),this.syncWithAnchor(t,s)):this.state===PB&&this.tick()}}},{key:"getLoadPosition",value:function(){return!this.startFragRequested&&this.nextLoadPosition>=0?this.nextLoadPosition:T(t,"getLoadPosition",this)([])}},{key:"syncWithAnchor",value:function(e,t){var n,i=(null==(n=this.mainFragLoading)?void 0:n.frag)||null;if(!t||(null==i?void 0:i.cc)!==t.cc){var a=(i||e).cc,r=pW(this.getLevelDetails(),a,this.getLoadPosition());r&&(this.log(`Syncing with main frag at ${r.start} cc ${r.cc}`),this.startFragRequested=!1,this.nextLoadPosition=r.start,this.resetLoadingState(),this.state===PB&&this.doTickIdle())}}},{key:"startLoad",value:function(e,t){if(!this.levels)return this.startPosition=e,void(this.state=EB);var n=this.lastCurrentTime;this.stopLoad(),this.setInterval(100),n>0&&-1===e?(this.log(`Override startPosition with lastCurrentTime @${n.toFixed(3)}`),e=n,this.state=PB):this.state=AB,this.nextLoadPosition=this.lastCurrentTime=e+this.timelineOffset,this.startPosition=t?-1:e,this.tick()}},{key:"doTick",value:function(){switch(this.state){case PB:this.doTickIdle();break;case AB:var e=this.levels,n=this.trackId,i=null==e?void 0:e[n],a=null==i?void 0:i.details;if(a&&!this.waitForLive(i)){if(this.waitForCdnTuneIn(a))break;this.state=LB}break;case MB:this.checkRetryDate();break;case LB:var r=this.waitingData;if(r){var o=r.frag,s=r.part,u=r.cache,l=r.complete,d=this.mainAnchor;if(void 0!==this.initPTS[o.cc]){this.waitingData=null,this.state=_B;var c={frag:o,part:s,payload:u.flush().buffer,networkDetails:null};this._handleFragmentLoadProgress(c),l&&T(t,"_handleFragmentLoadComplete",this)([c])}else d&&d.cc!==r.frag.cc&&this.syncWithAnchor(d,r.frag)}else this.state=PB}this.onTickEnd()}},{key:"resetLoadingState",value:function(){var e=this.waitingData;e&&(this.fragmentTracker.removeFragment(e.frag),this.waitingData=null),T(t,"resetLoadingState",this)([])}},{key:"onTickEnd",value:function(){var e=this.media;null!=e&&e.readyState&&(this.lastCurrentTime=e.currentTime)}},{key:"doTickIdle",value:function(){var e,t=this.hls,n=this.levels,i=this.media,a=this.trackId,r=t.config;if(this.buffering&&(i||this.primaryPrefetch||!this.startFragRequested&&r.startFragPrefetch)&&null!=n&&n[a]){var o=n[a],s=o.details;if(!s||this.waitForLive(o)||this.waitForCdnTuneIn(s))return this.state=AB,void(this.startFragRequested=!1);var u=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&u&&(this.bufferFlushed=!1,this.afterBufferFlushed(u,H$,b$));var l=this.getFwdBufferInfo(u,b$);if(null!==l){if(!this.switchingTrack&&this._streamEnded(l,s))return t.trigger(m$.BUFFER_EOS,{type:"audio"}),void(this.state=CB);var d=l.len,c=t.maxBufferLength,h=s.fragments,m=h[0].start,f=this.getLoadPosition(),v=this.flushing?f:l.end;if(this.switchingTrack&&i){var p=f;s.PTSKnown&&p<m&&(l.end>m||l.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),i.currentTime=m+.05)}if(!(d>=c&&!this.switchingTrack&&v<h[h.length-1].start)){var g=this.getNextFragment(v,s);if(g&&this.isLoopLoading(g,v)&&(g=this.getNextFragmentLoopLoading(g,s,l,y$,c)),g){if(!this.exceedsMaxBuffer(l,c,g)){var y=(null==(e=this.mainFragLoading)?void 0:e.frag)||null;if(!this.audioOnly&&this.startFragRequested&&y&&X$(g)&&!g.endList&&(!s.live||!this.loadingParts&&v<this.hls.liveSyncPosition)&&(this.fragmentTracker.getState(y)===NW&&(this.mainFragLoading=y=null),y&&X$(y))){if(g.start>y.end){var b=this.fragmentTracker.getFragAtPos(v,y$);b&&b.end>y.end&&(y=b,this.mainFragLoading={frag:b,targetBufferTime:null})}if(g.start>y.end)return}this.loadFragment(g,o,v)}}else this.bufferFlushed=!0}}}}},{key:"onMediaDetaching",value:function(e,n){this.bufferFlushed=this.flushing=!1,T(t,"onMediaDetaching",this)([e,n])}},{key:"onAudioTracksUpdated",value:function(e,{audioTracks:t}){this.resetTransmuxer(),this.levels=t.map(e=>new ZN(e))}},{key:"onAudioTrackSwitching",value:function(e,t){var n=!!t.url;this.trackId=t.id;var i=this.fragCurrent;i&&(i.abortRequests(),this.removeUnbufferedFrags(i.start)),this.resetLoadingState(),n?(this.switchingTrack=t,this.flushAudioIfNeeded(t),this.state!==EB&&(this.setInterval(100),this.state=PB,this.tick())):(this.resetTransmuxer(),this.switchingTrack=null,this.bufferedTrack=t,this.clearInterval())}},{key:"onManifestLoading",value:function(){T(t,"onManifestLoading",this)([]),this.bufferFlushed=this.flushing=this.audioOnly=!1,this.resetItem(),this.trackId=-1}},{key:"onLevelLoaded",value:function(e,t){this.mainDetails=t.details;var n=this.cachedTrackLoadedData;n&&(this.cachedTrackLoadedData=null,this.onAudioTrackLoaded(m$.AUDIO_TRACK_LOADED,n))}},{key:"onAudioTrackLoaded",value:function(e,t){var n,i=this.levels,a=t.details,r=t.id,o=t.groupId,s=t.track;if(i){var u=this.mainDetails;if(!u||a.endCC>u.endCC||u.expired)return this.cachedTrackLoadedData=t,void(this.state!==EB&&(this.state=AB));this.cachedTrackLoadedData=null,this.log(`Audio track ${r} "${s.name}" of "${o}" loaded [${a.startSN},${a.endSN}]${a.lastPartSn?`[part-${a.lastPartSn}-${a.lastPartIndex}]`:""},duration:${a.totalduration}`);var l=i[r],d=0;if(a.live||null!=(n=l.details)&&n.live){if(this.checkLiveUpdate(a),a.deltaUpdateFailed)return;var c;if(l.details)d=this.alignPlaylists(a,l.details,null==(c=this.levelLastLoaded)?void 0:c.details);a.alignedSliding||(yB(a,u),a.alignedSliding||bB(a,u),d=a.fragmentStart)}l.details=a,this.levelLastLoaded=l,this.startFragRequested||this.setStartPosition(u,d),this.hls.trigger(m$.AUDIO_TRACK_UPDATED,{details:a,id:r,groupId:t.groupId}),this.state!==AB||this.waitForCdnTuneIn(a)||(this.state=PB),this.tick()}else this.warn(`Audio tracks reset while loading track ${r} "${s.name}" of "${o}"`)}},{key:"_handleFragmentLoadProgress",value:function(e){var t,n=e.frag,i=e.part,a=e.payload,r=this.config,o=this.trackId,s=this.levels;if(s){var u=s[o];if(u){var l=u.details;if(!l)return this.warn("Audio track details undefined on fragment load progress"),void this.removeUnbufferedFrags(n.start);var d=r.defaultAudioCodec||u.audioCodec||"mp4a.40.2",c=this.transmuxer;c||(c=this.transmuxer=new pU(this.hls,b$,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));var h=this.initPTS[n.cc],m=null==(t=n.initSegment)?void 0:t.data;if(void 0!==h){var f=i?i.index:-1,v=-1!==f,p=new tj(n.level,n.sn,n.stats.chunkCount,a.byteLength,f,v);c.push(a,m,d,"",n,i,l.totalduration,!1,p,h)}else{this.log(`Unknown video PTS for cc ${n.cc}, waiting for video PTS before demuxing audio frag ${n.sn} of [${l.startSN} ,${l.endSN}],track ${o}`),(this.waitingData=this.waitingData||{frag:n,part:i,cache:new $B,complete:!1}).cache.push(new Uint8Array(a)),this.state!==EB&&(this.state=LB)}}else this.warn("Audio track is undefined on fragment load progress")}else this.warn(`Audio tracks were reset while fragment load was in progress. Fragment ${n.sn} of level ${n.level} will not be buffered`)}},{key:"_handleFragmentLoadComplete",value:function(e){this.waitingData?this.waitingData.complete=!0:T(t,"_handleFragmentLoadComplete",this)([e])}},{key:"onBufferReset",value:function(){this.mediaBuffer=null}},{key:"onBufferCreated",value:function(e,t){this.bufferFlushed=this.flushing=!1;var n=t.tracks.audio;n&&(this.mediaBuffer=n.buffer||null)}},{key:"onFragLoading",value:function(e,t){!this.audioOnly&&t.frag.type===y$&&X$(t.frag)&&(this.mainFragLoading=t,this.state===PB&&this.tick())}},{key:"onFragBuffered",value:function(e,t){var n=t.frag,i=t.part;if(n.type===b$)if(this.fragContextChanged(n))this.warn(`Fragment ${n.sn}${i?" p: "+i.index:""} of level ${n.level} finished buffering, but was aborted. state: ${this.state}, audioSwitch: ${this.switchingTrack?this.switchingTrack.name:"false"}`);else{if(X$(n)){this.fragPrevious=n;var a=this.switchingTrack;a&&(this.bufferedTrack=a,this.switchingTrack=null,this.hls.trigger(m$.AUDIO_TRACK_SWITCHED,_$({},a)))}this.fragBufferedComplete(n,i),this.media&&this.tick()}else this.audioOnly||n.type!==y$||n.elementaryStreams.video||n.elementaryStreams.audiovideo||(this.audioOnly=!0,this.mainFragLoading=null)}},{key:"onError",value:function(e,n){var i;if(n.fatal)this.state=IB;else switch(n.details){case h$.FRAG_GAP:case h$.FRAG_PARSING_ERROR:case h$.FRAG_DECRYPT_ERROR:case h$.FRAG_LOAD_ERROR:case h$.FRAG_LOAD_TIMEOUT:case h$.KEY_LOAD_ERROR:case h$.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(b$,n);break;case h$.AUDIO_TRACK_LOAD_ERROR:case h$.AUDIO_TRACK_LOAD_TIMEOUT:case h$.LEVEL_PARSING_ERROR:n.levelRetry||this.state!==AB||(null==(i=n.context)?void 0:i.type)!==p$||(this.state=PB);break;case h$.BUFFER_ADD_CODEC_ERROR:case h$.BUFFER_APPEND_ERROR:if("audio"!==n.parent)return;this.reduceLengthAndFlushBuffer(n)||this.resetLoadingState();break;case h$.BUFFER_FULL_ERROR:if("audio"!==n.parent)return;this.reduceLengthAndFlushBuffer(n)&&(this.bufferedTrack=null,T(t,"flushMainBuffer",this)([0,Number.POSITIVE_INFINITY,"audio"]));break;case h$.INTERNAL_EXCEPTION:this.recoverWorkerError(n)}}},{key:"onBufferFlushing",value:function(e,{type:t}){t!==G$&&(this.flushing=!0)}},{key:"onBufferFlushed",value:function(e,{type:t}){if(t!==G$){this.flushing=!1,this.bufferFlushed=!0,this.state===CB&&(this.state=PB);var n=this.mediaBuffer||this.media;n&&(this.afterBufferFlushed(n,t,b$),this.tick())}}},{key:"_handleTransmuxComplete",value:function(e){var t,n="audio",i=this.hls,a=e.remuxResult,r=e.chunkMeta,o=this.getCurrentContext(r);if(o){var s=o.frag,u=o.part,l=o.level,d=l.details,c=a.audio,h=a.text,m=a.id3,f=a.initSegment;if(!this.fragContextChanged(s)&&d){if(this.state=DB,this.switchingTrack&&c&&this.completeAudioSwitch(this.switchingTrack),null!=f&&f.tracks){var v=s.initSegment||s;if(this.unhandledEncryptionError(f,s))return;this._bufferInitSegment(l,f.tracks,v,r),i.trigger(m$.FRAG_PARSING_INIT_SEGMENT,{frag:v,id:n,tracks:f.tracks})}if(c){var p=c.startPTS,g=c.endPTS,y=c.startDTS,b=c.endDTS;u&&(u.elementaryStreams[H$]={startPTS:p,endPTS:g,startDTS:y,endDTS:b}),s.setElementaryStreamInfo(H$,p,g,y,b),this.bufferFragmentData(c,s,u,r)}if(null!=m&&null!=(t=m.samples)&&t.length){var w=P$({id:n,frag:s,details:d},m);i.trigger(m$.FRAG_PARSING_METADATA,w)}if(h){var k=P$({id:n,frag:s,details:d},h);i.trigger(m$.FRAG_PARSING_USERDATA,k)}}else this.fragmentTracker.removeFragment(s)}else this.resetWhenMissingContext(r)}},{key:"_bufferInitSegment",value:function(e,t,n,i){if(this.state===DB&&(t.video&&delete t.video,t.audiovideo&&delete t.audiovideo,t.audio)){var a=t.audio;a.id=b$;var r=e.audioCodec;this.log(`Init audio buffer, container:${a.container}, codecs[level/parsed]=[${r}/${a.codec}]`),r&&1===r.split(",").length&&(a.levelCodec=r),this.hls.trigger(m$.BUFFER_CODECS,t);var o=a.initSegment;if(null!=o&&o.byteLength){var s={type:"audio",frag:n,part:null,chunkMeta:i,parent:n.type,data:o};this.hls.trigger(m$.BUFFER_APPENDING,s)}this.tickImmediate()}}},{key:"loadFragment",value:function(e,n,i){var a,r=this.fragmentTracker.getState(e);if(this.switchingTrack||r===FW||r===$W)if(X$(e))if(null!=(a=n.details)&&a.live&&!this.initPTS[e.cc]){this.log(`Waiting for video PTS in continuity counter ${e.cc} of live stream before loading audio fragment ${e.sn} of level ${this.trackId}`),this.state=LB;var o=this.mainDetails;o&&o.fragmentStart!==n.details.fragmentStart&&bB(n.details,o)}else T(t,"loadFragment",this)([e,n,i]);else this._loadInitSegment(e,n);else this.clearTrackerIfNeeded(e)}},{key:"flushAudioIfNeeded",value:function(e){if(this.media&&this.bufferedTrack){var n=this.bufferedTrack;sW({name:n.name,lang:n.lang,assocLang:n.assocLang,characteristics:n.characteristics,audioCodec:n.audioCodec,channels:n.channels},e,uW)||(dW(e.url,this.hls)?(this.log("Switching audio track : flushing all audio"),T(t,"flushMainBuffer",this)([0,Number.POSITIVE_INFINITY,"audio"]),this.bufferedTrack=null):this.bufferedTrack=e)}}},{key:"completeAudioSwitch",value:function(e){var t=this.hls;this.flushAudioIfNeeded(e),this.bufferedTrack=e,this.switchingTrack=null,t.trigger(m$.AUDIO_TRACK_SWITCHED,_$({},e))}}])}(FB),yU=function(e){function t(e,n){var i;return o(this,t),(i=r(this,t,[n,e.logger])).hls=void 0,i.canLoad=!1,i.timer=-1,i.hls=e,i}return p(t,e),c(t,[{key:"destroy",value:function(){this.clearTimer(),this.hls=this.log=this.warn=null}},{key:"clearTimer",value:function(){-1!==this.timer&&(self.clearTimeout(this.timer),this.timer=-1)}},{key:"startLoad",value:function(){this.canLoad=!0,this.loadPlaylist()}},{key:"stopLoad",value:function(){this.canLoad=!1,this.clearTimer()}},{key:"switchParams",value:function(e,t,n){var i=null==t?void 0:t.renditionReports;if(i){for(var a=-1,r=0;r<i.length;r++){var o=i[r],s=void 0;try{s=new self.URL(o.URI,t.url).href}catch(e){this.warn(`Could not construct new URL for Rendition Report: ${e}`),s=o.URI||""}if(s===e){a=r;break}s===e.substring(0,s.length)&&(a=r)}if(-1!==a){var u=i[a],l=parseInt(u["LAST-MSN"])||t.lastPartSn,d=parseInt(u["LAST-PART"])||t.lastPartIndex;if(this.hls.config.lowLatencyMode){var c=Math.min(t.age-t.partTarget,t.targetduration);d>=0&&c>t.partTarget&&(d+=1)}var h=n&&JN(n);return new QN(l,d>=0?d:void 0,h)}}}},{key:"loadPlaylist",value:function(e){this.clearTimer()}},{key:"loadingPlaylist",value:function(e,t){this.clearTimer()}},{key:"shouldLoadPlaylist",value:function(e){return this.canLoad&&!!e&&!!e.url&&(!e.details||e.details.live)}},{key:"getUrlWithDirectives",value:function(e,t){if(t)try{return t.addDirectives(e)}catch(e){this.warn(`Could not construct new URL with HLS Delivery Directives: ${e}`)}return e}},{key:"playlistLoaded",value:function(e,t,n){var i=t.details,a=t.stats,r=self.performance.now(),o=a.loading.first?Math.max(0,r-a.loading.first):0;i.advancedDateTime=Date.now()-o;var s=this.hls.config.timelineOffset;if(s!==i.appliedTimelineOffset){var u=Math.max(s||0,0);i.appliedTimelineOffset=u,i.fragments.forEach(e=>{e.setStart(e.playlistOffset+u)})}if(i.live||null!=n&&n.live){var l="levelInfo"in t?t.levelInfo:t.track;if(i.reloaded(n),n&&i.fragments.length>0){aB(n,i,this);var d=i.playlistParsingError;if(d){this.warn(d);var c=this.hls;if(!c.config.ignorePlaylistParsingErrors){var h,m=t.networkDetails;return void c.trigger(m$.ERROR,{type:c$.NETWORK_ERROR,details:h$.LEVEL_PARSING_ERROR,fatal:!1,url:i.url,error:d,reason:d.message,level:t.level||void 0,parent:null==(h=i.fragments[0])?void 0:h.type,networkDetails:m,stats:a})}i.playlistParsingError=null}}-1===i.requestScheduled&&(i.requestScheduled=a.loading.start);var f,v=this.hls.mainForwardBufferInfo,p=v?v.end-v.len:0,g=uB(i,1e3*(i.edge-p));if(i.requestScheduled+g<r?i.requestScheduled=r:i.requestScheduled+=g,this.log(`live playlist ${e} ${i.advanced?"REFRESHED "+i.lastPartSn+"-"+i.lastPartIndex:i.updated?"UPDATED":"MISSED"}`),!this.canLoad||!i.live)return;var y=void 0,b=void 0;if(i.canBlockReload&&i.endSN&&i.advanced){var w=this.hls.config.lowLatencyMode,k=i.lastPartSn,S=i.endSN,E=i.lastPartIndex,P=k===S;-1!==E?P?(y=S+1,b=w?0:E):(y=k,b=w?E+1:i.maxPartIndex):y=S+1;var T=i.age,_=T+i.ageHeader,M=Math.min(_-i.partTarget,1.5*i.targetduration);if(M>0){if(_>3*i.targetduration)this.log(`Playlist last advanced ${T.toFixed(2)}s ago. Omitting segment and part directives.`),y=void 0,b=void 0;else if(null!=n&&n.tuneInGoal&&_-i.partTarget>n.tuneInGoal)this.warn(`CDN Tune-in goal increased from: ${n.tuneInGoal} to: ${M} with playlist age: ${i.age}`),M=0;else{var A=Math.floor(M/i.targetduration);if(y+=A,void 0!==b)b+=Math.round(M%i.targetduration/i.partTarget);this.log(`CDN Tune-in age: ${i.ageHeader}s last advanced ${T.toFixed(2)}s goal: ${M} skip sn ${A} to part ${b}`)}i.tuneInGoal=M}if(f=this.getDeliveryDirectives(i,t.deliveryDirectives,y,b),w||!P)return i.requestScheduled=r,void this.loadingPlaylist(l,f)}else(i.canBlockReload||i.canSkipUntil)&&(f=this.getDeliveryDirectives(i,t.deliveryDirectives,y,b));f&&void 0!==y&&i.canBlockReload&&(i.requestScheduled=a.loading.first+Math.max(g-2*o,g/2)),this.scheduleLoading(l,f,i)}else this.clearTimer()}},{key:"scheduleLoading",value:function(e,t,n){var i=n||e.details;if(i){var a=self.performance.now(),r=i.requestScheduled;if(a>=r)this.loadingPlaylist(e,t);else{var o=r-a;this.log(`reload live playlist ${e.name||e.bitrate+"bps"} in ${Math.round(o)} ms`),this.clearTimer(),this.timer=self.setTimeout(()=>this.loadingPlaylist(e,t),o)}}else this.loadingPlaylist(e,t)}},{key:"getDeliveryDirectives",value:function(e,t,n,i){var a=JN(e);return null!=t&&t.skip&&e.deltaUpdateFailed&&(n=t.msn,i=t.part,a=XN),new QN(n,i,a)}},{key:"checkRetry",value:function(e){var t=e.details,n=gW(e),i=e.errorAction,a=i||{},r=a.action,o=a.retryCount,s=void 0===o?0:o,u=a.retryConfig,l=!!i&&!!u&&(r===AW||!i.resolved&&r===_W);if(l){var d;if(s>=u.maxNumRetry)return!1;if(n&&null!=(d=e.context)&&d.deliveryDirectives)this.warn(`Retrying playlist loading ${s+1}/${u.maxNumRetry} after "${t}" without delivery-directives`),this.loadPlaylist();else{var c=kW(u,s);this.clearTimer(),this.timer=self.setTimeout(()=>this.loadPlaylist(),c),this.warn(`Retrying playlist loading ${s+1}/${u.maxNumRetry} after "${t}" in ${c}ms`)}e.levelRetry=!0,i.resolved=!0}return l}}])}(M$);function bU(e,t){if(e.length!==t.length)return!1;for(var n=0;n<e.length;n++)if(!wU(e[n].attrs,t[n].attrs))return!1;return!0}function wU(e,t,n){var i=e["STABLE-RENDITION-ID"];return i&&!n?i===t["STABLE-RENDITION-ID"]:!(n||["LANGUAGE","NAME","CHARACTERISTICS","AUTOSELECT","DEFAULT","FORCED","ASSOC-LANGUAGE"]).some(n=>e[n]!==t[n])}function kU(e,t){return t.label.toLowerCase()===e.name.toLowerCase()&&(!t.language||t.language.toLowerCase()===(e.lang||"").toLowerCase())}var SU=function(e){function t(e){var n;return o(this,t),(n=r(this,t,[e,"audio-track-controller"])).tracks=[],n.groupIds=null,n.tracksInGroup=[],n.trackId=-1,n.currentTrack=null,n.selectDefaultTrack=!0,n.registerListeners(),n}return p(t,e),c(t,[{key:"registerListeners",value:function(){var e=this.hls;e.on(m$.MANIFEST_LOADING,this.onManifestLoading,this),e.on(m$.MANIFEST_PARSED,this.onManifestParsed,this),e.on(m$.LEVEL_LOADING,this.onLevelLoading,this),e.on(m$.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(m$.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(m$.ERROR,this.onError,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e.off(m$.MANIFEST_LOADING,this.onManifestLoading,this),e.off(m$.MANIFEST_PARSED,this.onManifestParsed,this),e.off(m$.LEVEL_LOADING,this.onLevelLoading,this),e.off(m$.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(m$.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(m$.ERROR,this.onError,this)}},{key:"destroy",value:function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,T(t,"destroy",this)([])}},{key:"onManifestLoading",value:function(){this.tracks=[],this.tracksInGroup=[],this.groupIds=null,this.currentTrack=null,this.trackId=-1,this.selectDefaultTrack=!0}},{key:"onManifestParsed",value:function(e,t){this.tracks=t.audioTracks||[]}},{key:"onAudioTrackLoaded",value:function(e,t){var n=t.id,i=t.groupId,a=t.details,r=this.tracksInGroup[n];if(r&&r.groupId===i){var o=r.details;r.details=t.details,this.log(`Audio track ${n} "${r.name}" lang:${r.lang} group:${i} loaded [${a.startSN}-${a.endSN}]`),n===this.trackId&&this.playlistLoaded(n,t,o)}else this.warn(`Audio track with id:${n} and group:${i} not found in active group ${null==r?void 0:r.groupId}`)}},{key:"onLevelLoading",value:function(e,t){this.switchLevel(t.level)}},{key:"onLevelSwitching",value:function(e,t){this.switchLevel(t.level)}},{key:"switchLevel",value:function(e){var t=this.hls.levels[e];if(t){var n=t.audioGroups||null,i=this.groupIds,a=this.currentTrack;if(!n||(null==i?void 0:i.length)!==(null==n?void 0:n.length)||null!=n&&n.some(e=>-1===(null==i?void 0:i.indexOf(e)))){this.groupIds=n,this.trackId=-1,this.currentTrack=null;var r=this.tracks.filter(e=>!n||-1!==n.indexOf(e.groupId));if(r.length)this.selectDefaultTrack&&!r.some(e=>e.default)&&(this.selectDefaultTrack=!1),r.forEach((e,t)=>{e.id=t});else if(!a&&!this.tracksInGroup.length)return;this.tracksInGroup=r;var o=this.hls.config.audioPreference;if(!a&&o){var s=oW(o,r,uW);if(s>-1)a=r[s];else{var u=oW(o,this.tracks);a=this.tracks[u]}}var l=this.findTrackId(a);-1===l&&a&&(l=this.findTrackId(null));var d={audioTracks:r};this.log(`Updating audio tracks, ${r.length} track(s) found in group(s): ${null==n?void 0:n.join(",")}`),this.hls.trigger(m$.AUDIO_TRACKS_UPDATED,d);var c=this.trackId;if(-1!==l&&-1===c)this.setAudioTrack(l);else if(r.length&&-1===c){var h,m=new Error(`No audio track selected for current audio group-ID(s): ${null==(h=this.groupIds)?void 0:h.join(",")} track count: ${r.length}`);this.warn(m.message),this.hls.trigger(m$.ERROR,{type:c$.MEDIA_ERROR,details:h$.AUDIO_TRACK_LOAD_ERROR,fatal:!0,error:m})}}}}},{key:"onError",value:function(e,t){!t.fatal&&t.context&&(t.context.type!==p$||t.context.id!==this.trackId||this.groupIds&&-1===this.groupIds.indexOf(t.context.groupId)||this.checkRetry(t))}},{key:"allAudioTracks",get:function(){return this.tracks}},{key:"audioTracks",get:function(){return this.tracksInGroup}},{key:"audioTrack",get:function(){return this.trackId},set:function(e){this.selectDefaultTrack=!1,this.setAudioTrack(e)}},{key:"setAudioOption",value:function(e){var t=this.hls;if(t.config.audioPreference=e,e){var n=this.allAudioTracks;if(this.selectDefaultTrack=!1,n.length){var i=this.currentTrack;if(i&&sW(e,i,uW))return i;var a=oW(e,this.tracksInGroup,uW);if(a>-1){var r=this.tracksInGroup[a];return this.setAudioTrack(a),r}if(i){var o=t.loadLevel;-1===o&&(o=t.firstAutoLevel);var s=function(e,t,n,i,a){var r=t[i],o=t.reduce((e,t,n)=>{var i=t.uri;return(e[i]||(e[i]=[])).push(n),e},{})[r.uri];o.length>1&&(i=Math.max.apply(Math,o));var s=r.videoRange,u=r.frameRate,l=r.codecSet.substring(0,4),d=lW(t,i,t=>{if(t.videoRange!==s||t.frameRate!==u||t.codecSet.substring(0,4)!==l)return!1;var i=t.audioGroups,r=n.filter(e=>!i||-1!==i.indexOf(e.groupId));return oW(e,r,a)>-1});return d>-1?d:lW(t,i,t=>{var i=t.audioGroups,r=n.filter(e=>!i||-1!==i.indexOf(e.groupId));return oW(e,r,a)>-1})}(e,t.levels,n,o,uW);if(-1===s)return null;t.nextLoadLevel=s}if(e.channels||e.audioCodec){var u=oW(e,n);if(u>-1)return n[u]}}}return null}},{key:"setAudioTrack",value:function(e){var t=this.tracksInGroup;if(e<0||e>=t.length)this.warn(`Invalid audio track id: ${e}`);else{this.selectDefaultTrack=!1;var n=this.currentTrack,i=t[e],a=i.details&&!i.details.live;if(!(e===this.trackId&&i===n&&a||(this.log(`Switching to audio-track ${e} "${i.name}" lang:${i.lang} group:${i.groupId} channels:${i.channels}`),this.trackId=e,this.currentTrack=i,this.hls.trigger(m$.AUDIO_TRACK_SWITCHING,_$({},i)),a))){var r=this.switchParams(i.url,null==n?void 0:n.details,i.details);this.loadPlaylist(r)}}}},{key:"findTrackId",value:function(e){for(var t=this.tracksInGroup,n=0;n<t.length;n++){var i=t[n];if((!this.selectDefaultTrack||i.default)&&(!e||sW(e,i,uW)))return n}if(e){for(var a=e.name,r=e.lang,o=e.assocLang,s=e.characteristics,u=e.audioCodec,l=e.channels,d=0;d<t.length;d++){if(sW({name:a,lang:r,assocLang:o,characteristics:s,audioCodec:u,channels:l},t[d],uW))return d}for(var c=0;c<t.length;c++){var h=t[c];if(wU(e.attrs,h.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return c}for(var m=0;m<t.length;m++){var f=t[m];if(wU(e.attrs,f.attrs,["LANGUAGE"]))return m}}return-1}},{key:"loadPlaylist",value:function(e){T(t,"loadPlaylist",this)([]);var n=this.currentTrack;this.shouldLoadPlaylist(n)&&dW(n.url,this.hls)&&this.scheduleLoading(n,e)}},{key:"loadingPlaylist",value:function(e,n){T(t,"loadingPlaylist",this)([e,n]);var i=e.id,a=e.groupId,r=this.getUrlWithDirectives(e.url,n),o=e.details,s=null==o?void 0:o.age;this.log(`Loading audio-track ${i} "${e.name}" lang:${e.lang} group:${a}${void 0!==(null==n?void 0:n.msn)?" at sn "+n.msn+" part "+n.part:""}${s&&o.live?" age "+s.toFixed(1)+(o.type&&" "+o.type||""):""} ${r}`),this.hls.trigger(m$.AUDIO_TRACK_LOADING,{url:r,id:i,groupId:a,deliveryDirectives:n||null,track:e})}}])}(yU),EU=function(){return c(function e(t){o(this,e),this.tracks=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.tracks=t},[{key:"destroy",value:function(){this.tracks=this.queues=null}},{key:"append",value:function(e,t,n){if(null!==this.queues&&null!==this.tracks){var i=this.queues[t];i.push(e),1!==i.length||n||this.executeNext(t)}}},{key:"appendBlocker",value:function(e){return new Promise(t=>{var n={label:"async-blocker",execute:t,onStart:()=>{},onComplete:()=>{},onError:()=>{}};this.append(n,e)})}},{key:"prependBlocker",value:function(e){return new Promise(t=>{if(this.queues){var n={label:"async-blocker-prepend",execute:t,onStart:()=>{},onComplete:()=>{},onError:()=>{}};this.queues[e].unshift(n)}})}},{key:"removeBlockers",value:function(){null!==this.queues&&[this.queues.video,this.queues.audio,this.queues.audiovideo].forEach(e=>{var t,n=null==(t=e[0])?void 0:t.label;"async-blocker"!==n&&"async-blocker-prepend"!==n||(e[0].execute(),e.splice(0,1))})}},{key:"unblockAudio",value:function(e){null!==this.queues&&(this.queues.audio[0]===e&&this.shiftAndExecuteNext("audio"))}},{key:"executeNext",value:function(e){if(null!==this.queues&&null!==this.tracks){var t=this.queues[e];if(t.length){var n=t[0];try{n.execute()}catch(t){var i;if(n.onError(t),null===this.queues||null===this.tracks)return;var a=null==(i=this.tracks[e])?void 0:i.buffer;null!=a&&a.updating||this.shiftAndExecuteNext(e)}}}}},{key:"shiftAndExecuteNext",value:function(e){null!==this.queues&&(this.queues[e].shift(),this.executeNext(e))}},{key:"current",value:function(e){var t;return(null==(t=this.queues)?void 0:t[e][0])||null}},{key:"toString",value:function(){var e=this.queues,t=this.tracks;return null===e||null===t?"<destroyed>":`\n${this.list("video")}\n${this.list("audio")}\n${this.list("audiovideo")}}`}},{key:"list",value:function(e){var t,n;return null!=(t=this.queues)&&t[e]||null!=(n=this.tracks)&&n[e]?`${e}: (${this.listSbInfo(e)}) ${this.listOps(e)}`:""}},{key:"listSbInfo",value:function(e){var t,n=null==(t=this.tracks)?void 0:t[e],i=null==n?void 0:n.buffer;return i?`SourceBuffer${i.updating?" updating":""}${n.ended?" ended":""}${n.ending?" ending":""}`:"none"}},{key:"listOps",value:function(e){var t;return(null==(t=this.queues)?void 0:t[e].map(e=>e.label).join(", "))||""}}])}(),PU=/(avc[1234]|hvc1|hev1|dvh[1e]|vp09|av01)(?:\.[^.,]+)+/,TU="HlsJsTrackRemovedError",_U=function(e){function t(e){var n;return o(this,t),(n=r(this,t,[e])).name=TU,n}return p(t,e),c(t)}(M(Error)),MU=function(e){function t(e,n){var i,a;return o(this,t),(i=r(this,t,["buffer-controller",e.logger])).hls=void 0,i.fragmentTracker=void 0,i.details=null,i._objectUrl=null,i.operationQueue=null,i.bufferCodecEventsTotal=0,i.media=null,i.mediaSource=null,i.lastMpegAudioChunk=null,i.blockedAudioAppend=null,i.lastVideoAppendEnd=0,i.appendSource=void 0,i.transferData=void 0,i.overrides=void 0,i.appendErrors={audio:0,video:0,audiovideo:0},i.tracks={},i.sourceBuffers=[[null,null],[null,null]],i._onEndStreaming=e=>{var t;i.hls&&"open"===(null==(t=i.mediaSource)?void 0:t.readyState)&&i.hls.pauseBuffering()},i._onStartStreaming=e=>{i.hls&&i.hls.resumeBuffering()},i._onMediaSourceOpen=e=>{var t=i,n=t.media,a=t.mediaSource;e&&i.log("Media source opened"),n&&a&&(a.removeEventListener("sourceopen",i._onMediaSourceOpen),n.removeEventListener("emptied",i._onMediaEmptied),i.updateDuration(),i.hls.trigger(m$.MEDIA_ATTACHED,{media:n,mediaSource:a}),null!==i.mediaSource&&i.checkPendingTracks())},i._onMediaSourceClose=()=>{i.log("Media source closed")},i._onMediaSourceEnded=()=>{i.log("Media source ended")},i._onMediaEmptied=()=>{var e=i,t=e.mediaSrc,n=e._objectUrl;t!==n&&i.error(`Media element src was set while attaching MediaSource (${n} > ${t})`)},i.hls=e,i.fragmentTracker=n,i.appendSource=(a=R$(e.config.preferManagedMediaSource),"undefined"!=typeof self&&a===self.ManagedMediaSource),i.initTracks(),i.registerListeners(),i}return p(t,e),c(t,[{key:"hasSourceTypes",value:function(){return Object.keys(this.tracks).length>0}},{key:"destroy",value:function(){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}},{key:"registerListeners",value:function(){var e=this.hls;e.on(m$.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(m$.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(m$.MANIFEST_LOADING,this.onManifestLoading,this),e.on(m$.MANIFEST_PARSED,this.onManifestParsed,this),e.on(m$.BUFFER_RESET,this.onBufferReset,this),e.on(m$.BUFFER_APPENDING,this.onBufferAppending,this),e.on(m$.BUFFER_CODECS,this.onBufferCodecs,this),e.on(m$.BUFFER_EOS,this.onBufferEos,this),e.on(m$.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(m$.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(m$.FRAG_PARSED,this.onFragParsed,this),e.on(m$.FRAG_CHANGED,this.onFragChanged,this),e.on(m$.ERROR,this.onError,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e.off(m$.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(m$.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(m$.MANIFEST_LOADING,this.onManifestLoading,this),e.off(m$.MANIFEST_PARSED,this.onManifestParsed,this),e.off(m$.BUFFER_RESET,this.onBufferReset,this),e.off(m$.BUFFER_APPENDING,this.onBufferAppending,this),e.off(m$.BUFFER_CODECS,this.onBufferCodecs,this),e.off(m$.BUFFER_EOS,this.onBufferEos,this),e.off(m$.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(m$.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(m$.FRAG_PARSED,this.onFragParsed,this),e.off(m$.FRAG_CHANGED,this.onFragChanged,this),e.off(m$.ERROR,this.onError,this)}},{key:"transferMedia",value:function(){var e=this.media,t=this.mediaSource;if(!e)return null;var n={};if(this.operationQueue){var i=this.isUpdating();i||this.operationQueue.removeBlockers();var a=this.isQueued();(i||a)&&this.warn(`Transfering MediaSource with${a?" operations in queue":""}${i?" updating SourceBuffer(s)":""} ${this.operationQueue}`),this.operationQueue.destroy()}var r=this.transferData;return!this.sourceBufferCount&&r&&r.mediaSource===t?P$(n,r.tracks):this.sourceBuffers.forEach(e=>{var t=e[0];t&&(n[t]=P$({},this.tracks[t]),this.removeBuffer(t)),e[0]=e[1]=null}),{media:e,mediaSource:t,tracks:n}}},{key:"initTracks",value:function(){this.sourceBuffers=[[null,null],[null,null]],this.tracks={},this.resetQueue(),this.resetAppendErrors(),this.lastMpegAudioChunk=this.blockedAudioAppend=null,this.lastVideoAppendEnd=0}},{key:"onManifestLoading",value:function(){this.bufferCodecEventsTotal=0,this.details=null}},{key:"onManifestParsed",value:function(e,t){var n,i=2;(t.audio&&!t.video||!t.altAudio)&&(i=1),this.bufferCodecEventsTotal=i,this.log(`${i} bufferCodec event(s) expected.`),null!=(n=this.transferData)&&n.mediaSource&&this.sourceBufferCount&&i&&this.bufferCreated()}},{key:"onMediaAttaching",value:function(e,t){var n=this.media=t.media;this.transferData=this.overrides=void 0;var i=R$(this.appendSource);if(i){var a=!!t.mediaSource;(a||t.overrides)&&(this.transferData=t,this.overrides=t.overrides);var r=this.mediaSource=t.mediaSource||new i;if(this.assignMediaSource(r),a)this._objectUrl=n.src,this.attachTransferred();else{var o=this._objectUrl=self.URL.createObjectURL(r);if(this.appendSource)try{n.removeAttribute("src");var s=self.ManagedMediaSource;n.disableRemotePlayback=n.disableRemotePlayback||s&&r instanceof s,AU(n),function(e,t){var n=self.document.createElement("source");n.type="video/mp4",n.src=t,e.appendChild(n)}(n,o),n.load()}catch(e){n.src=o}else n.src=o}n.addEventListener("emptied",this._onMediaEmptied)}}},{key:"assignMediaSource",value:function(e){var t,n;this.log(`${(null==(t=this.transferData)?void 0:t.mediaSource)===e?"transferred":"created"} media source: ${null==(n=e.constructor)?void 0:n.name}`),e.addEventListener("sourceopen",this._onMediaSourceOpen),e.addEventListener("sourceended",this._onMediaSourceEnded),e.addEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(e.addEventListener("startstreaming",this._onStartStreaming),e.addEventListener("endstreaming",this._onEndStreaming))}},{key:"attachTransferred",value:function(){var e=this.media,t=this.transferData;if(t&&e){var n=this.tracks,i=t.tracks,a=i?Object.keys(i):null,r=a?a.length:0,o=()=>{Promise.resolve().then(()=>{this.media&&this.mediaSourceOpenOrEnded&&this._onMediaSourceOpen()})};if(i&&a&&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: ${nW(n,(e,t)=>"initSegment"===e?void 0:t)};\ntransfer tracks: ${nW(i,(e,t)=>"initSegment"===e?void 0:t)}}`),!F$(i,n)){t.mediaSource=null,t.tracks=void 0;var s=e.currentTime,u=this.details,l=Math.max(s,(null==u?void 0:u.fragments[0].start)||0);return l-s>1?void this.log(`attachTransferred: waiting for playback to reach new tracks start time ${s} -> ${l}`):(this.warn(`attachTransferred: resetting MediaSource for incompatible tracks ("${Object.keys(i)}"->"${Object.keys(n)}") start time: ${l} currentTime: ${s}`),this.onMediaDetaching(m$.MEDIA_DETACHING,{}),this.onMediaAttaching(m$.MEDIA_ATTACHING,t),void(e.currentTime=l))}this.transferData=void 0,a.forEach(e=>{var t=e,n=i[t];if(n){var a=n.buffer;if(a){var r=this.fragmentTracker,o=n.id;if(r.hasFragments(o)||r.hasParts(o)){var s=ij.getBuffered(a);r.detectEvictedFragments(t,s,o,null,!0)}var u=DU(t),l=[t,a];this.sourceBuffers[u]=l,a.updating&&this.operationQueue&&this.operationQueue.prependBlocker(t),this.trackSourceBuffer(t,n)}}}),o(),this.bufferCreated()}else this.log("attachTransferred: MediaSource w/o SourceBuffers"),o()}}},{key:"mediaSourceOpenOrEnded",get:function(){var e,t=null==(e=this.mediaSource)?void 0:e.readyState;return"open"===t||"ended"===t}},{key:"onMediaDetaching",value:function(e,t){var n=!!t.transferMedia;this.transferData=this.overrides=void 0;var i=this.media,a=this.mediaSource,r=this._objectUrl;if(a){if(this.log("media source "+(n?"transferring":"detaching")),n)this.sourceBuffers.forEach(([e])=>{e&&this.removeBuffer(e)}),this.resetQueue();else{if(this.mediaSourceOpenOrEnded){var o="open"===a.readyState;try{for(var s=a.sourceBuffers,u=s.length;u--;)o&&s[u].abort(),a.removeSourceBuffer(s[u]);o&&a.endOfStream()}catch(e){this.warn(`onMediaDetaching: ${e.message} while calling endOfStream`)}}this.sourceBufferCount&&this.onBufferReset()}a.removeEventListener("sourceopen",this._onMediaSourceOpen),a.removeEventListener("sourceended",this._onMediaSourceEnded),a.removeEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(a.removeEventListener("startstreaming",this._onStartStreaming),a.removeEventListener("endstreaming",this._onEndStreaming)),this.mediaSource=null,this._objectUrl=null}i&&(i.removeEventListener("emptied",this._onMediaEmptied),n||(r&&self.URL.revokeObjectURL(r),this.mediaSrc===r?(i.removeAttribute("src"),this.appendSource&&AU(i),i.load()):this.warn("media|source.src was changed by a third party - skip cleanup")),this.media=null),this.hls.trigger(m$.MEDIA_DETACHED,t)}},{key:"onBufferReset",value:function(){this.sourceBuffers.forEach(([e])=>{e&&this.resetBuffer(e)}),this.initTracks()}},{key:"resetBuffer",value:function(e){var t,n=null==(t=this.tracks[e])?void 0:t.buffer;if(this.removeBuffer(e),n)try{var i;null!=(i=this.mediaSource)&&i.sourceBuffers.length&&this.mediaSource.removeSourceBuffer(n)}catch(t){this.warn(`onBufferReset ${e}`,t)}delete this.tracks[e]}},{key:"removeBuffer",value:function(e){this.removeBufferListeners(e),this.sourceBuffers[DU(e)]=[null,null];var t=this.tracks[e];t&&(t.buffer=void 0)}},{key:"resetQueue",value:function(){this.operationQueue&&this.operationQueue.destroy(),this.operationQueue=new EU(this.tracks)}},{key:"onBufferCodecs",value:function(e,t){var n,i=this.tracks,a=Object.keys(t);this.log(`BUFFER_CODECS: "${a}" (current SB count ${this.sourceBufferCount})`);var r="audiovideo"in t&&(i.audio||i.video)||i.audiovideo&&("audio"in t||"video"in t),o=!r&&this.sourceBufferCount&&this.media&&a.some(e=>!i[e]);r||o?this.warn(`Unsupported transition between "${Object.keys(i)}" and "${a}" SourceBuffers`):(a.forEach(e=>{var n,a,r=t[e],o=r.id,s=r.codec,u=r.levelCodec,l=r.container,d=r.metadata,c=r.supplemental,h=i[e],m=null==(n=this.transferData)||null==(n=n.tracks)?void 0:n[e],f=null!=m&&m.buffer?m:h,v=(null==f?void 0:f.pendingCodec)||(null==f?void 0:f.codec),p=null==f?void 0:f.levelCodec;h||(h=i[e]={buffer:void 0,listeners:[],codec:s,supplemental:c,container:l,levelCodec:u,metadata:d,id:o});var g=FN(v,p),y=null==g?void 0:g.replace(PU,"$1"),b=FN(s,u),w=null==(a=b)?void 0:a.replace(PU,"$1");b&&g&&y!==w&&("audio"===e.slice(0,5)&&(b=RN(b,this.appendSource)),this.log(`switching codec ${v} to ${b}`),b!==(h.pendingCodec||h.codec)&&(h.pendingCodec=b),h.container=l,this.appendChangeType(e,l,b))}),(this.tracksReady||this.sourceBufferCount)&&(t.tracks=this.sourceBufferTracks),this.sourceBufferCount||(this.bufferCodecEventsTotal>1&&!this.tracks.video&&!t.video&&"main"===(null==(n=t.audio)?void 0:n.id)&&(this.log("Main audio-only"),this.bufferCodecEventsTotal=1),this.mediaSourceOpenOrEnded&&this.checkPendingTracks()))}},{key:"sourceBufferTracks",get:function(){return Object.keys(this.tracks).reduce((e,t)=>{var n=this.tracks[t];return e[t]={id:n.id,container:n.container,codec:n.codec,levelCodec:n.levelCodec},e},{})}},{key:"appendChangeType",value:function(e,t,n){var i=`${t};codecs=${n}`,a={label:`change-type=${i}`,execute:()=>{var a=this.tracks[e];if(a){var r=a.buffer;null!=r&&r.changeType&&(this.log(`changing ${e} sourceBuffer type to ${i}`),r.changeType(i),a.codec=n,a.container=t)}this.shiftAndExecuteNext(e)},onStart:()=>{},onComplete:()=>{},onError:t=>{this.warn(`Failed to change ${e} SourceBuffer type`,t)}};this.append(a,e,this.isPending(this.tracks[e]))}},{key:"blockAudio",value:function(e){var t,n=e.start,i=n+.05*e.duration;if(!(!0===(null==(t=this.fragmentTracker.getAppendedFrag(n,y$))?void 0:t.gap))){var a={label:"block-audio",execute:()=>{var e,t=this.tracks.video;(this.lastVideoAppendEnd>i||null!=t&&t.buffer&&ij.isBuffered(t.buffer,i)||!0===(null==(e=this.fragmentTracker.getAppendedFrag(i,y$))?void 0:e.gap))&&(this.blockedAudioAppend=null,this.shiftAndExecuteNext("audio"))},onStart:()=>{},onComplete:()=>{},onError:e=>{this.warn("Error executing block-audio operation",e)}};this.blockedAudioAppend={op:a,frag:e},this.append(a,"audio",!0)}}},{key:"unblockAudio",value:function(){var e=this.blockedAudioAppend,t=this.operationQueue;e&&t&&(this.blockedAudioAppend=null,t.unblockAudio(e.op))}},{key:"onBufferAppending",value:function(e,t){var n=this.tracks,i=t.data,a=t.type,r=t.parent,o=t.frag,s=t.part,u=t.chunkMeta,l=t.offset,d=u.buffering[a],c=o.sn,h=o.cc,m=self.performance.now();d.start=m;var f=o.stats.buffering,v=s?s.stats.buffering:null;0===f.start&&(f.start=m),v&&0===v.start&&(v.start=m);var p=n.audio,g=!1;"audio"===a&&"audio/mpeg"===(null==p?void 0:p.container)&&(g=!this.lastMpegAudioChunk||1===u.id||this.lastMpegAudioChunk.sn!==u.sn,this.lastMpegAudioChunk=u);var y=n.video,b=null==y?void 0:y.buffer;if(b&&"initSegment"!==c){var w=s||o,k=this.blockedAudioAppend;if("audio"!==a||"main"===r||this.blockedAudioAppend||y.ending||y.ended){if("video"===a){var S=w.end;if(k){var E=k.frag.start;(S>E||S<this.lastVideoAppendEnd||ij.isBuffered(b,E))&&this.unblockAudio()}this.lastVideoAppendEnd=S}}else{var P=w.start+.05*w.duration,T=b.buffered,_=this.currentOp("video");T.length||_?!_&&!ij.isBuffered(b,P)&&this.lastVideoAppendEnd<P&&this.blockAudio(w):this.blockAudio(w)}}var M=(s||o).start,A={label:`append-${a}`,execute:()=>{var e;d.executeStart=self.performance.now();var t=null==(e=this.tracks[a])?void 0:e.buffer;t&&(g?this.updateTimestampOffset(t,M,.1,a,c,h):void 0!==l&&u$(l)&&this.updateTimestampOffset(t,l,1e-6,a,c,h)),this.appendExecutor(i,a)},onStart:()=>{},onComplete:()=>{var e=self.performance.now();d.executeEnd=d.end=e,0===f.first&&(f.first=e),v&&0===v.first&&(v.first=e);var t={};this.sourceBuffers.forEach(([e,n])=>{e&&(t[e]=ij.getBuffered(n))}),this.appendErrors[a]=0,"audio"===a||"video"===a?this.appendErrors.audiovideo=0:(this.appendErrors.audio=0,this.appendErrors.video=0),this.hls.trigger(m$.BUFFER_APPENDED,{type:a,frag:o,part:s,chunkMeta:u,parent:o.type,timeRanges:t})},onError:e=>{var t,n={type:c$.MEDIA_ERROR,parent:o.type,details:h$.BUFFER_APPEND_ERROR,sourceBufferName:a,frag:o,part:s,chunkMeta:u,error:e,err:e,fatal:!1},i=null==(t=this.media)?void 0:t.error;if(e.code===DOMException.QUOTA_EXCEEDED_ERR||"QuotaExceededError"==e.name||"quota"in e)n.details=h$.BUFFER_FULL_ERROR;else if(e.code===DOMException.INVALID_STATE_ERR&&this.mediaSourceOpenOrEnded&&!i)n.errorAction=RW(!0);else if(e.name===TU&&0===this.sourceBufferCount)n.errorAction=RW(!0);else{var r=++this.appendErrors[a];this.warn(`Failed ${r}/${this.hls.config.appendErrorMaxRetry} times to append segment in "${a}" sourceBuffer (${i||"no media error"})`),(r>=this.hls.config.appendErrorMaxRetry||i)&&(n.fatal=!0)}this.hls.trigger(m$.ERROR,n)}};this.log(`queuing "${a}" append sn: ${c}${s?" p: "+s.index:""} of ${o.type===y$?"level":"track"} ${o.level} cc: ${h}`),this.append(A,a,this.isPending(this.tracks[a]))}},{key:"getFlushOp",value:function(e,t,n){return this.log(`queuing "${e}" remove ${t}-${n}`),{label:"remove",execute:()=>{this.removeExecutor(e,t,n)},onStart:()=>{},onComplete:()=>{this.hls.trigger(m$.BUFFER_FLUSHED,{type:e})},onError:i=>{this.warn(`Failed to remove ${t}-${n} from "${e}" SourceBuffer`,i)}}}},{key:"onBufferFlushing",value:function(e,t){var n=t.type,i=t.startOffset,a=t.endOffset;n?this.append(this.getFlushOp(n,i,a),n):this.sourceBuffers.forEach(([e])=>{e&&this.append(this.getFlushOp(e,i,a),e)})}},{key:"onFragParsed",value:function(e,t){var n=t.frag,i=t.part,a=[],r=i?i.elementaryStreams:n.elementaryStreams;r[V$]?a.push("audiovideo"):(r[H$]&&a.push("audio"),r[G$]&&a.push("video"));0===a.length&&this.warn(`Fragments must have at least one ElementaryStreamType set. type: ${n.type} level: ${n.level} sn: ${n.sn}`),this.blockBuffers(()=>{var e=self.performance.now();n.stats.buffering.end=e,i&&(i.stats.buffering.end=e);var t=i?i.stats:n.stats;this.hls.trigger(m$.FRAG_BUFFERED,{frag:n,part:i,stats:t,id:n.type})},a).catch(e=>{this.warn(`Fragment buffered callback ${e}`),this.stepOperationQueue(this.sourceBufferTypes)})}},{key:"onFragChanged",value:function(e,t){this.trimBuffers()}},{key:"bufferedToEnd",get:function(){return this.sourceBufferCount>0&&!this.sourceBuffers.some(([e])=>{if(e){var t=this.tracks[e];if(t)return!t.ended||t.ending}return!1})}},{key:"onBufferEos",value:function(e,t){var n;this.sourceBuffers.forEach(([e])=>{if(e){var n=this.tracks[e];t.type&&t.type!==e||(n.ending=!0,n.ended||(n.ended=!0,this.log(`${e} buffer reached EOS`)))}});var i=!1!==(null==(n=this.overrides)?void 0:n.endOfStream);this.sourceBufferCount>0&&!this.sourceBuffers.some(([e])=>{var t;return e&&!(null!=(t=this.tracks[e])&&t.ended)})?i?(this.log("Queueing EOS"),this.blockUntilOpen(()=>{this.tracksEnded();var e=this.mediaSource;e&&"open"===e.readyState?(this.log("Calling mediaSource.endOfStream()"),e.endOfStream(),this.hls.trigger(m$.BUFFERED_TO_END,void 0)):e&&this.log(`Could not call mediaSource.endOfStream(). mediaSource.readyState: ${e.readyState}`)})):(this.tracksEnded(),this.hls.trigger(m$.BUFFERED_TO_END,void 0)):"video"===t.type&&this.unblockAudio()}},{key:"tracksEnded",value:function(){this.sourceBuffers.forEach(([e])=>{if(null!==e){var t=this.tracks[e];t&&(t.ending=!1)}})}},{key:"onLevelUpdated",value:function(e,{details:t}){t.fragments.length&&(this.details=t,this.updateDuration())}},{key:"updateDuration",value:function(){this.blockUntilOpen(()=>{var e=this.getDurationAndRange();e&&this.updateMediaSource(e)})}},{key:"onError",value:function(e,t){if(t.details===h$.BUFFER_APPEND_ERROR&&t.frag){var n,i=null==(n=t.errorAction)?void 0:n.nextAutoLevel;u$(i)&&i!==t.frag.level&&this.resetAppendErrors()}}},{key:"resetAppendErrors",value:function(){this.appendErrors={audio:0,video:0,audiovideo:0}}},{key:"trimBuffers",value:function(){var e=this.hls,t=this.details,n=this.media;if(n&&null!==t&&this.sourceBufferCount){var i=e.config,a=n.currentTime,r=t.levelTargetDuration,o=t.live&&null!==i.liveBackBufferLength?i.liveBackBufferLength:i.backBufferLength;if(u$(o)&&o>=0){var s=Math.max(o,r),u=Math.floor(a/r)*r-s;this.flushBackBuffer(a,r,u)}var l=i.frontBufferFlushThreshold;if(u$(l)&&l>0){var d=Math.max(i.maxBufferLength,l),c=Math.max(d,r),h=Math.floor(a/r)*r+c;this.flushFrontBuffer(a,r,h)}}}},{key:"flushBackBuffer",value:function(e,t,n){this.sourceBuffers.forEach(([e,t])=>{if(t){var i=ij.getBuffered(t);if(i.length>0&&n>i.start(0)){var a;this.hls.trigger(m$.BACK_BUFFER_REACHED,{bufferEnd:n});var r=this.tracks[e];if(null!=(a=this.details)&&a.live)this.hls.trigger(m$.LIVE_BACK_BUFFER_REACHED,{bufferEnd:n});else if(null!=r&&r.ended)return void this.log(`Cannot flush ${e} back buffer while SourceBuffer is in ended state`);this.hls.trigger(m$.BUFFER_FLUSHING,{startOffset:0,endOffset:n,type:e})}}})}},{key:"flushFrontBuffer",value:function(e,t,n){this.sourceBuffers.forEach(([t,i])=>{if(i){var a=ij.getBuffered(i),r=a.length;if(r<2)return;var o=a.start(r-1),s=a.end(r-1);if(n>o||e>=o&&e<=s)return;this.hls.trigger(m$.BUFFER_FLUSHING,{startOffset:o,endOffset:1/0,type:t})}})}},{key:"getDurationAndRange",value:function(){var e,t=this.details,n=this.mediaSource;if(!t||!this.media||"open"!==(null==n?void 0:n.readyState))return null;var i=t.edge;if(t.live&&this.hls.config.liveDurationInfinity){if(t.fragments.length&&n.setLiveSeekableRange){var a=Math.max(0,t.fragmentStart);return{duration:1/0,start:a,end:Math.max(a,i)}}return{duration:1/0}}var r=null==(e=this.overrides)?void 0:e.duration;if(r)return u$(r)?{duration:r}:null;var o=this.media.duration;return i>(u$(n.duration)?n.duration:0)&&i>o||!u$(o)?{duration:i}:null}},{key:"updateMediaSource",value:function({duration:e,start:t,end:n}){var i=this.mediaSource;this.media&&i&&"open"===i.readyState&&(i.duration!==e&&(u$(e)&&this.log(`Updating MediaSource duration to ${e.toFixed(3)}`),i.duration=e),void 0!==t&&void 0!==n&&(this.log(`MediaSource duration is set to ${i.duration}. Setting seekable range to ${t}-${n}.`),i.setLiveSeekableRange(t,n)))}},{key:"tracksReady",get:function(){var e=this.pendingTrackCount;return e>0&&(e>=this.bufferCodecEventsTotal||this.isPending(this.tracks.audiovideo))}},{key:"checkPendingTracks",value:function(){var e=this.bufferCodecEventsTotal,t=this.pendingTrackCount,n=this.tracks;if(this.log(`checkPendingTracks (pending: ${t} codec events expected: ${e}) ${nW(n)}`),this.tracksReady){var i,a=null==(i=this.transferData)?void 0:i.tracks;a&&Object.keys(a).length?this.attachTransferred():this.createSourceBuffers()}}},{key:"bufferCreated",value:function(){if(this.sourceBufferCount){var e={};this.sourceBuffers.forEach(([t,n])=>{if(t){var i=this.tracks[t];e[t]={buffer:n,container:i.container,codec:i.codec,supplemental:i.supplemental,levelCodec:i.levelCodec,id:i.id,metadata:i.metadata}}}),this.hls.trigger(m$.BUFFER_CREATED,{tracks:e}),this.log(`SourceBuffers created. Running queue: ${this.operationQueue}`),this.sourceBuffers.forEach(([e])=>{this.executeNext(e)})}else{var t=new Error("could not create source buffer for media codec(s)");this.hls.trigger(m$.ERROR,{type:c$.MEDIA_ERROR,details:h$.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:t,reason:t.message})}}},{key:"createSourceBuffers",value:function(){var e=this.tracks,t=this.sourceBuffers,n=this.mediaSource;if(!n)throw new Error("createSourceBuffers called when mediaSource was null");for(var i in e){var a=i,r=e[a];if(this.isPending(r)){var o=this.getTrackCodec(r,a),s=`${r.container};codecs=${o}`;r.codec=o,this.log(`creating sourceBuffer(${s})${this.currentOp(a)?" Queued":""} ${nW(r)}`);try{var u=n.addSourceBuffer(s),l=DU(a),d=[a,u];t[l]=d,r.buffer=u}catch(e){var c;return this.error(`error while trying to add sourceBuffer: ${e.message}`),this.shiftAndExecuteNext(a),null==(c=this.operationQueue)||c.removeBlockers(),delete this.tracks[a],void this.hls.trigger(m$.ERROR,{type:c$.MEDIA_ERROR,details:h$.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:e,sourceBufferName:a,mimeType:s,parent:r.id})}this.trackSourceBuffer(a,r)}}this.bufferCreated()}},{key:"getTrackCodec",value:function(e,t){var n=e.supplemental,i=e.codec;n&&("video"===t||"audiovideo"===t)&&MN(n,"video")&&(i=function(e,t){var n=[];if(e)for(var i=e.split(","),a=0;a<i.length;a++)_N(i[a],"video")||n.push(i[a]);return t&&n.push(t),n.join(",")}(i,n));var a=FN(i,e.levelCodec);return a?"audio"===t.slice(0,5)?RN(a,this.appendSource):a:""}},{key:"trackSourceBuffer",value:function(e,t){var n=t.buffer;if(n){var i=this.getTrackCodec(t,e);this.tracks[e]={buffer:n,codec:i,container:t.container,levelCodec:t.levelCodec,supplemental:t.supplemental,metadata:t.metadata,id:t.id,listeners:[]},this.removeBufferListeners(e),this.addBufferListener(e,"updatestart",this.onSBUpdateStart),this.addBufferListener(e,"updateend",this.onSBUpdateEnd),this.addBufferListener(e,"error",this.onSBUpdateError),this.appendSource&&this.addBufferListener(e,"bufferedchange",(e,t)=>{var n=t.removedRanges;null!=n&&n.length&&this.hls.trigger(m$.BUFFER_FLUSHED,{type:e})})}}},{key:"mediaSrc",get:function(){var e,t,n=(null==(e=this.media)||null==(t=e.querySelector)?void 0:t.call(e,"source"))||this.media;return null==n?void 0:n.src}},{key:"onSBUpdateStart",value:function(e){var t=this.currentOp(e);t&&t.onStart()}},{key:"onSBUpdateEnd",value:function(e){var t;if("closed"!==(null==(t=this.mediaSource)?void 0:t.readyState)){var n=this.currentOp(e);n&&(n.onComplete(),this.shiftAndExecuteNext(e))}else this.resetBuffer(e)}},{key:"onSBUpdateError",value:function(e,t){var n,i=new Error(`${e} SourceBuffer error. MediaSource readyState: ${null==(n=this.mediaSource)?void 0:n.readyState}`);this.error(`${i}`,t),this.hls.trigger(m$.ERROR,{type:c$.MEDIA_ERROR,details:h$.BUFFER_APPENDING_ERROR,sourceBufferName:e,error:i,fatal:!1});var a=this.currentOp(e);a&&a.onError(i)}},{key:"updateTimestampOffset",value:function(e,t,n,i,a,r){var o=t-e.timestampOffset;Math.abs(o)>=n&&(this.log(`Updating ${i} SourceBuffer timestampOffset to ${t} (sn: ${a} cc: ${r})`),e.timestampOffset=t)}},{key:"removeExecutor",value:function(e,t,n){var i=this.media,a=this.mediaSource,r=this.tracks[e],o=null==r?void 0:r.buffer;if(!i||!a||!o)return this.warn(`Attempting to remove from the ${e} SourceBuffer, but it does not exist`),void this.shiftAndExecuteNext(e);var s=u$(i.duration)?i.duration:1/0,u=u$(a.duration)?a.duration:1/0,l=Math.max(0,t),d=Math.min(n,s,u);d>l&&(!r.ending||r.ended)?(r.ended=!1,this.log(`Removing [${l},${d}] from the ${e} SourceBuffer`),o.remove(l,d)):this.shiftAndExecuteNext(e)}},{key:"appendExecutor",value:function(e,t){var n=this.tracks[t],i=null==n?void 0:n.buffer;if(!i)throw new _U(`Attempting to append to the ${t} SourceBuffer, but it does not exist`);n.ending=!1,n.ended=!1,i.appendBuffer(e)}},{key:"blockUntilOpen",value:function(e){if(this.isUpdating()||this.isQueued())this.blockBuffers(e).catch(e=>{this.warn(`SourceBuffer blocked callback ${e}`),this.stepOperationQueue(this.sourceBufferTypes)});else try{e()}catch(e){this.warn(`Callback run without blocking ${this.operationQueue} ${e}`)}}},{key:"isUpdating",value:function(){return this.sourceBuffers.some(([e,t])=>e&&t.updating)}},{key:"isQueued",value:function(){return this.sourceBuffers.some(([e])=>e&&!!this.currentOp(e))}},{key:"isPending",value:function(e){return!!e&&!e.buffer}},{key:"blockBuffers",value:function(e,t=this.sourceBufferTypes){if(!t.length)return this.log("Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(e);var n=this.operationQueue,i=t.map(e=>this.appendBlocker(e));return t.length>1&&!!this.blockedAudioAppend&&this.unblockAudio(),Promise.all(i).then(t=>{n===this.operationQueue&&(e(),this.stepOperationQueue(this.sourceBufferTypes))})}},{key:"stepOperationQueue",value:function(e){e.forEach(e=>{var t,n=null==(t=this.tracks[e])?void 0:t.buffer;n&&!n.updating&&this.shiftAndExecuteNext(e)})}},{key:"append",value:function(e,t,n){this.operationQueue&&this.operationQueue.append(e,t,n)}},{key:"appendBlocker",value:function(e){if(this.operationQueue)return this.operationQueue.appendBlocker(e)}},{key:"currentOp",value:function(e){return this.operationQueue?this.operationQueue.current(e):null}},{key:"executeNext",value:function(e){e&&this.operationQueue&&this.operationQueue.executeNext(e)}},{key:"shiftAndExecuteNext",value:function(e){this.operationQueue&&this.operationQueue.shiftAndExecuteNext(e)}},{key:"pendingTrackCount",get:function(){return Object.keys(this.tracks).reduce((e,t)=>e+(this.isPending(this.tracks[t])?1:0),0)}},{key:"sourceBufferCount",get:function(){return this.sourceBuffers.reduce((e,[t])=>e+(t?1:0),0)}},{key:"sourceBufferTypes",get:function(){return this.sourceBuffers.map(([e])=>e).filter(e=>!!e)}},{key:"addBufferListener",value:function(e,t,n){var i=this.tracks[e];if(i){var a=i.buffer;if(a){var r=n.bind(this,e);i.listeners.push({event:t,listener:r}),a.addEventListener(t,r)}}}},{key:"removeBufferListeners",value:function(e){var t=this.tracks[e];if(t){var n=t.buffer;n&&(t.listeners.forEach(e=>{n.removeEventListener(e.event,e.listener)}),t.listeners.length=0)}}}])}(M$);function AU(e){var t=e.querySelectorAll("source");[].slice.call(t).forEach(t=>{e.removeChild(t)})}function DU(e){return"audio"===e?1:0}var xU=function(){function e(t){o(this,e),this.hls=void 0,this.autoLevelCapping=void 0,this.firstLevel=void 0,this.media=void 0,this.restrictedLevels=void 0,this.timer=void 0,this.clientRect=void 0,this.streamController=void 0,this.hls=t,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}return c(e,[{key:"setStreamController",value:function(e){this.streamController=e}},{key:"destroy",value:function(){this.hls&&this.unregisterListener(),this.timer&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null}},{key:"registerListeners",value:function(){var e=this.hls;e.on(m$.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.on(m$.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(m$.MANIFEST_PARSED,this.onManifestParsed,this),e.on(m$.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(m$.BUFFER_CODECS,this.onBufferCodecs,this),e.on(m$.MEDIA_DETACHING,this.onMediaDetaching,this)}},{key:"unregisterListener",value:function(){var e=this.hls;e.off(m$.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.off(m$.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(m$.MANIFEST_PARSED,this.onManifestParsed,this),e.off(m$.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(m$.BUFFER_CODECS,this.onBufferCodecs,this),e.off(m$.MEDIA_DETACHING,this.onMediaDetaching,this)}},{key:"onFpsDropLevelCapping",value:function(e,t){var n=this.hls.levels[t.droppedLevel];this.isLevelAllowed(n)&&this.restrictedLevels.push({bitrate:n.bitrate,height:n.height,width:n.width})}},{key:"onMediaAttaching",value:function(e,t){this.media=t.media instanceof HTMLVideoElement?t.media:null,this.clientRect=null,this.timer&&this.hls.levels.length&&this.detectPlayerSize()}},{key:"onManifestParsed",value:function(e,t){var n=this.hls;this.restrictedLevels=[],this.firstLevel=t.firstLevel,n.config.capLevelToPlayerSize&&t.video&&this.startCapping()}},{key:"onLevelsUpdated",value:function(e,t){this.timer&&u$(this.autoLevelCapping)&&this.detectPlayerSize()}},{key:"onBufferCodecs",value:function(e,t){this.hls.config.capLevelToPlayerSize&&t.video&&this.startCapping()}},{key:"onMediaDetaching",value:function(){this.stopCapping(),this.media=null}},{key:"detectPlayerSize",value:function(){if(this.media){if(this.mediaHeight<=0||this.mediaWidth<=0)return void(this.clientRect=null);var e=this.hls.levels;if(e.length){var t=this.hls,n=this.getMaxLevel(e.length-1);n!==this.autoLevelCapping&&t.logger.log(`Setting autoLevelCapping to ${n}: ${e[n].height}p@${e[n].bitrate} for media ${this.mediaWidth}x${this.mediaHeight}`),t.autoLevelCapping=n,t.autoLevelEnabled&&t.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=t.autoLevelCapping}}}},{key:"getMaxLevel",value:function(t){var n=this.hls.levels;if(!n.length)return-1;var i=n.filter((e,n)=>this.isLevelAllowed(e)&&n<=t);return this.clientRect=null,e.getMaxLevelByMediaSize(i,this.mediaWidth,this.mediaHeight)}},{key:"startCapping",value:function(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())}},{key:"stopCapping",value:function(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)}},{key:"getDimensions",value:function(){if(this.clientRect)return this.clientRect;var e=this.media,t={width:0,height:0};if(e){var n=e.getBoundingClientRect();t.width=n.width,t.height=n.height,t.width||t.height||(t.width=n.right-n.left||e.width||0,t.height=n.bottom-n.top||e.height||0)}return this.clientRect=t,t}},{key:"mediaWidth",get:function(){return this.getDimensions().width*this.contentScaleFactor}},{key:"mediaHeight",get:function(){return this.getDimensions().height*this.contentScaleFactor}},{key:"contentScaleFactor",get:function(){var e=1;if(!this.hls.config.ignoreDevicePixelRatio)try{e=self.devicePixelRatio}catch(e){}return Math.min(e,this.hls.config.maxDevicePixelRatio)}},{key:"isLevelAllowed",value:function(e){return!this.restrictedLevels.some(t=>e.bitrate===t.bitrate&&e.width===t.width&&e.height===t.height)}}],[{key:"getMaxLevelByMediaSize",value:function(e,t,n){if(null==e||!e.length)return-1;for(var i=(e,t)=>!t||(e.width!==t.width||e.height!==t.height),a=e.length-1,r=Math.max(t,n),o=0;o<e.length;o+=1){var s=e[o];if((s.width>=r||s.height>=r)&&i(s,e[o+1])){a=o;break}}return a}}])}(),CU={MANIFEST:"m",AUDIO:"a",VIDEO:"v",MUXED:"av",INIT:"i",CAPTION:"c",TIMED_TEXT:"tt",KEY:"k",OTHER:"o"},IU={HLS:"h"},LU=c(function e(t,n){o(this,e),Array.isArray(t)&&(t=t.map(t=>t instanceof e?t:new e(t))),this.value=t,this.params=n});function RU(e,t,n,i){return new Error(`failed to ${e} "${a=t,Array.isArray(a)?JSON.stringify(a):a instanceof Map?"Map{}":a instanceof Set?"Set{}":"object"==typeof a?JSON.stringify(a):String(a)}" as ${n}`,{cause:i});var a}function FU(e,t,n){return RU("serialize",e,t,n)}var OU=c(function e(t){o(this,e),this.description=t}),$U="Bare Item";function NU(e){if(!1===ArrayBuffer.isView(e))throw FU(e,"Byte Sequence");return`:${t=e,btoa(String.fromCharCode(...t))}:`;var t}function WU(e){if(function(e){return e<-999999999999999||999999999999999<e}(e))throw FU(e,"Integer");return e.toString()}function jU(e,t){if(e<0)return-jU(-e,t);var n=Math.pow(10,t);if(Math.abs(e*n%1-.5)<Number.EPSILON){var i=Math.floor(e*n);return(i%2==0?i:i+1)/n}return Math.round(e*n)/n}function BU(e){var t=jU(e,3);if(Math.floor(Math.abs(t)).toString().length>12)throw FU(e,"Decimal");var n=t.toString();return n.includes(".")?n:`${n}.0`}var zU=/[\x00-\x1f\x7f]+/;function UU(e){var t,n=(t=e).description||t.toString().slice(7,-1);if(!1===/^([a-zA-Z*])([!#$%&'*+\-.^_`|~\w:/]*)$/.test(n))throw FU(n,"Token");return n}function HU(e){switch(typeof e){case"number":if(!u$(e))throw FU(e,$U);return Number.isInteger(e)?WU(e):BU(e);case"string":return function(e){if(zU.test(e))throw FU(e,"String");return`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}(e);case"symbol":return UU(e);case"boolean":return function(e){if("boolean"!=typeof e)throw FU(e,"Boolean");return e?"?1":"?0"}(e);case"object":if(e instanceof Date)return function(e){return`@${WU(e.getTime()/1e3)}`}(e);if(e instanceof Uint8Array)return NU(e);if(e instanceof OU)return UU(e);default:throw FU(e,$U)}}function GU(e){if(!1===/^[a-z*][a-z0-9\-_.*]*$/.test(e))throw FU(e,"Key");return e}function VU(e){return null==e?"":Object.entries(e).map(([e,t])=>!0===t?`;${GU(e)}`:`;${GU(e)}=${HU(t)}`).join("")}function KU(e){return e instanceof LU?`${HU(e.value)}${VU(e.params)}`:HU(e)}function XU(e,t={whitespace:!0}){if("object"!=typeof e||null==e)throw FU(e,"Dict");var n=e instanceof Map?e.entries():Object.entries(e),i=(null==t?void 0:t.whitespace)?" ":"";return Array.from(n).map(([e,t])=>{t instanceof LU==!1&&(t=new LU(t));var n,i=GU(e);return!0===t.value?i+=VU(t.params):(i+="=",Array.isArray(t.value)?i+=`(${(n=t).value.map(KU).join(" ")})${VU(n.params)}`:i+=KU(t)),i}).join(`,${i}`)}function YU(e,t){return XU(e,t)}var qU="CMCD-Object",JU="CMCD-Request",QU="CMCD-Session",ZU="CMCD-Status",eH={br:qU,ab:qU,d:qU,ot:qU,tb:qU,tpb:qU,lb:qU,tab:qU,lab:qU,url:qU,pb:JU,bl:JU,tbl:JU,dl:JU,ltc:JU,mtp:JU,nor:JU,nrr:JU,rc:JU,sn:JU,sta:JU,su:JU,ttfb:JU,ttfbb:JU,ttlb:JU,cmsdd:JU,cmsds:JU,smrt:JU,df:JU,cs:JU,ts:JU,cid:QU,pr:QU,sf:QU,sid:QU,st:QU,v:QU,msd:QU,bs:ZU,bsd:ZU,cdn:ZU,rtp:ZU,bg:ZU,pt:ZU,ec:ZU,e:ZU},tH=JU;function nH(e,t){var n={};if(!e)return n;var i,a=Object.keys(e),r=t?(i=t,Object.keys(i).reduce((e,t)=>{var n;return null===(n=i[t])||void 0===n||n.forEach(n=>e[n]=t),e},{})):{};return a.reduce((t,n)=>{var i,a=eH[n]||r[n]||tH;return(null!==(i=t[a])&&void 0!==i?i:t[a]={})[n]=e[n],t},n)}var iH="event";var aH=e=>Math.round(e),rH=(e,t)=>Array.isArray(e)?e.map(e=>rH(e,t)):e instanceof LU&&"string"==typeof e.value?new LU(rH(e.value,t),e.params):(t.baseUrl&&(e=function(e,t){var n=new URL(e),i=new URL(t);if(n.origin!==i.origin)return e;for(var a=n.pathname.split("/").slice(1),r=i.pathname.split("/").slice(1,-1);a[0]===r[0];)a.shift(),r.shift();for(;r.length;)r.shift(),a.unshift("..");return a.join("/")+n.search+n.hash}(e,t.baseUrl)),1===t.version?encodeURIComponent(e):e),oH=e=>100*aH(e/100),sH={br:aH,d:aH,bl:oH,dl:oH,mtp:oH,nor:(e,t)=>{var n=e;return t.version>=2&&(e instanceof LU&&"string"==typeof e.value?n=new LU([e]):"string"==typeof e&&(n=[e])),rH(n,t)},rtp:oH,tb:aH},uH="request",lH="response",dH=["ab","bg","bl","br","bs","bsd","cdn","cid","cs","df","ec","lab","lb","ltc","msd","mtp","pb","pr","pt","sf","sid","sn","st","sta","tab","tb","tbl","tpb","ts","v"],cH=["e"],hH=/^[a-zA-Z0-9-.]+-[a-zA-Z0-9-.]+$/;function mH(e){return hH.test(e)}var fH=["d","dl","nor","ot","rtp","su"];var vH=["cmsdd","cmsds","rc","smrt","ttfb","ttfbb","ttlb","url"];var pH=["bl","br","bs","cid","d","dl","mtp","nor","nrr","ot","pr","rtp","sf","sid","st","su","tb","v"];function gH(e){return pH.includes(e)||mH(e)}var yH={[lH]:function(e){return dH.includes(e)||fH.includes(e)||vH.includes(e)||mH(e)},[iH]:function(e){return dH.includes(e)||cH.includes(e)||mH(e)},[uH]:function(e){return dH.includes(e)||fH.includes(e)||mH(e)}};function bH(e,t={}){var n={};if(null==e||"object"!=typeof e)return n;var i=t.version||e.v||1,a=t.reportingMode||uH,r=1===i?gH:yH[a],o=Object.keys(e).filter(r),s=t.filter;"function"==typeof s&&(o=o.filter(s));var u=a===lH||a===iH;u&&!o.includes("ts")&&o.push("ts"),i>1&&!o.includes("v")&&o.push("v");var l=P$({},sH,t.formatters),d={version:i,reportingMode:a,baseUrl:t.baseUrl};return o.sort().forEach(t=>{var a=e[t],r=l[t];if("function"==typeof r&&(a=r(a,d)),"v"===t){if(1===i)return;a=i}"pr"==t&&1===a||(u&&"ts"===t&&!u$(a)&&(a=Date.now()),function(e){return"number"==typeof e?u$(e):null!=e&&""!==e&&!1!==e}(a)&&(function(e){return["ot","sf","st","e","sta"].includes(e)}(t)&&"string"==typeof a&&(a=new OU(a)),n[t]=a))}),n}function wH(e,t,n){return P$(e,function(e,t={}){var n={};if(!e)return n;var i=nH(bH(e,t),null==t?void 0:t.customHeaderMap);return Object.entries(i).reduce((e,[t,n])=>{var i=YU(n,{whitespace:!1});return i&&(e[t]=i),e},n)}(t,n))}function kH(e,t={}){if(!e)return"";var n=function(e,t={}){return e?YU(bH(e,t),{whitespace:!1}):""}(e,t);return encodeURIComponent(n)}var SH=/CMCD=[^&#]+/;function EH(e,t,n){var i=function(e,t={}){return e?`CMCD=${kH(e,t)}`:""}(t,n);if(!i)return e;if(SH.test(e))return e.replace(SH,i);var a=e.includes("?")?"&":"?";return`${e}${a}${i}`}var PH=function(){return c(function e(t){o(this,e),this.hls=void 0,this.config=void 0,this.media=void 0,this.sid=void 0,this.cid=void 0,this.useHeaders=!1,this.includeKeys=void 0,this.initialized=!1,this.starved=!1,this.buffering=!0,this.audioBuffer=void 0,this.videoBuffer=void 0,this.onWaiting=()=>{this.initialized&&(this.starved=!0),this.buffering=!0},this.onPlaying=()=>{this.initialized||(this.initialized=!0),this.buffering=!1},this.applyPlaylistData=e=>{try{this.apply(e,{ot:CU.MANIFEST,su:!this.initialized})}catch(e){this.hls.logger.warn("Could not generate manifest CMCD data.",e)}},this.applyFragmentData=e=>{try{var t=e.frag,n=e.part,i=this.hls.levels[t.level],a=this.getObjectType(t),r={d:1e3*(n||t).duration,ot:a};a!==CU.VIDEO&&a!==CU.AUDIO&&a!=CU.MUXED||(r.br=i.bitrate/1e3,r.tb=this.getTopBandwidth(a)/1e3,r.bl=this.getBufferLength(a));var o=n?this.getNextPart(n):this.getNextFrag(t);null!=o&&o.url&&o.url!==t.url&&(r.nor=o.url),this.apply(e,r)}catch(e){this.hls.logger.warn("Could not generate segment CMCD data.",e)}},this.hls=t;var n=this.config=t.config,i=n.cmcd;null!=i&&(n.pLoader=this.createPlaylistLoader(),n.fLoader=this.createFragmentLoader(),this.sid=i.sessionId||t.sessionId,this.cid=i.contentId,this.useHeaders=!0===i.useHeaders,this.includeKeys=i.includeKeys,this.registerListeners())},[{key:"registerListeners",value:function(){var e=this.hls;e.on(m$.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(m$.MEDIA_DETACHED,this.onMediaDetached,this),e.on(m$.BUFFER_CREATED,this.onBufferCreated,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e.off(m$.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(m$.MEDIA_DETACHED,this.onMediaDetached,this),e.off(m$.BUFFER_CREATED,this.onBufferCreated,this)}},{key:"destroy",value:function(){this.unregisterListeners(),this.onMediaDetached(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null,this.onWaiting=this.onPlaying=this.media=null}},{key:"onMediaAttached",value:function(e,t){this.media=t.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)}},{key:"onMediaDetached",value:function(){this.media&&(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null)}},{key:"onBufferCreated",value:function(e,t){var n,i;this.audioBuffer=null==(n=t.tracks.audio)?void 0:n.buffer,this.videoBuffer=null==(i=t.tracks.video)?void 0:i.buffer}},{key:"createData",value:function(){var e;return{v:1,sf:IU.HLS,sid:this.sid,cid:this.cid,pr:null==(e=this.media)?void 0:e.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}}},{key:"apply",value:function(e,t={}){P$(t,this.createData());var n=t.ot===CU.INIT||t.ot===CU.VIDEO||t.ot===CU.MUXED;this.starved&&n&&(t.bs=!0,t.su=!0,this.starved=!1),null==t.su&&(t.su=this.buffering);var i=this.includeKeys;i&&(t=Object.keys(t).reduce((e,n)=>(i.includes(n)&&(e[n]=t[n]),e),{}));var a={baseUrl:e.url};this.useHeaders?(e.headers||(e.headers={}),wH(e.headers,t,a)):e.url=EH(e.url,t,a)}},{key:"getNextFrag",value:function(e){var t,n=null==(t=this.hls.levels[e.level])?void 0:t.details;if(n){var i=e.sn-n.startSN;return n.fragments[i+1]}}},{key:"getNextPart",value:function(e){var t,n=e.index,i=e.fragment,a=null==(t=this.hls.levels[i.level])||null==(t=t.details)?void 0:t.partList;if(a)for(var r=i.sn,o=a.length-1;o>=0;o--){var s=a[o];if(s.index===n&&s.fragment.sn===r)return a[o+1]}}},{key:"getObjectType",value:function(e){var t=e.type;return"subtitle"===t?CU.TIMED_TEXT:"initSegment"===e.sn?CU.INIT:"audio"===t?CU.AUDIO:"main"===t?this.hls.audioTracks.length?CU.VIDEO:CU.MUXED:void 0}},{key:"getTopBandwidth",value:function(e){var t,n=0,i=this.hls;if(e===CU.AUDIO)t=i.audioTracks;else{var a=i.maxAutoLevel,r=a>-1?a+1:i.levels.length;t=i.levels.slice(0,r)}return t.forEach(e=>{e.bitrate>n&&(n=e.bitrate)}),n>0?n:NaN}},{key:"getBufferLength",value:function(e){var t=this.media,n=e===CU.AUDIO?this.audioBuffer:this.videoBuffer;return n&&t?1e3*ij.bufferInfo(n,t.currentTime,this.config.maxBufferHole).len:NaN}},{key:"createPlaylistLoader",value:function(){var e=this.config.pLoader,t=this.applyPlaylistData,n=e||this.config.loader;return function(){return c(function e(t){o(this,e),this.loader=void 0,this.loader=new n(t)},[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}},{key:"destroy",value:function(){this.loader.destroy()}},{key:"abort",value:function(){this.loader.abort()}},{key:"load",value:function(e,n,i){t(e),this.loader.load(e,n,i)}}])}()}},{key:"createFragmentLoader",value:function(){var e=this.config.fLoader,t=this.applyFragmentData,n=e||this.config.loader;return function(){return c(function e(t){o(this,e),this.loader=void 0,this.loader=new n(t)},[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}},{key:"destroy",value:function(){this.loader.destroy()}},{key:"abort",value:function(){this.loader.abort()}},{key:"load",value:function(e,n,i){t(e),this.loader.load(e,n,i)}}])}()}}])}(),TH=function(e){function t(e){var n;return o(this,t),(n=r(this,t,["content-steering",e.logger])).hls=void 0,n.loader=null,n.uri=null,n.pathwayId=".",n._pathwayPriority=null,n.timeToLoad=300,n.reloadTimer=-1,n.updated=0,n.started=!1,n.enabled=!0,n.levels=null,n.audioTracks=null,n.subtitleTracks=null,n.penalizedPathways={},n.hls=e,n.registerListeners(),n}return p(t,e),c(t,[{key:"registerListeners",value:function(){var e=this.hls;e.on(m$.MANIFEST_LOADING,this.onManifestLoading,this),e.on(m$.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(m$.MANIFEST_PARSED,this.onManifestParsed,this),e.on(m$.ERROR,this.onError,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e&&(e.off(m$.MANIFEST_LOADING,this.onManifestLoading,this),e.off(m$.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(m$.MANIFEST_PARSED,this.onManifestParsed,this),e.off(m$.ERROR,this.onError,this))}},{key:"pathways",value:function(){return(this.levels||[]).reduce((e,t)=>(-1===e.indexOf(t.pathwayId)&&e.push(t.pathwayId),e),[])}},{key:"pathwayPriority",get:function(){return this._pathwayPriority},set:function(e){this.updatePathwayPriority(e)}},{key:"startLoad",value:function(){if(this.started=!0,this.clearTimeout(),this.enabled&&this.uri){if(this.updated){var e=1e3*this.timeToLoad-(performance.now()-this.updated);if(e>0)return void this.scheduleRefresh(this.uri,e)}this.loadSteeringManifest(this.uri)}}},{key:"stopLoad",value:function(){this.started=!1,this.loader&&(this.loader.destroy(),this.loader=null),this.clearTimeout()}},{key:"clearTimeout",value:function(){-1!==this.reloadTimer&&(self.clearTimeout(this.reloadTimer),this.reloadTimer=-1)}},{key:"destroy",value:function(){this.unregisterListeners(),this.stopLoad(),this.hls=null,this.levels=this.audioTracks=this.subtitleTracks=null}},{key:"removeLevel",value:function(e){var t=this.levels;t&&(this.levels=t.filter(t=>t!==e))}},{key:"onManifestLoading",value:function(){this.stopLoad(),this.enabled=!0,this.timeToLoad=300,this.updated=0,this.uri=null,this.pathwayId=".",this.levels=this.audioTracks=this.subtitleTracks=null}},{key:"onManifestLoaded",value:function(e,t){var n=t.contentSteering;null!==n&&(this.pathwayId=n.pathwayId,this.uri=n.uri,this.started&&this.startLoad())}},{key:"onManifestParsed",value:function(e,t){this.audioTracks=t.audioTracks,this.subtitleTracks=t.subtitleTracks}},{key:"onError",value:function(e,t){var n=t.errorAction;if((null==n?void 0:n.action)===_W&&n.flags===xW){var i=this.levels,a=this._pathwayPriority,r=this.pathwayId;if(t.context){var o=t.context,s=o.groupId,u=o.pathwayId,l=o.type;s&&i?r=this.getPathwayForGroupId(s,l,r):u&&(r=u)}r in this.penalizedPathways||(this.penalizedPathways[r]=performance.now()),!a&&i&&(a=this.pathways()),a&&a.length>1&&(this.updatePathwayPriority(a),n.resolved=this.pathwayId!==r),t.details!==h$.BUFFER_APPEND_ERROR||t.fatal?n.resolved||this.warn(`Could not resolve ${t.details} ("${t.error.message}") with content-steering for Pathway: ${r} levels: ${i?i.length:i} priorities: ${nW(a)} penalized: ${nW(this.penalizedPathways)}`):n.resolved=!0}}},{key:"filterParsedLevels",value:function(e){this.levels=e;var t=this.getLevelsForPathway(this.pathwayId);if(0===t.length){var n=e[0].pathwayId;this.log(`No levels found in Pathway ${this.pathwayId}. Setting initial Pathway to "${n}"`),t=this.getLevelsForPathway(n),this.pathwayId=n}return t.length!==e.length&&this.log(`Found ${t.length}/${e.length} levels in Pathway "${this.pathwayId}"`),t}},{key:"getLevelsForPathway",value:function(e){return null===this.levels?[]:this.levels.filter(t=>e===t.pathwayId)}},{key:"updatePathwayPriority",value:function(e){var t;this._pathwayPriority=e;var n=this.penalizedPathways,i=performance.now();Object.keys(n).forEach(e=>{i-n[e]>3e5&&delete n[e]});for(var a=0;a<e.length;a++){var r=e[a];if(!(r in n)){if(r===this.pathwayId)return;var o=this.hls.nextLoadLevel,s=this.hls.levels[o];if((t=this.getLevelsForPathway(r)).length>0){this.log(`Setting Pathway to "${r}"`),this.pathwayId=r,hB(t),this.hls.trigger(m$.LEVELS_UPDATED,{levels:t});var u=this.hls.levels[o];s&&u&&this.levels&&(u.attrs["STABLE-VARIANT-ID"]!==s.attrs["STABLE-VARIANT-ID"]&&u.bitrate!==s.bitrate&&this.log(`Unstable Pathways change from bitrate ${s.bitrate} to ${u.bitrate}`),this.hls.nextLoadLevel=o);break}}}}},{key:"getPathwayForGroupId",value:function(e,t,n){for(var i=this.getLevelsForPathway(n).concat(this.levels||[]),a=0;a<i.length;a++)if(t===p$&&i[a].hasAudioGroup(e)||t===g$&&i[a].hasSubtitleGroup(e))return i[a].pathwayId;return n}},{key:"clonePathways",value:function(e){var t=this.levels;if(t){var n={},i={};e.forEach(e=>{var a=e.ID,r=e["BASE-ID"],o=e["URI-REPLACEMENT"];if(!t.some(e=>e.pathwayId===a)){var s=this.getLevelsForPathway(r).map(e=>{var t=new cj(e.attrs);t["PATHWAY-ID"]=a;var r=t.AUDIO&&`${t.AUDIO}_clone_${a}`,s=t.SUBTITLES&&`${t.SUBTITLES}_clone_${a}`;r&&(n[t.AUDIO]=r,t.AUDIO=r),s&&(i[t.SUBTITLES]=s,t.SUBTITLES=s);var u=MH(e.uri,t["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",o),l=new ZN({attrs:t,audioCodec:e.audioCodec,bitrate:e.bitrate,height:e.height,name:e.name,url:u,videoCodec:e.videoCodec,width:e.width});if(e.audioGroups)for(var d=1;d<e.audioGroups.length;d++)l.addGroupId("audio",`${e.audioGroups[d]}_clone_${a}`);if(e.subtitleGroups)for(var c=1;c<e.subtitleGroups.length;c++)l.addGroupId("text",`${e.subtitleGroups[c]}_clone_${a}`);return l});t.push(...s),_H(this.audioTracks,n,o,a),_H(this.subtitleTracks,i,o,a)}})}}},{key:"loadSteeringManifest",value:function(e){var t,n=this.hls.config,i=n.loader;this.loader&&this.loader.destroy(),this.loader=new i(n);try{t=new self.URL(e)}catch(t){return this.enabled=!1,void this.log(`Failed to parse Steering Manifest URI: ${e}`)}if("data:"!==t.protocol){var a=0|(this.hls.bandwidthEstimate||n.abrEwmaDefaultEstimate);t.searchParams.set("_HLS_pathway",this.pathwayId),t.searchParams.set("_HLS_throughput",""+a)}var r={responseType:"json",url:t.href},o=n.steeringManifestLoadPolicy.default,s=o.errorRetry||o.timeoutRetry||{},u={loadPolicy:o,timeout:o.maxLoadTimeMs,maxRetry:s.maxNumRetry||0,retryDelay:s.retryDelayMs||0,maxRetryDelay:s.maxRetryDelayMs||0},l={onSuccess:(e,n,i,a)=>{this.log(`Loaded steering manifest: "${t}"`);var r=e.data;if(1===(null==r?void 0:r.VERSION)){this.updated=performance.now(),this.timeToLoad=r.TTL;var o=r["RELOAD-URI"],s=r["PATHWAY-CLONES"],u=r["PATHWAY-PRIORITY"];if(o)try{this.uri=new self.URL(o,t).href}catch(e){return this.enabled=!1,void this.log(`Failed to parse Steering Manifest RELOAD-URI: ${o}`)}this.scheduleRefresh(this.uri||i.url),s&&this.clonePathways(s);var l={steeringManifest:r,url:t.toString()};this.hls.trigger(m$.STEERING_MANIFEST_LOADED,l),u&&this.updatePathwayPriority(u)}else this.log(`Steering VERSION ${r.VERSION} not supported!`)},onError:(e,t,n,i)=>{if(this.log(`Error loading steering manifest: ${e.code} ${e.text} (${t.url})`),this.stopLoad(),410===e.code)return this.enabled=!1,void this.log(`Steering manifest ${t.url} no longer available`);var a=1e3*this.timeToLoad;if(429!==e.code)this.scheduleRefresh(this.uri||t.url,a);else{var r=this.loader;if("function"==typeof(null==r?void 0:r.getResponseHeader)){var o=r.getResponseHeader("Retry-After");o&&(a=1e3*parseFloat(o))}this.log(`Steering manifest ${t.url} rate limited`)}},onTimeout:(e,t,n)=>{this.log(`Timeout loading steering manifest (${t.url})`),this.scheduleRefresh(this.uri||t.url)}};this.log(`Requesting steering manifest: ${t}`),this.loader.load(r,u,l)}},{key:"scheduleRefresh",value:function(e,t=1e3*this.timeToLoad){this.clearTimeout(),this.reloadTimer=self.setTimeout(()=>{var t,n=null==(t=this.hls)?void 0:t.media;!n||n.ended?this.scheduleRefresh(e,1e3*this.timeToLoad):this.loadSteeringManifest(e)},t)}}])}(M$);function _H(e,t,n,i){e&&Object.keys(t).forEach(a=>{var r=e.filter(e=>e.groupId===a).map(e=>{var r=P$({},e);return r.details=void 0,r.attrs=new cj(r.attrs),r.url=r.attrs.URI=MH(e.url,e.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",n),r.groupId=r.attrs["GROUP-ID"]=t[a],r.attrs["PATHWAY-ID"]=i,r});e.push(...r)})}function MH(e,t,n,i){var a,r=i.HOST,o=i.PARAMS,s=i[n];t&&(a=null==s?void 0:s[t])&&(e=a);var u=new self.URL(e);return r&&!a&&(u.host=r),o&&Object.keys(o).sort().forEach(e=>{e&&u.searchParams.set(e,o[e])}),u.href}var AH=function(e){function t(e){var n;return o(this,t),(n=r(this,t,["eme",e.logger])).hls=void 0,n.config=void 0,n.media=null,n.mediaResolved=void 0,n.keyFormatPromise=null,n.keySystemAccessPromises={},n._requestLicenseFailureCount=0,n.mediaKeySessions=[],n.keyIdToKeySessionPromise={},n.mediaKeys=null,n.setMediaKeysQueue=t.CDMCleanupPromise?[t.CDMCleanupPromise]:[],n.bannedKeyIds={},n.onMediaEncrypted=e=>{var t=e.initDataType,i=e.initData,a=`"${e.type}" event: init data type: "${t}"`;if(n.debug(a),null!==i){if(!n.keyFormatPromise){var r=Object.keys(n.keySystemAccessPromises);r.length||(r=Ij(n.config));var o=r.map(Cj).filter(e=>!!e);n.keyFormatPromise=n.getKeyFormatPromise(o)}n.keyFormatPromise.then(r=>{var o=xj(r);if("sinf"===t&&o===Tj.FAIRPLAY){var s;try{var u=tN(new Uint8Array(i)),l=vN(wj(JSON.parse(u).sinf));if(!l)throw new Error("'schm' box missing or not cbcs/cenc with schi > tenc");s=new Uint8Array(l.subarray(8,24))}catch(e){return void n.warn(`${a} Failed to parse sinf: ${e}`)}for(var d,c=$$(s),h=n,m=h.keyIdToKeySessionPromise,f=h.mediaKeySessions,v=m[c],p=function(){var e=f[g],a=e.decryptdata;if(!a.keyId)return 0;var r=$$(a.keyId);return pj(s,a.keyId)||-1!==a.uri.replace(/-/g,"").indexOf(c)?(v=m[r])?(a.pssh||(delete m[r],a.pssh=new Uint8Array(i),a.keyId=s,(v=m[c]=v.then(()=>n.generateRequestWithPreferredKeySession(e,t,i,"encrypted-event-key-match"))).catch(e=>n.handleError(e))),1):0:void 0},g=0;g<f.length&&(0===(d=p())||1!==d);g++);v||n.handleError(new Error(`Key ID ${c} not encountered in playlist. Key-system sessions ${f.length}.`))}else n.log(`Ignoring "${e.type}" event with init data type: "${t}" for selected key-system ${o}`)}).catch(e=>n.handleError(e))}},n.onWaitingForKey=e=>{n.log(`"${e.type}" event`)},n.hls=e,n.config=e.config,n.registerListeners(),n}return p(t,e),c(t,[{key:"destroy",value:function(){this.onDestroying(),this.onMediaDetached();var 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}},{key:"registerListeners",value:function(){this.hls.on(m$.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(m$.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(m$.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(m$.MANIFEST_LOADED,this.onManifestLoaded,this),this.hls.on(m$.DESTROYING,this.onDestroying,this)}},{key:"unregisterListeners",value:function(){this.hls.off(m$.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(m$.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(m$.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(m$.MANIFEST_LOADED,this.onManifestLoaded,this),this.hls.off(m$.DESTROYING,this.onDestroying,this)}},{key:"getLicenseServerUrl",value:function(e){var t=this.config,n=t.drmSystems,i=t.widevineLicenseUrl,a=null==n?void 0:n[e];return a?a.licenseUrl:e===Tj.WIDEVINE&&i?i:void 0}},{key:"getLicenseServerUrlOrThrow",value:function(e){var t=this.getLicenseServerUrl(e);if(void 0===t)throw new Error(`no license server URL configured for key-system "${e}"`);return t}},{key:"getServerCertificateUrl",value:function(e){var t=this.config.drmSystems,n=null==t?void 0:t[e];if(n)return n.serverCertificateUrl;this.log(`No Server Certificate in config.drmSystems["${e}"]`)}},{key:"attemptKeySystemAccess",value:function(e){var t=this.hls.levels,n=(e,t,n)=>!!e&&n.indexOf(e)===t,i=t.map(e=>e.audioCodec).filter(n),a=t.map(e=>e.videoCodec).filter(n);return i.length+a.length===0&&a.push("avc1.42e01e"),new Promise((t,n)=>{var r=e=>{var o=e.shift();this.getMediaKeysPromise(o,i,a).then(e=>t({keySystem:o,mediaKeys:e})).catch(t=>{e.length?r(e):n(t instanceof CH?t:new CH({type:c$.KEY_SYSTEM_ERROR,details:h$.KEY_SYSTEM_NO_ACCESS,error:t,fatal:!0},t.message))})};r(e)})}},{key:"requestMediaKeySystemAccess",value:function(e,t){var n=this.config.requestMediaKeySystemAccessFunc;if("function"!=typeof n){var i=`Configured requestMediaKeySystemAccess is not a function ${n}`;return null===Rj&&"http:"===self.location.protocol&&(i=`navigator.requestMediaKeySystemAccess is not available over insecure protocol ${location.protocol}`),Promise.reject(new Error(i))}return n(e,t)}},{key:"getMediaKeysPromise",value:function(e,t,n){var i,a=function(e,t,n,i){var a;switch(e){case Tj.FAIRPLAY:a=["cenc","sinf"];break;case Tj.WIDEVINE:case Tj.PLAYREADY:a=["cenc"];break;case Tj.CLEARKEY:a=["cenc","keyids"];break;default:throw new Error(`Unknown key-system: ${e}`)}return function(e,t,n,i){return[{initDataTypes:e,persistentState:i.persistentState||"optional",distinctiveIdentifier:i.distinctiveIdentifier||"optional",sessionTypes:i.sessionTypes||[i.sessionType||"temporary"],audioCapabilities:t.map(e=>({contentType:`audio/mp4; codecs=${e}`,robustness:i.audioRobustness||"",encryptionScheme:i.audioEncryptionScheme||null})),videoCapabilities:n.map(e=>({contentType:`video/mp4; codecs=${e}`,robustness:i.videoRobustness||"",encryptionScheme:i.videoEncryptionScheme||null}))}]}(a,t,n,i)}(e,t,n,this.config.drmSystemOptions||{}),r=this.keySystemAccessPromises[e],o=null==(i=r)?void 0:i.keySystemAccess;if(!o){this.log(`Requesting encrypted media "${e}" key-system access with config: ${nW(a)}`),o=this.requestMediaKeySystemAccess(e,a);var s=r=this.keySystemAccessPromises[e]={keySystemAccess:o};return o.catch(t=>{this.log(`Failed to obtain access to key-system "${e}": ${t}`)}),o.then(t=>{this.log(`Access for key-system "${t.keySystem}" obtained`);var n=this.fetchServerCertificate(e);this.log(`Create media-keys for "${e}"`);var i=s.mediaKeys=t.createMediaKeys().then(t=>(this.log(`Media-keys created for "${e}"`),s.hasMediaKeys=!0,n.then(n=>n?this.setMediaKeysServerCertificate(t,e,n):t)));return i.catch(t=>{this.error(`Failed to create media-keys for "${e}"}: ${t}`)}),i})}return o.then(()=>r.mediaKeys)}},{key:"createMediaKeySessionContext",value:function({decryptdata:e,keySystem:t,mediaKeys:n}){this.log(`Creating key-system session "${t}" keyId: ${$$(e.keyId||[])} keyUri: ${e.uri}`);var i=n.createSession(),a={decryptdata:e,keySystem:t,mediaKeys:n,mediaKeysSession:i,keyStatus:"status-pending"};return this.mediaKeySessions.push(a),a}},{key:"renewKeySession",value:function(e){var t=e.decryptdata;if(t.pssh){var n=this.createMediaKeySessionContext(e),i=DH(t);this.keyIdToKeySessionPromise[i]=this.generateRequestWithPreferredKeySession(n,"cenc",t.pssh.buffer,"expired")}else this.warn("Could not renew expired session. Missing pssh initData.");this.removeSession(e)}},{key:"updateKeySession",value:function(e,t){var n=e.mediaKeysSession;return this.log(`Updating key-session "${n.sessionId}" for keyId ${$$(e.decryptdata.keyId||[])}\n } (data length: ${t.byteLength})`),n.update(t)}},{key:"getSelectedKeySystemFormats",value:function(){return Object.keys(this.keySystemAccessPromises).map(e=>({keySystem:e,hasMediaKeys:this.keySystemAccessPromises[e].hasMediaKeys})).filter(({hasMediaKeys:e})=>!!e).map(({keySystem:e})=>Cj(e)).filter(e=>!!e)}},{key:"getKeySystemAccess",value:function(e){return this.getKeySystemSelectionPromise(e).then(({keySystem:e,mediaKeys:t})=>this.attemptSetMediaKeys(e,t))}},{key:"selectKeySystem",value:function(e){return new Promise((t,n)=>{this.getKeySystemSelectionPromise(e).then(({keySystem:e})=>{var i=Cj(e);i?t(i):n(new Error(`Unable to find format for key-system "${e}"`))}).catch(n)})}},{key:"selectKeySystemFormat",value:function(e){var t=Object.keys(e.levelkeys||{});return this.keyFormatPromise||(this.log(`Selecting key-system from fragment (sn: ${e.sn} ${e.type}: ${e.level}) key formats ${t.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(t)),this.keyFormatPromise}},{key:"getKeyFormatPromise",value:function(e){var t=Ij(this.config),n=e.map(xj).filter(e=>!!e&&-1!==t.indexOf(e));return this.selectKeySystem(n)}},{key:"getKeyStatus",value:function(e){for(var t=this.mediaKeySessions,n=0;n<t.length;n++){var i=xH(e,t[n]);if(i)return i}}},{key:"loadKey",value:function(e){var t=e.keyInfo.decryptdata,n=DH(t),i=this.bannedKeyIds[n];if(i||"internal-error"===this.getKeyStatus(t)){var a=IH(i||"internal-error",t);return this.handleError(a,e.frag),Promise.reject(a)}var r=`(keyId: ${n} format: "${t.keyFormat}" method: ${t.method} uri: ${t.uri})`;this.log(`Starting session for key ${r}`);var o=this.keyIdToKeySessionPromise[n];if(!o){var s=this.getKeySystemForKeyPromise(t).then(({keySystem:n,mediaKeys:i})=>(this.throwIfDestroyed(),this.log(`Handle encrypted media sn: ${e.frag.sn} ${e.frag.type}: ${e.frag.level} using key ${r}`),this.attemptSetMediaKeys(n,i).then(()=>(this.throwIfDestroyed(),this.createMediaKeySessionContext({keySystem:n,mediaKeys:i,decryptdata:t}))))).then(e=>{var n=t.pssh?t.pssh.buffer:null;return this.generateRequestWithPreferredKeySession(e,"cenc",n,"playlist-key")});return s.catch(t=>this.handleError(t,e.frag)),this.keyIdToKeySessionPromise[n]=s,s}return o.catch(n=>{if(n instanceof CH){var i=_$({},n.data);"internal-error"===this.getKeyStatus(t)&&(i.decryptdata=t);var a=new CH(i,n.message);this.handleError(a,e.frag)}}),o}},{key:"throwIfDestroyed",value:function(e="Invalid state"){if(!this.hls)throw new Error("invalid state")}},{key:"handleError",value:function(e,t){if(this.hls)if(e instanceof CH){t&&(e.data.frag=t);var n=e.data.decryptdata;this.error(`${e.message}${n?` (${$$(n.keyId||[])})`:""}`),this.hls.trigger(m$.ERROR,e.data)}else this.error(e.message),this.hls.trigger(m$.ERROR,{type:c$.KEY_SYSTEM_ERROR,details:h$.KEY_SYSTEM_NO_KEYS,error:e,fatal:!0})}},{key:"getKeySystemForKeyPromise",value:function(e){var t=DH(e),n=this.keyIdToKeySessionPromise[t];if(!n){var i=xj(e.keyFormat),a=i?[i]:Ij(this.config);return this.attemptKeySystemAccess(a)}return n}},{key:"getKeySystemSelectionPromise",value:function(e){if(e.length||(e=Ij(this.config)),0===e.length)throw new CH({type:c$.KEY_SYSTEM_ERROR,details:h$.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},`Missing key-system license configuration options ${nW({drmSystems:this.config.drmSystems})}`);return this.attemptKeySystemAccess(e)}},{key:"attemptSetMediaKeys",value:function(e,t){if(this.mediaResolved=void 0,this.mediaKeys===t)return Promise.resolve();var n=this.setMediaKeysQueue.slice();this.log(`Setting media-keys for "${e}"`);var i=Promise.all(n).then(()=>this.media?this.media.setMediaKeys(t):new Promise((e,n)=>{this.mediaResolved=()=>{if(this.mediaResolved=void 0,!this.media)return n(new Error("Attempted to set mediaKeys without media element attached"));this.mediaKeys=t,this.media.setMediaKeys(t).then(e).catch(n)}}));return this.mediaKeys=t,this.setMediaKeysQueue.push(i),i.then(()=>{this.log(`Media-keys set for "${e}"`),n.push(i),this.setMediaKeysQueue=this.setMediaKeysQueue.filter(e=>-1===n.indexOf(e))})}},{key:"generateRequestWithPreferredKeySession",value:function(e,t,n,i){var a,r=null==(a=this.config.drmSystems)||null==(a=a[e.keySystem])?void 0:a.generateRequest;if(r)try{var o=r.call(this.hls,t,n,e);if(!o)throw new Error("Invalid response from configured generateRequest filter");t=o.initDataType,n=o.initData?o.initData:null,e.decryptdata.pssh=n?new Uint8Array(n):null}catch(e){if(this.warn(e.message),this.hls&&this.hls.config.debug)throw e}if(null===n)return this.log(`Skipping key-session request for "${i}" (no initData)`),Promise.resolve(e);var s=DH(e.decryptdata),u=e.decryptdata.uri;this.log(`Generating key-session request for "${i}" keyId: ${s} URI: ${u} (init data type: ${t} length: ${n.byteLength})`);var l=new BB,d=e._onmessage=t=>{var n=e.mediaKeysSession;if(n){var i=t.messageType,a=t.message;this.log(`"${i}" message event for session "${n.sessionId}" message size: ${a.byteLength}`),"license-request"===i||"license-renewal"===i?this.renewLicense(e,a).catch(e=>{l.eventNames().length?l.emit("error",e):this.handleError(e)}):"license-release"===i?e.keySystem===Tj.FAIRPLAY&&this.updateKeySession(e,kj("acknowledged")).then(()=>this.removeSession(e)).catch(e=>this.handleError(e)):this.warn(`unhandled media key message type "${i}"`)}else l.emit("error",new Error("invalid state"))},c=(e,t)=>{var n;t.keyStatus=e,e.startsWith("usable")?l.emit("resolved"):"internal-error"===e||"output-restricted"===e||"output-downscaled"===e?n=IH(e,t.decryptdata):"expired"===e?n=new Error(`key expired (keyId: ${s})`):"released"===e?n=new Error("key released"):"status-pending"===e||this.warn(`unhandled key status change "${e}" (keyId: ${s})`),n&&(l.eventNames().length?l.emit("error",n):this.handleError(n))},h=e._onkeystatuseschange=t=>{if(e.mediaKeysSession){var n=this.getKeyStatuses(e);if(Object.keys(n).some(e=>"status-pending"!==n[e])){if("expired"===n[s])return this.log(`Expired key ${nW(n)} in key-session "${e.mediaKeysSession.sessionId}"`),void this.renewKeySession(e);var i=n[s];if(i)c(i,e);else{var a;e.keyStatusTimeouts||(e.keyStatusTimeouts={}),(a=e.keyStatusTimeouts)[s]||(a[s]=self.setTimeout(()=>{if(e.mediaKeysSession&&this.mediaKeys){var t=this.getKeyStatus(e.decryptdata);if(t&&"status-pending"!==t)return this.log(`No status for keyId ${s} in key-session "${e.mediaKeysSession.sessionId}". Using session key-status ${t} from other session.`),c(t,e);this.log(`key status for ${s} in key-session "${e.mediaKeysSession.sessionId}" timed out after 1000ms`),c(i="internal-error",e)}},1e3)),this.log(`No status for keyId ${s} (${nW(n)}).`)}}}else l.emit("error",new Error("invalid state"))};wB(e.mediaKeysSession,"message",d),wB(e.mediaKeysSession,"keystatuseschange",h);var m=new Promise((e,t)=>{l.on("error",t),l.on("resolved",e)});return e.mediaKeysSession.generateRequest(t,n).then(()=>{this.log(`Request generated for key-session "${e.mediaKeysSession.sessionId}" keyId: ${s} URI: ${u}`)}).catch(t=>{throw new CH({type:c$.KEY_SYSTEM_ERROR,details:h$.KEY_SYSTEM_NO_SESSION,error:t,decryptdata:e.decryptdata,fatal:!1},`Error generating key-session request: ${t}`)}).then(()=>m).catch(t=>(l.removeAllListeners(),this.removeSession(e).then(()=>{throw t}))).then(()=>(l.removeAllListeners(),e))}},{key:"getKeyStatuses",value:function(e){var t={};return e.mediaKeysSession.keyStatuses.forEach((n,i)=>{if("string"==typeof i&&"object"==typeof n){var a=i;i=n,n=a}var r="buffer"in i?new Uint8Array(i.buffer,i.byteOffset,i.byteLength):new Uint8Array(i);if(e.keySystem===Tj.PLAYREADY&&16===r.length){var o=$$(r);t[o]=n,Sj(r)}var s=$$(r);"internal-error"===n&&(this.bannedKeyIds[s]=n),this.log(`key status change "${n}" for keyStatuses keyId: ${s} key-session "${e.mediaKeysSession.sessionId}"`),t[s]=n}),t}},{key:"fetchServerCertificate",value:function(e){var t=this.config,n=new(0,t.loader)(t),i=this.getServerCertificateUrl(e);return i?(this.log(`Fetching server certificate for "${e}"`),new Promise((a,r)=>{var o={responseType:"arraybuffer",url:i},s=t.certLoadPolicy.default,u={loadPolicy:s,timeout:s.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},l={onSuccess:(e,t,n,i)=>{a(e.data)},onError:(t,n,a,s)=>{r(new CH({type:c$.KEY_SYSTEM_ERROR,details:h$.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:a,response:_$({url:o.url,data:void 0},t)},`"${e}" certificate request failed (${i}). Status: ${t.code} (${t.text})`))},onTimeout:(t,n,a)=>{r(new CH({type:c$.KEY_SYSTEM_ERROR,details:h$.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:a,response:{url:o.url,data:void 0}},`"${e}" certificate request timed out (${i})`))},onAbort:(e,t,n)=>{r(new Error("aborted"))}};n.load(o,u,l)})):Promise.resolve()}},{key:"setMediaKeysServerCertificate",value:function(e,t,n){return new Promise((i,a)=>{e.setServerCertificate(n).then(a=>{this.log(`setServerCertificate ${a?"success":"not supported by CDM"} (${n.byteLength}) on "${t}"`),i(e)}).catch(e=>{a(new CH({type:c$.KEY_SYSTEM_ERROR,details:h$.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED,error:e,fatal:!0},e.message))})})}},{key:"renewLicense",value:function(e,t){return this.requestLicense(e,new Uint8Array(t)).then(t=>this.updateKeySession(e,new Uint8Array(t)).catch(t=>{throw new CH({type:c$.KEY_SYSTEM_ERROR,details:h$.KEY_SYSTEM_SESSION_UPDATE_FAILED,decryptdata:e.decryptdata,error:t,fatal:!1},t.message)}))}},{key:"unpackPlayReadyKeyMessage",value:function(e,t){var n=String.fromCharCode.apply(null,new Uint16Array(t.buffer));if(!n.includes("PlayReadyKeyMessage"))return e.setRequestHeader("Content-Type","text/xml; charset=utf-8"),t;var i=(new DOMParser).parseFromString(n,"application/xml"),a=i.querySelectorAll("HttpHeader");if(a.length>0)for(var r,o=0,s=a.length;o<s;o++){var u,l,d=null==(u=(r=a[o]).querySelector("name"))?void 0:u.textContent,c=null==(l=r.querySelector("value"))?void 0:l.textContent;d&&c&&e.setRequestHeader(d,c)}var h=i.querySelector("Challenge"),m=null==h?void 0:h.textContent;if(!m)throw new Error("Cannot find <Challenge> in key message");return kj(atob(m))}},{key:"setupLicenseXHR",value:function(e,t,n,i){var a=this.config.licenseXhrSetup;return a?Promise.resolve().then(()=>{if(!n.decryptdata)throw new Error("Key removed");return a.call(this.hls,e,t,n,i)}).catch(r=>{if(!n.decryptdata)throw r;return e.open("POST",t,!0),a.call(this.hls,e,t,n,i)}).then(n=>(e.readyState||e.open("POST",t,!0),{xhr:e,licenseChallenge:n||i})):(e.open("POST",t,!0),Promise.resolve({xhr:e,licenseChallenge:i}))}},{key:"requestLicense",value:function(e,t){var n=this.config.keyLoadPolicy.default;return new Promise((i,a)=>{var r=this.getLicenseServerUrlOrThrow(e.keySystem);this.log(`Sending license request to URL: ${r}`);var o=new XMLHttpRequest;o.responseType="arraybuffer",o.onreadystatechange=()=>{if(!this.hls||!e.mediaKeysSession)return a(new Error("invalid state"));if(4===o.readyState)if(200===o.status){this._requestLicenseFailureCount=0;var s=o.response;this.log(`License received ${s instanceof ArrayBuffer?s.byteLength:s}`);var u=this.config.licenseResponseCallback;if(u)try{s=u.call(this.hls,o,r,e)}catch(e){this.error(e)}i(s)}else{var l=n.errorRetry,d=l?l.maxNumRetry:0;if(this._requestLicenseFailureCount++,this._requestLicenseFailureCount>d||o.status>=400&&o.status<500)a(new CH({type:c$.KEY_SYSTEM_ERROR,details:h$.KEY_SYSTEM_LICENSE_REQUEST_FAILED,decryptdata:e.decryptdata,fatal:!0,networkDetails:o,response:{url:r,data:void 0,code:o.status,text:o.statusText}},`License Request XHR failed (${r}). Status: ${o.status} (${o.statusText})`));else{var c=d-this._requestLicenseFailureCount+1;this.warn(`Retrying license request, ${c} attempts left`),this.requestLicense(e,t).then(i,a)}}},e.licenseXhr&&e.licenseXhr.readyState!==XMLHttpRequest.DONE&&e.licenseXhr.abort(),e.licenseXhr=o,this.setupLicenseXHR(o,r,e,t).then(({xhr:t,licenseChallenge:n})=>{e.keySystem==Tj.PLAYREADY&&(n=this.unpackPlayReadyKeyMessage(t,n)),t.send(n)}).catch(a)})}},{key:"onDestroying",value:function(){this.unregisterListeners(),this._clear()}},{key:"onMediaAttached",value:function(e,t){if(this.config.emeEnabled){var n=t.media;this.media=n,wB(n,"encrypted",this.onMediaEncrypted),wB(n,"waitingforkey",this.onWaitingForKey);var i=this.mediaResolved;i?i():this.mediaKeys=n.mediaKeys}}},{key:"onMediaDetached",value:function(){var e=this.media;e&&(kB(e,"encrypted",this.onMediaEncrypted),kB(e,"waitingforkey",this.onWaitingForKey),this.media=null,this.mediaKeys=null)}},{key:"_clear",value:function(){var e;this._requestLicenseFailureCount=0,this.keyIdToKeySessionPromise={},this.bannedKeyIds={};var n=this.mediaResolved;if(n&&n(),this.mediaKeys||this.mediaKeySessions.length){var i=this.media,a=this.mediaKeySessions.slice();this.mediaKeySessions=[],this.mediaKeys=null,$j.clearKeyUriToKeyIdMap();var r=a.length;t.CDMCleanupPromise=Promise.all(a.map(e=>this.removeSession(e)).concat((null==i||null==(e=i.setMediaKeys(null))?void 0:e.catch(e=>{this.log(`Could not clear media keys: ${e}`),this.hls&&this.hls.trigger(m$.ERROR,{type:c$.OTHER_ERROR,details:h$.KEY_SYSTEM_DESTROY_MEDIA_KEYS_ERROR,fatal:!1,error:new Error(`Could not clear media keys: ${e}`)})}))||Promise.resolve())).catch(e=>{this.log(`Could not close sessions and clear media keys: ${e}`),this.hls&&this.hls.trigger(m$.ERROR,{type:c$.OTHER_ERROR,details:h$.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR,fatal:!1,error:new Error(`Could not close sessions and clear media keys: ${e}`)})}).then(()=>{r&&this.log("finished closing key sessions and clearing media keys")})}}},{key:"onManifestLoading",value:function(){this._clear()}},{key:"onManifestLoaded",value:function(e,{sessionKeys:t}){if(t&&this.config.emeEnabled&&!this.keyFormatPromise){var n=t.reduce((e,t)=>(-1===e.indexOf(t.keyFormat)&&e.push(t.keyFormat),e),[]);this.log(`Selecting key-system from session-keys ${n.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(n)}}},{key:"removeSession",value:function(e){var t=e.mediaKeysSession,n=e.licenseXhr,i=e.decryptdata;if(t){this.log(`Remove licenses and keys and close session "${t.sessionId}" keyId: ${$$((null==i?void 0:i.keyId)||[])}`),e._onmessage&&(t.removeEventListener("message",e._onmessage),e._onmessage=void 0),e._onkeystatuseschange&&(t.removeEventListener("keystatuseschange",e._onkeystatuseschange),e._onkeystatuseschange=void 0),n&&n.readyState!==XMLHttpRequest.DONE&&n.abort(),e.mediaKeysSession=e.decryptdata=e.licenseXhr=void 0;var a=this.mediaKeySessions.indexOf(e);a>-1&&this.mediaKeySessions.splice(a,1);var r=e.keyStatusTimeouts;r&&Object.keys(r).forEach(e=>self.clearTimeout(r[e]));var o=function(e){var t;return!(!e||"persistent-license"!==e.sessionType&&(null==(t=e.sessionTypes)||!t.some(e=>"persistent-license"===e)))}(this.config.drmSystemOptions)?new Promise((e,n)=>{self.setTimeout(()=>n(new Error("MediaKeySession.remove() timeout")),8e3),t.remove().then(e).catch(n)}):Promise.resolve();return o.catch(e=>{this.log(`Could not remove session: ${e}`),this.hls&&this.hls.trigger(m$.ERROR,{type:c$.OTHER_ERROR,details:h$.KEY_SYSTEM_DESTROY_REMOVE_SESSION_ERROR,fatal:!1,error:new Error(`Could not remove session: ${e}`)})}).then(()=>t.close()).catch(e=>{this.log(`Could not close session: ${e}`),this.hls&&this.hls.trigger(m$.ERROR,{type:c$.OTHER_ERROR,details:h$.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR,fatal:!1,error:new Error(`Could not close session: ${e}`)})})}return Promise.resolve()}}])}(M$);function DH(e){if(!e)throw new Error("Could not read keyId of undefined decryptdata");if(null===e.keyId)throw new Error("keyId is null");return $$(e.keyId)}function xH(e,t){return e.keyId&&t.mediaKeysSession.keyStatuses.has(e.keyId)?t.mediaKeysSession.keyStatuses.get(e.keyId):e.matches(t.decryptdata)?t.keyStatus:void 0}AH.CDMCleanupPromise=void 0;var CH=function(e){function t(e,n){var i;return o(this,t),(i=r(this,t,[n])).data=void 0,e.error||(e.error=new Error(n)),i.data=e,e.err=e.error,i}return p(t,e),c(t)}(M(Error));function IH(e,t){var n="output-restricted"===e,i=n?h$.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:h$.KEY_SYSTEM_STATUS_INTERNAL_ERROR;return new CH({type:c$.KEY_SYSTEM_ERROR,details:i,fatal:!1,decryptdata:t},n?"HDCP level output restricted":`key status changed to "${e}"`)}var LH=function(){return c(function e(t){o(this,e),this.hls=void 0,this.isVideoPlaybackQualityAvailable=!1,this.timer=void 0,this.media=null,this.lastTime=void 0,this.lastDroppedFrames=0,this.lastDecodedFrames=0,this.streamController=void 0,this.hls=t,this.registerListeners()},[{key:"setStreamController",value:function(e){this.streamController=e}},{key:"registerListeners",value:function(){this.hls.on(m$.MEDIA_ATTACHING,this.onMediaAttaching,this),this.hls.on(m$.MEDIA_DETACHING,this.onMediaDetaching,this)}},{key:"unregisterListeners",value:function(){this.hls.off(m$.MEDIA_ATTACHING,this.onMediaAttaching,this),this.hls.off(m$.MEDIA_DETACHING,this.onMediaDetaching,this)}},{key:"destroy",value:function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null}},{key:"onMediaAttaching",value:function(e,t){var n=this.hls.config;if(n.capLevelOnFPSDrop){var i=t.media instanceof self.HTMLVideoElement?t.media:null;this.media=i,i&&"function"==typeof i.getVideoPlaybackQuality&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),n.fpsDroppedMonitoringPeriod)}}},{key:"onMediaDetaching",value:function(){this.media=null}},{key:"checkFPS",value:function(e,t,n){var i=performance.now();if(t){if(this.lastTime){var a=i-this.lastTime,r=n-this.lastDroppedFrames,o=t-this.lastDecodedFrames,s=1e3*r/a,u=this.hls;if(u.trigger(m$.FPS_DROP,{currentDropped:r,currentDecoded:o,totalDroppedFrames:n}),s>0&&r>u.config.fpsDroppedMonitoringThreshold*o){var l=u.currentLevel;u.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+l),l>0&&(-1===u.autoLevelCapping||u.autoLevelCapping>=l)&&(l-=1,u.trigger(m$.FPS_DROP_LEVEL_CAPPING,{level:l,droppedLevel:u.currentLevel}),u.autoLevelCapping=l,this.streamController.nextLevelSwitch())}}this.lastTime=i,this.lastDroppedFrames=n,this.lastDecodedFrames=t}}},{key:"checkFPSInterval",value:function(){var e=this.media;if(e)if(this.isVideoPlaybackQualityAvailable){var t=e.getVideoPlaybackQuality();this.checkFPS(e,t.totalVideoFrames,t.droppedVideoFrames)}else this.checkFPS(e,e.webkitDecodedFrameCount,e.webkitDroppedFrameCount)}}])}();function RH(e,t){var n;try{n=new Event("addtrack")}catch(e){(n=document.createEvent("Event")).initEvent("addtrack",!1,!1)}n.track=e,t.dispatchEvent(n)}function FH(e,t){var n=e.mode;if("disabled"===n&&(e.mode="hidden"),e.cues&&!e.cues.getCueById(t.id))try{if(e.addCue(t),!e.cues.getCueById(t.id))throw new Error(`addCue is failed for: ${t}`)}catch(n){L$.debug(`[texttrack-utils]: ${n}`);try{var i=new self.TextTrackCue(t.startTime,t.endTime,t.text);i.id=t.id,e.addCue(i)}catch(e){L$.debug(`[texttrack-utils]: Legacy TextTrackCue fallback failed: ${e}`)}}"disabled"===n&&(e.mode=n)}function OH(e,t){var n=e.mode;if("disabled"===n&&(e.mode="hidden"),e.cues)for(var i=e.cues.length;i--;)t&&e.cues[i].removeEventListener("enter",t),e.removeCue(e.cues[i]);"disabled"===n&&(e.mode=n)}function $H(e,t,n,i){var a=e.mode;if("disabled"===a&&(e.mode="hidden"),e.cues&&e.cues.length>0)for(var r=function(e,t,n){var i=[],a=function(e,t){if(t<=e[0].startTime)return 0;var n=e.length-1;if(t>e[n].endTime)return-1;var i,a=0,r=n;for(;a<=r;)if(t<e[i=Math.floor((r+a)/2)].startTime)r=i-1;else{if(!(t>e[i].startTime&&a<n))return i;a=i+1}return e[a].startTime-t<t-e[r].startTime?a:r}(e,t);if(a>-1)for(var r=a,o=e.length;r<o;r++){var s=e[r];if(s.startTime>=t&&s.endTime<=n)i.push(s);else if(s.startTime>n)return i}return i}(e.cues,t,n),o=0;o<r.length;o++)i&&!i(r[o])||e.removeCue(r[o]);"disabled"===a&&(e.mode=a)}function NH(e){for(var t=[],n=0;n<e.length;n++){var i=e[n];"subtitles"!==i.kind&&"captions"!==i.kind||!i.label||t.push(e[n])}return t}var WH=function(e){function t(e){var n;return o(this,t),(n=r(this,t,[e,"subtitle-track-controller"])).media=null,n.tracks=[],n.groupIds=null,n.tracksInGroup=[],n.trackId=-1,n.currentTrack=null,n.selectDefaultTrack=!0,n.queuedDefaultTrack=-1,n.useTextTrackPolling=!1,n.subtitlePollingInterval=-1,n._subtitleDisplay=!0,n.asyncPollTrackChange=()=>n.pollTrackChange(0),n.onTextTracksChanged=()=>{if(n.useTextTrackPolling||self.clearInterval(n.subtitlePollingInterval),n.media&&n.hls.config.renderTextTracksNatively){for(var e=null,t=NH(n.media.textTracks),i=0;i<t.length;i++)if("hidden"===t[i].mode)e=t[i];else if("showing"===t[i].mode){e=t[i];break}var a=n.findTrackForTextTrack(e);n.subtitleTrack!==a&&n.setSubtitleTrack(a)}},n.registerListeners(),n}return p(t,e),c(t,[{key:"destroy",value:function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,this.onTextTracksChanged=this.asyncPollTrackChange=null,T(t,"destroy",this)([])}},{key:"subtitleDisplay",get:function(){return this._subtitleDisplay},set:function(e){this._subtitleDisplay=e,this.trackId>-1&&this.toggleTrackModes()}},{key:"registerListeners",value:function(){var e=this.hls;e.on(m$.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(m$.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(m$.MANIFEST_LOADING,this.onManifestLoading,this),e.on(m$.MANIFEST_PARSED,this.onManifestParsed,this),e.on(m$.LEVEL_LOADING,this.onLevelLoading,this),e.on(m$.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(m$.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(m$.ERROR,this.onError,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e.off(m$.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(m$.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(m$.MANIFEST_LOADING,this.onManifestLoading,this),e.off(m$.MANIFEST_PARSED,this.onManifestParsed,this),e.off(m$.LEVEL_LOADING,this.onLevelLoading,this),e.off(m$.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(m$.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(m$.ERROR,this.onError,this)}},{key:"onMediaAttached",value:function(e,t){this.media=t.media,this.media&&(this.queuedDefaultTrack>-1&&(this.subtitleTrack=this.queuedDefaultTrack,this.queuedDefaultTrack=-1),this.useTextTrackPolling=!(this.media.textTracks&&"onchange"in this.media.textTracks),this.useTextTrackPolling?this.pollTrackChange(500):this.media.textTracks.addEventListener("change",this.asyncPollTrackChange))}},{key:"pollTrackChange",value:function(e){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.onTextTracksChanged,e)}},{key:"onMediaDetaching",value:function(e,t){var n=this.media;if(n){var i=!!t.transferMedia;if(self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||n.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId),this.subtitleTrack=-1,this.media=null,!i)NH(n.textTracks).forEach(e=>{OH(e)})}}},{key:"onManifestLoading",value:function(){this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0}},{key:"onManifestParsed",value:function(e,t){this.tracks=t.subtitleTracks}},{key:"onSubtitleTrackLoaded",value:function(e,t){var n=t.id,i=t.groupId,a=t.details,r=this.tracksInGroup[n];if(r&&r.groupId===i){var o=r.details;r.details=t.details,this.log(`Subtitle track ${n} "${r.name}" lang:${r.lang} group:${i} loaded [${a.startSN}-${a.endSN}]`),n===this.trackId&&this.playlistLoaded(n,t,o)}else this.warn(`Subtitle track with id:${n} and group:${i} not found in active group ${null==r?void 0:r.groupId}`)}},{key:"onLevelLoading",value:function(e,t){this.switchLevel(t.level)}},{key:"onLevelSwitching",value:function(e,t){this.switchLevel(t.level)}},{key:"switchLevel",value:function(e){var t=this.hls.levels[e];if(t){var n=t.subtitleGroups||null,i=this.groupIds,a=this.currentTrack;if(!n||(null==i?void 0:i.length)!==(null==n?void 0:n.length)||null!=n&&n.some(e=>-1===(null==i?void 0:i.indexOf(e)))){this.groupIds=n,this.trackId=-1,this.currentTrack=null;var r=this.tracks.filter(e=>!n||-1!==n.indexOf(e.groupId));if(r.length)this.selectDefaultTrack&&!r.some(e=>e.default)&&(this.selectDefaultTrack=!1),r.forEach((e,t)=>{e.id=t});else if(!a&&!this.tracksInGroup.length)return;this.tracksInGroup=r;var o=this.hls.config.subtitlePreference;if(!a&&o){this.selectDefaultTrack=!1;var s=oW(o,r);if(s>-1)a=r[s];else{var u=oW(o,this.tracks);a=this.tracks[u]}}var l=this.findTrackId(a);-1===l&&a&&(l=this.findTrackId(null));var d={subtitleTracks:r};this.log(`Updating subtitle tracks, ${r.length} track(s) found in "${null==n?void 0:n.join(",")}" group-id`),this.hls.trigger(m$.SUBTITLE_TRACKS_UPDATED,d),-1!==l&&-1===this.trackId&&this.setSubtitleTrack(l)}}}},{key:"findTrackId",value:function(e){for(var t=this.tracksInGroup,n=this.selectDefaultTrack,i=0;i<t.length;i++){var a=t[i];if((!n||a.default)&&(n||e)&&(!e||sW(a,e)))return i}if(e){for(var r=0;r<t.length;r++){var o=t[r];if(wU(e.attrs,o.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return r}for(var s=0;s<t.length;s++){var u=t[s];if(wU(e.attrs,u.attrs,["LANGUAGE"]))return s}}return-1}},{key:"findTrackForTextTrack",value:function(e){if(e)for(var t=this.tracksInGroup,n=0;n<t.length;n++){if(kU(t[n],e))return n}return-1}},{key:"onError",value:function(e,t){!t.fatal&&t.context&&(t.context.type!==g$||t.context.id!==this.trackId||this.groupIds&&-1===this.groupIds.indexOf(t.context.groupId)||this.checkRetry(t))}},{key:"allSubtitleTracks",get:function(){return this.tracks}},{key:"subtitleTracks",get:function(){return this.tracksInGroup}},{key:"subtitleTrack",get:function(){return this.trackId},set:function(e){this.selectDefaultTrack=!1,this.setSubtitleTrack(e)}},{key:"setSubtitleOption",value:function(e){if(this.hls.config.subtitlePreference=e,e){if(-1===e.id)return this.setSubtitleTrack(-1),null;var t=this.allSubtitleTracks;if(this.selectDefaultTrack=!1,t.length){var n=this.currentTrack;if(n&&sW(e,n))return n;var i=oW(e,this.tracksInGroup);if(i>-1){var a=this.tracksInGroup[i];return this.setSubtitleTrack(i),a}if(n)return null;var r=oW(e,t);if(r>-1)return t[r]}}return null}},{key:"loadPlaylist",value:function(e){T(t,"loadPlaylist",this)([]),this.shouldLoadPlaylist(this.currentTrack)&&this.scheduleLoading(this.currentTrack,e)}},{key:"loadingPlaylist",value:function(e,n){T(t,"loadingPlaylist",this)([e,n]);var i=e.id,a=e.groupId,r=this.getUrlWithDirectives(e.url,n),o=e.details,s=null==o?void 0:o.age;this.log(`Loading subtitle ${i} "${e.name}" lang:${e.lang} group:${a}${void 0!==(null==n?void 0:n.msn)?" at sn "+n.msn+" part "+n.part:""}${s&&o.live?" age "+s.toFixed(1)+(o.type&&" "+o.type||""):""} ${r}`),this.hls.trigger(m$.SUBTITLE_TRACK_LOADING,{url:r,id:i,groupId:a,deliveryDirectives:n||null,track:e})}},{key:"toggleTrackModes",value:function(){var e=this.media;if(e){var t,n=NH(e.textTracks),i=this.currentTrack;if(i&&((t=n.filter(e=>kU(i,e))[0])||this.warn(`Unable to find subtitle TextTrack with name "${i.name}" and language "${i.lang}"`)),[].slice.call(n).forEach(e=>{"disabled"!==e.mode&&e!==t&&(e.mode="disabled")}),t){var a=this.subtitleDisplay?"showing":"hidden";t.mode!==a&&(t.mode=a)}}}},{key:"setSubtitleTrack",value:function(e){var t=this.tracksInGroup;if(this.media)if(e<-1||e>=t.length||!u$(e))this.warn(`Invalid subtitle track id: ${e}`);else{this.selectDefaultTrack=!1;var n=this.currentTrack,i=t[e]||null;if(this.trackId=e,this.currentTrack=i,this.toggleTrackModes(),i){var a=!!i.details&&!i.details.live;if(e!==this.trackId||i!==n||!a){this.log(`Switching to subtitle-track ${e}`+(i?` "${i.name}" lang:${i.lang} group:${i.groupId}`:""));var r=i.id,o=i.groupId,s=void 0===o?"":o,u=i.name,l=i.type,d=i.url;this.hls.trigger(m$.SUBTITLE_TRACK_SWITCH,{id:r,groupId:s,name:u,type:l,url:d});var c=this.switchParams(i.url,null==n?void 0:n.details,i.details);this.loadPlaylist(c)}}else this.hls.trigger(m$.SUBTITLE_TRACK_SWITCH,{id:e})}else this.queuedDefaultTrack=e}}])}(yU);function jH(e){for(var t=5381,n=e.length;n;)t=33*t^e.charCodeAt(--n);return(t>>>0).toString()}var BH=.025,zH=function(e){return e[e.Point=0]="Point",e[e.Range=1]="Range",e}({});function UH(e,t,n){return`${e.identifier}-${n+1}-${jH(t)}`}var HH=function(){return c(function e(t,n){o(this,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=n,this.dateRange=t,this.setDateRange(t)},[{key:"setDateRange",value:function(e){this.dateRange=e,this.resumeOffset=e.attr.optionalFloat("X-RESUME-OFFSET",this.resumeOffset),this.playoutLimit=e.attr.optionalFloat("X-PLAYOUT-LIMIT",this.playoutLimit),this.restrictions=e.attr.enumeratedStringList("X-RESTRICT",this.restrictions),this.snapOptions=e.attr.enumeratedStringList("X-SNAP",this.snapOptions)}},{key:"reset",value:function(){var e;this.appendInPlaceStarted=!1,null==(e=this.assetListLoader)||e.destroy(),this.assetListLoader=void 0,this.supplementsPrimary||(this.assetListResponse=null,this.assetList=[],this._duration=null)}},{key:"isAssetPastPlayoutLimit",value:function(e){var t;if(e>0&&e>=this.assetList.length)return!0;var n=this.playoutLimit;return!(e<=0||isNaN(n))&&(0===n||((null==(t=this.assetList[e])?void 0:t.startOffset)||0)>n)}},{key:"findAssetIndex",value:function(e){return this.assetList.indexOf(e)}},{key:"identifier",get:function(){return this.dateRange.id}},{key:"startDate",get:function(){return this.dateRange.startDate}},{key:"startTime",get:function(){var e=this.dateRange.startTime;if(this.snapOptions.out){var t=this.dateRange.tagAnchor;if(t)return GH(e,t)}return e}},{key:"startOffset",get:function(){return this.cue.pre?0:this.startTime}},{key:"startIsAligned",get:function(){if(0===this.startTime||this.snapOptions.out)return!0;var e=this.dateRange.tagAnchor;if(e){var t=this.dateRange.startTime;return t-GH(t,e)<.1}return!1}},{key:"resumptionOffset",get:function(){var e=this.resumeOffset,t=u$(e)?e:this.duration;return this.cumulativeDuration+t}},{key:"resumeTime",get:function(){var e=this.startOffset+this.resumptionOffset;if(this.snapOptions.in){var t=this.resumeAnchor;if(t)return GH(e,t)}return e}},{key:"appendInPlace",get:function(){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)<BH))},set:function(e){this.appendInPlaceStarted?this.resetOnResume=!e:this.appendInPlaceDisabled=!e}},{key:"timelineStart",get:function(){return null!==this._timelineStart?this._timelineStart:this.startTime},set:function(e){this._timelineStart=e}},{key:"duration",get:function(){var e,t=this.playoutLimit;return e=null!==this._duration?this._duration:this.dateRange.duration?this.dateRange.duration:this.dateRange.plannedDuration||0,!isNaN(t)&&t<e&&(e=t),e},set:function(e){this._duration=e}},{key:"cue",get:function(){return this.dateRange.cue}},{key:"timelineOccupancy",get:function(){return"RANGE"===this.dateRange.attr["X-TIMELINE-OCCUPIES"]?zH.Range:zH.Point}},{key:"supplementsPrimary",get:function(){return"PRIMARY"===this.dateRange.attr["X-TIMELINE-STYLE"]}},{key:"contentMayVary",get:function(){return"NO"!==this.dateRange.attr["X-CONTENT-MAY-VARY"]}},{key:"assetUrl",get:function(){return this.dateRange.attr["X-ASSET-URI"]}},{key:"assetListUrl",get:function(){return this.dateRange.attr["X-ASSET-LIST"]}},{key:"baseUrl",get:function(){return this.base.url}},{key:"assetListLoaded",get:function(){return this.assetList.length>0||null!==this.assetListResponse}},{key:"toString",value:function(){return`["${(e=this).identifier}" ${e.cue.pre?"<pre>":e.cue.post?"<post>":""}${e.timelineStart.toFixed(2)}-${e.resumeTime.toFixed(2)}]`;var e}}])}();function GH(e,t){return e-t.start<t.duration/2&&!(Math.abs(e-(t.start+t.duration))<BH)?t.start:t.start+t.duration}function VH(e,t,n){var i=new self.URL(e,n);return"data:"!==i.protocol&&i.searchParams.set("_HLS_primary_id",t),i}function KH(e,t){for(;null!=(n=e.assetList[++t])&&n.error;)var n;return t}function XH(e){var t=e.timelineStart,n=e.duration||0;return`["${e.identifier}" ${t.toFixed(2)}-${(t+n).toFixed(2)}]`}var YH=function(){return c(function e(t,n,i,a){o(this,e),this.hls=void 0,this.interstitial=void 0,this.assetItem=void 0,this.tracks=null,this.hasDetails=!1,this.mediaAttached=null,this._currentTime=void 0,this._bufferedEosTime=void 0,this.checkPlayout=()=>{this.reachedPlayout(this.currentTime)&&this.hls&&this.hls.trigger(m$.PLAYOUT_LIMIT_REACHED,{})};var r=this.hls=new t(n);this.interstitial=i,this.assetItem=a;var s=()=>{this.hasDetails=!0};r.once(m$.LEVEL_LOADED,s),r.once(m$.AUDIO_TRACK_LOADED,s),r.once(m$.SUBTITLE_TRACK_LOADED,s),r.on(m$.MEDIA_ATTACHING,(e,{media:t})=>{this.removeMediaListeners(),this.mediaAttached=t,this.interstitial.playoutLimit&&(t.addEventListener("timeupdate",this.checkPlayout),this.appendInPlace&&r.on(m$.BUFFER_APPENDED,()=>{var e=this.bufferedEnd;this.reachedPlayout(e)&&(this._bufferedEosTime=e,r.trigger(m$.BUFFERED_TO_END,void 0))}))})},[{key:"appendInPlace",get:function(){return this.interstitial.appendInPlace}},{key:"loadSource",value:function(){var e=this.hls;if(e)if(e.url)e.levels.length&&!e.started&&e.startLoad(-1,!0);else{var t=this.assetItem.uri;try{t=VH(t,e.config.primarySessionId||"").href}catch(e){}e.loadSource(t)}}},{key:"bufferedInPlaceToEnd",value:function(e){var t;if(!this.appendInPlace)return!1;if(null!=(t=this.hls)&&t.bufferedToEnd)return!0;if(!e)return!1;var n=Math.min(this._bufferedEosTime||1/0,this.duration),i=this.timelineOffset,a=ij.bufferInfo(e,i,0);return this.getAssetTime(a.end)>=n-.02}},{key:"reachedPlayout",value:function(e){var t=this.interstitial.playoutLimit;return this.startOffset+e>=t}},{key:"destroyed",get:function(){var e;return!(null!=(e=this.hls)&&e.userConfig)}},{key:"assetId",get:function(){return this.assetItem.identifier}},{key:"interstitialId",get:function(){return this.assetItem.parentIdentifier}},{key:"media",get:function(){var e;return(null==(e=this.hls)?void 0:e.media)||null}},{key:"bufferedEnd",get:function(){var e=this.media||this.mediaAttached;if(!e)return this._bufferedEosTime?this._bufferedEosTime:this.currentTime;var t=ij.bufferInfo(e,e.currentTime,.001);return this.getAssetTime(t.end)}},{key:"currentTime",get:function(){var e=this.media||this.mediaAttached;return e?this.getAssetTime(e.currentTime):this._currentTime||0}},{key:"duration",get:function(){var e=this.assetItem.duration;if(!e)return 0;var t=this.interstitial.playoutLimit;if(t){var n=t-this.startOffset;if(n>0&&n<e)return n}return e}},{key:"remaining",get:function(){var e=this.duration;return e?Math.max(0,e-this.currentTime):0}},{key:"startOffset",get:function(){return this.assetItem.startOffset}},{key:"timelineOffset",get:function(){var e;return(null==(e=this.hls)?void 0:e.config.timelineOffset)||0},set:function(e){var t=this.timelineOffset;if(e!==t){var n=e-t;if(Math.abs(n)>1/9e4&&this.hls){if(this.hasDetails)throw new Error("Cannot set timelineOffset after playlists are loaded");this.hls.config.timelineOffset=e}}}},{key:"getAssetTime",value:function(e){var t=this.timelineOffset,n=this.duration;return Math.min(Math.max(0,e-t),n)}},{key:"removeMediaListeners",value:function(){var e=this.mediaAttached;e&&(this._currentTime=e.currentTime,this.bufferSnapShot(),e.removeEventListener("timeupdate",this.checkPlayout))}},{key:"bufferSnapShot",value:function(){var e;this.mediaAttached&&(null!=(e=this.hls)&&e.bufferedToEnd&&(this._bufferedEosTime=this.bufferedEnd))}},{key:"destroy",value:function(){this.removeMediaListeners(),this.hls&&this.hls.destroy(),this.hls=null,this.tracks=this.mediaAttached=this.checkPlayout=null}},{key:"attachMedia",value:function(e){var t;this.loadSource(),null==(t=this.hls)||t.attachMedia(e)}},{key:"detachMedia",value:function(){var e;this.removeMediaListeners(),this.mediaAttached=null,null==(e=this.hls)||e.detachMedia()}},{key:"resumeBuffering",value:function(){var e;null==(e=this.hls)||e.resumeBuffering()}},{key:"pauseBuffering",value:function(){var e;null==(e=this.hls)||e.pauseBuffering()}},{key:"transferMedia",value:function(){var e;return this.bufferSnapShot(),(null==(e=this.hls)?void 0:e.transferMedia())||null}},{key:"resetDetails",value:function(){var e=this.hls;if(e&&this.hasDetails){e.stopLoad();var t=e=>delete e.details;e.levels.forEach(t),e.allAudioTracks.forEach(t),e.allSubtitleTracks.forEach(t),this.hasDetails=!1}}},{key:"on",value:function(e,t,n){var i;null==(i=this.hls)||i.on(e,t)}},{key:"once",value:function(e,t,n){var i;null==(i=this.hls)||i.once(e,t)}},{key:"off",value:function(e,t,n){var i;null==(i=this.hls)||i.off(e,t)}},{key:"toString",value:function(){var e;return`HlsAssetPlayer: ${XH(this.assetItem)} ${null==(e=this.hls)?void 0:e.sessionId} ${this.appendInPlace?"append-in-place":""}`}}])}(),qH=function(e){function t(e,n){var i;return o(this,t),(i=r(this,t,["interstitials-sched",n])).onScheduleUpdate=void 0,i.eventMap={},i.events=null,i.items=null,i.durations={primary:0,playout:0,integrated:0},i.onScheduleUpdate=e,i}return p(t,e),c(t,[{key:"destroy",value:function(){this.reset(),this.onScheduleUpdate=null}},{key:"reset",value:function(){this.eventMap={},this.setDurations(0,0,0),this.events&&this.events.forEach(e=>e.reset()),this.events=this.items=null}},{key:"resetErrorsInRange",value:function(e,t){return this.events?this.events.reduce((n,i)=>e<=i.startOffset&&t>i.startOffset?(delete i.error,n+1):n,0):0}},{key:"duration",get:function(){var e=this.items;return e?e[e.length-1].end:0}},{key:"length",get:function(){return this.items?this.items.length:0}},{key:"getEvent",value:function(e){return e&&this.eventMap[e]||null}},{key:"hasEvent",value:function(e){return e in this.eventMap}},{key:"findItemIndex",value:function(e,t){if(e.event)return this.findEventIndex(e.event.identifier);var n=-1;e.nextEvent?n=this.findEventIndex(e.nextEvent.identifier)-1:e.previousEvent&&(n=this.findEventIndex(e.previousEvent.identifier)+1);var i=this.items;if(i)for(i[n]||(void 0===t&&(t=e.start),n=this.findItemIndexAtTime(t));n>=0&&null!=(a=i[n])&&a.event;){var a;n--}return n}},{key:"findItemIndexAtTime",value:function(e,t){var n=this.items;if(n)for(var i=0;i<n.length;i++){var a=n[i];if(t&&"primary"!==t&&(a=a[t]),e===a.start||e>a.start&&e<a.end)return i}return-1}},{key:"findJumpRestrictedIndex",value:function(e,t){var n=this.items;if(n)for(var i=e;i<=t&&n[i];i++){var a=n[i].event;if(null!=a&&a.restrictions.jump&&!a.appendInPlace)return i}return-1}},{key:"findEventIndex",value:function(e){var t=this.items;if(t)for(var n=t.length;n--;){var i;if((null==(i=t[n].event)?void 0:i.identifier)===e)return n}return-1}},{key:"findAssetIndex",value:function(e,t){var n=e.assetList,i=n.length;if(i>1)for(var a=0;a<i;a++){var r=n[a];if(!r.error){var o=r.timelineStart;if(t===o||t>o&&(t<o+(r.duration||0)||a===i-1))return a}}return 0}},{key:"assetIdAtEnd",get:function(){var e,t=null==(e=this.items)||null==(e=e[this.length-1])?void 0:e.event;if(t){var n=t.assetList,i=n[n.length-1];if(i)return i.identifier}return null}},{key:"parseInterstitialDateRanges",value:function(e,t){var n=e.main.details,i=n.dateRanges,a=this.events,r=this.parseDateRanges(i,{url:n.url},t),o=Object.keys(i),s=a?a.filter(e=>!o.includes(e.identifier)):[];r.length&&r.sort((e,t)=>{var n=e.cue.pre,i=e.cue.post,a=t.cue.pre,r=t.cue.post;if(n&&!a)return-1;if(a&&!n)return 1;if(i&&!r)return 1;if(r&&!i)return-1;if(!(n||a||i||r)){var o=e.startTime,s=t.startTime;if(o!==s)return o-s}return e.dateRange.tagOrder-t.dateRange.tagOrder}),this.events=r,s.forEach(e=>{this.removeEvent(e)}),this.updateSchedule(e,s)}},{key:"updateSchedule",value:function(e,t=[],n=!1){var i=this.events||[];if(i.length||t.length||this.length<2){var a=this.items,r=this.parseSchedule(i,e),o=n||t.length||(null==a?void 0:a.length)!==r.length||r.some((e,t)=>Math.abs(e.playout.start-a[t].playout.start)>.005||Math.abs(e.playout.end-a[t].playout.end)>.005);o&&(this.items=r,this.onScheduleUpdate(t,a))}}},{key:"parseDateRanges",value:function(e,t,n){for(var i=[],a=Object.keys(e),r=0;r<a.length;r++){var o=a[r],s=e[o];if(s.isInterstitial){var u=this.eventMap[o];u?u.setDateRange(s):(u=new HH(s,t),this.eventMap[o]=u,!1===n&&(u.appendInPlace=n)),i.push(u)}}return i}},{key:"parseSchedule",value:function(e,t){var n=[],i=t.main.details,a=i.live?1/0:i.edge,r=0;if((e=e.filter(e=>!(e.error||e.cue.once&&e.hasPlayed))).length){this.resolveOffsets(e,t);var o=0,s=0;if(e.forEach((t,i)=>{var u=t.cue.pre,l=t.cue.post,d=e[i-1]||null,c=t.appendInPlace,h=l?a:t.startOffset,m=t.duration,f=t.timelineOccupancy===zH.Range?m:0,v=t.resumptionOffset,p=(null==d?void 0:d.startTime)===h,g=h+t.cumulativeDuration,y=c?g+m:h+v;if(u||!l&&h<=0){var b=s;s+=f,t.timelineStart=g;var w=r;r+=m,n.push({event:t,start:g,end:y,playout:{start:w,end:r},integrated:{start:b,end:s}})}else{if(!(h<=a))return;if(!p){var k=h-o;if(k>.033){var S=o,E=s;s+=k;var P=r;r+=k;var T={previousEvent:e[i-1]||null,nextEvent:t,start:S,end:S+k,playout:{start:P,end:r},integrated:{start:E,end:s}};n.push(T)}else k>0&&d&&(d.cumulativeDuration+=k,n[n.length-1].end=h)}l&&(y=g),t.timelineStart=g;var _=s;s+=f;var M=r;r+=m,n.push({event:t,start:g,end:y,playout:{start:M,end:r},integrated:{start:_,end:s}})}var A=t.resumeTime;o=l||A>a?a:A}),o<a){var u,l=o,d=s,c=a-o;s+=c;var h=r;r+=c,n.push({previousEvent:(null==(u=n[n.length-1])?void 0:u.event)||null,nextEvent:null,start:o,end:l+c,playout:{start:h,end:r},integrated:{start:d,end:s}})}this.setDurations(a,r,s)}else{n.push({previousEvent:null,nextEvent:null,start:0,end:a,playout:{start:0,end:a},integrated:{start:0,end:a}}),this.setDurations(a,a,a)}return n}},{key:"setDurations",value:function(e,t,n){this.durations={primary:e,playout:t,integrated:n}}},{key:"resolveOffsets",value:function(e,t){var n=t.main.details,i=n.live?1/0:n.edge,a=0,r=-1;e.forEach((o,s)=>{var u=o.cue.pre,l=o.cue.post,d=u?0:l?i:o.startTime;(this.updateAssetDurations(o),r===d?o.cumulativeDuration=a:(a=0,r=d),!l&&o.snapOptions.in&&(o.resumeAnchor=mW(null,n.fragments,o.startOffset+o.resumptionOffset,0,0)||void 0),o.appendInPlace&&!o.appendInPlaceStarted)&&(this.primaryCanResumeInPlaceAt(o,t)||(o.appendInPlace=!1));!o.appendInPlace&&s+1<e.length&&(e[s+1].startTime-e[s].resumeTime<.033&&(e[s+1].appendInPlace=!1,e[s+1].appendInPlace&&this.warn(`Could not change append strategy for abutting event ${o}`)));var c=u$(o.resumeOffset)?o.resumeOffset:o.duration;a+=c})}},{key:"primaryCanResumeInPlaceAt",value:function(e,t){var n=e.resumeTime,i=e.startTime+e.resumptionOffset;return Math.abs(n-i)>BH?(this.log(`"${e.identifier}" resumption ${n} not aligned with estimated timeline end ${i}`),!1):!Object.keys(t).some(i=>{var a=t[i].details,r=a.edge;if(n>=r)return this.log(`"${e.identifier}" resumption ${n} past ${i} playlist end ${r}`),!1;var o=mW(null,a.fragments,n);if(!o)return this.log(`"${e.identifier}" resumption ${n} does not align with any fragments in ${i} playlist (${a.fragStart}-${a.fragmentEnd})`),!0;var s="audio"===i?.175:0;return!(Math.abs(o.start-n)<BH+s||Math.abs(o.end-n)<BH+s)&&(this.log(`"${e.identifier}" resumption ${n} not aligned with ${i} fragment bounds (${o.start}-${o.end} sn: ${o.sn} cc: ${o.cc})`),!0)})}},{key:"updateAssetDurations",value:function(e){if(e.assetListLoaded){for(var t=e.timelineStart,n=0,i=!1,a=!1,r=0;r<e.assetList.length;r++){var o=e.assetList[r],s=t+n;o.startOffset=n,o.timelineStart=s,i||(i=null===o.duration),a||(a=!!o.error),n+=o.error?0:o.duration||0}e.duration=i&&!a?Math.max(n,e.duration):n}}},{key:"removeEvent",value:function(e){e.reset(),delete this.eventMap[e.identifier]}}])}(M$);function JH(e){return`[${e.event?'"'+e.event.identifier+'"':"primary"}: ${e.start.toFixed(2)}-${e.end.toFixed(2)}]`}var QH=function(){return c(function e(t){o(this,e),this.hls=void 0,this.hls=t},[{key:"destroy",value:function(){this.hls=null}},{key:"loadAssetList",value:function(e,t){var n,i=e.assetListUrl;try{n=VH(i,this.hls.sessionId,e.baseUrl)}catch(t){var a=this.assignAssetListError(e,h$.ASSET_LIST_LOAD_ERROR,t,i);return void this.hls.trigger(m$.ERROR,a)}t&&"data:"!==n.protocol&&n.searchParams.set("_HLS_start_offset",""+t);var r=this.hls.config,o=new(0,r.loader)(r),s={responseType:"json",url:n.href},u=r.interstitialAssetListLoadPolicy.default,l={loadPolicy:u,timeout:u.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},d={onSuccess:(t,n,i,a)=>{var r=t.data,o=null==r?void 0:r.ASSETS;if(Array.isArray(o))e.assetListResponse=r,this.hls.trigger(m$.ASSET_LIST_LOADED,{event:e,assetListResponse:r,networkDetails:a});else{var s=this.assignAssetListError(e,h$.ASSET_LIST_PARSING_ERROR,new Error("Invalid interstitial asset list"),i.url,n,a);this.hls.trigger(m$.ERROR,s)}},onError:(t,n,i,a)=>{var r=this.assignAssetListError(e,h$.ASSET_LIST_LOAD_ERROR,new Error(`Error loading X-ASSET-LIST: HTTP status ${t.code} ${t.text} (${n.url})`),n.url,a,i);this.hls.trigger(m$.ERROR,r)},onTimeout:(t,n,i)=>{var a=this.assignAssetListError(e,h$.ASSET_LIST_LOAD_TIMEOUT,new Error(`Timeout loading X-ASSET-LIST (${n.url})`),n.url,t,i);this.hls.trigger(m$.ERROR,a)}};return o.load(s,l,d),this.hls.trigger(m$.ASSET_LIST_LOADING,{event:e}),o}},{key:"assignAssetListError",value:function(e,t,n,i,a,r){return e.error=n,{type:c$.NETWORK_ERROR,details:t,fatal:!1,interstitial:e,url:i,error:n,networkDetails:r,stats:a}}}])}();function ZH(e){var t;null==e||null==(t=e.play())||t.catch(()=>{})}function eG(e,t){return`[${e}] Advancing timeline position to ${t}`}var tG=function(e){function t(e,n){var i;return o(this,t),(i=r(this,t,["interstitials",e.logger])).HlsPlayerClass=void 0,i.hls=void 0,i.assetListLoader=void 0,i.mediaSelection=null,i.altSelection=null,i.media=null,i.detachedData=null,i.requiredTracks=null,i.manager=null,i.playerQueue=[],i.bufferedPos=-1,i.timelinePos=-1,i.schedule=void 0,i.playingItem=null,i.bufferingItem=null,i.waitingItem=null,i.endedItem=null,i.playingAsset=null,i.endedAsset=null,i.bufferingAsset=null,i.shouldPlay=!1,i.onPlay=()=>{i.shouldPlay=!0},i.onPause=()=>{i.shouldPlay=!1},i.onSeeking=()=>{var e=i.currentTime;if(void 0!==e&&!i.playbackDisabled&&i.schedule){var t=e-i.timelinePos;if(!(Math.abs(t)<1/7056e5)){var n=t<=-.01;-1!==i.timelinePos||i.effectivePlayingItem||i.checkStart(),i.timelinePos=e,i.bufferedPos=e;var a=i.playingItem;if(a){if(n)i.schedule.resetErrorsInRange(e,e-t)&&i.updateSchedule(!0);if(i.checkBuffer(),n&&e<a.start||e>=a.end){var r,o=i.findItemIndex(a),s=i.schedule.findItemIndexAtTime(e);if(-1===s&&(s=o+(n?-1:1),i.log(`seeked ${n?"back ":""}to position not covered by schedule ${e} (resolving from ${o} to ${s})`)),!i.isInterstitial(a)&&null!=(r=i.media)&&r.paused&&(i.shouldPlay=!1),!n&&s>o){var u=i.schedule.findJumpRestrictedIndex(o+1,s);if(u>o)return void i.setSchedulePosition(u)}i.setSchedulePosition(s)}else{var l=i.playingAsset;if(l){var d,c=l.timelineStart,h=l.duration||0;if(n&&e<c||e>=c+h)null!=(d=a.event)&&d.appendInPlace&&(i.clearAssetPlayers(a.event,a),i.flushFrontBuffer(e)),i.setScheduleToAssetAtTime(e,l)}else if(i.playingLastItem&&i.isInterstitial(a)){var m=a.event.assetList[0];m&&(i.endedItem=i.playingItem,i.playingItem=null,i.setScheduleToAssetAtTime(e,m))}}}else i.checkBuffer()}}},i.onTimeupdate=()=>{var e=i.currentTime;if(void 0!==e&&!i.playbackDisabled&&(-1!==i.timelinePos||i.effectivePlayingItem||i.checkStart(),e>i.timelinePos)){i.timelinePos=e,e>i.bufferedPos&&i.checkBuffer();var t=i.playingItem;if(t&&!i.playingLastItem){if(e>=t.end){i.timelinePos=t.end;var n=i.findItemIndex(t);i.setSchedulePosition(n+1)}var a=i.playingAsset;if(a)e>=a.timelineStart+(a.duration||0)&&i.setScheduleToAssetAtTime(e,a)}}},i.onScheduleUpdate=(e,t)=>{var n=i.schedule;if(n){var a=i.playingItem,r=n.events||[],o=n.items||[],s=n.durations,u=e.map(e=>e.identifier),l=!(!r.length&&!u.length);(l||t)&&i.log(`INTERSTITIALS_UPDATED (${r.length}): ${r}\nSchedule: ${o.map(e=>JH(e))} pos: ${i.timelinePos}`),u.length&&i.log(`Removed events ${u}`);var d=null,c=null;a&&(d=i.updateItem(a,i.timelinePos),i.itemsMatch(a,d)?i.playingItem=d:i.waitingItem=i.endedItem=null),i.waitingItem=i.updateItem(i.waitingItem),i.endedItem=i.updateItem(i.endedItem);var h=i.bufferingItem;if(h&&(c=i.updateItem(h,i.bufferedPos),i.itemsMatch(h,c)?i.bufferingItem=c:h.event&&(i.bufferingItem=i.playingItem,i.clearInterstitial(h.event,null))),e.forEach(e=>{e.assetList.forEach(e=>{i.clearAssetPlayer(e.identifier,null)})}),i.playerQueue.forEach(e=>{if(e.interstitial.appendInPlace){var t=e.assetItem.timelineStart,n=e.timelineOffset-t;if(n)try{e.timelineOffset=t}catch(a){Math.abs(n)>BH&&i.warn(`${a} ("${e.assetId}" ${e.timelineOffset}->${t})`)}}}),l||t){if(i.hls.trigger(m$.INTERSTITIALS_UPDATED,{events:r.slice(0),schedule:o.slice(0),durations:s,removedIds:u}),i.isInterstitial(a)&&u.includes(a.event.identifier))return i.warn(`Interstitial "${a.event.identifier}" removed while playing`),void i.primaryFallback(a.event);a&&i.trimInPlace(d,a),h&&c!==d&&i.trimInPlace(c,h),i.checkBuffer()}}},i.hls=e,i.HlsPlayerClass=n,i.assetListLoader=new QH(e),i.schedule=new qH(i.onScheduleUpdate,e.logger),i.registerListeners(),i}return p(t,e),c(t,[{key:"registerListeners",value:function(){var e=this.hls;e&&(e.on(m$.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(m$.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(m$.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(m$.MANIFEST_LOADING,this.onManifestLoading,this),e.on(m$.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(m$.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(m$.AUDIO_TRACK_UPDATED,this.onAudioTrackUpdated,this),e.on(m$.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(m$.SUBTITLE_TRACK_UPDATED,this.onSubtitleTrackUpdated,this),e.on(m$.EVENT_CUE_ENTER,this.onInterstitialCueEnter,this),e.on(m$.ASSET_LIST_LOADED,this.onAssetListLoaded,this),e.on(m$.BUFFER_APPENDED,this.onBufferAppended,this),e.on(m$.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(m$.BUFFERED_TO_END,this.onBufferedToEnd,this),e.on(m$.MEDIA_ENDED,this.onMediaEnded,this),e.on(m$.ERROR,this.onError,this),e.on(m$.DESTROYING,this.onDestroying,this))}},{key:"unregisterListeners",value:function(){var e=this.hls;e&&(e.off(m$.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(m$.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(m$.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(m$.MANIFEST_LOADING,this.onManifestLoading,this),e.off(m$.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(m$.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(m$.AUDIO_TRACK_UPDATED,this.onAudioTrackUpdated,this),e.off(m$.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(m$.SUBTITLE_TRACK_UPDATED,this.onSubtitleTrackUpdated,this),e.off(m$.EVENT_CUE_ENTER,this.onInterstitialCueEnter,this),e.off(m$.ASSET_LIST_LOADED,this.onAssetListLoaded,this),e.off(m$.BUFFER_CODECS,this.onBufferCodecs,this),e.off(m$.BUFFER_APPENDED,this.onBufferAppended,this),e.off(m$.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(m$.BUFFERED_TO_END,this.onBufferedToEnd,this),e.off(m$.MEDIA_ENDED,this.onMediaEnded,this),e.off(m$.ERROR,this.onError,this),e.off(m$.DESTROYING,this.onDestroying,this))}},{key:"startLoad",value:function(){this.resumeBuffering()}},{key:"stopLoad",value:function(){this.pauseBuffering()}},{key:"resumeBuffering",value:function(){var e;null==(e=this.getBufferingPlayer())||e.resumeBuffering()}},{key:"pauseBuffering",value:function(){var e;null==(e=this.getBufferingPlayer())||e.pauseBuffering()}},{key:"destroy",value:function(){this.unregisterListeners(),this.stopLoad(),this.assetListLoader&&this.assetListLoader.destroy(),this.emptyPlayerQueue(),this.clearScheduleState(),this.schedule&&this.schedule.destroy(),this.media=this.detachedData=this.mediaSelection=this.requiredTracks=this.altSelection=this.schedule=this.manager=null,this.hls=this.HlsPlayerClass=this.log=null,this.assetListLoader=null,this.onPlay=this.onPause=this.onSeeking=this.onTimeupdate=null,this.onScheduleUpdate=null}},{key:"onDestroying",value:function(){var e=this.primaryMedia||this.media;e&&this.removeMediaListeners(e)}},{key:"removeMediaListeners",value:function(e){kB(e,"play",this.onPlay),kB(e,"pause",this.onPause),kB(e,"seeking",this.onSeeking),kB(e,"timeupdate",this.onTimeupdate)}},{key:"onMediaAttaching",value:function(e,t){var n=this.media=t.media;wB(n,"seeking",this.onSeeking),wB(n,"timeupdate",this.onTimeupdate),wB(n,"play",this.onPlay),wB(n,"pause",this.onPause)}},{key:"onMediaAttached",value:function(e,t){var n=this.effectivePlayingItem,i=this.detachedData;if(this.detachedData=null,null===n)this.checkStart();else if(!i){this.clearScheduleState();var a=this.findItemIndex(n);this.setSchedulePosition(a)}}},{key:"clearScheduleState",value:function(){this.log("clear schedule state"),this.playingItem=this.bufferingItem=this.waitingItem=this.endedItem=this.playingAsset=this.endedAsset=this.bufferingAsset=null}},{key:"onMediaDetaching",value:function(e,t){var n=!!t.transferMedia,i=this.media;if(this.media=null,!n&&(i&&this.removeMediaListeners(i),this.detachedData)){var a=this.getBufferingPlayer();a&&(this.log(`Removing schedule state for detachedData and ${a}`),this.playingAsset=this.endedAsset=this.bufferingAsset=this.bufferingItem=this.waitingItem=this.detachedData=null,a.detachMedia()),this.shouldPlay=!1}}},{key:"interstitialsManager",get:function(){if(!this.hls)return null;if(this.manager)return this.manager;var e=this,t=()=>e.bufferingItem||e.waitingItem,n=t=>t?e.getAssetPlayer(t.identifier):t,i=(t,i,r,o,s)=>{if(t){var u=t[i].start,l=t.event;if(l){if("playout"===i||l.timelineOccupancy!==zH.Point){var d=n(r);(null==d?void 0:d.interstitial)===l&&(u+=d.assetItem.startOffset+d[s])}}else u+=("bufferedPos"===o?a():e[o])-t.start;return u}return 0},a=()=>{var t=e.bufferedPos;return t===Number.MAX_VALUE?r("primary"):Math.max(t,0)},r=t=>{var n,i;return null!=(n=e.primaryDetails)&&n.live?e.primaryDetails.edge:(null==(i=e.schedule)?void 0:i.durations[t])||0},o=(t,a)=>{var r,o,s=e.effectivePlayingItem;if((null==s||null==(r=s.event)||!r.restrictions.skip)&&e.schedule){e.log(`seek to ${t} "${a}"`);var u=e.effectivePlayingItem,l=e.schedule.findItemIndexAtTime(t,a),d=null==(o=e.schedule.items)?void 0:o[l],c=e.getBufferingPlayer(),h=null==c?void 0:c.interstitial,m=null==h?void 0:h.appendInPlace,f=u&&e.itemsMatch(u,d);if(u&&(m||f)){var v=n(e.playingAsset),p=(null==v?void 0:v.media)||e.primaryMedia;if(p){var g="primary"===a?p.currentTime:i(u,a,e.playingAsset,"timelinePos","currentTime"),y=t-g,b=(m?g:p.currentTime)+y;if(b>=0&&(!v||m||b<=v.duration))return void(p.currentTime=b)}}if(d){var w=t;if("primary"!==a){var k=t-d[a].start;w=d.start+k}var S=!e.isInterstitial(d);if(e.isInterstitial(u)&&!u.event.appendInPlace||!S&&!d.event.appendInPlace){if(u){var E=e.findItemIndex(u);if(l>E){var P=e.schedule.findJumpRestrictedIndex(E+1,l);if(P>E)return void e.setSchedulePosition(P)}var T=0;if(S)e.timelinePos=w,e.checkBuffer();else for(var _=d.event.assetList,M=t-(d[a]||d).start,A=_.length;A--;){var D=_[A];if(D.duration&&M>=D.startOffset&&M<D.startOffset+D.duration){T=A;break}}e.setSchedulePosition(l,T)}}else{var x=e.media||(m?null==c?void 0:c.media:null);x&&(x.currentTime=w)}}}},s=()=>{var n=e.effectivePlayingItem;if(e.isInterstitial(n))return n;var i=t();return e.isInterstitial(i)?i:null},u={get bufferedEnd(){var n,a=t(),r=e.bufferingItem;return r&&r===a&&(i(r,"playout",e.bufferingAsset,"bufferedPos","bufferedEnd")-r.playout.start||(null==(n=e.bufferingAsset)?void 0:n.startOffset))||0},get currentTime(){var t=s(),n=e.effectivePlayingItem;return n&&n===t?i(n,"playout",e.effectivePlayingAsset,"timelinePos","currentTime")-n.playout.start:0},set currentTime(t){var n=s(),i=e.effectivePlayingItem;i&&i===n&&o(t+i.playout.start,"playout")},get duration(){var e=s();return e?e.playout.end-e.playout.start:0},get assetPlayers(){var t,n=null==(t=s())?void 0:t.event.assetList;return n?n.map(t=>e.getAssetPlayer(t.identifier)):[]},get playingIndex(){var t,n=null==(t=s())?void 0:t.event;return n&&e.effectivePlayingAsset?n.findAssetIndex(e.effectivePlayingAsset):-1},get scheduleItem(){return s()}};return this.manager={get events(){var t;return(null==(t=e.schedule)||null==(t=t.events)?void 0:t.slice(0))||[]},get schedule(){var t;return(null==(t=e.schedule)||null==(t=t.items)?void 0:t.slice(0))||[]},get interstitialPlayer(){return s()?u:null},get playerQueue(){return e.playerQueue.slice(0)},get bufferingAsset(){return e.bufferingAsset},get bufferingItem(){return t()},get bufferingIndex(){var n=t();return e.findItemIndex(n)},get playingAsset(){return e.effectivePlayingAsset},get playingItem(){return e.effectivePlayingItem},get playingIndex(){var t=e.effectivePlayingItem;return e.findItemIndex(t)},primary:{get bufferedEnd(){return a()},get currentTime(){var t=e.timelinePos;return t>0?t:0},set currentTime(e){o(e,"primary")},get duration(){return r("primary")},get seekableStart(){var t;return(null==(t=e.primaryDetails)?void 0:t.fragmentStart)||0}},integrated:{get bufferedEnd(){return i(t(),"integrated",e.bufferingAsset,"bufferedPos","bufferedEnd")},get currentTime(){return i(e.effectivePlayingItem,"integrated",e.effectivePlayingAsset,"timelinePos","currentTime")},set currentTime(e){o(e,"integrated")},get duration(){return r("integrated")},get seekableStart(){var t;return((t,n)=>{var i;if(0!==t&&"primary"!==n&&null!=(i=e.schedule)&&i.length){var a,r=e.schedule.findItemIndexAtTime(t),o=null==(a=e.schedule.items)?void 0:a[r];if(o)return t+(o[n].start-o.start)}return t})((null==(t=e.primaryDetails)?void 0:t.fragmentStart)||0,"integrated")}},skip:()=>{var t=e.effectivePlayingItem,n=null==t?void 0:t.event;if(n&&!n.restrictions.skip){var i=e.findItemIndex(t);if(n.appendInPlace){var a=t.playout.start+t.event.duration;o(a+.001,"playout")}else e.advanceAfterAssetEnded(n,i,1/0)}}}}},{key:"effectivePlayingItem",get:function(){return this.waitingItem||this.playingItem||this.endedItem}},{key:"effectivePlayingAsset",get:function(){return this.playingAsset||this.endedAsset}},{key:"playingLastItem",get:function(){var e,t=this.playingItem,n=null==(e=this.schedule)?void 0:e.items;return!!(this.playbackStarted&&t&&n)&&this.findItemIndex(t)===n.length-1}},{key:"playbackStarted",get:function(){return null!==this.effectivePlayingItem}},{key:"currentTime",get:function(){var e,t;if(null!==this.mediaSelection){var n=this.waitingItem||this.playingItem;if(!this.isInterstitial(n)||n.event.appendInPlace){var i=this.media;!i&&null!=(e=this.bufferingItem)&&null!=(e=e.event)&&e.appendInPlace&&(i=this.primaryMedia);var a=null==(t=i)?void 0:t.currentTime;if(void 0!==a&&u$(a))return a}}}},{key:"primaryMedia",get:function(){var e;return this.media||(null==(e=this.detachedData)?void 0:e.media)||null}},{key:"isInterstitial",value:function(e){return!(null==e||!e.event)}},{key:"retreiveMediaSource",value:function(e,t){var n=this.getAssetPlayer(e);n&&this.transferMediaFromPlayer(n,t)}},{key:"transferMediaFromPlayer",value:function(e,t){var n=e.interstitial.appendInPlace,i=e.media;if(n&&i===this.primaryMedia){if(this.bufferingAsset=null,(!t||this.isInterstitial(t)&&!t.event.appendInPlace)&&t&&i)return void(this.detachedData={media:i});var a=e.transferMedia();this.log(`transfer MediaSource from ${e} ${nW(a)}`),this.detachedData=a}else t&&i&&(this.shouldPlay||(this.shouldPlay=!i.paused))}},{key:"transferMediaTo",value:function(e,t){var n,i;if(e.media!==t){var a,r=null,o=this.hls,s=e!==o,u=s&&e.interstitial.appendInPlace,l=null==(n=this.detachedData)?void 0:n.mediaSource;if(o.media)u&&(r=o.transferMedia(),this.detachedData=r),a="Primary";else if(l){var d=this.getBufferingPlayer();d?(r=d.transferMedia(),a=`${d}`):a="detached MediaSource"}else a="detached media";if(!r)if(l)r=this.detachedData,this.log(`using detachedData: MediaSource ${nW(r)}`);else if(!this.detachedData||o.media===t){var c=this.playerQueue;c.length>1&&c.forEach(e=>{if(s&&e.interstitial.appendInPlace!==u){var t=e.interstitial;this.clearInterstitial(e.interstitial,null),t.appendInPlace=!1,t.appendInPlace&&this.warn(`Could not change append strategy for queued assets ${t}`)}}),this.hls.detachMedia(),this.detachedData={media:t}}var h=r&&"mediaSource"in r&&"closed"!==(null==(i=r.mediaSource)?void 0:i.readyState),m=h&&r?r:t;this.log(`${h?"transfering MediaSource":"attaching media"} to ${s?e:"Primary"} from ${a} (media.currentTime: ${t.currentTime})`);var f=this.schedule;if(m===r&&f){var v=s&&e.assetId===f.assetIdAtEnd;m.overrides={duration:f.duration,endOfStream:!s||v,cueRemoval:!s}}e.attachMedia(m)}}},{key:"onInterstitialCueEnter",value:function(){this.onTimeupdate()}},{key:"checkStart",value:function(){var e=this.schedule,t=null==e?void 0:e.events;if(t&&!this.playbackDisabled&&this.media){-1===this.bufferedPos&&(this.bufferedPos=0);var n=this.timelinePos,i=this.effectivePlayingItem;if(-1===n){var a=this.hls.startPosition;if(this.timelinePos=a,0===t.length)this.setSchedulePosition(0);else if(t[0].cue.pre){this.log(eG("checkStart (preroll)",a));var r=e.findEventIndex(t[0].identifier);this.setSchedulePosition(r)}else if(a>=0||!this.primaryLive){this.log(eG("checkStart",a));var o=this.timelinePos=a>0?a:0,s=e.findItemIndexAtTime(o);this.setSchedulePosition(s)}else 0===this.hls.liveSyncPosition?this.setSchedulePosition(0):this.log("[checkStart] waiting for live start")}else if(i&&!this.playingItem){this.log(eG("checkStart (playing item)",i.start));var u=e.findItemIndex(i);this.setSchedulePosition(u)}}}},{key:"advanceAssetBuffering",value:function(e,t){var n=e.event,i=n.findAssetIndex(t),a=KH(n,i);if(n.isAssetPastPlayoutLimit(a)){if(this.schedule){var r,o=null==(r=this.schedule.items)?void 0:r[this.findItemIndex(e)+1];o&&this.bufferedToItem(o)}}else this.bufferedToEvent(e,a)}},{key:"advanceAfterAssetEnded",value:function(e,t,n){var i=KH(e,n);if(e.isAssetPastPlayoutLimit(i)){if(this.schedule){var a=this.schedule.items;if(a){var r=t+1;if(r>=a.length)return void this.setSchedulePosition(-1);var o=e.resumeTime;this.timelinePos<o&&(this.log(eG("advanceAfterAssetEnded",o)),this.timelinePos=o,e.appendInPlace&&this.advanceInPlace(o),this.checkBuffer(this.bufferedPos<o)),this.setSchedulePosition(r)}}}else{if(e.appendInPlace){var s=e.assetList[i];s&&this.advanceInPlace(s.timelineStart)}this.setSchedulePosition(t,i)}}},{key:"setScheduleToAssetAtTime",value:function(e,t){var n=this.schedule;if(n){var i=t.parentIdentifier,a=n.getEvent(i);if(a){var r=n.findEventIndex(i),o=n.findAssetIndex(a,e);this.advanceAfterAssetEnded(a,r,o-1)}}}},{key:"setSchedulePosition",value:function(e,t){var n,i=null==(n=this.schedule)?void 0:n.items;if(i&&!this.playbackDisabled){var a=e>=0?i[e]:null;this.log(`setSchedulePosition ${e}, ${t} (${a?JH(a):a}) pos: ${this.timelinePos}`);var r=this.waitingItem||this.playingItem,o=this.playingLastItem;if(this.isInterstitial(r)){var s=r.event,u=this.playingAsset,l=null==u?void 0:u.identifier,d=l?this.getAssetPlayer(l):null;if(d&&l&&(!this.eventItemsMatch(r,a)||void 0!==t&&l!==s.assetList[t].identifier)){var c,h=s.findAssetIndex(u);if(this.log(`INTERSTITIAL_ASSET_ENDED ${h+1}/${s.assetList.length} ${XH(u)}`),this.endedAsset=u,this.playingAsset=null,this.hls.trigger(m$.INTERSTITIAL_ASSET_ENDED,{asset:u,assetListIndex:h,event:s,schedule:i.slice(0),scheduleIndex:e,player:d}),r!==this.playingItem)return void(this.itemsMatch(r,this.playingItem)&&!this.playingAsset&&this.advanceAfterAssetEnded(s,this.findItemIndex(this.playingItem),h));this.retreiveMediaSource(l,a),!d.media||null!=(c=this.detachedData)&&c.mediaSource||d.detachMedia()}if(!this.eventItemsMatch(r,a)&&(this.endedItem=r,this.playingItem=null,this.log(`INTERSTITIAL_ENDED ${s} ${JH(r)}`),s.hasPlayed=!0,this.hls.trigger(m$.INTERSTITIAL_ENDED,{event:s,schedule:i.slice(0),scheduleIndex:e}),s.cue.once)){var m;this.updateSchedule();var f=null==(m=this.schedule)?void 0:m.items;if(a&&f){var v=this.findItemIndex(a);this.advanceSchedule(v,f,t,r,o)}return}}this.advanceSchedule(e,i,t,r,o)}}},{key:"advanceSchedule",value:function(e,t,n,i,a){var r=this.schedule;if(r){var o=t[e]||null,s=this.primaryMedia,u=this.playerQueue;if(u.length&&u.forEach(t=>{var n=t.interstitial,i=r.findEventIndex(n.identifier);(i<e||i>e+1)&&this.clearInterstitial(n,o)}),this.isInterstitial(o)){this.timelinePos=Math.min(Math.max(this.timelinePos,o.start),o.end);var l=o.event;if(void 0===n){var d=KH(l,(n=r.findAssetIndex(l,this.timelinePos))-1);if(l.isAssetPastPlayoutLimit(d)||l.appendInPlace&&this.timelinePos===o.end)return void this.advanceAfterAssetEnded(l,e,n);n=d}var c=this.waitingItem;this.assetsBuffered(o,s)||this.setBufferingItem(o);var h=this.preloadAssets(l,n);if(this.eventItemsMatch(o,c||i)||(this.waitingItem=o,this.log(`INTERSTITIAL_STARTED ${JH(o)} ${l.appendInPlace?"append in place":""}`),this.hls.trigger(m$.INTERSTITIAL_STARTED,{event:l,schedule:t.slice(0),scheduleIndex:e})),!l.assetListLoaded)return void this.log(`Waiting for ASSET-LIST to complete loading ${l}`);if(l.assetListLoader&&(l.assetListLoader.destroy(),l.assetListLoader=void 0),!s)return void this.log(`Waiting for attachMedia to start Interstitial ${l}`);this.waitingItem=this.endedItem=null,this.playingItem=o;var m=l.assetList[n];if(!m)return void this.advanceAfterAssetEnded(l,e,n||0);if(h||(h=this.getAssetPlayer(m.identifier)),null===h||h.destroyed){var f=l.assetList.length;this.warn(`asset ${n+1}/${f} player destroyed ${l}`),(h=this.createAssetPlayer(l,m,n)).loadSource()}if(!this.eventItemsMatch(o,this.bufferingItem)&&l.appendInPlace&&this.isAssetBuffered(m))return;this.startAssetPlayer(h,n,t,e,s),this.shouldPlay&&ZH(h.media)}else o?(this.resumePrimary(o,e,i),this.shouldPlay&&ZH(this.hls.media)):a&&this.isInterstitial(i)&&(this.endedItem=null,this.playingItem=i,i.event.appendInPlace||this.attachPrimary(r.durations.primary,null))}}},{key:"playbackDisabled",get:function(){return!1===this.hls.config.enableInterstitialPlayback}},{key:"primaryDetails",get:function(){var e;return null==(e=this.mediaSelection)?void 0:e.main.details}},{key:"primaryLive",get:function(){var e;return!(null==(e=this.primaryDetails)||!e.live)}},{key:"resumePrimary",value:function(e,t,n){var i,a;if(this.playingItem=e,this.playingAsset=this.endedAsset=null,this.waitingItem=this.endedItem=null,this.bufferedToItem(e),this.log(`resuming ${JH(e)}`),null==(i=this.detachedData)||!i.mediaSource){var r=this.timelinePos;(r<e.start||r>=e.end)&&(r=this.getPrimaryResumption(e,t),this.log(eG("resumePrimary",r)),this.timelinePos=r),this.attachPrimary(r,e)}if(n){var o=null==(a=this.schedule)?void 0:a.items;o&&(this.log(`INTERSTITIALS_PRIMARY_RESUMED ${JH(e)}`),this.hls.trigger(m$.INTERSTITIALS_PRIMARY_RESUMED,{schedule:o.slice(0),scheduleIndex:t}),this.checkBuffer())}}},{key:"getPrimaryResumption",value:function(e,t){var n=e.start;if(this.primaryLive){var i=this.primaryDetails;if(0===t)return this.hls.startPosition;if(i&&(n<i.fragmentStart||n>i.edge))return this.hls.liveSyncPosition||-1}return n}},{key:"isAssetBuffered",value:function(e){var t=this.getAssetPlayer(e.identifier);return null!=t&&t.hls?t.hls.bufferedToEnd:ij.bufferInfo(this.primaryMedia,this.timelinePos,0).end+1>=e.timelineStart+(e.duration||0)}},{key:"attachPrimary",value:function(e,t,n){t?this.setBufferingItem(t):this.bufferingItem=this.playingItem,this.bufferingAsset=null;var i=this.primaryMedia;if(i){var a=this.hls;a.media?this.checkBuffer():(this.transferMediaTo(a,i),n&&this.startLoadingPrimaryAt(e,n)),n||(this.log(eG("attachPrimary",e)),this.timelinePos=e,this.startLoadingPrimaryAt(e,n))}}},{key:"startLoadingPrimaryAt",value:function(e,t){var n,i=this.hls;!i.loadingEnabled||!i.media||Math.abs(((null==(n=i.mainForwardBufferInfo)?void 0:n.start)||i.media.currentTime)-e)>.5?i.startLoad(e,t):i.bufferingEnabled||i.resumeBuffering()}},{key:"onManifestLoading",value:function(){var e;this.stopLoad(),null==(e=this.schedule)||e.reset(),this.emptyPlayerQueue(),this.clearScheduleState(),this.shouldPlay=!1,this.bufferedPos=this.timelinePos=-1,this.mediaSelection=this.altSelection=this.manager=this.requiredTracks=null,this.hls.off(m$.BUFFER_CODECS,this.onBufferCodecs,this),this.hls.on(m$.BUFFER_CODECS,this.onBufferCodecs,this)}},{key:"onLevelUpdated",value:function(e,t){if(-1!==t.level&&this.schedule){var n=this.hls.levels[t.level];if(n.details){var i=_$(_$({},this.mediaSelection||this.altSelection),{},{main:n});this.mediaSelection=i,this.schedule.parseInterstitialDateRanges(i,this.hls.config.interstitialAppendInPlace),!this.effectivePlayingItem&&this.schedule.items&&this.checkStart()}}}},{key:"onAudioTrackUpdated",value:function(e,t){var n=this.hls.audioTracks[t.id],i=this.mediaSelection;if(i){var a=_$(_$({},i),{},{audio:n});this.mediaSelection=a}else this.altSelection=_$(_$({},this.altSelection),{},{audio:n})}},{key:"onSubtitleTrackUpdated",value:function(e,t){var n=this.hls.subtitleTracks[t.id],i=this.mediaSelection;if(i){var a=_$(_$({},i),{},{subtitles:n});this.mediaSelection=a}else this.altSelection=_$(_$({},this.altSelection),{},{subtitles:n})}},{key:"onAudioTrackSwitching",value:function(e,t){var n=rW(t);this.playerQueue.forEach(({hls:e})=>e&&(e.setAudioOption(t)||e.setAudioOption(n)))}},{key:"onSubtitleTrackSwitch",value:function(e,t){var n=rW(t);this.playerQueue.forEach(({hls:e})=>e&&(e.setSubtitleOption(t)||-1!==t.id&&e.setSubtitleOption(n)))}},{key:"onBufferCodecs",value:function(e,t){var n=t.tracks;n&&(this.requiredTracks=n)}},{key:"onBufferAppended",value:function(e,t){this.checkBuffer()}},{key:"onBufferFlushed",value:function(e,t){var n=this.playingItem;if(n&&!this.itemsMatch(n,this.bufferingItem)&&!this.isInterstitial(n)){var i=this.timelinePos;this.bufferedPos=i,this.checkBuffer()}}},{key:"onBufferedToEnd",value:function(e){if(this.schedule){var t=this.schedule.events;if(this.bufferedPos<Number.MAX_VALUE&&t){for(var n=0;n<t.length;n++){var i=t[n];if(i.cue.post){var a,r=this.schedule.findEventIndex(i.identifier),o=null==(a=this.schedule.items)?void 0:a[r];this.isInterstitial(o)&&this.eventItemsMatch(o,this.bufferingItem)&&this.bufferedToItem(o,0);break}}this.bufferedPos=Number.MAX_VALUE}}}},{key:"onMediaEnded",value:function(e){var t=this.playingItem;if(!this.playingLastItem&&t){var n=this.findItemIndex(t);this.setSchedulePosition(n+1)}else this.shouldPlay=!1}},{key:"updateItem",value:function(e,t){var n,i=null==(n=this.schedule)?void 0:n.items;return e&&i&&i[this.findItemIndex(e,t)]||null}},{key:"trimInPlace",value:function(e,t){if(this.isInterstitial(e)&&e.event.appendInPlace&&t.end-e.end>.25){e.event.assetList.forEach((t,n)=>{e.event.isAssetPastPlayoutLimit(n)&&this.clearAssetPlayer(t.identifier,null)});var n=e.end+.25,i=ij.bufferInfo(this.primaryMedia,n,0);if(i.end>n||(i.nextStart||0)>n){this.log(`trim buffered interstitial ${JH(e)} (was ${JH(t)})`);this.attachPrimary(n,null,!0),this.flushFrontBuffer(n)}}}},{key:"itemsMatch",value:function(e,t){return!!t&&(e===t||e.event&&t.event&&this.eventItemsMatch(e,t)||!e.event&&!t.event&&this.findItemIndex(e)===this.findItemIndex(t))}},{key:"eventItemsMatch",value:function(e,t){var n;return!!t&&(e===t||e.event.identifier===(null==(n=t.event)?void 0:n.identifier))}},{key:"findItemIndex",value:function(e,t){return e&&this.schedule?this.schedule.findItemIndex(e,t):-1}},{key:"updateSchedule",value:function(e=!1){var t,n=this.mediaSelection;n&&(null==(t=this.schedule)||t.updateSchedule(n,[],e))}},{key:"checkBuffer",value:function(e){var t,n=null==(t=this.schedule)?void 0:t.items;if(n){var i=ij.bufferInfo(this.primaryMedia,this.timelinePos,0);e&&(this.bufferedPos=this.timelinePos),e||(e=i.len<1),this.updateBufferedPos(i.end,n,e)}}},{key:"updateBufferedPos",value:function(e,t,n){var i=this.schedule,a=this.bufferingItem;if(!(this.bufferedPos>e)&&i)if(1===t.length&&this.itemsMatch(t[0],a))this.bufferedPos=e;else{var r=this.playingItem,o=this.findItemIndex(r),s=i.findItemIndexAtTime(e);if(this.bufferedPos<e){var u,l=this.findItemIndex(a),d=Math.min(l+1,t.length-1),c=t[d];if((-1===s&&a&&e>=a.end||null!=(u=c.event)&&u.appendInPlace&&e+.01>=c.start)&&(s=d),this.isInterstitial(a)){var h=a.event;if(d-o>1&&!1===h.appendInPlace)return;if(0===h.assetList.length&&h.assetListLoader)return}if(this.bufferedPos=e,s>l&&s>o)this.bufferedToItem(c);else{var m=this.primaryDetails;this.primaryLive&&m&&e>m.edge-m.targetduration&&c.start<m.edge+this.hls.config.interstitialLiveLookAhead&&this.isInterstitial(c)&&this.preloadAssets(c.event,0)}}else n&&r&&!this.itemsMatch(r,a)&&(s===o?this.bufferedToItem(r):s===o+1&&this.bufferedToItem(t[s]))}}},{key:"assetsBuffered",value:function(e,t){return 0!==e.event.assetList.length&&!e.event.assetList.some(e=>{var n=this.getAssetPlayer(e.identifier);return!(null!=n&&n.bufferedInPlaceToEnd(t))})}},{key:"setBufferingItem",value:function(e){var t=this.bufferingItem,n=this.schedule;if(!this.itemsMatch(e,t)&&n){var i=n.items,a=n.events;if(!i||!a)return t;var r=this.isInterstitial(e),o=this.getBufferingPlayer();this.bufferingItem=e,this.bufferedPos=Math.max(e.start,Math.min(e.end,this.timelinePos));var s=o?o.remaining:t?t.end-this.timelinePos:0;if(this.log(`INTERSTITIALS_BUFFERED_TO_BOUNDARY ${JH(e)}`+(t?` (${s.toFixed(2)} remaining)`:"")),!this.playbackDisabled)if(r){var u=n.findAssetIndex(e.event,this.bufferedPos);e.event.assetList.forEach((e,t)=>{var n=this.getAssetPlayer(e.identifier);n&&(t===u&&n.loadSource(),n.resumeBuffering())})}else this.hls.resumeBuffering(),this.playerQueue.forEach(e=>e.pauseBuffering());this.hls.trigger(m$.INTERSTITIALS_BUFFERED_TO_BOUNDARY,{events:a.slice(0),schedule:i.slice(0),bufferingIndex:this.findItemIndex(e),playingIndex:this.findItemIndex(this.playingItem)})}else this.bufferingItem!==e&&(this.bufferingItem=e);return t}},{key:"bufferedToItem",value:function(e,t=0){var n=this.setBufferingItem(e);if(!this.playbackDisabled)if(this.isInterstitial(e))this.bufferedToEvent(e,t);else if(null!==n){this.bufferingAsset=null;var i=this.detachedData;if(i)if(i.mediaSource){this.attachPrimary(e.start,e,!0)}else this.preloadPrimary(e);else this.preloadPrimary(e)}}},{key:"preloadPrimary",value:function(e){var t=this.findItemIndex(e),n=this.getPrimaryResumption(e,t);this.startLoadingPrimaryAt(n)}},{key:"bufferedToEvent",value:function(e,t){var n=e.event,i=0===n.assetList.length&&!n.assetListLoader,a=n.cue.once;if(i||!a){var r=this.preloadAssets(n,t);if(null!=r&&r.interstitial.appendInPlace){var o=this.primaryMedia;o&&this.bufferAssetPlayer(r,o)}}}},{key:"preloadAssets",value:function(e,t){var n=e.assetUrl,i=e.assetList.length,a=0===i&&!e.assetListLoader,r=e.cue.once;if(a){var o,s=e.timelineStart;if(e.appendInPlace){var u,l=this.playingItem;this.isInterstitial(l)||(null==l||null==(u=l.nextEvent)?void 0:u.identifier)!==e.identifier||this.flushFrontBuffer(s+.25)}var d=0;if(!this.playingItem&&this.primaryLive&&-1===(d=this.hls.startPosition)&&(d=this.hls.liveSyncPosition||0),d&&!e.cue.pre&&!e.cue.post){var c=d-s;c>0&&(o=Math.round(1e3*c)/1e3)}if(this.log(`Load interstitial asset ${t+1}/${n?1:i} ${e}${o?` live-start: ${d} start-offset: ${o}`:""}`),n)return this.createAsset(e,0,0,s,e.duration,n);var h=this.assetListLoader.loadAssetList(e,o);h&&(e.assetListLoader=h)}else if(!r&&i){for(var m=t;m<i;m++){var f=e.assetList[m],v=this.getAssetPlayerQueueIndex(f.identifier);-1!==v&&!this.playerQueue[v].destroyed||f.error||this.createAssetPlayer(e,f,m)}var p=e.assetList[t];if(p){var g=this.getAssetPlayer(p.identifier);return g&&g.loadSource(),g}}return null}},{key:"flushFrontBuffer",value:function(e){var t=this.requiredTracks;t&&(this.log(`Removing front buffer starting at ${e}`),Object.keys(t).forEach(t=>{this.hls.trigger(m$.BUFFER_FLUSHING,{startOffset:e,endOffset:1/0,type:t})}))}},{key:"getAssetPlayerQueueIndex",value:function(e){for(var t=this.playerQueue,n=0;n<t.length;n++)if(e===t[n].assetId)return n;return-1}},{key:"getAssetPlayer",value:function(e){var t=this.getAssetPlayerQueueIndex(e);return this.playerQueue[t]||null}},{key:"getBufferingPlayer",value:function(){var e=this.playerQueue,t=this.primaryMedia;if(t)for(var n=0;n<e.length;n++)if(e[n].media===t)return e[n];return null}},{key:"createAsset",value:function(e,t,n,i,a,r){var o={parentIdentifier:e.identifier,identifier:UH(e,r,t),duration:a,startOffset:n,timelineStart:i,uri:r};return this.createAssetPlayer(e,o,t)}},{key:"createAssetPlayer",value:function(e,t,n){var i=this.hls,a=i.userConfig,r=a.videoPreference,o=i.loadLevelObj||i.levels[i.currentLevel];(r||o)&&(r=P$({},r),o.videoCodec&&(r.videoCodec=o.videoCodec),o.videoRange&&(r.allowedVideoRanges=[o.videoRange]));var s=i.audioTracks[i.audioTrack],u=i.subtitleTracks[i.subtitleTrack],l=0;if(this.primaryLive||e.appendInPlace){var d=this.timelinePos-t.timelineStart;if(d>1){var c=t.duration;c&&d<c&&(l=d)}}var h=t.identifier,m=_$(_$({},a),{},{maxMaxBufferLength:Math.min(180,i.config.maxMaxBufferLength),autoStartLoad:!0,startFragPrefetch:!0,primarySessionId:i.sessionId,assetPlayerId:h,abrEwmaDefaultEstimate:i.bandwidthEstimate,interstitialsController:void 0,startPosition:l,liveDurationInfinity:!1,testBandwidth:!1,videoPreference:r,audioPreference:s||a.audioPreference,subtitlePreference:u||a.subtitlePreference});e.appendInPlace&&(e.appendInPlaceStarted=!0,t.timelineStart&&(m.timelineOffset=t.timelineStart));var f=m.cmcd;null!=f&&f.sessionId&&f.contentId&&(m.cmcd=P$({},f,{contentId:jH(t.uri)})),this.getAssetPlayer(h)&&this.warn(`Duplicate date range identifier ${e} and asset ${h}`);var v=new YH(this.HlsPlayerClass,m,e,t);this.playerQueue.push(v),e.assetList[n]=t;var p=!0,g=i=>{if(i.live){var a,r=new Error(`Interstitials MUST be VOD assets ${e}`),o={fatal:!0,type:c$.OTHER_ERROR,details:h$.INTERSTITIAL_ASSET_ITEM_ERROR,error:r},s=(null==(a=this.schedule)?void 0:a.findEventIndex(e.identifier))||-1;this.handleAssetItemError(o,e,s,n,r.message)}else{var u=i.edge-i.fragmentStart,l=t.duration;(p||null===l||u>l)&&(p=!1,this.log(`Interstitial asset "${h}" duration change ${l} > ${u}`),t.duration=u,this.updateSchedule())}};v.on(m$.LEVEL_UPDATED,(e,{details:t})=>g(t)),v.on(m$.LEVEL_PTS_UPDATED,(e,{details:t})=>g(t)),v.on(m$.EVENT_CUE_ENTER,()=>this.onInterstitialCueEnter());var y=(e,t)=>{var n=this.getAssetPlayer(h);if(n&&t.tracks){n.off(m$.BUFFER_CODECS,y),n.tracks=t.tracks;var i=this.primaryMedia;this.bufferingAsset===n.assetItem&&i&&!n.media&&this.bufferAssetPlayer(n,i)}};v.on(m$.BUFFER_CODECS,y);v.on(m$.BUFFERED_TO_END,()=>{var n,i=this.getAssetPlayer(h);if(this.log(`buffered to end of asset ${i}`),i&&this.schedule){var a=this.schedule.findEventIndex(e.identifier),r=null==(n=this.schedule.items)?void 0:n[a];this.isInterstitial(r)&&this.advanceAssetBuffering(r,t)}});var b=t=>()=>{if(this.getAssetPlayer(h)&&this.schedule){this.shouldPlay=!0;var n=this.schedule.findEventIndex(e.identifier);this.advanceAfterAssetEnded(e,n,t)}};return v.once(m$.MEDIA_ENDED,b(n)),v.once(m$.PLAYOUT_LIMIT_REACHED,b(1/0)),v.on(m$.ERROR,(t,i)=>{if(this.schedule){var a=this.getAssetPlayer(h);if(i.details===h$.BUFFER_STALLED_ERROR)return null!=a&&a.appendInPlace?void this.handleInPlaceStall(e):(this.onTimeupdate(),void this.checkBuffer(!0));this.handleAssetItemError(i,e,this.schedule.findEventIndex(e.identifier),n,`Asset player error ${i.error} ${e}`)}}),v.on(m$.DESTROYING,()=>{if(this.getAssetPlayer(h)&&this.schedule){var t=new Error(`Asset player destroyed unexpectedly ${h}`),i={fatal:!0,type:c$.OTHER_ERROR,details:h$.INTERSTITIAL_ASSET_ITEM_ERROR,error:t};this.handleAssetItemError(i,e,this.schedule.findEventIndex(e.identifier),n,t.message)}}),this.log(`INTERSTITIAL_ASSET_PLAYER_CREATED ${XH(t)}`),this.hls.trigger(m$.INTERSTITIAL_ASSET_PLAYER_CREATED,{asset:t,assetListIndex:n,event:e,player:v}),v}},{key:"clearInterstitial",value:function(e,t){this.clearAssetPlayers(e,t),e.reset()}},{key:"clearAssetPlayers",value:function(e,t){e.assetList.forEach(e=>{this.clearAssetPlayer(e.identifier,t)})}},{key:"resetAssetPlayer",value:function(e){var t=this.getAssetPlayerQueueIndex(e);if(-1!==t){this.log(`reset asset player "${e}" after error`);var n=this.playerQueue[t];this.transferMediaFromPlayer(n,null),n.resetDetails()}}},{key:"clearAssetPlayer",value:function(e,t){var n=this.getAssetPlayerQueueIndex(e);if(-1!==n){var i=this.playerQueue[n];this.log(`clear ${i} toSegment: ${t?JH(t):t}`),this.transferMediaFromPlayer(i,t),this.playerQueue.splice(n,1),i.destroy()}}},{key:"emptyPlayerQueue",value:function(){for(var e;e=this.playerQueue.pop();)e.destroy();this.playerQueue=[]}},{key:"startAssetPlayer",value:function(e,t,n,i,a){var r=e.interstitial,o=e.assetItem,s=e.assetId,u=r.assetList.length,l=this.playingAsset;this.endedAsset=null,this.playingAsset=o,l&&l.identifier===s||(l&&(this.clearAssetPlayer(l.identifier,n[i]),delete l.error),this.log(`INTERSTITIAL_ASSET_STARTED ${t+1}/${u} ${XH(o)}`),this.hls.trigger(m$.INTERSTITIAL_ASSET_STARTED,{asset:o,assetListIndex:t,event:r,schedule:n.slice(0),scheduleIndex:i,player:e})),this.bufferAssetPlayer(e,a)}},{key:"bufferAssetPlayer",value:function(e,t){var n,i;if(this.schedule){var a=e.interstitial,r=e.assetItem,o=this.schedule.findEventIndex(a.identifier),s=null==(n=this.schedule.items)?void 0:n[o];if(s){e.loadSource(),this.setBufferingItem(s),this.bufferingAsset=r;var u=this.getBufferingPlayer();if(u!==e){var l=a.appendInPlace;if(!l||!1!==(null==u?void 0:u.interstitial.appendInPlace)){var d=(null==u?void 0:u.tracks)||(null==(i=this.detachedData)?void 0:i.tracks)||this.requiredTracks;if(l&&r!==this.playingAsset){if(!e.tracks)return void this.log(`Waiting for track info before buffering ${e}`);if(d&&!F$(d,e.tracks)){var c=new Error(`Asset ${XH(r)} SourceBuffer tracks ('${Object.keys(e.tracks)}') are not compatible with primary content tracks ('${Object.keys(d)}')`),h={fatal:!0,type:c$.OTHER_ERROR,details:h$.INTERSTITIAL_ASSET_ITEM_ERROR,error:c},m=a.findAssetIndex(r);return void this.handleAssetItemError(h,a,o,m,c.message)}}this.transferMediaTo(e,t)}}}}}},{key:"handleInPlaceStall",value:function(e){var t=this.schedule,n=this.primaryMedia;if(t&&n){var i=n.currentTime,a=t.findAssetIndex(e,i),r=e.assetList[a];if(r){var o=this.getAssetPlayer(r.identifier);if(o){var s=o.currentTime||i-r.timelineStart,u=o.duration-s;if(this.warn(`Stalled at ${s} of ${s+u} in ${o} ${e} (media.currentTime: ${i})`),s&&(u/n.playbackRate<.5||o.bufferedInPlaceToEnd(n))&&o.hls){var l=t.findEventIndex(e.identifier);this.advanceAfterAssetEnded(e,l,a)}}}}}},{key:"advanceInPlace",value:function(e){var t=this.primaryMedia;t&&t.currentTime<e&&(t.currentTime=e)}},{key:"handleAssetItemError",value:function(e,t,n,i,a){if(e.details!==h$.BUFFER_STALLED_ERROR){var r=t.assetList[i]||null;if(this.warn(`INTERSTITIAL_ASSET_ERROR ${r?XH(r):r} ${e.error}`),this.schedule){var o=(null==r?void 0:r.identifier)||"",s=this.getAssetPlayerQueueIndex(o),u=this.playerQueue[s]||null,l=this.schedule.items,d=P$({},e,{fatal:!1,errorAction:RW(!0),asset:r,assetListIndex:i,event:t,schedule:l,scheduleIndex:n,player:u});if(this.hls.trigger(m$.INTERSTITIAL_ASSET_ERROR,d),e.fatal){var c=this.playingAsset,h=this.bufferingAsset,m=new Error(a);if(r&&(this.clearAssetPlayer(o,null),r.error=m),t.assetList.some(e=>!e.error))for(var f=i;f<t.assetList.length;f++)this.resetAssetPlayer(t.assetList[f].identifier);else t.error=m;this.updateSchedule(!0),t.error?this.primaryFallback(t):c&&c.identifier===o?this.advanceAfterAssetEnded(t,n,i):h&&h.identifier===o&&this.isInterstitial(this.bufferingItem)&&this.advanceAssetBuffering(this.bufferingItem,h)}}}}},{key:"primaryFallback",value:function(e){var t=e.timelineStart,n=this.effectivePlayingItem,i=this.timelinePos;if(n){this.log(`Fallback to primary from event "${e.identifier}" start: ${t} pos: ${i} playing: ${JH(n)} error: ${e.error}`),-1===i&&(i=this.hls.startPosition);var a=this.updateItem(n,i);this.itemsMatch(n,a)&&this.clearInterstitial(e,null),e.appendInPlace&&(this.attachPrimary(t,null),this.flushFrontBuffer(t))}else if(-1===i)return void this.checkStart();if(this.schedule){var r=this.schedule.findItemIndexAtTime(i);this.setSchedulePosition(r)}}},{key:"onAssetListLoaded",value:function(e,t){var n,i,a=t.event,r=a.identifier,o=t.assetListResponse.ASSETS;if(null!=(n=this.schedule)&&n.hasEvent(r)){var s=a.timelineStart,u=a.duration,l=0;o.forEach((e,t)=>{var n=parseFloat(e.DURATION);this.createAsset(a,t,l,s+l,n,e.URI),l+=n}),a.duration=l,this.log(`Loaded asset-list with duration: ${l} (was: ${u}) ${a}`);var d=this.waitingItem,c=(null==d?void 0:d.event.identifier)===r;this.updateSchedule();var h=null==(i=this.bufferingItem)?void 0:i.event;if(c){var m,f=this.schedule.findEventIndex(r),v=null==(m=this.schedule.items)?void 0:m[f];if(v){if(!this.playingItem&&this.timelinePos>v.end)if(this.schedule.findItemIndexAtTime(this.timelinePos)!==f)return a.error=new Error(`Interstitial ${o.length?"no longer within playback range":"asset-list is empty"} ${this.timelinePos} ${a}`),this.log(a.error.message),this.updateSchedule(!0),void this.primaryFallback(a);this.setBufferingItem(v)}this.setSchedulePosition(f)}else if((null==h?void 0:h.identifier)===r){var p=a.assetList[0];if(p){var g=this.getAssetPlayer(p.identifier);if(h.appendInPlace){var y=this.primaryMedia;g&&y&&this.bufferAssetPlayer(g,y)}else g&&g.loadSource()}}}}},{key:"onError",value:function(e,t){if(this.schedule)switch(t.details){case h$.ASSET_LIST_PARSING_ERROR:case h$.ASSET_LIST_LOAD_ERROR:case h$.ASSET_LIST_LOAD_TIMEOUT:var n=t.interstitial;n&&(this.updateSchedule(!0),this.primaryFallback(n));break;case h$.BUFFER_STALLED_ERROR:var i=this.endedItem||this.waitingItem||this.playingItem;if(this.isInterstitial(i)&&i.event.appendInPlace)return void this.handleInPlaceStall(i.event);this.log(`Primary player stall @${this.timelinePos} bufferedPos: ${this.bufferedPos}`),this.onTimeupdate(),this.checkBuffer(!0)}}}])}(M$),nG=function(e){function t(e,n,i){var a;return o(this,t),(a=r(this,t,[e,n,i,"subtitle-stream-controller",w$])).currentTrackId=-1,a.tracksBuffered=[],a.mainDetails=null,a.registerListeners(),a}return p(t,e),c(t,[{key:"onHandlerDestroying",value:function(){this.unregisterListeners(),T(t,"onHandlerDestroying",this)([]),this.mainDetails=null}},{key:"registerListeners",value:function(){T(t,"registerListeners",this)([]);var e=this.hls;e.on(m$.LEVEL_LOADED,this.onLevelLoaded,this),e.on(m$.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(m$.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(m$.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(m$.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.on(m$.BUFFER_FLUSHING,this.onBufferFlushing,this)}},{key:"unregisterListeners",value:function(){T(t,"unregisterListeners",this)([]);var e=this.hls;e.off(m$.LEVEL_LOADED,this.onLevelLoaded,this),e.off(m$.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(m$.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(m$.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(m$.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.off(m$.BUFFER_FLUSHING,this.onBufferFlushing,this)}},{key:"startLoad",value:function(e,t){this.stopLoad(),this.state=PB,this.setInterval(500),this.nextLoadPosition=this.lastCurrentTime=e+this.timelineOffset,this.startPosition=t?-1:e,this.tick()}},{key:"onManifestLoading",value:function(){T(t,"onManifestLoading",this)([]),this.mainDetails=null}},{key:"onMediaDetaching",value:function(e,n){this.tracksBuffered=[],T(t,"onMediaDetaching",this)([e,n])}},{key:"onLevelLoaded",value:function(e,t){this.mainDetails=t.details}},{key:"onSubtitleFragProcessed",value:function(e,t){var n=t.frag,i=t.success;if(this.fragContextChanged(n)||(X$(n)&&(this.fragPrevious=n),this.state=PB),i){var a=this.tracksBuffered[this.currentTrackId];if(a){for(var r,o=n.start,s=0;s<a.length;s++)if(o>=a[s].start&&o<=a[s].end){r=a[s];break}var u=n.start+n.duration;r?r.end=u:(r={start:o,end:u},a.push(r)),this.fragmentTracker.fragBuffered(n),this.fragBufferedComplete(n,null),this.media&&this.tick()}}}},{key:"onBufferFlushing",value:function(e,t){var n=t.startOffset,i=t.endOffset;if(0===n&&i!==Number.POSITIVE_INFINITY){var a=i-1;if(a<=0)return;t.endOffsetSubtitles=Math.max(0,a),this.tracksBuffered.forEach(e=>{for(var t=0;t<e.length;)if(e[t].end<=a)e.shift();else{if(!(e[t].start<a))break;e[t].start=a,t++}}),this.fragmentTracker.removeFragmentsInRange(n,a,w$)}}},{key:"onError",value:function(e,t){var n=t.frag;(null==n?void 0:n.type)===w$&&(t.details===h$.FRAG_GAP&&this.fragmentTracker.fragBuffered(n,!0),this.fragCurrent&&this.fragCurrent.abortRequests(),this.state!==EB&&(this.state=PB))}},{key:"onSubtitleTracksUpdated",value:function(e,{subtitleTracks:t}){this.levels&&bU(this.levels,t)?this.levels=t.map(e=>new ZN(e)):(this.tracksBuffered=[],this.levels=t.map(e=>{var t=new ZN(e);return this.tracksBuffered[t.id]=[],t}),this.fragmentTracker.removeFragmentsInRange(0,Number.POSITIVE_INFINITY,w$),this.fragPrevious=null,this.mediaBuffer=null)}},{key:"onSubtitleTrackSwitch",value:function(e,t){var n;if(this.currentTrackId=t.id,null!=(n=this.levels)&&n.length&&-1!==this.currentTrackId){var i=this.levels[this.currentTrackId];null!=i&&i.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,i&&this.state!==EB&&this.setInterval(500)}else this.clearInterval()}},{key:"onSubtitleTrackLoaded",value:function(e,t){var n,i=this.currentTrackId,a=this.levels,r=t.details,o=t.id;if(a){var s=a[o];if(!(o>=a.length)&&s){this.log(`Subtitle track ${o} loaded [${r.startSN},${r.endSN}]${r.lastPartSn?`[part-${r.lastPartSn}-${r.lastPartIndex}]`:""},duration:${r.totalduration}`),this.mediaBuffer=this.mediaBufferTimeRanges;var u=0;if(r.live||null!=(n=s.details)&&n.live){if(r.deltaUpdateFailed)return;var l=this.mainDetails;if(!l)return void(this.startFragRequested=!1);var d,c=l.fragments[0];if(s.details)0===(u=this.alignPlaylists(r,s.details,null==(d=this.levelLastLoaded)?void 0:d.details))&&c&&sB(r,u=c.start);else r.hasProgramDateTime&&l.hasProgramDateTime?(bB(r,l),u=r.fragmentStart):c&&sB(r,u=c.start);l&&!this.startFragRequested&&this.setStartPosition(l,u)}if(s.details=r,this.levelLastLoaded=s,o===i)if(this.hls.trigger(m$.SUBTITLE_TRACK_UPDATED,{details:r,id:o,groupId:t.groupId}),this.tick(),r.live&&!this.fragCurrent&&this.media&&this.state===PB)mW(null,r.fragments,this.media.currentTime,0)||(this.warn("Subtitle playlist not aligned with playback"),s.details=void 0)}}else this.warn(`Subtitle tracks were reset while loading level ${o}`)}},{key:"_handleFragmentLoadComplete",value:function(e){var t=e.frag,n=e.payload,i=t.decryptdata,a=this.hls;if(!this.fragContextChanged(t)&&n&&n.byteLength>0&&null!=i&&i.key&&i.iv&&yj(i.method)){var r=performance.now();this.decrypter.decrypt(new Uint8Array(n),i.key.buffer,i.iv.buffer,bj(i.method)).catch(e=>{throw a.trigger(m$.ERROR,{type:c$.MEDIA_ERROR,details:h$.FRAG_DECRYPT_ERROR,fatal:!1,error:e,reason:e.message,frag:t}),e}).then(e=>{var n=performance.now();a.trigger(m$.FRAG_DECRYPTED,{frag:t,payload:e,stats:{tstart:r,tdecrypt:n}})}).catch(e=>{this.warn(`${e.name}: ${e.message}`),this.state=PB})}}},{key:"doTick",value:function(){if(this.media){if(this.state===PB){var e=this.currentTrackId,t=this.levels,n=null==t?void 0:t[e];if(!n||!t.length||!n.details)return;if(this.waitForLive(n))return;var i=this.config,a=this.getLoadPosition(),r=ij.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],a,i.maxBufferHole),o=r.end,s=r.len,u=n.details;if(s>this.hls.maxBufferLength+u.levelTargetDuration)return;var l=u.fragments,d=l.length,c=u.edge,h=null,m=this.fragPrevious;if(o<c){var f=i.maxFragLookUpTolerance,v=o>c-f?0:f;!(h=mW(m,l,Math.max(l[0].start,o),v))&&m&&m.start<l[0].start&&(h=l[0])}else h=l[d-1];if(!(h=this.filterReplacedPrimary(h,n.details)))return;var p=l[h.sn-u.startSN-1];if(p&&p.cc===h.cc&&this.fragmentTracker.getState(p)===FW&&(h=p),this.fragmentTracker.getState(h)===FW){var g=this.mapToInitFragWhenRequired(h);g&&this.loadFragment(g,n,o)}}}else this.state=PB}},{key:"loadFragment",value:function(e,n,i){X$(e)?T(t,"loadFragment",this)([e,n,i]):this._loadInitSegment(e,n)}},{key:"mediaBufferTimeRanges",get:function(){return new iG(this.tracksBuffered[this.currentTrackId]||[])}}])}(FB),iG=c(function e(t){o(this,e),this.buffered=void 0;var n=(e,n,i)=>{if((n>>>=0)>i-1)throw new DOMException(`Failed to execute '${e}' on 'TimeRanges': The index provided (${n}) is greater than the maximum bound (${i})`);return t[n][e]};this.buffered={get length(){return t.length},end:e=>n("end",e,t.length),start:e=>n("start",e,t.length)}}),aG={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},rG=e=>String.fromCharCode(aG[e]||e),oG=15,sG=100,uG={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},lG={17:2,18:4,21:6,22:8,23:10,19:13,20:15},dG={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},cG={25:2,26:4,29:6,30:8,31:10,27:13,28:15},hG=["white","green","blue","cyan","red","yellow","magenta","black","transparent"],mG=function(){return c(function e(){o(this,e),this.time=null,this.verboseLevel=0},[{key:"log",value:function(e,t){if(this.verboseLevel>=e){var n="function"==typeof t?t():t;L$.log(`${this.time} [${e}] ${n}`)}}}])}(),fG=function(e){for(var t=[],n=0;n<e.length;n++)t.push(e[n].toString(16));return t},vG=function(){return c(function e(){o(this,e),this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1},[{key:"reset",value:function(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1}},{key:"setStyles",value:function(e){for(var t=["foreground","underline","italics","background","flash"],n=0;n<t.length;n++){var i=t[n];e.hasOwnProperty(i)&&(this[i]=e[i])}}},{key:"isDefault",value:function(){return"white"===this.foreground&&!this.underline&&!this.italics&&"black"===this.background&&!this.flash}},{key:"equals",value:function(e){return this.foreground===e.foreground&&this.underline===e.underline&&this.italics===e.italics&&this.background===e.background&&this.flash===e.flash}},{key:"copy",value:function(e){this.foreground=e.foreground,this.underline=e.underline,this.italics=e.italics,this.background=e.background,this.flash=e.flash}},{key:"toString",value:function(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash}}])}(),pG=function(){return c(function e(){o(this,e),this.uchar=" ",this.penState=new vG},[{key:"reset",value:function(){this.uchar=" ",this.penState.reset()}},{key:"setChar",value:function(e,t){this.uchar=e,this.penState.copy(t)}},{key:"setPenState",value:function(e){this.penState.copy(e)}},{key:"equals",value:function(e){return this.uchar===e.uchar&&this.penState.equals(e.penState)}},{key:"copy",value:function(e){this.uchar=e.uchar,this.penState.copy(e.penState)}},{key:"isEmpty",value:function(){return" "===this.uchar&&this.penState.isDefault()}}])}(),gG=function(){return c(function e(t){o(this,e),this.chars=[],this.pos=0,this.currPenState=new vG,this.cueStartTime=null,this.logger=void 0;for(var n=0;n<sG;n++)this.chars.push(new pG);this.logger=t},[{key:"equals",value:function(e){for(var t=0;t<sG;t++)if(!this.chars[t].equals(e.chars[t]))return!1;return!0}},{key:"copy",value:function(e){for(var t=0;t<sG;t++)this.chars[t].copy(e.chars[t])}},{key:"isEmpty",value:function(){for(var e=!0,t=0;t<sG;t++)if(!this.chars[t].isEmpty()){e=!1;break}return e}},{key:"setCursor",value:function(e){this.pos!==e&&(this.pos=e),this.pos<0?(this.logger.log(3,"Negative cursor position "+this.pos),this.pos=0):this.pos>sG&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=sG)}},{key:"moveCursor",value:function(e){var t=this.pos+e;if(e>1)for(var n=this.pos+1;n<t+1;n++)this.chars[n].setPenState(this.currPenState);this.setCursor(t)}},{key:"backSpace",value:function(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)}},{key:"insertChar",value:function(e){e>=144&&this.backSpace();var t=rG(e);this.pos>=sG?this.logger.log(0,()=>"Cannot insert "+e.toString(16)+" ("+t+") at position "+this.pos+". Skipping it!"):(this.chars[this.pos].setChar(t,this.currPenState),this.moveCursor(1))}},{key:"clearFromPos",value:function(e){var t;for(t=e;t<sG;t++)this.chars[t].reset()}},{key:"clear",value:function(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()}},{key:"clearToEndOfRow",value:function(){this.clearFromPos(this.pos)}},{key:"getTextString",value:function(){for(var e=[],t=!0,n=0;n<sG;n++){var i=this.chars[n].uchar;" "!==i&&(t=!1),e.push(i)}return t?"":e.join("")}},{key:"setPenStyles",value:function(e){this.currPenState.setStyles(e),this.chars[this.pos].setPenState(this.currPenState)}}])}(),yG=function(){return c(function e(t){o(this,e),this.rows=[],this.currRow=14,this.nrRollUpRows=null,this.lastOutputScreen=null,this.logger=void 0;for(var n=0;n<oG;n++)this.rows.push(new gG(t));this.logger=t},[{key:"reset",value:function(){for(var e=0;e<oG;e++)this.rows[e].clear();this.currRow=14}},{key:"equals",value:function(e){for(var t=!0,n=0;n<oG;n++)if(!this.rows[n].equals(e.rows[n])){t=!1;break}return t}},{key:"copy",value:function(e){for(var t=0;t<oG;t++)this.rows[t].copy(e.rows[t])}},{key:"isEmpty",value:function(){for(var e=!0,t=0;t<oG;t++)if(!this.rows[t].isEmpty()){e=!1;break}return e}},{key:"backSpace",value:function(){this.rows[this.currRow].backSpace()}},{key:"clearToEndOfRow",value:function(){this.rows[this.currRow].clearToEndOfRow()}},{key:"insertChar",value:function(e){this.rows[this.currRow].insertChar(e)}},{key:"setPen",value:function(e){this.rows[this.currRow].setPenStyles(e)}},{key:"moveCursor",value:function(e){this.rows[this.currRow].moveCursor(e)}},{key:"setCursor",value:function(e){this.logger.log(2,"setCursor: "+e),this.rows[this.currRow].setCursor(e)}},{key:"setPAC",value:function(e){this.logger.log(2,()=>"pacData = "+nW(e));var t=e.row-1;if(this.nrRollUpRows&&t<this.nrRollUpRows-1&&(t=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==t){for(var n=0;n<oG;n++)this.rows[n].clear();var i=this.currRow+1-this.nrRollUpRows,a=this.lastOutputScreen;if(a){var r=a.rows[i].cueStartTime,o=this.logger.time;if(null!==r&&null!==o&&r<o)for(var s=0;s<this.nrRollUpRows;s++)this.rows[t-this.nrRollUpRows+s+1].copy(a.rows[i+s])}}this.currRow=t;var u=this.rows[this.currRow];if(null!==e.indent){var l=e.indent,d=Math.max(l-1,0);u.setCursor(e.indent),e.color=u.chars[d].penState.foreground}var c={foreground:e.color,underline:e.underline,italics:e.italics,background:"black",flash:!1};this.setPen(c)}},{key:"setBkgData",value:function(e){this.logger.log(2,()=>"bkgData = "+nW(e)),this.backSpace(),this.setPen(e),this.insertChar(32)}},{key:"setRollUpRows",value:function(e){this.nrRollUpRows=e}},{key:"rollUp",value:function(){if(null!==this.nrRollUpRows){this.logger.log(1,()=>this.getDisplayText());var e=this.currRow+1-this.nrRollUpRows,t=this.rows.splice(e,1)[0];t.clear(),this.rows.splice(this.currRow,0,t),this.logger.log(2,"Rolling up")}else this.logger.log(3,"roll_up but nrRollUpRows not set yet")}},{key:"getDisplayText",value:function(e){e=e||!1;for(var t=[],n="",i=-1,a=0;a<oG;a++){var r=this.rows[a].getTextString();r&&(i=a+1,e?t.push("Row "+i+": '"+r+"'"):t.push(r.trim()))}return t.length>0&&(n=e?"["+t.join(" | ")+"]":t.join("\n")),n}},{key:"getTextAndFormat",value:function(){return this.rows}}])}(),bG=function(){return c(function e(t,n,i){o(this,e),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=n,this.mode=null,this.verbose=0,this.displayedMemory=new yG(i),this.nonDisplayedMemory=new yG(i),this.lastOutputScreen=new yG(i),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=i},[{key:"reset",value:function(){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}},{key:"getHandler",value:function(){return this.outputFilter}},{key:"setHandler",value:function(e){this.outputFilter=e}},{key:"setPAC",value:function(e){this.writeScreen.setPAC(e)}},{key:"setBkgData",value:function(e){this.writeScreen.setBkgData(e)}},{key:"setMode",value:function(e){e!==this.mode&&(this.mode=e,this.logger.log(2,()=>"MODE="+e),"MODE_POP-ON"===this.mode?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),"MODE_ROLL-UP"!==this.mode&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=e)}},{key:"insertChars",value:function(e){for(var t=0;t<e.length;t++)this.writeScreen.insertChar(e[t]);var n=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(2,()=>n+": "+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())}},{key:"ccRCL",value:function(){this.logger.log(2,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")}},{key:"ccBS",value:function(){this.logger.log(2,"BS - BackSpace"),"MODE_TEXT"!==this.mode&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate())}},{key:"ccAOF",value:function(){}},{key:"ccAON",value:function(){}},{key:"ccDER",value:function(){this.logger.log(2,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()}},{key:"ccRU",value:function(e){this.logger.log(2,"RU("+e+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(e)}},{key:"ccFON",value:function(){this.logger.log(2,"FON - Flash On"),this.writeScreen.setPen({flash:!0})}},{key:"ccRDC",value:function(){this.logger.log(2,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")}},{key:"ccTR",value:function(){this.logger.log(2,"TR"),this.setMode("MODE_TEXT")}},{key:"ccRTD",value:function(){this.logger.log(2,"RTD"),this.setMode("MODE_TEXT")}},{key:"ccEDM",value:function(){this.logger.log(2,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)}},{key:"ccCR",value:function(){this.logger.log(2,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)}},{key:"ccENM",value:function(){this.logger.log(2,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()}},{key:"ccEOC",value:function(){if(this.logger.log(2,"EOC - End Of Caption"),"MODE_POP-ON"===this.mode){var e=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=e,this.writeScreen=this.nonDisplayedMemory,this.logger.log(1,()=>"DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(!0)}},{key:"ccTO",value:function(e){this.logger.log(2,"TO("+e+") - Tab Offset"),this.writeScreen.moveCursor(e)}},{key:"ccMIDROW",value:function(e){var t={flash:!1};if(t.underline=e%2==1,t.italics=e>=46,t.italics)t.foreground="white";else{var n=Math.floor(e/2)-16;t.foreground=["white","green","blue","cyan","red","yellow","magenta"][n]}this.logger.log(2,"MIDROW: "+nW(t)),this.writeScreen.setPen(t)}},{key:"outputDataUpdate",value:function(e=!1){var t=this.logger.time;null!==t&&this.outputFilter&&(null!==this.cueStartTime||this.displayedMemory.isEmpty()?this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,t,this.lastOutputScreen),e&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:t):this.cueStartTime=t,this.lastOutputScreen.copy(this.displayedMemory))}},{key:"cueSplitAtTime",value:function(e){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,e,this.displayedMemory),this.cueStartTime=e))}}])}(),wG=function(){return c(function e(t,n,i){o(this,e),this.channels=void 0,this.currentChannel=0,this.cmdHistory={a:null,b:null},this.logger=void 0;var a=this.logger=new mG;this.channels=[null,new bG(t,n,a),new bG(t+1,i,a)]},[{key:"getHandler",value:function(e){return this.channels[e].getHandler()}},{key:"setHandler",value:function(e,t){this.channels[e].setHandler(t)}},{key:"addData",value:function(e,t){var n=this;this.logger.time=e;for(var i=function(e){var i=127&t[e],a=127&t[e+1],r=!1,o=null;if(0===i&&0===a)return 0;n.logger.log(3,()=>"["+fG([t[e],t[e+1]])+"] -> ("+fG([i,a])+")");var s=n.cmdHistory;if(i>=16&&i<=31){if(function(e,t,n){return n.a===e&&n.b===t}(i,a,s))return kG(null,null,s),n.logger.log(3,()=>"Repeated command ("+fG([i,a])+") is dropped"),0;kG(i,a,n.cmdHistory),(r=n.parseCmd(i,a))||(r=n.parseMidrow(i,a)),r||(r=n.parsePAC(i,a)),r||(r=n.parseBackgroundAttributes(i,a))}else kG(null,null,s);if(!r&&(o=n.parseChars(i,a))){var u=n.currentChannel;if(u&&u>0)n.channels[u].insertChars(o);else n.logger.log(2,"No channel found yet. TEXT-MODE?")}r||o||n.logger.log(2,()=>"Couldn't parse cleaned data "+fG([i,a])+" orig: "+fG([t[e],t[e+1]]))},a=0;a<t.length;a+=2)i(a)}},{key:"parseCmd",value:function(e,t){if(!((20===e||28===e||21===e||29===e)&&t>=32&&t<=47)&&!((23===e||31===e)&&t>=33&&t<=35))return!1;var n=20===e||21===e||23===e?1:2,i=this.channels[n];return 20===e||21===e||28===e||29===e?32===t?i.ccRCL():33===t?i.ccBS():34===t?i.ccAOF():35===t?i.ccAON():36===t?i.ccDER():37===t?i.ccRU(2):38===t?i.ccRU(3):39===t?i.ccRU(4):40===t?i.ccFON():41===t?i.ccRDC():42===t?i.ccTR():43===t?i.ccRTD():44===t?i.ccEDM():45===t?i.ccCR():46===t?i.ccENM():47===t&&i.ccEOC():i.ccTO(t-32),this.currentChannel=n,!0}},{key:"parseMidrow",value:function(e,t){var n=0;if((17===e||25===e)&&t>=32&&t<=47){if((n=17===e?1:2)!==this.currentChannel)return this.logger.log(0,"Mismatch channel in midrow parsing"),!1;var i=this.channels[n];return!!i&&(i.ccMIDROW(t),this.logger.log(3,()=>"MIDROW ("+fG([e,t])+")"),!0)}return!1}},{key:"parsePAC",value:function(e,t){var n;if(!((e>=17&&e<=23||e>=25&&e<=31)&&t>=64&&t<=127)&&!((16===e||24===e)&&t>=64&&t<=95))return!1;var i=e<=23?1:2;n=t>=64&&t<=95?1===i?uG[e]:dG[e]:1===i?lG[e]:cG[e];var a=this.channels[i];return!!a&&(a.setPAC(this.interpretPAC(n,t)),this.currentChannel=i,!0)}},{key:"interpretPAC",value:function(e,t){var n,i={color:null,italics:!1,indent:null,underline:!1,row:e};return n=t>95?t-96:t-64,i.underline=!(1&~n),n<=13?i.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(n/2)]:n<=15?(i.italics=!0,i.color="white"):i.indent=4*Math.floor((n-16)/2),i}},{key:"parseChars",value:function(e,t){var n,i,a=null,r=null;(e>=25?(n=2,r=e-8):(n=1,r=e),r>=17&&r<=19)?(i=17===r?t+80:18===r?t+112:t+144,this.logger.log(2,()=>"Special char '"+rG(i)+"' in channel "+n),a=[i]):e>=32&&e<=127&&(a=0===t?[e]:[e,t]);return a&&this.logger.log(3,()=>"Char codes = "+fG(a).join(",")),a}},{key:"parseBackgroundAttributes",value:function(e,t){var n;if(!((16===e||24===e)&&t>=32&&t<=47)&&!((23===e||31===e)&&t>=45&&t<=47))return!1;var i={};16===e||24===e?(n=Math.floor((t-32)/2),i.background=hG[n],t%2==1&&(i.background=i.background+"_semi")):45===t?i.background="transparent":(i.foreground="black",47===t&&(i.underline=!0));var a=e<=23?1:2;return this.channels[a].setBkgData(i),!0}},{key:"reset",value:function(){for(var e=0;e<Object.keys(this.channels).length;e++){var t=this.channels[e];t&&t.reset()}kG(null,null,this.cmdHistory)}},{key:"cueSplitAtTime",value:function(e){for(var t=0;t<this.channels.length;t++){var n=this.channels[t];n&&n.cueSplitAtTime(e)}}}])}();function kG(e,t,n){n.a=e,n.b=t}var SG=function(){if(null!=Pj&&Pj.VTTCue)return self.VTTCue;var e=["","lr","rl"],t=["start","middle","end","left","right"];function n(e,t){if("string"!=typeof t)return!1;if(!Array.isArray(e))return!1;var n=t.toLowerCase();return!!~e.indexOf(n)&&n}function i(e){return n(t,e)}function a(e,...t){for(var n=1;n<arguments.length;n++){var i=arguments[n];for(var a in i)e[a]=i[a]}return e}function r(t,r,o){var s=this,u={enumerable:!0};s.hasBeenReset=!1;var l="",d=!1,c=t,h=r,m=o,f=null,v="",p=!0,g="auto",y="start",b=50,w="middle",k=50,S="middle";Object.defineProperty(s,"id",a({},u,{get:function(){return l},set:function(e){l=""+e}})),Object.defineProperty(s,"pauseOnExit",a({},u,{get:function(){return d},set:function(e){d=!!e}})),Object.defineProperty(s,"startTime",a({},u,{get:function(){return c},set:function(e){if("number"!=typeof e)throw new TypeError("Start time must be set to a number.");c=e,this.hasBeenReset=!0}})),Object.defineProperty(s,"endTime",a({},u,{get:function(){return h},set:function(e){if("number"!=typeof e)throw new TypeError("End time must be set to a number.");h=e,this.hasBeenReset=!0}})),Object.defineProperty(s,"text",a({},u,{get:function(){return m},set:function(e){m=""+e,this.hasBeenReset=!0}})),Object.defineProperty(s,"region",a({},u,{get:function(){return f},set:function(e){f=e,this.hasBeenReset=!0}})),Object.defineProperty(s,"vertical",a({},u,{get:function(){return v},set:function(t){var i=function(t){return n(e,t)}(t);if(!1===i)throw new SyntaxError("An invalid or illegal string was specified.");v=i,this.hasBeenReset=!0}})),Object.defineProperty(s,"snapToLines",a({},u,{get:function(){return p},set:function(e){p=!!e,this.hasBeenReset=!0}})),Object.defineProperty(s,"line",a({},u,{get:function(){return g},set:function(e){if("number"!=typeof e&&"auto"!==e)throw new SyntaxError("An invalid number or illegal string was specified.");g=e,this.hasBeenReset=!0}})),Object.defineProperty(s,"lineAlign",a({},u,{get:function(){return y},set:function(e){var t=i(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");y=t,this.hasBeenReset=!0}})),Object.defineProperty(s,"position",a({},u,{get:function(){return b},set:function(e){if(e<0||e>100)throw new Error("Position must be between 0 and 100.");b=e,this.hasBeenReset=!0}})),Object.defineProperty(s,"positionAlign",a({},u,{get:function(){return w},set:function(e){var t=i(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");w=t,this.hasBeenReset=!0}})),Object.defineProperty(s,"size",a({},u,{get:function(){return k},set:function(e){if(e<0||e>100)throw new Error("Size must be between 0 and 100.");k=e,this.hasBeenReset=!0}})),Object.defineProperty(s,"align",a({},u,{get:function(){return S},set:function(e){var t=i(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");S=t,this.hasBeenReset=!0}})),s.displayState=void 0}return r.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},r}(),EG=function(){return c(function e(){o(this,e)},[{key:"decode",value:function(e,t){if(!e)return"";if("string"!=typeof e)throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(e))}}])}();function PG(e){function t(e,t,n,i){return 3600*(0|e)+60*(0|t)+(0|n)+parseFloat(i||0)}var n=e.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return n?parseFloat(n[2])>59?t(n[2],n[3],0,n[4]):t(n[1],n[2],n[3],n[4]):null}var TG=function(){return c(function e(){o(this,e),this.values=Object.create(null)},[{key:"set",value:function(e,t){this.get(e)||""===t||(this.values[e]=t)}},{key:"get",value:function(e,t,n){return n?this.has(e)?this.values[e]:t[n]:this.has(e)?this.values[e]:t}},{key:"has",value:function(e){return e in this.values}},{key:"alt",value:function(e,t,n){for(var i=0;i<n.length;++i)if(t===n[i]){this.set(e,t);break}}},{key:"integer",value:function(e,t){/^-?\d+$/.test(t)&&this.set(e,parseInt(t,10))}},{key:"percent",value:function(e,t){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(t)){var n=parseFloat(t);if(n>=0&&n<=100)return this.set(e,n),!0}return!1}}])}();function _G(e,t,n,i){var a=i?e.split(i):[e];for(var r in a)if("string"==typeof a[r]){var o=a[r].split(n);if(2===o.length)t(o[0],o[1])}}var MG=new SG(0,0,""),AG="middle"===MG.align?"middle":"center";function DG(e,t,n){var i=e;function a(){var t=PG(e);if(null===t)throw new Error("Malformed timestamp: "+i);return e=e.replace(/^[^\sa-zA-Z-]+/,""),t}function r(){e=e.replace(/^\s+/,"")}if(r(),t.startTime=a(),r(),"--\x3e"!==e.slice(0,3))throw new Error("Malformed time stamp (time stamps must be separated by '--\x3e'): "+i);e=e.slice(3),r(),t.endTime=a(),r(),function(e,t){var i=new TG;_G(e,function(e,t){var a;switch(e){case"region":for(var r=n.length-1;r>=0;r--)if(n[r].id===t){i.set(e,n[r].region);break}break;case"vertical":i.alt(e,t,["rl","lr"]);break;case"line":a=t.split(","),i.integer(e,a[0]),i.percent(e,a[0])&&i.set("snapToLines",!1),i.alt(e,a[0],["auto"]),2===a.length&&i.alt("lineAlign",a[1],["start",AG,"end"]);break;case"position":a=t.split(","),i.percent(e,a[0]),2===a.length&&i.alt("positionAlign",a[1],["start",AG,"end","line-left","line-right","auto"]);break;case"size":i.percent(e,t);break;case"align":i.alt(e,t,["start",AG,"end","left","right"])}},/:/,/\s/),t.region=i.get("region",null),t.vertical=i.get("vertical","");var a=i.get("line","auto");"auto"===a&&-1===MG.line&&(a=-1),t.line=a,t.lineAlign=i.get("lineAlign","start"),t.snapToLines=i.get("snapToLines",!0),t.size=i.get("size",100),t.align=i.get("align",AG);var r=i.get("position","auto");"auto"===r&&50===MG.position&&(r="start"===t.align||"left"===t.align?0:"end"===t.align||"right"===t.align?100:50),t.position=r}(e,t)}function xG(e){return e.replace(/<br(?: \/)?>/gi,"\n")}var CG=function(){return c(function e(){o(this,e),this.state="INITIAL",this.buffer="",this.decoder=new EG,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0},[{key:"parse",value:function(e){var t=this;function n(){var e=t.buffer,n=0;for(e=xG(e);n<e.length&&"\r"!==e[n]&&"\n"!==e[n];)++n;var i=e.slice(0,n);return"\r"===e[n]&&++n,"\n"===e[n]&&++n,t.buffer=e.slice(n),i}function i(e){_G(e,function(e,t){},/:/)}e&&(t.buffer+=t.decoder.decode(e,{stream:!0}));try{var a="";if("INITIAL"===t.state){if(!/\r\n|\n/.test(t.buffer))return this;var r=(a=n()).match(/^()?WEBVTT([ \t].*)?$/);if(null==r||!r[0])throw new Error("Malformed WebVTT signature.");t.state="HEADER"}for(var o=!1;t.buffer;){if(!/\r\n|\n/.test(t.buffer))return this;switch(o?o=!1:a=n(),t.state){case"HEADER":/:/.test(a)?i(a):a||(t.state="ID");continue;case"NOTE":a||(t.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(a)){t.state="NOTE";break}if(!a)continue;if(t.cue=new SG(0,0,""),t.state="CUE",-1===a.indexOf("--\x3e")){t.cue.id=a;continue}case"CUE":if(!t.cue){t.state="BADCUE";continue}try{DG(a,t.cue,t.regionList)}catch(e){t.cue=null,t.state="BADCUE";continue}t.state="CUETEXT";continue;case"CUETEXT":var s=-1!==a.indexOf("--\x3e");if(!a||s&&(o=!0)){t.oncue&&t.cue&&t.oncue(t.cue),t.cue=null,t.state="ID";continue}if(null===t.cue)continue;t.cue.text&&(t.cue.text+="\n"),t.cue.text+=a;continue;case"BADCUE":a||(t.state="ID")}}}catch(e){"CUETEXT"===t.state&&t.cue&&t.oncue&&t.oncue(t.cue),t.cue=null,t.state="INITIAL"===t.state?"BADWEBVTT":"BADCUE"}return this}},{key:"flush",value:function(){var e=this;try{if((e.cue||"HEADER"===e.state)&&(e.buffer+="\n\n",e.parse()),"INITIAL"===e.state||"BADWEBVTT"===e.state)throw new Error("Malformed WebVTT signature.")}catch(t){e.onparsingerror&&e.onparsingerror(t)}return e.onflush&&e.onflush(),this}}])}(),IG=/\r\n|\n\r|\n|\r/g,LG=function(e,t,n=0){return e.slice(n,n+t.length)===t};function RG(e,t,n){return jH(e.toString())+jH(t.toString())+jH(n)}function FG(e,t,n,i,a,r,o){var s,u=new CG,l=O$(new Uint8Array(e)).trim().replace(IG,"\n").split("\n"),d=[],c=t?function(e,t=1){return Yz(e,9e4,1/t)}(t.baseTime,t.timescale):0,h="00:00.000",m=0,f=0,v=!0;u.oncue=function(e){var r=n[i],o=n.ccOffset,u=(m-c)/9e4;if(null!=r&&r.new&&(void 0!==f?o=n.ccOffset=r.start:function(e,t,n){var i=e[t],a=e[i.prevCC];if(!a||!a.new&&i.new)return e.ccOffset=e.presentationOffset=i.start,void(i.new=!1);for(;null!=(r=a)&&r.new;){var r;e.ccOffset+=i.start-a.start,i.new=!1,a=e[(i=a).prevCC]}e.presentationOffset=n}(n,i,u)),u){if(!t)return void(s=new Error("Missing initPTS for VTT MPEGTS"));o=u-n.presentationOffset}var l=e.endTime-e.startTime,h=nU(9e4*(e.startTime+o-f),9e4*a)/9e4;e.startTime=Math.max(h,0),e.endTime=Math.max(h+l,0);var v=e.text.trim();e.text=decodeURIComponent(encodeURIComponent(v)),e.id||(e.id=RG(e.startTime,e.endTime,v)),e.endTime>0&&d.push(e)},u.onparsingerror=function(e){s=e},u.onflush=function(){s?o(s):r(d)},l.forEach(e=>{if(v){if(LG(e,"X-TIMESTAMP-MAP=")){v=!1,e.slice(16).split(",").forEach(e=>{LG(e,"LOCAL:")?h=e.slice(6):LG(e,"MPEGTS:")&&(m=parseInt(e.slice(7)))});try{f=function(e){var t=parseInt(e.slice(-3)),n=parseInt(e.slice(-6,-4)),i=parseInt(e.slice(-9,-7)),a=e.length>9?parseInt(e.substring(0,e.indexOf(":"))):0;if(!(u$(t)&&u$(n)&&u$(i)&&u$(a)))throw Error(`Malformed X-TIMESTAMP-MAP: Local:${e}`);return t+=1e3*n,t+=6e4*i,t+36e5*a}(h)/1e3}catch(e){s=e}return}""===e&&(v=!1)}u.parse(e+"\n")}),u.flush()}var OG="stpp.ttml.im1t",$G=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,NG=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,WG={left:"start",center:"center",right:"end",start:"start",end:"end"};function jG(e,t,n,i){var a=oN(new Uint8Array(e),["mdat"]);if(0!==a.length){var r=a.map(e=>O$(e)),o=function(e,t,n=1,i=!1){return Yz(e,t,1/n,i)}(t.baseTime,1,t.timescale);try{r.forEach(e=>n(function(e,t){var n=(new DOMParser).parseFromString(e,"text/xml"),i=n.getElementsByTagName("tt")[0];if(!i)throw new Error("Invalid ttml");var a={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},r=Object.keys(a).reduce((e,t)=>(e[t]=i.getAttribute(`ttp:${t}`)||a[t],e),{}),o="preserve"!==i.getAttribute("xml:space"),s=zG(BG(i,"styling","style")),u=zG(BG(i,"layout","region")),l=BG(i,"body","[begin]");return[].map.call(l,e=>{var n=UG(e,o);if(!n||!e.hasAttribute("begin"))return null;var i=VG(e.getAttribute("begin"),r),a=VG(e.getAttribute("dur"),r),l=VG(e.getAttribute("end"),r);if(null===i)throw GG(e);if(null===l){if(null===a)throw GG(e);l=i+a}var d=new SG(i-t,l-t,n);d.id=RG(d.startTime,d.endTime,d.text);var c=function(e,t,n){var i="http://www.w3.org/ns/ttml#styling",a=null,r=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],o=null!=e&&e.hasAttribute("style")?e.getAttribute("style"):null;o&&n.hasOwnProperty(o)&&(a=n[o]);return r.reduce((n,r)=>{var o=HG(t,i,r)||HG(e,i,r)||HG(a,i,r);return o&&(n[r]=o),n},{})}(u[e.getAttribute("region")],s[e.getAttribute("style")],s),h=c.textAlign;if(h){var m=WG[h];m&&(d.lineAlign=m),d.align=h}return P$(d,c),d}).filter(e=>null!==e)}(e,o)))}catch(e){i(e)}}else i(new Error("Could not parse IMSC1 mdat"))}function BG(e,t,n){var i=e.getElementsByTagName(t)[0];return i?[].slice.call(i.querySelectorAll(n)):[]}function zG(e){return e.reduce((e,t)=>{var n=t.getAttribute("xml:id");return n&&(e[n]=t),e},{})}function UG(e,t){return[].slice.call(e.childNodes).reduce((e,n,i)=>{var a;return"br"===n.nodeName&&i?e+"\n":null!=(a=n.childNodes)&&a.length?UG(n,t):t?e+n.textContent.trim().replace(/\s+/g," "):e+n.textContent},"")}function HG(e,t,n){return e&&e.hasAttributeNS(t,n)?e.getAttributeNS(t,n):null}function GG(e){return new Error(`Could not parse ttml timestamp ${e}`)}function VG(e,t){if(!e)return null;var n=PG(e);return null===n&&($G.test(e)?n=function(e,t){var n=$G.exec(e),i=(0|n[4])+(0|n[5])/t.subFrameRate;return 3600*(0|n[1])+60*(0|n[2])+(0|n[3])+i/t.frameRate}(e,t):NG.test(e)&&(n=function(e,t){var n=NG.exec(e),i=Number(n[1]);switch(n[2]){case"h":return 3600*i;case"m":return 60*i;case"ms":return 1e3*i;case"f":return i/t.frameRate;case"t":return i/t.tickRate}return i}(e,t))),n}var KG=function(){return c(function e(t,n){o(this,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=n},[{key:"dispatchCue",value:function(){null!==this.startTime&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)}},{key:"newCue",value:function(e,t,n){(null===this.startTime||this.startTime>e)&&(this.startTime=e),this.endTime=t,this.screen=n,this.timelineController.createCaptionsTrack(this.trackName)}},{key:"reset",value:function(){this.cueRanges=[],this.startTime=null}}])}(),XG=function(){return c(function e(t){o(this,e),this.hls=void 0,this.media=null,this.config=void 0,this.enabled=!0,this.Cues=void 0,this.textTracks=[],this.tracks=[],this.initPTS=[],this.unparsedVttFrags=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.cea608Parser1=void 0,this.cea608Parser2=void 0,this.lastCc=-1,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs={ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}},this.captionsProperties=void 0,this.hls=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(m$.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(m$.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(m$.MANIFEST_LOADING,this.onManifestLoading,this),t.on(m$.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(m$.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.on(m$.FRAG_LOADING,this.onFragLoading,this),t.on(m$.FRAG_LOADED,this.onFragLoaded,this),t.on(m$.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),t.on(m$.FRAG_DECRYPTED,this.onFragDecrypted,this),t.on(m$.INIT_PTS_FOUND,this.onInitPtsFound,this),t.on(m$.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),t.on(m$.BUFFER_FLUSHING,this.onBufferFlushing,this)},[{key:"destroy",value:function(){var e=this.hls;e.off(m$.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(m$.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(m$.MANIFEST_LOADING,this.onManifestLoading,this),e.off(m$.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(m$.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(m$.FRAG_LOADING,this.onFragLoading,this),e.off(m$.FRAG_LOADED,this.onFragLoaded,this),e.off(m$.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.off(m$.FRAG_DECRYPTED,this.onFragDecrypted,this),e.off(m$.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(m$.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.off(m$.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.media=null,this.cea608Parser1=this.cea608Parser2=void 0}},{key:"initCea608Parsers",value:function(){var e=new KG(this,"textTrack1"),t=new KG(this,"textTrack2"),n=new KG(this,"textTrack3"),i=new KG(this,"textTrack4");this.cea608Parser1=new wG(1,e,t),this.cea608Parser2=new wG(3,n,i)}},{key:"addCues",value:function(e,t,n,i,a){for(var r=!1,o=a.length;o--;){var s=a[o],u=JG(s[0],s[1],t,n);if(u>=0&&(s[0]=Math.min(s[0],t),s[1]=Math.max(s[1],n),r=!0,u/(n-t)>.5))return}if(r||a.push([t,n]),this.config.renderTextTracksNatively){var l=this.captionsTracks[e];this.Cues.newCue(l,t,n,i)}else{var d=this.Cues.newCue(null,t,n,i);this.hls.trigger(m$.CUES_PARSED,{type:"captions",cues:d,track:e})}}},{key:"onInitPtsFound",value:function(e,{frag:t,id:n,initPTS:i,timescale:a,trackId:r}){var o=this.unparsedVttFrags;n===y$&&(this.initPTS[t.cc]={baseTime:i,timescale:a,trackId:r}),o.length&&(this.unparsedVttFrags=[],o.forEach(e=>{this.initPTS[e.frag.cc]?this.onFragLoaded(m$.FRAG_LOADED,e):this.hls.trigger(m$.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e.frag,error:new Error("Subtitle discontinuity domain does not match main")})}))}},{key:"getExistingTrack",value:function(e,t){var n=this.media;if(n)for(var i=0;i<n.textTracks.length;i++){var a=n.textTracks[i];if(qG(a,{name:e,lang:t,characteristics:"transcribes-spoken-dialog,describes-music-and-sound"}))return a}return null}},{key:"createCaptionsTrack",value:function(e){this.config.renderTextTracksNatively?this.createNativeTrack(e):this.createNonNativeTrack(e)}},{key:"createNativeTrack",value:function(e){if(!this.captionsTracks[e]){var t=this.captionsProperties,n=this.captionsTracks,i=this.media,a=t[e],r=a.label,o=a.languageCode,s=this.getExistingTrack(r,o);if(s)n[e]=s,OH(n[e]),RH(n[e],i);else{var u=this.createTextTrack("captions",r,o);u&&(u[e]=!0,n[e]=u)}}}},{key:"createNonNativeTrack",value:function(e){if(!this.nonNativeCaptionsTracks[e]){var t=this.captionsProperties[e];if(t){var n={_id:e,label:t.label,kind:"captions",default:!!t.media&&!!t.media.default,closedCaptions:t.media};this.nonNativeCaptionsTracks[e]=n,this.hls.trigger(m$.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[n]})}}}},{key:"createTextTrack",value:function(e,t,n){var i=this.media;if(i)return i.addTextTrack(e,t,n)}},{key:"onMediaAttaching",value:function(e,t){this.media=t.media,t.mediaSource||this._cleanTracks()}},{key:"onMediaDetaching",value:function(e,t){var n=!!t.transferMedia;if(this.media=null,!n){var i=this.captionsTracks;Object.keys(i).forEach(e=>{OH(i[e]),delete i[e]}),this.nonNativeCaptionsTracks={}}}},{key:"onManifestLoading",value:function(){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())}},{key:"_cleanTracks",value:function(){var e=this.media;if(e){var t=e.textTracks;if(t)for(var n=0;n<t.length;n++)OH(t[n])}}},{key:"onSubtitleTracksUpdated",value:function(e,t){var n=t.subtitleTracks||[],i=n.some(e=>e.textCodec===OG);if(this.config.enableWebVTT||i&&this.config.enableIMSC1){if(bU(this.tracks,n))return void(this.tracks=n);if(this.textTracks=[],this.tracks=n,this.config.renderTextTracksNatively){var a=this.media,r=a?NH(a.textTracks):null;if(this.tracks.forEach((e,t)=>{var n;if(r){for(var i=null,a=0;a<r.length;a++)if(r[a]&&qG(r[a],e)){i=r[a],r[a]=null;break}i&&(n=i)}if(n)OH(n);else{var o=YG(e);(n=this.createTextTrack(o,e.name,e.lang))&&(n.mode="disabled")}n&&this.textTracks.push(n)}),null!=r&&r.length){var o=r.filter(e=>null!==e).map(e=>e.label);o.length&&this.hls.logger.warn(`Media element contains unused subtitle tracks: ${o.join(", ")}. Replace media element for each source to clear TextTracks and captions menu.`)}}else if(this.tracks.length){var s=this.tracks.map(e=>({label:e.name,kind:e.type.toLowerCase(),default:e.default,subtitleTrack:e}));this.hls.trigger(m$.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:s})}}}},{key:"onManifestLoaded",value:function(e,t){this.config.enableCEA708Captions&&t.captions&&t.captions.forEach(e=>{var t=/(?:CC|SERVICE)([1-4])/.exec(e.instreamId);if(t){var n=`textTrack${t[1]}`,i=this.captionsProperties[n];i&&(i.label=e.name,e.lang&&(i.languageCode=e.lang),i.media=e)}})}},{key:"closedCaptionsForLevel",value:function(e){var t=this.hls.levels[e.level];return null==t?void 0:t.attrs["CLOSED-CAPTIONS"]}},{key:"onFragLoading",value:function(e,t){if(this.enabled&&t.frag.type===y$){var n,i,a=this.cea608Parser1,r=this.cea608Parser2,o=this.lastSn,s=t.frag,u=s.cc,l=s.sn,d=null!=(n=null==(i=t.part)?void 0:i.index)?n:-1;a&&r&&(l!==o+1||l===o&&d!==this.lastPartIndex+1||u!==this.lastCc)&&(a.reset(),r.reset()),this.lastCc=u,this.lastSn=l,this.lastPartIndex=d}}},{key:"onFragLoaded",value:function(e,t){var n=t.frag,i=t.payload;if(n.type===w$)if(i.byteLength){var a=n.decryptdata,r="stats"in t;if(null==a||!a.encrypted||r){var o=this.tracks[n.level],s=this.vttCCs;s[n.cc]||(s[n.cc]={start:n.start,prevCC:this.prevCC,new:!0},this.prevCC=n.cc),o&&o.textCodec===OG?this._parseIMSC1(n,i):this._parseVTTs(t)}}else this.hls.trigger(m$.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:n,error:new Error("Empty subtitle payload")})}},{key:"_parseIMSC1",value:function(e,t){var n=this.hls;jG(t,this.initPTS[e.cc],t=>{this._appendCues(t,e.level),n.trigger(m$.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})},t=>{n.logger.log(`Failed to parse IMSC1: ${t}`),n.trigger(m$.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e,error:t})})}},{key:"_parseVTTs",value:function(e){var t,n=e.frag,i=e.payload,a=this.initPTS,r=this.unparsedVttFrags,o=a.length-1;if(a[n.cc]||-1!==o){var s=this.hls;FG(null!=(t=n.initSegment)&&t.data?pN(n.initSegment.data,new Uint8Array(i)).buffer:i,this.initPTS[n.cc],this.vttCCs,n.cc,n.start,e=>{this._appendCues(e,n.level),s.trigger(m$.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:n})},t=>{var a="Missing initPTS for VTT MPEGTS"===t.message;a?r.push(e):this._fallbackToIMSC1(n,i),s.logger.log(`Failed to parse VTT cue: ${t}`),a&&o>n.cc||s.trigger(m$.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:n,error:t})})}else r.push(e)}},{key:"_fallbackToIMSC1",value:function(e,t){var n=this.tracks[e.level];n.textCodec||jG(t,this.initPTS[e.cc],()=>{n.textCodec=OG,this._parseIMSC1(e,t)},()=>{n.textCodec="wvtt"})}},{key:"_appendCues",value:function(e,t){var n=this.hls;if(this.config.renderTextTracksNatively){var i=this.textTracks[t];if(!i||"disabled"===i.mode)return;e.forEach(e=>FH(i,e))}else{var a=this.tracks[t];if(!a)return;var r=a.default?"default":"subtitles"+t;n.trigger(m$.CUES_PARSED,{type:"subtitles",cues:e,track:r})}}},{key:"onFragDecrypted",value:function(e,t){t.frag.type===w$&&this.onFragLoaded(m$.FRAG_LOADED,t)}},{key:"onSubtitleTracksCleared",value:function(){this.tracks=[],this.captionsTracks={}}},{key:"onFragParsingUserdata",value:function(e,t){if(this.enabled&&this.config.enableCEA708Captions){var n=t.frag,i=t.samples;if(n.type!==y$||"NONE"!==this.closedCaptionsForLevel(n))for(var a=0;a<i.length;a++){var r=i[a].bytes;if(r){this.cea608Parser1||this.initCea608Parsers();var o=this.extractCea608Data(r);this.cea608Parser1.addData(i[a].pts,o[0]),this.cea608Parser2.addData(i[a].pts,o[1])}}}}},{key:"onBufferFlushing",value:function(e,{startOffset:t,endOffset:n,endOffsetSubtitles:i,type:a}){var r=this.media;if(r&&!(r.currentTime<n)){if(!a||"video"===a){var o=this.captionsTracks;Object.keys(o).forEach(e=>$H(o[e],t,n))}if(this.config.renderTextTracksNatively&&0===t&&void 0!==i){var s=this.textTracks;Object.keys(s).forEach(e=>$H(s[e],t,i))}}}},{key:"extractCea608Data",value:function(e){for(var t=[[],[]],n=31&e[0],i=2,a=0;a<n;a++){var r=e[i++],o=127&e[i++],s=127&e[i++];if(0!==o||0!==s)if(!!(4&r)){var u=3&r;0!==u&&1!==u||(t[u].push(o),t[u].push(s))}}return t}}])}();function YG(e){return e.characteristics&&/transcribes-spoken-dialog/gi.test(e.characteristics)&&/describes-music-and-sound/gi.test(e.characteristics)?"captions":"subtitles"}function qG(e,t){return!!e&&e.kind===YG(t)&&kU(t,e)}function JG(e,t,n,i){return Math.min(t,i)-Math.max(e,n)}var QG=/\s/,ZG={newCue(e,t,n,i){for(var a,r,o,s,u,l=[],d=self.VTTCue||self.TextTrackCue,c=0;c<i.rows.length;c++)if(o=!0,s=0,u="",!(a=i.rows[c]).isEmpty()){for(var h,m=0;m<a.chars.length;m++)QG.test(a.chars[m].uchar)&&o?s++:(u+=a.chars[m].uchar,o=!1);a.cueStartTime=t,t===n&&(n+=1e-4),s>=16?s--:s++;var f=xG(u.trim()),v=RG(t,n,f);null!=e&&null!=(h=e.cues)&&h.getCueById(v)||((r=new d(t,n,f)).id=v,r.line=c+1,r.align="left",r.position=10+Math.min(80,10*Math.floor(8*s/32)),l.push(r))}return e&&l.length&&(l.sort((e,t)=>"auto"===e.line||"auto"===t.line?0:e.line>8&&t.line>8?t.line-e.line:e.line-t.line),l.forEach(t=>FH(e,t))),l}};var eV=/(\d+)-(\d+)\/(\d+)/,tV=function(){return c(function e(t){o(this,e),this.fetchSetup=void 0,this.requestTimeout=void 0,this.request=null,this.response=null,this.controller=void 0,this.context=null,this.config=null,this.callbacks=null,this.stats=void 0,this.loader=null,this.fetchSetup=t.fetchSetup||nV,this.controller=new self.AbortController,this.stats=new U$},[{key:"destroy",value:function(){this.loader=this.callbacks=this.context=this.config=this.request=null,this.abortInternal(),this.response=null,this.fetchSetup=this.controller=this.stats=null}},{key:"abortInternal",value:function(){this.controller&&!this.stats.loading.end&&(this.stats.aborted=!0,this.controller.abort())}},{key:"abort",value:function(){var e;this.abortInternal(),null!=(e=this.callbacks)&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)}},{key:"load",value:function(e,t,n){var i=this.stats;if(i.loading.start)throw new Error("Loader can only be used once.");i.loading.start=self.performance.now();var a=function(e,t){var n={method:"GET",mode:"cors",credentials:"same-origin",signal:t,headers:new self.Headers(P$({},e.headers))};e.rangeEnd&&n.headers.set("Range","bytes="+e.rangeStart+"-"+String(e.rangeEnd-1));return n}(e,this.controller.signal),r="arraybuffer"===e.responseType,o=r?"byteLength":"length",s=t.loadPolicy,u=s.maxTimeToFirstByteMs,l=s.maxLoadTimeMs;this.context=e,this.config=t,this.callbacks=n,this.request=this.fetchSetup(e,a),self.clearTimeout(this.requestTimeout),t.timeout=u&&u$(u)?u:l,this.requestTimeout=self.setTimeout(()=>{this.callbacks&&(this.abortInternal(),this.callbacks.onTimeout(i,e,this.response))},t.timeout),(hU(this.request)?this.request.then(self.fetch):self.fetch(this.request)).then(n=>{var a;this.response=this.loader=n;var o=Math.max(self.performance.now(),i.loading.start);if(self.clearTimeout(this.requestTimeout),t.timeout=l,this.requestTimeout=self.setTimeout(()=>{this.callbacks&&(this.abortInternal(),this.callbacks.onTimeout(i,e,this.response))},l-(o-i.loading.start)),!n.ok){var s=n.status,u=n.statusText;throw new iV(u||"fetch, bad network response",s,n)}i.loading.first=o,i.total=function(e){var t=e.get("Content-Range");if(t){var n=function(e){var t=eV.exec(e);if(t)return parseInt(t[2])-parseInt(t[1])+1}(t);if(u$(n))return n}var i=e.get("Content-Length");if(i)return parseInt(i)}(n.headers)||i.total;var d=null==(a=this.callbacks)?void 0:a.onProgress;return d&&u$(t.highWaterMark)?this.loadProgressively(n,i,e,t.highWaterMark,d):r?n.arrayBuffer():"json"===e.responseType?n.json():n.text()}).then(n=>{var a,r,s=this.response;if(!s)throw new Error("loader destroyed");self.clearTimeout(this.requestTimeout),i.loading.end=Math.max(self.performance.now(),i.loading.first);var u=n[o];u&&(i.loaded=i.total=u);var l={url:s.url,data:n,code:s.status},d=null==(a=this.callbacks)?void 0:a.onProgress;d&&!u$(t.highWaterMark)&&d(i,e,n,s),null==(r=this.callbacks)||r.onSuccess(l,i,e,s)}).catch(t=>{var n;if(self.clearTimeout(this.requestTimeout),!i.aborted){var a=t&&t.code||0,r=t?t.message:null;null==(n=this.callbacks)||n.onError({code:a,text:r},e,t?t.details:null,i)}})}},{key:"getCacheAge",value:function(){var e=null;if(this.response){var t=this.response.headers.get("age");e=t?parseFloat(t):null}return e}},{key:"getResponseHeader",value:function(e){return this.response?this.response.headers.get(e):null}},{key:"loadProgressively",value:function(e,t,n,i=0,a){var r=new $B,o=e.body.getReader(),s=()=>o.read().then(o=>{if(o.done)return r.dataLength&&a(t,n,r.flush().buffer,e),Promise.resolve(new ArrayBuffer(0));var u=o.value,l=u.length;return t.loaded+=l,l<i||r.dataLength?(r.push(u),r.dataLength>=i&&a(t,n,r.flush().buffer,e)):a(t,n,u.buffer,e),s()}).catch(()=>Promise.reject());return s()}}])}();function nV(e,t){return new self.Request(e.url,t)}var iV=function(e){function t(e,n,i){var a;return o(this,t),(a=r(this,t,[e])).code=void 0,a.details=void 0,a.code=n,a.details=i,a}return p(t,e),c(t)}(M(Error)),aV=/^age:\s*[\d.]+\s*$/im,rV=function(){return c(function e(t){o(this,e),this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=null,this.loader=null,this.stats=void 0,this.xhrSetup=t&&t.xhrSetup||null,this.stats=new U$,this.retryDelay=0},[{key:"destroy",value:function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null,this.context=null,this.xhrSetup=null}},{key:"abortInternal",value:function(){var e=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),e&&(e.onreadystatechange=null,e.onprogress=null,4!==e.readyState&&(this.stats.aborted=!0,e.abort()))}},{key:"abort",value:function(){var e;this.abortInternal(),null!=(e=this.callbacks)&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)}},{key:"load",value:function(e,t,n){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=e,this.config=t,this.callbacks=n,this.loadInternal()}},{key:"loadInternal",value:function(){var e=this.config,t=this.context;if(e&&t){var n=this.loader=new self.XMLHttpRequest,i=this.stats;i.loading.first=0,i.loaded=0,i.aborted=!1;var a=this.xhrSetup;a?Promise.resolve().then(()=>{if(this.loader===n&&!this.stats.aborted)return a(n,t.url)}).catch(e=>{if(this.loader===n&&!this.stats.aborted)return n.open("GET",t.url,!0),a(n,t.url)}).then(()=>{this.loader!==n||this.stats.aborted||this.openAndSendXhr(n,t,e)}).catch(e=>{var a;null==(a=this.callbacks)||a.onError({code:n.status,text:e.message},t,n,i)}):this.openAndSendXhr(n,t,e)}}},{key:"openAndSendXhr",value:function(e,t,n){e.readyState||e.open("GET",t.url,!0);var i=t.headers,a=n.loadPolicy,r=a.maxTimeToFirstByteMs,o=a.maxLoadTimeMs;if(i)for(var s in i)e.setRequestHeader(s,i[s]);t.rangeEnd&&e.setRequestHeader("Range","bytes="+t.rangeStart+"-"+(t.rangeEnd-1)),e.onreadystatechange=this.readystatechange.bind(this),e.onprogress=this.loadprogress.bind(this),e.responseType=t.responseType,self.clearTimeout(this.requestTimeout),n.timeout=r&&u$(r)?r:o,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),n.timeout),e.send()}},{key:"readystatechange",value:function(){var e=this.context,t=this.loader,n=this.stats;if(e&&t){var i=t.readyState,a=this.config;if(!n.aborted&&i>=2&&(0===n.loading.first&&(n.loading.first=Math.max(self.performance.now(),n.loading.start),a.timeout!==a.loadPolicy.maxLoadTimeMs&&(self.clearTimeout(this.requestTimeout),a.timeout=a.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),a.loadPolicy.maxLoadTimeMs-(n.loading.first-n.loading.start)))),4===i)){self.clearTimeout(this.requestTimeout),t.onreadystatechange=null,t.onprogress=null;var r=t.status,o="text"===t.responseType?t.responseText:null;if(r>=200&&r<300){var s=null!=o?o:t.response;if(null!=s){var u,l;n.loading.end=Math.max(self.performance.now(),n.loading.first);var d="arraybuffer"===t.responseType?s.byteLength:s.length;n.loaded=n.total=d,n.bwEstimate=8e3*n.total/(n.loading.end-n.loading.first);var c=null==(u=this.callbacks)?void 0:u.onProgress;c&&c(n,e,s,t);var h={url:t.responseURL,data:s,code:r};return void(null==(l=this.callbacks)||l.onSuccess(h,n,e,t))}}var m,f=a.loadPolicy.errorRetry;if(EW(f,n.retry,!1,{url:e.url,data:void 0,code:r}))this.retry(f);else L$.error(`${r} while loading ${e.url}`),null==(m=this.callbacks)||m.onError({code:r,text:t.statusText},e,t,n)}}}},{key:"loadtimeout",value:function(){if(this.config){var e=this.config.loadPolicy.timeoutRetry;if(EW(e,this.stats.retry,!0))this.retry(e);else{var t;L$.warn(`timeout while loading ${null==(t=this.context)?void 0:t.url}`);var n=this.callbacks;n&&(this.abortInternal(),n.onTimeout(this.stats,this.context,this.loader))}}}},{key:"retry",value:function(e){var t=this.context,n=this.stats;this.retryDelay=kW(e,n.retry),n.retry++,L$.warn(`${status?"HTTP Status "+status:"Timeout"} while loading ${null==t?void 0:t.url}, retrying ${n.retry}/${e.maxNumRetry} in ${this.retryDelay}ms`),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay)}},{key:"loadprogress",value:function(e){var t=this.stats;t.loaded=e.loaded,e.lengthComputable&&(t.total=e.total)}},{key:"getCacheAge",value:function(){var e=null;if(this.loader&&aV.test(this.loader.getAllResponseHeaders())){var t=this.loader.getResponseHeader("age");e=t?parseFloat(t):null}return e}},{key:"getResponseHeader",value:function(e){return this.loader&&new RegExp(`^${e}:\\s*[\\d.]+\\s*$`,"im").test(this.loader.getAllResponseHeaders())?this.loader.getResponseHeader(e):null}}])}(),oV=_$(_$({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,maxDevicePixelRatio:Number.POSITIVE_INFINITY,preferManagedMediaSource:!0,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,frontBufferFlushThreshold:1/0,startOnSegmentBoundary:!1,maxBufferSize:6e7,maxFragLookUpTolerance:.25,maxBufferHole:.1,detectStallWithCurrentTimeMs:1250,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,nudgeOnVideoHole:!0,liveSyncMode:"edge",liveSyncDurationCount:3,liveSyncOnStallIncrease:1,liveMaxLatencyDurationCount:1/0,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,maxLiveSyncPlaybackRate:1,liveDurationInfinity:!1,liveBackBufferLength:null,maxMaxBufferLength:600,enableWorker:!0,workerPath:null,enableSoftwareAES:!0,startLevel:void 0,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,ignorePlaylistParsingErrors:!1,loader:rV,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:cW,bufferController:MU,capLevelController:xU,errorController:LW,fpsController:LH,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:Rj,requireKeySystemAccessOnStart:!1,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableEmsgKLVMetadata:!1,enableID3MetadataCues:!0,enableInterstitialPlayback:!0,interstitialAppendInPlace:!0,interstitialLiveLookAhead:10,useMediaCapabilities:!0,preserveManualLevelOnError:!1,certLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null}},keyLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"},errorRetry:{maxNumRetry:8,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"}}},manifestLoadPolicy:{default:{maxTimeToFirstByteMs:1/0,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},playlistLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:2,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},fragLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:12e4,timeoutRetry:{maxNumRetry:4,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:6,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},steeringManifestLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},interstitialAssetListLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:3e4,timeoutRetry:{maxNumRetry:0,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:0,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3},{cueHandler:ZG,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:nG,subtitleTrackController:WH,timelineController:XG,audioStreamController:gU,audioTrackController:SU,emeController:AH,cmcdController:PH,contentSteeringController:TH,interstitialsController:tG});function sV(e){return e&&"object"==typeof e?Array.isArray(e)?e.map(sV):Object.keys(e).reduce((t,n)=>(t[n]=sV(e[n]),t),{}):e}function uV(e,t){var n=e.loader;n!==tV&&n!==rV?(t.log("[config]: Custom loader detected, cannot enable progressive streaming"),e.progressive=!1):function(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch(e){}return!1}()&&(e.loader=tV,e.progressive=!0,e.enableSoftwareAES=!0,t.log("[config]: Progressive streaming enabled, using FetchLoader"))}var lV=function(e){function t(e,n){var i;return o(this,t),(i=r(this,t,["gap-controller",e.logger])).hls=void 0,i.fragmentTracker=void 0,i.media=null,i.mediaSource=void 0,i.nudgeRetry=0,i.stallReported=!1,i.stalled=null,i.moved=!1,i.seeking=!1,i.buffered={},i.lastCurrentTime=0,i.ended=0,i.waiting=0,i.onMediaPlaying=()=>{i.ended=0,i.waiting=0},i.onMediaWaiting=()=>{var e;null!=(e=i.media)&&e.seeking||(i.waiting=self.performance.now(),i.tick())},i.onMediaEnded=()=>{var e;i.hls&&(i.ended=(null==(e=i.media)?void 0:e.currentTime)||1,i.hls.trigger(m$.MEDIA_ENDED,{stalled:!1}))},i.hls=e,i.fragmentTracker=n,i.registerListeners(),i}return p(t,e),c(t,[{key:"registerListeners",value:function(){var e=this.hls;e&&(e.on(m$.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(m$.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(m$.BUFFER_APPENDED,this.onBufferAppended,this))}},{key:"unregisterListeners",value:function(){var e=this.hls;e&&(e.off(m$.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(m$.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(m$.BUFFER_APPENDED,this.onBufferAppended,this))}},{key:"destroy",value:function(){T(t,"destroy",this)([]),this.unregisterListeners(),this.media=this.hls=this.fragmentTracker=null,this.mediaSource=void 0}},{key:"onMediaAttached",value:function(e,t){this.setInterval(100),this.mediaSource=t.mediaSource;var n=this.media=t.media;wB(n,"playing",this.onMediaPlaying),wB(n,"waiting",this.onMediaWaiting),wB(n,"ended",this.onMediaEnded)}},{key:"onMediaDetaching",value:function(e,t){this.clearInterval();var n=this.media;n&&(kB(n,"playing",this.onMediaPlaying),kB(n,"waiting",this.onMediaWaiting),kB(n,"ended",this.onMediaEnded),this.media=null),this.mediaSource=void 0}},{key:"onBufferAppended",value:function(e,t){this.buffered=t.timeRanges}},{key:"hasBuffered",get:function(){return Object.keys(this.buffered).length>0}},{key:"tick",value:function(){var e;if(null!=(e=this.media)&&e.readyState&&this.hasBuffered){var t=this.media.currentTime;this.poll(t,this.lastCurrentTime),this.lastCurrentTime=t}}},{key:"poll",value:function(e,t){var n,i,a=null==(n=this.hls)?void 0:n.config;if(a){var r=this.media;if(r){var o=r.seeking,s=this.seeking&&!o,u=!this.seeking&&o,l=r.paused&&!o||r.ended||0===r.playbackRate;if(this.seeking=o,e!==t)return t&&(this.ended=0),this.moved=!0,o||(this.nudgeRetry=0,a.nudgeOnVideoHole&&!l&&e>t&&this.nudgeOnVideoHole(e,t)),void(0===this.waiting&&this.stallResolved(e));if(u||s)s&&this.stallResolved(e);else{if(l)return this.nudgeRetry=0,this.stallResolved(e),void(!this.ended&&r.ended&&this.hls&&(this.ended=e||1,this.hls.trigger(m$.MEDIA_ENDED,{stalled:!1})));if(ij.getBuffered(r).length){var d=ij.bufferInfo(r,e,0),c=d.nextStart||0,h=this.fragmentTracker;if(o&&h&&this.hls){var m=dV(this.hls.inFlightFragments,e),f=d.len>2,v=!c||m||c-e>2&&!h.getPartialFragment(e);if(f||v)return;this.moved=!1}var p=null==(i=this.hls)?void 0:i.latestLevelDetails;if(!this.moved&&null!==this.stalled&&h){if(!(d.len>0)&&!c)return;var g=Math.max(c,d.start||0)-e,y=!(null==p||!p.live)?2*p.targetduration:2,b=hV(e,h);if(g>0&&(g<=y||b))return void(r.paused||this._trySkipBufferHole(b))}var w=a.detectStallWithCurrentTimeMs,k=self.performance.now(),S=this.waiting,E=this.stalled;if(null===E){if(!(S>0&&k-S<w))return void(this.stalled=k);E=this.stalled=S}var P=k-E;if(!o&&(P>=w||S)&&this.hls){var T;if("ended"===(null==(T=this.mediaSource)?void 0:T.readyState)&&(null==p||!p.live)&&Math.abs(e-((null==p?void 0:p.edge)||0))<1){if(this.ended)return;return this.ended=e||1,void this.hls.trigger(m$.MEDIA_ENDED,{stalled:!0})}if(this._reportStall(d),!this.media||!this.hls)return}var _=ij.bufferInfo(r,e,a.maxBufferHole);this._tryFixBufferStall(_,P,e)}else this.nudgeRetry=0}}}}},{key:"stallResolved",value:function(e){var t=this.stalled;if(t&&this.hls&&(this.stalled=null,this.stallReported)){var n=self.performance.now()-t;this.log(`playback not stuck anymore @${e}, after ${Math.round(n)}ms`),this.stallReported=!1,this.waiting=0,this.hls.trigger(m$.STALL_RESOLVED,{})}}},{key:"nudgeOnVideoHole",value:function(e,t){var n,i=this.buffered.video;if(this.hls&&this.media&&this.fragmentTracker&&null!=(n=this.buffered.audio)&&n.length&&i&&i.length>1&&e>i.end(0)){var a=ij.bufferedInfo(ij.timeRangesToArray(this.buffered.audio),e,0);if(a.len>1&&t>=a.start){var r=ij.timeRangesToArray(i),o=ij.bufferedInfo(r,t,0).bufferedIndex;if(o>-1&&o<r.length-1){var s=ij.bufferedInfo(r,e,0).bufferedIndex,u=r[o].end,l=r[o+1].start;if((-1===s||s>o)&&l-u<1&&e-u<2){var d=new Error(`nudging playhead to flush pipeline after video hole. currentTime: ${e} hole: ${u} -> ${l} buffered index: ${s}`);this.warn(d.message),this.media.currentTime+=1e-6;var c=hV(e,this.fragmentTracker);c&&"fragment"in c?c=c.fragment:c||(c=void 0);var h=ij.bufferInfo(this.media,e,0);this.hls.trigger(m$.ERROR,{type:c$.MEDIA_ERROR,details:h$.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:d,reason:d.message,frag:c,buffer:h.len,bufferInfo:h})}}}}}},{key:"_tryFixBufferStall",value:function(e,t,n){var i,a,r=this.fragmentTracker,o=this.media,s=null==(i=this.hls)?void 0:i.config;if(o&&r&&s){var u=null==(a=this.hls)?void 0:a.latestLevelDetails,l=hV(n,r);if(l||null!=u&&u.live&&n<u.fragmentStart)if(this._trySkipBufferHole(l)||!this.media)return;var d=e.buffered,c=this.adjacentTraversal(e,n);(d&&d.length>1&&e.len>s.maxBufferHole||e.nextStart&&(e.nextStart-n<s.maxBufferHole||c))&&(t>1e3*s.highBufferWatchdogPeriod||this.waiting)&&(this.warn("Trying to nudge playhead over buffer-hole"),this._tryNudgeBuffer(e))}}},{key:"adjacentTraversal",value:function(e,t){var n=this.fragmentTracker,i=e.nextStart;if(n&&i){var a=n.getFragAtPos(t,y$),r=n.getFragAtPos(i,y$);if(a&&r)return r.sn-a.sn<2}return!1}},{key:"_reportStall",value:function(e){var t=this.hls,n=this.media,i=this.stallReported,a=this.stalled;if(!i&&null!==a&&n&&t){this.stallReported=!0;var r=new Error(`Playback stalling at @${n.currentTime} due to low buffer (${nW(e)})`);this.warn(r.message),t.trigger(m$.ERROR,{type:c$.MEDIA_ERROR,details:h$.BUFFER_STALLED_ERROR,fatal:!1,error:r,buffer:e.len,bufferInfo:e,stalled:{start:a}})}}},{key:"_trySkipBufferHole",value:function(e){var t,n=this.fragmentTracker,i=this.media,a=null==(t=this.hls)?void 0:t.config;if(!i||!n||!a)return 0;var r=i.currentTime,o=ij.bufferInfo(i,r,0),s=r<o.start?o.start:o.nextStart;if(s&&this.hls){var u=o.len<=a.maxBufferHole,l=o.len>0&&o.len<1&&i.readyState<3,d=s-r;if(d>0&&(u||l)){if(d>a.maxBufferHole){var c=!1;if(0===r){var h=n.getAppendedFrag(0,y$);h&&s<h.end&&(c=!0)}if(!c&&e){var m;if(null==(m=this.hls.loadLevelObj)||!m.details)return 0;if(dV(this.hls.inFlightFragments,s))return 0;for(var f=!1,v=e.end;v<s;){var p=hV(v,n);if(!p){f=!0;break}v+=p.duration}if(f)return 0}}var g=Math.max(s+.05,r+.1);if(this.warn(`skipping hole, adjusting currentTime from ${r} to ${g}`),this.moved=!0,i.currentTime=g,null==e||!e.gap){var y=new Error(`fragment loaded with buffer holes, seeking from ${r} to ${g}`),b={type:c$.MEDIA_ERROR,details:h$.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:y,reason:y.message,buffer:o.len,bufferInfo:o};e&&("fragment"in e?b.part=e:b.frag=e),this.hls.trigger(m$.ERROR,b)}return g}}return 0}},{key:"_tryNudgeBuffer",value:function(e){var t=this.hls,n=this.media,i=this.nudgeRetry,a=null==t?void 0:t.config;if(!n||!a)return 0;var r=n.currentTime;if(this.nudgeRetry++,i<a.nudgeMaxRetry){var o=r+(i+1)*a.nudgeOffset,s=new Error(`Nudging 'currentTime' from ${r} to ${o}`);this.warn(s.message),n.currentTime=o,t.trigger(m$.ERROR,{type:c$.MEDIA_ERROR,details:h$.BUFFER_NUDGE_ON_STALL,error:s,fatal:!1,buffer:e.len,bufferInfo:e})}else{var u=new Error(`Playhead still not moving while enough data buffered @${r} after ${a.nudgeMaxRetry} nudges`);this.error(u.message),t.trigger(m$.ERROR,{type:c$.MEDIA_ERROR,details:h$.BUFFER_STALLED_ERROR,error:u,fatal:!0,buffer:e.len,bufferInfo:e})}}}])}(ej);function dV(e,t){var n=cV(e.main);if(n&&n.start<=t)return n;var i=cV(e.audio);return i&&i.start<=t?i:null}function cV(e){if(!e)return null;switch(e.state){case PB:case EB:case CB:case IB:return null}return e.frag}function hV(e,t){return t.getAppendedFrag(e,y$)||t.getPartialFragment(e)}function mV(){if("undefined"!=typeof self)return self.VTTCue||self.TextTrackCue}function fV(e,t,n,i,a){var r=new e(t,n,"");try{r.value=i,a&&(r.type=a)}catch(o){r=new e(t,n,nW(a?_$({type:a},i):i))}return r}var vV=(()=>{var e=mV();try{e&&new e(0,Number.POSITIVE_INFINITY,"")}catch(e){return Number.MAX_VALUE}return Number.POSITIVE_INFINITY})(),pV=function(){return c(function e(t){o(this,e),this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.removeCues=!0,this.assetCue=void 0,this.onEventCueEnter=()=>{this.hls&&this.hls.trigger(m$.EVENT_CUE_ENTER,{})},this.hls=t,this._registerListeners()},[{key:"destroy",value:function(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=this.onEventCueEnter=null}},{key:"_registerListeners",value:function(){var e=this.hls;e&&(e.on(m$.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(m$.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(m$.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(m$.MANIFEST_LOADING,this.onManifestLoading,this),e.on(m$.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(m$.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(m$.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(m$.LEVEL_PTS_UPDATED,this.onLevelPtsUpdated,this))}},{key:"_unregisterListeners",value:function(){var e=this.hls;e&&(e.off(m$.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(m$.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(m$.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(m$.MANIFEST_LOADING,this.onManifestLoading,this),e.off(m$.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(m$.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(m$.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(m$.LEVEL_PTS_UPDATED,this.onLevelPtsUpdated,this))}},{key:"onMediaAttaching",value:function(e,t){var n;this.media=t.media,!1===(null==(n=t.overrides)?void 0:n.cueRemoval)&&(this.removeCues=!1)}},{key:"onMediaAttached",value:function(){var e,t=null==(e=this.hls)?void 0:e.latestLevelDetails;t&&this.updateDateRangeCues(t)}},{key:"onMediaDetaching",value:function(e,t){this.media=null,!!t.transferMedia||(this.id3Track&&(this.removeCues&&OH(this.id3Track,this.onEventCueEnter),this.id3Track=null),this.dateRangeCuesAppended={})}},{key:"onManifestLoading",value:function(){this.dateRangeCuesAppended={}}},{key:"createTrack",value:function(e){var t=this.getID3Track(e.textTracks);return t.mode="hidden",t}},{key:"getID3Track",value:function(e){if(this.media){for(var t=0;t<e.length;t++){var n=e[t];if("metadata"===n.kind&&"id3"===n.label)return RH(n,this.media),n}return this.media.addTextTrack("metadata","id3")}}},{key:"onFragParsingMetadata",value:function(e,t){if(this.media&&this.hls){var n=this.hls.config,i=n.enableEmsgMetadataCues,a=n.enableID3MetadataCues;if(i||a){var r=t.samples;this.id3Track||(this.id3Track=this.createTrack(this.media));var o=mV();if(o)for(var s=0;s<r.length;s++){var u=r[s].type;if((u!==cz.emsg||i)&&a){var l=sz(r[s].data),d=r[s].pts,c=d+r[s].duration;c>vV&&(c=vV),c-d<=0&&(c=d+.25);for(var h=0;h<l.length;h++){var m=l[h];if(!uz(m)){this.updateId3CueEnds(d,u);var f=fV(o,d,c,m,u);f&&this.id3Track.addCue(f)}}}}}}}},{key:"updateId3CueEnds",value:function(e,t){var n,i=null==(n=this.id3Track)?void 0:n.cues;if(i)for(var a=i.length;a--;){var r=i[a];r.type===t&&r.startTime<e&&r.endTime===vV&&(r.endTime=e)}}},{key:"onBufferFlushing",value:function(e,{startOffset:t,endOffset:n,type:i}){var a=this.id3Track,r=this.hls;if(r){var o=r.config,s=o.enableEmsgMetadataCues,u=o.enableID3MetadataCues;if(a&&(s||u))$H(a,t,n,"audio"===i?e=>e.type===cz.audioId3&&u:"video"===i?e=>e.type===cz.emsg&&s:e=>e.type===cz.audioId3&&u||e.type===cz.emsg&&s)}}},{key:"onLevelUpdated",value:function(e,{details:t}){this.updateDateRangeCues(t,!0)}},{key:"onLevelPtsUpdated",value:function(e,t){Math.abs(t.drift)>.01&&this.updateDateRangeCues(t.details)}},{key:"updateDateRangeCues",value:function(e,t){var n=this;if(this.hls&&this.media){var i=this.hls.config,a=i.assetPlayerId,r=i.timelineOffset,o=i.enableDateRangeMetadataCues,s=i.interstitialsController;if(o){var u=mV();if(a&&r&&!s){var l=e.fragmentStart,d=e.fragmentEnd,c=this.assetCue;c?(c.startTime=l,c.endTime=d):u&&(c=this.assetCue=fV(u,l,d,{assetPlayerId:this.hls.config.assetPlayerId},"hlsjs.interstitial.asset"))&&(c.id=a,this.id3Track||(this.id3Track=this.createTrack(this.media)),this.id3Track.addCue(c),c.addEventListener("enter",this.onEventCueEnter))}if(e.hasProgramDateTime){var h,m=this.id3Track,f=e.dateRanges,v=Object.keys(f),p=this.dateRangeCuesAppended;if(m&&t)if(null!=(h=m.cues)&&h.length)for(var g,y=Object.keys(p).filter(e=>!v.includes(e)),b=function(){var e=y[w],t=null==(g=p[e])?void 0:g.cues;delete p[e],t&&Object.keys(t).forEach(e=>{var i=t[e];if(i){i.removeEventListener("enter",n.onEventCueEnter);try{m.removeCue(i)}catch(e){}}})},w=y.length;w--;)b();else p=this.dateRangeCuesAppended={};var k=e.fragments[e.fragments.length-1];if(0!==v.length&&u$(null==k?void 0:k.programDateTime)){this.id3Track||(this.id3Track=this.createTrack(this.media));for(var S=function(){var e=v[E],t=f[e],i=t.startTime,a=p[e],r=(null==a?void 0:a.cues)||{},o=(null==a?void 0:a.durationKnown)||!1,l=vV,d=t.duration;if(t.endDate&&null!==d)l=i+d,o=!0;else if(t.endOnNext&&!o){var c=v.reduce((e,n)=>{if(n!==t.id){var i=f[n];if(i.class===t.class&&i.startDate>t.startDate&&(!e||t.startDate<e.startDate))return i}return e},null);c&&(l=c.startTime,o=!0)}for(var h=Object.keys(t.attr),m=0;m<h.length;m++){var g=h[m];if(hj(g)){var y=r[g];if(y)!o||null!=a&&a.durationKnown?Math.abs(y.startTime-i)>.01&&(y.startTime=i,y.endTime=l):y.endTime=l;else if(u){var b=t.attr[g];mj(g)&&(b=N$(b));var w=fV(u,i,l,{key:g,data:b},cz.dateRange);w&&(w.id=e,n.id3Track.addCue(w),r[g]=w,s&&("X-ASSET-LIST"!==g&&"X-ASSET-URL"!==g||w.addEventListener("enter",n.onEventCueEnter)))}}}p[e]={cues:r,dateRange:t,durationKnown:o}},E=0;E<v.length;E++)S()}}}}}}])}(),gV=function(){return c(function e(t){o(this,e),this.hls=void 0,this.config=void 0,this.media=null,this.currentTime=0,this.stallCount=0,this._latency=null,this._targetLatencyUpdated=!1,this.onTimeupdate=()=>{var e=this.media,t=this.levelDetails;if(e&&t){this.currentTime=e.currentTime;var n=this.computeLatency();if(null!==n){this._latency=n;var i=this.config,a=i.lowLatencyMode,r=i.maxLiveSyncPlaybackRate;if(a&&1!==r&&t.live){var o=this.targetLatency;if(null!==o){var s=n-o;if(s<Math.min(this.maxLatency,o+t.targetduration)&&s>.05&&this.forwardBufferLength>1){var u=Math.min(2,Math.max(1,r)),l=Math.round(2/(1+Math.exp(-.75*s-this.edgeStalled))*20)/20,d=Math.min(u,Math.max(1,l));this.changeMediaPlaybackRate(e,d)}else 1!==e.playbackRate&&0!==e.playbackRate&&this.changeMediaPlaybackRate(e,1)}}}}},this.hls=t,this.config=t.config,this.registerListeners()},[{key:"levelDetails",get:function(){var e;return(null==(e=this.hls)?void 0:e.latestLevelDetails)||null}},{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var e=this.config;if(void 0!==e.liveMaxLatencyDuration)return e.liveMaxLatencyDuration;var t=this.levelDetails;return t?e.liveMaxLatencyDurationCount*t.targetduration:0}},{key:"targetLatency",get:function(){var e=this.levelDetails;if(null===e||null===this.hls)return null;var t=e.holdBack,n=e.partHoldBack,i=e.targetduration,a=this.config,r=a.liveSyncDuration,o=a.liveSyncDurationCount,s=a.lowLatencyMode,u=this.hls.userConfig,l=s&&n||t;(this._targetLatencyUpdated||u.liveSyncDuration||u.liveSyncDurationCount||0===l)&&(l=void 0!==r?r:o*i);var d=i;return l+Math.min(this.stallCount*this.config.liveSyncOnStallIncrease,d)},set:function(e){this.stallCount=0,this.config.liveSyncDuration=e,this._targetLatencyUpdated=!0}},{key:"liveSyncPosition",get:function(){var e=this.estimateLiveEdge(),t=this.targetLatency;if(null===e||null===t)return null;var n=this.levelDetails;if(null===n)return null;var i=n.edge,a=e-t-this.edgeStalled,r=i-n.totalduration,o=i-(this.config.lowLatencyMode&&n.partTarget||n.targetduration);return Math.min(Math.max(r,a),o)}},{key:"drift",get:function(){var e=this.levelDetails;return null===e?1:e.drift}},{key:"edgeStalled",get:function(){var e=this.levelDetails;if(null===e)return 0;var t=3*(this.config.lowLatencyMode&&e.partTarget||e.targetduration);return Math.max(e.age-t,0)}},{key:"forwardBufferLength",get:function(){var e=this.media,t=this.levelDetails;if(!e||!t)return 0;var n=e.buffered.length;return(n?e.buffered.end(n-1):t.edge)-this.currentTime}},{key:"destroy",value:function(){this.unregisterListeners(),this.onMediaDetaching(),this.hls=null}},{key:"registerListeners",value:function(){var e=this.hls;e&&(e.on(m$.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(m$.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(m$.MANIFEST_LOADING,this.onManifestLoading,this),e.on(m$.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(m$.ERROR,this.onError,this))}},{key:"unregisterListeners",value:function(){var e=this.hls;e&&(e.off(m$.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(m$.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(m$.MANIFEST_LOADING,this.onManifestLoading,this),e.off(m$.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(m$.ERROR,this.onError,this))}},{key:"onMediaAttached",value:function(e,t){this.media=t.media,this.media.addEventListener("timeupdate",this.onTimeupdate)}},{key:"onMediaDetaching",value:function(){this.media&&(this.media.removeEventListener("timeupdate",this.onTimeupdate),this.media=null)}},{key:"onManifestLoading",value:function(){this._latency=null,this.stallCount=0}},{key:"onLevelUpdated",value:function(e,{details:t}){t.advanced&&this.onTimeupdate(),!t.live&&this.media&&this.media.removeEventListener("timeupdate",this.onTimeupdate)}},{key:"onError",value:function(e,t){var n;t.details===h$.BUFFER_STALLED_ERROR&&(this.stallCount++,this.hls&&null!=(n=this.levelDetails)&&n.live&&this.hls.logger.warn("[latency-controller]: Stall detected, adjusting target latency"))}},{key:"changeMediaPlaybackRate",value:function(e,t){var n,i;e.playbackRate!==t&&(null==(n=this.hls)||n.logger.debug(`[latency-controller]: latency=${this.latency.toFixed(3)}, targetLatency=${null==(i=this.targetLatency)?void 0:i.toFixed(3)}, forwardBufferLength=${this.forwardBufferLength.toFixed(3)}: adjusting playback rate from ${e.playbackRate} to ${t}`),e.playbackRate=t)}},{key:"estimateLiveEdge",value:function(){var e=this.levelDetails;return null===e?null:e.edge+e.age}},{key:"computeLatency",value:function(){var e=this.estimateLiveEdge();return null===e?null:e-this.currentTime}}])}(),yV=function(e){function t(e,n){var i;return o(this,t),(i=r(this,t,[e,"level-controller"]))._levels=[],i._firstLevel=-1,i._maxAutoLevel=-1,i._startLevel=void 0,i.currentLevel=null,i.currentLevelIndex=-1,i.manualLevelIndex=-1,i.steering=void 0,i.onParsedComplete=void 0,i.steering=n,i._registerListeners(),i}return p(t,e),c(t,[{key:"_registerListeners",value:function(){var e=this.hls;e.on(m$.MANIFEST_LOADING,this.onManifestLoading,this),e.on(m$.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(m$.LEVEL_LOADED,this.onLevelLoaded,this),e.on(m$.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(m$.FRAG_BUFFERED,this.onFragBuffered,this),e.on(m$.ERROR,this.onError,this)}},{key:"_unregisterListeners",value:function(){var e=this.hls;e.off(m$.MANIFEST_LOADING,this.onManifestLoading,this),e.off(m$.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(m$.LEVEL_LOADED,this.onLevelLoaded,this),e.off(m$.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(m$.FRAG_BUFFERED,this.onFragBuffered,this),e.off(m$.ERROR,this.onError,this)}},{key:"destroy",value:function(){this._unregisterListeners(),this.steering=null,this.resetLevels(),T(t,"destroy",this)([])}},{key:"stopLoad",value:function(){this._levels.forEach(e=>{e.loadError=0,e.fragmentError=0}),T(t,"stopLoad",this)([])}},{key:"resetLevels",value:function(){this._startLevel=void 0,this.manualLevelIndex=-1,this.currentLevelIndex=-1,this.currentLevel=null,this._levels=[],this._maxAutoLevel=-1}},{key:"onManifestLoading",value:function(e,t){this.resetLevels()}},{key:"onManifestLoaded",value:function(e,t){var n=this.hls.config.preferManagedMediaSource,i=[],a={},r={},o=!1,s=!1,u=!1;t.levels.forEach(e=>{var t=e.attrs,l=e.audioCodec,d=e.videoCodec;l&&(e.audioCodec=l=RN(l,n)||void 0),d&&(d=e.videoCodec=function(e){for(var t=e.split(","),n=0;n<t.length;n++){var i=t[n].split(".");i.length>2&&"avc1"===i[0]&&(t[n]=`avc1.${parseInt(i[1]).toString(16)}${("000"+parseInt(i[2]).toString(16)).slice(-4)}`)}return t.join(",")}(d));var c=e.width,h=e.height,m=e.unknownCodecs,f=(null==m?void 0:m.length)||0;if(o||(o=!(!c||!h)),s||(s=!!d),u||(u=!!l),f||l&&!this.isAudioSupported(l)||d&&!this.isVideoSupported(d))this.log(`Some or all CODECS not supported "${t.CODECS}"`);else{var v=t.CODECS,p=t["FRAME-RATE"],g=t["HDCP-LEVEL"],y=t["PATHWAY-ID"],b=t.RESOLUTION,w=t["VIDEO-RANGE"],k=`${`${y||"."}-`}${e.bitrate}-${b}-${p}-${v}-${w}-${g}`;if(a[k])if(a[k].uri===e.url||e.attrs["PATHWAY-ID"])a[k].addGroupId("audio",t.AUDIO),a[k].addGroupId("text",t.SUBTITLES);else{var S=r[k]+=1;e.attrs["PATHWAY-ID"]=new Array(S+1).join(".");var E=this.createLevel(e);a[k]=E,i.push(E)}else{var P=this.createLevel(e);a[k]=P,r[k]=1,i.push(P)}}}),this.filterAndSortMediaOptions(i,t,o,s,u)}},{key:"createLevel",value:function(e){var t=new ZN(e),n=e.supplemental;if(null!=n&&n.videoCodec&&!this.isVideoSupported(n.videoCodec)){var i=new Error(`SUPPLEMENTAL-CODECS not supported "${n.videoCodec}"`);this.log(i.message),t.supportedResult=zN(i,[])}return t}},{key:"isAudioSupported",value:function(e){return MN(e,"audio",this.hls.config.preferManagedMediaSource)}},{key:"isVideoSupported",value:function(e){return MN(e,"video",this.hls.config.preferManagedMediaSource)}},{key:"filterAndSortMediaOptions",value:function(e,t,n,i,a){var r,o=[],s=[],u=e,l=(null==(r=t.stats)?void 0:r.parsing)||{};if((n||i)&&a&&(u=u.filter(({videoCodec:e,videoRange:t,width:n,height:i})=>{return(!!e||!(!n||!i))&&(!!(a=t)&&KN.indexOf(a)>-1);var a})),0===u.length)return Promise.resolve().then(()=>{if(this.hls){var e="no level with compatible codecs found in manifest",n=e;t.levels.length&&(n=`one or more CODECS in variant not supported: ${nW(t.levels.map(e=>e.attrs.CODECS).filter((e,t,n)=>n.indexOf(e)===t))}`,this.warn(n),e+=` (${n})`);var i=new Error(e);this.hls.trigger(m$.ERROR,{type:c$.MEDIA_ERROR,details:h$.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:t.url,error:i,reason:n})}}),void(l.end=performance.now());t.audioTracks&&bV(o=t.audioTracks.filter(e=>!e.audioCodec||this.isAudioSupported(e.audioCodec))),t.subtitles&&bV(s=t.subtitles);var d=u.slice(0);u.sort((e,t)=>{if(e.attrs["HDCP-LEVEL"]!==t.attrs["HDCP-LEVEL"])return(e.attrs["HDCP-LEVEL"]||"")>(t.attrs["HDCP-LEVEL"]||"")?1:-1;if(n&&e.height!==t.height)return e.height-t.height;if(e.frameRate!==t.frameRate)return e.frameRate-t.frameRate;if(e.videoRange!==t.videoRange)return KN.indexOf(e.videoRange)-KN.indexOf(t.videoRange);if(e.videoCodec!==t.videoCodec){var i=xN(e.videoCodec),a=xN(t.videoCodec);if(i!==a)return a-i}if(e.uri===t.uri&&e.codecSet!==t.codecSet){var r=CN(e.codecSet),o=CN(t.codecSet);if(r!==o)return o-r}return e.averageBitrate!==t.averageBitrate?e.averageBitrate-t.averageBitrate:0});var c=d[0];if(this.steering&&(u=this.steering.filterParsedLevels(u)).length!==d.length)for(var h=0;h<d.length;h++)if(d[h].pathwayId===u[0].pathwayId){c=d[h];break}this._levels=u;for(var m=0;m<u.length;m++)if(u[m]===c){var f;this._firstLevel=m;var v=c.bitrate,p=this.hls.bandwidthEstimate;if(this.log(`manifest loaded, ${u.length} level(s) found, first bitrate: ${v}`),void 0===(null==(f=this.hls.userConfig)?void 0:f.abrEwmaDefaultEstimate)){var g=Math.min(v,this.hls.config.abrEwmaDefaultEstimateMax);g>p&&p===this.hls.abrEwmaDefaultEstimate&&(this.hls.bandwidthEstimate=g)}break}var y=a&&!i,b=this.hls.config,w=!(!b.audioStreamController||!b.audioTrackController),k={levels:u,audioTracks:o,subtitleTracks:s,sessionData:t.sessionData,sessionKeys:t.sessionKeys,firstLevel:this._firstLevel,stats:t.stats,audio:a,video:i,altAudio:w&&!y&&o.some(e=>!!e.url)};l.end=performance.now(),this.hls.trigger(m$.MANIFEST_PARSED,k)}},{key:"levels",get:function(){return 0===this._levels.length?null:this._levels}},{key:"loadLevelObj",get:function(){return this.currentLevel}},{key:"level",get:function(){return this.currentLevelIndex},set:function(e){var t=this._levels;if(0!==t.length){if(e<0||e>=t.length){var n=new Error("invalid level idx"),i=e<0;if(this.hls.trigger(m$.ERROR,{type:c$.OTHER_ERROR,details:h$.LEVEL_SWITCH_ERROR,level:e,fatal:i,error:n,reason:n.message}),i)return;e=Math.min(e,t.length-1)}var a=this.currentLevelIndex,r=this.currentLevel,o=r?r.attrs["PATHWAY-ID"]:void 0,s=t[e],u=s.attrs["PATHWAY-ID"];if(this.currentLevelIndex=e,this.currentLevel=s,a!==e||!r||o!==u){this.log(`Switching to level ${e} (${s.height?s.height+"p ":""}${s.videoRange?s.videoRange+" ":""}${s.codecSet?s.codecSet+" ":""}@${s.bitrate})${u?" with Pathway "+u:""} from level ${a}${o?" with Pathway "+o:""}`);var l={level:e,attrs:s.attrs,details:s.details,bitrate:s.bitrate,averageBitrate:s.averageBitrate,maxBitrate:s.maxBitrate,realBitrate:s.realBitrate,width:s.width,height:s.height,codecSet:s.codecSet,audioCodec:s.audioCodec,videoCodec:s.videoCodec,audioGroups:s.audioGroups,subtitleGroups:s.subtitleGroups,loaded:s.loaded,loadError:s.loadError,fragmentError:s.fragmentError,name:s.name,id:s.id,uri:s.uri,url:s.url,urlId:0,audioGroupIds:s.audioGroupIds,textGroupIds:s.textGroupIds};this.hls.trigger(m$.LEVEL_SWITCHING,l);var d=s.details;if(!d||d.live){var c=this.switchParams(s.uri,null==r?void 0:r.details,d);this.loadPlaylist(c)}}}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(e){this.manualLevelIndex=e,void 0===this._startLevel&&(this._startLevel=e),-1!==e&&(this.level=e)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(e){this._firstLevel=e}},{key:"startLevel",get:function(){if(void 0===this._startLevel){var e=this.hls.config.startLevel;return void 0!==e?e:this.hls.firstAutoLevel}return this._startLevel},set:function(e){this._startLevel=e}},{key:"pathways",get:function(){return this.steering?this.steering.pathways():[]}},{key:"pathwayPriority",get:function(){return this.steering?this.steering.pathwayPriority:null},set:function(e){if(this.steering){var t=this.steering.pathways(),n=e.filter(e=>-1!==t.indexOf(e));if(e.length<1)return void this.warn(`pathwayPriority ${e} should contain at least one pathway from list: ${t}`);this.steering.pathwayPriority=n}}},{key:"onError",value:function(e,t){!t.fatal&&t.context&&t.context.type===v$&&t.context.level===this.level&&this.checkRetry(t)}},{key:"onFragBuffered",value:function(e,{frag:t}){if(void 0!==t&&t.type===y$){var n=t.elementaryStreams;if(!Object.keys(n).some(e=>!!n[e]))return;var i=this._levels[t.level];null!=i&&i.loadError&&(this.log(`Resetting level error count of ${i.loadError} on frag buffered`),i.loadError=0)}}},{key:"onLevelLoaded",value:function(e,t){var n,i,a=t.level,r=t.details,o=t.levelInfo;if(!o)return this.warn(`Invalid level index ${a}`),void(null!=(i=t.deliveryDirectives)&&i.skip&&(r.deltaUpdateFailed=!0));if(o===this.currentLevel||t.withoutMultiVariant){0===o.fragmentError&&(o.loadError=0);var s=o.details;s===t.details&&s.advanced&&(s=void 0),this.playlistLoaded(a,t,s)}else null!=(n=t.deliveryDirectives)&&n.skip&&(r.deltaUpdateFailed=!0)}},{key:"loadPlaylist",value:function(e){T(t,"loadPlaylist",this)([]),this.shouldLoadPlaylist(this.currentLevel)&&this.scheduleLoading(this.currentLevel,e)}},{key:"loadingPlaylist",value:function(e,n){T(t,"loadingPlaylist",this)([e,n]);var i=this.getUrlWithDirectives(e.uri,n),a=this.currentLevelIndex,r=e.attrs["PATHWAY-ID"],o=e.details,s=null==o?void 0:o.age;this.log(`Loading level index ${a}${void 0!==(null==n?void 0:n.msn)?" at sn "+n.msn+" part "+n.part:""}${r?" Pathway "+r:""}${s&&o.live?" age "+s.toFixed(1)+(o.type&&" "+o.type||""):""} ${i}`),this.hls.trigger(m$.LEVEL_LOADING,{url:i,level:a,levelInfo:e,pathwayId:e.attrs["PATHWAY-ID"],id:0,deliveryDirectives:n||null})}},{key:"nextLoadLevel",get:function(){return-1!==this.manualLevelIndex?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(e){this.level=e,-1===this.manualLevelIndex&&(this.hls.nextAutoLevel=e)}},{key:"removeLevel",value:function(e){var t;if(1!==this._levels.length){var n=this._levels.filter((t,n)=>n!==e||(this.steering&&this.steering.removeLevel(t),t===this.currentLevel&&(this.currentLevel=null,this.currentLevelIndex=-1,t.details&&t.details.fragments.forEach(e=>e.level=-1)),!1));hB(n),this._levels=n,this.currentLevelIndex>-1&&null!=(t=this.currentLevel)&&t.details&&(this.currentLevelIndex=this.currentLevel.details.fragments[0].level),this.manualLevelIndex>-1&&(this.manualLevelIndex=this.currentLevelIndex);var i=n.length-1;this._firstLevel=Math.min(this._firstLevel,i),this._startLevel&&(this._startLevel=Math.min(this._startLevel,i)),this.hls.trigger(m$.LEVELS_UPDATED,{levels:n})}}},{key:"onLevelsUpdated",value:function(e,{levels:t}){this._levels=t}},{key:"checkMaxAutoUpdated",value:function(){var e=this.hls,t=e.autoLevelCapping,n=e.maxAutoLevel,i=e.maxHdcpLevel;this._maxAutoLevel!==n&&(this._maxAutoLevel=n,this.hls.trigger(m$.MAX_AUTO_LEVEL_UPDATED,{autoLevelCapping:t,levels:this.levels,maxAutoLevel:n,minAutoLevel:this.hls.minAutoLevel,maxHdcpLevel:i}))}}])}(yU);function bV(e){var t={};e.forEach(e=>{var n=e.groupId||"";e.id=t[n]=t[n]||0,t[n]++})}function wV(){return self.SourceBuffer||self.WebKitSourceBuffer}function kV(){if(!R$())return!1;var e=wV();return!e||e.prototype&&"function"==typeof e.prototype.appendBuffer&&"function"==typeof e.prototype.remove}var SV=function(e){function t(e,n,i){var a;return o(this,t),(a=r(this,t,[e,n,i,"stream-controller",y$])).audioCodecSwap=!1,a.level=-1,a._forceStartLoad=!1,a._hasEnoughToStart=!1,a.altAudio=0,a.audioOnly=!1,a.fragPlaying=null,a.fragLastKbps=0,a.couldBacktrack=!1,a.backtrackFragment=null,a.audioCodecSwitch=!1,a.videoBuffer=null,a.onMediaPlaying=()=>{a.tick()},a.onMediaSeeked=()=>{var e=a.media,t=e?e.currentTime:null;if(null!==t&&u$(t)&&(a.log(`Media seeked to ${t.toFixed(3)}`),a.getBufferedFrag(t))){var n=a.getFwdBufferInfoAtPos(e,t,y$,0);null!==n&&0!==n.len?a.tick():a.warn(`Main forward buffer length at ${t} on "seeked" event ${n?n.len:"empty"})`)}},a.registerListeners(),a}return p(t,e),c(t,[{key:"registerListeners",value:function(){T(t,"registerListeners",this)([]);var e=this.hls;e.on(m$.MANIFEST_PARSED,this.onManifestParsed,this),e.on(m$.LEVEL_LOADING,this.onLevelLoading,this),e.on(m$.LEVEL_LOADED,this.onLevelLoaded,this),e.on(m$.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.on(m$.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(m$.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(m$.BUFFER_CREATED,this.onBufferCreated,this),e.on(m$.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(m$.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(m$.FRAG_BUFFERED,this.onFragBuffered,this)}},{key:"unregisterListeners",value:function(){T(t,"unregisterListeners",this)([]);var e=this.hls;e.off(m$.MANIFEST_PARSED,this.onManifestParsed,this),e.off(m$.LEVEL_LOADED,this.onLevelLoaded,this),e.off(m$.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.off(m$.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(m$.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(m$.BUFFER_CREATED,this.onBufferCreated,this),e.off(m$.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(m$.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(m$.FRAG_BUFFERED,this.onFragBuffered,this)}},{key:"onHandlerDestroying",value:function(){this.onMediaPlaying=this.onMediaSeeked=null,this.unregisterListeners(),T(t,"onHandlerDestroying",this)([])}},{key:"startLoad",value:function(e,t){if(this.levels){var n=this.lastCurrentTime,i=this.hls;if(this.stopLoad(),this.setInterval(100),this.level=-1,!this.startFragRequested){var a=i.startLevel;-1===a&&(i.config.testBandwidth&&this.levels.length>1?(a=0,this.bitrateTest=!0):a=i.firstAutoLevel),i.nextLoadLevel=a,this.level=i.loadLevel,this._hasEnoughToStart=!!t}n>0&&-1===e&&!t&&(this.log(`Override startPosition with lastCurrentTime @${n.toFixed(3)}`),e=n),this.state=PB,this.nextLoadPosition=this.lastCurrentTime=e+this.timelineOffset,this.startPosition=t?-1:e,this.tick()}else this._forceStartLoad=!0,this.state=EB}},{key:"stopLoad",value:function(){this._forceStartLoad=!1,T(t,"stopLoad",this)([])}},{key:"doTick",value:function(){switch(this.state){case RB:var e=this.levels,t=this.level,n=null==e?void 0:e[t],i=null==n?void 0:n.details;if(i&&(!i.live||this.levelLastLoaded===n&&!this.waitForLive(n))){if(this.waitForCdnTuneIn(i))break;this.state=PB;break}if(this.hls.nextLoadLevel!==this.level){this.state=PB;break}break;case MB:this.checkRetryDate()}this.state===PB&&this.doTickIdle(),this.onTickEnd()}},{key:"onTickEnd",value:function(){var e;T(t,"onTickEnd",this)([]),null!=(e=this.media)&&e.readyState&&!1===this.media.seeking&&(this.lastCurrentTime=this.media.currentTime),this.checkFragmentChanged()}},{key:"doTickIdle",value:function(){var e=this.hls,t=this.levelLastLoaded,n=this.levels,i=this.media;if(null!==t&&(i||this.primaryPrefetch||!this.startFragRequested&&e.config.startFragPrefetch)&&(!this.altAudio||!this.audioOnly)){var a=this.buffering?e.nextLoadLevel:e.loadLevel;if(null!=n&&n[a]){var r=n[a],o=this.getMainFwdBufferInfo();if(null!==o){var s=this.getLevelDetails();if(s&&this._streamEnded(o,s)){var u={};return 2===this.altAudio&&(u.type="video"),this.hls.trigger(m$.BUFFER_EOS,u),void(this.state=CB)}if(this.buffering){e.loadLevel!==a&&-1===e.manualLevel&&this.log(`Adapting to level ${a} from level ${this.level}`),this.level=e.nextLoadLevel=a;var l=r.details;if(!l||this.state===RB||this.waitForLive(r))return this.level=a,this.state=RB,void(this.startFragRequested=!1);var d=o.len,c=this.getMaxBufferLength(r.maxBitrate);if(!(d>=c)){this.backtrackFragment&&this.backtrackFragment.start>o.end&&(this.backtrackFragment=null);var h=this.backtrackFragment?this.backtrackFragment.start:o.end,m=this.getNextFragment(h,l);if(this.couldBacktrack&&!this.fragPrevious&&m&&X$(m)&&this.fragmentTracker.getState(m)!==NW){var f,v=(null!=(f=this.backtrackFragment)?f:m).sn-l.startSN,p=l.fragments[v-1];p&&m.cc===p.cc&&(m=p,this.fragmentTracker.removeFragment(p))}else this.backtrackFragment&&o.len&&(this.backtrackFragment=null);if(m&&this.isLoopLoading(m,h)){if(!m.gap){var g=this.audioOnly&&!this.altAudio?H$:G$,y=(g===G$?this.videoBuffer:this.mediaBuffer)||this.media;y&&this.afterBufferFlushed(y,g,y$)}m=this.getNextFragmentLoopLoading(m,l,o,y$,c)}m&&(this.exceedsMaxBuffer(o,c,m)||(!m.initSegment||m.initSegment.data||this.bitrateTest||(m=m.initSegment),this.loadFragment(m,r,h)))}}}}}}},{key:"loadFragment",value:function(e,n,i){var a=this.fragmentTracker.getState(e);a===FW||a===$W?X$(e)?this.bitrateTest?(this.log(`Fragment ${e.sn} of level ${e.level} is being downloaded to test bitrate and will not be buffered`),this._loadBitrateTestFrag(e,n)):T(t,"loadFragment",this)([e,n,i]):this._loadInitSegment(e,n):this.clearTrackerIfNeeded(e)}},{key:"getBufferedFrag",value:function(e){return this.fragmentTracker.getBufferedFrag(e,y$)}},{key:"followingBufferedFrag",value:function(e){return e?this.getBufferedFrag(e.end+.5):null}},{key:"immediateLevelSwitch",value:function(){var e;(this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY),0!==this.altAudio)&&(((null==(e=this.getLevelDetails())?void 0:e.fragmentStart)||0)>this.lastCurrentTime&&T(t,"flushMainBuffer",this)([0,Number.POSITIVE_INFINITY,"audio"]))}},{key:"nextLevelSwitch",value:function(){var e=this.levels,t=this.media;if(null!=t&&t.readyState){var n,i=this.getAppendedFrag(t.currentTime);i&&i.start>1&&this.flushMainBuffer(0,i.start-1);var a=this.getLevelDetails();if(null!=a&&a.live){var r=this.getMainFwdBufferInfo();if(!r||r.len<2*a.targetduration)return}if(!t.paused&&e){var o=e[this.hls.nextLoadLevel],s=this.fragLastKbps;n=s&&this.fragCurrent?this.fragCurrent.duration*o.maxBitrate/(1e3*s)+1:0}else n=0;var u=this.getBufferedFrag(t.currentTime+n);if(u){var l=this.followingBufferedFrag(u);if(l){this.abortCurrentFrag();var d=l.maxStartPTS?l.maxStartPTS:l.start,c=l.duration,h=Math.max(u.end,d+Math.min(Math.max(c-this.config.maxFragLookUpTolerance,c*(this.couldBacktrack?.5:.125)),c*(this.couldBacktrack?.75:.25)));this.flushMainBuffer(h,Number.POSITIVE_INFINITY)}}}}},{key:"abortCurrentFrag",value:function(){var e=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,e&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.state){case TB:case _B:case MB:case DB:case xB:this.state=PB}this.nextLoadPosition=this.getLoadPosition()}},{key:"flushMainBuffer",value:function(e,n){T(t,"flushMainBuffer",this)([e,n,2===this.altAudio?"video":null])}},{key:"onMediaAttached",value:function(e,n){T(t,"onMediaAttached",this)([e,n]);var i=n.media;wB(i,"playing",this.onMediaPlaying),wB(i,"seeked",this.onMediaSeeked)}},{key:"onMediaDetaching",value:function(e,n){var i=this.media;i&&(kB(i,"playing",this.onMediaPlaying),kB(i,"seeked",this.onMediaSeeked)),this.videoBuffer=null,this.fragPlaying=null,T(t,"onMediaDetaching",this)([e,n]),!!n.transferMedia||(this._hasEnoughToStart=!1)}},{key:"onManifestLoading",value:function(){T(t,"onManifestLoading",this)([]),this.log("Trigger BUFFER_RESET"),this.hls.trigger(m$.BUFFER_RESET,void 0),this.couldBacktrack=!1,this.fragLastKbps=0,this.fragPlaying=this.backtrackFragment=null,this.altAudio=0,this.audioOnly=!1}},{key:"onManifestParsed",value:function(e,t){for(var n,i,a=!1,r=!1,o=0;o<t.levels.length;o++){var s=t.levels[o].audioCodec;s&&(a=a||-1!==s.indexOf("mp4a.40.2"),r=r||-1!==s.indexOf("mp4a.40.5"))}this.audioCodecSwitch=a&&r&&!("function"==typeof(null==(i=wV())||null==(n=i.prototype)?void 0:n.changeType)),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=t.levels,this.startFragRequested=!1}},{key:"onLevelLoading",value:function(e,t){if(this.levels&&this.state===PB){var n=t.levelInfo;(!n.details||n.details.live&&(this.levelLastLoaded!==n||n.details.expired)||this.waitForCdnTuneIn(n.details))&&(this.state=RB)}}},{key:"onLevelLoaded",value:function(e,t){var n,i=this.levels,a=this.startFragRequested,r=t.level,o=t.details,s=o.totalduration;if(i){this.log(`Level ${r} loaded [${o.startSN},${o.endSN}]${o.lastPartSn?`[part-${o.lastPartSn}-${o.lastPartIndex}]`:""}, cc [${o.startCC}, ${o.endCC}] duration:${s}`);var u=t.levelInfo,l=this.fragCurrent;!l||this.state!==_B&&this.state!==MB||l.level!==t.level&&l.loader&&this.abortCurrentFrag();var d=0;if(o.live||null!=(n=u.details)&&n.live){var c;if(this.checkLiveUpdate(o),o.deltaUpdateFailed)return;d=this.alignPlaylists(o,u.details,null==(c=this.levelLastLoaded)?void 0:c.details)}if(u.details=o,this.levelLastLoaded=u,a||this.setStartPosition(o,d),this.hls.trigger(m$.LEVEL_UPDATED,{details:o,level:r}),this.state===RB){if(this.waitForCdnTuneIn(o))return;this.state=PB}a&&o.live&&this.synchronizeToLiveEdge(o),this.tick()}else this.warn(`Levels were reset while loading level ${r}`)}},{key:"synchronizeToLiveEdge",value:function(e){var t=this.config,n=this.media;if(n){var i=this.hls.liveSyncPosition,a=this.getLoadPosition(),r=e.fragmentStart,o=e.edge,s=a>=r-t.maxFragLookUpTolerance&&a<=o;if(null!==i&&n.duration>i&&(a<i||!s)){var u=void 0!==t.liveMaxLatencyDuration?t.liveMaxLatencyDuration:t.liveMaxLatencyDurationCount*e.targetduration;if((!s&&n.readyState<4||a<o-u)&&(this._hasEnoughToStart||(this.nextLoadPosition=i),n.readyState))if(this.warn(`Playback: ${a.toFixed(3)} is located too far from the end of live sliding playlist: ${o}, reset currentTime to : ${i.toFixed(3)}`),"buffered"===this.config.liveSyncMode){var l,d=ij.bufferInfo(n,i,0);if(null==(l=d.buffered)||!l.length)return void(n.currentTime=i);if(d.start<=a)return void(n.currentTime=i);var c=ij.bufferedInfo(d.buffered,a,0).nextStart;c&&(n.currentTime=c)}else n.currentTime=i}}}},{key:"_handleFragmentLoadProgress",value:function(e){var t,n=e.frag,i=e.part,a=e.payload,r=this.levels;if(r){var o=r[n.level];if(o){var s=o.details;if(!s)return this.warn(`Dropping fragment ${n.sn} of level ${n.level} after level details were reset`),void this.fragmentTracker.removeFragment(n);var u=o.videoCodec,l=s.PTSKnown||!s.live,d=null==(t=n.initSegment)?void 0:t.data,c=this._getAudioCodec(o),h=this.transmuxer=this.transmuxer||new pU(this.hls,y$,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),m=i?i.index:-1,f=-1!==m,v=new tj(n.level,n.sn,n.stats.chunkCount,a.byteLength,m,f),p=this.initPTS[n.cc];h.push(a,d,c,u,n,i,s.totalduration,l,v,p)}else this.warn(`Level ${n.level} not found on progress`)}else this.warn(`Levels were reset while fragment load was in progress. Fragment ${n.sn} of level ${n.level} will not be buffered`)}},{key:"onAudioTrackSwitching",value:function(e,t){var n=this.hls,i=0!==this.altAudio;if(dW(t.url,n))this.altAudio=1;else{if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var a=this.fragCurrent;a&&(this.log("Switching to main audio track, cancel main fragment load"),a.abortRequests(),this.fragmentTracker.removeFragment(a)),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();if(i)return this.altAudio=0,this.fragmentTracker.removeAllFragments(),n.once(m$.BUFFER_FLUSHED,()=>{this.hls&&this.hls.trigger(m$.AUDIO_TRACK_SWITCHED,t)}),void n.trigger(m$.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null});n.trigger(m$.AUDIO_TRACK_SWITCHED,t)}}},{key:"onAudioTrackSwitched",value:function(e,t){var n=dW(t.url,this.hls);if(n){var i=this.videoBuffer;i&&this.mediaBuffer!==i&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=i)}this.altAudio=n?2:0,this.tick()}},{key:"onBufferCreated",value:function(e,t){var n,i,a=t.tracks,r=!1;for(var o in a){var s=a[o];if("main"===s.id){if(i=o,n=s,"video"===o){var u=a[o];u&&(this.videoBuffer=u.buffer)}}else r=!0}r&&n?(this.log(`Alternate track found, use ${i}.buffered to schedule main fragment loading`),this.mediaBuffer=n.buffer):this.mediaBuffer=this.media}},{key:"onFragBuffered",value:function(e,t){var n=t.frag,i=t.part,a=n.type===y$;if(a){if(this.fragContextChanged(n))return this.warn(`Fragment ${n.sn}${i?" p: "+i.index:""} of level ${n.level} finished buffering, but was aborted. state: ${this.state}`),void(this.state===xB&&(this.state=PB));var r=i?i.stats:n.stats;this.fragLastKbps=Math.round(8*r.total/(r.buffering.end-r.loading.first)),X$(n)&&(this.fragPrevious=n),this.fragBufferedComplete(n,i)}var o=this.media;o&&(!this._hasEnoughToStart&&ij.getBuffered(o).length&&(this._hasEnoughToStart=!0,this.seekToStartPos()),a&&this.tick())}},{key:"hasEnoughToStart",get:function(){return this._hasEnoughToStart}},{key:"onError",value:function(e,t){var n;if(t.fatal)this.state=IB;else switch(t.details){case h$.FRAG_GAP:case h$.FRAG_PARSING_ERROR:case h$.FRAG_DECRYPT_ERROR:case h$.FRAG_LOAD_ERROR:case h$.FRAG_LOAD_TIMEOUT:case h$.KEY_LOAD_ERROR:case h$.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(y$,t);break;case h$.LEVEL_LOAD_ERROR:case h$.LEVEL_LOAD_TIMEOUT:case h$.LEVEL_PARSING_ERROR:t.levelRetry||this.state!==RB||(null==(n=t.context)?void 0:n.type)!==v$||(this.state=PB);break;case h$.BUFFER_ADD_CODEC_ERROR:case h$.BUFFER_APPEND_ERROR:if("main"!==t.parent)return;this.reduceLengthAndFlushBuffer(t)&&this.resetLoadingState();break;case h$.BUFFER_FULL_ERROR:if("main"!==t.parent)return;if(this.reduceLengthAndFlushBuffer(t))!this.config.interstitialsController&&this.config.assetPlayerId?this._hasEnoughToStart=!0:this.flushMainBuffer(0,Number.POSITIVE_INFINITY);break;case h$.INTERNAL_EXCEPTION:this.recoverWorkerError(t)}}},{key:"onFragLoadEmergencyAborted",value:function(){this.state=PB,this._hasEnoughToStart||(this.startFragRequested=!1,this.nextLoadPosition=this.lastCurrentTime),this.tickImmediate()}},{key:"onBufferFlushed",value:function(e,{type:t}){if(t!==H$||!this.altAudio){var n=(t===G$?this.videoBuffer:this.mediaBuffer)||this.media;n&&(this.afterBufferFlushed(n,t,y$),this.tick())}}},{key:"onLevelsUpdated",value:function(e,t){this.level>-1&&this.fragCurrent&&(this.level=this.fragCurrent.level,-1===this.level&&this.resetWhenMissingContext(this.fragCurrent)),this.levels=t.levels}},{key:"swapAudioCodec",value:function(){this.audioCodecSwap=!this.audioCodecSwap}},{key:"seekToStartPos",value:function(){var e=this.media;if(e){var t=e.currentTime,n=this.startPosition;if(n>=0&&t<n){if(e.seeking)return void this.log(`could not seek to ${n}, already seeking at ${t}`);var i=this.timelineOffset;i&&n&&(n+=i);var a=this.getLevelDetails(),r=ij.getBuffered(e),o=r.length?r.start(0):0,s=o-n,u=Math.max(this.config.maxBufferHole,this.config.maxFragLookUpTolerance);(this.config.startOnSegmentBoundary||s>0&&(s<u||this.loadingParts&&s<2*((null==a?void 0:a.partTarget)||0)))&&(this.log(`adjusting start position by ${s} to match buffer start`),n+=s,this.startPosition=n),t<n&&(this.log(`seek to target start position ${n} from current time ${t} buffer start ${o}`),e.currentTime=n)}}}},{key:"_getAudioCodec",value:function(e){var t=this.config.defaultAudioCodec||e.audioCodec;return this.audioCodecSwap&&t&&(this.log("Swapping audio codec"),t=-1!==t.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5"),t}},{key:"_loadBitrateTestFrag",value:function(e,t){e.bitrateTest=!0,this._doFragLoad(e,t).then(e=>{var n=this.hls,i=null==e?void 0:e.frag;if(i&&!this.fragContextChanged(i)){t.fragmentError=0,this.state=PB,this.startFragRequested=!1,this.bitrateTest=!1;var a=i.stats;a.parsing.start=a.parsing.end=a.buffering.start=a.buffering.end=self.performance.now(),n.trigger(m$.FRAG_LOADED,e),i.bitrateTest=!1}}).catch(t=>{this.state!==EB&&this.state!==IB&&(this.warn(t),this.resetFragmentLoading(e))})}},{key:"_handleTransmuxComplete",value:function(e){var t=this.playlistType,n=this.hls,i=e.remuxResult,a=e.chunkMeta,r=this.getCurrentContext(a);if(r){var o=r.frag,s=r.part,u=r.level,l=i.video,d=i.text,c=i.id3,h=i.initSegment,m=u.details,f=this.altAudio?void 0:i.audio;if(this.fragContextChanged(o))this.fragmentTracker.removeFragment(o);else{if(this.state=DB,h){var v=h.tracks;if(v){var p=o.initSegment||o;if(this.unhandledEncryptionError(h,o))return;this._bufferInitSegment(u,v,p,a),n.trigger(m$.FRAG_PARSING_INIT_SEGMENT,{frag:p,id:t,tracks:v})}var g=h.initPTS,y=h.timescale,b=this.initPTS[o.cc];if(u$(g)&&(!b||b.baseTime!==g||b.timescale!==y)){var w=h.trackId;this.initPTS[o.cc]={baseTime:g,timescale:y,trackId:w},n.trigger(m$.INIT_PTS_FOUND,{frag:o,id:t,initPTS:g,timescale:y,trackId:w})}}if(l&&m){f&&"audiovideo"===l.type&&this.logMuxedErr(o);var k=m.fragments[o.sn-1-m.startSN],S=o.sn===m.startSN,E=!k||o.cc>k.cc;if(!1!==i.independent){var P=l.startPTS,T=l.endPTS,_=l.startDTS,M=l.endDTS;if(s)s.elementaryStreams[l.type]={startPTS:P,endPTS:T,startDTS:_,endDTS:M};else if(l.firstKeyFrame&&l.independent&&1===a.id&&!E&&(this.couldBacktrack=!0),l.dropped&&l.independent){var A=this.getMainFwdBufferInfo(),D=(A?A.end:this.getLoadPosition())+this.config.maxBufferHole,x=l.firstKeyFramePTS?l.firstKeyFramePTS:P;if(!S&&D<x-this.config.maxBufferHole&&!E)return void this.backtrack(o);E&&(o.gap=!0),o.setElementaryStreamInfo(l.type,o.start,T,o.start,M,!0)}else S&&P-(m.appliedTimelineOffset||0)>2&&(o.gap=!0);o.setElementaryStreamInfo(l.type,P,T,_,M),this.backtrackFragment&&(this.backtrackFragment=o),this.bufferFragmentData(l,o,s,a,S||E)}else{if(!S&&!E)return void this.backtrack(o);o.gap=!0}}if(f){var C=f.startPTS,I=f.endPTS,L=f.startDTS,R=f.endDTS;s&&(s.elementaryStreams[H$]={startPTS:C,endPTS:I,startDTS:L,endDTS:R}),o.setElementaryStreamInfo(H$,C,I,L,R),this.bufferFragmentData(f,o,s,a)}if(m&&null!=c&&c.samples.length){var F={id:t,frag:o,details:m,samples:c.samples};n.trigger(m$.FRAG_PARSING_METADATA,F)}if(m&&d){var O={id:t,frag:o,details:m,samples:d.samples};n.trigger(m$.FRAG_PARSING_USERDATA,O)}}}else this.resetWhenMissingContext(a)}},{key:"logMuxedErr",value:function(e){this.warn(`${X$(e)?"Media":"Init"} segment with muxed audiovideo where only video expected: ${e.url}`)}},{key:"_bufferInitSegment",value:function(e,t,n,i){if(this.state===DB){this.audioOnly=!!t.audio&&!t.video,this.altAudio&&!this.audioOnly&&(delete t.audio,t.audiovideo&&this.logMuxedErr(n));var a=t.audio,r=t.video,o=t.audiovideo;if(a){var s=e.audioCodec,u=FN(a.codec,s);"mp4a"===u&&(u="mp4a.40.5");var l=navigator.userAgent.toLowerCase();if(this.audioCodecSwitch){u&&(u=-1!==u.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5");var d=a.metadata;d&&"channelCount"in d&&1!==(d.channelCount||1)&&-1===l.indexOf("firefox")&&(u="mp4a.40.5")}u&&-1!==u.indexOf("mp4a.40.5")&&-1!==l.indexOf("android")&&"audio/mpeg"!==a.container&&(u="mp4a.40.2",this.log(`Android: force audio codec to ${u}`)),s&&s!==u&&this.log(`Swapping manifest audio codec "${s}" for "${u}"`),a.levelCodec=u,a.id=y$,this.log(`Init audio buffer, container:${a.container}, codecs[selected/level/parsed]=[${u||""}/${s||""}/${a.codec}]`),delete t.audiovideo}if(r){r.levelCodec=e.videoCodec,r.id=y$;var c=r.codec;if(4===(null==c?void 0:c.length))switch(c){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]=[${e.videoCodec||""}/${c}]${r.codec!==c?" parsed-corrected="+r.codec:""}${r.supplemental?" supplemental="+r.supplemental:""}`),delete t.audiovideo}o&&(this.log(`Init audiovideo buffer, container:${o.container}, codecs[level/parsed]=[${e.codecs}/${o.codec}]`),delete t.video,delete t.audio);var h=Object.keys(t);if(h.length){if(this.hls.trigger(m$.BUFFER_CODECS,t),!this.hls)return;h.forEach(e=>{var a=t[e].initSegment;null!=a&&a.byteLength&&this.hls.trigger(m$.BUFFER_APPENDING,{type:e,data:a,frag:n,part:null,chunkMeta:i,parent:n.type})})}this.tickImmediate()}}},{key:"getMainFwdBufferInfo",value:function(){var e=this.mediaBuffer&&2===this.altAudio?this.mediaBuffer:this.media;return this.getFwdBufferInfo(e,y$)}},{key:"maxBufferLength",get:function(){var e=this.levels,t=this.level,n=null==e?void 0:e[t];return n?this.getMaxBufferLength(n.maxBitrate):this.config.maxBufferLength}},{key:"backtrack",value:function(e){this.couldBacktrack=!0,this.backtrackFragment=e,this.resetTransmuxer(),this.flushBufferGap(e),this.fragmentTracker.removeFragment(e),this.fragPrevious=null,this.nextLoadPosition=e.start,this.state=PB}},{key:"checkFragmentChanged",value:function(){var e=this.media,t=null;if(e&&e.readyState>1&&!1===e.seeking){var n=e.currentTime;if(ij.isBuffered(e,n)?t=this.getAppendedFrag(n):ij.isBuffered(e,n+.1)&&(t=this.getAppendedFrag(n+.1)),t){this.backtrackFragment=null;var i=this.fragPlaying,a=t.level;i&&t.sn===i.sn&&i.level===a||(this.fragPlaying=t,this.hls.trigger(m$.FRAG_CHANGED,{frag:t}),i&&i.level===a||this.hls.trigger(m$.LEVEL_SWITCHED,{level:a}))}}}},{key:"nextLevel",get:function(){var e=this.nextBufferedFrag;return e?e.level:-1}},{key:"currentFrag",get:function(){var e;if(this.fragPlaying)return this.fragPlaying;var t=(null==(e=this.media)?void 0:e.currentTime)||this.lastCurrentTime;return u$(t)?this.getAppendedFrag(t):null}},{key:"currentProgramDateTime",get:function(){var e,t=(null==(e=this.media)?void 0:e.currentTime)||this.lastCurrentTime;if(u$(t)){var n=this.getLevelDetails(),i=this.currentFrag||(n?mW(null,n.fragments,t):null);if(i){var a=i.programDateTime;if(null!==a){var r=a+1e3*(t-i.start);return new Date(r)}}}return null}},{key:"currentLevel",get:function(){var e=this.currentFrag;return e?e.level:-1}},{key:"nextBufferedFrag",get:function(){var e=this.currentFrag;return e?this.followingBufferedFrag(e):null}},{key:"forceStartLoad",get:function(){return this._forceStartLoad}}])}(FB),EV=function(e){function t(e,n){var i;return o(this,t),(i=r(this,t,["key-loader",n])).config=void 0,i.keyIdToKeyInfo={},i.emeController=null,i.config=e,i}return p(t,e),c(t,[{key:"abort",value:function(e){for(var t in this.keyIdToKeyInfo){var n=this.keyIdToKeyInfo[t].loader;if(n){var i;if(e&&e!==(null==(i=n.context)?void 0:i.frag.type))return;n.abort()}}}},{key:"detach",value:function(){for(var e in this.keyIdToKeyInfo){var t=this.keyIdToKeyInfo[e];(t.mediaKeySessionContext||t.decryptdata.isCommonEncryption)&&delete this.keyIdToKeyInfo[e]}}},{key:"destroy",value:function(){for(var e in this.detach(),this.keyIdToKeyInfo){var t=this.keyIdToKeyInfo[e].loader;t&&t.destroy()}this.keyIdToKeyInfo={}}},{key:"createKeyLoadError",value:function(e,t=h$.KEY_LOAD_ERROR,n,i,a){return new ZW({type:c$.NETWORK_ERROR,details:t,fatal:!1,frag:e,response:a,error:n,networkDetails:i})}},{key:"loadClear",value:function(e,t,n){var i=this;if(this.emeController&&this.config.emeEnabled&&!this.emeController.getSelectedKeySystemFormats().length){if(t.length)for(var a,r=function(){var a=t[o];if(e.cc<=a.cc&&(!X$(e)||!X$(a)||e.sn<a.sn)||!n&&o==s-1)return{v:i.emeController.selectKeySystemFormat(a).then(e=>{if(i.emeController){a.setKeyFormat(e);var t=xj(e);return t?i.emeController.getKeySystemAccess([t]):void 0}})}},o=0,s=t.length;o<s;o++)if(a=r())return a.v;if(this.config.requireKeySystemAccessOnStart){var u=Ij(this.config);if(u.length)return this.emeController.getKeySystemAccess(u)}}return null}},{key:"load",value:function(e){return!e.decryptdata&&e.encrypted&&this.emeController&&this.config.emeEnabled?this.emeController.selectKeySystemFormat(e).then(t=>this.loadInternal(e,t)):this.loadInternal(e)}},{key:"loadInternal",value:function(e,t){var n,i;t&&e.setKeyFormat(t);var a=e.decryptdata;if(!a){var r=new Error(t?`Expected frag.decryptdata to be defined after setting format ${t}`:`Missing decryption data on fragment in onKeyLoading (emeEnabled with controller: ${this.emeController&&this.config.emeEnabled})`);return Promise.reject(this.createKeyLoadError(e,h$.KEY_LOAD_ERROR,r))}var o=a.uri;if(!o)return Promise.reject(this.createKeyLoadError(e,h$.KEY_LOAD_ERROR,new Error(`Invalid key URI: "${o}"`)));var s=PV(a),u=this.keyIdToKeyInfo[s];if(null!=(n=u)&&n.decryptdata.key)return a.key=u.decryptdata.key,Promise.resolve({frag:e,keyInfo:u});if(this.emeController&&null!=(i=u)&&i.keyLoadPromise)switch(this.emeController.getKeyStatus(u.decryptdata)){case"usable":case"usable-in-future":return u.keyLoadPromise.then(t=>{var n=t.keyInfo;return a.key=n.decryptdata.key,{frag:e,keyInfo:n}})}switch(this.log(`${this.keyIdToKeyInfo[s]?"Rel":"L"}oading${a.keyId?" keyId: "+$$(a.keyId):""} URI: ${a.uri} from ${e.type} ${e.level}`),u=this.keyIdToKeyInfo[s]={decryptdata:a,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},a.method){case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return"identity"===a.keyFormat?this.loadKeyHTTP(u,e):this.loadKeyEME(u,e);case"AES-128":case"AES-256":case"AES-256-CTR":return this.loadKeyHTTP(u,e);default:return Promise.reject(this.createKeyLoadError(e,h$.KEY_LOAD_ERROR,new Error(`Key supplied with unsupported METHOD: "${a.method}"`)))}}},{key:"loadKeyEME",value:function(e,t){var n={frag:t,keyInfo:e};if(this.emeController&&this.config.emeEnabled){var i;if(!e.decryptdata.keyId&&null!=(i=t.initSegment)&&i.data){var a=function(e){var t=[];return fN(e,e=>t.push(e.subarray(8,24))),t}(t.initSegment.data);if(a.length){var r=a[0];r.some(e=>0!==e)?(this.log(`Using keyId found in init segment ${$$(r)}`),$j.setKeyIdForUri(e.decryptdata.uri,r)):(r=$j.addKeyIdForUri(e.decryptdata.uri),this.log(`Generating keyId to patch media ${$$(r)}`)),e.decryptdata.keyId=r}}if(!e.decryptdata.keyId&&!X$(t))return Promise.resolve(n);var o=this.emeController.loadKey(n);return(e.keyLoadPromise=o.then(t=>(e.mediaKeySessionContext=t,n))).catch(n=>{throw e.keyLoadPromise=null,"data"in n&&(n.data.frag=t),n})}return Promise.resolve(n)}},{key:"loadKeyHTTP",value:function(e,t){var n=this.config,i=new(0,n.loader)(n);return t.keyLoader=e.loader=i,e.keyLoadPromise=new Promise((a,r)=>{var o={keyInfo:e,frag:t,responseType:"arraybuffer",url:e.decryptdata.uri},s=n.keyLoadPolicy.default,u={loadPolicy:s,timeout:s.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},l={onSuccess:(e,t,n,i)=>{var o=n.frag,s=n.keyInfo,u=PV(s.decryptdata);if(!o.decryptdata||s!==this.keyIdToKeyInfo[u])return r(this.createKeyLoadError(o,h$.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),i));s.decryptdata.key=o.decryptdata.key=new Uint8Array(e.data),o.keyLoader=null,s.loader=null,a({frag:o,keyInfo:s})},onError:(e,n,i,a)=>{this.resetLoader(n),r(this.createKeyLoadError(t,h$.KEY_LOAD_ERROR,new Error(`HTTP Error ${e.code} loading key ${e.text}`),i,_$({url:o.url,data:void 0},e)))},onTimeout:(e,n,i)=>{this.resetLoader(n),r(this.createKeyLoadError(t,h$.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),i))},onAbort:(e,n,i)=>{this.resetLoader(n),r(this.createKeyLoadError(t,h$.INTERNAL_ABORTED,new Error("key loading aborted"),i))}};i.load(o,u,l)})}},{key:"resetLoader",value:function(e){var t=e.frag,n=e.keyInfo,i=e.url,a=n.loader;t.keyLoader===a&&(t.keyLoader=null,n.loader=null);var r=PV(n.decryptdata)||i;delete this.keyIdToKeyInfo[r],a&&a.destroy()}}])}(M$);function PV(e){if(e.keyFormat!==Mj){var t=e.keyId;if(t)return $$(t)}return e.uri}function TV(e){switch(e.type){case p$:return b$;case g$:return w$;default:return y$}}function _V(e,t){var n=e.url;return void 0!==n&&0!==n.indexOf("data:")||(n=t.url),n}var MV=function(){return c(function e(t){o(this,e),this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.onManifestLoaded=this.checkAutostartLoad,this.hls=t,this.registerListeners()},[{key:"startLoad",value:function(e){}},{key:"stopLoad",value:function(){this.destroyInternalLoaders()}},{key:"registerListeners",value:function(){var e=this.hls;e.on(m$.MANIFEST_LOADING,this.onManifestLoading,this),e.on(m$.LEVEL_LOADING,this.onLevelLoading,this),e.on(m$.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(m$.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this),e.on(m$.LEVELS_UPDATED,this.onLevelsUpdated,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e.off(m$.MANIFEST_LOADING,this.onManifestLoading,this),e.off(m$.LEVEL_LOADING,this.onLevelLoading,this),e.off(m$.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(m$.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this),e.off(m$.LEVELS_UPDATED,this.onLevelsUpdated,this)}},{key:"createInternalLoader",value:function(e){var t=this.hls.config,n=t.pLoader,i=t.loader,a=new(n||i)(t);return this.loaders[e.type]=a,a}},{key:"getInternalLoader",value:function(e){return this.loaders[e.type]}},{key:"resetInternalLoader",value:function(e){this.loaders[e]&&delete this.loaders[e]}},{key:"destroyInternalLoaders",value:function(){for(var e in this.loaders){var t=this.loaders[e];t&&t.destroy(),this.resetInternalLoader(e)}}},{key:"destroy",value:function(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()}},{key:"onManifestLoading",value:function(e,t){var n=t.url;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:f$,url:n,deliveryDirectives:null,levelOrTrack:null})}},{key:"onLevelLoading",value:function(e,t){var n=t.id,i=t.level,a=t.pathwayId,r=t.url,o=t.deliveryDirectives,s=t.levelInfo;this.load({id:n,level:i,pathwayId:a,responseType:"text",type:v$,url:r,deliveryDirectives:o,levelOrTrack:s})}},{key:"onAudioTrackLoading",value:function(e,t){var n=t.id,i=t.groupId,a=t.url,r=t.deliveryDirectives,o=t.track;this.load({id:n,groupId:i,level:null,responseType:"text",type:p$,url:a,deliveryDirectives:r,levelOrTrack:o})}},{key:"onSubtitleTrackLoading",value:function(e,t){var n=t.id,i=t.groupId,a=t.url,r=t.deliveryDirectives,o=t.track;this.load({id:n,groupId:i,level:null,responseType:"text",type:g$,url:a,deliveryDirectives:r,levelOrTrack:o})}},{key:"onLevelsUpdated",value:function(e,t){var n=this.loaders[v$];if(n){var i=n.context;i&&!t.levels.some(e=>e===i.levelOrTrack)&&(n.abort(),delete this.loaders[v$])}}},{key:"load",value:function(e){var t,n,i,a=this.hls.config,r=this.getInternalLoader(e);if(r){var o=this.hls.logger,s=r.context;if(s&&s.levelOrTrack===e.levelOrTrack&&(s.url===e.url||s.deliveryDirectives&&!e.deliveryDirectives))return void(s.url===e.url?o.log(`[playlist-loader]: ignore ${e.url} ongoing request`):o.log(`[playlist-loader]: ignore ${e.url} in favor of ${s.url}`));o.log(`[playlist-loader]: aborting previous loader for type: ${e.type}`),r.abort()}if((n=e.type===f$?a.manifestLoadPolicy.default:P$({},a.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),r=this.createInternalLoader(e),u$(null==(t=e.deliveryDirectives)?void 0:t.part))&&(e.type===v$&&null!==e.level?i=this.hls.levels[e.level].details:e.type===p$&&null!==e.id?i=this.hls.audioTracks[e.id].details:e.type===g$&&null!==e.id&&(i=this.hls.subtitleTracks[e.id].details),i)){var u=i.partTarget,l=i.targetduration;if(u&&l){var d=1e3*Math.max(3*u,.8*l);n=P$({},n,{maxTimeToFirstByteMs:Math.min(d,n.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(d,n.maxTimeToFirstByteMs)})}}var c=n.errorRetry||n.timeoutRetry||{},h={loadPolicy:n,timeout:n.maxLoadTimeMs,maxRetry:c.maxNumRetry||0,retryDelay:c.retryDelayMs||0,maxRetryDelay:c.maxRetryDelayMs||0},m={onSuccess:(e,t,n,i)=>{var a=this.getInternalLoader(n);this.resetInternalLoader(n.type);var r=e.data;t.parsing.start=performance.now(),Hj.isMediaPlaylist(r)||n.type!==f$?this.handleTrackOrLevelPlaylist(e,t,n,i||null,a):this.handleMasterPlaylist(e,t,n,i)},onError:(e,t,n,i)=>{this.handleNetworkError(t,n,!1,e,i)},onTimeout:(e,t,n)=>{this.handleNetworkError(t,n,!0,void 0,e)}};r.load(e,h,m)}},{key:"checkAutostartLoad",value:function(){if(this.hls){var e=this.hls,t=e.config,n=t.autoStartLoad,i=t.startPosition,a=e.forceStartLoad;(n||a)&&(this.hls.logger.log(`${n?"auto":"force"} startLoad with configured startPosition ${i}`),this.hls.startLoad(i))}}},{key:"handleMasterPlaylist",value:function(e,t,n,i){var a=this.hls,r=e.data,o=_V(e,n),s=Hj.parseMasterPlaylist(r,o);if(s.playlistParsingError)return t.parsing.end=performance.now(),void this.handleManifestParsingError(e,n,s.playlistParsingError,i,t);var u=s.contentSteering,l=s.levels,d=s.sessionData,c=s.sessionKeys,h=s.startTimeOffset,m=s.variableList;this.variableList=m,l.forEach(e=>{var t=e.unknownCodecs;if(t)for(var n=this.hls.config.preferManagedMediaSource,i=e.audioCodec,a=e.videoCodec,r=t.length;r--;){var o=t[r];MN(o,"audio",n)?(e.audioCodec=i=i?`${i},${o}`:o,TN.audio[i.substring(0,4)]=2,t.splice(r,1)):MN(o,"video",n)&&(e.videoCodec=a=a?`${a},${o}`:o,TN.video[a.substring(0,4)]=2,t.splice(r,1))}});var f=Hj.parseMasterPlaylistMedia(r,o,s),v=f.AUDIO,p=void 0===v?[]:v,g=f.SUBTITLES,y=f["CLOSED-CAPTIONS"];p.length&&(p.some(e=>!e.url)||!l[0].audioCodec||l[0].attrs.AUDIO||(this.hls.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),p.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new cj({}),bitrate:0,url:""})));a.trigger(m$.MANIFEST_LOADED,{levels:l,audioTracks:p,subtitles:g,captions:y,contentSteering:u,url:o,stats:t,networkDetails:i,sessionData:d,sessionKeys:c,startTimeOffset:h,variableList:m})}},{key:"handleTrackOrLevelPlaylist",value:function(e,t,n,i,a){var r=this.hls,o=n.id,s=n.level,u=n.type,l=_V(e,n),d=u$(s)?s:u$(o)?o:0,c=TV(n),h=Hj.parseLevelPlaylist(e.data,l,d,c,0,this.variableList);if(u===f$){var m={attrs:new cj({}),bitrate:0,details:h,name:"",url:l};h.requestScheduled=t.loading.start+uB(h,0),r.trigger(m$.MANIFEST_LOADED,{levels:[m],audioTracks:[],url:l,stats:t,networkDetails:i,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}t.parsing.end=performance.now(),n.levelDetails=h,this.handlePlaylistLoaded(h,e,t,n,i,a)}},{key:"handleManifestParsingError",value:function(e,t,n,i,a){this.hls.trigger(m$.ERROR,{type:c$.NETWORK_ERROR,details:h$.MANIFEST_PARSING_ERROR,fatal:t.type===f$,url:e.url,err:n,error:n,reason:n.message,response:e,context:t,networkDetails:i,stats:a})}},{key:"handleNetworkError",value:function(e,t,n=!1,i,a){var r=`A network ${n?"timeout":"error"+(i?" (status "+i.code+")":"")} occurred while loading ${e.type}`;e.type===v$?r+=`: ${e.level} id: ${e.id}`:e.type!==p$&&e.type!==g$||(r+=` id: ${e.id} group-id: "${e.groupId}"`);var o=new Error(r);this.hls.logger.warn(`[playlist-loader]: ${r}`);var s=h$.UNKNOWN,u=!1,l=this.getInternalLoader(e);switch(e.type){case f$:s=n?h$.MANIFEST_LOAD_TIMEOUT:h$.MANIFEST_LOAD_ERROR,u=!0;break;case v$:s=n?h$.LEVEL_LOAD_TIMEOUT:h$.LEVEL_LOAD_ERROR,u=!1;break;case p$:s=n?h$.AUDIO_TRACK_LOAD_TIMEOUT:h$.AUDIO_TRACK_LOAD_ERROR,u=!1;break;case g$:s=n?h$.SUBTITLE_TRACK_LOAD_TIMEOUT:h$.SUBTITLE_LOAD_ERROR,u=!1}l&&this.resetInternalLoader(e.type);var d={type:c$.NETWORK_ERROR,details:s,fatal:u,url:e.url,loader:l,context:e,error:o,networkDetails:t,stats:a};if(i){var c=(null==t?void 0:t.url)||e.url;d.response=_$({url:c,data:void 0},i)}this.hls.trigger(m$.ERROR,d)}},{key:"handlePlaylistLoaded",value:function(e,t,n,i,a,r){var o=this.hls,s=i.type,u=i.level,l=i.levelOrTrack,d=i.id,c=i.groupId,h=i.deliveryDirectives,m=_V(t,i),f=TV(i),v="number"==typeof i.level&&f===y$?u:void 0,p=e.playlistParsingError;if(p){if(this.hls.logger.warn(`${p} ${e.url}`),!o.config.ignorePlaylistParsingErrors)return void o.trigger(m$.ERROR,{type:c$.NETWORK_ERROR,details:h$.LEVEL_PARSING_ERROR,fatal:!1,url:m,error:p,reason:p.message,response:t,context:i,level:v,parent:f,networkDetails:a,stats:n});e.playlistParsingError=null}if(e.fragments.length)switch(e.live&&r&&(r.getCacheAge&&(e.ageHeader=r.getCacheAge()||0),r.getCacheAge&&!isNaN(e.ageHeader)||(e.ageHeader=0)),s){case f$:case v$:if(v)if(l){if(l!==o.levels[v]){var g=o.levels.indexOf(l);g>-1&&(v=g)}}else v=0;o.trigger(m$.LEVEL_LOADED,{details:e,levelInfo:l||o.levels[0],level:v||0,id:d||0,stats:n,networkDetails:a,deliveryDirectives:h,withoutMultiVariant:s===f$});break;case p$:o.trigger(m$.AUDIO_TRACK_LOADED,{details:e,track:l,id:d||0,groupId:c||"",stats:n,networkDetails:a,deliveryDirectives:h});break;case g$:o.trigger(m$.SUBTITLE_TRACK_LOADED,{details:e,track:l,id:d||0,groupId:c||"",stats:n,networkDetails:a,deliveryDirectives:h})}else{var y=e.playlistParsingError=new Error("No Segments found in Playlist");o.trigger(m$.ERROR,{type:c$.NETWORK_ERROR,details:h$.LEVEL_EMPTY_ERROR,fatal:!1,url:m,error:y,reason:y.message,response:t,context:i,level:v,parent:f,networkDetails:a,stats:n})}}}])}(),AV=function(){function e(t={}){o(this,e),this.config=void 0,this.userConfig=void 0,this.logger=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new BB,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;var n=this.logger=function(e,t,n){var i=x$();if("object"==typeof console&&!0===e||"object"==typeof e){var a=["debug","log","info","warn","error"];a.forEach(t=>{i[t]=C$(t,e,n)});try{i.log(`Debug logs enabled for "${t}" in hls.js version 1.6.16`)}catch(e){return x$()}a.forEach(t=>{I$[t]=C$(t,e)})}else P$(I$,i);return i}(t.debug||!1,"Hls instance",t.assetPlayerId),i=this.config=function(e,t,n){if((t.liveSyncDurationCount||t.liveMaxLatencyDurationCount)&&(t.liveSyncDuration||t.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(void 0!==t.liveMaxLatencyDurationCount&&(void 0===t.liveSyncDurationCount||t.liveMaxLatencyDurationCount<=t.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(void 0!==t.liveMaxLatencyDuration&&(void 0===t.liveSyncDuration||t.liveMaxLatencyDuration<=t.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');var i=sV(e),a=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return["manifest","level","frag"].forEach(e=>{var r=`${"level"===e?"playlist":e}LoadPolicy`,o=void 0===t[r],s=[];a.forEach(n=>{var a=`${e}Loading${n}`,u=t[a];if(void 0!==u&&o){s.push(a);var l=i[r].default;switch(t[r]={default:l},n){case"TimeOut":l.maxLoadTimeMs=u,l.maxTimeToFirstByteMs=u;break;case"MaxRetry":l.errorRetry.maxNumRetry=u,l.timeoutRetry.maxNumRetry=u;break;case"RetryDelay":l.errorRetry.retryDelayMs=u,l.timeoutRetry.retryDelayMs=u;break;case"MaxRetryTimeout":l.errorRetry.maxRetryDelayMs=u,l.timeoutRetry.maxRetryDelayMs=u}}}),s.length&&n.warn(`hls.js config: "${s.join('", "')}" setting(s) are deprecated, use "${r}": ${nW(t[r])}`)}),_$(_$({},i),t)}(e.DefaultConfig,t,n);this.userConfig=t,i.progressive&&uV(i,n);var a=i.abrController,r=i.bufferController,s=i.capLevelController,u=i.errorController,l=i.fpsController,d=new u(this),c=this.abrController=new a(this),h=new WW(this),m=i.interstitialsController,f=m?this.interstitialsController=new m(this,e):null,v=this.bufferController=new r(this,h),p=this.capLevelController=new s(this),g=new l(this),y=new MV(this),b=i.contentSteeringController,w=b?new b(this):null,k=this.levelController=new yV(this,w),S=new pV(this),E=new EV(this.config,this.logger),P=this.streamController=new SV(this,h,E),T=this.gapController=new lV(this,h);p.setStreamController(P),g.setStreamController(P);var _=[y,k,P];f&&_.splice(1,0,f),w&&_.splice(1,0,w),this.networkControllers=_;var M=[c,v,T,p,g,S,h];this.audioTrackController=this.createController(i.audioTrackController,_);var A=i.audioStreamController;A&&_.push(this.audioStreamController=new A(this,h,E)),this.subtitleTrackController=this.createController(i.subtitleTrackController,_);var D=i.subtitleStreamController;D&&_.push(this.subtititleStreamController=new D(this,h,E)),this.createController(i.timelineController,M),E.emeController=this.emeController=this.createController(i.emeController,M),this.cmcdController=this.createController(i.cmcdController,M),this.latencyController=this.createController(gV,M),this.coreComponents=M,_.push(d);var x=d.onErrorOut;"function"==typeof x&&this.on(m$.ERROR,x,d),this.on(m$.MANIFEST_LOADED,y.onManifestLoaded,y)}return c(e,[{key:"createController",value:function(e,t){if(e){var n=new e(this);return t&&t.push(n),n}return null}},{key:"on",value:function(e,t,n=this){this._emitter.on(e,t,n)}},{key:"once",value:function(e,t,n=this){this._emitter.once(e,t,n)}},{key:"removeAllListeners",value:function(e){this._emitter.removeAllListeners(e)}},{key:"off",value:function(e,t,n=this,i){this._emitter.off(e,t,n,i)}},{key:"listeners",value:function(e){return this._emitter.listeners(e)}},{key:"emit",value:function(e,t,n){return this._emitter.emit(e,t,n)}},{key:"trigger",value:function(e,t){if(this.config.debug)return this.emit(e,e,t);try{return this.emit(e,e,t)}catch(t){if(this.logger.error("An internal error happened while handling event "+e+'. Error message: "'+t.message+'". Here is a stacktrace:',t),!this.triggeringException){this.triggeringException=!0;var n=e===m$.ERROR;this.trigger(m$.ERROR,{type:c$.OTHER_ERROR,details:h$.INTERNAL_EXCEPTION,fatal:n,event:e,error:t}),this.triggeringException=!1}}return!1}},{key:"listenerCount",value:function(e){return this._emitter.listenerCount(e)}},{key:"destroy",value:function(){this.logger.log("destroy"),this.trigger(m$.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this._url=null,this.networkControllers.forEach(e=>e.destroy()),this.networkControllers.length=0,this.coreComponents.forEach(e=>e.destroy()),this.coreComponents.length=0;var e=this.config;e.xhrSetup=e.fetchSetup=void 0,this.userConfig=null}},{key:"attachMedia",value:function(e){if(!e||"media"in e&&!e.media){var t=new Error(`attachMedia failed: invalid argument (${e})`);this.trigger(m$.ERROR,{type:c$.OTHER_ERROR,details:h$.ATTACH_MEDIA_ERROR,fatal:!0,error:t})}else{this.logger.log("attachMedia"),this._media&&(this.logger.warn("media must be detached before attaching"),this.detachMedia());var n="media"in e,i=n?e.media:e,a=n?e:{media:i};this._media=i,this.trigger(m$.MEDIA_ATTACHING,a)}}},{key:"detachMedia",value:function(){this.logger.log("detachMedia"),this.trigger(m$.MEDIA_DETACHING,{}),this._media=null}},{key:"transferMedia",value:function(){this._media=null;var e=this.bufferController.transferMedia();return this.trigger(m$.MEDIA_DETACHING,{transferMedia:e}),e}},{key:"loadSource",value:function(e){this.stopLoad();var t=this.media,n=this._url,i=this._url=z$.buildAbsoluteURL(self.location.href,e,{alwaysNormalize:!0});this._autoLevelCapping=-1,this._maxHdcpLevel=null,this.logger.log(`loadSource:${i}`),t&&n&&(n!==i||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(t)),this.trigger(m$.MANIFEST_LOADING,{url:e})}},{key:"url",get:function(){return this._url}},{key:"hasEnoughToStart",get:function(){return this.streamController.hasEnoughToStart}},{key:"startPosition",get:function(){return this.streamController.startPositionValue}},{key:"startLoad",value:function(e=-1,t){this.logger.log(`startLoad(${e+(t?", <skip seek to start>":"")})`),this.started=!0,this.resumeBuffering();for(var n=0;n<this.networkControllers.length&&(this.networkControllers[n].startLoad(e,t),this.started&&this.networkControllers);n++);}},{key:"stopLoad",value:function(){this.logger.log("stopLoad"),this.started=!1;for(var e=0;e<this.networkControllers.length&&(this.networkControllers[e].stopLoad(),!this.started&&this.networkControllers);e++);}},{key:"loadingEnabled",get:function(){return this.started}},{key:"bufferingEnabled",get:function(){return this.streamController.bufferingEnabled}},{key:"resumeBuffering",value:function(){this.bufferingEnabled||(this.logger.log("resume buffering"),this.networkControllers.forEach(e=>{e.resumeBuffering&&e.resumeBuffering()}))}},{key:"pauseBuffering",value:function(){this.bufferingEnabled&&(this.logger.log("pause buffering"),this.networkControllers.forEach(e=>{e.pauseBuffering&&e.pauseBuffering()}))}},{key:"inFlightFragments",get:function(){var e={[y$]:this.streamController.inFlightFrag};return this.audioStreamController&&(e[b$]=this.audioStreamController.inFlightFrag),this.subtititleStreamController&&(e[w$]=this.subtititleStreamController.inFlightFrag),e}},{key:"swapAudioCodec",value:function(){this.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()}},{key:"recoverMediaError",value:function(){this.logger.log("recoverMediaError");var e=this._media,t=null==e?void 0:e.currentTime;this.detachMedia(),e&&(this.attachMedia(e),t&&this.startLoad(t))}},{key:"removeLevel",value:function(e){this.levelController.removeLevel(e)}},{key:"sessionId",get:function(){var e=this._sessionId;return e||(e=this._sessionId=function(){try{return crypto.randomUUID()}catch(a){try{var e=URL.createObjectURL(new Blob),t=e.toString();return URL.revokeObjectURL(e),t.slice(t.lastIndexOf("/")+1)}catch(e){var n=(new Date).getTime(),i="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{var t=(n+16*Math.random())%16|0;return n=Math.floor(n/16),("x"==e?t:3&t|8).toString(16)});return i}}}()),e}},{key:"levels",get:function(){var e=this.levelController.levels;return e||[]}},{key:"latestLevelDetails",get:function(){return this.streamController.getLevelDetails()||null}},{key:"loadLevelObj",get:function(){return this.levelController.loadLevelObj}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(e){this.logger.log(`set currentLevel:${e}`),this.levelController.manualLevel=e,this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(e){this.logger.log(`set nextLevel:${e}`),this.levelController.manualLevel=e,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(e){this.logger.log(`set loadLevel:${e}`),this.levelController.manualLevel=e}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel},set:function(e){this.levelController.nextLoadLevel=e}},{key:"firstLevel",get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(e){this.logger.log(`set firstLevel:${e}`),this.levelController.firstLevel=e}},{key:"startLevel",get:function(){var e=this.levelController.startLevel;return-1===e&&this.abrController.forcedAutoLevel>-1?this.abrController.forcedAutoLevel:e},set:function(e){this.logger.log(`set startLevel:${e}`),-1!==e&&(e=Math.max(e,this.minAutoLevel)),this.levelController.startLevel=e}},{key:"capLevelToPlayerSize",get:function(){return this.config.capLevelToPlayerSize},set:function(e){var t=!!e;t!==this.config.capLevelToPlayerSize&&(t?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=t)}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(e){this._autoLevelCapping!==e&&(this.logger.log(`set autoLevelCapping:${e}`),this._autoLevelCapping=e,this.levelController.checkMaxAutoUpdated())}},{key:"bandwidthEstimate",get:function(){var e=this.abrController.bwEstimator;return e?e.getEstimate():NaN},set:function(e){this.abrController.resetEstimator(e)}},{key:"abrEwmaDefaultEstimate",get:function(){var e=this.abrController.bwEstimator;return e?e.defaultEstimate:NaN}},{key:"ttfbEstimate",get:function(){var e=this.abrController.bwEstimator;return e?e.getEstimateTTFB():NaN}},{key:"maxHdcpLevel",get:function(){return this._maxHdcpLevel},set:function(e){(function(e){return VN.indexOf(e)>-1})(e)&&this._maxHdcpLevel!==e&&(this._maxHdcpLevel=e,this.levelController.checkMaxAutoUpdated())}},{key:"autoLevelEnabled",get:function(){return-1===this.levelController.manualLevel}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){var e=this.levels,t=this.config.minAutoBitrate;if(!e)return 0;for(var n=e.length,i=0;i<n;i++)if(e[i].maxBitrate>=t)return i;return 0}},{key:"maxAutoLevel",get:function(){var e,t=this.levels,n=this.autoLevelCapping,i=this.maxHdcpLevel;if(e=-1===n&&null!=t&&t.length?t.length-1:n,i)for(var a=e;a--;){var r=t[a].attrs["HDCP-LEVEL"];if(r&&r<=i)return a}return e}},{key:"firstAutoLevel",get:function(){return this.abrController.firstAutoLevel}},{key:"nextAutoLevel",get:function(){return this.abrController.nextAutoLevel},set:function(e){this.abrController.nextAutoLevel=e}},{key:"playingDate",get:function(){return this.streamController.currentProgramDateTime}},{key:"mainForwardBufferInfo",get:function(){return this.streamController.getMainFwdBufferInfo()}},{key:"maxBufferLength",get:function(){return this.streamController.maxBufferLength}},{key:"setAudioOption",value:function(e){var t;return(null==(t=this.audioTrackController)?void 0:t.setAudioOption(e))||null}},{key:"setSubtitleOption",value:function(e){var t;return(null==(t=this.subtitleTrackController)?void 0:t.setSubtitleOption(e))||null}},{key:"allAudioTracks",get:function(){var e=this.audioTrackController;return e?e.allAudioTracks:[]}},{key:"audioTracks",get:function(){var e=this.audioTrackController;return e?e.audioTracks:[]}},{key:"audioTrack",get:function(){var e=this.audioTrackController;return e?e.audioTrack:-1},set:function(e){var t=this.audioTrackController;t&&(t.audioTrack=e)}},{key:"allSubtitleTracks",get:function(){var e=this.subtitleTrackController;return e?e.allSubtitleTracks:[]}},{key:"subtitleTracks",get:function(){var e=this.subtitleTrackController;return e?e.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var e=this.subtitleTrackController;return e?e.subtitleTrack:-1},set:function(e){var t=this.subtitleTrackController;t&&(t.subtitleTrack=e)}},{key:"media",get:function(){return this._media}},{key:"subtitleDisplay",get:function(){var e=this.subtitleTrackController;return!!e&&e.subtitleDisplay},set:function(e){var t=this.subtitleTrackController;t&&(t.subtitleDisplay=e)}},{key:"lowLatencyMode",get:function(){return this.config.lowLatencyMode},set:function(e){this.config.lowLatencyMode=e}},{key:"liveSyncPosition",get:function(){return this.latencyController.liveSyncPosition}},{key:"latency",get:function(){return this.latencyController.latency}},{key:"maxLatency",get:function(){return this.latencyController.maxLatency}},{key:"targetLatency",get:function(){return this.latencyController.targetLatency},set:function(e){this.latencyController.targetLatency=e}},{key:"drift",get:function(){return this.latencyController.drift}},{key:"forceStartLoad",get:function(){return this.streamController.forceStartLoad}},{key:"pathways",get:function(){return this.levelController.pathways}},{key:"pathwayPriority",get:function(){return this.levelController.pathwayPriority},set:function(e){this.levelController.pathwayPriority=e}},{key:"bufferedToEnd",get:function(){var e;return!(null==(e=this.bufferController)||!e.bufferedToEnd)}},{key:"interstitialsManager",get:function(){var e;return(null==(e=this.interstitialsController)?void 0:e.interstitialsManager)||null}},{key:"getMediaDecodingInfo",value:function(e,t=this.allAudioTracks){return UN(e,aW(t),navigator.mediaCapabilities)}}],[{key:"version",get:function(){return zB}},{key:"isMSESupported",value:function(){return kV()}},{key:"isSupported",value:function(){return function(){if(!kV())return!1;var e=R$();return"function"==typeof(null==e?void 0:e.isTypeSupported)&&(["avc1.42E01E,mp4a.40.2","av01.0.01M.08","vp09.00.50.08"].some(t=>e.isTypeSupported(DN(t,"video")))||["mp4a.40.2","fLaC"].some(t=>e.isTypeSupported(DN(t,"audio"))))}()}},{key:"getMediaSource",value:function(){return R$()}},{key:"Events",get:function(){return m$}},{key:"MetadataSchema",get:function(){return cz}},{key:"ErrorTypes",get:function(){return c$}},{key:"ErrorDetails",get:function(){return h$}},{key:"DefaultConfig",get:function(){return e.defaultConfig?e.defaultConfig:oV},set:function(t){e.defaultConfig=t}}])}();AV.defaultConfig=void 0;var DV,xV=e=>e,CV=function(e){function t(){var e;return o(this,t),(e=r(this,t,arguments)).inFocusedState=!1,e.scaleFactor=1,e.bgVideo=!1,e}return p(t,e),c(t,[{key:"disconnectedCallback",value:function(){T(t,"disconnectedCallback",this)([]),Jb.instance&&(Jb.instance.removeVideoEvents(),Jb.instance=null)}},{key:"styles",value:function(){var e,t,n=this.component,i=n.url,a=n.imageCropping,r=n.alignment,o=n.rightMargin,s=n.spacing,u="fit"===a,l=null!==(e=null===(t=this.getRootNode().host)||void 0===t?void 0:t.tagName.toLowerCase())&&void 0!==e?e:"";this.bgVideo=l.includes("background");var d=u?"":tm(` position: ${this.bgVideo?"fixed":"relative"};\n right: 0;\n top: 0;\n min-width: 100%;\n `);return tm(`\n :host {\n box-sizing: border-box;\n display: flex;\n transition: all 0.3s;\n background-image: url(${i});\n background-size: ${u?"contain":"cover"};\n background-position: ${r||""} center;\n background-repeat: no-repeat;\n ${vk(this.component,this.scaleFactor)};\n margin-right: ${o||s||0}px;\n ${wk(this.component,this.scaleFactor,!1)}\n ${this.component.hidden?"display:none;":""}\n ${d}\n }\n :host(:focus) {\n ${wk(this.component,this.scaleFactor,!0)}\n }\n :host(:focus-visible){\n ${Mk(this.component)}\n }\n #nami-video {\n ${vk(this.component,this.scaleFactor)};\n object-fit: ${u?"contain":"cover"};\n }\n `)}},{key:"loadMediaSrc",value:function(e){var t=this.component.url;if(t&&!t.includes(ni)&&e.src!==t)if(!t.includes("m3u8")||e.canPlayType("application/vnd.apple.mpegurl"))e.src=t;else if(AV.isSupported()){var n=new AV;n.loadSource(t),n.attachMedia(e)}}},{key:"updated",value:function(){var e,t;Object.keys(this.component).forEach(e=>{this.component[e]=Sg(this.contextProvider,this.component[e])});var n=this.component,i=n.id,a=n.title,r=n.autoplayVideo,o=n.mute,s=n.loopVideo,u=n.controlsType,l=n.fallbackImage,d=null===(e=this.shadowRoot)||void 0===e?void 0:e.getElementById("nami-video");d&&(d.autoplay=null!=r&&r,d.loop=null!=s&&s,d.muted=null!=o&&o,d.controls="none"!==u,d.poster=null!=l?l:"",d.playsInline=null!=r?r:this.bgVideo,this.loadMediaSrc(d),null===(t=Jb.instance)||void 0===t||t.removeVideoEvents(),Jb.instance=new Jb(this.contextProvider,d,a,i))}},{key:"render",value:function(){var e,t=this.component,n=t.focusedBorderColor,i=t.focusedFillColor,a=t.fillColor,r=t.screenreaderText,o=t.title;return this.ariaLabel=null!==(e=null!=r?r:o)&&void 0!==e?e:"",!n&&Dg(a,i)||(this.tabIndex=0),Bm(DV||(DV=xV`<video id="nami-video" preload="auto"></video>`))}}])}(Gw);Vh([yf({type:Object})],CV.prototype,"component",void 0),Vh([yf({type:Boolean})],CV.prototype,"inFocusedState",void 0),Vh([yf({type:Number})],CV.prototype,"scaleFactor",void 0),CV=Vh([vf("nami-video")],CV);var IV,LV=e=>e,RV=function(e){function t(){var e;return o(this,t),(e=r(this,t,arguments)).inFocusedState=!1,e.height=0,e.scaleFactor=1,e.isCollapsed=!0,e._handleClick=()=>{var t,n;e.isCollapsed=!e.isCollapsed,e.contextProvider.setOpenHeaderIds(e.component.id||"",e.component.sku),e.height=(null===(t=e.shadowRoot)||void 0===t||null===(t=t.getElementById("collapse"))||void 0===t?void 0:t.scrollHeight)||0,null===(n=e.shadowRoot)||void 0===n||null===(n=n.getElementById("collapse"))||void 0===n||n.classList.toggle("hidden")},e}return p(t,e),c(t,[{key:"styles",value:function(){var e=this.component,t=this.height,n=this.scaleFactor,i=e.backgroundBlur,a="vertical"===e.direction?"margin-top":"margin-left";return tm(`\n :host {\n display: ${e.hidden?"none":"flex"};\n ${i?`backdrop-filter: blur(${i}px);`:""}\n ${ok(e,!1)};\n ${uk(this.component)}\n ${wk(e,n,!1)}\n cursor: pointer;\n }\n :host > *:not(:first-child) {\n ${a}: ${e.spacing?e.spacing*n:0}px;\n }\n :host(:focus){\n ${ok(e,!0)}\n ${wk(e,n,!0)}\n }\n :host(:focus-visible){\n ${Mk(e)}\n }\n #collapse.hidden{\n max-height: 0;\n opacity: 0;\n overflow: hidden;\n padding: 0;\n margin: 0;\n }\n #collapse {\n ${vk(e,n)}\n max-height: ${t}px;\n opacity: 1;\n transition: all linear 0.5s;\n overflow: hidden;\n }\n #collapse-btn{\n background: transparent;\n border: none;\n width: 100%;\n }\n `)}},{key:"render",value:function(){var e=this.component,t=e.components,n=e.collapseHeader,i=e.focusedBorderColor,a=e.focusedFillColor,r=e.fillColor;!i&&Dg(r,a)||(this.tabIndex=0);var o=t.map(e=>rS(this.contextProvider,e,this.scaleFactor,this.inFocusedState,this.minSDKVersion));return Bm(IV||(IV=LV`
|
|
471
|
-
<button
|
|
471
|
+
<button
|
|
472
472
|
id="collapse-btn"
|
|
473
|
-
aria-label="${0}"
|
|
474
473
|
aria-expanded=${0}
|
|
475
474
|
@click=${0}
|
|
476
475
|
>
|
|
@@ -485,7 +484,7 @@
|
|
|
485
484
|
>
|
|
486
485
|
${0}
|
|
487
486
|
</div>
|
|
488
|
-
`)
|
|
487
|
+
`),!this.isCollapsed,this._handleClick,rS(this.contextProvider,n,this.scaleFactor,this.inFocusedState,this.minSDKVersion),this.isCollapsed,this.isCollapsed?"-1":"0",o)}}])}(Gw);Vh([yf({type:Object})],RV.prototype,"component",void 0),Vh([yf({type:Boolean})],RV.prototype,"inFocusedState",void 0),Vh([yf({type:Number})],RV.prototype,"height",void 0),Vh([yf({type:Number})],RV.prototype,"scaleFactor",void 0),Vh([yf({type:Object})],RV.prototype,"minSDKVersion",void 0),Vh([bf()],RV.prototype,"isCollapsed",void 0),RV=Vh([vf("nami-collapse-container")],RV);var FV,OV,$V,NV,WV,jV,BV,zV=e=>e,UV=function(e){function t(){var e;return o(this,t),(e=r(this,t,arguments)).inFocusedState=!1,e.scaleFactor=1,e.timelineDots=[],e.railHeight=0,e.mouseDown=!1,e.startDragging=t=>{t.preventDefault(),e.mouseDown=!0,e.startX=t.pageX-e.offsetLeft},e.stopDragging=()=>{e.mouseDown=!1},e.move=t=>{t.preventDefault(),e.mouseDown&&(e.scrollLeft=e.scrollLeft-(t.pageX-e.offsetLeft-e.startX))},e._rowMouseDown=!1,e._rowStartX=0,e._rowStartDragging=t=>{t.preventDefault(),e._rowMouseDown=!0,e._rowStartX=t.pageX},e._rowStopDragging=()=>{e._rowMouseDown=!1},e._rowMove=t=>{(t.preventDefault(),e._rowMouseDown)&&(t.currentTarget.scrollLeft-=t.pageX-e._rowStartX,e._rowStartX=t.pageX)},e}return p(t,e),c(t,[{key:"connectedCallback",value:function(){T(t,"connectedCallback",this)([]),this.addEventListener("mousemove",this.move,!1),this.addEventListener("mousedown",this.startDragging,!1),this.addEventListener("mouseup",this.stopDragging,!1),this.addEventListener("mouseleave",this.stopDragging,!1)}},{key:"disconnectedCallback",value:function(){var e;T(t,"disconnectedCallback",this)([]),this.removeEventListener("mousemove",this.move,!1),this.removeEventListener("mousedown",this.startDragging,!1),this.removeEventListener("mouseup",this.stopDragging,!1),this.removeEventListener("mouseleave",this.stopDragging,!1),null===(e=this.timelineResizeObserver)||void 0===e||e.disconnect()}},{key:"isGroupedHorizontal",value:function(){return"horizontal"===this.component.direction&&!!this.component.groupBy&&!!this.component.groupHeaderTemplate}},{key:"isTimelineActive",value:function(){return!!this.component.timeline&&xg(this.component.timeline).width>0&&"vertical"===this.component.direction&&!!this.component.groupBy&&!!this.component.groupHeaderTemplate&&"television"!==ou()}},{key:"styles",value:function(){var e="vertical"===this.component.direction,t=this.isGroupedHorizontal(),n=e?"margin-top":"margin-left",i=this.component.spacing?this.component.spacing*this.scaleFactor:0;if(this.isTimelineActive()){var a=xg(this.component.timeline),r=(a.width+a.railSpacing)*this.scaleFactor+tk(1,this.component.leftPadding);return tm(`\n :host {\n display: ${this.component.hidden?"none":"grid"};\n position: relative;\n grid-auto-flow: row;\n grid-template-columns: minmax(0, 1fr);\n grid-gap: ${i}px;\n align-items: center;\n justify-items: stretch;\n overflow: visible;\n ${ok(this.component,!1)}\n ${kk(this.component,!1)}\n align-self: baseline;\n box-sizing: border-box;\n padding-left: ${r}px;\n }\n :host(:focus) {\n ${ok(this.component,!0)}\n ${kk(this.component,!0)}\n padding-left: ${r}px;\n }\n :host(:focus-visible) { ${Mk(this.component)} }\n .nami-group-header { width: 100%; }\n .nami-timeline-rail {\n position: absolute;\n top: 0; bottom: 0; left: 0;\n width: ${a.width*this.scaleFactor}px;\n pointer-events: none;\n }\n .nami-timeline-line, .nami-timeline-dot {\n position: absolute;\n box-sizing: border-box;\n }\n `)}return tm(t?`\n :host {\n display: ${this.component.hidden?"none":"flex"};\n flex-direction: column;\n overflow: visible;\n ${ok(this.component,!1)}\n ${kk(this.component,!1)}\n align-self: baseline;\n }\n :host(:focus) {\n ${ok(this.component,!0)}\n ${kk(this.component,!0)}\n }\n :host(:focus-visible) {\n ${Mk(this.component)}\n }\n .nami-group-header {\n width: 100%;\n }\n .nami-group-items-row {\n display: flex;\n flex-direction: row;\n flex-wrap: nowrap;\n align-items: flex-start;\n overflow-x: auto;\n width: 100%;\n cursor: -webkit-grab;\n cursor: grab;\n gap: ${i}px;\n }\n .nami-group-items-row > * {\n flex: 0 0 auto;\n }\n `:`\n :host {\n display: ${this.component.hidden?"none":"flex"};\n flex-direction: ${e?"column":"row"};\n flex-wrap: ${e?"nowrap":"wrap"};\n overflow: auto;\n align-items: center;\n justify-content: center;\n ${ok(this.component,!1)}\n ${kk(this.component,!1)}\n align-self: baseline;\n cursor: -webkit-grab;\n cursor: grab;\n }\n :host(:focus){\n ${ok(this.component,!0)}\n ${kk(this.component,!0)}\n }\n :host(:focus-visible){\n ${Mk(this.component)}\n }\n @supports not (display: grid) {\n :host > *:not(:first-child) {\n ${n}: ${i}px;\n }\n }\n @supports (display: grid) {\n :host {\n display: ${this.component.hidden?"none":"grid"};\n grid-row-gap: ${i}px;\n grid-column-gap: ${i}px;\n grid-gap: ${i}px;\n grid-auto-flow: ${e?"row":"column"};\n ${e?"grid-template-columns: minmax(0, 1fr);":""}\n align-items: center;\n justify-items: center;\n place-items: center;\n }\n :host > * {\n margin: 0;\n }\n }\n `)}},{key:"render",value:function(){var e=this.component,t=e.focusedBorderColor,n=e.focusedFillColor,i=e.fillColor;!t&&Dg(i,n)||(this.tabIndex=0);var a,r,o=e=>rS(this.contextProvider,e,this.scaleFactor,this.inFocusedState,this.minSDKVersion);if(this.isTimelineActive()){var s=xg(this.component.timeline),u=this.scaleFactor,l=yg(this.contextProvider,this.component),d=new Map(l.map(e=>[e.key,Cg(this.contextProvider,this.component.timeline,e.key)])),c=function(e){var t=e.lineTopOffset,n=e.railHeight-e.lineBottomOffset;if(n<=t)return[];for(var i,a=e.dots.map(t=>[t.centerY-t.size/2-e.dotLineSpacing,t.centerY+t.size/2+e.dotLineSpacing]).sort((e,t)=>e[0]-t[0]),r=[],o=t,s=h(a);!(i=s()).done;){var u=i.value,l=u[0],d=u[1];l>o&&r.push({top:o,height:l-o}),o=Math.max(o,d)}return n>o&&r.push({top:o,height:n-o}),r.filter(e=>e.height>0)}({railHeight:this.railHeight,lineTopOffset:s.lineTopOffset*u,lineBottomOffset:s.lineBottomOffset*u,dotLineSpacing:s.dotLineSpacing*u,dots:this.timelineDots.map(e=>{var t,n;return{centerY:e.centerY,size:(null!==(t=null===(n=d.get(e.key))||void 0===n?void 0:n.dotSize)&&void 0!==t?t:s.dotSize)*u}})}),m=s.width*u/2;return Bm(FV||(FV=zV`
|
|
489
488
|
<div class="nami-timeline-rail">
|
|
490
489
|
${0}
|
|
491
490
|
${0}
|