!function(e){!function(e){"use strict";var t,r,i,n,o,s,a,c,u,l,d,p,h,m,w,f,g,v,y,b,S,P,I,E,C,k,D,T,A,N,U,W,F,_,V,x,O,R,L,M,j,B,J,$,G,q,z,H,K,X,Y,Z,Q,ee,te,re,ie,ne,oe,se,ae,ce,ue,le,de,pe,he,me,we,fe,ge,ve,ye,be,Se,Pe,Ie,Ee,Ce,ke,De,Te,Ae,Ne,Ue,We,Fe,_e,Ve,xe,Oe,Re,Le,Me,je,Be,Je,$e,Ge,qe,ze,He,Ke,Xe,Ye,Ze,Qe,et,tt,rt,it,nt,ot,st,at,ct,ut,lt,dt,pt,ht,mt,wt,ft,gt,vt,yt,bt,St,Pt,It,Et,Ct,kt,Dt,Tt,At,Nt,Ut,Wt,Ft,_t,Vt,xt,Ot,Rt,Lt,Mt,jt,Bt,Jt,$t,Gt,qt,zt,Ht,Kt,Xt,Yt,Zt,Qt,er,tr,rr,ir,nr,or,sr,ar,cr,ur,lr,dr,pr,hr,mr,wr,fr,gr,vr,yr,br,Sr,Pr,Ir,Er,Cr,kr,Dr,Tr,Ar,Nr,Ur,Wr,Fr,_r,Vr,xr,Or,Rr,Lr,Mr,jr,Br,Jr,$r,Gr,qr,zr,Hr,Kr,Xr,Yr,Zr,Qr,ei,ti,ri,ii,ni,oi,si,ai,ci,ui,li,di,pi,hi,mi,wi,fi,gi,vi,yi,bi,Si,Pi,Ii,Ei,Ci,ki,Di,Ti,Ai,Ni,Ui,Wi,Fi,_i,Vi,xi,Oi,Ri,Li,Mi,ji,Bi,Ji,$i,Gi,qi,zi,Hi,Ki,Xi,Yi,Zi,Qi,en,tn,rn,nn,on,sn,an,cn,un,ln,dn,pn,hn,mn,wn,fn,gn,vn,yn,bn,Sn,Pn,In=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},En=(e,t,r)=>(In(e,t,"read from private field"),r?r.call(e):t.get(e)),Cn=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},kn=(e,t,r,i)=>(In(e,t,"write to private field"),i?i.call(e,r):t.set(e,r),r),Dn=(e,t,r)=>(In(e,t,"access private method"),r),Tn=(e=>(e["Await"]="await",e["Filter"]="filter",e["React"]="react",e["BackendTransfer"]="backend_transfer",e))(Tn||{}),An=(e=>(e["AwaitClick"]="await_click",e["AwaitScroll"]="await_scroll",e["AwaitExit"]="await_exit",e["AwaitInactivity"]="await_inactivity",e["AwaitECommerceActivity"]="await_ecommerce_activity",e["AwaitMergedNodes"]="await_merged_nodes",e["AwaitWebPushConsent"]="await_webpush_consent",e["FilterUrl"]="filter_url",e["FilterSubscriber"]="filter_subscriber",e["FilterDevice"]="filter_device",e["FilterLocation"]="filter_location",e["FilterTime"]="filter_time",e["FilterVisit"]="filter_visit",e["FilterUniqueSessionVisit"]="filter_unique_session_visit",e["FilterPopup"]="filter_popup",e["FilterECommerceActivity"]="filter_ecommerce_activity",e["ReactDelay"]="react_delay",e["ReactScroll"]="react_scroll",e["ReactRedirect"]="react_redirect",e["ReactPopup"]="react_popup",e["ReactSendToBackend"]="react_send_to_backend",e["ReactSendWebPush"]="react_send_webpush",e["ReactCollectWebPushConsent"]="react_collect_web_push_consent",e))(An||{});class Nn extends Error{}const Un="true",Wn="false",Fn="exit";class _n extends ReferenceError{constructor(e){super(`Node of selector ${e} not found`),Object.setPrototypeOf(this,new.target.prototype),this.name="ElementNotFoundException"}}if(false){if("undefined"!=typeof navigator&&"ReactNative"===navigator.product&&"undefined"==typeof crypto)throw new Error("React Native does not have a built-in secure random generator. If you don’t need unpredictable IDs use `nanoid/non-secure`. For secure IDs, import `react-native-get-random-values` before Nano ID.");if("undefined"!=typeof msCrypto&&"undefined"==typeof crypto)throw new Error("Import file with `if (!window.crypto) window.crypto = window.msCrypto` before importing Nano ID to fix IE 11 support");if("undefined"==typeof crypto)throw new Error("Your browser does not have secure random generator. If you don’t need unpredictable IDs, you can use nanoid/non-secure.")}let Vn=(e=21)=>{let t="",r=crypto.getRandomValues(new Uint8Array(e));for(;e--;){let i=63&r[e];if(36>i)t+=i.toString(36);else if(62>i)t+=(i-26).toString(36).toUpperCase();else if(63>i)t+="_";else t+="-"}return t};const xn="_grDebugMode",On=new class{isDebugEnabled(){return!!window.sessionStorage.getItem(xn)}startDebug(){window.sessionStorage.setItem(xn,"true")}},Rn=new class{get isLoggingEnabled(){return On.isDebugEnabled()}log(...e){this.displayLog("log",...e)}info(...e){this.displayLog("info",...e)}error(...e){if(e[0]instanceof Error)e.push(e[0].stack);this.displayLog("error",...e)}forceLogError(...e){if(e[0]instanceof Error)e.push(e[0].stack);console.error(...e)}warn(...e){this.displayLog("warn",...e)}displayLog(e,...t){if(this.isLoggingEnabled)console[e](...t)}};function Ln(e){const t=document.cookie.match(new RegExp(`(^| )${e}=([^;]+)`));if(t)return t[2]}function Mn(){const e=new Date,t=location.hostname.split(".").reverse(),r=[],i=`gaDomain-${Vn(6)}`,n=Vn(6);let o="";for(e.setTime(e.getTime()+60*1e3),r.push(t.shift());t.length>0;){if(o=r.reverse().join("."),document.cookie=`${i}=${n}; expires=${e.toUTCString()}; domain=.${o}; path=/`,Ln(i)===n)return o;r.push(t.shift())}return location.hostname}function jn(e){return new Proxy({},{get(t,r){if(!(r in t))if("object"==typeof e&&null!==e)t[r]=structuredClone(e);else t[r]=e;return t[r]}})}function Bn(e){return e.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function Jn(e){return!!e&&"object"==typeof e}function $n(e,t){const r={...e};for(const i of Object.keys(t))if(e.hasOwnProperty(i)&&Jn(e[i])&&Jn(t[i])&&!Array.isArray(e[i]))r[i]=$n(e[i],t[i]);else r[i]=t[i];return r}class Gn{constructor(){Cn(this,t,jn([]))}on(e,r,i={}){if(En(this,t)[e].push({once:i.once,listener:r}),i.signal)i.signal.addEventListener("abort",(()=>{this.off(e,r)}),{once:true})}off(e,r){En(this,t)[e]=En(this,t)[e].filter((e=>e.listener!==r))}emit(e,...r){En(this,t)[e].forEach((({listener:t,once:i})=>{if(t(...r),i)this.off(e,t)}))}}t=new WeakMap;const qn={1:"1",2:"2",3:"3",4:"4",5:"5",6:"6",0:"7"};function zn(e){Rn.error(`Unsupported value: ${e}`)}class Hn{static hasValue(...e){return true}}class Kn extends Hn{constructor(e){super(),Cn(this,n),Cn(this,r,null),Cn(this,i,void 0),kn(this,r,e)}waitForUpstream(){if(!Dn(this,n,o).call(this))return new Promise((e=>{const t=Date.now(),n=Date.parse(En(this,r))-t;if(n>0)kn(this,i,window.setTimeout((()=>{e()}),n));else e()}))}cancelUpstreamCalculation(){if(En(this,i))clearTimeout(En(this,i))}static hasValue(e){const t=Date.parse(e);return!isNaN(t)}}var Xn,Yn;r=new WeakMap,i=new WeakMap,n=new WeakSet,o=function(){return(new Date).getTime()>Date.parse(En(this,r))},(Yn=Xn||(Xn={}))["PageVisit"]="visit",Yn["Popup"]="popup",Yn["ViewItem"]="view_item",Yn["ViewCategory"]="view_category",Yn["WishlistItem"]="wishlist_item",Yn["LikeItem"]="like_item",Yn["UnlikeItem"]="unlike_item",Yn["OrderPlaced"]="order_placed",Yn["Cart"]="cart_update",void(Yn["ShopifyAbandonedCart"]="shopify_webhook_abandoned_cart");let Zn=class extends Error{constructor(e){super(e),Object.setPrototypeOf(this,new.target.prototype),this.name=this.constructor.name}};class Qn extends Zn{constructor(e){super(e)}}const eo={cartToken:"string",urlToken:"string",visitorEmail:"string"},to=["cartToken","urlToken"];var ro,io,no,oo,so,ao,co,uo,lo,po,ho,mo,wo,fo;(fo=ro||(ro={}))["Inline"]="inline",void(fo["Popup"]="popup"),(wo=io||(io={}))["Hq"]="Hq",void(wo["Us"]="Us"),void((no||(no={}))["UserAid"]="X-Aid"),(mo=oo||(oo={}))[mo["OneSecond"]=1e3]="OneSecond",mo[mo["OneMinute"]=6e4]="OneMinute",mo[mo["OneHour"]=36e5]="OneHour",mo[mo["OneDay"]=864e5]="OneDay",void(mo[mo["OneWeek"]=6048e5]="OneWeek"),(ho=so||(so={}))["Active"]="active",void(ho["Inactive"]="inactive"),(po=ao||(ao={}))["EveryTime"]="everyTime",void(po["OnceEveryAmountTime"]="onceEveryAmountTime"),void((co||(co={}))["RemoveLastTransitionNodeEnter"]="removeLastTransitionNodeEnter"),(lo=uo||(uo={}))["ReactSendWebPush"]="react_web_webpush",lo["ReactCollectWebPushConsent"]="react_web_collect_webpush_subscription",lo["ReactShowPopup"]="react_web_popup",lo["FilterWebUrl"]="filter_web_url",lo["FilterWebSubscribers"]="filter_web_subscriber",lo["FilterLocation"]="filter_web_geolocation",lo["FilterDevice"]="filter_web_device",lo["FilterReturningVisitor"]="filter_web_returning_visitor",lo["ConditionProductViewed"]="await_web_view_item_event",lo["ConditionCategoryViewed"]="await_web_view_category_event",lo["ConditionWebPushConsent"]="await_web_webpush_subscribe",lo["ConditionProductLiked"]="await_web_like_item_event",lo["ConditionWebAction"]="await_web_action",lo["TransferToBackend"]="react_backend_transfer",lo["AwaitScroll"]="await_scroll",void(lo["ShowPopup"]="react_popup");class go extends Hn{constructor(e,t){super(),Cn(this,u),Cn(this,d),Cn(this,s,void 0),Cn(this,a,void 0),Cn(this,c,void 0),kn(this,s,e),kn(this,a,t)}waitForUpstream(){if(Dn(this,u,l).call(this))return Promise.resolve();else return new Promise((e=>{const t=Date.now(),r=Dn(this,d,p).call(this)+En(this,s)*oo.OneSecond-t;if(!Number.isNaN(r))if(r>0)kn(this,c,window.setTimeout((()=>{e()}),r));else e()}))}cancelUpstreamCalculation(){if(En(this,c))clearTimeout(En(this,c))}static hasValue(e){return"number"==typeof e&&e>=0}}s=new WeakMap,a=new WeakMap,c=new WeakMap,u=new WeakSet,l=function(){return Date.now()-Dn(this,d,p).call(this)>En(this,s)*oo.OneSecond},d=new WeakSet,p=function(){var e;return(null==(e=En(this,a))?void 0:e.node_entered_at)?new Date(En(this,a).node_entered_at).getTime():(new Date).getTime()};var vo=(e=>(e["ExitIntend"]="exit-intend",e))(vo||{});const yo={gr:"exit-intend"};var bo,So,Po,Io,Eo,Co,ko,Do,To,Ao,No,Uo,Wo,Fo,_o,Vo,xo,Oo,Ro,Lo,Mo,jo,Bo,Jo,$o,Go,qo,zo,Ho,Ko,Xo,Yo,Zo,Qo,es,ts,rs,is,ns,os;(os=bo||(bo={}))["ShowWhenCondition"]="showWhenCondition",os["VisitorsCondition"]="visitors",os["DeviceCondition"]="device",os["LocationCondition"]="location",os["ECommerceCondition"]="ecommerce",os["TriggerFrequency"]="frequency",os["PreventDisplay"]="preventDisplay",void(os["DateRange"]="dateRange"),(ns=So||(So={}))["Mobile"]="mobile",ns["Tablet"]="tablet",void(ns["Desktop"]="desktop"),(is=Po||(Po={}))["All"]="all",is["New"]="new",void(is["Returning"]="returning"),void((Io||(Io={}))["All"]="all"),(rs=Eo||(Eo={}))["ConditionsLogicSeparator"]="conditionsLogicSeparator",void(rs["ECommerceConditions"]="ecommerceConditions"),(ts=Co||(Co={}))["Amount"]="amount",void(ts["Date"]="date"),(es=ko||(ko={}))["And"]="and",void(es["Or"]="or"),(Qo=Do||(Do={}))["Exactly"]="exactly",Qo["LessThan"]="lessThan",void(Qo["MoreThan"]="moreThan"),(Zo=To||(To={}))["LastDays"]="lastDays",void(Zo["DateRange"]="dateRange"),(Yo=Ao||(Ao={}))["AnyProduct"]="any",Yo["AnyCategory"]="any",Yo["AnyProductLiked"]="any",Yo["AnyProductInPlacedOrder"]="any",Yo["AnyCategoryInPlacedOrder"]="any",Yo["AnyProductInUpdatedCart"]="any",void(Yo["AnyCategoryInUpdatedCart"]="any"),(Xo=No||(No={}))["PastEvents"]="filter",void(Xo["FutureEvents"]="await"),(Ko=Uo||(Uo={}))["Category"]="category",void(Ko["Product"]="product"),void((Wo||(Wo={}))["Product"]="product"),(Ho=Fo||(Fo={}))["ViewProductOrCategory"]="productOrCategoryView",Ho["LikeProduct"]="likeItem",Ho["OrderPlaced"]="orderPlaced",void(Ho["CartUpdated"]="cartUpdated"),(zo=_o||(_o={}))["Percent"]="percent",void(zo["Selector"]="selector"),(qo=Vo||(Vo={}))["Instantly"]="instantly",qo["Delay"]="delay",qo["Exit"]="exit",qo["Scroll"]="scroll",qo["Inactivity"]="inactivity",void(qo["Click"]="click"),(Go=xo||(xo={}))["AfterSubmit"]="submit",Go["AfterClose"]="close",void(Go["AfterTimes"]="timesAmount"),($o=Oo||(Oo={}))["Always"]="always",$o["Session"]="session",void($o["EveryDays"]="everyDays"),(Jo=Ro||(Ro={}))["Exactly"]="equal",Jo["LessThan"]="lessThan",void(Jo["MoreThan"]="moreThan"),(Bo=Lo||(Lo={}))["Exactly"]="equal",Bo["LessThan"]="lessThan",void(Bo["MoreThan"]="moreThan"),(jo=Mo||(Mo={}))[jo["InvalidCssSelector"]=1]="InvalidCssSelector",jo[jo["EmptyCssSelector"]=2]="EmptyCssSelector",jo[jo["CssSelectorTooLong"]=3]="CssSelectorTooLong",jo[jo["CssInvalidType"]=4]="CssInvalidType",jo[jo["InvalidTimeoutProperty"]=5]="InvalidTimeoutProperty",jo[jo["ShowWhenScrollPercentInvalidValueType"]=6]="ShowWhenScrollPercentInvalidValueType",jo[jo["ShowWhenScrollPercentValueOutOfBound"]=7]="ShowWhenScrollPercentValueOutOfBound",jo[jo["VisitorTriggerEmpty"]=8]="VisitorTriggerEmpty",jo[jo["VisitorTriggerInvalidProperty"]=9]="VisitorTriggerInvalidProperty",jo[jo["DevicesTriggerEmpty"]=10]="DevicesTriggerEmpty",jo[jo["DevicesTriggerInvalidValue"]=11]="DevicesTriggerInvalidValue",jo[jo["FrequencyEmptyTrigger"]=12]="FrequencyEmptyTrigger",jo[jo["FrequencyTriggerInvalidName"]=13]="FrequencyTriggerInvalidName",jo[jo["FrequencyTriggerNDaysInvalidPropertyValue"]=14]="FrequencyTriggerNDaysInvalidPropertyValue",jo[jo["FrequencyTriggerNDaysEmptyValue"]=15]="FrequencyTriggerNDaysEmptyValue",jo[jo["PreventDisplayTriggerInvalidName"]=16]="PreventDisplayTriggerInvalidName",jo[jo["PreventDisplayTriggerAfterTimesNoValue"]=17]="PreventDisplayTriggerAfterTimesNoValue",jo[jo["PreventDisplayTriggerAfterTimesInvalidValue"]=18]="PreventDisplayTriggerAfterTimesInvalidValue",jo[jo["DateRangeInvalidFromDate"]=19]="DateRangeInvalidFromDate",jo[jo["DateRangeInvalidToDate"]=20]="DateRangeInvalidToDate",jo[jo["DateRangeDateFromAfterDateTo"]=21]="DateRangeDateFromAfterDateTo",jo[jo["LocationEmptyTrigger"]=22]="LocationEmptyTrigger",jo[jo["LocationInvalidType"]=23]="LocationInvalidType",jo[jo["LackOfLogicSeparator"]=24]="LackOfLogicSeparator",jo[jo["LackOfTriggerConditions"]=25]="LackOfTriggerConditions",jo[jo["InvalidTriggerConditions"]=26]="InvalidTriggerConditions",jo[jo["NoProductOrCategorySelected"]=27]="NoProductOrCategorySelected",jo[jo["ProductInvalidType"]=28]="ProductInvalidType",jo[jo["CategoryInvalidType"]=29]="CategoryInvalidType",jo[jo["AmountInvalidConditionName"]=30]="AmountInvalidConditionName",jo[jo["AmountInvalidConditionValueType"]=31]="AmountInvalidConditionValueType",jo[jo["DateInvalidConditionName"]=32]="DateInvalidConditionName",jo[jo["DateLastDaysInvalidConditionValue"]=33]="DateLastDaysInvalidConditionValue",jo[jo["DateDateRangeInvalidConditionValue"]=34]="DateDateRangeInvalidConditionValue",jo[jo["DateDateRangeFromInvalidValue"]=35]="DateDateRangeFromInvalidValue",jo[jo["DateDateRangeToInvalidValue"]=36]="DateDateRangeToInvalidValue",jo[jo["DateDateRangeDateFromAfterDateTo"]=37]="DateDateRangeDateFromAfterDateTo",jo[jo["PopupTriggerInvalidName"]=38]="PopupTriggerInvalidName",jo[jo["PopupTriggerLackOfValuesInLikeItemTrigger"]=39]="PopupTriggerLackOfValuesInLikeItemTrigger",jo[jo["PopupTriggerLikeItemInvalidValues"]=40]="PopupTriggerLikeItemInvalidValues",jo[jo["PopupTriggerOrderPlacedNoConditions"]=41]="PopupTriggerOrderPlacedNoConditions",jo[jo["PopupTriggerOrderPlacedInvalidProducts"]=42]="PopupTriggerOrderPlacedInvalidProducts",jo[jo["PopupTriggerOrderPlacedInvalidCategories"]=43]="PopupTriggerOrderPlacedInvalidCategories",jo[jo["PopupTriggerCartUpdatedNoConditions"]=44]="PopupTriggerCartUpdatedNoConditions",jo[jo["PopupTriggerCartUpdatedInvalidProducts"]=45]="PopupTriggerCartUpdatedInvalidProducts",jo[jo["PopupTriggerCartUpdatedInvalidCategories"]=46]="PopupTriggerCartUpdatedInvalidCategories",jo[jo["PopupTriggerPriceValueConditionInvalidComparator"]=47]="PopupTriggerPriceValueConditionInvalidComparator",jo[jo["PopupTriggerPriceValueConditionInvalidValue"]=48]="PopupTriggerPriceValueConditionInvalidValue",jo[jo["PopupTriggerProductsAmountValueConditionInvalidComparator"]=49]="PopupTriggerProductsAmountValueConditionInvalidComparator",jo[jo["PopupTriggerProductsAmountValueConditionInvalidValue"]=50]="PopupTriggerProductsAmountValueConditionInvalidValue",void(jo[jo["PopupTriggerInvalidTriggerType"]=51]="PopupTriggerInvalidTriggerType");var ss=(e=>(e[e["Mobile"]=768]="Mobile",e[e["Tablet"]=1023]="Tablet",e))(ss||{});const as=Symbol("DeviceService");h=new WeakSet,m=()=>window.matchMedia("(any-pointer: coarse)").matches&&navigator.maxTouchPoints>0,w=new WeakSet,f=()=>window.matchMedia("(pointer: coarse)").matches&&navigator.maxTouchPoints>0;let cs=class e{constructor(t){if(Cn(this,h),Cn(this,w),new.target===e&&t!==as)throw new Error(`Invalid ${new.target.name} constructor`)}detectDeviceTypeByScreenWidth(e){var t;const{availWidth:r,availHeight:i}=screen;let n=null==(t=screen.orientation)?void 0:t.type;if(!n)n=window.matchMedia("(orientation: landscape)").matches?"landscape":"portrait";const o=n.match(/landscape/)?i:r;if(ss.Mobile>=o)return So.Mobile;else if(o>ss.Mobile&&ss.Tablet>=o)return So.Tablet;return e?So.Tablet:So.Desktop}isDesktopDevice(){return this.getDeviceType()===So.Desktop}getDeviceType(){var e,t;const{userAgentData:r}=window.navigator;if(r){if(r.mobile)return So.Mobile;else if((null==(e=r.platform)?void 0:e.toLowerCase().includes("android"))||(null==(t=r.platform)?void 0:t.toLowerCase().includes("ipad")))return So.Tablet;else if(En(this,w,f))return So.Tablet}else if(En(this,w,f))return this.detectDeviceTypeByScreenWidth(true);else if(En(this,h,m))return this.detectDeviceTypeByScreenWidth();return So.Desktop}getBrowserLanguage(){const{language:e}=window.navigator;if(e.match(/\w{2}-\w{2}/))return e.split("-")[0].toLowerCase();else return e.toLowerCase()}getUserOs(){const{userAgentData:e}=window.navigator;if(e)return e.platform.toLowerCase();else return this.getOsFromUserAgent()}getOsFromUserAgent(){let e="unknown";const{userAgent:t}=navigator,r=t.toLowerCase();if(r.includes("win"))e="windows";if(r.includes("mac"))e="macos";if(r.includes("x11"))e="unix";if(r.includes("linux"))e="Linux";if(r.includes("android"))e="android";if(/iphone|ipad|ipod/.test(r))e="ios";return e}};const us=new cs(as),ls=50;class ds{constructor({useMobileHistoryBasedExitIntend:e=false,useMobileScrollBasedExitIntend:t=false}){Cn(this,b),Cn(this,P),Cn(this,E),Cn(this,k),Cn(this,T),Cn(this,g,null),Cn(this,v,false),Cn(this,y,false),kn(this,g,new AbortController),kn(this,v,e),kn(this,y,t)}handle(){return us.isDesktopDevice()?Dn(this,P,I).call(this):Dn(this,E,C).call(this)}abort(){En(this,g).abort()}}g=new WeakMap,v=new WeakMap,y=new WeakMap,b=new WeakSet,S=e=>{const{clientX:t,clientY:r}=e,{clientWidth:i,clientHeight:n}=document.documentElement;return!(t>0&&i>t&&r>0&&n>r)},P=new WeakSet,I=function(){return new Promise((e=>{document.documentElement.addEventListener("mouseleave",(t=>{if(Dn(this,b,S).call(this,t))e(),En(this,g).abort()}),{signal:En(this,g).signal})}))},E=new WeakSet,C=function(){const e=[Dn(this,P,I).call(this)];if(En(this,v))e.push(Dn(this,k,D).call(this));if(En(this,y))e.push(Dn(this,T,A).call(this));return Promise.race(e)},k=new WeakSet,D=function(){return new Promise((e=>{const t=window.history.state;document.documentElement.addEventListener("touchstart",(()=>{window.history.replaceState(yo,""),window.history.pushState(yo,""),window.addEventListener("popstate",(()=>{setTimeout((()=>{var r;if((null==(r=window.history.state)?void 0:r.gr)===vo.ExitIntend)e(),En(this,g).abort(),window.history.replaceState(t,"")}),0)}),{signal:En(this,g).signal})}),{once:true,signal:En(this,g).signal})}))},T=new WeakSet,A=function(){const e=document.documentElement;let t=e.scrollTop;return new Promise((r=>{window.addEventListener("scroll",(()=>{if(ls>e.scrollTop&&-ls>e.scrollTop-t)r(),En(this,g).abort();else t=e.scrollTop}),{signal:En(this,g).signal})}))};class ps extends Hn{constructor(){super(),Cn(this,N,void 0),kn(this,N,new ds({useMobileHistoryBasedExitIntend:true,useMobileScrollBasedExitIntend:true}))}waitForUpstream(){return En(this,N).handle()}cancelUpstreamCalculation(){En(this,N).abort()}static hasValue(e){return"boolean"==typeof e&&true===e}}N=new WeakMap,U=new WeakMap,W=new WeakMap,F=new WeakMap,_=new WeakMap,V=new WeakSet,x=async function(){const{quantifier:e}=En(this,F),t=En(this,W).map((e=>e.waitForUpstream()));if("and"===e)await Promise.all(t);else await Promise.race(t);this.emit("upstreamPassed"),this.hasUpstreamTimePassed=true},O=new WeakSet,R=function(){if(En(this,W).length)En(this,W).forEach((e=>e.cancelUpstreamCalculation()))},L=new WeakSet,(e,t)=>{const r=new Date(t);return e.includes((r.getHours()+1).toString())},M=new WeakSet,(e,t)=>{const r=new Date(t);return e.includes(r.getDate().toString())},j=new WeakSet,(e,t)=>{const r=new Date(t);return e.includes(qn[r.getDay().toString()])},B=new WeakSet,J=function(e){const t=[];return e.forEach((e=>{const{type:r,value:i}=e;switch(r){case"specificDate":if(Kn.hasValue(i))t.push(new Kn(i));break;case"delaySeconds":if(go.hasValue(i))t.push(new go(i,En(this,U)));break;case"onExitIntent":if(ps.hasValue(i))t.push(new ps);break;case"allowedDaysOfMonth":case"allowedHours":case"excludedDaysOfWeek":case"recalculateAt":break;default:zn(r)}})),t};let hs=class e extends Gn{constructor({journey:e,upstreamData:t,signal:r}){super(),Cn(this,V),Cn(this,O),Cn(this,L),Cn(this,M),Cn(this,j),Cn(this,B),Cn(this,U,void 0),Cn(this,W,void 0),Cn(this,F,void 0),Cn(this,_,void 0),kn(this,U,null),kn(this,W,[]),kn(this,F,null),this.hasUpstreamTimePassed=false,kn(this,_,null),kn(this,F,t),kn(this,U,e),kn(this,_,r)}static create(t){return new e(t)}initVisitorEntry(){var e;if(null==(e=En(this,F))?void 0:e.upstreams.length)if(kn(this,W,Dn(this,B,J).call(this,En(this,F).upstreams)),Dn(this,V,x).call(this),En(this,_))En(this,_).onabort=()=>{Dn(this,O,R).call(this)}}};var ms=(e=>(e["Api"]="api",e["Db"]="db",e["AutomationJourneyReactWebPushApi"]="automationJourneyReactWebPushApi",e["AutomationJourneyReactWebPushDb"]="automationJourneyReactWebPushDb",e))(ms||{}),ws=(e=>(e["Events"]="gr_webconnect",e["VisitorJourneys"]="gr_visitor_journeys",e["ServiceWorkerCallbacks"]="gr_sw_callbacks",e))(ws||{});const fs={gr_webconnect:1,gr_visitor_journeys:2,gr_sw_callbacks:1};var gs=(e=>(e["UserActivityEvents"]="user_activity_events",e))(gs||{}),vs=(e=>(e["EventType"]="eventType",e["VisitorUuid"]="visitorUuid",e["EventTypeWithVisitor"]="eventType, visitorUuid",e))(vs||{}),ys=(e=>(e["VisitorJourneys"]="visitorJourneys",e["VisitorJourneysGraphHistory"]="visitorJourneysGraphHistory",e["GraphJourneyFetchedData"]="graphJourneyFetchedData",e))(ys||{}),bs=(e=>(e["Callbacks"]="callbacks",e))(bs||{}),Ss=(e=>(e["VisitorUuid"]="visitor_uuid",e["JourneyIdentifier"]="uuid",e["VisitorUuidWithJourneyIdentifier"]="visitor_uuid, uuid",e))(Ss||{}),Ps=(e=>(e["VisitorUuid"]="visitor.uuid",e["NodeUuid"]="node.uuid",e["VisitorUuidWithNodeUuid"]="visitor.uuid, node.uuid",e))(Ps||{}),Is=(e=>(e["GraphId"]="graph.id",e))(Is||{});function Es(e,t,r){(e=>{if(!e.objectStoreNames.contains(ys.VisitorJourneys))try{const t=e.createObjectStore(ys.VisitorJourneys,{keyPath:["journey.uuid","visitor.uuid"],autoIncrement:false}),r=e.createObjectStore(ys.VisitorJourneysGraphHistory,{keyPath:["node.uuid","visitor.uuid"],autoIncrement:false});t.createIndex(Ss.VisitorUuid,"visitor.uuid",{unique:false}),t.createIndex(Ss.JourneyIdentifier,"journey.uuid",{unique:false}),t.createIndex(Ss.VisitorUuidWithJourneyIdentifier,["visitor.uuid","journey.uuid"],{unique:false}),r.createIndex(Ps.VisitorUuid,"visitor.uuid",{unique:false}),r.createIndex(Ps.NodeUuid,"node.uuid",{unique:false}),r.createIndex(Ps.VisitorUuidWithNodeUuid,["visitor.uuid","node.uuid"],{unique:true})}catch(t){Rn.error("Error while initializing/upgrading visitor journeys database",t)}})(r),(e=>{if(!e.objectStoreNames.contains(ys.GraphJourneyFetchedData))try{e.createObjectStore(ys.GraphJourneyFetchedData,{keyPath:["graph.id","journey.id","node.id"],autoIncrement:false}).createIndex(Is.GraphId,"graph.id",{unique:false})}catch(t){Rn.error("Error while initializing graph journey active node since date store",t)}})(r)}function Cs(e,t){return[e,t]}let ks,Ds;const Ts=new WeakMap,As=new WeakMap,Ns=new WeakMap,Us=new WeakMap,Ws=new WeakMap;let Fs={get(e,t,r){if(e instanceof IDBTransaction){if("done"===t)return As.get(e);if("objectStoreNames"===t)return e.objectStoreNames||Ns.get(e);if("store"===t)return r.objectStoreNames[1]?void 0:r.objectStore(r.objectStoreNames[0])}return Vs(e[t])},set:(e,t,r)=>(e[t]=r,true),has(e,t){if(e instanceof IDBTransaction&&("done"===t||"store"===t))return true;else return t in e}};function _s(e){if("function"==typeof e)return function(e){if(e===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype))return function(t,...r){const i=e.call(xs(this),t,...r);return Ns.set(i,t.sort?t.sort():[t]),Vs(i)};if((Ds||(Ds=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])).includes(e))return function(...t){return e.apply(xs(this),t),Vs(Ts.get(this))};else return function(...t){return Vs(e.apply(xs(this),t))}}(e);if(e instanceof IDBTransaction)!(e=>{if(As.has(e))return;const t=new Promise(((t,r)=>{const i=()=>{e.removeEventListener("complete",n),e.removeEventListener("error",o),e.removeEventListener("abort",o)},n=()=>{t(),i()},o=()=>{r(e.error||new DOMException("AbortError","AbortError")),i()};e.addEventListener("complete",n),e.addEventListener("error",o),e.addEventListener("abort",o)}));As.set(e,t)})(e);if(t=e,(ks||(ks=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])).some((e=>t instanceof e)))return new Proxy(e,Fs);else return e;var t}function Vs(e){if(e instanceof IDBRequest)return(e=>{const t=new Promise(((t,r)=>{const i=()=>{e.removeEventListener("success",n),e.removeEventListener("error",o)},n=()=>{t(Vs(e.result)),i()},o=()=>{r(e.error),i()};e.addEventListener("success",n),e.addEventListener("error",o)}));return t.then((t=>{if(t instanceof IDBCursor)Ts.set(t,e)})).catch((()=>{})),Ws.set(t,e),t})(e);if(Us.has(e))return Us.get(e);const t=_s(e);if(t!==e)Us.set(e,t),Ws.set(t,e);return t}const xs=e=>Ws.get(e),Os=["get","getKey","getAll","getAllKeys","count"],Rs=["put","add","delete","clear"],Ls=new Map;function Ms(e,t){if(!(e instanceof IDBDatabase&&!(t in e)&&"string"==typeof t))return;if(Ls.get(t))return Ls.get(t);const r=t.replace(/FromIndex$/,""),i=t!==r,n=Rs.includes(r);if(!(r in(i?IDBIndex:IDBObjectStore).prototype)||!(n||Os.includes(r)))return;const o=async function(e,...t){const o=this.transaction(e,n?"readwrite":"readonly");let s=o.store;if(i)s=s.index(t.shift());return(await Promise.all([s[r](...t),n&&o.done]))[0]};return Ls.set(t,o),o}var js;js=Fs,void(Fs={...js,get(e,t,r){return Ms(e,t)||js.get(e,t,r)},has(e,t){return!!Ms(e,t)||js.has(e,t)}});const Bs=new class{openEventsDatabaseConnection(e){return this.openConnection(ws.Events,fs[ws.Events],e)}openAutomationJourneysDatabaseConnection(e){return this.openConnection(ws.VisitorJourneys,fs[ws.VisitorJourneys],e)}openServiceWorkerCallbacksDatabaseConnection(e){return this.openConnection(ws.ServiceWorkerCallbacks,fs[ws.ServiceWorkerCallbacks],e)}async openConnection(e,t,r){const i=await((e,t,{blocked:r,upgrade:i,blocking:n,terminated:o}={})=>{const s=indexedDB.open(e,t),a=Vs(s);if(i)s.addEventListener("upgradeneeded",(e=>{i(Vs(s.result),e.oldVersion,e.newVersion,Vs(s.transaction),e)}));if(r)s.addEventListener("blocked",(e=>r(e.oldVersion,e.newVersion,e)));return a.then((e=>{if(o)e.addEventListener("close",(()=>o()));if(n)e.addEventListener("versionchange",(e=>n(e.oldVersion,e.newVersion,e)))})).catch((()=>{})),a})(e,t,{blocked(e,t,r){Rn.error(`Connection to old db version: ${t} not closed. Version ${e} not available`,r)},upgrade(e,t,i){Rn.log(`New db version ${i} detected, upgrading from ${t}`),r(t,i,e)},terminated(){Rn.log("Closing db connection")},blocking(e,t,r){Rn.log(`Current connection od db version ${e} is blocking connection to version ${t}.`,r),i.close()}});return i}},Js=(Bs.openServiceWorkerCallbacksDatabaseConnection.bind(Bs),Bs.openAutomationJourneysDatabaseConnection.bind(Bs),class e{constructor(e){Cn(this,$,void 0),kn(this,$,e)}static create(t){return new e(t)}validate(e){return Object.entries(En(this,$)).reduce(((t,[r,i])=>{if(false===t)return t;if(null==e[r]&&i._isOptional)return t;else return i.call(e,e[r])}),true)}stringifySchemaShape(){var t;return Dn(t=e,G,q).call(t,En(this,$))}trim(e,t=En(this,$)){var r;const i={};for(const[n,o]of Object.entries(e))if("object"==typeof o&&null!==o){if(n in t){const e=null==(r=t[n])?void 0:r.valueShape;if(Array.isArray(o))if(e)i[n]=o.map((t=>this.trim(t,e)));else i[n]=o;else i[n]=this.trim(o,e)}}else if(n in t)i[n]=o;return i}static string(){return Gs((e=>"string"==typeof e),(()=>"string"))}static number(){return Gs((e=>"number"==typeof e),(()=>"number"))}static boolean(){return Gs((e=>"boolean"==typeof e),(()=>"boolean"))}static dateString(){return Gs((e=>{if("string"!=typeof e)return false;else return!Number.isNaN(new Date(e).getTime())}),(()=>"date string"))}static object(t){return Gs((r=>{if(!t||"object"!=typeof t)return false;else return e.create(t).validate(r)}),(()=>Dn(this,G,q).call(this,t)),t)}static array(t){return Gs((r=>{if(!Array.isArray(r))return false;if("function"==typeof t)return r.every((e=>t(e)));const i=e.create(t);return r.every((e=>i.validate(e)))}),(()=>`[${Dn(this,G,q).call(this,t)}]`),"function"==typeof t?void 0:t)}});$=new WeakMap,G=new WeakSet,q=e=>{const t={};if("function"==typeof e)return e.getValueType();else for(const[r,i]of Object.entries(e))t[r]=i.getValueType();try{return JSON.stringify(t).replaceAll('\\"','"')}catch{return"Failed to parse validation shape"}},Cn(Js,G);let $s=Js;function Gs(e,t,r){if(e.optional=()=>(e._isOptional=true,e),e.getValueType=t,r)e.valueShape=r;return e}class qs extends Error{constructor(e,t){super(e),this.code=t,Object.setPrototypeOf(this,qs.prototype)}static createShopIdMismatchException(e,t){return new qs(`Shop id mismatch: shopId from event: ${e}, shopId already in journey: ${t}`,1)}static createInvalidEventException(e){return new qs(`Unable to replace event with ID ${e}: invalid event`,4)}static createNoShopDataProvidedInEventException(e){return new qs(`No shop data provided in event with id: ${e}`,2)}static createInvalidReplacementEventIdException(e){return new qs(`Unable to replace event with ID ${e} with newest event: specifier identifier not found in array`,3)}}const zs=8;z=new WeakSet,H=function(e){Dn(this,ae,ce).call(this,e),this.products||=[];const t=this.products.find((t=>t.data.product.id===e.data.product.id));if(t)Dn(this,ie,ne).call(this,t.eventId,e,this.products);else Dn(this,te,re).call(this,e,this.products);this.shopId||=e.data.shop.id},K=new WeakSet,X=function(e){Dn(this,ae,ce).call(this,e),this.categories||=[];const t=this.categories.find((t=>t.data.id===e.data.id));if(t)Dn(this,ie,ne).call(this,t.eventId,e,this.categories);else Dn(this,te,re).call(this,e,this.categories);this.shopId||=e.data.shop.id},Y=new WeakSet,Z=function(e){Dn(this,ae,ce).call(this,e),this.products||=[];const t=this.products.find((t=>t.data.product.id===e.data.product.id));if(t)Dn(this,ie,ne).call(this,t.eventId,e,this.products);else Dn(this,te,re).call(this,e,this.products);this.shopId||=e.data.shop.id},Q=new WeakSet,ee=function(e){var t;Dn(this,ae,ce).call(this,e),this.products||=[];const r=null==(t=this.products.find((t=>t.data.product.id===e.data.product.id)))?void 0:t.eventId;if(r)Dn(this,oe,se).call(this,r,this.products)},te=new WeakSet,re=(e,t)=>{if(!t.some((t=>t.eventId===e.eventId)))if(zs>t.length)t.push(e);else t.sort(((e,t)=>new Date(e.occurredOn).getTime()-new Date(t.occurredOn).getTime())),t.shift(),t.push(e)},ie=new WeakSet,ne=(e,t,r)=>{const i=r.findIndex((t=>t.eventId===e));if(0>i)throw qs.createInvalidReplacementEventIdException(e);r.splice(i,1,t)},oe=new WeakSet,se=(e,t)=>{const r=t.findIndex((t=>t.eventId===e));if(r>=-1)t.splice(r,1)},ae=new WeakSet,ce=function(e){var t,r;const i=e.eventType===Xn.ViewCategory;if(e.eventType===Xn.ViewItem||e.eventType===Xn.LikeItem||e.eventType===Xn.UnlikeItem){if(!(null==(t=e.data.shop)?void 0:t.id))throw qs.createNoShopDataProvidedInEventException(e.eventId);if(!e.data.product.id)throw qs.createInvalidEventException(e.eventId);if(this.shopId&&e.data.shop.id!==this.shopId)throw qs.createShopIdMismatchException(e.data.shop.id,this.shopId)}else if(i){if(!(null==(r=e.data.shop)?void 0:r.id))throw qs.createNoShopDataProvidedInEventException(e.eventId);if(this.shopId&&e.data.shop.id!==this.shopId)throw qs.createShopIdMismatchException(e.data.shop.id,this.shopId);if(!e.data.id)throw qs.createInvalidEventException(e.eventId)}};let Hs=class e{constructor({categories:e,shopId:t,products:r}){Cn(this,z),Cn(this,K),Cn(this,Y),Cn(this,Q),Cn(this,te),Cn(this,ie),Cn(this,oe),Cn(this,ae),this.products=[],this.categories=[],this.shopId=t,this.products=r||[],this.categories=e||[]}static create(t={}){return new e(t)}addParamFromEvent(e){switch(e.eventType){case Xn.ViewItem:Dn(this,z,H).call(this,e);break;case Xn.ViewCategory:Dn(this,K,X).call(this,e);break;case Xn.LikeItem:Dn(this,Y,Z).call(this,e);break;case Xn.UnlikeItem:Dn(this,Q,ee).call(this,e);break;default:zn(e)}}toSerializedForApiJson(){const{categories:e,shopId:t,products:r}=this;return{shopId:t,product_id:r.map((e=>e.data.product.id)).filter(Boolean),category_id:e.map((e=>e.data.id)).filter(Boolean)}}toSerializedForDatabaseAutomationJourneyField(){if(!this.shopId||0===this.products.length&&0===this.categories.length)return{};else return{pass_through_params:{...this}}}};var Ks=(e=>(e["UuidHasBeenSet"]="grUuidHasBeenSet",e["PopupsRendererCustomUrl"]="grPopupsRendererCustomUrl",e))(Ks||{});class Xs{constructor(){Cn(this,ue,new Proxy({},{get(e,t){if(t in e)return e[t];else return e[t]=[],e[t]}}))}addEvent(e,t){En(this,ue)[e].push(t)}drainEvents(e){const t=En(this,ue)[e];return En(this,ue)[e]=[],t}getEvents(e){return En(this,ue)[e]}hasDelayedEvents(e){return En(this,ue)[e].length>0}}ue=new WeakMap,le=new WeakMap,de=new WeakMap;const Ys=new class{constructor(){Cn(this,le,{}),Cn(this,de,new Xs)}publish(e,...t){var r;if(null==(r=En(this,le)[e])?void 0:r.length)En(this,le)[e].forEach((r=>{r(...t),Rn.log(`Event ${e} published with arguments'`,...t)}));else En(this,de).addEvent(e,t)}subscribe(e,t,r={}){const{preventEventDraining:i,ignoreQueuedEvents:n}=r;if(!En(this,le)[e])En(this,le)[e]=[];if(En(this,de).hasDelayedEvents(e)&&!n)if(i)En(this,de).getEvents(e).forEach((e=>t(...e)));else En(this,de).drainEvents(e).forEach((e=>t(...e)));if(r.signal)r.signal.addEventListener("abort",(()=>{this.unsubscribe(e,t)}),{once:true});En(this,le)[e].push(t)}unsubscribe(e,t){var r;const i=null==(r=En(this,le)[e])?void 0:r.indexOf(t);if(i>-1)En(this,le)[e].splice(i,1)}removeListeners(e){delete En(this,le)[e]}};var Zs=(e=>(e["DeviceType"]="debug_device_type",e["Location"]="debug_location",e["VisitUrlPath"]="debug_visit_url_path",e["BrowserStorageLastActivityDate"]="debug_browser_storage_last_activity_date",e["NewVisitor"]="debug_new_visitor",e["HasUserVisitPage"]="debug_has_user_visit_page",e["Events"]="debug_events",e))(Zs||{});function Qs(){const e=e=>{const t=sessionStorage.getItem(e);if(t){if([Zs.DeviceType,Zs.VisitUrlPath,Zs.Location].includes(e))return t;if(e===Zs.BrowserStorageLastActivityDate){const e=new Date(t);return isNaN(e.getTime())?void 0:e}if([Zs.NewVisitor,Zs.HasUserVisitPage,Zs.Events].includes(e))try{return JSON.parse(t)}catch(r){Rn.error(`Invalid debug data for: ${e}`)}}};return{enabled:true,data:{[Zs.DeviceType]:e(Zs.DeviceType),[Zs.BrowserStorageLastActivityDate]:e(Zs.BrowserStorageLastActivityDate),[Zs.Location]:e(Zs.Location),[Zs.NewVisitor]:e(Zs.NewVisitor),[Zs.VisitUrlPath]:e(Zs.VisitUrlPath),[Zs.HasUserVisitPage]:e(Zs.HasUserVisitPage),[Zs.Events]:e(Zs.Events)}}}function ea(e,t,r){const i=pa.debugObject;pa.debugObject={...i,data:{...null==i?void 0:i.data,[e]:t}},sessionStorage.setItem(e,r||String(t))}function ta(e){var t,r;return null==(r=null==(t=pa.debugObject)?void 0:t.data)?void 0:r[e]}function ra(e,t){return pa.isDebug?t:e}pe=new WeakMap;const ia=new class{constructor(){Cn(this,pe,{[Xn.LikeItem]:[],[Xn.OrderPlaced]:[],[Xn.UnlikeItem]:[],[Xn.ViewCategory]:[],[Xn.ViewItem]:[],[Xn.WishlistItem]:[],[Xn.PageVisit]:[],[Xn.Popup]:[],[Xn.Cart]:[]})}getEvents(e){return Promise.resolve(En(this,pe)[e])}getAllEvents(){return Promise.resolve(Object.values(En(this,pe)).flat(1))}getAllECommerceEvents(){return Promise.resolve([...En(this,pe)[Xn.ViewItem],...En(this,pe)[Xn.ViewCategory],...En(this,pe)[Xn.LikeItem],...En(this,pe)[Xn.UnlikeItem],...En(this,pe)[Xn.WishlistItem],...En(this,pe)[Xn.OrderPlaced],...En(this,pe)[Xn.Cart]])}getAllPopupEvents(){return Promise.resolve([...En(this,pe)[Xn.Popup]])}saveEvent(e){return En(this,pe)[e.eventType].push(e),Promise.resolve()}};var na=(e=>(e["v2"]="v2",e["af"]="af",e["wp"]="wp",e["we"]="we",e["ec"]="ec",e))(na||{}),oa=(e=>(e["v2"]="GRV2",e["af"]="GRAF",e["wp"]="GRWP",e["we"]="GRWE",e["ec"]="GREC",e))(oa||{});const sa={[na.af]:"autoFunnel",[na.ec]:"ecommerce",[na.v2]:"tracking",[na.we]:"webEvents",[na.wp]:"webPush"};he=new WeakSet,me=e=>sa[e];const aa=new class{constructor(){Cn(this,he)}setScriptInitialized(e){const t=Dn(this,he,me).call(this,e);window.__grIntegrationConfig[t].isModuleInitialized=true}isScriptInitialized(e){var t,r;const i=Dn(this,he,me).call(this,e);return(null==(r=null==(t=null==window?void 0:window.__grIntegrationConfig)?void 0:t[i])?void 0:r.isModuleInitialized)??false}};var ca=(e=>(e["visitorUuid"]="gaVisitorUuid",e["visitorValuable"]="gaIsValuable",e["VisitorEmail"]="gaVisitorEId",e["VisitorResubscribed"]="gaVisitorResubscribed",e["NotificationConsentAcceptedFromPrompt"]="gaWpnConAcc",e["NotificationConsentCustomPromptRejectedDEPRECATED"]="gaWpnConRej-{promptId}",e["NotificationConsentCustomPromptRejected"]="gaWpnConRej-promptId",e))(ca||{}),ua=(e=>(e[e["OneYear"]=31536e6]="OneYear",e[e["TwoWeeks"]=12096e5]="TwoWeeks",e[e["ThreeMonths"]=7776e6]="ThreeMonths",e))(ua||{});const la=new class{constructor(){this.timer=Date.now()}getCurrentVisitOnPageTime(){return Date.now()-this.timer}resetTimer(){this.timer=Date.now()}};we=new WeakMap,fe=new WeakMap,ge=new WeakMap,ve=new WeakSet,ye=function(){if(!En(this,we))window.history.pushState=new Proxy(window.history.pushState,{apply:(e,t,r)=>{const i=e.apply(t,r);for(const o of Array.from(En(this,fe)))try{o.apply(t,r)}catch(n){Rn.error("Push state callback error",n)}return i}}),window.history.replaceState=new Proxy(window.history.replaceState,{apply:(e,t,r)=>{const i=e.apply(t,r);for(const o of Array.from(En(this,ge)))try{o.apply(t,r)}catch(n){Rn.error("Replace state callback error",n)}return i}}),kn(this,we,true)};const da=new class{constructor(){Cn(this,ve),Cn(this,we,false),Cn(this,fe,new Set),Cn(this,ge,new Set)}init(){Dn(this,ve,ye).call(this)}onPushState(e,t={}){var r;if(!(null==(r=t.signal)?void 0:r.aborted))if(En(this,fe).add(e),t.signal)t.signal.addEventListener("abort",(()=>{this.removePushStateListener(e)}),{once:true})}onReplaceState(e,t={}){var r;if(!(null==(r=t.signal)?void 0:r.aborted))if(En(this,ge).add(e),t.signal)t.signal.addEventListener("abort",(()=>{this.removeReplaceStateListener(e)}),{once:true})}removePushStateListener(e){En(this,fe).delete(e)}removeReplaceStateListener(e){En(this,ge).delete(e)}};da.init();const pa=new class{constructor(){this.scriptModuleManager=aa}initialize(e){const{xsid:t,grid:r,clientLatestGrid:i,domain:n,aid:o,useNOStorage:s,useBetterSubscriberIdentification:a,isServedFromCustomDomain:c,scriptsDomain:u,scriptsVersion:l,tracking:d,isDebugMode:p,uuuid:h}=e;if(p)On.startDebug();window.__grIntegrationConfig=window.__grIntegrationConfig||{cData:{aid:o,grid:r,domain:n,useNOStorage:s,useBetterSubscriberIdentification:a,isServedFromCustomDomain:c,clientLatestGrid:i,uuuid:h},visitor:{email:null,eComId:null,xsid:t},tracking:{isModuleInitialized:false,isEnabled:d},webEvents:{isModuleInitialized:false,visitorApplicationEndpoint:null,automationJourneyGraphs:{},webPushActivePromptGraph:null,popupGraphs:{}},webPush:{isModuleInitialized:false,customSwPath:null,wpid:null,pushDomain:null,promptEndpoint:null},analyticsData:{scriptsDomain:u,scriptsVersion:l},ecommerce:{isModuleInitialized:false},autoFunnel:{isModuleInitialized:false},eventBus:Ys,temporaryEventsStorage:ia,vts:la,phs:da,debug:p?Qs():void 0,delayedScripts:{},scriptTypesInitialized:new Set}}canUseBackendForSubscriberIdentification(){return window.__grIntegrationConfig.cData.useBetterSubscriberIdentification}getUserAid(){return window.__grIntegrationConfig.cData.aid}getClientLatestGrid(){return window.__grIntegrationConfig.cData.clientLatestGrid}getVisitorUuid(){return Ln(ca.visitorUuid)}getUserAnalyticsDomain(){return window.__grIntegrationConfig.cData.domain}getUserUuid(){return window.__grIntegrationConfig.cData.uuuid}enablePopupDevMode(){window.__grIntegrationConfig.setCustomPopupRendererUrl=e=>{window.sessionStorage.setItem(Ks.PopupsRendererCustomUrl,e)}}getPopupRendererCustomUrl(){return window.sessionStorage.getItem(Ks.PopupsRendererCustomUrl)}setCustomSwPath(e){if("string"!=typeof e)throw new Error("Path type must be string");if(!e.match(/gr_sw_main.js|service-worker\/service-worker.js$/))throw new Error("Invalid sw file name");window.__grIntegrationConfig.webPush.customSwPath=e}getCustomSwPath(){var e;return null==(e=window.__grIntegrationConfig)?void 0:e.webPush.customSwPath}isTrackingEnabled(){return window.__grIntegrationConfig.tracking.isEnabled}isTrackingScriptServedFromCustomDomain(){return window.__grIntegrationConfig.cData.isServedFromCustomDomain}set visitorEmail(e){window.__grIntegrationConfig.visitor.email=e}get visitorEmail(){return window.__grIntegrationConfig.visitor.email}get pushWpid(){return window.__grIntegrationConfig.webPush.wpid}set pushWpid(e){window.__grIntegrationConfig.webPush.wpid=e}set pushDomain(e){window.__grIntegrationConfig.webPush.pushDomain=e}get pushDomain(){return window.__grIntegrationConfig.webPush.pushDomain}set pushPromptEndpoint(e){window.__grIntegrationConfig.webPush.promptEndpoint=e}get pushPromptEndpoint(){return window.__grIntegrationConfig.webPush.promptEndpoint}get eventBus(){return window.__grIntegrationConfig.eventBus}get canUseBackendStorageForEvents(){return window.__grIntegrationConfig.cData.useNOStorage}get webConnectScriptCdnUrl(){return window.__grIntegrationConfig.analyticsData.scriptsDomain}get webConnectCurrentScriptsVersion(){return window.__grIntegrationConfig.analyticsData.scriptsVersion}get isDebug(){var e,t;return!!(null==(t=null==(e=window.__grIntegrationConfig)?void 0:e.debug)?void 0:t.enabled)}set debugObject(e){window.__grIntegrationConfig.debug=e}get debugObject(){var e;return null==(e=window.__grIntegrationConfig)?void 0:e.debug}get delayedScripts(){var e;return(null==(e=window.__grIntegrationConfig)?void 0:e.delayedScripts)||{}}set delayedScripts(e){window.__grIntegrationConfig.delayedScripts=e}set visitorApplicationEndpoint(e){window.__grIntegrationConfig.webEvents.visitorApplicationEndpoint=e}get visitorApplicationEndpoint(){return window.__grIntegrationConfig.webEvents.visitorApplicationEndpoint}get userEventsStorageApplicationUrl(){return window.__grIntegrationConfig.ecommerce.webEventsSearchApplicationEndpoint}set userEventsStorageApplicationUrl(e){window.__grIntegrationConfig.ecommerce.webEventsSearchApplicationEndpoint=e}get temporaryEventsStorage(){return window.__grIntegrationConfig.temporaryEventsStorage}get automationJourneyGraphs(){return window.__grIntegrationConfig.webEvents.automationJourneyGraphs}get webPushActivePromptGraph(){return window.__grIntegrationConfig.webEvents.webPushActivePromptGraph}set webPushActivePromptGraph(e){window.__grIntegrationConfig.webEvents.webPushActivePromptGraph=e}get popupGraphs(){return window.__grIntegrationConfig.webEvents.popupGraphs}get visitorXsid(){return window.__grIntegrationConfig.visitor.xsid}get visitorTimeService(){return window.__grIntegrationConfig.vts}get pageHistoryService(){return window.__grIntegrationConfig.phs}};var ha=(e=>(e["SetDomain"]="setDomain",e["SetListToken"]="setListToken",e["SetUserId"]="setUserId",e["SetEvent"]="setEvent",e["SetCookie"]="setCookie",e["SetAutoFunnelData"]="setAutoFunnelData",e["Push"]="push",e["SetCustomServiceWorkerPath"]="setCustomSwPath",e["ViewItem"]="viewItem",e["ViewCategory"]="viewCategory",e["LikeItem"]="likeItem",e["UnlikeItem"]="unlikeItem",e["WishListItem"]="wishlistItem",e["Purchase"]="orderPlaced",e["CartUpdate"]="cartUpdate",e["ShopifyAbandonedCart"]="shopifyAbandonedCart",e["SaveEvent"]="saveEvent",e["FlushEvents"]="flushEvents",e["SetUserDevice"]="setUserDevice",e["SetUserLocation"]="setUserLocation",e["SetVisitUrlPath"]="setVisitUrlPath",e["SetLastActivityDate"]="setLastActivityDate",e["SetIsNewVisitor"]="setIsNewVisitor",e["SetHasUserVisitPage"]="setHasUserVisitPage",e["SetRawEvent"]="setRawEvent",e["ImportScript"]="importScript",e["DelayScript"]="delayScript",e["InitScript"]="initScript",e))(ha||{}),ma=(e=>(e["UserEventSaved"]="userEventSaved",e["UserEventUpdated"]="userEventUpdated",e["UserECommerceEventMatchedByECommerceElement"]="userECommerceEventMatchedByElement",e["WebPushConsentAccepted"]="webPushConsentAccepted",e["WebPushCustomConsentRejected"]="webPushCustomConsentRejected",e["WebPushNativeConsentRejected"]="webPushNativeConsentRejected",e))(ma||{}),wa=(e=>(e["Show"]="show",e["Close"]="close",e["Submit"]="submit",e))(wa||{}),fa=(e=>(e["One"]="1.0",e))(fa||{}),ga=(e=>(e["Web"]="web",e["Mobile"]="mobile",e))(ga||{});const va=new class{encodeEmail(e){return btoa(e)}decode(e){return atob(e)}isEncodedString(e){try{return atob(e),true}catch{return false}}validateEmail(e){return/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/.test(e)}};class ya extends Error{constructor(e){super(e)}static create(...[e,t]){switch(e){case"email":return new ya(`Provided string ${t} is not valid email address`);default:zn(e)}}}class ba{constructor({e}={}){if(e)this.e=va.encodeEmail(e)}static createFromContextData(e){try{if(va.isEncodedString(e.e))e.e=va.decode(e.e);return ba.validate(e),new ba(e)}catch(t){if(t instanceof ya)return Rn.error(t),ba.createBlank();throw t}}static createBlank(){return new ba}static validate(e){if("e"in e&&!va.validateEmail(e.e))throw ya.create("email",e.e)}toJSON(){return{...this}}}class Sa{constructor(e){Cn(this,be,void 0),this.eventType=e,kn(this,be,null),this.eventId=null,this.aid=pa.getUserAid(),this.grid=pa.getClientLatestGrid(),this.time=pa.visitorTimeService.getCurrentVisitOnPageTime(),this.context=ba.createBlank(),this.uuid=pa.getVisitorUuid(),this.url=window.location.href,this.occurredOn=new Date,this.tags=[]}get externalUid(){return En(this,be)}toJSON(){return{eventId:this.eventId,aid:this.aid,grid:this.aid,uuid:this.uuid,externalUid:this.externalUid,context:this.context.toJSON(),time:this.time,url:this.url,tags:this.tags,eventType:this.eventType,occurredOn:this.occurredOn.toUTCString()}}toString({normalized:e}={}){if(e)return JSON.stringify(this.normalizeForExternalStorage());else return JSON.stringify(this.toJSON())}normalize(){const{eventId:e,...t}=this.toJSON();return t}getBaseNormalizedEvent(){return{version:fa.One,user_uuid:pa.getUserUuid(),time:this.time,tags:this.tags,occurred_on:this.occurredOn.toISOString(),url:this.url,app:{lang:us.getBrowserLanguage(),device:us.getDeviceType(),os:us.getUserOs()},channel:ga.Web,visitor:{uuid:this.uuid,external_id:this.externalUid,xsid:pa.visitorXsid}}}}be=new WeakMap;const Pa=class e{constructor(e){Cn(this,De),Cn(this,Ae),Cn(this,Se,void 0),Cn(this,Pe,void 0),this.node={},kn(this,Se,new AbortController),kn(this,Pe,false);const{pass_through_params:t,...r}=e;Object.assign(this,r),this.pass_through_params=Hs.create(e.pass_through_params||{})}static create(t,r={}){var i,n;if(!Dn(i=e,Ie,Ee).call(i,t))throw new Error("Automation journey data does not match required schema");const o=new e(t);if(!r.preventAttachingListeners)Dn(n=o,De,Te).call(n);if(t instanceof e)t.terminate();return o}static createBlank(t){var r,i;if(!Dn(r=e,Ce,ke).call(r,t))throw new Error("Automation journey data does not match required schema");const n=new e(t);return Dn(i=n,De,Te).call(i),n}updateJourneyData({node_entered_at:e,node:t,upstreamed_to:r}){this.node.uuid=t.uuid,this.upstreamed_to=r,this.node_entered_at=e}toSerializedDatabaseJSON(){const{pass_through_params:e,...t}=this;return structuredClone({...t,...e.toSerializedForDatabaseAutomationJourneyField()})}terminate(){En(this,Se).abort(),kn(this,Pe,true)}};Se=new WeakMap,Pe=new WeakMap,Ie=new WeakSet,Ee=e=>$s.create({journey:$s.object({uuid:$s.string()}),visitor:$s.object({uuid:$s.string()}),node:$s.object({uuid:$s.string()}),node_entered_at:$s.dateString(),upstreamed_to:$s.dateString().optional(),pass_through_params:$s.object({shopId:$s.string().optional(),product_id:$s.array($s.string()).optional(),category_id:$s.array($s.string()).optional()}).optional()}).validate(e),Ce=new WeakSet,ke=e=>$s.create({journey:$s.object({uuid:$s.string()}),visitor:$s.object({uuid:$s.string()})}).validate(e),De=new WeakSet,Te=function(){pa.eventBus.subscribe(ma.UserECommerceEventMatchedByECommerceElement,(async e=>{if(!En(this,Pe))Dn(this,Ae,Ne).call(this,e),await Ea.saveVisitorJourney(this)}),{signal:En(this,Se).signal})},Ae=new WeakSet,Ne=function(e){const t=e instanceof Sa?e.toJSON():e;switch(e.eventType){case Xn.ViewItem:case Xn.ViewCategory:case Xn.LikeItem:case Xn.UnlikeItem:this.pass_through_params.addParamFromEvent(t);break}},Cn(Pa,Ie),Cn(Pa,Ce);let Ia=Pa;const Ea=new class{async getVisitorJourneys(e){const t=(await Bs.openAutomationJourneysDatabaseConnection(Es)).transaction(ys.VisitorJourneys,"readonly"),r=t.objectStore(ys.VisitorJourneys).index(Ss.VisitorUuid),i=await r.getAll(e);return await t.done,i.map((e=>Ia.create(e)))}async saveVisitorJourney(e){const{journey:t,visitor:r}=e,i=(await Bs.openAutomationJourneysDatabaseConnection(Es)).transaction(ys.VisitorJourneys,"readwrite"),n=i.objectStore(ys.VisitorJourneys);await n.delete([t.uuid,r.uuid]),await n.add(e.toSerializedDatabaseJSON()),await i.done}async clearVisitorJourney(e){const{journey:t,visitor:r}=e,i=(await Bs.openAutomationJourneysDatabaseConnection(Es)).transaction(ys.VisitorJourneys,"readwrite"),n=i.objectStore(ys.VisitorJourneys);await n.delete([t.uuid,r.uuid]),await i.done}async getNodeEntryHistory(e,t){const r=(await Bs.openAutomationJourneysDatabaseConnection(Es)).transaction(ys.VisitorJourneysGraphHistory,"readonly"),i=r.objectStore(ys.VisitorJourneysGraphHistory),n=await i.getAll(Cs(e,t));return await r.done,n}async saveNodeHistoryEntry(e,t,r){const i=(await Bs.openAutomationJourneysDatabaseConnection(Es)).transaction(ys.VisitorJourneysGraphHistory,"readwrite"),n=i.objectStore(ys.VisitorJourneysGraphHistory);await n.delete(Cs(e,t)),await n.add({node:{uuid:e},visitor:{uuid:t},entered_at:r}),await i.done}},Ca=new class{constructor(){this.visitorFlow=[]}addEntry(e){this.visitorFlow.push(e)}hasElementBeenVisited(e){return!!this.visitorFlow.find((t=>t===e))}};Ue=new WeakMap,We=new WeakSet,Fe=function(e,t){if(0===t.length)return true;const{type:r}=En(this,Ue).recurrent;switch(r){case ao.OnceEveryAmountTime:return Dn(this,_e,Ve).call(this,t);case ao.EveryTime:return Dn(this,xe,Oe).call(this,t,e);default:zn(r)}},_e=new WeakSet,Ve=function(e){const t=e.sort(((e,t)=>Date.parse(t.entered_at)-Date.parse(e.entered_at))).at(0),{value:r,type:i}=En(this,Ue).recurrent;if(i!==ao.OnceEveryAmountTime)throw new Error("Invalid recurrent condition type");return Date.now()>Date.parse(t.entered_at)+r},xe=new WeakSet,Oe=function(e,t){var r;const{value:i}=En(this,Ue).recurrent;if(i)return true;if((null==(r=null==t?void 0:t.node)?void 0:r.uuid)===En(this,Ue).id&&!Ca.hasElementBeenVisited(En(this,Ue).id))return true;else return 0===(null==e?void 0:e.length)};let ka=class e{constructor({node:e}){Cn(this,We),Cn(this,_e),Cn(this,xe),Cn(this,Ue,void 0),kn(this,Ue,e)}static create(t){return new e(t)}async shouldProcessElementInFlow(e){const t=await Ea.getNodeEntryHistory(En(this,Ue).id,e.visitor.uuid);return Dn(this,We,Fe).call(this,e,t)}};class Da{constructor({id:e,externalId:t,properties:r,recurrent:i,upstream:n,context:o}){Cn(this,Re,void 0),this.context=null,kn(this,Re,ka.create({node:this})),this.id=e,this.externalId=t,this.recurrent=i,this.properties=r,this.upstream=n,this.context=o}get nodeTypeGroup(){var e,t;if(this.type===An.ReactSendToBackend)return Tn.BackendTransfer;else return null==(t=null==(e=this.type.match(/^(?[a-zA-Z]*)_.*/))?void 0:e.groups)?void 0:t.nodeGroupType}startUpstreamCalculation(e){this.upstreamAbortController=new AbortController,this.upstreamService=hs.create({upstreamData:this.upstream,journey:e,signal:this.upstreamAbortController.signal}),this.upstreamService.initVisitorEntry()}waitForUpstreamPassed(){return new Promise((e=>{if(this.upstream)if(this.upstreamService.hasUpstreamTimePassed)e(Symbol.for("upstreamPassed"));else this.upstreamService.on("upstreamPassed",(()=>{e(Symbol.for("upstreamPassed"))}),{once:true,signal:this.upstreamAbortController.signal})}))}cancelUpstreamToResolveWait(){this.upstreamAbortController.abort()}validateRecurrentConditionForJourney(e){return En(this,Re).shouldProcessElementInFlow(e)}shouldProcessHandler(){return!this.upstreamService.hasUpstreamTimePassed}}Re=new WeakMap;class Ta extends Da{constructor(){super(...arguments),this.leaveFalseTimeout=null}waitForDelayLeaveFalse(){return new Promise((e=>{const{leaveFalseDelay:t}=this.properties;if(t)this.leaveFalseTimeout=window.setTimeout(e,t)}))}cleanLeaveFalseTimeout(){if(this.leaveFalseTimeout)window.clearTimeout(this.leaveFalseTimeout),this.leaveFalseTimeout=null}}const Aa=100,Na=204;function Ua(e,t){const r=e.isTextResponse??(null==t?void 0:t.isTextResponse);return fetch(e,{...t,headers:{...null==t?void 0:t.headers,...(null==t?void 0:t.omitAidHeader)?{}:{[no.UserAid]:pa.getUserAid()}}}).then((async e=>{if(e.ok){if(e.status===Na)return;return r?e.text():e.json()}const t=await e.text();return Promise.reject({statusCode:e.status,message:t})}))}const Wa=new class{getVisitorData(){return Ua(new URL(`visitors/${pa.getUserAid()}/${Ln(ca.visitorUuid)}`,pa.getUserAnalyticsDomain()).href)}},Fa=1e3*60*60*24,_a=1e3;function Va(e){return new Promise((t=>{setTimeout(t,e)}))}function xa(e,t){const r=new Date(e+t*Fa),i=new Date(r.getFullYear(),r.getMonth(),r.getDate(),0,0,0);return Date.now()>=Date.parse(i.toString())}async function Oa(e,{maxAttempts:t=void 0,delay:r=_a,multiplyDelay:i=true,maxDelay:n=_a}={}){const o=async s=>{try{return await e()}catch(c){if(t&&s+1>t)throw c;const e=i?r*s:r;return 0,a=n&&e>n?n:e,new Promise((e=>{setTimeout((()=>e(o(s+1))),a)}))}var a};return o(1)}class Ra extends Error{constructor(e){super(e),Object.setPrototypeOf(this,new.target.prototype),this.name=this.constructor.name}}class La extends Ra{}const Ma=Symbol("DebugDeviceService");class ja extends cs{constructor(e){if(super(),new.target===ja&&e!==Ma)throw new Error(`Invalid ${new.target.name} constructor`)}getDeviceType(){const e=ta(Zs.DeviceType);if(!e)return super.getDeviceType();if(!Object.values(So).includes(e))return Rn.error("Incorrect debug device type. Check if device is correct. Instead of that we will use normal values"),super.getDeviceType();else return e}setDeviceType(e){ea(Zs.DeviceType,e)}}const Ba=new ja(Ma),Ja=Symbol("LocationService");Le=new WeakMap;let $a=class e{constructor(t){if(Cn(this,Le,null),new.target===e&&t!==Ja)throw new Error(`Invalid ${new.target.name} constructor`)}async getVisitorCountryCode(){const{domain:e}=window.__grIntegrationConfig.cData;if(!En(this,Le))kn(this,Le,await fetch(`${e}web-user-data/country`).then((e=>e.text())));return En(this,Le)}};const Ga=new $a(Ja),qa=Symbol("DebugLocationService");class za extends $a{constructor(e){if(super(),new.target===za&&e!==qa)throw new Error(`Invalid ${new.target.name} constructor`)}getVisitorCountryCode(){const e=ta(Zs.Location);if(!e)return super.getVisitorCountryCode();else return Promise.resolve(e)}setVisitorCountryCode(e){if("string"!=typeof e)return Rn.error("Incorrect debug country code value"),null;ea(Zs.Location,e)}}const Ha=new za(qa),Ka=400;class Xa extends Ra{constructor(){super("Invalid time properties")}}const Ya=new Map,Za=(e,t)=>{if(!Array.isArray(e))switch(typeof e){case"string":e=[e];break;case"undefined":e=[];break;default:throw new TypeError(`Expected '${t}' to be a string or an array, but got a type of '${typeof e}'`)}return e.filter((e=>{if("string"!=typeof e){if(void 0===e)return false;throw new TypeError(`Expected '${t}' to be an array of strings, but found a type of '${typeof e}' in the array`)}return true}))};function Qa(e,t,r){return((e,t,r,i)=>{if(e=Za(e,"inputs"),0===(t=Za(t,"patterns")).length)return[];t=t.map((e=>((e,t)=>{t={caseSensitive:false,...t};const r=e+JSON.stringify(t);if(Ya.has(r))return Ya.get(r);const i="!"===e[0];if(i)e=e.slice(1);e=(e=>{if("string"!=typeof e)throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")})(e).replace(/\\\*/g,"[\\s\\S]*");const n=new RegExp(`^${e}$`,t.caseSensitive?"":"i");return n.negated=i,Ya.set(r,n),n})(e,r)));const{allPatterns:n}=r||{},o=[];for(const s of e){let e;const r=[...t].fill(false);for(const[i,n]of t.entries())if(n.test(s))if(r[i]=true,e=!n.negated,!e)break;if(!(false===e||void 0===e&&t.some((e=>!e.negated))||n&&r.some(((e,r)=>!e&&!t[r].negated))))if(o.push(s),i)break}return o})(e,t,r,true).length>0}class ec extends Ra{constructor(){super("Failed to parse data from JSON string")}}class tc extends Sa{constructor(e,t,r=ba.createBlank()){super(Xn.Popup),this.popupEvent=e,this.popupId=t,this.context=r}toJSON(){return{...super.toJSON(),popupId:this.popupId,popupEvent:this.popupEvent}}normalizeForExternalStorage(){return{...this.getBaseNormalizedEvent(),event:{version:"1.0",name:Xn.Popup}}}}class rc extends Sa{toJSON(){return{...super.toJSON(),data:this.data}}normalizeForExternalStorage(){const e=this.getBaseNormalizedEvent();return{...e,event:{version:this.eventVersion,name:this.eventType,data:this.data},visitor:{uuid:e.visitor.uuid,external_id:e.visitor.external_id}}}}class ic extends Sa{constructor(e){super(Xn.ShopifyAbandonedCart),this.data=e}toJSON(){return{...super.toJSON(),data:this.data}}normalizeForExternalStorage(){return{...this.getBaseNormalizedEvent(),event:{version:"1.0",name:Xn.ShopifyAbandonedCart,data:this.data}}}}const nc={id:$s.string(),sku:$s.string().optional(),name:$s.string().optional(),vendor:$s.string().optional(),price:$s.string().optional(),currency:$s.string().optional()},oc=$s.array({id:$s.string(),name:$s.string().optional()}).optional(),sc={id:$s.string()},ac={shop:$s.object({...sc}).optional(),product:$s.object({...nc}),categories:oc},cc={product:$s.object({...nc}),categories:oc,quantity:$s.number()},uc=$s.create({...ac}),lc=$s.create({shop:$s.object({...sc}).optional(),id:$s.string(),name:$s.string().optional()}),dc=$s.create({...ac}),pc=$s.create({...ac}),hc=$s.create({...ac}),mc=$s.create({orderId:$s.string(),cartId:$s.string().optional(),price:$s.number(),currency:$s.string(),products:$s.array(cc)}),wc=$s.create({price:$s.number(),cartId:$s.string(),cartUrl:$s.string(),currency:$s.string(),products:$s.array(cc)});class fc extends Error{constructor(e){super(`Data doesn't match required schema: ${e}`)}}class gc extends Sa{constructor(e=ba.createBlank()){super(Xn.PageVisit),this.context=e}normalizeForExternalStorage(){return{...this.getBaseNormalizedEvent(),event:{version:"1.0",name:this.eventType}}}}const vc={[Xn.ViewItem]:uc,[Xn.ViewCategory]:lc,[Xn.WishlistItem]:dc,[Xn.LikeItem]:pc,[Xn.UnlikeItem]:hc,[Xn.OrderPlaced]:mc,[Xn.Cart]:wc},yc={[Xn.ViewItem]:class extends rc{constructor(e,t){super(Xn.ViewItem),this.data=e,this.context=t,this.eventVersion="1.0"}normalizeForExternalStorage(){const e=super.normalizeForExternalStorage();return e.event.data.product.price=parseFloat(e.event.data.product.price),e.time=pa.visitorTimeService.getCurrentVisitOnPageTime(),e}},[Xn.ViewCategory]:class extends rc{constructor(e,t){super(Xn.ViewCategory),this.data=e,this.context=t,this.eventVersion="1.0"}normalizeForExternalStorage(){const e=super.normalizeForExternalStorage();return e.time=pa.visitorTimeService.getCurrentVisitOnPageTime(),e}},[Xn.WishlistItem]:class extends rc{constructor(e,t){super(Xn.WishlistItem),this.data=e,this.context=t,this.eventVersion="1.0"}},[Xn.LikeItem]:class extends rc{constructor(e,t){super(Xn.LikeItem),this.data=e,this.context=t,this.eventVersion="1.0"}normalizeForExternalStorage(){const e=super.normalizeForExternalStorage();return e.event.data.product.price=parseFloat(e.event.data.product.price),e}},[Xn.UnlikeItem]:class extends rc{constructor(e,t){super(Xn.UnlikeItem),this.data=e,this.context=t,this.eventVersion="1.0"}normalizeForExternalStorage(){const e=super.normalizeForExternalStorage();return e.event.data.product.price=parseFloat(e.event.data.product.price),e}},[Xn.OrderPlaced]:class extends rc{constructor(e,t){super(Xn.OrderPlaced),this.data=e,this.context=t,this.eventVersion="1.0"}normalizeForExternalStorage(){const e=super.normalizeForExternalStorage();return e.event.data.products=e.event.data.products.map((e=>({...e,product:{...e.product,price:parseFloat(e.product.price)}}))),e}},[Xn.Cart]:class extends rc{constructor(e,t){super(Xn.Cart),this.data=e,this.context=t,this.eventVersion="1.0"}normalizeForExternalStorage(){const e=super.normalizeForExternalStorage();return e.event.data.products=e.event.data.products.map((e=>({...e,product:{...e.product,price:parseFloat(e.product.price)}}))),e}}},bc=class e{static getPageVisitEvent(){return new gc}static getPopupEvent({popupId:e,popupEventName:t}){return new tc(t,e)}static getPopupSubmitEvent(e){return new tc(wa.Submit,e)}static getPopupShowEvent(e){return new tc(wa.Show,e)}static getPopupCloseEvent(e){return new tc(wa.Close,e)}static getViewItemEvent(t,r){var i;return Dn(i=e,Me,je).call(i,Xn.ViewItem,t,r)}static getWishlistItemEvent(t,r){var i;return Dn(i=e,Me,je).call(i,Xn.WishlistItem,t,r)}static getLikeItemEvent(t,r){var i;return Dn(i=e,Me,je).call(i,Xn.LikeItem,t,r)}static getUnlikeItemEvent(t,r){var i;return Dn(i=e,Me,je).call(i,Xn.UnlikeItem,t,r)}static getViewCategoryEvent(t,r){var i;return Dn(i=e,Me,je).call(i,Xn.ViewCategory,t,r)}static getOrderPlacedEvent(t,r){var i;return Dn(i=e,Me,je).call(i,Xn.OrderPlaced,t,r)}static getCartUpdateEvent(t,r){var i;return Dn(i=e,Me,je).call(i,Xn.Cart,t,r)}static getShopifyIntegrationAbandonedCartEvent(e){try{return(e=>{if("object"!=typeof e||null===e)throw new Qn("Invalid data parameter type");else{const t=Object.entries(eo),r=Object.keys(e);if(!to.every((e=>r.includes(e))))throw new Qn("Lack of required parameters");if(!t.every((([t,r])=>!e[t]||typeof e[t]===r)))throw new Qn("Properties have invalid type")}return true})(e),new ic((t=e,r=Object.keys(eo),Object.entries(t).reduce(((e,[t,i])=>{if(r.includes(t))e[t]=i;return e}),{})))}catch(i){return Rn.error(i),null}var t,r}};Me=new WeakSet,je=(e,t,r)=>{const i=vc[e],n=yc[e];if(!i||!n)throw new Error("Event type not supported in event factory");if(!i.validate(t))throw new fc(i.stringifySchemaShape());return new n(i.trim(t),r)},Cn(bc,Me);let Sc=bc;const Pc=Symbol("StorageService");class Ic{constructor(e){if(new.target===Ic&&e!==Pc)throw new Error(`Invalid ${new.target.name} constructor`)}async isNewVisitor(){return!(await this.getLastActivityDate())}getLastActivityDate(){return this.getLastActivityDateFromBrowserStorage()}getUserActivityDataFromBrowserStorage(){const e=Ln(ca.visitorUuid),t=localStorage.getItem("gaLocalStorageVisitKey");let r;try{r=JSON.parse(t)}catch{throw new ec}if(null==r?void 0:r[e])return r[e];else return{lastActivity:null,totalCount:1}}async getLastActivityDateFromBrowserStorage(){const{lastActivity:e}=await this.getUserActivityDataFromBrowserStorage();if(e)return Promise.resolve(new Date(e));else return null}saveUserActivity(){pa.eventBus.publish(ha.SaveEvent,{sendToBackend:true,saveToLocal:false},ba.createBlank(),Xn.PageVisit,null),this.saveUserActivityToBrowserStorage()}saveUserActivityToBrowserStorage(){const e=Ln(ca.visitorUuid),{totalCount:t}=this.getUserActivityDataFromBrowserStorage(),r={[e]:{lastActivity:Sc.getPageVisitEvent().occurredOn.toUTCString(),totalCount:t+1}};try{window.localStorage.setItem("gaLocalStorageVisitKey",JSON.stringify(r))}catch{throw new ec}}}const Ec=new Ic(Pc),Cc=Symbol("DebugStorageService");class kc extends Ic{constructor(e){if(super(),new.target===kc&&e!==Cc)throw new Error(`Invalid ${new.target.name} constructor`)}getLastActivityDate(){var e;const t=ta(Zs.BrowserStorageLastActivityDate);if(isNaN(null==(e=null==t?void 0:t.getTime)?void 0:e.call(t)))return super.getLastActivityDate();else return Promise.resolve(t)}setLastActivityDate(e){const t=new Date(e);if(isNaN(t.getTime()))return Rn.error("Incorrect dateString for last activity date. Try again with isoString."),null;ea(Zs.BrowserStorageLastActivityDate,t,t.toISOString())}isNewVisitor(){const e=ta(Zs.NewVisitor);if(void 0===e)return super.isNewVisitor();else return Promise.resolve(e)}setIsNewVisitor(e){ea(Zs.NewVisitor,e,String(e))}}const Dc=new kc(Cc);function Tc(){return ra(Ec,Dc)}var Ac=(e=>(e["Always"]="always",e["OnceEveryDays"]="xDays",e["OncePerTimeAmount"]="xTimeAmount",e["Session"]="everySession",e["LessThanXTimes"]="lessThanXTimes",e["ExactlyXTimes"]="exactlyXTimes",e["MoreThanXTimes"]="moreThanXTimes",e))(Ac||{});const Nc=Symbol("SessionService");class Uc{constructor(e){if(new.target===Uc&&e!==Nc)throw new Error(`Invalid ${new.target.name} constructor`)}hasUserVisitedPage(){return this.getSessionVisitData().count>1}saveUserVisit(){const e=this.getSessionVisitData()||{count:0};sessionStorage.setItem("gaUserPageSessionVisit",JSON.stringify({...e,count:e.count+1}))}getSessionVisitData(){return JSON.parse(sessionStorage.getItem("gaUserPageSessionVisit"))}}const Wc=new Uc(Nc),Fc=Symbol("DebugSessionService");class _c extends Uc{constructor(e){if(super(),new.target===_c&&e!==Fc)throw new Error(`Invalid ${new.target.name} constructor`)}hasUserVisitedPage(){const e=ta(Zs.HasUserVisitPage);if(void 0===e)return super.hasUserVisitedPage();else return e}setHasUserVisitedPage(e){ea(Zs.HasUserVisitPage,e)}}const Vc=new _c(Fc);function xc(){return ra(Wc,Vc)}Be=new WeakSet,Je=async(e,t=0)=>{if(e===Ac.Session)return!xc().hasUserVisitedPage();if(e===Ac.OnceEveryDays){const e=await Tc().getLastActivityDate();if(e)return xa(e.getTime(),t)}if(e===Ac.OncePerTimeAmount){const e=await Tc().getLastActivityDate();if(e)return r=e.getTime(),i=t,Date.now()>=r+i}var r,i;const{totalCount:n}=Tc().getUserActivityDataFromBrowserStorage();if(e===Ac.ExactlyXTimes)return t===n;if(e===Ac.LessThanXTimes)return t>n;if(e===Ac.MoreThanXTimes)return n>t;else return true},$e=new WeakSet,Ge=async e=>{const t=await Tc().isNewVisitor();switch(e){case Po.New:return t;case Po.Returning:return!t;default:return true}},qe=new WeakSet,ze=function(e="*"){const t=window.location.pathname;return Dn(this,He,Ke).call(this,e,t)},He=new WeakSet,Ke=(e,t)=>Qa(t,e);const Oc=new class{constructor(){Cn(this,Be),Cn(this,$e),Cn(this,qe),Cn(this,He)}async validateVisitorVisits({frequency:e,visitorType:t,frequencyDaysNumber:r,urlPath:i}){if(!Dn(this,qe,ze).call(this,i))return false;const[n,o]=await Promise.all([Dn(this,Be,Je).call(this,e,r),Dn(this,$e,Ge).call(this,t)]);return n&&o}},Rc=Symbol("BrowserEventsStorageService");Xe=new WeakSet,Ye=(e,t,r)=>{!(e=>{if(!e.objectStoreNames.contains(gs.UserActivityEvents))try{const t=e.createObjectStore(gs.UserActivityEvents,{keyPath:"id",autoIncrement:true});t.createIndex(vs.EventType,"eventType",{unique:false}),t.createIndex(vs.VisitorUuid,"uuid",{unique:false}),t.createIndex(vs.EventTypeWithVisitor,["eventType","uuid"])}catch(t){Rn.error("Error while initializing/upgrading database",t)}})(r)};let Lc=class e{constructor(t){if(Cn(this,Xe),new.target===e&&t!==Rc)throw new Error(`Invalid ${new.target.name} constructor`)}async saveEvent(e){const t=e instanceof Sa?e.normalize():e;try{const e=(await Bs.openEventsDatabaseConnection(Dn(this,Xe,Ye))).transaction(gs.UserActivityEvents,"readwrite"),r=e.objectStore(gs.UserActivityEvents),i=await r.add(t);return await e.done,Rn.log(`Event with created id: ${i} saved to database`,t),i}catch(r){Rn.error("Error while saving event to database",r)}}async getEvents(e){const t=Ln(ca.visitorUuid);try{const r=(await Bs.openEventsDatabaseConnection(Dn(this,Xe,Ye))).transaction(gs.UserActivityEvents,"readwrite"),i=r.objectStore(gs.UserActivityEvents).index(vs.EventTypeWithVisitor),n=await i.getAll([e,t]);return await r.done,n.map((e=>{const{id:t,...r}=e;return{...r,eventId:String(t)}}))}catch(r){Rn.error("Error while reading from database",r)}}async getEventById(e){const t=Ln(ca.visitorUuid);try{const r=(await Bs.openEventsDatabaseConnection(Dn(this,Xe,Ye))).transaction(gs.UserActivityEvents,"readwrite"),i=r.objectStore(gs.UserActivityEvents),n=await i.get(e);if(await r.done,n&&n.uuid===t)return{...n,eventId:String(e)};else return null}catch(r){Rn.error("Error while reading from database",r)}}async updateEvent(e,t){const r=(await Bs.openEventsDatabaseConnection(Dn(this,Xe,Ye))).transaction(gs.UserActivityEvents,"readwrite").objectStore(gs.UserActivityEvents),i=await r.get(e);if(i){const e=$n(i,t);await r.put(e)}}async getPopupECommerceEvents(e){const t=Ln(ca.visitorUuid),r=(await Bs.openEventsDatabaseConnection(Dn(this,Xe,Ye))).transaction(gs.UserActivityEvents,"readwrite").store.index(vs.VisitorUuid),i=[];let n=await r.openCursor(IDBKeyRange.only(t));for(;n;){const{value:t}=n;if(e(t)){const{id:e,...r}=t;i.push({eventId:String(e),...r})}n=await n.continue()}return i}};const Mc=new Lc(Rc),jc=Symbol("DebugBrowserEventsStorageService");class Bc extends Lc{constructor(e){if(super(),new.target===Bc&&e!==jc)throw new Error(`Invalid ${new.target.name} constructor`)}async getPopupECommerceEvents(e){const t=ta(Zs.Events)||[];if(!t.length)return super.getPopupECommerceEvents(e);else return t.filter(e)}async getEvents(e){const t=Ln(ca.visitorUuid),r=ta(Zs.Events)||[];if(!r.length)return super.getEvents(e);else return r.filter((({eventType:r,uuid:i})=>r===e&&i===t))}async saveEvent(e){const t=e instanceof Sa?e.toJSON():e,r=[...ta(Zs.Events)||[],t];try{const e=JSON.stringify(r);return ea(Zs.Events,r,e),Math.random()}catch(i){Rn.error(`Can't parse new debug events. Try again.`)}}}const Jc=new Bc(jc);function $c(){return ra(Mc,Jc)}function Gc(e,t,r){return r.filter((r=>r.popupEvent===t&&r.popupId===e))}function qc(e,t){return Gc(e,wa.Show,t).length>0}function zc(e,t){var r;const i=Gc(e,wa.Show,t).sort(((e,t)=>Date.parse(t.occurredOn)-Date.parse(e.occurredOn)));if(!(null==(r=i[0])?void 0:r.occurredOn))return null;else return new Date(i[0].occurredOn)}function Hc(e,t){return Gc(e,wa.Close,t).length>0}function Kc(e,t){return Gc(e,wa.Submit,t).length>0}function Xc(e,t){return Gc(e,wa.Show,t).length}const Yc=new class{getStorage(){try{const e=localStorage.getItem("grPopupsServiceKey");return JSON.parse(e)}catch(e){Rn.error("Failed to get local storage data",e)}}getPopupEvents(){return $c().getEvents(Xn.Popup)}async getLastPopupImpression(e){return zc(e,await this.getPopupEvents())}async getPopupImpressionsAmount(e){return Xc(e,await this.getPopupEvents())}async hasPopupBeenClosedBefore(e){return Hc(e,await this.getPopupEvents())}async hasPopupBeenSeenInSession(e){return qc(e,await this.getPopupEvents())}async hasPopupBeenSubmittedBefore(e){return Kc(e,await this.getPopupEvents())}_getPopupEventsFromLocalStorage(){var e,t;return null==(t=null==(e=this.getStorage())?void 0:e.events)?void 0:t.filter((e=>e.popupEvent===wa.Submit||wa.Close||wa.Show))}registerPopupClose(e){return this.addEventToStorage(wa.Close,e)}registerPopupSubmit(e){return this.addEventToStorage(wa.Submit,e)}registerPopupView(e){return this.addEventToStorage(wa.Show,e)}async migrateData(){if(!localStorage.getItem("grPopupsMigration")){const e=this._getPopupEventsFromLocalStorage();if(e)e.forEach((e=>{this.addEventToStorage(e.popupEvent,e.popupId,true)})),localStorage.setItem("grPopupsServiceKey",JSON.stringify({})),localStorage.setItem("grPopupsMigration","true")}}addEventToStorage(e,t,r){return pa.eventBus.publish(ha.SaveEvent,{sendToBackend:false,preventRenotify:r},ba.createBlank(),Xn.Popup,{popupEventName:e,popupId:t}),Promise.resolve()}};class Zc{static sendJSON(e,t,r=true){const i=r?JSON.stringify({...JSON.parse(t),[no.UserAid]:pa.getUserAid()}):t;navigator.sendBeacon(e,new Blob([i],{type:"application/json"}))}}const Qc=[Xn.OrderPlaced,Xn.Cart,Xn.LikeItem,Xn.UnlikeItem,Xn.WishlistItem,Xn.ViewItem,Xn.ViewCategory],eu=[Xn.Cart,Xn.LikeItem,Xn.UnlikeItem,Xn.OrderPlaced,Xn.ViewCategory,Xn.ViewItem];Ze=new WeakSet,Qe=()=>new URL(`u/${pa.getUserUuid()}/e/${ga.Web}/handle/`,pa.userEventsStorageApplicationUrl).href;const tu=new class{constructor(){Cn(this,Ze)}async addPopupEventToStorage(e){throw new Error("Not implemented")}async getPopupActivityData(e){throw new Error("Not implemented")}async saveEventsToStorage(e){if(pa.userEventsStorageApplicationUrl&&pa.getUserUuid()){const t=e.filter((e=>Qc.includes(e.event.name)));if(t.length>0)Zc.sendJSON(Dn(this,Ze,Qe).call(this),JSON.stringify(t),false)}else Rn.error("Attempt to send web events to search was made without search application endpoint or uuuid!")}async sendEventsToMetricsInc(e){const t=e.filter((e=>eu.includes(e.event.name)));if(t.length>0){const e=JSON.stringify({events:t.map((e=>({eventType:e.event.name}))),url:window.location.origin}),r=new URL("/a/ue",pa.getUserAnalyticsDomain()).href;Zc.sendJSON(r,e)}}},ru=Symbol("PopupsService");class iu{constructor(e){if(new.target===iu&&e!==ru)throw new Error(`Invalid ${new.target.name} constructor`)}setGrid(e){this.grid=e}setAid(e){this.aid=e}async registerPopupClose(e){return this.addEventToStorage(Sc.getPopupCloseEvent(e))}async registerPopupSubmit(e){return this.addEventToStorage(Sc.getPopupSubmitEvent(e))}async registerPopupView(e){return this.addEventToStorage(Sc.getPopupShowEvent(e))}hasPopupBeenSeenInSession(e){return this.getPopupActivityData(e).then((e=>!!e.lastImpressionOccurredAt))}addEventToStorage(e){return tu.addPopupEventToStorage(e)}async getPopupActivityData(e){return tu.getPopupActivityData(e)}getLastPopupImpression(e){return this.getPopupActivityData(e).then((e=>new Date(e.lastImpressionOccurredAt)))}hasPopupBeenClosedBefore(e){return this.getPopupActivityData(e).then((e=>e.closes>0))}hasPopupBeenSubmittedBefore(e){return this.getPopupActivityData(e).then((e=>e.submits>0))}getPopupImpressionsAmount(e){return this.getPopupActivityData(e).then((e=>e.impressions))}}function nu(){return Yc}new iu(ru);const ou=Symbol("DebugPopupService");class su extends iu{constructor(e){if(super(),this.hasPopupBeenSeenInSession=e=>{const t=this.getAllEvents();return Promise.resolve(qc(e,t))},this.getLastPopupImpression=e=>{var t;const r=zc(e,this.getAllEvents());if(isNaN(null==(t=null==r?void 0:r.getTime)?void 0:t.call(r)))return nu().getLastPopupImpression(e);else return Promise.resolve(r)},this.hasPopupBeenClosedBefore=e=>{const t=this.getAllEvents();return Promise.resolve(Hc(e,t))},this.hasPopupBeenSubmittedBefore=e=>{const t=this.getAllEvents();return Promise.resolve(Kc(e,t))},this.getPopupImpressionsAmount=e=>{const t=this.getAllEvents();return Promise.resolve(Xc(e,t))},new.target===su&&e!==ou)throw new Error(`Invalid ${new.target.name} constructor`)}getAllEvents(){return ta(Zs.Events)||[]}}const au=new su(ou);function cu(){return ra(nu(),au)}const uu="https://us-wbe.gr-cdn.com/dynamic/gr-popups.js";var lu=(e=>(e["PopupShow"]="popupShow",e["PopupClose"]="popupClose",e))(lu||{});const du=new class extends Gn{notifyPopupShow(e){this.emit(lu.PopupShow,e)}notifyPopupClose(e){this.emit(lu.PopupClose,e)}};et=new WeakMap,tt=new WeakMap;const pu=new class extends Gn{constructor(){super(...arguments),Cn(this,et,false),Cn(this,tt,false)}attachPopupLibrary(){return new Promise(((e,t)=>{if(En(this,et))e();else if(En(this,tt))this.on("libraryAttachingFinished",e,{once:true});else{kn(this,tt,true);const r=document.createElement("script");r.src=pa.getPopupRendererCustomUrl()??uu,r.async=true,r.addEventListener("load",(()=>{kn(this,et,true),kn(this,tt,false),this.emit("libraryAttachingFinished"),e()}),{once:true}),r.addEventListener("error",t),document.head.appendChild(r)}}))}};rt=new WeakMap;const hu="https://",mu="http://",wu="www.",fu=/^(http:\/\/|https:\/\/)/;class gu{constructor(e){this.url=e,this.enhancedUrls=[]}static create(e){return new gu(decodeURI(e))}withSlash(){if(!(this.url.endsWith("*")||this.url.endsWith("+")||this.url.includes("?")||this.url.endsWith("/")))this.url=`${this.url}/`;return this}withLackOfProtocolAndWww(){if(!this.url.startsWith("*")&&!this.hasProtocolIncluded()&&!this.hasWwwPart())this.enhancedUrls=[...this.enhancedUrls,`${hu}${this.url}`,`${mu}${this.url}`,`${hu}${wu}${this.url}`,`${mu}${wu}${this.url}`];return this}withEnforcedProtocol(){if(!this.hasProtocolIncluded())this.enhancedUrls=[...this.enhancedUrls,`${hu}${this.url}`,`${mu}${this.url}`];return this}withDecodeSpecialChars(){return this.enhancedUrls=this.enhancedUrls.map((e=>decodeURI(e))),this}withLackOfWww(){if(this.url.startsWith("*"))return this;if(this.hasProtocolIncluded()&&!this.hasWwwPart())this.enhancedUrls=[...this.enhancedUrls,`${hu}${wu}${this.url.replace(fu,"")}`,`${mu}${wu}${this.url.replace(fu,"")}`];return this}withLackOfProtocol(){if(this.url.startsWith("*"))return this;if(!this.hasProtocolIncluded()&&this.hasWwwPart())this.enhancedUrls=[...this.enhancedUrls,`${hu}${this.url}`,`${mu}${this.url}`];return this}enhance(){return[...this.enhancedUrls,this.url]}hasProtocolIncluded(){return this.url.startsWith(hu)||this.url.startsWith(mu)}hasWwwPart(){return this.url.replace(/^(http:\/\/|https:\/\/)/,"").startsWith(wu)}}function vu(e,t){return(e=>e.map((e=>gu.create(e).withSlash().withLackOfProtocolAndWww().withLackOfProtocol().withLackOfWww().withDecodeSpecialChars().enhance())).flat(1))(t).some((t=>{const r=Array.from(t.matchAll(/[*+]/g));let i;if(r.length)i=r.reduce(((e,r,i,n)=>{var o;const s=[...e,yu(t.substring(((null==(o=n[i-1])?void 0:o.index)??-1)+1,r.index)),"*"===r[0]?".*":"."];if(i===n.length-1)s.push(yu(t.substring(r.index+1)));return s}),[]).join("");else i=yu(t);return new RegExp(`^${i}$`).test((e=>{if(!e.includes("?")&&!e.endsWith("/"))return`${decodeURI(e)}/`;else return decodeURI(e)})(e))}))}function yu(e){return e.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")}it=new WeakMap,nt=new WeakSet,ot=function(e,t,r,i="eq"){if(r.has(e))return Dn(this,st,at).call(this,t,r.get(e),i);else return false},st=new WeakSet,at=(e,t,r="eq")=>{switch(r){case"eq":return!!decodeURIComponent(t).match(new RegExp(`^${decodeURIComponent(e).replaceAll("*",".*").replaceAll("+",".")}$`));default:return zn(r),false}};let bu=class e{constructor({baseUrl:e,queryParamsSelectionRule:t,queryParams:r,path:i,currentUrl:n}){Cn(this,nt),Cn(this,st),Cn(this,it,(e=>{var t;const r=new URL(this.path||"",e),i=new URL(this.currentUrl);for(const[n,o]of Object.entries(this.queryParams||{}))r.searchParams.append(n,o.value);if(this.queryParams)if("all"===this.queryParamsSelectionRule){if(!Array.from(r.searchParams.entries()).every((([e,t])=>Dn(this,nt,ot).call(this,e,t,i.searchParams,this.queryParams[e].operator))))return false}else if(!Array.from(r.searchParams.entries()).some((([e,t])=>Dn(this,nt,ot).call(this,e,t,i.searchParams,this.queryParams[e].operator))))return false;if(this.path)if(!Dn(this,st,at).call(this,r.pathname,i.pathname))return false;return Dn(this,st,at).call(this,null==(t=r.origin)?void 0:t.toLowerCase(),i.origin)})),this.baseUrl=e,this.path=i,this.queryParams=r,this.queryParamsSelectionRule=t,this.currentUrl=n}static create(t){return new e(t)}isOnCurrentUrl(){return gu.create(this.baseUrl).withEnforcedProtocol().withLackOfProtocolAndWww().withLackOfWww().withSlash().enhance().filter((e=>{try{return new URL(e),true}catch(t){return Rn.warn("Invalid URL",e),false}})).some(En(this,it))}};function Su(e){return e.sort(((e,t)=>Date.parse(t.occurredOn)-Date.parse(e.occurredOn)))[0].eventType===Xn.LikeItem}const Pu=1e3*60*60*24;function Iu(e,t,r){switch(r){case"equal":return e===t;case"lessThan":return t>e;case"moreThan":return e>t;default:zn(r)}}function Eu(e,t){var r;const{category:i,amount:n,product:o,price:s}=e.condition,{products:a,price:c}=t.data;let u=false;if(o){if("any"===o.id)u=true;if(a.some((e=>o.id.includes(e.product.id))))u=true}if(i){if("any"===i.id)u=true;if(a.some((e=>e.categories.some((e=>i.id.includes(e.id))))))u=true}if(n){const{value:e,condition:t}=n;if(Iu(a.reduce(((e,t)=>e+t.quantity),0),e,t))u=true}if(s){const{value:e,condition:t}=s;if(Iu(c,e,t))u=true}if(u)u=Cu(t,null==(r=e.settings)?void 0:r.date);return u}function Cu(e,t,{ignoreToDateInDateRange:r}={}){const{occurredOn:i}=e;if(t){const{name:e,value:n}=t;if(e===To.LastDays)return new Date(i).getTime()>Date.now()-n*Pu;if(e===To.DateRange){const{from:e,to:t}=n,o=new Date(i).getTime(),s=!e||new Date(e).getTime()(e["EventsAmount"]="eventsAmount",e["EventsTimeSpent"]="eventsTimeSpent",e))(_u||{}),Vu=(e=>(e["Or"]="or",e["And"]="and",e))(Vu||{});async function xu(e,t,r){let i=await $c().getEvents(e)||[];if(r||t)i=i.filter((e=>{const i=Date.parse(e.occurredOn);return!(r&&i>r||t&&t>i)}));return i}var Ou=(e=>(e["LessThan"]="lt",e["LessThanOrEqual"]="lte",e["Equal"]="eq",e["GreaterThanOrEqual"]="gte",e["GreaterThan"]="gt",e))(Ou||{});async function Ru({pastEventsCheckFn:e,rule:t,event:r,eventTypes:i}){const{totalEventsDuration:n,timeTo:o,timeFrom:s}=t;let a;if(r)a=(await xu(r.eventType,s,o)).filter((e=>e.eventId!==r.eventId));else if(i)a=(await Promise.all(i.map((e=>xu(e,s,o))))).flat();return a=await(async t=>{const r=await Promise.all(t.map((t=>e(t))));return t.filter(((e,t)=>r[t]))})(a),a.reduce(((e,t)=>e+t.time),(null==r?void 0:r.time)||0)>=n}ct=new WeakSet,ut=async({eventTypes:e,pastEventsCheckFn:t,rule:r,event:i})=>{switch(r.type){case _u.EventsAmount:return(async({pastEventsCheckFn:e,rule:t,event:r,eventTypes:i})=>{const{amount:n,timeTo:o,timeFrom:s,comparisonOperator:a="gte"}=t;let c;if(r)c=await xu(r.eventType,s,o);else if(i)c=(await Promise.all(i.map((e=>xu(e,s,o))))).flat();else throw new Error("Event or event types not provided");const u=c.filter((e=>e.eventId!==(null==r?void 0:r.eventId))).map((t=>e(t))),l=(await Promise.all(u)).filter(Boolean).length+(r?1:0);switch(a){case"eq":return l===n;case"gt":return l>n;case"lt":return n>l;case"gte":return l>=n;case"lte":return n>=l;default:zn(a)}})({event:i,rule:r,pastEventsCheckFn:t,eventTypes:e});case _u.EventsTimeSpent:{const n=Array.isArray(e)&&(null==e?void 0:e.every((e=>e===Xn.ViewItem||e===Xn.ViewCategory))),o=i&&(i.eventType===Xn.ViewItem||i.eventType===Xn.ViewCategory);if(n||o)return Ru({event:i,eventTypes:e,rule:r,pastEventsCheckFn:t});throw new Error("Time spent modifier can be used only with view item or view category events")}default:zn(r)}};const Lu=new class{constructor(){Cn(this,ct)}async checkECommerceEventModificators({eventTypes:e,modificators:t,pastEventsCheckFn:r,event:i}){const{separator:n,rules:o}=t,s=o.map((t=>Dn(this,ct,ut).call(this,{rule:t,event:i,pastEventsCheckFn:r,eventTypes:e})));if(n===Vu.And)return Promise.all(s).then((e=>e.every((e=>e))));else if(n===Vu.Or)return Promise.all(s).then((e=>e.some((e=>e))))}};var Mu=(e=>(e["Popup"]="popup",e["Automation"]="automation",e))(Mu||{});async function ju(e,t){const{amount:r,value:i,product:n,category:o}=e,{price:s,products:a}=t.data;if(r){const{condition:e,value:t}=r,i=a.reduce(((e,t)=>e+t.quantity),0);switch(e){case"equal":return i===t;case"lessThan":return t>i;case"moreThan":return i>t}}if(i){const{condition:e,value:t}=i;switch(e){case"equal":return s===t;case"lessThan":return t>s;case"moreThan":return s>t}}if(n){const{id:e}=n;if("any"===e)return true;else if(Array.isArray(e))return a.some((t=>e.includes(t.product.id)))}if(o){const{id:e}=o;if("any"===e)return true;else if(Array.isArray(e))return a.some((t=>{const{categories:r}=t;return r.some((t=>e.includes(t.id)))}))}throw new Error("Unknown condition in order placed ecommerce activity node condition")}async function Bu(e,t){const{data:r}=t,{modifiers:i,...n}=e,{id:o,category:s}=n;let a=false;if("any"===o)a=true;else if(Array.isArray(o))a=o.includes(r.product.id);else if("any"===s)a=r.categories.length>0;else if(Array.isArray(s))a=s.some((e=>{var t;return null==(t=r.categories)?void 0:t.find((t=>t.id===e))}));if(a&&i)return pa.eventBus.publish(ma.UserECommerceEventMatchedByECommerceElement,t),Lu.checkECommerceEventModificators({event:t,modificators:i,pastEventsCheckFn(e){return Bu(n,e)}});else return a}async function Ju(e,t){const{data:r}=t,{modifiers:i,...n}=e,{id:o}=n;let s=false;if("any"===o)s=true;else if(Array.isArray(o))s=o.includes(r.id);if(s&&i)return pa.eventBus.publish(ma.UserECommerceEventMatchedByECommerceElement,t),Lu.checkECommerceEventModificators({event:t,modificators:i,pastEventsCheckFn(e){return Ju(n,e)}});else return s}const $u=new Map;lt=new WeakMap,dt=new WeakMap,pt=new WeakSet,ht=async function(e){const{conditions:t,separator:r="or"}=this.properties;if("or"===r){const r=t.map((t=>Dn(this,mt,wt).call(this,t,e))),i=await Promise.race(r);if(i)Dn(this,vt,yt).call(this,e.eventId);return i}else if("and"===r){let r;for(const i of t)if(await Dn(this,mt,wt).call(this,i,e))r=i;if(r)return En(this,dt).push(r.conditionId),Dn(this,vt,yt).call(this,e.eventId),this.properties.conditions.every((e=>En(this,dt).includes(e.conditionId)))}else zn(r)},mt=new WeakSet,wt=(e,t)=>{const{product:r,category:i,likeProduct:n,orderPlaced:o,cartUpdate:s}=e;if(r&&Au(t))return Bu(r,t);if(i&&Tu(t))return Ju(i,t);if(n&&Nu(t))return(async(e,t)=>{const{product:r}=e;let i=false;if("any"===r.id)i=true;else if(Array.isArray(r.id))i=r.id.includes(t.data.product.id);if(i)pa.eventBus.publish(ma.UserECommerceEventMatchedByECommerceElement,t);return i})(n,t);if(o&&Uu(t))return(async(e,t)=>ju(e,t))(o,t);if(s&&Wu(t))return(async(e,t)=>ju(e,t))(s,t);else return Promise.resolve(false)},ft=new WeakSet,gt=async function(){if(En(this,lt)){const e=await pa.temporaryEventsStorage.getAllECommerceEvents();for(const t of e)if(!Dn(this,bt,St).call(this,t.eventId))if(await Dn(this,pt,ht).call(this,t))return true}else Rn.error("Could not find graph id for await ecommerce activity node",this.id)},vt=new WeakSet,yt=function(e){if($u.has(En(this,lt)))$u.get(En(this,lt)).add(e);else $u.set(En(this,lt),new Set([e]))},bt=new WeakSet,St=function(e){if($u.has(En(this,lt)))return $u.get(En(this,lt)).has(e);else return false};const Gu=new class{generateRandomUuid(){if("randomUUID"in window.crypto)return window.crypto.randomUUID();const e=window.URL.createObjectURL(new Blob([])),t=e.slice(-36);return window.URL.revokeObjectURL(e),t}},qu=1e3;Pt=new WeakMap,It=new WeakMap;class zu{constructor(e){this.resourceId=e}toJSON(){return{...this}}processBeforeExecution(){return Promise.resolve()}}class Hu extends zu{constructor(e,t,r){super(e),this.type=ms.Api,this.data=t,this.issuer=r}isSame(e){return e.issuer.id===this.issuer.id&&this.type===e.type}}class Ku extends zu{constructor(e,t,r){super(e),this.type=ms.Db,this.data=t,this.issuer=r}isSame(e){return e.issuer.id===this.issuer.id&&this.type===e.type}}class Xu extends Hu{constructor(){super(...arguments),this.type=ms.AutomationJourneyReactWebPushApi}processBeforeExecution(){const e=JSON.parse(this.data.body),t=e.transitions.at(-1),r=(new Date).toISOString();if(t.leave.occurred_at=r,t.entered)t.entered.occurred_at=r;return this.data.body=JSON.stringify(e),Promise.resolve()}}class Yu extends Ku{constructor(){super(...arguments),this.type=ms.AutomationJourneyReactWebPushDb}processBeforeExecution(){if("put"===this.data.operationType){const e=structuredClone(this.data.data);e.node_entered_at=(new Date).toISOString(),this.data.data=e}return Promise.resolve()}}class Zu{static create(e){const{type:t}=e;switch(t){case ms.Api:return new Hu(e.resourceId,e.data,e.issuer);case ms.Db:return new Ku(e.resourceId,e.data,e.issuer);case ms.AutomationJourneyReactWebPushApi:return new Xu(e.resourceId,e.data,e.issuer);case ms.AutomationJourneyReactWebPushDb:return new Yu(e.resourceId,e.data,e.issuer);default:zn(t)}}}Et=new WeakSet,Ct=async function(e,t){return(await Bs.openServiceWorkerCallbacksDatabaseConnection(Dn(this,kt,Dt))).transaction(e,t)},kt=new WeakSet,Dt=(e,t,r)=>{!(e=>{if(!e.objectStoreNames.contains(bs.Callbacks))e.createObjectStore(bs.Callbacks)})(r)};const Qu=new class{constructor(){Cn(this,Et),Cn(this,kt)}async addCallback(e){const t=await Dn(this,Et,Ct).call(this,bs.Callbacks,"readwrite"),r=t.objectStore(bs.Callbacks),i=await r.get(e.resourceId);if(!(i||[]).find((t=>e.isSame(t))))await r.put([...i||[],e.toJSON()],e.resourceId);await t.done}async getCallbacks({resourceId:e}){const t=await Dn(this,Et,Ct).call(this,bs.Callbacks,"readonly"),r=t.objectStore(bs.Callbacks),i=await r.get(e);if(await t.done,i)return i.map((e=>Zu.create(e)))}async deleteCallbacks({resourceId:e}){const t=await Dn(this,Et,Ct).call(this,bs.Callbacks,"readwrite"),r=t.objectStore(bs.Callbacks);await r.delete(e),await t.done}};Tt=new WeakSet,At=()=>({visitorUuid:Ln(ca.visitorUuid),user_uuid:pa.getUserUuid()}),Nt=new WeakSet,Ut=(e,t)=>`/c/${Bn(e)}/v/${Bn(t)}/state/`;const el=new class{constructor(){Cn(this,Tt),Cn(this,Nt)}getVisitorJourneys({visitorUuid:e,user_uuid:t}=Dn(this,Tt,At).call(this)){return Ua(new URL(Dn(this,Nt,Ut).call(this,t,e),pa.visitorApplicationEndpoint).href)}sendVisitorTransitions(e,{visitorUuid:t,user_uuid:r}=Dn(this,Tt,At).call(this)){return Ua(this.getVisitorApplicationEndpoint(r,t),{omitAidHeader:true,headers:{"Content-Type":"application/json"},body:JSON.stringify(e),method:"PUT"})}getVisitorApplicationEndpoint(e,t){return new URL(Dn(this,Nt,Ut).call(this,e,t),pa.visitorApplicationEndpoint).href}};var tl=(e=>(e["PushNotificationDisplayed"]="pushNotificationDisplayed",e["ReceiptOfPushNotificationDisplayedConfirmation"]="receiptOfPushNotificationDisplayedConfirmation",e))(tl||{});Wt=new WeakSet,Ft=e=>window.navigator.serviceWorker.ready.then((t=>t.active.postMessage(e)));const rl=new class{constructor(){Cn(this,Wt)}waitForWebPushReceptionConfirmation(e){return new Promise((t=>{window.navigator.serviceWorker.addEventListener("message",(r=>{if(r.origin===window.location.origin&&!!(i=r).data&&"object"==typeof i.data&&"type"in i.data&&i.data.type===tl.PushNotificationDisplayed){const{messageId:i}=r.data.data;if(i===e)Dn(this,Wt,Ft).call(this,{type:tl.ReceiptOfPushNotificationDisplayedConfirmation,data:{messageId:e}}).catch((e=>{Rn.error("Failed to send message to service worker about confirmation of push reception",e)})),t()}var i}))}))}async saveCallbackForServiceWorker({apiCallbackData:e,dbCallbackData:t,senderId:r,messageId:i}){const n=Zu.create({type:ms.AutomationJourneyReactWebPushDb,resourceId:i,issuer:{id:r},data:{dbName:ws.VisitorJourneys,operationType:t.operationType,key:"put"===t.operationType?void 0:[t.data.journey.uuid,Ln(ca.visitorUuid)],objectStore:ys.VisitorJourneys,data:t.data.toSerializedDatabaseJSON()}}),o=Zu.create({type:ms.AutomationJourneyReactWebPushApi,resourceId:i,issuer:{id:r},data:{body:JSON.stringify(e.toJSON()),headers:{"Content-Type":"application/json"},method:"PUT",url:el.getVisitorApplicationEndpoint(pa.getUserUuid(),Ln(ca.visitorUuid))}});await Promise.all([Qu.addCallback(n),Qu.addCallback(o)])}};class il extends Ra{constructor(e){super(`Failed to send message: ${e}`)}}const nl=new class{constructor(){this.authToken=null}async getAuthToken(){const{pushWpid:e,pushDomain:t}=pa;if(e)try{if(this.authToken)return this.authToken;const r=await fetch(`${t}webpush/auth`,{method:"POST",mode:"cors",headers:{"X-WpId":e,"Content-Type":"application/json"},body:JSON.stringify({url:window.location.origin,gau:Ln("gaVisitorUuid")})});return this.authToken=await r.text(),this.authToken}catch(r){Rn.error(r)}}};function ol(e){this.message=e}(ol.prototype=new Error).name="InvalidCharacterError";var sl="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||(e=>{var t=String(e).replace(/=+$/,"");if(t.length%4==1)throw new ol("'atob' failed: The string to be decoded is not correctly encoded.");for(var r,i,n=0,o=0,s="";i=t.charAt(o++);~i&&(r=n%4?64*r+i:i,n++%4)?s+=String.fromCharCode(255&r>>(-2*n&6)):0)i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(i);return s});function al(e){this.message=e}function cl(e,t){if("string"!=typeof e)throw new al("Invalid token specified");var r=true===(t=t||{}).header?0:1;try{return JSON.parse((e=>{var t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw"Illegal base64url string!"}try{return decodeURIComponent(sl(t).replace(/(.)/g,((e,t)=>{var r=t.charCodeAt(0).toString(16).toUpperCase();return 2>r.length&&(r="0"+r),"%"+r})))}catch(r){return sl(t)}})(e.split(".")[r]))}catch(i){throw new al("Invalid token specified: "+i.message)}}(al.prototype=new Error).name="InvalidTokenError";const ul="gr_webpush_database",ll="gr_visitor_data",dl="sub_data",pl=480;var hl=(e=>(e["DISPLAYED_CUSTOMIZED"]="dic",e["ACCEPTED_CUSTOMIZED"]="acc",e["DENIED_CUSTOMIZED"]="dec",e["DISPLAYED_NATIVE"]="din",e["ACCEPTED_NATIVE"]="acn",e["DENIED_NATIVE"]="den",e))(hl||{}),ml=(e=>(e["V1"]="1.0.0",e["V1_1"]="1.1.0",e["V2"]="2.0.0",e["V2_1"]="2.1.0",e))(ml||{});function wl({promptId:e,pushSubscription:t,wpid:r=pa.pushWpid,domain:i=pa.pushDomain,id:n}){window.indexedDB.deleteDatabase(ul),window.indexedDB.open(ul,1).onupgradeneeded=o=>{o.target.result.createObjectStore(ll,{keyPath:"id"}).add({id:dl,uuid:n,pushSubscription:t.toJSON(),domain:i,wpid:r,visitor:{pid:e,lang:us.getBrowserLanguage()}})}}class fl{get promptId(){var e;return null==(e=this.promptData)?void 0:e.id}get statisticsEndpoint(){var e;return pa.pushDomain+(null==(e=this.promptData)?void 0:e.pst)}get hasMobile(){var e,t;return!!(null==(t=null==(e=this.promptData)?void 0:e.data)?void 0:t.mobile)}get hasDesktop(){var e,t;return!!(null==(t=null==(e=this.promptData)?void 0:e.data)?void 0:t.desktop)}get mobilePromptData(){var e,t;return null==(t=null==(e=this.promptData)?void 0:e.data)?void 0:t.mobile}get desktopPromptData(){var e,t;return null==(t=null==(e=this.promptData)?void 0:e.data)?void 0:t.desktop}get showAgainAfter(){var e;return(null==(e=this.promptData)?void 0:e.showAgainAfter)||ua.ThreeMonths}shouldPromptBasedOnTriggersBeDisplayed(){return Promise.resolve(true)}}class gl extends fl{constructor(e){super(),this.promptData={id:e.pid,pst:e.pst,data:e.pc}}setActivePrompt(){throw new Error("Method not implemented in Prompt v1")}}function vl(e){const t=new URL(document.location.href).host;return vu(document.location.href,(Array.isArray(e)?e:[e]).map((e=>`${t}${e}`)))}var yl=(e=>(e["Includes"]="allowed",e["Excluded"]="excluded",e["Entire"]="entire",e))(yl||{}),bl=(e=>(e["Delay"]="delay",e["ExitIntend"]="exitIntend",e["Inactivity"]="inactivity",e["Scroll"]="scroll",e["Click"]="click",e["Location"]="location",e["Device"]="device",e["VisitorType"]="visitorType",e))(bl||{}),Sl=(e=>(e["New"]="new",e["Returning"]="returning",e["All"]="all",e))(Sl||{});_t=new WeakMap,Vt=new WeakMap,xt=new WeakMap,Ot=new WeakSet,Rt=function(e){En(this,xt).push({...e})};let Pl=class e{constructor({automationJourney:e}){if(Cn(this,Ot),Cn(this,_t,void 0),Cn(this,Vt,[]),Cn(this,xt,[]),e)kn(this,_t,e)}static create(t={}){return new e(t)}withNode(e,t){return En(this,Vt).push({type:e,...t}),this}withConnection(e){return Dn(this,Ot,Rt).call(this,e),this}withCascadeConnectionFalseOut({fromNodes:e,targetNode:t}){return e.forEach(((r,i)=>{if(i!==e.length-1)Dn(this,Ot,Rt).call(this,{from:r,to:e[i+1],fromPathKey:"false"});Dn(this,Ot,Rt).call(this,{from:r,to:t,fromPathKey:"true"})})),this}withSeriesConnectionTrueOut({fromNodes:e,targetNode:t}){return e.forEach(((r,i)=>{if(i===e.length-1)Dn(this,Ot,Rt).call(this,{from:r,to:t,fromPathKey:"true"});else Dn(this,Ot,Rt).call(this,{from:r,to:e[i+1],fromPathKey:"true"})})),this}build(){return{...En(this,_t)||{},nodes:En(this,Vt),connections:En(this,xt)}}};var Il=(e=>(e["NodeProcessed"]="nodeProcessed",e))(Il||{});Lt=new WeakSet,Mt=function(e,{awaitsSeparator:t,filtersSeparator:r}){const i=Pl.create(),n=i.build(),o=Dn(this,Gt,qt).call(this,i),s=[],a=[];for(const u of e)switch(u.type){case bl.Delay:s.push(Dn(this,tr,rr).call(this,u));break;case bl.Click:s.push(Dn(this,zt,Ht).call(this,u));break;case bl.ExitIntend:s.push(Dn(this,Qt,er).call(this));break;case bl.Inactivity:s.push(Dn(this,Yt,Zt).call(this,u));break;case bl.Scroll:s.push(Dn(this,Kt,Xt).call(this,u));break;case bl.Location:a.push(Dn(this,ir,nr).call(this,i,u));break;case bl.Device:a.push(Dn(this,or,sr).call(this,i,u));break;case bl.VisitorType:a.push(Dn(this,ar,cr).call(this,i,u));break;default:zn(u)}const c=Dn(this,Jt,$t).call(this,i,s,t);return Dn(this,jt,Bt).call(this,i,{filterUrlId:o,mergedAwaitsNodeId:c,filterElementsIds:a,filtersSeparator:r}),{webFlow:new sd({webflowSerializedData:n}),finalElementId:o,flowData:n}},jt=new WeakSet,Bt=(e,t)=>{const{filterUrlId:r,filtersSeparator:i,filterElementsIds:n,mergedAwaitsNodeId:o}=t;let s=r;if(n.length>0){if("or"===i)e.withCascadeConnectionFalseOut({fromNodes:n,targetNode:s});else if("and"===i)e.withSeriesConnectionTrueOut({fromNodes:n,targetNode:s});s=n[0]}if(o)e.withConnection({from:o,to:s,fromPathKey:"true"})},Jt=new WeakSet,$t=(e,t,r)=>{if(t.length){const i=Gu.generateRandomUuid();return e.withNode(An.AwaitMergedNodes,{id:i,recurrent:{type:ao.EveryTime,value:false},properties:{leaveFalseDelay:0,nodesDefinition:t,separator:r}}),i}return""},Gt=new WeakSet,qt=e=>{const t=Gu.generateRandomUuid();return e.withNode(An.FilterUrl,{id:t,properties:{urls:[window.location.origin]},recurrent:{type:ao.EveryTime,value:false}}),t},zt=new WeakSet,Ht=e=>({id:Gu.generateRandomUuid(),type:An.AwaitClick,properties:{selector:e.value.selector,leaveFalseDelay:0}}),Kt=new WeakSet,Xt=e=>({id:Gu.generateRandomUuid(),type:An.AwaitScroll,properties:{leaveFalseDelay:0,..."selector"===e.value.scrollType?{selector:e.value.value.selector}:{percent:e.value.value.percent}}}),Yt=new WeakSet,Zt=e=>({id:Gu.generateRandomUuid(),type:An.AwaitInactivity,properties:{inactivityTime:e.value.delay,leaveFalseDelay:0}}),Qt=new WeakSet,er=()=>({id:Gu.generateRandomUuid(),type:An.AwaitExit,properties:{leaveFalseDelay:0,useMobileScrollBasedExitIntend:true,useMobileHistoryBasedExitIntend:true}}),tr=new WeakSet,rr=e=>({id:Gu.generateRandomUuid(),type:An.ReactDelay,properties:{delay:e.value.timeout}}),ir=new WeakSet,nr=(e,t)=>{const r=Gu.generateRandomUuid();return e.withNode(An.FilterLocation,{id:r,properties:{locations:t.value.locations},recurrent:{type:ao.EveryTime,value:false}}),r},or=new WeakSet,sr=(e,t)=>{const r=Gu.generateRandomUuid();return e.withNode(An.FilterDevice,{id:r,properties:{deviceType:t.value.devices},recurrent:{type:ao.EveryTime,value:false}}),r},ar=new WeakSet,cr=(e,t)=>{const r=Gu.generateRandomUuid(),{visitorType:i,returningVisitorVisitAmount:n,returningVisitorVisitAmountType:o}=t.value,s={};if("number"==typeof n&&i===Sl.Returning)switch(s.frequencyDaysNumber=n,o){case"equal":s.frequency=Ac.ExactlyXTimes;break;case"before":s.frequency=Ac.LessThanXTimes;break;case"after":s.frequency=Ac.MoreThanXTimes;break;default:zn(o)}else s.visitors=i;return e.withNode(An.FilterVisit,{id:r,properties:s,recurrent:{type:ao.EveryTime,value:false}}),r};const El=new class{constructor(){Cn(this,Lt),Cn(this,jt),Cn(this,Jt),Cn(this,Gt),Cn(this,zt),Cn(this,Kt),Cn(this,Yt),Cn(this,Qt),Cn(this,tr),Cn(this,ir),Cn(this,or),Cn(this,ar)}doesVisitorMeetsTriggers(e,t={awaitsSeparator:"or",filtersSeparator:"and"}){const{webFlow:r,finalElementId:i,flowData:n}=Dn(this,Lt,Mt).call(this,e,t);return pa.webPushActivePromptGraph={originalTriggers:e,transformedGraph:n},r.initVisitorFlow(),new Promise((e=>{const t=new AbortController;r.on(Il.NodeProcessed,(({id:r})=>{if(r===i)t.abort(),e(true)}),{signal:t.signal})}))}};class Cl extends fl{constructor(e){super(),Cn(this,ur),Cn(this,dr),this.globalPromptConfig=e,Dn(this,ur,lr).call(this,e)}setActivePrompt(e){const t=this.globalPromptConfig.customPrompts.find((t=>t.pid===e));if(t)this.promptData={id:t.pid,pst:t.pst,data:t.pc,showAgainAfter:t.showAgainAfter,triggers:t.triggers||{}}}async shouldPromptBasedOnTriggersBeDisplayed(){const{triggers:e,triggersAwaitsSeparator:t,triggersFilterSeparator:r}=Dn(this,dr,pr).call(this,this.promptData.triggers);return El.doesVisitorMeetsTriggers(e,{awaitsSeparator:t,filtersSeparator:r})}}ur=new WeakSet,lr=function(e){const t=e.paths.map((e=>{switch(e.type){case yl.Entire:return{...e,type:yl.Includes,path:"*"};case yl.Includes:case yl.Excluded:return{...e,path:e.path.startsWith("/")?`${e.path}*`:`*${e.path}*`};default:return e}})).find((e=>e.type===yl.Includes?vl(e.path):!vl(e.path)));if(e.nativePrompt&&e.nativePrompt.pid===(null==t?void 0:t.pid))return this.promptData={id:e.nativePrompt.pid,pst:e.nativePrompt.pst,data:null},void 0;const r=e.customPrompts.find((e=>e.pid===(null==t?void 0:t.pid)));if(r)this.promptData={id:r.pid,pst:r.pst,data:r.pc,showAgainAfter:r.showAgainAfter,triggers:r.triggers||{}}},dr=new WeakSet,pr=e=>{var t,r;const{awaits:i={},filters:n={},filtersSeparator:o="and",awaitsSeparator:s="or"}=e,a=[];if(i.delay)a.push({type:bl.Delay,value:{timeout:i.delay}});if(i.inactivity)a.push({type:bl.Inactivity,value:{delay:i.inactivity}});if(i.exitIntend)a.push({type:bl.ExitIntend});if(i.click)a.push({type:bl.Click,value:{selector:i.click}});if(null==(t=i.scroll)?void 0:t.selector)a.push({type:bl.Scroll,value:{scrollType:"selector",value:{selector:i.scroll.selector}}});if(null==(r=i.scroll)?void 0:r.percent)a.push({type:bl.Scroll,value:{scrollType:"percent",value:{percent:i.scroll.percent}}});if(n.location)a.push({type:bl.Location,value:{locations:n.location}});if(n.device)a.push({type:bl.Device,value:{devices:n.device}});if(n.visit)a.push({type:bl.VisitorType,value:{visitorType:n.visit.visitorType,returningVisitorVisitAmount:n.visit.returningVisitorVisitCount,returningVisitorVisitAmountType:n.visit.returningVisitorType}});return{triggers:a,triggersAwaitsSeparator:s,triggersFilterSeparator:o}};class kl{constructor(e){this.nativePromptPaths=[],this.version=e._v;const t=e,r=e;switch(this.version){case ml.V1:case ml.V1_1:this.prompt=new gl(t),this.nativePromptPaths=t.paths;break;case ml.V2:case ml.V2_1:this.prompt=new Cl(r);break;default:throw new Error("Unsupported version of prompt")}}get shouldShowNativePrompt(){var e,t,r;if(this.version===ml.V2||this.version===ml.V2_1){if(!(null==(e=this.prompt)?void 0:e.hasDesktop)&&!(null==(t=this.prompt)?void 0:t.hasMobile)&&(null==(r=this.prompt)?void 0:r.promptId))return true}else if(vl(this.nativePromptPaths))return true;return false}getVersion(){return this.version}}const Dl=new class{async initialize(){await this.fetchSiteConfig(pa.pushPromptEndpoint),this.promptConfig=new kl(globalThis._grpr)}get prompt(){return this.promptConfig.prompt}get promptData(){return this.promptConfig}fetchSiteConfig(e){return new Promise(((t,r)=>{const i=document.createElement("script");i.type="text/javascript",i.src=e,document.body.appendChild(i),i.onload=()=>{t()},i.onerror=r}))}setActivePrompt(e){try{this.promptConfig.prompt.setActivePrompt(e)}catch(t){Rn.error(t)}}};hr=new WeakSet,mr=()=>({lang:us.getBrowserLanguage()});const Tl=new class{constructor(){Cn(this,hr)}sendConsentData(e,t,r){navigator.sendBeacon(new URL("wpn/consent-data",pa.getUserAnalyticsDomain()),new Blob([JSON.stringify({uuid:t,aid:r,publicVpk:e})],{type:"application/json"}))}async renewSubscription(e,t,r){const{pushWpid:i,pushDomain:n}=pa,o=await nl.getAuthToken();return fetch(`${n}webpush/renew`,{method:"POST",mode:"cors",headers:{"Content-Type":"application/json","X-WpId":i,Authorization:`Bearer ${o}`},body:JSON.stringify({oldSubscription:null==e?void 0:e.toJSON(),newSubscription:null==t?void 0:t.toJSON(),visitor:{...Dn(this,hr,mr).call(this),pid:r}})})}sendPushSubscriptionData({pushWpId:e,pushSubscription:t,subscriptionEndpoint:r,authToken:i,promptId:n}){return fetch(r,{method:"POST",mode:"cors",headers:{"Content-Type":"application/json","X-WpId":e,Authorization:`Bearer ${i}`},body:JSON.stringify({sub:t,prv:Dl.promptData.getVersion(),visitor:{...Dn(this,hr,mr).call(this),pid:n}})}).then((e=>{if(!e.ok)throw new Error(`Subscription failed ${e.status}`);return true}))}},Al=new class{async registerServiceWorker(){const e=pa.getCustomSwPath();if(e)return navigator.serviceWorker.register(`${e}`);try{return await navigator.serviceWorker.register("/gr_sw_main.js")}catch(t){return navigator.serviceWorker.register("./gr_sw_main.js")}}getExistingServiceWorkerRegistration(){const e=pa.getCustomSwPath()||"gr_sw_main.js";return navigator.serviceWorker.getRegistrations().then((t=>t.find((t=>t.active.scriptURL.includes(e)))))}},Nl=new class{sendStatsData(e){return fetch(`${Dl.prompt.statisticsEndpoint}${e}`,{mode:"cors"})}},Ul=new class{setCookie({expiresIn:e,domain:t="",value:r,name:i}){const n=this.getExpirationTimeString(e);document.cookie=`${i}=${r}; expires=${n}; path=/; ${t?`domain=${t}`:""}`}getExpirationTimeString(e){if(e instanceof Date)return e.toUTCString();const t=new Date;return t.setTime(t.getTime()+e),t.toUTCString()}getCookie(e){const t=document.cookie.match(new RegExp(`(^| )${e}=([^;]+)`));if(t)return t[2]}removeUuidCookieSessionInfo(){window.sessionStorage.removeItem(Ks.UuidHasBeenSet)}};class Wl extends Ra{constructor(e){if(super("User denied push notification consent"),e)this.cause=e}}const Fl=1e3*60*60*24*7,_l=new class{async isSubscribed(){return null!==await this.checkIfUserIsSubscribed()}async isSubscribedFromPrompt(e){if(Boolean(await this.checkIfUserIsSubscribed()))return e===Ul.getCookie(ca.NotificationConsentAcceptedFromPrompt);else return false}isPermissionPermanentlyDenied(){return"denied"===Notification.permission}isPermissionGranted(){return"granted"===Notification.permission}isPermissionDeniedForCustomPrompt(e){const t=!!Ul.getCookie(ca.NotificationConsentCustomPromptRejected.replace("promptId",e)),r=!!Ul.getCookie(ca.NotificationConsentCustomPromptRejectedDEPRECATED.replace("promptId",e));return"default"===Notification.permission&&(t||r)}async registerUserForNotifications(){const{pushWpid:e,pushDomain:t}=pa,r=Ln(ca.visitorUuid),i=await Al.registerServiceWorker();let n=await i.pushManager.getSubscription();if(!(null!==n))try{const i=await nl.getAuthToken(),o=cl(i),s=o.subEndp;n=await this.getUserNotificationsSubscription();const{promptId:a}=Dl.promptData.prompt;return wl({id:r,pushSubscription:n,domain:t,wpid:e,promptId:a}),Nl.sendStatsData(hl.ACCEPTED_NATIVE),await Tl.sendPushSubscriptionData({promptId:a,pushWpId:e,pushSubscription:n,subscriptionEndpoint:s,authToken:i}),Tl.sendConsentData(o.vpk,r,pa.getUserAid()),Ul.setCookie({value:a,name:ca.NotificationConsentAcceptedFromPrompt,expiresIn:ua.OneYear,domain:Mn()}),Ul.removeUuidCookieSessionInfo(),this.markVisitorAsResubscribed(),n}catch(o){if(0===o.code)throw Nl.sendStatsData(hl.DENIED_NATIVE),pa.eventBus.publish(ma.WebPushNativeConsentRejected),new Wl(o);throw o}}async resubscribeVisitor(){if(this.shouldResubscribeVisitor()){const e=await Al.getExistingServiceWorkerRegistration(),t=await(null==e?void 0:e.pushManager.getSubscription());if(t)if(!(await t.unsubscribe()))return;await(async()=>{var e,t;if("serviceWorker"in navigator){const r=await navigator.serviceWorker.getRegistrations(),i=[];for(const n of r)if(!((null==(e=n.active)?void 0:e.scriptURL.endsWith("gr_sw_main.js"))||(null==(t=n.active)?void 0:t.scriptURL.endsWith("service-worker/service-worker.js"))))i.push(n.unregister());return Promise.all(i)}})();const r=await this.getUserNotificationsSubscription(),i=Ul.getCookie(ca.NotificationConsentAcceptedFromPrompt);if(t||r)await Tl.renewSubscription(t,r,i).then((e=>{if(!e.ok)throw new Error(`Subscription failed ${e.status}`);return true})),Ul.removeUuidCookieSessionInfo();if(r)this.markVisitorAsResubscribed(),wl({id:Ln(ca.visitorUuid),pushSubscription:r,promptId:i});return r}}async getUserNotificationsSubscription(){const e=await Al.registerServiceWorker(),t=await e.pushManager.getSubscription();if(!(null!==t))try{const t=cl(await nl.getAuthToken());if("default"===Notification.permission)Nl.sendStatsData(hl.DISPLAYED_NATIVE);return e.pushManager.subscribe({userVisibleOnly:true,applicationServerKey:t.vpk})}catch(r){Rn.error(r)}return t}markVisitorAsResubscribed(){Ul.setCookie({name:ca.VisitorResubscribed,value:"true",expiresIn:Fl})}shouldResubscribeVisitor(){return!Ul.getCookie(ca.VisitorResubscribed)||!!window.sessionStorage.getItem(Ks.UuidHasBeenSet)}async checkIfUserIsSubscribed(){return(await Al.registerServiceWorker()).pushManager.getSubscription()}},Vl={".gr-visual-prompt":{all:"initial !important",position:"fixed !important",left:"50% !important",top:"0 !important","z-index":"999999999 !important",transform:"translateX(-50%) !important"}},xl={".gr-visual-prompt":{all:"initial !important",position:"fixed !important",left:"50% !important",bottom:"0 !important","z-index":"999999999 !important",transform:"translateX(-50%) !important"}};function Ol(e,t){return(e.shadowRoot||e).querySelector(t)}wr=new WeakMap,fr=new WeakMap,gr=new WeakMap,vr=new WeakSet,yr=function(e){Ul.setCookie({value:e,name:ca.NotificationConsentCustomPromptRejected.replace("promptId",e),expiresIn:En(this,gr)??ua.TwoWeeks,domain:Mn()})};const Rl=new class{constructor(){Cn(this,vr),Cn(this,wr,void 0),Cn(this,fr,void 0),Cn(this,gr,void 0),kn(this,wr,new AbortController),kn(this,fr,new AbortController),kn(this,gr,null),this.onImageError=e=>{const t=e.target;t.parentNode.removeChild(t)},this.closeNotificationPrompt=e=>{const t=document.documentElement.querySelector('[data-gr-prompt="content"]'),r=Ol(t,"img");if(null==r?void 0:r.removeEventListener("error",this.onImageError),!e)Nl.sendStatsData(hl.DENIED_CUSTOMIZED);document.body.removeChild(t)}}get hasCustomPrompt(){const{prompt:e}=Dl;return e&&((null==e?void 0:e.hasMobile)||(null==e?void 0:e.hasDesktop))}async displayCustomPrompt(e){if(e)kn(this,gr,e);if(this.hasCustomPrompt){const{prompt:e}=Dl;if(_l.isPermissionDeniedForCustomPrompt(null==e?void 0:e.promptId))throw new Wl;if(e.showAgainAfter)kn(this,gr,e.showAgainAfter);const r=function(e,t){const r=document.querySelector('[data-gr-prompt="content"]'),i=r?r:document.createElement("div"),n=/iPhone|iPad|iPod|Android|webOS|BlackBerry|Windows Phone/i.test(navigator.userAgent)||screen.availWidth{const t=document.createElement("style"),r=(i="mobile"===e?xl:Vl,Object.keys(i).reduce(((e,t)=>{const r=i[t];if("object"==typeof r){const i=Object.keys(r).reduce(((e,t)=>e+=`${t}: ${r[t]};`),"");e.push(`${t} {${i}}`)}return e}),[]));var i;let n;document.head.appendChild(t),n=t.sheet,r.forEach((e=>{n.insertRule(e,n.rules.length)}))})(n?"mobile":"desktop"),i}(e.desktopPromptData,e.mobilePromptData),i=Ol(r,'[data-gr-prompt-button="allow"]'),n=Ol(r,'[data-gr-prompt-button="cancel"]');Ol(r,"img").addEventListener("error",this.onImageError),i.style.cursor="pointer",n.style.cursor="pointer",t=r,void new MutationObserver(((e,r)=>{e.forEach((e=>{if(Array.from(e.addedNodes).includes(t))void Nl.sendStatsData(hl.DISPLAYED_CUSTOMIZED),r.disconnect()}))})).observe(document.body,{childList:true}),document.body.appendChild(r);const o=await Promise.race([this.getUserSubscriptionFromCustomPromptConfirm(r),this.waitForUserDenyConsent(r)]);if(this.isPushSubscription(o))return o;throw new Wl}var t}getUserSubscriptionFromCustomPromptConfirm(e){return new Promise(((t,r)=>{const i=Ol(e,'[data-gr-prompt-button="allow"]');if(i)i.addEventListener("click",(()=>{Nl.sendStatsData(hl.ACCEPTED_CUSTOMIZED),_l.registerUserForNotifications().then((e=>{const{promptId:r,hasDesktop:i,hasMobile:n}=Dl.promptData.prompt;pa.eventBus.publish(ma.WebPushConsentAccepted,n||i?r:""),En(this,fr).abort(),t(e)})).catch((e=>{r(e)})),this.closeNotificationPrompt(true)}),{once:true,signal:En(this,wr).signal})}))}waitForUserDenyConsent(e){return new Promise((t=>{const r=Ol(e,'[data-gr-prompt-button="cancel"]');if(r)r.addEventListener("click",(()=>{const{promptId:e}=Dl.promptData.prompt;this.closeNotificationPrompt(),En(this,wr).abort(),Dn(this,vr,yr).call(this,e),pa.eventBus.publish(ma.WebPushCustomConsentRejected,e),t()}),{once:true,signal:En(this,fr).signal})}))}isPushSubscription(e){return e instanceof PushSubscription||!!e&&"object"==typeof e&&"endpoint"in e&&"expirationTime"in e}},Ll=new class{async collectPushNotificationSubscription(e,t){if(await Dl.initialize(),await _l.isSubscribed()||_l.isPermissionGranted())return _l.isSubscribedFromPrompt(e);if(_l.isPermissionPermanentlyDenied()||_l.isPermissionDeniedForCustomPrompt(e))return false;if(Dl.setActivePrompt(e),!Rl.hasCustomPrompt)throw new Error("No prompt data");try{return await Rl.displayCustomPrompt(t),_l.isSubscribedFromPrompt(e)}catch(r){if(r instanceof Wl)return false;throw Rn.error("Error while trying to send web push",r),r}}};class Ml{constructor(e){this.promptId=e}static create(e){return new Ml(e)}}class jl{constructor(e){this.promptId=e}static create(e){return new jl(e)}}br=new WeakSet,Sr=()=>new Promise((e=>{pa.eventBus.subscribe(ma.WebPushConsentAccepted,(t=>{e(jl.create(t))}))})),Pr=new WeakSet,Ir=()=>new Promise((e=>{pa.eventBus.subscribe(ma.WebPushNativeConsentRejected,(()=>{e(Ml.create())}))})),Er=new WeakSet,Cr=()=>new Promise((e=>{pa.eventBus.subscribe(ma.WebPushCustomConsentRejected,(t=>{e(Ml.create(t))}))}));const Bl=Object.freeze({[Un]:true,[Wn]:true}),Jl=Object.freeze({[Un]:true}),$l=Object.freeze({[Fn]:true}),Gl=Object.freeze({}),ql={[An.AwaitClick]:class extends Ta{constructor(){super(...arguments),this.type=An.AwaitClick,this.outs=Hl.getNodeOutsInstance(An.AwaitClick)}async handler(){const{selector:e}=this.properties;try{return await this.waitForElementClick(e),Un}catch(t){if(t instanceof Nn)return Wn;throw Rn.forceLogError(t),t}}waitForElementClick(e){return new Promise(((t,r)=>{const i=Array.from(document.querySelectorAll(e)),n=new AbortController,o=()=>{t(),this.cleanLeaveFalseTimeout(),n.abort()};if(i.length>0){for(const e of i)e.addEventListener("click",o,{signal:n.signal});this.waitForDelayLeaveFalse().then((()=>{n.abort(),r(new Nn)}))}else r(new _n(e))}))}},[An.AwaitScroll]:class extends Ta{constructor(){super(...arguments),this.type=An.AwaitScroll,this.outs=Hl.getNodeOutsInstance(An.AwaitScroll)}async handler(){const{selector:e,percent:t}=this.properties;try{if(e)await this.watchForElementIntersectWithViewport(e);else if(t)await this.watchForPagePercentValueIntersectsWithViewport(t);return Un}catch(r){if(r instanceof Nn)return Wn;throw Rn.forceLogError(r),r}finally{this.cleanLeaveFalseTimeout()}}watchForElementIntersectWithViewport(e){return new Promise(((t,r)=>{const i=document.querySelector(e);if(i){const e=new IntersectionObserver(((e,r)=>{for(const n of e)if(n.isIntersecting&&n.target===i)t(),r.disconnect()}));e.observe(i),this.waitForDelayLeaveFalse().then((()=>{e.disconnect(),r(new Nn)}))}else r(new _n(e))}))}async watchForPagePercentValueIntersectsWithViewport(e){return new Promise(((t,r)=>{const i=document.documentElement.scrollHeight*(e/Aa);function n(){if(document.documentElement.clientHeight+document.documentElement.scrollTop>i)t(),document.removeEventListener("scroll",n)}if(document.documentElement.clientHeight+document.documentElement.scrollTop>i)t();else document.addEventListener("scroll",n,true);this.waitForDelayLeaveFalse().then((()=>{document.removeEventListener("scroll",n),r(new Nn)}))}))}},[An.AwaitExit]:class extends Ta{constructor(){super(...arguments),this.outs=Hl.getNodeOutsInstance(An.AwaitExit),this.type=An.AwaitExit}handler(){const{useMobileHistoryBasedExitIntend:e,useMobileScrollBasedExitIntend:t}=this.properties,r=new ds({useMobileHistoryBasedExitIntend:e,useMobileScrollBasedExitIntend:t});return new Promise((e=>{r.handle().then((()=>{this.cleanLeaveFalseTimeout(),e(Un)})).catch((e=>{Rn.error("Error while exit intend handler",e)})),this.waitForDelayLeaveFalse().then((()=>{e(Wn),r.abort()}))}))}},[An.AwaitInactivity]:class extends Ta{constructor(){super(...arguments),this.abortController=new AbortController,this.handlersMap={click:null,scroll:null,keydown:null,mousemove:null},this.type=An.AwaitInactivity,this.outs=Hl.getNodeOutsInstance(An.AwaitInactivity)}handler(){const{inactivityTime:e}=this.properties;return new Promise((t=>{this.waitForDelayLeaveFalse().then((()=>{t(Wn)})),this.waitForUserActivity(e).then((()=>{t(Un),this.cleanLeaveFalseTimeout()}))}))}async waitForUserActivity(e){const t=window.setTimeout((()=>{this.abortController.abort()}),e);try{return await Promise.race([this.waitForUserAction("scroll"),this.waitForUserAction("click"),this.waitForUserAction("keydown"),this.waitForUserAction("mousemove")]),window.clearTimeout(t),this.detachActivityMonitorHandlers(),this.waitForUserActivity(e)}catch(r){if(r instanceof La)return;window.clearTimeout(t),Rn.error(r)}}detachActivityMonitorHandlers(){const{click:e,keydown:t,scroll:r,mousemove:i}=this.handlersMap;document.removeEventListener("click",e),document.removeEventListener("scroll",r),document.removeEventListener("keydown",t),document.removeEventListener("mousemove",i),this.handlersMap={click:null,keydown:null,scroll:null,mousemove:null}}waitForUserAction(e){return new Promise(((t,r)=>{document.addEventListener(e,t,{once:true,capture:"scroll"===e}),this.handlersMap[e]=t,this.abortController.signal.addEventListener("abort",(()=>{r(new La)}),{once:true})}))}},[An.AwaitECommerceActivity]:class extends Ta{constructor(e){super(e),Cn(this,pt),Cn(this,mt),Cn(this,ft),Cn(this,vt),Cn(this,bt),Cn(this,lt,void 0),Cn(this,dt,void 0),kn(this,lt,(e=>{var t,r;const i=null==(t=Object.entries(pa.automationJourneyGraphs).find((([,t])=>{const{transformedGraph:r}=t;return r.nodes.find((t=>t.id===e))})))?void 0:t[0],n=null==(r=Object.entries(pa.popupGraphs).find((([,t])=>{const{transformedGraph:r}=t;return r.nodes.find((t=>t.id===e))})))?void 0:r[0];return i||n||null})(this.id)),kn(this,dt,[]),this.outs=Hl.getNodeOutsInstance(An.AwaitECommerceActivity),this.type=An.AwaitECommerceActivity,this.properties.conditions=this.properties.conditions.map((e=>({...e,conditionId:"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(e=>{const t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}))})))}async handler(){return new Promise((async e=>{const{conditions:t}=this.properties;if(0===t.length||await Dn(this,ft,gt).call(this))e(Un);else pa.eventBus.subscribe(ma.UserEventSaved,(async t=>{if(Du(t)&&!Dn(this,bt,St).call(this,t.eventId))if(await Dn(this,pt,ht).call(this,t))Dn(this,vt,yt).call(this,t.eventId),e(Un)}),{ignoreQueuedEvents:true}),pa.eventBus.subscribe(ma.UserEventUpdated,(async t=>{const r=await Mc.getEventById(t);if(r&&Du(r)&&!Dn(this,bt,St).call(this,r.eventId))if(await Dn(this,pt,ht).call(this,r))Dn(this,vt,yt).call(this,r.eventId),e(Un)}),{ignoreQueuedEvents:true})}))}},[An.AwaitMergedNodes]:class extends Ta{constructor(e){super(e),Cn(this,Pt,void 0),Cn(this,It,void 0),kn(this,Pt,null),this.type=An.AwaitMergedNodes,this.outs=Hl.getNodeOutsInstance(An.AwaitMergedNodes),kn(this,It,[]);const{nodesDefinition:t}=e.properties;kn(this,It,t.map((e=>Hl.getNodeInstance(e.type,{id:Gu.generateRandomUuid(),properties:e.properties,context:this.context}))))}async handler(e){const{separator:t="or"}=this.properties;if("or"===t){kn(this,Pt,Date.now());const t=await Promise.race(En(this,It).map((t=>t.handler(e))));if(t!==Wn)return t;if(En(this,Pt)&&Date.now()-En(this,Pt)t.handler(e))))).includes(Wn))return Wn;else return Un;else zn(t)}},[An.AwaitWebPushConsent]:class extends Ta{constructor(){super(...arguments),Cn(this,br),Cn(this,Pr),Cn(this,Er),this.type=An.AwaitWebPushConsent,this.outs=Hl.getNodeOutsInstance(An.AwaitWebPushConsent)}async handler(){const{pid:e}=this.properties;if("Notification"in window){if("denied"===window.Notification.permission)return Wn;else if("granted"===window.Notification.permission)if(Ul.getCookie(ca.NotificationConsentAcceptedFromPrompt)===e||"any"===e)return Un;else return Wn;else if("default"===window.Notification.permission){const t=await Promise.race([Dn(this,br,Sr).call(this),Dn(this,Er,Cr).call(this),Dn(this,Pr,Ir).call(this)]);if(t instanceof jl)if(t.promptId===e||"any"===e)return Un;else return this.handler();else if(t instanceof Ml)if(t.promptId===e)return Wn;else return this.handler()}}else return Wn}},[An.FilterSubscriber]:class extends Da{constructor(){super(...arguments),this.type=An.FilterSubscriber,this.outs=Hl.getNodeOutsInstance(An.FilterSubscriber)}async handler(){return await(async()=>{let e="1"===Ln("gaIsValuable");if(pa.canUseBackendForSubscriberIdentification())try{e=(await Wa.getVisitorData()).isConfirmedIdentifiedVisitor}catch(t){Rn.error("Failed to load subscriber data",t)}return e})()?Un:Wn}},[An.FilterDevice]:class extends Da{constructor(){super(...arguments),this.type=An.FilterDevice,this.outs=Hl.getNodeOutsInstance(An.FilterDevice)}handler(){const{deviceType:e}=this.properties,t=ra(us,Ba).getDeviceType();if(e.includes(t))return Promise.resolve(Un);else return Promise.resolve(Wn)}},[An.FilterLocation]:class extends Da{constructor(){super(...arguments),this.type=An.FilterLocation,this.outs=Hl.getNodeOutsInstance(An.FilterLocation)}handler(){return new Promise((async e=>{let{locations:t}=this.properties;if(null==t?void 0:t.length){if(t=(Array.isArray(t)?t:[t]).map((e=>e.toLowerCase())),t.includes(Io.All))return e(Un),void 0;try{const r=(await ra(Ga,Ha).getVisitorCountryCode()).toLowerCase();if(t.includes(r))e(Un);else e(Wn)}catch(r){if(r.status===Ka)e(Wn);Rn.error(r)}}else e(Un)}))}},[An.FilterUrl]:class extends Da{constructor(){super(...arguments),this.type=An.FilterUrl,this.outs=Hl.getNodeOutsInstance(An.FilterUrl)}handler(){if("urls"in(e=this.properties)&&Array.isArray(e.urls)&&e.urls.every((e=>"string"==typeof e))){const{urls:e}=this.properties;if(vu(document.location.href,e))return Promise.resolve(Un);else return Promise.resolve(Wn)}else if(bu.create({...this.properties,currentUrl:window.location.href}).isOnCurrentUrl())return Promise.resolve(Un);else return Promise.resolve(Wn);var e}},[An.FilterTime]:class extends Da{constructor(){super(...arguments),this.type=An.FilterTime,this.outs=Hl.getNodeOutsInstance(An.FilterVisit)}handler(){const{beforeTime:e,afterTime:t}=this.properties,r=Date.now();let i=true,n=true;if(null===e&&null===t)return Promise.resolve(Un);if(this.validateProperties(),e)i=e>r;if(t)n=r>t;if(i&&n)return Promise.resolve(Un);else return Promise.resolve(Wn)}validateProperties(){const{afterTime:e,beforeTime:t}=this.properties,r="number"==typeof e,i="number"==typeof t;if(e&&!r||t&&!i||(r&&i?e>=t:false))throw new Xa}},[An.FilterECommerceActivity]:class extends Da{constructor(){super(...arguments),this.type=An.FilterECommerceActivity,this.outs=Hl.getNodeOutsInstance(An.FilterECommerceActivity)}async handler(){var e,t,r;const i=0===Object.keys(this.properties).length;let n=i,o=i,s=i,a=i;if(this.properties.productOrCategoryView)n=await async function(e){const{modifiers:t}=e;return Lu.checkECommerceEventModificators({eventTypes:[Xn.ViewItem,Xn.ViewCategory],modificators:(null==t?void 0:t.rules.length)?t:{separator:Vu.Or,rules:[{type:_u.EventsAmount,comparisonOperator:Ou.GreaterThanOrEqual,amount:1}]},pastEventsCheckFn:t=>(async(e,t)=>{const{product:r,category:i}=t;let n=false;if(Au(e)){const{data:{product:{id:i},categories:o}}=e;if("any"===r)n=true;else if("any"===t.productCategories&&r)n=true;else if(Array.isArray(t.productCategories)&&Array.isArray(o)&&o.some((e=>t.productCategories.includes(e.id))))n=true;else n=null==r?void 0:r.includes(i)}else if(Tu(e)){const{data:{id:t}}=e;if("any"===i)n=true;else n=null==i?void 0:i.includes(t)}if(n)pa.eventBus.publish(ma.UserECommerceEventMatchedByECommerceElement,e);return n})(t,e)})}(this.properties.productOrCategoryView);if((null==(e=this.properties.likeItem)?void 0:e.product.length)>0)o=await async function(e){const t=(await Mc.getPopupECommerceEvents((t=>((e,t)=>{if(Nu(e)||Fu(e,Xn.UnlikeItem)){const{product:r,date:i}=t,{product:{id:n}}=e.data;if(r===Ao.AnyProductLiked)return true;else if(!r.includes(n))return false;return Cu(e,i,{ignoreToDateInDateRange:true})}})(t,e)))).reduce(((e,t)=>(e[t.data.product.id].push(t),e)),jn([]));let r=Object.values(t).filter(Su);if(e.date)r=r.map((t=>t.filter((t=>Cu(t,e.date)))));return r.some((e=>e.some((e=>{const t=e.eventType===Xn.LikeItem;if(t)pa.eventBus.publish(ma.UserECommerceEventMatchedByECommerceElement,e);return t}))))}(this.properties.likeItem);if(Object.keys((null==(t=this.properties.orderPlaced)?void 0:t.condition)||{}).length>0)s=await async function(e){return(await Mc.getPopupECommerceEvents((t=>((e,t)=>{if(Uu(e))return Eu(t,e)})(t,e)))).length>0}(this.properties.orderPlaced);if(Object.keys((null==(r=this.properties.cartUpdated)?void 0:r.condition)||{}).length>0)a=await async function(e){const[t,r]=await Promise.all([Mc.getPopupECommerceEvents((t=>((e,t)=>{if(Wu(e))return Eu(t,e)})(t,e))),Mc.getPopupECommerceEvents((()=>true))]);return t.filter((e=>!r.find((t=>t.data.cartId===e.data.cartId&&t.time>e.time)))).length>0}(this.properties.cartUpdated);return n||o||s||a?Un:Wn}},[An.FilterUniqueSessionVisit]:class extends Da{constructor(){super(...arguments),this.outs=Hl.getNodeOutsInstance(An.FilterUniqueSessionVisit),this.type=An.FilterUniqueSessionVisit}handler(){return Promise.resolve(Ca.hasElementBeenVisited(this.id)?Wn:Un)}},[An.FilterVisit]:class extends Da{constructor(){super(...arguments),this.type=An.FilterVisit,this.outs=Hl.getNodeOutsInstance(An.FilterVisit)}async handler(){const{frequency:e,frequencyDaysNumber:t,urlPath:r,visitors:i}=this.properties;return await Oc.validateVisitorVisits({frequency:e,visitorType:i,frequencyDaysNumber:t,urlPath:r})?Un:Wn}},[An.FilterPopup]:class extends Da{constructor(){super(...arguments),this.type=An.FilterPopup,this.outs=Hl.getNodeOutsInstance(An.FilterPopup)}async handler(){const{popupId:e,showIfNotCloseBefore:t,showIfNotSubmittedBefore:r,showIfSeenLessThanAmount:i}=this.properties;if(!(await this.shouldPassFrequencyConditionCheck()))return Wn;if(t&&await cu().hasPopupBeenClosedBefore(e))return Wn;if(r&&await cu().hasPopupBeenSubmittedBefore(e))return Wn;if(i&&await cu().getPopupImpressionsAmount(e)>=i)return Wn;else return Un}async shouldPassFrequencyConditionCheck(){const{showEveryDays:e,frequency:t,popupId:r}=this.properties;if("session"===t)return!(await cu().hasPopupBeenSeenInSession(r));if("everyDays"===t&&e){const t=await cu().getLastPopupImpression(r);if(t)return xa(t.getTime(),e);else return true}return true}},[An.ReactScroll]:class extends Da{constructor(){super(...arguments),this.type=An.ReactScroll,this.outs=Hl.getNodeOutsInstance(An.ReactScroll)}handler(){if(this.shouldProcessHandler()){const{selector:e}=this.properties,t=document.querySelector(e);if(t)return t.scrollIntoView({behavior:"smooth"}),Promise.resolve(Un)}}},[An.ReactRedirect]:class extends Da{constructor(){super(...arguments),this.type=An.ReactRedirect,this.outs=Hl.getNodeOutsInstance(An.ReactRedirect)}handler(){if(this.shouldProcessHandler()){const{url:e}=this.properties;return window.location.assign(e),Promise.resolve(void 0)}}},[An.ReactDelay]:class extends Da{constructor(){super(...arguments),this.type=An.ReactDelay,this.outs=Hl.getNodeOutsInstance(An.ReactDelay)}async handler(){const{delay:e}=this.properties;return await Va(e),Un}},[An.ReactPopup]:class extends Da{constructor(){super(...arguments),Cn(this,rt,void 0),kn(this,rt,false),this.type=An.ReactPopup,this.outs=Hl.getNodeOutsInstance(An.ReactPopup)}async handler(){var e;const{env:t,id:r,mode:i}=this.properties;if(i===ro.Inline)return await(null==(e=window.PopupsRenderer)?void 0:e.renderCustomElement(r)),Un;if(await pu.attachPopupLibrary(),window.PopupsRenderer)if(this.shouldProcessHandler()){if(!En(this,rt))this.attachPopupEvents();try{if(await window.PopupsRenderer.renderPopupFromId(r,{env:window.PopupsRenderer.GeoEnvironment[t]}),!this.context.isJourneyGraph)await this.waitForPopupClose();return Un}catch(n){return Rn.error(n),Un}}}attachPopupEvents(){window.PopupsRenderer.registerEventSubscriber((e=>{if(e instanceof window.PopupsRenderer.PopupEvents.Close)this.closePopupHandler(e);if(e instanceof window.PopupsRenderer.PopupEvents.BodyView)this.showPopupHandler();if(e instanceof window.PopupsRenderer.PopupEvents.FormLead)this.submitPopupHandler()})),kn(this,rt,true)}waitForPopupClose(){const e=new AbortController;return new Promise((t=>{du.on(lu.PopupClose,(r=>{if(r===this.properties.id)t(),e.abort()}),{signal:e.signal})}))}closePopupHandler(e){if(e.entityId===this.properties.id)cu().registerPopupClose(this.properties.id),du.notifyPopupClose(this.properties.id)}showPopupHandler(){cu().registerPopupView(this.properties.id),du.notifyPopupShow(this.properties.id)}submitPopupHandler(){cu().registerPopupSubmit(this.properties.id)}},[An.ReactSendToBackend]:class extends Da{constructor(){super(...arguments),this.type=An.ReactSendToBackend,this.outs=Hl.getNodeOutsInstance(An.ReactSendToBackend)}async handler(){if(this.shouldProcessHandler())return Promise.resolve(Fn)}},[An.ReactSendWebPush]:class extends Da{constructor(){super(...arguments),this.type=An.ReactSendWebPush,this.outs=Hl.getNodeOutsInstance(An.ReactSendWebPush)}async handler(e){const{messageId:t}=this.properties,{journeyVo:r,type:i}=this.context.calculateJourneyStateForNextNode(e,this,Un);if(_l.isPermissionPermanentlyDenied())return Wn;try{return rl.saveCallbackForServiceWorker({senderId:`${this.id}-${e.journey.uuid}`,apiCallbackData:this.context.calculateTransitionsForNextNodeFromNode(e,this,Un),dbCallbackData:{operationType:i,data:r},messageId:t}).catch((e=>{Rn.error("Error while saving callback data for sw",e)})),await rl.waitForWebPushReceptionConfirmation(t),Un}catch(n){if(n instanceof il)return Wn;throw n}}},[An.ReactCollectWebPushConsent]:class extends Da{constructor(){super(...arguments),this.type=An.ReactCollectWebPushConsent,this.outs=Hl.getNodeOutsInstance(An.ReactCollectWebPushConsent)}async handler(){const{customPromptRejectionDuration:e=ua.OneYear,pid:t}=this.properties;return await Ll.collectPushNotificationSubscription(t,e)?Un:Wn}}},zl={[An.AwaitClick]:Bl,[An.AwaitScroll]:Bl,[An.AwaitExit]:Bl,[An.AwaitInactivity]:Bl,[An.AwaitECommerceActivity]:Bl,[An.AwaitMergedNodes]:Bl,[An.AwaitWebPushConsent]:Bl,[An.FilterUrl]:Bl,[An.FilterSubscriber]:Bl,[An.FilterDevice]:Bl,[An.FilterLocation]:Bl,[An.FilterECommerceActivity]:Bl,[An.FilterUniqueSessionVisit]:Bl,[An.FilterTime]:Bl,[An.FilterVisit]:Bl,[An.FilterPopup]:Bl,[An.ReactDelay]:Jl,[An.ReactScroll]:Jl,[An.ReactRedirect]:Gl,[An.ReactPopup]:Jl,[An.ReactSendToBackend]:$l,[An.ReactSendWebPush]:Bl,[An.ReactCollectWebPushConsent]:Bl};class Hl{static getNodeInstance(e,t){return new ql[e](t)}static getNodeOutsInstance(e){return zl[e]}}function Kl(e){return"object"==typeof e&&null!==e&&"id"in e&&"status"in e&&"starting"in e}function Xl(e){var t;switch(e){case uo.TransferToBackend:return"backend_transfer";case uo.ReactSendWebPush:return"react_web_push";default:return null==(t=/(?filter|react|await)_.*/g.exec(e))?void 0:t.groups.type}}function Yl(e){switch(e.type){case uo.TransferToBackend:return e.data;case uo.ReactSendWebPush:return{message_encoded_id:e.data.nid};default:return{upstream:null}}}class Zl{constructor({journey:e,transitions:t,workflowEncodedId:r,graphEncodedId:i,pass_through_params:n}){this.journey=e,this.transitions=t,this.pass_through_params=n,this.graph={encodedId:i},this.workflow={encodedId:r}}static create(e){return new Zl(e)}addGlobalExitToLastTransition(){if(this.transitions.length){const e=this.transitions.at(-1);delete e.entered,e.leave.stats[e.leave.path]=[...new Set([...e.leave.stats[e.leave.path],"globalExit"])]}}toJSON(){const{pass_through_params:e,...t}=this;return{...t,...e.shopId&&(e.category_id.length||e.product_id.length)?{pass_through_params:e}:{}}}}kr=new WeakMap,Dr=new WeakMap,Tr=new WeakMap,Ar=new WeakMap,Nr=new WeakMap,Ur=new WeakSet,Wr=function(e){const t=e.filter((e=>{var t;return e.from.externalId!==(null==(t=e.to)?void 0:t.externalId)})).map(En(this,Fr)).filter(Boolean),{wId:r,id:i}=En(this,kr);return Zl.create({workflowEncodedId:r,graphEncodedId:i,journey:En(this,Dr).journey,pass_through_params:En(this,Dr).pass_through_params.toSerializedForApiJson(),transitions:t})},Fr=new WeakMap,_r=new WeakSet,Vr=function(e){var t,r,i,n,o,s,a;const c=En(this,Fr).call(this,e),u=(null==(t=e.to)?void 0:t.nodeTypeGroup)===Tn.Await,l=null==(i=null==(r=c.entered)?void 0:r.element)?void 0:i.starting,d=null==(o=null==(n=c.leave)?void 0:n.element)?void 0:o.starting,p=(null==(s=e.to)?void 0:s.nodeTypeGroup)===Tn.BackendTransfer,h=(null==(a=e.to)?void 0:a.type)===An.ReactSendWebPush;if(p||h)return true;if(u&&!l)return true;if(!c.entered&&!d)return true;else return false};let Ql=class e{constructor(e,t){Cn(this,Ur),Cn(this,_r),Cn(this,kr,void 0),Cn(this,Dr,void 0),Cn(this,Tr,[]),Cn(this,Ar,false),Cn(this,Nr,(e=>{const t=Dn(this,Ur,Wr).call(this,e);if(En(this,Ar))t.addGlobalExitToLastTransition();return el.sendVisitorTransitions(t.toJSON())})),Cn(this,Fr,(e=>{var t,r,i;const{fromPathKey:n,from:o,to:s,transitionTime:a,reason:c}=e,u={reason:c},l=En(this,kr).originalGraph.nodes.find((e=>e.id===o.externalId)),d=s?En(this,kr).originalGraph.nodes.find((e=>e.id===s.externalId)):null,p=En(this,kr).originalGraph.transitions.find((e=>e.from===l.id&&e.to===(null==d?void 0:d.id)));let h;if(En(this,kr).outsMap[o.externalId])h=En(this,kr).outsMap[o.externalId][n];const m=(null==p?void 0:p.key)??h??n;if(u.leave={node:{id:l.id},path:m,occurred_at:a,element:l.element,stats:{...(null==(r=null==(t=l.stats)?void 0:t.transitions)?void 0:r[m])?{[m]:l.stats.transitions[m]}:{}}},d)if(u.entered={node:{id:d.id,type:Xl(d.type),data:Yl(d)},occurred_at:a,element:d.element},d.type!==uo.TransferToBackend)u.entered.stats=(null==(i=d.stats)?void 0:i.enters)?{input:d.stats.enters.input}:{};return u})),kn(this,kr,e),kn(this,Dr,t)}get journey(){return En(this,Dr)}static create(t,r){return new e(t,r)}async addTransition(e){En(this,Tr).push(e)}async flushTransitionsIfNeeded(e){if(Dn(this,_r,Vr).call(this,e)){const e=[...En(this,Tr)];kn(this,Tr,[]),await Oa((()=>En(this,Nr).call(this,e)),{multiplyDelay:true,maxAttempts:10})}}getCurrentVisitorTransitionsVoCopyWithTransitions(e){const t=[...En(this,Tr),...e||[]];return Dn(this,Ur,Wr).call(this,t)}addGlobalExitToLastTransitionBeforeSend(){kn(this,Ar,true)}};const ed=1e3;xr=new WeakMap,Or=new WeakSet,Rr=function(e){En(this,xr).set(e,Date.now())};const td=new class{constructor(){Cn(this,Or),Cn(this,xr,new Map)}isNodeUsedInLoop(e,t){const r=`${e.id}-${t}`,i=En(this,xr).get(r);if(!i||Date.now()-i>ed)return Dn(this,Or,Rr).call(this,r),false;else return Rn.log(`JourneyLoopPrevention: Node overused. Journey will be stopped and removed because it violates fair usage policy. Node data:`,e),true}resetNodes(){En(this,xr).clear()}},rd=new class{publishEvent(e,t){if(window.__externalEventsEnabled)window.dispatchEvent(new CustomEvent(e,{detail:t}))}},id=new class{init(){window.__currentlyProcessedNodes=[]}publishCurrentlyProcessedNode(e){window.__currentlyProcessedNodes.push(e),rd.publishEvent("web_flow_node_process",window.__currentlyProcessedNodes)}};id.init();var nd=(e=>(e["WebFlowStarted"]="_grWebFlowStarted",e))(nd||{});Lr=new WeakSet,Mr=()=>{window._grTestWebFlowStarted=true};const od=new class{constructor(){Cn(this,Lr)}dispatchSandboxEvent(...[e,t]){if(window._grTestSandbox)switch(window.document.documentElement.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:true,composed:true})),e){case"_grWebFlowStarted":return Dn(this,Lr,Mr).call(this)}}};class sd extends Gn{constructor({webflowSerializedData:e,visitorJourneys:t,isJourneyGraph:r}){super(),Cn(this,jr,void 0),Cn(this,Br,void 0),Cn(this,Jr,Ln(ca.visitorUuid)),Cn(this,$r,new Map),kn(this,jr,this.createWebFlowFromSerializedData(e)),kn(this,Br,t),this.isJourneyGraph=r}initVisitorFlow(){this.findStartingElements().forEach((({node:e,journey:t})=>{const r=Gu.generateRandomUuid();let i;if(Kl(En(this,jr))){if(t)i=Ia.create(t);else i=Ia.createBlank({journey:{uuid:r},visitor:{uuid:En(this,Jr)}});En(this,$r).set(i.journey.uuid,Ql.create(En(this,jr),i))}this.shouldProcessFlow(e,i).then((t=>{if(t)od.dispatchSandboxEvent(nd.WebFlowStarted),this.processFlow(e,i)}))}))}calculateTransitionsForNextNodeFromNode(e,t,r){const i=this.calculateNextTransitionForNode(t,r);return En(this,$r).get(e.journey.uuid).getCurrentVisitorTransitionsVoCopyWithTransitions([{...i}])}calculateJourneyStateForNextNode(e,t,r){var i,n;const o=this.calculateNextTransitionForNode(t,r),s=null==(i=o.to)?void 0:i.id;return{journeyVo:Ia.create({journey:{uuid:e.journey.uuid},node:{uuid:(null==(n=o.to)?void 0:n.id)||t.id},visitor:{uuid:En(this,Jr)},pass_through_params:e.pass_through_params,node_entered_at:(new Date).toISOString()},{preventAttachingListeners:true}),type:s?"put":"delete"}}calculateNextTransitionForNode(e,t){return{from:e,to:this.getNodeConnectedToNodes(e)[t],fromPathKey:t,transitionTime:null}}async processFlow(e,t){try{const r=(new Date).toISOString(),i=e.id===(null==t?void 0:t.node.uuid);if(t&&!i)t.updateJourneyData({node:{uuid:e.id},node_entered_at:r});if(this.isJourneyGraph)await Ea.saveVisitorJourney(t);this.processNode(e,t).then((async i=>{if(Ca.addEntry(e.id),this.isJourneyGraph)await Ea.saveNodeHistoryEntry(e.id,En(this,Jr),r);if(i&&await this.shouldProcessFlow(i,t))this.processFlow(i,t);else if(!i&&this.isJourneyGraph&&e.type!==An.ReactSendToBackend)t.terminate(),await Ea.clearVisitorJourney(t)})).catch((e=>{Rn.error(e)}))}catch(r){Rn.error(r)}}async processNode(e,t){const r=this.getNodeConnectedToNodes(e);Rn.log(`Processing node ${e.type} with id: ${e.id}`,e),id.publishCurrentlyProcessedNode({nodeId:e.id,journeyUuid:null==t?void 0:t.journey.uuid,pathKey:"input"}),e.startUpstreamCalculation(t);const i=await Promise.race([e.waitForUpstreamPassed(),e.handler(t)]);let n;if(i===Symbol.for("upstreamPassed"))n=Wn;else n=i,e.cancelUpstreamToResolveWait();const o=r[n];if(this.isJourneyGraph)if(e.type!==An.ReactSendToBackend){const r=o?td.isNodeUsedInLoop(o,t.journey.uuid):false,i=o?await o.validateRecurrentConditionForJourney(t):true,s={from:e,to:r?void 0:o,fromPathKey:r?"exit":n,transitionTime:(new Date).toISOString(),reason:r?"loop":void 0},a=En(this,$r).get(t.journey.uuid);if(await a.addTransition(s),!i&&o.recurrent.failStrategy===co.RemoveLastTransitionNodeEnter)a.addGlobalExitToLastTransitionBeforeSend();if(await a.flushTransitionsIfNeeded(s),r)return}return this.emit(Il.NodeProcessed,{id:e.id,pathKey:n}),Rn.log(`Finished processing node ${e.type} with id: ${e.id} with result ${n}`),id.publishCurrentlyProcessedNode({nodeId:e.id,journeyUuid:null==t?void 0:t.journey.uuid,pathKey:n}),o}getNodeConnectedToNodes(e){return En(this,jr).connections.filter((t=>t.from===e.id)).reduce(((e,t)=>(e[t.fromPathKey]=En(this,jr).nodes.find((e=>e.id===t.to)),e)),{})}findStartingElements(){var e;if(Kl(En(this,jr))){const{starting:t,nodes:r,startAt:i,stopAt:n}=En(this,jr),o=null==(e=En(this,Br))?void 0:e.length;if(!(({startAt:e,stopAt:t})=>{const r=Date.parse(e),i=Date.parse(t),n=Date.now();if(!Number.isNaN(r)&&r>n)return false;if(!Number.isNaN(i)&&n>i)return false;else return true})({startAt:i,stopAt:n}))return[];if(o)return En(this,Br).map((e=>({node:r.find((t=>t.id===e.node.uuid)),journey:e}))).filter((e=>e.node.type!==An.ReactSendToBackend));if(t.length)return r.filter((e=>t.includes(e.externalId))).map((e=>({node:e})));else return[]}const{nodes:t,connections:r}=En(this,jr);return t.filter((e=>!r.some((t=>t.to===e.id)))).map((e=>({node:e})))}createWebFlowFromSerializedData(e){return{...e,nodes:e.nodes.map((e=>Hl.getNodeInstance(e.type,{...e,context:this})))}}async shouldProcessFlow(e,t){if(this.isJourneyGraph)return e.validateRecurrentConditionForJourney(t);else return true}}jr=new WeakMap,Br=new WeakMap,Jr=new WeakMap,$r=new WeakMap;class ad{fetchFlowDataFromRemote(e){return fetch(e).then((async e=>{var t;if(!e.ok){const r=null==(t=e.headers.get("Content-Type"))?void 0:t.includes("application/json");return Promise.reject(await(r?e.json():e.text()))}const r=await e.json();if(!!(i=r)&&"object"==typeof i&&"connections"in i&&"nodes"in i&&Array.isArray(i["nodes"])&&i["nodes"].length>0)return r;else return Rn.error("Fetched data is not a valid web flow data",r),null;var i})).catch((e=>(Rn.error("Failed to fetch web flow data",e),null)))}}class cd{static getLastFullNDaysTimestamp(e){const t=new Date(Date.now()-e*oo.OneDay);return t.setHours(0,0,0,0),t.getTime()}}function ud(e){return{...dd(e),...pd(e),...hd(e),...md(e)}}function ld(e){const t={},{cartUpdated:r,orderPlaced:i,likeItem:n,productOrCategoryView:o}=e;if(e[Fo.ViewProductOrCategory]||e[Fo.LikeProduct]||e[Fo.OrderPlaced]||e[Fo.CartUpdated]){if((null==o?void 0:o.product)||(null==o?void 0:o.category)){if(t.productOrCategoryView={},o.product)t.productOrCategoryView.product=o.product;if(o.category)t.productOrCategoryView.category=o.category;t.productOrCategoryView.modifiers={separator:Vu.Or,rules:[{type:_u.EventsAmount,amount:1,comparisonOperator:Ou.GreaterThanOrEqual}]};const e=t.productOrCategoryView.modifiers.rules.at(0);if(o.date)if(o.date.name===To.LastDays)e.timeFrom=cd.getLastFullNDaysTimestamp(o.date.value);else if(o.date.name===To.DateRange){if(o.date.value.from)e.timeFrom=new Date(o.date.value.from).getTime();if(o.date.value.to)e.timeTo=new Date(o.date.value.to).getTime()}if(o.amount)e.amount=o.amount.value}}else{t.productOrCategoryView={},t.productOrCategoryView.modifiers={separator:Vu.Or,rules:[{type:_u.EventsAmount,amount:1,comparisonOperator:Ou.GreaterThanOrEqual}]},t.productOrCategoryView.product=e.product,t.productOrCategoryView.category=e.category;const r=t.productOrCategoryView.modifiers.rules.at(0);if(e.amount)r.amount=e.amount.value;if(e.date)if(e.date.name===To.LastDays)r.timeFrom=cd.getLastFullNDaysTimestamp(e.date.value);else if(e.date.name===To.DateRange){if(e.date.value.from)r.timeFrom=new Date(e.date.value.from).getTime();if(e.date.value.to)r.timeTo=new Date(e.date.value.to).getTime()}}if(n)if(t.likeItem={product:n.product},n.date)t.likeItem.date=n.date;if(i){const{product:e,productsAmount:r,category:n,price:o,date:s}=i;if(t.orderPlaced={condition:{}},e)t.orderPlaced.condition.product={id:e};if(n)t.orderPlaced.condition.category={id:n};if(r)t.orderPlaced.condition.amount={condition:r.name,value:r.value};if(o)t.orderPlaced.condition.price={condition:o.name,value:o.value};if(s)t.orderPlaced.settings={date:s}}if(r){const{product:e,productsAmount:i,category:n,price:o,date:s}=r;if(t.cartUpdated={condition:{},settings:{}},e)t.cartUpdated.condition.product={id:e};if(n)t.cartUpdated.condition.category={id:n};if(i)t.cartUpdated.condition.amount={condition:i.name,value:i.value};if(o)t.cartUpdated.condition.price={condition:o.name,value:o.value};if(s)t.cartUpdated.settings={date:s}}return t}function dd(e){const t={};if(e.productOrCategoryView){if(e.productOrCategoryView.product)t.product={id:e.productOrCategoryView.product};if(e.productOrCategoryView.category)t.category={id:e.productOrCategoryView.category}}return t}function pd(e){var t;const r={};if(null==(t=e.likeItem)?void 0:t.product)r.likeProduct={product:{id:e.likeItem.product}};return r}function hd(e){const t={};if(e.orderPlaced){const{product:r,productsAmount:i,category:n,price:o}=e.orderPlaced;if(t.orderPlaced={},r)t.orderPlaced.product={id:r};if(n)t.orderPlaced.category={id:n};if(i)t.orderPlaced.amount={condition:i.name,value:i.value};if(o)t.orderPlaced.value={condition:o.name,value:o.value}}return t}function md(e){const t={};if(e.cartUpdated){const{product:r,productsAmount:i,category:n,price:o}=e.cartUpdated;if(t.cartUpdate={},r)t.cartUpdate.product={id:r};if(n)t.cartUpdate.category={id:n};if(i)t.cartUpdate.amount={condition:i.name,value:i.value};if(o)t.cartUpdate.value={condition:o.name,value:o.value}}return t}const wd=1e3;Gr=new WeakSet,qr=(e,t,r=1)=>{const i=[];for(let n=0;r>n;n++){const r=Gu.generateRandomUuid(),n={id:r,properties:{urls:t}};i.push(r),e.withNode(An.FilterUrl,n)}return i},zr=new WeakSet,Hr=(e,t)=>{const r=Gu.generateRandomUuid();return e.withNode(An.FilterLocation,{id:r,properties:{locations:t}}),r},Kr=new WeakSet,Xr=function(e,t){if(!t)return null;const{ecommerceConditions:r,conditionsLogicSeparator:i=ko.Or}=t;if(i===ko.Or){const{awaitNode:t,filterNodes:i}=Dn(this,Yr,Zr).call(this,r);if(t)e.withNode(t.type,t);for(const r of i)e.withNode(r.type,r);return{separator:ko.Or,...(null==t?void 0:t.id)&&{ecommerceActivityAwaitNodeId:t.id},...i.length&&{ecommerceActivityFilterNodeIds:i.map((e=>e.id))}}}else if(i===ko.And){const{nodesToMerge:t}=Dn(this,Qr,ei).call(this,r),i=Gu.generateRandomUuid();return e.withNode(An.AwaitMergedNodes,{id:i,properties:{separator:"and",nodesDefinition:t,leaveFalseDelay:0}}),{separator:ko.And,mergedNodeId:i}}},Yr=new WeakSet,Zr=e=>{const{filterConditions:t,awaitConditions:r}=e.reduce(((e,t)=>{const r={},i={};for(const[n,o]of Object.entries(t))if(o)if("object"==typeof o&&null!==o&&"triggerType"in o&&o.triggerType===No.FutureEvents)i[n]=o;else r[n]=o;if(Object.keys(r).length)e.filterConditions.push(r);if(Object.keys(i).length)e.awaitConditions.push(i);return e}),{filterConditions:[],awaitConditions:[]});let i;const n=t.map((e=>({id:Gu.generateRandomUuid(),type:An.FilterECommerceActivity,properties:ld(e)})));if(r.length)i={id:Gu.generateRandomUuid(),type:An.AwaitECommerceActivity,properties:{separator:"or",conditions:r.map((e=>ud(e)))}};return{awaitNode:i,filterNodes:n}},Qr=new WeakSet,ei=e=>({nodesToMerge:e.reduce(((e,t)=>{const r={},i={};for(const[s,a]of Object.entries(t))if(a)if("object"==typeof a&&null!==a&&"triggerType"in a&&a.triggerType===No.FutureEvents)r[s]=a;else i[s]=a;let n=null,o=null;if(Object.keys(r).length>0)n={id:Gu.generateRandomUuid(),type:An.AwaitECommerceActivity,properties:{separator:"or",conditions:[ud(r)]}};if(Object.keys(i).length>0)o={id:Gu.generateRandomUuid(),type:An.FilterECommerceActivity,properties:ld(i)};if(n&&o)e.push({id:Gu.generateRandomUuid(),type:An.AwaitMergedNodes,properties:{separator:"or",nodesDefinition:[o,n]}});else if(n)e.push(n);else if(o)e.push(o);return e}),[])}),ti=new WeakSet,ri=(e,t)=>{const r=Gu.generateRandomUuid(),i={id:r,properties:{deviceType:Array.isArray(t)?t:[t]}};return e.withNode(An.FilterDevice,i),r},ii=new WeakSet,ni=(e,t={})=>{const r=t.to&&new Date(t.to).getTime(),i=t.from&&new Date(t.from).getTime(),n=Gu.generateRandomUuid();return e.withNode(An.FilterTime,{id:n,properties:{beforeTime:r,afterTime:i}}),n},oi=new WeakSet,si=(e,t,r,i)=>{if((null==t?void 0:t.length)||r){let n,o,s;null==t?void 0:t.forEach((e=>{if(e.name===xo.AfterClose)n=true;if(e.name===xo.AfterSubmit)o=true;if(e.name===xo.AfterTimes)s=e.value}));const a=Gu.generateRandomUuid(),c={id:a,properties:{frequency:(null==r?void 0:r.name)||Oo.Always,...(null==r?void 0:r.name)===Oo.EveryDays&&{showEveryDays:r.value},popupId:i,showIfSeenLessThanAmount:s,showIfNotCloseBefore:n,showIfNotSubmittedBefore:o}};return e.withNode(An.FilterPopup,c),a}},ai=new WeakSet,ci=(e,t)=>{const r=Gu.generateRandomUuid();return e.withNode(An.FilterVisit,{id:r,properties:{visitors:t}}),r},ui=new WeakSet,li=function(e,t){const r=t.map((e=>Dn(this,di,pi).call(this,e))).filter(Boolean),i=t.find((e=>e.name===Vo.Click&&!e.value.showOnlyOncePerVisit));if(0===r.length)return{showWhenAwaitId:null,showWhenRecurrentClickNodeId:null};const n=Gu.generateRandomUuid(),o=i?Gu.generateRandomUuid():null;if(e.withNode(An.AwaitMergedNodes,{id:n,properties:{nodesDefinition:r,leaveFalseDelay:0}}),o)e.withNode(An.AwaitClick,{id:o,properties:{leaveFalseDelay:0,selector:i.value.selector}});return{showWhenAwaitId:n,showWhenRecurrentClickNodeId:o}},di=new WeakSet,pi=e=>{var t,r;switch(e.name){case Vo.Instantly:return null;case Vo.Delay:return{type:An.ReactDelay,properties:{delay:e.value*wd}};case Vo.Exit:return{type:An.AwaitExit,properties:{leaveFalseDelay:0,useMobileScrollBasedExitIntend:!!(null==(t=e.value)?void 0:t.useMobileScrollBasedExitIntend),useMobileHistoryBasedExitIntend:!!(null==(r=e.value)?void 0:r.useMobileHistoryBasedExitIntend)}};case Vo.Inactivity:return{type:An.AwaitInactivity,properties:{leaveFalseDelay:0,inactivityTime:e.value*wd}};case Vo.Scroll:return{type:An.AwaitScroll,properties:{leaveFalseDelay:0,selector:e.value.name===_o.Selector?e.value.value:null,percent:e.value.name===_o.Percent?e.value.value:null}};case Vo.Click:return{type:An.AwaitClick,properties:{leaveFalseDelay:0,selector:"string"==typeof e.value?e.value:e.value.selector||null}};default:zn(e)}},hi=new WeakSet,mi=(e,t,r,i)=>{const n=Gu.generateRandomUuid();return e.withNode(An.ReactPopup,{id:n,properties:{id:t,env:r,mode:i}}),n};const fd=new class{constructor(){Cn(this,Gr),Cn(this,zr),Cn(this,Kr),Cn(this,Yr),Cn(this,Qr),Cn(this,ti),Cn(this,ii),Cn(this,oi),Cn(this,ai),Cn(this,ui),Cn(this,di),Cn(this,hi)}createWebFlowForInlinePopup({popupEnv:e,popupId:t,excludedUrls:r,urls:i}){const n=Pl.create(),o=Dn(this,hi,mi).call(this,n,t,e,ro.Inline),s=Dn(this,Gr,qr).call(this,n,i);let a=null;if(Array.isArray(r)&&r.length>0)a=Dn(this,Gr,qr).call(this,n,r),n.withConnection({from:a[0],to:s[0],fromPathKey:"false"});return n.withConnection({from:s[0],to:o,fromPathKey:"true"}),n.build()}createWebFlowFromTriggerData({triggers:e,popupId:t,popupEnv:r,urls:i,excludedUrls:n}){const{location:o,device:s,visitors:a,showWhenCondition:c,dateRange:u,preventDisplay:l,frequency:d,ecommerce:p}=e,h=Pl.create(),m=Dn(this,zr,Hr).call(this,h,o),w=Dn(this,ti,ri).call(this,h,s),f=Dn(this,ai,ci).call(this,h,a),g=Dn(this,ii,ni).call(this,h,u),v=Dn(this,oi,si).call(this,h,l,d,t),{showWhenAwaitId:y,showWhenRecurrentClickNodeId:b}=Dn(this,ui,li).call(this,h,c),S=Dn(this,Kr,Xr).call(this,h,p),P=Dn(this,hi,mi).call(this,h,t,r,ro.Popup),I=Dn(this,Gr,qr).call(this,h,i);let E=null;if(Array.isArray(n)&&n.length>0)E=Dn(this,Gr,qr).call(this,h,n);if(Array.isArray(E)&&E[0])h.withConnection({from:E[0],to:I[0],fromPathKey:"false"});if(S){const{separator:e}=S;if(e===ko.Or){const{ecommerceActivityFilterNodeIds:e=[],ecommerceActivityAwaitNodeId:t}=S;if(h.withConnection({from:I[0],to:(null==e?void 0:e.length)?e[0]:t,fromPathKey:"true"}),y)h.withCascadeConnectionFalseOut({fromNodes:e,targetNode:y}).withConnection({from:y,to:m,fromPathKey:"true"});else h.withCascadeConnectionFalseOut({fromNodes:e,targetNode:m});if(t&&e.length)h.withConnection({from:e[e.length-1],to:t,fromPathKey:"false"});if(t)if(y)h.withConnection({from:t,to:y,fromPathKey:"true"}).withConnection({from:y,to:m,fromPathKey:"true"});else h.withConnection({from:t,to:m,fromPathKey:"true"})}else if(e===ko.And){const{mergedNodeId:e}=S;if(h.withConnection({from:I[0],to:e,fromPathKey:"true"}),y)h.withConnection({from:e,to:y,fromPathKey:"true"}),h.withConnection({from:y,to:m,fromPathKey:"true"});else h.withConnection({from:e,to:m,fromPathKey:"true"})}}else if(y)h.withConnection({from:I[0],to:y,fromPathKey:"true"}).withConnection({from:y,to:m,fromPathKey:"true"});else h.withConnection({from:I[0],to:m,fromPathKey:"true"});h.withConnection({from:m,to:w,fromPathKey:"true"}).withConnection({from:w,to:f,fromPathKey:"true"}).withConnection({from:f,to:g,fromPathKey:"true"});let C=g;if(v)h.withConnection({from:g,to:v,fromPathKey:"true"}),C=v;if(h.withConnection({from:C,to:P,fromPathKey:"true"}),b)h.withConnection({from:P,to:b,fromPathKey:"true"}),h.withConnection({from:b,to:g,fromPathKey:"true"});return h.build()}};wi=new WeakMap;const gd=new class extends ad{constructor(){super(...arguments),Cn(this,wi,false)}async parse({data:e,type:t,id:r}){if(t===Mu.Popup){let t;if((e=>!!e&&"object"==typeof e&&"flowDataUrl"in e)(e))t=await this.fetchFlowDataFromRemote(e.flowDataUrl);else if((e=>!!e&&"object"==typeof e&&"triggers"in e&&"urls"in e)(e)){const{env:i,...n}=e,o={popupId:r,popupEnv:i,...n};if(e.mode===ro.Inline){if(!En(this,wi))window.PopupsRenderer.registerCustomElements({lazy:true}),kn(this,wi,true);t=fd.createWebFlowForInlinePopup(o)}else t=fd.createWebFlowFromTriggerData(o)}if(pa.popupGraphs[r]={originalTriggers:e,transformedGraph:t},t)return t}}isPopupFromCurrentUrl(e){const{urls:t}=e.data;return vu(document.location.href,t)}},vd=class e{constructor(){Cn(this,gi),Cn(this,fi,new Set)}static create(){return new e}add(...e){for(const t of e)if(!Array.from(En(this,fi)).some((e=>Dn(this,gi,vi).call(this,e,t))))En(this,fi).add(t)}replace(e,t){this.remove(e),this.add(t)}remove(e){En(this,fi).delete(e)}forEach(e){En(this,fi).forEach(e)}*[Symbol.iterator](){yield*En(this,fi)}};fi=new WeakMap,gi=new WeakSet,vi=(e,t)=>t.from===e.from&&t.to===e.to&&t.key===e.key;let yd=vd;const bd=1e3*60*60;function Sd(e,t){if(e===An.ReactSendWebPush&&true===t)return{type:ao.OnceEveryAmountTime,value:bd,failStrategy:co.RemoveLastTransitionNodeEnter};else return(e=>{if(void 0===e)return{type:ao.EveryTime,value:false,failStrategy:co.RemoveLastTransitionNodeEnter};if("boolean"==typeof e)return{type:ao.EveryTime,value:e,failStrategy:co.RemoveLastTransitionNodeEnter};if(!!e&&"object"==typeof e)return e;else return})(t)}function Pd(e){const t={modifiers:{separator:Vu.Or,rules:[{type:_u.EventsAmount,amount:1,comparisonOperator:Ou.GreaterThanOrEqual}]}};if(e){if("and"===e.separator)t.modifiers.separator=Vu.And;else t.modifiers.separator=Vu.Or;if(Array.isArray(e.rules)&&e.rules.length>0){t.modifiers.rules=[];for(const r of e.rules)switch(r.type){case"amount":t.modifiers.rules.push({type:_u.EventsAmount,comparisonOperator:r.operator,amount:r.value,...Id(e)});break;case"duration":t.modifiers.rules.push({type:_u.EventsTimeSpent,totalEventsDuration:r.value*oo.OneSecond,...Id(e)});break;default:zn(r)}}else t.modifiers.rules.push({type:_u.EventsAmount,amount:1,comparisonOperator:Ou.GreaterThanOrEqual})}return t}function Id(e){if(e.activityPeriod)switch(e.activityPeriod.type){case"lastDays":return{timeFrom:cd.getLastFullNDaysTimestamp(e.activityPeriod.value)};default:zn(e.activityPeriod.type)}return{}}function Ed(e){return{quantifier:"or",upstreams:Object.entries(e||{}).filter((e=>{const t=e[1];if(Array.isArray(t))return!!t.length;else return null!==t})).map((([e,t])=>({type:e,value:t})))}}const Cd=1e3*60;yi=new WeakMap,bi=new WeakMap,Si=new WeakMap,Pi=new WeakMap,Ii=new WeakSet,Ei=(e,t)=>t.filter((t=>t.from===e.id)),Ci=new WeakSet,ki=function(e){return e.map((e=>({from:En(this,bi).has(e.from)?En(this,bi).get(e.from):e.from,to:En(this,Si).has(e.to)?En(this,Si).get(e.to):e.to,fromPathKey:e.key})))},Di=new WeakSet,Ti=function(e,t,r){const{id:i,data:n,isRecurrent:o,upstream:s}=e;r.withNode(An.ReactSendWebPush,{id:i,externalId:i,recurrent:Sd(An.ReactSendWebPush,o),upstream:Ed(s),properties:{messageId:n.nid}}),En(this,Pi).add(...t)},Ai=new WeakSet,Ni=function(e,t,r){const{id:i,data:n,isRecurrent:o,upstream:s}=e;r.withNode(An.ReactCollectWebPushConsent,{id:i,externalId:i,recurrent:Sd(An.ReactCollectWebPushConsent,o),upstream:Ed(s),properties:{pid:n.pid,customPromptRejectionDuration:n.denyBefore*Cd}}),En(this,Pi).add(...t)},Ui=new WeakSet,Wi=function(e,t,r){const{id:i,data:n,isRecurrent:o,upstream:s}=e,{pid:a,concerns:c}=n;r.withNode(An.AwaitWebPushConsent,{id:i,externalId:i,recurrent:Sd(An.AwaitWebPushConsent,o),upstream:Ed(s),properties:{pid:"specific_prompt"===c?a:"any",leaveFalseDelay:0}}),En(this,Pi).add(...t)},Fi=new WeakSet,_i=function(e,t,r){const{id:i,data:n,isRecurrent:o,upstream:s}=e,{concerns:a,url:c,params:u}=n,l="includes"===a?i:Gu.generateRandomUuid();let d;if(En(this,bi).set(i,l),En(this,Si).set(i,l),u){const e=c.startsWith("http://")||c.startsWith("https://")?c:`https://${c}`;d=new URL(e)}const p=u?{baseUrl:d.host,path:d.pathname,queryParamsSelectionRule:"all",queryParams:u.reduce(((e,t)=>({...e,[t.name]:{value:t.value,operator:t.operator}})),{})}:{urls:Array.isArray(c)?c:[c]};switch(r.withNode(An.FilterUrl,{id:l,externalId:i,upstream:Ed(s),recurrent:Sd(An.FilterUrl,o),properties:p}),e.data.concerns){case"excludes":En(this,Pi).add(...t.map((e=>({from:e.from,to:e.to,key:"false"===e.key?"true":"false"})))),En(this,yi)[i]={true:"false",false:"true"};break;case"includes":En(this,Pi).add(...t);break;default:zn(e.data.concerns)}},Vi=new WeakSet,xi=function(e,t,r){const{id:i,data:n,isRecurrent:o,upstream:s}=e;if("country_code"===n.contestType){const{countryCodes:e}=n;r.withNode(An.FilterLocation,{id:i,externalId:i,recurrent:Sd(An.FilterLocation,o),upstream:Ed(s),properties:{locations:e}}),En(this,Pi).add(...t)}else zn(n.contestType)},Oi=new WeakSet,Ri=(e,t)=>{const{id:r,data:i,isRecurrent:n,upstream:o}=e;t.withNode(An.ReactSendToBackend,{id:r,externalId:r,recurrent:Sd(An.ReactSendToBackend,n),upstream:Ed(o),properties:{automation_node:{id:i.destination_node_id}}})},Li=new WeakSet,Mi=function(e,t,r){const{id:i,data:{value:n},isRecurrent:o,upstream:s}=e,a="yes"===n?i:Gu.generateRandomUuid();if(En(this,bi).set(i,a),En(this,Si).set(i,a),r.withNode(An.FilterSubscriber,{id:a,externalId:i,recurrent:Sd(An.FilterSubscriber,o),upstream:Ed(s),properties:{}}),"yes"===n)En(this,Pi).add(...t);else if("no"===n)En(this,Pi).add(...t.map((e=>({from:e.from,to:e.to,key:"false"===e.key?"true":"false"})))),En(this,yi)[i]={true:"false",false:"true"};else zn(n)},ji=new WeakSet,Bi=function(e,t,r){const{id:i,data:n,isRecurrent:o,upstream:s}=e;r.withNode(An.AwaitScroll,{id:i,externalId:i,recurrent:Sd(An.AwaitScroll,o),upstream:Ed(s),properties:{percent:n.percent,leaveFalseDelay:0}}),En(this,Pi).add(...t)},Ji=new WeakSet,$i=function(e,t,r){const{id:i,data:n,isRecurrent:o,upstream:s}=e,{popupId:a,popupEnv:c}=n;r.withNode(An.ReactPopup,{id:i,externalId:i,recurrent:Sd(An.ReactPopup,o),upstream:Ed(s),properties:{id:a,env:c,mode:ro.Popup}}),En(this,Pi).add(...t)},Gi=new WeakSet,qi=function(e,t,r){const{id:i,data:n,isRecurrent:o,upstream:s}=e,{env:a,popup_uuid:c}=n;r.withNode(An.ReactPopup,{id:i,externalId:i,recurrent:Sd(An.ReactPopup,o),upstream:Ed(s),properties:{id:c,env:a,mode:ro.Popup}}),En(this,Pi).add(...t)},zi=new WeakSet,Hi=function(e,t,r){const{id:i,data:n,isRecurrent:o,upstream:s}=e,{product:a}=n;r.withNode(An.AwaitECommerceActivity,{id:i,externalId:i,recurrent:Sd(An.AwaitECommerceActivity,o),upstream:Ed(s),properties:{conditions:[{likeProduct:{product:a}}],separator:"or",leaveFalseDelay:0}}),En(this,Pi).add(...t)},Ki=new WeakSet,Xi=function(e,t,r){const{id:i,data:n,isRecurrent:o,upstream:s}=e,{device:a}=n;r.withNode(An.FilterDevice,{id:i,externalId:i,recurrent:Sd(An.FilterDevice,o),upstream:Ed(s),properties:{deviceType:a}}),En(this,Pi).add(...t)},Yi=new WeakSet,Zi=function(e,t,r){const{id:i,isRecurrent:n,upstream:o}=e;r.withNode(An.FilterVisit,{id:i,externalId:i,recurrent:Sd(An.FilterVisit,n),upstream:Ed(o),properties:{frequency:Ac.Always,visitors:Po.Returning}}),En(this,Pi).add(...t)},Qi=new WeakSet,en=function(e,t,r){const{id:i,data:n,isRecurrent:o,upstream:s}=e,{actions:a,logic_operator:c}=n;r.withNode(An.AwaitMergedNodes,{id:i,externalId:i,recurrent:Sd(An.AwaitMergedNodes,o),upstream:Ed(s),properties:{separator:null==c?void 0:c.toLowerCase(),leaveFalseDelay:0,nodesDefinition:a.map((e=>{if("scroll_to_element"===e.actionType)return{type:An.AwaitScroll,properties:{selector:e.value}};if("scroll_percentage"===e.actionType)return{type:An.AwaitScroll,properties:{percent:e.value}};else return{type:An.AwaitClick,properties:{selector:e.value}}}))}}),En(this,Pi).add(...t)},tn=new WeakSet,rn=function({webGraphOriginalIdToGeneratedNodeIdTo:e,webGraphOriginalIdToGeneratedNodeIdFrom:t,nodesConnections:r}){if(t)for(const[i,n]of t.entries())En(this,bi).set(i,n);if(e)for(const[i,n]of e.entries())En(this,Si).set(i,n);En(this,Pi).add(...r)};let kd=class e{constructor(){Cn(this,Ii),Cn(this,Ci),Cn(this,Di),Cn(this,Ai),Cn(this,Ui),Cn(this,Fi),Cn(this,Vi),Cn(this,Oi),Cn(this,Li),Cn(this,ji),Cn(this,Ji),Cn(this,Gi),Cn(this,zi),Cn(this,Ki),Cn(this,Yi),Cn(this,Qi),Cn(this,tn),Cn(this,yi,{}),Cn(this,bi,new Map),Cn(this,Si,new Map),Cn(this,Pi,yd.create())}static create(){return new e}transformEditorGraphToWebGraph(e){const{transitions:t,nodes:r,...i}=e,n=Pl.create({automationJourney:i});r.forEach((e=>{const r=Dn(this,Ii,Ei).call(this,e,t),{type:i}=e;switch(i){case uo.ReactSendWebPush:Dn(this,Di,Ti).call(this,e,r,n);break;case uo.ReactCollectWebPushConsent:Dn(this,Ai,Ni).call(this,e,r,n);break;case uo.FilterWebUrl:Dn(this,Fi,_i).call(this,e,r,n);break;case uo.TransferToBackend:Dn(this,Oi,Ri).call(this,e,n);break;case uo.ShowPopup:Dn(this,Ji,$i).call(this,e,r,n);break;case uo.FilterWebSubscribers:Dn(this,Li,Mi).call(this,e,r,n);break;case uo.AwaitScroll:Dn(this,ji,Bi).call(this,e,r,n);break;case uo.ConditionProductViewed:{const{nodesConnections:t,webGraphOriginalIdToGeneratedNodeIdFrom:i,webGraphOriginalIdToGeneratedNodeIdTo:o}=(({builder:e,nodesConnections:t,node:r})=>{const{id:i,data:n,isRecurrent:o,upstream:s}=r,{product:a,category:c,modifiers:u,filterMode:l}=n,d=l?Gu.generateRandomUuid():i,p=l?Gu.generateRandomUuid():null,h=Pd(u),m=Ed(s);if(l)e.withNode(An.FilterECommerceActivity,{id:p,externalId:i,recurrent:Sd(An.FilterECommerceActivity,o),upstream:m,properties:{productOrCategoryView:{...(null==a?void 0:a.id)?{product:a.id}:null,...(null==c?void 0:c.id)?{productCategories:c.id}:null,modifiers:h.modifiers}}});e.withNode(An.AwaitECommerceActivity,{id:d,externalId:i,recurrent:Sd(An.AwaitECommerceActivity,o),upstream:m,properties:{conditions:[{product:{...(null==a?void 0:a.id)?{id:a.id}:null,...(null==c?void 0:c.id)?{category:c.id}:null,modifiers:h.modifiers}}],separator:"or",leaveFalseDelay:0}});const w=t.filter((e=>e.to===i)),f=t.find((e=>e.from===i&&"true"===e.key));if(l){const e=[],t=new Map,r=new Map;t.set(i,d),r.set(i,p);for(const i of w)e.push({from:i.from,to:p,key:i.key});if(e.push({from:p,to:d,key:"false"}),f)e.push({from:p,to:f.to,key:"true"}),e.push({from:d,to:f.to,key:"true"});return{nodesConnections:e,webGraphOriginalIdToGeneratedNodeIdFrom:t,webGraphOriginalIdToGeneratedNodeIdTo:r}}return{nodesConnections:t}})({nodesConnections:r,node:e,builder:n});Dn(this,tn,rn).call(this,{webGraphOriginalIdToGeneratedNodeIdTo:o,webGraphOriginalIdToGeneratedNodeIdFrom:i,nodesConnections:t});break}case uo.ConditionCategoryViewed:{const{webGraphOriginalIdToGeneratedNodeIdTo:t,webGraphOriginalIdToGeneratedNodeIdFrom:i,nodesConnections:o}=(({node:e,builder:t,nodesConnections:r})=>{const{id:i,data:n,isRecurrent:o,upstream:s}=e,{category:a,modifiers:c,filterMode:u}=n,l=u?Gu.generateRandomUuid():i,d=u?Gu.generateRandomUuid():null,p=Pd(c),h=Ed(s);if(u)t.withNode(An.FilterECommerceActivity,{id:d,externalId:i,recurrent:Sd(An.FilterECommerceActivity,o),upstream:h,properties:{productOrCategoryView:{...(null==a?void 0:a.id)?{category:a.id}:null,modifiers:p.modifiers}}});t.withNode(An.AwaitECommerceActivity,{id:l,externalId:i,recurrent:Sd(An.AwaitECommerceActivity,o),upstream:h,properties:{conditions:[{category:{...a,modifiers:p.modifiers}}],separator:"or",leaveFalseDelay:0}});const m=r.filter((e=>e.to===i)),w=r.find((e=>e.from===i&&"true"===e.key));if(u){const e=[],t=new Map,r=new Map;t.set(i,l),r.set(i,d);for(const i of m)e.push({from:i.from,to:d,key:i.key});if(e.push({from:d,to:l,key:"false"}),w)e.push({from:d,to:w.to,key:"true"}),e.push({from:l,to:w.to,key:"true"});return{nodesConnections:e,webGraphOriginalIdToGeneratedNodeIdFrom:t,webGraphOriginalIdToGeneratedNodeIdTo:r}}return{nodesConnections:r}})({nodesConnections:r,builder:n,node:e});Dn(this,tn,rn).call(this,{webGraphOriginalIdToGeneratedNodeIdTo:t,webGraphOriginalIdToGeneratedNodeIdFrom:i,nodesConnections:o});break}case uo.ConditionWebPushConsent:Dn(this,Ui,Wi).call(this,e,r,n);break;case uo.FilterLocation:Dn(this,Vi,xi).call(this,e,r,n);break;case uo.ConditionProductLiked:Dn(this,zi,Hi).call(this,e,r,n);break;case uo.FilterDevice:Dn(this,Ki,Xi).call(this,e,r,n);break;case uo.FilterReturningVisitor:Dn(this,Yi,Zi).call(this,e,r,n);break;case uo.ReactShowPopup:Dn(this,Gi,qi).call(this,e,r,n);break;case uo.ConditionWebAction:Dn(this,Qi,en).call(this,e,r,n);break;default:zn(i)}})),Dn(this,Ci,ki).call(this,Array.from(En(this,Pi))).forEach((e=>{n.withConnection(e)}));const o=n.build();return o.outsMap=En(this,yi),o.originalGraph=e,o}};const Dd=new class extends ad{async parse({data:e,type:t,id:r}){if(t===Mu.Automation){let t;if((e=>!!e&&"object"==typeof e&&"flowDataUrl"in e)(e))t=await this.fetchFlowDataFromRemote(e.flowDataUrl);else if((e=>!!e&&"object"==typeof e&&"nodes"in e&&"transitions"in e&&Array.isArray(e.nodes)&&Array.isArray(e.transitions))(e))t=kd.create().transformEditorGraphToWebGraph(e),pa.automationJourneyGraphs[r]={originalGraph:e,transformedGraph:t};if(t)return t}}};nn=new WeakMap;const Td=new class{constructor(){Cn(this,nn,new Map)}async parseWebFlowScriptInitialSingleFlowData(e){let t;if(e.type===Mu.Popup)if(gd.isPopupFromCurrentUrl(e)){if(e.data.mode===ro.Inline)await pu.attachPopupLibrary();t=await gd.parse(e)}else return null;else if(e.type===Mu.Automation)t=await Dd.parse(e);return En(this,nn).set(t,e),t}shouldGraphWaitForDocumentLoad(e){const t=En(this,nn).get(e);if(t)return t.type===Mu.Popup&&t.data.mode===ro.Popup;else return true}};class Ad{constructor(e,t){this.webEventFlowData=e,this.journeys=t}initialize(){const e="complete"===document.readyState;for(const t of this.webEventFlowData){const r=Kl(t),i=r?this.journeys.get(t.id):null,n=new sd({webflowSerializedData:t,visitorJourneys:i,isJourneyGraph:r});if(e||!Td.shouldGraphWaitForDocumentLoad(t))n.initVisitorFlow();else window.addEventListener("load",(()=>{n.initVisitorFlow()}),{once:true})}}}const Nd=new class{isScriptDelayed(e){return Object.keys(pa.delayedScripts).includes(e)}delay(e){if(!this.isScriptDelayed(e))pa.delayedScripts={...pa.delayedScripts,[e]:void 0}}storeDelayedScriptParams(e,t){if(this.isScriptDelayed(e))pa.delayedScripts={...pa.delayedScripts,[e]:t}}initScript(e){var t;const r=pa.delayedScripts[e];if(r){pa.delayedScripts=Object.fromEntries(Object.entries(pa.delayedScripts).filter((([t])=>t!==e)));const i=oa[e];null==(t=null==window?void 0:window[i])?void 0:t.init(...r)}}};on=new WeakSet,sn=async e=>(await Bs.openAutomationJourneysDatabaseConnection(Es)).transaction(ys.GraphJourneyFetchedData,e);const Ud=new class{constructor(){Cn(this,on)}async getGraphActiveNodesData(e){const t=await Dn(this,on,sn).call(this,"readonly"),r=t.objectStore(ys.GraphJourneyFetchedData).index(Is.GraphId),i=await r.getAll(e);return await t.done,i}async saveGraphJourneyActiveNodeData(e,t){const{journey:r,node:i}=t,n=(await Dn(this,on,sn).call(this,"readwrite")).objectStore(ys.GraphJourneyFetchedData),o=e.nodes.find((e=>e.id===i.uuid)),s=e.originalGraph.nodes.find((e=>e.id===(null==o?void 0:o.externalId)));if(s)await n.put({graph:{id:e.id},journey:{id:r.uuid},node:{id:i.uuid,since:s.since}})}},Wd=30;an=new WeakSet,cn=(e,t)=>e.map((e=>{const r=t.find((t=>t.journey.uuid===e.journey.uuid));if(null==r?void 0:r.pass_through_params)e.pass_through_params=r.pass_through_params;return e})),un=new WeakSet,ln=(e,t)=>t.map((t=>{const r=e.nodes.find((e=>e.externalId===t.node.uuid)),{pass_through_params:i,...n}=t;if(r)return Ia.create({...n,node:{uuid:r.id},...i?{pass_through_params:Hs.create(i)}:{}})})).filter(Boolean),dn=new WeakSet,pn=(e,t)=>e.reduce(((e,r)=>{const i=t.filter((e=>r.nodes.some((t=>t.id===e.node.uuid))));return e.set(r,i.length?i:null),e}),new Map),hn=new WeakSet,mn=e=>new Map(Array.from(e.entries()).map((([e,t])=>[e.id,null==t?void 0:t.filter((e=>e.visitor.uuid===Ul.getCookie(ca.visitorUuid)))]))),wn=new WeakSet,fn=async(e,t)=>{const r=t.map((e=>e.journey.uuid)),i=e.filter((e=>!r.includes(e.journey.uuid)));return await Promise.all(i.map((e=>Ea.clearVisitorJourney(e)))),i},gn=new WeakSet,vn=async(e,t)=>{if(!(null==t?void 0:t.length))return false;const r=new Date(e.since),i=await Ud.getGraphActiveNodesData(e.id);return t.every((t=>{const n=new Date(t.node_entered_at);if(Number(n)>=Number(r))return true;const o=e.nodes.find((e=>e.id===t.node.uuid)),s=e.originalGraph.nodes.find((e=>e.id===(null==o?void 0:o.externalId))),a=new Date(s.since);if(Number(a)<=Number(n))return true;const c=i.find((e=>e.journey.id===t.journey.uuid&&e.node.id===(null==o?void 0:o.id))),u=c?new Date(c.node.since):void 0;if(u&&Number(a)===Number(u))return true;else return false}))},yn=new WeakSet,bn=async function(e){return(await Promise.all(Array.from(e.entries()).map((([e,t])=>Dn(this,gn,vn).call(this,e,t))))).every(Boolean)},Sn=new WeakSet,Pn=e=>e.filter((e=>{const t=new Date(e.node_entered_at),r=new Date(t.setDate(t.getDate()+Wd));if(Number(r)>Number(new Date))return true;else return false}));const Fd=new class{constructor(){Cn(this,an),Cn(this,un),Cn(this,dn),Cn(this,hn),Cn(this,wn),Cn(this,gn),Cn(this,yn),Cn(this,Sn)}async getVisitorJourneys(e){const t=Ul.getCookie(ca.visitorUuid),r=await Ea.getVisitorJourneys(t),i=Dn(this,dn,pn).call(this,e,Dn(this,Sn,Pn).call(this,r)),n=await Dn(this,yn,bn).call(this,i);await Dn(this,wn,fn).call(this,r,Array.from(i.values()).flat().filter(Boolean));const o=Array.from(i).some((([e,t])=>{if(!(null==t?void 0:t.length))return false;else return t.some((t=>{const r=e.nodes.find((e=>e.id===t.node.uuid));return(null==r?void 0:r.type)===An.ReactSendToBackend}))}));if(n&&!o)return Dn(this,hn,mn).call(this,i);const s=Dn(this,an,cn).call(this,(await el.getVisitorJourneys()).map((e=>Ia.create(e))),r);return await Dn(this,wn,fn).call(this,r,s),await Promise.all(Array.from(i.keys()).map((async e=>{const t=Dn(this,un,ln).call(this,e,s);if(t.length)return i.set(e,t),Promise.all(t.map((t=>Ud.saveGraphJourneyActiveNodeData(e,t))));else i.set(e,null)}))),Dn(this,hn,mn).call(this,i)}};async function _d(e){xc().saveUserVisit();const t=e.filter(Kl);let r=new Map;try{if(t.length>0)r=(await Promise.all([Fd.getVisitorJourneys(t),Yc.migrateData().catch((e=>Rn.warn("Failed to migrate popup data",e)))]))[0];else await Yc.migrateData()}catch(i){Rn.error("Failed to get journey data",i)}if(null==e?void 0:e.length)new Ad(e,r).initialize()}function Vd(e){if(Array.isArray(e))return Promise.all(e.map((e=>{if(!!(t=e)&&"object"==typeof t&&"type"in t&&"string"==typeof t.type&&Object.values(Mu).includes(t.type)&&"data"in t&&!!t.data&&"object"==typeof t.data)return Td.parseWebFlowScriptInitialSingleFlowData(e);else return Rn.error("Invalid web flow data",e),null;var t})).filter(Boolean));Rn.error("Invalid initial web flows data structure, expected array, got",e)}e.init=e=>{const{visitorApplicationEndpoint:t,flowData:r}=JSON.parse((e=>{if("string"!=typeof e)throw new Error(`Invalid input, expect string, got ${typeof e}`);return e.replace(/(\w+)([*|$^~]*)=["]([^"]*)["]/g,((e,t,r,i)=>`${t}${r}=\\"${i}\\"`))})(e));let i=window.location.href;if(Nd.isScriptDelayed(na.we))return Nd.storeDelayedScriptParams(na.we,[e]),null;if(!pa.scriptModuleManager.isScriptInitialized(na.we)){if(pa.scriptModuleManager.setScriptInitialized(na.we),pa.enablePopupDevMode(),t)pa.visitorApplicationEndpoint=t;Vd(r).then((e=>e.filter(Boolean))).then((e=>{function t(){Vd(r).then((e=>e.filter(Boolean))).then((e=>_d(e)))}_d(e),pa.pageHistoryService.onPushState(((e,r,n)=>{if((null==e?void 0:e.gr)!==vo.ExitIntend&&!!n&&n!==i)td.resetNodes(),i=n.toString(),setTimeout((()=>t()),0)})),pa.pageHistoryService.onReplaceState(((e,r,n)=>{if(n&&n!==i)td.resetNodes(),i=n.toString(),setTimeout((()=>t()),0)})),window.addEventListener("popstate",(e=>{var r;if((null==(r=e.state)?void 0:r.gr)!==vo.ExitIntend)td.resetNodes(),t()}))}))}},Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})}((e="undefined"!=typeof globalThis?globalThis:e||self).GRWE={})}(this);