@letscooee/web-sdk 12.2.3 → 12.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/main.min.js CHANGED
@@ -1,4 +1,4 @@
1
- import{a as js,b as Gs,c as wm,d as Sm,e as Tm,f as Im,g as xm,h as gr,i as zs,j as b,k as Cm,l as Rm,m as Am,n as Dm,o as Xr}from"./chunk-QSSYWKAF.js";import{a as _,b as Z,c as Ai,d as bm,e as Ql,f as vn,g as So}from"./chunk-V7UGKYBN.js";var Zl=Ql(qs=>{"use strict";Object.defineProperty(qs,"__esModule",{value:!0});qs.URLBuilder=void 0;var E_=(function(){function t(e){try{this.base=new URL(e),this.params=new URLSearchParams(this.base.search.slice(1))}catch(r){console.error("Un-parsable URL",r)}}return t.prototype.appendQueryParam=function(e,r){this.params.append(e,r?r.toString():"")},t.prototype.clearQueryParams=function(){return this.params=new URLSearchParams,this},t.prototype.deleteQueryParam=function(e){this.params.delete(e)},t.prototype.getBase=function(){return this.base},t.prototype.getPath=function(){return this.base.pathname},t.prototype.getHostname=function(){return this.base.hostname},t.prototype.getParams=function(){return this.params},t.prototype.getQueryParam=function(e){if(!this.params)return"";var r=this.params.get(e);return!r||r==="undefined"||r==="null"?void 0:r},t.prototype.getQueryString=function(){return this.params.toString()},t.prototype.setPath=function(e){return this.base.pathname=e,this},t.prototype.setQueryParam=function(e,r){return this.params.set(e,r?r.toString():""),this},t.prototype.setQueryString=function(e){if(e)return e[0]==="?"&&(e=e.slice(1)),this.params=new URLSearchParams(e),this},t.prototype.toString=function(){var e=this.params.toString();return e===""?this.base.search="":this.base.search="?"+e,this.base.toString()},t})();qs.URLBuilder=E_});var km=Ql((Um,au)=>{"use strict";(function(t){if(typeof Um=="object"&&typeof au<"u")au.exports=t();else if(typeof define=="function"&&define.amd)define([],t);else{var e;typeof window<"u"?e=window:typeof global<"u"?e=global:typeof self<"u"?e=self:e=this,e.localforage=t()}})(function(){var t,e,r;return(function n(o,i,s){function a(h,m){if(!i[h]){if(!o[h]){var E=typeof Ai=="function"&&Ai;if(!m&&E)return E(h,!0);if(l)return l(h,!0);var y=new Error("Cannot find module '"+h+"'");throw y.code="MODULE_NOT_FOUND",y}var C=i[h]={exports:{}};o[h][0].call(C.exports,function(D){var N=o[h][1][D];return a(N||D)},C,C.exports,n,o,i,s)}return i[h].exports}for(var l=typeof Ai=="function"&&Ai,f=0;f<s.length;f++)a(s[f]);return a})({1:[function(n,o,i){(function(s){"use strict";var a=s.MutationObserver||s.WebKitMutationObserver,l;if(a){var f=0,h=new a(D),m=s.document.createTextNode("");h.observe(m,{characterData:!0}),l=function(){m.data=f=++f%2}}else if(!s.setImmediate&&typeof s.MessageChannel<"u"){var E=new s.MessageChannel;E.port1.onmessage=D,l=function(){E.port2.postMessage(0)}}else"document"in s&&"onreadystatechange"in s.document.createElement("script")?l=function(){var k=s.document.createElement("script");k.onreadystatechange=function(){D(),k.onreadystatechange=null,k.parentNode.removeChild(k),k=null},s.document.documentElement.appendChild(k)}:l=function(){setTimeout(D,0)};var y,C=[];function D(){y=!0;for(var k,X,B=C.length;B;){for(X=C,C=[],k=-1;++k<B;)X[k]();B=C.length}y=!1}o.exports=N;function N(k){C.push(k)===1&&!y&&l()}}).call(this,typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{})},{}],2:[function(n,o,i){"use strict";var s=n(1);function a(){}var l={},f=["REJECTED"],h=["FULFILLED"],m=["PENDING"];o.exports=E;function E(K){if(typeof K!="function")throw new TypeError("resolver must be a function");this.state=m,this.queue=[],this.outcome=void 0,K!==a&&N(this,K)}E.prototype.catch=function(K){return this.then(null,K)},E.prototype.then=function(K,ce){if(typeof K!="function"&&this.state===h||typeof ce!="function"&&this.state===f)return this;var se=new this.constructor(a);if(this.state!==m){var me=this.state===h?K:ce;C(se,me,this.outcome)}else this.queue.push(new y(se,K,ce));return se};function y(K,ce,se){this.promise=K,typeof ce=="function"&&(this.onFulfilled=ce,this.callFulfilled=this.otherCallFulfilled),typeof se=="function"&&(this.onRejected=se,this.callRejected=this.otherCallRejected)}y.prototype.callFulfilled=function(K){l.resolve(this.promise,K)},y.prototype.otherCallFulfilled=function(K){C(this.promise,this.onFulfilled,K)},y.prototype.callRejected=function(K){l.reject(this.promise,K)},y.prototype.otherCallRejected=function(K){C(this.promise,this.onRejected,K)};function C(K,ce,se){s(function(){var me;try{me=ce(se)}catch(Pe){return l.reject(K,Pe)}me===K?l.reject(K,new TypeError("Cannot resolve promise with itself")):l.resolve(K,me)})}l.resolve=function(K,ce){var se=k(D,ce);if(se.status==="error")return l.reject(K,se.value);var me=se.value;if(me)N(K,me);else{K.state=h,K.outcome=ce;for(var Pe=-1,Se=K.queue.length;++Pe<Se;)K.queue[Pe].callFulfilled(ce)}return K},l.reject=function(K,ce){K.state=f,K.outcome=ce;for(var se=-1,me=K.queue.length;++se<me;)K.queue[se].callRejected(ce);return K};function D(K){var ce=K&&K.then;if(K&&(typeof K=="object"||typeof K=="function")&&typeof ce=="function")return function(){ce.apply(K,arguments)}}function N(K,ce){var se=!1;function me(Ge){se||(se=!0,l.reject(K,Ge))}function Pe(Ge){se||(se=!0,l.resolve(K,Ge))}function Se(){ce(Pe,me)}var Re=k(Se);Re.status==="error"&&me(Re.value)}function k(K,ce){var se={};try{se.value=K(ce),se.status="success"}catch(me){se.status="error",se.value=me}return se}E.resolve=X;function X(K){return K instanceof this?K:l.resolve(new this(a),K)}E.reject=B;function B(K){var ce=new this(a);return l.reject(ce,K)}E.all=Q;function Q(K){var ce=this;if(Object.prototype.toString.call(K)!=="[object Array]")return this.reject(new TypeError("must be an array"));var se=K.length,me=!1;if(!se)return this.resolve([]);for(var Pe=new Array(se),Se=0,Re=-1,Ge=new this(a);++Re<se;)Ze(K[Re],Re);return Ge;function Ze(kt,A){ce.resolve(kt).then(R,function(V){me||(me=!0,l.reject(Ge,V))});function R(V){Pe[A]=V,++Se===se&&!me&&(me=!0,l.resolve(Ge,Pe))}}}E.race=_e;function _e(K){var ce=this;if(Object.prototype.toString.call(K)!=="[object Array]")return this.reject(new TypeError("must be an array"));var se=K.length,me=!1;if(!se)return this.resolve([]);for(var Pe=-1,Se=new this(a);++Pe<se;)Re(K[Pe]);return Se;function Re(Ge){ce.resolve(Ge).then(function(Ze){me||(me=!0,l.resolve(Se,Ze))},function(Ze){me||(me=!0,l.reject(Se,Ze))})}}},{1:1}],3:[function(n,o,i){(function(s){"use strict";typeof s.Promise!="function"&&(s.Promise=n(2))}).call(this,typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{})},{2:2}],4:[function(n,o,i){"use strict";var s=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(p){return typeof p}:function(p){return p&&typeof Symbol=="function"&&p.constructor===Symbol&&p!==Symbol.prototype?"symbol":typeof p};function a(p,w){if(!(p instanceof w))throw new TypeError("Cannot call a class as a function")}function l(){try{if(typeof indexedDB<"u")return indexedDB;if(typeof webkitIndexedDB<"u")return webkitIndexedDB;if(typeof mozIndexedDB<"u")return mozIndexedDB;if(typeof OIndexedDB<"u")return OIndexedDB;if(typeof msIndexedDB<"u")return msIndexedDB}catch{return}}var f=l();function h(){try{if(!f||!f.open)return!1;var p=typeof openDatabase<"u"&&/(Safari|iPhone|iPad|iPod)/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)&&!/BlackBerry/.test(navigator.platform),w=typeof fetch=="function"&&fetch.toString().indexOf("[native code")!==-1;return(!p||w)&&typeof indexedDB<"u"&&typeof IDBKeyRange<"u"}catch{return!1}}function m(p,w){p=p||[],w=w||{};try{return new Blob(p,w)}catch(S){if(S.name!=="TypeError")throw S;for(var g=typeof BlobBuilder<"u"?BlobBuilder:typeof MSBlobBuilder<"u"?MSBlobBuilder:typeof MozBlobBuilder<"u"?MozBlobBuilder:WebKitBlobBuilder,T=new g,I=0;I<p.length;I+=1)T.append(p[I]);return T.getBlob(w.type)}}typeof Promise>"u"&&n(3);var E=Promise;function y(p,w){w&&p.then(function(g){w(null,g)},function(g){w(g)})}function C(p,w,g){typeof w=="function"&&p.then(w),typeof g=="function"&&p.catch(g)}function D(p){return typeof p!="string"&&(console.warn(p+" used as a key, but it is not a string."),p=String(p)),p}function N(){if(arguments.length&&typeof arguments[arguments.length-1]=="function")return arguments[arguments.length-1]}var k="local-forage-detect-blob-support",X=void 0,B={},Q=Object.prototype.toString,_e="readonly",K="readwrite";function ce(p){for(var w=p.length,g=new ArrayBuffer(w),T=new Uint8Array(g),I=0;I<w;I++)T[I]=p.charCodeAt(I);return g}function se(p){return new E(function(w){var g=p.transaction(k,K),T=m([""]);g.objectStore(k).put(T,"key"),g.onabort=function(I){I.preventDefault(),I.stopPropagation(),w(!1)},g.oncomplete=function(){var I=navigator.userAgent.match(/Chrome\/(\d+)/),S=navigator.userAgent.match(/Edge\//);w(S||!I||parseInt(I[1],10)>=43)}}).catch(function(){return!1})}function me(p){return typeof X=="boolean"?E.resolve(X):se(p).then(function(w){return X=w,X})}function Pe(p){var w=B[p.name],g={};g.promise=new E(function(T,I){g.resolve=T,g.reject=I}),w.deferredOperations.push(g),w.dbReady?w.dbReady=w.dbReady.then(function(){return g.promise}):w.dbReady=g.promise}function Se(p){var w=B[p.name],g=w.deferredOperations.pop();if(g)return g.resolve(),g.promise}function Re(p,w){var g=B[p.name],T=g.deferredOperations.pop();if(T)return T.reject(w),T.promise}function Ge(p,w){return new E(function(g,T){if(B[p.name]=B[p.name]||qe(),p.db)if(w)Pe(p),p.db.close();else return g(p.db);var I=[p.name];w&&I.push(p.version);var S=f.open.apply(f,I);w&&(S.onupgradeneeded=function(L){var G=S.result;try{G.createObjectStore(p.storeName),L.oldVersion<=1&&G.createObjectStore(k)}catch(z){if(z.name==="ConstraintError")console.warn('The database "'+p.name+'" has been upgraded from version '+L.oldVersion+" to version "+L.newVersion+', but the storage "'+p.storeName+'" already exists.');else throw z}}),S.onerror=function(L){L.preventDefault(),T(S.error)},S.onsuccess=function(){var L=S.result;L.onversionchange=function(G){G.target.close()},g(L),Se(p)}})}function Ze(p){return Ge(p,!1)}function kt(p){return Ge(p,!0)}function A(p,w){if(!p.db)return!0;var g=!p.db.objectStoreNames.contains(p.storeName),T=p.version<p.db.version,I=p.version>p.db.version;if(T&&(p.version!==w&&console.warn('The database "'+p.name+`" can't be downgraded from version `+p.db.version+" to version "+p.version+"."),p.version=p.db.version),I||g){if(g){var S=p.db.version+1;S>p.version&&(p.version=S)}return!0}return!1}function R(p){return new E(function(w,g){var T=new FileReader;T.onerror=g,T.onloadend=function(I){var S=btoa(I.target.result||"");w({__local_forage_encoded_blob:!0,data:S,type:p.type})},T.readAsBinaryString(p)})}function V(p){var w=ce(atob(p.data));return m([w],{type:p.type})}function U(p){return p&&p.__local_forage_encoded_blob}function H(p){var w=this,g=w._initReady().then(function(){var T=B[w._dbInfo.name];if(T&&T.dbReady)return T.dbReady});return C(g,p,p),g}function ne(p){Pe(p);for(var w=B[p.name],g=w.forages,T=0;T<g.length;T++){var I=g[T];I._dbInfo.db&&(I._dbInfo.db.close(),I._dbInfo.db=null)}return p.db=null,Ze(p).then(function(S){return p.db=S,A(p)?kt(p):S}).then(function(S){p.db=w.db=S;for(var L=0;L<g.length;L++)g[L]._dbInfo.db=S}).catch(function(S){throw Re(p,S),S})}function ge(p,w,g,T){T===void 0&&(T=1);try{var I=p.db.transaction(p.storeName,w);g(null,I)}catch(S){if(T>0&&(!p.db||S.name==="InvalidStateError"||S.name==="NotFoundError"))return E.resolve().then(function(){if(!p.db||S.name==="NotFoundError"&&!p.db.objectStoreNames.contains(p.storeName)&&p.version<=p.db.version)return p.db&&(p.version=p.db.version+1),kt(p)}).then(function(){return ne(p).then(function(){ge(p,w,g,T-1)})}).catch(g);g(S)}}function qe(){return{forages:[],db:null,dbReady:null,deferredOperations:[]}}function tt(p){var w=this,g={db:null};if(p)for(var T in p)g[T]=p[T];var I=B[g.name];I||(I=qe(),B[g.name]=I),I.forages.push(w),w._initReady||(w._initReady=w.ready,w.ready=H);var S=[];function L(){return E.resolve()}for(var G=0;G<I.forages.length;G++){var z=I.forages[G];z!==w&&S.push(z._initReady().catch(L))}var q=I.forages.slice(0);return E.all(S).then(function(){return g.db=I.db,Ze(g)}).then(function(J){return g.db=J,A(g,w._defaultConfig.version)?kt(g):J}).then(function(J){g.db=I.db=J,w._dbInfo=g;for(var te=0;te<q.length;te++){var ve=q[te];ve!==w&&(ve._dbInfo.db=g.db,ve._dbInfo.version=g.version)}})}function rt(p,w){var g=this;p=D(p);var T=new E(function(I,S){g.ready().then(function(){ge(g._dbInfo,_e,function(L,G){if(L)return S(L);try{var z=G.objectStore(g._dbInfo.storeName),q=z.get(p);q.onsuccess=function(){var J=q.result;J===void 0&&(J=null),U(J)&&(J=V(J)),I(J)},q.onerror=function(){S(q.error)}}catch(J){S(J)}})}).catch(S)});return y(T,w),T}function _t(p,w){var g=this,T=new E(function(I,S){g.ready().then(function(){ge(g._dbInfo,_e,function(L,G){if(L)return S(L);try{var z=G.objectStore(g._dbInfo.storeName),q=z.openCursor(),J=1;q.onsuccess=function(){var te=q.result;if(te){var ve=te.value;U(ve)&&(ve=V(ve));var Oe=p(ve,te.key,J++);Oe!==void 0?I(Oe):te.continue()}else I()},q.onerror=function(){S(q.error)}}catch(te){S(te)}})}).catch(S)});return y(T,w),T}function Et(p,w,g){var T=this;p=D(p);var I=new E(function(S,L){var G;T.ready().then(function(){return G=T._dbInfo,Q.call(w)==="[object Blob]"?me(G.db).then(function(z){return z?w:R(w)}):w}).then(function(z){ge(T._dbInfo,K,function(q,J){if(q)return L(q);try{var te=J.objectStore(T._dbInfo.storeName);z===null&&(z=void 0);var ve=te.put(z,p);J.oncomplete=function(){z===void 0&&(z=null),S(z)},J.onabort=J.onerror=function(){var Oe=ve.error?ve.error:ve.transaction.error;L(Oe)}}catch(Oe){L(Oe)}})}).catch(L)});return y(I,g),I}function st(p,w){var g=this;p=D(p);var T=new E(function(I,S){g.ready().then(function(){ge(g._dbInfo,K,function(L,G){if(L)return S(L);try{var z=G.objectStore(g._dbInfo.storeName),q=z.delete(p);G.oncomplete=function(){I()},G.onerror=function(){S(q.error)},G.onabort=function(){var J=q.error?q.error:q.transaction.error;S(J)}}catch(J){S(J)}})}).catch(S)});return y(T,w),T}function we(p){var w=this,g=new E(function(T,I){w.ready().then(function(){ge(w._dbInfo,K,function(S,L){if(S)return I(S);try{var G=L.objectStore(w._dbInfo.storeName),z=G.clear();L.oncomplete=function(){T()},L.onabort=L.onerror=function(){var q=z.error?z.error:z.transaction.error;I(q)}}catch(q){I(q)}})}).catch(I)});return y(g,p),g}function He(p){var w=this,g=new E(function(T,I){w.ready().then(function(){ge(w._dbInfo,_e,function(S,L){if(S)return I(S);try{var G=L.objectStore(w._dbInfo.storeName),z=G.count();z.onsuccess=function(){T(z.result)},z.onerror=function(){I(z.error)}}catch(q){I(q)}})}).catch(I)});return y(g,p),g}function Ae(p,w){var g=this,T=new E(function(I,S){if(p<0){I(null);return}g.ready().then(function(){ge(g._dbInfo,_e,function(L,G){if(L)return S(L);try{var z=G.objectStore(g._dbInfo.storeName),q=!1,J=z.openKeyCursor();J.onsuccess=function(){var te=J.result;if(!te){I(null);return}p===0||q?I(te.key):(q=!0,te.advance(p))},J.onerror=function(){S(J.error)}}catch(te){S(te)}})}).catch(S)});return y(T,w),T}function $e(p){var w=this,g=new E(function(T,I){w.ready().then(function(){ge(w._dbInfo,_e,function(S,L){if(S)return I(S);try{var G=L.objectStore(w._dbInfo.storeName),z=G.openKeyCursor(),q=[];z.onsuccess=function(){var J=z.result;if(!J){T(q);return}q.push(J.key),J.continue()},z.onerror=function(){I(z.error)}}catch(J){I(J)}})}).catch(I)});return y(g,p),g}function De(p,w){w=N.apply(this,arguments);var g=this.config();p=typeof p!="function"&&p||{},p.name||(p.name=p.name||g.name,p.storeName=p.storeName||g.storeName);var T=this,I;if(!p.name)I=E.reject("Invalid arguments");else{var S=p.name===g.name&&T._dbInfo.db,L=S?E.resolve(T._dbInfo.db):Ze(p).then(function(G){var z=B[p.name],q=z.forages;z.db=G;for(var J=0;J<q.length;J++)q[J]._dbInfo.db=G;return G});p.storeName?I=L.then(function(G){if(G.objectStoreNames.contains(p.storeName)){var z=G.version+1;Pe(p);var q=B[p.name],J=q.forages;G.close();for(var te=0;te<J.length;te++){var ve=J[te];ve._dbInfo.db=null,ve._dbInfo.version=z}var Oe=new E(function(Ne,ot){var et=f.open(p.name,z);et.onerror=function(Qt){var Ri=et.result;Ri.close(),ot(Qt)},et.onupgradeneeded=function(){var Qt=et.result;Qt.deleteObjectStore(p.storeName)},et.onsuccess=function(){var Qt=et.result;Qt.close(),Ne(Qt)}});return Oe.then(function(Ne){q.db=Ne;for(var ot=0;ot<J.length;ot++){var et=J[ot];et._dbInfo.db=Ne,Se(et._dbInfo)}}).catch(function(Ne){throw(Re(p,Ne)||E.resolve()).catch(function(){}),Ne})}}):I=L.then(function(G){Pe(p);var z=B[p.name],q=z.forages;G.close();for(var J=0;J<q.length;J++){var te=q[J];te._dbInfo.db=null}var ve=new E(function(Oe,Ne){var ot=f.deleteDatabase(p.name);ot.onerror=function(){var et=ot.result;et&&et.close(),Ne(ot.error)},ot.onblocked=function(){console.warn('dropInstance blocked for database "'+p.name+'" until all open connections are closed')},ot.onsuccess=function(){var et=ot.result;et&&et.close(),Oe(et)}});return ve.then(function(Oe){z.db=Oe;for(var Ne=0;Ne<q.length;Ne++){var ot=q[Ne];Se(ot._dbInfo)}}).catch(function(Oe){throw(Re(p,Oe)||E.resolve()).catch(function(){}),Oe})})}return y(I,w),I}var Wt={_driver:"asyncStorage",_initStorage:tt,_support:h(),iterate:_t,getItem:rt,setItem:Et,removeItem:st,clear:we,length:He,key:Ae,keys:$e,dropInstance:De};function d(){return typeof openDatabase=="function"}var c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",u="~~local_forage_type~",v=/^~~local_forage_type~([^~]+)~/,x="__lfsc__:",O=x.length,W="arbf",ue="blob",Ee="si08",ye="ui08",Le="uic8",ke="si16",nt="si32",mr="ur16",Kr="ui32",bo="fl32",dr="fl64",hr=O+W.length,mm=Object.prototype.toString;function dm(p){var w=p.length*.75,g=p.length,T,I=0,S,L,G,z;p[p.length-1]==="="&&(w--,p[p.length-2]==="="&&w--);var q=new ArrayBuffer(w),J=new Uint8Array(q);for(T=0;T<g;T+=4)S=c.indexOf(p[T]),L=c.indexOf(p[T+1]),G=c.indexOf(p[T+2]),z=c.indexOf(p[T+3]),J[I++]=S<<2|L>>4,J[I++]=(L&15)<<4|G>>2,J[I++]=(G&3)<<6|z&63;return q}function zl(p){var w=new Uint8Array(p),g="",T;for(T=0;T<w.length;T+=3)g+=c[w[T]>>2],g+=c[(w[T]&3)<<4|w[T+1]>>4],g+=c[(w[T+1]&15)<<2|w[T+2]>>6],g+=c[w[T+2]&63];return w.length%3===2?g=g.substring(0,g.length-1)+"=":w.length%3===1&&(g=g.substring(0,g.length-2)+"=="),g}function Bv(p,w){var g="";if(p&&(g=mm.call(p)),p&&(g==="[object ArrayBuffer]"||p.buffer&&mm.call(p.buffer)==="[object ArrayBuffer]")){var T,I=x;p instanceof ArrayBuffer?(T=p,I+=W):(T=p.buffer,g==="[object Int8Array]"?I+=Ee:g==="[object Uint8Array]"?I+=ye:g==="[object Uint8ClampedArray]"?I+=Le:g==="[object Int16Array]"?I+=ke:g==="[object Uint16Array]"?I+=mr:g==="[object Int32Array]"?I+=nt:g==="[object Uint32Array]"?I+=Kr:g==="[object Float32Array]"?I+=bo:g==="[object Float64Array]"?I+=dr:w(new Error("Failed to get type for BinaryArray"))),w(I+zl(T))}else if(g==="[object Blob]"){var S=new FileReader;S.onload=function(){var L=u+p.type+"~"+zl(this.result);w(x+ue+L)},S.readAsArrayBuffer(p)}else try{w(JSON.stringify(p))}catch(L){console.error("Couldn't convert value into a JSON string: ",p),w(null,L)}}function Uv(p){if(p.substring(0,O)!==x)return JSON.parse(p);var w=p.substring(hr),g=p.substring(O,hr),T;if(g===ue&&v.test(w)){var I=w.match(v);T=I[1],w=w.substring(I[0].length)}var S=dm(w);switch(g){case W:return S;case ue:return m([S],{type:T});case Ee:return new Int8Array(S);case ye:return new Uint8Array(S);case Le:return new Uint8ClampedArray(S);case ke:return new Int16Array(S);case mr:return new Uint16Array(S);case nt:return new Int32Array(S);case Kr:return new Uint32Array(S);case bo:return new Float32Array(S);case dr:return new Float64Array(S);default:throw new Error("Unkown type: "+g)}}var ql={serialize:Bv,deserialize:Uv,stringToBuffer:dm,bufferToString:zl};function hm(p,w,g,T){p.executeSql("CREATE TABLE IF NOT EXISTS "+w.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],g,T)}function kv(p){var w=this,g={db:null};if(p)for(var T in p)g[T]=typeof p[T]!="string"?p[T].toString():p[T];var I=new E(function(S,L){try{g.db=openDatabase(g.name,String(g.version),g.description,g.size)}catch(G){return L(G)}g.db.transaction(function(G){hm(G,g,function(){w._dbInfo=g,S()},function(z,q){L(q)})},L)});return g.serializer=ql,I}function yn(p,w,g,T,I,S){p.executeSql(g,T,I,function(L,G){G.code===G.SYNTAX_ERR?L.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[w.storeName],function(z,q){q.rows.length?S(z,G):hm(z,w,function(){z.executeSql(g,T,I,S)},S)},S):S(L,G)},S)}function Fv(p,w){var g=this;p=D(p);var T=new E(function(I,S){g.ready().then(function(){var L=g._dbInfo;L.db.transaction(function(G){yn(G,L,"SELECT * FROM "+L.storeName+" WHERE key = ? LIMIT 1",[p],function(z,q){var J=q.rows.length?q.rows.item(0).value:null;J&&(J=L.serializer.deserialize(J)),I(J)},function(z,q){S(q)})})}).catch(S)});return y(T,w),T}function Hv(p,w){var g=this,T=new E(function(I,S){g.ready().then(function(){var L=g._dbInfo;L.db.transaction(function(G){yn(G,L,"SELECT * FROM "+L.storeName,[],function(z,q){for(var J=q.rows,te=J.length,ve=0;ve<te;ve++){var Oe=J.item(ve),Ne=Oe.value;if(Ne&&(Ne=L.serializer.deserialize(Ne)),Ne=p(Ne,Oe.key,ve+1),Ne!==void 0){I(Ne);return}}I()},function(z,q){S(q)})})}).catch(S)});return y(T,w),T}function gm(p,w,g,T){var I=this;p=D(p);var S=new E(function(L,G){I.ready().then(function(){w===void 0&&(w=null);var z=w,q=I._dbInfo;q.serializer.serialize(w,function(J,te){te?G(te):q.db.transaction(function(ve){yn(ve,q,"INSERT OR REPLACE INTO "+q.storeName+" (key, value) VALUES (?, ?)",[p,J],function(){L(z)},function(Oe,Ne){G(Ne)})},function(ve){if(ve.code===ve.QUOTA_ERR){if(T>0){L(gm.apply(I,[p,z,g,T-1]));return}G(ve)}})})}).catch(G)});return y(S,g),S}function $v(p,w,g){return gm.apply(this,[p,w,g,1])}function Vv(p,w){var g=this;p=D(p);var T=new E(function(I,S){g.ready().then(function(){var L=g._dbInfo;L.db.transaction(function(G){yn(G,L,"DELETE FROM "+L.storeName+" WHERE key = ?",[p],function(){I()},function(z,q){S(q)})})}).catch(S)});return y(T,w),T}function Wv(p){var w=this,g=new E(function(T,I){w.ready().then(function(){var S=w._dbInfo;S.db.transaction(function(L){yn(L,S,"DELETE FROM "+S.storeName,[],function(){T()},function(G,z){I(z)})})}).catch(I)});return y(g,p),g}function jv(p){var w=this,g=new E(function(T,I){w.ready().then(function(){var S=w._dbInfo;S.db.transaction(function(L){yn(L,S,"SELECT COUNT(key) as c FROM "+S.storeName,[],function(G,z){var q=z.rows.item(0).c;T(q)},function(G,z){I(z)})})}).catch(I)});return y(g,p),g}function Gv(p,w){var g=this,T=new E(function(I,S){g.ready().then(function(){var L=g._dbInfo;L.db.transaction(function(G){yn(G,L,"SELECT key FROM "+L.storeName+" WHERE id = ? LIMIT 1",[p+1],function(z,q){var J=q.rows.length?q.rows.item(0).key:null;I(J)},function(z,q){S(q)})})}).catch(S)});return y(T,w),T}function zv(p){var w=this,g=new E(function(T,I){w.ready().then(function(){var S=w._dbInfo;S.db.transaction(function(L){yn(L,S,"SELECT key FROM "+S.storeName,[],function(G,z){for(var q=[],J=0;J<z.rows.length;J++)q.push(z.rows.item(J).key);T(q)},function(G,z){I(z)})})}).catch(I)});return y(g,p),g}function qv(p){return new E(function(w,g){p.transaction(function(T){T.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name <> '__WebKitDatabaseInfoTable__'",[],function(I,S){for(var L=[],G=0;G<S.rows.length;G++)L.push(S.rows.item(G).name);w({db:p,storeNames:L})},function(I,S){g(S)})},function(T){g(T)})})}function Yv(p,w){w=N.apply(this,arguments);var g=this.config();p=typeof p!="function"&&p||{},p.name||(p.name=p.name||g.name,p.storeName=p.storeName||g.storeName);var T=this,I;return p.name?I=new E(function(S){var L;p.name===g.name?L=T._dbInfo.db:L=openDatabase(p.name,"","",0),p.storeName?S({db:L,storeNames:[p.storeName]}):S(qv(L))}).then(function(S){return new E(function(L,G){S.db.transaction(function(z){function q(Oe){return new E(function(Ne,ot){z.executeSql("DROP TABLE IF EXISTS "+Oe,[],function(){Ne()},function(et,Qt){ot(Qt)})})}for(var J=[],te=0,ve=S.storeNames.length;te<ve;te++)J.push(q(S.storeNames[te]));E.all(J).then(function(){L()}).catch(function(Oe){G(Oe)})},function(z){G(z)})})}):I=E.reject("Invalid arguments"),y(I,w),I}var Kv={_driver:"webSQLStorage",_initStorage:kv,_support:d(),iterate:Hv,getItem:Fv,setItem:$v,removeItem:Vv,clear:Wv,length:jv,key:Gv,keys:zv,dropInstance:Yv};function Xv(){try{return typeof localStorage<"u"&&"setItem"in localStorage&&!!localStorage.setItem}catch{return!1}}function ym(p,w){var g=p.name+"/";return p.storeName!==w.storeName&&(g+=p.storeName+"/"),g}function Jv(){var p="_localforage_support_test";try{return localStorage.setItem(p,!0),localStorage.removeItem(p),!1}catch{return!0}}function Qv(){return!Jv()||localStorage.length>0}function Zv(p){var w=this,g={};if(p)for(var T in p)g[T]=p[T];return g.keyPrefix=ym(p,w._defaultConfig),Qv()?(w._dbInfo=g,g.serializer=ql,E.resolve()):E.reject()}function e_(p){var w=this,g=w.ready().then(function(){for(var T=w._dbInfo.keyPrefix,I=localStorage.length-1;I>=0;I--){var S=localStorage.key(I);S.indexOf(T)===0&&localStorage.removeItem(S)}});return y(g,p),g}function t_(p,w){var g=this;p=D(p);var T=g.ready().then(function(){var I=g._dbInfo,S=localStorage.getItem(I.keyPrefix+p);return S&&(S=I.serializer.deserialize(S)),S});return y(T,w),T}function r_(p,w){var g=this,T=g.ready().then(function(){for(var I=g._dbInfo,S=I.keyPrefix,L=S.length,G=localStorage.length,z=1,q=0;q<G;q++){var J=localStorage.key(q);if(J.indexOf(S)===0){var te=localStorage.getItem(J);if(te&&(te=I.serializer.deserialize(te)),te=p(te,J.substring(L),z++),te!==void 0)return te}}});return y(T,w),T}function n_(p,w){var g=this,T=g.ready().then(function(){var I=g._dbInfo,S;try{S=localStorage.key(p)}catch{S=null}return S&&(S=S.substring(I.keyPrefix.length)),S});return y(T,w),T}function o_(p){var w=this,g=w.ready().then(function(){for(var T=w._dbInfo,I=localStorage.length,S=[],L=0;L<I;L++){var G=localStorage.key(L);G.indexOf(T.keyPrefix)===0&&S.push(G.substring(T.keyPrefix.length))}return S});return y(g,p),g}function i_(p){var w=this,g=w.keys().then(function(T){return T.length});return y(g,p),g}function s_(p,w){var g=this;p=D(p);var T=g.ready().then(function(){var I=g._dbInfo;localStorage.removeItem(I.keyPrefix+p)});return y(T,w),T}function a_(p,w,g){var T=this;p=D(p);var I=T.ready().then(function(){w===void 0&&(w=null);var S=w;return new E(function(L,G){var z=T._dbInfo;z.serializer.serialize(w,function(q,J){if(J)G(J);else try{localStorage.setItem(z.keyPrefix+p,q),L(S)}catch(te){(te.name==="QuotaExceededError"||te.name==="NS_ERROR_DOM_QUOTA_REACHED")&&G(te),G(te)}})})});return y(I,g),I}function c_(p,w){if(w=N.apply(this,arguments),p=typeof p!="function"&&p||{},!p.name){var g=this.config();p.name=p.name||g.name,p.storeName=p.storeName||g.storeName}var T=this,I;return p.name?I=new E(function(S){p.storeName?S(ym(p,T._defaultConfig)):S(p.name+"/")}).then(function(S){for(var L=localStorage.length-1;L>=0;L--){var G=localStorage.key(L);G.indexOf(S)===0&&localStorage.removeItem(G)}}):I=E.reject("Invalid arguments"),y(I,w),I}var l_={_driver:"localStorageWrapper",_initStorage:Zv,_support:Xv(),iterate:r_,getItem:t_,setItem:a_,removeItem:s_,clear:e_,length:i_,key:n_,keys:o_,dropInstance:c_},u_=function(w,g){return w===g||typeof w=="number"&&typeof g=="number"&&isNaN(w)&&isNaN(g)},f_=function(w,g){for(var T=w.length,I=0;I<T;){if(u_(w[I],g))return!0;I++}return!1},vm=Array.isArray||function(p){return Object.prototype.toString.call(p)==="[object Array]"},Ci={},_m={},wo={INDEXEDDB:Wt,WEBSQL:Kv,LOCALSTORAGE:l_},p_=[wo.INDEXEDDB._driver,wo.WEBSQL._driver,wo.LOCALSTORAGE._driver],Ws=["dropInstance"],Yl=["clear","getItem","iterate","key","keys","length","removeItem","setItem"].concat(Ws),m_={description:"",driver:p_.slice(),name:"localforage",size:4980736,storeName:"keyvaluepairs",version:1};function d_(p,w){p[w]=function(){var g=arguments;return p.ready().then(function(){return p[w].apply(p,g)})}}function Kl(){for(var p=1;p<arguments.length;p++){var w=arguments[p];if(w)for(var g in w)w.hasOwnProperty(g)&&(vm(w[g])?arguments[0][g]=w[g].slice():arguments[0][g]=w[g])}return arguments[0]}var h_=(function(){function p(w){a(this,p);for(var g in wo)if(wo.hasOwnProperty(g)){var T=wo[g],I=T._driver;this[g]=I,Ci[I]||this.defineDriver(T)}this._defaultConfig=Kl({},m_),this._config=Kl({},this._defaultConfig,w),this._driverSet=null,this._initDriver=null,this._ready=!1,this._dbInfo=null,this._wrapLibraryMethodsWithReady(),this.setDriver(this._config.driver).catch(function(){})}return p.prototype.config=function(g){if((typeof g>"u"?"undefined":s(g))==="object"){if(this._ready)return new Error("Can't call config() after localforage has been used.");for(var T in g){if(T==="storeName"&&(g[T]=g[T].replace(/\W/g,"_")),T==="version"&&typeof g[T]!="number")return new Error("Database version must be a number.");this._config[T]=g[T]}return"driver"in g&&g.driver?this.setDriver(this._config.driver):!0}else return typeof g=="string"?this._config[g]:this._config},p.prototype.defineDriver=function(g,T,I){var S=new E(function(L,G){try{var z=g._driver,q=new Error("Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver");if(!g._driver){G(q);return}for(var J=Yl.concat("_initStorage"),te=0,ve=J.length;te<ve;te++){var Oe=J[te],Ne=!f_(Ws,Oe);if((Ne||g[Oe])&&typeof g[Oe]!="function"){G(q);return}}var ot=function(){for(var Ri=function(v_){return function(){var __=new Error("Method "+v_+" is not implemented by the current driver"),Em=E.reject(__);return y(Em,arguments[arguments.length-1]),Em}},Xl=0,y_=Ws.length;Xl<y_;Xl++){var Jl=Ws[Xl];g[Jl]||(g[Jl]=Ri(Jl))}};ot();var et=function(Ri){Ci[z]&&console.info("Redefining LocalForage driver: "+z),Ci[z]=g,_m[z]=Ri,L()};"_support"in g?g._support&&typeof g._support=="function"?g._support().then(et,G):et(!!g._support):et(!0)}catch(Qt){G(Qt)}});return C(S,T,I),S},p.prototype.driver=function(){return this._driver||null},p.prototype.getDriver=function(g,T,I){var S=Ci[g]?E.resolve(Ci[g]):E.reject(new Error("Driver not found."));return C(S,T,I),S},p.prototype.getSerializer=function(g){var T=E.resolve(ql);return C(T,g),T},p.prototype.ready=function(g){var T=this,I=T._driverSet.then(function(){return T._ready===null&&(T._ready=T._initDriver()),T._ready});return C(I,g,g),I},p.prototype.setDriver=function(g,T,I){var S=this;vm(g)||(g=[g]);var L=this._getSupportedDrivers(g);function G(){S._config.driver=S.driver()}function z(te){return S._extend(te),G(),S._ready=S._initStorage(S._config),S._ready}function q(te){return function(){var ve=0;function Oe(){for(;ve<te.length;){var Ne=te[ve];return ve++,S._dbInfo=null,S._ready=null,S.getDriver(Ne).then(z).catch(Oe)}G();var ot=new Error("No available storage method found.");return S._driverSet=E.reject(ot),S._driverSet}return Oe()}}var J=this._driverSet!==null?this._driverSet.catch(function(){return E.resolve()}):E.resolve();return this._driverSet=J.then(function(){var te=L[0];return S._dbInfo=null,S._ready=null,S.getDriver(te).then(function(ve){S._driver=ve._driver,G(),S._wrapLibraryMethodsWithReady(),S._initDriver=q(L)})}).catch(function(){G();var te=new Error("No available storage method found.");return S._driverSet=E.reject(te),S._driverSet}),C(this._driverSet,T,I),this._driverSet},p.prototype.supports=function(g){return!!_m[g]},p.prototype._extend=function(g){Kl(this,g)},p.prototype._getSupportedDrivers=function(g){for(var T=[],I=0,S=g.length;I<S;I++){var L=g[I];this.supports(L)&&T.push(L)}return T},p.prototype._wrapLibraryMethodsWithReady=function(){for(var g=0,T=Yl.length;g<T;g++)d_(this,Yl[g])},p.prototype.createInstance=function(g){return new p(g)},p})(),g_=new h_;o.exports=g_},{3:3}]},{},[4])(4)})});var hg=Ql((nc,dg)=>{"use strict";(function(t,e){typeof nc=="object"&&typeof dg<"u"?e(nc):typeof define=="function"&&define.amd?define(["exports"],e):e((t=typeof globalThis<"u"?globalThis:t||self).Sqrl={})})(nc,function(t){"use strict";function e(A){var R,V,U=new Error(A);return R=U,V=e.prototype,Object.setPrototypeOf?Object.setPrototypeOf(R,V):R.__proto__=V,U}function r(A,R,V){var U=R.slice(0,V).split(/\n/),H=U.length,ne=U[H-1].length+1;throw e(A+=" at line "+H+" col "+ne+`:
1
+ import{a as js,b as Gs,c as wm,d as Sm,e as Tm,f as Im,g as xm,h as gr,i as zs,j as b,k as Cm,l as Rm,m as Am,n as Dm,o as Xr}from"./chunk-YLEAM7UD.js";import{a as _,b as Z,c as Ai,d as bm,e as Ql,f as vn,g as So}from"./chunk-V7UGKYBN.js";var Zl=Ql(qs=>{"use strict";Object.defineProperty(qs,"__esModule",{value:!0});qs.URLBuilder=void 0;var E_=(function(){function t(e){try{this.base=new URL(e),this.params=new URLSearchParams(this.base.search.slice(1))}catch(r){console.error("Un-parsable URL",r)}}return t.prototype.appendQueryParam=function(e,r){this.params.append(e,r?r.toString():"")},t.prototype.clearQueryParams=function(){return this.params=new URLSearchParams,this},t.prototype.deleteQueryParam=function(e){this.params.delete(e)},t.prototype.getBase=function(){return this.base},t.prototype.getPath=function(){return this.base.pathname},t.prototype.getHostname=function(){return this.base.hostname},t.prototype.getParams=function(){return this.params},t.prototype.getQueryParam=function(e){if(!this.params)return"";var r=this.params.get(e);return!r||r==="undefined"||r==="null"?void 0:r},t.prototype.getQueryString=function(){return this.params.toString()},t.prototype.setPath=function(e){return this.base.pathname=e,this},t.prototype.setQueryParam=function(e,r){return this.params.set(e,r?r.toString():""),this},t.prototype.setQueryString=function(e){if(e)return e[0]==="?"&&(e=e.slice(1)),this.params=new URLSearchParams(e),this},t.prototype.toString=function(){var e=this.params.toString();return e===""?this.base.search="":this.base.search="?"+e,this.base.toString()},t})();qs.URLBuilder=E_});var km=Ql((Um,au)=>{"use strict";(function(t){if(typeof Um=="object"&&typeof au<"u")au.exports=t();else if(typeof define=="function"&&define.amd)define([],t);else{var e;typeof window<"u"?e=window:typeof global<"u"?e=global:typeof self<"u"?e=self:e=this,e.localforage=t()}})(function(){var t,e,r;return(function n(o,i,s){function a(h,m){if(!i[h]){if(!o[h]){var E=typeof Ai=="function"&&Ai;if(!m&&E)return E(h,!0);if(l)return l(h,!0);var y=new Error("Cannot find module '"+h+"'");throw y.code="MODULE_NOT_FOUND",y}var C=i[h]={exports:{}};o[h][0].call(C.exports,function(D){var N=o[h][1][D];return a(N||D)},C,C.exports,n,o,i,s)}return i[h].exports}for(var l=typeof Ai=="function"&&Ai,f=0;f<s.length;f++)a(s[f]);return a})({1:[function(n,o,i){(function(s){"use strict";var a=s.MutationObserver||s.WebKitMutationObserver,l;if(a){var f=0,h=new a(D),m=s.document.createTextNode("");h.observe(m,{characterData:!0}),l=function(){m.data=f=++f%2}}else if(!s.setImmediate&&typeof s.MessageChannel<"u"){var E=new s.MessageChannel;E.port1.onmessage=D,l=function(){E.port2.postMessage(0)}}else"document"in s&&"onreadystatechange"in s.document.createElement("script")?l=function(){var k=s.document.createElement("script");k.onreadystatechange=function(){D(),k.onreadystatechange=null,k.parentNode.removeChild(k),k=null},s.document.documentElement.appendChild(k)}:l=function(){setTimeout(D,0)};var y,C=[];function D(){y=!0;for(var k,X,B=C.length;B;){for(X=C,C=[],k=-1;++k<B;)X[k]();B=C.length}y=!1}o.exports=N;function N(k){C.push(k)===1&&!y&&l()}}).call(this,typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{})},{}],2:[function(n,o,i){"use strict";var s=n(1);function a(){}var l={},f=["REJECTED"],h=["FULFILLED"],m=["PENDING"];o.exports=E;function E(K){if(typeof K!="function")throw new TypeError("resolver must be a function");this.state=m,this.queue=[],this.outcome=void 0,K!==a&&N(this,K)}E.prototype.catch=function(K){return this.then(null,K)},E.prototype.then=function(K,ce){if(typeof K!="function"&&this.state===h||typeof ce!="function"&&this.state===f)return this;var se=new this.constructor(a);if(this.state!==m){var me=this.state===h?K:ce;C(se,me,this.outcome)}else this.queue.push(new y(se,K,ce));return se};function y(K,ce,se){this.promise=K,typeof ce=="function"&&(this.onFulfilled=ce,this.callFulfilled=this.otherCallFulfilled),typeof se=="function"&&(this.onRejected=se,this.callRejected=this.otherCallRejected)}y.prototype.callFulfilled=function(K){l.resolve(this.promise,K)},y.prototype.otherCallFulfilled=function(K){C(this.promise,this.onFulfilled,K)},y.prototype.callRejected=function(K){l.reject(this.promise,K)},y.prototype.otherCallRejected=function(K){C(this.promise,this.onRejected,K)};function C(K,ce,se){s(function(){var me;try{me=ce(se)}catch(Pe){return l.reject(K,Pe)}me===K?l.reject(K,new TypeError("Cannot resolve promise with itself")):l.resolve(K,me)})}l.resolve=function(K,ce){var se=k(D,ce);if(se.status==="error")return l.reject(K,se.value);var me=se.value;if(me)N(K,me);else{K.state=h,K.outcome=ce;for(var Pe=-1,Se=K.queue.length;++Pe<Se;)K.queue[Pe].callFulfilled(ce)}return K},l.reject=function(K,ce){K.state=f,K.outcome=ce;for(var se=-1,me=K.queue.length;++se<me;)K.queue[se].callRejected(ce);return K};function D(K){var ce=K&&K.then;if(K&&(typeof K=="object"||typeof K=="function")&&typeof ce=="function")return function(){ce.apply(K,arguments)}}function N(K,ce){var se=!1;function me(Ge){se||(se=!0,l.reject(K,Ge))}function Pe(Ge){se||(se=!0,l.resolve(K,Ge))}function Se(){ce(Pe,me)}var Re=k(Se);Re.status==="error"&&me(Re.value)}function k(K,ce){var se={};try{se.value=K(ce),se.status="success"}catch(me){se.status="error",se.value=me}return se}E.resolve=X;function X(K){return K instanceof this?K:l.resolve(new this(a),K)}E.reject=B;function B(K){var ce=new this(a);return l.reject(ce,K)}E.all=Q;function Q(K){var ce=this;if(Object.prototype.toString.call(K)!=="[object Array]")return this.reject(new TypeError("must be an array"));var se=K.length,me=!1;if(!se)return this.resolve([]);for(var Pe=new Array(se),Se=0,Re=-1,Ge=new this(a);++Re<se;)Ze(K[Re],Re);return Ge;function Ze(kt,A){ce.resolve(kt).then(R,function(V){me||(me=!0,l.reject(Ge,V))});function R(V){Pe[A]=V,++Se===se&&!me&&(me=!0,l.resolve(Ge,Pe))}}}E.race=_e;function _e(K){var ce=this;if(Object.prototype.toString.call(K)!=="[object Array]")return this.reject(new TypeError("must be an array"));var se=K.length,me=!1;if(!se)return this.resolve([]);for(var Pe=-1,Se=new this(a);++Pe<se;)Re(K[Pe]);return Se;function Re(Ge){ce.resolve(Ge).then(function(Ze){me||(me=!0,l.resolve(Se,Ze))},function(Ze){me||(me=!0,l.reject(Se,Ze))})}}},{1:1}],3:[function(n,o,i){(function(s){"use strict";typeof s.Promise!="function"&&(s.Promise=n(2))}).call(this,typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{})},{2:2}],4:[function(n,o,i){"use strict";var s=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(p){return typeof p}:function(p){return p&&typeof Symbol=="function"&&p.constructor===Symbol&&p!==Symbol.prototype?"symbol":typeof p};function a(p,w){if(!(p instanceof w))throw new TypeError("Cannot call a class as a function")}function l(){try{if(typeof indexedDB<"u")return indexedDB;if(typeof webkitIndexedDB<"u")return webkitIndexedDB;if(typeof mozIndexedDB<"u")return mozIndexedDB;if(typeof OIndexedDB<"u")return OIndexedDB;if(typeof msIndexedDB<"u")return msIndexedDB}catch{return}}var f=l();function h(){try{if(!f||!f.open)return!1;var p=typeof openDatabase<"u"&&/(Safari|iPhone|iPad|iPod)/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)&&!/BlackBerry/.test(navigator.platform),w=typeof fetch=="function"&&fetch.toString().indexOf("[native code")!==-1;return(!p||w)&&typeof indexedDB<"u"&&typeof IDBKeyRange<"u"}catch{return!1}}function m(p,w){p=p||[],w=w||{};try{return new Blob(p,w)}catch(S){if(S.name!=="TypeError")throw S;for(var g=typeof BlobBuilder<"u"?BlobBuilder:typeof MSBlobBuilder<"u"?MSBlobBuilder:typeof MozBlobBuilder<"u"?MozBlobBuilder:WebKitBlobBuilder,T=new g,I=0;I<p.length;I+=1)T.append(p[I]);return T.getBlob(w.type)}}typeof Promise>"u"&&n(3);var E=Promise;function y(p,w){w&&p.then(function(g){w(null,g)},function(g){w(g)})}function C(p,w,g){typeof w=="function"&&p.then(w),typeof g=="function"&&p.catch(g)}function D(p){return typeof p!="string"&&(console.warn(p+" used as a key, but it is not a string."),p=String(p)),p}function N(){if(arguments.length&&typeof arguments[arguments.length-1]=="function")return arguments[arguments.length-1]}var k="local-forage-detect-blob-support",X=void 0,B={},Q=Object.prototype.toString,_e="readonly",K="readwrite";function ce(p){for(var w=p.length,g=new ArrayBuffer(w),T=new Uint8Array(g),I=0;I<w;I++)T[I]=p.charCodeAt(I);return g}function se(p){return new E(function(w){var g=p.transaction(k,K),T=m([""]);g.objectStore(k).put(T,"key"),g.onabort=function(I){I.preventDefault(),I.stopPropagation(),w(!1)},g.oncomplete=function(){var I=navigator.userAgent.match(/Chrome\/(\d+)/),S=navigator.userAgent.match(/Edge\//);w(S||!I||parseInt(I[1],10)>=43)}}).catch(function(){return!1})}function me(p){return typeof X=="boolean"?E.resolve(X):se(p).then(function(w){return X=w,X})}function Pe(p){var w=B[p.name],g={};g.promise=new E(function(T,I){g.resolve=T,g.reject=I}),w.deferredOperations.push(g),w.dbReady?w.dbReady=w.dbReady.then(function(){return g.promise}):w.dbReady=g.promise}function Se(p){var w=B[p.name],g=w.deferredOperations.pop();if(g)return g.resolve(),g.promise}function Re(p,w){var g=B[p.name],T=g.deferredOperations.pop();if(T)return T.reject(w),T.promise}function Ge(p,w){return new E(function(g,T){if(B[p.name]=B[p.name]||qe(),p.db)if(w)Pe(p),p.db.close();else return g(p.db);var I=[p.name];w&&I.push(p.version);var S=f.open.apply(f,I);w&&(S.onupgradeneeded=function(L){var G=S.result;try{G.createObjectStore(p.storeName),L.oldVersion<=1&&G.createObjectStore(k)}catch(z){if(z.name==="ConstraintError")console.warn('The database "'+p.name+'" has been upgraded from version '+L.oldVersion+" to version "+L.newVersion+', but the storage "'+p.storeName+'" already exists.');else throw z}}),S.onerror=function(L){L.preventDefault(),T(S.error)},S.onsuccess=function(){var L=S.result;L.onversionchange=function(G){G.target.close()},g(L),Se(p)}})}function Ze(p){return Ge(p,!1)}function kt(p){return Ge(p,!0)}function A(p,w){if(!p.db)return!0;var g=!p.db.objectStoreNames.contains(p.storeName),T=p.version<p.db.version,I=p.version>p.db.version;if(T&&(p.version!==w&&console.warn('The database "'+p.name+`" can't be downgraded from version `+p.db.version+" to version "+p.version+"."),p.version=p.db.version),I||g){if(g){var S=p.db.version+1;S>p.version&&(p.version=S)}return!0}return!1}function R(p){return new E(function(w,g){var T=new FileReader;T.onerror=g,T.onloadend=function(I){var S=btoa(I.target.result||"");w({__local_forage_encoded_blob:!0,data:S,type:p.type})},T.readAsBinaryString(p)})}function V(p){var w=ce(atob(p.data));return m([w],{type:p.type})}function U(p){return p&&p.__local_forage_encoded_blob}function H(p){var w=this,g=w._initReady().then(function(){var T=B[w._dbInfo.name];if(T&&T.dbReady)return T.dbReady});return C(g,p,p),g}function ne(p){Pe(p);for(var w=B[p.name],g=w.forages,T=0;T<g.length;T++){var I=g[T];I._dbInfo.db&&(I._dbInfo.db.close(),I._dbInfo.db=null)}return p.db=null,Ze(p).then(function(S){return p.db=S,A(p)?kt(p):S}).then(function(S){p.db=w.db=S;for(var L=0;L<g.length;L++)g[L]._dbInfo.db=S}).catch(function(S){throw Re(p,S),S})}function ge(p,w,g,T){T===void 0&&(T=1);try{var I=p.db.transaction(p.storeName,w);g(null,I)}catch(S){if(T>0&&(!p.db||S.name==="InvalidStateError"||S.name==="NotFoundError"))return E.resolve().then(function(){if(!p.db||S.name==="NotFoundError"&&!p.db.objectStoreNames.contains(p.storeName)&&p.version<=p.db.version)return p.db&&(p.version=p.db.version+1),kt(p)}).then(function(){return ne(p).then(function(){ge(p,w,g,T-1)})}).catch(g);g(S)}}function qe(){return{forages:[],db:null,dbReady:null,deferredOperations:[]}}function tt(p){var w=this,g={db:null};if(p)for(var T in p)g[T]=p[T];var I=B[g.name];I||(I=qe(),B[g.name]=I),I.forages.push(w),w._initReady||(w._initReady=w.ready,w.ready=H);var S=[];function L(){return E.resolve()}for(var G=0;G<I.forages.length;G++){var z=I.forages[G];z!==w&&S.push(z._initReady().catch(L))}var q=I.forages.slice(0);return E.all(S).then(function(){return g.db=I.db,Ze(g)}).then(function(J){return g.db=J,A(g,w._defaultConfig.version)?kt(g):J}).then(function(J){g.db=I.db=J,w._dbInfo=g;for(var te=0;te<q.length;te++){var ve=q[te];ve!==w&&(ve._dbInfo.db=g.db,ve._dbInfo.version=g.version)}})}function rt(p,w){var g=this;p=D(p);var T=new E(function(I,S){g.ready().then(function(){ge(g._dbInfo,_e,function(L,G){if(L)return S(L);try{var z=G.objectStore(g._dbInfo.storeName),q=z.get(p);q.onsuccess=function(){var J=q.result;J===void 0&&(J=null),U(J)&&(J=V(J)),I(J)},q.onerror=function(){S(q.error)}}catch(J){S(J)}})}).catch(S)});return y(T,w),T}function _t(p,w){var g=this,T=new E(function(I,S){g.ready().then(function(){ge(g._dbInfo,_e,function(L,G){if(L)return S(L);try{var z=G.objectStore(g._dbInfo.storeName),q=z.openCursor(),J=1;q.onsuccess=function(){var te=q.result;if(te){var ve=te.value;U(ve)&&(ve=V(ve));var Oe=p(ve,te.key,J++);Oe!==void 0?I(Oe):te.continue()}else I()},q.onerror=function(){S(q.error)}}catch(te){S(te)}})}).catch(S)});return y(T,w),T}function Et(p,w,g){var T=this;p=D(p);var I=new E(function(S,L){var G;T.ready().then(function(){return G=T._dbInfo,Q.call(w)==="[object Blob]"?me(G.db).then(function(z){return z?w:R(w)}):w}).then(function(z){ge(T._dbInfo,K,function(q,J){if(q)return L(q);try{var te=J.objectStore(T._dbInfo.storeName);z===null&&(z=void 0);var ve=te.put(z,p);J.oncomplete=function(){z===void 0&&(z=null),S(z)},J.onabort=J.onerror=function(){var Oe=ve.error?ve.error:ve.transaction.error;L(Oe)}}catch(Oe){L(Oe)}})}).catch(L)});return y(I,g),I}function st(p,w){var g=this;p=D(p);var T=new E(function(I,S){g.ready().then(function(){ge(g._dbInfo,K,function(L,G){if(L)return S(L);try{var z=G.objectStore(g._dbInfo.storeName),q=z.delete(p);G.oncomplete=function(){I()},G.onerror=function(){S(q.error)},G.onabort=function(){var J=q.error?q.error:q.transaction.error;S(J)}}catch(J){S(J)}})}).catch(S)});return y(T,w),T}function we(p){var w=this,g=new E(function(T,I){w.ready().then(function(){ge(w._dbInfo,K,function(S,L){if(S)return I(S);try{var G=L.objectStore(w._dbInfo.storeName),z=G.clear();L.oncomplete=function(){T()},L.onabort=L.onerror=function(){var q=z.error?z.error:z.transaction.error;I(q)}}catch(q){I(q)}})}).catch(I)});return y(g,p),g}function He(p){var w=this,g=new E(function(T,I){w.ready().then(function(){ge(w._dbInfo,_e,function(S,L){if(S)return I(S);try{var G=L.objectStore(w._dbInfo.storeName),z=G.count();z.onsuccess=function(){T(z.result)},z.onerror=function(){I(z.error)}}catch(q){I(q)}})}).catch(I)});return y(g,p),g}function Ae(p,w){var g=this,T=new E(function(I,S){if(p<0){I(null);return}g.ready().then(function(){ge(g._dbInfo,_e,function(L,G){if(L)return S(L);try{var z=G.objectStore(g._dbInfo.storeName),q=!1,J=z.openKeyCursor();J.onsuccess=function(){var te=J.result;if(!te){I(null);return}p===0||q?I(te.key):(q=!0,te.advance(p))},J.onerror=function(){S(J.error)}}catch(te){S(te)}})}).catch(S)});return y(T,w),T}function $e(p){var w=this,g=new E(function(T,I){w.ready().then(function(){ge(w._dbInfo,_e,function(S,L){if(S)return I(S);try{var G=L.objectStore(w._dbInfo.storeName),z=G.openKeyCursor(),q=[];z.onsuccess=function(){var J=z.result;if(!J){T(q);return}q.push(J.key),J.continue()},z.onerror=function(){I(z.error)}}catch(J){I(J)}})}).catch(I)});return y(g,p),g}function De(p,w){w=N.apply(this,arguments);var g=this.config();p=typeof p!="function"&&p||{},p.name||(p.name=p.name||g.name,p.storeName=p.storeName||g.storeName);var T=this,I;if(!p.name)I=E.reject("Invalid arguments");else{var S=p.name===g.name&&T._dbInfo.db,L=S?E.resolve(T._dbInfo.db):Ze(p).then(function(G){var z=B[p.name],q=z.forages;z.db=G;for(var J=0;J<q.length;J++)q[J]._dbInfo.db=G;return G});p.storeName?I=L.then(function(G){if(G.objectStoreNames.contains(p.storeName)){var z=G.version+1;Pe(p);var q=B[p.name],J=q.forages;G.close();for(var te=0;te<J.length;te++){var ve=J[te];ve._dbInfo.db=null,ve._dbInfo.version=z}var Oe=new E(function(Ne,ot){var et=f.open(p.name,z);et.onerror=function(Qt){var Ri=et.result;Ri.close(),ot(Qt)},et.onupgradeneeded=function(){var Qt=et.result;Qt.deleteObjectStore(p.storeName)},et.onsuccess=function(){var Qt=et.result;Qt.close(),Ne(Qt)}});return Oe.then(function(Ne){q.db=Ne;for(var ot=0;ot<J.length;ot++){var et=J[ot];et._dbInfo.db=Ne,Se(et._dbInfo)}}).catch(function(Ne){throw(Re(p,Ne)||E.resolve()).catch(function(){}),Ne})}}):I=L.then(function(G){Pe(p);var z=B[p.name],q=z.forages;G.close();for(var J=0;J<q.length;J++){var te=q[J];te._dbInfo.db=null}var ve=new E(function(Oe,Ne){var ot=f.deleteDatabase(p.name);ot.onerror=function(){var et=ot.result;et&&et.close(),Ne(ot.error)},ot.onblocked=function(){console.warn('dropInstance blocked for database "'+p.name+'" until all open connections are closed')},ot.onsuccess=function(){var et=ot.result;et&&et.close(),Oe(et)}});return ve.then(function(Oe){z.db=Oe;for(var Ne=0;Ne<q.length;Ne++){var ot=q[Ne];Se(ot._dbInfo)}}).catch(function(Oe){throw(Re(p,Oe)||E.resolve()).catch(function(){}),Oe})})}return y(I,w),I}var Wt={_driver:"asyncStorage",_initStorage:tt,_support:h(),iterate:_t,getItem:rt,setItem:Et,removeItem:st,clear:we,length:He,key:Ae,keys:$e,dropInstance:De};function d(){return typeof openDatabase=="function"}var c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",u="~~local_forage_type~",v=/^~~local_forage_type~([^~]+)~/,x="__lfsc__:",O=x.length,W="arbf",ue="blob",Ee="si08",ye="ui08",Le="uic8",ke="si16",nt="si32",mr="ur16",Kr="ui32",bo="fl32",dr="fl64",hr=O+W.length,mm=Object.prototype.toString;function dm(p){var w=p.length*.75,g=p.length,T,I=0,S,L,G,z;p[p.length-1]==="="&&(w--,p[p.length-2]==="="&&w--);var q=new ArrayBuffer(w),J=new Uint8Array(q);for(T=0;T<g;T+=4)S=c.indexOf(p[T]),L=c.indexOf(p[T+1]),G=c.indexOf(p[T+2]),z=c.indexOf(p[T+3]),J[I++]=S<<2|L>>4,J[I++]=(L&15)<<4|G>>2,J[I++]=(G&3)<<6|z&63;return q}function zl(p){var w=new Uint8Array(p),g="",T;for(T=0;T<w.length;T+=3)g+=c[w[T]>>2],g+=c[(w[T]&3)<<4|w[T+1]>>4],g+=c[(w[T+1]&15)<<2|w[T+2]>>6],g+=c[w[T+2]&63];return w.length%3===2?g=g.substring(0,g.length-1)+"=":w.length%3===1&&(g=g.substring(0,g.length-2)+"=="),g}function Bv(p,w){var g="";if(p&&(g=mm.call(p)),p&&(g==="[object ArrayBuffer]"||p.buffer&&mm.call(p.buffer)==="[object ArrayBuffer]")){var T,I=x;p instanceof ArrayBuffer?(T=p,I+=W):(T=p.buffer,g==="[object Int8Array]"?I+=Ee:g==="[object Uint8Array]"?I+=ye:g==="[object Uint8ClampedArray]"?I+=Le:g==="[object Int16Array]"?I+=ke:g==="[object Uint16Array]"?I+=mr:g==="[object Int32Array]"?I+=nt:g==="[object Uint32Array]"?I+=Kr:g==="[object Float32Array]"?I+=bo:g==="[object Float64Array]"?I+=dr:w(new Error("Failed to get type for BinaryArray"))),w(I+zl(T))}else if(g==="[object Blob]"){var S=new FileReader;S.onload=function(){var L=u+p.type+"~"+zl(this.result);w(x+ue+L)},S.readAsArrayBuffer(p)}else try{w(JSON.stringify(p))}catch(L){console.error("Couldn't convert value into a JSON string: ",p),w(null,L)}}function Uv(p){if(p.substring(0,O)!==x)return JSON.parse(p);var w=p.substring(hr),g=p.substring(O,hr),T;if(g===ue&&v.test(w)){var I=w.match(v);T=I[1],w=w.substring(I[0].length)}var S=dm(w);switch(g){case W:return S;case ue:return m([S],{type:T});case Ee:return new Int8Array(S);case ye:return new Uint8Array(S);case Le:return new Uint8ClampedArray(S);case ke:return new Int16Array(S);case mr:return new Uint16Array(S);case nt:return new Int32Array(S);case Kr:return new Uint32Array(S);case bo:return new Float32Array(S);case dr:return new Float64Array(S);default:throw new Error("Unkown type: "+g)}}var ql={serialize:Bv,deserialize:Uv,stringToBuffer:dm,bufferToString:zl};function hm(p,w,g,T){p.executeSql("CREATE TABLE IF NOT EXISTS "+w.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],g,T)}function kv(p){var w=this,g={db:null};if(p)for(var T in p)g[T]=typeof p[T]!="string"?p[T].toString():p[T];var I=new E(function(S,L){try{g.db=openDatabase(g.name,String(g.version),g.description,g.size)}catch(G){return L(G)}g.db.transaction(function(G){hm(G,g,function(){w._dbInfo=g,S()},function(z,q){L(q)})},L)});return g.serializer=ql,I}function yn(p,w,g,T,I,S){p.executeSql(g,T,I,function(L,G){G.code===G.SYNTAX_ERR?L.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[w.storeName],function(z,q){q.rows.length?S(z,G):hm(z,w,function(){z.executeSql(g,T,I,S)},S)},S):S(L,G)},S)}function Fv(p,w){var g=this;p=D(p);var T=new E(function(I,S){g.ready().then(function(){var L=g._dbInfo;L.db.transaction(function(G){yn(G,L,"SELECT * FROM "+L.storeName+" WHERE key = ? LIMIT 1",[p],function(z,q){var J=q.rows.length?q.rows.item(0).value:null;J&&(J=L.serializer.deserialize(J)),I(J)},function(z,q){S(q)})})}).catch(S)});return y(T,w),T}function Hv(p,w){var g=this,T=new E(function(I,S){g.ready().then(function(){var L=g._dbInfo;L.db.transaction(function(G){yn(G,L,"SELECT * FROM "+L.storeName,[],function(z,q){for(var J=q.rows,te=J.length,ve=0;ve<te;ve++){var Oe=J.item(ve),Ne=Oe.value;if(Ne&&(Ne=L.serializer.deserialize(Ne)),Ne=p(Ne,Oe.key,ve+1),Ne!==void 0){I(Ne);return}}I()},function(z,q){S(q)})})}).catch(S)});return y(T,w),T}function gm(p,w,g,T){var I=this;p=D(p);var S=new E(function(L,G){I.ready().then(function(){w===void 0&&(w=null);var z=w,q=I._dbInfo;q.serializer.serialize(w,function(J,te){te?G(te):q.db.transaction(function(ve){yn(ve,q,"INSERT OR REPLACE INTO "+q.storeName+" (key, value) VALUES (?, ?)",[p,J],function(){L(z)},function(Oe,Ne){G(Ne)})},function(ve){if(ve.code===ve.QUOTA_ERR){if(T>0){L(gm.apply(I,[p,z,g,T-1]));return}G(ve)}})})}).catch(G)});return y(S,g),S}function $v(p,w,g){return gm.apply(this,[p,w,g,1])}function Vv(p,w){var g=this;p=D(p);var T=new E(function(I,S){g.ready().then(function(){var L=g._dbInfo;L.db.transaction(function(G){yn(G,L,"DELETE FROM "+L.storeName+" WHERE key = ?",[p],function(){I()},function(z,q){S(q)})})}).catch(S)});return y(T,w),T}function Wv(p){var w=this,g=new E(function(T,I){w.ready().then(function(){var S=w._dbInfo;S.db.transaction(function(L){yn(L,S,"DELETE FROM "+S.storeName,[],function(){T()},function(G,z){I(z)})})}).catch(I)});return y(g,p),g}function jv(p){var w=this,g=new E(function(T,I){w.ready().then(function(){var S=w._dbInfo;S.db.transaction(function(L){yn(L,S,"SELECT COUNT(key) as c FROM "+S.storeName,[],function(G,z){var q=z.rows.item(0).c;T(q)},function(G,z){I(z)})})}).catch(I)});return y(g,p),g}function Gv(p,w){var g=this,T=new E(function(I,S){g.ready().then(function(){var L=g._dbInfo;L.db.transaction(function(G){yn(G,L,"SELECT key FROM "+L.storeName+" WHERE id = ? LIMIT 1",[p+1],function(z,q){var J=q.rows.length?q.rows.item(0).key:null;I(J)},function(z,q){S(q)})})}).catch(S)});return y(T,w),T}function zv(p){var w=this,g=new E(function(T,I){w.ready().then(function(){var S=w._dbInfo;S.db.transaction(function(L){yn(L,S,"SELECT key FROM "+S.storeName,[],function(G,z){for(var q=[],J=0;J<z.rows.length;J++)q.push(z.rows.item(J).key);T(q)},function(G,z){I(z)})})}).catch(I)});return y(g,p),g}function qv(p){return new E(function(w,g){p.transaction(function(T){T.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name <> '__WebKitDatabaseInfoTable__'",[],function(I,S){for(var L=[],G=0;G<S.rows.length;G++)L.push(S.rows.item(G).name);w({db:p,storeNames:L})},function(I,S){g(S)})},function(T){g(T)})})}function Yv(p,w){w=N.apply(this,arguments);var g=this.config();p=typeof p!="function"&&p||{},p.name||(p.name=p.name||g.name,p.storeName=p.storeName||g.storeName);var T=this,I;return p.name?I=new E(function(S){var L;p.name===g.name?L=T._dbInfo.db:L=openDatabase(p.name,"","",0),p.storeName?S({db:L,storeNames:[p.storeName]}):S(qv(L))}).then(function(S){return new E(function(L,G){S.db.transaction(function(z){function q(Oe){return new E(function(Ne,ot){z.executeSql("DROP TABLE IF EXISTS "+Oe,[],function(){Ne()},function(et,Qt){ot(Qt)})})}for(var J=[],te=0,ve=S.storeNames.length;te<ve;te++)J.push(q(S.storeNames[te]));E.all(J).then(function(){L()}).catch(function(Oe){G(Oe)})},function(z){G(z)})})}):I=E.reject("Invalid arguments"),y(I,w),I}var Kv={_driver:"webSQLStorage",_initStorage:kv,_support:d(),iterate:Hv,getItem:Fv,setItem:$v,removeItem:Vv,clear:Wv,length:jv,key:Gv,keys:zv,dropInstance:Yv};function Xv(){try{return typeof localStorage<"u"&&"setItem"in localStorage&&!!localStorage.setItem}catch{return!1}}function ym(p,w){var g=p.name+"/";return p.storeName!==w.storeName&&(g+=p.storeName+"/"),g}function Jv(){var p="_localforage_support_test";try{return localStorage.setItem(p,!0),localStorage.removeItem(p),!1}catch{return!0}}function Qv(){return!Jv()||localStorage.length>0}function Zv(p){var w=this,g={};if(p)for(var T in p)g[T]=p[T];return g.keyPrefix=ym(p,w._defaultConfig),Qv()?(w._dbInfo=g,g.serializer=ql,E.resolve()):E.reject()}function e_(p){var w=this,g=w.ready().then(function(){for(var T=w._dbInfo.keyPrefix,I=localStorage.length-1;I>=0;I--){var S=localStorage.key(I);S.indexOf(T)===0&&localStorage.removeItem(S)}});return y(g,p),g}function t_(p,w){var g=this;p=D(p);var T=g.ready().then(function(){var I=g._dbInfo,S=localStorage.getItem(I.keyPrefix+p);return S&&(S=I.serializer.deserialize(S)),S});return y(T,w),T}function r_(p,w){var g=this,T=g.ready().then(function(){for(var I=g._dbInfo,S=I.keyPrefix,L=S.length,G=localStorage.length,z=1,q=0;q<G;q++){var J=localStorage.key(q);if(J.indexOf(S)===0){var te=localStorage.getItem(J);if(te&&(te=I.serializer.deserialize(te)),te=p(te,J.substring(L),z++),te!==void 0)return te}}});return y(T,w),T}function n_(p,w){var g=this,T=g.ready().then(function(){var I=g._dbInfo,S;try{S=localStorage.key(p)}catch{S=null}return S&&(S=S.substring(I.keyPrefix.length)),S});return y(T,w),T}function o_(p){var w=this,g=w.ready().then(function(){for(var T=w._dbInfo,I=localStorage.length,S=[],L=0;L<I;L++){var G=localStorage.key(L);G.indexOf(T.keyPrefix)===0&&S.push(G.substring(T.keyPrefix.length))}return S});return y(g,p),g}function i_(p){var w=this,g=w.keys().then(function(T){return T.length});return y(g,p),g}function s_(p,w){var g=this;p=D(p);var T=g.ready().then(function(){var I=g._dbInfo;localStorage.removeItem(I.keyPrefix+p)});return y(T,w),T}function a_(p,w,g){var T=this;p=D(p);var I=T.ready().then(function(){w===void 0&&(w=null);var S=w;return new E(function(L,G){var z=T._dbInfo;z.serializer.serialize(w,function(q,J){if(J)G(J);else try{localStorage.setItem(z.keyPrefix+p,q),L(S)}catch(te){(te.name==="QuotaExceededError"||te.name==="NS_ERROR_DOM_QUOTA_REACHED")&&G(te),G(te)}})})});return y(I,g),I}function c_(p,w){if(w=N.apply(this,arguments),p=typeof p!="function"&&p||{},!p.name){var g=this.config();p.name=p.name||g.name,p.storeName=p.storeName||g.storeName}var T=this,I;return p.name?I=new E(function(S){p.storeName?S(ym(p,T._defaultConfig)):S(p.name+"/")}).then(function(S){for(var L=localStorage.length-1;L>=0;L--){var G=localStorage.key(L);G.indexOf(S)===0&&localStorage.removeItem(G)}}):I=E.reject("Invalid arguments"),y(I,w),I}var l_={_driver:"localStorageWrapper",_initStorage:Zv,_support:Xv(),iterate:r_,getItem:t_,setItem:a_,removeItem:s_,clear:e_,length:i_,key:n_,keys:o_,dropInstance:c_},u_=function(w,g){return w===g||typeof w=="number"&&typeof g=="number"&&isNaN(w)&&isNaN(g)},f_=function(w,g){for(var T=w.length,I=0;I<T;){if(u_(w[I],g))return!0;I++}return!1},vm=Array.isArray||function(p){return Object.prototype.toString.call(p)==="[object Array]"},Ci={},_m={},wo={INDEXEDDB:Wt,WEBSQL:Kv,LOCALSTORAGE:l_},p_=[wo.INDEXEDDB._driver,wo.WEBSQL._driver,wo.LOCALSTORAGE._driver],Ws=["dropInstance"],Yl=["clear","getItem","iterate","key","keys","length","removeItem","setItem"].concat(Ws),m_={description:"",driver:p_.slice(),name:"localforage",size:4980736,storeName:"keyvaluepairs",version:1};function d_(p,w){p[w]=function(){var g=arguments;return p.ready().then(function(){return p[w].apply(p,g)})}}function Kl(){for(var p=1;p<arguments.length;p++){var w=arguments[p];if(w)for(var g in w)w.hasOwnProperty(g)&&(vm(w[g])?arguments[0][g]=w[g].slice():arguments[0][g]=w[g])}return arguments[0]}var h_=(function(){function p(w){a(this,p);for(var g in wo)if(wo.hasOwnProperty(g)){var T=wo[g],I=T._driver;this[g]=I,Ci[I]||this.defineDriver(T)}this._defaultConfig=Kl({},m_),this._config=Kl({},this._defaultConfig,w),this._driverSet=null,this._initDriver=null,this._ready=!1,this._dbInfo=null,this._wrapLibraryMethodsWithReady(),this.setDriver(this._config.driver).catch(function(){})}return p.prototype.config=function(g){if((typeof g>"u"?"undefined":s(g))==="object"){if(this._ready)return new Error("Can't call config() after localforage has been used.");for(var T in g){if(T==="storeName"&&(g[T]=g[T].replace(/\W/g,"_")),T==="version"&&typeof g[T]!="number")return new Error("Database version must be a number.");this._config[T]=g[T]}return"driver"in g&&g.driver?this.setDriver(this._config.driver):!0}else return typeof g=="string"?this._config[g]:this._config},p.prototype.defineDriver=function(g,T,I){var S=new E(function(L,G){try{var z=g._driver,q=new Error("Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver");if(!g._driver){G(q);return}for(var J=Yl.concat("_initStorage"),te=0,ve=J.length;te<ve;te++){var Oe=J[te],Ne=!f_(Ws,Oe);if((Ne||g[Oe])&&typeof g[Oe]!="function"){G(q);return}}var ot=function(){for(var Ri=function(v_){return function(){var __=new Error("Method "+v_+" is not implemented by the current driver"),Em=E.reject(__);return y(Em,arguments[arguments.length-1]),Em}},Xl=0,y_=Ws.length;Xl<y_;Xl++){var Jl=Ws[Xl];g[Jl]||(g[Jl]=Ri(Jl))}};ot();var et=function(Ri){Ci[z]&&console.info("Redefining LocalForage driver: "+z),Ci[z]=g,_m[z]=Ri,L()};"_support"in g?g._support&&typeof g._support=="function"?g._support().then(et,G):et(!!g._support):et(!0)}catch(Qt){G(Qt)}});return C(S,T,I),S},p.prototype.driver=function(){return this._driver||null},p.prototype.getDriver=function(g,T,I){var S=Ci[g]?E.resolve(Ci[g]):E.reject(new Error("Driver not found."));return C(S,T,I),S},p.prototype.getSerializer=function(g){var T=E.resolve(ql);return C(T,g),T},p.prototype.ready=function(g){var T=this,I=T._driverSet.then(function(){return T._ready===null&&(T._ready=T._initDriver()),T._ready});return C(I,g,g),I},p.prototype.setDriver=function(g,T,I){var S=this;vm(g)||(g=[g]);var L=this._getSupportedDrivers(g);function G(){S._config.driver=S.driver()}function z(te){return S._extend(te),G(),S._ready=S._initStorage(S._config),S._ready}function q(te){return function(){var ve=0;function Oe(){for(;ve<te.length;){var Ne=te[ve];return ve++,S._dbInfo=null,S._ready=null,S.getDriver(Ne).then(z).catch(Oe)}G();var ot=new Error("No available storage method found.");return S._driverSet=E.reject(ot),S._driverSet}return Oe()}}var J=this._driverSet!==null?this._driverSet.catch(function(){return E.resolve()}):E.resolve();return this._driverSet=J.then(function(){var te=L[0];return S._dbInfo=null,S._ready=null,S.getDriver(te).then(function(ve){S._driver=ve._driver,G(),S._wrapLibraryMethodsWithReady(),S._initDriver=q(L)})}).catch(function(){G();var te=new Error("No available storage method found.");return S._driverSet=E.reject(te),S._driverSet}),C(this._driverSet,T,I),this._driverSet},p.prototype.supports=function(g){return!!_m[g]},p.prototype._extend=function(g){Kl(this,g)},p.prototype._getSupportedDrivers=function(g){for(var T=[],I=0,S=g.length;I<S;I++){var L=g[I];this.supports(L)&&T.push(L)}return T},p.prototype._wrapLibraryMethodsWithReady=function(){for(var g=0,T=Yl.length;g<T;g++)d_(this,Yl[g])},p.prototype.createInstance=function(g){return new p(g)},p})(),g_=new h_;o.exports=g_},{3:3}]},{},[4])(4)})});var hg=Ql((nc,dg)=>{"use strict";(function(t,e){typeof nc=="object"&&typeof dg<"u"?e(nc):typeof define=="function"&&define.amd?define(["exports"],e):e((t=typeof globalThis<"u"?globalThis:t||self).Sqrl={})})(nc,function(t){"use strict";function e(A){var R,V,U=new Error(A);return R=U,V=e.prototype,Object.setPrototypeOf?Object.setPrototypeOf(R,V):R.__proto__=V,U}function r(A,R,V){var U=R.slice(0,V).split(/\n/),H=U.length,ne=U[H-1].length+1;throw e(A+=" at line "+H+" col "+ne+`:
2
2
 
3
3
  `+R.split(/\n/)[H-1]+`
4
4
  `+Array(ne).join(" ")+"^")}e.prototype=Object.create(Error.prototype,{name:{value:"Squirrelly Error",enumerable:!1}});var n=new Function("return this")().Promise,o=!1;try{o=new Function("return (async function(){}).constructor")()}catch(A){if(!(A instanceof SyntaxError))throw A}function i(A,R){return Object.prototype.hasOwnProperty.call(A,R)}function s(A,R,V){for(var U in R)i(R,U)&&(R[U]==null||typeof R[U]!="object"||U!=="storage"&&U!=="prefixes"||V?A[U]=R[U]:A[U]=s({},R[U]));return A}var a=/^async +/,l=/`(?:\\[\s\S]|\${(?:[^{}]|{(?:[^{}]|{[^}]*})*})*}|(?!\${)[^\\`])*`/g,f=/'(?:\\[\s\w"'\\`]|[^\n\r'\\])*?'/g,h=/"(?:\\[\s\w"'\\`]|[^\n\r"\\])*?"/g,m=/[.*+\-?^${}()|[\]\\]/g;function E(A){return m.test(A)?A.replace(m,"\\$&"):A}function y(A,R){R.rmWhitespace&&(A=A.replace(/[\r\n]+/g,`
@@ -57,4 +57,4 @@ mutation cartDiscountCodesUpdate($cartId: ID!, $discountCodes: [String!]) {
57
57
  <span class="${o}"
58
58
  style="background-color: ${e.pagination.color?.rgba};">
59
59
  </span>
60
- `},navigation:{nextEl:t.querySelector(".swiper-button-next"),prevEl:t.querySelector(".swiper-button-prev")},autoplay:e.autoplay?.enabled?{delay:e.autoplay?.delay,disableOnInteraction:!1,pauseOnMouseEnter:!1}:!1,autoHeight:!0};e.marquee&&r.autoplay&&typeof r.autoplay=="object"&&(r.speed=e.speed,r.autoplay.pauseOnMouseEnter=!0,t.style.setProperty("--swiper-wrapper-transition-timing-function","linear"));let n=new window.CooeeSDK.Swiper(t,r);return t.style.setProperty("--swiper-navigation-size",`${e.navigation.size}px`),n}function Al(t,e,r){let n={color:t.navigation.color?.rgba};return t.pagination.enabled&&(n.transform="translateY(-25%)"),Y("div",{class:"swiper-container",ref:e,style:"max-width: 100%",children:[Y("div",{class:"swiper-wrapper",children:r()}),t.navigation.enabled&&Y("div",{class:"swiper-button-next",style:n,children:Y("span",{})}),t.navigation.enabled&&Y("div",{class:"swiper-button-prev",style:n,children:Y("span",{})}),t.pagination.enabled&&Y("div",{className:"swiper-pagination",style:{bottom:0,top:"unset",position:"relative",color:t.pagination.color?.rgba}})]})}var Ls=class extends Ue{componentDidMount(){wt(()=>{this.setState(()=>({checked:this.props.item.selected.value}))})}render(){return Y("div",{style:this.getCompiledStyles(),className:"lc-checkbox",children:Y("input",{type:"checkbox",checked:this.state.checked,onChange:this.onChange.bind(this),style:{appearance:"auto"}})})}onChange(e){let{checked:r}=e.target;this.props.item.selected.value=r}getTypoStyles(){let e={},r=this.mediaStyle.typo??new at;return e.textAlign=r.alignment,e.justifyContent=r.alignment,e}getComponentStyles(){return Z(_({},this.getTypoStyles()),{display:"flex"})}};var hn=class extends Ue{constructor(e,r){super(e,r)}render(){let e=this.props.element[this.deviceTypeKey],r=e?.src||this.props.element.src||this.props.element.lg?.src;return Y("img",{onClick:this.customOnClick.bind(this),className:"lc-image",alt:e?.name||"Image",onMouseEnter:this.handleMouseEnter.bind(this),onMouseLeave:this.handleMouseLeave.bind(this),src:r,style:this.getCompiledStyles()})}customOnClick(e){this.props.element.clc?.at===be.ADD_TO_CART&&this.props.triggerContext.triggerData.items[0]&&this.onClick(e,{item:this.props.triggerContext.triggerData.items[0]}),this.props.onClick&&this.props.onClick("image")}getComponentStyles(){let e=this.mediaStyle.lout;if(!e||e.pos!=="absolute")return{};let r={zIndex:e.zIndex,cursor:this.props.element.clc?.at?"pointer":"auto"};return this.mediaStyle.size?.w&&(r.width=this.mediaStyle.size.w),this.mediaStyle.size?.h&&(r.height=this.mediaStyle.size.h),r}handleMouseEnter(e){let r=this.props.element[this.deviceTypeKey]?.secondarySrc;r&&(e.currentTarget.src=r)}handleMouseLeave(e){e.currentTarget.src=this.props.element[this.deviceTypeKey]?.src}};var gn=class extends Ue{render(){if(!(this.props.element.hide||!this.matchWhenCondition(this.props.element.when)))return Y("div",{style:this.getCompiledStyles(),class:"lc-flexbox",children:Y(Vn,{elements:this.props.elements,element:this.props.element,triggerContext:this.props.triggerContext})})}getComponentStyles(){let e=this.mediaStyle.flex??new Xo,r={display:"flex",gap:e.gap+"px",flexWrap:e.wrap,flexDirection:e.dir,justifyContent:e.jc,alignItems:e.ai};return e.wrap==="nowrap"&&e.scroll&&(e.dir==="column"?r["overflow-y"]="auto":r["overflow-x"]="auto"),r}};var Ms=class extends gn{render(){if(!(this.props.element.hide||!this.matchWhenCondition(this.props.element.when)))return Y("div",{style:this.getCompiledStyles(),class:"lc-flexbox",children:Y(Si,{elements:this.props.elements,element:this.props.element,triggerContext:this.props.triggerContext,item:this.props.item,noLinks:this.props.noLinks})})}};var Bs=class extends Ue{render(){return Y("select",{style:this.getCompiledStyles(),value:this.props.selectedVariant.selectedSellingPlan.value?.mID??"",onChange:this.onChange.bind(this),disabled:this.state.disabled,className:"lc-dropdown",children:this.createSelectItems()})}componentDidMount(){wt(()=>{this.setState(()=>({disabled:this.props.triggerContext.triggerData.isBundle()?!this.props.item.selected.value:!1}))})}getTypoStyles(){let e={},r=this.mediaStyle.typo??new at;return e.letterSpacing=r.letterSpacing,e.fontSize=r.fs+"px",e.lineHeight=r.lh,e.fontFamily="inherit",e.textAlign=r.alignment,e.fontWeight=r.fw,this.stylesConverter.getColourStyles(r.tc,"color",e),e.boxShadow="none",e}getComponentStyles(){let e={};return this.props.selectedVariant.sellingPlans?.length||(e.visibility="hidden"),_(_({},e),this.getTypoStyles())}createSelectItems(){let e=[],r=this.props.selectedVariant;if(!r.sellingPlans?.length)return[];this.props.triggerContext.triggerData.skipSubscribedItems?r.selectedSellingPlan.value||(r.sellingPlans[0].isSelected=!0,r.changeSellingPlan(r.sellingPlans[0])):e.push(Y("option",{value:"",selected:!r.selectedSellingPlan,children:"One time purchase"}));for(let n of r.sellingPlans??[])e.push(Y("option",{value:n.mID,selected:n.isSelected,children:n.name}));return e}onChange(e){let r=e.target.value;r?this.props.selectedVariant.selectedSellingPlan.value=this.props.selectedVariant.sellingPlans.find(n=>n.mID===r):this.props.selectedVariant.selectedSellingPlan.value=void 0}};var fT=new RegExp('fill="#[a-zA-Z0-9]+"'),Us=class extends Ue{constructor(){super()}render(){let e=this.getCompiledStyles(),r=this.getRating();return r||(e.display="none",r=""),Y("div",{style:e,className:"lc-star-rating",dangerouslySetInnerHTML:{__html:r}})}getRating(){let e={size:this.props.element.iconSize,color:this.props.element.c.hex},r=Vo(this.props.element.fullStar,{svg:e},this.props.triggerContext),n=Vo(this.props.element.halfStart,{svg:e},this.props.triggerContext),o=this.props.review;if(!o?.rating)return"";let i="";if(this.props.element.showSingleStar)i=r;else{let s=5,a=`${o.rating}`.split(".");for(let l=0;l<+a[0];l++)i+=r,s--;a[1]&&(i+=n,s--);for(let l=0;l<s;l++)i+=r.replace(fT,'fill="#f1f1f1"')}return i}getComponentStyles(){return{display:"flex",alignItems:"center"}}};var ks=class extends Ue{render(){return Y("select",{style:this.getCompiledStyles(),value:this.props.item.selectedOrFirstVariant.value.mID,onChange:this.onChange.bind(this),disabled:this.state.disabled,className:"lc-dropdown",children:this.createSelectItems()})}componentDidMount(){wt(()=>{this.setState(()=>({disabled:this.props.triggerContext.triggerData.isBundle()?!this.props.item.selected.value:!1}))})}getTypoStyles(){let e={},r=this.mediaStyle.typo??new at;return e.letterSpacing=r.letterSpacing,e.fontSize=r.fs+"px",e.lineHeight=r.lh,e.fontFamily="inherit",e.textAlign=r.alignment,e.fontWeight=r.fw,this.stylesConverter.getColourStyles(r.tc,"color",e),e.boxShadow="none",e}getComponentStyles(){let e={};return this.props.item.vars?.length===1&&this.props.item.vars[0].name==="Default Title"&&(e.visibility="hidden"),_(_({},e),this.getTypoStyles())}createSelectItems(){let e=[];for(let r of this.props.item.vars)e.push(Y("option",{value:r.mID,disabled:!r.isAvailable,children:r.name}));return e}onChange(e){let r=e.target.value,n=this.props.item.vars.find(o=>o.mID===r);this.props.item.setSelectedVariant(n)}};var lv=()=>{let t=window.ShopifyAnalytics?.meta??{},e=t.selectedVariantId;if(e)return e;if(t.product?.variants?.length>0)return t.product.variants[0].id},om=t=>{if(!t)return;let e;try{e=new URL(t)}catch{return}if(e.hostname!=="cdn.shopify.com")return t;let r=e.pathname.split(".");return r.length!==2?t:(e.pathname=r[0]+"_large."+r[1],e.toString())};var Si=class extends Ue{constructor(e,r){super(e,r),this.setState(()=>({decoration:"unset"}))}renderElement(e){if(!(e.hide||!this.matchWhenCondition(e.when))){if(e.t===4){let r=e;return r.l==="Star Rating"&&!this.props.item.reviews?.rating?void 0:Y(Ms,{element:r,triggerContext:this.props.triggerContext,elements:r.elems,item:this.props.item,noLinks:this.props.noLinks})}if(e.t===6)return this.props.triggerContext.triggerData.isBundle()?Y(Ls,{element:e,item:this.props.item,triggerContext:this.props.triggerContext}):void 0;if(e.t===13){let r=e,n=this.props.item,o=om(n.variantImage??n.firstImageURL),i=om(n.variantSecondaryImage??n.secondaryImageURL);r.lg=r.sm={src:o,name:n.name,secondarySrc:i};let s=Y(hn,{element:r,onClick:this.customOnClick.bind(this),triggerContext:this.props.triggerContext});return this.props.noLinks?s:Y("a",{href:this.props.item.selectedOrFirstVariant.value.link,style:{display:"block"},children:s})}if(e.t===14)return this.renderProductTitle(e);if(e.t===15){let r=e;return this.props.triggerContext.triggerData.isCartEmbed()&&this.props.item.vars?.length===1&&this.props.item.vars[0].name==="Default Title"?void 0:r.showChips?Y("cooee-product-options-picker",{item:this.props.item}):Y(ks,{element:r,item:this.props.item,triggerContext:this.props.triggerContext})}return e.t===16?Y(Bs,{element:e,selectedVariant:this.props.item.selectedOrFirstVariant.value,item:this.props.item,triggerContext:this.props.triggerContext}):e.t===19?Y(Us,{element:e,triggerContext:this.props.triggerContext,review:this.props.item.reviews}):e.t===18||e.t===3?Y(_o,{element:e,item:this.props.item,triggerContext:this.props.triggerContext}):Y(Vn,{elements:[e],element:this.props.element,triggerContext:this.props.triggerContext})}}render(){return this.props.elements.map(e=>this.renderElement(e))}getComponentStyles(){return{}}renderProductTitle(e){let r=Y(Jt,{element:e,onClick:this.customOnClick.bind(this),triggerContext:this.props.triggerContext});return this.props.noLinks?r:Y("a",{href:this.props.item.selectedOrFirstVariant.value.link,style:{display:"block",textDecoration:this.state.decoration},onMouseEnter:this.onMouseEnter.bind(this),onMouseLeave:this.onMouseLeave.bind(this),children:r})}customOnClick(e){this.sendTriggerClicked([this.props.item.toEmbed()],{from:e})}onMouseEnter(){this.setState(()=>({decoration:"underline"}))}onMouseLeave(){this.setState(()=>({decoration:"unset"}))}};var Eo=class extends Ue{productElement;constructor(e,r){super(e,r),this.setState(()=>({decoration:"unset"}))}render(){let e=eo(this.props.element,this.getProductData(),this.props.triggerContext);if(this.productElement=new Nn(e),!(this.productElement.hide||!this.matchWhenCondition(this.productElement.when)))return Y("div",{style:_({},this.getCompiledStyles()),class:"lc-single-product",children:Y(Si,{element:this.productElement,elements:this.productElement.elems,triggerContext:this.props.triggerContext,item:this.props.item,noLinks:this.productElement.noLinks})})}getComponentStyles(){return{flexShrink:0}}getProductData(){if(!this.props.item)return{};let e=this.props.item,r=e.selectedOrFirstVariant.value,n=e.getTemplateVariables();n.product.quantity=this.props.triggerContext.hasManipulatedProductQuantity()?this.props.triggerContext.getManipulatedQuantity(this.props.item.quantity):this.props.item.quantity;let o=this.props.triggerContext.triggerData.discount?.type===Zt.BXGY;return!r.hasEffectivePrice()&&o&&(n.product=Z(_(_({},n.product),Mt("effective_price",r.effectivePrice.value)),{price:""})),n.variant.quantity=this.props.triggerContext.hasManipulatedProductQuantity()?this.props.triggerContext.getManipulatedQuantity(r.quantity):r.quantity,{product:n.product,variant:n.variant,svg:{color:"{{ svg.color }}",size:"{{ svg.size }}"}}}};var Fs=class extends Ue{swiperRef=null;swiperInstance=null;configuration;gap;constructor(e,r){super(e,r),this.configuration=jr()?this.props.element.conf.sm:this.props.element.conf.lg,this.gap=(this.configuration.gap??15)+"px"}componentDidMount(){this.props.element.conf[this.deviceTypeKey].disp===2&&Oc().then(()=>{this.swiperInstance=Rl(this.swiperRef,this.props.element.conf[this.deviceTypeKey])})}componentWillUnmount(){this.swiperInstance&&this.swiperInstance.destroy()}render(){let e=this.props.triggerContext.triggerData.items;e.splice(this.configuration.maxItems??10);let r;if(this.configuration.disp===2){let n=i=>{this.swiperRef=i},o=()=>e?.map(i=>Y("div",{class:"swiper-slide",children:this.getProductFragment(i)}));r=Y("div",{style:Z(_({},this.getCompiledStyles()),{display:"block"}),class:"lc-product-swiper-list",children:Al(this.configuration,n,o)})}else r=Y("div",{style:this.getCompiledStyles(),class:"lc-product-list",children:e?.map((n,o)=>this.getProductFragment(n,o!==e.length-1))});return r}getComponentStyles(){let e=[0,2].includes(this.configuration.disp),r={display:e?"flex":"grid",justifyContent:"safe "+(this.mediaStyle.flex?.jc??"center"),gap:this.gap,flexDirection:this.mediaStyle.flex?.dir??"row"};if(r.flexDirection==="row"){if(e)r.maxWidth="100%",r.overflowY="auto";else if(this.configuration.disp===1){let n=this.props.triggerContext.triggerData,o=n.items.length,i;n.isBundle()?i=this.props.element.prod.symbol?.hide!==!0?o*2-1:o:i=this.props.element.conf[this.deviceTypeKey].maxInRow,r.gridTemplateColumns=`repeat(${i}, auto)`}}return r}getProductFragment(e,r=!1){return Y(Br,{children:[Y(Eo,{element:this.props.element.prod,item:e,triggerContext:this.props.triggerContext}),this.props.triggerContext.triggerData.isBundle()&&r&&this.props.element.prod.symbol&&!this.props.element.prod.symbol.hide&&Y("div",{style:{display:"flex",alignItems:"center",justifyContent:"center"},children:Y(Jt,{element:this.props.element.prod.symbol,triggerContext:this.props.triggerContext})})]},e.mID)}};var Hs=class extends Ue{swiperRef=null;swiperInstance=null;constructor(e,r){super(e,r)}componentDidMount(){Oc().then(()=>{this.swiperInstance=Rl(this.swiperRef,this.props.element.conf)})}componentWillUnmount(){this.swiperInstance&&this.swiperInstance.destroy()}render(){let e=this.props.element,r=o=>{this.swiperRef=o},n=()=>{let o=e.values?.map(a=>Y("div",{class:"swiper-slide",onClick:l=>this.onClick(l,{clickAction:this.getClickAction(a)}),children:this.renderElement(a)}));if(!o?.length)return[];let i=e.conf,s=o.length;if(i.marquee&&s<=Number(i.maxInRow)){let a=Number(i.maxInRow)-s+1;for(let l=0;l<a;l++)o.push(o[l%s])}return o};return Al(e.conf,r,n)}getComponentStyles(){return{}}renderElement(e){let r=this.valueAddedSlide(this.props.element.slide,e);switch(r?.t){case 1:return Y(hn,{element:r,triggerContext:this.props.triggerContext});case 4:return Y(gn,{elements:r.elems,element:r,triggerContext:this.props.triggerContext});default:b.warn("Unknown slide type for carousal")}}valueAddedSlide(e,r){let n=eo(e,{form:r},this.props.triggerContext);return qt.getParsedElement(n)}getClickAction(e){return eo(this.props.element.clc??{},{form:e},this.props.triggerContext)}};var Vn=class extends Ue{constructor(e,r){super(e,r),this.setState(()=>({decoration:"unset"})),wt(()=>{this.setState(()=>({showButton:!this.props.triggerContext.triggerData.isBundle()||!!this.props.triggerContext.selectedItems.length}))})}renderElement(e){if(!e.hide){if(e.t===4){let r=e;return Y(gn,{element:r,triggerContext:this.props.triggerContext,elements:r.elems})}if(e.t===61)return Y(Ps,{element:e,triggerContext:this.props.triggerContext});if(e.t===3)return this.state.showButton?Y(_o,{element:e,triggerContext:this.props.triggerContext}):void 0;if(e.t===2)return Y(Jt,{element:e,triggerContext:this.props.triggerContext});if(e.t===1)return Y(hn,{element:e,triggerContext:this.props.triggerContext});if(e.t===11)return Y(Fs,{element:e,triggerContext:this.props.triggerContext});if(e.t===12)return Y(Eo,{element:e,item:this.props.triggerContext.triggerData.items[0],triggerContext:this.props.triggerContext});if(e.t===62)return Y(Hs,{element:e,triggerContext:this.props.triggerContext})}}render(){return this.props.elements.map(e=>this.renderElement(e))}getComponentStyles(){return{}}};var $s=class extends Ue{clickAction;isClickable;constructor(e,r){super(e,r),this.clickAction=this.props.element.clc,this.isClickable=this.clickAction?.at===be.GO_TO_URL&&!!Uo(this.clickAction.gu?.u)||this.clickAction?.at===be.OPEN_CART||this.clickAction?.at===be.INITIATE_CHECKOUT}componentDidMount(){wt(()=>{let e=this.props.triggerContext.triggerData,r=this.props.triggerContext.selectedItems;e.calculateDiscountData(r,this.props.triggerContext.shouldGiveFBTDiscount)})}render(){return Y(Br,{children:[Y("div",{style:this.getCompiledStyles(),class:"lc-container",onClick:e=>{this.onClick(e,{clickAction:this.clickAction})},children:Y(Vn,{elements:this.props.elements,element:this.props.element,triggerContext:this.props.triggerContext})}),this.props.triggerContext.triggerData.id==="preview"&&Y("div",{class:"letscooee-preview-badge",children:["#",this.props.triggerContext.triggerData.shortID," preview"]})]})}getComponentStyles(){let e={position:"relative",overflow:"hidden",display:"block"};return this.isClickable&&(e.cursor="pointer"),e}};var vt=class t{constructor(e){this.engagementTrigger=e;this.triggerContext=new Cr(new Date,this.engagementTrigger)}static currentEngagements=new Set;static engagementIDsWithTrackedDisplay=new Set;static DEBOUNCE_TIME=1e3;rootContainer;widgetElement;widget;triggerContext;observers=[];renderedCount=0;scrollSubscription;variation;isExclusionWithBVariation;isRendering=!1;renderSilently(){this.render().catch(e=>{ae(e,"render-widget",{triggerContext:this.triggerContext})})}destroy(){b.verbose(`${this.engagementTrigger} will be destroyed`),this.preDestroy(),this.removeFromRendered(),this.rootContainer?.remove(),t.engagementIDsWithTrackedDisplay.delete(this.engagementTrigger.shortID),vp(this.engagementTrigger.content?.afterDeleteJS)}async render(){if(this.isRendering){b.verbose(`${this.engagementTrigger} rendering already in progress, skipping`);return}this.isRendering=!0;try{if(this.engagementTrigger.shouldGetVariationImmediately()){let e=await this.getVariation();this.handleVariationResponse(e)}if(this.rootContainer=await this.getWidgetContainer(!0),!this.rootContainer){b.warn(`${this.engagementTrigger} no section found to render the widget`);return}this.afterRootContainerCreated(),this.widget=this.engagementTrigger.widget,await this.getVariationIfRequired(),await this.runChoresBeforeRender(),this.attachScroll(),await this.checkAndSendEvent(),this.triggerContext.renderer=this,vp(this.engagementTrigger.content?.afterRenderJS)}finally{this.isRendering=!1}}matches(e){return this.engagementTrigger.shortID===e.shortID}async updateAndReRender(e){b.info(`${this.engagementTrigger} will be updated`),this.updateItems(e.items,this.engagementTrigger.items),await this.update(e),await this.render()}async update(e){}rerender(){this.rootContainer?.isConnected||(b.info(`${this.engagementTrigger} deleted. Will be re-rendered`),this.preDestroy(),this.renderSilently())}updateAngularWidget(){return this.widgetElement?.isConnected?(this.widgetElement.update(),!0):!1}preDestroy(){this.scrollSubscription?.unsubscribe(),this.observers.forEach(e=>{e?.disconnect&&e.disconnect()})}afterRootContainerCreated(){}isAllOkToRender(){return!!this.widget}async getVariationIfRequired(){if(this.engagementTrigger.shouldSkipVariation()){b.verbose(`${this.engagementTrigger} already has necessary data to render`);return}let e=await this.observeWidgetContainerInViewport();this.handleVariationResponse(e)}handleVariationResponse(e){e&&(b.log(`${this.engagementTrigger} visitor has been assigned to variation ${e.variation}`),e.items?.length&&(this.engagementTrigger.items=e.items.map(r=>new Ct(r)),this.engagementTrigger.nonMutableItems=e.items.map(r=>new Ct(r))),e.bundleFrom&&(this.engagementTrigger.bundleFrom=new Ct(e.bundleFrom)),e.discount&&(this.engagementTrigger.discount=e.discount),e.placement&&(this.triggerContext.triggerData.placement=e.placement),e.props&&tr.hasKeys(e.props)&&(this.engagementTrigger.props=_(_({},this.engagementTrigger.props),e.props)),e.content&&(this.triggerContext.triggerData.content=new is(e.content)),this.triggerContext.triggerData.widget=this.widget=new ei(e.widget),this.triggerContext.triggerData.contentID=e.contentID,this.triggerContext.triggerData.variation=this.variation=e.variation,this.triggerContext.triggerData.placement=e.placement,this.triggerContext.triggerData.manipulation=e.manipulation,this.triggerContext.triggerData.entryAnimation=e.entryAnimation??"NONE",this.isExclusionWithBVariation=this.engagementTrigger.isExclusionTesting()&&this.variation==="b",this.isExclusionWithBVariation&&(this.rootContainer.style.height="0.5px"))}addToRendered(){this.renderedCount++,b.info(`${this.engagementTrigger} rendered \u2705 ${Mh(this.renderedCount)} time`)}removeFromRendered(){this instanceof dt?dt.currentEngagements.delete(this):t.currentEngagements.delete(this)}async getVariation(){b.log(`${this.engagementTrigger} get variation`);let e={engagementID:this.engagementTrigger.engagementID,isPreview:this.engagementTrigger.id==="preview"};try{return(await uv(e)).data}catch(r){if(r instanceof vr&&r.response?.status===400)return;ae(r,"get-variation",{engagementTrigger:this.engagementTrigger});return}}async observeWidgetContainerInViewport(){if(!this.rootContainer){b.warn(`${this.engagementTrigger} No root container found to watch for viewport`);return}let e=window.innerHeight*.3,r={root:null,rootMargin:`${e}px 0px ${e}px 0px`,threshold:0};return this.isInViewport()?this.getVariation():new Promise(n=>{let o=new IntersectionObserver((i,s)=>{i.forEach(async a=>{if(a.isIntersecting){b.log(`${this.engagementTrigger} root container is near the viewport. Fetching variation`);let l=await this.getVariation();n(l),s.unobserve(this.rootContainer)}})},r);o.observe(this.rootContainer),this.observers.push(o)})}attachScroll(){this.scrollSubscription=ho(window,"scroll").pipe(Kt(t.DEBOUNCE_TIME)).subscribe(()=>{this.checkAndSendEvent()})}checkAndSendEvent(){let e=this.engagementTrigger.shortID;if(t.engagementIDsWithTrackedDisplay.has(e)||!this.isInViewport())return;let n={};this.triggerContext.triggerData.items?.length&&(n.promotedMIDs=this.engagementTrigger.items?.map(s=>s.mID));let o=this.isExclusionWithBVariation?"CE Campaign Holdout":"CE Trigger Displayed",i=new xe(o,n,this.engagementTrigger);i.name==="CE Campaign Holdout"&&(i.trigger.holdout=!0),Ut(i),t.engagementIDsWithTrackedDisplay.add(e),this.scrollSubscription.unsubscribe()}generateParentElementID(){return`letscooee-${this.engagementTrigger.shortID}`}createAngularWidget(e){let r=this.widgetElement=document.createElement(e);return r.cart=de.getCurrent(),r.triggerContext=this.triggerContext,r.engagementTrigger=this.engagementTrigger,r.setAttribute("engagement",this.engagementTrigger.shortID),this.rootContainer.appendChild(r),this.addToRendered(),r}getParentElement(e,r=document){let n=r.getElementById(e);if(n)return n;let o=this.engagementTrigger.objective.toLowerCase().replaceAll("_","-"),i=this.engagementTrigger.shortID;return n=document.createElement("div"),n.id=e,n.className=`letscooee letscooee-engagement engagement-${i} lc-${o}`,n.dataset.engagementId=i,this.engagementTrigger.id==="preview"&&(n.className+=" letscooee-preview"),n.style.display="block",n.style.minHeight="0.5px",n.style.minWidth="0.5px",n}startRendering(){let e=this.rootContainer;this.triggerContext.triggerData.hasSwiperElement()&&(e=this.rootContainer?.shadowRoot||this.rootContainer?.attachShadow({mode:"open"}),_p(e)),Jh(Mf($s,{element:this.widget.cont,triggerContext:this.triggerContext,elements:this.widget.elems}),e),this.addToRendered()}isInViewport(){let e=this.rootContainer?.getBoundingClientRect();if(!e)return!1;let r=window.innerHeight||document.documentElement.clientHeight,o=(Math.min(e.bottom,r)-Math.max(e.top,0))*e.width,i=e.width*e.height,s=o/i*100;return this.engagementTrigger.isAnySplit()?s>0:s>=30}async getWidgetContainer(e){if(this.rootContainer?.isConnected)return this.rootContainer;let r=await this.createParentElementWithPlacement(e);if(r)return r;let n=`.letscooee[data-engagement-id="${this.triggerContext.triggerData.shortID}"]`;return document.querySelector(n)}async createParentElementWithPlacement(e){let r=this.engagementTrigger.placement;if(!r?.selector)return b.info(`\u26A0\uFE0F${this.engagementTrigger} does not have a selector`),null;let n=r.selector,o;if(n.includes(":shadow")){let l=n.split(":shadow");o=(await Cn(l[0].trim()))?.shadowRoot,n=l[1].trim(),o&&_p(o,!1)}b.verbose(`${this.engagementTrigger} attempt to render ${r.position} "${n}"`);let i=await Cn(n,10,o??document);if(!i)return b.warn(`${this.engagementTrigger} no placement found with ${n}`),null;let s=this.generateParentElementID(),a=this.getParentElement(s);if(!e)return a;switch(r.position){case Dt.BEFORE1:case Dt.BEFORE:{i.parentElement?.insertBefore(a,i);break}case Dt.INSIDE_FIRST1:case Dt.INSIDE_FIRST:{i.insertBefore(a,i.firstChild);break}case Dt.INSIDE_LAST1:case Dt.INSIDE_LAST:{i.appendChild(a);break}case Dt.AFTER1:case Dt.AFTER:default:i.parentElement?.insertBefore(a,i.nextSibling)}return a}async runChoresBeforeRender(){if(this.isExclusionWithBVariation)return;if(!this.isAllOkToRender()){b.info(`\u26A0\uFE0F ${this.engagementTrigger} could not be rendered`);return}b.verbose(`${this.engagementTrigger} will be rendered`);let e;try{e=await Cl(this.engagementTrigger)}catch(r){b.info(`\u203C\uFE0F${this.engagementTrigger} could not render as items failed to refresh`,r);return}if(!this.engagementTrigger.isCollectionPromoted()&&!e?.length&&this.engagementTrigger.isProductPromoted()){b.info(`\u203C\uFE0F${this.engagementTrigger} could not render as no products promoted`);return}this.engagementTrigger.items=e,this.startRendering()}updateItems(e,r){let n=this.getItemDiff(e,r),o=this.getItemDiff(r,e);r.push(...n);for(let i of o)Jr.remove(r,i)}getItemDiff(e,r){return e.filter(n=>!r.some(o=>o.selectedOrFirstVariant.value.mID===n.selectedOrFirstVariant.value.mID))}};var dt=class extends vt{static currentEngagements=new Set;constructor(e){super(e)}rerender(){super.rerender(),this.checkAndSendEvent()}observeWidgetContainerInViewport(){return this.getVariation()}generateParentElementID(){let e=super.generateParentElementID();return this.engagementTrigger.isSubscriptionUpsell()&&(e+=`-${this.engagementTrigger.items[0].selectedOrFirstVariant.value.mID}`),e}checkAndSendEvent(){if(!Qe.get().isOpen()&&fe().pageName!=="cart"){b.log("Do not send display event as neither the cart drawer nor the cart page is open.");return}return super.checkAndSendEvent()}};var pT=t=>t,fv=t=>t.filter(e=>e.removedNodes&&e.removedNodes.length>0);function pv(t,e={childList:!0,subtree:!0},r=500,n=pT){return ul(o=>{let i=new MutationObserver(s=>o(s));return i.observe(t,e),i},(o,i)=>i.disconnect()).pipe(pn(o=>n(o)),qp(o=>o.length>0),Kt(r))}var Dl=class t{constructor(e,r){this.engagementTrigger=e;this.element=r;this.cartItems=de.getCurrent().items}cartItems;static renderCartUpsell(e){let r=e.placement;if(!r?.selector){b.warn(`No placement available for ${e.objective}`,e.shortID);return}let n=Array.from(document.querySelectorAll(r.selector));if(!n?.length){b.warn(`No placement found for ${e.objective}`,e.shortID);return}for(let o of n)new t(e,o).render()}render(){let e=this.findCartItemFromHTMLElement();if(!e||this.engagementTrigger.skipSubscribedItems&&e.selling_plan_allocation)return;let r=this.engagementTrigger.items.find(h=>h.mID===e.product_id.toString());if(!r)return;let n=r.vars.find(h=>h.mID===e.id.toString());if(!n)return;let o=new Ur(n),i=e.selling_plan_allocation?.selling_plan;if(i)for(let h of o.sellingPlans??[])h.mID===i.id.toString()&&(h.isSelected=!0,o.changeSellingPlan(h));let s=new Ct(r);s.vars=[o],s.selectedOrFirstVariant.value=o;let a=`lc-cart-item-${this.engagementTrigger.shortID}-${r.mID}`;this.element.classList.add(a);let l=new St(this.engagementTrigger);l.placement.selector=`.${a}`,l.items=[s];let f=new dt(l);f.renderSilently(),this.watchForCartItemDeletion(f,a)}watchForCartItemDeletion(e,r){let n=new MutationObserver(o=>{o.forEach(i=>{i.removedNodes.forEach(s=>{s===this.element&&(b.verbose(`${r} has been removed`),e.destroy(),n.disconnect())})})});n.observe(this.element.parentElement,{childList:!0,subtree:!0})}findCartItemFromHTMLElement(){let e=this.element.innerHTML;return this.cartItems.find(r=>{if(!(e.includes(r.url)||e.includes(r.variant_id))&&(!e.includes(r.product_title)||r.variant_title&&!e.includes(r.variant_title)))return!1;let n=r.selling_plan_allocation?.selling_plan?.name;return!(n&&!e.includes(n))})}};var Ol=class extends dt{ctaExecutor=new Hn;constructor(e){super(e)}async update(e){await super.update(e),this.engagementTrigger.progressBarConfig.update(e.progressBarConfig),await this.checkMilestoneTryCatch(),this.updateAngularWidget()}isAllOkToRender(){return!!this.engagementTrigger.progressBarConfig}startRendering(){if(this.updateAngularWidget()){this.addToRendered();return}this.createAngularWidget("cooee-progressbar"),this.checkMilestoneTryCatch()}async checkMilestoneTryCatch(){try{await this.checkMilestone()}catch(e){ae(e,"apply-milestones",{engagementTrigger:this.engagementTrigger})}}async checkMilestone(){let e=!1,r=await de.getCurrent().getNormalisedCart(),n=this.engagementTrigger.progressBarConfig,o,i=[],s=[],a=[],l,f,h=[...n.milestones];for(let E of h){if(E.rewardType!==nu.FREE_AUTO_GIFT)continue;if(E.isUIOnly&&!E.allowATC){b.verbose(`Skipping milestone ${E.label} as it is UI only and does not allow ATC`);continue}let y=E.items[0],C=E.reached,D=r.items.find(N=>(N.vID===y.vID||N.mID===y.mID)&&N.properties._letscooee_campaign===this.engagementTrigger.shortID);C&&(l=E,f=D),D&&i.push(D),!C&&D&&n.removeIneligibleItem?(b.verbose(`Removing free gift ${D.vID} from cart`),a.push(D)):C&&!D&&(b.verbose(`Adding free gift ${y.vID} to cart`),s.push(y))}n.restrictToLatestFreebie&&l&&(f?(i=i.filter(E=>E.vID!==f.vID),s=[]):s=[l.items[0]],a.push(...i)),a.length&&(await this.removeFreeGifts(a),e=!0),s.length&&(o=await this.ctaExecutor.addToCart(s,this.engagementTrigger),e=!0);let m=n.coupons;if(!m?.length){e&&Qe.get().refreshUI(o,!1);return}try{let E=m.map(D=>D.couponCode),y=de.getCurrent().discount_codes?.map(D=>D.code)??[];E.every(D=>y.some(N=>N===D))||(await Gr.applyWithStorefront(E),e=!0)}catch(E){ae(E,"cart-apply-discount",{extra:{coupons:m},engagementTrigger:this.engagementTrigger})}e&&Qe.get().refreshUI(o,!1)}async removeFreeGifts(e){await Promise.all(e.map(r=>this.ctaExecutor.updateLineItem(r,{quantity:0})))}};var Vs=class extends dt{constructor(e){super(e)}async update(e){await super.update(e),this.engagementTrigger.content.update(e.content),this.updateAngularWidget()}isAllOkToRender(){return!!this.engagementTrigger.content}startRendering(){if(this.updateAngularWidget()){this.addToRendered();return}this.createAngularWidget("cooee-savings-bar")}};var Nl=class extends vt{constructor(e){super(e)}isAllOkToRender(){return!!this.engagementTrigger.content?.videoConfig}startRendering(){if(this.widgetElement?.isConnected){this.addToRendered();return}let e,r=this.engagementTrigger.content.videoConfig;r.template==="FLOATING_POPUP"?e="cooee-video-popup":r.template==="STORY"?e="cooee-video-stories":e="cooee-video-playlist",this.createAngularWidget(e)}};var Pl=class extends vt{constructor(e){super(e)}isAllOkToRender(){return!0}startRendering(){if(this.widgetElement?.isConnected){this.addToRendered();return}this.createAngularWidget("cooee-sticky-atc")}};var Ll=class extends vt{constructor(e){super(e)}isAllOkToRender(){return!0}startRendering(){let e=this.getParentElement(`inner-letscooee-${this.engagementTrigger.shortID}`);this.rootContainer.appendChild(e),document.addEventListener("letscooee:inbound:cta:add-bundle",this.inboundCTAListener.bind(this),!1)}async inboundCTAListener(e){let r=this.engagementTrigger,n=`Engagement(id: ${r.engagementID}, shortID: ${r.shortID})`,o=e.detail;if(!tr.hasKeys(o)){b.error(`No detail received for ${n}`);return}b.log("Detail received for BYOB",o);let i=o.campaignID??o.campaignId??o.campaign_id;if(i!==r.shortID&&i!==r.engagementID){b.warn(`Current ${n} is not BYOB. Received: ${i}`);return}let s=o.items;if(!s?.length)return;let a=s.map(l=>new Ot({mID:l.product_id,vID:l.variant_id,quantity:l.quantity||1}));await new dn(this.triggerContext).execute({embeddedItems:a,clickAction:{at:be.ADD_BUNDLE,applyDiscount:!0}})}};var im=!1,sm=!1,Ml=null,Bl=null,mv=!1;function dv(){mv||(mv=!0,xn(()=>{pv(document.body,{childList:!0,subtree:!0},500,fv).subscribe(()=>{vt.currentEngagements.forEach(t=>t.rerender()),dt.currentEngagements.forEach(t=>t.rerender())})}))}function am(t){if(dv(),im){b.verbose("Cart widget processing in progress, queuing latest triggers"),Ml=t;return}im=!0;try{mT(t)}finally{if(im=!1,Ml){let e=Ml;Ml=null,b.verbose("Processing queued cart triggers"),am(e)}}}function cm(t){if(dv(),sm){b.verbose("Page widget processing in progress, queuing latest triggers"),Bl=t;return}sm=!0;try{dT(t)}finally{if(sm=!1,Bl){let e=Bl;Bl=null,b.verbose("Processing queued page triggers"),cm(e)}}}function mT(t){gv(dt.currentEngagements,t);for(let e of t){b.info(`${e} received as cart embed`);let r=hv(dt.currentEngagements,e);if(r&&!e.isSubscriptionUpsell()){r.updateAndReRender(e).catch(o=>{ae(o,"update-and-re-render",{engagementTrigger:e})});continue}b.verbose(`${e} is new`);let n;if(e.isProgressBar())n=new Ol(e);else if(e.isSubscriptionUpsell()){Dl.renderCartUpsell(e);continue}else e.isSavingsBar()?n=new Vs(e):n=new dt(e);dt.currentEngagements.add(n),n.renderSilently()}}function dT(t){gv(vt.currentEngagements,t);for(let e of t){b.info(`${e} received as page embed`);let r=hv(vt.currentEngagements,e);if(r){r.updateAndReRender(e).catch(o=>{ae(o,"update-and-re-render",{engagementTrigger:e})});continue}b.verbose(`${e} is new`);let n;e.isShoppableVideo()?n=new Nl(e):e.isBYOB()?n=new Ll(e):e.isStickyATC()?n=new Pl(e):e.isSavingsBar()?n=new Vs(e):n=new vt(e),vt.currentEngagements.add(n),n.renderSilently()}}function hv(t,e){for(let r of t)if(r.matches(e))return r}function gv(t,e){let r=new Set(e.map(n=>n.shortID));for(let n of t)r.has(n.engagementTrigger.shortID)||n.destroy()}var vv=new Yt,yv=0;vv.pipe(Kt(50),Yp(t=>Gp(Promise.all([hT().catch(e=>{ae(e,"load-page-widgets",{extra:{firstLoad:t}})}),gT().catch(e=>{ae(e,"load-cart-widgets",{extra:{firstLoad:t}})})])))).subscribe();function Ti(t=!1){xr(pr).then(()=>{vv.next(t)})}function _v(){dt.currentEngagements.forEach(t=>t.rerender())}async function uv(t){let e=await mn();return Object.assign(t,e),Xt("/v1/engagement/get-variant",t)}async function hT(){yv++,yv===1?b.info("Fetch page widgets (after \u23F0",To()+" of SDK load)"):b.info("Fetch page widgets");let t=await mn(),e=_({},t);Xt("/v1/engagement/page-widgets",e).then(r=>{b.info(`Page widgets loaded in \u23F0 ${Xr(r.timeTakenMs)}`);let n=r.data.widgets.map(o=>new St(o));cm(n)}).catch(r=>{b.error("Error sending widget getter",r)})}async function gT(){b.info("Fetch cart widgets");let t=await mn(),e=_({},t);Xt("/v1/engagement/cart-widgets",e).then(r=>{b.info(`Cart widgets loaded in \u23F0 ${Xr(r.timeTakenMs)}`);let n=r.data.widgets.map(o=>new St(o));am(n)}).catch(r=>{b.error("Error sending widget getter",r)})}var Ul=class{static processConfiguration(){let e=Ye.get();!e.gaMeasurementID||!e.gaEnabled||this.sendClientID()}static async sendClientID(){let e=await this.getClientID();e&&kl({gaClientID:e})}static async getClientID(){let e=await ze.get("gacid"),r=await this.getClientIDViaGTag();if(e!==r)return await ze.set("gacid",r),r}static async getClientIDViaGTag(){let r=Ye.get().gaMeasurementID;if(!(!r||!window.gtag))return new Promise(n=>{window.gtag("get",r,"client_id",o=>{n(o)})})}};var Fl=class t{static INSTANCE;constructor(){this.init()}static getInstance(){return this.INSTANCE||(this.INSTANCE=new t),this.INSTANCE}init(){As.get("conf",{}).then(e=>this.updateGlobalConfig(e)),window.CooeeSDK.cartChange$.subscribe(()=>{Ti()})}async processAppConfigurations(e){b.verbose("Received app configuration",e),e.currencyCount=e.currencies?.length;let r=this.updateGlobalConfig(e);As.set("conf",r).catch(n=>b.error(n)),Ul.processConfiguration(),r.website&&(Xg(r.website.commonJS),yp(r.website.commonCSS)),window.CooeeSDK.cartDrawerToggle$.pipe(Kt(10)).subscribe(async({open:n})=>{b.info("Cart drawer is now",n?"open":"closed"),n&&(_v(),await this.trackViewCartEvent())})}updateGlobalConfig(e){let r=Ce.globalRef.config.update(e);return Qe.forceUpdate(),b.verbose("App configurations",r),r}async trackViewCartEvent(){let e=await de.getCurrent().getNormalisedCart(),r={value:e.amount,currency:e.currency},n={items:e.items,amount:r,drawer:!0};It(new xe("View Cart",n))}};var pr=new ws(1),Ev="App ID or Shopify shop is not set",lm,qr=class t{coreService=Fl.getInstance();userID="";deviceID="";appID="";shopifyShop="";constructor(){}static getInstance(){return lm||(lm=new t),lm}async populateAuthDataFromStorage(){await this.getOrSetDeviceIDSafe(),this.userID=await ze.get("id"),this.updateAPIClient()}async isAuthenticated(){return!this.deviceID||await this.isNewSessionRequired()?!1:!await this.notSynced()}authenticate(e){if(b.verbose("Initialising SDK",e),jy(navigator.userAgent)){b.info("This seems to be a bot. Disabling SDK");return}this.appID=e.appID,this.shopifyShop=e.shopifyShop,this.checkForNewSessionOnPageLoad().then(async()=>{pr.next(!0),pr.complete()}).catch(r=>{r?.message?.includes(Ev)&&ae(r,"initiate-session",{extra:e}),b.error("Unable to initiate session",r)})}async storeAndPopulateAuthData(e){e&&(e.userID&&(this.userID=e.userID,await ze.set("id",e.userID)),e.deviceID&&(this.deviceID=e.deviceID,await ze.set("did",e.deviceID)),this.updateAPIClient())}async checkSessionAndGetContext(){return await this.checkForNewSessionUnsafe(!1),this.getContext()}async checkForNewSessionOnPageLoad(){await this.checkForNewSessionSafe(!0)}async getOrSetDeviceIDSafe(){await ml.request("gen_did",async()=>{let e=await ze.get("did");e||(e=new yt().toHexString(),await ze.set("did",e)),this.deviceID=e,b.info("Device ID:",this.deviceID)})}async getContext(){xt.set("lastUsedTime",new Date().getTime());let[e,r,n]=await Promise.all([xt.get("id",""),ze.get("sessionNumber",1),xt.get("landing",{})]);return Bo({"cooee_session.number":r}),$a("Visitor Session",{id:e,number:r,landing_page:n}),{sessionID:e,sessionNumber:r,landingPage:n}}async checkForNewSessionSafe(e){await this.checkForNewSessionUnsafe(e)}async checkForNewSessionUnsafe(e){let r=!1;if(await this.isNewSessionRequired()?(b.info("New session to be started"),await this.startNewSession(),e=!0,r=!0):await this.notSynced()&&(r=!0),e){let n=await this.getContext();b.info(`Session ID: ${n.sessionID} & number: ${n.sessionNumber}`),await this.validateSessionFromServer(Z(_({},n),{newSession:r})),await xt.set("synced",!0)}}async startNewSession(){b.verbose("Starting new session"),await xt.clear(),b.verbose("Cleared SessionStorage before starting new session");let e=new Date,r=new yt().toHexString();b.verbose("New session ID to be used",r);let n=await ze.get("sessionNumber",0)+1;await Promise.all([ze.set("sessionNumber",n),xt.set("id",r),xt.set("lastUsedTime",e.getTime()),xt.set("landing",Ys())])}async isNewSessionRequired(){if(!await xt.get("id"))return!0;let e=await xt.get("lastUsedTime",0);return e?(new Date().getTime()-e)/1e3>1800:!0}async notSynced(){return!await xt.get("synced",!1)}async getSessionValidateData(e){if(!this.appID&&!this.shopifyShop)throw new Error(Ev);let r=await qy(),n=Wc();return Z(_(_({deviceID:this.deviceID,deviceProps:r,appID:this.appID,shopifyShop:this.shopifyShop},e),n),{sdk:js,ad:fl.getAdParams(),occurred:yT(fe().jsLoadTime),properties:{}})}async validateSessionFromServer(e){b.verbose("Validating session with server"),await this.populateFirstSeen();let r=await this.getSessionValidateData(e);try{let n=await Xt("/v1/event/validate-session",r),o=n.data;b.info(`Auth finished in \u23F0 ${Xr(n.timeTakenMs)}`),b.verbose("Validate session Response",o),await this.coreService.processAppConfigurations(o.appSettings),await this.storeAndPopulateAuthData(o)}catch(n){throw b.error(n),n}}async populateFirstSeen(){let e=await ze.get("firstSeen"),r=e?new Date(e):new Date;e||await ze.set("firstSeen",r.toISOString()),wv(r),$a("Visitor Info",{first_seen:r.toISOString()})}updateAPIClient(){this.userID&&b.info("User ID:",this.userID),bi.trackDeviceID(this.deviceID),bv(this.deviceID),$a("Visitor Info",{device_id:this.deviceID,user_id:this.userID}),Ah({id:this.deviceID})}};function yT(t){return(new Date().getTime()-t.getTime())/1e3>1800?new Date:t}var vT="keepalive"in new Request(""),Yr=new Headers;wT();async function mn(){let[t]=await Promise.all([qr.getInstance().checkSessionAndGetContext()]);return _(_({},Wc()),t)}function wi(t){xr(pr).then(()=>_T(t??{}))}function _T(t){Sv("/v1/user/update",t).then(async e=>{b.verbose("Updated user profile"),await qr.getInstance().storeAndPopulateAuthData(e.data)}).catch(e=>{b.error("Error saving user profile",e)})}function cv(t){return Xt("/v1/event/generate-discount",t)}function kl(t){xr(pr).then(()=>ET({props:t}))}function ET(t){Sv("/v1/device/update",t).then(()=>{b.verbose("Updated device properties")}).catch(async e=>{b.error("Error saving device property",e)})}function bv(t){t&&Yr.set("cooee-device-id",t)}function wv(t){t&&Yr.set("cooee-first-seen",t.toUTCString())}function Xt(t,e){return Tv("POST",t,e)}function Sv(t,e){return Tv("PUT",t,e)}function Tv(t,e,r){if(!ns()&&!fe().flags?.allowEvents)return b.log(`Rejecting ${t} ${e} as this is not e-commerce app`),Promise.reject();if(e.startsWith("http")||(e=gr.apiURL+e),r&&!vT&&e.includes(rm))try{return bT(e,Yr,r)}catch(o){throw ae(o,"http-request",{extra:{body:JSON.stringify(r)}}),o}let n={method:t,headers:Yr,keepalive:!1};return r&&(n.body=JSON.stringify(r)),en(e,n)}function bT(t,e,r){return new Promise((n,o)=>{let i=new XMLHttpRequest;i.open("POST",t,!0),e.forEach((s,a)=>{i.setRequestHeader(a,s)}),i.onreadystatechange=()=>{if(i.readyState===XMLHttpRequest.DONE)if(i.status>=200&&i.status<300)try{if(i.getResponseHeader("Content-Type")?.includes("application/json")){let a=JSON.parse(i.responseText);n({data:a,headers:e,request:i,status:i.status,statusText:i.statusText})}else o(new Error("Content-Type of response header is not json"))}catch(s){o(s)}else o(new Error(`Received status - ${i.status}(${i.statusText})`))},i.onerror=()=>{o(new Error("Network error occurred during the request."))},i.send(JSON.stringify(r))})}function wT(){Yr.set("Content-Type","application/json; charset=utf-8"),Yr.set("cooee-sdk",js),Yr.set("cooee-sdk-code",wm.toString()),Yr.set("cooee-sdk-version",Gs),Yr.set("cooee-shop-name",oc()??""),gr.debug&&Yr.set("cooee-sdk-debug",String(1))}var Hl=class{modifications=[];constructor(){}execute(e){for(let r of e){if(!r.experimentConfig)continue;this.executeExperiment(r)&&this.trackExperimentRan(r)}if(document.querySelector("#lc-hide-body")?.remove(),!document.body){wa("No body element found","error");return}this.setupMutationObserver()}executeExperiment(e){let r=e.experimentConfig?.modifications;return r?.length?r.some(n=>{if(!n.cssSelector)return b.verbose("No CSS Selector available",e?.toString()),!1;this.modifications.push(n);let o=Array.from(document.querySelectorAll(n.cssSelector));return o?.length?(this.executeSingleModification(n,o),!0):!1}):(b.log("Nothing to experiment",e.toString()),!0)}executeSingleModification(e,r){if(r?.length)for(let n of r)Object.assign(n.style,e.style),e.type==="TEXT"&&e.text?n.innerHTML=e.text:e.type==="IMAGE"&&this.updateImage(e,n),e.moveTo?.selector&&this.changePlacement(e,n).catch(console.error)}async changePlacement(e,r){let n=await Cn(e.moveTo.selector);if(n)switch(e.moveTo.position){case Dt.BEFORE1:{r.nextElementSibling!==n&&n.parentElement?.insertBefore(r,n);break}case Dt.INSIDE_FIRST1:{n.firstChild!==r&&n.insertBefore(r,n.firstChild);break}case Dt.INSIDE_LAST1:{n.lastChild!==r&&n.appendChild(r);break}case Dt.AFTER1:default:r.previousElementSibling!==n&&n.parentElement?.insertBefore(r,n.nextSibling)}}trackExperimentRan(e){if(e.id==="preview"){b.warn("Skipping experiment attribution as its preview",e.toString());return}Iv({name:"CE Experiment Start",experiment:new Ln(e)}).catch(r=>{b.error("Fail to track experiment",r)})}setupMutationObserver(){new MutationObserver(r=>{r.forEach(n=>{n.addedNodes.forEach(o=>{o instanceof HTMLElement&&this.modifications.forEach(i=>{o.matches&&o.matches(i.cssSelector)?(b.verbose("Re-applying experiment",i.toString()),this.executeSingleModification(i,[o])):o.querySelectorAll&&(b.verbose("Re-applying experiment",i.toString()),this.executeSingleModification(i,Array.from(o.querySelectorAll(i.cssSelector))))})})})}).observe(document.body,{childList:!0,subtree:!0})}updateImage(e,r){let n=e.image?.lg?.src,o=e.image?.sm?.src;!n&&!o||(r instanceof HTMLPictureElement?this.updatePictureElement({desktop:n,mobile:o},r):this.updateImageElement({desktop:n,mobile:o},r))}updateImageElement(e,r){jr()&&e.mobile?(r.setAttribute("src",e.mobile),r.removeAttribute("srcset")):e.desktop&&(r.setAttribute("src",e.desktop),r.removeAttribute("srcset"))}updatePictureElement(e,r){if(r.innerHTML="",e.mobile){let o=document.createElement("source");o.srcset=e.mobile,o.media="(max-width: 767px)",r.append(o)}if(e.desktop){let o=document.createElement("source");o.srcset=e.desktop,o.media="(min-width: 768px)",r.append(o)}let n=document.createElement("img");n.src=e.desktop??e.mobile??"",r.append(n)}};async function Iv(t){let e=await mn(),r=_(_({},t),e);await Xt("/v1/event/experiment",r)}function $l(){ST().catch(t=>ae(t,"fetch-experiments"))}async function ST(){if(!fe().activeExperiments)return;await qr.getInstance().isAuthenticated()?await xv():(await xr(pr),await xv())}async function xv(){b.info("Fetch experiments after \u23F0",To()+" of SDK load");let t=await mn(),e=_({},t);Xt("/v1/engagement/experiments",e).then(async r=>{b.info(`Experiments fetched in \u23F0 ${Xr(r.timeTakenMs)}`);let n=r.data.experiments.map(o=>new St(o));new Hl().execute(n)}).catch(r=>{b.error("Error sending experiment getter",r)})}var Vl=class{runtimeData=fe();meddle(){let e=Ce.globalRef;e.account=e.account??[],e.profile=e.profile??[],e.events=e.events??[],e.page=e.page??[],this.meddlePage(),this.meddleAccount(),this.meddleEvents(),this.meddleProfile(),this.exposeMethods()}exposeMethods(){let e=Ce.globalRef;e.loadWidgets=e.loadCartWidgets=e.loadPageWidgets=()=>{Ti()},e.loadExperiments=()=>{$l()},e.testCartUpdate=this.testCartUpdate.bind(this),e.previewWidget=Ce.previewWidget.bind(Ce),e.previewPopup=Ce.previewPopup.bind(Ce),e.executeCTA=(r,n)=>{new dn(r).execute(n)},e.sendEvent=r=>{It(r)}}overwritePush(e,r){Lr(e,"push",r)}meddleAccount(){this.overwritePush(Ce.globalRef.account,(...e)=>{this.processAccount(e[0])}),Ce.globalRef.account.forEach(this.processAccount.bind(this))}meddleEvents(){this.overwritePush(Ce.globalRef.events,(...e)=>{this.processEvent(e[0])}),Ce.globalRef.events.forEach(this.processEvent.bind(this))}meddleProfile(){this.overwritePush(Ce.globalRef.profile,(...e)=>{this.processProfile(e[0])}),Ce.globalRef.profile.forEach(this.processProfile.bind(this))}processAccount(e){e&&(e.appID&&Ce.authenticate(e),e.flags&&(this.runtimeData.flags=e.flags))}processEvent(e){e&&(Im.includes(e[0])?Ce.sendEvent(e[0],e[1],_({occurred:this.runtimeData.jsLoadTime},e[2])):Ce.sendEvent(e[0],e[1],e[2]))}processProfile(e){e&&Ce.updateProfile(e)}processPageName(e){e&&Ce.setPageName(e)}meddlePage(){this.overwritePush(Ce.globalRef.page,(...e)=>{this.processPage(e[0])}),Ce.globalRef.page.forEach(this.processPage.bind(this))}processPage(e){e.currentItem&&TT(e.currentItem),e.currency&&(fe().currencyCode=e.currency),e.shopCurrency&&(this.runtimeData.shopCurrencyCode=e.shopCurrency),e.moneyFormat&&(this.runtimeData.moneyFormat=e.moneyFormat),e.jsLoad&&(this.runtimeData.jsLoadTime=e.jsLoad),e.locale&&(this.runtimeData.locale=e.locale),e.pageName&&Ce.setPageName(e.pageName),e.activeExperiment&&(this.runtimeData.activeExperiments=e.activeExperiment),e.cart&&de.getCurrent().update(e.cart),e.customContext&&(this.runtimeData.customContext=_(_({},this.runtimeData.customContext),e.customContext))}async testCartUpdate(){if(fe().pageName!=="product"){window.alert("This feature is only available on a product page");return}let e=lv();if(e||(e=fe().currentItem?.vID),!e){window.alert("Could not find a variant to test. Please try a different product page");return}let r=new St({id:"preview",shortID:"1",redirectBehaviour:er.CART_DRAWER});await new dn(new Cr(new Date,r)).execute({clickAction:{at:be.ADD_TO_CART},embeddedItem:new Ot({vID:e})})}};function TT(t){let e=fe();if(e.currentItem&&e.currentItem.vID!==t.vID){let r=new CustomEvent("letscooee:variant-change",{detail:{variantID:t.vID}});document.dispatchEvent(r)}e.currentItem=new Ot(t)}var Ii=class{static SESSION_STORAGE=window.sessionStorage;static SESSION_STORAGE_KEY_PREFIX="cooee".concat("-");static getString(e,r){return this.getItem(e)||r}static setString(e,r){this.setItem(e,r)}static remove(e){this.removeItem(e)}static getItem(e){return this.SESSION_STORAGE.getItem(this.SESSION_STORAGE_KEY_PREFIX.concat(e))}static setItem(e,r){this.SESSION_STORAGE.setItem(this.SESSION_STORAGE_KEY_PREFIX.concat(e),r)}static removeItem(e){this.SESSION_STORAGE.removeItem(this.SESSION_STORAGE_KEY_PREFIX.concat(e))}};var IT=1e3,xT=10,um=0,fm=new Date;function pm(t){Ii.remove("sleid"),fm=t??new Date}function Cv(){if(window.scrollY){let t=Dv();Rv(t)&&Av(t)}xn(()=>{CT()})}function CT(){ho(window,"scroll").pipe(Kt(IT),pn(()=>{let t=Dv();if(t>100){b.warn("Received scroll percent is more than 100",t);return}if(Rv(t))return t})).subscribe(t=>{Av(t)})}function Rv(t){return Math.abs(um-t)>=xT||um!==t&&t===100}function Av(t){if(t==null)return;let e={percent:t,timeMS:new Date().getTime()-fm.getTime()};um=t;let r=Ii.getString("sleid",""),n=new xe("CE Scroll",e,null,r);It(n),Ii.setString("sleid",n.id.toHexString()),fm=new Date(n.occurred)}function Dv(){let t=window.document.body.scrollHeight,e=window.innerHeight;return Math.ceil((window.scrollY+e)/t*100)}function Ov(){RT()}function RT(){let t=window.fetch;window.fetch=async function(e,r){try{await AT(e,r)}catch(n){ae(n,"modify-graphql-request",{extra:{body:JSON.stringify(r?.body)}})}return t(e,r)},b.verbose("Securely overwritten window.fetch method for graphql query")}async function AT(t,e){let r=typeof t=="string"?t:t instanceof Request?t.url:"";if(!(r.includes("graphql.json")&&e?.method==="POST")||!e.body)return;let n;if(typeof e.body=="string")try{n=JSON.parse(e.body)}catch{return}else n=e.body;n?.variables?.input&&(b.verbose("Intercepted fetch request of:",r),n?.query.includes("cartCreate")&&(e.body=await DT(n),OT()))}async function DT(t){let e=t.variables.input.attributes??[],r=await ja("Buy Now");return t.variables.input.attributes=[...e,...r],JSON.stringify(t)}function OT(){let t=fe().currentItem;if(!t)return;let e=new xe("Buy Now Clicked",{items:[t]});It(e)}var xi=class{constructor(e,r){this.selectors=e;this.eventName=r;this.selectorString=e.join(",")}static INSTANCE;elements;selectorString;clickListenerCallback=e=>{let r=e.currentTarget,n=new xe(this.eventName,{class:r.className||void 0,tagName:r.tagName||void 0,id:r.id||void 0});It(n),this.removeClickListener(this.clickListenerCallback)};listenSilently(){this.listen().catch(e=>b.error(e))}async listen(){this.elements=await Rf(this.selectorString),this.elements.forEach(e=>{e.addEventListener("click",this.clickListenerCallback)})}removeClickListener(e){this.elements?.forEach(r=>{r.removeEventListener("click",e)})}};var Wl=class t extends xi{static selectors=[".product__thumbnail-list-inner > button","product-gallery-navigation > button",".product-media--thumb-container",".product-images-inner > img",".m-product-media",".swiper-button-control",".media__thumb",".slick-arrow",".productView-img-container.product-single__media",".product-gallery__thumbnail_item_inner"];constructor(){super(t.selectors,"Item Thumbnail Clicked")}static getInstance(){return this.INSTANCE||(this.INSTANCE=new t),this.INSTANCE}};var jl=class t extends xi{static selectors=[".jdgm-widget.jdgm-preview-badge.jdgm-preview-badge--with-link.jdgm--done-setup","reviewsio-product-ratings",".ruk_rating_snippet.tracked:not(.hidden)","a > .loox-rating",".yotpo-reviews-star-ratings-widget",".yotpo.lp-hero__reviews",".pr-rating > a",".rivyoReviewWidget"];constructor(){super(t.selectors,"Review Clicked")}static getInstance(){return this.INSTANCE||(this.INSTANCE=new t),this.INSTANCE}};var NT=[".gokwik-checkout button","button.cart__checkout-button","button.cart__checkout","button#checkout","button#checkout2",'button[id*="checkout" i]','button[name*="checkout" i]','button[class*="checkout" i]'].join(",");function Nv(){xn(()=>{b.verbose("Execution order:","document ready"),PT()})}function PT(){let t=window.location.hash?.substring(1);if(t)if(t.includes("initiate-checkout")){document.dispatchEvent(new Event("letscooee:outbound:third-party-initiate-checkout"));let e=document.querySelector(NT);if(!e){b.verbose("No clickable cart checkout button found");return}b.verbose("Clickable cart checkout button found",e),e.click()}else t.includes("open-cart-drawer")&&Qe.get().open()}function Lv(){window.addEventListener("kp-modal:opened",()=>{fe().isGoKwikPopupOpen=!0}),window.addEventListener("user-loggedin",t=>{let{token:e}=t.detail;e&&wi({goKwikToken:e})}),window.gokwikSdk?Pv():window.addEventListener("gokwikLoaded",Pv)}function Pv(){window.gokwikSdk&&window.gokwikSdk.on("checkout_initiated",async()=>{let t=await de.getCurrent().getNormalisedCart(),e={via:"GoKwik",items:t.items,cartToken:t.token,amount:{value:t.amount,currency:t.currency}},r=new xe("Checkout Started",e);It(r)})}var Gl=class{static watch(){let e=Am();(e==="1"||e==="on")&&kl({debugTill:this.getDebugMillis()}),e==="on"?sessionStorage.cooeeDebug="1":e==="off"&&sessionStorage.removeItem("cooeeDebug"),sessionStorage.cooeeDebug&&this.renderDebugBar()}static renderDebugBar(){let e=document.createElement("cooee-debugger");e.logs=this.logs,xn(()=>{document.body.appendChild(e)})}static getDebugMillis(){return new Date().getTime()+360*60*1e3}};var Ce=class{static globalRef;static authenticated;static async initForMerchantWebsiteOnly(e){window.cooeeSDKPreview||(this.initGlobalReference(e),await qr.getInstance().populateAuthDataFromStorage(),this.autoAuthenticate(),new Vl().meddle(),Mm(),Ti(!0),$l(),Xy(),nv(),Ov(),Nv(),Cv(),jl.getInstance().listenSilently(),Wl.getInstance().listenSilently(),Lv(),LT(),Gl.watch())}static async initForAll(){this.injectWidgetAssets()}static initGlobalReference(e){window.CooeeSDK||Lr(window,"CooeeSDK",{}),this.globalRef=window.CooeeSDK,Lr(this.globalRef,"config",new Ye),Lr(this.globalRef,"runtimeData",{sdkLoadTime:e,jsLoadTime:new Date,lastEnterActive:new Date}),Lr(this.globalRef,"uaParser",new Tr,!0),Lr(this.globalRef,"cart",de.getCurrent()),Lr(this.globalRef,"cartChange$",rv()),Lr(this.globalRef,"cartDrawerToggle$",Qe.cartDrawerToggle$.asObservable()),b.verbose("Global reference initialised"),new Nc(()=>{this.globalRef.uaParser=new Tr})}static injectWidgetAssets(){Yg(gr.widgetURL,"cooee-widget-sdk"),gp()}static autoAuthenticate(){let e=oc();e&&this.authenticate({shopifyShop:e})}static authenticate(e){if(this.authenticated)return;b.info("Begin auth after \u23F0",To(),"of SDK load");let r=e.appID?.trim(),n=e.shopifyShop;if((xf(r)||r.length!==24)&&xf(n)){b.warn("Cooee App ID or Shop name is not configured");return}this.authenticated=!0,qr.getInstance().authenticate(e)}static sendEvent(e,r,n){let o=new xe(e,r,n?.triggerData);n?.occurred&&(o.occurred=n.occurred),It(o)}static updateProfile(e){for(let r in e)if(r.toLowerCase().startsWith("ce "))throw new Error("User property name cannot start with 'CE '");wi(e)}static setPageName(e){if(!e)return;let r=fe(),n=r.pageName;if(e===n)return;if(r.pageName=e,Sm.some(s=>e.includes(s))){pm();return}let o={};n&&(o.ps=n);let i=new xe("CE Screen View",o);i.occurred=r.jsLoadTime,It(i),pm(i.occurred)}static previewPopup(e,r){new $n(r).render(e)}static previewWidget(e){new vt(new St(e)).renderSilently()}};function LT(){if(window.opener){try{window.opener.postMessage({action:"COOEE_READY_FOR_PREVIEW"},"*")}catch(t){b.error(t)}window.addEventListener("message",t=>{if(b.verbose("Received event",t),!t.origin.includes("letscooee.com")&&!t.origin.includes("localhost"))return;let e=t.data;typeof e=="object"&&(e.action==="POPUP_PREVIEW"?(Ce.previewPopup(e.engagementTrigger),t.source?.postMessage({action:"PREVIEW_SUCCESSFUL"},t.origin)):e.action==="WIDGET_PREVIEW"&&(Ce.previewWidget(e.engagementTrigger),t.source?.postMessage({action:"PREVIEW_SUCCESSFUL"},t.origin)))})}}var Mv=new Date;Cm();Dm();b.verbose("Execution order:","top");window.cooeeShopifyScriptLoaded||(window.cooeeShopifyScriptLoaded=!0,(async()=>(b.verbose("Execution order:","IIFE start"),await Ce.initForMerchantWebsiteOnly(Mv),await Ce.initForAll(),MT(),b.verbose("Execution order:","IIFE end")))());b.verbose("Execution order:","bottom");function MT(){Rm()&&import("./debug-logs-BDCQNC4J.js").then(({printAllDebugLogs:t})=>t(Mv))}
60
+ `},navigation:{nextEl:t.querySelector(".swiper-button-next"),prevEl:t.querySelector(".swiper-button-prev")},autoplay:e.autoplay?.enabled?{delay:e.autoplay?.delay,disableOnInteraction:!1,pauseOnMouseEnter:!1}:!1,autoHeight:!0};e.marquee&&r.autoplay&&typeof r.autoplay=="object"&&(r.speed=e.speed,r.autoplay.pauseOnMouseEnter=!0,t.style.setProperty("--swiper-wrapper-transition-timing-function","linear"));let n=new window.CooeeSDK.Swiper(t,r);return t.style.setProperty("--swiper-navigation-size",`${e.navigation.size}px`),n}function Al(t,e,r){let n={color:t.navigation.color?.rgba};return t.pagination.enabled&&(n.transform="translateY(-25%)"),Y("div",{class:"swiper-container",ref:e,style:"max-width: 100%",children:[Y("div",{class:"swiper-wrapper",children:r()}),t.navigation.enabled&&Y("div",{class:"swiper-button-next",style:n,children:Y("span",{})}),t.navigation.enabled&&Y("div",{class:"swiper-button-prev",style:n,children:Y("span",{})}),t.pagination.enabled&&Y("div",{className:"swiper-pagination",style:{bottom:0,top:"unset",position:"relative",color:t.pagination.color?.rgba}})]})}var Ls=class extends Ue{componentDidMount(){wt(()=>{this.setState(()=>({checked:this.props.item.selected.value}))})}render(){return Y("div",{style:this.getCompiledStyles(),className:"lc-checkbox",children:Y("input",{type:"checkbox",checked:this.state.checked,onChange:this.onChange.bind(this),style:{appearance:"auto"}})})}onChange(e){let{checked:r}=e.target;this.props.item.selected.value=r}getTypoStyles(){let e={},r=this.mediaStyle.typo??new at;return e.textAlign=r.alignment,e.justifyContent=r.alignment,e}getComponentStyles(){return Z(_({},this.getTypoStyles()),{display:"flex"})}};var hn=class extends Ue{constructor(e,r){super(e,r)}render(){let e=this.props.element[this.deviceTypeKey],r=e?.src||this.props.element.src||this.props.element.lg?.src;return Y("img",{onClick:this.customOnClick.bind(this),className:"lc-image",alt:e?.name||"Image",onMouseEnter:this.handleMouseEnter.bind(this),onMouseLeave:this.handleMouseLeave.bind(this),src:r,style:this.getCompiledStyles()})}customOnClick(e){this.props.element.clc?.at===be.ADD_TO_CART&&this.props.triggerContext.triggerData.items[0]&&this.onClick(e,{item:this.props.triggerContext.triggerData.items[0]}),this.props.onClick&&this.props.onClick("image")}getComponentStyles(){let e=this.mediaStyle.lout;if(!e||e.pos!=="absolute")return{};let r={zIndex:e.zIndex,cursor:this.props.element.clc?.at?"pointer":"auto"};return this.mediaStyle.size?.w&&(r.width=this.mediaStyle.size.w),this.mediaStyle.size?.h&&(r.height=this.mediaStyle.size.h),r}handleMouseEnter(e){let r=this.props.element[this.deviceTypeKey]?.secondarySrc;r&&(e.currentTarget.src=r)}handleMouseLeave(e){e.currentTarget.src=this.props.element[this.deviceTypeKey]?.src}};var gn=class extends Ue{render(){if(!(this.props.element.hide||!this.matchWhenCondition(this.props.element.when)))return Y("div",{style:this.getCompiledStyles(),class:"lc-flexbox",children:Y(Vn,{elements:this.props.elements,element:this.props.element,triggerContext:this.props.triggerContext})})}getComponentStyles(){let e=this.mediaStyle.flex??new Xo,r={display:"flex",gap:e.gap+"px",flexWrap:e.wrap,flexDirection:e.dir,justifyContent:e.jc,alignItems:e.ai};return e.wrap==="nowrap"&&e.scroll&&(e.dir==="column"?r["overflow-y"]="auto":r["overflow-x"]="auto"),r}};var Ms=class extends gn{render(){if(!(this.props.element.hide||!this.matchWhenCondition(this.props.element.when)))return Y("div",{style:this.getCompiledStyles(),class:"lc-flexbox",children:Y(Si,{elements:this.props.elements,element:this.props.element,triggerContext:this.props.triggerContext,item:this.props.item,noLinks:this.props.noLinks})})}};var Bs=class extends Ue{render(){return Y("select",{style:this.getCompiledStyles(),value:this.props.selectedVariant.selectedSellingPlan.value?.mID??"",onChange:this.onChange.bind(this),disabled:this.state.disabled,className:"lc-dropdown",children:this.createSelectItems()})}componentDidMount(){wt(()=>{this.setState(()=>({disabled:this.props.triggerContext.triggerData.isBundle()?!this.props.item.selected.value:!1}))})}getTypoStyles(){let e={},r=this.mediaStyle.typo??new at;return e.letterSpacing=r.letterSpacing,e.fontSize=r.fs+"px",e.lineHeight=r.lh,e.fontFamily="inherit",e.textAlign=r.alignment,e.fontWeight=r.fw,this.stylesConverter.getColourStyles(r.tc,"color",e),e.boxShadow="none",e}getComponentStyles(){let e={};return this.props.selectedVariant.sellingPlans?.length||(e.visibility="hidden"),_(_({},e),this.getTypoStyles())}createSelectItems(){let e=[],r=this.props.selectedVariant;if(!r.sellingPlans?.length)return[];this.props.triggerContext.triggerData.skipSubscribedItems?r.selectedSellingPlan.value||(r.sellingPlans[0].isSelected=!0,r.changeSellingPlan(r.sellingPlans[0])):e.push(Y("option",{value:"",selected:!r.selectedSellingPlan,children:"One time purchase"}));for(let n of r.sellingPlans??[])e.push(Y("option",{value:n.mID,selected:n.isSelected,children:n.name}));return e}onChange(e){let r=e.target.value;r?this.props.selectedVariant.selectedSellingPlan.value=this.props.selectedVariant.sellingPlans.find(n=>n.mID===r):this.props.selectedVariant.selectedSellingPlan.value=void 0}};var fT=new RegExp('fill="#[a-zA-Z0-9]+"'),Us=class extends Ue{constructor(){super()}render(){let e=this.getCompiledStyles(),r=this.getRating();return r||(e.display="none",r=""),Y("div",{style:e,className:"lc-star-rating",dangerouslySetInnerHTML:{__html:r}})}getRating(){let e={size:this.props.element.iconSize,color:this.props.element.c.hex},r=Vo(this.props.element.fullStar,{svg:e},this.props.triggerContext),n=Vo(this.props.element.halfStart,{svg:e},this.props.triggerContext),o=this.props.review;if(!o?.rating)return"";let i="";if(this.props.element.showSingleStar)i=r;else{let s=5,a=`${o.rating}`.split(".");for(let l=0;l<+a[0];l++)i+=r,s--;a[1]&&(i+=n,s--);for(let l=0;l<s;l++)i+=r.replace(fT,'fill="#f1f1f1"')}return i}getComponentStyles(){return{display:"flex",alignItems:"center"}}};var ks=class extends Ue{render(){return Y("select",{style:this.getCompiledStyles(),value:this.props.item.selectedOrFirstVariant.value.mID,onChange:this.onChange.bind(this),disabled:this.state.disabled,className:"lc-dropdown",children:this.createSelectItems()})}componentDidMount(){wt(()=>{this.setState(()=>({disabled:this.props.triggerContext.triggerData.isBundle()?!this.props.item.selected.value:!1}))})}getTypoStyles(){let e={},r=this.mediaStyle.typo??new at;return e.letterSpacing=r.letterSpacing,e.fontSize=r.fs+"px",e.lineHeight=r.lh,e.fontFamily="inherit",e.textAlign=r.alignment,e.fontWeight=r.fw,this.stylesConverter.getColourStyles(r.tc,"color",e),e.boxShadow="none",e}getComponentStyles(){let e={};return this.props.item.vars?.length===1&&this.props.item.vars[0].name==="Default Title"&&(e.visibility="hidden"),_(_({},e),this.getTypoStyles())}createSelectItems(){let e=[];for(let r of this.props.item.vars)e.push(Y("option",{value:r.mID,disabled:!r.isAvailable,children:r.name}));return e}onChange(e){let r=e.target.value,n=this.props.item.vars.find(o=>o.mID===r);this.props.item.setSelectedVariant(n)}};var lv=()=>{let t=window.ShopifyAnalytics?.meta??{},e=t.selectedVariantId;if(e)return e;if(t.product?.variants?.length>0)return t.product.variants[0].id},om=t=>{if(!t)return;let e;try{e=new URL(t)}catch{return}if(e.hostname!=="cdn.shopify.com")return t;let r=e.pathname.split(".");return r.length!==2?t:(e.pathname=r[0]+"_large."+r[1],e.toString())};var Si=class extends Ue{constructor(e,r){super(e,r),this.setState(()=>({decoration:"unset"}))}renderElement(e){if(!(e.hide||!this.matchWhenCondition(e.when))){if(e.t===4){let r=e;return r.l==="Star Rating"&&!this.props.item.reviews?.rating?void 0:Y(Ms,{element:r,triggerContext:this.props.triggerContext,elements:r.elems,item:this.props.item,noLinks:this.props.noLinks})}if(e.t===6)return this.props.triggerContext.triggerData.isBundle()?Y(Ls,{element:e,item:this.props.item,triggerContext:this.props.triggerContext}):void 0;if(e.t===13){let r=e,n=this.props.item,o=om(n.variantImage??n.firstImageURL),i=om(n.variantSecondaryImage??n.secondaryImageURL);r.lg=r.sm={src:o,name:n.name,secondarySrc:i};let s=Y(hn,{element:r,onClick:this.customOnClick.bind(this),triggerContext:this.props.triggerContext});return this.props.noLinks?s:Y("a",{href:this.props.item.selectedOrFirstVariant.value.link,style:{display:"block"},children:s})}if(e.t===14)return this.renderProductTitle(e);if(e.t===15){let r=e;return this.props.triggerContext.triggerData.isCartEmbed()&&this.props.item.vars?.length===1&&this.props.item.vars[0].name==="Default Title"?void 0:r.showChips?Y("cooee-product-options-picker",{item:this.props.item}):Y(ks,{element:r,item:this.props.item,triggerContext:this.props.triggerContext})}return e.t===16?Y(Bs,{element:e,selectedVariant:this.props.item.selectedOrFirstVariant.value,item:this.props.item,triggerContext:this.props.triggerContext}):e.t===19?Y(Us,{element:e,triggerContext:this.props.triggerContext,review:this.props.item.reviews}):e.t===18||e.t===3?Y(_o,{element:e,item:this.props.item,triggerContext:this.props.triggerContext}):Y(Vn,{elements:[e],element:this.props.element,triggerContext:this.props.triggerContext})}}render(){return this.props.elements.map(e=>this.renderElement(e))}getComponentStyles(){return{}}renderProductTitle(e){let r=Y(Jt,{element:e,onClick:this.customOnClick.bind(this),triggerContext:this.props.triggerContext});return this.props.noLinks?r:Y("a",{href:this.props.item.selectedOrFirstVariant.value.link,style:{display:"block",textDecoration:this.state.decoration},onMouseEnter:this.onMouseEnter.bind(this),onMouseLeave:this.onMouseLeave.bind(this),children:r})}customOnClick(e){this.sendTriggerClicked([this.props.item.toEmbed()],{from:e})}onMouseEnter(){this.setState(()=>({decoration:"underline"}))}onMouseLeave(){this.setState(()=>({decoration:"unset"}))}};var Eo=class extends Ue{productElement;constructor(e,r){super(e,r),this.setState(()=>({decoration:"unset"}))}render(){let e=eo(this.props.element,this.getProductData(),this.props.triggerContext);if(this.productElement=new Nn(e),!(this.productElement.hide||!this.matchWhenCondition(this.productElement.when)))return Y("div",{style:_({},this.getCompiledStyles()),class:"lc-single-product",children:Y(Si,{element:this.productElement,elements:this.productElement.elems,triggerContext:this.props.triggerContext,item:this.props.item,noLinks:this.productElement.noLinks})})}getComponentStyles(){return{flexShrink:0}}getProductData(){if(!this.props.item)return{};let e=this.props.item,r=e.selectedOrFirstVariant.value,n=e.getTemplateVariables();n.product.quantity=this.props.triggerContext.hasManipulatedProductQuantity()?this.props.triggerContext.getManipulatedQuantity(this.props.item.quantity):this.props.item.quantity;let o=this.props.triggerContext.triggerData.discount?.type===Zt.BXGY;return!r.hasEffectivePrice()&&o&&(n.product=Z(_(_({},n.product),Mt("effective_price",r.effectivePrice.value)),{price:""})),n.variant.quantity=this.props.triggerContext.hasManipulatedProductQuantity()?this.props.triggerContext.getManipulatedQuantity(r.quantity):r.quantity,{product:n.product,variant:n.variant,svg:{color:"{{ svg.color }}",size:"{{ svg.size }}"}}}};var Fs=class extends Ue{swiperRef=null;swiperInstance=null;configuration;gap;constructor(e,r){super(e,r),this.configuration=jr()?this.props.element.conf.sm:this.props.element.conf.lg,this.gap=(this.configuration.gap??15)+"px"}componentDidMount(){this.props.element.conf[this.deviceTypeKey].disp===2&&Oc().then(()=>{this.swiperInstance=Rl(this.swiperRef,this.props.element.conf[this.deviceTypeKey])})}componentWillUnmount(){this.swiperInstance&&this.swiperInstance.destroy()}render(){let e=this.props.triggerContext.triggerData.items;e.splice(this.configuration.maxItems??10);let r;if(this.configuration.disp===2){let n=i=>{this.swiperRef=i},o=()=>e?.map(i=>Y("div",{class:"swiper-slide",children:this.getProductFragment(i)}));r=Y("div",{style:Z(_({},this.getCompiledStyles()),{display:"block"}),class:"lc-product-swiper-list",children:Al(this.configuration,n,o)})}else r=Y("div",{style:this.getCompiledStyles(),class:"lc-product-list",children:e?.map((n,o)=>this.getProductFragment(n,o!==e.length-1))});return r}getComponentStyles(){let e=[0,2].includes(this.configuration.disp),r={display:e?"flex":"grid",justifyContent:"safe "+(this.mediaStyle.flex?.jc??"center"),gap:this.gap,flexDirection:this.mediaStyle.flex?.dir??"row"};if(r.flexDirection==="row"){if(e)r.maxWidth="100%",r.overflowY="auto";else if(this.configuration.disp===1){let n=this.props.triggerContext.triggerData,o=n.items.length,i;n.isBundle()?i=this.props.element.prod.symbol?.hide!==!0?o*2-1:o:i=this.props.element.conf[this.deviceTypeKey].maxInRow,r.gridTemplateColumns=`repeat(${i}, auto)`}}return r}getProductFragment(e,r=!1){return Y(Br,{children:[Y(Eo,{element:this.props.element.prod,item:e,triggerContext:this.props.triggerContext}),this.props.triggerContext.triggerData.isBundle()&&r&&this.props.element.prod.symbol&&!this.props.element.prod.symbol.hide&&Y("div",{style:{display:"flex",alignItems:"center",justifyContent:"center"},children:Y(Jt,{element:this.props.element.prod.symbol,triggerContext:this.props.triggerContext})})]},e.mID)}};var Hs=class extends Ue{swiperRef=null;swiperInstance=null;constructor(e,r){super(e,r)}componentDidMount(){Oc().then(()=>{this.swiperInstance=Rl(this.swiperRef,this.props.element.conf)})}componentWillUnmount(){this.swiperInstance&&this.swiperInstance.destroy()}render(){let e=this.props.element,r=o=>{this.swiperRef=o},n=()=>{let o=e.values?.map(a=>Y("div",{class:"swiper-slide",onClick:l=>this.onClick(l,{clickAction:this.getClickAction(a)}),children:this.renderElement(a)}));if(!o?.length)return[];let i=e.conf,s=o.length;if(i.marquee&&s<=Number(i.maxInRow)){let a=Number(i.maxInRow)-s+1;for(let l=0;l<a;l++)o.push(o[l%s])}return o};return Al(e.conf,r,n)}getComponentStyles(){return{}}renderElement(e){let r=this.valueAddedSlide(this.props.element.slide,e);switch(r?.t){case 1:return Y(hn,{element:r,triggerContext:this.props.triggerContext});case 4:return Y(gn,{elements:r.elems,element:r,triggerContext:this.props.triggerContext});default:b.warn("Unknown slide type for carousal")}}valueAddedSlide(e,r){let n=eo(e,{form:r},this.props.triggerContext);return qt.getParsedElement(n)}getClickAction(e){return eo(this.props.element.clc??{},{form:e},this.props.triggerContext)}};var Vn=class extends Ue{constructor(e,r){super(e,r),this.setState(()=>({decoration:"unset"})),wt(()=>{this.setState(()=>({showButton:!this.props.triggerContext.triggerData.isBundle()||!!this.props.triggerContext.selectedItems.length}))})}renderElement(e){if(!e.hide){if(e.t===4){let r=e;return Y(gn,{element:r,triggerContext:this.props.triggerContext,elements:r.elems})}if(e.t===61)return Y(Ps,{element:e,triggerContext:this.props.triggerContext});if(e.t===3)return this.state.showButton?Y(_o,{element:e,triggerContext:this.props.triggerContext}):void 0;if(e.t===2)return Y(Jt,{element:e,triggerContext:this.props.triggerContext});if(e.t===1)return Y(hn,{element:e,triggerContext:this.props.triggerContext});if(e.t===11)return Y(Fs,{element:e,triggerContext:this.props.triggerContext});if(e.t===12)return Y(Eo,{element:e,item:this.props.triggerContext.triggerData.items[0],triggerContext:this.props.triggerContext});if(e.t===62)return Y(Hs,{element:e,triggerContext:this.props.triggerContext})}}render(){return this.props.elements.map(e=>this.renderElement(e))}getComponentStyles(){return{}}};var $s=class extends Ue{clickAction;isClickable;constructor(e,r){super(e,r),this.clickAction=this.props.element.clc,this.isClickable=this.clickAction?.at===be.GO_TO_URL&&!!Uo(this.clickAction.gu?.u)||this.clickAction?.at===be.OPEN_CART||this.clickAction?.at===be.INITIATE_CHECKOUT}componentDidMount(){wt(()=>{let e=this.props.triggerContext.triggerData,r=this.props.triggerContext.selectedItems;e.calculateDiscountData(r,this.props.triggerContext.shouldGiveFBTDiscount)})}render(){return Y(Br,{children:[Y("div",{style:this.getCompiledStyles(),class:"lc-container",onClick:e=>{this.onClick(e,{clickAction:this.clickAction})},children:Y(Vn,{elements:this.props.elements,element:this.props.element,triggerContext:this.props.triggerContext})}),this.props.triggerContext.triggerData.id==="preview"&&Y("div",{class:"letscooee-preview-badge",children:["#",this.props.triggerContext.triggerData.shortID," preview"]})]})}getComponentStyles(){let e={position:"relative",overflow:"hidden",display:"block"};return this.isClickable&&(e.cursor="pointer"),e}};var vt=class t{constructor(e){this.engagementTrigger=e;this.triggerContext=new Cr(new Date,this.engagementTrigger)}static currentEngagements=new Set;static engagementIDsWithTrackedDisplay=new Set;static DEBOUNCE_TIME=1e3;rootContainer;widgetElement;widget;triggerContext;observers=[];renderedCount=0;scrollSubscription;variation;isExclusionWithBVariation;isRendering=!1;renderSilently(){this.render().catch(e=>{ae(e,"render-widget",{triggerContext:this.triggerContext})})}destroy(){b.verbose(`${this.engagementTrigger} will be destroyed`),this.preDestroy(),this.removeFromRendered(),this.rootContainer?.remove(),t.engagementIDsWithTrackedDisplay.delete(this.engagementTrigger.shortID),vp(this.engagementTrigger.content?.afterDeleteJS)}async render(){if(this.isRendering){b.verbose(`${this.engagementTrigger} rendering already in progress, skipping`);return}this.isRendering=!0;try{if(this.engagementTrigger.shouldGetVariationImmediately()){let e=await this.getVariation();this.handleVariationResponse(e)}if(this.rootContainer=await this.getWidgetContainer(!0),!this.rootContainer){b.warn(`${this.engagementTrigger} no section found to render the widget`);return}this.afterRootContainerCreated(),this.widget=this.engagementTrigger.widget,await this.getVariationIfRequired(),await this.runChoresBeforeRender(),this.attachScroll(),await this.checkAndSendEvent(),this.triggerContext.renderer=this,vp(this.engagementTrigger.content?.afterRenderJS)}finally{this.isRendering=!1}}matches(e){return this.engagementTrigger.shortID===e.shortID}async updateAndReRender(e){b.info(`${this.engagementTrigger} will be updated`),this.updateItems(e.items,this.engagementTrigger.items),await this.update(e),await this.render()}async update(e){}rerender(){this.rootContainer?.isConnected||(b.info(`${this.engagementTrigger} deleted. Will be re-rendered`),this.preDestroy(),this.renderSilently())}updateAngularWidget(){return this.widgetElement?.isConnected?(this.widgetElement.update(),!0):!1}preDestroy(){this.scrollSubscription?.unsubscribe(),this.observers.forEach(e=>{e?.disconnect&&e.disconnect()})}afterRootContainerCreated(){}isAllOkToRender(){return!!this.widget}async getVariationIfRequired(){if(this.engagementTrigger.shouldSkipVariation()){b.verbose(`${this.engagementTrigger} already has necessary data to render`);return}let e=await this.observeWidgetContainerInViewport();this.handleVariationResponse(e)}handleVariationResponse(e){e&&(b.log(`${this.engagementTrigger} visitor has been assigned to variation ${e.variation}`),e.items?.length&&(this.engagementTrigger.items=e.items.map(r=>new Ct(r)),this.engagementTrigger.nonMutableItems=e.items.map(r=>new Ct(r))),e.bundleFrom&&(this.engagementTrigger.bundleFrom=new Ct(e.bundleFrom)),e.discount&&(this.engagementTrigger.discount=e.discount),e.placement&&(this.triggerContext.triggerData.placement=e.placement),e.props&&tr.hasKeys(e.props)&&(this.engagementTrigger.props=_(_({},this.engagementTrigger.props),e.props)),e.content&&(this.triggerContext.triggerData.content=new is(e.content)),this.triggerContext.triggerData.widget=this.widget=new ei(e.widget),this.triggerContext.triggerData.contentID=e.contentID,this.triggerContext.triggerData.variation=this.variation=e.variation,this.triggerContext.triggerData.placement=e.placement,this.triggerContext.triggerData.manipulation=e.manipulation,this.triggerContext.triggerData.entryAnimation=e.entryAnimation??"NONE",this.isExclusionWithBVariation=this.engagementTrigger.isExclusionTesting()&&this.variation==="b",this.isExclusionWithBVariation&&(this.rootContainer.style.height="0.5px"))}addToRendered(){this.renderedCount++,b.info(`${this.engagementTrigger} rendered \u2705 ${Mh(this.renderedCount)} time`)}removeFromRendered(){this instanceof dt?dt.currentEngagements.delete(this):t.currentEngagements.delete(this)}async getVariation(){b.log(`${this.engagementTrigger} get variation`);let e={engagementID:this.engagementTrigger.engagementID,isPreview:this.engagementTrigger.id==="preview"};try{return(await uv(e)).data}catch(r){if(r instanceof vr&&r.response?.status===400)return;ae(r,"get-variation",{engagementTrigger:this.engagementTrigger});return}}async observeWidgetContainerInViewport(){if(!this.rootContainer){b.warn(`${this.engagementTrigger} No root container found to watch for viewport`);return}let e=window.innerHeight*.3,r={root:null,rootMargin:`${e}px 0px ${e}px 0px`,threshold:0};return this.isInViewport()?this.getVariation():new Promise(n=>{let o=new IntersectionObserver((i,s)=>{i.forEach(async a=>{if(a.isIntersecting){b.log(`${this.engagementTrigger} root container is near the viewport. Fetching variation`);let l=await this.getVariation();n(l),s.unobserve(this.rootContainer)}})},r);o.observe(this.rootContainer),this.observers.push(o)})}attachScroll(){this.scrollSubscription=ho(window,"scroll").pipe(Kt(t.DEBOUNCE_TIME)).subscribe(()=>{this.checkAndSendEvent()})}checkAndSendEvent(){let e=this.engagementTrigger.shortID;if(t.engagementIDsWithTrackedDisplay.has(e)||!this.isInViewport())return;let n={};this.triggerContext.triggerData.items?.length&&(n.promotedMIDs=this.engagementTrigger.items?.map(s=>s.mID));let o=this.isExclusionWithBVariation?"CE Campaign Holdout":"CE Trigger Displayed",i=new xe(o,n,this.engagementTrigger);i.name==="CE Campaign Holdout"&&(i.trigger.holdout=!0),Ut(i),t.engagementIDsWithTrackedDisplay.add(e),this.scrollSubscription.unsubscribe()}generateParentElementID(){return`letscooee-${this.engagementTrigger.shortID}`}createAngularWidget(e){let r=this.widgetElement=document.createElement(e);return r.cart=de.getCurrent(),r.triggerContext=this.triggerContext,r.engagementTrigger=this.engagementTrigger,r.setAttribute("engagement",this.engagementTrigger.shortID),this.rootContainer.appendChild(r),this.addToRendered(),r}getParentElement(e,r=document){let n=r.getElementById(e);if(n)return n;let o=this.engagementTrigger.objective.toLowerCase().replaceAll("_","-"),i=this.engagementTrigger.shortID;return n=document.createElement("div"),n.id=e,n.className=`letscooee letscooee-engagement engagement-${i} lc-${o}`,n.dataset.engagementId=i,this.engagementTrigger.id==="preview"&&(n.className+=" letscooee-preview"),n.style.display="block",n.style.minHeight="0.5px",n.style.minWidth="0.5px",n}startRendering(){let e=this.rootContainer;this.triggerContext.triggerData.hasSwiperElement()&&(e=this.rootContainer?.shadowRoot||this.rootContainer?.attachShadow({mode:"open"}),_p(e)),Jh(Mf($s,{element:this.widget.cont,triggerContext:this.triggerContext,elements:this.widget.elems}),e),this.addToRendered()}isInViewport(){let e=this.rootContainer?.getBoundingClientRect();if(!e)return!1;let r=window.innerHeight||document.documentElement.clientHeight,o=(Math.min(e.bottom,r)-Math.max(e.top,0))*e.width,i=e.width*e.height,s=o/i*100;return this.engagementTrigger.isAnySplit()?s>0:s>=30}async getWidgetContainer(e){if(this.rootContainer?.isConnected)return this.rootContainer;let r=await this.createParentElementWithPlacement(e);if(r)return r;let n=`.letscooee[data-engagement-id="${this.triggerContext.triggerData.shortID}"]`;return document.querySelector(n)}async createParentElementWithPlacement(e){let r=this.engagementTrigger.placement;if(!r?.selector)return b.info(`\u26A0\uFE0F${this.engagementTrigger} does not have a selector`),null;let n=r.selector,o;if(n.includes(":shadow")){let l=n.split(":shadow");o=(await Cn(l[0].trim()))?.shadowRoot,n=l[1].trim(),o&&_p(o,!1)}b.verbose(`${this.engagementTrigger} attempt to render ${r.position} "${n}"`);let i=await Cn(n,10,o??document);if(!i)return b.warn(`${this.engagementTrigger} no placement found with ${n}`),null;let s=this.generateParentElementID(),a=this.getParentElement(s);if(!e)return a;switch(r.position){case Dt.BEFORE1:case Dt.BEFORE:{i.parentElement?.insertBefore(a,i);break}case Dt.INSIDE_FIRST1:case Dt.INSIDE_FIRST:{i.insertBefore(a,i.firstChild);break}case Dt.INSIDE_LAST1:case Dt.INSIDE_LAST:{i.appendChild(a);break}case Dt.AFTER1:case Dt.AFTER:default:i.parentElement?.insertBefore(a,i.nextSibling)}return a}async runChoresBeforeRender(){if(this.isExclusionWithBVariation)return;if(!this.isAllOkToRender()){b.info(`\u26A0\uFE0F ${this.engagementTrigger} could not be rendered`);return}b.verbose(`${this.engagementTrigger} will be rendered`);let e;try{e=await Cl(this.engagementTrigger)}catch(r){b.info(`\u203C\uFE0F${this.engagementTrigger} could not render as items failed to refresh`,r);return}if(!this.engagementTrigger.isCollectionPromoted()&&!e?.length&&this.engagementTrigger.isProductPromoted()){b.info(`\u203C\uFE0F${this.engagementTrigger} could not render as no products promoted`);return}this.engagementTrigger.items=e,this.startRendering()}updateItems(e,r){let n=this.getItemDiff(e,r),o=this.getItemDiff(r,e);r.push(...n);for(let i of o)Jr.remove(r,i)}getItemDiff(e,r){return e.filter(n=>!r.some(o=>o.selectedOrFirstVariant.value.mID===n.selectedOrFirstVariant.value.mID))}};var dt=class extends vt{static currentEngagements=new Set;constructor(e){super(e)}rerender(){super.rerender(),this.checkAndSendEvent()}observeWidgetContainerInViewport(){return this.getVariation()}generateParentElementID(){let e=super.generateParentElementID();return this.engagementTrigger.isSubscriptionUpsell()&&(e+=`-${this.engagementTrigger.items[0].selectedOrFirstVariant.value.mID}`),e}checkAndSendEvent(){if(!Qe.get().isOpen()&&fe().pageName!=="cart"){b.log("Do not send display event as neither the cart drawer nor the cart page is open.");return}return super.checkAndSendEvent()}};var pT=t=>t,fv=t=>t.filter(e=>e.removedNodes&&e.removedNodes.length>0);function pv(t,e={childList:!0,subtree:!0},r=500,n=pT){return ul(o=>{let i=new MutationObserver(s=>o(s));return i.observe(t,e),i},(o,i)=>i.disconnect()).pipe(pn(o=>n(o)),qp(o=>o.length>0),Kt(r))}var Dl=class t{constructor(e,r){this.engagementTrigger=e;this.element=r;this.cartItems=de.getCurrent().items}cartItems;static renderCartUpsell(e){let r=e.placement;if(!r?.selector){b.warn(`No placement available for ${e.objective}`,e.shortID);return}let n=Array.from(document.querySelectorAll(r.selector));if(!n?.length){b.warn(`No placement found for ${e.objective}`,e.shortID);return}for(let o of n)new t(e,o).render()}render(){let e=this.findCartItemFromHTMLElement();if(!e||this.engagementTrigger.skipSubscribedItems&&e.selling_plan_allocation)return;let r=this.engagementTrigger.items.find(h=>h.mID===e.product_id.toString());if(!r)return;let n=r.vars.find(h=>h.mID===e.id.toString());if(!n)return;let o=new Ur(n),i=e.selling_plan_allocation?.selling_plan;if(i)for(let h of o.sellingPlans??[])h.mID===i.id.toString()&&(h.isSelected=!0,o.changeSellingPlan(h));let s=new Ct(r);s.vars=[o],s.selectedOrFirstVariant.value=o;let a=`lc-cart-item-${this.engagementTrigger.shortID}-${r.mID}`;this.element.classList.add(a);let l=new St(this.engagementTrigger);l.placement.selector=`.${a}`,l.items=[s];let f=new dt(l);f.renderSilently(),this.watchForCartItemDeletion(f,a)}watchForCartItemDeletion(e,r){let n=new MutationObserver(o=>{o.forEach(i=>{i.removedNodes.forEach(s=>{s===this.element&&(b.verbose(`${r} has been removed`),e.destroy(),n.disconnect())})})});n.observe(this.element.parentElement,{childList:!0,subtree:!0})}findCartItemFromHTMLElement(){let e=this.element.innerHTML;return this.cartItems.find(r=>{if(!(e.includes(r.url)||e.includes(r.variant_id))&&(!e.includes(r.product_title)||r.variant_title&&!e.includes(r.variant_title)))return!1;let n=r.selling_plan_allocation?.selling_plan?.name;return!(n&&!e.includes(n))})}};var Ol=class extends dt{ctaExecutor=new Hn;constructor(e){super(e)}async update(e){await super.update(e),this.engagementTrigger.progressBarConfig.update(e.progressBarConfig),await this.checkMilestoneTryCatch(),this.updateAngularWidget()}isAllOkToRender(){return!!this.engagementTrigger.progressBarConfig}startRendering(){if(this.updateAngularWidget()){this.addToRendered();return}this.createAngularWidget("cooee-progressbar"),this.checkMilestoneTryCatch()}async checkMilestoneTryCatch(){try{await this.checkMilestone()}catch(e){ae(e,"apply-milestones",{engagementTrigger:this.engagementTrigger})}}async checkMilestone(){let e=!1,r=await de.getCurrent().getNormalisedCart(),n=this.engagementTrigger.progressBarConfig,o,i=[],s=[],a=[],l,f,h=[...n.milestones];for(let E of h){if(E.rewardType!==nu.FREE_AUTO_GIFT)continue;if(E.isUIOnly&&!E.allowATC){b.verbose(`Skipping milestone ${E.label} as it is UI only and does not allow ATC`);continue}let y=E.items[0],C=E.reached,D=r.items.find(N=>(N.vID===y.vID||N.mID===y.mID)&&N.properties._letscooee_campaign===this.engagementTrigger.shortID);C&&(l=E,f=D),D&&i.push(D),!C&&D&&n.removeIneligibleItem?(b.verbose(`Removing free gift ${D.vID} from cart`),a.push(D)):C&&!D&&(b.verbose(`Adding free gift ${y.vID} to cart`),s.push(y))}n.restrictToLatestFreebie&&l&&(f?(i=i.filter(E=>E.vID!==f.vID),s=[]):s=[l.items[0]],a.push(...i)),a.length&&(await this.removeFreeGifts(a),e=!0),s.length&&(o=await this.ctaExecutor.addToCart(s,this.engagementTrigger),e=!0);let m=n.coupons;if(!m?.length){e&&Qe.get().refreshUI(o,!1);return}try{let E=m.map(D=>D.couponCode),y=de.getCurrent().discount_codes?.map(D=>D.code)??[];E.every(D=>y.some(N=>N===D))||(await Gr.applyWithStorefront(E),e=!0)}catch(E){ae(E,"cart-apply-discount",{extra:{coupons:m},engagementTrigger:this.engagementTrigger})}e&&Qe.get().refreshUI(o,!1)}async removeFreeGifts(e){await Promise.all(e.map(r=>this.ctaExecutor.updateLineItem(r,{quantity:0})))}};var Vs=class extends dt{constructor(e){super(e)}async update(e){await super.update(e),this.engagementTrigger.content.update(e.content),this.updateAngularWidget()}isAllOkToRender(){return!!this.engagementTrigger.content}startRendering(){if(this.updateAngularWidget()){this.addToRendered();return}this.createAngularWidget("cooee-savings-bar")}};var Nl=class extends vt{constructor(e){super(e)}isAllOkToRender(){return!!this.engagementTrigger.content?.videoConfig}startRendering(){if(this.widgetElement?.isConnected){this.addToRendered();return}let e,r=this.engagementTrigger.content.videoConfig;r.template==="FLOATING_POPUP"?e="cooee-video-popup":r.template==="STORY"?e="cooee-video-stories":e="cooee-video-playlist",this.createAngularWidget(e)}};var Pl=class extends vt{constructor(e){super(e)}isAllOkToRender(){return!0}startRendering(){if(this.widgetElement?.isConnected){this.addToRendered();return}this.createAngularWidget("cooee-sticky-atc")}};var Ll=class extends vt{constructor(e){super(e)}isAllOkToRender(){return!0}startRendering(){let e=this.getParentElement(`inner-letscooee-${this.engagementTrigger.shortID}`);this.rootContainer.appendChild(e),document.addEventListener("letscooee:inbound:cta:add-bundle",this.inboundCTAListener.bind(this),!1)}async inboundCTAListener(e){let r=this.engagementTrigger,n=`Engagement(id: ${r.engagementID}, shortID: ${r.shortID})`,o=e.detail;if(!tr.hasKeys(o)){b.error(`No detail received for ${n}`);return}b.log("Detail received for BYOB",o);let i=o.campaignID??o.campaignId??o.campaign_id;if(i!==r.shortID&&i!==r.engagementID){b.warn(`Current ${n} is not BYOB. Received: ${i}`);return}let s=o.items;if(!s?.length)return;let a=s.map(l=>new Ot({mID:l.product_id,vID:l.variant_id,quantity:l.quantity||1}));await new dn(this.triggerContext).execute({embeddedItems:a,clickAction:{at:be.ADD_BUNDLE,applyDiscount:!0}})}};var im=!1,sm=!1,Ml=null,Bl=null,mv=!1;function dv(){mv||(mv=!0,xn(()=>{pv(document.body,{childList:!0,subtree:!0},500,fv).subscribe(()=>{vt.currentEngagements.forEach(t=>t.rerender()),dt.currentEngagements.forEach(t=>t.rerender())})}))}function am(t){if(dv(),im){b.verbose("Cart widget processing in progress, queuing latest triggers"),Ml=t;return}im=!0;try{mT(t)}finally{if(im=!1,Ml){let e=Ml;Ml=null,b.verbose("Processing queued cart triggers"),am(e)}}}function cm(t){if(dv(),sm){b.verbose("Page widget processing in progress, queuing latest triggers"),Bl=t;return}sm=!0;try{dT(t)}finally{if(sm=!1,Bl){let e=Bl;Bl=null,b.verbose("Processing queued page triggers"),cm(e)}}}function mT(t){gv(dt.currentEngagements,t);for(let e of t){b.info(`${e} received as cart embed`);let r=hv(dt.currentEngagements,e);if(r&&!e.isSubscriptionUpsell()){r.updateAndReRender(e).catch(o=>{ae(o,"update-and-re-render",{engagementTrigger:e})});continue}b.verbose(`${e} is new`);let n;if(e.isProgressBar())n=new Ol(e);else if(e.isSubscriptionUpsell()){Dl.renderCartUpsell(e);continue}else e.isSavingsBar()?n=new Vs(e):n=new dt(e);dt.currentEngagements.add(n),n.renderSilently()}}function dT(t){gv(vt.currentEngagements,t);for(let e of t){b.info(`${e} received as page embed`);let r=hv(vt.currentEngagements,e);if(r){r.updateAndReRender(e).catch(o=>{ae(o,"update-and-re-render",{engagementTrigger:e})});continue}b.verbose(`${e} is new`);let n;e.isShoppableVideo()?n=new Nl(e):e.isBYOB()?n=new Ll(e):e.isStickyATC()?n=new Pl(e):e.isSavingsBar()?n=new Vs(e):n=new vt(e),vt.currentEngagements.add(n),n.renderSilently()}}function hv(t,e){for(let r of t)if(r.matches(e))return r}function gv(t,e){let r=new Set(e.map(n=>n.shortID));for(let n of t)r.has(n.engagementTrigger.shortID)||n.destroy()}var vv=new Yt,yv=0;vv.pipe(Kt(50),Yp(t=>Gp(Promise.all([hT().catch(e=>{ae(e,"load-page-widgets",{extra:{firstLoad:t}})}),gT().catch(e=>{ae(e,"load-cart-widgets",{extra:{firstLoad:t}})})])))).subscribe();function Ti(t=!1){xr(pr).then(()=>{vv.next(t)})}function _v(){dt.currentEngagements.forEach(t=>t.rerender())}async function uv(t){let e=await mn();return Object.assign(t,e),Xt("/v1/engagement/get-variant",t)}async function hT(){yv++,yv===1?b.info("Fetch page widgets (after \u23F0",To()+" of SDK load)"):b.info("Fetch page widgets");let t=await mn(),e=_({},t);Xt("/v1/engagement/page-widgets",e).then(r=>{b.info(`Page widgets loaded in \u23F0 ${Xr(r.timeTakenMs)}`);let n=r.data.widgets.map(o=>new St(o));cm(n)}).catch(r=>{b.error("Error sending widget getter",r)})}async function gT(){b.info("Fetch cart widgets");let t=await mn(),e=_({},t);Xt("/v1/engagement/cart-widgets",e).then(r=>{b.info(`Cart widgets loaded in \u23F0 ${Xr(r.timeTakenMs)}`);let n=r.data.widgets.map(o=>new St(o));am(n)}).catch(r=>{b.error("Error sending widget getter",r)})}var Ul=class{static processConfiguration(){let e=Ye.get();!e.gaMeasurementID||!e.gaEnabled||this.sendClientID()}static async sendClientID(){let e=await this.getClientID();e&&kl({gaClientID:e})}static async getClientID(){let e=await ze.get("gacid"),r=await this.getClientIDViaGTag();if(e!==r)return await ze.set("gacid",r),r}static async getClientIDViaGTag(){let r=Ye.get().gaMeasurementID;if(!(!r||!window.gtag))return new Promise(n=>{window.gtag("get",r,"client_id",o=>{n(o)})})}};var Fl=class t{static INSTANCE;constructor(){this.init()}static getInstance(){return this.INSTANCE||(this.INSTANCE=new t),this.INSTANCE}init(){As.get("conf",{}).then(e=>this.updateGlobalConfig(e)),window.CooeeSDK.cartChange$.subscribe(()=>{Ti()})}async processAppConfigurations(e){b.verbose("Received app configuration",e),e.currencyCount=e.currencies?.length;let r=this.updateGlobalConfig(e);As.set("conf",r).catch(n=>b.error(n)),Ul.processConfiguration(),r.website&&(Xg(r.website.commonJS),yp(r.website.commonCSS)),window.CooeeSDK.cartDrawerToggle$.pipe(Kt(10)).subscribe(async({open:n})=>{b.info("Cart drawer is now",n?"open":"closed"),n&&(_v(),await this.trackViewCartEvent())})}updateGlobalConfig(e){let r=Ce.globalRef.config.update(e);return Qe.forceUpdate(),b.verbose("App configurations",r),r}async trackViewCartEvent(){let e=await de.getCurrent().getNormalisedCart(),r={value:e.amount,currency:e.currency},n={items:e.items,amount:r,drawer:!0};It(new xe("View Cart",n))}};var pr=new ws(1),Ev="App ID or Shopify shop is not set",lm,qr=class t{coreService=Fl.getInstance();userID="";deviceID="";appID="";shopifyShop="";constructor(){}static getInstance(){return lm||(lm=new t),lm}async populateAuthDataFromStorage(){await this.getOrSetDeviceIDSafe(),this.userID=await ze.get("id"),this.updateAPIClient()}async isAuthenticated(){return!this.deviceID||await this.isNewSessionRequired()?!1:!await this.notSynced()}authenticate(e){if(b.verbose("Initialising SDK",e),jy(navigator.userAgent)){b.info("This seems to be a bot. Disabling SDK");return}this.appID=e.appID,this.shopifyShop=e.shopifyShop,this.checkForNewSessionOnPageLoad().then(async()=>{pr.next(!0),pr.complete()}).catch(r=>{r?.message?.includes(Ev)&&ae(r,"initiate-session",{extra:e}),b.error("Unable to initiate session",r)})}async storeAndPopulateAuthData(e){e&&(e.userID&&(this.userID=e.userID,await ze.set("id",e.userID)),e.deviceID&&(this.deviceID=e.deviceID,await ze.set("did",e.deviceID)),this.updateAPIClient())}async checkSessionAndGetContext(){return await this.checkForNewSessionUnsafe(!1),this.getContext()}async checkForNewSessionOnPageLoad(){await this.checkForNewSessionSafe(!0)}async getOrSetDeviceIDSafe(){await ml.request("gen_did",async()=>{let e=await ze.get("did");e||(e=new yt().toHexString(),await ze.set("did",e)),this.deviceID=e,b.info("Device ID:",this.deviceID)})}async getContext(){xt.set("lastUsedTime",new Date().getTime());let[e,r,n]=await Promise.all([xt.get("id",""),ze.get("sessionNumber",1),xt.get("landing",{})]);return Bo({"cooee_session.number":r}),$a("Visitor Session",{id:e,number:r,landing_page:n}),{sessionID:e,sessionNumber:r,landingPage:n}}async checkForNewSessionSafe(e){await this.checkForNewSessionUnsafe(e)}async checkForNewSessionUnsafe(e){let r=!1;if(await this.isNewSessionRequired()?(b.info("New session to be started"),await this.startNewSession(),e=!0,r=!0):await this.notSynced()&&(r=!0),e){let n=await this.getContext();b.info(`Session ID: ${n.sessionID} & number: ${n.sessionNumber}`),await this.validateSessionFromServer(Z(_({},n),{newSession:r})),await xt.set("synced",!0)}}async startNewSession(){b.verbose("Starting new session"),await xt.clear(),b.verbose("Cleared SessionStorage before starting new session");let e=new Date,r=new yt().toHexString();b.verbose("New session ID to be used",r);let n=await ze.get("sessionNumber",0)+1;await Promise.all([ze.set("sessionNumber",n),xt.set("id",r),xt.set("lastUsedTime",e.getTime()),xt.set("landing",Ys())])}async isNewSessionRequired(){if(!await xt.get("id"))return!0;let e=await xt.get("lastUsedTime",0);return e?(new Date().getTime()-e)/1e3>1800:!0}async notSynced(){return!await xt.get("synced",!1)}async getSessionValidateData(e){if(!this.appID&&!this.shopifyShop)throw new Error(Ev);let r=await qy(),n=Wc();return Z(_(_({deviceID:this.deviceID,deviceProps:r,appID:this.appID,shopifyShop:this.shopifyShop},e),n),{sdk:js,ad:fl.getAdParams(),occurred:yT(fe().jsLoadTime),properties:{}})}async validateSessionFromServer(e){b.verbose("Validating session with server"),await this.populateFirstSeen();let r=await this.getSessionValidateData(e);try{let n=await Xt("/v1/event/validate-session",r),o=n.data;b.info(`Auth finished in \u23F0 ${Xr(n.timeTakenMs)}`),b.verbose("Validate session Response",o),await this.coreService.processAppConfigurations(o.appSettings),await this.storeAndPopulateAuthData(o)}catch(n){throw b.error(n),n}}async populateFirstSeen(){let e=await ze.get("firstSeen"),r=e?new Date(e):new Date;e||await ze.set("firstSeen",r.toISOString()),wv(r),$a("Visitor Info",{first_seen:r.toISOString()})}updateAPIClient(){this.userID&&b.info("User ID:",this.userID),bi.trackDeviceID(this.deviceID),bv(this.deviceID),$a("Visitor Info",{device_id:this.deviceID,user_id:this.userID}),Ah({id:this.deviceID})}};function yT(t){return(new Date().getTime()-t.getTime())/1e3>1800?new Date:t}var vT="keepalive"in new Request(""),Yr=new Headers;wT();async function mn(){let[t]=await Promise.all([qr.getInstance().checkSessionAndGetContext()]);return _(_({},Wc()),t)}function wi(t){xr(pr).then(()=>_T(t??{}))}function _T(t){Sv("/v1/user/update",t).then(async e=>{b.verbose("Updated user profile"),await qr.getInstance().storeAndPopulateAuthData(e.data)}).catch(e=>{b.error("Error saving user profile",e)})}function cv(t){return Xt("/v1/event/generate-discount",t)}function kl(t){xr(pr).then(()=>ET({props:t}))}function ET(t){Sv("/v1/device/update",t).then(()=>{b.verbose("Updated device properties")}).catch(async e=>{b.error("Error saving device property",e)})}function bv(t){t&&Yr.set("cooee-device-id",t)}function wv(t){t&&Yr.set("cooee-first-seen",t.toUTCString())}function Xt(t,e){return Tv("POST",t,e)}function Sv(t,e){return Tv("PUT",t,e)}function Tv(t,e,r){if(!ns()&&!fe().flags?.allowEvents)return b.log(`Rejecting ${t} ${e} as this is not e-commerce app`),Promise.reject();if(e.startsWith("http")||(e=gr.apiURL+e),r&&!vT&&e.includes(rm))try{return bT(e,Yr,r)}catch(o){throw ae(o,"http-request",{extra:{body:JSON.stringify(r)}}),o}let n={method:t,headers:Yr,keepalive:!1};return r&&(n.body=JSON.stringify(r)),en(e,n)}function bT(t,e,r){return new Promise((n,o)=>{let i=new XMLHttpRequest;i.open("POST",t,!0),e.forEach((s,a)=>{i.setRequestHeader(a,s)}),i.onreadystatechange=()=>{if(i.readyState===XMLHttpRequest.DONE)if(i.status>=200&&i.status<300)try{if(i.getResponseHeader("Content-Type")?.includes("application/json")){let a=JSON.parse(i.responseText);n({data:a,headers:e,request:i,status:i.status,statusText:i.statusText})}else o(new Error("Content-Type of response header is not json"))}catch(s){o(s)}else o(new Error(`Received status - ${i.status}(${i.statusText})`))},i.onerror=()=>{o(new Error("Network error occurred during the request."))},i.send(JSON.stringify(r))})}function wT(){Yr.set("Content-Type","application/json; charset=utf-8"),Yr.set("cooee-sdk",js),Yr.set("cooee-sdk-code",wm.toString()),Yr.set("cooee-sdk-version",Gs),Yr.set("cooee-shop-name",oc()??""),gr.debug&&Yr.set("cooee-sdk-debug",String(1))}var Hl=class{modifications=[];constructor(){}execute(e){for(let r of e){if(!r.experimentConfig)continue;this.executeExperiment(r)&&this.trackExperimentRan(r)}if(document.querySelector("#lc-hide-body")?.remove(),!document.body){wa("No body element found","error");return}this.setupMutationObserver()}executeExperiment(e){let r=e.experimentConfig?.modifications;return r?.length?r.some(n=>{if(!n.cssSelector)return b.verbose("No CSS Selector available",e?.toString()),!1;this.modifications.push(n);let o=Array.from(document.querySelectorAll(n.cssSelector));return o?.length?(this.executeSingleModification(n,o),!0):!1}):(b.log("Nothing to experiment",e.toString()),!0)}executeSingleModification(e,r){if(r?.length)for(let n of r)Object.assign(n.style,e.style),e.type==="TEXT"&&e.text?n.innerHTML=e.text:e.type==="IMAGE"&&this.updateImage(e,n),e.moveTo?.selector&&this.changePlacement(e,n).catch(console.error)}async changePlacement(e,r){let n=await Cn(e.moveTo.selector);if(n)switch(e.moveTo.position){case Dt.BEFORE1:{r.nextElementSibling!==n&&n.parentElement?.insertBefore(r,n);break}case Dt.INSIDE_FIRST1:{n.firstChild!==r&&n.insertBefore(r,n.firstChild);break}case Dt.INSIDE_LAST1:{n.lastChild!==r&&n.appendChild(r);break}case Dt.AFTER1:default:r.previousElementSibling!==n&&n.parentElement?.insertBefore(r,n.nextSibling)}}trackExperimentRan(e){if(e.id==="preview"){b.warn("Skipping experiment attribution as its preview",e.toString());return}Iv({name:"CE Experiment Start",experiment:new Ln(e)}).catch(r=>{b.error("Fail to track experiment",r)})}setupMutationObserver(){new MutationObserver(r=>{r.forEach(n=>{n.addedNodes.forEach(o=>{o instanceof HTMLElement&&this.modifications.forEach(i=>{o.matches&&o.matches(i.cssSelector)?(b.verbose("Re-applying experiment",i.toString()),this.executeSingleModification(i,[o])):o.querySelectorAll&&(b.verbose("Re-applying experiment",i.toString()),this.executeSingleModification(i,Array.from(o.querySelectorAll(i.cssSelector))))})})})}).observe(document.body,{childList:!0,subtree:!0})}updateImage(e,r){let n=e.image?.lg?.src,o=e.image?.sm?.src;!n&&!o||(r instanceof HTMLPictureElement?this.updatePictureElement({desktop:n,mobile:o},r):this.updateImageElement({desktop:n,mobile:o},r))}updateImageElement(e,r){jr()&&e.mobile?(r.setAttribute("src",e.mobile),r.removeAttribute("srcset")):e.desktop&&(r.setAttribute("src",e.desktop),r.removeAttribute("srcset"))}updatePictureElement(e,r){if(r.innerHTML="",e.mobile){let o=document.createElement("source");o.srcset=e.mobile,o.media="(max-width: 767px)",r.append(o)}if(e.desktop){let o=document.createElement("source");o.srcset=e.desktop,o.media="(min-width: 768px)",r.append(o)}let n=document.createElement("img");n.src=e.desktop??e.mobile??"",r.append(n)}};async function Iv(t){let e=await mn(),r=_(_({},t),e);await Xt("/v1/event/experiment",r)}function $l(){ST().catch(t=>ae(t,"fetch-experiments"))}async function ST(){if(!fe().activeExperiments)return;await qr.getInstance().isAuthenticated()?await xv():(await xr(pr),await xv())}async function xv(){b.info("Fetch experiments after \u23F0",To()+" of SDK load");let t=await mn(),e=_({},t);Xt("/v1/engagement/experiments",e).then(async r=>{b.info(`Experiments fetched in \u23F0 ${Xr(r.timeTakenMs)}`);let n=r.data.experiments.map(o=>new St(o));new Hl().execute(n)}).catch(r=>{b.error("Error sending experiment getter",r)})}var Vl=class{runtimeData=fe();meddle(){let e=Ce.globalRef;e.account=e.account??[],e.profile=e.profile??[],e.events=e.events??[],e.page=e.page??[],this.meddlePage(),this.meddleAccount(),this.meddleEvents(),this.meddleProfile(),this.exposeMethods()}exposeMethods(){let e=Ce.globalRef;e.loadWidgets=e.loadCartWidgets=e.loadPageWidgets=()=>{Ti()},e.loadExperiments=()=>{$l()},e.testCartUpdate=this.testCartUpdate.bind(this),e.previewWidget=Ce.previewWidget.bind(Ce),e.previewPopup=Ce.previewPopup.bind(Ce),e.executeCTA=(r,n)=>{new dn(r).execute(n)},e.sendEvent=r=>{It(r)}}overwritePush(e,r){Lr(e,"push",r)}meddleAccount(){this.overwritePush(Ce.globalRef.account,(...e)=>{this.processAccount(e[0])}),Ce.globalRef.account.forEach(this.processAccount.bind(this))}meddleEvents(){this.overwritePush(Ce.globalRef.events,(...e)=>{this.processEvent(e[0])}),Ce.globalRef.events.forEach(this.processEvent.bind(this))}meddleProfile(){this.overwritePush(Ce.globalRef.profile,(...e)=>{this.processProfile(e[0])}),Ce.globalRef.profile.forEach(this.processProfile.bind(this))}processAccount(e){e&&(e.appID&&Ce.authenticate(e),e.flags&&(this.runtimeData.flags=e.flags))}processEvent(e){e&&(Im.includes(e[0])?Ce.sendEvent(e[0],e[1],_({occurred:this.runtimeData.jsLoadTime},e[2])):Ce.sendEvent(e[0],e[1],e[2]))}processProfile(e){e&&Ce.updateProfile(e)}processPageName(e){e&&Ce.setPageName(e)}meddlePage(){this.overwritePush(Ce.globalRef.page,(...e)=>{this.processPage(e[0])}),Ce.globalRef.page.forEach(this.processPage.bind(this))}processPage(e){e.currentItem&&TT(e.currentItem),e.currency&&(fe().currencyCode=e.currency),e.shopCurrency&&(this.runtimeData.shopCurrencyCode=e.shopCurrency),e.moneyFormat&&(this.runtimeData.moneyFormat=e.moneyFormat),e.jsLoad&&(this.runtimeData.jsLoadTime=e.jsLoad),e.locale&&(this.runtimeData.locale=e.locale),e.pageName&&Ce.setPageName(e.pageName),e.activeExperiment&&(this.runtimeData.activeExperiments=e.activeExperiment),e.cart&&de.getCurrent().update(e.cart),e.customContext&&(this.runtimeData.customContext=_(_({},this.runtimeData.customContext),e.customContext))}async testCartUpdate(){if(fe().pageName!=="product"){window.alert("This feature is only available on a product page");return}let e=lv();if(e||(e=fe().currentItem?.vID),!e){window.alert("Could not find a variant to test. Please try a different product page");return}let r=new St({id:"preview",shortID:"1",redirectBehaviour:er.CART_DRAWER});await new dn(new Cr(new Date,r)).execute({clickAction:{at:be.ADD_TO_CART},embeddedItem:new Ot({vID:e})})}};function TT(t){let e=fe();if(e.currentItem&&e.currentItem.vID!==t.vID){let r=new CustomEvent("letscooee:variant-change",{detail:{variantID:t.vID}});document.dispatchEvent(r)}e.currentItem=new Ot(t)}var Ii=class{static SESSION_STORAGE=window.sessionStorage;static SESSION_STORAGE_KEY_PREFIX="cooee".concat("-");static getString(e,r){return this.getItem(e)||r}static setString(e,r){this.setItem(e,r)}static remove(e){this.removeItem(e)}static getItem(e){return this.SESSION_STORAGE.getItem(this.SESSION_STORAGE_KEY_PREFIX.concat(e))}static setItem(e,r){this.SESSION_STORAGE.setItem(this.SESSION_STORAGE_KEY_PREFIX.concat(e),r)}static removeItem(e){this.SESSION_STORAGE.removeItem(this.SESSION_STORAGE_KEY_PREFIX.concat(e))}};var IT=1e3,xT=10,um=0,fm=new Date;function pm(t){Ii.remove("sleid"),fm=t??new Date}function Cv(){if(window.scrollY){let t=Dv();Rv(t)&&Av(t)}xn(()=>{CT()})}function CT(){ho(window,"scroll").pipe(Kt(IT),pn(()=>{let t=Dv();if(t>100){b.warn("Received scroll percent is more than 100",t);return}if(Rv(t))return t})).subscribe(t=>{Av(t)})}function Rv(t){return Math.abs(um-t)>=xT||um!==t&&t===100}function Av(t){if(t==null)return;let e={percent:t,timeMS:new Date().getTime()-fm.getTime()};um=t;let r=Ii.getString("sleid",""),n=new xe("CE Scroll",e,null,r);It(n),Ii.setString("sleid",n.id.toHexString()),fm=new Date(n.occurred)}function Dv(){let t=window.document.body.scrollHeight,e=window.innerHeight;return Math.ceil((window.scrollY+e)/t*100)}function Ov(){RT()}function RT(){let t=window.fetch;window.fetch=async function(e,r){try{await AT(e,r)}catch(n){ae(n,"modify-graphql-request",{extra:{body:JSON.stringify(r?.body)}})}return t(e,r)},b.verbose("Securely overwritten window.fetch method for graphql query")}async function AT(t,e){let r=typeof t=="string"?t:t instanceof Request?t.url:"";if(!(r.includes("graphql.json")&&e?.method==="POST")||!e.body)return;let n;if(typeof e.body=="string")try{n=JSON.parse(e.body)}catch{return}else n=e.body;n?.variables?.input&&(b.verbose("Intercepted fetch request of:",r),n?.query.includes("cartCreate")&&(e.body=await DT(n),OT()))}async function DT(t){let e=t.variables.input.attributes??[],r=await ja("Buy Now");return t.variables.input.attributes=[...e,...r],JSON.stringify(t)}function OT(){let t=fe().currentItem;if(!t)return;let e=new xe("Buy Now Clicked",{items:[t]});It(e)}var xi=class{constructor(e,r){this.selectors=e;this.eventName=r;this.selectorString=e.join(",")}static INSTANCE;elements;selectorString;clickListenerCallback=e=>{let r=e.currentTarget,n=new xe(this.eventName,{class:r.className||void 0,tagName:r.tagName||void 0,id:r.id||void 0});It(n),this.removeClickListener(this.clickListenerCallback)};listenSilently(){this.listen().catch(e=>b.error(e))}async listen(){this.elements=await Rf(this.selectorString),this.elements.forEach(e=>{e.addEventListener("click",this.clickListenerCallback)})}removeClickListener(e){this.elements?.forEach(r=>{r.removeEventListener("click",e)})}};var Wl=class t extends xi{static selectors=[".product__thumbnail-list-inner > button","product-gallery-navigation > button",".product-media--thumb-container",".product-images-inner > img",".m-product-media",".swiper-button-control",".media__thumb",".slick-arrow",".productView-img-container.product-single__media",".product-gallery__thumbnail_item_inner"];constructor(){super(t.selectors,"Item Thumbnail Clicked")}static getInstance(){return this.INSTANCE||(this.INSTANCE=new t),this.INSTANCE}};var jl=class t extends xi{static selectors=[".jdgm-widget.jdgm-preview-badge.jdgm-preview-badge--with-link.jdgm--done-setup","reviewsio-product-ratings",".ruk_rating_snippet.tracked:not(.hidden)","a > .loox-rating",".yotpo-reviews-star-ratings-widget",".yotpo.lp-hero__reviews",".pr-rating > a",".rivyoReviewWidget"];constructor(){super(t.selectors,"Review Clicked")}static getInstance(){return this.INSTANCE||(this.INSTANCE=new t),this.INSTANCE}};var NT=[".gokwik-checkout button","button.cart__checkout-button","button.cart__checkout","button#checkout","button#checkout2",'button[id*="checkout" i]','button[name*="checkout" i]','button[class*="checkout" i]'].join(",");function Nv(){xn(()=>{b.verbose("Execution order:","document ready"),PT()})}function PT(){let t=window.location.hash?.substring(1);if(t)if(t.includes("initiate-checkout")){document.dispatchEvent(new Event("letscooee:outbound:third-party-initiate-checkout"));let e=document.querySelector(NT);if(!e){b.verbose("No clickable cart checkout button found");return}b.verbose("Clickable cart checkout button found",e),e.click()}else t.includes("open-cart-drawer")&&Qe.get().open()}function Lv(){window.addEventListener("kp-modal:opened",()=>{fe().isGoKwikPopupOpen=!0}),window.addEventListener("user-loggedin",t=>{let{token:e}=t.detail;e&&wi({goKwikToken:e})}),window.gokwikSdk?Pv():window.addEventListener("gokwikLoaded",Pv)}function Pv(){window.gokwikSdk&&window.gokwikSdk.on("checkout_initiated",async()=>{let t=await de.getCurrent().getNormalisedCart(),e={via:"GoKwik",items:t.items,cartToken:t.token,amount:{value:t.amount,currency:t.currency}},r=new xe("Checkout Started",e);It(r)})}var Gl=class{static watch(){let e=Am();(e==="1"||e==="on")&&kl({debugTill:this.getDebugMillis()}),e==="on"?sessionStorage.cooeeDebug="1":e==="off"&&sessionStorage.removeItem("cooeeDebug"),sessionStorage.cooeeDebug&&this.renderDebugBar()}static renderDebugBar(){let e=document.createElement("cooee-debugger");e.logs=this.logs,xn(()=>{document.body.appendChild(e)})}static getDebugMillis(){return new Date().getTime()+360*60*1e3}};var Ce=class{static globalRef;static authenticated;static async initForMerchantWebsiteOnly(e){window.cooeeSDKPreview||(this.initGlobalReference(e),await qr.getInstance().populateAuthDataFromStorage(),this.autoAuthenticate(),new Vl().meddle(),Mm(),Ti(!0),$l(),Xy(),nv(),Ov(),Nv(),Cv(),jl.getInstance().listenSilently(),Wl.getInstance().listenSilently(),Lv(),LT(),Gl.watch())}static async initForAll(){this.injectWidgetAssets()}static initGlobalReference(e){window.CooeeSDK||Lr(window,"CooeeSDK",{}),this.globalRef=window.CooeeSDK,Lr(this.globalRef,"config",new Ye),Lr(this.globalRef,"runtimeData",{sdkLoadTime:e,jsLoadTime:new Date,lastEnterActive:new Date}),Lr(this.globalRef,"uaParser",new Tr,!0),Lr(this.globalRef,"cart",de.getCurrent()),Lr(this.globalRef,"cartChange$",rv()),Lr(this.globalRef,"cartDrawerToggle$",Qe.cartDrawerToggle$.asObservable()),b.verbose("Global reference initialised"),new Nc(()=>{this.globalRef.uaParser=new Tr})}static injectWidgetAssets(){Yg(gr.widgetURL,"cooee-widget-sdk"),gp()}static autoAuthenticate(){let e=oc();e&&this.authenticate({shopifyShop:e})}static authenticate(e){if(this.authenticated)return;b.info("Begin auth after \u23F0",To(),"of SDK load");let r=e.appID?.trim(),n=e.shopifyShop;if((xf(r)||r.length!==24)&&xf(n)){b.warn("Cooee App ID or Shop name is not configured");return}this.authenticated=!0,qr.getInstance().authenticate(e)}static sendEvent(e,r,n){let o=new xe(e,r,n?.triggerData);n?.occurred&&(o.occurred=n.occurred),It(o)}static updateProfile(e){for(let r in e)if(r.toLowerCase().startsWith("ce "))throw new Error("User property name cannot start with 'CE '");wi(e)}static setPageName(e){if(!e)return;let r=fe(),n=r.pageName;if(e===n)return;if(r.pageName=e,Sm.some(s=>e.includes(s))){pm();return}let o={};n&&(o.ps=n);let i=new xe("CE Screen View",o);i.occurred=r.jsLoadTime,It(i),pm(i.occurred)}static previewPopup(e,r){new $n(r).render(e)}static previewWidget(e){new vt(new St(e)).renderSilently()}};function LT(){if(window.opener){try{window.opener.postMessage({action:"COOEE_READY_FOR_PREVIEW"},"*")}catch(t){b.error(t)}window.addEventListener("message",t=>{if(b.verbose("Received event",t),!t.origin.includes("letscooee.com")&&!t.origin.includes("localhost"))return;let e=t.data;typeof e=="object"&&(e.action==="POPUP_PREVIEW"?(Ce.previewPopup(e.engagementTrigger),t.source?.postMessage({action:"PREVIEW_SUCCESSFUL"},t.origin)):e.action==="WIDGET_PREVIEW"&&(Ce.previewWidget(e.engagementTrigger),t.source?.postMessage({action:"PREVIEW_SUCCESSFUL"},t.origin)))})}}var Mv=new Date;Cm();Dm();b.verbose("Execution order:","top");window.cooeeShopifyScriptLoaded||(window.cooeeShopifyScriptLoaded=!0,(async()=>(b.verbose("Execution order:","IIFE start"),await Ce.initForMerchantWebsiteOnly(Mv),await Ce.initForAll(),MT(),b.verbose("Execution order:","IIFE end")))());b.verbose("Execution order:","bottom");function MT(){Rm()&&import("./debug-logs-A6SXUVVE.js").then(({printAllDebugLogs:t})=>t(Mv))}
@@ -1 +1 @@
1
- import{a as C,b}from"./chunk-UE2CYNQW.js";import{e as g,f as h,i as u,l as f}from"./chunk-SZBUQIOV.js";import{Ba as l,Qa as c,X as m,na as n,oa as i,pa as r,v as s}from"./chunk-I62LO6BZ.js";import"./chunk-V7UGKYBN.js";var _=class d{dialogRef=s(u);eventData=s(h);triggerData=s(g)().triggerData;onShareAndClose(p,o){p.stopPropagation();let{url:t,text:a}=b(this.triggerData,this.eventData.video,o!=="Clipboard");switch(o){case"Whatsapp":window.open(`https://wa.me/?text=${a}%20${t}`,"_blank","noopener,noreferrer");break;case"X(Twitter)":window.open(`https://x.com/intent/post?text=${a}&url=${t}`,"_blank","noopener,noreferrer");break;case"Clipboard":navigator.clipboard.writeText(t).catch(()=>{let e=document.createElement("textarea");e.value=t,document.body.appendChild(e),e.select(),document.execCommand("copy"),document.body.removeChild(e)});break;default:}o&&C(this.triggerData,this.eventData.video,this.eventData.index,o),this.dialogRef.close()}static \u0275fac=function(o){return new(o||d)};static \u0275cmp=m({type:d,selectors:[["cooee-share-dialog"]],decls:19,vars:0,consts:[[1,"share-dialog"],[1,"share-dialog-header"],["type","button","aria-label","Close",1,"close-button",3,"click"],["name","close","aria-hidden","true"],[1,"share-options"],["type","button","aria-label","Share on WhatsApp",1,"share-option",3,"click"],["name","whatsapp","aria-hidden","true"],["type","button","aria-label","Share on X",1,"share-option",3,"click"],["name","x-twitter","aria-hidden","true"],["type","button","aria-label","Copy link",1,"share-option",3,"click"],["name","copy","aria-hidden","true"]],template:function(o,t){o&1&&(n(0,"div",0)(1,"div",1)(2,"h3"),c(3,"Share"),i(),n(4,"button",2),l("click",function(e){return t.onShareAndClose(e)}),r(5,"cooee-icon",3),i()(),n(6,"div",4)(7,"button",5),l("click",function(e){return t.onShareAndClose(e,"Whatsapp")}),r(8,"cooee-icon",6),n(9,"span"),c(10,"Whatsapp"),i()(),n(11,"button",7),l("click",function(e){return t.onShareAndClose(e,"X(Twitter)")}),r(12,"cooee-icon",8),n(13,"span"),c(14,"X"),i()(),n(15,"button",9),l("click",function(e){return t.onShareAndClose(e,"Clipboard")}),r(16,"cooee-icon",10),n(17,"span"),c(18,"Copy link"),i()()()())},dependencies:[f],styles:["@keyframes _ngcontent-%COMP%_slideInScale{0%{opacity:0;transform:scale(.9) translateY(8px)}to{opacity:1;transform:scale(1) translateY(0)}}.share-dialog[_ngcontent-%COMP%]{background:#fff;border-radius:12px;padding:20px;min-width:280px;box-shadow:0 8px 32px #00000026;color:#333;animation:_ngcontent-%COMP%_slideInScale .25s ease-out}.share-dialog-header[_ngcontent-%COMP%]{display:flex;justify-content:space-between;align-items:center;margin-bottom:20px}.share-dialog-header[_ngcontent-%COMP%] h3[_ngcontent-%COMP%]{font-family:var(--lc-heading-family),serif;margin:0;font-size:18px;font-weight:600}.share-options[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:12px;font-family:var(--lc-text-family),serif}.share-option[_ngcontent-%COMP%]{display:flex;align-items:center;gap:12px;padding:12px 16px;background:#0002;border:1px solid #e9ecef;border-radius:8px;color:#333;font-size:16px;font-weight:500;cursor:pointer;transition:all .2s ease}.share-option[_ngcontent-%COMP%]:hover{background:#0004;border-color:#dee2e6;transform:translateY(-1px)}.share-option[_ngcontent-%COMP%]:active{transform:translateY(0)}.share-option[_ngcontent-%COMP%] cooee-icon[_ngcontent-%COMP%]{width:24px;height:24px}.share-option[_ngcontent-%COMP%] cooee-icon[name=whatsapp][_ngcontent-%COMP%]{color:#25d366}.share-option[_ngcontent-%COMP%] cooee-icon[name=x-twitter][_ngcontent-%COMP%], .share-option[_ngcontent-%COMP%] cooee-icon[name=copy][_ngcontent-%COMP%]{color:#000}.share-option[_ngcontent-%COMP%] span[_ngcontent-%COMP%]{flex:1;text-align:left}button.close-button[_ngcontent-%COMP%]{background-color:transparent;border:none}button.close-button[_ngcontent-%COMP%] cooee-icon[name=close][_ngcontent-%COMP%]{border-radius:100%;color:#000}"]})};export{_ as ShareDialogComponent};
1
+ import{a as C,b}from"./chunk-WQZKLQRJ.js";import{e as g,f as h,i as u,l as f}from"./chunk-4BDZZRZN.js";import{Ba as l,Qa as c,X as m,na as n,oa as i,pa as r,v as s}from"./chunk-I62LO6BZ.js";import"./chunk-V7UGKYBN.js";var _=class d{dialogRef=s(u);eventData=s(h);triggerData=s(g)().triggerData;onShareAndClose(p,o){p.stopPropagation();let{url:t,text:a}=b(this.triggerData,this.eventData.video,o!=="Clipboard");switch(o){case"Whatsapp":window.open(`https://wa.me/?text=${a}%20${t}`,"_blank","noopener,noreferrer");break;case"X(Twitter)":window.open(`https://x.com/intent/post?text=${a}&url=${t}`,"_blank","noopener,noreferrer");break;case"Clipboard":navigator.clipboard.writeText(t).catch(()=>{let e=document.createElement("textarea");e.value=t,document.body.appendChild(e),e.select(),document.execCommand("copy"),document.body.removeChild(e)});break;default:}o&&C(this.triggerData,this.eventData.video,this.eventData.index,o),this.dialogRef.close()}static \u0275fac=function(o){return new(o||d)};static \u0275cmp=m({type:d,selectors:[["cooee-share-dialog"]],decls:19,vars:0,consts:[[1,"share-dialog"],[1,"share-dialog-header"],["type","button","aria-label","Close",1,"close-button",3,"click"],["name","close","aria-hidden","true"],[1,"share-options"],["type","button","aria-label","Share on WhatsApp",1,"share-option",3,"click"],["name","whatsapp","aria-hidden","true"],["type","button","aria-label","Share on X",1,"share-option",3,"click"],["name","x-twitter","aria-hidden","true"],["type","button","aria-label","Copy link",1,"share-option",3,"click"],["name","copy","aria-hidden","true"]],template:function(o,t){o&1&&(n(0,"div",0)(1,"div",1)(2,"h3"),c(3,"Share"),i(),n(4,"button",2),l("click",function(e){return t.onShareAndClose(e)}),r(5,"cooee-icon",3),i()(),n(6,"div",4)(7,"button",5),l("click",function(e){return t.onShareAndClose(e,"Whatsapp")}),r(8,"cooee-icon",6),n(9,"span"),c(10,"Whatsapp"),i()(),n(11,"button",7),l("click",function(e){return t.onShareAndClose(e,"X(Twitter)")}),r(12,"cooee-icon",8),n(13,"span"),c(14,"X"),i()(),n(15,"button",9),l("click",function(e){return t.onShareAndClose(e,"Clipboard")}),r(16,"cooee-icon",10),n(17,"span"),c(18,"Copy link"),i()()()())},dependencies:[f],styles:["@keyframes _ngcontent-%COMP%_slideInScale{0%{opacity:0;transform:scale(.9) translateY(8px)}to{opacity:1;transform:scale(1) translateY(0)}}.share-dialog[_ngcontent-%COMP%]{background:#fff;border-radius:12px;padding:20px;min-width:280px;box-shadow:0 8px 32px #00000026;color:#333;animation:_ngcontent-%COMP%_slideInScale .25s ease-out}.share-dialog-header[_ngcontent-%COMP%]{display:flex;justify-content:space-between;align-items:center;margin-bottom:20px}.share-dialog-header[_ngcontent-%COMP%] h3[_ngcontent-%COMP%]{font-family:var(--lc-heading-family),serif;margin:0;font-size:18px;font-weight:600}.share-options[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:12px;font-family:var(--lc-text-family),serif}.share-option[_ngcontent-%COMP%]{display:flex;align-items:center;gap:12px;padding:12px 16px;background:#0002;border:1px solid #e9ecef;border-radius:8px;color:#333;font-size:16px;font-weight:500;cursor:pointer;transition:all .2s ease}.share-option[_ngcontent-%COMP%]:hover{background:#0004;border-color:#dee2e6;transform:translateY(-1px)}.share-option[_ngcontent-%COMP%]:active{transform:translateY(0)}.share-option[_ngcontent-%COMP%] cooee-icon[_ngcontent-%COMP%]{width:24px;height:24px}.share-option[_ngcontent-%COMP%] cooee-icon[name=whatsapp][_ngcontent-%COMP%]{color:#25d366}.share-option[_ngcontent-%COMP%] cooee-icon[name=x-twitter][_ngcontent-%COMP%], .share-option[_ngcontent-%COMP%] cooee-icon[name=copy][_ngcontent-%COMP%]{color:#000}.share-option[_ngcontent-%COMP%] span[_ngcontent-%COMP%]{flex:1;text-align:left}button.close-button[_ngcontent-%COMP%]{background-color:transparent;border:none}button.close-button[_ngcontent-%COMP%] cooee-icon[name=close][_ngcontent-%COMP%]{border-radius:100%;color:#000}"]})};export{_ as ShareDialogComponent};
@@ -1,3 +1,3 @@
1
- import{A as Pe,B as Me,C as Re,a as _e,c as O,d as Ce,f as U,k as Q,r as R,s as De,t as be,u as Te,v as Ie,w as Ee,y as Se,z as ke}from"./chunk-ZL5ODBJY.js";import{a as Oe,b as Ne}from"./chunk-UE2CYNQW.js";import{c as we,e as fe,f as N,g as H,i as xe,j as Ve,k as ye,l as F}from"./chunk-SZBUQIOV.js";import"./chunk-SBONG2TS.js";import{$a as me,Ba as g,D as Y,Da as a,E as f,Ga as $,Ha as j,I as T,Ia as W,Ja as ae,Ka as de,L as J,La as b,M as X,Ma as S,O as s,Ta as se,Ua as le,V as Z,Va as ce,X as w,Za as pe,ba as I,fb as ue,ga as E,ha as x,ia as V,ib as k,ja as ee,jb as P,ka as y,kb as M,la as D,lb as ge,ma as u,na as l,oa as d,pa as _,qa as te,ra as ie,sa as oe,sb as he,ta as ne,ua as re,ub as ve,v as m,va as B,x as c,y as p,za as v}from"./chunk-I62LO6BZ.js";import"./chunk-V7UGKYBN.js";var A=class n{dialogState=P();dialog=m(ye);triggerData=m(fe)().triggerData;eventData=m(N);containerRef=m(Z);async share(t){t.stopPropagation(),t.preventDefault(),R()&&De()?await this.shareNative():await this.shareWithDialog()}async shareNative(){let t=Ne(this.triggerData,this.eventData.video,!1);await navigator.share(t),Oe(this.triggerData,this.eventData.video,this.eventData.index,"Native")}async shareWithDialog(){let t=await import("./share-dialog.component-DV3HWEOU.js");this.dialogState.emit(!0),this.dialog.open(t.ShareDialogComponent,{viewContainerRef:this.containerRef}).closed.subscribe(()=>this.dialogState.emit(!1))}static \u0275fac=function(e){return new(e||n)};static \u0275cmp=w({type:n,selectors:[["cooee-share-button"]],outputs:{dialogState:"dialogState"},decls:2,vars:0,consts:[["type","button","aria-label","Share video",3,"click"],["name","share"]],template:function(e,i){e&1&&(l(0,"button",0),g("click",function(r){return i.share(r)}),_(1,"cooee-icon",1),d())},dependencies:[F],styles:["button[_ngcontent-%COMP%]{width:var(--lc-icon-button-size, 44px);height:var(--lc-icon-button-size, 44px);display:flex;justify-content:center;align-items:center;border:none;border-radius:100%;background:#00000080;background:color-mix(in oklab,#000 50%,transparent)}button[_ngcontent-%COMP%] cooee-icon[name=share][_ngcontent-%COMP%]{color:#fff}"]})};var z=class n{video=M.required();progress=f(0);constructor(){k(t=>{let e=this.video(),i=()=>{this.progress.set(e.currentTime/e.duration*100)};e.addEventListener("timeupdate",i),t(()=>{e.removeEventListener("timeupdate",i)})})}static \u0275fac=function(e){return new(e||n)};static \u0275cmp=w({type:n,selectors:[["cooee-video-progress-bar"]],inputs:{video:[1,"video"]},decls:3,vars:3,consts:[[1,"video-untracked-path"],["role","progressbar",1,"video-tracked-path"]],template:function(e,i){e&1&&(te(0,"div",0)(1,"div",1),oe(2,"div"),ie()()),e&2&&(s(),S("width",i.progress(),"%"),E("aria-valuenow",i.progress()))},styles:["[_nghost-%COMP%]{display:block;width:100%;position:absolute;z-index:10;top:4px;padding-inline:8px;box-sizing:border-box}.video-untracked-path[_ngcontent-%COMP%], .video-tracked-path[_ngcontent-%COMP%]{height:4px;border-radius:var(--lc-video-progress-bar-radius)}.video-untracked-path[_ngcontent-%COMP%]{background-color:rgba(var(--lc-video-progress-bar-bg-color));width:100%;margin-bottom:2px}.video-tracked-path[_ngcontent-%COMP%]{background-color:rgba(var(--lc-video-progress-bar-color));transition:width .5s ease-in-out}@media (prefers-reduced-motion: reduce){.video-tracked-path[_ngcontent-%COMP%]{transition:none}}"]})};var Ae=["swiperContainer"],ze=(n,t)=>t.id;function Le(n,t){if(n&1){let e=v();l(0,"div",3)(1,"cooee-item-card",4),g("buttonClick",function(o){c(e);let r=a();return p(r.onButtonClick(o))})("click",function(){let o=c(e).$implicit,r=a();return p(r.cardClick.emit(o))}),d()()}if(n&2){let e=t.$implicit;s(),u("item",e)}}var L=class n{items=M.required();cardClick=P();destroyRef=m(Y);elementRef=m(T);engagementService=m(U);swiperContainerRef=ge.required("swiperContainer");swiperInstance;constructor(){k(()=>{this.initSwiper()}),this.destroyRef.onDestroy(()=>{this.swiperInstance?.destroy()})}ngOnInit(){O(this.elementRef.nativeElement.shadowRoot)}onButtonClick(t){let e=_e.get().website?.canChangeVariantInCart;if(this.items()?.length>1||t.hasVariants()&&!e){this.cardClick.emit(t);return}this.engagementService.executeCTA(Ce.ADD_TO_CART,{item:t})}initSwiper(){this.swiperInstance=new window.CooeeSDK.Swiper(this.swiperContainerRef().nativeElement,{direction:"horizontal",effect:"slide",slidesPerView:1.2,nested:!0,centeredSlides:!0,spaceBetween:12,mousewheel:{enabled:!0,thresholdDelta:10,thresholdTime:200}})}static \u0275fac=function(e){return new(e||n)};static \u0275cmp=w({type:n,selectors:[["cooee-video-promoted-items"]],viewQuery:function(e,i){e&1&&ae(i.swiperContainerRef,Ae,5),e&2&&de()},hostAttrs:[1,"letscooee-widget"],inputs:{items:[1,"items"]},outputs:{cardClick:"cardClick"},features:[me([U])],decls:5,vars:0,consts:[["swiperContainer",""],[1,"swiper-container"],[1,"swiper-wrapper"],[1,"swiper-slide"],["tabindex","0",3,"buttonClick","click","item"]],template:function(e,i){e&1&&(l(0,"div",1,0)(2,"div",2),y(3,Le,2,1,"div",3,ze),d()()),e&2&&(s(3),D(i.items()))},dependencies:[Re],styles:[`:host{display:block;width:100%}cooee-item-card{-webkit-backdrop-filter:blur(2px);backdrop-filter:blur(2px);background-color:rgba(var(--lc-card-bg-color));cursor:pointer;border-radius:var(--lc-card-radius)}
1
+ import{A as Pe,B as Me,C as Re,a as _e,c as O,d as Ce,f as U,k as Q,r as R,s as De,t as be,u as Te,v as Ie,w as Ee,y as Se,z as ke}from"./chunk-NQB2VJ76.js";import{a as Oe,b as Ne}from"./chunk-WQZKLQRJ.js";import{c as we,e as fe,f as N,g as H,i as xe,j as Ve,k as ye,l as F}from"./chunk-4BDZZRZN.js";import"./chunk-SBONG2TS.js";import{$a as me,Ba as g,D as Y,Da as a,E as f,Ga as $,Ha as j,I as T,Ia as W,Ja as ae,Ka as de,L as J,La as b,M as X,Ma as S,O as s,Ta as se,Ua as le,V as Z,Va as ce,X as w,Za as pe,ba as I,fb as ue,ga as E,ha as x,ia as V,ib as k,ja as ee,jb as P,ka as y,kb as M,la as D,lb as ge,ma as u,na as l,oa as d,pa as _,qa as te,ra as ie,sa as oe,sb as he,ta as ne,ua as re,ub as ve,v as m,va as B,x as c,y as p,za as v}from"./chunk-I62LO6BZ.js";import"./chunk-V7UGKYBN.js";var A=class n{dialogState=P();dialog=m(ye);triggerData=m(fe)().triggerData;eventData=m(N);containerRef=m(Z);async share(t){t.stopPropagation(),t.preventDefault(),R()&&De()?await this.shareNative():await this.shareWithDialog()}async shareNative(){let t=Ne(this.triggerData,this.eventData.video,!1);await navigator.share(t),Oe(this.triggerData,this.eventData.video,this.eventData.index,"Native")}async shareWithDialog(){let t=await import("./share-dialog.component-XKR2YDPF.js");this.dialogState.emit(!0),this.dialog.open(t.ShareDialogComponent,{viewContainerRef:this.containerRef}).closed.subscribe(()=>this.dialogState.emit(!1))}static \u0275fac=function(e){return new(e||n)};static \u0275cmp=w({type:n,selectors:[["cooee-share-button"]],outputs:{dialogState:"dialogState"},decls:2,vars:0,consts:[["type","button","aria-label","Share video",3,"click"],["name","share"]],template:function(e,i){e&1&&(l(0,"button",0),g("click",function(r){return i.share(r)}),_(1,"cooee-icon",1),d())},dependencies:[F],styles:["button[_ngcontent-%COMP%]{width:var(--lc-icon-button-size, 44px);height:var(--lc-icon-button-size, 44px);display:flex;justify-content:center;align-items:center;border:none;border-radius:100%;background:#00000080;background:color-mix(in oklab,#000 50%,transparent)}button[_ngcontent-%COMP%] cooee-icon[name=share][_ngcontent-%COMP%]{color:#fff}"]})};var z=class n{video=M.required();progress=f(0);constructor(){k(t=>{let e=this.video(),i=()=>{this.progress.set(e.currentTime/e.duration*100)};e.addEventListener("timeupdate",i),t(()=>{e.removeEventListener("timeupdate",i)})})}static \u0275fac=function(e){return new(e||n)};static \u0275cmp=w({type:n,selectors:[["cooee-video-progress-bar"]],inputs:{video:[1,"video"]},decls:3,vars:3,consts:[[1,"video-untracked-path"],["role","progressbar",1,"video-tracked-path"]],template:function(e,i){e&1&&(te(0,"div",0)(1,"div",1),oe(2,"div"),ie()()),e&2&&(s(),S("width",i.progress(),"%"),E("aria-valuenow",i.progress()))},styles:["[_nghost-%COMP%]{display:block;width:100%;position:absolute;z-index:10;top:4px;padding-inline:8px;box-sizing:border-box}.video-untracked-path[_ngcontent-%COMP%], .video-tracked-path[_ngcontent-%COMP%]{height:4px;border-radius:var(--lc-video-progress-bar-radius)}.video-untracked-path[_ngcontent-%COMP%]{background-color:rgba(var(--lc-video-progress-bar-bg-color));width:100%;margin-bottom:2px}.video-tracked-path[_ngcontent-%COMP%]{background-color:rgba(var(--lc-video-progress-bar-color));transition:width .5s ease-in-out}@media (prefers-reduced-motion: reduce){.video-tracked-path[_ngcontent-%COMP%]{transition:none}}"]})};var Ae=["swiperContainer"],ze=(n,t)=>t.id;function Le(n,t){if(n&1){let e=v();l(0,"div",3)(1,"cooee-item-card",4),g("buttonClick",function(o){c(e);let r=a();return p(r.onButtonClick(o))})("click",function(){let o=c(e).$implicit,r=a();return p(r.cardClick.emit(o))}),d()()}if(n&2){let e=t.$implicit;s(),u("item",e)}}var L=class n{items=M.required();cardClick=P();destroyRef=m(Y);elementRef=m(T);engagementService=m(U);swiperContainerRef=ge.required("swiperContainer");swiperInstance;constructor(){k(()=>{this.initSwiper()}),this.destroyRef.onDestroy(()=>{this.swiperInstance?.destroy()})}ngOnInit(){O(this.elementRef.nativeElement.shadowRoot)}onButtonClick(t){let e=_e.get().website?.canChangeVariantInCart;if(this.items()?.length>1||t.hasVariants()&&!e){this.cardClick.emit(t);return}this.engagementService.executeCTA(Ce.ADD_TO_CART,{item:t})}initSwiper(){this.swiperInstance=new window.CooeeSDK.Swiper(this.swiperContainerRef().nativeElement,{direction:"horizontal",effect:"slide",slidesPerView:1.2,nested:!0,centeredSlides:!0,spaceBetween:12,mousewheel:{enabled:!0,thresholdDelta:10,thresholdTime:200}})}static \u0275fac=function(e){return new(e||n)};static \u0275cmp=w({type:n,selectors:[["cooee-video-promoted-items"]],viewQuery:function(e,i){e&1&&ae(i.swiperContainerRef,Ae,5),e&2&&de()},hostAttrs:[1,"letscooee-widget"],inputs:{items:[1,"items"]},outputs:{cardClick:"cardClick"},features:[me([U])],decls:5,vars:0,consts:[["swiperContainer",""],[1,"swiper-container"],[1,"swiper-wrapper"],[1,"swiper-slide"],["tabindex","0",3,"buttonClick","click","item"]],template:function(e,i){e&1&&(l(0,"div",1,0)(2,"div",2),y(3,Le,2,1,"div",3,ze),d()()),e&2&&(s(3),D(i.items()))},dependencies:[Re],styles:[`:host{display:block;width:100%}cooee-item-card{-webkit-backdrop-filter:blur(2px);backdrop-filter:blur(2px);background-color:rgba(var(--lc-card-bg-color));cursor:pointer;border-radius:var(--lc-card-radius)}
2
2
  `],encapsulation:3})};var Be=["swiperComp"],$e=["videoEl"],je=(n,t)=>t.url;function We(n,t){n&1&&(l(0,"div",11),_(1,"div",15),d())}function He(n,t){if(n&1&&_(0,"source",13),n&2){let e=t.$implicit;u("type",pe(e.mimeType))("src",e.url,J)}}function Ue(n,t){n&1&&B(0)}function Qe(n,t){if(n&1){let e=v();l(0,"cooee-video-promoted-items",24),g("cardClick",function(o){c(e);let r=a(2).$implicit,C=a();return p(C.productCardClicked(o,r))}),d()}if(n&2){let e=a(2).$implicit;u("items",e.items)}}function Ke(n,t){if(n&1&&_(0,"cooee-video-card",23),n&2){let e=a(2).$implicit;u("card",e.card)}}function qe(n,t){if(n&1){let e=v();_(0,"cooee-video-progress-bar",16),l(1,"div",17)(2,"cooee-mute-toggle",18),ce("mutedChange",function(o){c(e);let r=a(2);return le(r.muted,o)||(r.muted=o),p(o)}),g("toggled",function(){c(e);let o=a(2);return p(o.muteToggled())}),d(),I(3,Ue,1,0,"ng-container",8),d(),l(4,"div",19)(5,"cooee-share-button",20),g("dialogState",function(o){c(e);let r=a(2);return p(r.shareDialogOpen.set(o))}),d()(),l(6,"div",21),x(7,Qe,1,1,"cooee-video-promoted-items",22)(8,Ke,1,1,"cooee-video-card",23),d()}if(n&2){let e=a().$implicit,i=b(5),o=a(),r=b(9);u("video",i),s(2),se("muted",o.muted),u("videoEl",i),s(),u("ngTemplateOutlet",r),s(4),V(e.items.length&&o.footerContent===o.VideoConfigFooterContent.FIRST_ITEM?7:e.card&&o.footerContent===o.VideoConfigFooterContent.CARD?8:-1)}}function Ge(n,t){if(n&1){let e=v();l(0,"cooee-item-detail",25),g("closeClick",function(){c(e);let o=a(2);return p(o.productModalClosed())}),d()}if(n&2){let e=a(2);u("item",e.selectedItem)("similarItems",e.selectedVideo.items)}}function Ye(n,t){if(n&1){let e=v();l(0,"div",6)(1,"div",9)(2,"div",10),x(3,We,2,0,"div",11),l(4,"video",12,2),g("click",function(){let o=c(e).$index,r=a();return p(r.currentIndex===o&&r.toggleMute())})("ended",function(){c(e);let o=b(5),r=a();return p(r.onVideoEnded(o))})("loadstart",function(){let o=c(e).$index,r=a();return p(r.onVideoLoadStart(o))})("canplay",function(){let o=c(e).$index,r=a();return p(r.onVideoCanPlay(o))}),y(6,He,1,3,"source",13,je),d(),x(8,qe,9,5),d(),x(9,Ge,1,2,"cooee-item-detail",14),d()()}if(n&2){let e=t.$implicit,i=t.$index,o=a();s(2),S("background-image",e.thumbnail?"url("+e.thumbnail+")":null),s(),V(o.shouldShowVideoSpinner(i)?3:-1),s(),u("ngClass",o.viewTemplateClassName)("muted",!0),E("preload",o.isVideoVisible(i)?"metadata":"none")("data-video-id",e.id)("autoplay",null),s(2),D(e.sources),s(2),V(o.currentIndex===i?8:-1),s(),V(o.selectedItem&&o.currentIndex===i?9:-1)}}function Je(n,t){n&1&&B(0)}function Xe(n,t){if(n&1){let e=v();l(0,"button",26),g("click",function(){c(e);let o=a();return p(o.close())}),_(1,"cooee-icon",27),d()}}var Fe=class n{swiperComponent;videoElements;VideoConfigFooterContent=Se;currentIndex=0;muted=f(!1);selectedItem=null;selectedVideo;detailPopupTemplate;footerContent;viewTemplateClassName="lc-video-only-view";shareDialogOpen=f(!1);data=m(Ve);elementRef=m(T);eventData=m(N);dialogRef=m(xe);swiperInitialized=f(!1);swiperOptions=f(null);videos=[];triggerContext;engagementTrigger;isMobile=R();navigationConfig;cssLoadedPromise;resizeDebouncer=new be(this.onResize.bind(this));videoLoadingStates=new Map;constructor(){this.videos=this.data.videos,this.currentIndex=this.data.currentIndex,this.selectedVideo=this.videos[this.currentIndex],this.triggerContext=this.data.triggerContext,this.engagementTrigger=this.triggerContext.triggerData,this.navigationConfig=new Ee({enabled:!0,size:50,color:new Ie({h:"#000000"})}),this.cssLoadedPromise=O(this.elementRef.nativeElement.shadowRoot)}onKeyDown(t){t.preventDefault(),t.stopPropagation(),this.close()}async ngOnInit(){this.muted.set(await Q.get("muted",!1));let t=this.engagementTrigger?.content?.videoConfig;switch(this.detailPopupTemplate=t?.detailPopup.template??"VIDEO_ONLY_VIEW",this.footerContent=t?.footerContent??"FIRST_ITEM",this.detailPopupTemplate){case"PRODUCT_DETAIL_VIEW":this.selectItemForDetailView(),this.viewTemplateClassName="lc-product-detail-view";break;case"VIDEO_ONLY_VIEW":this.viewTemplateClassName="lc-video-only-view";break}}ngAfterViewInit(){this.initializeSwiperWithVideoDimensions()}ngOnDestroy(){this.resizeDebouncer?.destroy()}initializeSwiperWithVideoDimensions(){this.applyOptimalVideoDimensions(),this.initSwiperOptions(),this.playActiveVideo(!1)}close(){let t=this.getCurrentVideoElement();this.dialogRef.close({lastVideo:this.videos[this.currentIndex],lastVideoIndex:this.currentIndex,lastVideoDuration:t?.currentTime})}getCurrentVideoElement(){return this.videoElements.get(this.currentIndex)?.nativeElement}moveToNextVideo(){this.swiperComponent.swiper.slideTo(this.currentIndex+1)}productModalClosed(){this.selectedItem=null}pauseAll(){this.videoElements.forEach(t=>t.nativeElement.pause())}toggleMute(){this.muted.update(t=>!t)}async muteToggled(){await Q.set("muted",this.muted());let e=[this.muted()?"CE Video Muted":"CE Video Unmuted",{current:this.currentVideoProps()},{triggerData:this.engagementTrigger}];window.CooeeSDK.events.push(e)}playActiveVideo(t=!0){t&&this.pauseAll();let e=this.getCurrentVideoElement();e&&this.playVideo(e)}playVideo(t){t.currentTime=0,t.play().catch(e=>we.error(e))}onVideoEnded(t){if(this.currentIndex<this.videos.length-1)this.selectedItem||this.shareDialogOpen()?this.playVideo(t):this.moveToNextVideo();else{let e=this.getPreviousVideoDataForEvent(),i=["CE Last Video Ended",{previous:e},{triggerData:this.engagementTrigger}];window.CooeeSDK.events.push(i),this.playVideo(t)}}onSlideChange(t){let e=this.getPreviousVideoDataForEvent();this.currentIndex=t.realIndex,this.selectedVideo=this.videos[this.currentIndex],this.eventData.video=this.selectedVideo,this.eventData.index=this.currentIndex,this.playActiveVideo(),this.detailPopupTemplate==="PRODUCT_DETAIL_VIEW"?this.selectItemForDetailView():this.selectedItem=null;let i=this.currentVideoProps(),o={previous:e,current:i},r=new H("CE Video Changed",o,this.engagementTrigger);r.setVideos(this.videos[this.currentIndex]),window.CooeeSDK.sendEvent(r)}productCardClicked(t,e){let i={videoID:e.id,videoIndex:this.currentIndex},o=new H("CE More Item Info Clicked",{current:i},this.engagementTrigger);o.setVideos(e),window.CooeeSDK.sendEvent(o),this.selectedItem=t}onVideoLoadStart(t){this.videoLoadingStates.set(t,!0)}onVideoCanPlay(t){this.videoLoadingStates.set(t,!1)}shouldShowVideoSpinner(t){return this.swiperInitialized()?this.videoLoadingStates.get(t)===!0&&this.isVideoVisible(t):this.isVideoVisible(t)}isVideoVisible(t){let e=this.currentIndex-1,i=this.currentIndex+1;return t===this.currentIndex||t===e||t===i}async initSwiperOptions(){await this.cssLoadedPromise;let t=this.isMobile?1:"auto",e=0;this.isProductDetailView()&&(t="auto",e=10),this.swiperOptions.set({direction:this.isMobile?"vertical":"horizontal",effect:this.isMobile?"slide":"coverflow",slidesPerView:t,initialSlide:this.currentIndex,centeredSlides:!0,spaceBetween:e,coverflowEffect:{rotate:0,stretch:0,depth:400,modifier:1,slideShadows:!1},on:{init:i=>{this.swiperInitialized.set(!0),setTimeout(()=>{i.update()},100)}},mousewheel:{enabled:!this.isMobile,invert:!1,thresholdDelta:20}})}isProductDetailView(){return this.detailPopupTemplate==="PRODUCT_DETAIL_VIEW"}currentVideoProps(){return{videoID:this.videos[this.currentIndex].id,videoIndex:this.currentIndex}}getPreviousVideoDataForEvent(){let t=this.currentVideoProps(),e=this.videoElements.find(o=>o.nativeElement.dataset.videoId===this.videos[this.currentIndex].id)?.nativeElement;t.playedTillMS=Math.ceil(e?.currentTime*1e3);let i=e?.duration*1e3;return t.playedTillPercent=+(t.playedTillMS/i).toFixed(4),t}selectItemForDetailView(){this.selectedItem=this.isMobile?null:this.selectedVideo?.items?.[0]??null}applyOptimalVideoDimensions(){if(this.isMobile||this.isProductDetailView())return;let t=this.calculateOptimalVideoDimensions();t&&this.setVideoContainerDimensions(t.width,t.height)}calculateOptimalVideoDimensions(){let t=this.videos.map(h=>h.sources?.[0]).filter(h=>h?.width&&h?.height).map(h=>({width:h.width,height:h.height,aspectRatio:h.width/h.height}));if(t.length===0)return null;let e=t[0],i=window.innerWidth*.9,o=window.innerHeight*.9,r=i/e.width,C=o/e.height,G=Math.min(r,C);return{width:Math.floor(e.width*G),height:Math.floor(e.height*G)}}setVideoContainerDimensions(t,e){let i=this.elementRef.nativeElement;i.style.setProperty("--video-container-width",`${t}px`),i.style.setProperty("--video-container-height",`${e}px`)}onResize(){this.applyOptimalVideoDimensions()}static \u0275fac=function(e){return new(e||n)};static \u0275cmp=w({type:n,selectors:[["cooee-video-detail-dialog"]],viewQuery:function(e,i){if(e&1&&($(Be,7),$($e,5)),e&2){let o;j(o=W())&&(i.swiperComponent=o.first),j(o=W())&&(i.videoElements=o)}},hostAttrs:[1,"letscooee-widget"],hostBindings:function(e,i){e&1&&g("keydown.escape",function(r){return i.onKeyDown(r)},X)},decls:10,vars:4,consts:[["swiperComp",""],["closeButtonTemplate",""],["videoEl",""],[1,"lc-shadow-inner",3,"ngClass"],[1,"video-swiper",3,"slideChange","options","navigationConfig"],["ngProjectAs","swiper-slides",5,["swiper-slides"]],[1,"swiper-slide","video-slide"],[1,"lc-desktop-controls"],[4,"ngTemplateOutlet"],[1,"lc-video-modal-row"],[1,"lc-video-container"],[1,"video-loading-overlay"],["playsinline","",1,"lc-video-el",3,"click","ended","loadstart","canplay","ngClass","muted"],[3,"src","type"],[1,"swiper-no-swiping","swiper-no-mousewheel",3,"item","similarItems"],[1,"loading-spinner"],[3,"video"],[1,"lc-video-controls"],[3,"mutedChange","toggled","muted","videoEl"],[1,"share-controls"],[3,"dialogState"],[1,"lc-card-container"],[3,"items"],[3,"card"],[3,"cardClick","items"],[1,"swiper-no-swiping","swiper-no-mousewheel",3,"closeClick","item","similarItems"],["type","button","aria-label","Close",1,"lc-close-button",3,"click"],["name","close","aria-hidden","true"]],template:function(e,i){if(e&1){let o=v();l(0,"div",3)(1,"cooee-swiper",4,0),g("slideChange",function(C){return c(o),p(i.onSlideChange(C))}),ne(3,5),y(4,Ye,10,10,"div",6,ee),re(),d(),l(6,"div",7),I(7,Je,1,0,"ng-container",8),d()(),I(8,Xe,2,0,"ng-template",null,1,ue)}if(e&2){let o=b(9);u("ngClass",i.viewTemplateClassName),s(),u("options",i.swiperOptions())("navigationConfig",i.navigationConfig),s(3),D(i.videos),s(3),u("ngTemplateOutlet",o)}},dependencies:[L,Te,Me,A,z,ve,he,Pe,ke,F],styles:[`:host{display:flex}.lc-shadow-inner{position:relative;width:100vw;height:100vh;display:flex}@media (min-width: 768px){.lc-shadow-inner{background-color:color-mix(in oklab,#000 70%,transparent);justify-content:center;align-items:center}}.video-swiper{--swiper-navigation-size: 50px;--swiper-navigation-color: white;width:100dvw;height:100dvh}.lc-product-detail-view .video-swiper{align-items:center}@media (min-width: 768px){.video-swiper{width:100%;height:100%;max-width:90vw;max-height:90vh}}.video-swiper>.swiper-wrapper{max-height:100%}.lc-product-detail-view .video-swiper>.swiper-wrapper{align-items:center}@media (max-width: 768px){.video-swiper>.swiper-button-prev,.video-swiper>.swiper-button-next{display:none!important}}.video-slide{position:relative;display:flex;align-items:center;visibility:hidden}.lc-product-detail-view .video-slide{width:40vw!important;height:70vh!important}@media (min-width: 768px){.lc-product-detail-view .video-slide{min-width:650px!important}}@media (max-width: 768px){.lc-product-detail-view .video-slide{width:100%!important;height:100%!important}}@media (min-width: 768px){.lc-video-only-view .video-slide{width:fit-content!important}}@media (min-width: 768px){.video-slide{border-radius:var(--lc-media-radius);overflow:hidden}}.video-slide.swiper-slide-active,.video-slide.swiper-slide-prev,.video-slide.swiper-slide-next{visibility:visible}video{width:100%;height:100%;object-fit:cover;position:relative;z-index:3}.lc-desktop-controls{position:absolute;top:2rem;right:4rem;z-index:10;display:flex;gap:.5rem}@media (max-width: 768px){.lc-desktop-controls{display:none}}.lc-video-controls{position:absolute;top:1rem;z-index:10;right:.5rem;display:flex;gap:.25rem}@media (min-width: 768px){.lc-video-controls .lc-close-button{display:none}}.share-controls{position:absolute;bottom:30%;right:.5rem;z-index:10;display:flex;gap:.25rem;flex-direction:column;justify-content:center;align-items:center}.lc-close-button{width:var(--lc-icon-button-size, 44px);height:var(--lc-icon-button-size, 44px);display:flex;justify-content:center;align-items:center;border:none;border-radius:100%;background:#00000080;background:color-mix(in oklab,#000 50%,transparent)}.lc-video-container{position:relative;height:100%;width:100%;background:#000000b3 no-repeat center;background-size:cover}@media (min-width: 768px){.lc-product-detail-view .lc-video-container{width:50%}}@media (min-width: 768px){.lc-video-only-view .lc-video-container{width:var(--video-container-width, 100%);height:var(--video-container-height, 100%)}}.lc-card-container{position:absolute;bottom:12px;z-index:10;width:100%;padding-inline:12px;box-sizing:border-box}.lc-product-detail-view .lc-card-container{display:none}@media (max-width: 768px){.lc-product-detail-view .lc-card-container{display:block}}.lc-product-detail-view .lc-video-modal-row{display:flex;justify-content:center;height:100%;width:100%}.lc-video-only-view .lc-video-modal-row{display:block;height:100%}.lc-product-detail-view cooee-item-detail{--header-display: none;width:50%;flex:1}@media (max-width: 768px){.lc-product-detail-view cooee-item-detail{--header-display: flex;width:100%;height:70dvh;position:absolute;bottom:0;z-index:2147483646}}.lc-video-only-view cooee-item-detail{width:100%;height:70dvh;z-index:2147483646;bottom:0;position:absolute;border-radius:var(--lc-card-radius) var(--lc-card-radius) 0 0}@keyframes spin{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.video-loading-overlay{position:absolute;top:0;left:0;width:100%;height:100%;display:flex;align-items:center;justify-content:center;background-color:#0000004d;z-index:2}.video-loading-overlay .loading-spinner{width:30px;height:30px;border:3px solid rgba(255,255,255,.3);border-top:3px solid #fff;border-radius:50%;animation:spin 1s linear infinite}
3
3
  `],encapsulation:3})};export{Fe as VideoDetailDialogComponent};