import{s as i,bW as h,g as f,bX as g,bY as O,L as l,bZ as w,P as b}from"./index-8PssKxKU.js";import{m as a,r as A,ah as P}from"./vendor-DWvj1jit.js";async function $(e){await i.mutate({mutation:h,variables:{command:e}})}async function q(e){const{data:t}=await i.query({query:g,variables:{...e,cultureName:f.cultureName}});return t.order}async function D(e){const{data:t}=await i.query({query:O,variables:{...e,cultureName:f.cultureName}});return t.order}const s=A(!1),r=P(),G=a(()=>(r.value?.items||[]).filter(e=>e.isGift)),v=a(()=>(r.value?.items||[]).filter(e=>!e.isGift)),I=a(()=>w(v.value)),L=a(()=>!!r.value?.items?.every(e=>e.productType===b.Digital)),c=a(()=>r.value?.shipments?.[0]),y=a(()=>r.value?.inPayments?.[0]),N=a(()=>c.value?.deliveryAddress),U=a(()=>c.value?.pickupLocation),F=a(()=>y.value?.billingAddress);function o(){async function e(u){s.value=!0;try{r.value=await D(u)}catch(n){throw l.error(`${o.name}.${e.name}`,n),n}finally{s.value=!1}}async function t(u){s.value=!0;try{r.value=await q(u)}catch(n){throw l.error(`${o.name}.${t.name}`,n),n}finally{s.value=!1}}function p(){r.value=void 0}async function d(u,n=!0){s.value=!0;try{await $(u)}catch(m){throw l.error(`${o.name}.${d.name}`,m),m}finally{s.value=!1}n&&await t({id:u.orderId})}return{loading:a(()=>s.value),order:a(()=>r.value),allItemsAreDigital:L,giftItems:G,orderItems:v,orderItemsGroupedByVendor:I,deliveryAddress:N,pickupLocation:U,billingAddress:F,shipment:c,payment:y,fetchShortOrder:e,fetchFullOrder:t,clearOrder:p,addOrUpdatePayment:d}}export{o as u};
//# sourceMappingURL=useUserOrder-BvF6hr1h.js.map
