bonsaif-ui 0.1.17 → 0.1.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- (function(A,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("react/jsx-runtime"),require("react-icons/hi2"),require("react"),require("react-dom"),require("overlayscrollbars"),require("react-icons/md"),require("overlayscrollbars-react"),require("react-day-picker"),require("react-day-picker/dist/style.css"),require("react-icons/fi"),require("sonner")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react-icons/hi2","react","react-dom","overlayscrollbars","react-icons/md","overlayscrollbars-react","react-day-picker","react-day-picker/dist/style.css","react-icons/fi","sonner"],e):(A=typeof globalThis<"u"?globalThis:A||self,e(A.BonsaifUI={},A.jsxRuntime,A.ReactIconsHi2,A.React,A.ReactDOM,A.OverlayScrollbarsGlobal,A.ReactIconsMd,A.OverlayScrollbarsReact,A.ReactDayPicker,A.ReactDayPickerStyles,A.ReactIconsFi,A.Sonner))})(this,(function(A,e,w,o,Ee,hr,ct,mr,vr,Nn,dt,ut){"use strict";"use client";function xr(...r){return r.filter(Boolean).join(" ")}function ft({variant:r="primary",className:t,type:a="button",children:n,...s}){return e.jsx("button",{className:xr("bonsaif-ui-button",`bonsaif-ui-button--${r}`,t),type:a,...s,children:n})}function gr({value:r,onChange:t,placeholder:a,className:n="",autoFocus:s=!1,forceExpanded:c=!1,onEscape:d,size:l="default",inputTabIndex:p}){const b=o.useRef(null),[S,k]=o.useState(!1),y=c||S||r.trim().length>0,x=l==="sm"?"h-9 rounded-md":"h-10 rounded-lg",u=n||"w-48 sm:w-64 lg:w-72";o.useEffect(()=>{var h;s&&((h=b.current)==null||h.focus())},[s]);const m=()=>{var h;k(!0),(h=b.current)==null||h.focus()};return e.jsxs("div",{className:`relative flex-shrink-0 overflow-visible transition-[width] duration-200 ease-out ${y?u:"w-24 sm:w-28"}`,onMouseDown:h=>{y||(h.preventDefault(),m())},children:[e.jsx(w.HiMagnifyingGlass,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 pointer-events-none transition-colors duration-200",style:{color:"var(--text-muted)"}}),e.jsx("input",{ref:b,type:"text",tabIndex:p,"aria-label":a,value:r,onChange:h=>t(h.target.value),onKeyDown:h=>{h.key==="Escape"&&(d==null||d())},placeholder:y?a:"Buscar",className:`${x} w-full py-0 text-sm leading-none placeholder:text-[var(--text-muted)] focus:outline-none transition-all duration-200 ${y?"pl-9 pr-8":"cursor-pointer pl-9 pr-3"}`,style:{background:"color-mix(in srgb, var(--bg-card) 86%, transparent)",border:"1px solid var(--border)",color:"var(--text-main)"},onFocus:h=>{k(!0),h.currentTarget.style.borderColor="var(--primary)",h.currentTarget.style.boxShadow="0 0 0 3px rgba(59,130,246,0.12)"},onBlur:h=>{k(!1),h.currentTarget.style.borderColor="var(--border)",h.currentTarget.style.boxShadow="none"}}),r&&e.jsx("button",{type:"button",onClick:()=>t(""),className:"absolute right-2 top-1/2 flex !h-6 !w-6 -translate-y-1/2 items-center justify-center rounded-full !p-0 leading-none transition-colors hover:bg-black/5",style:{color:"var(--text-muted)"},"aria-label":"Limpiar búsqueda",children:e.jsx(w.HiXMark,{className:"h-3.5 w-3.5 flex-shrink-0"})})]})}const yr=o.createContext({});function pt(r){var n;const t=Array.from(r.querySelectorAll("*")).filter(s=>{var c;return s.scrollWidth>s.clientWidth&&!!((c=s.textContent)!=null&&c.trim())&&s.tagName.toLowerCase()!=="svg"&&!s.closest("svg")});return(r.scrollWidth>r.clientWidth||t.length>0)&&(((n=t[0])==null?void 0:n.textContent)??r.textContent??"").trim()||null}function Ue({children:r,content:t,onlyWhenOverflow:a=!1,className:n="",style:s,as:c="div"}){const d=o.useRef(null),l=o.useRef(null),[p,b]=o.useState(null),[S,k]=o.useState("");o.useEffect(()=>{const u=d.current;u&&(u.querySelectorAll("[title]").forEach(m=>{const h=m.getAttribute("title");h&&(m.getAttribute("aria-label")||m.setAttribute("aria-label",h),m.removeAttribute("title"))}),u.querySelectorAll("svg title").forEach(m=>m.remove()))}),o.useLayoutEffect(()=>{if(!p)return;const u=l.current;if(!u)return;const m=12,h=14,E=u.getBoundingClientRect(),F=window.innerWidth-E.width-m,z=window.innerHeight-E.height-m;let T=p.mouseX+h,N=p.mouseY+h;T>F&&(T=p.mouseX-E.width-h),N>z&&(N=p.mouseY-E.height-h),T=Math.min(Math.max(m,T),Math.max(m,F)),N=Math.min(Math.max(m,N),Math.max(m,z)),(Math.abs(T-p.x)>.5||Math.abs(N-p.y)>.5)&&b($=>$&&{...$,x:T,y:N})},[p]);const y=(u,m)=>{const h=d.current;if(h){if(a){const E=pt(h);if(!E)return;k(E)}!a&&!t||b({mouseX:u,mouseY:m,x:u+14,y:m+14})}},x=a?S:t;return e.jsxs(e.Fragment,{children:[e.jsx(c,{ref:u=>{d.current=u},className:n,style:s,onMouseEnter:u=>y(u.clientX,u.clientY),onMouseMove:u=>{p&&y(u.clientX,u.clientY)},onMouseLeave:()=>b(null),children:r}),p&&x?Ee.createPortal(e.jsx("div",{ref:l,role:"tooltip",style:{position:"fixed",top:p.y,left:p.x,zIndex:9999,background:"var(--bg-card)",border:"1px solid var(--border)",borderRadius:6,padding:"5px 10px",fontSize:12,color:"var(--text-main)",boxShadow:"0 4px 16px rgba(0,0,0,0.35)",pointerEvents:"none",maxWidth:"min(420px, calc(100vw - 24px))",whiteSpace:"normal",lineHeight:1.6,overflowWrap:"anywhere"},children:x}),document.body):null]})}function wr(r){if(r!==void 0)return typeof r=="number"?`${r}px`:r}const bt="inline-flex shrink-0 items-center justify-center gap-2 whitespace-nowrap leading-none font-medium transition-all duration-150 focus:outline-none disabled:opacity-50 rounded-lg",ht={primary:"border border-[var(--border)] text-[var(--text-main)] hover:border-[var(--border)] hover:bg-[var(--bg-input)] active:scale-[0.98] transition-colors",secondary:"border border-[var(--border)] text-[var(--text-main)] hover:border-[var(--border)] hover:bg-[var(--bg-input)] active:scale-[0.98] transition-colors",danger:"border border-[var(--border)] text-[var(--danger)] hover:border-[var(--danger)] hover:bg-[var(--danger-bg)] active:scale-[0.98] transition-colors",ghost:"text-[var(--text-secondary)] hover:opacity-70",icon:"text-[var(--text-muted)] hover:text-[var(--primary)] hover:bg-primary/5"},mt="border border-[var(--border)] text-[var(--text-muted)] shadow-sm shadow-black/5 hover:border-[var(--border)] hover:bg-[var(--bg-input)] hover:text-[var(--primary)] active:scale-[0.98] transition-colors",vt={xs:"h-8 px-2.5 text-xs",sm:"h-9 px-3.5 text-xs",md:"h-10 px-3.5 text-sm",lg:"h-11 px-4 text-sm font-semibold"},xt={xs:"h-8 w-8",sm:"h-9 w-9",md:"h-10 w-10",lg:"h-10 w-10"},gt={primary:{background:"var(--bg-card)"},secondary:{background:"var(--bg-card)"},danger:{background:"var(--bg-card)"},ghost:{},icon:{}};function rr(r){return typeof r=="string"||typeof r=="number"?String(r):Array.isArray(r)?r.map(rr).join(" ").trim():o.isValidElement(r)?rr(r.props.children):""}function yt(r){return o.Children.toArray(r).find(o.isValidElement)??null}function ie({variant:r="primary",size:t="md",loading:a=!1,icon:n,tooltip:s,iconOnly:c,height:d,padding:l,children:p,className:b="",disabled:S,style:k,...y}){const x=o.useContext(yr),u=c??x.iconOnly??r==="icon",m=x.compact??!1,h=x.headerAction??!1,E=m&&!h&&t==="md"?"xs":t,F=r==="icon"||u,z=h&&F,T=rr(p),N=s??y.title??y["aria-label"]??(u?T:void 0),$=N?void 0:y.title,B=y["aria-label"]??(typeof N=="string"?N:T||void 0),P=a?null:n??(u?yt(p):null),D=e.jsxs("button",{...y,title:$,"aria-label":B,"data-variant":r,"data-size":E,"data-icon":F?"true":void 0,disabled:S||a,className:`${bt} ${z?mt:ht[r]} ${F?xt[E]:vt[E]} ${m&&!F?"px-2.5":""} ${b}`,style:{...gt[r],height:wr(d),padding:wr(l),...k,...z?{width:"40px",height:"40px",padding:0,background:"var(--bg-card)",borderRadius:"8px"}:null},children:[a?e.jsx("span",{className:"h-3.5 w-3.5 animate-spin rounded-full border-2 border-current border-t-transparent"}):P,!u&&p]});return N?e.jsx(Ue,{as:"span",content:N,className:"inline-flex shrink-0",children:D}):D}function Nr({variant:r="page",title:t="Cargando...",rows:a=6,children:n}){return r==="table"?e.jsx(kr,{rows:a}):r==="sections"?e.jsx(wt,{rows:a}):r==="cards"?e.jsx(Nt,{rows:a}):e.jsx("div",{className:"flex min-h-[240px] items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-6",children:e.jsxs("div",{className:"flex flex-col items-center gap-3 text-center",children:[e.jsx("div",{className:"h-9 w-9 animate-spin rounded-full border-2 border-[var(--border)] border-t-[var(--primary)]"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold text-[var(--text-main)]",children:t}),n&&e.jsx("div",{className:"mt-1 text-xs text-[var(--text-muted)]",children:n})]})]})})}function wt({rows:r}){return e.jsx("div",{className:"space-y-4",children:Array.from({length:Math.max(2,Math.min(r,4))}).map((t,a)=>e.jsxs("section",{className:"overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)]",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-[var(--border)] px-3 py-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-4 w-4 animate-pulse rounded bg-[var(--bg-input)]"}),e.jsx("div",{className:"h-4 w-32 animate-pulse rounded bg-[var(--bg-input)]"}),e.jsx("div",{className:"h-5 w-20 animate-pulse rounded-full bg-[var(--bg-input)]"})]}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx("div",{className:"h-8 w-8 animate-pulse rounded-md bg-[var(--bg-input)]"}),e.jsx("div",{className:"h-8 w-8 animate-pulse rounded-md bg-[var(--bg-input)]"})]})]}),e.jsx(kr,{rows:a===0?r:Math.max(3,r-2),compact:!0})]},a))})}function Nt({rows:r}){return e.jsx("div",{className:"grid gap-3 md:grid-cols-2 xl:grid-cols-3",children:Array.from({length:r}).map((t,a)=>e.jsxs("div",{className:"rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-4",children:[e.jsx("div",{className:"h-4 w-2/3 animate-pulse rounded bg-[var(--bg-input)]"}),e.jsx("div",{className:"mt-3 h-3 w-full animate-pulse rounded bg-[var(--bg-input)]"}),e.jsx("div",{className:"mt-2 h-3 w-4/5 animate-pulse rounded bg-[var(--bg-input)]"})]},a))})}function kr({rows:r,compact:t=!1}){const a=t?5:6;return e.jsxs("div",{className:"overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)]",children:[e.jsx("div",{className:"grid border-b border-[var(--border)]",style:{gridTemplateColumns:`repeat(${a}, minmax(0, 1fr))`},children:Array.from({length:a}).map((n,s)=>e.jsx("div",{className:"px-3 py-3",children:e.jsx("div",{className:"h-3 w-2/3 animate-pulse rounded bg-[var(--bg-input)]"})},s))}),Array.from({length:r}).map((n,s)=>e.jsx("div",{className:"grid border-b border-[var(--border)] last:border-b-0",style:{gridTemplateColumns:`repeat(${a}, minmax(0, 1fr))`},children:Array.from({length:a}).map((c,d)=>e.jsx("div",{className:"px-3 py-3",children:e.jsx("div",{className:"h-3.5 animate-pulse rounded-full bg-[var(--bg-input)]",style:{width:`${52+(s*13+d*11)%36}%`}})},d))},s))]})}function Sr(r){const t=r.split("/").filter(Boolean);return(t[t.length-1]??r).replace(/^lv_/,"").split(/[-_]/).filter(Boolean).map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join(" ")}function Cr(r){return r.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().trim()}function kt(r){return[r.label,Sr(r.service),r.description,r.service].filter(Boolean).join(" ")}function St(r){return typeof r=="function"?r:r.default}function Ct(r,t){return e.jsx("div",{className:"flex min-h-[220px] items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-6 text-center",children:e.jsxs("div",{className:"max-w-md",children:[e.jsx("p",{className:"text-sm font-semibold text-[var(--text-main)]",children:"No se pudo cargar este modulo"}),e.jsx("p",{className:"mt-1 text-xs text-[var(--text-muted)]",children:r.message}),e.jsx(ie,{className:"mt-4",height:36,padding:"0 14px",onClick:t,children:"Reintentar"})]})})}function Et({parentPanel:r,parentPanelComponent:t,renderParentPanel:a,parent:n,context:s,links:c,moduleRegistry:d,loadModule:l,activeService:p,initialService:b,onActiveServiceChange:S,canAccess:k,keepAlive:y=!0,title:x,subtitle:u,emptyState:m,loadingState:h,errorState:E=Ct,renderTabLabel:F,searchableTabs:z="auto",tabsSearchThreshold:T=6,tabsSearchPlaceholder:N="Buscar modulo...",tabsSearchValue:$,onTabsSearchChange:B,emptySearchState:P,showTabCount:D=!0,className:M="",parentClassName:j="",contentClassName:I="",tabsClassName:W=""}){var Se;const U=o.useMemo(()=>c.filter(L=>!L.hidden&&((k==null?void 0:k(L,s))??!0)),[k,s,c]),J=(Se=U.find(L=>!L.disabled))==null?void 0:Se.service,[te,f]=o.useState(b??J??""),[H,G]=o.useState({}),[K,Z]=o.useState({}),[ne,de]=o.useState(""),[v,Y]=o.useState(!1),be=o.useRef(K),ee=o.useRef(0),Q=$??ne,O=Cr(Q),V=z===!0||z==="auto"&&U.length>=T,R=V&&Q.trim().length>0,se=o.useMemo(()=>O?U.filter(L=>Cr(kt(L)).includes(O)):U,[O,U]),he=p??te,X=U.find(L=>L.service===he)??U.find(L=>!L.disabled);o.useEffect(()=>{!X&&J&&f(J)},[J,X]),o.useEffect(()=>{be.current=K},[K]);const we=L=>{L.disabled||(p||f(L.service),S==null||S(L.service,L))},De=L=>{$===void 0&&de(L),B==null||B(L)},_e=(L,le)=>{const ue=se.filter(fe=>!fe.disabled),me=ue.findIndex(fe=>fe.service===le.service);me<0||((L.key==="ArrowRight"||L.key==="ArrowDown")&&(L.preventDefault(),we(ue[(me+1)%ue.length])),(L.key==="ArrowLeft"||L.key==="ArrowUp")&&(L.preventDefault(),we(ue[(me-1+ue.length)%ue.length])),L.key==="Home"&&(L.preventDefault(),we(ue[0])),L.key==="End"&&(L.preventDefault(),we(ue[ue.length-1])))},Te=o.useCallback(()=>{if(!X)return;const L=X.service,le=be.current[L];if(le!=null&&le.loading||le!=null&&le.component&&y)return;const ue=(d==null?void 0:d[L])??l;if(!ue){Z(fe=>({...fe,[L]:{loading:!1,error:new Error(`No module loader found for service "${L}".`)}}));return}const me=++ee.current;Z(fe=>({...fe,[L]:{...fe[L],loading:!0,error:void 0}})),ue(X,s).then(fe=>{if(me!==ee.current&&!y)return;const We=St(fe);Z(Oe=>({...Oe,[L]:{component:We,loading:!1}}))}).catch(fe=>{const We=fe instanceof Error?fe:new Error(String(fe));Z(Oe=>({...Oe,[L]:{...Oe[L],loading:!1,error:We}}))})},[s,y,l,d,X]);o.useEffect(Te,[Te]);const Fe=X?H[X.service]??null:null,oe=X?K[X.service]:void 0,Be=oe==null?void 0:oe.component,Ke=L=>{X&&G(le=>({...le,[X.service]:L}))},Ae=()=>{X&&G(L=>({...L,[X.service]:null}))},Ze={context:s,parent:n,links:c,visibleLinks:U,filteredLinks:se,selectedLink:X,selectedService:X==null?void 0:X.service,activeItemId:Fe,tabsSearch:Q,onSelectService:we,onOpenDetail:Ke,onBackToList:Ae},ke=a?a(Ze):t?e.jsx(t,{...Ze}):r;return e.jsxs("section",{className:`grid min-h-[520px] gap-4 lg:grid-cols-[minmax(260px,360px)_minmax(0,1fr)] ${M}`,children:[e.jsx("aside",{className:`min-w-0 rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-4 ${j}`,children:ke}),e.jsxs("div",{className:`relative min-w-0 overflow-visible rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${I}`,children:[(x||u||V||D)&&e.jsx("div",{className:"relative border-b border-[var(--border)] px-4 py-3",children:e.jsxs("div",{className:"flex min-w-0 items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[x&&e.jsx("h2",{className:"truncate text-sm font-semibold text-[var(--text-main)]",children:x}),u&&e.jsx("p",{className:"mt-1 line-clamp-2 text-xs text-[var(--text-muted)]",children:u})]}),(V||D)&&e.jsxs("div",{className:"flex min-w-0 flex-shrink-0 items-center justify-end gap-2",children:[D&&e.jsxs("span",{className:"hidden text-xs font-semibold text-[var(--text-muted)] transition-opacity duration-200 sm:inline",children:[se.length," / ",U.length]}),V&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:`origin-right overflow-hidden transition-[width,opacity,transform] duration-200 ease-out ${v?"w-[min(20rem,44vw)] translate-x-0 opacity-100":"w-0 translate-x-2 opacity-0"}`,"aria-hidden":!v,children:e.jsx(gr,{value:Q,onChange:De,placeholder:N,className:"w-full",autoFocus:v,forceExpanded:!0,onEscape:()=>Y(!1),size:"sm",inputTabIndex:v?0:-1})}),e.jsx("button",{type:"button","aria-label":v?"Cerrar busqueda":"Buscar tabs","aria-expanded":v,onClick:()=>{v&&Q&&De(""),Y(L=>!L)},className:`inline-flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-md border transition-all duration-200 hover:scale-[1.03] active:scale-95 ${v||R?"border-[var(--primary)] bg-[var(--bg-input)] text-[var(--text-main)] shadow-sm":"border-[var(--border)] text-[var(--text-muted)] hover:bg-[var(--bg-input)] hover:text-[var(--text-main)]"}`,children:e.jsx("span",{className:"grid h-4 w-4 place-items-center transition-transform duration-200",children:v||R?e.jsx(w.HiXMark,{className:"h-4 w-4"}):e.jsx(w.HiMagnifyingGlass,{className:"h-4 w-4"})})})]})]})]})}),e.jsx("div",{role:"tablist","aria-label":x??"Modulos relacionados",className:`flex gap-1 overflow-x-auto border-b border-[var(--border)] bg-[var(--bg-input)] px-2 py-1.5 transition-colors duration-200 ${W}`,children:se.length>0?se.map(L=>{const le=L.service===(X==null?void 0:X.service);return e.jsx("button",{type:"button",role:"tab","aria-selected":le,disabled:L.disabled,onClick:()=>we(L),onKeyDown:ue=>_e(ue,L),className:`inline-flex h-9 min-w-max items-center gap-2 rounded-md border px-3 text-xs font-semibold transition-all duration-200 disabled:cursor-not-allowed disabled:opacity-50 ${le?"border-[var(--primary)] bg-[var(--bg-card)] text-[var(--text-main)] shadow-sm":"border-transparent text-[var(--text-muted)] hover:bg-[var(--bg-card)] hover:text-[var(--text-main)]"}`,children:F?F(L,le):e.jsxs(e.Fragment,{children:[L.icon,e.jsx("span",{children:L.label??Sr(L.service)}),L.badge&&e.jsx("span",{className:"rounded-full bg-[var(--bg-input)] px-1.5 py-0.5 text-[10px] text-[var(--text-muted)]",children:L.badge})]})},L.service)}):e.jsx("div",{className:"flex min-h-9 flex-1 items-center rounded-md border border-dashed border-[var(--border)] px-3 text-xs text-[var(--text-muted)]",children:P??"No hay modulos que coincidan con la busqueda."})}),(X==null?void 0:X.description)&&e.jsx("div",{className:"border-b border-[var(--border)] px-4 py-2 text-xs text-[var(--text-muted)]",children:X.description}),e.jsxs("div",{className:"min-h-[420px] p-4",children:[!X&&(m??e.jsx("div",{className:"flex min-h-[220px] items-center justify-center rounded-lg border border-dashed border-[var(--border)] text-sm text-[var(--text-muted)]",children:"No hay modulos disponibles."})),X&&(oe==null?void 0:oe.loading)&&(h??e.jsx(Nr,{title:"Cargando modulo..."})),X&&(oe==null?void 0:oe.error)&&E(oe.error,Te),X&&Be&&!(oe!=null&&oe.loading)&&!(oe!=null&&oe.error)&&e.jsx(Be,{context:s,parent:n,link:X,activeItemId:Fe,onOpenDetail:Ke,onBackToList:Ae})]})]})]})}const $t={info:{color:"#2563eb",background:"rgba(59, 130, 246, 0.1)",border:"rgba(59, 130, 246, 0.24)",icon:e.jsx(w.HiInformationCircle,{className:"h-5 w-5"})},success:{color:"#047857",background:"rgba(16, 185, 129, 0.1)",border:"rgba(16, 185, 129, 0.24)",icon:e.jsx(w.HiCheckCircle,{className:"h-5 w-5"})},warning:{color:"#b45309",background:"rgba(245, 158, 11, 0.12)",border:"rgba(245, 158, 11, 0.26)",icon:e.jsx(w.HiExclamationTriangle,{className:"h-5 w-5"})},danger:{color:"var(--danger)",background:"var(--danger-bg)",border:"color-mix(in srgb, var(--danger) 20%, var(--border))",icon:e.jsx(w.HiExclamationCircle,{className:"h-5 w-5"})},neutral:{color:"var(--text-secondary)",background:"var(--bg-input)",border:"var(--border)",icon:e.jsx(w.HiInformationCircle,{className:"h-5 w-5"})}};function Mt({variant:r="info",title:t,children:a,icon:n,action:s,onDismiss:c,className:d=""}){const l=$t[r];return e.jsxs("div",{role:r==="danger"||r==="warning"?"alert":"status",className:`flex items-start gap-3 rounded-lg border px-3 py-3 ${d}`,style:{background:l.background,borderColor:l.border},children:[e.jsx("div",{className:"mt-0.5 shrink-0",style:{color:l.color},children:n??l.icon}),e.jsxs("div",{className:"min-w-0 flex-1",children:[t&&e.jsx("div",{className:"text-sm font-semibold text-[var(--text-main)]",children:t}),a&&e.jsx("div",{className:"mt-0.5 text-sm leading-5 text-[var(--text-secondary)]",children:a}),s&&e.jsx("div",{className:"mt-3",children:s})]}),c&&e.jsx(ie,{variant:"icon",size:"xs","aria-label":"Cerrar alerta",onClick:c,className:"-mr-1 -mt-1",children:e.jsx(w.HiXMark,{className:"h-4 w-4"})})]})}const Er=["Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre"],Dt=["Ene","Feb","Mar","Abr","May","Jun","Jul","Ago","Sep","Oct","Nov","Dic"],Ht=["Do","Lu","Ma","Mi","Ju","Vi","Sá"],tr=6;function ar(r,t,a){return`${r}-${String(t).padStart(2,"0")}-${String(a).padStart(2,"0")}`}function Lt(){const r=new Date;return ar(r.getFullYear(),r.getMonth()+1,r.getDate())}function $r(r){const[t,a,n]=r.split("-").map(Number);return{year:t,month:a,day:n}}function Tt(r){if(!r)return"Seleccionar fecha";const{year:t,month:a,day:n}=$r(r);return!t||!a||!n?"Seleccionar fecha":`${String(n).padStart(2,"0")} ${Er[a-1]} ${t}`}function Bt({value:r,onChange:t,minDate:a,displayMode:n="inline"}){const s=Lt(),d=$r(r||s),l=n==="popover",[p,b]=o.useState(!1),S=o.useRef(null),[k,y]=o.useState({horizontal:"left",vertical:"bottom"}),[x,u]=o.useState(d.year),[m,h]=o.useState(d.month),[E,F]=o.useState("days"),z=16,[T,N]=o.useState(0),$=x-7+T,B=Array.from({length:z},(f,H)=>$+H);o.useEffect(()=>{if(!l||!p||!S.current)return;const f=S.current.getBoundingClientRect(),H=8,G=280,K=340,Z=f.left+G>window.innerWidth-H,ne=f.right-G>=H,de=f.bottom+8+K>window.innerHeight-H,v=f.top-8-K>=H;y({horizontal:Z&&ne?"right":"left",vertical:de&&v?"top":"bottom"})},[l,p]),o.useEffect(()=>{if(!l||!p)return;function f(G){S.current&&(S.current.contains(G.target)||b(!1))}function H(G){G.key==="Escape"&&b(!1)}return document.addEventListener("mousedown",f),document.addEventListener("keydown",H),()=>{document.removeEventListener("mousedown",f),document.removeEventListener("keydown",H)}},[l,p]);function P(){m===1?(u(f=>f-1),h(12)):h(f=>f-1)}function D(){m===12?(u(f=>f+1),h(1)):h(f=>f+1)}const M=new Date(x,m-1,1).getDay(),j=new Date(x,m,0).getDate(),I=[...Array(M).fill(null),...Array.from({length:j},(f,H)=>H+1)];for(;I.length<tr*7;)I.push(null);const W=I.slice(0,tr*7);function U(f){const H=ar(x,m,f);a&&H<a||(t(H),l&&b(!1))}const J={background:"none",border:"none",cursor:"pointer",color:"var(--text-muted)",padding:4,borderRadius:6,display:"flex",alignItems:"center"},te=e.jsxs("div",{style:{background:"var(--bg-input)",border:"1px solid var(--border)",borderRadius:10,overflow:"hidden",userSelect:"none",width:280},children:[e.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 12px",borderBottom:"1px solid var(--border)"},children:E==="days"?e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:P,style:J,title:"Mes anterior",children:e.jsx(w.HiChevronLeft,{size:16})}),e.jsxs("button",{type:"button",onClick:()=>{F("years"),N(0)},style:{background:"none",border:"none",cursor:"pointer",display:"flex",alignItems:"center",gap:4,fontSize:13,fontWeight:700,color:"var(--text-main)",borderRadius:6,padding:"2px 6px"},children:[Er[m-1]," ",x,e.jsx(w.HiChevronDown,{size:13,style:{color:"var(--text-muted)"}})]}),e.jsx("button",{type:"button",onClick:D,style:J,title:"Mes siguiente",children:e.jsx(w.HiChevronRight,{size:16})})]}):e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:()=>N(f=>f-z),style:J,children:e.jsx(w.HiChevronLeft,{size:16})}),e.jsxs("button",{type:"button",onClick:()=>F("days"),style:{background:"none",border:"none",cursor:"pointer",fontSize:13,fontWeight:700,color:"var(--text-main)",borderRadius:6,padding:"2px 6px"},children:[B[0]," – ",B[B.length-1]]}),e.jsx("button",{type:"button",onClick:()=>N(f=>f+z),style:J,children:e.jsx(w.HiChevronRight,{size:16})})]})}),E==="years"&&e.jsxs("div",{style:{padding:"8px 10px 10px"},children:[e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(4,1fr)",gap:3,marginBottom:8},children:Dt.map((f,H)=>{const G=H+1===m;return e.jsx("button",{type:"button",onClick:()=>h(H+1),style:{border:"none",cursor:"pointer",borderRadius:6,fontSize:11,fontWeight:G?700:400,padding:"4px 0",background:G?"var(--primary)":"transparent",color:G?"var(--primary-fg, #ffffff)":"var(--text-secondary)"},children:f},f)})}),e.jsx("div",{style:{height:1,background:"var(--border)",marginBottom:8}}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(4,1fr)",gap:3},children:B.map(f=>{const H=f===x;return e.jsx("button",{type:"button",onClick:()=>{u(f),F("days")},style:{border:"none",cursor:"pointer",borderRadius:6,fontSize:12,fontWeight:H?700:400,padding:"6px 0",background:H?"var(--primary)":"transparent",color:H?"var(--primary-fg, #ffffff)":"var(--text-main)",outline:f===new Date().getFullYear()&&!H?"2px solid var(--primary)":"none",outlineOffset:"-2px"},children:f},f)})})]}),E==="days"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(7,1fr)",padding:"6px 8px 0"},children:Ht.map(f=>e.jsx("div",{style:{textAlign:"center",fontSize:10,fontWeight:700,color:"var(--text-muted)",padding:"2px 0",textTransform:"uppercase"},children:f},f))}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(7,1fr)",gridTemplateRows:`repeat(${tr},1fr)`,padding:"4px 8px 10px",gap:2},children:W.map((f,H)=>{if(f===null)return e.jsx("div",{style:{aspectRatio:"1"}},H);const G=ar(x,m,f),K=G===r,Z=G===s,ne=!!(a&&G<a);return e.jsx("button",{type:"button",onClick:()=>!ne&&U(f),style:{width:"100%",aspectRatio:"1",borderRadius:6,border:"none",cursor:ne?"not-allowed":"pointer",fontSize:12,fontWeight:K||Z?700:400,background:K?"var(--primary)":"transparent",color:K?"var(--primary-fg, #ffffff)":ne?"var(--text-muted)":"var(--text-main)",opacity:ne?.4:1,outline:Z&&!K?"2px solid var(--primary)":"none",outlineOffset:"-2px"},children:f},H)})})]})]});return l?e.jsxs("div",{ref:S,className:"relative w-full",children:[e.jsxs("button",{type:"button",onClick:()=>b(f=>!f),className:"flex h-10 w-full items-center justify-between gap-2 rounded-lg px-2.5 py-0 text-sm transition-all duration-150 focus:outline-none",style:{background:"var(--bg-input)",border:`1px solid ${p?"var(--primary)":"var(--border)"}`,color:"var(--text-main)",boxShadow:p?"0 0 0 3px rgba(59,130,246,0.12)":"none"},children:[e.jsxs("span",{className:"inline-flex items-center gap-2 min-w-0",children:[e.jsx(w.HiCalendarDays,{className:"w-4 h-4 text-[var(--text-muted)]"}),e.jsx("span",{className:"truncate",children:Tt(r)})]}),e.jsx(w.HiChevronDown,{className:`w-4 h-4 text-[var(--text-muted)] transition-transform ${p?"rotate-180":""}`})]}),p&&e.jsx("div",{className:"absolute z-50",style:{...k.horizontal==="left"?{left:0}:{right:0},...k.vertical==="bottom"?{top:"calc(100% + 8px)"}:{bottom:"calc(100% + 8px)"}},children:te})]}):te}const At={sm:"h-4 w-4",md:"h-5 w-5"};function Ot({label:r,description:t,error:a,size:n="md",className:s="",containerClassName:c="",disabled:d,...l}){return e.jsxs("label",{className:`group inline-flex items-start gap-2.5 ${d?"cursor-not-allowed opacity-60":"cursor-pointer"} ${c}`,children:[e.jsxs("span",{className:"relative mt-0.5 inline-flex shrink-0",children:[e.jsx("input",{...l,type:"checkbox",disabled:d,"aria-invalid":!!a||l["aria-invalid"],className:`peer ${At[n]} appearance-none rounded border border-[var(--border)] bg-[var(--bg-input)] transition-colors checked:border-[var(--primary)] checked:bg-[var(--primary)] focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--primary)]/40 ${s}`}),e.jsx(w.HiCheck,{className:"pointer-events-none absolute left-1/2 top-1/2 h-3.5 w-3.5 -translate-x-1/2 -translate-y-1/2 scale-75 text-[var(--primary-fg)] opacity-0 transition peer-checked:scale-100 peer-checked:opacity-100"})]}),(r||t||a)&&e.jsxs("span",{className:"min-w-0",children:[r&&e.jsx("span",{className:"block text-sm font-medium leading-5 text-[var(--text-main)]",children:r}),t&&!a&&e.jsx("span",{className:"block text-xs leading-5 text-[var(--text-muted)]",children:t}),a&&e.jsx("span",{className:"block text-xs leading-5 text-[var(--danger)]",children:a})]})]})}function Mr(r){const t=document.createElement("textarea");t.value=r,t.style.position="fixed",t.style.opacity="0",t.style.pointerEvents="none",document.body.appendChild(t),t.select(),document.execCommand("copy"),document.body.removeChild(t)}async function It(r){var t;if((t=navigator.clipboard)!=null&&t.writeText){await navigator.clipboard.writeText(r);return}Mr(r)}function zt(r){return typeof r=="function"?r():r}function nr({value:r,resetDelay:t=2e3,title:a,copiedTitle:n="Copiado",copiedLabel:s,icon:c=e.jsx(w.HiClipboardDocument,{size:14}),copiedIcon:d=e.jsx(w.HiCheck,{size:14}),stopPropagation:l=!0,onCopied:p,onCopyError:b,className:S="",style:k,children:y,onClick:x,type:u="button",...m}){const[h,E]=o.useState(!1),F=o.useRef(null);o.useEffect(()=>()=>{F.current&&window.clearTimeout(F.current)},[]);function z(N){E(!0),p==null||p(N),F.current&&window.clearTimeout(F.current),F.current=window.setTimeout(()=>{E(!1),F.current=null},t)}async function T(N){var B;if(l&&N.stopPropagation(),x==null||x(N),N.defaultPrevented)return;const $=zt(r);if($)try{await It($),z($)}catch(P){try{Mr($),z($)}catch(D){b==null||b(D,$);return}(B=navigator.clipboard)!=null&&B.writeText||b==null||b(P,$)}}return e.jsxs("button",{...m,type:u,onClick:T,title:h?n:a,"aria-label":m["aria-label"]??(h?n:a),"data-copied":h?"true":void 0,className:`relative inline-flex h-7 shrink-0 items-center justify-center gap-1.5 rounded-md transition-all duration-200 ${y?"min-w-7 px-2":"w-7"} ${S}`,style:{cursor:"pointer",background:h?"rgba(22,163,74,0.15)":"var(--bg-card)",border:h?"1px solid rgba(22,163,74,0.4)":"1px solid var(--border)",color:h?"#16a34a":"var(--text-secondary)",boxShadow:h?"0 0 0 3px rgba(22,163,74,0.12)":"none",...k},children:[e.jsx("span",{className:"inline-flex items-center justify-center transition-all duration-150",style:{transform:h?"scale(1.15)":"scale(1)"},children:h?d:c}),y&&e.jsx("span",{className:"text-xs font-semibold leading-none",children:h?s??y:y})]})}function Pt({code:r,children:t,title:a="Codigo",language:n,copyLabel:s="Copiar",copiedLabel:c="Copiado",className:d="",style:l,onCopied:p}){const b=(r??t??"").trim();return e.jsxs("div",{className:`overflow-hidden rounded-lg border ${d}`,style:{borderColor:"rgba(148, 163, 184, 0.22)",background:"#0f172a",color:"#e2e8f0",...l},children:[e.jsxs("div",{className:"flex min-h-9 items-center justify-between gap-3 border-b px-3 py-1.5",style:{borderColor:"rgba(148, 163, 184, 0.18)",background:"#111827",color:"#94a3b8"},children:[e.jsx("span",{className:"min-w-0 truncate text-[11px] font-black uppercase tracking-[0.08em]",children:a}),e.jsx(nr,{value:b,title:"Copiar codigo",copiedTitle:"Codigo copiado",copiedLabel:c,onCopied:p,className:"h-7 min-w-[72px] px-2",style:{background:"#182235",border:"1px solid rgba(148, 163, 184, 0.28)",color:"#f8fafc"},children:s})]}),e.jsx("pre",{className:"m-0 overflow-x-auto p-3 text-xs leading-6",style:{background:"#0f172a",color:"#e2e8f0",fontFamily:'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace'},children:e.jsx("code",{className:n?`language-${n}`:void 0,children:b})})]})}function Dr(r){if(r!==void 0)return typeof r=="number"?`${r}px`:r}function or({value:r,onChange:t,options:a,placeholder:n="Seleccionar…",emptyLabel:s,disabled:c=!1,className:d="",style:l,height:p=40,padding:b="0 10px",searchable:S=!0,minOptionsForSearch:k=6}){const[y,x]=o.useState(!1),[u,m]=o.useState(""),[h,E]=o.useState(-1),[F,z]=o.useState(!1),[T,N]=o.useState({}),$=o.useRef(null),B=o.useRef(null),P=o.useRef(null),D=o.useRef(null),M=S&&a.length>=k,j=a.find(f=>f.value===r)??null,I=M&&u.trim()?a.filter(f=>{var H;return f.label.toLowerCase().includes(u.toLowerCase())||((H=f.sublabel)==null?void 0:H.toLowerCase().includes(u.toLowerCase()))}):a,W=o.useCallback(()=>{const f=$.current;if(!f)return;const H=f.getBoundingClientRect(),G=M?272:212,K=window.innerHeight-H.bottom,Z=K<G&&H.top>K;N({position:"fixed",left:H.left,top:Z?void 0:H.bottom+4,bottom:Z?window.innerHeight-H.top+4:void 0,width:H.width,zIndex:9999})},[M]);o.useEffect(()=>z(!0),[]),o.useEffect(()=>{if(!y)return;function f(H){var K,Z;const G=H.target;!((K=$.current)!=null&&K.contains(G))&&!((Z=B.current)!=null&&Z.contains(G))&&(x(!1),m(""))}return document.addEventListener("mousedown",f),()=>document.removeEventListener("mousedown",f)},[y]),o.useEffect(()=>{y&&(E(-1),W(),M&&setTimeout(()=>{var f;return(f=P.current)==null?void 0:f.focus()},0))},[y,M,W]),o.useEffect(()=>{if(y)return window.addEventListener("resize",W),window.addEventListener("scroll",W,!0),()=>{window.removeEventListener("resize",W),window.removeEventListener("scroll",W,!0)}},[y,W]),o.useEffect(()=>{if(h<0||!D.current)return;const f=D.current.children[h];f==null||f.scrollIntoView({block:"nearest"})},[h]);const U=o.useCallback(f=>{t(f),x(!1),m("")},[t]);function J(f){if(!y){(f.key==="Enter"||f.key===" "||f.key==="ArrowDown")&&(f.preventDefault(),x(!0));return}f.key==="Escape"?(f.preventDefault(),x(!1),m("")):f.key==="ArrowDown"?(f.preventDefault(),E(H=>Math.min(H+1,I.length-1))):f.key==="ArrowUp"?(f.preventDefault(),E(H=>Math.max(H-1,s?-1:0))):f.key==="Enter"&&(f.preventDefault(),h===-1&&s?U(""):I[h]&&U(I[h].value))}const te=e.jsxs("div",{ref:B,className:"rounded-xl shadow-xl overflow-hidden",style:{...T,background:"var(--bg-card)",border:"1px solid var(--border)"},children:[M&&e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",style:{borderBottom:"1px solid var(--border)"},children:[e.jsx(w.HiMagnifyingGlass,{className:"w-3.5 h-3.5 flex-shrink-0",style:{color:"var(--text-muted)"}}),e.jsx("input",{ref:P,value:u,onChange:f=>{m(f.target.value),E(-1)},placeholder:"Buscar…",className:"min-w-0 flex-1 text-sm bg-transparent outline-none",style:{color:"var(--text-main)"}}),u&&e.jsx("button",{type:"button",onMouseDown:f=>{f.preventDefault(),m("")},children:e.jsx(w.HiXMark,{className:"w-3.5 h-3.5",style:{color:"var(--text-muted)"}})})]}),e.jsxs("ul",{ref:D,role:"listbox",className:"overflow-y-auto",style:{maxHeight:M?220:180,scrollbarWidth:"thin",scrollbarColor:"var(--border) transparent",overscrollBehavior:"contain"},children:[s&&e.jsx("li",{role:"option","aria-selected":r==="",onMouseDown:f=>{f.preventDefault(),U("")},onMouseEnter:()=>E(-1),className:"flex items-center gap-2 px-3 py-2 cursor-pointer text-sm transition-colors",style:{background:h===-1?"var(--bg-hover)":"transparent",color:"var(--text-muted)",fontStyle:"italic"},children:s}),I.map((f,H)=>{const K=H===h,Z=f.value===r;return e.jsxs("li",{role:"option","aria-selected":Z,onMouseDown:ne=>{ne.preventDefault(),f.disabled||U(f.value)},onMouseEnter:()=>!f.disabled&&E(H),className:"flex items-center gap-2 px-3 py-2 cursor-pointer text-sm transition-colors",style:{background:K?"var(--bg-hover)":Z?"color-mix(in srgb, var(--primary) 6%, transparent)":"transparent",color:f.disabled?"var(--text-muted)":"var(--text-main)",cursor:f.disabled?"not-allowed":"pointer",boxShadow:Z?"inset 2px 0 0 var(--primary)":void 0},children:[f.color&&e.jsx("span",{className:"flex-shrink-0 w-2.5 h-2.5 rounded-full",style:{background:f.color}}),e.jsxs("span",{className:"min-w-0 flex flex-1 items-baseline gap-1 overflow-hidden",children:[e.jsx("span",{className:"truncate",children:f.label}),f.sublabel&&e.jsx("span",{className:"min-w-0 flex-shrink truncate",style:{color:"var(--text-muted)",fontSize:12},children:f.sublabel})]}),f.badge&&e.jsx("span",{className:"text-xs flex-shrink-0",style:{color:"var(--text-muted)"},children:f.badge})]},f.value)}),I.length===0&&e.jsx("li",{className:"px-3 py-4 text-sm text-center",style:{color:"var(--text-muted)"},children:"Sin resultados"})]})]});return e.jsxs("div",{ref:$,className:`relative ${d||"w-full"}`,style:l,onKeyDown:J,children:[e.jsxs("button",{type:"button",disabled:c,onClick:()=>!c&&x(f=>!f),className:"flex w-full items-center gap-2 rounded-lg text-left text-sm transition-colors focus:outline-none",style:{height:Dr(p),padding:Dr(b),background:"var(--bg-input)",color:j?"var(--text-main)":"var(--text-muted)",border:y?"1px solid var(--primary)":"1px solid var(--border)",opacity:c?.5:1,cursor:c?"not-allowed":"pointer"},"aria-haspopup":"listbox","aria-expanded":y,children:[(j==null?void 0:j.color)&&e.jsx("span",{className:"flex-shrink-0 w-2.5 h-2.5 rounded-full",style:{background:j.color}}),e.jsx("span",{className:"min-w-0 flex flex-1 items-baseline gap-1 overflow-hidden",children:j?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"truncate",children:j.label}),j.sublabel&&e.jsx("span",{className:"min-w-0 flex-shrink truncate",style:{color:"var(--text-muted)",fontSize:12},children:j.sublabel})]}):e.jsx("span",{className:"truncate",children:n})}),j&&s?e.jsx("span",{role:"button",tabIndex:-1,onMouseDown:f=>{f.preventDefault(),f.stopPropagation(),U("")},className:"flex-shrink-0 rounded-full p-0.5 transition-colors hover:bg-black/10",style:{color:"var(--text-muted)"},children:e.jsx(w.HiXMark,{className:"w-3 h-3"})}):e.jsx(w.HiChevronDown,{className:"flex-shrink-0 w-4 h-4 transition-transform",style:{color:"var(--text-muted)",transform:y?"rotate(180deg)":"rotate(0deg)"}})]}),y&&F&&Ee.createPortal(te,document.body)]})}function qe(r){if(r!==void 0)return typeof r=="number"?`${r}px`:r}function jt({value:r,onChange:t,placeholder:a="Buscar...",className:n="",height:s=40,padding:c="0 10px 0 30px",iconLeft:d=10}){return e.jsxs("div",{className:`relative ${n}`,children:[e.jsx(w.HiMagnifyingGlass,{className:"absolute top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-[var(--text-muted)] pointer-events-none",style:{left:qe(d)}}),e.jsx("input",{type:"text",value:r,onChange:l=>t(l.target.value),placeholder:a,className:"w-full rounded-lg border border-[var(--border)] [background:var(--bg-card)] text-sm text-[var(--text-main)] placeholder:text-[var(--text-muted)] outline-none transition-[border-color,box-shadow] focus:border-primary focus:ring-2 focus:ring-primary/20",style:{height:qe(s),padding:qe(c)}})]})}function _t({value:r,onChange:t,options:a,placeholder:n,icon:s,className:c="",height:d=40,padding:l,iconLeft:p=10,searchable:b=!0}){const S=s?a.map((k,y)=>y===0&&!k.color?{...k,sublabel:k.sublabel??void 0}:k):a;return e.jsxs("div",{className:`relative ${c}`,children:[s&&e.jsx("span",{className:"pointer-events-none absolute top-1/2 z-10 -translate-y-1/2 text-[var(--text-muted)]",style:{left:qe(p)},children:s}),e.jsx(or,{value:r,onChange:t,options:S,placeholder:n,searchable:b,minOptionsForSearch:5,height:d,padding:l??(s?"0 10px 0 30px":"0 10px"),className:"[&>button]:text-sm [&>button]:[background:var(--bg-card)]"})]})}const Ft={sm:"24rem",md:"28rem",lg:"32rem",xl:"40rem","2xl":"48rem","4xl":"56rem","5xl":"64rem"},Ge=180;function Hr({open:r,onClose:t,title:a,subtitle:n,leadingIcon:s,headerActions:c,footer:d,children:l,size:p="md",maxWidth:b,zIndex:S=1e3,closeOnBackdrop:k=!0,closeOnEscape:y=!0,showCloseButton:x=!0,placement:u="center",bodyClassName:m="px-6 py-5",panelClassName:h="",backdropClassName:E="bg-black/50 backdrop-blur-sm",contentClassName:F="p-4",ariaLabel:z,frameless:T=!1}){const[N,$]=o.useState(!1),[B,P]=o.useState(!1),D=o.useRef(null);if(o.useEffect(()=>(r?(D.current&&clearTimeout(D.current),$(!0),requestAnimationFrame(()=>requestAnimationFrame(()=>P(!0)))):(P(!1),D.current=setTimeout(()=>$(!1),Ge+40)),()=>{D.current&&clearTimeout(D.current)}),[r]),o.useEffect(()=>{if(r)return document.body.style.overflow="hidden",()=>{document.body.style.overflow=""}},[r]),o.useEffect(()=>{if(!r||!y)return;const J=te=>{te.key==="Escape"&&t()};return window.addEventListener("keydown",J),()=>window.removeEventListener("keydown",J)},[y,t,r]),!N)return null;const M=a||n||s||c||x,j=b??Ft[p],I=u==="bottom-mobile"?"items-end sm:items-center justify-center p-0 sm:p-4":"items-center justify-center",W=u==="bottom-mobile"?"rounded-t-2xl sm:rounded-2xl":"rounded-2xl",U=B?"translateY(0) scale(1)":u==="bottom-mobile"?"translateY(16px) scale(0.98)":"translateY(10px) scale(0.96)";return Ee.createPortal(e.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":z??a,className:`fixed inset-0 flex ${I} ${F}`,style:{zIndex:S},children:[e.jsx("div",{className:`absolute inset-0 ${E}`,onClick:k?t:void 0,style:{opacity:B?1:0,transition:`opacity ${Ge}ms ease`}}),e.jsxs("div",{className:`relative z-10 flex max-h-[92dvh] w-full flex-col overflow-hidden ${T?"shadow-none":"shadow-2xl"} ${W} ${h}`,style:{maxWidth:j,background:T?"transparent":"var(--bg-card)",border:T?"none":"1px solid var(--border)",opacity:B?1:0,transform:U,transition:`opacity ${Ge}ms ease, transform ${Ge}ms ease`},onClick:J=>J.stopPropagation(),children:[M&&e.jsxs("div",{className:"flex flex-shrink-0 items-center justify-between gap-3 px-6 py-4",style:{borderBottom:"1px solid var(--border)"},children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[s&&e.jsx("div",{className:"flex-shrink-0",children:s}),(a||n)&&e.jsxs("div",{className:"min-w-0",children:[a&&e.jsx("h2",{className:"truncate text-base font-semibold",style:{color:"var(--text-main)"},children:a}),n&&e.jsx("p",{className:"truncate text-xs",style:{color:"var(--text-muted)"},children:n})]})]}),e.jsxs("div",{className:"flex flex-shrink-0 items-center gap-2",children:[c,x&&e.jsx(ie,{variant:"icon",onClick:t,title:"Cerrar",children:e.jsx(w.HiXMark,{className:"h-5 w-5"})})]})]}),e.jsx("div",{className:`min-h-0 flex-1 overflow-y-auto ${m}`,children:l}),d&&e.jsx("div",{className:"flex flex-shrink-0 justify-end gap-2 px-6 py-4",style:{borderTop:"1px solid var(--border)"},children:d})]})]}),document.body)}const Wt={danger:{iconBg:"rgba(239,68,68,0.12)",iconColor:"var(--danger)",btnBg:"var(--danger)",btnColor:"#fff"},warning:{iconBg:"rgba(245,158,11,0.12)",iconColor:"var(--warning)",btnBg:"var(--warning)",btnColor:"#fff"},primary:{iconBg:"rgba(59,130,246,0.12)",iconColor:"var(--primary)",btnBg:"var(--primary)",btnColor:"#fff"}};function Ut({open:r,title:t,description:a,confirmLabel:n="Confirmar",cancelLabel:s="Cancelar",variant:c="danger",onConfirm:d,onCancel:l}){const p=Wt[c];return e.jsxs(Hr,{open:r,onClose:l,size:"sm",zIndex:9998,showCloseButton:!1,bodyClassName:"p-6",panelClassName:"px-1",ariaLabel:t,children:[e.jsx(ie,{variant:"icon",onClick:l,className:"absolute right-3 top-3 h-7 w-7 hover:opacity-70",style:{color:"var(--text-muted)"},"aria-label":"Cancelar",children:e.jsx(w.HiXMark,{className:"h-4 w-4"})}),e.jsx("div",{className:"mb-4 flex h-11 w-11 items-center justify-center rounded-xl",style:{background:p.iconBg},children:e.jsx(w.HiExclamationTriangle,{className:"h-5 w-5",style:{color:p.iconColor}})}),e.jsx("h2",{className:"mb-1 text-base font-semibold",style:{color:"var(--text-main)"},children:t}),a&&e.jsx("p",{className:"text-sm",style:{color:"var(--text-muted)"},children:a}),e.jsxs("div",{className:"mt-6 flex gap-2",children:[e.jsx(ie,{variant:"secondary",onClick:l,className:"flex-1",style:{background:"var(--bg-input)"},children:s}),e.jsx(ie,{variant:"danger",onClick:d,className:"flex-1",style:{background:p.btnBg,color:p.btnColor,borderColor:"transparent"},children:n})]})]})}function qt(r,t){const a=typeof r=="function"?r():r;return t?t(a):a}function Gt({url:r,resolveUrl:t,title:a="Copiar link",copiedTitle:n="Link copiado",icon:s=e.jsx(w.HiLink,{className:"h-3.5 w-3.5"}),...c}){return e.jsx(nr,{...c,value:()=>qt(r,t),title:a,copiedTitle:n,icon:s})}const Xt="[&_button]:h-7 [&_button]:min-h-0 [&_button]:gap-1 [&_button]:px-2 [&_button]:text-xs [&_button_svg]:h-3.5 [&_button_svg]:w-3.5 [&_button[data-icon=true]]:w-7 [&_button[data-icon=true]]:px-0",Yt=[];function Pe(r){if(!r)return 150;const t=parseInt(r,10);return isNaN(t)||t<=0?150:t}function $e(r,t){const a=r.minWidth??80,n=r.maxWidth??1/0;return Math.min(n,Math.max(a,t))}function Vt(r,t){if(t<=7)return Array.from({length:t},(n,s)=>s+1);const a=[1];r>3&&a.push("...");for(let n=Math.max(2,r-1);n<=Math.min(t-1,r+1);n++)a.push(n);return r<t-2&&a.push("..."),a.push(t),a}function Me(r,t){var d;const a=new Set(t.filter(l=>l.hideable!==!1).map(l=>l.key)),n=Array.from(new Set(r??[])).filter(l=>a.has(l));if(t.filter(l=>!n.includes(l.key)).length>0)return n;const c=(d=t.find(l=>l.hideable!==!1))==null?void 0:d.key;return c?n.filter(l=>l!==c):[]}function Lr({children:r,className:t="",style:a}){return e.jsx(Ue,{onlyWhenOverflow:!0,className:t,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",...a},children:r})}function Kt({columns:r,data:t,getRowId:a,loading:n=!1,skeletonRows:s=8,emptyIcon:c,emptyText:d="Sin resultados",initialEmptyDelay:l=450,onRowClick:p,selected:b,onToggleOne:S,onToggleAll:k,highlightSelected:y=!0,rowClassName:x,getRowCategory:u,stickyHeader:m=!0,pageSize:h=25,pageSizeOptions:E=[25,50,100],pageSizeSelectWidth:F=62,pageSizeSelectHeight:z=30,pageSizeSelectPadding:T="0 7px",totalRows:N,page:$,onPageChange:B,onPageSizeChange:P,storageKey:D,stickyFirstColumn:M=!1,bottomOffset:j=0,compact:I=!0,restrictHeight:W=!0,minTableWidth:U,enableColumnVisibility:J=!0,hiddenColumnKeys:te,defaultHiddenColumnKeys:f=Yt,onHiddenColumnKeysChange:H,columnVisibilityLabel:G="Columnas"}){const K=r.map(i=>i.key).join(","),[Z,ne]=o.useState(!D),de=o.useRef(null),v=o.useRef(!D),Y=te!==void 0,[be,ee]=o.useState(()=>Me(f,r)),Q=Me(Y?te:be,r),[O,V]=o.useState(!1),[R,se]=o.useState(null),[he,X]=o.useState({}),we=o.useRef(null),De=o.useRef(null),[_e,Te]=o.useState(t.length>0||n||l===!1),Fe=(i,g)=>50+(i*17+g*13+7)%40,oe=o.useRef(null),[Be,Ke]=o.useState(void 0),[Ae,Ze]=o.useState(!1);o.useEffect(()=>{const g=h!==!1?32:0,C=12;function _(){if(Ze(window.innerWidth<640),!oe.current)return;const q=oe.current.getBoundingClientRect().top;Ke(Math.max(120,window.innerHeight-q-g-C-j))}return _(),window.addEventListener("resize",_),()=>window.removeEventListener("resize",_)},[n,h,j]),o.useEffect(()=>{if(l===!1||n||t.length>0){Te(!0);return}if(_e)return;const i=window.setTimeout(()=>{Te(!0)},l);return()=>window.clearTimeout(i)},[t.length,l,_e,n]);const[ke,Se]=o.useState(()=>r.map(i=>i.key)),[L,le]=o.useState(()=>Object.fromEntries(r.map(i=>[i.key,$e(i,Pe(i.width))])));o.useEffect(()=>{const i=r.map(C=>C.key);if(!D){Se(i),Y||ee(Me(f,r)),v.current=!1,ne(!0);return}let g=!1;return v.current=!1,ne(!1),fetch(`/api/user/preferences/datatables?key=${encodeURIComponent(D)}`,{cache:"no-store"}).then(C=>C.ok?C.json():null).then(C=>{var er,lt,it;if(g)return;const _=(er=C==null?void 0:C.settings)==null?void 0:er.columnOrder,q=Array.isArray(_)?_.filter(ve=>i.includes(ve)):[],ae=i.filter(ve=>!q.includes(ve)),ce=q.length>0?[...q,...ae]:i,Le=Object.fromEntries(r.map(ve=>[ve.key,$e(ve,Pe(ve.width))])),re=((lt=C==null?void 0:C.settings)==null?void 0:lt.columnWidths)??{},pe=Object.fromEntries(r.map(ve=>[ve.key,$e(ve,re[ve.key]??Le[ve.key])])),Re=Me(((it=C==null?void 0:C.settings)==null?void 0:it.hiddenColumnKeys)??f,r);Se(ce),le(pe),Y||ee(Re),de.current=JSON.stringify({columnOrder:ce,columnWidths:pe,hiddenColumnKeys:Re}),v.current=!0}).catch(()=>{if(!g){Se(i);const C=Object.fromEntries(r.map(q=>[q.key,$e(q,Pe(q.width))]));le(C);const _=Me(f,r);Y||ee(_),de.current=JSON.stringify({columnOrder:i,columnWidths:C,hiddenColumnKeys:_}),v.current=!0}}).finally(()=>{g||ne(!0)}),()=>{g=!0}},[D,K,r,f,Y]),o.useEffect(()=>{if(!D||!Z||!v.current)return;const i={columnOrder:ke,columnWidths:L,hiddenColumnKeys:Q},g=JSON.stringify(i);if(g===de.current)return;const C=window.setTimeout(()=>{fetch("/api/user/preferences/datatables",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({key:D,settings:i})}).then(_=>{_.ok&&(de.current=g)}).catch(()=>{})},300);return()=>window.clearTimeout(C)},[ke,L,Q,D,Z]),o.useEffect(()=>{Se(i=>{const g=r.map(q=>q.key),C=i.filter(q=>g.includes(q)),_=g.filter(q=>!C.includes(q));return[...C,..._]})},[K,r]);const ue=ke.map(i=>r.find(g=>g.key===i)).filter(i=>!!i),me=ue.filter(i=>!Q.includes(i.key));function fe(i){const g=Me(i,r);Y||ee(g),H==null||H(g)}function We(i){fe(Q.includes(i)?Q.filter(g=>g!==i):[...Q,i])}function Oe(){fe([])}const ir=o.useCallback((i=De.current)=>{if(!i)return;const g=i.getBoundingClientRect(),C=256,_=Math.min(Math.max(8,g.right-C),window.innerWidth-C-8),q=window.innerHeight-g.bottom,ae=q<288&&g.top>q?void 0:g.bottom+6,ce=ae===void 0?window.innerHeight-g.top+6:void 0;X({position:"fixed",zIndex:9999,left:_,top:ae,bottom:ce,width:C})},[]);function on(i,g){i.preventDefault(),i.stopPropagation();const C=De.current===i.currentTarget&&R===g;if(O&&C){V(!1),se(null);return}De.current=i.currentTarget,se(g),ir(i.currentTarget),V(!0)}o.useEffect(()=>{le(i=>{const g=Object.fromEntries(r.map(C=>[C.key,$e(C,Pe(C.width))]));return Object.fromEntries(r.map(C=>[C.key,$e(C,i[C.key]??g[C.key])]))})},[K,r]),o.useEffect(()=>{Y||ee(i=>Me(i,r))},[K,r,Y]),o.useEffect(()=>{function i(_){var ae,ce;const q=_.target;!((ae=we.current)!=null&&ae.contains(q))&&!((ce=De.current)!=null&&ce.contains(q))&&(V(!1),se(null))}function g(_){_.key==="Escape"&&(V(!1),se(null))}function C(){ir()}return O&&(document.addEventListener("mousedown",i),window.addEventListener("keydown",g),window.addEventListener("resize",C),window.addEventListener("scroll",C,!0)),()=>{document.removeEventListener("mousedown",i),window.removeEventListener("keydown",g),window.removeEventListener("resize",C),window.removeEventListener("scroll",C,!0)}},[O,ir]);const Je=o.useRef(null);o.useEffect(()=>{function i(C){const _=Je.current;if(!_)return;const q=C.clientX-_.startX,ae=r.find(ce=>ce.key===_.colKey);ae&&le(ce=>({...ce,[_.colKey]:$e(ae,_.startWidth+q)}))}function g(){Je.current&&(Je.current=null,document.body.style.cursor="",document.body.style.userSelect="")}return document.addEventListener("pointermove",i),document.addEventListener("pointerup",g),()=>{document.removeEventListener("pointermove",i),document.removeEventListener("pointerup",g)}},[r]);const Qe=o.useRef(null),[Jr,cr]=o.useState(null);function sn(i,g){Qe.current=ke.indexOf(i),g.dataTransfer.effectAllowed="move"}function ln(i,g){g.preventDefault(),g.dataTransfer.dropEffect="move";const C=ke.indexOf(i);Jr!==C&&cr(C)}function cn(i,g){g.preventDefault();const C=Qe.current,_=ke.indexOf(i);C!==null&&C!==_&&Se(q=>{const ae=[...q],[ce]=ae.splice(C,1);return ae.splice(_,0,ce),ae}),Qe.current=null,cr(null)}function dn(){Qe.current=null,cr(null)}const[xe,Qr]=o.useState(null);function un(i){i.sortKey&&Qr(g=>(g==null?void 0:g.key)===i.key?{key:i.key,dir:g.dir==="asc"?"desc":"asc"}:{key:i.key,dir:"asc"})}const[fn,dr]=o.useState(1),[Rr,pn]=o.useState(h===!1?0:h);o.useEffect(()=>{dr(1)},[t]);const Ie=!!(B&&P),He=h!==!1,ge=Ie?$??1:fn,Ce=Ie||He?Rr:t.length,ye=!!b&&!!S&&!!k,ur=ye?40:0,bn=ye&&t.length>0&&b.size===t.length,hn=ye&&b.size>0&&b.size<t.length,fr=o.useMemo(()=>{if(!xe)return t;const i=r.find(g=>g.key===xe.key&&g.sortKey);return i!=null&&i.sortKey?[...t].sort((g,C)=>{const _=g[i.sortKey],q=C[i.sortKey],ae=_===q?0:_==null?1:q==null||_<q?-1:1;return xe.dir==="asc"?ae:-ae}):t},[t,xe,r]),et=o.useMemo(()=>{if(Ie||!He)return fr;const i=(ge-1)*Ce;return fr.slice(i,i+Ce)},[fr,Ie,He,ge,Ce]),ze=N??t.length,pr=He?Math.max(1,Math.ceil(ze/Ce)):1,mn=He&&ze>Ce,vn=He?(ge-1)*Ce+1:1,xn=He?Math.min(ge*Ce,ze):ze;function br(i){const g=Math.max(1,Math.min(i,pr));Ie?B(g):dr(g)}function gn(i){pn(i),Ie?(P(i),B(1)):dr(1),P&&P(i)}const rt=i=>i==="center"?"text-center":i==="right"?"text-right":"text-left",yn="color-mix(in srgb, var(--primary) 6%, var(--bg-card))",wn=me.length+(ye?1:0);o.useEffect(()=>{xe&&Q.includes(xe.key)&&Qr(null)},[Q,xe]);function tt(i){return i?typeof i=="string"?{key:i,label:i}:i:null}const at=()=>e.jsxs("tr",{style:{background:"color-mix(in srgb, var(--bg-input) 72%, transparent)"},children:[ye&&e.jsx("th",{className:`${I?"px-2 py-1.5":"px-3 py-2.5"} w-10`,style:M?{position:"sticky",left:0,zIndex:12,background:"color-mix(in srgb, var(--bg-input) 72%, transparent)",backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)",boxShadow:"inset 0 -2px 0 var(--border)",borderRight:"1px solid var(--border)"}:{borderBottom:"2px solid var(--border)",borderRight:"1px solid var(--border)"},children:e.jsx("input",{type:"checkbox",checked:bn,ref:i=>{i&&(i.indeterminate=hn)},onChange:k,className:"rounded cursor-pointer accent-[var(--primary)]"})}),me.map((i,g)=>{const C=(xe==null?void 0:xe.key)===i.key,_=!!i.sortKey,q=M&&!Ae&&g===0,ae=Jr===g,Le=(L[i.key]??Pe(i.width))<120;return e.jsxs("th",{className:`group select-none ${Le?"text-left":rt(i.align)}`,style:{...q?{position:"sticky",left:ur,zIndex:12,background:"color-mix(in srgb, var(--bg-input) 72%, transparent)",backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)",boxShadow:"3px 0 6px -2px rgba(0,0,0,0.12), inset 0 -2px 0 var(--border)",borderRight:"1px solid var(--border)"}:{position:"relative",borderBottom:"2px solid var(--border)",borderRight:"1px solid var(--border)"},color:C?"var(--primary)":"var(--text-muted)",whiteSpace:"nowrap",transition:"color 0.15s",borderLeft:ae?"2px solid var(--primary)":"2px solid transparent",cursor:_?"pointer":"default",padding:I?"5px 20px 5px 12px":"7px 24px 7px 12px"},onDragOver:re=>ln(i.key,re),onDrop:re=>cn(i.key,re),onClick:_?()=>un(i):void 0,children:[e.jsx("span",{draggable:!0,onDragStart:re=>{re.stopPropagation(),sn(i.key,re)},onDragEnd:re=>{re.stopPropagation(),dn()},onClick:re=>re.stopPropagation(),title:"Arrastrar para reordenar",className:`absolute left-2 top-1/2 inline-flex h-6 w-5 -translate-x-1/2 -translate-y-1/2 scale-90 items-center justify-center rounded-md border opacity-0 shadow-sm transition-[opacity,transform,background-color,border-color] duration-150 group-hover:scale-100 group-hover:opacity-100 ${ae?"scale-100 opacity-100":""}`,style:{cursor:"grab",color:ae?"var(--primary)":"var(--text-muted)",background:"var(--bg-card)",borderColor:ae?"var(--primary)":"var(--border)",zIndex:5},children:e.jsx(ct.MdDragIndicator,{size:15})}),e.jsx(Lr,{className:"inline-block max-w-full align-middle",style:{width:"100%",textAlign:Le?"left":i.align==="center"?"center":i.align==="right"?"right":"left"},children:e.jsxs("span",{className:`inline-flex max-w-full items-center gap-1 font-semibold uppercase tracking-wider ${I?"text-[11px]":"text-xs"}`,children:[e.jsx("span",{className:"min-w-0 truncate",children:i.header}),_&&e.jsx("span",{className:"flex-shrink-0 opacity-60",children:C?xe.dir==="asc"?e.jsx(w.HiChevronUp,{className:"w-3 h-3"}):e.jsx(w.HiChevronDown,{className:"w-3 h-3"}):e.jsx(w.HiChevronUpDown,{className:"w-3 h-3 opacity-40"})})]})}),J&&e.jsx("button",{type:"button","aria-haspopup":"menu","aria-expanded":O&&R===i.key,"aria-label":G,title:G,onClick:re=>on(re,i.key),className:`absolute right-3 top-1/2 inline-flex h-6 w-6 -translate-y-1/2 scale-95 items-center justify-center rounded-md border opacity-0 shadow-sm transition-[opacity,transform,background-color,border-color] duration-150 hover:bg-[var(--bg-card)] group-hover:scale-100 group-hover:opacity-100 focus:scale-100 focus:opacity-100 ${O&&R===i.key?"scale-100 opacity-100":""}`,style:{color:"var(--text-muted)",background:"var(--bg-card)",borderColor:"var(--border)",zIndex:4},children:e.jsx(w.HiEllipsisVertical,{className:"h-4 w-4"})}),e.jsx("span",{role:"separator","aria-orientation":"vertical",title:"Arrastrar para redimensionar",onPointerDown:re=>{re.preventDefault(),re.stopPropagation(),Je.current={colKey:i.key,startX:re.clientX,startWidth:L[i.key]??150},document.body.style.cursor="col-resize",document.body.style.userSelect="none"},onClick:re=>re.stopPropagation(),className:"absolute top-0 flex h-full items-center justify-center opacity-0 transition-opacity group-hover:opacity-100",style:{right:-6,width:12,cursor:"col-resize",zIndex:6},children:e.jsx("span",{style:{width:3,height:"40%",borderRadius:2,background:"var(--primary)",display:"block"}})})]},i.key)})]}),nt=()=>{if(!J||!O||typeof document>"u")return null;const i=Q.length;return Ee.createPortal(e.jsxs("div",{ref:we,role:"menu",className:"overflow-hidden rounded-lg border p-1 shadow-xl",style:{...he,borderColor:"var(--border)",background:"var(--bg-card)"},children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-[var(--border)] px-2 py-1.5",children:[e.jsx("span",{className:"min-w-0 truncate text-xs font-semibold uppercase text-[var(--text-muted)]",children:i>0?`${me.length} de ${r.length} visibles`:`${r.length} visibles`}),e.jsx("button",{type:"button",onClick:Oe,disabled:i===0,className:"rounded px-1.5 py-0.5 text-xs font-medium text-[var(--primary)] transition-colors hover:bg-[var(--bg-input)] disabled:opacity-40",children:"Mostrar todas"})]}),e.jsx("div",{className:"max-h-72 overflow-auto py-1",children:ue.map(g=>{const C=!Q.includes(g.key),q=!(g.hideable!==!1)||C&&me.length<=1;return e.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":C,disabled:q,onClick:()=>We(g.key),className:"flex w-full min-w-0 items-center gap-2 rounded-md px-2.5 py-1.5 text-left transition-colors hover:bg-[var(--bg-input)] disabled:cursor-not-allowed disabled:opacity-50",style:{color:"var(--text-main)"},children:[e.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center rounded border",style:{borderColor:C?"var(--primary)":"var(--border)",background:C?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:C&&e.jsx(w.HiCheck,{className:"h-3 w-3"})}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:g.header})]},g.key)})})]}),document.body)},ot=()=>{if(!mn||n)return null;const i=Vt(ge,pr);return e.jsxs("div",{className:`grid grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)] items-center gap-2 rounded-b-xl border-t text-xs select-none ${I?"px-2 py-0.5":"px-3 py-1"}`,style:{borderColor:"var(--border)",background:"var(--bg-input)"},children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{style:{color:"var(--text-muted)"},children:ze===0?"0 filas":`${vn}–${xn} de ${ze}`}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{style:{color:"var(--text-muted)"},children:"Filas:"}),e.jsx(or,{value:String(Ce),onChange:g=>gn(Number(g)),options:E.map(g=>({value:String(g),label:String(g)})),placeholder:"Filas",searchable:!1,height:z,padding:T,className:"shrink-0 [&>button]:rounded-md [&>button]:text-xs [&_svg]:h-3.5 [&_svg]:w-3.5",style:{width:F}})]})]}),e.jsxs("div",{className:"flex items-center justify-center gap-0.5",children:[e.jsx("button",{disabled:ge<=1,onClick:()=>br(ge-1),className:"rounded p-0.5 transition-colors disabled:opacity-30",style:{color:"var(--text-muted)",background:"transparent"},children:e.jsx(w.HiChevronLeft,{className:"h-3.5 w-3.5"})}),i.map((g,C)=>g==="..."?e.jsx("span",{className:"px-1",style:{color:"var(--text-muted)"},children:"…"},`e${C}`):e.jsx("button",{onClick:()=>br(g),className:"h-5 w-5 rounded text-[11px] font-medium transition-colors",style:{background:g===ge?"var(--primary)":"transparent",color:g===ge?"var(--primary-fg)":"var(--text-muted)"},children:g},g)),e.jsx("button",{disabled:ge>=pr,onClick:()=>br(ge+1),className:"rounded p-0.5 transition-colors disabled:opacity-30",style:{color:"var(--text-muted)",background:"transparent"},children:e.jsx(w.HiChevronRight,{className:"h-3.5 w-3.5"})})]}),e.jsx("div",{"aria-hidden":"true"})]})},st=()=>e.jsx("div",{className:"w-full min-w-0 max-w-full flex flex-col rounded-xl overflow-hidden",style:{border:"1px solid var(--border)"},children:e.jsxs("div",{ref:oe,className:"min-w-0 max-w-full",style:{maxHeight:W?Be:void 0,background:"var(--bg-card)"},children:[e.jsx("div",{className:"border-b px-3 py-2",style:{borderColor:"var(--border)",background:"color-mix(in srgb, var(--bg-input) 72%, transparent)"},children:e.jsx("div",{className:"h-3.5 w-40 animate-pulse rounded-full",style:{background:"var(--border)"}})}),e.jsx("div",{className:"space-y-2 p-3",children:Array.from({length:Math.min(6,s)}).map((i,g)=>e.jsx("div",{className:"grid grid-cols-[1.2fr_1fr_0.8fr_0.7fr] gap-3",children:Array.from({length:4}).map((C,_)=>e.jsx("div",{className:"h-3.5 animate-pulse rounded-full",style:{background:"var(--border)",width:`${Fe(g,_)}%`,minWidth:32}},_))},g))})]})});return D&&!Z||!n&&t.length===0&&!_e?st():n&&t.length===0?e.jsxs("div",{className:"w-full min-w-0 max-w-full flex flex-col rounded-xl overflow-visible",style:{border:"1px solid var(--border)"},children:[nt(),e.jsx("div",{ref:oe,className:"min-w-0 max-w-full overflow-hidden rounded-t-xl",children:e.jsx(mr.OverlayScrollbarsComponent,{options:{scrollbars:{autoHide:"leave",autoHideDelay:200}},className:"w-full",style:{maxHeight:W?Be:void 0,maxWidth:"100%"},defer:!0,children:e.jsxs("table",{className:"text-sm",style:{tableLayout:"fixed",width:"100%",minWidth:U??"max-content",borderCollapse:"separate",borderSpacing:0},children:[e.jsxs("colgroup",{children:[ye&&e.jsx("col",{style:{width:40}}),me.map(i=>e.jsx("col",{style:{width:L[i.key]??150}},i.key))]}),e.jsx("thead",{style:m?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:at()}),e.jsx("tbody",{children:Array.from({length:s}).map((i,g)=>e.jsxs("tr",{children:[ye&&e.jsx("td",{className:`${I?"px-2 py-1.5":"px-3 py-2"} w-10`,style:{borderBottom:"1px solid var(--border)",borderRight:"1px solid var(--border)"}}),me.map((C,_)=>{const q=M&&!Ae&&_===0;return e.jsx("td",{className:I?"px-2 py-1.5":"px-3 py-2",style:q?{position:"sticky",left:ur,zIndex:1,background:"color-mix(in srgb, var(--bg-card) 72%, transparent)",backdropFilter:"blur(10px)",WebkitBackdropFilter:"blur(10px)",boxShadow:"3px 0 6px -2px rgba(0,0,0,0.12), inset 0 -1px 0 var(--border)",borderRight:"1px solid var(--border)"}:{borderBottom:"1px solid var(--border)",borderRight:"1px solid var(--border)"},children:e.jsx("div",{className:"h-3.5 rounded-full animate-pulse",style:{background:"var(--border)",width:`${Fe(g,_)}%`,minWidth:32}})},C.key)})]},g))})]})})}),ot()]}):!n&&t.length===0?e.jsxs("div",{className:"flex min-h-[220px] flex-col items-center justify-center gap-3 rounded-xl border px-6 py-14 text-center",style:{borderColor:"var(--border)",background:"linear-gradient(180deg, color-mix(in srgb, var(--bg-input) 58%, transparent), var(--bg-card))"},children:[e.jsx("div",{className:"flex h-12 w-12 items-center justify-center rounded-full border",style:{borderColor:"color-mix(in srgb, var(--primary) 24%, var(--border))",background:"color-mix(in srgb, var(--primary) 8%, var(--bg-card))",color:"var(--primary)"},children:c??e.jsx(w.HiMagnifyingGlass,{className:"h-5 w-5"})}),e.jsx("p",{className:"max-w-sm text-sm font-medium",style:{color:"var(--text-main)"},children:d}),e.jsx("span",{className:"text-xs",style:{color:"var(--text-muted)"},children:"Ajusta la busqueda o cambia los filtros para ver mas informacion."})]}):e.jsxs("div",{className:"w-full min-w-0 max-w-full flex flex-col rounded-xl overflow-visible",style:{border:"1px solid var(--border)"},children:[nt(),e.jsx("div",{ref:oe,className:"min-w-0 max-w-full overflow-hidden rounded-t-xl",children:e.jsx(mr.OverlayScrollbarsComponent,{options:{scrollbars:{autoHide:"leave",autoHideDelay:200}},className:"w-full",style:{maxHeight:W?Be:void 0,maxWidth:"100%"},defer:!0,children:e.jsxs("table",{className:"text-sm",style:{tableLayout:"fixed",width:"100%",minWidth:U??"max-content",borderCollapse:"separate",borderSpacing:0},children:[e.jsxs("colgroup",{children:[ye&&e.jsx("col",{style:{width:40}}),me.map(i=>e.jsx("col",{style:{width:L[i.key]??150}},i.key))]}),e.jsx("thead",{style:m?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:at()}),e.jsx("tbody",{children:et.map((i,g)=>{const C=a(i),_=tt(u==null?void 0:u(i)),q=g>0?tt(u==null?void 0:u(et[g-1])):null,ae=_&&_.key!==(q==null?void 0:q.key),ce=ye&&b.has(C),Le=!!p,re=ce&&y?"color-mix(in srgb, var(--primary) 8%, var(--bg-card))":g%2===1?"color-mix(in srgb, var(--bg-input) 50%, var(--bg-card))":"var(--bg-card)";return e.jsxs(o.Fragment,{children:[ae&&e.jsx("tr",{className:_.className??"",children:e.jsx("td",{colSpan:wn,className:I?"px-2 py-2":"px-3 py-3",style:{background:"color-mix(in srgb, var(--primary) 8%, var(--bg-input))",borderBottom:"1px solid var(--border)",borderRight:"1px solid var(--border)"},children:e.jsx("div",{className:"flex min-w-0 items-center justify-between gap-3",children:e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate text-xs font-semibold uppercase tracking-wider text-[var(--text-main)]",children:_.label}),_.description&&e.jsx("div",{className:"mt-0.5 truncate text-xs text-[var(--text-muted)]",children:_.description})]})})})}),e.jsxs("tr",{onClick:Le?()=>p(i):void 0,className:`transition-colors ${Le?"cursor-pointer":""} ${x?x(i):""}`,style:{"--dt-row-bg":re,"--dt-sticky-bg":re,background:"var(--dt-row-bg)"},onMouseEnter:pe=>{ce||(pe.currentTarget.style.setProperty("--dt-row-bg","var(--bg-hover)"),pe.currentTarget.style.setProperty("--dt-sticky-bg",yn))},onMouseLeave:pe=>{pe.currentTarget.style.setProperty("--dt-row-bg",re),pe.currentTarget.style.setProperty("--dt-sticky-bg",re)},children:[ye&&e.jsx("td",{className:`${I?"px-2 py-1.5":"px-3 py-2"} w-10`,style:M?{position:"sticky",left:0,zIndex:3,background:"var(--dt-sticky-bg)",boxShadow:"inset 0 -1px 0 var(--border)"}:{borderBottom:"1px solid var(--border)",borderRight:"1px solid var(--border)"},onClick:pe=>{pe.stopPropagation(),S(C)},children:e.jsx("input",{type:"checkbox",checked:ce,onClick:pe=>pe.stopPropagation(),onChange:()=>S(C),className:"rounded cursor-pointer accent-[var(--primary)]"})}),me.map((pe,Re)=>{const er=M&&!Ae&&Re===0;return e.jsx("td",{className:`${I?"px-2 py-1.5":"px-3 py-2"} ${Xt} ${rt(pe.align)} ${pe.className??""}`,style:{overflow:"hidden",whiteSpace:"nowrap",...er?{position:"sticky",left:ur,zIndex:3,background:"var(--dt-sticky-bg)",boxShadow:"3px 0 6px -2px rgba(0,0,0,0.12), inset 0 -1px 0 var(--border)",borderRight:"1px solid var(--border)"}:{borderBottom:"1px solid var(--border)",borderRight:"1px solid var(--border)"}},children:e.jsx(Lr,{children:pe.cell(i)})},pe.key)})]})]},C)})})]})})}),ot()]})}function je(r){return r?new Date(`${r}T12:00:00`):void 0}function Tr(r){return r.toISOString().slice(0,10)}function Zt({calendarMonth:r,displayIndex:t}){const{previousMonth:a,nextMonth:n,goToMonth:s,months:c,labels:d,formatters:l}=vr.useDayPicker(),p=!!a&&t===0,b=!!n&&t===c.length-1;return e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",gap:8,width:"100%",color:"var(--text-main)",marginBottom:6},children:[e.jsx("span",{style:{fontWeight:700},children:l.formatCaption(r.date)}),e.jsx("button",{type:"button","aria-label":d.labelPrevious(a),onClick:()=>a&&s(a),disabled:!p,style:{height:28,width:28,borderRadius:8,border:"1px solid var(--border)",background:"var(--bg-card)",display:"inline-flex",alignItems:"center",justifyContent:"center",color:"var(--text-main)",opacity:p?1:.45,cursor:p?"pointer":"not-allowed"},children:e.jsx(w.HiChevronLeft,{size:16})}),e.jsx("button",{type:"button","aria-label":d.labelNext(n),onClick:()=>n&&s(n),disabled:!b,style:{height:28,width:28,borderRadius:8,border:"1px solid var(--border)",background:"var(--bg-card)",display:"inline-flex",alignItems:"center",justifyContent:"center",color:"var(--text-main)",opacity:b?1:.45,cursor:b?"pointer":"not-allowed"},children:e.jsx(w.HiChevronRight,{size:16})})]})}function Jt(r){return r.charAt(0).toUpperCase()+r.slice(1)}function Qt({startDate:r,endDate:t,onChange:a,minDate:n,viewMonth:s,numberOfMonths:c=1,showSummary:d=!0,startLabel:l="Inicio",endLabel:p="Regreso"}){const b={from:je(r),to:je(t)},S=je(n),[k,y]=o.useState(je(s||r));return o.useEffect(()=>{y(je(s||r))},[s,r]),e.jsxs("div",{children:[e.jsx("div",{style:{borderRadius:10,overflow:"hidden",border:"1px solid var(--border)",background:"var(--bg-input)",display:"flex",justifyContent:"center",padding:"10px 8px"},children:e.jsx(vr.DayPicker,{mode:"range",selected:b,month:k,onMonthChange:y,onSelect:x=>{const u=x!=null&&x.from?Tr(x.from):r,m=x!=null&&x.to?Tr(x.to):"";a({startDate:u,endDate:m})},numberOfMonths:c,hideNavigation:!0,disabled:S?{before:S}:void 0,showOutsideDays:!1,components:{MonthCaption:Zt},className:"text-sm",classNames:{root:"w-full",months:"flex gap-3 justify-center",month:"space-y-2",month_caption:"flex items-center justify-between px-1",caption_label:"capitalize",nav:"flex items-center gap-1",button_previous:"h-8 w-8 inline-flex items-center justify-center rounded-md transition-colors",button_next:"h-8 w-8 inline-flex items-center justify-center rounded-md transition-colors",month_grid:"w-full border-collapse",weekdays:"grid grid-cols-7 gap-1 mb-1",weekday:"text-[11px] font-semibold text-center",week:"grid grid-cols-7 gap-1",day:"h-9 w-9 p-0 flex items-center justify-center",day_button:"h-9 w-9 rounded-md text-sm font-medium transition-colors outline-none",selected:"font-semibold",range_start:"font-semibold",range_middle:"font-medium",range_end:"font-semibold",today:"font-bold",disabled:"opacity-40 cursor-not-allowed",hidden:"invisible"},styles:{month_caption:{color:"var(--text-main)",marginBottom:6,display:"flex",alignItems:"center",justifyContent:"space-between"},caption_label:{color:"var(--text-main)",fontWeight:700},nav:{position:"static",display:"flex",alignItems:"center",gap:6},weekday:{color:"var(--text-muted)",textTransform:"lowercase"},button_previous:{height:32,width:32,background:"var(--bg-card)",color:"var(--text-main)",border:"1px solid var(--border)"},button_next:{height:32,width:32,background:"var(--bg-card)",color:"var(--text-main)",border:"1px solid var(--border)"},day_button:{color:"var(--text-main)",borderRadius:8},chevron:{fill:"var(--text-main)"},today:{border:"1px solid color-mix(in srgb, var(--primary) 35%, transparent)"},disabled:{color:"var(--text-muted)"}},modifiersStyles:{selected:{background:"var(--primary)",color:"var(--primary-fg, #ffffff)"},range_start:{background:"var(--primary)",color:"var(--primary-fg, #ffffff)"},range_end:{background:"var(--primary)",color:"var(--primary-fg, #ffffff)"},range_middle:{background:"color-mix(in srgb, var(--primary) 20%, transparent)",color:"var(--text-main)"}},formatters:{formatCaption:x=>Jt(new Intl.DateTimeFormat("es-MX",{month:"long",year:"numeric"}).format(x)),formatWeekdayName:x=>new Intl.DateTimeFormat("es-MX",{weekday:"short"}).format(x)},labels:{labelMonthDropdown:()=>"Mes",labelYearDropdown:()=>"Año"}})}),d&&r&&e.jsxs("div",{style:{marginTop:8,fontSize:12,color:"var(--text-muted)",display:"flex",gap:8,flexWrap:"wrap"},children:[e.jsxs("span",{children:[l,":"," ",e.jsx("strong",{style:{color:"var(--text-main)"},children:r})]}),t&&e.jsxs("span",{children:[p,":"," ",e.jsx("strong",{style:{color:"var(--text-main)"},children:t})]})]})]})}function Rt(r){if(r!==void 0)return typeof r=="number"?`${r}px`:r}function ea({trigger:r,items:t,align:a="end",width:n=220,disabled:s=!1,className:c="",menuClassName:d="",onOpenChange:l}){const[p,b]=o.useState(!1),[S,k]=o.useState(!1),[y,x]=o.useState({}),u=o.useRef(null),m=o.useRef(null),h=o.useCallback(N=>{b(N),l==null||l(N)},[l]),E=o.useCallback(()=>{const N=u.current;if(!N)return;const $=N.getBoundingClientRect(),B=typeof n=="number"?n:$.width,P=typeof n=="number"?n:Math.max($.width,180),D=a==="end"?Math.max(8,$.right-P):Math.min($.left,window.innerWidth-P-8),M=window.innerHeight-$.bottom,j=M<240&&$.top>M?void 0:$.bottom+6,I=j===void 0?window.innerHeight-$.top+6:void 0;x({position:"fixed",zIndex:9999,left:D,top:j,bottom:I,width:Rt(typeof n=="number"?B:n)})},[a,n]);o.useEffect(()=>k(!0),[]),o.useEffect(()=>{if(!p)return;E();const N=B=>{var D,M;const P=B.target;!((D=u.current)!=null&&D.contains(P))&&!((M=m.current)!=null&&M.contains(P))&&h(!1)},$=B=>{B.key==="Escape"&&h(!1)};return document.addEventListener("mousedown",N),window.addEventListener("keydown",$),window.addEventListener("resize",E),window.addEventListener("scroll",E,!0),()=>{document.removeEventListener("mousedown",N),window.removeEventListener("keydown",$),window.removeEventListener("resize",E),window.removeEventListener("scroll",E,!0)}},[p,h,E]);const F=N=>{s||(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),h(!p))},z=o.isValidElement(r)?o.cloneElement(r,{onClick:()=>!s&&h(!p)}):r,T=p?e.jsx("div",{ref:m,role:"menu",className:`overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-1 shadow-xl ${d}`,style:y,children:t.map(N=>e.jsxs("div",{children:[N.separatorBefore&&e.jsx("div",{className:"my-1 border-t border-[var(--border)]"}),e.jsxs("button",{type:"button",role:"menuitem",disabled:N.disabled,onClick:()=>{var $;N.disabled||(($=N.onSelect)==null||$.call(N),h(!1))},className:"flex w-full min-w-0 items-start gap-2 rounded-md px-2.5 py-1.5 text-left transition-colors hover:bg-[var(--bg-input)] disabled:cursor-not-allowed disabled:opacity-50",style:{color:N.danger?"var(--danger)":"var(--text-main)"},children:[N.icon&&e.jsx("span",{className:"mt-0.5 shrink-0",children:N.icon}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block truncate text-sm font-medium",children:N.label}),N.description&&e.jsx("span",{className:"block truncate text-xs text-[var(--text-muted)]",children:N.description})]})]})]},N.id))}):null;return e.jsxs("span",{ref:u,role:"button",tabIndex:s?-1:0,"aria-haspopup":"menu","aria-expanded":p,onKeyDown:F,className:`inline-flex ${s?"pointer-events-none opacity-60":""} ${c}`,children:[z,S&&T?Ee.createPortal(T,document.body):null]})}const ra=180;function ta({open:r,onClose:t,title:a,subtitle:n,leadingIcon:s,confirmLabel:c="Guardar",onConfirm:d,loading:l=!1,confirmDisabled:p=!1,headerActions:b,bodyClassName:S="flex-1 overflow-y-auto px-6 py-5",width:k=440,hasUnsavedChanges:y=!1,unsavedChangesTitle:x="Descartar cambios",unsavedChangesDescription:u="Hay cambios sin guardar. Si cierras el drawer se perderán.",unsavedChangesConfirmLabel:m="Descartar",unsavedChangesCancelLabel:h="Seguir editando",onDiscardChanges:E,children:F}){const[z,T]=o.useState(!1),[N,$]=o.useState(!1),[B,P]=o.useState(!1),D=o.useCallback(()=>{$(!0),requestAnimationFrame(()=>{requestAnimationFrame(()=>P(!0))})},[]),M=o.useCallback(()=>{P(!1),window.setTimeout(()=>$(!1),ra)},[]),j=o.useCallback(()=>{if(y){D();return}t()},[y,t,D]),I=o.useCallback(()=>{P(!1),$(!1),E==null||E(),t()},[t,E]);return o.useEffect(()=>{T(!0)},[]),o.useEffect(()=>(document.body.style.overflow=r?"hidden":"",r||(P(!1),$(!1)),()=>{document.body.style.overflow=""}),[r]),o.useEffect(()=>{if(!r)return;const W=U=>{if(U.key==="Escape"){if(N){M();return}j()}};return window.addEventListener("keydown",W),()=>window.removeEventListener("keydown",W)},[M,N,r,j]),z?Ee.createPortal(e.jsxs("div",{"aria-hidden":!r,className:`fixed inset-0 z-[1000] flex transition-opacity duration-300 ${r?"opacity-100":"opacity-0 pointer-events-none"}`,children:[e.jsx("div",{className:"absolute inset-0 bg-black/40 backdrop-blur-sm",onClick:j}),e.jsxs("div",{className:`absolute inset-y-0 right-0 flex flex-col shadow-2xl transition-transform duration-300 ${r?"translate-x-0":"translate-x-full"}`,style:{width:`min(100vw, ${k}px)`,background:"var(--bg-card)",borderLeft:"1px solid var(--border)"},children:[e.jsxs("div",{className:"flex items-center justify-between px-6 py-4 flex-shrink-0",style:{borderBottom:"1px solid var(--border)"},children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx(ie,{variant:"icon",onClick:j,title:"Cerrar",children:e.jsx(w.HiXMark,{className:"w-5 h-5"})}),s&&e.jsx("div",{className:"flex-shrink-0",children:s}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h3",{className:"text-base font-semibold truncate",style:{color:"var(--text-main)"},children:a}),n&&e.jsx("p",{className:"text-xs truncate",style:{color:"var(--text-muted)"},children:n})]})]}),(b||d)&&e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[b,d&&e.jsxs(e.Fragment,{children:[e.jsx(ie,{variant:"secondary",size:"sm",onClick:j,style:{background:"var(--bg-input)"},children:"Cancelar"}),e.jsx(ie,{variant:"primary",size:"sm",icon:e.jsx(dt.FiSave,{className:"w-4 h-4"}),onClick:d,loading:l,disabled:p,title:c})]})]})]}),e.jsx("div",{"data-drawer-scroll":"true",className:S,children:F})]}),N&&e.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":x,className:"fixed inset-0 z-[1001] flex items-center justify-center p-4",children:[e.jsx("div",{className:`absolute inset-0 bg-black/50 backdrop-blur-sm transition-opacity duration-200 ease-out ${B?"opacity-100":"opacity-0"}`,onClick:M}),e.jsxs("div",{className:`relative z-10 w-full max-w-sm rounded-2xl border p-6 shadow-2xl transition-[opacity,transform] duration-200 ease-out ${B?"translate-y-0 scale-100 opacity-100":"translate-y-2 scale-[0.96] opacity-0"}`,style:{background:"var(--bg-card, #ffffff)",borderColor:"var(--border, #d8e1dc)"},children:[e.jsx(ie,{variant:"icon",onClick:M,className:"absolute right-3 top-3 h-7 w-7 hover:opacity-70",style:{color:"var(--text-muted, #6b7f78)"},"aria-label":h,children:e.jsx(w.HiXMark,{className:"h-4 w-4"})}),e.jsx("div",{className:"mb-4 flex h-11 w-11 items-center justify-center rounded-xl",style:{background:"var(--warning-bg, #fff7ed)"},children:e.jsx(w.HiExclamationTriangle,{className:"h-5 w-5",style:{color:"var(--warning, #d97706)"}})}),e.jsx("h2",{className:"mb-1 text-base font-semibold",style:{color:"var(--text-main, #0f2f2c)"},children:x}),e.jsx("p",{className:"text-sm",style:{color:"var(--text-muted, #6b7f78)"},children:u}),e.jsxs("div",{className:"mt-6 flex gap-2",children:[e.jsx(ie,{variant:"secondary",onClick:M,className:"flex-1 border",style:{background:"var(--bg-input, #f7faf8)",borderColor:"var(--border, #d8e1dc)",color:"var(--text-main, #0f2f2c)"},children:h}),e.jsx(ie,{variant:"secondary",onClick:I,className:"flex-1 border",style:{background:"var(--warning, #d97706)",borderColor:"transparent",color:"#fff",boxShadow:"0 10px 22px rgba(217, 119, 6, 0.22)"},children:m})]})]})]})]}),document.body):null}const aa={sm:"min-h-[160px] p-4",md:"min-h-[220px] p-6",lg:"min-h-[300px] p-8"};function na({title:r="Sin resultados",description:t,icon:a=e.jsx(w.HiInbox,{className:"h-5 w-5"}),action:n,secondaryAction:s,size:c="md",className:d=""}){return e.jsx("div",{className:`flex items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-card)] text-center ${aa[c]} ${d}`,children:e.jsxs("div",{className:"flex max-w-sm flex-col items-center gap-3",children:[a&&e.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-input)] text-[var(--text-muted)]",children:a}),e.jsxs("div",{className:"space-y-1",children:[r&&e.jsx("h3",{className:"text-sm font-semibold text-[var(--text-main)]",children:r}),t&&e.jsx("div",{className:"text-sm leading-5 text-[var(--text-muted)]",children:t})]}),(n||s)&&e.jsxs("div",{className:"mt-1 flex flex-wrap items-center justify-center gap-2",children:[s,n]})]})})}function Br({label:r,children:t,helperText:a,error:n,labelAction:s,required:c=!1,className:d="",contentClassName:l=""}){return e.jsxs("label",{className:`flex flex-col gap-2 ${d}`,children:[(r||s)&&e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-semibold uppercase text-[var(--text-muted)]",children:[r&&e.jsx("span",{children:r}),c&&e.jsx("span",{className:"text-[var(--danger)]",children:"*"}),s&&e.jsx("span",{className:"ml-auto normal-case",children:s})]}),e.jsx("span",{className:`block ${l}`,children:t}),n?e.jsx("span",{className:"text-xs font-medium normal-case text-[var(--danger)]",children:n}):a?e.jsx("span",{className:"text-xs font-medium normal-case text-[var(--text-muted)]",children:a}):null]})}var Ar={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},Or=o.createContext&&o.createContext(Ar),oa=["attr","size","title"];function sa(r,t){if(r==null)return{};var a,n,s=la(r,t);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(r);for(n=0;n<c.length;n++)a=c[n],t.indexOf(a)===-1&&{}.propertyIsEnumerable.call(r,a)&&(s[a]=r[a])}return s}function la(r,t){if(r==null)return{};var a={};for(var n in r)if({}.hasOwnProperty.call(r,n)){if(t.indexOf(n)!==-1)continue;a[n]=r[n]}return a}function Xe(){return Xe=Object.assign?Object.assign.bind():function(r){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var n in a)({}).hasOwnProperty.call(a,n)&&(r[n]=a[n])}return r},Xe.apply(null,arguments)}function Ir(r,t){var a=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);t&&(n=n.filter(function(s){return Object.getOwnPropertyDescriptor(r,s).enumerable})),a.push.apply(a,n)}return a}function Ye(r){for(var t=1;t<arguments.length;t++){var a=arguments[t]!=null?arguments[t]:{};t%2?Ir(Object(a),!0).forEach(function(n){ia(r,n,a[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(a)):Ir(Object(a)).forEach(function(n){Object.defineProperty(r,n,Object.getOwnPropertyDescriptor(a,n))})}return r}function ia(r,t,a){return(t=ca(t))in r?Object.defineProperty(r,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):r[t]=a,r}function ca(r){var t=da(r,"string");return typeof t=="symbol"?t:t+""}function da(r,t){if(typeof r!="object"||!r)return r;var a=r[Symbol.toPrimitive];if(a!==void 0){var n=a.call(r,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(r)}function zr(r){return r&&r.map((t,a)=>o.createElement(t.tag,Ye({key:a},t.attr),zr(t.child)))}function Pr(r){return t=>o.createElement(ua,Xe({attr:Ye({},r.attr)},t),zr(r.child))}function ua(r){var t=a=>{var{attr:n,size:s,title:c}=r,d=sa(r,oa),l=s||a.size||"1em",p;return a.className&&(p=a.className),r.className&&(p=(p?p+" ":"")+r.className),o.createElement("svg",Xe({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},a.attr,n,d,{className:p,style:Ye(Ye({color:r.color||a.color},a.style),r.style),height:l,width:l,xmlns:"http://www.w3.org/2000/svg"}),c&&o.createElement("title",null,c),r.children)};return Or!==void 0?o.createElement(Or.Consumer,null,a=>t(a)):t(Ar)}function fa(r){return Pr({attr:{viewBox:"0 0 256 256",fill:"currentColor"},child:[{tag:"path",attr:{d:"M247.31,124.76c-.35-.79-8.82-19.58-27.65-38.41C194.57,61.26,162.88,48,128,48S61.43,61.26,36.34,86.35C17.51,105.18,9,124,8.69,124.76a8,8,0,0,0,0,6.5c.35.79,8.82,19.57,27.65,38.4C61.43,194.74,93.12,208,128,208s66.57-13.26,91.66-38.34c18.83-18.83,27.3-37.61,27.65-38.4A8,8,0,0,0,247.31,124.76ZM128,192c-30.78,0-57.67-11.19-79.93-33.25A133.47,133.47,0,0,1,25,128,133.33,133.33,0,0,1,48.07,97.25C70.33,75.19,97.22,64,128,64s57.67,11.19,79.93,33.25A133.46,133.46,0,0,1,231.05,128C223.84,141.46,192.43,192,128,192Zm0-112a48,48,0,1,0,48,48A48.05,48.05,0,0,0,128,80Zm0,80a32,32,0,1,1,32-32A32,32,0,0,1,128,160Z"},child:[]}]})(r)}function pa(r){return Pr({attr:{viewBox:"0 0 256 256",fill:"currentColor"},child:[{tag:"path",attr:{d:"M228,175a8,8,0,0,1-10.92-3l-19-33.2A123.23,123.23,0,0,1,162,155.46l5.87,35.22a8,8,0,0,1-6.58,9.21A8.4,8.4,0,0,1,160,200a8,8,0,0,1-7.88-6.69l-5.77-34.58a133.06,133.06,0,0,1-36.68,0l-5.77,34.58A8,8,0,0,1,96,200a8.4,8.4,0,0,1-1.32-.11,8,8,0,0,1-6.58-9.21L94,155.46a123.23,123.23,0,0,1-36.06-16.69L39,172A8,8,0,1,1,25.06,164l20-35a153.47,153.47,0,0,1-19.3-20A8,8,0,1,1,38.22,99c16.6,20.54,45.64,45,89.78,45s73.18-24.49,89.78-45A8,8,0,1,1,230.22,109a153.47,153.47,0,0,1-19.3,20l20,35A8,8,0,0,1,228,175Z"},child:[]}]})(r)}function Ve({className:r="",...t}){return e.jsx("input",{...t,className:`h-10 rounded-lg border border-[var(--border)] bg-[var(--bg-input)] px-2.5 py-1.5 text-sm text-[var(--text-main)] outline-none placeholder:text-[var(--text-muted)] transition-colors focus:border-[var(--primary)] ${r}`})}function ba({label:r,containerClassName:t="",helperText:a,error:n,labelAction:s,floatingLabel:c=!1,showPasswordToggle:d=!0,className:l="",required:p,...b}){const[S,k]=o.useState(()=>!!b.autoFocus),[y,x]=o.useState(!1),u=b.type==="password"&&d,m=u&&y?"text":b.type,h=b.value!==void 0?String(b.value).length>0:b.defaultValue!==void 0&&String(b.defaultValue).length>0,E=S||h,F={top:E?7:12,color:S?"var(--primary)":"var(--text-muted)",fontSize:E?10:13,fontWeight:E?600:400,textTransform:E?"uppercase":"none"},z=$=>{var B;k(!0),(B=b.onFocus)==null||B.call(b,$)},T=$=>{var B;k(!1),(B=b.onBlur)==null||B.call(b,$)},N=u?e.jsxs("button",{type:"button","aria-label":y?"Ocultar contraseña":"Mostrar contraseña","aria-pressed":y,className:"absolute right-2.5 top-1/2 flex h-7 w-7 -translate-y-1/2 items-center justify-center rounded-md text-[var(--text-muted)] transition-colors duration-200 hover:text-[var(--primary)] focus:outline-none",tabIndex:-1,onClick:()=>x($=>!$),children:[e.jsx("span",{"aria-hidden":"true",className:`absolute inset-0 flex items-center justify-center transition-[opacity,transform] duration-200 ease-out ${y?"scale-y-0 rotate-[-8deg] opacity-0":"scale-y-100 rotate-0 opacity-100"}`,children:e.jsx(fa,{className:"h-[18px] w-[18px]"})}),e.jsx("span",{"aria-hidden":"true",className:`absolute inset-0 flex items-center justify-center transition-[opacity,transform] duration-200 ease-out ${y?"scale-y-100 rotate-0 opacity-100":"scale-y-0 rotate-[8deg] opacity-0"}`,children:e.jsx(pa,{className:"h-[18px] w-[18px]"})})]}):null;return c?e.jsxs("label",{className:`flex flex-col gap-2 ${t}`,children:[e.jsxs("span",{className:"relative block",children:[e.jsx(Ve,{...b,type:m,required:p,placeholder:" ","aria-invalid":!!n||b["aria-invalid"],"data-has-value":h?"true":void 0,className:`h-11 w-full pt-5 ${u?"pr-10":""} ${l}`,onFocus:z,onBlur:T}),e.jsxs("span",{className:"pointer-events-none absolute left-3 transition-all duration-150",style:F,children:[r,p&&e.jsx("span",{className:"ml-1 text-[var(--danger)]",children:"*"})]}),s&&e.jsx("span",{className:"absolute right-2 transition-all duration-150",style:{top:E?7:12},children:s}),N]}),n?e.jsx("span",{className:"text-xs font-medium normal-case text-[var(--danger)]",children:n}):a?e.jsx("span",{className:"text-xs font-medium normal-case text-[var(--text-muted)]",children:a}):null]}):e.jsxs("label",{className:`flex flex-col gap-2 ${t}`,children:[e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-semibold uppercase text-[var(--text-muted)]",children:[e.jsx("span",{children:r}),p&&e.jsx("span",{className:"text-[var(--danger)]",children:"*"}),s&&e.jsx("span",{className:"ml-auto normal-case",children:s})]}),u?e.jsxs("span",{className:"relative block",children:[e.jsx(Ve,{...b,type:m,required:p,"aria-invalid":!!n||b["aria-invalid"],className:`w-full pr-10 ${l}`,onFocus:z,onBlur:T}),N]}):e.jsx(Ve,{...b,required:p,"aria-invalid":!!n||b["aria-invalid"],className:l}),n?e.jsx("span",{className:"text-xs font-medium normal-case text-[var(--danger)]",children:n}):a?e.jsx("span",{className:"text-xs font-medium normal-case text-[var(--text-muted)]",children:a}):null]})}function jr(r){if(r!==void 0)return typeof r=="number"?`${r}px`:r}function ha(r,t){return r.length!==t.length?!1:r.every((a,n)=>a===t[n])}function ma({value:r,onChange:t,options:a,placeholder:n="Seleccionar…",disabled:s=!1,className:c="",style:d,height:l=40,padding:p="0 10px",searchable:b=!0,minOptionsForSearch:S=6,maxVisibleValues:k=2,emptyText:y="Sin resultados",clearLabel:x="Limpiar seleccion"}){const[u,m]=o.useState(!1),[h,E]=o.useState(""),[F,z]=o.useState(0),[T,N]=o.useState(!1),[$,B]=o.useState({}),P=o.useRef(null),D=o.useRef(null),M=o.useRef(null),j=o.useRef(null),I=b&&a.length>=S,W=o.useMemo(()=>new Set(r),[r]),U=o.useMemo(()=>a.filter(v=>W.has(v.value)),[a,W]),J=U.slice(0,k),te=Math.max(0,U.length-J.length),f=I&&h.trim()?a.filter(v=>{var Y;return v.label.toLowerCase().includes(h.toLowerCase())||((Y=v.sublabel)==null?void 0:Y.toLowerCase().includes(h.toLowerCase()))}):a,H=o.useCallback(()=>{const v=P.current;if(!v)return;const Y=v.getBoundingClientRect(),be=I?304:244,ee=window.innerHeight-Y.bottom,Q=ee<be&&Y.top>ee;B({position:"fixed",left:Y.left,top:Q?void 0:Y.bottom+4,bottom:Q?window.innerHeight-Y.top+4:void 0,width:Y.width,zIndex:9999})},[I]),G=o.useCallback(v=>{ha(r,v)||t(v)},[t,r]),K=o.useCallback(v=>{const Y=a.find(ee=>ee.value===v);if(Y!=null&&Y.disabled)return;const be=W.has(v)?r.filter(ee=>ee!==v):[...r,v];G(be)},[G,a,r,W]),Z=o.useCallback(()=>G([]),[G]);o.useEffect(()=>N(!0),[]),o.useEffect(()=>{if(!u)return;function v(Y){var ee,Q;const be=Y.target;!((ee=P.current)!=null&&ee.contains(be))&&!((Q=D.current)!=null&&Q.contains(be))&&(m(!1),E(""))}return document.addEventListener("mousedown",v),()=>document.removeEventListener("mousedown",v)},[u]),o.useEffect(()=>{u&&(z(0),H(),I&&setTimeout(()=>{var v;return(v=M.current)==null?void 0:v.focus()},0))},[u,I,H]),o.useEffect(()=>{if(u)return window.addEventListener("resize",H),window.addEventListener("scroll",H,!0),()=>{window.removeEventListener("resize",H),window.removeEventListener("scroll",H,!0)}},[u,H]),o.useEffect(()=>{if(F<0||!j.current)return;const v=j.current.children[F];v==null||v.scrollIntoView({block:"nearest"})},[F]);function ne(v){if(!u){(v.key==="Enter"||v.key===" "||v.key==="ArrowDown")&&(v.preventDefault(),m(!0));return}v.key==="Escape"&&(v.preventDefault(),m(!1),E("")),v.key==="ArrowDown"&&(v.preventDefault(),z(Y=>Math.min(Y+1,f.length-1))),v.key==="ArrowUp"&&(v.preventDefault(),z(Y=>Math.max(Y-1,0))),v.key==="Enter"&&f[F]&&(v.preventDefault(),K(f[F].value)),v.key==="Backspace"&&!h&&r.length&&(v.preventDefault(),G(r.slice(0,-1)))}const de=e.jsxs("div",{ref:D,className:"overflow-hidden rounded-xl shadow-xl",style:{...$,background:"var(--bg-card)",border:"1px solid var(--border)"},children:[I&&e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",style:{borderBottom:"1px solid var(--border)"},children:[e.jsx(w.HiMagnifyingGlass,{className:"h-3.5 w-3.5 flex-shrink-0",style:{color:"var(--text-muted)"}}),e.jsx("input",{ref:M,value:h,onChange:v=>{E(v.target.value),z(0)},placeholder:"Buscar…",className:"min-w-0 flex-1 bg-transparent text-sm outline-none",style:{color:"var(--text-main)"}}),h&&e.jsx("button",{type:"button",onMouseDown:v=>{v.preventDefault(),E("")},children:e.jsx(w.HiXMark,{className:"h-3.5 w-3.5",style:{color:"var(--text-muted)"}})})]}),U.length>0&&e.jsxs("div",{className:"flex items-center justify-between gap-3 px-3 py-2 text-xs",style:{borderBottom:"1px solid var(--border)",color:"var(--text-muted)"},children:[e.jsxs("span",{children:[U.length," seleccionados"]}),e.jsx("button",{type:"button",onMouseDown:v=>{v.preventDefault(),Z()},className:"font-semibold transition-colors hover:text-[var(--primary)]",children:x})]}),e.jsxs("ul",{ref:j,role:"listbox","aria-multiselectable":"true",className:"overflow-y-auto",style:{maxHeight:I?220:200,scrollbarWidth:"thin",scrollbarColor:"var(--border) transparent",overscrollBehavior:"contain"},children:[f.map((v,Y)=>{const be=Y===F,ee=W.has(v.value);return e.jsxs("li",{role:"option","aria-selected":ee,onMouseDown:Q=>{Q.preventDefault(),K(v.value)},onMouseEnter:()=>!v.disabled&&z(Y),className:"flex cursor-pointer items-center gap-2 px-3 py-2 text-sm transition-colors",style:{background:be?"var(--bg-hover)":ee?"color-mix(in srgb, var(--primary) 6%, transparent)":"transparent",color:v.disabled?"var(--text-muted)":"var(--text-main)",cursor:v.disabled?"not-allowed":"pointer",opacity:v.disabled?.58:1},children:[e.jsx("span",{className:"flex h-4 w-4 flex-shrink-0 items-center justify-center rounded border",style:{borderColor:ee?"var(--primary)":"var(--border)",background:ee?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:ee&&e.jsx(w.HiCheck,{className:"h-3 w-3"})}),v.color&&e.jsx("span",{className:"h-2.5 w-2.5 flex-shrink-0 rounded-full",style:{background:v.color}}),e.jsxs("span",{className:"flex min-w-0 flex-1 items-baseline gap-1 overflow-hidden",children:[e.jsx("span",{className:"truncate",children:v.label}),v.sublabel&&e.jsx("span",{className:"min-w-0 flex-shrink truncate",style:{color:"var(--text-muted)",fontSize:12},children:v.sublabel})]}),v.badge&&e.jsx("span",{className:"flex-shrink-0 text-xs",style:{color:"var(--text-muted)"},children:v.badge})]},v.value)}),f.length===0&&e.jsx("li",{className:"px-3 py-4 text-center text-sm",style:{color:"var(--text-muted)"},children:y})]})]});return e.jsxs("div",{ref:P,className:`relative ${c||"w-full"}`,style:d,onKeyDown:ne,children:[e.jsxs("button",{type:"button",disabled:s,onClick:()=>!s&&m(v=>!v),className:"flex w-full items-center gap-2 rounded-lg text-left text-sm transition-colors focus:outline-none",style:{minHeight:jr(l),padding:jr(p),background:"var(--bg-input)",color:U.length?"var(--text-main)":"var(--text-muted)",border:u?"1px solid var(--primary)":"1px solid var(--border)",opacity:s?.5:1,cursor:s?"not-allowed":"pointer"},"aria-haspopup":"listbox","aria-expanded":u,children:[e.jsx("span",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-1.5 overflow-hidden",children:J.length?e.jsxs(e.Fragment,{children:[J.map(v=>e.jsxs("span",{className:"inline-flex max-w-[160px] items-center gap-1 rounded-md border px-1.5 py-0.5 text-xs font-semibold",style:{background:"var(--bg-card)",borderColor:"var(--border)",color:"var(--text-main)"},children:[v.color&&e.jsx("span",{className:"h-1.5 w-1.5 flex-shrink-0 rounded-full",style:{background:v.color}}),e.jsx("span",{className:"truncate",children:v.label})]},v.value)),te>0&&e.jsxs("span",{className:"inline-flex items-center rounded-md px-1.5 py-0.5 text-xs font-semibold",style:{background:"color-mix(in srgb, var(--primary) 10%, transparent)",color:"var(--primary)"},children:["+",te]})]}):e.jsx("span",{className:"truncate",children:n})}),U.length?e.jsx("span",{role:"button",tabIndex:-1,"aria-label":x,onMouseDown:v=>{v.preventDefault(),v.stopPropagation(),Z()},className:"flex-shrink-0 rounded-full p-0.5 transition-colors hover:bg-black/10",style:{color:"var(--text-muted)"},children:e.jsx(w.HiXMark,{className:"h-3 w-3"})}):e.jsx(w.HiChevronDown,{className:"h-4 w-4 flex-shrink-0 transition-transform",style:{color:"var(--text-muted)",transform:u?"rotate(180deg)":"rotate(0deg)"}})]}),u&&T&&Ee.createPortal(de,document.body)]})}function va(r,t,a){const n=[],s=Math.max(2,r-a),c=Math.min(t-1,r+a);n.push(1),s>2&&n.push("...");for(let d=s;d<=c;d+=1)n.push(d);return c<t-1&&n.push("..."),t>1&&n.push(t),n}function xa({page:r,totalPages:t,onPageChange:a,disabled:n=!1,siblingCount:s=1,className:c=""}){const d=Math.max(1,t),l=Math.min(Math.max(1,r),d),p=va(l,d,s);return e.jsxs("nav",{"aria-label":"Paginacion",className:`inline-flex items-center gap-1 ${c}`,children:[e.jsx(ie,{variant:"icon",size:"xs","aria-label":"Pagina anterior",disabled:n||l<=1,onClick:()=>a(l-1),children:e.jsx(w.HiChevronLeft,{className:"h-4 w-4"})}),p.map((b,S)=>b==="..."?e.jsx("span",{className:"flex h-8 min-w-8 items-center justify-center text-xs font-semibold text-[var(--text-muted)]",children:"..."},`ellipsis-${S}`):e.jsx("button",{type:"button","aria-current":b===l?"page":void 0,disabled:n,onClick:()=>a(b),className:"flex h-8 min-w-8 items-center justify-center rounded-md border px-2 text-xs font-semibold transition-colors disabled:cursor-not-allowed disabled:opacity-50",style:{borderColor:b===l?"var(--primary)":"var(--border)",background:b===l?"var(--primary)":"var(--bg-card)",color:b===l?"var(--primary-fg)":"var(--text-secondary)"},children:b},b)),e.jsx(ie,{variant:"icon",size:"xs","aria-label":"Pagina siguiente",disabled:n||l>=d,onClick:()=>a(l+1),children:e.jsx(w.HiChevronRight,{className:"h-4 w-4"})})]})}function ga({value:r,onChange:t,options:a,name:n,label:s,orientation:c="vertical",disabled:d=!1,className:l="",optionClassName:p=""}){return e.jsxs("fieldset",{className:`min-w-0 ${l}`,disabled:d,children:[s&&e.jsx("legend",{className:"mb-2 text-xs font-semibold uppercase text-[var(--text-muted)]",children:s}),e.jsx("div",{className:c==="horizontal"?"flex flex-wrap gap-2":"flex flex-col gap-2",children:a.map(b=>{const S=b.value===r,k=d||b.disabled;return e.jsxs("label",{className:`inline-flex min-w-0 items-start gap-2 rounded-lg border px-2.5 py-1.5 transition-colors ${k?"cursor-not-allowed opacity-60":"cursor-pointer hover:bg-[var(--bg-input)]"} ${p}`,style:{borderColor:S?"color-mix(in srgb, var(--primary) 48%, var(--border))":"var(--border)",background:S?"color-mix(in srgb, var(--primary) 8%, transparent)":"var(--bg-card)"},children:[e.jsxs("span",{className:"relative mt-0.5 inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-full border border-[var(--border)] bg-[var(--bg-input)]",children:[e.jsx("input",{type:"radio",name:n,value:b.value,checked:S,disabled:k,onChange:()=>t(b.value),className:"absolute inset-0 opacity-0"}),e.jsx("span",{className:`h-2 w-2 rounded-full transition ${S?"scale-100 opacity-100":"scale-50 opacity-0"}`,style:{background:"var(--primary)"}})]}),e.jsxs("span",{className:"min-w-0",children:[e.jsx("span",{className:"block text-sm font-medium leading-5 text-[var(--text-main)]",children:b.label}),b.description&&e.jsx("span",{className:"block text-xs leading-5 text-[var(--text-muted)]",children:b.description})]})]},b.value)})})]})}function ya({title:r,subtitle:t,icon:a,actions:n,children:s,footer:c,className:d="",bodyClassName:l="p-4"}){const p=r||t||a||n;return e.jsxs("section",{className:`overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${d}`,children:[p&&e.jsxs("header",{className:"flex items-center justify-between gap-3 border-b border-[var(--border)] px-4 py-3",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[a&&e.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-input)] text-[var(--primary)]",children:a}),e.jsxs("div",{className:"min-w-0",children:[r&&e.jsx("h3",{className:"truncate text-sm font-semibold text-[var(--text-main)]",children:r}),t&&e.jsx("div",{className:"truncate text-xs text-[var(--text-muted)]",children:t})]})]}),n&&e.jsx("div",{className:"shrink-0",children:n})]}),e.jsx("div",{className:l,children:s}),c&&e.jsx("footer",{className:"border-t border-[var(--border)] px-4 py-3",children:c})]})}const wa={neutral:{text:"var(--text-secondary)",bg:"var(--bg-input)",border:"var(--border)"},primary:{text:"var(--primary)",bg:"color-mix(in srgb, var(--primary) 10%, transparent)",border:"color-mix(in srgb, var(--primary) 24%, var(--border))"},success:{text:"#047857",bg:"rgba(16, 185, 129, 0.11)",border:"rgba(16, 185, 129, 0.24)"},warning:{text:"#b45309",bg:"rgba(245, 158, 11, 0.12)",border:"rgba(245, 158, 11, 0.26)"},danger:{text:"var(--danger)",bg:"var(--danger-bg)",border:"color-mix(in srgb, var(--danger) 20%, var(--border))"},info:{text:"#2563eb",bg:"rgba(59, 130, 246, 0.11)",border:"rgba(59, 130, 246, 0.24)"}},Na={xs:"min-h-5 px-1.5 text-[10px]",sm:"min-h-6 px-2 text-xs",md:"min-h-7 px-2.5 text-sm"};function ka({children:r,tone:t="neutral",size:a="sm",icon:n,dot:s=!1,className:c=""}){const d=wa[t];return e.jsxs("span",{className:`inline-flex max-w-full shrink-0 items-center gap-1.5 rounded-full border font-semibold leading-none ${Na[a]} ${c}`,style:{color:d.text,background:d.bg,borderColor:d.border},children:[s&&e.jsx("span",{"aria-hidden":"true",className:"h-1.5 w-1.5 shrink-0 rounded-full",style:{background:d.text}}),n&&e.jsx("span",{className:"shrink-0",children:n}),e.jsx("span",{className:"min-w-0 truncate",children:r})]})}function Sa({tabs:r,activeTabId:t,defaultActiveTabId:a,onTabChange:n,ariaLabel:s="Pestanas",variant:c="underline",className:d="",listClassName:l="",panelClassName:p=""}){const b=r.find(u=>!u.disabled)??r[0],S=t??a??(b==null?void 0:b.id),k=r.find(u=>u.id===S)??b,y=u=>{u.disabled||n==null||n(u.id)},x=u=>{const m=r.filter(E=>!E.disabled);if(!m.length||!k)return;const h=m.findIndex(E=>E.id===k.id);(u.key==="ArrowRight"||u.key==="ArrowDown")&&(u.preventDefault(),y(m[(h+1)%m.length])),(u.key==="ArrowLeft"||u.key==="ArrowUp")&&(u.preventDefault(),y(m[(h-1+m.length)%m.length])),u.key==="Home"&&(u.preventDefault(),y(m[0])),u.key==="End"&&(u.preventDefault(),y(m[m.length-1]))};return e.jsxs("div",{className:d,children:[e.jsx("div",{role:"tablist","aria-label":s,onKeyDown:x,className:`flex min-w-0 gap-1 overflow-x-auto ${c==="underline"?"border-b border-[var(--border)]":"rounded-lg border border-[var(--border)] bg-[var(--bg-input)] p-1"} ${l}`,children:r.map(u=>{const m=u.id===(k==null?void 0:k.id);return e.jsxs("button",{type:"button",role:"tab","aria-selected":m,"aria-controls":`${u.id}-panel`,id:`${u.id}-tab`,disabled:u.disabled,tabIndex:m?0:-1,onClick:()=>y(u),className:`inline-flex min-h-8 shrink-0 items-center justify-center gap-1.5 whitespace-nowrap px-2.5 text-sm font-semibold transition-colors focus:outline-none disabled:cursor-not-allowed disabled:opacity-50 ${c==="underline"?"border-b-2":"rounded-md border"}`,style:{color:m?"var(--primary)":"var(--text-muted)",borderColor:m?"var(--primary)":"transparent",background:c==="pills"&&m?"var(--bg-card)":"transparent"},children:[u.icon&&e.jsx("span",{className:"shrink-0",children:u.icon}),e.jsx("span",{children:u.label}),u.badge&&e.jsx("span",{className:"shrink-0",children:u.badge})]},u.id)})}),(k==null?void 0:k.content)!==void 0&&e.jsx("div",{role:"tabpanel",id:`${k.id}-panel`,"aria-labelledby":`${k.id}-tab`,className:`pt-4 ${p}`,children:k.content})]})}function Ne(...r){return r.filter(Boolean).join(" ")}function Ca({steps:r,activeStepId:t,initialStepId:a,completedStepIds:n,defaultCompletedStepIds:s=[],onActiveStepChange:c,onCompletedStepIdsChange:d,onBlockedStep:l,allowBackNavigation:p=!0,showFooter:b=!0,previousLabel:S="Anterior",nextLabel:k="Siguiente",blockedNextLabel:y="Completa este paso",className:x="",headerClassName:u="",contentClassName:m="",footerClassName:h=""}){var Q;const E=((Q=r[0])==null?void 0:Q.id)??"",[F,z]=o.useState(a??E),[T,N]=o.useState(s),$=t??F,B=n??T,P=o.useMemo(()=>new Set(B),[B]),D=Math.max(0,r.findIndex(O=>O.id===$)),M=r[D]??r[0],j=r.length<=1?100:D/(r.length-1)*100,I=O=>{n||N(O),d==null||d(O)},W=O=>{const V=r.find(R=>R.id===O);V&&(t||z(O),c==null||c(O,V))},U=O=>P.has(O),J=O=>r.slice(0,O).find(V=>!V.optional&&!P.has(V.id)),te=O=>{const V=r[O];return!V||V.disabled?!1:O===D||p&&O<D?!0:!J(O)},f=O=>{const V=r.findIndex(R=>R.id===O);return V>=0&&te(V)},H=O=>{const V=r.findIndex(R=>R.id===O);if(V<0)return!1;if(!te(V)){const R=J(V);return R&&(l==null||l(r[V],R)),!1}return W(O),!0},G=(O=M==null?void 0:M.id)=>{!O||P.has(O)||I([...B,O])},K=(O=M==null?void 0:M.id)=>{if(!O)return;const V=r.findIndex(se=>se.id===O),R=B.filter(se=>{const he=r.findIndex(X=>X.id===se);return he>=0&&he<V});I(R),V>=0&&D>V&&W(O)},Z=()=>D<=0?!1:H(r[D-1].id),ne=()=>{const O=r[D+1];return O?H(O.id):!1},de={activeStep:M,activeIndex:D,completedStepIds:B,isCompleted:U,isUnlocked:f,completeStep:G,uncompleteStep:K,goToStep:H,goNext:ne,goPrevious:Z};if(!M)return null;const v=r[D+1],Y=D>0,be=v?f(v.id):!1,ee=typeof M.content=="function"?M.content(de):M.content;return e.jsxs("section",{className:Ne("overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)]",x),children:[e.jsxs("div",{className:Ne("border-b border-[var(--border)] bg-[var(--bg-input)]",u),children:[e.jsx("div",{className:"relative h-1 overflow-hidden bg-[var(--border)]/55",children:e.jsx("div",{className:"h-full rounded-r-full bg-[var(--primary)] transition-[width] duration-500 ease-out",style:{width:`${j}%`}})}),e.jsx("div",{className:"grid gap-2 p-2",style:{gridTemplateColumns:`repeat(${r.length}, minmax(0, 1fr))`},children:r.map((O,V)=>{const R=O.id===M.id,se=U(O.id),he=te(V),X=J(V);return e.jsxs("button",{type:"button",disabled:!he,"aria-current":R?"step":void 0,"aria-disabled":!he,title:!he&&X?`Completa ${X.title}`:O.title,onClick:()=>H(O.id),className:Ne("group relative min-h-16 min-w-0 overflow-hidden rounded-md border p-3 text-left transition-all duration-200 focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--primary)]/35 disabled:cursor-not-allowed",R&&"border-[var(--primary)] bg-[var(--bg-card)] shadow-sm",se&&!R&&"border-[var(--primary)]/35 bg-[var(--bg-card)]",!R&&!se&&he&&"border-transparent bg-[var(--bg-card)]/45 hover:border-[var(--border)] hover:bg-[var(--bg-card)]",!he&&"border-transparent bg-[var(--bg-card)]/35 opacity-60"),children:[e.jsx("span",{className:Ne("absolute inset-x-0 top-0 h-0.5 origin-left scale-x-0 bg-[var(--primary)] transition-transform duration-300",R&&"scale-x-100")}),e.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:Ne("grid h-7 w-7 shrink-0 place-items-center rounded-full border text-xs font-bold transition-all duration-200",R&&"border-[var(--primary)] bg-[var(--primary)] text-[var(--primary-fg)]",se&&!R&&"border-[var(--primary)] bg-[var(--primary)]/12 text-[var(--primary)]",!se&&!R&&he&&"border-[var(--border)] text-[var(--text-muted)]",!he&&"border-[var(--border)] text-[var(--text-muted)]"),children:se?e.jsx(w.HiCheck,{className:"h-4 w-4"}):he?V+1:e.jsx(w.HiLockClosed,{className:"h-3.5 w-3.5"})}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsxs("span",{className:Ne("block truncate text-xs font-semibold transition-colors duration-200",R?"text-[var(--text-main)]":"text-[var(--text-secondary)]"),children:[V+1,". ",O.title]}),O.description&&e.jsx("span",{className:"mt-1 block truncate text-[11px] text-[var(--text-muted)]",children:O.description})]}),O.badge&&e.jsx("span",{className:"shrink-0",children:O.badge})]})]},O.id)})})]}),e.jsx("div",{className:Ne("min-h-72 animate-[stepWizardIn_220ms_ease-out] p-5",m),children:ee},M.id),b&&e.jsxs("div",{className:Ne("flex flex-wrap items-center justify-between gap-3 border-t border-[var(--border)] bg-[var(--bg-input)] px-4 py-3",h),children:[e.jsx(ie,{variant:"secondary",height:38,padding:"0 14px",icon:e.jsx(w.HiChevronLeft,{}),disabled:!Y,onClick:Z,children:S}),e.jsxs("div",{className:"flex items-center gap-3 text-xs text-[var(--text-muted)]",children:[e.jsxs("span",{children:["Paso ",D+1," de ",r.length]}),e.jsx("span",{className:"h-1 w-1 rounded-full bg-[var(--border)]"}),e.jsxs("span",{children:[B.length," completados"]})]}),e.jsx(ie,{height:38,padding:"0 14px",icon:e.jsx(w.HiChevronRight,{}),disabled:!v||!be,onClick:ne,children:v&&!be?y:k})]})]})}const Ea={sm:"min-h-20 px-2.5 py-1.5 text-xs leading-5",md:"min-h-24 px-2.5 py-2 text-sm leading-5",lg:"min-h-32 px-3 py-2.5 text-sm leading-6"},$a={none:"resize-none",vertical:"resize-y",horizontal:"resize-x",both:"resize"};function Ma(r,t){if(r){if(typeof r=="function"){r(t);return}r.current=t}}function Da(r,t){return r!==void 0?String(r).length:t!==void 0?String(t).length:0}const _r=o.forwardRef(function({className:t="",wrapperClassName:a="",size:n="md",resize:s="vertical",autoResize:c=!1,minRows:d,maxRows:l,showCount:p=!1,maxCount:b,status:S="default",icon:k,action:y,style:x,value:u,defaultValue:m,maxLength:h,onInput:E,...F},z){const T=o.useRef(null),N=Da(u,m),$=b??h,B=!!(k||y||p),P=S==="error"?"var(--danger)":S==="success"?"#16a34a":"var(--border)",D={...x??{},...d?{minHeight:`${d*24+18}px`}:null,...l?{maxHeight:`${l*24+18}px`}:null},M=()=>{const I=T.current;!I||!c||(I.style.height="auto",I.style.height=`${I.scrollHeight}px`)};o.useEffect(M,[c,u]);const j=e.jsx("textarea",{...F,ref:I=>{T.current=I,Ma(z,I)},value:u,defaultValue:m,maxLength:h,"aria-invalid":S==="error"||F["aria-invalid"],onInput:I=>{M(),E==null||E(I)},style:{...D,borderColor:P},className:`w-full rounded-lg border bg-[var(--bg-input)] text-[var(--text-main)] outline-none placeholder:text-[var(--text-muted)] transition-colors focus:border-[var(--primary)] disabled:cursor-not-allowed disabled:opacity-60 ${Ea[n]} ${$a[c?"none":s]} ${k?"pl-8":""} ${y?"pr-10":""} ${t}`});return B?e.jsxs("span",{className:`relative block ${a}`,children:[k&&e.jsx("span",{className:"pointer-events-none absolute left-2.5 top-2.5 flex h-4 w-4 items-center justify-center text-[var(--text-muted)]",children:k}),j,y&&e.jsx("span",{className:"absolute right-2 top-2 flex items-center justify-center",children:y}),p&&e.jsxs("span",{className:"absolute bottom-1.5 right-2 rounded bg-[var(--bg-input)] px-1.5 text-[10px] font-semibold text-[var(--text-muted)]",children:[N,$?`/${$}`:""]})]}):j});function Ha({label:r,containerClassName:t="",helperText:a,error:n,labelAction:s,required:c,className:d="",status:l,...p}){return e.jsx(Br,{label:r,required:c,helperText:a,error:n,labelAction:s,className:t,children:e.jsx(_r,{...p,required:c,status:n?"error":l,className:`w-full ${d}`})})}const La={xs:{width:28,height:16,thumb:12,padding:2},sm:{width:36,height:20,thumb:16,padding:2}};function Ta({checked:r,disabled:t,onCheckedChange:a,size:n="sm",className:s="",...c}){const d=La[n],l=r?d.width-d.thumb-d.padding*2:0;return e.jsx("button",{...c,type:"button",role:"switch","aria-checked":r,disabled:t,onClick:()=>!t&&a(!r),className:`relative inline-flex shrink-0 items-center rounded-full transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--primary)]/50 disabled:cursor-not-allowed disabled:opacity-50 ${s}`,style:{width:d.width,height:d.height,background:r?"color-mix(in srgb, var(--primary) 85%, transparent)":"var(--bg-input)",border:r?"1px solid color-mix(in srgb, var(--primary) 55%, transparent)":"1px solid var(--border)"},children:e.jsx("span",{className:"absolute inline-block rounded-full transition-transform",style:{width:d.thumb,height:d.thumb,left:d.padding,top:"50%",transform:`translate(${l}px, -50%)`,background:r?"var(--primary-fg)":"var(--text-muted)"}})})}const Fr=[".sidebar-scroll","[data-overlay-scroll='true']"].join(",");function Ba(r){if(!(r instanceof HTMLElement)||r.dataset.overlayScroll==="false"||r.closest("[data-overlayscrollbars]")||r.matches("textarea,input,select,[contenteditable='true']"))return!1;const t=window.getComputedStyle(r);return!(![t.overflow,t.overflowX,t.overflowY].join(" ").match(/auto|scroll/)||r.clientWidth===0&&r.clientHeight===0)}function Wr(r){return r.classList.contains("sidebar-scroll")}function Ur(r){Wr(r)&&r.querySelectorAll(".os-scrollbar-horizontal").forEach(t=>{t.style.display="none",t.style.height="0",t.style.pointerEvents="none"})}function qr(){return o.useEffect(()=>{const r=new WeakMap;let t=0;const a=()=>{t=0,document.querySelectorAll(Fr).forEach(c=>{if(!Ba(c))return;if(hr.OverlayScrollbars(c)){Ur(c);return}const l=hr.OverlayScrollbars(c,{overflow:Wr(c)?{x:"hidden",y:"scroll"}:void 0,scrollbars:{autoHide:"leave",autoHideDelay:180}});Ur(c),r.set(c,l)})},n=()=>{t||(t=window.requestAnimationFrame(a))};a();const s=new MutationObserver(n);return s.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["class","data-overlay-scroll"]}),window.addEventListener("resize",n),()=>{t&&window.cancelAnimationFrame(t),s.disconnect(),window.removeEventListener("resize",n),document.querySelectorAll(Fr).forEach(c=>{var d;c instanceof HTMLElement&&((d=r.get(c))==null||d.destroy())})}},[]),null}const Aa={xs:{wh:"w-5 h-5",text:"text-[8px]"},sm:{wh:"w-7 h-7",text:"text-[11px]"},md:{wh:"w-9 h-9",text:"text-sm"},lg:{wh:"w-12 h-12",text:"text-base"},xl:{wh:"w-16 h-16",text:"text-xl"}},Gr=["bg-indigo-500","bg-blue-500","bg-emerald-500","bg-violet-500","bg-amber-500","bg-teal-500","bg-rose-500","bg-cyan-500"],Oa={xs:"text-xs",sm:"text-sm",md:"text-base",lg:"text-lg"},Ia="bonsaif.bot",za="Bonsaif Bot",Pa={xs:"p-0.5",sm:"p-1",md:"p-1.5",lg:"p-2",xl:"p-2.5"};function Xr(r){return typeof r=="string"?r.trim():""}function ja(r){let t=0;for(const a of r)t=t*31+a.charCodeAt(0)&65535;return Gr[t%Gr.length]}function _a(r,t){return r===Ia||t===za}function Fa(r,t){return`${r.replace(/\/$/,"")}${t}`}function Yr({userId:r,username:t,name:a,size:n="md",showName:s=!1,showTooltip:c,tooltipContent:d,fallbackLabel:l="Usuario",wrapperClassName:p="",labelClassName:b="",labelSize:S="xs",avatarVersion:k=0,className:y="",style:x}){var U;const[u,m]=o.useState(!1),h=typeof r=="string"&&r.trim()&&r!=="undefined"&&r!=="null"?r.trim():"";o.useEffect(()=>{m(!1)},[h,k]);const{wh:E,text:F}=Aa[n],z=Xr(a)||Xr(t)||l,T=z.trim()[0]||"?",N=typeof process<"u"&&((U=process.env)==null?void 0:U.NEXT_PUBLIC_BASE_PATH)||"",$=_a(t,a),B=Fa(N,"/favicon.svg"),P=h?`${N}/api/user/avatar/${h}${k?`?v=${k}`:""}`:"",M={xs:20,sm:28,md:36,lg:48,xl:64}[n],j=$?e.jsx("span",{className:`${E} ${Pa[n]} rounded-full flex items-center justify-center bg-[#071f1a] ring-1 ring-emerald-400/35 shadow-[0_0_0_1px_rgba(255,255,255,0.06)] flex-shrink-0 ${y}`,style:x,children:e.jsx("img",{src:B,alt:z,width:M,height:M,className:"h-full w-full object-contain"})}):P&&!u?e.jsx("img",{src:P,alt:z,width:M,height:M,className:`${E} rounded-full object-cover flex-shrink-0 ${y}`,style:x,onError:()=>m(!0)},`${h}-${k}`):e.jsx("span",{className:`${E} ${ja(z)} ${F} rounded-full flex items-center justify-center font-black text-white uppercase flex-shrink-0 ${y}`,style:x,title:z,children:T});if(s)return e.jsxs("span",{className:`inline-flex min-w-0 items-center gap-2 ${p}`,children:[j,e.jsx("span",{className:`min-w-0 truncate ${Oa[S]} font-medium text-[var(--text-main)] ${b}`,title:z,children:z})]});const I=c??!0,W=d??z;return I&&W?e.jsx(Ue,{as:"span",content:W,className:`inline-flex flex-shrink-0 ${p}`,children:j}):j}function Wa({href:r,className:t,children:a}){return e.jsx("a",{href:r,className:t,children:a})}function Ua(r){return r.reduce((t,a)=>{const n=a.section??"Principal";return t[n]=[...t[n]??[],a],t},{})}function Vr({children:r,navItems:t=[],currentPath:a=typeof window>"u"?"/":window.location.pathname,user:n,appName:s="Bonsaif",appLogo:c,header:d,footer:l,onLogout:p,LinkComponent:b=Wa}){const[S,k]=o.useState(!1),y=Ua(t);return e.jsxs("div",{className:"min-h-screen bg-[var(--bg-main)] text-[var(--text-main)]",children:[e.jsx(qr,{}),e.jsx("button",{type:"button","aria-label":"Abrir navegación",className:"fixed left-3 top-3 z-50 inline-flex h-9 w-9 items-center justify-center rounded-md border border-white/10 bg-black/70 text-white lg:hidden",onClick:()=>k(!0),children:e.jsx(w.HiBars3,{className:"h-5 w-5"})}),S&&e.jsx("button",{type:"button","aria-label":"Cerrar navegación",className:"fixed inset-0 z-40 bg-black/45 lg:hidden",onClick:()=>k(!1)}),e.jsxs("aside",{className:`fixed inset-y-0 left-0 z-50 flex w-72 flex-col bg-[#071716] text-white shadow-2xl transition-transform duration-200 lg:translate-x-0 ${S?"translate-x-0":"-translate-x-full"}`,children:[e.jsxs("div",{className:"flex h-16 items-center gap-3 border-b border-white/10 px-4",children:[e.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg bg-white/10 text-white",children:c??e.jsx(w.HiHome,{className:"h-5 w-5"})}),e.jsx("div",{className:"min-w-0 flex-1 truncate text-sm font-semibold",children:s}),e.jsx("button",{type:"button","aria-label":"Cerrar navegación",className:"inline-flex h-8 w-8 items-center justify-center rounded-md text-white/70 hover:bg-white/10 lg:hidden",onClick:()=>k(!1),children:e.jsx(w.HiXMark,{className:"h-5 w-5"})})]}),e.jsx("nav",{className:"sidebar-scroll min-h-0 flex-1 overflow-y-auto px-3 py-4","data-overlay-scroll":"true",children:Object.entries(y).map(([x,u])=>e.jsxs("div",{className:"mb-5",children:[e.jsxs("div",{className:"mb-2 flex items-center gap-2 px-2 text-[11px] font-semibold uppercase tracking-wide text-white/35",children:[e.jsx(w.HiChevronDown,{className:"h-3.5 w-3.5"}),x]}),e.jsx("div",{className:"space-y-1",children:u.map(m=>{const h=a===m.href||a.startsWith(`${m.href}/`);return e.jsxs(b,{href:m.href,className:`flex min-w-0 items-center gap-2 rounded-md px-2 py-2 text-sm transition-colors ${h?"bg-white/10 text-white":"text-white/55 hover:bg-white/[0.06] hover:text-white/85"}`,children:[e.jsx("span",{className:"flex h-5 w-5 flex-shrink-0 items-center justify-center",children:m.icon??e.jsx(w.HiHome,{className:"h-4 w-4"})}),e.jsx("span",{className:"truncate",children:m.label})]},m.href)})})]},x))}),e.jsxs("div",{className:"border-t border-white/10 p-3",children:[n&&e.jsxs("div",{className:"mb-3 flex min-w-0 items-center gap-3 rounded-lg bg-white/[0.04] p-2",children:[e.jsx(Yr,{name:n.initials??n.name??n.email??"Usuario",size:"md"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate text-sm font-medium text-white",children:n.name??"Usuario"}),n.email&&e.jsx("div",{className:"truncate text-xs text-white/45",children:n.email})]})]}),p&&e.jsxs(ie,{variant:"ghost",className:"w-full justify-start text-white hover:bg-white/10",onClick:p,children:[e.jsx(w.HiArrowRightOnRectangle,{className:"h-4 w-4"})," Salir"]}),l]})]}),e.jsxs("div",{className:"min-h-screen lg:pl-72",children:[d,e.jsx("main",{className:"min-h-screen",children:r})]})]})}const qa={dashboard:"Dashboard",tickets:"Tickets",teams:"Equipos",projects:"Proyectos",clients:"Clientes",surveys:"Encuestas",profile:"Perfil",settings:"Configuración",notifications:"Notificaciones",changelog:"Historial",admin:"Inicio",users:"Usuarios",roles:"Roles",menus:"Menús",guards:"Guardias",vacations:"Vacaciones",audit:"Auditoría",positions:"Puestos",ranks:"Rangos","email-inbox":"Buzones","security-incidents":"Incidentes","guard-schedule":"Guardias"},sr={dashboard:e.jsx(w.HiChartBar,{className:"h-5 w-5"}),tickets:e.jsx(w.HiTicket,{className:"h-5 w-5"}),teams:e.jsx(w.HiUsers,{className:"h-5 w-5"}),projects:e.jsx(w.HiRectangleGroup,{className:"h-5 w-5"}),clients:e.jsx(w.HiBuildingOffice2,{className:"h-5 w-5"}),surveys:e.jsx(w.HiClipboardDocumentList,{className:"h-5 w-5"}),profile:e.jsx(w.HiUser,{className:"h-5 w-5"}),settings:e.jsx(w.HiCog6Tooth,{className:"h-5 w-5"}),notifications:e.jsx(w.HiBell,{className:"h-5 w-5"}),changelog:e.jsx(w.HiDocumentText,{className:"h-5 w-5"}),admin:e.jsx(w.HiShieldCheck,{className:"h-5 w-5"}),users:e.jsx(w.HiUsers,{className:"h-5 w-5"}),roles:e.jsx(w.HiShieldCheck,{className:"h-5 w-5"}),menus:e.jsx(w.HiCog6Tooth,{className:"h-5 w-5"}),guards:e.jsx(w.HiCalendarDays,{className:"h-5 w-5"}),vacations:e.jsx(w.HiCalendarDays,{className:"h-5 w-5"}),audit:e.jsx(w.HiListBullet,{className:"h-5 w-5"}),positions:e.jsx(w.HiBriefcase,{className:"h-5 w-5"}),ranks:e.jsx(w.HiListBullet,{className:"h-5 w-5"}),"email-inbox":e.jsx(w.HiInbox,{className:"h-5 w-5"}),"security-incidents":e.jsx(w.HiShieldCheck,{className:"h-5 w-5"})};function Ga({href:r,className:t,style:a,children:n}){return e.jsx("a",{href:r,className:t,style:a,children:n})}function Xa(r){return r.split("-").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}function Ya(r){return/^\d+$/.test(r)||/^[a-f0-9]{8,}$/i.test(r)}function Va(r){const t=r.split("/").filter(Boolean);if(t.length===0||t.length===1&&t[0]==="dashboard")return[];const a=decodeURIComponent(t[t.length-1]),n=t.length>1?decodeURIComponent(t[t.length-2]):void 0,s=Ya(a)&&n?n:a,c=qa[s]??Xa(s);return[{label:"Inicio",href:"/"},{label:c}]}function lr(r){return(r==null?void 0:r.querySelector(":scope > .os-viewport"))??(r==null?void 0:r.querySelector(":scope > [data-overlayscrollbars-viewport]"))}function Ka(r){const t=r.split("/").filter(Boolean),a=t[t.length-1];if(!a)return e.jsx(w.HiHome,{className:"h-5 w-5"});if(sr[a])return sr[a];const n=t.length>1?t[t.length-2]:"";return sr[n]??e.jsx(w.HiHome,{className:"h-5 w-5"})}function Za({title:r,subtitle:t,action:a,meta:n,icon:s,className:c="",contentClassName:d="",breadcrumbs:l,currentPath:p=typeof window>"u"?"/":window.location.pathname,showBreadcrumbs:b=!0,contained:S=!1,LinkComponent:k=Ga}){const y=o.useRef(null),[x,u]=o.useState(!1),[m,h]=o.useState(null),E=l??Va(p),F=s??Ka(p),z=b&&E.length>1;return o.useEffect(()=>{if(S){u(!1);return}let T=null,N=0,$=0;const B=()=>{const M=y.current,j=document.querySelector("[data-app-scroll='true']");return(M==null?void 0:M.closest(".os-viewport"))??(M==null?void 0:M.closest("[data-overlayscrollbars-viewport]"))??lr(j)??j??window},P=()=>{const M=T&&T!==window?T.scrollTop:window.scrollY;u(j=>j?M>24:M>72)},D=()=>{T==null||T.removeEventListener("scroll",P),T=B(),T.addEventListener("scroll",P,{passive:!0}),P()};return D(),N=window.requestAnimationFrame(D),$=window.setTimeout(D,120),()=>{window.cancelAnimationFrame(N),window.clearTimeout($),T==null||T.removeEventListener("scroll",P)}},[S]),o.useEffect(()=>{if(S){h(null);return}let T=0;const N=[],$=()=>{const W=y.current,U=W==null?void 0:W.parentElement,J=document.querySelector("[data-app-scroll='true']"),te=lr(J)??J;if(!W||!U||!te){h(null);return}const f=U.getBoundingClientRect(),H=window.getComputedStyle(U),G=te.getBoundingClientRect(),K=te instanceof HTMLElement&&te.clientWidth>0?te.clientWidth:G.width,Z=f.left+parseFloat(H.paddingLeft||"0"),ne={marginLeft:Math.round(G.left-Z),width:Math.round(K)};h(de=>de&&de.marginLeft===ne.marginLeft&&de.width===ne.width?de:ne)},B=()=>{window.cancelAnimationFrame(T),T=window.requestAnimationFrame($)};B(),window.addEventListener("resize",B);const P=new ResizeObserver(B),D=y.current,M=D==null?void 0:D.parentElement,j=document.querySelector("[data-app-scroll='true']"),I=lr(j)??j;return[M,j,I].forEach(W=>{W&&P.observe(W)}),N.push(window.setTimeout(B,120)),N.push(window.setTimeout(B,280)),()=>{window.cancelAnimationFrame(T),window.removeEventListener("resize",B),P.disconnect(),N.forEach(W=>window.clearTimeout(W))}},[S]),e.jsx("div",{ref:y,"data-page-header":"true","data-compact":x?"true":"false",className:`sticky top-0 z-30 overflow-visible py-0 transition-[background-color,box-shadow,border-color] duration-300 ease-out ${S?"mb-0 flex-shrink-0":"mb-4 sm:mb-0"} ${c}`,style:{...m?{marginLeft:m.marginLeft,width:m.width}:null,background:S?"var(--bg-card)":x?"var(--bg-main)":"color-mix(in srgb, var(--bg-main) 44%, transparent)",backdropFilter:"saturate(1.2) blur(14px)",WebkitBackdropFilter:"saturate(1.2) blur(14px)",borderBottom:S||x?"1px solid var(--border)":"1px solid transparent",boxShadow:x?"0 10px 28px rgba(12, 54, 53, 0.12)":"none"},children:e.jsxs("div",{className:`flex flex-wrap items-center justify-between px-4 pt-0.5 transition-[gap,min-height,padding] duration-300 ease-out ${x?"min-h-9 gap-2 sm:min-h-10 sm:gap-2.5":"min-h-10 gap-2.5 sm:min-h-11 sm:gap-3"} ${d}`,children:[e.jsxs("div",{className:`min-w-0 flex flex-1 flex-col justify-center transition-[gap,transform] duration-300 ease-out ${x?"gap-1":"gap-1.5 sm:gap-2"}`,children:[z&&e.jsx("nav",{"aria-label":"Breadcrumb",className:"min-w-0 flex-shrink-0 transition-[opacity,transform] duration-300 ease-out",children:e.jsx("ol",{className:`flex flex-wrap items-center gap-1.5 leading-none transition-[font-size,line-height] duration-300 ease-out ${x?"text-[10px]":"text-[10px] sm:text-[11px]"}`,children:E.map((T,N)=>{const $=N===E.length-1;return e.jsxs("li",{className:"flex min-w-0 items-center gap-1.5",children:[N>0&&e.jsx(w.HiChevronRight,{className:"h-3.5 w-3.5 transition-[color,transform] duration-300 ease-out",style:{color:"var(--text-muted)"}}),T.href&&!$?e.jsx(k,{href:T.href,className:"truncate transition-colors duration-300 hover:underline",style:{color:"var(--text-muted)"},children:T.label}):e.jsx("span",{"aria-current":$?"page":void 0,className:$?"truncate font-semibold":"truncate",style:{color:$?"var(--text-main)":"var(--text-muted)"},children:T.label})]},`${T.label}-${N}`)})})}),e.jsxs("div",{className:`flex min-w-0 items-center transition-[gap,transform] duration-300 ease-out ${x?"gap-2":"gap-2.5 sm:gap-3"}`,children:[e.jsx("span",{className:`flex-shrink-0 transition-[color,transform,opacity] duration-300 ease-out ${x?"scale-75 opacity-80":"scale-90 opacity-100"}`,style:{color:z?"var(--text-secondary)":"var(--text-muted)"},children:F}),e.jsxs("div",{className:`flex min-w-0 flex-1 flex-wrap items-center transition-[gap] duration-300 ease-out ${x?"gap-x-2 gap-y-1":"gap-x-3 gap-y-2"}`,children:[e.jsxs("div",{className:"min-w-0 flex-shrink transition-[transform] duration-300 ease-out",children:[e.jsx("h1",{className:`truncate font-bold tracking-tight transition-[font-size,line-height,color] duration-300 ease-out ${x?"text-base sm:text-lg":"text-lg sm:text-xl"}`,style:{color:"var(--text-main)"},children:r}),t&&e.jsx("p",{"aria-hidden":x,className:`overflow-hidden text-xs transition-[max-height,opacity,transform,margin] duration-300 ease-out ${x?"mt-0 max-h-0 -translate-y-1 opacity-0":"mt-0.5 max-h-5 translate-y-0 opacity-100"}`,style:{color:"var(--text-muted)"},children:t})]}),n&&e.jsx("div",{className:`page-header-meta flex min-w-0 flex-1 basis-full items-center overflow-visible transition-[gap,opacity,transform] duration-300 ease-out sm:basis-auto ${x?"translate-y-0 gap-1.5 opacity-95":"gap-2 opacity-100"}`,children:n})]})]})]}),a&&e.jsx("div",{className:`page-header-actions ml-auto flex max-w-full flex-shrink-0 flex-wrap items-center justify-end self-center overflow-visible transition-[gap,min-height,opacity,transform] duration-300 ease-out ${x?"min-h-10 gap-1 opacity-95":"min-h-10 gap-1.5 opacity-100"}`,children:e.jsx(yr.Provider,{value:{compact:!0,headerAction:!0},children:a})})]})})}function Ja({children:r,currentPath:t=typeof window>"u"?"/":window.location.pathname,publicRoutes:a=["/","/login","/reset-password"],...n}){return a.includes(t)?e.jsx(e.Fragment,{children:r}):e.jsx(Vr,{currentPath:t,...n,children:r})}function Kr(){if(typeof window>"u")return"system";const r=localStorage.getItem("theme");return r==="light"||r==="dark"?r:r==="system"?"system":document.documentElement.classList.contains("dark")?"dark":"light"}function Qa(r,t,a){try{const n=new URL(r),s=n.searchParams.get("callbackUrl");if(s){const c=new URL(s,n.origin);return c.searchParams.set("theme",t),a&&(c.searchParams.set("primeAuthOrigin",window.location.origin),c.searchParams.set("primeAuthProjectKey",a)),n.searchParams.set("callbackUrl",`${c.pathname}${c.search}${c.hash}`),n.toString()}return n.searchParams.set("theme",t),a&&(n.searchParams.set("primeAuthOrigin",window.location.origin),n.searchParams.set("primeAuthProjectKey",a)),n.toString()}catch{return r}}function Ra({name:r,src:t,projectKey:a}){const[n,s]=o.useState(()=>Kr()),c=o.useRef(null);o.useEffect(()=>{const p=new MutationObserver(()=>s(Kr()));return p.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>p.disconnect()},[]);const d=o.useMemo(()=>Qa(t,n,a),[a,t,n]),l=o.useMemo(()=>{try{return new URL(d).origin}catch{return""}},[d]);return o.useEffect(()=>{if(!a)return;const p=a;function b(S){var x,u,m;if(S.source!==((x=c.current)==null?void 0:x.contentWindow)||l&&S.origin!==l)return;if(((u=S.data)==null?void 0:u.type)==="prime-microservice:overlay"){window.dispatchEvent(new CustomEvent("prime-auth:microservice-overlay",{detail:{active:!!S.data.active}}));return}if(((m=S.data)==null?void 0:m.type)!=="prime-microservice:navigation")return;const k=S.data.path;if(!k||!k.startsWith("/")||k.startsWith("//"))return;const y=`/apps/${encodeURIComponent(p)}${k}`;`${window.location.pathname}${window.location.search}${window.location.hash}`!==y&&(window.history.replaceState(window.history.state,"",y),window.dispatchEvent(new CustomEvent("prime-auth:microservice-navigation")))}return window.addEventListener("message",b),()=>{window.removeEventListener("message",b),window.dispatchEvent(new CustomEvent("prime-auth:microservice-overlay",{detail:{active:!1}}))}},[l,a]),e.jsx("div",{className:"flex h-full min-h-screen flex-col bg-[var(--bg-main)]",children:e.jsx("iframe",{ref:c,src:d,title:r,className:"min-h-0 flex-1 border-0 bg-[var(--bg-main)]",allow:"clipboard-write",sandbox:"allow-downloads allow-forms allow-modals allow-popups allow-same-origin allow-scripts",referrerPolicy:"strict-origin-when-cross-origin"})})}function en(){const[r,t]=o.useState(""),[a,n]=o.useState(!1),[s,c]=o.useState({width:96,height:96});return o.useEffect(()=>{let d=!1;return fetch("/api/microservices/prime-suite/chat-url",{cache:"no-store"}).then(l=>l.ok?l.json():null).then(l=>{!d&&(l!=null&&l.src)&&t(l.src)}).catch(()=>{}),()=>{d=!0}},[]),o.useEffect(()=>{const d=l=>{var b;if(((b=l.data)==null?void 0:b.type)!=="prime-suite-chat:state")return;const p=!!l.data.active;n(p),c({width:Zr(l.data.width,96,720),height:Zr(l.data.height,96,560)})};return window.addEventListener("message",d),()=>window.removeEventListener("message",d)},[]),r?e.jsx("iframe",{title:"Chat Bonsaif",src:r,allow:"clipboard-write",className:"fixed bottom-0 right-0 z-[70] border-0 bg-transparent transition-[width,height] duration-200",style:{width:a?`min(${s.width}px, 100vw)`:96,height:a?`min(${s.height}px, 100vh)`:96,background:"transparent",backgroundColor:"transparent",colorScheme:"normal"}}):null}function Zr(r,t,a){const n=typeof r=="number"&&Number.isFinite(r)?r:t;return Math.max(t,Math.min(a,Math.ceil(n)))}function rn(r){const t=document.documentElement,a=new MutationObserver(r);a.observe(t,{attributes:!0,attributeFilter:["class"]});const n=window.matchMedia("(prefers-color-scheme: dark)");return n.addEventListener("change",r),()=>{a.disconnect(),n.removeEventListener("change",r)}}function tn(){const r=localStorage.getItem("theme")||"system",t=window.matchMedia("(prefers-color-scheme: dark)").matches;return document.documentElement.classList.contains("dark")||r==="dark"||r==="system"&&t?"dark":"light"}function an(){return"light"}function nn(){const r=o.useSyncExternalStore(rn,tn,an);return e.jsx(ut.Toaster,{position:"bottom-center",theme:r,richColors:!0,closeButton:!0})}A.Alert=Mt,A.AuthShell=Vr,A.BonsaifButton=ft,A.Button=ie,A.CalendarPicker=Bt,A.Checkbox=Ot,A.CodeBlock=Pt,A.CompactFilterSelect=_t,A.CompactSearchInput=jt,A.ConfirmDialog=Ut,A.CopyButton=nr,A.CopyLinkButton=Gt,A.DataTable=Kt,A.DateRangePicker=Qt,A.Drawer=ta,A.DropdownMenu=ea,A.DynamicDetailTabs=Et,A.EmptyState=na,A.FormField=Br,A.GlobalScrollbars=qr,A.InputField=ba,A.LoadingState=Nr,A.MicroserviceFrame=Ra,A.Modal=Hr,A.MouseTooltip=Ue,A.MultiSelect=ma,A.PageHeader=Za,A.PageSearchInput=gr,A.Pagination=xa,A.PrimeAuthRouteShell=Ja,A.PrimeAuthToaster=nn,A.PrimeSuiteChatFrame=en,A.RadioGroup=ga,A.SearchableSelect=or,A.SectionPanel=ya,A.StatusBadge=ka,A.StepWizard=Ca,A.Tabs=Sa,A.TextInput=Ve,A.Textarea=_r,A.TextareaField=Ha,A.Toggle=Ta,A.UserAvatar=Yr,A.cn=xr,Object.defineProperty(A,Symbol.toStringTag,{value:"Module"})}));
1
+ (function(A,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("react/jsx-runtime"),require("react-icons/hi2"),require("react"),require("react-dom"),require("overlayscrollbars"),require("react-icons/md"),require("overlayscrollbars-react"),require("react-day-picker"),require("react-day-picker/dist/style.css"),require("react-icons/fi"),require("sonner")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react-icons/hi2","react","react-dom","overlayscrollbars","react-icons/md","overlayscrollbars-react","react-day-picker","react-day-picker/dist/style.css","react-icons/fi","sonner"],e):(A=typeof globalThis<"u"?globalThis:A||self,e(A.BonsaifUI={},A.jsxRuntime,A.ReactIconsHi2,A.React,A.ReactDOM,A.OverlayScrollbarsGlobal,A.ReactIconsMd,A.OverlayScrollbarsReact,A.ReactDayPicker,A.ReactDayPickerStyles,A.ReactIconsFi,A.Sonner))})(this,(function(A,e,w,o,Ce,xr,vt,gr,yr,Ln,xt,gt){"use strict";"use client";function wr(...r){return r.filter(Boolean).join(" ")}function yt({variant:r="primary",className:t,type:a="button",children:n,...s}){return e.jsx("button",{className:wr("bonsaif-ui-button",`bonsaif-ui-button--${r}`,t),type:a,...s,children:n})}function Nr({value:r,onChange:t,placeholder:a,className:n="",autoFocus:s=!1,forceExpanded:c=!1,onEscape:d,size:i="default",inputTabIndex:p}){const b=o.useRef(null),[C,k]=o.useState(!1),y=c||C||r.trim().length>0,g=i==="sm"?"h-9 rounded-md":"h-10 rounded-lg",u=n||"w-48 max-w-full sm:w-64 lg:w-72";o.useEffect(()=>{var h;s&&((h=b.current)==null||h.focus())},[s]);const m=()=>{var h;k(!0),(h=b.current)==null||h.focus()};return e.jsxs("div",{className:`relative min-w-0 max-w-full flex-shrink-0 overflow-visible transition-[width] duration-200 ease-out ${y?u:"w-24 sm:w-28"}`,onMouseDown:h=>{y||(h.preventDefault(),m())},children:[e.jsx(w.HiMagnifyingGlass,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 pointer-events-none transition-colors duration-200",style:{color:"var(--text-muted)"}}),e.jsx("input",{ref:b,type:"text",tabIndex:p,"aria-label":a,value:r,onChange:h=>t(h.target.value),onKeyDown:h=>{h.key==="Escape"&&(d==null||d())},placeholder:y?a:"Buscar",className:`${g} w-full py-0 text-sm leading-none placeholder:text-[var(--text-muted)] focus:outline-none transition-all duration-200 ${y?"pl-9 pr-8":"cursor-pointer pl-9 pr-3"}`,style:{background:"color-mix(in srgb, var(--bg-card) 86%, transparent)",border:"1px solid var(--border)",color:"var(--text-main)"},onFocus:h=>{k(!0),h.currentTarget.style.borderColor="var(--primary)",h.currentTarget.style.boxShadow="0 0 0 3px rgba(59,130,246,0.12)"},onBlur:h=>{k(!1),h.currentTarget.style.borderColor="var(--border)",h.currentTarget.style.boxShadow="none"}}),r&&e.jsx("button",{type:"button",onClick:()=>t(""),className:"absolute right-2 top-1/2 flex !h-6 !w-6 -translate-y-1/2 items-center justify-center rounded-full !p-0 leading-none transition-colors hover:bg-black/5",style:{color:"var(--text-muted)"},"aria-label":"Limpiar búsqueda",children:e.jsx(w.HiXMark,{className:"h-3.5 w-3.5 flex-shrink-0"})})]})}const kr=o.createContext({});function wt(r){var n;const t=Array.from(r.querySelectorAll("*")).filter(s=>{var c;return s.scrollWidth>s.clientWidth&&!!((c=s.textContent)!=null&&c.trim())&&s.tagName.toLowerCase()!=="svg"&&!s.closest("svg")});return(r.scrollWidth>r.clientWidth||t.length>0)&&(((n=t[0])==null?void 0:n.textContent)??r.textContent??"").trim()||null}function Fe({children:r,content:t,onlyWhenOverflow:a=!1,className:n="",style:s,as:c="div"}){const d=o.useRef(null),i=o.useRef(null),[p,b]=o.useState(null),[C,k]=o.useState("");o.useEffect(()=>{const u=d.current;u&&(u.querySelectorAll("[title]").forEach(m=>{const h=m.getAttribute("title");h&&(m.getAttribute("aria-label")||m.setAttribute("aria-label",h),m.removeAttribute("title"))}),u.querySelectorAll("svg title").forEach(m=>m.remove()))}),o.useLayoutEffect(()=>{if(!p)return;const u=i.current;if(!u)return;const m=12,h=14,E=u.getBoundingClientRect(),W=window.innerWidth-E.width-m,z=window.innerHeight-E.height-m;let T=p.mouseX+h,N=p.mouseY+h;T>W&&(T=p.mouseX-E.width-h),N>z&&(N=p.mouseY-E.height-h),T=Math.min(Math.max(m,T),Math.max(m,W)),N=Math.min(Math.max(m,N),Math.max(m,z)),(Math.abs(T-p.x)>.5||Math.abs(N-p.y)>.5)&&b($=>$&&{...$,x:T,y:N})},[p]);const y=(u,m)=>{const h=d.current;if(h){if(a){const E=wt(h);if(!E)return;k(E)}!a&&!t||b({mouseX:u,mouseY:m,x:u+14,y:m+14})}},g=a?C:t;return e.jsxs(e.Fragment,{children:[e.jsx(c,{ref:u=>{d.current=u},className:n,style:s,onMouseEnter:u=>y(u.clientX,u.clientY),onMouseMove:u=>{p&&y(u.clientX,u.clientY)},onMouseLeave:()=>b(null),children:r}),p&&g?Ce.createPortal(e.jsx("div",{ref:i,role:"tooltip",style:{position:"fixed",top:p.y,left:p.x,zIndex:9999,background:"var(--bg-card)",border:"1px solid var(--border)",borderRadius:6,padding:"5px 10px",fontSize:12,color:"var(--text-main)",boxShadow:"0 4px 16px rgba(0,0,0,0.35)",pointerEvents:"none",maxWidth:"min(420px, calc(100vw - 24px))",whiteSpace:"normal",lineHeight:1.6,overflowWrap:"anywhere"},children:g}),document.body):null]})}function Sr(r){if(r!==void 0)return typeof r=="number"?`${r}px`:r}const Nt="inline-flex shrink-0 items-center justify-center gap-2 whitespace-nowrap leading-none font-medium transition-all duration-150 focus:outline-none disabled:opacity-50 rounded-lg",kt={primary:"border border-[var(--border)] text-[var(--text-main)] hover:border-[var(--border)] hover:bg-[var(--bg-input)] active:scale-[0.98] transition-colors",secondary:"border border-[var(--border)] text-[var(--text-main)] hover:border-[var(--border)] hover:bg-[var(--bg-input)] active:scale-[0.98] transition-colors",danger:"border border-[var(--border)] text-[var(--danger)] hover:border-[var(--danger)] hover:bg-[var(--danger-bg)] active:scale-[0.98] transition-colors",ghost:"text-[var(--text-secondary)] hover:opacity-70",icon:"text-[var(--text-muted)] hover:text-[var(--primary)] hover:bg-primary/5"},St="border border-[var(--border)] text-[var(--text-muted)] shadow-sm shadow-black/5 hover:border-[var(--border)] hover:bg-[var(--bg-input)] hover:text-[var(--primary)] active:scale-[0.98] transition-colors",Ct={xs:"h-8 px-2.5 text-xs",sm:"h-9 px-3.5 text-xs",md:"h-10 px-3.5 text-sm",lg:"h-11 px-4 text-sm font-semibold"},Et={xs:"h-8 w-8",sm:"h-9 w-9",md:"h-10 w-10",lg:"h-10 w-10"},$t={primary:{background:"var(--bg-card)"},secondary:{background:"var(--bg-card)"},danger:{background:"var(--bg-card)"},ghost:{},icon:{}};function ar(r){return typeof r=="string"||typeof r=="number"?String(r):Array.isArray(r)?r.map(ar).join(" ").trim():o.isValidElement(r)?ar(r.props.children):""}function Mt(r){return o.Children.toArray(r).find(o.isValidElement)??null}function ce({variant:r="primary",size:t="md",loading:a=!1,icon:n,tooltip:s,iconOnly:c,height:d,padding:i,children:p,className:b="",disabled:C,style:k,...y}){const g=o.useContext(kr),u=c??g.iconOnly??r==="icon",m=g.compact??!1,h=g.headerAction??!1,E=m&&!h&&t==="md"?"xs":t,W=r==="icon"||u,z=h&&W,T=ar(p),N=s??y.title??y["aria-label"]??(u?T:void 0),$=N?void 0:y.title,B=y["aria-label"]??(typeof N=="string"?N:T||void 0),P=a?null:n??(u?Mt(p):null),D=e.jsxs("button",{...y,title:$,"aria-label":B,"data-variant":r,"data-size":E,"data-icon":W?"true":void 0,disabled:C||a,className:`${Nt} ${z?St:kt[r]} ${W?Et[E]:Ct[E]} ${m&&!W?"px-2.5":""} ${b}`,style:{...$t[r],height:Sr(d),padding:Sr(i),...k,...z?{width:"40px",height:"40px",padding:0,background:"var(--bg-card)",borderRadius:"8px"}:null},children:[a?e.jsx("span",{className:"h-3.5 w-3.5 animate-spin rounded-full border-2 border-current border-t-transparent"}):P,!u&&p]});return N?e.jsx(Fe,{as:"span",content:N,className:"inline-flex shrink-0",children:D}):D}function Cr({variant:r="page",title:t="Cargando...",rows:a=6,children:n}){return r==="table"?e.jsx(Er,{rows:a}):r==="sections"?e.jsx(Dt,{rows:a}):r==="cards"?e.jsx(Ht,{rows:a}):e.jsx("div",{className:"flex min-h-[240px] items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-6",children:e.jsxs("div",{className:"flex flex-col items-center gap-3 text-center",children:[e.jsx("div",{className:"h-9 w-9 animate-spin rounded-full border-2 border-[var(--border)] border-t-[var(--primary)]"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold text-[var(--text-main)]",children:t}),n&&e.jsx("div",{className:"mt-1 text-xs text-[var(--text-muted)]",children:n})]})]})})}function Dt({rows:r}){return e.jsx("div",{className:"space-y-4",children:Array.from({length:Math.max(2,Math.min(r,4))}).map((t,a)=>e.jsxs("section",{className:"overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)]",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-[var(--border)] px-3 py-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-4 w-4 animate-pulse rounded bg-[var(--bg-input)]"}),e.jsx("div",{className:"h-4 w-32 animate-pulse rounded bg-[var(--bg-input)]"}),e.jsx("div",{className:"h-5 w-20 animate-pulse rounded-full bg-[var(--bg-input)]"})]}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx("div",{className:"h-8 w-8 animate-pulse rounded-md bg-[var(--bg-input)]"}),e.jsx("div",{className:"h-8 w-8 animate-pulse rounded-md bg-[var(--bg-input)]"})]})]}),e.jsx(Er,{rows:a===0?r:Math.max(3,r-2),compact:!0})]},a))})}function Ht({rows:r}){return e.jsx("div",{className:"grid gap-3 md:grid-cols-2 xl:grid-cols-3",children:Array.from({length:r}).map((t,a)=>e.jsxs("div",{className:"rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-4",children:[e.jsx("div",{className:"h-4 w-2/3 animate-pulse rounded bg-[var(--bg-input)]"}),e.jsx("div",{className:"mt-3 h-3 w-full animate-pulse rounded bg-[var(--bg-input)]"}),e.jsx("div",{className:"mt-2 h-3 w-4/5 animate-pulse rounded bg-[var(--bg-input)]"})]},a))})}function Er({rows:r,compact:t=!1}){const a=t?5:6;return e.jsxs("div",{className:"overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)]",children:[e.jsx("div",{className:"grid border-b border-[var(--border)]",style:{gridTemplateColumns:`repeat(${a}, minmax(0, 1fr))`},children:Array.from({length:a}).map((n,s)=>e.jsx("div",{className:"px-3 py-3",children:e.jsx("div",{className:"h-3 w-2/3 animate-pulse rounded bg-[var(--bg-input)]"})},s))}),Array.from({length:r}).map((n,s)=>e.jsx("div",{className:"grid border-b border-[var(--border)] last:border-b-0",style:{gridTemplateColumns:`repeat(${a}, minmax(0, 1fr))`},children:Array.from({length:a}).map((c,d)=>e.jsx("div",{className:"px-3 py-3",children:e.jsx("div",{className:"h-3.5 animate-pulse rounded-full bg-[var(--bg-input)]",style:{width:`${52+(s*13+d*11)%36}%`}})},d))},s))]})}function $r(r){const t=r.split("/").filter(Boolean);return(t[t.length-1]??r).replace(/^lv_/,"").split(/[-_]/).filter(Boolean).map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join(" ")}function Mr(r){return r.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().trim()}function Lt(r){return[r.label,$r(r.service),r.description,r.service].filter(Boolean).join(" ")}function Tt(r){return typeof r=="function"?r:r.default}function Bt(r,t){return e.jsx("div",{className:"flex min-h-[220px] items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-6 text-center",children:e.jsxs("div",{className:"max-w-md",children:[e.jsx("p",{className:"text-sm font-semibold text-[var(--text-main)]",children:"No se pudo cargar este modulo"}),e.jsx("p",{className:"mt-1 text-xs text-[var(--text-muted)]",children:r.message}),e.jsx(ce,{className:"mt-4",height:36,padding:"0 14px",onClick:t,children:"Reintentar"})]})})}function At({parentPanel:r,parentPanelComponent:t,renderParentPanel:a,parent:n,context:s,links:c,moduleRegistry:d,loadModule:i,activeService:p,initialService:b,onActiveServiceChange:C,canAccess:k,keepAlive:y=!0,title:g,subtitle:u,emptyState:m,loadingState:h,errorState:E=Bt,renderTabLabel:W,searchableTabs:z="auto",tabsSearchThreshold:T=6,tabsSearchPlaceholder:N="Buscar modulo...",tabsSearchValue:$,onTabsSearchChange:B,emptySearchState:P,showTabCount:D=!0,className:M="",parentClassName:_="",contentClassName:I="",tabsClassName:U=""}){var Ze;const F=o.useMemo(()=>c.filter(L=>!L.hidden&&((k==null?void 0:k(L,s))??!0)),[k,s,c]),J=(Ze=F.find(L=>!L.disabled))==null?void 0:Ze.service,[te,f]=o.useState(b??J??""),[H,G]=o.useState({}),[K,Z]=o.useState({}),[ae,ue]=o.useState(""),[x,Y]=o.useState(!1),be=o.useRef(K),ee=o.useRef(0),Q=$??ae,O=Mr(Q),V=z===!0||z==="auto"&&F.length>=T,R=V&&Q.trim().length>0,le=o.useMemo(()=>O?F.filter(L=>Mr(Lt(L)).includes(O)):F,[O,F]),he=p??te,X=F.find(L=>L.service===he)??F.find(L=>!L.disabled);o.useEffect(()=>{!X&&J&&f(J)},[J,X]),o.useEffect(()=>{be.current=K},[K]);const we=L=>{L.disabled||(p||f(L.service),C==null||C(L.service,L))},De=L=>{$===void 0&&ue(L),B==null||B(L)},Pe=(L,ie)=>{const se=le.filter(fe=>!fe.disabled),ye=se.findIndex(fe=>fe.service===ie.service);ye<0||((L.key==="ArrowRight"||L.key==="ArrowDown")&&(L.preventDefault(),we(se[(ye+1)%se.length])),(L.key==="ArrowLeft"||L.key==="ArrowUp")&&(L.preventDefault(),we(se[(ye-1+se.length)%se.length])),L.key==="Home"&&(L.preventDefault(),we(se[0])),L.key==="End"&&(L.preventDefault(),we(se[se.length-1])))},Be=o.useCallback(()=>{if(!X)return;const L=X.service,ie=be.current[L];if(ie!=null&&ie.loading||ie!=null&&ie.component&&y)return;const se=(d==null?void 0:d[L])??i;if(!se){Z(fe=>({...fe,[L]:{loading:!1,error:new Error(`No module loader found for service "${L}".`)}}));return}const ye=++ee.current;Z(fe=>({...fe,[L]:{...fe[L],loading:!0,error:void 0}})),se(X,s).then(fe=>{if(ye!==ee.current&&!y)return;const me=Tt(fe);Z(He=>({...He,[L]:{component:me,loading:!1}}))}).catch(fe=>{const me=fe instanceof Error?fe:new Error(String(fe));Z(He=>({...He,[L]:{...He[L],loading:!1,error:me}}))})},[s,y,i,d,X]);o.useEffect(Be,[Be]);const _e=X?H[X.service]??null:null,ne=X?K[X.service]:void 0,Ae=ne==null?void 0:ne.component,Ve=L=>{X&&G(ie=>({...ie,[X.service]:L}))},je=()=>{X&&G(L=>({...L,[X.service]:null}))},Ke={context:s,parent:n,links:c,visibleLinks:F,filteredLinks:le,selectedLink:X,selectedService:X==null?void 0:X.service,activeItemId:_e,tabsSearch:Q,onSelectService:we,onOpenDetail:Ve,onBackToList:je},We=a?a(Ke):t?e.jsx(t,{...Ke}):r;return e.jsxs("section",{className:`grid min-h-[520px] gap-4 lg:grid-cols-[minmax(260px,360px)_minmax(0,1fr)] ${M}`,children:[e.jsx("aside",{className:`min-w-0 rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-4 ${_}`,children:We}),e.jsxs("div",{className:`relative min-w-0 overflow-visible rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${I}`,children:[(g||u||V||D)&&e.jsx("div",{className:"relative border-b border-[var(--border)] px-4 py-3",children:e.jsxs("div",{className:"flex min-w-0 items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[g&&e.jsx("h2",{className:"truncate text-sm font-semibold text-[var(--text-main)]",children:g}),u&&e.jsx("p",{className:"mt-1 line-clamp-2 text-xs text-[var(--text-muted)]",children:u})]}),(V||D)&&e.jsxs("div",{className:"flex min-w-0 flex-shrink-0 items-center justify-end gap-2",children:[D&&e.jsxs("span",{className:"hidden text-xs font-semibold text-[var(--text-muted)] transition-opacity duration-200 sm:inline",children:[le.length," / ",F.length]}),V&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:`origin-right overflow-hidden transition-[width,opacity,transform] duration-200 ease-out ${x?"w-[min(20rem,44vw)] translate-x-0 opacity-100":"w-0 translate-x-2 opacity-0"}`,"aria-hidden":!x,children:e.jsx(Nr,{value:Q,onChange:De,placeholder:N,className:"w-full",autoFocus:x,forceExpanded:!0,onEscape:()=>Y(!1),size:"sm",inputTabIndex:x?0:-1})}),e.jsx("button",{type:"button","aria-label":x?"Cerrar busqueda":"Buscar tabs","aria-expanded":x,onClick:()=>{x&&Q&&De(""),Y(L=>!L)},className:`inline-flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-md border transition-all duration-200 hover:scale-[1.03] active:scale-95 ${x||R?"border-[var(--primary)] bg-[var(--bg-input)] text-[var(--text-main)] shadow-sm":"border-[var(--border)] text-[var(--text-muted)] hover:bg-[var(--bg-input)] hover:text-[var(--text-main)]"}`,children:e.jsx("span",{className:"grid h-4 w-4 place-items-center transition-transform duration-200",children:x||R?e.jsx(w.HiXMark,{className:"h-4 w-4"}):e.jsx(w.HiMagnifyingGlass,{className:"h-4 w-4"})})})]})]})]})}),e.jsx("div",{role:"tablist","aria-label":g??"Modulos relacionados",className:`flex gap-1 overflow-x-auto border-b border-[var(--border)] bg-[var(--bg-input)] px-2 py-1.5 transition-colors duration-200 ${U}`,children:le.length>0?le.map(L=>{const ie=L.service===(X==null?void 0:X.service);return e.jsx("button",{type:"button",role:"tab","aria-selected":ie,disabled:L.disabled,onClick:()=>we(L),onKeyDown:se=>Pe(se,L),className:`inline-flex h-9 min-w-max items-center gap-2 rounded-md border px-3 text-xs font-semibold transition-all duration-200 disabled:cursor-not-allowed disabled:opacity-50 ${ie?"border-[var(--primary)] bg-[var(--bg-card)] text-[var(--text-main)] shadow-sm":"border-transparent text-[var(--text-muted)] hover:bg-[var(--bg-card)] hover:text-[var(--text-main)]"}`,children:W?W(L,ie):e.jsxs(e.Fragment,{children:[L.icon,e.jsx("span",{children:L.label??$r(L.service)}),L.badge&&e.jsx("span",{className:"rounded-full bg-[var(--bg-input)] px-1.5 py-0.5 text-[10px] text-[var(--text-muted)]",children:L.badge})]})},L.service)}):e.jsx("div",{className:"flex min-h-9 flex-1 items-center rounded-md border border-dashed border-[var(--border)] px-3 text-xs text-[var(--text-muted)]",children:P??"No hay modulos que coincidan con la busqueda."})}),(X==null?void 0:X.description)&&e.jsx("div",{className:"border-b border-[var(--border)] px-4 py-2 text-xs text-[var(--text-muted)]",children:X.description}),e.jsxs("div",{className:"min-h-[420px] p-4",children:[!X&&(m??e.jsx("div",{className:"flex min-h-[220px] items-center justify-center rounded-lg border border-dashed border-[var(--border)] text-sm text-[var(--text-muted)]",children:"No hay modulos disponibles."})),X&&(ne==null?void 0:ne.loading)&&(h??e.jsx(Cr,{title:"Cargando modulo..."})),X&&(ne==null?void 0:ne.error)&&E(ne.error,Be),X&&Ae&&!(ne!=null&&ne.loading)&&!(ne!=null&&ne.error)&&e.jsx(Ae,{context:s,parent:n,link:X,activeItemId:_e,onOpenDetail:Ve,onBackToList:je})]})]})]})}const Ot={info:{color:"#2563eb",background:"rgba(59, 130, 246, 0.1)",border:"rgba(59, 130, 246, 0.24)",icon:e.jsx(w.HiInformationCircle,{className:"h-5 w-5"})},success:{color:"#047857",background:"rgba(16, 185, 129, 0.1)",border:"rgba(16, 185, 129, 0.24)",icon:e.jsx(w.HiCheckCircle,{className:"h-5 w-5"})},warning:{color:"#b45309",background:"rgba(245, 158, 11, 0.12)",border:"rgba(245, 158, 11, 0.26)",icon:e.jsx(w.HiExclamationTriangle,{className:"h-5 w-5"})},danger:{color:"var(--danger)",background:"var(--danger-bg)",border:"color-mix(in srgb, var(--danger) 20%, var(--border))",icon:e.jsx(w.HiExclamationCircle,{className:"h-5 w-5"})},neutral:{color:"var(--text-secondary)",background:"var(--bg-input)",border:"var(--border)",icon:e.jsx(w.HiInformationCircle,{className:"h-5 w-5"})}};function It({variant:r="info",title:t,children:a,icon:n,action:s,onDismiss:c,className:d=""}){const i=Ot[r];return e.jsxs("div",{role:r==="danger"||r==="warning"?"alert":"status",className:`flex items-start gap-3 rounded-lg border px-3 py-3 ${d}`,style:{background:i.background,borderColor:i.border},children:[e.jsx("div",{className:"mt-0.5 shrink-0",style:{color:i.color},children:n??i.icon}),e.jsxs("div",{className:"min-w-0 flex-1",children:[t&&e.jsx("div",{className:"text-sm font-semibold text-[var(--text-main)]",children:t}),a&&e.jsx("div",{className:"mt-0.5 text-sm leading-5 text-[var(--text-secondary)]",children:a}),s&&e.jsx("div",{className:"mt-3",children:s})]}),c&&e.jsx(ce,{variant:"icon",size:"xs","aria-label":"Cerrar alerta",onClick:c,className:"-mr-1 -mt-1",children:e.jsx(w.HiXMark,{className:"h-4 w-4"})})]})}const Dr=["Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre"],zt=["Ene","Feb","Mar","Abr","May","Jun","Jul","Ago","Sep","Oct","Nov","Dic"],Pt=["Do","Lu","Ma","Mi","Ju","Vi","Sá"],nr=6;function or(r,t,a){return`${r}-${String(t).padStart(2,"0")}-${String(a).padStart(2,"0")}`}function _t(){const r=new Date;return or(r.getFullYear(),r.getMonth()+1,r.getDate())}function Hr(r){const[t,a,n]=r.split("-").map(Number);return{year:t,month:a,day:n}}function jt(r){if(!r)return"Seleccionar fecha";const{year:t,month:a,day:n}=Hr(r);return!t||!a||!n?"Seleccionar fecha":`${String(n).padStart(2,"0")} ${Dr[a-1]} ${t}`}function Wt({value:r,onChange:t,minDate:a,displayMode:n="inline"}){const s=_t(),d=Hr(r||s),i=n==="popover",[p,b]=o.useState(!1),C=o.useRef(null),[k,y]=o.useState({horizontal:"left",vertical:"bottom"}),[g,u]=o.useState(d.year),[m,h]=o.useState(d.month),[E,W]=o.useState("days"),z=16,[T,N]=o.useState(0),$=g-7+T,B=Array.from({length:z},(f,H)=>$+H);o.useEffect(()=>{if(!i||!p||!C.current)return;const f=C.current.getBoundingClientRect(),H=8,G=280,K=340,Z=f.left+G>window.innerWidth-H,ae=f.right-G>=H,ue=f.bottom+8+K>window.innerHeight-H,x=f.top-8-K>=H;y({horizontal:Z&&ae?"right":"left",vertical:ue&&x?"top":"bottom"})},[i,p]),o.useEffect(()=>{if(!i||!p)return;function f(G){C.current&&(C.current.contains(G.target)||b(!1))}function H(G){G.key==="Escape"&&b(!1)}return document.addEventListener("mousedown",f),document.addEventListener("keydown",H),()=>{document.removeEventListener("mousedown",f),document.removeEventListener("keydown",H)}},[i,p]);function P(){m===1?(u(f=>f-1),h(12)):h(f=>f-1)}function D(){m===12?(u(f=>f+1),h(1)):h(f=>f+1)}const M=new Date(g,m-1,1).getDay(),_=new Date(g,m,0).getDate(),I=[...Array(M).fill(null),...Array.from({length:_},(f,H)=>H+1)];for(;I.length<nr*7;)I.push(null);const U=I.slice(0,nr*7);function F(f){const H=or(g,m,f);a&&H<a||(t(H),i&&b(!1))}const J={background:"none",border:"none",cursor:"pointer",color:"var(--text-muted)",padding:4,borderRadius:6,display:"flex",alignItems:"center"},te=e.jsxs("div",{style:{background:"var(--bg-input)",border:"1px solid var(--border)",borderRadius:10,overflow:"hidden",userSelect:"none",width:280},children:[e.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 12px",borderBottom:"1px solid var(--border)"},children:E==="days"?e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:P,style:J,title:"Mes anterior",children:e.jsx(w.HiChevronLeft,{size:16})}),e.jsxs("button",{type:"button",onClick:()=>{W("years"),N(0)},style:{background:"none",border:"none",cursor:"pointer",display:"flex",alignItems:"center",gap:4,fontSize:13,fontWeight:700,color:"var(--text-main)",borderRadius:6,padding:"2px 6px"},children:[Dr[m-1]," ",g,e.jsx(w.HiChevronDown,{size:13,style:{color:"var(--text-muted)"}})]}),e.jsx("button",{type:"button",onClick:D,style:J,title:"Mes siguiente",children:e.jsx(w.HiChevronRight,{size:16})})]}):e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:()=>N(f=>f-z),style:J,children:e.jsx(w.HiChevronLeft,{size:16})}),e.jsxs("button",{type:"button",onClick:()=>W("days"),style:{background:"none",border:"none",cursor:"pointer",fontSize:13,fontWeight:700,color:"var(--text-main)",borderRadius:6,padding:"2px 6px"},children:[B[0]," – ",B[B.length-1]]}),e.jsx("button",{type:"button",onClick:()=>N(f=>f+z),style:J,children:e.jsx(w.HiChevronRight,{size:16})})]})}),E==="years"&&e.jsxs("div",{style:{padding:"8px 10px 10px"},children:[e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(4,1fr)",gap:3,marginBottom:8},children:zt.map((f,H)=>{const G=H+1===m;return e.jsx("button",{type:"button",onClick:()=>h(H+1),style:{border:"none",cursor:"pointer",borderRadius:6,fontSize:11,fontWeight:G?700:400,padding:"4px 0",background:G?"var(--primary)":"transparent",color:G?"var(--primary-fg, #ffffff)":"var(--text-secondary)"},children:f},f)})}),e.jsx("div",{style:{height:1,background:"var(--border)",marginBottom:8}}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(4,1fr)",gap:3},children:B.map(f=>{const H=f===g;return e.jsx("button",{type:"button",onClick:()=>{u(f),W("days")},style:{border:"none",cursor:"pointer",borderRadius:6,fontSize:12,fontWeight:H?700:400,padding:"6px 0",background:H?"var(--primary)":"transparent",color:H?"var(--primary-fg, #ffffff)":"var(--text-main)",outline:f===new Date().getFullYear()&&!H?"2px solid var(--primary)":"none",outlineOffset:"-2px"},children:f},f)})})]}),E==="days"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(7,1fr)",padding:"6px 8px 0"},children:Pt.map(f=>e.jsx("div",{style:{textAlign:"center",fontSize:10,fontWeight:700,color:"var(--text-muted)",padding:"2px 0",textTransform:"uppercase"},children:f},f))}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(7,1fr)",gridTemplateRows:`repeat(${nr},1fr)`,padding:"4px 8px 10px",gap:2},children:U.map((f,H)=>{if(f===null)return e.jsx("div",{style:{aspectRatio:"1"}},H);const G=or(g,m,f),K=G===r,Z=G===s,ae=!!(a&&G<a);return e.jsx("button",{type:"button",onClick:()=>!ae&&F(f),style:{width:"100%",aspectRatio:"1",borderRadius:6,border:"none",cursor:ae?"not-allowed":"pointer",fontSize:12,fontWeight:K||Z?700:400,background:K?"var(--primary)":"transparent",color:K?"var(--primary-fg, #ffffff)":ae?"var(--text-muted)":"var(--text-main)",opacity:ae?.4:1,outline:Z&&!K?"2px solid var(--primary)":"none",outlineOffset:"-2px"},children:f},H)})})]})]});return i?e.jsxs("div",{ref:C,className:"relative w-full",children:[e.jsxs("button",{type:"button",onClick:()=>b(f=>!f),className:"flex h-10 w-full items-center justify-between gap-2 rounded-lg px-2.5 py-0 text-sm transition-all duration-150 focus:outline-none",style:{background:"var(--bg-input)",border:`1px solid ${p?"var(--primary)":"var(--border)"}`,color:"var(--text-main)",boxShadow:p?"0 0 0 3px rgba(59,130,246,0.12)":"none"},children:[e.jsxs("span",{className:"inline-flex items-center gap-2 min-w-0",children:[e.jsx(w.HiCalendarDays,{className:"w-4 h-4 text-[var(--text-muted)]"}),e.jsx("span",{className:"truncate",children:jt(r)})]}),e.jsx(w.HiChevronDown,{className:`w-4 h-4 text-[var(--text-muted)] transition-transform ${p?"rotate-180":""}`})]}),p&&e.jsx("div",{className:"absolute z-50",style:{...k.horizontal==="left"?{left:0}:{right:0},...k.vertical==="bottom"?{top:"calc(100% + 8px)"}:{bottom:"calc(100% + 8px)"}},children:te})]}):te}const Ft={sm:"h-4 w-4",md:"h-5 w-5"};function Ut({label:r,description:t,error:a,size:n="md",className:s="",containerClassName:c="",disabled:d,...i}){return e.jsxs("label",{className:`group inline-flex items-start gap-2.5 ${d?"cursor-not-allowed opacity-60":"cursor-pointer"} ${c}`,children:[e.jsxs("span",{className:"relative mt-0.5 inline-flex shrink-0",children:[e.jsx("input",{...i,type:"checkbox",disabled:d,"aria-invalid":!!a||i["aria-invalid"],className:`peer ${Ft[n]} appearance-none rounded border border-[var(--border)] bg-[var(--bg-input)] transition-colors checked:border-[var(--primary)] checked:bg-[var(--primary)] focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--primary)]/40 ${s}`}),e.jsx(w.HiCheck,{className:"pointer-events-none absolute left-1/2 top-1/2 h-3.5 w-3.5 -translate-x-1/2 -translate-y-1/2 scale-75 text-[var(--primary-fg)] opacity-0 transition peer-checked:scale-100 peer-checked:opacity-100"})]}),(r||t||a)&&e.jsxs("span",{className:"min-w-0",children:[r&&e.jsx("span",{className:"block text-sm font-medium leading-5 text-[var(--text-main)]",children:r}),t&&!a&&e.jsx("span",{className:"block text-xs leading-5 text-[var(--text-muted)]",children:t}),a&&e.jsx("span",{className:"block text-xs leading-5 text-[var(--danger)]",children:a})]})]})}function Lr(r){const t=document.createElement("textarea");t.value=r,t.style.position="fixed",t.style.opacity="0",t.style.pointerEvents="none",document.body.appendChild(t),t.select(),document.execCommand("copy"),document.body.removeChild(t)}async function qt(r){var t;if((t=navigator.clipboard)!=null&&t.writeText){await navigator.clipboard.writeText(r);return}Lr(r)}function Gt(r){return typeof r=="function"?r():r}function sr({value:r,resetDelay:t=2e3,title:a,copiedTitle:n="Copiado",copiedLabel:s,icon:c=e.jsx(w.HiClipboardDocument,{size:14}),copiedIcon:d=e.jsx(w.HiCheck,{size:14}),stopPropagation:i=!0,onCopied:p,onCopyError:b,className:C="",style:k,children:y,onClick:g,type:u="button",...m}){const[h,E]=o.useState(!1),W=o.useRef(null);o.useEffect(()=>()=>{W.current&&window.clearTimeout(W.current)},[]);function z(N){E(!0),p==null||p(N),W.current&&window.clearTimeout(W.current),W.current=window.setTimeout(()=>{E(!1),W.current=null},t)}async function T(N){var B;if(i&&N.stopPropagation(),g==null||g(N),N.defaultPrevented)return;const $=Gt(r);if($)try{await qt($),z($)}catch(P){try{Lr($),z($)}catch(D){b==null||b(D,$);return}(B=navigator.clipboard)!=null&&B.writeText||b==null||b(P,$)}}return e.jsxs("button",{...m,type:u,onClick:T,title:h?n:a,"aria-label":m["aria-label"]??(h?n:a),"data-copied":h?"true":void 0,className:`relative inline-flex h-7 shrink-0 items-center justify-center gap-1.5 rounded-md transition-all duration-200 ${y?"min-w-7 px-2":"w-7"} ${C}`,style:{cursor:"pointer",background:h?"rgba(22,163,74,0.15)":"var(--bg-card)",border:h?"1px solid rgba(22,163,74,0.4)":"1px solid var(--border)",color:h?"#16a34a":"var(--text-secondary)",boxShadow:h?"0 0 0 3px rgba(22,163,74,0.12)":"none",...k},children:[e.jsx("span",{className:"inline-flex items-center justify-center transition-all duration-150",style:{transform:h?"scale(1.15)":"scale(1)"},children:h?d:c}),y&&e.jsx("span",{className:"text-xs font-semibold leading-none",children:h?s??y:y})]})}function Xt({code:r,children:t,title:a="Codigo",language:n,copyLabel:s="Copiar",copiedLabel:c="Copiado",className:d="",style:i,onCopied:p}){const b=(r??t??"").trim();return e.jsxs("div",{className:`overflow-hidden rounded-lg border ${d}`,style:{borderColor:"rgba(148, 163, 184, 0.22)",background:"#0f172a",color:"#e2e8f0",...i},children:[e.jsxs("div",{className:"flex min-h-9 items-center justify-between gap-3 border-b px-3 py-1.5",style:{borderColor:"rgba(148, 163, 184, 0.18)",background:"#111827",color:"#94a3b8"},children:[e.jsx("span",{className:"min-w-0 truncate text-[11px] font-black uppercase tracking-[0.08em]",children:a}),e.jsx(sr,{value:b,title:"Copiar codigo",copiedTitle:"Codigo copiado",copiedLabel:c,onCopied:p,className:"h-7 min-w-[72px] px-2",style:{background:"#182235",border:"1px solid rgba(148, 163, 184, 0.28)",color:"#f8fafc"},children:s})]}),e.jsx("pre",{className:"m-0 overflow-x-auto p-3 text-xs leading-6",style:{background:"#0f172a",color:"#e2e8f0",fontFamily:'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace'},children:e.jsx("code",{className:n?`language-${n}`:void 0,children:b})})]})}function Tr(r){if(r!==void 0)return typeof r=="number"?`${r}px`:r}function lr({value:r,onChange:t,options:a,placeholder:n="Seleccionar…",emptyLabel:s,disabled:c=!1,className:d="",style:i,height:p=40,padding:b="0 10px",searchable:C=!0,minOptionsForSearch:k=6}){const[y,g]=o.useState(!1),[u,m]=o.useState(""),[h,E]=o.useState(-1),[W,z]=o.useState(!1),[T,N]=o.useState({}),$=o.useRef(null),B=o.useRef(null),P=o.useRef(null),D=o.useRef(null),M=C&&a.length>=k,_=a.find(f=>f.value===r)??null,I=M&&u.trim()?a.filter(f=>{var H;return f.label.toLowerCase().includes(u.toLowerCase())||((H=f.sublabel)==null?void 0:H.toLowerCase().includes(u.toLowerCase()))}):a,U=o.useCallback(()=>{const f=$.current;if(!f)return;const H=f.getBoundingClientRect(),G=M?272:212,K=window.innerHeight-H.bottom,Z=K<G&&H.top>K;N({position:"fixed",left:H.left,top:Z?void 0:H.bottom+4,bottom:Z?window.innerHeight-H.top+4:void 0,width:H.width,zIndex:9999})},[M]);o.useEffect(()=>z(!0),[]),o.useEffect(()=>{if(!y)return;function f(H){var K,Z;const G=H.target;!((K=$.current)!=null&&K.contains(G))&&!((Z=B.current)!=null&&Z.contains(G))&&(g(!1),m(""))}return document.addEventListener("mousedown",f),()=>document.removeEventListener("mousedown",f)},[y]),o.useEffect(()=>{y&&(E(-1),U(),M&&setTimeout(()=>{var f;return(f=P.current)==null?void 0:f.focus()},0))},[y,M,U]),o.useEffect(()=>{if(y)return window.addEventListener("resize",U),window.addEventListener("scroll",U,!0),()=>{window.removeEventListener("resize",U),window.removeEventListener("scroll",U,!0)}},[y,U]),o.useEffect(()=>{if(h<0||!D.current)return;const f=D.current.children[h];f==null||f.scrollIntoView({block:"nearest"})},[h]);const F=o.useCallback(f=>{t(f),g(!1),m("")},[t]);function J(f){if(!y){(f.key==="Enter"||f.key===" "||f.key==="ArrowDown")&&(f.preventDefault(),g(!0));return}f.key==="Escape"?(f.preventDefault(),g(!1),m("")):f.key==="ArrowDown"?(f.preventDefault(),E(H=>Math.min(H+1,I.length-1))):f.key==="ArrowUp"?(f.preventDefault(),E(H=>Math.max(H-1,s?-1:0))):f.key==="Enter"&&(f.preventDefault(),h===-1&&s?F(""):I[h]&&F(I[h].value))}const te=e.jsxs("div",{ref:B,className:"rounded-xl shadow-xl overflow-hidden",style:{...T,background:"var(--bg-card)",border:"1px solid var(--border)"},children:[M&&e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",style:{borderBottom:"1px solid var(--border)"},children:[e.jsx(w.HiMagnifyingGlass,{className:"w-3.5 h-3.5 flex-shrink-0",style:{color:"var(--text-muted)"}}),e.jsx("input",{ref:P,value:u,onChange:f=>{m(f.target.value),E(-1)},placeholder:"Buscar…",className:"min-w-0 flex-1 text-sm bg-transparent outline-none",style:{color:"var(--text-main)"}}),u&&e.jsx("button",{type:"button",onMouseDown:f=>{f.preventDefault(),m("")},children:e.jsx(w.HiXMark,{className:"w-3.5 h-3.5",style:{color:"var(--text-muted)"}})})]}),e.jsxs("ul",{ref:D,role:"listbox",className:"overflow-y-auto",style:{maxHeight:M?220:180,scrollbarWidth:"thin",scrollbarColor:"var(--border) transparent",overscrollBehavior:"contain"},children:[s&&e.jsx("li",{role:"option","aria-selected":r==="",onMouseDown:f=>{f.preventDefault(),F("")},onMouseEnter:()=>E(-1),className:"flex items-center gap-2 px-3 py-2 cursor-pointer text-sm transition-colors",style:{background:h===-1?"var(--bg-hover)":"transparent",color:"var(--text-muted)",fontStyle:"italic"},children:s}),I.map((f,H)=>{const K=H===h,Z=f.value===r;return e.jsxs("li",{role:"option","aria-selected":Z,onMouseDown:ae=>{ae.preventDefault(),f.disabled||F(f.value)},onMouseEnter:()=>!f.disabled&&E(H),className:"flex items-center gap-2 px-3 py-2 cursor-pointer text-sm transition-colors",style:{background:K?"var(--bg-hover)":Z?"color-mix(in srgb, var(--primary) 6%, transparent)":"transparent",color:f.disabled?"var(--text-muted)":"var(--text-main)",cursor:f.disabled?"not-allowed":"pointer",boxShadow:Z?"inset 2px 0 0 var(--primary)":void 0},children:[f.color&&e.jsx("span",{className:"flex-shrink-0 w-2.5 h-2.5 rounded-full",style:{background:f.color}}),e.jsxs("span",{className:"min-w-0 flex flex-1 items-baseline gap-1 overflow-hidden",children:[e.jsx("span",{className:"truncate",children:f.label}),f.sublabel&&e.jsx("span",{className:"min-w-0 flex-shrink truncate",style:{color:"var(--text-muted)",fontSize:12},children:f.sublabel})]}),f.badge&&e.jsx("span",{className:"text-xs flex-shrink-0",style:{color:"var(--text-muted)"},children:f.badge})]},f.value)}),I.length===0&&e.jsx("li",{className:"px-3 py-4 text-sm text-center",style:{color:"var(--text-muted)"},children:"Sin resultados"})]})]});return e.jsxs("div",{ref:$,className:`relative ${d||"w-full"}`,style:i,onKeyDown:J,children:[e.jsxs("button",{type:"button",disabled:c,onClick:()=>!c&&g(f=>!f),className:"flex w-full items-center gap-2 rounded-lg text-left text-sm transition-colors focus:outline-none",style:{height:Tr(p),padding:Tr(b),background:"var(--bg-input)",color:_?"var(--text-main)":"var(--text-muted)",border:y?"1px solid var(--primary)":"1px solid var(--border)",opacity:c?.5:1,cursor:c?"not-allowed":"pointer"},"aria-haspopup":"listbox","aria-expanded":y,children:[(_==null?void 0:_.color)&&e.jsx("span",{className:"flex-shrink-0 w-2.5 h-2.5 rounded-full",style:{background:_.color}}),e.jsx("span",{className:"min-w-0 flex flex-1 items-baseline gap-1 overflow-hidden",children:_?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"truncate",children:_.label}),_.sublabel&&e.jsx("span",{className:"min-w-0 flex-shrink truncate",style:{color:"var(--text-muted)",fontSize:12},children:_.sublabel})]}):e.jsx("span",{className:"truncate",children:n})}),_&&s?e.jsx("span",{role:"button",tabIndex:-1,onMouseDown:f=>{f.preventDefault(),f.stopPropagation(),F("")},className:"flex-shrink-0 rounded-full p-0.5 transition-colors hover:bg-black/10",style:{color:"var(--text-muted)"},children:e.jsx(w.HiXMark,{className:"w-3 h-3"})}):e.jsx(w.HiChevronDown,{className:"flex-shrink-0 w-4 h-4 transition-transform",style:{color:"var(--text-muted)",transform:y?"rotate(180deg)":"rotate(0deg)"}})]}),y&&W&&Ce.createPortal(te,document.body)]})}function Ue(r){if(r!==void 0)return typeof r=="number"?`${r}px`:r}function Yt({value:r,onChange:t,placeholder:a="Buscar...",className:n="",height:s=40,padding:c="0 10px 0 30px",iconLeft:d=10}){return e.jsxs("div",{className:`relative ${n}`,children:[e.jsx(w.HiMagnifyingGlass,{className:"absolute top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-[var(--text-muted)] pointer-events-none",style:{left:Ue(d)}}),e.jsx("input",{type:"text",value:r,onChange:i=>t(i.target.value),placeholder:a,className:"w-full rounded-lg border border-[var(--border)] [background:var(--bg-card)] text-sm text-[var(--text-main)] placeholder:text-[var(--text-muted)] outline-none transition-[border-color,box-shadow] focus:border-primary focus:ring-2 focus:ring-primary/20",style:{height:Ue(s),padding:Ue(c)}})]})}function Vt({value:r,onChange:t,options:a,placeholder:n,icon:s,className:c="",height:d=40,padding:i,iconLeft:p=10,searchable:b=!0}){const C=s?a.map((k,y)=>y===0&&!k.color?{...k,sublabel:k.sublabel??void 0}:k):a;return e.jsxs("div",{className:`relative ${c}`,children:[s&&e.jsx("span",{className:"pointer-events-none absolute top-1/2 z-10 -translate-y-1/2 text-[var(--text-muted)]",style:{left:Ue(p)},children:s}),e.jsx(lr,{value:r,onChange:t,options:C,placeholder:n,searchable:b,minOptionsForSearch:5,height:d,padding:i??(s?"0 10px 0 30px":"0 10px"),className:"[&>button]:text-sm [&>button]:[background:var(--bg-card)]"})]})}const Kt={sm:"24rem",md:"28rem",lg:"32rem",xl:"40rem","2xl":"48rem","4xl":"56rem","5xl":"64rem"},qe=180;function Br({open:r,onClose:t,title:a,subtitle:n,leadingIcon:s,headerActions:c,footer:d,children:i,size:p="md",maxWidth:b,zIndex:C=1e3,closeOnBackdrop:k=!0,closeOnEscape:y=!0,showCloseButton:g=!0,placement:u="center",bodyClassName:m="px-6 py-5",panelClassName:h="",backdropClassName:E="bg-black/50 backdrop-blur-sm",contentClassName:W="p-4",ariaLabel:z,frameless:T=!1}){const[N,$]=o.useState(!1),[B,P]=o.useState(!1),D=o.useRef(null);if(o.useEffect(()=>(r?(D.current&&clearTimeout(D.current),$(!0),requestAnimationFrame(()=>requestAnimationFrame(()=>P(!0)))):(P(!1),D.current=setTimeout(()=>$(!1),qe+40)),()=>{D.current&&clearTimeout(D.current)}),[r]),o.useEffect(()=>{if(r)return document.body.style.overflow="hidden",()=>{document.body.style.overflow=""}},[r]),o.useEffect(()=>{if(!r||!y)return;const J=te=>{te.key==="Escape"&&t()};return window.addEventListener("keydown",J),()=>window.removeEventListener("keydown",J)},[y,t,r]),!N)return null;const M=a||n||s||c||g,_=b??Kt[p],I=u==="bottom-mobile"?"items-end sm:items-center justify-center p-0 sm:p-4":"items-center justify-center",U=u==="bottom-mobile"?"rounded-t-2xl sm:rounded-2xl":"rounded-2xl",F=B?"translateY(0) scale(1)":u==="bottom-mobile"?"translateY(16px) scale(0.98)":"translateY(10px) scale(0.96)";return Ce.createPortal(e.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":z??a,className:`fixed inset-0 flex ${I} ${W}`,style:{zIndex:C},children:[e.jsx("div",{className:`absolute inset-0 ${E}`,onClick:k?t:void 0,style:{opacity:B?1:0,transition:`opacity ${qe}ms ease`}}),e.jsxs("div",{className:`relative z-10 flex max-h-[92dvh] w-full flex-col overflow-hidden ${T?"shadow-none":"shadow-2xl"} ${U} ${h}`,style:{maxWidth:_,background:T?"transparent":"var(--bg-card)",border:T?"none":"1px solid var(--border)",opacity:B?1:0,transform:F,transition:`opacity ${qe}ms ease, transform ${qe}ms ease`},onClick:J=>J.stopPropagation(),children:[M&&e.jsxs("div",{className:"flex flex-shrink-0 items-center justify-between gap-3 px-6 py-4",style:{borderBottom:"1px solid var(--border)"},children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[s&&e.jsx("div",{className:"flex-shrink-0",children:s}),(a||n)&&e.jsxs("div",{className:"min-w-0",children:[a&&e.jsx("h2",{className:"truncate text-base font-semibold",style:{color:"var(--text-main)"},children:a}),n&&e.jsx("p",{className:"truncate text-xs",style:{color:"var(--text-muted)"},children:n})]})]}),e.jsxs("div",{className:"flex flex-shrink-0 items-center gap-2",children:[c,g&&e.jsx(ce,{variant:"icon",onClick:t,title:"Cerrar",children:e.jsx(w.HiXMark,{className:"h-5 w-5"})})]})]}),e.jsx("div",{className:`min-h-0 flex-1 overflow-y-auto ${m}`,children:i}),d&&e.jsx("div",{className:"flex flex-shrink-0 justify-end gap-2 px-6 py-4",style:{borderTop:"1px solid var(--border)"},children:d})]})]}),document.body)}const Zt={danger:{iconBg:"rgba(239,68,68,0.12)",iconColor:"var(--danger)",btnBg:"var(--danger)",btnColor:"#fff"},warning:{iconBg:"rgba(245,158,11,0.12)",iconColor:"var(--warning)",btnBg:"var(--warning)",btnColor:"#fff"},primary:{iconBg:"rgba(59,130,246,0.12)",iconColor:"var(--primary)",btnBg:"var(--primary)",btnColor:"#fff"}};function Jt({open:r,title:t,description:a,confirmLabel:n="Confirmar",cancelLabel:s="Cancelar",variant:c="danger",onConfirm:d,onCancel:i}){const p=Zt[c];return e.jsxs(Br,{open:r,onClose:i,size:"sm",zIndex:9998,showCloseButton:!1,bodyClassName:"p-6",panelClassName:"px-1",ariaLabel:t,children:[e.jsx(ce,{variant:"icon",onClick:i,className:"absolute right-3 top-3 h-7 w-7 hover:opacity-70",style:{color:"var(--text-muted)"},"aria-label":"Cancelar",children:e.jsx(w.HiXMark,{className:"h-4 w-4"})}),e.jsx("div",{className:"mb-4 flex h-11 w-11 items-center justify-center rounded-xl",style:{background:p.iconBg},children:e.jsx(w.HiExclamationTriangle,{className:"h-5 w-5",style:{color:p.iconColor}})}),e.jsx("h2",{className:"mb-1 text-base font-semibold",style:{color:"var(--text-main)"},children:t}),a&&e.jsx("p",{className:"text-sm",style:{color:"var(--text-muted)"},children:a}),e.jsxs("div",{className:"mt-6 flex gap-2",children:[e.jsx(ce,{variant:"secondary",onClick:i,className:"flex-1",style:{background:"var(--bg-input)"},children:s}),e.jsx(ce,{variant:"danger",onClick:d,className:"flex-1",style:{background:p.btnBg,color:p.btnColor,borderColor:"transparent"},children:n})]})]})}function Qt(r,t){const a=typeof r=="function"?r():r;return t?t(a):a}function Rt({url:r,resolveUrl:t,title:a="Copiar link",copiedTitle:n="Link copiado",icon:s=e.jsx(w.HiLink,{className:"h-3.5 w-3.5"}),...c}){return e.jsx(sr,{...c,value:()=>Qt(r,t),title:a,copiedTitle:n,icon:s})}const ea="[&_button]:h-7 [&_button]:min-h-0 [&_button]:gap-1 [&_button]:px-2 [&_button]:text-xs [&_button_svg]:h-3.5 [&_button_svg]:w-3.5 [&_button[data-icon=true]]:w-7 [&_button[data-icon=true]]:px-0",ra=[];function Ee(r){if(!r)return 150;const t=parseInt(r,10);return isNaN(t)||t<=0?150:t}function $e(r,t){const a=r.minWidth??80,n=r.maxWidth??1/0;return Math.min(n,Math.max(a,t))}function ta(r,t){if(t<=7)return Array.from({length:t},(n,s)=>s+1);const a=[1];r>3&&a.push("...");for(let n=Math.max(2,r-1);n<=Math.min(t-1,r+1);n++)a.push(n);return r<t-2&&a.push("..."),a.push(t),a}function Me(r,t){var d;const a=new Set(t.filter(i=>i.hideable!==!1).map(i=>i.key)),n=Array.from(new Set(r??[])).filter(i=>a.has(i));if(t.filter(i=>!n.includes(i.key)).length>0)return n;const c=(d=t.find(i=>i.hideable!==!1))==null?void 0:d.key;return c?n.filter(i=>i!==c):[]}function Ar({children:r,className:t="",style:a}){return e.jsx(Fe,{onlyWhenOverflow:!0,className:t,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",...a},children:r})}function aa({columns:r,data:t,getRowId:a,loading:n=!1,skeletonRows:s=8,emptyIcon:c,emptyText:d="Sin resultados",initialEmptyDelay:i=450,onRowClick:p,selected:b,onToggleOne:C,onToggleAll:k,highlightSelected:y=!0,rowClassName:g,getRowCategory:u,stickyHeader:m=!0,pageSize:h=25,pageSizeOptions:E=[25,50,100],pageSizeSelectWidth:W=62,pageSizeSelectHeight:z=30,pageSizeSelectPadding:T="0 7px",totalRows:N,page:$,onPageChange:B,onPageSizeChange:P,storageKey:D,stickyFirstColumn:M=!1,bottomOffset:_=0,compact:I=!0,restrictHeight:U=!0,minTableWidth:F,enableColumnVisibility:J=!0,hiddenColumnKeys:te,defaultHiddenColumnKeys:f=ra,onHiddenColumnKeysChange:H,columnVisibilityLabel:G="Columnas"}){var bt;const K=r.map(l=>l.key).join(","),[Z,ae]=o.useState(!D),ue=o.useRef(null),x=o.useRef(!D),Y=te!==void 0,[be,ee]=o.useState(()=>Me(f,r)),Q=Me(Y?te:be,r),[O,V]=o.useState(!1),[R,le]=o.useState(null),[he,X]=o.useState({}),we=o.useRef(null),De=o.useRef(null),[Pe,Be]=o.useState(t.length>0||n||i===!1),_e=(l,v)=>50+(l*17+v*13+7)%40,ne=o.useRef(null),[Ae,Ve]=o.useState(void 0),[je,Ke]=o.useState(0),[We,Ze]=o.useState(!1);o.useEffect(()=>{const v=h!==!1?32:0,S=12;function j(){if(Ze(window.innerWidth<640),!ne.current)return;const q=ne.current.getBoundingClientRect().top;Ve(Math.max(120,window.innerHeight-q-v-S-_))}return j(),window.addEventListener("resize",j),()=>window.removeEventListener("resize",j)},[n,h,_]),o.useEffect(()=>{const l=ne.current;if(!l)return;const v=()=>Ke(l.clientWidth);if(v(),typeof ResizeObserver>"u")return window.addEventListener("resize",v),()=>window.removeEventListener("resize",v);const S=new ResizeObserver(v);return S.observe(l),()=>S.disconnect()},[n,Z,t.length]),o.useEffect(()=>{if(i===!1||n||t.length>0){Be(!0);return}if(Pe)return;const l=window.setTimeout(()=>{Be(!0)},i);return()=>window.clearTimeout(l)},[t.length,i,Pe,n]);const[L,ie]=o.useState(()=>r.map(l=>l.key)),[se,ye]=o.useState(()=>Object.fromEntries(r.map(l=>[l.key,$e(l,Ee(l.width))])));o.useEffect(()=>{const l=r.map(S=>S.key);if(!D){ie(l),Y||ee(Me(f,r)),x.current=!1,ae(!0);return}let v=!1;return x.current=!1,ae(!1),fetch(`/api/user/preferences/datatables?key=${encodeURIComponent(D)}`,{cache:"no-store"}).then(S=>S.ok?S.json():null).then(S=>{var tr,ht,mt;if(v)return;const j=(tr=S==null?void 0:S.settings)==null?void 0:tr.columnOrder,q=Array.isArray(j)?j.filter(ve=>l.includes(ve)):[],oe=l.filter(ve=>!q.includes(ve)),de=q.length>0?[...q,...oe]:l,Te=Object.fromEntries(r.map(ve=>[ve.key,$e(ve,Ee(ve.width))])),re=((ht=S==null?void 0:S.settings)==null?void 0:ht.columnWidths)??{},pe=Object.fromEntries(r.map(ve=>[ve.key,$e(ve,re[ve.key]??Te[ve.key])])),rr=Me(((mt=S==null?void 0:S.settings)==null?void 0:mt.hiddenColumnKeys)??f,r);ie(de),ye(pe),Y||ee(rr),ue.current=JSON.stringify({columnOrder:de,columnWidths:pe,hiddenColumnKeys:rr}),x.current=!0}).catch(()=>{if(!v){ie(l);const S=Object.fromEntries(r.map(q=>[q.key,$e(q,Ee(q.width))]));ye(S);const j=Me(f,r);Y||ee(j),ue.current=JSON.stringify({columnOrder:l,columnWidths:S,hiddenColumnKeys:j}),x.current=!0}}).finally(()=>{v||ae(!0)}),()=>{v=!0}},[D,K,r,f,Y]),o.useEffect(()=>{if(!D||!Z||!x.current)return;const l={columnOrder:L,columnWidths:se,hiddenColumnKeys:Q},v=JSON.stringify(l);if(v===ue.current)return;const S=window.setTimeout(()=>{fetch("/api/user/preferences/datatables",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({key:D,settings:l})}).then(j=>{j.ok&&(ue.current=v)}).catch(()=>{})},300);return()=>window.clearTimeout(S)},[L,se,Q,D,Z]),o.useEffect(()=>{ie(l=>{const v=r.map(q=>q.key),S=l.filter(q=>v.includes(q)),j=v.filter(q=>!S.includes(q));return[...S,...j]})},[K,r]);const fe=L.map(l=>r.find(v=>v.key===l)).filter(l=>!!l),me=fe.filter(l=>!Q.includes(l.key));function He(l){const v=Me(l,r);Y||ee(v),H==null||H(v)}function bn(l){He(Q.includes(l)?Q.filter(v=>v!==l):[...Q,l])}function hn(){He([])}const dr=o.useCallback((l=De.current)=>{if(!l)return;const v=l.getBoundingClientRect(),S=256,j=Math.min(Math.max(8,v.right-S),window.innerWidth-S-8),q=window.innerHeight-v.bottom,oe=q<288&&v.top>q?void 0:v.bottom+6,de=oe===void 0?window.innerHeight-v.top+6:void 0;X({position:"fixed",zIndex:9999,left:j,top:oe,bottom:de,width:S})},[]);function mn(l,v){l.preventDefault(),l.stopPropagation();const S=De.current===l.currentTarget&&R===v;if(O&&S){V(!1),le(null);return}De.current=l.currentTarget,le(v),dr(l.currentTarget),V(!0)}o.useEffect(()=>{ye(l=>{const v=Object.fromEntries(r.map(S=>[S.key,$e(S,Ee(S.width))]));return Object.fromEntries(r.map(S=>[S.key,$e(S,l[S.key]??v[S.key])]))})},[K,r]),o.useEffect(()=>{Y||ee(l=>Me(l,r))},[K,r,Y]),o.useEffect(()=>{function l(j){var oe,de;const q=j.target;!((oe=we.current)!=null&&oe.contains(q))&&!((de=De.current)!=null&&de.contains(q))&&(V(!1),le(null))}function v(j){j.key==="Escape"&&(V(!1),le(null))}function S(){dr()}return O&&(document.addEventListener("mousedown",l),window.addEventListener("keydown",v),window.addEventListener("resize",S),window.addEventListener("scroll",S,!0)),()=>{document.removeEventListener("mousedown",l),window.removeEventListener("keydown",v),window.removeEventListener("resize",S),window.removeEventListener("scroll",S,!0)}},[O,dr]);const Je=o.useRef(null);o.useEffect(()=>{function l(S){const j=Je.current;if(!j)return;const q=S.clientX-j.startX,oe=r.find(de=>de.key===j.colKey);oe&&ye(de=>({...de,[j.colKey]:$e(oe,j.startWidth+q)}))}function v(){Je.current&&(Je.current=null,document.body.style.cursor="",document.body.style.userSelect="")}return document.addEventListener("pointermove",l),document.addEventListener("pointerup",v),()=>{document.removeEventListener("pointermove",l),document.removeEventListener("pointerup",v)}},[r]);const Qe=o.useRef(null),[et,ur]=o.useState(null);function vn(l,v){Qe.current=L.indexOf(l),v.dataTransfer.effectAllowed="move"}function xn(l,v){v.preventDefault(),v.dataTransfer.dropEffect="move";const S=L.indexOf(l);et!==S&&ur(S)}function gn(l,v){v.preventDefault();const S=Qe.current,j=L.indexOf(l);S!==null&&S!==j&&ie(q=>{const oe=[...q],[de]=oe.splice(S,1);return oe.splice(j,0,de),oe}),Qe.current=null,ur(null)}function yn(){Qe.current=null,ur(null)}const[xe,rt]=o.useState(null);function wn(l){l.sortKey&&rt(v=>(v==null?void 0:v.key)===l.key?{key:l.key,dir:v.dir==="asc"?"desc":"asc"}:{key:l.key,dir:"asc"})}const[Nn,fr]=o.useState(1),[tt,kn]=o.useState(h===!1?0:h);o.useEffect(()=>{fr(1)},[t]);const Oe=!!(B&&P),Le=h!==!1,ge=Oe?$??1:Nn,Se=Oe||Le?tt:t.length,Ne=!!b&&!!C&&!!k,pr=Ne?40:0,Sn=Ne&&t.length>0&&b.size===t.length,Cn=Ne&&b.size>0&&b.size<t.length,br=o.useMemo(()=>{if(!xe)return t;const l=r.find(v=>v.key===xe.key&&v.sortKey);return l!=null&&l.sortKey?[...t].sort((v,S)=>{const j=v[l.sortKey],q=S[l.sortKey],oe=j===q?0:j==null?1:q==null||j<q?-1:1;return xe.dir==="asc"?oe:-oe}):t},[t,xe,r]),at=o.useMemo(()=>{if(Oe||!Le)return br;const l=(ge-1)*Se;return br.slice(l,l+Se)},[br,Oe,Le,ge,Se]),Ie=N??t.length,hr=Le?Math.max(1,Math.ceil(Ie/Se)):1,nt=Le&&Ie>Se,En=Le?(ge-1)*Se+1:1,$n=Le?Math.min(ge*Se,Ie):Ie;function mr(l){const v=Math.max(1,Math.min(l,hr));Oe?B(v):fr(v)}function Mn(l){kn(l),Oe?(P(l),B(1)):fr(1),P&&P(l)}const ot=l=>l==="center"?"text-center":l==="right"?"text-right":"text-left",Dn="color-mix(in srgb, var(--primary) 6%, var(--bg-card))",vr=me.reduce((l,v)=>l+(se[v.key]??Ee(v.width)),Ne?40:0),st=typeof F=="number"?F:typeof F=="string"?Number(((bt=F.match(/^(\d+(?:\.\d+)?)px$/))==null?void 0:bt[1])??NaN):NaN,Re=Number.isFinite(st)?Math.max(vr,st,je):Math.max(vr,je),lt=F??Re,Hn=me.length>0?Math.max(0,Re-vr)/me.length:0,er=`${Ne?"40px ":""}${me.map(l=>`${(se[l.key]??Ee(l.width))+Hn}px`).join(" ")}`;o.useEffect(()=>{xe&&Q.includes(xe.key)&&rt(null)},[Q,xe]);function it(l){return l?typeof l=="string"?{key:l,label:l}:l:null}const ct=()=>e.jsxs("div",{role:"row",className:"grid",style:{gridTemplateColumns:er,background:"color-mix(in srgb, var(--bg-input) 72%, transparent)"},children:[Ne&&e.jsx("div",{role:"columnheader",className:`${I?"px-2 py-1.5":"px-3 py-2.5"} w-10`,style:M?{position:"sticky",left:0,zIndex:12,background:"color-mix(in srgb, var(--bg-input) 72%, transparent)",backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)",boxShadow:"inset 0 -2px 0 var(--border)",borderRight:"1px solid var(--border)"}:{borderBottom:"2px solid var(--border)",borderRight:"1px solid var(--border)"},children:e.jsx("input",{type:"checkbox",checked:Sn,ref:l=>{l&&(l.indeterminate=Cn)},onChange:k,className:"rounded cursor-pointer accent-[var(--primary)]"})}),me.map((l,v)=>{const S=(xe==null?void 0:xe.key)===l.key,j=!!l.sortKey,q=M&&!We&&v===0,oe=et===v,Te=(se[l.key]??Ee(l.width))<120;return e.jsxs("div",{role:"columnheader",className:`group select-none ${Te?"text-left":ot(l.align)}`,style:{...q?{position:"sticky",left:pr,zIndex:12,background:"color-mix(in srgb, var(--bg-input) 72%, transparent)",backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)",boxShadow:"3px 0 6px -2px rgba(0,0,0,0.12), inset 0 -2px 0 var(--border)",borderRight:"1px solid var(--border)"}:{position:"relative",borderBottom:"2px solid var(--border)",borderRight:"1px solid var(--border)"},color:S?"var(--primary)":"var(--text-muted)",whiteSpace:"nowrap",transition:"color 0.15s",borderLeft:oe?"2px solid var(--primary)":"2px solid transparent",cursor:j?"pointer":"default",padding:I?"5px 20px 5px 12px":"7px 24px 7px 12px"},onDragOver:re=>xn(l.key,re),onDrop:re=>gn(l.key,re),onClick:j?()=>wn(l):void 0,children:[e.jsx("span",{draggable:!0,onDragStart:re=>{re.stopPropagation(),vn(l.key,re)},onDragEnd:re=>{re.stopPropagation(),yn()},onClick:re=>re.stopPropagation(),title:"Arrastrar para reordenar",className:`absolute left-2 top-1/2 inline-flex h-5 w-5 -translate-x-1/2 -translate-y-1/2 scale-75 items-center justify-center rounded-[1px] border bg-[var(--bg-card)] text-[var(--text-muted)] opacity-0 shadow-sm transition-[opacity,transform,background-color,border-color,color] duration-150 hover:border-[var(--primary)] hover:bg-[color-mix(in_srgb,var(--primary)_14%,var(--bg-card))] hover:text-[var(--primary)] group-hover:scale-100 group-hover:opacity-100 ${oe?"scale-100 border-[var(--primary)] bg-[color-mix(in_srgb,var(--primary)_14%,var(--bg-card))] text-[var(--primary)] opacity-100":"border-[var(--border)]"}`,style:{cursor:"grab",zIndex:5},children:e.jsx(vt.MdDragIndicator,{size:14})}),e.jsx(Ar,{className:"inline-block max-w-full align-middle",style:{width:"100%",textAlign:Te?"left":l.align==="center"?"center":l.align==="right"?"right":"left"},children:e.jsxs("span",{className:`inline-flex max-w-full items-center gap-1 font-semibold uppercase tracking-wider ${I?"text-[11px]":"text-xs"}`,children:[e.jsx("span",{className:"min-w-0 truncate",children:l.header}),j&&e.jsx("span",{className:"flex-shrink-0 opacity-60",children:S?xe.dir==="asc"?e.jsx(w.HiChevronUp,{className:"w-3 h-3"}):e.jsx(w.HiChevronDown,{className:"w-3 h-3"}):e.jsx(w.HiChevronUpDown,{className:"w-3 h-3 opacity-40"})})]})}),J&&e.jsx("button",{type:"button","aria-haspopup":"menu","aria-expanded":O&&R===l.key,"aria-label":G,title:G,onClick:re=>mn(re,l.key),className:`absolute right-3 top-1/2 inline-flex h-5 w-5 -translate-y-1/2 scale-75 items-center justify-center rounded-[1px] border bg-[var(--bg-card)] text-[var(--text-muted)] opacity-0 shadow-sm transition-[opacity,transform,background-color,border-color,color] duration-150 hover:border-[var(--primary)] hover:bg-[color-mix(in_srgb,var(--primary)_14%,var(--bg-card))] hover:text-[var(--primary)] focus:scale-100 focus:border-[var(--primary)] focus:bg-[color-mix(in_srgb,var(--primary)_14%,var(--bg-card))] focus:text-[var(--primary)] focus:opacity-100 group-hover:scale-100 group-hover:opacity-100 ${O&&R===l.key?"scale-100 border-[var(--primary)] bg-[color-mix(in_srgb,var(--primary)_14%,var(--bg-card))] text-[var(--primary)] opacity-100":"border-[var(--border)]"}`,style:{zIndex:4},children:e.jsx(w.HiEllipsisVertical,{className:"h-3.5 w-3.5"})}),e.jsx("span",{role:"separator","aria-orientation":"vertical",title:"Arrastrar para redimensionar",onPointerDown:re=>{re.preventDefault(),re.stopPropagation(),Je.current={colKey:l.key,startX:re.clientX,startWidth:se[l.key]??150},document.body.style.cursor="col-resize",document.body.style.userSelect="none"},onClick:re=>re.stopPropagation(),className:"absolute top-0 flex h-full items-center justify-center opacity-0 transition-opacity duration-150 group-hover:opacity-100",style:{right:0,width:8,cursor:"col-resize",zIndex:6},children:e.jsx("span",{style:{width:3,height:"calc(100% - 8px)",borderRadius:2,background:"var(--primary)",display:"block"}})})]},l.key)})]}),dt=()=>{if(!J||!O||typeof document>"u")return null;const l=Q.length;return Ce.createPortal(e.jsxs("div",{ref:we,role:"menu",className:"overflow-hidden rounded-lg border p-1 shadow-xl",style:{...he,borderColor:"var(--border)",background:"var(--bg-card)"},children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-[var(--border)] px-2 py-1.5",children:[e.jsx("span",{className:"min-w-0 truncate text-xs font-semibold uppercase text-[var(--text-muted)]",children:l>0?`${me.length} de ${r.length} visibles`:`${r.length} visibles`}),e.jsx("button",{type:"button",onClick:hn,disabled:l===0,className:"rounded px-1.5 py-0.5 text-xs font-medium text-[var(--primary)] transition-colors hover:bg-[var(--bg-input)] disabled:opacity-40",children:"Mostrar todas"})]}),e.jsx("div",{className:"max-h-72 overflow-auto py-1",children:fe.map(v=>{const S=!Q.includes(v.key),q=!(v.hideable!==!1)||S&&me.length<=1;return e.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":S,disabled:q,onClick:()=>bn(v.key),className:"flex w-full min-w-0 items-center gap-2 rounded-md px-2.5 py-1.5 text-left transition-colors hover:bg-[var(--bg-input)] disabled:cursor-not-allowed disabled:opacity-50",style:{color:"var(--text-main)"},children:[e.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center rounded border",style:{borderColor:S?"var(--primary)":"var(--border)",background:S?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:S&&e.jsx(w.HiCheck,{className:"h-3 w-3"})}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:v.header})]},v.key)})})]}),document.body)},ut=()=>{if(!nt||n)return null;const l=ta(ge,hr);return e.jsxs("div",{className:`grid grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)] items-center gap-2 rounded-b-xl border-t text-xs select-none ${I?"px-2 py-0.5":"px-3 py-1"}`,style:{borderColor:"var(--border)",background:"var(--bg-input)"},children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{style:{color:"var(--text-muted)"},children:Ie===0?"0 filas":`${En}–${$n} de ${Ie}`}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{style:{color:"var(--text-muted)"},children:"Filas:"}),e.jsx(lr,{value:String(Se),onChange:v=>Mn(Number(v)),options:E.map(v=>({value:String(v),label:String(v)})),placeholder:"Filas",searchable:!1,height:z,padding:T,className:"shrink-0 [&>button]:rounded-md [&>button]:text-xs [&_svg]:h-3.5 [&_svg]:w-3.5",style:{width:W}})]})]}),e.jsxs("div",{className:"flex items-center justify-center gap-0.5",children:[e.jsx("button",{disabled:ge<=1,onClick:()=>mr(ge-1),className:"rounded p-0.5 transition-colors disabled:opacity-30",style:{color:"var(--text-muted)",background:"transparent"},children:e.jsx(w.HiChevronLeft,{className:"h-3.5 w-3.5"})}),l.map((v,S)=>v==="..."?e.jsx("span",{className:"px-1",style:{color:"var(--text-muted)"},children:"…"},`e${S}`):e.jsx("button",{onClick:()=>mr(v),className:"h-5 w-5 rounded text-[11px] font-medium transition-colors",style:{background:v===ge?"var(--primary)":"transparent",color:v===ge?"var(--primary-fg)":"var(--text-muted)"},children:v},v)),e.jsx("button",{disabled:ge>=hr,onClick:()=>mr(ge+1),className:"rounded p-0.5 transition-colors disabled:opacity-30",style:{color:"var(--text-muted)",background:"transparent"},children:e.jsx(w.HiChevronRight,{className:"h-3.5 w-3.5"})})]}),e.jsx("div",{"aria-hidden":"true"})]})},ft=()=>e.jsx("div",{className:"w-full min-w-0 max-w-full flex flex-col rounded-xl overflow-hidden",style:{border:"1px solid var(--border)"},children:e.jsxs("div",{ref:ne,className:"min-w-0 max-w-full",style:{maxHeight:U?Ae:void 0,background:"var(--bg-card)"},children:[e.jsx("div",{className:"border-b px-3 py-2",style:{borderColor:"var(--border)",background:"color-mix(in srgb, var(--bg-input) 72%, transparent)"},children:e.jsx("div",{className:"h-3.5 w-40 animate-pulse rounded-full",style:{background:"var(--border)"}})}),e.jsx("div",{className:"space-y-2 p-3",children:Array.from({length:Math.min(6,s)}).map((l,v)=>e.jsx("div",{className:"grid grid-cols-[1.2fr_1fr_0.8fr_0.7fr] gap-3",children:Array.from({length:4}).map((S,j)=>e.jsx("div",{className:"h-3.5 animate-pulse rounded-full",style:{background:"var(--border)",width:`${_e(v,j)}%`,minWidth:32}},j))},v))})]})}),pt=`min-w-0 max-w-full overflow-hidden ${nt?"rounded-t-xl":"rounded-xl"}`;return D&&!Z||!n&&t.length===0&&!Pe?ft():n&&t.length===0?e.jsxs("div",{className:"w-full min-w-0 max-w-full flex flex-col rounded-xl overflow-visible",style:{border:"1px solid var(--border)"},children:[dt(),e.jsx("div",{ref:ne,className:pt,children:e.jsx(gr.OverlayScrollbarsComponent,{options:{scrollbars:{autoHide:"leave",autoHideDelay:200}},className:"w-full",style:{maxHeight:U?Ae:void 0,maxWidth:"100%"},defer:!0,children:e.jsxs("div",{role:"table",className:"text-sm",style:{width:Re,minWidth:lt},children:[e.jsx("div",{role:"rowgroup",style:m?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:ct()}),e.jsx("div",{role:"rowgroup",children:Array.from({length:s}).map((l,v)=>e.jsxs("div",{role:"row",className:"grid",style:{gridTemplateColumns:er},children:[Ne&&e.jsx("div",{role:"cell",className:`${I?"px-2 py-1.5":"px-3 py-2"} w-10`,style:{borderBottom:"1px solid var(--border)",borderRight:"1px solid var(--border)"}}),me.map((S,j)=>{const q=M&&!We&&j===0;return e.jsx("div",{role:"cell",className:I?"px-2 py-1.5":"px-3 py-2",style:q?{position:"sticky",left:pr,zIndex:1,background:"color-mix(in srgb, var(--bg-card) 72%, transparent)",backdropFilter:"blur(10px)",WebkitBackdropFilter:"blur(10px)",boxShadow:"3px 0 6px -2px rgba(0,0,0,0.12), inset 0 -1px 0 var(--border)",borderRight:"1px solid var(--border)"}:{borderBottom:"1px solid var(--border)",borderRight:"1px solid var(--border)"},children:e.jsx("div",{className:"h-3.5 rounded-full animate-pulse",style:{background:"var(--border)",width:`${_e(v,j)}%`,minWidth:32}})},S.key)})]},v))})]})})}),ut()]}):!n&&t.length===0?e.jsxs("div",{className:"flex min-h-[220px] flex-col items-center justify-center gap-3 rounded-xl border px-6 py-14 text-center",style:{borderColor:"var(--border)",background:"linear-gradient(180deg, color-mix(in srgb, var(--bg-input) 58%, transparent), var(--bg-card))"},children:[e.jsx("div",{className:"flex h-12 w-12 items-center justify-center rounded-full border",style:{borderColor:"color-mix(in srgb, var(--primary) 24%, var(--border))",background:"color-mix(in srgb, var(--primary) 8%, var(--bg-card))",color:"var(--primary)"},children:c??e.jsx(w.HiMagnifyingGlass,{className:"h-5 w-5"})}),e.jsx("p",{className:"max-w-sm text-sm font-medium",style:{color:"var(--text-main)"},children:d}),e.jsx("span",{className:"text-xs",style:{color:"var(--text-muted)"},children:"Ajusta la busqueda o cambia los filtros para ver mas informacion."})]}):e.jsxs("div",{className:"w-full min-w-0 max-w-full flex flex-col rounded-xl overflow-visible",style:{border:"1px solid var(--border)"},children:[dt(),e.jsx("div",{ref:ne,className:pt,children:e.jsx(gr.OverlayScrollbarsComponent,{options:{scrollbars:{autoHide:"leave",autoHideDelay:200}},className:"w-full",style:{maxHeight:U?Ae:void 0,maxWidth:"100%"},defer:!0,children:e.jsxs("div",{role:"table",className:"text-sm",style:{width:Re,minWidth:lt},children:[e.jsx("div",{role:"rowgroup",style:m?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:ct()}),e.jsx("div",{role:"rowgroup",children:at.map((l,v)=>{const S=a(l),j=it(u==null?void 0:u(l)),q=v>0?it(u==null?void 0:u(at[v-1])):null,oe=j&&j.key!==(q==null?void 0:q.key),de=Ne&&b.has(S),Te=!!p,re=de&&y?"color-mix(in srgb, var(--primary) 8%, var(--bg-card))":v%2===1?"color-mix(in srgb, var(--bg-input) 50%, var(--bg-card))":"var(--bg-card)";return e.jsxs(o.Fragment,{children:[oe&&e.jsx("div",{role:"row",className:`grid ${j.className??""}`,style:{gridTemplateColumns:er},children:e.jsx("div",{role:"cell",className:I?"px-2 py-2":"px-3 py-3",style:{gridColumn:"1 / -1",background:"color-mix(in srgb, var(--primary) 8%, var(--bg-input))",borderBottom:"1px solid var(--border)",borderRight:"1px solid var(--border)"},children:e.jsx("div",{className:"flex min-w-0 items-center justify-between gap-3",children:e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate text-xs font-semibold uppercase tracking-wider text-[var(--text-main)]",children:j.label}),j.description&&e.jsx("div",{className:"mt-0.5 truncate text-xs text-[var(--text-muted)]",children:j.description})]})})})}),e.jsxs("div",{role:"row",onClick:Te?()=>p(l):void 0,className:`grid transition-colors ${Te?"cursor-pointer":""} ${g?g(l):""}`,style:{gridTemplateColumns:er,"--dt-row-bg":re,"--dt-sticky-bg":re,background:"var(--dt-row-bg)"},onMouseEnter:pe=>{de||(pe.currentTarget.style.setProperty("--dt-row-bg","var(--bg-hover)"),pe.currentTarget.style.setProperty("--dt-sticky-bg",Dn))},onMouseLeave:pe=>{pe.currentTarget.style.setProperty("--dt-row-bg",re),pe.currentTarget.style.setProperty("--dt-sticky-bg",re)},children:[Ne&&e.jsx("div",{role:"cell",className:`${I?"px-2 py-1.5":"px-3 py-2"} w-10`,style:M?{position:"sticky",left:0,zIndex:3,background:"var(--dt-sticky-bg)",boxShadow:"inset 0 -1px 0 var(--border)"}:{borderBottom:"1px solid var(--border)",borderRight:"1px solid var(--border)"},onClick:pe=>{pe.stopPropagation(),C(S)},children:e.jsx("input",{type:"checkbox",checked:de,onClick:pe=>pe.stopPropagation(),onChange:()=>C(S),className:"rounded cursor-pointer accent-[var(--primary)]"})}),me.map((pe,rr)=>{const tr=M&&!We&&rr===0;return e.jsx("div",{role:"cell",className:`${I?"px-2 py-1.5":"px-3 py-2"} ${ea} ${ot(pe.align)} ${pe.className??""}`,style:{overflow:"hidden",whiteSpace:"nowrap",...tr?{position:"sticky",left:pr,zIndex:3,background:"var(--dt-sticky-bg)",boxShadow:"3px 0 6px -2px rgba(0,0,0,0.12), inset 0 -1px 0 var(--border)",borderRight:"1px solid var(--border)"}:{borderBottom:"1px solid var(--border)",borderRight:"1px solid var(--border)"}},children:e.jsx(Ar,{children:pe.cell(l)})},pe.key)})]})]},S)})})]})})}),ut()]})}function ze(r){return r?new Date(`${r}T12:00:00`):void 0}function Or(r){return r.toISOString().slice(0,10)}function na({calendarMonth:r,displayIndex:t}){const{previousMonth:a,nextMonth:n,goToMonth:s,months:c,labels:d,formatters:i}=yr.useDayPicker(),p=!!a&&t===0,b=!!n&&t===c.length-1;return e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",gap:8,width:"100%",color:"var(--text-main)",marginBottom:6},children:[e.jsx("span",{style:{fontWeight:700},children:i.formatCaption(r.date)}),e.jsx("button",{type:"button","aria-label":d.labelPrevious(a),onClick:()=>a&&s(a),disabled:!p,style:{height:28,width:28,borderRadius:8,border:"1px solid var(--border)",background:"var(--bg-card)",display:"inline-flex",alignItems:"center",justifyContent:"center",color:"var(--text-main)",opacity:p?1:.45,cursor:p?"pointer":"not-allowed"},children:e.jsx(w.HiChevronLeft,{size:16})}),e.jsx("button",{type:"button","aria-label":d.labelNext(n),onClick:()=>n&&s(n),disabled:!b,style:{height:28,width:28,borderRadius:8,border:"1px solid var(--border)",background:"var(--bg-card)",display:"inline-flex",alignItems:"center",justifyContent:"center",color:"var(--text-main)",opacity:b?1:.45,cursor:b?"pointer":"not-allowed"},children:e.jsx(w.HiChevronRight,{size:16})})]})}function oa(r){return r.charAt(0).toUpperCase()+r.slice(1)}function sa({startDate:r,endDate:t,onChange:a,minDate:n,viewMonth:s,numberOfMonths:c=1,showSummary:d=!0,startLabel:i="Inicio",endLabel:p="Regreso"}){const b={from:ze(r),to:ze(t)},C=ze(n),[k,y]=o.useState(ze(s||r));return o.useEffect(()=>{y(ze(s||r))},[s,r]),e.jsxs("div",{children:[e.jsx("div",{style:{borderRadius:10,overflow:"hidden",border:"1px solid var(--border)",background:"var(--bg-input)",display:"flex",justifyContent:"center",padding:"10px 8px"},children:e.jsx(yr.DayPicker,{mode:"range",selected:b,month:k,onMonthChange:y,onSelect:g=>{const u=g!=null&&g.from?Or(g.from):r,m=g!=null&&g.to?Or(g.to):"";a({startDate:u,endDate:m})},numberOfMonths:c,hideNavigation:!0,disabled:C?{before:C}:void 0,showOutsideDays:!1,components:{MonthCaption:na},className:"text-sm",classNames:{root:"w-full",months:"flex gap-3 justify-center",month:"space-y-2",month_caption:"flex items-center justify-between px-1",caption_label:"capitalize",nav:"flex items-center gap-1",button_previous:"h-8 w-8 inline-flex items-center justify-center rounded-md transition-colors",button_next:"h-8 w-8 inline-flex items-center justify-center rounded-md transition-colors",month_grid:"w-full border-collapse",weekdays:"grid grid-cols-7 gap-1 mb-1",weekday:"text-[11px] font-semibold text-center",week:"grid grid-cols-7 gap-1",day:"h-9 w-9 p-0 flex items-center justify-center",day_button:"h-9 w-9 rounded-md text-sm font-medium transition-colors outline-none",selected:"font-semibold",range_start:"font-semibold",range_middle:"font-medium",range_end:"font-semibold",today:"font-bold",disabled:"opacity-40 cursor-not-allowed",hidden:"invisible"},styles:{month_caption:{color:"var(--text-main)",marginBottom:6,display:"flex",alignItems:"center",justifyContent:"space-between"},caption_label:{color:"var(--text-main)",fontWeight:700},nav:{position:"static",display:"flex",alignItems:"center",gap:6},weekday:{color:"var(--text-muted)",textTransform:"lowercase"},button_previous:{height:32,width:32,background:"var(--bg-card)",color:"var(--text-main)",border:"1px solid var(--border)"},button_next:{height:32,width:32,background:"var(--bg-card)",color:"var(--text-main)",border:"1px solid var(--border)"},day_button:{color:"var(--text-main)",borderRadius:8},chevron:{fill:"var(--text-main)"},today:{border:"1px solid color-mix(in srgb, var(--primary) 35%, transparent)"},disabled:{color:"var(--text-muted)"}},modifiersStyles:{selected:{background:"var(--primary)",color:"var(--primary-fg, #ffffff)"},range_start:{background:"var(--primary)",color:"var(--primary-fg, #ffffff)"},range_end:{background:"var(--primary)",color:"var(--primary-fg, #ffffff)"},range_middle:{background:"color-mix(in srgb, var(--primary) 20%, transparent)",color:"var(--text-main)"}},formatters:{formatCaption:g=>oa(new Intl.DateTimeFormat("es-MX",{month:"long",year:"numeric"}).format(g)),formatWeekdayName:g=>new Intl.DateTimeFormat("es-MX",{weekday:"short"}).format(g)},labels:{labelMonthDropdown:()=>"Mes",labelYearDropdown:()=>"Año"}})}),d&&r&&e.jsxs("div",{style:{marginTop:8,fontSize:12,color:"var(--text-muted)",display:"flex",gap:8,flexWrap:"wrap"},children:[e.jsxs("span",{children:[i,":"," ",e.jsx("strong",{style:{color:"var(--text-main)"},children:r})]}),t&&e.jsxs("span",{children:[p,":"," ",e.jsx("strong",{style:{color:"var(--text-main)"},children:t})]})]})]})}function la(r){if(r!==void 0)return typeof r=="number"?`${r}px`:r}function ia({trigger:r,items:t,align:a="end",width:n=220,disabled:s=!1,className:c="",menuClassName:d="",onOpenChange:i}){const[p,b]=o.useState(!1),[C,k]=o.useState(!1),[y,g]=o.useState({}),u=o.useRef(null),m=o.useRef(null),h=o.useCallback(N=>{b(N),i==null||i(N)},[i]),E=o.useCallback(()=>{const N=u.current;if(!N)return;const $=N.getBoundingClientRect(),B=typeof n=="number"?n:$.width,P=typeof n=="number"?n:Math.max($.width,180),D=a==="end"?Math.max(8,$.right-P):Math.min($.left,window.innerWidth-P-8),M=window.innerHeight-$.bottom,_=M<240&&$.top>M?void 0:$.bottom+6,I=_===void 0?window.innerHeight-$.top+6:void 0;g({position:"fixed",zIndex:9999,left:D,top:_,bottom:I,width:la(typeof n=="number"?B:n)})},[a,n]);o.useEffect(()=>k(!0),[]),o.useEffect(()=>{if(!p)return;E();const N=B=>{var D,M;const P=B.target;!((D=u.current)!=null&&D.contains(P))&&!((M=m.current)!=null&&M.contains(P))&&h(!1)},$=B=>{B.key==="Escape"&&h(!1)};return document.addEventListener("mousedown",N),window.addEventListener("keydown",$),window.addEventListener("resize",E),window.addEventListener("scroll",E,!0),()=>{document.removeEventListener("mousedown",N),window.removeEventListener("keydown",$),window.removeEventListener("resize",E),window.removeEventListener("scroll",E,!0)}},[p,h,E]);const W=N=>{s||(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),h(!p))},z=o.isValidElement(r)?o.cloneElement(r,{onClick:()=>!s&&h(!p)}):r,T=p?e.jsx("div",{ref:m,role:"menu",className:`overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-1 shadow-xl ${d}`,style:y,children:t.map(N=>e.jsxs("div",{children:[N.separatorBefore&&e.jsx("div",{className:"my-1 border-t border-[var(--border)]"}),e.jsxs("button",{type:"button",role:"menuitem",disabled:N.disabled,onClick:()=>{var $;N.disabled||(($=N.onSelect)==null||$.call(N),h(!1))},className:"flex w-full min-w-0 items-start gap-2 rounded-md px-2.5 py-1.5 text-left transition-colors hover:bg-[var(--bg-input)] disabled:cursor-not-allowed disabled:opacity-50",style:{color:N.danger?"var(--danger)":"var(--text-main)"},children:[N.icon&&e.jsx("span",{className:"mt-0.5 shrink-0",children:N.icon}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block truncate text-sm font-medium",children:N.label}),N.description&&e.jsx("span",{className:"block truncate text-xs text-[var(--text-muted)]",children:N.description})]})]})]},N.id))}):null;return e.jsxs("span",{ref:u,role:"button",tabIndex:s?-1:0,"aria-haspopup":"menu","aria-expanded":p,onKeyDown:W,className:`inline-flex ${s?"pointer-events-none opacity-60":""} ${c}`,children:[z,C&&T?Ce.createPortal(T,document.body):null]})}const ca=180;function da({open:r,onClose:t,title:a,subtitle:n,leadingIcon:s,confirmLabel:c="Guardar",onConfirm:d,loading:i=!1,confirmDisabled:p=!1,headerActions:b,bodyClassName:C="flex-1 overflow-y-auto px-6 py-5",width:k=440,hasUnsavedChanges:y=!1,unsavedChangesTitle:g="Descartar cambios",unsavedChangesDescription:u="Hay cambios sin guardar. Si cierras el drawer se perderán.",unsavedChangesConfirmLabel:m="Descartar",unsavedChangesCancelLabel:h="Seguir editando",onDiscardChanges:E,children:W}){const[z,T]=o.useState(!1),[N,$]=o.useState(!1),[B,P]=o.useState(!1),D=o.useCallback(()=>{$(!0),requestAnimationFrame(()=>{requestAnimationFrame(()=>P(!0))})},[]),M=o.useCallback(()=>{P(!1),window.setTimeout(()=>$(!1),ca)},[]),_=o.useCallback(()=>{if(y){D();return}t()},[y,t,D]),I=o.useCallback(()=>{P(!1),$(!1),E==null||E(),t()},[t,E]);return o.useEffect(()=>{T(!0)},[]),o.useEffect(()=>(document.body.style.overflow=r?"hidden":"",r||(P(!1),$(!1)),()=>{document.body.style.overflow=""}),[r]),o.useEffect(()=>{if(!r)return;const U=F=>{if(F.key==="Escape"){if(N){M();return}_()}};return window.addEventListener("keydown",U),()=>window.removeEventListener("keydown",U)},[M,N,r,_]),z?Ce.createPortal(e.jsxs("div",{"aria-hidden":!r,className:`fixed inset-0 z-[1000] flex transition-opacity duration-300 ${r?"opacity-100":"opacity-0 pointer-events-none"}`,children:[e.jsx("div",{className:"absolute inset-0 bg-black/40 backdrop-blur-sm",onClick:_}),e.jsxs("div",{className:`absolute inset-y-0 right-0 flex flex-col shadow-2xl transition-transform duration-300 ${r?"translate-x-0":"translate-x-full"}`,style:{width:`min(100vw, ${k}px)`,background:"var(--bg-card)",borderLeft:"1px solid var(--border)"},children:[e.jsxs("div",{className:"flex items-center justify-between px-6 py-4 flex-shrink-0",style:{borderBottom:"1px solid var(--border)"},children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx(ce,{variant:"icon",onClick:_,title:"Cerrar",children:e.jsx(w.HiXMark,{className:"w-5 h-5"})}),s&&e.jsx("div",{className:"flex-shrink-0",children:s}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h3",{className:"text-base font-semibold truncate",style:{color:"var(--text-main)"},children:a}),n&&e.jsx("p",{className:"text-xs truncate",style:{color:"var(--text-muted)"},children:n})]})]}),(b||d)&&e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[b,d&&e.jsxs(e.Fragment,{children:[e.jsx(ce,{variant:"secondary",size:"sm",onClick:_,style:{background:"var(--bg-input)"},children:"Cancelar"}),e.jsx(ce,{variant:"primary",size:"sm",icon:e.jsx(xt.FiSave,{className:"w-4 h-4"}),onClick:d,loading:i,disabled:p,title:c})]})]})]}),e.jsx("div",{"data-drawer-scroll":"true",className:C,children:W})]}),N&&e.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":g,className:"fixed inset-0 z-[1001] flex items-center justify-center p-4",children:[e.jsx("div",{className:`absolute inset-0 bg-black/50 backdrop-blur-sm transition-opacity duration-200 ease-out ${B?"opacity-100":"opacity-0"}`,onClick:M}),e.jsxs("div",{className:`relative z-10 w-full max-w-sm rounded-2xl border p-6 shadow-2xl transition-[opacity,transform] duration-200 ease-out ${B?"translate-y-0 scale-100 opacity-100":"translate-y-2 scale-[0.96] opacity-0"}`,style:{background:"var(--bg-card, #ffffff)",borderColor:"var(--border, #d8e1dc)"},children:[e.jsx(ce,{variant:"icon",onClick:M,className:"absolute right-3 top-3 h-7 w-7 hover:opacity-70",style:{color:"var(--text-muted, #6b7f78)"},"aria-label":h,children:e.jsx(w.HiXMark,{className:"h-4 w-4"})}),e.jsx("div",{className:"mb-4 flex h-11 w-11 items-center justify-center rounded-xl",style:{background:"var(--warning-bg, #fff7ed)"},children:e.jsx(w.HiExclamationTriangle,{className:"h-5 w-5",style:{color:"var(--warning, #d97706)"}})}),e.jsx("h2",{className:"mb-1 text-base font-semibold",style:{color:"var(--text-main, #0f2f2c)"},children:g}),e.jsx("p",{className:"text-sm",style:{color:"var(--text-muted, #6b7f78)"},children:u}),e.jsxs("div",{className:"mt-6 flex gap-2",children:[e.jsx(ce,{variant:"secondary",onClick:M,className:"flex-1 border",style:{background:"var(--bg-input, #f7faf8)",borderColor:"var(--border, #d8e1dc)",color:"var(--text-main, #0f2f2c)"},children:h}),e.jsx(ce,{variant:"secondary",onClick:I,className:"flex-1 border",style:{background:"var(--warning, #d97706)",borderColor:"transparent",color:"#fff",boxShadow:"0 10px 22px rgba(217, 119, 6, 0.22)"},children:m})]})]})]})]}),document.body):null}const ua={sm:"min-h-[160px] p-4",md:"min-h-[220px] p-6",lg:"min-h-[300px] p-8"};function fa({title:r="Sin resultados",description:t,icon:a=e.jsx(w.HiInbox,{className:"h-5 w-5"}),action:n,secondaryAction:s,size:c="md",className:d=""}){return e.jsx("div",{className:`flex items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-card)] text-center ${ua[c]} ${d}`,children:e.jsxs("div",{className:"flex max-w-sm flex-col items-center gap-3",children:[a&&e.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-input)] text-[var(--text-muted)]",children:a}),e.jsxs("div",{className:"space-y-1",children:[r&&e.jsx("h3",{className:"text-sm font-semibold text-[var(--text-main)]",children:r}),t&&e.jsx("div",{className:"text-sm leading-5 text-[var(--text-muted)]",children:t})]}),(n||s)&&e.jsxs("div",{className:"mt-1 flex flex-wrap items-center justify-center gap-2",children:[s,n]})]})})}function Ir({label:r,children:t,helperText:a,error:n,labelAction:s,required:c=!1,className:d="",contentClassName:i=""}){return e.jsxs("label",{className:`flex flex-col gap-2 ${d}`,children:[(r||s)&&e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-semibold uppercase text-[var(--text-muted)]",children:[r&&e.jsx("span",{children:r}),c&&e.jsx("span",{className:"text-[var(--danger)]",children:"*"}),s&&e.jsx("span",{className:"ml-auto normal-case",children:s})]}),e.jsx("span",{className:`block ${i}`,children:t}),n?e.jsx("span",{className:"text-xs font-medium normal-case text-[var(--danger)]",children:n}):a?e.jsx("span",{className:"text-xs font-medium normal-case text-[var(--text-muted)]",children:a}):null]})}var zr={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},Pr=o.createContext&&o.createContext(zr),pa=["attr","size","title"];function ba(r,t){if(r==null)return{};var a,n,s=ha(r,t);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(r);for(n=0;n<c.length;n++)a=c[n],t.indexOf(a)===-1&&{}.propertyIsEnumerable.call(r,a)&&(s[a]=r[a])}return s}function ha(r,t){if(r==null)return{};var a={};for(var n in r)if({}.hasOwnProperty.call(r,n)){if(t.indexOf(n)!==-1)continue;a[n]=r[n]}return a}function Ge(){return Ge=Object.assign?Object.assign.bind():function(r){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var n in a)({}).hasOwnProperty.call(a,n)&&(r[n]=a[n])}return r},Ge.apply(null,arguments)}function _r(r,t){var a=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);t&&(n=n.filter(function(s){return Object.getOwnPropertyDescriptor(r,s).enumerable})),a.push.apply(a,n)}return a}function Xe(r){for(var t=1;t<arguments.length;t++){var a=arguments[t]!=null?arguments[t]:{};t%2?_r(Object(a),!0).forEach(function(n){ma(r,n,a[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(a)):_r(Object(a)).forEach(function(n){Object.defineProperty(r,n,Object.getOwnPropertyDescriptor(a,n))})}return r}function ma(r,t,a){return(t=va(t))in r?Object.defineProperty(r,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):r[t]=a,r}function va(r){var t=xa(r,"string");return typeof t=="symbol"?t:t+""}function xa(r,t){if(typeof r!="object"||!r)return r;var a=r[Symbol.toPrimitive];if(a!==void 0){var n=a.call(r,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(r)}function jr(r){return r&&r.map((t,a)=>o.createElement(t.tag,Xe({key:a},t.attr),jr(t.child)))}function Wr(r){return t=>o.createElement(ga,Ge({attr:Xe({},r.attr)},t),jr(r.child))}function ga(r){var t=a=>{var{attr:n,size:s,title:c}=r,d=ba(r,pa),i=s||a.size||"1em",p;return a.className&&(p=a.className),r.className&&(p=(p?p+" ":"")+r.className),o.createElement("svg",Ge({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},a.attr,n,d,{className:p,style:Xe(Xe({color:r.color||a.color},a.style),r.style),height:i,width:i,xmlns:"http://www.w3.org/2000/svg"}),c&&o.createElement("title",null,c),r.children)};return Pr!==void 0?o.createElement(Pr.Consumer,null,a=>t(a)):t(zr)}function ya(r){return Wr({attr:{viewBox:"0 0 256 256",fill:"currentColor"},child:[{tag:"path",attr:{d:"M247.31,124.76c-.35-.79-8.82-19.58-27.65-38.41C194.57,61.26,162.88,48,128,48S61.43,61.26,36.34,86.35C17.51,105.18,9,124,8.69,124.76a8,8,0,0,0,0,6.5c.35.79,8.82,19.57,27.65,38.4C61.43,194.74,93.12,208,128,208s66.57-13.26,91.66-38.34c18.83-18.83,27.3-37.61,27.65-38.4A8,8,0,0,0,247.31,124.76ZM128,192c-30.78,0-57.67-11.19-79.93-33.25A133.47,133.47,0,0,1,25,128,133.33,133.33,0,0,1,48.07,97.25C70.33,75.19,97.22,64,128,64s57.67,11.19,79.93,33.25A133.46,133.46,0,0,1,231.05,128C223.84,141.46,192.43,192,128,192Zm0-112a48,48,0,1,0,48,48A48.05,48.05,0,0,0,128,80Zm0,80a32,32,0,1,1,32-32A32,32,0,0,1,128,160Z"},child:[]}]})(r)}function wa(r){return Wr({attr:{viewBox:"0 0 256 256",fill:"currentColor"},child:[{tag:"path",attr:{d:"M228,175a8,8,0,0,1-10.92-3l-19-33.2A123.23,123.23,0,0,1,162,155.46l5.87,35.22a8,8,0,0,1-6.58,9.21A8.4,8.4,0,0,1,160,200a8,8,0,0,1-7.88-6.69l-5.77-34.58a133.06,133.06,0,0,1-36.68,0l-5.77,34.58A8,8,0,0,1,96,200a8.4,8.4,0,0,1-1.32-.11,8,8,0,0,1-6.58-9.21L94,155.46a123.23,123.23,0,0,1-36.06-16.69L39,172A8,8,0,1,1,25.06,164l20-35a153.47,153.47,0,0,1-19.3-20A8,8,0,1,1,38.22,99c16.6,20.54,45.64,45,89.78,45s73.18-24.49,89.78-45A8,8,0,1,1,230.22,109a153.47,153.47,0,0,1-19.3,20l20,35A8,8,0,0,1,228,175Z"},child:[]}]})(r)}function Ye({className:r="",...t}){return e.jsx("input",{...t,className:`h-10 rounded-lg border border-[var(--border)] bg-[var(--bg-input)] px-2.5 py-1.5 text-sm text-[var(--text-main)] outline-none placeholder:text-[var(--text-muted)] transition-colors focus:border-[var(--primary)] ${r}`})}function Na({label:r,containerClassName:t="",helperText:a,error:n,labelAction:s,floatingLabel:c=!1,showPasswordToggle:d=!0,className:i="",required:p,...b}){const[C,k]=o.useState(()=>!!b.autoFocus),[y,g]=o.useState(!1),u=b.type==="password"&&d,m=u&&y?"text":b.type,h=b.value!==void 0?String(b.value).length>0:b.defaultValue!==void 0&&String(b.defaultValue).length>0,E=C||h,W={top:E?7:12,color:C?"var(--primary)":"var(--text-muted)",fontSize:E?10:13,fontWeight:E?600:400,textTransform:E?"uppercase":"none"},z=$=>{var B;k(!0),(B=b.onFocus)==null||B.call(b,$)},T=$=>{var B;k(!1),(B=b.onBlur)==null||B.call(b,$)},N=u?e.jsxs("button",{type:"button","aria-label":y?"Ocultar contraseña":"Mostrar contraseña","aria-pressed":y,className:"absolute right-2.5 top-1/2 flex h-7 w-7 -translate-y-1/2 items-center justify-center rounded-md text-[var(--text-muted)] transition-colors duration-200 hover:text-[var(--primary)] focus:outline-none",tabIndex:-1,onClick:()=>g($=>!$),children:[e.jsx("span",{"aria-hidden":"true",className:`absolute inset-0 flex items-center justify-center transition-[opacity,transform] duration-200 ease-out ${y?"scale-y-0 rotate-[-8deg] opacity-0":"scale-y-100 rotate-0 opacity-100"}`,children:e.jsx(ya,{className:"h-[18px] w-[18px]"})}),e.jsx("span",{"aria-hidden":"true",className:`absolute inset-0 flex items-center justify-center transition-[opacity,transform] duration-200 ease-out ${y?"scale-y-100 rotate-0 opacity-100":"scale-y-0 rotate-[8deg] opacity-0"}`,children:e.jsx(wa,{className:"h-[18px] w-[18px]"})})]}):null;return c?e.jsxs("label",{className:`flex flex-col gap-2 ${t}`,children:[e.jsxs("span",{className:"relative block",children:[e.jsx(Ye,{...b,type:m,required:p,placeholder:" ","aria-invalid":!!n||b["aria-invalid"],"data-has-value":h?"true":void 0,className:`h-11 w-full pt-5 ${u?"pr-10":""} ${i}`,onFocus:z,onBlur:T}),e.jsxs("span",{className:"pointer-events-none absolute left-3 transition-all duration-150",style:W,children:[r,p&&e.jsx("span",{className:"ml-1 text-[var(--danger)]",children:"*"})]}),s&&e.jsx("span",{className:"absolute right-2 transition-all duration-150",style:{top:E?7:12},children:s}),N]}),n?e.jsx("span",{className:"text-xs font-medium normal-case text-[var(--danger)]",children:n}):a?e.jsx("span",{className:"text-xs font-medium normal-case text-[var(--text-muted)]",children:a}):null]}):e.jsxs("label",{className:`flex flex-col gap-2 ${t}`,children:[e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-semibold uppercase text-[var(--text-muted)]",children:[e.jsx("span",{children:r}),p&&e.jsx("span",{className:"text-[var(--danger)]",children:"*"}),s&&e.jsx("span",{className:"ml-auto normal-case",children:s})]}),u?e.jsxs("span",{className:"relative block",children:[e.jsx(Ye,{...b,type:m,required:p,"aria-invalid":!!n||b["aria-invalid"],className:`w-full pr-10 ${i}`,onFocus:z,onBlur:T}),N]}):e.jsx(Ye,{...b,required:p,"aria-invalid":!!n||b["aria-invalid"],className:i}),n?e.jsx("span",{className:"text-xs font-medium normal-case text-[var(--danger)]",children:n}):a?e.jsx("span",{className:"text-xs font-medium normal-case text-[var(--text-muted)]",children:a}):null]})}function Fr(r){if(r!==void 0)return typeof r=="number"?`${r}px`:r}function ka(r,t){return r.length!==t.length?!1:r.every((a,n)=>a===t[n])}function Sa({value:r,onChange:t,options:a,placeholder:n="Seleccionar…",disabled:s=!1,className:c="",style:d,height:i=40,padding:p="0 10px",searchable:b=!0,minOptionsForSearch:C=6,maxVisibleValues:k=2,emptyText:y="Sin resultados",clearLabel:g="Limpiar seleccion"}){const[u,m]=o.useState(!1),[h,E]=o.useState(""),[W,z]=o.useState(0),[T,N]=o.useState(!1),[$,B]=o.useState({}),P=o.useRef(null),D=o.useRef(null),M=o.useRef(null),_=o.useRef(null),I=b&&a.length>=C,U=o.useMemo(()=>new Set(r),[r]),F=o.useMemo(()=>a.filter(x=>U.has(x.value)),[a,U]),J=F.slice(0,k),te=Math.max(0,F.length-J.length),f=I&&h.trim()?a.filter(x=>{var Y;return x.label.toLowerCase().includes(h.toLowerCase())||((Y=x.sublabel)==null?void 0:Y.toLowerCase().includes(h.toLowerCase()))}):a,H=o.useCallback(()=>{const x=P.current;if(!x)return;const Y=x.getBoundingClientRect(),be=I?304:244,ee=window.innerHeight-Y.bottom,Q=ee<be&&Y.top>ee;B({position:"fixed",left:Y.left,top:Q?void 0:Y.bottom+4,bottom:Q?window.innerHeight-Y.top+4:void 0,width:Y.width,zIndex:9999})},[I]),G=o.useCallback(x=>{ka(r,x)||t(x)},[t,r]),K=o.useCallback(x=>{const Y=a.find(ee=>ee.value===x);if(Y!=null&&Y.disabled)return;const be=U.has(x)?r.filter(ee=>ee!==x):[...r,x];G(be)},[G,a,r,U]),Z=o.useCallback(()=>G([]),[G]);o.useEffect(()=>N(!0),[]),o.useEffect(()=>{if(!u)return;function x(Y){var ee,Q;const be=Y.target;!((ee=P.current)!=null&&ee.contains(be))&&!((Q=D.current)!=null&&Q.contains(be))&&(m(!1),E(""))}return document.addEventListener("mousedown",x),()=>document.removeEventListener("mousedown",x)},[u]),o.useEffect(()=>{u&&(z(0),H(),I&&setTimeout(()=>{var x;return(x=M.current)==null?void 0:x.focus()},0))},[u,I,H]),o.useEffect(()=>{if(u)return window.addEventListener("resize",H),window.addEventListener("scroll",H,!0),()=>{window.removeEventListener("resize",H),window.removeEventListener("scroll",H,!0)}},[u,H]),o.useEffect(()=>{if(W<0||!_.current)return;const x=_.current.children[W];x==null||x.scrollIntoView({block:"nearest"})},[W]);function ae(x){if(!u){(x.key==="Enter"||x.key===" "||x.key==="ArrowDown")&&(x.preventDefault(),m(!0));return}x.key==="Escape"&&(x.preventDefault(),m(!1),E("")),x.key==="ArrowDown"&&(x.preventDefault(),z(Y=>Math.min(Y+1,f.length-1))),x.key==="ArrowUp"&&(x.preventDefault(),z(Y=>Math.max(Y-1,0))),x.key==="Enter"&&f[W]&&(x.preventDefault(),K(f[W].value)),x.key==="Backspace"&&!h&&r.length&&(x.preventDefault(),G(r.slice(0,-1)))}const ue=e.jsxs("div",{ref:D,className:"overflow-hidden rounded-xl shadow-xl",style:{...$,background:"var(--bg-card)",border:"1px solid var(--border)"},children:[I&&e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",style:{borderBottom:"1px solid var(--border)"},children:[e.jsx(w.HiMagnifyingGlass,{className:"h-3.5 w-3.5 flex-shrink-0",style:{color:"var(--text-muted)"}}),e.jsx("input",{ref:M,value:h,onChange:x=>{E(x.target.value),z(0)},placeholder:"Buscar…",className:"min-w-0 flex-1 bg-transparent text-sm outline-none",style:{color:"var(--text-main)"}}),h&&e.jsx("button",{type:"button",onMouseDown:x=>{x.preventDefault(),E("")},children:e.jsx(w.HiXMark,{className:"h-3.5 w-3.5",style:{color:"var(--text-muted)"}})})]}),F.length>0&&e.jsxs("div",{className:"flex items-center justify-between gap-3 px-3 py-2 text-xs",style:{borderBottom:"1px solid var(--border)",color:"var(--text-muted)"},children:[e.jsxs("span",{children:[F.length," seleccionados"]}),e.jsx("button",{type:"button",onMouseDown:x=>{x.preventDefault(),Z()},className:"font-semibold transition-colors hover:text-[var(--primary)]",children:g})]}),e.jsxs("ul",{ref:_,role:"listbox","aria-multiselectable":"true",className:"overflow-y-auto",style:{maxHeight:I?220:200,scrollbarWidth:"thin",scrollbarColor:"var(--border) transparent",overscrollBehavior:"contain"},children:[f.map((x,Y)=>{const be=Y===W,ee=U.has(x.value);return e.jsxs("li",{role:"option","aria-selected":ee,onMouseDown:Q=>{Q.preventDefault(),K(x.value)},onMouseEnter:()=>!x.disabled&&z(Y),className:"flex cursor-pointer items-center gap-2 px-3 py-2 text-sm transition-colors",style:{background:be?"var(--bg-hover)":ee?"color-mix(in srgb, var(--primary) 6%, transparent)":"transparent",color:x.disabled?"var(--text-muted)":"var(--text-main)",cursor:x.disabled?"not-allowed":"pointer",opacity:x.disabled?.58:1},children:[e.jsx("span",{className:"flex h-4 w-4 flex-shrink-0 items-center justify-center rounded border",style:{borderColor:ee?"var(--primary)":"var(--border)",background:ee?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:ee&&e.jsx(w.HiCheck,{className:"h-3 w-3"})}),x.color&&e.jsx("span",{className:"h-2.5 w-2.5 flex-shrink-0 rounded-full",style:{background:x.color}}),e.jsxs("span",{className:"flex min-w-0 flex-1 items-baseline gap-1 overflow-hidden",children:[e.jsx("span",{className:"truncate",children:x.label}),x.sublabel&&e.jsx("span",{className:"min-w-0 flex-shrink truncate",style:{color:"var(--text-muted)",fontSize:12},children:x.sublabel})]}),x.badge&&e.jsx("span",{className:"flex-shrink-0 text-xs",style:{color:"var(--text-muted)"},children:x.badge})]},x.value)}),f.length===0&&e.jsx("li",{className:"px-3 py-4 text-center text-sm",style:{color:"var(--text-muted)"},children:y})]})]});return e.jsxs("div",{ref:P,className:`relative ${c||"w-full"}`,style:d,onKeyDown:ae,children:[e.jsxs("button",{type:"button",disabled:s,onClick:()=>!s&&m(x=>!x),className:"flex w-full items-center gap-2 rounded-lg text-left text-sm transition-colors focus:outline-none",style:{minHeight:Fr(i),padding:Fr(p),background:"var(--bg-input)",color:F.length?"var(--text-main)":"var(--text-muted)",border:u?"1px solid var(--primary)":"1px solid var(--border)",opacity:s?.5:1,cursor:s?"not-allowed":"pointer"},"aria-haspopup":"listbox","aria-expanded":u,children:[e.jsx("span",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-1.5 overflow-hidden",children:J.length?e.jsxs(e.Fragment,{children:[J.map(x=>e.jsxs("span",{className:"inline-flex max-w-[160px] items-center gap-1 rounded-md border px-1.5 py-0.5 text-xs font-semibold",style:{background:"var(--bg-card)",borderColor:"var(--border)",color:"var(--text-main)"},children:[x.color&&e.jsx("span",{className:"h-1.5 w-1.5 flex-shrink-0 rounded-full",style:{background:x.color}}),e.jsx("span",{className:"truncate",children:x.label})]},x.value)),te>0&&e.jsxs("span",{className:"inline-flex items-center rounded-md px-1.5 py-0.5 text-xs font-semibold",style:{background:"color-mix(in srgb, var(--primary) 10%, transparent)",color:"var(--primary)"},children:["+",te]})]}):e.jsx("span",{className:"truncate",children:n})}),F.length?e.jsx("span",{role:"button",tabIndex:-1,"aria-label":g,onMouseDown:x=>{x.preventDefault(),x.stopPropagation(),Z()},className:"flex-shrink-0 rounded-full p-0.5 transition-colors hover:bg-black/10",style:{color:"var(--text-muted)"},children:e.jsx(w.HiXMark,{className:"h-3 w-3"})}):e.jsx(w.HiChevronDown,{className:"h-4 w-4 flex-shrink-0 transition-transform",style:{color:"var(--text-muted)",transform:u?"rotate(180deg)":"rotate(0deg)"}})]}),u&&T&&Ce.createPortal(ue,document.body)]})}function Ca(r,t,a){const n=[],s=Math.max(2,r-a),c=Math.min(t-1,r+a);n.push(1),s>2&&n.push("...");for(let d=s;d<=c;d+=1)n.push(d);return c<t-1&&n.push("..."),t>1&&n.push(t),n}function Ea({page:r,totalPages:t,onPageChange:a,disabled:n=!1,siblingCount:s=1,className:c=""}){const d=Math.max(1,t),i=Math.min(Math.max(1,r),d),p=Ca(i,d,s);return e.jsxs("nav",{"aria-label":"Paginacion",className:`inline-flex items-center gap-1 ${c}`,children:[e.jsx(ce,{variant:"icon",size:"xs","aria-label":"Pagina anterior",disabled:n||i<=1,onClick:()=>a(i-1),children:e.jsx(w.HiChevronLeft,{className:"h-4 w-4"})}),p.map((b,C)=>b==="..."?e.jsx("span",{className:"flex h-8 min-w-8 items-center justify-center text-xs font-semibold text-[var(--text-muted)]",children:"..."},`ellipsis-${C}`):e.jsx("button",{type:"button","aria-current":b===i?"page":void 0,disabled:n,onClick:()=>a(b),className:"flex h-8 min-w-8 items-center justify-center rounded-md border px-2 text-xs font-semibold transition-colors disabled:cursor-not-allowed disabled:opacity-50",style:{borderColor:b===i?"var(--primary)":"var(--border)",background:b===i?"var(--primary)":"var(--bg-card)",color:b===i?"var(--primary-fg)":"var(--text-secondary)"},children:b},b)),e.jsx(ce,{variant:"icon",size:"xs","aria-label":"Pagina siguiente",disabled:n||i>=d,onClick:()=>a(i+1),children:e.jsx(w.HiChevronRight,{className:"h-4 w-4"})})]})}function $a({value:r,onChange:t,options:a,name:n,label:s,orientation:c="vertical",disabled:d=!1,className:i="",optionClassName:p=""}){return e.jsxs("fieldset",{className:`min-w-0 ${i}`,disabled:d,children:[s&&e.jsx("legend",{className:"mb-2 text-xs font-semibold uppercase text-[var(--text-muted)]",children:s}),e.jsx("div",{className:c==="horizontal"?"flex flex-wrap gap-2":"flex flex-col gap-2",children:a.map(b=>{const C=b.value===r,k=d||b.disabled;return e.jsxs("label",{className:`inline-flex min-w-0 items-start gap-2 rounded-lg border px-2.5 py-1.5 transition-colors ${k?"cursor-not-allowed opacity-60":"cursor-pointer hover:bg-[var(--bg-input)]"} ${p}`,style:{borderColor:C?"color-mix(in srgb, var(--primary) 48%, var(--border))":"var(--border)",background:C?"color-mix(in srgb, var(--primary) 8%, transparent)":"var(--bg-card)"},children:[e.jsxs("span",{className:"relative mt-0.5 inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-full border border-[var(--border)] bg-[var(--bg-input)]",children:[e.jsx("input",{type:"radio",name:n,value:b.value,checked:C,disabled:k,onChange:()=>t(b.value),className:"absolute inset-0 opacity-0"}),e.jsx("span",{className:`h-2 w-2 rounded-full transition ${C?"scale-100 opacity-100":"scale-50 opacity-0"}`,style:{background:"var(--primary)"}})]}),e.jsxs("span",{className:"min-w-0",children:[e.jsx("span",{className:"block text-sm font-medium leading-5 text-[var(--text-main)]",children:b.label}),b.description&&e.jsx("span",{className:"block text-xs leading-5 text-[var(--text-muted)]",children:b.description})]})]},b.value)})})]})}function Ma({title:r,subtitle:t,icon:a,actions:n,children:s,footer:c,className:d="",bodyClassName:i="p-4"}){const p=r||t||a||n;return e.jsxs("section",{className:`overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${d}`,children:[p&&e.jsxs("header",{className:"flex items-center justify-between gap-3 border-b border-[var(--border)] px-4 py-3",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[a&&e.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-input)] text-[var(--primary)]",children:a}),e.jsxs("div",{className:"min-w-0",children:[r&&e.jsx("h3",{className:"truncate text-sm font-semibold text-[var(--text-main)]",children:r}),t&&e.jsx("div",{className:"truncate text-xs text-[var(--text-muted)]",children:t})]})]}),n&&e.jsx("div",{className:"shrink-0",children:n})]}),e.jsx("div",{className:i,children:s}),c&&e.jsx("footer",{className:"border-t border-[var(--border)] px-4 py-3",children:c})]})}const Da={neutral:{text:"var(--text-secondary)",bg:"var(--bg-input)",border:"var(--border)"},primary:{text:"var(--primary)",bg:"color-mix(in srgb, var(--primary) 10%, transparent)",border:"color-mix(in srgb, var(--primary) 24%, var(--border))"},success:{text:"#047857",bg:"rgba(16, 185, 129, 0.11)",border:"rgba(16, 185, 129, 0.24)"},warning:{text:"#b45309",bg:"rgba(245, 158, 11, 0.12)",border:"rgba(245, 158, 11, 0.26)"},danger:{text:"var(--danger)",bg:"var(--danger-bg)",border:"color-mix(in srgb, var(--danger) 20%, var(--border))"},info:{text:"#2563eb",bg:"rgba(59, 130, 246, 0.11)",border:"rgba(59, 130, 246, 0.24)"}},Ha={xs:"min-h-5 px-1.5 text-[10px]",sm:"min-h-6 px-2 text-xs",md:"min-h-7 px-2.5 text-sm"};function La({children:r,tone:t="neutral",size:a="sm",icon:n,dot:s=!1,className:c=""}){const d=Da[t];return e.jsxs("span",{className:`inline-flex max-w-full shrink-0 items-center gap-1.5 rounded-full border font-semibold leading-none ${Ha[a]} ${c}`,style:{color:d.text,background:d.bg,borderColor:d.border},children:[s&&e.jsx("span",{"aria-hidden":"true",className:"h-1.5 w-1.5 shrink-0 rounded-full",style:{background:d.text}}),n&&e.jsx("span",{className:"shrink-0",children:n}),e.jsx("span",{className:"min-w-0 truncate",children:r})]})}function Ta({tabs:r,activeTabId:t,defaultActiveTabId:a,onTabChange:n,ariaLabel:s="Pestanas",variant:c="underline",className:d="",listClassName:i="",panelClassName:p=""}){const b=r.find(u=>!u.disabled)??r[0],C=t??a??(b==null?void 0:b.id),k=r.find(u=>u.id===C)??b,y=u=>{u.disabled||n==null||n(u.id)},g=u=>{const m=r.filter(E=>!E.disabled);if(!m.length||!k)return;const h=m.findIndex(E=>E.id===k.id);(u.key==="ArrowRight"||u.key==="ArrowDown")&&(u.preventDefault(),y(m[(h+1)%m.length])),(u.key==="ArrowLeft"||u.key==="ArrowUp")&&(u.preventDefault(),y(m[(h-1+m.length)%m.length])),u.key==="Home"&&(u.preventDefault(),y(m[0])),u.key==="End"&&(u.preventDefault(),y(m[m.length-1]))};return e.jsxs("div",{className:d,children:[e.jsx("div",{role:"tablist","aria-label":s,onKeyDown:g,className:`flex min-w-0 gap-1 overflow-x-auto ${c==="underline"?"border-b border-[var(--border)]":"rounded-lg border border-[var(--border)] bg-[var(--bg-input)] p-1"} ${i}`,children:r.map(u=>{const m=u.id===(k==null?void 0:k.id);return e.jsxs("button",{type:"button",role:"tab","aria-selected":m,"aria-controls":`${u.id}-panel`,id:`${u.id}-tab`,disabled:u.disabled,tabIndex:m?0:-1,onClick:()=>y(u),className:`inline-flex min-h-8 shrink-0 items-center justify-center gap-1.5 whitespace-nowrap px-2.5 text-sm font-semibold transition-colors focus:outline-none disabled:cursor-not-allowed disabled:opacity-50 ${c==="underline"?"border-b-2":"rounded-md border"}`,style:{color:m?"var(--primary)":"var(--text-muted)",borderColor:m?"var(--primary)":"transparent",background:c==="pills"&&m?"var(--bg-card)":"transparent"},children:[u.icon&&e.jsx("span",{className:"shrink-0",children:u.icon}),e.jsx("span",{children:u.label}),u.badge&&e.jsx("span",{className:"shrink-0",children:u.badge})]},u.id)})}),(k==null?void 0:k.content)!==void 0&&e.jsx("div",{role:"tabpanel",id:`${k.id}-panel`,"aria-labelledby":`${k.id}-tab`,className:`pt-4 ${p}`,children:k.content})]})}function ke(...r){return r.filter(Boolean).join(" ")}function Ba({steps:r,activeStepId:t,initialStepId:a,completedStepIds:n,defaultCompletedStepIds:s=[],onActiveStepChange:c,onCompletedStepIdsChange:d,onBlockedStep:i,allowBackNavigation:p=!0,showFooter:b=!0,previousLabel:C="Anterior",nextLabel:k="Siguiente",blockedNextLabel:y="Completa este paso",className:g="",headerClassName:u="",contentClassName:m="",footerClassName:h=""}){var Q;const E=((Q=r[0])==null?void 0:Q.id)??"",[W,z]=o.useState(a??E),[T,N]=o.useState(s),$=t??W,B=n??T,P=o.useMemo(()=>new Set(B),[B]),D=Math.max(0,r.findIndex(O=>O.id===$)),M=r[D]??r[0],_=r.length<=1?100:D/(r.length-1)*100,I=O=>{n||N(O),d==null||d(O)},U=O=>{const V=r.find(R=>R.id===O);V&&(t||z(O),c==null||c(O,V))},F=O=>P.has(O),J=O=>r.slice(0,O).find(V=>!V.optional&&!P.has(V.id)),te=O=>{const V=r[O];return!V||V.disabled?!1:O===D||p&&O<D?!0:!J(O)},f=O=>{const V=r.findIndex(R=>R.id===O);return V>=0&&te(V)},H=O=>{const V=r.findIndex(R=>R.id===O);if(V<0)return!1;if(!te(V)){const R=J(V);return R&&(i==null||i(r[V],R)),!1}return U(O),!0},G=(O=M==null?void 0:M.id)=>{!O||P.has(O)||I([...B,O])},K=(O=M==null?void 0:M.id)=>{if(!O)return;const V=r.findIndex(le=>le.id===O),R=B.filter(le=>{const he=r.findIndex(X=>X.id===le);return he>=0&&he<V});I(R),V>=0&&D>V&&U(O)},Z=()=>D<=0?!1:H(r[D-1].id),ae=()=>{const O=r[D+1];return O?H(O.id):!1},ue={activeStep:M,activeIndex:D,completedStepIds:B,isCompleted:F,isUnlocked:f,completeStep:G,uncompleteStep:K,goToStep:H,goNext:ae,goPrevious:Z};if(!M)return null;const x=r[D+1],Y=D>0,be=x?f(x.id):!1,ee=typeof M.content=="function"?M.content(ue):M.content;return e.jsxs("section",{className:ke("overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)]",g),children:[e.jsxs("div",{className:ke("border-b border-[var(--border)] bg-[var(--bg-input)]",u),children:[e.jsx("div",{className:"relative h-1 overflow-hidden bg-[var(--border)]/55",children:e.jsx("div",{className:"h-full rounded-r-full bg-[var(--primary)] transition-[width] duration-500 ease-out",style:{width:`${_}%`}})}),e.jsx("div",{className:"grid gap-2 p-2",style:{gridTemplateColumns:`repeat(${r.length}, minmax(0, 1fr))`},children:r.map((O,V)=>{const R=O.id===M.id,le=F(O.id),he=te(V),X=J(V);return e.jsxs("button",{type:"button",disabled:!he,"aria-current":R?"step":void 0,"aria-disabled":!he,title:!he&&X?`Completa ${X.title}`:O.title,onClick:()=>H(O.id),className:ke("group relative min-h-16 min-w-0 overflow-hidden rounded-md border p-3 text-left transition-all duration-200 focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--primary)]/35 disabled:cursor-not-allowed",R&&"border-[var(--primary)] bg-[var(--bg-card)] shadow-sm",le&&!R&&"border-[var(--primary)]/35 bg-[var(--bg-card)]",!R&&!le&&he&&"border-transparent bg-[var(--bg-card)]/45 hover:border-[var(--border)] hover:bg-[var(--bg-card)]",!he&&"border-transparent bg-[var(--bg-card)]/35 opacity-60"),children:[e.jsx("span",{className:ke("absolute inset-x-0 top-0 h-0.5 origin-left scale-x-0 bg-[var(--primary)] transition-transform duration-300",R&&"scale-x-100")}),e.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:ke("grid h-7 w-7 shrink-0 place-items-center rounded-full border text-xs font-bold transition-all duration-200",R&&"border-[var(--primary)] bg-[var(--primary)] text-[var(--primary-fg)]",le&&!R&&"border-[var(--primary)] bg-[var(--primary)]/12 text-[var(--primary)]",!le&&!R&&he&&"border-[var(--border)] text-[var(--text-muted)]",!he&&"border-[var(--border)] text-[var(--text-muted)]"),children:le?e.jsx(w.HiCheck,{className:"h-4 w-4"}):he?V+1:e.jsx(w.HiLockClosed,{className:"h-3.5 w-3.5"})}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsxs("span",{className:ke("block truncate text-xs font-semibold transition-colors duration-200",R?"text-[var(--text-main)]":"text-[var(--text-secondary)]"),children:[V+1,". ",O.title]}),O.description&&e.jsx("span",{className:"mt-1 block truncate text-[11px] text-[var(--text-muted)]",children:O.description})]}),O.badge&&e.jsx("span",{className:"shrink-0",children:O.badge})]})]},O.id)})})]}),e.jsx("div",{className:ke("min-h-72 animate-[stepWizardIn_220ms_ease-out] p-5",m),children:ee},M.id),b&&e.jsxs("div",{className:ke("flex flex-wrap items-center justify-between gap-3 border-t border-[var(--border)] bg-[var(--bg-input)] px-4 py-3",h),children:[e.jsx(ce,{variant:"secondary",height:38,padding:"0 14px",icon:e.jsx(w.HiChevronLeft,{}),disabled:!Y,onClick:Z,children:C}),e.jsxs("div",{className:"flex items-center gap-3 text-xs text-[var(--text-muted)]",children:[e.jsxs("span",{children:["Paso ",D+1," de ",r.length]}),e.jsx("span",{className:"h-1 w-1 rounded-full bg-[var(--border)]"}),e.jsxs("span",{children:[B.length," completados"]})]}),e.jsx(ce,{height:38,padding:"0 14px",icon:e.jsx(w.HiChevronRight,{}),disabled:!x||!be,onClick:ae,children:x&&!be?y:k})]})]})}const Aa={sm:"min-h-20 px-2.5 py-1.5 text-xs leading-5",md:"min-h-24 px-2.5 py-2 text-sm leading-5",lg:"min-h-32 px-3 py-2.5 text-sm leading-6"},Oa={none:"resize-none",vertical:"resize-y",horizontal:"resize-x",both:"resize"};function Ia(r,t){if(r){if(typeof r=="function"){r(t);return}r.current=t}}function za(r,t){return r!==void 0?String(r).length:t!==void 0?String(t).length:0}const Ur=o.forwardRef(function({className:t="",wrapperClassName:a="",size:n="md",resize:s="vertical",autoResize:c=!1,minRows:d,maxRows:i,showCount:p=!1,maxCount:b,status:C="default",icon:k,action:y,style:g,value:u,defaultValue:m,maxLength:h,onInput:E,...W},z){const T=o.useRef(null),N=za(u,m),$=b??h,B=!!(k||y||p),P=C==="error"?"var(--danger)":C==="success"?"#16a34a":"var(--border)",D={...g??{},...d?{minHeight:`${d*24+18}px`}:null,...i?{maxHeight:`${i*24+18}px`}:null},M=()=>{const I=T.current;!I||!c||(I.style.height="auto",I.style.height=`${I.scrollHeight}px`)};o.useEffect(M,[c,u]);const _=e.jsx("textarea",{...W,ref:I=>{T.current=I,Ia(z,I)},value:u,defaultValue:m,maxLength:h,"aria-invalid":C==="error"||W["aria-invalid"],onInput:I=>{M(),E==null||E(I)},style:{...D,borderColor:P},className:`w-full rounded-lg border bg-[var(--bg-input)] text-[var(--text-main)] outline-none placeholder:text-[var(--text-muted)] transition-colors focus:border-[var(--primary)] disabled:cursor-not-allowed disabled:opacity-60 ${Aa[n]} ${Oa[c?"none":s]} ${k?"pl-8":""} ${y?"pr-10":""} ${t}`});return B?e.jsxs("span",{className:`relative block ${a}`,children:[k&&e.jsx("span",{className:"pointer-events-none absolute left-2.5 top-2.5 flex h-4 w-4 items-center justify-center text-[var(--text-muted)]",children:k}),_,y&&e.jsx("span",{className:"absolute right-2 top-2 flex items-center justify-center",children:y}),p&&e.jsxs("span",{className:"absolute bottom-1.5 right-2 rounded bg-[var(--bg-input)] px-1.5 text-[10px] font-semibold text-[var(--text-muted)]",children:[N,$?`/${$}`:""]})]}):_});function Pa({label:r,containerClassName:t="",helperText:a,error:n,labelAction:s,required:c,className:d="",status:i,...p}){return e.jsx(Ir,{label:r,required:c,helperText:a,error:n,labelAction:s,className:t,children:e.jsx(Ur,{...p,required:c,status:n?"error":i,className:`w-full ${d}`})})}const _a={xs:{width:28,height:16,thumb:12,padding:2},sm:{width:36,height:20,thumb:16,padding:2}};function ja({checked:r,disabled:t,onCheckedChange:a,size:n="sm",className:s="",...c}){const d=_a[n],i=r?d.width-d.thumb-d.padding*2:0;return e.jsx("button",{...c,type:"button",role:"switch","aria-checked":r,disabled:t,onClick:()=>!t&&a(!r),className:`relative inline-flex shrink-0 items-center rounded-full transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--primary)]/50 disabled:cursor-not-allowed disabled:opacity-50 ${s}`,style:{width:d.width,height:d.height,background:r?"color-mix(in srgb, var(--primary) 85%, transparent)":"var(--bg-input)",border:r?"1px solid color-mix(in srgb, var(--primary) 55%, transparent)":"1px solid var(--border)"},children:e.jsx("span",{className:"absolute inline-block rounded-full transition-transform",style:{width:d.thumb,height:d.thumb,left:d.padding,top:"50%",transform:`translate(${i}px, -50%)`,background:r?"var(--primary-fg)":"var(--text-muted)"}})})}const qr=[".sidebar-scroll","[data-overlay-scroll='true']"].join(",");function Wa(r){if(!(r instanceof HTMLElement)||r.dataset.overlayScroll==="false"||r.closest("[data-overlayscrollbars]")||r.matches("textarea,input,select,[contenteditable='true']"))return!1;const t=window.getComputedStyle(r);return!(![t.overflow,t.overflowX,t.overflowY].join(" ").match(/auto|scroll/)||r.clientWidth===0&&r.clientHeight===0)}function Gr(r){return r.classList.contains("sidebar-scroll")}function Xr(r){Gr(r)&&r.querySelectorAll(".os-scrollbar-horizontal").forEach(t=>{t.style.display="none",t.style.height="0",t.style.pointerEvents="none"})}function Yr(){return o.useEffect(()=>{const r=new WeakMap;let t=0;const a=()=>{t=0,document.querySelectorAll(qr).forEach(c=>{if(!Wa(c))return;if(xr.OverlayScrollbars(c)){Xr(c);return}const i=xr.OverlayScrollbars(c,{overflow:Gr(c)?{x:"hidden",y:"scroll"}:void 0,scrollbars:{autoHide:"leave",autoHideDelay:180}});Xr(c),r.set(c,i)})},n=()=>{t||(t=window.requestAnimationFrame(a))};a();const s=new MutationObserver(n);return s.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["class","data-overlay-scroll"]}),window.addEventListener("resize",n),()=>{t&&window.cancelAnimationFrame(t),s.disconnect(),window.removeEventListener("resize",n),document.querySelectorAll(qr).forEach(c=>{var d;c instanceof HTMLElement&&((d=r.get(c))==null||d.destroy())})}},[]),null}const Fa={xs:{wh:"w-5 h-5",text:"text-[8px]"},sm:{wh:"w-7 h-7",text:"text-[11px]"},md:{wh:"w-9 h-9",text:"text-sm"},lg:{wh:"w-12 h-12",text:"text-base"},xl:{wh:"w-16 h-16",text:"text-xl"}},Vr=["bg-indigo-500","bg-blue-500","bg-emerald-500","bg-violet-500","bg-amber-500","bg-teal-500","bg-rose-500","bg-cyan-500"],Ua={xs:"text-xs",sm:"text-sm",md:"text-base",lg:"text-lg"},qa="bonsaif.bot",Ga="Bonsaif Bot",Xa={xs:"p-0.5",sm:"p-1",md:"p-1.5",lg:"p-2",xl:"p-2.5"};function Kr(r){return typeof r=="string"?r.trim():""}function Ya(r){let t=0;for(const a of r)t=t*31+a.charCodeAt(0)&65535;return Vr[t%Vr.length]}function Va(r,t){return r===qa||t===Ga}function Ka(r,t){return`${r.replace(/\/$/,"")}${t}`}function Zr({userId:r,username:t,name:a,size:n="md",showName:s=!1,showTooltip:c,tooltipContent:d,fallbackLabel:i="Usuario",wrapperClassName:p="",labelClassName:b="",labelSize:C="xs",avatarVersion:k=0,className:y="",style:g}){var F;const[u,m]=o.useState(!1),h=typeof r=="string"&&r.trim()&&r!=="undefined"&&r!=="null"?r.trim():"";o.useEffect(()=>{m(!1)},[h,k]);const{wh:E,text:W}=Fa[n],z=Kr(a)||Kr(t)||i,T=z.trim()[0]||"?",N=typeof process<"u"&&((F=process.env)==null?void 0:F.NEXT_PUBLIC_BASE_PATH)||"",$=Va(t,a),B=Ka(N,"/favicon.svg"),P=h?`${N}/api/user/avatar/${h}${k?`?v=${k}`:""}`:"",M={xs:20,sm:28,md:36,lg:48,xl:64}[n],_=$?e.jsx("span",{className:`${E} ${Xa[n]} rounded-full flex items-center justify-center bg-[#071f1a] ring-1 ring-emerald-400/35 shadow-[0_0_0_1px_rgba(255,255,255,0.06)] flex-shrink-0 ${y}`,style:g,children:e.jsx("img",{src:B,alt:z,width:M,height:M,className:"h-full w-full object-contain"})}):P&&!u?e.jsx("img",{src:P,alt:z,width:M,height:M,className:`${E} rounded-full object-cover flex-shrink-0 ${y}`,style:g,onError:()=>m(!0)},`${h}-${k}`):e.jsx("span",{className:`${E} ${Ya(z)} ${W} rounded-full flex items-center justify-center font-black text-white uppercase flex-shrink-0 ${y}`,style:g,title:z,children:T});if(s)return e.jsxs("span",{className:`inline-flex min-w-0 items-center gap-2 ${p}`,children:[_,e.jsx("span",{className:`min-w-0 truncate ${Ua[C]} font-medium text-[var(--text-main)] ${b}`,title:z,children:z})]});const I=c??!0,U=d??z;return I&&U?e.jsx(Fe,{as:"span",content:U,className:`inline-flex flex-shrink-0 ${p}`,children:_}):_}function Za({href:r,className:t,children:a}){return e.jsx("a",{href:r,className:t,children:a})}function Ja(r){return r.reduce((t,a)=>{const n=a.section??"Principal";return t[n]=[...t[n]??[],a],t},{})}function Jr({children:r,navItems:t=[],currentPath:a=typeof window>"u"?"/":window.location.pathname,user:n,appName:s="Bonsaif",appLogo:c,header:d,footer:i,onLogout:p,LinkComponent:b=Za}){const[C,k]=o.useState(!1),y=Ja(t);return e.jsxs("div",{className:"min-h-screen bg-[var(--bg-main)] text-[var(--text-main)]",children:[e.jsx(Yr,{}),e.jsx("button",{type:"button","aria-label":"Abrir navegación",className:"fixed left-3 top-3 z-50 inline-flex h-9 w-9 items-center justify-center rounded-md border border-white/10 bg-black/70 text-white lg:hidden",onClick:()=>k(!0),children:e.jsx(w.HiBars3,{className:"h-5 w-5"})}),C&&e.jsx("button",{type:"button","aria-label":"Cerrar navegación",className:"fixed inset-0 z-40 bg-black/45 lg:hidden",onClick:()=>k(!1)}),e.jsxs("aside",{className:`fixed inset-y-0 left-0 z-50 flex w-72 flex-col bg-[#071716] text-white shadow-2xl transition-transform duration-200 lg:translate-x-0 ${C?"translate-x-0":"-translate-x-full"}`,children:[e.jsxs("div",{className:"flex h-16 items-center gap-3 border-b border-white/10 px-4",children:[e.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg bg-white/10 text-white",children:c??e.jsx(w.HiHome,{className:"h-5 w-5"})}),e.jsx("div",{className:"min-w-0 flex-1 truncate text-sm font-semibold",children:s}),e.jsx("button",{type:"button","aria-label":"Cerrar navegación",className:"inline-flex h-8 w-8 items-center justify-center rounded-md text-white/70 hover:bg-white/10 lg:hidden",onClick:()=>k(!1),children:e.jsx(w.HiXMark,{className:"h-5 w-5"})})]}),e.jsx("nav",{className:"sidebar-scroll min-h-0 flex-1 overflow-y-auto px-3 py-4","data-overlay-scroll":"true",children:Object.entries(y).map(([g,u])=>e.jsxs("div",{className:"mb-5",children:[e.jsxs("div",{className:"mb-2 flex items-center gap-2 px-2 text-[11px] font-semibold uppercase tracking-wide text-white/35",children:[e.jsx(w.HiChevronDown,{className:"h-3.5 w-3.5"}),g]}),e.jsx("div",{className:"space-y-1",children:u.map(m=>{const h=a===m.href||a.startsWith(`${m.href}/`);return e.jsxs(b,{href:m.href,className:`flex min-w-0 items-center gap-2 rounded-md px-2 py-2 text-sm transition-colors ${h?"bg-white/10 text-white":"text-white/55 hover:bg-white/[0.06] hover:text-white/85"}`,children:[e.jsx("span",{className:"flex h-5 w-5 flex-shrink-0 items-center justify-center",children:m.icon??e.jsx(w.HiHome,{className:"h-4 w-4"})}),e.jsx("span",{className:"truncate",children:m.label})]},m.href)})})]},g))}),e.jsxs("div",{className:"border-t border-white/10 p-3",children:[n&&e.jsxs("div",{className:"mb-3 flex min-w-0 items-center gap-3 rounded-lg bg-white/[0.04] p-2",children:[e.jsx(Zr,{name:n.initials??n.name??n.email??"Usuario",size:"md"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate text-sm font-medium text-white",children:n.name??"Usuario"}),n.email&&e.jsx("div",{className:"truncate text-xs text-white/45",children:n.email})]})]}),p&&e.jsxs(ce,{variant:"ghost",className:"w-full justify-start text-white hover:bg-white/10",onClick:p,children:[e.jsx(w.HiArrowRightOnRectangle,{className:"h-4 w-4"})," Salir"]}),i]})]}),e.jsxs("div",{className:"min-h-screen lg:pl-72",children:[d,e.jsx("main",{className:"min-h-screen",children:r})]})]})}const Qa={dashboard:"Dashboard",tickets:"Tickets",teams:"Equipos",projects:"Proyectos",clients:"Clientes",surveys:"Encuestas",profile:"Perfil",settings:"Configuración",notifications:"Notificaciones",changelog:"Historial",admin:"Inicio",users:"Usuarios",roles:"Roles",menus:"Menús",guards:"Guardias",vacations:"Vacaciones",audit:"Auditoría",positions:"Puestos",ranks:"Rangos","email-inbox":"Buzones","security-incidents":"Incidentes","guard-schedule":"Guardias"},ir={dashboard:e.jsx(w.HiChartBar,{className:"h-5 w-5"}),tickets:e.jsx(w.HiTicket,{className:"h-5 w-5"}),teams:e.jsx(w.HiUsers,{className:"h-5 w-5"}),projects:e.jsx(w.HiRectangleGroup,{className:"h-5 w-5"}),clients:e.jsx(w.HiBuildingOffice2,{className:"h-5 w-5"}),surveys:e.jsx(w.HiClipboardDocumentList,{className:"h-5 w-5"}),profile:e.jsx(w.HiUser,{className:"h-5 w-5"}),settings:e.jsx(w.HiCog6Tooth,{className:"h-5 w-5"}),notifications:e.jsx(w.HiBell,{className:"h-5 w-5"}),changelog:e.jsx(w.HiDocumentText,{className:"h-5 w-5"}),admin:e.jsx(w.HiShieldCheck,{className:"h-5 w-5"}),users:e.jsx(w.HiUsers,{className:"h-5 w-5"}),roles:e.jsx(w.HiShieldCheck,{className:"h-5 w-5"}),menus:e.jsx(w.HiCog6Tooth,{className:"h-5 w-5"}),guards:e.jsx(w.HiCalendarDays,{className:"h-5 w-5"}),vacations:e.jsx(w.HiCalendarDays,{className:"h-5 w-5"}),audit:e.jsx(w.HiListBullet,{className:"h-5 w-5"}),positions:e.jsx(w.HiBriefcase,{className:"h-5 w-5"}),ranks:e.jsx(w.HiListBullet,{className:"h-5 w-5"}),"email-inbox":e.jsx(w.HiInbox,{className:"h-5 w-5"}),"security-incidents":e.jsx(w.HiShieldCheck,{className:"h-5 w-5"})};function Ra({href:r,className:t,style:a,children:n}){return e.jsx("a",{href:r,className:t,style:a,children:n})}function en(r){return r.split("-").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}function rn(r){return/^\d+$/.test(r)||/^[a-f0-9]{8,}$/i.test(r)}function tn(r){const t=r.split("/").filter(Boolean);if(t.length===0||t.length===1&&t[0]==="dashboard")return[];const a=decodeURIComponent(t[t.length-1]),n=t.length>1?decodeURIComponent(t[t.length-2]):void 0,s=rn(a)&&n?n:a,c=Qa[s]??en(s);return[{label:"Inicio",href:"/"},{label:c}]}function cr(r){return(r==null?void 0:r.querySelector(":scope > .os-viewport"))??(r==null?void 0:r.querySelector(":scope > [data-overlayscrollbars-viewport]"))}function an(r){const t=r.split("/").filter(Boolean),a=t[t.length-1];if(!a)return e.jsx(w.HiHome,{className:"h-5 w-5"});if(ir[a])return ir[a];const n=t.length>1?t[t.length-2]:"";return ir[n]??e.jsx(w.HiHome,{className:"h-5 w-5"})}function nn({title:r,subtitle:t,action:a,meta:n,icon:s,className:c="",contentClassName:d="",breadcrumbs:i,currentPath:p=typeof window>"u"?"/":window.location.pathname,showBreadcrumbs:b=!0,contained:C=!1,LinkComponent:k=Ra}){const y=o.useRef(null),[g,u]=o.useState(!1),[m,h]=o.useState(null),E=i??tn(p),W=s??an(p),z=b&&E.length>1;return o.useEffect(()=>{if(C){u(!1);return}let T=null,N=0,$=0;const B=()=>{const M=y.current,_=document.querySelector("[data-app-scroll='true']");return(M==null?void 0:M.closest(".os-viewport"))??(M==null?void 0:M.closest("[data-overlayscrollbars-viewport]"))??cr(_)??_??window},P=()=>{const M=T&&T!==window?T.scrollTop:window.scrollY;u(_=>_?M>24:M>72)},D=()=>{T==null||T.removeEventListener("scroll",P),T=B(),T.addEventListener("scroll",P,{passive:!0}),P()};return D(),N=window.requestAnimationFrame(D),$=window.setTimeout(D,120),()=>{window.cancelAnimationFrame(N),window.clearTimeout($),T==null||T.removeEventListener("scroll",P)}},[C]),o.useEffect(()=>{if(C){h(null);return}let T=0;const N=[],$=()=>{const U=y.current,F=U==null?void 0:U.parentElement,J=document.querySelector("[data-app-scroll='true']"),te=cr(J)??J;if(!U||!F||!te){h(null);return}const f=F.getBoundingClientRect(),H=window.getComputedStyle(F),G=te.getBoundingClientRect(),K=te instanceof HTMLElement&&te.clientWidth>0?te.clientWidth:G.width,Z=f.left+parseFloat(H.paddingLeft||"0"),ae={marginLeft:Math.round(G.left-Z),width:Math.round(K)};h(ue=>ue&&ue.marginLeft===ae.marginLeft&&ue.width===ae.width?ue:ae)},B=()=>{window.cancelAnimationFrame(T),T=window.requestAnimationFrame($)};B(),window.addEventListener("resize",B);const P=new ResizeObserver(B),D=y.current,M=D==null?void 0:D.parentElement,_=document.querySelector("[data-app-scroll='true']"),I=cr(_)??_;return[M,_,I].forEach(U=>{U&&P.observe(U)}),N.push(window.setTimeout(B,120)),N.push(window.setTimeout(B,280)),()=>{window.cancelAnimationFrame(T),window.removeEventListener("resize",B),P.disconnect(),N.forEach(U=>window.clearTimeout(U))}},[C]),e.jsx("div",{ref:y,"data-page-header":"true","data-compact":g?"true":"false",className:`sticky top-0 z-30 overflow-visible py-0 transition-[background-color,box-shadow,border-color] duration-300 ease-out ${C?"mb-0 flex-shrink-0":"mb-4 sm:mb-0"} ${c}`,style:{...m?{marginLeft:m.marginLeft,width:m.width}:null,background:C?"var(--bg-card)":g?"var(--bg-main)":"color-mix(in srgb, var(--bg-main) 44%, transparent)",backdropFilter:"saturate(1.2) blur(14px)",WebkitBackdropFilter:"saturate(1.2) blur(14px)",borderBottom:C||g?"1px solid var(--border)":"1px solid transparent",boxShadow:g?"0 10px 28px rgba(12, 54, 53, 0.12)":"none"},children:e.jsxs("div",{className:`flex flex-wrap items-center justify-between px-4 pt-0.5 transition-[gap,min-height,padding] duration-300 ease-out ${g?"min-h-9 gap-2 sm:min-h-10 sm:gap-2.5":"min-h-10 gap-2.5 sm:min-h-11 sm:gap-3"} ${d}`,children:[e.jsxs("div",{className:`min-w-0 flex flex-1 flex-col justify-center transition-[gap,transform] duration-300 ease-out ${g?"gap-1":"gap-1.5 sm:gap-2"}`,children:[z&&e.jsx("nav",{"aria-label":"Breadcrumb",className:"min-w-0 flex-shrink-0 transition-[opacity,transform] duration-300 ease-out",children:e.jsx("ol",{className:`flex flex-wrap items-center gap-1.5 leading-none transition-[font-size,line-height] duration-300 ease-out ${g?"text-[10px]":"text-[10px] sm:text-[11px]"}`,children:E.map((T,N)=>{const $=N===E.length-1;return e.jsxs("li",{className:"flex min-w-0 items-center gap-1.5",children:[N>0&&e.jsx(w.HiChevronRight,{className:"h-3.5 w-3.5 transition-[color,transform] duration-300 ease-out",style:{color:"var(--text-muted)"}}),T.href&&!$?e.jsx(k,{href:T.href,className:"truncate transition-colors duration-300 hover:underline",style:{color:"var(--text-muted)"},children:T.label}):e.jsx("span",{"aria-current":$?"page":void 0,className:$?"truncate font-semibold":"truncate",style:{color:$?"var(--text-main)":"var(--text-muted)"},children:T.label})]},`${T.label}-${N}`)})})}),e.jsxs("div",{className:`flex min-w-0 items-center transition-[gap,transform] duration-300 ease-out ${g?"gap-2":"gap-2.5 sm:gap-3"}`,children:[e.jsx("span",{className:`flex-shrink-0 transition-[color,transform,opacity] duration-300 ease-out ${g?"scale-75 opacity-80":"scale-90 opacity-100"}`,style:{color:z?"var(--text-secondary)":"var(--text-muted)"},children:W}),e.jsxs("div",{className:`flex min-w-0 flex-1 flex-wrap items-center transition-[gap] duration-300 ease-out ${g?"gap-x-2 gap-y-1":"gap-x-3 gap-y-2"}`,children:[e.jsxs("div",{className:"min-w-0 flex-shrink transition-[transform] duration-300 ease-out",children:[e.jsx("h1",{className:`truncate font-bold tracking-tight transition-[font-size,line-height,color] duration-300 ease-out ${g?"text-base sm:text-lg":"text-lg sm:text-xl"}`,style:{color:"var(--text-main)"},children:r}),t&&e.jsx("p",{"aria-hidden":g,className:`overflow-hidden text-xs transition-[max-height,opacity,transform,margin] duration-300 ease-out ${g?"mt-0 max-h-0 -translate-y-1 opacity-0":"mt-0.5 max-h-5 translate-y-0 opacity-100"}`,style:{color:"var(--text-muted)"},children:t})]}),n&&e.jsx("div",{className:`page-header-meta flex min-w-0 flex-1 basis-full items-center overflow-visible transition-[gap,opacity,transform] duration-300 ease-out sm:basis-auto ${g?"translate-y-0 gap-1.5 opacity-95":"gap-2 opacity-100"}`,children:n})]})]})]}),a&&e.jsx("div",{className:`page-header-actions ml-auto flex max-w-full flex-shrink-0 flex-wrap items-center justify-end self-center overflow-visible transition-[gap,min-height,opacity,transform] duration-300 ease-out ${g?"min-h-10 gap-1 opacity-95":"min-h-10 gap-1.5 opacity-100"}`,children:e.jsx(kr.Provider,{value:{compact:!0,headerAction:!0},children:a})})]})})}function on({children:r,currentPath:t=typeof window>"u"?"/":window.location.pathname,publicRoutes:a=["/","/login","/reset-password"],...n}){return a.includes(t)?e.jsx(e.Fragment,{children:r}):e.jsx(Jr,{currentPath:t,...n,children:r})}function Qr(){if(typeof window>"u")return"system";const r=localStorage.getItem("theme");return r==="light"||r==="dark"?r:r==="system"?"system":document.documentElement.classList.contains("dark")?"dark":"light"}function sn(r,t,a){try{const n=new URL(r),s=n.searchParams.get("callbackUrl");if(s){const c=new URL(s,n.origin);return c.searchParams.set("theme",t),a&&(c.searchParams.set("primeAuthOrigin",window.location.origin),c.searchParams.set("primeAuthProjectKey",a)),n.searchParams.set("callbackUrl",`${c.pathname}${c.search}${c.hash}`),n.toString()}return n.searchParams.set("theme",t),a&&(n.searchParams.set("primeAuthOrigin",window.location.origin),n.searchParams.set("primeAuthProjectKey",a)),n.toString()}catch{return r}}function ln({name:r,src:t,projectKey:a}){const[n,s]=o.useState(()=>Qr()),c=o.useRef(null);o.useEffect(()=>{const p=new MutationObserver(()=>s(Qr()));return p.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>p.disconnect()},[]);const d=o.useMemo(()=>sn(t,n,a),[a,t,n]),i=o.useMemo(()=>{try{return new URL(d).origin}catch{return""}},[d]);return o.useEffect(()=>{if(!a)return;const p=a;function b(C){var g,u,m;if(C.source!==((g=c.current)==null?void 0:g.contentWindow)||i&&C.origin!==i)return;if(((u=C.data)==null?void 0:u.type)==="prime-microservice:overlay"){window.dispatchEvent(new CustomEvent("prime-auth:microservice-overlay",{detail:{active:!!C.data.active}}));return}if(((m=C.data)==null?void 0:m.type)!=="prime-microservice:navigation")return;const k=C.data.path;if(!k||!k.startsWith("/")||k.startsWith("//"))return;const y=`/apps/${encodeURIComponent(p)}${k}`;`${window.location.pathname}${window.location.search}${window.location.hash}`!==y&&(window.history.replaceState(window.history.state,"",y),window.dispatchEvent(new CustomEvent("prime-auth:microservice-navigation")))}return window.addEventListener("message",b),()=>{window.removeEventListener("message",b),window.dispatchEvent(new CustomEvent("prime-auth:microservice-overlay",{detail:{active:!1}}))}},[i,a]),e.jsx("div",{className:"flex h-full min-h-screen flex-col bg-[var(--bg-main)]",children:e.jsx("iframe",{ref:c,src:d,title:r,className:"min-h-0 flex-1 border-0 bg-[var(--bg-main)]",allow:"clipboard-write",sandbox:"allow-downloads allow-forms allow-modals allow-popups allow-same-origin allow-scripts",referrerPolicy:"strict-origin-when-cross-origin"})})}function cn(){const[r,t]=o.useState(""),[a,n]=o.useState(!1),[s,c]=o.useState({width:96,height:96});return o.useEffect(()=>{let d=!1;return fetch("/api/microservices/prime-suite/chat-url",{cache:"no-store"}).then(i=>i.ok?i.json():null).then(i=>{!d&&(i!=null&&i.src)&&t(i.src)}).catch(()=>{}),()=>{d=!0}},[]),o.useEffect(()=>{const d=i=>{var b;if(((b=i.data)==null?void 0:b.type)!=="prime-suite-chat:state")return;const p=!!i.data.active;n(p),c({width:Rr(i.data.width,96,720),height:Rr(i.data.height,96,560)})};return window.addEventListener("message",d),()=>window.removeEventListener("message",d)},[]),r?e.jsx("iframe",{title:"Chat Bonsaif",src:r,allow:"clipboard-write",className:"fixed bottom-0 right-0 z-[70] border-0 bg-transparent transition-[width,height] duration-200",style:{width:a?`min(${s.width}px, 100vw)`:96,height:a?`min(${s.height}px, 100vh)`:96,background:"transparent",backgroundColor:"transparent",colorScheme:"normal"}}):null}function Rr(r,t,a){const n=typeof r=="number"&&Number.isFinite(r)?r:t;return Math.max(t,Math.min(a,Math.ceil(n)))}function dn(r){const t=document.documentElement,a=new MutationObserver(r);a.observe(t,{attributes:!0,attributeFilter:["class"]});const n=window.matchMedia("(prefers-color-scheme: dark)");return n.addEventListener("change",r),()=>{a.disconnect(),n.removeEventListener("change",r)}}function un(){const r=localStorage.getItem("theme")||"system",t=window.matchMedia("(prefers-color-scheme: dark)").matches;return document.documentElement.classList.contains("dark")||r==="dark"||r==="system"&&t?"dark":"light"}function fn(){return"light"}function pn(){const r=o.useSyncExternalStore(dn,un,fn);return e.jsx(gt.Toaster,{position:"bottom-center",theme:r,richColors:!0,closeButton:!0})}A.Alert=It,A.AuthShell=Jr,A.BonsaifButton=yt,A.Button=ce,A.CalendarPicker=Wt,A.Checkbox=Ut,A.CodeBlock=Xt,A.CompactFilterSelect=Vt,A.CompactSearchInput=Yt,A.ConfirmDialog=Jt,A.CopyButton=sr,A.CopyLinkButton=Rt,A.DataTable=aa,A.DateRangePicker=sa,A.Drawer=da,A.DropdownMenu=ia,A.DynamicDetailTabs=At,A.EmptyState=fa,A.FormField=Ir,A.GlobalScrollbars=Yr,A.InputField=Na,A.LoadingState=Cr,A.MicroserviceFrame=ln,A.Modal=Br,A.MouseTooltip=Fe,A.MultiSelect=Sa,A.PageHeader=nn,A.PageSearchInput=Nr,A.Pagination=Ea,A.PrimeAuthRouteShell=on,A.PrimeAuthToaster=pn,A.PrimeSuiteChatFrame=cn,A.RadioGroup=$a,A.SearchableSelect=lr,A.SectionPanel=Ma,A.StatusBadge=La,A.StepWizard=Ba,A.Tabs=Ta,A.TextInput=Ye,A.Textarea=Ur,A.TextareaField=Pa,A.Toggle=ja,A.UserAvatar=Zr,A.cn=wr,Object.defineProperty(A,Symbol.toStringTag,{value:"Module"})}));