import{d as v,g as w,h as N}from"https://cdn.shopify.com/oxygen-v2/26431/10783/22349/1653411/build/_shared/chunk-JG2DATSI.js";import{$ as A,g,s as y}from"https://cdn.shopify.com/oxygen-v2/26431/10783/22349/1653411/build/_shared/chunk-3AWCCX5S.js";import{p as l,q as p}from"https://cdn.shopify.com/oxygen-v2/26431/10783/22349/1653411/build/_shared/chunk-Y6K5Z6SS.js";import{c as b}from"https://cdn.shopify.com/oxygen-v2/26431/10783/22349/1653411/build/_shared/chunk-6ODWWT4U.js";import{a as x}from"https://cdn.shopify.com/oxygen-v2/26431/10783/22349/1653411/build/_shared/chunk-QFSHI6QZ.js";import{a as f}from"https://cdn.shopify.com/oxygen-v2/26431/10783/22349/1653411/build/_shared/chunk-4WUWJLQN.js";import{r as h}from"https://cdn.shopify.com/oxygen-v2/26431/10783/22349/1653411/build/_shared/chunk-GSUAV5SD.js";import{a as C}from"https://cdn.shopify.com/oxygen-v2/26431/10783/22349/1653411/build/_shared/chunk-T3SAXWHR.js";import{a as I}from"https://cdn.shopify.com/oxygen-v2/26431/10783/22349/1653411/build/_shared/chunk-ZQ5CXEJV.js";import{d}from"https://cdn.shopify.com/oxygen-v2/26431/10783/22349/1653411/build/_shared/chunk-ISGSLAJR.js";var n=d(I());var e=d(C()),T=(0,n.memo)(({open:t,onClose:o,cart:i})=>{let[a,s]=(0,n.useState)([]);return(0,e.jsx)(n.Suspense,{children:(0,e.jsx)(h,{resolve:i,children:r=>(0,e.jsx)(p,{appear:!0,show:t,as:n.Fragment,children:(0,e.jsxs)(l,{as:"div",className:"relative z-[10000]",id:"cart",onClose:o,children:[(0,e.jsx)(p.Child,{as:n.Fragment,enter:"ease-out duration-500",enterFrom:"opacity-0",enterTo:"opacity-100",leave:"ease-in duration-500",leaveFrom:"opacity-100",leaveTo:"opacity-0",children:(0,e.jsx)("div",{"aria-hidden":"true",className:"pointer-events-none fixed inset-0 z-40 bg-black bg-opacity-20"})}),(0,e.jsx)(p.Child,{as:n.Fragment,enter:"ease-in-out duration-500",enterFrom:"translate-x-full",enterTo:"translate-x-0",leave:"ease-in-out duration-500",leaveFrom:"translate-x-0",leaveTo:"translate-x-full",children:(0,e.jsxs)(l.Panel,{className:f("rounded-l-none fixed bottom-0 left-0 right-0 top-0 z-40 flex h-full w-full flex-col overflow-y-auto bg-white md:bottom-auto md:left-auto md:w-[627px]","md:rounded-l-xl"),children:[(0,e.jsx)(O,{numLines:r?.lines,onClose:o}),r?.totalQuantity>0?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(w,{linesObj:r.lines,taxVariants:a,setTaxVariants:s,close:o}),(0,e.jsx)(S,{cart:r,onClose:o,taxVariants:a})]}):(0,e.jsx)(B,{onClose:o})]})})]})})})})});T.Title=l.Title;function U(t=!1){let[o,i]=(0,n.useState)(t);function a(){i(!0)}function s(){i(!1)}return{isOpen:o,openDrawer:a,closeDrawer:s}}function O({numLines:t,onClose:o}){let a=x(t||[]).reduce((s,r)=>r.merchandise.product.tags.includes("OPTIONS_HIDDEN_PRODUCT")?s:s+r.quantity,0);return(0,e.jsxs)("header",{className:f("sticky top-0 flex h-header-sm items-center justify-between bg-white px-4 pb-[11px] pt-6 lg:px-9 lg:pt-[40px]","lg:h-header-lg"),children:[(0,e.jsxs)("div",{className:"flex text-xl font-bold leading-[1.2] text-black",children:["Cart",a>0?(0,e.jsx)("span",{className:"ml-[5px] inline-flex h-6 min-w-[24px] items-center justify-center rounded-[12px] bg-[#FE522A] text-sm text-white",children:a}):null]}),(0,e.jsx)("button",{type:"button",className:"outline-none",onClick:o,children:(0,e.jsx)(g,{src:A.closeCart,aspectRatio:1,className:"h-6 w-6 md:h-5 md:w-5",alt:"close"})})]})}function S({cart:t,onClose:o,taxVariants:i}){let{isOn:a,getGstPrice:s}=y(),r=t.buyerIdentity?.purchasingCompany?.company?.name,k=(0,n.useMemo)(()=>(t?.lines?x(t?.lines):[]).reduce((u,m)=>{let D=i.find(F=>m.merchandise.id.includes(F.id))?.taxable,c=m.quantity*+m.merchandise.price.amount;return a&&D?u+s(c):u+c},0),[a,i,t.cost.subtotalAmount.amount]);return(0,e.jsx)("footer",{className:"sticky bottom-0 bg-white",children:(0,e.jsxs)("div",{className:"relative flex flex-col",children:[(0,e.jsx)(v,{cost:t.cost,price:r?void 0:k}),(0,e.jsxs)("div",{className:"flex w-full gap-4 px-4 pb-8 lg:px-8 lg:pb-9",children:[(0,e.jsx)(b,{onClick:o,type:"button",className:"text-base h-[48px] w-full max-w-[163px] rounded-[12px] border-2 border-[#AAA9AA] bg-white px-[5px] text-center font-[600] leading-[1.4] text-black md:max-w-[272px] md:px-[10px]",children:(0,e.jsx)("span",{children:"Continue Shopping"})}),(0,e.jsx)(N,{cart:t})]})]})})}function B({onClose:t}){return(0,e.jsxs)("div",{className:"flex flex-col px-4 pt-6 lg:px-8",children:[(0,e.jsx)("p",{className:"mb-4 text-lg font-bold text-black",children:"There\u2019s nothing in here...yet."}),(0,e.jsx)(b,{onClick:t,type:"button",className:"text-base h-auto w-full rounded-[12px] border-2 border-[#AAA9AA] bg-white p-[13px] text-center font-[600] text-black",children:(0,e.jsx)("span",{children:"Continue Shopping"})})]})}var J=T;export{U as a,J as b};