import{a as Me}from"https://cdn.shopify.com/oxygen-v2/26437/10785/22343/1653408/build/_shared/chunk-TGFEQRIO.js";import{a as Ee}from"https://cdn.shopify.com/oxygen-v2/26437/10785/22343/1653408/build/_shared/chunk-3EUOPIQA.js";import"https://cdn.shopify.com/oxygen-v2/26437/10785/22343/1653408/build/_shared/chunk-KKTF6C5G.js";import{a as X}from"https://cdn.shopify.com/oxygen-v2/26437/10785/22343/1653408/build/_shared/chunk-PUQJQHSQ.js";import{a as Be}from"https://cdn.shopify.com/oxygen-v2/26437/10785/22343/1653408/build/_shared/chunk-FHIYLRJA.js";import"https://cdn.shopify.com/oxygen-v2/26437/10785/22343/1653408/build/_shared/chunk-WEDYDU2S.js";import{b as ce}from"https://cdn.shopify.com/oxygen-v2/26437/10785/22343/1653408/build/_shared/chunk-GVWERIYP.js";import{a as $e}from"https://cdn.shopify.com/oxygen-v2/26437/10785/22343/1653408/build/_shared/chunk-E43N735O.js";import{a as J}from"https://cdn.shopify.com/oxygen-v2/26437/10785/22343/1653408/build/_shared/chunk-YSVA35EN.js";import{e as Oe}from"https://cdn.shopify.com/oxygen-v2/26437/10785/22343/1653408/build/_shared/chunk-DA5IJ7XM.js";import"https://cdn.shopify.com/oxygen-v2/26437/10785/22343/1653408/build/_shared/chunk-DBZIAGBT.js";import"https://cdn.shopify.com/oxygen-v2/26437/10785/22343/1653408/build/_shared/chunk-P5X5QREN.js";import"https://cdn.shopify.com/oxygen-v2/26437/10785/22343/1653408/build/_shared/chunk-RH7K7YQU.js";import{a as Re,c as De,d as E,g as ke}from"https://cdn.shopify.com/oxygen-v2/26437/10785/22343/1653408/build/_shared/chunk-C2MSQUIF.js";import"https://cdn.shopify.com/oxygen-v2/26437/10785/22343/1653408/build/_shared/chunk-BMLPKF64.js";import{$ as m,g as f,i as de,p as _e}from"https://cdn.shopify.com/oxygen-v2/26437/10785/22343/1653408/build/_shared/chunk-4WGLXVPZ.js";import"https://cdn.shopify.com/oxygen-v2/26437/10785/22343/1653408/build/_shared/chunk-PYETN2HX.js";import"https://cdn.shopify.com/oxygen-v2/26437/10785/22343/1653408/build/_shared/chunk-W7B6E32U.js";import{p as fe,q as le,r as we}from"https://cdn.shopify.com/oxygen-v2/26437/10785/22343/1653408/build/_shared/chunk-QXO7CJXO.js";import{a as re}from"https://cdn.shopify.com/oxygen-v2/26437/10785/22343/1653408/build/_shared/chunk-J44IZTW2.js";import{d as Y,e as Se}from"https://cdn.shopify.com/oxygen-v2/26437/10785/22343/1653408/build/_shared/chunk-GFXNKJ5U.js";import{a as p}from"https://cdn.shopify.com/oxygen-v2/26437/10785/22343/1653408/build/_shared/chunk-FWBXOOCE.js";import{a as F,b as Le,c as Pe}from"https://cdn.shopify.com/oxygen-v2/26437/10785/22343/1653408/build/_shared/chunk-6NX3IJVR.js";import{a as ae,e as ne,g as ie}from"https://cdn.shopify.com/oxygen-v2/26437/10785/22343/1653408/build/_shared/chunk-YAHMRLQ4.js";import{a as w}from"https://cdn.shopify.com/oxygen-v2/26437/10785/22343/1653408/build/_shared/chunk-34QOOIQ4.js";import"https://cdn.shopify.com/oxygen-v2/26437/10785/22343/1653408/build/_shared/chunk-W2IUONAN.js";import"https://cdn.shopify.com/oxygen-v2/26437/10785/22343/1653408/build/_shared/chunk-3NRANKP7.js";import"https://cdn.shopify.com/oxygen-v2/26437/10785/22343/1653408/build/_shared/chunk-OPOLM3WC.js";import{a as Q,b as K,d as Ae,g as Te,j as te,l as Ie,m as Ce,o as _,t as j,u as k,x as Z}from"https://cdn.shopify.com/oxygen-v2/26437/10785/22343/1653408/build/_shared/chunk-C4I3W2OX.js";import{a as l}from"https://cdn.shopify.com/oxygen-v2/26437/10785/22343/1653408/build/_shared/chunk-LL6AKNEK.js";import{a as ee}from"https://cdn.shopify.com/oxygen-v2/26437/10785/22343/1653408/build/_shared/chunk-LQ2PFFE3.js";import"https://cdn.shopify.com/oxygen-v2/26437/10785/22343/1653408/build/_shared/chunk-X2OUMLEL.js";import{d as n}from"https://cdn.shopify.com/oxygen-v2/26437/10785/22343/1653408/build/_shared/chunk-H7QMOPDN.js";function me(e,t){var r=null;return function(){for(var i=arguments.length,o=new Array(i),a=0;a{let o=Z(),a=o?.data,u=r?e?.formattedAddress:e?.formatted;return(0,Ye.useEffect)(()=>{let s=a?.deletedLocation?.companyLocationDelete?.userErrors;if(s?.length)for(let c of s)Se(c?.message,"error")},[a]),(0,I.jsxs)("div",{className:"relative flex flex-col rounded-lg border-2 border-GREY_THREE p-6",children:[t&&(0,I.jsx)(J,{mode:"outline",label:"Default"}),(0,I.jsxs)("ul",{className:"flex flex-1 flex-col gap-4 space-y-1",children:[(e?.firstName||e?.lastName)&&(0,I.jsxs)("li",{className:"flex flex-col gap-1",children:[(0,I.jsx)(p.P3,{className:"text-[#888888]",children:"Name"}),(0,I.jsx)(p.P2,{className:"pb-1 font-[600]",children:""+(e.firstName&&e.firstName+" ")+e.lastName})]}),!!u?.length&&(0,I.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,I.jsx)(p.P3,{className:"text-[#888888]",children:"Address"}),(0,I.jsx)("div",{children:u?.map(s=>(0,I.jsx)(p.P2,{className:"pb-1 font-[600] last:pb-0",children:s},s))})]})]}),(0,I.jsxs)("div",{className:"mt-9 flex flex-row items-center justify-between text-sm font-medium text-darkGray",children:[(0,I.jsx)(_,{to:`/account/address/${encodeURIComponent(e?.id)}`,className:"rounded-lg border-2 border-GREY_TWO px-4 py-2 font-inter text-sm text-black",prefetch:"intent",preventScrollReset:!0,children:"Edit"}),(0,I.jsxs)(o.Form,{action:r?"/account?action=delete":"/account/address/delete",method:"delete",children:[!r&&(0,I.jsx)("input",{type:"hidden",name:"addressId",value:e?.id}),r&&(0,I.jsx)("input",{type:"hidden",name:"companyLocationId",value:i}),(0,I.jsx)("button",{disabled:o.state!=="idle",className:"ml-6 text-left text-sm text-red",children:o.state==="idle"?(0,I.jsx)(f,{src:m.trash_2,width:20,height:20,layout:"fixed"}):(0,I.jsx)(de,{width:20,height:20})})]})]})]})};var P=n(l()),Fe=()=>{let{company:e}=ce(),t=Ce(),{openDrawer:r,closeDrawer:i,isOpen:o}=_e(),a=e?.locations.edges.map(s=>({shipping:s.node.shippingAddress,id:s.node.id})),u=t.find(s=>s.formAction==="/account");return(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(Ue,{open:o,onClose:i}),(0,P.jsxs)("div",{className:"relative col-span-3 mt-16 grid w-full lg:mt-0",children:[(0,P.jsx)("div",{id:"address",className:"absolute top-0 h-[180px] translate-y-[-100%] lg:h-[100px]"}),(0,P.jsxs)("div",{className:"flex flex-col items-center justify-center gap-6 py-2 md:flex-row md:justify-start md:gap-3.5",children:[(0,P.jsxs)("div",{className:"flex md:contents",children:[(0,P.jsx)(f,{src:m.delivery,width:20,height:20,className:"flex h-5 items-center justify-center"}),(0,P.jsx)(p.H3,{className:"whitespace-nowrap text-xl font-bold",children:"Company locations"})]}),(0,P.jsx)("div",{className:"relative",children:(0,P.jsx)("button",{type:"button",onClick:r,className:"bottom-[50%] right-0 top-[50%] flex h-12 min-w-[132px] items-center justify-center rounded-[32px] bg-GREY_TWO px-5 py-3 font-[600] text-white md:absolute md:translate-x-[100%] md:translate-y-[-50%]",children:u?.state==="submitting"?(0,P.jsx)(de,{width:20}):"Add location"})})]}),(0,P.jsx)("div",{className:w("mb-2 mt-4 gap-4 md:gap-8",a?.length?"grid grid-cols-1 md:grid-cols-3":"flex flex-col items-center justify-center"),children:!!a?.length&&a.map((s,c)=>(0,P.jsx)(oe,{address:s.shipping,id:s.id,company:!0},c))})]})]})};var B=n(ee());var v=n(l()),He=({item:e,currency:t,cursor:r})=>{let i=`/account/orders/${btoa(e.id)}?cursor=${r}`;return(0,v.jsxs)("li",{className:"flex flex-col rounded",children:[(0,v.jsx)(_,{to:i,children:(0,v.jsxs)("div",{className:"bg-primary/5 relative mb-2 aspect-square overflow-hidden rounded-lg border-2 border-GREY_THREE",children:[(0,v.jsx)("div",{className:"mb-1 inline-flex",children:(0,v.jsx)(J,{mode:e.financialStatus==="PAID"?"outline":"default",label:e.financialStatus?.replaceAll("_"," ")})}),e.lineItems?.nodes?.length>1&&(0,v.jsxs)("div",{className:"absolute bottom-3 left-3 z-[11] flex h-5 items-center justify-center rounded-lg bg-white px-1.5 text-[10px] font-bold uppercase",children:["+ ",e?.lineItems?.nodes?.length-1," other products"]}),e.lineItems?.nodes?.[0].image?.url?(0,v.jsx)(ie,{alt:e.lineItems?.nodes[0].variant?.image?.altText??"Order image",className:"fadeIn relative z-[1] w-full transform object-contain transition-transform duration-300 ease-in-out hover:scale-110",data:e.lineItems?.nodes[0].image,height:200,crop:"center",width:200}):(0,v.jsx)(f,{src:m.medshopPlugImg,className:"fadeIn w-full object-contain"})]})}),(0,v.jsxs)("ul",{className:"mt-2 flex-1 flex-row gap-1 space-y-1",children:[(0,v.jsxs)("li",{className:"flex w-full gap-2",children:[(0,v.jsx)(p.P2,{className:"text-sm font-[400] leading-[140%] text-[#888888]",children:e.name}),(0,v.jsxs)(p.P2,{className:"text-sm font-[400] leading-[140%] text-[#888888]",children:["on ",new Date(e.processedAt).toDateString()]})]}),(0,v.jsx)("li",{children:(0,v.jsx)(_,{to:i,children:(0,v.jsx)(p.P2,{className:"font-[600] leading-[140%]",children:e.lineItems?.nodes?.length>1?`${e?.lineItems?.nodes[0]?.title} +${e?.lineItems?.nodes?.length-1} more`:e?.lineItems?.nodes[0]?.title})})}),(0,v.jsx)("li",{className:"pt-2",children:(0,v.jsxs)(p.P2,{className:"flex !text-md font-[700] !leading-[150%]",children:[t,(0,v.jsx)(ne,{data:e.totalPrice,withoutCurrency:!0})]})})]}),(0,v.jsx)("div",{className:"mt-4 flex flex-row gap-5 text-sm font-medium",children:(0,v.jsx)(_,{className:w(" flex justify-center rounded-lg border-2 px-4 py-2 text-center text-sm font-[600] leading-[140%]",e.financialStatus==="PAID"?"bg-[#3BB900] text-white":"border-GREY_TWO text-black"),to:i,children:"View details"})})]})};var V=n(l()),Ge=()=>{let{erpData:e}=k();return e?.price_list_name?(0,V.jsxs)("div",{className:"mt-10 flex w-full flex-col lg:mt-0",children:[(0,V.jsxs)("div",{className:"relative flex h-[70px] w-full items-center justify-center gap-1 overflow-hidden rounded-t-lg text-[24px] font-[600]",children:[(0,V.jsx)(f,{src:(()=>{let r=e?.price_list_name;return r==="Bronze"?m.bronze:r==="Platinium"?m.platinum:r==="Silver"?m.silver:r==="Gold"?m.gold:m.whiteNoise})(),className:"absolute z-[-1] h-full w-full opacity-80"}),(0,V.jsx)(f,{src:m.priceTier,width:40,height:40,className:"w-10"}),e?.price_list_name||""]}),(0,V.jsx)("div",{className:"flex w-full flex-col rounded-b-lg border-2 border-GREY_THREE p-5 text-[14px] font-[700] leading-[1.4]",dangerouslySetInnerHTML:{__html:e?.customer_message}})]}):null};var he=(s=>(s.AUTHORIZED="AUTHORIZED",s.PAID="PAID",s.PARTIALLY_PAID="PARTIALLY_PAID",s.PARTIALLY_REFUNDED="PARTIALLY_REFUNDED",s.PENDING="PENDING",s.REFUNDED="REFUNDED",s.VOIDED="VOIDED",s))(he||{});var d=n(l()),qe=({orders:e,locations:t})=>{let[r,i]=(0,B.useState)(null),[o,a]=(0,B.useState)(null),u=K(),s=Q(),c=new URLSearchParams(s.search),[g,R]=(0,B.useState)(c.has("address")?`gid://shopify/CompanyLocation/${c.get("address")}`:""),D=[...Object.entries(he),["ALL","ALL"]],[M]=j(),L=M.data.currency.symbol;(0,B.useEffect)(()=>{me(A=>{if(A||g){let $=new URLSearchParams;A&&$.set("query",A),g&&$.set("address",g.replace("gid://shopify/CompanyLocation/","")),u(s.pathname+"?"+$.toString(),{preventScrollReset:!0})}else u(s.pathname,{preventScrollReset:!0})},500)(r||void 0)},[r,g]);let C=y=>{let{value:A}=y.target;i(A)},q=y=>{if(y){let A=D.find($=>$[1]===y.replaceAll(" ","_"))?.[0];if(A){a(A);return}}a(null)},rt=(0,B.useMemo)(()=>D.find(y=>y[0]===o)?.[1]||"",[o,D]),ge=(0,B.useMemo)(()=>o&&o!=="ALL"?e?.edges?.filter(y=>y.node.financialStatus===o):e?.edges,[e,o]),W=e.pageInfo,ot=y=>{R(t.find(A=>A.name===y)?.id||"")},st=t.find(y=>y.id===g)?.name||"",at=()=>{let y={status:o,orderNumber:r,address:g},A=[];for(let $ in y)y[$]&&A.push($==="orderNumber"?"order number":$);if(A.length===1)return A[0];if(A.length===2)return`${A[0]} and/or ${A[1]}`;if(A.length===3)return`${A[0]}, ${A[1]} and/or ${A[2]}`};return(0,d.jsxs)("div",{className:"relative mt-10 flex w-full flex-col justify-center lg:mt-20 lg:justify-start",children:[(0,d.jsx)("div",{id:"orders",className:"absolute top-0 h-[180px] translate-y-[-100%] lg:h-[100px]"}),(0,d.jsx)("div",{className:"border-b-2 border-[#E6E6E6] pb-10 lg:pb-15",children:(0,d.jsxs)("div",{className:"grid w-full lg:grid-cols-4 lg:gap-8",children:[(0,d.jsx)(nt,{handleSearchQueryChange:C,statusList:D,handleSelectStatus:q,currentStatus:rt,currentAddress:st,handleSelectAddress:ot,addressList:t.map(y=>y.name)}),!ge?.length&&(0,d.jsxs)("div",{className:"grid-cols-subgrid col-span-1 flex flex-col items-center justify-center text-center lg:col-span-3",children:[!r&&!o&&(0,d.jsx)(p.H2,{children:"You haven't placed any orders yet."}),(o||r||g)&&(0,d.jsxs)(p.H2,{children:["Could not find orders with this ",at()]})]}),!!ge?.length&&(0,d.jsxs)("div",{className:"grid-cols-subgrid col-span-1 grid md:col-span-2 lg:col-span-3",children:[(0,d.jsx)("ul",{className:"grid grid-flow-row grid-cols-1 items-start gap-8 md:grid-cols-2 lg:grid-cols-3",children:ge.map(y=>(0,d.jsx)(He,{item:y.node,cursor:y.cursor,currency:L},y.node.id))}),(W?.hasPreviousPage||W?.hasNextPage)&&(0,d.jsxs)("div",{className:"mt-16 flex w-full justify-center gap-9",children:[!!W?.hasPreviousPage&&(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)(f,{src:m.arrowRight,width:20,height:20,className:"h-4 rotate-180"}),(0,d.jsx)(_,{className:"font-inter text-GREY_ONE",to:s.pathname+"?startCursor="+W?.startCursor,children:"Previous"})]}),!!W?.hasNextPage&&(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)(_,{className:"font-inter text-GREY_ONE",to:s.pathname+"?endCursor="+W?.endCursor,children:"Next"}),(0,d.jsx)(f,{src:m.arrowRight,width:20,height:20,className:"h-4"})]})]})]})]})})]})},nt=({orderNumber:e,handleSearchQueryChange:t,statusList:r,handleSelectStatus:i,currentStatus:o,currentAddress:a,handleSelectAddress:u,addressList:s})=>{let c=Z(),[g]=Ie(),R=k(),D=R.contact.id,M=R.customer?.orders?.nodes,L=!R.erpData?.price_list_name,C=()=>{let q=Object.fromEntries([...g]);c.submit({companyContactId:D,...q,status:o},{action:"/account?action=export",method:"POST"})};return(0,B.useEffect)(()=>{c?.data?.csv&&it(c?.data?.csv)},[c.data]),(0,d.jsxs)("div",{className:"flex w-full flex-col gap-5 lg:pt-0",children:[(0,d.jsx)(Ge,{}),(0,d.jsx)("h2",{className:w("text-center text-xl font-bold lg:text-start",L?"mt-10 lg:mt-0":""),children:"Your Medshop orders"}),(0,d.jsxs)("div",{className:"flex w-full flex-col gap-5 pb-10 lg:pb-0",children:[(0,d.jsx)(Y.Dropdown,{items:["ALL",...s],select:u,current:a,placeholder:"Filter by address",buttonClassName:"text-[14px] font-[600]"}),(0,d.jsxs)("div",{className:"relative flex w-full",children:[(0,d.jsx)(f,{src:m.search,width:16,height:16,className:"absolute left-4 top-4"}),(0,d.jsx)(Y.TextInput,{className:"h-12 !pl-10 text-[14px]",placeholder:"Search by order number",value:e||void 0,onChange:t})]}),(0,d.jsx)(Y.Dropdown,{items:r.map(q=>q[1].replaceAll("_"," ")),select:i,current:o.replaceAll("_"," "),placeholder:"Order status",buttonClassName:"text-[14px] font-[600]"}),(0,d.jsxs)(re.Secondary,{className:"gap-2.5 font-[600]",onClick:C,disabled:!M,children:[(0,d.jsx)(f,{src:m.excelLogo,height:20,width:20,className:"max-h-[20px]"}),"Export orders"]}),(0,d.jsxs)(_,{to:"/account/quick-order",className:"flex items-center justify-center gap-2.5 rounded-lg border-2 border-ORANGE_ONE p-3 font-[600] text-ORANGE_ONE hover:bg-ORANGE_ONE hover:bg-opacity-5",children:[(0,d.jsx)(f,{src:m.cartIconOrange,width:20,className:"filter--image_orange h-5 w-5"}),"Quick order"]})]})]})},it=(e,t="orders.csv")=>{let r=new Blob([e],{type:"text/csv;charset=utf-8;"}),i=document.createElement("a"),o=URL.createObjectURL(r);i.setAttribute("href",o),i.setAttribute("download",t),i.style.visibility="hidden",document.body.appendChild(i),i.click(),document.body.removeChild(i)};var U=n(l()),je=()=>{let{erpData:e}=k();return(0,U.jsxs)("div",{className:"-mb-12 flex w-full flex-col items-center justify-between gap-8 pt-10 lg:flex-row lg:gap-0",children:[(0,U.jsxs)("div",{className:"text-[24px] font-bold tracking-[-0.72px]",children:[(0,U.jsx)("span",{className:"text-[#AAA9AA]",children:"Your open balance is"})," ",(0,U.jsxs)("span",{className:"text-black",children:["$",e?.balance||"0.00"]})]}),(0,U.jsxs)("div",{className:"flex flex-col gap-4 lg:flex-row lg:gap-6",children:[(0,U.jsx)(_,{to:"/pages/apply-pharmaceuticals",className:"min-w-fit rounded-lg border-2 border-GREY_TWO px-5 py-3 font-[600] hover:bg-GREY_TWO",children:"Apply to access pharmaceuticals"}),(0,U.jsx)(_,{to:"/pages/increase-credit-terms",className:"min-w-fit rounded-lg border-2 border-GREY_TWO px-5 py-3 font-[600] hover:bg-GREY_TWO",children:"Increase credit / terms"})]})]})};var ye=n(l());function Ve({handleSubmit:e,disabled:t}){return(0,ye.jsx)("div",{className:"flex w-full gap-4 px-4 py-8 lg:px-8 lg:py-9",children:(0,ye.jsx)(Pe,{type:"submit",disabled:t,className:w([Le(),"!h-12","bg-[#FE522A] hover:bg-ORANGE_TWO","rounded-[12px]","text-base","w-full"]),onClick:e,children:"Apply"})})}var pe=n(ee());var h=n(l()),lt={name:"",note:"",phone:"",shipping_address1:"",shipping_address2:"",shipping_city:"",shipping_firstName:"",shipping_lastName:"",shipping_phone:"",shipping_recipient:"",shipping_zip:"",billingSameAsShipping:!0,billing_address1:"",billing_address2:"",billing_city:"",billing_firstName:"",billing_lastName:"",billing_phone:"",billing_recipient:"",billing_zip:""},z=e=>E().test("conditional-required",`${e} field is required`,function(t){let{billingSameAsShipping:r}=this.parent;return r?!0:typeof t=="string"&&t.trim()!==""}),ve=/^(?:\+61|0)[2-478](?:[ -]?[0-9]){8}$/,dt=ke().shape({name:E().required("Location name is required"),note:E(),phone:E().matches(ve,"Invalid phone number").required("Location phone is required"),shipping_address1:E().required("Shipping address is required"),shipping_address2:E(),shipping_city:E().required("City is required"),shipping_firstName:E().required("First name is required"),shipping_lastName:E().required("Last name is required"),shipping_phone:E().matches(ve,"Invalid phone number").required("Phone is required"),shipping_recipient:E().required("Recipient is required"),shipping_zip:E().required("Zip code is required").matches(/^\d{4}$/,"Invalid zip code"),billingSameAsShipping:De(),billing_address1:z("Billing address"),billing_address2:E(),billing_city:z("City"),billing_firstName:z("First name"),billing_lastName:z("Last name"),billing_phone:z("Phone").matches(ve,"Invalid phone number"),billing_recipient:z("Recipient"),billing_zip:z("Zip code").matches(/^\d{4}$/,"Invalid zip code")}),ze=[{key:"address1",title:"Address 1"},{key:"address2",title:"Address 2"},{key:"city",title:"City"},{key:"firstName",title:"First name"},{key:"lastName",title:"Last name"},{key:"phone",title:"Phone"},{key:"recipient",title:"Recipient"},{key:"zip",title:"Zip"}],We=({onClose:e})=>{let{company:t,contact:r}=k(),o=ce().companyLocationId||t.locations?.edges?.[0]?.node.id,{values:a,handleChange:u,handleBlur:s,errors:c,touched:g,setFieldValue:R,isValid:D,dirty:M}=Re({initialValues:lt,validateOnBlur:!0,validationSchema:dt,onSubmit:()=>{}}),L=t.id;return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)("div",{className:"flex flex-grow flex-col overflow-auto px-8",children:[(0,h.jsx)(X,{field:"name",placeholder:"Location name",values:a,touched:g,errors:c,handleBlur:s,handleChange:u}),(0,h.jsx)(X,{field:"note",placeholder:"Location note",values:a,touched:g,errors:c,handleBlur:s,handleChange:u}),(0,h.jsx)(X,{field:"phone",placeholder:"Phone",values:a,touched:g,errors:c,handleBlur:s,handleChange:u}),(0,h.jsx)("p",{className:"mb-4 font-[600]",children:"Shipping address"}),ze.map(C=>(0,h.jsx)(X,{field:`shipping_${C.key}`,placeholder:C.title,values:a,touched:g,errors:c,handleBlur:s,handleChange:u},`shipping_${C.key}`)),(0,h.jsx)("input",{type:"hidden",name:"shipping_countryCode",value:"AU"}),(0,h.jsxs)("div",{className:"flex items-center gap-3",children:[(0,h.jsx)(Y.Checkbox,{name:"billingSameAsShipping",checked:a.billingSameAsShipping,onChange:()=>R("billingSameAsShipping",!a.billingSameAsShipping)}),"Billing same as shipping"]}),!a.billingSameAsShipping&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)("p",{className:"my-4 font-[600]",children:"Billing address"}),ze.map(C=>(0,h.jsx)(X,{field:`billing_${C.key}`,placeholder:C.title,values:a,touched:g,errors:c,handleBlur:s,handleChange:u},`billing_${C.key}`))]}),(0,h.jsx)("input",{type:"hidden",name:"billing_countryCode",value:"AU"}),(0,h.jsx)("input",{type:"hidden",name:"companyId",value:L}),(0,h.jsx)("input",{type:"hidden",name:"companyContactId",value:r.id}),(0,h.jsx)("input",{type:"hidden",name:"locationId",value:o})]}),(0,h.jsx)(Ve,{handleSubmit:e,disabled:!D||!M})]})};var O=n(l()),Ue=({open:e,onClose:t})=>{let r=Z();return(0,O.jsx)(le,{appear:!0,show:e,as:pe.Fragment,children:(0,O.jsxs)(fe,{as:"div",className:"relative z-[10000]",onClose:t,children:[(0,O.jsx)(le.Child,{as:pe.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,O.jsx)("div",{"aria-hidden":"true",className:"fixed inset-0 z-40 bg-black bg-opacity-20"})}),(0,O.jsx)(le.Child,{as:pe.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,O.jsxs)(fe.Panel,{className:w("rounded-l-none fixed bottom-0 left-0 right-0 top-0 z-[100] flex h-full w-full flex-col overflow-y-scroll bg-white sm:overflow-y-auto md:bottom-auto md:left-auto md:w-[480px]","md:rounded-l-xl"),children:[(0,O.jsx)(ct,{onClose:t}),(0,O.jsx)(r.Form,{method:"POST",className:"contents",children:(0,O.jsx)(We,{onClose:t})})]})})]})})};function ct({onClose:e}){return(0,O.jsx)("header",{className:w("sticky top-0 z-[1] flex items-center justify-between bg-white"),children:(0,O.jsxs)("div",{className:"mb-2 flex w-full items-center justify-between px-4 py-8 lg:px-8",children:[(0,O.jsx)("div",{className:"flex flex-grow items-center gap-3 text-xl font-bold leading-none text-black",children:"Add location"}),(0,O.jsx)("button",{type:"button",onClick:e,children:(0,O.jsx)(we,{})})]})})}var ue=n(ee());var b=n(l()),Qe=({customer:e,addresses:t})=>(0,b.jsx)(b.Fragment,{children:(0,b.jsxs)("div",{className:"relative col-span-3 mt-3 grid w-full md:mt-0",children:[(0,b.jsx)("div",{id:"address",className:"absolute top-0 h-[180px] translate-y-[-100%] lg:h-[100px]"}),(0,b.jsxs)("div",{className:"relative mb-6 mt-2 flex w-full flex-col items-center justify-center gap-6 pt-15 md:mb-4 md:max-h-[26.4px] md:max-w-fit md:flex-row md:justify-start md:gap-3 md:pt-0",children:[(0,b.jsxs)("div",{className:"flex items-center justify-center gap-3.5 pr-6 md:justify-start",children:[(0,b.jsx)(f,{src:m.delivery,width:20,height:20,className:"flex h-5 items-center justify-center"}),(0,b.jsx)(p.H3,{className:"whitespace-nowrap text-xl font-bold",children:"Address Book"})]}),!!t?.length&&(0,b.jsx)(re.Primary,{className:"right-0 inline-flex h-12 !max-w-fit bg-[#AAA9AA] leading-[150%] hover:bg-[#AAA9AA] md:absolute md:translate-x-[100%]",children:(0,b.jsx)(F,{to:"/account/address/add",preventScrollReset:!0,children:"Add Address"})})]}),(0,b.jsxs)("div",{className:w("mb-2 w-full gap-4 md:gap-8",t?.length?"grid grid-cols-1 md:grid-cols-3":"flex flex-col items-center justify-center"),children:[!!t?.length&&(0,b.jsxs)(b.Fragment,{children:[e.defaultAddress&&(0,b.jsx)(oe,{address:e.defaultAddress,defaultAddress:!0}),t.filter(r=>r.id!==e.defaultAddress?.id).map(r=>(0,b.jsx)(oe,{address:r},r.id))]}),!t?.length&&(0,b.jsxs)("div",{className:"flex flex-col items-center justify-center gap-5",children:[(0,b.jsx)(p.P2,{children:"You haven't saved any addresses yet."}),(0,b.jsx)(re.Primary,{className:"inline-flex h-12 !w-auto",children:(0,b.jsx)(F,{to:"/account/address/add",preventScrollReset:!0,children:"Add Address"})})]})]})]})});var x=n(l());function Ke({customer:e}){let{firstName:t,lastName:r,email:i,phone:o}=e;return(0,x.jsx)(x.Fragment,{children:(0,x.jsxs)("div",{className:"relative mt-16 flex min-h-[264px] w-full flex-col self-start lg:mt-0",children:[(0,x.jsx)("div",{id:"profile",className:"absolute top-0 h-[180px] translate-y-[-100%] lg:h-[100px]"}),(0,x.jsxs)("div",{className:"mb-5 mt-2 flex items-center justify-center gap-3 md:justify-start",children:[(0,x.jsx)(f,{src:m.user,width:20,height:20}),(0,x.jsx)(p.H3,{className:"align-baseline text-xl font-bold",children:"Profile"})]}),(0,x.jsxs)("div",{className:"mt-2 flex w-full flex-grow flex-col space-y-4 rounded-lg border-2 border-GREY_THREE p-6 text-sm font-[600] text-BLACK md:text-md",children:[(0,x.jsxs)("div",{className:"space-y-1",children:[(0,x.jsx)("div",{className:"text-sm font-[400] text-darkGray",children:"Name"}),(0,x.jsxs)("p",{className:w(!t&&!r&&"italic text-darkGray"),children:[t||r?(t?t+" ":"")+r:"Add name"," "]})]}),(0,x.jsxs)("div",{className:"space-y-1",children:[(0,x.jsx)("div",{className:"text-sm font-[400] text-darkGray",children:"Phone"}),(0,x.jsx)("p",{className:w(!o&&"italic text-darkGray"),children:o??"Not added"})]}),(0,x.jsxs)("div",{className:"space-y-1",children:[(0,x.jsx)("div",{className:"text-sm font-[400] text-darkGray",children:"Email address"}),(0,x.jsx)("p",{className:"break-all",children:i})]}),(0,x.jsx)("div",{className:"flex flex-grow items-end pt-2",children:(0,x.jsx)(F,{prefetch:"intent",className:"rounded-lg border-2 border-GREY_TWO px-4 py-2 font-inter text-sm text-black",to:"/account/edit",preventScrollReset:!0,children:"Edit"})})]})]})})}var se=n(l()),Ze=()=>(0,se.jsx)(se.Fragment,{children:(0,se.jsx)(te,{})});var G=n(ee());var H=n(l()),Je=({searchQuery:e,handleSearchQueryChange:t,statusList:r,handleSelectStatus:i,currentStatus:o})=>(0,H.jsxs)("div",{className:"flex w-full flex-col items-center justify-between gap-10 lg:flex-row lg:gap-0",children:[(0,H.jsx)("h2",{className:"text-center text-xl font-bold lg:text-start",children:"Order History"}),(0,H.jsxs)("div",{className:"flex flex-col gap-5 lg:w-[calc(50%-16px)] lg:flex-row lg:gap-8",children:[(0,H.jsxs)("div",{className:"relative flex w-full",children:[(0,H.jsx)(f,{src:m.search,width:16,height:16,className:"absolute left-4 top-4"}),(0,H.jsx)(Y.TextInput,{className:"h-12 !pl-10",placeholder:"Search by order number",value:e||void 0,onChange:t})]}),(0,H.jsx)(Y.Dropdown,{items:r.map(a=>a[1]),select:i,current:o,placeholder:"Order status"})]})]});var N=n(l()),Xe=({order:e})=>{let[t]=j(),r=t.data.currency.symbol;if(!e?.id)return null;let[i,o]=e.id.split("/").pop().split("?"),a=ae(e?.lineItems||[]),u=a.map(c=>({merchandiseId:c.variant?.id,quantity:c.quantity,attributes:c.customAttributes?.filter(g=>g.key!=="customization_notes"&&g.key!=="_checkout_line_item_key")})),s=c=>{let g=new Date(c).toDateString().split(" ");return`${g[1]} ${g[2]}, ${g[3]}`};return(0,N.jsxs)("li",{className:"flex flex-col rounded",children:[(0,N.jsx)(F,{to:`/account/orders/${i}?${o}${e.cursor?`&cursor=${e.cursor}`:""}`,children:(0,N.jsxs)("div",{className:"bg-primary/5 relative my-2 aspect-square overflow-hidden rounded-lg border-2 border-GREY_THREE",children:[(0,N.jsx)("div",{className:"mb-1 inline-flex",children:(0,N.jsx)(J,{mode:e.fulfillmentStatus==="FULFILLED"?"outline":"default",label:Oe(e.fulfillmentStatus)})}),a?.[0]?.variant?.image||a?.[1]?.variant?.image?(0,N.jsx)(ie,{alt:a[0].variant?.image?.altText??"Order image",className:"fadeIn w-full object-contain",data:a?.[0]?.variant?.image||a?.[1]?.variant?.image,height:200,crop:"center",width:200}):(0,N.jsx)(f,{src:m.medshopPlugImg,width:168,height:168,className:"fadeIn w-full object-contain"})]})}),(0,N.jsxs)("ul",{className:"mt-2 flex-1 flex-row gap-1 space-y-1",children:[(0,N.jsxs)("li",{className:"flex w-full gap-2",children:[(0,N.jsxs)(p.P2,{className:"text-sm font-[400] leading-[140%] text-[#888888]",children:["#",e.orderNumber]}),(0,N.jsxs)(p.P2,{className:"text-sm font-[400] leading-[140%] text-[#888888]",children:["on ",s(e.processedAt)]})]}),(0,N.jsx)("li",{children:(0,N.jsx)(F,{to:`/account/orders/${i}?${o}`,children:(0,N.jsx)(p.P2,{className:"font-[600] leading-[140%]",children:a.length>1?`${a[0]?.title} +${a.length-1} more`:a[0]?.title})})}),(0,N.jsx)("li",{className:"pt-2",children:(0,N.jsxs)(p.P2,{className:"flex !text-md font-[700] !leading-[150%]",children:[r,(0,N.jsx)(ne,{data:e.currentTotalPrice,withoutCurrency:!0})]})})]}),(0,N.jsxs)("div",{className:"mt-4 flex flex-row gap-5 text-sm font-medium",children:[(0,N.jsx)(F,{className:w(" flex justify-center rounded-lg border-2 px-4 py-2 text-center text-sm font-[600] leading-[140%]",e.fulfillmentStatus==="FULFILLED"?"bg-[#3BB900] text-white":"border-GREY_TWO text-black"),to:`/account/orders/${i}?${o}`,children:"View details"}),e.fulfillmentStatus==="FULFILLED"&&(0,N.jsx)(Me,{lines:u})]})]})};var be=n(l()),et=({orders:e})=>(0,be.jsx)("ul",{className:"grid grid-flow-row grid-cols-1 gap-8 md:grid-cols-2 md:gap-8 lg:grid-cols-4",children:e.map(t=>(0,be.jsx)(Xe,{order:t},t.id))});var S=n(l()),mt={ALL:"All",FULFILLED:"Fulfilled",UNFULFILLED:"Unfulfilled"};function xe({orders:e,pageInfo:t}){let[r,i]=(0,G.useState)(null),[o,a]=(0,G.useState)(null),u=K(),s=Q(),c=Object.entries(mt);(0,G.useEffect)(()=>{let L=me(C=>{u(C?s.pathname+"?query="+C:s.pathname)},500);r&&L(r),r===""&&L()},[r]);let g=L=>{let{value:C}=L.target;i(C)},R=L=>{if(L){let C=c.find(q=>q[1]===L)?.[0];if(C){a(C);return}}a(null)},D=(0,G.useMemo)(()=>c.find(L=>L[0]===o)?.[1]||"",[o,c]),M=(0,G.useMemo)(()=>o&&o!=="ALL"?e?.filter(L=>L.fulfillmentStatus===o):e,[e,o]);return(0,S.jsxs)("div",{className:"relative mt-10 flex w-full flex-col justify-center lg:mt-20 lg:justify-start",children:[(0,S.jsx)("div",{id:"orders",className:"absolute top-0 h-[180px] translate-y-[-100%] lg:h-[100px]"}),(0,S.jsx)(Je,{handleSearchQueryChange:g,statusList:c,handleSelectStatus:R,currentStatus:D}),(0,S.jsxs)("div",{className:"mt-10 border-b-2 border-[#E6E6E6] pb-10 lg:mt-7 lg:pb-15",children:[!e?.length&&!r&&!o&&(0,S.jsx)(p.H2,{children:"You haven't placed any orders yet."}),!e?.length&&r&&!o&&(0,S.jsx)(p.H2,{children:"Could not find orders with this order number"}),!M?.length&&o&&(0,S.jsx)(p.H2,{children:"Could not find orders with this status"}),!!M?.length&&(0,S.jsx)(et,{orders:M}),(t?.hasPreviousPage||t?.hasNextPage)&&(0,S.jsxs)("div",{className:"flex w-full justify-center gap-9 pt-10",children:[!!t?.hasPreviousPage&&(0,S.jsxs)("div",{className:"flex items-center gap-2",children:[(0,S.jsx)(f,{src:m.arrowRight,width:20,height:20,className:"h-4 rotate-180"}),(0,S.jsx)(_,{className:"font-inter text-GREY_ONE",to:`${s.pathname}?startCursor=${t?.startCursor}`,children:"Previous"})]}),!!t?.hasNextPage&&(0,S.jsxs)("div",{className:"flex items-center gap-2",children:[(0,S.jsx)(_,{className:"font-inter text-GREY_ONE",to:`${s.pathname}?endCursor=${t?.endCursor}`,children:"Next"}),(0,S.jsx)(f,{src:m.arrowRight,width:20,height:20,className:"h-4"})]})]})]})]})}var T=n(l());function Ne(){let e=k(),t=Ae(),r=j(),{revalidate:i}=Te(),o=Q(),a=K();(0,ue.useEffect)(()=>{o.search.includes("update=true")&&(i(),a(".",{preventScrollReset:!0}))},[o.search]);let u=r.some(s=>s?.handle?.renderInModal);return e.isAuthenticated?t?u?(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(te,{context:{customer:e.customer}}),(0,T.jsx)(tt,{...e})]}):(0,T.jsx)(te,{context:{customer:e.customer}}):(0,T.jsx)(tt,{...e}):(0,T.jsx)(Ze,{})}function tt({customer:e,orders:t,heading:r,addresses:i,company:o}){let[a]=j(),u=a.data.layout.benefits,s=ae(o?.locations||[]),c=(0,ue.useMemo)(()=>o?[]:t.edges.map(g=>({...g.node,cursor:g.cursor})),[]);return(0,T.jsxs)("div",{className:"content-wrapper flex-col",children:[(0,T.jsx)(Ee,{heading:r,company:o}),t&&!o&&(0,T.jsx)(xe,{orders:c,pageInfo:t.pageInfo}),o&&(0,T.jsx)(je,{}),t&&o&&(0,T.jsx)(qe,{orders:t,locations:s}),(0,T.jsxs)("div",{className:"grid w-full grid-cols-1 lg:grid-cols-4 lg:gap-8 lg:pt-13",children:[e&&(0,T.jsx)(Ke,{customer:e}),o?(0,T.jsx)(Fe,{}):(0,T.jsx)(Qe,{addresses:i,customer:e})]}),u&&(0,T.jsx)("div",{className:"mt-11 w-screen md:mt-16",children:(0,T.jsx)(Be,{secondary:!0,benefits:u})})]})}var pt=({data:e})=>({title:$e("Account details",e?.storeDomain)}),ut={seo:pt,isPublic:!0};var gt=Ne;export{gt as default,ut as handle};