import{u as y}from"./data-D7xXWmPy.js";import{j as g,y as k,q as w,f as s,i as x,b as e,v as o,e as d,w as v,F as B,t as C,c as i,r as n,o as _}from"./index-DLUb5LSe.js";import{_ as I}from"./TopBar.vue_vue_type_script_setup_true_lang-DNeo4_WD.js";import{_ as $}from"./BottomNav.vue_vue_type_script_setup_true_lang-BcRvF8NM.js";const j={class:"pb-32 min-h-dvh"},D={class:"max-w-md mx-auto px-4 pt-2"},N={key:0,class:"rounded-card bg-amber-50 border border-amber-200 p-4 mb-4"},S={class:"text-display text-amber-900 mt-1"},V={class:"mt-3 flex gap-2"},F=["href"],L=["href"],P={key:1,class:"text-center py-12 text-ink-muted"},T={class:"flex items-start justify-between gap-3"},q={class:"flex-1 min-w-0"},z={class:"font-bold"},E={class:"text-meta text-ink-muted"},H={class:"mt-3 grid grid-cols-3 gap-2 text-meta"},M={class:"font-bold tabular-nums"},O={class:"font-bold tabular-nums"},J=g({__name:"InvoicesView",setup(R){const u=y(),c=k();w(()=>u.loadInvoices());const m=i(()=>u.invoices??[]),f=r=>({paid:"bg-emerald-50 text-emerald-700 border-emerald-200",partial:"bg-amber-50   text-amber-800   border-amber-200",due:"bg-red-50     text-red-700     border-red-200"})[r]??"bg-slate-50 text-slate-700 border-slate-200",p=i(()=>m.value.reduce((r,t)=>r+(t.balance>0?t.balance:0),0)),l=r=>r.toLocaleString(void 0,{maximumFractionDigits:2}),b=i(()=>(c.brand.contact_phone??"").replace(/[^0-9]/g,"")),h=i(()=>`https://wa.me/${b.value}?text=${encodeURIComponent("Hi, I would like to pay an open invoice.")}`);return(r,t)=>(n(),s("div",j,[x(I),e("main",D,[t[5]||(t[5]=e("h1",{class:"text-display py-4"},"Invoices",-1)),p.value>0?(n(),s("div",N,[t[0]||(t[0]=e("div",{class:"text-meta uppercase tracking-wider text-amber-800 font-bold"},"Outstanding balance",-1)),e("div",S,o(l(p.value)),1),e("div",V,[b.value?(n(),s("a",{key:0,href:h.value,target:"_blank",rel:"noopener",class:"flex-1 h-10 rounded-pill bg-emerald-600 text-white font-bold text-meta inline-flex items-center justify-center"},"💬 Pay via clinic",8,F)):d("",!0),v(c).brand.contact_phone?(n(),s("a",{key:1,href:`tel:${v(c).brand.contact_phone}`,class:"flex-1 h-10 rounded-pill bg-white text-emerald-800 font-bold text-meta inline-flex items-center justify-center border border-emerald-200"},"📞 Call",8,L)):d("",!0)])])):d("",!0),m.value.length===0?(n(),s("div",P,[...t[1]||(t[1]=[e("div",{class:"text-5xl mb-3 opacity-60"},"🧾",-1),e("p",{class:"text-meta"},"No invoices yet.",-1)])])):d("",!0),(n(!0),s(B,null,C(m.value,a=>(n(),s("article",{key:a.id,class:"rounded-card bg-surface shadow-card p-4 mb-3"},[e("div",T,[e("div",q,[e("div",z,o(a.invoice_no),1),e("div",E,o(a.date_label),1)]),e("span",{class:_(["px-2 py-0.5 rounded-pill text-[10px] font-bold uppercase border",f(a.payment_status)])},o(a.payment_status),3)]),e("div",H,[e("div",null,[t[2]||(t[2]=e("div",{class:"text-micro uppercase text-ink-subtle"},"Total",-1)),e("div",M,o(l(a.total)),1)]),e("div",null,[t[3]||(t[3]=e("div",{class:"text-micro uppercase text-ink-subtle"},"Paid",-1)),e("div",O,o(l(a.paid)),1)]),e("div",null,[t[4]||(t[4]=e("div",{class:"text-micro uppercase text-ink-subtle"},"Balance",-1)),e("div",{class:_(["font-bold tabular-nums",a.balance>0?"text-red-600":"text-emerald-700"])},o(l(a.balance)),3)])])]))),128))]),x($)]))}});export{J as default};
//# sourceMappingURL=InvoicesView-DzszSWrL.js.map
