import{l as C,S as g,o as d,c as l,a as s,u as t,e as f,f as v,h as u,t as a,n as x,g as h,D as p,s as y,F as b,j as $}from"../vendor-3-7-95.js";import{a as _}from"../ajax-3-7-95.js";import{S as k}from"../SetDefaultBadge-3-7-95.js";import{_ as S}from"../PrimaryButton-3-7-95.js";import{u as B}from"../CheckoutStore-3-7-95.js";import{i as j}from"../admin-app-3-7-95.js";import"../store-3-7-95.js";import"../_plugin-vue_export-helper-3-7-95.js";const D=C("UserSavedCards",{state:()=>({isProActive:window.gpos.is_pro_active||!1,isTestMode:window.gpos.is_test_mode||!1,assetsUrl:window.gpos.asset_dir_url||"/",savedCards:window.gpos.saved_cards||[]}),actions:{async setDefault(e){await _.post("set_default_saved_card",{id:e}),this.swalFire()},async deleteCard(e){await _.post("delete_saved_card",{id:e}),this.swalFire()},swalFire(){g.fire({html:window.gpos.alert_texts.process_success,icon:"success",confirmButtonText:window.gpos.alert_texts.ok,confirmButtonColor:"#1A56DB"}).then(()=>window.location.reload())}}}),F={class:"w-full flex bg-[#fbfbfb] border rounded border-gray-200 px-3 py-4 items-center"},A={class:"w-2/12 flex justify-center"},T=["src","alt"],U={class:"w-2/12"},N={class:"w-3/12"},V={class:"w-2/12 text-end"},L={class:"w-1/12 text-end"},q={class:"w-2/12 flex justify-end items-center gap-1"},z={__name:"SavedCard",props:{savedCard:{required:!0,type:Object}},setup(e){const{assetsUrl:r,setDefault:c,deleteCard:m,savedCards:o}=D();return(i,n)=>(d(),l("div",F,[s("div",A,[s("img",{class:"w-9 h-9 object-contain rounded-md",src:`${t(r)}/images/card/${e.savedCard.card_family?e.savedCard.card_family.toLowerCase().replaceAll(/\s/g,""):"default"}.svg
          `,alt:e.savedCard.card_family},null,8,T)]),s("div",U,[e.savedCard.default?(d(),f(k,{key:0},{default:v(()=>[u(a(i.$t("default")),1)]),_:1})):(d(),f(S,{key:1,class:"!inline-flex !items-center !bg-blue-700 !text-white !text-xs !font-medium !mr-2 !px-2.5 !py-0.5 !rounded-full",onClick:n[0]||(n[0]=w=>t(c)(e.savedCard.id))},{default:v(()=>[u(a(i.$t("make_default")),1)]),_:1}))]),s("div",N,a(e.savedCard.card_name||i.$t("saved_card")),1),s("div",V,a(e.savedCard.masked_card_bin),1),s("div",L,a(e.savedCard.card_expiry_month)+"/"+a(e.savedCard.card_expiry_year.substr(-2)),1),s("div",q,[s("div",{class:x(`flex items-center justify-end gap-1 ${!e.savedCard.default||t(o).length===1?"text-red-600 cursor-pointer":"pointer-events-none text-gray-300"}`),onClick:n[1]||(n[1]=w=>t(m)(e.savedCard.id))},[h(t(p),{class:"w-6 h-6"}),u(" "+a(i.$t("delete")),1)],2)])]))}},E={key:0,class:"w-full flex flex-col gap-3"},M={key:1},O={class:"w-full flex p-4 bg-blue-200 text-blue-600 rounded"},P={__name:"App",setup(e){const{savedCards:r}=y(B());return(c,m)=>t(r).length>0?(d(),l("div",E,[(d(!0),l(b,null,$(t(r),o=>(d(),f(z,{key:o.id,"saved-card":o},null,8,["saved-card"]))),128))])):(d(),l("div",M,[s("div",O,a(c.$t("saved_card_not_found")),1)]))}};j(P);
