import{F as j,ai as I,aD as Q,P as r,Q as b,R as d,T as t,_ as y,X as m,W as X,a1 as i,a2 as N,a0 as s,m as x,e as p,r as M,a5 as q,a6 as G}from"./vendor-DWvj1jit.js";import{aW as J,h as K,bV as Y,o as Z,a_ as D,x as ee}from"./index-8PssKxKU.js";import{A as se}from"./address-type.enum-CGCAFS3X.js";import{_ as T}from"./address-dropdown-menu.vue_vue_type_script_setup_true_lang-B49aWyHh.js";const te={class:"flex items-center justify-between"},oe={class:"sm:hidden"},ne={class:"hidden sm:inline"},ae={class:"relative grid grid-cols-2 gap-y-4 border-b border-neutral-200 p-6"},le={class:"flex flex-col"},ie={class:"text-sm text-neutral-400"},de={class:"overflow-hidden text-ellipsis pr-4 font-black"},ce={class:"flex flex-col"},re={class:"text-sm text-neutral-400"},me={class:"overflow-hidden text-ellipsis"},pe={class:"flex flex-col"},ue={class:"text-sm text-neutral-400"},_e={class:"overflow-hidden text-ellipsis pr-4"},ve={class:"flex flex-col"},fe={class:"text-sm text-neutral-400"},he={class:"overflow-hidden text-ellipsis"},ge={class:"overflow-hidden text-ellipsis p-5"},be={class:"overflow-hidden text-ellipsis p-5"},ye={class:"overflow-hidden text-ellipsis p-5"},xe={class:"overflow-hidden text-ellipsis p-5"},we={class:"p-5 text-end"},Ne=j({__name:"addresses",setup(Ce){const{t:n}=I(),{countries:B,loadCountries:E}=Y(),{loading:u,addresses:w,sort:C,fetchAddresses:V,removeAddresses:P,addOrUpdateAddresses:W}=J(),{openModal:$,closeModal:S}=Z(),U=ee();K({title:n("pages.account.addresses.meta.title")});const l=M(1),f=M(6),h=x(()=>Math.ceil(w.value.length/f.value)),_=x(()=>w.value.slice((l.value-1)*f.value,l.value*f.value)),z=x(()=>[{id:"firstName",title:n("common.labels.recipient_name"),sortable:!0},{id:"countryCode",title:n("common.labels.address"),sortable:!0},{id:"phone",title:n("common.labels.phone"),sortable:!0},{id:"email",title:n("common.labels.email"),sortable:!0}]);function F(o){window.scroll({top:0,behavior:"smooth"}),l.value=o}function v(o){$({component:D,props:{address:o,loading:u,async onResult(a){await W([{...a,addressType:se.BillingAndShipping}]),S()}}})}async function H(o){C.value=o,l.value=1,await V()}function k(o){const a=$({component:"VcConfirmationModal",props:{variant:"danger",loading:u,title:n("common.titles.delete_address"),text:n("common.messages.confirm_delete_address"),async onConfirm(){const c=h.value;await P([o]),U.success({text:n("common.messages.address_deletion_successful"),duration:1e4,single:!0}),c>1&&c===l.value&&c>h.value&&(l.value-=1),a()}}})}return Q(async()=>{await V(),B.value.length||await E()}),(o,a)=>{const c=r("VcTypography"),A=r("VcButton"),L=r("VcEmptyView"),O=r("VcTable"),R=r("VcWidget");return d(),b("div",null,[t("div",te,[m(c,{tag:"h1"},{default:i(()=>[N(s(o.$t("common.titles.addresses")),1)]),_:1}),_.value.length?(d(),y(A,{key:0,size:"sm",variant:"outline",onClick:a[0]||(a[0]=e=>v())},{default:i(()=>[t("span",oe,s(o.$t("common.buttons.add_new")),1),t("span",ne,s(o.$t("common.buttons.add_new_address")),1)]),_:1})):X("",!0)]),!_.value.length&&!p(u)?(d(),y(L,{key:0,text:o.$t("common.messages.no_addresses"),icon:"outline-address"},{button:i(()=>[m(A,{"prepend-icon":"plus",onClick:a[1]||(a[1]=e=>v())},{default:i(()=>[N(s(o.$t("common.buttons.add_new_address")),1)]),_:1})]),_:1},8,["text"])):(d(),y(R,{key:1,size:"lg"},{"default-container":i(()=>[m(O,{loading:p(u),columns:z.value,sort:p(C),items:_.value,pages:h.value,page:l.value,description:o.$t("pages.account.addresses.meta.table_description"),onPageChanged:F,onHeaderClick:H},{"mobile-item":i(e=>[t("div",ae,[t("div",le,[t("span",ie,s(o.$t("common.labels.recipient_name")),1),t("span",de,s(e.item.firstName)+" "+s(e.item.lastName),1)]),t("div",ce,[t("span",re,s(o.$t("common.labels.address")),1),t("span",me,s(e.item.countryCode)+" "+s(e.item.regionName)+" "+s(e.item.city)+" "+s(e.item.line1)+" "+s(e.item.postalCode),1)]),t("div",pe,[t("span",ue,s(o.$t("common.labels.phone")),1),t("span",_e,s(e.item.phone),1)]),t("div",ve,[t("span",fe,s(o.$t("common.labels.email")),1),t("span",he,s(e.item.email),1)]),m(p(T),{class:"absolute right-4 top-3",address:e.item,placement:"left-start",onEdit:g=>v(e.item),onDelete:g=>k(e.item)},null,8,["address","onEdit","onDelete"])])]),"desktop-body":i(()=>[(d(!0),b(q,null,G(_.value,e=>(d(),b("tr",{key:e.id,class:"even:bg-neutral-50"},[t("td",ge,s(e.firstName)+" "+s(e.lastName),1),t("td",be,s(e.countryCode)+" "+s(e.regionName)+" "+s(e.city)+" "+s(e.line1)+" "+s(e.postalCode),1),t("td",ye,s(e.phone),1),t("td",xe,s(e.email),1),t("td",we,[m(p(T),{class:"inline-block",address:e,onEdit:g=>v(e),onDelete:g=>k(e)},null,8,["address","onEdit","onDelete"])])]))),128))]),_:1},8,["loading","columns","sort","items","pages","page","description"])]),_:1}))])}}});export{Ne as default};
//# sourceMappingURL=addresses-DorF_3qi.js.map
