1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./CYKo8LC2.js","./BEitN51j.js","./CXIEtJGx.js","./swiper-vue.Bx4R_3Ti.css","./entry.C1e5h36o.css","./ROadPMVl.js","./CpjCy-2w.js"])))=>i.map(i=>d[i]); 2import{a as V,m as ot,t as L,cs as b,cr as nt,ab as rt,E as Q,F as it,ch as ct,c1 as ut,cg as dt,au as z}from"./BEitN51j.js";import{aF as w,k as f,aq as lt}from"./CXIEtJGx.js";import{s as mt}from"./C3QsFaVl.js";import{f as pt,a as K}from"./Dsep5Gqa.js";import{u as yt,g as ft}from"./Dua0kzTF.js";import{B as vt}from"./B-no4NmY.js";import{u as It}from"./do0XmCrS.js";import{u as kt}from"./C1HCbBiJ.js";const ht=globalThis.crypto,Dt=ht.subtle,M={MD5:"md5",SHA256:"sha256"},gt=e=>e?e.every(a=>a.operation==="add"&&a.kind===V.ITEM_ADDED_WITH_REDUCED_QUANTITY||a.operation==="update"&&a.kind===ot.ITEM_ADDED_WITH_REDUCED_QUANTITY):!1;var wt={};function bt(e,a=!1){return e?e.toLowerCase()==="true":a}const Et=async e=>{if(bt(wt.SFC_OMIT_MD5))throw Error("SFC was built without support for MD5");{const a=await L(()=>import("./CYKo8LC2.js").then(n=>n.m),__vite__mapDeps([0,1,2,3,4,5]),import.meta.url),s=await L(()=>import("./CpjCy-2w.js").then(n=>n.e),__vite__mapDeps([6,1,2,3,4,5]),import.meta.url),d=a.default&&(typeof a.default=="function"||typeof a.default=="object")?a.default:a;return(s.default&&(typeof s.default=="function"||typeof s.default=="object")?s.default:s).stringify(d(e))}},Bt=async e=>Array.from(new Uint8Array(await Dt.digest("SHA-256",new TextEncoder().encode(e)))).map(a=>a.toString(16).padStart(2,"0")).join(""),_t=async({keyTemplate:e,hashAlgorithm:a=M.SHA256,shopId:s,userId:d,log:r})=>{s||r?.warn("No shopId provided",{shopId:s}),d||r?.warn("No userId provided",{userId:d});const n=String(e.replace("{shopId}",s).replace("{userId}",d));return a===M.MD5?await Et(n):a===M.SHA256?await Bt(n):n},Tt=async({keyTemplate:e,hashAlgorithm:a=M.SHA256,shopId:s,userId:d,log:r})=>await _t({log:r?.space("core.generateBasketKey"),keyTemplate:e,hashAlgorithm:a,shopId:s,userId:d}),At=e=>{const a=e.map(d=>d.deliveryDate.min).sort(),s=e.map(d=>d.deliveryDate.max).sort();return[a?.[0]||null,s?.[s.length-1]||null]};function St({params:e}={},a="useBasket"){const s=b("addItemToBasket"),d=b("addItemsToBasket"),r=b("updateBasketItem"),n=b("mergeBaskets"),h=b("clearBasket"),E=b("removeItemFromBasket"),v=b("getApplicablePromotionsByCode"),o=f(()=>{const t=w(e);if(t&&"orderCustomData"in t){const{orderCustomData:u,...y}=t;return y}return t}),g=nt("getBasket",a,o,{server:!1,watch:[o],dedupe:"defer",transform:t=>t.basket,getCachedData:(t,u)=>w(u._asyncData[t]?.data)??void 0}),{data:l,error:B,refresh:q,status:N}=g,P=t=>{if(gt(t))throw new Error("Item was added with reduced quantity",{cause:V.ITEM_ADDED_WITH_REDUCED_QUANTITY})},F=t=>{throw t instanceof it&&C(t.data.errors?.[0])&&t.data.errors?.[0].operation!=="delete"?new Error(t.message,{cause:t.data.errors?.[0].kind}):t},W=async({variantId:t,promotionId:u,promotions:y,quantity:D,existingItemHandling:I,displayData:tt,customData:et,itemGroup:at})=>{try{const{basket:H,errors:st}=await s({promotionId:u,promotions:y,variantId:t,quantity:D,existingItemHandling:I,displayData:tt,customData:et,itemGroup:at,with:w(o)});l.value=H,P(st)}catch(H){F(H)}},S=async(t,u=Q.ADD_QUANTITY_TO_EXISTING)=>{try{const{basket:y,errors:D}=await d({items:t,existingItemHandling:u,with:w(o)});l.value=y,P(D)}catch(y){F(y)}};function C(t){return typeof t=="object"&&t!==null&&"operation"in t&&"kind"in t}const x=async t=>await n({...t,with:w(o)}),R=t=>l.value?.items?.find(u=>"variantId"in t?u.variant.id===t.variantId:u.product.id===t.productId),i=t=>R(t)!==void 0,c=async t=>{const u=R(t);if(!u)throw new Error(`Could not find basket item by variant-id: ${t.variantId}`);const{basket:y}=await E({itemKey:u.key,with:w(o)});l.value=y},m=async t=>{const{basket:u}=await E({itemKey:t,with:w(o)});l.value=u},p=async(t,u)=>{const{basket:y}=await r({basketItemKey:t,update:u,with:w(o)});l.value=y},k=async t=>{const{basket:u}=await v({promotionCode:t});return u},_=async()=>{await h()},T=f(()=>l.value?.items.map(t=>t.product)||[]),A=f(()=>l.value?.items?.reduce((t,u)=>u.itemGroup?.id&&!u.itemGroup.isMainItem?t:t+u.quantity,0)),G=f(()=>{const t=new Map,u=new Set;let y=(l.value?.items??[]).reduce((D,I)=>
2{if(I.itemGroup?.id)if(I.itemGroup.isMainItem)t.set(I.itemGroup.id,I.quantity);else return I.product.isSoldOut&&I.itemGroup.isRequired&&u.add(I.itemGroup.id),D;return I.product.isSoldOut?D:D+I.quantity},0);return u.forEach(D=>{y-=t.get(D)||0}),y}),Y=f(()=>l.value?.items),X=f(()=>l.value?.cost),$=f(()=>l.value?.key),J=f(()=>A.value===0),O=f(()=>l.value?.packages),Z=f(()=>O.value?At(O.value):void 0);return rt(g,{data:l,items:Y,count:A,cost:X,refresh:q,error:B,status:N,addItem:W,addItems:S,removeItemByKey:m,updateItem:p,clear:_,getApplicablePromotionsByCode:k,key:$,packages:O,shippingDates:Z,isEmpty:J,countWithoutSoldOutItems:G,removeItem:c,contains:i,products:T,findItem:R,generateBasketKey:Tt,mergeBaskets:x})}function Ct(e,a,s){return e<a?s==="asc"?-1:1:e>a?s==="asc"?1:-1:0}function Rt(e,a,s){return e.slice().sort((d,r)=>{const n=s.length;for(let h=0;h<a.length;h++){const E=n>h?s[h]:s[n-1],v=a[h],o=typeof v=="function",g=o?v(d):d[v],l=o?v(r):r[v],B=Ct(g,l,E);if(B!==0)return B}return 0})}const j=(e,a)=>a?.find(s=>"variantId"in e?s.variant.id===e.variantId:s.product.id===e.productId),Pt=(e,a)=>!!j(e,a),Ft=e=>{const a=new Map,s=new Set;let d=e.reduce((r,n)=>{if(n.itemGroup?.id)if(n.itemGroup.isMainItem)a.set(n.itemGroup.id,n.quantity);else return n.status!=="available"&&n.itemGroup.isRequired&&s.add(n.itemGroup.id),r;return n.status!=="available"?r:r+n.quantity},0);return s.forEach(r=>{d-=a.get(r)||0}),d},Qt=e=>e.appliedReductions.reduce((a,{amount:s})=>a+s.absoluteWithTax,e.withTax),Gt=()=>{const{$i18n:e}=ct(),a=ut();return{getBaskedDeliveryEstimation:r=>{if(!r)return{};const n=isNaN(r)?r:Math.ceil(Number(r));return{"attribute-3":{key:"deliveryForecast",label:e.t("checkout.delivery_estimate.label"),value:e.t("checkout.delivery_estimate.value",{days:n})}}},getBaskedDeliveryEstimationWithDate:r=>r?{"attribute-3":{key:"deliveryForecast",label:e.t("checkout.delivery_estimate.label"),value:String(pt(String(r),a.value.locale))}}:{"attribute-3":{key:"deliveryForecast",label:e.t("checkout.delivery_estimate_unknown.label"),value:e.t("checkout.delivery_estimate_unknown.value")}}}},U=new Map,Lt=(e="")=>{if(U.has(e))return U.get(e);const a=Mt(e);return U.set(e,a),a};function Mt(e=""){const a=b("addItemsWithPromotionsToBasket"),{getSizeDisplayData:s}=kt(),{trackRemoveFromBasket:d,trackAddToBasket:r}=It(),{getBaskedDeliveryEstimationWithDate:n}=Gt(),h=dt("useAgsBasket"),E=yt(),v=lt({...vt,...e&&{pricePromotionKey:e},applicablePromotions:!0}),o=St({params:v},"useAgsBasket"),g=f(()=>ft(E.data.value)),l=async(i,c=Q.REPLACE_EXISTING)=>{try{const{orderCustomData:m,...p}=v.value;await a({items:i,basketWithOptions:p,orderCustomData:m,existingItemHandling:c}),await o.refresh()}catch(m){S("addItems",m)}},B=async()=>{await Promise.all([E.fetch(),o.refresh()])},q=async()=>{const i=o.data.value?.items.map(c=>{const m=c.variant,p=c.customData,k=p?.deliveryEstimationDate,_=K(m,g.value);if(k?.toString().split("T")[0]===_?.toISOString().split("T")[0])return;const T=n(_),A={"attribute-2":s(m)};return{variantId:m.id,quantity:c.quantity,displayData:{...T,...A||{}},customData:{...p||{},deliveryEstimationDate:_},existingItemHandling:Q.REPLACE_EXISTING}}).filter(c=>c!==void 0);i&&await l(i)},N=async()=>{await B(),await q()};o.status.value!=="pending"&&B();const P=async i=>{try{const{key:c,product:m,variant:p,quantity:k=1}=i;await o.removeItemByKey(c),await o.refresh(),d({product:m,quantity:k,variant:p,coupon:i.promotionCode,type:"delete_cart"})}catch(c){S("removeItemFromBasket",c)}},F=async({quantity:i,item:c})=>{const m=c.product,p=c.variant,k=c.customData,_=c.promotionId,T=c.quantity,A=i>T;try{await o.updateItem(c.key,{variantId:p.id,quantity:i,...k?.pricePromotionKey&&{pricePromotionKey:k.pricePromotionKey},displayData:{"attribute-2":s(p),...n(K(p,g.value))},customData:{ordernumber:k?.ordernumber||mt(m),deliveryEstimationDate:K(p,g.value)},promotionId:_}),A?r({product:m,variant:p,quantity:i-T,coupon:c.promotionCode,type:"increase_item_quantity"}):d({product:m,variant:p,quantity:T-i,coupon:c.promotionCode,type:"decrease_cart"})}catch(G){S("changeBasketProductQuantity",G)}},W=i=>{v.value={...v.value,pricePromotionKey:i}},S=(i,c)=>{(typeof c=="string"||c instanceof Error)&&h.space(i).error(c)},C=f(()=>Rt(o.items.value??[],[i=>z(i.product?.attributes,"name")?.label,i=>z(i.variant?.attributes,"size")?.id],["asc"])),x=f(()=>C.value.filter(({status:i})=>i==="available")),R=f(()=>C.value.filter(({status:i})=>i==="unavailable"));return{data:o.data,count:o.count,status:o.status,cost:o.cost,applicablePromotions:o.data.value?.applicablePromotions,items:C,availableItems:x,unavailableItems:R,refresh:o.refresh,addItem:o.addItem,findItem:j,contains:Pt,removeFreeGiftItem:o.removeItemByKey,c
2ountAvailableBasketItems:Ft,fetch:N,addItems:l,removeItem:P,changeQuantity:F,setPricePromotionKey:W}}export{Gt as a,Qt as g,Rt as o,Lt as u};
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.