(self.webpackChunk_klaviyo_onsite_modules=self.webpackChunk_klaviyo_onsite_modules||[]).push([[7913,4928],{47849:function(e,t,n){"use strict";n.d(t,{P:function(){return r},f:function(){return o}});const r="triggering-state-update";class o extends CustomEvent{constructor(e){super(r,{detail:e})}}},94988:function(e,t,n){"use strict";n.d(t,{Gi:function(){return c},KS:function(){return o}});var r=n(12276);class o extends CustomEvent{constructor(e){super(r.Rc,{detail:e})}}const i=[],s=e=>{const t=new o(e);window.dispatchEvent(t)},c=e=>{if(window.onsiteTelemetryLoaded){for(;i.length>0;){const e=i.shift();e&&s(e)}s(e)}else i.push(e)}},12276:function(e,t,n){"use strict";n.d(t,{Rc:function(){return r},T4:function(){return s},Xf:function(){return i},lv:function(){return o}});const r="ONSITE_TELEMETRICS_EVENT",o="visitor-tracking",i="signup-forms",s="onsite_visitor_tracking"},88176:function(e,t,n){"use strict";n.d(t,{UF:function(){return x},mq:function(){return U},oO:function(){return O},rN:function(){return L}});const r="qualify",o="open",i="close",s="closeTeaser",c="submit",a="stepSubmit",d="embedOpen",u="redirectedToUrl",l="subscribedViaSMS",f="failedAgeGate",p="viewedStep",m="redirectedToUrlFromStep",v="submitOptInCode",y="triggeredBotProtection",g="falsePositiveBotProtection",w="requestBlockedByWAF",_="redirectedToDeepLink",S="clickedRedirectToInbox",k="hideRedirectToInbox",h="failedToRedirectToInbox",b="submitBackInStockForm",E="dynamicButtonBackInStockClicked",I="dynamicButtonBackInStockPlaced",T="submitBackInStockStep",O="klaviyojsSessionStarted",U="userIdentified",L={[r]:"qualifyModal",[o]:"openModal",[i]:"closeModal",[s]:"closeTeaser",[c]:"submitModal",[a]:"stepSubmit",errorView:"showErrorView",[d]:"loadedEmbed",[u]:"redirectedToUrl",[l]:"subscribedViaSMS",submitRateLimit:"submitRateLimit",klaviyoBranding:"clickedKlaviyoBranding",showEmailField:"showEmailField",showShopLogin:"showShopLogin",shopLoginSuccess:"shopLoginSuccess",[f]:"failedAgeGate",[p]:"viewedStep",[m]:"redirectedToUrlFromStep",[v]:"submitOptInCode",resendOptInCode:"resendOptInCode",openFormActionFormOpened:"openFormActionFormOpened",[y]:"triggeredBotProtection",[g]:"falsePositiveBotProtection",[w]:"requestBlockedByWAF",submitSpinToWin:"submitSpinToWin",receivedOutcomeView:"receivedOutcomeView",receivedOutcomeViewAndCouponCode:"receivedOutcomeViewAndCouponCode",[_]:"redirectedToDeepLink",[S]:S,[k]:k,[h]:h,[b]:"submitBackInStockForm",[E]:"dynamicButtonBackInStockClicked",[I]:"dynamicButtonBackInStockPlaced",[T]:"submitBackInStockStep",[O]:O,[U]:U},P="viewed_form",j="engaged_with_form",C="submitted_form_step",B="bot_protection",x={[r]:"qualified_form",[o]:P,[i]:"closed_form",[s]:"closed_teaser",[d]:P,[c]:j,[u]:j,[l]:j,[v]:j,[f]:"failed_age_gate",[p]:"viewed_form_step",[a]:C,[m]:C,[y]:B,[g]:B,[w]:B,[_]:j,[b]:"submitted_back_in_stock_form",[E]:"dynamic_button_back_in_stock_clicked",[I]:"dynamic_button_back_in_stock_placed",[T]:"submitted_back_in_stock_form_step",[O]:"klaviyojs_session_started",[U]:"user_identified"}},75240:function(e,t,n){"use strict";var r=n(12276),o=n(47849),i=n(25598),s=n(84509),c=n(5645),a=n.n(c),d=(n(92461),n(60873),n(87100)),u=n(83187),l=n(93648),f=n(71721),p=n(22314),m=n(12948),v=n(88176),y=n(75902),g=n(267);const w="__kla_session",_=(()=>{const e="https:"===window.location.protocol;return{path:"/",sameSite:e?"None":"Lax",secure:e}})(),S=(e,t)=>{(0,y.zP)(e,t,1800,Object.assign({},_))},k=async({updateExpiryTime:e=!0,_isRecoveryAttempt:t=!1}={})=>{if(!await(async()=>{var e,t;if("true"===(0,y.ej)("__kla_off"))return!1;const n=null==(e=window.Shopify)||null==(e=e.customerPrivacy)||null==e.userCanBeTracked?void 0:e.userCanBeTracked(),r=await(null==(t=window.klaviyo)||null==t.account?void 0:t.account()),o="string"==typeof r&&r.length>0;return n||o})())return;const n=(0,y.ej)(w);if(!n){const e={sessionId:(0,g.Z)(),sentSessionStartedEvent:!1,sentUserIdentifiedEvent:!1};return r=w,o=JSON.stringify(e),(0,y.d8)(r,o,1800,Object.assign({},_)),e}var r,o;try{e&&S(w,n);const r=JSON.parse(n);if((e=>"object"==typeof e&&null!==e&&"sessionId"in e&&"string"==typeof e.sessionId&&"sentSessionStartedEvent"in e&&"boolean"==typeof e.sentSessionStartedEvent&&"sentUserIdentifiedEvent"in e&&"boolean"==typeof e.sentUserIdentifiedEvent)(r))return r;if(!t)return(0,i.Yd)("Malformed session cookie detected, attempting recovery"),(e=>{(0,y.kT)(e,Object.assign({},_))})(w),k({updateExpiryTime:e,_isRecoveryAttempt:!0});throw new Error(`Malformed session cookie: ${r}`)}catch(e){return void(0,i.Yd)("Error parsing session cookie",{error:e,stack:e instanceof Error?e.stack:void 0})}};let h=Promise.resolve(!1);const b=({sentSessionStartedEvent:e=!1,sentUserIdentifiedEvent:t=!1})=>(h=h.then((async()=>{const n=await k({updateExpiryTime:!1});if(!n)return!1;const r=Object.assign({},n);let o=!1;return e&&!n.sentSessionStartedEvent&&(r.sentSessionStartedEvent=!0,o=!0),t&&!n.sentUserIdentifiedEvent&&(r.sentUserIdentifiedEvent=!0,o=!0),o&&S(w,JSON.stringify(r)),o})).catch((e=>((0,i.Yd)("Error updating session cookie",{error:e,stack:null==e?void 0:e.stack}),!1))),h),E=["formId","form_id"],I=async(e,t)=>{const n=(0,l.$j)(window.location.toString()),r=(0,f.af)(),o=(0,f.FU)(),i=(0,p.Z)()?"MOBILE":"DESKTOP",s=Object.keys(v.rN),c=Object.values(v.rN),d=t?await(async({updateExpiryTime:e=!0}={})=>{const t=await k({updateExpiryTime:e});return null==t?void 0:t.sessionId})():void 0;return e.map((e=>{var t,u,l,f;const p=(e=>e in v.rN)(e.metric)?v.rN[e.metric]:e.metric;if(!s.includes(p)&&!c.includes(p))throw new Error(`Invalid metric: ${p}`);const m=v.UF[e.metric],y=e.eventDetails||{},{formId:g,form_id:w}=y,_=a()(y,E),S=null!=g?g:w;return{metric:p,metric_service_event_name:m,log_to_statsd:null==(t=e.logToStatsd)||t,statsd_info:e.statsdInfo,log_to_s3:null==(u=e.logToS3)||u,log_to_metrics_service:!!m,event_details:Object.assign({},_,n,{form_id:S,device_type:i,hostname:window.location.hostname,href:window.location.href,page_url:`${window.location.origin}${window.location.pathname}`,first_referrer:null==o||null==(l=o.$referrer)?void 0:l.first_page,referrer:null==o||null==(f=o.$last_referrer)?void 0:f.first_page,user_agent:navigator.userAgent,locale:navigator.language},r||{},{klaviyo_js_session_id:d})}}))},T=async e=>{const{metricGroup:t,events:n,companyId:o,sample:i=1,useSession:s=!0}=e.detail;try{const e=await I(n,s),c=await(({metricGroup:e,events:t,companyId:n,sample:r=1})=>Math.random()>r?Promise.resolve(null):(0,d.Z)(`https://a.klaviyo.com/onsite/track-analytics?company_id=${n}`,{method:"POST",mode:"no-cors",body:JSON.stringify((0,u.Y)({metricGroup:e,events:t})),headers:{"Content-Type":"application/json",accept:"application/json"}}))({metricGroup:t||r.Xf,companyId:o,sample:i,events:e});return c}catch(e){return((e,t)=>{const n="undefined"!=typeof ProgressEvent&&e instanceof ProgressEvent||void 0!==window.XMLHttpRequestProgressEvent&&e instanceof window.XMLHttpRequestProgressEvent,r=e instanceof Error;!n&&r&&(0,m.T)(e,{tags:{logMetric:"True"},extra:{events:t}})})(e,n),null}};var O=n(94988);const U=()=>{const e=window.klaviyoModulesObject;return null==e?void 0:e.companyId},L=(e,t,n)=>{var r;if(!v.UF[e])return null;const o=null==(r=(0,f.zy)())?void 0:r.$exchange_id;return[Object.assign({metric:e,metricServiceEventName:v.UF[e],logToMetricsService:!0,logToS3:!0,logToStatsd:!0,statsdInfo:void 0},n,{eventDetails:{exchangeId:o,isIdentified:t.isIdentified,isClient:!0}})]},P="sessionStartedSent";let j=!1;const C=()=>{try{return!!j||"true"===sessionStorage.getItem(P)}catch(e){return(0,i.Yd)("Error checking if session started event has been sent",{error:e}),!1}},B="userIdentifiedSent";let x=!1;const R=()=>{try{return!!x||"true"===sessionStorage.getItem(B)}catch(e){return(0,i.Yd)("Error checking if user identified event has been sent",{error:e}),!1}},F=e=>async t=>{try{await e(t)}catch(e){(0,i.Yd)("Error visitor tracking event handler",{error:e,stack:e instanceof Error?e.stack:void 0})}},M=F((async({detail:e})=>{if(C())return;if(!(({visitedUrls:e,elapsedTime:t,scrollPercentage:n})=>e.length>=2||t>=1e4||n>=50)(e.state))return;if(!await b({sentSessionStartedEvent:!0}))return;const t=r.lv,n=U(),o=L(v.oO,e.state);if(!o||!n)return;const s=new O.KS({metricGroup:t,companyId:n,events:o});window.dispatchEvent(s),(()=>{try{j=!0,sessionStorage.setItem(P,"true")}catch(e){(0,i.Yd)("Error setting session started sent",{error:e})}})()})),A=F((async({detail:e})=>{if(R())return;if(!e.state.isIdentified)return;if(!await b({sentUserIdentifiedEvent:!0}))return;const t=r.lv,n=U(),o=L(v.mq,e.state);if(!o||!n)return;const s=new O.KS({metricGroup:t,companyId:n,events:o});window.dispatchEvent(s),(()=>{try{x=!0,sessionStorage.setItem(B,"true")}catch(e){(0,i.Yd)("Error setting user identified sent",{error:e})}})()})),N=()=>{(0,s.O)(r.T4)&&(window.removeEventListener(r.Rc,T),window.removeEventListener(o.P,M),window.removeEventListener(o.P,A),window.onsiteTelemetryLoaded=!1)};let V=!1;(async()=>{(async()=>{if(V)(0,i.Yd)("Telemetry setup already in progress, skipping.");else{V=!0;try{if(N(),!(0,s.O)(r.T4))return;window.addEventListener(r.Rc,T);const e=await k({updateExpiryTime:!1});!1!==(null==e?void 0:e.sentSessionStartedEvent)||C()||window.addEventListener(o.P,M),!1!==(null==e?void 0:e.sentUserIdentifiedEvent)||R()||window.addEventListener(o.P,A),window.onsiteTelemetryLoaded=!0}catch(e){(0,i.Yd)("Error during onsite telemetry setup",{error:e,stack:e instanceof Error?e.stack:void 0}),N()}finally{V=!1}}})()})()},51311:function(e,t,n){var r,o,i,s,c,a,d,u,l,f,p,m,v,y,g,w;i=function(e,t,n){if(!l(t)||p(t)||m(t)||v(t)||u(t))return t;var r,o=0,s=0;if(f(t))for(r=[],s=t.length;o