(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3912],{2066:(e,t,r)=>{"use strict";let n;function a(){return"undefined"!=typeof window}function s(e){return l(e)?(e.nodeName||"").toLowerCase():"#document"}function i(e){var t;return(null==e||null==(t=e.ownerDocument)?void 0:t.defaultView)||window}function o(e){var t;return null==(t=(l(e)?e.ownerDocument:e.document)||window.document)?void 0:t.documentElement}function l(e){return!!a()&&(e instanceof Node||e instanceof i(e).Node)}function c(e){return!!a()&&(e instanceof Element||e instanceof i(e).Element)}function d(e){return!!a()&&(e instanceof HTMLElement||e instanceof i(e).HTMLElement)}function u(e){return!!a()&&"undefined"!=typeof ShadowRoot&&(e instanceof ShadowRoot||e instanceof i(e).ShadowRoot)}function f(e){let{overflow:t,overflowX:r,overflowY:n,display:a}=k(e);return/auto|scroll|overlay|hidden|clip/.test(t+n+r)&&"inline"!==a&&"contents"!==a}function m(e){return/^(table|td|th)$/.test(s(e))}function p(e){try{if(e.matches(":popover-open"))return!0}catch(e){}try{return e.matches(":modal")}catch(e){return!1}}r.d(t,{$4:()=>j,CP:()=>w,L9:()=>k,Ll:()=>l,Lv:()=>m,Ng:()=>u,Tc:()=>y,Tf:()=>p,ZU:()=>f,_m:()=>z,ep:()=>o,eu:()=>N,gJ:()=>b,mq:()=>s,sQ:()=>h,sb:()=>d,v9:()=>function e(t,r,n){var a;void 0===r&&(r=[]),void 0===n&&(n=!0);let s=function e(t){let r=j(t);return N(r)?t.ownerDocument?t.ownerDocument.body:t.body:d(r)&&f(r)?r:e(r)}(t),o=s===(null==(a=t.ownerDocument)?void 0:a.body),l=i(s);if(!o)return r.concat(s,e(s,[],n));{let t=z(l);return r.concat(l,l.visualViewport||[],f(s)?s:[],t&&n?e(t):[])}},vq:()=>c,zk:()=>i});let g=/transform|translate|scale|rotate|perspective|filter/,x=/paint|layout|strict|content/,v=e=>!!e&&"none"!==e;function h(e){let t=c(e)?k(e):e;return v(t.transform)||v(t.translate)||v(t.scale)||v(t.rotate)||v(t.perspective)||!y()&&(v(t.backdropFilter)||v(t.filter))||g.test(t.willChange||"")||x.test(t.contain||"")}function b(e){let t=j(e);for(;d(t)&&!N(t);){if(h(t))return t;if(p(t))break;t=j(t)}return null}function y(){return null==n&&(n="undefined"!=typeof CSS&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),n}function N(e){return/^(html|body|#document)$/.test(s(e))}function k(e){return i(e).getComputedStyle(e)}function w(e){return c(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function j(e){if("html"===s(e))return e;let t=e.assignedSlot||e.parentNode||u(e)&&e.host||o(e);return u(t)?t.host:t}function z(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}},7546:(e,t,r)=>{"use strict";r.d(t,{K:()=>l});var n,a=r(12115),s=r(77509);let i=(n||(n=r.t(a,2)))["useInsertionEffect".concat(Math.random().toFixed(1)).slice(0,-3)],o=i&&i!==a.useLayoutEffect?i:e=>e();function l(e){let t=(0,s.useRefWithInit)(c).current;return t.next=e,o(t.effect),t.trampoline}function c(){let e={next:void 0,callback:d,trampoline:function(){for(var t,r=arguments.length,n=Array(r),a=0;a{e.callback=e.next}};return e}function d(){}},11647:(e,t,r)=>{"use strict";r.d(t,{E:()=>l});var n=r(21083),a=r(22027),s=r(83101),i=r(64269);let o=(0,s.F)("group/badge inline-flex h-5 w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-4xl border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-all focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3!",{variants:{variant:{default:"bg-primary text-primary-foreground [a]:hover:bg-primary/80",secondary:"bg-secondary text-secondary-foreground [a]:hover:bg-secondary/80",destructive:"bg-destructive/10 text-destructive focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:focus-visible:ring-destructive/40 [a]:hover:bg-destructive/20",outline:"border-border text-foreground [a]:hover:bg-muted [a]:hover:text-muted-foreground",ghost:"hover:bg-muted hover:text-muted-foreground dark:hover:bg-muted/50",link:"text-primary underline-offset-4 hover:underline"}},defaultVariants:{variant:"default"}});function l(e){let{className:t,variant:r="default",render:s,...l}=e;return(0,a.C)({defaultTagName:"span",props:(0,n.v6)({className:(0,i.cn)(o({variant:r}),t)},l),render:s,state:{slot:"badge",variant:r}})}},20063:(e,t,r)=>{"use strict";var n=r(47260);r.o(n,"usePathname")&&r.d(t,{usePathname:function(){return n.usePathname}}),r.o(n,"useRouter")&&r.d(t,{useRouter:function(){return n.useRouter}})},20243:(e,t,r)=>{"use strict";r.d(t,{E:()=>s});var n=r(95155),a=r(64269);function s(e){let{className:t,...r}=e;return(0,n.jsx)("div",{"data-slot":"skeleton",className:(0,a.cn)("animate-pulse rounded-md bg-muted",t),...r})}},22027:(e,t,r)=>{"use strict";r.d(t,{C:()=>a});var n=r(87711);function a(e){return(0,n.o)(e.defaultTagName??"div",e,e)}},24454:(e,t,r)=>{Promise.resolve().then(r.bind(r,80899))},39972:(e,t,r)=>{"use strict";r.d(t,{g:()=>a});var n=r(12115);let a="undefined"!=typeof document?n.useLayoutEffect:()=>{}},64269:(e,t,r)=>{"use strict";r.d(t,{cn:()=>s});var n=r(2821),a=r(75889);function s(){for(var e=arguments.length,t=Array(e),r=0;r{"use strict";r.d(t,{p:()=>i});var n=r(95155);r(12115);var a=r(50092),s=r(64269);function i(e){let{className:t,type:r,...i}=e;return(0,n.jsx)(a.p,{type:r,"data-slot":"input",className:(0,s.cn)("h-8 w-full min-w-0 rounded-lg border border-input bg-transparent px-2.5 py-1 text-base transition-colors outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",t),...i})}},77650:(e,t,r)=>{"use strict";r.d(t,{U:()=>a});var n=r(79786);function a(){return(0,n.createBrowserClient)("https://supabase.silvioalzate.shop","eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJyb2xlIjoiYW5vbiIsImlzcyI6InN1cGFiYXNlIiwiaWF0IjoxNzc5MTYzNDQ1LCJleHAiOjE5MzY4NDM0NDV9.RGVwyQdA7oigXmMylP2Df7DKpNno_8_rSTwd0471zLk")}},80899:(e,t,r)=>{"use strict";r.r(t),r.d(t,{default:()=>v});var n=r(95155),a=r(12115),s=r(20063),i=r(83410),o=r(13185);let l=(0,o.A)("user-check",[["path",{d:"m16 11 2 2 4-4",key:"9rsbq5"}],["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]]),c=(0,o.A)("user-x",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"17",x2:"22",y1:"8",y2:"13",key:"3nzzx3"}],["line",{x1:"22",x2:"17",y1:"8",y2:"13",key:"1swrse"}]]),d=(0,o.A)("search",[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]);var u=r(77650),f=r(65142),m=r(11647),p=r(86948),g=r(20243);let x={prospecto:{label:"Prospecto",icon:i.A,className:"bg-yellow-50 text-yellow-700 border-yellow-200"},activo:{label:"Activo",icon:l,className:"bg-emerald-50 text-emerald-700 border-emerald-200"},inactivo:{label:"Inactivo",icon:c,className:"bg-gray-50 text-gray-600 border-gray-200"}};function v(){let e=(0,s.useRouter)(),t=(0,a.useMemo)(()=>(0,u.U)(),[]),[r,i]=(0,a.useState)([]),[o,l]=(0,a.useState)(""),[c,v]=(0,a.useState)(!0),h=(0,a.useRef)(null),b=(0,a.useRef)(null),y=(0,a.useCallback)(async e=>{h.current&&h.current.abort();let r=new AbortController;h.current=r,v(!0);let n=e.trim(),a=t.from("patients").select("id, phone, name, email, status, created_at").order("created_at",{ascending:!1}).limit(100);if(n){let e=n.replace(/[%_]/g,"\\$&");a=a.or("name.ilike.%".concat(e,"%,phone.ilike.%").concat(e,"%,email.ilike.%").concat(e,"%"))}let{data:s}=await a;r.signal.aborted||(i(null!=s?s:[]),v(!1))},[t]);(0,a.useEffect)(()=>{y("")},[]);let N=(0,a.useCallback)(e=>{l(e),b.current&&clearTimeout(b.current),b.current=setTimeout(()=>{y(e)},300)},[y]);return(0,n.jsxs)("div",{className:"space-y-6",children:[(0,n.jsx)("div",{className:"flex items-start justify-between gap-4 flex-wrap",children:(0,n.jsxs)("div",{children:[(0,n.jsx)("h2",{className:"font-heading font-bold text-2xl text-foreground",children:"Pacientes"}),(0,n.jsx)("p",{className:"text-muted-foreground text-sm mt-1",children:"Gestiona los perfiles y el historial cl\xednico"})]})}),(0,n.jsxs)("div",{className:"relative max-w-md",children:[(0,n.jsx)(d,{className:"absolute left-3 top-1/2 -translate-y-1/2 size-4 text-muted-foreground"}),(0,n.jsx)(f.p,{id:"patient-search",type:"search",placeholder:"Buscar por nombre, tel\xe9fono o email…",value:o,onChange:e=>N(e.target.value),className:"pl-9"})]}),c?(0,n.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4",children:Array.from({length:6}).map((e,t)=>(0,n.jsx)(g.E,{className:"h-28 rounded-[18px]"},t))}):0===r.length?(0,n.jsx)(p.Zp,{className:"border-border",children:(0,n.jsx)(p.Wu,{className:"flex items-center justify-center h-40",children:(0,n.jsx)("p",{className:"text-muted-foreground text-sm",children:o?"No se encontraron pacientes con ese criterio.":"No hay pacientes registrados a\xfan."})})}):(0,n.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4",children:r.map(t=>{var r;let a=null!=(r=x[t.status])?r:x.prospecto,s=a.icon;return(0,n.jsx)("button",{onClick:()=>e.push("/dashboard/patients/".concat(t.id)),className:"text-left",children:(0,n.jsxs)(p.Zp,{className:"border-border hover:border-primary/40 hover:shadow-md transition-all cursor-pointer rounded-[18px]",children:[(0,n.jsx)(p.aR,{className:"pb-2",children:(0,n.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,n.jsx)(p.ZB,{className:"font-heading text-base font-semibold truncate",children:t.name}),(0,n.jsxs)(m.E,{variant:"outline",className:"text-[10px] px-2 py-0.5 flex items-center gap-1 ".concat(a.className),children:[(0,n.jsx)(s,{className:"size-3"}),a.label]})]})}),(0,n.jsxs)(p.Wu,{className:"space-y-1",children:[(0,n.jsx)("p",{className:"text-xs text-muted-foreground",children:t.phone}),t.email&&(0,n.jsx)("p",{className:"text-xs text-muted-foreground truncate",children:t.email})]})]})},t.id)})}),!c&&r.length>0&&(0,n.jsxs)("p",{className:"text-xs text-muted-foreground",children:[r.length," paciente",1!==r.length?"s":""," mostrados"]})]})}},83410:(e,t,r)=>{"use strict";r.d(t,{A:()=>n});let n=(0,r(13185).A)("clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6l4 2",key:"mmk7yg"}]])},86948:(e,t,r)=>{"use strict";r.d(t,{BT:()=>l,Wu:()=>c,ZB:()=>o,Zp:()=>s,aR:()=>i});var n=r(95155);r(12115);var a=r(64269);function s(e){let{className:t,size:r="default",...s}=e;return(0,n.jsx)("div",{"data-slot":"card","data-size":r,className:(0,a.cn)("group/card flex flex-col gap-4 overflow-hidden rounded-xl bg-card py-4 text-sm text-card-foreground ring-1 ring-foreground/10 has-data-[slot=card-footer]:pb-0 has-[>img:first-child]:pt-0 data-[size=sm]:gap-3 data-[size=sm]:py-3 data-[size=sm]:has-data-[slot=card-footer]:pb-0 *:[img:first-child]:rounded-t-xl *:[img:last-child]:rounded-b-xl",t),...s})}function i(e){let{className:t,...r}=e;return(0,n.jsx)("div",{"data-slot":"card-header",className:(0,a.cn)("group/card-header @container/card-header grid auto-rows-min items-start gap-1 rounded-t-xl px-4 group-data-[size=sm]/card:px-3 has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto] [.border-b]:pb-4 group-data-[size=sm]/card:[.border-b]:pb-3",t),...r})}function o(e){let{className:t,...r}=e;return(0,n.jsx)("div",{"data-slot":"card-title",className:(0,a.cn)("font-heading text-base leading-snug font-medium group-data-[size=sm]/card:text-sm",t),...r})}function l(e){let{className:t,...r}=e;return(0,n.jsx)("div",{"data-slot":"card-description",className:(0,a.cn)("text-sm text-muted-foreground",t),...r})}function c(e){let{className:t,...r}=e;return(0,n.jsx)("div",{"data-slot":"card-content",className:(0,a.cn)("px-4 group-data-[size=sm]/card:px-3",t),...r})}}},e=>{e.O(0,[5730,7711,7349,3540,7958,8441,1255,7358],()=>e(e.s=24454)),_N_E=e.O()}]);