import{qW as E,dR as q,G as S,aY as z,qX as F,bi as U,dW as C,qY as Y,Y as k,aZ as V,a as n,b1 as A,aB as j,aA as D,b6 as x,B as P,qZ as H,q_ as W,ac as h,K as X,gm as b,aC as f,b8 as Z,bf as G,aX as K,o as Q,a_ as $,a$ as J}from"./app.B46ok1sD.js";const ee={id:"76113fc688fe950e2e09d64b5b10df17007abf25436339310e6aeb706bdf5e30",type:"query",name:"PrivacyBannerSettings",source:"query PrivacyBannerSettings{privacyBannerSettings{autoManaged buttonAcceptText buttonDeclineText buttonPrefsOpenText enabled policyLinkText policyLinkUrl preferences{bulletPoints{enabled firstText secondText thirdText title __typename}buttonAcceptText buttonDeclineText buttonSaveText introText introTitle purposes{essentialDesc essentialName marketingDesc marketingName performanceDesc performanceName preferencesDesc preferencesName __typename}title __typename}text title consentTrackingApiToken showBannerOnCheckout __typename}}"},ne="privacy-consent-banner",B="privacy_preferences_modal",M=(e,a)=>{a?console.debug(a):e?console.error("Set consent error: ",e):console.error("Set consent error: unknown")},te=async(e,a)=>{await E({analytics:e,marketing:e,preferences:e,storefrontAccessToken:a},M)};var m=(e=>(e.Accept="accept",e.Decline="decline",e.AcceptAll="accept_all",e.DeclineAll="decline_all",e.ManagePreferences="manage_preferences",e.Save="save",e.LeavePreferences="leave_preferences",e.PrivacyPolicyView="privacy_policy_view",e.CloseCheckoutBanner="close_checkout_banner",e))(m||{});function N(){const e=q(),{domain:a,storefrontDomains:d}=S(),r=z(),o=r.searchParams.get("previewPrivacyBanner")==="true",{getCookie:c}=F(),l=U().checkoutSessionIdentifier,y=d.some(t=>document.referrer.includes(t));return{emitPrivacyBannerInteractionEvent:t=>{const _={schemaId:C.PrivacyBannerInteract,payload:{shopPermanentDomain:a,sessionToken:c("_shopify_y")||"0",regulation:"CMP",path:r.pathname,visitorRegion:Y(),interactionType:t,checkoutSessionIdentifier:l,isStorefrontReferrer:y}};o||e.record(_)},emitPrivacyBannerRenderEvent:()=>{const t={schemaId:C.PrivacyBannerRender,payload:{shopPermanentDomain:a,sessionToken:c("_shopify_y")||"0",regulation:"CMP",path:r.pathname,checkoutSessionIdentifier:l,isStorefrontReferrer:y}};o||e.record(t)},emitPrivacyBannerInitializedEvent:()=>{const t={schemaId:C.PrivacyBannerInitialized,payload:{shopPermanentDomain:a,sessionToken:c("_shopify_y")||"0",regulation:"CMP",path:r.pathname,checkoutSessionIdentifier:l,isStorefrontReferrer:y}};o||e.record(t)}}}function ae(e){function a(){T(ne),T(B)}const[d,r]=k(!1),[o,c]=k(!1),[p,l]=k(!1),[y,g]=k(!0),{closeOverlay:T}=V(),{emitPrivacyBannerInteractionEvent:v}=N(),t=async({analytics:s,marketing:i,preferences:u})=>{r(s),c(i),l(u),await E({analytics:s,marketing:i,preferences:u,storefrontAccessToken:e.consentTrackingApiToken},M)},_=()=>{v(m.LeavePreferences),g(!0)},L=()=>{if(y){const{analytics:s,marketing:i,preferences:u}=K();r(s==="yes"),c(i==="yes"),l(u==="yes"),g(!1)}},R=n(j,{spacing:"large200",inlineAlignment:"start",children:[n(A,{onClick:()=>{t({analytics:!0,marketing:!0,preferences:!0}),v(m.AcceptAll),a()},children:e.buttonAcceptText}),n(A,{onClick:()=>{t({analytics:!1,marketing:!1,preferences:!1}),v(m.DeclineAll),a()},children:e.buttonDeclineText}),n(A,{variant:"primary",onClick:()=>{t({analytics:d,marketing:o,preferences:p}),v(m.Save),a()},children:e.buttonSaveText})]}),I=(()=>{const s=[e.bulletPoints?.firstText,e.bulletPoints?.secondText,e.bulletPoints?.thirdText].filter(i=>typeof i=="string");return e.bulletPoints?.enabled&&s.length>0?n(X,{children:[n(D,{spacing:"base"}),n(x,{level:3,children:e?.bulletPoints?.title}),n(P,{padding:["small300","none","small300","none"],children:n(H,{children:s.map((i,u)=>n(W,{children:n(h,{children:i})},u))})})]}):null})(),O=n(P,{spacing:"none",children:[n(x,{level:3,children:e.introTitle}),n(h,{children:e.introText}),I]}),w=n(P,{children:[n(b,{checked:!0,disabled:!0,children:[n(h,{children:n(f,{type:"strong",children:e.purposes.essentialName})}),e.purposes.essentialDesc]}),n(b,{checked:p,onChange:s=>l(s),children:[n(h,{children:n(f,{type:"strong",children:e.purposes.preferencesName})}),e.purposes.preferencesDesc]}),n(b,{checked:o,onChange:s=>c(s),children:[n(h,{children:n(f,{type:"strong",children:e.purposes.marketingName})}),e.purposes.marketingDesc]}),n(b,{checked:d,onChange:s=>r(s),children:[n(h,{children:n(f,{type:"strong",children:e.purposes.performanceName})}),e.purposes.performanceDesc]})]});return n(G,{id:B,heading:e.title||"",primaryAction:R,size:"large",onHide:_,onShow:L,children:[n(D,{spacing:"base"}),n(Z,{}),n(P,{padding:["base","large200","base","large200"],children:[O,w]})]})}function re({small:e}){const a=Q(),{emitPrivacyBannerInteractionEvent:d}=N(),{data:r,loading:o,error:c}=$(ee,{cache:!1});if(o||!r?.privacyBannerSettings?.enabled)return null;if(c||!r)return console.error("Error fetching consent banner data",c),null;const p=a("shop_policies.cookie_preferences");return n(J,{onClick:()=>{d(m.ManagePreferences)},overlay:n(ae,{...r.privacyBannerSettings.preferences,consentTrackingApiToken:r.privacyBannerSettings.consentTrackingApiToken||void 0}),children:e?n(f,{size:"small",children:p}):p})}const ce=Object.freeze(Object.defineProperty({__proto__:null,default:re},Symbol.toStringTag,{value:"Module"}));export{m as B,ce as F,ee as P,ne as a,ae as b,te as s,N as u};