import{j as e,a as h}from"./ui-vendor-oFzHwyuF.js";import{u as p,r as o}from"./react-vendor-BJie2xkO.js";import{i as f,c as j,T as b,R as v}from"./format-a-HSotw1.js";import{B as N}from"./BottomNav-K-woSEft.js";import{V as y}from"./VirtualList-CXeAoZhz.js";import{s as g}from"./guestService-CqI2mvSO.js";import{S as k}from"./main-Bfm0Ar4t.js";import"./api-DAXyRoTB.js";const w={SINGLE:"bg-blue-100 text-blue-700",DOUBLE:"bg-purple-100 text-purple-700",GROUP:"bg-orange-100 text-orange-700"};function S({guest:t,style:l}){const s=p(),n=t.checked_in_count>=t.total_attendees;return e.jsxs("div",{style:l,className:"flex items-center gap-3 px-4 py-3 border-b border-slate-100 bg-white active:bg-slate-50 cursor-pointer transition-colors",onClick:()=>s(`/checkin-app/guest/${t.id}`),children:[e.jsx("div",{className:"h-11 w-11 rounded-full bg-primary text-white flex items-center justify-center text-sm font-bold shrink-0",children:f(t.name)}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-semibold text-slate-900 truncate",children:t.name}),e.jsxs("p",{className:"text-xs text-slate-500 mt-0.5",children:[e.jsx("span",{className:`inline-flex items-center px-1.5 py-0.5 rounded text-xs font-medium mr-1.5 ${w[t.card_type]??"bg-slate-100 text-slate-600"}`,children:j(t.card_type)}),t.card_number?`#${t.card_number}`:"No card #"]})]}),e.jsx("button",{onClick:r=>{r.stopPropagation(),s(`/checkin-app/guest/${t.id}`)},className:`shrink-0 h-10 w-10 rounded-full flex items-center justify-center transition-all active:scale-90 ${n?"bg-emerald-100 text-emerald-600":"bg-primary text-white shadow"}`,"aria-label":"View guest detail",children:e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",strokeWidth:2.5,viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})})]})}const C=150;function L(t="all"){const[l,s]=o.useState(""),[n,r]=o.useState([]),[x,i]=o.useState(!1);return o.useEffect(()=>{const u=l.trim();if(!u){r([]),i(!1);return}i(!0);const m=setTimeout(()=>{try{let c=g(u);t==="checked"?c=c.filter(d=>d.checked_in_count>0):t==="pending"&&(c=c.filter(d=>d.checked_in_count<d.total_attendees)),r(c)}catch{r([])}finally{i(!1)}},C);return()=>clearTimeout(m)},[l,t]),{query:l,setQuery:s,results:n,setResults:r,isSearching:x,clear:()=>{s(""),r([])}}}const _=[{value:"all",label:"All"},{value:"pending",label:"Pending"},{value:"checked",label:"Checked In"}];function $(){const[t,l]=o.useState("all"),{query:s,setQuery:n,results:r,isSearching:x,clear:i}=L(t);return e.jsxs("div",{className:"flex flex-col h-dvh bg-white",children:[e.jsx(b,{title:"Search Guests",action:e.jsx(v,{})}),e.jsxs("div",{className:"px-4 py-3 bg-white border-b border-slate-100 sticky z-10",style:{top:"var(--topbar-h)"},children:[e.jsxs("div",{className:"relative",children:[e.jsxs("svg",{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-slate-400",fill:"none",stroke:"currentColor",strokeWidth:2,viewBox:"0 0 24 24",children:[e.jsx("circle",{cx:"11",cy:"11",r:"8"}),e.jsx("path",{strokeLinecap:"round",d:"M21 21l-4.35-4.35"})]}),e.jsx("input",{type:"search",value:s,onChange:a=>n(a.target.value),placeholder:"Name or card number…",className:"w-full pl-9 pr-10 py-3 bg-slate-100 rounded-xl text-sm focus:outline-none focus:ring-2 focus:ring-primary/30",autoFocus:!0}),s&&e.jsx("button",{onClick:i,className:"absolute right-3 top-1/2 -translate-y-1/2 text-slate-400 hover:text-slate-600",children:e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",strokeWidth:2,viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),e.jsx("div",{className:"flex gap-2 mt-2",children:_.map(a=>e.jsx("button",{onClick:()=>l(a.value),className:h("px-3 py-1.5 rounded-full text-xs font-medium transition-colors",t===a.value?"bg-primary text-white":"bg-slate-100 text-slate-600"),children:a.label},a.value))})]}),e.jsx("div",{className:"flex-1 overflow-hidden",children:x?e.jsx("div",{className:"flex justify-center mt-12",children:e.jsx(k,{size:"md",className:"text-slate-400"})}):s?r.length===0?e.jsx("div",{className:"flex flex-col items-center justify-center mt-12 text-slate-400 px-8",children:e.jsxs("p",{className:"text-sm",children:["No results for “",s,"”"]})}):e.jsx(y,{items:r,estimateSize:72,className:"h-full pb-24",renderItem:a=>e.jsx(S,{guest:a})}):e.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-slate-400 px-8",children:[e.jsxs("svg",{className:"w-16 h-16 mb-4 opacity-30",fill:"none",stroke:"currentColor",strokeWidth:1,viewBox:"0 0 24 24",children:[e.jsx("circle",{cx:"11",cy:"11",r:"8"}),e.jsx("path",{strokeLinecap:"round",d:"M21 21l-4.35-4.35"})]}),e.jsx("p",{className:"text-sm text-center",children:"Type a name or card number to search"})]})}),e.jsx(N,{})]})}export{$ as Search};
