@namiml/web-sdk 3.3.9-dev.202603172234 → 3.3.9-dev.202603180145

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -33,6 +33,32 @@ Example apps showing how to use the SDK are available in our [Nami Web SDK repo]
33
33
 
34
34
  More information on configuring and using the SDK is available in our docs at [https://learn.namiml.com](https://learn.namiml.com).
35
35
 
36
+ ## Testing
37
+
38
+ Unit tests live in `tests/unit/` and mirror the `src/` directory structure. Run them with:
39
+
40
+ ```bash
41
+ yarn test
42
+ ```
43
+
44
+ ### Test infrastructure
45
+
46
+ The suite uses two transformers side-by-side, each with a distinct role:
47
+
48
+ | Tool | Role | What it handles |
49
+ |---|---|---|
50
+ | **ts-jest** | TypeScript transformer | All `.ts` test files and source files — compiles TypeScript to CommonJS for Jest |
51
+ | **babel-jest** | JavaScript transformer | Third-party ESM packages from `node_modules` (Lit, `@open-wc`, `@esm-bundle/chai`, `lodash-es`, etc.) that Jest cannot run as-is because they ship as native ES modules |
52
+ | **@open-wc/testing** | Web Component test utilities | `fixture()` for rendering Lit components into a real jsdom DOM, `elementUpdated()` for awaiting Lit update cycles, and semantic DOM diff assertions (`expect(el).dom.to.equal(…)`) |
53
+
54
+ `transformIgnorePatterns` in `jest.config.mjs` lists the packages that babel-jest must transform (all others in `node_modules` are skipped). `babel.config.jest.cjs` configures the babel presets and plugins used for those transformations.
55
+
56
+ ### Strategy for new tests
57
+
58
+ - **Pure logic** (services, repositories, utilities, managers): use ts-jest only. Import the class under test directly. No `@open-wc/testing` needed.
59
+ - **Web Components** (anything in `src/components/`): use `fixture()` from `@open-wc/testing` to mount the component in jsdom and `elementUpdated()` to wait for Lit's render cycle before asserting. See any existing file in `tests/unit/components/` for the pattern.
60
+ - Do not add new packages to `transformIgnorePatterns` without also verifying that `babel.config.jest.cjs` can transform them. New ESM-only packages may require additional babel plugins.
61
+
36
62
  ## Legacy support
37
63
 
38
64
  To support older browsers, import our side-effect module before you import the SDK. It installs the necessary polyfills and shims, allowing the main entry point to stay the same for every app.
package/dist/nami-web.cjs CHANGED
@@ -88,7 +88,7 @@
88
88
  padding-top: 0;
89
89
  padding-bottom: 0;
90
90
  }
91
- `)),yc=e=>(t,n)=>{void 0!==n?n.addInitializer((()=>{customElements.define(e,t)})):customElements.define(e,t)},bc=globalThis,wc=bc.ShadowRoot&&(void 0===bc.ShadyCSS||bc.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,kc=Symbol(),Sc=new WeakMap,Ec=function(){return c((function e(t,n,a){if(s(this,e),this._$cssResult$=!0,a!==kc)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(wc&&void 0===e){var n=void 0!==t&&1===t.length;n&&(e=Sc.get(t)),void 0===e&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),n&&Sc.set(t,e))}return e}},{key:"toString",value:function(){return this.cssText}}])}(),Mc=(e,t)=>{if(wc)e.adoptedStyleSheets=t.map((e=>e instanceof CSSStyleSheet?e:e.styleSheet));else for(var n,a=m(t);!(n=a()).done;){var i=n.value,r=document.createElement("style"),o=bc.litNonce;void 0!==o&&r.setAttribute("nonce",o),r.textContent=i.cssText,e.appendChild(r)}},Pc=wc?e=>e:e=>e instanceof CSSStyleSheet?(e=>{for(var t,n="",a=m(e.cssRules);!(t=a()).done;){n+=t.value.cssText}return(e=>new Ec("string"==typeof e?e:e+"",void 0,kc))(n)})(e):e,Tc=Object.is,_c=Object.defineProperty,Dc=Object.getOwnPropertyDescriptor,Ac=Object.getOwnPropertyNames,xc=Object.getOwnPropertySymbols,Cc=Object.getPrototypeOf,Ic=globalThis,Lc=Ic.trustedTypes,Fc=Lc?Lc.emptyScript:"",Rc=Ic.reactiveElementPolyfillSupport,Wc=(e,t)=>e,Nc={toAttribute(e,t){switch(t){case Boolean:e=e?Fc: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}},Oc=(e,t)=>!Tc(e,t),jc={attribute:!0,type:String,converter:Nc,reflect:!1,useDefault:!1,hasChanged:Oc};null!==(fc=Symbol.metadata)&&void 0!==fc||(Symbol.metadata=Symbol("metadata")),null!==(vc=Ic.litPropertyMetadata)&&void 0!==vc||(Ic.litPropertyMetadata=new WeakMap);var $c=function(){function e(){var t;return s(this,e),(t=o(this,e))._$Ep=void 0,t.isUpdatePending=!1,t.hasUpdated=!1,t._$Em=null,t._$Ev(),t}return g(e,D(HTMLElement)),c(e,[{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=m(this.constructor.elementProperties.keys());!(e=n()).done;){var a=e.value;this.hasOwnProperty(a)&&(t.set(a,this[a]),delete this[a])}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 Mc(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),a=this.constructor._$Eu(e,n);if(void 0!==a&&!0===n.reflect){var i,r=(void 0!==(null===(i=n.converter)||void 0===i?void 0:i.toAttribute)?n.converter:Nc).toAttribute(t,n.type);this._$Em=e,null==r?this.removeAttribute(a):this.setAttribute(a,r),this._$Em=null}}},{key:"_$AK",value:function(e,t){var n=this.constructor,a=n._$Eh.get(e);if(void 0!==a&&this._$Em!==a){var i,r,o,s=n.getPropertyOptions(a),u="function"==typeof s.converter?{fromAttribute:s.converter}:void 0!==(null===(i=s.converter)||void 0===i?void 0:i.fromAttribute)?s.converter:Nc;this._$Em=a;var l=u.fromAttribute(t,s.type);this[a]=null!==(r=null!=l?l:null===(o=this._$Ej)||void 0===o?void 0:o.get(a))&&void 0!==r?r:l,this._$Em=null}}},{key:"requestUpdate",value:function(e,t,n){if(void 0!==e){var a,i,r=this.constructor,o=this[e];if(null!=n||(n=r.getPropertyOptions(e)),!((null!==(a=n.hasChanged)&&void 0!==a?a:Oc)(o,t)||n.useDefault&&n.reflect&&o===(null===(i=this._$Ej)||void 0===i?void 0:i.get(e))&&!this.hasAttribute(r._$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:a,wrapped:i},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!==i||void 0!==r)||(this._$AL.has(e)||(this.hasUpdated||n||(t=void 0),this._$AL.set(e,t)),!0===a&&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 S((function(n){for(;;)switch(n.p=n.n){case 0:return this.isUpdatePending=!0,n.p=1,n.n=2,r(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,r(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=m(this._$Ep);!(t=n()).done;){var a=t.value,i=a[0],r=a[1];this[i]=r}this._$Ep=void 0}var o=this.constructor.elementProperties;if(o.size>0)for(var s,u=m(o);!(s=u()).done;){var l=s.value,d=l[0],h=l[1],c=h.wrapped,f=this[d];!0!==c||this._$AL.has(d)||void 0===f||this.C(d,void 0,h,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=jc){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(),a=this.getPropertyDescriptor(e,n,t);void 0!==a&&_c(this.prototype,e,a)}}},{key:"getPropertyDescriptor",value:function(e,t,n){var a,i=null!==(a=Dc(this.prototype,e))&&void 0!==a?a:{get(){return this[t]},set(e){this[t]=e}},r=i.get,o=i.set;return{get:r,set(t){var a=null==r?void 0:r.call(this);null!=o&&o.call(this,t),this.requestUpdate(e,a,n)},configurable:!0,enumerable:!0}}},{key:"getPropertyOptions",value:function(e){var t;return null!==(t=this.elementProperties.get(e))&&void 0!==t?t:jc}},{key:"_$Ei",value:function(){if(!this.hasOwnProperty(Wc("elementProperties"))){var e=Cc(this);e.finalize(),void 0!==e.l&&(this.l=[...e.l]),this.elementProperties=new Map(e.elementProperties)}}},{key:"finalize",value:function(){if(!this.hasOwnProperty(Wc("finalized"))){if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(Wc("properties")))for(var e=this.properties,t=0,n=[...Ac(e),...xc(e)];t<n.length;t++){var a=n[t];this.createProperty(a,e[a])}var i=this[Symbol.metadata];if(null!==i){var r=litPropertyMetadata.get(i);if(void 0!==r)for(var o,s=m(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 h,c=m(this.elementProperties);!(h=c()).done;){var f=h.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,a=m(new Set(e.flat(1/0).reverse()));!(n=a()).done;){var i=n.value;t.unshift(Pc(i))}else void 0!==e&&t.push(Pc(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}}])}();$c.elementStyles=[],$c.shadowRootOptions={mode:"open"},$c[Wc("elementProperties")]=new Map,$c[Wc("finalized")]=new Map,null!=Rc&&Rc({ReactiveElement:$c}),(null!==(pc=Ic.reactiveElementVersions)&&void 0!==pc?pc:Ic.reactiveElementVersions=[]).push("2.1.1");var zc={attribute:!0,type:String,converter:Nc,reflect:!1,hasChanged:Oc},Bc=(e=zc,t,n)=>{var a=n.kind,i=n.metadata,r=globalThis.litPropertyMetadata.get(i);if(void 0===r&&globalThis.litPropertyMetadata.set(i,r=new Map),"setter"===a&&((e=Object.create(e)).wrapped=!0),r.set(n.name,e),"accessor"===a){var o=n.name;return{set(n){var a=t.get.call(this);t.set.call(this,n),this.requestUpdate(o,a,e)},init(t){return void 0!==t&&this.C(o,void 0,e,t),t}}}if("setter"===a){var s=n.name;return function(n){var a=this[s];t.call(this,n),this.requestUpdate(s,a,e)}}throw Error("Unsupported decorator location: "+a)};function Hc(e){return(t,n)=>"object"==typeof n?Bc(e,t,n):((e,t,n)=>{var a=t.hasOwnProperty(n);return t.constructor.createProperty(n,e),a?Object.getOwnPropertyDescriptor(t,n):void 0})(e,t,n)}function Uc(e){return Hc(f({},e,{state:!0,attribute:!1}))}function Gc(e){return!e||"object"==typeof e&&0==Object.keys(e).length}var Vc,Xc="entry",Kc="screen",Yc="branch",qc="exit",Jc="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.PAUSE="flowPause",e.RESUME="flowResume"}(Vc||(Vc={}));var Qc="__handoff_sequence__",Zc="__buy_sku__",em="__default__",tm="__appear__",nm="__disappear__",am="__login_success__",im="__login_failure__",rm="__logout_success__",om="__logout_failure__",sm="__purchase_success__",um="__remoteback__",lm="__tag_update__",dm="and",hm="or",cm="i_contains",mm="equals",fm="i_equals",vm="not_equals",pm="not_i_equals",gm="not_contains",ym="set",bm="notSet",wm=function(){function e(){s(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 a=n.map((e=>this.evaluateFilter(e)));switch(e.operator){case dm:return a.every((e=>e));case hm:return a.some((e=>e));default:return a.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 dm:for(var a,i=m(n);!(a=i()).done;){var r=a.value;if(!this.evaluateFilter(r))return!1}return!0;case hm:for(var o,s=m(n);!(o=s()).done;){var u=o.value;if(this.evaluateFilter(u))return!0}return!1;default:for(var l,d=m(n);!(l=d()).done;){var h=l.value;if(!this.evaluateFilter(h))return!1}return!0}}},{key:"evaluateFilter",value:function(e){var t=this.resolve(e.identifier);if(e.operator===ym)return null!=t;if(e.operator===bm)return null==t;if(null==t)return!![vm,pm,gm].includes(e.operator);switch(e.operator){case cm:return Array.isArray(t)?e.values.some((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 mm:return e.values.some((e=>{if("string"==typeof t)return t===e;if("boolean"==typeof t){var n="true"===e.toLowerCase();return t===n}return this.log("Unsupported type for equals comparison: "+typeof t),!1}));case fm:return e.values.some((e=>{if("string"==typeof t)return 0===t.localeCompare(e,void 0,{sensitivity:"accent"});if("boolean"==typeof t){var n="true"===e.toLowerCase();return t===n}return this.log("Unsupported type for i_equals comparison: "+typeof t),!1}));case vm:return e.values.every((e=>"string"!=typeof t||t!==e));case pm:return e.values.every((e=>"string"!=typeof t||0!==t.localeCompare(e,void 0,{sensitivity:"accent"})));case gm:return e.values.every((e=>"string"!=typeof t||!t.includes(e)));default:return this.log(`Unsupported operator: ${e.operator}`),!1}}},{key:"resolve",value:function(e){var t=this.resolveRaw(e);if(void 0!==t)return t;var n=e.lastIndexOf(".");if(-1!==n){var a=e.slice(0,n),i=e.slice(n+1),r=this.resolveRaw(a);return void 0!==r?this.extractProperty(i,r):void this.log(`Could not resolve base identifier: ${a}`)}}},{key:"resolveRaw",value:function(e){for(var t,n=[...this.namespaceResolvers.keys()].sort(((e,t)=>t.length-e.length)),a=m(n);!(t=a()).done;){var i=t.value;if(e.startsWith(i)){var r=this.namespaceResolvers.get(i);if(r)return r(e)}}}},{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){Wn.debug(`[NamiConditionEvaluator] ${e}`)}}],[{key:"shared",get:function(){return e.instance||(e.instance=new e),e.instance}}])}(),km=function(){return c((function e(){s(this,e)}),[{key:"register",value:function(){wm.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,a=t,i=m(e.replace(/\[(\w+)\]/g,".$1").split(".").filter(Boolean));!(n=i()).done;){var r=n.value;if(null==a||"object"!=typeof a)return;a=a[r]}return a}}])}(),Sm=function(){function e(t){var n;return s(this,e),(n=o(this,e)).namespace="LaunchContext",n.context=t,n.register(),n}return g(e,km),c(e,[{key:"resolveValue",value:function(e){if(e.startsWith("customAttributes.")){var t=e.substring(17);return this.resolveKeyPath(t,this.context.customAttributes)}if(e.startsWith("customObject.")){var n=e.substring(13);return this.resolveKeyPath(n,this.context.customObject)}return this.resolveKeyPath(e,{customAttributes:this.context.customAttributes,customObject:this.context.customObject,productGroups:this.context.productGroups})}}])}(),Em=function(){function e(){var t,n,a,i;s(this,e),(i=o(this,e)).namespace="Device";var r=Intl.DateTimeFormat().resolvedOptions().locale.split("-")[1]||"",u=Intl.DateTimeFormat().resolvedOptions().timeZone,l=su();return i.context={osName:l.os_name,osVersion:l.os_version,appVersion:l.extended_platform_version,sdkVersion:l.sdk_version,deviceModel:l.device_model,screenWidth:window.innerWidth,screenHeight:window.innerHeight,formFactor:l.form_factor,tvQuality:i.tvQuality(null!==(t=l.form_factor)&&void 0!==t?t:"desktop"),tvResolution:i.tvResolution(null!==(n=l.form_factor)&&void 0!==n?n:"desktop"),screenSize:i.screenSizeTier(null!==(a=l.form_factor)&&void 0!==a?a:"desktop"),language:l.language,country:r,timezone:u},i.register(),i}return g(e,km),c(e,[{key:"screenSizeTier",value:function(e){var t=window.screen.width,n=window.screen.height,a=window.devicePixelRatio||1,i=Math.round(t*a),r=Math.round(n*a),o=Math.max(i,r);switch(e){case"phone":return o<1136?"tiny":o<1334?"small":o<1920?"medium":o<2560?"large":"huge";case"tablet":return o<2048?"medium":o<2732?"large":"huge";case"television":return o<1920?"medium":o<3840?"large":"huge";case"desktop":return o<1440?"small":o<2560?"medium":o<3840?"large":"huge";default:return"medium"}}},{key:"tvQuality",value:function(e){if("television"!==e)return"";var t=window.screen.width,n=window.screen.height,a=window.devicePixelRatio||1,i=Math.round(t*a),r=Math.round(n*a),o=Math.max(i,r),s=Math.min(i,r);return o>=3840||s>=2160?"4K":o>=1920||s>=1080?"1080p":"720p"}},{key:"tvResolution",value:function(e){if("television"!==e)return"";var t=window.screen.width,n=window.screen.height,a=window.devicePixelRatio||1,i=Math.round(t*a),r=Math.round(n*a),o=Math.max(i,r),s=Math.min(i,r);return s<720&&o<1280?"SD":s>=720&&s<1080&&o>=1280&&o<1920?"720p":s>=1080&&s<1440&&o>=1920&&o<2560?"1080p":s>=1440&&s<2160&&o>=2560&&o<3840?"1440p":s>=2160&&s<3e3&&o>=3840&&o<5e3?"4K":s>=3e3&&o>=5e3?"8K":"Unknown"}},{key:"resolveValue",value:function(e){return this.resolveKeyPath(e,this.context)}}])}(),Mm=[/(^|_)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],Pm=function(){function e(){s(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 a,i=new URLSearchParams(e.search),r=(e,a)=>{var i=(e=>e.replace(/([a-z])([A-Z])/g,"$1_$2").replace(/[-\s]/g,"_").toLowerCase())(e);if(!(n.size>=10||(e=>Mm.some((t=>t.test(e))))(i))){var r=this.safeValue(a);r&&(t[i]=r,n.add(i))}},o=m(i.entries());!(a=o()).done;){var s=a.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()}}])}();Pm._instance=null;var Tm,_m=()=>Pm.instance.params,Dm=/\{\{\s*([^}]+?)\s*\}\}/g,Am=function(){return c((function e(t){s(this,e),this.flowManager=t,this.urlParams=_m()}),[{key:"resolve",value:function(e){var t,n,a,i,r,o,s,u,l,d,h,c,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 Sm(p).resolveValue(g);return null==y?void 0:y.toString()}}else 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!==(a=null==f||null===(i=f.campaign)||void 0===i?void 0:i.value)&&void 0!==a?a: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===(h=m.currentFlowStep)||void 0===h?void 0:h.name;case"buttonText":return null==m||null===(c=m.currentButton)||void 0===c?void 0:c.firstTextValue();case"slideNumber":var b=null==f?void 0:f.getSelectedSlideIndexForCurrentCarousel();return null!=b?`${b+1}`:void 0;default:return}}},{key:"interpolateLiquidVariables",value:function(e){return e.replace(Dm,((e,t)=>{var n,a=null!==(n=this.resolve(t))&&void 0!==n?n:this.urlParams[t];return null!=a?a:""}))}},{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])=>f({},e,{[t]:this.interpolateDeep(n)})),{}):e}}])}(),xm=function(){function e(){var t;return s(this,e),(t=o(this,e)).namespace="urlParams",t.context=_m(),t.register(),t}return g(e,km),c(e,[{key:"resolveValue",value:function(e){return Wn.debug("[URLParamsResolver]","Resolving keyPath",e),this.resolveKeyPath(e,this.context)}}])}(),Cm=function(){function e(){var t;return s(this,e),(t=o(this,e)).namespace="state",t.register(),t}return g(e,km),c(e,[{key:"getContextProvider",value:function(){var e=Xh.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)}}}])}(),Im=function(){function e(t){var n;return s(this,e),(n=o(this,e)).namespace="Placement",n.campaign=t,n.register(),n}return g(e,km),c(e,[{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=Xh.providers;if(0!==n.length){var a=n.find((e=>e.flow));return a?a.getCurrentPlacementLabel():null===(t=n[n.length-1])||void 0===t?void 0:t.getCurrentPlacementLabel()}}}}])}(),Lm=function(){return c((function e(){s(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?Kr.setNamiProfile({externalId:this.externalId}):Kr.removeNamiProfile(),this}},{key:"load",value:function(){var e=Kr.getNamiProfile();e&&(this.externalId=e.externalId),Xh.setIsLoggedIn(!!this.externalId)}},{key:"login",value:function(e){var t;return S((function(n){for(;;)switch(n.n){case 0:return n.n=1,r(Ns.instance.login(e));case 1:(t=n.v).external_id&&Xh.setIsLoggedIn(!0),this.setExternalId(t.external_id).save();case 2:return n.a(2)}}),null,this,null,Promise)}},{key:"logout",value:function(){return S((function(e){for(;;)switch(e.n){case 0:return e.n=1,r(Ns.instance.logout());case 1:Xh.setIsLoggedIn(!1),this.setExternalId(void 0).save();case 2:return e.a(2)}}),null,this,null,Promise)}}])}();Lm.instance=new Lm,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"}(Tm||(Tm={}));var Fm=function(){return c((function e(){s(this,e),this.emitter=ju.getInstance(),wm.shared.registerNamespaceResolver("UserTags",(t=>{var n=t.replace("UserTags.",""),a=e.getCustomerAttribute(n);if(null!=a){var i=a.toLowerCase();return"true"===i||"false"===i?"true"===i:isNaN(Number(a))?a:parseInt(a,10)}return null}))}),[{key:"isSDKInitialized",get:function(){return dc.instance.isInitialized}}],[{key:"isLoggedIn",value:function(){return Lm.instance.isLoggedIn()}},{key:"loggedInId",value:function(){return this.instance.isSDKInitialized||Wn.debug(ke),Lm.instance.getExternalId()}},{key:"login",value:function(e){var t,n,a,i,o,s,u;return S((function(l){for(;;)switch(l.p=l.n){case 0:if(this.instance.isSDKInitialized){l.n=1;break}throw t=new Qr,this.invokeStateHandler(Tm.LOGIN,!1,t),t;case 1:if(!this.inAnonymousMode()){l.n=2;break}throw n=new oo,this.invokeStateHandler(Tm.LOGIN,!1,n),n;case 2:return l.p=2,l.n=3,r(Lm.instance.login(e));case 3:return l.n=4,r(Qh.instance.fetchActiveEntitlements());case 4:this.invokeStateHandler(Tm.LOGIN,!0),Nm.instance.flowOpen&&(a=Nm.instance.currentFlow,(i=null==a?void 0:a.currentFlowStep)&&a.executeLifecycle(i,am)),l.n=6;break;case 5:throw l.p=5,u=l.v,this.invokeStateHandler(Tm.LOGIN,!1,u),Nm.instance.flowOpen&&(o=Nm.instance.currentFlow,(s=null==o?void 0:o.currentFlowStep)&&o.executeLifecycle(s,im)),u;case 6:return l.a(2)}}),null,this,[[2,5]],Promise)}},{key:"logout",value:function(){var e,t,n,a,i,o,s;return S((function(u){for(;;)switch(u.p=u.n){case 0:if(this.instance.isSDKInitialized){u.n=1;break}throw e=new Qr,this.invokeStateHandler(Tm.LOGOUT,!1,e),e;case 1:if(!this.inAnonymousMode()){u.n=2;break}throw t=new oo,this.invokeStateHandler(Tm.LOGOUT,!1,t),t;case 2:return u.p=2,u.n=3,r(Lm.instance.logout());case 3:return u.n=4,r(Qh.instance.fetchActiveEntitlements());case 4:this.invokeStateHandler(Tm.LOGOUT,!0),Nm.instance.flowOpen&&(n=Nm.instance.currentFlow,(a=null==n?void 0:n.currentFlowStep)&&n.executeLifecycle(a,rm)),u.n=6;break;case 5:throw u.p=5,s=u.v,this.invokeStateHandler(Tm.LOGOUT,!1,s),Nm.instance.flowOpen&&(i=Nm.instance.currentFlow,(o=null==i?void 0:i.currentFlowStep)&&i.executeLifecycle(o,om)),s;case 6:return u.a(2)}}),null,this,[[2,5]],Promise)}},{key:"setCustomerDataPlatformId",value:function(e){return S((function(t){for(;;)switch(t.n){case 0:return t.n=1,r(this.updateCustomerDataPlatformId(e));case 1:return t.a(2)}}),null,this,null,Promise)}},{key:"clearCustomerDataPlatformId",value:function(){return S((function(e){for(;;)switch(e.n){case 0:return e.n=1,r(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,a,i,o;return S((function(s){for(;;)switch(s.n){case 0:if(t=e?Tm.ANONYMOUS_MODE_ON:Tm.ANONYMOUS_MODE_OFF,this.instance.isSDKInitialized){s.n=1;break}throw n=new Qr,this.invokeStateHandler(t,!1,n),n;case 1:if(this.anonymousModeCapability()){s.n=2;break}return Wn.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 a=e?new io:new ro,this.invokeStateHandler(t,!1,a),s.a(2);case 3:if(!e){s.n=4;break}Kr.setAnonymousMode(e),Kr.resetDevice(),this.refetchConfig(),this.invokeStateHandler(Tm.ANONYMOUS_MODE_ON,!0),s.n=6;break;case 4:return Kr.clearAnonymousMode(),o=null===(i=Kr.getNamiConfig())||void 0===i?void 0:i.namiCommands,s.n=5,r(Bu.instance.createOrUpdateDevice(su(o)));case 5:Kr.clearAnonymousUUID(),this.refetchConfig(),this.invokeStateHandler(Tm.ANONYMOUS_MODE_OFF,!0);case 6:return s.a(2)}}),null,this,null,Promise)}},{key:"inAnonymousMode",value:function(){return!!this.instance.isSDKInitialized&&Xu()}},{key:"setCustomerAttribute",value:function(e,t){if(!this.instance.isSDKInitialized)throw new Qr;if(Kr.setCustomerAttribute(e,t),Cs(le.PAYWALL_PERSONALIZATION)?(Xh.setCustomerAttribute({[e]:t}),Wn.debug(`This customer attribute you set is now available for paywall personalization using the smart text variable: ${e}`)):Wn.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.`),Nm.instance.flowOpen){var n=Nm.instance.currentFlow;if(n){var a=n.currentFlowStep;a&&n.executeLifecycle(a,lm)}}}},{key:"getCustomerAttribute",value:function(e){if(!this.instance.isSDKInitialized)throw new Qr;var t=Kr.getCustomerAttribute(e);return null!=t?Cs(le.PAYWALL_PERSONALIZATION)?Wn.debug(`Found customer attribute. ${e} is available for paywall personalization on this device.`):Wn.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.`):Wn.warn(`No ${e} customer attribute found.`),t}},{key:"getAllCustomerAttributes",value:function(){if(!this.instance.isSDKInitialized)throw new Qr;return Kr.getAllCustomerAttributes()}},{key:"clearCustomerAttribute",value:function(e){if(!this.instance.isSDKInitialized)throw new Qr;Kr.clearCustomerAttribute(e)?(Xh.removeCustomerAttribute(e),Wn.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.`)):Wn.warn(`No value to clear for attribute ${e}.`)}},{key:"clearAllCustomerAttributes",value:function(){if(!this.instance.isSDKInitialized)throw new Qr;Kr.getAllCustomerAttributesKeys().forEach((e=>{Xh.removeCustomerAttribute(e)})),Kr.clearAllCustomerAttributes(),Wn.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 Qr;return Kr.getCustomerJourneyState()}},{key:"deviceId",value:function(){var e,t;return this.instance.isSDKInitialized&&null!==(e=null===(t=Kr.getDevice())||void 0===t?void 0:t.id)&&void 0!==e?e:Le}},{key:"registerJourneyStateHandler",value:function(e){if(Is("NamiCustomerManager.registerJourneyStateHandler"))return this.instance.emitter.addListener(Pn,e),()=>{this.instance.emitter.removeListener(Pn,e)}}},{key:"invokeStateHandler",value:function(e,t,n){this.instance.emitter.emit("accountStateChange",e,t,n)}},{key:"updateCustomerDataPlatformId",value:function(e){var t,n,a,i;return S((function(o){for(;;)switch(o.p=o.n){case 0:if(this.instance.isSDKInitialized){o.n=1;break}throw t=new Qr,this.invokeStateHandler(Tm.CUSTOMER_DATA_PLATFORM_ID_SET,!1,t),t;case 1:if(this.inAnonymousMode()){o.n=6;break}return o.p=2,o.n=3,r(Bu.instance.updateDeviceField("customer_data_platform_id",e));case 3:this.invokeStateHandler(Tm.CUSTOMER_DATA_PLATFORM_ID_SET,!0),o.n=5;break;case 4:o.p=4,i=o.v,this.invokeStateHandler(Tm.CUSTOMER_DATA_PLATFORM_ID_SET,!1,i);case 5:o.n=7;break;case 6:return Wn.info("Unable to set CDP ID in anonymous mode",{deviceId:null===(n=Kr.getDevice())||void 0===n?void 0:n.id,anonymousMode:!0}),a=new so,this.invokeStateHandler(Tm.CUSTOMER_DATA_PLATFORM_ID_SET,!1,a),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=Cs(le.ANONYMOUS_MODE_CAPABILITY),t=Cs(le.THIRD_PARTY_TRANSACTIONS);return e&&t}},{key:"refetchConfig",value:function(){return S((function(e){for(;;)switch(e.n){case 0:if(!this.instance.isSDKInitialized){e.n=1;break}return e.n=1,r(Promise.all([Hu.instance.fetchProducts(),Uu.instance.fetchPaywalls().then((e=>$u.instance.fetchCampaignRules(e)))]));case 1:return e.a(2)}}),null,this,null,Promise)}}])}();Fm.instance=new Fm;var Rm=function(){return c((function e(t={}){var n,a,i,r,o;s(this,e),this.id=null!==(n=t.id)&&void 0!==n?n:"",this.name=null!==(a=t.name)&&void 0!==a?a:"",this.steps=null!==(i=t.steps)&&void 0!==i?i:[],this.screens=null!==(r=t.screens)&&void 0!==r?r:[],this.resumeFromBookmark=Boolean(t.resume_from_bookmark),this.transition=null!==(o=t.transition)&&void 0!==o?o:"none"}),[{key:"allScreensAvailable",get:function(){return this.screens.length>0&&Hs(this.screens)}}])}(),Wm=function(){function e(t,n,a,i){var r,u;s(this,e),(u=o(this,e,[null!==(r=t.flow.object)&&void 0!==r?r:{}])).stepcrumbs=[],u.branchcrumbs=[],u.activeHandoffSequence=null,u.currentScreenState=null,u.isPaused=!1,u.timerStates={},u.campaign=t,u.component=n,u.context=i,u.manager=a,u.branchcrumbs=[],u.stepcrumbs=[],u.registerResolvers(i);var l=u.findStepByType(Xc);return l&&u.forward(l.id),u}return g(e,Rm),c(e,[{key:"registerResolvers",value:function(e){e&&new Sm(e),new Em,new xm,new Cm,new Im(this.campaign),wm.shared.registerNamespaceResolver("Flow",(e=>{switch(e){case"Flow.stepcrumbs":return this.stepcrumbs.map((e=>e.id));case"Flow.branchcrumbs":return this.branchcrumbs;default:return}}))}},{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),a=this.stepcrumbs.slice(0,-1).some((e=>"screen"===e.type));return t&&n&&a}},{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:"finished",value:function(){this.manager.finishFlow()}},{key:"back",value:function(){this.previousStepAvailable?this.backToPreviousScreenStep():Wn.debug("No previous step available")}},{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 a,i,r=Bs(n.screen);return r&&this.component.flowNavigateToScreen(r,{transition:this.transition,direction:"backward"}),void(this.currentScreenState=null!==(a=null===(i=Xh.currentProvider)||void 0===i?void 0:i.state)&&void 0!==a?a:null)}}Wn.warn("No previous screen step found to return to")}else Wn.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(t.type){case Xc:case qc:return this.stepcrumbs.push(t),void this.executeLifecycle(t,em);case Yc:return void this.handleBranchStep(t);case Kc:return void this.handleScreenStep(t);case Jc:return}}else Wn.error(`No step found with id: ${e}`)}},{key:"pause",value:function(){var e;this.isPaused?Wn.info("Flow is already paused"):(this.isPaused=!0,this.pausedStepID=null===(e=this.currentFlowStep)||void 0===e?void 0:e.id,Wn.info("Flow paused"))}},{key:"resumeFromPause",value:function(){if(this.isPaused)if(this.isPaused=!1,this.pausedStepID){var e=this.pausedStepID;this.pausedStepID=void 0,Wn.info(`Flow resumed from step ${e}`),this.forward(e)}else Wn.warn("No step to resume from");else Wn.info("Flow is not paused")}},{key:"executeLifecycle",value:function(e,t,n){var a=e.actions[t];a&&this.executeFullLifecycles(a,n)}},{key:"lifecycles",value:function(e){if(this.currentFlowStep){var t=this.currentFlowStep.actions[e];if(t)return t;Wn.info(`No actions found for button ${e} on step ${this.currentFlowStep.id}`)}}},{key:"triggerActions",value:function(e,t,n){var a=this.lifecycles(e);a&&(this.currentButton=t,this.executeFullLifecycles(a,n))}},{key:"executeFullLifecycles",value:function(e,t){for(var n,a=m(e);!(n=a()).done;){var i=n.value;[i.before,i.action,i.after].forEach((e=>null==e?void 0:e.forEach((e=>this.shouldRun(e)&&this.performAction(e,t)))))}}},{key:"triggerBeforeActions",value:function(e,t,n){var a=this.lifecycles(e);if(a){this.currentButton=t;for(var i,r=m(a);!(i=r()).done;){var o;null===(o=i.value.before)||void 0===o||o.forEach((e=>this.shouldRun(e)&&this.performAction(e,n)))}}}},{key:"triggerAfterActions",value:function(e,t,n){var a=this.lifecycles(e);if(a){this.currentButton=t;for(var i,r=m(a);!(i=r()).done;){var o;null===(o=i.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){return!e.conditions||e.conditions.every((e=>wm.shared.evaluate(e)))}},{key:"performAction",value:function(e,t){var n;if(this.currentFlowStep){var a=(null!==(n=e.parameters)&&void 0!==n&&n.delay?+e.parameters.delay:0)||0,i=n=>{var a,i,r,o,s,u,l;if((null===(a=this.currentFlowStep)||void 0===a?void 0:a.id)===n)switch(e.function){case Vc.BACK:this.back();break;case Vc.NEXT:null!==(i=e.parameters)&&void 0!==i&&i.step?this.forward(e.parameters.step):this.next();break;case Vc.NAVIGATE:var d;if(null!==(r=e.parameters)&&void 0!==r&&r.step)(null===(d=this.previousFlowStep)||void 0===d?void 0:d.id)===e.parameters.step?this.back():this.forward(e.parameters.step);else this.next();break;case Vc.FINISHED:case Vc.DISMISS:this.finished();break;case Vc.EXIT:var h=this.steps.find((e=>e.type===qc));h&&this.forward(h.id);break;case Vc.PAUSE:this.pause();break;case Vc.RESUME:this.resumeFromPause();break;case Vc.HANDOFF:if(null!==(o=e.parameters)&&void 0!==o&&o.handoffTag)if(this.manager.handoffStepHandler)if(e.parameters.handoffData)Wn.debug(`Invoking handoffStepHandler with ${e.parameters.handoffTag} ${JSON.stringify(e.parameters.handoffData)}`),this.manager.handoffStepHandler(e.parameters.handoffTag,e.parameters.handoffData);else if(t)Wn.debug(`Invoking handoffStepHandler with ${e.parameters.handoffTag} ${JSON.stringify(t)}`),this.manager.handoffStepHandler(e.parameters.handoffTag,t);else if(e.parameters.handoffFormId){var c=this.getFormData();e.parameters.handoffTag===Qc?this.flowHandoffFormSequence():this.manager.handoffStepHandler(e.parameters.handoffTag,c)}else Wn.debug(`Invoking handoffStepHandler with ${e.parameters.handoffTag} and no data`),this.manager.handoffStepHandler(e.parameters.handoffTag);else Wn.debug("No handoffStepHandler found",e);break;case Vc.LOG:var m;if(null!==(s=e.parameters)&&void 0!==s&&s.eventName)Wn.info(`logEvent → ${e.parameters.eventName}`);else Wn.warn(`Missing 'eventName' in logEvent action ${null!==(m=e.id)&&void 0!==m?m:"unknown"}`);break;case Vc.TRACK:var f;if(null!==(u=e.parameters)&&void 0!==u&&u.eventName)Wn.info(`trackEvent → ${e.parameters.eventName}`);else Wn.warn(`Missing 'eventName' in logEvent action ${null!==(f=e.id)&&void 0!==f?f:"unknown"}`);break;case Vc.SET_VIDEO:null!==(l=e.parameters)&&void 0!==l&&l.name&&e.parameters.url?Xh.setAppSuppliedVideoDetails({name:e.parameters.name,url:e.parameters.url}):Wn.warn("Missing name, url for setting video details");break;case Vc.BLOCK_BACK:var v,p=null===(v=e.parameters)||void 0===v?void 0:v.step,g=p?this.getStep(p):void 0;g?g.allow_back_to=!1:this.currentFlowStep?this.currentFlowStep.allow_back_to=!1:Wn.warn("Missing step for blocking back");break;case Vc.FLOW_EVENT:var y,b=new Am(this.manager),w=Object.fromEntries(Object.entries(null!==(y=e.parameters)&&void 0!==y?y:{}).map((([e,t])=>[e,b.interpolateDeep(t)])));this.manager.eventHandler?this.manager.eventHandler(w):Wn.warn("Missing event handler",w);break;case Vc.FLOW_ENABLED:Xh.setUserInteractionEnabled(!0);break;case Vc.FLOW_DISABLED:Xh.setUserInteractionEnabled(!1);break;case Vc.SET_TAGS:e.parameters&&(Xh.setUserTags(e.parameters),Object.entries(e.parameters).forEach((([e,t])=>{Fm.setCustomerAttribute(e,t)})));break;default:Wn.warn(`Missing action handler for ${e.function}`,e)}else Wn.debug(`Skipped action for stale flow step ${n}`)};a?setTimeout(i.bind(this,this.currentFlowStep.id),a):i(this.currentFlowStep.id)}else Wn.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,a=m(this.steps.slice(t+1));!(n=a()).done;){var i=n.value;if(this.isStepActive(i))return i}Wn.debug(`No active next step found after ${e.id}`)}else Wn.error(`Could not find next step for step ${e.id}`)}else Wn.error("Next step not found")}},{key:"handleScreenStep",value:function(e){var t,n=Bs(null!==(t=e.screen)&&void 0!==t?t:"");e.screen&&n&&this.campaign?(this.stepcrumbs.push(e),this.component.flowNavigateToScreen(n,{transition:this.transition,direction:"forward"})):Wn.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 a=n[t],i=a[0],r=a[1];if(r)for(var o,s=m(r);!(o=s()).done;){var u=o.value;if(u.action)for(var l,d=m(u.action);!(l=d()).done;){var h,c,f=l.value;if(this.shouldRun(f))return this.branchcrumbs.push(i),null===(h=u.before)||void 0===h||h.forEach((e=>{this.performAction(e)})),u.action.forEach((e=>{this.shouldRun(e)&&this.performAction(e)})),void(null===(c=u.after)||void 0===c||c.forEach((e=>{this.performAction(e)})))}else Wn.warn(`No actions defined for branch tag ${i}`)}}Wn.warn(`No matching branch condition matched for step ${e.id}`)}},{key:"getFormData",value:function(){var e,t;return f({},null!==(e=null===(t=Xh.currentProvider)||void 0===t||null===(t=t.state)||void 0===t?void 0:t.formStates)&&void 0!==e?e:{})}},{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).sort();if(0!==n.length){var a=n.filter((e=>!0===t[e]));if(0===a.length)return Wn.info("No eligible handoff keys after filtering"),void this.manager.resume();this.activeHandoffSequence={formStates:f({},t),remainingKeys:[...a]},this.resumeNextHandoff()}else Wn.warn("formStates is empty, no handoffs to perform")}else Wn.warn("No formStates available for handoff sequence")}},{key:"resumeNextHandoff",value:function(){var e,t,n=this.activeHandoffSequence;if(!n)return Wn.warn("No active handoff sequence to resume"),void this.manager.resume();if(0===n.remainingKeys.length)return Wn.info("All handoffs in the sequence are complete"),this.activeHandoffSequence=null,void this.manager.resume();var a=n.remainingKeys.shift(),i=n.formStates[a];Wn.debug(`Starting handoff for ${a} → ${String(i)}`),this.activeHandoffSequence=n;var r=`${a}`;null===(e=(t=this.manager).handoffStepHandler)||void 0===e||e.call(t,r,void 0)}}])}(),Nm=function(){function e(){s(this,e),this.flowOpen=!1,this.lastAnimatedFlowProgress=new Map,this.navGraphCache=new WeakMap}return c(e,[{key:"resume",value:function(){e.resume()}},{key:"presentFlow",value:function(e,t,n){var a=new Wm(e,t,this,n);return this.flowOpen=!0,this.currentFlow=a,a}},{key:"finishFlow",value:function(){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===Kc));if(0===t.length)return 0;var n=this.currentFlow.stepcrumbs.filter((e=>e.type===Kc));if(0===n.length)return 0;var a=this.buildNavGraph(this.currentFlow),i=this.currentFlow.currentFlowStep,r=this.findBranchPoint(t,a),o=0;if(r)o=this.calculateBranchingProgress(n,t,i,r,a);else{var s=t.findIndex((e=>e.id===i.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,a=m(e);!(n=a()).done;){var i=n.value;if(this.hasBranching(i,e,t))return i}return null}},{key:"calculateBranchingProgress",value:function(e,t,n,a,i){var r=e.length,o=t.findIndex((e=>e.id===a.id)),s=e.findIndex((e=>e.id===a.id)),u=t.findIndex((e=>e.id===n.id));if(-1===s||n.id===a.id)return(u+1)/(o+2);var l=this.countForwardScreens(n,t,i),d=r+l;return Wn.debug(`Branching progress: visited=${r}, remaining=${l}, total=${d}, step=${n.id}`),r/d}},{key:"countForwardScreens",value:function(e,t,n){var a=t.findIndex((t=>t.id===e.id));if(-1===a)return 0;var i=new Set,r=0,o=(e,s)=>{if(!i.has(e)){i.add(e);var u=(n.get(e)||[]).filter((e=>{var n=t.findIndex((t=>t.id===e));return n>a}));if(0!==u.length)for(var l,d=m(u);!(l=d()).done;){var h=l.value;o(h,s+1)}else r=Math.max(r,s)}};return o(e.id,0),r}},{key:"hasBranching",value:function(e,t,n){var a=t.findIndex((t=>t.id===e.id));if(-1===a)return!1;var i=(n.get(e.id)||[]).filter((e=>{var n=t.findIndex((t=>t.id===e));return n>a}));return i.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 a,i=null===(a=t.parameters)||void 0===a?void 0:a.step;i&&(n.has(e.id)||n.set(e.id,new Set),n.get(e.id).add(i))}}))}))}))}));var a=new Map;return n.forEach(((e,t)=>{a.set(t,Array.from(e))})),this.navGraphCache.set(e,a),a}},{key:"getCurrentFlowStepAutoAdvanceDelay",value:function(){var e,t,n=null===(e=this.currentFlow)||void 0===e?void 0:e.currentFlowStep;if(!n)return null;var a=null===(t=n.actions)||void 0===t?void 0:t[tm];if(!a)return null;for(var i,r=m(a);!(i=r()).done;)for(var o,s,u=m(null!==(o=i.value.action)&&void 0!==o?o:[]);!(s=u()).done;){var l,d=s.value;if((d.function===Vc.NAVIGATE||d.function===Vc.NEXT)&&null!=(null===(l=d.parameters)||void 0===l?void 0:l.delay)){var h=d.parameters.delay,c=Number(h);if(!isNaN(c)&&c>0)return c/1e3}}return null}}],[{key:"instance",get:function(){return e._instance||(e._instance=new e),e._instance}},{key:"registerStepHandoff",value:function(e){this.instance.handoffStepHandler=e}},{key:"registerEventHandler",value:function(e){this.instance.eventHandler=e}},{key:"resume",value:function(){var t=e.instance,n=t.flowOpen,a=t.currentFlow;if(n&&a&&a.currentFlowStep){if(a.activeHandoffSequence)return Wn.debug(`Resuming flow at handoff sequence ${a.currentFlowStep.id}`),void a.resumeNextHandoff();Wn.debug(`Resuming flow at step ${a.currentFlowStep.id}`),a.executeLifecycle(a.currentFlowStep,"__resume__")}else Wn.warn("Cannot resume: no active flow or current step")}},{key:"finish",value:function(){var t=e.instance,n=t.flowOpen,a=t.currentFlow;n&&a&&a.currentFlowStep?(Wn.debug(`Finishing flow programmatically at step ${a.currentFlowStep.id}`),a.finished()):Wn.debug("Cannot finish: no active flow or current step")}},{key:"pause",value:function(){var t=e.instance,n=t.flowOpen,a=t.currentFlow;n&&a&&a.currentFlowStep?!0===a.resumeFromBookmark?a.pause():Wn.warn("This flow cannot be paused"):Wn.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()}}])}();var Om=e=>{var t;return S((function(n){for(;;)if(0===n.n)return t=new Set(Array.from(document.fonts.values()).map((e=>e.family))),e.forEach((e=>{var n=jm(e);if(!t.has(n)){var a=new FontFace(n,`url(${e.file})`);document.fonts.add(a)}})),n.a(2,document.fonts.ready.then())}),null,null,null,Promise)};function jm(e){return`${e.family}-${e.style}`.replace(/ /g,"")}function $m(e,t,n){var a,i,r,o,s,u,l,d;if("undefined"==typeof window||!e||!t)return Wn.debug("Swipe detection is not supported in this environment."),{destroy(){},updateOptions(){}};var h={minDistance:null!==(a=null==n?void 0:n.minDistance)&&void 0!==a?a:30,maxDuration:null!==(i=null==n?void 0:n.maxDuration)&&void 0!==i?i:600,lockAxis:null===(r=null==n?void 0:n.lockAxis)||void 0===r||r,preventScrollOnSwipe:null!==(o=null==n?void 0:n.preventScrollOnSwipe)&&void 0!==o&&o,pointerTypes:null!==(s=null==n?void 0:n.pointerTypes)&&void 0!==s?s:["touch"],passiveListeners:null===(u=null==n?void 0:n.passiveListeners)||void 0===u||u,axisHint:null!==(l=null==n?void 0:n.axisHint)&&void 0!==l?l:"y",edgeLeakThreshold:null!==(d=null==n?void 0:n.edgeLeakThreshold)&&void 0!==d?d:24},c=e.style.touchAction;h.preventScrollOnSwipe&&(e.style.touchAction="none");var m=null,f=0,v=0,p=0,g=0,y=0,b=null,w=null,k=!1,S=!1,E=!1,M=e=>{try{var t=window.getComputedStyle(e);if(!t)return!1;var n=t.overflowY;if("auto"!==n&&"scroll"!==n)return!1;var a=e;return a.scrollHeight>a.clientHeight}catch(e){return!1}},P=e=>h.pointerTypes.includes(e.pointerType),T=t=>{var n=t.composedPath?t.composedPath()[0]:t.target;if(P(t)&&null===m){m=t.pointerId,f=p=t.clientX,v=g=t.clientY,y=performance.now(),b=null,E=!1,k=!1,S=!1,(w="y"===h.axisHint?((e,t)=>{for(var n=e;n&&n!==t&&n instanceof HTMLElement;){var a,i;if(M(n))return n;n=n.parentElement||(null!==(a=null===(i=n.parentNode)||void 0===i?void 0:i.host)&&void 0!==a?a:null)}return null})(n,e):null)||(S=!0);try{var a;null==e||null===(a=e.setPointerCapture)||void 0===a||a.call(e,t.pointerId)}catch(e){try{var i;null==n||null===(i=n.setPointerCapture)||void 0===i||i.call(n,t.pointerId)}catch(e){}}}},_=e=>{if(e.pointerId===m&&P(e)){if(p=e.clientX,g=e.clientY,h.lockAxis&&!b){var n=Math.abs(p-f),a=Math.abs(g-v);(n>2||a>2)&&(b=a>=n?"y":"x")}if("y"===h.axisHint&&("y"===b||!h.lockAxis)){var i=g-v,r=i<0?"up":"down",o=Math.abs(i),s=performance.now()-y,u=o/Math.max(s,1),l=o>=h.minDistance||u>.5;if(w)if(l)S=!0;else if(((e,t)=>!!e&&("down"===t?e.scrollTop>0:e.scrollTop+e.clientHeight<e.scrollHeight-1))(w,r)){if(!(("down"===r&&w.scrollTop<=50||"up"===r&&w.scrollTop+w.clientHeight>=w.scrollHeight-50)&&u>.3))return void(k=!0);S=!0}else S=!0;var d=!w||o>=h.edgeLeakThreshold;if(!E&&!k&&S&&d&&o>=h.minDistance){E=!0;var c=performance.now(),M={direction:"up"===r?"up":"down",distanceX:p-f,distanceY:i,absX:Math.abs(p-f),absY:o,duration:c-y,velocity:o/Math.max(c-y,1),startX:f,startY:v,endX:p,endY:g,startedAt:y,endedAt:c,originalEvent:e};t(M)}}}},D=e=>{if(e.pointerId===m)if(P(e))if(w)A();else if(E||k)A();else{var n,a=performance.now(),i=a-y,r=p-f,o=g-v,s=Math.abs(r),u=Math.abs(o),l="x"===(n=h.lockAxis&&b?b:"x"===h.axisHint?"x":"y"===h.axisHint?"y":s>=u?"x":"y")?s:u,d=i<=h.maxDuration,c=h.minDistance;if(w&&"y"===n&&S&&(c+=h.edgeLeakThreshold),d&&l>=c){var M;M="x"===n?r>0?"right":"left":o>0?"down":"up";var T=l/Math.max(i,1);t({direction:M,distanceX:r,distanceY:o,absX:s,absY:u,duration:i,velocity:T,startX:f,startY:v,endX:p,endY:g,startedAt:y,endedAt:a,originalEvent:e})}A()}else A()},A=()=>{m=null,b=null,y=0,w=null,S=!1,k=!1,E=!1},x=!!h.passiveListeners&&{passive:!0},C=h.passiveListeners?{passive:!0,capture:!0}:{capture:!0};e.addEventListener("pointerdown",T,C),e.addEventListener("pointermove",_,x),e.addEventListener("pointerup",D,x),e.addEventListener("pointercancel",D,x),e.addEventListener("lostpointercapture",D,x);return{destroy:()=>{e.removeEventListener("pointerdown",T,C),e.removeEventListener("pointermove",_,x),e.removeEventListener("pointerup",D,x),e.removeEventListener("pointercancel",D,x),e.removeEventListener("lostpointercapture",D,x),h.preventScrollOnSwipe&&(e.style.touchAction=c),A()},updateOptions:t=>{Object.assign(h,t),"boolean"==typeof t.preventScrollOnSwipe&&(t.preventScrollOnSwipe?e.style.touchAction="none":e.style.touchAction=c)}}}var zm,Bm,Hm,Um,Gm,Vm,Xm,Km,Ym,qm,Jm,Qm=e=>e,Zm=function(){function n(e,t,a){var i;return s(this,n),(i=o(this,n)).pages=[],i.currentOffset=0,i.presentationStyle="fullscreen",i.formFactor=uu(),i.timeSpentOnPaywall=0,i.animation={transition:"none",direction:"forward"},i._originalBodyStyles={},i._originalDocumentStyles={},i._savedScrollY=0,i._sheetDragStartY=0,i._sheetIsDragging=!1,i._dismissThreshold=100,i.type=e,i.value=t,i.context=a,i.setPaywallData(),w(i,i)}return g(n,e.LitElement),c(n,[{key:"setPaywallData",value:function(){var e=Pu(this.value,this.type);this.paywall=e.paywall,this.campaign=e.campaign}},{key:"getPresentationStyle",value:function(e){var t,n,a=null==e||null===(t=e.template)||void 0===t||null===(t=t.initialState)||void 0===t?void 0:t.presentation_style;return(n=a)&&cc.has(n)?"sheet"===n?"fullscreen":n:"fullscreen"}},{key:"isHalfSheet",get:function(){return"compact_sheet"===this.presentationStyle}},{key:"connectedCallback",value:function(){var e;T(n,"connectedCallback",this)([]),null!==(e=window.TVJS)&&void 0!==e&&e.DirectionalNavigation&&(window.TVJS.DirectionalNavigation.focusRoot=this),document.addEventListener("keydown",this.handleKeyDownEvent.bind(this)),this._swipeHandler=$m(this,this.handleSwipeEvent.bind(this),{axisHint:"y",lockAxis:!0,minDistance:25,edgeLeakThreshold:15,preventScrollOnSwipe:!1,pointerTypes:["touch"]}),this.presentationStyle=this.getPresentationStyle(this.paywall),this.setOriginalStyles()}},{key:"disconnectedCallback",value:function(){var e,t;T(n,"disconnectedCallback",this)([]),Kr.clearLaunchId(),null!==(e=window.TVJS)&&void 0!==e&&e.DirectionalNavigation&&(window.TVJS.DirectionalNavigation.focusRoot=document.body),document.removeEventListener("keydown",this.handleKeyDownEvent.bind(this)),ju.getInstance().removeAllListeners(kn),this.restoreStyles(),null===(t=this._halfSheetAbortController)||void 0===t||t.abort(),this._swipeHandler.destroy()}},{key:"setOriginalStyles",value:function(){"television"===this.formFactor&&(this._originalBodyStyles.overflow=document.body.style.overflow,document.body.style.overflow="hidden"),this._originalBodyStyles.background=document.body.style.background,"phone"===this.formFactor&&(this._originalBodyStyles["overscroll-behavior"]=document.body.style.overscrollBehavior?document.body.style.overscrollBehavior:null,this._originalDocumentStyles["overscroll-behavior"]=document.documentElement.style.overscrollBehavior?document.documentElement.style.overscrollBehavior:null,document.body.style.overscrollBehavior="none",document.documentElement.style.overscrollBehavior="none",this.isHalfSheet||(this._originalBodyStyles.overflow=document.body.style.overflow,document.body.style.overflow="hidden")),this.isHalfSheet&&(this._savedScrollY=window.scrollY,this._originalBodyStyles.position=document.body.style.position||null,this._originalBodyStyles.top=document.body.style.top||null,this._originalBodyStyles.width=document.body.style.width||null,document.body.style.position="fixed",document.body.style.top=`-${this._savedScrollY}px`,document.body.style.width="100%")}},{key:"restoreStyles",value:function(){Object.entries(this._originalBodyStyles).forEach((([e,t])=>{null!==t?document.body.style.setProperty(e,t):document.body.style.removeProperty(e)})),Object.entries(this._originalDocumentStyles).forEach((([e,t])=>{null!==t?document.documentElement.style.setProperty(e,t):document.documentElement.style.removeProperty(e)})),this._savedScrollY>0&&(window.scrollTo(0,this._savedScrollY),this._savedScrollY=0)}},{key:"handleKeyDownEvent",value:function(e){!this.flow||10009!==e.keyCode&&"Backspace"!==e.key&&"GoBack"!==e.key||this.flow.triggerActions(um)}},{key:"handleSwipeEvent",value:function({direction:e}){var t;if("down"===e)null===(t=this.flow)||void 0===t||t.triggerActions("__swipe_down__");else if("up"===e){var n;null===(n=this.flow)||void 0===n||n.triggerActions("__swipe_up__")}}},{key:"setupHalfSheetDragTracking",value:function(){var e,t,n;null===(e=this._halfSheetAbortController)||void 0===e||e.abort(),this._halfSheetAbortController=new AbortController;var a=this._halfSheetAbortController.signal,i=null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector(".nami-half-sheet-container"),r=null===(n=this.shadowRoot)||void 0===n?void 0:n.querySelector(".nami-half-sheet-content");if(i&&r){i.addEventListener("touchstart",(e=>{r.scrollTop>0||(this._sheetDragStartY=e.touches[0].clientY,this._sheetIsDragging=!0)}),{passive:!0,signal:a}),i.addEventListener("touchmove",(e=>{if(this._sheetIsDragging){var t=e.touches[0].clientY-this._sheetDragStartY;t>0&&(i.style.transform=`translateY(${t}px)`,i.style.transition="none",e.preventDefault())}}),{passive:!1,signal:a}),i.addEventListener("touchend",(()=>{if(this._sheetIsDragging){this._sheetIsDragging=!1;var e,t,n=i.style.transform.match(/translateY\((\d+(?:\.\d+)?)px\)/);if((n?parseFloat(n[1]):0)>this._dismissThreshold)if(null!==(e=null===(t=this.flow)||void 0===t?void 0:t.currentStepHasHoistedPrimaryActions("__swipe_down__"))&&void 0!==e&&e){var a;i.style.transform="translateY(0)",i.style.transition="transform 0.2s ease-out",null===(a=this.flow)||void 0===a||a.triggerActions("__swipe_down__")}else{var r;i.style.transform="translateY(100%)",i.style.transition="transform 0.2s ease-in";var o=null===(r=this.shadowRoot)||void 0===r?void 0:r.querySelector(".nami-half-sheet-backdrop");o&&o.classList.add("nami-dismissing"),setTimeout((()=>{var e;null===(e=this.flow)||void 0===e||e.finished()}),200)}else i.style.transform="translateY(0)",i.style.transition="transform 0.2s ease-out"}}),{signal:a})}}},{key:"setupHalfSheetFocusTrap",value:function(){var e,t,n=null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector(".nami-half-sheet-container");if(n){n.focus();var a=null===(t=this._halfSheetAbortController)||void 0===t?void 0:t.signal;n.addEventListener("keydown",(e=>{if("Tab"===e.key){var t=n.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');if(0!==t.length){var a,i,r=t[0],o=t[t.length-1];if(e.shiftKey)document.activeElement!==r&&(null===(a=this.shadowRoot)||void 0===a?void 0:a.activeElement)!==r||(e.preventDefault(),o.focus());else document.activeElement!==o&&(null===(i=this.shadowRoot)||void 0===i?void 0:i.activeElement)!==o||(e.preventDefault(),r.focus())}}}),a?{signal:a}:void 0)}}},{key:"firstUpdated",value:function(){this.timeSpentOnPaywall=Date.now(),Os(this.campaign)&&(this.flow=Nm.instance.presentFlow(this.campaign,this,this.context)),this.isHalfSheet&&this.updateComplete.then((()=>{this.setupHalfSheetDragTracking(),this.setupHalfSheetFocusTrap()}))}},{key:"updated",value:function(e){T(n,"updated",this)([e]),this.isHalfSheet&&e.has("presentationStyle")&&(this.setupHalfSheetDragTracking(),this.setupHalfSheetFocusTrap())}},{key:"getAnimationStyles",value:function(e){var t="backward"===this.animation.direction?-1:1;switch(this.animation.transition){case"verticalSlide":return`transform: translateY(${100*(e-this.currentOffset)*t}vh);`;case"slide":return`transform: translateX(${100*(e-this.currentOffset)*t}vw);`;case"fade":return`opacity: ${e===this.currentOffset?1:0};`;default:return""}}},{key:"updatePages",value:function(e){var t;return S((function(n){for(;;)switch(n.n){case 0:if(0!==this.pages.length&&"none"!==this.animation.transition){n.n=1;break}return this.pages=[e],n.a(2);case 1:if((null==(t=this.pages[this.pages.length-1])?void 0:t.id)!==e.id){n.n=2;break}return n.a(2);case 2:return this.pages=[t,e],this.currentOffset=0,n.n=3,r(this.updateComplete);case 3:requestAnimationFrame((()=>{this.currentOffset=1,setTimeout((()=>{this.pages=[e],this.currentOffset=0,this.paywall=e}),250)}));case 4:return n.a(2)}}),null,this,null,Promise)}},{key:"flowNavigateToScreen",value:function(e,t){var n,a,i,o;return S((function(s){for(;;)switch(s.n){case 0:if(null!==(n=this.flow)&&void 0!==n&&n.previousFlowStep&&this.flow.executeLifecycle(this.flow.previousFlowStep,nm),i=this.presentationStyle,o=this.getPresentationStyle(e),"fullscreen"!==i||"compact_sheet"!==o){s.n=1;break}console.warn("Unsupported transition: fullscreen → compact_sheet. Presenting as fullscreen."),s.n=4;break;case 1:if("compact_sheet"!==i||"fullscreen"!==o&&"sheet"!==o){s.n=3;break}return s.n=2,r(this.animateHalfSheetExpand());case 2:this.presentationStyle="fullscreen",s.n=4;break;case 3:this.presentationStyle=o;case 4:return this.animation=t,s.n=5,r(this.updatePages(e));case 5:null!==(a=this.flow)&&void 0!==a&&a.currentFlowStep&&this.flow.executeLifecycle(this.flow.currentFlowStep,tm);case 6:return s.a(2)}}),null,this,null,Promise)}},{key:"animateHalfSheetExpand",value:function(){var e,t;return S((function(n){for(;;)switch(n.n){case 0:if(t=null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector(".nami-half-sheet-container")){n.n=1;break}return n.a(2);case 1:return t.classList.add("nami-expanding"),n.n=2,r(new Promise((e=>setTimeout(e,300))));case 2:return n.a(2)}}),null,this,null,Promise)}},{key:"getSelectedSlideIndexForCurrentCarousel",value:function(){return Xh.getSelectedSlideIndex()}},{key:"renderFlow",value:function(){return"undefined"==typeof document?e.html(zm||(zm=Qm``)):this.isHalfSheet?this.renderHalfSheet():e.html(Bm||(Bm=Qm`
91
+ `)),yc=e=>(t,n)=>{void 0!==n?n.addInitializer((()=>{customElements.define(e,t)})):customElements.define(e,t)},bc=globalThis,wc=bc.ShadowRoot&&(void 0===bc.ShadyCSS||bc.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,kc=Symbol(),Sc=new WeakMap,Ec=function(){return c((function e(t,n,a){if(s(this,e),this._$cssResult$=!0,a!==kc)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(wc&&void 0===e){var n=void 0!==t&&1===t.length;n&&(e=Sc.get(t)),void 0===e&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),n&&Sc.set(t,e))}return e}},{key:"toString",value:function(){return this.cssText}}])}(),Mc=(e,t)=>{if(wc)e.adoptedStyleSheets=t.map((e=>e instanceof CSSStyleSheet?e:e.styleSheet));else for(var n,a=m(t);!(n=a()).done;){var i=n.value,r=document.createElement("style"),o=bc.litNonce;void 0!==o&&r.setAttribute("nonce",o),r.textContent=i.cssText,e.appendChild(r)}},Pc=wc?e=>e:e=>e instanceof CSSStyleSheet?(e=>{for(var t,n="",a=m(e.cssRules);!(t=a()).done;){n+=t.value.cssText}return(e=>new Ec("string"==typeof e?e:e+"",void 0,kc))(n)})(e):e,Tc=Object.is,_c=Object.defineProperty,Dc=Object.getOwnPropertyDescriptor,Ac=Object.getOwnPropertyNames,xc=Object.getOwnPropertySymbols,Cc=Object.getPrototypeOf,Ic=globalThis,Lc=Ic.trustedTypes,Fc=Lc?Lc.emptyScript:"",Rc=Ic.reactiveElementPolyfillSupport,Wc=(e,t)=>e,Nc={toAttribute(e,t){switch(t){case Boolean:e=e?Fc: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}},Oc=(e,t)=>!Tc(e,t),jc={attribute:!0,type:String,converter:Nc,reflect:!1,useDefault:!1,hasChanged:Oc};null!==(fc=Symbol.metadata)&&void 0!==fc||(Symbol.metadata=Symbol("metadata")),null!==(vc=Ic.litPropertyMetadata)&&void 0!==vc||(Ic.litPropertyMetadata=new WeakMap);var $c=function(){function e(){var t;return s(this,e),(t=o(this,e))._$Ep=void 0,t.isUpdatePending=!1,t.hasUpdated=!1,t._$Em=null,t._$Ev(),t}return g(e,D(HTMLElement)),c(e,[{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=m(this.constructor.elementProperties.keys());!(e=n()).done;){var a=e.value;this.hasOwnProperty(a)&&(t.set(a,this[a]),delete this[a])}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 Mc(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),a=this.constructor._$Eu(e,n);if(void 0!==a&&!0===n.reflect){var i,r=(void 0!==(null===(i=n.converter)||void 0===i?void 0:i.toAttribute)?n.converter:Nc).toAttribute(t,n.type);this._$Em=e,null==r?this.removeAttribute(a):this.setAttribute(a,r),this._$Em=null}}},{key:"_$AK",value:function(e,t){var n=this.constructor,a=n._$Eh.get(e);if(void 0!==a&&this._$Em!==a){var i,r,o,s=n.getPropertyOptions(a),u="function"==typeof s.converter?{fromAttribute:s.converter}:void 0!==(null===(i=s.converter)||void 0===i?void 0:i.fromAttribute)?s.converter:Nc;this._$Em=a;var l=u.fromAttribute(t,s.type);this[a]=null!==(r=null!=l?l:null===(o=this._$Ej)||void 0===o?void 0:o.get(a))&&void 0!==r?r:l,this._$Em=null}}},{key:"requestUpdate",value:function(e,t,n){if(void 0!==e){var a,i,r=this.constructor,o=this[e];if(null!=n||(n=r.getPropertyOptions(e)),!((null!==(a=n.hasChanged)&&void 0!==a?a:Oc)(o,t)||n.useDefault&&n.reflect&&o===(null===(i=this._$Ej)||void 0===i?void 0:i.get(e))&&!this.hasAttribute(r._$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:a,wrapped:i},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!==i||void 0!==r)||(this._$AL.has(e)||(this.hasUpdated||n||(t=void 0),this._$AL.set(e,t)),!0===a&&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 S((function(n){for(;;)switch(n.p=n.n){case 0:return this.isUpdatePending=!0,n.p=1,n.n=2,r(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,r(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=m(this._$Ep);!(t=n()).done;){var a=t.value,i=a[0],r=a[1];this[i]=r}this._$Ep=void 0}var o=this.constructor.elementProperties;if(o.size>0)for(var s,u=m(o);!(s=u()).done;){var l=s.value,d=l[0],h=l[1],c=h.wrapped,f=this[d];!0!==c||this._$AL.has(d)||void 0===f||this.C(d,void 0,h,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=jc){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(),a=this.getPropertyDescriptor(e,n,t);void 0!==a&&_c(this.prototype,e,a)}}},{key:"getPropertyDescriptor",value:function(e,t,n){var a,i=null!==(a=Dc(this.prototype,e))&&void 0!==a?a:{get(){return this[t]},set(e){this[t]=e}},r=i.get,o=i.set;return{get:r,set(t){var a=null==r?void 0:r.call(this);null!=o&&o.call(this,t),this.requestUpdate(e,a,n)},configurable:!0,enumerable:!0}}},{key:"getPropertyOptions",value:function(e){var t;return null!==(t=this.elementProperties.get(e))&&void 0!==t?t:jc}},{key:"_$Ei",value:function(){if(!this.hasOwnProperty(Wc("elementProperties"))){var e=Cc(this);e.finalize(),void 0!==e.l&&(this.l=[...e.l]),this.elementProperties=new Map(e.elementProperties)}}},{key:"finalize",value:function(){if(!this.hasOwnProperty(Wc("finalized"))){if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(Wc("properties")))for(var e=this.properties,t=0,n=[...Ac(e),...xc(e)];t<n.length;t++){var a=n[t];this.createProperty(a,e[a])}var i=this[Symbol.metadata];if(null!==i){var r=litPropertyMetadata.get(i);if(void 0!==r)for(var o,s=m(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 h,c=m(this.elementProperties);!(h=c()).done;){var f=h.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,a=m(new Set(e.flat(1/0).reverse()));!(n=a()).done;){var i=n.value;t.unshift(Pc(i))}else void 0!==e&&t.push(Pc(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}}])}();$c.elementStyles=[],$c.shadowRootOptions={mode:"open"},$c[Wc("elementProperties")]=new Map,$c[Wc("finalized")]=new Map,null!=Rc&&Rc({ReactiveElement:$c}),(null!==(pc=Ic.reactiveElementVersions)&&void 0!==pc?pc:Ic.reactiveElementVersions=[]).push("2.1.1");var zc={attribute:!0,type:String,converter:Nc,reflect:!1,hasChanged:Oc},Bc=(e=zc,t,n)=>{var a=n.kind,i=n.metadata,r=globalThis.litPropertyMetadata.get(i);if(void 0===r&&globalThis.litPropertyMetadata.set(i,r=new Map),"setter"===a&&((e=Object.create(e)).wrapped=!0),r.set(n.name,e),"accessor"===a){var o=n.name;return{set(n){var a=t.get.call(this);t.set.call(this,n),this.requestUpdate(o,a,e)},init(t){return void 0!==t&&this.C(o,void 0,e,t),t}}}if("setter"===a){var s=n.name;return function(n){var a=this[s];t.call(this,n),this.requestUpdate(s,a,e)}}throw Error("Unsupported decorator location: "+a)};function Hc(e){return(t,n)=>"object"==typeof n?Bc(e,t,n):((e,t,n)=>{var a=t.hasOwnProperty(n);return t.constructor.createProperty(n,e),a?Object.getOwnPropertyDescriptor(t,n):void 0})(e,t,n)}function Uc(e){return Hc(f({},e,{state:!0,attribute:!1}))}function Gc(e){return!e||"object"==typeof e&&0==Object.keys(e).length}var Vc,Xc="entry",Kc="screen",Yc="branch",qc="exit",Jc="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.PAUSE="flowPause",e.RESUME="flowResume"}(Vc||(Vc={}));var Qc="__handoff_sequence__",Zc="__buy_sku__",em="__default__",tm="__appear__",nm="__disappear__",am="__login_success__",im="__login_failure__",rm="__logout_success__",om="__logout_failure__",sm="__purchase_success__",um="__remoteback__",lm="__tag_update__",dm="and",hm="or",cm="i_contains",mm="equals",fm="i_equals",vm="not_equals",pm="not_i_equals",gm="not_contains",ym="set",bm="notSet",wm=function(){function e(){s(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 a=n.map((e=>this.evaluateFilter(e)));switch(e.operator){case dm:return a.every((e=>e));case hm:return a.some((e=>e));default:return a.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 dm:for(var a,i=m(n);!(a=i()).done;){var r=a.value;if(!this.evaluateFilter(r))return!1}return!0;case hm:for(var o,s=m(n);!(o=s()).done;){var u=o.value;if(this.evaluateFilter(u))return!0}return!1;default:for(var l,d=m(n);!(l=d()).done;){var h=l.value;if(!this.evaluateFilter(h))return!1}return!0}}},{key:"evaluateFilter",value:function(e){var t=this.resolve(e.identifier);if(e.operator===ym)return null!=t;if(e.operator===bm)return null==t;if(null==t)return!![vm,pm,gm].includes(e.operator);switch(e.operator){case cm:return Array.isArray(t)?e.values.some((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 mm:return e.values.some((e=>{if("string"==typeof t)return t===e;if("boolean"==typeof t){var n="true"===e.toLowerCase();return t===n}return this.log("Unsupported type for equals comparison: "+typeof t),!1}));case fm:return e.values.some((e=>{if("string"==typeof t)return 0===t.localeCompare(e,void 0,{sensitivity:"accent"});if("boolean"==typeof t){var n="true"===e.toLowerCase();return t===n}return this.log("Unsupported type for i_equals comparison: "+typeof t),!1}));case vm:return e.values.every((e=>"string"!=typeof t||t!==e));case pm:return e.values.every((e=>"string"!=typeof t||0!==t.localeCompare(e,void 0,{sensitivity:"accent"})));case gm:return e.values.every((e=>"string"!=typeof t||!t.includes(e)));default:return this.log(`Unsupported operator: ${e.operator}`),!1}}},{key:"resolve",value:function(e){var t=this.resolveRaw(e);if(void 0!==t)return t;var n=e.lastIndexOf(".");if(-1!==n){var a=e.slice(0,n),i=e.slice(n+1),r=this.resolveRaw(a);return void 0!==r?this.extractProperty(i,r):void this.log(`Could not resolve base identifier: ${a}`)}}},{key:"resolveRaw",value:function(e){for(var t,n=[...this.namespaceResolvers.keys()].sort(((e,t)=>t.length-e.length)),a=m(n);!(t=a()).done;){var i=t.value;if(e.startsWith(i)){var r=this.namespaceResolvers.get(i);if(r)return r(e)}}}},{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){Wn.debug(`[NamiConditionEvaluator] ${e}`)}}],[{key:"shared",get:function(){return e.instance||(e.instance=new e),e.instance}}])}(),km=function(){return c((function e(){s(this,e)}),[{key:"register",value:function(){wm.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,a=t,i=m(e.replace(/\[(\w+)\]/g,".$1").split(".").filter(Boolean));!(n=i()).done;){var r=n.value;if(null==a||"object"!=typeof a)return;a=a[r]}return a}}])}(),Sm=function(){function e(t){var n;return s(this,e),(n=o(this,e)).namespace="LaunchContext",n.context=t,n.register(),n}return g(e,km),c(e,[{key:"resolveValue",value:function(e){if(e.startsWith("customAttributes.")){var t=e.substring(17);return this.resolveKeyPath(t,this.context.customAttributes)}if(e.startsWith("customObject.")){var n=e.substring(13);return this.resolveKeyPath(n,this.context.customObject)}return this.resolveKeyPath(e,{customAttributes:this.context.customAttributes,customObject:this.context.customObject,productGroups:this.context.productGroups})}}])}(),Em=function(){function e(){var t,n,a,i;s(this,e),(i=o(this,e)).namespace="Device";var r=Intl.DateTimeFormat().resolvedOptions().locale.split("-")[1]||"",u=Intl.DateTimeFormat().resolvedOptions().timeZone,l=su();return i.context={osName:l.os_name,osVersion:l.os_version,appVersion:l.extended_platform_version,sdkVersion:l.sdk_version,deviceModel:l.device_model,screenWidth:window.innerWidth,screenHeight:window.innerHeight,formFactor:l.form_factor,tvQuality:i.tvQuality(null!==(t=l.form_factor)&&void 0!==t?t:"desktop"),tvResolution:i.tvResolution(null!==(n=l.form_factor)&&void 0!==n?n:"desktop"),screenSize:i.screenSizeTier(null!==(a=l.form_factor)&&void 0!==a?a:"desktop"),language:l.language,country:r,timezone:u},i.register(),i}return g(e,km),c(e,[{key:"screenSizeTier",value:function(e){var t=window.screen.width,n=window.screen.height,a=window.devicePixelRatio||1,i=Math.round(t*a),r=Math.round(n*a),o=Math.max(i,r);switch(e){case"phone":return o<1136?"tiny":o<1334?"small":o<1920?"medium":o<2560?"large":"huge";case"tablet":return o<2048?"medium":o<2732?"large":"huge";case"television":return o<1920?"medium":o<3840?"large":"huge";case"desktop":return o<1440?"small":o<2560?"medium":o<3840?"large":"huge";default:return"medium"}}},{key:"tvQuality",value:function(e){if("television"!==e)return"";var t=window.screen.width,n=window.screen.height,a=window.devicePixelRatio||1,i=Math.round(t*a),r=Math.round(n*a),o=Math.max(i,r),s=Math.min(i,r);return o>=3840||s>=2160?"4K":o>=1920||s>=1080?"1080p":"720p"}},{key:"tvResolution",value:function(e){if("television"!==e)return"";var t=window.screen.width,n=window.screen.height,a=window.devicePixelRatio||1,i=Math.round(t*a),r=Math.round(n*a),o=Math.max(i,r),s=Math.min(i,r);return s<720&&o<1280?"SD":s>=720&&s<1080&&o>=1280&&o<1920?"720p":s>=1080&&s<1440&&o>=1920&&o<2560?"1080p":s>=1440&&s<2160&&o>=2560&&o<3840?"1440p":s>=2160&&s<3e3&&o>=3840&&o<5e3?"4K":s>=3e3&&o>=5e3?"8K":"Unknown"}},{key:"resolveValue",value:function(e){return this.resolveKeyPath(e,this.context)}}])}(),Mm=[/(^|_)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],Pm=function(){function e(){s(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 a,i=new URLSearchParams(e.search),r=(e,a)=>{var i=(e=>e.replace(/([a-z])([A-Z])/g,"$1_$2").replace(/[-\s]/g,"_").toLowerCase())(e);if(!(n.size>=10||(e=>Mm.some((t=>t.test(e))))(i))){var r=this.safeValue(a);r&&(t[i]=r,n.add(i))}},o=m(i.entries());!(a=o()).done;){var s=a.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()}}])}();Pm._instance=null;var Tm,_m=()=>Pm.instance.params,Dm=/\{\{\s*([^}]+?)\s*\}\}/g,Am=function(){return c((function e(t){s(this,e),this.flowManager=t,this.urlParams=_m()}),[{key:"resolve",value:function(e){var t,n,a,i,r,o,s,u,l,d,h,c,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 Sm(p).resolveValue(g);return null==y?void 0:y.toString()}}else 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!==(a=null==f||null===(i=f.campaign)||void 0===i?void 0:i.value)&&void 0!==a?a: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===(h=m.currentFlowStep)||void 0===h?void 0:h.name;case"buttonText":return null==m||null===(c=m.currentButton)||void 0===c?void 0:c.firstTextValue();case"slideNumber":var b=null==f?void 0:f.getSelectedSlideIndexForCurrentCarousel();return null!=b?`${b+1}`:void 0;default:return}}},{key:"interpolateLiquidVariables",value:function(e){return e.replace(Dm,((e,t)=>{var n,a=null!==(n=this.resolve(t))&&void 0!==n?n:this.urlParams[t];return null!=a?a:""}))}},{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])=>f({},e,{[t]:this.interpolateDeep(n)})),{}):e}}])}(),xm=function(){function e(){var t;return s(this,e),(t=o(this,e)).namespace="urlParams",t.context=_m(),t.register(),t}return g(e,km),c(e,[{key:"resolveValue",value:function(e){return Wn.debug("[URLParamsResolver]","Resolving keyPath",e),this.resolveKeyPath(e,this.context)}}])}(),Cm=function(){function e(){var t;return s(this,e),(t=o(this,e)).namespace="state",t.register(),t}return g(e,km),c(e,[{key:"getContextProvider",value:function(){var e=Xh.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)}}}])}(),Im=function(){function e(t){var n;return s(this,e),(n=o(this,e)).namespace="Placement",n.campaign=t,n.register(),n}return g(e,km),c(e,[{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=Xh.providers;if(0!==n.length){var a=n.find((e=>e.flow));return a?a.getCurrentPlacementLabel():null===(t=n[n.length-1])||void 0===t?void 0:t.getCurrentPlacementLabel()}}}}])}(),Lm=function(){return c((function e(){s(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?Kr.setNamiProfile({externalId:this.externalId}):Kr.removeNamiProfile(),this}},{key:"load",value:function(){var e=Kr.getNamiProfile();e&&(this.externalId=e.externalId),Xh.setIsLoggedIn(!!this.externalId)}},{key:"login",value:function(e){var t;return S((function(n){for(;;)switch(n.n){case 0:return n.n=1,r(Ns.instance.login(e));case 1:(t=n.v).external_id&&Xh.setIsLoggedIn(!0),this.setExternalId(t.external_id).save();case 2:return n.a(2)}}),null,this,null,Promise)}},{key:"logout",value:function(){return S((function(e){for(;;)switch(e.n){case 0:return e.n=1,r(Ns.instance.logout());case 1:Xh.setIsLoggedIn(!1),this.setExternalId(void 0).save();case 2:return e.a(2)}}),null,this,null,Promise)}}])}();Lm.instance=new Lm,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"}(Tm||(Tm={}));var Fm=function(){return c((function e(){s(this,e),this.emitter=ju.getInstance(),wm.shared.registerNamespaceResolver("UserTags",(t=>{var n=t.replace("UserTags.",""),a=e.getCustomerAttribute(n);if(null!=a){var i=a.toLowerCase();return"true"===i||"false"===i?"true"===i:isNaN(Number(a))?a:parseInt(a,10)}return null}))}),[{key:"isSDKInitialized",get:function(){return dc.instance.isInitialized}}],[{key:"isLoggedIn",value:function(){return Lm.instance.isLoggedIn()}},{key:"loggedInId",value:function(){return this.instance.isSDKInitialized||Wn.debug(ke),Lm.instance.getExternalId()}},{key:"login",value:function(e){var t,n,a,i,o,s,u;return S((function(l){for(;;)switch(l.p=l.n){case 0:if(this.instance.isSDKInitialized){l.n=1;break}throw t=new Qr,this.invokeStateHandler(Tm.LOGIN,!1,t),t;case 1:if(!this.inAnonymousMode()){l.n=2;break}throw n=new oo,this.invokeStateHandler(Tm.LOGIN,!1,n),n;case 2:return l.p=2,l.n=3,r(Lm.instance.login(e));case 3:return l.n=4,r(Qh.instance.fetchActiveEntitlements());case 4:this.invokeStateHandler(Tm.LOGIN,!0),Nm.instance.flowOpen&&(a=Nm.instance.currentFlow,(i=null==a?void 0:a.currentFlowStep)&&a.executeLifecycle(i,am)),l.n=6;break;case 5:throw l.p=5,u=l.v,this.invokeStateHandler(Tm.LOGIN,!1,u),Nm.instance.flowOpen&&(o=Nm.instance.currentFlow,(s=null==o?void 0:o.currentFlowStep)&&o.executeLifecycle(s,im)),u;case 6:return l.a(2)}}),null,this,[[2,5]],Promise)}},{key:"logout",value:function(){var e,t,n,a,i,o,s;return S((function(u){for(;;)switch(u.p=u.n){case 0:if(this.instance.isSDKInitialized){u.n=1;break}throw e=new Qr,this.invokeStateHandler(Tm.LOGOUT,!1,e),e;case 1:if(!this.inAnonymousMode()){u.n=2;break}throw t=new oo,this.invokeStateHandler(Tm.LOGOUT,!1,t),t;case 2:return u.p=2,u.n=3,r(Lm.instance.logout());case 3:return u.n=4,r(Qh.instance.fetchActiveEntitlements());case 4:this.invokeStateHandler(Tm.LOGOUT,!0),Nm.instance.flowOpen&&(n=Nm.instance.currentFlow,(a=null==n?void 0:n.currentFlowStep)&&n.executeLifecycle(a,rm)),u.n=6;break;case 5:throw u.p=5,s=u.v,this.invokeStateHandler(Tm.LOGOUT,!1,s),Nm.instance.flowOpen&&(i=Nm.instance.currentFlow,(o=null==i?void 0:i.currentFlowStep)&&i.executeLifecycle(o,om)),s;case 6:return u.a(2)}}),null,this,[[2,5]],Promise)}},{key:"setCustomerDataPlatformId",value:function(e){return S((function(t){for(;;)switch(t.n){case 0:return t.n=1,r(this.updateCustomerDataPlatformId(e));case 1:return t.a(2)}}),null,this,null,Promise)}},{key:"clearCustomerDataPlatformId",value:function(){return S((function(e){for(;;)switch(e.n){case 0:return e.n=1,r(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,a,i,o;return S((function(s){for(;;)switch(s.n){case 0:if(t=e?Tm.ANONYMOUS_MODE_ON:Tm.ANONYMOUS_MODE_OFF,this.instance.isSDKInitialized){s.n=1;break}throw n=new Qr,this.invokeStateHandler(t,!1,n),n;case 1:if(this.anonymousModeCapability()){s.n=2;break}return Wn.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 a=e?new io:new ro,this.invokeStateHandler(t,!1,a),s.a(2);case 3:if(!e){s.n=4;break}Kr.setAnonymousMode(e),Kr.resetDevice(),this.refetchConfig(),this.invokeStateHandler(Tm.ANONYMOUS_MODE_ON,!0),s.n=6;break;case 4:return Kr.clearAnonymousMode(),Vu&&Vu.setInMemoryAnonymousMode(!1),o=null===(i=Kr.getNamiConfig())||void 0===i?void 0:i.namiCommands,s.n=5,r(Bu.instance.createOrUpdateDevice(su(o)));case 5:Kr.clearAnonymousUUID(),this.refetchConfig(),this.invokeStateHandler(Tm.ANONYMOUS_MODE_OFF,!0);case 6:return s.a(2)}}),null,this,null,Promise)}},{key:"inAnonymousMode",value:function(){return!!this.instance.isSDKInitialized&&Xu()}},{key:"setCustomerAttribute",value:function(e,t){if(!this.instance.isSDKInitialized)throw new Qr;if(Kr.setCustomerAttribute(e,t),Cs(le.PAYWALL_PERSONALIZATION)?(Xh.setCustomerAttribute({[e]:t}),Wn.debug(`This customer attribute you set is now available for paywall personalization using the smart text variable: ${e}`)):Wn.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.`),Nm.instance.flowOpen){var n=Nm.instance.currentFlow;if(n){var a=n.currentFlowStep;a&&n.executeLifecycle(a,lm)}}}},{key:"getCustomerAttribute",value:function(e){if(!this.instance.isSDKInitialized)throw new Qr;var t=Kr.getCustomerAttribute(e);return null!=t?Cs(le.PAYWALL_PERSONALIZATION)?Wn.debug(`Found customer attribute. ${e} is available for paywall personalization on this device.`):Wn.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.`):Wn.warn(`No ${e} customer attribute found.`),t}},{key:"getAllCustomerAttributes",value:function(){if(!this.instance.isSDKInitialized)throw new Qr;return Kr.getAllCustomerAttributes()}},{key:"clearCustomerAttribute",value:function(e){if(!this.instance.isSDKInitialized)throw new Qr;Kr.clearCustomerAttribute(e)?(Xh.removeCustomerAttribute(e),Wn.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.`)):Wn.warn(`No value to clear for attribute ${e}.`)}},{key:"clearAllCustomerAttributes",value:function(){if(!this.instance.isSDKInitialized)throw new Qr;Kr.getAllCustomerAttributesKeys().forEach((e=>{Xh.removeCustomerAttribute(e)})),Kr.clearAllCustomerAttributes(),Wn.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 Qr;return Kr.getCustomerJourneyState()}},{key:"deviceId",value:function(){var e,t;return this.instance.isSDKInitialized&&null!==(e=null===(t=Kr.getDevice())||void 0===t?void 0:t.id)&&void 0!==e?e:Le}},{key:"registerJourneyStateHandler",value:function(e){if(Is("NamiCustomerManager.registerJourneyStateHandler"))return this.instance.emitter.addListener(Pn,e),()=>{this.instance.emitter.removeListener(Pn,e)}}},{key:"invokeStateHandler",value:function(e,t,n){this.instance.emitter.emit("accountStateChange",e,t,n)}},{key:"updateCustomerDataPlatformId",value:function(e){var t,n,a,i;return S((function(o){for(;;)switch(o.p=o.n){case 0:if(this.instance.isSDKInitialized){o.n=1;break}throw t=new Qr,this.invokeStateHandler(Tm.CUSTOMER_DATA_PLATFORM_ID_SET,!1,t),t;case 1:if(this.inAnonymousMode()){o.n=6;break}return o.p=2,o.n=3,r(Bu.instance.updateDeviceField("customer_data_platform_id",e));case 3:this.invokeStateHandler(Tm.CUSTOMER_DATA_PLATFORM_ID_SET,!0),o.n=5;break;case 4:o.p=4,i=o.v,this.invokeStateHandler(Tm.CUSTOMER_DATA_PLATFORM_ID_SET,!1,i);case 5:o.n=7;break;case 6:return Wn.info("Unable to set CDP ID in anonymous mode",{deviceId:null===(n=Kr.getDevice())||void 0===n?void 0:n.id,anonymousMode:!0}),a=new so,this.invokeStateHandler(Tm.CUSTOMER_DATA_PLATFORM_ID_SET,!1,a),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=Cs(le.ANONYMOUS_MODE_CAPABILITY),t=Cs(le.THIRD_PARTY_TRANSACTIONS);return e&&t}},{key:"refetchConfig",value:function(){return S((function(e){for(;;)switch(e.n){case 0:if(!this.instance.isSDKInitialized){e.n=1;break}return e.n=1,r(Promise.all([Hu.instance.fetchProducts(),Uu.instance.fetchPaywalls().then((e=>$u.instance.fetchCampaignRules(e)))]));case 1:return e.a(2)}}),null,this,null,Promise)}}])}();Fm.instance=new Fm;var Rm=function(){return c((function e(t={}){var n,a,i,r,o;s(this,e),this.id=null!==(n=t.id)&&void 0!==n?n:"",this.name=null!==(a=t.name)&&void 0!==a?a:"",this.steps=null!==(i=t.steps)&&void 0!==i?i:[],this.screens=null!==(r=t.screens)&&void 0!==r?r:[],this.resumeFromBookmark=Boolean(t.resume_from_bookmark),this.transition=null!==(o=t.transition)&&void 0!==o?o:"none"}),[{key:"allScreensAvailable",get:function(){return this.screens.length>0&&Hs(this.screens)}}])}(),Wm=function(){function e(t,n,a,i){var r,u;s(this,e),(u=o(this,e,[null!==(r=t.flow.object)&&void 0!==r?r:{}])).stepcrumbs=[],u.branchcrumbs=[],u.activeHandoffSequence=null,u.currentScreenState=null,u.isPaused=!1,u.timerStates={},u.campaign=t,u.component=n,u.context=i,u.manager=a,u.branchcrumbs=[],u.stepcrumbs=[],u.registerResolvers(i);var l=u.findStepByType(Xc);return l&&u.forward(l.id),u}return g(e,Rm),c(e,[{key:"registerResolvers",value:function(e){e&&new Sm(e),new Em,new xm,new Cm,new Im(this.campaign),wm.shared.registerNamespaceResolver("Flow",(e=>{switch(e){case"Flow.stepcrumbs":return this.stepcrumbs.map((e=>e.id));case"Flow.branchcrumbs":return this.branchcrumbs;default:return}}))}},{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),a=this.stepcrumbs.slice(0,-1).some((e=>"screen"===e.type));return t&&n&&a}},{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:"finished",value:function(){this.manager.finishFlow()}},{key:"back",value:function(){this.previousStepAvailable?this.backToPreviousScreenStep():Wn.debug("No previous step available")}},{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 a,i,r=Bs(n.screen);return r&&this.component.flowNavigateToScreen(r,{transition:this.transition,direction:"backward"}),void(this.currentScreenState=null!==(a=null===(i=Xh.currentProvider)||void 0===i?void 0:i.state)&&void 0!==a?a:null)}}Wn.warn("No previous screen step found to return to")}else Wn.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(t.type){case Xc:case qc:return this.stepcrumbs.push(t),void this.executeLifecycle(t,em);case Yc:return void this.handleBranchStep(t);case Kc:return void this.handleScreenStep(t);case Jc:return}}else Wn.error(`No step found with id: ${e}`)}},{key:"pause",value:function(){var e;this.isPaused?Wn.info("Flow is already paused"):(this.isPaused=!0,this.pausedStepID=null===(e=this.currentFlowStep)||void 0===e?void 0:e.id,Wn.info("Flow paused"))}},{key:"resumeFromPause",value:function(){if(this.isPaused)if(this.isPaused=!1,this.pausedStepID){var e=this.pausedStepID;this.pausedStepID=void 0,Wn.info(`Flow resumed from step ${e}`),this.forward(e)}else Wn.warn("No step to resume from");else Wn.info("Flow is not paused")}},{key:"executeLifecycle",value:function(e,t,n){var a=e.actions[t];a&&this.executeFullLifecycles(a,n)}},{key:"lifecycles",value:function(e){if(this.currentFlowStep){var t=this.currentFlowStep.actions[e];if(t)return t;Wn.info(`No actions found for button ${e} on step ${this.currentFlowStep.id}`)}}},{key:"triggerActions",value:function(e,t,n){var a=this.lifecycles(e);a&&(this.currentButton=t,this.executeFullLifecycles(a,n))}},{key:"executeFullLifecycles",value:function(e,t){for(var n,a=m(e);!(n=a()).done;){var i=n.value;[i.before,i.action,i.after].forEach((e=>null==e?void 0:e.forEach((e=>this.shouldRun(e)&&this.performAction(e,t)))))}}},{key:"triggerBeforeActions",value:function(e,t,n){var a=this.lifecycles(e);if(a){this.currentButton=t;for(var i,r=m(a);!(i=r()).done;){var o;null===(o=i.value.before)||void 0===o||o.forEach((e=>this.shouldRun(e)&&this.performAction(e,n)))}}}},{key:"triggerAfterActions",value:function(e,t,n){var a=this.lifecycles(e);if(a){this.currentButton=t;for(var i,r=m(a);!(i=r()).done;){var o;null===(o=i.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){return!e.conditions||e.conditions.every((e=>wm.shared.evaluate(e)))}},{key:"performAction",value:function(e,t){var n;if(this.currentFlowStep){var a=(null!==(n=e.parameters)&&void 0!==n&&n.delay?+e.parameters.delay:0)||0,i=n=>{var a,i,r,o,s,u,l;if((null===(a=this.currentFlowStep)||void 0===a?void 0:a.id)===n)switch(e.function){case Vc.BACK:this.back();break;case Vc.NEXT:null!==(i=e.parameters)&&void 0!==i&&i.step?this.forward(e.parameters.step):this.next();break;case Vc.NAVIGATE:var d;if(null!==(r=e.parameters)&&void 0!==r&&r.step)(null===(d=this.previousFlowStep)||void 0===d?void 0:d.id)===e.parameters.step?this.back():this.forward(e.parameters.step);else this.next();break;case Vc.FINISHED:case Vc.DISMISS:this.finished();break;case Vc.EXIT:var h=this.steps.find((e=>e.type===qc));h&&this.forward(h.id);break;case Vc.PAUSE:this.pause();break;case Vc.RESUME:this.resumeFromPause();break;case Vc.HANDOFF:if(null!==(o=e.parameters)&&void 0!==o&&o.handoffTag)if(this.manager.handoffStepHandler)if(e.parameters.handoffData)Wn.debug(`Invoking handoffStepHandler with ${e.parameters.handoffTag} ${JSON.stringify(e.parameters.handoffData)}`),this.manager.handoffStepHandler(e.parameters.handoffTag,e.parameters.handoffData);else if(t)Wn.debug(`Invoking handoffStepHandler with ${e.parameters.handoffTag} ${JSON.stringify(t)}`),this.manager.handoffStepHandler(e.parameters.handoffTag,t);else if(e.parameters.handoffFormId){var c=this.getFormData();e.parameters.handoffTag===Qc?this.flowHandoffFormSequence():this.manager.handoffStepHandler(e.parameters.handoffTag,c)}else Wn.debug(`Invoking handoffStepHandler with ${e.parameters.handoffTag} and no data`),this.manager.handoffStepHandler(e.parameters.handoffTag);else Wn.debug("No handoffStepHandler found",e);break;case Vc.LOG:var m;if(null!==(s=e.parameters)&&void 0!==s&&s.eventName)Wn.info(`logEvent → ${e.parameters.eventName}`);else Wn.warn(`Missing 'eventName' in logEvent action ${null!==(m=e.id)&&void 0!==m?m:"unknown"}`);break;case Vc.TRACK:var f;if(null!==(u=e.parameters)&&void 0!==u&&u.eventName)Wn.info(`trackEvent → ${e.parameters.eventName}`);else Wn.warn(`Missing 'eventName' in logEvent action ${null!==(f=e.id)&&void 0!==f?f:"unknown"}`);break;case Vc.SET_VIDEO:null!==(l=e.parameters)&&void 0!==l&&l.name&&e.parameters.url?Xh.setAppSuppliedVideoDetails({name:e.parameters.name,url:e.parameters.url}):Wn.warn("Missing name, url for setting video details");break;case Vc.BLOCK_BACK:var v,p=null===(v=e.parameters)||void 0===v?void 0:v.step,g=p?this.getStep(p):void 0;g?g.allow_back_to=!1:this.currentFlowStep?this.currentFlowStep.allow_back_to=!1:Wn.warn("Missing step for blocking back");break;case Vc.FLOW_EVENT:var y,b=new Am(this.manager),w=Object.fromEntries(Object.entries(null!==(y=e.parameters)&&void 0!==y?y:{}).map((([e,t])=>[e,b.interpolateDeep(t)])));this.manager.eventHandler?this.manager.eventHandler(w):Wn.warn("Missing event handler",w);break;case Vc.FLOW_ENABLED:Xh.setUserInteractionEnabled(!0);break;case Vc.FLOW_DISABLED:Xh.setUserInteractionEnabled(!1);break;case Vc.SET_TAGS:e.parameters&&(Xh.setUserTags(e.parameters),Object.entries(e.parameters).forEach((([e,t])=>{Fm.setCustomerAttribute(e,t)})));break;default:Wn.warn(`Missing action handler for ${e.function}`,e)}else Wn.debug(`Skipped action for stale flow step ${n}`)};a?setTimeout(i.bind(this,this.currentFlowStep.id),a):i(this.currentFlowStep.id)}else Wn.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,a=m(this.steps.slice(t+1));!(n=a()).done;){var i=n.value;if(this.isStepActive(i))return i}Wn.debug(`No active next step found after ${e.id}`)}else Wn.error(`Could not find next step for step ${e.id}`)}else Wn.error("Next step not found")}},{key:"handleScreenStep",value:function(e){var t,n=Bs(null!==(t=e.screen)&&void 0!==t?t:"");e.screen&&n&&this.campaign?(this.stepcrumbs.push(e),this.component.flowNavigateToScreen(n,{transition:this.transition,direction:"forward"})):Wn.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 a=n[t],i=a[0],r=a[1];if(r)for(var o,s=m(r);!(o=s()).done;){var u=o.value;if(u.action)for(var l,d=m(u.action);!(l=d()).done;){var h,c,f=l.value;if(this.shouldRun(f))return this.branchcrumbs.push(i),null===(h=u.before)||void 0===h||h.forEach((e=>{this.performAction(e)})),u.action.forEach((e=>{this.shouldRun(e)&&this.performAction(e)})),void(null===(c=u.after)||void 0===c||c.forEach((e=>{this.performAction(e)})))}else Wn.warn(`No actions defined for branch tag ${i}`)}}Wn.warn(`No matching branch condition matched for step ${e.id}`)}},{key:"getFormData",value:function(){var e,t;return f({},null!==(e=null===(t=Xh.currentProvider)||void 0===t||null===(t=t.state)||void 0===t?void 0:t.formStates)&&void 0!==e?e:{})}},{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).sort();if(0!==n.length){var a=n.filter((e=>!0===t[e]));if(0===a.length)return Wn.info("No eligible handoff keys after filtering"),void this.manager.resume();this.activeHandoffSequence={formStates:f({},t),remainingKeys:[...a]},this.resumeNextHandoff()}else Wn.warn("formStates is empty, no handoffs to perform")}else Wn.warn("No formStates available for handoff sequence")}},{key:"resumeNextHandoff",value:function(){var e,t,n=this.activeHandoffSequence;if(!n)return Wn.warn("No active handoff sequence to resume"),void this.manager.resume();if(0===n.remainingKeys.length)return Wn.info("All handoffs in the sequence are complete"),this.activeHandoffSequence=null,void this.manager.resume();var a=n.remainingKeys.shift(),i=n.formStates[a];Wn.debug(`Starting handoff for ${a} → ${String(i)}`),this.activeHandoffSequence=n;var r=`${a}`;null===(e=(t=this.manager).handoffStepHandler)||void 0===e||e.call(t,r,void 0)}}])}(),Nm=function(){function e(){s(this,e),this.flowOpen=!1,this.lastAnimatedFlowProgress=new Map,this.navGraphCache=new WeakMap}return c(e,[{key:"resume",value:function(){e.resume()}},{key:"presentFlow",value:function(e,t,n){var a=new Wm(e,t,this,n);return this.flowOpen=!0,this.currentFlow=a,a}},{key:"finishFlow",value:function(){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===Kc));if(0===t.length)return 0;var n=this.currentFlow.stepcrumbs.filter((e=>e.type===Kc));if(0===n.length)return 0;var a=this.buildNavGraph(this.currentFlow),i=this.currentFlow.currentFlowStep,r=this.findBranchPoint(t,a),o=0;if(r)o=this.calculateBranchingProgress(n,t,i,r,a);else{var s=t.findIndex((e=>e.id===i.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,a=m(e);!(n=a()).done;){var i=n.value;if(this.hasBranching(i,e,t))return i}return null}},{key:"calculateBranchingProgress",value:function(e,t,n,a,i){var r=e.length,o=t.findIndex((e=>e.id===a.id)),s=e.findIndex((e=>e.id===a.id)),u=t.findIndex((e=>e.id===n.id));if(-1===s||n.id===a.id)return(u+1)/(o+2);var l=this.countForwardScreens(n,t,i),d=r+l;return Wn.debug(`Branching progress: visited=${r}, remaining=${l}, total=${d}, step=${n.id}`),r/d}},{key:"countForwardScreens",value:function(e,t,n){var a=t.findIndex((t=>t.id===e.id));if(-1===a)return 0;var i=new Set,r=0,o=(e,s)=>{if(!i.has(e)){i.add(e);var u=(n.get(e)||[]).filter((e=>{var n=t.findIndex((t=>t.id===e));return n>a}));if(0!==u.length)for(var l,d=m(u);!(l=d()).done;){var h=l.value;o(h,s+1)}else r=Math.max(r,s)}};return o(e.id,0),r}},{key:"hasBranching",value:function(e,t,n){var a=t.findIndex((t=>t.id===e.id));if(-1===a)return!1;var i=(n.get(e.id)||[]).filter((e=>{var n=t.findIndex((t=>t.id===e));return n>a}));return i.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 a,i=null===(a=t.parameters)||void 0===a?void 0:a.step;i&&(n.has(e.id)||n.set(e.id,new Set),n.get(e.id).add(i))}}))}))}))}));var a=new Map;return n.forEach(((e,t)=>{a.set(t,Array.from(e))})),this.navGraphCache.set(e,a),a}},{key:"getCurrentFlowStepAutoAdvanceDelay",value:function(){var e,t,n=null===(e=this.currentFlow)||void 0===e?void 0:e.currentFlowStep;if(!n)return null;var a=null===(t=n.actions)||void 0===t?void 0:t[tm];if(!a)return null;for(var i,r=m(a);!(i=r()).done;)for(var o,s,u=m(null!==(o=i.value.action)&&void 0!==o?o:[]);!(s=u()).done;){var l,d=s.value;if((d.function===Vc.NAVIGATE||d.function===Vc.NEXT)&&null!=(null===(l=d.parameters)||void 0===l?void 0:l.delay)){var h=d.parameters.delay,c=Number(h);if(!isNaN(c)&&c>0)return c/1e3}}return null}}],[{key:"instance",get:function(){return e._instance||(e._instance=new e),e._instance}},{key:"registerStepHandoff",value:function(e){this.instance.handoffStepHandler=e}},{key:"registerEventHandler",value:function(e){this.instance.eventHandler=e}},{key:"resume",value:function(){var t=e.instance,n=t.flowOpen,a=t.currentFlow;if(n&&a&&a.currentFlowStep){if(a.activeHandoffSequence)return Wn.debug(`Resuming flow at handoff sequence ${a.currentFlowStep.id}`),void a.resumeNextHandoff();Wn.debug(`Resuming flow at step ${a.currentFlowStep.id}`),a.executeLifecycle(a.currentFlowStep,"__resume__")}else Wn.warn("Cannot resume: no active flow or current step")}},{key:"finish",value:function(){var t=e.instance,n=t.flowOpen,a=t.currentFlow;n&&a&&a.currentFlowStep?(Wn.debug(`Finishing flow programmatically at step ${a.currentFlowStep.id}`),a.finished()):Wn.debug("Cannot finish: no active flow or current step")}},{key:"pause",value:function(){var t=e.instance,n=t.flowOpen,a=t.currentFlow;n&&a&&a.currentFlowStep?!0===a.resumeFromBookmark?a.pause():Wn.warn("This flow cannot be paused"):Wn.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()}}])}();var Om=e=>{var t;return S((function(n){for(;;)if(0===n.n)return t=new Set(Array.from(document.fonts.values()).map((e=>e.family))),e.forEach((e=>{var n=jm(e);if(!t.has(n)){var a=new FontFace(n,`url(${e.file})`);document.fonts.add(a)}})),n.a(2,document.fonts.ready.then())}),null,null,null,Promise)};function jm(e){return`${e.family}-${e.style}`.replace(/ /g,"")}function $m(e,t,n){var a,i,r,o,s,u,l,d;if("undefined"==typeof window||!e||!t)return Wn.debug("Swipe detection is not supported in this environment."),{destroy(){},updateOptions(){}};var h={minDistance:null!==(a=null==n?void 0:n.minDistance)&&void 0!==a?a:30,maxDuration:null!==(i=null==n?void 0:n.maxDuration)&&void 0!==i?i:600,lockAxis:null===(r=null==n?void 0:n.lockAxis)||void 0===r||r,preventScrollOnSwipe:null!==(o=null==n?void 0:n.preventScrollOnSwipe)&&void 0!==o&&o,pointerTypes:null!==(s=null==n?void 0:n.pointerTypes)&&void 0!==s?s:["touch"],passiveListeners:null===(u=null==n?void 0:n.passiveListeners)||void 0===u||u,axisHint:null!==(l=null==n?void 0:n.axisHint)&&void 0!==l?l:"y",edgeLeakThreshold:null!==(d=null==n?void 0:n.edgeLeakThreshold)&&void 0!==d?d:24},c=e.style.touchAction;h.preventScrollOnSwipe&&(e.style.touchAction="none");var m=null,f=0,v=0,p=0,g=0,y=0,b=null,w=null,k=!1,S=!1,E=!1,M=e=>{try{var t=window.getComputedStyle(e);if(!t)return!1;var n=t.overflowY;if("auto"!==n&&"scroll"!==n)return!1;var a=e;return a.scrollHeight>a.clientHeight}catch(e){return!1}},P=e=>h.pointerTypes.includes(e.pointerType),T=t=>{var n=t.composedPath?t.composedPath()[0]:t.target;if(P(t)&&null===m){m=t.pointerId,f=p=t.clientX,v=g=t.clientY,y=performance.now(),b=null,E=!1,k=!1,S=!1,(w="y"===h.axisHint?((e,t)=>{for(var n=e;n&&n!==t&&n instanceof HTMLElement;){var a,i;if(M(n))return n;n=n.parentElement||(null!==(a=null===(i=n.parentNode)||void 0===i?void 0:i.host)&&void 0!==a?a:null)}return null})(n,e):null)||(S=!0);try{var a;null==e||null===(a=e.setPointerCapture)||void 0===a||a.call(e,t.pointerId)}catch(e){try{var i;null==n||null===(i=n.setPointerCapture)||void 0===i||i.call(n,t.pointerId)}catch(e){}}}},_=e=>{if(e.pointerId===m&&P(e)){if(p=e.clientX,g=e.clientY,h.lockAxis&&!b){var n=Math.abs(p-f),a=Math.abs(g-v);(n>2||a>2)&&(b=a>=n?"y":"x")}if("y"===h.axisHint&&("y"===b||!h.lockAxis)){var i=g-v,r=i<0?"up":"down",o=Math.abs(i),s=performance.now()-y,u=o/Math.max(s,1),l=o>=h.minDistance||u>.5;if(w)if(l)S=!0;else if(((e,t)=>!!e&&("down"===t?e.scrollTop>0:e.scrollTop+e.clientHeight<e.scrollHeight-1))(w,r)){if(!(("down"===r&&w.scrollTop<=50||"up"===r&&w.scrollTop+w.clientHeight>=w.scrollHeight-50)&&u>.3))return void(k=!0);S=!0}else S=!0;var d=!w||o>=h.edgeLeakThreshold;if(!E&&!k&&S&&d&&o>=h.minDistance){E=!0;var c=performance.now(),M={direction:"up"===r?"up":"down",distanceX:p-f,distanceY:i,absX:Math.abs(p-f),absY:o,duration:c-y,velocity:o/Math.max(c-y,1),startX:f,startY:v,endX:p,endY:g,startedAt:y,endedAt:c,originalEvent:e};t(M)}}}},D=e=>{if(e.pointerId===m)if(P(e))if(w)A();else if(E||k)A();else{var n,a=performance.now(),i=a-y,r=p-f,o=g-v,s=Math.abs(r),u=Math.abs(o),l="x"===(n=h.lockAxis&&b?b:"x"===h.axisHint?"x":"y"===h.axisHint?"y":s>=u?"x":"y")?s:u,d=i<=h.maxDuration,c=h.minDistance;if(w&&"y"===n&&S&&(c+=h.edgeLeakThreshold),d&&l>=c){var M;M="x"===n?r>0?"right":"left":o>0?"down":"up";var T=l/Math.max(i,1);t({direction:M,distanceX:r,distanceY:o,absX:s,absY:u,duration:i,velocity:T,startX:f,startY:v,endX:p,endY:g,startedAt:y,endedAt:a,originalEvent:e})}A()}else A()},A=()=>{m=null,b=null,y=0,w=null,S=!1,k=!1,E=!1},x=!!h.passiveListeners&&{passive:!0},C=h.passiveListeners?{passive:!0,capture:!0}:{capture:!0};e.addEventListener("pointerdown",T,C),e.addEventListener("pointermove",_,x),e.addEventListener("pointerup",D,x),e.addEventListener("pointercancel",D,x),e.addEventListener("lostpointercapture",D,x);return{destroy:()=>{e.removeEventListener("pointerdown",T,C),e.removeEventListener("pointermove",_,x),e.removeEventListener("pointerup",D,x),e.removeEventListener("pointercancel",D,x),e.removeEventListener("lostpointercapture",D,x),h.preventScrollOnSwipe&&(e.style.touchAction=c),A()},updateOptions:t=>{Object.assign(h,t),"boolean"==typeof t.preventScrollOnSwipe&&(t.preventScrollOnSwipe?e.style.touchAction="none":e.style.touchAction=c)}}}var zm,Bm,Hm,Um,Gm,Vm,Xm,Km,Ym,qm,Jm,Qm=e=>e,Zm=function(){function n(e,t,a){var i;return s(this,n),(i=o(this,n)).pages=[],i.currentOffset=0,i.presentationStyle="fullscreen",i.formFactor=uu(),i.timeSpentOnPaywall=0,i.animation={transition:"none",direction:"forward"},i._originalBodyStyles={},i._originalDocumentStyles={},i._savedScrollY=0,i._sheetDragStartY=0,i._sheetIsDragging=!1,i._dismissThreshold=100,i.type=e,i.value=t,i.context=a,i.setPaywallData(),w(i,i)}return g(n,e.LitElement),c(n,[{key:"setPaywallData",value:function(){var e=Pu(this.value,this.type);this.paywall=e.paywall,this.campaign=e.campaign}},{key:"getPresentationStyle",value:function(e){var t,n,a=null==e||null===(t=e.template)||void 0===t||null===(t=t.initialState)||void 0===t?void 0:t.presentation_style;return(n=a)&&cc.has(n)?"sheet"===n?"fullscreen":n:"fullscreen"}},{key:"isHalfSheet",get:function(){return"compact_sheet"===this.presentationStyle}},{key:"connectedCallback",value:function(){var e;T(n,"connectedCallback",this)([]),null!==(e=window.TVJS)&&void 0!==e&&e.DirectionalNavigation&&(window.TVJS.DirectionalNavigation.focusRoot=this),document.addEventListener("keydown",this.handleKeyDownEvent.bind(this)),this._swipeHandler=$m(this,this.handleSwipeEvent.bind(this),{axisHint:"y",lockAxis:!0,minDistance:25,edgeLeakThreshold:15,preventScrollOnSwipe:!1,pointerTypes:["touch"]}),this.presentationStyle=this.getPresentationStyle(this.paywall),this.setOriginalStyles()}},{key:"disconnectedCallback",value:function(){var e,t;T(n,"disconnectedCallback",this)([]),Kr.clearLaunchId(),null!==(e=window.TVJS)&&void 0!==e&&e.DirectionalNavigation&&(window.TVJS.DirectionalNavigation.focusRoot=document.body),document.removeEventListener("keydown",this.handleKeyDownEvent.bind(this)),ju.getInstance().removeAllListeners(kn),this.restoreStyles(),null===(t=this._halfSheetAbortController)||void 0===t||t.abort(),this._swipeHandler.destroy()}},{key:"setOriginalStyles",value:function(){"television"===this.formFactor&&(this._originalBodyStyles.overflow=document.body.style.overflow,document.body.style.overflow="hidden"),this._originalBodyStyles.background=document.body.style.background,"phone"===this.formFactor&&(this._originalBodyStyles["overscroll-behavior"]=document.body.style.overscrollBehavior?document.body.style.overscrollBehavior:null,this._originalDocumentStyles["overscroll-behavior"]=document.documentElement.style.overscrollBehavior?document.documentElement.style.overscrollBehavior:null,document.body.style.overscrollBehavior="none",document.documentElement.style.overscrollBehavior="none",this.isHalfSheet||(this._originalBodyStyles.overflow=document.body.style.overflow,document.body.style.overflow="hidden")),this.isHalfSheet&&(this._savedScrollY=window.scrollY,this._originalBodyStyles.position=document.body.style.position||null,this._originalBodyStyles.top=document.body.style.top||null,this._originalBodyStyles.width=document.body.style.width||null,document.body.style.position="fixed",document.body.style.top=`-${this._savedScrollY}px`,document.body.style.width="100%")}},{key:"restoreStyles",value:function(){Object.entries(this._originalBodyStyles).forEach((([e,t])=>{null!==t?document.body.style.setProperty(e,t):document.body.style.removeProperty(e)})),Object.entries(this._originalDocumentStyles).forEach((([e,t])=>{null!==t?document.documentElement.style.setProperty(e,t):document.documentElement.style.removeProperty(e)})),this._savedScrollY>0&&(window.scrollTo(0,this._savedScrollY),this._savedScrollY=0)}},{key:"handleKeyDownEvent",value:function(e){!this.flow||10009!==e.keyCode&&"Backspace"!==e.key&&"GoBack"!==e.key||this.flow.triggerActions(um)}},{key:"handleSwipeEvent",value:function({direction:e}){var t;if("down"===e)null===(t=this.flow)||void 0===t||t.triggerActions("__swipe_down__");else if("up"===e){var n;null===(n=this.flow)||void 0===n||n.triggerActions("__swipe_up__")}}},{key:"setupHalfSheetDragTracking",value:function(){var e,t,n;null===(e=this._halfSheetAbortController)||void 0===e||e.abort(),this._halfSheetAbortController=new AbortController;var a=this._halfSheetAbortController.signal,i=null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector(".nami-half-sheet-container"),r=null===(n=this.shadowRoot)||void 0===n?void 0:n.querySelector(".nami-half-sheet-content");if(i&&r){i.addEventListener("touchstart",(e=>{r.scrollTop>0||(this._sheetDragStartY=e.touches[0].clientY,this._sheetIsDragging=!0)}),{passive:!0,signal:a}),i.addEventListener("touchmove",(e=>{if(this._sheetIsDragging){var t=e.touches[0].clientY-this._sheetDragStartY;t>0&&(i.style.transform=`translateY(${t}px)`,i.style.transition="none",e.preventDefault())}}),{passive:!1,signal:a}),i.addEventListener("touchend",(()=>{if(this._sheetIsDragging){this._sheetIsDragging=!1;var e,t,n=i.style.transform.match(/translateY\((\d+(?:\.\d+)?)px\)/);if((n?parseFloat(n[1]):0)>this._dismissThreshold)if(null!==(e=null===(t=this.flow)||void 0===t?void 0:t.currentStepHasHoistedPrimaryActions("__swipe_down__"))&&void 0!==e&&e){var a;i.style.transform="translateY(0)",i.style.transition="transform 0.2s ease-out",null===(a=this.flow)||void 0===a||a.triggerActions("__swipe_down__")}else{var r;i.style.transform="translateY(100%)",i.style.transition="transform 0.2s ease-in";var o=null===(r=this.shadowRoot)||void 0===r?void 0:r.querySelector(".nami-half-sheet-backdrop");o&&o.classList.add("nami-dismissing"),setTimeout((()=>{var e;null===(e=this.flow)||void 0===e||e.finished()}),200)}else i.style.transform="translateY(0)",i.style.transition="transform 0.2s ease-out"}}),{signal:a})}}},{key:"setupHalfSheetFocusTrap",value:function(){var e,t,n=null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector(".nami-half-sheet-container");if(n){n.focus();var a=null===(t=this._halfSheetAbortController)||void 0===t?void 0:t.signal;n.addEventListener("keydown",(e=>{if("Tab"===e.key){var t=n.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');if(0!==t.length){var a,i,r=t[0],o=t[t.length-1];if(e.shiftKey)document.activeElement!==r&&(null===(a=this.shadowRoot)||void 0===a?void 0:a.activeElement)!==r||(e.preventDefault(),o.focus());else document.activeElement!==o&&(null===(i=this.shadowRoot)||void 0===i?void 0:i.activeElement)!==o||(e.preventDefault(),r.focus())}}}),a?{signal:a}:void 0)}}},{key:"firstUpdated",value:function(){this.timeSpentOnPaywall=Date.now(),Os(this.campaign)&&(this.flow=Nm.instance.presentFlow(this.campaign,this,this.context)),this.isHalfSheet&&this.updateComplete.then((()=>{this.setupHalfSheetDragTracking(),this.setupHalfSheetFocusTrap()}))}},{key:"updated",value:function(e){T(n,"updated",this)([e]),this.isHalfSheet&&e.has("presentationStyle")&&(this.setupHalfSheetDragTracking(),this.setupHalfSheetFocusTrap())}},{key:"getAnimationStyles",value:function(e){var t="backward"===this.animation.direction?-1:1;switch(this.animation.transition){case"verticalSlide":return`transform: translateY(${100*(e-this.currentOffset)*t}vh);`;case"slide":return`transform: translateX(${100*(e-this.currentOffset)*t}vw);`;case"fade":return`opacity: ${e===this.currentOffset?1:0};`;default:return""}}},{key:"updatePages",value:function(e){var t;return S((function(n){for(;;)switch(n.n){case 0:if(0!==this.pages.length&&"none"!==this.animation.transition){n.n=1;break}return this.pages=[e],n.a(2);case 1:if((null==(t=this.pages[this.pages.length-1])?void 0:t.id)!==e.id){n.n=2;break}return n.a(2);case 2:return this.pages=[t,e],this.currentOffset=0,n.n=3,r(this.updateComplete);case 3:requestAnimationFrame((()=>{this.currentOffset=1,setTimeout((()=>{this.pages=[e],this.currentOffset=0,this.paywall=e}),250)}));case 4:return n.a(2)}}),null,this,null,Promise)}},{key:"flowNavigateToScreen",value:function(e,t){var n,a,i,o;return S((function(s){for(;;)switch(s.n){case 0:if(null!==(n=this.flow)&&void 0!==n&&n.previousFlowStep&&this.flow.executeLifecycle(this.flow.previousFlowStep,nm),i=this.presentationStyle,o=this.getPresentationStyle(e),"fullscreen"!==i||"compact_sheet"!==o){s.n=1;break}console.warn("Unsupported transition: fullscreen → compact_sheet. Presenting as fullscreen."),s.n=4;break;case 1:if("compact_sheet"!==i||"fullscreen"!==o&&"sheet"!==o){s.n=3;break}return s.n=2,r(this.animateHalfSheetExpand());case 2:this.presentationStyle="fullscreen",s.n=4;break;case 3:this.presentationStyle=o;case 4:return this.animation=t,s.n=5,r(this.updatePages(e));case 5:null!==(a=this.flow)&&void 0!==a&&a.currentFlowStep&&this.flow.executeLifecycle(this.flow.currentFlowStep,tm);case 6:return s.a(2)}}),null,this,null,Promise)}},{key:"animateHalfSheetExpand",value:function(){var e,t;return S((function(n){for(;;)switch(n.n){case 0:if(t=null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector(".nami-half-sheet-container")){n.n=1;break}return n.a(2);case 1:return t.classList.add("nami-expanding"),n.n=2,r(new Promise((e=>setTimeout(e,300))));case 2:return n.a(2)}}),null,this,null,Promise)}},{key:"getSelectedSlideIndexForCurrentCarousel",value:function(){return Xh.getSelectedSlideIndex()}},{key:"renderFlow",value:function(){return"undefined"==typeof document?e.html(zm||(zm=Qm``)):this.isHalfSheet?this.renderHalfSheet():e.html(Bm||(Bm=Qm`
92
92
  <div class="nami-flow-container">
93
93
  ${0}
94
94
  </div>
package/dist/nami-web.mjs CHANGED
@@ -88,7 +88,7 @@ import{css as e,html as t,LitElement as n,unsafeCSS as i,svg as a}from"lit";impo
88
88
  padding-top: 0;
89
89
  padding-bottom: 0;
90
90
  }
91
- `)),Sc=e=>(t,n)=>{void 0!==n?n.addInitializer((()=>{customElements.define(e,t)})):customElements.define(e,t)},Ec=globalThis,Mc=Ec.ShadowRoot&&(void 0===Ec.ShadyCSS||Ec.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Pc=Symbol(),Tc=new WeakMap,_c=function(){return p((function e(t,n,i){if(h(this,e),this._$cssResult$=!0,i!==Pc)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(Mc&&void 0===e){var n=void 0!==t&&1===t.length;n&&(e=Tc.get(t)),void 0===e&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),n&&Tc.set(t,e))}return e}},{key:"toString",value:function(){return this.cssText}}])}(),Dc=(e,t)=>{if(Mc)e.adoptedStyleSheets=t.map((e=>e instanceof CSSStyleSheet?e:e.styleSheet));else for(var n,i=g(t);!(n=i()).done;){var a=n.value,r=document.createElement("style"),o=Ec.litNonce;void 0!==o&&r.setAttribute("nonce",o),r.textContent=a.cssText,e.appendChild(r)}},Ac=Mc?e=>e:e=>e instanceof CSSStyleSheet?(e=>{for(var t,n="",i=g(e.cssRules);!(t=i()).done;){n+=t.value.cssText}return(e=>new _c("string"==typeof e?e:e+"",void 0,Pc))(n)})(e):e,xc=Object.is,Cc=Object.defineProperty,Ic=Object.getOwnPropertyDescriptor,Lc=Object.getOwnPropertyNames,Fc=Object.getOwnPropertySymbols,Rc=Object.getPrototypeOf,Wc=globalThis,Oc=Wc.trustedTypes,Nc=Oc?Oc.emptyScript:"",jc=Wc.reactiveElementPolyfillSupport,$c=(e,t)=>e,zc={toAttribute(e,t){switch(t){case Boolean:e=e?Nc: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}},Bc=(e,t)=>!xc(e,t),Hc={attribute:!0,type:String,converter:zc,reflect:!1,useDefault:!1,hasChanged:Bc};null!==(yc=Symbol.metadata)&&void 0!==yc||(Symbol.metadata=Symbol("metadata")),null!==(bc=Wc.litPropertyMetadata)&&void 0!==bc||(Wc.litPropertyMetadata=new WeakMap);var Uc=function(){function e(){var t;return h(this,e),(t=d(this,e))._$Ep=void 0,t.isUpdatePending=!1,t.hasUpdated=!1,t._$Em=null,t._$Ev(),t}return k(e,I(HTMLElement)),p(e,[{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=g(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 Dc(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:zc).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:zc;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){if(void 0!==e){var i,a,r=this.constructor,o=this[e];if(null!=n||(n=r.getPropertyOptions(e)),!((null!==(i=n.hasChanged)&&void 0!==i?i:Bc)(o,t)||n.useDefault&&n.reflect&&o===(null===(a=this._$Ej)||void 0===a?void 0:a.get(e))&&!this.hasAttribute(r._$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 T((function(n){for(;;)switch(n.p=n.n){case 0:return this.isUpdatePending=!0,n.p=1,n.n=2,l(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,l(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=g(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=g(o);!(s=u()).done;){var l=s.value,d=l[0],h=l[1],c=h.wrapped,m=this[d];!0!==c||this._$AL.has(d)||void 0===m||this.C(d,void 0,h,m)}}var f=!1,v=this._$AL;try{var p;(f=this.shouldUpdate(v))?(this.willUpdate(v),null!==(p=this._$EO)&&void 0!==p&&p.forEach((e=>{var t;return null===(t=e.hostUpdate)||void 0===t?void 0:t.call(e)})),this.update(v)):this._$EM()}catch(v){throw f=!1,this._$EM(),v}f&&this._$AE(v)}}},{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=Hc){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&&Cc(this.prototype,e,i)}}},{key:"getPropertyDescriptor",value:function(e,t,n){var i,a=null!==(i=Ic(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:Hc}},{key:"_$Ei",value:function(){if(!this.hasOwnProperty($c("elementProperties"))){var e=Rc(this);e.finalize(),void 0!==e.l&&(this.l=[...e.l]),this.elementProperties=new Map(e.elementProperties)}}},{key:"finalize",value:function(){if(!this.hasOwnProperty($c("finalized"))){if(this.finalized=!0,this._$Ei(),this.hasOwnProperty($c("properties")))for(var e=this.properties,t=0,n=[...Lc(e),...Fc(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=g(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 h,c=g(this.elementProperties);!(h=c()).done;){var m=h.value,f=m[0],v=m[1],p=this._$Eu(f,v);void 0!==p&&this._$Eh.set(p,f)}this.elementStyles=this.finalizeStyles(this.styles)}}},{key:"finalizeStyles",value:function(e){var t=[];if(Array.isArray(e))for(var n,i=g(new Set(e.flat(1/0).reverse()));!(n=i()).done;){var a=n.value;t.unshift(Ac(a))}else void 0!==e&&t.push(Ac(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}}])}();Uc.elementStyles=[],Uc.shadowRootOptions={mode:"open"},Uc[$c("elementProperties")]=new Map,Uc[$c("finalized")]=new Map,null!=jc&&jc({ReactiveElement:Uc}),(null!==(wc=Wc.reactiveElementVersions)&&void 0!==wc?wc:Wc.reactiveElementVersions=[]).push("2.1.1");var Gc={attribute:!0,type:String,converter:zc,reflect:!1,hasChanged:Bc},Vc=(e=Gc,t,n)=>{var i=n.kind,a=n.metadata,r=globalThis.litPropertyMetadata.get(a);if(void 0===r&&globalThis.litPropertyMetadata.set(a,r=new Map),"setter"===i&&((e=Object.create(e)).wrapped=!0),r.set(n.name,e),"accessor"===i){var o=n.name;return{set(n){var i=t.get.call(this);t.set.call(this,n),this.requestUpdate(o,i,e)},init(t){return void 0!==t&&this.C(o,void 0,e,t),t}}}if("setter"===i){var s=n.name;return function(n){var i=this[s];t.call(this,n),this.requestUpdate(s,i,e)}}throw Error("Unsupported decorator location: "+i)};function Xc(e){return(t,n)=>"object"==typeof n?Vc(e,t,n):((e,t,n)=>{var i=t.hasOwnProperty(n);return t.constructor.createProperty(n,e),i?Object.getOwnPropertyDescriptor(t,n):void 0})(e,t,n)}function Kc(e){return Xc(y({},e,{state:!0,attribute:!1}))}function Yc(e){return!e||"object"==typeof e&&0==Object.keys(e).length}var qc,Jc="entry",Qc="screen",Zc="branch",em="exit",tm="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.PAUSE="flowPause",e.RESUME="flowResume"}(qc||(qc={}));var nm="__handoff_sequence__",im="__buy_sku__",am="__default__",rm="__appear__",om="__disappear__",sm="__login_success__",um="__login_failure__",lm="__logout_success__",dm="__logout_failure__",hm="__purchase_success__",cm="__remoteback__",mm="__tag_update__",fm="and",vm="or",pm="i_contains",gm="equals",ym="i_equals",bm="not_equals",wm="not_i_equals",km="not_contains",Sm="set",Em="notSet",Mm=function(){function e(){h(this,e),this.resolvers=new Map,this.namespaceResolvers=new Map}return p(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 fm:return i.every((e=>e));case vm: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 fm:for(var i,a=g(n);!(i=a()).done;){var r=i.value;if(!this.evaluateFilter(r))return!1}return!0;case vm:for(var o,s=g(n);!(o=s()).done;){var u=o.value;if(this.evaluateFilter(u))return!0}return!1;default:for(var l,d=g(n);!(l=d()).done;){var h=l.value;if(!this.evaluateFilter(h))return!1}return!0}}},{key:"evaluateFilter",value:function(e){var t=this.resolve(e.identifier);if(e.operator===Sm)return null!=t;if(e.operator===Em)return null==t;if(null==t)return!![bm,wm,km].includes(e.operator);switch(e.operator){case pm:return Array.isArray(t)?e.values.some((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 gm:return e.values.some((e=>{if("string"==typeof t)return t===e;if("boolean"==typeof t){var n="true"===e.toLowerCase();return t===n}return this.log("Unsupported type for equals comparison: "+typeof t),!1}));case ym:return e.values.some((e=>{if("string"==typeof t)return 0===t.localeCompare(e,void 0,{sensitivity:"accent"});if("boolean"==typeof t){var n="true"===e.toLowerCase();return t===n}return this.log("Unsupported type for i_equals comparison: "+typeof t),!1}));case bm:return e.values.every((e=>"string"!=typeof t||t!==e));case wm:return e.values.every((e=>"string"!=typeof t||0!==t.localeCompare(e,void 0,{sensitivity:"accent"})));case km:return e.values.every((e=>"string"!=typeof t||!t.includes(e)));default:return this.log(`Unsupported operator: ${e.operator}`),!1}}},{key:"resolve",value:function(e){var t=this.resolveRaw(e);if(void 0!==t)return t;var n=e.lastIndexOf(".");if(-1!==n){var i=e.slice(0,n),a=e.slice(n+1),r=this.resolveRaw(i);return void 0!==r?this.extractProperty(a,r):void 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=g(n);!(t=i()).done;){var a=t.value;if(e.startsWith(a)){var r=this.namespaceResolvers.get(a);if(r)return r(e)}}}},{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){$n.debug(`[NamiConditionEvaluator] ${e}`)}}],[{key:"shared",get:function(){return e.instance||(e.instance=new e),e.instance}}])}(),Pm=function(){return p((function e(){h(this,e)}),[{key:"register",value:function(){Mm.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=g(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}}])}(),Tm=function(){function e(t){var n;return h(this,e),(n=d(this,e)).namespace="LaunchContext",n.context=t,n.register(),n}return k(e,Pm),p(e,[{key:"resolveValue",value:function(e){if(e.startsWith("customAttributes.")){var t=e.substring(17);return this.resolveKeyPath(t,this.context.customAttributes)}if(e.startsWith("customObject.")){var n=e.substring(13);return this.resolveKeyPath(n,this.context.customObject)}return this.resolveKeyPath(e,{customAttributes:this.context.customAttributes,customObject:this.context.customObject,productGroups:this.context.productGroups})}}])}(),_m=function(){function e(){var t,n,i,a;h(this,e),(a=d(this,e)).namespace="Device";var r=Intl.DateTimeFormat().resolvedOptions().locale.split("-")[1]||"",o=Intl.DateTimeFormat().resolvedOptions().timeZone,s=hu();return a.context={osName:s.os_name,osVersion:s.os_version,appVersion:s.extended_platform_version,sdkVersion:s.sdk_version,deviceModel:s.device_model,screenWidth:window.innerWidth,screenHeight:window.innerHeight,formFactor:s.form_factor,tvQuality:a.tvQuality(null!==(t=s.form_factor)&&void 0!==t?t:"desktop"),tvResolution:a.tvResolution(null!==(n=s.form_factor)&&void 0!==n?n:"desktop"),screenSize:a.screenSizeTier(null!==(i=s.form_factor)&&void 0!==i?i:"desktop"),language:s.language,country:r,timezone:o},a.register(),a}return k(e,Pm),p(e,[{key:"screenSizeTier",value:function(e){var t=window.screen.width,n=window.screen.height,i=window.devicePixelRatio||1,a=Math.round(t*i),r=Math.round(n*i),o=Math.max(a,r);switch(e){case"phone":return o<1136?"tiny":o<1334?"small":o<1920?"medium":o<2560?"large":"huge";case"tablet":return o<2048?"medium":o<2732?"large":"huge";case"television":return o<1920?"medium":o<3840?"large":"huge";case"desktop":return o<1440?"small":o<2560?"medium":o<3840?"large":"huge";default:return"medium"}}},{key:"tvQuality",value:function(e){if("television"!==e)return"";var t=window.screen.width,n=window.screen.height,i=window.devicePixelRatio||1,a=Math.round(t*i),r=Math.round(n*i),o=Math.max(a,r),s=Math.min(a,r);return o>=3840||s>=2160?"4K":o>=1920||s>=1080?"1080p":"720p"}},{key:"tvResolution",value:function(e){if("television"!==e)return"";var t=window.screen.width,n=window.screen.height,i=window.devicePixelRatio||1,a=Math.round(t*i),r=Math.round(n*i),o=Math.max(a,r),s=Math.min(a,r);return s<720&&o<1280?"SD":s>=720&&s<1080&&o>=1280&&o<1920?"720p":s>=1080&&s<1440&&o>=1920&&o<2560?"1080p":s>=1440&&s<2160&&o>=2560&&o<3840?"1440p":s>=2160&&s<3e3&&o>=3840&&o<5e3?"4K":s>=3e3&&o>=5e3?"8K":"Unknown"}},{key:"resolveValue",value:function(e){return this.resolveKeyPath(e,this.context)}}])}(),Dm=[/(^|_)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],Am=function(){function e(){h(this,e),this.params={},"undefined"!=typeof window&&this.setSearchParams()}return p(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=>Dm.some((t=>t.test(e))))(a))){var r=this.safeValue(i);r&&(t[a]=r,n.add(a))}},o=g(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()}}])}();Am._instance=null;var xm,Cm=()=>Am.instance.params,Im=/\{\{\s*([^}]+?)\s*\}\}/g,Lm=function(){return p((function e(t){h(this,e),this.flowManager=t,this.urlParams=Cm()}),[{key:"resolve",value:function(e){var t,n,i,a,r,o,s,u,l,d,h,c,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 Tm(p).resolveValue(g);return null==y?void 0:y.toString()}}else 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===(h=m.currentFlowStep)||void 0===h?void 0:h.name;case"buttonText":return null==m||null===(c=m.currentButton)||void 0===c?void 0:c.firstTextValue();case"slideNumber":var b=null==f?void 0:f.getSelectedSlideIndexForCurrentCarousel();return null!=b?`${b+1}`:void 0;default:return}}},{key:"interpolateLiquidVariables",value:function(e){return e.replace(Im,((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])=>y({},e,{[t]:this.interpolateDeep(n)})),{}):e}}])}(),Fm=function(){function e(){var t;return h(this,e),(t=d(this,e)).namespace="urlParams",t.context=Cm(),t.register(),t}return k(e,Pm),p(e,[{key:"resolveValue",value:function(e){return $n.debug("[URLParamsResolver]","Resolving keyPath",e),this.resolveKeyPath(e,this.context)}}])}(),Rm=function(){function e(){var t;return h(this,e),(t=d(this,e)).namespace="state",t.register(),t}return k(e,Pm),p(e,[{key:"getContextProvider",value:function(){var e=Jh.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)}}}])}(),Wm=function(){function e(t){var n;return h(this,e),(n=d(this,e)).namespace="Placement",n.campaign=t,n.register(),n}return k(e,Pm),p(e,[{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=Jh.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()}}}}])}(),Om=function(){return p((function e(){h(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?Qr.setNamiProfile({externalId:this.externalId}):Qr.removeNamiProfile(),this}},{key:"load",value:function(){var e=Qr.getNamiProfile();e&&(this.externalId=e.externalId),Jh.setIsLoggedIn(!!this.externalId)}},{key:"login",value:function(e){var t;return T((function(n){for(;;)switch(n.n){case 0:return n.n=1,l(zs.instance.login(e));case 1:(t=n.v).external_id&&Jh.setIsLoggedIn(!0),this.setExternalId(t.external_id).save();case 2:return n.a(2)}}),null,this,null,Promise)}},{key:"logout",value:function(){return T((function(e){for(;;)switch(e.n){case 0:return e.n=1,l(zs.instance.logout());case 1:Jh.setIsLoggedIn(!1),this.setExternalId(void 0).save();case 2:return e.a(2)}}),null,this,null,Promise)}}])}();Om.instance=new Om,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"}(xm||(xm={}));var Nm=function(){return p((function e(){h(this,e),this.emitter=Hu.getInstance(),Mm.shared.registerNamespaceResolver("UserTags",(t=>{var n=t.replace("UserTags.",""),i=e.getCustomerAttribute(n);if(null!=i){var a=i.toLowerCase();return"true"===a||"false"===a?"true"===a:isNaN(Number(i))?i:parseInt(i,10)}return null}))}),[{key:"isSDKInitialized",get:function(){return fc.instance.isInitialized}}],[{key:"isLoggedIn",value:function(){return Om.instance.isLoggedIn()}},{key:"loggedInId",value:function(){return this.instance.isSDKInitialized||$n.debug(Pe),Om.instance.getExternalId()}},{key:"login",value:function(e){var t,n,i,a,r,o,s;return T((function(u){for(;;)switch(u.p=u.n){case 0:if(this.instance.isSDKInitialized){u.n=1;break}throw t=new no,this.invokeStateHandler(xm.LOGIN,!1,t),t;case 1:if(!this.inAnonymousMode()){u.n=2;break}throw n=new ho,this.invokeStateHandler(xm.LOGIN,!1,n),n;case 2:return u.p=2,u.n=3,l(Om.instance.login(e));case 3:return u.n=4,l(nc.instance.fetchActiveEntitlements());case 4:this.invokeStateHandler(xm.LOGIN,!0),zm.instance.flowOpen&&(i=zm.instance.currentFlow,(a=null==i?void 0:i.currentFlowStep)&&i.executeLifecycle(a,sm)),u.n=6;break;case 5:throw u.p=5,s=u.v,this.invokeStateHandler(xm.LOGIN,!1,s),zm.instance.flowOpen&&(r=zm.instance.currentFlow,(o=null==r?void 0:r.currentFlowStep)&&r.executeLifecycle(o,um)),s;case 6:return u.a(2)}}),null,this,[[2,5]],Promise)}},{key:"logout",value:function(){var e,t,n,i,a,r,o;return T((function(s){for(;;)switch(s.p=s.n){case 0:if(this.instance.isSDKInitialized){s.n=1;break}throw e=new no,this.invokeStateHandler(xm.LOGOUT,!1,e),e;case 1:if(!this.inAnonymousMode()){s.n=2;break}throw t=new ho,this.invokeStateHandler(xm.LOGOUT,!1,t),t;case 2:return s.p=2,s.n=3,l(Om.instance.logout());case 3:return s.n=4,l(nc.instance.fetchActiveEntitlements());case 4:this.invokeStateHandler(xm.LOGOUT,!0),zm.instance.flowOpen&&(n=zm.instance.currentFlow,(i=null==n?void 0:n.currentFlowStep)&&n.executeLifecycle(i,lm)),s.n=6;break;case 5:throw s.p=5,o=s.v,this.invokeStateHandler(xm.LOGOUT,!1,o),zm.instance.flowOpen&&(a=zm.instance.currentFlow,(r=null==a?void 0:a.currentFlowStep)&&a.executeLifecycle(r,dm)),o;case 6:return s.a(2)}}),null,this,[[2,5]],Promise)}},{key:"setCustomerDataPlatformId",value:function(e){return T((function(t){for(;;)switch(t.n){case 0:return t.n=1,l(this.updateCustomerDataPlatformId(e));case 1:return t.a(2)}}),null,this,null,Promise)}},{key:"clearCustomerDataPlatformId",value:function(){return T((function(e){for(;;)switch(e.n){case 0:return e.n=1,l(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,a,r;return T((function(o){for(;;)switch(o.n){case 0:if(t=e?xm.ANONYMOUS_MODE_ON:xm.ANONYMOUS_MODE_OFF,this.instance.isSDKInitialized){o.n=1;break}throw n=new no,this.invokeStateHandler(t,!1,n),n;case 1:if(this.anonymousModeCapability()){o.n=2;break}return $n.warn("Anonymous mode feature is not enabled for your Nami account. Contact support@nami.ml for details."),o.a(2);case 2:if(this.inAnonymousMode()!==e){o.n=3;break}return i=e?new uo:new lo,this.invokeStateHandler(t,!1,i),o.a(2);case 3:if(!e){o.n=4;break}Qr.setAnonymousMode(e),Qr.resetDevice(),this.refetchConfig(),this.invokeStateHandler(xm.ANONYMOUS_MODE_ON,!0),o.n=6;break;case 4:return Qr.clearAnonymousMode(),r=null===(a=Qr.getNamiConfig())||void 0===a?void 0:a.namiCommands,o.n=5,l(Vu.instance.createOrUpdateDevice(hu(r)));case 5:Qr.clearAnonymousUUID(),this.refetchConfig(),this.invokeStateHandler(xm.ANONYMOUS_MODE_OFF,!0);case 6:return o.a(2)}}),null,this,null,Promise)}},{key:"inAnonymousMode",value:function(){return!!this.instance.isSDKInitialized&&Ju()}},{key:"setCustomerAttribute",value:function(e,t){if(!this.instance.isSDKInitialized)throw new no;if(Qr.setCustomerAttribute(e,t),Rs(me.PAYWALL_PERSONALIZATION)?(Jh.setCustomerAttribute({[e]:t}),$n.debug(`This customer attribute you set is now available for paywall personalization using the smart text variable: ${e}`)):$n.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.`),zm.instance.flowOpen){var n=zm.instance.currentFlow;if(n){var i=n.currentFlowStep;i&&n.executeLifecycle(i,mm)}}}},{key:"getCustomerAttribute",value:function(e){if(!this.instance.isSDKInitialized)throw new no;var t=Qr.getCustomerAttribute(e);return null!=t?Rs(me.PAYWALL_PERSONALIZATION)?$n.debug(`Found customer attribute. ${e} is available for paywall personalization on this device.`):$n.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.`):$n.warn(`No ${e} customer attribute found.`),t}},{key:"getAllCustomerAttributes",value:function(){if(!this.instance.isSDKInitialized)throw new no;return Qr.getAllCustomerAttributes()}},{key:"clearCustomerAttribute",value:function(e){if(!this.instance.isSDKInitialized)throw new no;Qr.clearCustomerAttribute(e)?(Jh.removeCustomerAttribute(e),$n.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.`)):$n.warn(`No value to clear for attribute ${e}.`)}},{key:"clearAllCustomerAttributes",value:function(){if(!this.instance.isSDKInitialized)throw new no;Qr.getAllCustomerAttributesKeys().forEach((e=>{Jh.removeCustomerAttribute(e)})),Qr.clearAllCustomerAttributes(),$n.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 no;return Qr.getCustomerJourneyState()}},{key:"deviceId",value:function(){var e,t;return this.instance.isSDKInitialized&&null!==(e=null===(t=Qr.getDevice())||void 0===t?void 0:t.id)&&void 0!==e?e:Oe}},{key:"registerJourneyStateHandler",value:function(e){if(Ws("NamiCustomerManager.registerJourneyStateHandler"))return this.instance.emitter.addListener(An,e),()=>{this.instance.emitter.removeListener(An,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,a;return T((function(r){for(;;)switch(r.p=r.n){case 0:if(this.instance.isSDKInitialized){r.n=1;break}throw t=new no,this.invokeStateHandler(xm.CUSTOMER_DATA_PLATFORM_ID_SET,!1,t),t;case 1:if(this.inAnonymousMode()){r.n=6;break}return r.p=2,r.n=3,l(Vu.instance.updateDeviceField("customer_data_platform_id",e));case 3:this.invokeStateHandler(xm.CUSTOMER_DATA_PLATFORM_ID_SET,!0),r.n=5;break;case 4:r.p=4,a=r.v,this.invokeStateHandler(xm.CUSTOMER_DATA_PLATFORM_ID_SET,!1,a);case 5:r.n=7;break;case 6:return $n.info("Unable to set CDP ID in anonymous mode",{deviceId:null===(n=Qr.getDevice())||void 0===n?void 0:n.id,anonymousMode:!0}),i=new co,this.invokeStateHandler(xm.CUSTOMER_DATA_PLATFORM_ID_SET,!1,i),r.a(2);case 7:return r.a(2)}}),null,this,[[2,4]],Promise)}},{key:"anonymousModeCapability",value:function(){if(!this.instance.isSDKInitialized)return!1;var e=Rs(me.ANONYMOUS_MODE_CAPABILITY),t=Rs(me.THIRD_PARTY_TRANSACTIONS);return e&&t}},{key:"refetchConfig",value:function(){return T((function(e){for(;;)switch(e.n){case 0:if(!this.instance.isSDKInitialized){e.n=1;break}return e.n=1,l(Promise.all([Xu.instance.fetchProducts(),Ku.instance.fetchPaywalls().then((e=>Uu.instance.fetchCampaignRules(e)))]));case 1:return e.a(2)}}),null,this,null,Promise)}}])}();Nm.instance=new Nm;var jm=function(){return p((function e(t={}){var n,i,a,r,o;h(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!==(o=t.transition)&&void 0!==o?o:"none"}),[{key:"allScreensAvailable",get:function(){return this.screens.length>0&&Xs(this.screens)}}])}(),$m=function(){function e(t,n,i,a){var r,o;h(this,e),(o=d(this,e,[null!==(r=t.flow.object)&&void 0!==r?r:{}])).stepcrumbs=[],o.branchcrumbs=[],o.activeHandoffSequence=null,o.currentScreenState=null,o.isPaused=!1,o.timerStates={},o.campaign=t,o.component=n,o.context=a,o.manager=i,o.branchcrumbs=[],o.stepcrumbs=[],o.registerResolvers(a);var s=o.findStepByType(Jc);return s&&o.forward(s.id),o}return k(e,jm),p(e,[{key:"registerResolvers",value:function(e){e&&new Tm(e),new _m,new Fm,new Rm,new Wm(this.campaign),Mm.shared.registerNamespaceResolver("Flow",(e=>{switch(e){case"Flow.stepcrumbs":return this.stepcrumbs.map((e=>e.id));case"Flow.branchcrumbs":return this.branchcrumbs;default:return}}))}},{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:"finished",value:function(){this.manager.finishFlow()}},{key:"back",value:function(){this.previousStepAvailable?this.backToPreviousScreenStep():$n.debug("No previous step available")}},{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=Vs(n.screen);return r&&this.component.flowNavigateToScreen(r,{transition:this.transition,direction:"backward"}),void(this.currentScreenState=null!==(i=null===(a=Jh.currentProvider)||void 0===a?void 0:a.state)&&void 0!==i?i:null)}}$n.warn("No previous screen step found to return to")}else $n.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(t.type){case Jc:case em:return this.stepcrumbs.push(t),void this.executeLifecycle(t,am);case Zc:return void this.handleBranchStep(t);case Qc:return void this.handleScreenStep(t);case tm:return}}else $n.error(`No step found with id: ${e}`)}},{key:"pause",value:function(){var e;this.isPaused?$n.info("Flow is already paused"):(this.isPaused=!0,this.pausedStepID=null===(e=this.currentFlowStep)||void 0===e?void 0:e.id,$n.info("Flow paused"))}},{key:"resumeFromPause",value:function(){if(this.isPaused)if(this.isPaused=!1,this.pausedStepID){var e=this.pausedStepID;this.pausedStepID=void 0,$n.info(`Flow resumed from step ${e}`),this.forward(e)}else $n.warn("No step to resume from");else $n.info("Flow is not paused")}},{key:"executeLifecycle",value:function(e,t,n){var i=e.actions[t];i&&this.executeFullLifecycles(i,n)}},{key:"lifecycles",value:function(e){if(this.currentFlowStep){var t=this.currentFlowStep.actions[e];if(t)return t;$n.info(`No actions found for button ${e} on step ${this.currentFlowStep.id}`)}}},{key:"triggerActions",value:function(e,t,n){var i=this.lifecycles(e);i&&(this.currentButton=t,this.executeFullLifecycles(i,n))}},{key:"executeFullLifecycles",value:function(e,t){for(var n,i=g(e);!(n=i()).done;){var a=n.value;[a.before,a.action,a.after].forEach((e=>null==e?void 0:e.forEach((e=>this.shouldRun(e)&&this.performAction(e,t)))))}}},{key:"triggerBeforeActions",value:function(e,t,n){var i=this.lifecycles(e);if(i){this.currentButton=t;for(var a,r=g(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=g(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){return!e.conditions||e.conditions.every((e=>Mm.shared.evaluate(e)))}},{key:"performAction",value:function(e,t){var n;if(this.currentFlowStep){var i=(null!==(n=e.parameters)&&void 0!==n&&n.delay?+e.parameters.delay:0)||0,a=n=>{var i,a,r,o,s,u,l;if((null===(i=this.currentFlowStep)||void 0===i?void 0:i.id)===n)switch(e.function){case qc.BACK:this.back();break;case qc.NEXT:null!==(a=e.parameters)&&void 0!==a&&a.step?this.forward(e.parameters.step):this.next();break;case qc.NAVIGATE:var d;if(null!==(r=e.parameters)&&void 0!==r&&r.step)(null===(d=this.previousFlowStep)||void 0===d?void 0:d.id)===e.parameters.step?this.back():this.forward(e.parameters.step);else this.next();break;case qc.FINISHED:case qc.DISMISS:this.finished();break;case qc.EXIT:var h=this.steps.find((e=>e.type===em));h&&this.forward(h.id);break;case qc.PAUSE:this.pause();break;case qc.RESUME:this.resumeFromPause();break;case qc.HANDOFF:if(null!==(o=e.parameters)&&void 0!==o&&o.handoffTag)if(this.manager.handoffStepHandler)if(e.parameters.handoffData)$n.debug(`Invoking handoffStepHandler with ${e.parameters.handoffTag} ${JSON.stringify(e.parameters.handoffData)}`),this.manager.handoffStepHandler(e.parameters.handoffTag,e.parameters.handoffData);else if(t)$n.debug(`Invoking handoffStepHandler with ${e.parameters.handoffTag} ${JSON.stringify(t)}`),this.manager.handoffStepHandler(e.parameters.handoffTag,t);else if(e.parameters.handoffFormId){var c=this.getFormData();e.parameters.handoffTag===nm?this.flowHandoffFormSequence():this.manager.handoffStepHandler(e.parameters.handoffTag,c)}else $n.debug(`Invoking handoffStepHandler with ${e.parameters.handoffTag} and no data`),this.manager.handoffStepHandler(e.parameters.handoffTag);else $n.debug("No handoffStepHandler found",e);break;case qc.LOG:var m;if(null!==(s=e.parameters)&&void 0!==s&&s.eventName)$n.info(`logEvent → ${e.parameters.eventName}`);else $n.warn(`Missing 'eventName' in logEvent action ${null!==(m=e.id)&&void 0!==m?m:"unknown"}`);break;case qc.TRACK:var f;if(null!==(u=e.parameters)&&void 0!==u&&u.eventName)$n.info(`trackEvent → ${e.parameters.eventName}`);else $n.warn(`Missing 'eventName' in logEvent action ${null!==(f=e.id)&&void 0!==f?f:"unknown"}`);break;case qc.SET_VIDEO:null!==(l=e.parameters)&&void 0!==l&&l.name&&e.parameters.url?Jh.setAppSuppliedVideoDetails({name:e.parameters.name,url:e.parameters.url}):$n.warn("Missing name, url for setting video details");break;case qc.BLOCK_BACK:var v,p=null===(v=e.parameters)||void 0===v?void 0:v.step,g=p?this.getStep(p):void 0;g?g.allow_back_to=!1:this.currentFlowStep?this.currentFlowStep.allow_back_to=!1:$n.warn("Missing step for blocking back");break;case qc.FLOW_EVENT:var y,b=new Lm(this.manager),w=Object.fromEntries(Object.entries(null!==(y=e.parameters)&&void 0!==y?y:{}).map((([e,t])=>[e,b.interpolateDeep(t)])));this.manager.eventHandler?this.manager.eventHandler(w):$n.warn("Missing event handler",w);break;case qc.FLOW_ENABLED:Jh.setUserInteractionEnabled(!0);break;case qc.FLOW_DISABLED:Jh.setUserInteractionEnabled(!1);break;case qc.SET_TAGS:e.parameters&&(Jh.setUserTags(e.parameters),Object.entries(e.parameters).forEach((([e,t])=>{Nm.setCustomerAttribute(e,t)})));break;default:$n.warn(`Missing action handler for ${e.function}`,e)}else $n.debug(`Skipped action for stale flow step ${n}`)};i?setTimeout(a.bind(this,this.currentFlowStep.id),i):a(this.currentFlowStep.id)}else $n.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=g(this.steps.slice(t+1));!(n=i()).done;){var a=n.value;if(this.isStepActive(a))return a}$n.debug(`No active next step found after ${e.id}`)}else $n.error(`Could not find next step for step ${e.id}`)}else $n.error("Next step not found")}},{key:"handleScreenStep",value:function(e){var t,n=Vs(null!==(t=e.screen)&&void 0!==t?t:"");e.screen&&n&&this.campaign?(this.stepcrumbs.push(e),this.component.flowNavigateToScreen(n,{transition:this.transition,direction:"forward"})):$n.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=g(r);!(o=s()).done;){var u=o.value;if(u.action)for(var l,d=g(u.action);!(l=d()).done;){var h,c,m=l.value;if(this.shouldRun(m))return this.branchcrumbs.push(a),null===(h=u.before)||void 0===h||h.forEach((e=>{this.performAction(e)})),u.action.forEach((e=>{this.shouldRun(e)&&this.performAction(e)})),void(null===(c=u.after)||void 0===c||c.forEach((e=>{this.performAction(e)})))}else $n.warn(`No actions defined for branch tag ${a}`)}}$n.warn(`No matching branch condition matched for step ${e.id}`)}},{key:"getFormData",value:function(){var e,t;return y({},null!==(e=null===(t=Jh.currentProvider)||void 0===t||null===(t=t.state)||void 0===t?void 0:t.formStates)&&void 0!==e?e:{})}},{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).sort();if(0!==n.length){var i=n.filter((e=>!0===t[e]));if(0===i.length)return $n.info("No eligible handoff keys after filtering"),void this.manager.resume();this.activeHandoffSequence={formStates:y({},t),remainingKeys:[...i]},this.resumeNextHandoff()}else $n.warn("formStates is empty, no handoffs to perform")}else $n.warn("No formStates available for handoff sequence")}},{key:"resumeNextHandoff",value:function(){var e,t,n=this.activeHandoffSequence;if(!n)return $n.warn("No active handoff sequence to resume"),void this.manager.resume();if(0===n.remainingKeys.length)return $n.info("All handoffs in the sequence are complete"),this.activeHandoffSequence=null,void this.manager.resume();var i=n.remainingKeys.shift(),a=n.formStates[i];$n.debug(`Starting handoff for ${i} → ${String(a)}`),this.activeHandoffSequence=n;var r=`${i}`;null===(e=(t=this.manager).handoffStepHandler)||void 0===e||e.call(t,r,void 0)}}])}(),zm=function(){function e(){h(this,e),this.flowOpen=!1,this.lastAnimatedFlowProgress=new Map,this.navGraphCache=new WeakMap}return p(e,[{key:"resume",value:function(){e.resume()}},{key:"presentFlow",value:function(e,t,n){var i=new $m(e,t,this,n);return this.flowOpen=!0,this.currentFlow=i,i}},{key:"finishFlow",value:function(){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===Qc));if(0===t.length)return 0;var n=this.currentFlow.stepcrumbs.filter((e=>e.type===Qc));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=g(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 $n.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=g(u);!(l=d()).done;){var h=l.value;o(h,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[rm];if(!i)return null;for(var a,r=g(i);!(a=r()).done;)for(var o,s,u=g(null!==(o=a.value.action)&&void 0!==o?o:[]);!(s=u()).done;){var l,d=s.value;if((d.function===qc.NAVIGATE||d.function===qc.NEXT)&&null!=(null===(l=d.parameters)||void 0===l?void 0:l.delay)){var h=d.parameters.delay,c=Number(h);if(!isNaN(c)&&c>0)return c/1e3}}return null}}],[{key:"instance",get:function(){return e._instance||(e._instance=new e),e._instance}},{key:"registerStepHandoff",value:function(e){this.instance.handoffStepHandler=e}},{key:"registerEventHandler",value:function(e){this.instance.eventHandler=e}},{key:"resume",value:function(){var t=e.instance,n=t.flowOpen,i=t.currentFlow;if(n&&i&&i.currentFlowStep){if(i.activeHandoffSequence)return $n.debug(`Resuming flow at handoff sequence ${i.currentFlowStep.id}`),void i.resumeNextHandoff();$n.debug(`Resuming flow at step ${i.currentFlowStep.id}`),i.executeLifecycle(i.currentFlowStep,"__resume__")}else $n.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?($n.debug(`Finishing flow programmatically at step ${i.currentFlowStep.id}`),i.finished()):$n.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():$n.warn("This flow cannot be paused"):$n.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()}}])}();var Bm=e=>{var t;return T((function(n){for(;;)if(0===n.n)return t=new Set(Array.from(document.fonts.values()).map((e=>e.family))),e.forEach((e=>{var n=Hm(e);if(!t.has(n)){var i=new FontFace(n,`url(${e.file})`);document.fonts.add(i)}})),n.a(2,document.fonts.ready.then())}),null,null,null,Promise)};function Hm(e){return`${e.family}-${e.style}`.replace(/ /g,"")}function Um(e,t,n){var i,a,r,o,s,u,l,d;if("undefined"==typeof window||!e||!t)return $n.debug("Swipe detection is not supported in this environment."),{destroy(){},updateOptions(){}};var h={minDistance:null!==(i=null==n?void 0:n.minDistance)&&void 0!==i?i:30,maxDuration:null!==(a=null==n?void 0:n.maxDuration)&&void 0!==a?a:600,lockAxis:null===(r=null==n?void 0:n.lockAxis)||void 0===r||r,preventScrollOnSwipe:null!==(o=null==n?void 0:n.preventScrollOnSwipe)&&void 0!==o&&o,pointerTypes:null!==(s=null==n?void 0:n.pointerTypes)&&void 0!==s?s:["touch"],passiveListeners:null===(u=null==n?void 0:n.passiveListeners)||void 0===u||u,axisHint:null!==(l=null==n?void 0:n.axisHint)&&void 0!==l?l:"y",edgeLeakThreshold:null!==(d=null==n?void 0:n.edgeLeakThreshold)&&void 0!==d?d:24},c=e.style.touchAction;h.preventScrollOnSwipe&&(e.style.touchAction="none");var m=null,f=0,v=0,p=0,g=0,y=0,b=null,w=null,k=!1,S=!1,E=!1,M=e=>{try{var t=window.getComputedStyle(e);if(!t)return!1;var n=t.overflowY;if("auto"!==n&&"scroll"!==n)return!1;var i=e;return i.scrollHeight>i.clientHeight}catch(e){return!1}},P=e=>h.pointerTypes.includes(e.pointerType),T=t=>{var n=t.composedPath?t.composedPath()[0]:t.target;if(P(t)&&null===m){m=t.pointerId,f=p=t.clientX,v=g=t.clientY,y=performance.now(),b=null,E=!1,k=!1,S=!1,(w="y"===h.axisHint?((e,t)=>{for(var n=e;n&&n!==t&&n instanceof HTMLElement;){var i,a;if(M(n))return n;n=n.parentElement||(null!==(i=null===(a=n.parentNode)||void 0===a?void 0:a.host)&&void 0!==i?i:null)}return null})(n,e):null)||(S=!0);try{var i;null==e||null===(i=e.setPointerCapture)||void 0===i||i.call(e,t.pointerId)}catch(e){try{var a;null==n||null===(a=n.setPointerCapture)||void 0===a||a.call(n,t.pointerId)}catch(e){}}}},_=e=>{if(e.pointerId===m&&P(e)){if(p=e.clientX,g=e.clientY,h.lockAxis&&!b){var n=Math.abs(p-f),i=Math.abs(g-v);(n>2||i>2)&&(b=i>=n?"y":"x")}if("y"===h.axisHint&&("y"===b||!h.lockAxis)){var a=g-v,r=a<0?"up":"down",o=Math.abs(a),s=performance.now()-y,u=o/Math.max(s,1),l=o>=h.minDistance||u>.5;if(w)if(l)S=!0;else if(((e,t)=>!!e&&("down"===t?e.scrollTop>0:e.scrollTop+e.clientHeight<e.scrollHeight-1))(w,r)){if(!(("down"===r&&w.scrollTop<=50||"up"===r&&w.scrollTop+w.clientHeight>=w.scrollHeight-50)&&u>.3))return void(k=!0);S=!0}else S=!0;var d=!w||o>=h.edgeLeakThreshold;if(!E&&!k&&S&&d&&o>=h.minDistance){E=!0;var c=performance.now(),M={direction:"up"===r?"up":"down",distanceX:p-f,distanceY:a,absX:Math.abs(p-f),absY:o,duration:c-y,velocity:o/Math.max(c-y,1),startX:f,startY:v,endX:p,endY:g,startedAt:y,endedAt:c,originalEvent:e};t(M)}}}},D=e=>{if(e.pointerId===m)if(P(e))if(w)A();else if(E||k)A();else{var n,i=performance.now(),a=i-y,r=p-f,o=g-v,s=Math.abs(r),u=Math.abs(o),l="x"===(n=h.lockAxis&&b?b:"x"===h.axisHint?"x":"y"===h.axisHint?"y":s>=u?"x":"y")?s:u,d=a<=h.maxDuration,c=h.minDistance;if(w&&"y"===n&&S&&(c+=h.edgeLeakThreshold),d&&l>=c){var M;M="x"===n?r>0?"right":"left":o>0?"down":"up";var T=l/Math.max(a,1);t({direction:M,distanceX:r,distanceY:o,absX:s,absY:u,duration:a,velocity:T,startX:f,startY:v,endX:p,endY:g,startedAt:y,endedAt:i,originalEvent:e})}A()}else A()},A=()=>{m=null,b=null,y=0,w=null,S=!1,k=!1,E=!1},x=!!h.passiveListeners&&{passive:!0},C=h.passiveListeners?{passive:!0,capture:!0}:{capture:!0};e.addEventListener("pointerdown",T,C),e.addEventListener("pointermove",_,x),e.addEventListener("pointerup",D,x),e.addEventListener("pointercancel",D,x),e.addEventListener("lostpointercapture",D,x);return{destroy:()=>{e.removeEventListener("pointerdown",T,C),e.removeEventListener("pointermove",_,x),e.removeEventListener("pointerup",D,x),e.removeEventListener("pointercancel",D,x),e.removeEventListener("lostpointercapture",D,x),h.preventScrollOnSwipe&&(e.style.touchAction=c),A()},updateOptions:t=>{Object.assign(h,t),"boolean"==typeof t.preventScrollOnSwipe&&(t.preventScrollOnSwipe?e.style.touchAction="none":e.style.touchAction=c)}}}var Gm,Vm,Xm,Km,Ym,qm,Jm,Qm,Zm,ef,tf,nf=e=>e,af=function(){function e(t,n,i){var a;return h(this,e),(a=d(this,e)).pages=[],a.currentOffset=0,a.presentationStyle="fullscreen",a.formFactor=cu(),a.timeSpentOnPaywall=0,a.animation={transition:"none",direction:"forward"},a._originalBodyStyles={},a._originalDocumentStyles={},a._savedScrollY=0,a._sheetDragStartY=0,a._sheetIsDragging=!1,a._dismissThreshold=100,a.type=t,a.value=n,a.context=i,a.setPaywallData(),M(a,a)}return k(e,n),p(e,[{key:"setPaywallData",value:function(){var e=Au(this.value,this.type);this.paywall=e.paywall,this.campaign=e.campaign}},{key:"getPresentationStyle",value:function(e){var t,n,i=null==e||null===(t=e.template)||void 0===t||null===(t=t.initialState)||void 0===t?void 0:t.presentation_style;return(n=i)&&pc.has(n)?"sheet"===n?"fullscreen":n:"fullscreen"}},{key:"isHalfSheet",get:function(){return"compact_sheet"===this.presentationStyle}},{key:"connectedCallback",value:function(){var t;x(e,"connectedCallback",this)([]),null!==(t=window.TVJS)&&void 0!==t&&t.DirectionalNavigation&&(window.TVJS.DirectionalNavigation.focusRoot=this),document.addEventListener("keydown",this.handleKeyDownEvent.bind(this)),this._swipeHandler=Um(this,this.handleSwipeEvent.bind(this),{axisHint:"y",lockAxis:!0,minDistance:25,edgeLeakThreshold:15,preventScrollOnSwipe:!1,pointerTypes:["touch"]}),this.presentationStyle=this.getPresentationStyle(this.paywall),this.setOriginalStyles()}},{key:"disconnectedCallback",value:function(){var t,n;x(e,"disconnectedCallback",this)([]),Qr.clearLaunchId(),null!==(t=window.TVJS)&&void 0!==t&&t.DirectionalNavigation&&(window.TVJS.DirectionalNavigation.focusRoot=document.body),document.removeEventListener("keydown",this.handleKeyDownEvent.bind(this)),Hu.getInstance().removeAllListeners(Pn),this.restoreStyles(),null===(n=this._halfSheetAbortController)||void 0===n||n.abort(),this._swipeHandler.destroy()}},{key:"setOriginalStyles",value:function(){"television"===this.formFactor&&(this._originalBodyStyles.overflow=document.body.style.overflow,document.body.style.overflow="hidden"),this._originalBodyStyles.background=document.body.style.background,"phone"===this.formFactor&&(this._originalBodyStyles["overscroll-behavior"]=document.body.style.overscrollBehavior?document.body.style.overscrollBehavior:null,this._originalDocumentStyles["overscroll-behavior"]=document.documentElement.style.overscrollBehavior?document.documentElement.style.overscrollBehavior:null,document.body.style.overscrollBehavior="none",document.documentElement.style.overscrollBehavior="none",this.isHalfSheet||(this._originalBodyStyles.overflow=document.body.style.overflow,document.body.style.overflow="hidden")),this.isHalfSheet&&(this._savedScrollY=window.scrollY,this._originalBodyStyles.position=document.body.style.position||null,this._originalBodyStyles.top=document.body.style.top||null,this._originalBodyStyles.width=document.body.style.width||null,document.body.style.position="fixed",document.body.style.top=`-${this._savedScrollY}px`,document.body.style.width="100%")}},{key:"restoreStyles",value:function(){Object.entries(this._originalBodyStyles).forEach((([e,t])=>{null!==t?document.body.style.setProperty(e,t):document.body.style.removeProperty(e)})),Object.entries(this._originalDocumentStyles).forEach((([e,t])=>{null!==t?document.documentElement.style.setProperty(e,t):document.documentElement.style.removeProperty(e)})),this._savedScrollY>0&&(window.scrollTo(0,this._savedScrollY),this._savedScrollY=0)}},{key:"handleKeyDownEvent",value:function(e){!this.flow||10009!==e.keyCode&&"Backspace"!==e.key&&"GoBack"!==e.key||this.flow.triggerActions(cm)}},{key:"handleSwipeEvent",value:function({direction:e}){var t;if("down"===e)null===(t=this.flow)||void 0===t||t.triggerActions("__swipe_down__");else if("up"===e){var n;null===(n=this.flow)||void 0===n||n.triggerActions("__swipe_up__")}}},{key:"setupHalfSheetDragTracking",value:function(){var e,t,n;null===(e=this._halfSheetAbortController)||void 0===e||e.abort(),this._halfSheetAbortController=new AbortController;var i=this._halfSheetAbortController.signal,a=null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector(".nami-half-sheet-container"),r=null===(n=this.shadowRoot)||void 0===n?void 0:n.querySelector(".nami-half-sheet-content");if(a&&r){a.addEventListener("touchstart",(e=>{r.scrollTop>0||(this._sheetDragStartY=e.touches[0].clientY,this._sheetIsDragging=!0)}),{passive:!0,signal:i}),a.addEventListener("touchmove",(e=>{if(this._sheetIsDragging){var t=e.touches[0].clientY-this._sheetDragStartY;t>0&&(a.style.transform=`translateY(${t}px)`,a.style.transition="none",e.preventDefault())}}),{passive:!1,signal:i}),a.addEventListener("touchend",(()=>{if(this._sheetIsDragging){this._sheetIsDragging=!1;var e,t,n=a.style.transform.match(/translateY\((\d+(?:\.\d+)?)px\)/);if((n?parseFloat(n[1]):0)>this._dismissThreshold)if(null!==(e=null===(t=this.flow)||void 0===t?void 0:t.currentStepHasHoistedPrimaryActions("__swipe_down__"))&&void 0!==e&&e){var i;a.style.transform="translateY(0)",a.style.transition="transform 0.2s ease-out",null===(i=this.flow)||void 0===i||i.triggerActions("__swipe_down__")}else{var r;a.style.transform="translateY(100%)",a.style.transition="transform 0.2s ease-in";var o=null===(r=this.shadowRoot)||void 0===r?void 0:r.querySelector(".nami-half-sheet-backdrop");o&&o.classList.add("nami-dismissing"),setTimeout((()=>{var e;null===(e=this.flow)||void 0===e||e.finished()}),200)}else a.style.transform="translateY(0)",a.style.transition="transform 0.2s ease-out"}}),{signal:i})}}},{key:"setupHalfSheetFocusTrap",value:function(){var e,t,n=null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector(".nami-half-sheet-container");if(n){n.focus();var i=null===(t=this._halfSheetAbortController)||void 0===t?void 0:t.signal;n.addEventListener("keydown",(e=>{if("Tab"===e.key){var t=n.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');if(0!==t.length){var i,a,r=t[0],o=t[t.length-1];if(e.shiftKey)document.activeElement!==r&&(null===(i=this.shadowRoot)||void 0===i?void 0:i.activeElement)!==r||(e.preventDefault(),o.focus());else document.activeElement!==o&&(null===(a=this.shadowRoot)||void 0===a?void 0:a.activeElement)!==o||(e.preventDefault(),r.focus())}}}),i?{signal:i}:void 0)}}},{key:"firstUpdated",value:function(){this.timeSpentOnPaywall=Date.now(),Bs(this.campaign)&&(this.flow=zm.instance.presentFlow(this.campaign,this,this.context)),this.isHalfSheet&&this.updateComplete.then((()=>{this.setupHalfSheetDragTracking(),this.setupHalfSheetFocusTrap()}))}},{key:"updated",value:function(t){x(e,"updated",this)([t]),this.isHalfSheet&&t.has("presentationStyle")&&(this.setupHalfSheetDragTracking(),this.setupHalfSheetFocusTrap())}},{key:"getAnimationStyles",value:function(e){var t="backward"===this.animation.direction?-1:1;switch(this.animation.transition){case"verticalSlide":return`transform: translateY(${100*(e-this.currentOffset)*t}vh);`;case"slide":return`transform: translateX(${100*(e-this.currentOffset)*t}vw);`;case"fade":return`opacity: ${e===this.currentOffset?1:0};`;default:return""}}},{key:"updatePages",value:function(e){var t;return T((function(n){for(;;)switch(n.n){case 0:if(0!==this.pages.length&&"none"!==this.animation.transition){n.n=1;break}return this.pages=[e],n.a(2);case 1:if((null==(t=this.pages[this.pages.length-1])?void 0:t.id)!==e.id){n.n=2;break}return n.a(2);case 2:return this.pages=[t,e],this.currentOffset=0,n.n=3,l(this.updateComplete);case 3:requestAnimationFrame((()=>{this.currentOffset=1,setTimeout((()=>{this.pages=[e],this.currentOffset=0,this.paywall=e}),250)}));case 4:return n.a(2)}}),null,this,null,Promise)}},{key:"flowNavigateToScreen",value:function(e,t){var n,i,a,r;return T((function(o){for(;;)switch(o.n){case 0:if(null!==(n=this.flow)&&void 0!==n&&n.previousFlowStep&&this.flow.executeLifecycle(this.flow.previousFlowStep,om),a=this.presentationStyle,r=this.getPresentationStyle(e),"fullscreen"!==a||"compact_sheet"!==r){o.n=1;break}console.warn("Unsupported transition: fullscreen → compact_sheet. Presenting as fullscreen."),o.n=4;break;case 1:if("compact_sheet"!==a||"fullscreen"!==r&&"sheet"!==r){o.n=3;break}return o.n=2,l(this.animateHalfSheetExpand());case 2:this.presentationStyle="fullscreen",o.n=4;break;case 3:this.presentationStyle=r;case 4:return this.animation=t,o.n=5,l(this.updatePages(e));case 5:null!==(i=this.flow)&&void 0!==i&&i.currentFlowStep&&this.flow.executeLifecycle(this.flow.currentFlowStep,rm);case 6:return o.a(2)}}),null,this,null,Promise)}},{key:"animateHalfSheetExpand",value:function(){var e,t;return T((function(n){for(;;)switch(n.n){case 0:if(t=null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector(".nami-half-sheet-container")){n.n=1;break}return n.a(2);case 1:return t.classList.add("nami-expanding"),n.n=2,l(new Promise((e=>setTimeout(e,300))));case 2:return n.a(2)}}),null,this,null,Promise)}},{key:"getSelectedSlideIndexForCurrentCarousel",value:function(){return Jh.getSelectedSlideIndex()}},{key:"renderFlow",value:function(){return"undefined"==typeof document?t(Gm||(Gm=nf``)):this.isHalfSheet?this.renderHalfSheet():t(Vm||(Vm=nf`
91
+ `)),Sc=e=>(t,n)=>{void 0!==n?n.addInitializer((()=>{customElements.define(e,t)})):customElements.define(e,t)},Ec=globalThis,Mc=Ec.ShadowRoot&&(void 0===Ec.ShadyCSS||Ec.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Pc=Symbol(),Tc=new WeakMap,_c=function(){return p((function e(t,n,i){if(h(this,e),this._$cssResult$=!0,i!==Pc)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(Mc&&void 0===e){var n=void 0!==t&&1===t.length;n&&(e=Tc.get(t)),void 0===e&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),n&&Tc.set(t,e))}return e}},{key:"toString",value:function(){return this.cssText}}])}(),Dc=(e,t)=>{if(Mc)e.adoptedStyleSheets=t.map((e=>e instanceof CSSStyleSheet?e:e.styleSheet));else for(var n,i=g(t);!(n=i()).done;){var a=n.value,r=document.createElement("style"),o=Ec.litNonce;void 0!==o&&r.setAttribute("nonce",o),r.textContent=a.cssText,e.appendChild(r)}},Ac=Mc?e=>e:e=>e instanceof CSSStyleSheet?(e=>{for(var t,n="",i=g(e.cssRules);!(t=i()).done;){n+=t.value.cssText}return(e=>new _c("string"==typeof e?e:e+"",void 0,Pc))(n)})(e):e,xc=Object.is,Cc=Object.defineProperty,Ic=Object.getOwnPropertyDescriptor,Lc=Object.getOwnPropertyNames,Fc=Object.getOwnPropertySymbols,Rc=Object.getPrototypeOf,Wc=globalThis,Oc=Wc.trustedTypes,Nc=Oc?Oc.emptyScript:"",jc=Wc.reactiveElementPolyfillSupport,$c=(e,t)=>e,zc={toAttribute(e,t){switch(t){case Boolean:e=e?Nc: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}},Bc=(e,t)=>!xc(e,t),Hc={attribute:!0,type:String,converter:zc,reflect:!1,useDefault:!1,hasChanged:Bc};null!==(yc=Symbol.metadata)&&void 0!==yc||(Symbol.metadata=Symbol("metadata")),null!==(bc=Wc.litPropertyMetadata)&&void 0!==bc||(Wc.litPropertyMetadata=new WeakMap);var Uc=function(){function e(){var t;return h(this,e),(t=d(this,e))._$Ep=void 0,t.isUpdatePending=!1,t.hasUpdated=!1,t._$Em=null,t._$Ev(),t}return k(e,I(HTMLElement)),p(e,[{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=g(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 Dc(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:zc).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:zc;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){if(void 0!==e){var i,a,r=this.constructor,o=this[e];if(null!=n||(n=r.getPropertyOptions(e)),!((null!==(i=n.hasChanged)&&void 0!==i?i:Bc)(o,t)||n.useDefault&&n.reflect&&o===(null===(a=this._$Ej)||void 0===a?void 0:a.get(e))&&!this.hasAttribute(r._$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 T((function(n){for(;;)switch(n.p=n.n){case 0:return this.isUpdatePending=!0,n.p=1,n.n=2,l(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,l(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=g(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=g(o);!(s=u()).done;){var l=s.value,d=l[0],h=l[1],c=h.wrapped,m=this[d];!0!==c||this._$AL.has(d)||void 0===m||this.C(d,void 0,h,m)}}var f=!1,v=this._$AL;try{var p;(f=this.shouldUpdate(v))?(this.willUpdate(v),null!==(p=this._$EO)&&void 0!==p&&p.forEach((e=>{var t;return null===(t=e.hostUpdate)||void 0===t?void 0:t.call(e)})),this.update(v)):this._$EM()}catch(v){throw f=!1,this._$EM(),v}f&&this._$AE(v)}}},{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=Hc){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&&Cc(this.prototype,e,i)}}},{key:"getPropertyDescriptor",value:function(e,t,n){var i,a=null!==(i=Ic(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:Hc}},{key:"_$Ei",value:function(){if(!this.hasOwnProperty($c("elementProperties"))){var e=Rc(this);e.finalize(),void 0!==e.l&&(this.l=[...e.l]),this.elementProperties=new Map(e.elementProperties)}}},{key:"finalize",value:function(){if(!this.hasOwnProperty($c("finalized"))){if(this.finalized=!0,this._$Ei(),this.hasOwnProperty($c("properties")))for(var e=this.properties,t=0,n=[...Lc(e),...Fc(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=g(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 h,c=g(this.elementProperties);!(h=c()).done;){var m=h.value,f=m[0],v=m[1],p=this._$Eu(f,v);void 0!==p&&this._$Eh.set(p,f)}this.elementStyles=this.finalizeStyles(this.styles)}}},{key:"finalizeStyles",value:function(e){var t=[];if(Array.isArray(e))for(var n,i=g(new Set(e.flat(1/0).reverse()));!(n=i()).done;){var a=n.value;t.unshift(Ac(a))}else void 0!==e&&t.push(Ac(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}}])}();Uc.elementStyles=[],Uc.shadowRootOptions={mode:"open"},Uc[$c("elementProperties")]=new Map,Uc[$c("finalized")]=new Map,null!=jc&&jc({ReactiveElement:Uc}),(null!==(wc=Wc.reactiveElementVersions)&&void 0!==wc?wc:Wc.reactiveElementVersions=[]).push("2.1.1");var Gc={attribute:!0,type:String,converter:zc,reflect:!1,hasChanged:Bc},Vc=(e=Gc,t,n)=>{var i=n.kind,a=n.metadata,r=globalThis.litPropertyMetadata.get(a);if(void 0===r&&globalThis.litPropertyMetadata.set(a,r=new Map),"setter"===i&&((e=Object.create(e)).wrapped=!0),r.set(n.name,e),"accessor"===i){var o=n.name;return{set(n){var i=t.get.call(this);t.set.call(this,n),this.requestUpdate(o,i,e)},init(t){return void 0!==t&&this.C(o,void 0,e,t),t}}}if("setter"===i){var s=n.name;return function(n){var i=this[s];t.call(this,n),this.requestUpdate(s,i,e)}}throw Error("Unsupported decorator location: "+i)};function Xc(e){return(t,n)=>"object"==typeof n?Vc(e,t,n):((e,t,n)=>{var i=t.hasOwnProperty(n);return t.constructor.createProperty(n,e),i?Object.getOwnPropertyDescriptor(t,n):void 0})(e,t,n)}function Kc(e){return Xc(y({},e,{state:!0,attribute:!1}))}function Yc(e){return!e||"object"==typeof e&&0==Object.keys(e).length}var qc,Jc="entry",Qc="screen",Zc="branch",em="exit",tm="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.PAUSE="flowPause",e.RESUME="flowResume"}(qc||(qc={}));var nm="__handoff_sequence__",im="__buy_sku__",am="__default__",rm="__appear__",om="__disappear__",sm="__login_success__",um="__login_failure__",lm="__logout_success__",dm="__logout_failure__",hm="__purchase_success__",cm="__remoteback__",mm="__tag_update__",fm="and",vm="or",pm="i_contains",gm="equals",ym="i_equals",bm="not_equals",wm="not_i_equals",km="not_contains",Sm="set",Em="notSet",Mm=function(){function e(){h(this,e),this.resolvers=new Map,this.namespaceResolvers=new Map}return p(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 fm:return i.every((e=>e));case vm: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 fm:for(var i,a=g(n);!(i=a()).done;){var r=i.value;if(!this.evaluateFilter(r))return!1}return!0;case vm:for(var o,s=g(n);!(o=s()).done;){var u=o.value;if(this.evaluateFilter(u))return!0}return!1;default:for(var l,d=g(n);!(l=d()).done;){var h=l.value;if(!this.evaluateFilter(h))return!1}return!0}}},{key:"evaluateFilter",value:function(e){var t=this.resolve(e.identifier);if(e.operator===Sm)return null!=t;if(e.operator===Em)return null==t;if(null==t)return!![bm,wm,km].includes(e.operator);switch(e.operator){case pm:return Array.isArray(t)?e.values.some((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 gm:return e.values.some((e=>{if("string"==typeof t)return t===e;if("boolean"==typeof t){var n="true"===e.toLowerCase();return t===n}return this.log("Unsupported type for equals comparison: "+typeof t),!1}));case ym:return e.values.some((e=>{if("string"==typeof t)return 0===t.localeCompare(e,void 0,{sensitivity:"accent"});if("boolean"==typeof t){var n="true"===e.toLowerCase();return t===n}return this.log("Unsupported type for i_equals comparison: "+typeof t),!1}));case bm:return e.values.every((e=>"string"!=typeof t||t!==e));case wm:return e.values.every((e=>"string"!=typeof t||0!==t.localeCompare(e,void 0,{sensitivity:"accent"})));case km:return e.values.every((e=>"string"!=typeof t||!t.includes(e)));default:return this.log(`Unsupported operator: ${e.operator}`),!1}}},{key:"resolve",value:function(e){var t=this.resolveRaw(e);if(void 0!==t)return t;var n=e.lastIndexOf(".");if(-1!==n){var i=e.slice(0,n),a=e.slice(n+1),r=this.resolveRaw(i);return void 0!==r?this.extractProperty(a,r):void 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=g(n);!(t=i()).done;){var a=t.value;if(e.startsWith(a)){var r=this.namespaceResolvers.get(a);if(r)return r(e)}}}},{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){$n.debug(`[NamiConditionEvaluator] ${e}`)}}],[{key:"shared",get:function(){return e.instance||(e.instance=new e),e.instance}}])}(),Pm=function(){return p((function e(){h(this,e)}),[{key:"register",value:function(){Mm.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=g(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}}])}(),Tm=function(){function e(t){var n;return h(this,e),(n=d(this,e)).namespace="LaunchContext",n.context=t,n.register(),n}return k(e,Pm),p(e,[{key:"resolveValue",value:function(e){if(e.startsWith("customAttributes.")){var t=e.substring(17);return this.resolveKeyPath(t,this.context.customAttributes)}if(e.startsWith("customObject.")){var n=e.substring(13);return this.resolveKeyPath(n,this.context.customObject)}return this.resolveKeyPath(e,{customAttributes:this.context.customAttributes,customObject:this.context.customObject,productGroups:this.context.productGroups})}}])}(),_m=function(){function e(){var t,n,i,a;h(this,e),(a=d(this,e)).namespace="Device";var r=Intl.DateTimeFormat().resolvedOptions().locale.split("-")[1]||"",o=Intl.DateTimeFormat().resolvedOptions().timeZone,s=hu();return a.context={osName:s.os_name,osVersion:s.os_version,appVersion:s.extended_platform_version,sdkVersion:s.sdk_version,deviceModel:s.device_model,screenWidth:window.innerWidth,screenHeight:window.innerHeight,formFactor:s.form_factor,tvQuality:a.tvQuality(null!==(t=s.form_factor)&&void 0!==t?t:"desktop"),tvResolution:a.tvResolution(null!==(n=s.form_factor)&&void 0!==n?n:"desktop"),screenSize:a.screenSizeTier(null!==(i=s.form_factor)&&void 0!==i?i:"desktop"),language:s.language,country:r,timezone:o},a.register(),a}return k(e,Pm),p(e,[{key:"screenSizeTier",value:function(e){var t=window.screen.width,n=window.screen.height,i=window.devicePixelRatio||1,a=Math.round(t*i),r=Math.round(n*i),o=Math.max(a,r);switch(e){case"phone":return o<1136?"tiny":o<1334?"small":o<1920?"medium":o<2560?"large":"huge";case"tablet":return o<2048?"medium":o<2732?"large":"huge";case"television":return o<1920?"medium":o<3840?"large":"huge";case"desktop":return o<1440?"small":o<2560?"medium":o<3840?"large":"huge";default:return"medium"}}},{key:"tvQuality",value:function(e){if("television"!==e)return"";var t=window.screen.width,n=window.screen.height,i=window.devicePixelRatio||1,a=Math.round(t*i),r=Math.round(n*i),o=Math.max(a,r),s=Math.min(a,r);return o>=3840||s>=2160?"4K":o>=1920||s>=1080?"1080p":"720p"}},{key:"tvResolution",value:function(e){if("television"!==e)return"";var t=window.screen.width,n=window.screen.height,i=window.devicePixelRatio||1,a=Math.round(t*i),r=Math.round(n*i),o=Math.max(a,r),s=Math.min(a,r);return s<720&&o<1280?"SD":s>=720&&s<1080&&o>=1280&&o<1920?"720p":s>=1080&&s<1440&&o>=1920&&o<2560?"1080p":s>=1440&&s<2160&&o>=2560&&o<3840?"1440p":s>=2160&&s<3e3&&o>=3840&&o<5e3?"4K":s>=3e3&&o>=5e3?"8K":"Unknown"}},{key:"resolveValue",value:function(e){return this.resolveKeyPath(e,this.context)}}])}(),Dm=[/(^|_)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],Am=function(){function e(){h(this,e),this.params={},"undefined"!=typeof window&&this.setSearchParams()}return p(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=>Dm.some((t=>t.test(e))))(a))){var r=this.safeValue(i);r&&(t[a]=r,n.add(a))}},o=g(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()}}])}();Am._instance=null;var xm,Cm=()=>Am.instance.params,Im=/\{\{\s*([^}]+?)\s*\}\}/g,Lm=function(){return p((function e(t){h(this,e),this.flowManager=t,this.urlParams=Cm()}),[{key:"resolve",value:function(e){var t,n,i,a,r,o,s,u,l,d,h,c,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 Tm(p).resolveValue(g);return null==y?void 0:y.toString()}}else 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===(h=m.currentFlowStep)||void 0===h?void 0:h.name;case"buttonText":return null==m||null===(c=m.currentButton)||void 0===c?void 0:c.firstTextValue();case"slideNumber":var b=null==f?void 0:f.getSelectedSlideIndexForCurrentCarousel();return null!=b?`${b+1}`:void 0;default:return}}},{key:"interpolateLiquidVariables",value:function(e){return e.replace(Im,((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])=>y({},e,{[t]:this.interpolateDeep(n)})),{}):e}}])}(),Fm=function(){function e(){var t;return h(this,e),(t=d(this,e)).namespace="urlParams",t.context=Cm(),t.register(),t}return k(e,Pm),p(e,[{key:"resolveValue",value:function(e){return $n.debug("[URLParamsResolver]","Resolving keyPath",e),this.resolveKeyPath(e,this.context)}}])}(),Rm=function(){function e(){var t;return h(this,e),(t=d(this,e)).namespace="state",t.register(),t}return k(e,Pm),p(e,[{key:"getContextProvider",value:function(){var e=Jh.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)}}}])}(),Wm=function(){function e(t){var n;return h(this,e),(n=d(this,e)).namespace="Placement",n.campaign=t,n.register(),n}return k(e,Pm),p(e,[{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=Jh.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()}}}}])}(),Om=function(){return p((function e(){h(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?Qr.setNamiProfile({externalId:this.externalId}):Qr.removeNamiProfile(),this}},{key:"load",value:function(){var e=Qr.getNamiProfile();e&&(this.externalId=e.externalId),Jh.setIsLoggedIn(!!this.externalId)}},{key:"login",value:function(e){var t;return T((function(n){for(;;)switch(n.n){case 0:return n.n=1,l(zs.instance.login(e));case 1:(t=n.v).external_id&&Jh.setIsLoggedIn(!0),this.setExternalId(t.external_id).save();case 2:return n.a(2)}}),null,this,null,Promise)}},{key:"logout",value:function(){return T((function(e){for(;;)switch(e.n){case 0:return e.n=1,l(zs.instance.logout());case 1:Jh.setIsLoggedIn(!1),this.setExternalId(void 0).save();case 2:return e.a(2)}}),null,this,null,Promise)}}])}();Om.instance=new Om,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"}(xm||(xm={}));var Nm=function(){return p((function e(){h(this,e),this.emitter=Hu.getInstance(),Mm.shared.registerNamespaceResolver("UserTags",(t=>{var n=t.replace("UserTags.",""),i=e.getCustomerAttribute(n);if(null!=i){var a=i.toLowerCase();return"true"===a||"false"===a?"true"===a:isNaN(Number(i))?i:parseInt(i,10)}return null}))}),[{key:"isSDKInitialized",get:function(){return fc.instance.isInitialized}}],[{key:"isLoggedIn",value:function(){return Om.instance.isLoggedIn()}},{key:"loggedInId",value:function(){return this.instance.isSDKInitialized||$n.debug(Pe),Om.instance.getExternalId()}},{key:"login",value:function(e){var t,n,i,a,r,o,s;return T((function(u){for(;;)switch(u.p=u.n){case 0:if(this.instance.isSDKInitialized){u.n=1;break}throw t=new no,this.invokeStateHandler(xm.LOGIN,!1,t),t;case 1:if(!this.inAnonymousMode()){u.n=2;break}throw n=new ho,this.invokeStateHandler(xm.LOGIN,!1,n),n;case 2:return u.p=2,u.n=3,l(Om.instance.login(e));case 3:return u.n=4,l(nc.instance.fetchActiveEntitlements());case 4:this.invokeStateHandler(xm.LOGIN,!0),zm.instance.flowOpen&&(i=zm.instance.currentFlow,(a=null==i?void 0:i.currentFlowStep)&&i.executeLifecycle(a,sm)),u.n=6;break;case 5:throw u.p=5,s=u.v,this.invokeStateHandler(xm.LOGIN,!1,s),zm.instance.flowOpen&&(r=zm.instance.currentFlow,(o=null==r?void 0:r.currentFlowStep)&&r.executeLifecycle(o,um)),s;case 6:return u.a(2)}}),null,this,[[2,5]],Promise)}},{key:"logout",value:function(){var e,t,n,i,a,r,o;return T((function(s){for(;;)switch(s.p=s.n){case 0:if(this.instance.isSDKInitialized){s.n=1;break}throw e=new no,this.invokeStateHandler(xm.LOGOUT,!1,e),e;case 1:if(!this.inAnonymousMode()){s.n=2;break}throw t=new ho,this.invokeStateHandler(xm.LOGOUT,!1,t),t;case 2:return s.p=2,s.n=3,l(Om.instance.logout());case 3:return s.n=4,l(nc.instance.fetchActiveEntitlements());case 4:this.invokeStateHandler(xm.LOGOUT,!0),zm.instance.flowOpen&&(n=zm.instance.currentFlow,(i=null==n?void 0:n.currentFlowStep)&&n.executeLifecycle(i,lm)),s.n=6;break;case 5:throw s.p=5,o=s.v,this.invokeStateHandler(xm.LOGOUT,!1,o),zm.instance.flowOpen&&(a=zm.instance.currentFlow,(r=null==a?void 0:a.currentFlowStep)&&a.executeLifecycle(r,dm)),o;case 6:return s.a(2)}}),null,this,[[2,5]],Promise)}},{key:"setCustomerDataPlatformId",value:function(e){return T((function(t){for(;;)switch(t.n){case 0:return t.n=1,l(this.updateCustomerDataPlatformId(e));case 1:return t.a(2)}}),null,this,null,Promise)}},{key:"clearCustomerDataPlatformId",value:function(){return T((function(e){for(;;)switch(e.n){case 0:return e.n=1,l(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,a,r;return T((function(o){for(;;)switch(o.n){case 0:if(t=e?xm.ANONYMOUS_MODE_ON:xm.ANONYMOUS_MODE_OFF,this.instance.isSDKInitialized){o.n=1;break}throw n=new no,this.invokeStateHandler(t,!1,n),n;case 1:if(this.anonymousModeCapability()){o.n=2;break}return $n.warn("Anonymous mode feature is not enabled for your Nami account. Contact support@nami.ml for details."),o.a(2);case 2:if(this.inAnonymousMode()!==e){o.n=3;break}return i=e?new uo:new lo,this.invokeStateHandler(t,!1,i),o.a(2);case 3:if(!e){o.n=4;break}Qr.setAnonymousMode(e),Qr.resetDevice(),this.refetchConfig(),this.invokeStateHandler(xm.ANONYMOUS_MODE_ON,!0),o.n=6;break;case 4:return Qr.clearAnonymousMode(),qu&&qu.setInMemoryAnonymousMode(!1),r=null===(a=Qr.getNamiConfig())||void 0===a?void 0:a.namiCommands,o.n=5,l(Vu.instance.createOrUpdateDevice(hu(r)));case 5:Qr.clearAnonymousUUID(),this.refetchConfig(),this.invokeStateHandler(xm.ANONYMOUS_MODE_OFF,!0);case 6:return o.a(2)}}),null,this,null,Promise)}},{key:"inAnonymousMode",value:function(){return!!this.instance.isSDKInitialized&&Ju()}},{key:"setCustomerAttribute",value:function(e,t){if(!this.instance.isSDKInitialized)throw new no;if(Qr.setCustomerAttribute(e,t),Rs(me.PAYWALL_PERSONALIZATION)?(Jh.setCustomerAttribute({[e]:t}),$n.debug(`This customer attribute you set is now available for paywall personalization using the smart text variable: ${e}`)):$n.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.`),zm.instance.flowOpen){var n=zm.instance.currentFlow;if(n){var i=n.currentFlowStep;i&&n.executeLifecycle(i,mm)}}}},{key:"getCustomerAttribute",value:function(e){if(!this.instance.isSDKInitialized)throw new no;var t=Qr.getCustomerAttribute(e);return null!=t?Rs(me.PAYWALL_PERSONALIZATION)?$n.debug(`Found customer attribute. ${e} is available for paywall personalization on this device.`):$n.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.`):$n.warn(`No ${e} customer attribute found.`),t}},{key:"getAllCustomerAttributes",value:function(){if(!this.instance.isSDKInitialized)throw new no;return Qr.getAllCustomerAttributes()}},{key:"clearCustomerAttribute",value:function(e){if(!this.instance.isSDKInitialized)throw new no;Qr.clearCustomerAttribute(e)?(Jh.removeCustomerAttribute(e),$n.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.`)):$n.warn(`No value to clear for attribute ${e}.`)}},{key:"clearAllCustomerAttributes",value:function(){if(!this.instance.isSDKInitialized)throw new no;Qr.getAllCustomerAttributesKeys().forEach((e=>{Jh.removeCustomerAttribute(e)})),Qr.clearAllCustomerAttributes(),$n.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 no;return Qr.getCustomerJourneyState()}},{key:"deviceId",value:function(){var e,t;return this.instance.isSDKInitialized&&null!==(e=null===(t=Qr.getDevice())||void 0===t?void 0:t.id)&&void 0!==e?e:Oe}},{key:"registerJourneyStateHandler",value:function(e){if(Ws("NamiCustomerManager.registerJourneyStateHandler"))return this.instance.emitter.addListener(An,e),()=>{this.instance.emitter.removeListener(An,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,a;return T((function(r){for(;;)switch(r.p=r.n){case 0:if(this.instance.isSDKInitialized){r.n=1;break}throw t=new no,this.invokeStateHandler(xm.CUSTOMER_DATA_PLATFORM_ID_SET,!1,t),t;case 1:if(this.inAnonymousMode()){r.n=6;break}return r.p=2,r.n=3,l(Vu.instance.updateDeviceField("customer_data_platform_id",e));case 3:this.invokeStateHandler(xm.CUSTOMER_DATA_PLATFORM_ID_SET,!0),r.n=5;break;case 4:r.p=4,a=r.v,this.invokeStateHandler(xm.CUSTOMER_DATA_PLATFORM_ID_SET,!1,a);case 5:r.n=7;break;case 6:return $n.info("Unable to set CDP ID in anonymous mode",{deviceId:null===(n=Qr.getDevice())||void 0===n?void 0:n.id,anonymousMode:!0}),i=new co,this.invokeStateHandler(xm.CUSTOMER_DATA_PLATFORM_ID_SET,!1,i),r.a(2);case 7:return r.a(2)}}),null,this,[[2,4]],Promise)}},{key:"anonymousModeCapability",value:function(){if(!this.instance.isSDKInitialized)return!1;var e=Rs(me.ANONYMOUS_MODE_CAPABILITY),t=Rs(me.THIRD_PARTY_TRANSACTIONS);return e&&t}},{key:"refetchConfig",value:function(){return T((function(e){for(;;)switch(e.n){case 0:if(!this.instance.isSDKInitialized){e.n=1;break}return e.n=1,l(Promise.all([Xu.instance.fetchProducts(),Ku.instance.fetchPaywalls().then((e=>Uu.instance.fetchCampaignRules(e)))]));case 1:return e.a(2)}}),null,this,null,Promise)}}])}();Nm.instance=new Nm;var jm=function(){return p((function e(t={}){var n,i,a,r,o;h(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!==(o=t.transition)&&void 0!==o?o:"none"}),[{key:"allScreensAvailable",get:function(){return this.screens.length>0&&Xs(this.screens)}}])}(),$m=function(){function e(t,n,i,a){var r,o;h(this,e),(o=d(this,e,[null!==(r=t.flow.object)&&void 0!==r?r:{}])).stepcrumbs=[],o.branchcrumbs=[],o.activeHandoffSequence=null,o.currentScreenState=null,o.isPaused=!1,o.timerStates={},o.campaign=t,o.component=n,o.context=a,o.manager=i,o.branchcrumbs=[],o.stepcrumbs=[],o.registerResolvers(a);var s=o.findStepByType(Jc);return s&&o.forward(s.id),o}return k(e,jm),p(e,[{key:"registerResolvers",value:function(e){e&&new Tm(e),new _m,new Fm,new Rm,new Wm(this.campaign),Mm.shared.registerNamespaceResolver("Flow",(e=>{switch(e){case"Flow.stepcrumbs":return this.stepcrumbs.map((e=>e.id));case"Flow.branchcrumbs":return this.branchcrumbs;default:return}}))}},{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:"finished",value:function(){this.manager.finishFlow()}},{key:"back",value:function(){this.previousStepAvailable?this.backToPreviousScreenStep():$n.debug("No previous step available")}},{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=Vs(n.screen);return r&&this.component.flowNavigateToScreen(r,{transition:this.transition,direction:"backward"}),void(this.currentScreenState=null!==(i=null===(a=Jh.currentProvider)||void 0===a?void 0:a.state)&&void 0!==i?i:null)}}$n.warn("No previous screen step found to return to")}else $n.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(t.type){case Jc:case em:return this.stepcrumbs.push(t),void this.executeLifecycle(t,am);case Zc:return void this.handleBranchStep(t);case Qc:return void this.handleScreenStep(t);case tm:return}}else $n.error(`No step found with id: ${e}`)}},{key:"pause",value:function(){var e;this.isPaused?$n.info("Flow is already paused"):(this.isPaused=!0,this.pausedStepID=null===(e=this.currentFlowStep)||void 0===e?void 0:e.id,$n.info("Flow paused"))}},{key:"resumeFromPause",value:function(){if(this.isPaused)if(this.isPaused=!1,this.pausedStepID){var e=this.pausedStepID;this.pausedStepID=void 0,$n.info(`Flow resumed from step ${e}`),this.forward(e)}else $n.warn("No step to resume from");else $n.info("Flow is not paused")}},{key:"executeLifecycle",value:function(e,t,n){var i=e.actions[t];i&&this.executeFullLifecycles(i,n)}},{key:"lifecycles",value:function(e){if(this.currentFlowStep){var t=this.currentFlowStep.actions[e];if(t)return t;$n.info(`No actions found for button ${e} on step ${this.currentFlowStep.id}`)}}},{key:"triggerActions",value:function(e,t,n){var i=this.lifecycles(e);i&&(this.currentButton=t,this.executeFullLifecycles(i,n))}},{key:"executeFullLifecycles",value:function(e,t){for(var n,i=g(e);!(n=i()).done;){var a=n.value;[a.before,a.action,a.after].forEach((e=>null==e?void 0:e.forEach((e=>this.shouldRun(e)&&this.performAction(e,t)))))}}},{key:"triggerBeforeActions",value:function(e,t,n){var i=this.lifecycles(e);if(i){this.currentButton=t;for(var a,r=g(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=g(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){return!e.conditions||e.conditions.every((e=>Mm.shared.evaluate(e)))}},{key:"performAction",value:function(e,t){var n;if(this.currentFlowStep){var i=(null!==(n=e.parameters)&&void 0!==n&&n.delay?+e.parameters.delay:0)||0,a=n=>{var i,a,r,o,s,u,l;if((null===(i=this.currentFlowStep)||void 0===i?void 0:i.id)===n)switch(e.function){case qc.BACK:this.back();break;case qc.NEXT:null!==(a=e.parameters)&&void 0!==a&&a.step?this.forward(e.parameters.step):this.next();break;case qc.NAVIGATE:var d;if(null!==(r=e.parameters)&&void 0!==r&&r.step)(null===(d=this.previousFlowStep)||void 0===d?void 0:d.id)===e.parameters.step?this.back():this.forward(e.parameters.step);else this.next();break;case qc.FINISHED:case qc.DISMISS:this.finished();break;case qc.EXIT:var h=this.steps.find((e=>e.type===em));h&&this.forward(h.id);break;case qc.PAUSE:this.pause();break;case qc.RESUME:this.resumeFromPause();break;case qc.HANDOFF:if(null!==(o=e.parameters)&&void 0!==o&&o.handoffTag)if(this.manager.handoffStepHandler)if(e.parameters.handoffData)$n.debug(`Invoking handoffStepHandler with ${e.parameters.handoffTag} ${JSON.stringify(e.parameters.handoffData)}`),this.manager.handoffStepHandler(e.parameters.handoffTag,e.parameters.handoffData);else if(t)$n.debug(`Invoking handoffStepHandler with ${e.parameters.handoffTag} ${JSON.stringify(t)}`),this.manager.handoffStepHandler(e.parameters.handoffTag,t);else if(e.parameters.handoffFormId){var c=this.getFormData();e.parameters.handoffTag===nm?this.flowHandoffFormSequence():this.manager.handoffStepHandler(e.parameters.handoffTag,c)}else $n.debug(`Invoking handoffStepHandler with ${e.parameters.handoffTag} and no data`),this.manager.handoffStepHandler(e.parameters.handoffTag);else $n.debug("No handoffStepHandler found",e);break;case qc.LOG:var m;if(null!==(s=e.parameters)&&void 0!==s&&s.eventName)$n.info(`logEvent → ${e.parameters.eventName}`);else $n.warn(`Missing 'eventName' in logEvent action ${null!==(m=e.id)&&void 0!==m?m:"unknown"}`);break;case qc.TRACK:var f;if(null!==(u=e.parameters)&&void 0!==u&&u.eventName)$n.info(`trackEvent → ${e.parameters.eventName}`);else $n.warn(`Missing 'eventName' in logEvent action ${null!==(f=e.id)&&void 0!==f?f:"unknown"}`);break;case qc.SET_VIDEO:null!==(l=e.parameters)&&void 0!==l&&l.name&&e.parameters.url?Jh.setAppSuppliedVideoDetails({name:e.parameters.name,url:e.parameters.url}):$n.warn("Missing name, url for setting video details");break;case qc.BLOCK_BACK:var v,p=null===(v=e.parameters)||void 0===v?void 0:v.step,g=p?this.getStep(p):void 0;g?g.allow_back_to=!1:this.currentFlowStep?this.currentFlowStep.allow_back_to=!1:$n.warn("Missing step for blocking back");break;case qc.FLOW_EVENT:var y,b=new Lm(this.manager),w=Object.fromEntries(Object.entries(null!==(y=e.parameters)&&void 0!==y?y:{}).map((([e,t])=>[e,b.interpolateDeep(t)])));this.manager.eventHandler?this.manager.eventHandler(w):$n.warn("Missing event handler",w);break;case qc.FLOW_ENABLED:Jh.setUserInteractionEnabled(!0);break;case qc.FLOW_DISABLED:Jh.setUserInteractionEnabled(!1);break;case qc.SET_TAGS:e.parameters&&(Jh.setUserTags(e.parameters),Object.entries(e.parameters).forEach((([e,t])=>{Nm.setCustomerAttribute(e,t)})));break;default:$n.warn(`Missing action handler for ${e.function}`,e)}else $n.debug(`Skipped action for stale flow step ${n}`)};i?setTimeout(a.bind(this,this.currentFlowStep.id),i):a(this.currentFlowStep.id)}else $n.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=g(this.steps.slice(t+1));!(n=i()).done;){var a=n.value;if(this.isStepActive(a))return a}$n.debug(`No active next step found after ${e.id}`)}else $n.error(`Could not find next step for step ${e.id}`)}else $n.error("Next step not found")}},{key:"handleScreenStep",value:function(e){var t,n=Vs(null!==(t=e.screen)&&void 0!==t?t:"");e.screen&&n&&this.campaign?(this.stepcrumbs.push(e),this.component.flowNavigateToScreen(n,{transition:this.transition,direction:"forward"})):$n.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=g(r);!(o=s()).done;){var u=o.value;if(u.action)for(var l,d=g(u.action);!(l=d()).done;){var h,c,m=l.value;if(this.shouldRun(m))return this.branchcrumbs.push(a),null===(h=u.before)||void 0===h||h.forEach((e=>{this.performAction(e)})),u.action.forEach((e=>{this.shouldRun(e)&&this.performAction(e)})),void(null===(c=u.after)||void 0===c||c.forEach((e=>{this.performAction(e)})))}else $n.warn(`No actions defined for branch tag ${a}`)}}$n.warn(`No matching branch condition matched for step ${e.id}`)}},{key:"getFormData",value:function(){var e,t;return y({},null!==(e=null===(t=Jh.currentProvider)||void 0===t||null===(t=t.state)||void 0===t?void 0:t.formStates)&&void 0!==e?e:{})}},{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).sort();if(0!==n.length){var i=n.filter((e=>!0===t[e]));if(0===i.length)return $n.info("No eligible handoff keys after filtering"),void this.manager.resume();this.activeHandoffSequence={formStates:y({},t),remainingKeys:[...i]},this.resumeNextHandoff()}else $n.warn("formStates is empty, no handoffs to perform")}else $n.warn("No formStates available for handoff sequence")}},{key:"resumeNextHandoff",value:function(){var e,t,n=this.activeHandoffSequence;if(!n)return $n.warn("No active handoff sequence to resume"),void this.manager.resume();if(0===n.remainingKeys.length)return $n.info("All handoffs in the sequence are complete"),this.activeHandoffSequence=null,void this.manager.resume();var i=n.remainingKeys.shift(),a=n.formStates[i];$n.debug(`Starting handoff for ${i} → ${String(a)}`),this.activeHandoffSequence=n;var r=`${i}`;null===(e=(t=this.manager).handoffStepHandler)||void 0===e||e.call(t,r,void 0)}}])}(),zm=function(){function e(){h(this,e),this.flowOpen=!1,this.lastAnimatedFlowProgress=new Map,this.navGraphCache=new WeakMap}return p(e,[{key:"resume",value:function(){e.resume()}},{key:"presentFlow",value:function(e,t,n){var i=new $m(e,t,this,n);return this.flowOpen=!0,this.currentFlow=i,i}},{key:"finishFlow",value:function(){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===Qc));if(0===t.length)return 0;var n=this.currentFlow.stepcrumbs.filter((e=>e.type===Qc));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=g(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 $n.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=g(u);!(l=d()).done;){var h=l.value;o(h,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[rm];if(!i)return null;for(var a,r=g(i);!(a=r()).done;)for(var o,s,u=g(null!==(o=a.value.action)&&void 0!==o?o:[]);!(s=u()).done;){var l,d=s.value;if((d.function===qc.NAVIGATE||d.function===qc.NEXT)&&null!=(null===(l=d.parameters)||void 0===l?void 0:l.delay)){var h=d.parameters.delay,c=Number(h);if(!isNaN(c)&&c>0)return c/1e3}}return null}}],[{key:"instance",get:function(){return e._instance||(e._instance=new e),e._instance}},{key:"registerStepHandoff",value:function(e){this.instance.handoffStepHandler=e}},{key:"registerEventHandler",value:function(e){this.instance.eventHandler=e}},{key:"resume",value:function(){var t=e.instance,n=t.flowOpen,i=t.currentFlow;if(n&&i&&i.currentFlowStep){if(i.activeHandoffSequence)return $n.debug(`Resuming flow at handoff sequence ${i.currentFlowStep.id}`),void i.resumeNextHandoff();$n.debug(`Resuming flow at step ${i.currentFlowStep.id}`),i.executeLifecycle(i.currentFlowStep,"__resume__")}else $n.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?($n.debug(`Finishing flow programmatically at step ${i.currentFlowStep.id}`),i.finished()):$n.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():$n.warn("This flow cannot be paused"):$n.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()}}])}();var Bm=e=>{var t;return T((function(n){for(;;)if(0===n.n)return t=new Set(Array.from(document.fonts.values()).map((e=>e.family))),e.forEach((e=>{var n=Hm(e);if(!t.has(n)){var i=new FontFace(n,`url(${e.file})`);document.fonts.add(i)}})),n.a(2,document.fonts.ready.then())}),null,null,null,Promise)};function Hm(e){return`${e.family}-${e.style}`.replace(/ /g,"")}function Um(e,t,n){var i,a,r,o,s,u,l,d;if("undefined"==typeof window||!e||!t)return $n.debug("Swipe detection is not supported in this environment."),{destroy(){},updateOptions(){}};var h={minDistance:null!==(i=null==n?void 0:n.minDistance)&&void 0!==i?i:30,maxDuration:null!==(a=null==n?void 0:n.maxDuration)&&void 0!==a?a:600,lockAxis:null===(r=null==n?void 0:n.lockAxis)||void 0===r||r,preventScrollOnSwipe:null!==(o=null==n?void 0:n.preventScrollOnSwipe)&&void 0!==o&&o,pointerTypes:null!==(s=null==n?void 0:n.pointerTypes)&&void 0!==s?s:["touch"],passiveListeners:null===(u=null==n?void 0:n.passiveListeners)||void 0===u||u,axisHint:null!==(l=null==n?void 0:n.axisHint)&&void 0!==l?l:"y",edgeLeakThreshold:null!==(d=null==n?void 0:n.edgeLeakThreshold)&&void 0!==d?d:24},c=e.style.touchAction;h.preventScrollOnSwipe&&(e.style.touchAction="none");var m=null,f=0,v=0,p=0,g=0,y=0,b=null,w=null,k=!1,S=!1,E=!1,M=e=>{try{var t=window.getComputedStyle(e);if(!t)return!1;var n=t.overflowY;if("auto"!==n&&"scroll"!==n)return!1;var i=e;return i.scrollHeight>i.clientHeight}catch(e){return!1}},P=e=>h.pointerTypes.includes(e.pointerType),T=t=>{var n=t.composedPath?t.composedPath()[0]:t.target;if(P(t)&&null===m){m=t.pointerId,f=p=t.clientX,v=g=t.clientY,y=performance.now(),b=null,E=!1,k=!1,S=!1,(w="y"===h.axisHint?((e,t)=>{for(var n=e;n&&n!==t&&n instanceof HTMLElement;){var i,a;if(M(n))return n;n=n.parentElement||(null!==(i=null===(a=n.parentNode)||void 0===a?void 0:a.host)&&void 0!==i?i:null)}return null})(n,e):null)||(S=!0);try{var i;null==e||null===(i=e.setPointerCapture)||void 0===i||i.call(e,t.pointerId)}catch(e){try{var a;null==n||null===(a=n.setPointerCapture)||void 0===a||a.call(n,t.pointerId)}catch(e){}}}},_=e=>{if(e.pointerId===m&&P(e)){if(p=e.clientX,g=e.clientY,h.lockAxis&&!b){var n=Math.abs(p-f),i=Math.abs(g-v);(n>2||i>2)&&(b=i>=n?"y":"x")}if("y"===h.axisHint&&("y"===b||!h.lockAxis)){var a=g-v,r=a<0?"up":"down",o=Math.abs(a),s=performance.now()-y,u=o/Math.max(s,1),l=o>=h.minDistance||u>.5;if(w)if(l)S=!0;else if(((e,t)=>!!e&&("down"===t?e.scrollTop>0:e.scrollTop+e.clientHeight<e.scrollHeight-1))(w,r)){if(!(("down"===r&&w.scrollTop<=50||"up"===r&&w.scrollTop+w.clientHeight>=w.scrollHeight-50)&&u>.3))return void(k=!0);S=!0}else S=!0;var d=!w||o>=h.edgeLeakThreshold;if(!E&&!k&&S&&d&&o>=h.minDistance){E=!0;var c=performance.now(),M={direction:"up"===r?"up":"down",distanceX:p-f,distanceY:a,absX:Math.abs(p-f),absY:o,duration:c-y,velocity:o/Math.max(c-y,1),startX:f,startY:v,endX:p,endY:g,startedAt:y,endedAt:c,originalEvent:e};t(M)}}}},D=e=>{if(e.pointerId===m)if(P(e))if(w)A();else if(E||k)A();else{var n,i=performance.now(),a=i-y,r=p-f,o=g-v,s=Math.abs(r),u=Math.abs(o),l="x"===(n=h.lockAxis&&b?b:"x"===h.axisHint?"x":"y"===h.axisHint?"y":s>=u?"x":"y")?s:u,d=a<=h.maxDuration,c=h.minDistance;if(w&&"y"===n&&S&&(c+=h.edgeLeakThreshold),d&&l>=c){var M;M="x"===n?r>0?"right":"left":o>0?"down":"up";var T=l/Math.max(a,1);t({direction:M,distanceX:r,distanceY:o,absX:s,absY:u,duration:a,velocity:T,startX:f,startY:v,endX:p,endY:g,startedAt:y,endedAt:i,originalEvent:e})}A()}else A()},A=()=>{m=null,b=null,y=0,w=null,S=!1,k=!1,E=!1},x=!!h.passiveListeners&&{passive:!0},C=h.passiveListeners?{passive:!0,capture:!0}:{capture:!0};e.addEventListener("pointerdown",T,C),e.addEventListener("pointermove",_,x),e.addEventListener("pointerup",D,x),e.addEventListener("pointercancel",D,x),e.addEventListener("lostpointercapture",D,x);return{destroy:()=>{e.removeEventListener("pointerdown",T,C),e.removeEventListener("pointermove",_,x),e.removeEventListener("pointerup",D,x),e.removeEventListener("pointercancel",D,x),e.removeEventListener("lostpointercapture",D,x),h.preventScrollOnSwipe&&(e.style.touchAction=c),A()},updateOptions:t=>{Object.assign(h,t),"boolean"==typeof t.preventScrollOnSwipe&&(t.preventScrollOnSwipe?e.style.touchAction="none":e.style.touchAction=c)}}}var Gm,Vm,Xm,Km,Ym,qm,Jm,Qm,Zm,ef,tf,nf=e=>e,af=function(){function e(t,n,i){var a;return h(this,e),(a=d(this,e)).pages=[],a.currentOffset=0,a.presentationStyle="fullscreen",a.formFactor=cu(),a.timeSpentOnPaywall=0,a.animation={transition:"none",direction:"forward"},a._originalBodyStyles={},a._originalDocumentStyles={},a._savedScrollY=0,a._sheetDragStartY=0,a._sheetIsDragging=!1,a._dismissThreshold=100,a.type=t,a.value=n,a.context=i,a.setPaywallData(),M(a,a)}return k(e,n),p(e,[{key:"setPaywallData",value:function(){var e=Au(this.value,this.type);this.paywall=e.paywall,this.campaign=e.campaign}},{key:"getPresentationStyle",value:function(e){var t,n,i=null==e||null===(t=e.template)||void 0===t||null===(t=t.initialState)||void 0===t?void 0:t.presentation_style;return(n=i)&&pc.has(n)?"sheet"===n?"fullscreen":n:"fullscreen"}},{key:"isHalfSheet",get:function(){return"compact_sheet"===this.presentationStyle}},{key:"connectedCallback",value:function(){var t;x(e,"connectedCallback",this)([]),null!==(t=window.TVJS)&&void 0!==t&&t.DirectionalNavigation&&(window.TVJS.DirectionalNavigation.focusRoot=this),document.addEventListener("keydown",this.handleKeyDownEvent.bind(this)),this._swipeHandler=Um(this,this.handleSwipeEvent.bind(this),{axisHint:"y",lockAxis:!0,minDistance:25,edgeLeakThreshold:15,preventScrollOnSwipe:!1,pointerTypes:["touch"]}),this.presentationStyle=this.getPresentationStyle(this.paywall),this.setOriginalStyles()}},{key:"disconnectedCallback",value:function(){var t,n;x(e,"disconnectedCallback",this)([]),Qr.clearLaunchId(),null!==(t=window.TVJS)&&void 0!==t&&t.DirectionalNavigation&&(window.TVJS.DirectionalNavigation.focusRoot=document.body),document.removeEventListener("keydown",this.handleKeyDownEvent.bind(this)),Hu.getInstance().removeAllListeners(Pn),this.restoreStyles(),null===(n=this._halfSheetAbortController)||void 0===n||n.abort(),this._swipeHandler.destroy()}},{key:"setOriginalStyles",value:function(){"television"===this.formFactor&&(this._originalBodyStyles.overflow=document.body.style.overflow,document.body.style.overflow="hidden"),this._originalBodyStyles.background=document.body.style.background,"phone"===this.formFactor&&(this._originalBodyStyles["overscroll-behavior"]=document.body.style.overscrollBehavior?document.body.style.overscrollBehavior:null,this._originalDocumentStyles["overscroll-behavior"]=document.documentElement.style.overscrollBehavior?document.documentElement.style.overscrollBehavior:null,document.body.style.overscrollBehavior="none",document.documentElement.style.overscrollBehavior="none",this.isHalfSheet||(this._originalBodyStyles.overflow=document.body.style.overflow,document.body.style.overflow="hidden")),this.isHalfSheet&&(this._savedScrollY=window.scrollY,this._originalBodyStyles.position=document.body.style.position||null,this._originalBodyStyles.top=document.body.style.top||null,this._originalBodyStyles.width=document.body.style.width||null,document.body.style.position="fixed",document.body.style.top=`-${this._savedScrollY}px`,document.body.style.width="100%")}},{key:"restoreStyles",value:function(){Object.entries(this._originalBodyStyles).forEach((([e,t])=>{null!==t?document.body.style.setProperty(e,t):document.body.style.removeProperty(e)})),Object.entries(this._originalDocumentStyles).forEach((([e,t])=>{null!==t?document.documentElement.style.setProperty(e,t):document.documentElement.style.removeProperty(e)})),this._savedScrollY>0&&(window.scrollTo(0,this._savedScrollY),this._savedScrollY=0)}},{key:"handleKeyDownEvent",value:function(e){!this.flow||10009!==e.keyCode&&"Backspace"!==e.key&&"GoBack"!==e.key||this.flow.triggerActions(cm)}},{key:"handleSwipeEvent",value:function({direction:e}){var t;if("down"===e)null===(t=this.flow)||void 0===t||t.triggerActions("__swipe_down__");else if("up"===e){var n;null===(n=this.flow)||void 0===n||n.triggerActions("__swipe_up__")}}},{key:"setupHalfSheetDragTracking",value:function(){var e,t,n;null===(e=this._halfSheetAbortController)||void 0===e||e.abort(),this._halfSheetAbortController=new AbortController;var i=this._halfSheetAbortController.signal,a=null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector(".nami-half-sheet-container"),r=null===(n=this.shadowRoot)||void 0===n?void 0:n.querySelector(".nami-half-sheet-content");if(a&&r){a.addEventListener("touchstart",(e=>{r.scrollTop>0||(this._sheetDragStartY=e.touches[0].clientY,this._sheetIsDragging=!0)}),{passive:!0,signal:i}),a.addEventListener("touchmove",(e=>{if(this._sheetIsDragging){var t=e.touches[0].clientY-this._sheetDragStartY;t>0&&(a.style.transform=`translateY(${t}px)`,a.style.transition="none",e.preventDefault())}}),{passive:!1,signal:i}),a.addEventListener("touchend",(()=>{if(this._sheetIsDragging){this._sheetIsDragging=!1;var e,t,n=a.style.transform.match(/translateY\((\d+(?:\.\d+)?)px\)/);if((n?parseFloat(n[1]):0)>this._dismissThreshold)if(null!==(e=null===(t=this.flow)||void 0===t?void 0:t.currentStepHasHoistedPrimaryActions("__swipe_down__"))&&void 0!==e&&e){var i;a.style.transform="translateY(0)",a.style.transition="transform 0.2s ease-out",null===(i=this.flow)||void 0===i||i.triggerActions("__swipe_down__")}else{var r;a.style.transform="translateY(100%)",a.style.transition="transform 0.2s ease-in";var o=null===(r=this.shadowRoot)||void 0===r?void 0:r.querySelector(".nami-half-sheet-backdrop");o&&o.classList.add("nami-dismissing"),setTimeout((()=>{var e;null===(e=this.flow)||void 0===e||e.finished()}),200)}else a.style.transform="translateY(0)",a.style.transition="transform 0.2s ease-out"}}),{signal:i})}}},{key:"setupHalfSheetFocusTrap",value:function(){var e,t,n=null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector(".nami-half-sheet-container");if(n){n.focus();var i=null===(t=this._halfSheetAbortController)||void 0===t?void 0:t.signal;n.addEventListener("keydown",(e=>{if("Tab"===e.key){var t=n.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');if(0!==t.length){var i,a,r=t[0],o=t[t.length-1];if(e.shiftKey)document.activeElement!==r&&(null===(i=this.shadowRoot)||void 0===i?void 0:i.activeElement)!==r||(e.preventDefault(),o.focus());else document.activeElement!==o&&(null===(a=this.shadowRoot)||void 0===a?void 0:a.activeElement)!==o||(e.preventDefault(),r.focus())}}}),i?{signal:i}:void 0)}}},{key:"firstUpdated",value:function(){this.timeSpentOnPaywall=Date.now(),Bs(this.campaign)&&(this.flow=zm.instance.presentFlow(this.campaign,this,this.context)),this.isHalfSheet&&this.updateComplete.then((()=>{this.setupHalfSheetDragTracking(),this.setupHalfSheetFocusTrap()}))}},{key:"updated",value:function(t){x(e,"updated",this)([t]),this.isHalfSheet&&t.has("presentationStyle")&&(this.setupHalfSheetDragTracking(),this.setupHalfSheetFocusTrap())}},{key:"getAnimationStyles",value:function(e){var t="backward"===this.animation.direction?-1:1;switch(this.animation.transition){case"verticalSlide":return`transform: translateY(${100*(e-this.currentOffset)*t}vh);`;case"slide":return`transform: translateX(${100*(e-this.currentOffset)*t}vw);`;case"fade":return`opacity: ${e===this.currentOffset?1:0};`;default:return""}}},{key:"updatePages",value:function(e){var t;return T((function(n){for(;;)switch(n.n){case 0:if(0!==this.pages.length&&"none"!==this.animation.transition){n.n=1;break}return this.pages=[e],n.a(2);case 1:if((null==(t=this.pages[this.pages.length-1])?void 0:t.id)!==e.id){n.n=2;break}return n.a(2);case 2:return this.pages=[t,e],this.currentOffset=0,n.n=3,l(this.updateComplete);case 3:requestAnimationFrame((()=>{this.currentOffset=1,setTimeout((()=>{this.pages=[e],this.currentOffset=0,this.paywall=e}),250)}));case 4:return n.a(2)}}),null,this,null,Promise)}},{key:"flowNavigateToScreen",value:function(e,t){var n,i,a,r;return T((function(o){for(;;)switch(o.n){case 0:if(null!==(n=this.flow)&&void 0!==n&&n.previousFlowStep&&this.flow.executeLifecycle(this.flow.previousFlowStep,om),a=this.presentationStyle,r=this.getPresentationStyle(e),"fullscreen"!==a||"compact_sheet"!==r){o.n=1;break}console.warn("Unsupported transition: fullscreen → compact_sheet. Presenting as fullscreen."),o.n=4;break;case 1:if("compact_sheet"!==a||"fullscreen"!==r&&"sheet"!==r){o.n=3;break}return o.n=2,l(this.animateHalfSheetExpand());case 2:this.presentationStyle="fullscreen",o.n=4;break;case 3:this.presentationStyle=r;case 4:return this.animation=t,o.n=5,l(this.updatePages(e));case 5:null!==(i=this.flow)&&void 0!==i&&i.currentFlowStep&&this.flow.executeLifecycle(this.flow.currentFlowStep,rm);case 6:return o.a(2)}}),null,this,null,Promise)}},{key:"animateHalfSheetExpand",value:function(){var e,t;return T((function(n){for(;;)switch(n.n){case 0:if(t=null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector(".nami-half-sheet-container")){n.n=1;break}return n.a(2);case 1:return t.classList.add("nami-expanding"),n.n=2,l(new Promise((e=>setTimeout(e,300))));case 2:return n.a(2)}}),null,this,null,Promise)}},{key:"getSelectedSlideIndexForCurrentCarousel",value:function(){return Jh.getSelectedSlideIndex()}},{key:"renderFlow",value:function(){return"undefined"==typeof document?t(Gm||(Gm=nf``)):this.isHalfSheet?this.renderHalfSheet():t(Vm||(Vm=nf`
92
92
  <div class="nami-flow-container">
93
93
  ${0}
94
94
  </div>
@@ -88,7 +88,7 @@
88
88
  padding-top: 0;
89
89
  padding-bottom: 0;
90
90
  }
91
- `,$m=e=>(t,n)=>{void 0!==n?n.addInitializer((()=>{customElements.define(e,t)})):customElements.define(e,t)},jm={attribute:!0,type:String,converter:Gh,reflect:!1,hasChanged:Vh},zm=(e=jm,t,n)=>{const{kind:i,metadata:a}=n;let r=globalThis.litPropertyMetadata.get(a);if(void 0===r&&globalThis.litPropertyMetadata.set(a,r=new Map),"setter"===i&&((e=Object.create(e)).wrapped=!0),r.set(n.name,e),"accessor"===i){const{name:i}=n;return{set(n){const a=t.get.call(this);t.set.call(this,n),this.requestUpdate(i,a,e)},init(t){return void 0!==t&&this.C(i,void 0,e,t),t}}}if("setter"===i){const{name:i}=n;return function(n){const a=this[i];t.call(this,n),this.requestUpdate(i,a,e)}}throw Error("Unsupported decorator location: "+i)};function Hm(e){return(t,n)=>"object"==typeof n?zm(e,t,n):((e,t,n)=>{const i=t.hasOwnProperty(n);return t.constructor.createProperty(n,e),i?Object.getOwnPropertyDescriptor(t,n):void 0})(e,t,n)}function Bm(e){return Hm({...e,state:!0,attribute:!1})}function Um(e){return!e||"object"==typeof e&&0==Object.keys(e).length}const Gm="entry",Vm="screen",Xm="branch",Km="exit",Ym="unknown";var qm;!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.PAUSE="flowPause",e.RESUME="flowResume"}(qm||(qm={}));const Jm="__handoff_sequence__",Qm="__buy_sku__",Zm="__default__",ef="__appear__",tf="__disappear__",nf="__login_success__",af="__login_failure__",rf="__logout_success__",of="__logout_failure__",sf="__purchase_success__",lf="__remoteback__",df="__tag_update__",uf="and",cf="or",hf="i_contains",mf="equals",ff="i_equals",pf="not_equals",gf="not_i_equals",vf="not_contains",yf="set",bf="notSet";class wf{constructor(){this.resolvers=new Map,this.namespaceResolvers=new Map}static get shared(){return wf.instance||(wf.instance=new wf),wf.instance}registerNamespaceResolver(e,t){this.namespaceResolvers.set(e,t)}resetResolvers(){this.resolvers.clear()}evaluate(e){const t=e.filter??[];if(0===t.length)return!0;const n=t.map((e=>this.evaluateFilter(e)));switch(e.operator){case uf:return n.every((e=>e));case cf:return n.some((e=>e));default:return n.every((e=>e))}}evaluateOrdered(e){if(!e)return!0;const t=e.filter??[];if(0===t.length)return!0;switch(e.operator){case uf:for(const e of t)if(!this.evaluateFilter(e))return!1;return!0;case cf:for(const e of t)if(this.evaluateFilter(e))return!0;return!1;default:for(const e of t)if(!this.evaluateFilter(e))return!1;return!0}}evaluateFilter(e){const t=this.resolve(e.identifier);if(e.operator===yf)return null!=t;if(e.operator===bf)return null==t;if(null==t){return!![pf,gf,vf].includes(e.operator)}switch(e.operator){case hf:if(Array.isArray(t)){return e.values.some((e=>t.some((t=>0===t.localeCompare(e,void 0,{sensitivity:"accent"})))))}return this.log("Resolved value is not an array of strings for i_contains."),!1;case mf:return e.values.some((e=>{if("string"==typeof t)return t===e;if("boolean"==typeof t){const n="true"===e.toLowerCase();return t===n}return this.log("Unsupported type for equals comparison: "+typeof t),!1}));case ff:return e.values.some((e=>{if("string"==typeof t){return 0===t.localeCompare(e,void 0,{sensitivity:"accent"})}if("boolean"==typeof t){const n="true"===e.toLowerCase();return t===n}return this.log("Unsupported type for i_equals comparison: "+typeof t),!1}));case pf:return e.values.every((e=>"string"!=typeof t||t!==e));case gf:return e.values.every((e=>"string"!=typeof t||0!==t.localeCompare(e,void 0,{sensitivity:"accent"})));case vf:return e.values.every((e=>"string"!=typeof t||!t.includes(e)));default:return this.log(`Unsupported operator: ${e.operator}`),!1}}resolve(e){const t=this.resolveRaw(e);if(void 0!==t)return t;const n=e.lastIndexOf(".");if(-1!==n){const t=e.slice(0,n),i=e.slice(n+1),a=this.resolveRaw(t);return void 0!==a?this.extractProperty(i,a):void this.log(`Could not resolve base identifier: ${t}`)}}resolveRaw(e){const t=[...this.namespaceResolvers.keys()].sort(((e,t)=>t.length-e.length));for(const n of t)if(e.startsWith(n)){const t=this.namespaceResolvers.get(n);if(t)return t(e)}}extractProperty(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}`)}log(e){Je.debug(`[NamiConditionEvaluator] ${e}`)}}class kf{constructor(){}register(){wf.shared.registerNamespaceResolver(this.namespace,(e=>{const t=e.replace(new RegExp(`^${this.namespace}\\.`),"");return this.resolveValue(t)}))}resolveKeyPath(e,t){const n=e.replace(/\[(\w+)\]/g,".$1").split(".").filter(Boolean);let i=t;for(const e of n){if(null==i||"object"!=typeof i)return;i=i[e]}return i}}class Sf extends kf{constructor(e){super(),this.namespace="LaunchContext",this.context=e,this.register()}resolveValue(e){if(e.startsWith("customAttributes.")){const t=e.substring(17);return this.resolveKeyPath(t,this.context.customAttributes)}if(e.startsWith("customObject.")){const t=e.substring(13);return this.resolveKeyPath(t,this.context.customObject)}return this.resolveKeyPath(e,{customAttributes:this.context.customAttributes,customObject:this.context.customObject,productGroups:this.context.productGroups})}}class _f extends kf{constructor(){super(),this.namespace="Device";const e=Intl.DateTimeFormat().resolvedOptions().locale.split("-")[1]||"",t=Intl.DateTimeFormat().resolvedOptions().timeZone,n=kl();this.context={osName:n.os_name,osVersion:n.os_version,appVersion:n.extended_platform_version,sdkVersion:n.sdk_version,deviceModel:n.device_model,screenWidth:window.innerWidth,screenHeight:window.innerHeight,formFactor:n.form_factor,tvQuality:this.tvQuality(n.form_factor??"desktop"),tvResolution:this.tvResolution(n.form_factor??"desktop"),screenSize:this.screenSizeTier(n.form_factor??"desktop"),language:n.language,country:e,timezone:t},this.register()}screenSizeTier(e){const t=window.screen.width,n=window.screen.height,i=window.devicePixelRatio||1,a=Math.round(t*i),r=Math.round(n*i),o=Math.max(a,r);switch(e){case"phone":return o<1136?"tiny":o<1334?"small":o<1920?"medium":o<2560?"large":"huge";case"tablet":return o<2048?"medium":o<2732?"large":"huge";case"television":return o<1920?"medium":o<3840?"large":"huge";case"desktop":return o<1440?"small":o<2560?"medium":o<3840?"large":"huge";default:return"medium"}}tvQuality(e){if("television"!==e)return"";const t=window.screen.width,n=window.screen.height,i=window.devicePixelRatio||1,a=Math.round(t*i),r=Math.round(n*i),o=Math.max(a,r),s=Math.min(a,r);return o>=3840||s>=2160?"4K":o>=1920||s>=1080?"1080p":"720p"}tvResolution(e){if("television"!==e)return"";const t=window.screen.width,n=window.screen.height,i=window.devicePixelRatio||1,a=Math.round(t*i),r=Math.round(n*i),o=Math.max(a,r),s=Math.min(a,r);return s<720&&o<1280?"SD":s>=720&&s<1080&&o>=1280&&o<1920?"720p":s>=1080&&s<1440&&o>=1920&&o<2560?"1080p":s>=1440&&s<2160&&o>=2560&&o<3840?"1440p":s>=2160&&s<3e3&&o>=3840&&o<5e3?"4K":s>=3e3&&o>=5e3?"8K":"Unknown"}resolveValue(e){return this.resolveKeyPath(e,this.context)}}const Mf=[/(^|_)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];class Ef{constructor(){this.params={},"undefined"!=typeof window&&this.setSearchParams()}static get instance(){return Ef._instance||(Ef._instance=new Ef),Ef._instance}static refresh(){"undefined"!=typeof window&&this.instance.setSearchParams()}setSearchParams(){this.params=this.extractSafeParams()}safeValue(e){if(!e)return null;try{const 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{return null}}extractSafeParams(){const e=window.location,t={},n=new Set;try{const i=new URLSearchParams(e.search),a=(e,i)=>{const a=(e=>e.replace(/([a-z])([A-Z])/g,"$1_$2").replace(/[-\s]/g,"_").toLowerCase())(e);if(n.size>=10)return;if((e=>Mf.some((t=>t.test(e))))(a))return;const r=this.safeValue(i);r&&(t[a]=r,n.add(a))};for(const[e,t]of i.entries())a(e,t)}catch{}return t}}Ef._instance=null;const Pf=()=>Ef.instance.params,Tf=/\{\{\s*([^}]+?)\s*\}\}/g;class xf{constructor(e){this.flowManager=e,this.urlParams=Pf()}resolve(e){const t=this.flowManager.currentFlow,n=t?.component;if(e.startsWith("launchContext.")){const t=this.flowManager.currentFlow?.context;if(t){const n=e.substring(14),i=new Sf(t).resolveValue(n);return i?.toString()}}else switch(e){case"campaignId":return n?.campaign?.rule;case"campaignName":return n?.campaign?.name;case"campaignLabel":case"campaignPlacement":return n?.campaign?.value??void 0;case"campaignSegment":case"campaignSegmentId":return n?.campaign?.segment;case"campaignExternalSegment":case"campaignExternalSegmentId":return n?.campaign?.external_segment??void 0;case"pageName":return n?.paywall?.name;case"pageId":return n?.paywall?.id;case"flowName":return t?.name;case"flowId":return t?.id;case"objectId":return n?.campaign?.flow?.object_id;case"stepName":return t?.currentFlowStep?.name;case"buttonText":return t?.currentButton?.firstTextValue();case"slideNumber":{const e=n?.getSelectedSlideIndexForCurrentCarousel();return null!=e?`${e+1}`:void 0}default:return}}interpolateLiquidVariables(e){return e.replace(Tf,((e,t)=>{const n=this.resolve(t)??this.urlParams[t];return null!=n?n:""}))}interpolateDeep(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])=>({...e,[t]:this.interpolateDeep(n)})),{}):e}}class Af extends kf{constructor(){super(),this.namespace="urlParams",this.context=Pf(),this.register()}resolveValue(e){return Je.debug("[URLParamsResolver]","Resolving keyPath",e),this.resolveKeyPath(e,this.context)}}class Cf extends kf{getContextProvider(){const e=oh.providers;if(0===e.length)return;const t=e.find((e=>e.flow));return t||e[e.length-1]}constructor(){super(),this.namespace="state",this.register()}resolveValue(e){const t=this.getContextProvider();if(t){if(e.startsWith("formStates.")){const n=e.substring(11);return t.getCurrentFormId(n)}return this.resolveKeyPath(e,t.state)}}}class Lf extends kf{constructor(e){super(),this.namespace="Placement",this.campaign=e,this.register()}resolveValue(e){if("label"!==e)return;if(this.campaign&&void 0!==this.campaign.value&&null!==this.campaign.value)return this.campaign.value;const t=oh.providers;if(0===t.length)return;const n=t.find((e=>e.flow));return n?n.getCurrentPlacementLabel():t[t.length-1]?.getCurrentPlacementLabel()}}class If{constructor(){this.load()}setExternalId(e){return this.externalId=e,this}getExternalId(){return this.externalId}isLoggedIn(){return!!this.externalId}save(){return this.externalId?da.setNamiProfile({externalId:this.externalId}):da.removeNamiProfile(),this}load(){const e=da.getNamiProfile();e&&(this.externalId=e.externalId),oh.setIsLoggedIn(!!this.externalId)}async login(e){const t=await qs.instance.login(e);t.external_id&&oh.setIsLoggedIn(!0),this.setExternalId(t.external_id).save()}async logout(){await qs.instance.logout(),oh.setIsLoggedIn(!1),this.setExternalId(void 0).save()}}var Df;If.instance=new If,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"}(Df||(Df={}));class Rf{constructor(){this.emitter=Zl.getInstance(),wf.shared.registerNamespaceResolver("UserTags",(e=>{const t=e.replace("UserTags.",""),n=Rf.getCustomerAttribute(t);if(null!=n){const e=n.toLowerCase();return"true"===e||"false"===e?"true"===e:isNaN(Number(n))?n:parseInt(n,10)}return null}))}static isLoggedIn(){return If.instance.isLoggedIn()}static loggedInId(){return this.instance.isSDKInitialized||Je.debug(N),If.instance.getExternalId()}static async login(e){if(!this.instance.isSDKInitialized){const e=new ma;throw this.invokeStateHandler(Df.LOGIN,!1,e),e}if(this.inAnonymousMode()){const e=new ka;throw this.invokeStateHandler(Df.LOGIN,!1,e),e}try{if(await If.instance.login(e),await ch.instance.fetchActiveEntitlements(),this.invokeStateHandler(Df.LOGIN,!0),Ff.instance.flowOpen){const e=Ff.instance.currentFlow,t=e?.currentFlowStep;t&&e.executeLifecycle(t,nf)}}catch(e){if(this.invokeStateHandler(Df.LOGIN,!1,e),Ff.instance.flowOpen){const e=Ff.instance.currentFlow,t=e?.currentFlowStep;t&&e.executeLifecycle(t,af)}throw e}}static async logout(){if(!this.instance.isSDKInitialized){const e=new ma;throw this.invokeStateHandler(Df.LOGOUT,!1,e),e}if(this.inAnonymousMode()){const e=new ka;throw this.invokeStateHandler(Df.LOGOUT,!1,e),e}try{if(await If.instance.logout(),await ch.instance.fetchActiveEntitlements(),this.invokeStateHandler(Df.LOGOUT,!0),Ff.instance.flowOpen){const e=Ff.instance.currentFlow,t=e?.currentFlowStep;t&&e.executeLifecycle(t,rf)}}catch(e){if(this.invokeStateHandler(Df.LOGOUT,!1,e),Ff.instance.flowOpen){const e=Ff.instance.currentFlow,t=e?.currentFlowStep;t&&e.executeLifecycle(t,of)}throw e}}static async setCustomerDataPlatformId(e){await this.updateCustomerDataPlatformId(e)}static async clearCustomerDataPlatformId(){await this.updateCustomerDataPlatformId(null)}static registerAccountStateHandler(e){return this.instance.emitter.on("accountStateChange",e),()=>{this.instance.emitter.off("accountStateChange",e)}}static async setAnonymousMode(e){const t=e?Df.ANONYMOUS_MODE_ON:Df.ANONYMOUS_MODE_OFF;if(!this.instance.isSDKInitialized){const e=new ma;throw this.invokeStateHandler(t,!1,e),e}if(this.anonymousModeCapability())if(this.inAnonymousMode()!==e)if(e)da.setAnonymousMode(e),da.resetDevice(),this.refetchConfig(),this.invokeStateHandler(Df.ANONYMOUS_MODE_ON,!0);else{da.clearAnonymousMode();const e=da.getNamiConfig()?.namiCommands;await nd.instance.createOrUpdateDevice(kl(e)),da.clearAnonymousUUID(),this.refetchConfig(),this.invokeStateHandler(Df.ANONYMOUS_MODE_OFF,!0)}else{const n=e?new ba:new wa;this.invokeStateHandler(t,!1,n)}else Je.warn("Anonymous mode feature is not enabled for your Nami account. Contact support@nami.ml for details.")}static inAnonymousMode(){return!!this.instance.isSDKInitialized&&sd()}static setCustomerAttribute(e,t){if(!this.instance.isSDKInitialized)throw new ma;if(da.setCustomerAttribute(e,t),Gs(A.PAYWALL_PERSONALIZATION)?(oh.setCustomerAttribute({[e]:t}),Je.debug(`This customer attribute you set is now available for paywall personalization using the smart text variable: ${e}`)):Je.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.`),Ff.instance.flowOpen){const e=Ff.instance.currentFlow;if(e){const t=e.currentFlowStep;t&&e.executeLifecycle(t,df)}}}static getCustomerAttribute(e){if(!this.instance.isSDKInitialized)throw new ma;const t=da.getCustomerAttribute(e);return null!=t?Gs(A.PAYWALL_PERSONALIZATION)?Je.debug(`Found customer attribute. ${e} is available for paywall personalization on this device.`):Je.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.`):Je.warn(`No ${e} customer attribute found.`),t}static getAllCustomerAttributes(){if(!this.instance.isSDKInitialized)throw new ma;return da.getAllCustomerAttributes()}static clearCustomerAttribute(e){if(!this.instance.isSDKInitialized)throw new ma;da.clearCustomerAttribute(e)?(oh.removeCustomerAttribute(e),Je.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.`)):Je.warn(`No value to clear for attribute ${e}.`)}static clearAllCustomerAttributes(){if(!this.instance.isSDKInitialized)throw new ma;da.getAllCustomerAttributesKeys().forEach((e=>{oh.removeCustomerAttribute(e)})),da.clearAllCustomerAttributes(),Je.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.")}static journeyState(){if(!this.instance.isSDKInitialized)throw new ma;return da.getCustomerJourneyState()}static deviceId(){return this.instance.isSDKInitialized?da.getDevice()?.id??U:U}static registerJourneyStateHandler(e){if(Vs("NamiCustomerManager.registerJourneyStateHandler"))return this.instance.emitter.addListener(Be,e),()=>{this.instance.emitter.removeListener(Be,e)}}static invokeStateHandler(e,t,n){this.instance.emitter.emit("accountStateChange",e,t,n)}get isSDKInitialized(){return _h.instance.isInitialized}static async updateCustomerDataPlatformId(e){if(!this.instance.isSDKInitialized){const e=new ma;throw this.invokeStateHandler(Df.CUSTOMER_DATA_PLATFORM_ID_SET,!1,e),e}if(this.inAnonymousMode()){Je.info("Unable to set CDP ID in anonymous mode",{deviceId:da.getDevice()?.id,anonymousMode:!0});const e=new Sa;this.invokeStateHandler(Df.CUSTOMER_DATA_PLATFORM_ID_SET,!1,e)}else try{await nd.instance.updateDeviceField("customer_data_platform_id",e),this.invokeStateHandler(Df.CUSTOMER_DATA_PLATFORM_ID_SET,!0)}catch(e){this.invokeStateHandler(Df.CUSTOMER_DATA_PLATFORM_ID_SET,!1,e)}}static anonymousModeCapability(){if(!this.instance.isSDKInitialized)return!1;const e=Gs(A.ANONYMOUS_MODE_CAPABILITY),t=Gs(A.THIRD_PARTY_TRANSACTIONS);return e&&t}static async refetchConfig(){this.instance.isSDKInitialized&&await Promise.all([id.instance.fetchProducts(),ad.instance.fetchPaywalls().then((e=>ed.instance.fetchCampaignRules(e)))])}}Rf.instance=new Rf;class Wf{constructor(e={}){this.id=e.id??"",this.name=e.name??"",this.steps=e.steps??[],this.screens=e.screens??[],this.resumeFromBookmark=Boolean(e.resume_from_bookmark),this.transition=e.transition??"none"}get allScreensAvailable(){return this.screens.length>0&&il(this.screens)}}class Nf extends Wf{constructor(e,t,n,i){super(e.flow.object??{}),this.stepcrumbs=[],this.branchcrumbs=[],this.activeHandoffSequence=null,this.currentScreenState=null,this.isPaused=!1,this.timerStates={},this.campaign=e,this.component=t,this.context=i,this.manager=n,this.branchcrumbs=[],this.stepcrumbs=[],this.registerResolvers(i);const a=this.findStepByType(Gm);a&&this.forward(a.id)}registerResolvers(e){e&&new Sf(e),new _f,new Af,new Cf,new Lf(this.campaign),wf.shared.registerNamespaceResolver("Flow",(e=>{switch(e){case"Flow.stepcrumbs":return this.stepcrumbs.map((e=>e.id));case"Flow.branchcrumbs":return this.branchcrumbs;default:return}}))}get currentFlowStep(){return this.stepcrumbs.at(-1)}get nextStepAvailable(){return void 0!==this.nextFlowStep}get previousStepAvailable(){const e=!!this.previousFlowStep,t=!1!==this.previousFlowStep?.allow_back_to,n=this.stepcrumbs.slice(0,-1).some((e=>"screen"===e.type));return e&&t&&n}get previousFlowStep(){const e=this.stepcrumbs.length-2;return e>=0?this.stepcrumbs[e]:void 0}get nextFlowStep(){return this.nextStep(this.currentFlowStep)}getStep(e){return this.steps.find((t=>t.id===e))}findStepByType(e){return this.steps.find((t=>t.type===e))}isStepActive(e){return!e.branch_tags||!e.branch_tags.length||e.branch_tags.some((e=>this.branchcrumbs.includes(e)))}finished(){this.manager.finishFlow()}back(){this.previousStepAvailable?this.backToPreviousScreenStep():Je.debug("No previous step available")}next(){const e=this.nextFlowStep;e&&this.forward(e.id)}backToPreviousScreenStep(){if(!1!==this.previousFlowStep?.allow_back_to){for(let e=this.stepcrumbs.length-2;e>=0;e--){const t=this.stepcrumbs[e];if(this.stepcrumbs.pop(),"branch"===t.type&&this.branchcrumbs.length>0&&this.branchcrumbs.pop(),"screen"===t.type&&t.screen){const e=nl(t.screen);return e&&this.component.flowNavigateToScreen(e,{transition:this.transition,direction:"backward"}),void(this.currentScreenState=oh.currentProvider?.state??null)}}Je.warn("No previous screen step found to return to")}else Je.warn(`Not allowed to go back to ${this.previousFlowStep.id}`)}forward(e){const t=this.getStep(e);if(t){if(this.isStepActive(t))switch(t.type){case Gm:case Km:return this.stepcrumbs.push(t),void this.executeLifecycle(t,Zm);case Xm:return void this.handleBranchStep(t);case Vm:return void this.handleScreenStep(t);case Ym:return}}else Je.error(`No step found with id: ${e}`)}pause(){this.isPaused?Je.info("Flow is already paused"):(this.isPaused=!0,this.pausedStepID=this.currentFlowStep?.id,Je.info("Flow paused"))}resumeFromPause(){if(!this.isPaused)return void Je.info("Flow is not paused");if(this.isPaused=!1,!this.pausedStepID)return void Je.warn("No step to resume from");const e=this.pausedStepID;this.pausedStepID=void 0,Je.info(`Flow resumed from step ${e}`),this.forward(e)}executeLifecycle(e,t,n){const i=e.actions[t];i&&this.executeFullLifecycles(i,n)}lifecycles(e){if(!this.currentFlowStep)return;const t=this.currentFlowStep.actions[e];if(t)return t;Je.info(`No actions found for button ${e} on step ${this.currentFlowStep.id}`)}triggerActions(e,t,n){const i=this.lifecycles(e);i&&(this.currentButton=t,this.executeFullLifecycles(i,n))}executeFullLifecycles(e,t){for(const n of e)[n.before,n.action,n.after].forEach((e=>e?.forEach((e=>this.shouldRun(e)&&this.performAction(e,t)))))}triggerBeforeActions(e,t,n){const i=this.lifecycles(e);if(i){this.currentButton=t;for(const e of i)e.before?.forEach((e=>this.shouldRun(e)&&this.performAction(e,n)))}}triggerAfterActions(e,t,n){const i=this.lifecycles(e);if(i){this.currentButton=t;for(const e of i)e.after?.forEach((e=>this.shouldRun(e)&&this.performAction(e,n)))}}currentStepHasHoistedPrimaryActions(e){const t=this.lifecycles(e);return!!t&&t.some((e=>e.action?.length))}shouldRun(e){return!e.conditions||e.conditions.every((e=>wf.shared.evaluate(e)))}performAction(e,t){if(!this.currentFlowStep)return void Je.warn("No current flow step");const n=(e.parameters?.delay?+e.parameters.delay:0)||0,i=n=>{if(this.currentFlowStep?.id===n)switch(e.function){case qm.BACK:this.back();break;case qm.NEXT:e.parameters?.step?this.forward(e.parameters.step):this.next();break;case qm.NAVIGATE:e.parameters?.step?this.previousFlowStep?.id===e.parameters.step?this.back():this.forward(e.parameters.step):this.next();break;case qm.FINISHED:case qm.DISMISS:this.finished();break;case qm.EXIT:{const e=this.steps.find((e=>e.type===Km));e&&this.forward(e.id);break}case qm.PAUSE:this.pause();break;case qm.RESUME:this.resumeFromPause();break;case qm.HANDOFF:if(e.parameters?.handoffTag)if(this.manager.handoffStepHandler)if(e.parameters.handoffData)Je.debug(`Invoking handoffStepHandler with ${e.parameters.handoffTag} ${JSON.stringify(e.parameters.handoffData)}`),this.manager.handoffStepHandler(e.parameters.handoffTag,e.parameters.handoffData);else if(t)Je.debug(`Invoking handoffStepHandler with ${e.parameters.handoffTag} ${JSON.stringify(t)}`),this.manager.handoffStepHandler(e.parameters.handoffTag,t);else if(e.parameters.handoffFormId){const t=this.getFormData();e.parameters.handoffTag===Jm?this.flowHandoffFormSequence():this.manager.handoffStepHandler(e.parameters.handoffTag,t)}else Je.debug(`Invoking handoffStepHandler with ${e.parameters.handoffTag} and no data`),this.manager.handoffStepHandler(e.parameters.handoffTag);else Je.debug("No handoffStepHandler found",e);break;case qm.LOG:e.parameters?.eventName?Je.info(`logEvent → ${e.parameters.eventName}`):Je.warn(`Missing 'eventName' in logEvent action ${e.id??"unknown"}`);break;case qm.TRACK:e.parameters?.eventName?Je.info(`trackEvent → ${e.parameters.eventName}`):Je.warn(`Missing 'eventName' in logEvent action ${e.id??"unknown"}`);break;case qm.SET_VIDEO:e.parameters?.name&&e.parameters.url?oh.setAppSuppliedVideoDetails({name:e.parameters.name,url:e.parameters.url}):Je.warn("Missing name, url for setting video details");break;case qm.BLOCK_BACK:{const t=e.parameters?.step,n=t?this.getStep(t):void 0;n?n.allow_back_to=!1:this.currentFlowStep?this.currentFlowStep.allow_back_to=!1:Je.warn("Missing step for blocking back");break}case qm.FLOW_EVENT:{const t=new xf(this.manager),n=Object.fromEntries(Object.entries(e.parameters??{}).map((([e,n])=>[e,t.interpolateDeep(n)])));this.manager.eventHandler?this.manager.eventHandler(n):Je.warn("Missing event handler",n);break}case qm.FLOW_ENABLED:oh.setUserInteractionEnabled(!0);break;case qm.FLOW_DISABLED:oh.setUserInteractionEnabled(!1);break;case qm.SET_TAGS:e.parameters&&(oh.setUserTags(e.parameters),Object.entries(e.parameters).forEach((([e,t])=>{Rf.setCustomerAttribute(e,t)})));break;default:Je.warn(`Missing action handler for ${e.function}`,e)}else Je.debug(`Skipped action for stale flow step ${n}`)};n?setTimeout(i.bind(this,this.currentFlowStep.id),n):i(this.currentFlowStep.id)}nextStep(e){if(!e)return void Je.error("Next step not found");const t=this.steps.findIndex((t=>t.id===e.id));if(-1===t)return void Je.error(`Could not find next step for step ${e.id}`);const n=this.steps.slice(t+1);for(const e of n){if(this.isStepActive(e))return e}Je.debug(`No active next step found after ${e.id}`)}handleScreenStep(e){const t=nl(e.screen??"");e.screen&&t&&this.campaign?(this.stepcrumbs.push(e),this.component.flowNavigateToScreen(t,{transition:this.transition,direction:"forward"})):Je.error("No paywall or campaign found for next step")}handleBranchStep(e){this.stepcrumbs.push(e);for(const[t,n]of Object.entries(e.actions))if(n)for(const e of n)if(e.action){for(const n of e.action)if(this.shouldRun(n))return this.branchcrumbs.push(t),e.before?.forEach((e=>{this.performAction(e)})),e.action.forEach((e=>{this.shouldRun(e)&&this.performAction(e)})),void e.after?.forEach((e=>{this.performAction(e)}))}else Je.warn(`No actions defined for branch tag ${t}`);Je.warn(`No matching branch condition matched for step ${e.id}`)}getFormData(){return{...oh.currentProvider?.state?.formStates??{}}}flowHandoffFormSequence(){const e=this.currentScreenState?.formStates;if(!e)return void Je.warn("No formStates available for handoff sequence");const t=Object.keys(e).sort();if(0===t.length)return void Je.warn("formStates is empty, no handoffs to perform");const n=t.filter((t=>!0===e[t]));if(0===n.length)return Je.info("No eligible handoff keys after filtering"),void this.manager.resume();this.activeHandoffSequence={formStates:{...e},remainingKeys:[...n]},this.resumeNextHandoff()}resumeNextHandoff(){const e=this.activeHandoffSequence;if(!e)return Je.warn("No active handoff sequence to resume"),void this.manager.resume();if(0===e.remainingKeys.length)return Je.info("All handoffs in the sequence are complete"),this.activeHandoffSequence=null,void this.manager.resume();const t=e.remainingKeys.shift(),n=e.formStates[t];Je.debug(`Starting handoff for ${t} → ${String(n)}`),this.activeHandoffSequence=e;const i=`${t}`;this.manager.handoffStepHandler?.(i,void 0)}}let Ff=class e{static get instance(){return e._instance||(e._instance=new e),e._instance}constructor(){this.flowOpen=!1,this.lastAnimatedFlowProgress=new Map,this.navGraphCache=new WeakMap}static registerStepHandoff(e){this.instance.handoffStepHandler=e}static registerEventHandler(e){this.instance.eventHandler=e}static resume(){const{flowOpen:t,currentFlow:n}=e.instance;if(t&&n&&n.currentFlowStep){if(n.activeHandoffSequence)return Je.debug(`Resuming flow at handoff sequence ${n.currentFlowStep.id}`),void n.resumeNextHandoff();Je.debug(`Resuming flow at step ${n.currentFlowStep.id}`),n.executeLifecycle(n.currentFlowStep,"__resume__")}else Je.warn("Cannot resume: no active flow or current step")}resume(){e.resume()}static finish(){const{flowOpen:t,currentFlow:n}=e.instance;t&&n&&n.currentFlowStep?(Je.debug(`Finishing flow programmatically at step ${n.currentFlowStep.id}`),n.finished()):Je.debug("Cannot finish: no active flow or current step")}static pause(){const{flowOpen:t,currentFlow:n}=e.instance;t&&n&&n.currentFlowStep?!0===n.resumeFromBookmark?n.pause():Je.warn("This flow cannot be paused"):Je.warn("Cannot pause: no active flow or current step")}static isFlowOpen(){return e.instance.flowOpen}presentFlow(e,t,n){const i=new Nf(e,t,this,n);return this.flowOpen=!0,this.currentFlow=i,i}finishFlow(){this.flowOpen=!1,this.currentFlow=void 0,this.lastAnimatedFlowProgress.clear()}getLastAnimatedFlowProgress(e){return this.lastAnimatedFlowProgress.get(e)??0}setLastAnimatedFlowProgress(e,t){this.currentFlow&&this.lastAnimatedFlowProgress.set(e,t)}getCurrentFlowProgress(e){if(!this.currentFlow)return 1;if(!this.currentFlow.currentFlowStep)return 0;const t=this.currentFlow.steps.filter((e=>e.type===Vm));if(0===t.length)return 0;const n=this.currentFlow.stepcrumbs.filter((e=>e.type===Vm));if(0===n.length)return 0;const i=this.buildNavGraph(this.currentFlow),a=this.currentFlow.currentFlowStep,r=this.findBranchPoint(t,i);let o=0;if(r)o=this.calculateBranchingProgress(n,t,a,r,i);else{const e=t.findIndex((e=>e.id===a.id));o=e>=0?(e+1)/t.length:0}return o=Math.max(0,Math.min(1,o)),e&&this.setLastAnimatedFlowProgress(e,o),o}findBranchPoint(e,t){for(const n of e)if(this.hasBranching(n,e,t))return n;return null}calculateBranchingProgress(e,t,n,i,a){const r=e.length,o=t.findIndex((e=>e.id===i.id)),s=e.findIndex((e=>e.id===i.id)),l=t.findIndex((e=>e.id===n.id));if(-1===s||n.id===i.id)return(l+1)/(o+2);const d=this.countForwardScreens(n,t,a),u=r+d;return Je.debug(`Branching progress: visited=${r}, remaining=${d}, total=${u}, step=${n.id}`),r/u}countForwardScreens(e,t,n){const i=t.findIndex((t=>t.id===e.id));if(-1===i)return 0;const a=new Set;let r=0;const o=(e,s)=>{if(a.has(e))return;a.add(e);const l=(n.get(e)||[]).filter((e=>{const n=t.findIndex((t=>t.id===e));return n>i}));if(0!==l.length)for(const e of l)o(e,s+1);else r=Math.max(r,s)};return o(e.id,0),r}hasBranching(e,t,n){const i=t.findIndex((t=>t.id===e.id));if(-1===i)return!1;const a=(n.get(e.id)||[]).filter((e=>{const n=t.findIndex((t=>t.id===e));return n>i}));return a.length>1}buildNavGraph(e){const t=this.navGraphCache.get(e);if(t)return t;const 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){const i=t.parameters?.step;i&&(n.has(e.id)||n.set(e.id,new Set),n.get(e.id).add(i))}}))}))}))}));const i=new Map;return n.forEach(((e,t)=>{i.set(t,Array.from(e))})),this.navGraphCache.set(e,i),i}static getLastAnimatedFlowProgress(e){return this.instance.getLastAnimatedFlowProgress(e)}static setLastAnimatedFlowProgress(e,t){this.instance.setLastAnimatedFlowProgress(e,t)}static getCurrentFlowProgress(e){return this.instance.getCurrentFlowProgress(e)}getCurrentFlowStepAutoAdvanceDelay(){const e=this.currentFlow?.currentFlowStep;if(!e)return null;const t=e.actions?.[ef];if(!t)return null;for(const e of t){const t=e.action??[];for(const e of t)if((e.function===qm.NAVIGATE||e.function===qm.NEXT)&&null!=e.parameters?.delay){const t=e.parameters.delay,n=Number(t);if(!isNaN(n)&&n>0)return n/1e3}}return null}static getCurrentFlowStepAutoAdvanceDelay(){return this.instance.getCurrentFlowStepAutoAdvanceDelay()}};const Of=2;let $f=class{constructor(e){}get _$AU(){return this._$AM._$AU}_$AT(e,t,n){this._$Ct=e,this._$AM=t,this._$Ci=n}_$AS(e,t){return this.update(e,t)}update(e,t){return this.render(...t)}};const{I:jf}=Dm,zf=()=>document.createComment(""),Hf=(e,t,n)=>{const i=e._$AA.parentNode,a=void 0===t?e._$AB:t._$AA;if(void 0===n){const t=i.insertBefore(zf(),a),r=i.insertBefore(zf(),a);n=new jf(t,r,e,e.options)}else{const t=n._$AB.nextSibling,r=n._$AM,o=r!==e;if(o){let t;n._$AQ?.(e),n._$AM=e,void 0!==n._$AP&&(t=e._$AU)!==r._$AU&&n._$AP(t)}if(t!==a||o){let e=n._$AA;for(;e!==t;){const t=e.nextSibling;i.insertBefore(e,a),e=t}}}return n},Bf=(e,t,n=e)=>(e._$AI(t,n),e),Uf={},Gf=e=>{e._$AR(),e._$AA.remove()},Vf=(e,t,n)=>{const i=new Map;for(let a=t;a<=n;a++)i.set(e[a],a);return i},Xf=(e=>(...t)=>({_$litDirective$:e,values:t}))(class extends $f{constructor(e){if(super(e),e.type!==Of)throw Error("repeat() can only be used in text expressions")}dt(e,t,n){let i;void 0===n?n=t:void 0!==t&&(i=t);const a=[],r=[];let o=0;for(const t of e)a[o]=i?i(t,o):o,r[o]=n(t,o),o++;return{values:r,keys:a}}render(e,t,n){return this.dt(e,t,n).values}update(e,[t,n,i]){const a=(e=>e._$AH)(e),{values:r,keys:o}=this.dt(t,n,i);if(!Array.isArray(a))return this.ut=o,r;const s=this.ut??=[],l=[];let d,u,c=0,h=a.length-1,m=0,f=r.length-1;for(;c<=h&&m<=f;)if(null===a[c])c++;else if(null===a[h])h--;else if(s[c]===o[m])l[m]=Bf(a[c],r[m]),c++,m++;else if(s[h]===o[f])l[f]=Bf(a[h],r[f]),h--,f--;else if(s[c]===o[f])l[f]=Bf(a[c],r[f]),Hf(e,l[f+1],a[c]),c++,f--;else if(s[h]===o[m])l[m]=Bf(a[h],r[m]),Hf(e,a[c],a[h]),h--,m++;else if(void 0===d&&(d=Vf(o,m,f),u=Vf(s,c,h)),d.has(s[c]))if(d.has(s[h])){const t=u.get(o[m]),n=void 0!==t?a[t]:null;if(null===n){const t=Hf(e,a[c]);Bf(t,r[m]),l[m]=t}else l[m]=Bf(n,r[m]),Hf(e,a[c],n),a[t]=null;m++}else Gf(a[h]),h--;else Gf(a[c]),c++;for(;m<=f;){const t=Hf(e,l[f+1]);Bf(t,r[m]),l[m++]=t}for(;c<=h;){const e=a[c++];null!==e&&Gf(e)}return this.ut=o,((e,t=Uf)=>{e._$AH=t})(e,l),ym}});const Kf=async e=>{const t=new Set(Array.from(document.fonts.values()).map((e=>e.family)));return e.forEach((e=>{const n=function(e){return t=`${e.family}-${e.style}`,t.replace(/ /g,"");var t}(e);if(t.has(n))return;const i=new FontFace(n,`url(${e.file})`);document.fonts.add(i)})),document.fonts.ready.then()};function Yf(e,t,n){if("undefined"==typeof window||!e||!t)return Je.debug("Swipe detection is not supported in this environment."),{destroy(){},updateOptions(){}};const i={minDistance:n?.minDistance,maxDuration:n?.maxDuration??600,lockAxis:n?.lockAxis,preventScrollOnSwipe:n?.preventScrollOnSwipe,pointerTypes:n?.pointerTypes??["touch"],passiveListeners:n?.passiveListeners??!0,axisHint:n?.axisHint,edgeLeakThreshold:n?.edgeLeakThreshold},a=e.style.touchAction;i.preventScrollOnSwipe&&(e.style.touchAction="none");let r=null,o=0,s=0,l=0,d=0,u=0,c=null,h=null,m=!1,f=!1,p=!1;const g=e=>{try{const t=window.getComputedStyle(e);if(!t)return!1;const n=t.overflowY;if("auto"!==n&&"scroll"!==n)return!1;const i=e;return i.scrollHeight>i.clientHeight}catch{return!1}},v=e=>i.pointerTypes.includes(e.pointerType),y=t=>{const n=t.composedPath?t.composedPath()[0]:t.target;if(v(t)&&null===r){r=t.pointerId,o=l=t.clientX,s=d=t.clientY,u=performance.now(),c=null,p=!1,m=!1,f=!1,h="y"===i.axisHint?((e,t)=>{let n=e;for(;n&&n!==t&&n instanceof HTMLElement;){if(g(n))return n;n=n.parentElement||(n.parentNode?.host??null)}return null})(n,e):null,h||(f=!0);try{e?.setPointerCapture?.(t.pointerId)}catch{try{n?.setPointerCapture?.(t.pointerId)}catch{}}}},b=e=>{if(e.pointerId===r&&v(e)){if(l=e.clientX,d=e.clientY,i.lockAxis&&!c){const e=Math.abs(l-o),t=Math.abs(d-s);(e>2||t>2)&&(c=t>=e?"y":"x")}if("y"===i.axisHint&&("y"===c||!i.lockAxis)){const n=d-s,a=n<0?"up":"down",r=Math.abs(n),c=performance.now()-u,g=r/Math.max(c,1),v=r>=i.minDistance||g>.5;if(h)if(v)f=!0;else if(((e,t)=>!!e&&("down"===t?e.scrollTop>0:e.scrollTop+e.clientHeight<e.scrollHeight-1))(h,a)){if(!(("down"===a&&h.scrollTop<=50||"up"===a&&h.scrollTop+h.clientHeight>=h.scrollHeight-50)&&g>.3))return void(m=!0);f=!0}else f=!0;const y=!h||r>=i.edgeLeakThreshold;if(!p&&!m&&f&&y&&r>=i.minDistance){p=!0;const i=performance.now(),c={direction:"up"===a?"up":"down",distanceX:l-o,distanceY:n,absX:Math.abs(l-o),absY:r,duration:i-u,velocity:r/Math.max(i-u,1),startX:o,startY:s,endX:l,endY:d,startedAt:u,endedAt:i,originalEvent:e};t(c)}}}},w=e=>{if(e.pointerId!==r)return;if(!v(e))return void k();if(h)return void k();if(p||m)return void k();const n=performance.now(),a=n-u,g=l-o,y=d-s,b=Math.abs(g),w=Math.abs(y);let S;S=i.lockAxis&&c?c:"x"===i.axisHint?"x":"y"===i.axisHint?"y":b>=w?"x":"y";const _="x"===S?b:w,M=a<=i.maxDuration;let E=i.minDistance;h&&"y"===S&&f&&(E+=i.edgeLeakThreshold);if(M&&_>=E){let i;i="x"===S?g>0?"right":"left":y>0?"down":"up";const r=_/Math.max(a,1);t({direction:i,distanceX:g,distanceY:y,absX:b,absY:w,duration:a,velocity:r,startX:o,startY:s,endX:l,endY:d,startedAt:u,endedAt:n,originalEvent:e})}k()},k=()=>{r=null,c=null,u=0,h=null,f=!1,m=!1,p=!1},S=!!i.passiveListeners&&{passive:!0},_=i.passiveListeners?{passive:!0,capture:!0}:{capture:!0};e.addEventListener("pointerdown",y,_),e.addEventListener("pointermove",b,S),e.addEventListener("pointerup",w,S),e.addEventListener("pointercancel",w,S),e.addEventListener("lostpointercapture",w,S);return{destroy:()=>{e.removeEventListener("pointerdown",y,_),e.removeEventListener("pointermove",b,S),e.removeEventListener("pointerup",w,S),e.removeEventListener("pointercancel",w,S),e.removeEventListener("lostpointercapture",w,S),i.preventScrollOnSwipe&&(e.style.touchAction=a),k()},updateOptions:t=>{Object.assign(i,t),"boolean"==typeof t.preventScrollOnSwipe&&(t.preventScrollOnSwipe?e.style.touchAction="none":e.style.touchAction=a)}}}let qf=class extends Nm{constructor(e,t,n){return super(),this.pages=[],this.currentOffset=0,this.presentationStyle="fullscreen",this.formFactor=Sl(),this.timeSpentOnPaywall=0,this.animation={transition:"none",direction:"forward"},this._originalBodyStyles={},this._originalDocumentStyles={},this._savedScrollY=0,this._sheetDragStartY=0,this._sheetIsDragging=!1,this._dismissThreshold=100,this.type=e,this.value=t,this.context=n,this.setPaywallData(),this}setPaywallData(){const e=Ol(this.value,this.type);this.paywall=e.paywall,this.campaign=e.campaign}getPresentationStyle(e){const t=e?.template?.initialState?.presentation_style;return(n=t)&&Mh.has(n)?"sheet"===n?"fullscreen":n:"fullscreen";var n}get isHalfSheet(){return"compact_sheet"===this.presentationStyle}connectedCallback(){super.connectedCallback(),window.TVJS?.DirectionalNavigation&&(window.TVJS.DirectionalNavigation.focusRoot=this),document.addEventListener("keydown",this.handleKeyDownEvent.bind(this)),this._swipeHandler=Yf(this,this.handleSwipeEvent.bind(this),{axisHint:"y",lockAxis:!0,minDistance:25,edgeLeakThreshold:15,preventScrollOnSwipe:!1,pointerTypes:["touch"]}),this.presentationStyle=this.getPresentationStyle(this.paywall),this.setOriginalStyles()}disconnectedCallback(){super.disconnectedCallback(),da.clearLaunchId(),window.TVJS?.DirectionalNavigation&&(window.TVJS.DirectionalNavigation.focusRoot=document.body),document.removeEventListener("keydown",this.handleKeyDownEvent.bind(this)),Zl.getInstance().removeAllListeners(ze),this.restoreStyles(),this._halfSheetAbortController?.abort(),this._swipeHandler.destroy()}setOriginalStyles(){"television"===this.formFactor&&(this._originalBodyStyles.overflow=document.body.style.overflow,document.body.style.overflow="hidden"),this._originalBodyStyles.background=document.body.style.background,"phone"===this.formFactor&&(this._originalBodyStyles["overscroll-behavior"]=document.body.style.overscrollBehavior?document.body.style.overscrollBehavior:null,this._originalDocumentStyles["overscroll-behavior"]=document.documentElement.style.overscrollBehavior?document.documentElement.style.overscrollBehavior:null,document.body.style.overscrollBehavior="none",document.documentElement.style.overscrollBehavior="none",this.isHalfSheet||(this._originalBodyStyles.overflow=document.body.style.overflow,document.body.style.overflow="hidden")),this.isHalfSheet&&(this._savedScrollY=window.scrollY,this._originalBodyStyles.position=document.body.style.position||null,this._originalBodyStyles.top=document.body.style.top||null,this._originalBodyStyles.width=document.body.style.width||null,document.body.style.position="fixed",document.body.style.top=`-${this._savedScrollY}px`,document.body.style.width="100%")}restoreStyles(){Object.entries(this._originalBodyStyles).forEach((([e,t])=>{null!==t?document.body.style.setProperty(e,t):document.body.style.removeProperty(e)})),Object.entries(this._originalDocumentStyles).forEach((([e,t])=>{null!==t?document.documentElement.style.setProperty(e,t):document.documentElement.style.removeProperty(e)})),this._savedScrollY>0&&(window.scrollTo(0,this._savedScrollY),this._savedScrollY=0)}handleKeyDownEvent(e){!this.flow||10009!==e.keyCode&&"Backspace"!==e.key&&"GoBack"!==e.key||this.flow.triggerActions(lf)}handleSwipeEvent({direction:e}){"down"===e?this.flow?.triggerActions("__swipe_down__"):"up"===e&&this.flow?.triggerActions("__swipe_up__")}setupHalfSheetDragTracking(){this._halfSheetAbortController?.abort(),this._halfSheetAbortController=new AbortController;const{signal:e}=this._halfSheetAbortController,t=this.shadowRoot?.querySelector(".nami-half-sheet-container"),n=this.shadowRoot?.querySelector(".nami-half-sheet-content");if(!t||!n)return;t.addEventListener("touchstart",(e=>{n.scrollTop>0||(this._sheetDragStartY=e.touches[0].clientY,this._sheetIsDragging=!0)}),{passive:!0,signal:e}),t.addEventListener("touchmove",(e=>{if(!this._sheetIsDragging)return;const n=e.touches[0].clientY-this._sheetDragStartY;n>0&&(t.style.transform=`translateY(${n}px)`,t.style.transition="none",e.preventDefault())}),{passive:!1,signal:e}),t.addEventListener("touchend",(()=>{if(!this._sheetIsDragging)return;this._sheetIsDragging=!1;const e=t.style.transform.match(/translateY\((\d+(?:\.\d+)?)px\)/);if((e?parseFloat(e[1]):0)>this._dismissThreshold){if(this.flow?.currentStepHasHoistedPrimaryActions("__swipe_down__")??!1)t.style.transform="translateY(0)",t.style.transition="transform 0.2s ease-out",this.flow?.triggerActions("__swipe_down__");else{t.style.transform="translateY(100%)",t.style.transition="transform 0.2s ease-in";const e=this.shadowRoot?.querySelector(".nami-half-sheet-backdrop");e&&e.classList.add("nami-dismissing"),setTimeout((()=>{this.flow?.finished()}),200)}}else t.style.transform="translateY(0)",t.style.transition="transform 0.2s ease-out"}),{signal:e})}setupHalfSheetFocusTrap(){const e=this.shadowRoot?.querySelector(".nami-half-sheet-container");if(!e)return;e.focus();const t=this._halfSheetAbortController?.signal;e.addEventListener("keydown",(t=>{if("Tab"!==t.key)return;const n=e.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');if(0===n.length)return;const i=n[0],a=n[n.length-1];t.shiftKey?document.activeElement!==i&&this.shadowRoot?.activeElement!==i||(t.preventDefault(),a.focus()):document.activeElement!==a&&this.shadowRoot?.activeElement!==a||(t.preventDefault(),i.focus())}),t?{signal:t}:void 0)}firstUpdated(){this.timeSpentOnPaywall=Date.now(),Js(this.campaign)&&(this.flow=Ff.instance.presentFlow(this.campaign,this,this.context)),this.isHalfSheet&&this.updateComplete.then((()=>{this.setupHalfSheetDragTracking(),this.setupHalfSheetFocusTrap()}))}updated(e){super.updated(e),this.isHalfSheet&&e.has("presentationStyle")&&(this.setupHalfSheetDragTracking(),this.setupHalfSheetFocusTrap())}getAnimationStyles(e){const t="backward"===this.animation.direction?-1:1;switch(this.animation.transition){case"verticalSlide":return`transform: translateY(${100*(e-this.currentOffset)*t}vh);`;case"slide":return`transform: translateX(${100*(e-this.currentOffset)*t}vw);`;case"fade":return`opacity: ${e===this.currentOffset?1:0};`;default:return""}}async updatePages(e){if(0===this.pages.length||"none"===this.animation.transition)return void(this.pages=[e]);const t=this.pages[this.pages.length-1];t?.id!==e.id&&(this.pages=[t,e],this.currentOffset=0,await this.updateComplete,requestAnimationFrame((()=>{this.currentOffset=1,setTimeout((()=>{this.pages=[e],this.currentOffset=0,this.paywall=e}),250)})))}async flowNavigateToScreen(e,t){this.flow?.previousFlowStep&&this.flow.executeLifecycle(this.flow.previousFlowStep,tf);const n=this.presentationStyle,i=this.getPresentationStyle(e);"fullscreen"===n&&"compact_sheet"===i?console.warn("Unsupported transition: fullscreen → compact_sheet. Presenting as fullscreen."):"compact_sheet"!==n||"fullscreen"!==i&&"sheet"!==i?this.presentationStyle=i:(await this.animateHalfSheetExpand(),this.presentationStyle="fullscreen"),this.animation=t,await this.updatePages(e),this.flow?.currentFlowStep&&this.flow.executeLifecycle(this.flow.currentFlowStep,ef)}async animateHalfSheetExpand(){const e=this.shadowRoot?.querySelector(".nami-half-sheet-container");e&&(e.classList.add("nami-expanding"),await new Promise((e=>setTimeout(e,300))))}getSelectedSlideIndexForCurrentCarousel(){return oh.getSelectedSlideIndex()}renderFlow(){return"undefined"==typeof document?gm``:this.isHalfSheet?this.renderHalfSheet():gm`
91
+ `,$m=e=>(t,n)=>{void 0!==n?n.addInitializer((()=>{customElements.define(e,t)})):customElements.define(e,t)},jm={attribute:!0,type:String,converter:Gh,reflect:!1,hasChanged:Vh},zm=(e=jm,t,n)=>{const{kind:i,metadata:a}=n;let r=globalThis.litPropertyMetadata.get(a);if(void 0===r&&globalThis.litPropertyMetadata.set(a,r=new Map),"setter"===i&&((e=Object.create(e)).wrapped=!0),r.set(n.name,e),"accessor"===i){const{name:i}=n;return{set(n){const a=t.get.call(this);t.set.call(this,n),this.requestUpdate(i,a,e)},init(t){return void 0!==t&&this.C(i,void 0,e,t),t}}}if("setter"===i){const{name:i}=n;return function(n){const a=this[i];t.call(this,n),this.requestUpdate(i,a,e)}}throw Error("Unsupported decorator location: "+i)};function Hm(e){return(t,n)=>"object"==typeof n?zm(e,t,n):((e,t,n)=>{const i=t.hasOwnProperty(n);return t.constructor.createProperty(n,e),i?Object.getOwnPropertyDescriptor(t,n):void 0})(e,t,n)}function Bm(e){return Hm({...e,state:!0,attribute:!1})}function Um(e){return!e||"object"==typeof e&&0==Object.keys(e).length}const Gm="entry",Vm="screen",Xm="branch",Km="exit",Ym="unknown";var qm;!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.PAUSE="flowPause",e.RESUME="flowResume"}(qm||(qm={}));const Jm="__handoff_sequence__",Qm="__buy_sku__",Zm="__default__",ef="__appear__",tf="__disappear__",nf="__login_success__",af="__login_failure__",rf="__logout_success__",of="__logout_failure__",sf="__purchase_success__",lf="__remoteback__",df="__tag_update__",uf="and",cf="or",hf="i_contains",mf="equals",ff="i_equals",pf="not_equals",gf="not_i_equals",vf="not_contains",yf="set",bf="notSet";class wf{constructor(){this.resolvers=new Map,this.namespaceResolvers=new Map}static get shared(){return wf.instance||(wf.instance=new wf),wf.instance}registerNamespaceResolver(e,t){this.namespaceResolvers.set(e,t)}resetResolvers(){this.resolvers.clear()}evaluate(e){const t=e.filter??[];if(0===t.length)return!0;const n=t.map((e=>this.evaluateFilter(e)));switch(e.operator){case uf:return n.every((e=>e));case cf:return n.some((e=>e));default:return n.every((e=>e))}}evaluateOrdered(e){if(!e)return!0;const t=e.filter??[];if(0===t.length)return!0;switch(e.operator){case uf:for(const e of t)if(!this.evaluateFilter(e))return!1;return!0;case cf:for(const e of t)if(this.evaluateFilter(e))return!0;return!1;default:for(const e of t)if(!this.evaluateFilter(e))return!1;return!0}}evaluateFilter(e){const t=this.resolve(e.identifier);if(e.operator===yf)return null!=t;if(e.operator===bf)return null==t;if(null==t){return!![pf,gf,vf].includes(e.operator)}switch(e.operator){case hf:if(Array.isArray(t)){return e.values.some((e=>t.some((t=>0===t.localeCompare(e,void 0,{sensitivity:"accent"})))))}return this.log("Resolved value is not an array of strings for i_contains."),!1;case mf:return e.values.some((e=>{if("string"==typeof t)return t===e;if("boolean"==typeof t){const n="true"===e.toLowerCase();return t===n}return this.log("Unsupported type for equals comparison: "+typeof t),!1}));case ff:return e.values.some((e=>{if("string"==typeof t){return 0===t.localeCompare(e,void 0,{sensitivity:"accent"})}if("boolean"==typeof t){const n="true"===e.toLowerCase();return t===n}return this.log("Unsupported type for i_equals comparison: "+typeof t),!1}));case pf:return e.values.every((e=>"string"!=typeof t||t!==e));case gf:return e.values.every((e=>"string"!=typeof t||0!==t.localeCompare(e,void 0,{sensitivity:"accent"})));case vf:return e.values.every((e=>"string"!=typeof t||!t.includes(e)));default:return this.log(`Unsupported operator: ${e.operator}`),!1}}resolve(e){const t=this.resolveRaw(e);if(void 0!==t)return t;const n=e.lastIndexOf(".");if(-1!==n){const t=e.slice(0,n),i=e.slice(n+1),a=this.resolveRaw(t);return void 0!==a?this.extractProperty(i,a):void this.log(`Could not resolve base identifier: ${t}`)}}resolveRaw(e){const t=[...this.namespaceResolvers.keys()].sort(((e,t)=>t.length-e.length));for(const n of t)if(e.startsWith(n)){const t=this.namespaceResolvers.get(n);if(t)return t(e)}}extractProperty(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}`)}log(e){Je.debug(`[NamiConditionEvaluator] ${e}`)}}class kf{constructor(){}register(){wf.shared.registerNamespaceResolver(this.namespace,(e=>{const t=e.replace(new RegExp(`^${this.namespace}\\.`),"");return this.resolveValue(t)}))}resolveKeyPath(e,t){const n=e.replace(/\[(\w+)\]/g,".$1").split(".").filter(Boolean);let i=t;for(const e of n){if(null==i||"object"!=typeof i)return;i=i[e]}return i}}class Sf extends kf{constructor(e){super(),this.namespace="LaunchContext",this.context=e,this.register()}resolveValue(e){if(e.startsWith("customAttributes.")){const t=e.substring(17);return this.resolveKeyPath(t,this.context.customAttributes)}if(e.startsWith("customObject.")){const t=e.substring(13);return this.resolveKeyPath(t,this.context.customObject)}return this.resolveKeyPath(e,{customAttributes:this.context.customAttributes,customObject:this.context.customObject,productGroups:this.context.productGroups})}}class _f extends kf{constructor(){super(),this.namespace="Device";const e=Intl.DateTimeFormat().resolvedOptions().locale.split("-")[1]||"",t=Intl.DateTimeFormat().resolvedOptions().timeZone,n=kl();this.context={osName:n.os_name,osVersion:n.os_version,appVersion:n.extended_platform_version,sdkVersion:n.sdk_version,deviceModel:n.device_model,screenWidth:window.innerWidth,screenHeight:window.innerHeight,formFactor:n.form_factor,tvQuality:this.tvQuality(n.form_factor??"desktop"),tvResolution:this.tvResolution(n.form_factor??"desktop"),screenSize:this.screenSizeTier(n.form_factor??"desktop"),language:n.language,country:e,timezone:t},this.register()}screenSizeTier(e){const t=window.screen.width,n=window.screen.height,i=window.devicePixelRatio||1,a=Math.round(t*i),r=Math.round(n*i),o=Math.max(a,r);switch(e){case"phone":return o<1136?"tiny":o<1334?"small":o<1920?"medium":o<2560?"large":"huge";case"tablet":return o<2048?"medium":o<2732?"large":"huge";case"television":return o<1920?"medium":o<3840?"large":"huge";case"desktop":return o<1440?"small":o<2560?"medium":o<3840?"large":"huge";default:return"medium"}}tvQuality(e){if("television"!==e)return"";const t=window.screen.width,n=window.screen.height,i=window.devicePixelRatio||1,a=Math.round(t*i),r=Math.round(n*i),o=Math.max(a,r),s=Math.min(a,r);return o>=3840||s>=2160?"4K":o>=1920||s>=1080?"1080p":"720p"}tvResolution(e){if("television"!==e)return"";const t=window.screen.width,n=window.screen.height,i=window.devicePixelRatio||1,a=Math.round(t*i),r=Math.round(n*i),o=Math.max(a,r),s=Math.min(a,r);return s<720&&o<1280?"SD":s>=720&&s<1080&&o>=1280&&o<1920?"720p":s>=1080&&s<1440&&o>=1920&&o<2560?"1080p":s>=1440&&s<2160&&o>=2560&&o<3840?"1440p":s>=2160&&s<3e3&&o>=3840&&o<5e3?"4K":s>=3e3&&o>=5e3?"8K":"Unknown"}resolveValue(e){return this.resolveKeyPath(e,this.context)}}const Mf=[/(^|_)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];class Ef{constructor(){this.params={},"undefined"!=typeof window&&this.setSearchParams()}static get instance(){return Ef._instance||(Ef._instance=new Ef),Ef._instance}static refresh(){"undefined"!=typeof window&&this.instance.setSearchParams()}setSearchParams(){this.params=this.extractSafeParams()}safeValue(e){if(!e)return null;try{const 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{return null}}extractSafeParams(){const e=window.location,t={},n=new Set;try{const i=new URLSearchParams(e.search),a=(e,i)=>{const a=(e=>e.replace(/([a-z])([A-Z])/g,"$1_$2").replace(/[-\s]/g,"_").toLowerCase())(e);if(n.size>=10)return;if((e=>Mf.some((t=>t.test(e))))(a))return;const r=this.safeValue(i);r&&(t[a]=r,n.add(a))};for(const[e,t]of i.entries())a(e,t)}catch{}return t}}Ef._instance=null;const Pf=()=>Ef.instance.params,Tf=/\{\{\s*([^}]+?)\s*\}\}/g;class xf{constructor(e){this.flowManager=e,this.urlParams=Pf()}resolve(e){const t=this.flowManager.currentFlow,n=t?.component;if(e.startsWith("launchContext.")){const t=this.flowManager.currentFlow?.context;if(t){const n=e.substring(14),i=new Sf(t).resolveValue(n);return i?.toString()}}else switch(e){case"campaignId":return n?.campaign?.rule;case"campaignName":return n?.campaign?.name;case"campaignLabel":case"campaignPlacement":return n?.campaign?.value??void 0;case"campaignSegment":case"campaignSegmentId":return n?.campaign?.segment;case"campaignExternalSegment":case"campaignExternalSegmentId":return n?.campaign?.external_segment??void 0;case"pageName":return n?.paywall?.name;case"pageId":return n?.paywall?.id;case"flowName":return t?.name;case"flowId":return t?.id;case"objectId":return n?.campaign?.flow?.object_id;case"stepName":return t?.currentFlowStep?.name;case"buttonText":return t?.currentButton?.firstTextValue();case"slideNumber":{const e=n?.getSelectedSlideIndexForCurrentCarousel();return null!=e?`${e+1}`:void 0}default:return}}interpolateLiquidVariables(e){return e.replace(Tf,((e,t)=>{const n=this.resolve(t)??this.urlParams[t];return null!=n?n:""}))}interpolateDeep(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])=>({...e,[t]:this.interpolateDeep(n)})),{}):e}}class Af extends kf{constructor(){super(),this.namespace="urlParams",this.context=Pf(),this.register()}resolveValue(e){return Je.debug("[URLParamsResolver]","Resolving keyPath",e),this.resolveKeyPath(e,this.context)}}class Cf extends kf{getContextProvider(){const e=oh.providers;if(0===e.length)return;const t=e.find((e=>e.flow));return t||e[e.length-1]}constructor(){super(),this.namespace="state",this.register()}resolveValue(e){const t=this.getContextProvider();if(t){if(e.startsWith("formStates.")){const n=e.substring(11);return t.getCurrentFormId(n)}return this.resolveKeyPath(e,t.state)}}}class Lf extends kf{constructor(e){super(),this.namespace="Placement",this.campaign=e,this.register()}resolveValue(e){if("label"!==e)return;if(this.campaign&&void 0!==this.campaign.value&&null!==this.campaign.value)return this.campaign.value;const t=oh.providers;if(0===t.length)return;const n=t.find((e=>e.flow));return n?n.getCurrentPlacementLabel():t[t.length-1]?.getCurrentPlacementLabel()}}class If{constructor(){this.load()}setExternalId(e){return this.externalId=e,this}getExternalId(){return this.externalId}isLoggedIn(){return!!this.externalId}save(){return this.externalId?da.setNamiProfile({externalId:this.externalId}):da.removeNamiProfile(),this}load(){const e=da.getNamiProfile();e&&(this.externalId=e.externalId),oh.setIsLoggedIn(!!this.externalId)}async login(e){const t=await qs.instance.login(e);t.external_id&&oh.setIsLoggedIn(!0),this.setExternalId(t.external_id).save()}async logout(){await qs.instance.logout(),oh.setIsLoggedIn(!1),this.setExternalId(void 0).save()}}var Df;If.instance=new If,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"}(Df||(Df={}));class Rf{constructor(){this.emitter=Zl.getInstance(),wf.shared.registerNamespaceResolver("UserTags",(e=>{const t=e.replace("UserTags.",""),n=Rf.getCustomerAttribute(t);if(null!=n){const e=n.toLowerCase();return"true"===e||"false"===e?"true"===e:isNaN(Number(n))?n:parseInt(n,10)}return null}))}static isLoggedIn(){return If.instance.isLoggedIn()}static loggedInId(){return this.instance.isSDKInitialized||Je.debug(N),If.instance.getExternalId()}static async login(e){if(!this.instance.isSDKInitialized){const e=new ma;throw this.invokeStateHandler(Df.LOGIN,!1,e),e}if(this.inAnonymousMode()){const e=new ka;throw this.invokeStateHandler(Df.LOGIN,!1,e),e}try{if(await If.instance.login(e),await ch.instance.fetchActiveEntitlements(),this.invokeStateHandler(Df.LOGIN,!0),Ff.instance.flowOpen){const e=Ff.instance.currentFlow,t=e?.currentFlowStep;t&&e.executeLifecycle(t,nf)}}catch(e){if(this.invokeStateHandler(Df.LOGIN,!1,e),Ff.instance.flowOpen){const e=Ff.instance.currentFlow,t=e?.currentFlowStep;t&&e.executeLifecycle(t,af)}throw e}}static async logout(){if(!this.instance.isSDKInitialized){const e=new ma;throw this.invokeStateHandler(Df.LOGOUT,!1,e),e}if(this.inAnonymousMode()){const e=new ka;throw this.invokeStateHandler(Df.LOGOUT,!1,e),e}try{if(await If.instance.logout(),await ch.instance.fetchActiveEntitlements(),this.invokeStateHandler(Df.LOGOUT,!0),Ff.instance.flowOpen){const e=Ff.instance.currentFlow,t=e?.currentFlowStep;t&&e.executeLifecycle(t,rf)}}catch(e){if(this.invokeStateHandler(Df.LOGOUT,!1,e),Ff.instance.flowOpen){const e=Ff.instance.currentFlow,t=e?.currentFlowStep;t&&e.executeLifecycle(t,of)}throw e}}static async setCustomerDataPlatformId(e){await this.updateCustomerDataPlatformId(e)}static async clearCustomerDataPlatformId(){await this.updateCustomerDataPlatformId(null)}static registerAccountStateHandler(e){return this.instance.emitter.on("accountStateChange",e),()=>{this.instance.emitter.off("accountStateChange",e)}}static async setAnonymousMode(e){const t=e?Df.ANONYMOUS_MODE_ON:Df.ANONYMOUS_MODE_OFF;if(!this.instance.isSDKInitialized){const e=new ma;throw this.invokeStateHandler(t,!1,e),e}if(this.anonymousModeCapability())if(this.inAnonymousMode()!==e)if(e)da.setAnonymousMode(e),da.resetDevice(),this.refetchConfig(),this.invokeStateHandler(Df.ANONYMOUS_MODE_ON,!0);else{da.clearAnonymousMode(),od&&od.setInMemoryAnonymousMode(!1);const e=da.getNamiConfig()?.namiCommands;await nd.instance.createOrUpdateDevice(kl(e)),da.clearAnonymousUUID(),this.refetchConfig(),this.invokeStateHandler(Df.ANONYMOUS_MODE_OFF,!0)}else{const n=e?new ba:new wa;this.invokeStateHandler(t,!1,n)}else Je.warn("Anonymous mode feature is not enabled for your Nami account. Contact support@nami.ml for details.")}static inAnonymousMode(){return!!this.instance.isSDKInitialized&&sd()}static setCustomerAttribute(e,t){if(!this.instance.isSDKInitialized)throw new ma;if(da.setCustomerAttribute(e,t),Gs(A.PAYWALL_PERSONALIZATION)?(oh.setCustomerAttribute({[e]:t}),Je.debug(`This customer attribute you set is now available for paywall personalization using the smart text variable: ${e}`)):Je.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.`),Ff.instance.flowOpen){const e=Ff.instance.currentFlow;if(e){const t=e.currentFlowStep;t&&e.executeLifecycle(t,df)}}}static getCustomerAttribute(e){if(!this.instance.isSDKInitialized)throw new ma;const t=da.getCustomerAttribute(e);return null!=t?Gs(A.PAYWALL_PERSONALIZATION)?Je.debug(`Found customer attribute. ${e} is available for paywall personalization on this device.`):Je.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.`):Je.warn(`No ${e} customer attribute found.`),t}static getAllCustomerAttributes(){if(!this.instance.isSDKInitialized)throw new ma;return da.getAllCustomerAttributes()}static clearCustomerAttribute(e){if(!this.instance.isSDKInitialized)throw new ma;da.clearCustomerAttribute(e)?(oh.removeCustomerAttribute(e),Je.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.`)):Je.warn(`No value to clear for attribute ${e}.`)}static clearAllCustomerAttributes(){if(!this.instance.isSDKInitialized)throw new ma;da.getAllCustomerAttributesKeys().forEach((e=>{oh.removeCustomerAttribute(e)})),da.clearAllCustomerAttributes(),Je.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.")}static journeyState(){if(!this.instance.isSDKInitialized)throw new ma;return da.getCustomerJourneyState()}static deviceId(){return this.instance.isSDKInitialized?da.getDevice()?.id??U:U}static registerJourneyStateHandler(e){if(Vs("NamiCustomerManager.registerJourneyStateHandler"))return this.instance.emitter.addListener(Be,e),()=>{this.instance.emitter.removeListener(Be,e)}}static invokeStateHandler(e,t,n){this.instance.emitter.emit("accountStateChange",e,t,n)}get isSDKInitialized(){return _h.instance.isInitialized}static async updateCustomerDataPlatformId(e){if(!this.instance.isSDKInitialized){const e=new ma;throw this.invokeStateHandler(Df.CUSTOMER_DATA_PLATFORM_ID_SET,!1,e),e}if(this.inAnonymousMode()){Je.info("Unable to set CDP ID in anonymous mode",{deviceId:da.getDevice()?.id,anonymousMode:!0});const e=new Sa;this.invokeStateHandler(Df.CUSTOMER_DATA_PLATFORM_ID_SET,!1,e)}else try{await nd.instance.updateDeviceField("customer_data_platform_id",e),this.invokeStateHandler(Df.CUSTOMER_DATA_PLATFORM_ID_SET,!0)}catch(e){this.invokeStateHandler(Df.CUSTOMER_DATA_PLATFORM_ID_SET,!1,e)}}static anonymousModeCapability(){if(!this.instance.isSDKInitialized)return!1;const e=Gs(A.ANONYMOUS_MODE_CAPABILITY),t=Gs(A.THIRD_PARTY_TRANSACTIONS);return e&&t}static async refetchConfig(){this.instance.isSDKInitialized&&await Promise.all([id.instance.fetchProducts(),ad.instance.fetchPaywalls().then((e=>ed.instance.fetchCampaignRules(e)))])}}Rf.instance=new Rf;class Wf{constructor(e={}){this.id=e.id??"",this.name=e.name??"",this.steps=e.steps??[],this.screens=e.screens??[],this.resumeFromBookmark=Boolean(e.resume_from_bookmark),this.transition=e.transition??"none"}get allScreensAvailable(){return this.screens.length>0&&il(this.screens)}}class Nf extends Wf{constructor(e,t,n,i){super(e.flow.object??{}),this.stepcrumbs=[],this.branchcrumbs=[],this.activeHandoffSequence=null,this.currentScreenState=null,this.isPaused=!1,this.timerStates={},this.campaign=e,this.component=t,this.context=i,this.manager=n,this.branchcrumbs=[],this.stepcrumbs=[],this.registerResolvers(i);const a=this.findStepByType(Gm);a&&this.forward(a.id)}registerResolvers(e){e&&new Sf(e),new _f,new Af,new Cf,new Lf(this.campaign),wf.shared.registerNamespaceResolver("Flow",(e=>{switch(e){case"Flow.stepcrumbs":return this.stepcrumbs.map((e=>e.id));case"Flow.branchcrumbs":return this.branchcrumbs;default:return}}))}get currentFlowStep(){return this.stepcrumbs.at(-1)}get nextStepAvailable(){return void 0!==this.nextFlowStep}get previousStepAvailable(){const e=!!this.previousFlowStep,t=!1!==this.previousFlowStep?.allow_back_to,n=this.stepcrumbs.slice(0,-1).some((e=>"screen"===e.type));return e&&t&&n}get previousFlowStep(){const e=this.stepcrumbs.length-2;return e>=0?this.stepcrumbs[e]:void 0}get nextFlowStep(){return this.nextStep(this.currentFlowStep)}getStep(e){return this.steps.find((t=>t.id===e))}findStepByType(e){return this.steps.find((t=>t.type===e))}isStepActive(e){return!e.branch_tags||!e.branch_tags.length||e.branch_tags.some((e=>this.branchcrumbs.includes(e)))}finished(){this.manager.finishFlow()}back(){this.previousStepAvailable?this.backToPreviousScreenStep():Je.debug("No previous step available")}next(){const e=this.nextFlowStep;e&&this.forward(e.id)}backToPreviousScreenStep(){if(!1!==this.previousFlowStep?.allow_back_to){for(let e=this.stepcrumbs.length-2;e>=0;e--){const t=this.stepcrumbs[e];if(this.stepcrumbs.pop(),"branch"===t.type&&this.branchcrumbs.length>0&&this.branchcrumbs.pop(),"screen"===t.type&&t.screen){const e=nl(t.screen);return e&&this.component.flowNavigateToScreen(e,{transition:this.transition,direction:"backward"}),void(this.currentScreenState=oh.currentProvider?.state??null)}}Je.warn("No previous screen step found to return to")}else Je.warn(`Not allowed to go back to ${this.previousFlowStep.id}`)}forward(e){const t=this.getStep(e);if(t){if(this.isStepActive(t))switch(t.type){case Gm:case Km:return this.stepcrumbs.push(t),void this.executeLifecycle(t,Zm);case Xm:return void this.handleBranchStep(t);case Vm:return void this.handleScreenStep(t);case Ym:return}}else Je.error(`No step found with id: ${e}`)}pause(){this.isPaused?Je.info("Flow is already paused"):(this.isPaused=!0,this.pausedStepID=this.currentFlowStep?.id,Je.info("Flow paused"))}resumeFromPause(){if(!this.isPaused)return void Je.info("Flow is not paused");if(this.isPaused=!1,!this.pausedStepID)return void Je.warn("No step to resume from");const e=this.pausedStepID;this.pausedStepID=void 0,Je.info(`Flow resumed from step ${e}`),this.forward(e)}executeLifecycle(e,t,n){const i=e.actions[t];i&&this.executeFullLifecycles(i,n)}lifecycles(e){if(!this.currentFlowStep)return;const t=this.currentFlowStep.actions[e];if(t)return t;Je.info(`No actions found for button ${e} on step ${this.currentFlowStep.id}`)}triggerActions(e,t,n){const i=this.lifecycles(e);i&&(this.currentButton=t,this.executeFullLifecycles(i,n))}executeFullLifecycles(e,t){for(const n of e)[n.before,n.action,n.after].forEach((e=>e?.forEach((e=>this.shouldRun(e)&&this.performAction(e,t)))))}triggerBeforeActions(e,t,n){const i=this.lifecycles(e);if(i){this.currentButton=t;for(const e of i)e.before?.forEach((e=>this.shouldRun(e)&&this.performAction(e,n)))}}triggerAfterActions(e,t,n){const i=this.lifecycles(e);if(i){this.currentButton=t;for(const e of i)e.after?.forEach((e=>this.shouldRun(e)&&this.performAction(e,n)))}}currentStepHasHoistedPrimaryActions(e){const t=this.lifecycles(e);return!!t&&t.some((e=>e.action?.length))}shouldRun(e){return!e.conditions||e.conditions.every((e=>wf.shared.evaluate(e)))}performAction(e,t){if(!this.currentFlowStep)return void Je.warn("No current flow step");const n=(e.parameters?.delay?+e.parameters.delay:0)||0,i=n=>{if(this.currentFlowStep?.id===n)switch(e.function){case qm.BACK:this.back();break;case qm.NEXT:e.parameters?.step?this.forward(e.parameters.step):this.next();break;case qm.NAVIGATE:e.parameters?.step?this.previousFlowStep?.id===e.parameters.step?this.back():this.forward(e.parameters.step):this.next();break;case qm.FINISHED:case qm.DISMISS:this.finished();break;case qm.EXIT:{const e=this.steps.find((e=>e.type===Km));e&&this.forward(e.id);break}case qm.PAUSE:this.pause();break;case qm.RESUME:this.resumeFromPause();break;case qm.HANDOFF:if(e.parameters?.handoffTag)if(this.manager.handoffStepHandler)if(e.parameters.handoffData)Je.debug(`Invoking handoffStepHandler with ${e.parameters.handoffTag} ${JSON.stringify(e.parameters.handoffData)}`),this.manager.handoffStepHandler(e.parameters.handoffTag,e.parameters.handoffData);else if(t)Je.debug(`Invoking handoffStepHandler with ${e.parameters.handoffTag} ${JSON.stringify(t)}`),this.manager.handoffStepHandler(e.parameters.handoffTag,t);else if(e.parameters.handoffFormId){const t=this.getFormData();e.parameters.handoffTag===Jm?this.flowHandoffFormSequence():this.manager.handoffStepHandler(e.parameters.handoffTag,t)}else Je.debug(`Invoking handoffStepHandler with ${e.parameters.handoffTag} and no data`),this.manager.handoffStepHandler(e.parameters.handoffTag);else Je.debug("No handoffStepHandler found",e);break;case qm.LOG:e.parameters?.eventName?Je.info(`logEvent → ${e.parameters.eventName}`):Je.warn(`Missing 'eventName' in logEvent action ${e.id??"unknown"}`);break;case qm.TRACK:e.parameters?.eventName?Je.info(`trackEvent → ${e.parameters.eventName}`):Je.warn(`Missing 'eventName' in logEvent action ${e.id??"unknown"}`);break;case qm.SET_VIDEO:e.parameters?.name&&e.parameters.url?oh.setAppSuppliedVideoDetails({name:e.parameters.name,url:e.parameters.url}):Je.warn("Missing name, url for setting video details");break;case qm.BLOCK_BACK:{const t=e.parameters?.step,n=t?this.getStep(t):void 0;n?n.allow_back_to=!1:this.currentFlowStep?this.currentFlowStep.allow_back_to=!1:Je.warn("Missing step for blocking back");break}case qm.FLOW_EVENT:{const t=new xf(this.manager),n=Object.fromEntries(Object.entries(e.parameters??{}).map((([e,n])=>[e,t.interpolateDeep(n)])));this.manager.eventHandler?this.manager.eventHandler(n):Je.warn("Missing event handler",n);break}case qm.FLOW_ENABLED:oh.setUserInteractionEnabled(!0);break;case qm.FLOW_DISABLED:oh.setUserInteractionEnabled(!1);break;case qm.SET_TAGS:e.parameters&&(oh.setUserTags(e.parameters),Object.entries(e.parameters).forEach((([e,t])=>{Rf.setCustomerAttribute(e,t)})));break;default:Je.warn(`Missing action handler for ${e.function}`,e)}else Je.debug(`Skipped action for stale flow step ${n}`)};n?setTimeout(i.bind(this,this.currentFlowStep.id),n):i(this.currentFlowStep.id)}nextStep(e){if(!e)return void Je.error("Next step not found");const t=this.steps.findIndex((t=>t.id===e.id));if(-1===t)return void Je.error(`Could not find next step for step ${e.id}`);const n=this.steps.slice(t+1);for(const e of n){if(this.isStepActive(e))return e}Je.debug(`No active next step found after ${e.id}`)}handleScreenStep(e){const t=nl(e.screen??"");e.screen&&t&&this.campaign?(this.stepcrumbs.push(e),this.component.flowNavigateToScreen(t,{transition:this.transition,direction:"forward"})):Je.error("No paywall or campaign found for next step")}handleBranchStep(e){this.stepcrumbs.push(e);for(const[t,n]of Object.entries(e.actions))if(n)for(const e of n)if(e.action){for(const n of e.action)if(this.shouldRun(n))return this.branchcrumbs.push(t),e.before?.forEach((e=>{this.performAction(e)})),e.action.forEach((e=>{this.shouldRun(e)&&this.performAction(e)})),void e.after?.forEach((e=>{this.performAction(e)}))}else Je.warn(`No actions defined for branch tag ${t}`);Je.warn(`No matching branch condition matched for step ${e.id}`)}getFormData(){return{...oh.currentProvider?.state?.formStates??{}}}flowHandoffFormSequence(){const e=this.currentScreenState?.formStates;if(!e)return void Je.warn("No formStates available for handoff sequence");const t=Object.keys(e).sort();if(0===t.length)return void Je.warn("formStates is empty, no handoffs to perform");const n=t.filter((t=>!0===e[t]));if(0===n.length)return Je.info("No eligible handoff keys after filtering"),void this.manager.resume();this.activeHandoffSequence={formStates:{...e},remainingKeys:[...n]},this.resumeNextHandoff()}resumeNextHandoff(){const e=this.activeHandoffSequence;if(!e)return Je.warn("No active handoff sequence to resume"),void this.manager.resume();if(0===e.remainingKeys.length)return Je.info("All handoffs in the sequence are complete"),this.activeHandoffSequence=null,void this.manager.resume();const t=e.remainingKeys.shift(),n=e.formStates[t];Je.debug(`Starting handoff for ${t} → ${String(n)}`),this.activeHandoffSequence=e;const i=`${t}`;this.manager.handoffStepHandler?.(i,void 0)}}let Ff=class e{static get instance(){return e._instance||(e._instance=new e),e._instance}constructor(){this.flowOpen=!1,this.lastAnimatedFlowProgress=new Map,this.navGraphCache=new WeakMap}static registerStepHandoff(e){this.instance.handoffStepHandler=e}static registerEventHandler(e){this.instance.eventHandler=e}static resume(){const{flowOpen:t,currentFlow:n}=e.instance;if(t&&n&&n.currentFlowStep){if(n.activeHandoffSequence)return Je.debug(`Resuming flow at handoff sequence ${n.currentFlowStep.id}`),void n.resumeNextHandoff();Je.debug(`Resuming flow at step ${n.currentFlowStep.id}`),n.executeLifecycle(n.currentFlowStep,"__resume__")}else Je.warn("Cannot resume: no active flow or current step")}resume(){e.resume()}static finish(){const{flowOpen:t,currentFlow:n}=e.instance;t&&n&&n.currentFlowStep?(Je.debug(`Finishing flow programmatically at step ${n.currentFlowStep.id}`),n.finished()):Je.debug("Cannot finish: no active flow or current step")}static pause(){const{flowOpen:t,currentFlow:n}=e.instance;t&&n&&n.currentFlowStep?!0===n.resumeFromBookmark?n.pause():Je.warn("This flow cannot be paused"):Je.warn("Cannot pause: no active flow or current step")}static isFlowOpen(){return e.instance.flowOpen}presentFlow(e,t,n){const i=new Nf(e,t,this,n);return this.flowOpen=!0,this.currentFlow=i,i}finishFlow(){this.flowOpen=!1,this.currentFlow=void 0,this.lastAnimatedFlowProgress.clear()}getLastAnimatedFlowProgress(e){return this.lastAnimatedFlowProgress.get(e)??0}setLastAnimatedFlowProgress(e,t){this.currentFlow&&this.lastAnimatedFlowProgress.set(e,t)}getCurrentFlowProgress(e){if(!this.currentFlow)return 1;if(!this.currentFlow.currentFlowStep)return 0;const t=this.currentFlow.steps.filter((e=>e.type===Vm));if(0===t.length)return 0;const n=this.currentFlow.stepcrumbs.filter((e=>e.type===Vm));if(0===n.length)return 0;const i=this.buildNavGraph(this.currentFlow),a=this.currentFlow.currentFlowStep,r=this.findBranchPoint(t,i);let o=0;if(r)o=this.calculateBranchingProgress(n,t,a,r,i);else{const e=t.findIndex((e=>e.id===a.id));o=e>=0?(e+1)/t.length:0}return o=Math.max(0,Math.min(1,o)),e&&this.setLastAnimatedFlowProgress(e,o),o}findBranchPoint(e,t){for(const n of e)if(this.hasBranching(n,e,t))return n;return null}calculateBranchingProgress(e,t,n,i,a){const r=e.length,o=t.findIndex((e=>e.id===i.id)),s=e.findIndex((e=>e.id===i.id)),l=t.findIndex((e=>e.id===n.id));if(-1===s||n.id===i.id)return(l+1)/(o+2);const d=this.countForwardScreens(n,t,a),u=r+d;return Je.debug(`Branching progress: visited=${r}, remaining=${d}, total=${u}, step=${n.id}`),r/u}countForwardScreens(e,t,n){const i=t.findIndex((t=>t.id===e.id));if(-1===i)return 0;const a=new Set;let r=0;const o=(e,s)=>{if(a.has(e))return;a.add(e);const l=(n.get(e)||[]).filter((e=>{const n=t.findIndex((t=>t.id===e));return n>i}));if(0!==l.length)for(const e of l)o(e,s+1);else r=Math.max(r,s)};return o(e.id,0),r}hasBranching(e,t,n){const i=t.findIndex((t=>t.id===e.id));if(-1===i)return!1;const a=(n.get(e.id)||[]).filter((e=>{const n=t.findIndex((t=>t.id===e));return n>i}));return a.length>1}buildNavGraph(e){const t=this.navGraphCache.get(e);if(t)return t;const 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){const i=t.parameters?.step;i&&(n.has(e.id)||n.set(e.id,new Set),n.get(e.id).add(i))}}))}))}))}));const i=new Map;return n.forEach(((e,t)=>{i.set(t,Array.from(e))})),this.navGraphCache.set(e,i),i}static getLastAnimatedFlowProgress(e){return this.instance.getLastAnimatedFlowProgress(e)}static setLastAnimatedFlowProgress(e,t){this.instance.setLastAnimatedFlowProgress(e,t)}static getCurrentFlowProgress(e){return this.instance.getCurrentFlowProgress(e)}getCurrentFlowStepAutoAdvanceDelay(){const e=this.currentFlow?.currentFlowStep;if(!e)return null;const t=e.actions?.[ef];if(!t)return null;for(const e of t){const t=e.action??[];for(const e of t)if((e.function===qm.NAVIGATE||e.function===qm.NEXT)&&null!=e.parameters?.delay){const t=e.parameters.delay,n=Number(t);if(!isNaN(n)&&n>0)return n/1e3}}return null}static getCurrentFlowStepAutoAdvanceDelay(){return this.instance.getCurrentFlowStepAutoAdvanceDelay()}};const Of=2;let $f=class{constructor(e){}get _$AU(){return this._$AM._$AU}_$AT(e,t,n){this._$Ct=e,this._$AM=t,this._$Ci=n}_$AS(e,t){return this.update(e,t)}update(e,t){return this.render(...t)}};const{I:jf}=Dm,zf=()=>document.createComment(""),Hf=(e,t,n)=>{const i=e._$AA.parentNode,a=void 0===t?e._$AB:t._$AA;if(void 0===n){const t=i.insertBefore(zf(),a),r=i.insertBefore(zf(),a);n=new jf(t,r,e,e.options)}else{const t=n._$AB.nextSibling,r=n._$AM,o=r!==e;if(o){let t;n._$AQ?.(e),n._$AM=e,void 0!==n._$AP&&(t=e._$AU)!==r._$AU&&n._$AP(t)}if(t!==a||o){let e=n._$AA;for(;e!==t;){const t=e.nextSibling;i.insertBefore(e,a),e=t}}}return n},Bf=(e,t,n=e)=>(e._$AI(t,n),e),Uf={},Gf=e=>{e._$AR(),e._$AA.remove()},Vf=(e,t,n)=>{const i=new Map;for(let a=t;a<=n;a++)i.set(e[a],a);return i},Xf=(e=>(...t)=>({_$litDirective$:e,values:t}))(class extends $f{constructor(e){if(super(e),e.type!==Of)throw Error("repeat() can only be used in text expressions")}dt(e,t,n){let i;void 0===n?n=t:void 0!==t&&(i=t);const a=[],r=[];let o=0;for(const t of e)a[o]=i?i(t,o):o,r[o]=n(t,o),o++;return{values:r,keys:a}}render(e,t,n){return this.dt(e,t,n).values}update(e,[t,n,i]){const a=(e=>e._$AH)(e),{values:r,keys:o}=this.dt(t,n,i);if(!Array.isArray(a))return this.ut=o,r;const s=this.ut??=[],l=[];let d,u,c=0,h=a.length-1,m=0,f=r.length-1;for(;c<=h&&m<=f;)if(null===a[c])c++;else if(null===a[h])h--;else if(s[c]===o[m])l[m]=Bf(a[c],r[m]),c++,m++;else if(s[h]===o[f])l[f]=Bf(a[h],r[f]),h--,f--;else if(s[c]===o[f])l[f]=Bf(a[c],r[f]),Hf(e,l[f+1],a[c]),c++,f--;else if(s[h]===o[m])l[m]=Bf(a[h],r[m]),Hf(e,a[c],a[h]),h--,m++;else if(void 0===d&&(d=Vf(o,m,f),u=Vf(s,c,h)),d.has(s[c]))if(d.has(s[h])){const t=u.get(o[m]),n=void 0!==t?a[t]:null;if(null===n){const t=Hf(e,a[c]);Bf(t,r[m]),l[m]=t}else l[m]=Bf(n,r[m]),Hf(e,a[c],n),a[t]=null;m++}else Gf(a[h]),h--;else Gf(a[c]),c++;for(;m<=f;){const t=Hf(e,l[f+1]);Bf(t,r[m]),l[m++]=t}for(;c<=h;){const e=a[c++];null!==e&&Gf(e)}return this.ut=o,((e,t=Uf)=>{e._$AH=t})(e,l),ym}});const Kf=async e=>{const t=new Set(Array.from(document.fonts.values()).map((e=>e.family)));return e.forEach((e=>{const n=function(e){return t=`${e.family}-${e.style}`,t.replace(/ /g,"");var t}(e);if(t.has(n))return;const i=new FontFace(n,`url(${e.file})`);document.fonts.add(i)})),document.fonts.ready.then()};function Yf(e,t,n){if("undefined"==typeof window||!e||!t)return Je.debug("Swipe detection is not supported in this environment."),{destroy(){},updateOptions(){}};const i={minDistance:n?.minDistance,maxDuration:n?.maxDuration??600,lockAxis:n?.lockAxis,preventScrollOnSwipe:n?.preventScrollOnSwipe,pointerTypes:n?.pointerTypes??["touch"],passiveListeners:n?.passiveListeners??!0,axisHint:n?.axisHint,edgeLeakThreshold:n?.edgeLeakThreshold},a=e.style.touchAction;i.preventScrollOnSwipe&&(e.style.touchAction="none");let r=null,o=0,s=0,l=0,d=0,u=0,c=null,h=null,m=!1,f=!1,p=!1;const g=e=>{try{const t=window.getComputedStyle(e);if(!t)return!1;const n=t.overflowY;if("auto"!==n&&"scroll"!==n)return!1;const i=e;return i.scrollHeight>i.clientHeight}catch{return!1}},v=e=>i.pointerTypes.includes(e.pointerType),y=t=>{const n=t.composedPath?t.composedPath()[0]:t.target;if(v(t)&&null===r){r=t.pointerId,o=l=t.clientX,s=d=t.clientY,u=performance.now(),c=null,p=!1,m=!1,f=!1,h="y"===i.axisHint?((e,t)=>{let n=e;for(;n&&n!==t&&n instanceof HTMLElement;){if(g(n))return n;n=n.parentElement||(n.parentNode?.host??null)}return null})(n,e):null,h||(f=!0);try{e?.setPointerCapture?.(t.pointerId)}catch{try{n?.setPointerCapture?.(t.pointerId)}catch{}}}},b=e=>{if(e.pointerId===r&&v(e)){if(l=e.clientX,d=e.clientY,i.lockAxis&&!c){const e=Math.abs(l-o),t=Math.abs(d-s);(e>2||t>2)&&(c=t>=e?"y":"x")}if("y"===i.axisHint&&("y"===c||!i.lockAxis)){const n=d-s,a=n<0?"up":"down",r=Math.abs(n),c=performance.now()-u,g=r/Math.max(c,1),v=r>=i.minDistance||g>.5;if(h)if(v)f=!0;else if(((e,t)=>!!e&&("down"===t?e.scrollTop>0:e.scrollTop+e.clientHeight<e.scrollHeight-1))(h,a)){if(!(("down"===a&&h.scrollTop<=50||"up"===a&&h.scrollTop+h.clientHeight>=h.scrollHeight-50)&&g>.3))return void(m=!0);f=!0}else f=!0;const y=!h||r>=i.edgeLeakThreshold;if(!p&&!m&&f&&y&&r>=i.minDistance){p=!0;const i=performance.now(),c={direction:"up"===a?"up":"down",distanceX:l-o,distanceY:n,absX:Math.abs(l-o),absY:r,duration:i-u,velocity:r/Math.max(i-u,1),startX:o,startY:s,endX:l,endY:d,startedAt:u,endedAt:i,originalEvent:e};t(c)}}}},w=e=>{if(e.pointerId!==r)return;if(!v(e))return void k();if(h)return void k();if(p||m)return void k();const n=performance.now(),a=n-u,g=l-o,y=d-s,b=Math.abs(g),w=Math.abs(y);let S;S=i.lockAxis&&c?c:"x"===i.axisHint?"x":"y"===i.axisHint?"y":b>=w?"x":"y";const _="x"===S?b:w,M=a<=i.maxDuration;let E=i.minDistance;h&&"y"===S&&f&&(E+=i.edgeLeakThreshold);if(M&&_>=E){let i;i="x"===S?g>0?"right":"left":y>0?"down":"up";const r=_/Math.max(a,1);t({direction:i,distanceX:g,distanceY:y,absX:b,absY:w,duration:a,velocity:r,startX:o,startY:s,endX:l,endY:d,startedAt:u,endedAt:n,originalEvent:e})}k()},k=()=>{r=null,c=null,u=0,h=null,f=!1,m=!1,p=!1},S=!!i.passiveListeners&&{passive:!0},_=i.passiveListeners?{passive:!0,capture:!0}:{capture:!0};e.addEventListener("pointerdown",y,_),e.addEventListener("pointermove",b,S),e.addEventListener("pointerup",w,S),e.addEventListener("pointercancel",w,S),e.addEventListener("lostpointercapture",w,S);return{destroy:()=>{e.removeEventListener("pointerdown",y,_),e.removeEventListener("pointermove",b,S),e.removeEventListener("pointerup",w,S),e.removeEventListener("pointercancel",w,S),e.removeEventListener("lostpointercapture",w,S),i.preventScrollOnSwipe&&(e.style.touchAction=a),k()},updateOptions:t=>{Object.assign(i,t),"boolean"==typeof t.preventScrollOnSwipe&&(t.preventScrollOnSwipe?e.style.touchAction="none":e.style.touchAction=a)}}}let qf=class extends Nm{constructor(e,t,n){return super(),this.pages=[],this.currentOffset=0,this.presentationStyle="fullscreen",this.formFactor=Sl(),this.timeSpentOnPaywall=0,this.animation={transition:"none",direction:"forward"},this._originalBodyStyles={},this._originalDocumentStyles={},this._savedScrollY=0,this._sheetDragStartY=0,this._sheetIsDragging=!1,this._dismissThreshold=100,this.type=e,this.value=t,this.context=n,this.setPaywallData(),this}setPaywallData(){const e=Ol(this.value,this.type);this.paywall=e.paywall,this.campaign=e.campaign}getPresentationStyle(e){const t=e?.template?.initialState?.presentation_style;return(n=t)&&Mh.has(n)?"sheet"===n?"fullscreen":n:"fullscreen";var n}get isHalfSheet(){return"compact_sheet"===this.presentationStyle}connectedCallback(){super.connectedCallback(),window.TVJS?.DirectionalNavigation&&(window.TVJS.DirectionalNavigation.focusRoot=this),document.addEventListener("keydown",this.handleKeyDownEvent.bind(this)),this._swipeHandler=Yf(this,this.handleSwipeEvent.bind(this),{axisHint:"y",lockAxis:!0,minDistance:25,edgeLeakThreshold:15,preventScrollOnSwipe:!1,pointerTypes:["touch"]}),this.presentationStyle=this.getPresentationStyle(this.paywall),this.setOriginalStyles()}disconnectedCallback(){super.disconnectedCallback(),da.clearLaunchId(),window.TVJS?.DirectionalNavigation&&(window.TVJS.DirectionalNavigation.focusRoot=document.body),document.removeEventListener("keydown",this.handleKeyDownEvent.bind(this)),Zl.getInstance().removeAllListeners(ze),this.restoreStyles(),this._halfSheetAbortController?.abort(),this._swipeHandler.destroy()}setOriginalStyles(){"television"===this.formFactor&&(this._originalBodyStyles.overflow=document.body.style.overflow,document.body.style.overflow="hidden"),this._originalBodyStyles.background=document.body.style.background,"phone"===this.formFactor&&(this._originalBodyStyles["overscroll-behavior"]=document.body.style.overscrollBehavior?document.body.style.overscrollBehavior:null,this._originalDocumentStyles["overscroll-behavior"]=document.documentElement.style.overscrollBehavior?document.documentElement.style.overscrollBehavior:null,document.body.style.overscrollBehavior="none",document.documentElement.style.overscrollBehavior="none",this.isHalfSheet||(this._originalBodyStyles.overflow=document.body.style.overflow,document.body.style.overflow="hidden")),this.isHalfSheet&&(this._savedScrollY=window.scrollY,this._originalBodyStyles.position=document.body.style.position||null,this._originalBodyStyles.top=document.body.style.top||null,this._originalBodyStyles.width=document.body.style.width||null,document.body.style.position="fixed",document.body.style.top=`-${this._savedScrollY}px`,document.body.style.width="100%")}restoreStyles(){Object.entries(this._originalBodyStyles).forEach((([e,t])=>{null!==t?document.body.style.setProperty(e,t):document.body.style.removeProperty(e)})),Object.entries(this._originalDocumentStyles).forEach((([e,t])=>{null!==t?document.documentElement.style.setProperty(e,t):document.documentElement.style.removeProperty(e)})),this._savedScrollY>0&&(window.scrollTo(0,this._savedScrollY),this._savedScrollY=0)}handleKeyDownEvent(e){!this.flow||10009!==e.keyCode&&"Backspace"!==e.key&&"GoBack"!==e.key||this.flow.triggerActions(lf)}handleSwipeEvent({direction:e}){"down"===e?this.flow?.triggerActions("__swipe_down__"):"up"===e&&this.flow?.triggerActions("__swipe_up__")}setupHalfSheetDragTracking(){this._halfSheetAbortController?.abort(),this._halfSheetAbortController=new AbortController;const{signal:e}=this._halfSheetAbortController,t=this.shadowRoot?.querySelector(".nami-half-sheet-container"),n=this.shadowRoot?.querySelector(".nami-half-sheet-content");if(!t||!n)return;t.addEventListener("touchstart",(e=>{n.scrollTop>0||(this._sheetDragStartY=e.touches[0].clientY,this._sheetIsDragging=!0)}),{passive:!0,signal:e}),t.addEventListener("touchmove",(e=>{if(!this._sheetIsDragging)return;const n=e.touches[0].clientY-this._sheetDragStartY;n>0&&(t.style.transform=`translateY(${n}px)`,t.style.transition="none",e.preventDefault())}),{passive:!1,signal:e}),t.addEventListener("touchend",(()=>{if(!this._sheetIsDragging)return;this._sheetIsDragging=!1;const e=t.style.transform.match(/translateY\((\d+(?:\.\d+)?)px\)/);if((e?parseFloat(e[1]):0)>this._dismissThreshold){if(this.flow?.currentStepHasHoistedPrimaryActions("__swipe_down__")??!1)t.style.transform="translateY(0)",t.style.transition="transform 0.2s ease-out",this.flow?.triggerActions("__swipe_down__");else{t.style.transform="translateY(100%)",t.style.transition="transform 0.2s ease-in";const e=this.shadowRoot?.querySelector(".nami-half-sheet-backdrop");e&&e.classList.add("nami-dismissing"),setTimeout((()=>{this.flow?.finished()}),200)}}else t.style.transform="translateY(0)",t.style.transition="transform 0.2s ease-out"}),{signal:e})}setupHalfSheetFocusTrap(){const e=this.shadowRoot?.querySelector(".nami-half-sheet-container");if(!e)return;e.focus();const t=this._halfSheetAbortController?.signal;e.addEventListener("keydown",(t=>{if("Tab"!==t.key)return;const n=e.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');if(0===n.length)return;const i=n[0],a=n[n.length-1];t.shiftKey?document.activeElement!==i&&this.shadowRoot?.activeElement!==i||(t.preventDefault(),a.focus()):document.activeElement!==a&&this.shadowRoot?.activeElement!==a||(t.preventDefault(),i.focus())}),t?{signal:t}:void 0)}firstUpdated(){this.timeSpentOnPaywall=Date.now(),Js(this.campaign)&&(this.flow=Ff.instance.presentFlow(this.campaign,this,this.context)),this.isHalfSheet&&this.updateComplete.then((()=>{this.setupHalfSheetDragTracking(),this.setupHalfSheetFocusTrap()}))}updated(e){super.updated(e),this.isHalfSheet&&e.has("presentationStyle")&&(this.setupHalfSheetDragTracking(),this.setupHalfSheetFocusTrap())}getAnimationStyles(e){const t="backward"===this.animation.direction?-1:1;switch(this.animation.transition){case"verticalSlide":return`transform: translateY(${100*(e-this.currentOffset)*t}vh);`;case"slide":return`transform: translateX(${100*(e-this.currentOffset)*t}vw);`;case"fade":return`opacity: ${e===this.currentOffset?1:0};`;default:return""}}async updatePages(e){if(0===this.pages.length||"none"===this.animation.transition)return void(this.pages=[e]);const t=this.pages[this.pages.length-1];t?.id!==e.id&&(this.pages=[t,e],this.currentOffset=0,await this.updateComplete,requestAnimationFrame((()=>{this.currentOffset=1,setTimeout((()=>{this.pages=[e],this.currentOffset=0,this.paywall=e}),250)})))}async flowNavigateToScreen(e,t){this.flow?.previousFlowStep&&this.flow.executeLifecycle(this.flow.previousFlowStep,tf);const n=this.presentationStyle,i=this.getPresentationStyle(e);"fullscreen"===n&&"compact_sheet"===i?console.warn("Unsupported transition: fullscreen → compact_sheet. Presenting as fullscreen."):"compact_sheet"!==n||"fullscreen"!==i&&"sheet"!==i?this.presentationStyle=i:(await this.animateHalfSheetExpand(),this.presentationStyle="fullscreen"),this.animation=t,await this.updatePages(e),this.flow?.currentFlowStep&&this.flow.executeLifecycle(this.flow.currentFlowStep,ef)}async animateHalfSheetExpand(){const e=this.shadowRoot?.querySelector(".nami-half-sheet-container");e&&(e.classList.add("nami-expanding"),await new Promise((e=>setTimeout(e,300))))}getSelectedSlideIndexForCurrentCarousel(){return oh.getSelectedSlideIndex()}renderFlow(){return"undefined"==typeof document?gm``:this.isHalfSheet?this.renderHalfSheet():gm`
92
92
  <div class="nami-flow-container">
93
93
  ${Xf(this.pages,(e=>e.id),((e,t)=>{const n=this.getAnimationStyles(t);return gm`
94
94
  <div class="nami-screen" style="${n} z-index: ${2-t}">${this.renderPaywall(e)}</div>
@@ -11,6 +11,12 @@ export interface INamiRefsInstance {
11
11
  * Called from namiRefs.ts during initialization
12
12
  */
13
13
  export declare function setNamiRefsInstance(instance: INamiRefsInstance): void;
14
+ /**
15
+ * Clears the in-memory anonymous mode flag.
16
+ * Called when setAnonymousMode(false) is invoked to ensure both
17
+ * persistent and session flags are cleared.
18
+ */
19
+ export declare function clearInMemoryAnonymousMode(): void;
14
20
  /**
15
21
  * Utility function to check anonymous mode status
16
22
  * Checks both persistent (storage) and in-memory flags
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@namiml/web-sdk",
3
3
  "type": "module",
4
- "version": "3.3.9-dev.202603172234",
4
+ "version": "3.3.9-dev.202603180145",
5
5
  "source": "src/nami-web.ts",
6
6
  "description": "Subscription monetization infrastructure — drop-in SDK with no-code paywalls, onboarding flows, A/B testing for web",
7
7
  "scripts": {