1import{g as p}from"./basket.DtFICkLE.js";import{c as m}from"./clientFetchApi.CG5VfCYs.js";import{g as l}from"./index.D2p_Bu1Q.js";import{m as c}from"./index.DtsRjIc2.js";import"./basket.B_utnBWZ.js";import"./trackingHelpers.BfHonhIc.js";import"./preload-helper.BlTxHScW.js";import"./_commonjsHelpers.CqkleIqs.js";import"./imageOptimization.BhY-BxPI.js";import"./index.BSdFiPHn.js";const n=c({id:p()??null,count:0}),k=c({basket:{}}),w=c({}),E=t=>{w.set(t)},h=t=>{k.setKey("basket",t)},u=()=>k.get()?.basket,C=t=>{n.set(t)},f=()=>n.get(),d=t=>{n.setKey("count",t)},b=(t,e)=>{n.setKey(t,e)},y=t=>{const s=`; ${document.cookie}`.split(`; ${t}=`);return s.length===2?s.pop().split(";").shift():null},I=t=>{if(t){const e=new Date;e.setTime(e.getTime()+1440*60*1e3),document.cookie=`autoApplyPromoCode=${t}; expires=${e.toUTCString()}; path=/; SameSite=Lax`}},L=()=>y("autoApplyPromoCode"),M=()=>{document.cookie="autoApplyPromoCode=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/; SameSite=Lax"};async function V(t){if(n.get().id!==t.id){C(t);return}else{const e=t.count;n.get().count!==e&&d(e);return}}const F=t=>{if(f().id!==t){localStorage.setItem("basketId",t);const e=window.__HOST__.includes("thgaltitude")||window.__HOST__.includes("thg.dev");if(f().id===null)document.cookie=e?`ElysiumBasket${window.tenantConfig.basketCookieName}_V6=; secure; path=/; Expires=Thu, 01 Jan 1970 00:00:01 GMT;`:`ElysiumBasket${window.tenantConfig.basketCookieName}_V6=; secure; path=/; domain=${l()}; Expires=Thu, 01 Jan 1970 00:00:01 GMT;`;else{const s=btoa(t);e?document.cookie=`ElysiumBasket${window.tenantConfig?.basketCookieName}_V6=${s}; secure; max-age=2500000; path=/;`:document.cookie=`ElysiumBasket${window.tenantConfig?.basketCookieName}_V6=${s}; secure; path=/;max-age=2500000; domain=${l()}`}b("id",t)}};let i=!1,r=null;async function K(){let t=p();if(t||(t=n.get().id),!!t)return!window.sessionSettings?.currency||!window.tenantConfig?(console.warn("Session settings not yet available, deferring basket initialization"),null):i&&r?r:u()&&u().id===t?u():(i=!0,r=(async()=>{const e=window.tenantConfig?.features?.basket,g=(e?.hasBasketGiftWrapping?.giftWrapSKU??[]).flat();try{const o=await m("Basket",{id:t,currency:window.sessionSettings?.currency,shippingDestination:window.sessionSettings?.country,hasSubscriptions:window.tenantConfig?.features?.hasSubscriptions,hasLoyalty:window.tenantConfig?.features?.hasLoyalty,hasPersonalisation:window.tenantConfig?.features?.hasPersonalisation?.enabled??window.tenantConfig?.features?.hasPersonalisation??!1,hasWishlist:window.tenantConfig?.features?.hasWishlist??!1,hasSpendingLimits:window.tenantConfig?.features?.hasSpendingLimits??!1,hasFutureLots:window.tenantConfig?.features?.hasFutureLots??!1,hasGiftMessage:e?.hasBasketGiftMessaging?.enabled??!1,basketGiftMessageSku:e?.hasBasketGiftMessaging?.giftMessageSKU||0,hasGiftWrap:e?.hasBasketGiftWrapping?.enabled??!1,basketGiftWrapperSkus:g});if(!o||o.errors)throw new Error("Failed to fetch basket");const a=o.data.basket;return d(a.totalQuantity||a.count||0),h(a),i=!1,a}catch(o){throw console.error("Error initializing basket:",o),i=!1,o}})(),r)}export{k as basketContents,n as basketStore,w as basketUnwrappedItems,V as checkBasketCount,M as clearAutoApplyCode,L as getAutoApplyCode,u as getBasketContents,f as getBasketStore,K as initializeBasket,I as setAutoApplyCode,h as setBasketContents,d as setBasketCount,F as setBasketId,b as setBasketKey,C as setBasketStore,E as setBasketUnwrappedItems};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.