import{j as w,D as y,f as n,i as h,b as s,H as C,C as V,F as l,t as p,e as d,s as _,A as $,r as i,w as m,v as a,h as N}from"./index-DLUb5LSe.js";import{u as S}from"./data-D7xXWmPy.js";import{_ as D}from"./TopBar.vue_vue_type_script_setup_true_lang-DNeo4_WD.js";import{_ as T}from"./BottomNav.vue_vue_type_script_setup_true_lang-BcRvF8NM.js";const B={class:"pb-32 min-h-dvh"},F={class:"max-w-md mx-auto px-4 pt-2"},j={key:0,class:"mt-4 text-meta text-ink-muted"},I={key:1,class:"mt-6 text-center text-meta text-ink-muted"},P={key:0,class:"mt-5"},q=["onClick"],A={class:"w-10 h-10 rounded-card bg-brand-50 text-2xl flex items-center justify-center"},E={class:"flex-1 min-w-0"},H={class:"font-bold"},L={class:"text-meta text-ink-muted"},M={key:1,class:"mt-5"},R={class:"font-bold"},U={class:"text-ink-subtle"},z={class:"text-meta text-ink-muted"},G={key:2,class:"mt-5"},J={class:"font-bold"},K={class:"text-meta text-ink-muted"},O={key:3,class:"mt-5"},Q={class:"font-bold"},W={class:"text-meta text-ink-muted"},st=w({__name:"SearchView",setup(X){const k=S(),c=$(),u=_(""),o=_({pets:[],appointments:[],prescriptions:[],invoices:[]}),v=_(!1);let f=null;y(u,r=>{if(f&&clearTimeout(f),r.trim().length<2){o.value={pets:[],appointments:[],prescriptions:[],invoices:[]};return}f=setTimeout(async()=>{v.value=!0,o.value=await k.search(r),v.value=!1},250)});const b=()=>o.value.pets.length+o.value.appointments.length+o.value.prescriptions.length+o.value.invoices.length===0,g=r=>({dog:"🐕",cat:"🐈",rabbit:"🐇",bird:"🦜",fish:"🐟"})[r]??"🐾";return(r,e)=>(i(),n("div",B,[h(D),s("main",F,[e[8]||(e[8]=s("h1",{class:"text-display py-3"},"Search",-1)),C(s("input",{"onUpdate:modelValue":e[0]||(e[0]=t=>u.value=t),placeholder:"Find pets, visits, prescriptions, invoices…",autofocus:"",class:"w-full h-12 px-4 rounded-card bg-surface border border-ink/10 focus:border-brand-500 focus:outline-none"},null,512),[[V,u.value]]),v.value?(i(),n("div",j,"Searching…")):u.value.length>=2&&b()?(i(),n("p",I,"No matches.")):b()?d("",!0):(i(),n(l,{key:2},[o.value.pets.length?(i(),n("section",P,[e[4]||(e[4]=s("div",{class:"text-micro uppercase text-ink-subtle tracking-wider mb-2 px-1"},"Pets",-1)),(i(!0),n(l,null,p(o.value.pets,t=>(i(),n("button",{key:t.id,class:"w-full text-left rounded-card bg-surface shadow-card p-3 mb-2 flex items-center gap-3",onClick:x=>m(c).push(`/pets/${t.id}`)},[s("div",A,a(g(t.species)),1),s("div",E,[s("div",H,a(t.name),1),s("div",L,a(t.breed??"—"),1)])],8,q))),128))])):d("",!0),o.value.appointments.length?(i(),n("section",M,[e[5]||(e[5]=s("div",{class:"text-micro uppercase text-ink-subtle tracking-wider mb-2 px-1"},"Visits",-1)),(i(!0),n(l,null,p(o.value.appointments,t=>(i(),n("button",{key:t.id,class:"w-full text-left rounded-card bg-surface shadow-card p-3 mb-2",onClick:e[1]||(e[1]=x=>m(c).push("/appointments"))},[s("div",R,[N(a(t.type??"Visit")+" ",1),s("span",U,a(t.ref_no),1)]),s("div",z,a(t.date)+" · "+a(t.status),1)]))),128))])):d("",!0),o.value.prescriptions.length?(i(),n("section",G,[e[6]||(e[6]=s("div",{class:"text-micro uppercase text-ink-subtle tracking-wider mb-2 px-1"},"Prescriptions",-1)),(i(!0),n(l,null,p(o.value.prescriptions,t=>(i(),n("button",{key:t.id,class:"w-full text-left rounded-card bg-surface shadow-card p-3 mb-2",onClick:e[2]||(e[2]=x=>m(c).push("/prescriptions"))},[s("div",J,a(t.ref_no),1),s("div",K,a(t.diagnosis??"—")+" · "+a(t.date),1)]))),128))])):d("",!0),o.value.invoices.length?(i(),n("section",O,[e[7]||(e[7]=s("div",{class:"text-micro uppercase text-ink-subtle tracking-wider mb-2 px-1"},"Invoices",-1)),(i(!0),n(l,null,p(o.value.invoices,t=>(i(),n("button",{key:t.id,class:"w-full text-left rounded-card bg-surface shadow-card p-3 mb-2",onClick:e[3]||(e[3]=x=>m(c).push("/invoices"))},[s("div",Q,a(t.invoice_no),1),s("div",W,a(t.date)+" · "+a(t.total)+" · "+a(t.payment_status),1)]))),128))])):d("",!0)],64))]),h(T)]))}});export{st as default};
//# sourceMappingURL=SearchView-CYWMxmly.js.map
