bonsaif-ui 0.1.124 → 0.1.128

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,10 +1,10 @@
1
- (function(Y,s){typeof exports=="object"&&typeof module<"u"?s(exports,require("react"),require("react/jsx-runtime"),require("react-icons/hi2"),require("react-dom"),require("recharts"),require("overlayscrollbars"),require("sonner"),require("overlayscrollbars-react"),require("react-day-picker"),require("react-day-picker/dist/style.css"),require("react-icons/fi")):typeof define=="function"&&define.amd?define(["exports","react","react/jsx-runtime","react-icons/hi2","react-dom","recharts","overlayscrollbars","sonner","overlayscrollbars-react","react-day-picker","react-day-picker/dist/style.css","react-icons/fi"],s):(Y=typeof globalThis<"u"?globalThis:Y||self,s(Y.BonsaifUI={},Y.React,Y.jsxRuntime,Y.ReactIconsHi2,Y.ReactDOM,Y.Recharts,Y.OverlayScrollbarsGlobal,Y.Sonner,Y.OverlayScrollbarsReact,Y.ReactDayPicker,Y.ReactDayPickerStyles,Y.ReactIconsFi))})(this,(function(Y,s,t,z,nt,Ne,oa,bs,ms,la,bb,Gl){"use strict";"use client";function Tt(...e){return e.filter(Boolean).join(" ")}function Zl({variant:e="primary",className:r,type:n="button",children:a,...o}){return t.jsx("button",{className:Tt("bonsaif-ui-button",`bonsaif-ui-button--${e}`,r),type:n,...o,children:a})}function ps({value:e,onChange:r,placeholder:n,className:a="",autoFocus:o=!1,forceExpanded:l=!1,onEscape:i,size:c="default",inputTabIndex:d}){const u=s.useRef(null),[m,f]=s.useState(!1),b=l||m||e.trim().length>0,v=c==="sm"?"h-9 rounded-md":"h-10 rounded-lg",x=a||"w-48 max-w-full sm:w-64 lg:w-72";s.useEffect(()=>{var h;o&&((h=u.current)==null||h.focus())},[o]);const E=()=>{var h;f(!0),(h=u.current)==null||h.focus()};return t.jsxs("div",{className:`relative min-w-0 max-w-full flex-shrink-0 overflow-visible transition-[width] duration-200 ease-out ${b?x:"w-24 sm:w-28"}`,onMouseDown:h=>{b||(h.preventDefault(),E())},children:[t.jsx(z.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)",left:"var(--page-header-control-icon-left, 12px)"}}),t.jsx("input",{ref:u,type:"text",tabIndex:d,"aria-label":n,value:e,onChange:h=>r(h.target.value),onKeyDown:h=>{h.key==="Escape"&&(i==null||i())},placeholder:b?n:"Buscar",className:`${v} w-full py-0 text-sm leading-none placeholder:text-[var(--text-muted)] focus:outline-none transition-all duration-200 ${b?"pl-9 pr-8":"cursor-pointer pl-9 pr-3"}`,style:{height:`var(--page-header-control-height, ${c==="sm"?"36px":"40px"})`,paddingLeft:"calc(var(--page-header-control-icon-left, 12px) + 24px)",paddingRight:b?"calc(var(--page-header-control-padding-x, 14px) + 18px)":"var(--page-header-control-padding-x, 14px)",background:"color-mix(in srgb, var(--bg-card) 86%, transparent)",border:"1px solid var(--border)",color:"var(--text-main)"},onFocus:h=>{f(!0),h.currentTarget.style.borderColor="var(--primary)",h.currentTarget.style.boxShadow="0 0 0 3px rgba(59,130,246,0.12)"},onBlur:h=>{f(!1),h.currentTarget.style.borderColor="var(--border)",h.currentTarget.style.boxShadow="none"}}),e&&t.jsx("button",{type:"button",onClick:()=>r(""),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)",right:"var(--page-header-control-padding-x, 8px)"},"aria-label":"Limpiar búsqueda",children:t.jsx(z.HiXMark,{className:"h-3.5 w-3.5 flex-shrink-0"})})]})}const hs=s.createContext({});let gs=0;const vs="bonsaif-ui:hide-tooltips";function on(e=700){gs=Date.now()+e}function Ql(){return Date.now()>gs}function ln(e){if(typeof document>"u")return!1;const r=Array.from(document.querySelectorAll('[data-bonsaif-overlay="true"], [role="menu"], [role="dialog"][aria-modal="true"], [aria-hidden="false"] [aria-modal="true"]'));return e&&r.some(n=>n.contains(e))?!1:r.length>0}function Jl(e){var a;const r=Array.from(e.querySelectorAll("*")).filter(o=>{var l;return o.scrollWidth>o.clientWidth&&!!((l=o.textContent)!=null&&l.trim())&&o.tagName.toLowerCase()!=="svg"&&!o.closest("svg")});return(e.scrollWidth>e.clientWidth||r.length>0)&&(((a=r[0])==null?void 0:a.textContent)??e.textContent??"").trim()||null}function zt({children:e,content:r,onlyWhenOverflow:n=!1,interactive:a=!1,followCursor:o=!0,placement:l="bottom",showArrow:i=!1,className:c="",tooltipClassName:d="",style:u,tooltipStyle:m,as:f="div"}){const b=s.useRef(null),v=s.useRef(null),x=s.useRef(null),E=s.useRef(!1),[h,$]=s.useState(null),[M,y]=s.useState("");s.useEffect(()=>{const T=b.current;T&&(T.querySelectorAll("[title]").forEach(Z=>{const H=Z.getAttribute("title");H&&(Z.getAttribute("aria-label")||Z.setAttribute("aria-label",H),Z.removeAttribute("title"))}),T.querySelectorAll("svg title").forEach(Z=>Z.remove()))}),s.useLayoutEffect(()=>{if(!h)return;const T=v.current;if(!T)return;const Z=12,H=14,ae=T.getBoundingClientRect(),X=window.innerWidth-ae.width-Z,V=window.innerHeight-ae.height-Z;let q=h.mouseX+H,L=h.mouseY+H,oe,B;if(!o&&b.current){const F=b.current.getBoundingClientRect(),le=F.left+F.width/2,g=F.top+F.height/2;l==="top"?(q=le-ae.width/2,L=F.top-ae.height-H,B=ae.height-1):l==="left"?(q=F.left-ae.width-H,L=g-ae.height/2,oe=ae.width-1):l==="right"?(q=F.right+H,L=g-ae.height/2,oe=-7):(q=le-ae.width/2,L=F.bottom+H,B=-7)}if(o&&(q>X&&(q=h.mouseX-ae.width-H),L>V&&(L=h.mouseY-ae.height-H)),q=Math.min(Math.max(Z,q),Math.max(Z,X)),L=Math.min(Math.max(Z,L),Math.max(Z,V)),!o&&b.current){const F=b.current.getBoundingClientRect(),le=F.left+F.width/2,g=F.top+F.height/2;l==="top"||l==="bottom"?oe=Math.min(Math.max(14,le-q),ae.width-14):B=Math.min(Math.max(14,g-L),ae.height-14)}(Math.abs(q-h.x)>.5||Math.abs(L-h.y)>.5||oe!==h.arrowX||B!==h.arrowY)&&$(F=>F&&{...F,x:q,y:L,arrowX:oe,arrowY:B})},[o,l,h]);const w=()=>{x.current&&(window.clearTimeout(x.current),x.current=null)},k=(T,Z)=>{if(!Ql()||E.current)return;const H=b.current;if(H&&!ln(H)){if(n){const ae=Jl(H);if(!ae)return;y(ae)}!n&&!r||$({mouseX:T,mouseY:Z,x:T+14,y:Z+14})}},N=()=>{const T=b.current;if(!T)return;const Z=T.getBoundingClientRect();k(Z.left+Z.width/2,Z.bottom)},A=()=>{w(),$(null)},C=()=>{if(!a){A();return}w(),x.current=window.setTimeout(()=>$(null),120)},j=()=>{on(),E.current=!0,A()},W=()=>{E.current=!1};s.useEffect(()=>{if(!h)return;if(ln(b.current)){$(null);return}const T=()=>$(null),Z=()=>{on(),E.current=!0,$(null)};document.addEventListener("pointerdown",Z,!0),document.addEventListener("click",Z,!0),document.addEventListener("scroll",T,!0),window.addEventListener("blur",T),document.addEventListener("visibilitychange",T),document.addEventListener("keydown",T,!0);const H=new MutationObserver(()=>{ln(b.current)&&$(null)});return H.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["role","aria-modal","aria-hidden","class"]}),()=>{document.removeEventListener("pointerdown",Z,!0),document.removeEventListener("click",Z,!0),document.removeEventListener("scroll",T,!0),window.removeEventListener("blur",T),document.removeEventListener("visibilitychange",T),document.removeEventListener("keydown",T,!0),H.disconnect()}},[h]),s.useEffect(()=>{const T=()=>on(),Z=()=>{on(),E.current=!0,$(null)};return document.addEventListener("pointerdown",T,!0),document.addEventListener("click",T,!0),document.addEventListener("keydown",T,!0),window.addEventListener(vs,Z),()=>{document.removeEventListener("pointerdown",T,!0),document.removeEventListener("click",T,!0),document.removeEventListener("keydown",T,!0),window.removeEventListener(vs,Z)}},[]);const G=n?M:r;return t.jsxs(t.Fragment,{children:[t.jsx(f,{ref:T=>{b.current=T},className:c,style:u,onMouseEnter:T=>{w(),W(),o?k(T.clientX,T.clientY):N()},onMouseMove:T=>{h&&o&&k(T.clientX,T.clientY)},onMouseDown:j,onClick:j,onMouseLeave:()=>{W(),C()},onFocus:N,onBlur:A,children:e}),h&&G&&!ln(b.current)?nt.createPortal(t.jsxs("div",{ref:v,role:"tooltip",className:d,onMouseEnter:a?w:void 0,onMouseLeave:a?C:void 0,style:{position:"fixed",top:h.y,left:h.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:a?"auto":"none",maxWidth:"min(420px, calc(100vw - 24px))",whiteSpace:"normal",lineHeight:1.6,overflowWrap:"anywhere",...m},children:[i&&t.jsx("span",{"aria-hidden":"true",style:{position:"absolute",width:12,height:12,background:(m==null?void 0:m.background)??"var(--bg-card)",borderLeft:l==="right"?(m==null?void 0:m.border)??"1px solid var(--border)":void 0,borderTop:l==="bottom"||l==="right"?(m==null?void 0:m.border)??"1px solid var(--border)":void 0,borderRight:l==="left"?(m==null?void 0:m.border)??"1px solid var(--border)":void 0,borderBottom:l==="top"||l==="left"?(m==null?void 0:m.border)??"1px solid var(--border)":void 0,transform:"rotate(45deg)",left:h.arrowX===void 0?void 0:h.arrowX-6,top:h.arrowY===void 0?void 0:h.arrowY-6,zIndex:-1}}),G]}),document.body):null]})}function ys(e){if(e!==void 0)return typeof e=="number"?`${e}px`:e}const Rl="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",ei={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"},ti="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",ri={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"},ni={xs:"h-8 w-8",sm:"h-9 w-9",md:"h-10 w-10",lg:"h-10 w-10"},ai={primary:{background:"var(--bg-card)"},secondary:{background:"var(--bg-card)"},danger:{background:"var(--bg-card)"},ghost:{},icon:{}};function ia(e){return typeof e=="string"||typeof e=="number"?String(e):Array.isArray(e)?e.map(ia).join(" ").trim():s.isValidElement(e)?ia(e.props.children):""}function si(e){return s.Children.toArray(e).find(s.isValidElement)??null}function je({variant:e="primary",size:r="md",loading:n=!1,icon:a,tooltip:o,iconOnly:l,height:i,padding:c,children:d,className:u="",disabled:m,style:f,...b}){const v=s.useContext(hs),x=l??v.iconOnly??e==="icon",E=v.compact??!1,h=v.headerAction??!1,$=h&&r==="md"?"sm":E&&!h&&r==="md"?"xs":r,M=e==="icon"||x,y=h&&M,w=ia(d),k=o??b.title??b["aria-label"]??(x?w:void 0),N=k?void 0:b.title,A=b["aria-label"]??(typeof k=="string"?k:w||void 0),C=n?null:a??(x?si(d):null),j=t.jsxs("button",{...b,title:N,"aria-label":A,"data-variant":e,"data-size":$,"data-icon":M?"true":void 0,disabled:m||n,className:`${Rl} ${y?ti:ei[e]} ${M?ni[$]:ri[$]} ${E&&!M?"px-2.5":""} ${u}`,style:{...ai[e],height:ys(i),padding:ys(c),...f,...h&&!M?{height:"var(--page-header-control-height, 34px)",padding:"0 var(--page-header-control-padding-x, 10px)",borderRadius:"8px"}:null,...y?{width:"var(--page-header-control-height, 40px)",height:"var(--page-header-control-height, 40px)",padding:0,background:"var(--bg-card)",borderRadius:"8px"}:null},children:[n?t.jsx("span",{className:"h-3.5 w-3.5 animate-spin rounded-full border-2 border-current border-t-transparent"}):C,!x&&d]});return k?t.jsx(zt,{as:"span",content:k,className:"inline-flex shrink-0",children:j}):j}const tt={background:"color-mix(in srgb, var(--text-muted) 26%, var(--bg-input))"};function cn({rows:e=8,columns:r=7,showToolbar:n=!0,showPagination:a=!0,compact:o=!1,className:l=""}){const i=Math.max(3,Math.min(r,12)),c=Math.max(3,Math.min(e,20)),d=o?"px-2 py-2":"px-3 py-2.5",u=o?"px-2 py-2":"px-3 py-3";return t.jsxs("div",{className:`w-full min-w-0 overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${l}`,"aria-busy":"true","aria-label":"Cargando tabla",children:[n&&t.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-[var(--border)] px-3 py-2",children:[t.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[t.jsx("div",{className:"h-7 w-14 shrink-0 animate-pulse rounded-md",style:tt}),t.jsx("div",{className:"h-7 max-w-md flex-1 animate-pulse rounded-md",style:tt})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[t.jsx("div",{className:"h-7 w-7 animate-pulse rounded-md",style:tt}),t.jsx("div",{className:"h-7 w-7 animate-pulse rounded-md",style:tt})]})]}),t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("div",{className:"min-w-full",style:{display:"grid",gridTemplateColumns:`repeat(${i}, minmax(96px, 1fr))`},children:[Array.from({length:i}).map((m,f)=>t.jsx("div",{className:`${u} border-b border-[var(--border)]`,style:{background:"color-mix(in srgb, var(--bg-input) 55%, transparent)"},children:t.jsx("div",{className:"h-3 animate-pulse rounded-md",style:{...tt,width:`${48+f*17%40}%`}})},`h-${f}`)),Array.from({length:c}).map((m,f)=>Array.from({length:i}).map((b,v)=>t.jsx("div",{className:`${d} ${f<c-1?"border-b border-[var(--border)]":""}`,children:t.jsx("div",{className:"h-3.5 animate-pulse rounded-md",style:{...tt,width:`${46+(f*13+v*11)%42}%`,minWidth:28}})},`c-${f}-${v}`)))]})}),a&&t.jsxs("div",{className:"flex items-center justify-between gap-3 border-t border-[var(--border)] px-3 py-2",style:{background:"color-mix(in srgb, var(--bg-input) 40%, transparent)"},children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"h-3 w-28 animate-pulse rounded-md",style:tt}),t.jsx("div",{className:"h-7 w-14 animate-pulse rounded-md",style:tt})]}),t.jsx("div",{className:"flex items-center gap-1",children:Array.from({length:4}).map((m,f)=>t.jsx("div",{className:"h-7 w-7 animate-pulse rounded-md",style:tt},f))}),t.jsx("div",{className:"h-3 w-16 animate-pulse rounded-md",style:tt})]})]})}function oi({size:e="md"}){const r=e==="sm"?"h-7 w-7":"h-9 w-9";return t.jsx("div",{className:`${r} animate-spin rounded-full border-2 border-[var(--border)] border-t-[var(--primary)]`,"aria-hidden":!0})}function li({logoSrc:e,logoAlt:r}){return e?t.jsxs("span",{className:"relative flex h-16 w-16 items-center justify-center","aria-hidden":!1,children:[t.jsx("span",{className:"absolute inset-0 rounded-2xl opacity-40 blur-xl",style:{background:"radial-gradient(circle, color-mix(in srgb, var(--primary) 45%, transparent) 0%, transparent 70%)"}}),t.jsx("img",{src:e,alt:r,className:"relative h-14 w-14 rounded-2xl object-contain shadow-sm shadow-black/10"})]}):null}function xs({variant:e="page",title:r="Cargando...",description:n,logoSrc:a,logoAlt:o,appearance:l="card",rows:i=6,columns:c=7,children:d,className:u=""}){if(e==="table")return t.jsx(cn,{rows:i,columns:c,className:u});if(e==="sections")return t.jsx(ii,{rows:i});if(e==="cards")return t.jsx(ci,{rows:i});const m=o||(typeof r=="string"?r:"Aplicación"),f=l==="bare",b=t.jsxs("div",{className:`flex flex-col items-center text-center ${f?"gap-5":"gap-3"}`,children:[a?t.jsx(li,{logoSrc:a,logoAlt:m}):null,t.jsx(oi,{size:f?"md":"sm"}),t.jsxs("div",{className:f?"space-y-1.5":"",children:[t.jsx("p",{className:f?"text-base font-semibold tracking-tight text-[var(--text-main)]":"text-sm font-semibold text-[var(--text-main)]",children:r}),n?t.jsx("p",{className:f?"text-sm font-medium text-[var(--text-muted)]":"mt-1 text-xs text-[var(--text-muted)]",children:n}):null,d&&t.jsx("div",{className:"mt-1 text-xs text-[var(--text-muted)]",children:d})]})]});return f?t.jsx("div",{className:`flex min-h-[240px] w-full items-center justify-center p-8 ${u}`,role:"status","aria-live":"polite","aria-busy":"true",children:b}):t.jsx("div",{className:`flex min-h-[240px] items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-6 ${u}`,role:"status","aria-live":"polite","aria-busy":"true",children:b})}function ii({rows:e}){return t.jsx(cn,{rows:e,columns:7})}function ci({rows:e}){return t.jsx("div",{className:"grid gap-3 md:grid-cols-2 xl:grid-cols-3",children:Array.from({length:e}).map((r,n)=>t.jsxs("div",{className:"rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-4",children:[t.jsx("div",{className:"h-4 w-2/3 animate-pulse rounded-md",style:tt}),t.jsx("div",{className:"mt-3 h-3 w-full animate-pulse rounded-md",style:tt}),t.jsx("div",{className:"mt-2 h-3 w-4/5 animate-pulse rounded-md",style:tt})]},n))})}function ws(e){const r=e.split("/").filter(Boolean);return(r[r.length-1]??e).replace(/^lv_/,"").split(/[-_]/).filter(Boolean).map(a=>a.charAt(0).toUpperCase()+a.slice(1)).join(" ")}function ks(e){return e.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().trim()}function di(e){return[e.label,ws(e.service),e.description,e.service].filter(Boolean).join(" ")}function ui(e){return typeof e=="function"?e:e.default}function fi(e,r){return t.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:t.jsxs("div",{className:"max-w-md",children:[t.jsx("p",{className:"text-sm font-semibold text-[var(--text-main)]",children:"No se pudo cargar este modulo"}),t.jsx("p",{className:"mt-1 text-xs text-[var(--text-muted)]",children:e.message}),t.jsx(je,{className:"mt-4",height:36,padding:"0 14px",onClick:r,children:"Reintentar"})]})})}function bi({parentPanel:e,parentPanelComponent:r,renderParentPanel:n,parent:a,context:o,links:l,moduleRegistry:i,loadModule:c,activeService:d,initialService:u,onActiveServiceChange:m,canAccess:f,keepAlive:b=!0,title:v,subtitle:x,emptyState:E,loadingState:h,errorState:$=fi,renderTabLabel:M,searchableTabs:y="auto",tabsSearchThreshold:w=6,tabsSearchPlaceholder:k="Buscar modulo...",tabsSearchValue:N,onTabsSearchChange:A,emptySearchState:C,showTabCount:j=!0,className:W="",parentClassName:G="",contentClassName:T="",tabsClassName:Z=""}){var et;const H=s.useMemo(()=>l.filter(me=>!me.hidden&&((f==null?void 0:f(me,o))??!0)),[f,o,l]),ae=(et=H.find(me=>!me.disabled))==null?void 0:et.service,[X,V]=s.useState(u??ae??""),[q,L]=s.useState({}),[oe,B]=s.useState({}),[F,le]=s.useState(""),[g,P]=s.useState(!1),I=s.useRef(oe),te=s.useRef(0),U=N??F,K=ks(U),D=y===!0||y==="auto"&&H.length>=w,ee=D&&U.trim().length>0,_=s.useMemo(()=>K?H.filter(me=>ks(di(me)).includes(K)):H,[K,H]),se=d??X,Q=H.find(me=>me.service===se)??H.find(me=>!me.disabled);s.useEffect(()=>{!Q&&ae&&V(ae)},[ae,Q]),s.useEffect(()=>{I.current=oe},[oe]);const de=me=>{me.disabled||(d||V(me.service),m==null||m(me.service,me))},Se=me=>{N===void 0&&le(me),A==null||A(me)},ie=(me,J)=>{const re=_.filter(he=>!he.disabled),be=re.findIndex(he=>he.service===J.service);be<0||((me.key==="ArrowRight"||me.key==="ArrowDown")&&(me.preventDefault(),de(re[(be+1)%re.length])),(me.key==="ArrowLeft"||me.key==="ArrowUp")&&(me.preventDefault(),de(re[(be-1+re.length)%re.length])),me.key==="Home"&&(me.preventDefault(),de(re[0])),me.key==="End"&&(me.preventDefault(),de(re[re.length-1])))},pe=s.useCallback(()=>{if(!Q)return;const me=Q.service,J=I.current[me];if(J!=null&&J.loading||J!=null&&J.component&&b)return;const re=(i==null?void 0:i[me])??c;if(!re){B(he=>({...he,[me]:{loading:!1,error:new Error(`No module loader found for service "${me}".`)}}));return}const be=++te.current;B(he=>({...he,[me]:{...he[me],loading:!0,error:void 0}})),re(Q,o).then(he=>{if(be!==te.current&&!b)return;const Be=ui(he);B(Te=>({...Te,[me]:{component:Be,loading:!1}}))}).catch(he=>{const Be=he instanceof Error?he:new Error(String(he));B(Te=>({...Te,[me]:{...Te[me],loading:!1,error:Be}}))})},[o,b,c,i,Q]);s.useEffect(pe,[pe]);const Ce=Q?q[Q.service]??null:null,De=Q?oe[Q.service]:void 0,mt=De==null?void 0:De.component,xt=me=>{Q&&L(J=>({...J,[Q.service]:me}))},We=()=>{Q&&L(me=>({...me,[Q.service]:null}))},Le={context:o,parent:a,links:l,visibleLinks:H,filteredLinks:_,selectedLink:Q,selectedService:Q==null?void 0:Q.service,activeItemId:Ce,tabsSearch:U,onSelectService:de,onOpenDetail:xt,onBackToList:We},ke=n?n(Le):r?t.jsx(r,{...Le}):e;return t.jsxs("section",{className:`grid min-h-[520px] gap-4 lg:grid-cols-[minmax(260px,360px)_minmax(0,1fr)] ${W}`,children:[t.jsx("aside",{className:`min-w-0 rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-4 ${G}`,children:ke}),t.jsxs("div",{className:`relative min-w-0 overflow-visible rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${T}`,children:[(v||x||D||j)&&t.jsx("div",{className:"relative border-b border-[var(--border)] px-4 py-3",children:t.jsxs("div",{className:"flex min-w-0 items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[v&&t.jsx("h2",{className:"truncate text-sm font-semibold text-[var(--text-main)]",children:v}),x&&t.jsx("p",{className:"mt-1 line-clamp-2 text-xs text-[var(--text-muted)]",children:x})]}),(D||j)&&t.jsxs("div",{className:"flex min-w-0 flex-shrink-0 items-center justify-end gap-2",children:[j&&t.jsxs("span",{className:"hidden text-xs font-semibold text-[var(--text-muted)] transition-opacity duration-200 sm:inline",children:[_.length," / ",H.length]}),D&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:`origin-right overflow-hidden transition-[width,opacity,transform] duration-200 ease-out ${g?"w-[min(20rem,44vw)] translate-x-0 opacity-100":"w-0 translate-x-2 opacity-0"}`,"aria-hidden":!g,children:t.jsx(ps,{value:U,onChange:Se,placeholder:k,className:"w-full",autoFocus:g,forceExpanded:!0,onEscape:()=>P(!1),size:"sm",inputTabIndex:g?0:-1})}),t.jsx("button",{type:"button","aria-label":g?"Cerrar busqueda":"Buscar tabs","aria-expanded":g,onClick:()=>{g&&U&&Se(""),P(me=>!me)},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 ${g||ee?"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:t.jsx("span",{className:"grid h-4 w-4 place-items-center transition-transform duration-200",children:g||ee?t.jsx(z.HiXMark,{className:"h-4 w-4"}):t.jsx(z.HiMagnifyingGlass,{className:"h-4 w-4"})})})]})]})]})}),t.jsx("div",{role:"tablist","aria-label":v??"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 ${Z}`,children:_.length>0?_.map(me=>{const J=me.service===(Q==null?void 0:Q.service);return t.jsx("button",{type:"button",role:"tab","aria-selected":J,disabled:me.disabled,onClick:()=>de(me),onKeyDown:re=>ie(re,me),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 ${J?"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:M?M(me,J):t.jsxs(t.Fragment,{children:[me.icon,t.jsx("span",{children:me.label??ws(me.service)}),me.badge&&t.jsx("span",{className:"rounded-full bg-[var(--bg-input)] px-1.5 py-0.5 text-[10px] text-[var(--text-muted)]",children:me.badge})]})},me.service)}):t.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:C??"No hay modulos que coincidan con la busqueda."})}),(Q==null?void 0:Q.description)&&t.jsx("div",{className:"border-b border-[var(--border)] px-4 py-2 text-xs text-[var(--text-muted)]",children:Q.description}),t.jsxs("div",{className:"min-h-[420px] p-4",children:[!Q&&(E??t.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."})),Q&&(De==null?void 0:De.loading)&&(h??t.jsx(xs,{title:"Cargando modulo..."})),Q&&(De==null?void 0:De.error)&&$(De.error,pe),Q&&mt&&!(De!=null&&De.loading)&&!(De!=null&&De.error)&&t.jsx(mt,{context:o,parent:a,link:Q,activeItemId:Ce,onOpenDetail:xt,onBackToList:We})]})]})]})}const mi={info:{color:"#2563eb",background:"rgba(59, 130, 246, 0.1)",border:"rgba(59, 130, 246, 0.24)",icon:t.jsx(z.HiInformationCircle,{className:"h-5 w-5"})},success:{color:"#047857",background:"rgba(16, 185, 129, 0.1)",border:"rgba(16, 185, 129, 0.24)",icon:t.jsx(z.HiCheckCircle,{className:"h-5 w-5"})},warning:{color:"#b45309",background:"rgba(245, 158, 11, 0.12)",border:"rgba(245, 158, 11, 0.26)",icon:t.jsx(z.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:t.jsx(z.HiExclamationCircle,{className:"h-5 w-5"})},neutral:{color:"var(--text-secondary)",background:"var(--bg-input)",border:"var(--border)",icon:t.jsx(z.HiInformationCircle,{className:"h-5 w-5"})}};function pi({variant:e="info",title:r,children:n,icon:a,action:o,onDismiss:l,className:i=""}){const c=mi[e];return t.jsxs("div",{role:e==="danger"||e==="warning"?"alert":"status",className:`flex items-start gap-3 rounded-lg border px-3 py-3 ${i}`,style:{background:c.background,borderColor:c.border},children:[t.jsx("div",{className:"mt-0.5 shrink-0",style:{color:c.color},children:a??c.icon}),t.jsxs("div",{className:"min-w-0 flex-1",children:[r&&t.jsx("div",{className:"text-sm font-semibold text-[var(--text-main)]",children:r}),n&&t.jsx("div",{className:"mt-0.5 text-sm leading-5 text-[var(--text-secondary)]",children:n}),o&&t.jsx("div",{className:"mt-3",children:o})]}),l&&t.jsx(je,{variant:"icon",size:"xs","aria-label":"Cerrar alerta",onClick:l,className:"-mr-1 -mt-1",children:t.jsx(z.HiXMark,{className:"h-4 w-4"})})]})}const Ns=["Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre"],hi=["Ene","Feb","Mar","Abr","May","Jun","Jul","Ago","Sep","Oct","Nov","Dic"],gi=["lu","ma","mi","ju","vi","sá","do"],Ss=6;function ca(e,r,n){return`${e}-${String(r).padStart(2,"0")}-${String(n).padStart(2,"0")}`}function vi(){const e=new Date;return ca(e.getFullYear(),e.getMonth()+1,e.getDate())}function Cs(e){const[r,n,a]=e.split("-").map(Number);return{year:r,month:n,day:a}}function yi(e){if(!e)return"Seleccionar fecha";const{year:r,month:n,day:a}=Cs(e);return!r||!n||!a?"Seleccionar fecha":`${String(a).padStart(2,"0")} ${Ns[n-1]} ${r}`}function xi({value:e,onChange:r,minDate:n,displayMode:a="inline",className:o=""}){const l=vi(),c=Cs(e||l),d=a==="popover",[u,m]=s.useState(!1),f=s.useRef(null),[b,v]=s.useState({horizontal:"left",vertical:"bottom"}),[x,E]=s.useState(c.year),[h,$]=s.useState(c.month),[M,y]=s.useState("days"),w=16,[k,N]=s.useState(0),A=x-7+k,C=Array.from({length:w},(V,q)=>A+q);s.useEffect(()=>{if(!d||!u||!f.current)return;const V=f.current.getBoundingClientRect(),q=8,L=280,oe=340,B=V.left+L>window.innerWidth-q,F=V.right-L>=q,le=V.bottom+8+oe>window.innerHeight-q,g=V.top-8-oe>=q;v({horizontal:B&&F?"right":"left",vertical:le&&g?"top":"bottom"})},[d,u]),s.useEffect(()=>{if(!d||!u)return;function V(L){f.current&&(f.current.contains(L.target)||m(!1))}function q(L){L.key==="Escape"&&m(!1)}return document.addEventListener("mousedown",V),document.addEventListener("keydown",q),()=>{document.removeEventListener("mousedown",V),document.removeEventListener("keydown",q)}},[d,u]);function j(){h===1?(E(V=>V-1),$(12)):$(V=>V-1)}function W(){h===12?(E(V=>V+1),$(1)):$(V=>V+1)}const G=(new Date(x,h-1,1).getDay()+6)%7,T=new Date(x,h,0).getDate(),Z=[...Array(G).fill(null),...Array.from({length:T},(V,q)=>q+1)];for(;Z.length<Ss*7;)Z.push(null);const H=Z.slice(0,Ss*7);function ae(V){const q=ca(x,h,V);n&&q<n||(r(q),d&&m(!1))}const X=t.jsx("div",{className:`bonsaif-calendar bonsaif-calendar-picker ${o}`.trim(),children:t.jsxs("div",{className:"bonsaif-cal-shell",children:[t.jsx("div",{className:"bonsaif-cal-toolbar",children:M==="days"?t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn",onClick:j,"aria-label":"Mes anterior",children:t.jsx(z.HiChevronLeft,{size:16})}),t.jsxs("button",{type:"button",className:"bonsaif-cal-title-btn",onClick:()=>{y("years"),N(0)},children:[t.jsxs("span",{className:"bonsaif-cal-title",children:[Ns[h-1]," ",x]}),t.jsx(z.HiChevronDown,{size:13})]}),t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn",onClick:W,"aria-label":"Mes siguiente",children:t.jsx(z.HiChevronRight,{size:16})})]}):t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn",onClick:()=>N(V=>V-w),"aria-label":"Años anteriores",children:t.jsx(z.HiChevronLeft,{size:16})}),t.jsx("button",{type:"button",className:"bonsaif-cal-title-btn",onClick:()=>y("days"),children:t.jsxs("span",{className:"bonsaif-cal-title",children:[C[0]," – ",C[C.length-1]]})}),t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn",onClick:()=>N(V=>V+w),"aria-label":"Años siguientes",children:t.jsx(z.HiChevronRight,{size:16})})]})}),M==="years"?t.jsxs("div",{className:"bonsaif-cal-picker-years",children:[t.jsx("div",{className:"bonsaif-cal-picker-months",children:hi.map((V,q)=>{const L=q+1===h;return t.jsx("button",{type:"button",className:`bonsaif-cal-pill-btn${L?" is-active":""}`,onClick:()=>$(q+1),children:V},V)})}),t.jsx("div",{className:"bonsaif-cal-picker-year-grid",children:C.map(V=>{const q=V===x,L=V===new Date().getFullYear();return t.jsx("button",{type:"button",className:`bonsaif-cal-pill-btn${q?" is-active":""}${L&&!q?" is-today":""}`,onClick:()=>{E(V),y("days")},children:V},V)})})]}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"bonsaif-multi-weekdays bonsaif-cal-picker-weekdays",children:gi.map(V=>t.jsx("div",{className:"bonsaif-multi-weekday",children:V},V))}),t.jsx("div",{className:"bonsaif-cal-picker-days",children:H.map((V,q)=>{if(V===null)return t.jsx("div",{className:"bonsaif-multi-day bonsaif-multi-day-hidden"},q);const L=ca(x,h,V),oe=L===e,B=L===l,F=!!(n&&L<n);return t.jsx("div",{className:`bonsaif-multi-day${oe?" bonsaif-multi-day-selected":""}${B?" bonsaif-multi-day-today":""}${F?" bonsaif-multi-day-disabled":""}`,children:t.jsx("button",{type:"button",className:"bonsaif-multi-day-btn",disabled:F,"aria-pressed":oe,onClick:()=>!F&&ae(V),children:V})},q)})})]})]})});return d?t.jsxs("div",{ref:f,className:`relative w-full ${o}`.trim(),children:[t.jsxs("button",{type:"button",onClick:()=>m(V=>!V),className:"bonsaif-cal-trigger","data-open":u?"true":"false",children:[t.jsxs("span",{className:"inline-flex items-center gap-2 min-w-0",children:[t.jsx(z.HiCalendarDays,{className:"w-4 h-4 text-[var(--text-muted)]"}),t.jsx("span",{className:"truncate",children:yi(e)})]}),t.jsx(z.HiChevronDown,{className:`w-4 h-4 text-[var(--text-muted)] transition-transform ${u?"rotate-180":""}`})]}),u&&t.jsx("div",{className:"absolute z-50",style:{...b.horizontal==="left"?{left:0}:{right:0},...b.vertical==="bottom"?{top:"calc(100% + 8px)"}:{bottom:"calc(100% + 8px)"}},children:X})]}):X}const wi={sm:"h-4 w-4",md:"h-5 w-5"};function ki(e,r){if(typeof e=="function"){e(r);return}e&&(e.current=r)}const dn=s.forwardRef(function({label:r,description:n,error:a,size:o="md",indeterminate:l=!1,className:i="",containerClassName:c="",disabled:d,...u},m){const f=s.useRef(null);return s.useEffect(()=>{f.current&&(f.current.indeterminate=l)},[l]),t.jsxs("label",{className:`group inline-flex items-start gap-2.5 ${d?"cursor-not-allowed opacity-60":"cursor-pointer"} ${c}`,children:[t.jsxs("span",{className:"relative mt-0.5 inline-flex shrink-0",children:[t.jsx("input",{...u,ref:b=>{f.current=b,ki(m,b)},type:"checkbox",disabled:d,"aria-checked":l?"mixed":u["aria-checked"],"aria-invalid":!!a||u["aria-invalid"],className:`peer ${wi[o]} 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 ${i}`}),t.jsx(z.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 peer-aria-checked:mixed:scale-100 peer-aria-checked:mixed:opacity-100"})]}),(r||n||a)&&t.jsxs("span",{className:"min-w-0",children:[r&&t.jsx("span",{className:"block text-sm font-medium leading-5 text-[var(--text-main)]",children:r}),n&&!a&&t.jsx("span",{className:"block text-xs leading-5 text-[var(--text-muted)]",children:n}),a&&t.jsx("span",{className:"block text-xs leading-5 text-[var(--danger)]",children:a})]})]})});function Es(e){const r=document.createElement("textarea");r.value=e,r.style.position="fixed",r.style.opacity="0",r.style.pointerEvents="none",document.body.appendChild(r),r.select(),document.execCommand("copy"),document.body.removeChild(r)}async function Ni(e){var r;if((r=navigator.clipboard)!=null&&r.writeText){await navigator.clipboard.writeText(e);return}Es(e)}function Si(e){return typeof e=="function"?e():e}function da({value:e,resetDelay:r=2e3,title:n,copiedTitle:a="Copiado",copiedLabel:o,icon:l=t.jsx(z.HiClipboardDocument,{size:14}),copiedIcon:i=t.jsx(z.HiCheck,{size:14}),stopPropagation:c=!0,onCopied:d,onCopyError:u,className:m="",style:f,children:b,onClick:v,type:x="button",...E}){const[h,$]=s.useState(!1),M=s.useRef(null);s.useEffect(()=>()=>{M.current&&window.clearTimeout(M.current)},[]);function y(k){$(!0),d==null||d(k),M.current&&window.clearTimeout(M.current),M.current=window.setTimeout(()=>{$(!1),M.current=null},r)}async function w(k){var A;if(c&&k.stopPropagation(),v==null||v(k),k.defaultPrevented)return;const N=Si(e);if(N)try{await Ni(N),y(N)}catch(C){try{Es(N),y(N)}catch(j){u==null||u(j,N);return}(A=navigator.clipboard)!=null&&A.writeText||u==null||u(C,N)}}return t.jsxs("button",{...E,type:x,onClick:w,title:h?a:n,"aria-label":E["aria-label"]??(h?a:n),"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 ${b?"min-w-7 px-2":"w-7"} ${m}`,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",...f},children:[t.jsx("span",{className:"inline-flex items-center justify-center transition-all duration-150",style:{transform:h?"scale(1.15)":"scale(1)"},children:h?i:l}),b&&t.jsx("span",{className:"text-xs font-semibold leading-none",children:h?o??b:b})]})}function Ci({code:e,children:r,title:n="Codigo",language:a,copyLabel:o="Copiar",copiedLabel:l="Copiado",className:i="",style:c,onCopied:d}){const u=(e??r??"").trim();return t.jsxs("div",{className:`overflow-hidden rounded-lg border ${i}`,style:{borderColor:"rgba(148, 163, 184, 0.22)",background:"#0f172a",color:"#e2e8f0",...c},children:[t.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:[t.jsx("span",{className:"min-w-0 truncate text-[11px] font-black uppercase tracking-[0.08em]",children:n}),t.jsx(da,{value:u,title:"Copiar codigo",copiedTitle:"Codigo copiado",copiedLabel:l,onCopied:d,className:"h-7 min-w-[72px] px-2",style:{background:"#182235",border:"1px solid rgba(148, 163, 184, 0.28)",color:"#f8fafc"},children:o})]}),t.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:t.jsx("code",{className:a?`language-${a}`:void 0,children:u})})]})}function ua(e){if(e!==void 0)return typeof e=="number"?`${e}px`:e}function fa(e){return e.normalize("NFD").replace(new RegExp("\\p{M}","gu"),"").toLowerCase()}function Ei(e,r){if(!r.trim())return!0;const n=fa(r);return fa(e.label).includes(n)||!!(e.sublabel&&fa(e.sublabel).includes(n))}function jt({value:e,onChange:r,options:n,status:a="default",ariaLabel:o,triggerVariant:l="default",showSelectedSublabel:i=!0,placeholder:c="Seleccionar…",emptyLabel:d,disabled:u=!1,className:m="",style:f,dropdownMinWidth:b,height:v=40,padding:x="0 10px",searchable:E=!0,minOptionsForSearch:h=6}){const[$,M]=s.useState(!1),[y,w]=s.useState(""),[k,N]=s.useState(-1),[A,C]=s.useState(!1),[j,W]=s.useState({}),G=s.useRef(null),T=s.useRef(null),Z=s.useRef(null),H=s.useRef(null),ae=E&&n.length>=h,X=n.find(U=>U.value===e)??null,V=l==="ghost",q=a==="error"?"var(--danger)":$?"var(--primary)":"var(--border)",L=ae&&y.trim()?n.filter(U=>Ei(U,y)):n,oe=s.useCallback(()=>{const U=G.current;if(!U)return;const K=U.getBoundingClientRect(),D=ae?272:212,ee=window.innerHeight-K.bottom,_=ee<D&&K.top>ee;W({position:"fixed",left:K.left,top:_?void 0:K.bottom+4,bottom:_?window.innerHeight-K.top+4:void 0,width:K.width,minWidth:ua(b),zIndex:9999})},[b,ae]);s.useEffect(()=>C(!0),[]),s.useEffect(()=>{if(!$)return;function U(K){var ee,_;const D=K.target;!((ee=G.current)!=null&&ee.contains(D))&&!((_=T.current)!=null&&_.contains(D))&&(M(!1),w(""))}return document.addEventListener("mousedown",U),()=>document.removeEventListener("mousedown",U)},[$]),s.useEffect(()=>{$&&(N(-1),oe(),ae&&setTimeout(()=>{var U;return(U=Z.current)==null?void 0:U.focus()},0))},[$,ae,oe]),s.useEffect(()=>{if($)return window.addEventListener("resize",oe),window.addEventListener("scroll",oe,!0),()=>{window.removeEventListener("resize",oe),window.removeEventListener("scroll",oe,!0)}},[$,oe]),s.useEffect(()=>{if(k<0||!H.current)return;const U=H.current.children[k];U==null||U.scrollIntoView({block:"nearest"})},[k]);const B=s.useCallback(U=>{r(U),M(!1),w("")},[r]),F=s.useRef($);F.current=$;const le=s.useRef(L);le.current=L;const g=s.useRef(k);g.current=k;const P=s.useRef(d);P.current=d;const I=s.useRef(B);I.current=B,s.useEffect(()=>{function U(K){var se,Q;const D=document.activeElement,ee=((se=G.current)==null?void 0:se.contains(D))??!1,_=((Q=T.current)==null?void 0:Q.contains(D))??!1;if(!(!ee&&!_)){if(!F.current){(K.key==="Enter"||K.key===" "||K.key==="ArrowDown")&&(K.preventDefault(),M(!0));return}switch(K.key){case"ArrowDown":K.preventDefault(),N(de=>Math.min(de+1,le.current.length-1));break;case"ArrowUp":K.preventDefault(),N(de=>Math.max(de-1,P.current?-1:0));break;case"Enter":{K.preventDefault();const de=g.current,Se=le.current;de===-1&&P.current?I.current(""):Se[de]&&!Se[de].disabled&&I.current(Se[de].value);break}case"Escape":K.preventDefault(),K.stopPropagation(),M(!1),w("");break}}}return document.addEventListener("keydown",U),()=>document.removeEventListener("keydown",U)},[]);const te=t.jsxs("div",{ref:T,"data-bonsaif-select-dropdown":"true",className:"rounded-xl shadow-xl overflow-hidden",style:{...j,background:"var(--bg-card)",border:"1px solid var(--border)"},children:[ae&&t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",style:{borderBottom:"1px solid var(--border)"},children:[t.jsx(z.HiMagnifyingGlass,{className:"w-3.5 h-3.5 flex-shrink-0",style:{color:"var(--text-muted)"}}),t.jsx("input",{ref:Z,value:y,onChange:U=>{w(U.target.value),N(-1)},placeholder:"Buscar…",className:"min-w-0 flex-1 text-sm bg-transparent outline-none",style:{color:"var(--text-main)"}}),y&&t.jsx("button",{type:"button",onMouseDown:U=>{U.preventDefault(),w("")},children:t.jsx(z.HiXMark,{className:"w-3.5 h-3.5",style:{color:"var(--text-muted)"}})})]}),t.jsxs("ul",{ref:H,role:"listbox",className:"overflow-y-auto",style:{maxHeight:ae?220:180,scrollbarWidth:"thin",scrollbarColor:"var(--border) transparent",overscrollBehavior:"contain"},children:[d&&t.jsx("li",{role:"option","aria-selected":e==="",onMouseDown:U=>{U.preventDefault(),B("")},onMouseEnter:()=>N(-1),className:"flex items-center gap-2 px-3 py-2 cursor-pointer text-sm transition-colors",style:{background:k===-1&&!y.trim()?"var(--bg-hover)":"transparent",color:"var(--text-muted)",fontStyle:"italic"},children:d}),L.map((U,K)=>{const ee=K===k,_=U.value===e;return t.jsxs("li",{role:"option","aria-selected":_,onMouseDown:se=>{se.preventDefault(),U.disabled||B(U.value)},onMouseEnter:()=>!U.disabled&&N(K),className:"flex items-center gap-2 px-3 py-2 cursor-pointer text-sm transition-colors",style:{background:ee?"var(--bg-hover)":_?"color-mix(in srgb, var(--primary) 6%, transparent)":"transparent",color:U.disabled?"var(--text-muted)":"var(--text-main)",cursor:U.disabled?"not-allowed":"pointer",boxShadow:_?"inset 2px 0 0 var(--primary)":void 0},children:[U.color&&t.jsx("span",{className:"flex-shrink-0 w-2.5 h-2.5 rounded-full",style:{background:U.color}}),t.jsxs("span",{className:"min-w-0 flex flex-1 items-baseline gap-1 overflow-hidden",children:[t.jsx("span",{className:"truncate",children:U.label}),U.sublabel&&t.jsx("span",{className:"min-w-0 flex-shrink truncate",style:{color:"var(--text-muted)",fontSize:12},children:U.sublabel})]}),U.badge&&t.jsx("span",{className:"text-xs flex-shrink-0",style:{color:"var(--text-muted)"},children:U.badge})]},U.value)}),L.length===0&&t.jsx("li",{className:"px-3 py-4 text-sm text-center",style:{color:"var(--text-muted)"},children:"Sin resultados"})]})]});return t.jsxs("div",{ref:G,className:`relative ${m||"w-full"}`,style:f,children:[t.jsxs("button",{type:"button",disabled:u,onClick:()=>!u&&M(U=>!U),className:"flex w-full items-center gap-2 rounded-lg text-left text-sm transition-colors focus:outline-none",style:{height:ua(v),padding:ua(x),background:V?"transparent":"var(--bg-input)",color:X?"var(--text-main)":"var(--text-muted)",border:V?"1px solid transparent":`1px solid ${q}`,opacity:u?.5:1,cursor:u?"not-allowed":"pointer"},"aria-haspopup":"listbox","aria-expanded":$,"aria-label":o,children:[(X==null?void 0:X.color)&&t.jsx("span",{className:"flex-shrink-0 w-2.5 h-2.5 rounded-full",style:{background:X.color}}),t.jsx("span",{className:"min-w-0 flex flex-1 items-baseline gap-1 overflow-hidden",children:X?t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"truncate",children:X.label}),i&&X.sublabel&&t.jsx("span",{className:"min-w-0 flex-shrink truncate",style:{color:"var(--text-muted)",fontSize:12},children:X.sublabel})]}):t.jsx("span",{className:"truncate",children:c})}),X&&d?t.jsx("span",{role:"button",tabIndex:-1,onMouseDown:U=>{U.preventDefault(),U.stopPropagation(),B("")},className:"flex-shrink-0 rounded-full p-0.5 transition-colors hover:bg-black/10",style:{color:"var(--text-muted)"},children:t.jsx(z.HiXMark,{className:"w-3 h-3"})}):t.jsx(z.HiChevronDown,{className:"flex-shrink-0 w-4 h-4 transition-transform",style:{color:"var(--text-muted)",transform:$?"rotate(180deg)":"rotate(0deg)"}})]}),$&&A&&nt.createPortal(te,document.body)]})}function un(e){if(e!==void 0)return typeof e=="number"?`${e}px`:e}function Mi({value:e,onChange:r,placeholder:n="Buscar...",className:a="",height:o=40,padding:l="0 10px 0 30px",iconLeft:i=10}){return t.jsxs("div",{className:`relative ${a}`,children:[t.jsx(z.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:un(i)}}),t.jsx("input",{type:"text",value:e,onChange:c=>r(c.target.value),placeholder:n,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:un(o),padding:un(l)}})]})}function $i({value:e,onChange:r,options:n,placeholder:a,icon:o,className:l="",height:i=40,padding:c,iconLeft:d=10,searchable:u=!0}){const m=o?n.map((f,b)=>b===0&&!f.color?{...f,sublabel:f.sublabel??void 0}:f):n;return t.jsxs("div",{className:`relative ${l}`,children:[o&&t.jsx("span",{className:"pointer-events-none absolute top-1/2 z-10 -translate-y-1/2 text-[var(--text-muted)]",style:{left:un(d)},children:o}),t.jsx(jt,{value:e,onChange:r,options:m,placeholder:a,searchable:u,minOptionsForSearch:5,height:i,padding:c??(o?"0 10px 0 30px":"0 10px"),className:"[&>button]:text-sm [&>button]:[background:var(--bg-card)]"})]})}const Ti={sm:"24rem",md:"28rem",lg:"32rem",xl:"40rem","2xl":"48rem","4xl":"56rem","5xl":"64rem"},fn=180,Li="bg-[color-mix(in_srgb,var(--bg-main)_72%,transparent)] backdrop-blur-sm";function ba({open:e,onClose:r,title:n,subtitle:a,leadingIcon:o,headerActions:l,footer:i,children:c,size:d="md",maxWidth:u,zIndex:m=1e3,closeOnBackdrop:f=!0,closeOnEscape:b=!0,showCloseButton:v=!0,placement:x="center",bodyClassName:E="px-6 py-5",panelClassName:h="",backdropClassName:$=Li,contentClassName:M="p-4",ariaLabel:y,frameless:w=!1,disabled:k=!1}){const[N,A]=s.useState(!1),[C,j]=s.useState(!1),W=s.useRef(null);if(s.useEffect(()=>(e?(W.current&&clearTimeout(W.current),A(!0),requestAnimationFrame(()=>requestAnimationFrame(()=>j(!0)))):(j(!1),W.current=setTimeout(()=>A(!1),fn+40)),()=>{W.current&&clearTimeout(W.current)}),[e]),s.useEffect(()=>{if(e)return document.body.style.overflow="hidden",()=>{document.body.style.overflow=""}},[e]),s.useEffect(()=>{if(!e||!b)return;const X=V=>{V.key==="Escape"&&r()};return window.addEventListener("keydown",X),()=>window.removeEventListener("keydown",X)},[b,r,e]),!N)return null;const G=n||a||o||l||v,T=u??Ti[d],Z=x==="bottom-mobile"?"items-end sm:items-center justify-center p-0 sm:p-4":"items-center justify-center",H=x==="bottom-mobile"?"rounded-t-2xl sm:rounded-2xl":"rounded-2xl",ae=C?"translateY(0) scale(1)":x==="bottom-mobile"?"translateY(16px) scale(0.98)":"translateY(10px) scale(0.96)";return nt.createPortal(t.jsxs("div",{role:"dialog","aria-modal":"true","data-bonsaif-overlay":"true","aria-label":y??n,className:`fixed inset-0 flex ${Z} ${M}`,style:{zIndex:m},children:[t.jsx("div",{className:`absolute inset-0 ${$}`,onClick:f?r:void 0,style:{opacity:C?1:0,transition:`opacity ${fn}ms ease`}}),t.jsxs("div",{className:`relative z-10 flex max-h-[92dvh] w-full flex-col overflow-hidden ${w?"shadow-none":"shadow-2xl"} ${H} ${h}`,style:{maxWidth:T,background:w?"transparent":"var(--bg-card)",border:w?"none":"1px solid var(--border)",opacity:C?1:0,transform:ae,transition:`opacity ${fn}ms ease, transform ${fn}ms ease`},onClick:X=>X.stopPropagation(),children:[k&&t.jsx("div",{className:"absolute inset-0 z-[1002] cursor-not-allowed rounded-2xl",style:{background:"color-mix(in srgb, var(--bg-card, #ffffff) 60%, transparent)",backdropFilter:"blur(2px)"}}),G&&t.jsxs("div",{className:"flex flex-shrink-0 items-center justify-between gap-3 px-6 py-4",style:{borderBottom:"1px solid var(--border)"},children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[o&&t.jsx("div",{className:"flex-shrink-0",children:o}),(n||a)&&t.jsxs("div",{className:"min-w-0",children:[n&&t.jsx("h2",{className:"truncate text-base font-semibold",style:{color:"var(--text-main)"},children:n}),a&&t.jsx("p",{className:"truncate text-xs",style:{color:"var(--text-muted)"},children:a})]})]}),t.jsxs("div",{className:"flex flex-shrink-0 items-center gap-2",children:[l,v&&t.jsx(je,{variant:"icon",onClick:r,title:"Cerrar",children:t.jsx(z.HiXMark,{className:"h-5 w-5"})})]})]}),t.jsx("div",{className:`min-h-0 flex-1 overflow-y-auto ${E}`,children:c}),i&&t.jsx("div",{className:"flex flex-shrink-0 justify-end gap-2 px-6 py-4",style:{borderTop:"1px solid var(--border)"},children:i})]})]}),document.body)}const Ai={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 Di({open:e,title:r,description:n,confirmLabel:a="Confirmar",cancelLabel:o="Cancelar",variant:l="danger",closeOnBackdrop:i=!0,onConfirm:c,onCancel:d}){const u=Ai[l];return t.jsx(ba,{open:e,onClose:d,size:"md",zIndex:9998,showCloseButton:!1,bodyClassName:"p-0",panelClassName:"overflow-visible",ariaLabel:r,closeOnBackdrop:i,children:t.jsxs("div",{className:"relative px-6 pb-6 pt-6",children:[t.jsx(je,{variant:"icon",onClick:d,className:"absolute right-3 top-3 h-8 w-8 hover:opacity-70",style:{color:"var(--text-muted)"},"aria-label":"Cancelar",children:t.jsx(z.HiXMark,{className:"h-4 w-4"})}),t.jsxs("div",{className:"flex gap-3 pr-8",children:[t.jsx("div",{className:"mt-0.5 flex h-10 w-10 flex-shrink-0 items-center justify-center rounded-xl",style:{background:u.iconBg},children:t.jsx(z.HiExclamationTriangle,{className:"h-5 w-5",style:{color:u.iconColor}})}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("h2",{className:"text-base font-semibold leading-snug",style:{color:"var(--text-main)"},children:r}),n?t.jsx("div",{className:"mt-1.5 text-sm leading-relaxed",style:{color:"var(--text-muted)"},children:n}):null]})]}),t.jsxs("div",{className:"mt-6 flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",children:[t.jsx(je,{variant:"secondary",onClick:d,className:"w-full sm:w-auto sm:min-w-[7.5rem]",style:{background:"var(--bg-input)"},children:o}),t.jsx(je,{variant:"danger",onClick:c,className:"w-full sm:w-auto sm:min-w-[7.5rem]",style:{background:u.btnBg,color:u.btnColor,borderColor:"transparent"},children:a})]})]})})}function Ii(e){return e?typeof e=="function"?e():e:""}function Oi(e){return/^https?:\/\//i.test(e)}function Ms(e,r){try{return new URL(e,r).toString()}catch{return e}}function Hi(e,r,n,a=!1){const o=typeof e=="function"?e():e,l=r?r(o):o;if(!l||Oi(l))return l;const i=Ii(n);return i?Ms(l,i):a&&typeof window<"u"?Ms(l,window.location.origin):l}function Bi({url:e,resolveUrl:r,baseUrl:n,useWindowOriginForRelative:a=!1,title:o="Copiar link",copiedTitle:l="Link copiado",icon:i=t.jsx(z.HiLink,{className:"h-3.5 w-3.5"}),...c}){return t.jsx(da,{...c,value:()=>Hi(e,r,n,a),title:o,copiedTitle:l,icon:i})}const bn=[25,50,100,200,500];let ft={dataTable:{pageSizeOptions:[...bn]}};function Fi(){if(typeof window>"u")return;const r=window.__BONSAIF_DATA_TABLE_PREFERENCES_ENDPOINT__;return typeof r=="string"&&r.trim().length>0?r.trim().replace(/\/+$/,""):void 0}function ma(){const e=ft.dataTable.preferencesEndpoint,r=Fi();return e&&e.trim().length>0?e.trim().replace(/\/+$/,""):r}function Pi(e){if(!Array.isArray(e))return[...bn];const r=Array.from(new Set(e.map(n=>typeof n=="number"?Math.floor(n):Number.NaN).filter(n=>Number.isFinite(n)&&n>0)));return r.length>0?r:[...bn]}function $s(e){if(typeof e!="string")return;const r=e.trim();if(r)return r.replace(/\/+$/,"")}function _i(e){if(!e||typeof e!="object"||!e.dataTable)return;const r=$s(e.dataTable.preferencesEndpoint);ft={...ft,dataTable:{...ft.dataTable,pageSizeOptions:Pi(e.dataTable.pageSizeOptions),preferencesEndpoint:r??ft.dataTable.preferencesEndpoint}}}function zi(){return{dataTable:{pageSizeOptions:[...ft.dataTable.pageSizeOptions]}}}function Ir(){return[...ft.dataTable.pageSizeOptions]}function ji(){ft={dataTable:{pageSizeOptions:[...bn]}}}function Wi(e){ft={...ft,dataTable:{...ft.dataTable,preferencesEndpoint:$s(e)}}}const mn=[{value:"equals",label:"Igual a",valueMode:"single"},{value:"notEquals",label:"No es igual a",valueMode:"single"},{value:"greaterThan",label:"Mayor que",valueMode:"single"},{value:"greaterThanOrEqual",label:"Mayor o igual que",valueMode:"single"},{value:"lessThan",label:"Menor que",valueMode:"single"},{value:"lessThanOrEqual",label:"Menor o igual que",valueMode:"single"},{value:"between",label:"Entre",valueMode:"between"},{value:"top10",label:"10 superiores",valueMode:"none"},{value:"bottom10",label:"10 inferiores",valueMode:"none"},{value:"aboveAverage",label:"Sobre promedio",valueMode:"none"},{value:"belowAverage",label:"Bajo promedio",valueMode:"none"}],qi=mn.map(e=>({value:e.value,label:e.label})),Ui=12,Vi={layout:!0,filters:!1,sort:!1,bql:!1,pagination:!0},Ts={layout:!0,filters:!0,sort:!0,bql:!0,pagination:!0},Yi="bonsaif-ui:datatable:",Xi="[&_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",Ki=[],Gi=52;function St(e){if(!e)return 150;const r=parseInt(e,10);return isNaN(r)||r<=0?150:r}function Ls(e){return!!(e&&(Array.isArray(e.columnOrder)&&e.columnOrder.length>0||e.columnWidths&&Object.keys(e.columnWidths).length>0||Array.isArray(e.hiddenColumnKeys)&&e.hiddenColumnKeys.length>0||e.filters&&Object.keys(e.filters).length>0||e.conditionFilters&&Object.keys(e.conditionFilters).length>0||e.sort||typeof e.bql=="string"||Array.isArray(e.bqlHistory)&&e.bqlHistory.length>0||typeof e.pageSize=="number"))}function As(e){return`${Yi}${e}`}function pn(e){try{const r=window.localStorage.getItem(As(e));if(!r)return null;const n=JSON.parse(r);return n&&typeof n=="object"?n:null}catch{return null}}function Zi(e,r){try{window.localStorage.setItem(As(e),JSON.stringify(r))}catch{}}function Qi(e,r){if(e===!0)return{...Ts};if(e===!1)return{layout:!1,filters:!1,sort:!1,bql:!1,pagination:!1};if(r&&e==null)return{...Ts};const n={...Vi,...e??{}};return r&&(typeof e!="object"||e.pagination!==!1)&&(n.pagination=!0),n}function Ds(...e){return e.reduce((r,n)=>({...r,...n??{}}),{})}function pa(e,r,n){return typeof e!="number"||e<=0?n:Pr(r).includes(e)?e:n}function Or(e){if(!e||typeof e!="object")return!1;const r=e;return typeof r.key=="string"&&(r.dir==="asc"||r.dir==="desc")}function Hr(e,r){if(!e||typeof e!="object"||Array.isArray(e))return{};const n=Object.entries(e).flatMap(([a,o])=>{if(!r.has(a)||!Array.isArray(o))return[];const l=o.filter(i=>typeof i=="string");return l.length>0?[[a,l]]:[]});return Object.fromEntries(n)}function Br(e,r){if(!e||typeof e!="object"||Array.isArray(e))return{};const n=new Set(mn.map(o=>o.value)),a=Object.entries(e).flatMap(([o,l])=>{if(!r.has(o)||!l||typeof l!="object")return[];const i=l;return!i.operator||!n.has(i.operator)?[]:[[o,{operator:i.operator,value:typeof i.value=="string"?i.value:"",valueTo:typeof i.valueTo=="string"?i.valueTo:""}]]});return Object.fromEntries(a)}function at(e,r){if(Wt(e))return Gi;const n=e.minWidth??80,a=e.maxWidth??1/0;return Math.min(a,Math.max(n,r))}function Ji(e){const r=window.getComputedStyle(e);return parseFloat(r.paddingLeft)+parseFloat(r.paddingRight)}function Wt(e){return e.key==="actions"||e.key==="acciones"?!0:typeof e.header=="string"&&e.header.trim().toLowerCase()==="acciones"}function ha(e){return e.sticky===!0}function Is(e){return!(e.reorderable===!1||e.sticky&&e.reorderable!==!0)}function Lt(e,r){const n=r.filter(ha).map(i=>i.key);if(n.length===0)return e;const a=new Set(n),o=n.filter(i=>e.includes(i)),l=e.filter(i=>!a.has(i));return[...o,...l]}function Ri(e,r){if(r<=7)return Array.from({length:r},(a,o)=>o+1);const n=[1];e>3&&n.push("...");for(let a=Math.max(2,e-1);a<=Math.min(r-1,e+1);a++)n.push(a);return e<r-2&&n.push("..."),n.push(r),n}function At(e,r){var i;const n=new Set(r.filter(c=>c.hideable!==!1).map(c=>c.key)),a=Array.from(new Set(e??[])).filter(c=>n.has(c));if(r.filter(c=>!a.includes(c.key)).length>0)return a;const l=(i=r.find(c=>c.hideable!==!1))==null?void 0:i.key;return l?a.filter(c=>c!==l):[]}function ec(e){return e==null||e===""?"(Vacio)":e instanceof Date?e.toLocaleDateString():String(e)}function nr(e){return e==null||typeof e=="boolean"?"":typeof e=="string"||typeof e=="number"?String(e):Array.isArray(e)?e.map(nr).join(" ").trim():s.isValidElement(e)?nr(e.props.children):""}function hn(e,r){const n=e.filterValue?e.filterValue(r):e.sortKey?r[e.sortKey]:e.cell(r);return typeof n=="string"||typeof n=="number"||typeof n=="boolean"||n===null||n===void 0||n instanceof Date?ec(n):nr(n).trim()}function Fr(e){const r=e.replace(/,/g,"").trim();if(!r)return null;const n=Number(r);return Number.isFinite(n)?n:null}function ar(e,r){const n=Fr(e),a=Fr(r);return n!==null&&a!==null?n-a:e.localeCompare(r,void 0,{numeric:!0,sensitivity:"base"})}function Pr(e){const r=Array.from(new Set(e.map(n=>Math.floor(n)).filter(n=>Number.isFinite(n)&&n>0)));return r.length>0?r:Ir()}function tc(e,r,n){var i,c;const a=((i=r.value)==null?void 0:i.trim())??"",o=((c=r.valueTo)==null?void 0:c.trim())??"",l=mn.find(d=>d.value===r.operator);if((l==null?void 0:l.valueMode)==="single"&&!a||(l==null?void 0:l.valueMode)==="between"&&(!a||!o))return!0;switch(r.operator){case"equals":return e.toLowerCase()===a.toLowerCase();case"notEquals":return e.toLowerCase()!==a.toLowerCase();case"greaterThan":return ar(e,a)>0;case"greaterThanOrEqual":return ar(e,a)>=0;case"lessThan":return ar(e,a)<0;case"lessThanOrEqual":return ar(e,a)<=0;case"between":return ar(e,a)>=0&&ar(e,o)<=0;case"top10":case"bottom10":{const u=n.map(f=>({value:f,number:Fr(f)})).filter(f=>f.number!==null).sort((f,b)=>f.number-b.number).map(f=>f.value);return(r.operator==="top10"?u.slice(-10):u.slice(0,10)).includes(e)}case"aboveAverage":case"belowAverage":{const d=n.map(Fr).filter(f=>f!==null);if(d.length===0)return!1;const u=d.reduce((f,b)=>f+b,0)/d.length,m=Fr(e);return m===null?!1:r.operator==="aboveAverage"?m>u:m<u}default:return!0}}function Os({children:e,className:r="",style:n}){return t.jsx(zt,{onlyWhenOverflow:!0,className:r,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,...n},children:e})}function Hs({columns:e,data:r,getRowId:n,loading:a=!1,skeletonRows:o=8,emptyIcon:l,emptyText:i="Sin resultados",initialEmptyDelay:c=450,onRowClick:d,renderExpandedRow:u,getRowCanExpand:m,expandedRowIds:f,defaultExpandedRowIds:b=[],onExpandedRowIdsChange:v,expandOnRowClick:x=!1,selected:E,onToggleOne:h,onToggleAll:$,getRowSelectable:M,highlightSelected:y=!0,rowClassName:w,getRowCategory:k,stickyHeader:N=!0,pageSize:A=25,pageSizeOptions:C,pageSizeSelectWidth:j=62,pageSizeSelectHeight:W=30,pageSizeSelectPadding:G="0 7px",totalRows:T,page:Z,onPageChange:H,onPageSizeChange:ae,storageKey:X,stickyFirstColumn:V=!1,bottomOffset:q=0,compact:L=!0,restrictHeight:oe=!0,maxHeight:B,minTableWidth:F,enableColumnVisibility:le=!0,enableColumnFilters:g=!0,hiddenColumnKeys:P,defaultHiddenColumnKeys:I=Ki,onHiddenColumnKeysChange:te,columnVisibilityLabel:U="Columnas",enableBql:K=!1,bqlValue:D,defaultBqlValue:ee="",onBqlChange:_,bqlDescription:se="Filtra registros con Bonsaif Query Language",bqlPlaceholder:Q=`status = activo
2
- rol IN (admin, employee)`,bqlQuickFilters:de=[],bqlExamples:Se=[],bqlSuggestions:ie=[],bqlActiveFilters:pe,bqlError:Ce,onQueryChange:De,persistState:mt,onPreferencesReady:xt,enableExport:We=!1,exportFilename:Le="datos"}){var Xl;const ke=Qi(mt,X),et=Object.values(ke).some(Boolean),me=e.map(p=>p.key).join(","),J=I.join(","),re=s.useRef(e),be=s.useRef(I);re.current=e,be.current=I;const[he,Be]=s.useState(!X||!et),Te=s.useRef(null),He=s.useRef(!X),Fe=s.useRef(!1),ce=s.useRef(xt);ce.current=xt;const ue=s.useRef(!X||!et?X??"__none__":null),Ee=P!==void 0,[Ie,Ae]=s.useState(()=>At(I,e)),Pe=At(Ee?P:Ie,e),[Ge,Ze]=s.useState(!1),[Qe,Et]=s.useState("filter"),[Ht,Ut]=s.useState(null),[bl,ml]=s.useState(""),[dt,yr]=s.useState({}),[wt,Qr]=s.useState({}),Ga=f!==void 0,[pl,Ef]=s.useState(b),Vt=D!==void 0,[Mf,Jr]=s.useState(ee),Mt=Vt?D:Mf,[Rr,_n]=s.useState(Mt),[$t,Yt]=s.useState(!1),[hl,xr]=s.useState(!1),[gl,wr]=s.useState(!1),[en,kr]=s.useState([]),Nr=s.useRef(null),Xt=s.useRef(null),kt=s.useRef(_);kt.current=_;const zn=s.useRef(A);zn.current=A;const jn=s.useRef(C);jn.current=C;const $f=Array.isArray(C)?C.join(","):"",Za=s.useRef(null),vl=s.useRef(null),Qa=s.useRef(null),yl=s.useRef(0),[Tf,Lf]=s.useState({}),[Af,Df]=s.useState({}),[tn,Wn]=s.useState(!1),Ja=s.useRef(null),qn=s.useRef(null),[If,Of]=s.useState({}),xl=s.useRef(null),Un=s.useRef(null),[Ra,wl]=s.useState(r.length>0||a||c===!1),kl=(p,S)=>50+(p*17+S*13+7)%40,Bt=s.useRef(null),[Hf,Bf]=s.useState(void 0),[Nl,Ff]=s.useState(0),[Pf,_f]=s.useState(!1);s.useEffect(()=>{function p(){_f(window.innerWidth<640)}if(!oe||B!==void 0)return p(),window.addEventListener("resize",p),()=>window.removeEventListener("resize",p);const R=A!==!1?48:0,O=12;function ne(){if(p(),!Bt.current)return;const fe=Bt.current.getBoundingClientRect().top;Bf(Math.max(120,window.innerHeight-fe-R-O-q))}return ne(),window.addEventListener("resize",ne),()=>window.removeEventListener("resize",ne)},[a,A,q,oe,B]);const Sl=oe?B??Hf:void 0;s.useEffect(()=>{const p=Bt.current;if(!p)return;const S=()=>Ff(p.clientWidth);if(S(),typeof ResizeObserver>"u")return window.addEventListener("resize",S),()=>window.removeEventListener("resize",S);const R=new ResizeObserver(S);return R.observe(p),()=>R.disconnect()},[a,he,r.length]),s.useEffect(()=>{if(c===!1||a||r.length>0){wl(!0);return}if(Ra)return;const p=window.setTimeout(()=>{wl(!0)},c);return()=>window.clearTimeout(p)},[r.length,c,Ra,a]);const[Sr,Cr]=s.useState(()=>Lt(e.map(p=>p.key),e)),[Kt,Er]=s.useState(()=>Object.fromEntries(e.map(p=>[p.key,at(p,St(p.width))]))),[qe,Gt]=s.useState(null),[zf,Vn]=s.useState(1),[Yn,Xn]=s.useState(A===!1?0:A);s.useEffect(()=>{var Me;const p=re.current,S=be.current,R=p.map(we=>we.key),O=new Set(R),ne=()=>{var we;Fe.current||(Fe.current=!0,(we=ce.current)==null||we.call(ce))};if(!X||!et){ke.layout&&Cr(Lt(R,p)),Ee||Ae(At(S,p)),He.current=!1,Be(!0),ne();return}let fe=!1;const ve=ue.current===X;ve||(He.current=!1,Be(!1),Fe.current=!1);const $e=pn(X);if(Ls($e)&&!ve){const we=$e,ye=Pr(jn.current??Ir()),xe=zn.current,tr=xe===!1?0:xe,Ft=ke.layout?we==null?void 0:we.columnOrder:void 0,Pt=Array.isArray(Ft)?Ft.filter(_e=>R.includes(_e)):[],_t=R.filter(_e=>!Pt.includes(_e)),rr=Lt(Pt.length>0?[...Pt,..._t]:R,p),Tr=Object.fromEntries(p.map(_e=>[_e.key,at(_e,St(_e.width))])),Lr=ke.layout?(we==null?void 0:we.columnWidths)??{}:{},sn=Object.fromEntries(p.map(_e=>[_e.key,at(_e,Lr[_e.key]??Tr[_e.key])])),Ar=At(ke.layout?(we==null?void 0:we.hiddenColumnKeys)??S:S,p);if(ke.layout&&(Cr(rr),Er(sn)),Ee||Ae(Ar),ke.filters&&(yr(Hr(we==null?void 0:we.filters,O)),Qr(Br(we==null?void 0:we.conditionFilters,O))),ke.sort){const _e=Or(we==null?void 0:we.sort)?we.sort:null;Gt(_e&&O.has(_e.key)?_e:null)}if(ke.bql){if(Nr.current!==X){Nr.current=X;const _e=typeof(we==null?void 0:we.bql)=="string"?we.bql:ee;Vt?(Me=kt.current)==null||Me.call(kt,_e):Jr(_e)}kr(Array.isArray(we==null?void 0:we.bqlHistory)?we.bqlHistory.filter(_e=>typeof _e=="string"):[])}ke.pagination&&Xt.current!==X&&(Xt.current=X,Xn(pa(we==null?void 0:we.pageSize,ye,tr))),ue.current=X,Be(!0),ne()}const rt=`${ma()??"/api/user/preferences/datatables"}?key=${encodeURIComponent(X)}`,Xe=new AbortController,ge=window.setTimeout(()=>Xe.abort(),2500);return fetch(rt,{cache:"no-store",signal:Xe.signal}).then(we=>we.ok?we.json():null).then(we=>{var Kl;if(fe)return;const ye=pn(X),xe=Ds(Ls(we==null?void 0:we.settings)?we==null?void 0:we.settings:null,ye),tr=Pr(jn.current??Ir()),Ft=zn.current,Pt=Ft===!1?0:Ft,_t=ke.layout?xe==null?void 0:xe.columnOrder:void 0,rr=Array.isArray(_t)?_t.filter(Ve=>R.includes(Ve)):[],Tr=R.filter(Ve=>!rr.includes(Ve)),Lr=Lt(rr.length>0?[...rr,...Tr]:R,p),sn=Object.fromEntries(p.map(Ve=>[Ve.key,at(Ve,St(Ve.width))])),Ar=ke.layout?(xe==null?void 0:xe.columnWidths)??{}:{},_e=Object.fromEntries(p.map(Ve=>[Ve.key,at(Ve,Ar[Ve.key]??sn[Ve.key])])),Dr=At(ke.layout?(xe==null?void 0:xe.hiddenColumnKeys)??S:S,p);if(ke.layout&&(Cr(Lr),Er(_e)),Ee||Ae(Dr),ke.filters&&(yr(Hr(xe==null?void 0:xe.filters,O)),Qr(Br(xe==null?void 0:xe.conditionFilters,O))),ke.sort){const Ve=Or(xe==null?void 0:xe.sort)?xe.sort:null;Gt(Ve&&O.has(Ve.key)?Ve:null)}if(ke.bql){if(Nr.current!==X){Nr.current=X;const Ve=typeof(xe==null?void 0:xe.bql)=="string"?xe.bql:ee;Vt?(Kl=kt.current)==null||Kl.call(kt,Ve):Jr(Ve)}kr(Array.isArray(xe==null?void 0:xe.bqlHistory)?xe.bqlHistory.filter(Ve=>typeof Ve=="string"):[])}let ze;ke.pagination&&(ze=pa(xe==null?void 0:xe.pageSize,tr,Pt),Xt.current!==X&&(Xt.current=X,Xn(ze))),Te.current=JSON.stringify({columnOrder:Lr,columnWidths:_e,hiddenColumnKeys:Dr,filters:Hr(xe==null?void 0:xe.filters,O),conditionFilters:Br(xe==null?void 0:xe.conditionFilters,O),sort:Or(xe==null?void 0:xe.sort)?xe.sort:null,bql:typeof(xe==null?void 0:xe.bql)=="string"?xe.bql:"",bqlHistory:Array.isArray(xe==null?void 0:xe.bqlHistory)?xe.bqlHistory:[],pageSize:ke.pagination&&Ft!==!1?ze:void 0}),He.current=!0}).catch(()=>{var we;if(!fe){const ye=pn(X),xe=Pr(jn.current??Ir()),tr=zn.current,Ft=tr===!1?0:tr,Pt=ke.layout?ye==null?void 0:ye.columnOrder:void 0,_t=Array.isArray(Pt)?Pt.filter(ze=>R.includes(ze)):[],rr=R.filter(ze=>!_t.includes(ze)),Tr=Lt(_t.length>0?[..._t,...rr]:R,p),Lr=Object.fromEntries(p.map(ze=>[ze.key,at(ze,St(ze.width))])),sn=ke.layout?(ye==null?void 0:ye.columnWidths)??{}:{},Ar=Object.fromEntries(p.map(ze=>[ze.key,at(ze,sn[ze.key]??Lr[ze.key])]));ke.layout&&(Cr(Tr),Er(Ar));const _e=At(ke.layout?(ye==null?void 0:ye.hiddenColumnKeys)??S:S,p);if(Ee||Ae(_e),ke.filters&&(yr(Hr(ye==null?void 0:ye.filters,O)),Qr(Br(ye==null?void 0:ye.conditionFilters,O))),ke.sort){const ze=Or(ye==null?void 0:ye.sort)?ye.sort:null;Gt(ze&&O.has(ze.key)?ze:null)}if(ke.bql){if(Nr.current!==X){Nr.current=X;const ze=typeof(ye==null?void 0:ye.bql)=="string"?ye.bql:ee;Vt?(we=kt.current)==null||we.call(kt,ze):Jr(ze)}kr(Array.isArray(ye==null?void 0:ye.bqlHistory)?ye.bqlHistory.filter(ze=>typeof ze=="string"):[])}let Dr;ke.pagination&&(Dr=pa(ye==null?void 0:ye.pageSize,xe,Ft),Xt.current!==X&&(Xt.current=X,Xn(Dr))),Te.current=JSON.stringify({columnOrder:Tr,columnWidths:Ar,hiddenColumnKeys:_e,filters:Hr(ye==null?void 0:ye.filters,O),conditionFilters:Br(ye==null?void 0:ye.conditionFilters,O),sort:Or(ye==null?void 0:ye.sort)?ye.sort:null,bql:typeof(ye==null?void 0:ye.bql)=="string"?ye.bql:"",bqlHistory:Array.isArray(ye==null?void 0:ye.bqlHistory)?ye.bqlHistory:[],pageSize:ke.pagination&&tr!==!1?Dr:void 0}),He.current=!0}}).finally(()=>{window.clearTimeout(ge),fe||(ue.current=X,Be(!0),ne())}),()=>{fe=!0,Xe.abort(),window.clearTimeout(ge)}},[X,et,me,J,Ee,ke.layout,ke.filters,ke.sort,ke.bql,ke.pagination,Vt,ee,$f]),s.useEffect(()=>{if(!X||!he||!et||!He.current)return;const p={};ke.layout&&(p.columnOrder=Sr,p.columnWidths=Kt,p.hiddenColumnKeys=Pe),ke.filters&&(p.filters=dt,p.conditionFilters=wt),ke.sort&&(p.sort=qe),ke.bql&&(p.bql=Mt,p.bqlHistory=en),ke.pagination&&A!==!1&&(p.pageSize=Yn);const S=pn(X),R=Ds(S,p),O=JSON.stringify(R);if(O===Te.current)return;Zi(X,R),Te.current=O;const ne=window.setTimeout(()=>{const fe=ma()??"/api/user/preferences/datatables";fetch(fe,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({key:X,settings:R})}).then(()=>{}).catch(()=>{})},300);return()=>window.clearTimeout(ne)},[Sr,Kt,Pe,dt,wt,qe,Mt,en,Yn,A,X,he,et,ke.layout,ke.filters,ke.sort,ke.bql,ke.pagination]),s.useEffect(()=>{Cr(p=>{const S=e.map(ne=>ne.key),R=p.filter(ne=>S.includes(ne)),O=S.filter(ne=>!R.includes(ne));return Lt([...R,...O],e)})},[me,e]);const Cl=Lt(Sr,e).map(p=>e.find(S=>S.key===p)).filter(p=>!!p),ut=Cl.filter(p=>!Pe.includes(p.key)),El=e.some(ha),jf=Object.keys(dt).length,Wf=Object.keys(wt).length,es=jf+Wf;function Ml(p){const S=new Set;return r.reduce((R,O)=>{const ne=hn(p,O);return!ne||S.has(ne)||(S.add(ne),R.push({value:ne,label:ne})),R},[])}function qf(){const p=e.find(S=>S.key===Ht);return p?Ml(p):[]}function Uf(p){return!!(g&&!Wt(p)&&(p.filterValue||p.sortKey||Ml(p).length>0))}function $l(p,S){yr(R=>{const O={...R};return O[p]=S,O})}function Vf(p,S,R,O){const ne=dt[p]??[],fe=O?ne:R.filter($e=>$e!==S),ve=O?ne.includes(S)?ne.filter($e=>$e!==S):[...ne,S]:fe;ve.length===R.length?ts(p):$l(p,ve)}function ts(p){yr(S=>{const R={...S};return delete R[p],R})}function Kn(p,S){Qr(R=>{const O={...R};return S?O[p]=S:delete O[p],O})}function Tl(p){Kn(p,null)}function Yf(){yr({}),Qr({})}function Xf(p){Vt||Jr(p),_==null||_(p)}function Ll(p){const S=p.trim();_n(S),(_==null?void 0:_(S))!==!1&&(Vt||Jr(S),Yt(!1),xr(!1),wr(!1),S&&kr(O=>[S,...O.filter(ne=>ne!==S)].slice(0,Ui)))}function Al(){_n(""),Xf(""),Yt(!1),xr(!1),wr(!1)}function rs(p,S){_n(p),S&&(S.style.height="auto",S.style.height=`${Math.min(S.scrollHeight,180)}px`)}function Gn(p){const S=p.trim();if(!S)return;yl.current=Date.now()+500;const R=Rr.replace(/\s+$/u,""),O=R.length===0?S:R.split(`
3
- `).map(ne=>ne.trim()).includes(S)?R:`${R}
4
- ${S}`;rs(O,Qa.current??void 0),requestAnimationFrame(()=>{const ne=Qa.current;if(!ne)return;ne.focus();const fe=ne.value.length;ne.setSelectionRange(fe,fe),rs(ne.value,ne)})}s.useEffect(()=>{_n(Mt)},[Mt]);const Zn=s.useCallback(()=>{const p=Za.current;if(!p)return;const S=p.getBoundingClientRect(),R=12,O=8,ne=Math.min(780,Math.max(320,window.innerWidth-32)),fe=Math.max(R,window.innerWidth-ne-R),ve=Math.min(Math.max(R,S.left),fe),$e=S.bottom+O,Ke=window.innerHeight-S.top+O,Ue=window.innerHeight-$e-R,rt=S.top-R-O,Xe=Ue<280&&rt>Ue,ge=Math.max(240,Xe?rt:Ue);Lf({position:"fixed",zIndex:1e4,left:ve,top:Xe?void 0:$e,bottom:Xe?Ke:void 0,width:ne,maxWidth:"calc(100vw - 24px)",maxHeight:ge,overflowY:"auto"})},[]);s.useEffect(()=>{if(!$t)return;function p(O){var fe,ve;if(Date.now()<yl.current)return;const ne=O.target;(fe=Za.current)!=null&&fe.contains(ne)||(ve=vl.current)!=null&&ve.contains(ne)||(Yt(!1),xr(!1),wr(!1))}function S(O){O.key==="Escape"&&(Yt(!1),xr(!1),wr(!1))}function R(){Zn()}return Zn(),document.addEventListener("mousedown",p),window.addEventListener("keydown",S),window.addEventListener("resize",R),window.addEventListener("scroll",R,!0),()=>{document.removeEventListener("mousedown",p),window.removeEventListener("keydown",S),window.removeEventListener("resize",R),window.removeEventListener("scroll",R,!0)}},[$t,Zn]);function Dl(p){const S=At(p,e);Ee||Ae(S),te==null||te(S)}function Kf(p){Dl(Pe.includes(p)?Pe.filter(S=>S!==p):[...Pe,p])}function Gf(){Dl([])}const ns=s.useCallback((p=Un.current)=>{if(!p)return;const S=p.getBoundingClientRect(),R=Math.min(292,Math.max(240,window.innerWidth-16)),O=Math.max(8,window.innerWidth-R-8),ne=Math.min(Math.max(8,S.right-R),O),fe=window.innerHeight-S.bottom,ve=S.bottom+6,$e=window.innerHeight-S.top+6,Ue=fe<360&&S.top>fe?void 0:ve,rt=Ue===void 0?$e:void 0,Xe=Math.max(220,Ue===void 0?S.top-16:window.innerHeight-ve-8),ge={position:"fixed",zIndex:9999,left:ne,top:Ue,bottom:rt,width:R,maxWidth:"calc(100vw - 16px)",maxHeight:Xe,"--dt-column-menu-max-height":`${Xe}px`};Df(ge)},[]);function Il(p,S,R=null){p.preventDefault(),p.stopPropagation();const O=Un.current===p.currentTarget&&Qe===S&&Ht===R;if(Ge&&O){Ze(!1),Ut(null);return}Un.current=p.currentTarget,Et(S),Ut(R),ml(""),ns(p.currentTarget),Ze(!0)}function Zf(p){if(Wt(p))return;const S=Bt.current;if(!S)return;const O=Array.from(S.querySelectorAll("[data-dt-column-key]")).filter(ne=>ne.dataset.dtColumnKey===p.key).reduce((ne,fe)=>{const ve=fe.querySelector("[data-dt-autofit-content]"),$e=ve?ve.scrollWidth:Math.max(fe.scrollWidth,fe.offsetWidth);return Math.max(ne,Math.ceil($e+Ji(fe)))},0);O<=0||Er(ne=>({...ne,[p.key]:at(p,O+12)}))}s.useEffect(()=>{Er(p=>{const S=Object.fromEntries(e.map(R=>[R.key,at(R,St(R.width))]));return Object.fromEntries(e.map(R=>[R.key,at(R,p[R.key]??S[R.key])]))})},[me,e]),s.useEffect(()=>{Ee||Ae(p=>At(p,e))},[me,e,Ee]),s.useEffect(()=>{function p(O){var ve,$e;const ne=O.target,fe=O.target;fe!=null&&fe.closest("[data-bonsaif-select-dropdown='true']")||!((ve=xl.current)!=null&&ve.contains(ne))&&!(($e=Un.current)!=null&&$e.contains(ne))&&(Ze(!1),Ut(null))}function S(O){O.key==="Escape"&&(Ze(!1),Ut(null))}function R(){ns()}return Ge&&(document.addEventListener("mousedown",p),window.addEventListener("keydown",S),window.addEventListener("resize",R),window.addEventListener("scroll",R,!0)),()=>{document.removeEventListener("mousedown",p),window.removeEventListener("keydown",S),window.removeEventListener("resize",R),window.removeEventListener("scroll",R,!0)}},[Ge,ns]);const rn=s.useRef(null);s.useEffect(()=>{function p(R){const O=rn.current;if(!O)return;const ne=R.clientX-O.startX,fe=e.find(ve=>ve.key===O.colKey);fe&&Er(ve=>({...ve,[O.colKey]:at(fe,O.startWidth+ne)}))}function S(){rn.current&&(rn.current=null,document.body.style.cursor="",document.body.style.userSelect="")}return document.addEventListener("pointermove",p),document.addEventListener("pointerup",S),()=>{document.removeEventListener("pointermove",p),document.removeEventListener("pointerup",S)}},[e]);const nn=s.useRef(null),[Ol,as]=s.useState(null);function Qf(p,S){const R=e.find(O=>O.key===p);if(!R||!Is(R)){S.preventDefault();return}nn.current=Sr.indexOf(p),S.dataTransfer.effectAllowed="move"}function Jf(p,S){S.preventDefault(),S.dataTransfer.dropEffect="move";const R=Sr.indexOf(p);Ol!==R&&as(R)}function Rf(p,S){S.preventDefault();const R=nn.current,O=Sr.indexOf(p);R!==null&&R!==O&&Cr(ne=>{const fe=[...ne],[ve]=fe.splice(R,1);return fe.splice(O,0,ve),Lt(fe,e)}),nn.current=null,as(null)}function eb(){nn.current=null,as(null)}function tb(p){p.sortKey&&Gt(S=>(S==null?void 0:S.key)===p.key?{key:p.key,dir:S.dir==="asc"?"desc":"asc"}:{key:p.key,dir:"asc"})}s.useEffect(()=>{Vn(1)},[r]),s.useEffect(()=>{Vn(1)},[wt,dt]);const Zt=!!(H&&ae),Qt=A!==!1,Hl=s.useMemo(()=>Pr(C??Ir()),[C]),Re=Zt?Z??1:zf,Nt=Zt||Qt?Yn:r.length,pt=!!E&&!!h&&!!$,ss=s.useMemo(()=>M?r.filter(p=>M(p)):r,[r,M]),Mr=!!u,Bl=s.useMemo(()=>new Set(Ga?Array.from(f??[]):pl),[Ga,f,pl]),rb=(Mr?40:0)+(pt?40:0),os=!Pf&&(El||V),Qn=(()=>{if(!os)return{};let p=rb;const S={};return ut.forEach((R,O)=>{(ha(R)||!El&&V&&O===0)&&(S[R.key]=p,p+=Kt[R.key]??at(R,St(R.width)))}),S})(),ls=Object.keys(Qn),is=ls.length>0?ls[ls.length-1]:null,Fl=pt&&ss.length>0&&ss.every(p=>E.has(n(p))),nb=pt&&E.size>0&&ss.some(p=>E.has(n(p)))&&!Fl,Jn=s.useMemo(()=>{const p=Object.entries(dt),S=Object.entries(wt);return p.length===0&&S.length===0?r:r.filter(R=>p.every(([O,ne])=>{const fe=e.find(ve=>ve.key===O);return fe?ne.includes(hn(fe,R)):!0})&&S.every(([O,ne])=>{const fe=e.find($e=>$e.key===O);if(!fe)return!0;const ve=r.map($e=>hn(fe,$e));return tc(hn(fe,R),ne,ve)}))},[wt,dt,e,r]),Jt=s.useMemo(()=>{if(!qe)return Jn;const p=e.find(S=>S.key===qe.key&&S.sortKey);return p!=null&&p.sortKey?[...Jn].sort((S,R)=>{const O=S[p.sortKey],ne=R[p.sortKey],fe=O===ne?0:O==null?1:ne==null||O<ne?-1:1;return qe.dir==="asc"?fe:-fe}):Jn},[Jn,qe,e]),Pl=s.useMemo(()=>{if(Zt||!Qt)return Jt;const p=(Re-1)*Nt;return Jt.slice(p,p+Nt)},[Jt,Zt,Qt,Re,Nt]),Rt=Zt?T??r.length:Jt.length,cs=Qt?Math.max(1,Math.ceil(Rt/Nt)):1,ab=Math.min(...Hl),sb=Qt&&(Rt>Nt||Rt>ab),ob=Qt?(Re-1)*Nt+1:1,lb=Qt?Math.min(Re*Nt,Rt):Rt;function ds(p){if(a)return;const S=Math.max(1,Math.min(p,cs));Zt?H(S):Vn(S)}function ib(p){a||(X&&(Xt.current=X),Xn(p),Zt?(ae(p),H(1)):(Vn(1),ae==null||ae(p)))}function _l(p){const S=new Set(Bl);S.has(p)?S.delete(p):S.add(p);const R=Array.from(S);Ga||Ef(R),v==null||v(R)}s.useEffect(()=>{De==null||De({bql:Mt,filters:dt,conditionFilters:wt,sort:qe,page:Re,pageSize:Nt,hiddenColumnKeys:Pe})},[Mt,dt,wt,qe,Re,Nt,Pe,De]);const zl=p=>p==="center"?"justify-center text-center":p==="right"?"justify-end text-right":"justify-start text-left",cb="color-mix(in srgb, var(--primary) 6%, var(--bg-card))",us="linear-gradient(180deg, color-mix(in srgb, var(--bg-input) 90%, var(--bg-card)) 0%, color-mix(in srgb, var(--bg-input) 70%, var(--bg-card)) 100%)",Oe="color-mix(in srgb, var(--border) 62%, var(--bg-card))",er="color-mix(in srgb, var(--primary) 24%, var(--border))",Rn=`inset 0 0 0 1px ${Oe}`,jl=ut.reduce((p,S)=>p+(Kt[S.key]??St(S.width)),(Mr?40:0)+(pt?40:0)),Wl=typeof F=="number"?F:typeof F=="string"?Number(((Xl=F.match(/^(\d+(?:\.\d+)?)px$/))==null?void 0:Xl[1])??NaN):NaN,an=Number.isFinite(Wl)?Math.max(jl,Wl,Nl):Math.max(jl,Nl),ea=F??an,$r=`${Mr?"40px ":""}${pt?"40px ":""}${ut.map(p=>`${Kt[p.key]??St(p.width)}px`).join(" ")}`;s.useEffect(()=>{qe&&Pe.includes(qe.key)&&Gt(null)},[Pe,qe]);function ql(p){return p?typeof p=="string"?{key:p,label:p}:p:null}const ta=()=>t.jsxs("div",{role:"row",className:"grid",style:{gridTemplateColumns:$r,background:us,borderBottom:`1px solid ${er}`},children:[Mr&&t.jsx("div",{role:"columnheader",className:`${L?"px-2 py-1.5":"px-3 py-2.5"} w-10`,style:{borderBottom:`1px solid ${er}`,borderRight:`1px solid ${Oe}`}}),pt&&t.jsx("div",{role:"columnheader",className:`${L?"px-2 py-1.5":"px-3 py-2.5"} flex w-10 items-center justify-center`,style:os?{position:"sticky",left:0,zIndex:12,background:us,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)",boxShadow:`inset 0 -1px 0 ${er}`,borderRight:`1px solid ${Oe}`}:{borderBottom:`1px solid ${er}`,borderRight:`1px solid ${Oe}`},children:t.jsx(dn,{size:"sm",checked:Fl,indeterminate:nb,onChange:$,"aria-label":"Seleccionar todos",containerClassName:"items-center",className:"cursor-pointer"})}),ut.map((p,S)=>{const R=(qe==null?void 0:qe.key)===p.key,O=!!p.sortKey,ne=Wt(p),fe=Qn[p.key],ve=fe!==void 0,$e=p.key===is,Ke=Is(p),Ue=Ol===S,Xe=(Kt[p.key]??St(p.width))<120,ge=Object.prototype.hasOwnProperty.call(dt,p.key)||Object.prototype.hasOwnProperty.call(wt,p.key);return t.jsxs("div",{role:"columnheader","data-dt-column-key":p.key,className:`group select-none ${Xe?"text-left":zl(p.align)}`,style:{...ve?{position:"sticky",left:fe,zIndex:12,background:us,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)",boxShadow:$e?`3px 0 6px -2px rgba(0,0,0,0.10), inset 0 -1px 0 ${er}`:`inset 0 -1px 0 ${er}`,borderRight:`1px solid ${Oe}`}:{position:"relative",borderBottom:`1px solid ${er}`,borderRight:`1px solid ${Oe}`},color:R?"var(--primary)":"var(--text-muted)",whiteSpace:"nowrap",transition:"color 0.15s",borderLeft:Ue?"2px solid var(--primary)":"2px solid transparent",cursor:"default",padding:ne?L?"7px 6px":"9px 8px":L?"8px 6px 10px":"10px 8px 12px"},onDragOver:Me=>{(Ke||nn.current!==null)&&Jf(p.key,Me)},onDrop:Me=>Rf(p.key,Me),children:[t.jsxs("div",{className:`flex min-w-0 items-center gap-1 ${ne?"justify-center":Xe?"justify-start":p.align==="center"?"justify-center":p.align==="right"?"justify-end":"justify-start"}`,children:[Ke?t.jsx("span",{draggable:!0,onDragStart:Me=>{Me.stopPropagation(),Qf(p.key,Me)},onDragEnd:Me=>{Me.stopPropagation(),eb()},onClick:Me=>Me.stopPropagation(),title:"Arrastrar para mover columna","aria-label":"Arrastrar para mover columna",className:`absolute left-0 top-0 z-10 inline-flex h-full w-3 shrink-0 rounded-sm transition-colors duration-150 hover:bg-[var(--primary)]/15 ${Ue?"bg-[var(--primary)]/20":""}`,style:{cursor:"grab"}}):null,ne?t.jsx("span",{className:"inline-flex h-5 w-5 items-center justify-center rounded-md text-[var(--text-muted)]",title:"Acciones","aria-label":"Acciones",children:t.jsx(z.HiCog6Tooth,{className:"h-3.5 w-3.5"})}):t.jsx(Os,{className:"min-w-0 flex-1",children:t.jsx("span",{"data-dt-autofit-content":!0,className:`inline-flex max-w-full items-center font-semibold uppercase tracking-wider ${L?"text-[11px]":"text-xs"}`,children:t.jsx("span",{className:"min-w-0 truncate",children:p.header})})}),O&&t.jsx("button",{type:"button","aria-label":`Ordenar por ${String(p.header)}`,title:"Ordenar",onClick:Me=>{Me.stopPropagation(),tb(p)},"data-dt-sort-button":!0,className:`absolute -bottom-2 left-1/2 z-20 inline-flex h-4 w-4 -translate-x-1/2 items-center justify-center rounded-full bg-[var(--primary)] text-[var(--primary-fg)] shadow-[0_1px_3px_rgba(15,23,42,0.22)] transition-[opacity,transform] duration-150 hover:scale-105 focus:scale-105 focus:opacity-100 focus:outline-none ${R?"opacity-100":"opacity-0 group-hover:opacity-100 group-focus-within:opacity-100"}`,style:{bottom:"-0.5rem",top:"auto"},children:R?qe.dir==="asc"?t.jsx(z.HiChevronUp,{className:"h-3 w-3"}):t.jsx(z.HiChevronDown,{className:"h-3 w-3"}):t.jsx(z.HiChevronUpDown,{className:"h-3 w-3"})}),g&&!ne&&Uf(p)&&t.jsx("button",{type:"button","aria-haspopup":"menu","aria-expanded":Ge&&Ht===p.key,"aria-label":`Filtrar ${String(p.header)}`,title:"Filtrar",onClick:Me=>Il(Me,"filter",p.key),className:`inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-sm bg-transparent text-[var(--text-muted)] opacity-0 transition-[opacity,color,background-color] duration-150 hover:bg-[var(--bg-card)] hover:text-[var(--primary)] focus:bg-[var(--bg-card)] focus:text-[var(--primary)] focus:opacity-100 group-hover:opacity-100 ${Ge&&Qe==="filter"&&Ht===p.key?"bg-[var(--bg-card)] text-[var(--primary)] opacity-100":ge?"text-[var(--primary)] opacity-100":""}`,children:ge?t.jsx(z.HiFunnel,{className:"h-3.5 w-3.5"}):t.jsx(z.HiEllipsisVertical,{className:"h-3.5 w-3.5"})})]}),!ne&&t.jsx("span",{role:"separator","aria-orientation":"vertical",title:"Arrastrar para redimensionar. Doble click para autoajustar",onPointerDown:Me=>{Me.preventDefault(),Me.stopPropagation(),rn.current={colKey:p.key,startX:Me.clientX,startWidth:Kt[p.key]??150},document.body.style.cursor="col-resize",document.body.style.userSelect="none"},onDoubleClick:Me=>{Me.preventDefault(),Me.stopPropagation(),rn.current=null,document.body.style.cursor="",document.body.style.userSelect="",Zf(p)},onClick:Me=>Me.stopPropagation(),className:"absolute top-0 flex h-full items-center justify-center opacity-0 transition-opacity duration-200 hover:opacity-100",style:{right:0,width:12,cursor:"col-resize",zIndex:6,transform:"translateX(50%)"},children:t.jsxs("span",{style:{display:"flex",gap:4,alignItems:"center",height:"calc(100% - 8px)"},children:[t.jsx("span",{style:{width:2,height:"100%",borderRadius:2,background:"var(--primary)",display:"block"}}),t.jsx("span",{style:{width:2,height:"100%",borderRadius:2,background:"var(--primary)",display:"block"}})]})})]},p.key)})]}),ra=()=>{if(!Ge||typeof document>"u"||Qe==="visibility"&&!le||Qe==="filter"&&!g)return null;const p=e.find(ge=>ge.key===Ht),S=qf(),R=p?Object.prototype.hasOwnProperty.call(dt,p.key):!1,O=p?wt[p.key]:void 0,ne=mn.find(ge=>ge.value===(O==null?void 0:O.operator)),fe=p?dt[p.key]??[]:[],ve=bl.trim().toLowerCase(),$e=ve?S.filter(ge=>ge.label.toLowerCase().includes(ve)):S,Ke=p&&S.length>0&&(!R||fe.length===S.length),Ue=p&&R&&fe.length>0&&fe.length<S.length,rt=Pe.length,Xe=()=>{p&&(ts(p.key),Tl(p.key))};return nt.createPortal(t.jsx("div",{ref:xl,role:"menu",className:"overflow-hidden rounded-lg border p-1 shadow-xl",style:{...Af,borderColor:"var(--border)",background:"var(--bg-card)"},children:Qe==="visibility"?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-[var(--border)] px-2 py-1.5",children:[t.jsx("span",{className:"min-w-0 truncate text-xs font-semibold uppercase text-[var(--text-muted)]",children:rt>0?`${ut.length} de ${e.length} visibles`:`${e.length} visibles`}),t.jsx("button",{type:"button",onClick:Gf,disabled:rt===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"})]}),t.jsx("div",{className:"max-h-72 overflow-auto py-1",children:Cl.map(ge=>{const Me=!Pe.includes(ge.key),ye=!(ge.hideable!==!1)||Me&&ut.length<=1;return t.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":Me,disabled:ye,onClick:()=>Kf(ge.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:[t.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center rounded border",style:{borderColor:Me?"var(--primary)":"var(--border)",background:Me?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:Me&&t.jsx(z.HiCheck,{className:"h-3 w-3"})}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:ge.header})]},ge.key)})})]}):p?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-[var(--border)] px-2 py-1.5",children:[t.jsxs("span",{className:"min-w-0 truncate text-xs font-semibold uppercase text-[var(--text-muted)]",children:["Filtrar ",p.header]}),t.jsx("button",{type:"button",onClick:Xe,disabled:!R&&!O,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:"Limpiar"})]}),p.sortKey&&t.jsxs("div",{className:"grid grid-cols-2 gap-1 border-b border-[var(--border)] p-1",children:[t.jsxs("button",{type:"button",onClick:()=>Gt({key:p.key,dir:"asc"}),className:"flex min-w-0 items-center justify-between rounded-md px-2 py-1.5 text-left text-sm transition-colors hover:bg-[var(--bg-input)]",style:{color:"var(--text-main)"},children:[t.jsxs("span",{className:"flex min-w-0 items-center gap-1.5 truncate",children:[t.jsx(z.HiChevronUp,{className:"h-4 w-4 shrink-0 text-[var(--primary)]"}),t.jsx("span",{className:"truncate",children:"Ascendente"})]}),(qe==null?void 0:qe.key)===p.key&&qe.dir==="asc"&&t.jsx(z.HiCheck,{className:"h-4 w-4 shrink-0 text-[var(--primary)]"})]}),t.jsxs("button",{type:"button",onClick:()=>Gt({key:p.key,dir:"desc"}),className:"flex min-w-0 items-center justify-between rounded-md px-2 py-1.5 text-left text-sm transition-colors hover:bg-[var(--bg-input)]",style:{color:"var(--text-main)"},children:[t.jsxs("span",{className:"flex min-w-0 items-center gap-1.5 truncate",children:[t.jsx(z.HiChevronDown,{className:"h-4 w-4 shrink-0 text-[var(--primary)]"}),t.jsx("span",{className:"truncate",children:"Descendente"})]}),(qe==null?void 0:qe.key)===p.key&&qe.dir==="desc"&&t.jsx(z.HiCheck,{className:"h-4 w-4 shrink-0 text-[var(--primary)]"})]})]}),t.jsxs("div",{className:"border-b border-[var(--border)] p-2",children:[t.jsxs("div",{className:"grid grid-cols-[minmax(0,1.05fr)_minmax(0,0.95fr)] gap-2",children:[t.jsx(jt,{value:(O==null?void 0:O.operator)??"",onChange:ge=>{if(!ge){Tl(p.key);return}Kn(p.key,{operator:ge,value:(O==null?void 0:O.value)??"",valueTo:(O==null?void 0:O.valueTo)??""})},options:qi,placeholder:"Opcion",emptyLabel:"Sin condicion",ariaLabel:"Operador de filtro",searchable:!1,height:34,padding:"0 9px",dropdownMinWidth:260,className:"min-w-0 [&>button]:rounded-md [&>button]:text-sm [&>button]:font-medium"}),(ne==null?void 0:ne.valueMode)!=="none"?t.jsx("input",{value:(O==null?void 0:O.value)??"",onChange:ge=>{O&&Kn(p.key,{...O,value:ge.target.value})},disabled:!O,placeholder:"Valor",className:"min-w-0 rounded-md border px-2 py-1.5 text-sm outline-none transition-colors placeholder:text-[var(--text-muted)] focus:border-[var(--primary)] disabled:opacity-50",style:{borderColor:"var(--border)",background:"var(--bg-input)",color:"var(--text-main)"}}):t.jsx("div",{className:"min-h-8 rounded-md border px-2 py-1.5 text-sm text-[var(--text-muted)]",style:{borderColor:"var(--border)",background:"var(--bg-input)"},children:"Automatico"})]}),(ne==null?void 0:ne.valueMode)==="between"&&t.jsx("input",{value:(O==null?void 0:O.valueTo)??"",onChange:ge=>{O&&Kn(p.key,{...O,valueTo:ge.target.value})},placeholder:"Valor final",className:"mt-2 w-full rounded-md border px-2 py-1.5 text-xs outline-none transition-colors placeholder:text-[var(--text-muted)] focus:border-[var(--primary)]",style:{borderColor:"var(--border)",background:"var(--bg-input)",color:"var(--text-main)"}})]}),t.jsx("div",{className:"border-b border-[var(--border)] p-2",children:t.jsxs("div",{className:"flex items-center gap-1 rounded-md border px-2 py-1.5 text-sm",style:{borderColor:"var(--border)",background:"var(--bg-input)"},children:[t.jsx(z.HiMagnifyingGlass,{className:"h-4 w-4 shrink-0 text-[var(--text-muted)]"}),t.jsx("input",{value:bl,onChange:ge=>ml(ge.target.value),placeholder:"Buscar",className:"min-w-0 flex-1 bg-transparent text-sm outline-none placeholder:text-[var(--text-muted)]",style:{color:"var(--text-main)"}})]})}),t.jsxs("div",{className:"overflow-auto py-1",style:{maxHeight:"max(96px, calc(var(--dt-column-menu-max-height, 520px) - 236px))"},children:[t.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":Ue?"mixed":!!Ke,onClick:()=>{p&&(Ke&&!R?$l(p.key,[]):ts(p.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)]",style:{color:"var(--text-main)"},children:[t.jsxs("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center rounded border",style:{borderColor:Ke||Ue?"var(--primary)":"var(--border)",background:Ke||Ue?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:[Ue&&t.jsx(z.HiMinus,{className:"h-3 w-3"}),Ke&&!Ue&&t.jsx(z.HiCheck,{className:"h-3 w-3"})]}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:"Seleccionar todo"})]}),$e.map(ge=>{const Me=!R||fe.includes(ge.value);return t.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":Me,onClick:()=>Vf(p.key,ge.value,S.map(we=>we.value),R),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)]",style:{color:"var(--text-main)"},children:[t.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center rounded border",style:{borderColor:Me?"var(--primary)":"var(--border)",background:Me?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:Me&&t.jsx(z.HiCheck,{className:"h-3 w-3"})}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:ge.label})]},ge.value)}),$e.length===0&&t.jsx("div",{className:"px-3 py-3 text-sm text-[var(--text-muted)]",children:"Sin valores"})]})]}):null}),document.body)};s.useEffect(()=>{if(!tn)return;function p(S){Ja.current&&!Ja.current.contains(S.target)&&qn.current&&!qn.current.contains(S.target)&&Wn(!1)}return document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[tn]);function Ul(p,S){if(p.filterValue){const R=p.filterValue(S);return R==null||R===""?"":String(R)}return nr(p.cell(S))}function Vl(p){return`"${p.replace(/"/g,'""')}"`}function na(p){return p.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function db(){const p=ut.filter($e=>!Wt($e)),S=p.map($e=>Vl(nr($e.header))).join(","),R=Jt.map($e=>p.map(Ke=>Vl(Ul(Ke,$e))).join(",")).join(`
5
- `),O=`${S}
6
- ${R}`,ne=new Blob(["\uFEFF"+O],{type:"text/csv;charset=utf-8;"}),fe=URL.createObjectURL(ne),ve=document.createElement("a");ve.href=fe,ve.download=`${Le}.csv`,document.body.appendChild(ve),ve.click(),document.body.removeChild(ve),URL.revokeObjectURL(fe)}function ub(){const p=ut.filter(ve=>!Wt(ve)),S=p.map(ve=>na(nr(ve.header))),O=Jt.map(ve=>p.map($e=>na(Ul($e,ve)))).map(ve=>`<tr>${ve.map($e=>`<td>${$e}</td>`).join("")}</tr>`).join(""),ne=`<!DOCTYPE html>
7
- <html lang="es"><head><meta charset="utf-8"><title>${na(Le)}</title>
1
+ (function(V,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("react"),require("react/jsx-runtime"),require("react-icons/hi2"),require("react-dom"),require("recharts"),require("overlayscrollbars"),require("sonner"),require("overlayscrollbars-react"),require("react-day-picker"),require("react-day-picker/dist/style.css"),require("react-icons/fi")):typeof define=="function"&&define.amd?define(["exports","react","react/jsx-runtime","react-icons/hi2","react-dom","recharts","overlayscrollbars","sonner","overlayscrollbars-react","react-day-picker","react-day-picker/dist/style.css","react-icons/fi"],o):(V=typeof globalThis<"u"?globalThis:V||self,o(V.BonsaifUI={},V.React,V.jsxRuntime,V.ReactIconsHi2,V.ReactDOM,V.Recharts,V.OverlayScrollbarsGlobal,V.Sonner,V.OverlayScrollbarsReact,V.ReactDayPicker,V.ReactDayPickerStyles,V.ReactIconsFi))})(this,(function(V,o,t,q,ct,Se,Ea,Ma,_o,Ta,im,Ai){"use strict";"use client";function Vt(...e){return e.filter(Boolean).join(" ")}function Li({variant:e="primary",className:r,type:n="button",children:a,...s}){return t.jsx("button",{className:Vt("bonsaif-ui-button",`bonsaif-ui-button--${e}`,r),type:n,...s,children:a})}function zo({value:e,onChange:r,placeholder:n,className:a="",autoFocus:s=!1,forceExpanded:l=!1,onEscape:i,size:c="default",inputTabIndex:d}){const u=o.useRef(null),[m,b]=o.useState(!1),f=l||m||e.trim().length>0,h=c==="sm"?"h-9 rounded-md":"h-10 rounded-lg",v=a||"w-48 max-w-full sm:w-64 lg:w-72";o.useEffect(()=>{var g;s&&((g=u.current)==null||g.focus())},[s]);const k=()=>{var g;b(!0),(g=u.current)==null||g.focus()};return t.jsxs("div",{className:`relative min-w-0 max-w-full flex-shrink-0 overflow-visible transition-[width] duration-200 ease-out ${f?v:"w-24 sm:w-28"}`,onMouseDown:g=>{f||(g.preventDefault(),k())},children:[t.jsx(q.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)",left:"var(--page-header-control-icon-left, 12px)"}}),t.jsx("input",{ref:u,type:"text",tabIndex:d,"aria-label":n,value:e,onChange:g=>r(g.target.value),onKeyDown:g=>{g.key==="Escape"&&(i==null||i())},placeholder:f?n:"Buscar",className:`${h} w-full py-0 text-sm leading-none placeholder:text-[var(--text-muted)] focus:outline-none transition-all duration-200 ${f?"pl-9 pr-8":"cursor-pointer pl-9 pr-3"}`,style:{height:`var(--page-header-control-height, ${c==="sm"?"36px":"40px"})`,paddingLeft:"calc(var(--page-header-control-icon-left, 12px) + 24px)",paddingRight:f?"calc(var(--page-header-control-padding-x, 14px) + 18px)":"var(--page-header-control-padding-x, 14px)",background:"color-mix(in srgb, var(--bg-card) 86%, transparent)",border:"1px solid var(--border)",color:"var(--text-main)"},onFocus:g=>{b(!0),g.currentTarget.style.borderColor="var(--primary)",g.currentTarget.style.boxShadow="0 0 0 3px rgba(59,130,246,0.12)"},onBlur:g=>{b(!1),g.currentTarget.style.borderColor="var(--border)",g.currentTarget.style.boxShadow="none"}}),e&&t.jsx("button",{type:"button",onClick:()=>r(""),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)",right:"var(--page-header-control-padding-x, 8px)"},"aria-label":"Limpiar búsqueda",children:t.jsx(q.HiXMark,{className:"h-3.5 w-3.5 flex-shrink-0"})})]})}const Wo=o.createContext({});let jo=0;const qo="bonsaif-ui:hide-tooltips";function yn(e=700){jo=Date.now()+e}function Di(){return Date.now()>jo}function xn(e){if(typeof document>"u")return!1;const r=Array.from(document.querySelectorAll('[data-bonsaif-overlay="true"], [role="menu"], [role="dialog"][aria-modal="true"], [aria-hidden="false"] [aria-modal="true"]'));return e&&r.some(n=>n.contains(e))?!1:r.length>0}function Ii(e){var a;const r=Array.from(e.querySelectorAll("*")).filter(s=>{var l;return s.scrollWidth>s.clientWidth&&!!((l=s.textContent)!=null&&l.trim())&&s.tagName.toLowerCase()!=="svg"&&!s.closest("svg")});return(e.scrollWidth>e.clientWidth||r.length>0)&&(((a=r[0])==null?void 0:a.textContent)??e.textContent??"").trim()||null}function Yt({children:e,content:r,onlyWhenOverflow:n=!1,interactive:a=!1,followCursor:s=!0,placement:l="bottom",showArrow:i=!1,className:c="",tooltipClassName:d="",style:u,tooltipStyle:m,as:b="div"}){const f=o.useRef(null),h=o.useRef(null),v=o.useRef(null),k=o.useRef(!1),[g,A]=o.useState(null),[$,N]=o.useState("");o.useEffect(()=>{const D=f.current;D&&(D.querySelectorAll("[title]").forEach(Q=>{const j=Q.getAttribute("title");j&&(Q.getAttribute("aria-label")||Q.setAttribute("aria-label",j),Q.removeAttribute("title"))}),D.querySelectorAll("svg title").forEach(Q=>Q.remove()))}),o.useLayoutEffect(()=>{if(!g)return;const D=h.current;if(!D)return;const Q=12,j=14,se=D.getBoundingClientRect(),te=window.innerWidth-se.width-Q,ee=window.innerHeight-se.height-Q;let U=g.mouseX+j,J=g.mouseY+j,ce,C;if(!s&&f.current){const _=f.current.getBoundingClientRect(),ae=_.left+_.width/2,B=_.top+_.height/2;l==="top"?(U=ae-se.width/2,J=_.top-se.height-j,C=se.height-1):l==="left"?(U=_.left-se.width-j,J=B-se.height/2,ce=se.width-1):l==="right"?(U=_.right+j,J=B-se.height/2,ce=-7):(U=ae-se.width/2,J=_.bottom+j,C=-7)}if(s&&(U>te&&(U=g.mouseX-se.width-j),J>ee&&(J=g.mouseY-se.height-j)),U=Math.min(Math.max(Q,U),Math.max(Q,te)),J=Math.min(Math.max(Q,J),Math.max(Q,ee)),!s&&f.current){const _=f.current.getBoundingClientRect(),ae=_.left+_.width/2,B=_.top+_.height/2;l==="top"||l==="bottom"?ce=Math.min(Math.max(14,ae-U),se.width-14):C=Math.min(Math.max(14,B-J),se.height-14)}(Math.abs(U-g.x)>.5||Math.abs(J-g.y)>.5||ce!==g.arrowX||C!==g.arrowY)&&A(_=>_&&{..._,x:U,y:J,arrowX:ce,arrowY:C})},[s,l,g]);const T=()=>{v.current&&(window.clearTimeout(v.current),v.current=null)},x=(D,Q)=>{if(!Di()||k.current)return;const j=f.current;if(j&&!xn(j)){if(n){const se=Ii(j);if(!se)return;N(se)}!n&&!r||A({mouseX:D,mouseY:Q,x:D+14,y:Q+14})}},y=()=>{const D=f.current;if(!D)return;const Q=D.getBoundingClientRect();x(Q.left+Q.width/2,Q.bottom)},L=()=>{T(),A(null)},w=()=>{if(!a){L();return}T(),v.current=window.setTimeout(()=>A(null),120)},W=()=>{yn(),k.current=!0,L()},X=()=>{k.current=!1};o.useEffect(()=>{if(!g)return;if(xn(f.current)){A(null);return}const D=()=>A(null),Q=()=>{yn(),k.current=!0,A(null)};document.addEventListener("pointerdown",Q,!0),document.addEventListener("click",Q,!0),document.addEventListener("scroll",D,!0),window.addEventListener("blur",D),document.addEventListener("visibilitychange",D),document.addEventListener("keydown",D,!0);const j=new MutationObserver(()=>{xn(f.current)&&A(null)});return j.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["role","aria-modal","aria-hidden","class"]}),()=>{document.removeEventListener("pointerdown",Q,!0),document.removeEventListener("click",Q,!0),document.removeEventListener("scroll",D,!0),window.removeEventListener("blur",D),document.removeEventListener("visibilitychange",D),document.removeEventListener("keydown",D,!0),j.disconnect()}},[g]),o.useEffect(()=>{const D=()=>yn(),Q=()=>{yn(),k.current=!0,A(null)};return document.addEventListener("pointerdown",D,!0),document.addEventListener("click",D,!0),document.addEventListener("keydown",D,!0),window.addEventListener(qo,Q),()=>{document.removeEventListener("pointerdown",D,!0),document.removeEventListener("click",D,!0),document.removeEventListener("keydown",D,!0),window.removeEventListener(qo,Q)}},[]);const Z=n?$:r;return t.jsxs(t.Fragment,{children:[t.jsx(b,{ref:D=>{f.current=D},className:c,style:u,onMouseEnter:D=>{T(),X(),s?x(D.clientX,D.clientY):y()},onMouseMove:D=>{g&&s&&x(D.clientX,D.clientY)},onMouseDown:W,onClick:W,onMouseLeave:()=>{X(),w()},onFocus:y,onBlur:L,children:e}),g&&Z&&!xn(f.current)?ct.createPortal(t.jsxs("div",{ref:h,role:"tooltip",className:d,onMouseEnter:a?T:void 0,onMouseLeave:a?w:void 0,style:{position:"fixed",top:g.y,left:g.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:a?"auto":"none",maxWidth:"min(420px, calc(100vw - 24px))",whiteSpace:"normal",lineHeight:1.6,overflowWrap:"anywhere",...m},children:[i&&t.jsx("span",{"aria-hidden":"true",style:{position:"absolute",width:12,height:12,background:(m==null?void 0:m.background)??"var(--bg-card)",borderLeft:l==="right"?(m==null?void 0:m.border)??"1px solid var(--border)":void 0,borderTop:l==="bottom"||l==="right"?(m==null?void 0:m.border)??"1px solid var(--border)":void 0,borderRight:l==="left"?(m==null?void 0:m.border)??"1px solid var(--border)":void 0,borderBottom:l==="top"||l==="left"?(m==null?void 0:m.border)??"1px solid var(--border)":void 0,transform:"rotate(45deg)",left:g.arrowX===void 0?void 0:g.arrowX-6,top:g.arrowY===void 0?void 0:g.arrowY-6,zIndex:-1}}),Z]}),document.body):null]})}function Uo(e){if(e!==void 0)return typeof e=="number"?`${e}px`:e}const Oi="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",Hi={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"},Bi="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",Fi={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"},Pi={xs:"h-8 w-8",sm:"h-9 w-9",md:"h-10 w-10",lg:"h-10 w-10"},_i={primary:{background:"var(--bg-card)"},secondary:{background:"var(--bg-card)"},danger:{background:"var(--bg-card)"},ghost:{},icon:{}};function $a(e){return typeof e=="string"||typeof e=="number"?String(e):Array.isArray(e)?e.map($a).join(" ").trim():o.isValidElement(e)?$a(e.props.children):""}function zi(e){return o.Children.toArray(e).find(o.isValidElement)??null}function Ue({variant:e="primary",size:r="md",loading:n=!1,icon:a,tooltip:s,iconOnly:l,height:i,padding:c,children:d,className:u="",disabled:m,style:b,...f}){const h=o.useContext(Wo),v=l??h.iconOnly??e==="icon",k=h.compact??!1,g=h.headerAction??!1,A=g&&r==="md"?"sm":k&&!g&&r==="md"?"xs":r,$=e==="icon"||v,N=g&&$,T=$a(d),x=s??f.title??f["aria-label"]??(v?T:void 0),y=x?void 0:f.title,L=f["aria-label"]??(typeof x=="string"?x:T||void 0),w=n?null:a??(v?zi(d):null),W=t.jsxs("button",{...f,title:y,"aria-label":L,"data-variant":e,"data-size":A,"data-icon":$?"true":void 0,disabled:m||n,className:`${Oi} ${N?Bi:Hi[e]} ${$?Pi[A]:Fi[A]} ${k&&!$?"px-2.5":""} ${u}`,style:{..._i[e],height:Uo(i),padding:Uo(c),...b,...g&&!$?{height:"var(--page-header-control-height, 34px)",padding:"0 var(--page-header-control-padding-x, 10px)",borderRadius:"8px"}:null,...N?{width:"var(--page-header-control-height, 40px)",height:"var(--page-header-control-height, 40px)",padding:0,background:"var(--bg-card)",borderRadius:"8px"}:null},children:[n?t.jsx("span",{className:"h-3.5 w-3.5 animate-spin rounded-full border-2 border-current border-t-transparent"}):w,!v&&d]});return x?t.jsx(Yt,{as:"span",content:x,className:"inline-flex shrink-0",children:W}):W}const dt={background:"color-mix(in srgb, var(--text-muted) 26%, var(--bg-input))"};function wn({rows:e=8,columns:r=7,showToolbar:n=!0,showPagination:a=!0,compact:s=!1,className:l=""}){const i=Math.max(3,Math.min(r,12)),c=Math.max(3,Math.min(e,20)),d=s?"px-2 py-2":"px-3 py-2.5",u=s?"px-2 py-2":"px-3 py-3";return t.jsxs("div",{className:`w-full min-w-0 overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${l}`,"aria-busy":"true","aria-label":"Cargando tabla",children:[n&&t.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-[var(--border)] px-3 py-2",children:[t.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[t.jsx("div",{className:"h-7 w-14 shrink-0 animate-pulse rounded-md",style:dt}),t.jsx("div",{className:"h-7 max-w-md flex-1 animate-pulse rounded-md",style:dt})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[t.jsx("div",{className:"h-7 w-7 animate-pulse rounded-md",style:dt}),t.jsx("div",{className:"h-7 w-7 animate-pulse rounded-md",style:dt})]})]}),t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("div",{className:"min-w-full",style:{display:"grid",gridTemplateColumns:`repeat(${i}, minmax(96px, 1fr))`},children:[Array.from({length:i}).map((m,b)=>t.jsx("div",{className:`${u} border-b border-[var(--border)]`,style:{background:"color-mix(in srgb, var(--bg-input) 55%, transparent)"},children:t.jsx("div",{className:"h-3 animate-pulse rounded-md",style:{...dt,width:`${48+b*17%40}%`}})},`h-${b}`)),Array.from({length:c}).map((m,b)=>Array.from({length:i}).map((f,h)=>t.jsx("div",{className:`${d} ${b<c-1?"border-b border-[var(--border)]":""}`,children:t.jsx("div",{className:"h-3.5 animate-pulse rounded-md",style:{...dt,width:`${46+(b*13+h*11)%42}%`,minWidth:28}})},`c-${b}-${h}`)))]})}),a&&t.jsxs("div",{className:"flex items-center justify-between gap-3 border-t border-[var(--border)] px-3 py-2",style:{background:"color-mix(in srgb, var(--bg-input) 40%, transparent)"},children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"h-3 w-28 animate-pulse rounded-md",style:dt}),t.jsx("div",{className:"h-7 w-14 animate-pulse rounded-md",style:dt})]}),t.jsx("div",{className:"flex items-center gap-1",children:Array.from({length:4}).map((m,b)=>t.jsx("div",{className:"h-7 w-7 animate-pulse rounded-md",style:dt},b))}),t.jsx("div",{className:"h-3 w-16 animate-pulse rounded-md",style:dt})]})]})}function Wi({size:e="md"}){const r=e==="sm"?"h-7 w-7":"h-9 w-9";return t.jsx("div",{className:`${r} animate-spin rounded-full border-2 border-[var(--border)] border-t-[var(--primary)]`,"aria-hidden":!0})}function ji({logoSrc:e,logoAlt:r}){return e?t.jsxs("span",{className:"relative flex h-16 w-16 items-center justify-center","aria-hidden":!1,children:[t.jsx("span",{className:"absolute inset-0 rounded-2xl opacity-40 blur-xl",style:{background:"radial-gradient(circle, color-mix(in srgb, var(--primary) 45%, transparent) 0%, transparent 70%)"}}),t.jsx("img",{src:e,alt:r,className:"relative h-14 w-14 rounded-2xl object-contain shadow-sm shadow-black/10"})]}):null}function Vo({variant:e="page",title:r="Cargando...",description:n,logoSrc:a,logoAlt:s,appearance:l="card",rows:i=6,columns:c=7,children:d,className:u=""}){if(e==="table")return t.jsx(wn,{rows:i,columns:c,className:u});if(e==="sections")return t.jsx(qi,{rows:i});if(e==="cards")return t.jsx(Ui,{rows:i});const m=s||(typeof r=="string"?r:"Aplicación"),b=l==="bare",f=t.jsxs("div",{className:`flex flex-col items-center text-center ${b?"gap-5":"gap-3"}`,children:[a?t.jsx(ji,{logoSrc:a,logoAlt:m}):null,t.jsx(Wi,{size:b?"md":"sm"}),t.jsxs("div",{className:b?"space-y-1.5":"",children:[t.jsx("p",{className:b?"text-base font-semibold tracking-tight text-[var(--text-main)]":"text-sm font-semibold text-[var(--text-main)]",children:r}),n?t.jsx("p",{className:b?"text-sm font-medium text-[var(--text-muted)]":"mt-1 text-xs text-[var(--text-muted)]",children:n}):null,d&&t.jsx("div",{className:"mt-1 text-xs text-[var(--text-muted)]",children:d})]})]});return b?t.jsx("div",{className:`flex min-h-[240px] w-full items-center justify-center p-8 ${u}`,role:"status","aria-live":"polite","aria-busy":"true",children:f}):t.jsx("div",{className:`flex min-h-[240px] items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-6 ${u}`,role:"status","aria-live":"polite","aria-busy":"true",children:f})}function qi({rows:e}){return t.jsx(wn,{rows:e,columns:7})}function Ui({rows:e}){return t.jsx("div",{className:"grid gap-3 md:grid-cols-2 xl:grid-cols-3",children:Array.from({length:e}).map((r,n)=>t.jsxs("div",{className:"rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-4",children:[t.jsx("div",{className:"h-4 w-2/3 animate-pulse rounded-md",style:dt}),t.jsx("div",{className:"mt-3 h-3 w-full animate-pulse rounded-md",style:dt}),t.jsx("div",{className:"mt-2 h-3 w-4/5 animate-pulse rounded-md",style:dt})]},n))})}function Yo(e){const r=e.split("/").filter(Boolean);return(r[r.length-1]??e).replace(/^lv_/,"").split(/[-_]/).filter(Boolean).map(a=>a.charAt(0).toUpperCase()+a.slice(1)).join(" ")}function Xo(e){return e.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().trim()}function Vi(e){return[e.label,Yo(e.service),e.description,e.service].filter(Boolean).join(" ")}function Yi(e){return typeof e=="function"?e:e.default}function Xi(e,r){return t.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:t.jsxs("div",{className:"max-w-md",children:[t.jsx("p",{className:"text-sm font-semibold text-[var(--text-main)]",children:"No se pudo cargar este modulo"}),t.jsx("p",{className:"mt-1 text-xs text-[var(--text-muted)]",children:e.message}),t.jsx(Ue,{className:"mt-4",height:36,padding:"0 14px",onClick:r,children:"Reintentar"})]})})}function Ki({parentPanel:e,parentPanelComponent:r,renderParentPanel:n,parent:a,context:s,links:l,moduleRegistry:i,loadModule:c,activeService:d,initialService:u,onActiveServiceChange:m,canAccess:b,keepAlive:f=!0,title:h,subtitle:v,emptyState:k,loadingState:g,errorState:A=Xi,renderTabLabel:$,searchableTabs:N="auto",tabsSearchThreshold:T=6,tabsSearchPlaceholder:x="Buscar modulo...",tabsSearchValue:y,onTabsSearchChange:L,emptySearchState:w,showTabCount:W=!0,className:X="",parentClassName:Z="",contentClassName:D="",tabsClassName:Q=""}){var Et;const j=o.useMemo(()=>l.filter(le=>!le.hidden&&((b==null?void 0:b(le,s))??!0)),[b,s,l]),se=(Et=j.find(le=>!le.disabled))==null?void 0:Et.service,[te,ee]=o.useState(u??se??""),[U,J]=o.useState({}),[ce,C]=o.useState({}),[_,ae]=o.useState(""),[B,I]=o.useState(!1),M=o.useRef(ce),oe=o.useRef(0),K=y??_,Y=Xo(K),S=N===!0||N==="auto"&&j.length>=T,H=S&&K.trim().length>0,O=o.useMemo(()=>Y?j.filter(le=>Xo(Vi(le)).includes(Y)):j,[Y,j]),re=d??te,z=j.find(le=>le.service===re)??j.find(le=>!le.disabled);o.useEffect(()=>{!z&&se&&ee(se)},[se,z]),o.useEffect(()=>{M.current=ce},[ce]);const de=le=>{le.disabled||(d||ee(le.service),m==null||m(le.service,le))},he=le=>{y===void 0&&ae(le),L==null||L(le)},ie=(le,Fe)=>{const ze=O.filter(Ve=>!Ve.disabled),ft=ze.findIndex(Ve=>Ve.service===Fe.service);ft<0||((le.key==="ArrowRight"||le.key==="ArrowDown")&&(le.preventDefault(),de(ze[(ft+1)%ze.length])),(le.key==="ArrowLeft"||le.key==="ArrowUp")&&(le.preventDefault(),de(ze[(ft-1+ze.length)%ze.length])),le.key==="Home"&&(le.preventDefault(),de(ze[0])),le.key==="End"&&(le.preventDefault(),de(ze[ze.length-1])))},ge=o.useCallback(()=>{if(!z)return;const le=z.service,Fe=M.current[le];if(Fe!=null&&Fe.loading||Fe!=null&&Fe.component&&f)return;const ze=(i==null?void 0:i[le])??c;if(!ze){C(Ve=>({...Ve,[le]:{loading:!1,error:new Error(`No module loader found for service "${le}".`)}}));return}const ft=++oe.current;C(Ve=>({...Ve,[le]:{...Ve[le],loading:!0,error:void 0}})),ze(z,s).then(Ve=>{if(ft!==oe.current&&!f)return;const Mt=Yi(Ve);C(bt=>({...bt,[le]:{component:Mt,loading:!1}}))}).catch(Ve=>{const Mt=Ve instanceof Error?Ve:new Error(String(Ve));C(bt=>({...bt,[le]:{...bt[le],loading:!1,error:Mt}}))})},[s,f,c,i,z]);o.useEffect(ge,[ge]);const Me=z?U[z.service]??null:null,$e=z?ce[z.service]:void 0,Dt=$e==null?void 0:$e.component,ut=le=>{z&&J(Fe=>({...Fe,[z.service]:le}))},Re=()=>{z&&J(le=>({...le,[z.service]:null}))},It={context:s,parent:a,links:l,visibleLinks:j,filteredLinks:O,selectedLink:z,selectedService:z==null?void 0:z.service,activeItemId:Me,tabsSearch:K,onSelectService:de,onOpenDetail:ut,onBackToList:Re},Ct=n?n(It):r?t.jsx(r,{...It}):e;return t.jsxs("section",{className:`grid min-h-[520px] gap-4 lg:grid-cols-[minmax(260px,360px)_minmax(0,1fr)] ${X}`,children:[t.jsx("aside",{className:`min-w-0 rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-4 ${Z}`,children:Ct}),t.jsxs("div",{className:`relative min-w-0 overflow-visible rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${D}`,children:[(h||v||S||W)&&t.jsx("div",{className:"relative border-b border-[var(--border)] px-4 py-3",children:t.jsxs("div",{className:"flex min-w-0 items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[h&&t.jsx("h2",{className:"truncate text-sm font-semibold text-[var(--text-main)]",children:h}),v&&t.jsx("p",{className:"mt-1 line-clamp-2 text-xs text-[var(--text-muted)]",children:v})]}),(S||W)&&t.jsxs("div",{className:"flex min-w-0 flex-shrink-0 items-center justify-end gap-2",children:[W&&t.jsxs("span",{className:"hidden text-xs font-semibold text-[var(--text-muted)] transition-opacity duration-200 sm:inline",children:[O.length," / ",j.length]}),S&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:`origin-right overflow-hidden transition-[width,opacity,transform] duration-200 ease-out ${B?"w-[min(20rem,44vw)] translate-x-0 opacity-100":"w-0 translate-x-2 opacity-0"}`,"aria-hidden":!B,children:t.jsx(zo,{value:K,onChange:he,placeholder:x,className:"w-full",autoFocus:B,forceExpanded:!0,onEscape:()=>I(!1),size:"sm",inputTabIndex:B?0:-1})}),t.jsx("button",{type:"button","aria-label":B?"Cerrar busqueda":"Buscar tabs","aria-expanded":B,onClick:()=>{B&&K&&he(""),I(le=>!le)},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 ${B||H?"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:t.jsx("span",{className:"grid h-4 w-4 place-items-center transition-transform duration-200",children:B||H?t.jsx(q.HiXMark,{className:"h-4 w-4"}):t.jsx(q.HiMagnifyingGlass,{className:"h-4 w-4"})})})]})]})]})}),t.jsx("div",{role:"tablist","aria-label":h??"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 ${Q}`,children:O.length>0?O.map(le=>{const Fe=le.service===(z==null?void 0:z.service);return t.jsx("button",{type:"button",role:"tab","aria-selected":Fe,disabled:le.disabled,onClick:()=>de(le),onKeyDown:ze=>ie(ze,le),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 ${Fe?"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:$?$(le,Fe):t.jsxs(t.Fragment,{children:[le.icon,t.jsx("span",{children:le.label??Yo(le.service)}),le.badge&&t.jsx("span",{className:"rounded-full bg-[var(--bg-input)] px-1.5 py-0.5 text-[10px] text-[var(--text-muted)]",children:le.badge})]})},le.service)}):t.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:w??"No hay modulos que coincidan con la busqueda."})}),(z==null?void 0:z.description)&&t.jsx("div",{className:"border-b border-[var(--border)] px-4 py-2 text-xs text-[var(--text-muted)]",children:z.description}),t.jsxs("div",{className:"min-h-[420px] p-4",children:[!z&&(k??t.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."})),z&&($e==null?void 0:$e.loading)&&(g??t.jsx(Vo,{title:"Cargando modulo..."})),z&&($e==null?void 0:$e.error)&&A($e.error,ge),z&&Dt&&!($e!=null&&$e.loading)&&!($e!=null&&$e.error)&&t.jsx(Dt,{context:s,parent:a,link:z,activeItemId:Me,onOpenDetail:ut,onBackToList:Re})]})]})]})}const Gi={info:{color:"#2563eb",background:"rgba(59, 130, 246, 0.1)",border:"rgba(59, 130, 246, 0.24)",icon:t.jsx(q.HiInformationCircle,{className:"h-5 w-5"})},success:{color:"#047857",background:"rgba(16, 185, 129, 0.1)",border:"rgba(16, 185, 129, 0.24)",icon:t.jsx(q.HiCheckCircle,{className:"h-5 w-5"})},warning:{color:"#b45309",background:"rgba(245, 158, 11, 0.12)",border:"rgba(245, 158, 11, 0.26)",icon:t.jsx(q.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:t.jsx(q.HiExclamationCircle,{className:"h-5 w-5"})},neutral:{color:"var(--text-secondary)",background:"var(--bg-input)",border:"var(--border)",icon:t.jsx(q.HiInformationCircle,{className:"h-5 w-5"})}};function Zi({variant:e="info",title:r,children:n,icon:a,action:s,onDismiss:l,className:i=""}){const c=Gi[e];return t.jsxs("div",{role:e==="danger"||e==="warning"?"alert":"status",className:`flex items-start gap-3 rounded-lg border px-3 py-3 ${i}`,style:{background:c.background,borderColor:c.border},children:[t.jsx("div",{className:"mt-0.5 shrink-0",style:{color:c.color},children:a??c.icon}),t.jsxs("div",{className:"min-w-0 flex-1",children:[r&&t.jsx("div",{className:"text-sm font-semibold text-[var(--text-main)]",children:r}),n&&t.jsx("div",{className:"mt-0.5 text-sm leading-5 text-[var(--text-secondary)]",children:n}),s&&t.jsx("div",{className:"mt-3",children:s})]}),l&&t.jsx(Ue,{variant:"icon",size:"xs","aria-label":"Cerrar alerta",onClick:l,className:"-mr-1 -mt-1",children:t.jsx(q.HiXMark,{className:"h-4 w-4"})})]})}const Ko=["Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre"],Qi=["Ene","Feb","Mar","Abr","May","Jun","Jul","Ago","Sep","Oct","Nov","Dic"],Ji=["lu","ma","mi","ju","vi","sá","do"],Go=6;function Aa(e,r,n){return`${e}-${String(r).padStart(2,"0")}-${String(n).padStart(2,"0")}`}function Ri(){const e=new Date;return Aa(e.getFullYear(),e.getMonth()+1,e.getDate())}function Zo(e){const[r,n,a]=e.split("-").map(Number);return{year:r,month:n,day:a}}function ec(e){if(!e)return"Seleccionar fecha";const{year:r,month:n,day:a}=Zo(e);return!r||!n||!a?"Seleccionar fecha":`${String(a).padStart(2,"0")} ${Ko[n-1]} ${r}`}function tc({value:e,onChange:r,minDate:n,displayMode:a="inline",className:s=""}){const l=Ri(),c=Zo(e||l),d=a==="popover",[u,m]=o.useState(!1),b=o.useRef(null),[f,h]=o.useState({horizontal:"left",vertical:"bottom"}),[v,k]=o.useState(c.year),[g,A]=o.useState(c.month),[$,N]=o.useState("days"),T=16,[x,y]=o.useState(0),L=v-7+x,w=Array.from({length:T},(ee,U)=>L+U);o.useEffect(()=>{if(!d||!u||!b.current)return;const ee=b.current.getBoundingClientRect(),U=8,J=280,ce=340,C=ee.left+J>window.innerWidth-U,_=ee.right-J>=U,ae=ee.bottom+8+ce>window.innerHeight-U,B=ee.top-8-ce>=U;h({horizontal:C&&_?"right":"left",vertical:ae&&B?"top":"bottom"})},[d,u]),o.useEffect(()=>{if(!d||!u)return;function ee(J){b.current&&(b.current.contains(J.target)||m(!1))}function U(J){J.key==="Escape"&&m(!1)}return document.addEventListener("mousedown",ee),document.addEventListener("keydown",U),()=>{document.removeEventListener("mousedown",ee),document.removeEventListener("keydown",U)}},[d,u]);function W(){g===1?(k(ee=>ee-1),A(12)):A(ee=>ee-1)}function X(){g===12?(k(ee=>ee+1),A(1)):A(ee=>ee+1)}const Z=(new Date(v,g-1,1).getDay()+6)%7,D=new Date(v,g,0).getDate(),Q=[...Array(Z).fill(null),...Array.from({length:D},(ee,U)=>U+1)];for(;Q.length<Go*7;)Q.push(null);const j=Q.slice(0,Go*7);function se(ee){const U=Aa(v,g,ee);n&&U<n||(r(U),d&&m(!1))}const te=t.jsx("div",{className:`bonsaif-calendar bonsaif-calendar-picker ${s}`.trim(),children:t.jsxs("div",{className:"bonsaif-cal-shell",children:[t.jsx("div",{className:"bonsaif-cal-toolbar",children:$==="days"?t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn",onClick:W,"aria-label":"Mes anterior",children:t.jsx(q.HiChevronLeft,{size:16})}),t.jsxs("button",{type:"button",className:"bonsaif-cal-title-btn",onClick:()=>{N("years"),y(0)},children:[t.jsxs("span",{className:"bonsaif-cal-title",children:[Ko[g-1]," ",v]}),t.jsx(q.HiChevronDown,{size:13})]}),t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn",onClick:X,"aria-label":"Mes siguiente",children:t.jsx(q.HiChevronRight,{size:16})})]}):t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn",onClick:()=>y(ee=>ee-T),"aria-label":"Años anteriores",children:t.jsx(q.HiChevronLeft,{size:16})}),t.jsx("button",{type:"button",className:"bonsaif-cal-title-btn",onClick:()=>N("days"),children:t.jsxs("span",{className:"bonsaif-cal-title",children:[w[0]," – ",w[w.length-1]]})}),t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn",onClick:()=>y(ee=>ee+T),"aria-label":"Años siguientes",children:t.jsx(q.HiChevronRight,{size:16})})]})}),$==="years"?t.jsxs("div",{className:"bonsaif-cal-picker-years",children:[t.jsx("div",{className:"bonsaif-cal-picker-months",children:Qi.map((ee,U)=>{const J=U+1===g;return t.jsx("button",{type:"button",className:`bonsaif-cal-pill-btn${J?" is-active":""}`,onClick:()=>A(U+1),children:ee},ee)})}),t.jsx("div",{className:"bonsaif-cal-picker-year-grid",children:w.map(ee=>{const U=ee===v,J=ee===new Date().getFullYear();return t.jsx("button",{type:"button",className:`bonsaif-cal-pill-btn${U?" is-active":""}${J&&!U?" is-today":""}`,onClick:()=>{k(ee),N("days")},children:ee},ee)})})]}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"bonsaif-multi-weekdays bonsaif-cal-picker-weekdays",children:Ji.map(ee=>t.jsx("div",{className:"bonsaif-multi-weekday",children:ee},ee))}),t.jsx("div",{className:"bonsaif-cal-picker-days",children:j.map((ee,U)=>{if(ee===null)return t.jsx("div",{className:"bonsaif-multi-day bonsaif-multi-day-hidden"},U);const J=Aa(v,g,ee),ce=J===e,C=J===l,_=!!(n&&J<n);return t.jsx("div",{className:`bonsaif-multi-day${ce?" bonsaif-multi-day-selected":""}${C?" bonsaif-multi-day-today":""}${_?" bonsaif-multi-day-disabled":""}`,children:t.jsx("button",{type:"button",className:"bonsaif-multi-day-btn",disabled:_,"aria-pressed":ce,onClick:()=>!_&&se(ee),children:ee})},U)})})]})]})});return d?t.jsxs("div",{ref:b,className:`relative w-full ${s}`.trim(),children:[t.jsxs("button",{type:"button",onClick:()=>m(ee=>!ee),className:"bonsaif-cal-trigger","data-open":u?"true":"false",children:[t.jsxs("span",{className:"inline-flex items-center gap-2 min-w-0",children:[t.jsx(q.HiCalendarDays,{className:"w-4 h-4 text-[var(--text-muted)]"}),t.jsx("span",{className:"truncate",children:ec(e)})]}),t.jsx(q.HiChevronDown,{className:`w-4 h-4 text-[var(--text-muted)] transition-transform ${u?"rotate-180":""}`})]}),u&&t.jsx("div",{className:"absolute z-50",style:{...f.horizontal==="left"?{left:0}:{right:0},...f.vertical==="bottom"?{top:"calc(100% + 8px)"}:{bottom:"calc(100% + 8px)"}},children:te})]}):te}const rc={sm:"h-4 w-4",md:"h-5 w-5"};function nc(e,r){if(typeof e=="function"){e(r);return}e&&(e.current=r)}const Nn=o.forwardRef(function({label:r,description:n,error:a,size:s="md",indeterminate:l=!1,className:i="",containerClassName:c="",disabled:d,...u},m){const b=o.useRef(null);return o.useEffect(()=>{b.current&&(b.current.indeterminate=l)},[l]),t.jsxs("label",{className:`group inline-flex items-start gap-2.5 ${d?"cursor-not-allowed opacity-60":"cursor-pointer"} ${c}`,children:[t.jsxs("span",{className:"relative mt-0.5 inline-flex shrink-0",children:[t.jsx("input",{...u,ref:f=>{b.current=f,nc(m,f)},type:"checkbox",disabled:d,"aria-checked":l?"mixed":u["aria-checked"],"aria-invalid":!!a||u["aria-invalid"],className:`peer ${rc[s]} 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 ${i}`}),t.jsx(q.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 peer-aria-checked:mixed:scale-100 peer-aria-checked:mixed:opacity-100"})]}),(r||n||a)&&t.jsxs("span",{className:"min-w-0",children:[r&&t.jsx("span",{className:"block text-sm font-medium leading-5 text-[var(--text-main)]",children:r}),n&&!a&&t.jsx("span",{className:"block text-xs leading-5 text-[var(--text-muted)]",children:n}),a&&t.jsx("span",{className:"block text-xs leading-5 text-[var(--danger)]",children:a})]})]})});function Qo(e){const r=document.createElement("textarea");r.value=e,r.style.position="fixed",r.style.opacity="0",r.style.pointerEvents="none",document.body.appendChild(r),r.select(),document.execCommand("copy"),document.body.removeChild(r)}async function ac(e){var r;if((r=navigator.clipboard)!=null&&r.writeText){await navigator.clipboard.writeText(e);return}Qo(e)}function oc(e){return typeof e=="function"?e():e}function La({value:e,resetDelay:r=2e3,title:n,copiedTitle:a="Copiado",copiedLabel:s,icon:l=t.jsx(q.HiClipboardDocument,{size:14}),copiedIcon:i=t.jsx(q.HiCheck,{size:14}),stopPropagation:c=!0,onCopied:d,onCopyError:u,className:m="",style:b,children:f,onClick:h,type:v="button",...k}){const[g,A]=o.useState(!1),$=o.useRef(null);o.useEffect(()=>()=>{$.current&&window.clearTimeout($.current)},[]);function N(x){A(!0),d==null||d(x),$.current&&window.clearTimeout($.current),$.current=window.setTimeout(()=>{A(!1),$.current=null},r)}async function T(x){var L;if(c&&x.stopPropagation(),h==null||h(x),x.defaultPrevented)return;const y=oc(e);if(y)try{await ac(y),N(y)}catch(w){try{Qo(y),N(y)}catch(W){u==null||u(W,y);return}(L=navigator.clipboard)!=null&&L.writeText||u==null||u(w,y)}}return t.jsxs("button",{...k,type:v,onClick:T,title:g?a:n,"aria-label":k["aria-label"]??(g?a:n),"data-copied":g?"true":void 0,className:`relative inline-flex h-7 shrink-0 items-center justify-center gap-1.5 rounded-md transition-all duration-200 ${f?"min-w-7 px-2":"w-7"} ${m}`,style:{cursor:"pointer",background:g?"rgba(22,163,74,0.15)":"var(--bg-card)",border:g?"1px solid rgba(22,163,74,0.4)":"1px solid var(--border)",color:g?"#16a34a":"var(--text-secondary)",boxShadow:g?"0 0 0 3px rgba(22,163,74,0.12)":"none",...b},children:[t.jsx("span",{className:"inline-flex items-center justify-center transition-all duration-150",style:{transform:g?"scale(1.15)":"scale(1)"},children:g?i:l}),f&&t.jsx("span",{className:"text-xs font-semibold leading-none",children:g?s??f:f})]})}function sc({code:e,children:r,title:n="Codigo",language:a,copyLabel:s="Copiar",copiedLabel:l="Copiado",className:i="",style:c,onCopied:d}){const u=(e??r??"").trim();return t.jsxs("div",{className:`overflow-hidden rounded-lg border ${i}`,style:{borderColor:"rgba(148, 163, 184, 0.22)",background:"#0f172a",color:"#e2e8f0",...c},children:[t.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:[t.jsx("span",{className:"min-w-0 truncate text-[11px] font-black uppercase tracking-[0.08em]",children:n}),t.jsx(La,{value:u,title:"Copiar codigo",copiedTitle:"Codigo copiado",copiedLabel:l,onCopied:d,className:"h-7 min-w-[72px] px-2",style:{background:"#182235",border:"1px solid rgba(148, 163, 184, 0.28)",color:"#f8fafc"},children:s})]}),t.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:t.jsx("code",{className:a?`language-${a}`:void 0,children:u})})]})}function Pt({children:e,className:r="",style:n,as:a="span",followCursor:s=!1,placement:l="top"}){return t.jsx(Yt,{onlyWhenOverflow:!0,as:a,followCursor:s,placement:l,showArrow:!s,className:r,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",minWidth:0,...n},children:e})}function Da(e){if(e!==void 0)return typeof e=="number"?`${e}px`:e}function Ia(e){return e.normalize("NFD").replace(new RegExp("\\p{M}","gu"),"").toLowerCase()}function lc(e,r){if(!r.trim())return!0;const n=Ia(r);return Ia(e.label).includes(n)||!!(e.sublabel&&Ia(e.sublabel).includes(n))}function ar({value:e,onChange:r,options:n,status:a="default",ariaLabel:s,triggerVariant:l="default",showSelectedSublabel:i=!0,placeholder:c="Seleccionar…",emptyLabel:d,disabled:u=!1,className:m="",style:b,dropdownMinWidth:f,height:h=40,padding:v="0 10px",searchable:k=!0,minOptionsForSearch:g=6}){const[A,$]=o.useState(!1),[N,T]=o.useState(""),[x,y]=o.useState(-1),[L,w]=o.useState(!1),[W,X]=o.useState({}),Z=o.useRef(null),D=o.useRef(null),Q=o.useRef(null),j=o.useRef(null),se=k&&n.length>=g,te=n.find(K=>K.value===e)??null,ee=l==="ghost",U=a==="error"?"var(--danger)":A?"var(--primary)":"var(--border)",J=se&&N.trim()?n.filter(K=>lc(K,N)):n,ce=o.useCallback(()=>{const K=Z.current;if(!K)return;const Y=K.getBoundingClientRect(),S=se?272:212,H=window.innerHeight-Y.bottom,O=H<S&&Y.top>H;X({position:"fixed",left:Y.left,top:O?void 0:Y.bottom+4,bottom:O?window.innerHeight-Y.top+4:void 0,width:Y.width,minWidth:Da(f),zIndex:9999})},[f,se]);o.useEffect(()=>w(!0),[]),o.useEffect(()=>{if(!A)return;function K(Y){var H,O;const S=Y.target;!((H=Z.current)!=null&&H.contains(S))&&!((O=D.current)!=null&&O.contains(S))&&($(!1),T(""))}return document.addEventListener("mousedown",K),()=>document.removeEventListener("mousedown",K)},[A]),o.useEffect(()=>{A&&(y(-1),ce(),se&&setTimeout(()=>{var K;return(K=Q.current)==null?void 0:K.focus()},0))},[A,se,ce]),o.useEffect(()=>{if(A)return window.addEventListener("resize",ce),window.addEventListener("scroll",ce,!0),()=>{window.removeEventListener("resize",ce),window.removeEventListener("scroll",ce,!0)}},[A,ce]),o.useEffect(()=>{if(x<0||!j.current)return;const K=j.current.children[x];K==null||K.scrollIntoView({block:"nearest"})},[x]);const C=o.useCallback(K=>{r(K),$(!1),T("")},[r]),_=o.useRef(A);_.current=A;const ae=o.useRef(J);ae.current=J;const B=o.useRef(x);B.current=x;const I=o.useRef(d);I.current=d;const M=o.useRef(C);M.current=C,o.useEffect(()=>{function K(Y){var re,z;const S=document.activeElement,H=((re=Z.current)==null?void 0:re.contains(S))??!1,O=((z=D.current)==null?void 0:z.contains(S))??!1;if(!(!H&&!O)){if(!_.current){(Y.key==="Enter"||Y.key===" "||Y.key==="ArrowDown")&&(Y.preventDefault(),$(!0));return}switch(Y.key){case"ArrowDown":Y.preventDefault(),y(de=>Math.min(de+1,ae.current.length-1));break;case"ArrowUp":Y.preventDefault(),y(de=>Math.max(de-1,I.current?-1:0));break;case"Enter":{Y.preventDefault();const de=B.current,he=ae.current;de===-1&&I.current?M.current(""):he[de]&&!he[de].disabled&&M.current(he[de].value);break}case"Escape":Y.preventDefault(),Y.stopPropagation(),$(!1),T("");break}}}return document.addEventListener("keydown",K),()=>document.removeEventListener("keydown",K)},[]);const oe=t.jsxs("div",{ref:D,"data-bonsaif-select-dropdown":"true",className:"rounded-xl shadow-xl overflow-hidden",style:{...W,background:"var(--bg-card)",border:"1px solid var(--border)"},children:[se&&t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",style:{borderBottom:"1px solid var(--border)"},children:[t.jsx(q.HiMagnifyingGlass,{className:"w-3.5 h-3.5 flex-shrink-0",style:{color:"var(--text-muted)"}}),t.jsx("input",{ref:Q,value:N,onChange:K=>{T(K.target.value),y(-1)},placeholder:"Buscar…",className:"min-w-0 flex-1 text-sm bg-transparent outline-none",style:{color:"var(--text-main)"}}),N&&t.jsx("button",{type:"button",onMouseDown:K=>{K.preventDefault(),T("")},children:t.jsx(q.HiXMark,{className:"w-3.5 h-3.5",style:{color:"var(--text-muted)"}})})]}),t.jsxs("ul",{ref:j,role:"listbox",className:"overflow-y-auto",style:{maxHeight:se?220:180,scrollbarWidth:"thin",scrollbarColor:"var(--border) transparent",overscrollBehavior:"contain"},children:[d&&t.jsx("li",{role:"option","aria-selected":e==="",onMouseDown:K=>{K.preventDefault(),C("")},onMouseEnter:()=>y(-1),className:"flex items-center gap-2 px-3 py-2 cursor-pointer text-sm transition-colors",style:{background:x===-1&&!N.trim()?"var(--bg-hover)":"transparent",color:"var(--text-muted)",fontStyle:"italic"},children:d}),J.map((K,Y)=>{const H=Y===x,O=K.value===e;return t.jsxs("li",{role:"option","aria-selected":O,onMouseDown:re=>{re.preventDefault(),K.disabled||C(K.value)},onMouseEnter:()=>!K.disabled&&y(Y),className:"flex items-center gap-2 px-3 py-2 cursor-pointer text-sm transition-colors",style:{background:H?"var(--bg-hover)":O?"color-mix(in srgb, var(--primary) 6%, transparent)":"transparent",color:K.disabled?"var(--text-muted)":"var(--text-main)",cursor:K.disabled?"not-allowed":"pointer",boxShadow:O?"inset 2px 0 0 var(--primary)":void 0},children:[K.color&&t.jsx("span",{className:"flex-shrink-0 w-2.5 h-2.5 rounded-full",style:{background:K.color}}),t.jsxs("span",{className:"min-w-0 flex flex-1 items-baseline gap-1 overflow-hidden",children:[t.jsx(Pt,{className:"min-w-0 flex-1",children:K.label}),K.sublabel&&t.jsx(Pt,{className:"min-w-0 flex-shrink",style:{color:"var(--text-muted)",fontSize:12},children:K.sublabel})]}),K.badge&&t.jsx("span",{className:"text-xs flex-shrink-0",style:{color:"var(--text-muted)"},children:K.badge})]},K.value)}),J.length===0&&t.jsx("li",{className:"px-3 py-4 text-sm text-center",style:{color:"var(--text-muted)"},children:"Sin resultados"})]})]});return t.jsxs("div",{ref:Z,className:`relative ${m||"w-full"}`,style:b,children:[t.jsxs("button",{type:"button",disabled:u,onClick:()=>!u&&$(K=>!K),className:"flex w-full items-center gap-2 rounded-lg text-left text-sm transition-colors focus:outline-none",style:{height:Da(h),padding:Da(v),background:ee?"transparent":"var(--bg-input)",color:te?"var(--text-main)":"var(--text-muted)",border:ee?"1px solid transparent":`1px solid ${U}`,opacity:u?.5:1,cursor:u?"not-allowed":"pointer"},"aria-haspopup":"listbox","aria-expanded":A,"aria-label":s,children:[(te==null?void 0:te.color)&&t.jsx("span",{className:"flex-shrink-0 w-2.5 h-2.5 rounded-full",style:{background:te.color}}),t.jsx("span",{className:"min-w-0 flex flex-1 items-baseline gap-1 overflow-hidden",children:te?t.jsxs(t.Fragment,{children:[t.jsx(Pt,{className:"min-w-0 flex-1",children:te.label}),i&&te.sublabel&&t.jsx(Pt,{className:"min-w-0 flex-shrink",style:{color:"var(--text-muted)",fontSize:12},children:te.sublabel})]}):t.jsx(Pt,{className:"min-w-0 flex-1",children:c})}),te&&d?t.jsx("span",{role:"button",tabIndex:-1,onMouseDown:K=>{K.preventDefault(),K.stopPropagation(),C("")},className:"flex-shrink-0 rounded-full p-0.5 transition-colors hover:bg-black/10",style:{color:"var(--text-muted)"},children:t.jsx(q.HiXMark,{className:"w-3 h-3"})}):t.jsx(q.HiChevronDown,{className:"flex-shrink-0 w-4 h-4 transition-transform",style:{color:"var(--text-muted)",transform:A?"rotate(180deg)":"rotate(0deg)"}})]}),A&&L&&ct.createPortal(oe,document.body)]})}function kn(e){if(e!==void 0)return typeof e=="number"?`${e}px`:e}function ic({value:e,onChange:r,placeholder:n="Buscar...",className:a="",height:s=40,padding:l="0 10px 0 30px",iconLeft:i=10}){return t.jsxs("div",{className:`relative ${a}`,children:[t.jsx(q.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:kn(i)}}),t.jsx("input",{type:"text",value:e,onChange:c=>r(c.target.value),placeholder:n,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:kn(s),padding:kn(l)}})]})}function cc({value:e,onChange:r,options:n,placeholder:a,icon:s,className:l="",height:i=40,padding:c,iconLeft:d=10,searchable:u=!0}){const m=s?n.map((b,f)=>f===0&&!b.color?{...b,sublabel:b.sublabel??void 0}:b):n;return t.jsxs("div",{className:`relative ${l}`,children:[s&&t.jsx("span",{className:"pointer-events-none absolute top-1/2 z-10 -translate-y-1/2 text-[var(--text-muted)]",style:{left:kn(d)},children:s}),t.jsx(ar,{value:e,onChange:r,options:m,placeholder:a,searchable:u,minOptionsForSearch:5,height:i,padding:c??(s?"0 10px 0 30px":"0 10px"),className:"[&>button]:text-sm [&>button]:[background:var(--bg-card)]"})]})}const dc={sm:"24rem",md:"28rem",lg:"32rem",xl:"40rem","2xl":"48rem","4xl":"56rem","5xl":"64rem"},Sn=180,uc="bg-[color-mix(in_srgb,var(--bg-main)_72%,transparent)] backdrop-blur-sm";function Oa({open:e,onClose:r,title:n,subtitle:a,leadingIcon:s,headerActions:l,footer:i,children:c,size:d="md",maxWidth:u,zIndex:m=1e3,closeOnBackdrop:b=!0,closeOnEscape:f=!0,showCloseButton:h=!0,placement:v="center",bodyClassName:k="px-6 py-5",panelClassName:g="",backdropClassName:A=uc,contentClassName:$="p-4",ariaLabel:N,frameless:T=!1,disabled:x=!1}){const[y,L]=o.useState(!1),[w,W]=o.useState(!1),X=o.useRef(null);if(o.useEffect(()=>(e?(X.current&&clearTimeout(X.current),L(!0),requestAnimationFrame(()=>requestAnimationFrame(()=>W(!0)))):(W(!1),X.current=setTimeout(()=>L(!1),Sn+40)),()=>{X.current&&clearTimeout(X.current)}),[e]),o.useEffect(()=>{if(e)return document.body.style.overflow="hidden",()=>{document.body.style.overflow=""}},[e]),o.useEffect(()=>{if(!e||!f)return;const te=ee=>{ee.key==="Escape"&&r()};return window.addEventListener("keydown",te),()=>window.removeEventListener("keydown",te)},[f,r,e]),!y)return null;const Z=n||a||s||l||h,D=u??dc[d],Q=v==="bottom-mobile"?"items-end sm:items-center justify-center p-0 sm:p-4":"items-center justify-center",j=v==="bottom-mobile"?"rounded-t-2xl sm:rounded-2xl":"rounded-2xl",se=w?"translateY(0) scale(1)":v==="bottom-mobile"?"translateY(16px) scale(0.98)":"translateY(10px) scale(0.96)";return ct.createPortal(t.jsxs("div",{role:"dialog","aria-modal":"true","data-bonsaif-overlay":"true","aria-label":N??n,className:`fixed inset-0 flex ${Q} ${$}`,style:{zIndex:m},children:[t.jsx("div",{className:`absolute inset-0 ${A}`,onClick:b?r:void 0,style:{opacity:w?1:0,transition:`opacity ${Sn}ms ease`}}),t.jsxs("div",{className:`relative z-10 flex max-h-[92dvh] w-full flex-col overflow-hidden ${T?"shadow-none":"shadow-2xl"} ${j} ${g}`,style:{maxWidth:D,background:T?"transparent":"var(--bg-card)",border:T?"none":"1px solid var(--border)",opacity:w?1:0,transform:se,transition:`opacity ${Sn}ms ease, transform ${Sn}ms ease`},onClick:te=>te.stopPropagation(),children:[x&&t.jsx("div",{className:"absolute inset-0 z-[1002] cursor-not-allowed rounded-2xl",style:{background:"color-mix(in srgb, var(--bg-card, #ffffff) 60%, transparent)",backdropFilter:"blur(2px)"}}),Z&&t.jsxs("div",{className:"flex flex-shrink-0 items-center justify-between gap-3 px-6 py-4",style:{borderBottom:"1px solid var(--border)"},children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[s&&t.jsx("div",{className:"flex-shrink-0",children:s}),(n||a)&&t.jsxs("div",{className:"min-w-0",children:[n&&t.jsx("h2",{className:"truncate text-base font-semibold",style:{color:"var(--text-main)"},children:n}),a&&t.jsx("p",{className:"truncate text-xs",style:{color:"var(--text-muted)"},children:a})]})]}),t.jsxs("div",{className:"flex flex-shrink-0 items-center gap-2",children:[l,h&&t.jsx(Ue,{variant:"icon",onClick:r,title:"Cerrar",children:t.jsx(q.HiXMark,{className:"h-5 w-5"})})]})]}),t.jsx("div",{className:`min-h-0 flex-1 overflow-y-auto ${k}`,children:c}),i&&t.jsx("div",{className:"flex flex-shrink-0 justify-end gap-2 px-6 py-4",style:{borderTop:"1px solid var(--border)"},children:i})]})]}),document.body)}const fc={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 bc({open:e,title:r,description:n,confirmLabel:a="Confirmar",cancelLabel:s="Cancelar",variant:l="danger",closeOnBackdrop:i=!0,onConfirm:c,onCancel:d}){const u=fc[l];return t.jsx(Oa,{open:e,onClose:d,size:"md",zIndex:9998,showCloseButton:!1,bodyClassName:"p-0",panelClassName:"overflow-visible",ariaLabel:r,closeOnBackdrop:i,children:t.jsxs("div",{className:"relative px-6 pb-6 pt-6",children:[t.jsx(Ue,{variant:"icon",onClick:d,className:"absolute right-3 top-3 h-8 w-8 hover:opacity-70",style:{color:"var(--text-muted)"},"aria-label":"Cancelar",children:t.jsx(q.HiXMark,{className:"h-4 w-4"})}),t.jsxs("div",{className:"flex gap-3 pr-8",children:[t.jsx("div",{className:"mt-0.5 flex h-10 w-10 flex-shrink-0 items-center justify-center rounded-xl",style:{background:u.iconBg},children:t.jsx(q.HiExclamationTriangle,{className:"h-5 w-5",style:{color:u.iconColor}})}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("h2",{className:"text-base font-semibold leading-snug",style:{color:"var(--text-main)"},children:r}),n?t.jsx("div",{className:"mt-1.5 text-sm leading-relaxed",style:{color:"var(--text-muted)"},children:n}):null]})]}),t.jsxs("div",{className:"mt-6 flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",children:[t.jsx(Ue,{variant:"secondary",onClick:d,className:"w-full sm:w-auto sm:min-w-[7.5rem]",style:{background:"var(--bg-input)"},children:s}),t.jsx(Ue,{variant:"danger",onClick:c,className:"w-full sm:w-auto sm:min-w-[7.5rem]",style:{background:u.btnBg,color:u.btnColor,borderColor:"transparent"},children:a})]})]})})}function mc(e){return e?typeof e=="function"?e():e:""}function pc(e){return/^https?:\/\//i.test(e)}function Jo(e,r){try{return new URL(e,r).toString()}catch{return e}}function hc(e,r,n,a=!1){const s=typeof e=="function"?e():e,l=r?r(s):s;if(!l||pc(l))return l;const i=mc(n);return i?Jo(l,i):a&&typeof window<"u"?Jo(l,window.location.origin):l}function gc({url:e,resolveUrl:r,baseUrl:n,useWindowOriginForRelative:a=!1,title:s="Copiar link",copiedTitle:l="Link copiado",icon:i=t.jsx(q.HiLink,{className:"h-3.5 w-3.5"}),...c}){return t.jsx(La,{...c,value:()=>hc(e,r,n,a),title:s,copiedTitle:l,icon:i})}const Ro=32767;function Cn(e){let r=String(e??"");return r=r.split("\0").join(""),r.length<=Ro?r:`${r.slice(0,Ro-1)}…`}const En=[25,50,100,200,500];let Nt={dataTable:{pageSizeOptions:[...En]}};function vc(){if(typeof window>"u")return;const r=window.__BONSAIF_DATA_TABLE_PREFERENCES_ENDPOINT__;return typeof r=="string"&&r.trim().length>0?r.trim().replace(/\/+$/,""):void 0}function Ha(){const e=Nt.dataTable.preferencesEndpoint,r=vc();return e&&e.trim().length>0?e.trim().replace(/\/+$/,""):r}function yc(e){if(!Array.isArray(e))return[...En];const r=Array.from(new Set(e.map(n=>typeof n=="number"?Math.floor(n):Number.NaN).filter(n=>Number.isFinite(n)&&n>0)));return r.length>0?r:[...En]}function es(e){if(typeof e!="string")return;const r=e.trim();if(r)return r.replace(/\/+$/,"")}function xc(e){if(!e||typeof e!="object"||!e.dataTable)return;const r=es(e.dataTable.preferencesEndpoint);Nt={...Nt,dataTable:{...Nt.dataTable,pageSizeOptions:yc(e.dataTable.pageSizeOptions),preferencesEndpoint:r??Nt.dataTable.preferencesEndpoint}}}function wc(){return{dataTable:{pageSizeOptions:[...Nt.dataTable.pageSizeOptions]}}}function Xr(){return[...Nt.dataTable.pageSizeOptions]}function Nc(){Nt={dataTable:{pageSizeOptions:[...En]}}}function kc(e){Nt={...Nt,dataTable:{...Nt.dataTable,preferencesEndpoint:es(e)}}}const Mn=[{value:"equals",label:"Igual a",valueMode:"single"},{value:"notEquals",label:"No es igual a",valueMode:"single"},{value:"greaterThan",label:"Mayor que",valueMode:"single"},{value:"greaterThanOrEqual",label:"Mayor o igual que",valueMode:"single"},{value:"lessThan",label:"Menor que",valueMode:"single"},{value:"lessThanOrEqual",label:"Menor o igual que",valueMode:"single"},{value:"between",label:"Entre",valueMode:"between"},{value:"top10",label:"10 superiores",valueMode:"none"},{value:"bottom10",label:"10 inferiores",valueMode:"none"},{value:"aboveAverage",label:"Sobre promedio",valueMode:"none"},{value:"belowAverage",label:"Bajo promedio",valueMode:"none"}],Sc=Mn.map(e=>({value:e.value,label:e.label})),Cc=12,Ec={layout:!0,filters:!1,sort:!1,bql:!1,pagination:!0},ts={layout:!0,filters:!0,sort:!0,bql:!0,pagination:!0},Mc="bonsaif-ui:datatable:",Tc="[&_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",$c=[],Ac=52;function _t(e){if(!e)return 150;const r=parseInt(e,10);return isNaN(r)||r<=0?150:r}function rs(e){return!!(e&&(Array.isArray(e.columnOrder)&&e.columnOrder.length>0||e.columnWidths&&Object.keys(e.columnWidths).length>0||Array.isArray(e.hiddenColumnKeys)&&e.hiddenColumnKeys.length>0||e.filters&&Object.keys(e.filters).length>0||e.conditionFilters&&Object.keys(e.conditionFilters).length>0||e.sort||typeof e.bql=="string"||Array.isArray(e.bqlHistory)&&e.bqlHistory.length>0||typeof e.pageSize=="number"))}function ns(e){return`${Mc}${e}`}function Tn(e){try{const r=window.localStorage.getItem(ns(e));if(!r)return null;const n=JSON.parse(r);return n&&typeof n=="object"?n:null}catch{return null}}function Lc(e,r){try{window.localStorage.setItem(ns(e),JSON.stringify(r))}catch{}}function Dc(e,r){if(e===!0)return{...ts};if(e===!1)return{layout:!1,filters:!1,sort:!1,bql:!1,pagination:!1};if(r&&e==null)return{...ts};const n={...Ec,...e??{}};return r&&(typeof e!="object"||e.pagination!==!1)&&(n.pagination=!0),n}function as(...e){return e.reduce((r,n)=>({...r,...n??{}}),{})}function Ba(e,r,n){return typeof e!="number"||e<=0?n:Jr(r).includes(e)?e:n}function Kr(e){if(!e||typeof e!="object")return!1;const r=e;return typeof r.key=="string"&&(r.dir==="asc"||r.dir==="desc")}function Gr(e,r){if(!e||typeof e!="object"||Array.isArray(e))return{};const n=Object.entries(e).flatMap(([a,s])=>{if(!r.has(a)||!Array.isArray(s))return[];const l=s.filter(i=>typeof i=="string");return l.length>0?[[a,l]]:[]});return Object.fromEntries(n)}function Zr(e,r){if(!e||typeof e!="object"||Array.isArray(e))return{};const n=new Set(Mn.map(s=>s.value)),a=Object.entries(e).flatMap(([s,l])=>{if(!r.has(s)||!l||typeof l!="object")return[];const i=l;return!i.operator||!n.has(i.operator)?[]:[[s,{operator:i.operator,value:typeof i.value=="string"?i.value:"",valueTo:typeof i.valueTo=="string"?i.valueTo:""}]]});return Object.fromEntries(a)}function pt(e,r){if(or(e))return Ac;const n=e.minWidth??80,a=e.maxWidth??1/0;return Math.min(a,Math.max(n,r))}function Ic(e){const r=window.getComputedStyle(e);return parseFloat(r.paddingLeft)+parseFloat(r.paddingRight)}function or(e){return e.key==="actions"||e.key==="acciones"?!0:typeof e.header=="string"&&e.header.trim().toLowerCase()==="acciones"}function Fa(e){return e.sticky===!0}function os(e){return!(e.reorderable===!1||e.sticky&&e.reorderable!==!0)}function Xt(e,r){const n=r.filter(Fa).map(i=>i.key);if(n.length===0)return e;const a=new Set(n),s=n.filter(i=>e.includes(i)),l=e.filter(i=>!a.has(i));return[...s,...l]}function Oc(e,r){if(r<=7)return Array.from({length:r},(a,s)=>s+1);const n=[1];e>3&&n.push("...");for(let a=Math.max(2,e-1);a<=Math.min(r-1,e+1);a++)n.push(a);return e<r-2&&n.push("..."),n.push(r),n}function Kt(e,r){var i;const n=new Set(r.filter(c=>c.hideable!==!1).map(c=>c.key)),a=Array.from(new Set(e??[])).filter(c=>n.has(c));if(r.filter(c=>!a.includes(c.key)).length>0)return a;const l=(i=r.find(c=>c.hideable!==!1))==null?void 0:i.key;return l?a.filter(c=>c!==l):[]}function Hc(e){return e==null||e===""?"(Vacio)":e instanceof Date?e.toLocaleDateString():String(e)}function gr(e){return e==null||typeof e=="boolean"?"":typeof e=="string"||typeof e=="number"?String(e):Array.isArray(e)?e.map(gr).join(" ").trim():o.isValidElement(e)?gr(e.props.children):""}function $n(e,r){const n=e.filterValue?e.filterValue(r):e.sortKey?r[e.sortKey]:e.cell(r);return typeof n=="string"||typeof n=="number"||typeof n=="boolean"||n===null||n===void 0||n instanceof Date?Hc(n):gr(n).trim()}function Qr(e){const r=e.replace(/,/g,"").trim();if(!r)return null;const n=Number(r);return Number.isFinite(n)?n:null}function vr(e,r){const n=Qr(e),a=Qr(r);return n!==null&&a!==null?n-a:e.localeCompare(r,void 0,{numeric:!0,sensitivity:"base"})}function Jr(e){const r=Array.from(new Set(e.map(n=>Math.floor(n)).filter(n=>Number.isFinite(n)&&n>0)));return r.length>0?r:Xr()}function Bc(e,r,n){var i,c;const a=((i=r.value)==null?void 0:i.trim())??"",s=((c=r.valueTo)==null?void 0:c.trim())??"",l=Mn.find(d=>d.value===r.operator);if((l==null?void 0:l.valueMode)==="single"&&!a||(l==null?void 0:l.valueMode)==="between"&&(!a||!s))return!0;switch(r.operator){case"equals":return e.toLowerCase()===a.toLowerCase();case"notEquals":return e.toLowerCase()!==a.toLowerCase();case"greaterThan":return vr(e,a)>0;case"greaterThanOrEqual":return vr(e,a)>=0;case"lessThan":return vr(e,a)<0;case"lessThanOrEqual":return vr(e,a)<=0;case"between":return vr(e,a)>=0&&vr(e,s)<=0;case"top10":case"bottom10":{const u=n.map(b=>({value:b,number:Qr(b)})).filter(b=>b.number!==null).sort((b,f)=>b.number-f.number).map(b=>b.value);return(r.operator==="top10"?u.slice(-10):u.slice(0,10)).includes(e)}case"aboveAverage":case"belowAverage":{const d=n.map(Qr).filter(b=>b!==null);if(d.length===0)return!1;const u=d.reduce((b,f)=>b+f,0)/d.length,m=Qr(e);return m===null?!1:r.operator==="aboveAverage"?m>u:m<u}default:return!0}}function ss({children:e,className:r="",style:n}){return t.jsx(Yt,{onlyWhenOverflow:!0,className:r,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,...n},children:e})}function ls({columns:e,data:r,getRowId:n,loading:a=!1,skeletonRows:s=8,emptyIcon:l,emptyText:i="Sin resultados",initialEmptyDelay:c=450,onRowClick:d,renderExpandedRow:u,getRowCanExpand:m,expandedRowIds:b,defaultExpandedRowIds:f=[],onExpandedRowIdsChange:h,expandOnRowClick:v=!1,selected:k,onToggleOne:g,onToggleAll:A,getRowSelectable:$,highlightSelected:N=!0,rowClassName:T,getRowCategory:x,stickyHeader:y=!0,pageSize:L=25,pageSizeOptions:w,pageSizeSelectWidth:W=62,pageSizeSelectHeight:X=30,pageSizeSelectPadding:Z="0 7px",totalRows:D,page:Q,onPageChange:j,onPageSizeChange:se,storageKey:te,stickyFirstColumn:ee=!1,bottomOffset:U=0,compact:J=!0,restrictHeight:ce=!0,maxHeight:C,minTableWidth:_,enableColumnVisibility:ae=!0,enableColumnFilters:B=!0,hiddenColumnKeys:I,defaultHiddenColumnKeys:M=$c,onHiddenColumnKeysChange:oe,columnVisibilityLabel:K="Columnas",enableBql:Y=!1,bqlValue:S,defaultBqlValue:H="",onBqlChange:O,bqlDescription:re="Filtra registros con Bonsaif Query Language",bqlPlaceholder:z=`status = activo
2
+ rol IN (admin, employee)`,bqlQuickFilters:de=[],bqlExamples:he=[],bqlSuggestions:ie=[],bqlActiveFilters:ge,bqlError:Me,onQueryChange:$e,persistState:Dt,onPreferencesReady:ut,enableExport:Re=!1,exportFilename:It="datos",onExportCsv:Ct,onExportPdf:Et}){var Ti;const le=Dc(Dt,te),Fe=Object.values(le).some(Boolean),ze=e.map(p=>p.key).join(","),ft=M.join(","),Ve=o.useRef(e),Mt=o.useRef(M);Ve.current=e,Mt.current=M;const[bt,rt]=o.useState(!te||!Fe),Wt=o.useRef(null),ue=o.useRef(!te),pe=o.useRef(!1),Le=o.useRef(ut);Le.current=ut;const He=o.useRef(!te||!Fe?te??"__none__":null),Ie=I!==void 0,[tt,at]=o.useState(()=>Kt(M,e)),We=Kt(Ie?I:tt,e),[Ke,Ge]=o.useState(!1),[Ae,lr]=o.useState("filter"),[ir,Or]=o.useState(null),[Jt,oa]=o.useState(""),[lt,jt]=o.useState({}),[F,G]=o.useState({}),fe=b!==void 0,[be,Te]=o.useState(f),ye=S!==void 0,[Be,De]=o.useState(H),Ye=ye?S:Be,[Ze,Ot]=o.useState(Ye),[ot,it]=o.useState(!1),[cr,qt]=o.useState(!1),[fn,Hr]=o.useState(!1),[bn,Br]=o.useState([]),Fr=o.useRef(null),dr=o.useRef(null),Ht=o.useRef(O);Ht.current=O;const sa=o.useRef(L);sa.current=L;const la=o.useRef(w);la.current=w;const kb=Array.isArray(w)?w.join(","):"",wo=o.useRef(null),Jl=o.useRef(null),No=o.useRef(null),Rl=o.useRef(0),[Sb,Cb]=o.useState({}),[Eb,Mb]=o.useState({}),[mn,ia]=o.useState(!1),ko=o.useRef(null),ca=o.useRef(null),[Tb,$b]=o.useState({}),ei=o.useRef(null),da=o.useRef(null),[So,ti]=o.useState(r.length>0||a||c===!1),ri=(p,E)=>50+(p*17+E*13+7)%40,Rt=o.useRef(null),[Ab,Lb]=o.useState(void 0),[ni,Db]=o.useState(0),[Ib,Ob]=o.useState(!1);o.useEffect(()=>{function p(){Ob(window.innerWidth<640)}if(!ce||C!==void 0)return p(),window.addEventListener("resize",p),()=>window.removeEventListener("resize",p);const R=L!==!1?48:0,P=12;function ne(){if(p(),!Rt.current)return;const me=Rt.current.getBoundingClientRect().top;Lb(Math.max(120,window.innerHeight-me-R-P-U))}return ne(),window.addEventListener("resize",ne),()=>window.removeEventListener("resize",ne)},[a,L,U,ce,C]);const ai=ce?C??Ab:void 0;o.useEffect(()=>{const p=Rt.current;if(!p)return;const E=()=>Db(p.clientWidth);if(E(),typeof ResizeObserver>"u")return window.addEventListener("resize",E),()=>window.removeEventListener("resize",E);const R=new ResizeObserver(E);return R.observe(p),()=>R.disconnect()},[a,bt,r.length]),o.useEffect(()=>{if(c===!1||a||r.length>0){ti(!0);return}if(So)return;const p=window.setTimeout(()=>{ti(!0)},c);return()=>window.clearTimeout(p)},[r.length,c,So,a]);const[Pr,_r]=o.useState(()=>Xt(e.map(p=>p.key),e)),[ur,zr]=o.useState(()=>Object.fromEntries(e.map(p=>[p.key,pt(p,_t(p.width))]))),[Xe,fr]=o.useState(null),[Hb,ua]=o.useState(1),[fa,ba]=o.useState(L===!1?0:L);o.useEffect(()=>{var Ee;const p=Ve.current,E=Mt.current,R=p.map(Ne=>Ne.key),P=new Set(R),ne=()=>{var Ne;pe.current||(pe.current=!0,(Ne=Le.current)==null||Ne.call(Le))};if(!te||!Fe){le.layout&&_r(Xt(R,p)),Ie||at(Kt(E,p)),ue.current=!1,rt(!0),ne();return}let me=!1;const ke=He.current===te;ke||(ue.current=!1,rt(!1),pe.current=!1);const Ce=Tn(te);if(rs(Ce)&&!ke){const Ne=Ce,xe=Jr(la.current??Xr()),we=sa.current,pr=we===!1?0:we,tr=le.layout?Ne==null?void 0:Ne.columnOrder:void 0,rr=Array.isArray(tr)?tr.filter(_e=>R.includes(_e)):[],nr=R.filter(_e=>!rr.includes(_e)),hr=Xt(rr.length>0?[...rr,...nr]:R,p),qr=Object.fromEntries(p.map(_e=>[_e.key,pt(_e,_t(_e.width))])),Ur=le.layout?(Ne==null?void 0:Ne.columnWidths)??{}:{},vn=Object.fromEntries(p.map(_e=>[_e.key,pt(_e,Ur[_e.key]??qr[_e.key])])),Vr=Kt(le.layout?(Ne==null?void 0:Ne.hiddenColumnKeys)??E:E,p);if(le.layout&&(_r(hr),zr(vn)),Ie||at(Vr),le.filters&&(jt(Gr(Ne==null?void 0:Ne.filters,P)),G(Zr(Ne==null?void 0:Ne.conditionFilters,P))),le.sort){const _e=Kr(Ne==null?void 0:Ne.sort)?Ne.sort:null;fr(_e&&P.has(_e.key)?_e:null)}if(le.bql){if(Fr.current!==te){Fr.current=te;const _e=typeof(Ne==null?void 0:Ne.bql)=="string"?Ne.bql:H;ye?(Ee=Ht.current)==null||Ee.call(Ht,_e):De(_e)}Br(Array.isArray(Ne==null?void 0:Ne.bqlHistory)?Ne.bqlHistory.filter(_e=>typeof _e=="string"):[])}le.pagination&&dr.current!==te&&(dr.current=te,ba(Ba(Ne==null?void 0:Ne.pageSize,xe,pr))),He.current=te,rt(!0),ne()}const mt=`${Ha()??"/api/user/preferences/datatables"}?key=${encodeURIComponent(te)}`,et=new AbortController,ve=window.setTimeout(()=>et.abort(),2500);return fetch(mt,{cache:"no-store",signal:et.signal}).then(Ne=>Ne.ok?Ne.json():null).then(Ne=>{var $i;if(me)return;const xe=Tn(te),we=as(rs(Ne==null?void 0:Ne.settings)?Ne==null?void 0:Ne.settings:null,xe),pr=Jr(la.current??Xr()),tr=sa.current,rr=tr===!1?0:tr,nr=le.layout?we==null?void 0:we.columnOrder:void 0,hr=Array.isArray(nr)?nr.filter(Qe=>R.includes(Qe)):[],qr=R.filter(Qe=>!hr.includes(Qe)),Ur=Xt(hr.length>0?[...hr,...qr]:R,p),vn=Object.fromEntries(p.map(Qe=>[Qe.key,pt(Qe,_t(Qe.width))])),Vr=le.layout?(we==null?void 0:we.columnWidths)??{}:{},_e=Object.fromEntries(p.map(Qe=>[Qe.key,pt(Qe,Vr[Qe.key]??vn[Qe.key])])),Yr=Kt(le.layout?(we==null?void 0:we.hiddenColumnKeys)??E:E,p);if(le.layout&&(_r(Ur),zr(_e)),Ie||at(Yr),le.filters&&(jt(Gr(we==null?void 0:we.filters,P)),G(Zr(we==null?void 0:we.conditionFilters,P))),le.sort){const Qe=Kr(we==null?void 0:we.sort)?we.sort:null;fr(Qe&&P.has(Qe.key)?Qe:null)}if(le.bql){if(Fr.current!==te){Fr.current=te;const Qe=typeof(we==null?void 0:we.bql)=="string"?we.bql:H;ye?($i=Ht.current)==null||$i.call(Ht,Qe):De(Qe)}Br(Array.isArray(we==null?void 0:we.bqlHistory)?we.bqlHistory.filter(Qe=>typeof Qe=="string"):[])}let je;le.pagination&&(je=Ba(we==null?void 0:we.pageSize,pr,rr),dr.current!==te&&(dr.current=te,ba(je))),Wt.current=JSON.stringify({columnOrder:Ur,columnWidths:_e,hiddenColumnKeys:Yr,filters:Gr(we==null?void 0:we.filters,P),conditionFilters:Zr(we==null?void 0:we.conditionFilters,P),sort:Kr(we==null?void 0:we.sort)?we.sort:null,bql:typeof(we==null?void 0:we.bql)=="string"?we.bql:"",bqlHistory:Array.isArray(we==null?void 0:we.bqlHistory)?we.bqlHistory:[],pageSize:le.pagination&&tr!==!1?je:void 0}),ue.current=!0}).catch(()=>{var Ne;if(!me){const xe=Tn(te),we=Jr(la.current??Xr()),pr=sa.current,tr=pr===!1?0:pr,rr=le.layout?xe==null?void 0:xe.columnOrder:void 0,nr=Array.isArray(rr)?rr.filter(je=>R.includes(je)):[],hr=R.filter(je=>!nr.includes(je)),qr=Xt(nr.length>0?[...nr,...hr]:R,p),Ur=Object.fromEntries(p.map(je=>[je.key,pt(je,_t(je.width))])),vn=le.layout?(xe==null?void 0:xe.columnWidths)??{}:{},Vr=Object.fromEntries(p.map(je=>[je.key,pt(je,vn[je.key]??Ur[je.key])]));le.layout&&(_r(qr),zr(Vr));const _e=Kt(le.layout?(xe==null?void 0:xe.hiddenColumnKeys)??E:E,p);if(Ie||at(_e),le.filters&&(jt(Gr(xe==null?void 0:xe.filters,P)),G(Zr(xe==null?void 0:xe.conditionFilters,P))),le.sort){const je=Kr(xe==null?void 0:xe.sort)?xe.sort:null;fr(je&&P.has(je.key)?je:null)}if(le.bql){if(Fr.current!==te){Fr.current=te;const je=typeof(xe==null?void 0:xe.bql)=="string"?xe.bql:H;ye?(Ne=Ht.current)==null||Ne.call(Ht,je):De(je)}Br(Array.isArray(xe==null?void 0:xe.bqlHistory)?xe.bqlHistory.filter(je=>typeof je=="string"):[])}let Yr;le.pagination&&(Yr=Ba(xe==null?void 0:xe.pageSize,we,tr),dr.current!==te&&(dr.current=te,ba(Yr))),Wt.current=JSON.stringify({columnOrder:qr,columnWidths:Vr,hiddenColumnKeys:_e,filters:Gr(xe==null?void 0:xe.filters,P),conditionFilters:Zr(xe==null?void 0:xe.conditionFilters,P),sort:Kr(xe==null?void 0:xe.sort)?xe.sort:null,bql:typeof(xe==null?void 0:xe.bql)=="string"?xe.bql:"",bqlHistory:Array.isArray(xe==null?void 0:xe.bqlHistory)?xe.bqlHistory:[],pageSize:le.pagination&&pr!==!1?Yr:void 0}),ue.current=!0}}).finally(()=>{window.clearTimeout(ve),me||(He.current=te,rt(!0),ne())}),()=>{me=!0,et.abort(),window.clearTimeout(ve)}},[te,Fe,ze,ft,Ie,le.layout,le.filters,le.sort,le.bql,le.pagination,ye,H,kb]),o.useEffect(()=>{if(!te||!bt||!Fe||!ue.current)return;const p={};le.layout&&(p.columnOrder=Pr,p.columnWidths=ur,p.hiddenColumnKeys=We),le.filters&&(p.filters=lt,p.conditionFilters=F),le.sort&&(p.sort=Xe),le.bql&&(p.bql=Ye,p.bqlHistory=bn),le.pagination&&L!==!1&&(p.pageSize=fa);const E=Tn(te),R=as(E,p),P=JSON.stringify(R);if(P===Wt.current)return;Lc(te,R),Wt.current=P;const ne=window.setTimeout(()=>{const me=Ha()??"/api/user/preferences/datatables";fetch(me,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({key:te,settings:R})}).then(()=>{}).catch(()=>{})},300);return()=>window.clearTimeout(ne)},[Pr,ur,We,lt,F,Xe,Ye,bn,fa,L,te,bt,Fe,le.layout,le.filters,le.sort,le.bql,le.pagination]),o.useEffect(()=>{_r(p=>{const E=e.map(ne=>ne.key),R=p.filter(ne=>E.includes(ne)),P=E.filter(ne=>!R.includes(ne));return Xt([...R,...P],e)})},[ze,e]);const oi=Xt(Pr,e).map(p=>e.find(E=>E.key===p)).filter(p=>!!p),wt=oi.filter(p=>!We.includes(p.key)),si=e.some(Fa),Bb=Object.keys(lt).length,Fb=Object.keys(F).length,Co=Bb+Fb;function li(p){const E=new Set;return r.reduce((R,P)=>{const ne=$n(p,P);return!ne||E.has(ne)||(E.add(ne),R.push({value:ne,label:ne})),R},[])}function Pb(){const p=e.find(E=>E.key===ir);return p?li(p):[]}function _b(p){return!!(B&&!or(p)&&(p.filterValue||p.sortKey||li(p).length>0))}function ii(p,E){jt(R=>{const P={...R};return P[p]=E,P})}function zb(p,E,R,P){const ne=lt[p]??[],me=P?ne:R.filter(Ce=>Ce!==E),ke=P?ne.includes(E)?ne.filter(Ce=>Ce!==E):[...ne,E]:me;ke.length===R.length?Eo(p):ii(p,ke)}function Eo(p){jt(E=>{const R={...E};return delete R[p],R})}function ma(p,E){G(R=>{const P={...R};return E?P[p]=E:delete P[p],P})}function ci(p){ma(p,null)}function Wb(){jt({}),G({})}function jb(p){ye||De(p),O==null||O(p)}function di(p){const E=p.trim();Ot(E),(O==null?void 0:O(E))!==!1&&(ye||De(E),it(!1),qt(!1),Hr(!1),E&&Br(P=>[E,...P.filter(ne=>ne!==E)].slice(0,Cc)))}function ui(){Ot(""),jb(""),it(!1),qt(!1),Hr(!1)}function Mo(p,E){Ot(p),E&&(E.style.height="auto",E.style.height=`${Math.min(E.scrollHeight,180)}px`)}function pa(p){const E=p.trim();if(!E)return;Rl.current=Date.now()+500;const R=Ze.replace(/\s+$/u,""),P=R.length===0?E:R.split(`
3
+ `).map(ne=>ne.trim()).includes(E)?R:`${R}
4
+ ${E}`;Mo(P,No.current??void 0),requestAnimationFrame(()=>{const ne=No.current;if(!ne)return;ne.focus();const me=ne.value.length;ne.setSelectionRange(me,me),Mo(ne.value,ne)})}o.useEffect(()=>{Ot(Ye)},[Ye]);const ha=o.useCallback(()=>{const p=wo.current;if(!p)return;const E=p.getBoundingClientRect(),R=12,P=8,ne=Math.min(780,Math.max(320,window.innerWidth-32)),me=Math.max(R,window.innerWidth-ne-R),ke=Math.min(Math.max(R,E.left),me),Ce=E.bottom+P,Pe=window.innerHeight-E.top+P,qe=window.innerHeight-Ce-R,mt=E.top-R-P,et=qe<280&&mt>qe,ve=Math.max(240,et?mt:qe);Cb({position:"fixed",zIndex:1e4,left:ke,top:et?void 0:Ce,bottom:et?Pe:void 0,width:ne,maxWidth:"calc(100vw - 24px)",maxHeight:ve,overflowY:"auto"})},[]);o.useEffect(()=>{if(!ot)return;function p(P){var me,ke;if(Date.now()<Rl.current)return;const ne=P.target;(me=wo.current)!=null&&me.contains(ne)||(ke=Jl.current)!=null&&ke.contains(ne)||(it(!1),qt(!1),Hr(!1))}function E(P){P.key==="Escape"&&(it(!1),qt(!1),Hr(!1))}function R(){ha()}return ha(),document.addEventListener("mousedown",p),window.addEventListener("keydown",E),window.addEventListener("resize",R),window.addEventListener("scroll",R,!0),()=>{document.removeEventListener("mousedown",p),window.removeEventListener("keydown",E),window.removeEventListener("resize",R),window.removeEventListener("scroll",R,!0)}},[ot,ha]);function fi(p){const E=Kt(p,e);Ie||at(E),oe==null||oe(E)}function qb(p){fi(We.includes(p)?We.filter(E=>E!==p):[...We,p])}function Ub(){fi([])}const To=o.useCallback((p=da.current)=>{if(!p)return;const E=p.getBoundingClientRect(),R=Math.min(292,Math.max(240,window.innerWidth-16)),P=Math.max(8,window.innerWidth-R-8),ne=Math.min(Math.max(8,E.right-R),P),me=window.innerHeight-E.bottom,ke=E.bottom+6,Ce=window.innerHeight-E.top+6,qe=me<360&&E.top>me?void 0:ke,mt=qe===void 0?Ce:void 0,et=Math.max(220,qe===void 0?E.top-16:window.innerHeight-ke-8),ve={position:"fixed",zIndex:9999,left:ne,top:qe,bottom:mt,width:R,maxWidth:"calc(100vw - 16px)",maxHeight:et,"--dt-column-menu-max-height":`${et}px`};Mb(ve)},[]);function bi(p,E,R=null){p.preventDefault(),p.stopPropagation();const P=da.current===p.currentTarget&&Ae===E&&ir===R;if(Ke&&P){Ge(!1),Or(null);return}da.current=p.currentTarget,lr(E),Or(R),oa(""),To(p.currentTarget),Ge(!0)}function Vb(p){if(or(p))return;const E=Rt.current;if(!E)return;const P=Array.from(E.querySelectorAll("[data-dt-column-key]")).filter(ne=>ne.dataset.dtColumnKey===p.key).reduce((ne,me)=>{const ke=me.querySelector("[data-dt-autofit-content]"),Ce=ke?ke.scrollWidth:Math.max(me.scrollWidth,me.offsetWidth);return Math.max(ne,Math.ceil(Ce+Ic(me)))},0);P<=0||zr(ne=>({...ne,[p.key]:pt(p,P+12)}))}o.useEffect(()=>{zr(p=>{const E=Object.fromEntries(e.map(R=>[R.key,pt(R,_t(R.width))]));return Object.fromEntries(e.map(R=>[R.key,pt(R,p[R.key]??E[R.key])]))})},[ze,e]),o.useEffect(()=>{Ie||at(p=>Kt(p,e))},[ze,e,Ie]),o.useEffect(()=>{function p(P){var ke,Ce;const ne=P.target,me=P.target;me!=null&&me.closest("[data-bonsaif-select-dropdown='true']")||!((ke=ei.current)!=null&&ke.contains(ne))&&!((Ce=da.current)!=null&&Ce.contains(ne))&&(Ge(!1),Or(null))}function E(P){P.key==="Escape"&&(Ge(!1),Or(null))}function R(){To()}return Ke&&(document.addEventListener("mousedown",p),window.addEventListener("keydown",E),window.addEventListener("resize",R),window.addEventListener("scroll",R,!0)),()=>{document.removeEventListener("mousedown",p),window.removeEventListener("keydown",E),window.removeEventListener("resize",R),window.removeEventListener("scroll",R,!0)}},[Ke,To]);const pn=o.useRef(null);o.useEffect(()=>{function p(R){const P=pn.current;if(!P)return;const ne=R.clientX-P.startX,me=e.find(ke=>ke.key===P.colKey);me&&zr(ke=>({...ke,[P.colKey]:pt(me,P.startWidth+ne)}))}function E(){pn.current&&(pn.current=null,document.body.style.cursor="",document.body.style.userSelect="")}return document.addEventListener("pointermove",p),document.addEventListener("pointerup",E),()=>{document.removeEventListener("pointermove",p),document.removeEventListener("pointerup",E)}},[e]);const hn=o.useRef(null),[mi,$o]=o.useState(null);function Yb(p,E){const R=e.find(P=>P.key===p);if(!R||!os(R)){E.preventDefault();return}hn.current=Pr.indexOf(p),E.dataTransfer.effectAllowed="move"}function Xb(p,E){E.preventDefault(),E.dataTransfer.dropEffect="move";const R=Pr.indexOf(p);mi!==R&&$o(R)}function Kb(p,E){E.preventDefault();const R=hn.current,P=Pr.indexOf(p);R!==null&&R!==P&&_r(ne=>{const me=[...ne],[ke]=me.splice(R,1);return me.splice(P,0,ke),Xt(me,e)}),hn.current=null,$o(null)}function Gb(){hn.current=null,$o(null)}function Zb(p){p.sortKey&&fr(E=>(E==null?void 0:E.key)===p.key?{key:p.key,dir:E.dir==="asc"?"desc":"asc"}:{key:p.key,dir:"asc"})}o.useEffect(()=>{ua(1)},[r]),o.useEffect(()=>{ua(1)},[F,lt]);const Bt=!!(j&&se),er=L!==!1,Ao=o.useMemo(()=>Jr(w??Xr()),[w]),st=Bt?Q??1:Hb,pi=er&&fa<1?typeof L=="number"&&L>0?L:Ao[0]??25:fa,Ft=Bt||er?pi:r.length,Tt=!!k&&!!g&&!!A,Lo=o.useMemo(()=>$?r.filter(p=>$(p)):r,[r,$]),Wr=!!u,hi=o.useMemo(()=>new Set(fe?Array.from(b??[]):be),[fe,b,be]),Qb=(Wr?40:0)+(Tt?40:0),Do=!Ib&&(si||ee),ga=(()=>{if(!Do)return{};let p=Qb;const E={};return wt.forEach((R,P)=>{(Fa(R)||!si&&ee&&P===0)&&(E[R.key]=p,p+=ur[R.key]??pt(R,_t(R.width)))}),E})(),Io=Object.keys(ga),Oo=Io.length>0?Io[Io.length-1]:null,gi=Tt&&Lo.length>0&&Lo.every(p=>k.has(n(p))),Jb=Tt&&k.size>0&&Lo.some(p=>k.has(n(p)))&&!gi,va=o.useMemo(()=>{if(Bt)return r;const p=Object.entries(lt),E=Object.entries(F);return p.length===0&&E.length===0?r:r.filter(R=>p.every(([P,ne])=>{const me=e.find(ke=>ke.key===P);return me?ne.includes($n(me,R)):!0})&&E.every(([P,ne])=>{const me=e.find(Ce=>Ce.key===P);if(!me)return!0;const ke=r.map(Ce=>$n(me,Ce));return Bc($n(me,R),ne,ke)}))},[F,lt,e,r,Bt]),br=o.useMemo(()=>{if(!Xe)return va;const p=e.find(E=>E.key===Xe.key&&E.sortKey);return p!=null&&p.sortKey?[...va].sort((E,R)=>{const P=E[p.sortKey],ne=R[p.sortKey],me=P===ne?0:P==null?1:ne==null||P<ne?-1:1;return Xe.dir==="asc"?me:-me}):va},[va,Xe,e]),vi=o.useMemo(()=>{if(Bt||!er)return br;const p=(st-1)*Ft;return br.slice(p,p+Ft)},[br,Bt,er,st,Ft]),Ut=Bt?D??r.length:br.length,Ho=er?Math.max(1,Math.ceil(Ut/Ft)):1,Rb=Math.min(...Ao),em=er&&(Ut>Ft||Ut>Rb),tm=er?(st-1)*Ft+1:1,rm=er?Math.min(st*Ft,Ut):Ut;function Bo(p){if(a)return;const E=Math.max(1,Math.min(p,Ho));Bt?j(E):ua(E)}function nm(p){a||(te&&(dr.current=te),ba(p),Bt?(se(p),j(1)):(ua(1),se==null||se(p)))}function yi(p){const E=new Set(hi);E.has(p)?E.delete(p):E.add(p);const R=Array.from(E);fe||Te(R),h==null||h(R)}o.useEffect(()=>{$e==null||$e({bql:Ye,filters:lt,conditionFilters:F,sort:Xe,page:st,pageSize:Ft,hiddenColumnKeys:We})},[Ye,lt,F,Xe,st,Ft,We,$e]);const xi=p=>p==="center"?"justify-center text-center":p==="right"?"justify-end text-right":"justify-start text-left",am="color-mix(in srgb, var(--primary) 6%, var(--bg-card))",Fo="linear-gradient(180deg, color-mix(in srgb, var(--bg-input) 90%, var(--bg-card)) 0%, color-mix(in srgb, var(--bg-input) 70%, var(--bg-card)) 100%)",Oe="color-mix(in srgb, var(--border) 62%, var(--bg-card))",mr="color-mix(in srgb, var(--primary) 24%, var(--border))",ya=`inset 0 0 0 1px ${Oe}`,wi=wt.reduce((p,E)=>p+(ur[E.key]??_t(E.width)),(Wr?40:0)+(Tt?40:0)),Ni=typeof _=="number"?_:typeof _=="string"?Number(((Ti=_.match(/^(\d+(?:\.\d+)?)px$/))==null?void 0:Ti[1])??NaN):NaN,gn=Number.isFinite(Ni)?Math.max(wi,Ni,ni):Math.max(wi,ni),xa=_??gn,jr=`${Wr?"40px ":""}${Tt?"40px ":""}${wt.map(p=>`${ur[p.key]??_t(p.width)}px`).join(" ")}`;o.useEffect(()=>{Xe&&We.includes(Xe.key)&&fr(null)},[We,Xe]);function ki(p){return p?typeof p=="string"?{key:p,label:p}:p:null}const wa=()=>t.jsxs("div",{role:"row",className:"grid",style:{gridTemplateColumns:jr,background:Fo,borderBottom:`1px solid ${mr}`},children:[Wr&&t.jsx("div",{role:"columnheader",className:`${J?"px-2 py-1.5":"px-3 py-2.5"} w-10`,style:{borderBottom:`1px solid ${mr}`,borderRight:`1px solid ${Oe}`}}),Tt&&t.jsx("div",{role:"columnheader",className:`${J?"px-2 py-1.5":"px-3 py-2.5"} flex w-10 items-center justify-center`,style:Do?{position:"sticky",left:0,zIndex:12,background:Fo,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)",boxShadow:`inset 0 -1px 0 ${mr}`,borderRight:`1px solid ${Oe}`}:{borderBottom:`1px solid ${mr}`,borderRight:`1px solid ${Oe}`},children:t.jsx(Nn,{size:"sm",checked:gi,indeterminate:Jb,onChange:A,"aria-label":"Seleccionar todos",containerClassName:"items-center",className:"cursor-pointer"})}),wt.map((p,E)=>{const R=(Xe==null?void 0:Xe.key)===p.key,P=!!p.sortKey,ne=or(p),me=ga[p.key],ke=me!==void 0,Ce=p.key===Oo,Pe=os(p),qe=mi===E,et=(ur[p.key]??_t(p.width))<120,ve=Object.prototype.hasOwnProperty.call(lt,p.key)||Object.prototype.hasOwnProperty.call(F,p.key);return t.jsxs("div",{role:"columnheader","data-dt-column-key":p.key,className:`group select-none ${et?"text-left":xi(p.align)}`,style:{...ke?{position:"sticky",left:me,zIndex:12,background:Fo,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)",boxShadow:Ce?`3px 0 6px -2px rgba(0,0,0,0.10), inset 0 -1px 0 ${mr}`:`inset 0 -1px 0 ${mr}`,borderRight:`1px solid ${Oe}`}:{position:"relative",borderBottom:`1px solid ${mr}`,borderRight:`1px solid ${Oe}`},color:R?"var(--primary)":"var(--text-muted)",whiteSpace:"nowrap",transition:"color 0.15s",borderLeft:qe?"2px solid var(--primary)":"2px solid transparent",cursor:"default",padding:ne?J?"7px 6px":"9px 8px":J?"8px 6px 10px":"10px 8px 12px"},onDragOver:Ee=>{(Pe||hn.current!==null)&&Xb(p.key,Ee)},onDrop:Ee=>Kb(p.key,Ee),children:[t.jsxs("div",{className:`flex min-w-0 items-center gap-1 ${ne?"justify-center":et?"justify-start":p.align==="center"?"justify-center":p.align==="right"?"justify-end":"justify-start"}`,children:[Pe?t.jsx("span",{draggable:!0,onDragStart:Ee=>{Ee.stopPropagation(),Yb(p.key,Ee)},onDragEnd:Ee=>{Ee.stopPropagation(),Gb()},onClick:Ee=>Ee.stopPropagation(),title:"Arrastrar para mover columna","aria-label":"Arrastrar para mover columna",className:`absolute left-0 top-0 z-10 inline-flex h-full w-3 shrink-0 rounded-sm transition-colors duration-150 hover:bg-[var(--primary)]/15 ${qe?"bg-[var(--primary)]/20":""}`,style:{cursor:"grab"}}):null,ne?t.jsx("span",{className:"inline-flex h-5 w-5 items-center justify-center rounded-md text-[var(--text-muted)]",title:"Acciones","aria-label":"Acciones",children:t.jsx(q.HiCog6Tooth,{className:"h-3.5 w-3.5"})}):t.jsx(ss,{className:"min-w-0 flex-1",children:t.jsx("span",{"data-dt-autofit-content":!0,className:`inline-flex max-w-full items-center font-semibold uppercase tracking-wider ${J?"text-[11px]":"text-xs"}`,children:t.jsx("span",{className:"min-w-0 truncate",children:p.header})})}),P&&t.jsx("button",{type:"button","aria-label":`Ordenar por ${String(p.header)}`,title:"Ordenar",onClick:Ee=>{Ee.stopPropagation(),Zb(p)},"data-dt-sort-button":!0,className:`absolute -bottom-2 left-1/2 z-20 inline-flex h-4 w-4 -translate-x-1/2 items-center justify-center rounded-full bg-[var(--primary)] text-[var(--primary-fg)] shadow-[0_1px_3px_rgba(15,23,42,0.22)] transition-[opacity,transform] duration-150 hover:scale-105 focus:scale-105 focus:opacity-100 focus:outline-none ${R?"opacity-100":"opacity-0 group-hover:opacity-100 group-focus-within:opacity-100"}`,style:{bottom:"-0.5rem",top:"auto"},children:R?Xe.dir==="asc"?t.jsx(q.HiChevronUp,{className:"h-3 w-3"}):t.jsx(q.HiChevronDown,{className:"h-3 w-3"}):t.jsx(q.HiChevronUpDown,{className:"h-3 w-3"})}),B&&!ne&&_b(p)&&t.jsx("button",{type:"button","aria-haspopup":"menu","aria-expanded":Ke&&ir===p.key,"aria-label":`Filtrar ${String(p.header)}`,title:"Filtrar",onClick:Ee=>bi(Ee,"filter",p.key),className:`inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-sm bg-transparent text-[var(--text-muted)] opacity-0 transition-[opacity,color,background-color] duration-150 hover:bg-[var(--bg-card)] hover:text-[var(--primary)] focus:bg-[var(--bg-card)] focus:text-[var(--primary)] focus:opacity-100 group-hover:opacity-100 ${Ke&&Ae==="filter"&&ir===p.key?"bg-[var(--bg-card)] text-[var(--primary)] opacity-100":ve?"text-[var(--primary)] opacity-100":""}`,children:ve?t.jsx(q.HiFunnel,{className:"h-3.5 w-3.5"}):t.jsx(q.HiEllipsisVertical,{className:"h-3.5 w-3.5"})})]}),!ne&&t.jsx("span",{role:"separator","aria-orientation":"vertical",title:"Arrastrar para redimensionar. Doble click para autoajustar",onPointerDown:Ee=>{Ee.preventDefault(),Ee.stopPropagation(),pn.current={colKey:p.key,startX:Ee.clientX,startWidth:ur[p.key]??150},document.body.style.cursor="col-resize",document.body.style.userSelect="none"},onDoubleClick:Ee=>{Ee.preventDefault(),Ee.stopPropagation(),pn.current=null,document.body.style.cursor="",document.body.style.userSelect="",Vb(p)},onClick:Ee=>Ee.stopPropagation(),className:"absolute top-0 flex h-full items-center justify-center opacity-0 transition-opacity duration-200 hover:opacity-100",style:{right:0,width:12,cursor:"col-resize",zIndex:6,transform:"translateX(50%)"},children:t.jsxs("span",{style:{display:"flex",gap:4,alignItems:"center",height:"calc(100% - 8px)"},children:[t.jsx("span",{style:{width:2,height:"100%",borderRadius:2,background:"var(--primary)",display:"block"}}),t.jsx("span",{style:{width:2,height:"100%",borderRadius:2,background:"var(--primary)",display:"block"}})]})})]},p.key)})]}),Na=()=>{if(!Ke||typeof document>"u"||Ae==="visibility"&&!ae||Ae==="filter"&&!B)return null;const p=e.find(ve=>ve.key===ir),E=Pb(),R=p?Object.prototype.hasOwnProperty.call(lt,p.key):!1,P=p?F[p.key]:void 0,ne=Mn.find(ve=>ve.value===(P==null?void 0:P.operator)),me=p?lt[p.key]??[]:[],ke=Jt.trim().toLowerCase(),Ce=ke?E.filter(ve=>ve.label.toLowerCase().includes(ke)):E,Pe=p&&E.length>0&&(!R||me.length===E.length),qe=p&&R&&me.length>0&&me.length<E.length,mt=We.length,et=()=>{p&&(Eo(p.key),ci(p.key))};return ct.createPortal(t.jsx("div",{ref:ei,role:"menu",className:"overflow-hidden rounded-lg border p-1 shadow-xl",style:{...Eb,borderColor:"var(--border)",background:"var(--bg-card)"},children:Ae==="visibility"?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-[var(--border)] px-2 py-1.5",children:[t.jsx("span",{className:"min-w-0 truncate text-xs font-semibold uppercase text-[var(--text-muted)]",children:mt>0?`${wt.length} de ${e.length} visibles`:`${e.length} visibles`}),t.jsx("button",{type:"button",onClick:Ub,disabled:mt===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"})]}),t.jsx("div",{className:"max-h-72 overflow-auto py-1",children:oi.map(ve=>{const Ee=!We.includes(ve.key),xe=!(ve.hideable!==!1)||Ee&&wt.length<=1;return t.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":Ee,disabled:xe,onClick:()=>qb(ve.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:[t.jsx("span",{className:"flex h-4 w-4 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&&t.jsx(q.HiCheck,{className:"h-3 w-3"})}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:ve.header})]},ve.key)})})]}):p?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-[var(--border)] px-2 py-1.5",children:[t.jsxs("span",{className:"min-w-0 truncate text-xs font-semibold uppercase text-[var(--text-muted)]",children:["Filtrar ",p.header]}),t.jsx("button",{type:"button",onClick:et,disabled:!R&&!P,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:"Limpiar"})]}),p.sortKey&&t.jsxs("div",{className:"grid grid-cols-2 gap-1 border-b border-[var(--border)] p-1",children:[t.jsxs("button",{type:"button",onClick:()=>fr({key:p.key,dir:"asc"}),className:"flex min-w-0 items-center justify-between rounded-md px-2 py-1.5 text-left text-sm transition-colors hover:bg-[var(--bg-input)]",style:{color:"var(--text-main)"},children:[t.jsxs("span",{className:"flex min-w-0 items-center gap-1.5 truncate",children:[t.jsx(q.HiChevronUp,{className:"h-4 w-4 shrink-0 text-[var(--primary)]"}),t.jsx("span",{className:"truncate",children:"Ascendente"})]}),(Xe==null?void 0:Xe.key)===p.key&&Xe.dir==="asc"&&t.jsx(q.HiCheck,{className:"h-4 w-4 shrink-0 text-[var(--primary)]"})]}),t.jsxs("button",{type:"button",onClick:()=>fr({key:p.key,dir:"desc"}),className:"flex min-w-0 items-center justify-between rounded-md px-2 py-1.5 text-left text-sm transition-colors hover:bg-[var(--bg-input)]",style:{color:"var(--text-main)"},children:[t.jsxs("span",{className:"flex min-w-0 items-center gap-1.5 truncate",children:[t.jsx(q.HiChevronDown,{className:"h-4 w-4 shrink-0 text-[var(--primary)]"}),t.jsx("span",{className:"truncate",children:"Descendente"})]}),(Xe==null?void 0:Xe.key)===p.key&&Xe.dir==="desc"&&t.jsx(q.HiCheck,{className:"h-4 w-4 shrink-0 text-[var(--primary)]"})]})]}),t.jsxs("div",{className:"border-b border-[var(--border)] p-2",children:[t.jsxs("div",{className:"grid grid-cols-[minmax(0,1.05fr)_minmax(0,0.95fr)] gap-2",children:[t.jsx(ar,{value:(P==null?void 0:P.operator)??"",onChange:ve=>{if(!ve){ci(p.key);return}ma(p.key,{operator:ve,value:(P==null?void 0:P.value)??"",valueTo:(P==null?void 0:P.valueTo)??""})},options:Sc,placeholder:"Opcion",emptyLabel:"Sin condicion",ariaLabel:"Operador de filtro",searchable:!1,height:34,padding:"0 9px",dropdownMinWidth:260,className:"min-w-0 [&>button]:rounded-md [&>button]:text-sm [&>button]:font-medium"}),(ne==null?void 0:ne.valueMode)!=="none"?t.jsx("input",{value:(P==null?void 0:P.value)??"",onChange:ve=>{P&&ma(p.key,{...P,value:ve.target.value})},disabled:!P,placeholder:"Valor",className:"min-w-0 rounded-md border px-2 py-1.5 text-sm outline-none transition-colors placeholder:text-[var(--text-muted)] focus:border-[var(--primary)] disabled:opacity-50",style:{borderColor:"var(--border)",background:"var(--bg-input)",color:"var(--text-main)"}}):t.jsx("div",{className:"min-h-8 rounded-md border px-2 py-1.5 text-sm text-[var(--text-muted)]",style:{borderColor:"var(--border)",background:"var(--bg-input)"},children:"Automatico"})]}),(ne==null?void 0:ne.valueMode)==="between"&&t.jsx("input",{value:(P==null?void 0:P.valueTo)??"",onChange:ve=>{P&&ma(p.key,{...P,valueTo:ve.target.value})},placeholder:"Valor final",className:"mt-2 w-full rounded-md border px-2 py-1.5 text-xs outline-none transition-colors placeholder:text-[var(--text-muted)] focus:border-[var(--primary)]",style:{borderColor:"var(--border)",background:"var(--bg-input)",color:"var(--text-main)"}})]}),t.jsx("div",{className:"border-b border-[var(--border)] p-2",children:t.jsxs("div",{className:"flex items-center gap-1 rounded-md border px-2 py-1.5 text-sm",style:{borderColor:"var(--border)",background:"var(--bg-input)"},children:[t.jsx(q.HiMagnifyingGlass,{className:"h-4 w-4 shrink-0 text-[var(--text-muted)]"}),t.jsx("input",{value:Jt,onChange:ve=>oa(ve.target.value),placeholder:"Buscar",className:"min-w-0 flex-1 bg-transparent text-sm outline-none placeholder:text-[var(--text-muted)]",style:{color:"var(--text-main)"}})]})}),t.jsxs("div",{className:"overflow-auto py-1",style:{maxHeight:"max(96px, calc(var(--dt-column-menu-max-height, 520px) - 236px))"},children:[t.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":qe?"mixed":!!Pe,onClick:()=>{p&&(Pe&&!R?ii(p.key,[]):Eo(p.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)]",style:{color:"var(--text-main)"},children:[t.jsxs("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center rounded border",style:{borderColor:Pe||qe?"var(--primary)":"var(--border)",background:Pe||qe?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:[qe&&t.jsx(q.HiMinus,{className:"h-3 w-3"}),Pe&&!qe&&t.jsx(q.HiCheck,{className:"h-3 w-3"})]}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:"Seleccionar todo"})]}),Ce.map(ve=>{const Ee=!R||me.includes(ve.value);return t.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":Ee,onClick:()=>zb(p.key,ve.value,E.map(Ne=>Ne.value),R),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)]",style:{color:"var(--text-main)"},children:[t.jsx("span",{className:"flex h-4 w-4 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&&t.jsx(q.HiCheck,{className:"h-3 w-3"})}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:ve.label})]},ve.value)}),Ce.length===0&&t.jsx("div",{className:"px-3 py-3 text-sm text-[var(--text-muted)]",children:"Sin valores"})]})]}):null}),document.body)};o.useEffect(()=>{if(!mn)return;function p(E){ko.current&&!ko.current.contains(E.target)&&ca.current&&!ca.current.contains(E.target)&&ia(!1)}return document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[mn]);function Si(p,E){if(p.filterValue){const R=p.filterValue(E);return R==null||R===""?"":Cn(R)}return Cn(gr(p.cell(E)))}function Ci(p){return`"${Cn(p).replace(/"/g,'""')}"`}function ka(p){return Cn(p).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function Ei(){return Bt&&Ut>br.length&&Ma.toast.warning(`Exportando ${br.length.toLocaleString("es-MX")} de ${Ut.toLocaleString("es-MX")} (página actual). Usa exportación completa si está disponible.`),br}function om(){const p=wt.filter(Pe=>!or(Pe)),E=Ei(),R=p.map(Pe=>Ci(gr(Pe.header))).join(","),P=E.map(Pe=>p.map(qe=>Ci(Si(qe,Pe))).join(",")).join(`
5
+ `),ne=`${R}
6
+ ${P}`,me=new Blob(["\uFEFF"+ne],{type:"text/csv;charset=utf-8;"}),ke=URL.createObjectURL(me),Ce=document.createElement("a");Ce.href=ke,Ce.download=`${It}.csv`,document.body.appendChild(Ce),Ce.click(),document.body.removeChild(Ce),URL.revokeObjectURL(ke)}function sm(){const p=wt.filter(Ce=>!or(Ce)),E=Ei(),R=p.map(Ce=>ka(gr(Ce.header))),ne=E.map(Ce=>p.map(Pe=>ka(Si(Pe,Ce)))).map(Ce=>`<tr>${Ce.map(Pe=>`<td>${Pe}</td>`).join("")}</tr>`).join(""),me=`<!DOCTYPE html>
7
+ <html lang="es"><head><meta charset="utf-8"><title>${ka(It)}</title>
8
8
  <style>
9
9
  body{font-family:system-ui,sans-serif;font-size:11px;margin:20px;color:#111}
10
10
  h3{margin:0 0 4px;font-size:14px}
@@ -15,22 +15,24 @@ ${R}`,ne=new Blob(["\uFEFF"+O],{type:"text/csv;charset=utf-8;"}),fe=URL.createOb
15
15
  tr:nth-child(even) td{background:#f9f9f9}
16
16
  @media print{body{margin:0}@page{margin:1cm}}
17
17
  </style></head><body>
18
- <h3>${na(Le)}</h3>
19
- <p>${Jt.length} registros · ${new Date().toLocaleDateString("es")}</p>
20
- <table><thead><tr>${S.map(ve=>`<th>${ve}</th>`).join("")}</tr></thead>
21
- <tbody>${O}</tbody></table>
18
+ <h3>${ka(It)}</h3>
19
+ <p>${E.length} registros · ${new Date().toLocaleDateString("es")}</p>
20
+ <table><thead><tr>${R.map(Ce=>`<th>${Ce}</th>`).join("")}</tr></thead>
21
+ <tbody>${ne}</tbody></table>
22
22
  <script>window.onload=()=>{window.print()}<\/script>
23
- </body></html>`,fe=window.open("","_blank");fe&&(fe.document.write(ne),fe.document.close())}const aa=()=>!We||!tn?null:nt.createPortal(t.jsxs("div",{ref:Ja,role:"menu",className:"overflow-hidden rounded-lg border p-1 shadow-xl",style:{...If,position:"fixed",zIndex:9999,minWidth:170,borderColor:"var(--border)",background:"var(--bg-card)"},children:[t.jsxs("button",{type:"button",role:"menuitem",className:"flex w-full items-center gap-2.5 rounded-md px-2.5 py-1.5 text-sm transition-colors hover:bg-[var(--bg-input)]",style:{color:"var(--text-main)"},onClick:()=>{db(),Wn(!1)},children:[t.jsx(z.HiTableCells,{className:"h-4 w-4 shrink-0 text-emerald-500"}),"Descargar CSV / Excel"]}),t.jsxs("button",{type:"button",role:"menuitem",className:"flex w-full items-center gap-2.5 rounded-md px-2.5 py-1.5 text-sm transition-colors hover:bg-[var(--bg-input)]",style:{color:"var(--text-main)"},onClick:()=>{ub(),Wn(!1)},children:[t.jsx(z.HiDocumentText,{className:"h-4 w-4 shrink-0 text-red-500"}),"Imprimir / PDF"]})]}),document.body),sa=()=>{const p=K&&Mt.trim().length>0,S=pe!=null&&pe.length?pe:p?[{key:"bql",label:"BQL",value:Mt}]:[],R=ie.filter(O=>{const ne=O.trim();return ne?!new Set(Rr.split(`
24
- `).map(ve=>ve.trim()).filter(Boolean)).has(ne):!1}).slice(0,8);return!le&&es===0&&!K&&!We?null:t.jsxs("div",{className:"relative flex min-h-9 flex-wrap items-center justify-between gap-2 border-b rounded-t-lg px-2 py-1",style:{borderColor:"var(--border)",background:"var(--bg-input)"},children:[t.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[es>0&&t.jsxs("button",{type:"button",onClick:Yf,className:"inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs font-medium text-[var(--primary)] transition-colors hover:bg-[var(--bg-card)]",children:[t.jsx(z.HiXMark,{className:"h-3.5 w-3.5"}),es," filtros"]}),K&&t.jsxs("div",{ref:Za,className:"relative flex min-w-0 flex-1 items-center gap-2",children:[t.jsxs("button",{type:"button",onClick:()=>{if($t){Yt(!1);return}Zn(),Yt(!0)},className:"inline-flex h-7 shrink-0 items-center gap-1.5 rounded-md border px-2 text-xs font-bold transition-colors",style:{background:$t?"var(--primary)":p?"color-mix(in srgb, var(--primary) 12%, transparent)":"var(--bg-card)",borderColor:$t||p?"var(--primary)":"var(--border)",color:$t?"var(--primary-fg)":"var(--primary)"},"aria-expanded":$t,title:"Abrir filtros BQL",children:[t.jsx(z.HiCommandLine,{className:"h-3.5 w-3.5"}),"BQL",p&&t.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-current"}),$t?t.jsx(z.HiChevronUp,{className:"h-3.5 w-3.5"}):t.jsx(z.HiChevronDown,{className:"h-3.5 w-3.5"})]}),t.jsx("span",{className:"hidden truncate text-xs text-[var(--text-muted)] sm:inline",children:se}),S.length>0&&t.jsxs("div",{className:"hidden min-w-0 items-center gap-1.5 overflow-hidden lg:flex",children:[S.slice(0,3).map(O=>t.jsxs("span",{className:"inline-flex max-w-44 items-center gap-1 truncate rounded-full px-2 py-1 text-xs font-medium",style:{background:"var(--bg-hover)",border:"1px solid var(--primary)",color:"var(--primary)"},children:[t.jsxs("span",{className:"text-[var(--text-muted)]",children:[O.label,":"]}),t.jsx("span",{className:"truncate",children:O.value})]},O.key)),S.length>3&&t.jsxs("span",{className:"text-xs text-[var(--text-muted)]",children:["+",S.length-3]})]}),p&&t.jsx("button",{type:"button","aria-label":"Limpiar BQL",title:"Limpiar BQL",onClick:Al,className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-[var(--text-muted)] transition-colors hover:bg-[var(--bg-card)] hover:text-[var(--primary)]",children:t.jsx(z.HiXMark,{className:"h-4 w-4"})}),$t&&nt.createPortal(t.jsxs("div",{ref:vl,className:"flex flex-col gap-3 rounded-lg p-3 shadow-2xl",style:{...Tf,background:"var(--bg-card)",border:"1px solid color-mix(in srgb, var(--primary) 35%, var(--border))"},children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[de.map(O=>t.jsxs("button",{type:"button",onMouseDown:ne=>{ne.preventDefault(),ne.stopPropagation()},onClick:ne=>{ne.preventDefault(),ne.stopPropagation(),Gn(O.bql)},className:"inline-flex h-7 items-center gap-1.5 rounded-md border px-2.5 text-xs font-semibold transition-colors hover:border-[var(--primary)] hover:text-[var(--primary)]",style:{background:"var(--bg-input)",borderColor:"var(--border)",color:"var(--text-secondary)"},children:[O.icon,O.label]},O.label)),Se.length>0&&t.jsxs("button",{type:"button",onClick:()=>xr(O=>!O),className:"inline-flex h-7 items-center gap-1.5 rounded-md px-2 text-xs font-medium text-[var(--text-muted)] transition-colors hover:bg-[var(--bg-input)] hover:text-[var(--primary)]","aria-expanded":hl,children:[t.jsx(z.HiInformationCircle,{className:"h-3.5 w-3.5"}),"Ejemplos"]}),en.length>0&&t.jsxs("button",{type:"button",onClick:()=>wr(O=>!O),className:"inline-flex h-7 items-center gap-1.5 rounded-md px-2 text-xs font-medium text-[var(--text-muted)] transition-colors hover:bg-[var(--bg-input)] hover:text-[var(--primary)]","aria-expanded":gl,children:[t.jsx(z.HiClock,{className:"h-3.5 w-3.5"}),"Historial"]})]}),t.jsxs("div",{className:"overflow-hidden rounded-lg",style:{background:"var(--bg-input)",border:`1.5px solid ${Ce?"var(--danger)":p?"var(--primary)":"var(--border)"}`},children:[t.jsx("textarea",{ref:Qa,value:Rr,rows:3,onChange:O=>rs(O.target.value,O.target),onKeyDown:O=>{O.key==="Enter"&&!O.shiftKey&&(O.preventDefault(),Ll(Rr)),O.key==="Escape"&&Yt(!1)},placeholder:Q,autoComplete:"off",spellCheck:!1,className:"block w-full px-4 py-3 text-sm outline-none",style:{background:"var(--bg-input)",color:"var(--text-main)",border:"none",fontFamily:"'SF Mono', 'Fira Code', 'Consolas', monospace",lineHeight:1.6,maxHeight:180,minHeight:88,overflowY:"auto",resize:"vertical"}}),R.length>0&&t.jsx("div",{className:"border-t border-[var(--border)] bg-[var(--bg-card)]",children:R.map(O=>t.jsx("button",{type:"button",onMouseDown:ne=>{ne.preventDefault(),ne.stopPropagation()},onClick:ne=>{ne.preventDefault(),ne.stopPropagation(),Gn(O)},className:"block w-full px-4 py-2 text-left text-xs transition-colors hover:bg-[var(--bg-hover)] hover:text-[var(--primary)]",style:{fontFamily:"'SF Mono', 'Fira Code', 'Consolas', monospace"},children:O},O))})]}),t.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[t.jsx("span",{className:"min-w-0 text-xs",style:{color:Ce?"var(--danger)":"var(--text-muted)"},children:Ce??(p?`${S.length||1} filtro${(S.length||1)===1?"":"s"} activo${(S.length||1)===1?"":"s"}`:"Enter aplica la consulta. Shift + Enter agrega linea.")}),S.map(O=>t.jsxs("span",{className:"inline-flex max-w-56 items-center gap-1 truncate rounded-full px-2 py-1 text-xs font-medium",style:{background:"var(--bg-hover)",border:"1px solid var(--primary)",color:"var(--primary)"},children:[t.jsxs("span",{className:"text-[var(--text-muted)]",children:[O.label,":"]}),t.jsx("span",{className:"truncate",children:O.value})]},O.key))]}),gl&&en.length>0&&t.jsxs("div",{className:"overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-input)]",children:[t.jsxs("div",{className:"flex items-center justify-between border-b border-[var(--border)] px-3 py-2",children:[t.jsxs("span",{className:"flex items-center gap-1.5 text-xs font-semibold text-[var(--text-secondary)]",children:[t.jsx(z.HiClock,{className:"h-3.5 w-3.5"}),"Historial"]}),t.jsxs("button",{type:"button",onClick:()=>{kr([]),wr(!1)},className:"inline-flex items-center gap-1 rounded px-2 py-0.5 text-xs text-[var(--text-muted)]",children:[t.jsx(z.HiTrash,{className:"h-3 w-3"}),"Limpiar"]})]}),en.map(O=>t.jsxs("div",{className:"group flex items-center gap-2 border-b border-[var(--border)] px-3 py-2 last:border-b-0",children:[t.jsx("button",{type:"button",onMouseDown:ne=>{ne.preventDefault(),ne.stopPropagation()},onClick:ne=>{ne.preventDefault(),ne.stopPropagation(),Gn(O)},className:"min-w-0 flex-1 text-left",children:t.jsx("code",{className:"block truncate text-xs text-[var(--primary)]",children:O})}),t.jsx("button",{type:"button",onClick:()=>kr(ne=>ne.filter(fe=>fe!==O)),className:"rounded p-1 text-[var(--text-muted)] opacity-0 transition-opacity group-hover:opacity-100",children:t.jsx(z.HiXMark,{className:"h-3.5 w-3.5"})})]},O))]}),hl&&Se.length>0&&t.jsx("div",{className:"grid gap-2 sm:grid-cols-2 lg:grid-cols-3",children:Se.map(O=>t.jsxs("button",{type:"button",onMouseDown:ne=>{ne.preventDefault(),ne.stopPropagation()},onClick:ne=>{ne.preventDefault(),ne.stopPropagation(),Gn(O.bql),xr(!1)},className:"rounded-lg border border-[var(--border)] bg-[var(--bg-input)] p-2 text-left transition-colors hover:border-[var(--primary)]",children:[t.jsx("code",{className:"block truncate text-xs text-[var(--primary)]",children:O.bql}),O.description&&t.jsx("span",{className:"mt-1 block text-xs text-[var(--text-muted)]",children:O.description})]},O.bql))}),t.jsxs("div",{className:"flex items-center justify-end gap-2 border-t border-[var(--border)] pt-3",children:[p&&t.jsxs("button",{type:"button",onClick:Al,className:"inline-flex h-8 items-center gap-1 rounded-md px-2.5 text-xs font-medium text-[var(--text-muted)] transition-colors hover:bg-[var(--bg-input)] hover:text-[var(--primary)]",children:[t.jsx(z.HiXMark,{className:"h-3.5 w-3.5"}),"Limpiar"]}),t.jsxs("button",{type:"button",onClick:()=>Ll(Rr),className:"inline-flex h-8 items-center gap-1.5 rounded-md bg-[var(--primary)] px-4 text-xs font-semibold text-[var(--primary-fg)] transition-opacity hover:opacity-90",children:[t.jsx(z.HiCheck,{className:"h-3.5 w-3.5"}),"Aplicar"]})]})]}),document.body)]})]}),We&&t.jsx("button",{ref:qn,type:"button","aria-haspopup":"menu","aria-expanded":tn,"aria-label":"Exportar datos",title:"Exportar datos",onClick:()=>{var ne;const O=(ne=qn.current)==null?void 0:ne.getBoundingClientRect();O&&Of({top:O.bottom+4,right:window.innerWidth-O.right}),Wn(fe=>!fe)},className:`inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-[var(--text-muted)] transition-colors hover:bg-[var(--bg-card)] hover:text-[var(--primary)] focus:bg-[var(--bg-card)] focus:text-[var(--primary)] ${tn?"bg-[var(--bg-card)] text-[var(--primary)]":""}`,children:t.jsx(z.HiArrowDownTray,{className:"h-4 w-4"})}),le&&t.jsx("button",{type:"button","aria-haspopup":"menu","aria-expanded":Ge&&Qe==="visibility","aria-label":U,title:U,onClick:O=>Il(O,"visibility"),className:`inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-[var(--text-muted)] transition-colors hover:bg-[var(--bg-card)] hover:text-[var(--primary)] focus:bg-[var(--bg-card)] focus:text-[var(--primary)] ${Ge&&Qe==="visibility"?"bg-[var(--bg-card)] text-[var(--primary)]":""}`,children:t.jsx(z.HiCog6Tooth,{className:"h-4 w-4"})})]})},Yl=()=>{if(!sb)return null;const p=Ri(Re,cs);return t.jsxs("div",{"aria-busy":a,className:`grid grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)] items-center gap-2 rounded-b-xl border-t text-xs select-none ${L?"px-2 py-0.5":"px-3 py-1"}`,style:{borderColor:"var(--border)",background:"var(--bg-input)"},children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx("span",{style:{color:"var(--text-muted)"},children:Rt===0?"0 filas":`${ob}–${lb} de ${Rt}`}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("span",{style:{color:"var(--text-muted)"},children:"Filas:"}),t.jsx(jt,{value:String(Nt),onChange:S=>ib(Number(S)),options:Hl.map(S=>({value:String(S),label:String(S)})),placeholder:"Filas",searchable:!1,disabled:a,height:W,padding:G,className:"shrink-0 [&>button]:rounded-md [&>button]:text-xs [&_svg]:h-3.5 [&_svg]:w-3.5",style:{width:j}})]})]}),t.jsxs("div",{className:"flex items-center justify-center gap-0.5",children:[t.jsx("button",{disabled:a||Re<=1,onClick:()=>ds(Re-1),onMouseEnter:S=>{S.currentTarget.disabled||(S.currentTarget.style.background="color-mix(in srgb, var(--primary) 14%, var(--bg-card))",S.currentTarget.style.color="var(--primary)")},onMouseLeave:S=>{S.currentTarget.style.background="transparent",S.currentTarget.style.color="var(--text-muted)"},className:"cursor-pointer rounded p-0.5 transition-colors disabled:cursor-not-allowed disabled:opacity-30",style:{background:"transparent",color:"var(--text-muted)"},children:t.jsx(z.HiChevronLeft,{className:"h-3.5 w-3.5"})}),p.map((S,R)=>S==="..."?t.jsx("span",{className:"px-1",style:{color:"var(--text-muted)"},children:"…"},`e${R}`):t.jsx("button",{disabled:a,onClick:()=>ds(S),onMouseEnter:O=>{O.currentTarget.disabled||S===Re||(O.currentTarget.style.background="color-mix(in srgb, var(--primary) 14%, var(--bg-card))",O.currentTarget.style.color="var(--primary)")},onMouseLeave:O=>{O.currentTarget.style.background=S===Re?"var(--primary)":"transparent",O.currentTarget.style.color=S===Re?"var(--primary-fg)":"var(--text-muted)"},className:"h-5 w-5 cursor-pointer rounded text-[11px] font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-60",style:{background:S===Re?"var(--primary)":"transparent",color:S===Re?"var(--primary-fg)":"var(--text-muted)"},children:S},S)),t.jsx("button",{disabled:a||Re>=cs,onClick:()=>ds(Re+1),onMouseEnter:S=>{S.currentTarget.disabled||(S.currentTarget.style.background="color-mix(in srgb, var(--primary) 14%, var(--bg-card))",S.currentTarget.style.color="var(--primary)")},onMouseLeave:S=>{S.currentTarget.style.background="transparent",S.currentTarget.style.color="var(--text-muted)"},className:"cursor-pointer rounded p-0.5 transition-colors disabled:cursor-not-allowed disabled:opacity-30",style:{background:"transparent",color:"var(--text-muted)"},children:t.jsx(z.HiChevronRight,{className:"h-3.5 w-3.5"})})]}),t.jsx("div",{"aria-hidden":"true"})]})},fb=()=>t.jsxs("div",{className:"w-full min-w-0 max-w-full flex flex-col rounded-lg overflow-hidden",style:{background:"var(--bg-card)",boxShadow:Rn},children:[ra(),aa(),sa(),t.jsx("div",{ref:Bt,className:"min-w-0 max-w-full overflow-hidden",children:t.jsxs("div",{role:"table",className:"text-sm",style:{width:an,minWidth:ea},children:[t.jsx("div",{role:"rowgroup",style:N?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:ta()}),t.jsx("div",{role:"rowgroup",children:Array.from({length:Math.min(6,o)}).map((p,S)=>t.jsxs("div",{role:"row",className:"grid",style:{gridTemplateColumns:$r,borderBottom:`1px solid ${Oe}`},children:[pt&&t.jsx("div",{role:"cell",className:`${L?"px-2 py-1.5":"px-3 py-2"} w-10`,style:{borderBottom:`1px solid ${Oe}`,borderRight:`1px solid ${Oe}`}},"select-cell"),ut.map((R,O)=>t.jsx("div",{role:"cell",className:L?"px-2 py-1.5":"px-3 py-2",style:{borderBottom:`1px solid ${Oe}`,borderRight:`1px solid ${Oe}`},children:t.jsx("div",{className:"h-3.5 rounded-full animate-pulse",style:{background:"var(--border)",width:`${kl(S,O)}%`,minWidth:32}})},R.key))]},S))})]})})]}),fs="min-w-0 max-w-full overflow-hidden";return X&&et&&!he?t.jsx(cn,{rows:o,columns:Math.max(4,ut.length||7)}):!a&&r.length===0&&!Ra?fb():a&&r.length===0?t.jsxs("div",{className:"w-full min-w-0 max-w-full flex flex-col rounded-lg overflow-hidden",style:{background:"var(--bg-card)",boxShadow:Rn},children:[ra(),aa(),sa(),t.jsx("div",{ref:Bt,className:fs,children:t.jsx(ms.OverlayScrollbarsComponent,{options:{scrollbars:{autoHide:"leave",autoHideDelay:200}},className:"w-full",style:{maxHeight:Sl,maxWidth:"100%"},defer:!0,children:t.jsxs("div",{role:"table",className:"text-sm",style:{width:an,minWidth:ea},children:[t.jsx("div",{role:"rowgroup",style:N?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:ta()}),t.jsx("div",{role:"rowgroup",children:Array.from({length:o}).map((p,S)=>t.jsxs("div",{role:"row",className:"grid",style:{gridTemplateColumns:$r,borderBottom:`1px solid ${Oe}`},children:[pt&&t.jsx("div",{role:"cell",className:`${L?"px-2 py-1.5":"px-3 py-2"} w-10`,style:{borderBottom:`1px solid ${Oe}`,borderRight:`1px solid ${Oe}`}},"select-cell"),ut.map((R,O)=>{const ne=Qn[R.key],fe=ne!==void 0,ve=R.key===is;return t.jsx("div",{role:"cell","data-dt-column-key":R.key,className:L?"px-2 py-1.5":"px-3 py-2",style:fe?{position:"sticky",left:ne,zIndex:1,background:"color-mix(in srgb, var(--bg-card) 72%, transparent)",backdropFilter:"blur(10px)",WebkitBackdropFilter:"blur(10px)",boxShadow:ve?`3px 0 6px -2px rgba(0,0,0,0.10), inset 0 -1px 0 ${Oe}`:`inset 0 -1px 0 ${Oe}`,borderRight:`1px solid ${Oe}`}:{borderBottom:`1px solid ${Oe}`,borderRight:`1px solid ${Oe}`},children:t.jsx("div",{className:"h-3.5 rounded-full animate-pulse",style:{background:"var(--border)",width:`${kl(S,O)}%`,minWidth:32}})},R.key)})]},S))})]})})}),Yl()]}):!a&&r.length===0?t.jsxs("div",{className:"w-full min-w-0 max-w-full flex flex-col rounded-lg overflow-hidden",style:{background:"var(--bg-card)",boxShadow:Rn},children:[ra(),aa(),sa(),t.jsx("div",{ref:Bt,className:fs,children:t.jsx("div",{role:"table",className:"text-sm",style:{width:an,minWidth:ea},children:t.jsx("div",{role:"rowgroup",style:N?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:ta()})})}),t.jsxs("div",{className:"flex min-h-[180px] flex-col items-center justify-center gap-3 border-t px-6 py-12 text-center",style:{borderColor:Oe,background:"linear-gradient(180deg, color-mix(in srgb, var(--bg-input) 58%, transparent), var(--bg-card))"},children:[t.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:l??t.jsx(z.HiMagnifyingGlass,{className:"h-5 w-5"})}),t.jsx("p",{className:"max-w-sm text-sm font-medium",style:{color:"var(--text-main)"},children:i}),t.jsx("span",{className:"text-xs",style:{color:"var(--text-muted)"},children:"Ajusta la busqueda o cambia los filtros para ver mas informacion."})]})]}):t.jsxs("div",{className:"w-full min-w-0 max-w-full flex flex-col rounded-lg overflow-hidden",style:{background:"var(--bg-card)",boxShadow:Rn},children:[ra(),aa(),sa(),t.jsx("div",{ref:Bt,className:fs,children:t.jsx(ms.OverlayScrollbarsComponent,{options:{scrollbars:{autoHide:"leave",autoHideDelay:200}},className:"w-full",style:{maxHeight:Sl,maxWidth:"100%"},defer:!0,children:t.jsxs("div",{role:"table",className:"text-sm",style:{width:an,minWidth:ea},children:[t.jsx("div",{role:"rowgroup",style:N?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:ta()}),t.jsx("div",{role:"rowgroup",children:Pl.map((p,S)=>{const R=n(p),O=ql(k==null?void 0:k(p)),ne=S>0?ql(k==null?void 0:k(Pl[S-1])):null,fe=O&&O.key!==(ne==null?void 0:ne.key),ve=pt&&E.has(R),$e=pt&&(!M||M(p)),Ke=Mr?(m==null?void 0:m(p))??!0:!1,Ue=Ke&&Bl.has(R),rt=!!d||x&&Ke,Xe=ve&&y?"color-mix(in srgb, var(--primary) 8%, var(--bg-card))":S%2===1?"color-mix(in srgb, var(--bg-input) 30%, var(--bg-card))":"var(--bg-card)";return t.jsxs(s.Fragment,{children:[fe&&t.jsx("div",{role:"row",className:`grid ${O.className??""}`,style:{gridTemplateColumns:$r},children:t.jsx("div",{role:"cell",className:L?"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 ${Oe}`,borderRight:`1px solid ${Oe}`},children:t.jsx("div",{className:"flex min-w-0 items-center justify-between gap-3",children:t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"truncate text-xs font-semibold uppercase tracking-wider text-[var(--text-main)]",children:O.label}),O.description&&t.jsx("div",{className:"mt-0.5 truncate text-xs text-[var(--text-muted)]",children:O.description})]})})})}),t.jsxs("div",{role:"row",onClick:rt?ge=>{const Me=ge.target;if(!(Me!=null&&Me.closest('[data-dt-disable-row-click="true"]'))){if(x&&Ke){_l(R);return}d==null||d(p)}}:void 0,className:`grid transition-colors ${rt?"cursor-pointer":""} ${w?w(p):""}`,style:{gridTemplateColumns:$r,"--dt-row-bg":Xe,"--dt-sticky-bg":Xe,background:"var(--dt-row-bg)",borderBottom:`1px solid ${Oe}`},onMouseEnter:ge=>{ve||(ge.currentTarget.style.setProperty("--dt-row-bg","var(--bg-hover)"),ge.currentTarget.style.setProperty("--dt-sticky-bg",cb))},onMouseLeave:ge=>{ge.currentTarget.style.setProperty("--dt-row-bg",Xe),ge.currentTarget.style.setProperty("--dt-sticky-bg",Xe)},children:[Mr&&t.jsx("div",{role:"cell",className:`${L?"px-2 py-1.5":"px-3 py-2"} flex w-10 items-center justify-center`,style:{borderBottom:`1px solid ${Oe}`,borderRight:`1px solid ${Oe}`},"data-dt-disable-row-click":"true",children:Ke&&t.jsx("button",{type:"button","aria-label":Ue?"Contraer fila":"Desplegar fila","aria-expanded":Ue,onClick:ge=>{ge.stopPropagation(),_l(R)},className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-[var(--text-muted)] transition-colors hover:bg-[var(--bg-input)] hover:text-[var(--primary)]",children:Ue?t.jsx(z.HiChevronDown,{className:"h-4 w-4"}):t.jsx(z.HiChevronRight,{className:"h-4 w-4"})})}),pt&&t.jsx("div",{role:"cell",className:`${L?"px-2 py-1.5":"px-3 py-2"} flex w-10 items-center justify-center`,style:os?{position:"sticky",left:0,zIndex:3,background:"var(--dt-sticky-bg)",boxShadow:`inset 0 -1px 0 ${Oe}`}:{borderBottom:`1px solid ${Oe}`,borderRight:`1px solid ${Oe}`},onClick:ge=>{ge.stopPropagation(),$e&&h(R)},children:t.jsx(dn,{size:"sm",checked:ve,disabled:!$e,"aria-label":$e?"Seleccionar fila":"Fila no seleccionable",containerClassName:"items-center",className:$e?"cursor-pointer":"cursor-not-allowed opacity-50",onClick:ge=>ge.stopPropagation(),onChange:()=>{$e&&h(R)}})}),ut.map(ge=>{const Me=Qn[ge.key],we=Me!==void 0,ye=ge.key===is,xe=Wt(ge);return t.jsx("div",{role:"cell","data-dt-column-key":ge.key,"data-dt-disable-row-click":ge.disableRowClick||xe?"true":void 0,className:`${xe?"px-2 py-1.5 justify-center text-center":`${L?"px-2 py-1.5":"px-3 py-2"} ${zl(ge.align)}`} flex min-w-0 items-center ${Xi} ${ge.className??""}`,style:{overflow:"hidden",whiteSpace:"nowrap",...we?{position:"sticky",left:Me,zIndex:3,background:"var(--dt-sticky-bg)",boxShadow:ye?`3px 0 6px -2px rgba(0,0,0,0.10), inset 0 -1px 0 ${Oe}`:`inset 0 -1px 0 ${Oe}`,borderRight:`1px solid ${Oe}`}:{borderBottom:`1px solid ${Oe}`,borderRight:`1px solid ${Oe}`}},children:t.jsx(Os,{children:t.jsx("div",{"data-dt-autofit-content":!0,className:"inline-block max-w-none align-middle",children:ge.cell(p)})})},ge.key)})]}),Ue&&u&&t.jsx("div",{role:"row",className:"grid",style:{gridTemplateColumns:$r},children:t.jsx("div",{role:"cell",className:L?"px-2 py-2":"px-3 py-3",style:{gridColumn:"1 / -1",background:"color-mix(in srgb, var(--bg-input) 60%, var(--bg-card))",borderBottom:`1px solid ${Oe}`},children:u(p)})})]},R)})})]})})}),Yl()]})}const rc={email:{pattern:/^[^\s@]+@[^\s@]+\.[^\s@]+$/,message:"Correo inválido"},integer:{pattern:/^-?\d+$/,message:"Debe ser un número entero"},date:{pattern:/^\d{4}-\d{2}-\d{2}$/,message:"Fecha inválida"}};function nc(e,r){if(r.minLength!==void 0&&e.length<r.minLength)return r.message??`Mínimo ${r.minLength} caracteres`;if(r.maxLength!==void 0&&e.length>r.maxLength)return r.message??`Máximo ${r.maxLength} caracteres`;if(!e)return null;if(r.preset){const n=rc[r.preset];if(!n.pattern.test(e))return r.message??n.message}return r.pattern&&!r.pattern.test(e)?r.message??"Formato inválido":null}const ac=new Set(["Backspace","Delete","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Tab","Home","End","Enter","Escape"]);function sc({initialValue:e,type:r,mask:n,onCommit:a,onCancel:o}){const[l,i]=s.useState(e),c=s.useRef(null),d=(n==null?void 0:n.preset)==="date",u=d?"date":r==="number"?"number":"text";return s.useEffect(()=>{var m,f;(m=c.current)==null||m.focus(),d||(f=c.current)==null||f.select()},[d]),t.jsx("input",{ref:c,type:u,value:l,maxLength:n==null?void 0:n.maxLength,onChange:m=>i(m.target.value),onBlur:()=>o(),onKeyDown:m=>{m.key==="Enter"&&(m.preventDefault(),a(l)),m.key==="Escape"&&(m.preventDefault(),o()),(n==null?void 0:n.preset)==="integer"&&!m.ctrlKey&&!m.metaKey&&!ac.has(m.key)&&!/^[\d-]$/.test(m.key)&&m.preventDefault()},onClick:m=>m.stopPropagation(),className:"w-full min-w-0 border-0 bg-transparent p-0 text-sm text-[var(--text-main)] outline-none"})}function oc({initialValue:e,options:r,loading:n,onCommit:a,onCancel:o}){const l=s.useRef(null);return s.useEffect(()=>{if(n)return;const i=setTimeout(()=>{var c,d;(d=(c=l.current)==null?void 0:c.querySelector("button"))==null||d.click()},0);return()=>clearTimeout(i)},[n]),t.jsx("div",{ref:l,className:"w-full",tabIndex:-1,onKeyDown:i=>{i.key==="Escape"&&(i.stopPropagation(),o())},children:t.jsx(jt,{value:e,onChange:i=>{a(i)},options:r,disabled:n,placeholder:n?"Cargando…":"Seleccionar…",triggerVariant:"ghost",height:30,padding:"0 6px",minOptionsForSearch:1,className:"w-full"})})}const lc={outline:"2px solid var(--primary)",outlineOffset:"-2px",borderRadius:"4px",background:"color-mix(in srgb, var(--primary) 5%, var(--bg-card))"},ga={outline:"2px solid var(--primary)",outlineOffset:"-2px",borderRadius:"4px"};function ic({columns:e,data:r,getRowId:n,onCellUpdate:a,readOnly:o=!1,...l}){const[i,c]=s.useState(r),d=s.useRef(null);s.useEffect(()=>{d.current||c(r)},[r]);const[u,m]=s.useState(null);d.current=u;const[f,b]=s.useState(null),v=s.useRef(null);v.current=f;const[x,E]=s.useState({}),[h,$]=s.useState(null),M=s.useRef(null);M.current=h;const[y,w]=s.useState({}),[k,N]=s.useState({}),A=s.useRef(new Set),C=s.useRef(null);s.useEffect(()=>{var F;const B=document.activeElement;(!B||B===document.body)&&((F=C.current)==null||F.focus({preventScroll:!0}))},[]);const j=e.map(B=>{var F,le,g;return`${B.key}:${((g=(le=(F=B.editable)==null?void 0:F.select)==null?void 0:le.options)==null?void 0:g.length)??-1}`}).join("|");s.useEffect(()=>{e.forEach(B=>{var g,P;const F=(P=(g=B.editable)==null?void 0:g.select)==null?void 0:P.options;if(!F)return;const le=y[B.key];(!A.current.has(B.key)||(le==null?void 0:le.length)===0&&F.length>0)&&(A.current.add(B.key),w(I=>({...I,[B.key]:F})))})},[j]);const W=s.useCallback(async(B,F)=>{if(A.current.has(B))return;A.current.add(B);const{url:le,fetchOptions:g}=F.select??{};if(!(!le&&!g)){N(P=>({...P,[B]:!0}));try{let P=[];if(g)P=await g();else if(le){const I=await fetch(le);if(!I.ok)throw new Error("fetch failed");P=await I.json()}w(I=>({...I,[B]:P}))}catch{w(P=>({...P,[B]:[]}))}finally{N(P=>({...P,[B]:!1}))}}},[]),G=s.useRef(i);G.current=i;const T=s.useRef(a);T.current=a;const Z=s.useRef(n);Z.current=n;const H=s.useRef(e);H.current=e;const ae=s.useRef(o);ae.current=o,s.useEffect(()=>{if(e.length>0&&r.length>0){const B=e.find(F=>F.selectable!==!1);B&&b({rowId:n(r[0]),colKey:B.key})}},[]),s.useEffect(()=>{if(!f)return;const B=C.current;if(!B)return;const F=B.querySelector(`[data-cell-id="${f.rowId}:${f.colKey}"]`);if(!F)return;const le=B.querySelector('[role="rowgroup"]');F.style.scrollMarginTop=`${(le==null?void 0:le.offsetHeight)??0}px`;const g=B.querySelector('[role="row"]');let P=0;g&&g.querySelectorAll('[role="cell"], [role="columnheader"]').forEach(I=>{I.style.position==="sticky"&&I.style.left!==""&&(P=Math.max(P,parseFloat(I.style.left)+I.offsetWidth))}),F.style.scrollMarginLeft=`${P}px`,F.scrollIntoView({block:"nearest",inline:"nearest"})},[f]);const X=s.useCallback(B=>{var P;const F=H.current,le=new Set,g=[];(P=C.current)==null||P.querySelectorAll("[data-cell-id]").forEach(I=>{const te=I.dataset.cellId.split(":")[0];le.has(te)||(le.add(te),g.push(te))}),b(I=>{if(!I)return I;const te=F.findIndex(ee=>ee.key===I.colKey),U=g.indexOf(I.rowId);let K=te,D=U;if(B==="up")D=Math.max(0,U-1);else if(B==="down")D=Math.min(g.length-1,U+1);else if(B==="left"){let ee=te-1;for(;ee>=0&&F[ee].selectable===!1;)ee--;ee>=0&&(K=ee)}else if(B==="right"){let ee=te+1;for(;ee<F.length&&F[ee].selectable===!1;)ee++;ee<F.length&&(K=ee)}return K===te&&D===U?I:{rowId:g[D],colKey:F[K].key}})},[]),V=s.useCallback((B=!0)=>{const F=d.current;m(null),F&&b(F),B&&setTimeout(()=>{var le;return(le=C.current)==null?void 0:le.focus({preventScroll:!0})},0)},[]),q=s.useCallback(async(B,F,le)=>{var ie;const g=H.current.find(pe=>pe.key===F);if(!(g!=null&&g.editable))return;const{field:P,type:I,mask:te,validate:U}=g.editable,K=I==="number"?le===""?null:Number(le):le;if(te){const pe=nc(le,te);if(pe){E(Ce=>({...Ce,[`${B}:${F}`]:pe}));return}}if(U){const pe=U(K);if(pe){E(Ce=>({...Ce,[`${B}:${F}`]:pe}));return}}const D=Z.current,ee=G.current.find(pe=>D(pe)===B);if(!ee)return;const _=ee[P];m(null),E(pe=>{const Ce={...pe};return delete Ce[`${B}:${F}`],Ce});const se=G.current,Q=se.findIndex(pe=>D(pe)===B),de=se[Math.min(se.length-1,Q+1)];if(b({rowId:D(de),colKey:F}),setTimeout(()=>{var Ce,De;const pe=document.activeElement;(!pe||pe===document.body||(Ce=C.current)!=null&&Ce.contains(pe))&&((De=C.current)==null||De.focus({preventScroll:!0}))},0),String(_??"")===String(K??""))return;const Se={...ee,[P]:K};c(pe=>pe.map(Ce=>D(Ce)===B?Se:Ce)),$({rowId:B,colKey:F});try{await((ie=T.current)==null?void 0:ie.call(T,{row:ee,rowId:B,field:P,oldValue:_,newValue:K}))}catch{c(pe=>pe.map(Ce=>D(Ce)===B?ee:Ce)),E(pe=>({...pe,[`${B}:${F}`]:"Error al guardar. Intenta de nuevo."}))}finally{$(null)}},[]),L=s.useCallback(B=>{if(M.current){B.preventDefault();return}if(d.current)return;const F=v.current;if(!(!F||!["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Enter","Escape","Tab"].includes(B.key)))switch(B.preventDefault(),B.key){case"ArrowUp":X("up");break;case"ArrowDown":X("down");break;case"ArrowLeft":X("left");break;case"ArrowRight":X("right");break;case"Tab":X(B.shiftKey?"left":"right");break;case"Enter":{const g=H.current.find(P=>P.key===F.colKey);g!=null&&g.editable&&!ae.current?(m(F),g.editable.type==="select"&&!A.current.has(F.colKey)&&W(F.colKey,g.editable)):X("down");break}}},[X,W]),oe=s.useMemo(()=>e.map(B=>{if(!B.editable||o){const le={...B};if(delete le.editable,delete le.selectable,B.selectable===!1)return{...le,disableRowClick:!0};const g=le.cell;return{...le,className:`relative ${le.className??""}`.trim(),disableRowClick:!0,cell:P=>{const I=n(P),te=(f==null?void 0:f.rowId)===I&&(f==null?void 0:f.colKey)===B.key;return t.jsxs(t.Fragment,{children:[t.jsx("span",{"data-cell-id":`${I}:${B.key}`,className:"absolute inset-0 z-10 cursor-default",onClick:()=>{var U;M.current||(b({rowId:I,colKey:B.key}),(U=C.current)==null||U.focus({preventScroll:!0}))}}),te&&t.jsx("div",{className:"pointer-events-none absolute inset-0 z-20",style:ga}),t.jsx("span",{className:"relative z-0 pointer-events-none",children:g(P)})]})}}}const F=B.editable;return{...B,className:`relative ${B.className??""}`.trim(),disableRowClick:!0,cell:le=>{const g=n(le),P=B.key,I=(u==null?void 0:u.rowId)===g&&(u==null?void 0:u.colKey)===P,te=(f==null?void 0:f.rowId)===g&&(f==null?void 0:f.colKey)===P,U=x[`${g}:${P}`],K=(h==null?void 0:h.rowId)===g&&(h==null?void 0:h.colKey)===P,D=le[F.field],ee=String(D??""),_=()=>{var Q;M.current||(b({rowId:g,colKey:P}),m({rowId:g,colKey:P}),(Q=C.current)==null||Q.focus({preventScroll:!0}),F.type==="select"&&!A.current.has(P)&&W(P,F))};if(I){const Q=F.type==="select"?t.jsx(oc,{initialValue:ee,options:y[P]??[],loading:k[P]??!1,onCommit:de=>q(g,P,de),onCancel:V}):t.jsx(sc,{initialValue:ee,type:F.type??"text",mask:F.mask,onCommit:de=>q(g,P,de),onCancel:V});return t.jsx("div",{className:"absolute inset-0 flex items-center px-2",style:lc,onClick:de=>de.stopPropagation(),children:Q})}const se=B.cell(le);return t.jsxs(t.Fragment,{children:[t.jsx("span",{"data-cell-id":`${g}:${P}`,className:`peer absolute inset-0 z-10 ${K?"cursor-wait":"cursor-pointer"}`,onClick:_}),te&&!K&&t.jsx("div",{className:"pointer-events-none absolute inset-0 z-20",style:ga}),K&&t.jsxs("div",{className:"pointer-events-none absolute inset-0 z-20 flex items-center gap-1.5 bg-[var(--bg-card)]/80 px-2",style:ga,children:[t.jsx("span",{className:"h-3 w-3 shrink-0 animate-spin rounded-full border-2 border-[var(--text-muted)] border-t-transparent","aria-hidden":!0}),t.jsx("span",{className:"truncate text-xs text-[var(--text-muted)]",children:"Guardando…"})]}),t.jsx("span",{className:"relative z-0 inline-flex items-center gap-1 pointer-events-none",children:U?t.jsxs("span",{className:"flex items-center gap-1 text-red-500",children:[t.jsx(z.HiExclamationCircle,{className:"h-3.5 w-3.5 shrink-0"}),t.jsx("span",{className:"truncate text-xs",children:U})]}):t.jsx("span",{className:"truncate",children:se})}),!K&&t.jsx(z.HiPencil,{className:"pointer-events-none absolute right-1 top-1/2 z-0 h-3 w-3 -translate-y-1/2 shrink-0 text-[var(--text-muted)] opacity-0 transition-opacity peer-hover:opacity-40"})]})}}}),[e,o,u,f,h,x,y,k,n,q,V,W]);return t.jsx("div",{ref:C,tabIndex:0,onKeyDown:L,onBlur:B=>{var F;(F=C.current)!=null&&F.contains(B.relatedTarget)||setTimeout(()=>{var g,P;const le=document.activeElement;le&&((g=le.closest)!=null&&g.call(le,"[data-bonsaif-select-dropdown]"))||(P=C.current)!=null&&P.contains(le)||V(!1)},0)},style:{width:"100%",minWidth:0,outline:"none"},children:t.jsx(Hs,{...l,columns:oe,data:i,getRowId:n})})}function Je(e){if(e)return new Date(`${e}T12:00:00`)}function ht(e){const r=e.getFullYear(),n=String(e.getMonth()+1).padStart(2,"0"),a=String(e.getDate()).padStart(2,"0");return`${r}-${n}-${a}`}function sr(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Bs(e){return e.map(r=>Je(r)).filter(r=>!!r)}function cc(e){if(!(e!=null&&e.length))return[];const r=new Set(e.map(ht));return Array.from(r).sort()}function va(e){return new Intl.DateTimeFormat("es-MX",{weekday:"short"}).format(e)}function Fs(e){const r=Je(e);if(!r)return e;const n=va(r).replace(/\.$/u,"").replace(/^\w/u,o=>o.toUpperCase()),a=new Intl.DateTimeFormat("es-MX",{month:"short"}).format(r).replace(/\.$/u,"").toLowerCase();return`${n} - ${r.getDate()} ${a} ${r.getFullYear()}`}const ya={weekend:{dayOfWeek:[0,6]}},xa={weekend:"bonsaif-weekend"};function wa({children:e,className:r="",...n}){const a=String(e??"").toLowerCase().normalize("NFD").replace(new RegExp("\\p{M}","gu"),"").trim(),o=a.startsWith("sab")||a.startsWith("dom")||a==="s"||a==="d";return t.jsx("th",{...n,className:`${r} ${o?"bonsaif-weekday-weekend":""}`.trim(),children:e})}const dc={background:"var(--primary)",color:"var(--primary-fg, #ffffff)",borderRadius:999},uc={background:"color-mix(in srgb, var(--primary) 22%, transparent)",color:"var(--text-main)",borderRadius:999};function fc({day:e,modifiers:r,...n}){const a=r.range_start||r.range_end||r.selected&&!r.range_middle,o=!!r.range_middle,l=!!r.weekend||e.date.getDay()===0||e.date.getDay()===6;return t.jsx("button",{...n,type:"button",className:`bonsaif-multi-day-btn${a?" is-range-edge":""}${o?" is-range-middle":""}${l?" bonsaif-day-weekend":""} ${n.className??""}`,style:{...a?dc:null,...o?uc:null,...l?{fontWeight:800}:null,...n.style}})}function bc({startDate:e,endDate:r,onChange:n,minDate:a,viewMonth:o,numberOfMonths:l=1,orientation:i="horizontal",showSummary:c=!0,startLabel:d="Inicio",endLabel:u="Regreso",className:m=""}){const f={from:Je(e),to:Je(r)},b=Je(a),[v,x]=s.useState(()=>Je(o||e)??new Date);s.useEffect(()=>{const y=Je(o||e);y&&x(y)},[o,e]);const E=s.useMemo(()=>{if(l<=1)return sr(new Intl.DateTimeFormat("es-MX",{month:"long",year:"numeric"}).format(v));const y=new Date(v.getFullYear(),v.getMonth()+l-1,1),w=v.getFullYear()===y.getFullYear(),k=new Intl.DateTimeFormat("es-MX",{month:"short",...w?{}:{year:"numeric"}}).format(v),N=new Intl.DateTimeFormat("es-MX",{month:"short",year:"numeric"}).format(y);return`${sr(k)} – ${sr(N)}`},[v,l]);function h(){x(new Date(v.getFullYear(),v.getMonth()-1,1))}function $(){x(new Date(v.getFullYear(),v.getMonth()+1,1))}const M=l>1?`bonsaif-range-months bonsaif-range-months--multi bonsaif-range-months--${i}`:"bonsaif-range-months";return t.jsxs("div",{className:`bonsaif-calendar bonsaif-date-range-picker ${m}`.trim(),children:[t.jsxs("div",{className:"bonsaif-cal-shell",children:[t.jsxs("div",{className:"bonsaif-cal-toolbar",children:[t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn","aria-label":"Mes anterior",onClick:h,children:t.jsx(z.HiChevronLeft,{size:16})}),t.jsx("span",{className:"bonsaif-cal-title",children:E}),t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn","aria-label":"Mes siguiente",onClick:$,children:t.jsx(z.HiChevronRight,{size:16})})]}),t.jsx(la.DayPicker,{mode:"range",selected:f,month:v,onMonthChange:x,onSelect:y=>{const w=y!=null&&y.from?ht(y.from):e,k=y!=null&&y.to?ht(y.to):"";n({startDate:w,endDate:k})},numberOfMonths:l,hideNavigation:!0,weekStartsOn:1,disabled:b?{before:b}:void 0,showOutsideDays:!1,modifiers:ya,modifiersClassNames:xa,components:{DayButton:fc,Weekday:wa},classNames:{root:"bonsaif-range-daypicker w-full",months:M,month:l>1?"bonsaif-multi-month bonsaif-range-month-card":"bonsaif-multi-month",month_caption:l>1?"bonsaif-range-month-caption":"bonsaif-multi-caption-hidden",month_grid:"bonsaif-multi-month-grid",weekdays:"bonsaif-multi-weekdays",weekday:"bonsaif-multi-weekday",week:"bonsaif-multi-week",day:"bonsaif-multi-day",day_button:"bonsaif-multi-day-btn",selected:"bonsaif-range-day-selected",range_start:"bonsaif-range-start",range_middle:"bonsaif-range-middle",range_end:"bonsaif-range-end",today:"bonsaif-multi-day-today",disabled:"bonsaif-multi-day-disabled",hidden:"bonsaif-multi-day-hidden"},formatters:{formatCaption:y=>`${sr(new Intl.DateTimeFormat("es-MX",{month:"long"}).format(y))} ${y.getFullYear()}`,formatWeekdayName:va}})]}),c?t.jsx("div",{className:"bonsaif-cal-summary",children:e?t.jsxs("div",{className:"bonsaif-cal-chips",children:[t.jsxs("span",{className:"bonsaif-cal-chip bonsaif-cal-chip--static",children:[d,": ",e]}),r?t.jsxs("span",{className:"bonsaif-cal-chip bonsaif-cal-chip--static",children:[u,": ",r]}):null]}):t.jsx("span",{children:"Sin rango seleccionado"})}):null]})}function Ps({day:e,modifiers:r,onDayPointerDown:n,onDayPointerEnter:a,onDayClickSelect:o,...l}){const i=!!(r.disabled||r.hidden),c=!!r.weekend||e.date.getDay()===0||e.date.getDay()===6;return t.jsx("button",{...l,type:"button",disabled:i||l.disabled,className:`${l.className??""}${c?" bonsaif-day-weekend":""}`,style:{...c?{fontWeight:800}:null,...l.style},onPointerDown:d=>{var u;i||(n==null||n(e.date,d),(u=l.onPointerDown)==null||u.call(l,d))},onPointerEnter:()=>{i||a==null||a(e.date)},onClick:d=>{i||(d.preventDefault(),d.stopPropagation(),o==null||o(e.date,d))}})}function _s(e,r){const n=Je(e),a=Je(r);if(!n||!a)return[];const o=n<=a?n:a,l=n<=a?a:n,i=[],c=new Date(o);for(;c<=l;)i.push(ht(c)),c.setDate(c.getDate()+1);return i}function zs(e,r=1){const n=e.getDay(),a=r===1?(n+6)%7:n,o=new Date(e);return o.setHours(12,0,0,0),o.setDate(o.getDate()-a),Array.from({length:7},(l,i)=>{const c=new Date(o);return c.setDate(o.getDate()+i),c})}function _r(e,r,n){const a=new Set(e);for(const o of r)n==="add"?a.add(o):n==="remove"||a.has(o)?a.delete(o):a.add(o);return Array.from(a).sort()}function mc(e,r){return typeof r!="number"||r<=0||e.length<=r?e:e.slice(-r)}function gn(e,r,n){return!!(r&&e<r||n&&e>n)}function js({value:e,onChange:r,disabled:n=!1,minDate:a,maxDate:o,maxDates:l,retainOutsidePrefix:i}){const c=s.useRef(null),d=s.useRef(null),u=s.useRef(!1),m=s.useRef(e);m.current=e;const f=s.useCallback(y=>{let w=y;if(i){const k=m.current.filter(A=>!A.startsWith(i)),N=y.filter(A=>A.startsWith(i));w=[...k,...N].sort()}r==null||r(mc(w,l))},[l,r,i]),b=s.useCallback(y=>y.filter(w=>!gn(w,a,o)),[a,o]),v=s.useCallback(()=>{d.current=null},[]);s.useEffect(()=>{const y=()=>v();return window.addEventListener("pointerup",y),window.addEventListener("pointercancel",y),()=>{window.removeEventListener("pointerup",y),window.removeEventListener("pointercancel",y)}},[v]);const x=s.useCallback((y,w,k,N)=>{const A=b(_s(y,w));f(k==="add"?_r(N,A,"add"):_r(N,A,"remove"))},[f,b]),E=s.useCallback((y,w)=>{if(n||w.button!==0)return;const k=ht(y);if(gn(k,a,o)||w.shiftKey)return;u.current=!0;const N=[...m.current],A=N.includes(k)?"remove":"add";d.current={active:!0,mode:A,anchor:k,latest:k,baseline:N},c.current=k,x(k,k,A,N),w.preventDefault()},[x,n,o,a]),h=s.useCallback(y=>{const w=d.current;if(!(w!=null&&w.active)||n)return;const k=ht(y);gn(k,a,o)||w.latest!==k&&(w.latest=k,x(w.anchor,k,w.mode,w.baseline))},[x,n,o,a]),$=s.useCallback((y,w)=>{if(n)return;const k=ht(y);if(!gn(k,a,o)){if(u.current&&!w.shiftKey){u.current=!1,w.preventDefault(),w.stopPropagation();return}if(u.current=!1,w.shiftKey&&c.current){w.preventDefault(),w.stopPropagation();const N=b(_s(c.current,k));f(_r(m.current,N,"add"));return}c.current=k,f(_r(m.current,[k],"toggle"))}},[f,n,b,o,a]),M=s.useCallback(y=>{if(n)return;const w=b(cc(y));if(!w.length)return;const k=w.every(N=>m.current.includes(N));f(_r(m.current,w,k?"remove":"add")),c.current=w[0]??c.current},[f,n,b]);return{onDayPointerDown:E,onDayPointerEnter:h,onDayClick:$,toggleWeek:M,endDrag:v}}function zr(e){return zs(e,1)[0]}function Ws(e,r){const n=new Date(e);return n.setDate(n.getDate()+r),n}function pc({value:e=[],onChange:r,minDate:n,maxDate:a,viewMonth:o,maxDates:l,showWeekNumbers:i=!1,viewMode:c,defaultViewMode:d="month",onViewModeChange:u,showSummary:m=!0,className:f="",disabled:b=!1}){const v=s.useMemo(()=>Bs(e),[e]),x=s.useMemo(()=>new Set(e),[e]),E=Je(n),h=Je(a),[$,M]=s.useState(()=>Je(o||e[0])??new Date),[y,w]=s.useState(()=>zr(Je(o||e[0])??new Date)),[k,N]=s.useState(d),A=c??k;function C(L){c===void 0&&N(L),u==null||u(L)}s.useEffect(()=>{const L=Je(o);L&&(M(L),w(zr(L)))},[o]);const{onDayPointerDown:j,onDayPointerEnter:W,onDayClick:G,toggleWeek:T}=js({value:e,onChange:r,disabled:b,minDate:n,maxDate:a,maxDates:l}),Z=s.useCallback(L=>t.jsx(Ps,{...L,className:`bonsaif-multi-day-btn ${L.className??""}`,onDayPointerDown:j,onDayPointerEnter:W,onDayClickSelect:G}),[G,j,W]),H=s.useMemo(()=>zs(y,1),[y]),ae=H[6],X=A==="week"?`${new Intl.DateTimeFormat("es-MX",{day:"numeric",month:"short"}).format(H[0])} – ${new Intl.DateTimeFormat("es-MX",{day:"numeric",month:"short",year:"numeric"}).format(ae)}`:sr(new Intl.DateTimeFormat("es-MX",{month:"long",year:"numeric"}).format($));function V(){if(A==="week"){const L=Ws(y,-7);w(zr(L)),M(L);return}M(new Date($.getFullYear(),$.getMonth()-1,1))}function q(){if(A==="week"){const L=Ws(y,7);w(zr(L)),M(L);return}M(new Date($.getFullYear(),$.getMonth()+1,1))}return t.jsxs("div",{className:`bonsaif-calendar bonsaif-multi-date-calendar ${f}`,children:[t.jsxs("div",{className:"bonsaif-cal-shell",children:[t.jsxs("div",{className:"bonsaif-cal-view-toggle",role:"tablist","aria-label":"Vista",children:[t.jsx("button",{type:"button",role:"tab","aria-selected":A==="month",className:`bonsaif-cal-view-btn${A==="month"?" is-active":""}`,disabled:b,onClick:()=>{C("month"),M(y)},children:"Mes"}),t.jsx("button",{type:"button",role:"tab","aria-selected":A==="week",className:`bonsaif-cal-view-btn${A==="week"?" is-active":""}`,disabled:b,onClick:()=>{C("week"),w(zr($))},children:"Semana"})]}),t.jsxs("div",{className:"bonsaif-cal-toolbar",children:[t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn","aria-label":A==="week"?"Semana anterior":"Mes anterior",disabled:b,onClick:V,children:t.jsx(z.HiChevronLeft,{size:16})}),t.jsx("span",{className:"bonsaif-cal-title",children:X}),t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn","aria-label":A==="week"?"Semana siguiente":"Mes siguiente",disabled:b,onClick:q,children:t.jsx(z.HiChevronRight,{size:16})})]}),t.jsxs("p",{className:"bonsaif-cal-hint",children:["Click · Shift+click rango · Arrastra",i&&A==="month"?" · Semana (nº)":"",A==="week"?" · Botón semana completa":""]}),A==="month"?t.jsx(la.DayPicker,{mode:"multiple",required:!1,selected:v,month:$,onMonthChange:M,onSelect:()=>{},hideNavigation:!0,showOutsideDays:!1,weekStartsOn:1,showWeekNumber:i,onWeekNumberClick:(L,oe)=>{T(oe)},disabled:b?!0:[...E?[{before:E}]:[],...h?[{after:h}]:[]],className:"bonsaif-multi-daypicker",modifiers:ya,modifiersClassNames:xa,classNames:{root:"bonsaif-multi-daypicker",months:"bonsaif-multi-months",month:"bonsaif-multi-month",month_caption:"bonsaif-multi-caption-hidden",month_grid:"bonsaif-multi-month-grid",weekdays:i?"bonsaif-multi-weekdays bonsaif-multi-weekdays--with-week":"bonsaif-multi-weekdays",weekday:"bonsaif-multi-weekday",week:i?"bonsaif-multi-week bonsaif-multi-week--with-week":"bonsaif-multi-week",week_number:"bonsaif-week-number",week_number_header:"bonsaif-week-number-header",day:"bonsaif-multi-day",day_button:"bonsaif-multi-day-btn",selected:"bonsaif-multi-day-selected",today:"bonsaif-multi-day-today",disabled:"bonsaif-multi-day-disabled",hidden:"bonsaif-multi-day-hidden"},components:{DayButton:Z,Weekday:wa},formatters:{formatWeekdayName:va}}):t.jsxs("div",{className:"bonsaif-week-view",children:[t.jsx("div",{className:"bonsaif-week-view-head",children:H.map(L=>t.jsx("div",{className:"bonsaif-multi-weekday",children:new Intl.DateTimeFormat("es-MX",{weekday:"short"}).format(L)},`h-${ht(L)}`))}),t.jsx("div",{className:"bonsaif-week-view-days",children:H.map(L=>{const oe=ht(L),B=x.has(oe),F=b||(n?oe<n:!1)||(a?oe>a:!1),le=oe===ht(new Date);return t.jsx("div",{className:`bonsaif-multi-day${B?" bonsaif-multi-day-selected":""}${le?" bonsaif-multi-day-today":""}${F?" bonsaif-multi-day-disabled":""}`,children:t.jsxs("button",{type:"button",className:"bonsaif-multi-day-btn",disabled:F,"aria-pressed":B,onPointerDown:g=>j(L,g),onPointerEnter:()=>W(L),onClick:g=>G(L,g),children:[t.jsx("span",{className:"bonsaif-week-day-num",children:L.getDate()}),t.jsx("span",{className:"bonsaif-week-day-month",children:new Intl.DateTimeFormat("es-MX",{month:"short"}).format(L)})]})},oe)})}),t.jsx("button",{type:"button",className:"bonsaif-week-select-all",disabled:b,onClick:()=>T(H),children:"Marcar / desmarcar semana"})]})]}),m?t.jsx("div",{className:"bonsaif-cal-summary",children:e.length===0?t.jsx("span",{children:"Sin fechas seleccionadas"}):t.jsxs(t.Fragment,{children:[t.jsxs("span",{children:[e.length," ",e.length===1?"fecha":"fechas"]}),t.jsx("div",{className:"bonsaif-cal-chips",children:e.map(L=>t.jsxs("button",{type:"button",className:"bonsaif-cal-chip",disabled:b,onClick:()=>r==null?void 0:r(e.filter(oe=>oe!==L)),title:`Quitar ${L}`,children:[Fs(L),t.jsx("span",{"aria-hidden":!0,children:"×"})]},L))})]})}):null]})}const hc=Array.from({length:12},(e,r)=>r);function gc({value:e=[],onChange:r,year:n,onYearChange:a,minDate:o,maxDate:l,maxDates:i,showSummary:c=!0,className:d="",disabled:u=!1,readOnly:m=!1}){const f=s.useMemo(()=>Bs(e),[e]),b=Je(o),v=Je(l),x=n??(e[0]?Number(e[0].slice(0,4)):new Date().getFullYear()),[E,h]=s.useState(x);s.useEffect(()=>{typeof n=="number"&&h(n)},[n]);function $(C){h(C),a==null||a(C)}const{onDayPointerDown:M,onDayPointerEnter:y,onDayClick:w}=js({value:e,onChange:r,disabled:u||m,minDate:o,maxDate:l,maxDates:i,retainOutsidePrefix:`${E}-`}),k=s.useCallback(C=>t.jsx(Ps,{...C,className:`bonsaif-year-day-btn ${C.className??""}`,onDayPointerDown:M,onDayPointerEnter:y,onDayClickSelect:w}),[w,M,y]),N=f.filter(C=>C.getFullYear()===E),A=u?!0:[...b?[{before:b}]:[],...v?[{after:v}]:[]];return t.jsxs("div",{className:`bonsaif-calendar bonsaif-year-multi-date-calendar${m?" bonsaif-year-multi-date-calendar--readonly":""} ${d}`,children:[t.jsxs("div",{className:"bonsaif-cal-shell bonsaif-year-cal-shell",children:[t.jsxs("div",{className:"bonsaif-cal-toolbar",children:[t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn","aria-label":"Año anterior",disabled:u,onClick:()=>$(E-1),children:t.jsx(z.HiChevronLeft,{size:16})}),t.jsx("span",{className:"bonsaif-cal-title",children:E}),t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn","aria-label":"Año siguiente",disabled:u,onClick:()=>$(E+1),children:t.jsx(z.HiChevronRight,{size:16})})]}),!m&&!u?t.jsx("p",{className:"bonsaif-cal-hint",children:"Click · Shift+click rango · Arrastra para marcar varias"}):null,t.jsx("div",{className:"bonsaif-year-cal-grid",children:hc.map(C=>{const j=new Date(E,C,1);return t.jsxs("div",{className:"bonsaif-year-cal-month",children:[t.jsx("div",{className:"bonsaif-year-cal-month-title",children:sr(new Intl.DateTimeFormat("es-MX",{month:"long"}).format(j))}),t.jsx(la.DayPicker,{mode:"multiple",required:!1,selected:N,month:j,onMonthChange:()=>{},onSelect:()=>{},numberOfMonths:1,hideNavigation:!0,showOutsideDays:!1,weekStartsOn:1,disabled:A,className:"bonsaif-year-month-picker",modifiers:ya,modifiersClassNames:xa,classNames:{root:"bonsaif-year-month-picker",months:"bonsaif-year-month-months",month:"bonsaif-year-month-inner",month_caption:"bonsaif-year-month-caption-hidden",month_grid:"bonsaif-year-month-grid",weekdays:"bonsaif-year-weekdays",weekday:"bonsaif-year-weekday",week:"bonsaif-year-week",day:"bonsaif-year-day",day_button:"bonsaif-year-day-btn",selected:"bonsaif-year-day-selected",today:"bonsaif-year-day-today",disabled:"bonsaif-year-day-disabled",hidden:"bonsaif-year-day-hidden"},components:{DayButton:k,Weekday:wa},formatters:{formatWeekdayName:W=>new Intl.DateTimeFormat("es-MX",{weekday:"narrow"}).format(W)}})]},`${E}-${C}`)})})]}),c?t.jsx("div",{className:"bonsaif-cal-summary",children:e.length===0?t.jsx("span",{children:"Sin fechas seleccionadas"}):t.jsxs(t.Fragment,{children:[t.jsxs("span",{children:[e.length," ",e.length===1?"fecha":"fechas"," ·"," ",E]}),t.jsx("div",{className:"bonsaif-cal-chips",children:e.map(C=>t.jsxs("button",{type:"button",className:"bonsaif-cal-chip",disabled:u||m,onClick:()=>r==null?void 0:r(e.filter(j=>j!==C)),title:`Quitar ${C}`,children:[Fs(C),t.jsx("span",{"aria-hidden":!0,children:"×"})]},C))})]})}):null]})}const vc="bonsaif-ui:hide-tooltips";function qs(){window.dispatchEvent(new CustomEvent(vc))}function yc(e){if(e!==void 0)return typeof e=="number"?`${e}px`:e}function xc({trigger:e,items:r,align:n="end",width:a=220,disabled:o=!1,className:l="",menuClassName:i="",onOpenChange:c}){const[d,u]=s.useState(!1),[m,f]=s.useState(!1),[b,v]=s.useState({}),x=s.useRef(null),E=s.useRef(null),h=s.useCallback(k=>{u(k),c==null||c(k)},[c]),$=s.useCallback(()=>{const k=x.current;if(!k)return;const N=k.getBoundingClientRect(),A=typeof a=="number"?a:N.width,C=typeof a=="number"?a:Math.max(N.width,180),j=n==="end"?Math.max(8,N.right-C):Math.min(N.left,window.innerWidth-C-8),W=window.innerHeight-N.bottom,G=W<240&&N.top>W?void 0:N.bottom+6,T=G===void 0?window.innerHeight-N.top+6:void 0;v({position:"fixed",zIndex:9999,left:j,top:G,bottom:T,width:yc(typeof a=="number"?A:a)})},[n,a]);s.useEffect(()=>f(!0),[]),s.useEffect(()=>{if(!d)return;$();const k=A=>{var j,W;const C=A.target;!((j=x.current)!=null&&j.contains(C))&&!((W=E.current)!=null&&W.contains(C))&&h(!1)},N=A=>{A.key==="Escape"&&h(!1)};return document.addEventListener("mousedown",k),window.addEventListener("keydown",N),window.addEventListener("resize",$),window.addEventListener("scroll",$,!0),()=>{document.removeEventListener("mousedown",k),window.removeEventListener("keydown",N),window.removeEventListener("resize",$),window.removeEventListener("scroll",$,!0)}},[d,h,$]);const M=k=>{o||(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),h(!d))},y=s.isValidElement(e)?s.cloneElement(e,{onClick:()=>{o||(qs(),h(!d))}}):e,w=d?t.jsx("div",{ref:E,role:"menu","data-bonsaif-overlay":"true",className:`overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-1 shadow-xl ${i}`,style:b,children:r.map(k=>t.jsxs("div",{children:[k.separatorBefore&&t.jsx("div",{className:"my-1 border-t border-[var(--border)]"}),t.jsxs("button",{type:"button",role:"menuitem",disabled:k.disabled,onClick:()=>{var N;k.disabled||(qs(),(N=k.onSelect)==null||N.call(k),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:k.danger?"var(--danger)":"var(--text-main)"},children:[k.icon&&t.jsx("span",{className:"mt-0.5 shrink-0",children:k.icon}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"block truncate text-sm font-medium",children:k.label}),k.description&&t.jsx("span",{className:"block truncate text-xs text-[var(--text-muted)]",children:k.description})]})]})]},k.id))}):null;return t.jsxs("span",{ref:x,role:"button",tabIndex:o?-1:0,"aria-haspopup":"menu","aria-expanded":d,onKeyDown:M,className:`inline-flex ${o?"pointer-events-none opacity-60":""} ${l}`,children:[y,m&&w?nt.createPortal(w,document.body):null]})}const wc=180,Us="bg-[color-mix(in_srgb,var(--bg-main)_72%,transparent)] backdrop-blur-sm";function kc({open:e,onClose:r,title:n,subtitle:a,leadingIcon:o,confirmLabel:l="Guardar",onConfirm:i,loading:c=!1,confirmDisabled:d=!1,headerActions:u,bodyClassName:m="flex-1 overflow-y-auto px-6 py-5",width:f=440,hasUnsavedChanges:b=!1,unsavedChangesTitle:v="Descartar cambios",unsavedChangesDescription:x="Hay cambios sin guardar. Si cierras el drawer se perderán.",unsavedChangesConfirmLabel:E="Descartar",unsavedChangesCancelLabel:h="Seguir editando",onDiscardChanges:$,disabled:M=!1,disabledMessage:y,children:w}){const[k,N]=s.useState(!1),[A,C]=s.useState(!1),[j,W]=s.useState(!1),G=s.useCallback(()=>{C(!0),requestAnimationFrame(()=>{requestAnimationFrame(()=>W(!0))})},[]),T=s.useCallback(()=>{W(!1),window.setTimeout(()=>C(!1),wc)},[]),Z=M||c,H=s.useCallback(()=>{if(!Z){if(b){G();return}r()}},[Z,b,r,G]),ae=s.useCallback(()=>{W(!1),C(!1),$==null||$(),r()},[r,$]);if(s.useEffect(()=>{N(!0)},[]),s.useEffect(()=>(document.body.style.overflow=e?"hidden":"",e||(W(!1),C(!1)),()=>{document.body.style.overflow=""}),[e]),s.useEffect(()=>{if(!e)return;const V=q=>{if(q.key==="Escape"&&!Z){if(A){T();return}H()}};return window.addEventListener("keydown",V),()=>window.removeEventListener("keydown",V)},[T,Z,A,e,H]),!k)return null;const X=y!==void 0?y:c?"Guardando…":null;return nt.createPortal(t.jsxs("div",{"aria-hidden":!e,"data-bonsaif-overlay":e?"true":void 0,className:`fixed inset-0 z-[1000] flex transition-opacity duration-300 ${e?"opacity-100":"opacity-0 pointer-events-none"}`,children:[t.jsx("div",{className:`absolute inset-0 ${Us}`,onClick:H}),t.jsxs("div",{className:`absolute inset-y-0 right-0 flex flex-col shadow-2xl transition-transform duration-300 ${e?"translate-x-0":"translate-x-full"}`,style:{width:`min(100vw, ${f}px)`,background:"var(--bg-card)",borderLeft:"1px solid var(--border)"},children:[t.jsxs("div",{className:"flex items-center justify-between px-6 py-4 flex-shrink-0",style:{borderBottom:"1px solid var(--border)"},children:[t.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[t.jsx(je,{variant:"icon",onClick:H,title:"Cerrar",disabled:Z,children:t.jsx(z.HiXMark,{className:"w-5 h-5"})}),o&&t.jsx("div",{className:"flex-shrink-0",children:o}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("h3",{className:"text-base font-semibold truncate",style:{color:"var(--text-main)"},children:n}),a&&t.jsx("p",{className:"text-xs truncate",style:{color:"var(--text-muted)"},children:a})]})]}),(u||i)&&t.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[u,i&&t.jsxs(t.Fragment,{children:[t.jsx(je,{variant:"secondary",size:"sm",onClick:H,disabled:Z,style:{background:"var(--bg-input)"},children:"Cancelar"}),t.jsx(je,{variant:"primary",size:"sm",icon:t.jsx(Gl.FiSave,{className:"w-4 h-4"}),onClick:i,loading:c,disabled:d||Z,title:l})]})]})]}),t.jsx("div",{"data-drawer-scroll":"true",className:m,children:w}),Z&&t.jsx("div",{className:"absolute inset-0 z-[1002] flex cursor-not-allowed items-center justify-center p-6",style:{background:"color-mix(in srgb, var(--bg-card, #ffffff) 72%, transparent)",backdropFilter:"blur(3px)"},role:"status","aria-live":"polite","aria-busy":"true",children:X?t.jsxs("div",{className:"flex max-w-xs flex-col items-center gap-3 text-center",children:[t.jsx("div",{className:"h-9 w-9 animate-spin rounded-full border-2 border-[var(--border)] border-t-[var(--primary)]","aria-hidden":!0}),t.jsx("p",{className:"text-sm font-semibold text-[var(--text-main)]",children:X})]}):null})]}),A&&t.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":v,className:"fixed inset-0 z-[1001] flex items-center justify-center p-4",children:[t.jsx("div",{className:`absolute inset-0 ${Us} transition-opacity duration-200 ease-out ${j?"opacity-100":"opacity-0"}`,onClick:T}),t.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 ${j?"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:[t.jsx(je,{variant:"icon",onClick:T,className:"absolute right-3 top-3 h-7 w-7 hover:opacity-70",style:{color:"var(--text-muted, #6b7f78)"},"aria-label":h,children:t.jsx(z.HiXMark,{className:"h-4 w-4"})}),t.jsx("div",{className:"mb-4 flex h-11 w-11 items-center justify-center rounded-xl",style:{background:"var(--warning-bg, #fff7ed)"},children:t.jsx(z.HiExclamationTriangle,{className:"h-5 w-5",style:{color:"var(--warning, #d97706)"}})}),t.jsx("h2",{className:"mb-1 text-base font-semibold",style:{color:"var(--text-main, #0f2f2c)"},children:v}),t.jsx("p",{className:"text-sm",style:{color:"var(--text-muted, #6b7f78)"},children:x}),t.jsxs("div",{className:"mt-6 flex gap-2",children:[t.jsx(je,{variant:"secondary",onClick:T,className:"flex-1 border",style:{background:"var(--bg-input, #f7faf8)",borderColor:"var(--border, #d8e1dc)",color:"var(--text-main, #0f2f2c)"},children:h}),t.jsx(je,{variant:"secondary",onClick:ae,className:"flex-1 border",style:{background:"var(--warning, #d97706)",borderColor:"transparent",color:"#fff",boxShadow:"0 10px 22px rgba(217, 119, 6, 0.22)"},children:E})]})]})]})]}),document.body)}const Nc=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,Sc=/^\+?[0-9\s().-]+$/,Cc=7,Ec=15;function gt(e){return e==null||String(e).trim()===""}function Vs(e){return typeof e=="number"?e:typeof e=="string"&&e.trim()!==""?Number(e):Number.NaN}function ka(e){return gt(e)?!1:Nc.test(String(e))}function Na(e){if(gt(e))return!1;const r=String(e),n=r.replace(/\D/g,"");return Sc.test(r)&&n.length>=Cc&&n.length<=Ec}function Mc(e="Este campo es requerido."){return r=>gt(r)?e:void 0}function $c(e="Ingresa un correo valido."){return r=>gt(r)||ka(r)?void 0:e}function Tc(e="Ingresa un telefono valido."){return r=>gt(r)||Na(r)?void 0:e}function Lc(e,r){return n=>gt(n)||String(n).length>=e?void 0:r??`Debe tener al menos ${e} caracteres.`}function Ac(e,r){return n=>gt(n)||String(n).length<=e?void 0:r??`Debe tener ${e} caracteres o menos.`}function Dc(e,r){return n=>{if(gt(n))return;const a=Vs(n);return Number.isFinite(a)&&a>=e?void 0:r??`Debe ser mayor o igual a ${e}.`}}function Ic(e,r){return n=>{if(gt(n))return;const a=Vs(n);return Number.isFinite(a)&&a<=e?void 0:r??`Debe ser menor o igual a ${e}.`}}function Oc(e,r="El formato no es valido."){return n=>gt(n)||e.test(String(n))?void 0:r}function Hc(e,r){const n={};for(const a of Object.keys(r)){const o=r[a];if(!o)continue;const l=Array.isArray(o)?o:[o];for(const i of l){const c=i(e[a],e);if(c){n[a]=c;break}}}return{valid:Object.keys(n).length===0,errors:n}}var Ys={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},Xs=s.createContext&&s.createContext(Ys),Bc=["attr","size","title"];function Fc(e,r){if(e==null)return{};var n,a,o=Pc(e,r);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(a=0;a<l.length;a++)n=l[a],r.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}function Pc(e,r){if(e==null)return{};var n={};for(var a in e)if({}.hasOwnProperty.call(e,a)){if(r.indexOf(a)!==-1)continue;n[a]=e[a]}return n}function vn(){return vn=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var a in n)({}).hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},vn.apply(null,arguments)}function Ks(e,r){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);r&&(a=a.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),n.push.apply(n,a)}return n}function yn(e){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};r%2?Ks(Object(n),!0).forEach(function(a){_c(e,a,n[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ks(Object(n)).forEach(function(a){Object.defineProperty(e,a,Object.getOwnPropertyDescriptor(n,a))})}return e}function _c(e,r,n){return(r=zc(r))in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}function zc(e){var r=jc(e,"string");return typeof r=="symbol"?r:r+""}function jc(e,r){if(typeof e!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var a=n.call(e,r);if(typeof a!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(e)}function Gs(e){return e&&e.map((r,n)=>s.createElement(r.tag,yn({key:n},r.attr),Gs(r.child)))}function Sa(e){return r=>s.createElement(Wc,vn({attr:yn({},e.attr)},r),Gs(e.child))}function Wc(e){var r=n=>{var{attr:a,size:o,title:l}=e,i=Fc(e,Bc),c=o||n.size||"1em",d;return n.className&&(d=n.className),e.className&&(d=(d?d+" ":"")+e.className),s.createElement("svg",vn({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},n.attr,a,i,{className:d,style:yn(yn({color:e.color||n.color},n.style),e.style),height:c,width:c,xmlns:"http://www.w3.org/2000/svg"}),l&&s.createElement("title",null,l),e.children)};return Xs!==void 0?s.createElement(Xs.Consumer,null,n=>r(n)):r(Ys)}function Zs(e){return Sa({attr:{viewBox:"0 0 256 256",fill:"currentColor"},child:[{tag:"path",attr:{d:"M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm0,192a88,88,0,1,1,88-88A88.1,88.1,0,0,1,128,216Zm-8-80V80a8,8,0,0,1,16,0v56a8,8,0,0,1-16,0Zm20,36a12,12,0,1,1-12-12A12,12,0,0,1,140,172Z"},child:[]}]})(e)}function qc(e){return Sa({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:[]}]})(e)}function Uc(e){return Sa({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:[]}]})(e)}function or({content:e,ariaLabel:r="Más información",className:n=""}){return t.jsx(zt,{as:"span",content:e,className:`inline-flex shrink-0 align-middle text-[var(--text-muted)] outline-none transition-colors hover:text-[var(--primary)] focus-visible:text-[var(--primary)] ${n}`,children:t.jsx("span",{tabIndex:0,role:"img","aria-label":r,className:"inline-flex items-center justify-center outline-none",children:t.jsx(z.HiInformationCircle,{className:"h-3.5 w-3.5"})})})}function lr({error:e,helperText:r,helperDisplay:n="inline"}){return e?t.jsx("span",{className:"text-xs font-medium normal-case text-[var(--danger)]",children:e}):r&&n!=="tooltip"?t.jsx("span",{className:"text-xs font-medium normal-case text-[var(--text-muted)]",children:r}):null}function xn({className:e="",...r}){return t.jsx("input",{...r,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)] ${e}`})}function Ca({label:e,containerClassName:r="",helperText:n,helperDisplay:a="inline",error:o,errorDisplay:l="inline",errorTooltipLabel:i="Error de validacion",labelAction:c,floatingLabel:d=!1,showPasswordToggle:u=!0,nativeValidation:m=!1,className:f="",required:b,...v}){const[x,E]=s.useState(()=>!!v.autoFocus),[h,$]=s.useState(!1),M=v.type==="password"&&u,y=M&&h?"text":v.type,w=!!o,k=w&&l!=="tooltip",N=w&&l!=="inline",A=!!n&&a==="tooltip"&&!k,C=m?b:void 0,j=w?"border-[var(--danger)] focus:border-[var(--danger)]":"",W=N?M?"pr-20":"pr-10":M?"pr-10":"",G=v.value!==void 0?String(v.value).length>0:v.defaultValue!==void 0&&String(v.defaultValue).length>0,T=x||G,Z={top:T?7:12,color:x?"var(--primary)":"var(--text-muted)",fontSize:T?10:13,fontWeight:T?600:400,textTransform:T?"uppercase":"none"},H=L=>{var oe;E(!0),(oe=v.onFocus)==null||oe.call(v,L)},ae=L=>{var oe;E(!1),(oe=v.onBlur)==null||oe.call(v,L)},X=M?t.jsxs("button",{type:"button","aria-label":h?"Ocultar contraseña":"Mostrar contraseña","aria-pressed":h,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:()=>$(L=>!L),children:[t.jsx("span",{"aria-hidden":"true",className:`absolute inset-0 flex items-center justify-center transition-[opacity,transform] duration-200 ease-out ${h?"scale-y-0 rotate-[-8deg] opacity-0":"scale-y-100 rotate-0 opacity-100"}`,children:t.jsx(qc,{className:"h-[18px] w-[18px]"})}),t.jsx("span",{"aria-hidden":"true",className:`absolute inset-0 flex items-center justify-center transition-[opacity,transform] duration-200 ease-out ${h?"scale-y-100 rotate-0 opacity-100":"scale-y-0 rotate-[8deg] opacity-0"}`,children:t.jsx(Uc,{className:"h-[18px] w-[18px]"})})]}):null,V=N?t.jsx(zt,{as:"span",content:o,className:`absolute top-1/2 flex h-7 w-7 -translate-y-1/2 items-center justify-center rounded-md text-[var(--danger)] outline-none transition-colors hover:bg-[var(--danger-bg)] focus-visible:bg-[var(--danger-bg)] ${M?"right-10":"right-2.5"}`,children:t.jsx("span",{tabIndex:0,role:"img","aria-label":i,className:"flex h-full w-full items-center justify-center outline-none",children:t.jsx(Zs,{className:"h-[18px] w-[18px]"})})}):null,q=t.jsx(lr,{error:k?o:void 0,helperText:n,helperDisplay:a});return d?t.jsxs("label",{className:`flex flex-col gap-2 ${r}`,children:[t.jsxs("span",{className:"relative block",children:[t.jsx(xn,{...v,type:y,required:C,placeholder:" ","aria-invalid":w||v["aria-invalid"],"data-has-value":G?"true":void 0,className:`h-11 w-full pt-5 ${W} ${j} ${f}`,onFocus:H,onBlur:ae}),t.jsxs("span",{className:"pointer-events-none absolute left-3 transition-all duration-150",style:Z,children:[e,b&&t.jsx("span",{className:"ml-1 text-[var(--danger)]",children:"*"})]}),c&&t.jsx("span",{className:"absolute right-2 transition-all duration-150",style:{top:T?7:12},children:c}),V,X]}),q]}):t.jsxs("label",{className:`flex flex-col gap-2 ${r}`,children:[t.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-semibold uppercase text-[var(--text-muted)]",children:[t.jsx("span",{children:e}),b&&t.jsx("span",{className:"text-[var(--danger)]",children:"*"}),A?t.jsx(or,{content:n}):null,c&&t.jsx("span",{className:"ml-auto normal-case",children:c})]}),M?t.jsxs("span",{className:"relative block",children:[t.jsx(xn,{...v,type:y,required:C,"aria-invalid":w||v["aria-invalid"],className:`w-full ${W} ${j} ${f}`,onFocus:H,onBlur:ae}),V,X]}):t.jsxs("span",{className:"relative block",children:[t.jsx(xn,{...v,required:C,"aria-invalid":w||v["aria-invalid"],className:`w-full ${W} ${j} ${f}`}),V]}),q]})}function Qs(e){return e==null?"":String(e)}function Vc({autoComplete:e="email",inputMode:r="email",validate:n=!0,invalidMessage:a="Ingresa un correo valido.",errorDisplay:o="tooltip",error:l,value:i,defaultValue:c,onChange:d,...u}){const[m,f]=s.useState(()=>Qs(c)),b=i!==void 0?Qs(i):m,v=n&&b.length>0&&!ka(b)?a:void 0,x=E=>{i===void 0&&f(E.currentTarget.value),d==null||d(E)};return t.jsx(Ca,{...u,value:i,defaultValue:c,type:"text",inputMode:r,autoComplete:e,error:l??v,errorDisplay:o,onChange:x})}const Yc={sm:"min-h-[160px] p-4",md:"min-h-[220px] p-6",lg:"min-h-[300px] p-8"};function Xc({title:e="Sin resultados",description:r,icon:n=t.jsx(z.HiInbox,{className:"h-5 w-5"}),action:a,secondaryAction:o,size:l="md",className:i=""}){return t.jsx("div",{className:`flex items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-card)] text-center ${Yc[l]} ${i}`,children:t.jsxs("div",{className:"flex max-w-sm flex-col items-center gap-3",children:[n&&t.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:n}),t.jsxs("div",{className:"space-y-1",children:[e&&t.jsx("h3",{className:"text-sm font-semibold text-[var(--text-main)]",children:e}),r&&t.jsx("div",{className:"text-sm leading-5 text-[var(--text-muted)]",children:r})]}),(a||o)&&t.jsxs("div",{className:"mt-1 flex flex-wrap items-center justify-center gap-2",children:[o,a]})]})})}const Kc={sm:"min-h-[112px] p-4",md:"min-h-[148px] p-5",lg:"min-h-[184px] p-6"};function Gc(e){if(e===0)return"0 B";const r=["B","KB","MB","GB"],n=Math.min(Math.floor(Math.log(e)/Math.log(1024)),r.length-1),a=e/1024**n;return`${a>=10||n===0?a.toFixed(0):a.toFixed(1)} ${r[n]}`}function Js(e,r){return r?r.split(",").map(n=>n.trim().toLowerCase()).filter(Boolean).some(n=>{const a=e.name.toLowerCase(),o=e.type.toLowerCase();return n.startsWith(".")?a.endsWith(n):n.endsWith("/*")?o.startsWith(n.slice(0,-1)):o===n}):!0}function Zc(e,r,n){return r?n===void 0?e:e.slice(0,Math.max(0,n)):e.slice(0,1)}function Qc({label:e,helperText:r,helperDisplay:n="inline",error:a,labelAction:o,value:l,defaultValue:i=[],onFilesChange:c,onRejectedFiles:d,multiple:u=!1,maxFiles:m,appendFiles:f=!1,showFileList:b=!0,clearable:v=!0,browseLabel:x="Buscar archivos",dropLabel:E="Suelta los archivos aqui",emptyLabel:h="Arrastra y suelta archivos",emptyDescription:$="o haz click para buscarlos en tu equipo",selectedLabel:M="Archivos seleccionados",size:y="md",containerClassName:w="",dropzoneClassName:k="",fileListClassName:N="",className:A="",id:C,accept:j,disabled:W,required:G,...T}){const Z=s.useId(),H=C??Z,ae=s.useRef(null),[X,V]=s.useState(!1),[q,L]=s.useState(i),oe=l??q,B=!!a,F=!!r&&n==="tooltip"&&!B,le=v&&oe.length>0&&!W,g=(Q,de)=>{l===void 0&&L(Q),c==null||c(Q,de)},P=(Q,de)=>{const Se=Q.filter(De=>Js(De,j)),ie=Q.filter(De=>!Js(De,j)),pe=f?[...oe,...Se]:Se,Ce=Zc(pe,u,m);ie.length>0&&(d==null||d(ie)),g(Ce,de)},I=()=>{var Q;W||(Q=ae.current)==null||Q.click()},te=Q=>{P(Array.from(Q.target.files??[]),Q),Q.target.value=""},U=Q=>{Q.preventDefault(),W||V(!0)},K=Q=>{Q.currentTarget.contains(Q.relatedTarget)||V(!1)},D=Q=>{Q.preventDefault(),V(!1),!W&&P(Array.from(Q.dataTransfer.files),Q)},ee=Q=>{Q.key!=="Enter"&&Q.key!==" "||(Q.preventDefault(),I())},_=Q=>{g(oe.filter((de,Se)=>Se!==Q))},se=()=>{g([])};return t.jsxs("div",{className:`flex flex-col gap-2 ${w}`,children:[(e||o||F)&&t.jsxs("div",{className:"inline-flex items-center gap-1 text-xs font-semibold uppercase text-[var(--text-muted)]",children:[e&&t.jsx("span",{children:e}),G&&t.jsx("span",{className:"text-[var(--danger)]",children:"*"}),F?t.jsx(or,{content:r}):null,o&&t.jsx("span",{className:"ml-auto normal-case",children:o})]}),t.jsx("input",{...T,ref:ae,id:H,type:"file",accept:j,multiple:u,disabled:W,required:G&&oe.length===0,"aria-invalid":B||T["aria-invalid"],className:"sr-only",onChange:te}),t.jsxs("div",{role:"button",tabIndex:W?-1:0,"aria-controls":H,"aria-disabled":W||void 0,"aria-invalid":B||void 0,className:`flex cursor-pointer flex-col items-center justify-center gap-3 rounded-lg border border-dashed bg-[var(--bg-card)] text-center outline-none transition-colors focus:border-[var(--primary)] focus:bg-[var(--bg-input)] ${Kc[y]} ${X?"border-[var(--primary)] bg-[var(--bg-input)]":B?"border-[var(--danger)]":"border-[var(--border)]"} ${W?"cursor-not-allowed opacity-60":"hover:border-[var(--primary)] hover:bg-[var(--bg-input)]"} ${k} ${A}`,onClick:I,onDragOver:U,onDragLeave:K,onDrop:D,onKeyDown:ee,children:[t.jsx("span",{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:t.jsx(z.HiArrowUpTray,{className:"h-5 w-5"})}),t.jsxs("span",{className:"space-y-1",children:[t.jsx("span",{className:"block text-sm font-semibold text-[var(--text-main)]",children:X?E:h}),$&&t.jsx("span",{className:"block text-sm text-[var(--text-muted)]",children:$})]}),x&&t.jsx("span",{className:"inline-flex h-9 items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-card)] px-3 text-xs font-semibold text-[var(--text-main)] shadow-sm shadow-black/5 transition-colors",children:x})]}),b&&oe.length>0&&t.jsxs("div",{className:`rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${N}`,children:[t.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-[var(--border)] px-3 py-2",children:[t.jsx("span",{className:"text-xs font-semibold uppercase text-[var(--text-muted)]",children:M}),le&&t.jsx("button",{type:"button",className:"inline-flex h-7 w-7 items-center justify-center rounded-md text-[var(--text-muted)] transition-colors hover:bg-[var(--bg-input)] hover:text-[var(--danger)] focus:outline-none","aria-label":"Quitar todos los archivos",onClick:se,children:t.jsx(z.HiTrash,{className:"h-4 w-4"})})]}),t.jsx("ul",{className:"divide-y divide-[var(--border)]",children:oe.map((Q,de)=>t.jsxs("li",{className:"flex items-center gap-3 px-3 py-2",children:[t.jsx("span",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-md bg-[var(--bg-input)] text-[var(--text-muted)]",children:t.jsx(z.HiDocument,{className:"h-4 w-4"})}),t.jsxs("span",{className:"min-w-0 flex-1 text-left",children:[t.jsx("span",{className:"block truncate text-sm font-medium text-[var(--text-main)]",children:Q.name}),t.jsx("span",{className:"block text-xs text-[var(--text-muted)]",children:Gc(Q.size)})]}),!W&&t.jsx("button",{type:"button",className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-[var(--text-muted)] transition-colors hover:bg-[var(--bg-input)] hover:text-[var(--danger)] focus:outline-none","aria-label":`Quitar ${Q.name}`,onClick:()=>_(de),children:t.jsx(z.HiXMark,{className:"h-4 w-4"})})]},`${Q.name}-${Q.lastModified}-${de}`))})]}),t.jsx(lr,{error:a,helperText:r,helperDisplay:n})]})}const Jc=[{value:"texto",label:"texto"},{value:"numero",label:"número"},{value:"fecha",label:"fecha"},{value:"booleano",label:"booleano"},{value:"email",label:"email"},{value:"telefono",label:"teléfono"},{value:"select",label:"select"},{value:"textarea",label:"textarea"},{value:"archivo",label:"archivo"},{value:"imagen",label:"imagen"}];function Rc({fields:e,title:r="Layout",fieldTypes:n=Jc,saveLabel:a="Guardar",allowAddField:o=!1,addFieldPlaceholder:l="Nuevo campo",addFieldLabel:i="Anadir",loading:c=!1,onSave:d,onChange:u}){const[m,f]=s.useState(()=>e.map(y=>({key:!1,type:"",...y}))),[b,v]=s.useState(""),[x,E]=s.useState(""),h=s.useCallback((y,w)=>{f(k=>{const N=k.map((A,C)=>C===y?{...A,...w}:A);return u==null||u(N),N})},[u]),$=s.useCallback(()=>{d==null||d(m)},[m,d]),M=s.useCallback(()=>{var N;const y=b.trim();if(!y){E("Ingresa un nombre de campo.");return}if(m.some(A=>A.name.toLowerCase()===y.toLowerCase())){E("Ese campo ya existe en el arreglo.");return}const k={name:y,key:!1,type:((N=n[0])==null?void 0:N.value)??""};f(A=>{const C=[...A,k];return u==null||u(C),C}),v(""),E("")},[n,m,b,u]);return t.jsxs("div",{className:"flex flex-col rounded-xl border shadow-sm",style:{borderColor:"var(--border)",background:"var(--bg-card)",color:"var(--text-main)"},children:[t.jsx("div",{className:"border-b px-6 py-4",style:{borderColor:"var(--border)"},children:t.jsx("span",{className:"text-base font-semibold",style:{color:"var(--text-main)"},children:r})}),t.jsxs("div",{className:"grid grid-cols-[1fr_80px_1fr] gap-4 border-b px-6 py-2 text-xs font-medium uppercase tracking-wide",style:{borderColor:"var(--border)",color:"var(--text-muted)"},children:[t.jsx("span",{children:"Campo"}),t.jsx("span",{className:"text-center",children:"Llave"}),t.jsx("span",{children:"Tipo de Campo"})]}),t.jsxs("div",{className:"max-h-[420px] overflow-y-auto",children:[m.map((y,w)=>t.jsxs("div",{className:"grid grid-cols-[1fr_80px_1fr] items-center gap-4 border-b px-6 py-3 last:border-0 hover:bg-[var(--bg-input)] transition-colors",style:{borderColor:"var(--border)"},children:[t.jsx("span",{className:"text-sm font-medium",style:{color:"var(--text-main)"},children:y.name}),t.jsx("div",{className:"flex justify-center",children:t.jsx(dn,{size:"sm",checked:y.key??!1,onChange:k=>h(w,{key:k.target.checked}),"aria-label":`${y.name} es clave`})}),t.jsx(jt,{value:y.type??"",onChange:k=>h(w,{type:k}),options:n,placeholder:"—",emptyLabel:"—",height:36,searchable:!1,ariaLabel:`Tipo de ${y.name}`})]},y.name)),m.length===0&&t.jsx("p",{className:"px-6 py-8 text-center text-sm",style:{color:"var(--text-muted)"},children:"No hay campos disponibles."})]}),t.jsx("div",{className:"flex justify-end border-t px-6 py-4",style:{borderColor:"var(--border)"},children:t.jsxs("div",{className:"w-full space-y-2",children:[o&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{type:"text",value:b,onChange:y=>{v(y.currentTarget.value),x&&E("")},onKeyDown:y=>{y.key==="Enter"&&(y.preventDefault(),M())},placeholder:l,className:"min-w-0 flex-1 rounded-lg border px-3 py-2 text-sm outline-none transition-colors",style:{borderColor:"var(--border)",background:"var(--bg-input)",color:"var(--text-main)"},"aria-label":"Nombre del nuevo campo"}),t.jsx(je,{variant:"secondary",onClick:M,height:36,padding:"0 12px",children:i})]}),x&&t.jsx("p",{className:"text-xs",style:{color:"var(--danger)"},children:x})]}),t.jsx("div",{className:"flex justify-end",children:t.jsx(je,{variant:"primary",onClick:$,disabled:c,loading:c,children:a})})]})})]})}function Ea({label:e,children:r,helperText:n,helperDisplay:a="inline",error:o,labelAction:l,required:i=!1,className:c="",contentClassName:d=""}){const u=!!n&&a==="tooltip"&&!o;return t.jsxs("label",{className:`flex flex-col gap-2 ${c}`,children:[(e||l||u)&&t.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-semibold uppercase text-[var(--text-muted)]",children:[e&&t.jsx("span",{children:e}),i&&t.jsx("span",{className:"text-[var(--danger)]",children:"*"}),u?t.jsx(or,{content:n}):null,l&&t.jsx("span",{className:"ml-auto normal-case",children:l})]}),t.jsx("span",{className:`block ${d}`,children:r}),t.jsx(lr,{error:o,helperText:n,helperDisplay:a})]})}function ed(e){return Array.from(e.querySelectorAll("img")).filter(r=>!!(r.currentSrc||r.src||"").trim())}function Rs(e,r){const n=e.target;if(!(n instanceof HTMLImageElement))return!1;const a=e.currentTarget,o=ed(a),l=o.indexOf(n);if(l<0)return!1;e.preventDefault(),e.stopPropagation();const i=n.getBoundingClientRect();return r(o.map(c=>({src:c.currentSrc||c.src,alt:c.alt||void 0})),l,{left:i.left,top:i.top,width:i.width,height:i.height}),!0}const bt=260,ir=420,Ma=380,vt="cubic-bezier(0.22, 1, 0.36, 1)",td="cubic-bezier(0.16, 1, 0.3, 1)",$a="cubic-bezier(0.22, 1, 0.36, 1)",rd="cubic-bezier(0.22, 1, 0.36, 1)",nd=8,ad=1,sd=1.25,Ta={background:"color-mix(in srgb, var(--bg-card) 90%, transparent)",border:"1px solid var(--border)",boxShadow:"0 10px 28px color-mix(in srgb, var(--bg-main) 28%, transparent), inset 0 1px 0 color-mix(in srgb, var(--bg-card) 55%, transparent)",color:"var(--text-main)",backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)"},od="color-mix(in srgb, var(--bg-card) 88%, var(--primary) 12%)",La=10;function jr(e,r,n){return Math.min(n,Math.max(r,e))}function ld(e){return!e||e.width<1||e.height<1?null:{left:e.left,top:e.top,width:e.width,height:e.height}}function eo(e,r){if(r.width<1||r.height<1)return{dx:0,dy:0,scale:1};const n=Math.min(e.width/r.width,e.height/r.height),a=e.left+e.width/2-(r.left+r.width/2),o=e.top+e.height/2-(r.top+r.height/2);return{dx:a,dy:o,scale:Number.isFinite(n)?n:1}}function cr({label:e,onClick:r,children:n,disabled:a,size:o="md"}){const l=o==="lg"?44:40;return t.jsx("button",{type:"button","aria-label":e,title:e,disabled:a,onClick:i=>{i.stopPropagation(),r()},className:"inline-flex items-center justify-center rounded-full disabled:cursor-not-allowed disabled:opacity-35",style:{...Ta,width:l,height:l,transition:"background 160ms ease, transform 160ms cubic-bezier(0.22, 1, 0.36, 1), opacity 160ms ease"},onMouseEnter:i=>{a||(i.currentTarget.style.background=od,i.currentTarget.style.transform="scale(1.06)")},onMouseLeave:i=>{i.currentTarget.style.background=String(Ta.background??""),i.currentTarget.style.transform="scale(1)"},onMouseDown:i=>{a||(i.currentTarget.style.transform="scale(0.94)")},onMouseUp:i=>{a||(i.currentTarget.style.transform="scale(1.06)")},children:n})}function to({open:e,onClose:r,slides:n,index:a,onIndexChange:o,originRect:l=null,maxZoom:i=nd,minZoom:c=ad,zoomStep:d=sd,closeOnBackdrop:u=!0,closeOnEscape:m=!0,showCounter:f=!0,showZoomControls:b=!0,loop:v=!0,showThumbnails:x=!0,zIndex:E=1100,ariaLabel:h="Visor de imagen"}){const[$,M]=s.useState(!1),[y,w]=s.useState(!1),[k,N]=s.useState(a??0),[A,C]=s.useState(1),[j,W]=s.useState({x:0,y:0}),[G,T]=s.useState({opacity:1,x:0,scale:1,blur:0,animate:!1}),[Z,H]=s.useState({dx:0,dy:0,scale:1,animate:!1,enabled:!1}),[ae,X]=s.useState(!1),V=s.useRef(null),q=s.useRef(null),L=s.useRef(null),oe=s.useRef(null),B=s.useRef(null),F=s.useRef(!1),le=s.useRef(!1),g=s.useRef(null),P=s.useRef(null),I=s.useRef(null),te=s.useRef(null),U=s.useRef(null),K=s.useRef(a??0),D=a??k,ee=n.length===0?0:jr(D,0,Math.max(0,n.length-1)),_=n[ee],se=n.length>1,Q=Math.max(c,i),de=x&&se,Se=s.useCallback(ce=>{if(n.length===0)return;const ue=n.length-1,Ee=v?(ce%n.length+n.length)%n.length:jr(ce,0,ue);a===void 0&&N(Ee),o==null||o(Ee)},[a,v,o,n.length]),ie=s.useCallback(()=>{C(1),W({x:0,y:0})},[]),pe=s.useCallback((ce,ue)=>{if(ue<=c+.001)return{x:0,y:0};const Ee=te.current,Ie=U.current;if(!Ee||!Ie)return ce;const Ae=Ee.getBoundingClientRect(),Pe=Ie.offsetWidth*ue,Ge=Ie.offsetHeight*ue,Ze=Math.max(0,(Pe-Ae.width)/2+Ae.width*.15),Qe=Math.max(0,(Ge-Ae.height)/2+Ae.height*.15);return{x:jr(ce.x,-Ze,Ze),y:jr(ce.y,-Qe,Qe)}},[c]),Ce=s.useCallback(()=>{M(!1),H({dx:0,dy:0,scale:1,animate:!1,enabled:!1}),oe.current=null,B.current=null,F.current=!1,le.current=!1,g.current&&(clearTimeout(g.current),g.current=null)},[]),De=s.useCallback(()=>{if(F.current)return;F.current=!0,w(!1),ie();const ce=oe.current,ue=ce!=null&&B.current!=null&&B.current===ee;if(ce&&ue){L.current!=null&&cancelAnimationFrame(L.current),L.current=requestAnimationFrame(()=>{L.current=requestAnimationFrame(()=>{const Ee=U.current;if(!Ee){L.current=null,V.current&&clearTimeout(V.current),V.current=setTimeout(Ce,bt+40);return}const Ie=Ee.getBoundingClientRect(),Ae=eo(ce,Ie);H({enabled:!0,dx:0,dy:0,scale:1,animate:!1}),L.current=requestAnimationFrame(()=>{H({enabled:!0,dx:Ae.dx,dy:Ae.dy,scale:Ae.scale,animate:!0}),L.current=null})})}),V.current&&clearTimeout(V.current),V.current=setTimeout(Ce,ir+80);return}H({dx:0,dy:0,scale:1,animate:!1,enabled:!1}),V.current&&clearTimeout(V.current),V.current=setTimeout(Ce,bt+40)},[Ce,ie,ee]);s.useEffect(()=>(e?(V.current&&clearTimeout(V.current),g.current&&(clearTimeout(g.current),g.current=null),F.current=!1,le.current=!1,oe.current=ld(l),B.current=oe.current!=null?a??k:null,M(!0),w(!1),oe.current?H({dx:0,dy:0,scale:1,animate:!1,enabled:!0}):(B.current=null,requestAnimationFrame(()=>requestAnimationFrame(()=>{w(!0),H({dx:0,dy:0,scale:1,animate:!1,enabled:!1})})))):$&&De(),()=>{V.current&&clearTimeout(V.current),L.current!=null&&cancelAnimationFrame(L.current)}),[e]);const mt=s.useCallback(()=>{if(!e||F.current||le.current)return;const ce=oe.current,ue=U.current;if(!ce||!ue){ce||(w(!0),le.current=!0);return}const Ee=ue.getBoundingClientRect();if(Ee.width<2||Ee.height<2)return;le.current=!0;const Ie=eo(ce,Ee);H({enabled:!0,dx:Ie.dx,dy:Ie.dy,scale:Ie.scale,animate:!1}),L.current!=null&&cancelAnimationFrame(L.current),L.current=requestAnimationFrame(()=>{L.current=requestAnimationFrame(()=>{H({enabled:!0,dx:0,dy:0,scale:1,animate:!0}),w(!0),L.current=null,g.current&&clearTimeout(g.current),g.current=setTimeout(()=>{H({dx:0,dy:0,scale:1,animate:!1,enabled:!1}),g.current=null},ir+20)})})},[e]);s.useLayoutEffect(()=>{!$||!e||!oe.current||le.current||mt()},[$,e,mt]),s.useEffect(()=>{!e||F.current||B.current!=null&&B.current!==ee&&H(ce=>ce.enabled?{dx:0,dy:0,scale:1,animate:!1,enabled:!1}:ce)},[e,ee]),s.useEffect(()=>{if(!e)return;const ce=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=ce}},[e]),s.useEffect(()=>{e&&ie()},[e,ee,ie]),s.useEffect(()=>{a!==void 0&&N(a)},[a]),s.useEffect(()=>{if(!e){K.current=ee,T({opacity:1,x:0,scale:1,blur:0,animate:!1});return}const ce=K.current;if(ce===ee)return;K.current=ee;const ue=n.length;let Ee=1;if(ue>1){const Ie=(ce+1)%ue===ee,Ae=(ce-1+ue)%ue===ee;Ae&&!Ie?Ee=-1:Ie&&!Ae?Ee=1:Ee=ee>ce?1:-1}return q.current!=null&&(cancelAnimationFrame(q.current),q.current=null),T({opacity:0,x:Ee*56,scale:.94,blur:8,animate:!1}),q.current=requestAnimationFrame(()=>{q.current=requestAnimationFrame(()=>{T({opacity:1,x:0,scale:1,blur:0,animate:!0}),q.current=null})}),()=>{q.current!=null&&(cancelAnimationFrame(q.current),q.current=null)}},[e,ee,n.length]);const xt=A<=c+.001&&Math.abs(j.x)<.5&&Math.abs(j.y)<.5,We=s.useCallback((ce,ue,Ee)=>{C(Ie=>{const Ae=jr(ce,c,Q);if(Math.abs(Ae-Ie)<1e-4)return Ie;const Pe=Ae/Ie,Ge=Ae<Ie;return Ae<=c+.001?(W({x:0,y:0}),c):(W(Ze=>{let Qe=Ze;if(typeof ue=="number"&&typeof Ee=="number"&&te.current&&!Ge){const Et=te.current.getBoundingClientRect(),Ht=ue-Et.left-Et.width/2,Ut=Ee-Et.top-Et.height/2;Qe={x:Ht-(Ht-Ze.x)*Pe,y:Ut-(Ut-Ze.y)*Pe}}else if(Ge){Qe={x:Ze.x*Pe,y:Ze.y*Pe};const Et=Math.min(1,(Ie-Ae)/Math.max(.01,Ie-c));Qe={x:Qe.x*(1-Et*.65),y:Qe.y*(1-Et*.65)}}else Qe={x:Ze.x*Pe,y:Ze.y*Pe};return pe(Qe,Ae)}),Ae)})},[pe,c,Q]),Le=s.useCallback(()=>{We(A*d)},[We,A,d]),ke=s.useCallback(()=>{const ce=Math.max(c,A/d);if(ce<=c+.001){ie();return}C(ce),W({x:0,y:0})},[c,ie,A,d]);s.useEffect(()=>{if(!e)return;const ce=ue=>{if(ue.key==="Escape"&&m){ue.preventDefault(),r();return}ue.key==="ArrowLeft"&&se?(ue.preventDefault(),Se(ee-1)):ue.key==="ArrowRight"&&se?(ue.preventDefault(),Se(ee+1)):ue.key==="+"||ue.key==="="?(ue.preventDefault(),We(A*d)):ue.key==="-"||ue.key==="_"?(ue.preventDefault(),ke()):ue.key==="0"&&(ue.preventDefault(),ie())};return window.addEventListener("keydown",ce),()=>window.removeEventListener("keydown",ce)},[We,m,se,r,e,ie,ee,A,Se,ke,d]);const et=ce=>{ce.preventDefault();const ue=ce.deltaY>0?1/d:d;We(A*ue,ce.clientX,ce.clientY)},me=ce=>{A<=c+.001||(ce.currentTarget.setPointerCapture(ce.pointerId),X(!0),P.current={pointerId:ce.pointerId,startX:ce.clientX,startY:ce.clientY,originX:j.x,originY:j.y})},J=ce=>{const ue=P.current;!ue||ue.pointerId!==ce.pointerId||W(pe({x:ue.originX+(ce.clientX-ue.startX),y:ue.originY+(ce.clientY-ue.startY)},A))},re=ce=>{var ue;((ue=P.current)==null?void 0:ue.pointerId)===ce.pointerId&&(P.current=null,X(!1))},be=ce=>{if(ce.stopPropagation(),A>c+.05){ie();return}We(Math.min(Q,3),ce.clientX,ce.clientY)},he=ce=>{if(ce.touches.length!==2)return;X(!0);const[ue,Ee]=[ce.touches[0],ce.touches[1]],Ie=Math.hypot(ue.clientX-Ee.clientX,ue.clientY-Ee.clientY);I.current={distance:Ie,scale:A}},Be=ce=>{if(ce.touches.length!==2||!I.current)return;ce.preventDefault();const[ue,Ee]=[ce.touches[0],ce.touches[1]],Ie=Math.hypot(ue.clientX-Ee.clientX,ue.clientY-Ee.clientY),Ae=(ue.clientX+Ee.clientX)/2,Pe=(ue.clientY+Ee.clientY)/2,Ge=I.current.scale*(Ie/Math.max(1,I.current.distance));We(Ge,Ae,Pe)},Te=()=>{I.current=null,X(!1)};if(!$||!_)return null;const He=Z.enabled,Fe=Z.animate?`transform ${ir}ms ${rd}`:"none";return nt.createPortal(t.jsxs("div",{className:"fixed inset-0",style:{zIndex:E},role:"dialog","aria-modal":"true","aria-label":h,children:[t.jsx("button",{type:"button","aria-label":"Cerrar",className:"absolute inset-0 border-0",style:{background:"color-mix(in srgb, var(--bg-sidebar, var(--primary)) 72%, transparent)",backdropFilter:"blur(10px)",WebkitBackdropFilter:"blur(10px)",opacity:y?1:0,transition:`opacity ${He?ir:bt}ms ${vt}`,cursor:"default",zIndex:0},onClick:()=>{u&&r()}}),t.jsx("div",{ref:te,className:"absolute inset-0 flex items-center justify-center",style:{zIndex:1,padding:de?"4.5rem 3.5rem 6.5rem":"4.5rem 3.5rem 2.5rem",opacity:He||y?1:0,transform:He||y?"translateY(0) scale(1)":"translateY(10px) scale(0.96)",transition:He?"none":`opacity ${bt}ms ${vt}, transform ${bt}ms ${vt}`},onClick:ce=>{ce.target===ce.currentTarget&&u&&r()},onWheel:et,children:t.jsx("div",{className:"relative flex max-h-full max-w-full items-center justify-center will-change-transform",style:{transform:Z.enabled?`translate3d(${Z.dx}px, ${Z.dy}px, 0) scale(${Z.scale})`:void 0,transformOrigin:"center center",transition:Z.enabled?Fe:void 0},children:t.jsx("div",{className:"relative flex max-h-full max-w-full items-center justify-center will-change-transform",style:{opacity:G.opacity,filter:G.blur?`blur(${G.blur}px)`:"blur(0px)",transform:`translate3d(${G.x}px, 0, 0) scale(${G.scale})`,transition:G.animate?[`opacity ${Ma}ms ${$a}`,`transform ${Ma}ms ${$a}`,`filter ${Ma}ms ${$a}`].join(", "):"none"},children:t.jsx("div",{ref:U,className:"pointer-events-auto relative max-h-full max-w-full touch-none select-none will-change-transform",style:{cursor:A>c+.001?"grab":"zoom-in",transform:`translate3d(${j.x}px, ${j.y}px, 0) scale(${A})`,transformOrigin:"center center",transition:ae?"none":`transform 220ms ${td}`},onClick:ce=>ce.stopPropagation(),onDoubleClick:be,onPointerDown:me,onPointerMove:J,onPointerUp:re,onPointerCancel:re,onTouchStart:he,onTouchMove:Be,onTouchEnd:Te,children:t.jsx("img",{src:_.src,alt:_.alt||"",draggable:!1,className:"block max-h-[min(78vh,820px)] max-w-[min(86vw,1100px)] object-contain",style:{display:"block",borderRadius:La,imageRendering:A>2.5?"pixelated":"auto"},onLoad:()=>{mt()}},_.src+String(ee))})})})}),t.jsxs("div",{className:"pointer-events-none absolute inset-0",style:{zIndex:2,opacity:y?1:0,transform:y?"translateY(0)":"translateY(-6px)",transition:`opacity ${He?ir:bt}ms ${vt}, transform ${He?ir:bt}ms ${vt}`},children:[t.jsxs("div",{className:"pointer-events-none absolute inset-x-0 top-0 flex items-center justify-between gap-3 px-4 pt-4",children:[t.jsx("div",{className:"pointer-events-auto flex items-center gap-2",children:f&&n.length>0?t.jsxs("span",{className:"rounded-full px-3 py-1.5 text-xs font-semibold tracking-wide",style:Ta,children:[ee+1," / ",n.length]}):null}),t.jsxs("div",{className:"pointer-events-auto flex items-center gap-2",children:[b?t.jsxs(t.Fragment,{children:[t.jsx(cr,{label:"Alejar",onClick:ke,disabled:A<=c+.001,children:t.jsx(z.HiMinus,{className:"h-5 w-5"})}),t.jsx(cr,{label:"Restablecer tamaño",onClick:ie,disabled:xt,children:t.jsx(z.HiArrowsPointingIn,{className:"h-5 w-5"})}),t.jsx(cr,{label:"Acercar",onClick:Le,disabled:A>=Q-.001,children:t.jsx(z.HiPlus,{className:"h-5 w-5"})})]}):null,t.jsx(cr,{label:"Cerrar",onClick:r,children:t.jsx(z.HiXMark,{className:"h-5 w-5"})})]})]}),se?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"pointer-events-auto absolute left-3 top-1/2",style:{opacity:y?1:0,transform:y?"translate(0, -50%)":"translate(-8px, -50%)",transition:`opacity ${bt}ms ${vt}, transform ${bt}ms ${vt}`},children:t.jsx(cr,{label:"Anterior",size:"lg",onClick:()=>Se(ee-1),disabled:!v&&ee<=0,children:t.jsx(z.HiChevronLeft,{className:"h-6 w-6"})})}),t.jsx("div",{className:"pointer-events-auto absolute right-3 top-1/2",style:{opacity:y?1:0,transform:y?"translate(0, -50%)":"translate(8px, -50%)",transition:`opacity ${bt}ms ${vt}, transform ${bt}ms ${vt}`},children:t.jsx(cr,{label:"Siguiente",size:"lg",onClick:()=>Se(ee+1),disabled:!v&&ee>=n.length-1,children:t.jsx(z.HiChevronRight,{className:"h-6 w-6"})})})]}):null,de?t.jsx("div",{className:"pointer-events-none absolute inset-x-0 bottom-0 flex justify-center px-4 pb-4 pt-8",style:{background:"linear-gradient(to top, color-mix(in srgb, var(--bg-sidebar, var(--primary)) 72%, transparent), transparent)"},children:t.jsx("div",{className:"pointer-events-auto flex max-w-full items-end gap-2.5 overflow-x-auto rounded-2xl px-2 py-2",style:{background:"color-mix(in srgb, var(--bg-card) 55%, transparent)",backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)",scrollbarWidth:"thin"},role:"tablist","aria-label":"Miniaturas",children:n.map((ce,ue)=>{const Ee=ue===ee;return t.jsx("button",{type:"button",role:"tab","aria-selected":Ee,"aria-label":ce.alt||`Imagen ${ue+1}`,onClick:Ie=>{Ie.stopPropagation(),Se(ue)},className:"relative shrink-0 overflow-hidden transition-opacity",style:{width:56,height:42,borderRadius:La,opacity:Ee?1:.42,transition:`opacity 180ms ${vt}`},children:t.jsx("img",{src:ce.src,alt:"",draggable:!1,className:"h-full w-full object-cover",style:{borderRadius:La}})},`${ce.src}-${ue}`)})})}):null]})]}),document.body)}function id({children:e,className:r,style:n,maxZoom:a,minZoom:o,zoomStep:l,loop:i,showThumbnails:c}){const[d,u]=s.useState(!1),[m,f]=s.useState(0),[b,v]=s.useState([]),[x,E]=s.useState(null),h=s.useCallback((M,y,w)=>{v(M),E(w??null),f(y),u(!0)},[]),$=s.useCallback(M=>{Rs(M,h)},[h]);return t.jsxs(t.Fragment,{children:[t.jsx("div",{className:`[&_img]:cursor-zoom-in ${r??""}`,style:n,onClick:$,children:e}),t.jsx(to,{open:d,onClose:()=>u(!1),index:m,onIndexChange:f,slides:b,originRect:x,maxZoom:a,minZoom:o,zoomStep:l,loop:i,showThumbnails:c})]})}function ro(e){if(e!==void 0)return typeof e=="number"?`${e}px`:e}function no(e,r){if(e.length!==r.length)return!1;const n=new Set(r);return e.every(a=>n.has(a))}function Aa(e){return e.normalize("NFD").replace(new RegExp("\\p{M}","gu"),"").toLowerCase()}function cd(e,r){if(!r)return!0;const n=Aa(r);return Aa(e.label).includes(n)||!!(e.sublabel&&Aa(e.sublabel).includes(n))}function dd({value:e,onChange:r,options:n,placeholder:a="Seleccionar…",disabled:o=!1,className:l="",style:i,height:c=40,padding:d="6px 10px",searchable:u=!0,minOptionsForSearch:m=6,maxVisibleValues:f=2,truncateSelectedValues:b=!0,emptyText:v="Sin resultados",clearLabel:x="Limpiar seleccion",pruneMissingValues:E=!0}){const[h,$]=s.useState(!1),[M,y]=s.useState(""),[w,k]=s.useState(0),[N,A]=s.useState(!1),[C,j]=s.useState({}),W=s.useRef(null),G=s.useRef(null),T=s.useRef(null),Z=s.useRef(null),H=u&&n.length>=m,ae=s.useMemo(()=>new Set(e),[e]),X=s.useMemo(()=>{const D=new Map;for(const ee of n)D.set(ee.value,ee);return D},[n]),V=s.useMemo(()=>{const D=[];for(const ee of e){const _=X.get(ee);_&&D.push(_)}return D},[X,e]),q=f==="all"?V.length:f,L=V.slice(0,q),oe=Math.max(0,V.length-L.length),B=s.useMemo(()=>{const D=M.trim();return!H||!D?n:n.filter(ee=>cd(ee,D))},[n,M,H]),F=s.useCallback(()=>{const D=W.current;if(!D)return;const ee=D.getBoundingClientRect(),_=H?304:244,se=window.innerHeight-ee.bottom,Q=se<_&&ee.top>se;j({position:"fixed",left:ee.left,top:Q?void 0:ee.bottom+4,bottom:Q?window.innerHeight-ee.top+4:void 0,width:Math.max(ee.width,240),zIndex:9999})},[H]),le=s.useCallback(D=>{no(e,D)||r(D)},[r,e]),g=s.useCallback(D=>{const ee=X.get(D);if(ee!=null&&ee.disabled)return;const _=ae.has(D)?e.filter(se=>se!==D):[...e,D];le(_)},[le,X,e,ae]),P=s.useCallback(()=>le([]),[le]),I=s.useCallback(()=>{$(!1),y(""),k(0)},[]);s.useEffect(()=>A(!0),[]);const te=s.useMemo(()=>n.map(D=>D.value).join("\0"),[n]);s.useEffect(()=>{if(!E||e.length===0||n.length===0)return;const D=new Set(n.map(_=>_.value)),ee=e.filter(_=>D.has(_));no(e,ee)||r(ee)},[te]),s.useEffect(()=>{if(!h)return;function D(ee){var se,Q;const _=ee.target;!((se=W.current)!=null&&se.contains(_))&&!((Q=G.current)!=null&&Q.contains(_))&&I()}return document.addEventListener("mousedown",D),()=>document.removeEventListener("mousedown",D)},[I,h]),s.useEffect(()=>{h&&(k(0),F(),H&&setTimeout(()=>{var D;return(D=T.current)==null?void 0:D.focus()},0))},[h,H,F]),s.useEffect(()=>{if(h)return window.addEventListener("resize",F),window.addEventListener("scroll",F,!0),()=>{window.removeEventListener("resize",F),window.removeEventListener("scroll",F,!0)}},[h,F]),s.useEffect(()=>{if(B.length===0){k(0);return}k(D=>Math.min(D,B.length-1))},[B.length]),s.useEffect(()=>{if(w<0||!Z.current)return;const D=Z.current.children[w];D==null||D.scrollIntoView({block:"nearest"})},[w]);function U(D){if(!o){if(!h){(D.key==="Enter"||D.key===" "||D.key==="ArrowDown")&&(D.preventDefault(),$(!0));return}if(D.key==="Escape"){D.preventDefault(),I();return}if(D.key==="ArrowDown"){if(D.preventDefault(),B.length===0)return;k(ee=>Math.min(ee+1,B.length-1));return}if(D.key==="ArrowUp"){D.preventDefault(),k(ee=>Math.max(ee-1,0));return}if(D.key==="Enter"&&B[w]&&!B[w].disabled){D.preventDefault(),g(B[w].value);return}D.key==="Backspace"&&!M&&e.length&&(D.preventDefault(),le(e.slice(0,-1)))}}const K=t.jsxs("div",{ref:G,className:"overflow-hidden rounded-xl shadow-xl",style:{...C,background:"var(--bg-card)",border:"1px solid var(--border)"},children:[H&&t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",style:{borderBottom:"1px solid var(--border)"},children:[t.jsx(z.HiMagnifyingGlass,{className:"h-3.5 w-3.5 flex-shrink-0",style:{color:"var(--text-muted)"}}),t.jsx("input",{ref:T,value:M,onChange:D=>{y(D.target.value),k(0)},onKeyDown:D=>{(D.key==="ArrowDown"||D.key==="ArrowUp"||D.key==="Enter"||D.key==="Escape")&&(D.stopPropagation(),U(D))},placeholder:"Buscar…",className:"min-w-0 flex-1 bg-transparent text-sm outline-none",style:{color:"var(--text-main)"}}),M&&t.jsx("button",{type:"button","aria-label":"Limpiar búsqueda",onMouseDown:D=>{D.preventDefault(),y(""),k(0)},children:t.jsx(z.HiXMark,{className:"h-3.5 w-3.5",style:{color:"var(--text-muted)"}})})]}),e.length>0&&t.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:[t.jsxs("span",{children:[V.length," seleccionados",e.length>V.length?` (${e.length-V.length} no disponibles)`:""]}),t.jsx("button",{type:"button",onMouseDown:D=>{D.preventDefault(),P()},className:"font-semibold transition-colors hover:text-[var(--primary)]",children:x})]}),t.jsxs("ul",{ref:Z,role:"listbox","aria-multiselectable":"true",className:"overflow-y-auto",style:{maxHeight:H?220:200,scrollbarWidth:"thin",scrollbarColor:"var(--border) transparent",overscrollBehavior:"contain"},children:[B.map((D,ee)=>{const _=ee===w,se=ae.has(D.value);return t.jsxs("li",{role:"option","aria-selected":se,onMouseDown:Q=>{Q.preventDefault(),!D.disabled&&g(D.value)},onMouseEnter:()=>!D.disabled&&k(ee),className:"flex cursor-pointer items-center gap-2 px-3 py-2 text-sm transition-colors",style:{background:_?"var(--bg-hover)":se?"color-mix(in srgb, var(--primary) 6%, transparent)":"transparent",color:D.disabled?"var(--text-muted)":"var(--text-main)",cursor:D.disabled?"not-allowed":"pointer",opacity:D.disabled?.58:1},children:[t.jsx("span",{className:"flex h-4 w-4 flex-shrink-0 items-center justify-center rounded border",style:{borderColor:se?"var(--primary)":"var(--border)",background:se?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:se&&t.jsx(z.HiCheck,{className:"h-3 w-3"})}),D.color&&t.jsx("span",{className:"h-2.5 w-2.5 flex-shrink-0 rounded-full",style:{background:D.color}}),t.jsxs("span",{className:"flex min-w-0 flex-1 items-baseline gap-1 overflow-hidden",children:[t.jsx("span",{className:"truncate",children:D.label}),D.sublabel&&t.jsx("span",{className:"min-w-0 flex-shrink truncate",style:{color:"var(--text-muted)",fontSize:12},children:D.sublabel})]}),D.badge&&t.jsx("span",{className:"flex-shrink-0 text-xs",style:{color:"var(--text-muted)"},children:D.badge})]},D.value)}),B.length===0&&t.jsx("li",{className:"px-3 py-4 text-center text-sm",style:{color:"var(--text-muted)"},children:v})]})]});return t.jsxs("div",{ref:W,className:`relative ${l||"w-full"}`,style:i,onKeyDown:U,children:[t.jsxs("button",{type:"button",disabled:o,onClick:()=>{o||(h?I():$(!0))},className:"flex w-full items-center gap-2 rounded-lg text-left text-sm transition-colors focus:outline-none",style:{minHeight:ro(c),padding:ro(d),background:"var(--bg-input)",color:V.length?"var(--text-main)":"var(--text-muted)",border:h?"1px solid var(--primary)":"1px solid var(--border)",opacity:o?.5:1,cursor:o?"not-allowed":"pointer"},"aria-haspopup":"listbox","aria-expanded":h,children:[t.jsx("span",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-1.5 overflow-hidden",children:L.length?t.jsxs(t.Fragment,{children:[L.map(D=>t.jsxs("span",{className:`inline-flex items-center gap-1 rounded-md border px-1.5 py-0.5 text-xs font-semibold ${b?"max-w-[160px]":"max-w-full whitespace-normal"}`,style:{background:"var(--bg-card)",borderColor:"var(--border)",color:"var(--text-main)"},children:[D.color&&t.jsx("span",{className:"h-1.5 w-1.5 flex-shrink-0 rounded-full",style:{background:D.color}}),t.jsx("span",{className:b?"truncate":"break-words",children:D.label}),t.jsx("span",{role:"button",tabIndex:-1,"aria-label":`Quitar ${D.label}`,onMouseDown:ee=>{ee.preventDefault(),ee.stopPropagation(),g(D.value)},className:"flex-shrink-0 rounded-full p-0.5 transition-colors hover:bg-black/10",style:{color:"var(--text-muted)"},children:t.jsx(z.HiXMark,{className:"h-3 w-3"})})]},D.value)),oe>0&&t.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:["+",oe]})]}):t.jsx("span",{className:"truncate",children:a})}),V.length?t.jsx("span",{role:"button",tabIndex:-1,"aria-label":x,onMouseDown:D=>{D.preventDefault(),D.stopPropagation(),P()},className:"flex-shrink-0 rounded-full p-0.5 transition-colors hover:bg-black/10",style:{color:"var(--text-muted)"},children:t.jsx(z.HiXMark,{className:"h-3.5 w-3.5"})}):t.jsx(z.HiChevronDown,{className:"h-4 w-4 flex-shrink-0 transition-transform",style:{color:"var(--text-muted)",transform:h?"rotate(180deg)":"rotate(0deg)"}})]}),h&&N&&nt.createPortal(K,document.body)]})}function ud({inputMode:e="decimal",...r}){return t.jsx(Ca,{...r,type:"number",inputMode:e})}function fd(e,r,n){const a=[],o=Math.max(2,e-n),l=Math.min(r-1,e+n);a.push(1),o>2&&a.push("...");for(let i=o;i<=l;i+=1)a.push(i);return l<r-1&&a.push("..."),r>1&&a.push(r),a}function bd({page:e,totalPages:r,onPageChange:n,disabled:a=!1,siblingCount:o=1,className:l=""}){const i=Math.max(1,r),c=Math.min(Math.max(1,e),i),d=fd(c,i,o);return t.jsxs("nav",{"aria-label":"Paginacion",className:`inline-flex items-center gap-1 ${l}`,children:[t.jsx(je,{variant:"icon",size:"xs","aria-label":"Pagina anterior",disabled:a||c<=1,onClick:()=>n(c-1),children:t.jsx(z.HiChevronLeft,{className:"h-4 w-4"})}),d.map((u,m)=>u==="..."?t.jsx("span",{className:"flex h-8 min-w-8 items-center justify-center text-xs font-semibold text-[var(--text-muted)]",children:"..."},`ellipsis-${m}`):t.jsx("button",{type:"button","aria-current":u===c?"page":void 0,disabled:a,onClick:()=>n(u),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:u===c?"var(--primary)":"var(--border)",background:u===c?"var(--primary)":"var(--bg-card)",color:u===c?"var(--primary-fg)":"var(--text-secondary)"},children:u},u)),t.jsx(je,{variant:"icon",size:"xs","aria-label":"Pagina siguiente",disabled:a||c>=i,onClick:()=>n(c+1),children:t.jsx(z.HiChevronRight,{className:"h-4 w-4"})})]})}const ao=[{value:"+1",label:"+1",sublabel:"Estados Unidos, Canada, Caribe"},{value:"+7",label:"+7",sublabel:"Rusia, Kazajistan"},{value:"+20",label:"+20",sublabel:"Egipto"},{value:"+27",label:"+27",sublabel:"Sudafrica"},{value:"+30",label:"+30",sublabel:"Grecia"},{value:"+31",label:"+31",sublabel:"Paises Bajos"},{value:"+32",label:"+32",sublabel:"Belgica"},{value:"+33",label:"+33",sublabel:"Francia"},{value:"+34",label:"+34",sublabel:"Espana"},{value:"+36",label:"+36",sublabel:"Hungria"},{value:"+39",label:"+39",sublabel:"Italia, Vaticano"},{value:"+40",label:"+40",sublabel:"Rumania"},{value:"+41",label:"+41",sublabel:"Suiza"},{value:"+43",label:"+43",sublabel:"Austria"},{value:"+44",label:"+44",sublabel:"Reino Unido"},{value:"+45",label:"+45",sublabel:"Dinamarca"},{value:"+46",label:"+46",sublabel:"Suecia"},{value:"+47",label:"+47",sublabel:"Noruega"},{value:"+48",label:"+48",sublabel:"Polonia"},{value:"+49",label:"+49",sublabel:"Alemania"},{value:"+51",label:"+51",sublabel:"Peru"},{value:"+52",label:"+52",sublabel:"Mexico"},{value:"+53",label:"+53",sublabel:"Cuba"},{value:"+54",label:"+54",sublabel:"Argentina"},{value:"+55",label:"+55",sublabel:"Brasil"},{value:"+56",label:"+56",sublabel:"Chile"},{value:"+57",label:"+57",sublabel:"Colombia"},{value:"+58",label:"+58",sublabel:"Venezuela"},{value:"+60",label:"+60",sublabel:"Malasia"},{value:"+61",label:"+61",sublabel:"Australia"},{value:"+62",label:"+62",sublabel:"Indonesia"},{value:"+63",label:"+63",sublabel:"Filipinas"},{value:"+64",label:"+64",sublabel:"Nueva Zelanda"},{value:"+65",label:"+65",sublabel:"Singapur"},{value:"+66",label:"+66",sublabel:"Tailandia"},{value:"+81",label:"+81",sublabel:"Japon"},{value:"+82",label:"+82",sublabel:"Corea del Sur"},{value:"+84",label:"+84",sublabel:"Vietnam"},{value:"+86",label:"+86",sublabel:"China"},{value:"+90",label:"+90",sublabel:"Turquia"},{value:"+91",label:"+91",sublabel:"India"},{value:"+92",label:"+92",sublabel:"Pakistan"},{value:"+93",label:"+93",sublabel:"Afganistan"},{value:"+94",label:"+94",sublabel:"Sri Lanka"},{value:"+95",label:"+95",sublabel:"Myanmar"},{value:"+98",label:"+98",sublabel:"Iran"},{value:"+211",label:"+211",sublabel:"Sudan del Sur"},{value:"+212",label:"+212",sublabel:"Marruecos, Sahara Occidental"},{value:"+213",label:"+213",sublabel:"Argelia"},{value:"+216",label:"+216",sublabel:"Tunez"},{value:"+218",label:"+218",sublabel:"Libia"},{value:"+220",label:"+220",sublabel:"Gambia"},{value:"+221",label:"+221",sublabel:"Senegal"},{value:"+222",label:"+222",sublabel:"Mauritania"},{value:"+223",label:"+223",sublabel:"Mali"},{value:"+224",label:"+224",sublabel:"Guinea"},{value:"+225",label:"+225",sublabel:"Costa de Marfil"},{value:"+226",label:"+226",sublabel:"Burkina Faso"},{value:"+227",label:"+227",sublabel:"Niger"},{value:"+228",label:"+228",sublabel:"Togo"},{value:"+229",label:"+229",sublabel:"Benin"},{value:"+230",label:"+230",sublabel:"Mauricio"},{value:"+231",label:"+231",sublabel:"Liberia"},{value:"+232",label:"+232",sublabel:"Sierra Leona"},{value:"+233",label:"+233",sublabel:"Ghana"},{value:"+234",label:"+234",sublabel:"Nigeria"},{value:"+235",label:"+235",sublabel:"Chad"},{value:"+236",label:"+236",sublabel:"Republica Centroafricana"},{value:"+237",label:"+237",sublabel:"Camerun"},{value:"+238",label:"+238",sublabel:"Cabo Verde"},{value:"+239",label:"+239",sublabel:"Santo Tome y Principe"},{value:"+240",label:"+240",sublabel:"Guinea Ecuatorial"},{value:"+241",label:"+241",sublabel:"Gabon"},{value:"+242",label:"+242",sublabel:"Republica del Congo"},{value:"+243",label:"+243",sublabel:"Republica Democratica del Congo"},{value:"+244",label:"+244",sublabel:"Angola"},{value:"+245",label:"+245",sublabel:"Guinea-Bisau"},{value:"+246",label:"+246",sublabel:"Territorio Britanico del Oceano Indico"},{value:"+248",label:"+248",sublabel:"Seychelles"},{value:"+249",label:"+249",sublabel:"Sudan"},{value:"+250",label:"+250",sublabel:"Ruanda"},{value:"+251",label:"+251",sublabel:"Etiopia"},{value:"+252",label:"+252",sublabel:"Somalia"},{value:"+253",label:"+253",sublabel:"Yibuti"},{value:"+254",label:"+254",sublabel:"Kenia"},{value:"+255",label:"+255",sublabel:"Tanzania"},{value:"+256",label:"+256",sublabel:"Uganda"},{value:"+257",label:"+257",sublabel:"Burundi"},{value:"+258",label:"+258",sublabel:"Mozambique"},{value:"+260",label:"+260",sublabel:"Zambia"},{value:"+261",label:"+261",sublabel:"Madagascar"},{value:"+262",label:"+262",sublabel:"Reunion, Mayotte"},{value:"+263",label:"+263",sublabel:"Zimbabue"},{value:"+264",label:"+264",sublabel:"Namibia"},{value:"+265",label:"+265",sublabel:"Malaui"},{value:"+266",label:"+266",sublabel:"Lesoto"},{value:"+267",label:"+267",sublabel:"Botsuana"},{value:"+268",label:"+268",sublabel:"Esuatini"},{value:"+269",label:"+269",sublabel:"Comoras"},{value:"+290",label:"+290",sublabel:"Santa Elena"},{value:"+291",label:"+291",sublabel:"Eritrea"},{value:"+297",label:"+297",sublabel:"Aruba"},{value:"+298",label:"+298",sublabel:"Islas Feroe"},{value:"+299",label:"+299",sublabel:"Groenlandia"},{value:"+350",label:"+350",sublabel:"Gibraltar"},{value:"+351",label:"+351",sublabel:"Portugal"},{value:"+352",label:"+352",sublabel:"Luxemburgo"},{value:"+353",label:"+353",sublabel:"Irlanda"},{value:"+354",label:"+354",sublabel:"Islandia"},{value:"+355",label:"+355",sublabel:"Albania"},{value:"+356",label:"+356",sublabel:"Malta"},{value:"+357",label:"+357",sublabel:"Chipre"},{value:"+358",label:"+358",sublabel:"Finlandia, Aland"},{value:"+359",label:"+359",sublabel:"Bulgaria"},{value:"+370",label:"+370",sublabel:"Lituania"},{value:"+371",label:"+371",sublabel:"Letonia"},{value:"+372",label:"+372",sublabel:"Estonia"},{value:"+373",label:"+373",sublabel:"Moldavia"},{value:"+374",label:"+374",sublabel:"Armenia"},{value:"+375",label:"+375",sublabel:"Bielorrusia"},{value:"+376",label:"+376",sublabel:"Andorra"},{value:"+377",label:"+377",sublabel:"Monaco"},{value:"+378",label:"+378",sublabel:"San Marino"},{value:"+380",label:"+380",sublabel:"Ucrania"},{value:"+381",label:"+381",sublabel:"Serbia"},{value:"+382",label:"+382",sublabel:"Montenegro"},{value:"+383",label:"+383",sublabel:"Kosovo"},{value:"+385",label:"+385",sublabel:"Croacia"},{value:"+386",label:"+386",sublabel:"Eslovenia"},{value:"+387",label:"+387",sublabel:"Bosnia y Herzegovina"},{value:"+389",label:"+389",sublabel:"Macedonia del Norte"},{value:"+420",label:"+420",sublabel:"Chequia"},{value:"+421",label:"+421",sublabel:"Eslovaquia"},{value:"+423",label:"+423",sublabel:"Liechtenstein"},{value:"+500",label:"+500",sublabel:"Islas Malvinas"},{value:"+501",label:"+501",sublabel:"Belice"},{value:"+502",label:"+502",sublabel:"Guatemala"},{value:"+503",label:"+503",sublabel:"El Salvador"},{value:"+504",label:"+504",sublabel:"Honduras"},{value:"+505",label:"+505",sublabel:"Nicaragua"},{value:"+506",label:"+506",sublabel:"Costa Rica"},{value:"+507",label:"+507",sublabel:"Panama"},{value:"+508",label:"+508",sublabel:"San Pedro y Miquelon"},{value:"+509",label:"+509",sublabel:"Haiti"},{value:"+590",label:"+590",sublabel:"Guadalupe, San Bartolome"},{value:"+591",label:"+591",sublabel:"Bolivia"},{value:"+592",label:"+592",sublabel:"Guyana"},{value:"+593",label:"+593",sublabel:"Ecuador"},{value:"+594",label:"+594",sublabel:"Guayana Francesa"},{value:"+595",label:"+595",sublabel:"Paraguay"},{value:"+596",label:"+596",sublabel:"Martinica"},{value:"+597",label:"+597",sublabel:"Surinam"},{value:"+598",label:"+598",sublabel:"Uruguay"},{value:"+599",label:"+599",sublabel:"Caribe Neerlandes, Curazao"},{value:"+670",label:"+670",sublabel:"Timor Oriental"},{value:"+672",label:"+672",sublabel:"Antartida, Isla Norfolk"},{value:"+673",label:"+673",sublabel:"Brunei"},{value:"+674",label:"+674",sublabel:"Nauru"},{value:"+675",label:"+675",sublabel:"Papua Nueva Guinea"},{value:"+676",label:"+676",sublabel:"Tonga"},{value:"+677",label:"+677",sublabel:"Islas Salomon"},{value:"+678",label:"+678",sublabel:"Vanuatu"},{value:"+679",label:"+679",sublabel:"Fiyi"},{value:"+680",label:"+680",sublabel:"Palaos"},{value:"+681",label:"+681",sublabel:"Wallis y Futuna"},{value:"+682",label:"+682",sublabel:"Islas Cook"},{value:"+683",label:"+683",sublabel:"Niue"},{value:"+685",label:"+685",sublabel:"Samoa"},{value:"+686",label:"+686",sublabel:"Kiribati"},{value:"+687",label:"+687",sublabel:"Nueva Caledonia"},{value:"+688",label:"+688",sublabel:"Tuvalu"},{value:"+689",label:"+689",sublabel:"Polinesia Francesa"},{value:"+690",label:"+690",sublabel:"Tokelau"},{value:"+691",label:"+691",sublabel:"Micronesia"},{value:"+692",label:"+692",sublabel:"Islas Marshall"},{value:"+850",label:"+850",sublabel:"Corea del Norte"},{value:"+852",label:"+852",sublabel:"Hong Kong"},{value:"+853",label:"+853",sublabel:"Macao"},{value:"+855",label:"+855",sublabel:"Camboya"},{value:"+856",label:"+856",sublabel:"Laos"},{value:"+880",label:"+880",sublabel:"Banglades"},{value:"+886",label:"+886",sublabel:"Taiwan"},{value:"+960",label:"+960",sublabel:"Maldivas"},{value:"+961",label:"+961",sublabel:"Libano"},{value:"+962",label:"+962",sublabel:"Jordania"},{value:"+963",label:"+963",sublabel:"Siria"},{value:"+964",label:"+964",sublabel:"Irak"},{value:"+965",label:"+965",sublabel:"Kuwait"},{value:"+966",label:"+966",sublabel:"Arabia Saudita"},{value:"+967",label:"+967",sublabel:"Yemen"},{value:"+968",label:"+968",sublabel:"Oman"},{value:"+970",label:"+970",sublabel:"Palestina"},{value:"+971",label:"+971",sublabel:"Emiratos Arabes Unidos"},{value:"+972",label:"+972",sublabel:"Israel"},{value:"+973",label:"+973",sublabel:"Barein"},{value:"+974",label:"+974",sublabel:"Catar"},{value:"+975",label:"+975",sublabel:"Butan"},{value:"+976",label:"+976",sublabel:"Mongolia"},{value:"+977",label:"+977",sublabel:"Nepal"},{value:"+992",label:"+992",sublabel:"Tayikistan"},{value:"+993",label:"+993",sublabel:"Turkmenistan"},{value:"+994",label:"+994",sublabel:"Azerbaiyan"},{value:"+995",label:"+995",sublabel:"Georgia"},{value:"+996",label:"+996",sublabel:"Kirguistan"},{value:"+998",label:"+998",sublabel:"Uzbekistan"}];function so(e){return e==null?"":String(e)}function wn(e){return e?e.startsWith("+")?e:`+${e}`:"+1"}function md(e){return typeof e=="number"?`${e}px`:e}function pd({autoComplete:e="tel",inputMode:r="tel",validate:n=!0,invalidMessage:a="Ingresa un telefono valido.",errorDisplay:o="tooltip",error:l,value:i,defaultValue:c,onChange:d,countryCode:u,defaultCountryCode:m="+1",onCountryCodeChange:f,allowedCountryCodes:b,countryCodeOptions:v,countryCodePlaceholder:x="Codigo",countryCodeClassName:E="",countryCodeWidth:h=84,onPhoneValueChange:$,label:M,containerClassName:y="",helperText:w,helperDisplay:k="inline",labelAction:N,className:A="",required:C,disabled:j,floatingLabel:W,showPasswordToggle:G,nativeValidation:T,errorTooltipLabel:Z="Error de validacion",...H}){var Q;const[ae,X]=s.useState(()=>so(c)),[V,q]=s.useState(()=>wn(m)),L=s.useMemo(()=>{const de=v??ao,Se=b==null?void 0:b.map(wn);return Se!=null&&Se.length?de.filter(ie=>Se.includes(ie.value)):de},[b,v]),oe=((Q=L[0])==null?void 0:Q.value)??"+1",B=L.some(de=>de.value===wn(u??V))?wn(u??V):oe,F=i!==void 0?so(i):ae,le=`${B} ${F}`.trim(),g=n&&F.length>0&&!Na(le)?a:void 0,P=l??g,I=!!P,te=I&&o!=="tooltip",U=I&&o!=="inline",K=!!w&&k==="tooltip"&&!te,D=I?"border-[var(--danger)] focus-within:border-[var(--danger)]":"border-[var(--border)] focus-within:border-[var(--primary)]",ee=de=>{const Se=de.currentTarget.value;i===void 0&&X(Se),$==null||$(Se,{countryCode:B,nationalNumber:Se,fullNumber:`${B} ${Se}`.trim()}),d==null||d(de)},_=de=>{u===void 0&&q(de),f==null||f(de),$==null||$(F,{countryCode:de,nationalNumber:F,fullNumber:`${de} ${F}`.trim()})},se=U?t.jsx(zt,{as:"span",content:P,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(--danger)] outline-none transition-colors hover:bg-[var(--danger-bg)] focus-visible:bg-[var(--danger-bg)]",children:t.jsx("span",{tabIndex:0,role:"img","aria-label":Z,className:"flex h-full w-full items-center justify-center outline-none",children:t.jsx(Zs,{className:"h-[18px] w-[18px]"})})}):null;return t.jsxs("div",{className:`flex flex-col gap-2 ${y}`,children:[t.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-semibold uppercase text-[var(--text-muted)]",children:[t.jsx("span",{children:M}),C&&t.jsx("span",{className:"text-[var(--danger)]",children:"*"}),K?t.jsx(or,{content:w}):null,N&&t.jsx("span",{className:"ml-auto normal-case",children:N})]}),t.jsxs("span",{className:`flex h-10 min-w-0 items-center overflow-hidden rounded-lg border bg-[var(--bg-input)] transition-colors ${D}`,children:[t.jsx(jt,{value:B,onChange:_,options:L,placeholder:x,disabled:j,ariaLabel:"Codigo telefonico",triggerVariant:"ghost",showSelectedSublabel:!1,searchable:!0,minOptionsForSearch:0,dropdownMinWidth:300,className:`shrink-0 ${E}`,style:{width:md(h)},height:38,padding:"0 8px 0 10px"}),t.jsx("span",{className:"h-5 w-px shrink-0 bg-[var(--border)]"}),t.jsxs("span",{className:"relative min-w-0 flex-1 self-stretch",children:[t.jsx("input",{...H,value:i,defaultValue:c,type:"tel",inputMode:r,autoComplete:e,disabled:j,required:void 0,"aria-label":H["aria-label"]??(typeof M=="string"?M:void 0),"aria-invalid":I||H["aria-invalid"],className:`h-full w-full min-w-0 bg-transparent px-2 py-1.5 text-sm text-[var(--text-main)] outline-none placeholder:text-[var(--text-muted)] disabled:cursor-not-allowed disabled:opacity-60 ${U?"pr-10":""} ${A}`,onChange:ee}),se]})]}),t.jsx(lr,{error:te?P:void 0,helperText:w,helperDisplay:k})]})}function hd({value:e,onChange:r,options:n,name:a,label:o,orientation:l="vertical",disabled:i=!1,className:c="",optionClassName:d=""}){return t.jsxs("fieldset",{className:`min-w-0 ${c}`,disabled:i,children:[o&&t.jsx("legend",{className:"mb-2 text-xs font-semibold uppercase text-[var(--text-muted)]",children:o}),t.jsx("div",{className:l==="horizontal"?"flex flex-wrap gap-2":"flex flex-col gap-2",children:n.map(u=>{const m=u.value===e,f=i||u.disabled;return t.jsxs("label",{className:`inline-flex min-w-0 items-start gap-2 rounded-lg border px-2.5 py-1.5 transition-colors ${f?"cursor-not-allowed opacity-60":"cursor-pointer hover:bg-[var(--bg-input)]"} ${d}`,style:{borderColor:m?"color-mix(in srgb, var(--primary) 48%, var(--border))":"var(--border)",background:m?"color-mix(in srgb, var(--primary) 8%, transparent)":"var(--bg-card)"},children:[t.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:[t.jsx("input",{type:"radio",name:a,value:u.value,checked:m,disabled:f,onChange:()=>r(u.value),className:"absolute inset-0 opacity-0"}),t.jsx("span",{className:`h-2 w-2 rounded-full transition ${m?"scale-100 opacity-100":"scale-50 opacity-0"}`,style:{background:"var(--primary)"}})]}),t.jsxs("span",{className:"min-w-0",children:[t.jsx("span",{className:"block text-sm font-medium leading-5 text-[var(--text-main)]",children:u.label}),u.description&&t.jsx("span",{className:"block text-xs leading-5 text-[var(--text-muted)]",children:u.description})]})]},u.value)})})]})}const oo=()=>'<button type="button" class="rich-img-del" data-action="delete-img" title="Eliminar imagen"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor"><path fill-rule="evenodd" d="M9 2a1 1 0 0 0-.894.553L7.382 4H4a1 1 0 0 0 0 2v10a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V6a1 1 0 0 0 0-2h-3.382l-.724-1.447A1 1 0 0 0 11 2H9zm-1 6a1 1 0 1 1 2 0v4a1 1 0 1 1-2 0V8zm4 0a1 1 0 1 1 2 0v4a1 1 0 1 1-2 0V8z" clip-rule="evenodd"/></svg></button>',Wr=e=>e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;"),lo=e=>e.toLocaleLowerCase().replace(new RegExp("(^|[^\\p{L}\\p{N}])(\\p{L})","gu"),(r,n,a)=>`${n}${a.toLocaleUpperCase()}`),gd=e=>e.replace(/[<>]/g,"").toLowerCase(),vd=new Set(["p","br","div","span","b","strong","i","em","u","s","strike","ul","ol","li","h1","h2","h3","h4","blockquote","a","img","hr"]),yd=/^[\s\u00a0]*([•●○■▪▫◆◇►▶➢❖✓✔\-–—*])[\s\u00a0]+/,xd=e=>{const r=e.indexOf("<!--StartFragment-->"),n=e.indexOf("<!--EndFragment-->");if(r!==-1&&n!==-1&&n>r)return e.slice(r+20,n);const a=e.match(/<body[^>]*>([\s\S]*)<\/body>/i);return a?a[1]:e},kn=(e,r)=>r.test(e),wd=e=>kn(e,/font-weight\s*:\s*(bold|[6-9]00)/i),kd=e=>kn(e,/font-style\s*:\s*italic/i),Nd=e=>kn(e,/text-decoration(?:-line)?\s*:[^;]*underline/i),Sd=e=>kn(e,/text-decoration(?:-line)?\s*:[^;]*(line-through|linethrough)/i),Nn=(e,r)=>{var a;if(!e.childNodes.length||e.childNodes.length===1&&((a=e.firstChild)==null?void 0:a.nodeType)===Node.ELEMENT_NODE&&e.firstChild.tagName.toLowerCase()===r)return;const n=e.ownerDocument.createElement(r);for(;e.firstChild;)n.appendChild(e.firstChild);e.appendChild(n)},Sn=e=>{const r=e.parentNode;if(!r){e.remove();return}for(;e.firstChild;)r.insertBefore(e.firstChild,e);r.removeChild(e)},Cd=e=>{const r=e.getAttribute("class")??"",n=e.getAttribute("style")??"";return/mso-list/i.test(n)||/MsoListParagraph/i.test(r)||/MsoList/i.test(r)},io=e=>{const r=e.getAttribute("style")??"",n=e.textContent??"";return/mso-level-number-format\s*:\s*(decimal|arabic|roman|alpha)/i.test(r)||/^\s*\d+[.)]\s/.test(n)||/^\s*[a-zA-Z][.)]\s/.test(n)?"ol":"ul"},Ed=e=>{const n=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_TEXT).nextNode();if(!n||!n.textContent)return;const a=n.textContent.replace(yd,"").replace(/^\s*\d+[.)]\s+/,"").replace(/^\s*[a-zA-Z][.)]\s+/,"");a!==n.textContent&&(n.textContent=a)},Md=e=>{const r=Array.from(e.querySelectorAll("span, font, p, div, li, h1, h2, h3, h4"));r.sort((n,a)=>a.querySelectorAll("*").length-n.querySelectorAll("*").length),r.forEach(n=>{const a=n.getAttribute("style")??"";a&&(wd(a)&&Nn(n,"strong"),kd(a)&&Nn(n,"em"),Nd(a)&&Nn(n,"u"),Sd(a)&&Nn(n,"s"))})},$d=e=>{const r=Array.from(e.querySelectorAll("p, div")).filter(Cd);if(!r.length)return;let n=0;for(;n<r.length;){const a=r[n],o=io(a),l=[a];let i=n+1;for(;i<r.length;){const u=r[i];if(io(u)!==o)break;let m=l[l.length-1].nextSibling;for(;m&&m.nodeType===Node.TEXT_NODE&&!(m.textContent??"").trim();)m=m.nextSibling;if(m!==u)break;l.push(u),i++}const c=a.parentNode;if(!c){n=i;continue}const d=a.ownerDocument.createElement(o);c.insertBefore(d,a),l.forEach(u=>{Ed(u);const m=u.ownerDocument.createElement("li");for(;u.firstChild;)m.appendChild(u.firstChild);d.appendChild(m),u.remove()}),n=i}},Td=e=>e==="h1"?"h2":e==="h4"||e==="h5"||e==="h6"?"h3":e==="div"?"p":e,Ld=e=>{const r=xd(e.replace(/<!--\[if[\s\S]*?<!\[endif\]-->/gi,"").replace(/<xml[\s\S]*?<\/xml>/gi,"").replace(/<style[\s\S]*?<\/style>/gi,"").replace(/<\/?o:[^>]*>/gi,"").replace(/<\/?w:[^>]*>/gi,"").replace(/<\/?m:[^>]*>/gi,"")),o=new DOMParser().parseFromString(`<!DOCTYPE html><html><body>${r}</body></html>`,"text/html").body;o.querySelectorAll("script, style, meta, link, xml, title, head, iframe, object, embed, form, input, button, textarea, select, noscript").forEach(i=>i.remove()),Md(o),$d(o);const l=i=>{const c=Array.from(i.childNodes);if(i.nodeType===Node.ELEMENT_NODE){const d=i,u=d.tagName.toLowerCase();if(u==="html"||u==="body"){c.forEach(l);return}if(u==="font"){Sn(d),c.forEach(l);return}if(!vd.has(u)){Sn(d),c.forEach(l);return}const m=Td(u);if(m!==u){const f=d.ownerDocument.createElement(m);for(;d.firstChild;)f.appendChild(d.firstChild);d.replaceWith(f),l(f);return}if(Array.from(d.attributes).forEach(f=>{const b=f.name.toLowerCase(),v=f.value;if(b.startsWith("on")||b==="style"||b==="class"){d.removeAttribute(f.name);return}if(b==="lang"||b.startsWith("data-")||b.startsWith("mso-")){d.removeAttribute(f.name);return}if((b==="href"||b==="src")&&/^\s*javascript:/i.test(v)){d.removeAttribute(f.name);return}u!=="a"&&u!=="img"&&b!=="href"&&b!=="src"&&b!=="alt"&&(["href","src","alt","target","rel"].includes(b)||d.removeAttribute(f.name))}),u==="a"){const f=d.getAttribute("href");if(!f||/^\s*#/.test(f)&&f.length<2){Sn(d),c.forEach(l);return}d.setAttribute("target","_blank"),d.setAttribute("rel","noopener noreferrer"),d.classList.add("rich-link")}if(u==="img"){const f=d.getAttribute("src")??"";if(!f||/^\s*javascript:/i.test(f)||/^file:/i.test(f)||/scheme\s*=\s*["']?file/i.test(f)){d.remove();return}d.classList.add("rich-img"),Array.from(d.attributes).forEach(b=>{["src","alt","class"].includes(b.name.toLowerCase())||d.removeAttribute(b.name)})}if(u==="span"){Sn(d),c.forEach(l);return}}c.forEach(l)};return l(o),o.querySelectorAll("p, h2, h3, li").forEach(i=>{const c=(i.textContent??"").replace(/[\u00a0\s]+/g,"").trim(),d=i.querySelector("img, hr"),u=!c&&!d&&Array.from(i.childNodes).every(m=>m.nodeType===Node.TEXT_NODE||m.nodeType===Node.ELEMENT_NODE&&m.tagName.toLowerCase()==="br");(!c&&!d||u)&&i.remove()}),o.querySelectorAll("strong, b, em, i, u, s").forEach(i=>{let c=i.nextSibling;for(;c&&c.nodeType===Node.TEXT_NODE&&!(c.textContent??"").trim();)c=c.nextSibling;if(c&&c.nodeType===Node.ELEMENT_NODE&&c.tagName===i.tagName){const d=c;for(;d.firstChild;)i.appendChild(d.firstChild);d.remove()}}),o.innerHTML.replace(/<!--[\s\S]*?-->/g,"").replace(/&nbsp;/gi," ").replace(/(<br\s*\/?>\s*){3,}/gi,"<br><br>").replace(/<p>(?:\s|<br\s*\/?>)*<\/p>/gi,"").trim()},Da=e=>Wr(e).replace(/\r\n?/g,`
25
- `).split(/\n{2,}/).map(r=>`<p>${r.replace(/\n/g,"<br>")||"<br>"}</p>`).join(""),Ad=e=>new RegExp("\\p{L}","u").test(e),Ia=(e,r)=>{const n=e.trim();return!n||!Ad(n)?!1:r==="uppercase"?n===n.toLocaleUpperCase():r==="lowercase"?n===n.toLocaleLowerCase():n===lo(n)},co=e=>{const r=a=>{var o,l;if(!a.closest(".rich-img-wrap")){const i=document.createElement("span");i.className="rich-img-wrap",i.contentEditable="false",(o=a.parentNode)==null||o.insertBefore(i,a),i.appendChild(a),i.insertAdjacentHTML("beforeend",oo())}(l=a.closest(".rich-img-wrap"))==null||l.classList.add("rich-img-broken")};e.querySelectorAll("img").forEach(a=>{if(!a.complete||a.naturalWidth===0){a.addEventListener("error",()=>r(a),{once:!0}),a.addEventListener("load",()=>{a.naturalWidth===0&&r(a)},{once:!0});const o=a.src;a.src="",a.src=o}});const n=a=>{const o=a.target;o.tagName==="IMG"&&r(o)};return e.addEventListener("error",n,!0),()=>e.removeEventListener("error",n,!0)};function uo({value:e,onChange:r,placeholder:n="Escribe algo...",minHeight:a="80px",instanceId:o}){const l=s.useId(),i=o||l,c=s.useCallback(()=>document,[]),d=s.useRef(null),u=s.useRef(null),m=s.useRef(new Map),f=s.useRef(null),b=s.useRef(!1),v=s.useRef(e??""),x=s.useRef(r),E=s.useRef(!1),[h,$]=s.useState(()=>!e||e.trim()===""),[M,y]=s.useState(new Set),[w,k]=s.useState(null),[N,A]=s.useState(""),[C,j]=s.useState(""),[W,G]=s.useState(""),[T,Z]=s.useState(""),[H,ae]=s.useState(!1),X=s.useCallback(()=>b.current?u.current:d.current,[]);s.useEffect(()=>{x.current=r},[r]);const V=s.useCallback(()=>{const J=window.getSelection(),re=X();if(!J||!re||J.rangeCount===0||J.isCollapsed)return"";const be=J.getRangeAt(0);return!re.contains(be.startContainer)||!re.contains(be.endContainer)?"":J.toString()},[X]);s.useEffect(()=>{const J=e??"";if(E.current&&J===v.current){E.current=!1,$(!J||J.trim()==="");return}E.current=!1,v.current=J;const re=[d.current,u.current].filter(he=>!!he);re.forEach(he=>{he.innerHTML!==J&&(he.innerHTML=J)}),$(!J||J.trim()==="");const be=re.map(he=>co(he));return()=>be.forEach(he=>he())},[e]),s.useEffect(()=>{var he,Be;b.current=H;let J,re=0,be;if(H){const Te=d.current;Te&&(v.current=Te.innerHTML);const He=()=>{var ce;const Fe=u.current;if(!Fe){re=requestAnimationFrame(He);return}Fe.innerHTML!==v.current&&(Fe.innerHTML=v.current),J=co(Fe),$(((ce=Fe.textContent)==null?void 0:ce.trim())===""),be=setTimeout(()=>Fe.focus(),60)};re=requestAnimationFrame(He)}else{const Te=u.current,He=d.current,Fe=(Te==null?void 0:Te.innerHTML)??v.current,ce=v.current;v.current=Fe,He&&He.innerHTML!==Fe&&(He.innerHTML=Fe),Fe!==ce&&x.current(Fe),$(((Be=(he=Te??He)==null?void 0:he.textContent)==null?void 0:Be.trim())==="")}return()=>{re&&cancelAnimationFrame(re),be&&clearTimeout(be),J==null||J()}},[H]);const q=s.useCallback(()=>{const J=["bold","italic","underline","strikeThrough","insertUnorderedList","insertOrderedList","justifyLeft","justifyCenter","justifyRight","justifyFull"],re=new Set;J.forEach(he=>{try{c().queryCommandState(he)&&re.add(he)}catch{return}});try{const he=gd(c().queryCommandValue("formatBlock"));he&&re.add(`formatBlock:${he}`)}catch{}const be=V();Ia(be,"uppercase")&&re.add("__upper"),Ia(be,"lowercase")&&re.add("__lower"),Ia(be,"capitalize")&&re.add("__cap"),y(re)},[V,c]),L=()=>{var re;const J=X();J&&(v.current=J.innerHTML,E.current=!0,x.current(v.current),$(((re=J.textContent)==null?void 0:re.trim())===""))},oe=J=>{if(!J){const re=d.current;re&&(v.current=re.innerHTML)}ae(!J)},B=(J,re)=>{var be;(be=X())==null||be.focus(),c().execCommand(J,!1,re),L(),q()},F=J=>{B("formatBlock",J)},le=()=>{var J;(J=X())==null||J.focus(),c().execCommand("insertHTML",!1,"<hr><p><br></p>"),L(),q()},g=()=>{const J=window.getSelection();J&&J.rangeCount>0&&(f.current=J.getRangeAt(0).cloneRange())},P=()=>{const J=window.getSelection();J&&f.current&&(J.removeAllRanges(),J.addRange(f.current))},I=J=>{if(g(),J==="link"){const re=window.getSelection();j(re&&!re.isCollapsed?re.toString():""),A("")}J==="image"&&(G(""),Z("")),k(J)},te=()=>{var he;if(!N.trim())return;P(),(he=X())==null||he.focus();const J=window.getSelection(),be=(J&&!J.isCollapsed?J.toString():"")||C.trim()||N.trim();c().execCommand("insertHTML",!1,`<a href="${Wr(N.trim())}" target="_blank" rel="noopener noreferrer" class="rich-link">${Wr(be)}</a>`),L(),k(null)},U=(J,re="")=>`<span class="rich-img-wrap" contenteditable="false"><img src="${Wr(J)}" alt="${Wr(re)}" class="rich-img" />${oo()}</span>`,K=()=>{var J;W.trim()&&(P(),(J=X())==null||J.focus(),c().execCommand("insertHTML",!1,U(W.trim(),T.trim())),L(),k(null))},D=(J,re=1200,be=1200,he=.72)=>new Promise((Be,Te)=>{const He=new FileReader;He.onerror=Te,He.onload=Fe=>{var Ee;const ce=(Ee=Fe.target)==null?void 0:Ee.result,ue=new Image;ue.onerror=Te,ue.onload=()=>{let{width:Ie,height:Ae}=ue;if(Ie>re||Ae>be){const Ze=Math.min(re/Ie,be/Ae);Ie=Math.round(Ie*Ze),Ae=Math.round(Ae*Ze)}const Pe=document.createElement("canvas");Pe.width=Ie,Pe.height=Ae;const Ge=Pe.getContext("2d");if(!Ge){Be(ce);return}Ge.drawImage(ue,0,0,Ie,Ae),Be(Pe.toDataURL("image/jpeg",he))},ue.src=ce},He.readAsDataURL(J)}),ee=J=>{J.focus();const re=window.getSelection();if(!re||re.rangeCount===0||!J.contains(re.anchorNode)){const be=document.createRange();be.selectNodeContents(J),be.collapse(!1),re==null||re.removeAllRanges(),re==null||re.addRange(be)}},_=s.useRef(()=>{});_.current=J=>{const re=X();re&&(ee(re),c().execCommand("insertHTML",!1,J),re.querySelectorAll("p").forEach(be=>{!(be.textContent??"").replace(/[\u00a0\s]+/g,"")&&!be.querySelector("img, hr")&&be.remove()}),L(),q())};const se=s.useRef(D);se.current=D;const Q=s.useRef(U);Q.current=U;const de=s.useCallback(J=>{if(!J||m.current.has(J))return;const re=be=>{const he=be.clipboardData;if(!he)return;const Be=he.getData("text/html"),Te=he.getData("text/plain");if(Be||Te){be.preventDefault(),be.stopPropagation();try{const ue=Be?Ld(Be):Da(Te);if(!ue){Te&&_.current(Da(Te));return}_.current(ue)}catch{Te&&_.current(Da(Te))}return}const Fe=Array.from(he.items).find(ue=>ue.type.startsWith("image/"));if(!Fe)return;be.preventDefault(),be.stopPropagation();const ce=Fe.getAsFile();ce&&se.current(ce).then(ue=>{_.current(Q.current(ue,"imagen"))})};J.addEventListener("paste",re,!0),m.current.set(J,()=>{J.removeEventListener("paste",re,!0),m.current.delete(J)})},[]),Se=s.useCallback(J=>{var be;const re=d.current;re&&re!==J&&((be=m.current.get(re))==null||be()),d.current=J,J&&de(J)},[de]),ie=s.useCallback(J=>{var be;const re=u.current;re&&re!==J&&((be=m.current.get(re))==null||be()),u.current=J,J&&de(J)},[de]);s.useEffect(()=>{const J=m.current;return()=>{J.forEach(re=>re()),J.clear()}},[]);const pe=J=>{const re=window.getSelection(),be=X();if(!re||!be||re.rangeCount===0||re.isCollapsed)return;const he=re.getRangeAt(0);if(!be.contains(he.startContainer)||!be.contains(he.endContainer))return;const Be=he.toString();if(!Be)return;let Te=Be;J==="uppercase"?Te=Be.toLocaleUpperCase():J==="lowercase"?Te=Be.toLocaleLowerCase():Te=lo(Be),he.deleteContents();const He=document.createTextNode(Te);he.insertNode(He);const Fe=document.createRange();Fe.setStart(He,0),Fe.setEnd(He,Te.length),re.removeAllRanges(),re.addRange(Fe),f.current=Fe.cloneRange(),L(),q()},Ce=()=>{g(),q()},De=()=>{L(),q()},mt=()=>{requestAnimationFrame(()=>{var J;(J=X())==null||J.focus()})},xt=J=>{var re,be;if((J.metaKey||J.ctrlKey)&&J.key==="Enter"){if(J.preventDefault(),J.stopPropagation(),J.repeat)return;(re=X())==null||re.focus(),c().execCommand("insertLineBreak",!1)||c().execCommand("insertHTML",!1,"<br>"),L(),q();return}if(J.key==="Tab"){J.preventDefault(),(be=X())==null||be.focus(),c().execCommand("insertText",!1,"    "),L(),q();return}if(J.key==="Escape"){if(w){k(null);return}if(b.current){ae(!1);return}}w||(J.ctrlKey||J.metaKey)&&(J.key==="b"&&(J.preventDefault(),B("bold")),J.key==="i"&&(J.preventDefault(),B("italic")),J.key==="u"&&(J.preventDefault(),B("underline")),J.key==="k"&&(J.preventDefault(),I("link")))},We=()=>t.jsx("div",{className:"h-4 w-px flex-shrink-0 mx-1",style:{background:"var(--border)"}}),Le=(J,re,be,he,Be)=>{const Te=Be??(M.has(be)||be==="__link"&&w==="link"||be==="__img"&&w==="image");return t.jsx("button",{type:"button",title:re,tabIndex:-1,onFocus:mt,onMouseDown:He=>{He.preventDefault(),he?he():B(be)},className:"flex h-7 w-7 items-center justify-center rounded text-xs font-bold transition-colors",style:{color:Te?"var(--primary)":"var(--text-secondary)",background:Te?"rgba(59,130,246,0.12)":"transparent"},children:J},be)},ke=J=>{const re=J.target;if(re.closest("[data-action='delete-img']")){J.preventDefault();const be=re.closest(".rich-img-wrap");be&&(be.remove(),L())}},et=J=>t.jsxs(t.Fragment,{children:[w==="link"&&t.jsxs("div",{className:"flex flex-shrink-0 flex-wrap items-center gap-2 border-t px-3 py-2",style:{borderColor:"var(--border)",background:J},children:[t.jsx("input",{autoFocus:!0,type:"url",value:N,onChange:re=>A(re.target.value),onKeyDown:re=>{re.key==="Enter"&&(re.preventDefault(),te()),re.key==="Escape"&&k(null)},placeholder:"https://...",className:"min-w-0 flex-1 rounded px-2 py-1 text-xs focus:outline-none",style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-main)"}}),t.jsx("input",{type:"text",value:C,onChange:re=>j(re.target.value),onKeyDown:re=>{re.key==="Enter"&&(re.preventDefault(),te()),re.key==="Escape"&&k(null)},placeholder:"Texto (opcional)",className:"w-32 rounded px-2 py-1 text-xs focus:outline-none",style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-main)"}}),t.jsx("button",{type:"button",onClick:te,className:"rounded px-2.5 py-1 text-xs font-semibold text-white",style:{background:"var(--primary)"},children:"OK"}),t.jsx("button",{type:"button",onClick:()=>k(null),className:"rounded px-2 py-1 text-xs",style:{color:"var(--text-muted)"},children:"x"})]}),w==="image"&&t.jsxs("div",{className:"flex flex-shrink-0 flex-wrap items-center gap-2 border-t px-3 py-2",style:{borderColor:"var(--border)",background:J},children:[t.jsx("input",{autoFocus:!0,type:"url",value:W,onChange:re=>G(re.target.value),onKeyDown:re=>{re.key==="Enter"&&(re.preventDefault(),K()),re.key==="Escape"&&k(null)},placeholder:"URL de la imagen...",className:"min-w-0 flex-1 rounded px-2 py-1 text-xs focus:outline-none",style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-main)"}}),t.jsx("input",{type:"text",value:T,onChange:re=>Z(re.target.value),onKeyDown:re=>{re.key==="Enter"&&(re.preventDefault(),K()),re.key==="Escape"&&k(null)},placeholder:"Texto alt",className:"w-28 rounded px-2 py-1 text-xs focus:outline-none",style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-main)"}}),t.jsx("button",{type:"button",onClick:K,className:"rounded px-2.5 py-1 text-xs font-semibold text-white",style:{background:"var(--primary)"},children:"OK"}),t.jsx("button",{type:"button",onClick:()=>k(null),className:"rounded px-2 py-1 text-xs",style:{color:"var(--text-muted)"},children:"x"})]})]}),me=(J,re)=>t.jsxs("div",{className:"flex flex-shrink-0 flex-wrap items-center gap-0.5 border-t px-2 py-1",style:{borderColor:"var(--border)",background:re},children:[Le(t.jsx(z.HiArrowUturnLeft,{className:"h-4 w-4"}),"Deshacer","undo"),Le(t.jsx(z.HiArrowUturnRight,{className:"h-4 w-4"}),"Rehacer","redo"),We(),Le(t.jsx("span",{style:{fontSize:"10px"},children:"P"}),"Parrafo","__paragraph",()=>F("p"),M.has("formatBlock:p")||M.has("formatBlock:div")),Le(t.jsx(z.HiH2,{className:"h-4 w-4"}),"Titulo 2","__h2",()=>F("h2"),M.has("formatBlock:h2")),Le(t.jsx(z.HiH3,{className:"h-4 w-4"}),"Titulo 3","__h3",()=>F("h3"),M.has("formatBlock:h3")),Le(t.jsx("span",{style:{fontSize:"13px",lineHeight:1},children:"“"}),"Cita","__quote",()=>F("blockquote"),M.has("formatBlock:blockquote")),We(),Le(t.jsx("b",{children:"B"}),"Negrita (Ctrl+B)","bold"),Le(t.jsx("i",{children:"I"}),"Cursiva (Ctrl+I)","italic"),Le(t.jsx("u",{children:"U"}),"Subrayado (Ctrl+U)","underline"),Le(t.jsx("s",{children:"S"}),"Tachado","strikeThrough"),We(),Le(t.jsx(z.HiListBullet,{className:"h-4 w-4"}),"Lista sin orden","insertUnorderedList"),Le(t.jsx(z.HiNumberedList,{className:"h-4 w-4"}),"Lista numerada","insertOrderedList"),Le(t.jsx(z.HiArrowTurnUpLeft,{className:"h-4 w-4"}),"Disminuir sangria","outdent"),Le(t.jsx(z.HiArrowTurnDownRight,{className:"h-4 w-4"}),"Aumentar sangria","indent"),We(),Le(t.jsx(z.HiBars3BottomLeft,{className:"h-4 w-4"}),"Alinear izquierda","justifyLeft"),Le(t.jsx(z.HiBars3CenterLeft,{className:"h-4 w-4"}),"Centrar","justifyCenter"),Le(t.jsx(z.HiBars3BottomRight,{className:"h-4 w-4"}),"Alinear derecha","justifyRight"),Le(t.jsx(z.HiBars3,{className:"h-4 w-4"}),"Justificar","justifyFull"),We(),Le(t.jsx("span",{style:{fontSize:"10px"},children:"AA"}),"Mayusculas","__upper",()=>pe("uppercase")),Le(t.jsx("span",{style:{fontSize:"10px"},children:"aa"}),"Minusculas","__lower",()=>pe("lowercase")),Le(t.jsx("span",{style:{fontSize:"10px"},children:"Aa"}),"Capitalizar","__cap",()=>pe("capitalize")),We(),Le(t.jsx(z.HiLink,{className:"h-4 w-4"}),"Insertar enlace (Ctrl+K)","__link",()=>I("link")),Le(t.jsx(z.HiLinkSlash,{className:"h-4 w-4"}),"Quitar enlace","unlink"),Le(t.jsx(z.HiPhoto,{className:"h-4 w-4"}),"Insertar imagen","__img",()=>I("image")),Le(t.jsx(z.HiMinus,{className:"h-4 w-4"}),"Insertar separador","__divider",le),We(),Le(t.jsx(z.HiOutlinePaintBrush,{className:"h-4 w-4"}),"Limpiar formato","removeFormat"),Le(t.jsx(z.HiNoSymbol,{className:"h-4 w-4"}),"Quitar bloque","__clearBlock",()=>F("p")),We(),t.jsx("button",{type:"button",title:J?"Salir del modo de enfoque (Esc)":"Modo de enfoque",tabIndex:-1,onFocus:mt,onMouseDown:be=>{be.preventDefault(),oe(J)},className:"flex h-7 w-7 items-center justify-center rounded transition-colors",style:{color:"var(--text-secondary)"},children:J?t.jsx(z.HiArrowsPointingIn,{className:"h-4 w-4"}):t.jsx(z.HiArrowsPointingOut,{className:"h-4 w-4"})})]});return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"overflow-hidden rounded-lg transition-all duration-150 ring-1 ring-transparent focus-within:ring-primary/30",style:{border:"1px solid var(--border)"},children:[t.jsx("div",{ref:Se,contentEditable:!0,suppressContentEditableWarning:!0,"data-bonsaif-rich-instance":i,onInput:De,onKeyDown:xt,onKeyUp:Ce,onSelect:Ce,onMouseUp:Ce,onMouseDown:ke,"data-placeholder":n,className:`rich-editor px-3 py-2 text-sm focus:outline-none${h?" is-empty":""}`,style:{color:"var(--text-main)",background:"var(--bg-input)",minHeight:a,maxHeight:"320px",overflowY:"auto",lineHeight:"1.6"}}),et("var(--bg-input)"),me(!1,"var(--bg-input)")]}),t.jsxs(ba,{open:H,onClose:()=>ae(!1),title:"Modo de enfoque",subtitle:"Esc para salir",maxWidth:"920px",bodyClassName:"flex min-h-0 flex-col p-0",panelClassName:"h-[88vh]",backdropClassName:"bg-black/50 backdrop-blur-[2px]",children:[t.jsx("div",{ref:ie,contentEditable:!0,suppressContentEditableWarning:!0,"data-bonsaif-rich-instance":i,onInput:De,onKeyDown:xt,onKeyUp:Ce,onSelect:Ce,onMouseUp:Ce,onMouseDown:ke,"data-placeholder":n,className:`rich-editor min-h-0 flex-1 overflow-y-auto px-8 py-6 text-sm focus:outline-none${h?" is-empty":""}`,style:{color:"var(--text-main)",background:"var(--bg-card)",lineHeight:"1.75"}}),et("var(--bg-input)"),me(!0,"var(--bg-input)")]})]})}const fo="[a-zA-Z0-9._@-]+",Oa=new RegExp(`@(${fo})`,"g"),Dd=/[a-zA-Z0-9._@-]/,qr=new Set([" ",`
26
- `," ","\r"," ","(","[","{",".",",",";",":","!","?","¿","¡",")","]","}",'"',"'","«","»","/","\\","|","-","—","–"]);function bo(e,r){if(r<=0)return!0;const n=e[r-1]??"";return qr.has(n)}function mo(e,r,n){var a;if(r<0||r>e.length)return null;for(let o=r-1;o>=0;o-=1){if(e[o]!=="@"){const c=e[o]??"";if(qr.has(c)||!Dd.test(c))return null;continue}if((a=n==null?void 0:n.isInsideExistingMention)!=null&&a.call(n,o)||!(n!=null&&n.isTriggerBoundary?n.isTriggerBoundary(o):bo(e,o)))continue;const i=e.slice(o+1,r);return i.length>0&&!new RegExp(`^${fo}$`).test(i)?null:{query:i,triggerIndex:o,caretIndex:r}}return null}function po(e,r){var a;const n=dr(e,r);return n?!!((a=n.node.parentElement)!=null&&a.closest(".mention-chip")):!1}function ho(e,r){if(r<=0)return!0;const n=dr(e,r);if(!n){const o=e.textContent??"";return bo(o,r)}if(n.offset>0){const o=n.node.data[n.offset-1]??"";return qr.has(o)}let a=n.node.previousSibling;for(;a;){if(a.nodeType===Node.TEXT_NODE){const o=a.textContent??"";if(o.length===0){a=a.previousSibling;continue}return qr.has(o[o.length-1]??"")}if(a.nodeType===Node.ELEMENT_NODE){const o=a;if(o.classList.contains("mention-chip")||o.tagName==="BR"||/^(P|DIV|LI|H[1-6]|BLOCKQUOTE)$/i.test(o.tagName))return!0;const l=o.textContent??"";if(l.length===0){a=a.previousSibling;continue}return qr.has(l[l.length-1]??"")}a=a.previousSibling}return!0}function Ha(e,r){const n=e.textContent??"";return mo(n,r,{isTriggerBoundary:a=>ho(e,a),isInsideExistingMention:a=>po(e,a)})}function Ba(e){return e.toLowerCase().trim()}function go(e){return e?e.replace(/<style[^>]*>[\s\S]*?<\/style>/gi," ").replace(/<script[^>]*>[\s\S]*?<\/script>/gi," ").replace(/<br\s*\/?>/gi,`
23
+ </body></html>`,ke=window.open("","_blank");ke&&(ke.document.write(me),ke.document.close())}const Sa=()=>!Re||!mn?null:ct.createPortal(t.jsxs("div",{ref:ko,role:"menu",className:"overflow-hidden rounded-lg border p-1 shadow-xl",style:{...Tb,position:"fixed",zIndex:9999,minWidth:170,borderColor:"var(--border)",background:"var(--bg-card)"},children:[t.jsxs("button",{type:"button",role:"menuitem",className:"flex w-full items-center gap-2.5 rounded-md px-2.5 py-1.5 text-sm transition-colors hover:bg-[var(--bg-input)]",style:{color:"var(--text-main)"},onClick:()=>{(async()=>(Ct?await Ct():om(),ia(!1)))()},children:[t.jsx(q.HiTableCells,{className:"h-4 w-4 shrink-0 text-emerald-500"}),"Descargar CSV / Excel"]}),t.jsxs("button",{type:"button",role:"menuitem",className:"flex w-full items-center gap-2.5 rounded-md px-2.5 py-1.5 text-sm transition-colors hover:bg-[var(--bg-input)]",style:{color:"var(--text-main)"},onClick:()=>{(async()=>(Et?await Et():sm(),ia(!1)))()},children:[t.jsx(q.HiDocumentText,{className:"h-4 w-4 shrink-0 text-red-500"}),"Imprimir / PDF"]})]}),document.body),Ca=()=>{const p=Y&&Ye.trim().length>0,E=ge!=null&&ge.length?ge:p?[{key:"bql",label:"BQL",value:Ye}]:[],R=ie.filter(P=>{const ne=P.trim();return ne?!new Set(Ze.split(`
24
+ `).map(ke=>ke.trim()).filter(Boolean)).has(ne):!1}).slice(0,8);return!ae&&Co===0&&!Y&&!Re?null:t.jsxs("div",{className:"relative flex min-h-9 flex-wrap items-center justify-between gap-2 border-b rounded-t-lg px-2 py-1",style:{borderColor:"var(--border)",background:"var(--bg-input)"},children:[t.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[Co>0&&t.jsxs("button",{type:"button",onClick:Wb,className:"inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs font-medium text-[var(--primary)] transition-colors hover:bg-[var(--bg-card)]",children:[t.jsx(q.HiXMark,{className:"h-3.5 w-3.5"}),Co," filtros"]}),Y&&t.jsxs("div",{ref:wo,className:"relative flex min-w-0 flex-1 items-center gap-2",children:[t.jsxs("button",{type:"button",onClick:()=>{if(ot){it(!1);return}ha(),it(!0)},className:"inline-flex h-7 shrink-0 items-center gap-1.5 rounded-md border px-2 text-xs font-bold transition-colors",style:{background:ot?"var(--primary)":p?"color-mix(in srgb, var(--primary) 12%, transparent)":"var(--bg-card)",borderColor:ot||p?"var(--primary)":"var(--border)",color:ot?"var(--primary-fg)":"var(--primary)"},"aria-expanded":ot,title:"Abrir filtros BQL",children:[t.jsx(q.HiCommandLine,{className:"h-3.5 w-3.5"}),"BQL",p&&t.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-current"}),ot?t.jsx(q.HiChevronUp,{className:"h-3.5 w-3.5"}):t.jsx(q.HiChevronDown,{className:"h-3.5 w-3.5"})]}),t.jsx("span",{className:"hidden truncate text-xs text-[var(--text-muted)] sm:inline",children:re}),E.length>0&&t.jsxs("div",{className:"hidden min-w-0 items-center gap-1.5 overflow-hidden lg:flex",children:[E.slice(0,3).map(P=>t.jsxs("span",{className:"inline-flex max-w-44 items-center gap-1 truncate rounded-full px-2 py-1 text-xs font-medium",style:{background:"var(--bg-hover)",border:"1px solid var(--primary)",color:"var(--primary)"},children:[t.jsxs("span",{className:"text-[var(--text-muted)]",children:[P.label,":"]}),t.jsx("span",{className:"truncate",children:P.value})]},P.key)),E.length>3&&t.jsxs("span",{className:"text-xs text-[var(--text-muted)]",children:["+",E.length-3]})]}),p&&t.jsx("button",{type:"button","aria-label":"Limpiar BQL",title:"Limpiar BQL",onClick:ui,className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-[var(--text-muted)] transition-colors hover:bg-[var(--bg-card)] hover:text-[var(--primary)]",children:t.jsx(q.HiXMark,{className:"h-4 w-4"})}),ot&&ct.createPortal(t.jsxs("div",{ref:Jl,className:"flex flex-col gap-3 rounded-lg p-3 shadow-2xl",style:{...Sb,background:"var(--bg-card)",border:"1px solid color-mix(in srgb, var(--primary) 35%, var(--border))"},children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[de.map(P=>t.jsxs("button",{type:"button",onMouseDown:ne=>{ne.preventDefault(),ne.stopPropagation()},onClick:ne=>{ne.preventDefault(),ne.stopPropagation(),pa(P.bql)},className:"inline-flex h-7 items-center gap-1.5 rounded-md border px-2.5 text-xs font-semibold transition-colors hover:border-[var(--primary)] hover:text-[var(--primary)]",style:{background:"var(--bg-input)",borderColor:"var(--border)",color:"var(--text-secondary)"},children:[P.icon,P.label]},P.label)),he.length>0&&t.jsxs("button",{type:"button",onClick:()=>qt(P=>!P),className:"inline-flex h-7 items-center gap-1.5 rounded-md px-2 text-xs font-medium text-[var(--text-muted)] transition-colors hover:bg-[var(--bg-input)] hover:text-[var(--primary)]","aria-expanded":cr,children:[t.jsx(q.HiInformationCircle,{className:"h-3.5 w-3.5"}),"Ejemplos"]}),bn.length>0&&t.jsxs("button",{type:"button",onClick:()=>Hr(P=>!P),className:"inline-flex h-7 items-center gap-1.5 rounded-md px-2 text-xs font-medium text-[var(--text-muted)] transition-colors hover:bg-[var(--bg-input)] hover:text-[var(--primary)]","aria-expanded":fn,children:[t.jsx(q.HiClock,{className:"h-3.5 w-3.5"}),"Historial"]})]}),t.jsxs("div",{className:"overflow-hidden rounded-lg",style:{background:"var(--bg-input)",border:`1.5px solid ${Me?"var(--danger)":p?"var(--primary)":"var(--border)"}`},children:[t.jsx("textarea",{ref:No,value:Ze,rows:3,onChange:P=>Mo(P.target.value,P.target),onKeyDown:P=>{P.key==="Enter"&&!P.shiftKey&&(P.preventDefault(),di(Ze)),P.key==="Escape"&&it(!1)},placeholder:z,autoComplete:"off",spellCheck:!1,className:"block w-full px-4 py-3 text-sm outline-none",style:{background:"var(--bg-input)",color:"var(--text-main)",border:"none",fontFamily:"'SF Mono', 'Fira Code', 'Consolas', monospace",lineHeight:1.6,maxHeight:180,minHeight:88,overflowY:"auto",resize:"vertical"}}),R.length>0&&t.jsx("div",{className:"border-t border-[var(--border)] bg-[var(--bg-card)]",children:R.map(P=>t.jsx("button",{type:"button",onMouseDown:ne=>{ne.preventDefault(),ne.stopPropagation()},onClick:ne=>{ne.preventDefault(),ne.stopPropagation(),pa(P)},className:"block w-full px-4 py-2 text-left text-xs transition-colors hover:bg-[var(--bg-hover)] hover:text-[var(--primary)]",style:{fontFamily:"'SF Mono', 'Fira Code', 'Consolas', monospace"},children:P},P))})]}),t.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[t.jsx("span",{className:"min-w-0 text-xs",style:{color:Me?"var(--danger)":"var(--text-muted)"},children:Me??(p?`${E.length||1} filtro${(E.length||1)===1?"":"s"} activo${(E.length||1)===1?"":"s"}`:"Enter aplica la consulta. Shift + Enter agrega linea.")}),E.map(P=>t.jsxs("span",{className:"inline-flex max-w-56 items-center gap-1 truncate rounded-full px-2 py-1 text-xs font-medium",style:{background:"var(--bg-hover)",border:"1px solid var(--primary)",color:"var(--primary)"},children:[t.jsxs("span",{className:"text-[var(--text-muted)]",children:[P.label,":"]}),t.jsx("span",{className:"truncate",children:P.value})]},P.key))]}),fn&&bn.length>0&&t.jsxs("div",{className:"overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-input)]",children:[t.jsxs("div",{className:"flex items-center justify-between border-b border-[var(--border)] px-3 py-2",children:[t.jsxs("span",{className:"flex items-center gap-1.5 text-xs font-semibold text-[var(--text-secondary)]",children:[t.jsx(q.HiClock,{className:"h-3.5 w-3.5"}),"Historial"]}),t.jsxs("button",{type:"button",onClick:()=>{Br([]),Hr(!1)},className:"inline-flex items-center gap-1 rounded px-2 py-0.5 text-xs text-[var(--text-muted)]",children:[t.jsx(q.HiTrash,{className:"h-3 w-3"}),"Limpiar"]})]}),bn.map(P=>t.jsxs("div",{className:"group flex items-center gap-2 border-b border-[var(--border)] px-3 py-2 last:border-b-0",children:[t.jsx("button",{type:"button",onMouseDown:ne=>{ne.preventDefault(),ne.stopPropagation()},onClick:ne=>{ne.preventDefault(),ne.stopPropagation(),pa(P)},className:"min-w-0 flex-1 text-left",children:t.jsx("code",{className:"block truncate text-xs text-[var(--primary)]",children:P})}),t.jsx("button",{type:"button",onClick:()=>Br(ne=>ne.filter(me=>me!==P)),className:"rounded p-1 text-[var(--text-muted)] opacity-0 transition-opacity group-hover:opacity-100",children:t.jsx(q.HiXMark,{className:"h-3.5 w-3.5"})})]},P))]}),cr&&he.length>0&&t.jsx("div",{className:"grid gap-2 sm:grid-cols-2 lg:grid-cols-3",children:he.map(P=>t.jsxs("button",{type:"button",onMouseDown:ne=>{ne.preventDefault(),ne.stopPropagation()},onClick:ne=>{ne.preventDefault(),ne.stopPropagation(),pa(P.bql),qt(!1)},className:"rounded-lg border border-[var(--border)] bg-[var(--bg-input)] p-2 text-left transition-colors hover:border-[var(--primary)]",children:[t.jsx("code",{className:"block truncate text-xs text-[var(--primary)]",children:P.bql}),P.description&&t.jsx("span",{className:"mt-1 block text-xs text-[var(--text-muted)]",children:P.description})]},P.bql))}),t.jsxs("div",{className:"flex items-center justify-end gap-2 border-t border-[var(--border)] pt-3",children:[p&&t.jsxs("button",{type:"button",onClick:ui,className:"inline-flex h-8 items-center gap-1 rounded-md px-2.5 text-xs font-medium text-[var(--text-muted)] transition-colors hover:bg-[var(--bg-input)] hover:text-[var(--primary)]",children:[t.jsx(q.HiXMark,{className:"h-3.5 w-3.5"}),"Limpiar"]}),t.jsxs("button",{type:"button",onClick:()=>di(Ze),className:"inline-flex h-8 items-center gap-1.5 rounded-md bg-[var(--primary)] px-4 text-xs font-semibold text-[var(--primary-fg)] transition-opacity hover:opacity-90",children:[t.jsx(q.HiCheck,{className:"h-3.5 w-3.5"}),"Aplicar"]})]})]}),document.body)]})]}),Re&&t.jsx("button",{ref:ca,type:"button","aria-haspopup":"menu","aria-expanded":mn,"aria-label":"Exportar datos",title:"Exportar datos",onClick:()=>{var ne;const P=(ne=ca.current)==null?void 0:ne.getBoundingClientRect();P&&$b({top:P.bottom+4,right:window.innerWidth-P.right}),ia(me=>!me)},className:`inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-[var(--text-muted)] transition-colors hover:bg-[var(--bg-card)] hover:text-[var(--primary)] focus:bg-[var(--bg-card)] focus:text-[var(--primary)] ${mn?"bg-[var(--bg-card)] text-[var(--primary)]":""}`,children:t.jsx(q.HiArrowDownTray,{className:"h-4 w-4"})}),ae&&t.jsx("button",{type:"button","aria-haspopup":"menu","aria-expanded":Ke&&Ae==="visibility","aria-label":K,title:K,onClick:P=>bi(P,"visibility"),className:`inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-[var(--text-muted)] transition-colors hover:bg-[var(--bg-card)] hover:text-[var(--primary)] focus:bg-[var(--bg-card)] focus:text-[var(--primary)] ${Ke&&Ae==="visibility"?"bg-[var(--bg-card)] text-[var(--primary)]":""}`,children:t.jsx(q.HiCog6Tooth,{className:"h-4 w-4"})})]})},Mi=()=>{if(!em)return null;const p=Oc(st,Ho);return t.jsxs("div",{"aria-busy":a,className:`grid grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)] items-center gap-2 rounded-b-xl border-t text-xs select-none ${J?"px-2 py-0.5":"px-3 py-1"}`,style:{borderColor:"var(--border)",background:"var(--bg-input)"},children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx("span",{style:{color:"var(--text-muted)"},children:Ut===0?"0 filas":`${tm}–${rm} de ${Ut}`}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("span",{style:{color:"var(--text-muted)"},children:"Filas:"}),t.jsx(ar,{value:String(Ft),onChange:E=>nm(Number(E)),options:Ao.map(E=>({value:String(E),label:String(E)})),placeholder:"Filas",searchable:!1,disabled:a,height:X,padding:Z,className:"shrink-0 [&>button]:rounded-md [&>button]:text-xs [&_svg]:h-3.5 [&_svg]:w-3.5",style:{width:W}})]})]}),t.jsxs("div",{className:"flex items-center justify-center gap-0.5",children:[t.jsx("button",{disabled:a||st<=1,onClick:()=>Bo(st-1),onMouseEnter:E=>{E.currentTarget.disabled||(E.currentTarget.style.background="color-mix(in srgb, var(--primary) 14%, var(--bg-card))",E.currentTarget.style.color="var(--primary)")},onMouseLeave:E=>{E.currentTarget.style.background="transparent",E.currentTarget.style.color="var(--text-muted)"},className:"cursor-pointer rounded p-0.5 transition-colors disabled:cursor-not-allowed disabled:opacity-30",style:{background:"transparent",color:"var(--text-muted)"},children:t.jsx(q.HiChevronLeft,{className:"h-3.5 w-3.5"})}),p.map((E,R)=>E==="..."?t.jsx("span",{className:"px-1",style:{color:"var(--text-muted)"},children:"…"},`e${R}`):t.jsx("button",{disabled:a,onClick:()=>Bo(E),onMouseEnter:P=>{P.currentTarget.disabled||E===st||(P.currentTarget.style.background="color-mix(in srgb, var(--primary) 14%, var(--bg-card))",P.currentTarget.style.color="var(--primary)")},onMouseLeave:P=>{P.currentTarget.style.background=E===st?"var(--primary)":"transparent",P.currentTarget.style.color=E===st?"var(--primary-fg)":"var(--text-muted)"},className:"h-5 w-5 cursor-pointer rounded text-[11px] font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-60",style:{background:E===st?"var(--primary)":"transparent",color:E===st?"var(--primary-fg)":"var(--text-muted)"},children:E},E)),t.jsx("button",{disabled:a||st>=Ho,onClick:()=>Bo(st+1),onMouseEnter:E=>{E.currentTarget.disabled||(E.currentTarget.style.background="color-mix(in srgb, var(--primary) 14%, var(--bg-card))",E.currentTarget.style.color="var(--primary)")},onMouseLeave:E=>{E.currentTarget.style.background="transparent",E.currentTarget.style.color="var(--text-muted)"},className:"cursor-pointer rounded p-0.5 transition-colors disabled:cursor-not-allowed disabled:opacity-30",style:{background:"transparent",color:"var(--text-muted)"},children:t.jsx(q.HiChevronRight,{className:"h-3.5 w-3.5"})})]}),t.jsx("div",{"aria-hidden":"true"})]})},lm=()=>t.jsxs("div",{className:"w-full min-w-0 max-w-full flex flex-col rounded-lg overflow-hidden",style:{background:"var(--bg-card)",boxShadow:ya},children:[Na(),Sa(),Ca(),t.jsx("div",{ref:Rt,className:"min-w-0 max-w-full overflow-hidden",children:t.jsxs("div",{role:"table",className:"text-sm",style:{width:gn,minWidth:xa},children:[t.jsx("div",{role:"rowgroup",style:y?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:wa()}),t.jsx("div",{role:"rowgroup",children:Array.from({length:Math.min(6,s)}).map((p,E)=>t.jsxs("div",{role:"row",className:"grid",style:{gridTemplateColumns:jr,borderBottom:`1px solid ${Oe}`},children:[Tt&&t.jsx("div",{role:"cell",className:`${J?"px-2 py-1.5":"px-3 py-2"} w-10`,style:{borderBottom:`1px solid ${Oe}`,borderRight:`1px solid ${Oe}`}},"select-cell"),wt.map((R,P)=>t.jsx("div",{role:"cell",className:J?"px-2 py-1.5":"px-3 py-2",style:{borderBottom:`1px solid ${Oe}`,borderRight:`1px solid ${Oe}`},children:t.jsx("div",{className:"h-3.5 rounded-full animate-pulse",style:{background:"var(--border)",width:`${ri(E,P)}%`,minWidth:32}})},R.key))]},E))})]})})]}),Po="min-w-0 max-w-full overflow-hidden";return te&&Fe&&!bt?t.jsx(wn,{rows:s,columns:Math.max(4,wt.length||7)}):!a&&r.length===0&&!So?lm():a&&r.length===0?t.jsxs("div",{className:"w-full min-w-0 max-w-full flex flex-col rounded-lg overflow-hidden",style:{background:"var(--bg-card)",boxShadow:ya},children:[Na(),Sa(),Ca(),t.jsx("div",{ref:Rt,className:Po,children:t.jsx(_o.OverlayScrollbarsComponent,{options:{scrollbars:{autoHide:"leave",autoHideDelay:200}},className:"w-full",style:{maxHeight:ai,maxWidth:"100%"},defer:!0,children:t.jsxs("div",{role:"table",className:"text-sm",style:{width:gn,minWidth:xa},children:[t.jsx("div",{role:"rowgroup",style:y?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:wa()}),t.jsx("div",{role:"rowgroup",children:Array.from({length:s}).map((p,E)=>t.jsxs("div",{role:"row",className:"grid",style:{gridTemplateColumns:jr,borderBottom:`1px solid ${Oe}`},children:[Tt&&t.jsx("div",{role:"cell",className:`${J?"px-2 py-1.5":"px-3 py-2"} w-10`,style:{borderBottom:`1px solid ${Oe}`,borderRight:`1px solid ${Oe}`}},"select-cell"),wt.map((R,P)=>{const ne=ga[R.key],me=ne!==void 0,ke=R.key===Oo;return t.jsx("div",{role:"cell","data-dt-column-key":R.key,className:J?"px-2 py-1.5":"px-3 py-2",style:me?{position:"sticky",left:ne,zIndex:1,background:"color-mix(in srgb, var(--bg-card) 72%, transparent)",backdropFilter:"blur(10px)",WebkitBackdropFilter:"blur(10px)",boxShadow:ke?`3px 0 6px -2px rgba(0,0,0,0.10), inset 0 -1px 0 ${Oe}`:`inset 0 -1px 0 ${Oe}`,borderRight:`1px solid ${Oe}`}:{borderBottom:`1px solid ${Oe}`,borderRight:`1px solid ${Oe}`},children:t.jsx("div",{className:"h-3.5 rounded-full animate-pulse",style:{background:"var(--border)",width:`${ri(E,P)}%`,minWidth:32}})},R.key)})]},E))})]})})}),Mi()]}):!a&&r.length===0?t.jsxs("div",{className:"w-full min-w-0 max-w-full flex flex-col rounded-lg overflow-hidden",style:{background:"var(--bg-card)",boxShadow:ya},children:[Na(),Sa(),Ca(),t.jsx("div",{ref:Rt,className:Po,children:t.jsx("div",{role:"table",className:"text-sm",style:{width:gn,minWidth:xa},children:t.jsx("div",{role:"rowgroup",style:y?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:wa()})})}),t.jsxs("div",{className:"flex min-h-[180px] flex-col items-center justify-center gap-3 border-t px-6 py-12 text-center",style:{borderColor:Oe,background:"linear-gradient(180deg, color-mix(in srgb, var(--bg-input) 58%, transparent), var(--bg-card))"},children:[t.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:l??t.jsx(q.HiMagnifyingGlass,{className:"h-5 w-5"})}),t.jsx("p",{className:"max-w-sm text-sm font-medium",style:{color:"var(--text-main)"},children:i}),t.jsx("span",{className:"text-xs",style:{color:"var(--text-muted)"},children:"Ajusta la busqueda o cambia los filtros para ver mas informacion."})]})]}):t.jsxs("div",{className:"w-full min-w-0 max-w-full flex flex-col rounded-lg overflow-hidden",style:{background:"var(--bg-card)",boxShadow:ya},children:[Na(),Sa(),Ca(),t.jsx("div",{ref:Rt,className:Po,children:t.jsx(_o.OverlayScrollbarsComponent,{options:{scrollbars:{autoHide:"leave",autoHideDelay:200}},className:"w-full",style:{maxHeight:ai,maxWidth:"100%"},defer:!0,children:t.jsxs("div",{role:"table",className:"text-sm",style:{width:gn,minWidth:xa},children:[t.jsx("div",{role:"rowgroup",style:y?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:wa()}),t.jsx("div",{role:"rowgroup",children:vi.map((p,E)=>{const R=n(p),P=ki(x==null?void 0:x(p)),ne=E>0?ki(x==null?void 0:x(vi[E-1])):null,me=P&&P.key!==(ne==null?void 0:ne.key),ke=Tt&&k.has(R),Ce=Tt&&(!$||$(p)),Pe=Wr?(m==null?void 0:m(p))??!0:!1,qe=Pe&&hi.has(R),mt=!!d||v&&Pe,et=ke&&N?"color-mix(in srgb, var(--primary) 8%, var(--bg-card))":E%2===1?"color-mix(in srgb, var(--bg-input) 30%, var(--bg-card))":"var(--bg-card)";return t.jsxs(o.Fragment,{children:[me&&t.jsx("div",{role:"row",className:`grid ${P.className??""}`,style:{gridTemplateColumns:jr},children:t.jsx("div",{role:"cell",className:J?"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 ${Oe}`,borderRight:`1px solid ${Oe}`},children:t.jsx("div",{className:"flex min-w-0 items-center justify-between gap-3",children:t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"truncate text-xs font-semibold uppercase tracking-wider text-[var(--text-main)]",children:P.label}),P.description&&t.jsx("div",{className:"mt-0.5 truncate text-xs text-[var(--text-muted)]",children:P.description})]})})})}),t.jsxs("div",{role:"row",onClick:mt?ve=>{const Ee=ve.target;if(!(Ee!=null&&Ee.closest('[data-dt-disable-row-click="true"]'))){if(v&&Pe){yi(R);return}d==null||d(p)}}:void 0,className:`grid transition-colors ${mt?"cursor-pointer":""} ${T?T(p):""}`,style:{gridTemplateColumns:jr,"--dt-row-bg":et,"--dt-sticky-bg":et,background:"var(--dt-row-bg)",borderBottom:`1px solid ${Oe}`},onMouseEnter:ve=>{ke||(ve.currentTarget.style.setProperty("--dt-row-bg","var(--bg-hover)"),ve.currentTarget.style.setProperty("--dt-sticky-bg",am))},onMouseLeave:ve=>{ve.currentTarget.style.setProperty("--dt-row-bg",et),ve.currentTarget.style.setProperty("--dt-sticky-bg",et)},children:[Wr&&t.jsx("div",{role:"cell",className:`${J?"px-2 py-1.5":"px-3 py-2"} flex w-10 items-center justify-center`,style:{borderBottom:`1px solid ${Oe}`,borderRight:`1px solid ${Oe}`},"data-dt-disable-row-click":"true",children:Pe&&t.jsx("button",{type:"button","aria-label":qe?"Contraer fila":"Desplegar fila","aria-expanded":qe,onClick:ve=>{ve.stopPropagation(),yi(R)},className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-[var(--text-muted)] transition-colors hover:bg-[var(--bg-input)] hover:text-[var(--primary)]",children:qe?t.jsx(q.HiChevronDown,{className:"h-4 w-4"}):t.jsx(q.HiChevronRight,{className:"h-4 w-4"})})}),Tt&&t.jsx("div",{role:"cell",className:`${J?"px-2 py-1.5":"px-3 py-2"} flex w-10 items-center justify-center`,style:Do?{position:"sticky",left:0,zIndex:3,background:"var(--dt-sticky-bg)",boxShadow:`inset 0 -1px 0 ${Oe}`}:{borderBottom:`1px solid ${Oe}`,borderRight:`1px solid ${Oe}`},onClick:ve=>{ve.stopPropagation(),Ce&&g(R)},children:t.jsx(Nn,{size:"sm",checked:ke,disabled:!Ce,"aria-label":Ce?"Seleccionar fila":"Fila no seleccionable",containerClassName:"items-center",className:Ce?"cursor-pointer":"cursor-not-allowed opacity-50",onClick:ve=>ve.stopPropagation(),onChange:()=>{Ce&&g(R)}})}),wt.map(ve=>{const Ee=ga[ve.key],Ne=Ee!==void 0,xe=ve.key===Oo,we=or(ve);return t.jsx("div",{role:"cell","data-dt-column-key":ve.key,"data-dt-disable-row-click":ve.disableRowClick||we?"true":void 0,className:`${we?"px-2 py-1.5 justify-center text-center":`${J?"px-2 py-1.5":"px-3 py-2"} ${xi(ve.align)}`} flex min-w-0 items-center ${Tc} ${ve.className??""}`,style:{overflow:"hidden",whiteSpace:"nowrap",...Ne?{position:"sticky",left:Ee,zIndex:3,background:"var(--dt-sticky-bg)",boxShadow:xe?`3px 0 6px -2px rgba(0,0,0,0.10), inset 0 -1px 0 ${Oe}`:`inset 0 -1px 0 ${Oe}`,borderRight:`1px solid ${Oe}`}:{borderBottom:`1px solid ${Oe}`,borderRight:`1px solid ${Oe}`}},children:t.jsx(ss,{children:t.jsx("div",{"data-dt-autofit-content":!0,className:"inline-block max-w-none align-middle",children:ve.cell(p)})})},ve.key)})]}),qe&&u&&t.jsx("div",{role:"row",className:"grid",style:{gridTemplateColumns:jr},children:t.jsx("div",{role:"cell",className:J?"px-2 py-2":"px-3 py-3",style:{gridColumn:"1 / -1",background:"color-mix(in srgb, var(--bg-input) 60%, var(--bg-card))",borderBottom:`1px solid ${Oe}`},children:u(p)})})]},R)})})]})})}),Mi()]})}const Fc={email:{pattern:/^[^\s@]+@[^\s@]+\.[^\s@]+$/,message:"Correo inválido"},integer:{pattern:/^-?\d+$/,message:"Debe ser un número entero"},date:{pattern:/^\d{4}-\d{2}-\d{2}$/,message:"Fecha inválida"}};function Pc(e,r){if(r.minLength!==void 0&&e.length<r.minLength)return r.message??`Mínimo ${r.minLength} caracteres`;if(r.maxLength!==void 0&&e.length>r.maxLength)return r.message??`Máximo ${r.maxLength} caracteres`;if(!e)return null;if(r.preset){const n=Fc[r.preset];if(!n.pattern.test(e))return r.message??n.message}return r.pattern&&!r.pattern.test(e)?r.message??"Formato inválido":null}const _c=new Set(["Backspace","Delete","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Tab","Home","End","Enter","Escape"]);function zc({initialValue:e,type:r,mask:n,onCommit:a,onCancel:s}){const[l,i]=o.useState(e),c=o.useRef(null),d=(n==null?void 0:n.preset)==="date",u=d?"date":r==="number"?"number":"text";return o.useEffect(()=>{var m,b;(m=c.current)==null||m.focus(),d||(b=c.current)==null||b.select()},[d]),t.jsx("input",{ref:c,type:u,value:l,maxLength:n==null?void 0:n.maxLength,onChange:m=>i(m.target.value),onBlur:()=>s(),onKeyDown:m=>{m.key==="Enter"&&(m.preventDefault(),a(l)),m.key==="Escape"&&(m.preventDefault(),s()),(n==null?void 0:n.preset)==="integer"&&!m.ctrlKey&&!m.metaKey&&!_c.has(m.key)&&!/^[\d-]$/.test(m.key)&&m.preventDefault()},onClick:m=>m.stopPropagation(),className:"w-full min-w-0 border-0 bg-transparent p-0 text-sm text-[var(--text-main)] outline-none"})}function Wc({initialValue:e,options:r,loading:n,onCommit:a,onCancel:s}){const l=o.useRef(null);return o.useEffect(()=>{if(n)return;const i=setTimeout(()=>{var c,d;(d=(c=l.current)==null?void 0:c.querySelector("button"))==null||d.click()},0);return()=>clearTimeout(i)},[n]),t.jsx("div",{ref:l,className:"w-full",tabIndex:-1,onKeyDown:i=>{i.key==="Escape"&&(i.stopPropagation(),s())},children:t.jsx(ar,{value:e,onChange:i=>{a(i)},options:r,disabled:n,placeholder:n?"Cargando…":"Seleccionar…",triggerVariant:"ghost",height:30,padding:"0 6px",minOptionsForSearch:1,className:"w-full"})})}const jc={outline:"2px solid var(--primary)",outlineOffset:"-2px",borderRadius:"4px",background:"color-mix(in srgb, var(--primary) 5%, var(--bg-card))"},Pa={outline:"2px solid var(--primary)",outlineOffset:"-2px",borderRadius:"4px"};function qc({columns:e,data:r,getRowId:n,onCellUpdate:a,readOnly:s=!1,...l}){const[i,c]=o.useState(r),d=o.useRef(null);o.useEffect(()=>{d.current||c(r)},[r]);const[u,m]=o.useState(null);d.current=u;const[b,f]=o.useState(null),h=o.useRef(null);h.current=b;const[v,k]=o.useState({}),[g,A]=o.useState(null),$=o.useRef(null);$.current=g;const[N,T]=o.useState({}),[x,y]=o.useState({}),L=o.useRef(new Set),w=o.useRef(null);o.useEffect(()=>{var _;const C=document.activeElement;(!C||C===document.body)&&((_=w.current)==null||_.focus({preventScroll:!0}))},[]);const W=e.map(C=>{var _,ae,B;return`${C.key}:${((B=(ae=(_=C.editable)==null?void 0:_.select)==null?void 0:ae.options)==null?void 0:B.length)??-1}`}).join("|");o.useEffect(()=>{e.forEach(C=>{var B,I;const _=(I=(B=C.editable)==null?void 0:B.select)==null?void 0:I.options;if(!_)return;const ae=N[C.key];(!L.current.has(C.key)||(ae==null?void 0:ae.length)===0&&_.length>0)&&(L.current.add(C.key),T(M=>({...M,[C.key]:_})))})},[W]);const X=o.useCallback(async(C,_)=>{if(L.current.has(C))return;L.current.add(C);const{url:ae,fetchOptions:B}=_.select??{};if(!(!ae&&!B)){y(I=>({...I,[C]:!0}));try{let I=[];if(B)I=await B();else if(ae){const M=await fetch(ae);if(!M.ok)throw new Error("fetch failed");I=await M.json()}T(M=>({...M,[C]:I}))}catch{T(I=>({...I,[C]:[]}))}finally{y(I=>({...I,[C]:!1}))}}},[]),Z=o.useRef(i);Z.current=i;const D=o.useRef(a);D.current=a;const Q=o.useRef(n);Q.current=n;const j=o.useRef(e);j.current=e;const se=o.useRef(s);se.current=s,o.useEffect(()=>{if(e.length>0&&r.length>0){const C=e.find(_=>_.selectable!==!1);C&&f({rowId:n(r[0]),colKey:C.key})}},[]),o.useEffect(()=>{if(!b)return;const C=w.current;if(!C)return;const _=C.querySelector(`[data-cell-id="${b.rowId}:${b.colKey}"]`);if(!_)return;const ae=C.querySelector('[role="rowgroup"]');_.style.scrollMarginTop=`${(ae==null?void 0:ae.offsetHeight)??0}px`;const B=C.querySelector('[role="row"]');let I=0;B&&B.querySelectorAll('[role="cell"], [role="columnheader"]').forEach(M=>{M.style.position==="sticky"&&M.style.left!==""&&(I=Math.max(I,parseFloat(M.style.left)+M.offsetWidth))}),_.style.scrollMarginLeft=`${I}px`,_.scrollIntoView({block:"nearest",inline:"nearest"})},[b]);const te=o.useCallback(C=>{var I;const _=j.current,ae=new Set,B=[];(I=w.current)==null||I.querySelectorAll("[data-cell-id]").forEach(M=>{const oe=M.dataset.cellId.split(":")[0];ae.has(oe)||(ae.add(oe),B.push(oe))}),f(M=>{if(!M)return M;const oe=_.findIndex(H=>H.key===M.colKey),K=B.indexOf(M.rowId);let Y=oe,S=K;if(C==="up")S=Math.max(0,K-1);else if(C==="down")S=Math.min(B.length-1,K+1);else if(C==="left"){let H=oe-1;for(;H>=0&&_[H].selectable===!1;)H--;H>=0&&(Y=H)}else if(C==="right"){let H=oe+1;for(;H<_.length&&_[H].selectable===!1;)H++;H<_.length&&(Y=H)}return Y===oe&&S===K?M:{rowId:B[S],colKey:_[Y].key}})},[]),ee=o.useCallback((C=!0)=>{const _=d.current;m(null),_&&f(_),C&&setTimeout(()=>{var ae;return(ae=w.current)==null?void 0:ae.focus({preventScroll:!0})},0)},[]),U=o.useCallback(async(C,_,ae)=>{var ie;const B=j.current.find(ge=>ge.key===_);if(!(B!=null&&B.editable))return;const{field:I,type:M,mask:oe,validate:K}=B.editable,Y=M==="number"?ae===""?null:Number(ae):ae;if(oe){const ge=Pc(ae,oe);if(ge){k(Me=>({...Me,[`${C}:${_}`]:ge}));return}}if(K){const ge=K(Y);if(ge){k(Me=>({...Me,[`${C}:${_}`]:ge}));return}}const S=Q.current,H=Z.current.find(ge=>S(ge)===C);if(!H)return;const O=H[I];m(null),k(ge=>{const Me={...ge};return delete Me[`${C}:${_}`],Me});const re=Z.current,z=re.findIndex(ge=>S(ge)===C),de=re[Math.min(re.length-1,z+1)];if(f({rowId:S(de),colKey:_}),setTimeout(()=>{var Me,$e;const ge=document.activeElement;(!ge||ge===document.body||(Me=w.current)!=null&&Me.contains(ge))&&(($e=w.current)==null||$e.focus({preventScroll:!0}))},0),String(O??"")===String(Y??""))return;const he={...H,[I]:Y};c(ge=>ge.map(Me=>S(Me)===C?he:Me)),A({rowId:C,colKey:_});try{await((ie=D.current)==null?void 0:ie.call(D,{row:H,rowId:C,field:I,oldValue:O,newValue:Y}))}catch{c(ge=>ge.map(Me=>S(Me)===C?H:Me)),k(ge=>({...ge,[`${C}:${_}`]:"Error al guardar. Intenta de nuevo."}))}finally{A(null)}},[]),J=o.useCallback(C=>{if($.current){C.preventDefault();return}if(d.current)return;const _=h.current;if(!(!_||!["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Enter","Escape","Tab"].includes(C.key)))switch(C.preventDefault(),C.key){case"ArrowUp":te("up");break;case"ArrowDown":te("down");break;case"ArrowLeft":te("left");break;case"ArrowRight":te("right");break;case"Tab":te(C.shiftKey?"left":"right");break;case"Enter":{const B=j.current.find(I=>I.key===_.colKey);B!=null&&B.editable&&!se.current?(m(_),B.editable.type==="select"&&!L.current.has(_.colKey)&&X(_.colKey,B.editable)):te("down");break}}},[te,X]),ce=o.useMemo(()=>e.map(C=>{if(!C.editable||s){const ae={...C};if(delete ae.editable,delete ae.selectable,C.selectable===!1)return{...ae,disableRowClick:!0};const B=ae.cell;return{...ae,className:`relative ${ae.className??""}`.trim(),disableRowClick:!0,cell:I=>{const M=n(I),oe=(b==null?void 0:b.rowId)===M&&(b==null?void 0:b.colKey)===C.key;return t.jsxs(t.Fragment,{children:[t.jsx("span",{"data-cell-id":`${M}:${C.key}`,className:"absolute inset-0 z-10 cursor-default",onClick:()=>{var K;$.current||(f({rowId:M,colKey:C.key}),(K=w.current)==null||K.focus({preventScroll:!0}))}}),oe&&t.jsx("div",{className:"pointer-events-none absolute inset-0 z-20",style:Pa}),t.jsx("span",{className:"relative z-0 pointer-events-none",children:B(I)})]})}}}const _=C.editable;return{...C,className:`relative ${C.className??""}`.trim(),disableRowClick:!0,cell:ae=>{const B=n(ae),I=C.key,M=(u==null?void 0:u.rowId)===B&&(u==null?void 0:u.colKey)===I,oe=(b==null?void 0:b.rowId)===B&&(b==null?void 0:b.colKey)===I,K=v[`${B}:${I}`],Y=(g==null?void 0:g.rowId)===B&&(g==null?void 0:g.colKey)===I,S=ae[_.field],H=String(S??""),O=()=>{var z;$.current||(f({rowId:B,colKey:I}),m({rowId:B,colKey:I}),(z=w.current)==null||z.focus({preventScroll:!0}),_.type==="select"&&!L.current.has(I)&&X(I,_))};if(M){const z=_.type==="select"?t.jsx(Wc,{initialValue:H,options:N[I]??[],loading:x[I]??!1,onCommit:de=>U(B,I,de),onCancel:ee}):t.jsx(zc,{initialValue:H,type:_.type??"text",mask:_.mask,onCommit:de=>U(B,I,de),onCancel:ee});return t.jsx("div",{className:"absolute inset-0 flex items-center px-2",style:jc,onClick:de=>de.stopPropagation(),children:z})}const re=C.cell(ae);return t.jsxs(t.Fragment,{children:[t.jsx("span",{"data-cell-id":`${B}:${I}`,className:`peer absolute inset-0 z-10 ${Y?"cursor-wait":"cursor-pointer"}`,onClick:O}),oe&&!Y&&t.jsx("div",{className:"pointer-events-none absolute inset-0 z-20",style:Pa}),Y&&t.jsxs("div",{className:"pointer-events-none absolute inset-0 z-20 flex items-center gap-1.5 bg-[var(--bg-card)]/80 px-2",style:Pa,children:[t.jsx("span",{className:"h-3 w-3 shrink-0 animate-spin rounded-full border-2 border-[var(--text-muted)] border-t-transparent","aria-hidden":!0}),t.jsx("span",{className:"truncate text-xs text-[var(--text-muted)]",children:"Guardando…"})]}),t.jsx("span",{className:"relative z-0 inline-flex items-center gap-1 pointer-events-none",children:K?t.jsxs("span",{className:"flex items-center gap-1 text-red-500",children:[t.jsx(q.HiExclamationCircle,{className:"h-3.5 w-3.5 shrink-0"}),t.jsx("span",{className:"truncate text-xs",children:K})]}):t.jsx("span",{className:"truncate",children:re})}),!Y&&t.jsx(q.HiPencil,{className:"pointer-events-none absolute right-1 top-1/2 z-0 h-3 w-3 -translate-y-1/2 shrink-0 text-[var(--text-muted)] opacity-0 transition-opacity peer-hover:opacity-40"})]})}}}),[e,s,u,b,g,v,N,x,n,U,ee,X]);return t.jsx("div",{ref:w,tabIndex:0,onKeyDown:J,onBlur:C=>{var _;(_=w.current)!=null&&_.contains(C.relatedTarget)||setTimeout(()=>{var B,I;const ae=document.activeElement;ae&&((B=ae.closest)!=null&&B.call(ae,"[data-bonsaif-select-dropdown]"))||(I=w.current)!=null&&I.contains(ae)||ee(!1)},0)},style:{width:"100%",minWidth:0,outline:"none"},children:t.jsx(ls,{...l,columns:ce,data:i,getRowId:n})})}function nt(e){if(e)return new Date(`${e}T12:00:00`)}function kt(e){const r=e.getFullYear(),n=String(e.getMonth()+1).padStart(2,"0"),a=String(e.getDate()).padStart(2,"0");return`${r}-${n}-${a}`}function yr(e){return e.charAt(0).toUpperCase()+e.slice(1)}function is(e){return e.map(r=>nt(r)).filter(r=>!!r)}function Uc(e){if(!(e!=null&&e.length))return[];const r=new Set(e.map(kt));return Array.from(r).sort()}function _a(e){return new Intl.DateTimeFormat("es-MX",{weekday:"short"}).format(e)}function cs(e){const r=nt(e);if(!r)return e;const n=_a(r).replace(/\.$/u,"").replace(/^\w/u,s=>s.toUpperCase()),a=new Intl.DateTimeFormat("es-MX",{month:"short"}).format(r).replace(/\.$/u,"").toLowerCase();return`${n} - ${r.getDate()} ${a} ${r.getFullYear()}`}const za={weekend:{dayOfWeek:[0,6]}},Wa={weekend:"bonsaif-weekend"};function ja({children:e,className:r="",...n}){const a=String(e??"").toLowerCase().normalize("NFD").replace(new RegExp("\\p{M}","gu"),"").trim(),s=a.startsWith("sab")||a.startsWith("dom")||a==="s"||a==="d";return t.jsx("th",{...n,className:`${r} ${s?"bonsaif-weekday-weekend":""}`.trim(),children:e})}const Vc={background:"var(--primary)",color:"var(--primary-fg, #ffffff)",borderRadius:999},Yc={background:"color-mix(in srgb, var(--primary) 22%, transparent)",color:"var(--text-main)",borderRadius:999};function Xc({day:e,modifiers:r,...n}){const a=r.range_start||r.range_end||r.selected&&!r.range_middle,s=!!r.range_middle,l=!!r.weekend||e.date.getDay()===0||e.date.getDay()===6;return t.jsx("button",{...n,type:"button",className:`bonsaif-multi-day-btn${a?" is-range-edge":""}${s?" is-range-middle":""}${l?" bonsaif-day-weekend":""} ${n.className??""}`,style:{...a?Vc:null,...s?Yc:null,...l?{fontWeight:800}:null,...n.style}})}function Kc({startDate:e,endDate:r,onChange:n,minDate:a,viewMonth:s,numberOfMonths:l=1,orientation:i="horizontal",showSummary:c=!0,startLabel:d="Inicio",endLabel:u="Regreso",className:m=""}){const b={from:nt(e),to:nt(r)},f=nt(a),[h,v]=o.useState(()=>nt(s||e)??new Date);o.useEffect(()=>{const N=nt(s||e);N&&v(N)},[s,e]);const k=o.useMemo(()=>{if(l<=1)return yr(new Intl.DateTimeFormat("es-MX",{month:"long",year:"numeric"}).format(h));const N=new Date(h.getFullYear(),h.getMonth()+l-1,1),T=h.getFullYear()===N.getFullYear(),x=new Intl.DateTimeFormat("es-MX",{month:"short",...T?{}:{year:"numeric"}}).format(h),y=new Intl.DateTimeFormat("es-MX",{month:"short",year:"numeric"}).format(N);return`${yr(x)} – ${yr(y)}`},[h,l]);function g(){v(new Date(h.getFullYear(),h.getMonth()-1,1))}function A(){v(new Date(h.getFullYear(),h.getMonth()+1,1))}const $=l>1?`bonsaif-range-months bonsaif-range-months--multi bonsaif-range-months--${i}`:"bonsaif-range-months";return t.jsxs("div",{className:`bonsaif-calendar bonsaif-date-range-picker ${m}`.trim(),children:[t.jsxs("div",{className:"bonsaif-cal-shell",children:[t.jsxs("div",{className:"bonsaif-cal-toolbar",children:[t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn","aria-label":"Mes anterior",onClick:g,children:t.jsx(q.HiChevronLeft,{size:16})}),t.jsx("span",{className:"bonsaif-cal-title",children:k}),t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn","aria-label":"Mes siguiente",onClick:A,children:t.jsx(q.HiChevronRight,{size:16})})]}),t.jsx(Ta.DayPicker,{mode:"range",selected:b,month:h,onMonthChange:v,onSelect:N=>{const T=N!=null&&N.from?kt(N.from):e,x=N!=null&&N.to?kt(N.to):"";n({startDate:T,endDate:x})},numberOfMonths:l,hideNavigation:!0,weekStartsOn:1,disabled:f?{before:f}:void 0,showOutsideDays:!1,modifiers:za,modifiersClassNames:Wa,components:{DayButton:Xc,Weekday:ja},classNames:{root:"bonsaif-range-daypicker w-full",months:$,month:l>1?"bonsaif-multi-month bonsaif-range-month-card":"bonsaif-multi-month",month_caption:l>1?"bonsaif-range-month-caption":"bonsaif-multi-caption-hidden",month_grid:"bonsaif-multi-month-grid",weekdays:"bonsaif-multi-weekdays",weekday:"bonsaif-multi-weekday",week:"bonsaif-multi-week",day:"bonsaif-multi-day",day_button:"bonsaif-multi-day-btn",selected:"bonsaif-range-day-selected",range_start:"bonsaif-range-start",range_middle:"bonsaif-range-middle",range_end:"bonsaif-range-end",today:"bonsaif-multi-day-today",disabled:"bonsaif-multi-day-disabled",hidden:"bonsaif-multi-day-hidden"},formatters:{formatCaption:N=>`${yr(new Intl.DateTimeFormat("es-MX",{month:"long"}).format(N))} ${N.getFullYear()}`,formatWeekdayName:_a}})]}),c?t.jsx("div",{className:"bonsaif-cal-summary",children:e?t.jsxs("div",{className:"bonsaif-cal-chips",children:[t.jsxs("span",{className:"bonsaif-cal-chip bonsaif-cal-chip--static",children:[d,": ",e]}),r?t.jsxs("span",{className:"bonsaif-cal-chip bonsaif-cal-chip--static",children:[u,": ",r]}):null]}):t.jsx("span",{children:"Sin rango seleccionado"})}):null]})}function ds({day:e,modifiers:r,onDayPointerDown:n,onDayPointerEnter:a,onDayClickSelect:s,...l}){const i=!!(r.disabled||r.hidden),c=!!r.weekend||e.date.getDay()===0||e.date.getDay()===6;return t.jsx("button",{...l,type:"button",disabled:i||l.disabled,className:`${l.className??""}${c?" bonsaif-day-weekend":""}`,style:{...c?{fontWeight:800}:null,...l.style},onPointerDown:d=>{var u;i||(n==null||n(e.date,d),(u=l.onPointerDown)==null||u.call(l,d))},onPointerEnter:()=>{i||a==null||a(e.date)},onClick:d=>{i||(d.preventDefault(),d.stopPropagation(),s==null||s(e.date,d))}})}function us(e,r){const n=nt(e),a=nt(r);if(!n||!a)return[];const s=n<=a?n:a,l=n<=a?a:n,i=[],c=new Date(s);for(;c<=l;)i.push(kt(c)),c.setDate(c.getDate()+1);return i}function fs(e,r=1){const n=e.getDay(),a=r===1?(n+6)%7:n,s=new Date(e);return s.setHours(12,0,0,0),s.setDate(s.getDate()-a),Array.from({length:7},(l,i)=>{const c=new Date(s);return c.setDate(s.getDate()+i),c})}function Rr(e,r,n){const a=new Set(e);for(const s of r)n==="add"?a.add(s):n==="remove"||a.has(s)?a.delete(s):a.add(s);return Array.from(a).sort()}function Gc(e,r){return typeof r!="number"||r<=0||e.length<=r?e:e.slice(-r)}function Zc(e,r,n){return!!(r&&e<r||n&&e>n)}function bs({value:e,onChange:r,disabled:n=!1,minDate:a,maxDate:s,maxDates:l,isDateDisabled:i,retainOutsidePrefix:c}){const d=o.useRef(null),u=o.useRef(null),m=o.useRef(!1),b=o.useRef(e);b.current=e;const f=o.useCallback(x=>{let y=x;if(c){const L=b.current.filter(W=>!W.startsWith(c)),w=x.filter(W=>W.startsWith(c));y=[...L,...w].sort()}r==null||r(Gc(y,l))},[l,r,c]),h=o.useCallback((x,y=!1)=>Zc(x,a,s)?!0:!(!(i!=null&&i(x))||y&&b.current.includes(x)),[i,s,a]),v=o.useCallback(x=>x.filter(y=>!h(y)),[h]),k=o.useCallback(()=>{u.current=null},[]);o.useEffect(()=>{const x=()=>k();return window.addEventListener("pointerup",x),window.addEventListener("pointercancel",x),()=>{window.removeEventListener("pointerup",x),window.removeEventListener("pointercancel",x)}},[k]);const g=o.useCallback((x,y,L,w)=>{const W=v(us(x,y));f(L==="add"?Rr(w,W,"add"):Rr(w,W,"remove"))},[f,v]),A=o.useCallback((x,y)=>{if(n||y.button!==0)return;const L=kt(x);if(h(L,!0)||y.shiftKey)return;m.current=!0;const w=[...b.current],W=w.includes(L)?"remove":"add";W==="add"&&h(L)||(u.current={active:!0,mode:W,anchor:L,latest:L,baseline:w},d.current=L,g(L,L,W,w),y.preventDefault())},[g,n,h]),$=o.useCallback(x=>{const y=u.current;if(!(y!=null&&y.active)||n)return;const L=kt(x);y.mode==="add"&&h(L)||y.latest!==L&&(y.latest=L,g(y.anchor,L,y.mode,y.baseline))},[g,n,h]),N=o.useCallback((x,y)=>{if(n)return;const L=kt(x);if(!h(L,!0)){if(m.current&&!y.shiftKey){m.current=!1,y.preventDefault(),y.stopPropagation();return}if(m.current=!1,y.shiftKey&&d.current){y.preventDefault(),y.stopPropagation();const w=v(us(d.current,L));f(Rr(b.current,w,"add"));return}!b.current.includes(L)&&h(L)||(d.current=L,f(Rr(b.current,[L],"toggle")))}},[f,n,v,h]),T=o.useCallback(x=>{if(n)return;const y=v(Uc(x));if(!y.length)return;const L=y.every(w=>b.current.includes(w));f(Rr(b.current,y,L?"remove":"add")),d.current=y[0]??d.current},[f,n,v]);return{onDayPointerDown:A,onDayPointerEnter:$,onDayClick:N,toggleWeek:T,endDrag:k}}function en(e){return fs(e,1)[0]}function ms(e,r){const n=new Date(e);return n.setDate(n.getDate()+r),n}function Qc({value:e=[],onChange:r,minDate:n,maxDate:a,isDateDisabled:s,viewMonth:l,maxDates:i,showWeekNumbers:c=!1,viewMode:d,defaultViewMode:u="month",onViewModeChange:m,showSummary:b=!0,className:f="",disabled:h=!1}){const v=o.useMemo(()=>is(e),[e]),k=o.useMemo(()=>new Set(e),[e]),g=nt(n),A=nt(a),[$,N]=o.useState(()=>nt(l||e[0])??new Date),[T,x]=o.useState(()=>en(nt(l||e[0])??new Date)),[y,L]=o.useState(u),w=d??y;function W(C){d===void 0&&L(C),m==null||m(C)}o.useEffect(()=>{const C=nt(l);C&&(N(C),x(en(C)))},[l]);const{onDayPointerDown:X,onDayPointerEnter:Z,onDayClick:D,toggleWeek:Q}=bs({value:e,onChange:r,disabled:h,minDate:n,maxDate:a,maxDates:i,isDateDisabled:s}),j=o.useMemo(()=>{if(h)return!0;const C=[];return g&&C.push({before:g}),A&&C.push({after:A}),s&&C.push(_=>s(kt(_))),C.length>0?C:void 0},[h,s,A,g]),se=o.useCallback(C=>t.jsx(ds,{...C,className:`bonsaif-multi-day-btn ${C.className??""}`,onDayPointerDown:X,onDayPointerEnter:Z,onDayClickSelect:D}),[D,X,Z]),te=o.useMemo(()=>fs(T,1),[T]),ee=te[6],U=w==="week"?`${new Intl.DateTimeFormat("es-MX",{day:"numeric",month:"short"}).format(te[0])} – ${new Intl.DateTimeFormat("es-MX",{day:"numeric",month:"short",year:"numeric"}).format(ee)}`:yr(new Intl.DateTimeFormat("es-MX",{month:"long",year:"numeric"}).format($));function J(){if(w==="week"){const C=ms(T,-7);x(en(C)),N(C);return}N(new Date($.getFullYear(),$.getMonth()-1,1))}function ce(){if(w==="week"){const C=ms(T,7);x(en(C)),N(C);return}N(new Date($.getFullYear(),$.getMonth()+1,1))}return t.jsxs("div",{className:`bonsaif-calendar bonsaif-multi-date-calendar ${f}`,children:[t.jsxs("div",{className:"bonsaif-cal-shell",children:[t.jsxs("div",{className:"bonsaif-cal-view-toggle",role:"tablist","aria-label":"Vista",children:[t.jsx("button",{type:"button",role:"tab","aria-selected":w==="month",className:`bonsaif-cal-view-btn${w==="month"?" is-active":""}`,disabled:h,onClick:()=>{W("month"),N(T)},children:"Mes"}),t.jsx("button",{type:"button",role:"tab","aria-selected":w==="week",className:`bonsaif-cal-view-btn${w==="week"?" is-active":""}`,disabled:h,onClick:()=>{W("week"),x(en($))},children:"Semana"})]}),t.jsxs("div",{className:"bonsaif-cal-toolbar",children:[t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn","aria-label":w==="week"?"Semana anterior":"Mes anterior",disabled:h,onClick:J,children:t.jsx(q.HiChevronLeft,{size:16})}),t.jsx("span",{className:"bonsaif-cal-title",children:U}),t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn","aria-label":w==="week"?"Semana siguiente":"Mes siguiente",disabled:h,onClick:ce,children:t.jsx(q.HiChevronRight,{size:16})})]}),t.jsxs("p",{className:"bonsaif-cal-hint",children:["Click · Shift+click rango · Arrastra",c&&w==="month"?" · Semana (nº)":"",w==="week"?" · Botón semana completa":""]}),w==="month"?t.jsx(Ta.DayPicker,{mode:"multiple",required:!1,selected:v,month:$,onMonthChange:N,onSelect:()=>{},hideNavigation:!0,showOutsideDays:!1,weekStartsOn:1,showWeekNumber:c,onWeekNumberClick:(C,_)=>{Q(_)},disabled:j,className:"bonsaif-multi-daypicker",modifiers:za,modifiersClassNames:Wa,classNames:{root:"bonsaif-multi-daypicker",months:"bonsaif-multi-months",month:"bonsaif-multi-month",month_caption:"bonsaif-multi-caption-hidden",month_grid:"bonsaif-multi-month-grid",weekdays:c?"bonsaif-multi-weekdays bonsaif-multi-weekdays--with-week":"bonsaif-multi-weekdays",weekday:"bonsaif-multi-weekday",week:c?"bonsaif-multi-week bonsaif-multi-week--with-week":"bonsaif-multi-week",week_number:"bonsaif-week-number",week_number_header:"bonsaif-week-number-header",day:"bonsaif-multi-day",day_button:"bonsaif-multi-day-btn",selected:"bonsaif-multi-day-selected",today:"bonsaif-multi-day-today",disabled:"bonsaif-multi-day-disabled",hidden:"bonsaif-multi-day-hidden"},components:{DayButton:se,Weekday:ja},formatters:{formatWeekdayName:_a}}):t.jsxs("div",{className:"bonsaif-week-view",children:[t.jsx("div",{className:"bonsaif-week-view-head",children:te.map(C=>t.jsx("div",{className:"bonsaif-multi-weekday",children:new Intl.DateTimeFormat("es-MX",{weekday:"short"}).format(C)},`h-${kt(C)}`))}),t.jsx("div",{className:"bonsaif-week-view-days",children:te.map(C=>{const _=kt(C),ae=k.has(_),B=h||(n?_<n:!1)||(a?_>a:!1)||!!(s!=null&&s(_)),I=_===kt(new Date);return t.jsx("div",{className:`bonsaif-multi-day${ae?" bonsaif-multi-day-selected":""}${I?" bonsaif-multi-day-today":""}${B?" bonsaif-multi-day-disabled":""}`,children:t.jsxs("button",{type:"button",className:"bonsaif-multi-day-btn",disabled:B,"aria-pressed":ae,onPointerDown:M=>X(C,M),onPointerEnter:()=>Z(C),onClick:M=>D(C,M),children:[t.jsx("span",{className:"bonsaif-week-day-num",children:C.getDate()}),t.jsx("span",{className:"bonsaif-week-day-month",children:new Intl.DateTimeFormat("es-MX",{month:"short"}).format(C)})]})},_)})}),t.jsx("button",{type:"button",className:"bonsaif-week-select-all",disabled:h,onClick:()=>Q(te),children:"Marcar / desmarcar semana"})]})]}),b?t.jsx("div",{className:"bonsaif-cal-summary",children:e.length===0?t.jsx("span",{children:"Sin fechas seleccionadas"}):t.jsxs(t.Fragment,{children:[t.jsxs("span",{children:[e.length," ",e.length===1?"fecha":"fechas"]}),t.jsx("div",{className:"bonsaif-cal-chips",children:e.map(C=>t.jsxs("button",{type:"button",className:"bonsaif-cal-chip",disabled:h,onClick:()=>r==null?void 0:r(e.filter(_=>_!==C)),title:`Quitar ${C}`,children:[cs(C),t.jsx("span",{"aria-hidden":!0,children:"×"})]},C))})]})}):null]})}const Jc=Array.from({length:12},(e,r)=>r);function Rc({value:e=[],onChange:r,year:n,onYearChange:a,minDate:s,maxDate:l,maxDates:i,showSummary:c=!0,className:d="",disabled:u=!1,readOnly:m=!1}){const b=o.useMemo(()=>is(e),[e]),f=nt(s),h=nt(l),v=n??(e[0]?Number(e[0].slice(0,4)):new Date().getFullYear()),[k,g]=o.useState(v);o.useEffect(()=>{typeof n=="number"&&g(n)},[n]);function A(w){g(w),a==null||a(w)}const{onDayPointerDown:$,onDayPointerEnter:N,onDayClick:T}=bs({value:e,onChange:r,disabled:u||m,minDate:s,maxDate:l,maxDates:i,retainOutsidePrefix:`${k}-`}),x=o.useCallback(w=>t.jsx(ds,{...w,className:`bonsaif-year-day-btn ${w.className??""}`,onDayPointerDown:$,onDayPointerEnter:N,onDayClickSelect:T}),[T,$,N]),y=b.filter(w=>w.getFullYear()===k),L=u?!0:[...f?[{before:f}]:[],...h?[{after:h}]:[]];return t.jsxs("div",{className:`bonsaif-calendar bonsaif-year-multi-date-calendar${m?" bonsaif-year-multi-date-calendar--readonly":""} ${d}`,children:[t.jsxs("div",{className:"bonsaif-cal-shell bonsaif-year-cal-shell",children:[t.jsxs("div",{className:"bonsaif-cal-toolbar",children:[t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn","aria-label":"Año anterior",disabled:u,onClick:()=>A(k-1),children:t.jsx(q.HiChevronLeft,{size:16})}),t.jsx("span",{className:"bonsaif-cal-title",children:k}),t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn","aria-label":"Año siguiente",disabled:u,onClick:()=>A(k+1),children:t.jsx(q.HiChevronRight,{size:16})})]}),!m&&!u?t.jsx("p",{className:"bonsaif-cal-hint",children:"Click · Shift+click rango · Arrastra para marcar varias"}):null,t.jsx("div",{className:"bonsaif-year-cal-grid",children:Jc.map(w=>{const W=new Date(k,w,1);return t.jsxs("div",{className:"bonsaif-year-cal-month",children:[t.jsx("div",{className:"bonsaif-year-cal-month-title",children:yr(new Intl.DateTimeFormat("es-MX",{month:"long"}).format(W))}),t.jsx(Ta.DayPicker,{mode:"multiple",required:!1,selected:y,month:W,onMonthChange:()=>{},onSelect:()=>{},numberOfMonths:1,hideNavigation:!0,showOutsideDays:!1,weekStartsOn:1,disabled:L,className:"bonsaif-year-month-picker",modifiers:za,modifiersClassNames:Wa,classNames:{root:"bonsaif-year-month-picker",months:"bonsaif-year-month-months",month:"bonsaif-year-month-inner",month_caption:"bonsaif-year-month-caption-hidden",month_grid:"bonsaif-year-month-grid",weekdays:"bonsaif-year-weekdays",weekday:"bonsaif-year-weekday",week:"bonsaif-year-week",day:"bonsaif-year-day",day_button:"bonsaif-year-day-btn",selected:"bonsaif-year-day-selected",today:"bonsaif-year-day-today",disabled:"bonsaif-year-day-disabled",hidden:"bonsaif-year-day-hidden"},components:{DayButton:x,Weekday:ja},formatters:{formatWeekdayName:X=>new Intl.DateTimeFormat("es-MX",{weekday:"narrow"}).format(X)}})]},`${k}-${w}`)})})]}),c?t.jsx("div",{className:"bonsaif-cal-summary",children:e.length===0?t.jsx("span",{children:"Sin fechas seleccionadas"}):t.jsxs(t.Fragment,{children:[t.jsxs("span",{children:[e.length," ",e.length===1?"fecha":"fechas"," ·"," ",k]}),t.jsx("div",{className:"bonsaif-cal-chips",children:e.map(w=>t.jsxs("button",{type:"button",className:"bonsaif-cal-chip",disabled:u||m,onClick:()=>r==null?void 0:r(e.filter(W=>W!==w)),title:`Quitar ${w}`,children:[cs(w),t.jsx("span",{"aria-hidden":!0,children:"×"})]},w))})]})}):null]})}const ed="bonsaif-ui:hide-tooltips";function ps(){window.dispatchEvent(new CustomEvent(ed))}function td(e){if(e!==void 0)return typeof e=="number"?`${e}px`:e}function rd({trigger:e,items:r,align:n="end",width:a=220,disabled:s=!1,className:l="",menuClassName:i="",onOpenChange:c}){const[d,u]=o.useState(!1),[m,b]=o.useState(!1),[f,h]=o.useState({}),v=o.useRef(null),k=o.useRef(null),g=o.useCallback(x=>{u(x),c==null||c(x)},[c]),A=o.useCallback(()=>{const x=v.current;if(!x)return;const y=x.getBoundingClientRect(),L=typeof a=="number"?a:y.width,w=typeof a=="number"?a:Math.max(y.width,180),W=n==="end"?Math.max(8,y.right-w):Math.min(y.left,window.innerWidth-w-8),X=window.innerHeight-y.bottom,Z=X<240&&y.top>X?void 0:y.bottom+6,D=Z===void 0?window.innerHeight-y.top+6:void 0;h({position:"fixed",zIndex:9999,left:W,top:Z,bottom:D,width:td(typeof a=="number"?L:a)})},[n,a]);o.useEffect(()=>b(!0),[]),o.useEffect(()=>{if(!d)return;A();const x=L=>{var W,X;const w=L.target;!((W=v.current)!=null&&W.contains(w))&&!((X=k.current)!=null&&X.contains(w))&&g(!1)},y=L=>{L.key==="Escape"&&g(!1)};return document.addEventListener("mousedown",x),window.addEventListener("keydown",y),window.addEventListener("resize",A),window.addEventListener("scroll",A,!0),()=>{document.removeEventListener("mousedown",x),window.removeEventListener("keydown",y),window.removeEventListener("resize",A),window.removeEventListener("scroll",A,!0)}},[d,g,A]);const $=x=>{s||(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),g(!d))},N=o.isValidElement(e)?o.cloneElement(e,{onClick:()=>{s||(ps(),g(!d))}}):e,T=d?t.jsx("div",{ref:k,role:"menu","data-bonsaif-overlay":"true",className:`overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-1 shadow-xl ${i}`,style:f,children:r.map(x=>t.jsxs("div",{children:[x.separatorBefore&&t.jsx("div",{className:"my-1 border-t border-[var(--border)]"}),t.jsxs("button",{type:"button",role:"menuitem",disabled:x.disabled,onClick:()=>{var y;x.disabled||(ps(),(y=x.onSelect)==null||y.call(x),g(!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:x.danger?"var(--danger)":"var(--text-main)"},children:[x.icon&&t.jsx("span",{className:"mt-0.5 shrink-0",children:x.icon}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"block truncate text-sm font-medium",children:x.label}),x.description&&t.jsx("span",{className:"block truncate text-xs text-[var(--text-muted)]",children:x.description})]})]})]},x.id))}):null;return t.jsxs("span",{ref:v,role:"button",tabIndex:s?-1:0,"aria-haspopup":"menu","aria-expanded":d,onKeyDown:$,className:`inline-flex ${s?"pointer-events-none opacity-60":""} ${l}`,children:[N,m&&T?ct.createPortal(T,document.body):null]})}const nd=180,hs="bg-[color-mix(in_srgb,var(--bg-main)_72%,transparent)] backdrop-blur-sm";function ad({open:e,onClose:r,title:n,subtitle:a,leadingIcon:s,confirmLabel:l="Guardar",onConfirm:i,loading:c=!1,confirmDisabled:d=!1,headerActions:u,bodyClassName:m="flex-1 overflow-y-auto px-6 py-5",width:b=440,hasUnsavedChanges:f=!1,unsavedChangesTitle:h="Descartar cambios",unsavedChangesDescription:v="Hay cambios sin guardar. Si cierras el drawer se perderán.",unsavedChangesConfirmLabel:k="Descartar",unsavedChangesCancelLabel:g="Seguir editando",onDiscardChanges:A,disabled:$=!1,disabledMessage:N,children:T}){const[x,y]=o.useState(!1),[L,w]=o.useState(!1),[W,X]=o.useState(!1),Z=o.useCallback(()=>{w(!0),requestAnimationFrame(()=>{requestAnimationFrame(()=>X(!0))})},[]),D=o.useCallback(()=>{X(!1),window.setTimeout(()=>w(!1),nd)},[]),Q=$||c,j=o.useCallback(()=>{if(!Q){if(f){Z();return}r()}},[Q,f,r,Z]),se=o.useCallback(()=>{X(!1),w(!1),A==null||A(),r()},[r,A]);if(o.useEffect(()=>{y(!0)},[]),o.useEffect(()=>(document.body.style.overflow=e?"hidden":"",e||(X(!1),w(!1)),()=>{document.body.style.overflow=""}),[e]),o.useEffect(()=>{if(!e)return;const ee=U=>{if(U.key==="Escape"&&!Q){if(L){D();return}j()}};return window.addEventListener("keydown",ee),()=>window.removeEventListener("keydown",ee)},[D,Q,L,e,j]),!x)return null;const te=N!==void 0?N:c?"Guardando…":null;return ct.createPortal(t.jsxs("div",{"aria-hidden":!e,"data-bonsaif-overlay":e?"true":void 0,className:`fixed inset-0 z-[1000] flex transition-opacity duration-300 ${e?"opacity-100":"opacity-0 pointer-events-none"}`,children:[t.jsx("div",{className:`absolute inset-0 ${hs}`,onClick:j}),t.jsxs("div",{className:`absolute inset-y-0 right-0 flex flex-col shadow-2xl transition-transform duration-300 ${e?"translate-x-0":"translate-x-full"}`,style:{width:`min(100vw, ${b}px)`,background:"var(--bg-card)",borderLeft:"1px solid var(--border)"},children:[t.jsxs("div",{className:"flex items-center justify-between px-6 py-4 flex-shrink-0",style:{borderBottom:"1px solid var(--border)"},children:[t.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[t.jsx(Ue,{variant:"icon",onClick:j,title:"Cerrar",disabled:Q,children:t.jsx(q.HiXMark,{className:"w-5 h-5"})}),s&&t.jsx("div",{className:"flex-shrink-0",children:s}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("h3",{className:"text-base font-semibold truncate",style:{color:"var(--text-main)"},children:n}),a&&t.jsx("p",{className:"text-xs truncate",style:{color:"var(--text-muted)"},children:a})]})]}),(u||i)&&t.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[u,i&&t.jsxs(t.Fragment,{children:[t.jsx(Ue,{variant:"secondary",size:"sm",onClick:j,disabled:Q,style:{background:"var(--bg-input)"},children:"Cancelar"}),t.jsx(Ue,{variant:"primary",size:"sm",icon:t.jsx(Ai.FiSave,{className:"w-4 h-4"}),onClick:i,loading:c,disabled:d||Q,title:l})]})]})]}),t.jsx("div",{"data-drawer-scroll":"true",className:m,children:T}),Q&&t.jsx("div",{className:"absolute inset-0 z-[1002] flex cursor-not-allowed items-center justify-center p-6",style:{background:"color-mix(in srgb, var(--bg-card, #ffffff) 72%, transparent)",backdropFilter:"blur(3px)"},role:"status","aria-live":"polite","aria-busy":"true",children:te?t.jsxs("div",{className:"flex max-w-xs flex-col items-center gap-3 text-center",children:[t.jsx("div",{className:"h-9 w-9 animate-spin rounded-full border-2 border-[var(--border)] border-t-[var(--primary)]","aria-hidden":!0}),t.jsx("p",{className:"text-sm font-semibold text-[var(--text-main)]",children:te})]}):null})]}),L&&t.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":h,className:"fixed inset-0 z-[1001] flex items-center justify-center p-4",children:[t.jsx("div",{className:`absolute inset-0 ${hs} transition-opacity duration-200 ease-out ${W?"opacity-100":"opacity-0"}`,onClick:D}),t.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 ${W?"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:[t.jsx(Ue,{variant:"icon",onClick:D,className:"absolute right-3 top-3 h-7 w-7 hover:opacity-70",style:{color:"var(--text-muted, #6b7f78)"},"aria-label":g,children:t.jsx(q.HiXMark,{className:"h-4 w-4"})}),t.jsx("div",{className:"mb-4 flex h-11 w-11 items-center justify-center rounded-xl",style:{background:"var(--warning-bg, #fff7ed)"},children:t.jsx(q.HiExclamationTriangle,{className:"h-5 w-5",style:{color:"var(--warning, #d97706)"}})}),t.jsx("h2",{className:"mb-1 text-base font-semibold",style:{color:"var(--text-main, #0f2f2c)"},children:h}),t.jsx("p",{className:"text-sm",style:{color:"var(--text-muted, #6b7f78)"},children:v}),t.jsxs("div",{className:"mt-6 flex gap-2",children:[t.jsx(Ue,{variant:"secondary",onClick:D,className:"flex-1 border",style:{background:"var(--bg-input, #f7faf8)",borderColor:"var(--border, #d8e1dc)",color:"var(--text-main, #0f2f2c)"},children:g}),t.jsx(Ue,{variant:"secondary",onClick:se,className:"flex-1 border",style:{background:"var(--warning, #d97706)",borderColor:"transparent",color:"#fff",boxShadow:"0 10px 22px rgba(217, 119, 6, 0.22)"},children:k})]})]})]})]}),document.body)}const od=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,sd=/^\+?[0-9\s().-]+$/,ld=7,id=15;function $t(e){return e==null||String(e).trim()===""}function gs(e){return typeof e=="number"?e:typeof e=="string"&&e.trim()!==""?Number(e):Number.NaN}function qa(e){return $t(e)?!1:od.test(String(e))}function Ua(e){if($t(e))return!1;const r=String(e),n=r.replace(/\D/g,"");return sd.test(r)&&n.length>=ld&&n.length<=id}function cd(e="Este campo es requerido."){return r=>$t(r)?e:void 0}function dd(e="Ingresa un correo valido."){return r=>$t(r)||qa(r)?void 0:e}function ud(e="Ingresa un telefono valido."){return r=>$t(r)||Ua(r)?void 0:e}function fd(e,r){return n=>$t(n)||String(n).length>=e?void 0:r??`Debe tener al menos ${e} caracteres.`}function bd(e,r){return n=>$t(n)||String(n).length<=e?void 0:r??`Debe tener ${e} caracteres o menos.`}function md(e,r){return n=>{if($t(n))return;const a=gs(n);return Number.isFinite(a)&&a>=e?void 0:r??`Debe ser mayor o igual a ${e}.`}}function pd(e,r){return n=>{if($t(n))return;const a=gs(n);return Number.isFinite(a)&&a<=e?void 0:r??`Debe ser menor o igual a ${e}.`}}function hd(e,r="El formato no es valido."){return n=>$t(n)||e.test(String(n))?void 0:r}function gd(e,r){const n={};for(const a of Object.keys(r)){const s=r[a];if(!s)continue;const l=Array.isArray(s)?s:[s];for(const i of l){const c=i(e[a],e);if(c){n[a]=c;break}}}return{valid:Object.keys(n).length===0,errors:n}}var vs={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},ys=o.createContext&&o.createContext(vs),vd=["attr","size","title"];function yd(e,r){if(e==null)return{};var n,a,s=xd(e,r);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(a=0;a<l.length;a++)n=l[a],r.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(s[n]=e[n])}return s}function xd(e,r){if(e==null)return{};var n={};for(var a in e)if({}.hasOwnProperty.call(e,a)){if(r.indexOf(a)!==-1)continue;n[a]=e[a]}return n}function An(){return An=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var a in n)({}).hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},An.apply(null,arguments)}function xs(e,r){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);r&&(a=a.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),n.push.apply(n,a)}return n}function Ln(e){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};r%2?xs(Object(n),!0).forEach(function(a){wd(e,a,n[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):xs(Object(n)).forEach(function(a){Object.defineProperty(e,a,Object.getOwnPropertyDescriptor(n,a))})}return e}function wd(e,r,n){return(r=Nd(r))in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}function Nd(e){var r=kd(e,"string");return typeof r=="symbol"?r:r+""}function kd(e,r){if(typeof e!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var a=n.call(e,r);if(typeof a!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(e)}function ws(e){return e&&e.map((r,n)=>o.createElement(r.tag,Ln({key:n},r.attr),ws(r.child)))}function Va(e){return r=>o.createElement(Sd,An({attr:Ln({},e.attr)},r),ws(e.child))}function Sd(e){var r=n=>{var{attr:a,size:s,title:l}=e,i=yd(e,vd),c=s||n.size||"1em",d;return n.className&&(d=n.className),e.className&&(d=(d?d+" ":"")+e.className),o.createElement("svg",An({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},n.attr,a,i,{className:d,style:Ln(Ln({color:e.color||n.color},n.style),e.style),height:c,width:c,xmlns:"http://www.w3.org/2000/svg"}),l&&o.createElement("title",null,l),e.children)};return ys!==void 0?o.createElement(ys.Consumer,null,n=>r(n)):r(vs)}function Ns(e){return Va({attr:{viewBox:"0 0 256 256",fill:"currentColor"},child:[{tag:"path",attr:{d:"M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm0,192a88,88,0,1,1,88-88A88.1,88.1,0,0,1,128,216Zm-8-80V80a8,8,0,0,1,16,0v56a8,8,0,0,1-16,0Zm20,36a12,12,0,1,1-12-12A12,12,0,0,1,140,172Z"},child:[]}]})(e)}function Cd(e){return Va({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:[]}]})(e)}function Ed(e){return Va({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:[]}]})(e)}function xr({content:e,ariaLabel:r="Más información",className:n=""}){return t.jsx(Yt,{as:"span",content:e,className:`inline-flex shrink-0 align-middle text-[var(--text-muted)] outline-none transition-colors hover:text-[var(--primary)] focus-visible:text-[var(--primary)] ${n}`,children:t.jsx("span",{tabIndex:0,role:"img","aria-label":r,className:"inline-flex items-center justify-center outline-none",children:t.jsx(q.HiInformationCircle,{className:"h-3.5 w-3.5"})})})}function wr({error:e,helperText:r,helperDisplay:n="inline"}){return e?t.jsx("span",{className:"text-xs font-medium normal-case text-[var(--danger)]",children:e}):r&&n!=="tooltip"?t.jsx("span",{className:"text-xs font-medium normal-case text-[var(--text-muted)]",children:r}):null}function Dn({className:e="",...r}){return t.jsx("input",{...r,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)] ${e}`})}function Ya({label:e,containerClassName:r="",helperText:n,helperDisplay:a="inline",error:s,errorDisplay:l="inline",errorTooltipLabel:i="Error de validacion",labelAction:c,floatingLabel:d=!1,showPasswordToggle:u=!0,nativeValidation:m=!1,className:b="",required:f,...h}){const[v,k]=o.useState(()=>!!h.autoFocus),[g,A]=o.useState(!1),$=h.type==="password"&&u,N=$&&g?"text":h.type,T=!!s,x=T&&l!=="tooltip",y=T&&l!=="inline",L=!!n&&a==="tooltip"&&!x,w=m?f:void 0,W=T?"border-[var(--danger)] focus:border-[var(--danger)]":"",X=y?$?"pr-20":"pr-10":$?"pr-10":"",Z=h.value!==void 0?String(h.value).length>0:h.defaultValue!==void 0&&String(h.defaultValue).length>0,D=v||Z,Q={top:D?7:12,color:v?"var(--primary)":"var(--text-muted)",fontSize:D?10:13,fontWeight:D?600:400,textTransform:D?"uppercase":"none"},j=J=>{var ce;k(!0),(ce=h.onFocus)==null||ce.call(h,J)},se=J=>{var ce;k(!1),(ce=h.onBlur)==null||ce.call(h,J)},te=$?t.jsxs("button",{type:"button","aria-label":g?"Ocultar contraseña":"Mostrar contraseña","aria-pressed":g,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:()=>A(J=>!J),children:[t.jsx("span",{"aria-hidden":"true",className:`absolute inset-0 flex items-center justify-center transition-[opacity,transform] duration-200 ease-out ${g?"scale-y-0 rotate-[-8deg] opacity-0":"scale-y-100 rotate-0 opacity-100"}`,children:t.jsx(Cd,{className:"h-[18px] w-[18px]"})}),t.jsx("span",{"aria-hidden":"true",className:`absolute inset-0 flex items-center justify-center transition-[opacity,transform] duration-200 ease-out ${g?"scale-y-100 rotate-0 opacity-100":"scale-y-0 rotate-[8deg] opacity-0"}`,children:t.jsx(Ed,{className:"h-[18px] w-[18px]"})})]}):null,ee=y?t.jsx(Yt,{as:"span",content:s,className:`absolute top-1/2 flex h-7 w-7 -translate-y-1/2 items-center justify-center rounded-md text-[var(--danger)] outline-none transition-colors hover:bg-[var(--danger-bg)] focus-visible:bg-[var(--danger-bg)] ${$?"right-10":"right-2.5"}`,children:t.jsx("span",{tabIndex:0,role:"img","aria-label":i,className:"flex h-full w-full items-center justify-center outline-none",children:t.jsx(Ns,{className:"h-[18px] w-[18px]"})})}):null,U=t.jsx(wr,{error:x?s:void 0,helperText:n,helperDisplay:a});return d?t.jsxs("label",{className:`flex flex-col gap-2 ${r}`,children:[t.jsxs("span",{className:"relative block",children:[t.jsx(Dn,{...h,type:N,required:w,placeholder:" ","aria-invalid":T||h["aria-invalid"],"data-has-value":Z?"true":void 0,className:`h-11 w-full pt-5 ${X} ${W} ${b}`,onFocus:j,onBlur:se}),t.jsxs("span",{className:"pointer-events-none absolute left-3 transition-all duration-150",style:Q,children:[e,f&&t.jsx("span",{className:"ml-1 text-[var(--danger)]",children:"*"})]}),c&&t.jsx("span",{className:"absolute right-2 transition-all duration-150",style:{top:D?7:12},children:c}),ee,te]}),U]}):t.jsxs("label",{className:`flex flex-col gap-2 ${r}`,children:[t.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-semibold uppercase text-[var(--text-muted)]",children:[t.jsx("span",{children:e}),f&&t.jsx("span",{className:"text-[var(--danger)]",children:"*"}),L?t.jsx(xr,{content:n}):null,c&&t.jsx("span",{className:"ml-auto normal-case",children:c})]}),$?t.jsxs("span",{className:"relative block",children:[t.jsx(Dn,{...h,type:N,required:w,"aria-invalid":T||h["aria-invalid"],className:`w-full ${X} ${W} ${b}`,onFocus:j,onBlur:se}),ee,te]}):t.jsxs("span",{className:"relative block",children:[t.jsx(Dn,{...h,required:w,"aria-invalid":T||h["aria-invalid"],className:`w-full ${X} ${W} ${b}`}),ee]}),U]})}function ks(e){return e==null?"":String(e)}function Md({autoComplete:e="email",inputMode:r="email",validate:n=!0,invalidMessage:a="Ingresa un correo valido.",errorDisplay:s="tooltip",error:l,value:i,defaultValue:c,onChange:d,...u}){const[m,b]=o.useState(()=>ks(c)),f=i!==void 0?ks(i):m,h=n&&f.length>0&&!qa(f)?a:void 0,v=k=>{i===void 0&&b(k.currentTarget.value),d==null||d(k)};return t.jsx(Ya,{...u,value:i,defaultValue:c,type:"text",inputMode:r,autoComplete:e,error:l??h,errorDisplay:s,onChange:v})}const Td={sm:"min-h-[160px] p-4",md:"min-h-[220px] p-6",lg:"min-h-[300px] p-8"};function $d({title:e="Sin resultados",description:r,icon:n=t.jsx(q.HiInbox,{className:"h-5 w-5"}),action:a,secondaryAction:s,size:l="md",className:i=""}){return t.jsx("div",{className:`flex items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-card)] text-center ${Td[l]} ${i}`,children:t.jsxs("div",{className:"flex max-w-sm flex-col items-center gap-3",children:[n&&t.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:n}),t.jsxs("div",{className:"space-y-1",children:[e&&t.jsx("h3",{className:"text-sm font-semibold text-[var(--text-main)]",children:e}),r&&t.jsx("div",{className:"text-sm leading-5 text-[var(--text-muted)]",children:r})]}),(a||s)&&t.jsxs("div",{className:"mt-1 flex flex-wrap items-center justify-center gap-2",children:[s,a]})]})})}const Ad={sm:"min-h-[112px] p-4",md:"min-h-[148px] p-5",lg:"min-h-[184px] p-6"};function Ld(e){if(e===0)return"0 B";const r=["B","KB","MB","GB"],n=Math.min(Math.floor(Math.log(e)/Math.log(1024)),r.length-1),a=e/1024**n;return`${a>=10||n===0?a.toFixed(0):a.toFixed(1)} ${r[n]}`}function Ss(e,r){return r?r.split(",").map(n=>n.trim().toLowerCase()).filter(Boolean).some(n=>{const a=e.name.toLowerCase(),s=e.type.toLowerCase();return n.startsWith(".")?a.endsWith(n):n.endsWith("/*")?s.startsWith(n.slice(0,-1)):s===n}):!0}function Dd(e,r,n){return r?n===void 0?e:e.slice(0,Math.max(0,n)):e.slice(0,1)}function Id({label:e,helperText:r,helperDisplay:n="inline",error:a,labelAction:s,value:l,defaultValue:i=[],onFilesChange:c,onRejectedFiles:d,multiple:u=!1,maxFiles:m,appendFiles:b=!1,showFileList:f=!0,clearable:h=!0,browseLabel:v="Buscar archivos",dropLabel:k="Suelta los archivos aqui",emptyLabel:g="Arrastra y suelta archivos",emptyDescription:A="o haz click para buscarlos en tu equipo",selectedLabel:$="Archivos seleccionados",size:N="md",containerClassName:T="",dropzoneClassName:x="",fileListClassName:y="",className:L="",id:w,accept:W,disabled:X,required:Z,...D}){const Q=o.useId(),j=w??Q,se=o.useRef(null),[te,ee]=o.useState(!1),[U,J]=o.useState(i),ce=l??U,C=!!a,_=!!r&&n==="tooltip"&&!C,ae=h&&ce.length>0&&!X,B=(z,de)=>{l===void 0&&J(z),c==null||c(z,de)},I=(z,de)=>{const he=z.filter($e=>Ss($e,W)),ie=z.filter($e=>!Ss($e,W)),ge=b?[...ce,...he]:he,Me=Dd(ge,u,m);ie.length>0&&(d==null||d(ie)),B(Me,de)},M=()=>{var z;X||(z=se.current)==null||z.click()},oe=z=>{I(Array.from(z.target.files??[]),z),z.target.value=""},K=z=>{z.preventDefault(),X||ee(!0)},Y=z=>{z.currentTarget.contains(z.relatedTarget)||ee(!1)},S=z=>{z.preventDefault(),ee(!1),!X&&I(Array.from(z.dataTransfer.files),z)},H=z=>{z.key!=="Enter"&&z.key!==" "||(z.preventDefault(),M())},O=z=>{B(ce.filter((de,he)=>he!==z))},re=()=>{B([])};return t.jsxs("div",{className:`flex flex-col gap-2 ${T}`,children:[(e||s||_)&&t.jsxs("div",{className:"inline-flex items-center gap-1 text-xs font-semibold uppercase text-[var(--text-muted)]",children:[e&&t.jsx("span",{children:e}),Z&&t.jsx("span",{className:"text-[var(--danger)]",children:"*"}),_?t.jsx(xr,{content:r}):null,s&&t.jsx("span",{className:"ml-auto normal-case",children:s})]}),t.jsx("input",{...D,ref:se,id:j,type:"file",accept:W,multiple:u,disabled:X,required:Z&&ce.length===0,"aria-invalid":C||D["aria-invalid"],className:"sr-only",onChange:oe}),t.jsxs("div",{role:"button",tabIndex:X?-1:0,"aria-controls":j,"aria-disabled":X||void 0,"aria-invalid":C||void 0,className:`flex cursor-pointer flex-col items-center justify-center gap-3 rounded-lg border border-dashed bg-[var(--bg-card)] text-center outline-none transition-colors focus:border-[var(--primary)] focus:bg-[var(--bg-input)] ${Ad[N]} ${te?"border-[var(--primary)] bg-[var(--bg-input)]":C?"border-[var(--danger)]":"border-[var(--border)]"} ${X?"cursor-not-allowed opacity-60":"hover:border-[var(--primary)] hover:bg-[var(--bg-input)]"} ${x} ${L}`,onClick:M,onDragOver:K,onDragLeave:Y,onDrop:S,onKeyDown:H,children:[t.jsx("span",{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:t.jsx(q.HiArrowUpTray,{className:"h-5 w-5"})}),t.jsxs("span",{className:"space-y-1",children:[t.jsx("span",{className:"block text-sm font-semibold text-[var(--text-main)]",children:te?k:g}),A&&t.jsx("span",{className:"block text-sm text-[var(--text-muted)]",children:A})]}),v&&t.jsx("span",{className:"inline-flex h-9 items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-card)] px-3 text-xs font-semibold text-[var(--text-main)] shadow-sm shadow-black/5 transition-colors",children:v})]}),f&&ce.length>0&&t.jsxs("div",{className:`rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${y}`,children:[t.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-[var(--border)] px-3 py-2",children:[t.jsx("span",{className:"text-xs font-semibold uppercase text-[var(--text-muted)]",children:$}),ae&&t.jsx("button",{type:"button",className:"inline-flex h-7 w-7 items-center justify-center rounded-md text-[var(--text-muted)] transition-colors hover:bg-[var(--bg-input)] hover:text-[var(--danger)] focus:outline-none","aria-label":"Quitar todos los archivos",onClick:re,children:t.jsx(q.HiTrash,{className:"h-4 w-4"})})]}),t.jsx("ul",{className:"divide-y divide-[var(--border)]",children:ce.map((z,de)=>t.jsxs("li",{className:"flex items-center gap-3 px-3 py-2",children:[t.jsx("span",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-md bg-[var(--bg-input)] text-[var(--text-muted)]",children:t.jsx(q.HiDocument,{className:"h-4 w-4"})}),t.jsxs("span",{className:"min-w-0 flex-1 text-left",children:[t.jsx("span",{className:"block truncate text-sm font-medium text-[var(--text-main)]",children:z.name}),t.jsx("span",{className:"block text-xs text-[var(--text-muted)]",children:Ld(z.size)})]}),!X&&t.jsx("button",{type:"button",className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-[var(--text-muted)] transition-colors hover:bg-[var(--bg-input)] hover:text-[var(--danger)] focus:outline-none","aria-label":`Quitar ${z.name}`,onClick:()=>O(de),children:t.jsx(q.HiXMark,{className:"h-4 w-4"})})]},`${z.name}-${z.lastModified}-${de}`))})]}),t.jsx(wr,{error:a,helperText:r,helperDisplay:n})]})}const Od=[{value:"texto",label:"texto"},{value:"numero",label:"número"},{value:"fecha",label:"fecha"},{value:"booleano",label:"booleano"},{value:"email",label:"email"},{value:"telefono",label:"teléfono"},{value:"select",label:"select"},{value:"textarea",label:"textarea"},{value:"archivo",label:"archivo"},{value:"imagen",label:"imagen"}];function Hd({fields:e,title:r="Layout",fieldTypes:n=Od,saveLabel:a="Guardar",allowAddField:s=!1,addFieldPlaceholder:l="Nuevo campo",addFieldLabel:i="Anadir",loading:c=!1,onSave:d,onChange:u}){const[m,b]=o.useState(()=>e.map(N=>({key:!1,type:"",...N}))),[f,h]=o.useState(""),[v,k]=o.useState(""),g=o.useCallback((N,T)=>{b(x=>{const y=x.map((L,w)=>w===N?{...L,...T}:L);return u==null||u(y),y})},[u]),A=o.useCallback(()=>{d==null||d(m)},[m,d]),$=o.useCallback(()=>{var y;const N=f.trim();if(!N){k("Ingresa un nombre de campo.");return}if(m.some(L=>L.name.toLowerCase()===N.toLowerCase())){k("Ese campo ya existe en el arreglo.");return}const x={name:N,key:!1,type:((y=n[0])==null?void 0:y.value)??""};b(L=>{const w=[...L,x];return u==null||u(w),w}),h(""),k("")},[n,m,f,u]);return t.jsxs("div",{className:"flex flex-col rounded-xl border shadow-sm",style:{borderColor:"var(--border)",background:"var(--bg-card)",color:"var(--text-main)"},children:[t.jsx("div",{className:"border-b px-6 py-4",style:{borderColor:"var(--border)"},children:t.jsx("span",{className:"text-base font-semibold",style:{color:"var(--text-main)"},children:r})}),t.jsxs("div",{className:"grid grid-cols-[1fr_80px_1fr] gap-4 border-b px-6 py-2 text-xs font-medium uppercase tracking-wide",style:{borderColor:"var(--border)",color:"var(--text-muted)"},children:[t.jsx("span",{children:"Campo"}),t.jsx("span",{className:"text-center",children:"Llave"}),t.jsx("span",{children:"Tipo de Campo"})]}),t.jsxs("div",{className:"max-h-[420px] overflow-y-auto",children:[m.map((N,T)=>t.jsxs("div",{className:"grid grid-cols-[1fr_80px_1fr] items-center gap-4 border-b px-6 py-3 last:border-0 hover:bg-[var(--bg-input)] transition-colors",style:{borderColor:"var(--border)"},children:[t.jsx("span",{className:"text-sm font-medium",style:{color:"var(--text-main)"},children:N.name}),t.jsx("div",{className:"flex justify-center",children:t.jsx(Nn,{size:"sm",checked:N.key??!1,onChange:x=>g(T,{key:x.target.checked}),"aria-label":`${N.name} es clave`})}),t.jsx(ar,{value:N.type??"",onChange:x=>g(T,{type:x}),options:n,placeholder:"—",emptyLabel:"—",height:36,searchable:!1,ariaLabel:`Tipo de ${N.name}`})]},N.name)),m.length===0&&t.jsx("p",{className:"px-6 py-8 text-center text-sm",style:{color:"var(--text-muted)"},children:"No hay campos disponibles."})]}),t.jsx("div",{className:"flex justify-end border-t px-6 py-4",style:{borderColor:"var(--border)"},children:t.jsxs("div",{className:"w-full space-y-2",children:[s&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{type:"text",value:f,onChange:N=>{h(N.currentTarget.value),v&&k("")},onKeyDown:N=>{N.key==="Enter"&&(N.preventDefault(),$())},placeholder:l,className:"min-w-0 flex-1 rounded-lg border px-3 py-2 text-sm outline-none transition-colors",style:{borderColor:"var(--border)",background:"var(--bg-input)",color:"var(--text-main)"},"aria-label":"Nombre del nuevo campo"}),t.jsx(Ue,{variant:"secondary",onClick:$,height:36,padding:"0 12px",children:i})]}),v&&t.jsx("p",{className:"text-xs",style:{color:"var(--danger)"},children:v})]}),t.jsx("div",{className:"flex justify-end",children:t.jsx(Ue,{variant:"primary",onClick:A,disabled:c,loading:c,children:a})})]})})]})}function In({label:e,children:r,helperText:n,helperDisplay:a="inline",error:s,labelAction:l,required:i=!1,className:c="",contentClassName:d=""}){const u=!!n&&a==="tooltip"&&!s;return t.jsxs("label",{className:`flex flex-col gap-2 ${c}`,children:[(e||l||u)&&t.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-semibold uppercase text-[var(--text-muted)]",children:[e&&t.jsx("span",{children:e}),i&&t.jsx("span",{className:"text-[var(--danger)]",children:"*"}),u?t.jsx(xr,{content:n}):null,l&&t.jsx("span",{className:"ml-auto normal-case",children:l})]}),t.jsx("span",{className:`block ${d}`,children:r}),t.jsx(wr,{error:s,helperText:n,helperDisplay:a})]})}function Bd(e){return Array.from(e.querySelectorAll("img")).filter(r=>!!(r.currentSrc||r.src||"").trim())}function Cs(e,r){const n=e.target;if(!(n instanceof HTMLImageElement))return!1;const a=e.currentTarget,s=Bd(a),l=s.indexOf(n);if(l<0)return!1;e.preventDefault(),e.stopPropagation();const i=n.getBoundingClientRect();return r(s.map(c=>({src:c.currentSrc||c.src,alt:c.alt||void 0})),l,{left:i.left,top:i.top,width:i.width,height:i.height}),!0}const St=260,Nr=420,Xa=380,At="cubic-bezier(0.22, 1, 0.36, 1)",Fd="cubic-bezier(0.16, 1, 0.3, 1)",Ka="cubic-bezier(0.22, 1, 0.36, 1)",Pd="cubic-bezier(0.22, 1, 0.36, 1)",_d=8,zd=1,Wd=1.25,Ga={background:"color-mix(in srgb, var(--bg-card) 90%, transparent)",border:"1px solid var(--border)",boxShadow:"0 10px 28px color-mix(in srgb, var(--bg-main) 28%, transparent), inset 0 1px 0 color-mix(in srgb, var(--bg-card) 55%, transparent)",color:"var(--text-main)",backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)"},jd="color-mix(in srgb, var(--bg-card) 88%, var(--primary) 12%)",Za=10;function tn(e,r,n){return Math.min(n,Math.max(r,e))}function qd(e){return!e||e.width<1||e.height<1?null:{left:e.left,top:e.top,width:e.width,height:e.height}}function Es(e,r){if(r.width<1||r.height<1)return{dx:0,dy:0,scale:1};const n=Math.min(e.width/r.width,e.height/r.height),a=e.left+e.width/2-(r.left+r.width/2),s=e.top+e.height/2-(r.top+r.height/2);return{dx:a,dy:s,scale:Number.isFinite(n)?n:1}}function kr({label:e,onClick:r,children:n,disabled:a,size:s="md"}){const l=s==="lg"?44:40;return t.jsx("button",{type:"button","aria-label":e,title:e,disabled:a,onClick:i=>{i.stopPropagation(),r()},className:"inline-flex items-center justify-center rounded-full disabled:cursor-not-allowed disabled:opacity-35",style:{...Ga,width:l,height:l,transition:"background 160ms ease, transform 160ms cubic-bezier(0.22, 1, 0.36, 1), opacity 160ms ease"},onMouseEnter:i=>{a||(i.currentTarget.style.background=jd,i.currentTarget.style.transform="scale(1.06)")},onMouseLeave:i=>{i.currentTarget.style.background=String(Ga.background??""),i.currentTarget.style.transform="scale(1)"},onMouseDown:i=>{a||(i.currentTarget.style.transform="scale(0.94)")},onMouseUp:i=>{a||(i.currentTarget.style.transform="scale(1.06)")},children:n})}function Ms({open:e,onClose:r,slides:n,index:a,onIndexChange:s,originRect:l=null,maxZoom:i=_d,minZoom:c=zd,zoomStep:d=Wd,closeOnBackdrop:u=!0,closeOnEscape:m=!0,showCounter:b=!0,showZoomControls:f=!0,loop:h=!0,showThumbnails:v=!0,zIndex:k=1100,ariaLabel:g="Visor de imagen"}){const[A,$]=o.useState(!1),[N,T]=o.useState(!1),[x,y]=o.useState(a??0),[L,w]=o.useState(1),[W,X]=o.useState({x:0,y:0}),[Z,D]=o.useState({opacity:1,x:0,scale:1,blur:0,animate:!1}),[Q,j]=o.useState({dx:0,dy:0,scale:1,animate:!1,enabled:!1}),[se,te]=o.useState(!1),ee=o.useRef(null),U=o.useRef(null),J=o.useRef(null),ce=o.useRef(null),C=o.useRef(null),_=o.useRef(!1),ae=o.useRef(!1),B=o.useRef(null),I=o.useRef(null),M=o.useRef(null),oe=o.useRef(null),K=o.useRef(null),Y=o.useRef(a??0),S=a??x,H=n.length===0?0:tn(S,0,Math.max(0,n.length-1)),O=n[H],re=n.length>1,z=Math.max(c,i),de=v&&re,he=o.useCallback(ue=>{if(n.length===0)return;const pe=n.length-1,Le=h?(ue%n.length+n.length)%n.length:tn(ue,0,pe);a===void 0&&y(Le),s==null||s(Le)},[a,h,s,n.length]),ie=o.useCallback(()=>{w(1),X({x:0,y:0})},[]),ge=o.useCallback((ue,pe)=>{if(pe<=c+.001)return{x:0,y:0};const Le=oe.current,He=K.current;if(!Le||!He)return ue;const Ie=Le.getBoundingClientRect(),tt=He.offsetWidth*pe,at=He.offsetHeight*pe,We=Math.max(0,(tt-Ie.width)/2+Ie.width*.15),Ke=Math.max(0,(at-Ie.height)/2+Ie.height*.15);return{x:tn(ue.x,-We,We),y:tn(ue.y,-Ke,Ke)}},[c]),Me=o.useCallback(()=>{$(!1),j({dx:0,dy:0,scale:1,animate:!1,enabled:!1}),ce.current=null,C.current=null,_.current=!1,ae.current=!1,B.current&&(clearTimeout(B.current),B.current=null)},[]),$e=o.useCallback(()=>{if(_.current)return;_.current=!0,T(!1),ie();const ue=ce.current,pe=ue!=null&&C.current!=null&&C.current===H;if(ue&&pe){J.current!=null&&cancelAnimationFrame(J.current),J.current=requestAnimationFrame(()=>{J.current=requestAnimationFrame(()=>{const Le=K.current;if(!Le){J.current=null,ee.current&&clearTimeout(ee.current),ee.current=setTimeout(Me,St+40);return}const He=Le.getBoundingClientRect(),Ie=Es(ue,He);j({enabled:!0,dx:0,dy:0,scale:1,animate:!1}),J.current=requestAnimationFrame(()=>{j({enabled:!0,dx:Ie.dx,dy:Ie.dy,scale:Ie.scale,animate:!0}),J.current=null})})}),ee.current&&clearTimeout(ee.current),ee.current=setTimeout(Me,Nr+80);return}j({dx:0,dy:0,scale:1,animate:!1,enabled:!1}),ee.current&&clearTimeout(ee.current),ee.current=setTimeout(Me,St+40)},[Me,ie,H]);o.useEffect(()=>(e?(ee.current&&clearTimeout(ee.current),B.current&&(clearTimeout(B.current),B.current=null),_.current=!1,ae.current=!1,ce.current=qd(l),C.current=ce.current!=null?a??x:null,$(!0),T(!1),ce.current?j({dx:0,dy:0,scale:1,animate:!1,enabled:!0}):(C.current=null,requestAnimationFrame(()=>requestAnimationFrame(()=>{T(!0),j({dx:0,dy:0,scale:1,animate:!1,enabled:!1})})))):A&&$e(),()=>{ee.current&&clearTimeout(ee.current),J.current!=null&&cancelAnimationFrame(J.current)}),[e]);const Dt=o.useCallback(()=>{if(!e||_.current||ae.current)return;const ue=ce.current,pe=K.current;if(!ue||!pe){ue||(T(!0),ae.current=!0);return}const Le=pe.getBoundingClientRect();if(Le.width<2||Le.height<2)return;ae.current=!0;const He=Es(ue,Le);j({enabled:!0,dx:He.dx,dy:He.dy,scale:He.scale,animate:!1}),J.current!=null&&cancelAnimationFrame(J.current),J.current=requestAnimationFrame(()=>{J.current=requestAnimationFrame(()=>{j({enabled:!0,dx:0,dy:0,scale:1,animate:!0}),T(!0),J.current=null,B.current&&clearTimeout(B.current),B.current=setTimeout(()=>{j({dx:0,dy:0,scale:1,animate:!1,enabled:!1}),B.current=null},Nr+20)})})},[e]);o.useLayoutEffect(()=>{!A||!e||!ce.current||ae.current||Dt()},[A,e,Dt]),o.useEffect(()=>{!e||_.current||C.current!=null&&C.current!==H&&j(ue=>ue.enabled?{dx:0,dy:0,scale:1,animate:!1,enabled:!1}:ue)},[e,H]),o.useEffect(()=>{if(!e)return;const ue=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=ue}},[e]),o.useEffect(()=>{e&&ie()},[e,H,ie]),o.useEffect(()=>{a!==void 0&&y(a)},[a]),o.useEffect(()=>{if(!e){Y.current=H,D({opacity:1,x:0,scale:1,blur:0,animate:!1});return}const ue=Y.current;if(ue===H)return;Y.current=H;const pe=n.length;let Le=1;if(pe>1){const He=(ue+1)%pe===H,Ie=(ue-1+pe)%pe===H;Ie&&!He?Le=-1:He&&!Ie?Le=1:Le=H>ue?1:-1}return U.current!=null&&(cancelAnimationFrame(U.current),U.current=null),D({opacity:0,x:Le*56,scale:.94,blur:8,animate:!1}),U.current=requestAnimationFrame(()=>{U.current=requestAnimationFrame(()=>{D({opacity:1,x:0,scale:1,blur:0,animate:!0}),U.current=null})}),()=>{U.current!=null&&(cancelAnimationFrame(U.current),U.current=null)}},[e,H,n.length]);const ut=L<=c+.001&&Math.abs(W.x)<.5&&Math.abs(W.y)<.5,Re=o.useCallback((ue,pe,Le)=>{w(He=>{const Ie=tn(ue,c,z);if(Math.abs(Ie-He)<1e-4)return He;const tt=Ie/He,at=Ie<He;return Ie<=c+.001?(X({x:0,y:0}),c):(X(We=>{let Ke=We;if(typeof pe=="number"&&typeof Le=="number"&&oe.current&&!at){const Ge=oe.current.getBoundingClientRect(),Ae=pe-Ge.left-Ge.width/2,lr=Le-Ge.top-Ge.height/2;Ke={x:Ae-(Ae-We.x)*tt,y:lr-(lr-We.y)*tt}}else if(at){Ke={x:We.x*tt,y:We.y*tt};const Ge=Math.min(1,(He-Ie)/Math.max(.01,He-c));Ke={x:Ke.x*(1-Ge*.65),y:Ke.y*(1-Ge*.65)}}else Ke={x:We.x*tt,y:We.y*tt};return ge(Ke,Ie)}),Ie)})},[ge,c,z]),It=o.useCallback(()=>{Re(L*d)},[Re,L,d]),Ct=o.useCallback(()=>{const ue=Math.max(c,L/d);if(ue<=c+.001){ie();return}w(ue),X({x:0,y:0})},[c,ie,L,d]);o.useEffect(()=>{if(!e)return;const ue=pe=>{if(pe.key==="Escape"&&m){pe.preventDefault(),r();return}pe.key==="ArrowLeft"&&re?(pe.preventDefault(),he(H-1)):pe.key==="ArrowRight"&&re?(pe.preventDefault(),he(H+1)):pe.key==="+"||pe.key==="="?(pe.preventDefault(),Re(L*d)):pe.key==="-"||pe.key==="_"?(pe.preventDefault(),Ct()):pe.key==="0"&&(pe.preventDefault(),ie())};return window.addEventListener("keydown",ue),()=>window.removeEventListener("keydown",ue)},[Re,m,re,r,e,ie,H,L,he,Ct,d]);const Et=ue=>{ue.preventDefault();const pe=ue.deltaY>0?1/d:d;Re(L*pe,ue.clientX,ue.clientY)},le=ue=>{L<=c+.001||(ue.currentTarget.setPointerCapture(ue.pointerId),te(!0),I.current={pointerId:ue.pointerId,startX:ue.clientX,startY:ue.clientY,originX:W.x,originY:W.y})},Fe=ue=>{const pe=I.current;!pe||pe.pointerId!==ue.pointerId||X(ge({x:pe.originX+(ue.clientX-pe.startX),y:pe.originY+(ue.clientY-pe.startY)},L))},ze=ue=>{var pe;((pe=I.current)==null?void 0:pe.pointerId)===ue.pointerId&&(I.current=null,te(!1))},ft=ue=>{if(ue.stopPropagation(),L>c+.05){ie();return}Re(Math.min(z,3),ue.clientX,ue.clientY)},Ve=ue=>{if(ue.touches.length!==2)return;te(!0);const[pe,Le]=[ue.touches[0],ue.touches[1]],He=Math.hypot(pe.clientX-Le.clientX,pe.clientY-Le.clientY);M.current={distance:He,scale:L}},Mt=ue=>{if(ue.touches.length!==2||!M.current)return;ue.preventDefault();const[pe,Le]=[ue.touches[0],ue.touches[1]],He=Math.hypot(pe.clientX-Le.clientX,pe.clientY-Le.clientY),Ie=(pe.clientX+Le.clientX)/2,tt=(pe.clientY+Le.clientY)/2,at=M.current.scale*(He/Math.max(1,M.current.distance));Re(at,Ie,tt)},bt=()=>{M.current=null,te(!1)};if(!A||!O)return null;const rt=Q.enabled,Wt=Q.animate?`transform ${Nr}ms ${Pd}`:"none";return ct.createPortal(t.jsxs("div",{className:"fixed inset-0",style:{zIndex:k},role:"dialog","aria-modal":"true","aria-label":g,children:[t.jsx("button",{type:"button","aria-label":"Cerrar",className:"absolute inset-0 border-0",style:{background:"color-mix(in srgb, var(--bg-sidebar, var(--primary)) 72%, transparent)",backdropFilter:"blur(10px)",WebkitBackdropFilter:"blur(10px)",opacity:N?1:0,transition:`opacity ${rt?Nr:St}ms ${At}`,cursor:"default",zIndex:0},onClick:()=>{u&&r()}}),t.jsx("div",{ref:oe,className:"absolute inset-0 flex items-center justify-center",style:{zIndex:1,padding:de?"4.5rem 3.5rem 6.5rem":"4.5rem 3.5rem 2.5rem",opacity:rt||N?1:0,transform:rt||N?"translateY(0) scale(1)":"translateY(10px) scale(0.96)",transition:rt?"none":`opacity ${St}ms ${At}, transform ${St}ms ${At}`},onClick:ue=>{ue.target===ue.currentTarget&&u&&r()},onWheel:Et,children:t.jsx("div",{className:"relative flex max-h-full max-w-full items-center justify-center will-change-transform",style:{transform:Q.enabled?`translate3d(${Q.dx}px, ${Q.dy}px, 0) scale(${Q.scale})`:void 0,transformOrigin:"center center",transition:Q.enabled?Wt:void 0},children:t.jsx("div",{className:"relative flex max-h-full max-w-full items-center justify-center will-change-transform",style:{opacity:Z.opacity,filter:Z.blur?`blur(${Z.blur}px)`:"blur(0px)",transform:`translate3d(${Z.x}px, 0, 0) scale(${Z.scale})`,transition:Z.animate?[`opacity ${Xa}ms ${Ka}`,`transform ${Xa}ms ${Ka}`,`filter ${Xa}ms ${Ka}`].join(", "):"none"},children:t.jsx("div",{ref:K,className:"pointer-events-auto relative max-h-full max-w-full touch-none select-none will-change-transform",style:{cursor:L>c+.001?"grab":"zoom-in",transform:`translate3d(${W.x}px, ${W.y}px, 0) scale(${L})`,transformOrigin:"center center",transition:se?"none":`transform 220ms ${Fd}`},onClick:ue=>ue.stopPropagation(),onDoubleClick:ft,onPointerDown:le,onPointerMove:Fe,onPointerUp:ze,onPointerCancel:ze,onTouchStart:Ve,onTouchMove:Mt,onTouchEnd:bt,children:t.jsx("img",{src:O.src,alt:O.alt||"",draggable:!1,className:"block max-h-[min(78vh,820px)] max-w-[min(86vw,1100px)] object-contain",style:{display:"block",borderRadius:Za,imageRendering:L>2.5?"pixelated":"auto"},onLoad:()=>{Dt()}},O.src+String(H))})})})}),t.jsxs("div",{className:"pointer-events-none absolute inset-0",style:{zIndex:2,opacity:N?1:0,transform:N?"translateY(0)":"translateY(-6px)",transition:`opacity ${rt?Nr:St}ms ${At}, transform ${rt?Nr:St}ms ${At}`},children:[t.jsxs("div",{className:"pointer-events-none absolute inset-x-0 top-0 flex items-center justify-between gap-3 px-4 pt-4",children:[t.jsx("div",{className:"pointer-events-auto flex items-center gap-2",children:b&&n.length>0?t.jsxs("span",{className:"rounded-full px-3 py-1.5 text-xs font-semibold tracking-wide",style:Ga,children:[H+1," / ",n.length]}):null}),t.jsxs("div",{className:"pointer-events-auto flex items-center gap-2",children:[f?t.jsxs(t.Fragment,{children:[t.jsx(kr,{label:"Alejar",onClick:Ct,disabled:L<=c+.001,children:t.jsx(q.HiMinus,{className:"h-5 w-5"})}),t.jsx(kr,{label:"Restablecer tamaño",onClick:ie,disabled:ut,children:t.jsx(q.HiArrowsPointingIn,{className:"h-5 w-5"})}),t.jsx(kr,{label:"Acercar",onClick:It,disabled:L>=z-.001,children:t.jsx(q.HiPlus,{className:"h-5 w-5"})})]}):null,t.jsx(kr,{label:"Cerrar",onClick:r,children:t.jsx(q.HiXMark,{className:"h-5 w-5"})})]})]}),re?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"pointer-events-auto absolute left-3 top-1/2",style:{opacity:N?1:0,transform:N?"translate(0, -50%)":"translate(-8px, -50%)",transition:`opacity ${St}ms ${At}, transform ${St}ms ${At}`},children:t.jsx(kr,{label:"Anterior",size:"lg",onClick:()=>he(H-1),disabled:!h&&H<=0,children:t.jsx(q.HiChevronLeft,{className:"h-6 w-6"})})}),t.jsx("div",{className:"pointer-events-auto absolute right-3 top-1/2",style:{opacity:N?1:0,transform:N?"translate(0, -50%)":"translate(8px, -50%)",transition:`opacity ${St}ms ${At}, transform ${St}ms ${At}`},children:t.jsx(kr,{label:"Siguiente",size:"lg",onClick:()=>he(H+1),disabled:!h&&H>=n.length-1,children:t.jsx(q.HiChevronRight,{className:"h-6 w-6"})})})]}):null,de?t.jsx("div",{className:"pointer-events-none absolute inset-x-0 bottom-0 flex justify-center px-4 pb-4 pt-8",style:{background:"linear-gradient(to top, color-mix(in srgb, var(--bg-sidebar, var(--primary)) 72%, transparent), transparent)"},children:t.jsx("div",{className:"pointer-events-auto flex max-w-full items-end gap-2.5 overflow-x-auto rounded-2xl px-2 py-2",style:{background:"color-mix(in srgb, var(--bg-card) 55%, transparent)",backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)",scrollbarWidth:"thin"},role:"tablist","aria-label":"Miniaturas",children:n.map((ue,pe)=>{const Le=pe===H;return t.jsx("button",{type:"button",role:"tab","aria-selected":Le,"aria-label":ue.alt||`Imagen ${pe+1}`,onClick:He=>{He.stopPropagation(),he(pe)},className:"relative shrink-0 overflow-hidden transition-opacity",style:{width:56,height:42,borderRadius:Za,opacity:Le?1:.42,transition:`opacity 180ms ${At}`},children:t.jsx("img",{src:ue.src,alt:"",draggable:!1,className:"h-full w-full object-cover",style:{borderRadius:Za}})},`${ue.src}-${pe}`)})})}):null]})]}),document.body)}function Ud({children:e,className:r,style:n,maxZoom:a,minZoom:s,zoomStep:l,loop:i,showThumbnails:c}){const[d,u]=o.useState(!1),[m,b]=o.useState(0),[f,h]=o.useState([]),[v,k]=o.useState(null),g=o.useCallback(($,N,T)=>{h($),k(T??null),b(N),u(!0)},[]),A=o.useCallback($=>{Cs($,g)},[g]);return t.jsxs(t.Fragment,{children:[t.jsx("div",{className:`[&_img]:cursor-zoom-in ${r??""}`,style:n,onClick:A,children:e}),t.jsx(Ms,{open:d,onClose:()=>u(!1),index:m,onIndexChange:b,slides:f,originRect:v,maxZoom:a,minZoom:s,zoomStep:l,loop:i,showThumbnails:c})]})}function Ts(e){if(e!==void 0)return typeof e=="number"?`${e}px`:e}function $s(e,r){if(e.length!==r.length)return!1;const n=new Set(r);return e.every(a=>n.has(a))}function Qa(e){return e.normalize("NFD").replace(new RegExp("\\p{M}","gu"),"").toLowerCase()}function Vd(e,r){if(!r)return!0;const n=Qa(r);return Qa(e.label).includes(n)||!!(e.sublabel&&Qa(e.sublabel).includes(n))}function Yd({value:e,onChange:r,options:n,placeholder:a="Seleccionar…",disabled:s=!1,className:l="",style:i,height:c=40,padding:d="6px 10px",searchable:u=!0,minOptionsForSearch:m=6,maxVisibleValues:b=2,truncateSelectedValues:f=!0,emptyText:h="Sin resultados",clearLabel:v="Limpiar seleccion",pruneMissingValues:k=!0}){const[g,A]=o.useState(!1),[$,N]=o.useState(""),[T,x]=o.useState(0),[y,L]=o.useState(!1),[w,W]=o.useState({}),X=o.useRef(null),Z=o.useRef(null),D=o.useRef(null),Q=o.useRef(null),j=u&&n.length>=m,se=o.useMemo(()=>new Set(e),[e]),te=o.useMemo(()=>{const S=new Map;for(const H of n)S.set(H.value,H);return S},[n]),ee=o.useMemo(()=>{const S=[];for(const H of e){const O=te.get(H);O&&S.push(O)}return S},[te,e]),U=b==="all"?ee.length:b,J=ee.slice(0,U),ce=Math.max(0,ee.length-J.length),C=o.useMemo(()=>{const S=$.trim();return!j||!S?n:n.filter(H=>Vd(H,S))},[n,$,j]),_=o.useCallback(()=>{const S=X.current;if(!S)return;const H=S.getBoundingClientRect(),O=j?304:244,re=window.innerHeight-H.bottom,z=re<O&&H.top>re;W({position:"fixed",left:H.left,top:z?void 0:H.bottom+4,bottom:z?window.innerHeight-H.top+4:void 0,width:Math.max(H.width,240),zIndex:9999})},[j]),ae=o.useCallback(S=>{$s(e,S)||r(S)},[r,e]),B=o.useCallback(S=>{const H=te.get(S);if(H!=null&&H.disabled)return;const O=se.has(S)?e.filter(re=>re!==S):[...e,S];ae(O)},[ae,te,e,se]),I=o.useCallback(()=>ae([]),[ae]),M=o.useCallback(()=>{A(!1),N(""),x(0)},[]);o.useEffect(()=>L(!0),[]);const oe=o.useMemo(()=>n.map(S=>S.value).join("\0"),[n]);o.useEffect(()=>{if(!k||e.length===0||n.length===0)return;const S=new Set(n.map(O=>O.value)),H=e.filter(O=>S.has(O));$s(e,H)||r(H)},[oe]),o.useEffect(()=>{if(!g)return;function S(H){var re,z;const O=H.target;!((re=X.current)!=null&&re.contains(O))&&!((z=Z.current)!=null&&z.contains(O))&&M()}return document.addEventListener("mousedown",S),()=>document.removeEventListener("mousedown",S)},[M,g]),o.useEffect(()=>{g&&(x(0),_(),j&&setTimeout(()=>{var S;return(S=D.current)==null?void 0:S.focus()},0))},[g,j,_]),o.useEffect(()=>{if(g)return window.addEventListener("resize",_),window.addEventListener("scroll",_,!0),()=>{window.removeEventListener("resize",_),window.removeEventListener("scroll",_,!0)}},[g,_]),o.useEffect(()=>{if(C.length===0){x(0);return}x(S=>Math.min(S,C.length-1))},[C.length]),o.useEffect(()=>{if(T<0||!Q.current)return;const S=Q.current.children[T];S==null||S.scrollIntoView({block:"nearest"})},[T]);function K(S){if(!s){if(!g){(S.key==="Enter"||S.key===" "||S.key==="ArrowDown")&&(S.preventDefault(),A(!0));return}if(S.key==="Escape"){S.preventDefault(),M();return}if(S.key==="ArrowDown"){if(S.preventDefault(),C.length===0)return;x(H=>Math.min(H+1,C.length-1));return}if(S.key==="ArrowUp"){S.preventDefault(),x(H=>Math.max(H-1,0));return}if(S.key==="Enter"&&C[T]&&!C[T].disabled){S.preventDefault(),B(C[T].value);return}S.key==="Backspace"&&!$&&e.length&&(S.preventDefault(),ae(e.slice(0,-1)))}}const Y=t.jsxs("div",{ref:Z,className:"overflow-hidden rounded-xl shadow-xl",style:{...w,background:"var(--bg-card)",border:"1px solid var(--border)"},children:[j&&t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",style:{borderBottom:"1px solid var(--border)"},children:[t.jsx(q.HiMagnifyingGlass,{className:"h-3.5 w-3.5 flex-shrink-0",style:{color:"var(--text-muted)"}}),t.jsx("input",{ref:D,value:$,onChange:S=>{N(S.target.value),x(0)},onKeyDown:S=>{(S.key==="ArrowDown"||S.key==="ArrowUp"||S.key==="Enter"||S.key==="Escape")&&(S.stopPropagation(),K(S))},placeholder:"Buscar…",className:"min-w-0 flex-1 bg-transparent text-sm outline-none",style:{color:"var(--text-main)"}}),$&&t.jsx("button",{type:"button","aria-label":"Limpiar búsqueda",onMouseDown:S=>{S.preventDefault(),N(""),x(0)},children:t.jsx(q.HiXMark,{className:"h-3.5 w-3.5",style:{color:"var(--text-muted)"}})})]}),e.length>0&&t.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:[t.jsxs("span",{children:[ee.length," seleccionados",e.length>ee.length?` (${e.length-ee.length} no disponibles)`:""]}),t.jsx("button",{type:"button",onMouseDown:S=>{S.preventDefault(),I()},className:"font-semibold transition-colors hover:text-[var(--primary)]",children:v})]}),t.jsxs("ul",{ref:Q,role:"listbox","aria-multiselectable":"true",className:"overflow-y-auto",style:{maxHeight:j?220:200,scrollbarWidth:"thin",scrollbarColor:"var(--border) transparent",overscrollBehavior:"contain"},children:[C.map((S,H)=>{const O=H===T,re=se.has(S.value);return t.jsxs("li",{role:"option","aria-selected":re,onMouseDown:z=>{z.preventDefault(),!S.disabled&&B(S.value)},onMouseEnter:()=>!S.disabled&&x(H),className:"flex cursor-pointer items-center gap-2 px-3 py-2 text-sm transition-colors",style:{background:O?"var(--bg-hover)":re?"color-mix(in srgb, var(--primary) 6%, transparent)":"transparent",color:S.disabled?"var(--text-muted)":"var(--text-main)",cursor:S.disabled?"not-allowed":"pointer",opacity:S.disabled?.58:1},children:[t.jsx("span",{className:"flex h-4 w-4 flex-shrink-0 items-center justify-center rounded border",style:{borderColor:re?"var(--primary)":"var(--border)",background:re?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:re&&t.jsx(q.HiCheck,{className:"h-3 w-3"})}),S.color&&t.jsx("span",{className:"h-2.5 w-2.5 flex-shrink-0 rounded-full",style:{background:S.color}}),t.jsxs("span",{className:"flex min-w-0 flex-1 items-baseline gap-1 overflow-hidden",children:[t.jsx(Pt,{className:"min-w-0 flex-1",children:S.label}),S.sublabel&&t.jsx(Pt,{className:"min-w-0 flex-shrink",style:{color:"var(--text-muted)",fontSize:12},children:S.sublabel})]}),S.badge&&t.jsx("span",{className:"flex-shrink-0 text-xs",style:{color:"var(--text-muted)"},children:S.badge})]},S.value)}),C.length===0&&t.jsx("li",{className:"px-3 py-4 text-center text-sm",style:{color:"var(--text-muted)"},children:h})]})]});return t.jsxs("div",{ref:X,className:`relative ${l||"w-full"}`,style:i,onKeyDown:K,children:[t.jsxs("button",{type:"button",disabled:s,onClick:()=>{s||(g?M():A(!0))},className:"flex w-full items-center gap-2 rounded-lg text-left text-sm transition-colors focus:outline-none",style:{minHeight:Ts(c),padding:Ts(d),background:"var(--bg-input)",color:ee.length?"var(--text-main)":"var(--text-muted)",border:g?"1px solid var(--primary)":"1px solid var(--border)",opacity:s?.5:1,cursor:s?"not-allowed":"pointer"},"aria-haspopup":"listbox","aria-expanded":g,children:[t.jsx("span",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-1.5 overflow-hidden",children:J.length?t.jsxs(t.Fragment,{children:[J.map(S=>t.jsxs("span",{className:`inline-flex items-center gap-1 rounded-md border px-1.5 py-0.5 text-xs font-semibold ${f?"max-w-[160px]":"max-w-full whitespace-normal"}`,style:{background:"var(--bg-card)",borderColor:"var(--border)",color:"var(--text-main)"},children:[S.color&&t.jsx("span",{className:"h-1.5 w-1.5 flex-shrink-0 rounded-full",style:{background:S.color}}),f?t.jsx(Pt,{className:"min-w-0 flex-1",children:S.label}):t.jsx("span",{className:"break-words",children:S.label}),t.jsx("span",{role:"button",tabIndex:-1,"aria-label":`Quitar ${S.label}`,onMouseDown:H=>{H.preventDefault(),H.stopPropagation(),B(S.value)},className:"flex-shrink-0 rounded-full p-0.5 transition-colors hover:bg-black/10",style:{color:"var(--text-muted)"},children:t.jsx(q.HiXMark,{className:"h-3 w-3"})})]},S.value)),ce>0&&t.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:["+",ce]})]}):t.jsx("span",{className:"truncate",children:a})}),ee.length?t.jsx("span",{role:"button",tabIndex:-1,"aria-label":v,onMouseDown:S=>{S.preventDefault(),S.stopPropagation(),I()},className:"flex-shrink-0 rounded-full p-0.5 transition-colors hover:bg-black/10",style:{color:"var(--text-muted)"},children:t.jsx(q.HiXMark,{className:"h-3.5 w-3.5"})}):t.jsx(q.HiChevronDown,{className:"h-4 w-4 flex-shrink-0 transition-transform",style:{color:"var(--text-muted)",transform:g?"rotate(180deg)":"rotate(0deg)"}})]}),g&&y&&ct.createPortal(Y,document.body)]})}function Xd({inputMode:e="decimal",...r}){return t.jsx(Ya,{...r,type:"number",inputMode:e})}function Kd(e,r,n){const a=[],s=Math.max(2,e-n),l=Math.min(r-1,e+n);a.push(1),s>2&&a.push("...");for(let i=s;i<=l;i+=1)a.push(i);return l<r-1&&a.push("..."),r>1&&a.push(r),a}function Gd({page:e,totalPages:r,onPageChange:n,disabled:a=!1,siblingCount:s=1,className:l=""}){const i=Math.max(1,r),c=Math.min(Math.max(1,e),i),d=Kd(c,i,s);return t.jsxs("nav",{"aria-label":"Paginacion",className:`inline-flex items-center gap-1 ${l}`,children:[t.jsx(Ue,{variant:"icon",size:"xs","aria-label":"Pagina anterior",disabled:a||c<=1,onClick:()=>n(c-1),children:t.jsx(q.HiChevronLeft,{className:"h-4 w-4"})}),d.map((u,m)=>u==="..."?t.jsx("span",{className:"flex h-8 min-w-8 items-center justify-center text-xs font-semibold text-[var(--text-muted)]",children:"..."},`ellipsis-${m}`):t.jsx("button",{type:"button","aria-current":u===c?"page":void 0,disabled:a,onClick:()=>n(u),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:u===c?"var(--primary)":"var(--border)",background:u===c?"var(--primary)":"var(--bg-card)",color:u===c?"var(--primary-fg)":"var(--text-secondary)"},children:u},u)),t.jsx(Ue,{variant:"icon",size:"xs","aria-label":"Pagina siguiente",disabled:a||c>=i,onClick:()=>n(c+1),children:t.jsx(q.HiChevronRight,{className:"h-4 w-4"})})]})}const As=[{value:"+1",label:"+1",sublabel:"Estados Unidos, Canada, Caribe"},{value:"+7",label:"+7",sublabel:"Rusia, Kazajistan"},{value:"+20",label:"+20",sublabel:"Egipto"},{value:"+27",label:"+27",sublabel:"Sudafrica"},{value:"+30",label:"+30",sublabel:"Grecia"},{value:"+31",label:"+31",sublabel:"Paises Bajos"},{value:"+32",label:"+32",sublabel:"Belgica"},{value:"+33",label:"+33",sublabel:"Francia"},{value:"+34",label:"+34",sublabel:"Espana"},{value:"+36",label:"+36",sublabel:"Hungria"},{value:"+39",label:"+39",sublabel:"Italia, Vaticano"},{value:"+40",label:"+40",sublabel:"Rumania"},{value:"+41",label:"+41",sublabel:"Suiza"},{value:"+43",label:"+43",sublabel:"Austria"},{value:"+44",label:"+44",sublabel:"Reino Unido"},{value:"+45",label:"+45",sublabel:"Dinamarca"},{value:"+46",label:"+46",sublabel:"Suecia"},{value:"+47",label:"+47",sublabel:"Noruega"},{value:"+48",label:"+48",sublabel:"Polonia"},{value:"+49",label:"+49",sublabel:"Alemania"},{value:"+51",label:"+51",sublabel:"Peru"},{value:"+52",label:"+52",sublabel:"Mexico"},{value:"+53",label:"+53",sublabel:"Cuba"},{value:"+54",label:"+54",sublabel:"Argentina"},{value:"+55",label:"+55",sublabel:"Brasil"},{value:"+56",label:"+56",sublabel:"Chile"},{value:"+57",label:"+57",sublabel:"Colombia"},{value:"+58",label:"+58",sublabel:"Venezuela"},{value:"+60",label:"+60",sublabel:"Malasia"},{value:"+61",label:"+61",sublabel:"Australia"},{value:"+62",label:"+62",sublabel:"Indonesia"},{value:"+63",label:"+63",sublabel:"Filipinas"},{value:"+64",label:"+64",sublabel:"Nueva Zelanda"},{value:"+65",label:"+65",sublabel:"Singapur"},{value:"+66",label:"+66",sublabel:"Tailandia"},{value:"+81",label:"+81",sublabel:"Japon"},{value:"+82",label:"+82",sublabel:"Corea del Sur"},{value:"+84",label:"+84",sublabel:"Vietnam"},{value:"+86",label:"+86",sublabel:"China"},{value:"+90",label:"+90",sublabel:"Turquia"},{value:"+91",label:"+91",sublabel:"India"},{value:"+92",label:"+92",sublabel:"Pakistan"},{value:"+93",label:"+93",sublabel:"Afganistan"},{value:"+94",label:"+94",sublabel:"Sri Lanka"},{value:"+95",label:"+95",sublabel:"Myanmar"},{value:"+98",label:"+98",sublabel:"Iran"},{value:"+211",label:"+211",sublabel:"Sudan del Sur"},{value:"+212",label:"+212",sublabel:"Marruecos, Sahara Occidental"},{value:"+213",label:"+213",sublabel:"Argelia"},{value:"+216",label:"+216",sublabel:"Tunez"},{value:"+218",label:"+218",sublabel:"Libia"},{value:"+220",label:"+220",sublabel:"Gambia"},{value:"+221",label:"+221",sublabel:"Senegal"},{value:"+222",label:"+222",sublabel:"Mauritania"},{value:"+223",label:"+223",sublabel:"Mali"},{value:"+224",label:"+224",sublabel:"Guinea"},{value:"+225",label:"+225",sublabel:"Costa de Marfil"},{value:"+226",label:"+226",sublabel:"Burkina Faso"},{value:"+227",label:"+227",sublabel:"Niger"},{value:"+228",label:"+228",sublabel:"Togo"},{value:"+229",label:"+229",sublabel:"Benin"},{value:"+230",label:"+230",sublabel:"Mauricio"},{value:"+231",label:"+231",sublabel:"Liberia"},{value:"+232",label:"+232",sublabel:"Sierra Leona"},{value:"+233",label:"+233",sublabel:"Ghana"},{value:"+234",label:"+234",sublabel:"Nigeria"},{value:"+235",label:"+235",sublabel:"Chad"},{value:"+236",label:"+236",sublabel:"Republica Centroafricana"},{value:"+237",label:"+237",sublabel:"Camerun"},{value:"+238",label:"+238",sublabel:"Cabo Verde"},{value:"+239",label:"+239",sublabel:"Santo Tome y Principe"},{value:"+240",label:"+240",sublabel:"Guinea Ecuatorial"},{value:"+241",label:"+241",sublabel:"Gabon"},{value:"+242",label:"+242",sublabel:"Republica del Congo"},{value:"+243",label:"+243",sublabel:"Republica Democratica del Congo"},{value:"+244",label:"+244",sublabel:"Angola"},{value:"+245",label:"+245",sublabel:"Guinea-Bisau"},{value:"+246",label:"+246",sublabel:"Territorio Britanico del Oceano Indico"},{value:"+248",label:"+248",sublabel:"Seychelles"},{value:"+249",label:"+249",sublabel:"Sudan"},{value:"+250",label:"+250",sublabel:"Ruanda"},{value:"+251",label:"+251",sublabel:"Etiopia"},{value:"+252",label:"+252",sublabel:"Somalia"},{value:"+253",label:"+253",sublabel:"Yibuti"},{value:"+254",label:"+254",sublabel:"Kenia"},{value:"+255",label:"+255",sublabel:"Tanzania"},{value:"+256",label:"+256",sublabel:"Uganda"},{value:"+257",label:"+257",sublabel:"Burundi"},{value:"+258",label:"+258",sublabel:"Mozambique"},{value:"+260",label:"+260",sublabel:"Zambia"},{value:"+261",label:"+261",sublabel:"Madagascar"},{value:"+262",label:"+262",sublabel:"Reunion, Mayotte"},{value:"+263",label:"+263",sublabel:"Zimbabue"},{value:"+264",label:"+264",sublabel:"Namibia"},{value:"+265",label:"+265",sublabel:"Malaui"},{value:"+266",label:"+266",sublabel:"Lesoto"},{value:"+267",label:"+267",sublabel:"Botsuana"},{value:"+268",label:"+268",sublabel:"Esuatini"},{value:"+269",label:"+269",sublabel:"Comoras"},{value:"+290",label:"+290",sublabel:"Santa Elena"},{value:"+291",label:"+291",sublabel:"Eritrea"},{value:"+297",label:"+297",sublabel:"Aruba"},{value:"+298",label:"+298",sublabel:"Islas Feroe"},{value:"+299",label:"+299",sublabel:"Groenlandia"},{value:"+350",label:"+350",sublabel:"Gibraltar"},{value:"+351",label:"+351",sublabel:"Portugal"},{value:"+352",label:"+352",sublabel:"Luxemburgo"},{value:"+353",label:"+353",sublabel:"Irlanda"},{value:"+354",label:"+354",sublabel:"Islandia"},{value:"+355",label:"+355",sublabel:"Albania"},{value:"+356",label:"+356",sublabel:"Malta"},{value:"+357",label:"+357",sublabel:"Chipre"},{value:"+358",label:"+358",sublabel:"Finlandia, Aland"},{value:"+359",label:"+359",sublabel:"Bulgaria"},{value:"+370",label:"+370",sublabel:"Lituania"},{value:"+371",label:"+371",sublabel:"Letonia"},{value:"+372",label:"+372",sublabel:"Estonia"},{value:"+373",label:"+373",sublabel:"Moldavia"},{value:"+374",label:"+374",sublabel:"Armenia"},{value:"+375",label:"+375",sublabel:"Bielorrusia"},{value:"+376",label:"+376",sublabel:"Andorra"},{value:"+377",label:"+377",sublabel:"Monaco"},{value:"+378",label:"+378",sublabel:"San Marino"},{value:"+380",label:"+380",sublabel:"Ucrania"},{value:"+381",label:"+381",sublabel:"Serbia"},{value:"+382",label:"+382",sublabel:"Montenegro"},{value:"+383",label:"+383",sublabel:"Kosovo"},{value:"+385",label:"+385",sublabel:"Croacia"},{value:"+386",label:"+386",sublabel:"Eslovenia"},{value:"+387",label:"+387",sublabel:"Bosnia y Herzegovina"},{value:"+389",label:"+389",sublabel:"Macedonia del Norte"},{value:"+420",label:"+420",sublabel:"Chequia"},{value:"+421",label:"+421",sublabel:"Eslovaquia"},{value:"+423",label:"+423",sublabel:"Liechtenstein"},{value:"+500",label:"+500",sublabel:"Islas Malvinas"},{value:"+501",label:"+501",sublabel:"Belice"},{value:"+502",label:"+502",sublabel:"Guatemala"},{value:"+503",label:"+503",sublabel:"El Salvador"},{value:"+504",label:"+504",sublabel:"Honduras"},{value:"+505",label:"+505",sublabel:"Nicaragua"},{value:"+506",label:"+506",sublabel:"Costa Rica"},{value:"+507",label:"+507",sublabel:"Panama"},{value:"+508",label:"+508",sublabel:"San Pedro y Miquelon"},{value:"+509",label:"+509",sublabel:"Haiti"},{value:"+590",label:"+590",sublabel:"Guadalupe, San Bartolome"},{value:"+591",label:"+591",sublabel:"Bolivia"},{value:"+592",label:"+592",sublabel:"Guyana"},{value:"+593",label:"+593",sublabel:"Ecuador"},{value:"+594",label:"+594",sublabel:"Guayana Francesa"},{value:"+595",label:"+595",sublabel:"Paraguay"},{value:"+596",label:"+596",sublabel:"Martinica"},{value:"+597",label:"+597",sublabel:"Surinam"},{value:"+598",label:"+598",sublabel:"Uruguay"},{value:"+599",label:"+599",sublabel:"Caribe Neerlandes, Curazao"},{value:"+670",label:"+670",sublabel:"Timor Oriental"},{value:"+672",label:"+672",sublabel:"Antartida, Isla Norfolk"},{value:"+673",label:"+673",sublabel:"Brunei"},{value:"+674",label:"+674",sublabel:"Nauru"},{value:"+675",label:"+675",sublabel:"Papua Nueva Guinea"},{value:"+676",label:"+676",sublabel:"Tonga"},{value:"+677",label:"+677",sublabel:"Islas Salomon"},{value:"+678",label:"+678",sublabel:"Vanuatu"},{value:"+679",label:"+679",sublabel:"Fiyi"},{value:"+680",label:"+680",sublabel:"Palaos"},{value:"+681",label:"+681",sublabel:"Wallis y Futuna"},{value:"+682",label:"+682",sublabel:"Islas Cook"},{value:"+683",label:"+683",sublabel:"Niue"},{value:"+685",label:"+685",sublabel:"Samoa"},{value:"+686",label:"+686",sublabel:"Kiribati"},{value:"+687",label:"+687",sublabel:"Nueva Caledonia"},{value:"+688",label:"+688",sublabel:"Tuvalu"},{value:"+689",label:"+689",sublabel:"Polinesia Francesa"},{value:"+690",label:"+690",sublabel:"Tokelau"},{value:"+691",label:"+691",sublabel:"Micronesia"},{value:"+692",label:"+692",sublabel:"Islas Marshall"},{value:"+850",label:"+850",sublabel:"Corea del Norte"},{value:"+852",label:"+852",sublabel:"Hong Kong"},{value:"+853",label:"+853",sublabel:"Macao"},{value:"+855",label:"+855",sublabel:"Camboya"},{value:"+856",label:"+856",sublabel:"Laos"},{value:"+880",label:"+880",sublabel:"Banglades"},{value:"+886",label:"+886",sublabel:"Taiwan"},{value:"+960",label:"+960",sublabel:"Maldivas"},{value:"+961",label:"+961",sublabel:"Libano"},{value:"+962",label:"+962",sublabel:"Jordania"},{value:"+963",label:"+963",sublabel:"Siria"},{value:"+964",label:"+964",sublabel:"Irak"},{value:"+965",label:"+965",sublabel:"Kuwait"},{value:"+966",label:"+966",sublabel:"Arabia Saudita"},{value:"+967",label:"+967",sublabel:"Yemen"},{value:"+968",label:"+968",sublabel:"Oman"},{value:"+970",label:"+970",sublabel:"Palestina"},{value:"+971",label:"+971",sublabel:"Emiratos Arabes Unidos"},{value:"+972",label:"+972",sublabel:"Israel"},{value:"+973",label:"+973",sublabel:"Barein"},{value:"+974",label:"+974",sublabel:"Catar"},{value:"+975",label:"+975",sublabel:"Butan"},{value:"+976",label:"+976",sublabel:"Mongolia"},{value:"+977",label:"+977",sublabel:"Nepal"},{value:"+992",label:"+992",sublabel:"Tayikistan"},{value:"+993",label:"+993",sublabel:"Turkmenistan"},{value:"+994",label:"+994",sublabel:"Azerbaiyan"},{value:"+995",label:"+995",sublabel:"Georgia"},{value:"+996",label:"+996",sublabel:"Kirguistan"},{value:"+998",label:"+998",sublabel:"Uzbekistan"}];function Ls(e){return e==null?"":String(e)}function On(e){return e?e.startsWith("+")?e:`+${e}`:"+1"}function Zd(e){return typeof e=="number"?`${e}px`:e}function Qd({autoComplete:e="tel",inputMode:r="tel",validate:n=!0,invalidMessage:a="Ingresa un telefono valido.",errorDisplay:s="tooltip",error:l,value:i,defaultValue:c,onChange:d,countryCode:u,defaultCountryCode:m="+1",onCountryCodeChange:b,allowedCountryCodes:f,countryCodeOptions:h,countryCodePlaceholder:v="Codigo",countryCodeClassName:k="",countryCodeWidth:g=84,onPhoneValueChange:A,label:$,containerClassName:N="",helperText:T,helperDisplay:x="inline",labelAction:y,className:L="",required:w,disabled:W,floatingLabel:X,showPasswordToggle:Z,nativeValidation:D,errorTooltipLabel:Q="Error de validacion",...j}){var z;const[se,te]=o.useState(()=>Ls(c)),[ee,U]=o.useState(()=>On(m)),J=o.useMemo(()=>{const de=h??As,he=f==null?void 0:f.map(On);return he!=null&&he.length?de.filter(ie=>he.includes(ie.value)):de},[f,h]),ce=((z=J[0])==null?void 0:z.value)??"+1",C=J.some(de=>de.value===On(u??ee))?On(u??ee):ce,_=i!==void 0?Ls(i):se,ae=`${C} ${_}`.trim(),B=n&&_.length>0&&!Ua(ae)?a:void 0,I=l??B,M=!!I,oe=M&&s!=="tooltip",K=M&&s!=="inline",Y=!!T&&x==="tooltip"&&!oe,S=M?"border-[var(--danger)] focus-within:border-[var(--danger)]":"border-[var(--border)] focus-within:border-[var(--primary)]",H=de=>{const he=de.currentTarget.value;i===void 0&&te(he),A==null||A(he,{countryCode:C,nationalNumber:he,fullNumber:`${C} ${he}`.trim()}),d==null||d(de)},O=de=>{u===void 0&&U(de),b==null||b(de),A==null||A(_,{countryCode:de,nationalNumber:_,fullNumber:`${de} ${_}`.trim()})},re=K?t.jsx(Yt,{as:"span",content:I,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(--danger)] outline-none transition-colors hover:bg-[var(--danger-bg)] focus-visible:bg-[var(--danger-bg)]",children:t.jsx("span",{tabIndex:0,role:"img","aria-label":Q,className:"flex h-full w-full items-center justify-center outline-none",children:t.jsx(Ns,{className:"h-[18px] w-[18px]"})})}):null;return t.jsxs("div",{className:`flex flex-col gap-2 ${N}`,children:[t.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-semibold uppercase text-[var(--text-muted)]",children:[t.jsx("span",{children:$}),w&&t.jsx("span",{className:"text-[var(--danger)]",children:"*"}),Y?t.jsx(xr,{content:T}):null,y&&t.jsx("span",{className:"ml-auto normal-case",children:y})]}),t.jsxs("span",{className:`flex h-10 min-w-0 items-center overflow-hidden rounded-lg border bg-[var(--bg-input)] transition-colors ${S}`,children:[t.jsx(ar,{value:C,onChange:O,options:J,placeholder:v,disabled:W,ariaLabel:"Codigo telefonico",triggerVariant:"ghost",showSelectedSublabel:!1,searchable:!0,minOptionsForSearch:0,dropdownMinWidth:300,className:`shrink-0 ${k}`,style:{width:Zd(g)},height:38,padding:"0 8px 0 10px"}),t.jsx("span",{className:"h-5 w-px shrink-0 bg-[var(--border)]"}),t.jsxs("span",{className:"relative min-w-0 flex-1 self-stretch",children:[t.jsx("input",{...j,value:i,defaultValue:c,type:"tel",inputMode:r,autoComplete:e,disabled:W,required:void 0,"aria-label":j["aria-label"]??(typeof $=="string"?$:void 0),"aria-invalid":M||j["aria-invalid"],className:`h-full w-full min-w-0 bg-transparent px-2 py-1.5 text-sm text-[var(--text-main)] outline-none placeholder:text-[var(--text-muted)] disabled:cursor-not-allowed disabled:opacity-60 ${K?"pr-10":""} ${L}`,onChange:H}),re]})]}),t.jsx(wr,{error:oe?I:void 0,helperText:T,helperDisplay:x})]})}function Jd({value:e,onChange:r,options:n,name:a,label:s,orientation:l="vertical",disabled:i=!1,className:c="",optionClassName:d=""}){return t.jsxs("fieldset",{className:`min-w-0 ${c}`,disabled:i,children:[s&&t.jsx("legend",{className:"mb-2 text-xs font-semibold uppercase text-[var(--text-muted)]",children:s}),t.jsx("div",{className:l==="horizontal"?"flex flex-wrap gap-2":"flex flex-col gap-2",children:n.map(u=>{const m=u.value===e,b=i||u.disabled;return t.jsxs("label",{className:`inline-flex min-w-0 items-start gap-2 rounded-lg border px-2.5 py-1.5 transition-colors ${b?"cursor-not-allowed opacity-60":"cursor-pointer hover:bg-[var(--bg-input)]"} ${d}`,style:{borderColor:m?"color-mix(in srgb, var(--primary) 48%, var(--border))":"var(--border)",background:m?"color-mix(in srgb, var(--primary) 8%, transparent)":"var(--bg-card)"},children:[t.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:[t.jsx("input",{type:"radio",name:a,value:u.value,checked:m,disabled:b,onChange:()=>r(u.value),className:"absolute inset-0 opacity-0"}),t.jsx("span",{className:`h-2 w-2 rounded-full transition ${m?"scale-100 opacity-100":"scale-50 opacity-0"}`,style:{background:"var(--primary)"}})]}),t.jsxs("span",{className:"min-w-0",children:[t.jsx("span",{className:"block text-sm font-medium leading-5 text-[var(--text-main)]",children:u.label}),u.description&&t.jsx("span",{className:"block text-xs leading-5 text-[var(--text-muted)]",children:u.description})]})]},u.value)})})]})}const Rd=new Set(["table","thead","tbody","tfoot","tr","th","td","caption"]),Hn=(e,r,n)=>Math.min(n,Math.max(r,Math.round(e)||r)),Sr=12,Bn=8,Ja=(e,r,n)=>{const a=Pn(n),s=e.insertRow(r);for(let l=0;l<a;l+=1){const i=s.insertCell(-1);i.innerHTML="<br>"}return s.cells[0]??null},Ds=(e,r)=>{const n=e.rows[r];if(!n)return null;const a=n.parentElement;if(!a)return null;if(a.tagName==="THEAD"){const l=e.tBodies[0]??e.createTBody();return l.rows.length>=Sr?null:Ja(l,0,e)}if(a.tagName==="TBODY"&&a.rows.length>=Sr)return null;const s=Array.from(a.rows).indexOf(n);return Ja(a,s+1,e)},eu=(e,r)=>{var s;const n=e.rows[r];if(!n)return!1;const a=n.parentElement;return(a==null?void 0:a.tagName)==="TBODY"&&a.rows.length<=1||(a==null?void 0:a.tagName)==="THEAD"&&((s=e.tBodies[0])==null?void 0:s.rows.length)===0&&e.rows.length<=1?!1:(n.remove(),!0)},Is=(e,r)=>Pn(e)>=Bn?!1:(e.querySelectorAll("tr").forEach(n=>{const a=n.closest("thead")!==null,s=document.createElement(a?"th":"td");a?s.textContent=`Columna ${n.cells.length+1}`:s.innerHTML="<br>";const l=n.cells[r];l!=null&&l.nextSibling?n.insertBefore(s,l.nextSibling):n.appendChild(s)}),!0),tu=(e,r)=>Pn(e)<=1?!1:(e.querySelectorAll("tr").forEach(n=>{var a;(a=n.cells[r])==null||a.remove()}),!0),Os=e=>{e.querySelectorAll(".rich-table-row-active").forEach(r=>{r.classList.remove("rich-table-row-active")}),e.querySelectorAll(".rich-table-col-active").forEach(r=>{r.classList.remove("rich-table-col-active")})},Hs=(e,r,n)=>{Os(e),r&&(r.classList.add("rich-table-row-active"),e.querySelectorAll("tr").forEach(a=>{var s;(s=a.cells[n])==null||s.classList.add("rich-table-col-active")}))},ru=(e,r,n)=>{const a=e.getBoundingClientRect();return{rowIndex:Array.from(e.rows).indexOf(r),colIndex:n.cellIndex,bar:{x:a.left+a.width/2,y:a.top-6}}},Fn=e=>{const r=e.cloneNode(!0);return r.querySelectorAll(".rich-table-ui").forEach(n=>n.remove()),r.querySelectorAll(".rich-table-wrap").forEach(n=>{const a=n.querySelector("table");a?n.replaceWith(a):n.remove()}),r.querySelectorAll("table").forEach(n=>{n.classList.add("rich-table")}),r.querySelectorAll(".rich-table-row-active, .rich-table-col-active").forEach(n=>{n.classList.remove("rich-table-row-active","rich-table-col-active")}),r.innerHTML},Bs=e=>{e.querySelectorAll(".rich-table-wrap").forEach(r=>{const n=r.querySelector("table");n&&r.replaceWith(n)}),e.querySelectorAll(".rich-table-ui").forEach(r=>r.remove()),e.querySelectorAll("table").forEach(r=>{r.classList.add("rich-table")})},nu=(e,r,n,a,s)=>{switch(e){case"table-delete":return r.remove(),!0;case"table-row-add":{const l=Number.isFinite(n)?Ds(r,n):Ra(r);return l&&_n(l,s,!0),!!l}case"table-row-del":return Number.isFinite(n)?eu(r,n):!1;case"table-col-add":return Number.isFinite(a)?Is(r,a):lu(r);case"table-col-del":return Number.isFinite(a)?tu(r,a):!1;default:return!1}},Pn=e=>{let r=0;return e.querySelectorAll("tr").forEach(n=>{r=Math.max(r,n.cells.length)}),r||1},au=e=>{const r=e.tBodies[0]??e.createTBody();return Array.from(r.rows)},Fs=e=>(e==null?void 0:e.closest("table"))??null,Ps=e=>{if(!e)return null;const r=e.nodeType===Node.ELEMENT_NODE?e:e.parentElement;return(r==null?void 0:r.closest("td, th"))??null},ou=e=>Array.from(e.querySelectorAll("th, td")),_s=(e,r)=>{if(e.closest("thead"))return!1;const n=e.closest("tbody")??r.tBodies[0];if(!n)return!1;const a=Array.from(n.rows),s=e.closest("tr");return!s||s!==a[a.length-1]?!1:e===s.cells[s.cells.length-1]},su=e=>{const r=window.getSelection();if(!r||!r.isCollapsed||r.rangeCount===0)return!1;const n=r.getRangeAt(0);if(!e.contains(n.startContainer))return!1;const a=n.cloneRange();return a.selectNodeContents(e),a.setStart(n.endContainer,n.endOffset),a.toString().trim()===""},_n=(e,r,n=!0)=>{r==null||r.focus();const a=document.createRange();a.selectNodeContents(e),a.collapse(n);const s=window.getSelection();s==null||s.removeAllRanges(),s==null||s.addRange(a)},Ra=e=>{const r=au(e);if(r.length>=Sr)return null;const n=r[r.length-1];if(!n){const a=e.tBodies[0]??e.createTBody();return Ja(a,0,e)}return Ds(e,Array.from(e.rows).indexOf(n))},lu=e=>{const r=Pn(e)-1;return r<0?!1:Is(e,r)},eo=e=>{Bs(e)},iu=(e,r,n)=>{const a=Hn(e,1,Sr),s=Hn(r,1,Bn),l=n?`<thead><tr>${Array.from({length:s},(c,d)=>`<th>Columna ${d+1}</th>`).join("")}</tr></thead>`:"",i=Array.from({length:a},()=>`<tr>${Array.from({length:s},()=>"<td><br></td>").join("")}</tr>`).join("");return`<table class="rich-table">${l}<tbody>${i}</tbody></table><p><br></p>`},zs=()=>'<button type="button" class="rich-img-del" data-action="delete-img" title="Eliminar imagen"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor"><path fill-rule="evenodd" d="M9 2a1 1 0 0 0-.894.553L7.382 4H4a1 1 0 0 0 0 2v10a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V6a1 1 0 0 0 0-2h-3.382l-.724-1.447A1 1 0 0 0 11 2H9zm-1 6a1 1 0 1 1 2 0v4a1 1 0 1 1-2 0V8zm4 0a1 1 0 1 1 2 0v4a1 1 0 1 1-2 0V8z" clip-rule="evenodd"/></svg></button>',rn=e=>e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;"),Ws=e=>e.toLocaleLowerCase().replace(new RegExp("(^|[^\\p{L}\\p{N}])(\\p{L})","gu"),(r,n,a)=>`${n}${a.toLocaleUpperCase()}`),cu=e=>e.replace(/[<>]/g,"").toLowerCase(),du=new Set(["p","br","div","span","b","strong","i","em","u","s","strike","ul","ol","li","h1","h2","h3","h4","blockquote","a","img","hr","table","thead","tbody","tfoot","tr","th","td","caption"]),uu=/^[\s\u00a0]*([•●○■▪▫◆◇►▶➢❖✓✔\-–—*])[\s\u00a0]+/,fu=e=>{const r=e.indexOf("<!--StartFragment-->"),n=e.indexOf("<!--EndFragment-->");if(r!==-1&&n!==-1&&n>r)return e.slice(r+20,n);const a=e.match(/<body[^>]*>([\s\S]*)<\/body>/i);return a?a[1]:e},zn=(e,r)=>r.test(e),bu=e=>zn(e,/font-weight\s*:\s*(bold|[6-9]00)/i),mu=e=>zn(e,/font-style\s*:\s*italic/i),pu=e=>zn(e,/text-decoration(?:-line)?\s*:[^;]*underline/i),hu=e=>zn(e,/text-decoration(?:-line)?\s*:[^;]*(line-through|linethrough)/i),Wn=(e,r)=>{var a;if(!e.childNodes.length||e.childNodes.length===1&&((a=e.firstChild)==null?void 0:a.nodeType)===Node.ELEMENT_NODE&&e.firstChild.tagName.toLowerCase()===r)return;const n=e.ownerDocument.createElement(r);for(;e.firstChild;)n.appendChild(e.firstChild);e.appendChild(n)},jn=e=>{const r=e.parentNode;if(!r){e.remove();return}for(;e.firstChild;)r.insertBefore(e.firstChild,e);r.removeChild(e)},gu=e=>{const r=e.getAttribute("class")??"",n=e.getAttribute("style")??"";return/mso-list/i.test(n)||/MsoListParagraph/i.test(r)||/MsoList/i.test(r)},js=e=>{const r=e.getAttribute("style")??"",n=e.textContent??"";return/mso-level-number-format\s*:\s*(decimal|arabic|roman|alpha)/i.test(r)||/^\s*\d+[.)]\s/.test(n)||/^\s*[a-zA-Z][.)]\s/.test(n)?"ol":"ul"},vu=e=>{const n=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_TEXT).nextNode();if(!n||!n.textContent)return;const a=n.textContent.replace(uu,"").replace(/^\s*\d+[.)]\s+/,"").replace(/^\s*[a-zA-Z][.)]\s+/,"");a!==n.textContent&&(n.textContent=a)},yu=e=>{const r=Array.from(e.querySelectorAll("span, font, p, div, li, h1, h2, h3, h4"));r.sort((n,a)=>a.querySelectorAll("*").length-n.querySelectorAll("*").length),r.forEach(n=>{const a=n.getAttribute("style")??"";a&&(bu(a)&&Wn(n,"strong"),mu(a)&&Wn(n,"em"),pu(a)&&Wn(n,"u"),hu(a)&&Wn(n,"s"))})},xu=e=>{const r=Array.from(e.querySelectorAll("p, div")).filter(gu);if(!r.length)return;let n=0;for(;n<r.length;){const a=r[n],s=js(a),l=[a];let i=n+1;for(;i<r.length;){const u=r[i];if(js(u)!==s)break;let m=l[l.length-1].nextSibling;for(;m&&m.nodeType===Node.TEXT_NODE&&!(m.textContent??"").trim();)m=m.nextSibling;if(m!==u)break;l.push(u),i++}const c=a.parentNode;if(!c){n=i;continue}const d=a.ownerDocument.createElement(s);c.insertBefore(d,a),l.forEach(u=>{vu(u);const m=u.ownerDocument.createElement("li");for(;u.firstChild;)m.appendChild(u.firstChild);d.appendChild(m),u.remove()}),n=i}},wu=e=>e==="h1"?"h2":e==="h4"||e==="h5"||e==="h6"?"h3":e==="div"?"p":e,Nu=e=>{const r=fu(e.replace(/<!--\[if[\s\S]*?<!\[endif\]-->/gi,"").replace(/<xml[\s\S]*?<\/xml>/gi,"").replace(/<style[\s\S]*?<\/style>/gi,"").replace(/<\/?o:[^>]*>/gi,"").replace(/<\/?w:[^>]*>/gi,"").replace(/<\/?m:[^>]*>/gi,"")),s=new DOMParser().parseFromString(`<!DOCTYPE html><html><body>${r}</body></html>`,"text/html").body;s.querySelectorAll("script, style, meta, link, xml, title, head, iframe, object, embed, form, input, button, textarea, select, noscript").forEach(i=>i.remove()),yu(s),xu(s);const l=i=>{const c=Array.from(i.childNodes);if(i.nodeType===Node.ELEMENT_NODE){const d=i,u=d.tagName.toLowerCase();if(u==="html"||u==="body"){c.forEach(l);return}if(u==="font"){jn(d),c.forEach(l);return}if(!du.has(u)){jn(d),c.forEach(l);return}if(u==="div"){const b=d.getAttribute("class")??"";if(/rich-table-wrap/.test(b)){Array.from(d.attributes).forEach(f=>{f.name.toLowerCase()!=="class"&&d.removeAttribute(f.name)}),d.className="rich-table-wrap",c.forEach(l);return}}const m=wu(u);if(m!==u){const b=d.ownerDocument.createElement(m);for(;d.firstChild;)b.appendChild(d.firstChild);d.replaceWith(b),l(b);return}if(Rd.has(u)){Array.from(d.attributes).forEach(b=>{const f=b.name.toLowerCase();if(u==="td"||u==="th"){["colspan","rowspan"].includes(f)||d.removeAttribute(b.name);return}d.removeAttribute(b.name)}),u==="table"&&d.classList.add("rich-table"),c.forEach(l);return}if(Array.from(d.attributes).forEach(b=>{const f=b.name.toLowerCase(),h=b.value;if(f.startsWith("on")||f==="style"||f==="class"){d.removeAttribute(b.name);return}if(f==="lang"||f.startsWith("data-")||f.startsWith("mso-")){d.removeAttribute(b.name);return}if((f==="href"||f==="src")&&/^\s*javascript:/i.test(h)){d.removeAttribute(b.name);return}u!=="a"&&u!=="img"&&f!=="href"&&f!=="src"&&f!=="alt"&&(["href","src","alt","target","rel"].includes(f)||d.removeAttribute(b.name))}),u==="a"){const b=d.getAttribute("href");if(!b||/^\s*#/.test(b)&&b.length<2){jn(d),c.forEach(l);return}d.setAttribute("target","_blank"),d.setAttribute("rel","noopener noreferrer"),d.classList.add("rich-link")}if(u==="img"){const b=d.getAttribute("src")??"";if(!b||/^\s*javascript:/i.test(b)||/^file:/i.test(b)||/scheme\s*=\s*["']?file/i.test(b)){d.remove();return}d.classList.add("rich-img"),Array.from(d.attributes).forEach(f=>{["src","alt","class"].includes(f.name.toLowerCase())||d.removeAttribute(f.name)})}if(u==="span"){jn(d),c.forEach(l);return}}c.forEach(l)};return l(s),s.querySelectorAll("p, h2, h3, li").forEach(i=>{const c=(i.textContent??"").replace(/[\u00a0\s]+/g,"").trim(),d=i.querySelector("img, hr"),u=!c&&!d&&Array.from(i.childNodes).every(m=>m.nodeType===Node.TEXT_NODE||m.nodeType===Node.ELEMENT_NODE&&m.tagName.toLowerCase()==="br");(!c&&!d||u)&&i.remove()}),s.querySelectorAll("strong, b, em, i, u, s").forEach(i=>{let c=i.nextSibling;for(;c&&c.nodeType===Node.TEXT_NODE&&!(c.textContent??"").trim();)c=c.nextSibling;if(c&&c.nodeType===Node.ELEMENT_NODE&&c.tagName===i.tagName){const d=c;for(;d.firstChild;)i.appendChild(d.firstChild);d.remove()}}),s.innerHTML.replace(/<!--[\s\S]*?-->/g,"").replace(/&nbsp;/gi," ").replace(/(<br\s*\/?>\s*){3,}/gi,"<br><br>").replace(/<p>(?:\s|<br\s*\/?>)*<\/p>/gi,"").trim()},to=e=>rn(e).replace(/\r\n?/g,`
25
+ `).split(/\n{2,}/).map(r=>`<p>${r.replace(/\n/g,"<br>")||"<br>"}</p>`).join(""),ku=e=>new RegExp("\\p{L}","u").test(e),ro=(e,r)=>{const n=e.trim();return!n||!ku(n)?!1:r==="uppercase"?n===n.toLocaleUpperCase():r==="lowercase"?n===n.toLocaleLowerCase():n===Ws(n)},qs=e=>{const r=a=>{var s,l;if(!a.closest(".rich-img-wrap")){const i=document.createElement("span");i.className="rich-img-wrap",i.contentEditable="false",(s=a.parentNode)==null||s.insertBefore(i,a),i.appendChild(a),i.insertAdjacentHTML("beforeend",zs())}(l=a.closest(".rich-img-wrap"))==null||l.classList.add("rich-img-broken")};e.querySelectorAll("img").forEach(a=>{if(!a.complete||a.naturalWidth===0){a.addEventListener("error",()=>r(a),{once:!0}),a.addEventListener("load",()=>{a.naturalWidth===0&&r(a)},{once:!0});const s=a.src;a.src="",a.src=s}});const n=a=>{const s=a.target;s.tagName==="IMG"&&r(s)};return e.addEventListener("error",n,!0),()=>e.removeEventListener("error",n,!0)};function Us({value:e,onChange:r,placeholder:n="Escribe algo...",minHeight:a="80px",instanceId:s}){const l=o.useId(),i=s||l,c=o.useCallback(()=>document,[]),d=o.useRef(null),u=o.useRef(null),m=o.useRef(new Map),b=o.useRef(null),f=o.useRef(!1),h=o.useRef(e??""),v=o.useRef(r),k=o.useRef(()=>{}),g=o.useRef(!1),[A,$]=o.useState(()=>!e||e.trim()===""),[N,T]=o.useState(new Set),[x,y]=o.useState(null),[L,w]=o.useState(""),[W,X]=o.useState(""),[Z,D]=o.useState(""),[Q,j]=o.useState(""),[se,te]=o.useState(3),[ee,U]=o.useState(3),[J,ce]=o.useState(!0),[C,_]=o.useState(!1),[ae,B]=o.useState(null),[I,M]=o.useState(null),oe=o.useRef(null),K=o.useRef(!1),Y=o.useRef(null),S=o.useCallback(()=>f.current?u.current:d.current,[]);o.useEffect(()=>{v.current=r},[r]);const H=o.useCallback(()=>{const F=window.getSelection(),G=S();if(!F||!G||F.rangeCount===0||F.isCollapsed)return"";const fe=F.getRangeAt(0);return!G.contains(fe.startContainer)||!G.contains(fe.endContainer)?"":F.toString()},[S]);o.useEffect(()=>{const F=e??"";if(g.current&&F===h.current){g.current=!1,$(!F||F.trim()==="");return}g.current=!1,h.current=F;const G=[d.current,u.current].filter(be=>!!be);G.forEach(be=>{be.innerHTML!==F&&(be.innerHTML=F)}),$(!F||F.trim()===""),G.forEach(be=>eo(be));const fe=G.map(be=>qs(be));return()=>fe.forEach(be=>be())},[e]),o.useEffect(()=>{var be,Te;f.current=C;let F,G=0,fe;if(C){const ye=d.current;ye&&(h.current=Fn(ye));const Be=()=>{var Ye;const De=u.current;if(!De){G=requestAnimationFrame(Be);return}De.innerHTML!==h.current&&(De.innerHTML=h.current),F=qs(De),eo(De),$(((Ye=De.textContent)==null?void 0:Ye.trim())===""),fe=setTimeout(()=>De.focus(),60)};G=requestAnimationFrame(Be)}else{const ye=u.current,Be=d.current,De=ye?Fn(ye):h.current,Ye=h.current;h.current=De,Be&&Be.innerHTML!==De&&(Be.innerHTML=De),De!==Ye&&v.current(De),$(((Te=(be=ye??Be)==null?void 0:be.textContent)==null?void 0:Te.trim())==="")}return()=>{G&&cancelAnimationFrame(G),fe&&clearTimeout(fe),F==null||F()}},[C]);const O=o.useCallback(()=>{const F=["bold","italic","underline","strikeThrough","insertUnorderedList","insertOrderedList","justifyLeft","justifyCenter","justifyRight","justifyFull"],G=new Set;F.forEach(be=>{try{c().queryCommandState(be)&&G.add(be)}catch{return}});try{const be=cu(c().queryCommandValue("formatBlock"));be&&G.add(`formatBlock:${be}`)}catch{}const fe=H();ro(fe,"uppercase")&&G.add("__upper"),ro(fe,"lowercase")&&G.add("__lower"),ro(fe,"capitalize")&&G.add("__cap"),T(G)},[H,c]),re=()=>{var G;const F=S();F&&(h.current=Fn(F),g.current=!0,v.current(h.current),$(((G=F.textContent)==null?void 0:G.trim())===""))};k.current=re;const z=o.useCallback(()=>{Y.current&&(clearTimeout(Y.current),Y.current=null),oe.current&&(Os(oe.current),oe.current=null),K.current=!1,B(null),M(null)},[]),de=o.useCallback(()=>{Y.current&&(clearTimeout(Y.current),Y.current=null)},[]),he=o.useCallback(()=>{de(),Y.current=setTimeout(()=>{K.current||z()},280)},[de,z]);o.useEffect(()=>()=>{Y.current&&clearTimeout(Y.current)},[]);const ie=o.useCallback(F=>{const G=oe.current;if(!G||!G.isConnected){z();return}const fe=(ae==null?void 0:ae.rowIndex)??(I==null?void 0:I.rowIndex)??-1,be=(ae==null?void 0:ae.colIndex)??(I==null?void 0:I.colIndex)??-1;nu(F,G,fe,be,S()),z(),k.current(),O()},[S,z,O,I,ae]),ge=o.useCallback(F=>{if(I)return;const G=F.currentTarget,fe=F.target;if(fe.closest(".rich-table-action-bar, .rich-table-context-menu")){de();return}const be=fe.closest("td, th");if(!be||!G.contains(be)){he();return}const Te=be.closest("tr"),ye=be.closest("table");if(!Te||!ye||!G.contains(ye)){he();return}de(),ye.classList.add("rich-table"),oe.current=ye,Hs(ye,Te,be.cellIndex),B(ru(ye,Te,be))},[de,he,I]),Me=o.useCallback(F=>{const G=F.relatedTarget;if(G instanceof Element&&(G.closest(".rich-table-action-bar")||G.closest(".rich-table-context-menu"))){de();return}he()},[de,he]),$e=o.useCallback(F=>{const G=F.currentTarget,be=F.target.closest("td, th");if(!be||!G.contains(be))return;const Te=be.closest("tr"),ye=be.closest("table");if(!Te||!ye||!G.contains(ye))return;F.preventDefault(),ye.classList.add("rich-table"),oe.current=ye;const Be=Array.from(ye.rows).indexOf(Te),De=be.cellIndex;Hs(ye,Te,De),B(null),M({x:F.clientX,y:F.clientY,rowIndex:Be,colIndex:De})},[]);o.useEffect(()=>{if(!ae&&!I)return;const F=()=>he();return window.addEventListener("scroll",F,!0),window.addEventListener("resize",F),()=>{window.removeEventListener("scroll",F,!0),window.removeEventListener("resize",F)}},[he,I,ae]),o.useEffect(()=>{if(!I)return;const F=G=>{const fe=G.target;fe instanceof Element&&fe.closest(".rich-table-context-menu")||M(null)};return window.addEventListener("mousedown",F),()=>window.removeEventListener("mousedown",F)},[I]);const Dt=F=>{if(!F){const G=d.current;G&&(h.current=Fn(G))}_(!F)},ut=(F,G)=>{var fe;(fe=S())==null||fe.focus(),c().execCommand(F,!1,G),re(),O()},Re=F=>{ut("formatBlock",F)},It=()=>{var F;(F=S())==null||F.focus(),c().execCommand("insertHTML",!1,"<hr><p><br></p>"),re(),O()},Ct=()=>{const F=window.getSelection();F&&F.rangeCount>0&&(b.current=F.getRangeAt(0).cloneRange())},Et=()=>{const F=window.getSelection();F&&b.current&&(F.removeAllRanges(),F.addRange(b.current))},le=F=>{if(Ct(),F==="link"){const G=window.getSelection();X(G&&!G.isCollapsed?G.toString():""),w("")}F==="image"&&(D(""),j("")),F==="table"&&(te(3),U(3),ce(!0)),y(F)},Fe=()=>{var be;if(!L.trim())return;Et(),(be=S())==null||be.focus();const F=window.getSelection(),fe=(F&&!F.isCollapsed?F.toString():"")||W.trim()||L.trim();c().execCommand("insertHTML",!1,`<a href="${rn(L.trim())}" target="_blank" rel="noopener noreferrer" class="rich-link">${rn(fe)}</a>`),re(),y(null)},ze=(F,G="")=>`<span class="rich-img-wrap" contenteditable="false"><img src="${rn(F)}" alt="${rn(G)}" class="rich-img" />${zs()}</span>`,ft=()=>{var F;Z.trim()&&(Et(),(F=S())==null||F.focus(),c().execCommand("insertHTML",!1,ze(Z.trim(),Q.trim())),re(),y(null))},Ve=()=>{var F;Et(),(F=S())==null||F.focus(),c().execCommand("insertHTML",!1,iu(se,ee,J)),re(),y(null)},Mt=(F,G=1200,fe=1200,be=.72)=>new Promise((Te,ye)=>{const Be=new FileReader;Be.onerror=ye,Be.onload=De=>{var Ot;const Ye=(Ot=De.target)==null?void 0:Ot.result,Ze=new Image;Ze.onerror=ye,Ze.onload=()=>{let{width:ot,height:it}=Ze;if(ot>G||it>fe){const fn=Math.min(G/ot,fe/it);ot=Math.round(ot*fn),it=Math.round(it*fn)}const cr=document.createElement("canvas");cr.width=ot,cr.height=it;const qt=cr.getContext("2d");if(!qt){Te(Ye);return}qt.drawImage(Ze,0,0,ot,it),Te(cr.toDataURL("image/jpeg",be))},Ze.src=Ye},Be.readAsDataURL(F)}),bt=F=>{F.focus();const G=window.getSelection();if(!G||G.rangeCount===0||!F.contains(G.anchorNode)){const fe=document.createRange();fe.selectNodeContents(F),fe.collapse(!1),G==null||G.removeAllRanges(),G==null||G.addRange(fe)}},rt=o.useRef(()=>{});rt.current=F=>{const G=S();G&&(bt(G),c().execCommand("insertHTML",!1,F),eo(G),G.querySelectorAll("p").forEach(fe=>{!(fe.textContent??"").replace(/[\u00a0\s]+/g,"")&&!fe.querySelector("img, hr, table")&&fe.remove()}),re(),O())};const Wt=o.useRef(Mt);Wt.current=Mt;const ue=o.useRef(ze);ue.current=ze;const pe=o.useCallback(F=>{if(!F||m.current.has(F))return;const G=fe=>{const be=fe.clipboardData;if(!be)return;const Te=be.getData("text/html"),ye=be.getData("text/plain");if(Te||ye){fe.preventDefault(),fe.stopPropagation();try{const Ze=Te?Nu(Te):to(ye);if(!Ze){ye&&rt.current(to(ye));return}rt.current(Ze)}catch{ye&&rt.current(to(ye))}return}const De=Array.from(be.items).find(Ze=>Ze.type.startsWith("image/"));if(!De)return;fe.preventDefault(),fe.stopPropagation();const Ye=De.getAsFile();Ye&&Wt.current(Ye).then(Ze=>{rt.current(ue.current(Ze,"imagen"))})};F.addEventListener("paste",G,!0),m.current.set(F,()=>{F.removeEventListener("paste",G,!0),m.current.delete(F)})},[]),Le=o.useCallback(F=>{var fe;const G=d.current;G&&G!==F&&((fe=m.current.get(G))==null||fe()),d.current=F,F&&pe(F)},[pe]),He=o.useCallback(F=>{var fe;const G=u.current;G&&G!==F&&((fe=m.current.get(G))==null||fe()),u.current=F,F&&pe(F)},[pe]);o.useEffect(()=>{const F=m.current;return()=>{F.forEach(G=>G()),F.clear()}},[]);const Ie=F=>{const G=window.getSelection(),fe=S();if(!G||!fe||G.rangeCount===0||G.isCollapsed)return;const be=G.getRangeAt(0);if(!fe.contains(be.startContainer)||!fe.contains(be.endContainer))return;const Te=be.toString();if(!Te)return;let ye=Te;F==="uppercase"?ye=Te.toLocaleUpperCase():F==="lowercase"?ye=Te.toLocaleLowerCase():ye=Ws(Te),be.deleteContents();const Be=document.createTextNode(ye);be.insertNode(Be);const De=document.createRange();De.setStart(Be,0),De.setEnd(Be,ye.length),G.removeAllRanges(),G.addRange(De),b.current=De.cloneRange(),re(),O()},tt=()=>{Ct(),O()},at=()=>{const F=S();F&&Bs(F),re(),O()},We=()=>{requestAnimationFrame(()=>{var F;(F=S())==null||F.focus()})},Ke=F=>{var G,fe;if((F.metaKey||F.ctrlKey)&&F.key==="Enter"){if(F.preventDefault(),F.stopPropagation(),F.repeat)return;(G=S())==null||G.focus(),c().execCommand("insertLineBreak",!1)||c().execCommand("insertHTML",!1,"<br>"),re(),O();return}if(F.key==="Tab"){const be=window.getSelection(),Te=Ps((be==null?void 0:be.anchorNode)??null),ye=S(),Be=Fs(Te);if(Te&&Be&&(ye!=null&&ye.contains(Te))){F.preventDefault();const De=ou(Be),Ye=De.indexOf(Te),Ze=Ye>=0?De[Ye+1]:null;if(Ze)_n(Ze,ye,!0);else if(_s(Te,Be)){const Ot=Ra(Be);Ot&&_n(Ot,ye,!0)}re(),O();return}F.preventDefault(),(fe=S())==null||fe.focus(),c().execCommand("insertText",!1,"    "),re(),O();return}if(F.key==="Enter"&&!F.shiftKey&&!(F.metaKey||F.ctrlKey)){const be=window.getSelection(),Te=Ps((be==null?void 0:be.anchorNode)??null),ye=S(),Be=Fs(Te);if(Te&&Be&&(ye!=null&&ye.contains(Te))&&_s(Te,Be)&&su(Te)){F.preventDefault();const De=Ra(Be);De&&_n(De,ye,!0),re(),O();return}}if(F.key==="Escape"){if(I){M(null);return}if(x){y(null);return}if(f.current){_(!1);return}}x||(F.ctrlKey||F.metaKey)&&(F.key==="b"&&(F.preventDefault(),ut("bold")),F.key==="i"&&(F.preventDefault(),ut("italic")),F.key==="u"&&(F.preventDefault(),ut("underline")),F.key==="k"&&(F.preventDefault(),le("link")))},Ge=()=>t.jsx("div",{className:"h-4 w-px flex-shrink-0 mx-1",style:{background:"var(--border)"}}),Ae=(F,G,fe,be,Te)=>{const ye=Te??(N.has(fe)||fe==="__link"&&x==="link"||fe==="__img"&&x==="image"||fe==="__table"&&x==="table");return t.jsx("button",{type:"button",title:G,tabIndex:-1,onFocus:We,onMouseDown:Be=>{Be.preventDefault(),be?be():ut(fe)},className:"flex h-7 w-7 items-center justify-center rounded text-xs font-bold transition-colors",style:{color:ye?"var(--primary)":"var(--text-secondary)",background:ye?"rgba(59,130,246,0.12)":"transparent"},children:F},fe)},lr=F=>{const G=F.target;if(G.closest("[data-action='delete-img']")){F.preventDefault();const fe=G.closest(".rich-img-wrap");fe&&(fe.remove(),re())}},ir=()=>{de(),K.current=!0},Or=()=>{K.current=!1,he()},Jt=(F,G,fe,be=!1)=>t.jsx("button",{type:"button",className:`rich-table-action-btn${be?" rich-table-action-btn--danger":""}`,title:F,"aria-label":F,onMouseDown:Te=>{Te.preventDefault(),Te.stopPropagation(),ie(fe)},children:G}),oa=()=>typeof document>"u"||!ae&&!I?null:ct.createPortal(t.jsxs(t.Fragment,{children:[ae&&!I&&t.jsxs("div",{className:"rich-table-action-bar",style:{left:ae.bar.x,top:ae.bar.y},onMouseEnter:ir,onMouseLeave:Or,children:[t.jsxs("span",{className:"rich-table-action-hint",children:["Fila ",ae.rowIndex+1," · Col ",ae.colIndex+1]}),t.jsxs("div",{className:"rich-table-action-group",children:[t.jsx("span",{className:"rich-table-action-label",children:"Fila"}),Jt("Añadir fila abajo","+","table-row-add"),Jt("Eliminar fila","−","table-row-del")]}),t.jsxs("div",{className:"rich-table-action-group",children:[t.jsx("span",{className:"rich-table-action-label",children:"Columna"}),Jt("Añadir columna a la derecha","+","table-col-add"),Jt("Eliminar columna","−","table-col-del")]}),Jt("Eliminar tabla","Eliminar","table-delete",!0)]}),I&&t.jsx("div",{className:"rich-table-context-menu",style:{left:I.x,top:I.y},onMouseDown:F=>F.stopPropagation(),children:[["Añadir fila abajo","table-row-add"],["Eliminar fila","table-row-del"],["Añadir columna a la derecha","table-col-add"],["Eliminar columna","table-col-del"],["Eliminar tabla","table-delete"]].map(([F,G])=>t.jsx("button",{type:"button",onMouseDown:fe=>{fe.preventDefault(),ie(G)},children:F},G))})]}),document.body),lt=F=>t.jsxs(t.Fragment,{children:[x==="link"&&t.jsxs("div",{className:"flex flex-shrink-0 flex-wrap items-center gap-2 border-t px-3 py-2",style:{borderColor:"var(--border)",background:F},children:[t.jsx("input",{autoFocus:!0,type:"url",value:L,onChange:G=>w(G.target.value),onKeyDown:G=>{G.key==="Enter"&&(G.preventDefault(),Fe()),G.key==="Escape"&&y(null)},placeholder:"https://...",className:"min-w-0 flex-1 rounded px-2 py-1 text-xs focus:outline-none",style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-main)"}}),t.jsx("input",{type:"text",value:W,onChange:G=>X(G.target.value),onKeyDown:G=>{G.key==="Enter"&&(G.preventDefault(),Fe()),G.key==="Escape"&&y(null)},placeholder:"Texto (opcional)",className:"w-32 rounded px-2 py-1 text-xs focus:outline-none",style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-main)"}}),t.jsx("button",{type:"button",onClick:Fe,className:"rounded px-2.5 py-1 text-xs font-semibold text-white",style:{background:"var(--primary)"},children:"OK"}),t.jsx("button",{type:"button",onClick:()=>y(null),className:"rounded px-2 py-1 text-xs",style:{color:"var(--text-muted)"},children:"x"})]}),x==="table"&&t.jsxs("div",{className:"flex flex-shrink-0 flex-wrap items-center gap-2 border-t px-3 py-2",style:{borderColor:"var(--border)",background:F},children:[t.jsxs("label",{className:"flex items-center gap-1 text-xs",style:{color:"var(--text-secondary)"},children:["Filas",t.jsx("input",{autoFocus:!0,type:"number",min:1,max:Sr,value:se,onChange:G=>te(Hn(Number(G.target.value),1,Sr)),onKeyDown:G=>{G.key==="Enter"&&(G.preventDefault(),Ve()),G.key==="Escape"&&y(null)},className:"w-14 rounded px-2 py-1 text-xs focus:outline-none",style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-main)"}})]}),t.jsxs("label",{className:"flex items-center gap-1 text-xs",style:{color:"var(--text-secondary)"},children:["Columnas",t.jsx("input",{type:"number",min:1,max:Bn,value:ee,onChange:G=>U(Hn(Number(G.target.value),1,Bn)),onKeyDown:G=>{G.key==="Enter"&&(G.preventDefault(),Ve()),G.key==="Escape"&&y(null)},className:"w-14 rounded px-2 py-1 text-xs focus:outline-none",style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-main)"}})]}),t.jsxs("label",{className:"flex items-center gap-1.5 text-xs",style:{color:"var(--text-secondary)"},children:[t.jsx("input",{type:"checkbox",checked:J,onChange:G=>ce(G.target.checked)}),"Encabezado"]}),t.jsx("button",{type:"button",onClick:Ve,className:"rounded px-2.5 py-1 text-xs font-semibold text-white",style:{background:"var(--primary)"},children:"OK"}),t.jsx("button",{type:"button",onClick:()=>y(null),className:"rounded px-2 py-1 text-xs",style:{color:"var(--text-muted)"},children:"x"})]}),x==="image"&&t.jsxs("div",{className:"flex flex-shrink-0 flex-wrap items-center gap-2 border-t px-3 py-2",style:{borderColor:"var(--border)",background:F},children:[t.jsx("input",{autoFocus:!0,type:"url",value:Z,onChange:G=>D(G.target.value),onKeyDown:G=>{G.key==="Enter"&&(G.preventDefault(),ft()),G.key==="Escape"&&y(null)},placeholder:"URL de la imagen...",className:"min-w-0 flex-1 rounded px-2 py-1 text-xs focus:outline-none",style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-main)"}}),t.jsx("input",{type:"text",value:Q,onChange:G=>j(G.target.value),onKeyDown:G=>{G.key==="Enter"&&(G.preventDefault(),ft()),G.key==="Escape"&&y(null)},placeholder:"Texto alt",className:"w-28 rounded px-2 py-1 text-xs focus:outline-none",style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-main)"}}),t.jsx("button",{type:"button",onClick:ft,className:"rounded px-2.5 py-1 text-xs font-semibold text-white",style:{background:"var(--primary)"},children:"OK"}),t.jsx("button",{type:"button",onClick:()=>y(null),className:"rounded px-2 py-1 text-xs",style:{color:"var(--text-muted)"},children:"x"})]})]}),jt=(F,G)=>t.jsxs("div",{className:"flex flex-shrink-0 flex-wrap items-center gap-0.5 border-t px-2 py-1",style:{borderColor:"var(--border)",background:G},children:[Ae(t.jsx(q.HiArrowUturnLeft,{className:"h-4 w-4"}),"Deshacer","undo"),Ae(t.jsx(q.HiArrowUturnRight,{className:"h-4 w-4"}),"Rehacer","redo"),Ge(),Ae(t.jsx("span",{style:{fontSize:"10px"},children:"P"}),"Parrafo","__paragraph",()=>Re("p"),N.has("formatBlock:p")||N.has("formatBlock:div")),Ae(t.jsx(q.HiH2,{className:"h-4 w-4"}),"Titulo 2","__h2",()=>Re("h2"),N.has("formatBlock:h2")),Ae(t.jsx(q.HiH3,{className:"h-4 w-4"}),"Titulo 3","__h3",()=>Re("h3"),N.has("formatBlock:h3")),Ae(t.jsx("span",{style:{fontSize:"13px",lineHeight:1},children:"“"}),"Cita","__quote",()=>Re("blockquote"),N.has("formatBlock:blockquote")),Ge(),Ae(t.jsx("b",{children:"B"}),"Negrita (Ctrl+B)","bold"),Ae(t.jsx("i",{children:"I"}),"Cursiva (Ctrl+I)","italic"),Ae(t.jsx("u",{children:"U"}),"Subrayado (Ctrl+U)","underline"),Ae(t.jsx("s",{children:"S"}),"Tachado","strikeThrough"),Ge(),Ae(t.jsx(q.HiListBullet,{className:"h-4 w-4"}),"Lista sin orden","insertUnorderedList"),Ae(t.jsx(q.HiNumberedList,{className:"h-4 w-4"}),"Lista numerada","insertOrderedList"),Ae(t.jsx(q.HiArrowTurnUpLeft,{className:"h-4 w-4"}),"Disminuir sangria","outdent"),Ae(t.jsx(q.HiArrowTurnDownRight,{className:"h-4 w-4"}),"Aumentar sangria","indent"),Ge(),Ae(t.jsx(q.HiBars3BottomLeft,{className:"h-4 w-4"}),"Alinear izquierda","justifyLeft"),Ae(t.jsx(q.HiBars3CenterLeft,{className:"h-4 w-4"}),"Centrar","justifyCenter"),Ae(t.jsx(q.HiBars3BottomRight,{className:"h-4 w-4"}),"Alinear derecha","justifyRight"),Ae(t.jsx(q.HiBars3,{className:"h-4 w-4"}),"Justificar","justifyFull"),Ge(),Ae(t.jsx("span",{style:{fontSize:"10px"},children:"AA"}),"Mayusculas","__upper",()=>Ie("uppercase")),Ae(t.jsx("span",{style:{fontSize:"10px"},children:"aa"}),"Minusculas","__lower",()=>Ie("lowercase")),Ae(t.jsx("span",{style:{fontSize:"10px"},children:"Aa"}),"Capitalizar","__cap",()=>Ie("capitalize")),Ge(),Ae(t.jsx(q.HiLink,{className:"h-4 w-4"}),"Insertar enlace (Ctrl+K)","__link",()=>le("link")),Ae(t.jsx(q.HiLinkSlash,{className:"h-4 w-4"}),"Quitar enlace","unlink"),Ae(t.jsx(q.HiPhoto,{className:"h-4 w-4"}),"Insertar imagen","__img",()=>le("image")),Ae(t.jsx(q.HiTableCells,{className:"h-4 w-4"}),"Insertar tabla","__table",()=>le("table")),Ae(t.jsx(q.HiMinus,{className:"h-4 w-4"}),"Insertar separador","__divider",It),Ge(),Ae(t.jsx(q.HiOutlinePaintBrush,{className:"h-4 w-4"}),"Limpiar formato","removeFormat"),Ae(t.jsx(q.HiNoSymbol,{className:"h-4 w-4"}),"Quitar bloque","__clearBlock",()=>Re("p")),Ge(),t.jsx("button",{type:"button",title:F?"Salir del modo de enfoque (Esc)":"Modo de enfoque",tabIndex:-1,onFocus:We,onMouseDown:fe=>{fe.preventDefault(),Dt(F)},className:"flex h-7 w-7 items-center justify-center rounded transition-colors",style:{color:"var(--text-secondary)"},children:F?t.jsx(q.HiArrowsPointingIn,{className:"h-4 w-4"}):t.jsx(q.HiArrowsPointingOut,{className:"h-4 w-4"})})]});return t.jsxs(t.Fragment,{children:[oa(),t.jsxs("div",{className:"overflow-hidden rounded-lg transition-all duration-150 ring-1 ring-transparent focus-within:ring-primary/30",style:{border:"1px solid var(--border)"},children:[t.jsx("div",{ref:Le,contentEditable:!0,suppressContentEditableWarning:!0,"data-bonsaif-rich-instance":i,onInput:at,onKeyDown:Ke,onKeyUp:tt,onSelect:tt,onMouseUp:tt,onMouseMove:ge,onMouseLeave:Me,onContextMenu:$e,onMouseDown:lr,"data-placeholder":n,className:`rich-editor px-3 py-2 text-sm focus:outline-none${A?" is-empty":""}`,style:{color:"var(--text-main)",background:"var(--bg-input)",minHeight:a,maxHeight:"320px",overflowY:"auto",lineHeight:"1.6"}}),lt("var(--bg-input)"),jt(!1,"var(--bg-input)")]}),t.jsxs(Oa,{open:C,onClose:()=>_(!1),title:"Modo de enfoque",subtitle:"Esc para salir",maxWidth:"920px",bodyClassName:"flex min-h-0 flex-col p-0",panelClassName:"h-[88vh]",backdropClassName:"bg-black/50 backdrop-blur-[2px]",children:[t.jsx("div",{ref:He,contentEditable:!0,suppressContentEditableWarning:!0,"data-bonsaif-rich-instance":i,onInput:at,onKeyDown:Ke,onKeyUp:tt,onSelect:tt,onMouseUp:tt,onMouseMove:ge,onMouseLeave:Me,onContextMenu:$e,onMouseDown:lr,"data-placeholder":n,className:`rich-editor min-h-0 flex-1 overflow-y-auto px-8 py-6 text-sm focus:outline-none${A?" is-empty":""}`,style:{color:"var(--text-main)",background:"var(--bg-card)",lineHeight:"1.75"}}),lt("var(--bg-input)"),jt(!0,"var(--bg-input)")]})]})}const Vs="[a-zA-Z0-9._@-]+",no=new RegExp(`@(${Vs})`,"g"),Su=/[a-zA-Z0-9._@-]/,nn=new Set([" ",`
26
+ `," ","\r"," ","(","[","{",".",",",";",":","!","?","¿","¡",")","]","}",'"',"'","«","»","/","\\","|","-","—","–"]);function Ys(e,r){if(r<=0)return!0;const n=e[r-1]??"";return nn.has(n)}function Xs(e,r,n){var a;if(r<0||r>e.length)return null;for(let s=r-1;s>=0;s-=1){if(e[s]!=="@"){const c=e[s]??"";if(nn.has(c)||!Su.test(c))return null;continue}if((a=n==null?void 0:n.isInsideExistingMention)!=null&&a.call(n,s)||!(n!=null&&n.isTriggerBoundary?n.isTriggerBoundary(s):Ys(e,s)))continue;const i=e.slice(s+1,r);return i.length>0&&!new RegExp(`^${Vs}$`).test(i)?null:{query:i,triggerIndex:s,caretIndex:r}}return null}function Ks(e,r){var a;const n=Cr(e,r);return n?!!((a=n.node.parentElement)!=null&&a.closest(".mention-chip")):!1}function Gs(e,r){if(r<=0)return!0;const n=Cr(e,r);if(!n){const s=io(e);return Ys(s,r)}if(n.offset>0){const s=n.node.data[n.offset-1]??"";return nn.has(s)}let a=n.node.previousSibling;for(;a;){if(a.nodeType===Node.TEXT_NODE){const s=a.textContent??"";if(s.length===0){a=a.previousSibling;continue}return nn.has(s[s.length-1]??"")}if(a.nodeType===Node.ELEMENT_NODE){const s=a;if(s.classList.contains("mention-chip")||s.tagName==="BR"||/^(P|DIV|LI|H[1-6]|BLOCKQUOTE)$/i.test(s.tagName))return!0;const l=s.textContent??"";if(l.length===0){a=a.previousSibling;continue}return nn.has(l[l.length-1]??"")}a=a.previousSibling}return!0}function ao(e,r){const n=io(e);return Xs(n,r,{isTriggerBoundary:a=>Gs(e,a),isInsideExistingMention:a=>Ks(e,a)})}function oo(e){return e.toLowerCase().trim()}function Zs(e){return e?e.replace(/<style[^>]*>[\s\S]*?<\/style>/gi," ").replace(/<script[^>]*>[\s\S]*?<\/script>/gi," ").replace(/<br\s*\/?>/gi,`
27
27
  `).replace(/<\/(p|div|li)>/gi,`
28
- `).replace(/<[^>]+>/g," ").replace(/&nbsp;/g," ").replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&#39;/g,"'").replace(/\s+/g," ").trim():""}function Fa(e){if(!e)return[];const r=new Set,n=[],a=d=>{const u=Ba(d);!u||r.has(u)||(r.add(u),n.push(u))},o=/data-username\s*=\s*["']([^"']+)["']/gi;let l;for(;(l=o.exec(e))!==null;)a(l[1]??"");const i=go(e);Oa.lastIndex=0;let c;for(;(c=Oa.exec(i))!==null;)a(c[1]??"");return n}function vo(e){const r=String(e.name??"").trim();return r||String(e.username??"").trim()||"usuario"}function Id(e,r){const n=Fa(e);if(!n.length)return[];const a=new Map;r.forEach(i=>{i.username&&a.set(Ba(i.username),i)});const o=new Set,l=[];for(const i of n){const c=a.get(i);c&&(o.has(c.userId)||(o.add(c.userId),l.push({userId:c.userId,username:c.username,email:c.email??void 0,display:c.name??c.username})))}return l}function yo(e){const r=new Set,n=[];for(const a of e)r.has(a.userId)||(r.add(a.userId),n.push(a));return n}function Od(e,r){return r?e.filter(n=>n.userId!==r):e}function xo(e){return!e||!/@/.test(e)?e:e.replace(Oa,(r,n,a,o)=>{const l=o.slice(0,a),i=l.lastIndexOf("<"),c=l.lastIndexOf(">");return i>c?r:`<span class="mention-chip" contenteditable="false" data-username="${(n??"").toLowerCase()}">${r}</span>`})}function dr(e,r){if(r<0)return null;const n=e.ownerDocument;if(!n)return null;const a=n.createTreeWalker(e,NodeFilter.SHOW_TEXT);let o=r,l=null,i=a.nextNode();for(;i;){l=i;const c=i.data.length;if(o<=c)return{node:i,offset:o};o-=c,i=a.nextNode()}return l&&o===0?{node:l,offset:l.data.length}:null}function Pa(e,r,n){var o;const a=e.ownerDocument;if(!a||e!==r&&!e.contains(r))return-1;try{const l=a.createRange();return l.selectNodeContents(e),l.setEnd(r,n),((o=l.cloneContents().textContent)==null?void 0:o.length)??0}catch{return-1}}function wo(e,r){const{triggerIndex:n,caretIndex:a,username:o}=r;if(a<n)return null;const l=dr(e,n),i=dr(e,a);if(!l||!i)return null;const c=e.ownerDocument,d=c.createRange();d.setStart(l.node,l.offset),d.setEnd(i.node,i.offset),d.deleteContents();const u=vo({name:r.display,username:o}),m=c.createElement("span");m.className="mention-chip",m.setAttribute("data-username",o.toLowerCase()),r.userId&&m.setAttribute("data-userid",String(r.userId)),m.contentEditable="false",m.textContent=u,m.title=`@${o}`;const f=c.createTextNode(" ");d.insertNode(f),d.insertNode(m);const b=c.defaultView,v=b==null?void 0:b.getSelection();if(v){const x=c.createRange();x.setStart(f,f.data.length),x.collapse(!0),v.removeAllRanges(),v.addRange(x)}return{caretPlainOffset:n+u.length+1}}function ko(e,r){const n=e.ownerDocument,a=n.defaultView;if(!a)return;const o=a.getSelection();if(!o)return;const l=n.createRange(),i=dr(e,r);i?(l.setStart(i.node,i.offset),l.collapse(!0)):(l.selectNodeContents(e),l.collapse(!1)),o.removeAllRanges(),o.addRange(l)}function Cn(e){return e instanceof HTMLElement&&e.classList.contains("mention-chip")}function No(e,r){let n=e;for(;n&&n.nodeType===Node.TEXT_NODE&&!(n.textContent??"").replace(/\u00a0/g," ").trim();)n=r==="prev"?n.previousSibling:n.nextSibling;return n}function So(e){var o;const r=e.ownerDocument,n=(o=r.defaultView)==null?void 0:o.getSelection();if(!n)return;const a=r.createRange();a.selectNode(e),n.removeAllRanges(),n.addRange(a),e.classList.add("is-selected")}function ur(e=document){var r;(r=e.querySelectorAll)==null||r.call(e,".mention-chip.is-selected").forEach(n=>{n.classList.remove("is-selected")})}function En(e){var m,f;const r=e.ownerDocument,n=e.parentNode;if(!n)return;const a=(b,v)=>{let x=b;for(;x&&x.nodeType===Node.TEXT_NODE&&(x.textContent??"")==="";){const E=x;x=x[v],E.remove()}return x},o=a(e.nextSibling,"nextSibling");if(o&&o.nodeType===Node.TEXT_NODE&&/^( |\u00a0)/.test(o.textContent??"")){const b=o;(b.data.length??0)<=1?b.remove():b.data=b.data.slice(1)}const l=a(e.previousSibling,"previousSibling"),i=n,c=Array.from(n.childNodes).indexOf(e);e.remove();const d=(m=r.defaultView)==null?void 0:m.getSelection();if(!d)return;const u=r.createRange();if(l)if(l.nodeType===Node.TEXT_NODE){const b=((f=l.textContent)==null?void 0:f.length)??0;u.setStart(l,b)}else u.setStartAfter(l);else i.childNodes[c]?u.setStart(i,c):(u.selectNodeContents(i),u.collapse(!1));u.collapse(!0),d.removeAllRanges(),d.addRange(u)}function Co(e){var l;const r=(l=e.ownerDocument.defaultView)==null?void 0:l.getSelection();if(!r||!r.isCollapsed||r.rangeCount===0)return null;const n=r.getRangeAt(0);if(!e.contains(n.startContainer))return null;const{startContainer:a,startOffset:o}=n;if(a.nodeType===Node.TEXT_NODE){const i=a.textContent??"",c=No(a.previousSibling,"prev");return Cn(c)&&(o===0||o===1&&(i.charAt(0)===" "||i.charAt(0)===" "))?c:null}if(a.nodeType===Node.ELEMENT_NODE){const i=a.childNodes;let c=o-1;for(;c>=0;){const d=i[c];if(Cn(d))return d;if(d.nodeType===Node.TEXT_NODE&&!(d.textContent??"").replace(/\u00a0/g," ").trim()){c-=1;continue}break}}return null}function Eo(e){var l;const r=(l=e.ownerDocument.defaultView)==null?void 0:l.getSelection();if(!r||!r.isCollapsed||r.rangeCount===0)return null;const n=r.getRangeAt(0);if(!e.contains(n.startContainer))return null;const{startContainer:a,startOffset:o}=n;if(a.nodeType===Node.TEXT_NODE){const i=a.textContent??"";if(o>=i.length){const c=No(a.nextSibling,"next");if(Cn(c))return c}return null}if(a.nodeType===Node.ELEMENT_NODE){const i=a.childNodes;let c=o;for(;c<i.length;){const d=i[c];if(Cn(d))return d;if(d.nodeType===Node.TEXT_NODE&&!(d.textContent??"").replace(/\u00a0/g," ").trim()){c+=1;continue}break}}return null}function Mo(e){var o;const r=(o=e.ownerDocument.defaultView)==null?void 0:o.getSelection();if(!r||r.isCollapsed||r.rangeCount===0)return[];const n=r.getRangeAt(0);return e.contains(n.commonAncestorContainer)?Array.from(e.querySelectorAll(".mention-chip")).filter(l=>{try{return n.intersectsNode(l)}catch{return!1}}):[]}const _a=280,Mn=6,$o=260,Hd=new Set(["ArrowDown","ArrowUp","Enter","Tab","Escape"]),Bd={position:"relative"},Fd={position:"fixed",zIndex:11050,minWidth:$o,overflowY:"auto",background:"var(--bg-card, var(--bonsaif-ui-surface, #fff))",border:"1px solid var(--border, var(--bonsaif-ui-border, #d0d7de))",borderRadius:10,boxShadow:"0 12px 32px rgba(0,0,0,0.18)",padding:4},To={padding:"10px 12px",fontSize:12,color:"var(--text-muted, #656d76)"};function Pd(e){return Array.from(document.querySelectorAll(`[data-bonsaif-rich-instance="${CSS.escape(e)}"]`))}function _d(e,r){const n=Math.max(8,Math.min(e.left,window.innerWidth-$o-8)),a=r==null?void 0:r.getBoundingClientRect(),o=a?Math.min(window.innerHeight-8,a.bottom):window.innerHeight-8,l=a?Math.max(8,a.top):8,i=o-e.bottom-Mn,c=e.top-l-Mn;return i<Math.min(_a,160)&&c>i?{left:n,bottom:window.innerHeight-e.top+Mn,maxHeight:Math.max(120,Math.min(_a,c))}:{left:n,top:e.bottom+Mn,maxHeight:Math.max(120,Math.min(_a,i))}}function Lo({value:e,onChange:r,onSearchUsers:n,onMentionsChange:a,minHeight:o,placeholder:l,className:i,maxSuggestions:c=8,searchDebounceMs:d=140,highlightInEditor:u=!1,searchCacheKey:m=""}){const f=s.useId().replace(/:/g,""),b=s.useRef(null),v=s.useRef(null),x=s.useRef(new Map),E=s.useRef(n);E.current=n;const h=s.useRef(null),$=s.useRef(0),M=s.useRef([]),[y,w]=s.useState(null),[k,N]=s.useState([]),[A,C]=s.useState(0),[j,W]=s.useState([]),[G,T]=s.useState(!1),[Z,H]=s.useState(!1);$.current=A,s.useEffect(()=>{H(!0)},[]);const ae=(y==null?void 0:y.query)??null;s.useEffect(()=>{if(ae===null){N([]);return}const g=ae.trim(),P=`${m}|${g.toLowerCase()||"*"}`,I=x.current.get(P);if(I){N(I),T(!1),C(0);return}const te=new AbortController;T(!0);const U=window.setTimeout(()=>{(async()=>{try{const K=await E.current(g,{signal:te.signal,limit:c});if(te.signal.aborted)return;const D=Array.isArray(K)?K:[];x.current.set(P,D),N(D),C(0)}catch{te.signal.aborted||N([])}finally{te.signal.aborted||T(!1)}})()},d);return()=>{te.abort(),window.clearTimeout(U)}},[ae,c,d,m]);const X=s.useRef(a);X.current=a,s.useEffect(()=>{var g;(g=X.current)==null||g.call(X,yo(j))},[j]);const V=s.useCallback(()=>{const g=Pd(f);if(g.length===0)return null;const P=window.getSelection();if(P!=null&&P.rangeCount){const te=P.getRangeAt(0).startContainer;for(const U of g)if(U.contains(te))return U}const I=document.activeElement;for(const te of g)if(I===te||I&&te.contains(I))return te;for(const te of g)if(te.closest('[role="dialog"]'))return te;return g[0]??null},[f]),q=s.useCallback(()=>{const g=V(),P=window.getSelection();if(!g||!P||P.rangeCount===0){w(null);return}const I=P.getRangeAt(0);if(!g.contains(I.startContainer)){w(null);return}const te=Pa(g,I.startContainer,I.startOffset);if(te<0){w(null);return}const U=Ha(g,te);if(!U){w(null);return}const K=I.getBoundingClientRect(),D=K.width===0&&K.height===0?(()=>{const _=document.createRange();return _.selectNodeContents(I.startContainer),_.collapse(!0),_.getBoundingClientRect()})():K;h.current={query:U.query,caretIndex:U.caretIndex,triggerIndex:U.triggerIndex};const ee=_d(D,g);w(_=>{const se={query:U.query,...ee};return _&&_.query===se.query&&_.top===se.top&&_.bottom===se.bottom&&_.left===se.left&&_.maxHeight===se.maxHeight?_:se})},[V]),L=s.useCallback(g=>{r(g),q()},[r,q]);s.useEffect(()=>{const g=P=>{if(Hd.has(P.key))return;const I=V(),te=P.target;!I||!te||!I.contains(te)||q()};return document.addEventListener("keyup",g,!0),()=>document.removeEventListener("keyup",g,!0)},[V,q]);const oe=s.useCallback(g=>{const P=V();if(!P)return;let I=-1;const te=window.getSelection();if(te&&te.rangeCount>0){const _=te.getRangeAt(0);P.contains(_.startContainer)&&(I=Pa(P,_.startContainer,_.startOffset))}if(I<0&&h.current&&(I=h.current.caretIndex),I<0)return;const U=Ha(P,I);if(!U)return;const K=wo(P,{triggerIndex:U.triggerIndex,caretIndex:I,username:g.username,display:g.name,userId:g.userId});if(!K)return;P.dispatchEvent(new InputEvent("input",{bubbles:!0,cancelable:!0}));const D={userId:g.userId,username:g.username,email:g.email??void 0,display:g.name??g.username};W(_=>{const se=new Map(_.map(Q=>[Q.userId,Q]));return se.set(D.userId,D),Array.from(se.values())}),w(null),h.current=null;const ee=K.caretPlainOffset;requestAnimationFrame(()=>{requestAnimationFrame(()=>{var Se,ie;const _=V();if(!_)return;_.focus(),ko(_,ee);const se=window.getSelection(),Q=se==null?void 0:se.anchorNode,de=Q instanceof Element?Q.closest(".mention-chip"):(Se=Q==null?void 0:Q.parentElement)==null?void 0:Se.closest(".mention-chip");if(de!=null&&de.parentNode){const pe=document.createRange(),Ce=de.nextSibling;Ce&&Ce.nodeType===Node.TEXT_NODE?pe.setStart(Ce,((ie=Ce.textContent)==null?void 0:ie.length)??0):pe.setStartAfter(de),pe.collapse(!0),se==null||se.removeAllRanges(),se==null||se.addRange(pe)}})})},[V]);s.useEffect(()=>{const g=new Set(Fa(e).map(P=>P.toLowerCase()));W(P=>{const I=P.filter(te=>g.has(te.username.toLowerCase()));return I.length===P.length?P:I})},[e]),s.useEffect(()=>{if(!y)return;const g=P=>{const I=P.target;if(!I||b.current&&b.current.contains(I)||v.current&&v.current.contains(I))return;const te=V();te&&te.contains(I)||w(null)};return document.addEventListener("mousedown",g),()=>{document.removeEventListener("mousedown",g)}},[y,V]);const B=s.useMemo(()=>k.slice(0,c),[k,c]);M.current=B,s.useEffect(()=>{if(!y)return;const g=P=>{const I=V(),te=P.target;if(!I||!te||!I.contains(te))return;const U=M.current;if(!(U.length===0&&P.key!=="Escape"))if(P.key==="ArrowDown")P.preventDefault(),P.stopPropagation(),C(K=>(K+1)%Math.max(U.length,1));else if(P.key==="ArrowUp")P.preventDefault(),P.stopPropagation(),C(K=>(K-1+U.length)%Math.max(U.length,1));else if(P.key==="Enter"||P.key==="Tab"){const K=U[$.current];K&&(P.preventDefault(),P.stopPropagation(),oe(K))}else P.key==="Escape"&&(P.preventDefault(),P.stopPropagation(),w(null))};return document.addEventListener("keydown",g,!0),()=>document.removeEventListener("keydown",g,!0)},[V,oe,y]),s.useEffect(()=>{const g=te=>{te.dispatchEvent(new InputEvent("input",{bubbles:!0,cancelable:!0}))},P=te=>{if(te.key!=="Backspace"&&te.key!=="Delete")return;const U=V(),K=te.target;if(!U||!K||!U.contains(K))return;const D=Mo(U);if(D.length>0){te.preventDefault(),te.stopPropagation();for(const _ of D)En(_);ur(U),g(U);return}if(te.key==="Backspace"){const _=Co(U);if(!_)return;te.preventDefault(),te.stopPropagation(),En(_),ur(U),g(U);return}const ee=Eo(U);ee&&(te.preventDefault(),te.stopPropagation(),En(ee),ur(U),g(U))},I=te=>{const U=V();if(!U)return;const K=te.target;if(!(K instanceof Element)||!U.contains(K))return;const D=K.closest(".mention-chip");if(!(D instanceof HTMLElement)||!U.contains(D)){ur(U);return}te.preventDefault(),U.focus(),ur(U),So(D)};return document.addEventListener("keydown",P,!0),document.addEventListener("mousedown",I,!0),()=>{document.removeEventListener("keydown",P,!0),document.removeEventListener("mousedown",I,!0)}},[V]),s.useEffect(()=>{if(!y||!v.current)return;const g=v.current.querySelector(`[data-mention-index="${A}"]`);g==null||g.scrollIntoView({block:"nearest"})},[A,y]);const F=u?xo(e):e,le=y&&Z?nt.createPortal(t.jsxs("ul",{ref:v,style:{...Fd,left:y.left,top:y.top,bottom:y.bottom,maxHeight:y.maxHeight},role:"listbox","aria-label":"Menciones sugeridas",children:[G&&B.length===0&&t.jsx("li",{style:To,children:"Buscando…"}),!G&&B.length===0&&t.jsx("li",{style:To,children:y.query.trim().length===0?"Escribe un nombre o usuario":`Sin coincidencias para “${y.query}”`}),B.map((g,P)=>{var I,te;return t.jsx("li",{children:t.jsxs("button",{type:"button","data-mention-index":P,onMouseDown:U=>{U.preventDefault(),oe(g)},onMouseEnter:()=>C(P),style:{width:"100%",textAlign:"left",padding:"8px 10px",border:"none",background:P===A?"color-mix(in srgb, var(--primary, var(--bonsaif-ui-primary, #1f6feb)) 14%, transparent)":"transparent",color:"var(--text-main, var(--bonsaif-ui-text, #24292f))",borderRadius:6,cursor:"pointer",display:"flex",flexDirection:"column",gap:2},children:[t.jsx("span",{style:{fontWeight:600,fontSize:13},children:((I=g.name)==null?void 0:I.trim())||`@${g.username}`}),t.jsx("span",{style:{fontSize:11,color:"var(--text-muted, #656d76)"},children:[(te=g.name)!=null&&te.trim()?`@${g.username}`:null,g.email].filter(Boolean).join(" · ")||`@${g.username}`})]})},g.userId)})]}),document.body):null;return t.jsxs("div",{ref:b,style:Bd,className:i,children:[t.jsx(uo,{value:F,onChange:L,placeholder:l,minHeight:o,instanceId:f}),le]})}function zd({value:e,onChange:r,placeholder:n,minHeight:a,onSearchUsers:o,onMentionsChange:l,className:i,maxSuggestions:c,searchDebounceMs:d,highlightInEditor:u,searchCacheKey:m}){return o?t.jsx(Lo,{value:e,onChange:r,onSearchUsers:o,onMentionsChange:l,placeholder:n,minHeight:a,className:i,maxSuggestions:c,searchDebounceMs:d,highlightInEditor:u,searchCacheKey:m}):t.jsx(uo,{value:e,onChange:r,placeholder:n,minHeight:a})}function jd({title:e,subtitle:r,icon:n,actions:a,children:o,footer:l,className:i="",bodyClassName:c="p-4"}){const d=e||r||n||a;return t.jsxs("section",{className:`overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${i}`,children:[d&&t.jsxs("header",{className:"flex items-center justify-between gap-3 border-b border-[var(--border)] px-4 py-3",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[n&&t.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:n}),t.jsxs("div",{className:"min-w-0",children:[e&&t.jsx("h3",{className:"truncate text-sm font-semibold text-[var(--text-main)]",children:e}),r&&t.jsx("div",{className:"truncate text-xs text-[var(--text-muted)]",children:r})]})]}),a&&t.jsx("div",{className:"shrink-0",children:a})]}),t.jsx("div",{className:c,children:o}),l&&t.jsx("footer",{className:"border-t border-[var(--border)] px-4 py-3",children:l})]})}const Wd={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)"}},qd={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 Ud({children:e,tone:r="neutral",size:n="sm",icon:a,dot:o=!1,className:l=""}){const i=Wd[r];return t.jsxs("span",{className:`inline-flex max-w-full shrink-0 items-center gap-1.5 rounded-full border font-semibold leading-none ${qd[n]} ${l}`,style:{color:i.text,background:i.bg,borderColor:i.border},children:[o&&t.jsx("span",{"aria-hidden":"true",className:"h-1.5 w-1.5 shrink-0 rounded-full",style:{background:i.text}}),a&&t.jsx("span",{className:"shrink-0",children:a}),t.jsx("span",{className:"min-w-0 truncate",children:e})]})}const Ao={neutral:{color:"var(--text-secondary)",background:"var(--bg-input)"},primary:{color:"var(--primary)",background:"color-mix(in srgb, var(--primary) 10%, transparent)"},success:{color:"#047857",background:"rgba(16, 185, 129, 0.11)"},warning:{color:"#b45309",background:"rgba(245, 158, 11, 0.12)"},danger:{color:"var(--danger)",background:"var(--danger-bg)"},info:{color:"#2563eb",background:"rgba(59, 130, 246, 0.11)"}},Vd={xs:"min-h-5 px-1.5 pr-6 text-[10px]",sm:"min-h-6 px-2 pr-7 text-xs",md:"min-h-7 px-2.5 pr-8 text-sm"},Yd={xs:"right-1 h-3 w-3",sm:"right-1.5 h-3 w-3",md:"right-2 h-3.5 w-3.5"},Xd={xs:148,sm:164,md:184},Kd={xs:"px-2.5 py-1.5 text-xs",sm:"px-3 py-2 text-sm",md:"px-3.5 py-2.5 text-sm"};function Gd({value:e,options:r,onChange:n,size:a="sm",disabled:o=!1,loading:l=!1,stopPropagation:i=!1,ariaLabel:c="Cambiar estado",title:d="Cambiar estado",className:u,selectClassName:m,menuClassName:f,optionClassName:b,spinnerClassName:v}){const[x,E]=s.useState(!1),[h,$]=s.useState(!1),[M,y]=s.useState(-1),[w,k]=s.useState({}),N=s.useRef(null),A=s.useRef(null),C=s.useRef(null),j=r.find(q=>q.value===e)??r[0],W={...j!=null&&j.tone?Ao[j.tone]:void 0,...j==null?void 0:j.style},G=o||l||r.length===0,T=q=>{i&&q.stopPropagation()},Z=s.useCallback(()=>{E(!1),y(-1)},[]),H=s.useCallback(()=>{const q=N.current;if(!q)return;const L=q.getBoundingClientRect(),oe=Math.max(L.width,Xd[a]),B=Math.min(Math.max(r.length,1)*38+12,260),F=window.innerHeight-L.bottom,le=F<B&&L.top>F,g=Math.min(Math.max(8,L.left+L.width/2-oe/2),window.innerWidth-oe-8);k({position:"fixed",left:g,top:le?void 0:L.bottom+6,bottom:le?window.innerHeight-L.top+6:void 0,width:oe,zIndex:9999})},[r.length,a]),ae=s.useCallback(q=>{q.disabled||(n(q.value),Z())},[Z,n]);s.useEffect(()=>$(!0),[]),s.useEffect(()=>{if(!x)return;H();const q=r.findIndex(L=>L.value===e);y(q>=0?q:0)},[x,r,H,e]),s.useEffect(()=>{if(!x)return;function q(L){var B,F;const oe=L.target;!((B=N.current)!=null&&B.contains(oe))&&!((F=A.current)!=null&&F.contains(oe))&&Z()}return document.addEventListener("mousedown",q),()=>document.removeEventListener("mousedown",q)},[Z,x]),s.useEffect(()=>{if(x)return window.addEventListener("resize",H),window.addEventListener("scroll",H,!0),()=>{window.removeEventListener("resize",H),window.removeEventListener("scroll",H,!0)}},[x,H]),s.useEffect(()=>{if(M<0||!C.current)return;const q=C.current.children[M];q==null||q.scrollIntoView({block:"nearest"})},[M]);function X(q){if(!G){if(!x){["Enter"," ","ArrowDown","ArrowUp"].includes(q.key)&&(q.preventDefault(),E(!0));return}if(q.key==="Escape"){q.preventDefault(),Z();return}if(q.key==="ArrowDown"){q.preventDefault(),y(L=>Math.min(L+1,r.length-1));return}if(q.key==="ArrowUp"){q.preventDefault(),y(L=>Math.max(L-1,0));return}if(q.key==="Enter"||q.key===" "){q.preventDefault();const L=r[M];L&&ae(L)}}}const V=t.jsx("div",{ref:A,role:"listbox","aria-label":c,className:Tt("overflow-hidden rounded-xl border shadow-xl backdrop-blur-md",f),style:{...w,background:"color-mix(in srgb, var(--bg-card) 92%, transparent)",borderColor:"var(--border)",color:"var(--text-main)"},onClick:T,onMouseDown:T,onPointerDown:T,children:t.jsx("div",{ref:C,className:"max-h-64 overflow-y-auto p-1",style:{scrollbarWidth:"thin",scrollbarColor:"var(--border) transparent",overscrollBehavior:"contain"},children:r.map((q,L)=>{const oe=q.value===e,B=L===M,F={...q.tone?Ao[q.tone]:void 0,...q.style};return t.jsxs("button",{type:"button",role:"option","aria-selected":oe,disabled:q.disabled,onMouseEnter:()=>!q.disabled&&y(L),onMouseDown:le=>{le.preventDefault(),ae(q)},className:Tt("flex w-full items-center gap-2 rounded-lg font-medium text-left transition-colors disabled:cursor-not-allowed disabled:opacity-45",Kd[a],oe?q.className:void 0,b),style:{...oe?F:void 0,background:oe?F.background??"color-mix(in srgb, var(--primary) 12%, transparent)":B?"var(--bg-hover)":"transparent",color:oe?F.color??"var(--primary)":"var(--text-main)"},children:[t.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center",children:oe?t.jsx(z.HiCheck,{className:"h-4 w-4"}):null}),t.jsx("span",{className:"min-w-0 flex-1 truncate",children:q.label})]},q.value)})})});return t.jsxs("span",{ref:N,className:Tt("relative inline-flex shrink-0 items-center",u),onKeyDown:X,onClick:T,onPointerDown:T,children:[t.jsx("button",{type:"button",disabled:G,"aria-label":c,"aria-haspopup":"listbox","aria-expanded":x,title:d,onClick:()=>!G&&E(q=>!q),className:Tt("inline-flex items-center rounded-full border border-transparent font-medium leading-none outline-none transition-colors hover:border-current focus:border-current disabled:cursor-wait disabled:opacity-70",Vd[a],j==null?void 0:j.className,m),style:W,children:t.jsx("span",{className:"min-w-0 truncate",children:(j==null?void 0:j.label)??e})}),t.jsx(z.HiChevronDown,{"aria-hidden":"true",className:Tt("pointer-events-none absolute opacity-70 transition-transform",Yd[a],x?"rotate-180":"rotate-0")}),l&&t.jsx("span",{"aria-hidden":"true",className:Tt("absolute -right-1 -top-1 h-2.5 w-2.5 rounded-full border border-current border-t-transparent animate-spin",v)}),x&&h&&nt.createPortal(V,document.body)]})}function Zd({tabs:e,activeTabId:r,defaultActiveTabId:n,onTabChange:a,ariaLabel:o="Pestanas",variant:l="underline",className:i="",listClassName:c="",panelClassName:d=""}){const u=e.find(x=>!x.disabled)??e[0],m=r??n??(u==null?void 0:u.id),f=e.find(x=>x.id===m)??u,b=x=>{x.disabled||a==null||a(x.id)},v=x=>{const E=e.filter($=>!$.disabled);if(!E.length||!f)return;const h=E.findIndex($=>$.id===f.id);(x.key==="ArrowRight"||x.key==="ArrowDown")&&(x.preventDefault(),b(E[(h+1)%E.length])),(x.key==="ArrowLeft"||x.key==="ArrowUp")&&(x.preventDefault(),b(E[(h-1+E.length)%E.length])),x.key==="Home"&&(x.preventDefault(),b(E[0])),x.key==="End"&&(x.preventDefault(),b(E[E.length-1]))};return t.jsxs("div",{className:i,children:[t.jsx("div",{role:"tablist","aria-label":o,onKeyDown:v,className:`flex min-w-0 gap-1 overflow-x-auto ${l==="underline"?"border-b border-[var(--border)]":"rounded-lg border border-[var(--border)] bg-[var(--bg-input)] p-1"} ${c}`,children:e.map(x=>{const E=x.id===(f==null?void 0:f.id);return t.jsxs("button",{type:"button",role:"tab","aria-selected":E,"aria-controls":`${x.id}-panel`,id:`${x.id}-tab`,disabled:x.disabled,tabIndex:E?0:-1,onClick:()=>b(x),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 ${l==="underline"?"border-b-2":"rounded-md border"}`,style:{color:E?"var(--primary)":"var(--text-muted)",borderColor:E?"var(--primary)":"transparent",background:l==="pills"&&E?"var(--bg-card)":"transparent"},children:[x.icon&&t.jsx("span",{className:"shrink-0",children:x.icon}),t.jsx("span",{children:x.label}),x.badge&&t.jsx("span",{className:"shrink-0",children:x.badge})]},x.id)})}),(f==null?void 0:f.content)!==void 0&&t.jsx("div",{role:"tabpanel",id:`${f.id}-panel`,"aria-labelledby":`${f.id}-tab`,className:`pt-4 ${d}`,children:f.content})]})}function Dt(...e){return e.filter(Boolean).join(" ")}function Qd({steps:e,activeStepId:r,initialStepId:n,completedStepIds:a,defaultCompletedStepIds:o=[],onActiveStepChange:l,onCompletedStepIdsChange:i,onBlockedStep:c,allowBackNavigation:d=!0,showFooter:u=!0,previousLabel:m="Anterior",nextLabel:f="Siguiente",blockedNextLabel:b="Completa este paso",className:v="",headerClassName:x="",contentClassName:E="",footerClassName:h=""}){var U;const $=((U=e[0])==null?void 0:U.id)??"",[M,y]=s.useState(n??$),[w,k]=s.useState(o),N=r??M,A=a??w,C=s.useMemo(()=>new Set(A),[A]),j=Math.max(0,e.findIndex(K=>K.id===N)),W=e[j]??e[0],G=e.length<=1?100:j/(e.length-1)*100,T=K=>{a||k(K),i==null||i(K)},Z=K=>{const D=e.find(ee=>ee.id===K);D&&(r||y(K),l==null||l(K,D))},H=K=>C.has(K),ae=K=>e.slice(0,K).find(D=>!D.optional&&!C.has(D.id)),X=K=>{const D=e[K];return!D||D.disabled?!1:K===j||d&&K<j?!0:!ae(K)},V=K=>{const D=e.findIndex(ee=>ee.id===K);return D>=0&&X(D)},q=K=>{const D=e.findIndex(ee=>ee.id===K);if(D<0)return!1;if(!X(D)){const ee=ae(D);return ee&&(c==null||c(e[D],ee)),!1}return Z(K),!0},L=(K=W==null?void 0:W.id)=>{!K||C.has(K)||T([...A,K])},oe=(K=W==null?void 0:W.id)=>{if(!K)return;const D=e.findIndex(_=>_.id===K),ee=A.filter(_=>{const se=e.findIndex(Q=>Q.id===_);return se>=0&&se<D});T(ee),D>=0&&j>D&&Z(K)},B=()=>j<=0?!1:q(e[j-1].id),F=()=>{const K=e[j+1];return K?q(K.id):!1},le={activeStep:W,activeIndex:j,completedStepIds:A,isCompleted:H,isUnlocked:V,completeStep:L,uncompleteStep:oe,goToStep:q,goNext:F,goPrevious:B};if(!W)return null;const g=e[j+1],P=j>0,I=g?V(g.id):!1,te=typeof W.content=="function"?W.content(le):W.content;return t.jsxs("section",{className:Dt("overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)]",v),children:[t.jsxs("div",{className:Dt("border-b border-[var(--border)] bg-[var(--bg-input)]",x),children:[t.jsx("div",{className:"relative h-1 overflow-hidden bg-[var(--border)]/55",children:t.jsx("div",{className:"h-full rounded-r-full bg-[var(--primary)] transition-[width] duration-500 ease-out",style:{width:`${G}%`}})}),t.jsx("div",{className:"grid gap-2 p-2",style:{gridTemplateColumns:`repeat(${e.length}, minmax(0, 1fr))`},children:e.map((K,D)=>{const ee=K.id===W.id,_=H(K.id),se=X(D),Q=ae(D);return t.jsxs("button",{type:"button",disabled:!se,"aria-current":ee?"step":void 0,"aria-disabled":!se,title:!se&&Q?`Completa ${Q.title}`:K.title,onClick:()=>q(K.id),className:Dt("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",ee&&"border-[var(--primary)] bg-[var(--bg-card)] shadow-sm",_&&!ee&&"border-[var(--primary)]/35 bg-[var(--bg-card)]",!ee&&!_&&se&&"border-transparent bg-[var(--bg-card)]/45 hover:border-[var(--border)] hover:bg-[var(--bg-card)]",!se&&"border-transparent bg-[var(--bg-card)]/35 opacity-60"),children:[t.jsx("span",{className:Dt("absolute inset-x-0 top-0 h-0.5 origin-left scale-x-0 bg-[var(--primary)] transition-transform duration-300",ee&&"scale-x-100")}),t.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[t.jsx("span",{className:Dt("grid h-7 w-7 shrink-0 place-items-center rounded-full border text-xs font-bold transition-all duration-200",ee&&"border-[var(--primary)] bg-[var(--primary)] text-[var(--primary-fg)]",_&&!ee&&"border-[var(--primary)] bg-[var(--primary)]/12 text-[var(--primary)]",!_&&!ee&&se&&"border-[var(--border)] text-[var(--text-muted)]",!se&&"border-[var(--border)] text-[var(--text-muted)]"),children:_?t.jsx(z.HiCheck,{className:"h-4 w-4"}):se?D+1:t.jsx(z.HiLockClosed,{className:"h-3.5 w-3.5"})}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsxs("span",{className:Dt("block truncate text-xs font-semibold transition-colors duration-200",ee?"text-[var(--text-main)]":"text-[var(--text-secondary)]"),children:[D+1,". ",K.title]}),K.description&&t.jsx("span",{className:"mt-1 block truncate text-[11px] text-[var(--text-muted)]",children:K.description})]}),K.badge&&t.jsx("span",{className:"shrink-0",children:K.badge})]})]},K.id)})})]}),t.jsx("div",{className:Dt("min-h-72 animate-[stepWizardIn_220ms_ease-out] p-5",E),children:te},W.id),u&&t.jsxs("div",{className:Dt("flex flex-wrap items-center justify-between gap-3 border-t border-[var(--border)] bg-[var(--bg-input)] px-4 py-3",h),children:[t.jsx(je,{variant:"secondary",height:38,padding:"0 14px",icon:t.jsx(z.HiChevronLeft,{}),disabled:!P,onClick:B,children:m}),t.jsxs("div",{className:"flex items-center gap-3 text-xs text-[var(--text-muted)]",children:[t.jsxs("span",{children:["Paso ",j+1," de ",e.length]}),t.jsx("span",{className:"h-1 w-1 rounded-full bg-[var(--border)]"}),t.jsxs("span",{children:[A.length," completados"]})]}),t.jsx(je,{height:38,padding:"0 14px",icon:t.jsx(z.HiChevronRight,{}),disabled:!g||!I,onClick:F,children:g&&!I?b:f})]})]})}const Jd={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"},Rd={none:"resize-none",vertical:"resize-y",horizontal:"resize-x",both:"resize"};function eu(e,r){if(e){if(typeof e=="function"){e(r);return}e.current=r}}function tu(e,r){return e!==void 0?String(e).length:r!==void 0?String(r).length:0}const Do=s.forwardRef(function({className:r="",wrapperClassName:n="",size:a="md",resize:o="vertical",autoResize:l=!1,minRows:i,maxRows:c,showCount:d=!1,maxCount:u,status:m="default",icon:f,action:b,style:v,value:x,defaultValue:E,maxLength:h,onInput:$,...M},y){const w=s.useRef(null),k=tu(x,E),N=u??h,A=!!(f||b||d),C=m==="error"?"var(--danger)":m==="success"?"#16a34a":"var(--border)",j={...v??{},...i?{minHeight:`${i*24+18}px`}:null,...c?{maxHeight:`${c*24+18}px`}:null},W=()=>{const T=w.current;!T||!l||(T.style.height="auto",T.style.height=`${T.scrollHeight}px`)};s.useEffect(W,[l,x]);const G=t.jsx("textarea",{...M,ref:T=>{w.current=T,eu(y,T)},value:x,defaultValue:E,maxLength:h,"aria-invalid":m==="error"||M["aria-invalid"],onInput:T=>{W(),$==null||$(T)},style:{...j,borderColor:C},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 ${Jd[a]} ${Rd[l?"none":o]} ${f?"pl-8":""} ${b?"pr-10":""} ${r}`});return A?t.jsxs("span",{className:`relative block ${n}`,children:[f&&t.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:f}),G,b&&t.jsx("span",{className:"absolute right-2 top-2 flex items-center justify-center",children:b}),d&&t.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:[k,N?`/${N}`:""]})]}):G});function ru({label:e,containerClassName:r="",helperText:n,helperDisplay:a,error:o,labelAction:l,required:i,className:c="",status:d,...u}){return t.jsx(Ea,{label:e,required:i,helperText:n,helperDisplay:a,error:o,labelAction:l,className:r,children:t.jsx(Do,{...u,required:i,status:o?"error":d,className:`w-full ${c}`})})}const Io=[{bg:"#dbeafe",text:"#1e40af",border:"#bfdbfe"},{bg:"#dcfce7",text:"#166534",border:"#bbf7d0"},{bg:"#fce7f3",text:"#9d174d",border:"#fbcfe8"},{bg:"#fef9c3",text:"#854d0e",border:"#fef08a"},{bg:"#ede9fe",text:"#5b21b6",border:"#ddd6fe"},{bg:"#ffedd5",text:"#9a3412",border:"#fed7aa"},{bg:"#cffafe",text:"#155e75",border:"#a5f3fc"},{bg:"#f0fdf4",text:"#14532d",border:"#bbf7d0"}];function nu(e){return Io[e%Io.length]}let au=0;function za(){return++au}function Oo(e,r){return r?r instanceof RegExp?r.test(e):r(e):!0}function su(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ou(e,r){const n=r.filter(Boolean);if(n.length===0)return[e.trim()].filter(Boolean);const a=new RegExp(`${n.map(o=>su(o)).join("|")}|\\r?\\n`,"g");return e.split(a).map(o=>o.trim()).filter(Boolean)}function lu({value:e,defaultValue:r,onChange:n,placeholder:a="Escribe y presiona Enter…",disabled:o=!1,className:l="",delimiters:i=[","],maxTags:c,allowDuplicates:d=!1,validate:u,label:m,helperText:f,helperDisplay:b="inline",error:v,required:x=!1}){const E=e!==void 0,h=!!v,$=!!f&&b==="tooltip"&&!h,[M,y]=s.useState(()=>(r??[]).map((_,se)=>({id:za(),value:_.trim(),colorIndex:se})));s.useEffect(()=>{E&&y(_=>{const se=e??[],Q=new Map(_.map(de=>[de.value,de]));return se.map((de,Se)=>Q.get(de)??{id:za(),value:de,colorIndex:Se})})},[E,e]);const w=M,[k,N]=s.useState(""),[A,C]=s.useState(null),[j,W]=s.useState(""),[G,T]=s.useState(!1),[Z,H]=s.useState(!1),ae=s.useRef(null),X=s.useRef(null),V=s.useRef(null);function q(){H(!0),setTimeout(()=>H(!1),400)}function L(_){y(_),n==null||n(_.map(se=>se.value))}function oe(_){let se=w,Q=!1,de=!1;for(const Se of _){const ie=Se.trim();if(ie){if(c!==void 0&&se.length>=c){de=!0;break}if(!d&&se.some(pe=>pe.value.toLowerCase()===ie.toLowerCase())){de=!0;continue}if(!Oo(ie,u)){de=!0;continue}se=[...se,{id:za(),value:ie,colorIndex:se.length}],Q=!0}}return Q&&L(se),de&&q(),Q}function B(_){return oe([_])}function F(_){const se=w.filter(Q=>Q.id!==_);L(se.map((Q,de)=>({...Q,colorIndex:de})))}function le(_,se){const Q=se.trim();if(C(null),W(""),!Q){F(_);return}if(!(!d&&w.some(de=>de.id!==_&&de.value.toLowerCase()===Q.toLowerCase()))){if(!Oo(Q,u)){q();return}L(w.map(de=>de.id===_?{...de,value:Q}:de))}}function g(_){o||(C(_.id),W(_.value),setTimeout(()=>{var se;return(se=X.current)==null?void 0:se.select()},0))}function P(_){if(_.key==="Enter"||i.includes(_.key)){_.preventDefault(),B(k)&&N("");return}if(_.key==="Backspace"&&k===""&&w.length>0){_.preventDefault();const se=w[w.length-1];F(se.id)}}function I(_,se){if(_.key==="Enter"){_.preventDefault(),le(se,j),setTimeout(()=>{var Q;return(Q=ae.current)==null?void 0:Q.focus()},0);return}_.key==="Escape"&&(_.preventDefault(),C(null),W(""),setTimeout(()=>{var Q;return(Q=ae.current)==null?void 0:Q.focus()},0))}function te(){var _;o||(_=ae.current)==null||_.focus()}function U(_){if(o)return;const se=_.clipboardData.getData("text");if(!se||!(i.some(ie=>ie&&se.includes(ie))||se.includes(`
29
- `)))return;_.preventDefault();const de=ou(se,i);oe(de)&&N("")}function K(){const _=k.trim();_&&B(_)&&N("")}const D=h?"var(--danger)":G?"var(--primary)":"var(--border)",ee=c!==void 0&&w.length>=c;return t.jsxs("div",{className:`flex flex-col gap-2 ${l}`,children:[(m||x||$)&&t.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-semibold uppercase text-[var(--text-muted)]",children:[m&&t.jsx("span",{children:m}),x&&t.jsx("span",{className:"text-[var(--danger)]",children:"*"}),$?t.jsx(or,{content:f}):null]}),t.jsxs("div",{ref:V,onClick:te,onFocus:()=>T(!0),onBlur:_=>{var se;(se=V.current)!=null&&se.contains(_.relatedTarget)||(T(!1),A!==null&&le(A,j),A===null&&K())},style:{borderColor:D},className:`
28
+ `).replace(/<[^>]+>/g," ").replace(/&nbsp;/g," ").replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&#39;/g,"'").replace(/\s+/g," ").trim():""}function so(e){if(!e)return[];const r=new Set,n=[],a=d=>{const u=oo(d);!u||r.has(u)||(r.add(u),n.push(u))},s=/data-username\s*=\s*["']([^"']+)["']/gi;let l;for(;(l=s.exec(e))!==null;)a(l[1]??"");const i=Zs(e);no.lastIndex=0;let c;for(;(c=no.exec(i))!==null;)a(c[1]??"");return n}function Qs(e){const r=String(e.name??"").trim();return r||String(e.username??"").trim()||"usuario"}function Cu(e,r){const n=so(e);if(!n.length)return[];const a=new Map;r.forEach(i=>{i.username&&a.set(oo(i.username),i)});const s=new Set,l=[];for(const i of n){const c=a.get(i);c&&(s.has(c.userId)||(s.add(c.userId),l.push({userId:c.userId,username:c.username,email:c.email??void 0,display:c.name??c.username})))}return l}function Js(e){const r=new Set,n=[];for(const a of e)r.has(a.userId)||(r.add(a.userId),n.push(a));return n}function Eu(e,r){return r?e.filter(n=>n.userId!==r):e}function Rs(e){return!e||!/@/.test(e)?e:e.replace(no,(r,n,a,s)=>{const l=s.slice(0,a),i=l.lastIndexOf("<"),c=l.lastIndexOf(">");return i>c?r:`<span class="mention-chip" contenteditable="false" data-username="${(n??"").toLowerCase()}">${r}</span>`})}const Mu=new Set(["P","DIV","LI","H1","H2","H3","H4","H5","H6","BLOCKQUOTE"]);function el(e,r){return Mu.has(e.tagName)&&e!==r}function lo(e,r){let n="",a,s,l=!1;const i=(f,h)=>{if(l||!(r!=null&&r.domPoint))return;const{container:v,offset:k}=r.domPoint;v===f&&k===h&&(s=n.length,l=!0)},c=(f,h)=>(r==null?void 0:r.locatePlain)!==n.length?!1:(a={node:f,offset:h},!0),d=f=>(r==null?void 0:r.locatePlain)===n.length?(f==null?void 0:f.nodeType)===Node.TEXT_NODE?(a={node:f,offset:0},"matched"):"matched-at-newline":(n+=`
29
+ `,(r==null?void 0:r.locatePlain)===n.length?(f==null?void 0:f.nodeType)===Node.TEXT_NODE?(a={node:f,offset:0},"matched"):"matched-at-newline":!1),u=f=>{const h=f.data;for(let v=0;v<=h.length;v+=1){if(i(f,v),c(f,v))return!0;v<h.length&&(n+=h[v])}return!1},m=(f,h)=>{if(h&&n.length>0&&!n.endsWith(`
30
+ `)&&d(f)==="matched")return!0;if(f.nodeType===Node.TEXT_NODE)return u(f);if(f.nodeType!==Node.ELEMENT_NODE)return!1;const v=f;if(v.tagName==="BR")return i(v,0),d(v.nextSibling??void 0)==="matched";const k=Array.from(f.childNodes);for(let g=0;g<k.length;g+=1){const A=k[g],$=g>0&&A.nodeType===Node.ELEMENT_NODE&&el(A,e);if(m(A,$))return!0}return!1},b=Array.from(e.childNodes);for(let f=0;f<b.length;f+=1){const h=b[f],v=f>0&&h.nodeType===Node.ELEMENT_NODE&&el(h,e);if(m(h,v))break}if((r==null?void 0:r.locatePlain)===n.length&&!a){const f=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_TEXT);let h=f.nextNode(),v=h;for(;v;)h=v,v=f.nextNode();h&&(a={node:h,offset:h.data.length})}return{plain:n,locate:a,domOffset:s}}function io(e){return lo(e).plain}function Cr(e,r){return r<0?null:lo(e,{locatePlain:r}).locate??null}function qn(e,r,n){return e!==r&&!e.contains(r)?-1:lo(e,{domPoint:{container:r,offset:n}}).domOffset??-1}function tl(e,r){const{triggerIndex:n,caretIndex:a,username:s}=r;if(a<n)return null;const l=Cr(e,n),i=Cr(e,a);if(!l||!i)return null;const c=e.ownerDocument,d=c.createRange();d.setStart(l.node,l.offset),d.setEnd(i.node,i.offset),d.deleteContents();const u=Qs({name:r.display,username:s}),m=c.createElement("span");m.className="mention-chip",m.setAttribute("data-username",s.toLowerCase()),r.userId&&m.setAttribute("data-userid",String(r.userId)),m.contentEditable="false",m.textContent=u,m.title=`@${s}`;const b=c.createTextNode(" ");d.insertNode(b),d.insertNode(m);const f=c.defaultView,h=f==null?void 0:f.getSelection();if(h){const k=c.createRange();k.setStart(b,b.data.length),k.collapse(!0),h.removeAllRanges(),h.addRange(k)}const v=h!=null&&h.rangeCount?qn(e,h.getRangeAt(0).startContainer,h.getRangeAt(0).startOffset):n+u.length+1;return{caretPlainOffset:v>=0?v:n+u.length+1}}function rl(e,r){const n=e.ownerDocument,a=n.defaultView;if(!a)return;const s=a.getSelection();if(!s)return;const l=n.createRange(),i=Cr(e,r);i?(l.setStart(i.node,i.offset),l.collapse(!0)):(l.selectNodeContents(e),l.collapse(!1)),s.removeAllRanges(),s.addRange(l)}function Un(e){return e instanceof HTMLElement&&e.classList.contains("mention-chip")}function nl(e,r){let n=e;for(;n&&n.nodeType===Node.TEXT_NODE&&!(n.textContent??"").replace(/\u00a0/g," ").trim();)n=r==="prev"?n.previousSibling:n.nextSibling;return n}function al(e){var s;const r=e.ownerDocument,n=(s=r.defaultView)==null?void 0:s.getSelection();if(!n)return;const a=r.createRange();a.selectNode(e),n.removeAllRanges(),n.addRange(a),e.classList.add("is-selected")}function Er(e=document){var r;(r=e.querySelectorAll)==null||r.call(e,".mention-chip.is-selected").forEach(n=>{n.classList.remove("is-selected")})}function Vn(e){var a;const r=(a=e.ownerDocument.defaultView)==null?void 0:a.getSelection();e.querySelectorAll(".mention-chip").forEach(s=>{let l=!1;if(r&&r.rangeCount>0)try{const i=r.getRangeAt(0);(!r.isCollapsed&&i.intersectsNode(s)||r.isCollapsed&&i.startContainer===s&&i.endContainer===s)&&(l=!0)}catch{l=!1}s.classList.toggle("is-selected",l)})}function ol(e){var s;const r=e.ownerDocument,n=(s=r.defaultView)==null?void 0:s.getSelection();if(!n)return;const a=r.createRange();a.selectNodeContents(e),n.removeAllRanges(),n.addRange(a),Vn(e)}function sl(e){const r=e.cloneContents();return r.querySelectorAll(".mention-chip").forEach(n=>n.remove()),(r.textContent??"").replace(/\u00a0/g," ").trim().length>0}function ll(e){var a;const r=(a=e.ownerDocument.defaultView)==null?void 0:a.getSelection();if(!r||r.isCollapsed||r.rangeCount===0)return!1;const n=r.getRangeAt(0);return e.contains(n.commonAncestorContainer)?(n.deleteContents(),Er(e),!0):!1}function Yn(e){var m,b;const r=e.ownerDocument,n=e.parentNode;if(!n)return;const a=(f,h)=>{let v=f;for(;v&&v.nodeType===Node.TEXT_NODE&&(v.textContent??"")==="";){const k=v;v=v[h],k.remove()}return v},s=a(e.nextSibling,"nextSibling");if(s&&s.nodeType===Node.TEXT_NODE&&/^( |\u00a0)/.test(s.textContent??"")){const f=s;(f.data.length??0)<=1?f.remove():f.data=f.data.slice(1)}const l=a(e.previousSibling,"previousSibling"),i=n,c=Array.from(n.childNodes).indexOf(e);e.remove();const d=(m=r.defaultView)==null?void 0:m.getSelection();if(!d)return;const u=r.createRange();if(l)if(l.nodeType===Node.TEXT_NODE){const f=((b=l.textContent)==null?void 0:b.length)??0;u.setStart(l,f)}else u.setStartAfter(l);else i.childNodes[c]?u.setStart(i,c):(u.selectNodeContents(i),u.collapse(!1));u.collapse(!0),d.removeAllRanges(),d.addRange(u)}function il(e){var l;const r=(l=e.ownerDocument.defaultView)==null?void 0:l.getSelection();if(!r||!r.isCollapsed||r.rangeCount===0)return null;const n=r.getRangeAt(0);if(!e.contains(n.startContainer))return null;const{startContainer:a,startOffset:s}=n;if(a.nodeType===Node.TEXT_NODE){const i=a.textContent??"",c=nl(a.previousSibling,"prev");return Un(c)&&(s===0||s===1&&(i.charAt(0)===" "||i.charAt(0)===" "))?c:null}if(a.nodeType===Node.ELEMENT_NODE){const i=a.childNodes;let c=s-1;for(;c>=0;){const d=i[c];if(Un(d))return d;if(d.nodeType===Node.TEXT_NODE&&!(d.textContent??"").replace(/\u00a0/g," ").trim()){c-=1;continue}break}}return null}function cl(e){var l;const r=(l=e.ownerDocument.defaultView)==null?void 0:l.getSelection();if(!r||!r.isCollapsed||r.rangeCount===0)return null;const n=r.getRangeAt(0);if(!e.contains(n.startContainer))return null;const{startContainer:a,startOffset:s}=n;if(a.nodeType===Node.TEXT_NODE){const i=a.textContent??"";if(s>=i.length){const c=nl(a.nextSibling,"next");if(Un(c))return c}return null}if(a.nodeType===Node.ELEMENT_NODE){const i=a.childNodes;let c=s;for(;c<i.length;){const d=i[c];if(Un(d))return d;if(d.nodeType===Node.TEXT_NODE&&!(d.textContent??"").replace(/\u00a0/g," ").trim()){c+=1;continue}break}}return null}function co(e){var s;const r=(s=e.ownerDocument.defaultView)==null?void 0:s.getSelection();if(!r||r.isCollapsed||r.rangeCount===0)return[];const n=r.getRangeAt(0);return e.contains(n.commonAncestorContainer)?Array.from(e.querySelectorAll(".mention-chip")).filter(l=>{try{return n.intersectsNode(l)}catch{return!1}}):[]}const uo=280,Xn=6,dl=260,Tu=new Set(["ArrowDown","ArrowUp","Enter","Tab","Escape"]),ul=4,$u={position:"relative"},Au={position:"fixed",zIndex:11050,minWidth:dl,overflowY:"auto",background:"var(--bg-card, var(--bonsaif-ui-surface, #fff))",border:"1px solid var(--border, var(--bonsaif-ui-border, #d0d7de))",borderRadius:10,boxShadow:"0 12px 32px rgba(0,0,0,0.18)",padding:4},fl={padding:"10px 12px",fontSize:12,color:"var(--text-muted, #656d76)"};function Lu(e){return Array.from(document.querySelectorAll(`[data-bonsaif-rich-instance="${CSS.escape(e)}"]`))}function Du(e,r){const n=Math.max(8,Math.min(e.left,window.innerWidth-dl-8)),a=r==null?void 0:r.getBoundingClientRect(),s=a?Math.min(window.innerHeight-8,a.bottom):window.innerHeight-8,l=a?Math.max(8,a.top):8,i=s-e.bottom-Xn,c=e.top-l-Xn;return i<Math.min(uo,160)&&c>i?{left:n,bottom:window.innerHeight-e.top+Xn,maxHeight:Math.max(120,Math.min(uo,c))}:{left:n,top:e.bottom+Xn,maxHeight:Math.max(120,Math.min(uo,i))}}function bl({value:e,onChange:r,onSearchUsers:n,onMentionsChange:a,minHeight:s,placeholder:l,className:i,maxSuggestions:c=8,searchDebounceMs:d=140,highlightInEditor:u=!1,searchCacheKey:m=""}){const b=o.useId().replace(/:/g,""),f=o.useRef(null),h=o.useRef(null),v=o.useRef(new Map),k=o.useRef(n);k.current=n;const g=o.useRef(null),A=o.useRef(0),$=o.useRef([]),N=o.useRef(null),[T,x]=o.useState(null),[y,L]=o.useState([]),[w,W]=o.useState(0),[X,Z]=o.useState([]),[D,Q]=o.useState(!1),[j,se]=o.useState(!1);A.current=w,o.useEffect(()=>{se(!0)},[]);const te=(T==null?void 0:T.query)??null;o.useEffect(()=>{if(te===null){L([]);return}const I=te.trim(),M=`${m}|${I.toLowerCase()||"*"}`,oe=v.current.get(M);if(oe){L(oe),Q(!1),W(0);return}const K=new AbortController;Q(!0);const Y=window.setTimeout(()=>{(async()=>{try{const S=await k.current(I,{signal:K.signal,limit:c});if(K.signal.aborted)return;const H=Array.isArray(S)?S:[];v.current.set(M,H),L(H),W(0)}catch{K.signal.aborted||L([])}finally{K.signal.aborted||Q(!1)}})()},d);return()=>{K.abort(),window.clearTimeout(Y)}},[te,c,d,m]);const ee=o.useRef(a);ee.current=a,o.useEffect(()=>{var I;(I=ee.current)==null||I.call(ee,Js(X))},[X]);const U=o.useCallback(()=>{const I=Lu(b);if(I.length===0)return null;const M=window.getSelection();if(M!=null&&M.rangeCount){const K=M.getRangeAt(0).startContainer;for(const Y of I)if(Y.contains(K))return Y}const oe=document.activeElement;for(const K of I)if(oe===K||oe&&K.contains(oe))return K;for(const K of I)if(K.closest('[role="dialog"]'))return K;return I[0]??null},[b]),J=o.useCallback(()=>{const I=U(),M=window.getSelection();if(!I||!M||M.rangeCount===0){x(null);return}const oe=M.getRangeAt(0);if(!I.contains(oe.startContainer)){x(null);return}const K=qn(I,oe.startContainer,oe.startOffset);if(K<0){x(null);return}const Y=ao(I,K);if(!Y){x(null);return}const S=oe.getBoundingClientRect(),H=S.width===0&&S.height===0?(()=>{const re=document.createRange();return re.selectNodeContents(oe.startContainer),re.collapse(!0),re.getBoundingClientRect()})():S;g.current={query:Y.query,caretIndex:Y.caretIndex,triggerIndex:Y.triggerIndex};const O=Du(H,I);x(re=>{const z={query:Y.query,...O};return re&&re.query===z.query&&re.top===z.top&&re.bottom===z.bottom&&re.left===z.left&&re.maxHeight===z.maxHeight?re:z})},[U]),ce=o.useCallback(I=>{r(I),J()},[r,J]);o.useEffect(()=>{const I=M=>{if(Tu.has(M.key))return;const oe=U(),K=M.target;!oe||!K||!oe.contains(K)||J()};return document.addEventListener("keyup",I,!0),()=>document.removeEventListener("keyup",I,!0)},[U,J]);const C=o.useCallback(I=>{const M=U();if(!M)return;let oe=-1;const K=window.getSelection();if(K&&K.rangeCount>0){const re=K.getRangeAt(0);M.contains(re.startContainer)&&(oe=qn(M,re.startContainer,re.startOffset))}if(oe<0&&g.current&&(oe=g.current.caretIndex),oe<0)return;const Y=ao(M,oe);if(!Y)return;const S=tl(M,{triggerIndex:Y.triggerIndex,caretIndex:oe,username:I.username,display:I.name,userId:I.userId});if(!S)return;M.dispatchEvent(new InputEvent("input",{bubbles:!0,cancelable:!0}));const H={userId:I.userId,username:I.username,email:I.email??void 0,display:I.name??I.username};Z(re=>{const z=new Map(re.map(de=>[de.userId,de]));return z.set(H.userId,H),Array.from(z.values())}),x(null),g.current=null;const O=S.caretPlainOffset;requestAnimationFrame(()=>{requestAnimationFrame(()=>{var ie,ge;const re=U();if(!re)return;re.focus(),rl(re,O);const z=window.getSelection(),de=z==null?void 0:z.anchorNode,he=de instanceof Element?de.closest(".mention-chip"):(ie=de==null?void 0:de.parentElement)==null?void 0:ie.closest(".mention-chip");if(he!=null&&he.parentNode){const Me=document.createRange(),$e=he.nextSibling;$e&&$e.nodeType===Node.TEXT_NODE?Me.setStart($e,((ge=$e.textContent)==null?void 0:ge.length)??0):Me.setStartAfter(he),Me.collapse(!0),z==null||z.removeAllRanges(),z==null||z.addRange(Me)}})})},[U]);o.useEffect(()=>{const I=new Set(so(e).map(M=>M.toLowerCase()));Z(M=>{const oe=M.filter(K=>I.has(K.username.toLowerCase()));return oe.length===M.length?M:oe})},[e]),o.useEffect(()=>{if(!T)return;const I=M=>{const oe=M.target;if(!oe||f.current&&f.current.contains(oe)||h.current&&h.current.contains(oe))return;const K=U();K&&K.contains(oe)||x(null)};return document.addEventListener("mousedown",I),()=>{document.removeEventListener("mousedown",I)}},[T,U]);const _=o.useMemo(()=>y.slice(0,c),[y,c]);$.current=_,o.useEffect(()=>{if(!T)return;const I=M=>{const oe=U(),K=M.target;if(!oe||!K||!oe.contains(K))return;const Y=$.current;if(!(Y.length===0&&M.key!=="Escape"))if(M.key==="ArrowDown")M.preventDefault(),M.stopPropagation(),W(S=>(S+1)%Math.max(Y.length,1));else if(M.key==="ArrowUp")M.preventDefault(),M.stopPropagation(),W(S=>(S-1+Y.length)%Math.max(Y.length,1));else if(M.key==="Enter"||M.key==="Tab"){const S=Y[A.current];S&&(M.preventDefault(),M.stopPropagation(),C(S))}else M.key==="Escape"&&(M.preventDefault(),M.stopPropagation(),x(null))};return document.addEventListener("keydown",I,!0),()=>document.removeEventListener("keydown",I,!0)},[U,C,T]),o.useEffect(()=>{const I=H=>{H.dispatchEvent(new InputEvent("input",{bubbles:!0,cancelable:!0}))},M=H=>{const O=U(),re=H.target;if(!O||!re||!O.contains(re))return;if((H.metaKey||H.ctrlKey)&&H.key.toLowerCase()==="a"){H.preventDefault(),H.stopPropagation(),O.focus(),ol(O);return}if(H.key!=="Backspace"&&H.key!=="Delete")return;const z=window.getSelection();if(z&&!z.isCollapsed&&z.rangeCount>0){const ie=z.getRangeAt(0);if(O.contains(ie.commonAncestorContainer)&&co(O).length>0&&sl(ie)){H.preventDefault(),H.stopPropagation(),ll(O)&&I(O);return}}const de=co(O);if(de.length>0){H.preventDefault(),H.stopPropagation();for(const ie of de)Yn(ie);Er(O),I(O);return}if(H.key==="Backspace"){const ie=il(O);if(!ie)return;H.preventDefault(),H.stopPropagation(),Yn(ie),Er(O),I(O);return}const he=cl(O);he&&(H.preventDefault(),H.stopPropagation(),Yn(he),Er(O),I(O))},oe=H=>{const O=U();if(!O)return;const re=H.target;if(!(re instanceof Element)||!O.contains(re))return;const z=re.closest(".mention-chip");if(!(z instanceof HTMLElement)||!O.contains(z)){N.current=null,Er(O);return}H.shiftKey||H.button!==0||(N.current={chip:z,x:H.clientX,y:H.clientY})},K=H=>{const O=N.current;if(!O)return;const re=Math.abs(H.clientX-O.x),z=Math.abs(H.clientY-O.y);(re>ul||z>ul)&&(N.current=null)},Y=H=>{var he;const O=U(),re=N.current;if(N.current=null,!O||!re)return;const z=H.target;if(!(z instanceof Element)||!O.contains(z)||!((he=z.closest(".mention-chip"))!=null&&he.isSameNode(re.chip)))return;const de=window.getSelection();if(de){if(!de.isCollapsed){Vn(O);return}O.focus(),al(re.chip)}},S=()=>{const H=U();if(!H)return;const O=window.getSelection();!O||O.rangeCount===0||!O.anchorNode||!H.contains(O.anchorNode)||!O.focusNode||!H.contains(O.focusNode)||Vn(H)};return document.addEventListener("keydown",M,!0),document.addEventListener("mousedown",oe,!0),document.addEventListener("mousemove",K,!0),document.addEventListener("mouseup",Y,!0),document.addEventListener("selectionchange",S),()=>{document.removeEventListener("keydown",M,!0),document.removeEventListener("mousedown",oe,!0),document.removeEventListener("mousemove",K,!0),document.removeEventListener("mouseup",Y,!0),document.removeEventListener("selectionchange",S)}},[U]),o.useEffect(()=>{if(!T||!h.current)return;const I=h.current.querySelector(`[data-mention-index="${w}"]`);I==null||I.scrollIntoView({block:"nearest"})},[w,T]);const ae=u?Rs(e):e,B=T&&j?ct.createPortal(t.jsxs("ul",{ref:h,style:{...Au,left:T.left,top:T.top,bottom:T.bottom,maxHeight:T.maxHeight},role:"listbox","aria-label":"Menciones sugeridas",children:[D&&_.length===0&&t.jsx("li",{style:fl,children:"Buscando…"}),!D&&_.length===0&&t.jsx("li",{style:fl,children:T.query.trim().length===0?"Escribe un nombre o usuario":`Sin coincidencias para “${T.query}”`}),_.map((I,M)=>{var oe,K;return t.jsx("li",{children:t.jsxs("button",{type:"button","data-mention-index":M,onMouseDown:Y=>{Y.preventDefault(),C(I)},onMouseEnter:()=>W(M),style:{width:"100%",textAlign:"left",padding:"8px 10px",border:"none",background:M===w?"color-mix(in srgb, var(--primary, var(--bonsaif-ui-primary, #1f6feb)) 14%, transparent)":"transparent",color:"var(--text-main, var(--bonsaif-ui-text, #24292f))",borderRadius:6,cursor:"pointer",display:"flex",flexDirection:"column",gap:2},children:[t.jsx("span",{style:{fontWeight:600,fontSize:13},children:((oe=I.name)==null?void 0:oe.trim())||`@${I.username}`}),t.jsx("span",{style:{fontSize:11,color:"var(--text-muted, #656d76)"},children:[(K=I.name)!=null&&K.trim()?`@${I.username}`:null,I.email].filter(Boolean).join(" · ")||`@${I.username}`})]})},I.userId)})]}),document.body):null;return t.jsxs("div",{ref:f,style:$u,className:i,children:[t.jsx(Us,{value:ae,onChange:ce,placeholder:l,minHeight:s,instanceId:b}),B]})}function Iu({value:e,onChange:r,placeholder:n,minHeight:a,onSearchUsers:s,onMentionsChange:l,className:i,maxSuggestions:c,searchDebounceMs:d,highlightInEditor:u,searchCacheKey:m}){return s?t.jsx(bl,{value:e,onChange:r,onSearchUsers:s,onMentionsChange:l,placeholder:n,minHeight:a,className:i,maxSuggestions:c,searchDebounceMs:d,highlightInEditor:u,searchCacheKey:m}):t.jsx(Us,{value:e,onChange:r,placeholder:n,minHeight:a})}function Ou({title:e,subtitle:r,icon:n,actions:a,children:s,footer:l,className:i="",bodyClassName:c="p-4"}){const d=e||r||n||a;return t.jsxs("section",{className:`overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${i}`,children:[d&&t.jsxs("header",{className:"flex items-center justify-between gap-3 border-b border-[var(--border)] px-4 py-3",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[n&&t.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:n}),t.jsxs("div",{className:"min-w-0",children:[e&&t.jsx("h3",{className:"truncate text-sm font-semibold text-[var(--text-main)]",children:e}),r&&t.jsx("div",{className:"truncate text-xs text-[var(--text-muted)]",children:r})]})]}),a&&t.jsx("div",{className:"shrink-0",children:a})]}),t.jsx("div",{className:c,children:s}),l&&t.jsx("footer",{className:"border-t border-[var(--border)] px-4 py-3",children:l})]})}const Hu={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)"}},Bu={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 Fu({children:e,tone:r="neutral",size:n="sm",icon:a,dot:s=!1,className:l=""}){const i=Hu[r];return t.jsxs("span",{className:`inline-flex max-w-full shrink-0 items-center gap-1.5 rounded-full border font-semibold leading-none ${Bu[n]} ${l}`,style:{color:i.text,background:i.bg,borderColor:i.border},children:[s&&t.jsx("span",{"aria-hidden":"true",className:"h-1.5 w-1.5 shrink-0 rounded-full",style:{background:i.text}}),a&&t.jsx("span",{className:"shrink-0",children:a}),t.jsx("span",{className:"min-w-0 truncate",children:e})]})}const ml={neutral:{color:"var(--text-secondary)",background:"var(--bg-input)"},primary:{color:"var(--primary)",background:"color-mix(in srgb, var(--primary) 10%, transparent)"},success:{color:"#047857",background:"rgba(16, 185, 129, 0.11)"},warning:{color:"#b45309",background:"rgba(245, 158, 11, 0.12)"},danger:{color:"var(--danger)",background:"var(--danger-bg)"},info:{color:"#2563eb",background:"rgba(59, 130, 246, 0.11)"}},Pu={xs:"min-h-5 px-1.5 pr-6 text-[10px]",sm:"min-h-6 px-2 pr-7 text-xs",md:"min-h-7 px-2.5 pr-8 text-sm"},_u={xs:"right-1 h-3 w-3",sm:"right-1.5 h-3 w-3",md:"right-2 h-3.5 w-3.5"},zu={xs:148,sm:164,md:184},Wu={xs:"px-2.5 py-1.5 text-xs",sm:"px-3 py-2 text-sm",md:"px-3.5 py-2.5 text-sm"};function ju({value:e,options:r,onChange:n,size:a="sm",disabled:s=!1,loading:l=!1,stopPropagation:i=!1,ariaLabel:c="Cambiar estado",title:d="Cambiar estado",className:u,selectClassName:m,menuClassName:b,optionClassName:f,spinnerClassName:h}){const[v,k]=o.useState(!1),[g,A]=o.useState(!1),[$,N]=o.useState(-1),[T,x]=o.useState({}),y=o.useRef(null),L=o.useRef(null),w=o.useRef(null),W=r.find(U=>U.value===e)??r[0],X={...W!=null&&W.tone?ml[W.tone]:void 0,...W==null?void 0:W.style},Z=s||l||r.length===0,D=U=>{i&&U.stopPropagation()},Q=o.useCallback(()=>{k(!1),N(-1)},[]),j=o.useCallback(()=>{const U=y.current;if(!U)return;const J=U.getBoundingClientRect(),ce=Math.max(J.width,zu[a]),C=Math.min(Math.max(r.length,1)*38+12,260),_=window.innerHeight-J.bottom,ae=_<C&&J.top>_,B=Math.min(Math.max(8,J.left+J.width/2-ce/2),window.innerWidth-ce-8);x({position:"fixed",left:B,top:ae?void 0:J.bottom+6,bottom:ae?window.innerHeight-J.top+6:void 0,width:ce,zIndex:9999})},[r.length,a]),se=o.useCallback(U=>{U.disabled||(n(U.value),Q())},[Q,n]);o.useEffect(()=>A(!0),[]),o.useEffect(()=>{if(!v)return;j();const U=r.findIndex(J=>J.value===e);N(U>=0?U:0)},[v,r,j,e]),o.useEffect(()=>{if(!v)return;function U(J){var C,_;const ce=J.target;!((C=y.current)!=null&&C.contains(ce))&&!((_=L.current)!=null&&_.contains(ce))&&Q()}return document.addEventListener("mousedown",U),()=>document.removeEventListener("mousedown",U)},[Q,v]),o.useEffect(()=>{if(v)return window.addEventListener("resize",j),window.addEventListener("scroll",j,!0),()=>{window.removeEventListener("resize",j),window.removeEventListener("scroll",j,!0)}},[v,j]),o.useEffect(()=>{if($<0||!w.current)return;const U=w.current.children[$];U==null||U.scrollIntoView({block:"nearest"})},[$]);function te(U){if(!Z){if(!v){["Enter"," ","ArrowDown","ArrowUp"].includes(U.key)&&(U.preventDefault(),k(!0));return}if(U.key==="Escape"){U.preventDefault(),Q();return}if(U.key==="ArrowDown"){U.preventDefault(),N(J=>Math.min(J+1,r.length-1));return}if(U.key==="ArrowUp"){U.preventDefault(),N(J=>Math.max(J-1,0));return}if(U.key==="Enter"||U.key===" "){U.preventDefault();const J=r[$];J&&se(J)}}}const ee=t.jsx("div",{ref:L,role:"listbox","aria-label":c,className:Vt("overflow-hidden rounded-xl border shadow-xl backdrop-blur-md",b),style:{...T,background:"color-mix(in srgb, var(--bg-card) 92%, transparent)",borderColor:"var(--border)",color:"var(--text-main)"},onClick:D,onMouseDown:D,onPointerDown:D,children:t.jsx("div",{ref:w,className:"max-h-64 overflow-y-auto p-1",style:{scrollbarWidth:"thin",scrollbarColor:"var(--border) transparent",overscrollBehavior:"contain"},children:r.map((U,J)=>{const ce=U.value===e,C=J===$,_={...U.tone?ml[U.tone]:void 0,...U.style};return t.jsxs("button",{type:"button",role:"option","aria-selected":ce,disabled:U.disabled,onMouseEnter:()=>!U.disabled&&N(J),onMouseDown:ae=>{ae.preventDefault(),se(U)},className:Vt("flex w-full items-center gap-2 rounded-lg font-medium text-left transition-colors disabled:cursor-not-allowed disabled:opacity-45",Wu[a],ce?U.className:void 0,f),style:{...ce?_:void 0,background:ce?_.background??"color-mix(in srgb, var(--primary) 12%, transparent)":C?"var(--bg-hover)":"transparent",color:ce?_.color??"var(--primary)":"var(--text-main)"},children:[t.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center",children:ce?t.jsx(q.HiCheck,{className:"h-4 w-4"}):null}),t.jsx("span",{className:"min-w-0 flex-1 truncate",children:U.label})]},U.value)})})});return t.jsxs("span",{ref:y,className:Vt("relative inline-flex shrink-0 items-center",u),onKeyDown:te,onClick:D,onPointerDown:D,children:[t.jsx("button",{type:"button",disabled:Z,"aria-label":c,"aria-haspopup":"listbox","aria-expanded":v,title:d,onClick:()=>!Z&&k(U=>!U),className:Vt("inline-flex items-center rounded-full border border-transparent font-medium leading-none outline-none transition-colors hover:border-current focus:border-current disabled:cursor-wait disabled:opacity-70",Pu[a],W==null?void 0:W.className,m),style:X,children:t.jsx("span",{className:"min-w-0 truncate",children:(W==null?void 0:W.label)??e})}),t.jsx(q.HiChevronDown,{"aria-hidden":"true",className:Vt("pointer-events-none absolute opacity-70 transition-transform",_u[a],v?"rotate-180":"rotate-0")}),l&&t.jsx("span",{"aria-hidden":"true",className:Vt("absolute -right-1 -top-1 h-2.5 w-2.5 rounded-full border border-current border-t-transparent animate-spin",h)}),v&&g&&ct.createPortal(ee,document.body)]})}function qu({tabs:e,activeTabId:r,defaultActiveTabId:n,onTabChange:a,ariaLabel:s="Pestanas",variant:l="underline",className:i="",listClassName:c="",panelClassName:d=""}){const u=e.find(v=>!v.disabled)??e[0],m=r??n??(u==null?void 0:u.id),b=e.find(v=>v.id===m)??u,f=v=>{v.disabled||a==null||a(v.id)},h=v=>{const k=e.filter(A=>!A.disabled);if(!k.length||!b)return;const g=k.findIndex(A=>A.id===b.id);(v.key==="ArrowRight"||v.key==="ArrowDown")&&(v.preventDefault(),f(k[(g+1)%k.length])),(v.key==="ArrowLeft"||v.key==="ArrowUp")&&(v.preventDefault(),f(k[(g-1+k.length)%k.length])),v.key==="Home"&&(v.preventDefault(),f(k[0])),v.key==="End"&&(v.preventDefault(),f(k[k.length-1]))};return t.jsxs("div",{className:i,children:[t.jsx("div",{role:"tablist","aria-label":s,onKeyDown:h,className:`flex min-w-0 gap-1 overflow-x-auto ${l==="underline"?"border-b border-[var(--border)]":"rounded-lg border border-[var(--border)] bg-[var(--bg-input)] p-1"} ${c}`,children:e.map(v=>{const k=v.id===(b==null?void 0:b.id);return t.jsxs("button",{type:"button",role:"tab","aria-selected":k,"aria-controls":`${v.id}-panel`,id:`${v.id}-tab`,disabled:v.disabled,tabIndex:k?0:-1,onClick:()=>f(v),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 ${l==="underline"?"border-b-2":"rounded-md border"}`,style:{color:k?"var(--primary)":"var(--text-muted)",borderColor:k?"var(--primary)":"transparent",background:l==="pills"&&k?"var(--bg-card)":"transparent"},children:[v.icon&&t.jsx("span",{className:"shrink-0",children:v.icon}),t.jsx("span",{children:v.label}),v.badge&&t.jsx("span",{className:"shrink-0",children:v.badge})]},v.id)})}),(b==null?void 0:b.content)!==void 0&&t.jsx("div",{role:"tabpanel",id:`${b.id}-panel`,"aria-labelledby":`${b.id}-tab`,className:`pt-4 ${d}`,children:b.content})]})}function Gt(...e){return e.filter(Boolean).join(" ")}function Uu({steps:e,activeStepId:r,initialStepId:n,completedStepIds:a,defaultCompletedStepIds:s=[],onActiveStepChange:l,onCompletedStepIdsChange:i,onBlockedStep:c,allowBackNavigation:d=!0,showFooter:u=!0,previousLabel:m="Anterior",nextLabel:b="Siguiente",blockedNextLabel:f="Completa este paso",className:h="",headerClassName:v="",contentClassName:k="",footerClassName:g=""}){var K;const A=((K=e[0])==null?void 0:K.id)??"",[$,N]=o.useState(n??A),[T,x]=o.useState(s),y=r??$,L=a??T,w=o.useMemo(()=>new Set(L),[L]),W=Math.max(0,e.findIndex(Y=>Y.id===y)),X=e[W]??e[0],Z=e.length<=1?100:W/(e.length-1)*100,D=Y=>{a||x(Y),i==null||i(Y)},Q=Y=>{const S=e.find(H=>H.id===Y);S&&(r||N(Y),l==null||l(Y,S))},j=Y=>w.has(Y),se=Y=>e.slice(0,Y).find(S=>!S.optional&&!w.has(S.id)),te=Y=>{const S=e[Y];return!S||S.disabled?!1:Y===W||d&&Y<W?!0:!se(Y)},ee=Y=>{const S=e.findIndex(H=>H.id===Y);return S>=0&&te(S)},U=Y=>{const S=e.findIndex(H=>H.id===Y);if(S<0)return!1;if(!te(S)){const H=se(S);return H&&(c==null||c(e[S],H)),!1}return Q(Y),!0},J=(Y=X==null?void 0:X.id)=>{!Y||w.has(Y)||D([...L,Y])},ce=(Y=X==null?void 0:X.id)=>{if(!Y)return;const S=e.findIndex(O=>O.id===Y),H=L.filter(O=>{const re=e.findIndex(z=>z.id===O);return re>=0&&re<S});D(H),S>=0&&W>S&&Q(Y)},C=()=>W<=0?!1:U(e[W-1].id),_=()=>{const Y=e[W+1];return Y?U(Y.id):!1},ae={activeStep:X,activeIndex:W,completedStepIds:L,isCompleted:j,isUnlocked:ee,completeStep:J,uncompleteStep:ce,goToStep:U,goNext:_,goPrevious:C};if(!X)return null;const B=e[W+1],I=W>0,M=B?ee(B.id):!1,oe=typeof X.content=="function"?X.content(ae):X.content;return t.jsxs("section",{className:Gt("overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)]",h),children:[t.jsxs("div",{className:Gt("border-b border-[var(--border)] bg-[var(--bg-input)]",v),children:[t.jsx("div",{className:"relative h-1 overflow-hidden bg-[var(--border)]/55",children:t.jsx("div",{className:"h-full rounded-r-full bg-[var(--primary)] transition-[width] duration-500 ease-out",style:{width:`${Z}%`}})}),t.jsx("div",{className:"grid gap-2 p-2",style:{gridTemplateColumns:`repeat(${e.length}, minmax(0, 1fr))`},children:e.map((Y,S)=>{const H=Y.id===X.id,O=j(Y.id),re=te(S),z=se(S);return t.jsxs("button",{type:"button",disabled:!re,"aria-current":H?"step":void 0,"aria-disabled":!re,title:!re&&z?`Completa ${z.title}`:Y.title,onClick:()=>U(Y.id),className:Gt("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",H&&"border-[var(--primary)] bg-[var(--bg-card)] shadow-sm",O&&!H&&"border-[var(--primary)]/35 bg-[var(--bg-card)]",!H&&!O&&re&&"border-transparent bg-[var(--bg-card)]/45 hover:border-[var(--border)] hover:bg-[var(--bg-card)]",!re&&"border-transparent bg-[var(--bg-card)]/35 opacity-60"),children:[t.jsx("span",{className:Gt("absolute inset-x-0 top-0 h-0.5 origin-left scale-x-0 bg-[var(--primary)] transition-transform duration-300",H&&"scale-x-100")}),t.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[t.jsx("span",{className:Gt("grid h-7 w-7 shrink-0 place-items-center rounded-full border text-xs font-bold transition-all duration-200",H&&"border-[var(--primary)] bg-[var(--primary)] text-[var(--primary-fg)]",O&&!H&&"border-[var(--primary)] bg-[var(--primary)]/12 text-[var(--primary)]",!O&&!H&&re&&"border-[var(--border)] text-[var(--text-muted)]",!re&&"border-[var(--border)] text-[var(--text-muted)]"),children:O?t.jsx(q.HiCheck,{className:"h-4 w-4"}):re?S+1:t.jsx(q.HiLockClosed,{className:"h-3.5 w-3.5"})}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsxs("span",{className:Gt("block truncate text-xs font-semibold transition-colors duration-200",H?"text-[var(--text-main)]":"text-[var(--text-secondary)]"),children:[S+1,". ",Y.title]}),Y.description&&t.jsx("span",{className:"mt-1 block truncate text-[11px] text-[var(--text-muted)]",children:Y.description})]}),Y.badge&&t.jsx("span",{className:"shrink-0",children:Y.badge})]})]},Y.id)})})]}),t.jsx("div",{className:Gt("min-h-72 animate-[stepWizardIn_220ms_ease-out] p-5",k),children:oe},X.id),u&&t.jsxs("div",{className:Gt("flex flex-wrap items-center justify-between gap-3 border-t border-[var(--border)] bg-[var(--bg-input)] px-4 py-3",g),children:[t.jsx(Ue,{variant:"secondary",height:38,padding:"0 14px",icon:t.jsx(q.HiChevronLeft,{}),disabled:!I,onClick:C,children:m}),t.jsxs("div",{className:"flex items-center gap-3 text-xs text-[var(--text-muted)]",children:[t.jsxs("span",{children:["Paso ",W+1," de ",e.length]}),t.jsx("span",{className:"h-1 w-1 rounded-full bg-[var(--border)]"}),t.jsxs("span",{children:[L.length," completados"]})]}),t.jsx(Ue,{height:38,padding:"0 14px",icon:t.jsx(q.HiChevronRight,{}),disabled:!B||!M,onClick:_,children:B&&!M?f:b})]})]})}const Vu={sm:"px-2.5 py-1.5 text-xs leading-5",md:"px-2.5 py-1.5 text-sm leading-5",lg:"px-3 py-2 text-sm leading-6"};function Yu(e,r){if(e){if(typeof e=="function"){e(r);return}e.current=r}}function Xu(e){const r=getComputedStyle(e),n=Number.parseFloat(r.lineHeight),a=Number.parseFloat(r.paddingTop)+Number.parseFloat(r.paddingBottom),s=Number.parseFloat(r.borderTopWidth)+Number.parseFloat(r.borderBottomWidth);return{lineHeight:Number.isFinite(n)?n:20,paddingY:Number.isFinite(a)?a:12,borderY:Number.isFinite(s)?s:2}}function pl(e,r){const{lineHeight:n,paddingY:a,borderY:s}=Xu(e);return Math.ceil(r*n+a+s)}const hl=o.forwardRef(function({className:r="",size:n="md",status:a="default",maxHeight:s,maxRows:l,minRows:i=1,style:c,value:d,defaultValue:u,onInput:m,...b},f){const h=o.useRef(null),v=a==="error"?"var(--danger)":a==="success"?"#16a34a":"var(--border)",k=o.useCallback(()=>{const g=h.current;if(!g)return;g.style.height="auto";const A=g.scrollHeight,$=pl(g,i),N=s??(l!==void 0?pl(g,l):void 0),T=N!==void 0?Math.min(Math.max(A,$),N):Math.max(A,$);g.style.height=`${T}px`,g.style.overflowY=N!==void 0&&A>N?"auto":"hidden"},[s,l,i]);return o.useLayoutEffect(()=>{k()},[k,d,u]),o.useEffect(()=>{const g=h.current;if(!g||typeof ResizeObserver>"u")return;const A=new ResizeObserver(()=>k());return A.observe(g),()=>A.disconnect()},[k]),t.jsx("textarea",{...b,ref:g=>{h.current=g,Yu(f,g)},rows:i,value:d,defaultValue:u,"aria-invalid":a==="error"||b["aria-invalid"],onInput:g=>{k(),m==null||m(g)},style:{...c,borderColor:v,minHeight:void 0},className:`w-full resize-none overflow-hidden 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 ${Vu[n]} ${r}`})});function Ku({label:e,containerClassName:r="",helperText:n,helperDisplay:a,error:s,labelAction:l,required:i,className:c="",status:d,...u}){return t.jsx(In,{label:e,required:i,helperText:n,helperDisplay:a,error:s,labelAction:l,className:r,children:t.jsx(hl,{...u,required:i,status:s?"error":d,className:`w-full ${c}`})})}const Gu={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"},Zu={none:"resize-none",vertical:"resize-y",horizontal:"resize-x",both:"resize"};function Qu(e,r){if(e){if(typeof e=="function"){e(r);return}e.current=r}}function Ju(e,r){return e!==void 0?String(e).length:r!==void 0?String(r).length:0}const gl=o.forwardRef(function({className:r="",wrapperClassName:n="",size:a="md",resize:s="vertical",autoResize:l=!1,minRows:i,maxRows:c,showCount:d=!1,maxCount:u,status:m="default",icon:b,action:f,style:h,value:v,defaultValue:k,maxLength:g,onInput:A,...$},N){const T=o.useRef(null),x=Ju(v,k),y=u??g,L=!!(b||f||d),w=m==="error"?"var(--danger)":m==="success"?"#16a34a":"var(--border)",W={...h??{},...i?{minHeight:`${i*24+18}px`}:null,...c?{maxHeight:`${c*24+18}px`}:null},X=()=>{const D=T.current;!D||!l||(D.style.height="auto",D.style.height=`${D.scrollHeight}px`)};o.useEffect(X,[l,v]);const Z=t.jsx("textarea",{...$,ref:D=>{T.current=D,Qu(N,D)},value:v,defaultValue:k,maxLength:g,"aria-invalid":m==="error"||$["aria-invalid"],onInput:D=>{X(),A==null||A(D)},style:{...W,borderColor:w},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 ${Gu[a]} ${Zu[l?"none":s]} ${b?"pl-8":""} ${f?"pr-10":""} ${r}`});return L?t.jsxs("span",{className:`relative block ${n}`,children:[b&&t.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:b}),Z,f&&t.jsx("span",{className:"absolute right-2 top-2 flex items-center justify-center",children:f}),d&&t.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:[x,y?`/${y}`:""]})]}):Z});function Ru({label:e,containerClassName:r="",helperText:n,helperDisplay:a,error:s,labelAction:l,required:i,className:c="",status:d,...u}){return t.jsx(In,{label:e,required:i,helperText:n,helperDisplay:a,error:s,labelAction:l,className:r,children:t.jsx(gl,{...u,required:i,status:s?"error":d,className:`w-full ${c}`})})}const vl=[{bg:"#dbeafe",text:"#1e40af",border:"#bfdbfe"},{bg:"#dcfce7",text:"#166534",border:"#bbf7d0"},{bg:"#fce7f3",text:"#9d174d",border:"#fbcfe8"},{bg:"#fef9c3",text:"#854d0e",border:"#fef08a"},{bg:"#ede9fe",text:"#5b21b6",border:"#ddd6fe"},{bg:"#ffedd5",text:"#9a3412",border:"#fed7aa"},{bg:"#cffafe",text:"#155e75",border:"#a5f3fc"},{bg:"#f0fdf4",text:"#14532d",border:"#bbf7d0"}];function ef(e){return vl[e%vl.length]}let tf=0;function fo(){return++tf}function yl(e,r){return r?r instanceof RegExp?r.test(e):r(e):!0}function rf(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function nf(e,r){const n=r.filter(Boolean);if(n.length===0)return[e.trim()].filter(Boolean);const a=new RegExp(`${n.map(s=>rf(s)).join("|")}|\\r?\\n`,"g");return e.split(a).map(s=>s.trim()).filter(Boolean)}function af({value:e,defaultValue:r,onChange:n,placeholder:a="Escribe y presiona Enter…",disabled:s=!1,className:l="",delimiters:i=[","],maxTags:c,allowDuplicates:d=!1,validate:u,label:m,helperText:b,helperDisplay:f="inline",error:h,required:v=!1}){const k=e!==void 0,g=!!h,A=!!b&&f==="tooltip"&&!g,[$,N]=o.useState(()=>(r??[]).map((O,re)=>({id:fo(),value:O.trim(),colorIndex:re})));o.useEffect(()=>{k&&N(O=>{const re=e??[],z=new Map(O.map(de=>[de.value,de]));return re.map((de,he)=>z.get(de)??{id:fo(),value:de,colorIndex:he})})},[k,e]);const T=$,[x,y]=o.useState(""),[L,w]=o.useState(null),[W,X]=o.useState(""),[Z,D]=o.useState(!1),[Q,j]=o.useState(!1),se=o.useRef(null),te=o.useRef(null),ee=o.useRef(null);function U(){j(!0),setTimeout(()=>j(!1),400)}function J(O){N(O),n==null||n(O.map(re=>re.value))}function ce(O){let re=T,z=!1,de=!1;for(const he of O){const ie=he.trim();if(ie){if(c!==void 0&&re.length>=c){de=!0;break}if(!d&&re.some(ge=>ge.value.toLowerCase()===ie.toLowerCase())){de=!0;continue}if(!yl(ie,u)){de=!0;continue}re=[...re,{id:fo(),value:ie,colorIndex:re.length}],z=!0}}return z&&J(re),de&&U(),z}function C(O){return ce([O])}function _(O){const re=T.filter(z=>z.id!==O);J(re.map((z,de)=>({...z,colorIndex:de})))}function ae(O,re){const z=re.trim();if(w(null),X(""),!z){_(O);return}if(!(!d&&T.some(de=>de.id!==O&&de.value.toLowerCase()===z.toLowerCase()))){if(!yl(z,u)){U();return}J(T.map(de=>de.id===O?{...de,value:z}:de))}}function B(O){s||(w(O.id),X(O.value),setTimeout(()=>{var re;return(re=te.current)==null?void 0:re.select()},0))}function I(O){if(O.key==="Enter"||i.includes(O.key)){O.preventDefault(),C(x)&&y("");return}if(O.key==="Backspace"&&x===""&&T.length>0){O.preventDefault();const re=T[T.length-1];_(re.id)}}function M(O,re){if(O.key==="Enter"){O.preventDefault(),ae(re,W),setTimeout(()=>{var z;return(z=se.current)==null?void 0:z.focus()},0);return}O.key==="Escape"&&(O.preventDefault(),w(null),X(""),setTimeout(()=>{var z;return(z=se.current)==null?void 0:z.focus()},0))}function oe(){var O;s||(O=se.current)==null||O.focus()}function K(O){if(s)return;const re=O.clipboardData.getData("text");if(!re||!(i.some(ie=>ie&&re.includes(ie))||re.includes(`
31
+ `)))return;O.preventDefault();const de=nf(re,i);ce(de)&&y("")}function Y(){const O=x.trim();O&&C(O)&&y("")}const S=g?"var(--danger)":Z?"var(--primary)":"var(--border)",H=c!==void 0&&T.length>=c;return t.jsxs("div",{className:`flex flex-col gap-2 ${l}`,children:[(m||v||A)&&t.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-semibold uppercase text-[var(--text-muted)]",children:[m&&t.jsx("span",{children:m}),v&&t.jsx("span",{className:"text-[var(--danger)]",children:"*"}),A?t.jsx(xr,{content:b}):null]}),t.jsxs("div",{ref:ee,onClick:oe,onFocus:()=>D(!0),onBlur:O=>{var re;(re=ee.current)!=null&&re.contains(O.relatedTarget)||(D(!1),L!==null&&ae(L,W),L===null&&Y())},style:{borderColor:S},className:`
30
32
  flex min-h-10 flex-wrap items-center gap-1.5 rounded-lg border
31
33
  bg-[var(--bg-input)] px-2.5 py-2 transition-colors
32
- ${o?"cursor-not-allowed opacity-60":"cursor-text"}
33
- ${Z?"animate-[tag-shake_0.4s_ease]":""}
34
+ ${s?"cursor-not-allowed opacity-60":"cursor-text"}
35
+ ${Q?"animate-[tag-shake_0.4s_ease]":""}
34
36
  `,children:[t.jsx("style",{children:`
35
37
  @keyframes tag-shake {
36
38
  0%,100% { transform: translateX(0); }
@@ -39,7 +41,7 @@ ${R}`,ne=new Blob(["\uFEFF"+O],{type:"text/csv;charset=utf-8;"}),fe=URL.createOb
39
41
  60% { transform: translateX(-3px); }
40
42
  80% { transform: translateX(3px); }
41
43
  }
42
- `}),w.map(_=>{const se=nu(_.colorIndex);return A===_.id?t.jsx("input",{ref:X,value:j,disabled:o,onChange:Q=>W(Q.target.value),onKeyDown:Q=>I(Q,_.id),onBlur:()=>le(_.id,j),className:"min-w-[4rem] rounded border border-[var(--primary)] bg-transparent px-1 py-0.5 text-sm text-[var(--text-main)] outline-none",style:{width:`${Math.max(j.length+2,6)}ch`}},_.id):t.jsxs("span",{className:"inline-flex max-w-[240px] items-center gap-1 rounded-md px-2 py-0.5 text-xs font-medium",style:{backgroundColor:se.bg,color:se.text,border:`1px solid ${se.border}`},children:[t.jsx("span",{className:"truncate",children:_.value}),t.jsx("button",{type:"button","aria-label":`Editar "${_.value}"`,disabled:o,tabIndex:-1,onClick:Q=>{Q.stopPropagation(),g(_)},className:"flex h-4 w-4 flex-shrink-0 items-center justify-center rounded opacity-60 transition-opacity hover:opacity-100 focus:outline-none disabled:pointer-events-none",children:t.jsx(z.HiPencil,{className:"h-3 w-3"})}),t.jsx("button",{type:"button","aria-label":`Eliminar "${_.value}"`,disabled:o,tabIndex:-1,onClick:Q=>{Q.stopPropagation(),F(_.id)},className:"flex h-4 w-4 flex-shrink-0 items-center justify-center rounded opacity-60 transition-opacity hover:opacity-100 focus:outline-none disabled:pointer-events-none",children:t.jsx(z.HiXMark,{className:"h-3.5 w-3.5"})})]},_.id)}),!ee&&t.jsx("input",{ref:ae,value:k,disabled:o,placeholder:w.length===0?a:"",onChange:_=>N(_.target.value),onKeyDown:P,onPaste:U,className:"min-w-[8rem] flex-1 bg-transparent text-sm text-[var(--text-main)] outline-none placeholder:text-[var(--text-muted)] disabled:cursor-not-allowed"})]}),t.jsx(lr,{error:v,helperText:f,helperDisplay:b})]})}const iu=/^(\d{1,2}):(\d{2})(?::(\d{2}))?$/;function Ye(e){return String(e).padStart(2,"0")}function ja(e,r=fr()){const n=e.trim();if(!n)return r;const a=n.match(iu);if(!a)return r;const o=Number(a[1]),l=Number(a[2]),i=a[3]?Number(a[3]):0;return!Number.isFinite(o)||!Number.isFinite(l)||!Number.isFinite(i)||o<0||o>23||l<0||l>59||i<0||i>59?r:{hour24:o,minute:l,second:i}}function Ur(e,r=!0){const n=`${Ye(e.hour24)}:${Ye(e.minute)}`;return r?`${n}:${Ye(e.second)}`:n}function $n(e){const r=e.hour24>=12?"PM":"AM";return{hour12:e.hour24%12===0?12:e.hour24%12,minute:e.minute,second:e.second,meridiem:r}}function Vr(e){let n=Math.min(12,Math.max(1,e.hour12))%12;return e.meridiem==="PM"&&(n+=12),{hour24:n,minute:Math.min(59,Math.max(0,e.minute)),second:Math.min(59,Math.max(0,e.second))}}function cu(e,r){const n=(r==null?void 0:r.use12Hour)??!1,a=(r==null?void 0:r.showSeconds)??!0,o=ja(e);if(n){const l=$n(o),i=`${l.hour12}:${Ye(l.minute)}`;return`${a?`${i}:${Ye(l.second)}`:i} ${l.meridiem}`}return Ur(o,a)}function fr(){const e=new Date;return{hour24:e.getHours(),minute:e.getMinutes(),second:e.getSeconds()}}function du(e=!0){return Ur(fr(),e)}function Wa(e,r){const n=[];for(let a=e;a<=r;a+=1)n.push(a);return n}const st=36,qa=5,Ho=Math.floor(qa/2),uu=52,fu=48,Ct=18;function Bo(e){return e*st}function Fo(e){return Math.round(e/st)}function bu(e){return e.use12Hour??e.hour12??!1}function Tn({values:e,selected:r,onSelect:n,syncEpochRef:a,forceSyncAt:o=0,width:l=uu,label:i,maxNumeric:c=59,isMeridiem:d=!1,isFocused:u=!1,onFocus:m,onAdvance:f,onBack:b,setColumnRef:v}){const x=s.useRef(null),E=s.useRef(null),h=s.useRef(null),$=s.useRef(""),M=s.useRef(0),y=s.useRef(!1),[w,k]=s.useState(r),[N,A]=s.useState(""),C=s.useCallback(g=>{$.current=g,A(g)},[]),j=s.useMemo(()=>[...Array(Ho).fill(""),...e,...Array(Ho).fill("")],[e]),W=s.useCallback(()=>{const g=x.current;if(!g)return r;const P=Fo(g.scrollTop),I=Math.min(Math.max(P,0),e.length-1);return e[I]??r},[r,e]),G=s.useCallback((g,P=!0)=>{const I=Math.min(Math.max(g,0),e.length-1),te=e[I],U=x.current;!U||!te||(E.current&&(window.clearTimeout(E.current),E.current=null),y.current=!0,M.current=I,U.scrollTop=Bo(I),k(te),P&&te!==r&&n(te))},[n,r,e]);s.useLayoutEffect(()=>{E.current&&(window.clearTimeout(E.current),E.current=null),h.current&&(window.clearTimeout(h.current),h.current=null),C(""),k(r);const g=e.indexOf(r);if(g>=0&&(M.current=g),g<0||!x.current)return;const P=Bo(g);x.current.scrollTop!==P&&(x.current.scrollTop=P)},[o,r,C,e]);const T=s.useCallback(()=>{h.current&&(window.clearTimeout(h.current),h.current=null)},[]),Z=s.useCallback((g,P=!1)=>{T(),C("");const I=Number(g);if(!Number.isFinite(I))return;const te=Math.min(c,Math.max(0,I));let U=Ye(te),K=e.indexOf(U);if(K<0){const D=Math.min(e.length-1,Math.max(0,te-(c===12?1:0)));U=e[D]??U,K=e.indexOf(U)}K>=0&&G(K),P&&(f==null||f())},[T,c,f,G,C,e]),H=s.useCallback(g=>{const P=Math.floor(c/10),I=$.current;if(I===""){if(g>P){Z(String(g),!0);return}const U=String(g);C(U),h.current=window.setTimeout(()=>{Z($.current,!0)},1200);return}T();const te=+`${I}${g}`;te<=c?Z(String(te),!0):Z(String(g),!0)},[T,Z,c,C]),ae=s.useCallback(g=>{T(),C(""),G(M.current+g)},[T,G,C]),X=g=>{if(d){g.key==="a"||g.key==="A"?(g.preventDefault(),n("AM"),f==null||f()):g.key==="p"||g.key==="P"?(g.preventDefault(),n("PM"),f==null||f()):g.key==="ArrowUp"||g.key==="ArrowDown"?(g.preventDefault(),n(r==="AM"?"PM":"AM")):g.key==="Tab"&&(g.preventDefault(),g.shiftKey?b==null||b():f==null||f());return}if(/^\d$/.test(g.key)){g.preventDefault(),H(Number(g.key));return}g.key==="ArrowUp"?(g.preventDefault(),ae(-1)):g.key==="ArrowDown"?(g.preventDefault(),ae(1)):g.key==="Tab"&&(g.preventDefault(),T(),$.current!==""&&Z($.current,!1),g.shiftKey?b==null||b():f==null||f())},V=s.useCallback(()=>{const g=a.current,P=x.current;P&&g===a.current&&G(Fo(P.scrollTop))},[G,a]),q=()=>{if($.current!=="")return;if(y.current){y.current=!1;const P=W();k(P);const I=e.indexOf(P);I>=0&&(M.current=I);return}k(W()),E.current&&window.clearTimeout(E.current);const g=a.current;E.current=window.setTimeout(()=>{g===a.current&&V()},100)},L="absolute left-0 right-0 z-40 flex items-center justify-center border-0 bg-transparent p-0 transition-opacity duration-150 hover:opacity-80 focus:outline-none",oe=st*qa,B=oe+Ct*2,F=N!==""?N:null,le=F!==null;return t.jsxs("div",{ref:v,role:"spinbutton",tabIndex:u?0:-1,"aria-label":i,"aria-valuetext":F??r,"aria-valuenow":d?void 0:Number(r),onFocus:m,onMouseDown:()=>m==null?void 0:m(),onKeyDown:X,onBlur:()=>{T(),$.current!==""&&Z($.current,!1)},className:"relative shrink-0 rounded-lg outline-none",style:{width:l,height:B,boxShadow:u?"0 0 0 2px color-mix(in srgb, var(--primary) 35%, transparent)":"none"},children:[t.jsx("button",{type:"button","aria-label":"Valor anterior",className:L,style:{top:0,height:Ct,color:"var(--text-muted)",opacity:.35},onClick:()=>ae(-1),children:t.jsx(z.HiChevronUp,{className:"h-3.5 w-3.5"})}),t.jsx("div",{ref:x,className:"absolute inset-x-0 overflow-y-auto [scrollbar-width:none] [-ms-overflow-style:none] [&::-webkit-scrollbar]:hidden",style:{top:Ct,height:oe,scrollSnapType:"y mandatory",scrollBehavior:"auto"},onScroll:q,onMouseUp:V,onTouchEnd:V,children:j.map((g,P)=>{const I=g!==""&&g===w;return t.jsx("button",{type:"button",tabIndex:-1,disabled:!g,onClick:()=>{if(!g)return;const te=e.indexOf(g);te>=0&&G(te)},className:"flex w-full items-center justify-center tabular-nums leading-none disabled:cursor-default",style:{height:st,scrollSnapAlign:"center",color:I?"var(--text-main)":"var(--text-muted)",fontSize:I?16:14,fontWeight:I?600:400,opacity:g?le?I?0:.35:I?1:.35:0},children:g},`wheel-${P}-${g}`)})}),F!==null?t.jsx("div",{className:"pointer-events-none absolute inset-x-0 z-50 flex items-center justify-center tabular-nums font-semibold leading-none",style:{top:Ct+oe/2-st/2,height:st,color:"var(--text-main)",fontSize:16,background:"var(--bg-card)"},children:F}):null,t.jsx("button",{type:"button","aria-label":"Valor siguiente",className:L,style:{bottom:0,height:Ct,color:"var(--text-muted)",opacity:.35},onClick:()=>ae(1),children:t.jsx(z.HiChevronDown,{className:"h-3.5 w-3.5"})})]})}function Po(){return t.jsx("span",{className:"flex shrink-0 items-center justify-center self-center text-base font-medium tabular-nums leading-none",style:{color:"var(--text-muted)",height:st,width:14,opacity:.45},"aria-hidden":!0,children:":"})}function _o({value:e,onChange:r,use12Hour:n,hour12:a,showSeconds:o=!1,title:l="Seleccionar hora",variant:i="panel",onCancel:c,onConfirm:d,className:u=""}){const m=i==="popover",f=m||!d,b=bu({use12Hour:n,hour12:a}),v=s.useRef(e),x=ja(e,fr()),E=$n(x),[h,$]=s.useState(Ye(b?E.hour12:x.hour24)),[M,y]=s.useState(Ye(x.minute)),[w,k]=s.useState(Ye(x.second)),[N,A]=s.useState(E.meridiem),[C,j]=s.useState(0),W=s.useRef(0),G=s.useRef(!1),T=s.useRef({hour:null,minute:null,second:null,meridiem:null}),[Z,H]=s.useState("hour"),ae=s.useMemo(()=>{const ie=["hour","minute"];return o&&ie.push("second"),b&&ie.push("meridiem"),ie},[b,o]),X=s.useCallback(ie=>{H(pe=>{const Ce=ae.indexOf(pe);return ae[(Ce+ie+ae.length)%ae.length]})},[ae]);s.useEffect(()=>{var ie;(ie=T.current[Z])==null||ie.focus()},[Z]),s.useEffect(()=>{var ie;H("hour"),(ie=T.current.hour)==null||ie.focus()},[]),s.useEffect(()=>{if(e===v.current)return;v.current=e;const ie=ja(e,fr()),pe=$n(ie);$(Ye(b?pe.hour12:ie.hour24)),y(Ye(ie.minute)),k(Ye(ie.second)),A(pe.meridiem)},[b,e]);const V=s.useMemo(()=>(b?Wa(1,12):Wa(0,23)).map(ie=>Ye(ie)),[b]),q=s.useMemo(()=>Wa(0,59).map(ie=>Ye(ie)),[]),L=q,oe=s.useMemo(()=>["AM","PM"],[]),B=s.useCallback(()=>b?Vr({hour12:Number(h),minute:Number(M),second:Number(w),meridiem:N}):{hour24:Number(h),minute:Number(M),second:Number(w)},[h,b,N,M,w]),F=s.useCallback(ie=>{if(G.current)return;const pe=Ur(ie,o);v.current=pe,r(pe)},[r,o]),le=s.useCallback(()=>{F(B())},[B,F]),g=ie=>{$(ie),f&&F(b?Vr({hour12:Number(ie),minute:Number(M),second:Number(w),meridiem:N}):{hour24:Number(ie),minute:Number(M),second:Number(w)})},P=ie=>{y(ie),f&&F(b?Vr({hour12:Number(h),minute:Number(ie),second:Number(w),meridiem:N}):{hour24:Number(h),minute:Number(ie),second:Number(w)})},I=ie=>{k(ie),f&&F(b?Vr({hour12:Number(h),minute:Number(M),second:Number(ie),meridiem:N}):{hour24:Number(h),minute:Number(M),second:Number(ie)})},te=ie=>{A(ie),f&&F(Vr({hour12:Number(h),minute:Number(M),second:Number(w),meridiem:ie}))},U=s.useCallback(()=>(W.current+=1,j(W.current),W.current),[]),K=s.useCallback(ie=>{const pe=$n(ie),Ce=Ur(ie,o);v.current=Ce,$(Ye(b?pe.hour12:ie.hour24)),y(Ye(ie.minute)),k(Ye(ie.second)),A(pe.meridiem),r(Ce)},[b,r,o]),D=()=>{G.current=!0,U(),K(fr()),queueMicrotask(()=>{const ie=fr();Ur(ie,o)!==v.current&&(U(),K(ie)),G.current=!1})},ee=()=>{le(),d==null||d()},_=st*qa,se=_+Ct*2,Q=Ct+_/2-st/2,de=t.jsx("div",{className:"relative px-4 py-2",children:t.jsxs("div",{className:"relative mx-auto",style:{height:se,maxWidth:"100%"},children:[t.jsx("div",{className:"pointer-events-none absolute inset-x-1 z-10 rounded-xl",style:{top:Q,height:st,background:"color-mix(in srgb, var(--primary) 10%, var(--bg-input))",border:"1px solid color-mix(in srgb, var(--primary) 22%, transparent)"}}),t.jsx("div",{className:"pointer-events-none absolute inset-x-0 z-20",style:{top:Ct,height:st*1.35,background:"linear-gradient(to bottom, var(--bg-card) 40%, transparent 100%)"}}),t.jsx("div",{className:"pointer-events-none absolute inset-x-0 z-20",style:{bottom:Ct,height:st*1.35,background:"linear-gradient(to top, var(--bg-card) 40%, transparent 100%)"}}),t.jsxs("div",{className:"relative z-30 flex h-full items-center justify-center gap-1",children:[t.jsx(Tn,{syncEpochRef:W,forceSyncAt:C,values:V,selected:h,onSelect:g,label:"Horas",maxNumeric:b?12:23,isFocused:Z==="hour",onFocus:()=>H("hour"),onAdvance:()=>X(1),onBack:()=>X(-1),setColumnRef:ie=>{T.current.hour=ie}}),t.jsx(Po,{}),t.jsx(Tn,{syncEpochRef:W,forceSyncAt:C,values:q,selected:M,onSelect:P,label:"Minutos",maxNumeric:59,isFocused:Z==="minute",onFocus:()=>H("minute"),onAdvance:()=>X(1),onBack:()=>X(-1),setColumnRef:ie=>{T.current.minute=ie}}),o?t.jsxs(t.Fragment,{children:[t.jsx(Po,{}),t.jsx(Tn,{syncEpochRef:W,forceSyncAt:C,values:L,selected:w,onSelect:I,label:"Segundos",maxNumeric:59,isFocused:Z==="second",onFocus:()=>H("second"),onAdvance:()=>X(1),onBack:()=>X(-1),setColumnRef:ie=>{T.current.second=ie}})]}):null,b?t.jsx("div",{className:"ml-3 shrink-0 pl-1",children:t.jsx(Tn,{syncEpochRef:W,forceSyncAt:C,values:oe,selected:N,onSelect:ie=>te(ie),width:fu,label:"AM o PM",isMeridiem:!0,isFocused:Z==="meridiem",onFocus:()=>H("meridiem"),onAdvance:()=>X(1),onBack:()=>X(-1),setColumnRef:ie=>{T.current.meridiem=ie}})}):null]})]})}),Se=t.jsxs("div",{className:`flex items-center ${m?"justify-center px-3 py-2":"justify-between gap-2 px-3 py-2.5"}`,style:{borderTop:m?"none":"1px solid color-mix(in srgb, var(--border) 80%, transparent)"},children:[t.jsx(je,{variant:"ghost",size:"sm",onClick:D,className:m?"text-xs":void 0,children:"Ahora"}),!m&&(c||d)?t.jsxs("div",{className:"flex items-center gap-2",children:[c?t.jsx(je,{variant:"ghost",size:"sm",onClick:c,children:"Cancelar"}):null,d?t.jsx(je,{variant:"primary",size:"sm",onClick:ee,children:"Listo"}):null]}):null]});return t.jsxs("div",{className:`overflow-hidden ${u}`,style:{borderRadius:m?12:14,border:m?"1px solid color-mix(in srgb, var(--border) 85%, transparent)":"1px solid var(--border)",background:"var(--bg-card)",boxShadow:m?"0 12px 40px rgba(15, 23, 42, 0.14), 0 2px 8px rgba(15, 23, 42, 0.06)":"0 1px 3px rgba(15, 23, 42, 0.06)",minWidth:b?o?300:260:o?252:212},children:[!m&&l?t.jsx("div",{className:"border-b px-3 py-2.5",style:{borderColor:"color-mix(in srgb, var(--border) 80%, transparent)"},children:t.jsx("h3",{className:"text-sm font-semibold",style:{color:"var(--text-main)"},children:l})}):null,de,Se]})}function mu(e){return e.use12Hour??e.hour12??!1}function pu({label:e,value:r,onChange:n,use12Hour:a,hour12:o,showSeconds:l=!1,title:i="Seleccionar hora",placeholder:c="Seleccionar hora",disabled:d=!1,displayMode:u="popover",required:m,error:f,helperText:b,helperDisplay:v,className:x,contentClassName:E,className:h=""}){const $=u==="popover",[M,y]=s.useState(!1),w=s.useRef(null),[k,N]=s.useState({horizontal:"left",vertical:"bottom"}),A=mu({use12Hour:a,hour12:o}),C=s.useMemo(()=>r?cu(r,{use12Hour:A,showSeconds:l}):"",[A,l,r]);s.useEffect(()=>{if(!$||!M||!w.current)return;const G=w.current.getBoundingClientRect(),T=8,Z=A?l?300:260:l?252:212,H=276,ae=G.left+Z>window.innerWidth-T,X=G.right-Z>=T,V=G.bottom+8+H>window.innerHeight-T,q=G.top-8-H>=T;N({horizontal:ae&&X?"right":"left",vertical:V&&q?"top":"bottom"})},[A,$,M,l]),s.useEffect(()=>{if(!$||!M)return;function G(Z){w.current&&(w.current.contains(Z.target)||y(!1))}function T(Z){Z.key==="Escape"&&y(!1)}return document.addEventListener("mousedown",G),document.addEventListener("keydown",T),()=>{document.removeEventListener("mousedown",G),document.removeEventListener("keydown",T)}},[$,M]);const j=t.jsxs("button",{type:"button",disabled:d,onClick:()=>{d||y(G=>!G)},className:`flex h-10 w-full items-center justify-between gap-2 rounded-lg border px-2.5 text-sm transition-all duration-150 focus:outline-none disabled:cursor-not-allowed disabled:opacity-60 ${h}`,style:{background:"var(--bg-input)",borderColor:f?"var(--danger)":M?"var(--primary)":"var(--border)",color:C?"var(--text-main)":"var(--text-muted)",boxShadow:M?"0 0 0 3px color-mix(in srgb, var(--primary) 14%, transparent)":"none"},children:[t.jsxs("span",{className:"inline-flex min-w-0 items-center gap-2",children:[t.jsx(z.HiClock,{className:"h-4 w-4 shrink-0 text-[var(--text-muted)]"}),t.jsx("span",{className:"truncate",children:C||c})]}),$?t.jsx(z.HiChevronDown,{className:`h-4 w-4 shrink-0 text-[var(--text-muted)] transition-transform duration-150 ${M?"rotate-180":""}`}):null]}),W=t.jsx(_o,{variant:$?"popover":"panel",value:r||du(l),onChange:n,use12Hour:A,showSeconds:l,title:i,onClose:()=>y(!1)});return t.jsx(Ea,{label:e,required:m,error:f,helperText:b,helperDisplay:v,className:x,contentClassName:E,children:$?t.jsxs("div",{ref:w,className:"relative w-full",children:[j,M?t.jsx("div",{className:"absolute z-50",style:{...k.horizontal==="left"?{left:0}:{right:0},...k.vertical==="bottom"?{top:"calc(100% + 6px)"}:{bottom:"calc(100% + 6px)"}},children:W}):null]}):t.jsxs("div",{className:"space-y-2",children:[j,M?W:null]})})}const hu={xs:{width:28,height:16,thumb:12,padding:2},sm:{width:36,height:20,thumb:16,padding:2}};function gu({checked:e,disabled:r,onCheckedChange:n,size:a="sm",className:o="",...l}){const i=hu[a],c=e?i.width-i.thumb-i.padding*2:0;return t.jsx("button",{...l,type:"button",role:"switch","aria-checked":e,disabled:r,onClick:()=>!r&&n(!e),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 ${o}`,style:{width:i.width,height:i.height,background:e?"color-mix(in srgb, var(--primary) 85%, transparent)":"var(--bg-input)",border:e?"1px solid color-mix(in srgb, var(--primary) 55%, transparent)":"1px solid var(--border)"},children:t.jsx("span",{className:"absolute inline-block rounded-full transition-transform",style:{width:i.thumb,height:i.thumb,left:i.padding,top:"50%",transform:`translate(${c}px, -50%)`,background:e?"var(--primary-fg)":"var(--text-muted)"}})})}const zo=[".sidebar-scroll",".app-scroll",".showcase-nav-scroll","[data-overlay-scroll='true']"].join(","),vu=[":scope > [data-overlayscrollbars-contents]",":scope > .sidebar-scroll-body",":scope > .showcase-nav-scroll-body",":scope > .app-scroll-body"].join(", ");function yu(e){if(!(e instanceof HTMLElement)||e.dataset.overlayScroll==="false"||e.matches("[data-overlayscrollbars]")||e.closest("[data-overlayscrollbars]")||e.matches("textarea,input,select,[contenteditable='true']"))return!1;const r=window.getComputedStyle(e);return!(![r.overflow,r.overflowX,r.overflowY].join(" ").match(/auto|scroll/)||e.clientWidth===0&&e.clientHeight===0)}function jo(e){return e.classList.contains("sidebar-scroll")||e.classList.contains("showcase-nav-scroll")}function Wo(e){jo(e)&&e.querySelectorAll(".os-scrollbar-horizontal").forEach(r=>{r.style.display="none",r.style.height="0",r.style.pointerEvents="none"})}function xu(e){const r=e.querySelector(vu);return r instanceof HTMLElement?r:null}function qo(){return s.useEffect(()=>{const e=new WeakMap;let r=0;const n=()=>{r=0,document.querySelectorAll(zo).forEach(l=>{if(!(l instanceof HTMLElement))return;if(oa.OverlayScrollbars(l)){Wo(l);return}if(!yu(l))return;const c={overflow:jo(l)?{x:"hidden",y:"scroll"}:void 0,scrollbars:{autoHide:"leave",autoHideDelay:180}},d=xu(l),u=d?oa.OverlayScrollbars({target:l,elements:{viewport:d}},c):oa.OverlayScrollbars(l,c);Wo(l),e.set(l,u)})},a=()=>{r||(r=window.requestAnimationFrame(n))};n();const o=new MutationObserver(a);return o.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["class","data-overlay-scroll"]}),window.addEventListener("resize",a),()=>{r&&window.cancelAnimationFrame(r),o.disconnect(),window.removeEventListener("resize",a),document.querySelectorAll(zo).forEach(l=>{var i;l instanceof HTMLElement&&((i=e.get(l))==null||i.destroy())})}},[]),null}function It(e){const r=e.trim();return!r||r==="/"||r==="/."?"":(r.startsWith("/")?r:`/${r}`).replace(/\/+$/,"")}function Uo(e){try{const r=new URL(e);return It(r.pathname)}catch{return""}}function wu(e){const r=It(e);if(!r)return"";const n=r.match(/^\/apps\/[^/]+/i);if(n)return It(n[0]);const a=r.split("/").filter(Boolean);return a.length===0?"":a.length>=2&&a[0].toLowerCase()==="apps"?It(`/${a[0]}/${a[1]}`):new Set(["admin","apps","apps-list","tickets","my-tickets","projects","projects-calendars","dashboard","teams","clients","services","settings","profile","messages","notifications","my-access","my-registers","my-pings","security-incidents","email-inbox","webhook-config","webphone-config","vobo","auth","api","login","forbidden","unauthorized","change-password","reset-password","chat-widget"]).has(a[0].toLowerCase())?"":It(`/${a[0]}`)}const Ua="primeSuiteAppUrl",ku={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"}},Vo={xs:20,sm:28,md:36,lg:48,xl:64},Yo=["bg-indigo-500","bg-blue-500","bg-emerald-500","bg-violet-500","bg-amber-500","bg-teal-500","bg-rose-500","bg-cyan-500"],Nu={xs:"text-xs",sm:"text-sm",md:"text-base",lg:"text-lg"},Su="bonsaif.bot",Cu="Bonsaif Bot",Eu={xs:"p-0.5",sm:"p-1",md:"p-1.5",lg:"p-2",xl:"p-2.5"};function Xo(e){return typeof e=="string"?e.trim():""}function Mu(e){var o;if(e!==void 0)return It(e);const r=It(typeof process<"u"&&((o=process.env)==null?void 0:o.NEXT_PUBLIC_BASE_PATH)||"");if(r)return r;if(typeof window>"u")return"";try{const i=new URLSearchParams(window.location.search).get(Ua)||"";i&&window.sessionStorage.setItem(Ua,i);const c=window.sessionStorage.getItem(Ua)||"",d=i||c;if(d){const u=Uo(d);if(u&&!/^\/admin(\/|$)/i.test(u))return u}}catch{}const n=window.__NEXT_DATA__,a=(n==null?void 0:n.assetPrefix)||"";if(a){const l=a.startsWith("http")?Uo(a):It(a);if(l&&!/^\/admin(\/|$)/i.test(l))return l}return wu(window.location.pathname)}function $u(e){const r=e.split(/\s+/).map(n=>n.trim()).filter(Boolean);return r.length===0?"?":r.length===1?r[0].slice(0,1).toUpperCase():`${r[0].slice(0,1)}${r[1].slice(0,1)}`.toUpperCase()}function Tu(e){let r=0;for(const n of e)r=r*31+n.charCodeAt(0)&65535;return Yo[r%Yo.length]}function Lu(e,r){return e===Su||r===Cu}function Au(e,r){return`${e.replace(/\/$/,"")}${r}`}function Ko({userId:e,username:r,name:n,size:a="md",showName:o=!1,showTooltip:l,tooltipContent:i,fallbackLabel:c="Usuario",basePath:d,wrapperClassName:u="",labelClassName:m="",labelSize:f="xs",avatarVersion:b=0,className:v="",style:x}){const[E,h]=s.useState(!1),$=typeof e=="string"&&e.trim()&&e!=="undefined"&&e!=="null"?e.trim():"";s.useEffect(()=>{h(!1)},[$,b]);const{wh:M,text:y}=ku[a],w=Xo(n)||Xo(r)||c,k=$u(w),N=Mu(d),A=Lu(r,n),C=Au(N,"/favicon.svg"),j=s.useMemo(()=>{if(!$)return"";const H=new URLSearchParams;H.set("size",String(Vo[a])),b&&H.set("v",String(b));const ae=H.toString();return`${N}/api/user/avatar/${encodeURIComponent($)}${ae?`?${ae}`:""}`},[b,N,$,a]),W=Vo[a],G=A?t.jsx("span",{className:`${M} ${Eu[a]} 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 ${v}`,style:x,children:t.jsx("img",{src:C,alt:w,width:W,height:W,className:"h-full w-full object-contain"})}):j&&!E?t.jsx("img",{src:j,alt:w,width:W,height:W,className:`${M} rounded-full object-cover flex-shrink-0 ${v}`,style:x,loading:"lazy",referrerPolicy:"no-referrer",onError:()=>h(!0)},`${$}-${b}`):t.jsx("span",{className:`${M} ${Tu(w)} ${y} rounded-full flex items-center justify-center font-black text-white uppercase flex-shrink-0 ${v}`,style:x,title:w,children:k});if(o)return t.jsxs("span",{className:`inline-flex min-w-0 items-center gap-2 ${u}`,children:[G,t.jsx("span",{className:`min-w-0 truncate ${Nu[f]} font-medium text-[var(--text-main)] ${m}`,title:w,children:w})]});const T=l??!0,Z=i??w;return T&&Z?t.jsx(zt,{as:"span",content:Z,className:`inline-flex flex-shrink-0 ${u}`,children:G}):G}function Du({href:e,className:r,children:n}){return t.jsx("a",{href:e,className:r,children:n})}function Iu(e){return e.reduce((r,n)=>{const a=n.section??"Principal";return r[a]=[...r[a]??[],n],r},{})}function Go({children:e,navItems:r=[],currentPath:n=typeof window>"u"?"/":window.location.pathname,user:a,appName:o="Bonsaif",appLogo:l,header:i,footer:c,onLogout:d,LinkComponent:u=Du}){const[m,f]=s.useState(!1),b=Iu(r);return t.jsxs("div",{className:"min-h-screen bg-[var(--bg-main)] text-[var(--text-main)]",children:[t.jsx(qo,{}),t.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:()=>f(!0),children:t.jsx(z.HiBars3,{className:"h-5 w-5"})}),m&&t.jsx("button",{type:"button","aria-label":"Cerrar navegación",className:"fixed inset-0 z-40 bg-black/45 lg:hidden",onClick:()=>f(!1)}),t.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 ${m?"translate-x-0":"-translate-x-full"}`,children:[t.jsxs("div",{className:"flex h-16 items-center gap-3 border-b border-white/10 px-4",children:[t.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg bg-white/10 text-white",children:l??t.jsx(z.HiHome,{className:"h-5 w-5"})}),t.jsx("div",{className:"min-w-0 flex-1 truncate text-sm font-semibold",children:o}),t.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:()=>f(!1),children:t.jsx(z.HiXMark,{className:"h-5 w-5"})})]}),t.jsx("nav",{className:"sidebar-scroll min-h-0 flex-1 overflow-y-auto px-3 py-4","data-overlay-scroll":"true",children:t.jsx("div",{className:"sidebar-scroll-body",children:Object.entries(b).map(([v,x])=>t.jsxs("div",{className:"mb-5",children:[t.jsxs("div",{className:"mb-2 flex items-center gap-2 px-2 text-[11px] font-semibold uppercase tracking-wide text-white/35",children:[t.jsx(z.HiChevronDown,{className:"h-3.5 w-3.5"}),v]}),t.jsx("div",{className:"space-y-1",children:x.map(E=>{const h=n===E.href||n.startsWith(`${E.href}/`);return t.jsxs(u,{href:E.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:[t.jsx("span",{className:"flex h-5 w-5 flex-shrink-0 items-center justify-center",children:E.icon??t.jsx(z.HiHome,{className:"h-4 w-4"})}),t.jsx("span",{className:"truncate",children:E.label})]},E.href)})})]},v))})}),t.jsxs("div",{className:"border-t border-white/10 p-3",children:[a&&t.jsxs("div",{className:"mb-3 flex min-w-0 items-center gap-3 rounded-lg bg-white/[0.04] p-2",children:[t.jsx(Ko,{name:a.initials??a.name??a.email??"Usuario",size:"md"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"truncate text-sm font-medium text-white",children:a.name??"Usuario"}),a.email&&t.jsx("div",{className:"truncate text-xs text-white/45",children:a.email})]})]}),d&&t.jsxs(je,{variant:"ghost",className:"w-full justify-start text-white hover:bg-white/10",onClick:d,children:[t.jsx(z.HiArrowRightOnRectangle,{className:"h-4 w-4"})," Salir"]}),c]})]}),t.jsxs("div",{className:"min-h-screen lg:pl-72",children:[i,t.jsx("main",{className:"min-h-screen",children:e})]})]})}const Zo="bonsaif-ui:prime-auth-sso",Ou={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"},Va={dashboard:t.jsx(z.HiChartBar,{className:"h-5 w-5"}),tickets:t.jsx(z.HiTicket,{className:"h-5 w-5"}),teams:t.jsx(z.HiUsers,{className:"h-5 w-5"}),projects:t.jsx(z.HiRectangleGroup,{className:"h-5 w-5"}),clients:t.jsx(z.HiBuildingOffice2,{className:"h-5 w-5"}),surveys:t.jsx(z.HiClipboardDocumentList,{className:"h-5 w-5"}),profile:t.jsx(z.HiUser,{className:"h-5 w-5"}),settings:t.jsx(z.HiCog6Tooth,{className:"h-5 w-5"}),notifications:t.jsx(z.HiBell,{className:"h-5 w-5"}),changelog:t.jsx(z.HiDocumentText,{className:"h-5 w-5"}),admin:t.jsx(z.HiShieldCheck,{className:"h-5 w-5"}),users:t.jsx(z.HiUsers,{className:"h-5 w-5"}),roles:t.jsx(z.HiShieldCheck,{className:"h-5 w-5"}),menus:t.jsx(z.HiCog6Tooth,{className:"h-5 w-5"}),guards:t.jsx(z.HiCalendarDays,{className:"h-5 w-5"}),vacations:t.jsx(z.HiCalendarDays,{className:"h-5 w-5"}),audit:t.jsx(z.HiListBullet,{className:"h-5 w-5"}),positions:t.jsx(z.HiBriefcase,{className:"h-5 w-5"}),ranks:t.jsx(z.HiListBullet,{className:"h-5 w-5"}),"email-inbox":t.jsx(z.HiInbox,{className:"h-5 w-5"}),"security-incidents":t.jsx(z.HiShieldCheck,{className:"h-5 w-5"})};function Hu(e){return e.split("-").map(r=>r.charAt(0).toUpperCase()+r.slice(1)).join(" ")}function Bu(e){return/^\d+$/.test(e)||/^[a-f0-9]{8,}$/i.test(e)}function Fu(e){const r=e.split("/").filter(Boolean);if(r.length===0||r.length===1&&r[0]==="dashboard")return[];const n=decodeURIComponent(r[r.length-1]),a=r.length>1?decodeURIComponent(r[r.length-2]):void 0,o=Bu(n)&&a?a:n,l=Ou[o]??Hu(o);return[{label:"Inicio",href:"/"},{label:l}]}function Ya(e){return(e==null?void 0:e.querySelector(":scope > .os-viewport"))??(e==null?void 0:e.querySelector(":scope > [data-overlayscrollbars-viewport]"))}function Pu(e){const r=e.split("/").filter(Boolean),n=r[r.length-1];if(!n)return t.jsx(z.HiHome,{className:"h-5 w-5"});if(Va[n])return Va[n];const a=r.length>1?r[r.length-2]:"";return Va[a]??t.jsx(z.HiHome,{className:"h-5 w-5"})}function _u(e){return e.includes("primeAuthOrigin")||e.includes("primeAuthProjectKey")}function Qo(){if(typeof window>"u")return!1;if(_u(window.location.href)){try{window.sessionStorage.setItem(Zo,"true")}catch{}return!0}try{return window.sessionStorage.getItem(Zo)==="true"}catch{return!1}}function zu({title:e,subtitle:r,action:n,meta:a,icon:o,className:l="",contentClassName:i="",breadcrumbs:c,currentPath:d,showBreadcrumbs:u=!0,contained:m=!1}){const f=s.useRef(null),[b,v]=s.useState(!1),[x,E]=s.useState(d??"/"),[h,$]=s.useState(()=>Qo()),[M,y]=s.useState(null),w=d??x,k=c??Fu(w),N=o??Pu(w),A=u&&!h&&k.length>1,C=!A;s.useEffect(()=>{d||E(window.location.pathname)},[d]),s.useEffect(()=>{$(Qo())},[]),s.useEffect(()=>{if(m){v(!1);return}let W=null,G=0,T=0;const Z=()=>{const X=f.current,V=document.querySelector("[data-app-scroll='true']");return(X==null?void 0:X.closest(".os-viewport"))??(X==null?void 0:X.closest("[data-overlayscrollbars-viewport]"))??Ya(V)??V??window},H=()=>{const X=W&&W!==window?W.scrollTop:window.scrollY;v(V=>V?X>24:X>72)},ae=()=>{W==null||W.removeEventListener("scroll",H),W=Z(),W.addEventListener("scroll",H,{passive:!0}),H()};return ae(),G=window.requestAnimationFrame(ae),T=window.setTimeout(ae,120),()=>{window.cancelAnimationFrame(G),window.clearTimeout(T),W==null||W.removeEventListener("scroll",H)}},[m]),s.useEffect(()=>{if(m){y(null);return}let W=0;const G=[],T=()=>{const L=f.current,oe=L==null?void 0:L.parentElement,B=document.querySelector("[data-app-scroll='true']"),F=Ya(B)??B;if(!L||!oe||!F){y(null);return}const le=oe.getBoundingClientRect(),g=window.getComputedStyle(oe),P=F.getBoundingClientRect(),I=F instanceof HTMLElement&&F.clientWidth>0?F.clientWidth:P.width,te=le.left+parseFloat(g.paddingLeft||"0"),U={marginLeft:Math.round(P.left-te),width:Math.round(I)};y(K=>K&&K.marginLeft===U.marginLeft&&K.width===U.width?K:U)},Z=()=>{window.cancelAnimationFrame(W),W=window.requestAnimationFrame(T)};Z(),window.addEventListener("resize",Z);const H=new ResizeObserver(Z),ae=f.current,X=ae==null?void 0:ae.parentElement,V=document.querySelector("[data-app-scroll='true']"),q=Ya(V)??V;return[X,V,q].forEach(L=>{L&&H.observe(L)}),G.push(window.setTimeout(Z,120)),G.push(window.setTimeout(Z,280)),()=>{window.cancelAnimationFrame(W),window.removeEventListener("resize",Z),H.disconnect(),G.forEach(L=>window.clearTimeout(L))}},[m]);const j={...M?{marginLeft:M.marginLeft,width:M.width}:null,"--page-header-control-height":b?"34px":"40px","--page-header-control-padding-x":b?"10px":"14px","--page-header-control-icon-left":b?"10px":"12px",background:m?"var(--bg-card)":b?"color-mix(in srgb, var(--bg-main) 82%, transparent)":"color-mix(in srgb, var(--bg-main) 58%, transparent)",backdropFilter:"saturate(1.25) blur(18px)",WebkitBackdropFilter:"saturate(1.25) blur(18px)",borderBottom:m||b?"1px solid var(--border)":"1px solid transparent",boxShadow:b?"0 10px 28px rgba(12, 54, 53, 0.12)":"none"};return t.jsx("div",{ref:f,"data-page-header":"true","data-compact":b?"true":"false",className:`sticky top-0 z-30 overflow-visible py-0 transition-[background-color,box-shadow,border-color] duration-300 ease-out ${m?"mb-0 flex-shrink-0":"mb-4 sm:mb-0"} ${l}`,style:j,children:t.jsxs("div",{className:`flex flex-wrap items-center justify-between transition-[gap,min-height,padding] duration-300 ease-out ${b?"min-h-8 gap-1.5 px-3 py-0 sm:min-h-9 sm:gap-2":C?"min-h-9 gap-2 px-4 py-0 sm:min-h-10 sm:gap-2.5":"min-h-10 gap-2.5 px-4 pt-0.5 sm:min-h-11 sm:gap-3"} ${i}`,children:[t.jsx("div",{className:`min-w-0 flex flex-1 flex-col justify-center transition-[gap,transform] duration-300 ease-out ${b||C?"gap-1":"gap-1.5 sm:gap-2"}`,children:t.jsxs("div",{className:`flex min-w-0 items-center transition-[gap,transform] duration-300 ease-out ${b||C?"gap-2":"gap-2.5 sm:gap-3"}`,children:[t.jsx("span",{className:`flex-shrink-0 transition-[color,transform,opacity] duration-300 ease-out ${b?"scale-75 opacity-80":"scale-90 opacity-100"}`,style:{color:A?"var(--text-secondary)":"var(--text-muted)"},children:N}),t.jsxs("div",{className:`flex min-w-0 flex-1 flex-wrap items-center transition-[gap] duration-300 ease-out ${b?"gap-x-2 gap-y-1":"gap-x-3 gap-y-2"}`,children:[t.jsxs("div",{className:"min-w-0 flex-shrink transition-[transform] duration-300 ease-out",children:[t.jsx("h1",{className:`truncate font-bold tracking-tight transition-[font-size,line-height,color] duration-300 ease-out ${b?"text-sm sm:text-base":"text-lg sm:text-xl"}`,style:{color:"var(--text-main)"},children:e}),r&&t.jsx("div",{"aria-hidden":b,className:`overflow-hidden text-xs transition-[max-height,opacity,transform,margin] duration-300 ease-out ${b?"mt-0 max-h-0 -translate-y-1 opacity-0":"mt-0.5 max-h-8 translate-y-0 opacity-100"}`,style:{color:"var(--text-muted)"},children:r})]}),a&&t.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 ${b?"translate-y-0 gap-1.5 opacity-95":"gap-2 opacity-100"}`,children:a})]})]})}),n&&t.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 ${b?"min-h-9 gap-1 opacity-95":"min-h-9 gap-1.5 opacity-100"}`,children:t.jsx(hs.Provider,{value:{compact:!0,headerAction:!0},children:n})})]})})}function ju({children:e,currentPath:r=typeof window>"u"?"/":window.location.pathname,publicRoutes:n=["/","/login","/reset-password"],...a}){return n.includes(r)?t.jsx(t.Fragment,{children:e}):t.jsx(Go,{currentPath:r,...a,children:e})}function Jo(){if(typeof window>"u")return"system";const e=localStorage.getItem("theme");return e==="light"||e==="dark"?e:e==="system"?"system":document.documentElement.classList.contains("dark")?"dark":"light"}function Wu(e,r,n){try{const a=new URL(e),o=a.searchParams.get("callbackUrl");if(o){const l=new URL(o,a.origin);return l.searchParams.set("theme",r),n&&(l.searchParams.set("primeAuthOrigin",window.location.origin),l.searchParams.set("primeAuthProjectKey",n)),a.searchParams.set("callbackUrl",`${l.pathname}${l.search}${l.hash}`),a.toString()}return a.searchParams.set("theme",r),n&&(a.searchParams.set("primeAuthOrigin",window.location.origin),a.searchParams.set("primeAuthProjectKey",n)),a.toString()}catch{return e}}function qu({name:e,src:r,projectKey:n}){const[a,o]=s.useState("system"),l=s.useRef(null);s.useEffect(()=>{o(Jo());const d=new MutationObserver(()=>o(Jo()));return d.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>d.disconnect()},[]);const i=s.useMemo(()=>Wu(r,a,n),[n,r,a]),c=s.useMemo(()=>{try{return new URL(i).origin}catch{return""}},[i]);return s.useEffect(()=>{if(!n)return;const d=n;function u(m){var v,x,E;if(m.source!==((v=l.current)==null?void 0:v.contentWindow)||c&&m.origin!==c)return;if(((x=m.data)==null?void 0:x.type)==="prime-microservice:overlay"){window.dispatchEvent(new CustomEvent("prime-auth:microservice-overlay",{detail:{active:!!m.data.active}}));return}if(((E=m.data)==null?void 0:E.type)!=="prime-microservice:navigation")return;const f=m.data.path;if(!f||!f.startsWith("/")||f.startsWith("//"))return;const b=`/apps/${encodeURIComponent(d)}${f}`;`${window.location.pathname}${window.location.search}${window.location.hash}`!==b&&(window.history.replaceState(window.history.state,"",b),window.dispatchEvent(new CustomEvent("prime-auth:microservice-navigation")))}return window.addEventListener("message",u),()=>{window.removeEventListener("message",u),window.dispatchEvent(new CustomEvent("prime-auth:microservice-overlay",{detail:{active:!1}}))}},[c,n]),t.jsx("div",{className:"flex h-full min-h-screen flex-col bg-[var(--bg-main)]",children:t.jsx("iframe",{ref:l,src:i,title:e,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 Uu(){const[e,r]=s.useState(""),[n,a]=s.useState(!1),[o,l]=s.useState({width:96,height:96});return s.useEffect(()=>{let i=!1;return fetch("/api/microservices/prime-suite/chat-url",{cache:"no-store"}).then(c=>c.ok?c.json():null).then(c=>{!i&&(c!=null&&c.src)&&r(c.src)}).catch(()=>{}),()=>{i=!0}},[]),s.useEffect(()=>{const i=c=>{var u;if(((u=c.data)==null?void 0:u.type)!=="prime-suite-chat:state")return;const d=!!c.data.active;a(d),l({width:Ro(c.data.width,96,720),height:Ro(c.data.height,96,560)})};return window.addEventListener("message",i),()=>window.removeEventListener("message",i)},[]),e?t.jsx("iframe",{title:"Chat Bonsaif",src:e,allow:"clipboard-write",className:"fixed bottom-0 right-0 z-[70] border-0 bg-transparent transition-[width,height] duration-200",style:{width:n?`min(${o.width}px, 100vw)`:96,height:n?`min(${o.height}px, 100vh)`:96,background:"transparent",backgroundColor:"transparent",colorScheme:"normal"}}):null}function Ro(e,r,n){const a=typeof e=="number"&&Number.isFinite(e)?e:r;return Math.max(r,Math.min(n,Math.ceil(a)))}function Vu(e){const r=document.documentElement,n=new MutationObserver(e);n.observe(r,{attributes:!0,attributeFilter:["class"]});const a=window.matchMedia("(prefers-color-scheme: dark)");return a.addEventListener("change",e),()=>{n.disconnect(),a.removeEventListener("change",e)}}function Yu(){const e=localStorage.getItem("theme")||"system",r=window.matchMedia("(prefers-color-scheme: dark)").matches;return document.documentElement.classList.contains("dark")||e==="dark"||e==="system"&&r?"dark":"light"}function Xu(){return"light"}function Ku({position:e="bottom-center"}){const r=s.useSyncExternalStore(Vu,Yu,Xu);return t.jsx(bs.Toaster,{position:e,theme:r,richColors:!0,closeButton:!0})}function Gu({title:e,subtitle:r,actions:n,loading:a=!1,empty:o=!1,emptyText:l="Sin datos para mostrar",className:i="",children:c}){return t.jsxs("div",{className:`bonsaif-chart-card w-full overflow-visible ${i}`,children:[(e||r||n)&&t.jsxs("div",{className:"bonsaif-chart-card-head",children:[t.jsx("div",{className:"bonsaif-chart-card-accent","aria-hidden":!0}),t.jsxs("div",{className:"bonsaif-chart-card-copy min-w-0",children:[e?t.jsx("div",{className:"bonsaif-chart-card-title",children:e}):null,r?t.jsx("div",{className:"bonsaif-chart-card-subtitle",children:r}):null]}),n?t.jsx("div",{className:"bonsaif-chart-card-actions shrink-0",children:n}):null]}),t.jsx("div",{className:"bonsaif-chart-card-body",children:a?t.jsx("div",{className:"flex h-48 items-center justify-center",children:t.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-2 border-t-transparent",style:{borderColor:"var(--border)",borderTopColor:"var(--primary)"},"aria-label":"Cargando"})}):o?t.jsx("div",{className:"flex h-48 items-center justify-center text-sm",style:{color:"var(--text-muted)"},children:l}):c})]})}const Yr=["var(--primary)","#38bdf8","#34d399","#a78bfa","#2dd4bf","#fbbf24","#60a5fa","#94a3b8"];function el(e,r){return e.color??Yr[r%Yr.length]}function yt(e="primary"){switch(e){case"success":return"#34d399";case"warning":return"#fbbf24";case"danger":return"#f87171";case"neutral":return"var(--text-muted)";default:return"var(--primary)"}}const ot=e=>{if(!Number.isFinite(e))return"—";const r=Math.abs(e);return r>=1e9?`${(e/1e9).toFixed(1).replace(/\.0$/,"")}B`:r>=1e6?`${(e/1e6).toFixed(1).replace(/\.0$/,"")}M`:r>=1e4?`${(e/1e3).toFixed(1).replace(/\.0$/,"")}k`:e.toLocaleString(void 0,{maximumFractionDigits:2})};function br(e){if(e==null||e==="")return null;const r=typeof e=="number"?e:Number(e);return Number.isFinite(r)?r:null}const Xa={warning:70,danger:90};function Ln(e,r=Xa){const n=r.warning??Xa.warning,a=r.danger??Xa.danger;return e>=a?"danger":e>=n?"warning":e<=0?"primary":"success"}function Xr(e,r){return yt(Ln(e,r))}function mr(e,r=0){return Number.isFinite(e)?`${e.toFixed(r)}%`:"—"}function pr(e,r=1){if(!Number.isFinite(e))return"—";const n=e<0?"-":"",a=Math.abs(e);if(a<1024)return`${n}${Math.round(a)} B`;const o=["KB","MB","GB","TB","PB"];let l=a/1024,i=0;for(;l>=1024&&i<o.length-1;)l/=1024,i+=1;const c=l>=100?l.toFixed(0):l.toFixed(r);return`${n}${c.replace(/\.0$/,"")} ${o[i]}`}function tl(e,r="bytes",n=1){if(!Number.isFinite(e))return"—";const a=e<0?"-":"",o=Math.abs(e),l=r==="bits"?["b/s","Kb/s","Mb/s","Gb/s","Tb/s"]:["B/s","KB/s","MB/s","GB/s","TB/s"];if(o<1024)return`${a}${Math.round(o)} ${l[0]}`;let i=o/1024,c=1;for(;i>=1024&&c<l.length-1;)i/=1024,c+=1;const d=i>=100?i.toFixed(0):i.toFixed(n);return`${a}${d.replace(/\.0$/,"")} ${l[c]}`}function hr(e,r){var n;for(let a=e.length-1;a>=0;a-=1){const o=br((n=e[a])==null?void 0:n[r]);if(o!==null)return o}return null}function lt({height:e}){return t.jsx("div",{className:"flex items-center justify-center",style:{height:e},"aria-busy":!0,children:t.jsx("div",{className:"h-7 w-7 animate-spin rounded-full border-2",style:{borderColor:"var(--border)",borderTopColor:"var(--primary)"}})})}function it({height:e,text:r}){return t.jsx("div",{className:"flex items-center justify-center text-sm",style:{height:e,color:"var(--text-muted)"},children:r})}const Ot=680,qt="ease-out",Zu={top:18,right:8,bottom:12,left:0};function Kr(e){return{...Zu,...e}}function Gr(e){return e.map((r,n)=>({...r,color:el(r,n),label:r.label??r.key}))}function An(e,r){return!e.length||!r.length||e.every(n=>r.every(a=>br(n[a.key])===null))}function ct(){return{fill:"var(--text-muted)",fontSize:10,fontWeight:500,letterSpacing:"0.02em"}}function Zr(){return"color-mix(in srgb, var(--border) 55%, transparent)"}function rl(){return"color-mix(in srgb, var(--primary) 45%, var(--border))"}function Dn(){return{paddingBottom:12,paddingLeft:4,fontSize:11,fontWeight:600,letterSpacing:"0.04em",textTransform:"uppercase",color:"var(--text-muted)"}}function Qu(e,r=ot){if(e==null||e==="")return"—";const n=typeof e=="number"?e:Number(e);return Number.isFinite(n)?r(n):String(e)}function nl(e){return`bonsaif-grad-${e.replace(/[^a-zA-Z0-9_-]/g,"")}`}function Ju({active:e,label:r,payload:n,valueFormat:a=ot}){var c,d,u,m,f,b;if(!e||!(n!=null&&n.length))return null;const o=n.filter(v=>v.dataKey!=="base"&&v.name!=="base"&&v.value!==null&&v.value!==void 0);if(!o.length)return null;const l=((d=(c=o[0])==null?void 0:c.payload)==null?void 0:d.fullName)??((m=(u=o[0])==null?void 0:u.payload)==null?void 0:m.tooltipLabel)??((b=(f=o[0])==null?void 0:f.payload)==null?void 0:b.display),i=typeof l=="string"&&l.length>0?l:r;return t.jsxs("div",{className:"bonsaif-chart-tooltip-panel",children:[i!=null&&i!==""?t.jsx("div",{className:"bonsaif-chart-tooltip-label",children:String(i)}):null,t.jsx("div",{className:"bonsaif-chart-tooltip-items",children:o.map((v,x)=>{const E=v.payload,h=E&&typeof E.display=="number"?E.display:v.value;return t.jsxs("div",{className:"bonsaif-chart-tooltip-row",children:[t.jsxs("span",{className:"bonsaif-chart-tooltip-name",children:[t.jsx("span",{className:"bonsaif-chart-tooltip-swatch",style:{background:v.color??"var(--primary)"}}),v.name??v.dataKey]}),t.jsx("span",{className:"bonsaif-chart-tooltip-value",children:Qu(h,a)})]},String(v.dataKey??v.name??x))})})]})}function gr({valueFormat:e,content:r,cursor:n,offset:a=12,wrapperStyle:o,allowEscapeViewBox:l,reverseDirection:i,...c}){return t.jsx(Ne.Tooltip,{...c,cursor:n,offset:a,allowEscapeViewBox:l??{x:!1,y:!1},reverseDirection:i??{x:!1,y:!1},wrapperStyle:{outline:"none",zIndex:60,pointerEvents:"none",overflow:"visible",...o},content:r??t.jsx(Ju,{valueFormat:e})})}function al(e,r,n){return n==null?-1:e.findIndex(a=>String(a[r])===String(n))}function sl(e,r,n){if(n<=1)return null;const a=Math.max(0,Math.min(e,r)),o=Math.min(n-1,Math.max(e,r));return o-a<1||a===0&&o>=n-1?null:{startIndex:a,endIndex:o}}function In(e,r,n={}){const{zoomable:a=!1,zoomMode:o="both",brushHeight:l=28,onZoomChange:i}=n,[c,d]=s.useState(null),[u,m]=s.useState(null),f=!!a&&e.length>1,b=f&&(o==="brush"||o==="both"),v=f&&(o==="drag"||o==="both"),x=s.useCallback(G=>{d(G),i==null||i(G)},[i]),E=s.useCallback(()=>{m(null),x(null)},[x]),h=!!c,$=s.useMemo(()=>!c||b?e:e.slice(c.startIndex,c.endIndex+1),[e,b,c]),M=s.useCallback((G,T)=>{const Z=al(e,r,G),H=al(e,r,T);Z<0||H<0||x(sl(Z,H,e.length))},[x,e,r]),y=s.useCallback(G=>{v&&((G==null?void 0:G.activeLabel)===void 0||(G==null?void 0:G.activeLabel)===null||m({leftLabel:G.activeLabel,rightLabel:G.activeLabel}))},[v]),w=s.useCallback(G=>{!v||!u||(G==null?void 0:G.activeLabel)===void 0||(G==null?void 0:G.activeLabel)===null||m(T=>T&&{...T,rightLabel:G.activeLabel})},[u,v]),k=s.useCallback(()=>{if(v){if(!u||u.rightLabel===null||u.rightLabel===void 0){m(null);return}M(u.leftLabel,u.rightLabel),m(null)}},[M,u,v]),N=s.useCallback(G=>{if(b){if(!G){x(null);return}x(sl(G.startIndex??0,G.endIndex??e.length-1,e.length))}},[x,e.length,b]),A=v?{onMouseDown:y,onMouseMove:w,onMouseUp:k,onMouseLeave:()=>{u&&k()}}:{},C=c??{startIndex:0,endIndex:Math.max(0,e.length-1)},j=t.jsxs(t.Fragment,{children:[v&&u&&u.rightLabel!==null&&u.rightLabel!==void 0?t.jsx(Ne.ReferenceArea,{x1:u.leftLabel,x2:u.rightLabel,strokeOpacity:.18,fill:"var(--primary)",fillOpacity:.12,stroke:"var(--primary)"}):null,b?t.jsx(Ne.Brush,{dataKey:r,height:l,stroke:"var(--primary)",fill:"color-mix(in srgb, var(--primary) 10%, var(--bg-card))",travellerWidth:8,startIndex:C.startIndex,endIndex:C.endIndex,onChange:N,tickFormatter:G=>String(G)}):null]}),W=b?{bottom:Math.max(l+10,36)}:void 0;return{enabled:f,showBrush:b,showDrag:v,viewData:$,isZoomed:h,resetZoom:E,chartHandlers:A,zoomNodes:j,marginExtra:W}}function On({visible:e,onReset:r}){return e?t.jsx("button",{type:"button",className:"bonsaif-chart-zoom-reset",onClick:r,"aria-label":"Restablecer zoom",children:"Restablecer zoom"}):null}function Ru({data:e,xKey:r,series:n,height:a=280,className:o="",loading:l=!1,emptyText:i="Sin datos para mostrar",showGrid:c=!0,showLegend:d=!0,showTooltip:u=!0,margin:m,valueFormat:f=ot,yDomain:b,ariaLabel:v="Gráfico de líneas",curve:x=!0,strokeWidth:E=2.25,zoomable:h=!1,zoomMode:$="both",brushHeight:M,onZoomChange:y}){const w=An(e,n),k=Gr(n),N=In(e,r,{zoomable:h,zoomMode:$,brushHeight:M,onZoomChange:y}),A=Kr({...m,...N.marginExtra});return l?t.jsx(lt,{height:a}):w?t.jsx(it,{height:a,text:i}):t.jsxs("div",{className:`bonsaif-chart bonsaif-line-chart w-full ${o}`,role:"img","aria-label":v,style:{height:a},children:[t.jsx(On,{visible:N.isZoomed,onReset:N.resetZoom}),t.jsx(Ne.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Ne.LineChart,{data:N.viewData,margin:A,...N.chartHandlers,children:[c?t.jsx(Ne.CartesianGrid,{strokeDasharray:"2 8",stroke:Zr(),vertical:!1}):null,t.jsx(Ne.XAxis,{dataKey:r,tick:ct(),tickLine:!1,axisLine:!1,padding:{left:0,right:0},interval:"preserveStartEnd",minTickGap:52,dy:6}),t.jsx(Ne.YAxis,{tick:ct(),tickLine:!1,axisLine:!1,width:44,domain:b??["auto","auto"],tickFormatter:C=>f(Number(C)),dx:-2}),u?t.jsx(gr,{valueFormat:f,cursor:{stroke:rl(),strokeWidth:1.25,strokeDasharray:"4 4"}}):null,d?t.jsx(Ne.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:Dn()}):null,k.map((C,j)=>t.jsx(Ne.Line,{type:x?"monotone":"linear",dataKey:C.key,name:C.label,stroke:C.color,strokeWidth:j===0?E+.35:E,strokeOpacity:j===0?1:.88,isAnimationActive:!0,animationDuration:Ot,animationEasing:qt,dot:!1,activeDot:{r:5,strokeWidth:2,stroke:"var(--bg-card)",fill:C.color}},C.key)),N.zoomNodes]})})]})}function Hn({data:e,xKey:r,series:n,height:a=280,className:o="",loading:l=!1,emptyText:i="Sin datos para mostrar",showGrid:c=!0,showLegend:d=!0,showTooltip:u=!0,margin:m,valueFormat:f=ot,yDomain:b,ariaLabel:v="Gráfico de área",stacked:x=!1,opacity:E=.22,zoomable:h=!1,zoomMode:$="both",brushHeight:M,onZoomChange:y}){const w=An(e,n),k=Gr(n),N=In(e,r,{zoomable:h,zoomMode:$,brushHeight:M,onZoomChange:y}),A=Kr({...m,...N.marginExtra});return l?t.jsx(lt,{height:a}):w?t.jsx(it,{height:a,text:i}):t.jsxs("div",{className:`bonsaif-chart bonsaif-area-chart w-full ${o}`,role:"img","aria-label":v,style:{height:a},children:[t.jsx(On,{visible:N.isZoomed,onReset:N.resetZoom}),t.jsx(Ne.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Ne.AreaChart,{data:N.viewData,margin:A,...N.chartHandlers,children:[t.jsx("defs",{children:k.map(C=>t.jsxs("linearGradient",{id:nl(C.key),x1:"0",y1:"0",x2:"0",y2:"1",children:[t.jsx("stop",{offset:"0%",stopColor:C.color,stopOpacity:Math.min(.55,E+.28)}),t.jsx("stop",{offset:"48%",stopColor:C.color,stopOpacity:E*.5}),t.jsx("stop",{offset:"100%",stopColor:C.color,stopOpacity:0})]},C.key))}),c?t.jsx(Ne.CartesianGrid,{strokeDasharray:"2 8",stroke:Zr(),vertical:!1}):null,t.jsx(Ne.XAxis,{dataKey:r,tick:ct(),tickLine:!1,axisLine:!1,padding:{left:0,right:0},interval:"preserveStartEnd",minTickGap:52,dy:6}),t.jsx(Ne.YAxis,{tick:ct(),tickLine:!1,axisLine:!1,width:44,domain:b??["auto","auto"],tickFormatter:C=>f(Number(C)),dx:-2}),u?t.jsx(gr,{valueFormat:f,cursor:{stroke:rl(),strokeWidth:1.25,strokeDasharray:"4 4"}}):null,d?t.jsx(Ne.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:Dn()}):null,k.map(C=>t.jsx(Ne.Area,{type:"monotone",dataKey:C.key,name:C.label,stroke:C.color,fill:`url(#${nl(C.key)})`,strokeWidth:2.25,stackId:x?"stack":void 0,isAnimationActive:!0,animationDuration:Ot,animationEasing:qt,dot:!1,activeDot:{r:5,strokeWidth:2,stroke:"var(--bg-card)",fill:C.color}},C.key)),N.zoomNodes]})})]})}function ef({data:e,xKey:r,series:n,height:a=280,className:o="",loading:l=!1,emptyText:i="Sin datos para mostrar",showGrid:c=!0,showLegend:d=!0,showTooltip:u=!0,margin:m,valueFormat:f=ot,yDomain:b,ariaLabel:v="Gráfico de barras",layout:x="vertical",mode:E="grouped",barRadius:h=6,categoryAxisWidth:$=64,zoomable:M=!1,zoomMode:y="both",brushHeight:w,onZoomChange:k}){const N=An(e,n),A=Gr(n),C=x==="horizontal",j=In(e,r,{zoomable:M&&!C,zoomMode:y,brushHeight:w,onZoomChange:k}),W=Kr({...m,...j.marginExtra});return l?t.jsx(lt,{height:a}):N?t.jsx(it,{height:a,text:i}):t.jsxs("div",{className:`bonsaif-chart bonsaif-bar-chart w-full ${o}`,role:"img","aria-label":v,style:{height:a},children:[t.jsx(On,{visible:j.isZoomed,onReset:j.resetZoom}),t.jsx(Ne.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Ne.BarChart,{data:j.viewData,margin:W,layout:C?"vertical":"horizontal",barCategoryGap:"34%",barGap:3,...j.chartHandlers,children:[c?t.jsx(Ne.CartesianGrid,{strokeDasharray:"2 8",stroke:Zr(),horizontal:!C,vertical:C}):null,C?t.jsxs(t.Fragment,{children:[t.jsx(Ne.XAxis,{type:"number",tick:ct(),tickLine:!1,axisLine:!1,tickFormatter:G=>f(Number(G)),domain:b??["auto","auto"]}),t.jsx(Ne.YAxis,{type:"category",dataKey:r,tick:ct(),tickLine:!1,axisLine:!1,width:$})]}):t.jsxs(t.Fragment,{children:[t.jsx(Ne.XAxis,{dataKey:r,tick:ct(),tickLine:!1,axisLine:!1,interval:"preserveStartEnd",minTickGap:36,dy:6}),t.jsx(Ne.YAxis,{tick:ct(),tickLine:!1,axisLine:!1,width:44,domain:b??["auto","auto"],tickFormatter:G=>f(Number(G)),dx:-2})]}),u?t.jsx(gr,{valueFormat:f,cursor:{fill:"color-mix(in srgb, var(--primary) 8%, transparent)"}}):null,d?t.jsx(Ne.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:Dn()}):null,A.map((G,T)=>t.jsx(Ne.Bar,{dataKey:G.key,name:G.label,fill:G.color,fillOpacity:T===0?1:.82,radius:C?[0,h,h,0]:[h,h,2,2],maxBarSize:20,stackId:E==="stacked"?"stack":void 0,isAnimationActive:!0,animationDuration:Ot,animationEasing:qt},G.key)),j.zoomNodes]})})]})}function tf(e){return t.jsx(ll,{...e,variant:"pie"})}function rf(e){return t.jsx(ll,{...e,variant:"donut",innerRadius:e.innerRadius??.62,cornerRadius:e.cornerRadius??10,padAngle:e.padAngle??2})}function ol(e,r){return e==null||!Number.isFinite(e)?r:e>0&&e<=1?e*100:e}function ll({data:e,nameKey:r,valueKey:n,height:a=280,className:o="",loading:l=!1,emptyText:i="Sin datos para mostrar",showLegend:c=!0,showTooltip:d=!0,valueFormat:u=ot,ariaLabel:m,innerRadius:f,outerRadius:b,colors:v=[...Yr],padAngle:x,cornerRadius:E,variant:h}){const $=e.map((T,Z)=>({name:String(T[r]??""),value:br(T[n])??0,fill:v[Z%v.length],row:T})).filter(T=>T.value>0),M=!$.length,y=h==="donut",w=$.length,k=ol(f,y?62:12),N=ol(b,78),A=Math.min(x??(y?2:3),Math.max(.5,10/Math.max(1,w))),C=Math.min(E??(y?10:8),Math.max(2,36/Math.max(1,w)));if(l)return t.jsx(lt,{height:a});if(M)return t.jsx(it,{height:a,text:i});const j=$.reduce((T,Z)=>T+Z.value,0),W=c?Math.min(96,28+Math.ceil(w/3)*22):0,G=Math.max(140,a-W);return t.jsx("div",{className:`bonsaif-chart bonsaif-${h}-chart w-full ${o}`,role:"img","aria-label":m??(h==="donut"?"Donut chart":"Pie chart"),style:{height:a},children:t.jsxs("div",{className:"bonsaif-pie-layout",children:[t.jsx("div",{className:"bonsaif-pie-plot",style:{height:G},children:t.jsx(Ne.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Ne.PieChart,{margin:{top:4,right:4,bottom:4,left:4},children:[d?t.jsx(gr,{valueFormat:u,isAnimationActive:!1}):null,t.jsx(Ne.Pie,{data:$,dataKey:"value",nameKey:"name",cx:"50%",cy:"50%",innerRadius:`${k}%`,outerRadius:`${N}%`,startAngle:90,endAngle:-270,paddingAngle:A,cornerRadius:C,minAngle:w>6?3:2,stroke:"var(--bg-card)",strokeWidth:2,isAnimationActive:!0,animationDuration:Ot,animationEasing:qt,label:!1,activeShape:nf,children:$.map(T=>t.jsx(Ne.Cell,{fill:T.fill},T.name))}),y?t.jsx("text",{x:"50%",y:"50%",textAnchor:"middle",dominantBaseline:"middle",fill:"var(--text-main)",fontSize:18,fontWeight:700,letterSpacing:"-0.02em",children:u(j)}):null]})})}),c?t.jsx("ul",{className:"bonsaif-pie-legend","aria-label":"Leyenda",children:$.map(T=>t.jsxs("li",{className:"bonsaif-pie-legend-item",children:[t.jsx("span",{className:"bonsaif-pie-legend-swatch",style:{background:T.fill},"aria-hidden":!0}),t.jsx("span",{className:"bonsaif-pie-legend-label",title:T.name,children:T.name}),t.jsx("span",{className:"bonsaif-pie-legend-value",children:u(T.value)})]},T.name))}):null]})})}function nf(e){const{outerRadius:r=0,...n}=e;return t.jsx(Ne.Sector,{...n,outerRadius:Number(r)+4,stroke:"var(--bg-card)",strokeWidth:2})}function af({data:e,dataKey:r,width:n="100%",height:a=36,tone:o="primary",color:l,fill:i=!0,className:c="",ariaLabel:d="Sparkline"}){const u=l??yt(o),m=e.map(N=>br(N[r])).filter(N=>N!==null);if(m.length<2)return t.jsx("div",{className:c,style:{width:n,height:a,color:"var(--text-muted)"},"aria-label":d});const f=120,b=36,v=3,x=1,E=Math.min(...m),$=Math.max(...m)-E||1,M=m.map((N,A)=>{const C=x+A/(m.length-1)*(f-x*2),j=b-v-(N-E)/$*(b-v*2);return{x:C,y:j}}),y=M.map((N,A)=>`${A===0?"M":"L"}${N.x.toFixed(2)} ${N.y.toFixed(2)}`).join(" "),w=`${y} L${M[M.length-1].x.toFixed(2)} ${b} L${M[0].x.toFixed(2)} ${b} Z`,k=`bonsaif-spark-${r.replace(/[^a-zA-Z0-9_-]/g,"")}-${o}`;return t.jsx("div",{className:`bonsaif-sparkline ${c}`,style:{width:n,height:a},role:"img","aria-label":d,children:t.jsxs("svg",{width:"100%",height:"100%",viewBox:`0 0 ${f} ${b}`,preserveAspectRatio:"none",focusable:"false",children:[i?t.jsx("defs",{children:t.jsxs("linearGradient",{id:k,x1:"0",y1:"0",x2:"0",y2:"1",children:[t.jsx("stop",{offset:"0%",stopColor:u,stopOpacity:.38}),t.jsx("stop",{offset:"100%",stopColor:u,stopOpacity:0})]})}):null,i?t.jsx("path",{d:w,fill:`url(#${k})`}):null,t.jsx("path",{d:y,fill:"none",stroke:u,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",vectorEffect:"non-scaling-stroke"})]})})}function sf({data:e,xKey:r,series:n,barSeries:a,lineSeries:o,height:l=280,className:i="",loading:c=!1,emptyText:d="Sin datos para mostrar",showGrid:u=!0,showLegend:m=!0,showTooltip:f=!0,margin:b,valueFormat:v=ot,yDomain:x,ariaLabel:E="Gráfico combinado",barRadius:h=6,zoomable:$=!1,zoomMode:M="both",brushHeight:y,onZoomChange:w}){const k=a??n.slice(0,Math.max(1,n.length-1)),N=o??(n.length>1?n.slice(-1):n.length?[n[0]]:[]),A=[...k,...N.filter(H=>!k.some(ae=>ae.key===H.key))],C=An(e,A),j=Gr(k),W=Gr(A),G=N.map(H=>{var X;const ae=W.find(V=>V.key===H.key);return{...H,label:H.label??H.key,color:H.color??(ae==null?void 0:ae.color)??((X=W[0])==null?void 0:X.color)}}),T=In(e,r,{zoomable:$,zoomMode:M,brushHeight:y,onZoomChange:w}),Z=Kr({...b,...T.marginExtra});return c?t.jsx(lt,{height:l}):C?t.jsx(it,{height:l,text:d}):t.jsxs("div",{className:`bonsaif-chart bonsaif-combo-chart w-full ${i}`,role:"img","aria-label":E,style:{height:l},children:[t.jsx(On,{visible:T.isZoomed,onReset:T.resetZoom}),t.jsx(Ne.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Ne.ComposedChart,{data:T.viewData,margin:Z,barCategoryGap:"34%",...T.chartHandlers,children:[u?t.jsx(Ne.CartesianGrid,{strokeDasharray:"2 8",stroke:Zr(),vertical:!1}):null,t.jsx(Ne.XAxis,{dataKey:r,tick:ct(),tickLine:!1,axisLine:!1,interval:"preserveStartEnd",minTickGap:36,dy:6}),t.jsx(Ne.YAxis,{tick:ct(),tickLine:!1,axisLine:!1,width:44,domain:x??["auto","auto"],tickFormatter:H=>v(Number(H)),dx:-2}),f?t.jsx(gr,{valueFormat:v,cursor:{fill:"color-mix(in srgb, var(--primary) 8%, transparent)"}}):null,m?t.jsx(Ne.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:Dn()}):null,j.map(H=>t.jsx(Ne.Bar,{dataKey:H.key,name:H.label,fill:H.color,fillOpacity:.88,radius:[h,h,2,2],maxBarSize:18,isAnimationActive:!0,animationDuration:Ot,animationEasing:qt},H.key)),G.map(H=>t.jsx(Ne.Line,{type:"monotone",dataKey:H.key,name:H.label,stroke:H.color,strokeWidth:2.5,isAnimationActive:!0,animationDuration:Ot,animationEasing:qt,dot:!1,activeDot:{r:5,strokeWidth:2,stroke:"var(--bg-card)",fill:H.color}},H.key)),T.zoomNodes]})})]})}function of({data:e,xKey:r,valueKey:n,typeKey:a,height:o=280,className:l="",loading:i=!1,emptyText:c="Sin datos para mostrar",showGrid:d=!0,showTooltip:u=!0,margin:m,valueFormat:f=ot,ariaLabel:b="Gráfico waterfall",increaseColor:v="#34d399",decreaseColor:x="#f87171",totalColor:E="var(--primary)"}){const h=s.useMemo(()=>lf(e,{xKey:r,valueKey:n,typeKey:a,increaseColor:v,decreaseColor:x,totalColor:E}),[e,r,n,a,v,x,E]),$=!h.length,M=Kr(m);return i?t.jsx(lt,{height:o}):$?t.jsx(it,{height:o,text:c}):t.jsx("div",{className:`bonsaif-chart bonsaif-waterfall-chart w-full ${l}`,role:"img","aria-label":b,style:{height:o},children:t.jsx(Ne.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Ne.BarChart,{data:h,margin:M,barCategoryGap:"42%",children:[d?t.jsx(Ne.CartesianGrid,{strokeDasharray:"2 8",stroke:Zr(),vertical:!1}):null,t.jsx(Ne.XAxis,{dataKey:"label",tick:ct(),tickLine:!1,axisLine:!1,interval:0,dy:6}),t.jsx(Ne.YAxis,{tick:ct(),tickLine:!1,axisLine:!1,width:44,tickFormatter:y=>f(Number(y)),dx:-2}),u?t.jsx(gr,{valueFormat:f,cursor:{fill:"color-mix(in srgb, var(--primary) 8%, transparent)"}}):null,t.jsx(Ne.Bar,{dataKey:"base",stackId:"wf",fill:"transparent",isAnimationActive:!1,legendType:"none",maxBarSize:22}),t.jsx(Ne.Bar,{dataKey:"delta",name:"Valor",stackId:"wf",radius:[6,6,2,2],maxBarSize:22,isAnimationActive:!0,animationDuration:Ot,animationEasing:qt,children:h.map(y=>t.jsx(Ne.Cell,{fill:y.color},y.label))})]})})})}function lf(e,r){let n=0;return e.map((a,o)=>{const l=br(a[r.valueKey])??0,i=r.typeKey?String(a[r.typeKey]??""):"",c=i==="total"||o===e.length-1&&i!=="increase"&&i!=="decrease";let d="increase",u=0,m=0,f=l;return c&&i==="total"?(d="total",u=0,m=Math.abs(l),f=l,n=l):c&&o===e.length-1&&!i?(d="total",u=0,m=Math.abs(n),f=n):(d=i==="decrease"||l<0?"decrease":"increase",d==="decrease"?(u=n+l,m=Math.abs(l),n=n+l):(u=n,m=Math.abs(l),n=n+l),f=l),{label:String(a[r.xKey]??""),base:u,delta:m,display:f,kind:d,color:d==="total"?r.totalColor:d==="decrease"?r.decreaseColor:r.increaseColor}})}const il="bonsaif-funnel-chart-keyframes",cf=`
44
+ `}),T.map(O=>{const re=ef(O.colorIndex);return L===O.id?t.jsx("input",{ref:te,value:W,disabled:s,onChange:z=>X(z.target.value),onKeyDown:z=>M(z,O.id),onBlur:()=>ae(O.id,W),className:"min-w-[4rem] rounded border border-[var(--primary)] bg-transparent px-1 py-0.5 text-sm text-[var(--text-main)] outline-none",style:{width:`${Math.max(W.length+2,6)}ch`}},O.id):t.jsxs("span",{className:"inline-flex max-w-[240px] items-center gap-1 rounded-md px-2 py-0.5 text-xs font-medium",style:{backgroundColor:re.bg,color:re.text,border:`1px solid ${re.border}`},children:[t.jsx("span",{className:"truncate",children:O.value}),t.jsx("button",{type:"button","aria-label":`Editar "${O.value}"`,disabled:s,tabIndex:-1,onClick:z=>{z.stopPropagation(),B(O)},className:"flex h-4 w-4 flex-shrink-0 items-center justify-center rounded opacity-60 transition-opacity hover:opacity-100 focus:outline-none disabled:pointer-events-none",children:t.jsx(q.HiPencil,{className:"h-3 w-3"})}),t.jsx("button",{type:"button","aria-label":`Eliminar "${O.value}"`,disabled:s,tabIndex:-1,onClick:z=>{z.stopPropagation(),_(O.id)},className:"flex h-4 w-4 flex-shrink-0 items-center justify-center rounded opacity-60 transition-opacity hover:opacity-100 focus:outline-none disabled:pointer-events-none",children:t.jsx(q.HiXMark,{className:"h-3.5 w-3.5"})})]},O.id)}),!H&&t.jsx("input",{ref:se,value:x,disabled:s,placeholder:T.length===0?a:"",onChange:O=>y(O.target.value),onKeyDown:I,onPaste:K,className:"min-w-[8rem] flex-1 bg-transparent text-sm text-[var(--text-main)] outline-none placeholder:text-[var(--text-muted)] disabled:cursor-not-allowed"})]}),t.jsx(wr,{error:h,helperText:b,helperDisplay:f})]})}const of=/^(\d{1,2}):(\d{2})(?::(\d{2}))?$/;function Je(e){return String(e).padStart(2,"0")}function bo(e,r=Mr()){const n=e.trim();if(!n)return r;const a=n.match(of);if(!a)return r;const s=Number(a[1]),l=Number(a[2]),i=a[3]?Number(a[3]):0;return!Number.isFinite(s)||!Number.isFinite(l)||!Number.isFinite(i)||s<0||s>23||l<0||l>59||i<0||i>59?r:{hour24:s,minute:l,second:i}}function an(e,r=!0){const n=`${Je(e.hour24)}:${Je(e.minute)}`;return r?`${n}:${Je(e.second)}`:n}function Kn(e){const r=e.hour24>=12?"PM":"AM";return{hour12:e.hour24%12===0?12:e.hour24%12,minute:e.minute,second:e.second,meridiem:r}}function on(e){let n=Math.min(12,Math.max(1,e.hour12))%12;return e.meridiem==="PM"&&(n+=12),{hour24:n,minute:Math.min(59,Math.max(0,e.minute)),second:Math.min(59,Math.max(0,e.second))}}function sf(e,r){const n=(r==null?void 0:r.use12Hour)??!1,a=(r==null?void 0:r.showSeconds)??!0,s=bo(e);if(n){const l=Kn(s),i=`${l.hour12}:${Je(l.minute)}`;return`${a?`${i}:${Je(l.second)}`:i} ${l.meridiem}`}return an(s,a)}function Mr(){const e=new Date;return{hour24:e.getHours(),minute:e.getMinutes(),second:e.getSeconds()}}function lf(e=!0){return an(Mr(),e)}function mo(e,r){const n=[];for(let a=e;a<=r;a+=1)n.push(a);return n}const ht=36,po=5,xl=Math.floor(po/2),cf=52,df=48,zt=18;function wl(e){return e*ht}function Nl(e){return Math.round(e/ht)}function uf(e){return e.use12Hour??e.hour12??!1}function Gn({values:e,selected:r,onSelect:n,syncEpochRef:a,forceSyncAt:s=0,width:l=cf,label:i,maxNumeric:c=59,isMeridiem:d=!1,isFocused:u=!1,onFocus:m,onAdvance:b,onBack:f,setColumnRef:h}){const v=o.useRef(null),k=o.useRef(null),g=o.useRef(null),A=o.useRef(""),$=o.useRef(0),N=o.useRef(!1),[T,x]=o.useState(r),[y,L]=o.useState(""),w=o.useCallback(B=>{A.current=B,L(B)},[]),W=o.useMemo(()=>[...Array(xl).fill(""),...e,...Array(xl).fill("")],[e]),X=o.useCallback(()=>{const B=v.current;if(!B)return r;const I=Nl(B.scrollTop),M=Math.min(Math.max(I,0),e.length-1);return e[M]??r},[r,e]),Z=o.useCallback((B,I=!0)=>{const M=Math.min(Math.max(B,0),e.length-1),oe=e[M],K=v.current;!K||!oe||(k.current&&(window.clearTimeout(k.current),k.current=null),N.current=!0,$.current=M,K.scrollTop=wl(M),x(oe),I&&oe!==r&&n(oe))},[n,r,e]);o.useLayoutEffect(()=>{k.current&&(window.clearTimeout(k.current),k.current=null),g.current&&(window.clearTimeout(g.current),g.current=null),w(""),x(r);const B=e.indexOf(r);if(B>=0&&($.current=B),B<0||!v.current)return;const I=wl(B);v.current.scrollTop!==I&&(v.current.scrollTop=I)},[s,r,w,e]);const D=o.useCallback(()=>{g.current&&(window.clearTimeout(g.current),g.current=null)},[]),Q=o.useCallback((B,I=!1)=>{D(),w("");const M=Number(B);if(!Number.isFinite(M))return;const oe=Math.min(c,Math.max(0,M));let K=Je(oe),Y=e.indexOf(K);if(Y<0){const S=Math.min(e.length-1,Math.max(0,oe-(c===12?1:0)));K=e[S]??K,Y=e.indexOf(K)}Y>=0&&Z(Y),I&&(b==null||b())},[D,c,b,Z,w,e]),j=o.useCallback(B=>{const I=Math.floor(c/10),M=A.current;if(M===""){if(B>I){Q(String(B),!0);return}const K=String(B);w(K),g.current=window.setTimeout(()=>{Q(A.current,!0)},1200);return}D();const oe=+`${M}${B}`;oe<=c?Q(String(oe),!0):Q(String(B),!0)},[D,Q,c,w]),se=o.useCallback(B=>{D(),w(""),Z($.current+B)},[D,Z,w]),te=B=>{if(d){B.key==="a"||B.key==="A"?(B.preventDefault(),n("AM"),b==null||b()):B.key==="p"||B.key==="P"?(B.preventDefault(),n("PM"),b==null||b()):B.key==="ArrowUp"||B.key==="ArrowDown"?(B.preventDefault(),n(r==="AM"?"PM":"AM")):B.key==="Tab"&&(B.preventDefault(),B.shiftKey?f==null||f():b==null||b());return}if(/^\d$/.test(B.key)){B.preventDefault(),j(Number(B.key));return}B.key==="ArrowUp"?(B.preventDefault(),se(-1)):B.key==="ArrowDown"?(B.preventDefault(),se(1)):B.key==="Tab"&&(B.preventDefault(),D(),A.current!==""&&Q(A.current,!1),B.shiftKey?f==null||f():b==null||b())},ee=o.useCallback(()=>{const B=a.current,I=v.current;I&&B===a.current&&Z(Nl(I.scrollTop))},[Z,a]),U=()=>{if(A.current!=="")return;if(N.current){N.current=!1;const I=X();x(I);const M=e.indexOf(I);M>=0&&($.current=M);return}x(X()),k.current&&window.clearTimeout(k.current);const B=a.current;k.current=window.setTimeout(()=>{B===a.current&&ee()},100)},J="absolute left-0 right-0 z-40 flex items-center justify-center border-0 bg-transparent p-0 transition-opacity duration-150 hover:opacity-80 focus:outline-none",ce=ht*po,C=ce+zt*2,_=y!==""?y:null,ae=_!==null;return t.jsxs("div",{ref:h,role:"spinbutton",tabIndex:u?0:-1,"aria-label":i,"aria-valuetext":_??r,"aria-valuenow":d?void 0:Number(r),onFocus:m,onMouseDown:()=>m==null?void 0:m(),onKeyDown:te,onBlur:()=>{D(),A.current!==""&&Q(A.current,!1)},className:"relative shrink-0 rounded-lg outline-none",style:{width:l,height:C,boxShadow:u?"0 0 0 2px color-mix(in srgb, var(--primary) 35%, transparent)":"none"},children:[t.jsx("button",{type:"button","aria-label":"Valor anterior",className:J,style:{top:0,height:zt,color:"var(--text-muted)",opacity:.35},onClick:()=>se(-1),children:t.jsx(q.HiChevronUp,{className:"h-3.5 w-3.5"})}),t.jsx("div",{ref:v,className:"absolute inset-x-0 overflow-y-auto [scrollbar-width:none] [-ms-overflow-style:none] [&::-webkit-scrollbar]:hidden",style:{top:zt,height:ce,scrollSnapType:"y mandatory",scrollBehavior:"auto"},onScroll:U,onMouseUp:ee,onTouchEnd:ee,children:W.map((B,I)=>{const M=B!==""&&B===T;return t.jsx("button",{type:"button",tabIndex:-1,disabled:!B,onClick:()=>{if(!B)return;const oe=e.indexOf(B);oe>=0&&Z(oe)},className:"flex w-full items-center justify-center tabular-nums leading-none disabled:cursor-default",style:{height:ht,scrollSnapAlign:"center",color:M?"var(--text-main)":"var(--text-muted)",fontSize:M?16:14,fontWeight:M?600:400,opacity:B?ae?M?0:.35:M?1:.35:0},children:B},`wheel-${I}-${B}`)})}),_!==null?t.jsx("div",{className:"pointer-events-none absolute inset-x-0 z-50 flex items-center justify-center tabular-nums font-semibold leading-none",style:{top:zt+ce/2-ht/2,height:ht,color:"var(--text-main)",fontSize:16,background:"var(--bg-card)"},children:_}):null,t.jsx("button",{type:"button","aria-label":"Valor siguiente",className:J,style:{bottom:0,height:zt,color:"var(--text-muted)",opacity:.35},onClick:()=>se(1),children:t.jsx(q.HiChevronDown,{className:"h-3.5 w-3.5"})})]})}function kl(){return t.jsx("span",{className:"flex shrink-0 items-center justify-center self-center text-base font-medium tabular-nums leading-none",style:{color:"var(--text-muted)",height:ht,width:14,opacity:.45},"aria-hidden":!0,children:":"})}function Sl({value:e,onChange:r,use12Hour:n,hour12:a,showSeconds:s=!1,title:l="Seleccionar hora",variant:i="panel",onCancel:c,onConfirm:d,className:u=""}){const m=i==="popover",b=m||!d,f=uf({use12Hour:n,hour12:a}),h=o.useRef(e),v=bo(e,Mr()),k=Kn(v),[g,A]=o.useState(Je(f?k.hour12:v.hour24)),[$,N]=o.useState(Je(v.minute)),[T,x]=o.useState(Je(v.second)),[y,L]=o.useState(k.meridiem),[w,W]=o.useState(0),X=o.useRef(0),Z=o.useRef(!1),D=o.useRef({hour:null,minute:null,second:null,meridiem:null}),[Q,j]=o.useState("hour"),se=o.useMemo(()=>{const ie=["hour","minute"];return s&&ie.push("second"),f&&ie.push("meridiem"),ie},[f,s]),te=o.useCallback(ie=>{j(ge=>{const Me=se.indexOf(ge);return se[(Me+ie+se.length)%se.length]})},[se]);o.useEffect(()=>{var ie;(ie=D.current[Q])==null||ie.focus()},[Q]),o.useEffect(()=>{var ie;j("hour"),(ie=D.current.hour)==null||ie.focus()},[]),o.useEffect(()=>{if(e===h.current)return;h.current=e;const ie=bo(e,Mr()),ge=Kn(ie);A(Je(f?ge.hour12:ie.hour24)),N(Je(ie.minute)),x(Je(ie.second)),L(ge.meridiem)},[f,e]);const ee=o.useMemo(()=>(f?mo(1,12):mo(0,23)).map(ie=>Je(ie)),[f]),U=o.useMemo(()=>mo(0,59).map(ie=>Je(ie)),[]),J=U,ce=o.useMemo(()=>["AM","PM"],[]),C=o.useCallback(()=>f?on({hour12:Number(g),minute:Number($),second:Number(T),meridiem:y}):{hour24:Number(g),minute:Number($),second:Number(T)},[g,f,y,$,T]),_=o.useCallback(ie=>{if(Z.current)return;const ge=an(ie,s);h.current=ge,r(ge)},[r,s]),ae=o.useCallback(()=>{_(C())},[C,_]),B=ie=>{A(ie),b&&_(f?on({hour12:Number(ie),minute:Number($),second:Number(T),meridiem:y}):{hour24:Number(ie),minute:Number($),second:Number(T)})},I=ie=>{N(ie),b&&_(f?on({hour12:Number(g),minute:Number(ie),second:Number(T),meridiem:y}):{hour24:Number(g),minute:Number(ie),second:Number(T)})},M=ie=>{x(ie),b&&_(f?on({hour12:Number(g),minute:Number($),second:Number(ie),meridiem:y}):{hour24:Number(g),minute:Number($),second:Number(ie)})},oe=ie=>{L(ie),b&&_(on({hour12:Number(g),minute:Number($),second:Number(T),meridiem:ie}))},K=o.useCallback(()=>(X.current+=1,W(X.current),X.current),[]),Y=o.useCallback(ie=>{const ge=Kn(ie),Me=an(ie,s);h.current=Me,A(Je(f?ge.hour12:ie.hour24)),N(Je(ie.minute)),x(Je(ie.second)),L(ge.meridiem),r(Me)},[f,r,s]),S=()=>{Z.current=!0,K(),Y(Mr()),queueMicrotask(()=>{const ie=Mr();an(ie,s)!==h.current&&(K(),Y(ie)),Z.current=!1})},H=()=>{ae(),d==null||d()},O=ht*po,re=O+zt*2,z=zt+O/2-ht/2,de=t.jsx("div",{className:"relative px-4 py-2",children:t.jsxs("div",{className:"relative mx-auto",style:{height:re,maxWidth:"100%"},children:[t.jsx("div",{className:"pointer-events-none absolute inset-x-1 z-10 rounded-xl",style:{top:z,height:ht,background:"color-mix(in srgb, var(--primary) 10%, var(--bg-input))",border:"1px solid color-mix(in srgb, var(--primary) 22%, transparent)"}}),t.jsx("div",{className:"pointer-events-none absolute inset-x-0 z-20",style:{top:zt,height:ht*1.35,background:"linear-gradient(to bottom, var(--bg-card) 40%, transparent 100%)"}}),t.jsx("div",{className:"pointer-events-none absolute inset-x-0 z-20",style:{bottom:zt,height:ht*1.35,background:"linear-gradient(to top, var(--bg-card) 40%, transparent 100%)"}}),t.jsxs("div",{className:"relative z-30 flex h-full items-center justify-center gap-1",children:[t.jsx(Gn,{syncEpochRef:X,forceSyncAt:w,values:ee,selected:g,onSelect:B,label:"Horas",maxNumeric:f?12:23,isFocused:Q==="hour",onFocus:()=>j("hour"),onAdvance:()=>te(1),onBack:()=>te(-1),setColumnRef:ie=>{D.current.hour=ie}}),t.jsx(kl,{}),t.jsx(Gn,{syncEpochRef:X,forceSyncAt:w,values:U,selected:$,onSelect:I,label:"Minutos",maxNumeric:59,isFocused:Q==="minute",onFocus:()=>j("minute"),onAdvance:()=>te(1),onBack:()=>te(-1),setColumnRef:ie=>{D.current.minute=ie}}),s?t.jsxs(t.Fragment,{children:[t.jsx(kl,{}),t.jsx(Gn,{syncEpochRef:X,forceSyncAt:w,values:J,selected:T,onSelect:M,label:"Segundos",maxNumeric:59,isFocused:Q==="second",onFocus:()=>j("second"),onAdvance:()=>te(1),onBack:()=>te(-1),setColumnRef:ie=>{D.current.second=ie}})]}):null,f?t.jsx("div",{className:"ml-3 shrink-0 pl-1",children:t.jsx(Gn,{syncEpochRef:X,forceSyncAt:w,values:ce,selected:y,onSelect:ie=>oe(ie),width:df,label:"AM o PM",isMeridiem:!0,isFocused:Q==="meridiem",onFocus:()=>j("meridiem"),onAdvance:()=>te(1),onBack:()=>te(-1),setColumnRef:ie=>{D.current.meridiem=ie}})}):null]})]})}),he=t.jsxs("div",{className:`flex items-center ${m?"justify-center px-3 py-2":"justify-between gap-2 px-3 py-2.5"}`,style:{borderTop:m?"none":"1px solid color-mix(in srgb, var(--border) 80%, transparent)"},children:[t.jsx(Ue,{variant:"ghost",size:"sm",onClick:S,className:m?"text-xs":void 0,children:"Ahora"}),!m&&(c||d)?t.jsxs("div",{className:"flex items-center gap-2",children:[c?t.jsx(Ue,{variant:"ghost",size:"sm",onClick:c,children:"Cancelar"}):null,d?t.jsx(Ue,{variant:"primary",size:"sm",onClick:H,children:"Listo"}):null]}):null]});return t.jsxs("div",{className:`overflow-hidden ${u}`,style:{borderRadius:m?12:14,border:m?"1px solid color-mix(in srgb, var(--border) 85%, transparent)":"1px solid var(--border)",background:"var(--bg-card)",boxShadow:m?"0 12px 40px rgba(15, 23, 42, 0.14), 0 2px 8px rgba(15, 23, 42, 0.06)":"0 1px 3px rgba(15, 23, 42, 0.06)",minWidth:f?s?300:260:s?252:212},children:[!m&&l?t.jsx("div",{className:"border-b px-3 py-2.5",style:{borderColor:"color-mix(in srgb, var(--border) 80%, transparent)"},children:t.jsx("h3",{className:"text-sm font-semibold",style:{color:"var(--text-main)"},children:l})}):null,de,he]})}function ff(e){return e.use12Hour??e.hour12??!1}function bf({label:e,value:r,onChange:n,use12Hour:a,hour12:s,showSeconds:l=!1,title:i="Seleccionar hora",placeholder:c="Seleccionar hora",disabled:d=!1,displayMode:u="popover",required:m,error:b,helperText:f,helperDisplay:h,className:v,contentClassName:k,className:g=""}){const A=u==="popover",[$,N]=o.useState(!1),T=o.useRef(null),[x,y]=o.useState({horizontal:"left",vertical:"bottom"}),L=ff({use12Hour:a,hour12:s}),w=o.useMemo(()=>r?sf(r,{use12Hour:L,showSeconds:l}):"",[L,l,r]);o.useEffect(()=>{if(!A||!$||!T.current)return;const Z=T.current.getBoundingClientRect(),D=8,Q=L?l?300:260:l?252:212,j=276,se=Z.left+Q>window.innerWidth-D,te=Z.right-Q>=D,ee=Z.bottom+8+j>window.innerHeight-D,U=Z.top-8-j>=D;y({horizontal:se&&te?"right":"left",vertical:ee&&U?"top":"bottom"})},[L,A,$,l]),o.useEffect(()=>{if(!A||!$)return;function Z(Q){T.current&&(T.current.contains(Q.target)||N(!1))}function D(Q){Q.key==="Escape"&&N(!1)}return document.addEventListener("mousedown",Z),document.addEventListener("keydown",D),()=>{document.removeEventListener("mousedown",Z),document.removeEventListener("keydown",D)}},[A,$]);const W=t.jsxs("button",{type:"button",disabled:d,onClick:()=>{d||N(Z=>!Z)},className:`flex h-10 w-full items-center justify-between gap-2 rounded-lg border px-2.5 text-sm transition-all duration-150 focus:outline-none disabled:cursor-not-allowed disabled:opacity-60 ${g}`,style:{background:"var(--bg-input)",borderColor:b?"var(--danger)":$?"var(--primary)":"var(--border)",color:w?"var(--text-main)":"var(--text-muted)",boxShadow:$?"0 0 0 3px color-mix(in srgb, var(--primary) 14%, transparent)":"none"},children:[t.jsxs("span",{className:"inline-flex min-w-0 items-center gap-2",children:[t.jsx(q.HiClock,{className:"h-4 w-4 shrink-0 text-[var(--text-muted)]"}),t.jsx("span",{className:"truncate",children:w||c})]}),A?t.jsx(q.HiChevronDown,{className:`h-4 w-4 shrink-0 text-[var(--text-muted)] transition-transform duration-150 ${$?"rotate-180":""}`}):null]}),X=t.jsx(Sl,{variant:A?"popover":"panel",value:r||lf(l),onChange:n,use12Hour:L,showSeconds:l,title:i,onClose:()=>N(!1)});return t.jsx(In,{label:e,required:m,error:b,helperText:f,helperDisplay:h,className:v,contentClassName:k,children:A?t.jsxs("div",{ref:T,className:"relative w-full",children:[W,$?t.jsx("div",{className:"absolute z-50",style:{...x.horizontal==="left"?{left:0}:{right:0},...x.vertical==="bottom"?{top:"calc(100% + 6px)"}:{bottom:"calc(100% + 6px)"}},children:X}):null]}):t.jsxs("div",{className:"space-y-2",children:[W,$?X:null]})})}const mf={xs:{width:28,height:16,thumb:12,padding:2},sm:{width:36,height:20,thumb:16,padding:2}};function pf({checked:e,disabled:r,onCheckedChange:n,size:a="sm",className:s="",...l}){const i=mf[a],c=e?i.width-i.thumb-i.padding*2:0;return t.jsx("button",{...l,type:"button",role:"switch","aria-checked":e,disabled:r,onClick:()=>!r&&n(!e),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:i.width,height:i.height,background:e?"color-mix(in srgb, var(--primary) 85%, transparent)":"var(--bg-input)",border:e?"1px solid color-mix(in srgb, var(--primary) 55%, transparent)":"1px solid var(--border)"},children:t.jsx("span",{className:"absolute inline-block rounded-full transition-transform",style:{width:i.thumb,height:i.thumb,left:i.padding,top:"50%",transform:`translate(${c}px, -50%)`,background:e?"var(--primary-fg)":"var(--text-muted)"}})})}const Cl=[".sidebar-scroll",".app-scroll",".showcase-nav-scroll","[data-overlay-scroll='true']"].join(","),hf=[":scope > [data-overlayscrollbars-contents]",":scope > .sidebar-scroll-body",":scope > .showcase-nav-scroll-body",":scope > .app-scroll-body"].join(", ");function gf(e){if(!(e instanceof HTMLElement)||e.dataset.overlayScroll==="false"||e.matches("[data-overlayscrollbars]")||e.closest("[data-overlayscrollbars]")||e.matches("textarea,input,select,[contenteditable='true']"))return!1;const r=window.getComputedStyle(e);return!(![r.overflow,r.overflowX,r.overflowY].join(" ").match(/auto|scroll/)||e.clientWidth===0&&e.clientHeight===0)}function El(e){return e.classList.contains("sidebar-scroll")||e.classList.contains("showcase-nav-scroll")}function Ml(e){El(e)&&e.querySelectorAll(".os-scrollbar-horizontal").forEach(r=>{r.style.display="none",r.style.height="0",r.style.pointerEvents="none"})}function vf(e){const r=e.querySelector(hf);return r instanceof HTMLElement?r:null}function Tl(){return o.useEffect(()=>{const e=new WeakMap;let r=0;const n=()=>{r=0,document.querySelectorAll(Cl).forEach(l=>{if(!(l instanceof HTMLElement))return;if(Ea.OverlayScrollbars(l)){Ml(l);return}if(!gf(l))return;const c={overflow:El(l)?{x:"hidden",y:"scroll"}:void 0,scrollbars:{autoHide:"leave",autoHideDelay:180}},d=vf(l),u=d?Ea.OverlayScrollbars({target:l,elements:{viewport:d}},c):Ea.OverlayScrollbars(l,c);Ml(l),e.set(l,u)})},a=()=>{r||(r=window.requestAnimationFrame(n))};n();const s=new MutationObserver(a);return s.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["class","data-overlay-scroll"]}),window.addEventListener("resize",a),()=>{r&&window.cancelAnimationFrame(r),s.disconnect(),window.removeEventListener("resize",a),document.querySelectorAll(Cl).forEach(l=>{var i;l instanceof HTMLElement&&((i=e.get(l))==null||i.destroy())})}},[]),null}function Zt(e){const r=e.trim();return!r||r==="/"||r==="/."?"":(r.startsWith("/")?r:`/${r}`).replace(/\/+$/,"")}function $l(e){try{const r=new URL(e);return Zt(r.pathname)}catch{return""}}function yf(e){const r=Zt(e);if(!r)return"";const n=r.match(/^\/apps\/[^/]+/i);if(n)return Zt(n[0]);const a=r.split("/").filter(Boolean);return a.length===0?"":a.length>=2&&a[0].toLowerCase()==="apps"?Zt(`/${a[0]}/${a[1]}`):new Set(["admin","apps","apps-list","tickets","my-tickets","projects","projects-calendars","dashboard","teams","clients","services","settings","profile","messages","notifications","my-access","my-registers","my-pings","security-incidents","email-inbox","webhook-config","webphone-config","vobo","auth","api","login","forbidden","unauthorized","change-password","reset-password","chat-widget"]).has(a[0].toLowerCase())?"":Zt(`/${a[0]}`)}const ho="primeSuiteAppUrl",xf={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"}},Al={xs:20,sm:28,md:36,lg:48,xl:64},Ll=["bg-indigo-500","bg-blue-500","bg-emerald-500","bg-violet-500","bg-amber-500","bg-teal-500","bg-rose-500","bg-cyan-500"],wf={xs:"text-xs",sm:"text-sm",md:"text-base",lg:"text-lg"},Nf="bonsaif.bot",kf="Bonsaif Bot",Sf={xs:"p-0.5",sm:"p-1",md:"p-1.5",lg:"p-2",xl:"p-2.5"};function Dl(e){return typeof e=="string"?e.trim():""}function Cf(e){var s;if(e!==void 0)return Zt(e);const r=Zt(typeof process<"u"&&((s=process.env)==null?void 0:s.NEXT_PUBLIC_BASE_PATH)||"");if(r)return r;if(typeof window>"u")return"";try{const i=new URLSearchParams(window.location.search).get(ho)||"";i&&window.sessionStorage.setItem(ho,i);const c=window.sessionStorage.getItem(ho)||"",d=i||c;if(d){const u=$l(d);if(u&&!/^\/admin(\/|$)/i.test(u))return u}}catch{}const n=window.__NEXT_DATA__,a=(n==null?void 0:n.assetPrefix)||"";if(a){const l=a.startsWith("http")?$l(a):Zt(a);if(l&&!/^\/admin(\/|$)/i.test(l))return l}return yf(window.location.pathname)}function Ef(e){const r=e.split(/\s+/).map(n=>n.trim()).filter(Boolean);return r.length===0?"?":r.length===1?r[0].slice(0,1).toUpperCase():`${r[0].slice(0,1)}${r[1].slice(0,1)}`.toUpperCase()}function Mf(e){let r=0;for(const n of e)r=r*31+n.charCodeAt(0)&65535;return Ll[r%Ll.length]}function Tf(e,r){return e===Nf||r===kf}function $f(e,r){return`${e.replace(/\/$/,"")}${r}`}function Il({userId:e,username:r,name:n,size:a="md",showName:s=!1,showTooltip:l,tooltipContent:i,fallbackLabel:c="Usuario",basePath:d,wrapperClassName:u="",labelClassName:m="",labelSize:b="xs",avatarVersion:f=0,className:h="",style:v}){const[k,g]=o.useState(!1),A=typeof e=="string"&&e.trim()&&e!=="undefined"&&e!=="null"?e.trim():"";o.useEffect(()=>{g(!1)},[A,f]);const{wh:$,text:N}=xf[a],T=Dl(n)||Dl(r)||c,x=Ef(T),y=Cf(d),L=Tf(r,n),w=$f(y,"/favicon.svg"),W=o.useMemo(()=>{if(!A)return"";const j=new URLSearchParams;j.set("size",String(Al[a])),f&&j.set("v",String(f));const se=j.toString();return`${y}/api/user/avatar/${encodeURIComponent(A)}${se?`?${se}`:""}`},[f,y,A,a]),X=Al[a],Z=L?t.jsx("span",{className:`${$} ${Sf[a]} 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 ${h}`,style:v,children:t.jsx("img",{src:w,alt:T,width:X,height:X,className:"h-full w-full object-contain"})}):W&&!k?t.jsx("img",{src:W,alt:T,width:X,height:X,className:`${$} rounded-full object-cover flex-shrink-0 ${h}`,style:v,loading:"lazy",referrerPolicy:"no-referrer",onError:()=>g(!0)},`${A}-${f}`):t.jsx("span",{className:`${$} ${Mf(T)} ${N} rounded-full flex items-center justify-center font-black text-white uppercase flex-shrink-0 ${h}`,style:v,title:T,children:x});if(s)return t.jsxs("span",{className:`inline-flex min-w-0 items-center gap-2 ${u}`,children:[Z,t.jsx("span",{className:`min-w-0 truncate ${wf[b]} font-medium text-[var(--text-main)] ${m}`,title:T,children:T})]});const D=l??!0,Q=i??T;return D&&Q?t.jsx(Yt,{as:"span",content:Q,className:`inline-flex flex-shrink-0 ${u}`,children:Z}):Z}function Af({href:e,className:r,children:n}){return t.jsx("a",{href:e,className:r,children:n})}function Lf(e){return e.reduce((r,n)=>{const a=n.section??"Principal";return r[a]=[...r[a]??[],n],r},{})}function Ol({children:e,navItems:r=[],currentPath:n=typeof window>"u"?"/":window.location.pathname,user:a,appName:s="Bonsaif",appLogo:l,header:i,footer:c,onLogout:d,LinkComponent:u=Af}){const[m,b]=o.useState(!1),f=Lf(r);return t.jsxs("div",{className:"min-h-screen bg-[var(--bg-main)] text-[var(--text-main)]",children:[t.jsx(Tl,{}),t.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:()=>b(!0),children:t.jsx(q.HiBars3,{className:"h-5 w-5"})}),m&&t.jsx("button",{type:"button","aria-label":"Cerrar navegación",className:"fixed inset-0 z-40 bg-black/45 lg:hidden",onClick:()=>b(!1)}),t.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 ${m?"translate-x-0":"-translate-x-full"}`,children:[t.jsxs("div",{className:"flex h-16 items-center gap-3 border-b border-white/10 px-4",children:[t.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg bg-white/10 text-white",children:l??t.jsx(q.HiHome,{className:"h-5 w-5"})}),t.jsx("div",{className:"min-w-0 flex-1 truncate text-sm font-semibold",children:s}),t.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:()=>b(!1),children:t.jsx(q.HiXMark,{className:"h-5 w-5"})})]}),t.jsx("nav",{className:"sidebar-scroll min-h-0 flex-1 overflow-y-auto px-3 py-4","data-overlay-scroll":"true",children:t.jsx("div",{className:"sidebar-scroll-body",children:Object.entries(f).map(([h,v])=>t.jsxs("div",{className:"mb-5",children:[t.jsxs("div",{className:"mb-2 flex items-center gap-2 px-2 text-[11px] font-semibold uppercase tracking-wide text-white/35",children:[t.jsx(q.HiChevronDown,{className:"h-3.5 w-3.5"}),h]}),t.jsx("div",{className:"space-y-1",children:v.map(k=>{const g=n===k.href||n.startsWith(`${k.href}/`);return t.jsxs(u,{href:k.href,className:`flex min-w-0 items-center gap-2 rounded-md px-2 py-2 text-sm transition-colors ${g?"bg-white/10 text-white":"text-white/55 hover:bg-white/[0.06] hover:text-white/85"}`,children:[t.jsx("span",{className:"flex h-5 w-5 flex-shrink-0 items-center justify-center",children:k.icon??t.jsx(q.HiHome,{className:"h-4 w-4"})}),t.jsx("span",{className:"truncate",children:k.label})]},k.href)})})]},h))})}),t.jsxs("div",{className:"border-t border-white/10 p-3",children:[a&&t.jsxs("div",{className:"mb-3 flex min-w-0 items-center gap-3 rounded-lg bg-white/[0.04] p-2",children:[t.jsx(Il,{name:a.initials??a.name??a.email??"Usuario",size:"md"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"truncate text-sm font-medium text-white",children:a.name??"Usuario"}),a.email&&t.jsx("div",{className:"truncate text-xs text-white/45",children:a.email})]})]}),d&&t.jsxs(Ue,{variant:"ghost",className:"w-full justify-start text-white hover:bg-white/10",onClick:d,children:[t.jsx(q.HiArrowRightOnRectangle,{className:"h-4 w-4"})," Salir"]}),c]})]}),t.jsxs("div",{className:"min-h-screen lg:pl-72",children:[i,t.jsx("main",{className:"min-h-screen",children:e})]})]})}const Hl="bonsaif-ui:prime-auth-sso",Df={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"},go={dashboard:t.jsx(q.HiChartBar,{className:"h-5 w-5"}),tickets:t.jsx(q.HiTicket,{className:"h-5 w-5"}),teams:t.jsx(q.HiUsers,{className:"h-5 w-5"}),projects:t.jsx(q.HiRectangleGroup,{className:"h-5 w-5"}),clients:t.jsx(q.HiBuildingOffice2,{className:"h-5 w-5"}),surveys:t.jsx(q.HiClipboardDocumentList,{className:"h-5 w-5"}),profile:t.jsx(q.HiUser,{className:"h-5 w-5"}),settings:t.jsx(q.HiCog6Tooth,{className:"h-5 w-5"}),notifications:t.jsx(q.HiBell,{className:"h-5 w-5"}),changelog:t.jsx(q.HiDocumentText,{className:"h-5 w-5"}),admin:t.jsx(q.HiShieldCheck,{className:"h-5 w-5"}),users:t.jsx(q.HiUsers,{className:"h-5 w-5"}),roles:t.jsx(q.HiShieldCheck,{className:"h-5 w-5"}),menus:t.jsx(q.HiCog6Tooth,{className:"h-5 w-5"}),guards:t.jsx(q.HiCalendarDays,{className:"h-5 w-5"}),vacations:t.jsx(q.HiCalendarDays,{className:"h-5 w-5"}),audit:t.jsx(q.HiListBullet,{className:"h-5 w-5"}),positions:t.jsx(q.HiBriefcase,{className:"h-5 w-5"}),ranks:t.jsx(q.HiListBullet,{className:"h-5 w-5"}),"email-inbox":t.jsx(q.HiInbox,{className:"h-5 w-5"}),"security-incidents":t.jsx(q.HiShieldCheck,{className:"h-5 w-5"})};function If(e){return e.split("-").map(r=>r.charAt(0).toUpperCase()+r.slice(1)).join(" ")}function Of(e){return/^\d+$/.test(e)||/^[a-f0-9]{8,}$/i.test(e)}function Hf(e){const r=e.split("/").filter(Boolean);if(r.length===0||r.length===1&&r[0]==="dashboard")return[];const n=decodeURIComponent(r[r.length-1]),a=r.length>1?decodeURIComponent(r[r.length-2]):void 0,s=Of(n)&&a?a:n,l=Df[s]??If(s);return[{label:"Inicio",href:"/"},{label:l}]}function vo(e){return(e==null?void 0:e.querySelector(":scope > .os-viewport"))??(e==null?void 0:e.querySelector(":scope > [data-overlayscrollbars-viewport]"))}function Bf(e){const r=e.split("/").filter(Boolean),n=r[r.length-1];if(!n)return t.jsx(q.HiHome,{className:"h-5 w-5"});if(go[n])return go[n];const a=r.length>1?r[r.length-2]:"";return go[a]??t.jsx(q.HiHome,{className:"h-5 w-5"})}function Ff(e){return e.includes("primeAuthOrigin")||e.includes("primeAuthProjectKey")}function Bl(){if(typeof window>"u")return!1;if(Ff(window.location.href)){try{window.sessionStorage.setItem(Hl,"true")}catch{}return!0}try{return window.sessionStorage.getItem(Hl)==="true"}catch{return!1}}function Pf({title:e,subtitle:r,action:n,meta:a,icon:s,className:l="",contentClassName:i="",breadcrumbs:c,currentPath:d,showBreadcrumbs:u=!0,contained:m=!1}){const b=o.useRef(null),[f,h]=o.useState(!1),[v,k]=o.useState(d??"/"),[g,A]=o.useState(()=>Bl()),[$,N]=o.useState(null),T=d??v,x=c??Hf(T),y=s??Bf(T),L=u&&!g&&x.length>1,w=!L;o.useEffect(()=>{d||k(window.location.pathname)},[d]),o.useEffect(()=>{A(Bl())},[]),o.useEffect(()=>{if(m){h(!1);return}let X=null,Z=0,D=0;const Q=()=>{const te=b.current,ee=document.querySelector("[data-app-scroll='true']");return(te==null?void 0:te.closest(".os-viewport"))??(te==null?void 0:te.closest("[data-overlayscrollbars-viewport]"))??vo(ee)??ee??window},j=()=>{const te=X&&X!==window?X.scrollTop:window.scrollY;h(ee=>ee?te>24:te>72)},se=()=>{X==null||X.removeEventListener("scroll",j),X=Q(),X.addEventListener("scroll",j,{passive:!0}),j()};return se(),Z=window.requestAnimationFrame(se),D=window.setTimeout(se,120),()=>{window.cancelAnimationFrame(Z),window.clearTimeout(D),X==null||X.removeEventListener("scroll",j)}},[m]),o.useEffect(()=>{if(m){N(null);return}let X=0;const Z=[],D=()=>{const J=b.current,ce=J==null?void 0:J.parentElement,C=document.querySelector("[data-app-scroll='true']"),_=vo(C)??C;if(!J||!ce||!_){N(null);return}const ae=ce.getBoundingClientRect(),B=window.getComputedStyle(ce),I=_.getBoundingClientRect(),M=_ instanceof HTMLElement&&_.clientWidth>0?_.clientWidth:I.width,oe=ae.left+parseFloat(B.paddingLeft||"0"),K={marginLeft:Math.round(I.left-oe),width:Math.round(M)};N(Y=>Y&&Y.marginLeft===K.marginLeft&&Y.width===K.width?Y:K)},Q=()=>{window.cancelAnimationFrame(X),X=window.requestAnimationFrame(D)};Q(),window.addEventListener("resize",Q);const j=new ResizeObserver(Q),se=b.current,te=se==null?void 0:se.parentElement,ee=document.querySelector("[data-app-scroll='true']"),U=vo(ee)??ee;return[te,ee,U].forEach(J=>{J&&j.observe(J)}),Z.push(window.setTimeout(Q,120)),Z.push(window.setTimeout(Q,280)),()=>{window.cancelAnimationFrame(X),window.removeEventListener("resize",Q),j.disconnect(),Z.forEach(J=>window.clearTimeout(J))}},[m]);const W={...$?{marginLeft:$.marginLeft,width:$.width}:null,"--page-header-control-height":f?"34px":"40px","--page-header-control-padding-x":f?"10px":"14px","--page-header-control-icon-left":f?"10px":"12px",background:m?"var(--bg-card)":f?"color-mix(in srgb, var(--bg-main) 82%, transparent)":"color-mix(in srgb, var(--bg-main) 58%, transparent)",backdropFilter:"saturate(1.25) blur(18px)",WebkitBackdropFilter:"saturate(1.25) blur(18px)",borderBottom:m||f?"1px solid var(--border)":"1px solid transparent",boxShadow:f?"0 10px 28px rgba(12, 54, 53, 0.12)":"none"};return t.jsx("div",{ref:b,"data-page-header":"true","data-compact":f?"true":"false",className:`sticky top-0 z-30 overflow-visible py-0 transition-[background-color,box-shadow,border-color] duration-300 ease-out ${m?"mb-0 flex-shrink-0":"mb-4 sm:mb-0"} ${l}`,style:W,children:t.jsxs("div",{className:`flex flex-wrap items-center justify-between transition-[gap,min-height,padding] duration-300 ease-out ${f?"min-h-8 gap-1.5 px-3 py-0 sm:min-h-9 sm:gap-2":w?"min-h-9 gap-2 px-4 py-0 sm:min-h-10 sm:gap-2.5":"min-h-10 gap-2.5 px-4 pt-0.5 sm:min-h-11 sm:gap-3"} ${i}`,children:[t.jsx("div",{className:`min-w-0 flex flex-1 flex-col justify-center transition-[gap,transform] duration-300 ease-out ${f||w?"gap-1":"gap-1.5 sm:gap-2"}`,children:t.jsxs("div",{className:`flex min-w-0 items-center transition-[gap,transform] duration-300 ease-out ${f||w?"gap-2":"gap-2.5 sm:gap-3"}`,children:[t.jsx("span",{className:`flex-shrink-0 transition-[color,transform,opacity] duration-300 ease-out ${f?"scale-75 opacity-80":"scale-90 opacity-100"}`,style:{color:L?"var(--text-secondary)":"var(--text-muted)"},children:y}),t.jsxs("div",{className:`flex min-w-0 flex-1 flex-wrap items-center transition-[gap] duration-300 ease-out ${f?"gap-x-2 gap-y-1":"gap-x-3 gap-y-2"}`,children:[t.jsxs("div",{className:"min-w-0 flex-shrink transition-[transform] duration-300 ease-out",children:[t.jsx("h1",{className:`truncate font-bold tracking-tight transition-[font-size,line-height,color] duration-300 ease-out ${f?"text-sm sm:text-base":"text-lg sm:text-xl"}`,style:{color:"var(--text-main)"},children:e}),r&&t.jsx("div",{"aria-hidden":f,className:`overflow-hidden text-xs transition-[max-height,opacity,transform,margin] duration-300 ease-out ${f?"mt-0 max-h-0 -translate-y-1 opacity-0":"mt-0.5 max-h-8 translate-y-0 opacity-100"}`,style:{color:"var(--text-muted)"},children:r})]}),a&&t.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 ${f?"translate-y-0 gap-1.5 opacity-95":"gap-2 opacity-100"}`,children:a})]})]})}),n&&t.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 ${f?"min-h-9 gap-1 opacity-95":"min-h-9 gap-1.5 opacity-100"}`,children:t.jsx(Wo.Provider,{value:{compact:!0,headerAction:!0},children:n})})]})})}function _f({children:e,currentPath:r=typeof window>"u"?"/":window.location.pathname,publicRoutes:n=["/","/login","/reset-password"],...a}){return n.includes(r)?t.jsx(t.Fragment,{children:e}):t.jsx(Ol,{currentPath:r,...a,children:e})}function Fl(){if(typeof window>"u")return"system";const e=localStorage.getItem("theme");return e==="light"||e==="dark"?e:e==="system"?"system":document.documentElement.classList.contains("dark")?"dark":"light"}function zf(e,r,n){try{const a=new URL(e),s=a.searchParams.get("callbackUrl");if(s){const l=new URL(s,a.origin);return l.searchParams.set("theme",r),n&&(l.searchParams.set("primeAuthOrigin",window.location.origin),l.searchParams.set("primeAuthProjectKey",n)),a.searchParams.set("callbackUrl",`${l.pathname}${l.search}${l.hash}`),a.toString()}return a.searchParams.set("theme",r),n&&(a.searchParams.set("primeAuthOrigin",window.location.origin),a.searchParams.set("primeAuthProjectKey",n)),a.toString()}catch{return e}}function Wf({name:e,src:r,projectKey:n}){const[a,s]=o.useState("system"),l=o.useRef(null);o.useEffect(()=>{s(Fl());const d=new MutationObserver(()=>s(Fl()));return d.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>d.disconnect()},[]);const i=o.useMemo(()=>zf(r,a,n),[n,r,a]),c=o.useMemo(()=>{try{return new URL(i).origin}catch{return""}},[i]);return o.useEffect(()=>{if(!n)return;const d=n;function u(m){var h,v,k;if(m.source!==((h=l.current)==null?void 0:h.contentWindow)||c&&m.origin!==c)return;if(((v=m.data)==null?void 0:v.type)==="prime-microservice:overlay"){window.dispatchEvent(new CustomEvent("prime-auth:microservice-overlay",{detail:{active:!!m.data.active}}));return}if(((k=m.data)==null?void 0:k.type)!=="prime-microservice:navigation")return;const b=m.data.path;if(!b||!b.startsWith("/")||b.startsWith("//"))return;const f=`/apps/${encodeURIComponent(d)}${b}`;`${window.location.pathname}${window.location.search}${window.location.hash}`!==f&&(window.history.replaceState(window.history.state,"",f),window.dispatchEvent(new CustomEvent("prime-auth:microservice-navigation")))}return window.addEventListener("message",u),()=>{window.removeEventListener("message",u),window.dispatchEvent(new CustomEvent("prime-auth:microservice-overlay",{detail:{active:!1}}))}},[c,n]),t.jsx("div",{className:"flex h-full min-h-screen flex-col bg-[var(--bg-main)]",children:t.jsx("iframe",{ref:l,src:i,title:e,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 jf(){const[e,r]=o.useState(""),[n,a]=o.useState(!1),[s,l]=o.useState({width:96,height:96});return o.useEffect(()=>{let i=!1;return fetch("/api/microservices/prime-suite/chat-url",{cache:"no-store"}).then(c=>c.ok?c.json():null).then(c=>{!i&&(c!=null&&c.src)&&r(c.src)}).catch(()=>{}),()=>{i=!0}},[]),o.useEffect(()=>{const i=c=>{var u;if(((u=c.data)==null?void 0:u.type)!=="prime-suite-chat:state")return;const d=!!c.data.active;a(d),l({width:Pl(c.data.width,96,720),height:Pl(c.data.height,96,560)})};return window.addEventListener("message",i),()=>window.removeEventListener("message",i)},[]),e?t.jsx("iframe",{title:"Chat Bonsaif",src:e,allow:"clipboard-write",className:"fixed bottom-0 right-0 z-[70] border-0 bg-transparent transition-[width,height] duration-200",style:{width:n?`min(${s.width}px, 100vw)`:96,height:n?`min(${s.height}px, 100vh)`:96,background:"transparent",backgroundColor:"transparent",colorScheme:"normal"}}):null}function Pl(e,r,n){const a=typeof e=="number"&&Number.isFinite(e)?e:r;return Math.max(r,Math.min(n,Math.ceil(a)))}function qf(e){const r=document.documentElement,n=new MutationObserver(e);n.observe(r,{attributes:!0,attributeFilter:["class"]});const a=window.matchMedia("(prefers-color-scheme: dark)");return a.addEventListener("change",e),()=>{n.disconnect(),a.removeEventListener("change",e)}}function Uf(){const e=localStorage.getItem("theme")||"system",r=window.matchMedia("(prefers-color-scheme: dark)").matches;return document.documentElement.classList.contains("dark")||e==="dark"||e==="system"&&r?"dark":"light"}function Vf(){return"light"}function Yf({position:e="bottom-center"}){const r=o.useSyncExternalStore(qf,Uf,Vf);return t.jsx(Ma.Toaster,{position:e,theme:r,richColors:!0,closeButton:!0})}function Xf({title:e,subtitle:r,actions:n,loading:a=!1,empty:s=!1,emptyText:l="Sin datos para mostrar",className:i="",children:c}){return t.jsxs("div",{className:`bonsaif-chart-card w-full overflow-visible ${i}`,children:[(e||r||n)&&t.jsxs("div",{className:"bonsaif-chart-card-head",children:[t.jsx("div",{className:"bonsaif-chart-card-accent","aria-hidden":!0}),t.jsxs("div",{className:"bonsaif-chart-card-copy min-w-0",children:[e?t.jsx("div",{className:"bonsaif-chart-card-title",children:e}):null,r?t.jsx("div",{className:"bonsaif-chart-card-subtitle",children:r}):null]}),n?t.jsx("div",{className:"bonsaif-chart-card-actions shrink-0",children:n}):null]}),t.jsx("div",{className:"bonsaif-chart-card-body",children:a?t.jsx("div",{className:"flex h-48 items-center justify-center",children:t.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-2 border-t-transparent",style:{borderColor:"var(--border)",borderTopColor:"var(--primary)"},"aria-label":"Cargando"})}):s?t.jsx("div",{className:"flex h-48 items-center justify-center text-sm",style:{color:"var(--text-muted)"},children:l}):c})]})}const sn=["var(--primary)","#38bdf8","#34d399","#a78bfa","#2dd4bf","#fbbf24","#60a5fa","#94a3b8"];function _l(e,r){return e.color??sn[r%sn.length]}function Lt(e="primary"){switch(e){case"success":return"#34d399";case"warning":return"#fbbf24";case"danger":return"#f87171";case"neutral":return"var(--text-muted)";default:return"var(--primary)"}}const gt=e=>{if(!Number.isFinite(e))return"—";const r=Math.abs(e);return r>=1e9?`${(e/1e9).toFixed(1).replace(/\.0$/,"")}B`:r>=1e6?`${(e/1e6).toFixed(1).replace(/\.0$/,"")}M`:r>=1e4?`${(e/1e3).toFixed(1).replace(/\.0$/,"")}k`:e.toLocaleString(void 0,{maximumFractionDigits:2})};function Tr(e){if(e==null||e==="")return null;const r=typeof e=="number"?e:Number(e);return Number.isFinite(r)?r:null}const yo={warning:70,danger:90};function Zn(e,r=yo){const n=r.warning??yo.warning,a=r.danger??yo.danger;return e>=a?"danger":e>=n?"warning":e<=0?"primary":"success"}function ln(e,r){return Lt(Zn(e,r))}function $r(e,r=0){return Number.isFinite(e)?`${e.toFixed(r)}%`:"—"}function Ar(e,r=1){if(!Number.isFinite(e))return"—";const n=e<0?"-":"",a=Math.abs(e);if(a<1024)return`${n}${Math.round(a)} B`;const s=["KB","MB","GB","TB","PB"];let l=a/1024,i=0;for(;l>=1024&&i<s.length-1;)l/=1024,i+=1;const c=l>=100?l.toFixed(0):l.toFixed(r);return`${n}${c.replace(/\.0$/,"")} ${s[i]}`}function zl(e,r="bytes",n=1){if(!Number.isFinite(e))return"—";const a=e<0?"-":"",s=Math.abs(e),l=r==="bits"?["b/s","Kb/s","Mb/s","Gb/s","Tb/s"]:["B/s","KB/s","MB/s","GB/s","TB/s"];if(s<1024)return`${a}${Math.round(s)} ${l[0]}`;let i=s/1024,c=1;for(;i>=1024&&c<l.length-1;)i/=1024,c+=1;const d=i>=100?i.toFixed(0):i.toFixed(n);return`${a}${d.replace(/\.0$/,"")} ${l[c]}`}function Lr(e,r){var n;for(let a=e.length-1;a>=0;a-=1){const s=Tr((n=e[a])==null?void 0:n[r]);if(s!==null)return s}return null}function vt({height:e}){return t.jsx("div",{className:"flex items-center justify-center",style:{height:e},"aria-busy":!0,children:t.jsx("div",{className:"h-7 w-7 animate-spin rounded-full border-2",style:{borderColor:"var(--border)",borderTopColor:"var(--primary)"}})})}function yt({height:e,text:r}){return t.jsx("div",{className:"flex items-center justify-center text-sm",style:{height:e,color:"var(--text-muted)"},children:r})}const Qt=680,sr="ease-out",Kf={top:18,right:8,bottom:12,left:0};function cn(e){return{...Kf,...e}}function dn(e){return e.map((r,n)=>({...r,color:_l(r,n),label:r.label??r.key}))}function Qn(e,r){return!e.length||!r.length||e.every(n=>r.every(a=>Tr(n[a.key])===null))}function xt(){return{fill:"var(--text-muted)",fontSize:10,fontWeight:500,letterSpacing:"0.02em"}}function un(){return"color-mix(in srgb, var(--border) 55%, transparent)"}function Wl(){return"color-mix(in srgb, var(--primary) 45%, var(--border))"}function Jn(){return{paddingBottom:12,paddingLeft:4,fontSize:11,fontWeight:600,letterSpacing:"0.04em",textTransform:"uppercase",color:"var(--text-muted)"}}function Gf(e,r=gt){if(e==null||e==="")return"—";const n=typeof e=="number"?e:Number(e);return Number.isFinite(n)?r(n):String(e)}function jl(e){return`bonsaif-grad-${e.replace(/[^a-zA-Z0-9_-]/g,"")}`}function Zf({active:e,label:r,payload:n,valueFormat:a=gt}){var c,d,u,m,b,f;if(!e||!(n!=null&&n.length))return null;const s=n.filter(h=>h.dataKey!=="base"&&h.name!=="base"&&h.value!==null&&h.value!==void 0);if(!s.length)return null;const l=((d=(c=s[0])==null?void 0:c.payload)==null?void 0:d.fullName)??((m=(u=s[0])==null?void 0:u.payload)==null?void 0:m.tooltipLabel)??((f=(b=s[0])==null?void 0:b.payload)==null?void 0:f.display),i=typeof l=="string"&&l.length>0?l:r;return t.jsxs("div",{className:"bonsaif-chart-tooltip-panel",children:[i!=null&&i!==""?t.jsx("div",{className:"bonsaif-chart-tooltip-label",children:String(i)}):null,t.jsx("div",{className:"bonsaif-chart-tooltip-items",children:s.map((h,v)=>{const k=h.payload,g=k&&typeof k.display=="number"?k.display:h.value;return t.jsxs("div",{className:"bonsaif-chart-tooltip-row",children:[t.jsxs("span",{className:"bonsaif-chart-tooltip-name",children:[t.jsx("span",{className:"bonsaif-chart-tooltip-swatch",style:{background:h.color??"var(--primary)"}}),h.name??h.dataKey]}),t.jsx("span",{className:"bonsaif-chart-tooltip-value",children:Gf(g,a)})]},String(h.dataKey??h.name??v))})})]})}function Dr({valueFormat:e,content:r,cursor:n,offset:a=12,wrapperStyle:s,allowEscapeViewBox:l,reverseDirection:i,...c}){return t.jsx(Se.Tooltip,{...c,cursor:n,offset:a,allowEscapeViewBox:l??{x:!1,y:!1},reverseDirection:i??{x:!1,y:!1},wrapperStyle:{outline:"none",zIndex:60,pointerEvents:"none",overflow:"visible",...s},content:r??t.jsx(Zf,{valueFormat:e})})}function ql(e,r,n){return n==null?-1:e.findIndex(a=>String(a[r])===String(n))}function Ul(e,r,n){if(n<=1)return null;const a=Math.max(0,Math.min(e,r)),s=Math.min(n-1,Math.max(e,r));return s-a<1||a===0&&s>=n-1?null:{startIndex:a,endIndex:s}}function Rn(e,r,n={}){const{zoomable:a=!1,zoomMode:s="both",brushHeight:l=28,onZoomChange:i}=n,[c,d]=o.useState(null),[u,m]=o.useState(null),b=!!a&&e.length>1,f=b&&(s==="brush"||s==="both"),h=b&&(s==="drag"||s==="both"),v=o.useCallback(Z=>{d(Z),i==null||i(Z)},[i]),k=o.useCallback(()=>{m(null),v(null)},[v]),g=!!c,A=o.useMemo(()=>!c||f?e:e.slice(c.startIndex,c.endIndex+1),[e,f,c]),$=o.useCallback((Z,D)=>{const Q=ql(e,r,Z),j=ql(e,r,D);Q<0||j<0||v(Ul(Q,j,e.length))},[v,e,r]),N=o.useCallback(Z=>{h&&((Z==null?void 0:Z.activeLabel)===void 0||(Z==null?void 0:Z.activeLabel)===null||m({leftLabel:Z.activeLabel,rightLabel:Z.activeLabel}))},[h]),T=o.useCallback(Z=>{!h||!u||(Z==null?void 0:Z.activeLabel)===void 0||(Z==null?void 0:Z.activeLabel)===null||m(D=>D&&{...D,rightLabel:Z.activeLabel})},[u,h]),x=o.useCallback(()=>{if(h){if(!u||u.rightLabel===null||u.rightLabel===void 0){m(null);return}$(u.leftLabel,u.rightLabel),m(null)}},[$,u,h]),y=o.useCallback(Z=>{if(f){if(!Z){v(null);return}v(Ul(Z.startIndex??0,Z.endIndex??e.length-1,e.length))}},[v,e.length,f]),L=h?{onMouseDown:N,onMouseMove:T,onMouseUp:x,onMouseLeave:()=>{u&&x()}}:{},w=c??{startIndex:0,endIndex:Math.max(0,e.length-1)},W=t.jsxs(t.Fragment,{children:[h&&u&&u.rightLabel!==null&&u.rightLabel!==void 0?t.jsx(Se.ReferenceArea,{x1:u.leftLabel,x2:u.rightLabel,strokeOpacity:.18,fill:"var(--primary)",fillOpacity:.12,stroke:"var(--primary)"}):null,f?t.jsx(Se.Brush,{dataKey:r,height:l,stroke:"var(--primary)",fill:"color-mix(in srgb, var(--primary) 10%, var(--bg-card))",travellerWidth:8,startIndex:w.startIndex,endIndex:w.endIndex,onChange:y,tickFormatter:Z=>String(Z)}):null]}),X=f?{bottom:Math.max(l+10,36)}:void 0;return{enabled:b,showBrush:f,showDrag:h,viewData:A,isZoomed:g,resetZoom:k,chartHandlers:L,zoomNodes:W,marginExtra:X}}function ea({visible:e,onReset:r}){return e?t.jsx("button",{type:"button",className:"bonsaif-chart-zoom-reset",onClick:r,"aria-label":"Restablecer zoom",children:"Restablecer zoom"}):null}function Qf({data:e,xKey:r,series:n,height:a=280,className:s="",loading:l=!1,emptyText:i="Sin datos para mostrar",showGrid:c=!0,showLegend:d=!0,showTooltip:u=!0,margin:m,valueFormat:b=gt,yDomain:f,ariaLabel:h="Gráfico de líneas",curve:v=!0,strokeWidth:k=2.25,zoomable:g=!1,zoomMode:A="both",brushHeight:$,onZoomChange:N}){const T=Qn(e,n),x=dn(n),y=Rn(e,r,{zoomable:g,zoomMode:A,brushHeight:$,onZoomChange:N}),L=cn({...m,...y.marginExtra});return l?t.jsx(vt,{height:a}):T?t.jsx(yt,{height:a,text:i}):t.jsxs("div",{className:`bonsaif-chart bonsaif-line-chart w-full ${s}`,role:"img","aria-label":h,style:{height:a},children:[t.jsx(ea,{visible:y.isZoomed,onReset:y.resetZoom}),t.jsx(Se.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Se.LineChart,{data:y.viewData,margin:L,...y.chartHandlers,children:[c?t.jsx(Se.CartesianGrid,{strokeDasharray:"2 8",stroke:un(),vertical:!1}):null,t.jsx(Se.XAxis,{dataKey:r,tick:xt(),tickLine:!1,axisLine:!1,padding:{left:0,right:0},interval:"preserveStartEnd",minTickGap:52,dy:6}),t.jsx(Se.YAxis,{tick:xt(),tickLine:!1,axisLine:!1,width:44,domain:f??["auto","auto"],tickFormatter:w=>b(Number(w)),dx:-2}),u?t.jsx(Dr,{valueFormat:b,cursor:{stroke:Wl(),strokeWidth:1.25,strokeDasharray:"4 4"}}):null,d?t.jsx(Se.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:Jn()}):null,x.map((w,W)=>t.jsx(Se.Line,{type:v?"monotone":"linear",dataKey:w.key,name:w.label,stroke:w.color,strokeWidth:W===0?k+.35:k,strokeOpacity:W===0?1:.88,isAnimationActive:!0,animationDuration:Qt,animationEasing:sr,dot:!1,activeDot:{r:5,strokeWidth:2,stroke:"var(--bg-card)",fill:w.color}},w.key)),y.zoomNodes]})})]})}function ta({data:e,xKey:r,series:n,height:a=280,className:s="",loading:l=!1,emptyText:i="Sin datos para mostrar",showGrid:c=!0,showLegend:d=!0,showTooltip:u=!0,margin:m,valueFormat:b=gt,yDomain:f,ariaLabel:h="Gráfico de área",stacked:v=!1,opacity:k=.22,zoomable:g=!1,zoomMode:A="both",brushHeight:$,onZoomChange:N}){const T=Qn(e,n),x=dn(n),y=Rn(e,r,{zoomable:g,zoomMode:A,brushHeight:$,onZoomChange:N}),L=cn({...m,...y.marginExtra});return l?t.jsx(vt,{height:a}):T?t.jsx(yt,{height:a,text:i}):t.jsxs("div",{className:`bonsaif-chart bonsaif-area-chart w-full ${s}`,role:"img","aria-label":h,style:{height:a},children:[t.jsx(ea,{visible:y.isZoomed,onReset:y.resetZoom}),t.jsx(Se.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Se.AreaChart,{data:y.viewData,margin:L,...y.chartHandlers,children:[t.jsx("defs",{children:x.map(w=>t.jsxs("linearGradient",{id:jl(w.key),x1:"0",y1:"0",x2:"0",y2:"1",children:[t.jsx("stop",{offset:"0%",stopColor:w.color,stopOpacity:Math.min(.55,k+.28)}),t.jsx("stop",{offset:"48%",stopColor:w.color,stopOpacity:k*.5}),t.jsx("stop",{offset:"100%",stopColor:w.color,stopOpacity:0})]},w.key))}),c?t.jsx(Se.CartesianGrid,{strokeDasharray:"2 8",stroke:un(),vertical:!1}):null,t.jsx(Se.XAxis,{dataKey:r,tick:xt(),tickLine:!1,axisLine:!1,padding:{left:0,right:0},interval:"preserveStartEnd",minTickGap:52,dy:6}),t.jsx(Se.YAxis,{tick:xt(),tickLine:!1,axisLine:!1,width:44,domain:f??["auto","auto"],tickFormatter:w=>b(Number(w)),dx:-2}),u?t.jsx(Dr,{valueFormat:b,cursor:{stroke:Wl(),strokeWidth:1.25,strokeDasharray:"4 4"}}):null,d?t.jsx(Se.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:Jn()}):null,x.map(w=>t.jsx(Se.Area,{type:"monotone",dataKey:w.key,name:w.label,stroke:w.color,fill:`url(#${jl(w.key)})`,strokeWidth:2.25,stackId:v?"stack":void 0,isAnimationActive:!0,animationDuration:Qt,animationEasing:sr,dot:!1,activeDot:{r:5,strokeWidth:2,stroke:"var(--bg-card)",fill:w.color}},w.key)),y.zoomNodes]})})]})}function Jf({data:e,xKey:r,series:n,height:a=280,className:s="",loading:l=!1,emptyText:i="Sin datos para mostrar",showGrid:c=!0,showLegend:d=!0,showTooltip:u=!0,margin:m,valueFormat:b=gt,yDomain:f,ariaLabel:h="Gráfico de barras",layout:v="vertical",mode:k="grouped",barRadius:g=6,categoryAxisWidth:A=64,zoomable:$=!1,zoomMode:N="both",brushHeight:T,onZoomChange:x}){const y=Qn(e,n),L=dn(n),w=v==="horizontal",W=Rn(e,r,{zoomable:$&&!w,zoomMode:N,brushHeight:T,onZoomChange:x}),X=cn({...m,...W.marginExtra});return l?t.jsx(vt,{height:a}):y?t.jsx(yt,{height:a,text:i}):t.jsxs("div",{className:`bonsaif-chart bonsaif-bar-chart w-full ${s}`,role:"img","aria-label":h,style:{height:a},children:[t.jsx(ea,{visible:W.isZoomed,onReset:W.resetZoom}),t.jsx(Se.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Se.BarChart,{data:W.viewData,margin:X,layout:w?"vertical":"horizontal",barCategoryGap:"34%",barGap:3,...W.chartHandlers,children:[c?t.jsx(Se.CartesianGrid,{strokeDasharray:"2 8",stroke:un(),horizontal:!w,vertical:w}):null,w?t.jsxs(t.Fragment,{children:[t.jsx(Se.XAxis,{type:"number",tick:xt(),tickLine:!1,axisLine:!1,tickFormatter:Z=>b(Number(Z)),domain:f??["auto","auto"]}),t.jsx(Se.YAxis,{type:"category",dataKey:r,tick:xt(),tickLine:!1,axisLine:!1,width:A})]}):t.jsxs(t.Fragment,{children:[t.jsx(Se.XAxis,{dataKey:r,tick:xt(),tickLine:!1,axisLine:!1,interval:"preserveStartEnd",minTickGap:36,dy:6}),t.jsx(Se.YAxis,{tick:xt(),tickLine:!1,axisLine:!1,width:44,domain:f??["auto","auto"],tickFormatter:Z=>b(Number(Z)),dx:-2})]}),u?t.jsx(Dr,{valueFormat:b,cursor:{fill:"color-mix(in srgb, var(--primary) 8%, transparent)"}}):null,d?t.jsx(Se.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:Jn()}):null,L.map((Z,D)=>t.jsx(Se.Bar,{dataKey:Z.key,name:Z.label,fill:Z.color,fillOpacity:D===0?1:.82,radius:w?[0,g,g,0]:[g,g,2,2],maxBarSize:20,stackId:k==="stacked"?"stack":void 0,isAnimationActive:!0,animationDuration:Qt,animationEasing:sr},Z.key)),W.zoomNodes]})})]})}function Rf(e){return t.jsx(Yl,{...e,variant:"pie"})}function eb(e){return t.jsx(Yl,{...e,variant:"donut",innerRadius:e.innerRadius??.62,cornerRadius:e.cornerRadius??10,padAngle:e.padAngle??2})}function Vl(e,r){return e==null||!Number.isFinite(e)?r:e>0&&e<=1?e*100:e}function Yl({data:e,nameKey:r,valueKey:n,height:a=280,className:s="",loading:l=!1,emptyText:i="Sin datos para mostrar",showLegend:c=!0,showTooltip:d=!0,valueFormat:u=gt,ariaLabel:m,innerRadius:b,outerRadius:f,colors:h=[...sn],padAngle:v,cornerRadius:k,variant:g}){const A=e.map((D,Q)=>({name:String(D[r]??""),value:Tr(D[n])??0,fill:h[Q%h.length],row:D})).filter(D=>D.value>0),$=!A.length,N=g==="donut",T=A.length,x=Vl(b,N?62:12),y=Vl(f,78),L=Math.min(v??(N?2:3),Math.max(.5,10/Math.max(1,T))),w=Math.min(k??(N?10:8),Math.max(2,36/Math.max(1,T)));if(l)return t.jsx(vt,{height:a});if($)return t.jsx(yt,{height:a,text:i});const W=A.reduce((D,Q)=>D+Q.value,0),X=c?Math.min(96,28+Math.ceil(T/3)*22):0,Z=Math.max(140,a-X);return t.jsx("div",{className:`bonsaif-chart bonsaif-${g}-chart w-full ${s}`,role:"img","aria-label":m??(g==="donut"?"Donut chart":"Pie chart"),style:{height:a},children:t.jsxs("div",{className:"bonsaif-pie-layout",children:[t.jsx("div",{className:"bonsaif-pie-plot",style:{height:Z},children:t.jsx(Se.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Se.PieChart,{margin:{top:4,right:4,bottom:4,left:4},children:[d?t.jsx(Dr,{valueFormat:u,isAnimationActive:!1}):null,t.jsx(Se.Pie,{data:A,dataKey:"value",nameKey:"name",cx:"50%",cy:"50%",innerRadius:`${x}%`,outerRadius:`${y}%`,startAngle:90,endAngle:-270,paddingAngle:L,cornerRadius:w,minAngle:T>6?3:2,stroke:"var(--bg-card)",strokeWidth:2,isAnimationActive:!0,animationDuration:Qt,animationEasing:sr,label:!1,activeShape:tb,children:A.map(D=>t.jsx(Se.Cell,{fill:D.fill},D.name))}),N?t.jsx("text",{x:"50%",y:"50%",textAnchor:"middle",dominantBaseline:"middle",fill:"var(--text-main)",fontSize:18,fontWeight:700,letterSpacing:"-0.02em",children:u(W)}):null]})})}),c?t.jsx("ul",{className:"bonsaif-pie-legend","aria-label":"Leyenda",children:A.map(D=>t.jsxs("li",{className:"bonsaif-pie-legend-item",children:[t.jsx("span",{className:"bonsaif-pie-legend-swatch",style:{background:D.fill},"aria-hidden":!0}),t.jsx("span",{className:"bonsaif-pie-legend-label",title:D.name,children:D.name}),t.jsx("span",{className:"bonsaif-pie-legend-value",children:u(D.value)})]},D.name))}):null]})})}function tb(e){const{outerRadius:r=0,...n}=e;return t.jsx(Se.Sector,{...n,outerRadius:Number(r)+4,stroke:"var(--bg-card)",strokeWidth:2})}function rb({data:e,dataKey:r,width:n="100%",height:a=36,tone:s="primary",color:l,fill:i=!0,className:c="",ariaLabel:d="Sparkline"}){const u=l??Lt(s),m=e.map(y=>Tr(y[r])).filter(y=>y!==null);if(m.length<2)return t.jsx("div",{className:c,style:{width:n,height:a,color:"var(--text-muted)"},"aria-label":d});const b=120,f=36,h=3,v=1,k=Math.min(...m),A=Math.max(...m)-k||1,$=m.map((y,L)=>{const w=v+L/(m.length-1)*(b-v*2),W=f-h-(y-k)/A*(f-h*2);return{x:w,y:W}}),N=$.map((y,L)=>`${L===0?"M":"L"}${y.x.toFixed(2)} ${y.y.toFixed(2)}`).join(" "),T=`${N} L${$[$.length-1].x.toFixed(2)} ${f} L${$[0].x.toFixed(2)} ${f} Z`,x=`bonsaif-spark-${r.replace(/[^a-zA-Z0-9_-]/g,"")}-${s}`;return t.jsx("div",{className:`bonsaif-sparkline ${c}`,style:{width:n,height:a},role:"img","aria-label":d,children:t.jsxs("svg",{width:"100%",height:"100%",viewBox:`0 0 ${b} ${f}`,preserveAspectRatio:"none",focusable:"false",children:[i?t.jsx("defs",{children:t.jsxs("linearGradient",{id:x,x1:"0",y1:"0",x2:"0",y2:"1",children:[t.jsx("stop",{offset:"0%",stopColor:u,stopOpacity:.38}),t.jsx("stop",{offset:"100%",stopColor:u,stopOpacity:0})]})}):null,i?t.jsx("path",{d:T,fill:`url(#${x})`}):null,t.jsx("path",{d:N,fill:"none",stroke:u,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",vectorEffect:"non-scaling-stroke"})]})})}function nb({data:e,xKey:r,series:n,barSeries:a,lineSeries:s,height:l=280,className:i="",loading:c=!1,emptyText:d="Sin datos para mostrar",showGrid:u=!0,showLegend:m=!0,showTooltip:b=!0,margin:f,valueFormat:h=gt,yDomain:v,ariaLabel:k="Gráfico combinado",barRadius:g=6,zoomable:A=!1,zoomMode:$="both",brushHeight:N,onZoomChange:T}){const x=a??n.slice(0,Math.max(1,n.length-1)),y=s??(n.length>1?n.slice(-1):n.length?[n[0]]:[]),L=[...x,...y.filter(j=>!x.some(se=>se.key===j.key))],w=Qn(e,L),W=dn(x),X=dn(L),Z=y.map(j=>{var te;const se=X.find(ee=>ee.key===j.key);return{...j,label:j.label??j.key,color:j.color??(se==null?void 0:se.color)??((te=X[0])==null?void 0:te.color)}}),D=Rn(e,r,{zoomable:A,zoomMode:$,brushHeight:N,onZoomChange:T}),Q=cn({...f,...D.marginExtra});return c?t.jsx(vt,{height:l}):w?t.jsx(yt,{height:l,text:d}):t.jsxs("div",{className:`bonsaif-chart bonsaif-combo-chart w-full ${i}`,role:"img","aria-label":k,style:{height:l},children:[t.jsx(ea,{visible:D.isZoomed,onReset:D.resetZoom}),t.jsx(Se.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Se.ComposedChart,{data:D.viewData,margin:Q,barCategoryGap:"34%",...D.chartHandlers,children:[u?t.jsx(Se.CartesianGrid,{strokeDasharray:"2 8",stroke:un(),vertical:!1}):null,t.jsx(Se.XAxis,{dataKey:r,tick:xt(),tickLine:!1,axisLine:!1,interval:"preserveStartEnd",minTickGap:36,dy:6}),t.jsx(Se.YAxis,{tick:xt(),tickLine:!1,axisLine:!1,width:44,domain:v??["auto","auto"],tickFormatter:j=>h(Number(j)),dx:-2}),b?t.jsx(Dr,{valueFormat:h,cursor:{fill:"color-mix(in srgb, var(--primary) 8%, transparent)"}}):null,m?t.jsx(Se.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:Jn()}):null,W.map(j=>t.jsx(Se.Bar,{dataKey:j.key,name:j.label,fill:j.color,fillOpacity:.88,radius:[g,g,2,2],maxBarSize:18,isAnimationActive:!0,animationDuration:Qt,animationEasing:sr},j.key)),Z.map(j=>t.jsx(Se.Line,{type:"monotone",dataKey:j.key,name:j.label,stroke:j.color,strokeWidth:2.5,isAnimationActive:!0,animationDuration:Qt,animationEasing:sr,dot:!1,activeDot:{r:5,strokeWidth:2,stroke:"var(--bg-card)",fill:j.color}},j.key)),D.zoomNodes]})})]})}function ab({data:e,xKey:r,valueKey:n,typeKey:a,height:s=280,className:l="",loading:i=!1,emptyText:c="Sin datos para mostrar",showGrid:d=!0,showTooltip:u=!0,margin:m,valueFormat:b=gt,ariaLabel:f="Gráfico waterfall",increaseColor:h="#34d399",decreaseColor:v="#f87171",totalColor:k="var(--primary)"}){const g=o.useMemo(()=>ob(e,{xKey:r,valueKey:n,typeKey:a,increaseColor:h,decreaseColor:v,totalColor:k}),[e,r,n,a,h,v,k]),A=!g.length,$=cn(m);return i?t.jsx(vt,{height:s}):A?t.jsx(yt,{height:s,text:c}):t.jsx("div",{className:`bonsaif-chart bonsaif-waterfall-chart w-full ${l}`,role:"img","aria-label":f,style:{height:s},children:t.jsx(Se.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Se.BarChart,{data:g,margin:$,barCategoryGap:"42%",children:[d?t.jsx(Se.CartesianGrid,{strokeDasharray:"2 8",stroke:un(),vertical:!1}):null,t.jsx(Se.XAxis,{dataKey:"label",tick:xt(),tickLine:!1,axisLine:!1,interval:0,dy:6}),t.jsx(Se.YAxis,{tick:xt(),tickLine:!1,axisLine:!1,width:44,tickFormatter:N=>b(Number(N)),dx:-2}),u?t.jsx(Dr,{valueFormat:b,cursor:{fill:"color-mix(in srgb, var(--primary) 8%, transparent)"}}):null,t.jsx(Se.Bar,{dataKey:"base",stackId:"wf",fill:"transparent",isAnimationActive:!1,legendType:"none",maxBarSize:22}),t.jsx(Se.Bar,{dataKey:"delta",name:"Valor",stackId:"wf",radius:[6,6,2,2],maxBarSize:22,isAnimationActive:!0,animationDuration:Qt,animationEasing:sr,children:g.map(N=>t.jsx(Se.Cell,{fill:N.color},N.label))})]})})})}function ob(e,r){let n=0;return e.map((a,s)=>{const l=Tr(a[r.valueKey])??0,i=r.typeKey?String(a[r.typeKey]??""):"",c=i==="total"||s===e.length-1&&i!=="increase"&&i!=="decrease";let d="increase",u=0,m=0,b=l;return c&&i==="total"?(d="total",u=0,m=Math.abs(l),b=l,n=l):c&&s===e.length-1&&!i?(d="total",u=0,m=Math.abs(n),b=n):(d=i==="decrease"||l<0?"decrease":"increase",d==="decrease"?(u=n+l,m=Math.abs(l),n=n+l):(u=n,m=Math.abs(l),n=n+l),b=l),{label:String(a[r.xKey]??""),base:u,delta:m,display:b,kind:d,color:d==="total"?r.totalColor:d==="decrease"?r.decreaseColor:r.increaseColor}})}const Xl="bonsaif-funnel-chart-keyframes",sb=`
43
45
  @keyframes bonsaif-funnel-stage-in {
44
46
  from {
45
47
  opacity: 0;
@@ -79,4 +81,4 @@ ${R}`,ne=new Blob(["\uFEFF"+O],{type:"text/csv;charset=utf-8;"}),fe=URL.createOb
79
81
  animation: none !important;
80
82
  }
81
83
  }
82
- `;function df(){if(typeof document>"u"||document.getElementById(il))return;const e=document.createElement("style");e.id=il,e.textContent=cf,document.head.appendChild(e)}function cl(e,r,n){return Math.min(n,Math.max(r,e))}function Bn(e,r,n){const a=cl(n,0,1);return`color-mix(in srgb, ${e} ${Math.round((1-a)*100)}%, ${r} ${Math.round(a*100)}%)`}function uf(e,r,n,a,o,l){const i=e.map((d,u)=>{const m=br(d[n])??0,f=String(d[r]??""),b=a?String(d[a]??"").trim():"",v=o?String(d[o]??"").trim():"";return{name:f,value:m,color:l[u%l.length],...b?{title:b}:{},...v?{description:v}:{}}}).filter(d=>d.value>0&&d.name),c=Math.max(...i.map(d=>d.value),1);return i.map(d=>({...d,pct:d.value/c}))}function ff(e,r){const n=e.length;if(n===0)return[];const a=r.gap*Math.max(0,n-1),o=(r.plotH-a)/n,l=r.maxTopW,i=r.maxTopW*r.taper;return e.map((c,d)=>{const u=n===1?0:d/n,m=n===1?1:(d+1)/n,f=l+(i-l)*u,b=l+(i-l)*m;return{...c,index:d,y:r.topY+d*(o+r.gap),h:o,topW:f,bottomW:b,cx:r.cx}})}function bf({stage:e,hovered:r,onHover:n}){const{cx:a,y:o,h:l,topW:i,bottomW:c,color:d}=e,u=a-i/2,m=a+i/2,f=a-c/2,b=a+c/2,v=o+l,x=Math.max(4,Math.min(14,l*.18)),E=Bn(d,"#000",r?.12:.22),h=Bn(d,"#fff",r?.08:0),$=Bn(d,"#fff",.22),M=[`M ${u} ${o}`,`L ${m} ${o}`,`L ${b} ${v}`,`L ${f} ${v}`,"Z"].join(" ");return t.jsxs("g",{onMouseEnter:()=>n(e.index),onMouseLeave:()=>n(null),style:{cursor:"default"},children:[t.jsx("path",{d:M,fill:E}),t.jsx("path",{d:[`M ${u} ${o}`,`L ${m} ${o}`,`L ${m} ${o+1}`,`L ${b} ${v}`,`L ${a} ${v}`,`L ${u} ${o}`,"Z"].join(" "),fill:h,opacity:.55}),t.jsx("ellipse",{cx:a,cy:o,rx:i/2,ry:x,fill:$,stroke:Bn(d,"#000",.15),strokeWidth:1}),r?t.jsx("ellipse",{cx:a,cy:o,rx:i/2,ry:x,fill:"none",stroke:"var(--text-main)",strokeOpacity:.25,strokeWidth:1.5}):null]})}function mf({data:e,nameKey:r,valueKey:n,titleKey:a,descriptionKey:o,height:l=360,className:i="",loading:c=!1,emptyText:d="Sin datos para mostrar",showTooltip:u=!0,showLabels:m=!0,showValues:f=!0,showBottomArrow:b=!0,taper:v=.42,colors:x=[...Yr],animationDuration:E=Ot,valueFormat:h=ot,ariaLabel:$="Gráfico embudo"}){const[M,y]=s.useState(null),[w,k]=s.useState(!1),N=s.useMemo(()=>uf(e,r,n,a,o,x),[e,r,n,a,o,x]),A=s.useMemo(()=>N.map(I=>`${I.name}:${I.value}`).join("|"),[N]);if(s.useEffect(()=>{if(df(),typeof window>"u")return;const I=window.matchMedia("(prefers-reduced-motion: reduce)");k(I.matches);const te=()=>k(I.matches);return I.addEventListener("change",te),()=>I.removeEventListener("change",te)},[]),c)return t.jsx(lt,{height:l});if(!N.length)return t.jsx(it,{height:l,text:d});const C=E>0&&!w,j=E,W=Math.min(90,Math.max(40,Math.round(E/8))),G=Math.round(j*.15),T=N.length*W+Math.round(j*.35),Z=N.some(I=>I.title||I.description),H=m?160:24,ae=Z?168:24,X=b?36:8,V=H+220+ae,q=l,L=18,oe=Math.max(120,q-L-X-8),B=H+110,le=ff(N,{cx:B,topY:L,plotH:oe,maxTopW:200,taper:cl(v,.2,.95),gap:10}),g=M!=null?le[M]:null,P="cubic-bezier(0.22, 1, 0.36, 1)";return t.jsxs("div",{className:`bonsaif-chart bonsaif-funnel-chart relative w-full ${i}`,role:"img","aria-label":$,style:{height:l},children:[t.jsxs("svg",{viewBox:`0 0 ${V} ${q}`,width:"100%",height:"100%",preserveAspectRatio:"xMidYMid meet",children:[m?t.jsx("line",{className:C?"bonsaif-funnel-label":void 0,style:C?{animation:`bonsaif-funnel-fade-in ${j}ms ${P} both`}:void 0,x1:H-12,y1:L,x2:H-12,y2:L+oe,stroke:"var(--border)",strokeDasharray:"3 5",strokeWidth:1}):null,le.map(I=>{const te=I.y+I.h/2,U=I.cx-I.topW/2,K=I.index*W,D=C?{animation:`bonsaif-funnel-stage-in ${j}ms ${P} ${K}ms both`}:void 0,ee=C?{animation:`bonsaif-funnel-fade-in ${Math.round(j*.85)}ms ${P} ${K+G}ms both`}:void 0;return t.jsxs("g",{children:[t.jsx("g",{className:"bonsaif-funnel-stage",style:D,children:t.jsx(bf,{stage:I,hovered:M===I.index,onHover:y})}),m?t.jsxs("g",{className:"bonsaif-funnel-label",style:ee,children:[t.jsx("line",{x1:24,y1:te,x2:H-12,y2:te,stroke:I.color,strokeOpacity:.55,strokeDasharray:"3 4",strokeWidth:1}),t.jsx("line",{x1:H-12,y1:te,x2:U-6,y2:te,stroke:I.color,strokeOpacity:.35,strokeDasharray:"3 4",strokeWidth:1}),t.jsx("text",{x:20,y:te-(f?6:0),textAnchor:"end",fill:I.color,fontSize:12,fontWeight:600,children:I.name.length>18?`${I.name.slice(0,16)}…`:I.name}),f?t.jsx("text",{x:20,y:te+10,textAnchor:"end",fill:"var(--text-muted)",fontSize:11,children:h(I.value)}):null]}):null,(I.title||I.description)&&Z?t.jsxs("g",{className:"bonsaif-funnel-anno",style:ee,children:[t.jsx("line",{x1:I.cx+I.bottomW/2+6,y1:te,x2:H+220+8,y2:te,stroke:I.color,strokeOpacity:.35,strokeDasharray:"3 4",strokeWidth:1}),I.title?t.jsx("text",{x:H+220+14,y:te-(I.description?6:0),fill:"var(--text-main)",fontSize:12,fontWeight:700,children:I.title.length>22?`${I.title.slice(0,20)}…`:I.title}):null,I.description?t.jsx("text",{x:H+220+14,y:te+(I.title?10:0),fill:"var(--text-muted)",fontSize:11,children:I.description.length>28?`${I.description.slice(0,26)}…`:I.description}):null]}):null]},`${I.name}-${I.index}`)}),b?t.jsx("g",{className:"bonsaif-funnel-arrow",transform:`translate(${B}, ${L+oe+8})`,fill:"var(--primary)",style:C?{animation:`bonsaif-funnel-arrow-in ${Math.round(j*.7)}ms ${P} ${T}ms both`}:void 0,children:t.jsx("path",{d:"M0,22 L10,8 L4,8 L4,0 L-4,0 L-4,8 L-10,8 Z"})}):null]},A),u&&g?t.jsxs("div",{className:"pointer-events-none absolute z-10 rounded-md border px-2.5 py-1.5 text-xs shadow-sm",style:{left:"50%",top:8,transform:"translateX(-50%)",background:"var(--bg-card)",borderColor:"var(--border)",color:"var(--text-main)"},children:[t.jsx("span",{className:"font-semibold",style:{color:g.color},children:g.name}),t.jsx("span",{style:{color:"var(--text-muted)"},children:" · "}),h(g.value),t.jsxs("span",{style:{color:"var(--text-muted)"},children:[" ","(",Math.round(g.pct*100),"% del top)"]})]}):null]})}const vr=135*Math.PI/180,Ka=270*Math.PI/180;function pf({value:e,min:r=0,max:n=100,height:a=180,className:o="",loading:l=!1,empty:i=!1,emptyText:c="Sin datos para mostrar",label:d,valueFormat:u=ot,tone:m="primary",color:f,thresholds:b,ariaLabel:v="Gauge",animationDuration:x=700,thickness:E=9,showScale:h=!1}){const $=s.useId().replace(/:/g,""),M=n-r||1,y=Math.min(1,Math.max(0,(e-r)/M)),[w,k]=s.useState(x>0?0:y);if(s.useEffect(()=>{if(l||i)return;if(x<=0){k(y);return}if(typeof window<"u"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches){k(y);return}let V=0,q=0;k(B=>(q=B,B));const L=performance.now(),oe=B=>{const F=Math.min(1,(B-L)/x),le=1-(1-F)**3;k(q+(y-q)*le),F<1&&(V=requestAnimationFrame(oe))};return V=requestAnimationFrame(oe),()=>cancelAnimationFrame(V)},[y,x,l,i]),l)return t.jsx(lt,{height:a});if(i)return t.jsx(it,{height:a,text:c});const N=100,A=108,C=72,j=f??hf(e,n,m,b),W=r+w*M,G=dl(N,A,C,vr,vr+Ka),T=vr+Math.max(.001,w)*Ka,Z=dl(N,A,C,vr,T),H=Fn(N,A,C,vr),ae=Fn(N,A,C,vr+Ka);return t.jsx("div",{className:`bonsaif-chart bonsaif-gauge-chart flex flex-col items-center justify-center ${o}`,style:{height:a},children:t.jsxs("svg",{viewBox:"0 0 200 168",width:"100%",height:"100%",role:"img","aria-label":v,className:"overflow-visible",children:[t.jsx("defs",{children:t.jsxs("linearGradient",{id:`bonsaif-gauge-${$}`,x1:"0",y1:"0",x2:"1",y2:"0",children:[t.jsx("stop",{offset:"0%",stopColor:j,stopOpacity:.82}),t.jsx("stop",{offset:"100%",stopColor:j,stopOpacity:1})]})}),t.jsx("path",{d:G,fill:"none",stroke:"color-mix(in srgb, var(--border) 70%, transparent)",strokeWidth:E,strokeLinecap:"butt"}),t.jsx("path",{d:Z,fill:"none",stroke:`url(#bonsaif-gauge-${$})`,strokeWidth:E,strokeLinecap:"butt",className:"bonsaif-chart-gauge-value"}),t.jsx("text",{x:N,y:A-(d?4:0),textAnchor:"middle",dominantBaseline:"middle",fill:"var(--text-main)",fontSize:28,fontWeight:700,letterSpacing:"-0.04em",className:"bonsaif-chart-gauge-label",children:u(W)}),d?t.jsx("text",{x:N,y:A+18,textAnchor:"middle",fill:"var(--text-muted)",fontSize:11,fontWeight:600,letterSpacing:"0.06em",children:d}):null,h?t.jsxs(t.Fragment,{children:[t.jsx("text",{x:H.x-2,y:H.y+E+14,textAnchor:"middle",fill:"var(--text-muted)",fontSize:10,children:u(r)}),t.jsx("text",{x:ae.x+2,y:ae.y+E+14,textAnchor:"middle",fill:"var(--text-muted)",fontSize:10,children:u(n)})]}):null]})})}function hf(e,r,n,a){if(a!=null&&a.length){const l=[...a].sort((c,d)=>c.value-d.value);let i=l[0].color;for(const c of l)e>=c.value&&(i=c.color);return i}if(n)return yt(n);const o=e/(r||1);return o>=.8?yt("success"):o>=.5?yt("warning"):yt("danger")}function Fn(e,r,n,a){return{x:e+n*Math.cos(a),y:r+n*Math.sin(a)}}function dl(e,r,n,a,o){const l=Fn(e,r,n,a),i=Fn(e,r,n,o),c=o-a,d=Math.abs(c)>Math.PI?1:0;return`M ${l.x} ${l.y} A ${n} ${n} 0 ${d} 1 ${i.x} ${i.y}`}function gf({value:e,target:r,max:n,ranges:a,height:o=72,className:l="",loading:i=!1,empty:c=!1,emptyText:d="Sin datos para mostrar",label:u,subtitle:m,valueFormat:f=ot,tone:b="primary",showScale:v=!0,showStatus:x=!0,ariaLabel:E="Bullet chart"}){if(i)return t.jsx(lt,{height:o});if(c)return t.jsx(it,{height:o,text:d});const h=n??Math.max(e,r,...(a==null?void 0:a.map(j=>j.value))??[],1)*1.05,M=[...a??[{value:h*.5,color:"color-mix(in srgb, var(--border) 72%, transparent)"},{value:h*.75,color:"color-mix(in srgb, var(--border) 48%, transparent)"},{value:h,color:"color-mix(in srgb, var(--border) 28%, transparent)"}]].sort((j,W)=>j.value-W.value),y=yt(b),w=Math.min(100,Math.max(0,e/h*100)),k=Math.min(100,Math.max(0,r/h*100)),N=e>=r,A=[0,.25,.5,.75,1].map(j=>j*h),C=t.jsxs("div",{className:"bonsaif-bullet-plot min-w-0 flex-1",children:[t.jsxs("div",{className:"bonsaif-bullet-track relative w-full",style:{height:Math.max(22,u?28:o*.42)},role:"img","aria-label":E,children:[t.jsx("div",{className:"bonsaif-bullet-ranges absolute inset-0 flex overflow-hidden",children:M.map((j,W)=>{const G=W===0?0:M[W-1].value,T=Math.max(0,(j.value-G)/h*100);return t.jsx("div",{style:{width:`${T}%`,background:j.color??`color-mix(in srgb, var(--border) ${70-W*18}%, transparent)`}},W)})}),t.jsx("div",{className:"absolute left-0 top-1/2 w-full",style:{height:"34%",transform:"translateY(-50%)"},children:t.jsx("div",{className:"bonsaif-bullet-value h-full",style:{width:`${w}%`,background:y,borderRadius:"0 999px 999px 0",boxShadow:`0 0 12px color-mix(in srgb, ${y} 35%, transparent)`}})}),t.jsx("div",{className:"bonsaif-bullet-target absolute top-1/2 z-[1]",style:{left:`${k}%`,height:"72%",width:3,transform:"translate(-50%, -50%)",background:y,borderRadius:1,boxShadow:"0 0 0 1px color-mix(in srgb, var(--bg-card) 70%, transparent)"},title:`Meta ${f(r)}`})]}),v?t.jsx("div",{className:"bonsaif-bullet-scale relative mt-1.5 h-4 w-full",children:A.map((j,W)=>{const G=j/h*100,T=W===0,Z=W===A.length-1;return t.jsxs("div",{className:"absolute top-0",style:{left:`${G}%`,transform:T?"none":Z?"translateX(-100%)":"translateX(-50%)"},children:[t.jsx("div",{className:"mx-auto h-1.5 w-px",style:{background:"color-mix(in srgb, var(--text-muted) 55%, transparent)",marginLeft:T?0:Z?"auto":void 0,marginRight:Z?0:void 0}}),t.jsx("div",{className:"bonsaif-bullet-scale-label mt-0.5 tabular-nums",style:{color:"var(--text-muted)",textAlign:T?"left":Z?"right":"center"},children:f(j)})]},j)})}):null]});return t.jsx("div",{className:`bonsaif-chart bonsaif-bullet-chart w-full ${l}`,children:u?t.jsxs("div",{className:"bonsaif-bullet-row flex flex-col gap-2 sm:flex-row sm:items-start sm:gap-4",children:[t.jsxs("div",{className:"bonsaif-bullet-label shrink-0 sm:w-[7.5rem] sm:pt-1 sm:text-right",children:[t.jsx("div",{className:"text-sm font-semibold tracking-tight",style:{color:"var(--text-main)"},children:u}),m?t.jsx("div",{className:"mt-0.5 text-[11px] leading-snug",style:{color:"var(--text-muted)"},children:m}):t.jsxs("div",{className:"mt-0.5 text-[11px] tabular-nums leading-snug",style:{color:"var(--text-muted)"},children:[t.jsx("span",{style:{color:y,fontWeight:600},children:f(e)}),t.jsxs("span",{children:[" / meta ",f(r)]})]}),x?t.jsx("div",{className:"bonsaif-bullet-status mt-1.5 inline-flex text-[10px] font-bold uppercase tracking-wide",style:{color:yt(N?"success":"warning")},children:N?"En meta":"Bajo meta"}):null]}),C]}):C})}function vf({data:e,value:r,timeKey:n="t",usageKey:a="usage",series:o,cores:l,height:i=220,className:c="",loading:d=!1,emptyText:u="Sin datos de CPU",showLegend:m=!1,showTooltip:f=!0,thresholds:b,label:v="CPU",ariaLabel:x="Uso de CPU"}){var k;const E=o??[{key:a,label:"Uso",color:Xr(r??hr(e,a)??0,b)}],h=r??hr(e,a)??hr(e,((k=E[0])==null?void 0:k.key)??a),$=!d&&(!e.length||h===null);if(d)return t.jsx(lt,{height:i});if($)return t.jsx(it,{height:i,text:u});const M=Math.min(100,Math.max(0,h??0)),y=Ln(M,b),w=Xr(M,b);return t.jsxs("div",{className:`bonsaif-chart bonsaif-cpu-chart w-full ${c}`,role:"group","aria-label":x,children:[t.jsxs("div",{className:"bonsaif-metric-head",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"bonsaif-metric-kicker",children:[v,l!=null?t.jsxs("span",{className:"ml-1.5 normal-case tracking-normal opacity-80",children:["· ",l," ",l===1?"core":"cores"]}):null]}),t.jsx("div",{className:"bonsaif-metric-value",style:{color:w},children:mr(M,M<10?1:0)})]}),t.jsx("div",{className:"bonsaif-metric-badge",style:{color:w,background:`color-mix(in srgb, ${w} 14%, transparent)`},children:y==="danger"?"Crítico":y==="warning"?"Alto":"Normal"})]}),t.jsx(Hn,{data:e,xKey:n,series:E.map(N=>({...N,color:N.color??w})),height:Math.max(120,i-56),yDomain:[0,100],showLegend:m,showTooltip:f,valueFormat:N=>mr(N,0),ariaLabel:x,opacity:.22,margin:{top:8,right:8,bottom:4,left:0}})]})}function yf({used:e,total:r,cached:n,data:a=[],timeKey:o="t",usageKey:l="usage",height:i=220,className:c="",loading:d=!1,emptyText:u="Sin datos de memoria",showHistory:m=!0,showTooltip:f=!0,thresholds:b,label:v="RAM",ariaLabel:x="Uso de memoria"}){const E=r>0?r:1,h=Math.min(100,Math.max(0,e/E*100)),$=!d&&!(Number.isFinite(e)&&Number.isFinite(r)&&r>0);if(d)return t.jsx(lt,{height:i});if($)return t.jsx(it,{height:i,text:u});const M=Ln(h,b),y=Xr(h,b),w=Math.max(0,r-e),k=a.length>0?hr(a,l)??h:h,N=Xr(k,b),A=m&&a.length>1?Math.max(100,i-110):0;return t.jsxs("div",{className:`bonsaif-chart bonsaif-ram-chart w-full ${c}`,role:"group","aria-label":x,children:[t.jsxs("div",{className:"bonsaif-metric-head",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"bonsaif-metric-kicker",children:v}),t.jsxs("div",{className:"flex items-baseline gap-2",children:[t.jsx("span",{className:"bonsaif-metric-value",style:{color:y},children:mr(h,h<10?1:0)}),t.jsxs("span",{className:"text-sm tabular-nums",style:{color:"var(--text-secondary)"},children:[pr(e)," / ",pr(r)]})]})]}),t.jsx("div",{className:"bonsaif-metric-badge",style:{color:y,background:`color-mix(in srgb, ${y} 14%, transparent)`},children:M==="danger"?"Crítico":M==="warning"?"Alto":"Normal"})]}),t.jsxs("div",{className:"mb-2",children:[t.jsx("div",{className:"h-2 w-full overflow-hidden rounded-sm",style:{background:"color-mix(in srgb, var(--border) 55%, transparent)"},role:"progressbar","aria-valuenow":Math.round(h),"aria-valuemin":0,"aria-valuemax":100,"aria-label":`${v} ${mr(h,0)}`,children:t.jsx("div",{className:"h-full rounded-sm transition-[width] duration-300",style:{width:`${h}%`,background:`linear-gradient(90deg, ${y}, color-mix(in srgb, ${y} 55%, #38bdf8))`}})}),t.jsxs("div",{className:"mt-2 flex flex-wrap gap-x-4 gap-y-1 text-[11px] tabular-nums",style:{color:"var(--text-muted)"},children:[t.jsxs("span",{children:[t.jsx("span",{className:"font-medium",style:{color:"var(--text-main)"},children:"Usada"})," ",pr(e)]}),n!=null&&Number.isFinite(n)?t.jsxs("span",{children:[t.jsx("span",{className:"font-medium",style:{color:"var(--text-main)"},children:"Caché"})," ",pr(n)]}):null,t.jsxs("span",{children:[t.jsx("span",{className:"font-medium",style:{color:"var(--text-main)"},children:"Libre"})," ",pr(w)]})]})]}),m&&a.length>1?t.jsx(Hn,{data:a,xKey:o,series:[{key:l,label:"Uso",color:N}],height:A,yDomain:[0,100],showLegend:!1,showTooltip:f,valueFormat:C=>mr(C,0),ariaLabel:`${x} — historial`,opacity:.22,margin:{top:8,right:8,bottom:4,left:0}}):null]})}const xf="color-mix(in srgb, var(--primary) 25%, #38bdf8)",wf="color-mix(in srgb, var(--primary) 20%, #2dd4bf)";function kf({data:e,timeKey:r="t",inboundKey:n="in",outboundKey:a="out",inbound:o,outbound:l,unit:i="bytes",inboundLabel:c="Entrada",outboundLabel:d="Salida",inboundColor:u=xf,outboundColor:m=wf,height:f=240,className:b="",loading:v=!1,emptyText:x="Sin datos de red",showLegend:E=!1,showTooltip:h=!0,label:$="Network",ariaLabel:M="Tráfico de red"}){const y=o??hr(e,n)??0,w=l??hr(e,a)??0,k=!v&&e.length===0;if(v)return t.jsx(lt,{height:f});if(k)return t.jsx(it,{height:f,text:x});const N=j=>tl(j,i),C=Math.max(140,f-76);return t.jsxs("div",{className:`bonsaif-chart bonsaif-network-chart w-full ${b}`,role:"group","aria-label":M,children:[t.jsx("div",{className:"bonsaif-network-header relative z-10 mb-4 grid gap-3 border-b pb-3 sm:grid-cols-[minmax(0,1.4fr)_minmax(0,1fr)]",style:{borderColor:"var(--border)"},children:t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"bonsaif-metric-kicker",children:$}),t.jsxs("div",{className:"mt-2 grid grid-cols-2 gap-5 sm:max-w-lg",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-1.5 text-[11px]",style:{color:"var(--text-muted)"},children:[t.jsx("span",{className:"h-3 w-1.5 shrink-0 rounded-sm",style:{background:u},"aria-hidden":!0}),c]}),t.jsx("div",{className:"mt-1 truncate text-xl font-bold tabular-nums leading-tight tracking-tight",style:{color:u},title:N(y),children:N(y)})]}),t.jsxs("div",{className:"min-w-0 pl-1",children:[t.jsxs("div",{className:"flex items-center gap-1.5 text-[11px]",style:{color:"var(--text-muted)"},children:[t.jsx("span",{className:"h-3 w-1.5 shrink-0 rounded-sm",style:{background:m},"aria-hidden":!0}),d]}),t.jsx("div",{className:"mt-1 truncate text-lg font-semibold tabular-nums leading-tight tracking-tight opacity-95",style:{color:m},title:N(w),children:N(w)})]})]})]})}),t.jsx("div",{className:"bonsaif-network-plot relative z-0",children:t.jsx(Hn,{data:e,xKey:r,series:[{key:n,label:c,color:u},{key:a,label:d,color:m}],height:C,showLegend:E,showTooltip:h,valueFormat:N,ariaLabel:M,opacity:.18,margin:{top:8,right:8,bottom:4,left:4}})})]})}const ul=["primeSuiteOrigin","primeAuthOrigin","primeSuiteAppUrl"],fl=["primeSuiteOrigin","primeSuiteProjectKey"];function Nf(){if(typeof window>"u")return"*";try{if(window.parent===window)return"*";const e=new URLSearchParams(window.location.search);for(const r of ul){const n=e.get(r);if(n){const a=Pn(n);if(a)return a}}if(typeof sessionStorage<"u")for(const r of fl){const n=sessionStorage.getItem(r);if(n)try{const a=new URL(n);if(a.origin&&a.origin!==window.location.origin)return a.origin}catch{const a=Pn(n);if(a)return a}}if(document.referrer){const r=Pn(document.referrer);if(r&&r!==window.location.origin)return r}return"*"}catch{return"*"}}function Sf(){if(typeof window>"u")return"self";try{if(window.parent===window)return"self";const e=new URLSearchParams(window.location.search);for(const r of ul)if(e.get(r))return"query";if(typeof sessionStorage<"u"){for(const r of fl)if(sessionStorage.getItem(r))return"sessionStorage"}if(document.referrer){const r=Pn(document.referrer);if(r&&r!==window.location.origin)return"referrer"}return"wildcard"}catch{return"wildcard"}}function Pn(e){if(!e)return null;const r=e.trim().replace(/\/+$/,"");if(!r)return null;if(/^https?:\/\/[^/]+$/.test(r))return r;try{return new URL(r).origin}catch{return null}}function Cf(e){const[r,n]=s.useState({}),[a,o]=s.useState(!1),l=s.useCallback(u=>a||r[u]?e[u]:void 0,[e,a,r]),i=s.useCallback(u=>{n(m=>({...m,[u]:!0}))},[]),c=s.useCallback(()=>{o(!0)},[]),d=s.useCallback(()=>{n({}),o(!1)},[]);return{submitted:a,touchedFields:r,getFieldError:l,touchField:i,submit:c,reset:d}}Object.defineProperty(Y,"toast",{enumerable:!0,get:()=>bs.toast}),Y.Alert=pi,Y.AreaChart=Hn,Y.AuthShell=Go,Y.BarChart=ef,Y.BonsaifButton=Zl,Y.BonsaifUIToaster=Ku,Y.BulletChart=gf,Y.Button=je,Y.CHART_PALETTE=Yr,Y.CalendarPicker=xi,Y.ChartCard=Gu,Y.Checkbox=dn,Y.CodeBlock=Ci,Y.ComboChart=sf,Y.CompactFilterSelect=$i,Y.CompactSearchInput=Mi,Y.ConfirmDialog=Di,Y.CopyButton=da,Y.CopyLinkButton=Bi,Y.CpuChart=vf,Y.DataSheets=ic,Y.DataTable=Hs,Y.DateRangePicker=bc,Y.DonutChart=rf,Y.Drawer=kc,Y.DropdownMenu=xc,Y.DynamicDetailTabs=bi,Y.EmailField=Vc,Y.EmptyState=Xc,Y.FieldHelperFooter=lr,Y.FieldLabelInfo=or,Y.FieldLayoutEditor=Rc,Y.FileUpload=Qc,Y.FormField=Ea,Y.FunnelChart=mf,Y.GaugeChart=pf,Y.GlobalScrollbars=qo,Y.ImageLightbox=to,Y.ImageLightboxHost=id,Y.InputField=Ca,Y.LineChart=Ru,Y.LoadingState=xs,Y.MentionTextEditor=Lo,Y.MicroserviceFrame=qu,Y.Modal=ba,Y.MouseTooltip=zt,Y.MultiDateCalendar=pc,Y.MultiSelect=dd,Y.NetworkChart=kf,Y.NumberField=ud,Y.PageHeader=zu,Y.PageSearchInput=ps,Y.Pagination=bd,Y.PhoneField=pd,Y.PieChart=tf,Y.PrimeAuthRouteShell=ju,Y.PrimeSuiteChatFrame=Uu,Y.RadioGroup=hd,Y.RamChart=yf,Y.RichTextEditor=zd,Y.SearchableSelect=jt,Y.SectionPanel=jd,Y.Sparkline=af,Y.StatusBadge=Ud,Y.StatusSelect=Gd,Y.StepWizard=Qd,Y.TableSkeleton=cn,Y.Tabs=Zd,Y.TagInput=lu,Y.TextInput=xn,Y.Textarea=Do,Y.TextareaField=ru,Y.TimeField=pu,Y.TimePicker=_o,Y.Toggle=gu,Y.UserAvatar=Ko,Y.WaterfallChart=of,Y.YearMultiDateCalendar=gc,Y.buildMentionQueryRegex=mo,Y.clearMentionChipSelection=ur,Y.cn=Tt,Y.configureBonsaifUI=_i,Y.dedupeMentions=yo,Y.defaultValueFormat=ot,Y.describeParentTargetOrigin=Sf,Y.emailFormat=$c,Y.extractMentionUsernames=Fa,Y.filterSelfMentions=Od,Y.findMentionChipAfterCaret=Eo,Y.findMentionChipBeforeCaret=Co,Y.findMentionChipsInSelection=Mo,Y.findMentionTriggerInEditor=Ha,Y.formatBytes=pr,Y.formatPercent=mr,Y.formatRate=tl,Y.getBonsaifUIConfig=zi,Y.getDataTablePreferencesEndpoint=ma,Y.getPlainTextOffset=Pa,Y.highlightMentions=xo,Y.htmlToText=go,Y.insertMentionInEditor=wo,Y.isMentionTriggerBoundary=ho,Y.isPlainOffsetInsideMentionChip=po,Y.isValidEmail=ka,Y.isValidPhone=Na,Y.locateTextOffset=dr,Y.matches=Oc,Y.maxLength=Ac,Y.maxValue=Ic,Y.mentionDisplayLabel=vo,Y.minLength=Lc,Y.minValue=Dc,Y.normalizeUsername=Ba,Y.openImageLightboxFromEvent=Rs,Y.phoneCountryCodeOptions=ao,Y.phoneFormat=Tc,Y.placeCaretAtTextOffset=ko,Y.removeMentionChip=En,Y.required=Mc,Y.resetBonsaifUIConfig=ji,Y.resolveMentions=Id,Y.resolveParentTargetOrigin=Nf,Y.selectMentionChip=So,Y.seriesColor=el,Y.setBonsaifDataTablePreferencesEndpoint=Wi,Y.toneColor=yt,Y.usageColor=Xr,Y.usageTone=Ln,Y.useValidationVisibility=Cf,Y.validateForm=Hc,Object.defineProperty(Y,Symbol.toStringTag,{value:"Module"})}));
84
+ `;function lb(){if(typeof document>"u"||document.getElementById(Xl))return;const e=document.createElement("style");e.id=Xl,e.textContent=sb,document.head.appendChild(e)}function Kl(e,r,n){return Math.min(n,Math.max(r,e))}function ra(e,r,n){const a=Kl(n,0,1);return`color-mix(in srgb, ${e} ${Math.round((1-a)*100)}%, ${r} ${Math.round(a*100)}%)`}function ib(e,r,n,a,s,l){const i=e.map((d,u)=>{const m=Tr(d[n])??0,b=String(d[r]??""),f=a?String(d[a]??"").trim():"",h=s?String(d[s]??"").trim():"";return{name:b,value:m,color:l[u%l.length],...f?{title:f}:{},...h?{description:h}:{}}}).filter(d=>d.value>0&&d.name),c=Math.max(...i.map(d=>d.value),1);return i.map(d=>({...d,pct:d.value/c}))}function cb(e,r){const n=e.length;if(n===0)return[];const a=r.gap*Math.max(0,n-1),s=(r.plotH-a)/n,l=r.maxTopW,i=r.maxTopW*r.taper;return e.map((c,d)=>{const u=n===1?0:d/n,m=n===1?1:(d+1)/n,b=l+(i-l)*u,f=l+(i-l)*m;return{...c,index:d,y:r.topY+d*(s+r.gap),h:s,topW:b,bottomW:f,cx:r.cx}})}function db({stage:e,hovered:r,onHover:n}){const{cx:a,y:s,h:l,topW:i,bottomW:c,color:d}=e,u=a-i/2,m=a+i/2,b=a-c/2,f=a+c/2,h=s+l,v=Math.max(4,Math.min(14,l*.18)),k=ra(d,"#000",r?.12:.22),g=ra(d,"#fff",r?.08:0),A=ra(d,"#fff",.22),$=[`M ${u} ${s}`,`L ${m} ${s}`,`L ${f} ${h}`,`L ${b} ${h}`,"Z"].join(" ");return t.jsxs("g",{onMouseEnter:()=>n(e.index),onMouseLeave:()=>n(null),style:{cursor:"default"},children:[t.jsx("path",{d:$,fill:k}),t.jsx("path",{d:[`M ${u} ${s}`,`L ${m} ${s}`,`L ${m} ${s+1}`,`L ${f} ${h}`,`L ${a} ${h}`,`L ${u} ${s}`,"Z"].join(" "),fill:g,opacity:.55}),t.jsx("ellipse",{cx:a,cy:s,rx:i/2,ry:v,fill:A,stroke:ra(d,"#000",.15),strokeWidth:1}),r?t.jsx("ellipse",{cx:a,cy:s,rx:i/2,ry:v,fill:"none",stroke:"var(--text-main)",strokeOpacity:.25,strokeWidth:1.5}):null]})}function ub({data:e,nameKey:r,valueKey:n,titleKey:a,descriptionKey:s,height:l=360,className:i="",loading:c=!1,emptyText:d="Sin datos para mostrar",showTooltip:u=!0,showLabels:m=!0,showValues:b=!0,showBottomArrow:f=!0,taper:h=.42,colors:v=[...sn],animationDuration:k=Qt,valueFormat:g=gt,ariaLabel:A="Gráfico embudo"}){const[$,N]=o.useState(null),[T,x]=o.useState(!1),y=o.useMemo(()=>ib(e,r,n,a,s,v),[e,r,n,a,s,v]),L=o.useMemo(()=>y.map(M=>`${M.name}:${M.value}`).join("|"),[y]);if(o.useEffect(()=>{if(lb(),typeof window>"u")return;const M=window.matchMedia("(prefers-reduced-motion: reduce)");x(M.matches);const oe=()=>x(M.matches);return M.addEventListener("change",oe),()=>M.removeEventListener("change",oe)},[]),c)return t.jsx(vt,{height:l});if(!y.length)return t.jsx(yt,{height:l,text:d});const w=k>0&&!T,W=k,X=Math.min(90,Math.max(40,Math.round(k/8))),Z=Math.round(W*.15),D=y.length*X+Math.round(W*.35),Q=y.some(M=>M.title||M.description),j=m?160:24,se=Q?168:24,te=f?36:8,ee=j+220+se,U=l,J=18,ce=Math.max(120,U-J-te-8),C=j+110,ae=cb(y,{cx:C,topY:J,plotH:ce,maxTopW:200,taper:Kl(h,.2,.95),gap:10}),B=$!=null?ae[$]:null,I="cubic-bezier(0.22, 1, 0.36, 1)";return t.jsxs("div",{className:`bonsaif-chart bonsaif-funnel-chart relative w-full ${i}`,role:"img","aria-label":A,style:{height:l},children:[t.jsxs("svg",{viewBox:`0 0 ${ee} ${U}`,width:"100%",height:"100%",preserveAspectRatio:"xMidYMid meet",children:[m?t.jsx("line",{className:w?"bonsaif-funnel-label":void 0,style:w?{animation:`bonsaif-funnel-fade-in ${W}ms ${I} both`}:void 0,x1:j-12,y1:J,x2:j-12,y2:J+ce,stroke:"var(--border)",strokeDasharray:"3 5",strokeWidth:1}):null,ae.map(M=>{const oe=M.y+M.h/2,K=M.cx-M.topW/2,Y=M.index*X,S=w?{animation:`bonsaif-funnel-stage-in ${W}ms ${I} ${Y}ms both`}:void 0,H=w?{animation:`bonsaif-funnel-fade-in ${Math.round(W*.85)}ms ${I} ${Y+Z}ms both`}:void 0;return t.jsxs("g",{children:[t.jsx("g",{className:"bonsaif-funnel-stage",style:S,children:t.jsx(db,{stage:M,hovered:$===M.index,onHover:N})}),m?t.jsxs("g",{className:"bonsaif-funnel-label",style:H,children:[t.jsx("line",{x1:24,y1:oe,x2:j-12,y2:oe,stroke:M.color,strokeOpacity:.55,strokeDasharray:"3 4",strokeWidth:1}),t.jsx("line",{x1:j-12,y1:oe,x2:K-6,y2:oe,stroke:M.color,strokeOpacity:.35,strokeDasharray:"3 4",strokeWidth:1}),t.jsx("text",{x:20,y:oe-(b?6:0),textAnchor:"end",fill:M.color,fontSize:12,fontWeight:600,children:M.name.length>18?`${M.name.slice(0,16)}…`:M.name}),b?t.jsx("text",{x:20,y:oe+10,textAnchor:"end",fill:"var(--text-muted)",fontSize:11,children:g(M.value)}):null]}):null,(M.title||M.description)&&Q?t.jsxs("g",{className:"bonsaif-funnel-anno",style:H,children:[t.jsx("line",{x1:M.cx+M.bottomW/2+6,y1:oe,x2:j+220+8,y2:oe,stroke:M.color,strokeOpacity:.35,strokeDasharray:"3 4",strokeWidth:1}),M.title?t.jsx("text",{x:j+220+14,y:oe-(M.description?6:0),fill:"var(--text-main)",fontSize:12,fontWeight:700,children:M.title.length>22?`${M.title.slice(0,20)}…`:M.title}):null,M.description?t.jsx("text",{x:j+220+14,y:oe+(M.title?10:0),fill:"var(--text-muted)",fontSize:11,children:M.description.length>28?`${M.description.slice(0,26)}…`:M.description}):null]}):null]},`${M.name}-${M.index}`)}),f?t.jsx("g",{className:"bonsaif-funnel-arrow",transform:`translate(${C}, ${J+ce+8})`,fill:"var(--primary)",style:w?{animation:`bonsaif-funnel-arrow-in ${Math.round(W*.7)}ms ${I} ${D}ms both`}:void 0,children:t.jsx("path",{d:"M0,22 L10,8 L4,8 L4,0 L-4,0 L-4,8 L-10,8 Z"})}):null]},L),u&&B?t.jsxs("div",{className:"pointer-events-none absolute z-10 rounded-md border px-2.5 py-1.5 text-xs shadow-sm",style:{left:"50%",top:8,transform:"translateX(-50%)",background:"var(--bg-card)",borderColor:"var(--border)",color:"var(--text-main)"},children:[t.jsx("span",{className:"font-semibold",style:{color:B.color},children:B.name}),t.jsx("span",{style:{color:"var(--text-muted)"},children:" · "}),g(B.value),t.jsxs("span",{style:{color:"var(--text-muted)"},children:[" ","(",Math.round(B.pct*100),"% del top)"]})]}):null]})}const Ir=135*Math.PI/180,xo=270*Math.PI/180;function fb({value:e,min:r=0,max:n=100,height:a=180,className:s="",loading:l=!1,empty:i=!1,emptyText:c="Sin datos para mostrar",label:d,valueFormat:u=gt,tone:m="primary",color:b,thresholds:f,ariaLabel:h="Gauge",animationDuration:v=700,thickness:k=9,showScale:g=!1}){const A=o.useId().replace(/:/g,""),$=n-r||1,N=Math.min(1,Math.max(0,(e-r)/$)),[T,x]=o.useState(v>0?0:N);if(o.useEffect(()=>{if(l||i)return;if(v<=0){x(N);return}if(typeof window<"u"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches){x(N);return}let ee=0,U=0;x(C=>(U=C,C));const J=performance.now(),ce=C=>{const _=Math.min(1,(C-J)/v),ae=1-(1-_)**3;x(U+(N-U)*ae),_<1&&(ee=requestAnimationFrame(ce))};return ee=requestAnimationFrame(ce),()=>cancelAnimationFrame(ee)},[N,v,l,i]),l)return t.jsx(vt,{height:a});if(i)return t.jsx(yt,{height:a,text:c});const y=100,L=108,w=72,W=b??bb(e,n,m,f),X=r+T*$,Z=Gl(y,L,w,Ir,Ir+xo),D=Ir+Math.max(.001,T)*xo,Q=Gl(y,L,w,Ir,D),j=na(y,L,w,Ir),se=na(y,L,w,Ir+xo);return t.jsx("div",{className:`bonsaif-chart bonsaif-gauge-chart flex flex-col items-center justify-center ${s}`,style:{height:a},children:t.jsxs("svg",{viewBox:"0 0 200 168",width:"100%",height:"100%",role:"img","aria-label":h,className:"overflow-visible",children:[t.jsx("defs",{children:t.jsxs("linearGradient",{id:`bonsaif-gauge-${A}`,x1:"0",y1:"0",x2:"1",y2:"0",children:[t.jsx("stop",{offset:"0%",stopColor:W,stopOpacity:.82}),t.jsx("stop",{offset:"100%",stopColor:W,stopOpacity:1})]})}),t.jsx("path",{d:Z,fill:"none",stroke:"color-mix(in srgb, var(--border) 70%, transparent)",strokeWidth:k,strokeLinecap:"butt"}),t.jsx("path",{d:Q,fill:"none",stroke:`url(#bonsaif-gauge-${A})`,strokeWidth:k,strokeLinecap:"butt",className:"bonsaif-chart-gauge-value"}),t.jsx("text",{x:y,y:L-(d?4:0),textAnchor:"middle",dominantBaseline:"middle",fill:"var(--text-main)",fontSize:28,fontWeight:700,letterSpacing:"-0.04em",className:"bonsaif-chart-gauge-label",children:u(X)}),d?t.jsx("text",{x:y,y:L+18,textAnchor:"middle",fill:"var(--text-muted)",fontSize:11,fontWeight:600,letterSpacing:"0.06em",children:d}):null,g?t.jsxs(t.Fragment,{children:[t.jsx("text",{x:j.x-2,y:j.y+k+14,textAnchor:"middle",fill:"var(--text-muted)",fontSize:10,children:u(r)}),t.jsx("text",{x:se.x+2,y:se.y+k+14,textAnchor:"middle",fill:"var(--text-muted)",fontSize:10,children:u(n)})]}):null]})})}function bb(e,r,n,a){if(a!=null&&a.length){const l=[...a].sort((c,d)=>c.value-d.value);let i=l[0].color;for(const c of l)e>=c.value&&(i=c.color);return i}if(n)return Lt(n);const s=e/(r||1);return s>=.8?Lt("success"):s>=.5?Lt("warning"):Lt("danger")}function na(e,r,n,a){return{x:e+n*Math.cos(a),y:r+n*Math.sin(a)}}function Gl(e,r,n,a,s){const l=na(e,r,n,a),i=na(e,r,n,s),c=s-a,d=Math.abs(c)>Math.PI?1:0;return`M ${l.x} ${l.y} A ${n} ${n} 0 ${d} 1 ${i.x} ${i.y}`}function mb({value:e,target:r,max:n,ranges:a,height:s=72,className:l="",loading:i=!1,empty:c=!1,emptyText:d="Sin datos para mostrar",label:u,subtitle:m,valueFormat:b=gt,tone:f="primary",showScale:h=!0,showStatus:v=!0,ariaLabel:k="Bullet chart"}){if(i)return t.jsx(vt,{height:s});if(c)return t.jsx(yt,{height:s,text:d});const g=n??Math.max(e,r,...(a==null?void 0:a.map(W=>W.value))??[],1)*1.05,$=[...a??[{value:g*.5,color:"color-mix(in srgb, var(--border) 72%, transparent)"},{value:g*.75,color:"color-mix(in srgb, var(--border) 48%, transparent)"},{value:g,color:"color-mix(in srgb, var(--border) 28%, transparent)"}]].sort((W,X)=>W.value-X.value),N=Lt(f),T=Math.min(100,Math.max(0,e/g*100)),x=Math.min(100,Math.max(0,r/g*100)),y=e>=r,L=[0,.25,.5,.75,1].map(W=>W*g),w=t.jsxs("div",{className:"bonsaif-bullet-plot min-w-0 flex-1",children:[t.jsxs("div",{className:"bonsaif-bullet-track relative w-full",style:{height:Math.max(22,u?28:s*.42)},role:"img","aria-label":k,children:[t.jsx("div",{className:"bonsaif-bullet-ranges absolute inset-0 flex overflow-hidden",children:$.map((W,X)=>{const Z=X===0?0:$[X-1].value,D=Math.max(0,(W.value-Z)/g*100);return t.jsx("div",{style:{width:`${D}%`,background:W.color??`color-mix(in srgb, var(--border) ${70-X*18}%, transparent)`}},X)})}),t.jsx("div",{className:"absolute left-0 top-1/2 w-full",style:{height:"34%",transform:"translateY(-50%)"},children:t.jsx("div",{className:"bonsaif-bullet-value h-full",style:{width:`${T}%`,background:N,borderRadius:"0 999px 999px 0",boxShadow:`0 0 12px color-mix(in srgb, ${N} 35%, transparent)`}})}),t.jsx("div",{className:"bonsaif-bullet-target absolute top-1/2 z-[1]",style:{left:`${x}%`,height:"72%",width:3,transform:"translate(-50%, -50%)",background:N,borderRadius:1,boxShadow:"0 0 0 1px color-mix(in srgb, var(--bg-card) 70%, transparent)"},title:`Meta ${b(r)}`})]}),h?t.jsx("div",{className:"bonsaif-bullet-scale relative mt-1.5 h-4 w-full",children:L.map((W,X)=>{const Z=W/g*100,D=X===0,Q=X===L.length-1;return t.jsxs("div",{className:"absolute top-0",style:{left:`${Z}%`,transform:D?"none":Q?"translateX(-100%)":"translateX(-50%)"},children:[t.jsx("div",{className:"mx-auto h-1.5 w-px",style:{background:"color-mix(in srgb, var(--text-muted) 55%, transparent)",marginLeft:D?0:Q?"auto":void 0,marginRight:Q?0:void 0}}),t.jsx("div",{className:"bonsaif-bullet-scale-label mt-0.5 tabular-nums",style:{color:"var(--text-muted)",textAlign:D?"left":Q?"right":"center"},children:b(W)})]},W)})}):null]});return t.jsx("div",{className:`bonsaif-chart bonsaif-bullet-chart w-full ${l}`,children:u?t.jsxs("div",{className:"bonsaif-bullet-row flex flex-col gap-2 sm:flex-row sm:items-start sm:gap-4",children:[t.jsxs("div",{className:"bonsaif-bullet-label shrink-0 sm:w-[7.5rem] sm:pt-1 sm:text-right",children:[t.jsx("div",{className:"text-sm font-semibold tracking-tight",style:{color:"var(--text-main)"},children:u}),m?t.jsx("div",{className:"mt-0.5 text-[11px] leading-snug",style:{color:"var(--text-muted)"},children:m}):t.jsxs("div",{className:"mt-0.5 text-[11px] tabular-nums leading-snug",style:{color:"var(--text-muted)"},children:[t.jsx("span",{style:{color:N,fontWeight:600},children:b(e)}),t.jsxs("span",{children:[" / meta ",b(r)]})]}),v?t.jsx("div",{className:"bonsaif-bullet-status mt-1.5 inline-flex text-[10px] font-bold uppercase tracking-wide",style:{color:Lt(y?"success":"warning")},children:y?"En meta":"Bajo meta"}):null]}),w]}):w})}function pb({data:e,value:r,timeKey:n="t",usageKey:a="usage",series:s,cores:l,height:i=220,className:c="",loading:d=!1,emptyText:u="Sin datos de CPU",showLegend:m=!1,showTooltip:b=!0,thresholds:f,label:h="CPU",ariaLabel:v="Uso de CPU"}){var x;const k=s??[{key:a,label:"Uso",color:ln(r??Lr(e,a)??0,f)}],g=r??Lr(e,a)??Lr(e,((x=k[0])==null?void 0:x.key)??a),A=!d&&(!e.length||g===null);if(d)return t.jsx(vt,{height:i});if(A)return t.jsx(yt,{height:i,text:u});const $=Math.min(100,Math.max(0,g??0)),N=Zn($,f),T=ln($,f);return t.jsxs("div",{className:`bonsaif-chart bonsaif-cpu-chart w-full ${c}`,role:"group","aria-label":v,children:[t.jsxs("div",{className:"bonsaif-metric-head",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"bonsaif-metric-kicker",children:[h,l!=null?t.jsxs("span",{className:"ml-1.5 normal-case tracking-normal opacity-80",children:["· ",l," ",l===1?"core":"cores"]}):null]}),t.jsx("div",{className:"bonsaif-metric-value",style:{color:T},children:$r($,$<10?1:0)})]}),t.jsx("div",{className:"bonsaif-metric-badge",style:{color:T,background:`color-mix(in srgb, ${T} 14%, transparent)`},children:N==="danger"?"Crítico":N==="warning"?"Alto":"Normal"})]}),t.jsx(ta,{data:e,xKey:n,series:k.map(y=>({...y,color:y.color??T})),height:Math.max(120,i-56),yDomain:[0,100],showLegend:m,showTooltip:b,valueFormat:y=>$r(y,0),ariaLabel:v,opacity:.22,margin:{top:8,right:8,bottom:4,left:0}})]})}function hb({used:e,total:r,cached:n,data:a=[],timeKey:s="t",usageKey:l="usage",height:i=220,className:c="",loading:d=!1,emptyText:u="Sin datos de memoria",showHistory:m=!0,showTooltip:b=!0,thresholds:f,label:h="RAM",ariaLabel:v="Uso de memoria"}){const k=r>0?r:1,g=Math.min(100,Math.max(0,e/k*100)),A=!d&&!(Number.isFinite(e)&&Number.isFinite(r)&&r>0);if(d)return t.jsx(vt,{height:i});if(A)return t.jsx(yt,{height:i,text:u});const $=Zn(g,f),N=ln(g,f),T=Math.max(0,r-e),x=a.length>0?Lr(a,l)??g:g,y=ln(x,f),L=m&&a.length>1?Math.max(100,i-110):0;return t.jsxs("div",{className:`bonsaif-chart bonsaif-ram-chart w-full ${c}`,role:"group","aria-label":v,children:[t.jsxs("div",{className:"bonsaif-metric-head",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"bonsaif-metric-kicker",children:h}),t.jsxs("div",{className:"flex items-baseline gap-2",children:[t.jsx("span",{className:"bonsaif-metric-value",style:{color:N},children:$r(g,g<10?1:0)}),t.jsxs("span",{className:"text-sm tabular-nums",style:{color:"var(--text-secondary)"},children:[Ar(e)," / ",Ar(r)]})]})]}),t.jsx("div",{className:"bonsaif-metric-badge",style:{color:N,background:`color-mix(in srgb, ${N} 14%, transparent)`},children:$==="danger"?"Crítico":$==="warning"?"Alto":"Normal"})]}),t.jsxs("div",{className:"mb-2",children:[t.jsx("div",{className:"h-2 w-full overflow-hidden rounded-sm",style:{background:"color-mix(in srgb, var(--border) 55%, transparent)"},role:"progressbar","aria-valuenow":Math.round(g),"aria-valuemin":0,"aria-valuemax":100,"aria-label":`${h} ${$r(g,0)}`,children:t.jsx("div",{className:"h-full rounded-sm transition-[width] duration-300",style:{width:`${g}%`,background:`linear-gradient(90deg, ${N}, color-mix(in srgb, ${N} 55%, #38bdf8))`}})}),t.jsxs("div",{className:"mt-2 flex flex-wrap gap-x-4 gap-y-1 text-[11px] tabular-nums",style:{color:"var(--text-muted)"},children:[t.jsxs("span",{children:[t.jsx("span",{className:"font-medium",style:{color:"var(--text-main)"},children:"Usada"})," ",Ar(e)]}),n!=null&&Number.isFinite(n)?t.jsxs("span",{children:[t.jsx("span",{className:"font-medium",style:{color:"var(--text-main)"},children:"Caché"})," ",Ar(n)]}):null,t.jsxs("span",{children:[t.jsx("span",{className:"font-medium",style:{color:"var(--text-main)"},children:"Libre"})," ",Ar(T)]})]})]}),m&&a.length>1?t.jsx(ta,{data:a,xKey:s,series:[{key:l,label:"Uso",color:y}],height:L,yDomain:[0,100],showLegend:!1,showTooltip:b,valueFormat:w=>$r(w,0),ariaLabel:`${v} — historial`,opacity:.22,margin:{top:8,right:8,bottom:4,left:0}}):null]})}const gb="color-mix(in srgb, var(--primary) 25%, #38bdf8)",vb="color-mix(in srgb, var(--primary) 20%, #2dd4bf)";function yb({data:e,timeKey:r="t",inboundKey:n="in",outboundKey:a="out",inbound:s,outbound:l,unit:i="bytes",inboundLabel:c="Entrada",outboundLabel:d="Salida",inboundColor:u=gb,outboundColor:m=vb,height:b=240,className:f="",loading:h=!1,emptyText:v="Sin datos de red",showLegend:k=!1,showTooltip:g=!0,label:A="Network",ariaLabel:$="Tráfico de red"}){const N=s??Lr(e,n)??0,T=l??Lr(e,a)??0,x=!h&&e.length===0;if(h)return t.jsx(vt,{height:b});if(x)return t.jsx(yt,{height:b,text:v});const y=W=>zl(W,i),w=Math.max(140,b-76);return t.jsxs("div",{className:`bonsaif-chart bonsaif-network-chart w-full ${f}`,role:"group","aria-label":$,children:[t.jsx("div",{className:"bonsaif-network-header relative z-10 mb-4 grid gap-3 border-b pb-3 sm:grid-cols-[minmax(0,1.4fr)_minmax(0,1fr)]",style:{borderColor:"var(--border)"},children:t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"bonsaif-metric-kicker",children:A}),t.jsxs("div",{className:"mt-2 grid grid-cols-2 gap-5 sm:max-w-lg",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-1.5 text-[11px]",style:{color:"var(--text-muted)"},children:[t.jsx("span",{className:"h-3 w-1.5 shrink-0 rounded-sm",style:{background:u},"aria-hidden":!0}),c]}),t.jsx("div",{className:"mt-1 truncate text-xl font-bold tabular-nums leading-tight tracking-tight",style:{color:u},title:y(N),children:y(N)})]}),t.jsxs("div",{className:"min-w-0 pl-1",children:[t.jsxs("div",{className:"flex items-center gap-1.5 text-[11px]",style:{color:"var(--text-muted)"},children:[t.jsx("span",{className:"h-3 w-1.5 shrink-0 rounded-sm",style:{background:m},"aria-hidden":!0}),d]}),t.jsx("div",{className:"mt-1 truncate text-lg font-semibold tabular-nums leading-tight tracking-tight opacity-95",style:{color:m},title:y(T),children:y(T)})]})]})]})}),t.jsx("div",{className:"bonsaif-network-plot relative z-0",children:t.jsx(ta,{data:e,xKey:r,series:[{key:n,label:c,color:u},{key:a,label:d,color:m}],height:w,showLegend:k,showTooltip:g,valueFormat:y,ariaLabel:$,opacity:.18,margin:{top:8,right:8,bottom:4,left:4}})})]})}const Zl=["primeSuiteOrigin","primeAuthOrigin","primeSuiteAppUrl"],Ql=["primeSuiteOrigin","primeSuiteProjectKey"];function xb(){if(typeof window>"u")return"*";try{if(window.parent===window)return"*";const e=new URLSearchParams(window.location.search);for(const r of Zl){const n=e.get(r);if(n){const a=aa(n);if(a)return a}}if(typeof sessionStorage<"u")for(const r of Ql){const n=sessionStorage.getItem(r);if(n)try{const a=new URL(n);if(a.origin&&a.origin!==window.location.origin)return a.origin}catch{const a=aa(n);if(a)return a}}if(document.referrer){const r=aa(document.referrer);if(r&&r!==window.location.origin)return r}return"*"}catch{return"*"}}function wb(){if(typeof window>"u")return"self";try{if(window.parent===window)return"self";const e=new URLSearchParams(window.location.search);for(const r of Zl)if(e.get(r))return"query";if(typeof sessionStorage<"u"){for(const r of Ql)if(sessionStorage.getItem(r))return"sessionStorage"}if(document.referrer){const r=aa(document.referrer);if(r&&r!==window.location.origin)return"referrer"}return"wildcard"}catch{return"wildcard"}}function aa(e){if(!e)return null;const r=e.trim().replace(/\/+$/,"");if(!r)return null;if(/^https?:\/\/[^/]+$/.test(r))return r;try{return new URL(r).origin}catch{return null}}function Nb(e){const[r,n]=o.useState({}),[a,s]=o.useState(!1),l=o.useCallback(u=>a||r[u]?e[u]:void 0,[e,a,r]),i=o.useCallback(u=>{n(m=>({...m,[u]:!0}))},[]),c=o.useCallback(()=>{s(!0)},[]),d=o.useCallback(()=>{n({}),s(!1)},[]);return{submitted:a,touchedFields:r,getFieldError:l,touchField:i,submit:c,reset:d}}Object.defineProperty(V,"toast",{enumerable:!0,get:()=>Ma.toast}),V.Alert=Zi,V.AreaChart=ta,V.AuthShell=Ol,V.AutoGrowTextarea=hl,V.AutoGrowTextareaField=Ku,V.BarChart=Jf,V.BonsaifButton=Li,V.BonsaifUIToaster=Yf,V.BulletChart=mb,V.Button=Ue,V.CHART_PALETTE=sn,V.CalendarPicker=tc,V.ChartCard=Xf,V.Checkbox=Nn,V.CodeBlock=sc,V.ComboChart=nb,V.CompactFilterSelect=cc,V.CompactSearchInput=ic,V.ConfirmDialog=bc,V.CopyButton=La,V.CopyLinkButton=gc,V.CpuChart=pb,V.DataSheets=qc,V.DataTable=ls,V.DateRangePicker=Kc,V.DonutChart=eb,V.Drawer=ad,V.DropdownMenu=rd,V.DynamicDetailTabs=Ki,V.EmailField=Md,V.EmptyState=$d,V.FieldHelperFooter=wr,V.FieldLabelInfo=xr,V.FieldLayoutEditor=Hd,V.FileUpload=Id,V.FormField=In,V.FunnelChart=ub,V.GaugeChart=fb,V.GlobalScrollbars=Tl,V.ImageLightbox=Ms,V.ImageLightboxHost=Ud,V.InputField=Ya,V.LineChart=Qf,V.LoadingState=Vo,V.MentionTextEditor=bl,V.MicroserviceFrame=Wf,V.Modal=Oa,V.MouseTooltip=Yt,V.MultiDateCalendar=Qc,V.MultiSelect=Yd,V.NetworkChart=yb,V.NumberField=Xd,V.PageHeader=Pf,V.PageSearchInput=zo,V.Pagination=Gd,V.PhoneField=Qd,V.PieChart=Rf,V.PrimeAuthRouteShell=_f,V.PrimeSuiteChatFrame=jf,V.RadioGroup=Jd,V.RamChart=hb,V.RichTextEditor=Iu,V.SearchableSelect=ar,V.SectionPanel=Ou,V.Sparkline=rb,V.StatusBadge=Fu,V.StatusSelect=ju,V.StepWizard=Uu,V.TableSkeleton=wn,V.Tabs=qu,V.TagInput=af,V.TextInput=Dn,V.Textarea=gl,V.TextareaField=Ru,V.TimeField=bf,V.TimePicker=Sl,V.Toggle=pf,V.TruncatedWithTooltip=Pt,V.UserAvatar=Il,V.WaterfallChart=ab,V.YearMultiDateCalendar=Rc,V.buildMentionQueryRegex=Xs,V.clearMentionChipSelection=Er,V.cn=Vt,V.configureBonsaifUI=xc,V.dedupeMentions=Js,V.defaultValueFormat=gt,V.deleteEditorSelection=ll,V.describeParentTargetOrigin=wb,V.emailFormat=dd,V.extractMentionUsernames=so,V.filterSelfMentions=Eu,V.findMentionChipAfterCaret=cl,V.findMentionChipBeforeCaret=il,V.findMentionChipsInSelection=co,V.findMentionTriggerInEditor=ao,V.formatBytes=Ar,V.formatPercent=$r,V.formatRate=zl,V.getBonsaifUIConfig=wc,V.getDataTablePreferencesEndpoint=Ha,V.getEditorPlainText=io,V.getPlainTextOffset=qn,V.highlightMentions=Rs,V.htmlToText=Zs,V.insertMentionInEditor=tl,V.isMentionTriggerBoundary=Gs,V.isPlainOffsetInsideMentionChip=Ks,V.isValidEmail=qa,V.isValidPhone=Ua,V.locateTextOffset=Cr,V.matches=hd,V.maxLength=bd,V.maxValue=pd,V.mentionDisplayLabel=Qs,V.minLength=fd,V.minValue=md,V.normalizeUsername=oo,V.openImageLightboxFromEvent=Cs,V.phoneCountryCodeOptions=As,V.phoneFormat=ud,V.placeCaretAtTextOffset=rl,V.removeMentionChip=Yn,V.required=cd,V.resetBonsaifUIConfig=Nc,V.resolveMentions=Cu,V.resolveParentTargetOrigin=xb,V.selectAllEditorContents=ol,V.selectMentionChip=al,V.selectionIncludesNonChipText=sl,V.seriesColor=_l,V.setBonsaifDataTablePreferencesEndpoint=kc,V.syncMentionChipSelectionHighlight=Vn,V.toneColor=Lt,V.usageColor=ln,V.usageTone=Zn,V.useValidationVisibility=Nb,V.validateForm=gd,Object.defineProperty(V,Symbol.toStringTag,{value:"Module"})}));