1import{u as X,a as b,j as e,L as R}from"./vendor-react-CuuqKQpN.js";import{u as W,M as n}from"./vendor-intl-DflcVhi5.js";import{u as Q}from"./ShopContext-GqNXKGqv.js";import{u as U}from"./useMoneyFormat-SaVvDe0m.js";import{u as Z,e as G}from"./SectionRenderer-Bj_DctFR.js";import{u as _}from"./useScreenContext-Jg1QQ7e_.js";import{S as ee}from"./ShopBreadcrumb-BLLnwe5x.js";import{O as D}from"./OrderEntryBffService-Be6cGa8q.js";import{Q as se}from"./QuantityStepper-B1e4WYFh.js";import{r as te}from"./productFormatters-C62HFpN-.js";import{c as E}from"./cartLineIdentity-DjtFau5e.js";import{p as J,d as ae,e as le}from"./distributorDiscount-C6zg_nHE.js";import{S as A}from"./ShopHelmet-BMJzL5mh.js";import"./vendor-cjs-BosuxZz1.js";import"./i18nProvider-CcUjZRgB.js";import"./AssistantDrawer-DhOqiwD3.js";import"./main-BFwzyxdJ.js";import"./vendor-query-DJ11Sd2y.js";import"./vendor-ui-CP508Bka.js";import"./vendor-monitoring-CnHeFoWS.js";import"./vendor-markdown-BXjZCFI9.js";import"./ProductsBffService-Cara56k8.js";import"./ShopRoutes-rUULs2hG.js";const ie=({item:s,updating:i,onRemove:f,onQuantityChange:c,currencySymbol:N="$",taxIncludedDisplay:g})=>{const j=W(),x=G(),{currencyDecimals:d,hidePrices:C}=Q(),l=U(d),v=g&&s.quantity>0?s.unitPrice+(s.taxAmount??0)/s.quantity:s.unitPrice,k=v*s.quantity;return e.jsxs("div",{className:"d-flex gap-3 py-4 border-bottom",children:[e.jsxs("div",{className:"flex-shrink-0 rounded-2 overflow-hidden position-relative",style:{width:88,aspectRatio:x.aspectRatio,backgroundColor:x.backgroundColor},children:[e.jsx("img",{src:s.imageUrl?te(s.imageUrl):"",alt:s.name,className:`position-absolute top-0 start-0 w-100 h-100 object-fit-${x.objectFit}`,style:{display:"none"},onLoad:m=>{var p;m.currentTarget.style.display="";const y=(p=m.currentTarget.parentElement)==null?void 0:p.querySelector(".img-fallback-icon");y&&(y.style.display="none")},onError:m=>{m.currentTarget.style.display="none"}}),e.jsx("div",{className:"img-fallback-icon w-100 h-100 align-items-center justify-content-center position-absolute",style:{display:"flex",inset:0,backgroundColor:x.backgroundColor},children:e.jsx("i",{className:"ki-outline ki-picture fs-4 text-muted","aria-hidden":"true"})})]}),e.jsxs("div",{className:"flex-grow-1 min-w-0",children:[e.jsx("div",{className:"fw-semibold text-gray-900 mb-1 lh-sm",children:s.name}),e.jsxs("div",{className:"text-muted fs-8 mb-2",children:[e.jsx(n,{id:"message.catalog.label.sku"}),": ",s.sku]}),e.jsxs("div",{className:"d-flex align-items-center justify-content-between flex-wrap gap-2",children:[e.jsx(se,{value:s.quantity,onDecrease:()=>c(s,s.quantity-1),onIncrease:()=>c(s,s.quantity+1),disabled:i,updating:i,size:"md",groupLabel:j.formatMessage({id:"shop.cart.quantityFor"},{name:s.name}),decreaseLabel:j.formatMessage({id:"shop.cart.decreaseQuantity"}),increaseLabel:j.formatMessage({id:"shop.cart.increaseQuantity"})}),e.jsxs("div",{className:"d-flex align-items-center gap-3",children:[!C&&e.jsxs("div",{className:"text-end",children:[e.jsxs("div",{className:"fw-bold text-gray-900 fs-5",children:[N,l(k)]}),s.quantity>1&&e.jsxs("div",{className:"text-muted fs-8",children:[N,l(v)," ",e.jsx(n,{id:"shop.cart.each"})]})]}),e.jsx("button",{type:"button",className:"btn btn-icon btn-sm btn-light-danger cart-remove-btn",onClick:()=>f(s),disabled:i,"aria-label":j.formatMessage({id:"shop.cart.removeItem"},{name:s.name}),children:e.jsx("i",{className:"ki-outline ki-trash fs-7","aria-hidden":"true"})})]})]})]})]})},ne=({cart:s,onCheckout:i,hidePrices:f,currencySymbol:c="$"})=>{var y,p,L,w,h,F,P,q;const{currencyDecimals:N}=Q(),g=U(N),j=((y=s.totals)==null?void 0:y.subtotal)??0,x=((p=s.totals)==null?void 0:p.discounts)??0,d=J(s),C=ae((L=s.totals)==null?void 0:L.taxes,((w=s.totals)==null?void 0:w.taxIncludedDisplay)??!1,d),l=le((h=s.totals)==null?void 0:h.shipping,((F=s.totals)==null?void 0:F.taxIncludedDisplay)??!1,d),v=((P=s.totals)==null?void 0:P.total)??0,k=((q=s.totals)==null?void 0:q.taxIncludedDisplay)??!1,m=s.items.reduce(($,O)=>$+O.quantity,0);return e.jsx("div",{className:"card card-custom shadow-sm rounded-3",children:e.jsxs("div",{className:"card-body p-4",children:[e.jsx("h5",{className:"fw-bold text-gray-900 mb-4",children:e.jsx(n,{id:f?"shop.cart.summary.titleQuote":"message.label.reviewYourOrder"})}),f?e.jsx("div",{className:"d-flex flex-column gap-2 mb-3",children:e.jsx("div",{className:"d-flex justify-content-between fs-7",children:e.jsx("span",{className:"text-muted",children:e.jsx(n,{id:"shop.cart.summary.itemsCount",values:{count:m}})})})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"d-flex flex-column gap-2 mb-3",children:[!k&&e.jsxs("div",{className:"d-flex justify-content-between fs-7",children:[e.jsx("span",{className:"text-muted",children:e.jsx(n,{id:"message.label.subtotal",values:{count:m}})}),e.jsxs("span",{className:"fw-semibold",children:[c,g(j)]})]}),x>0&&e.jsxs("div",{className:"d-flex justify-content-between fs-7",children:[e.jsx("span",{className:"text-muted",children:e.jsx(n,{id:"shop.cart.summary.discounts"})}),e.jsxs("span",{className:"fw-semibold text-success",children:["-",c,g(x)]})]}),l>0&&e.jsxs("div",{className:"d-flex justify-content-between fs-7",children:[e.jsx("span",{className:"text-muted",children:e.jsx(n,{id:"shop.cart.summary.shipping"})}),e.jsxs("span",{className:"fw-semibold",children:[c,g(l)]})]}),!k&&C>0&&e.jsxs("div",{className:"d-flex justify-content-between fs-7",children:[e.jsx("span",{className:"text-muted",children:e.jsx(n,{id:"message.taxes"})}),e.jsxs("span",{className:"fw-semibold",children:[c,g(C)]})]})]}),e.jsx("hr",{className:"my-3"}),e.jsxs("div",{className:"d-flex justify-content-between align-items-center mb-4",children:[e.jsx("span",{className:"fw-bold fs-5 text-gray-900",children:e.jsx(n,{id:k?"message.label.total":"message.orderEntry.referenceTable.totalNet"})}),e.jsxs("span",{className:"fw-bold fs-4 text-primary",children:[c,g(v)]})]})]}),e.jsxs("button",{type:"button",className:"btn btn-primary btn-sm w-100",onClick:i,children:[e.jsx(n,{id:f?"shop.cart.requestQuote":"messages.orderEntry.wizard.checkout"}),e.jsx("i",{className:"ki-outline ki-arrow-right ms-2","aria-hidden":"true"})]})]})})},Me=()=>{var B,z,V;const s=W(),{activeOrderId:i,hidePrices:f,currencySymbol:c,applyCartCount:N,currencyDecimals:g}=Q(),j=U(g),x=X(),d=Z(),C=G(),[l,v]=b.useState(null),[k,m]=b.useState(!0),[y,p]=b.useState(null),[L,w]=b.useState(new Set);_("shop.cart",i??void 0,l?{itemCount:l.items.reduce((a,o)=>a+o.quantity,0),items:l.items.slice(0,10).map(a=>({sku:a.sku,name:a.name,quantity:a.quantity})),...f?{}:{total:(B=l.totals)==null?void 0:B.total,currency:c}}:void 0,!!l);const h=b.useCallback(async()=>{var a,o,r,u,M,S,T,Y,H,K;if(!i){m(!1);return}try{m(!0);const I=await D.getCart(i),t=((a=I.data)==null?void 0:a.data)??I.data;N(t),v({orderId:i,items:Array.isArray(t==null?void 0:t.items)?t.items:Array.isArray((o=t==null?void 0:t.cart)==null?void 0:o.items)?t.cart.items:[],totals:{subtotal:((r=t==null?void 0:t.cart)==null?void 0:r.grossTotal)??0,discounts:((u=t==null?void 0:t.cart)==null?void 0:u.discountTotal)??0,taxes:((M=t==null?void 0:t.cart)==null?void 0:M.taxTotal)??0,shipping:((S=t==null?void 0:t.cart)==null?void 0:S.shipping)??0,total:((T=t==null?void 0:t.cart)==null?void 0:T.netTotal)??0,taxIncludedDisplay:(t==null?void 0:t.taxIncludedDisplay)??!1,countryTaxValue:(t==null?void 0:t.countryTaxValue)??null,breakdown:J(t)??void 0},validationErrors:((Y=t==null?void 0:t.validation)==null?void 0:Y.errors)??[],isValid:((H=t==null?void 0:t.validation)==null?void 0:H.valid)??!0})}catch(I){const t=(K=I==null?void 0:I.response)==null?void 0:K.status;t!==401&&t!==403&&p(s.formatMessage({id:"shop.cart.error.load"}))}finally{m(!1)}},[i,s,N]);b.useEffect(()=>{h()}
1,[h]);const F=b.useCallback(async(a,o)=>{if(!i||!l)return;const r=a.sku,u=o-a.quantity;if(u===0)return;const M=E(a);w(S=>new Set(S).add(M));try{o<=0?await D.removeFromCart(i,r,a.orderDetailId):u>0?await D.addToCart(i,r,u,a.orderEntryCode,a.catalogId):(await D.removeFromCart(i,r,a.orderDetailId),o>0&&await D.addToCart(i,r,o,a.orderEntryCode,a.catalogId)),await h()}catch{p(s.formatMessage({id:"shop.cart.error.update"}))}finally{w(S=>{const T=new Set(S);return T.delete(M),T})}},[i,l,h,s]),P=b.useCallback(async a=>{if(!i||!l)return;const o=E(a);v(r=>r&&{...r,items:r.items.filter(u=>E(u)!==o)}),w(r=>new Set(r).add(o));try{await D.removeFromCart(i,a.sku,a.orderDetailId),await h()}catch{p(s.formatMessage({id:"shop.cart.error.remove"})),await h()}finally{w(r=>{const u=new Set(r);return u.delete(o),u})}},[i,l,h,s]),q=b.useCallback(()=>{x(`${d}/checkout`)},[x]);if(k)return e.jsxs("div",{className:"container-fluid py-8 py-md-12",children:[e.jsx(A,{}),e.jsx("div",{className:"mb-4",children:e.jsx("div",{className:"placeholder-glow",children:e.jsx("span",{className:"placeholder col-3 rounded-2 cart-skeleton-title"})})}),[1,2,3].map(a=>e.jsxs("div",{className:"d-flex gap-3 py-4 border-bottom placeholder-glow",children:[e.jsx("span",{className:"placeholder rounded-2 flex-shrink-0",style:{width:88,aspectRatio:C.aspectRatio}}),e.jsxs("div",{className:"flex-grow-1",children:[e.jsx("span",{className:"placeholder col-6 rounded-1 d-block mb-2 cart-skeleton-line-lg"}),e.jsx("span",{className:"placeholder col-3 rounded-1 d-block mb-3 cart-skeleton-line-sm"}),e.jsx("span",{className:"placeholder col-4 rounded-1 d-block cart-skeleton-line-md"})]})]},a))]});const $=(((z=l==null?void 0:l.items)==null?void 0:z.length)??0)>0,O=(l==null?void 0:l.items.reduce((a,o)=>a+o.quantity,0))??0;return!i||!$?e.jsxs("div",{className:"container-fluid py-8 py-md-12",children:[e.jsx(A,{}),e.jsxs("div",{className:"d-flex flex-column align-items-center justify-content-center text-center cart-empty-state",role:"status",children:[e.jsx("div",{className:"rounded-circle bg-light d-flex align-items-center justify-content-center mb-4 cart-empty-icon-wrap",children:e.jsx("i",{className:"ki-outline ki-basket fs-2tx text-muted","aria-hidden":"true"})}),e.jsx("h3",{className:"fw-bold text-gray-900 mb-2",children:e.jsx(n,{id:"shop.cart.empty.title",defaultMessage:"Your cart is empty"})}),e.jsx("p",{className:"text-muted mb-5",children:e.jsx(n,{id:"messages.label.CheckOurSuggestions"})}),e.jsxs(R,{to:`${d}/catalog`,className:"btn btn-primary btn-sm px-6",children:[e.jsx("i",{className:"ki-outline ki-arrow-left me-2","aria-hidden":"true"}),e.jsx(n,{id:"messages.showCatalog"})]})]})]}):e.jsxs("div",{className:"container-fluid py-8 py-md-12",children:[e.jsx(A,{}),e.jsx(ee,{crumbs:[{label:s.formatMessage({id:"message.home"}),to:d},{label:s.formatMessage({id:"message.page.cms.shoppingCart"})}]}),e.jsxs("div",{className:"d-flex align-items-center justify-content-between mb-5",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"fw-bold text-gray-900 mb-1",children:e.jsx(n,{id:"message.page.cms.shoppingCart"})}),e.jsx("p",{className:"text-muted fs-7 mb-0",children:e.jsx(n,{id:"message.label.itemsCount",values:{count:O}})})]}),e.jsxs(R,{to:`${d}/catalog`,className:"btn btn-light btn-sm d-flex align-items-center gap-2",children:[e.jsx("i",{className:"ki-outline ki-arrow-left fs-7","aria-hidden":"true"}),e.jsx("span",{className:"d-none d-md-inline",children:e.jsx(n,{id:"message.label.continueShopping"})})]})]}),y&&e.jsxs("div",{className:"alert alert-danger d-flex align-items-center mb-4",role:"alert",children:[e.jsx("i",{className:"ki-outline ki-information-3 fs-4 me-3 text-danger flex-shrink-0","aria-hidden":"true"}),e.jsx("div",{className:"flex-grow-1",children:y}),e.jsx("button",{type:"button",className:"btn btn-sm btn-icon ms-auto",onClick:()=>p(null),"aria-label":s.formatMessage({id:"message.control.dismiss"}),children:e.jsx("i",{className:"ki-outline ki-cross fs-6","aria-hidden":"true"})})]}),e.jsxs("div",{className:"row g-4 g-md-6",children:[e.jsxs("div",{className:"col-12 col-lg-8",children:[e.jsx("div",{className:"card card-custom shadow-sm rounded-3",children:e.jsx("div",{className:"card-body p-4",children:e.jsx("div",{role:"list","aria-label":s.formatMessage({id:"shop.cart.itemsListLabel"}),children:l.items.map(a=>{var o;return e.jsx("div",{role:"listitem",children:e.jsx(ie,{item:a,updating:L.has(E(a)),onRemove:P,onQuantityChange:F,currencySymbol:c,taxIncludedDisplay:((o=l==null?void 0:l.totals)==null?void 0:o.taxIncludedDisplay)??!1})}
1,E(a))})})})}),e.jsx("div",{className:"d-none d-lg-flex mt-4",children:e.jsxs(R,{to:`${d}/catalog`,className:"btn btn-light btn-sm d-flex align-items-center gap-2",children:[e.jsx("i",{className:"ki-outline ki-arrow-left fs-7","aria-hidden":"true"}),e.jsx(n,{id:"message.label.continueShopping"})]})})]}),e.jsx("div",{className:"col-12 col-lg-4",children:e.jsx("div",{className:"cart-summary-sticky",children:e.jsx(ne,{cart:l,onCheckout:q,hidePrices:f,currencySymbol:c})})})]}),e.jsxs("div",{className:"d-lg-none position-fixed bottom-0 start-0 end-0 bg-white border-top p-3 d-flex gap-3 cart-mobile-bar",children:[e.jsx(R,{to:`${d}/catalog`,className:"btn btn-light flex-shrink-0","aria-label":s.formatMessage({id:"message.label.continueShopping"}),children:e.jsx("i",{className:"ki-outline ki-arrow-left fs-7","aria-hidden":"true"})}),e.jsx("button",{type:"button",className:"btn btn-primary flex-grow-1 fw-bold cart-mobile-checkout-btn",onClick:q,children:f?e.jsx(n,{id:"shop.cart.requestQuote"}):e.jsx(n,{id:"shop.cart.checkoutWithTotal",values:{total:j(((V=l.totals)==null?void 0:V.total)??0)}})})]})]})};export{Me as default};
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.