bonsaif-ui 0.1.136 → 0.1.138
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.
- package/CHANGELOG.md +9 -0
- package/dist/bonsaif-ui.js +5187 -4961
- package/dist/bonsaif-ui.umd.cjs +20 -20
- package/dist/components/ui/EventCalendar.d.ts +14 -1
- package/dist/components/ui/EventCalendar.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/bonsaif-ui.umd.cjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
(function(q,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):(q=typeof globalThis<"u"?globalThis:q||self,s(q.BonsaifUI={},q.React,q.jsxRuntime,q.ReactIconsHi2,q.ReactDOM,q.Recharts,q.OverlayScrollbarsGlobal,q.Sonner,q.OverlayScrollbarsReact,q.ReactDayPicker,q.ReactDayPickerStyles,q.ReactIconsFi))})(this,(function(q,s,t,W,ht,Me,Oa,Ha,Zo,Ia,Hm,Ki){"use strict";"use client";function Zt(...e){return e.filter(Boolean).join(" ")}function Gi({variant:e="primary",className:r,type:n="button",children:a,...o}){return t.jsx("button",{className:Zt("bonsaif-ui-button",`bonsaif-ui-button--${e}`,r),type:n,...o,children:a})}function Qo({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,b]=s.useState(!1),f=l||m||e.trim().length>0,g=c==="sm"?"h-9 rounded-md":"h-10 rounded-lg",h=a||"w-48 max-w-full sm:w-64 lg:w-72";s.useEffect(()=>{var v;o&&((v=u.current)==null||v.focus())},[o]);const E=()=>{var v;b(!0),(v=u.current)==null||v.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?h:"w-24 sm:w-28"}`,onMouseDown:v=>{f||(v.preventDefault(),E())},children:[t.jsx(W.HiMagnifyingGlass,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 pointer-events-none transition-colors duration-200",style:{color:"var(--text-muted)",left:"var(--page-header-control-icon-left, 12px)"}}),t.jsx("input",{ref:u,type:"text",tabIndex:d,"aria-label":n,value:e,onChange:v=>r(v.target.value),onKeyDown:v=>{v.key==="Escape"&&(i==null||i())},placeholder:f?n:"Buscar",className:`${g} 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:v=>{b(!0),v.currentTarget.style.borderColor="var(--primary)",v.currentTarget.style.boxShadow="0 0 0 3px rgba(59,130,246,0.12)"},onBlur:v=>{b(!1),v.currentTarget.style.borderColor="var(--border)",v.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(W.HiXMark,{className:"h-3.5 w-3.5 flex-shrink-0"})})]})}const Jo=s.createContext({});let Ro=0;const es="bonsaif-ui:hide-tooltips";function Sn(e=700){Ro=Date.now()+e}function Zi(){return Date.now()>Ro}function En(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 Qi(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 Bt({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:b="div"}){const f=s.useRef(null),g=s.useRef(null),h=s.useRef(null),E=s.useRef(!1),[v,S]=s.useState(null),[A,C]=s.useState("");s.useEffect(()=>{const D=f.current;D&&(D.querySelectorAll("[title]").forEach(G=>{const U=G.getAttribute("title");U&&(G.getAttribute("aria-label")||G.setAttribute("aria-label",U),G.removeAttribute("title"))}),D.querySelectorAll("svg title").forEach(G=>G.remove()))}),s.useLayoutEffect(()=>{if(!v)return;const D=g.current;if(!D)return;const G=12,U=14,ne=D.getBoundingClientRect(),J=window.innerWidth-ne.width-G,R=window.innerHeight-ne.height-G;let V=v.mouseX+U,X=v.mouseY+U,de,H;if(!o&&f.current){const I=f.current.getBoundingClientRect(),le=I.left+I.width/2,L=I.top+I.height/2;l==="top"?(V=le-ne.width/2,X=I.top-ne.height-U,H=ne.height-1):l==="left"?(V=I.left-ne.width-U,X=L-ne.height/2,de=ne.width-1):l==="right"?(V=I.right+U,X=L-ne.height/2,de=-7):(V=le-ne.width/2,X=I.bottom+U,H=-7)}if(o&&(V>J&&(V=v.mouseX-ne.width-U),X>R&&(X=v.mouseY-ne.height-U)),V=Math.min(Math.max(G,V),Math.max(G,J)),X=Math.min(Math.max(G,X),Math.max(G,R)),!o&&f.current){const I=f.current.getBoundingClientRect(),le=I.left+I.width/2,L=I.top+I.height/2;l==="top"||l==="bottom"?de=Math.min(Math.max(14,le-V),ne.width-14):H=Math.min(Math.max(14,L-X),ne.height-14)}(Math.abs(V-v.x)>.5||Math.abs(X-v.y)>.5||de!==v.arrowX||H!==v.arrowY)&&S(I=>I&&{...I,x:V,y:X,arrowX:de,arrowY:H})},[o,l,v]);const O=()=>{h.current&&(window.clearTimeout(h.current),h.current=null)},N=(D,G)=>{if(!Zi()||E.current)return;const U=f.current;if(U&&!En(U)){if(n){const ne=Qi(U);if(!ne)return;C(ne)}!n&&!r||S({mouseX:D,mouseY:G,x:D+14,y:G+14})}},y=()=>{const D=f.current;if(!D)return;const G=D.getBoundingClientRect();N(G.left+G.width/2,G.bottom)},M=()=>{O(),S(null)},k=()=>{if(!a){M();return}O(),h.current=window.setTimeout(()=>S(null),120)},_=()=>{Sn(),E.current=!0,M()},Y=()=>{E.current=!1};s.useEffect(()=>{if(!v)return;if(En(f.current)){S(null);return}const D=()=>S(null),G=()=>{Sn(),E.current=!0,S(null)};document.addEventListener("pointerdown",G,!0),document.addEventListener("click",G,!0),document.addEventListener("scroll",D,!0),window.addEventListener("blur",D),document.addEventListener("visibilitychange",D),document.addEventListener("keydown",D,!0);const U=new MutationObserver(()=>{En(f.current)&&S(null)});return U.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["role","aria-modal","aria-hidden","class"]}),()=>{document.removeEventListener("pointerdown",G,!0),document.removeEventListener("click",G,!0),document.removeEventListener("scroll",D,!0),window.removeEventListener("blur",D),document.removeEventListener("visibilitychange",D),document.removeEventListener("keydown",D,!0),U.disconnect()}},[v]),s.useEffect(()=>{const D=()=>Sn(),G=()=>{Sn(),E.current=!0,S(null)};return document.addEventListener("pointerdown",D,!0),document.addEventListener("click",D,!0),document.addEventListener("keydown",D,!0),window.addEventListener(es,G),()=>{document.removeEventListener("pointerdown",D,!0),document.removeEventListener("click",D,!0),document.removeEventListener("keydown",D,!0),window.removeEventListener(es,G)}},[]);const K=n?A:r;return t.jsxs(t.Fragment,{children:[t.jsx(b,{ref:D=>{f.current=D},className:c,style:u,onMouseEnter:D=>{O(),Y(),o?N(D.clientX,D.clientY):y()},onMouseMove:D=>{v&&o&&N(D.clientX,D.clientY)},onMouseDown:_,onClick:_,onMouseLeave:()=>{Y(),k()},onFocus:y,onBlur:M,children:e}),v&&K&&!En(f.current)?ht.createPortal(t.jsxs("div",{ref:g,role:"tooltip",className:d,onMouseEnter:a?O:void 0,onMouseLeave:a?k:void 0,style:{position:"fixed",top:v.y,left:v.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:v.arrowX===void 0?void 0:v.arrowX-6,top:v.arrowY===void 0?void 0:v.arrowY-6,zIndex:-1}}),K]}),document.body):null]})}function ts(e){if(e!==void 0)return typeof e=="number"?`${e}px`:e}const Ji="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",Ri={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"},ec="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",tc={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"},rc={xs:"h-8 w-8",sm:"h-9 w-9",md:"h-10 w-10",lg:"h-10 w-10"},nc={primary:{background:"var(--bg-card)"},secondary:{background:"var(--bg-card)"},danger:{background:"var(--bg-card)"},ghost:{},icon:{}};function Ba(e){return typeof e=="string"||typeof e=="number"?String(e):Array.isArray(e)?e.map(Ba).join(" ").trim():s.isValidElement(e)?Ba(e.props.children):""}function ac(e){return s.Children.toArray(e).find(s.isValidElement)??null}function Ve({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:b,...f}){const g=s.useContext(Jo),h=l??g.iconOnly??e==="icon",E=g.compact??!1,v=g.headerAction??!1,S=v&&r==="md"?"sm":E&&!v&&r==="md"?"xs":r,A=e==="icon"||h,C=v&&A,O=Ba(d),N=o??f.title??f["aria-label"]??(h?O:void 0),y=N?void 0:f.title,M=f["aria-label"]??(typeof N=="string"?N:O||void 0),k=n?null:a??(h?ac(d):null),_=t.jsxs("button",{...f,title:y,"aria-label":M,"data-variant":e,"data-size":S,"data-icon":A?"true":void 0,disabled:m||n,className:`${Ji} ${C?ec:Ri[e]} ${A?rc[S]:tc[S]} ${E&&!A?"px-2.5":""} ${u}`,style:{...nc[e],height:ts(i),padding:ts(c),...b,...v&&!A?{height:"var(--page-header-control-height, 34px)",padding:"0 var(--page-header-control-padding-x, 10px)",borderRadius:"8px"}:null,...C?{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"}):k,!h&&d]});return N?t.jsx(Bt,{as:"span",content:N,className:"inline-flex shrink-0",children:_}):_}const gt={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:gt}),t.jsx("div",{className:"h-7 max-w-md flex-1 animate-pulse rounded-md",style:gt})]}),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:gt}),t.jsx("div",{className:"h-7 w-7 animate-pulse rounded-md",style:gt})]})]}),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:{...gt,width:`${48+b*17%40}%`}})},`h-${b}`)),Array.from({length:c}).map((m,b)=>Array.from({length:i}).map((f,g)=>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:{...gt,width:`${46+(b*13+g*11)%42}%`,minWidth:28}})},`c-${b}-${g}`)))]})}),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:gt}),t.jsx("div",{className:"h-7 w-14 animate-pulse rounded-md",style:gt})]}),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:gt},b))}),t.jsx("div",{className:"h-3 w-16 animate-pulse rounded-md",style:gt})]})]})}function oc({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 sc({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 rs({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(lc,{rows:i});if(e==="cards")return t.jsx(ic,{rows:i});const m=o||(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(sc,{logoSrc:a,logoAlt:m}):null,t.jsx(oc,{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 lc({rows:e}){return t.jsx(Cn,{rows:e,columns:7})}function ic({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:gt}),t.jsx("div",{className:"mt-3 h-3 w-full animate-pulse rounded-md",style:gt}),t.jsx("div",{className:"mt-2 h-3 w-4/5 animate-pulse rounded-md",style:gt})]},n))})}function ns(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 as(e){return e.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().trim()}function cc(e){return[e.label,ns(e.service),e.description,e.service].filter(Boolean).join(" ")}function dc(e){return typeof e=="function"?e:e.default}function uc(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(Ve,{className:"mt-4",height:36,padding:"0 14px",onClick:r,children:"Reintentar"})]})})}function fc({parentPanel:e,parentPanelComponent:r,renderParentPanel:n,parent:a,context:o,links:l,moduleRegistry:i,loadModule:c,activeService:d,initialService:u,onActiveServiceChange:m,canAccess:b,keepAlive:f=!0,title:g,subtitle:h,emptyState:E,loadingState:v,errorState:S=uc,renderTabLabel:A,searchableTabs:C="auto",tabsSearchThreshold:O=6,tabsSearchPlaceholder:N="Buscar modulo...",tabsSearchValue:y,onTabsSearchChange:M,emptySearchState:k,showTabCount:_=!0,className:Y="",parentClassName:K="",contentClassName:D="",tabsClassName:G=""}){var Le;const U=s.useMemo(()=>l.filter(ce=>!ce.hidden&&((b==null?void 0:b(ce,o))??!0)),[b,o,l]),ne=(Le=U.find(ce=>!ce.disabled))==null?void 0:Le.service,[J,R]=s.useState(u??ne??""),[V,X]=s.useState({}),[de,H]=s.useState({}),[I,le]=s.useState(""),[L,oe]=s.useState(!1),w=s.useRef(de),te=s.useRef(0),B=y??I,F=as(B),ue=C===!0||C==="auto"&&U.length>=O,re=ue&&B.trim().length>0,j=s.useMemo(()=>F?U.filter(ce=>as(cc(ce)).includes(F)):U,[F,U]),x=d??J,T=U.find(ce=>ce.service===x)??U.find(ce=>!ce.disabled);s.useEffect(()=>{!T&&ne&&R(ne)},[ne,T]),s.useEffect(()=>{w.current=de},[de]);const ee=ce=>{ce.disabled||(d||R(ce.service),m==null||m(ce.service,ce))},fe=ce=>{y===void 0&&le(ce),M==null||M(ce)},ie=(ce,Pe)=>{const _e=j.filter(Xe=>!Xe.disabled),at=_e.findIndex(Xe=>Xe.service===Pe.service);at<0||((ce.key==="ArrowRight"||ce.key==="ArrowDown")&&(ce.preventDefault(),ee(_e[(at+1)%_e.length])),(ce.key==="ArrowLeft"||ce.key==="ArrowUp")&&(ce.preventDefault(),ee(_e[(at-1+_e.length)%_e.length])),ce.key==="Home"&&(ce.preventDefault(),ee(_e[0])),ce.key==="End"&&(ce.preventDefault(),ee(_e[_e.length-1])))},pe=s.useCallback(()=>{if(!T)return;const ce=T.service,Pe=w.current[ce];if(Pe!=null&&Pe.loading||Pe!=null&&Pe.component&&f)return;const _e=(i==null?void 0:i[ce])??c;if(!_e){H(Xe=>({...Xe,[ce]:{loading:!1,error:new Error(`No module loader found for service "${ce}".`)}}));return}const at=++te.current;H(Xe=>({...Xe,[ce]:{...Xe[ce],loading:!0,error:void 0}})),_e(T,o).then(Xe=>{if(at!==te.current&&!f)return;const Ct=dc(Xe);H(lt=>({...lt,[ce]:{component:Ct,loading:!1}}))}).catch(Xe=>{const Ct=Xe instanceof Error?Xe:new Error(String(Xe));H(lt=>({...lt,[ce]:{...lt[ce],loading:!1,error:Ct}}))})},[o,f,c,i,T]);s.useEffect(pe,[pe]);const ae=T?V[T.service]??null:null,ye=T?de[T.service]:void 0,Qe=ye==null?void 0:ye.component,Je=ce=>{T&&X(Pe=>({...Pe,[T.service]:ce}))},et=()=>{T&&X(ce=>({...ce,[T.service]:null}))},ft={context:o,parent:a,links:l,visibleLinks:U,filteredLinks:j,selectedLink:T,selectedService:T==null?void 0:T.service,activeItemId:ae,tabsSearch:B,onSelectService:ee,onOpenDetail:Je,onBackToList:et},nt=n?n(ft):r?t.jsx(r,{...ft}):e;return t.jsxs("section",{className:`grid min-h-[520px] gap-4 lg:grid-cols-[minmax(260px,360px)_minmax(0,1fr)] ${Y}`,children:[t.jsx("aside",{className:`min-w-0 rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-4 ${K}`,children:nt}),t.jsxs("div",{className:`relative min-w-0 overflow-visible rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${D}`,children:[(g||h||ue||_)&&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:[g&&t.jsx("h2",{className:"truncate text-sm font-semibold text-[var(--text-main)]",children:g}),h&&t.jsx("p",{className:"mt-1 line-clamp-2 text-xs text-[var(--text-muted)]",children:h})]}),(ue||_)&&t.jsxs("div",{className:"flex min-w-0 flex-shrink-0 items-center justify-end gap-2",children:[_&&t.jsxs("span",{className:"hidden text-xs font-semibold text-[var(--text-muted)] transition-opacity duration-200 sm:inline",children:[j.length," / ",U.length]}),ue&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:`origin-right overflow-hidden transition-[width,opacity,transform] duration-200 ease-out ${L?"w-[min(20rem,44vw)] translate-x-0 opacity-100":"w-0 translate-x-2 opacity-0"}`,"aria-hidden":!L,children:t.jsx(Qo,{value:B,onChange:fe,placeholder:N,className:"w-full",autoFocus:L,forceExpanded:!0,onEscape:()=>oe(!1),size:"sm",inputTabIndex:L?0:-1})}),t.jsx("button",{type:"button","aria-label":L?"Cerrar busqueda":"Buscar tabs","aria-expanded":L,onClick:()=>{L&&B&&fe(""),oe(ce=>!ce)},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 ${L||re?"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:L||re?t.jsx(W.HiXMark,{className:"h-4 w-4"}):t.jsx(W.HiMagnifyingGlass,{className:"h-4 w-4"})})})]})]})]})}),t.jsx("div",{role:"tablist","aria-label":g??"Modulos relacionados",className:`flex gap-1 overflow-x-auto border-b border-[var(--border)] bg-[var(--bg-input)] px-2 py-1.5 transition-colors duration-200 ${G}`,children:j.length>0?j.map(ce=>{const Pe=ce.service===(T==null?void 0:T.service);return t.jsx("button",{type:"button",role:"tab","aria-selected":Pe,disabled:ce.disabled,onClick:()=>ee(ce),onKeyDown:_e=>ie(_e,ce),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 ${Pe?"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:A?A(ce,Pe):t.jsxs(t.Fragment,{children:[ce.icon,t.jsx("span",{children:ce.label??ns(ce.service)}),ce.badge&&t.jsx("span",{className:"rounded-full bg-[var(--bg-input)] px-1.5 py-0.5 text-[10px] text-[var(--text-muted)]",children:ce.badge})]})},ce.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:k??"No hay modulos que coincidan con la busqueda."})}),(T==null?void 0:T.description)&&t.jsx("div",{className:"border-b border-[var(--border)] px-4 py-2 text-xs text-[var(--text-muted)]",children:T.description}),t.jsxs("div",{className:"min-h-[420px] p-4",children:[!T&&(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."})),T&&(ye==null?void 0:ye.loading)&&(v??t.jsx(rs,{title:"Cargando modulo..."})),T&&(ye==null?void 0:ye.error)&&S(ye.error,pe),T&&Qe&&!(ye!=null&&ye.loading)&&!(ye!=null&&ye.error)&&t.jsx(Qe,{context:o,parent:a,link:T,activeItemId:ae,onOpenDetail:Je,onBackToList:et})]})]})]})}const bc={info:{color:"#2563eb",background:"rgba(59, 130, 246, 0.1)",border:"rgba(59, 130, 246, 0.24)",icon:t.jsx(W.HiInformationCircle,{className:"h-5 w-5"})},success:{color:"#047857",background:"rgba(16, 185, 129, 0.1)",border:"rgba(16, 185, 129, 0.24)",icon:t.jsx(W.HiCheckCircle,{className:"h-5 w-5"})},warning:{color:"#b45309",background:"rgba(245, 158, 11, 0.12)",border:"rgba(245, 158, 11, 0.26)",icon:t.jsx(W.HiExclamationTriangle,{className:"h-5 w-5"})},danger:{color:"var(--danger)",background:"var(--danger-bg)",border:"color-mix(in srgb, var(--danger) 20%, var(--border))",icon:t.jsx(W.HiExclamationCircle,{className:"h-5 w-5"})},neutral:{color:"var(--text-secondary)",background:"var(--bg-input)",border:"var(--border)",icon:t.jsx(W.HiInformationCircle,{className:"h-5 w-5"})}};function mc({variant:e="info",title:r,children:n,icon:a,action:o,onDismiss:l,className:i=""}){const c=bc[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(Ve,{variant:"icon",size:"xs","aria-label":"Cerrar alerta",onClick:l,className:"-mr-1 -mt-1",children:t.jsx(W.HiXMark,{className:"h-4 w-4"})})]})}const os=["Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre"],pc=["Ene","Feb","Mar","Abr","May","Jun","Jul","Ago","Sep","Oct","Nov","Dic"],hc=["lu","ma","mi","ju","vi","sá","do"],ss=6;function Fa(e,r,n){return`${e}-${String(r).padStart(2,"0")}-${String(n).padStart(2,"0")}`}function gc(){const e=new Date;return Fa(e.getFullYear(),e.getMonth()+1,e.getDate())}function ls(e){const[r,n,a]=e.split("-").map(Number);return{year:r,month:n,day:a}}function vc(e){if(!e)return"Seleccionar fecha";const{year:r,month:n,day:a}=ls(e);return!r||!n||!a?"Seleccionar fecha":`${String(a).padStart(2,"0")} ${os[n-1]} ${r}`}function yc({value:e,onChange:r,minDate:n,displayMode:a="inline",className:o=""}){const l=gc(),c=ls(e||l),d=a==="popover",[u,m]=s.useState(!1),b=s.useRef(null),[f,g]=s.useState({horizontal:"left",vertical:"bottom"}),[h,E]=s.useState(c.year),[v,S]=s.useState(c.month),[A,C]=s.useState("days"),O=16,[N,y]=s.useState(0),M=h-7+N,k=Array.from({length:O},(R,V)=>M+V);s.useEffect(()=>{if(!d||!u||!b.current)return;const R=b.current.getBoundingClientRect(),V=8,X=280,de=340,H=R.left+X>window.innerWidth-V,I=R.right-X>=V,le=R.bottom+8+de>window.innerHeight-V,L=R.top-8-de>=V;g({horizontal:H&&I?"right":"left",vertical:le&&L?"top":"bottom"})},[d,u]),s.useEffect(()=>{if(!d||!u)return;function R(X){b.current&&(b.current.contains(X.target)||m(!1))}function V(X){X.key==="Escape"&&m(!1)}return document.addEventListener("mousedown",R),document.addEventListener("keydown",V),()=>{document.removeEventListener("mousedown",R),document.removeEventListener("keydown",V)}},[d,u]);function _(){v===1?(E(R=>R-1),S(12)):S(R=>R-1)}function Y(){v===12?(E(R=>R+1),S(1)):S(R=>R+1)}const K=(new Date(h,v-1,1).getDay()+6)%7,D=new Date(h,v,0).getDate(),G=[...Array(K).fill(null),...Array.from({length:D},(R,V)=>V+1)];for(;G.length<ss*7;)G.push(null);const U=G.slice(0,ss*7);function ne(R){const V=Fa(h,v,R);n&&V<n||(r(V),d&&m(!1))}const J=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:A==="days"?t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn",onClick:_,"aria-label":"Mes anterior",children:t.jsx(W.HiChevronLeft,{size:16})}),t.jsxs("button",{type:"button",className:"bonsaif-cal-title-btn",onClick:()=>{C("years"),y(0)},children:[t.jsxs("span",{className:"bonsaif-cal-title",children:[os[v-1]," ",h]}),t.jsx(W.HiChevronDown,{size:13})]}),t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn",onClick:Y,"aria-label":"Mes siguiente",children:t.jsx(W.HiChevronRight,{size:16})})]}):t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn",onClick:()=>y(R=>R-O),"aria-label":"Años anteriores",children:t.jsx(W.HiChevronLeft,{size:16})}),t.jsx("button",{type:"button",className:"bonsaif-cal-title-btn",onClick:()=>C("days"),children:t.jsxs("span",{className:"bonsaif-cal-title",children:[k[0]," – ",k[k.length-1]]})}),t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn",onClick:()=>y(R=>R+O),"aria-label":"Años siguientes",children:t.jsx(W.HiChevronRight,{size:16})})]})}),A==="years"?t.jsxs("div",{className:"bonsaif-cal-picker-years",children:[t.jsx("div",{className:"bonsaif-cal-picker-months",children:pc.map((R,V)=>{const X=V+1===v;return t.jsx("button",{type:"button",className:`bonsaif-cal-pill-btn${X?" is-active":""}`,onClick:()=>S(V+1),children:R},R)})}),t.jsx("div",{className:"bonsaif-cal-picker-year-grid",children:k.map(R=>{const V=R===h,X=R===new Date().getFullYear();return t.jsx("button",{type:"button",className:`bonsaif-cal-pill-btn${V?" is-active":""}${X&&!V?" is-today":""}`,onClick:()=>{E(R),C("days")},children:R},R)})})]}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"bonsaif-multi-weekdays bonsaif-cal-picker-weekdays",children:hc.map(R=>t.jsx("div",{className:"bonsaif-multi-weekday",children:R},R))}),t.jsx("div",{className:"bonsaif-cal-picker-days",children:U.map((R,V)=>{if(R===null)return t.jsx("div",{className:"bonsaif-multi-day bonsaif-multi-day-hidden"},V);const X=Fa(h,v,R),de=X===e,H=X===l,I=!!(n&&X<n);return t.jsx("div",{className:`bonsaif-multi-day${de?" bonsaif-multi-day-selected":""}${H?" bonsaif-multi-day-today":""}${I?" bonsaif-multi-day-disabled":""}`,children:t.jsx("button",{type:"button",className:"bonsaif-multi-day-btn",disabled:I,"aria-pressed":de,onClick:()=>!I&&ne(R),children:R})},V)})})]})]})});return d?t.jsxs("div",{ref:b,className:`relative w-full ${o}`.trim(),children:[t.jsxs("button",{type:"button",onClick:()=>m(R=>!R),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(W.HiCalendarDays,{className:"w-4 h-4 text-[var(--text-muted)]"}),t.jsx("span",{className:"truncate",children:vc(e)})]}),t.jsx(W.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:J})]}):J}function qt({children:e,className:r="",style:n,as:a="span",followCursor:o=!1,placement:l="top"}){return t.jsx(Bt,{onlyWhenOverflow:!0,as:a,followCursor:o,placement:l,showArrow:!o,className:r,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",minWidth:0,...n},children:e})}function Pa(e){if(e!==void 0)return typeof e=="number"?`${e}px`:e}function _a(e){return e.normalize("NFD").replace(new RegExp("\\p{M}","gu"),"").toLowerCase()}function xc(e,r){if(!r.trim())return!0;const n=_a(r);return _a(e.label).includes(n)||!!(e.sublabel&&_a(e.sublabel).includes(n))}function dr({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:b,dropdownMinWidth:f,height:g=40,padding:h="0 10px",searchable:E=!0,minOptionsForSearch:v=6}){const[S,A]=s.useState(!1),[C,O]=s.useState(""),[N,y]=s.useState(-1),[M,k]=s.useState(!1),[_,Y]=s.useState({}),K=s.useRef(null),D=s.useRef(null),G=s.useRef(null),U=s.useRef(null),ne=E&&n.length>=v,J=n.find(B=>B.value===e)??null,R=l==="ghost",V=a==="error"?"var(--danger)":S?"var(--primary)":"var(--border)",X=ne&&C.trim()?n.filter(B=>xc(B,C)):n,de=s.useCallback(()=>{const B=K.current;if(!B)return;const F=B.getBoundingClientRect(),ue=ne?272:212,re=window.innerHeight-F.bottom,j=re<ue&&F.top>re;Y({position:"fixed",left:F.left,top:j?void 0:F.bottom+4,bottom:j?window.innerHeight-F.top+4:void 0,width:F.width,minWidth:Pa(f),zIndex:9999})},[f,ne]);s.useEffect(()=>k(!0),[]),s.useEffect(()=>{if(!S)return;function B(F){var re,j;const ue=F.target;!((re=K.current)!=null&&re.contains(ue))&&!((j=D.current)!=null&&j.contains(ue))&&(A(!1),O(""))}return document.addEventListener("mousedown",B),()=>document.removeEventListener("mousedown",B)},[S]),s.useEffect(()=>{S&&(y(-1),de(),ne&&setTimeout(()=>{var B;return(B=G.current)==null?void 0:B.focus()},0))},[S,ne,de]),s.useEffect(()=>{if(S)return window.addEventListener("resize",de),window.addEventListener("scroll",de,!0),()=>{window.removeEventListener("resize",de),window.removeEventListener("scroll",de,!0)}},[S,de]),s.useEffect(()=>{if(N<0||!U.current)return;const B=U.current.children[N];B==null||B.scrollIntoView({block:"nearest"})},[N]);const H=s.useCallback(B=>{r(B),A(!1),O("")},[r]),I=s.useRef(S);I.current=S;const le=s.useRef(X);le.current=X;const L=s.useRef(N);L.current=N;const oe=s.useRef(d);oe.current=d;const w=s.useRef(H);w.current=H,s.useEffect(()=>{function B(F){var x,T;const ue=document.activeElement,re=((x=K.current)==null?void 0:x.contains(ue))??!1,j=((T=D.current)==null?void 0:T.contains(ue))??!1;if(!(!re&&!j)){if(!I.current){(F.key==="Enter"||F.key===" "||F.key==="ArrowDown")&&(F.preventDefault(),A(!0));return}switch(F.key){case"ArrowDown":F.preventDefault(),y(ee=>Math.min(ee+1,le.current.length-1));break;case"ArrowUp":F.preventDefault(),y(ee=>Math.max(ee-1,oe.current?-1:0));break;case"Enter":{F.preventDefault();const ee=L.current,fe=le.current;ee===-1&&oe.current?w.current(""):fe[ee]&&!fe[ee].disabled&&w.current(fe[ee].value);break}case"Escape":F.preventDefault(),F.stopPropagation(),A(!1),O("");break}}}return document.addEventListener("keydown",B),()=>document.removeEventListener("keydown",B)},[]);const te=t.jsxs("div",{ref:D,"data-bonsaif-select-dropdown":"true",className:"rounded-xl shadow-xl overflow-hidden",style:{..._,background:"var(--bg-card)",border:"1px solid var(--border)"},children:[ne&&t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",style:{borderBottom:"1px solid var(--border)"},children:[t.jsx(W.HiMagnifyingGlass,{className:"w-3.5 h-3.5 flex-shrink-0",style:{color:"var(--text-muted)"}}),t.jsx("input",{ref:G,value:C,onChange:B=>{O(B.target.value),y(-1)},placeholder:"Buscar…",className:"min-w-0 flex-1 text-sm bg-transparent outline-none",style:{color:"var(--text-main)"}}),C&&t.jsx("button",{type:"button",onMouseDown:B=>{B.preventDefault(),O("")},children:t.jsx(W.HiXMark,{className:"w-3.5 h-3.5",style:{color:"var(--text-muted)"}})})]}),t.jsxs("ul",{ref:U,role:"listbox",className:"overflow-y-auto",style:{maxHeight:ne?220:180,scrollbarWidth:"thin",scrollbarColor:"var(--border) transparent",overscrollBehavior:"contain"},children:[d&&t.jsx("li",{role:"option","aria-selected":e==="",onMouseDown:B=>{B.preventDefault(),H("")},onMouseEnter:()=>y(-1),className:"flex items-center gap-2 px-3 py-2 cursor-pointer text-sm transition-colors",style:{background:N===-1&&!C.trim()?"var(--bg-hover)":"transparent",color:"var(--text-muted)",fontStyle:"italic"},children:d}),X.map((B,F)=>{const re=F===N,j=B.value===e;return t.jsxs("li",{role:"option","aria-selected":j,onMouseDown:x=>{x.preventDefault(),B.disabled||H(B.value)},onMouseEnter:()=>!B.disabled&&y(F),className:"flex items-center gap-2 px-3 py-2 cursor-pointer text-sm transition-colors",style:{background:re?"var(--bg-hover)":j?"color-mix(in srgb, var(--primary) 6%, transparent)":"transparent",color:B.disabled?"var(--text-muted)":"var(--text-main)",cursor:B.disabled?"not-allowed":"pointer",boxShadow:j?"inset 2px 0 0 var(--primary)":void 0},children:[B.color&&t.jsx("span",{className:"flex-shrink-0 w-2.5 h-2.5 rounded-full",style:{background:B.color}}),t.jsxs("span",{className:"min-w-0 flex flex-1 items-baseline gap-1 overflow-hidden",children:[t.jsx(qt,{className:"min-w-0 flex-1",children:B.label}),B.sublabel&&t.jsx(qt,{className:"min-w-0 flex-shrink",style:{color:"var(--text-muted)",fontSize:12},children:B.sublabel})]}),B.badge&&t.jsx("span",{className:"text-xs flex-shrink-0",style:{color:"var(--text-muted)"},children:B.badge})]},B.value)}),X.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:K,className:`relative ${m||"w-full"}`,style:b,children:[t.jsxs("button",{type:"button",disabled:u,onClick:()=>!u&&A(B=>!B),className:"flex w-full items-center gap-2 rounded-lg text-left text-sm transition-colors focus:outline-none",style:{height:Pa(g),padding:Pa(h),background:R?"transparent":"var(--bg-input)",color:J?"var(--text-main)":"var(--text-muted)",border:R?"1px solid transparent":`1px solid ${V}`,opacity:u?.5:1,cursor:u?"not-allowed":"pointer"},"aria-haspopup":"listbox","aria-expanded":S,"aria-label":o,children:[(J==null?void 0:J.color)&&t.jsx("span",{className:"flex-shrink-0 w-2.5 h-2.5 rounded-full",style:{background:J.color}}),t.jsx("span",{className:"min-w-0 flex flex-1 items-baseline gap-1 overflow-hidden",children:J?t.jsxs(t.Fragment,{children:[t.jsx(qt,{className:"min-w-0 flex-1",children:J.label}),i&&J.sublabel&&t.jsx(qt,{className:"min-w-0 flex-shrink",style:{color:"var(--text-muted)",fontSize:12},children:J.sublabel})]}):t.jsx(qt,{className:"min-w-0 flex-1",children:c})}),J&&d?t.jsx("span",{role:"button",tabIndex:-1,onMouseDown:B=>{B.preventDefault(),B.stopPropagation(),H("")},className:"flex-shrink-0 rounded-full p-0.5 transition-colors hover:bg-black/10",style:{color:"var(--text-muted)"},children:t.jsx(W.HiXMark,{className:"w-3 h-3"})}):t.jsx(W.HiChevronDown,{className:"flex-shrink-0 w-4 h-4 transition-transform",style:{color:"var(--text-muted)",transform:S?"rotate(180deg)":"rotate(0deg)"}})]}),S&&M&&ht.createPortal(te,document.body)]})}const wc={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 Mn=s.forwardRef(function({label:r,description:n,error:a,size:o="md",indeterminate:l=!1,className:i="",containerClassName:c="",disabled:d,...u},m){const b=s.useRef(null);return s.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 ${wc[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(W.HiCheck,{className:"pointer-events-none absolute left-1/2 top-1/2 h-3.5 w-3.5 -translate-x-1/2 -translate-y-1/2 scale-75 text-[var(--primary-fg)] opacity-0 transition peer-checked:scale-100 peer-checked:opacity-100 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})]})]})}),is=32767;function Tn(e){let r=String(e??"");return r=r.split("\0").join(""),r.length<=is?r:`${r.slice(0,is-1)}…`}const $n=[25,50,100,200,500];let At={dataTable:{pageSizeOptions:[...$n]}};function kc(){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 za(){const e=At.dataTable.preferencesEndpoint,r=kc();return e&&e.trim().length>0?e.trim().replace(/\/+$/,""):r}function Sc(e){if(!Array.isArray(e))return[...$n];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:[...$n]}function cs(e){if(typeof e!="string")return;const r=e.trim();if(r)return r.replace(/\/+$/,"")}function Ec(e){if(!e||typeof e!="object"||!e.dataTable)return;const r=cs(e.dataTable.preferencesEndpoint);At={...At,dataTable:{...At.dataTable,pageSizeOptions:Sc(e.dataTable.pageSizeOptions),preferencesEndpoint:r??At.dataTable.preferencesEndpoint}}}function Cc(){return{dataTable:{pageSizeOptions:[...At.dataTable.pageSizeOptions]}}}function Qr(){return[...At.dataTable.pageSizeOptions]}function Mc(){At={dataTable:{pageSizeOptions:[...$n]}}}function Tc(e){At={...At,dataTable:{...At.dataTable,preferencesEndpoint:cs(e)}}}const An=[{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"}],$c=An.map(e=>({value:e.value,label:e.label})),Ac=12,Lc={layout:!0,filters:!1,sort:!1,bql:!1,pagination:!0},ds={layout:!0,filters:!0,sort:!0,bql:!0,pagination:!0},Dc="bonsaif-ui:datatable:",Oc="[&_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",Hc=[],Ic=52;function Ut(e){if(!e)return 150;const r=parseInt(e,10);return isNaN(r)||r<=0?150:r}function us(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 fs(e){return`${Dc}${e}`}function Ln(e){try{const r=window.localStorage.getItem(fs(e));if(!r)return null;const n=JSON.parse(r);return n&&typeof n=="object"?n:null}catch{return null}}function Bc(e,r){try{window.localStorage.setItem(fs(e),JSON.stringify(r))}catch{}}function Fc(e,r){if(e===!0)return{...ds};if(e===!1)return{layout:!1,filters:!1,sort:!1,bql:!1,pagination:!1};if(r&&e==null)return{...ds};const n={...Lc,...e??{}};return r&&(typeof e!="object"||e.pagination!==!1)&&(n.pagination=!0),n}function bs(...e){return e.reduce((r,n)=>({...r,...n??{}}),{})}function Wa(e,r,n){return typeof e!="number"||e<=0?n:rn(r).includes(e)?e:n}function Jr(e){if(!e||typeof e!="object")return!1;const r=e;return typeof r.key=="string"&&(r.dir==="asc"||r.dir==="desc")}function Rr(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 en(e,r){if(!e||typeof e!="object"||Array.isArray(e))return{};const n=new Set(An.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 xt(e,r){if(ur(e))return Ic;const n=e.minWidth??80,a=e.maxWidth??1/0;return Math.min(a,Math.max(n,r))}function Pc(e){const r=window.getComputedStyle(e);return parseFloat(r.paddingLeft)+parseFloat(r.paddingRight)}function ur(e){return e.key==="actions"||e.key==="acciones"?!0:typeof e.header=="string"&&e.header.trim().toLowerCase()==="acciones"}function ja(e){return e.sticky===!0}function ms(e){return!(e.reorderable===!1||e.sticky&&e.reorderable!==!0)}function Dn(e,r){const a=[...e.filter(o=>r.includes(o))];for(let o=0;o<r.length;o+=1){const l=r[o];if(a.includes(l))continue;let i=a.length;for(let c=o-1;c>=0;c-=1){const d=r[c],u=a.indexOf(d);if(u!==-1){i=u+1;break}}if(i===a.length)for(let c=o+1;c<r.length;c+=1){const d=r[c],u=a.indexOf(d);if(u!==-1){i=u;break}}a.splice(i,0,l)}return a}function Qt(e,r){const n=r.filter(ja).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 _c(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 Jt(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 zc(e){return e==null||e===""?"(Vacio)":e instanceof Date?e.toLocaleDateString():String(e)}function kr(e){return e==null||typeof e=="boolean"?"":typeof e=="string"||typeof e=="number"?String(e):Array.isArray(e)?e.map(kr).join(" ").trim():s.isValidElement(e)?kr(e.props.children):""}function On(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?zc(n):kr(n).trim()}function tn(e){const r=e.replace(/,/g,"").trim();if(!r)return null;const n=Number(r);return Number.isFinite(n)?n:null}function Sr(e,r){const n=tn(e),a=tn(r);return n!==null&&a!==null?n-a:e.localeCompare(r,void 0,{numeric:!0,sensitivity:"base"})}function rn(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:Qr()}function Wc(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=An.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 Sr(e,a)>0;case"greaterThanOrEqual":return Sr(e,a)>=0;case"lessThan":return Sr(e,a)<0;case"lessThanOrEqual":return Sr(e,a)<=0;case"between":return Sr(e,a)>=0&&Sr(e,o)<=0;case"top10":case"bottom10":{const u=n.map(b=>({value:b,number:tn(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(tn).filter(b=>b!==null);if(d.length===0)return!1;const u=d.reduce((b,f)=>b+f,0)/d.length,m=tn(e);return m===null?!1:r.operator==="aboveAverage"?m>u:m<u}default:return!0}}function ps({children:e,className:r="",style:n}){return t.jsx(Bt,{onlyWhenOverflow:!0,className:r,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,...n},children:e})}function qa({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:b,defaultExpandedRowIds:f=[],onExpandedRowIdsChange:g,expandOnRowClick:h=!1,selected:E,onToggleOne:v,onToggleAll:S,getRowSelectable:A,highlightSelected:C=!0,rowClassName:O,getRowCategory:N,stickyHeader:y=!0,pageSize:M=25,pageSizeOptions:k,pageSizeSelectWidth:_=62,pageSizeSelectHeight:Y=30,pageSizeSelectPadding:K="0 7px",totalRows:D,page:G,onPageChange:U,onPageSizeChange:ne,storageKey:J,stickyFirstColumn:R=!1,bottomOffset:V=0,compact:X=!0,restrictHeight:de=!0,maxHeight:H,minTableWidth:I,enableColumnVisibility:le=!0,enableColumnFilters:L=!0,hiddenColumnKeys:oe,defaultHiddenColumnKeys:w=Hc,onHiddenColumnKeysChange:te,columnVisibilityLabel:B="Columnas",enableBql:F=!1,bqlValue:ue,defaultBqlValue:re="",onBqlChange:j,bqlDescription:x="Filtra registros con Bonsaif Query Language",bqlPlaceholder:T=`status = activo
|
|
2
|
-
rol IN (admin, employee)`,bqlQuickFilters:
|
|
3
|
-
`).map(
|
|
4
|
-
${$}`;Po(P,Oo.current??void 0),requestAnimationFrame(()=>{const se=Oo.current;if(!se)return;se.focus();const ve=se.value.length;se.setSelectionRange(ve,ve),Po(se.value,se)})}s.useEffect(()=>{De(xe)},[xe]);const ka=s.useCallback(()=>{const p=Do.current;if(!p)return;const $=p.getBoundingClientRect(),Q=12,P=8,se=Math.min(780,Math.max(320,window.innerWidth-32)),ve=Math.max(Q,window.innerWidth-se-Q),Ce=Math.min(Math.max(Q,$.left),ve),Te=$.bottom+P,We=window.innerHeight-$.top+P,Ue=window.innerHeight-Te-Q,yt=$.top-Q-P,tt=Ue<280&&yt>Ue,we=Math.max(240,tt?yt:Ue);Qb({position:"fixed",zIndex:1e4,left:Ce,top:tt?void 0:Te,bottom:tt?We:void 0,width:se,maxWidth:"calc(100vw - 24px)",maxHeight:we,overflowY:"auto"})},[]);s.useEffect(()=>{if(!Ye)return;function p(P){var ve,Ce;if(Date.now()<gi.current)return;const se=P.target;(ve=Do.current)!=null&&ve.contains(se)||(Ce=hi.current)!=null&&Ce.contains(se)||(Ke(!1),vt(!1),Ht(!1))}function $(P){P.key==="Escape"&&(Ke(!1),vt(!1),Ht(!1))}function Q(){ka()}return ka(),document.addEventListener("mousedown",p),window.addEventListener("keydown",$),window.addEventListener("resize",Q),window.addEventListener("scroll",Q,!0),()=>{document.removeEventListener("mousedown",p),window.removeEventListener("keydown",$),window.removeEventListener("resize",Q),window.removeEventListener("scroll",Q,!0)}},[Ye,ka]);function Ai(p){const $=Jt(p,e);Oe||ct($),te==null||te($)}function pm(p){Ai(ze.includes(p)?ze.filter($=>$!==p):[...ze,p])}function hm(){Ai([])}const _o=s.useCallback((p=ga.current)=>{if(!p)return;const $=p.getBoundingClientRect(),Q=Math.min(292,Math.max(240,window.innerWidth-16)),P=Math.max(8,window.innerWidth-Q-8),se=Math.min(Math.max(8,$.right-Q),P),ve=window.innerHeight-$.bottom,Ce=$.bottom+6,Te=window.innerHeight-$.top+6,Ue=ve<360&&$.top>ve?void 0:Ce,yt=Ue===void 0?Te:void 0,tt=Math.max(220,Ue===void 0?$.top-16:window.innerHeight-Ce-8),we={position:"fixed",zIndex:9999,left:se,top:Ue,bottom:yt,width:Q,maxWidth:"calc(100vw - 16px)",maxHeight:tt,"--dt-column-menu-max-height":`${tt}px`};Rb(we)},[]);function Li(p,$,Q=null){p.preventDefault(),p.stopPropagation();const P=ga.current===p.currentTarget&&mt===$&&ut===Q;if(je&&P){dt(!1),Be(null);return}ga.current=p.currentTarget,br($),Be(Q),fa(""),_o(p.currentTarget),dt(!0)}function gm(p){if(ur(p))return;const $=lr.current;if(!$)return;const P=Array.from($.querySelectorAll("[data-dt-column-key]")).filter(se=>se.dataset.dtColumnKey===p.key).reduce((se,ve)=>{const Ce=ve.querySelector("[data-dt-autofit-content]"),Te=Ce?Ce.scrollWidth:Math.max(ve.scrollWidth,ve.offsetWidth);return Math.max(se,Math.ceil(Te+Pc(ve)))},0);P<=0||Vr(se=>({...se,[p.key]:xt(p,P+12)}))}s.useEffect(()=>{Vr(p=>{const $=Object.fromEntries(e.map(Q=>[Q.key,xt(Q,Ut(Q.width))]));return Object.fromEntries(e.map(Q=>[Q.key,xt(Q,p[Q.key]??$[Q.key])]))})},[_e,e]),s.useEffect(()=>{Oe||ct(p=>Jt(p,e))},[_e,e,Oe]),s.useEffect(()=>{function p(P){var Ce,Te;const se=P.target,ve=P.target;ve!=null&&ve.closest("[data-bonsaif-select-dropdown='true']")||!((Ce=vi.current)!=null&&Ce.contains(se))&&!((Te=ga.current)!=null&&Te.contains(se))&&(dt(!1),Be(null))}function $(P){P.key==="Escape"&&(dt(!1),Be(null))}function Q(){_o()}return je&&(document.addEventListener("mousedown",p),window.addEventListener("keydown",$),window.addEventListener("resize",Q),window.addEventListener("scroll",Q,!0)),()=>{document.removeEventListener("mousedown",p),window.removeEventListener("keydown",$),window.removeEventListener("resize",Q),window.removeEventListener("scroll",Q,!0)}},[je,_o]);const xn=s.useRef(null);s.useEffect(()=>{function p(Q){const P=xn.current;if(!P)return;const se=Q.clientX-P.startX,ve=e.find(Ce=>Ce.key===P.colKey);ve&&Vr(Ce=>({...Ce,[P.colKey]:xt(ve,P.startWidth+se)}))}function $(){xn.current&&(xn.current=null,document.body.style.cursor="",document.body.style.userSelect="")}return document.addEventListener("pointermove",p),document.addEventListener("pointerup",$),()=>{document.removeEventListener("pointermove",p),document.removeEventListener("pointerup",$)}},[e]);const wn=s.useRef(null),[Di,zo]=s.useState(null);function vm(p,$){const Q=e.find(P=>P.key===p);if(!Q||!ms(Q)){$.preventDefault();return}wn.current=qr.indexOf(p),$.dataTransfer.effectAllowed="move"}function ym(p,$){$.preventDefault(),$.dataTransfer.dropEffect="move";const Q=qr.indexOf(p);Di!==Q&&zo(Q)}function xm(p,$){$.preventDefault();const Q=wn.current,P=qr.indexOf(p);Q!==null&&Q!==P&&Ur(se=>{const ve=[...se],[Ce]=ve.splice(Q,1);return ve.splice(P,0,Ce),Qt(ve,e)}),wn.current=null,zo(null)}function wm(){wn.current=null,zo(null)}function Nm(p){p.sortKey&&hr($=>($==null?void 0:$.key)===p.key?{key:p.key,dir:$.dir==="asc"?"desc":"asc"}:{key:p.key,dir:"asc"})}s.useEffect(()=>{va(1)},[r]),s.useEffect(()=>{va(1)},[Tt,pt]);const Wt=!!(U&&ne),ir=M!==!1,Wo=s.useMemo(()=>rn(k??Qr()),[k]),st=Wt?G??1:lm,Oi=ir&&ya<1?typeof M=="number"&&M>0?M:Wo[0]??25:ya,jt=Wt||ir?Oi:r.length,It=!!E&&!!v&&!!S,jo=s.useMemo(()=>A?r.filter(p=>A(p)):r,[r,A]),Xr=!!u,Hi=s.useMemo(()=>new Set(Wr?Array.from(b??[]):z),[Wr,b,z]),km=(Xr?40:0)+(It?40:0),qo=!om&&(Si||R),Sa=(()=>{if(!qo)return{};let p=km;const $={};return $t.forEach((Q,P)=>{(ja(Q)||!Si&&R&&P===0)&&($[Q.key]=p,p+=pr[Q.key]??xt(Q,Ut(Q.width)))}),$})(),Uo=Object.keys(Sa),Vo=Uo.length>0?Uo[Uo.length-1]:null,Ii=It&&jo.length>0&&jo.every(p=>E.has(n(p))),Sm=It&&E.size>0&&jo.some(p=>E.has(n(p)))&&!Ii,Ea=s.useMemo(()=>{if(Wt)return r;const p=Object.entries(pt),$=Object.entries(Tt);return p.length===0&&$.length===0?r:r.filter(Q=>p.every(([P,se])=>{const ve=e.find(Ce=>Ce.key===P);return ve?se.includes(On(ve,Q)):!0})&&$.every(([P,se])=>{const ve=e.find(Te=>Te.key===P);if(!ve)return!0;const Ce=r.map(Te=>On(ve,Te));return Wc(On(ve,Q),se,Ce)}))},[Tt,pt,e,r,Wt]),gr=s.useMemo(()=>{if(!Ge)return Ea;const p=e.find($=>$.key===Ge.key&&$.sortKey);return p!=null&&p.sortKey?[...Ea].sort(($,Q)=>{const P=$[p.sortKey],se=Q[p.sortKey],ve=P===se?0:P==null?1:se==null||P<se?-1:1;return Ge.dir==="asc"?ve:-ve}):Ea},[Ea,Ge,e]),Bi=s.useMemo(()=>{if(Wt||!ir)return gr;const p=(st-1)*jt;return gr.slice(p,p+jt)},[gr,Wt,ir,st,jt]),Gt=Wt?D??r.length:gr.length,Xo=ir?Math.max(1,Math.ceil(Gt/jt)):1,Em=Math.min(...Wo),Cm=ir&&(Gt>jt||Gt>Em),Mm=ir?(st-1)*jt+1:1,Tm=ir?Math.min(st*jt,Gt):Gt;function Yo(p){if(a)return;const $=Math.max(1,Math.min(p,Xo));Wt?U($):va($)}function $m(p){a||(J&&(mr.current=J),xa(p),Wt?(ne(p),U(1)):(va(1),ne==null||ne(p)))}function Fi(p){const $=new Set(Hi);$.has(p)?$.delete(p):$.add(p);const Q=Array.from($);Wr||Z(Q),g==null||g(Q)}s.useEffect(()=>{ye==null||ye({bql:xe,filters:pt,conditionFilters:Tt,sort:Ge,page:st,pageSize:jt,hiddenColumnKeys:ze})},[xe,pt,Tt,Ge,st,jt,ze,ye]);const Pi=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))",Ko="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%)",Ie="color-mix(in srgb, var(--border) 62%, var(--bg-card))",vr="color-mix(in srgb, var(--primary) 24%, var(--border))",Ca=`inset 0 0 0 1px ${Ie}`,_i=$t.reduce((p,$)=>p+(pr[$.key]??Ut($.width)),(Xr?40:0)+(It?40:0)),zi=typeof I=="number"?I:typeof I=="string"?Number(((Xi=I.match(/^(\d+(?:\.\d+)?)px$/))==null?void 0:Xi[1])??NaN):NaN,Nn=Number.isFinite(zi)?Math.max(_i,zi,wi):Math.max(_i,wi),Ma=I??Nn,Yr=`${Xr?"40px ":""}${It?"40px ":""}${$t.map(p=>`${pr[p.key]??Ut(p.width)}px`).join(" ")}`;s.useEffect(()=>{Ge&&ze.includes(Ge.key)&&hr(null)},[ze,Ge]);function Wi(p){return p?typeof p=="string"?{key:p,label:p}:p:null}const Ta=()=>t.jsxs("div",{role:"row",className:"grid",style:{gridTemplateColumns:Yr,background:Ko,borderBottom:`1px solid ${vr}`},children:[Xr&&t.jsx("div",{role:"columnheader",className:`${X?"px-2 py-1.5":"px-3 py-2.5"} w-10`,style:{borderBottom:`1px solid ${vr}`,borderRight:`1px solid ${Ie}`}}),It&&t.jsx("div",{role:"columnheader",className:`${X?"px-2 py-1.5":"px-3 py-2.5"} flex w-10 items-center justify-center`,style:qo?{position:"sticky",left:0,zIndex:12,background:Ko,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)",boxShadow:`inset 0 -1px 0 ${vr}`,borderRight:`1px solid ${Ie}`}:{borderBottom:`1px solid ${vr}`,borderRight:`1px solid ${Ie}`},children:t.jsx(Mn,{size:"sm",checked:Ii,indeterminate:Sm,onChange:S,"aria-label":"Seleccionar todos",containerClassName:"items-center",className:"cursor-pointer"})}),$t.map((p,$)=>{const Q=(Ge==null?void 0:Ge.key)===p.key,P=!!p.sortKey,se=ur(p),ve=Sa[p.key],Ce=ve!==void 0,Te=p.key===Vo,We=ms(p),Ue=Di===$,tt=(pr[p.key]??Ut(p.width))<120,we=Object.prototype.hasOwnProperty.call(pt,p.key)||Object.prototype.hasOwnProperty.call(Tt,p.key);return t.jsxs("div",{role:"columnheader","data-dt-column-key":p.key,className:`group select-none ${tt?"text-left":Pi(p.align)}`,style:{...Ce?{position:"sticky",left:ve,zIndex:12,background:Ko,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)",boxShadow:Te?`3px 0 6px -2px rgba(0,0,0,0.10), inset 0 -1px 0 ${vr}`:`inset 0 -1px 0 ${vr}`,borderRight:`1px solid ${Ie}`}:{position:"relative",borderBottom:`1px solid ${vr}`,borderRight:`1px solid ${Ie}`},color:Q?"var(--primary)":"var(--text-muted)",whiteSpace:"nowrap",transition:"color 0.15s",borderLeft:Ue?"2px solid var(--primary)":"2px solid transparent",cursor:"default",padding:se?X?"7px 6px":"9px 8px":X?"8px 6px 10px":"10px 8px 12px"},onDragOver:$e=>{(We||wn.current!==null)&&ym(p.key,$e)},onDrop:$e=>xm(p.key,$e),children:[t.jsxs("div",{className:`flex min-w-0 items-center gap-1 ${se?"justify-center":tt?"justify-start":p.align==="center"?"justify-center":p.align==="right"?"justify-end":"justify-start"}`,children:[We?t.jsx("span",{draggable:!0,onDragStart:$e=>{$e.stopPropagation(),vm(p.key,$e)},onDragEnd:$e=>{$e.stopPropagation(),wm()},onClick:$e=>$e.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,se?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(W.HiCog6Tooth,{className:"h-3.5 w-3.5"})}):t.jsx(ps,{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 ${X?"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:$e=>{$e.stopPropagation(),Nm(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 ${Q?"opacity-100":"opacity-0 group-hover:opacity-100 group-focus-within:opacity-100"}`,style:{bottom:"-0.5rem",top:"auto"},children:Q?Ge.dir==="asc"?t.jsx(W.HiChevronUp,{className:"h-3 w-3"}):t.jsx(W.HiChevronDown,{className:"h-3 w-3"}):t.jsx(W.HiChevronUpDown,{className:"h-3 w-3"})}),L&&!se&&um(p)&&t.jsx("button",{type:"button","aria-haspopup":"menu","aria-expanded":je&&ut===p.key,"aria-label":`Filtrar ${String(p.header)}`,title:"Filtrar",onClick:$e=>Li($e,"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 ${je&&mt==="filter"&&ut===p.key?"bg-[var(--bg-card)] text-[var(--primary)] opacity-100":we?"text-[var(--primary)] opacity-100":""}`,children:we?t.jsx(W.HiFunnel,{className:"h-3.5 w-3.5"}):t.jsx(W.HiEllipsisVertical,{className:"h-3.5 w-3.5"})})]}),!se&&t.jsx("span",{role:"separator","aria-orientation":"vertical",title:"Arrastrar para redimensionar. Doble click para autoajustar",onPointerDown:$e=>{$e.preventDefault(),$e.stopPropagation(),xn.current={colKey:p.key,startX:$e.clientX,startWidth:pr[p.key]??150},document.body.style.cursor="col-resize",document.body.style.userSelect="none"},onDoubleClick:$e=>{$e.preventDefault(),$e.stopPropagation(),xn.current=null,document.body.style.cursor="",document.body.style.userSelect="",gm(p)},onClick:$e=>$e.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)})]}),$a=()=>{if(!je||typeof document>"u"||mt==="visibility"&&!le||mt==="filter"&&!L)return null;const p=e.find(we=>we.key===ut),$=dm(),Q=p?Object.prototype.hasOwnProperty.call(pt,p.key):!1,P=p?Tt[p.key]:void 0,se=An.find(we=>we.value===(P==null?void 0:P.operator)),ve=p?pt[p.key]??[]:[],Ce=vn.trim().toLowerCase(),Te=Ce?$.filter(we=>we.label.toLowerCase().includes(Ce)):$,We=p&&$.length>0&&(!Q||ve.length===$.length),Ue=p&&Q&&ve.length>0&&ve.length<$.length,yt=ze.length,tt=()=>{p&&(Fo(p.key),Mi(p.key))};return ht.createPortal(t.jsx("div",{ref:vi,role:"menu",className:"overflow-hidden rounded-lg border p-1 shadow-xl",style:{...Jb,borderColor:"var(--border)",background:"var(--bg-card)"},children:mt==="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:yt>0?`${$t.length} de ${e.length} visibles`:`${e.length} visibles`}),t.jsx("button",{type:"button",onClick:hm,disabled:yt===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:ki.map(we=>{const $e=!ze.includes(we.key),Ne=!(we.hideable!==!1)||$e&&$t.length<=1;return t.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":$e,disabled:Ne,onClick:()=>pm(we.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:$e?"var(--primary)":"var(--border)",background:$e?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:$e&&t.jsx(W.HiCheck,{className:"h-3 w-3"})}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:we.header})]},we.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:tt,disabled:!Q&&!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:()=>hr({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(W.HiChevronUp,{className:"h-4 w-4 shrink-0 text-[var(--primary)]"}),t.jsx("span",{className:"truncate",children:"Ascendente"})]}),(Ge==null?void 0:Ge.key)===p.key&&Ge.dir==="asc"&&t.jsx(W.HiCheck,{className:"h-4 w-4 shrink-0 text-[var(--primary)]"})]}),t.jsxs("button",{type:"button",onClick:()=>hr({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(W.HiChevronDown,{className:"h-4 w-4 shrink-0 text-[var(--primary)]"}),t.jsx("span",{className:"truncate",children:"Descendente"})]}),(Ge==null?void 0:Ge.key)===p.key&&Ge.dir==="desc"&&t.jsx(W.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(dr,{value:(P==null?void 0:P.operator)??"",onChange:we=>{if(!we){Mi(p.key);return}wa(p.key,{operator:we,value:(P==null?void 0:P.value)??"",valueTo:(P==null?void 0:P.valueTo)??""})},options:$c,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"}),(se==null?void 0:se.valueMode)!=="none"?t.jsx("input",{value:(P==null?void 0:P.value)??"",onChange:we=>{P&&wa(p.key,{...P,value:we.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"})]}),(se==null?void 0:se.valueMode)==="between"&&t.jsx("input",{value:(P==null?void 0:P.valueTo)??"",onChange:we=>{P&&wa(p.key,{...P,valueTo:we.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(W.HiMagnifyingGlass,{className:"h-4 w-4 shrink-0 text-[var(--text-muted)]"}),t.jsx("input",{value:vn,onChange:we=>fa(we.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":!!We,onClick:()=>{p&&(We&&!Q?Ci(p.key,[]):Fo(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:We||Ue?"var(--primary)":"var(--border)",background:We||Ue?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:[Ue&&t.jsx(W.HiMinus,{className:"h-3 w-3"}),We&&!Ue&&t.jsx(W.HiCheck,{className:"h-3 w-3"})]}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:"Seleccionar todo"})]}),Te.map(we=>{const $e=!Q||ve.includes(we.value);return t.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":$e,onClick:()=>fm(p.key,we.value,$.map(Se=>Se.value),Q),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:$e?"var(--primary)":"var(--border)",background:$e?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:$e&&t.jsx(W.HiCheck,{className:"h-3 w-3"})}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:we.label})]},we.value)}),Te.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(!yn)return;function p($){Ho.current&&!Ho.current.contains($.target)&&ha.current&&!ha.current.contains($.target)&&pa(!1)}return document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[yn]);function ji(p,$){if(p.filterValue){const Q=p.filterValue($);return Q==null||Q===""?"":Tn(Q)}return Tn(kr(p.cell($)))}function qi(p){return`"${Tn(p).replace(/"/g,'""')}"`}function Aa(p){return Tn(p).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function Ui(){return Wt&&Gt>gr.length&&Ha.toast.warning(`Exportando ${gr.length.toLocaleString("es-MX")} de ${Gt.toLocaleString("es-MX")} (página actual). Usa exportación completa si está disponible.`),gr}function Lm(){const p=$t.filter(We=>!ur(We)),$=Ui(),Q=p.map(We=>qi(kr(We.header))).join(","),P=$.map(We=>p.map(Ue=>qi(ji(Ue,We))).join(",")).join(`
|
|
5
|
-
`),
|
|
6
|
-
${P}`,ve=new Blob(["\uFEFF"+
|
|
7
|
-
<html lang="es"><head><meta charset="utf-8"><title>${Aa(
|
|
1
|
+
(function(q,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):(q=typeof globalThis<"u"?globalThis:q||self,s(q.BonsaifUI={},q.React,q.jsxRuntime,q.ReactIconsHi2,q.ReactDOM,q.Recharts,q.OverlayScrollbarsGlobal,q.Sonner,q.OverlayScrollbarsReact,q.ReactDayPicker,q.ReactDayPickerStyles,q.ReactIconsFi))})(this,(function(q,s,t,j,gt,Me,Oa,Ha,Zo,Ia,Im,Zi){"use strict";"use client";function Qt(...e){return e.filter(Boolean).join(" ")}function Qi({variant:e="primary",className:r,type:n="button",children:a,...o}){return t.jsx("button",{className:Qt("bonsaif-ui-button",`bonsaif-ui-button--${e}`,r),type:n,...o,children:a})}function Qo({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,b]=s.useState(!1),f=l||m||e.trim().length>0,g=c==="sm"?"h-9 rounded-md":"h-10 rounded-lg",p=a||"w-48 max-w-full sm:w-64 lg:w-72";s.useEffect(()=>{var v;o&&((v=u.current)==null||v.focus())},[o]);const E=()=>{var v;b(!0),(v=u.current)==null||v.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?p:"w-24 sm:w-28"}`,onMouseDown:v=>{f||(v.preventDefault(),E())},children:[t.jsx(j.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:v=>r(v.target.value),onKeyDown:v=>{v.key==="Escape"&&(i==null||i())},placeholder:f?n:"Buscar",className:`${g} 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:v=>{b(!0),v.currentTarget.style.borderColor="var(--primary)",v.currentTarget.style.boxShadow="0 0 0 3px rgba(59,130,246,0.12)"},onBlur:v=>{b(!1),v.currentTarget.style.borderColor="var(--border)",v.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(j.HiXMark,{className:"h-3.5 w-3.5 flex-shrink-0"})})]})}const Jo=s.createContext({});let Ro=0;const es="bonsaif-ui:hide-tooltips";function Sn(e=700){Ro=Date.now()+e}function Ji(){return Date.now()>Ro}function En(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 Ri(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 Bt({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:b="div"}){const f=s.useRef(null),g=s.useRef(null),p=s.useRef(null),E=s.useRef(!1),[v,w]=s.useState(null),[A,C]=s.useState("");s.useEffect(()=>{const D=f.current;D&&(D.querySelectorAll("[title]").forEach(G=>{const V=G.getAttribute("title");V&&(G.getAttribute("aria-label")||G.setAttribute("aria-label",V),G.removeAttribute("title"))}),D.querySelectorAll("svg title").forEach(G=>G.remove()))}),s.useLayoutEffect(()=>{if(!v)return;const D=g.current;if(!D)return;const G=12,V=14,ne=D.getBoundingClientRect(),J=window.innerWidth-ne.width-G,R=window.innerHeight-ne.height-G;let U=v.mouseX+V,Y=v.mouseY+V,ce,L;if(!o&&f.current){const B=f.current.getBoundingClientRect(),le=B.left+B.width/2,O=B.top+B.height/2;l==="top"?(U=le-ne.width/2,Y=B.top-ne.height-V,L=ne.height-1):l==="left"?(U=B.left-ne.width-V,Y=O-ne.height/2,ce=ne.width-1):l==="right"?(U=B.right+V,Y=O-ne.height/2,ce=-7):(U=le-ne.width/2,Y=B.bottom+V,L=-7)}if(o&&(U>J&&(U=v.mouseX-ne.width-V),Y>R&&(Y=v.mouseY-ne.height-V)),U=Math.min(Math.max(G,U),Math.max(G,J)),Y=Math.min(Math.max(G,Y),Math.max(G,R)),!o&&f.current){const B=f.current.getBoundingClientRect(),le=B.left+B.width/2,O=B.top+B.height/2;l==="top"||l==="bottom"?ce=Math.min(Math.max(14,le-U),ne.width-14):L=Math.min(Math.max(14,O-Y),ne.height-14)}(Math.abs(U-v.x)>.5||Math.abs(Y-v.y)>.5||ce!==v.arrowX||L!==v.arrowY)&&w(B=>B&&{...B,x:U,y:Y,arrowX:ce,arrowY:L})},[o,l,v]);const H=()=>{p.current&&(window.clearTimeout(p.current),p.current=null)},k=(D,G)=>{if(!Ji()||E.current)return;const V=f.current;if(V&&!En(V)){if(n){const ne=Ri(V);if(!ne)return;C(ne)}!n&&!r||w({mouseX:D,mouseY:G,x:D+14,y:G+14})}},x=()=>{const D=f.current;if(!D)return;const G=D.getBoundingClientRect();k(G.left+G.width/2,G.bottom)},M=()=>{H(),w(null)},N=()=>{if(!a){M();return}H(),p.current=window.setTimeout(()=>w(null),120)},z=()=>{Sn(),E.current=!0,M()},X=()=>{E.current=!1};s.useEffect(()=>{if(!v)return;if(En(f.current)){w(null);return}const D=()=>w(null),G=()=>{Sn(),E.current=!0,w(null)};document.addEventListener("pointerdown",G,!0),document.addEventListener("click",G,!0),document.addEventListener("scroll",D,!0),window.addEventListener("blur",D),document.addEventListener("visibilitychange",D),document.addEventListener("keydown",D,!0);const V=new MutationObserver(()=>{En(f.current)&&w(null)});return V.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["role","aria-modal","aria-hidden","class"]}),()=>{document.removeEventListener("pointerdown",G,!0),document.removeEventListener("click",G,!0),document.removeEventListener("scroll",D,!0),window.removeEventListener("blur",D),document.removeEventListener("visibilitychange",D),document.removeEventListener("keydown",D,!0),V.disconnect()}},[v]),s.useEffect(()=>{const D=()=>Sn(),G=()=>{Sn(),E.current=!0,w(null)};return document.addEventListener("pointerdown",D,!0),document.addEventListener("click",D,!0),document.addEventListener("keydown",D,!0),window.addEventListener(es,G),()=>{document.removeEventListener("pointerdown",D,!0),document.removeEventListener("click",D,!0),document.removeEventListener("keydown",D,!0),window.removeEventListener(es,G)}},[]);const K=n?A:r;return t.jsxs(t.Fragment,{children:[t.jsx(b,{ref:D=>{f.current=D},className:c,style:u,onMouseEnter:D=>{H(),X(),o?k(D.clientX,D.clientY):x()},onMouseMove:D=>{v&&o&&k(D.clientX,D.clientY)},onMouseDown:z,onClick:z,onMouseLeave:()=>{X(),N()},onFocus:x,onBlur:M,children:e}),v&&K&&!En(f.current)?gt.createPortal(t.jsxs("div",{ref:g,role:"tooltip",className:d,onMouseEnter:a?H:void 0,onMouseLeave:a?N:void 0,style:{position:"fixed",top:v.y,left:v.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:v.arrowX===void 0?void 0:v.arrowX-6,top:v.arrowY===void 0?void 0:v.arrowY-6,zIndex:-1}}),K]}),document.body):null]})}function ts(e){if(e!==void 0)return typeof e=="number"?`${e}px`:e}const ec="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",tc={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"},rc="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",nc={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"},ac={xs:"h-8 w-8",sm:"h-9 w-9",md:"h-10 w-10",lg:"h-10 w-10"},oc={primary:{background:"var(--bg-card)"},secondary:{background:"var(--bg-card)"},danger:{background:"var(--bg-card)"},ghost:{},icon:{}};function Ba(e){return typeof e=="string"||typeof e=="number"?String(e):Array.isArray(e)?e.map(Ba).join(" ").trim():s.isValidElement(e)?Ba(e.props.children):""}function sc(e){return s.Children.toArray(e).find(s.isValidElement)??null}function Qe({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:b,...f}){const g=s.useContext(Jo),p=l??g.iconOnly??e==="icon",E=g.compact??!1,v=g.headerAction??!1,w=v&&r==="md"?"sm":E&&!v&&r==="md"?"xs":r,A=e==="icon"||p,C=v&&A,H=Ba(d),k=o??f.title??f["aria-label"]??(p?H:void 0),x=k?void 0:f.title,M=f["aria-label"]??(typeof k=="string"?k:H||void 0),N=n?null:a??(p?sc(d):null),z=t.jsxs("button",{...f,title:x,"aria-label":M,"data-variant":e,"data-size":w,"data-icon":A?"true":void 0,disabled:m||n,className:`${ec} ${C?rc:tc[e]} ${A?ac[w]:nc[w]} ${E&&!A?"px-2.5":""} ${u}`,style:{...oc[e],height:ts(i),padding:ts(c),...b,...v&&!A?{height:"var(--page-header-control-height, 34px)",padding:"0 var(--page-header-control-padding-x, 10px)",borderRadius:"8px"}:null,...C?{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"}):N,!p&&d]});return k?t.jsx(Bt,{as:"span",content:k,className:"inline-flex shrink-0",children:z}):z}const vt={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:vt}),t.jsx("div",{className:"h-7 max-w-md flex-1 animate-pulse rounded-md",style:vt})]}),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:vt}),t.jsx("div",{className:"h-7 w-7 animate-pulse rounded-md",style:vt})]})]}),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:{...vt,width:`${48+b*17%40}%`}})},`h-${b}`)),Array.from({length:c}).map((m,b)=>Array.from({length:i}).map((f,g)=>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:{...vt,width:`${46+(b*13+g*11)%42}%`,minWidth:28}})},`c-${b}-${g}`)))]})}),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:vt}),t.jsx("div",{className:"h-7 w-14 animate-pulse rounded-md",style:vt})]}),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:vt},b))}),t.jsx("div",{className:"h-3 w-16 animate-pulse rounded-md",style:vt})]})]})}function lc({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 ic({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 rs({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(cc,{rows:i});if(e==="cards")return t.jsx(dc,{rows:i});const m=o||(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(ic,{logoSrc:a,logoAlt:m}):null,t.jsx(lc,{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 cc({rows:e}){return t.jsx(Cn,{rows:e,columns:7})}function dc({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:vt}),t.jsx("div",{className:"mt-3 h-3 w-full animate-pulse rounded-md",style:vt}),t.jsx("div",{className:"mt-2 h-3 w-4/5 animate-pulse rounded-md",style:vt})]},n))})}function ns(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 as(e){return e.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().trim()}function uc(e){return[e.label,ns(e.service),e.description,e.service].filter(Boolean).join(" ")}function fc(e){return typeof e=="function"?e:e.default}function bc(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(Qe,{className:"mt-4",height:36,padding:"0 14px",onClick:r,children:"Reintentar"})]})})}function mc({parentPanel:e,parentPanelComponent:r,renderParentPanel:n,parent:a,context:o,links:l,moduleRegistry:i,loadModule:c,activeService:d,initialService:u,onActiveServiceChange:m,canAccess:b,keepAlive:f=!0,title:g,subtitle:p,emptyState:E,loadingState:v,errorState:w=bc,renderTabLabel:A,searchableTabs:C="auto",tabsSearchThreshold:H=6,tabsSearchPlaceholder:k="Buscar modulo...",tabsSearchValue:x,onTabsSearchChange:M,emptySearchState:N,showTabCount:z=!0,className:X="",parentClassName:K="",contentClassName:D="",tabsClassName:G=""}){var Ye;const V=s.useMemo(()=>l.filter(ie=>!ie.hidden&&((b==null?void 0:b(ie,o))??!0)),[b,o,l]),ne=(Ye=V.find(ie=>!ie.disabled))==null?void 0:Ye.service,[J,R]=s.useState(u??ne??""),[U,Y]=s.useState({}),[ce,L]=s.useState({}),[B,le]=s.useState(""),[O,ae]=s.useState(!1),S=s.useRef(ce),ee=s.useRef(0),_=x??B,I=as(_),de=C===!0||C==="auto"&&V.length>=H,re=de&&_.trim().length>0,F=s.useMemo(()=>I?V.filter(ie=>as(uc(ie)).includes(I)):V,[I,V]),y=d??J,T=V.find(ie=>ie.service===y)??V.find(ie=>!ie.disabled);s.useEffect(()=>{!T&&ne&&R(ne)},[ne,T]),s.useEffect(()=>{S.current=ce},[ce]);const te=ie=>{ie.disabled||(d||R(ie.service),m==null||m(ie.service,ie))},fe=ie=>{x===void 0&&le(ie),M==null||M(ie)},se=(ie,Se)=>{const _e=F.filter(Ke=>!Ke.disabled),ot=_e.findIndex(Ke=>Ke.service===Se.service);ot<0||((ie.key==="ArrowRight"||ie.key==="ArrowDown")&&(ie.preventDefault(),te(_e[(ot+1)%_e.length])),(ie.key==="ArrowLeft"||ie.key==="ArrowUp")&&(ie.preventDefault(),te(_e[(ot-1+_e.length)%_e.length])),ie.key==="Home"&&(ie.preventDefault(),te(_e[0])),ie.key==="End"&&(ie.preventDefault(),te(_e[_e.length-1])))},he=s.useCallback(()=>{if(!T)return;const ie=T.service,Se=S.current[ie];if(Se!=null&&Se.loading||Se!=null&&Se.component&&f)return;const _e=(i==null?void 0:i[ie])??c;if(!_e){L(Ke=>({...Ke,[ie]:{loading:!1,error:new Error(`No module loader found for service "${ie}".`)}}));return}const ot=++ee.current;L(Ke=>({...Ke,[ie]:{...Ke[ie],loading:!0,error:void 0}})),_e(T,o).then(Ke=>{if(ot!==ee.current&&!f)return;const lt=fc(Ke);L(ct=>({...ct,[ie]:{component:lt,loading:!1}}))}).catch(Ke=>{const lt=Ke instanceof Error?Ke:new Error(String(Ke));L(ct=>({...ct,[ie]:{...ct[ie],loading:!1,error:lt}}))})},[o,f,c,i,T]);s.useEffect(he,[he]);const Ae=T?U[T.service]??null:null,De=T?ce[T.service]:void 0,ue=De==null?void 0:De.component,Te=ie=>{T&&Y(Se=>({...Se,[T.service]:ie}))},He=()=>{T&&Y(ie=>({...ie,[T.service]:null}))},Xe={context:o,parent:a,links:l,visibleLinks:V,filteredLinks:F,selectedLink:T,selectedService:T==null?void 0:T.service,activeItemId:Ae,tabsSearch:_,onSelectService:te,onOpenDetail:Te,onBackToList:He},je=n?n(Xe):r?t.jsx(r,{...Xe}):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 ${K}`,children:je}),t.jsxs("div",{className:`relative min-w-0 overflow-visible rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${D}`,children:[(g||p||de||z)&&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:[g&&t.jsx("h2",{className:"truncate text-sm font-semibold text-[var(--text-main)]",children:g}),p&&t.jsx("p",{className:"mt-1 line-clamp-2 text-xs text-[var(--text-muted)]",children:p})]}),(de||z)&&t.jsxs("div",{className:"flex min-w-0 flex-shrink-0 items-center justify-end gap-2",children:[z&&t.jsxs("span",{className:"hidden text-xs font-semibold text-[var(--text-muted)] transition-opacity duration-200 sm:inline",children:[F.length," / ",V.length]}),de&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:`origin-right overflow-hidden transition-[width,opacity,transform] duration-200 ease-out ${O?"w-[min(20rem,44vw)] translate-x-0 opacity-100":"w-0 translate-x-2 opacity-0"}`,"aria-hidden":!O,children:t.jsx(Qo,{value:_,onChange:fe,placeholder:k,className:"w-full",autoFocus:O,forceExpanded:!0,onEscape:()=>ae(!1),size:"sm",inputTabIndex:O?0:-1})}),t.jsx("button",{type:"button","aria-label":O?"Cerrar busqueda":"Buscar tabs","aria-expanded":O,onClick:()=>{O&&_&&fe(""),ae(ie=>!ie)},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 ${O||re?"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:O||re?t.jsx(j.HiXMark,{className:"h-4 w-4"}):t.jsx(j.HiMagnifyingGlass,{className:"h-4 w-4"})})})]})]})]})}),t.jsx("div",{role:"tablist","aria-label":g??"Modulos relacionados",className:`flex gap-1 overflow-x-auto border-b border-[var(--border)] bg-[var(--bg-input)] px-2 py-1.5 transition-colors duration-200 ${G}`,children:F.length>0?F.map(ie=>{const Se=ie.service===(T==null?void 0:T.service);return t.jsx("button",{type:"button",role:"tab","aria-selected":Se,disabled:ie.disabled,onClick:()=>te(ie),onKeyDown:_e=>se(_e,ie),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 ${Se?"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:A?A(ie,Se):t.jsxs(t.Fragment,{children:[ie.icon,t.jsx("span",{children:ie.label??ns(ie.service)}),ie.badge&&t.jsx("span",{className:"rounded-full bg-[var(--bg-input)] px-1.5 py-0.5 text-[10px] text-[var(--text-muted)]",children:ie.badge})]})},ie.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:N??"No hay modulos que coincidan con la busqueda."})}),(T==null?void 0:T.description)&&t.jsx("div",{className:"border-b border-[var(--border)] px-4 py-2 text-xs text-[var(--text-muted)]",children:T.description}),t.jsxs("div",{className:"min-h-[420px] p-4",children:[!T&&(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."})),T&&(De==null?void 0:De.loading)&&(v??t.jsx(rs,{title:"Cargando modulo..."})),T&&(De==null?void 0:De.error)&&w(De.error,he),T&&ue&&!(De!=null&&De.loading)&&!(De!=null&&De.error)&&t.jsx(ue,{context:o,parent:a,link:T,activeItemId:Ae,onOpenDetail:Te,onBackToList:He})]})]})]})}const hc={info:{color:"#2563eb",background:"rgba(59, 130, 246, 0.1)",border:"rgba(59, 130, 246, 0.24)",icon:t.jsx(j.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(j.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(j.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(j.HiExclamationCircle,{className:"h-5 w-5"})},neutral:{color:"var(--text-secondary)",background:"var(--bg-input)",border:"var(--border)",icon:t.jsx(j.HiInformationCircle,{className:"h-5 w-5"})}};function pc({variant:e="info",title:r,children:n,icon:a,action:o,onDismiss:l,className:i=""}){const c=hc[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(Qe,{variant:"icon",size:"xs","aria-label":"Cerrar alerta",onClick:l,className:"-mr-1 -mt-1",children:t.jsx(j.HiXMark,{className:"h-4 w-4"})})]})}const os=["Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre"],gc=["Ene","Feb","Mar","Abr","May","Jun","Jul","Ago","Sep","Oct","Nov","Dic"],vc=["lu","ma","mi","ju","vi","sá","do"],ss=6;function Fa(e,r,n){return`${e}-${String(r).padStart(2,"0")}-${String(n).padStart(2,"0")}`}function xc(){const e=new Date;return Fa(e.getFullYear(),e.getMonth()+1,e.getDate())}function ls(e){const[r,n,a]=e.split("-").map(Number);return{year:r,month:n,day:a}}function yc(e){if(!e)return"Seleccionar fecha";const{year:r,month:n,day:a}=ls(e);return!r||!n||!a?"Seleccionar fecha":`${String(a).padStart(2,"0")} ${os[n-1]} ${r}`}function wc({value:e,onChange:r,minDate:n,displayMode:a="inline",className:o=""}){const l=xc(),c=ls(e||l),d=a==="popover",[u,m]=s.useState(!1),b=s.useRef(null),[f,g]=s.useState({horizontal:"left",vertical:"bottom"}),[p,E]=s.useState(c.year),[v,w]=s.useState(c.month),[A,C]=s.useState("days"),H=16,[k,x]=s.useState(0),M=p-7+k,N=Array.from({length:H},(R,U)=>M+U);s.useEffect(()=>{if(!d||!u||!b.current)return;const R=b.current.getBoundingClientRect(),U=8,Y=280,ce=340,L=R.left+Y>window.innerWidth-U,B=R.right-Y>=U,le=R.bottom+8+ce>window.innerHeight-U,O=R.top-8-ce>=U;g({horizontal:L&&B?"right":"left",vertical:le&&O?"top":"bottom"})},[d,u]),s.useEffect(()=>{if(!d||!u)return;function R(Y){b.current&&(b.current.contains(Y.target)||m(!1))}function U(Y){Y.key==="Escape"&&m(!1)}return document.addEventListener("mousedown",R),document.addEventListener("keydown",U),()=>{document.removeEventListener("mousedown",R),document.removeEventListener("keydown",U)}},[d,u]);function z(){v===1?(E(R=>R-1),w(12)):w(R=>R-1)}function X(){v===12?(E(R=>R+1),w(1)):w(R=>R+1)}const K=(new Date(p,v-1,1).getDay()+6)%7,D=new Date(p,v,0).getDate(),G=[...Array(K).fill(null),...Array.from({length:D},(R,U)=>U+1)];for(;G.length<ss*7;)G.push(null);const V=G.slice(0,ss*7);function ne(R){const U=Fa(p,v,R);n&&U<n||(r(U),d&&m(!1))}const J=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:A==="days"?t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn",onClick:z,"aria-label":"Mes anterior",children:t.jsx(j.HiChevronLeft,{size:16})}),t.jsxs("button",{type:"button",className:"bonsaif-cal-title-btn",onClick:()=>{C("years"),x(0)},children:[t.jsxs("span",{className:"bonsaif-cal-title",children:[os[v-1]," ",p]}),t.jsx(j.HiChevronDown,{size:13})]}),t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn",onClick:X,"aria-label":"Mes siguiente",children:t.jsx(j.HiChevronRight,{size:16})})]}):t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn",onClick:()=>x(R=>R-H),"aria-label":"Años anteriores",children:t.jsx(j.HiChevronLeft,{size:16})}),t.jsx("button",{type:"button",className:"bonsaif-cal-title-btn",onClick:()=>C("days"),children:t.jsxs("span",{className:"bonsaif-cal-title",children:[N[0]," – ",N[N.length-1]]})}),t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn",onClick:()=>x(R=>R+H),"aria-label":"Años siguientes",children:t.jsx(j.HiChevronRight,{size:16})})]})}),A==="years"?t.jsxs("div",{className:"bonsaif-cal-picker-years",children:[t.jsx("div",{className:"bonsaif-cal-picker-months",children:gc.map((R,U)=>{const Y=U+1===v;return t.jsx("button",{type:"button",className:`bonsaif-cal-pill-btn${Y?" is-active":""}`,onClick:()=>w(U+1),children:R},R)})}),t.jsx("div",{className:"bonsaif-cal-picker-year-grid",children:N.map(R=>{const U=R===p,Y=R===new Date().getFullYear();return t.jsx("button",{type:"button",className:`bonsaif-cal-pill-btn${U?" is-active":""}${Y&&!U?" is-today":""}`,onClick:()=>{E(R),C("days")},children:R},R)})})]}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"bonsaif-multi-weekdays bonsaif-cal-picker-weekdays",children:vc.map(R=>t.jsx("div",{className:"bonsaif-multi-weekday",children:R},R))}),t.jsx("div",{className:"bonsaif-cal-picker-days",children:V.map((R,U)=>{if(R===null)return t.jsx("div",{className:"bonsaif-multi-day bonsaif-multi-day-hidden"},U);const Y=Fa(p,v,R),ce=Y===e,L=Y===l,B=!!(n&&Y<n);return t.jsx("div",{className:`bonsaif-multi-day${ce?" bonsaif-multi-day-selected":""}${L?" bonsaif-multi-day-today":""}${B?" bonsaif-multi-day-disabled":""}`,children:t.jsx("button",{type:"button",className:"bonsaif-multi-day-btn",disabled:B,"aria-pressed":ce,onClick:()=>!B&&ne(R),children:R})},U)})})]})]})});return d?t.jsxs("div",{ref:b,className:`relative w-full ${o}`.trim(),children:[t.jsxs("button",{type:"button",onClick:()=>m(R=>!R),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(j.HiCalendarDays,{className:"w-4 h-4 text-[var(--text-muted)]"}),t.jsx("span",{className:"truncate",children:yc(e)})]}),t.jsx(j.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:J})]}):J}function Ut({children:e,className:r="",style:n,as:a="span",followCursor:o=!1,placement:l="top"}){return t.jsx(Bt,{onlyWhenOverflow:!0,as:a,followCursor:o,placement:l,showArrow:!o,className:r,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",minWidth:0,...n},children:e})}function Pa(e){if(e!==void 0)return typeof e=="number"?`${e}px`:e}function _a(e){return e.normalize("NFD").replace(new RegExp("\\p{M}","gu"),"").toLowerCase()}function Nc(e,r){if(!r.trim())return!0;const n=_a(r);return _a(e.label).includes(n)||!!(e.sublabel&&_a(e.sublabel).includes(n))}function dr({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:b,dropdownMinWidth:f,height:g=40,padding:p="0 10px",searchable:E=!0,minOptionsForSearch:v=6}){const[w,A]=s.useState(!1),[C,H]=s.useState(""),[k,x]=s.useState(-1),[M,N]=s.useState(!1),[z,X]=s.useState({}),K=s.useRef(null),D=s.useRef(null),G=s.useRef(null),V=s.useRef(null),ne=E&&n.length>=v,J=n.find(_=>_.value===e)??null,R=l==="ghost",U=a==="error"?"var(--danger)":w?"var(--primary)":"var(--border)",Y=ne&&C.trim()?n.filter(_=>Nc(_,C)):n,ce=s.useCallback(()=>{const _=K.current;if(!_)return;const I=_.getBoundingClientRect(),de=ne?272:212,re=window.innerHeight-I.bottom,F=re<de&&I.top>re;X({position:"fixed",left:I.left,top:F?void 0:I.bottom+4,bottom:F?window.innerHeight-I.top+4:void 0,width:I.width,minWidth:Pa(f),zIndex:9999})},[f,ne]);s.useEffect(()=>N(!0),[]),s.useEffect(()=>{if(!w)return;function _(I){var re,F;const de=I.target;!((re=K.current)!=null&&re.contains(de))&&!((F=D.current)!=null&&F.contains(de))&&(A(!1),H(""))}return document.addEventListener("mousedown",_),()=>document.removeEventListener("mousedown",_)},[w]),s.useEffect(()=>{w&&(x(-1),ce(),ne&&setTimeout(()=>{var _;return(_=G.current)==null?void 0:_.focus()},0))},[w,ne,ce]),s.useEffect(()=>{if(w)return window.addEventListener("resize",ce),window.addEventListener("scroll",ce,!0),()=>{window.removeEventListener("resize",ce),window.removeEventListener("scroll",ce,!0)}},[w,ce]),s.useEffect(()=>{if(k<0||!V.current)return;const _=V.current.children[k];_==null||_.scrollIntoView({block:"nearest"})},[k]);const L=s.useCallback(_=>{r(_),A(!1),H("")},[r]),B=s.useRef(w);B.current=w;const le=s.useRef(Y);le.current=Y;const O=s.useRef(k);O.current=k;const ae=s.useRef(d);ae.current=d;const S=s.useRef(L);S.current=L,s.useEffect(()=>{function _(I){var y,T;const de=document.activeElement,re=((y=K.current)==null?void 0:y.contains(de))??!1,F=((T=D.current)==null?void 0:T.contains(de))??!1;if(!(!re&&!F)){if(!B.current){(I.key==="Enter"||I.key===" "||I.key==="ArrowDown")&&(I.preventDefault(),A(!0));return}switch(I.key){case"ArrowDown":I.preventDefault(),x(te=>Math.min(te+1,le.current.length-1));break;case"ArrowUp":I.preventDefault(),x(te=>Math.max(te-1,ae.current?-1:0));break;case"Enter":{I.preventDefault();const te=O.current,fe=le.current;te===-1&&ae.current?S.current(""):fe[te]&&!fe[te].disabled&&S.current(fe[te].value);break}case"Escape":I.preventDefault(),I.stopPropagation(),A(!1),H("");break}}}return document.addEventListener("keydown",_),()=>document.removeEventListener("keydown",_)},[]);const ee=t.jsxs("div",{ref:D,"data-bonsaif-select-dropdown":"true",className:"rounded-xl shadow-xl overflow-hidden",style:{...z,background:"var(--bg-card)",border:"1px solid var(--border)"},children:[ne&&t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",style:{borderBottom:"1px solid var(--border)"},children:[t.jsx(j.HiMagnifyingGlass,{className:"w-3.5 h-3.5 flex-shrink-0",style:{color:"var(--text-muted)"}}),t.jsx("input",{ref:G,value:C,onChange:_=>{H(_.target.value),x(-1)},placeholder:"Buscar…",className:"min-w-0 flex-1 text-sm bg-transparent outline-none",style:{color:"var(--text-main)"}}),C&&t.jsx("button",{type:"button",onMouseDown:_=>{_.preventDefault(),H("")},children:t.jsx(j.HiXMark,{className:"w-3.5 h-3.5",style:{color:"var(--text-muted)"}})})]}),t.jsxs("ul",{ref:V,role:"listbox",className:"overflow-y-auto",style:{maxHeight:ne?220:180,scrollbarWidth:"thin",scrollbarColor:"var(--border) transparent",overscrollBehavior:"contain"},children:[d&&t.jsx("li",{role:"option","aria-selected":e==="",onMouseDown:_=>{_.preventDefault(),L("")},onMouseEnter:()=>x(-1),className:"flex items-center gap-2 px-3 py-2 cursor-pointer text-sm transition-colors",style:{background:k===-1&&!C.trim()?"var(--bg-hover)":"transparent",color:"var(--text-muted)",fontStyle:"italic"},children:d}),Y.map((_,I)=>{const re=I===k,F=_.value===e;return t.jsxs("li",{role:"option","aria-selected":F,onMouseDown:y=>{y.preventDefault(),_.disabled||L(_.value)},onMouseEnter:()=>!_.disabled&&x(I),className:"flex items-center gap-2 px-3 py-2 cursor-pointer text-sm transition-colors",style:{background:re?"var(--bg-hover)":F?"color-mix(in srgb, var(--primary) 6%, transparent)":"transparent",color:_.disabled?"var(--text-muted)":"var(--text-main)",cursor:_.disabled?"not-allowed":"pointer",boxShadow:F?"inset 2px 0 0 var(--primary)":void 0},children:[_.color&&t.jsx("span",{className:"flex-shrink-0 w-2.5 h-2.5 rounded-full",style:{background:_.color}}),t.jsxs("span",{className:"min-w-0 flex flex-1 items-baseline gap-1 overflow-hidden",children:[t.jsx(Ut,{className:"min-w-0 flex-1",children:_.label}),_.sublabel&&t.jsx(Ut,{className:"min-w-0 flex-shrink",style:{color:"var(--text-muted)",fontSize:12},children:_.sublabel})]}),_.badge&&t.jsx("span",{className:"text-xs flex-shrink-0",style:{color:"var(--text-muted)"},children:_.badge})]},_.value)}),Y.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:K,className:`relative ${m||"w-full"}`,style:b,children:[t.jsxs("button",{type:"button",disabled:u,onClick:()=>!u&&A(_=>!_),className:"flex w-full items-center gap-2 rounded-lg text-left text-sm transition-colors focus:outline-none",style:{height:Pa(g),padding:Pa(p),background:R?"transparent":"var(--bg-input)",color:J?"var(--text-main)":"var(--text-muted)",border:R?"1px solid transparent":`1px solid ${U}`,opacity:u?.5:1,cursor:u?"not-allowed":"pointer"},"aria-haspopup":"listbox","aria-expanded":w,"aria-label":o,children:[(J==null?void 0:J.color)&&t.jsx("span",{className:"flex-shrink-0 w-2.5 h-2.5 rounded-full",style:{background:J.color}}),t.jsx("span",{className:"min-w-0 flex flex-1 items-baseline gap-1 overflow-hidden",children:J?t.jsxs(t.Fragment,{children:[t.jsx(Ut,{className:"min-w-0 flex-1",children:J.label}),i&&J.sublabel&&t.jsx(Ut,{className:"min-w-0 flex-shrink",style:{color:"var(--text-muted)",fontSize:12},children:J.sublabel})]}):t.jsx(Ut,{className:"min-w-0 flex-1",children:c})}),J&&d?t.jsx("span",{role:"button",tabIndex:-1,onMouseDown:_=>{_.preventDefault(),_.stopPropagation(),L("")},className:"flex-shrink-0 rounded-full p-0.5 transition-colors hover:bg-black/10",style:{color:"var(--text-muted)"},children:t.jsx(j.HiXMark,{className:"w-3 h-3"})}):t.jsx(j.HiChevronDown,{className:"flex-shrink-0 w-4 h-4 transition-transform",style:{color:"var(--text-muted)",transform:w?"rotate(180deg)":"rotate(0deg)"}})]}),w&&M&>.createPortal(ee,document.body)]})}const kc={sm:"h-4 w-4",md:"h-5 w-5"};function Sc(e,r){if(typeof e=="function"){e(r);return}e&&(e.current=r)}const Mn=s.forwardRef(function({label:r,description:n,error:a,size:o="md",indeterminate:l=!1,className:i="",containerClassName:c="",disabled:d,...u},m){const b=s.useRef(null);return s.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,Sc(m,f)},type:"checkbox",disabled:d,"aria-checked":l?"mixed":u["aria-checked"],"aria-invalid":!!a||u["aria-invalid"],className:`peer ${kc[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(j.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})]})]})}),is=32767;function Tn(e){let r=String(e??"");return r=r.split("\0").join(""),r.length<=is?r:`${r.slice(0,is-1)}…`}const $n=[25,50,100,200,500];let At={dataTable:{pageSizeOptions:[...$n]}};function Ec(){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 za(){const e=At.dataTable.preferencesEndpoint,r=Ec();return e&&e.trim().length>0?e.trim().replace(/\/+$/,""):r}function Cc(e){if(!Array.isArray(e))return[...$n];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:[...$n]}function cs(e){if(typeof e!="string")return;const r=e.trim();if(r)return r.replace(/\/+$/,"")}function Mc(e){if(!e||typeof e!="object"||!e.dataTable)return;const r=cs(e.dataTable.preferencesEndpoint);At={...At,dataTable:{...At.dataTable,pageSizeOptions:Cc(e.dataTable.pageSizeOptions),preferencesEndpoint:r??At.dataTable.preferencesEndpoint}}}function Tc(){return{dataTable:{pageSizeOptions:[...At.dataTable.pageSizeOptions]}}}function Qr(){return[...At.dataTable.pageSizeOptions]}function $c(){At={dataTable:{pageSizeOptions:[...$n]}}}function Ac(e){At={...At,dataTable:{...At.dataTable,preferencesEndpoint:cs(e)}}}const An=[{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"}],Lc=An.map(e=>({value:e.value,label:e.label})),Dc=12,Oc={layout:!0,filters:!1,sort:!1,bql:!1,pagination:!0},ds={layout:!0,filters:!0,sort:!0,bql:!0,pagination:!0},Hc="bonsaif-ui:datatable:",Ic="[&_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",Bc=[],Fc=52;function Vt(e){if(!e)return 150;const r=parseInt(e,10);return isNaN(r)||r<=0?150:r}function us(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 fs(e){return`${Hc}${e}`}function Ln(e){try{const r=window.localStorage.getItem(fs(e));if(!r)return null;const n=JSON.parse(r);return n&&typeof n=="object"?n:null}catch{return null}}function Pc(e,r){try{window.localStorage.setItem(fs(e),JSON.stringify(r))}catch{}}function _c(e,r){if(e===!0)return{...ds};if(e===!1)return{layout:!1,filters:!1,sort:!1,bql:!1,pagination:!1};if(r&&e==null)return{...ds};const n={...Oc,...e??{}};return r&&(typeof e!="object"||e.pagination!==!1)&&(n.pagination=!0),n}function bs(...e){return e.reduce((r,n)=>({...r,...n??{}}),{})}function Wa(e,r,n){return typeof e!="number"||e<=0?n:rn(r).includes(e)?e:n}function Jr(e){if(!e||typeof e!="object")return!1;const r=e;return typeof r.key=="string"&&(r.dir==="asc"||r.dir==="desc")}function Rr(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 en(e,r){if(!e||typeof e!="object"||Array.isArray(e))return{};const n=new Set(An.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 wt(e,r){if(ur(e))return Fc;const n=e.minWidth??80,a=e.maxWidth??1/0;return Math.min(a,Math.max(n,r))}function zc(e){const r=window.getComputedStyle(e);return parseFloat(r.paddingLeft)+parseFloat(r.paddingRight)}function ur(e){return e.key==="actions"||e.key==="acciones"?!0:typeof e.header=="string"&&e.header.trim().toLowerCase()==="acciones"}function ja(e){return e.sticky===!0}function ms(e){return!(e.reorderable===!1||e.sticky&&e.reorderable!==!0)}function Dn(e,r){const a=[...e.filter(o=>r.includes(o))];for(let o=0;o<r.length;o+=1){const l=r[o];if(a.includes(l))continue;let i=a.length;for(let c=o-1;c>=0;c-=1){const d=r[c],u=a.indexOf(d);if(u!==-1){i=u+1;break}}if(i===a.length)for(let c=o+1;c<r.length;c+=1){const d=r[c],u=a.indexOf(d);if(u!==-1){i=u;break}}a.splice(i,0,l)}return a}function Jt(e,r){const n=r.filter(ja).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 Wc(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 Rt(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 jc(e){return e==null||e===""?"(Vacio)":e instanceof Date?e.toLocaleDateString():String(e)}function kr(e){return e==null||typeof e=="boolean"?"":typeof e=="string"||typeof e=="number"?String(e):Array.isArray(e)?e.map(kr).join(" ").trim():s.isValidElement(e)?kr(e.props.children):""}function On(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?jc(n):kr(n).trim()}function tn(e){const r=e.replace(/,/g,"").trim();if(!r)return null;const n=Number(r);return Number.isFinite(n)?n:null}function Sr(e,r){const n=tn(e),a=tn(r);return n!==null&&a!==null?n-a:e.localeCompare(r,void 0,{numeric:!0,sensitivity:"base"})}function rn(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:Qr()}function qc(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=An.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 Sr(e,a)>0;case"greaterThanOrEqual":return Sr(e,a)>=0;case"lessThan":return Sr(e,a)<0;case"lessThanOrEqual":return Sr(e,a)<=0;case"between":return Sr(e,a)>=0&&Sr(e,o)<=0;case"top10":case"bottom10":{const u=n.map(b=>({value:b,number:tn(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(tn).filter(b=>b!==null);if(d.length===0)return!1;const u=d.reduce((b,f)=>b+f,0)/d.length,m=tn(e);return m===null?!1:r.operator==="aboveAverage"?m>u:m<u}default:return!0}}function hs({children:e,className:r="",style:n}){return t.jsx(Bt,{onlyWhenOverflow:!0,className:r,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,...n},children:e})}function qa({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:b,defaultExpandedRowIds:f=[],onExpandedRowIdsChange:g,expandOnRowClick:p=!1,selected:E,onToggleOne:v,onToggleAll:w,getRowSelectable:A,highlightSelected:C=!0,rowClassName:H,getRowCategory:k,stickyHeader:x=!0,pageSize:M=25,pageSizeOptions:N,pageSizeSelectWidth:z=62,pageSizeSelectHeight:X=30,pageSizeSelectPadding:K="0 7px",totalRows:D,page:G,onPageChange:V,onPageSizeChange:ne,storageKey:J,stickyFirstColumn:R=!1,bottomOffset:U=0,compact:Y=!0,restrictHeight:ce=!0,maxHeight:L,minTableWidth:B,enableColumnVisibility:le=!0,enableColumnFilters:O=!0,hiddenColumnKeys:ae,defaultHiddenColumnKeys:S=Bc,onHiddenColumnKeysChange:ee,columnVisibilityLabel:_="Columnas",enableBql:I=!1,bqlValue:de,defaultBqlValue:re="",onBqlChange:F,bqlDescription:y="Filtra registros con Bonsaif Query Language",bqlPlaceholder:T=`status = activo
|
|
2
|
+
rol IN (admin, employee)`,bqlQuickFilters:te=[],bqlExamples:fe=[],bqlSuggestions:se=[],bqlActiveFilters:he,bqlError:Ae,onQueryChange:De,persistState:ue,onPreferencesReady:Te,enableExport:He=!1,exportFilename:Xe="datos",onExportCsv:je,onExportPdf:Ye}){var Ki;const ie=_c(ue,J),Se=Object.values(ie).some(Boolean),_e=e.map(h=>h.key).join(","),ot=S.join(","),Ke=s.useRef(e),lt=s.useRef(S);Ke.current=e,lt.current=S;const[ct,dt]=s.useState(!J||!Se),Yt=s.useRef(null),me=s.useRef(!J),ge=s.useRef(!1),Oe=s.useRef(Te);Oe.current=Te;const We=s.useRef(!J||!Se?J??"__none__":null),Be=ae!==void 0,[mt,ut]=s.useState(()=>Rt(S,e)),qe=Rt(Be?ae:mt,e),[Ve,ft]=s.useState(!1),[ht,br]=s.useState("filter"),[bt,ze]=s.useState(null),[vn,fa]=s.useState(""),[pt,Mt]=s.useState({}),[Tt,ar]=s.useState({}),Wr=b!==void 0,[W,Z]=s.useState(f),be=de!==void 0,[pe,Ee]=s.useState(re),xe=be?de:pe,[Fe,Ie]=s.useState(xe),[Je,Re]=s.useState(!1),[or,xt]=s.useState(!1),[Kt,Ht]=s.useState(!1),[sr,Gt]=s.useState([]),jr=s.useRef(null),mr=s.useRef(null),Wt=s.useRef(F);Wt.current=F;const ba=s.useRef(M);ba.current=M;const ma=s.useRef(N);ma.current=N;const Zb=Array.isArray(N)?N.join(","):"",Do=s.useRef(null),vi=s.useRef(null),Oo=s.useRef(null),xi=s.useRef(0),[Qb,Jb]=s.useState({}),[Rb,em]=s.useState({}),[xn,ha]=s.useState(!1),Ho=s.useRef(null),pa=s.useRef(null),[tm,rm]=s.useState({}),yi=s.useRef(null),ga=s.useRef(null),[Io,wi]=s.useState(r.length>0||a||c===!1),Ni=(h,$)=>50+(h*17+$*13+7)%40,lr=s.useRef(null),[nm,am]=s.useState(void 0),[ki,om]=s.useState(0),[sm,lm]=s.useState(!1);s.useEffect(()=>{function h(){lm(window.innerWidth<640)}if(!ce||L!==void 0)return h(),window.addEventListener("resize",h),()=>window.removeEventListener("resize",h);const Q=M!==!1?48:0,P=12;function oe(){if(h(),!lr.current)return;const ve=lr.current.getBoundingClientRect().top;am(Math.max(120,window.innerHeight-ve-Q-P-U))}return oe(),window.addEventListener("resize",oe),()=>window.removeEventListener("resize",oe)},[a,M,U,ce,L]);const Si=ce?L??nm:void 0;s.useEffect(()=>{const h=lr.current;if(!h)return;const $=()=>om(h.clientWidth);if($(),typeof ResizeObserver>"u")return window.addEventListener("resize",$),()=>window.removeEventListener("resize",$);const Q=new ResizeObserver($);return Q.observe(h),()=>Q.disconnect()},[a,ct,r.length]),s.useEffect(()=>{if(c===!1||a||r.length>0){wi(!0);return}if(Io)return;const h=window.setTimeout(()=>{wi(!0)},c);return()=>window.clearTimeout(h)},[r.length,c,Io,a]);const[qr,Ur]=s.useState(()=>Jt(e.map(h=>h.key),e)),[hr,Vr]=s.useState(()=>Object.fromEntries(e.map(h=>[h.key,wt(h,Vt(h.width))]))),[et,pr]=s.useState(null),[im,va]=s.useState(1),[xa,ya]=s.useState(M===!1?0:M);s.useEffect(()=>{var Le;const h=Ke.current,$=lt.current,Q=h.map(ke=>ke.key),P=new Set(Q),oe=()=>{var ke;ge.current||(ge.current=!0,(ke=Oe.current)==null||ke.call(Oe))};if(!J||!Se){ie.layout&&Ur(Jt(Q,h)),Be||ut(Rt($,h)),me.current=!1,dt(!0),oe();return}let ve=!1;const Ce=We.current===J;Ce||(me.current=!1,dt(!1),ge.current=!1);const $e=Ln(J);if(us($e)&&!Ce){const ke=$e,we=rn(ma.current??Qr()),Ne=ba.current,xr=Ne===!1?0:Ne,cr=ie.layout?ke==null?void 0:ke.columnOrder:void 0,yr=Array.isArray(cr)?cr.filter(Ge=>Q.includes(Ge)):[],wr=Jt(yr.length>0?Dn(yr,Q):Q,h),Nr=Object.fromEntries(h.map(Ge=>[Ge.key,wt(Ge,Vt(Ge.width))])),Kr=ie.layout?(ke==null?void 0:ke.columnWidths)??{}:{},kn=Object.fromEntries(h.map(Ge=>[Ge.key,wt(Ge,Kr[Ge.key]??Nr[Ge.key])])),Gr=Rt(ie.layout?(ke==null?void 0:ke.hiddenColumnKeys)??$:$,h);if(ie.layout&&(Ur(wr),Vr(kn)),Be||ut(Gr),ie.filters&&(Mt(Rr(ke==null?void 0:ke.filters,P)),ar(en(ke==null?void 0:ke.conditionFilters,P))),ie.sort){const Ge=Jr(ke==null?void 0:ke.sort)?ke.sort:null;pr(Ge&&P.has(Ge.key)?Ge:null)}if(ie.bql){if(jr.current!==J){jr.current=J;const Ge=typeof(ke==null?void 0:ke.bql)=="string"?ke.bql:re;be?(Le=Wt.current)==null||Le.call(Wt,Ge):Ee(Ge)}Gt(Array.isArray(ke==null?void 0:ke.bqlHistory)?ke.bqlHistory.filter(Ge=>typeof Ge=="string"):[])}ie.pagination&&mr.current!==J&&(mr.current=J,ya(Wa(ke==null?void 0:ke.pageSize,we,xr))),We.current=J,dt(!0),oe()}const yt=`${za()??"/api/user/preferences/datatables"}?key=${encodeURIComponent(J)}`,nt=new AbortController,ye=window.setTimeout(()=>nt.abort(),2500);return fetch(yt,{cache:"no-store",signal:nt.signal}).then(ke=>ke.ok?ke.json():null).then(ke=>{var Gi;if(ve)return;const we=Ln(J),Ne=bs(us(ke==null?void 0:ke.settings)?ke==null?void 0:ke.settings:null,we),xr=rn(ma.current??Qr()),cr=ba.current,yr=cr===!1?0:cr,wr=ie.layout?Ne==null?void 0:Ne.columnOrder:void 0,Nr=Array.isArray(wr)?wr.filter(at=>Q.includes(at)):[],Kr=Jt(Nr.length>0?Dn(Nr,Q):Q,h),kn=Object.fromEntries(h.map(at=>[at.key,wt(at,Vt(at.width))])),Gr=ie.layout?(Ne==null?void 0:Ne.columnWidths)??{}:{},Ge=Object.fromEntries(h.map(at=>[at.key,wt(at,Gr[at.key]??kn[at.key])])),Zr=Rt(ie.layout?(Ne==null?void 0:Ne.hiddenColumnKeys)??$:$,h);if(ie.layout&&(Ur(Kr),Vr(Ge)),Be||ut(Zr),ie.filters&&(Mt(Rr(Ne==null?void 0:Ne.filters,P)),ar(en(Ne==null?void 0:Ne.conditionFilters,P))),ie.sort){const at=Jr(Ne==null?void 0:Ne.sort)?Ne.sort:null;pr(at&&P.has(at.key)?at:null)}if(ie.bql){if(jr.current!==J){jr.current=J;const at=typeof(Ne==null?void 0:Ne.bql)=="string"?Ne.bql:re;be?(Gi=Wt.current)==null||Gi.call(Wt,at):Ee(at)}Gt(Array.isArray(Ne==null?void 0:Ne.bqlHistory)?Ne.bqlHistory.filter(at=>typeof at=="string"):[])}let tt;ie.pagination&&(tt=Wa(Ne==null?void 0:Ne.pageSize,xr,yr),mr.current!==J&&(mr.current=J,ya(tt))),Yt.current=JSON.stringify({columnOrder:Kr,columnWidths:Ge,hiddenColumnKeys:Zr,filters:Rr(Ne==null?void 0:Ne.filters,P),conditionFilters:en(Ne==null?void 0:Ne.conditionFilters,P),sort:Jr(Ne==null?void 0:Ne.sort)?Ne.sort:null,bql:typeof(Ne==null?void 0:Ne.bql)=="string"?Ne.bql:"",bqlHistory:Array.isArray(Ne==null?void 0:Ne.bqlHistory)?Ne.bqlHistory:[],pageSize:ie.pagination&&cr!==!1?tt:void 0}),me.current=!0}).catch(()=>{var ke;if(!ve){const we=Ln(J),Ne=rn(ma.current??Qr()),xr=ba.current,cr=xr===!1?0:xr,yr=ie.layout?we==null?void 0:we.columnOrder:void 0,wr=Array.isArray(yr)?yr.filter(tt=>Q.includes(tt)):[],Nr=Jt(wr.length>0?Dn(wr,Q):Q,h),Kr=Object.fromEntries(h.map(tt=>[tt.key,wt(tt,Vt(tt.width))])),kn=ie.layout?(we==null?void 0:we.columnWidths)??{}:{},Gr=Object.fromEntries(h.map(tt=>[tt.key,wt(tt,kn[tt.key]??Kr[tt.key])]));ie.layout&&(Ur(Nr),Vr(Gr));const Ge=Rt(ie.layout?(we==null?void 0:we.hiddenColumnKeys)??$:$,h);if(Be||ut(Ge),ie.filters&&(Mt(Rr(we==null?void 0:we.filters,P)),ar(en(we==null?void 0:we.conditionFilters,P))),ie.sort){const tt=Jr(we==null?void 0:we.sort)?we.sort:null;pr(tt&&P.has(tt.key)?tt:null)}if(ie.bql){if(jr.current!==J){jr.current=J;const tt=typeof(we==null?void 0:we.bql)=="string"?we.bql:re;be?(ke=Wt.current)==null||ke.call(Wt,tt):Ee(tt)}Gt(Array.isArray(we==null?void 0:we.bqlHistory)?we.bqlHistory.filter(tt=>typeof tt=="string"):[])}let Zr;ie.pagination&&(Zr=Wa(we==null?void 0:we.pageSize,Ne,cr),mr.current!==J&&(mr.current=J,ya(Zr))),Yt.current=JSON.stringify({columnOrder:Nr,columnWidths:Gr,hiddenColumnKeys:Ge,filters:Rr(we==null?void 0:we.filters,P),conditionFilters:en(we==null?void 0:we.conditionFilters,P),sort:Jr(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:ie.pagination&&xr!==!1?Zr:void 0}),me.current=!0}}).finally(()=>{window.clearTimeout(ye),ve||(We.current=J,dt(!0),oe())}),()=>{ve=!0,nt.abort(),window.clearTimeout(ye)}},[J,Se,_e,ot,Be,ie.layout,ie.filters,ie.sort,ie.bql,ie.pagination,be,re,Zb]),s.useEffect(()=>{if(!J||!ct||!Se||!me.current)return;const h={};ie.layout&&(h.columnOrder=qr,h.columnWidths=hr,h.hiddenColumnKeys=qe),ie.filters&&(h.filters=pt,h.conditionFilters=Tt),ie.sort&&(h.sort=et),ie.bql&&(h.bql=xe,h.bqlHistory=sr),ie.pagination&&M!==!1&&(h.pageSize=xa);const $=Ln(J),Q=bs($,h),P=JSON.stringify(Q);if(P===Yt.current)return;Pc(J,Q),Yt.current=P;const oe=window.setTimeout(()=>{const ve=za()??"/api/user/preferences/datatables";fetch(ve,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({key:J,settings:Q})}).then(()=>{}).catch(()=>{})},300);return()=>window.clearTimeout(oe)},[qr,hr,qe,pt,Tt,et,xe,sr,xa,M,J,ct,Se,ie.layout,ie.filters,ie.sort,ie.bql,ie.pagination]),s.useEffect(()=>{Ur(h=>{const $=e.map(Q=>Q.key);return Jt(Dn(h,$),e)})},[_e,e]);const Ei=Jt(qr,e).map(h=>e.find($=>$.key===h)).filter(h=>!!h),$t=Ei.filter(h=>!qe.includes(h.key)),Ci=e.some(ja),cm=Object.keys(pt).length,dm=Object.keys(Tt).length,Bo=cm+dm;function Mi(h){const $=new Set;return r.reduce((Q,P)=>{const oe=On(h,P);return!oe||$.has(oe)||($.add(oe),Q.push({value:oe,label:oe})),Q},[])}function um(){const h=e.find($=>$.key===bt);return h?Mi(h):[]}function fm(h){return!!(O&&!ur(h)&&(h.filterValue||h.sortKey||Mi(h).length>0))}function Ti(h,$){Mt(Q=>{const P={...Q};return P[h]=$,P})}function bm(h,$,Q,P){const oe=pt[h]??[],ve=P?oe:Q.filter($e=>$e!==$),Ce=P?oe.includes($)?oe.filter($e=>$e!==$):[...oe,$]:ve;Ce.length===Q.length?Fo(h):Ti(h,Ce)}function Fo(h){Mt($=>{const Q={...$};return delete Q[h],Q})}function wa(h,$){ar(Q=>{const P={...Q};return $?P[h]=$:delete P[h],P})}function $i(h){wa(h,null)}function mm(){Mt({}),ar({})}function hm(h){be||Ee(h),F==null||F(h)}function Ai(h){const $=h.trim();Ie($),(F==null?void 0:F($))!==!1&&(be||Ee($),Re(!1),xt(!1),Ht(!1),$&&Gt(P=>[$,...P.filter(oe=>oe!==$)].slice(0,Dc)))}function Li(){Ie(""),hm(""),Re(!1),xt(!1),Ht(!1)}function Po(h,$){Ie(h),$&&($.style.height="auto",$.style.height=`${Math.min($.scrollHeight,180)}px`)}function Na(h){const $=h.trim();if(!$)return;xi.current=Date.now()+500;const Q=Fe.replace(/\s+$/u,""),P=Q.length===0?$:Q.split(`
|
|
3
|
+
`).map(oe=>oe.trim()).includes($)?Q:`${Q}
|
|
4
|
+
${$}`;Po(P,Oo.current??void 0),requestAnimationFrame(()=>{const oe=Oo.current;if(!oe)return;oe.focus();const ve=oe.value.length;oe.setSelectionRange(ve,ve),Po(oe.value,oe)})}s.useEffect(()=>{Ie(xe)},[xe]);const ka=s.useCallback(()=>{const h=Do.current;if(!h)return;const $=h.getBoundingClientRect(),Q=12,P=8,oe=Math.min(780,Math.max(320,window.innerWidth-32)),ve=Math.max(Q,window.innerWidth-oe-Q),Ce=Math.min(Math.max(Q,$.left),ve),$e=$.bottom+P,Ue=window.innerHeight-$.top+P,Ze=window.innerHeight-$e-Q,yt=$.top-Q-P,nt=Ze<280&&yt>Ze,ye=Math.max(240,nt?yt:Ze);Jb({position:"fixed",zIndex:1e4,left:Ce,top:nt?void 0:$e,bottom:nt?Ue:void 0,width:oe,maxWidth:"calc(100vw - 24px)",maxHeight:ye,overflowY:"auto"})},[]);s.useEffect(()=>{if(!Je)return;function h(P){var ve,Ce;if(Date.now()<xi.current)return;const oe=P.target;(ve=Do.current)!=null&&ve.contains(oe)||(Ce=vi.current)!=null&&Ce.contains(oe)||(Re(!1),xt(!1),Ht(!1))}function $(P){P.key==="Escape"&&(Re(!1),xt(!1),Ht(!1))}function Q(){ka()}return ka(),document.addEventListener("mousedown",h),window.addEventListener("keydown",$),window.addEventListener("resize",Q),window.addEventListener("scroll",Q,!0),()=>{document.removeEventListener("mousedown",h),window.removeEventListener("keydown",$),window.removeEventListener("resize",Q),window.removeEventListener("scroll",Q,!0)}},[Je,ka]);function Di(h){const $=Rt(h,e);Be||ut($),ee==null||ee($)}function pm(h){Di(qe.includes(h)?qe.filter($=>$!==h):[...qe,h])}function gm(){Di([])}const _o=s.useCallback((h=ga.current)=>{if(!h)return;const $=h.getBoundingClientRect(),Q=Math.min(292,Math.max(240,window.innerWidth-16)),P=Math.max(8,window.innerWidth-Q-8),oe=Math.min(Math.max(8,$.right-Q),P),ve=window.innerHeight-$.bottom,Ce=$.bottom+6,$e=window.innerHeight-$.top+6,Ze=ve<360&&$.top>ve?void 0:Ce,yt=Ze===void 0?$e:void 0,nt=Math.max(220,Ze===void 0?$.top-16:window.innerHeight-Ce-8),ye={position:"fixed",zIndex:9999,left:oe,top:Ze,bottom:yt,width:Q,maxWidth:"calc(100vw - 16px)",maxHeight:nt,"--dt-column-menu-max-height":`${nt}px`};em(ye)},[]);function Oi(h,$,Q=null){h.preventDefault(),h.stopPropagation();const P=ga.current===h.currentTarget&&ht===$&&bt===Q;if(Ve&&P){ft(!1),ze(null);return}ga.current=h.currentTarget,br($),ze(Q),fa(""),_o(h.currentTarget),ft(!0)}function vm(h){if(ur(h))return;const $=lr.current;if(!$)return;const P=Array.from($.querySelectorAll("[data-dt-column-key]")).filter(oe=>oe.dataset.dtColumnKey===h.key).reduce((oe,ve)=>{const Ce=ve.querySelector("[data-dt-autofit-content]"),$e=Ce?Ce.scrollWidth:Math.max(ve.scrollWidth,ve.offsetWidth);return Math.max(oe,Math.ceil($e+zc(ve)))},0);P<=0||Vr(oe=>({...oe,[h.key]:wt(h,P+12)}))}s.useEffect(()=>{Vr(h=>{const $=Object.fromEntries(e.map(Q=>[Q.key,wt(Q,Vt(Q.width))]));return Object.fromEntries(e.map(Q=>[Q.key,wt(Q,h[Q.key]??$[Q.key])]))})},[_e,e]),s.useEffect(()=>{Be||ut(h=>Rt(h,e))},[_e,e,Be]),s.useEffect(()=>{function h(P){var Ce,$e;const oe=P.target,ve=P.target;ve!=null&&ve.closest("[data-bonsaif-select-dropdown='true']")||!((Ce=yi.current)!=null&&Ce.contains(oe))&&!(($e=ga.current)!=null&&$e.contains(oe))&&(ft(!1),ze(null))}function $(P){P.key==="Escape"&&(ft(!1),ze(null))}function Q(){_o()}return Ve&&(document.addEventListener("mousedown",h),window.addEventListener("keydown",$),window.addEventListener("resize",Q),window.addEventListener("scroll",Q,!0)),()=>{document.removeEventListener("mousedown",h),window.removeEventListener("keydown",$),window.removeEventListener("resize",Q),window.removeEventListener("scroll",Q,!0)}},[Ve,_o]);const yn=s.useRef(null);s.useEffect(()=>{function h(Q){const P=yn.current;if(!P)return;const oe=Q.clientX-P.startX,ve=e.find(Ce=>Ce.key===P.colKey);ve&&Vr(Ce=>({...Ce,[P.colKey]:wt(ve,P.startWidth+oe)}))}function $(){yn.current&&(yn.current=null,document.body.style.cursor="",document.body.style.userSelect="")}return document.addEventListener("pointermove",h),document.addEventListener("pointerup",$),()=>{document.removeEventListener("pointermove",h),document.removeEventListener("pointerup",$)}},[e]);const wn=s.useRef(null),[Hi,zo]=s.useState(null);function xm(h,$){const Q=e.find(P=>P.key===h);if(!Q||!ms(Q)){$.preventDefault();return}wn.current=qr.indexOf(h),$.dataTransfer.effectAllowed="move"}function ym(h,$){$.preventDefault(),$.dataTransfer.dropEffect="move";const Q=qr.indexOf(h);Hi!==Q&&zo(Q)}function wm(h,$){$.preventDefault();const Q=wn.current,P=qr.indexOf(h);Q!==null&&Q!==P&&Ur(oe=>{const ve=[...oe],[Ce]=ve.splice(Q,1);return ve.splice(P,0,Ce),Jt(ve,e)}),wn.current=null,zo(null)}function Nm(){wn.current=null,zo(null)}function km(h){h.sortKey&&pr($=>($==null?void 0:$.key)===h.key?{key:h.key,dir:$.dir==="asc"?"desc":"asc"}:{key:h.key,dir:"asc"})}s.useEffect(()=>{va(1)},[r]),s.useEffect(()=>{va(1)},[Tt,pt]);const jt=!!(V&&ne),ir=M!==!1,Wo=s.useMemo(()=>rn(N??Qr()),[N]),it=jt?G??1:im,Ii=ir&&xa<1?typeof M=="number"&&M>0?M:Wo[0]??25:xa,qt=jt||ir?Ii:r.length,It=!!E&&!!v&&!!w,jo=s.useMemo(()=>A?r.filter(h=>A(h)):r,[r,A]),Xr=!!u,Bi=s.useMemo(()=>new Set(Wr?Array.from(b??[]):W),[Wr,b,W]),Sm=(Xr?40:0)+(It?40:0),qo=!sm&&(Ci||R),Sa=(()=>{if(!qo)return{};let h=Sm;const $={};return $t.forEach((Q,P)=>{(ja(Q)||!Ci&&R&&P===0)&&($[Q.key]=h,h+=hr[Q.key]??wt(Q,Vt(Q.width)))}),$})(),Uo=Object.keys(Sa),Vo=Uo.length>0?Uo[Uo.length-1]:null,Fi=It&&jo.length>0&&jo.every(h=>E.has(n(h))),Em=It&&E.size>0&&jo.some(h=>E.has(n(h)))&&!Fi,Ea=s.useMemo(()=>{if(jt)return r;const h=Object.entries(pt),$=Object.entries(Tt);return h.length===0&&$.length===0?r:r.filter(Q=>h.every(([P,oe])=>{const ve=e.find(Ce=>Ce.key===P);return ve?oe.includes(On(ve,Q)):!0})&&$.every(([P,oe])=>{const ve=e.find($e=>$e.key===P);if(!ve)return!0;const Ce=r.map($e=>On(ve,$e));return qc(On(ve,Q),oe,Ce)}))},[Tt,pt,e,r,jt]),gr=s.useMemo(()=>{if(!et)return Ea;const h=e.find($=>$.key===et.key&&$.sortKey);return h!=null&&h.sortKey?[...Ea].sort(($,Q)=>{const P=$[h.sortKey],oe=Q[h.sortKey],ve=P===oe?0:P==null?1:oe==null||P<oe?-1:1;return et.dir==="asc"?ve:-ve}):Ea},[Ea,et,e]),Pi=s.useMemo(()=>{if(jt||!ir)return gr;const h=(it-1)*qt;return gr.slice(h,h+qt)},[gr,jt,ir,it,qt]),Zt=jt?D??r.length:gr.length,Xo=ir?Math.max(1,Math.ceil(Zt/qt)):1,Cm=Math.min(...Wo),Mm=ir&&(Zt>qt||Zt>Cm),Tm=ir?(it-1)*qt+1:1,$m=ir?Math.min(it*qt,Zt):Zt;function Yo(h){if(a)return;const $=Math.max(1,Math.min(h,Xo));jt?V($):va($)}function Am(h){a||(J&&(mr.current=J),ya(h),jt?(ne(h),V(1)):(va(1),ne==null||ne(h)))}function _i(h){const $=new Set(Bi);$.has(h)?$.delete(h):$.add(h);const Q=Array.from($);Wr||Z(Q),g==null||g(Q)}s.useEffect(()=>{De==null||De({bql:xe,filters:pt,conditionFilters:Tt,sort:et,page:it,pageSize:qt,hiddenColumnKeys:qe})},[xe,pt,Tt,et,it,qt,qe,De]);const zi=h=>h==="center"?"justify-center text-center":h==="right"?"justify-end text-right":"justify-start text-left",Lm="color-mix(in srgb, var(--primary) 6%, var(--bg-card))",Ko="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%)",Pe="color-mix(in srgb, var(--border) 62%, var(--bg-card))",vr="color-mix(in srgb, var(--primary) 24%, var(--border))",Ca=`inset 0 0 0 1px ${Pe}`,Wi=$t.reduce((h,$)=>h+(hr[$.key]??Vt($.width)),(Xr?40:0)+(It?40:0)),ji=typeof B=="number"?B:typeof B=="string"?Number(((Ki=B.match(/^(\d+(?:\.\d+)?)px$/))==null?void 0:Ki[1])??NaN):NaN,Nn=Number.isFinite(ji)?Math.max(Wi,ji,ki):Math.max(Wi,ki),Ma=B??Nn,Yr=`${Xr?"40px ":""}${It?"40px ":""}${$t.map(h=>`${hr[h.key]??Vt(h.width)}px`).join(" ")}`;s.useEffect(()=>{et&&qe.includes(et.key)&&pr(null)},[qe,et]);function qi(h){return h?typeof h=="string"?{key:h,label:h}:h:null}const Ta=()=>t.jsxs("div",{role:"row",className:"grid",style:{gridTemplateColumns:Yr,background:Ko,borderBottom:`1px solid ${vr}`},children:[Xr&&t.jsx("div",{role:"columnheader",className:`${Y?"px-2 py-1.5":"px-3 py-2.5"} w-10`,style:{borderBottom:`1px solid ${vr}`,borderRight:`1px solid ${Pe}`}}),It&&t.jsx("div",{role:"columnheader",className:`${Y?"px-2 py-1.5":"px-3 py-2.5"} flex w-10 items-center justify-center`,style:qo?{position:"sticky",left:0,zIndex:12,background:Ko,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)",boxShadow:`inset 0 -1px 0 ${vr}`,borderRight:`1px solid ${Pe}`}:{borderBottom:`1px solid ${vr}`,borderRight:`1px solid ${Pe}`},children:t.jsx(Mn,{size:"sm",checked:Fi,indeterminate:Em,onChange:w,"aria-label":"Seleccionar todos",containerClassName:"items-center",className:"cursor-pointer"})}),$t.map((h,$)=>{const Q=(et==null?void 0:et.key)===h.key,P=!!h.sortKey,oe=ur(h),ve=Sa[h.key],Ce=ve!==void 0,$e=h.key===Vo,Ue=ms(h),Ze=Hi===$,nt=(hr[h.key]??Vt(h.width))<120,ye=Object.prototype.hasOwnProperty.call(pt,h.key)||Object.prototype.hasOwnProperty.call(Tt,h.key);return t.jsxs("div",{role:"columnheader","data-dt-column-key":h.key,className:`group select-none ${nt?"text-left":zi(h.align)}`,style:{...Ce?{position:"sticky",left:ve,zIndex:12,background:Ko,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)",boxShadow:$e?`3px 0 6px -2px rgba(0,0,0,0.10), inset 0 -1px 0 ${vr}`:`inset 0 -1px 0 ${vr}`,borderRight:`1px solid ${Pe}`}:{position:"relative",borderBottom:`1px solid ${vr}`,borderRight:`1px solid ${Pe}`},color:Q?"var(--primary)":"var(--text-muted)",whiteSpace:"nowrap",transition:"color 0.15s",borderLeft:Ze?"2px solid var(--primary)":"2px solid transparent",cursor:"default",padding:oe?Y?"7px 6px":"9px 8px":Y?"8px 6px 10px":"10px 8px 12px"},onDragOver:Le=>{(Ue||wn.current!==null)&&ym(h.key,Le)},onDrop:Le=>wm(h.key,Le),children:[t.jsxs("div",{className:`flex min-w-0 items-center gap-1 ${oe?"justify-center":nt?"justify-start":h.align==="center"?"justify-center":h.align==="right"?"justify-end":"justify-start"}`,children:[Ue?t.jsx("span",{draggable:!0,onDragStart:Le=>{Le.stopPropagation(),xm(h.key,Le)},onDragEnd:Le=>{Le.stopPropagation(),Nm()},onClick:Le=>Le.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 ${Ze?"bg-[var(--primary)]/20":""}`,style:{cursor:"grab"}}):null,oe?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(j.HiCog6Tooth,{className:"h-3.5 w-3.5"})}):t.jsx(hs,{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 ${Y?"text-[11px]":"text-xs"}`,children:t.jsx("span",{className:"min-w-0 truncate",children:h.header})})}),P&&t.jsx("button",{type:"button","aria-label":`Ordenar por ${String(h.header)}`,title:"Ordenar",onClick:Le=>{Le.stopPropagation(),km(h)},"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 ${Q?"opacity-100":"opacity-0 group-hover:opacity-100 group-focus-within:opacity-100"}`,style:{bottom:"-0.5rem",top:"auto"},children:Q?et.dir==="asc"?t.jsx(j.HiChevronUp,{className:"h-3 w-3"}):t.jsx(j.HiChevronDown,{className:"h-3 w-3"}):t.jsx(j.HiChevronUpDown,{className:"h-3 w-3"})}),O&&!oe&&fm(h)&&t.jsx("button",{type:"button","aria-haspopup":"menu","aria-expanded":Ve&&bt===h.key,"aria-label":`Filtrar ${String(h.header)}`,title:"Filtrar",onClick:Le=>Oi(Le,"filter",h.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 ${Ve&&ht==="filter"&&bt===h.key?"bg-[var(--bg-card)] text-[var(--primary)] opacity-100":ye?"text-[var(--primary)] opacity-100":""}`,children:ye?t.jsx(j.HiFunnel,{className:"h-3.5 w-3.5"}):t.jsx(j.HiEllipsisVertical,{className:"h-3.5 w-3.5"})})]}),!oe&&t.jsx("span",{role:"separator","aria-orientation":"vertical",title:"Arrastrar para redimensionar. Doble click para autoajustar",onPointerDown:Le=>{Le.preventDefault(),Le.stopPropagation(),yn.current={colKey:h.key,startX:Le.clientX,startWidth:hr[h.key]??150},document.body.style.cursor="col-resize",document.body.style.userSelect="none"},onDoubleClick:Le=>{Le.preventDefault(),Le.stopPropagation(),yn.current=null,document.body.style.cursor="",document.body.style.userSelect="",vm(h)},onClick:Le=>Le.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"}})]})})]},h.key)})]}),$a=()=>{if(!Ve||typeof document>"u"||ht==="visibility"&&!le||ht==="filter"&&!O)return null;const h=e.find(ye=>ye.key===bt),$=um(),Q=h?Object.prototype.hasOwnProperty.call(pt,h.key):!1,P=h?Tt[h.key]:void 0,oe=An.find(ye=>ye.value===(P==null?void 0:P.operator)),ve=h?pt[h.key]??[]:[],Ce=vn.trim().toLowerCase(),$e=Ce?$.filter(ye=>ye.label.toLowerCase().includes(Ce)):$,Ue=h&&$.length>0&&(!Q||ve.length===$.length),Ze=h&&Q&&ve.length>0&&ve.length<$.length,yt=qe.length,nt=()=>{h&&(Fo(h.key),$i(h.key))};return gt.createPortal(t.jsx("div",{ref:yi,role:"menu",className:"overflow-hidden rounded-lg border p-1 shadow-xl",style:{...Rb,borderColor:"var(--border)",background:"var(--bg-card)"},children:ht==="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:yt>0?`${$t.length} de ${e.length} visibles`:`${e.length} visibles`}),t.jsx("button",{type:"button",onClick:gm,disabled:yt===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:Ei.map(ye=>{const Le=!qe.includes(ye.key),we=!(ye.hideable!==!1)||Le&&$t.length<=1;return t.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":Le,disabled:we,onClick:()=>pm(ye.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:Le?"var(--primary)":"var(--border)",background:Le?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:Le&&t.jsx(j.HiCheck,{className:"h-3 w-3"})}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:ye.header})]},ye.key)})})]}):h?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 ",h.header]}),t.jsx("button",{type:"button",onClick:nt,disabled:!Q&&!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"})]}),h.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:()=>pr({key:h.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(j.HiChevronUp,{className:"h-4 w-4 shrink-0 text-[var(--primary)]"}),t.jsx("span",{className:"truncate",children:"Ascendente"})]}),(et==null?void 0:et.key)===h.key&&et.dir==="asc"&&t.jsx(j.HiCheck,{className:"h-4 w-4 shrink-0 text-[var(--primary)]"})]}),t.jsxs("button",{type:"button",onClick:()=>pr({key:h.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(j.HiChevronDown,{className:"h-4 w-4 shrink-0 text-[var(--primary)]"}),t.jsx("span",{className:"truncate",children:"Descendente"})]}),(et==null?void 0:et.key)===h.key&&et.dir==="desc"&&t.jsx(j.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(dr,{value:(P==null?void 0:P.operator)??"",onChange:ye=>{if(!ye){$i(h.key);return}wa(h.key,{operator:ye,value:(P==null?void 0:P.value)??"",valueTo:(P==null?void 0:P.valueTo)??""})},options:Lc,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"}),(oe==null?void 0:oe.valueMode)!=="none"?t.jsx("input",{value:(P==null?void 0:P.value)??"",onChange:ye=>{P&&wa(h.key,{...P,value:ye.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"})]}),(oe==null?void 0:oe.valueMode)==="between"&&t.jsx("input",{value:(P==null?void 0:P.valueTo)??"",onChange:ye=>{P&&wa(h.key,{...P,valueTo:ye.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(j.HiMagnifyingGlass,{className:"h-4 w-4 shrink-0 text-[var(--text-muted)]"}),t.jsx("input",{value:vn,onChange:ye=>fa(ye.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":Ze?"mixed":!!Ue,onClick:()=>{h&&(Ue&&!Q?Ti(h.key,[]):Fo(h.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:Ue||Ze?"var(--primary)":"var(--border)",background:Ue||Ze?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:[Ze&&t.jsx(j.HiMinus,{className:"h-3 w-3"}),Ue&&!Ze&&t.jsx(j.HiCheck,{className:"h-3 w-3"})]}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:"Seleccionar todo"})]}),$e.map(ye=>{const Le=!Q||ve.includes(ye.value);return t.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":Le,onClick:()=>bm(h.key,ye.value,$.map(ke=>ke.value),Q),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:Le?"var(--primary)":"var(--border)",background:Le?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:Le&&t.jsx(j.HiCheck,{className:"h-3 w-3"})}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:ye.label})]},ye.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(!xn)return;function h($){Ho.current&&!Ho.current.contains($.target)&&pa.current&&!pa.current.contains($.target)&&ha(!1)}return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[xn]);function Ui(h,$){if(h.filterValue){const Q=h.filterValue($);return Q==null||Q===""?"":Tn(Q)}return Tn(kr(h.cell($)))}function Vi(h){return`"${Tn(h).replace(/"/g,'""')}"`}function Aa(h){return Tn(h).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function Xi(){return jt&&Zt>gr.length&&Ha.toast.warning(`Exportando ${gr.length.toLocaleString("es-MX")} de ${Zt.toLocaleString("es-MX")} (página actual). Usa exportación completa si está disponible.`),gr}function Dm(){const h=$t.filter(Ue=>!ur(Ue)),$=Xi(),Q=h.map(Ue=>Vi(kr(Ue.header))).join(","),P=$.map(Ue=>h.map(Ze=>Vi(Ui(Ze,Ue))).join(",")).join(`
|
|
5
|
+
`),oe=`${Q}
|
|
6
|
+
${P}`,ve=new Blob(["\uFEFF"+oe],{type:"text/csv;charset=utf-8;"}),Ce=URL.createObjectURL(ve),$e=document.createElement("a");$e.href=Ce,$e.download=`${Xe}.csv`,document.body.appendChild($e),$e.click(),document.body.removeChild($e),URL.revokeObjectURL(Ce)}function Om(){const h=$t.filter($e=>!ur($e)),$=Xi(),Q=h.map($e=>Aa(kr($e.header))),oe=$.map($e=>h.map(Ue=>Aa(Ui(Ue,$e)))).map($e=>`<tr>${$e.map(Ue=>`<td>${Ue}</td>`).join("")}</tr>`).join(""),ve=`<!DOCTYPE html>
|
|
7
|
+
<html lang="es"><head><meta charset="utf-8"><title>${Aa(Xe)}</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,20 +15,20 @@ ${P}`,ve=new Blob(["\uFEFF"+se],{type:"text/csv;charset=utf-8;"}),Ce=URL.createO
|
|
|
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>${Aa(
|
|
18
|
+
<h3>${Aa(Xe)}</h3>
|
|
19
19
|
<p>${$.length} registros · ${new Date().toLocaleDateString("es")}</p>
|
|
20
|
-
<table><thead><tr>${Q.map(
|
|
21
|
-
<tbody>${
|
|
20
|
+
<table><thead><tr>${Q.map($e=>`<th>${$e}</th>`).join("")}</tr></thead>
|
|
21
|
+
<tbody>${oe}</tbody></table>
|
|
22
22
|
<script>window.onload=()=>{window.print()}<\/script>
|
|
23
|
-
</body></html>`,Ce=window.open("","_blank");Ce&&(Ce.document.write(ve),Ce.document.close())}const La=()=>!
|
|
24
|
-
`).map(Ce=>Ce.trim()).filter(Boolean)).has(se):!1}).slice(0,8);return!le&&Bo===0&&!F&&!et?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:[Bo>0&&t.jsxs("button",{type:"button",onClick:bm,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(W.HiXMark,{className:"h-3.5 w-3.5"}),Bo," filtros"]}),F&&t.jsxs("div",{ref:Do,className:"relative flex min-w-0 flex-1 items-center gap-2",children:[t.jsxs("button",{type:"button",onClick:()=>{if(Ye){Ke(!1);return}ka(),Ke(!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:Ye?"var(--primary)":p?"color-mix(in srgb, var(--primary) 12%, transparent)":"var(--bg-card)",borderColor:Ye||p?"var(--primary)":"var(--border)",color:Ye?"var(--primary-fg)":"var(--primary)"},"aria-expanded":Ye,title:"Abrir filtros BQL",children:[t.jsx(W.HiCommandLine,{className:"h-3.5 w-3.5"}),"BQL",p&&t.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-current"}),Ye?t.jsx(W.HiChevronUp,{className:"h-3.5 w-3.5"}):t.jsx(W.HiChevronDown,{className:"h-3.5 w-3.5"})]}),t.jsx("span",{className:"hidden truncate text-xs text-[var(--text-muted)] sm:inline",children:x}),$.length>0&&t.jsxs("div",{className:"hidden min-w-0 items-center gap-1.5 overflow-hidden lg:flex",children:[$.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)),$.length>3&&t.jsxs("span",{className:"text-xs text-[var(--text-muted)]",children:["+",$.length-3]})]}),p&&t.jsx("button",{type:"button","aria-label":"Limpiar BQL",title:"Limpiar BQL",onClick:$i,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(W.HiXMark,{className:"h-4 w-4"})}),Ye&&ht.createPortal(t.jsxs("div",{ref:hi,className:"flex flex-col gap-3 rounded-lg p-3 shadow-2xl",style:{...Zb,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:[ee.map(P=>t.jsxs("button",{type:"button",onMouseDown:se=>{se.preventDefault(),se.stopPropagation()},onClick:se=>{se.preventDefault(),se.stopPropagation(),Na(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)),fe.length>0&&t.jsxs("button",{type:"button",onClick:()=>vt(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":or,children:[t.jsx(W.HiInformationCircle,{className:"h-3.5 w-3.5"}),"Ejemplos"]}),sr.length>0&&t.jsxs("button",{type:"button",onClick:()=>Ht(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":Yt,children:[t.jsx(W.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 ${ae?"var(--danger)":p?"var(--primary)":"var(--border)"}`},children:[t.jsx("textarea",{ref:Oo,value:He,rows:3,onChange:P=>Po(P.target.value,P.target),onKeyDown:P=>{P.key==="Enter"&&!P.shiftKey&&(P.preventDefault(),Ti(He)),P.key==="Escape"&&Ke(!1)},placeholder:T,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"}}),Q.length>0&&t.jsx("div",{className:"border-t border-[var(--border)] bg-[var(--bg-card)]",children:Q.map(P=>t.jsx("button",{type:"button",onMouseDown:se=>{se.preventDefault(),se.stopPropagation()},onClick:se=>{se.preventDefault(),se.stopPropagation(),Na(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:ae?"var(--danger)":"var(--text-muted)"},children:ae??(p?`${$.length||1} filtro${($.length||1)===1?"":"s"} activo${($.length||1)===1?"":"s"}`:"Enter aplica la consulta. Shift + Enter agrega linea.")}),$.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))]}),Yt&&sr.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(W.HiClock,{className:"h-3.5 w-3.5"}),"Historial"]}),t.jsxs("button",{type:"button",onClick:()=>{Kt([]),Ht(!1)},className:"inline-flex items-center gap-1 rounded px-2 py-0.5 text-xs text-[var(--text-muted)]",children:[t.jsx(W.HiTrash,{className:"h-3 w-3"}),"Limpiar"]})]}),sr.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:se=>{se.preventDefault(),se.stopPropagation()},onClick:se=>{se.preventDefault(),se.stopPropagation(),Na(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:()=>Kt(se=>se.filter(ve=>ve!==P)),className:"rounded p-1 text-[var(--text-muted)] opacity-0 transition-opacity group-hover:opacity-100",children:t.jsx(W.HiXMark,{className:"h-3.5 w-3.5"})})]},P))]}),or&&fe.length>0&&t.jsx("div",{className:"grid gap-2 sm:grid-cols-2 lg:grid-cols-3",children:fe.map(P=>t.jsxs("button",{type:"button",onMouseDown:se=>{se.preventDefault(),se.stopPropagation()},onClick:se=>{se.preventDefault(),se.stopPropagation(),Na(P.bql),vt(!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:$i,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(W.HiXMark,{className:"h-3.5 w-3.5"}),"Limpiar"]}),t.jsxs("button",{type:"button",onClick:()=>Ti(He),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(W.HiCheck,{className:"h-3.5 w-3.5"}),"Aplicar"]})]})]}),document.body)]})]}),et&&t.jsx("button",{ref:ha,type:"button","aria-haspopup":"menu","aria-expanded":yn,"aria-label":"Exportar datos",title:"Exportar datos",onClick:()=>{var se;const P=(se=ha.current)==null?void 0:se.getBoundingClientRect();P&&tm({top:P.bottom+4,right:window.innerWidth-P.right}),pa(ve=>!ve)},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)] ${yn?"bg-[var(--bg-card)] text-[var(--primary)]":""}`,children:t.jsx(W.HiArrowDownTray,{className:"h-4 w-4"})}),le&&t.jsx("button",{type:"button","aria-haspopup":"menu","aria-expanded":je&&mt==="visibility","aria-label":B,title:B,onClick:P=>Li(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)] ${je&&mt==="visibility"?"bg-[var(--bg-card)] text-[var(--primary)]":""}`,children:t.jsx(W.HiCog6Tooth,{className:"h-4 w-4"})})]})},Vi=()=>{if(!Cm)return null;const p=_c(st,Xo);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 ${X?"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:Gt===0?"0 filas":`${Mm}–${Tm} de ${Gt}`}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("span",{style:{color:"var(--text-muted)"},children:"Filas:"}),t.jsx(dr,{value:String(jt),onChange:$=>$m(Number($)),options:Wo.map($=>({value:String($),label:String($)})),placeholder:"Filas",searchable:!1,disabled:a,height:Y,padding:K,className:"shrink-0 [&>button]:rounded-md [&>button]:text-xs [&_svg]:h-3.5 [&_svg]:w-3.5",style:{width:_}})]})]}),t.jsxs("div",{className:"flex items-center justify-center gap-0.5",children:[t.jsx("button",{disabled:a||st<=1,onClick:()=>Yo(st-1),onMouseEnter:$=>{$.currentTarget.disabled||($.currentTarget.style.background="color-mix(in srgb, var(--primary) 14%, var(--bg-card))",$.currentTarget.style.color="var(--primary)")},onMouseLeave:$=>{$.currentTarget.style.background="transparent",$.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(W.HiChevronLeft,{className:"h-3.5 w-3.5"})}),p.map(($,Q)=>$==="..."?t.jsx("span",{className:"px-1",style:{color:"var(--text-muted)"},children:"…"},`e${Q}`):t.jsx("button",{disabled:a,onClick:()=>Yo($),onMouseEnter:P=>{P.currentTarget.disabled||$===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=$===st?"var(--primary)":"transparent",P.currentTarget.style.color=$===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:$===st?"var(--primary)":"transparent",color:$===st?"var(--primary-fg)":"var(--text-muted)"},children:$},$)),t.jsx("button",{disabled:a||st>=Xo,onClick:()=>Yo(st+1),onMouseEnter:$=>{$.currentTarget.disabled||($.currentTarget.style.background="color-mix(in srgb, var(--primary) 14%, var(--bg-card))",$.currentTarget.style.color="var(--primary)")},onMouseLeave:$=>{$.currentTarget.style.background="transparent",$.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(W.HiChevronRight,{className:"h-3.5 w-3.5"})})]}),t.jsx("div",{"aria-hidden":"true"})]})},Om=()=>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:Ca},children:[$a(),La(),Da(),t.jsx("div",{ref:lr,className:"min-w-0 max-w-full overflow-hidden",children:t.jsxs("div",{role:"table",className:"text-sm",style:{width:Nn,minWidth:Ma},children:[t.jsx("div",{role:"rowgroup",style:y?{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,$)=>t.jsxs("div",{role:"row",className:"grid",style:{gridTemplateColumns:Yr,borderBottom:`1px solid ${Ie}`},children:[It&&t.jsx("div",{role:"cell",className:`${X?"px-2 py-1.5":"px-3 py-2"} w-10`,style:{borderBottom:`1px solid ${Ie}`,borderRight:`1px solid ${Ie}`}},"select-cell"),$t.map((Q,P)=>t.jsx("div",{role:"cell",className:X?"px-2 py-1.5":"px-3 py-2",style:{borderBottom:`1px solid ${Ie}`,borderRight:`1px solid ${Ie}`},children:t.jsx("div",{className:"h-3.5 rounded-full animate-pulse",style:{background:"var(--border)",width:`${xi($,P)}%`,minWidth:32}})},Q.key))]},$))})]})})]}),Go="min-w-0 max-w-full overflow-hidden";return J&&Pe&&!lt?t.jsx(Cn,{rows:o,columns:Math.max(4,$t.length||7)}):!a&&r.length===0&&!Io?Om():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:Ca},children:[$a(),La(),Da(),t.jsx("div",{ref:lr,className:Go,children:t.jsx(Zo.OverlayScrollbarsComponent,{options:{scrollbars:{autoHide:"leave",autoHideDelay:200}},className:"w-full",style:{maxHeight:Ni,maxWidth:"100%"},defer:!0,children:t.jsxs("div",{role:"table",className:"text-sm",style:{width:Nn,minWidth:Ma},children:[t.jsx("div",{role:"rowgroup",style:y?{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,$)=>t.jsxs("div",{role:"row",className:"grid",style:{gridTemplateColumns:Yr,borderBottom:`1px solid ${Ie}`},children:[It&&t.jsx("div",{role:"cell",className:`${X?"px-2 py-1.5":"px-3 py-2"} w-10`,style:{borderBottom:`1px solid ${Ie}`,borderRight:`1px solid ${Ie}`}},"select-cell"),$t.map((Q,P)=>{const se=Sa[Q.key],ve=se!==void 0,Ce=Q.key===Vo;return t.jsx("div",{role:"cell","data-dt-column-key":Q.key,className:X?"px-2 py-1.5":"px-3 py-2",style:ve?{position:"sticky",left:se,zIndex:1,background:"color-mix(in srgb, var(--bg-card) 72%, transparent)",backdropFilter:"blur(10px)",WebkitBackdropFilter:"blur(10px)",boxShadow:Ce?`3px 0 6px -2px rgba(0,0,0,0.10), inset 0 -1px 0 ${Ie}`:`inset 0 -1px 0 ${Ie}`,borderRight:`1px solid ${Ie}`}:{borderBottom:`1px solid ${Ie}`,borderRight:`1px solid ${Ie}`},children:t.jsx("div",{className:"h-3.5 rounded-full animate-pulse",style:{background:"var(--border)",width:`${xi($,P)}%`,minWidth:32}})},Q.key)})]},$))})]})})}),Vi()]}):!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:Ca},children:[$a(),La(),Da(),t.jsx("div",{ref:lr,className:Go,children:t.jsx("div",{role:"table",className:"text-sm",style:{width:Nn,minWidth:Ma},children:t.jsx("div",{role:"rowgroup",style:y?{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:Ie,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(W.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:Ca},children:[$a(),La(),Da(),t.jsx("div",{ref:lr,className:Go,children:t.jsx(Zo.OverlayScrollbarsComponent,{options:{scrollbars:{autoHide:"leave",autoHideDelay:200}},className:"w-full",style:{maxHeight:Ni,maxWidth:"100%"},defer:!0,children:t.jsxs("div",{role:"table",className:"text-sm",style:{width:Nn,minWidth:Ma},children:[t.jsx("div",{role:"rowgroup",style:y?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:Ta()}),t.jsx("div",{role:"rowgroup",children:Bi.map((p,$)=>{const Q=n(p),P=Wi(N==null?void 0:N(p)),se=$>0?Wi(N==null?void 0:N(Bi[$-1])):null,ve=P&&P.key!==(se==null?void 0:se.key),Ce=It&&E.has(Q),Te=It&&(!A||A(p)),We=Xr?(m==null?void 0:m(p))??!0:!1,Ue=We&&Hi.has(Q),yt=!!d||h&&We,tt=Ce&&C?"color-mix(in srgb, var(--primary) 8%, var(--bg-card))":$%2===1?"color-mix(in srgb, var(--bg-input) 30%, var(--bg-card))":"var(--bg-card)";return t.jsxs(s.Fragment,{children:[ve&&t.jsx("div",{role:"row",className:`grid ${P.className??""}`,style:{gridTemplateColumns:Yr},children:t.jsx("div",{role:"cell",className:X?"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 ${Ie}`,borderRight:`1px solid ${Ie}`},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:yt?we=>{const $e=we.target;if(!($e!=null&&$e.closest('[data-dt-disable-row-click="true"]'))){if(h&&We){Fi(Q);return}d==null||d(p)}}:void 0,className:`grid transition-colors ${yt?"cursor-pointer":""} ${O?O(p):""}`,style:{gridTemplateColumns:Yr,"--dt-row-bg":tt,"--dt-sticky-bg":tt,background:"var(--dt-row-bg)",borderBottom:`1px solid ${Ie}`},onMouseEnter:we=>{Ce||(we.currentTarget.style.setProperty("--dt-row-bg","var(--bg-hover)"),we.currentTarget.style.setProperty("--dt-sticky-bg",Am))},onMouseLeave:we=>{we.currentTarget.style.setProperty("--dt-row-bg",tt),we.currentTarget.style.setProperty("--dt-sticky-bg",tt)},children:[Xr&&t.jsx("div",{role:"cell",className:`${X?"px-2 py-1.5":"px-3 py-2"} flex w-10 items-center justify-center`,style:{borderBottom:`1px solid ${Ie}`,borderRight:`1px solid ${Ie}`},"data-dt-disable-row-click":"true",children:We&&t.jsx("button",{type:"button","aria-label":Ue?"Contraer fila":"Desplegar fila","aria-expanded":Ue,onClick:we=>{we.stopPropagation(),Fi(Q)},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(W.HiChevronDown,{className:"h-4 w-4"}):t.jsx(W.HiChevronRight,{className:"h-4 w-4"})})}),It&&t.jsx("div",{role:"cell",className:`${X?"px-2 py-1.5":"px-3 py-2"} flex w-10 items-center justify-center`,style:qo?{position:"sticky",left:0,zIndex:3,background:"var(--dt-sticky-bg)",boxShadow:`inset 0 -1px 0 ${Ie}`}:{borderBottom:`1px solid ${Ie}`,borderRight:`1px solid ${Ie}`},onClick:we=>{we.stopPropagation(),Te&&v(Q)},children:t.jsx(Mn,{size:"sm",checked:Ce,disabled:!Te,"aria-label":Te?"Seleccionar fila":"Fila no seleccionable",containerClassName:"items-center",className:Te?"cursor-pointer":"cursor-not-allowed opacity-50",onClick:we=>we.stopPropagation(),onChange:()=>{Te&&v(Q)}})}),$t.map(we=>{const $e=Sa[we.key],Se=$e!==void 0,Ne=we.key===Vo,ke=ur(we);return t.jsx("div",{role:"cell","data-dt-column-key":we.key,"data-dt-disable-row-click":we.disableRowClick||ke?"true":void 0,className:`${ke?"px-2 py-1.5 justify-center text-center":`${X?"px-2 py-1.5":"px-3 py-2"} ${Pi(we.align)}`} flex min-w-0 items-center ${Oc} ${we.className??""}`,style:{overflow:"hidden",whiteSpace:"nowrap",...Se?{position:"sticky",left:$e,zIndex:3,background:"var(--dt-sticky-bg)",boxShadow:Ne?`3px 0 6px -2px rgba(0,0,0,0.10), inset 0 -1px 0 ${Ie}`:`inset 0 -1px 0 ${Ie}`,borderRight:`1px solid ${Ie}`}:{borderBottom:`1px solid ${Ie}`,borderRight:`1px solid ${Ie}`}},children:t.jsx(ps,{children:t.jsx("div",{"data-dt-autofit-content":!0,className:"inline-block max-w-none align-middle",children:we.cell(p)})})},we.key)})]}),Ue&&u&&t.jsx("div",{role:"row",className:"grid",style:{gridTemplateColumns:Yr},children:t.jsx("div",{role:"cell",className:X?"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 ${Ie}`},children:u(p)})})]},Q)})})]})})}),Vi()]})}const jc={sm:"min-h-[160px] p-4",md:"min-h-[220px] p-6",lg:"min-h-[300px] p-8"};function Hn({title:e="Sin resultados",description:r,icon:n=t.jsx(W.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 ${jc[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]})]})})}function Rt(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 hs(e){if(!e)return null;const r=String(e).slice(0,10),[n,a,o]=r.split("-").map(Number);return!n||!a||!o?null:new Date(n,a-1,o)}function nn(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate())}function Er(e,r){const n=new Date(e);return n.setDate(n.getDate()+r),n}function gs(e){const r=nn(e),n=(r.getDay()+6)%7;return Er(r,-n)}function vs(e){const r=gs(e);return Array.from({length:7},(n,a)=>Er(r,a))}function ys(e){const r=new Date(e.getFullYear(),e.getMonth(),1),n=gs(r);return Array.from({length:42},(a,o)=>Er(n,o))}function xs(e){const r=[];for(let n=0;n<e.length;n+=7)r.push(e.slice(n,n+7));return r}function qc(e,r,n,a){return e.getTime()<=a.getTime()&&r.getTime()>=n.getTime()}function er(e,r){const n=r?r(e):{start:e.startDate,end:e.endDate},a=hs(n.start);if(!a)return null;const o=hs(n.end??n.start)??a;return o.getTime()<a.getTime()?{start:o,end:a}:{start:a,end:o}}function ws(e,r){const n={};for(const a of e){const o=er(a,r);if(!o)continue;let l=nn(o.start);const i=nn(o.end);for(;l.getTime()<=i.getTime();){const c=Rt(l);n[c]||(n[c]=[]),n[c].push(a),l=Er(l,1)}}return n}function Ua(e,r,n){if(r.length===0)return[];const a=nn(r[0]),o=nn(r[r.length-1]),l=[],i=[],c=[...e].sort((d,u)=>{const m=er(d,n),b=er(u,n),f=(m==null?void 0:m.start.getTime())??0,g=(b==null?void 0:b.start.getTime())??0;return f-g||d.title.localeCompare(u.title)});for(const d of c){const u=er(d,n);if(!u||!qc(u.start,u.end,a,o))continue;const m=u.start.getTime()<a.getTime()?a:u.start,b=u.end.getTime()>o.getTime()?o:u.end,f=Math.max(0,Math.round((m.getTime()-a.getTime())/864e5)),g=Math.min(r.length-1,Math.round((b.getTime()-a.getTime())/864e5)),h=Math.max(1,g-f+1);let E=l.findIndex(v=>v<f);E<0?(E=l.length,l.push(f+h-1)):l[E]=f+h-1,i.push({item:d,lane:E,colStart:f,colSpan:h})}return i}function Lt(e){return new Intl.DateTimeFormat("es-MX",{day:"2-digit",month:"short",year:"numeric"}).format(e)}function Uc(e){const r=new Intl.DateTimeFormat("es-MX",{month:"long",year:"numeric"}).format(e);return r.charAt(0).toUpperCase()+r.slice(1)}function Vc(e){const r=new Intl.DateTimeFormat("es-MX",{weekday:"short",day:"2-digit",month:"short",year:"numeric"}).format(e);return r.charAt(0).toUpperCase()+r.slice(1)}function Xc(e){const r=new Intl.DateTimeFormat("es-MX",{weekday:"short",day:"2-digit",month:"short"}).format(e);return r.charAt(0).toUpperCase()+r.slice(1)}function Ns(e,r,n){return r==="month"?new Date(e.getFullYear(),e.getMonth()+n,1):r==="week"?Er(e,n*7):Er(e,n)}const Yc=["Lun","Mar","Mié","Jue","Vie","Sáb","Dom"];function Kc({item:e,style:r,onClick:n}){const a=e.color??"var(--text-muted)",o=e.bg??"rgba(100, 116, 139, 0.14)",l=er(e),i=l?`${Lt(l.start)} → ${Lt(l.end)}`:"",c=[e.title,e.subtitle,i,e.status].filter(Boolean).join(" · ");return t.jsx(Bt,{content:c||e.title,children:t.jsxs("button",{type:"button",className:"absolute overflow-hidden rounded-md px-1.5 py-0.5 text-left text-[11px] leading-tight transition-opacity hover:opacity-90",style:{...r,background:o,borderLeft:`3px solid ${a}`,boxShadow:"inset 0 0 0 1px var(--border)",color:"var(--text-main)"},onClick:d=>{d.stopPropagation(),n==null||n()},children:[t.jsx("span",{className:"block truncate font-semibold",children:e.title}),e.status?t.jsx("span",{className:"block truncate",style:{color:a},children:e.status}):null]})})}function Gc({item:e,onClick:r}){const n=e.color??"var(--text-muted)",a=e.bg??"rgba(100, 116, 139, 0.10)",o=er(e),l=o?`${Lt(o.start)} → ${Lt(o.end)}`:"";return t.jsxs("button",{type:"button",className:"flex w-full flex-col gap-2 rounded-lg p-4 text-left transition-opacity hover:opacity-95 sm:flex-row sm:items-start sm:justify-between",style:{background:a,border:"1px solid var(--border)",boxShadow:`inset 3px 0 0 ${n}`,color:"var(--text-main)"},onClick:()=>r==null?void 0:r(),children:[t.jsxs("div",{className:"min-w-0 flex-1 space-y-1",children:[t.jsx("div",{className:"text-base font-semibold",children:e.title}),e.subtitle?t.jsx("div",{className:"text-sm leading-5",style:{color:"var(--text-muted)"},children:e.subtitle}):null]}),t.jsxs("div",{className:"flex shrink-0 flex-col gap-2 sm:items-end",children:[e.status?t.jsx("span",{className:"inline-flex rounded-full px-2.5 py-0.5 text-xs font-semibold",style:{color:n,background:"color-mix(in srgb, var(--bg-card) 70%, transparent)",border:`1px solid color-mix(in srgb, ${n} 45%, transparent)`},children:e.status}):null,l?t.jsxs("div",{className:"text-xs",style:{color:"var(--text-secondary)"},children:[t.jsx("span",{className:"font-semibold uppercase tracking-wide opacity-70",children:"Rango"}),t.jsx("div",{children:l})]}):null]})]})}function Zc({item:e,style:r,onClick:n}){const a=e.color??"var(--text-muted)",o=e.bg??"rgba(100, 116, 139, 0.14)",l=er(e),i=l?`${Lt(l.start)} → ${Lt(l.end)}`:"";return t.jsxs("button",{type:"button",className:"absolute mx-1 overflow-hidden rounded-md px-2 py-1.5 text-left text-xs transition-opacity hover:opacity-90",style:{...r,background:o,borderLeft:`3px solid ${a}`,boxShadow:"inset 0 0 0 1px var(--border)",color:"var(--text-main)"},title:[e.title,i,e.status].filter(Boolean).join(" · "),onClick:()=>n==null?void 0:n(),children:[t.jsx("span",{className:"block truncate font-semibold",children:e.title}),t.jsx("span",{className:"block truncate",style:{color:a},children:[e.status,i].filter(Boolean).join(" · ")})]})}function ks({value:e,options:r,onChange:n}){return t.jsx("div",{className:"inline-flex overflow-hidden rounded-lg",style:{border:"1px solid var(--border)"},children:r.map((a,o)=>{const l=e===a.value;return t.jsxs("button",{type:"button",onClick:()=>n(a.value),className:"inline-flex items-center gap-1.5 px-3 py-2 text-xs font-semibold transition-colors",style:{background:l?"var(--primary)":"var(--bg-card)",color:l?"var(--primary-fg, #fff)":"var(--text-secondary)",borderRight:o<r.length-1?"1px solid var(--border)":void 0},children:[a.icon,a.label]},a.value)})})}function Qc({items:e,cursorDate:r,onCursorDateChange:n,displayMode:a,onDisplayModeChange:o,viewMode:l,onViewModeChange:i,getItemDates:c,maxPillsPerDay:d=3,overloadThreshold:u=5,weekdayLabels:m=[...Yc],renderToolbarExtra:b,renderPill:f,renderDayCard:g,renderWeekBar:h,tableColumns:E,tableProps:v,onItemClick:S,onDayClick:A,loading:C=!1,emptyTitle:O="Sin eventos",emptyDescription:N="No hay eventos para los filtros seleccionados.",legend:y,legendInteractive:M=!0,activeLegendKeys:k,defaultActiveLegendKeys:_,onActiveLegendKeysChange:Y,getItemLegendKey:K,overloadLabel:D="Sobrecarga de eventos",className:G="",showToolbar:U=!0}){const ne=s.useMemo(()=>(y??[]).map(ae=>ae.label),[y]),[J,R]=s.useState(()=>_??ne),V=k??(ne.length>0?J:[]),X=s.useMemo(()=>new Set(V),[V]),de=ae=>{k===void 0&&R(ae),Y==null||Y(ae)},H=ae=>{M&&(X.has(ae)?de(V.filter(ye=>ye!==ae)):de([...V,ae]))},I=s.useMemo(()=>{if(!M||ne.length===0)return e;const ae=new Set(ne);return e.filter(ye=>{const Qe=(K==null?void 0:K(ye))??ye.status;return!Qe||!ae.has(Qe)?!0:X.has(Qe)})},[e,M,ne,X,K]),le=s.useMemo(()=>ws(I,c),[I,c]),L=s.useMemo(()=>ys(r),[r]),oe=s.useMemo(()=>xs(L),[L]),w=s.useMemo(()=>vs(r),[r]),te=Rt(r),B=le[te]??[],F=s.useMemo(()=>Ua(I,w,c),[I,w,c]),ue=s.useMemo(()=>F.length===0?1:Math.max(...F.map(ae=>ae.lane))+1,[F]),re=s.useMemo(()=>oe.map(ae=>{const ye=Ua(I,ae,c),Qe=ye.length===0?0:Math.max(...ye.map(Je=>Je.lane))+1;return{days:ae,bars:ye,laneCount:Qe}}),[oe,I,c]),j=36,x=34,T=l==="month"?L:l==="week"?w:[r],ee=s.useMemo(()=>{const ae=[];for(const ye of T){const Qe=Rt(ye),Je=le[Qe]??[];Je.length>=u&&ae.push([ye,Je])}return ae},[T,le,u]),fe=l==="month"?Uc(r):l==="week"?`${Lt(w[0])} – ${Lt(w[6])}`:Vc(r),ie=s.useMemo(()=>[{key:"title",header:"Título",cell:ae=>ae.title},{key:"status",header:"Estado",cell:ae=>ae.status??"—"},{key:"range",header:"Rango",cell:ae=>{const ye=er(ae,c);return ye?`${Lt(ye.start)} → ${Lt(ye.end)}`:"—"}},{key:"subtitle",header:"Detalle",cell:ae=>ae.subtitle??"—"}],[c]),pe=ae=>{if(n(ae),A){A(ae);return}i("day")};return t.jsxs("div",{className:`bonsaif-event-calendar space-y-4 ${G}`.trim(),children:[U?t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("button",{type:"button","aria-label":"Anterior",className:"inline-flex h-9 w-9 items-center justify-center rounded-lg",style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-main)"},onClick:()=>n(Ns(r,l,-1)),children:t.jsx(W.HiChevronLeft,{className:"h-4 w-4"})}),t.jsx("div",{className:"min-w-[160px] text-center text-sm font-semibold capitalize",style:{color:"var(--text-main)"},children:fe}),t.jsx("button",{type:"button","aria-label":"Siguiente",className:"inline-flex h-9 w-9 items-center justify-center rounded-lg",style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-main)"},onClick:()=>n(Ns(r,l,1)),children:t.jsx(W.HiChevronRight,{className:"h-4 w-4"})}),t.jsx("button",{type:"button",className:"rounded-lg px-3 py-2 text-xs font-semibold",style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-secondary)"},onClick:()=>n(new Date),children:"Hoy"})]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[b,t.jsx(ks,{value:a,onChange:o,options:[{value:"calendar",label:"Calendario",icon:t.jsx(W.HiCalendarDays,{className:"h-4 w-4"})},{value:"table",label:"Tabla",icon:t.jsx(W.HiTableCells,{className:"h-4 w-4"})}]}),a==="calendar"?t.jsx(ks,{value:l,onChange:i,options:[{value:"month",label:"Mes"},{value:"week",label:"Semana"},{value:"day",label:"Día"}]}):null]})]}):null,y&&y.length>0?t.jsx("div",{className:"flex flex-wrap items-center gap-2 text-xs",role:M?"group":void 0,"aria-label":M?"Filtrar por estado":void 0,children:y.map(ae=>{const ye=X.has(ae.label);return M?t.jsxs("button",{type:"button","aria-pressed":ye,onClick:()=>H(ae.label),className:"inline-flex items-center gap-1.5 rounded-full px-2.5 py-1 transition-opacity",style:{color:ye?"var(--text-main)":"var(--text-muted)",background:ye?"color-mix(in srgb, var(--bg-card) 80%, transparent)":"transparent",border:ye?`1px solid color-mix(in srgb, ${ae.color} 55%, var(--border))`:"1px solid var(--border)",opacity:ye?1:.45},title:ye?`Ocultar “${ae.label}”`:`Mostrar “${ae.label}”`,children:[t.jsx("span",{className:"inline-block h-2.5 w-2.5 rounded-full",style:{background:ae.color,boxShadow:ye?`0 0 0 2px color-mix(in srgb, ${ae.color} 25%, transparent)`:void 0},"aria-hidden":!0}),ae.label]},ae.label):t.jsxs("span",{className:"inline-flex items-center gap-1.5",style:{color:"var(--text-secondary)"},children:[t.jsx("span",{className:"inline-block h-2.5 w-2.5 rounded-full",style:{background:ae.color},"aria-hidden":!0}),ae.label]},ae.label)})}):null,a==="calendar"&&ee.length>0?t.jsxs("div",{className:"rounded-lg px-4 py-3 text-sm",style:{background:"rgba(217, 119, 6, 0.14)",border:"1px solid rgba(217, 119, 6, 0.35)",color:"#b45309"},children:[t.jsxs("strong",{children:[D,":"]})," ",ee.map(([ae,ye])=>`${Lt(ae)} (${ye.length})`).join(", ")]}):null,a==="table"?C||I.length>0?t.jsx(qa,{columns:E??ie,data:I,getRowId:ae=>ae.id,loading:C,skeletonRows:8,emptyIcon:t.jsx(W.HiCalendarDays,{className:"h-10 w-10"}),emptyText:N,onRowClick:S,pageSize:25,compact:!0,...v}):t.jsx(Hn,{icon:t.jsx(W.HiCalendarDays,{className:"h-5 w-5"}),title:O,description:N}):null,a==="calendar"&&l==="month"?t.jsxs("div",{className:"overflow-hidden rounded-lg",style:{border:"1px solid var(--border)"},children:[t.jsx("div",{className:"grid grid-cols-7",style:{borderBottom:"1px solid var(--border)"},children:m.map(ae=>t.jsx("div",{className:"px-3 py-2 text-xs font-bold uppercase",style:{background:"var(--bg-card)",color:"var(--text-muted)"},children:ae},ae))}),re.map(({days:ae,bars:ye,laneCount:Qe},Je)=>{const et=Math.min(Qe,d),ft=Math.max(0,Qe-d),nt=j+Math.max(1,et)*x+(ft>0?20:8)+8;return t.jsxs("div",{className:"relative",style:{minHeight:nt,borderBottom:Je<re.length-1?"1px solid var(--border)":void 0},children:[t.jsx("div",{className:"grid grid-cols-7",style:{minHeight:nt},children:ae.map(Le=>{const ce=Rt(Le),Pe=le[ce]??[],_e=Le.getMonth()!==r.getMonth();return t.jsx("div",{role:"button",tabIndex:0,"aria-label":`${Le.getDate()}`,onClick:()=>pe(Le),onKeyDown:at=>{(at.key==="Enter"||at.key===" ")&&(at.preventDefault(),pe(Le))},className:"cursor-pointer p-2 text-left transition-colors hover:bg-black/[0.03] dark:hover:bg-white/[0.04]",style:{background:"var(--bg-main)",borderRight:"1px solid var(--border)",minHeight:nt},children:t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsx("span",{className:"text-sm font-semibold",style:{color:_e?"var(--text-muted)":"var(--text-main)"},children:Le.getDate()}),Pe.length>0?t.jsx("span",{className:"rounded-full px-2 py-0.5 text-[11px] font-bold",style:{background:"var(--primary)",color:"var(--primary-fg, #fff)"},children:Pe.length}):null]})},ce)})}),t.jsxs("div",{className:"pointer-events-none absolute inset-x-0",style:{top:j,bottom:4},children:[ye.filter(Le=>Le.lane<d).map(Le=>{const ce={left:`calc(${Le.colStart/7*100}% + 4px)`,width:`calc(${Le.colSpan/7*100}% - 8px)`,top:2+Le.lane*x,height:x-6,pointerEvents:"auto"};return f?t.jsx("div",{className:"absolute",style:ce,children:f(Le.item,{day:ae[Le.colStart]})},`${Le.item.id}-${Le.colStart}-${Je}`):h?t.jsx("div",{className:"absolute",style:ce,children:h(Le.item)},`${Le.item.id}-${Le.colStart}-${Je}`):t.jsx(Kc,{item:Le.item,style:ce,onClick:()=>S==null?void 0:S(Le.item)},`${Le.item.id}-${Le.colStart}-${Je}`)}),ft>0?t.jsxs("span",{className:"absolute text-[11px] font-semibold",style:{left:8,top:2+et*x,color:"var(--text-muted)"},children:["+",ft," más"]}):null]})]},`week-${Je}-${Rt(ae[0])}`)})]}):null,a==="calendar"&&l==="week"?t.jsxs("div",{className:"overflow-hidden rounded-lg",style:{background:"var(--bg-card)",border:"1px solid var(--border)"},children:[t.jsx("div",{className:"grid grid-cols-7 border-b",style:{borderColor:"var(--border)"},children:w.map(ae=>t.jsx("button",{type:"button",className:"px-3 py-2 text-center text-xs font-semibold capitalize",style:{color:"var(--text-main)",borderRight:"1px solid var(--border)"},onClick:()=>pe(ae),children:Xc(ae)},Rt(ae)))}),t.jsxs("div",{className:"relative grid grid-cols-7",style:{minHeight:Math.max(220,ue*56+24)},children:[w.map(ae=>t.jsx("div",{className:"min-h-full",style:{borderRight:"1px solid var(--border)"}},`lane-${Rt(ae)}`)),F.map(ae=>{const ye={left:`calc(${ae.colStart/7*100}% + 4px)`,width:`calc(${ae.colSpan/7*100}% - 8px)`,top:12+ae.lane*56};return h?t.jsx("div",{className:"absolute",style:ye,children:h(ae.item)},`${ae.item.id}-${ae.colStart}`):t.jsx(Zc,{item:ae.item,style:ye,onClick:()=>S==null?void 0:S(ae.item)},`${ae.item.id}-${ae.colStart}`)}),F.length===0&&!C?t.jsx("div",{className:"absolute inset-0 flex items-center justify-center text-sm",style:{color:"var(--text-muted)"},children:N}):null]})]}):null,a==="calendar"&&l==="day"?B.length>0||C?t.jsxs("div",{className:"space-y-3",children:[C&&B.length===0?t.jsx(Hn,{icon:t.jsx(W.HiCalendarDays,{className:"h-5 w-5"}),title:"Cargando…",description:"Obteniendo eventos del día."}):null,B.map(ae=>g?t.jsx("div",{children:g(ae)},ae.id):t.jsx(Gc,{item:ae,onClick:()=>S==null?void 0:S(ae)},ae.id))]}):t.jsx(Hn,{icon:t.jsx(W.HiCalendarDays,{className:"h-5 w-5"}),title:O,description:N}):null]})}function Ss(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 Jc(e){var r;if((r=navigator.clipboard)!=null&&r.writeText){await navigator.clipboard.writeText(e);return}Ss(e)}function Rc(e){return typeof e=="function"?e():e}function Va({value:e,resetDelay:r=2e3,title:n,copiedTitle:a="Copiado",copiedLabel:o,icon:l=t.jsx(W.HiClipboardDocument,{size:14}),copiedIcon:i=t.jsx(W.HiCheck,{size:14}),stopPropagation:c=!0,onCopied:d,onCopyError:u,className:m="",style:b,children:f,onClick:g,type:h="button",...E}){const[v,S]=s.useState(!1),A=s.useRef(null);s.useEffect(()=>()=>{A.current&&window.clearTimeout(A.current)},[]);function C(N){S(!0),d==null||d(N),A.current&&window.clearTimeout(A.current),A.current=window.setTimeout(()=>{S(!1),A.current=null},r)}async function O(N){var M;if(c&&N.stopPropagation(),g==null||g(N),N.defaultPrevented)return;const y=Rc(e);if(y)try{await Jc(y),C(y)}catch(k){try{Ss(y),C(y)}catch(_){u==null||u(_,y);return}(M=navigator.clipboard)!=null&&M.writeText||u==null||u(k,y)}}return t.jsxs("button",{...E,type:h,onClick:O,title:v?a:n,"aria-label":E["aria-label"]??(v?a:n),"data-copied":v?"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:v?"rgba(22,163,74,0.15)":"var(--bg-card)",border:v?"1px solid rgba(22,163,74,0.4)":"1px solid var(--border)",color:v?"#16a34a":"var(--text-secondary)",boxShadow:v?"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:v?"scale(1.15)":"scale(1)"},children:v?i:l}),f&&t.jsx("span",{className:"text-xs font-semibold leading-none",children:v?o??f:f})]})}function ed({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(Va,{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 In(e){if(e!==void 0)return typeof e=="number"?`${e}px`:e}function td({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(W.HiMagnifyingGlass,{className:"absolute top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-[var(--text-muted)] pointer-events-none",style:{left:In(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:In(o),padding:In(l)}})]})}function rd({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((b,f)=>f===0&&!b.color?{...b,sublabel:b.sublabel??void 0}:b):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:In(d)},children:o}),t.jsx(dr,{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 nd={sm:"24rem",md:"28rem",lg:"32rem",xl:"40rem","2xl":"48rem","4xl":"56rem","5xl":"64rem"},Bn=180,ad="bg-[color-mix(in_srgb,var(--bg-main)_72%,transparent)] backdrop-blur-sm";function Xa({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:b=!0,closeOnEscape:f=!0,showCloseButton:g=!0,placement:h="center",bodyClassName:E="px-6 py-5",panelClassName:v="",backdropClassName:S=ad,contentClassName:A="p-4",ariaLabel:C,frameless:O=!1,disabled:N=!1}){const[y,M]=s.useState(!1),[k,_]=s.useState(!1),Y=s.useRef(null);if(s.useEffect(()=>(e?(Y.current&&clearTimeout(Y.current),M(!0),requestAnimationFrame(()=>requestAnimationFrame(()=>_(!0)))):(_(!1),Y.current=setTimeout(()=>M(!1),Bn+40)),()=>{Y.current&&clearTimeout(Y.current)}),[e]),s.useEffect(()=>{if(e)return document.body.style.overflow="hidden",()=>{document.body.style.overflow=""}},[e]),s.useEffect(()=>{if(!e||!f)return;const J=R=>{R.key==="Escape"&&r()};return window.addEventListener("keydown",J),()=>window.removeEventListener("keydown",J)},[f,r,e]),!y)return null;const K=n||a||o||l||g,D=u??nd[d],G=h==="bottom-mobile"?"items-end sm:items-center justify-center p-0 sm:p-4":"items-center justify-center",U=h==="bottom-mobile"?"rounded-t-2xl sm:rounded-2xl":"rounded-2xl",ne=k?"translateY(0) scale(1)":h==="bottom-mobile"?"translateY(16px) scale(0.98)":"translateY(10px) scale(0.96)";return ht.createPortal(t.jsxs("div",{role:"dialog","aria-modal":"true","data-bonsaif-overlay":"true","aria-label":C??n,className:`fixed inset-0 flex ${G} ${A}`,style:{zIndex:m},children:[t.jsx("div",{className:`absolute inset-0 ${S}`,onClick:b?r:void 0,style:{opacity:k?1:0,transition:`opacity ${Bn}ms ease`}}),t.jsxs("div",{className:`relative z-10 flex max-h-[92dvh] w-full flex-col overflow-hidden ${O?"shadow-none":"shadow-2xl"} ${U} ${v}`,style:{maxWidth:D,background:O?"transparent":"var(--bg-card)",border:O?"none":"1px solid var(--border)",opacity:k?1:0,transform:ne,transition:`opacity ${Bn}ms ease, transform ${Bn}ms ease`},onClick:J=>J.stopPropagation(),children:[N&&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)"}}),K&&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,g&&t.jsx(Ve,{variant:"icon",onClick:r,title:"Cerrar",children:t.jsx(W.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 od={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 sd({open:e,title:r,description:n,confirmLabel:a="Confirmar",cancelLabel:o="Cancelar",variant:l="danger",closeOnBackdrop:i=!0,onConfirm:c,onCancel:d}){const u=od[l];return t.jsx(Xa,{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(Ve,{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(W.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(W.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(Ve,{variant:"secondary",onClick:d,className:"w-full sm:w-auto sm:min-w-[7.5rem]",style:{background:"var(--bg-input)"},children:o}),t.jsx(Ve,{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 ld(e){return e?typeof e=="function"?e():e:""}function id(e){return/^https?:\/\//i.test(e)}function Es(e,r){try{return new URL(e,r).toString()}catch{return e}}function cd(e,r,n,a=!1){const o=typeof e=="function"?e():e,l=r?r(o):o;if(!l||id(l))return l;const i=ld(n);return i?Es(l,i):a&&typeof window<"u"?Es(l,window.location.origin):l}function dd({url:e,resolveUrl:r,baseUrl:n,useWindowOriginForRelative:a=!1,title:o="Copiar link",copiedTitle:l="Link copiado",icon:i=t.jsx(W.HiLink,{className:"h-3.5 w-3.5"}),...c}){return t.jsx(Va,{...c,value:()=>cd(e,r,n,a),title:o,copiedTitle:l,icon:i})}const ud={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 fd(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=ud[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 bd=new Set(["Backspace","Delete","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Tab","Home","End","Enter","Escape"]);function md({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,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:()=>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&&!bd.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 pd({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(dr,{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 hd={outline:"2px solid var(--primary)",outlineOffset:"-2px",borderRadius:"4px",background:"color-mix(in srgb, var(--primary) 5%, var(--bg-card))"},Ya={outline:"2px solid var(--primary)",outlineOffset:"-2px",borderRadius:"4px"};function gd({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[b,f]=s.useState(null),g=s.useRef(null);g.current=b;const[h,E]=s.useState({}),[v,S]=s.useState(null),A=s.useRef(null);A.current=v;const[C,O]=s.useState({}),[N,y]=s.useState({}),M=s.useRef(new Set),k=s.useRef(null);s.useEffect(()=>{var I;const H=document.activeElement;(!H||H===document.body)&&((I=k.current)==null||I.focus({preventScroll:!0}))},[]);const _=e.map(H=>{var I,le,L;return`${H.key}:${((L=(le=(I=H.editable)==null?void 0:I.select)==null?void 0:le.options)==null?void 0:L.length)??-1}`}).join("|");s.useEffect(()=>{e.forEach(H=>{var L,oe;const I=(oe=(L=H.editable)==null?void 0:L.select)==null?void 0:oe.options;if(!I)return;const le=C[H.key];(!M.current.has(H.key)||(le==null?void 0:le.length)===0&&I.length>0)&&(M.current.add(H.key),O(w=>({...w,[H.key]:I})))})},[_]);const Y=s.useCallback(async(H,I)=>{if(M.current.has(H))return;M.current.add(H);const{url:le,fetchOptions:L}=I.select??{};if(!(!le&&!L)){y(oe=>({...oe,[H]:!0}));try{let oe=[];if(L)oe=await L();else if(le){const w=await fetch(le);if(!w.ok)throw new Error("fetch failed");oe=await w.json()}O(w=>({...w,[H]:oe}))}catch{O(oe=>({...oe,[H]:[]}))}finally{y(oe=>({...oe,[H]:!1}))}}},[]),K=s.useRef(i);K.current=i;const D=s.useRef(a);D.current=a;const G=s.useRef(n);G.current=n;const U=s.useRef(e);U.current=e;const ne=s.useRef(o);ne.current=o,s.useEffect(()=>{if(e.length>0&&r.length>0){const H=e.find(I=>I.selectable!==!1);H&&f({rowId:n(r[0]),colKey:H.key})}},[]),s.useEffect(()=>{if(!b)return;const H=k.current;if(!H)return;const I=H.querySelector(`[data-cell-id="${b.rowId}:${b.colKey}"]`);if(!I)return;const le=H.querySelector('[role="rowgroup"]');I.style.scrollMarginTop=`${(le==null?void 0:le.offsetHeight)??0}px`;const L=H.querySelector('[role="row"]');let oe=0;L&&L.querySelectorAll('[role="cell"], [role="columnheader"]').forEach(w=>{w.style.position==="sticky"&&w.style.left!==""&&(oe=Math.max(oe,parseFloat(w.style.left)+w.offsetWidth))}),I.style.scrollMarginLeft=`${oe}px`,I.scrollIntoView({block:"nearest",inline:"nearest"})},[b]);const J=s.useCallback(H=>{var oe;const I=U.current,le=new Set,L=[];(oe=k.current)==null||oe.querySelectorAll("[data-cell-id]").forEach(w=>{const te=w.dataset.cellId.split(":")[0];le.has(te)||(le.add(te),L.push(te))}),f(w=>{if(!w)return w;const te=I.findIndex(re=>re.key===w.colKey),B=L.indexOf(w.rowId);let F=te,ue=B;if(H==="up")ue=Math.max(0,B-1);else if(H==="down")ue=Math.min(L.length-1,B+1);else if(H==="left"){let re=te-1;for(;re>=0&&I[re].selectable===!1;)re--;re>=0&&(F=re)}else if(H==="right"){let re=te+1;for(;re<I.length&&I[re].selectable===!1;)re++;re<I.length&&(F=re)}return F===te&&ue===B?w:{rowId:L[ue],colKey:I[F].key}})},[]),R=s.useCallback((H=!0)=>{const I=d.current;m(null),I&&f(I),H&&setTimeout(()=>{var le;return(le=k.current)==null?void 0:le.focus({preventScroll:!0})},0)},[]),V=s.useCallback(async(H,I,le)=>{var ie;const L=U.current.find(pe=>pe.key===I);if(!(L!=null&&L.editable))return;const{field:oe,type:w,mask:te,validate:B}=L.editable,F=w==="number"?le===""?null:Number(le):le;if(te){const pe=fd(le,te);if(pe){E(ae=>({...ae,[`${H}:${I}`]:pe}));return}}if(B){const pe=B(F);if(pe){E(ae=>({...ae,[`${H}:${I}`]:pe}));return}}const ue=G.current,re=K.current.find(pe=>ue(pe)===H);if(!re)return;const j=re[oe];m(null),E(pe=>{const ae={...pe};return delete ae[`${H}:${I}`],ae});const x=K.current,T=x.findIndex(pe=>ue(pe)===H),ee=x[Math.min(x.length-1,T+1)];if(f({rowId:ue(ee),colKey:I}),setTimeout(()=>{var ae,ye;const pe=document.activeElement;(!pe||pe===document.body||(ae=k.current)!=null&&ae.contains(pe))&&((ye=k.current)==null||ye.focus({preventScroll:!0}))},0),String(j??"")===String(F??""))return;const fe={...re,[oe]:F};c(pe=>pe.map(ae=>ue(ae)===H?fe:ae)),S({rowId:H,colKey:I});try{await((ie=D.current)==null?void 0:ie.call(D,{row:re,rowId:H,field:oe,oldValue:j,newValue:F}))}catch{c(pe=>pe.map(ae=>ue(ae)===H?re:ae)),E(pe=>({...pe,[`${H}:${I}`]:"Error al guardar. Intenta de nuevo."}))}finally{S(null)}},[]),X=s.useCallback(H=>{if(A.current){H.preventDefault();return}if(d.current)return;const I=g.current;if(!(!I||!["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Enter","Escape","Tab"].includes(H.key)))switch(H.preventDefault(),H.key){case"ArrowUp":J("up");break;case"ArrowDown":J("down");break;case"ArrowLeft":J("left");break;case"ArrowRight":J("right");break;case"Tab":J(H.shiftKey?"left":"right");break;case"Enter":{const L=U.current.find(oe=>oe.key===I.colKey);L!=null&&L.editable&&!ne.current?(m(I),L.editable.type==="select"&&!M.current.has(I.colKey)&&Y(I.colKey,L.editable)):J("down");break}}},[J,Y]),de=s.useMemo(()=>e.map(H=>{if(!H.editable||o){const le={...H};if(delete le.editable,delete le.selectable,H.selectable===!1)return{...le,disableRowClick:!0};const L=le.cell;return{...le,className:`relative ${le.className??""}`.trim(),disableRowClick:!0,cell:oe=>{const w=n(oe),te=(b==null?void 0:b.rowId)===w&&(b==null?void 0:b.colKey)===H.key;return t.jsxs(t.Fragment,{children:[t.jsx("span",{"data-cell-id":`${w}:${H.key}`,className:"absolute inset-0 z-10 cursor-default",onClick:()=>{var B;A.current||(f({rowId:w,colKey:H.key}),(B=k.current)==null||B.focus({preventScroll:!0}))}}),te&&t.jsx("div",{className:"pointer-events-none absolute inset-0 z-20",style:Ya}),t.jsx("span",{className:"relative z-0 pointer-events-none",children:L(oe)})]})}}}const I=H.editable;return{...H,className:`relative ${H.className??""}`.trim(),disableRowClick:!0,cell:le=>{const L=n(le),oe=H.key,w=(u==null?void 0:u.rowId)===L&&(u==null?void 0:u.colKey)===oe,te=(b==null?void 0:b.rowId)===L&&(b==null?void 0:b.colKey)===oe,B=h[`${L}:${oe}`],F=(v==null?void 0:v.rowId)===L&&(v==null?void 0:v.colKey)===oe,ue=le[I.field],re=String(ue??""),j=()=>{var T;A.current||(f({rowId:L,colKey:oe}),m({rowId:L,colKey:oe}),(T=k.current)==null||T.focus({preventScroll:!0}),I.type==="select"&&!M.current.has(oe)&&Y(oe,I))};if(w){const T=I.type==="select"?t.jsx(pd,{initialValue:re,options:C[oe]??[],loading:N[oe]??!1,onCommit:ee=>V(L,oe,ee),onCancel:R}):t.jsx(md,{initialValue:re,type:I.type??"text",mask:I.mask,onCommit:ee=>V(L,oe,ee),onCancel:R});return t.jsx("div",{className:"absolute inset-0 flex items-center px-2",style:hd,onClick:ee=>ee.stopPropagation(),children:T})}const x=H.cell(le);return t.jsxs(t.Fragment,{children:[t.jsx("span",{"data-cell-id":`${L}:${oe}`,className:`peer absolute inset-0 z-10 ${F?"cursor-wait":"cursor-pointer"}`,onClick:j}),te&&!F&&t.jsx("div",{className:"pointer-events-none absolute inset-0 z-20",style:Ya}),F&&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:Ya,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:B?t.jsxs("span",{className:"flex items-center gap-1 text-red-500",children:[t.jsx(W.HiExclamationCircle,{className:"h-3.5 w-3.5 shrink-0"}),t.jsx("span",{className:"truncate text-xs",children:B})]}):t.jsx("span",{className:"truncate",children:x})}),!F&&t.jsx(W.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,b,v,h,C,N,n,V,R,Y]);return t.jsx("div",{ref:k,tabIndex:0,onKeyDown:X,onBlur:H=>{var I;(I=k.current)!=null&&I.contains(H.relatedTarget)||setTimeout(()=>{var L,oe;const le=document.activeElement;le&&((L=le.closest)!=null&&L.call(le,"[data-bonsaif-select-dropdown]"))||(oe=k.current)!=null&&oe.contains(le)||R(!1)},0)},style:{width:"100%",minWidth:0,outline:"none"},children:t.jsx(qa,{...l,columns:de,data:i,getRowId:n})})}function ot(e){if(e)return new Date(`${e}T12:00:00`)}function Dt(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 Cr(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Cs(e){return e.map(r=>ot(r)).filter(r=>!!r)}function vd(e){if(!(e!=null&&e.length))return[];const r=new Set(e.map(Dt));return Array.from(r).sort()}function Ka(e){return new Intl.DateTimeFormat("es-MX",{weekday:"short"}).format(e)}function Ms(e){const r=ot(e);if(!r)return e;const n=Ka(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 Ga={weekend:{dayOfWeek:[0,6]}},Za={weekend:"bonsaif-weekend"};function Qa({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 yd={background:"var(--primary)",color:"var(--primary-fg, #ffffff)",borderRadius:999},xd={background:"color-mix(in srgb, var(--primary) 22%, transparent)",color:"var(--text-main)",borderRadius:999};function wd({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?yd:null,...o?xd:null,...l?{fontWeight:800}:null,...n.style}})}function Nd({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 b={from:ot(e),to:ot(r)},f=ot(a),[g,h]=s.useState(()=>ot(o||e)??new Date);s.useEffect(()=>{const C=ot(o||e);C&&h(C)},[o,e]);const E=s.useMemo(()=>{if(l<=1)return Cr(new Intl.DateTimeFormat("es-MX",{month:"long",year:"numeric"}).format(g));const C=new Date(g.getFullYear(),g.getMonth()+l-1,1),O=g.getFullYear()===C.getFullYear(),N=new Intl.DateTimeFormat("es-MX",{month:"short",...O?{}:{year:"numeric"}}).format(g),y=new Intl.DateTimeFormat("es-MX",{month:"short",year:"numeric"}).format(C);return`${Cr(N)} – ${Cr(y)}`},[g,l]);function v(){h(new Date(g.getFullYear(),g.getMonth()-1,1))}function S(){h(new Date(g.getFullYear(),g.getMonth()+1,1))}const A=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:v,children:t.jsx(W.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:S,children:t.jsx(W.HiChevronRight,{size:16})})]}),t.jsx(Ia.DayPicker,{mode:"range",selected:b,month:g,onMonthChange:h,onSelect:C=>{const O=C!=null&&C.from?Dt(C.from):e,N=C!=null&&C.to?Dt(C.to):"";n({startDate:O,endDate:N})},numberOfMonths:l,hideNavigation:!0,weekStartsOn:1,disabled:f?{before:f}:void 0,showOutsideDays:!1,modifiers:Ga,modifiersClassNames:Za,components:{DayButton:wd,Weekday:Qa},classNames:{root:"bonsaif-range-daypicker w-full",months:A,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:C=>`${Cr(new Intl.DateTimeFormat("es-MX",{month:"long"}).format(C))} ${C.getFullYear()}`,formatWeekdayName:Ka}})]}),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 Ts({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=ot(e),a=ot(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(Dt(c)),c.setDate(c.getDate()+1);return i}function As(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 an(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 kd(e,r){return typeof r!="number"||r<=0||e.length<=r?e:e.slice(-r)}function Sd(e,r,n){return!!(r&&e<r||n&&e>n)}function Ls({value:e,onChange:r,disabled:n=!1,minDate:a,maxDate:o,maxDates:l,isDateDisabled:i,retainOutsidePrefix:c}){const d=s.useRef(null),u=s.useRef(null),m=s.useRef(!1),b=s.useRef(e);b.current=e;const f=s.useCallback(N=>{let y=N;if(c){const M=b.current.filter(_=>!_.startsWith(c)),k=N.filter(_=>_.startsWith(c));y=[...M,...k].sort()}r==null||r(kd(y,l))},[l,r,c]),g=s.useCallback((N,y=!1)=>Sd(N,a,o)?!0:!(!(i!=null&&i(N))||y&&b.current.includes(N)),[i,o,a]),h=s.useCallback(N=>N.filter(y=>!g(y)),[g]),E=s.useCallback(()=>{u.current=null},[]);s.useEffect(()=>{const N=()=>E();return window.addEventListener("pointerup",N),window.addEventListener("pointercancel",N),()=>{window.removeEventListener("pointerup",N),window.removeEventListener("pointercancel",N)}},[E]);const v=s.useCallback((N,y,M,k)=>{const _=h($s(N,y));f(M==="add"?an(k,_,"add"):an(k,_,"remove"))},[f,h]),S=s.useCallback((N,y)=>{if(n||y.button!==0)return;const M=Dt(N);if(g(M,!0)||y.shiftKey)return;m.current=!0;const k=[...b.current],_=k.includes(M)?"remove":"add";_==="add"&&g(M)||(u.current={active:!0,mode:_,anchor:M,latest:M,baseline:k},d.current=M,v(M,M,_,k),y.preventDefault())},[v,n,g]),A=s.useCallback(N=>{const y=u.current;if(!(y!=null&&y.active)||n)return;const M=Dt(N);y.mode==="add"&&g(M)||y.latest!==M&&(y.latest=M,v(y.anchor,M,y.mode,y.baseline))},[v,n,g]),C=s.useCallback((N,y)=>{if(n)return;const M=Dt(N);if(!g(M,!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 k=h($s(d.current,M));f(an(b.current,k,"add"));return}!b.current.includes(M)&&g(M)||(d.current=M,f(an(b.current,[M],"toggle")))}},[f,n,h,g]),O=s.useCallback(N=>{if(n)return;const y=h(vd(N));if(!y.length)return;const M=y.every(k=>b.current.includes(k));f(an(b.current,y,M?"remove":"add")),d.current=y[0]??d.current},[f,n,h]);return{onDayPointerDown:S,onDayPointerEnter:A,onDayClick:C,toggleWeek:O,endDrag:E}}function on(e){return As(e,1)[0]}function Ds(e,r){const n=new Date(e);return n.setDate(n.getDate()+r),n}function Ed({value:e=[],onChange:r,minDate:n,maxDate:a,isDateDisabled:o,viewMonth:l,maxDates:i,showWeekNumbers:c=!1,viewMode:d,defaultViewMode:u="month",onViewModeChange:m,showSummary:b=!0,className:f="",disabled:g=!1}){const h=s.useMemo(()=>Cs(e),[e]),E=s.useMemo(()=>new Set(e),[e]),v=ot(n),S=ot(a),[A,C]=s.useState(()=>ot(l||e[0])??new Date),[O,N]=s.useState(()=>on(ot(l||e[0])??new Date)),[y,M]=s.useState(u),k=d??y;function _(H){d===void 0&&M(H),m==null||m(H)}s.useEffect(()=>{const H=ot(l);H&&(C(H),N(on(H)))},[l]);const{onDayPointerDown:Y,onDayPointerEnter:K,onDayClick:D,toggleWeek:G}=Ls({value:e,onChange:r,disabled:g,minDate:n,maxDate:a,maxDates:i,isDateDisabled:o}),U=s.useMemo(()=>{if(g)return!0;const H=[];return v&&H.push({before:v}),S&&H.push({after:S}),o&&H.push(I=>o(Dt(I))),H.length>0?H:void 0},[g,o,S,v]),ne=s.useCallback(H=>t.jsx(Ts,{...H,className:`bonsaif-multi-day-btn ${H.className??""}`,onDayPointerDown:Y,onDayPointerEnter:K,onDayClickSelect:D}),[D,Y,K]),J=s.useMemo(()=>As(O,1),[O]),R=J[6],V=k==="week"?`${new Intl.DateTimeFormat("es-MX",{day:"numeric",month:"short"}).format(J[0])} – ${new Intl.DateTimeFormat("es-MX",{day:"numeric",month:"short",year:"numeric"}).format(R)}`:Cr(new Intl.DateTimeFormat("es-MX",{month:"long",year:"numeric"}).format(A));function X(){if(k==="week"){const H=Ds(O,-7);N(on(H)),C(H);return}C(new Date(A.getFullYear(),A.getMonth()-1,1))}function de(){if(k==="week"){const H=Ds(O,7);N(on(H)),C(H);return}C(new Date(A.getFullYear(),A.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":k==="month",className:`bonsaif-cal-view-btn${k==="month"?" is-active":""}`,disabled:g,onClick:()=>{_("month"),C(O)},children:"Mes"}),t.jsx("button",{type:"button",role:"tab","aria-selected":k==="week",className:`bonsaif-cal-view-btn${k==="week"?" is-active":""}`,disabled:g,onClick:()=>{_("week"),N(on(A))},children:"Semana"})]}),t.jsxs("div",{className:"bonsaif-cal-toolbar",children:[t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn","aria-label":k==="week"?"Semana anterior":"Mes anterior",disabled:g,onClick:X,children:t.jsx(W.HiChevronLeft,{size:16})}),t.jsx("span",{className:"bonsaif-cal-title",children:V}),t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn","aria-label":k==="week"?"Semana siguiente":"Mes siguiente",disabled:g,onClick:de,children:t.jsx(W.HiChevronRight,{size:16})})]}),t.jsxs("p",{className:"bonsaif-cal-hint",children:["Click · Shift+click rango · Arrastra",c&&k==="month"?" · Semana (nº)":"",k==="week"?" · Botón semana completa":""]}),k==="month"?t.jsx(Ia.DayPicker,{mode:"multiple",required:!1,selected:h,month:A,onMonthChange:C,onSelect:()=>{},hideNavigation:!0,showOutsideDays:!1,weekStartsOn:1,showWeekNumber:c,onWeekNumberClick:(H,I)=>{G(I)},disabled:U,className:"bonsaif-multi-daypicker",modifiers:Ga,modifiersClassNames:Za,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:ne,Weekday:Qa},formatters:{formatWeekdayName:Ka}}):t.jsxs("div",{className:"bonsaif-week-view",children:[t.jsx("div",{className:"bonsaif-week-view-head",children:J.map(H=>t.jsx("div",{className:"bonsaif-multi-weekday",children:new Intl.DateTimeFormat("es-MX",{weekday:"short"}).format(H)},`h-${Dt(H)}`))}),t.jsx("div",{className:"bonsaif-week-view-days",children:J.map(H=>{const I=Dt(H),le=E.has(I),L=g||(n?I<n:!1)||(a?I>a:!1)||!!(o!=null&&o(I)),oe=I===Dt(new Date);return t.jsx("div",{className:`bonsaif-multi-day${le?" bonsaif-multi-day-selected":""}${oe?" bonsaif-multi-day-today":""}${L?" bonsaif-multi-day-disabled":""}`,children:t.jsxs("button",{type:"button",className:"bonsaif-multi-day-btn",disabled:L,"aria-pressed":le,onPointerDown:w=>Y(H,w),onPointerEnter:()=>K(H),onClick:w=>D(H,w),children:[t.jsx("span",{className:"bonsaif-week-day-num",children:H.getDate()}),t.jsx("span",{className:"bonsaif-week-day-month",children:new Intl.DateTimeFormat("es-MX",{month:"short"}).format(H)})]})},I)})}),t.jsx("button",{type:"button",className:"bonsaif-week-select-all",disabled:g,onClick:()=>G(J),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(H=>t.jsxs("button",{type:"button",className:"bonsaif-cal-chip",disabled:g,onClick:()=>r==null?void 0:r(e.filter(I=>I!==H)),title:`Quitar ${H}`,children:[Ms(H),t.jsx("span",{"aria-hidden":!0,children:"×"})]},H))})]})}):null]})}const Cd=Array.from({length:12},(e,r)=>r);function Md({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 b=s.useMemo(()=>Cs(e),[e]),f=ot(o),g=ot(l),h=n??(e[0]?Number(e[0].slice(0,4)):new Date().getFullYear()),[E,v]=s.useState(h);s.useEffect(()=>{typeof n=="number"&&v(n)},[n]);function S(k){v(k),a==null||a(k)}const{onDayPointerDown:A,onDayPointerEnter:C,onDayClick:O}=Ls({value:e,onChange:r,disabled:u||m,minDate:o,maxDate:l,maxDates:i,retainOutsidePrefix:`${E}-`}),N=s.useCallback(k=>t.jsx(Ts,{...k,className:`bonsaif-year-day-btn ${k.className??""}`,onDayPointerDown:A,onDayPointerEnter:C,onDayClickSelect:O}),[O,A,C]),y=b.filter(k=>k.getFullYear()===E),M=u?!0:[...f?[{before:f}]:[],...g?[{after:g}]:[]];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:()=>S(E-1),children:t.jsx(W.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:()=>S(E+1),children:t.jsx(W.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:Cd.map(k=>{const _=new Date(E,k,1);return t.jsxs("div",{className:"bonsaif-year-cal-month",children:[t.jsx("div",{className:"bonsaif-year-cal-month-title",children:Cr(new Intl.DateTimeFormat("es-MX",{month:"long"}).format(_))}),t.jsx(Ia.DayPicker,{mode:"multiple",required:!1,selected:y,month:_,onMonthChange:()=>{},onSelect:()=>{},numberOfMonths:1,hideNavigation:!0,showOutsideDays:!1,weekStartsOn:1,disabled:M,className:"bonsaif-year-month-picker",modifiers:Ga,modifiersClassNames:Za,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:N,Weekday:Qa},formatters:{formatWeekdayName:Y=>new Intl.DateTimeFormat("es-MX",{weekday:"narrow"}).format(Y)}})]},`${E}-${k}`)})})]}),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(k=>t.jsxs("button",{type:"button",className:"bonsaif-cal-chip",disabled:u||m,onClick:()=>r==null?void 0:r(e.filter(_=>_!==k)),title:`Quitar ${k}`,children:[Ms(k),t.jsx("span",{"aria-hidden":!0,children:"×"})]},k))})]})}):null]})}const Td="bonsaif-ui:hide-tooltips";function Os(){window.dispatchEvent(new CustomEvent(Td))}function $d(e){if(e!==void 0)return typeof e=="number"?`${e}px`:e}function Ad({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,b]=s.useState(!1),[f,g]=s.useState({}),h=s.useRef(null),E=s.useRef(null),v=s.useCallback(N=>{u(N),c==null||c(N)},[c]),S=s.useCallback(()=>{const N=h.current;if(!N)return;const y=N.getBoundingClientRect(),M=typeof a=="number"?a:y.width,k=typeof a=="number"?a:Math.max(y.width,180),_=n==="end"?Math.max(8,y.right-k):Math.min(y.left,window.innerWidth-k-8),Y=window.innerHeight-y.bottom,K=Y<240&&y.top>Y?void 0:y.bottom+6,D=K===void 0?window.innerHeight-y.top+6:void 0;g({position:"fixed",zIndex:9999,left:_,top:K,bottom:D,width:$d(typeof a=="number"?M:a)})},[n,a]);s.useEffect(()=>b(!0),[]),s.useEffect(()=>{if(!d)return;S();const N=M=>{var _,Y;const k=M.target;!((_=h.current)!=null&&_.contains(k))&&!((Y=E.current)!=null&&Y.contains(k))&&v(!1)},y=M=>{M.key==="Escape"&&v(!1)};return document.addEventListener("mousedown",N),window.addEventListener("keydown",y),window.addEventListener("resize",S),window.addEventListener("scroll",S,!0),()=>{document.removeEventListener("mousedown",N),window.removeEventListener("keydown",y),window.removeEventListener("resize",S),window.removeEventListener("scroll",S,!0)}},[d,v,S]);const A=N=>{o||(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),v(!d))},C=s.isValidElement(e)?s.cloneElement(e,{onClick:()=>{o||(Os(),v(!d))}}):e,O=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:f,children:r.map(N=>t.jsxs("div",{children:[N.separatorBefore&&t.jsx("div",{className:"my-1 border-t border-[var(--border)]"}),t.jsxs("button",{type:"button",role:"menuitem",disabled:N.disabled,onClick:()=>{var y;N.disabled||(Os(),(y=N.onSelect)==null||y.call(N),v(!1))},className:"flex w-full min-w-0 items-start gap-2 rounded-md px-2.5 py-1.5 text-left transition-colors hover:bg-[var(--bg-input)] disabled:cursor-not-allowed disabled:opacity-50",style:{color:N.danger?"var(--danger)":"var(--text-main)"},children:[N.icon&&t.jsx("span",{className:"mt-0.5 shrink-0",children:N.icon}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"block truncate text-sm font-medium",children:N.label}),N.description&&t.jsx("span",{className:"block truncate text-xs text-[var(--text-muted)]",children:N.description})]})]})]},N.id))}):null;return t.jsxs("span",{ref:h,role:"button",tabIndex:o?-1:0,"aria-haspopup":"menu","aria-expanded":d,onKeyDown:A,className:`inline-flex ${o?"pointer-events-none opacity-60":""} ${l}`,children:[C,m&&O?ht.createPortal(O,document.body):null]})}const Ld=180,Hs="bg-[color-mix(in_srgb,var(--bg-main)_72%,transparent)] backdrop-blur-sm";function Dd({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:b=440,hasUnsavedChanges:f=!1,unsavedChangesTitle:g="Descartar cambios",unsavedChangesDescription:h="Hay cambios sin guardar. Si cierras el drawer se perderán.",unsavedChangesConfirmLabel:E="Descartar",unsavedChangesCancelLabel:v="Seguir editando",onDiscardChanges:S,disabled:A=!1,disabledMessage:C,children:O}){const[N,y]=s.useState(!1),[M,k]=s.useState(!1),[_,Y]=s.useState(!1),K=s.useCallback(()=>{k(!0),requestAnimationFrame(()=>{requestAnimationFrame(()=>Y(!0))})},[]),D=s.useCallback(()=>{Y(!1),window.setTimeout(()=>k(!1),Ld)},[]),G=A||c,U=s.useCallback(()=>{if(!G){if(f){K();return}r()}},[G,f,r,K]),ne=s.useCallback(()=>{Y(!1),k(!1),S==null||S(),r()},[r,S]);if(s.useEffect(()=>{y(!0)},[]),s.useEffect(()=>(document.body.style.overflow=e?"hidden":"",e||(Y(!1),k(!1)),()=>{document.body.style.overflow=""}),[e]),s.useEffect(()=>{if(!e)return;const R=V=>{if(V.key==="Escape"&&!G){if(M){D();return}U()}};return window.addEventListener("keydown",R),()=>window.removeEventListener("keydown",R)},[D,G,M,e,U]),!N)return null;const J=C!==void 0?C:c?"Guardando…":null;return ht.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:U}),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(Ve,{variant:"icon",onClick:U,title:"Cerrar",disabled:G,children:t.jsx(W.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(Ve,{variant:"secondary",size:"sm",onClick:U,disabled:G,style:{background:"var(--bg-input)"},children:"Cancelar"}),t.jsx(Ve,{variant:"primary",size:"sm",icon:t.jsx(Ki.FiSave,{className:"w-4 h-4"}),onClick:i,loading:c,disabled:d||G,title:l})]})]})]}),t.jsx("div",{"data-drawer-scroll":"true",className:m,children:O}),G&&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:J?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:J})]}):null})]}),M&&t.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":g,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 ${_?"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 ${_?"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(Ve,{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":v,children:t.jsx(W.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(W.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:g}),t.jsx("p",{className:"text-sm",style:{color:"var(--text-muted, #6b7f78)"},children:h}),t.jsxs("div",{className:"mt-6 flex gap-2",children:[t.jsx(Ve,{variant:"secondary",onClick:D,className:"flex-1 border",style:{background:"var(--bg-input, #f7faf8)",borderColor:"var(--border, #d8e1dc)",color:"var(--text-main, #0f2f2c)"},children:v}),t.jsx(Ve,{variant:"secondary",onClick:ne,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 Od=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,Hd=/^\+?[0-9\s().-]+$/,Id=7,Bd=15;function Ft(e){return e==null||String(e).trim()===""}function Is(e){return typeof e=="number"?e:typeof e=="string"&&e.trim()!==""?Number(e):Number.NaN}function Ja(e){return Ft(e)?!1:Od.test(String(e))}function Ra(e){if(Ft(e))return!1;const r=String(e),n=r.replace(/\D/g,"");return Hd.test(r)&&n.length>=Id&&n.length<=Bd}function Fd(e="Este campo es requerido."){return r=>Ft(r)?e:void 0}function Pd(e="Ingresa un correo valido."){return r=>Ft(r)||Ja(r)?void 0:e}function _d(e="Ingresa un telefono valido."){return r=>Ft(r)||Ra(r)?void 0:e}function zd(e,r){return n=>Ft(n)||String(n).length>=e?void 0:r??`Debe tener al menos ${e} caracteres.`}function Wd(e,r){return n=>Ft(n)||String(n).length<=e?void 0:r??`Debe tener ${e} caracteres o menos.`}function jd(e,r){return n=>{if(Ft(n))return;const a=Is(n);return Number.isFinite(a)&&a>=e?void 0:r??`Debe ser mayor o igual a ${e}.`}}function qd(e,r){return n=>{if(Ft(n))return;const a=Is(n);return Number.isFinite(a)&&a<=e?void 0:r??`Debe ser menor o igual a ${e}.`}}function Ud(e,r="El formato no es valido."){return n=>Ft(n)||e.test(String(n))?void 0:r}function Vd(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 Bs={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},Fs=s.createContext&&s.createContext(Bs),Xd=["attr","size","title"];function Yd(e,r){if(e==null)return{};var n,a,o=Kd(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 Kd(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 Fn(){return Fn=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},Fn.apply(null,arguments)}function Ps(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 Pn(e){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};r%2?Ps(Object(n),!0).forEach(function(a){Gd(e,a,n[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ps(Object(n)).forEach(function(a){Object.defineProperty(e,a,Object.getOwnPropertyDescriptor(n,a))})}return e}function Gd(e,r,n){return(r=Zd(r))in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}function Zd(e){var r=Qd(e,"string");return typeof r=="symbol"?r:r+""}function Qd(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 _s(e){return e&&e.map((r,n)=>s.createElement(r.tag,Pn({key:n},r.attr),_s(r.child)))}function eo(e){return r=>s.createElement(Jd,Fn({attr:Pn({},e.attr)},r),_s(e.child))}function Jd(e){var r=n=>{var{attr:a,size:o,title:l}=e,i=Yd(e,Xd),c=o||n.size||"1em",d;return n.className&&(d=n.className),e.className&&(d=(d?d+" ":"")+e.className),s.createElement("svg",Fn({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},n.attr,a,i,{className:d,style:Pn(Pn({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 Fs!==void 0?s.createElement(Fs.Consumer,null,n=>r(n)):r(Bs)}function zs(e){return eo({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 Rd(e){return eo({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 eu(e){return eo({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 Mr({content:e,ariaLabel:r="Más información",className:n=""}){return t.jsx(Bt,{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(W.HiInformationCircle,{className:"h-3.5 w-3.5"})})})}function Tr({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 _n({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 to({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:b="",required:f,...g}){const[h,E]=s.useState(()=>!!g.autoFocus),[v,S]=s.useState(!1),A=g.type==="password"&&u,C=A&&v?"text":g.type,O=!!o,N=O&&l!=="tooltip",y=O&&l!=="inline",M=!!n&&a==="tooltip"&&!N,k=m?f:void 0,_=O?"border-[var(--danger)] focus:border-[var(--danger)]":"",Y=y?A?"pr-20":"pr-10":A?"pr-10":"",K=g.value!==void 0?String(g.value).length>0:g.defaultValue!==void 0&&String(g.defaultValue).length>0,D=h||K,G={top:D?7:12,color:h?"var(--primary)":"var(--text-muted)",fontSize:D?10:13,fontWeight:D?600:400,textTransform:D?"uppercase":"none"},U=X=>{var de;E(!0),(de=g.onFocus)==null||de.call(g,X)},ne=X=>{var de;E(!1),(de=g.onBlur)==null||de.call(g,X)},J=A?t.jsxs("button",{type:"button","aria-label":v?"Ocultar contraseña":"Mostrar contraseña","aria-pressed":v,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:()=>S(X=>!X),children:[t.jsx("span",{"aria-hidden":"true",className:`absolute inset-0 flex items-center justify-center transition-[opacity,transform] duration-200 ease-out ${v?"scale-y-0 rotate-[-8deg] opacity-0":"scale-y-100 rotate-0 opacity-100"}`,children:t.jsx(Rd,{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 ${v?"scale-y-100 rotate-0 opacity-100":"scale-y-0 rotate-[8deg] opacity-0"}`,children:t.jsx(eu,{className:"h-[18px] w-[18px]"})})]}):null,R=y?t.jsx(Bt,{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)] ${A?"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,V=t.jsx(Tr,{error:N?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(_n,{...g,type:C,required:k,placeholder:" ","aria-invalid":O||g["aria-invalid"],"data-has-value":K?"true":void 0,className:`h-11 w-full pt-5 ${Y} ${_} ${b}`,onFocus:U,onBlur:ne}),t.jsxs("span",{className:"pointer-events-none absolute left-3 transition-all duration-150",style:G,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}),R,J]}),V]}):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:"*"}),M?t.jsx(Mr,{content:n}):null,c&&t.jsx("span",{className:"ml-auto normal-case",children:c})]}),A?t.jsxs("span",{className:"relative block",children:[t.jsx(_n,{...g,type:C,required:k,"aria-invalid":O||g["aria-invalid"],className:`w-full ${Y} ${_} ${b}`,onFocus:U,onBlur:ne}),R,J]}):t.jsxs("span",{className:"relative block",children:[t.jsx(_n,{...g,required:k,"aria-invalid":O||g["aria-invalid"],className:`w-full ${Y} ${_} ${b}`}),R]}),V]})}function Ws(e){return e==null?"":String(e)}function tu({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,b]=s.useState(()=>Ws(c)),f=i!==void 0?Ws(i):m,g=n&&f.length>0&&!Ja(f)?a:void 0,h=E=>{i===void 0&&b(E.currentTarget.value),d==null||d(E)};return t.jsx(to,{...u,value:i,defaultValue:c,type:"text",inputMode:r,autoComplete:e,error:l??g,errorDisplay:o,onChange:h})}const ru={sm:"min-h-[112px] p-4",md:"min-h-[148px] p-5",lg:"min-h-[184px] p-6"};function nu(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 au(e,r,n){return r?n===void 0?e:e.slice(0,Math.max(0,n)):e.slice(0,1)}function ou({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:b=!1,showFileList:f=!0,clearable:g=!0,browseLabel:h="Buscar archivos",dropLabel:E="Suelta los archivos aqui",emptyLabel:v="Arrastra y suelta archivos",emptyDescription:S="o haz click para buscarlos en tu equipo",selectedLabel:A="Archivos seleccionados",size:C="md",containerClassName:O="",dropzoneClassName:N="",fileListClassName:y="",className:M="",id:k,accept:_,disabled:Y,required:K,...D}){const G=s.useId(),U=k??G,ne=s.useRef(null),[J,R]=s.useState(!1),[V,X]=s.useState(i),de=l??V,H=!!a,I=!!r&&n==="tooltip"&&!H,le=g&&de.length>0&&!Y,L=(T,ee)=>{l===void 0&&X(T),c==null||c(T,ee)},oe=(T,ee)=>{const fe=T.filter(ye=>js(ye,_)),ie=T.filter(ye=>!js(ye,_)),pe=b?[...de,...fe]:fe,ae=au(pe,u,m);ie.length>0&&(d==null||d(ie)),L(ae,ee)},w=()=>{var T;Y||(T=ne.current)==null||T.click()},te=T=>{oe(Array.from(T.target.files??[]),T),T.target.value=""},B=T=>{T.preventDefault(),Y||R(!0)},F=T=>{T.currentTarget.contains(T.relatedTarget)||R(!1)},ue=T=>{T.preventDefault(),R(!1),!Y&&oe(Array.from(T.dataTransfer.files),T)},re=T=>{T.key!=="Enter"&&T.key!==" "||(T.preventDefault(),w())},j=T=>{L(de.filter((ee,fe)=>fe!==T))},x=()=>{L([])};return t.jsxs("div",{className:`flex flex-col gap-2 ${O}`,children:[(e||o||I)&&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}),K&&t.jsx("span",{className:"text-[var(--danger)]",children:"*"}),I?t.jsx(Mr,{content:r}):null,o&&t.jsx("span",{className:"ml-auto normal-case",children:o})]}),t.jsx("input",{...D,ref:ne,id:U,type:"file",accept:_,multiple:u,disabled:Y,required:K&&de.length===0,"aria-invalid":H||D["aria-invalid"],className:"sr-only",onChange:te}),t.jsxs("div",{role:"button",tabIndex:Y?-1:0,"aria-controls":U,"aria-disabled":Y||void 0,"aria-invalid":H||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)] ${ru[C]} ${J?"border-[var(--primary)] bg-[var(--bg-input)]":H?"border-[var(--danger)]":"border-[var(--border)]"} ${Y?"cursor-not-allowed opacity-60":"hover:border-[var(--primary)] hover:bg-[var(--bg-input)]"} ${N} ${M}`,onClick:w,onDragOver:B,onDragLeave:F,onDrop:ue,onKeyDown:re,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(W.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:J?E:v}),S&&t.jsx("span",{className:"block text-sm text-[var(--text-muted)]",children:S})]}),h&&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:h})]}),f&&de.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:A}),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:x,children:t.jsx(W.HiTrash,{className:"h-4 w-4"})})]}),t.jsx("ul",{className:"divide-y divide-[var(--border)]",children:de.map((T,ee)=>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(W.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:T.name}),t.jsx("span",{className:"block text-xs text-[var(--text-muted)]",children:nu(T.size)})]}),!Y&&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 ${T.name}`,onClick:()=>j(ee),children:t.jsx(W.HiXMark,{className:"h-4 w-4"})})]},`${T.name}-${T.lastModified}-${ee}`))})]}),t.jsx(Tr,{error:a,helperText:r,helperDisplay:n})]})}const su=[{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 lu({fields:e,title:r="Layout",fieldTypes:n=su,saveLabel:a="Guardar",allowAddField:o=!1,addFieldPlaceholder:l="Nuevo campo",addFieldLabel:i="Anadir",loading:c=!1,onSave:d,onChange:u}){const[m,b]=s.useState(()=>e.map(C=>({key:!1,type:"",...C}))),[f,g]=s.useState(""),[h,E]=s.useState(""),v=s.useCallback((C,O)=>{b(N=>{const y=N.map((M,k)=>k===C?{...M,...O}:M);return u==null||u(y),y})},[u]),S=s.useCallback(()=>{d==null||d(m)},[m,d]),A=s.useCallback(()=>{var y;const C=f.trim();if(!C){E("Ingresa un nombre de campo.");return}if(m.some(M=>M.name.toLowerCase()===C.toLowerCase())){E("Ese campo ya existe en el arreglo.");return}const N={name:C,key:!1,type:((y=n[0])==null?void 0:y.value)??""};b(M=>{const k=[...M,N];return u==null||u(k),k}),g(""),E("")},[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((C,O)=>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:C.name}),t.jsx("div",{className:"flex justify-center",children:t.jsx(Mn,{size:"sm",checked:C.key??!1,onChange:N=>v(O,{key:N.target.checked}),"aria-label":`${C.name} es clave`})}),t.jsx(dr,{value:C.type??"",onChange:N=>v(O,{type:N}),options:n,placeholder:"—",emptyLabel:"—",height:36,searchable:!1,ariaLabel:`Tipo de ${C.name}`})]},C.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:f,onChange:C=>{g(C.currentTarget.value),h&&E("")},onKeyDown:C=>{C.key==="Enter"&&(C.preventDefault(),A())},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(Ve,{variant:"secondary",onClick:A,height:36,padding:"0 12px",children:i})]}),h&&t.jsx("p",{className:"text-xs",style:{color:"var(--danger)"},children:h})]}),t.jsx("div",{className:"flex justify-end",children:t.jsx(Ve,{variant:"primary",onClick:S,disabled:c,loading:c,children:a})})]})})]})}function zn({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(Mr,{content:n}):null,l&&t.jsx("span",{className:"ml-auto normal-case",children:l})]}),t.jsx("span",{className:`block ${d}`,children:r}),t.jsx(Tr,{error:o,helperText:n,helperDisplay:a})]})}function iu(e){return Array.from(e.querySelectorAll("img")).filter(r=>!!(r.currentSrc||r.src||"").trim())}function qs(e,r){const n=e.target;if(!(n instanceof HTMLImageElement))return!1;const a=e.currentTarget,o=iu(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 Ot=260,$r=420,ro=380,Pt="cubic-bezier(0.22, 1, 0.36, 1)",cu="cubic-bezier(0.16, 1, 0.3, 1)",no="cubic-bezier(0.22, 1, 0.36, 1)",du="cubic-bezier(0.22, 1, 0.36, 1)",uu=8,fu=1,bu=1.25,ao={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)"},mu="color-mix(in srgb, var(--bg-card) 88%, var(--primary) 12%)",oo=10;function sn(e,r,n){return Math.min(n,Math.max(r,e))}function pu(e){return!e||e.width<1||e.height<1?null:{left:e.left,top:e.top,width:e.width,height:e.height}}function Us(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 Ar({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:{...ao,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=mu,i.currentTarget.style.transform="scale(1.06)")},onMouseLeave:i=>{i.currentTarget.style.background=String(ao.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 Vs({open:e,onClose:r,slides:n,index:a,onIndexChange:o,originRect:l=null,maxZoom:i=uu,minZoom:c=fu,zoomStep:d=bu,closeOnBackdrop:u=!0,closeOnEscape:m=!0,showCounter:b=!0,showZoomControls:f=!0,loop:g=!0,showThumbnails:h=!0,zIndex:E=1100,ariaLabel:v="Visor de imagen"}){const[S,A]=s.useState(!1),[C,O]=s.useState(!1),[N,y]=s.useState(a??0),[M,k]=s.useState(1),[_,Y]=s.useState({x:0,y:0}),[K,D]=s.useState({opacity:1,x:0,scale:1,blur:0,animate:!1}),[G,U]=s.useState({dx:0,dy:0,scale:1,animate:!1,enabled:!1}),[ne,J]=s.useState(!1),R=s.useRef(null),V=s.useRef(null),X=s.useRef(null),de=s.useRef(null),H=s.useRef(null),I=s.useRef(!1),le=s.useRef(!1),L=s.useRef(null),oe=s.useRef(null),w=s.useRef(null),te=s.useRef(null),B=s.useRef(null),F=s.useRef(a??0),ue=a??N,re=n.length===0?0:sn(ue,0,Math.max(0,n.length-1)),j=n[re],x=n.length>1,T=Math.max(c,i),ee=h&&x,fe=s.useCallback(me=>{if(n.length===0)return;const ge=n.length-1,Ae=g?(me%n.length+n.length)%n.length:sn(me,0,ge);a===void 0&&y(Ae),o==null||o(Ae)},[a,g,o,n.length]),ie=s.useCallback(()=>{k(1),Y({x:0,y:0})},[]),pe=s.useCallback((me,ge)=>{if(ge<=c+.001)return{x:0,y:0};const Ae=te.current,Fe=B.current;if(!Ae||!Fe)return me;const Oe=Ae.getBoundingClientRect(),bt=Fe.offsetWidth*ge,ct=Fe.offsetHeight*ge,ze=Math.max(0,(bt-Oe.width)/2+Oe.width*.15),je=Math.max(0,(ct-Oe.height)/2+Oe.height*.15);return{x:sn(me.x,-ze,ze),y:sn(me.y,-je,je)}},[c]),ae=s.useCallback(()=>{A(!1),U({dx:0,dy:0,scale:1,animate:!1,enabled:!1}),de.current=null,H.current=null,I.current=!1,le.current=!1,L.current&&(clearTimeout(L.current),L.current=null)},[]),ye=s.useCallback(()=>{if(I.current)return;I.current=!0,O(!1),ie();const me=de.current,ge=me!=null&&H.current!=null&&H.current===re;if(me&&ge){X.current!=null&&cancelAnimationFrame(X.current),X.current=requestAnimationFrame(()=>{X.current=requestAnimationFrame(()=>{const Ae=B.current;if(!Ae){X.current=null,R.current&&clearTimeout(R.current),R.current=setTimeout(ae,Ot+40);return}const Fe=Ae.getBoundingClientRect(),Oe=Us(me,Fe);U({enabled:!0,dx:0,dy:0,scale:1,animate:!1}),X.current=requestAnimationFrame(()=>{U({enabled:!0,dx:Oe.dx,dy:Oe.dy,scale:Oe.scale,animate:!0}),X.current=null})})}),R.current&&clearTimeout(R.current),R.current=setTimeout(ae,$r+80);return}U({dx:0,dy:0,scale:1,animate:!1,enabled:!1}),R.current&&clearTimeout(R.current),R.current=setTimeout(ae,Ot+40)},[ae,ie,re]);s.useEffect(()=>(e?(R.current&&clearTimeout(R.current),L.current&&(clearTimeout(L.current),L.current=null),I.current=!1,le.current=!1,de.current=pu(l),H.current=de.current!=null?a??N:null,A(!0),O(!1),de.current?U({dx:0,dy:0,scale:1,animate:!1,enabled:!0}):(H.current=null,requestAnimationFrame(()=>requestAnimationFrame(()=>{O(!0),U({dx:0,dy:0,scale:1,animate:!1,enabled:!1})})))):S&&ye(),()=>{R.current&&clearTimeout(R.current),X.current!=null&&cancelAnimationFrame(X.current)}),[e]);const Qe=s.useCallback(()=>{if(!e||I.current||le.current)return;const me=de.current,ge=B.current;if(!me||!ge){me||(O(!0),le.current=!0);return}const Ae=ge.getBoundingClientRect();if(Ae.width<2||Ae.height<2)return;le.current=!0;const Fe=Us(me,Ae);U({enabled:!0,dx:Fe.dx,dy:Fe.dy,scale:Fe.scale,animate:!1}),X.current!=null&&cancelAnimationFrame(X.current),X.current=requestAnimationFrame(()=>{X.current=requestAnimationFrame(()=>{U({enabled:!0,dx:0,dy:0,scale:1,animate:!0}),O(!0),X.current=null,L.current&&clearTimeout(L.current),L.current=setTimeout(()=>{U({dx:0,dy:0,scale:1,animate:!1,enabled:!1}),L.current=null},$r+20)})})},[e]);s.useLayoutEffect(()=>{!S||!e||!de.current||le.current||Qe()},[S,e,Qe]),s.useEffect(()=>{!e||I.current||H.current!=null&&H.current!==re&&U(me=>me.enabled?{dx:0,dy:0,scale:1,animate:!1,enabled:!1}:me)},[e,re]),s.useEffect(()=>{if(!e)return;const me=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=me}},[e]),s.useEffect(()=>{e&&ie()},[e,re,ie]),s.useEffect(()=>{a!==void 0&&y(a)},[a]),s.useEffect(()=>{if(!e){F.current=re,D({opacity:1,x:0,scale:1,blur:0,animate:!1});return}const me=F.current;if(me===re)return;F.current=re;const ge=n.length;let Ae=1;if(ge>1){const Fe=(me+1)%ge===re,Oe=(me-1+ge)%ge===re;Oe&&!Fe?Ae=-1:Fe&&!Oe?Ae=1:Ae=re>me?1:-1}return V.current!=null&&(cancelAnimationFrame(V.current),V.current=null),D({opacity:0,x:Ae*56,scale:.94,blur:8,animate:!1}),V.current=requestAnimationFrame(()=>{V.current=requestAnimationFrame(()=>{D({opacity:1,x:0,scale:1,blur:0,animate:!0}),V.current=null})}),()=>{V.current!=null&&(cancelAnimationFrame(V.current),V.current=null)}},[e,re,n.length]);const Je=M<=c+.001&&Math.abs(_.x)<.5&&Math.abs(_.y)<.5,et=s.useCallback((me,ge,Ae)=>{k(Fe=>{const Oe=sn(me,c,T);if(Math.abs(Oe-Fe)<1e-4)return Fe;const bt=Oe/Fe,ct=Oe<Fe;return Oe<=c+.001?(Y({x:0,y:0}),c):(Y(ze=>{let je=ze;if(typeof ge=="number"&&typeof Ae=="number"&&te.current&&!ct){const dt=te.current.getBoundingClientRect(),mt=ge-dt.left-dt.width/2,br=Ae-dt.top-dt.height/2;je={x:mt-(mt-ze.x)*bt,y:br-(br-ze.y)*bt}}else if(ct){je={x:ze.x*bt,y:ze.y*bt};const dt=Math.min(1,(Fe-Oe)/Math.max(.01,Fe-c));je={x:je.x*(1-dt*.65),y:je.y*(1-dt*.65)}}else je={x:ze.x*bt,y:ze.y*bt};return pe(je,Oe)}),Oe)})},[pe,c,T]),ft=s.useCallback(()=>{et(M*d)},[et,M,d]),nt=s.useCallback(()=>{const me=Math.max(c,M/d);if(me<=c+.001){ie();return}k(me),Y({x:0,y:0})},[c,ie,M,d]);s.useEffect(()=>{if(!e)return;const me=ge=>{if(ge.key==="Escape"&&m){ge.preventDefault(),r();return}ge.key==="ArrowLeft"&&x?(ge.preventDefault(),fe(re-1)):ge.key==="ArrowRight"&&x?(ge.preventDefault(),fe(re+1)):ge.key==="+"||ge.key==="="?(ge.preventDefault(),et(M*d)):ge.key==="-"||ge.key==="_"?(ge.preventDefault(),nt()):ge.key==="0"&&(ge.preventDefault(),ie())};return window.addEventListener("keydown",me),()=>window.removeEventListener("keydown",me)},[et,m,x,r,e,ie,re,M,fe,nt,d]);const Le=me=>{me.preventDefault();const ge=me.deltaY>0?1/d:d;et(M*ge,me.clientX,me.clientY)},ce=me=>{M<=c+.001||(me.currentTarget.setPointerCapture(me.pointerId),J(!0),oe.current={pointerId:me.pointerId,startX:me.clientX,startY:me.clientY,originX:_.x,originY:_.y})},Pe=me=>{const ge=oe.current;!ge||ge.pointerId!==me.pointerId||Y(pe({x:ge.originX+(me.clientX-ge.startX),y:ge.originY+(me.clientY-ge.startY)},M))},_e=me=>{var ge;((ge=oe.current)==null?void 0:ge.pointerId)===me.pointerId&&(oe.current=null,J(!1))},at=me=>{if(me.stopPropagation(),M>c+.05){ie();return}et(Math.min(T,3),me.clientX,me.clientY)},Xe=me=>{if(me.touches.length!==2)return;J(!0);const[ge,Ae]=[me.touches[0],me.touches[1]],Fe=Math.hypot(ge.clientX-Ae.clientX,ge.clientY-Ae.clientY);w.current={distance:Fe,scale:M}},Ct=me=>{if(me.touches.length!==2||!w.current)return;me.preventDefault();const[ge,Ae]=[me.touches[0],me.touches[1]],Fe=Math.hypot(ge.clientX-Ae.clientX,ge.clientY-Ae.clientY),Oe=(ge.clientX+Ae.clientX)/2,bt=(ge.clientY+Ae.clientY)/2,ct=w.current.scale*(Fe/Math.max(1,w.current.distance));et(ct,Oe,bt)},lt=()=>{w.current=null,J(!1)};if(!S||!j)return null;const it=G.enabled,Xt=G.animate?`transform ${$r}ms ${du}`:"none";return ht.createPortal(t.jsxs("div",{className:"fixed inset-0",style:{zIndex:E},role:"dialog","aria-modal":"true","aria-label":v,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:C?1:0,transition:`opacity ${it?$r:Ot}ms ${Pt}`,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:ee?"4.5rem 3.5rem 6.5rem":"4.5rem 3.5rem 2.5rem",opacity:it||C?1:0,transform:it||C?"translateY(0) scale(1)":"translateY(10px) scale(0.96)",transition:it?"none":`opacity ${Ot}ms ${Pt}, transform ${Ot}ms ${Pt}`},onClick:me=>{me.target===me.currentTarget&&u&&r()},onWheel:Le,children:t.jsx("div",{className:"relative flex max-h-full max-w-full items-center justify-center will-change-transform",style:{transform:G.enabled?`translate3d(${G.dx}px, ${G.dy}px, 0) scale(${G.scale})`:void 0,transformOrigin:"center center",transition:G.enabled?Xt:void 0},children:t.jsx("div",{className:"relative flex max-h-full max-w-full items-center justify-center will-change-transform",style:{opacity:K.opacity,filter:K.blur?`blur(${K.blur}px)`:"blur(0px)",transform:`translate3d(${K.x}px, 0, 0) scale(${K.scale})`,transition:K.animate?[`opacity ${ro}ms ${no}`,`transform ${ro}ms ${no}`,`filter ${ro}ms ${no}`].join(", "):"none"},children:t.jsx("div",{ref:B,className:"pointer-events-auto relative max-h-full max-w-full touch-none select-none will-change-transform",style:{cursor:M>c+.001?"grab":"zoom-in",transform:`translate3d(${_.x}px, ${_.y}px, 0) scale(${M})`,transformOrigin:"center center",transition:ne?"none":`transform 220ms ${cu}`},onClick:me=>me.stopPropagation(),onDoubleClick:at,onPointerDown:ce,onPointerMove:Pe,onPointerUp:_e,onPointerCancel:_e,onTouchStart:Xe,onTouchMove:Ct,onTouchEnd:lt,children:t.jsx("img",{src:j.src,alt:j.alt||"",draggable:!1,className:"block max-h-[min(78vh,820px)] max-w-[min(86vw,1100px)] object-contain",style:{display:"block",borderRadius:oo,imageRendering:M>2.5?"pixelated":"auto"},onLoad:()=>{Qe()}},j.src+String(re))})})})}),t.jsxs("div",{className:"pointer-events-none absolute inset-0",style:{zIndex:2,opacity:C?1:0,transform:C?"translateY(0)":"translateY(-6px)",transition:`opacity ${it?$r:Ot}ms ${Pt}, transform ${it?$r:Ot}ms ${Pt}`},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:ao,children:[re+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(Ar,{label:"Alejar",onClick:nt,disabled:M<=c+.001,children:t.jsx(W.HiMinus,{className:"h-5 w-5"})}),t.jsx(Ar,{label:"Restablecer tamaño",onClick:ie,disabled:Je,children:t.jsx(W.HiArrowsPointingIn,{className:"h-5 w-5"})}),t.jsx(Ar,{label:"Acercar",onClick:ft,disabled:M>=T-.001,children:t.jsx(W.HiPlus,{className:"h-5 w-5"})})]}):null,t.jsx(Ar,{label:"Cerrar",onClick:r,children:t.jsx(W.HiXMark,{className:"h-5 w-5"})})]})]}),x?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"pointer-events-auto absolute left-3 top-1/2",style:{opacity:C?1:0,transform:C?"translate(0, -50%)":"translate(-8px, -50%)",transition:`opacity ${Ot}ms ${Pt}, transform ${Ot}ms ${Pt}`},children:t.jsx(Ar,{label:"Anterior",size:"lg",onClick:()=>fe(re-1),disabled:!g&&re<=0,children:t.jsx(W.HiChevronLeft,{className:"h-6 w-6"})})}),t.jsx("div",{className:"pointer-events-auto absolute right-3 top-1/2",style:{opacity:C?1:0,transform:C?"translate(0, -50%)":"translate(8px, -50%)",transition:`opacity ${Ot}ms ${Pt}, transform ${Ot}ms ${Pt}`},children:t.jsx(Ar,{label:"Siguiente",size:"lg",onClick:()=>fe(re+1),disabled:!g&&re>=n.length-1,children:t.jsx(W.HiChevronRight,{className:"h-6 w-6"})})})]}):null,ee?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((me,ge)=>{const Ae=ge===re;return t.jsx("button",{type:"button",role:"tab","aria-selected":Ae,"aria-label":me.alt||`Imagen ${ge+1}`,onClick:Fe=>{Fe.stopPropagation(),fe(ge)},className:"relative shrink-0 overflow-hidden transition-opacity",style:{width:56,height:42,borderRadius:oo,opacity:Ae?1:.42,transition:`opacity 180ms ${Pt}`},children:t.jsx("img",{src:me.src,alt:"",draggable:!1,className:"h-full w-full object-cover",style:{borderRadius:oo}})},`${me.src}-${ge}`)})})}):null]})]}),document.body)}function hu({children:e,className:r,style:n,maxZoom:a,minZoom:o,zoomStep:l,loop:i,showThumbnails:c}){const[d,u]=s.useState(!1),[m,b]=s.useState(0),[f,g]=s.useState([]),[h,E]=s.useState(null),v=s.useCallback((A,C,O)=>{g(A),E(O??null),b(C),u(!0)},[]),S=s.useCallback(A=>{qs(A,v)},[v]);return t.jsxs(t.Fragment,{children:[t.jsx("div",{className:`[&_img]:cursor-zoom-in ${r??""}`,style:n,onClick:S,children:e}),t.jsx(Vs,{open:d,onClose:()=>u(!1),index:m,onIndexChange:b,slides:f,originRect:h,maxZoom:a,minZoom:o,zoomStep:l,loop:i,showThumbnails:c})]})}function Xs(e){if(e!==void 0)return typeof e=="number"?`${e}px`:e}function Ys(e,r){if(e.length!==r.length)return!1;const n=new Set(r);return e.every(a=>n.has(a))}function so(e){return e.normalize("NFD").replace(new RegExp("\\p{M}","gu"),"").toLowerCase()}function gu(e,r){if(!r)return!0;const n=so(r);return so(e.label).includes(n)||!!(e.sublabel&&so(e.sublabel).includes(n))}function vu({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:b=2,truncateSelectedValues:f=!0,selectedOverflowPopover:g=!0,emptyText:h="Sin resultados",clearLabel:E="Limpiar seleccion",pruneMissingValues:v=!0}){const[S,A]=s.useState(!1),[C,O]=s.useState(""),[N,y]=s.useState(0),[M,k]=s.useState(!1),[_,Y]=s.useState({}),K=s.useRef(null),D=s.useRef(null),G=s.useRef(null),U=s.useRef(null),ne=u&&n.length>=m,J=s.useMemo(()=>new Set(e),[e]),R=s.useMemo(()=>{const x=new Map;for(const T of n)x.set(T.value,T);return x},[n]),V=s.useMemo(()=>{const x=[];for(const T of e){const ee=R.get(T);ee&&x.push(ee)}return x},[R,e]),X=b==="all"?V.length:b,de=V.slice(0,X),H=Math.max(0,V.length-de.length),I=g&&V.length>1,le=t.jsxs("div",{className:"flex max-w-[280px] flex-col gap-1.5 py-0.5",children:[t.jsxs("div",{className:"text-[11px] font-semibold uppercase tracking-wide",style:{color:"var(--text-muted)"},children:[V.length," seleccionados"]}),t.jsx("ul",{className:"m-0 flex list-none flex-col gap-1 p-0",children:V.map(x=>t.jsxs("li",{className:"flex min-w-0 items-baseline gap-1.5 text-xs",style:{color:"var(--text-main)"},children:[x.color&&t.jsx("span",{className:"mt-1 h-1.5 w-1.5 flex-shrink-0 rounded-full",style:{background:x.color}}),t.jsx("span",{className:"min-w-0 break-words font-medium",children:x.label}),x.sublabel?t.jsx("span",{className:"min-w-0 break-words",style:{color:"var(--text-muted)"},children:x.sublabel}):null]},x.value))})]}),L=s.useMemo(()=>{const x=C.trim();return!ne||!x?n:n.filter(T=>gu(T,x))},[n,C,ne]),oe=s.useCallback(()=>{const x=K.current;if(!x)return;const T=x.getBoundingClientRect(),ee=ne?304:244,fe=window.innerHeight-T.bottom,ie=fe<ee&&T.top>fe;Y({position:"fixed",left:T.left,top:ie?void 0:T.bottom+4,bottom:ie?window.innerHeight-T.top+4:void 0,width:Math.max(T.width,240),zIndex:9999})},[ne]),w=s.useCallback(x=>{Ys(e,x)||r(x)},[r,e]),te=s.useCallback(x=>{const T=R.get(x);if(T!=null&&T.disabled)return;const ee=J.has(x)?e.filter(fe=>fe!==x):[...e,x];w(ee)},[w,R,e,J]),B=s.useCallback(()=>w([]),[w]),F=s.useCallback(()=>{A(!1),O(""),y(0)},[]);s.useEffect(()=>k(!0),[]);const ue=s.useMemo(()=>n.map(x=>x.value).join("\0"),[n]);s.useEffect(()=>{if(!v||e.length===0||n.length===0)return;const x=new Set(n.map(ee=>ee.value)),T=e.filter(ee=>x.has(ee));Ys(e,T)||r(T)},[ue]),s.useEffect(()=>{if(!S)return;function x(T){var fe,ie;const ee=T.target;!((fe=K.current)!=null&&fe.contains(ee))&&!((ie=D.current)!=null&&ie.contains(ee))&&F()}return document.addEventListener("mousedown",x),()=>document.removeEventListener("mousedown",x)},[F,S]),s.useEffect(()=>{S&&(y(0),oe(),ne&&setTimeout(()=>{var x;return(x=G.current)==null?void 0:x.focus()},0))},[S,ne,oe]),s.useEffect(()=>{if(S)return window.addEventListener("resize",oe),window.addEventListener("scroll",oe,!0),()=>{window.removeEventListener("resize",oe),window.removeEventListener("scroll",oe,!0)}},[S,oe]),s.useEffect(()=>{if(L.length===0){y(0);return}y(x=>Math.min(x,L.length-1))},[L.length]),s.useEffect(()=>{if(N<0||!U.current)return;const x=U.current.children[N];x==null||x.scrollIntoView({block:"nearest"})},[N]);function re(x){if(!o){if(!S){(x.key==="Enter"||x.key===" "||x.key==="ArrowDown")&&(x.preventDefault(),A(!0));return}if(x.key==="Escape"){x.preventDefault(),F();return}if(x.key==="ArrowDown"){if(x.preventDefault(),L.length===0)return;y(T=>Math.min(T+1,L.length-1));return}if(x.key==="ArrowUp"){x.preventDefault(),y(T=>Math.max(T-1,0));return}if(x.key==="Enter"&&L[N]&&!L[N].disabled){x.preventDefault(),te(L[N].value);return}x.key==="Backspace"&&!C&&e.length&&(x.preventDefault(),w(e.slice(0,-1)))}}const j=t.jsxs("div",{ref:D,className:"overflow-hidden rounded-xl shadow-xl",style:{..._,background:"var(--bg-card)",border:"1px solid var(--border)"},children:[ne&&t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",style:{borderBottom:"1px solid var(--border)"},children:[t.jsx(W.HiMagnifyingGlass,{className:"h-3.5 w-3.5 flex-shrink-0",style:{color:"var(--text-muted)"}}),t.jsx("input",{ref:G,value:C,onChange:x=>{O(x.target.value),y(0)},onKeyDown:x=>{(x.key==="ArrowDown"||x.key==="ArrowUp"||x.key==="Enter"||x.key==="Escape")&&(x.stopPropagation(),re(x))},placeholder:"Buscar…",className:"min-w-0 flex-1 bg-transparent text-sm outline-none",style:{color:"var(--text-main)"}}),C&&t.jsx("button",{type:"button","aria-label":"Limpiar búsqueda",onMouseDown:x=>{x.preventDefault(),O(""),y(0)},children:t.jsx(W.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:x=>{x.preventDefault(),B()},className:"font-semibold transition-colors hover:text-[var(--primary)]",children:E})]}),t.jsxs("ul",{ref:U,role:"listbox","aria-multiselectable":"true",className:"overflow-y-auto",style:{maxHeight:ne?220:200,scrollbarWidth:"thin",scrollbarColor:"var(--border) transparent",overscrollBehavior:"contain"},children:[L.map((x,T)=>{const ee=T===N,fe=J.has(x.value);return t.jsxs("li",{role:"option","aria-selected":fe,onMouseDown:ie=>{ie.preventDefault(),!x.disabled&&te(x.value)},onMouseEnter:()=>!x.disabled&&y(T),className:"flex cursor-pointer items-center gap-2 px-3 py-2 text-sm transition-colors",style:{background:ee?"var(--bg-hover)":fe?"color-mix(in srgb, var(--primary) 6%, transparent)":"transparent",color:x.disabled?"var(--text-muted)":"var(--text-main)",cursor:x.disabled?"not-allowed":"pointer",opacity:x.disabled?.58:1},children:[t.jsx("span",{className:"flex h-4 w-4 flex-shrink-0 items-center justify-center rounded border",style:{borderColor:fe?"var(--primary)":"var(--border)",background:fe?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:fe&&t.jsx(W.HiCheck,{className:"h-3 w-3"})}),x.color&&t.jsx("span",{className:"h-2.5 w-2.5 flex-shrink-0 rounded-full",style:{background:x.color}}),t.jsxs("span",{className:"flex min-w-0 flex-1 items-baseline gap-1 overflow-hidden",children:[t.jsx(qt,{className:"min-w-0 flex-1",children:x.label}),x.sublabel&&t.jsx(qt,{className:"min-w-0 flex-shrink",style:{color:"var(--text-muted)",fontSize:12},children:x.sublabel})]}),x.badge&&t.jsx("span",{className:"flex-shrink-0 text-xs",style:{color:"var(--text-muted)"},children:x.badge})]},x.value)}),L.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:K,className:`relative ${l||"w-full"}`,style:i,onKeyDown:re,children:[t.jsxs("button",{type:"button",disabled:o,onClick:()=>{o||(S?F():A(!0))},className:"flex w-full items-center gap-2 rounded-lg text-left text-sm transition-colors focus:outline-none",style:{minHeight:Xs(c),padding:Xs(d),background:"var(--bg-input)",color:V.length?"var(--text-main)":"var(--text-muted)",border:S?"1px solid var(--primary)":"1px solid var(--border)",opacity:o?.5:1,cursor:o?"not-allowed":"pointer"},"aria-haspopup":"listbox","aria-expanded":S,children:[t.jsx("span",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-1.5 overflow-hidden",children:de.length?(()=>{const x=t.jsxs(t.Fragment,{children:[de.map(T=>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:[T.color&&t.jsx("span",{className:"h-1.5 w-1.5 flex-shrink-0 rounded-full",style:{background:T.color}}),f?t.jsx(qt,{className:"min-w-0 flex-1",children:T.label}):t.jsx("span",{className:"break-words",children:T.label}),t.jsx("span",{role:"button",tabIndex:-1,"aria-label":`Quitar ${T.label}`,onMouseDown:ee=>{ee.preventDefault(),ee.stopPropagation(),te(T.value)},className:"flex-shrink-0 rounded-full p-0.5 transition-colors hover:bg-black/10",style:{color:"var(--text-muted)"},children:t.jsx(W.HiXMark,{className:"h-3 w-3"})})]},T.value)),H>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)"},"aria-label":`${H} seleccionados más`,children:["+",H]})]});return I?t.jsx(Bt,{as:"span",content:le,placement:"bottom",followCursor:!1,className:"flex min-w-0 flex-1 flex-wrap items-center gap-1.5 overflow-hidden",children:x}):x})():t.jsx("span",{className:"truncate",children:a})}),V.length?t.jsx("span",{role:"button",tabIndex:-1,"aria-label":E,onMouseDown:x=>{x.preventDefault(),x.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(W.HiXMark,{className:"h-3.5 w-3.5"})}):t.jsx(W.HiChevronDown,{className:"h-4 w-4 flex-shrink-0 transition-transform",style:{color:"var(--text-muted)",transform:S?"rotate(180deg)":"rotate(0deg)"}})]}),S&&M&&ht.createPortal(j,document.body)]})}function yu({inputMode:e="decimal",...r}){return t.jsx(to,{...r,type:"number",inputMode:e})}function xu(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 wu({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=xu(c,i,o);return t.jsxs("nav",{"aria-label":"Paginacion",className:`inline-flex items-center gap-1 ${l}`,children:[t.jsx(Ve,{variant:"icon",size:"xs","aria-label":"Pagina anterior",disabled:a||c<=1,onClick:()=>n(c-1),children:t.jsx(W.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(Ve,{variant:"icon",size:"xs","aria-label":"Pagina siguiente",disabled:a||c>=i,onClick:()=>n(c+1),children:t.jsx(W.HiChevronRight,{className:"h-4 w-4"})})]})}const Ks=[{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 Gs(e){return e==null?"":String(e)}function Wn(e){return e?e.startsWith("+")?e:`+${e}`:"+1"}function Nu(e){return typeof e=="number"?`${e}px`:e}function ku({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:b,allowedCountryCodes:f,countryCodeOptions:g,countryCodePlaceholder:h="Codigo",countryCodeClassName:E="",countryCodeWidth:v=84,onPhoneValueChange:S,label:A,containerClassName:C="",helperText:O,helperDisplay:N="inline",labelAction:y,className:M="",required:k,disabled:_,floatingLabel:Y,showPasswordToggle:K,nativeValidation:D,errorTooltipLabel:G="Error de validacion",...U}){var T;const[ne,J]=s.useState(()=>Gs(c)),[R,V]=s.useState(()=>Wn(m)),X=s.useMemo(()=>{const ee=g??Ks,fe=f==null?void 0:f.map(Wn);return fe!=null&&fe.length?ee.filter(ie=>fe.includes(ie.value)):ee},[f,g]),de=((T=X[0])==null?void 0:T.value)??"+1",H=X.some(ee=>ee.value===Wn(u??R))?Wn(u??R):de,I=i!==void 0?Gs(i):ne,le=`${H} ${I}`.trim(),L=n&&I.length>0&&!Ra(le)?a:void 0,oe=l??L,w=!!oe,te=w&&o!=="tooltip",B=w&&o!=="inline",F=!!O&&N==="tooltip"&&!te,ue=w?"border-[var(--danger)] focus-within:border-[var(--danger)]":"border-[var(--border)] focus-within:border-[var(--primary)]",re=ee=>{const fe=ee.currentTarget.value;i===void 0&&J(fe),S==null||S(fe,{countryCode:H,nationalNumber:fe,fullNumber:`${H} ${fe}`.trim()}),d==null||d(ee)},j=ee=>{u===void 0&&V(ee),b==null||b(ee),S==null||S(I,{countryCode:ee,nationalNumber:I,fullNumber:`${ee} ${I}`.trim()})},x=B?t.jsx(Bt,{as:"span",content:oe,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":G,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 ${C}`,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:A}),k&&t.jsx("span",{className:"text-[var(--danger)]",children:"*"}),F?t.jsx(Mr,{content:O}):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 ${ue}`,children:[t.jsx(dr,{value:H,onChange:j,options:X,placeholder:h,disabled:_,ariaLabel:"Codigo telefonico",triggerVariant:"ghost",showSelectedSublabel:!1,searchable:!0,minOptionsForSearch:0,dropdownMinWidth:300,className:`shrink-0 ${E}`,style:{width:Nu(v)},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",{...U,value:i,defaultValue:c,type:"tel",inputMode:r,autoComplete:e,disabled:_,required:void 0,"aria-label":U["aria-label"]??(typeof A=="string"?A:void 0),"aria-invalid":w||U["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 ${B?"pr-10":""} ${M}`,onChange:re}),x]})]}),t.jsx(Tr,{error:te?oe:void 0,helperText:O,helperDisplay:N})]})}function Su({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,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 Eu=new Set(["table","thead","tbody","tfoot","tr","th","td","caption"]),jn=(e,r,n)=>Math.min(n,Math.max(r,Math.round(e)||r)),Lr=12,qn=8,lo=(e,r,n)=>{const a=Vn(n),o=e.insertRow(r);for(let l=0;l<a;l+=1){const i=o.insertCell(-1);i.innerHTML="<br>"}return o.cells[0]??null},Zs=(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>=Lr?null:lo(l,0,e)}if(a.tagName==="TBODY"&&a.rows.length>=Lr)return null;const o=Array.from(a.rows).indexOf(n);return lo(a,o+1,e)},Cu=(e,r)=>{var o;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"&&((o=e.tBodies[0])==null?void 0:o.rows.length)===0&&e.rows.length<=1?!1:(n.remove(),!0)},Qs=(e,r)=>Vn(e)>=qn?!1:(e.querySelectorAll("tr").forEach(n=>{const a=n.closest("thead")!==null,o=document.createElement(a?"th":"td");a?o.textContent=`Columna ${n.cells.length+1}`:o.innerHTML="<br>";const l=n.cells[r];l!=null&&l.nextSibling?n.insertBefore(o,l.nextSibling):n.appendChild(o)}),!0),Mu=(e,r)=>Vn(e)<=1?!1:(e.querySelectorAll("tr").forEach(n=>{var a;(a=n.cells[r])==null||a.remove()}),!0),Js=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")})},Rs=(e,r,n)=>{Js(e),r&&(r.classList.add("rich-table-row-active"),e.querySelectorAll("tr").forEach(a=>{var o;(o=a.cells[n])==null||o.classList.add("rich-table-col-active")}))},Tu=(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}}},Un=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},el=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")})},$u=(e,r,n,a,o)=>{switch(e){case"table-delete":return r.remove(),!0;case"table-row-add":{const l=Number.isFinite(n)?Zs(r,n):io(r);return l&&Xn(l,o,!0),!!l}case"table-row-del":return Number.isFinite(n)?Cu(r,n):!1;case"table-col-add":return Number.isFinite(a)?Qs(r,a):Ou(r);case"table-col-del":return Number.isFinite(a)?Mu(r,a):!1;default:return!1}},Vn=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)},tl=e=>(e==null?void 0:e.closest("table"))??null,rl=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},Lu=e=>Array.from(e.querySelectorAll("th, td")),nl=(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),o=e.closest("tr");return!o||o!==a[a.length-1]?!1:e===o.cells[o.cells.length-1]},Du=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()===""},Xn=(e,r,n=!0)=>{r==null||r.focus();const a=document.createRange();a.selectNodeContents(e),a.collapse(n);const o=window.getSelection();o==null||o.removeAllRanges(),o==null||o.addRange(a)},io=e=>{const r=Au(e);if(r.length>=Lr)return null;const n=r[r.length-1];if(!n){const a=e.tBodies[0]??e.createTBody();return lo(a,0,e)}return Zs(e,Array.from(e.rows).indexOf(n))},Ou=e=>{const r=Vn(e)-1;return r<0?!1:Qs(e,r)},co=e=>{el(e)},Hu=(e,r,n)=>{const a=jn(e,1,Lr),o=jn(r,1,qn),l=n?`<thead><tr>${Array.from({length:o},(c,d)=>`<th>Columna ${d+1}</th>`).join("")}</tr></thead>`:"",i=Array.from({length:a},()=>`<tr>${Array.from({length:o},()=>"<td><br></td>").join("")}</tr>`).join("");return`<table class="rich-table">${l}<tbody>${i}</tbody></table><p><br></p>`},al=()=>'<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>',ln=e=>e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'"),ol=e=>e.toLocaleLowerCase().replace(new RegExp("(^|[^\\p{L}\\p{N}])(\\p{L})","gu"),(r,n,a)=>`${n}${a.toLocaleUpperCase()}`),Iu=e=>e.replace(/[<>]/g,"").toLowerCase(),Bu=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"]),Fu=/^[\s\u00a0]*([•●○■▪▫◆◇►▶➢❖✓✔\-–—*])[\s\u00a0]+/,Pu=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},Yn=(e,r)=>r.test(e),_u=e=>Yn(e,/font-weight\s*:\s*(bold|[6-9]00)/i),zu=e=>Yn(e,/font-style\s*:\s*italic/i),Wu=e=>Yn(e,/text-decoration(?:-line)?\s*:[^;]*underline/i),ju=e=>Yn(e,/text-decoration(?:-line)?\s*:[^;]*(line-through|linethrough)/i),Kn=(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)},Gn=e=>{const r=e.parentNode;if(!r){e.remove();return}for(;e.firstChild;)r.insertBefore(e.firstChild,e);r.removeChild(e)},qu=e=>{const r=e.getAttribute("class")??"",n=e.getAttribute("style")??"";return/mso-list/i.test(n)||/MsoListParagraph/i.test(r)||/MsoList/i.test(r)},sl=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"},Uu=e=>{const n=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_TEXT).nextNode();if(!n||!n.textContent)return;const a=n.textContent.replace(Fu,"").replace(/^\s*\d+[.)]\s+/,"").replace(/^\s*[a-zA-Z][.)]\s+/,"");a!==n.textContent&&(n.textContent=a)},Vu=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&&(_u(a)&&Kn(n,"strong"),zu(a)&&Kn(n,"em"),Wu(a)&&Kn(n,"u"),ju(a)&&Kn(n,"s"))})},Xu=e=>{const r=Array.from(e.querySelectorAll("p, div")).filter(qu);if(!r.length)return;let n=0;for(;n<r.length;){const a=r[n],o=sl(a),l=[a];let i=n+1;for(;i<r.length;){const u=r[i];if(sl(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=>{Uu(u);const m=u.ownerDocument.createElement("li");for(;u.firstChild;)m.appendChild(u.firstChild);d.appendChild(m),u.remove()}),n=i}},Yu=e=>e==="h1"?"h2":e==="h4"||e==="h5"||e==="h6"?"h3":e==="div"?"p":e,Ku=e=>{const r=Pu(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()),Vu(o),Xu(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"){Gn(d),c.forEach(l);return}if(!Bu.has(u)){Gn(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=Yu(u);if(m!==u){const b=d.ownerDocument.createElement(m);for(;d.firstChild;)b.appendChild(d.firstChild);d.replaceWith(b),l(b);return}if(Eu.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(),g=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(g)){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){Gn(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"){Gn(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(/ /gi," ").replace(/(<br\s*\/?>\s*){3,}/gi,"<br><br>").replace(/<p>(?:\s|<br\s*\/?>)*<\/p>/gi,"").trim()},uo=e=>ln(e).replace(/\r\n?/g,`
|
|
25
|
-
`).split(/\n{2,}/).map(r=>`<p>${r.replace(/\n/g,"<br>")||"<br>"}</p>`).join(""),Gu=e=>new RegExp("\\p{L}","u").test(e),fo=(e,r)=>{const n=e.trim();return!n||!Gu(n)?!1:r==="uppercase"?n===n.toLocaleUpperCase():r==="lowercase"?n===n.toLocaleLowerCase():n===ol(n)},ll=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",al())}(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 il({value:e,onChange:r,placeholder:n="Escribe algo...",minHeight:a="80px",instanceId:o,toolbarVariant:l="full"}){const i=s.useId(),c=o||i,d=s.useCallback(()=>document,[]),u=s.useRef(null),m=s.useRef(null),b=s.useRef(new Map),f=s.useRef(null),g=s.useRef(!1),h=s.useRef(e??""),E=s.useRef(r),v=s.useRef(()=>{}),S=s.useRef(!1),[A,C]=s.useState(()=>!e||e.trim()===""),[O,N]=s.useState(new Set),[y,M]=s.useState(null),[k,_]=s.useState(""),[Y,K]=s.useState(""),[D,G]=s.useState(""),[U,ne]=s.useState(""),[J,R]=s.useState(3),[V,X]=s.useState(3),[de,H]=s.useState(!0),[I,le]=s.useState(!1),[L,oe]=s.useState(l==="full"),[w,te]=s.useState(null),[B,F]=s.useState(null),ue=s.useRef(null),re=s.useRef(!1),j=s.useRef(null),x=s.useCallback(()=>g.current?m.current:u.current,[]);s.useEffect(()=>{E.current=r},[r]);const T=s.useCallback(()=>{const z=window.getSelection(),Z=x();if(!z||!Z||z.rangeCount===0||z.isCollapsed)return"";const be=z.getRangeAt(0);return!Z.contains(be.startContainer)||!Z.contains(be.endContainer)?"":z.toString()},[x]);s.useEffect(()=>{const z=e??"";if(S.current&&z===h.current){S.current=!1,C(!z||z.trim()==="");return}S.current=!1,h.current=z;const Z=[u.current,m.current].filter(he=>!!he);Z.forEach(he=>{he.innerHTML!==z&&(he.innerHTML=z)}),C(!z||z.trim()===""),Z.forEach(he=>co(he));const be=Z.map(he=>ll(he));return()=>be.forEach(he=>he())},[e]),s.useEffect(()=>{var he,Ee;g.current=I;let z,Z=0,be;if(I){const xe=u.current;xe&&(h.current=Un(xe));const He=()=>{var Ye;const De=m.current;if(!De){Z=requestAnimationFrame(He);return}De.innerHTML!==h.current&&(De.innerHTML=h.current),z=ll(De),co(De),C(((Ye=De.textContent)==null?void 0:Ye.trim())===""),be=setTimeout(()=>De.focus(),60)};Z=requestAnimationFrame(He)}else{const xe=m.current,He=u.current,De=xe?Un(xe):h.current,Ye=h.current;h.current=De,He&&He.innerHTML!==De&&(He.innerHTML=De),De!==Ye&&E.current(De),C(((Ee=(he=xe??He)==null?void 0:he.textContent)==null?void 0:Ee.trim())==="")}return()=>{Z&&cancelAnimationFrame(Z),be&&clearTimeout(be),z==null||z()}},[I]);const ee=s.useCallback(()=>{const z=["bold","italic","underline","strikeThrough","insertUnorderedList","insertOrderedList","justifyLeft","justifyCenter","justifyRight","justifyFull"],Z=new Set;z.forEach(he=>{try{d().queryCommandState(he)&&Z.add(he)}catch{return}});try{const he=Iu(d().queryCommandValue("formatBlock"));he&&Z.add(`formatBlock:${he}`)}catch{}const be=T();fo(be,"uppercase")&&Z.add("__upper"),fo(be,"lowercase")&&Z.add("__lower"),fo(be,"capitalize")&&Z.add("__cap"),N(Z)},[T,d]),fe=()=>{var Z;const z=x();z&&(h.current=Un(z),S.current=!0,E.current(h.current),C(((Z=z.textContent)==null?void 0:Z.trim())===""))};v.current=fe;const ie=s.useCallback(()=>{j.current&&(clearTimeout(j.current),j.current=null),ue.current&&(Js(ue.current),ue.current=null),re.current=!1,te(null),F(null)},[]),pe=s.useCallback(()=>{j.current&&(clearTimeout(j.current),j.current=null)},[]),ae=s.useCallback(()=>{pe(),j.current=setTimeout(()=>{re.current||ie()},280)},[pe,ie]);s.useEffect(()=>()=>{j.current&&clearTimeout(j.current)},[]);const ye=s.useCallback(z=>{const Z=ue.current;if(!Z||!Z.isConnected){ie();return}const be=(w==null?void 0:w.rowIndex)??(B==null?void 0:B.rowIndex)??-1,he=(w==null?void 0:w.colIndex)??(B==null?void 0:B.colIndex)??-1;$u(z,Z,be,he,x()),ie(),v.current(),ee()},[x,ie,ee,B,w]),Qe=s.useCallback(z=>{if(B)return;const Z=z.currentTarget,be=z.target;if(be.closest(".rich-table-action-bar, .rich-table-context-menu")){pe();return}const he=be.closest("td, th");if(!he||!Z.contains(he)){ae();return}const Ee=he.closest("tr"),xe=he.closest("table");if(!Ee||!xe||!Z.contains(xe)){ae();return}pe(),xe.classList.add("rich-table"),ue.current=xe,Rs(xe,Ee,he.cellIndex),te(Tu(xe,Ee,he))},[pe,ae,B]),Je=s.useCallback(z=>{const Z=z.relatedTarget;if(Z instanceof Element&&(Z.closest(".rich-table-action-bar")||Z.closest(".rich-table-context-menu"))){pe();return}ae()},[pe,ae]),et=s.useCallback(z=>{const Z=z.currentTarget,he=z.target.closest("td, th");if(!he||!Z.contains(he))return;const Ee=he.closest("tr"),xe=he.closest("table");if(!Ee||!xe||!Z.contains(xe))return;z.preventDefault(),xe.classList.add("rich-table"),ue.current=xe;const He=Array.from(xe.rows).indexOf(Ee),De=he.cellIndex;Rs(xe,Ee,De),te(null),F({x:z.clientX,y:z.clientY,rowIndex:He,colIndex:De})},[]);s.useEffect(()=>{if(!w&&!B)return;const z=()=>ae();return window.addEventListener("scroll",z,!0),window.addEventListener("resize",z),()=>{window.removeEventListener("scroll",z,!0),window.removeEventListener("resize",z)}},[ae,B,w]),s.useEffect(()=>{if(!B)return;const z=Z=>{const be=Z.target;be instanceof Element&&be.closest(".rich-table-context-menu")||F(null)};return window.addEventListener("mousedown",z),()=>window.removeEventListener("mousedown",z)},[B]);const ft=z=>{if(!z){const Z=u.current;Z&&(h.current=Un(Z))}le(!z)},nt=(z,Z)=>{var be;(be=x())==null||be.focus(),d().execCommand(z,!1,Z),fe(),ee()},Le=z=>{nt("formatBlock",z)},ce=()=>{var z;(z=x())==null||z.focus(),d().execCommand("insertHTML",!1,"<hr><p><br></p>"),fe(),ee()},Pe=()=>{const z=window.getSelection();z&&z.rangeCount>0&&(f.current=z.getRangeAt(0).cloneRange())},_e=()=>{const z=window.getSelection();z&&f.current&&(z.removeAllRanges(),z.addRange(f.current))},at=z=>{if(Pe(),z==="link"){const Z=window.getSelection();K(Z&&!Z.isCollapsed?Z.toString():""),_("")}z==="image"&&(G(""),ne("")),z==="table"&&(R(3),X(3),H(!0)),M(z)},Xe=()=>{var he;if(!k.trim())return;_e(),(he=x())==null||he.focus();const z=window.getSelection(),be=(z&&!z.isCollapsed?z.toString():"")||Y.trim()||k.trim();d().execCommand("insertHTML",!1,`<a href="${ln(k.trim())}" target="_blank" rel="noopener noreferrer" class="rich-link">${ln(be)}</a>`),fe(),M(null)},Ct=(z,Z="")=>`<span class="rich-img-wrap" contenteditable="false"><img src="${ln(z)}" alt="${ln(Z)}" class="rich-img" />${al()}</span>`,lt=()=>{var z;D.trim()&&(_e(),(z=x())==null||z.focus(),d().execCommand("insertHTML",!1,Ct(D.trim(),U.trim())),fe(),M(null))},it=()=>{var z;_e(),(z=x())==null||z.focus(),d().execCommand("insertHTML",!1,Hu(J,V,de)),fe(),M(null)},Xt=(z,Z=1200,be=1200,he=.72)=>new Promise((Ee,xe)=>{const He=new FileReader;He.onerror=xe,He.onload=De=>{var or;const Ye=(or=De.target)==null?void 0:or.result,Ke=new Image;Ke.onerror=xe,Ke.onload=()=>{let{width:vt,height:Yt}=Ke;if(vt>Z||Yt>be){const Kt=Math.min(Z/vt,be/Yt);vt=Math.round(vt*Kt),Yt=Math.round(Yt*Kt)}const Ht=document.createElement("canvas");Ht.width=vt,Ht.height=Yt;const sr=Ht.getContext("2d");if(!sr){Ee(Ye);return}sr.drawImage(Ke,0,0,vt,Yt),Ee(Ht.toDataURL("image/jpeg",he))},Ke.src=Ye},He.readAsDataURL(z)}),me=z=>{z.focus();const Z=window.getSelection();if(!Z||Z.rangeCount===0||!z.contains(Z.anchorNode)){const be=document.createRange();be.selectNodeContents(z),be.collapse(!1),Z==null||Z.removeAllRanges(),Z==null||Z.addRange(be)}},ge=s.useRef(()=>{});ge.current=z=>{const Z=x();Z&&(me(Z),d().execCommand("insertHTML",!1,z),co(Z),Z.querySelectorAll("p").forEach(be=>{!(be.textContent??"").replace(/[\u00a0\s]+/g,"")&&!be.querySelector("img, hr, table")&&be.remove()}),fe(),ee())};const Ae=s.useRef(Xt);Ae.current=Xt;const Fe=s.useRef(Ct);Fe.current=Ct;const Oe=s.useCallback(z=>{if(!z||b.current.has(z))return;const Z=be=>{const he=be.clipboardData;if(!he)return;const Ee=he.getData("text/html"),xe=he.getData("text/plain");if(Ee||xe){be.preventDefault(),be.stopPropagation();try{const Ke=Ee?Ku(Ee):uo(xe);if(!Ke){xe&&ge.current(uo(xe));return}ge.current(Ke)}catch{xe&&ge.current(uo(xe))}return}const De=Array.from(he.items).find(Ke=>Ke.type.startsWith("image/"));if(!De)return;be.preventDefault(),be.stopPropagation();const Ye=De.getAsFile();Ye&&Ae.current(Ye).then(Ke=>{ge.current(Fe.current(Ke,"imagen"))})};z.addEventListener("paste",Z,!0),b.current.set(z,()=>{z.removeEventListener("paste",Z,!0),b.current.delete(z)})},[]),bt=s.useCallback(z=>{var be;const Z=u.current;Z&&Z!==z&&((be=b.current.get(Z))==null||be()),u.current=z,z&&Oe(z)},[Oe]),ct=s.useCallback(z=>{var be;const Z=m.current;Z&&Z!==z&&((be=b.current.get(Z))==null||be()),m.current=z,z&&Oe(z)},[Oe]);s.useEffect(()=>{const z=b.current;return()=>{z.forEach(Z=>Z()),z.clear()}},[]);const ze=z=>{const Z=window.getSelection(),be=x();if(!Z||!be||Z.rangeCount===0||Z.isCollapsed)return;const he=Z.getRangeAt(0);if(!be.contains(he.startContainer)||!be.contains(he.endContainer))return;const Ee=he.toString();if(!Ee)return;let xe=Ee;z==="uppercase"?xe=Ee.toLocaleUpperCase():z==="lowercase"?xe=Ee.toLocaleLowerCase():xe=ol(Ee),he.deleteContents();const He=document.createTextNode(xe);he.insertNode(He);const De=document.createRange();De.setStart(He,0),De.setEnd(He,xe.length),Z.removeAllRanges(),Z.addRange(De),f.current=De.cloneRange(),fe(),ee()},je=()=>{Pe(),ee()},dt=()=>{const z=x();z&&el(z),fe(),ee()},mt=()=>{requestAnimationFrame(()=>{var z;(z=x())==null||z.focus()})},br=z=>{var Z,be;if((z.metaKey||z.ctrlKey)&&z.key==="Enter"){if(z.preventDefault(),z.stopPropagation(),z.repeat)return;(Z=x())==null||Z.focus(),d().execCommand("insertLineBreak",!1)||d().execCommand("insertHTML",!1,"<br>"),fe(),ee();return}if(z.key==="Tab"){const he=window.getSelection(),Ee=rl((he==null?void 0:he.anchorNode)??null),xe=x(),He=tl(Ee);if(Ee&&He&&(xe!=null&&xe.contains(Ee))){z.preventDefault();const De=Lu(He),Ye=De.indexOf(Ee),Ke=Ye>=0?De[Ye+1]:null;if(Ke)Xn(Ke,xe,!0);else if(nl(Ee,He)){const or=io(He);or&&Xn(or,xe,!0)}fe(),ee();return}z.preventDefault(),(be=x())==null||be.focus(),d().execCommand("insertText",!1," "),fe(),ee();return}if(z.key==="Enter"&&!z.shiftKey&&!(z.metaKey||z.ctrlKey)){const he=window.getSelection(),Ee=rl((he==null?void 0:he.anchorNode)??null),xe=x(),He=tl(Ee);if(Ee&&He&&(xe!=null&&xe.contains(Ee))&&nl(Ee,He)&&Du(Ee)){z.preventDefault();const De=io(He);De&&Xn(De,xe,!0),fe(),ee();return}}if(z.key==="Escape"){if(B){F(null);return}if(y){M(null);return}if(g.current){le(!1);return}}y||(z.ctrlKey||z.metaKey)&&(z.key==="b"&&(z.preventDefault(),nt("bold")),z.key==="i"&&(z.preventDefault(),nt("italic")),z.key==="u"&&(z.preventDefault(),nt("underline")),z.key==="k"&&(z.preventDefault(),at("link")))},ut=()=>t.jsx("div",{className:"h-4 w-px flex-shrink-0 mx-1",style:{background:"var(--border)"}}),Be=(z,Z,be,he,Ee)=>{const xe=Ee??(O.has(be)||be==="__link"&&y==="link"||be==="__img"&&y==="image"||be==="__table"&&y==="table");return t.jsx("button",{type:"button",title:Z,tabIndex:-1,onFocus:mt,onMouseDown:He=>{He.preventDefault(),he?he():nt(be)},className:"flex h-7 w-7 items-center justify-center rounded text-xs font-bold transition-colors",style:{color:xe?"var(--primary)":"var(--text-secondary)",background:xe?"rgba(59,130,246,0.12)":"transparent"},children:z},be)},vn=z=>{const Z=z.target;if(Z.closest("[data-action='delete-img']")){z.preventDefault();const be=Z.closest(".rich-img-wrap");be&&(be.remove(),fe())}},fa=()=>{pe(),re.current=!0},pt=()=>{re.current=!1,ae()},Mt=(z,Z,be,he=!1)=>t.jsx("button",{type:"button",className:`rich-table-action-btn${he?" rich-table-action-btn--danger":""}`,title:z,"aria-label":z,onMouseDown:Ee=>{Ee.preventDefault(),Ee.stopPropagation(),ye(be)},children:Z}),Tt=()=>typeof document>"u"||!w&&!B?null:ht.createPortal(t.jsxs(t.Fragment,{children:[w&&!B&&t.jsxs("div",{className:"rich-table-action-bar",style:{left:w.bar.x,top:w.bar.y},onMouseEnter:fa,onMouseLeave:pt,children:[t.jsxs("span",{className:"rich-table-action-hint",children:["Fila ",w.rowIndex+1," · Col ",w.colIndex+1]}),t.jsxs("div",{className:"rich-table-action-group",children:[t.jsx("span",{className:"rich-table-action-label",children:"Fila"}),Mt("Añadir fila abajo","+","table-row-add"),Mt("Eliminar fila","−","table-row-del")]}),t.jsxs("div",{className:"rich-table-action-group",children:[t.jsx("span",{className:"rich-table-action-label",children:"Columna"}),Mt("Añadir columna a la derecha","+","table-col-add"),Mt("Eliminar columna","−","table-col-del")]}),Mt("Eliminar tabla","Eliminar","table-delete",!0)]}),B&&t.jsx("div",{className:"rich-table-context-menu",style:{left:B.x,top:B.y},onMouseDown:z=>z.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(([z,Z])=>t.jsx("button",{type:"button",onMouseDown:be=>{be.preventDefault(),ye(Z)},children:z},Z))})]}),document.body),ar=z=>t.jsxs(t.Fragment,{children:[y==="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:z},children:[t.jsx("input",{autoFocus:!0,type:"url",value:k,onChange:Z=>_(Z.target.value),onKeyDown:Z=>{Z.key==="Enter"&&(Z.preventDefault(),Xe()),Z.key==="Escape"&&M(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:Y,onChange:Z=>K(Z.target.value),onKeyDown:Z=>{Z.key==="Enter"&&(Z.preventDefault(),Xe()),Z.key==="Escape"&&M(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:Xe,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:()=>M(null),className:"rounded px-2 py-1 text-xs",style:{color:"var(--text-muted)"},children:"x"})]}),y==="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:z},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:Lr,value:J,onChange:Z=>R(jn(Number(Z.target.value),1,Lr)),onKeyDown:Z=>{Z.key==="Enter"&&(Z.preventDefault(),it()),Z.key==="Escape"&&M(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:qn,value:V,onChange:Z=>X(jn(Number(Z.target.value),1,qn)),onKeyDown:Z=>{Z.key==="Enter"&&(Z.preventDefault(),it()),Z.key==="Escape"&&M(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:de,onChange:Z=>H(Z.target.checked)}),"Encabezado"]}),t.jsx("button",{type:"button",onClick:it,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:()=>M(null),className:"rounded px-2 py-1 text-xs",style:{color:"var(--text-muted)"},children:"x"})]}),y==="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:z},children:[t.jsx("input",{autoFocus:!0,type:"url",value:D,onChange:Z=>G(Z.target.value),onKeyDown:Z=>{Z.key==="Enter"&&(Z.preventDefault(),lt()),Z.key==="Escape"&&M(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:U,onChange:Z=>ne(Z.target.value),onKeyDown:Z=>{Z.key==="Enter"&&(Z.preventDefault(),lt()),Z.key==="Escape"&&M(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:lt,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:()=>M(null),className:"rounded px-2 py-1 text-xs",style:{color:"var(--text-muted)"},children:"x"})]})]}),Wr=(z,Z)=>{const be=l==="compact",he=!be||L||z;return 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:Z},"data-toolbar-variant":l,children:[be&&!z&&t.jsxs("button",{type:"button",title:L?"Ocultar herramientas":"Mostrar herramientas de formato",tabIndex:-1,onFocus:mt,onMouseDown:Ee=>{Ee.preventDefault(),oe(xe=>!xe)},className:"flex h-7 items-center gap-1 rounded px-1.5 text-[10px] font-semibold transition-colors",style:{color:"var(--text-secondary)",background:L?"color-mix(in srgb, var(--primary) 12%, transparent)":"transparent"},children:[L?t.jsx(W.HiChevronUp,{className:"h-3.5 w-3.5"}):t.jsx(W.HiChevronDown,{className:"h-3.5 w-3.5"}),L?"Ocultar herramientas":"Herramientas"]}),he&&t.jsxs(t.Fragment,{children:[Be(t.jsx("b",{children:"B"}),"Negrita (Ctrl+B)","bold"),Be(t.jsx("i",{children:"I"}),"Cursiva (Ctrl+I)","italic"),Be(t.jsx("u",{children:"U"}),"Subrayado (Ctrl+U)","underline"),Be(t.jsx(W.HiListBullet,{className:"h-4 w-4"}),"Lista sin orden","insertUnorderedList"),Be(t.jsx(W.HiNumberedList,{className:"h-4 w-4"}),"Lista numerada","insertOrderedList"),Be(t.jsx(W.HiLink,{className:"h-4 w-4"}),"Insertar enlace (Ctrl+K)","__link",()=>at("link")),ut(),Be(t.jsx(W.HiArrowUturnLeft,{className:"h-4 w-4"}),"Deshacer","undo"),Be(t.jsx(W.HiArrowUturnRight,{className:"h-4 w-4"}),"Rehacer","redo"),ut(),Be(t.jsx("span",{style:{fontSize:"10px"},children:"P"}),"Parrafo","__paragraph",()=>Le("p"),O.has("formatBlock:p")||O.has("formatBlock:div")),Be(t.jsx(W.HiH2,{className:"h-4 w-4"}),"Titulo 2","__h2",()=>Le("h2"),O.has("formatBlock:h2")),Be(t.jsx(W.HiH3,{className:"h-4 w-4"}),"Titulo 3","__h3",()=>Le("h3"),O.has("formatBlock:h3")),Be(t.jsx("span",{style:{fontSize:"13px",lineHeight:1},children:"“"}),"Cita","__quote",()=>Le("blockquote"),O.has("formatBlock:blockquote")),ut(),Be(t.jsx("s",{children:"S"}),"Tachado","strikeThrough"),ut(),Be(t.jsx(W.HiArrowTurnUpLeft,{className:"h-4 w-4"}),"Disminuir sangria","outdent"),Be(t.jsx(W.HiArrowTurnDownRight,{className:"h-4 w-4"}),"Aumentar sangria","indent"),ut(),Be(t.jsx(W.HiBars3BottomLeft,{className:"h-4 w-4"}),"Alinear izquierda","justifyLeft"),Be(t.jsx(W.HiBars3CenterLeft,{className:"h-4 w-4"}),"Centrar","justifyCenter"),Be(t.jsx(W.HiBars3BottomRight,{className:"h-4 w-4"}),"Alinear derecha","justifyRight"),Be(t.jsx(W.HiBars3,{className:"h-4 w-4"}),"Justificar","justifyFull"),ut(),Be(t.jsx("span",{style:{fontSize:"10px"},children:"AA"}),"Mayusculas","__upper",()=>ze("uppercase")),Be(t.jsx("span",{style:{fontSize:"10px"},children:"aa"}),"Minusculas","__lower",()=>ze("lowercase")),Be(t.jsx("span",{style:{fontSize:"10px"},children:"Aa"}),"Capitalizar","__cap",()=>ze("capitalize")),ut(),Be(t.jsx(W.HiLinkSlash,{className:"h-4 w-4"}),"Quitar enlace","unlink"),Be(t.jsx(W.HiPhoto,{className:"h-4 w-4"}),"Insertar imagen","__img",()=>at("image")),Be(t.jsx(W.HiTableCells,{className:"h-4 w-4"}),"Insertar tabla","__table",()=>at("table")),Be(t.jsx(W.HiMinus,{className:"h-4 w-4"}),"Insertar separador","__divider",ce),ut(),Be(t.jsx(W.HiOutlinePaintBrush,{className:"h-4 w-4"}),"Limpiar formato","removeFormat"),Be(t.jsx(W.HiNoSymbol,{className:"h-4 w-4"}),"Quitar bloque","__clearBlock",()=>Le("p"))]}),ut(),t.jsx("button",{type:"button",title:z?"Salir del modo de enfoque (Esc)":"Modo de enfoque",tabIndex:-1,onFocus:mt,onMouseDown:Ee=>{Ee.preventDefault(),ft(z)},className:"flex h-7 w-7 items-center justify-center rounded transition-colors",style:{color:"var(--text-secondary)"},children:z?t.jsx(W.HiArrowsPointingIn,{className:"h-4 w-4"}):t.jsx(W.HiArrowsPointingOut,{className:"h-4 w-4"})})]})};return t.jsxs(t.Fragment,{children:[Tt(),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:bt,contentEditable:!0,suppressContentEditableWarning:!0,"data-bonsaif-rich-instance":c,onInput:dt,onKeyDown:br,onKeyUp:je,onSelect:je,onMouseUp:je,onMouseMove:Qe,onMouseLeave:Je,onContextMenu:et,onMouseDown:vn,"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"}}),ar("var(--bg-input)"),Wr(!1,"var(--bg-input)")]}),t.jsxs(Xa,{open:I,onClose:()=>le(!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:ct,contentEditable:!0,suppressContentEditableWarning:!0,"data-bonsaif-rich-instance":c,onInput:dt,onKeyDown:br,onKeyUp:je,onSelect:je,onMouseUp:je,onMouseMove:Qe,onMouseLeave:Je,onContextMenu:et,onMouseDown:vn,"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"}}),ar("var(--bg-input)"),Wr(!0,"var(--bg-input)")]})]})}const cl="[a-zA-Z0-9._@-]+",bo=new RegExp(`@(${cl})`,"g"),Zu=/[a-zA-Z0-9._@-]/,cn=new Set([" ",`
|
|
26
|
-
`," ","\r"," ","(","[","{",".",",",";",":","!","?","¿","¡",")","]","}",'"',"'","«","»","/","\\","|","-","—","–"]);function
|
|
23
|
+
</body></html>`,Ce=window.open("","_blank");Ce&&(Ce.document.write(ve),Ce.document.close())}const La=()=>!He||!xn?null:gt.createPortal(t.jsxs("div",{ref:Ho,role:"menu",className:"overflow-hidden rounded-lg border p-1 shadow-xl",style:{...tm,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()=>(je?await je():Dm(),ha(!1)))()},children:[t.jsx(j.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()=>(Ye?await Ye():Om(),ha(!1)))()},children:[t.jsx(j.HiDocumentText,{className:"h-4 w-4 shrink-0 text-red-500"}),"Imprimir / PDF"]})]}),document.body),Da=()=>{const h=I&&xe.trim().length>0,$=he!=null&&he.length?he:h?[{key:"bql",label:"BQL",value:xe}]:[],Q=se.filter(P=>{const oe=P.trim();return oe?!new Set(Fe.split(`
|
|
24
|
+
`).map(Ce=>Ce.trim()).filter(Boolean)).has(oe):!1}).slice(0,8);return!le&&Bo===0&&!I&&!He?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:[Bo>0&&t.jsxs("button",{type:"button",onClick:mm,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(j.HiXMark,{className:"h-3.5 w-3.5"}),Bo," filtros"]}),I&&t.jsxs("div",{ref:Do,className:"relative flex min-w-0 flex-1 items-center gap-2",children:[t.jsxs("button",{type:"button",onClick:()=>{if(Je){Re(!1);return}ka(),Re(!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:Je?"var(--primary)":h?"color-mix(in srgb, var(--primary) 12%, transparent)":"var(--bg-card)",borderColor:Je||h?"var(--primary)":"var(--border)",color:Je?"var(--primary-fg)":"var(--primary)"},"aria-expanded":Je,title:"Abrir filtros BQL",children:[t.jsx(j.HiCommandLine,{className:"h-3.5 w-3.5"}),"BQL",h&&t.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-current"}),Je?t.jsx(j.HiChevronUp,{className:"h-3.5 w-3.5"}):t.jsx(j.HiChevronDown,{className:"h-3.5 w-3.5"})]}),t.jsx("span",{className:"hidden truncate text-xs text-[var(--text-muted)] sm:inline",children:y}),$.length>0&&t.jsxs("div",{className:"hidden min-w-0 items-center gap-1.5 overflow-hidden lg:flex",children:[$.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)),$.length>3&&t.jsxs("span",{className:"text-xs text-[var(--text-muted)]",children:["+",$.length-3]})]}),h&&t.jsx("button",{type:"button","aria-label":"Limpiar BQL",title:"Limpiar BQL",onClick:Li,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(j.HiXMark,{className:"h-4 w-4"})}),Je&>.createPortal(t.jsxs("div",{ref:vi,className:"flex flex-col gap-3 rounded-lg p-3 shadow-2xl",style:{...Qb,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:[te.map(P=>t.jsxs("button",{type:"button",onMouseDown:oe=>{oe.preventDefault(),oe.stopPropagation()},onClick:oe=>{oe.preventDefault(),oe.stopPropagation(),Na(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)),fe.length>0&&t.jsxs("button",{type:"button",onClick:()=>xt(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":or,children:[t.jsx(j.HiInformationCircle,{className:"h-3.5 w-3.5"}),"Ejemplos"]}),sr.length>0&&t.jsxs("button",{type:"button",onClick:()=>Ht(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":Kt,children:[t.jsx(j.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 ${Ae?"var(--danger)":h?"var(--primary)":"var(--border)"}`},children:[t.jsx("textarea",{ref:Oo,value:Fe,rows:3,onChange:P=>Po(P.target.value,P.target),onKeyDown:P=>{P.key==="Enter"&&!P.shiftKey&&(P.preventDefault(),Ai(Fe)),P.key==="Escape"&&Re(!1)},placeholder:T,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"}}),Q.length>0&&t.jsx("div",{className:"border-t border-[var(--border)] bg-[var(--bg-card)]",children:Q.map(P=>t.jsx("button",{type:"button",onMouseDown:oe=>{oe.preventDefault(),oe.stopPropagation()},onClick:oe=>{oe.preventDefault(),oe.stopPropagation(),Na(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:Ae?"var(--danger)":"var(--text-muted)"},children:Ae??(h?`${$.length||1} filtro${($.length||1)===1?"":"s"} activo${($.length||1)===1?"":"s"}`:"Enter aplica la consulta. Shift + Enter agrega linea.")}),$.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))]}),Kt&&sr.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(j.HiClock,{className:"h-3.5 w-3.5"}),"Historial"]}),t.jsxs("button",{type:"button",onClick:()=>{Gt([]),Ht(!1)},className:"inline-flex items-center gap-1 rounded px-2 py-0.5 text-xs text-[var(--text-muted)]",children:[t.jsx(j.HiTrash,{className:"h-3 w-3"}),"Limpiar"]})]}),sr.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:oe=>{oe.preventDefault(),oe.stopPropagation()},onClick:oe=>{oe.preventDefault(),oe.stopPropagation(),Na(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:()=>Gt(oe=>oe.filter(ve=>ve!==P)),className:"rounded p-1 text-[var(--text-muted)] opacity-0 transition-opacity group-hover:opacity-100",children:t.jsx(j.HiXMark,{className:"h-3.5 w-3.5"})})]},P))]}),or&&fe.length>0&&t.jsx("div",{className:"grid gap-2 sm:grid-cols-2 lg:grid-cols-3",children:fe.map(P=>t.jsxs("button",{type:"button",onMouseDown:oe=>{oe.preventDefault(),oe.stopPropagation()},onClick:oe=>{oe.preventDefault(),oe.stopPropagation(),Na(P.bql),xt(!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:[h&&t.jsxs("button",{type:"button",onClick:Li,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(j.HiXMark,{className:"h-3.5 w-3.5"}),"Limpiar"]}),t.jsxs("button",{type:"button",onClick:()=>Ai(Fe),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(j.HiCheck,{className:"h-3.5 w-3.5"}),"Aplicar"]})]})]}),document.body)]})]}),He&&t.jsx("button",{ref:pa,type:"button","aria-haspopup":"menu","aria-expanded":xn,"aria-label":"Exportar datos",title:"Exportar datos",onClick:()=>{var oe;const P=(oe=pa.current)==null?void 0:oe.getBoundingClientRect();P&&rm({top:P.bottom+4,right:window.innerWidth-P.right}),ha(ve=>!ve)},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)] ${xn?"bg-[var(--bg-card)] text-[var(--primary)]":""}`,children:t.jsx(j.HiArrowDownTray,{className:"h-4 w-4"})}),le&&t.jsx("button",{type:"button","aria-haspopup":"menu","aria-expanded":Ve&&ht==="visibility","aria-label":_,title:_,onClick:P=>Oi(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)] ${Ve&&ht==="visibility"?"bg-[var(--bg-card)] text-[var(--primary)]":""}`,children:t.jsx(j.HiCog6Tooth,{className:"h-4 w-4"})})]})},Yi=()=>{if(!Mm)return null;const h=Wc(it,Xo);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 ${Y?"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:Zt===0?"0 filas":`${Tm}–${$m} de ${Zt}`}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("span",{style:{color:"var(--text-muted)"},children:"Filas:"}),t.jsx(dr,{value:String(qt),onChange:$=>Am(Number($)),options:Wo.map($=>({value:String($),label:String($)})),placeholder:"Filas",searchable:!1,disabled:a,height:X,padding:K,className:"shrink-0 [&>button]:rounded-md [&>button]:text-xs [&_svg]:h-3.5 [&_svg]:w-3.5",style:{width:z}})]})]}),t.jsxs("div",{className:"flex items-center justify-center gap-0.5",children:[t.jsx("button",{disabled:a||it<=1,onClick:()=>Yo(it-1),onMouseEnter:$=>{$.currentTarget.disabled||($.currentTarget.style.background="color-mix(in srgb, var(--primary) 14%, var(--bg-card))",$.currentTarget.style.color="var(--primary)")},onMouseLeave:$=>{$.currentTarget.style.background="transparent",$.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(j.HiChevronLeft,{className:"h-3.5 w-3.5"})}),h.map(($,Q)=>$==="..."?t.jsx("span",{className:"px-1",style:{color:"var(--text-muted)"},children:"…"},`e${Q}`):t.jsx("button",{disabled:a,onClick:()=>Yo($),onMouseEnter:P=>{P.currentTarget.disabled||$===it||(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=$===it?"var(--primary)":"transparent",P.currentTarget.style.color=$===it?"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:$===it?"var(--primary)":"transparent",color:$===it?"var(--primary-fg)":"var(--text-muted)"},children:$},$)),t.jsx("button",{disabled:a||it>=Xo,onClick:()=>Yo(it+1),onMouseEnter:$=>{$.currentTarget.disabled||($.currentTarget.style.background="color-mix(in srgb, var(--primary) 14%, var(--bg-card))",$.currentTarget.style.color="var(--primary)")},onMouseLeave:$=>{$.currentTarget.style.background="transparent",$.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(j.HiChevronRight,{className:"h-3.5 w-3.5"})})]}),t.jsx("div",{"aria-hidden":"true"})]})},Hm=()=>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:Ca},children:[$a(),La(),Da(),t.jsx("div",{ref:lr,className:"min-w-0 max-w-full overflow-hidden",children:t.jsxs("div",{role:"table",className:"text-sm",style:{width:Nn,minWidth:Ma},children:[t.jsx("div",{role:"rowgroup",style:x?{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((h,$)=>t.jsxs("div",{role:"row",className:"grid",style:{gridTemplateColumns:Yr,borderBottom:`1px solid ${Pe}`},children:[It&&t.jsx("div",{role:"cell",className:`${Y?"px-2 py-1.5":"px-3 py-2"} w-10`,style:{borderBottom:`1px solid ${Pe}`,borderRight:`1px solid ${Pe}`}},"select-cell"),$t.map((Q,P)=>t.jsx("div",{role:"cell",className:Y?"px-2 py-1.5":"px-3 py-2",style:{borderBottom:`1px solid ${Pe}`,borderRight:`1px solid ${Pe}`},children:t.jsx("div",{className:"h-3.5 rounded-full animate-pulse",style:{background:"var(--border)",width:`${Ni($,P)}%`,minWidth:32}})},Q.key))]},$))})]})})]}),Go="min-w-0 max-w-full overflow-hidden";return J&&Se&&!ct?t.jsx(Cn,{rows:o,columns:Math.max(4,$t.length||7)}):!a&&r.length===0&&!Io?Hm():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:Ca},children:[$a(),La(),Da(),t.jsx("div",{ref:lr,className:Go,children:t.jsx(Zo.OverlayScrollbarsComponent,{options:{scrollbars:{autoHide:"leave",autoHideDelay:200}},className:"w-full",style:{maxHeight:Si,maxWidth:"100%"},defer:!0,children:t.jsxs("div",{role:"table",className:"text-sm",style:{width:Nn,minWidth:Ma},children:[t.jsx("div",{role:"rowgroup",style:x?{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((h,$)=>t.jsxs("div",{role:"row",className:"grid",style:{gridTemplateColumns:Yr,borderBottom:`1px solid ${Pe}`},children:[It&&t.jsx("div",{role:"cell",className:`${Y?"px-2 py-1.5":"px-3 py-2"} w-10`,style:{borderBottom:`1px solid ${Pe}`,borderRight:`1px solid ${Pe}`}},"select-cell"),$t.map((Q,P)=>{const oe=Sa[Q.key],ve=oe!==void 0,Ce=Q.key===Vo;return t.jsx("div",{role:"cell","data-dt-column-key":Q.key,className:Y?"px-2 py-1.5":"px-3 py-2",style:ve?{position:"sticky",left:oe,zIndex:1,background:"color-mix(in srgb, var(--bg-card) 72%, transparent)",backdropFilter:"blur(10px)",WebkitBackdropFilter:"blur(10px)",boxShadow:Ce?`3px 0 6px -2px rgba(0,0,0,0.10), inset 0 -1px 0 ${Pe}`:`inset 0 -1px 0 ${Pe}`,borderRight:`1px solid ${Pe}`}:{borderBottom:`1px solid ${Pe}`,borderRight:`1px solid ${Pe}`},children:t.jsx("div",{className:"h-3.5 rounded-full animate-pulse",style:{background:"var(--border)",width:`${Ni($,P)}%`,minWidth:32}})},Q.key)})]},$))})]})})}),Yi()]}):!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:Ca},children:[$a(),La(),Da(),t.jsx("div",{ref:lr,className:Go,children:t.jsx("div",{role:"table",className:"text-sm",style:{width:Nn,minWidth:Ma},children:t.jsx("div",{role:"rowgroup",style:x?{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:Pe,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(j.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:Ca},children:[$a(),La(),Da(),t.jsx("div",{ref:lr,className:Go,children:t.jsx(Zo.OverlayScrollbarsComponent,{options:{scrollbars:{autoHide:"leave",autoHideDelay:200}},className:"w-full",style:{maxHeight:Si,maxWidth:"100%"},defer:!0,children:t.jsxs("div",{role:"table",className:"text-sm",style:{width:Nn,minWidth:Ma},children:[t.jsx("div",{role:"rowgroup",style:x?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:Ta()}),t.jsx("div",{role:"rowgroup",children:Pi.map((h,$)=>{const Q=n(h),P=qi(k==null?void 0:k(h)),oe=$>0?qi(k==null?void 0:k(Pi[$-1])):null,ve=P&&P.key!==(oe==null?void 0:oe.key),Ce=It&&E.has(Q),$e=It&&(!A||A(h)),Ue=Xr?(m==null?void 0:m(h))??!0:!1,Ze=Ue&&Bi.has(Q),yt=!!d||p&&Ue,nt=Ce&&C?"color-mix(in srgb, var(--primary) 8%, var(--bg-card))":$%2===1?"color-mix(in srgb, var(--bg-input) 30%, var(--bg-card))":"var(--bg-card)";return t.jsxs(s.Fragment,{children:[ve&&t.jsx("div",{role:"row",className:`grid ${P.className??""}`,style:{gridTemplateColumns:Yr},children:t.jsx("div",{role:"cell",className:Y?"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 ${Pe}`,borderRight:`1px solid ${Pe}`},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:yt?ye=>{const Le=ye.target;if(!(Le!=null&&Le.closest('[data-dt-disable-row-click="true"]'))){if(p&&Ue){_i(Q);return}d==null||d(h)}}:void 0,className:`grid transition-colors ${yt?"cursor-pointer":""} ${H?H(h):""}`,style:{gridTemplateColumns:Yr,"--dt-row-bg":nt,"--dt-sticky-bg":nt,background:"var(--dt-row-bg)",borderBottom:`1px solid ${Pe}`},onMouseEnter:ye=>{Ce||(ye.currentTarget.style.setProperty("--dt-row-bg","var(--bg-hover)"),ye.currentTarget.style.setProperty("--dt-sticky-bg",Lm))},onMouseLeave:ye=>{ye.currentTarget.style.setProperty("--dt-row-bg",nt),ye.currentTarget.style.setProperty("--dt-sticky-bg",nt)},children:[Xr&&t.jsx("div",{role:"cell",className:`${Y?"px-2 py-1.5":"px-3 py-2"} flex w-10 items-center justify-center`,style:{borderBottom:`1px solid ${Pe}`,borderRight:`1px solid ${Pe}`},"data-dt-disable-row-click":"true",children:Ue&&t.jsx("button",{type:"button","aria-label":Ze?"Contraer fila":"Desplegar fila","aria-expanded":Ze,onClick:ye=>{ye.stopPropagation(),_i(Q)},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:Ze?t.jsx(j.HiChevronDown,{className:"h-4 w-4"}):t.jsx(j.HiChevronRight,{className:"h-4 w-4"})})}),It&&t.jsx("div",{role:"cell",className:`${Y?"px-2 py-1.5":"px-3 py-2"} flex w-10 items-center justify-center`,style:qo?{position:"sticky",left:0,zIndex:3,background:"var(--dt-sticky-bg)",boxShadow:`inset 0 -1px 0 ${Pe}`}:{borderBottom:`1px solid ${Pe}`,borderRight:`1px solid ${Pe}`},onClick:ye=>{ye.stopPropagation(),$e&&v(Q)},children:t.jsx(Mn,{size:"sm",checked:Ce,disabled:!$e,"aria-label":$e?"Seleccionar fila":"Fila no seleccionable",containerClassName:"items-center",className:$e?"cursor-pointer":"cursor-not-allowed opacity-50",onClick:ye=>ye.stopPropagation(),onChange:()=>{$e&&v(Q)}})}),$t.map(ye=>{const Le=Sa[ye.key],ke=Le!==void 0,we=ye.key===Vo,Ne=ur(ye);return t.jsx("div",{role:"cell","data-dt-column-key":ye.key,"data-dt-disable-row-click":ye.disableRowClick||Ne?"true":void 0,className:`${Ne?"px-2 py-1.5 justify-center text-center":`${Y?"px-2 py-1.5":"px-3 py-2"} ${zi(ye.align)}`} flex min-w-0 items-center ${Ic} ${ye.className??""}`,style:{overflow:"hidden",whiteSpace:"nowrap",...ke?{position:"sticky",left:Le,zIndex:3,background:"var(--dt-sticky-bg)",boxShadow:we?`3px 0 6px -2px rgba(0,0,0,0.10), inset 0 -1px 0 ${Pe}`:`inset 0 -1px 0 ${Pe}`,borderRight:`1px solid ${Pe}`}:{borderBottom:`1px solid ${Pe}`,borderRight:`1px solid ${Pe}`}},children:t.jsx(hs,{children:t.jsx("div",{"data-dt-autofit-content":!0,className:"inline-block max-w-none align-middle",children:ye.cell(h)})})},ye.key)})]}),Ze&&u&&t.jsx("div",{role:"row",className:"grid",style:{gridTemplateColumns:Yr},children:t.jsx("div",{role:"cell",className:Y?"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 ${Pe}`},children:u(h)})})]},Q)})})]})})}),Yi()]})}const Uc={sm:"min-h-[160px] p-4",md:"min-h-[220px] p-6",lg:"min-h-[300px] p-8"};function Hn({title:e="Sin resultados",description:r,icon:n=t.jsx(j.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 ${Uc[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]})]})})}function Ft(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 ps(e){if(!e)return null;const r=String(e).slice(0,10),[n,a,o]=r.split("-").map(Number);return!n||!a||!o?null:new Date(n,a-1,o)}function nn(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate())}function Er(e,r){const n=new Date(e);return n.setDate(n.getDate()+r),n}function gs(e){const r=nn(e),n=(r.getDay()+6)%7;return Er(r,-n)}function vs(e){const r=gs(e);return Array.from({length:7},(n,a)=>Er(r,a))}function xs(e){const r=new Date(e.getFullYear(),e.getMonth(),1),n=gs(r);return Array.from({length:42},(a,o)=>Er(n,o))}function ys(e){const r=[];for(let n=0;n<e.length;n+=7)r.push(e.slice(n,n+7));return r}function Vc(e,r,n,a){return e.getTime()<=a.getTime()&&r.getTime()>=n.getTime()}function er(e,r){const n=r?r(e):{start:e.startDate,end:e.endDate},a=ps(n.start);if(!a)return null;const o=ps(n.end??n.start)??a;return o.getTime()<a.getTime()?{start:o,end:a}:{start:a,end:o}}function ws(e,r){const n={};for(const a of e){const o=er(a,r);if(!o)continue;let l=nn(o.start);const i=nn(o.end);for(;l.getTime()<=i.getTime();){const c=Ft(l);n[c]||(n[c]=[]),n[c].push(a),l=Er(l,1)}}return n}function Ua(e,r,n){if(r.length===0)return[];const a=nn(r[0]),o=nn(r[r.length-1]),l=[],i=[],c=[...e].sort((d,u)=>{const m=er(d,n),b=er(u,n),f=(m==null?void 0:m.start.getTime())??0,g=(b==null?void 0:b.start.getTime())??0;return f-g||d.title.localeCompare(u.title)});for(const d of c){const u=er(d,n);if(!u||!Vc(u.start,u.end,a,o))continue;const m=u.start.getTime()<a.getTime()?a:u.start,b=u.end.getTime()>o.getTime()?o:u.end,f=Math.max(0,Math.round((m.getTime()-a.getTime())/864e5)),g=Math.min(r.length-1,Math.round((b.getTime()-a.getTime())/864e5)),p=Math.max(1,g-f+1);let E=l.findIndex(v=>v<f);E<0?(E=l.length,l.push(f+p-1)):l[E]=f+p-1,i.push({item:d,lane:E,colStart:f,colSpan:p})}return i}function Lt(e){return new Intl.DateTimeFormat("es-MX",{day:"2-digit",month:"short",year:"numeric"}).format(e)}function Xc(e){const r=new Intl.DateTimeFormat("es-MX",{month:"long",year:"numeric"}).format(e);return r.charAt(0).toUpperCase()+r.slice(1)}function Yc(e){const r=new Intl.DateTimeFormat("es-MX",{weekday:"short",day:"2-digit",month:"short",year:"numeric"}).format(e);return r.charAt(0).toUpperCase()+r.slice(1)}function Ns(e){const r=new Intl.DateTimeFormat("es-MX",{weekday:"short",day:"2-digit",month:"short"}).format(e);return r.charAt(0).toUpperCase()+r.slice(1)}function ks(e,r,n){return r==="month"?new Date(e.getFullYear(),e.getMonth()+n,1):r==="week"?Er(e,n*7):Er(e,n)}const Kc=["Lun","Mar","Mié","Jue","Vie","Sáb","Dom"];function Gc({item:e,style:r,onClick:n}){const a=e.color??"var(--text-muted)",o=e.bg??"rgba(100, 116, 139, 0.14)",l=er(e),i=l?`${Lt(l.start)} → ${Lt(l.end)}`:"",c=[e.title,e.subtitle,i,e.status].filter(Boolean).join(" · ");return t.jsx(Bt,{content:c||e.title,children:t.jsxs("button",{type:"button",className:"absolute overflow-hidden rounded-md px-1.5 py-0.5 text-left text-[11px] leading-tight transition-opacity hover:opacity-90",style:{...r,background:o,borderLeft:`3px solid ${a}`,boxShadow:"inset 0 0 0 1px var(--border)",color:"var(--text-main)"},onClick:d=>{d.stopPropagation(),n==null||n()},children:[t.jsx("span",{className:"block truncate font-semibold",children:e.title}),e.status?t.jsx("span",{className:"block truncate",style:{color:a},children:e.status}):null]})})}function Zc({item:e,onClick:r}){const n=e.color??"var(--text-muted)",a=e.bg??"rgba(100, 116, 139, 0.10)",o=er(e),l=o?`${Lt(o.start)} → ${Lt(o.end)}`:"";return t.jsxs("button",{type:"button",className:"flex w-full flex-col gap-2 rounded-lg p-4 text-left transition-opacity hover:opacity-95 sm:flex-row sm:items-start sm:justify-between",style:{background:a,border:"1px solid var(--border)",boxShadow:`inset 3px 0 0 ${n}`,color:"var(--text-main)"},onClick:()=>r==null?void 0:r(),children:[t.jsxs("div",{className:"min-w-0 flex-1 space-y-1",children:[t.jsx("div",{className:"text-base font-semibold",children:e.title}),e.subtitle?t.jsx("div",{className:"text-sm leading-5",style:{color:"var(--text-muted)"},children:e.subtitle}):null]}),t.jsxs("div",{className:"flex shrink-0 flex-col gap-2 sm:items-end",children:[e.status?t.jsx("span",{className:"inline-flex rounded-full px-2.5 py-0.5 text-xs font-semibold",style:{color:n,background:"color-mix(in srgb, var(--bg-card) 70%, transparent)",border:`1px solid color-mix(in srgb, ${n} 45%, transparent)`},children:e.status}):null,l?t.jsxs("div",{className:"text-xs",style:{color:"var(--text-secondary)"},children:[t.jsx("span",{className:"font-semibold uppercase tracking-wide opacity-70",children:"Rango"}),t.jsx("div",{children:l})]}):null]})]})}function Qc({item:e,style:r,onClick:n}){const a=e.color??"var(--text-muted)",o=e.bg??"rgba(100, 116, 139, 0.14)",l=er(e),i=l?`${Lt(l.start)} → ${Lt(l.end)}`:"";return t.jsxs("button",{type:"button",className:"absolute mx-1 overflow-hidden rounded-md px-2 py-1.5 text-left text-xs transition-opacity hover:opacity-90",style:{...r,background:o,borderLeft:`3px solid ${a}`,boxShadow:"inset 0 0 0 1px var(--border)",color:"var(--text-main)"},title:[e.title,i,e.status].filter(Boolean).join(" · "),onClick:()=>n==null?void 0:n(),children:[t.jsx("span",{className:"block truncate font-semibold",children:e.title}),t.jsx("span",{className:"block truncate",style:{color:a},children:[e.status,i].filter(Boolean).join(" · ")})]})}function Ss({item:e,day:r,renderPill:n,onClick:a}){if(n)return t.jsx("div",{className:"min-w-0",children:n(e,{day:r})});const o=e.color??"var(--text-muted)",l=e.bg??"rgba(100, 116, 139, 0.14)";return t.jsxs("button",{type:"button",className:"block w-full overflow-hidden rounded-md px-1.5 py-0.5 text-left text-[11px] leading-tight",style:{background:l,borderLeft:`3px solid ${o}`,color:"var(--text-main)"},onClick:i=>{i.stopPropagation(),a==null||a()},children:[t.jsx("span",{className:"block truncate font-semibold",children:e.title}),e.status?t.jsx("span",{className:"block truncate",style:{color:o},children:e.status}):null]})}function Es({value:e,options:r,onChange:n}){return t.jsx("div",{className:"inline-flex overflow-hidden rounded-lg",style:{border:"1px solid var(--border)"},children:r.map((a,o)=>{const l=e===a.value;return t.jsxs("button",{type:"button",onClick:()=>n(a.value),className:"inline-flex items-center gap-1.5 px-3 py-2 text-xs font-semibold transition-colors",style:{background:l?"var(--primary)":"var(--bg-card)",color:l?"var(--primary-fg, #fff)":"var(--text-secondary)",borderRight:o<r.length-1?"1px solid var(--border)":void 0},children:[a.icon,a.label]},a.value)})})}function Jc({items:e,cursorDate:r,onCursorDateChange:n,displayMode:a,onDisplayModeChange:o,viewMode:l,onViewModeChange:i,getItemDates:c,maxPillsPerDay:d=3,overloadThreshold:u=5,weekdayLabels:m=[...Kc],renderToolbarExtra:b,renderPill:f,renderDayCard:g,renderWeekBar:p,tableColumns:E,tableProps:v,onItemClick:w,onDayClick:A,loading:C=!1,emptyTitle:H="Sin eventos",emptyDescription:k="No hay eventos para los filtros seleccionados.",legend:x,legendInteractive:M=!0,activeLegendKeys:N,defaultActiveLegendKeys:z,onActiveLegendKeysChange:X,getItemLegendKey:K,overloadLabel:D="Sobrecarga de eventos",notice:G,showOverload:V=!0,layout:ne="span",className:J="",showToolbar:R=!0}){const U=s.useMemo(()=>(x??[]).map(ue=>ue.label),[x]),[Y,ce]=s.useState(()=>z??U),L=s.useMemo(()=>N??(U.length>0?Y:[]),[N,U.length,Y]),B=s.useMemo(()=>new Set(L),[L]),le=ue=>{N===void 0&&ce(ue),X==null||X(ue)},O=ue=>{M&&(B.has(ue)?le(L.filter(Te=>Te!==ue)):le([...L,ue]))},ae=s.useMemo(()=>{if(!M||U.length===0)return e;const ue=new Set(U);return e.filter(Te=>{const He=(K==null?void 0:K(Te))??Te.status;return!He||!ue.has(He)?!0:B.has(He)})},[e,M,U,B,K]),S=s.useMemo(()=>ws(ae,c),[ae,c]),ee=s.useMemo(()=>xs(r),[r]),_=s.useMemo(()=>ys(ee),[ee]),I=s.useMemo(()=>vs(r),[r]),de=Ft(r),re=S[de]??[],F=s.useMemo(()=>Ua(ae,I,c),[ae,I,c]),y=s.useMemo(()=>F.length===0?1:Math.max(...F.map(ue=>ue.lane))+1,[F]),T=s.useMemo(()=>_.map(ue=>{const Te=Ua(ae,ue,c),He=Te.length===0?0:Math.max(...Te.map(Xe=>Xe.lane))+1;return{days:ue,bars:Te,laneCount:He}}),[_,ae,c]),te=36,fe=38,se=s.useMemo(()=>{const ue=l==="month"?ee:l==="week"?I:[r],Te=[];for(const He of ue){const Xe=Ft(He),je=S[Xe]??[];je.length>=u&&Te.push([He,je])}return Te},[l,ee,I,r,S,u]),he=l==="month"?Xc(r):l==="week"?`${Lt(I[0])} – ${Lt(I[6])}`:Yc(r),Ae=s.useMemo(()=>[{key:"title",header:"Título",cell:ue=>ue.title},{key:"status",header:"Estado",cell:ue=>ue.status??"—"},{key:"range",header:"Rango",cell:ue=>{const Te=er(ue,c);return Te?`${Lt(Te.start)} → ${Lt(Te.end)}`:"—"}},{key:"subtitle",header:"Detalle",cell:ue=>ue.subtitle??"—"}],[c]),De=ue=>{if(n(ue),A){A(ue);return}i("day")};return t.jsxs("div",{className:`bonsaif-event-calendar space-y-4 ${J}`.trim(),children:[R?t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("button",{type:"button","aria-label":"Anterior",className:"inline-flex h-9 w-9 items-center justify-center rounded-lg",style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-main)"},onClick:()=>n(ks(r,l,-1)),children:t.jsx(j.HiChevronLeft,{className:"h-4 w-4"})}),t.jsx("div",{className:"min-w-[160px] text-center text-sm font-semibold capitalize",style:{color:"var(--text-main)"},children:he}),t.jsx("button",{type:"button","aria-label":"Siguiente",className:"inline-flex h-9 w-9 items-center justify-center rounded-lg",style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-main)"},onClick:()=>n(ks(r,l,1)),children:t.jsx(j.HiChevronRight,{className:"h-4 w-4"})}),t.jsx("button",{type:"button",className:"rounded-lg px-3 py-2 text-xs font-semibold",style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-secondary)"},onClick:()=>n(new Date),children:"Hoy"})]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[b,t.jsx(Es,{value:a,onChange:o,options:[{value:"calendar",label:"Calendario",icon:t.jsx(j.HiCalendarDays,{className:"h-4 w-4"})},{value:"table",label:"Tabla",icon:t.jsx(j.HiTableCells,{className:"h-4 w-4"})}]}),a==="calendar"?t.jsx(Es,{value:l,onChange:i,options:[{value:"month",label:"Mes"},{value:"week",label:"Semana"},{value:"day",label:"Día"}]}):null]})]}):null,x&&x.length>0?t.jsx("div",{className:"flex flex-wrap items-center gap-2 text-xs",role:M?"group":void 0,"aria-label":M?"Filtrar por estado":void 0,children:x.map(ue=>{const Te=B.has(ue.label);return M?t.jsxs("button",{type:"button","aria-pressed":Te,onClick:()=>O(ue.label),className:"inline-flex items-center gap-1.5 rounded-full px-2.5 py-1 transition-opacity",style:{color:Te?"var(--text-main)":"var(--text-muted)",background:Te?"color-mix(in srgb, var(--bg-card) 80%, transparent)":"transparent",border:Te?`1px solid color-mix(in srgb, ${ue.color} 55%, var(--border))`:"1px solid var(--border)",opacity:Te?1:.45},title:Te?`Ocultar “${ue.label}”`:`Mostrar “${ue.label}”`,children:[t.jsx("span",{className:"inline-block h-2.5 w-2.5 rounded-full",style:{background:ue.color,boxShadow:Te?`0 0 0 2px color-mix(in srgb, ${ue.color} 25%, transparent)`:void 0},"aria-hidden":!0}),ue.label]},ue.label):t.jsxs("span",{className:"inline-flex items-center gap-1.5",style:{color:"var(--text-secondary)"},children:[t.jsx("span",{className:"inline-block h-2.5 w-2.5 rounded-full",style:{background:ue.color},"aria-hidden":!0}),ue.label]},ue.label)})}):null,a==="calendar"&&G&&G.items.length>0?t.jsxs("div",{className:"rounded-lg px-4 py-3 text-sm",style:G.tone==="danger"?{background:"rgba(220, 38, 38, 0.12)",border:"1px solid rgba(220, 38, 38, 0.35)",color:"#dc2626"}:{background:"rgba(217, 119, 6, 0.14)",border:"1px solid rgba(217, 119, 6, 0.35)",color:"#b45309"},children:[t.jsxs("strong",{children:[G.label,":"]})," ",G.items.join(", ")]}):a==="calendar"&&V&&se.length>0?t.jsxs("div",{className:"rounded-lg px-4 py-3 text-sm",style:{background:"rgba(217, 119, 6, 0.14)",border:"1px solid rgba(217, 119, 6, 0.35)",color:"#b45309"},children:[t.jsxs("strong",{children:[D,":"]})," ",se.map(([ue,Te])=>`${Lt(ue)} (${Te.length})`).join(", ")]}):null,a==="table"?C||ae.length>0?t.jsx(qa,{columns:E??Ae,data:ae,getRowId:ue=>ue.id,loading:C,skeletonRows:8,emptyIcon:t.jsx(j.HiCalendarDays,{className:"h-10 w-10"}),emptyText:k,onRowClick:w,pageSize:25,compact:!0,...v}):t.jsx(Hn,{icon:t.jsx(j.HiCalendarDays,{className:"h-5 w-5"}),title:H,description:k}):null,a==="calendar"&&l==="month"&&ne==="daily"?t.jsxs("div",{className:"overflow-hidden rounded-lg",style:{border:"1px solid var(--border)"},children:[t.jsx("div",{className:"grid grid-cols-7",style:{borderBottom:"1px solid var(--border)"},children:m.map(ue=>t.jsx("div",{className:"px-3 py-2 text-xs font-bold uppercase",style:{background:"var(--bg-card)",color:"var(--text-muted)"},children:ue},ue))}),t.jsx("div",{className:"grid grid-cols-7",children:ee.map(ue=>{const Te=Ft(ue),He=S[Te]??[],Xe=ue.getMonth()!==r.getMonth(),je=Math.max(0,He.length-d);return t.jsxs("div",{role:"button",tabIndex:0,"aria-label":`${ue.getDate()}`,onClick:()=>De(ue),onKeyDown:Ye=>{(Ye.key==="Enter"||Ye.key===" ")&&(Ye.preventDefault(),De(ue))},className:"flex min-h-[108px] cursor-pointer flex-col gap-1 p-2 text-left transition-colors hover:bg-black/[0.03] dark:hover:bg-white/[0.04]",style:{background:"var(--bg-main)",borderRight:"1px solid var(--border)",borderBottom:"1px solid var(--border)"},children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsx("span",{className:"text-sm font-semibold",style:{color:Xe?"var(--text-muted)":"var(--text-main)"},children:ue.getDate()}),He.length>0?t.jsx("span",{className:"rounded-full px-2 py-0.5 text-[11px] font-bold",style:{background:"var(--primary)",color:"var(--primary-fg, #fff)"},children:He.length}):null]}),t.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[He.slice(0,d).map(Ye=>t.jsx(Ss,{item:Ye,day:ue,renderPill:f,onClick:()=>w==null?void 0:w(Ye)},Ye.id)),je>0?t.jsxs("span",{className:"text-[11px] font-semibold",style:{color:"var(--text-muted)"},children:["+",je," más"]}):null]})]},Te)})})]}):null,a==="calendar"&&l==="month"&&ne==="span"?t.jsxs("div",{className:"overflow-hidden rounded-lg",style:{border:"1px solid var(--border)"},children:[t.jsx("div",{className:"grid grid-cols-7",style:{borderBottom:"1px solid var(--border)"},children:m.map(ue=>t.jsx("div",{className:"px-3 py-2 text-xs font-bold uppercase",style:{background:"var(--bg-card)",color:"var(--text-muted)"},children:ue},ue))}),T.map(({days:ue,bars:Te,laneCount:He},Xe)=>{const je=Math.min(He,d),Ye=Math.max(0,He-d),ie=te+Math.max(1,je)*fe+(Ye>0?20:8)+8;return t.jsxs("div",{className:"relative",style:{minHeight:ie,borderBottom:Xe<T.length-1?"1px solid var(--border)":void 0},children:[t.jsx("div",{className:"grid grid-cols-7",style:{minHeight:ie},children:ue.map(Se=>{const _e=Ft(Se),ot=S[_e]??[],Ke=Se.getMonth()!==r.getMonth();return t.jsx("div",{role:"button",tabIndex:0,"aria-label":`${Se.getDate()}`,onClick:()=>De(Se),onKeyDown:lt=>{(lt.key==="Enter"||lt.key===" ")&&(lt.preventDefault(),De(Se))},className:"cursor-pointer p-2 text-left transition-colors hover:bg-black/[0.03] dark:hover:bg-white/[0.04]",style:{background:"var(--bg-main)",borderRight:"1px solid var(--border)",minHeight:ie},children:t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsx("span",{className:"text-sm font-semibold",style:{color:Ke?"var(--text-muted)":"var(--text-main)"},children:Se.getDate()}),ot.length>0?t.jsx("span",{className:"rounded-full px-2 py-0.5 text-[11px] font-bold",style:{background:"var(--primary)",color:"var(--primary-fg, #fff)"},children:ot.length}):null]})},_e)})}),t.jsxs("div",{className:"pointer-events-none absolute inset-x-0",style:{top:te,bottom:4},children:[Te.filter(Se=>Se.lane<d).map(Se=>{const _e={left:`calc(${Se.colStart/7*100}% + 4px)`,width:`calc(${Se.colSpan/7*100}% - 8px)`,top:2+Se.lane*fe,height:fe-6,pointerEvents:"auto"};return f?t.jsx("div",{className:"absolute overflow-hidden",style:_e,children:t.jsx("div",{className:"h-full min-h-0 w-full overflow-hidden",children:f(Se.item,{day:ue[Se.colStart]})})},`${Se.item.id}-${Se.colStart}-${Xe}`):p?t.jsx("div",{className:"absolute overflow-hidden",style:_e,children:t.jsx("div",{className:"h-full min-h-0 w-full overflow-hidden",children:p(Se.item)})},`${Se.item.id}-${Se.colStart}-${Xe}`):t.jsx(Gc,{item:Se.item,style:_e,onClick:()=>w==null?void 0:w(Se.item)},`${Se.item.id}-${Se.colStart}-${Xe}`)}),Ye>0?t.jsxs("span",{className:"absolute text-[11px] font-semibold",style:{left:8,top:2+je*fe,color:"var(--text-muted)"},children:["+",Ye," más"]}):null]})]},`week-${Xe}-${Ft(ue[0])}`)})]}):null,a==="calendar"&&l==="week"&&ne==="daily"?t.jsx("div",{className:"overflow-hidden rounded-lg",style:{background:"var(--bg-card)",border:"1px solid var(--border)"},children:t.jsx("div",{className:"grid grid-cols-7",children:I.map(ue=>{const Te=Ft(ue),He=S[Te]??[],Xe=Math.max(0,He.length-d);return t.jsxs("div",{className:"min-h-[180px] p-2",style:{borderRight:"1px solid var(--border)"},children:[t.jsxs("button",{type:"button",className:"mb-2 w-full text-center text-xs font-semibold capitalize",style:{color:"var(--text-main)"},onClick:()=>De(ue),children:[Ns(ue),t.jsx("span",{className:"mt-1 block text-sm",children:ue.getDate()})]}),t.jsxs("div",{className:"flex flex-col gap-1",children:[He.slice(0,d).map(je=>t.jsx(Ss,{item:je,day:ue,renderPill:f,onClick:()=>w==null?void 0:w(je)},je.id)),Xe>0?t.jsxs("span",{className:"text-[11px] font-semibold",style:{color:"var(--text-muted)"},children:["+",Xe," más"]}):null]})]},Te)})})}):null,a==="calendar"&&l==="week"&&ne==="span"?t.jsxs("div",{className:"overflow-hidden rounded-lg",style:{background:"var(--bg-card)",border:"1px solid var(--border)"},children:[t.jsx("div",{className:"grid grid-cols-7 border-b",style:{borderColor:"var(--border)"},children:I.map(ue=>t.jsx("button",{type:"button",className:"px-3 py-2 text-center text-xs font-semibold capitalize",style:{color:"var(--text-main)",borderRight:"1px solid var(--border)"},onClick:()=>De(ue),children:Ns(ue)},Ft(ue)))}),t.jsxs("div",{className:"relative grid grid-cols-7",style:{minHeight:Math.max(220,y*56+24)},children:[I.map(ue=>t.jsx("div",{className:"min-h-full",style:{borderRight:"1px solid var(--border)"}},`lane-${Ft(ue)}`)),F.map(ue=>{const Te={left:`calc(${ue.colStart/7*100}% + 4px)`,width:`calc(${ue.colSpan/7*100}% - 8px)`,top:12+ue.lane*56,height:48};return p?t.jsx("div",{className:"absolute overflow-hidden",style:Te,children:t.jsx("div",{className:"h-full min-h-0 w-full overflow-hidden",children:p(ue.item)})},`${ue.item.id}-${ue.colStart}`):t.jsx(Qc,{item:ue.item,style:Te,onClick:()=>w==null?void 0:w(ue.item)},`${ue.item.id}-${ue.colStart}`)}),F.length===0&&!C?t.jsx("div",{className:"absolute inset-0 flex items-center justify-center text-sm",style:{color:"var(--text-muted)"},children:k}):null]})]}):null,a==="calendar"&&l==="day"?re.length>0||C?t.jsxs("div",{className:"space-y-3",children:[C&&re.length===0?t.jsx(Hn,{icon:t.jsx(j.HiCalendarDays,{className:"h-5 w-5"}),title:"Cargando…",description:"Obteniendo eventos del día."}):null,re.map(ue=>g?t.jsx("div",{children:g(ue)},ue.id):t.jsx(Zc,{item:ue,onClick:()=>w==null?void 0:w(ue)},ue.id))]}):t.jsx(Hn,{icon:t.jsx(j.HiCalendarDays,{className:"h-5 w-5"}),title:H,description:k}):null]})}function Cs(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 Rc(e){var r;if((r=navigator.clipboard)!=null&&r.writeText){await navigator.clipboard.writeText(e);return}Cs(e)}function ed(e){return typeof e=="function"?e():e}function Va({value:e,resetDelay:r=2e3,title:n,copiedTitle:a="Copiado",copiedLabel:o,icon:l=t.jsx(j.HiClipboardDocument,{size:14}),copiedIcon:i=t.jsx(j.HiCheck,{size:14}),stopPropagation:c=!0,onCopied:d,onCopyError:u,className:m="",style:b,children:f,onClick:g,type:p="button",...E}){const[v,w]=s.useState(!1),A=s.useRef(null);s.useEffect(()=>()=>{A.current&&window.clearTimeout(A.current)},[]);function C(k){w(!0),d==null||d(k),A.current&&window.clearTimeout(A.current),A.current=window.setTimeout(()=>{w(!1),A.current=null},r)}async function H(k){var M;if(c&&k.stopPropagation(),g==null||g(k),k.defaultPrevented)return;const x=ed(e);if(x)try{await Rc(x),C(x)}catch(N){try{Cs(x),C(x)}catch(z){u==null||u(z,x);return}(M=navigator.clipboard)!=null&&M.writeText||u==null||u(N,x)}}return t.jsxs("button",{...E,type:p,onClick:H,title:v?a:n,"aria-label":E["aria-label"]??(v?a:n),"data-copied":v?"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:v?"rgba(22,163,74,0.15)":"var(--bg-card)",border:v?"1px solid rgba(22,163,74,0.4)":"1px solid var(--border)",color:v?"#16a34a":"var(--text-secondary)",boxShadow:v?"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:v?"scale(1.15)":"scale(1)"},children:v?i:l}),f&&t.jsx("span",{className:"text-xs font-semibold leading-none",children:v?o??f:f})]})}function td({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(Va,{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 In(e){if(e!==void 0)return typeof e=="number"?`${e}px`:e}function rd({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(j.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:In(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:In(o),padding:In(l)}})]})}function nd({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((b,f)=>f===0&&!b.color?{...b,sublabel:b.sublabel??void 0}:b):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:In(d)},children:o}),t.jsx(dr,{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 ad={sm:"24rem",md:"28rem",lg:"32rem",xl:"40rem","2xl":"48rem","4xl":"56rem","5xl":"64rem"},Bn=180,od="bg-[color-mix(in_srgb,var(--bg-main)_72%,transparent)] backdrop-blur-sm";function Xa({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:b=!0,closeOnEscape:f=!0,showCloseButton:g=!0,placement:p="center",bodyClassName:E="px-6 py-5",panelClassName:v="",backdropClassName:w=od,contentClassName:A="p-4",ariaLabel:C,frameless:H=!1,disabled:k=!1}){const[x,M]=s.useState(!1),[N,z]=s.useState(!1),X=s.useRef(null);if(s.useEffect(()=>(e?(X.current&&clearTimeout(X.current),M(!0),requestAnimationFrame(()=>requestAnimationFrame(()=>z(!0)))):(z(!1),X.current=setTimeout(()=>M(!1),Bn+40)),()=>{X.current&&clearTimeout(X.current)}),[e]),s.useEffect(()=>{if(e)return document.body.style.overflow="hidden",()=>{document.body.style.overflow=""}},[e]),s.useEffect(()=>{if(!e||!f)return;const J=R=>{R.key==="Escape"&&r()};return window.addEventListener("keydown",J),()=>window.removeEventListener("keydown",J)},[f,r,e]),!x)return null;const K=n||a||o||l||g,D=u??ad[d],G=p==="bottom-mobile"?"items-end sm:items-center justify-center p-0 sm:p-4":"items-center justify-center",V=p==="bottom-mobile"?"rounded-t-2xl sm:rounded-2xl":"rounded-2xl",ne=N?"translateY(0) scale(1)":p==="bottom-mobile"?"translateY(16px) scale(0.98)":"translateY(10px) scale(0.96)";return gt.createPortal(t.jsxs("div",{role:"dialog","aria-modal":"true","data-bonsaif-overlay":"true","aria-label":C??n,className:`fixed inset-0 flex ${G} ${A}`,style:{zIndex:m},children:[t.jsx("div",{className:`absolute inset-0 ${w}`,onClick:b?r:void 0,style:{opacity:N?1:0,transition:`opacity ${Bn}ms ease`}}),t.jsxs("div",{className:`relative z-10 flex max-h-[92dvh] w-full flex-col overflow-hidden ${H?"shadow-none":"shadow-2xl"} ${V} ${v}`,style:{maxWidth:D,background:H?"transparent":"var(--bg-card)",border:H?"none":"1px solid var(--border)",opacity:N?1:0,transform:ne,transition:`opacity ${Bn}ms ease, transform ${Bn}ms ease`},onClick:J=>J.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)"}}),K&&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,g&&t.jsx(Qe,{variant:"icon",onClick:r,title:"Cerrar",children:t.jsx(j.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 sd={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 ld({open:e,title:r,description:n,confirmLabel:a="Confirmar",cancelLabel:o="Cancelar",variant:l="danger",closeOnBackdrop:i=!0,onConfirm:c,onCancel:d}){const u=sd[l];return t.jsx(Xa,{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(Qe,{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(j.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(j.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(Qe,{variant:"secondary",onClick:d,className:"w-full sm:w-auto sm:min-w-[7.5rem]",style:{background:"var(--bg-input)"},children:o}),t.jsx(Qe,{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 id(e){return e?typeof e=="function"?e():e:""}function cd(e){return/^https?:\/\//i.test(e)}function Ms(e,r){try{return new URL(e,r).toString()}catch{return e}}function dd(e,r,n,a=!1){const o=typeof e=="function"?e():e,l=r?r(o):o;if(!l||cd(l))return l;const i=id(n);return i?Ms(l,i):a&&typeof window<"u"?Ms(l,window.location.origin):l}function ud({url:e,resolveUrl:r,baseUrl:n,useWindowOriginForRelative:a=!1,title:o="Copiar link",copiedTitle:l="Link copiado",icon:i=t.jsx(j.HiLink,{className:"h-3.5 w-3.5"}),...c}){return t.jsx(Va,{...c,value:()=>dd(e,r,n,a),title:o,copiedTitle:l,icon:i})}const fd={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 bd(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=fd[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 md=new Set(["Backspace","Delete","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Tab","Home","End","Enter","Escape"]);function hd({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,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:()=>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&&!md.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 pd({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(dr,{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 gd={outline:"2px solid var(--primary)",outlineOffset:"-2px",borderRadius:"4px",background:"color-mix(in srgb, var(--primary) 5%, var(--bg-card))"},Ya={outline:"2px solid var(--primary)",outlineOffset:"-2px",borderRadius:"4px"};function vd({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[b,f]=s.useState(null),g=s.useRef(null);g.current=b;const[p,E]=s.useState({}),[v,w]=s.useState(null),A=s.useRef(null);A.current=v;const[C,H]=s.useState({}),[k,x]=s.useState({}),M=s.useRef(new Set),N=s.useRef(null);s.useEffect(()=>{var B;const L=document.activeElement;(!L||L===document.body)&&((B=N.current)==null||B.focus({preventScroll:!0}))},[]);const z=e.map(L=>{var B,le,O;return`${L.key}:${((O=(le=(B=L.editable)==null?void 0:B.select)==null?void 0:le.options)==null?void 0:O.length)??-1}`}).join("|");s.useEffect(()=>{e.forEach(L=>{var O,ae;const B=(ae=(O=L.editable)==null?void 0:O.select)==null?void 0:ae.options;if(!B)return;const le=C[L.key];(!M.current.has(L.key)||(le==null?void 0:le.length)===0&&B.length>0)&&(M.current.add(L.key),H(S=>({...S,[L.key]:B})))})},[z]);const X=s.useCallback(async(L,B)=>{if(M.current.has(L))return;M.current.add(L);const{url:le,fetchOptions:O}=B.select??{};if(!(!le&&!O)){x(ae=>({...ae,[L]:!0}));try{let ae=[];if(O)ae=await O();else if(le){const S=await fetch(le);if(!S.ok)throw new Error("fetch failed");ae=await S.json()}H(S=>({...S,[L]:ae}))}catch{H(ae=>({...ae,[L]:[]}))}finally{x(ae=>({...ae,[L]:!1}))}}},[]),K=s.useRef(i);K.current=i;const D=s.useRef(a);D.current=a;const G=s.useRef(n);G.current=n;const V=s.useRef(e);V.current=e;const ne=s.useRef(o);ne.current=o,s.useEffect(()=>{if(e.length>0&&r.length>0){const L=e.find(B=>B.selectable!==!1);L&&f({rowId:n(r[0]),colKey:L.key})}},[]),s.useEffect(()=>{if(!b)return;const L=N.current;if(!L)return;const B=L.querySelector(`[data-cell-id="${b.rowId}:${b.colKey}"]`);if(!B)return;const le=L.querySelector('[role="rowgroup"]');B.style.scrollMarginTop=`${(le==null?void 0:le.offsetHeight)??0}px`;const O=L.querySelector('[role="row"]');let ae=0;O&&O.querySelectorAll('[role="cell"], [role="columnheader"]').forEach(S=>{S.style.position==="sticky"&&S.style.left!==""&&(ae=Math.max(ae,parseFloat(S.style.left)+S.offsetWidth))}),B.style.scrollMarginLeft=`${ae}px`,B.scrollIntoView({block:"nearest",inline:"nearest"})},[b]);const J=s.useCallback(L=>{var ae;const B=V.current,le=new Set,O=[];(ae=N.current)==null||ae.querySelectorAll("[data-cell-id]").forEach(S=>{const ee=S.dataset.cellId.split(":")[0];le.has(ee)||(le.add(ee),O.push(ee))}),f(S=>{if(!S)return S;const ee=B.findIndex(re=>re.key===S.colKey),_=O.indexOf(S.rowId);let I=ee,de=_;if(L==="up")de=Math.max(0,_-1);else if(L==="down")de=Math.min(O.length-1,_+1);else if(L==="left"){let re=ee-1;for(;re>=0&&B[re].selectable===!1;)re--;re>=0&&(I=re)}else if(L==="right"){let re=ee+1;for(;re<B.length&&B[re].selectable===!1;)re++;re<B.length&&(I=re)}return I===ee&&de===_?S:{rowId:O[de],colKey:B[I].key}})},[]),R=s.useCallback((L=!0)=>{const B=d.current;m(null),B&&f(B),L&&setTimeout(()=>{var le;return(le=N.current)==null?void 0:le.focus({preventScroll:!0})},0)},[]),U=s.useCallback(async(L,B,le)=>{var se;const O=V.current.find(he=>he.key===B);if(!(O!=null&&O.editable))return;const{field:ae,type:S,mask:ee,validate:_}=O.editable,I=S==="number"?le===""?null:Number(le):le;if(ee){const he=bd(le,ee);if(he){E(Ae=>({...Ae,[`${L}:${B}`]:he}));return}}if(_){const he=_(I);if(he){E(Ae=>({...Ae,[`${L}:${B}`]:he}));return}}const de=G.current,re=K.current.find(he=>de(he)===L);if(!re)return;const F=re[ae];m(null),E(he=>{const Ae={...he};return delete Ae[`${L}:${B}`],Ae});const y=K.current,T=y.findIndex(he=>de(he)===L),te=y[Math.min(y.length-1,T+1)];if(f({rowId:de(te),colKey:B}),setTimeout(()=>{var Ae,De;const he=document.activeElement;(!he||he===document.body||(Ae=N.current)!=null&&Ae.contains(he))&&((De=N.current)==null||De.focus({preventScroll:!0}))},0),String(F??"")===String(I??""))return;const fe={...re,[ae]:I};c(he=>he.map(Ae=>de(Ae)===L?fe:Ae)),w({rowId:L,colKey:B});try{await((se=D.current)==null?void 0:se.call(D,{row:re,rowId:L,field:ae,oldValue:F,newValue:I}))}catch{c(he=>he.map(Ae=>de(Ae)===L?re:Ae)),E(he=>({...he,[`${L}:${B}`]:"Error al guardar. Intenta de nuevo."}))}finally{w(null)}},[]),Y=s.useCallback(L=>{if(A.current){L.preventDefault();return}if(d.current)return;const B=g.current;if(!(!B||!["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Enter","Escape","Tab"].includes(L.key)))switch(L.preventDefault(),L.key){case"ArrowUp":J("up");break;case"ArrowDown":J("down");break;case"ArrowLeft":J("left");break;case"ArrowRight":J("right");break;case"Tab":J(L.shiftKey?"left":"right");break;case"Enter":{const O=V.current.find(ae=>ae.key===B.colKey);O!=null&&O.editable&&!ne.current?(m(B),O.editable.type==="select"&&!M.current.has(B.colKey)&&X(B.colKey,O.editable)):J("down");break}}},[J,X]),ce=s.useMemo(()=>e.map(L=>{if(!L.editable||o){const le={...L};if(delete le.editable,delete le.selectable,L.selectable===!1)return{...le,disableRowClick:!0};const O=le.cell;return{...le,className:`relative ${le.className??""}`.trim(),disableRowClick:!0,cell:ae=>{const S=n(ae),ee=(b==null?void 0:b.rowId)===S&&(b==null?void 0:b.colKey)===L.key;return t.jsxs(t.Fragment,{children:[t.jsx("span",{"data-cell-id":`${S}:${L.key}`,className:"absolute inset-0 z-10 cursor-default",onClick:()=>{var _;A.current||(f({rowId:S,colKey:L.key}),(_=N.current)==null||_.focus({preventScroll:!0}))}}),ee&&t.jsx("div",{className:"pointer-events-none absolute inset-0 z-20",style:Ya}),t.jsx("span",{className:"relative z-0 pointer-events-none",children:O(ae)})]})}}}const B=L.editable;return{...L,className:`relative ${L.className??""}`.trim(),disableRowClick:!0,cell:le=>{const O=n(le),ae=L.key,S=(u==null?void 0:u.rowId)===O&&(u==null?void 0:u.colKey)===ae,ee=(b==null?void 0:b.rowId)===O&&(b==null?void 0:b.colKey)===ae,_=p[`${O}:${ae}`],I=(v==null?void 0:v.rowId)===O&&(v==null?void 0:v.colKey)===ae,de=le[B.field],re=String(de??""),F=()=>{var T;A.current||(f({rowId:O,colKey:ae}),m({rowId:O,colKey:ae}),(T=N.current)==null||T.focus({preventScroll:!0}),B.type==="select"&&!M.current.has(ae)&&X(ae,B))};if(S){const T=B.type==="select"?t.jsx(pd,{initialValue:re,options:C[ae]??[],loading:k[ae]??!1,onCommit:te=>U(O,ae,te),onCancel:R}):t.jsx(hd,{initialValue:re,type:B.type??"text",mask:B.mask,onCommit:te=>U(O,ae,te),onCancel:R});return t.jsx("div",{className:"absolute inset-0 flex items-center px-2",style:gd,onClick:te=>te.stopPropagation(),children:T})}const y=L.cell(le);return t.jsxs(t.Fragment,{children:[t.jsx("span",{"data-cell-id":`${O}:${ae}`,className:`peer absolute inset-0 z-10 ${I?"cursor-wait":"cursor-pointer"}`,onClick:F}),ee&&!I&&t.jsx("div",{className:"pointer-events-none absolute inset-0 z-20",style:Ya}),I&&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:Ya,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:_?t.jsxs("span",{className:"flex items-center gap-1 text-red-500",children:[t.jsx(j.HiExclamationCircle,{className:"h-3.5 w-3.5 shrink-0"}),t.jsx("span",{className:"truncate text-xs",children:_})]}):t.jsx("span",{className:"truncate",children:y})}),!I&&t.jsx(j.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,b,v,p,C,k,n,U,R,X]);return t.jsx("div",{ref:N,tabIndex:0,onKeyDown:Y,onBlur:L=>{var B;(B=N.current)!=null&&B.contains(L.relatedTarget)||setTimeout(()=>{var O,ae;const le=document.activeElement;le&&((O=le.closest)!=null&&O.call(le,"[data-bonsaif-select-dropdown]"))||(ae=N.current)!=null&&ae.contains(le)||R(!1)},0)},style:{width:"100%",minWidth:0,outline:"none"},children:t.jsx(qa,{...l,columns:ce,data:i,getRowId:n})})}function st(e){if(e)return new Date(`${e}T12:00:00`)}function Dt(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 Cr(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Ts(e){return e.map(r=>st(r)).filter(r=>!!r)}function xd(e){if(!(e!=null&&e.length))return[];const r=new Set(e.map(Dt));return Array.from(r).sort()}function Ka(e){return new Intl.DateTimeFormat("es-MX",{weekday:"short"}).format(e)}function $s(e){const r=st(e);if(!r)return e;const n=Ka(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 Ga={weekend:{dayOfWeek:[0,6]}},Za={weekend:"bonsaif-weekend"};function Qa({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 yd={background:"var(--primary)",color:"var(--primary-fg, #ffffff)",borderRadius:999},wd={background:"color-mix(in srgb, var(--primary) 22%, transparent)",color:"var(--text-main)",borderRadius:999};function Nd({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?yd:null,...o?wd:null,...l?{fontWeight:800}:null,...n.style}})}function kd({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 b={from:st(e),to:st(r)},f=st(a),[g,p]=s.useState(()=>st(o||e)??new Date);s.useEffect(()=>{const C=st(o||e);C&&p(C)},[o,e]);const E=s.useMemo(()=>{if(l<=1)return Cr(new Intl.DateTimeFormat("es-MX",{month:"long",year:"numeric"}).format(g));const C=new Date(g.getFullYear(),g.getMonth()+l-1,1),H=g.getFullYear()===C.getFullYear(),k=new Intl.DateTimeFormat("es-MX",{month:"short",...H?{}:{year:"numeric"}}).format(g),x=new Intl.DateTimeFormat("es-MX",{month:"short",year:"numeric"}).format(C);return`${Cr(k)} – ${Cr(x)}`},[g,l]);function v(){p(new Date(g.getFullYear(),g.getMonth()-1,1))}function w(){p(new Date(g.getFullYear(),g.getMonth()+1,1))}const A=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:v,children:t.jsx(j.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:w,children:t.jsx(j.HiChevronRight,{size:16})})]}),t.jsx(Ia.DayPicker,{mode:"range",selected:b,month:g,onMonthChange:p,onSelect:C=>{const H=C!=null&&C.from?Dt(C.from):e,k=C!=null&&C.to?Dt(C.to):"";n({startDate:H,endDate:k})},numberOfMonths:l,hideNavigation:!0,weekStartsOn:1,disabled:f?{before:f}:void 0,showOutsideDays:!1,modifiers:Ga,modifiersClassNames:Za,components:{DayButton:Nd,Weekday:Qa},classNames:{root:"bonsaif-range-daypicker w-full",months:A,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:C=>`${Cr(new Intl.DateTimeFormat("es-MX",{month:"long"}).format(C))} ${C.getFullYear()}`,formatWeekdayName:Ka}})]}),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 As({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 Ls(e,r){const n=st(e),a=st(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(Dt(c)),c.setDate(c.getDate()+1);return i}function Ds(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 an(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 Sd(e,r){return typeof r!="number"||r<=0||e.length<=r?e:e.slice(-r)}function Ed(e,r,n){return!!(r&&e<r||n&&e>n)}function Os({value:e,onChange:r,disabled:n=!1,minDate:a,maxDate:o,maxDates:l,isDateDisabled:i,retainOutsidePrefix:c}){const d=s.useRef(null),u=s.useRef(null),m=s.useRef(!1),b=s.useRef(e);b.current=e;const f=s.useCallback(k=>{let x=k;if(c){const M=b.current.filter(z=>!z.startsWith(c)),N=k.filter(z=>z.startsWith(c));x=[...M,...N].sort()}r==null||r(Sd(x,l))},[l,r,c]),g=s.useCallback((k,x=!1)=>Ed(k,a,o)?!0:!(!(i!=null&&i(k))||x&&b.current.includes(k)),[i,o,a]),p=s.useCallback(k=>k.filter(x=>!g(x)),[g]),E=s.useCallback(()=>{u.current=null},[]);s.useEffect(()=>{const k=()=>E();return window.addEventListener("pointerup",k),window.addEventListener("pointercancel",k),()=>{window.removeEventListener("pointerup",k),window.removeEventListener("pointercancel",k)}},[E]);const v=s.useCallback((k,x,M,N)=>{const z=p(Ls(k,x));f(M==="add"?an(N,z,"add"):an(N,z,"remove"))},[f,p]),w=s.useCallback((k,x)=>{if(n||x.button!==0)return;const M=Dt(k);if(g(M,!0)||x.shiftKey)return;m.current=!0;const N=[...b.current],z=N.includes(M)?"remove":"add";z==="add"&&g(M)||(u.current={active:!0,mode:z,anchor:M,latest:M,baseline:N},d.current=M,v(M,M,z,N),x.preventDefault())},[v,n,g]),A=s.useCallback(k=>{const x=u.current;if(!(x!=null&&x.active)||n)return;const M=Dt(k);x.mode==="add"&&g(M)||x.latest!==M&&(x.latest=M,v(x.anchor,M,x.mode,x.baseline))},[v,n,g]),C=s.useCallback((k,x)=>{if(n)return;const M=Dt(k);if(!g(M,!0)){if(m.current&&!x.shiftKey){m.current=!1,x.preventDefault(),x.stopPropagation();return}if(m.current=!1,x.shiftKey&&d.current){x.preventDefault(),x.stopPropagation();const N=p(Ls(d.current,M));f(an(b.current,N,"add"));return}!b.current.includes(M)&&g(M)||(d.current=M,f(an(b.current,[M],"toggle")))}},[f,n,p,g]),H=s.useCallback(k=>{if(n)return;const x=p(xd(k));if(!x.length)return;const M=x.every(N=>b.current.includes(N));f(an(b.current,x,M?"remove":"add")),d.current=x[0]??d.current},[f,n,p]);return{onDayPointerDown:w,onDayPointerEnter:A,onDayClick:C,toggleWeek:H,endDrag:E}}function on(e){return Ds(e,1)[0]}function Hs(e,r){const n=new Date(e);return n.setDate(n.getDate()+r),n}function Cd({value:e=[],onChange:r,minDate:n,maxDate:a,isDateDisabled:o,viewMonth:l,maxDates:i,showWeekNumbers:c=!1,viewMode:d,defaultViewMode:u="month",onViewModeChange:m,showSummary:b=!0,className:f="",disabled:g=!1}){const p=s.useMemo(()=>Ts(e),[e]),E=s.useMemo(()=>new Set(e),[e]),v=st(n),w=st(a),[A,C]=s.useState(()=>st(l||e[0])??new Date),[H,k]=s.useState(()=>on(st(l||e[0])??new Date)),[x,M]=s.useState(u),N=d??x;function z(L){d===void 0&&M(L),m==null||m(L)}s.useEffect(()=>{const L=st(l);L&&(C(L),k(on(L)))},[l]);const{onDayPointerDown:X,onDayPointerEnter:K,onDayClick:D,toggleWeek:G}=Os({value:e,onChange:r,disabled:g,minDate:n,maxDate:a,maxDates:i,isDateDisabled:o}),V=s.useMemo(()=>{if(g)return!0;const L=[];return v&&L.push({before:v}),w&&L.push({after:w}),o&&L.push(B=>o(Dt(B))),L.length>0?L:void 0},[g,o,w,v]),ne=s.useCallback(L=>t.jsx(As,{...L,className:`bonsaif-multi-day-btn ${L.className??""}`,onDayPointerDown:X,onDayPointerEnter:K,onDayClickSelect:D}),[D,X,K]),J=s.useMemo(()=>Ds(H,1),[H]),R=J[6],U=N==="week"?`${new Intl.DateTimeFormat("es-MX",{day:"numeric",month:"short"}).format(J[0])} – ${new Intl.DateTimeFormat("es-MX",{day:"numeric",month:"short",year:"numeric"}).format(R)}`:Cr(new Intl.DateTimeFormat("es-MX",{month:"long",year:"numeric"}).format(A));function Y(){if(N==="week"){const L=Hs(H,-7);k(on(L)),C(L);return}C(new Date(A.getFullYear(),A.getMonth()-1,1))}function ce(){if(N==="week"){const L=Hs(H,7);k(on(L)),C(L);return}C(new Date(A.getFullYear(),A.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":N==="month",className:`bonsaif-cal-view-btn${N==="month"?" is-active":""}`,disabled:g,onClick:()=>{z("month"),C(H)},children:"Mes"}),t.jsx("button",{type:"button",role:"tab","aria-selected":N==="week",className:`bonsaif-cal-view-btn${N==="week"?" is-active":""}`,disabled:g,onClick:()=>{z("week"),k(on(A))},children:"Semana"})]}),t.jsxs("div",{className:"bonsaif-cal-toolbar",children:[t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn","aria-label":N==="week"?"Semana anterior":"Mes anterior",disabled:g,onClick:Y,children:t.jsx(j.HiChevronLeft,{size:16})}),t.jsx("span",{className:"bonsaif-cal-title",children:U}),t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn","aria-label":N==="week"?"Semana siguiente":"Mes siguiente",disabled:g,onClick:ce,children:t.jsx(j.HiChevronRight,{size:16})})]}),t.jsxs("p",{className:"bonsaif-cal-hint",children:["Click · Shift+click rango · Arrastra",c&&N==="month"?" · Semana (nº)":"",N==="week"?" · Botón semana completa":""]}),N==="month"?t.jsx(Ia.DayPicker,{mode:"multiple",required:!1,selected:p,month:A,onMonthChange:C,onSelect:()=>{},hideNavigation:!0,showOutsideDays:!1,weekStartsOn:1,showWeekNumber:c,onWeekNumberClick:(L,B)=>{G(B)},disabled:V,className:"bonsaif-multi-daypicker",modifiers:Ga,modifiersClassNames:Za,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:ne,Weekday:Qa},formatters:{formatWeekdayName:Ka}}):t.jsxs("div",{className:"bonsaif-week-view",children:[t.jsx("div",{className:"bonsaif-week-view-head",children:J.map(L=>t.jsx("div",{className:"bonsaif-multi-weekday",children:new Intl.DateTimeFormat("es-MX",{weekday:"short"}).format(L)},`h-${Dt(L)}`))}),t.jsx("div",{className:"bonsaif-week-view-days",children:J.map(L=>{const B=Dt(L),le=E.has(B),O=g||(n?B<n:!1)||(a?B>a:!1)||!!(o!=null&&o(B)),ae=B===Dt(new Date);return t.jsx("div",{className:`bonsaif-multi-day${le?" bonsaif-multi-day-selected":""}${ae?" bonsaif-multi-day-today":""}${O?" bonsaif-multi-day-disabled":""}`,children:t.jsxs("button",{type:"button",className:"bonsaif-multi-day-btn",disabled:O,"aria-pressed":le,onPointerDown:S=>X(L,S),onPointerEnter:()=>K(L),onClick:S=>D(L,S),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)})]})},B)})}),t.jsx("button",{type:"button",className:"bonsaif-week-select-all",disabled:g,onClick:()=>G(J),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(L=>t.jsxs("button",{type:"button",className:"bonsaif-cal-chip",disabled:g,onClick:()=>r==null?void 0:r(e.filter(B=>B!==L)),title:`Quitar ${L}`,children:[$s(L),t.jsx("span",{"aria-hidden":!0,children:"×"})]},L))})]})}):null]})}const Md=Array.from({length:12},(e,r)=>r);function Td({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 b=s.useMemo(()=>Ts(e),[e]),f=st(o),g=st(l),p=n??(e[0]?Number(e[0].slice(0,4)):new Date().getFullYear()),[E,v]=s.useState(p);s.useEffect(()=>{typeof n=="number"&&v(n)},[n]);function w(N){v(N),a==null||a(N)}const{onDayPointerDown:A,onDayPointerEnter:C,onDayClick:H}=Os({value:e,onChange:r,disabled:u||m,minDate:o,maxDate:l,maxDates:i,retainOutsidePrefix:`${E}-`}),k=s.useCallback(N=>t.jsx(As,{...N,className:`bonsaif-year-day-btn ${N.className??""}`,onDayPointerDown:A,onDayPointerEnter:C,onDayClickSelect:H}),[H,A,C]),x=b.filter(N=>N.getFullYear()===E),M=u?!0:[...f?[{before:f}]:[],...g?[{after:g}]:[]];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:()=>w(E-1),children:t.jsx(j.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:()=>w(E+1),children:t.jsx(j.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:Md.map(N=>{const z=new Date(E,N,1);return t.jsxs("div",{className:"bonsaif-year-cal-month",children:[t.jsx("div",{className:"bonsaif-year-cal-month-title",children:Cr(new Intl.DateTimeFormat("es-MX",{month:"long"}).format(z))}),t.jsx(Ia.DayPicker,{mode:"multiple",required:!1,selected:x,month:z,onMonthChange:()=>{},onSelect:()=>{},numberOfMonths:1,hideNavigation:!0,showOutsideDays:!1,weekStartsOn:1,disabled:M,className:"bonsaif-year-month-picker",modifiers:Ga,modifiersClassNames:Za,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:Qa},formatters:{formatWeekdayName:X=>new Intl.DateTimeFormat("es-MX",{weekday:"narrow"}).format(X)}})]},`${E}-${N}`)})})]}),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(N=>t.jsxs("button",{type:"button",className:"bonsaif-cal-chip",disabled:u||m,onClick:()=>r==null?void 0:r(e.filter(z=>z!==N)),title:`Quitar ${N}`,children:[$s(N),t.jsx("span",{"aria-hidden":!0,children:"×"})]},N))})]})}):null]})}const $d="bonsaif-ui:hide-tooltips";function Is(){window.dispatchEvent(new CustomEvent($d))}function Ad(e){if(e!==void 0)return typeof e=="number"?`${e}px`:e}function Ld({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,b]=s.useState(!1),[f,g]=s.useState({}),p=s.useRef(null),E=s.useRef(null),v=s.useCallback(k=>{u(k),c==null||c(k)},[c]),w=s.useCallback(()=>{const k=p.current;if(!k)return;const x=k.getBoundingClientRect(),M=typeof a=="number"?a:x.width,N=typeof a=="number"?a:Math.max(x.width,180),z=n==="end"?Math.max(8,x.right-N):Math.min(x.left,window.innerWidth-N-8),X=window.innerHeight-x.bottom,K=X<240&&x.top>X?void 0:x.bottom+6,D=K===void 0?window.innerHeight-x.top+6:void 0;g({position:"fixed",zIndex:9999,left:z,top:K,bottom:D,width:Ad(typeof a=="number"?M:a)})},[n,a]);s.useEffect(()=>b(!0),[]),s.useEffect(()=>{if(!d)return;w();const k=M=>{var z,X;const N=M.target;!((z=p.current)!=null&&z.contains(N))&&!((X=E.current)!=null&&X.contains(N))&&v(!1)},x=M=>{M.key==="Escape"&&v(!1)};return document.addEventListener("mousedown",k),window.addEventListener("keydown",x),window.addEventListener("resize",w),window.addEventListener("scroll",w,!0),()=>{document.removeEventListener("mousedown",k),window.removeEventListener("keydown",x),window.removeEventListener("resize",w),window.removeEventListener("scroll",w,!0)}},[d,v,w]);const A=k=>{o||(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),v(!d))},C=s.isValidElement(e)?s.cloneElement(e,{onClick:()=>{o||(Is(),v(!d))}}):e,H=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:f,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 x;k.disabled||(Is(),(x=k.onSelect)==null||x.call(k),v(!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:p,role:"button",tabIndex:o?-1:0,"aria-haspopup":"menu","aria-expanded":d,onKeyDown:A,className:`inline-flex ${o?"pointer-events-none opacity-60":""} ${l}`,children:[C,m&&H?gt.createPortal(H,document.body):null]})}const Dd=180,Bs="bg-[color-mix(in_srgb,var(--bg-main)_72%,transparent)] backdrop-blur-sm";function Od({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:b=440,hasUnsavedChanges:f=!1,unsavedChangesTitle:g="Descartar cambios",unsavedChangesDescription:p="Hay cambios sin guardar. Si cierras el drawer se perderán.",unsavedChangesConfirmLabel:E="Descartar",unsavedChangesCancelLabel:v="Seguir editando",onDiscardChanges:w,disabled:A=!1,disabledMessage:C,children:H}){const[k,x]=s.useState(!1),[M,N]=s.useState(!1),[z,X]=s.useState(!1),K=s.useCallback(()=>{N(!0),requestAnimationFrame(()=>{requestAnimationFrame(()=>X(!0))})},[]),D=s.useCallback(()=>{X(!1),window.setTimeout(()=>N(!1),Dd)},[]),G=A||c,V=s.useCallback(()=>{if(!G){if(f){K();return}r()}},[G,f,r,K]),ne=s.useCallback(()=>{X(!1),N(!1),w==null||w(),r()},[r,w]);if(s.useEffect(()=>{x(!0)},[]),s.useEffect(()=>(document.body.style.overflow=e?"hidden":"",e||(X(!1),N(!1)),()=>{document.body.style.overflow=""}),[e]),s.useEffect(()=>{if(!e)return;const R=U=>{if(U.key==="Escape"&&!G){if(M){D();return}V()}};return window.addEventListener("keydown",R),()=>window.removeEventListener("keydown",R)},[D,G,M,e,V]),!k)return null;const J=C!==void 0?C:c?"Guardando…":null;return gt.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 ${Bs}`,onClick:V}),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(Qe,{variant:"icon",onClick:V,title:"Cerrar",disabled:G,children:t.jsx(j.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(Qe,{variant:"secondary",size:"sm",onClick:V,disabled:G,style:{background:"var(--bg-input)"},children:"Cancelar"}),t.jsx(Qe,{variant:"primary",size:"sm",icon:t.jsx(Zi.FiSave,{className:"w-4 h-4"}),onClick:i,loading:c,disabled:d||G,title:l})]})]})]}),t.jsx("div",{"data-drawer-scroll":"true",className:m,children:H}),G&&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:J?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:J})]}):null})]}),M&&t.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":g,className:"fixed inset-0 z-[1001] flex items-center justify-center p-4",children:[t.jsx("div",{className:`absolute inset-0 ${Bs} transition-opacity duration-200 ease-out ${z?"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 ${z?"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(Qe,{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":v,children:t.jsx(j.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(j.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:g}),t.jsx("p",{className:"text-sm",style:{color:"var(--text-muted, #6b7f78)"},children:p}),t.jsxs("div",{className:"mt-6 flex gap-2",children:[t.jsx(Qe,{variant:"secondary",onClick:D,className:"flex-1 border",style:{background:"var(--bg-input, #f7faf8)",borderColor:"var(--border, #d8e1dc)",color:"var(--text-main, #0f2f2c)"},children:v}),t.jsx(Qe,{variant:"secondary",onClick:ne,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 Hd=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,Id=/^\+?[0-9\s().-]+$/,Bd=7,Fd=15;function Pt(e){return e==null||String(e).trim()===""}function Fs(e){return typeof e=="number"?e:typeof e=="string"&&e.trim()!==""?Number(e):Number.NaN}function Ja(e){return Pt(e)?!1:Hd.test(String(e))}function Ra(e){if(Pt(e))return!1;const r=String(e),n=r.replace(/\D/g,"");return Id.test(r)&&n.length>=Bd&&n.length<=Fd}function Pd(e="Este campo es requerido."){return r=>Pt(r)?e:void 0}function _d(e="Ingresa un correo valido."){return r=>Pt(r)||Ja(r)?void 0:e}function zd(e="Ingresa un telefono valido."){return r=>Pt(r)||Ra(r)?void 0:e}function Wd(e,r){return n=>Pt(n)||String(n).length>=e?void 0:r??`Debe tener al menos ${e} caracteres.`}function jd(e,r){return n=>Pt(n)||String(n).length<=e?void 0:r??`Debe tener ${e} caracteres o menos.`}function qd(e,r){return n=>{if(Pt(n))return;const a=Fs(n);return Number.isFinite(a)&&a>=e?void 0:r??`Debe ser mayor o igual a ${e}.`}}function Ud(e,r){return n=>{if(Pt(n))return;const a=Fs(n);return Number.isFinite(a)&&a<=e?void 0:r??`Debe ser menor o igual a ${e}.`}}function Vd(e,r="El formato no es valido."){return n=>Pt(n)||e.test(String(n))?void 0:r}function Xd(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 Ps={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},_s=s.createContext&&s.createContext(Ps),Yd=["attr","size","title"];function Kd(e,r){if(e==null)return{};var n,a,o=Gd(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 Gd(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 Fn(){return Fn=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},Fn.apply(null,arguments)}function zs(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 Pn(e){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};r%2?zs(Object(n),!0).forEach(function(a){Zd(e,a,n[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):zs(Object(n)).forEach(function(a){Object.defineProperty(e,a,Object.getOwnPropertyDescriptor(n,a))})}return e}function Zd(e,r,n){return(r=Qd(r))in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}function Qd(e){var r=Jd(e,"string");return typeof r=="symbol"?r:r+""}function Jd(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)=>s.createElement(r.tag,Pn({key:n},r.attr),Ws(r.child)))}function eo(e){return r=>s.createElement(Rd,Fn({attr:Pn({},e.attr)},r),Ws(e.child))}function Rd(e){var r=n=>{var{attr:a,size:o,title:l}=e,i=Kd(e,Yd),c=o||n.size||"1em",d;return n.className&&(d=n.className),e.className&&(d=(d?d+" ":"")+e.className),s.createElement("svg",Fn({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},n.attr,a,i,{className:d,style:Pn(Pn({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 _s!==void 0?s.createElement(_s.Consumer,null,n=>r(n)):r(Ps)}function js(e){return eo({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 eu(e){return eo({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 tu(e){return eo({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 Mr({content:e,ariaLabel:r="Más información",className:n=""}){return t.jsx(Bt,{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(j.HiInformationCircle,{className:"h-3.5 w-3.5"})})})}function Tr({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 _n({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 to({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:b="",required:f,...g}){const[p,E]=s.useState(()=>!!g.autoFocus),[v,w]=s.useState(!1),A=g.type==="password"&&u,C=A&&v?"text":g.type,H=!!o,k=H&&l!=="tooltip",x=H&&l!=="inline",M=!!n&&a==="tooltip"&&!k,N=m?f:void 0,z=H?"border-[var(--danger)] focus:border-[var(--danger)]":"",X=x?A?"pr-20":"pr-10":A?"pr-10":"",K=g.value!==void 0?String(g.value).length>0:g.defaultValue!==void 0&&String(g.defaultValue).length>0,D=p||K,G={top:D?7:12,color:p?"var(--primary)":"var(--text-muted)",fontSize:D?10:13,fontWeight:D?600:400,textTransform:D?"uppercase":"none"},V=Y=>{var ce;E(!0),(ce=g.onFocus)==null||ce.call(g,Y)},ne=Y=>{var ce;E(!1),(ce=g.onBlur)==null||ce.call(g,Y)},J=A?t.jsxs("button",{type:"button","aria-label":v?"Ocultar contraseña":"Mostrar contraseña","aria-pressed":v,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:()=>w(Y=>!Y),children:[t.jsx("span",{"aria-hidden":"true",className:`absolute inset-0 flex items-center justify-center transition-[opacity,transform] duration-200 ease-out ${v?"scale-y-0 rotate-[-8deg] opacity-0":"scale-y-100 rotate-0 opacity-100"}`,children:t.jsx(eu,{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 ${v?"scale-y-100 rotate-0 opacity-100":"scale-y-0 rotate-[8deg] opacity-0"}`,children:t.jsx(tu,{className:"h-[18px] w-[18px]"})})]}):null,R=x?t.jsx(Bt,{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)] ${A?"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(js,{className:"h-[18px] w-[18px]"})})}):null,U=t.jsx(Tr,{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(_n,{...g,type:C,required:N,placeholder:" ","aria-invalid":H||g["aria-invalid"],"data-has-value":K?"true":void 0,className:`h-11 w-full pt-5 ${X} ${z} ${b}`,onFocus:V,onBlur:ne}),t.jsxs("span",{className:"pointer-events-none absolute left-3 transition-all duration-150",style:G,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}),R,J]}),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:"*"}),M?t.jsx(Mr,{content:n}):null,c&&t.jsx("span",{className:"ml-auto normal-case",children:c})]}),A?t.jsxs("span",{className:"relative block",children:[t.jsx(_n,{...g,type:C,required:N,"aria-invalid":H||g["aria-invalid"],className:`w-full ${X} ${z} ${b}`,onFocus:V,onBlur:ne}),R,J]}):t.jsxs("span",{className:"relative block",children:[t.jsx(_n,{...g,required:N,"aria-invalid":H||g["aria-invalid"],className:`w-full ${X} ${z} ${b}`}),R]}),U]})}function qs(e){return e==null?"":String(e)}function ru({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,b]=s.useState(()=>qs(c)),f=i!==void 0?qs(i):m,g=n&&f.length>0&&!Ja(f)?a:void 0,p=E=>{i===void 0&&b(E.currentTarget.value),d==null||d(E)};return t.jsx(to,{...u,value:i,defaultValue:c,type:"text",inputMode:r,autoComplete:e,error:l??g,errorDisplay:o,onChange:p})}const nu={sm:"min-h-[112px] p-4",md:"min-h-[148px] p-5",lg:"min-h-[184px] p-6"};function au(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 Us(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 ou(e,r,n){return r?n===void 0?e:e.slice(0,Math.max(0,n)):e.slice(0,1)}function su({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:b=!1,showFileList:f=!0,clearable:g=!0,browseLabel:p="Buscar archivos",dropLabel:E="Suelta los archivos aqui",emptyLabel:v="Arrastra y suelta archivos",emptyDescription:w="o haz click para buscarlos en tu equipo",selectedLabel:A="Archivos seleccionados",size:C="md",containerClassName:H="",dropzoneClassName:k="",fileListClassName:x="",className:M="",id:N,accept:z,disabled:X,required:K,...D}){const G=s.useId(),V=N??G,ne=s.useRef(null),[J,R]=s.useState(!1),[U,Y]=s.useState(i),ce=l??U,L=!!a,B=!!r&&n==="tooltip"&&!L,le=g&&ce.length>0&&!X,O=(T,te)=>{l===void 0&&Y(T),c==null||c(T,te)},ae=(T,te)=>{const fe=T.filter(De=>Us(De,z)),se=T.filter(De=>!Us(De,z)),he=b?[...ce,...fe]:fe,Ae=ou(he,u,m);se.length>0&&(d==null||d(se)),O(Ae,te)},S=()=>{var T;X||(T=ne.current)==null||T.click()},ee=T=>{ae(Array.from(T.target.files??[]),T),T.target.value=""},_=T=>{T.preventDefault(),X||R(!0)},I=T=>{T.currentTarget.contains(T.relatedTarget)||R(!1)},de=T=>{T.preventDefault(),R(!1),!X&&ae(Array.from(T.dataTransfer.files),T)},re=T=>{T.key!=="Enter"&&T.key!==" "||(T.preventDefault(),S())},F=T=>{O(ce.filter((te,fe)=>fe!==T))},y=()=>{O([])};return t.jsxs("div",{className:`flex flex-col gap-2 ${H}`,children:[(e||o||B)&&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}),K&&t.jsx("span",{className:"text-[var(--danger)]",children:"*"}),B?t.jsx(Mr,{content:r}):null,o&&t.jsx("span",{className:"ml-auto normal-case",children:o})]}),t.jsx("input",{...D,ref:ne,id:V,type:"file",accept:z,multiple:u,disabled:X,required:K&&ce.length===0,"aria-invalid":L||D["aria-invalid"],className:"sr-only",onChange:ee}),t.jsxs("div",{role:"button",tabIndex:X?-1:0,"aria-controls":V,"aria-disabled":X||void 0,"aria-invalid":L||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)] ${nu[C]} ${J?"border-[var(--primary)] bg-[var(--bg-input)]":L?"border-[var(--danger)]":"border-[var(--border)]"} ${X?"cursor-not-allowed opacity-60":"hover:border-[var(--primary)] hover:bg-[var(--bg-input)]"} ${k} ${M}`,onClick:S,onDragOver:_,onDragLeave:I,onDrop:de,onKeyDown:re,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(j.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:J?E:v}),w&&t.jsx("span",{className:"block text-sm text-[var(--text-muted)]",children:w})]}),p&&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:p})]}),f&&ce.length>0&&t.jsxs("div",{className:`rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${x}`,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:A}),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:y,children:t.jsx(j.HiTrash,{className:"h-4 w-4"})})]}),t.jsx("ul",{className:"divide-y divide-[var(--border)]",children:ce.map((T,te)=>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(j.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:T.name}),t.jsx("span",{className:"block text-xs text-[var(--text-muted)]",children:au(T.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 ${T.name}`,onClick:()=>F(te),children:t.jsx(j.HiXMark,{className:"h-4 w-4"})})]},`${T.name}-${T.lastModified}-${te}`))})]}),t.jsx(Tr,{error:a,helperText:r,helperDisplay:n})]})}const lu=[{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 iu({fields:e,title:r="Layout",fieldTypes:n=lu,saveLabel:a="Guardar",allowAddField:o=!1,addFieldPlaceholder:l="Nuevo campo",addFieldLabel:i="Anadir",loading:c=!1,onSave:d,onChange:u}){const[m,b]=s.useState(()=>e.map(C=>({key:!1,type:"",...C}))),[f,g]=s.useState(""),[p,E]=s.useState(""),v=s.useCallback((C,H)=>{b(k=>{const x=k.map((M,N)=>N===C?{...M,...H}:M);return u==null||u(x),x})},[u]),w=s.useCallback(()=>{d==null||d(m)},[m,d]),A=s.useCallback(()=>{var x;const C=f.trim();if(!C){E("Ingresa un nombre de campo.");return}if(m.some(M=>M.name.toLowerCase()===C.toLowerCase())){E("Ese campo ya existe en el arreglo.");return}const k={name:C,key:!1,type:((x=n[0])==null?void 0:x.value)??""};b(M=>{const N=[...M,k];return u==null||u(N),N}),g(""),E("")},[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((C,H)=>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:C.name}),t.jsx("div",{className:"flex justify-center",children:t.jsx(Mn,{size:"sm",checked:C.key??!1,onChange:k=>v(H,{key:k.target.checked}),"aria-label":`${C.name} es clave`})}),t.jsx(dr,{value:C.type??"",onChange:k=>v(H,{type:k}),options:n,placeholder:"—",emptyLabel:"—",height:36,searchable:!1,ariaLabel:`Tipo de ${C.name}`})]},C.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:f,onChange:C=>{g(C.currentTarget.value),p&&E("")},onKeyDown:C=>{C.key==="Enter"&&(C.preventDefault(),A())},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(Qe,{variant:"secondary",onClick:A,height:36,padding:"0 12px",children:i})]}),p&&t.jsx("p",{className:"text-xs",style:{color:"var(--danger)"},children:p})]}),t.jsx("div",{className:"flex justify-end",children:t.jsx(Qe,{variant:"primary",onClick:w,disabled:c,loading:c,children:a})})]})})]})}function zn({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(Mr,{content:n}):null,l&&t.jsx("span",{className:"ml-auto normal-case",children:l})]}),t.jsx("span",{className:`block ${d}`,children:r}),t.jsx(Tr,{error:o,helperText:n,helperDisplay:a})]})}function cu(e){return Array.from(e.querySelectorAll("img")).filter(r=>!!(r.currentSrc||r.src||"").trim())}function Vs(e,r){const n=e.target;if(!(n instanceof HTMLImageElement))return!1;const a=e.currentTarget,o=cu(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 Ot=260,$r=420,ro=380,_t="cubic-bezier(0.22, 1, 0.36, 1)",du="cubic-bezier(0.16, 1, 0.3, 1)",no="cubic-bezier(0.22, 1, 0.36, 1)",uu="cubic-bezier(0.22, 1, 0.36, 1)",fu=8,bu=1,mu=1.25,ao={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)"},hu="color-mix(in srgb, var(--bg-card) 88%, var(--primary) 12%)",oo=10;function sn(e,r,n){return Math.min(n,Math.max(r,e))}function pu(e){return!e||e.width<1||e.height<1?null:{left:e.left,top:e.top,width:e.width,height:e.height}}function Xs(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 Ar({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:{...ao,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=hu,i.currentTarget.style.transform="scale(1.06)")},onMouseLeave:i=>{i.currentTarget.style.background=String(ao.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 Ys({open:e,onClose:r,slides:n,index:a,onIndexChange:o,originRect:l=null,maxZoom:i=fu,minZoom:c=bu,zoomStep:d=mu,closeOnBackdrop:u=!0,closeOnEscape:m=!0,showCounter:b=!0,showZoomControls:f=!0,loop:g=!0,showThumbnails:p=!0,zIndex:E=1100,ariaLabel:v="Visor de imagen"}){const[w,A]=s.useState(!1),[C,H]=s.useState(!1),[k,x]=s.useState(a??0),[M,N]=s.useState(1),[z,X]=s.useState({x:0,y:0}),[K,D]=s.useState({opacity:1,x:0,scale:1,blur:0,animate:!1}),[G,V]=s.useState({dx:0,dy:0,scale:1,animate:!1,enabled:!1}),[ne,J]=s.useState(!1),R=s.useRef(null),U=s.useRef(null),Y=s.useRef(null),ce=s.useRef(null),L=s.useRef(null),B=s.useRef(!1),le=s.useRef(!1),O=s.useRef(null),ae=s.useRef(null),S=s.useRef(null),ee=s.useRef(null),_=s.useRef(null),I=s.useRef(a??0),de=a??k,re=n.length===0?0:sn(de,0,Math.max(0,n.length-1)),F=n[re],y=n.length>1,T=Math.max(c,i),te=p&&y,fe=s.useCallback(me=>{if(n.length===0)return;const ge=n.length-1,Oe=g?(me%n.length+n.length)%n.length:sn(me,0,ge);a===void 0&&x(Oe),o==null||o(Oe)},[a,g,o,n.length]),se=s.useCallback(()=>{N(1),X({x:0,y:0})},[]),he=s.useCallback((me,ge)=>{if(ge<=c+.001)return{x:0,y:0};const Oe=ee.current,We=_.current;if(!Oe||!We)return me;const Be=Oe.getBoundingClientRect(),mt=We.offsetWidth*ge,ut=We.offsetHeight*ge,qe=Math.max(0,(mt-Be.width)/2+Be.width*.15),Ve=Math.max(0,(ut-Be.height)/2+Be.height*.15);return{x:sn(me.x,-qe,qe),y:sn(me.y,-Ve,Ve)}},[c]),Ae=s.useCallback(()=>{A(!1),V({dx:0,dy:0,scale:1,animate:!1,enabled:!1}),ce.current=null,L.current=null,B.current=!1,le.current=!1,O.current&&(clearTimeout(O.current),O.current=null)},[]),De=s.useCallback(()=>{if(B.current)return;B.current=!0,H(!1),se();const me=ce.current,ge=me!=null&&L.current!=null&&L.current===re;if(me&&ge){Y.current!=null&&cancelAnimationFrame(Y.current),Y.current=requestAnimationFrame(()=>{Y.current=requestAnimationFrame(()=>{const Oe=_.current;if(!Oe){Y.current=null,R.current&&clearTimeout(R.current),R.current=setTimeout(Ae,Ot+40);return}const We=Oe.getBoundingClientRect(),Be=Xs(me,We);V({enabled:!0,dx:0,dy:0,scale:1,animate:!1}),Y.current=requestAnimationFrame(()=>{V({enabled:!0,dx:Be.dx,dy:Be.dy,scale:Be.scale,animate:!0}),Y.current=null})})}),R.current&&clearTimeout(R.current),R.current=setTimeout(Ae,$r+80);return}V({dx:0,dy:0,scale:1,animate:!1,enabled:!1}),R.current&&clearTimeout(R.current),R.current=setTimeout(Ae,Ot+40)},[Ae,se,re]);s.useEffect(()=>(e?(R.current&&clearTimeout(R.current),O.current&&(clearTimeout(O.current),O.current=null),B.current=!1,le.current=!1,ce.current=pu(l),L.current=ce.current!=null?a??k:null,A(!0),H(!1),ce.current?V({dx:0,dy:0,scale:1,animate:!1,enabled:!0}):(L.current=null,requestAnimationFrame(()=>requestAnimationFrame(()=>{H(!0),V({dx:0,dy:0,scale:1,animate:!1,enabled:!1})})))):w&&De(),()=>{R.current&&clearTimeout(R.current),Y.current!=null&&cancelAnimationFrame(Y.current)}),[e]);const ue=s.useCallback(()=>{if(!e||B.current||le.current)return;const me=ce.current,ge=_.current;if(!me||!ge){me||(H(!0),le.current=!0);return}const Oe=ge.getBoundingClientRect();if(Oe.width<2||Oe.height<2)return;le.current=!0;const We=Xs(me,Oe);V({enabled:!0,dx:We.dx,dy:We.dy,scale:We.scale,animate:!1}),Y.current!=null&&cancelAnimationFrame(Y.current),Y.current=requestAnimationFrame(()=>{Y.current=requestAnimationFrame(()=>{V({enabled:!0,dx:0,dy:0,scale:1,animate:!0}),H(!0),Y.current=null,O.current&&clearTimeout(O.current),O.current=setTimeout(()=>{V({dx:0,dy:0,scale:1,animate:!1,enabled:!1}),O.current=null},$r+20)})})},[e]);s.useLayoutEffect(()=>{!w||!e||!ce.current||le.current||ue()},[w,e,ue]),s.useEffect(()=>{!e||B.current||L.current!=null&&L.current!==re&&V(me=>me.enabled?{dx:0,dy:0,scale:1,animate:!1,enabled:!1}:me)},[e,re]),s.useEffect(()=>{if(!e)return;const me=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=me}},[e]),s.useEffect(()=>{e&&se()},[e,re,se]),s.useEffect(()=>{a!==void 0&&x(a)},[a]),s.useEffect(()=>{if(!e){I.current=re,D({opacity:1,x:0,scale:1,blur:0,animate:!1});return}const me=I.current;if(me===re)return;I.current=re;const ge=n.length;let Oe=1;if(ge>1){const We=(me+1)%ge===re,Be=(me-1+ge)%ge===re;Be&&!We?Oe=-1:We&&!Be?Oe=1:Oe=re>me?1:-1}return U.current!=null&&(cancelAnimationFrame(U.current),U.current=null),D({opacity:0,x:Oe*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,re,n.length]);const Te=M<=c+.001&&Math.abs(z.x)<.5&&Math.abs(z.y)<.5,He=s.useCallback((me,ge,Oe)=>{N(We=>{const Be=sn(me,c,T);if(Math.abs(Be-We)<1e-4)return We;const mt=Be/We,ut=Be<We;return Be<=c+.001?(X({x:0,y:0}),c):(X(qe=>{let Ve=qe;if(typeof ge=="number"&&typeof Oe=="number"&&ee.current&&!ut){const ft=ee.current.getBoundingClientRect(),ht=ge-ft.left-ft.width/2,br=Oe-ft.top-ft.height/2;Ve={x:ht-(ht-qe.x)*mt,y:br-(br-qe.y)*mt}}else if(ut){Ve={x:qe.x*mt,y:qe.y*mt};const ft=Math.min(1,(We-Be)/Math.max(.01,We-c));Ve={x:Ve.x*(1-ft*.65),y:Ve.y*(1-ft*.65)}}else Ve={x:qe.x*mt,y:qe.y*mt};return he(Ve,Be)}),Be)})},[he,c,T]),Xe=s.useCallback(()=>{He(M*d)},[He,M,d]),je=s.useCallback(()=>{const me=Math.max(c,M/d);if(me<=c+.001){se();return}N(me),X({x:0,y:0})},[c,se,M,d]);s.useEffect(()=>{if(!e)return;const me=ge=>{if(ge.key==="Escape"&&m){ge.preventDefault(),r();return}ge.key==="ArrowLeft"&&y?(ge.preventDefault(),fe(re-1)):ge.key==="ArrowRight"&&y?(ge.preventDefault(),fe(re+1)):ge.key==="+"||ge.key==="="?(ge.preventDefault(),He(M*d)):ge.key==="-"||ge.key==="_"?(ge.preventDefault(),je()):ge.key==="0"&&(ge.preventDefault(),se())};return window.addEventListener("keydown",me),()=>window.removeEventListener("keydown",me)},[He,m,y,r,e,se,re,M,fe,je,d]);const Ye=me=>{me.preventDefault();const ge=me.deltaY>0?1/d:d;He(M*ge,me.clientX,me.clientY)},ie=me=>{M<=c+.001||(me.currentTarget.setPointerCapture(me.pointerId),J(!0),ae.current={pointerId:me.pointerId,startX:me.clientX,startY:me.clientY,originX:z.x,originY:z.y})},Se=me=>{const ge=ae.current;!ge||ge.pointerId!==me.pointerId||X(he({x:ge.originX+(me.clientX-ge.startX),y:ge.originY+(me.clientY-ge.startY)},M))},_e=me=>{var ge;((ge=ae.current)==null?void 0:ge.pointerId)===me.pointerId&&(ae.current=null,J(!1))},ot=me=>{if(me.stopPropagation(),M>c+.05){se();return}He(Math.min(T,3),me.clientX,me.clientY)},Ke=me=>{if(me.touches.length!==2)return;J(!0);const[ge,Oe]=[me.touches[0],me.touches[1]],We=Math.hypot(ge.clientX-Oe.clientX,ge.clientY-Oe.clientY);S.current={distance:We,scale:M}},lt=me=>{if(me.touches.length!==2||!S.current)return;me.preventDefault();const[ge,Oe]=[me.touches[0],me.touches[1]],We=Math.hypot(ge.clientX-Oe.clientX,ge.clientY-Oe.clientY),Be=(ge.clientX+Oe.clientX)/2,mt=(ge.clientY+Oe.clientY)/2,ut=S.current.scale*(We/Math.max(1,S.current.distance));He(ut,Be,mt)},ct=()=>{S.current=null,J(!1)};if(!w||!F)return null;const dt=G.enabled,Yt=G.animate?`transform ${$r}ms ${uu}`:"none";return gt.createPortal(t.jsxs("div",{className:"fixed inset-0",style:{zIndex:E},role:"dialog","aria-modal":"true","aria-label":v,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:C?1:0,transition:`opacity ${dt?$r:Ot}ms ${_t}`,cursor:"default",zIndex:0},onClick:()=>{u&&r()}}),t.jsx("div",{ref:ee,className:"absolute inset-0 flex items-center justify-center",style:{zIndex:1,padding:te?"4.5rem 3.5rem 6.5rem":"4.5rem 3.5rem 2.5rem",opacity:dt||C?1:0,transform:dt||C?"translateY(0) scale(1)":"translateY(10px) scale(0.96)",transition:dt?"none":`opacity ${Ot}ms ${_t}, transform ${Ot}ms ${_t}`},onClick:me=>{me.target===me.currentTarget&&u&&r()},onWheel:Ye,children:t.jsx("div",{className:"relative flex max-h-full max-w-full items-center justify-center will-change-transform",style:{transform:G.enabled?`translate3d(${G.dx}px, ${G.dy}px, 0) scale(${G.scale})`:void 0,transformOrigin:"center center",transition:G.enabled?Yt:void 0},children:t.jsx("div",{className:"relative flex max-h-full max-w-full items-center justify-center will-change-transform",style:{opacity:K.opacity,filter:K.blur?`blur(${K.blur}px)`:"blur(0px)",transform:`translate3d(${K.x}px, 0, 0) scale(${K.scale})`,transition:K.animate?[`opacity ${ro}ms ${no}`,`transform ${ro}ms ${no}`,`filter ${ro}ms ${no}`].join(", "):"none"},children:t.jsx("div",{ref:_,className:"pointer-events-auto relative max-h-full max-w-full touch-none select-none will-change-transform",style:{cursor:M>c+.001?"grab":"zoom-in",transform:`translate3d(${z.x}px, ${z.y}px, 0) scale(${M})`,transformOrigin:"center center",transition:ne?"none":`transform 220ms ${du}`},onClick:me=>me.stopPropagation(),onDoubleClick:ot,onPointerDown:ie,onPointerMove:Se,onPointerUp:_e,onPointerCancel:_e,onTouchStart:Ke,onTouchMove:lt,onTouchEnd:ct,children:t.jsx("img",{src:F.src,alt:F.alt||"",draggable:!1,className:"block max-h-[min(78vh,820px)] max-w-[min(86vw,1100px)] object-contain",style:{display:"block",borderRadius:oo,imageRendering:M>2.5?"pixelated":"auto"},onLoad:()=>{ue()}},F.src+String(re))})})})}),t.jsxs("div",{className:"pointer-events-none absolute inset-0",style:{zIndex:2,opacity:C?1:0,transform:C?"translateY(0)":"translateY(-6px)",transition:`opacity ${dt?$r:Ot}ms ${_t}, transform ${dt?$r:Ot}ms ${_t}`},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:ao,children:[re+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(Ar,{label:"Alejar",onClick:je,disabled:M<=c+.001,children:t.jsx(j.HiMinus,{className:"h-5 w-5"})}),t.jsx(Ar,{label:"Restablecer tamaño",onClick:se,disabled:Te,children:t.jsx(j.HiArrowsPointingIn,{className:"h-5 w-5"})}),t.jsx(Ar,{label:"Acercar",onClick:Xe,disabled:M>=T-.001,children:t.jsx(j.HiPlus,{className:"h-5 w-5"})})]}):null,t.jsx(Ar,{label:"Cerrar",onClick:r,children:t.jsx(j.HiXMark,{className:"h-5 w-5"})})]})]}),y?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"pointer-events-auto absolute left-3 top-1/2",style:{opacity:C?1:0,transform:C?"translate(0, -50%)":"translate(-8px, -50%)",transition:`opacity ${Ot}ms ${_t}, transform ${Ot}ms ${_t}`},children:t.jsx(Ar,{label:"Anterior",size:"lg",onClick:()=>fe(re-1),disabled:!g&&re<=0,children:t.jsx(j.HiChevronLeft,{className:"h-6 w-6"})})}),t.jsx("div",{className:"pointer-events-auto absolute right-3 top-1/2",style:{opacity:C?1:0,transform:C?"translate(0, -50%)":"translate(8px, -50%)",transition:`opacity ${Ot}ms ${_t}, transform ${Ot}ms ${_t}`},children:t.jsx(Ar,{label:"Siguiente",size:"lg",onClick:()=>fe(re+1),disabled:!g&&re>=n.length-1,children:t.jsx(j.HiChevronRight,{className:"h-6 w-6"})})})]}):null,te?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((me,ge)=>{const Oe=ge===re;return t.jsx("button",{type:"button",role:"tab","aria-selected":Oe,"aria-label":me.alt||`Imagen ${ge+1}`,onClick:We=>{We.stopPropagation(),fe(ge)},className:"relative shrink-0 overflow-hidden transition-opacity",style:{width:56,height:42,borderRadius:oo,opacity:Oe?1:.42,transition:`opacity 180ms ${_t}`},children:t.jsx("img",{src:me.src,alt:"",draggable:!1,className:"h-full w-full object-cover",style:{borderRadius:oo}})},`${me.src}-${ge}`)})})}):null]})]}),document.body)}function gu({children:e,className:r,style:n,maxZoom:a,minZoom:o,zoomStep:l,loop:i,showThumbnails:c}){const[d,u]=s.useState(!1),[m,b]=s.useState(0),[f,g]=s.useState([]),[p,E]=s.useState(null),v=s.useCallback((A,C,H)=>{g(A),E(H??null),b(C),u(!0)},[]),w=s.useCallback(A=>{Vs(A,v)},[v]);return t.jsxs(t.Fragment,{children:[t.jsx("div",{className:`[&_img]:cursor-zoom-in ${r??""}`,style:n,onClick:w,children:e}),t.jsx(Ys,{open:d,onClose:()=>u(!1),index:m,onIndexChange:b,slides:f,originRect:p,maxZoom:a,minZoom:o,zoomStep:l,loop:i,showThumbnails:c})]})}function Ks(e){if(e!==void 0)return typeof e=="number"?`${e}px`:e}function Gs(e,r){if(e.length!==r.length)return!1;const n=new Set(r);return e.every(a=>n.has(a))}function so(e){return e.normalize("NFD").replace(new RegExp("\\p{M}","gu"),"").toLowerCase()}function vu(e,r){if(!r)return!0;const n=so(r);return so(e.label).includes(n)||!!(e.sublabel&&so(e.sublabel).includes(n))}function xu({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:b=2,truncateSelectedValues:f=!0,selectedOverflowPopover:g=!0,emptyText:p="Sin resultados",clearLabel:E="Limpiar seleccion",pruneMissingValues:v=!0}){const[w,A]=s.useState(!1),[C,H]=s.useState(""),[k,x]=s.useState(0),[M,N]=s.useState(!1),[z,X]=s.useState({}),K=s.useRef(null),D=s.useRef(null),G=s.useRef(null),V=s.useRef(null),ne=u&&n.length>=m,J=s.useMemo(()=>new Set(e),[e]),R=s.useMemo(()=>{const y=new Map;for(const T of n)y.set(T.value,T);return y},[n]),U=s.useMemo(()=>{const y=[];for(const T of e){const te=R.get(T);te&&y.push(te)}return y},[R,e]),Y=b==="all"?U.length:b,ce=U.slice(0,Y),L=Math.max(0,U.length-ce.length),B=g&&U.length>1,le=t.jsxs("div",{className:"flex max-w-[280px] flex-col gap-1.5 py-0.5",children:[t.jsxs("div",{className:"text-[11px] font-semibold uppercase tracking-wide",style:{color:"var(--text-muted)"},children:[U.length," seleccionados"]}),t.jsx("ul",{className:"m-0 flex list-none flex-col gap-1 p-0",children:U.map(y=>t.jsxs("li",{className:"flex min-w-0 items-baseline gap-1.5 text-xs",style:{color:"var(--text-main)"},children:[y.color&&t.jsx("span",{className:"mt-1 h-1.5 w-1.5 flex-shrink-0 rounded-full",style:{background:y.color}}),t.jsx("span",{className:"min-w-0 break-words font-medium",children:y.label}),y.sublabel?t.jsx("span",{className:"min-w-0 break-words",style:{color:"var(--text-muted)"},children:y.sublabel}):null]},y.value))})]}),O=s.useMemo(()=>{const y=C.trim();return!ne||!y?n:n.filter(T=>vu(T,y))},[n,C,ne]),ae=s.useCallback(()=>{const y=K.current;if(!y)return;const T=y.getBoundingClientRect(),te=ne?304:244,fe=window.innerHeight-T.bottom,se=fe<te&&T.top>fe;X({position:"fixed",left:T.left,top:se?void 0:T.bottom+4,bottom:se?window.innerHeight-T.top+4:void 0,width:Math.max(T.width,240),zIndex:9999})},[ne]),S=s.useCallback(y=>{Gs(e,y)||r(y)},[r,e]),ee=s.useCallback(y=>{const T=R.get(y);if(T!=null&&T.disabled)return;const te=J.has(y)?e.filter(fe=>fe!==y):[...e,y];S(te)},[S,R,e,J]),_=s.useCallback(()=>S([]),[S]),I=s.useCallback(()=>{A(!1),H(""),x(0)},[]);s.useEffect(()=>N(!0),[]);const de=s.useMemo(()=>n.map(y=>y.value).join("\0"),[n]);s.useEffect(()=>{if(!v||e.length===0||n.length===0)return;const y=new Set(n.map(te=>te.value)),T=e.filter(te=>y.has(te));Gs(e,T)||r(T)},[de]),s.useEffect(()=>{if(!w)return;function y(T){var fe,se;const te=T.target;!((fe=K.current)!=null&&fe.contains(te))&&!((se=D.current)!=null&&se.contains(te))&&I()}return document.addEventListener("mousedown",y),()=>document.removeEventListener("mousedown",y)},[I,w]),s.useEffect(()=>{w&&(x(0),ae(),ne&&setTimeout(()=>{var y;return(y=G.current)==null?void 0:y.focus()},0))},[w,ne,ae]),s.useEffect(()=>{if(w)return window.addEventListener("resize",ae),window.addEventListener("scroll",ae,!0),()=>{window.removeEventListener("resize",ae),window.removeEventListener("scroll",ae,!0)}},[w,ae]),s.useEffect(()=>{if(O.length===0){x(0);return}x(y=>Math.min(y,O.length-1))},[O.length]),s.useEffect(()=>{if(k<0||!V.current)return;const y=V.current.children[k];y==null||y.scrollIntoView({block:"nearest"})},[k]);function re(y){if(!o){if(!w){(y.key==="Enter"||y.key===" "||y.key==="ArrowDown")&&(y.preventDefault(),A(!0));return}if(y.key==="Escape"){y.preventDefault(),I();return}if(y.key==="ArrowDown"){if(y.preventDefault(),O.length===0)return;x(T=>Math.min(T+1,O.length-1));return}if(y.key==="ArrowUp"){y.preventDefault(),x(T=>Math.max(T-1,0));return}if(y.key==="Enter"&&O[k]&&!O[k].disabled){y.preventDefault(),ee(O[k].value);return}y.key==="Backspace"&&!C&&e.length&&(y.preventDefault(),S(e.slice(0,-1)))}}const F=t.jsxs("div",{ref:D,className:"overflow-hidden rounded-xl shadow-xl",style:{...z,background:"var(--bg-card)",border:"1px solid var(--border)"},children:[ne&&t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",style:{borderBottom:"1px solid var(--border)"},children:[t.jsx(j.HiMagnifyingGlass,{className:"h-3.5 w-3.5 flex-shrink-0",style:{color:"var(--text-muted)"}}),t.jsx("input",{ref:G,value:C,onChange:y=>{H(y.target.value),x(0)},onKeyDown:y=>{(y.key==="ArrowDown"||y.key==="ArrowUp"||y.key==="Enter"||y.key==="Escape")&&(y.stopPropagation(),re(y))},placeholder:"Buscar…",className:"min-w-0 flex-1 bg-transparent text-sm outline-none",style:{color:"var(--text-main)"}}),C&&t.jsx("button",{type:"button","aria-label":"Limpiar búsqueda",onMouseDown:y=>{y.preventDefault(),H(""),x(0)},children:t.jsx(j.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:[U.length," seleccionados",e.length>U.length?` (${e.length-U.length} no disponibles)`:""]}),t.jsx("button",{type:"button",onMouseDown:y=>{y.preventDefault(),_()},className:"font-semibold transition-colors hover:text-[var(--primary)]",children:E})]}),t.jsxs("ul",{ref:V,role:"listbox","aria-multiselectable":"true",className:"overflow-y-auto",style:{maxHeight:ne?220:200,scrollbarWidth:"thin",scrollbarColor:"var(--border) transparent",overscrollBehavior:"contain"},children:[O.map((y,T)=>{const te=T===k,fe=J.has(y.value);return t.jsxs("li",{role:"option","aria-selected":fe,onMouseDown:se=>{se.preventDefault(),!y.disabled&&ee(y.value)},onMouseEnter:()=>!y.disabled&&x(T),className:"flex cursor-pointer items-center gap-2 px-3 py-2 text-sm transition-colors",style:{background:te?"var(--bg-hover)":fe?"color-mix(in srgb, var(--primary) 6%, transparent)":"transparent",color:y.disabled?"var(--text-muted)":"var(--text-main)",cursor:y.disabled?"not-allowed":"pointer",opacity:y.disabled?.58:1},children:[t.jsx("span",{className:"flex h-4 w-4 flex-shrink-0 items-center justify-center rounded border",style:{borderColor:fe?"var(--primary)":"var(--border)",background:fe?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:fe&&t.jsx(j.HiCheck,{className:"h-3 w-3"})}),y.color&&t.jsx("span",{className:"h-2.5 w-2.5 flex-shrink-0 rounded-full",style:{background:y.color}}),t.jsxs("span",{className:"flex min-w-0 flex-1 items-baseline gap-1 overflow-hidden",children:[t.jsx(Ut,{className:"min-w-0 flex-1",children:y.label}),y.sublabel&&t.jsx(Ut,{className:"min-w-0 flex-shrink",style:{color:"var(--text-muted)",fontSize:12},children:y.sublabel})]}),y.badge&&t.jsx("span",{className:"flex-shrink-0 text-xs",style:{color:"var(--text-muted)"},children:y.badge})]},y.value)}),O.length===0&&t.jsx("li",{className:"px-3 py-4 text-center text-sm",style:{color:"var(--text-muted)"},children:p})]})]});return t.jsxs("div",{ref:K,className:`relative ${l||"w-full"}`,style:i,onKeyDown:re,children:[t.jsxs("button",{type:"button",disabled:o,onClick:()=>{o||(w?I():A(!0))},className:"flex w-full items-center gap-2 rounded-lg text-left text-sm transition-colors focus:outline-none",style:{minHeight:Ks(c),padding:Ks(d),background:"var(--bg-input)",color:U.length?"var(--text-main)":"var(--text-muted)",border:w?"1px solid var(--primary)":"1px solid var(--border)",opacity:o?.5:1,cursor:o?"not-allowed":"pointer"},"aria-haspopup":"listbox","aria-expanded":w,children:[t.jsx("span",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-1.5 overflow-hidden",children:ce.length?(()=>{const y=t.jsxs(t.Fragment,{children:[ce.map(T=>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:[T.color&&t.jsx("span",{className:"h-1.5 w-1.5 flex-shrink-0 rounded-full",style:{background:T.color}}),f?t.jsx(Ut,{className:"min-w-0 flex-1",children:T.label}):t.jsx("span",{className:"break-words",children:T.label}),t.jsx("span",{role:"button",tabIndex:-1,"aria-label":`Quitar ${T.label}`,onMouseDown:te=>{te.preventDefault(),te.stopPropagation(),ee(T.value)},className:"flex-shrink-0 rounded-full p-0.5 transition-colors hover:bg-black/10",style:{color:"var(--text-muted)"},children:t.jsx(j.HiXMark,{className:"h-3 w-3"})})]},T.value)),L>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)"},"aria-label":`${L} seleccionados más`,children:["+",L]})]});return B?t.jsx(Bt,{as:"span",content:le,placement:"bottom",followCursor:!1,className:"flex min-w-0 flex-1 flex-wrap items-center gap-1.5 overflow-hidden",children:y}):y})():t.jsx("span",{className:"truncate",children:a})}),U.length?t.jsx("span",{role:"button",tabIndex:-1,"aria-label":E,onMouseDown:y=>{y.preventDefault(),y.stopPropagation(),_()},className:"flex-shrink-0 rounded-full p-0.5 transition-colors hover:bg-black/10",style:{color:"var(--text-muted)"},children:t.jsx(j.HiXMark,{className:"h-3.5 w-3.5"})}):t.jsx(j.HiChevronDown,{className:"h-4 w-4 flex-shrink-0 transition-transform",style:{color:"var(--text-muted)",transform:w?"rotate(180deg)":"rotate(0deg)"}})]}),w&&M&>.createPortal(F,document.body)]})}function yu({inputMode:e="decimal",...r}){return t.jsx(to,{...r,type:"number",inputMode:e})}function wu(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 Nu({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=wu(c,i,o);return t.jsxs("nav",{"aria-label":"Paginacion",className:`inline-flex items-center gap-1 ${l}`,children:[t.jsx(Qe,{variant:"icon",size:"xs","aria-label":"Pagina anterior",disabled:a||c<=1,onClick:()=>n(c-1),children:t.jsx(j.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(Qe,{variant:"icon",size:"xs","aria-label":"Pagina siguiente",disabled:a||c>=i,onClick:()=>n(c+1),children:t.jsx(j.HiChevronRight,{className:"h-4 w-4"})})]})}const Zs=[{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 Qs(e){return e==null?"":String(e)}function Wn(e){return e?e.startsWith("+")?e:`+${e}`:"+1"}function ku(e){return typeof e=="number"?`${e}px`:e}function Su({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:b,allowedCountryCodes:f,countryCodeOptions:g,countryCodePlaceholder:p="Codigo",countryCodeClassName:E="",countryCodeWidth:v=84,onPhoneValueChange:w,label:A,containerClassName:C="",helperText:H,helperDisplay:k="inline",labelAction:x,className:M="",required:N,disabled:z,floatingLabel:X,showPasswordToggle:K,nativeValidation:D,errorTooltipLabel:G="Error de validacion",...V}){var T;const[ne,J]=s.useState(()=>Qs(c)),[R,U]=s.useState(()=>Wn(m)),Y=s.useMemo(()=>{const te=g??Zs,fe=f==null?void 0:f.map(Wn);return fe!=null&&fe.length?te.filter(se=>fe.includes(se.value)):te},[f,g]),ce=((T=Y[0])==null?void 0:T.value)??"+1",L=Y.some(te=>te.value===Wn(u??R))?Wn(u??R):ce,B=i!==void 0?Qs(i):ne,le=`${L} ${B}`.trim(),O=n&&B.length>0&&!Ra(le)?a:void 0,ae=l??O,S=!!ae,ee=S&&o!=="tooltip",_=S&&o!=="inline",I=!!H&&k==="tooltip"&&!ee,de=S?"border-[var(--danger)] focus-within:border-[var(--danger)]":"border-[var(--border)] focus-within:border-[var(--primary)]",re=te=>{const fe=te.currentTarget.value;i===void 0&&J(fe),w==null||w(fe,{countryCode:L,nationalNumber:fe,fullNumber:`${L} ${fe}`.trim()}),d==null||d(te)},F=te=>{u===void 0&&U(te),b==null||b(te),w==null||w(B,{countryCode:te,nationalNumber:B,fullNumber:`${te} ${B}`.trim()})},y=_?t.jsx(Bt,{as:"span",content:ae,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":G,className:"flex h-full w-full items-center justify-center outline-none",children:t.jsx(js,{className:"h-[18px] w-[18px]"})})}):null;return t.jsxs("div",{className:`flex flex-col gap-2 ${C}`,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:A}),N&&t.jsx("span",{className:"text-[var(--danger)]",children:"*"}),I?t.jsx(Mr,{content:H}):null,x&&t.jsx("span",{className:"ml-auto normal-case",children:x})]}),t.jsxs("span",{className:`flex h-10 min-w-0 items-center overflow-hidden rounded-lg border bg-[var(--bg-input)] transition-colors ${de}`,children:[t.jsx(dr,{value:L,onChange:F,options:Y,placeholder:p,disabled:z,ariaLabel:"Codigo telefonico",triggerVariant:"ghost",showSelectedSublabel:!1,searchable:!0,minOptionsForSearch:0,dropdownMinWidth:300,className:`shrink-0 ${E}`,style:{width:ku(v)},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",{...V,value:i,defaultValue:c,type:"tel",inputMode:r,autoComplete:e,disabled:z,required:void 0,"aria-label":V["aria-label"]??(typeof A=="string"?A:void 0),"aria-invalid":S||V["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 ${_?"pr-10":""} ${M}`,onChange:re}),y]})]}),t.jsx(Tr,{error:ee?ae:void 0,helperText:H,helperDisplay:k})]})}function Eu({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,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 Cu=new Set(["table","thead","tbody","tfoot","tr","th","td","caption"]),jn=(e,r,n)=>Math.min(n,Math.max(r,Math.round(e)||r)),Lr=12,qn=8,lo=(e,r,n)=>{const a=Vn(n),o=e.insertRow(r);for(let l=0;l<a;l+=1){const i=o.insertCell(-1);i.innerHTML="<br>"}return o.cells[0]??null},Js=(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>=Lr?null:lo(l,0,e)}if(a.tagName==="TBODY"&&a.rows.length>=Lr)return null;const o=Array.from(a.rows).indexOf(n);return lo(a,o+1,e)},Mu=(e,r)=>{var o;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"&&((o=e.tBodies[0])==null?void 0:o.rows.length)===0&&e.rows.length<=1?!1:(n.remove(),!0)},Rs=(e,r)=>Vn(e)>=qn?!1:(e.querySelectorAll("tr").forEach(n=>{const a=n.closest("thead")!==null,o=document.createElement(a?"th":"td");a?o.textContent=`Columna ${n.cells.length+1}`:o.innerHTML="<br>";const l=n.cells[r];l!=null&&l.nextSibling?n.insertBefore(o,l.nextSibling):n.appendChild(o)}),!0),Tu=(e,r)=>Vn(e)<=1?!1:(e.querySelectorAll("tr").forEach(n=>{var a;(a=n.cells[r])==null||a.remove()}),!0),el=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")})},tl=(e,r,n)=>{el(e),r&&(r.classList.add("rich-table-row-active"),e.querySelectorAll("tr").forEach(a=>{var o;(o=a.cells[n])==null||o.classList.add("rich-table-col-active")}))},$u=(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}}},Un=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},rl=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")})},Au=(e,r,n,a,o)=>{switch(e){case"table-delete":return r.remove(),!0;case"table-row-add":{const l=Number.isFinite(n)?Js(r,n):io(r);return l&&Xn(l,o,!0),!!l}case"table-row-del":return Number.isFinite(n)?Mu(r,n):!1;case"table-col-add":return Number.isFinite(a)?Rs(r,a):Hu(r);case"table-col-del":return Number.isFinite(a)?Tu(r,a):!1;default:return!1}},Vn=e=>{let r=0;return e.querySelectorAll("tr").forEach(n=>{r=Math.max(r,n.cells.length)}),r||1},Lu=e=>{const r=e.tBodies[0]??e.createTBody();return Array.from(r.rows)},nl=e=>(e==null?void 0:e.closest("table"))??null,al=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},Du=e=>Array.from(e.querySelectorAll("th, td")),ol=(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),o=e.closest("tr");return!o||o!==a[a.length-1]?!1:e===o.cells[o.cells.length-1]},Ou=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()===""},Xn=(e,r,n=!0)=>{r==null||r.focus();const a=document.createRange();a.selectNodeContents(e),a.collapse(n);const o=window.getSelection();o==null||o.removeAllRanges(),o==null||o.addRange(a)},io=e=>{const r=Lu(e);if(r.length>=Lr)return null;const n=r[r.length-1];if(!n){const a=e.tBodies[0]??e.createTBody();return lo(a,0,e)}return Js(e,Array.from(e.rows).indexOf(n))},Hu=e=>{const r=Vn(e)-1;return r<0?!1:Rs(e,r)},co=e=>{rl(e)},Iu=(e,r,n)=>{const a=jn(e,1,Lr),o=jn(r,1,qn),l=n?`<thead><tr>${Array.from({length:o},(c,d)=>`<th>Columna ${d+1}</th>`).join("")}</tr></thead>`:"",i=Array.from({length:a},()=>`<tr>${Array.from({length:o},()=>"<td><br></td>").join("")}</tr>`).join("");return`<table class="rich-table">${l}<tbody>${i}</tbody></table><p><br></p>`},sl=()=>'<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>',ln=e=>e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'"),ll=e=>e.toLocaleLowerCase().replace(new RegExp("(^|[^\\p{L}\\p{N}])(\\p{L})","gu"),(r,n,a)=>`${n}${a.toLocaleUpperCase()}`),Bu=e=>e.replace(/[<>]/g,"").toLowerCase(),Fu=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"]),Pu=/^[\s\u00a0]*([•●○■▪▫◆◇►▶➢❖✓✔\-–—*])[\s\u00a0]+/,_u=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},Yn=(e,r)=>r.test(e),zu=e=>Yn(e,/font-weight\s*:\s*(bold|[6-9]00)/i),Wu=e=>Yn(e,/font-style\s*:\s*italic/i),ju=e=>Yn(e,/text-decoration(?:-line)?\s*:[^;]*underline/i),qu=e=>Yn(e,/text-decoration(?:-line)?\s*:[^;]*(line-through|linethrough)/i),Kn=(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)},Gn=e=>{const r=e.parentNode;if(!r){e.remove();return}for(;e.firstChild;)r.insertBefore(e.firstChild,e);r.removeChild(e)},Uu=e=>{const r=e.getAttribute("class")??"",n=e.getAttribute("style")??"";return/mso-list/i.test(n)||/MsoListParagraph/i.test(r)||/MsoList/i.test(r)},il=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(Pu,"").replace(/^\s*\d+[.)]\s+/,"").replace(/^\s*[a-zA-Z][.)]\s+/,"");a!==n.textContent&&(n.textContent=a)},Xu=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&&(zu(a)&&Kn(n,"strong"),Wu(a)&&Kn(n,"em"),ju(a)&&Kn(n,"u"),qu(a)&&Kn(n,"s"))})},Yu=e=>{const r=Array.from(e.querySelectorAll("p, div")).filter(Uu);if(!r.length)return;let n=0;for(;n<r.length;){const a=r[n],o=il(a),l=[a];let i=n+1;for(;i<r.length;){const u=r[i];if(il(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=>{Vu(u);const m=u.ownerDocument.createElement("li");for(;u.firstChild;)m.appendChild(u.firstChild);d.appendChild(m),u.remove()}),n=i}},Ku=e=>e==="h1"?"h2":e==="h4"||e==="h5"||e==="h6"?"h3":e==="div"?"p":e,Gu=e=>{const r=_u(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()),Xu(o),Yu(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"){Gn(d),c.forEach(l);return}if(!Fu.has(u)){Gn(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=Ku(u);if(m!==u){const b=d.ownerDocument.createElement(m);for(;d.firstChild;)b.appendChild(d.firstChild);d.replaceWith(b),l(b);return}if(Cu.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(),g=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(g)){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){Gn(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"){Gn(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(/ /gi," ").replace(/(<br\s*\/?>\s*){3,}/gi,"<br><br>").replace(/<p>(?:\s|<br\s*\/?>)*<\/p>/gi,"").trim()},uo=e=>ln(e).replace(/\r\n?/g,`
|
|
25
|
+
`).split(/\n{2,}/).map(r=>`<p>${r.replace(/\n/g,"<br>")||"<br>"}</p>`).join(""),Zu=e=>new RegExp("\\p{L}","u").test(e),fo=(e,r)=>{const n=e.trim();return!n||!Zu(n)?!1:r==="uppercase"?n===n.toLocaleUpperCase():r==="lowercase"?n===n.toLocaleLowerCase():n===ll(n)},cl=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",sl())}(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 dl({value:e,onChange:r,placeholder:n="Escribe algo...",minHeight:a="80px",instanceId:o,toolbarVariant:l="full"}){const i=s.useId(),c=o||i,d=s.useCallback(()=>document,[]),u=s.useRef(null),m=s.useRef(null),b=s.useRef(new Map),f=s.useRef(null),g=s.useRef(!1),p=s.useRef(e??""),E=s.useRef(r),v=s.useRef(()=>{}),w=s.useRef(!1),[A,C]=s.useState(()=>!e||e.trim()===""),[H,k]=s.useState(new Set),[x,M]=s.useState(null),[N,z]=s.useState(""),[X,K]=s.useState(""),[D,G]=s.useState(""),[V,ne]=s.useState(""),[J,R]=s.useState(3),[U,Y]=s.useState(3),[ce,L]=s.useState(!0),[B,le]=s.useState(!1),[O,ae]=s.useState(l==="full"),[S,ee]=s.useState(null),[_,I]=s.useState(null),de=s.useRef(null),re=s.useRef(!1),F=s.useRef(null),y=s.useCallback(()=>g.current?m.current:u.current,[]);s.useEffect(()=>{E.current=r},[r]);const T=s.useCallback(()=>{const W=window.getSelection(),Z=y();if(!W||!Z||W.rangeCount===0||W.isCollapsed)return"";const be=W.getRangeAt(0);return!Z.contains(be.startContainer)||!Z.contains(be.endContainer)?"":W.toString()},[y]);s.useEffect(()=>{const W=e??"";if(w.current&&W===p.current){w.current=!1,C(!W||W.trim()==="");return}w.current=!1,p.current=W;const Z=[u.current,m.current].filter(pe=>!!pe);Z.forEach(pe=>{pe.innerHTML!==W&&(pe.innerHTML=W)}),C(!W||W.trim()===""),Z.forEach(pe=>co(pe));const be=Z.map(pe=>cl(pe));return()=>be.forEach(pe=>pe())},[e]),s.useEffect(()=>{var pe,Ee;g.current=B;let W,Z=0,be;if(B){const xe=u.current;xe&&(p.current=Un(xe));const Fe=()=>{var Je;const Ie=m.current;if(!Ie){Z=requestAnimationFrame(Fe);return}Ie.innerHTML!==p.current&&(Ie.innerHTML=p.current),W=cl(Ie),co(Ie),C(((Je=Ie.textContent)==null?void 0:Je.trim())===""),be=setTimeout(()=>Ie.focus(),60)};Z=requestAnimationFrame(Fe)}else{const xe=m.current,Fe=u.current,Ie=xe?Un(xe):p.current,Je=p.current;p.current=Ie,Fe&&Fe.innerHTML!==Ie&&(Fe.innerHTML=Ie),Ie!==Je&&E.current(Ie),C(((Ee=(pe=xe??Fe)==null?void 0:pe.textContent)==null?void 0:Ee.trim())==="")}return()=>{Z&&cancelAnimationFrame(Z),be&&clearTimeout(be),W==null||W()}},[B]);const te=s.useCallback(()=>{const W=["bold","italic","underline","strikeThrough","insertUnorderedList","insertOrderedList","justifyLeft","justifyCenter","justifyRight","justifyFull"],Z=new Set;W.forEach(pe=>{try{d().queryCommandState(pe)&&Z.add(pe)}catch{return}});try{const pe=Bu(d().queryCommandValue("formatBlock"));pe&&Z.add(`formatBlock:${pe}`)}catch{}const be=T();fo(be,"uppercase")&&Z.add("__upper"),fo(be,"lowercase")&&Z.add("__lower"),fo(be,"capitalize")&&Z.add("__cap"),k(Z)},[T,d]),fe=()=>{var Z;const W=y();W&&(p.current=Un(W),w.current=!0,E.current(p.current),C(((Z=W.textContent)==null?void 0:Z.trim())===""))};v.current=fe;const se=s.useCallback(()=>{F.current&&(clearTimeout(F.current),F.current=null),de.current&&(el(de.current),de.current=null),re.current=!1,ee(null),I(null)},[]),he=s.useCallback(()=>{F.current&&(clearTimeout(F.current),F.current=null)},[]),Ae=s.useCallback(()=>{he(),F.current=setTimeout(()=>{re.current||se()},280)},[he,se]);s.useEffect(()=>()=>{F.current&&clearTimeout(F.current)},[]);const De=s.useCallback(W=>{const Z=de.current;if(!Z||!Z.isConnected){se();return}const be=(S==null?void 0:S.rowIndex)??(_==null?void 0:_.rowIndex)??-1,pe=(S==null?void 0:S.colIndex)??(_==null?void 0:_.colIndex)??-1;Au(W,Z,be,pe,y()),se(),v.current(),te()},[y,se,te,_,S]),ue=s.useCallback(W=>{if(_)return;const Z=W.currentTarget,be=W.target;if(be.closest(".rich-table-action-bar, .rich-table-context-menu")){he();return}const pe=be.closest("td, th");if(!pe||!Z.contains(pe)){Ae();return}const Ee=pe.closest("tr"),xe=pe.closest("table");if(!Ee||!xe||!Z.contains(xe)){Ae();return}he(),xe.classList.add("rich-table"),de.current=xe,tl(xe,Ee,pe.cellIndex),ee($u(xe,Ee,pe))},[he,Ae,_]),Te=s.useCallback(W=>{const Z=W.relatedTarget;if(Z instanceof Element&&(Z.closest(".rich-table-action-bar")||Z.closest(".rich-table-context-menu"))){he();return}Ae()},[he,Ae]),He=s.useCallback(W=>{const Z=W.currentTarget,pe=W.target.closest("td, th");if(!pe||!Z.contains(pe))return;const Ee=pe.closest("tr"),xe=pe.closest("table");if(!Ee||!xe||!Z.contains(xe))return;W.preventDefault(),xe.classList.add("rich-table"),de.current=xe;const Fe=Array.from(xe.rows).indexOf(Ee),Ie=pe.cellIndex;tl(xe,Ee,Ie),ee(null),I({x:W.clientX,y:W.clientY,rowIndex:Fe,colIndex:Ie})},[]);s.useEffect(()=>{if(!S&&!_)return;const W=()=>Ae();return window.addEventListener("scroll",W,!0),window.addEventListener("resize",W),()=>{window.removeEventListener("scroll",W,!0),window.removeEventListener("resize",W)}},[Ae,_,S]),s.useEffect(()=>{if(!_)return;const W=Z=>{const be=Z.target;be instanceof Element&&be.closest(".rich-table-context-menu")||I(null)};return window.addEventListener("mousedown",W),()=>window.removeEventListener("mousedown",W)},[_]);const Xe=W=>{if(!W){const Z=u.current;Z&&(p.current=Un(Z))}le(!W)},je=(W,Z)=>{var be;(be=y())==null||be.focus(),d().execCommand(W,!1,Z),fe(),te()},Ye=W=>{je("formatBlock",W)},ie=()=>{var W;(W=y())==null||W.focus(),d().execCommand("insertHTML",!1,"<hr><p><br></p>"),fe(),te()},Se=()=>{const W=window.getSelection();W&&W.rangeCount>0&&(f.current=W.getRangeAt(0).cloneRange())},_e=()=>{const W=window.getSelection();W&&f.current&&(W.removeAllRanges(),W.addRange(f.current))},ot=W=>{if(Se(),W==="link"){const Z=window.getSelection();K(Z&&!Z.isCollapsed?Z.toString():""),z("")}W==="image"&&(G(""),ne("")),W==="table"&&(R(3),Y(3),L(!0)),M(W)},Ke=()=>{var pe;if(!N.trim())return;_e(),(pe=y())==null||pe.focus();const W=window.getSelection(),be=(W&&!W.isCollapsed?W.toString():"")||X.trim()||N.trim();d().execCommand("insertHTML",!1,`<a href="${ln(N.trim())}" target="_blank" rel="noopener noreferrer" class="rich-link">${ln(be)}</a>`),fe(),M(null)},lt=(W,Z="")=>`<span class="rich-img-wrap" contenteditable="false"><img src="${ln(W)}" alt="${ln(Z)}" class="rich-img" />${sl()}</span>`,ct=()=>{var W;D.trim()&&(_e(),(W=y())==null||W.focus(),d().execCommand("insertHTML",!1,lt(D.trim(),V.trim())),fe(),M(null))},dt=()=>{var W;_e(),(W=y())==null||W.focus(),d().execCommand("insertHTML",!1,Iu(J,U,ce)),fe(),M(null)},Yt=(W,Z=1200,be=1200,pe=.72)=>new Promise((Ee,xe)=>{const Fe=new FileReader;Fe.onerror=xe,Fe.onload=Ie=>{var or;const Je=(or=Ie.target)==null?void 0:or.result,Re=new Image;Re.onerror=xe,Re.onload=()=>{let{width:xt,height:Kt}=Re;if(xt>Z||Kt>be){const Gt=Math.min(Z/xt,be/Kt);xt=Math.round(xt*Gt),Kt=Math.round(Kt*Gt)}const Ht=document.createElement("canvas");Ht.width=xt,Ht.height=Kt;const sr=Ht.getContext("2d");if(!sr){Ee(Je);return}sr.drawImage(Re,0,0,xt,Kt),Ee(Ht.toDataURL("image/jpeg",pe))},Re.src=Je},Fe.readAsDataURL(W)}),me=W=>{W.focus();const Z=window.getSelection();if(!Z||Z.rangeCount===0||!W.contains(Z.anchorNode)){const be=document.createRange();be.selectNodeContents(W),be.collapse(!1),Z==null||Z.removeAllRanges(),Z==null||Z.addRange(be)}},ge=s.useRef(()=>{});ge.current=W=>{const Z=y();Z&&(me(Z),d().execCommand("insertHTML",!1,W),co(Z),Z.querySelectorAll("p").forEach(be=>{!(be.textContent??"").replace(/[\u00a0\s]+/g,"")&&!be.querySelector("img, hr, table")&&be.remove()}),fe(),te())};const Oe=s.useRef(Yt);Oe.current=Yt;const We=s.useRef(lt);We.current=lt;const Be=s.useCallback(W=>{if(!W||b.current.has(W))return;const Z=be=>{const pe=be.clipboardData;if(!pe)return;const Ee=pe.getData("text/html"),xe=pe.getData("text/plain");if(Ee||xe){be.preventDefault(),be.stopPropagation();try{const Re=Ee?Gu(Ee):uo(xe);if(!Re){xe&&ge.current(uo(xe));return}ge.current(Re)}catch{xe&&ge.current(uo(xe))}return}const Ie=Array.from(pe.items).find(Re=>Re.type.startsWith("image/"));if(!Ie)return;be.preventDefault(),be.stopPropagation();const Je=Ie.getAsFile();Je&&Oe.current(Je).then(Re=>{ge.current(We.current(Re,"imagen"))})};W.addEventListener("paste",Z,!0),b.current.set(W,()=>{W.removeEventListener("paste",Z,!0),b.current.delete(W)})},[]),mt=s.useCallback(W=>{var be;const Z=u.current;Z&&Z!==W&&((be=b.current.get(Z))==null||be()),u.current=W,W&&Be(W)},[Be]),ut=s.useCallback(W=>{var be;const Z=m.current;Z&&Z!==W&&((be=b.current.get(Z))==null||be()),m.current=W,W&&Be(W)},[Be]);s.useEffect(()=>{const W=b.current;return()=>{W.forEach(Z=>Z()),W.clear()}},[]);const qe=W=>{const Z=window.getSelection(),be=y();if(!Z||!be||Z.rangeCount===0||Z.isCollapsed)return;const pe=Z.getRangeAt(0);if(!be.contains(pe.startContainer)||!be.contains(pe.endContainer))return;const Ee=pe.toString();if(!Ee)return;let xe=Ee;W==="uppercase"?xe=Ee.toLocaleUpperCase():W==="lowercase"?xe=Ee.toLocaleLowerCase():xe=ll(Ee),pe.deleteContents();const Fe=document.createTextNode(xe);pe.insertNode(Fe);const Ie=document.createRange();Ie.setStart(Fe,0),Ie.setEnd(Fe,xe.length),Z.removeAllRanges(),Z.addRange(Ie),f.current=Ie.cloneRange(),fe(),te()},Ve=()=>{Se(),te()},ft=()=>{const W=y();W&&rl(W),fe(),te()},ht=()=>{requestAnimationFrame(()=>{var W;(W=y())==null||W.focus()})},br=W=>{var Z,be;if((W.metaKey||W.ctrlKey)&&W.key==="Enter"){if(W.preventDefault(),W.stopPropagation(),W.repeat)return;(Z=y())==null||Z.focus(),d().execCommand("insertLineBreak",!1)||d().execCommand("insertHTML",!1,"<br>"),fe(),te();return}if(W.key==="Tab"){const pe=window.getSelection(),Ee=al((pe==null?void 0:pe.anchorNode)??null),xe=y(),Fe=nl(Ee);if(Ee&&Fe&&(xe!=null&&xe.contains(Ee))){W.preventDefault();const Ie=Du(Fe),Je=Ie.indexOf(Ee),Re=Je>=0?Ie[Je+1]:null;if(Re)Xn(Re,xe,!0);else if(ol(Ee,Fe)){const or=io(Fe);or&&Xn(or,xe,!0)}fe(),te();return}W.preventDefault(),(be=y())==null||be.focus(),d().execCommand("insertText",!1," "),fe(),te();return}if(W.key==="Enter"&&!W.shiftKey&&!(W.metaKey||W.ctrlKey)){const pe=window.getSelection(),Ee=al((pe==null?void 0:pe.anchorNode)??null),xe=y(),Fe=nl(Ee);if(Ee&&Fe&&(xe!=null&&xe.contains(Ee))&&ol(Ee,Fe)&&Ou(Ee)){W.preventDefault();const Ie=io(Fe);Ie&&Xn(Ie,xe,!0),fe(),te();return}}if(W.key==="Escape"){if(_){I(null);return}if(x){M(null);return}if(g.current){le(!1);return}}x||(W.ctrlKey||W.metaKey)&&(W.key==="b"&&(W.preventDefault(),je("bold")),W.key==="i"&&(W.preventDefault(),je("italic")),W.key==="u"&&(W.preventDefault(),je("underline")),W.key==="k"&&(W.preventDefault(),ot("link")))},bt=()=>t.jsx("div",{className:"h-4 w-px flex-shrink-0 mx-1",style:{background:"var(--border)"}}),ze=(W,Z,be,pe,Ee)=>{const xe=Ee??(H.has(be)||be==="__link"&&x==="link"||be==="__img"&&x==="image"||be==="__table"&&x==="table");return t.jsx("button",{type:"button",title:Z,tabIndex:-1,onFocus:ht,onMouseDown:Fe=>{Fe.preventDefault(),pe?pe():je(be)},className:"flex h-7 w-7 items-center justify-center rounded text-xs font-bold transition-colors",style:{color:xe?"var(--primary)":"var(--text-secondary)",background:xe?"rgba(59,130,246,0.12)":"transparent"},children:W},be)},vn=W=>{const Z=W.target;if(Z.closest("[data-action='delete-img']")){W.preventDefault();const be=Z.closest(".rich-img-wrap");be&&(be.remove(),fe())}},fa=()=>{he(),re.current=!0},pt=()=>{re.current=!1,Ae()},Mt=(W,Z,be,pe=!1)=>t.jsx("button",{type:"button",className:`rich-table-action-btn${pe?" rich-table-action-btn--danger":""}`,title:W,"aria-label":W,onMouseDown:Ee=>{Ee.preventDefault(),Ee.stopPropagation(),De(be)},children:Z}),Tt=()=>typeof document>"u"||!S&&!_?null:gt.createPortal(t.jsxs(t.Fragment,{children:[S&&!_&&t.jsxs("div",{className:"rich-table-action-bar",style:{left:S.bar.x,top:S.bar.y},onMouseEnter:fa,onMouseLeave:pt,children:[t.jsxs("span",{className:"rich-table-action-hint",children:["Fila ",S.rowIndex+1," · Col ",S.colIndex+1]}),t.jsxs("div",{className:"rich-table-action-group",children:[t.jsx("span",{className:"rich-table-action-label",children:"Fila"}),Mt("Añadir fila abajo","+","table-row-add"),Mt("Eliminar fila","−","table-row-del")]}),t.jsxs("div",{className:"rich-table-action-group",children:[t.jsx("span",{className:"rich-table-action-label",children:"Columna"}),Mt("Añadir columna a la derecha","+","table-col-add"),Mt("Eliminar columna","−","table-col-del")]}),Mt("Eliminar tabla","Eliminar","table-delete",!0)]}),_&&t.jsx("div",{className:"rich-table-context-menu",style:{left:_.x,top:_.y},onMouseDown:W=>W.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(([W,Z])=>t.jsx("button",{type:"button",onMouseDown:be=>{be.preventDefault(),De(Z)},children:W},Z))})]}),document.body),ar=W=>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:W},children:[t.jsx("input",{autoFocus:!0,type:"url",value:N,onChange:Z=>z(Z.target.value),onKeyDown:Z=>{Z.key==="Enter"&&(Z.preventDefault(),Ke()),Z.key==="Escape"&&M(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:X,onChange:Z=>K(Z.target.value),onKeyDown:Z=>{Z.key==="Enter"&&(Z.preventDefault(),Ke()),Z.key==="Escape"&&M(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:Ke,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:()=>M(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:W},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:Lr,value:J,onChange:Z=>R(jn(Number(Z.target.value),1,Lr)),onKeyDown:Z=>{Z.key==="Enter"&&(Z.preventDefault(),dt()),Z.key==="Escape"&&M(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:qn,value:U,onChange:Z=>Y(jn(Number(Z.target.value),1,qn)),onKeyDown:Z=>{Z.key==="Enter"&&(Z.preventDefault(),dt()),Z.key==="Escape"&&M(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:ce,onChange:Z=>L(Z.target.checked)}),"Encabezado"]}),t.jsx("button",{type:"button",onClick:dt,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:()=>M(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:W},children:[t.jsx("input",{autoFocus:!0,type:"url",value:D,onChange:Z=>G(Z.target.value),onKeyDown:Z=>{Z.key==="Enter"&&(Z.preventDefault(),ct()),Z.key==="Escape"&&M(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:V,onChange:Z=>ne(Z.target.value),onKeyDown:Z=>{Z.key==="Enter"&&(Z.preventDefault(),ct()),Z.key==="Escape"&&M(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:ct,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:()=>M(null),className:"rounded px-2 py-1 text-xs",style:{color:"var(--text-muted)"},children:"x"})]})]}),Wr=(W,Z)=>{const be=l==="compact",pe=!be||O||W;return 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:Z},"data-toolbar-variant":l,children:[be&&!W&&t.jsxs("button",{type:"button",title:O?"Ocultar herramientas":"Mostrar herramientas de formato",tabIndex:-1,onFocus:ht,onMouseDown:Ee=>{Ee.preventDefault(),ae(xe=>!xe)},className:"flex h-7 items-center gap-1 rounded px-1.5 text-[10px] font-semibold transition-colors",style:{color:"var(--text-secondary)",background:O?"color-mix(in srgb, var(--primary) 12%, transparent)":"transparent"},children:[O?t.jsx(j.HiChevronUp,{className:"h-3.5 w-3.5"}):t.jsx(j.HiChevronDown,{className:"h-3.5 w-3.5"}),O?"Ocultar herramientas":"Herramientas"]}),pe&&t.jsxs(t.Fragment,{children:[ze(t.jsx("b",{children:"B"}),"Negrita (Ctrl+B)","bold"),ze(t.jsx("i",{children:"I"}),"Cursiva (Ctrl+I)","italic"),ze(t.jsx("u",{children:"U"}),"Subrayado (Ctrl+U)","underline"),ze(t.jsx(j.HiListBullet,{className:"h-4 w-4"}),"Lista sin orden","insertUnorderedList"),ze(t.jsx(j.HiNumberedList,{className:"h-4 w-4"}),"Lista numerada","insertOrderedList"),ze(t.jsx(j.HiLink,{className:"h-4 w-4"}),"Insertar enlace (Ctrl+K)","__link",()=>ot("link")),bt(),ze(t.jsx(j.HiArrowUturnLeft,{className:"h-4 w-4"}),"Deshacer","undo"),ze(t.jsx(j.HiArrowUturnRight,{className:"h-4 w-4"}),"Rehacer","redo"),bt(),ze(t.jsx("span",{style:{fontSize:"10px"},children:"P"}),"Parrafo","__paragraph",()=>Ye("p"),H.has("formatBlock:p")||H.has("formatBlock:div")),ze(t.jsx(j.HiH2,{className:"h-4 w-4"}),"Titulo 2","__h2",()=>Ye("h2"),H.has("formatBlock:h2")),ze(t.jsx(j.HiH3,{className:"h-4 w-4"}),"Titulo 3","__h3",()=>Ye("h3"),H.has("formatBlock:h3")),ze(t.jsx("span",{style:{fontSize:"13px",lineHeight:1},children:"“"}),"Cita","__quote",()=>Ye("blockquote"),H.has("formatBlock:blockquote")),bt(),ze(t.jsx("s",{children:"S"}),"Tachado","strikeThrough"),bt(),ze(t.jsx(j.HiArrowTurnUpLeft,{className:"h-4 w-4"}),"Disminuir sangria","outdent"),ze(t.jsx(j.HiArrowTurnDownRight,{className:"h-4 w-4"}),"Aumentar sangria","indent"),bt(),ze(t.jsx(j.HiBars3BottomLeft,{className:"h-4 w-4"}),"Alinear izquierda","justifyLeft"),ze(t.jsx(j.HiBars3CenterLeft,{className:"h-4 w-4"}),"Centrar","justifyCenter"),ze(t.jsx(j.HiBars3BottomRight,{className:"h-4 w-4"}),"Alinear derecha","justifyRight"),ze(t.jsx(j.HiBars3,{className:"h-4 w-4"}),"Justificar","justifyFull"),bt(),ze(t.jsx("span",{style:{fontSize:"10px"},children:"AA"}),"Mayusculas","__upper",()=>qe("uppercase")),ze(t.jsx("span",{style:{fontSize:"10px"},children:"aa"}),"Minusculas","__lower",()=>qe("lowercase")),ze(t.jsx("span",{style:{fontSize:"10px"},children:"Aa"}),"Capitalizar","__cap",()=>qe("capitalize")),bt(),ze(t.jsx(j.HiLinkSlash,{className:"h-4 w-4"}),"Quitar enlace","unlink"),ze(t.jsx(j.HiPhoto,{className:"h-4 w-4"}),"Insertar imagen","__img",()=>ot("image")),ze(t.jsx(j.HiTableCells,{className:"h-4 w-4"}),"Insertar tabla","__table",()=>ot("table")),ze(t.jsx(j.HiMinus,{className:"h-4 w-4"}),"Insertar separador","__divider",ie),bt(),ze(t.jsx(j.HiOutlinePaintBrush,{className:"h-4 w-4"}),"Limpiar formato","removeFormat"),ze(t.jsx(j.HiNoSymbol,{className:"h-4 w-4"}),"Quitar bloque","__clearBlock",()=>Ye("p"))]}),bt(),t.jsx("button",{type:"button",title:W?"Salir del modo de enfoque (Esc)":"Modo de enfoque",tabIndex:-1,onFocus:ht,onMouseDown:Ee=>{Ee.preventDefault(),Xe(W)},className:"flex h-7 w-7 items-center justify-center rounded transition-colors",style:{color:"var(--text-secondary)"},children:W?t.jsx(j.HiArrowsPointingIn,{className:"h-4 w-4"}):t.jsx(j.HiArrowsPointingOut,{className:"h-4 w-4"})})]})};return t.jsxs(t.Fragment,{children:[Tt(),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:mt,contentEditable:!0,suppressContentEditableWarning:!0,"data-bonsaif-rich-instance":c,onInput:ft,onKeyDown:br,onKeyUp:Ve,onSelect:Ve,onMouseUp:Ve,onMouseMove:ue,onMouseLeave:Te,onContextMenu:He,onMouseDown:vn,"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"}}),ar("var(--bg-input)"),Wr(!1,"var(--bg-input)")]}),t.jsxs(Xa,{open:B,onClose:()=>le(!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:ut,contentEditable:!0,suppressContentEditableWarning:!0,"data-bonsaif-rich-instance":c,onInput:ft,onKeyDown:br,onKeyUp:Ve,onSelect:Ve,onMouseUp:Ve,onMouseMove:ue,onMouseLeave:Te,onContextMenu:He,onMouseDown:vn,"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"}}),ar("var(--bg-input)"),Wr(!0,"var(--bg-input)")]})]})}const ul="[a-zA-Z0-9._@-]+",bo=new RegExp(`@(${ul})`,"g"),Qu=/[a-zA-Z0-9._@-]/,cn=new Set([" ",`
|
|
26
|
+
`," ","\r"," ","(","[","{",".",",",";",":","!","?","¿","¡",")","]","}",'"',"'","«","»","/","\\","|","-","—","–"]);function fl(e,r){if(r<=0)return!0;const n=e[r-1]??"";return cn.has(n)}function bl(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(cn.has(c)||!Qu.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):fl(e,o)))continue;const i=e.slice(o+1,r);return i.length>0&&!new RegExp(`^${ul}$`).test(i)?null:{query:i,triggerIndex:o,caretIndex:r}}return null}function ml(e,r){var a;const n=Dr(e,r);return n?!!((a=n.node.parentElement)!=null&&a.closest(".mention-chip")):!1}function hl(e,r){if(r<=0)return!0;const n=Dr(e,r);if(!n){const o=yo(e);return fl(o,r)}if(n.offset>0){const o=n.node.data[n.offset-1]??"";return cn.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 cn.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 cn.has(l[l.length-1]??"")}a=a.previousSibling}return!0}function mo(e,r){const n=yo(e);return bl(n,r,{isTriggerBoundary:a=>hl(e,a),isInsideExistingMention:a=>ml(e,a)})}function ho(e){return e.toLowerCase().trim()}function pl(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(/ /g," ").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'").replace(/\s+/g," ").trim():""}function
|
|
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 g=f.data;for(let
|
|
30
|
-
`)&&d(f)==="matched")return!0;if(f.nodeType===Node.TEXT_NODE)return u(f);if(f.nodeType!==Node.ELEMENT_NODE)return!1;const h=f;if(h.tagName==="BR")return i(h,0),d(h.nextSibling??void 0)==="matched";const E=Array.from(f.childNodes);for(let v=0;v<E.length;v+=1){const S=E[v],A=v>0&&S.nodeType===Node.ELEMENT_NODE&&vl(S,e);if(m(S,A))return!0}return!1},b=Array.from(e.childNodes);for(let f=0;f<b.length;f+=1){const g=b[f],h=f>0&&g.nodeType===Node.ELEMENT_NODE&&vl(g,e);if(m(g,h))break}if((r==null?void 0:r.locatePlain)===n.length&&!a){const f=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_TEXT);let g=f.nextNode(),h=g;for(;h;)g=h,h=f.nextNode();g&&(a={node:g,offset:g.data.length})}return{plain:n,locate:a,domOffset:o}}function xo(e){return yo(e).plain}function Dr(e,r){return r<0?null:yo(e,{locatePlain:r}).locate??null}function Zn(e,r,n){return e!==r&&!e.contains(r)?-1:yo(e,{domPoint:{container:r,offset:n}}).domOffset??-1}function yl(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=pl({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 b=c.createTextNode(" "),f=c.createDocumentFragment();f.append(m,b),d.insertNode(f),dn(e),vo(m);const g=c.defaultView,h=g==null?void 0:g.getSelection(),E=h!=null&&h.rangeCount?Zn(e,h.getRangeAt(0).startContainer,h.getRangeAt(0).startOffset):n+u.length+1;return{caretPlainOffset:E>=0?E:n+u.length+1}}function xl(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 Qn(e){return e instanceof HTMLElement&&e.classList.contains("mention-chip")}function wl(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 Nl(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 Or(e=document){var r;(r=e.querySelectorAll)==null||r.call(e,".mention-chip.is-selected").forEach(n=>{n.classList.remove("is-selected")})}function Jn(e){var a;const r=(a=e.ownerDocument.defaultView)==null?void 0:a.getSelection();e.querySelectorAll(".mention-chip").forEach(o=>{let l=!1;if(r&&r.rangeCount>0)try{const i=r.getRangeAt(0);(!r.isCollapsed&&i.intersectsNode(o)||r.isCollapsed&&i.startContainer===o&&i.endContainer===o)&&(l=!0)}catch{l=!1}o.classList.toggle("is-selected",l)})}function kl(e){var o;const r=e.ownerDocument,n=(o=r.defaultView)==null?void 0:o.getSelection();if(!n)return;const a=r.createRange();a.selectNodeContents(e),n.removeAllRanges(),n.addRange(a),Jn(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 El(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(),Or(e),!0):!1}function Rn(e){var m,b;const r=e.ownerDocument,n=e.parentNode;if(!n)return;const a=(f,g)=>{let h=f;for(;h&&h.nodeType===Node.TEXT_NODE&&(h.textContent??"")==="";){const E=h;h=h[g],E.remove()}return h},o=a(e.nextSibling,"nextSibling");if(o&&o.nodeType===Node.TEXT_NODE&&/^( |\u00a0)/.test(o.textContent??"")){const f=o;(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 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:o}=n;if(a.nodeType===Node.TEXT_NODE){const i=a.textContent??"",c=wl(a.previousSibling,"prev");return Qn(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(Qn(d))return d;if(d.nodeType===Node.TEXT_NODE&&!(d.textContent??"").replace(/\u00a0/g," ").trim()){c-=1;continue}break}}return null}function Ml(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=wl(a.nextSibling,"next");if(Qn(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(Qn(d))return d;if(d.nodeType===Node.TEXT_NODE&&!(d.textContent??"").replace(/\u00a0/g," ").trim()){c+=1;continue}break}}return null}function wo(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 No=420,ea=6,Tl=260,ef=new Set(["ArrowDown","ArrowUp","Enter","Tab","Escape"]),$l=4,tf={position:"relative"},rf={position:"fixed",zIndex:11050,minWidth:Tl,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},Al={padding:"10px 12px",fontSize:12,color:"var(--text-muted, #656d76)"};function nf(e){return Array.from(document.querySelectorAll(`[data-bonsaif-rich-instance="${CSS.escape(e)}"]`))}function af(e){const r=Math.max(8,Math.min(e.left,window.innerWidth-Tl-8)),n=window.innerHeight-e.bottom-ea-8,a=e.top-ea-8;return n<Math.min(No,180)&&a>n?{left:r,bottom:window.innerHeight-e.top+ea,maxHeight:Math.min(No,Math.max(120,a))}:{left:r,top:e.bottom+ea,maxHeight:Math.min(No,Math.max(120,n))}}function Ll({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="",toolbarVariant:b="full"}){const f=s.useId().replace(/:/g,""),g=s.useRef(null),h=s.useRef(null),E=s.useRef(new Map),v=s.useRef(n);v.current=n;const S=s.useRef(null),A=s.useRef(0),C=s.useRef([]),O=s.useRef(null),[N,y]=s.useState(null),[M,k]=s.useState([]),[_,Y]=s.useState(0),[K,D]=s.useState([]),[G,U]=s.useState(!1),[ne,J]=s.useState(!1);A.current=_,s.useEffect(()=>{J(!0)},[]);const R=(N==null?void 0:N.query)??null;s.useEffect(()=>{if(R===null){k([]);return}const w=R.trim(),te=`${m}|${w.toLowerCase()||"*"}`,B=E.current.get(te);if(B){k(B),U(!1),Y(0);return}const F=new AbortController;U(!0);const ue=window.setTimeout(()=>{(async()=>{try{const re=await v.current(w,{signal:F.signal,limit:c});if(F.signal.aborted)return;const j=Array.isArray(re)?re:[];E.current.set(te,j),k(j),Y(0)}catch{F.signal.aborted||k([])}finally{F.signal.aborted||U(!1)}})()},d);return()=>{F.abort(),window.clearTimeout(ue)}},[R,c,d,m]);const V=s.useRef(a);V.current=a,s.useEffect(()=>{var w;(w=V.current)==null||w.call(V,hl(K))},[K]);const X=s.useCallback(()=>{const w=nf(f);if(w.length===0)return null;const te=window.getSelection();if(te!=null&&te.rangeCount){const F=te.getRangeAt(0).startContainer;for(const ue of w)if(ue.contains(F))return ue}const B=document.activeElement;for(const F of w)if(B===F||B&&F.contains(B))return F;for(const F of w)if(F.closest('[role="dialog"]'))return F;return w[0]??null},[f]),de=s.useCallback(()=>{const w=X(),te=window.getSelection();if(!w||!te||te.rangeCount===0){y(null);return}const B=te.getRangeAt(0);if(!w.contains(B.startContainer)){y(null);return}const F=Zn(w,B.startContainer,B.startOffset);if(F<0){y(null);return}const ue=mo(w,F);if(!ue){y(null);return}const re=B.getBoundingClientRect(),j=re.width===0&&re.height===0?(()=>{const T=document.createRange();return T.selectNodeContents(B.startContainer),T.collapse(!0),T.getBoundingClientRect()})():re;S.current={query:ue.query,caretIndex:ue.caretIndex,triggerIndex:ue.triggerIndex};const x=af(j);y(T=>{const ee={query:ue.query,...x};return T&&T.query===ee.query&&T.top===ee.top&&T.bottom===ee.bottom&&T.left===ee.left&&T.maxHeight===ee.maxHeight?T:ee})},[X]),H=s.useCallback(w=>{r(w),de()},[r,de]);s.useEffect(()=>{const w=te=>{if(ef.has(te.key))return;const B=X(),F=te.target;!B||!F||!B.contains(F)||de()};return document.addEventListener("keyup",w,!0),()=>document.removeEventListener("keyup",w,!0)},[X,de]);const I=s.useCallback(w=>{const te=X();if(!te)return;let B=-1;const F=window.getSelection();if(F&&F.rangeCount>0){const T=F.getRangeAt(0);te.contains(T.startContainer)&&(B=Zn(te,T.startContainer,T.startOffset))}if(B<0&&S.current&&(B=S.current.caretIndex),B<0)return;const ue=mo(te,B);if(!ue)return;const re=yl(te,{triggerIndex:ue.triggerIndex,caretIndex:B,username:w.username,display:w.name,userId:w.userId});if(!re)return;dn(te),te.dispatchEvent(new InputEvent("input",{bubbles:!0,cancelable:!0}));const j={userId:w.userId,username:w.username,email:w.email??void 0,display:w.name??w.username};D(T=>{const ee=new Map(T.map(fe=>[fe.userId,fe]));return ee.set(j.userId,j),Array.from(ee.values())}),y(null),S.current=null;const x=w.username.toLowerCase();requestAnimationFrame(()=>{requestAnimationFrame(()=>{const T=X();if(!T)return;T.focus(),dn(T);const ee=Array.from(T.querySelectorAll(".mention-chip")),fe=[...ee].reverse().find(ie=>ie.getAttribute("data-username")===x)??ee[ee.length-1];if(fe){vo(fe);return}xl(T,re.caretPlainOffset)})})},[X]);s.useEffect(()=>{const w=new Set(ho(e).map(te=>te.toLowerCase()));D(te=>{const B=te.filter(F=>w.has(F.username.toLowerCase()));return B.length===te.length?te:B})},[e]),s.useEffect(()=>{if(!N)return;const w=te=>{const B=te.target;if(!B||g.current&&g.current.contains(B)||h.current&&h.current.contains(B))return;const F=X();F&&F.contains(B)||y(null)};return document.addEventListener("mousedown",w),()=>{document.removeEventListener("mousedown",w)}},[N,X]);const le=s.useMemo(()=>M.slice(0,c),[M,c]);C.current=le,s.useEffect(()=>{if(!N)return;const w=te=>{const B=X(),F=te.target;if(!B||!F||!B.contains(F))return;const ue=C.current;if(!(ue.length===0&&te.key!=="Escape"))if(te.key==="ArrowDown")te.preventDefault(),te.stopPropagation(),Y(re=>(re+1)%Math.max(ue.length,1));else if(te.key==="ArrowUp")te.preventDefault(),te.stopPropagation(),Y(re=>(re-1+ue.length)%Math.max(ue.length,1));else if(te.key==="Enter"||te.key==="Tab"){const re=ue[A.current];re&&(te.preventDefault(),te.stopPropagation(),I(re))}else te.key==="Escape"&&(te.preventDefault(),te.stopPropagation(),y(null))};return document.addEventListener("keydown",w,!0),()=>document.removeEventListener("keydown",w,!0)},[X,I,N]),s.useEffect(()=>{const w=j=>{j.dispatchEvent(new InputEvent("input",{bubbles:!0,cancelable:!0}))},te=j=>{const x=X(),T=j.target;if(!x||!T||!x.contains(T))return;if((j.metaKey||j.ctrlKey)&&j.key.toLowerCase()==="a"){j.preventDefault(),j.stopPropagation(),x.focus(),kl(x);return}if(j.key!=="Backspace"&&j.key!=="Delete")return;const ee=window.getSelection();if(ee&&!ee.isCollapsed&&ee.rangeCount>0){const pe=ee.getRangeAt(0);if(x.contains(pe.commonAncestorContainer)&&wo(x).length>0&&Sl(pe)){j.preventDefault(),j.stopPropagation(),El(x)&&w(x);return}}const fe=wo(x);if(fe.length>0){j.preventDefault(),j.stopPropagation();for(const pe of fe)Rn(pe);Or(x),w(x);return}if(j.key==="Backspace"){const pe=Cl(x);if(!pe)return;j.preventDefault(),j.stopPropagation(),Rn(pe),Or(x),w(x);return}const ie=Ml(x);ie&&(j.preventDefault(),j.stopPropagation(),Rn(ie),Or(x),w(x))},B=j=>{const x=X();if(!x)return;const T=j.target;if(!(T instanceof Element)||!x.contains(T))return;const ee=T.closest(".mention-chip");if(!(ee instanceof HTMLElement)||!x.contains(ee)){O.current=null,Or(x);return}j.shiftKey||j.button!==0||(O.current={chip:ee,x:j.clientX,y:j.clientY})},F=j=>{const x=O.current;if(!x)return;const T=Math.abs(j.clientX-x.x),ee=Math.abs(j.clientY-x.y);(T>$l||ee>$l)&&(O.current=null)},ue=j=>{var ie;const x=X(),T=O.current;if(O.current=null,!x||!T)return;const ee=j.target;if(!(ee instanceof Element)||!x.contains(ee)||!((ie=ee.closest(".mention-chip"))!=null&&ie.isSameNode(T.chip)))return;const fe=window.getSelection();if(fe){if(!fe.isCollapsed){Jn(x);return}x.focus(),Nl(T.chip)}},re=()=>{const j=X();if(!j)return;const x=window.getSelection();!x||x.rangeCount===0||!x.anchorNode||!j.contains(x.anchorNode)||!x.focusNode||!j.contains(x.focusNode)||Jn(j)};return document.addEventListener("keydown",te,!0),document.addEventListener("mousedown",B,!0),document.addEventListener("mousemove",F,!0),document.addEventListener("mouseup",ue,!0),document.addEventListener("selectionchange",re),()=>{document.removeEventListener("keydown",te,!0),document.removeEventListener("mousedown",B,!0),document.removeEventListener("mousemove",F,!0),document.removeEventListener("mouseup",ue,!0),document.removeEventListener("selectionchange",re)}},[X]),s.useEffect(()=>{if(!N||!h.current)return;const w=h.current.querySelector(`[data-mention-index="${_}"]`);w==null||w.scrollIntoView({block:"nearest"})},[_,N]);const L=u?gl(e):e,oe=N&&ne?ht.createPortal(t.jsxs("ul",{ref:h,style:{...rf,left:N.left,top:N.top,bottom:N.bottom,maxHeight:N.maxHeight},role:"listbox","aria-label":"Menciones sugeridas",children:[G&&le.length===0&&t.jsx("li",{style:Al,children:"Buscando…"}),!G&&le.length===0&&t.jsx("li",{style:Al,children:N.query.trim().length===0?"Escribe un nombre o usuario":`Sin coincidencias para “${N.query}”`}),le.map((w,te)=>{var B,F;return t.jsx("li",{children:t.jsxs("button",{type:"button","data-mention-index":te,onMouseDown:ue=>{ue.preventDefault(),I(w)},onMouseEnter:()=>Y(te),style:{width:"100%",textAlign:"left",padding:"8px 10px",border:"none",background:te===_?"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:((B=w.name)==null?void 0:B.trim())||`@${w.username}`}),t.jsx("span",{style:{fontSize:11,color:"var(--text-muted, #656d76)"},children:[(F=w.name)!=null&&F.trim()?`@${w.username}`:null,w.email].filter(Boolean).join(" · ")||`@${w.username}`})]})},w.userId)})]}),document.body):null;return t.jsxs("div",{ref:g,style:tf,className:i,children:[t.jsx(il,{value:L,onChange:H,placeholder:l,minHeight:o,instanceId:f,toolbarVariant:b}),oe]})}function of({value:e,onChange:r,placeholder:n,minHeight:a,onSearchUsers:o,onMentionsChange:l,className:i,maxSuggestions:c,searchDebounceMs:d,highlightInEditor:u,searchCacheKey:m,toolbarVariant:b}){return o?t.jsx(Ll,{value:e,onChange:r,onSearchUsers:o,onMentionsChange:l,placeholder:n,minHeight:a,className:i,maxSuggestions:c,searchDebounceMs:d,highlightInEditor:u,searchCacheKey:m,toolbarVariant:b}):t.jsx(il,{value:e,onChange:r,placeholder:n,minHeight:a,toolbarVariant:b})}function sf({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 lf={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)"}},cf={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 df({children:e,tone:r="neutral",size:n="sm",icon:a,dot:o=!1,className:l=""}){const i=lf[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 ${cf[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 Dl={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)"}},uf={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"},ff={xs:"right-1 h-3 w-3",sm:"right-1.5 h-3 w-3",md:"right-2 h-3.5 w-3.5"},bf={xs:148,sm:164,md:184},mf={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 pf({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:b,optionClassName:f,spinnerClassName:g}){const[h,E]=s.useState(!1),[v,S]=s.useState(!1),[A,C]=s.useState(-1),[O,N]=s.useState({}),y=s.useRef(null),M=s.useRef(null),k=s.useRef(null),_=r.find(V=>V.value===e)??r[0],Y={..._!=null&&_.tone?Dl[_.tone]:void 0,..._==null?void 0:_.style},K=o||l||r.length===0,D=V=>{i&&V.stopPropagation()},G=s.useCallback(()=>{E(!1),C(-1)},[]),U=s.useCallback(()=>{const V=y.current;if(!V)return;const X=V.getBoundingClientRect(),de=Math.max(X.width,bf[a]),H=Math.min(Math.max(r.length,1)*38+12,260),I=window.innerHeight-X.bottom,le=I<H&&X.top>I,L=Math.min(Math.max(8,X.left+X.width/2-de/2),window.innerWidth-de-8);N({position:"fixed",left:L,top:le?void 0:X.bottom+6,bottom:le?window.innerHeight-X.top+6:void 0,width:de,zIndex:9999})},[r.length,a]),ne=s.useCallback(V=>{V.disabled||(n(V.value),G())},[G,n]);s.useEffect(()=>S(!0),[]),s.useEffect(()=>{if(!h)return;U();const V=r.findIndex(X=>X.value===e);C(V>=0?V:0)},[h,r,U,e]),s.useEffect(()=>{if(!h)return;function V(X){var H,I;const de=X.target;!((H=y.current)!=null&&H.contains(de))&&!((I=M.current)!=null&&I.contains(de))&&G()}return document.addEventListener("mousedown",V),()=>document.removeEventListener("mousedown",V)},[G,h]),s.useEffect(()=>{if(h)return window.addEventListener("resize",U),window.addEventListener("scroll",U,!0),()=>{window.removeEventListener("resize",U),window.removeEventListener("scroll",U,!0)}},[h,U]),s.useEffect(()=>{if(A<0||!k.current)return;const V=k.current.children[A];V==null||V.scrollIntoView({block:"nearest"})},[A]);function J(V){if(!K){if(!h){["Enter"," ","ArrowDown","ArrowUp"].includes(V.key)&&(V.preventDefault(),E(!0));return}if(V.key==="Escape"){V.preventDefault(),G();return}if(V.key==="ArrowDown"){V.preventDefault(),C(X=>Math.min(X+1,r.length-1));return}if(V.key==="ArrowUp"){V.preventDefault(),C(X=>Math.max(X-1,0));return}if(V.key==="Enter"||V.key===" "){V.preventDefault();const X=r[A];X&&ne(X)}}}const R=t.jsx("div",{ref:M,role:"listbox","aria-label":c,className:Zt("overflow-hidden rounded-xl border shadow-xl backdrop-blur-md",b),style:{...O,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:k,className:"max-h-64 overflow-y-auto p-1",style:{scrollbarWidth:"thin",scrollbarColor:"var(--border) transparent",overscrollBehavior:"contain"},children:r.map((V,X)=>{const de=V.value===e,H=X===A,I={...V.tone?Dl[V.tone]:void 0,...V.style};return t.jsxs("button",{type:"button",role:"option","aria-selected":de,disabled:V.disabled,onMouseEnter:()=>!V.disabled&&C(X),onMouseDown:le=>{le.preventDefault(),ne(V)},className:Zt("flex w-full items-center gap-2 rounded-lg font-medium text-left transition-colors disabled:cursor-not-allowed disabled:opacity-45",mf[a],de?V.className:void 0,f),style:{...de?I:void 0,background:de?I.background??"color-mix(in srgb, var(--primary) 12%, transparent)":H?"var(--bg-hover)":"transparent",color:de?I.color??"var(--primary)":"var(--text-main)"},children:[t.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center",children:de?t.jsx(W.HiCheck,{className:"h-4 w-4"}):null}),t.jsx("span",{className:"min-w-0 flex-1 truncate",children:V.label})]},V.value)})})});return t.jsxs("span",{ref:y,className:Zt("relative inline-flex shrink-0 items-center",u),onKeyDown:J,onClick:D,onPointerDown:D,children:[t.jsx("button",{type:"button",disabled:K,"aria-label":c,"aria-haspopup":"listbox","aria-expanded":h,title:d,onClick:()=>!K&&E(V=>!V),className:Zt("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",uf[a],_==null?void 0:_.className,m),style:Y,children:t.jsx("span",{className:"min-w-0 truncate",children:(_==null?void 0:_.label)??e})}),t.jsx(W.HiChevronDown,{"aria-hidden":"true",className:Zt("pointer-events-none absolute opacity-70 transition-transform",ff[a],h?"rotate-180":"rotate-0")}),l&&t.jsx("span",{"aria-hidden":"true",className:Zt("absolute -right-1 -top-1 h-2.5 w-2.5 rounded-full border border-current border-t-transparent animate-spin",g)}),h&&v&&ht.createPortal(R,document.body)]})}function hf({tabs:e,activeTabId:r,defaultActiveTabId:n,onTabChange:a,ariaLabel:o="Pestanas",variant:l="underline",className:i="",listClassName:c="",panelClassName:d=""}){const u=e.find(h=>!h.disabled)??e[0],m=r??n??(u==null?void 0:u.id),b=e.find(h=>h.id===m)??u,f=h=>{h.disabled||a==null||a(h.id)},g=h=>{const E=e.filter(S=>!S.disabled);if(!E.length||!b)return;const v=E.findIndex(S=>S.id===b.id);(h.key==="ArrowRight"||h.key==="ArrowDown")&&(h.preventDefault(),f(E[(v+1)%E.length])),(h.key==="ArrowLeft"||h.key==="ArrowUp")&&(h.preventDefault(),f(E[(v-1+E.length)%E.length])),h.key==="Home"&&(h.preventDefault(),f(E[0])),h.key==="End"&&(h.preventDefault(),f(E[E.length-1]))};return t.jsxs("div",{className:i,children:[t.jsx("div",{role:"tablist","aria-label":o,onKeyDown:g,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(h=>{const E=h.id===(b==null?void 0:b.id);return t.jsxs("button",{type:"button",role:"tab","aria-selected":E,"aria-controls":`${h.id}-panel`,id:`${h.id}-tab`,disabled:h.disabled,tabIndex:E?0:-1,onClick:()=>f(h),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:[h.icon&&t.jsx("span",{className:"shrink-0",children:h.icon}),t.jsx("span",{children:h.label}),h.badge&&t.jsx("span",{className:"shrink-0",children:h.badge})]},h.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 tr(...e){return e.filter(Boolean).join(" ")}function gf({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:b="Siguiente",blockedNextLabel:f="Completa este paso",className:g="",headerClassName:h="",contentClassName:E="",footerClassName:v=""}){var B;const S=((B=e[0])==null?void 0:B.id)??"",[A,C]=s.useState(n??S),[O,N]=s.useState(o),y=r??A,M=a??O,k=s.useMemo(()=>new Set(M),[M]),_=Math.max(0,e.findIndex(F=>F.id===y)),Y=e[_]??e[0],K=e.length<=1?100:_/(e.length-1)*100,D=F=>{a||N(F),i==null||i(F)},G=F=>{const ue=e.find(re=>re.id===F);ue&&(r||C(F),l==null||l(F,ue))},U=F=>k.has(F),ne=F=>e.slice(0,F).find(ue=>!ue.optional&&!k.has(ue.id)),J=F=>{const ue=e[F];return!ue||ue.disabled?!1:F===_||d&&F<_?!0:!ne(F)},R=F=>{const ue=e.findIndex(re=>re.id===F);return ue>=0&&J(ue)},V=F=>{const ue=e.findIndex(re=>re.id===F);if(ue<0)return!1;if(!J(ue)){const re=ne(ue);return re&&(c==null||c(e[ue],re)),!1}return G(F),!0},X=(F=Y==null?void 0:Y.id)=>{!F||k.has(F)||D([...M,F])},de=(F=Y==null?void 0:Y.id)=>{if(!F)return;const ue=e.findIndex(j=>j.id===F),re=M.filter(j=>{const x=e.findIndex(T=>T.id===j);return x>=0&&x<ue});D(re),ue>=0&&_>ue&&G(F)},H=()=>_<=0?!1:V(e[_-1].id),I=()=>{const F=e[_+1];return F?V(F.id):!1},le={activeStep:Y,activeIndex:_,completedStepIds:M,isCompleted:U,isUnlocked:R,completeStep:X,uncompleteStep:de,goToStep:V,goNext:I,goPrevious:H};if(!Y)return null;const L=e[_+1],oe=_>0,w=L?R(L.id):!1,te=typeof Y.content=="function"?Y.content(le):Y.content;return t.jsxs("section",{className:tr("overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)]",g),children:[t.jsxs("div",{className:tr("border-b border-[var(--border)] bg-[var(--bg-input)]",h),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:`${K}%`}})}),t.jsx("div",{className:"grid gap-2 p-2",style:{gridTemplateColumns:`repeat(${e.length}, minmax(0, 1fr))`},children:e.map((F,ue)=>{const re=F.id===Y.id,j=U(F.id),x=J(ue),T=ne(ue);return t.jsxs("button",{type:"button",disabled:!x,"aria-current":re?"step":void 0,"aria-disabled":!x,title:!x&&T?`Completa ${T.title}`:F.title,onClick:()=>V(F.id),className:tr("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",re&&"border-[var(--primary)] bg-[var(--bg-card)] shadow-sm",j&&!re&&"border-[var(--primary)]/35 bg-[var(--bg-card)]",!re&&!j&&x&&"border-transparent bg-[var(--bg-card)]/45 hover:border-[var(--border)] hover:bg-[var(--bg-card)]",!x&&"border-transparent bg-[var(--bg-card)]/35 opacity-60"),children:[t.jsx("span",{className:tr("absolute inset-x-0 top-0 h-0.5 origin-left scale-x-0 bg-[var(--primary)] transition-transform duration-300",re&&"scale-x-100")}),t.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[t.jsx("span",{className:tr("grid h-7 w-7 shrink-0 place-items-center rounded-full border text-xs font-bold transition-all duration-200",re&&"border-[var(--primary)] bg-[var(--primary)] text-[var(--primary-fg)]",j&&!re&&"border-[var(--primary)] bg-[var(--primary)]/12 text-[var(--primary)]",!j&&!re&&x&&"border-[var(--border)] text-[var(--text-muted)]",!x&&"border-[var(--border)] text-[var(--text-muted)]"),children:j?t.jsx(W.HiCheck,{className:"h-4 w-4"}):x?ue+1:t.jsx(W.HiLockClosed,{className:"h-3.5 w-3.5"})}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsxs("span",{className:tr("block truncate text-xs font-semibold transition-colors duration-200",re?"text-[var(--text-main)]":"text-[var(--text-secondary)]"),children:[ue+1,". ",F.title]}),F.description&&t.jsx("span",{className:"mt-1 block truncate text-[11px] text-[var(--text-muted)]",children:F.description})]}),F.badge&&t.jsx("span",{className:"shrink-0",children:F.badge})]})]},F.id)})})]}),t.jsx("div",{className:tr("min-h-72 animate-[stepWizardIn_220ms_ease-out] p-5",E),children:te},Y.id),u&&t.jsxs("div",{className:tr("flex flex-wrap items-center justify-between gap-3 border-t border-[var(--border)] bg-[var(--bg-input)] px-4 py-3",v),children:[t.jsx(Ve,{variant:"secondary",height:38,padding:"0 14px",icon:t.jsx(W.HiChevronLeft,{}),disabled:!oe,onClick:H,children:m}),t.jsxs("div",{className:"flex items-center gap-3 text-xs text-[var(--text-muted)]",children:[t.jsxs("span",{children:["Paso ",_+1," de ",e.length]}),t.jsx("span",{className:"h-1 w-1 rounded-full bg-[var(--border)]"}),t.jsxs("span",{children:[M.length," completados"]})]}),t.jsx(Ve,{height:38,padding:"0 14px",icon:t.jsx(W.HiChevronRight,{}),disabled:!L||!w,onClick:I,children:L&&!w?f:b})]})]})}const vf={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 yf(e,r){if(e){if(typeof e=="function"){e(r);return}e.current=r}}function xf(e){const r=getComputedStyle(e),n=Number.parseFloat(r.lineHeight),a=Number.parseFloat(r.paddingTop)+Number.parseFloat(r.paddingBottom),o=Number.parseFloat(r.borderTopWidth)+Number.parseFloat(r.borderBottomWidth);return{lineHeight:Number.isFinite(n)?n:20,paddingY:Number.isFinite(a)?a:12,borderY:Number.isFinite(o)?o:2}}function Ol(e,r){const{lineHeight:n,paddingY:a,borderY:o}=xf(e);return Math.ceil(r*n+a+o)}const Hl=s.forwardRef(function({className:r="",size:n="md",status:a="default",maxHeight:o,maxRows:l,minRows:i=1,style:c,value:d,defaultValue:u,onInput:m,...b},f){const g=s.useRef(null),h=a==="error"?"var(--danger)":a==="success"?"#16a34a":"var(--border)",E=s.useCallback(()=>{const v=g.current;if(!v)return;v.style.height="auto";const S=v.scrollHeight,A=Ol(v,i),C=o??(l!==void 0?Ol(v,l):void 0),O=C!==void 0?Math.min(Math.max(S,A),C):Math.max(S,A);v.style.height=`${O}px`,v.style.overflowY=C!==void 0&&S>C?"auto":"hidden"},[o,l,i]);return s.useLayoutEffect(()=>{E()},[E,d,u]),s.useEffect(()=>{const v=g.current;if(!v||typeof ResizeObserver>"u")return;const S=new ResizeObserver(()=>E());return S.observe(v),()=>S.disconnect()},[E]),t.jsx("textarea",{...b,ref:v=>{g.current=v,yf(f,v)},rows:i,value:d,defaultValue:u,"aria-invalid":a==="error"||b["aria-invalid"],onInput:v=>{E(),m==null||m(v)},style:{...c,borderColor:h,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 ${vf[n]} ${r}`})});function wf({label:e,containerClassName:r="",helperText:n,helperDisplay:a,error:o,labelAction:l,required:i,className:c="",status:d,...u}){return t.jsx(zn,{label:e,required:i,helperText:n,helperDisplay:a,error:o,labelAction:l,className:r,children:t.jsx(Hl,{...u,required:i,status:o?"error":d,className:`w-full ${c}`})})}const Nf={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"},kf={none:"resize-none",vertical:"resize-y",horizontal:"resize-x",both:"resize"};function Sf(e,r){if(e){if(typeof e=="function"){e(r);return}e.current=r}}function Ef(e,r){return e!==void 0?String(e).length:r!==void 0?String(r).length:0}const Il=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:b,action:f,style:g,value:h,defaultValue:E,maxLength:v,onInput:S,...A},C){const O=s.useRef(null),N=Ef(h,E),y=u??v,M=!!(b||f||d),k=m==="error"?"var(--danger)":m==="success"?"#16a34a":"var(--border)",_={...g??{},...i?{minHeight:`${i*24+18}px`}:null,...c?{maxHeight:`${c*24+18}px`}:null},Y=()=>{const D=O.current;!D||!l||(D.style.height="auto",D.style.height=`${D.scrollHeight}px`)};s.useEffect(Y,[l,h]);const K=t.jsx("textarea",{...A,ref:D=>{O.current=D,Sf(C,D)},value:h,defaultValue:E,maxLength:v,"aria-invalid":m==="error"||A["aria-invalid"],onInput:D=>{Y(),S==null||S(D)},style:{..._,borderColor:k},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 ${Nf[a]} ${kf[l?"none":o]} ${b?"pl-8":""} ${f?"pr-10":""} ${r}`});return M?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}),K,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:[N,y?`/${y}`:""]})]}):K});function Cf({label:e,containerClassName:r="",helperText:n,helperDisplay:a,error:o,labelAction:l,required:i,className:c="",status:d,...u}){return t.jsx(zn,{label:e,required:i,helperText:n,helperDisplay:a,error:o,labelAction:l,className:r,children:t.jsx(Il,{...u,required:i,status:o?"error":d,className:`w-full ${c}`})})}const Bl=[{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 Mf(e){return Bl[e%Bl.length]}let Tf=0;function ko(){return++Tf}function Fl(e,r){return r?r instanceof RegExp?r.test(e):r(e):!0}function $f(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Af(e,r){const n=r.filter(Boolean);if(n.length===0)return[e.trim()].filter(Boolean);const a=new RegExp(`${n.map(o=>$f(o)).join("|")}|\\r?\\n`,"g");return e.split(a).map(o=>o.trim()).filter(Boolean)}function Lf({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:b,helperDisplay:f="inline",error:g,required:h=!1}){const E=e!==void 0,v=!!g,S=!!b&&f==="tooltip"&&!v,[A,C]=s.useState(()=>(r??[]).map((j,x)=>({id:ko(),value:j.trim(),colorIndex:x})));s.useEffect(()=>{E&&C(j=>{const x=e??[],T=new Map(j.map(ee=>[ee.value,ee]));return x.map((ee,fe)=>T.get(ee)??{id:ko(),value:ee,colorIndex:fe})})},[E,e]);const O=A,[N,y]=s.useState(""),[M,k]=s.useState(null),[_,Y]=s.useState(""),[K,D]=s.useState(!1),[G,U]=s.useState(!1),ne=s.useRef(null),J=s.useRef(null),R=s.useRef(null);function V(){U(!0),setTimeout(()=>U(!1),400)}function X(j){C(j),n==null||n(j.map(x=>x.value))}function de(j){let x=O,T=!1,ee=!1;for(const fe of j){const ie=fe.trim();if(ie){if(c!==void 0&&x.length>=c){ee=!0;break}if(!d&&x.some(pe=>pe.value.toLowerCase()===ie.toLowerCase())){ee=!0;continue}if(!Fl(ie,u)){ee=!0;continue}x=[...x,{id:ko(),value:ie,colorIndex:x.length}],T=!0}}return T&&X(x),ee&&V(),T}function H(j){return de([j])}function I(j){const x=O.filter(T=>T.id!==j);X(x.map((T,ee)=>({...T,colorIndex:ee})))}function le(j,x){const T=x.trim();if(k(null),Y(""),!T){I(j);return}if(!(!d&&O.some(ee=>ee.id!==j&&ee.value.toLowerCase()===T.toLowerCase()))){if(!Fl(T,u)){V();return}X(O.map(ee=>ee.id===j?{...ee,value:T}:ee))}}function L(j){o||(k(j.id),Y(j.value),setTimeout(()=>{var x;return(x=J.current)==null?void 0:x.select()},0))}function oe(j){if(j.key==="Enter"||i.includes(j.key)){j.preventDefault(),H(N)&&y("");return}if(j.key==="Backspace"&&N===""&&O.length>0){j.preventDefault();const x=O[O.length-1];I(x.id)}}function w(j,x){if(j.key==="Enter"){j.preventDefault(),le(x,_),setTimeout(()=>{var T;return(T=ne.current)==null?void 0:T.focus()},0);return}j.key==="Escape"&&(j.preventDefault(),k(null),Y(""),setTimeout(()=>{var T;return(T=ne.current)==null?void 0:T.focus()},0))}function te(){var j;o||(j=ne.current)==null||j.focus()}function B(j){if(o)return;const x=j.clipboardData.getData("text");if(!x||!(i.some(ie=>ie&&x.includes(ie))||x.includes(`
|
|
31
|
-
`)))return;
|
|
28
|
+
`).replace(/<[^>]+>/g," ").replace(/ /g," ").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'").replace(/\s+/g," ").trim():""}function po(e){if(!e)return[];const r=new Set,n=[],a=d=>{const u=ho(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=pl(e);bo.lastIndex=0;let c;for(;(c=bo.exec(i))!==null;)a(c[1]??"");return n}function gl(e){const r=String(e.name??"").trim();return r||String(e.username??"").trim()||"usuario"}function Ju(e,r){const n=po(e);if(!n.length)return[];const a=new Map;r.forEach(i=>{i.username&&a.set(ho(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 vl(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 Ru(e,r){return r?e.filter(n=>n.userId!==r):e}function go(e){var n;let r=e.nextSibling;for((r==null?void 0:r.nodeType)===Node.TEXT_NODE&&/^[ \u00a0]/.test(r.textContent??"")&&(r=r.nextSibling);r&&r.nodeType===Node.TEXT_NODE&&!(r.textContent??"").replace(/\u00a0/g," ").trim();)r=r.nextSibling;return r&&r.nodeType===Node.ELEMENT_NODE&&((n=r.classList)!=null&&n.contains("mention-chip"))?" ":!r||r.nodeType===Node.ELEMENT_NODE&&r.tagName==="BR"?" ":" "}function xl(e){return!e||!/@/.test(e)?e:e.replace(bo,(r,n,a,o)=>{const l=o.slice(0,a),i=l.lastIndexOf("<"),c=l.lastIndexOf(">");if(i>c)return r;const d=(n??"").toLowerCase(),u=o[a+r.length]??"";return u===" "||u===" "?`<span class="mention-chip" contenteditable="false" data-username="${d}">${r}</span>`:`<span class="mention-chip" contenteditable="false" data-username="${d}">${r}</span>${u?" ":" "}`})}function dn(e){var r;(r=e.querySelectorAll)==null||r.call(e,".mention-chip").forEach(n=>{if(!(n instanceof HTMLElement))return;const a=n.ownerDocument,o=go(n),l=n.nextSibling;if((l==null?void 0:l.nodeType)===Node.TEXT_NODE){const i=l.textContent??"";if(i.startsWith(o))return;if(i.startsWith(" ")||i.startsWith(" ")){l.textContent=`${o}${i.slice(1)}`;return}if(i.length>0){l.textContent=`${o}${i}`;return}}n.after(a.createTextNode(o))})}function vo(e){var d;const r=e.ownerDocument,n=r.defaultView,a=e.parentNode;a&&dn(a);const o=go(e);let l=e.nextSibling;!l||l.nodeType!==Node.TEXT_NODE||!/^[ \u00a0]/.test(l.textContent??"")?(l=r.createTextNode(o),e.after(l)):(l.textContent??"").startsWith(o)||(l.textContent=`${o}${(l.textContent??"").slice(1)}`);const i=n==null?void 0:n.getSelection();if(!i)return;const c=r.createRange();c.setStart(l,((d=l.textContent)==null?void 0:d.length)??1),c.collapse(!0),i.removeAllRanges(),i.addRange(c)}const ef=new Set(["P","DIV","LI","H1","H2","H3","H4","H5","H6","BLOCKQUOTE"]);function yl(e,r){return ef.has(e.tagName)&&e!==r}function xo(e,r){let n="",a,o,l=!1;const i=(f,g)=>{if(l||!(r!=null&&r.domPoint))return;const{container:p,offset:E}=r.domPoint;p===f&&E===g&&(o=n.length,l=!0)},c=(f,g)=>(r==null?void 0:r.locatePlain)!==n.length?!1:(a={node:f,offset:g},!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 g=f.data;for(let p=0;p<=g.length;p+=1){if(i(f,p),c(f,p))return!0;p<g.length&&(n+=g[p])}return!1},m=(f,g)=>{if(g&&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 p=f;if(p.tagName==="BR")return i(p,0),d(p.nextSibling??void 0)==="matched";const E=Array.from(f.childNodes);for(let v=0;v<E.length;v+=1){const w=E[v],A=v>0&&w.nodeType===Node.ELEMENT_NODE&&yl(w,e);if(m(w,A))return!0}return!1},b=Array.from(e.childNodes);for(let f=0;f<b.length;f+=1){const g=b[f],p=f>0&&g.nodeType===Node.ELEMENT_NODE&&yl(g,e);if(m(g,p))break}if((r==null?void 0:r.locatePlain)===n.length&&!a){const f=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_TEXT);let g=f.nextNode(),p=g;for(;p;)g=p,p=f.nextNode();g&&(a={node:g,offset:g.data.length})}return{plain:n,locate:a,domOffset:o}}function yo(e){return xo(e).plain}function Dr(e,r){return r<0?null:xo(e,{locatePlain:r}).locate??null}function Zn(e,r,n){return e!==r&&!e.contains(r)?-1:xo(e,{domPoint:{container:r,offset:n}}).domOffset??-1}function wl(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=gl({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 b=c.createTextNode(" "),f=c.createDocumentFragment();f.append(m,b),d.insertNode(f),dn(e),vo(m);const g=c.defaultView,p=g==null?void 0:g.getSelection(),E=p!=null&&p.rangeCount?Zn(e,p.getRangeAt(0).startContainer,p.getRangeAt(0).startOffset):n+u.length+1;return{caretPlainOffset:E>=0?E:n+u.length+1}}function Nl(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 Qn(e){return e instanceof HTMLElement&&e.classList.contains("mention-chip")}function kl(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 Sl(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 Or(e=document){var r;(r=e.querySelectorAll)==null||r.call(e,".mention-chip.is-selected").forEach(n=>{n.classList.remove("is-selected")})}function Jn(e){var a;const r=(a=e.ownerDocument.defaultView)==null?void 0:a.getSelection();e.querySelectorAll(".mention-chip").forEach(o=>{let l=!1;if(r&&r.rangeCount>0)try{const i=r.getRangeAt(0);(!r.isCollapsed&&i.intersectsNode(o)||r.isCollapsed&&i.startContainer===o&&i.endContainer===o)&&(l=!0)}catch{l=!1}o.classList.toggle("is-selected",l)})}function El(e){var o;const r=e.ownerDocument,n=(o=r.defaultView)==null?void 0:o.getSelection();if(!n)return;const a=r.createRange();a.selectNodeContents(e),n.removeAllRanges(),n.addRange(a),Jn(e)}function Cl(e){const r=e.cloneContents();return r.querySelectorAll(".mention-chip").forEach(n=>n.remove()),(r.textContent??"").replace(/\u00a0/g," ").trim().length>0}function Ml(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(),Or(e),!0):!1}function Rn(e){var m,b;const r=e.ownerDocument,n=e.parentNode;if(!n)return;const a=(f,g)=>{let p=f;for(;p&&p.nodeType===Node.TEXT_NODE&&(p.textContent??"")==="";){const E=p;p=p[g],E.remove()}return p},o=a(e.nextSibling,"nextSibling");if(o&&o.nodeType===Node.TEXT_NODE&&/^( |\u00a0)/.test(o.textContent??"")){const f=o;(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 Tl(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=kl(a.previousSibling,"prev");return Qn(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(Qn(d))return d;if(d.nodeType===Node.TEXT_NODE&&!(d.textContent??"").replace(/\u00a0/g," ").trim()){c-=1;continue}break}}return null}function $l(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=kl(a.nextSibling,"next");if(Qn(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(Qn(d))return d;if(d.nodeType===Node.TEXT_NODE&&!(d.textContent??"").replace(/\u00a0/g," ").trim()){c+=1;continue}break}}return null}function wo(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 No=420,ea=6,Al=260,tf=new Set(["ArrowDown","ArrowUp","Enter","Tab","Escape"]),Ll=4,rf={position:"relative"},nf={position:"fixed",zIndex:11050,minWidth:Al,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},Dl={padding:"10px 12px",fontSize:12,color:"var(--text-muted, #656d76)"};function af(e){return Array.from(document.querySelectorAll(`[data-bonsaif-rich-instance="${CSS.escape(e)}"]`))}function of(e){const r=Math.max(8,Math.min(e.left,window.innerWidth-Al-8)),n=window.innerHeight-e.bottom-ea-8,a=e.top-ea-8;return n<Math.min(No,180)&&a>n?{left:r,bottom:window.innerHeight-e.top+ea,maxHeight:Math.min(No,Math.max(120,a))}:{left:r,top:e.bottom+ea,maxHeight:Math.min(No,Math.max(120,n))}}function Ol({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="",toolbarVariant:b="full"}){const f=s.useId().replace(/:/g,""),g=s.useRef(null),p=s.useRef(null),E=s.useRef(new Map),v=s.useRef(n);v.current=n;const w=s.useRef(null),A=s.useRef(0),C=s.useRef([]),H=s.useRef(null),[k,x]=s.useState(null),[M,N]=s.useState([]),[z,X]=s.useState(0),[K,D]=s.useState([]),[G,V]=s.useState(!1),[ne,J]=s.useState(!1);A.current=z,s.useEffect(()=>{J(!0)},[]);const R=(k==null?void 0:k.query)??null;s.useEffect(()=>{if(R===null){N([]);return}const S=R.trim(),ee=`${m}|${S.toLowerCase()||"*"}`,_=E.current.get(ee);if(_){N(_),V(!1),X(0);return}const I=new AbortController;V(!0);const de=window.setTimeout(()=>{(async()=>{try{const re=await v.current(S,{signal:I.signal,limit:c});if(I.signal.aborted)return;const F=Array.isArray(re)?re:[];E.current.set(ee,F),N(F),X(0)}catch{I.signal.aborted||N([])}finally{I.signal.aborted||V(!1)}})()},d);return()=>{I.abort(),window.clearTimeout(de)}},[R,c,d,m]);const U=s.useRef(a);U.current=a,s.useEffect(()=>{var S;(S=U.current)==null||S.call(U,vl(K))},[K]);const Y=s.useCallback(()=>{const S=af(f);if(S.length===0)return null;const ee=window.getSelection();if(ee!=null&&ee.rangeCount){const I=ee.getRangeAt(0).startContainer;for(const de of S)if(de.contains(I))return de}const _=document.activeElement;for(const I of S)if(_===I||_&&I.contains(_))return I;for(const I of S)if(I.closest('[role="dialog"]'))return I;return S[0]??null},[f]),ce=s.useCallback(()=>{const S=Y(),ee=window.getSelection();if(!S||!ee||ee.rangeCount===0){x(null);return}const _=ee.getRangeAt(0);if(!S.contains(_.startContainer)){x(null);return}const I=Zn(S,_.startContainer,_.startOffset);if(I<0){x(null);return}const de=mo(S,I);if(!de){x(null);return}const re=_.getBoundingClientRect(),F=re.width===0&&re.height===0?(()=>{const T=document.createRange();return T.selectNodeContents(_.startContainer),T.collapse(!0),T.getBoundingClientRect()})():re;w.current={query:de.query,caretIndex:de.caretIndex,triggerIndex:de.triggerIndex};const y=of(F);x(T=>{const te={query:de.query,...y};return T&&T.query===te.query&&T.top===te.top&&T.bottom===te.bottom&&T.left===te.left&&T.maxHeight===te.maxHeight?T:te})},[Y]),L=s.useCallback(S=>{r(S),ce()},[r,ce]);s.useEffect(()=>{const S=ee=>{if(tf.has(ee.key))return;const _=Y(),I=ee.target;!_||!I||!_.contains(I)||ce()};return document.addEventListener("keyup",S,!0),()=>document.removeEventListener("keyup",S,!0)},[Y,ce]);const B=s.useCallback(S=>{const ee=Y();if(!ee)return;let _=-1;const I=window.getSelection();if(I&&I.rangeCount>0){const T=I.getRangeAt(0);ee.contains(T.startContainer)&&(_=Zn(ee,T.startContainer,T.startOffset))}if(_<0&&w.current&&(_=w.current.caretIndex),_<0)return;const de=mo(ee,_);if(!de)return;const re=wl(ee,{triggerIndex:de.triggerIndex,caretIndex:_,username:S.username,display:S.name,userId:S.userId});if(!re)return;dn(ee),ee.dispatchEvent(new InputEvent("input",{bubbles:!0,cancelable:!0}));const F={userId:S.userId,username:S.username,email:S.email??void 0,display:S.name??S.username};D(T=>{const te=new Map(T.map(fe=>[fe.userId,fe]));return te.set(F.userId,F),Array.from(te.values())}),x(null),w.current=null;const y=S.username.toLowerCase();requestAnimationFrame(()=>{requestAnimationFrame(()=>{const T=Y();if(!T)return;T.focus(),dn(T);const te=Array.from(T.querySelectorAll(".mention-chip")),fe=[...te].reverse().find(se=>se.getAttribute("data-username")===y)??te[te.length-1];if(fe){vo(fe);return}Nl(T,re.caretPlainOffset)})})},[Y]);s.useEffect(()=>{const S=new Set(po(e).map(ee=>ee.toLowerCase()));D(ee=>{const _=ee.filter(I=>S.has(I.username.toLowerCase()));return _.length===ee.length?ee:_})},[e]),s.useEffect(()=>{if(!k)return;const S=ee=>{const _=ee.target;if(!_||g.current&&g.current.contains(_)||p.current&&p.current.contains(_))return;const I=Y();I&&I.contains(_)||x(null)};return document.addEventListener("mousedown",S),()=>{document.removeEventListener("mousedown",S)}},[k,Y]);const le=s.useMemo(()=>M.slice(0,c),[M,c]);C.current=le,s.useEffect(()=>{if(!k)return;const S=ee=>{const _=Y(),I=ee.target;if(!_||!I||!_.contains(I))return;const de=C.current;if(!(de.length===0&&ee.key!=="Escape"))if(ee.key==="ArrowDown")ee.preventDefault(),ee.stopPropagation(),X(re=>(re+1)%Math.max(de.length,1));else if(ee.key==="ArrowUp")ee.preventDefault(),ee.stopPropagation(),X(re=>(re-1+de.length)%Math.max(de.length,1));else if(ee.key==="Enter"||ee.key==="Tab"){const re=de[A.current];re&&(ee.preventDefault(),ee.stopPropagation(),B(re))}else ee.key==="Escape"&&(ee.preventDefault(),ee.stopPropagation(),x(null))};return document.addEventListener("keydown",S,!0),()=>document.removeEventListener("keydown",S,!0)},[Y,B,k]),s.useEffect(()=>{const S=F=>{F.dispatchEvent(new InputEvent("input",{bubbles:!0,cancelable:!0}))},ee=F=>{const y=Y(),T=F.target;if(!y||!T||!y.contains(T))return;if((F.metaKey||F.ctrlKey)&&F.key.toLowerCase()==="a"){F.preventDefault(),F.stopPropagation(),y.focus(),El(y);return}if(F.key!=="Backspace"&&F.key!=="Delete")return;const te=window.getSelection();if(te&&!te.isCollapsed&&te.rangeCount>0){const he=te.getRangeAt(0);if(y.contains(he.commonAncestorContainer)&&wo(y).length>0&&Cl(he)){F.preventDefault(),F.stopPropagation(),Ml(y)&&S(y);return}}const fe=wo(y);if(fe.length>0){F.preventDefault(),F.stopPropagation();for(const he of fe)Rn(he);Or(y),S(y);return}if(F.key==="Backspace"){const he=Tl(y);if(!he)return;F.preventDefault(),F.stopPropagation(),Rn(he),Or(y),S(y);return}const se=$l(y);se&&(F.preventDefault(),F.stopPropagation(),Rn(se),Or(y),S(y))},_=F=>{const y=Y();if(!y)return;const T=F.target;if(!(T instanceof Element)||!y.contains(T))return;const te=T.closest(".mention-chip");if(!(te instanceof HTMLElement)||!y.contains(te)){H.current=null,Or(y);return}F.shiftKey||F.button!==0||(H.current={chip:te,x:F.clientX,y:F.clientY})},I=F=>{const y=H.current;if(!y)return;const T=Math.abs(F.clientX-y.x),te=Math.abs(F.clientY-y.y);(T>Ll||te>Ll)&&(H.current=null)},de=F=>{var se;const y=Y(),T=H.current;if(H.current=null,!y||!T)return;const te=F.target;if(!(te instanceof Element)||!y.contains(te)||!((se=te.closest(".mention-chip"))!=null&&se.isSameNode(T.chip)))return;const fe=window.getSelection();if(fe){if(!fe.isCollapsed){Jn(y);return}y.focus(),Sl(T.chip)}},re=()=>{const F=Y();if(!F)return;const y=window.getSelection();!y||y.rangeCount===0||!y.anchorNode||!F.contains(y.anchorNode)||!y.focusNode||!F.contains(y.focusNode)||Jn(F)};return document.addEventListener("keydown",ee,!0),document.addEventListener("mousedown",_,!0),document.addEventListener("mousemove",I,!0),document.addEventListener("mouseup",de,!0),document.addEventListener("selectionchange",re),()=>{document.removeEventListener("keydown",ee,!0),document.removeEventListener("mousedown",_,!0),document.removeEventListener("mousemove",I,!0),document.removeEventListener("mouseup",de,!0),document.removeEventListener("selectionchange",re)}},[Y]),s.useEffect(()=>{if(!k||!p.current)return;const S=p.current.querySelector(`[data-mention-index="${z}"]`);S==null||S.scrollIntoView({block:"nearest"})},[z,k]);const O=u?xl(e):e,ae=k&&ne?gt.createPortal(t.jsxs("ul",{ref:p,style:{...nf,left:k.left,top:k.top,bottom:k.bottom,maxHeight:k.maxHeight},role:"listbox","aria-label":"Menciones sugeridas",children:[G&&le.length===0&&t.jsx("li",{style:Dl,children:"Buscando…"}),!G&&le.length===0&&t.jsx("li",{style:Dl,children:k.query.trim().length===0?"Escribe un nombre o usuario":`Sin coincidencias para “${k.query}”`}),le.map((S,ee)=>{var _,I;return t.jsx("li",{children:t.jsxs("button",{type:"button","data-mention-index":ee,onMouseDown:de=>{de.preventDefault(),B(S)},onMouseEnter:()=>X(ee),style:{width:"100%",textAlign:"left",padding:"8px 10px",border:"none",background:ee===z?"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:((_=S.name)==null?void 0:_.trim())||`@${S.username}`}),t.jsx("span",{style:{fontSize:11,color:"var(--text-muted, #656d76)"},children:[(I=S.name)!=null&&I.trim()?`@${S.username}`:null,S.email].filter(Boolean).join(" · ")||`@${S.username}`})]})},S.userId)})]}),document.body):null;return t.jsxs("div",{ref:g,style:rf,className:i,children:[t.jsx(dl,{value:O,onChange:L,placeholder:l,minHeight:o,instanceId:f,toolbarVariant:b}),ae]})}function sf({value:e,onChange:r,placeholder:n,minHeight:a,onSearchUsers:o,onMentionsChange:l,className:i,maxSuggestions:c,searchDebounceMs:d,highlightInEditor:u,searchCacheKey:m,toolbarVariant:b}){return o?t.jsx(Ol,{value:e,onChange:r,onSearchUsers:o,onMentionsChange:l,placeholder:n,minHeight:a,className:i,maxSuggestions:c,searchDebounceMs:d,highlightInEditor:u,searchCacheKey:m,toolbarVariant:b}):t.jsx(dl,{value:e,onChange:r,placeholder:n,minHeight:a,toolbarVariant:b})}function lf({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 cf={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)"}},df={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 uf({children:e,tone:r="neutral",size:n="sm",icon:a,dot:o=!1,className:l=""}){const i=cf[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 ${df[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 Hl={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)"}},ff={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"},bf={xs:"right-1 h-3 w-3",sm:"right-1.5 h-3 w-3",md:"right-2 h-3.5 w-3.5"},mf={xs:148,sm:164,md:184},hf={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 pf({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:b,optionClassName:f,spinnerClassName:g}){const[p,E]=s.useState(!1),[v,w]=s.useState(!1),[A,C]=s.useState(-1),[H,k]=s.useState({}),x=s.useRef(null),M=s.useRef(null),N=s.useRef(null),z=r.find(U=>U.value===e)??r[0],X={...z!=null&&z.tone?Hl[z.tone]:void 0,...z==null?void 0:z.style},K=o||l||r.length===0,D=U=>{i&&U.stopPropagation()},G=s.useCallback(()=>{E(!1),C(-1)},[]),V=s.useCallback(()=>{const U=x.current;if(!U)return;const Y=U.getBoundingClientRect(),ce=Math.max(Y.width,mf[a]),L=Math.min(Math.max(r.length,1)*38+12,260),B=window.innerHeight-Y.bottom,le=B<L&&Y.top>B,O=Math.min(Math.max(8,Y.left+Y.width/2-ce/2),window.innerWidth-ce-8);k({position:"fixed",left:O,top:le?void 0:Y.bottom+6,bottom:le?window.innerHeight-Y.top+6:void 0,width:ce,zIndex:9999})},[r.length,a]),ne=s.useCallback(U=>{U.disabled||(n(U.value),G())},[G,n]);s.useEffect(()=>w(!0),[]),s.useEffect(()=>{if(!p)return;V();const U=r.findIndex(Y=>Y.value===e);C(U>=0?U:0)},[p,r,V,e]),s.useEffect(()=>{if(!p)return;function U(Y){var L,B;const ce=Y.target;!((L=x.current)!=null&&L.contains(ce))&&!((B=M.current)!=null&&B.contains(ce))&&G()}return document.addEventListener("mousedown",U),()=>document.removeEventListener("mousedown",U)},[G,p]),s.useEffect(()=>{if(p)return window.addEventListener("resize",V),window.addEventListener("scroll",V,!0),()=>{window.removeEventListener("resize",V),window.removeEventListener("scroll",V,!0)}},[p,V]),s.useEffect(()=>{if(A<0||!N.current)return;const U=N.current.children[A];U==null||U.scrollIntoView({block:"nearest"})},[A]);function J(U){if(!K){if(!p){["Enter"," ","ArrowDown","ArrowUp"].includes(U.key)&&(U.preventDefault(),E(!0));return}if(U.key==="Escape"){U.preventDefault(),G();return}if(U.key==="ArrowDown"){U.preventDefault(),C(Y=>Math.min(Y+1,r.length-1));return}if(U.key==="ArrowUp"){U.preventDefault(),C(Y=>Math.max(Y-1,0));return}if(U.key==="Enter"||U.key===" "){U.preventDefault();const Y=r[A];Y&&ne(Y)}}}const R=t.jsx("div",{ref:M,role:"listbox","aria-label":c,className:Qt("overflow-hidden rounded-xl border shadow-xl backdrop-blur-md",b),style:{...H,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:N,className:"max-h-64 overflow-y-auto p-1",style:{scrollbarWidth:"thin",scrollbarColor:"var(--border) transparent",overscrollBehavior:"contain"},children:r.map((U,Y)=>{const ce=U.value===e,L=Y===A,B={...U.tone?Hl[U.tone]:void 0,...U.style};return t.jsxs("button",{type:"button",role:"option","aria-selected":ce,disabled:U.disabled,onMouseEnter:()=>!U.disabled&&C(Y),onMouseDown:le=>{le.preventDefault(),ne(U)},className:Qt("flex w-full items-center gap-2 rounded-lg font-medium text-left transition-colors disabled:cursor-not-allowed disabled:opacity-45",hf[a],ce?U.className:void 0,f),style:{...ce?B:void 0,background:ce?B.background??"color-mix(in srgb, var(--primary) 12%, transparent)":L?"var(--bg-hover)":"transparent",color:ce?B.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(j.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:x,className:Qt("relative inline-flex shrink-0 items-center",u),onKeyDown:J,onClick:D,onPointerDown:D,children:[t.jsx("button",{type:"button",disabled:K,"aria-label":c,"aria-haspopup":"listbox","aria-expanded":p,title:d,onClick:()=>!K&&E(U=>!U),className:Qt("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",ff[a],z==null?void 0:z.className,m),style:X,children:t.jsx("span",{className:"min-w-0 truncate",children:(z==null?void 0:z.label)??e})}),t.jsx(j.HiChevronDown,{"aria-hidden":"true",className:Qt("pointer-events-none absolute opacity-70 transition-transform",bf[a],p?"rotate-180":"rotate-0")}),l&&t.jsx("span",{"aria-hidden":"true",className:Qt("absolute -right-1 -top-1 h-2.5 w-2.5 rounded-full border border-current border-t-transparent animate-spin",g)}),p&&v&>.createPortal(R,document.body)]})}function gf({tabs:e,activeTabId:r,defaultActiveTabId:n,onTabChange:a,ariaLabel:o="Pestanas",variant:l="underline",className:i="",listClassName:c="",panelClassName:d=""}){const u=e.find(p=>!p.disabled)??e[0],m=r??n??(u==null?void 0:u.id),b=e.find(p=>p.id===m)??u,f=p=>{p.disabled||a==null||a(p.id)},g=p=>{const E=e.filter(w=>!w.disabled);if(!E.length||!b)return;const v=E.findIndex(w=>w.id===b.id);(p.key==="ArrowRight"||p.key==="ArrowDown")&&(p.preventDefault(),f(E[(v+1)%E.length])),(p.key==="ArrowLeft"||p.key==="ArrowUp")&&(p.preventDefault(),f(E[(v-1+E.length)%E.length])),p.key==="Home"&&(p.preventDefault(),f(E[0])),p.key==="End"&&(p.preventDefault(),f(E[E.length-1]))};return t.jsxs("div",{className:i,children:[t.jsx("div",{role:"tablist","aria-label":o,onKeyDown:g,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(p=>{const E=p.id===(b==null?void 0:b.id);return t.jsxs("button",{type:"button",role:"tab","aria-selected":E,"aria-controls":`${p.id}-panel`,id:`${p.id}-tab`,disabled:p.disabled,tabIndex:E?0:-1,onClick:()=>f(p),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:[p.icon&&t.jsx("span",{className:"shrink-0",children:p.icon}),t.jsx("span",{children:p.label}),p.badge&&t.jsx("span",{className:"shrink-0",children:p.badge})]},p.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 tr(...e){return e.filter(Boolean).join(" ")}function vf({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:b="Siguiente",blockedNextLabel:f="Completa este paso",className:g="",headerClassName:p="",contentClassName:E="",footerClassName:v=""}){var _;const w=((_=e[0])==null?void 0:_.id)??"",[A,C]=s.useState(n??w),[H,k]=s.useState(o),x=r??A,M=a??H,N=s.useMemo(()=>new Set(M),[M]),z=Math.max(0,e.findIndex(I=>I.id===x)),X=e[z]??e[0],K=e.length<=1?100:z/(e.length-1)*100,D=I=>{a||k(I),i==null||i(I)},G=I=>{const de=e.find(re=>re.id===I);de&&(r||C(I),l==null||l(I,de))},V=I=>N.has(I),ne=I=>e.slice(0,I).find(de=>!de.optional&&!N.has(de.id)),J=I=>{const de=e[I];return!de||de.disabled?!1:I===z||d&&I<z?!0:!ne(I)},R=I=>{const de=e.findIndex(re=>re.id===I);return de>=0&&J(de)},U=I=>{const de=e.findIndex(re=>re.id===I);if(de<0)return!1;if(!J(de)){const re=ne(de);return re&&(c==null||c(e[de],re)),!1}return G(I),!0},Y=(I=X==null?void 0:X.id)=>{!I||N.has(I)||D([...M,I])},ce=(I=X==null?void 0:X.id)=>{if(!I)return;const de=e.findIndex(F=>F.id===I),re=M.filter(F=>{const y=e.findIndex(T=>T.id===F);return y>=0&&y<de});D(re),de>=0&&z>de&&G(I)},L=()=>z<=0?!1:U(e[z-1].id),B=()=>{const I=e[z+1];return I?U(I.id):!1},le={activeStep:X,activeIndex:z,completedStepIds:M,isCompleted:V,isUnlocked:R,completeStep:Y,uncompleteStep:ce,goToStep:U,goNext:B,goPrevious:L};if(!X)return null;const O=e[z+1],ae=z>0,S=O?R(O.id):!1,ee=typeof X.content=="function"?X.content(le):X.content;return t.jsxs("section",{className:tr("overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)]",g),children:[t.jsxs("div",{className:tr("border-b border-[var(--border)] bg-[var(--bg-input)]",p),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:`${K}%`}})}),t.jsx("div",{className:"grid gap-2 p-2",style:{gridTemplateColumns:`repeat(${e.length}, minmax(0, 1fr))`},children:e.map((I,de)=>{const re=I.id===X.id,F=V(I.id),y=J(de),T=ne(de);return t.jsxs("button",{type:"button",disabled:!y,"aria-current":re?"step":void 0,"aria-disabled":!y,title:!y&&T?`Completa ${T.title}`:I.title,onClick:()=>U(I.id),className:tr("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",re&&"border-[var(--primary)] bg-[var(--bg-card)] shadow-sm",F&&!re&&"border-[var(--primary)]/35 bg-[var(--bg-card)]",!re&&!F&&y&&"border-transparent bg-[var(--bg-card)]/45 hover:border-[var(--border)] hover:bg-[var(--bg-card)]",!y&&"border-transparent bg-[var(--bg-card)]/35 opacity-60"),children:[t.jsx("span",{className:tr("absolute inset-x-0 top-0 h-0.5 origin-left scale-x-0 bg-[var(--primary)] transition-transform duration-300",re&&"scale-x-100")}),t.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[t.jsx("span",{className:tr("grid h-7 w-7 shrink-0 place-items-center rounded-full border text-xs font-bold transition-all duration-200",re&&"border-[var(--primary)] bg-[var(--primary)] text-[var(--primary-fg)]",F&&!re&&"border-[var(--primary)] bg-[var(--primary)]/12 text-[var(--primary)]",!F&&!re&&y&&"border-[var(--border)] text-[var(--text-muted)]",!y&&"border-[var(--border)] text-[var(--text-muted)]"),children:F?t.jsx(j.HiCheck,{className:"h-4 w-4"}):y?de+1:t.jsx(j.HiLockClosed,{className:"h-3.5 w-3.5"})}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsxs("span",{className:tr("block truncate text-xs font-semibold transition-colors duration-200",re?"text-[var(--text-main)]":"text-[var(--text-secondary)]"),children:[de+1,". ",I.title]}),I.description&&t.jsx("span",{className:"mt-1 block truncate text-[11px] text-[var(--text-muted)]",children:I.description})]}),I.badge&&t.jsx("span",{className:"shrink-0",children:I.badge})]})]},I.id)})})]}),t.jsx("div",{className:tr("min-h-72 animate-[stepWizardIn_220ms_ease-out] p-5",E),children:ee},X.id),u&&t.jsxs("div",{className:tr("flex flex-wrap items-center justify-between gap-3 border-t border-[var(--border)] bg-[var(--bg-input)] px-4 py-3",v),children:[t.jsx(Qe,{variant:"secondary",height:38,padding:"0 14px",icon:t.jsx(j.HiChevronLeft,{}),disabled:!ae,onClick:L,children:m}),t.jsxs("div",{className:"flex items-center gap-3 text-xs text-[var(--text-muted)]",children:[t.jsxs("span",{children:["Paso ",z+1," de ",e.length]}),t.jsx("span",{className:"h-1 w-1 rounded-full bg-[var(--border)]"}),t.jsxs("span",{children:[M.length," completados"]})]}),t.jsx(Qe,{height:38,padding:"0 14px",icon:t.jsx(j.HiChevronRight,{}),disabled:!O||!S,onClick:B,children:O&&!S?f:b})]})]})}const xf={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 yf(e,r){if(e){if(typeof e=="function"){e(r);return}e.current=r}}function wf(e){const r=getComputedStyle(e),n=Number.parseFloat(r.lineHeight),a=Number.parseFloat(r.paddingTop)+Number.parseFloat(r.paddingBottom),o=Number.parseFloat(r.borderTopWidth)+Number.parseFloat(r.borderBottomWidth);return{lineHeight:Number.isFinite(n)?n:20,paddingY:Number.isFinite(a)?a:12,borderY:Number.isFinite(o)?o:2}}function Il(e,r){const{lineHeight:n,paddingY:a,borderY:o}=wf(e);return Math.ceil(r*n+a+o)}const Bl=s.forwardRef(function({className:r="",size:n="md",status:a="default",maxHeight:o,maxRows:l,minRows:i=1,style:c,value:d,defaultValue:u,onInput:m,...b},f){const g=s.useRef(null),p=a==="error"?"var(--danger)":a==="success"?"#16a34a":"var(--border)",E=s.useCallback(()=>{const v=g.current;if(!v)return;v.style.height="auto";const w=v.scrollHeight,A=Il(v,i),C=o??(l!==void 0?Il(v,l):void 0),H=C!==void 0?Math.min(Math.max(w,A),C):Math.max(w,A);v.style.height=`${H}px`,v.style.overflowY=C!==void 0&&w>C?"auto":"hidden"},[o,l,i]);return s.useLayoutEffect(()=>{E()},[E,d,u]),s.useEffect(()=>{const v=g.current;if(!v||typeof ResizeObserver>"u")return;const w=new ResizeObserver(()=>E());return w.observe(v),()=>w.disconnect()},[E]),t.jsx("textarea",{...b,ref:v=>{g.current=v,yf(f,v)},rows:i,value:d,defaultValue:u,"aria-invalid":a==="error"||b["aria-invalid"],onInput:v=>{E(),m==null||m(v)},style:{...c,borderColor:p,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 ${xf[n]} ${r}`})});function Nf({label:e,containerClassName:r="",helperText:n,helperDisplay:a,error:o,labelAction:l,required:i,className:c="",status:d,...u}){return t.jsx(zn,{label:e,required:i,helperText:n,helperDisplay:a,error:o,labelAction:l,className:r,children:t.jsx(Bl,{...u,required:i,status:o?"error":d,className:`w-full ${c}`})})}const kf={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"},Sf={none:"resize-none",vertical:"resize-y",horizontal:"resize-x",both:"resize"};function Ef(e,r){if(e){if(typeof e=="function"){e(r);return}e.current=r}}function Cf(e,r){return e!==void 0?String(e).length:r!==void 0?String(r).length:0}const Fl=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:b,action:f,style:g,value:p,defaultValue:E,maxLength:v,onInput:w,...A},C){const H=s.useRef(null),k=Cf(p,E),x=u??v,M=!!(b||f||d),N=m==="error"?"var(--danger)":m==="success"?"#16a34a":"var(--border)",z={...g??{},...i?{minHeight:`${i*24+18}px`}:null,...c?{maxHeight:`${c*24+18}px`}:null},X=()=>{const D=H.current;!D||!l||(D.style.height="auto",D.style.height=`${D.scrollHeight}px`)};s.useEffect(X,[l,p]);const K=t.jsx("textarea",{...A,ref:D=>{H.current=D,Ef(C,D)},value:p,defaultValue:E,maxLength:v,"aria-invalid":m==="error"||A["aria-invalid"],onInput:D=>{X(),w==null||w(D)},style:{...z,borderColor:N},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 ${kf[a]} ${Sf[l?"none":o]} ${b?"pl-8":""} ${f?"pr-10":""} ${r}`});return M?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}),K,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:[k,x?`/${x}`:""]})]}):K});function Mf({label:e,containerClassName:r="",helperText:n,helperDisplay:a,error:o,labelAction:l,required:i,className:c="",status:d,...u}){return t.jsx(zn,{label:e,required:i,helperText:n,helperDisplay:a,error:o,labelAction:l,className:r,children:t.jsx(Fl,{...u,required:i,status:o?"error":d,className:`w-full ${c}`})})}const Pl=[{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 Tf(e){return Pl[e%Pl.length]}let $f=0;function ko(){return++$f}function _l(e,r){return r?r instanceof RegExp?r.test(e):r(e):!0}function Af(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Lf(e,r){const n=r.filter(Boolean);if(n.length===0)return[e.trim()].filter(Boolean);const a=new RegExp(`${n.map(o=>Af(o)).join("|")}|\\r?\\n`,"g");return e.split(a).map(o=>o.trim()).filter(Boolean)}function Df({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:b,helperDisplay:f="inline",error:g,required:p=!1}){const E=e!==void 0,v=!!g,w=!!b&&f==="tooltip"&&!v,[A,C]=s.useState(()=>(r??[]).map((F,y)=>({id:ko(),value:F.trim(),colorIndex:y})));s.useEffect(()=>{E&&C(F=>{const y=e??[],T=new Map(F.map(te=>[te.value,te]));return y.map((te,fe)=>T.get(te)??{id:ko(),value:te,colorIndex:fe})})},[E,e]);const H=A,[k,x]=s.useState(""),[M,N]=s.useState(null),[z,X]=s.useState(""),[K,D]=s.useState(!1),[G,V]=s.useState(!1),ne=s.useRef(null),J=s.useRef(null),R=s.useRef(null);function U(){V(!0),setTimeout(()=>V(!1),400)}function Y(F){C(F),n==null||n(F.map(y=>y.value))}function ce(F){let y=H,T=!1,te=!1;for(const fe of F){const se=fe.trim();if(se){if(c!==void 0&&y.length>=c){te=!0;break}if(!d&&y.some(he=>he.value.toLowerCase()===se.toLowerCase())){te=!0;continue}if(!_l(se,u)){te=!0;continue}y=[...y,{id:ko(),value:se,colorIndex:y.length}],T=!0}}return T&&Y(y),te&&U(),T}function L(F){return ce([F])}function B(F){const y=H.filter(T=>T.id!==F);Y(y.map((T,te)=>({...T,colorIndex:te})))}function le(F,y){const T=y.trim();if(N(null),X(""),!T){B(F);return}if(!(!d&&H.some(te=>te.id!==F&&te.value.toLowerCase()===T.toLowerCase()))){if(!_l(T,u)){U();return}Y(H.map(te=>te.id===F?{...te,value:T}:te))}}function O(F){o||(N(F.id),X(F.value),setTimeout(()=>{var y;return(y=J.current)==null?void 0:y.select()},0))}function ae(F){if(F.key==="Enter"||i.includes(F.key)){F.preventDefault(),L(k)&&x("");return}if(F.key==="Backspace"&&k===""&&H.length>0){F.preventDefault();const y=H[H.length-1];B(y.id)}}function S(F,y){if(F.key==="Enter"){F.preventDefault(),le(y,z),setTimeout(()=>{var T;return(T=ne.current)==null?void 0:T.focus()},0);return}F.key==="Escape"&&(F.preventDefault(),N(null),X(""),setTimeout(()=>{var T;return(T=ne.current)==null?void 0:T.focus()},0))}function ee(){var F;o||(F=ne.current)==null||F.focus()}function _(F){if(o)return;const y=F.clipboardData.getData("text");if(!y||!(i.some(se=>se&&y.includes(se))||y.includes(`
|
|
31
|
+
`)))return;F.preventDefault();const te=Lf(y,i);ce(te)&&x("")}function I(){const F=k.trim();F&&L(F)&&x("")}const de=v?"var(--danger)":K?"var(--primary)":"var(--border)",re=c!==void 0&&H.length>=c;return t.jsxs("div",{className:`flex flex-col gap-2 ${l}`,children:[(m||p||w)&&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}),p&&t.jsx("span",{className:"text-[var(--danger)]",children:"*"}),w?t.jsx(Mr,{content:b}):null]}),t.jsxs("div",{ref:R,onClick:ee,onFocus:()=>D(!0),onBlur:F=>{var y;(y=R.current)!=null&&y.contains(F.relatedTarget)||(D(!1),M!==null&&le(M,z),M===null&&I())},style:{borderColor:de},className:`
|
|
32
32
|
flex min-h-10 flex-wrap items-center gap-1.5 rounded-lg border
|
|
33
33
|
bg-[var(--bg-input)] px-2.5 py-2 transition-colors
|
|
34
34
|
${o?"cursor-not-allowed opacity-60":"cursor-text"}
|
|
@@ -41,7 +41,7 @@ ${P}`,ve=new Blob(["\uFEFF"+se],{type:"text/csv;charset=utf-8;"}),Ce=URL.createO
|
|
|
41
41
|
60% { transform: translateX(-3px); }
|
|
42
42
|
80% { transform: translateX(3px); }
|
|
43
43
|
}
|
|
44
|
-
`}),O.map(j=>{const x=Mf(j.colorIndex);return M===j.id?t.jsx("input",{ref:J,value:_,disabled:o,onChange:T=>Y(T.target.value),onKeyDown:T=>w(T,j.id),onBlur:()=>le(j.id,_),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(_.length+2,6)}ch`}},j.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:x.bg,color:x.text,border:`1px solid ${x.border}`},children:[t.jsx("span",{className:"truncate",children:j.value}),t.jsx("button",{type:"button","aria-label":`Editar "${j.value}"`,disabled:o,tabIndex:-1,onClick:T=>{T.stopPropagation(),L(j)},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(W.HiPencil,{className:"h-3 w-3"})}),t.jsx("button",{type:"button","aria-label":`Eliminar "${j.value}"`,disabled:o,tabIndex:-1,onClick:T=>{T.stopPropagation(),I(j.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(W.HiXMark,{className:"h-3.5 w-3.5"})})]},j.id)}),!re&&t.jsx("input",{ref:ne,value:N,disabled:o,placeholder:O.length===0?a:"",onChange:j=>y(j.target.value),onKeyDown:oe,onPaste:B,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(Tr,{error:g,helperText:b,helperDisplay:f})]})}const Df=/^(\d{1,2}):(\d{2})(?::(\d{2}))?$/;function Re(e){return String(e).padStart(2,"0")}function So(e,r=Hr()){const n=e.trim();if(!n)return r;const a=n.match(Df);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 un(e,r=!0){const n=`${Re(e.hour24)}:${Re(e.minute)}`;return r?`${n}:${Re(e.second)}`:n}function ta(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 fn(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 Of(e,r){const n=(r==null?void 0:r.use12Hour)??!1,a=(r==null?void 0:r.showSeconds)??!0,o=So(e);if(n){const l=ta(o),i=`${l.hour12}:${Re(l.minute)}`;return`${a?`${i}:${Re(l.second)}`:i} ${l.meridiem}`}return un(o,a)}function Hr(){const e=new Date;return{hour24:e.getHours(),minute:e.getMinutes(),second:e.getSeconds()}}function Hf(e=!0){return un(Hr(),e)}function Eo(e,r){const n=[];for(let a=e;a<=r;a+=1)n.push(a);return n}const wt=36,Co=5,Pl=Math.floor(Co/2),If=52,Bf=48,Vt=18;function _l(e){return e*wt}function zl(e){return Math.round(e/wt)}function Ff(e){return e.use12Hour??e.hour12??!1}function ra({values:e,selected:r,onSelect:n,syncEpochRef:a,forceSyncAt:o=0,width:l=If,label:i,maxNumeric:c=59,isMeridiem:d=!1,isFocused:u=!1,onFocus:m,onAdvance:b,onBack:f,setColumnRef:g}){const h=s.useRef(null),E=s.useRef(null),v=s.useRef(null),S=s.useRef(""),A=s.useRef(0),C=s.useRef(!1),[O,N]=s.useState(r),[y,M]=s.useState(""),k=s.useCallback(L=>{S.current=L,M(L)},[]),_=s.useMemo(()=>[...Array(Pl).fill(""),...e,...Array(Pl).fill("")],[e]),Y=s.useCallback(()=>{const L=h.current;if(!L)return r;const oe=zl(L.scrollTop),w=Math.min(Math.max(oe,0),e.length-1);return e[w]??r},[r,e]),K=s.useCallback((L,oe=!0)=>{const w=Math.min(Math.max(L,0),e.length-1),te=e[w],B=h.current;!B||!te||(E.current&&(window.clearTimeout(E.current),E.current=null),C.current=!0,A.current=w,B.scrollTop=_l(w),N(te),oe&&te!==r&&n(te))},[n,r,e]);s.useLayoutEffect(()=>{E.current&&(window.clearTimeout(E.current),E.current=null),v.current&&(window.clearTimeout(v.current),v.current=null),k(""),N(r);const L=e.indexOf(r);if(L>=0&&(A.current=L),L<0||!h.current)return;const oe=_l(L);h.current.scrollTop!==oe&&(h.current.scrollTop=oe)},[o,r,k,e]);const D=s.useCallback(()=>{v.current&&(window.clearTimeout(v.current),v.current=null)},[]),G=s.useCallback((L,oe=!1)=>{D(),k("");const w=Number(L);if(!Number.isFinite(w))return;const te=Math.min(c,Math.max(0,w));let B=Re(te),F=e.indexOf(B);if(F<0){const ue=Math.min(e.length-1,Math.max(0,te-(c===12?1:0)));B=e[ue]??B,F=e.indexOf(B)}F>=0&&K(F),oe&&(b==null||b())},[D,c,b,K,k,e]),U=s.useCallback(L=>{const oe=Math.floor(c/10),w=S.current;if(w===""){if(L>oe){G(String(L),!0);return}const B=String(L);k(B),v.current=window.setTimeout(()=>{G(S.current,!0)},1200);return}D();const te=+`${w}${L}`;te<=c?G(String(te),!0):G(String(L),!0)},[D,G,c,k]),ne=s.useCallback(L=>{D(),k(""),K(A.current+L)},[D,K,k]),J=L=>{if(d){L.key==="a"||L.key==="A"?(L.preventDefault(),n("AM"),b==null||b()):L.key==="p"||L.key==="P"?(L.preventDefault(),n("PM"),b==null||b()):L.key==="ArrowUp"||L.key==="ArrowDown"?(L.preventDefault(),n(r==="AM"?"PM":"AM")):L.key==="Tab"&&(L.preventDefault(),L.shiftKey?f==null||f():b==null||b());return}if(/^\d$/.test(L.key)){L.preventDefault(),U(Number(L.key));return}L.key==="ArrowUp"?(L.preventDefault(),ne(-1)):L.key==="ArrowDown"?(L.preventDefault(),ne(1)):L.key==="Tab"&&(L.preventDefault(),D(),S.current!==""&&G(S.current,!1),L.shiftKey?f==null||f():b==null||b())},R=s.useCallback(()=>{const L=a.current,oe=h.current;oe&&L===a.current&&K(zl(oe.scrollTop))},[K,a]),V=()=>{if(S.current!=="")return;if(C.current){C.current=!1;const oe=Y();N(oe);const w=e.indexOf(oe);w>=0&&(A.current=w);return}N(Y()),E.current&&window.clearTimeout(E.current);const L=a.current;E.current=window.setTimeout(()=>{L===a.current&&R()},100)},X="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",de=wt*Co,H=de+Vt*2,I=y!==""?y:null,le=I!==null;return t.jsxs("div",{ref:g,role:"spinbutton",tabIndex:u?0:-1,"aria-label":i,"aria-valuetext":I??r,"aria-valuenow":d?void 0:Number(r),onFocus:m,onMouseDown:()=>m==null?void 0:m(),onKeyDown:J,onBlur:()=>{D(),S.current!==""&&G(S.current,!1)},className:"relative shrink-0 rounded-lg outline-none",style:{width:l,height:H,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:X,style:{top:0,height:Vt,color:"var(--text-muted)",opacity:.35},onClick:()=>ne(-1),children:t.jsx(W.HiChevronUp,{className:"h-3.5 w-3.5"})}),t.jsx("div",{ref:h,className:"absolute inset-x-0 overflow-y-auto [scrollbar-width:none] [-ms-overflow-style:none] [&::-webkit-scrollbar]:hidden",style:{top:Vt,height:de,scrollSnapType:"y mandatory",scrollBehavior:"auto"},onScroll:V,onMouseUp:R,onTouchEnd:R,children:_.map((L,oe)=>{const w=L!==""&&L===O;return t.jsx("button",{type:"button",tabIndex:-1,disabled:!L,onClick:()=>{if(!L)return;const te=e.indexOf(L);te>=0&&K(te)},className:"flex w-full items-center justify-center tabular-nums leading-none disabled:cursor-default",style:{height:wt,scrollSnapAlign:"center",color:w?"var(--text-main)":"var(--text-muted)",fontSize:w?16:14,fontWeight:w?600:400,opacity:L?le?w?0:.35:w?1:.35:0},children:L},`wheel-${oe}-${L}`)})}),I!==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:Vt+de/2-wt/2,height:wt,color:"var(--text-main)",fontSize:16,background:"var(--bg-card)"},children:I}):null,t.jsx("button",{type:"button","aria-label":"Valor siguiente",className:X,style:{bottom:0,height:Vt,color:"var(--text-muted)",opacity:.35},onClick:()=>ne(1),children:t.jsx(W.HiChevronDown,{className:"h-3.5 w-3.5"})})]})}function Wl(){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:wt,width:14,opacity:.45},"aria-hidden":!0,children:":"})}function jl({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",b=m||!d,f=Ff({use12Hour:n,hour12:a}),g=s.useRef(e),h=So(e,Hr()),E=ta(h),[v,S]=s.useState(Re(f?E.hour12:h.hour24)),[A,C]=s.useState(Re(h.minute)),[O,N]=s.useState(Re(h.second)),[y,M]=s.useState(E.meridiem),[k,_]=s.useState(0),Y=s.useRef(0),K=s.useRef(!1),D=s.useRef({hour:null,minute:null,second:null,meridiem:null}),[G,U]=s.useState("hour"),ne=s.useMemo(()=>{const ie=["hour","minute"];return o&&ie.push("second"),f&&ie.push("meridiem"),ie},[f,o]),J=s.useCallback(ie=>{U(pe=>{const ae=ne.indexOf(pe);return ne[(ae+ie+ne.length)%ne.length]})},[ne]);s.useEffect(()=>{var ie;(ie=D.current[G])==null||ie.focus()},[G]),s.useEffect(()=>{var ie;U("hour"),(ie=D.current.hour)==null||ie.focus()},[]),s.useEffect(()=>{if(e===g.current)return;g.current=e;const ie=So(e,Hr()),pe=ta(ie);S(Re(f?pe.hour12:ie.hour24)),C(Re(ie.minute)),N(Re(ie.second)),M(pe.meridiem)},[f,e]);const R=s.useMemo(()=>(f?Eo(1,12):Eo(0,23)).map(ie=>Re(ie)),[f]),V=s.useMemo(()=>Eo(0,59).map(ie=>Re(ie)),[]),X=V,de=s.useMemo(()=>["AM","PM"],[]),H=s.useCallback(()=>f?fn({hour12:Number(v),minute:Number(A),second:Number(O),meridiem:y}):{hour24:Number(v),minute:Number(A),second:Number(O)},[v,f,y,A,O]),I=s.useCallback(ie=>{if(K.current)return;const pe=un(ie,o);g.current=pe,r(pe)},[r,o]),le=s.useCallback(()=>{I(H())},[H,I]),L=ie=>{S(ie),b&&I(f?fn({hour12:Number(ie),minute:Number(A),second:Number(O),meridiem:y}):{hour24:Number(ie),minute:Number(A),second:Number(O)})},oe=ie=>{C(ie),b&&I(f?fn({hour12:Number(v),minute:Number(ie),second:Number(O),meridiem:y}):{hour24:Number(v),minute:Number(ie),second:Number(O)})},w=ie=>{N(ie),b&&I(f?fn({hour12:Number(v),minute:Number(A),second:Number(ie),meridiem:y}):{hour24:Number(v),minute:Number(A),second:Number(ie)})},te=ie=>{M(ie),b&&I(fn({hour12:Number(v),minute:Number(A),second:Number(O),meridiem:ie}))},B=s.useCallback(()=>(Y.current+=1,_(Y.current),Y.current),[]),F=s.useCallback(ie=>{const pe=ta(ie),ae=un(ie,o);g.current=ae,S(Re(f?pe.hour12:ie.hour24)),C(Re(ie.minute)),N(Re(ie.second)),M(pe.meridiem),r(ae)},[f,r,o]),ue=()=>{K.current=!0,B(),F(Hr()),queueMicrotask(()=>{const ie=Hr();un(ie,o)!==g.current&&(B(),F(ie)),K.current=!1})},re=()=>{le(),d==null||d()},j=wt*Co,x=j+Vt*2,T=Vt+j/2-wt/2,ee=t.jsx("div",{className:"relative px-4 py-2",children:t.jsxs("div",{className:"relative mx-auto",style:{height:x,maxWidth:"100%"},children:[t.jsx("div",{className:"pointer-events-none absolute inset-x-1 z-10 rounded-xl",style:{top:T,height:wt,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:Vt,height:wt*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:Vt,height:wt*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(ra,{syncEpochRef:Y,forceSyncAt:k,values:R,selected:v,onSelect:L,label:"Horas",maxNumeric:f?12:23,isFocused:G==="hour",onFocus:()=>U("hour"),onAdvance:()=>J(1),onBack:()=>J(-1),setColumnRef:ie=>{D.current.hour=ie}}),t.jsx(Wl,{}),t.jsx(ra,{syncEpochRef:Y,forceSyncAt:k,values:V,selected:A,onSelect:oe,label:"Minutos",maxNumeric:59,isFocused:G==="minute",onFocus:()=>U("minute"),onAdvance:()=>J(1),onBack:()=>J(-1),setColumnRef:ie=>{D.current.minute=ie}}),o?t.jsxs(t.Fragment,{children:[t.jsx(Wl,{}),t.jsx(ra,{syncEpochRef:Y,forceSyncAt:k,values:X,selected:O,onSelect:w,label:"Segundos",maxNumeric:59,isFocused:G==="second",onFocus:()=>U("second"),onAdvance:()=>J(1),onBack:()=>J(-1),setColumnRef:ie=>{D.current.second=ie}})]}):null,f?t.jsx("div",{className:"ml-3 shrink-0 pl-1",children:t.jsx(ra,{syncEpochRef:Y,forceSyncAt:k,values:de,selected:y,onSelect:ie=>te(ie),width:Bf,label:"AM o PM",isMeridiem:!0,isFocused:G==="meridiem",onFocus:()=>U("meridiem"),onAdvance:()=>J(1),onBack:()=>J(-1),setColumnRef:ie=>{D.current.meridiem=ie}})}):null]})]})}),fe=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(Ve,{variant:"ghost",size:"sm",onClick:ue,className:m?"text-xs":void 0,children:"Ahora"}),!m&&(c||d)?t.jsxs("div",{className:"flex items-center gap-2",children:[c?t.jsx(Ve,{variant:"ghost",size:"sm",onClick:c,children:"Cancelar"}):null,d?t.jsx(Ve,{variant:"primary",size:"sm",onClick:re,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?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,ee,fe]})}function Pf(e){return e.use12Hour??e.hour12??!1}function _f({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:b,helperText:f,helperDisplay:g,className:h,contentClassName:E,className:v=""}){const S=u==="popover",[A,C]=s.useState(!1),O=s.useRef(null),[N,y]=s.useState({horizontal:"left",vertical:"bottom"}),M=Pf({use12Hour:a,hour12:o}),k=s.useMemo(()=>r?Of(r,{use12Hour:M,showSeconds:l}):"",[M,l,r]);s.useEffect(()=>{if(!S||!A||!O.current)return;const K=O.current.getBoundingClientRect(),D=8,G=M?l?300:260:l?252:212,U=276,ne=K.left+G>window.innerWidth-D,J=K.right-G>=D,R=K.bottom+8+U>window.innerHeight-D,V=K.top-8-U>=D;y({horizontal:ne&&J?"right":"left",vertical:R&&V?"top":"bottom"})},[M,S,A,l]),s.useEffect(()=>{if(!S||!A)return;function K(G){O.current&&(O.current.contains(G.target)||C(!1))}function D(G){G.key==="Escape"&&C(!1)}return document.addEventListener("mousedown",K),document.addEventListener("keydown",D),()=>{document.removeEventListener("mousedown",K),document.removeEventListener("keydown",D)}},[S,A]);const _=t.jsxs("button",{type:"button",disabled:d,onClick:()=>{d||C(K=>!K)},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 ${v}`,style:{background:"var(--bg-input)",borderColor:b?"var(--danger)":A?"var(--primary)":"var(--border)",color:k?"var(--text-main)":"var(--text-muted)",boxShadow:A?"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(W.HiClock,{className:"h-4 w-4 shrink-0 text-[var(--text-muted)]"}),t.jsx("span",{className:"truncate",children:k||c})]}),S?t.jsx(W.HiChevronDown,{className:`h-4 w-4 shrink-0 text-[var(--text-muted)] transition-transform duration-150 ${A?"rotate-180":""}`}):null]}),Y=t.jsx(jl,{variant:S?"popover":"panel",value:r||Hf(l),onChange:n,use12Hour:M,showSeconds:l,title:i,onClose:()=>C(!1)});return t.jsx(zn,{label:e,required:m,error:b,helperText:f,helperDisplay:g,className:h,contentClassName:E,children:S?t.jsxs("div",{ref:O,className:"relative w-full",children:[_,A?t.jsx("div",{className:"absolute z-50",style:{...N.horizontal==="left"?{left:0}:{right:0},...N.vertical==="bottom"?{top:"calc(100% + 6px)"}:{bottom:"calc(100% + 6px)"}},children:Y}):null]}):t.jsxs("div",{className:"space-y-2",children:[_,A?Y:null]})})}const zf={xs:{width:28,height:16,thumb:12,padding:2},sm:{width:36,height:20,thumb:16,padding:2}};function Wf({checked:e,disabled:r,onCheckedChange:n,size:a="sm",className:o="",...l}){const i=zf[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 ql=[".sidebar-scroll",".app-scroll",".showcase-nav-scroll","[data-overlay-scroll='true']"].join(","),jf=[":scope > [data-overlayscrollbars-contents]",":scope > .sidebar-scroll-body",":scope > .showcase-nav-scroll-body",":scope > .app-scroll-body"].join(", ");function qf(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 Ul(e){return e.classList.contains("sidebar-scroll")||e.classList.contains("showcase-nav-scroll")}function Vl(e){Ul(e)&&e.querySelectorAll(".os-scrollbar-horizontal").forEach(r=>{r.style.display="none",r.style.height="0",r.style.pointerEvents="none"})}function Uf(e){const r=e.querySelector(jf);return r instanceof HTMLElement?r:null}function Xl(){return s.useEffect(()=>{const e=new WeakMap;let r=0;const n=()=>{r=0,document.querySelectorAll(ql).forEach(l=>{if(!(l instanceof HTMLElement))return;if(Oa.OverlayScrollbars(l)){Vl(l);return}if(!qf(l))return;const c={overflow:Ul(l)?{x:"hidden",y:"scroll"}:void 0,scrollbars:{autoHide:"leave",autoHideDelay:180}},d=Uf(l),u=d?Oa.OverlayScrollbars({target:l,elements:{viewport:d}},c):Oa.OverlayScrollbars(l,c);Vl(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(ql).forEach(l=>{var i;l instanceof HTMLElement&&((i=e.get(l))==null||i.destroy())})}},[]),null}function rr(e){const r=e.trim();return!r||r==="/"||r==="/."?"":(r.startsWith("/")?r:`/${r}`).replace(/\/+$/,"")}function Yl(e){try{const r=new URL(e);return rr(r.pathname)}catch{return""}}function Vf(e){const r=rr(e);if(!r)return"";const n=r.match(/^\/apps\/[^/]+/i);if(n)return rr(n[0]);const a=r.split("/").filter(Boolean);return a.length===0?"":a.length>=2&&a[0].toLowerCase()==="apps"?rr(`/${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())?"":rr(`/${a[0]}`)}const Mo="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"}},Kl={xs:20,sm:28,md:36,lg:48,xl:64},Gl=["bg-indigo-500","bg-blue-500","bg-emerald-500","bg-violet-500","bg-amber-500","bg-teal-500","bg-rose-500","bg-cyan-500"],Yf={xs:"text-xs",sm:"text-sm",md:"text-base",lg:"text-lg"},Kf="bonsaif.bot",Gf="Bonsaif Bot",Zf={xs:"p-0.5",sm:"p-1",md:"p-1.5",lg:"p-2",xl:"p-2.5"};function Zl(e){return typeof e=="string"?e.trim():""}function Qf(e){var o;if(e!==void 0)return rr(e);const r=rr(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(Mo)||"";i&&window.sessionStorage.setItem(Mo,i);const c=window.sessionStorage.getItem(Mo)||"",d=i||c;if(d){const u=Yl(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")?Yl(a):rr(a);if(l&&!/^\/admin(\/|$)/i.test(l))return l}return Vf(window.location.pathname)}function Jf(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 Rf(e){let r=0;for(const n of e)r=r*31+n.charCodeAt(0)&65535;return Gl[r%Gl.length]}function eb(e,r){return e===Kf||r===Gf}function tb(e,r){return`${e.replace(/\/$/,"")}${r}`}function Ql({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:b="xs",avatarVersion:f=0,className:g="",style:h}){const[E,v]=s.useState(!1),S=typeof e=="string"&&e.trim()&&e!=="undefined"&&e!=="null"?e.trim():"";s.useEffect(()=>{v(!1)},[S,f]);const{wh:A,text:C}=Xf[a],O=Zl(n)||Zl(r)||c,N=Jf(O),y=Qf(d),M=eb(r,n),k=tb(y,"/favicon.svg"),_=s.useMemo(()=>{if(!S)return"";const U=new URLSearchParams;U.set("size",String(Kl[a])),f&&U.set("v",String(f));const ne=U.toString();return`${y}/api/user/avatar/${encodeURIComponent(S)}${ne?`?${ne}`:""}`},[f,y,S,a]),Y=Kl[a],K=M?t.jsx("span",{className:`${A} ${Zf[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 ${g}`,style:h,children:t.jsx("img",{src:k,alt:O,width:Y,height:Y,className:"h-full w-full object-contain"})}):_&&!E?t.jsx("img",{src:_,alt:O,width:Y,height:Y,className:`${A} rounded-full object-cover flex-shrink-0 ${g}`,style:h,loading:"lazy",referrerPolicy:"no-referrer",onError:()=>v(!0)},`${S}-${f}`):t.jsx("span",{className:`${A} ${Rf(O)} ${C} rounded-full flex items-center justify-center font-black text-white uppercase flex-shrink-0 ${g}`,style:h,title:O,children:N});if(o)return t.jsxs("span",{className:`inline-flex min-w-0 items-center gap-2 ${u}`,children:[K,t.jsx("span",{className:`min-w-0 truncate ${Yf[b]} font-medium text-[var(--text-main)] ${m}`,title:O,children:O})]});const D=l??!0,G=i??O;return D&&G?t.jsx(Bt,{as:"span",content:G,className:`inline-flex flex-shrink-0 ${u}`,children:K}):K}function rb({href:e,className:r,children:n}){return t.jsx("a",{href:e,className:r,children:n})}function nb(e){return e.reduce((r,n)=>{const a=n.section??"Principal";return r[a]=[...r[a]??[],n],r},{})}function Jl({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=rb}){const[m,b]=s.useState(!1),f=nb(r);return t.jsxs("div",{className:"min-h-screen bg-[var(--bg-main)] text-[var(--text-main)]",children:[t.jsx(Xl,{}),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(W.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(W.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:()=>b(!1),children:t.jsx(W.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(([g,h])=>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(W.HiChevronDown,{className:"h-3.5 w-3.5"}),g]}),t.jsx("div",{className:"space-y-1",children:h.map(E=>{const v=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 ${v?"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(W.HiHome,{className:"h-4 w-4"})}),t.jsx("span",{className:"truncate",children:E.label})]},E.href)})})]},g))})}),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(Ql,{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(Ve,{variant:"ghost",className:"w-full justify-start text-white hover:bg-white/10",onClick:d,children:[t.jsx(W.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 Rl="bonsaif-ui:prime-auth-sso",ab={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"},To={dashboard:t.jsx(W.HiChartBar,{className:"h-5 w-5"}),tickets:t.jsx(W.HiTicket,{className:"h-5 w-5"}),teams:t.jsx(W.HiUsers,{className:"h-5 w-5"}),projects:t.jsx(W.HiRectangleGroup,{className:"h-5 w-5"}),clients:t.jsx(W.HiBuildingOffice2,{className:"h-5 w-5"}),surveys:t.jsx(W.HiClipboardDocumentList,{className:"h-5 w-5"}),profile:t.jsx(W.HiUser,{className:"h-5 w-5"}),settings:t.jsx(W.HiCog6Tooth,{className:"h-5 w-5"}),notifications:t.jsx(W.HiBell,{className:"h-5 w-5"}),changelog:t.jsx(W.HiDocumentText,{className:"h-5 w-5"}),admin:t.jsx(W.HiShieldCheck,{className:"h-5 w-5"}),users:t.jsx(W.HiUsers,{className:"h-5 w-5"}),roles:t.jsx(W.HiShieldCheck,{className:"h-5 w-5"}),menus:t.jsx(W.HiCog6Tooth,{className:"h-5 w-5"}),guards:t.jsx(W.HiCalendarDays,{className:"h-5 w-5"}),vacations:t.jsx(W.HiCalendarDays,{className:"h-5 w-5"}),audit:t.jsx(W.HiListBullet,{className:"h-5 w-5"}),positions:t.jsx(W.HiBriefcase,{className:"h-5 w-5"}),ranks:t.jsx(W.HiListBullet,{className:"h-5 w-5"}),"email-inbox":t.jsx(W.HiInbox,{className:"h-5 w-5"}),"security-incidents":t.jsx(W.HiShieldCheck,{className:"h-5 w-5"})};function ob(e){return e.split("-").map(r=>r.charAt(0).toUpperCase()+r.slice(1)).join(" ")}function sb(e){return/^\d+$/.test(e)||/^[a-f0-9]{8,}$/i.test(e)}function lb(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=sb(n)&&a?a:n,l=ab[o]??ob(o);return[{label:"Inicio",href:"/"},{label:l}]}function $o(e){return(e==null?void 0:e.querySelector(":scope > .os-viewport"))??(e==null?void 0:e.querySelector(":scope > [data-overlayscrollbars-viewport]"))}function ib(e){const r=e.split("/").filter(Boolean),n=r[r.length-1];if(!n)return t.jsx(W.HiHome,{className:"h-5 w-5"});if(To[n])return To[n];const a=r.length>1?r[r.length-2]:"";return To[a]??t.jsx(W.HiHome,{className:"h-5 w-5"})}function cb(e){return e.includes("primeAuthOrigin")||e.includes("primeAuthProjectKey")}function ei(){if(typeof window>"u")return!1;if(cb(window.location.href)){try{window.sessionStorage.setItem(Rl,"true")}catch{}return!0}try{return window.sessionStorage.getItem(Rl)==="true"}catch{return!1}}function db({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 b=s.useRef(null),[f,g]=s.useState(!1),[h,E]=s.useState(d??"/"),[v,S]=s.useState(()=>ei()),[A,C]=s.useState(null),O=d??h,N=c??lb(O),y=o??ib(O),M=u&&!v&&N.length>1,k=!M;s.useEffect(()=>{d||E(window.location.pathname)},[d]),s.useEffect(()=>{S(ei())},[]),s.useEffect(()=>{if(m){g(!1);return}let Y=null,K=0,D=0;const G=()=>{const J=b.current,R=document.querySelector("[data-app-scroll='true']");return(J==null?void 0:J.closest(".os-viewport"))??(J==null?void 0:J.closest("[data-overlayscrollbars-viewport]"))??$o(R)??R??window},U=()=>{const J=Y&&Y!==window?Y.scrollTop:window.scrollY;g(R=>R?J>24:J>72)},ne=()=>{Y==null||Y.removeEventListener("scroll",U),Y=G(),Y.addEventListener("scroll",U,{passive:!0}),U()};return ne(),K=window.requestAnimationFrame(ne),D=window.setTimeout(ne,120),()=>{window.cancelAnimationFrame(K),window.clearTimeout(D),Y==null||Y.removeEventListener("scroll",U)}},[m]),s.useEffect(()=>{if(m){C(null);return}let Y=0;const K=[],D=()=>{const X=b.current,de=X==null?void 0:X.parentElement,H=document.querySelector("[data-app-scroll='true']"),I=$o(H)??H;if(!X||!de||!I){C(null);return}const le=de.getBoundingClientRect(),L=window.getComputedStyle(de),oe=I.getBoundingClientRect(),w=I instanceof HTMLElement&&I.clientWidth>0?I.clientWidth:oe.width,te=le.left+parseFloat(L.paddingLeft||"0"),B={marginLeft:Math.round(oe.left-te),width:Math.round(w)};C(F=>F&&F.marginLeft===B.marginLeft&&F.width===B.width?F:B)},G=()=>{window.cancelAnimationFrame(Y),Y=window.requestAnimationFrame(D)};G(),window.addEventListener("resize",G);const U=new ResizeObserver(G),ne=b.current,J=ne==null?void 0:ne.parentElement,R=document.querySelector("[data-app-scroll='true']"),V=$o(R)??R;return[J,R,V].forEach(X=>{X&&U.observe(X)}),K.push(window.setTimeout(G,120)),K.push(window.setTimeout(G,280)),()=>{window.cancelAnimationFrame(Y),window.removeEventListener("resize",G),U.disconnect(),K.forEach(X=>window.clearTimeout(X))}},[m]);const _={...A?{marginLeft:A.marginLeft,width:A.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:_,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":k?"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||k?"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||k?"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:M?"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(Jo.Provider,{value:{compact:!0,headerAction:!0},children:n})})]})})}function ub({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(Jl,{currentPath:r,...a,children:e})}function ti(){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 fb(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 bb({name:e,src:r,projectKey:n}){const[a,o]=s.useState("system"),l=s.useRef(null);s.useEffect(()=>{o(ti());const d=new MutationObserver(()=>o(ti()));return d.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>d.disconnect()},[]);const i=s.useMemo(()=>fb(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 g,h,E;if(m.source!==((g=l.current)==null?void 0:g.contentWindow)||c&&m.origin!==c)return;if(((h=m.data)==null?void 0:h.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 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 mb(){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:ri(c.data.width,96,720),height:ri(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 ri(e,r,n){const a=typeof e=="number"&&Number.isFinite(e)?e:r;return Math.max(r,Math.min(n,Math.ceil(a)))}function pb(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 hb(){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 gb(){return"light"}function vb({position:e="bottom-center"}){const r=s.useSyncExternalStore(pb,hb,gb);return t.jsx(Ha.Toaster,{position:e,theme:r,richColors:!0,closeButton:!0})}function yb({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 bn=["var(--primary)","#38bdf8","#34d399","#a78bfa","#2dd4bf","#fbbf24","#60a5fa","#94a3b8"];function ni(e,r){return e.color??bn[r%bn.length]}function _t(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 Nt=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 Ir(e){if(e==null||e==="")return null;const r=typeof e=="number"?e:Number(e);return Number.isFinite(r)?r:null}const Ao={warning:70,danger:90};function na(e,r=Ao){const n=r.warning??Ao.warning,a=r.danger??Ao.danger;return e>=a?"danger":e>=n?"warning":e<=0?"primary":"success"}function mn(e,r){return _t(na(e,r))}function Br(e,r=0){return Number.isFinite(e)?`${e.toFixed(r)}%`:"—"}function Fr(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 ai(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 Pr(e,r){var n;for(let a=e.length-1;a>=0;a-=1){const o=Ir((n=e[a])==null?void 0:n[r]);if(o!==null)return o}return null}function kt({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 St({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 nr=680,fr="ease-out",xb={top:18,right:8,bottom:12,left:0};function pn(e){return{...xb,...e}}function hn(e){return e.map((r,n)=>({...r,color:ni(r,n),label:r.label??r.key}))}function aa(e,r){return!e.length||!r.length||e.every(n=>r.every(a=>Ir(n[a.key])===null))}function Et(){return{fill:"var(--text-muted)",fontSize:10,fontWeight:500,letterSpacing:"0.02em"}}function gn(){return"color-mix(in srgb, var(--border) 55%, transparent)"}function oi(){return"color-mix(in srgb, var(--primary) 45%, var(--border))"}function oa(){return{paddingBottom:12,paddingLeft:4,fontSize:11,fontWeight:600,letterSpacing:"0.04em",textTransform:"uppercase",color:"var(--text-muted)"}}function wb(e,r=Nt){if(e==null||e==="")return"—";const n=typeof e=="number"?e:Number(e);return Number.isFinite(n)?r(n):String(e)}function si(e){return`bonsaif-grad-${e.replace(/[^a-zA-Z0-9_-]/g,"")}`}function Nb({active:e,label:r,payload:n,valueFormat:a=Nt}){var c,d,u,m,b,f;if(!e||!(n!=null&&n.length))return null;const o=n.filter(g=>g.dataKey!=="base"&&g.name!=="base"&&g.value!==null&&g.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)??((f=(b=o[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:o.map((g,h)=>{const E=g.payload,v=E&&typeof E.display=="number"?E.display:g.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:g.color??"var(--primary)"}}),g.name??g.dataKey]}),t.jsx("span",{className:"bonsaif-chart-tooltip-value",children:wb(v,a)})]},String(g.dataKey??g.name??h))})})]})}function _r({valueFormat:e,content:r,cursor:n,offset:a=12,wrapperStyle:o,allowEscapeViewBox:l,reverseDirection:i,...c}){return t.jsx(Me.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(Nb,{valueFormat:e})})}function li(e,r,n){return n==null?-1:e.findIndex(a=>String(a[r])===String(n))}function ii(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 sa(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),b=!!a&&e.length>1,f=b&&(o==="brush"||o==="both"),g=b&&(o==="drag"||o==="both"),h=s.useCallback(K=>{d(K),i==null||i(K)},[i]),E=s.useCallback(()=>{m(null),h(null)},[h]),v=!!c,S=s.useMemo(()=>!c||f?e:e.slice(c.startIndex,c.endIndex+1),[e,f,c]),A=s.useCallback((K,D)=>{const G=li(e,r,K),U=li(e,r,D);G<0||U<0||h(ii(G,U,e.length))},[h,e,r]),C=s.useCallback(K=>{g&&((K==null?void 0:K.activeLabel)===void 0||(K==null?void 0:K.activeLabel)===null||m({leftLabel:K.activeLabel,rightLabel:K.activeLabel}))},[g]),O=s.useCallback(K=>{!g||!u||(K==null?void 0:K.activeLabel)===void 0||(K==null?void 0:K.activeLabel)===null||m(D=>D&&{...D,rightLabel:K.activeLabel})},[u,g]),N=s.useCallback(()=>{if(g){if(!u||u.rightLabel===null||u.rightLabel===void 0){m(null);return}A(u.leftLabel,u.rightLabel),m(null)}},[A,u,g]),y=s.useCallback(K=>{if(f){if(!K){h(null);return}h(ii(K.startIndex??0,K.endIndex??e.length-1,e.length))}},[h,e.length,f]),M=g?{onMouseDown:C,onMouseMove:O,onMouseUp:N,onMouseLeave:()=>{u&&N()}}:{},k=c??{startIndex:0,endIndex:Math.max(0,e.length-1)},_=t.jsxs(t.Fragment,{children:[g&&u&&u.rightLabel!==null&&u.rightLabel!==void 0?t.jsx(Me.ReferenceArea,{x1:u.leftLabel,x2:u.rightLabel,strokeOpacity:.18,fill:"var(--primary)",fillOpacity:.12,stroke:"var(--primary)"}):null,f?t.jsx(Me.Brush,{dataKey:r,height:l,stroke:"var(--primary)",fill:"color-mix(in srgb, var(--primary) 10%, var(--bg-card))",travellerWidth:8,startIndex:k.startIndex,endIndex:k.endIndex,onChange:y,tickFormatter:K=>String(K)}):null]}),Y=f?{bottom:Math.max(l+10,36)}:void 0;return{enabled:b,showBrush:f,showDrag:g,viewData:S,isZoomed:v,resetZoom:E,chartHandlers:M,zoomNodes:_,marginExtra:Y}}function la({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 kb({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:b=Nt,yDomain:f,ariaLabel:g="Gráfico de líneas",curve:h=!0,strokeWidth:E=2.25,zoomable:v=!1,zoomMode:S="both",brushHeight:A,onZoomChange:C}){const O=aa(e,n),N=hn(n),y=sa(e,r,{zoomable:v,zoomMode:S,brushHeight:A,onZoomChange:C}),M=pn({...m,...y.marginExtra});return l?t.jsx(kt,{height:a}):O?t.jsx(St,{height:a,text:i}):t.jsxs("div",{className:`bonsaif-chart bonsaif-line-chart w-full ${o}`,role:"img","aria-label":g,style:{height:a},children:[t.jsx(la,{visible:y.isZoomed,onReset:y.resetZoom}),t.jsx(Me.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Me.LineChart,{data:y.viewData,margin:M,...y.chartHandlers,children:[c?t.jsx(Me.CartesianGrid,{strokeDasharray:"2 8",stroke:gn(),vertical:!1}):null,t.jsx(Me.XAxis,{dataKey:r,tick:Et(),tickLine:!1,axisLine:!1,padding:{left:0,right:0},interval:"preserveStartEnd",minTickGap:52,dy:6}),t.jsx(Me.YAxis,{tick:Et(),tickLine:!1,axisLine:!1,width:44,domain:f??["auto","auto"],tickFormatter:k=>b(Number(k)),dx:-2}),u?t.jsx(_r,{valueFormat:b,cursor:{stroke:oi(),strokeWidth:1.25,strokeDasharray:"4 4"}}):null,d?t.jsx(Me.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:oa()}):null,N.map((k,_)=>t.jsx(Me.Line,{type:h?"monotone":"linear",dataKey:k.key,name:k.label,stroke:k.color,strokeWidth:_===0?E+.35:E,strokeOpacity:_===0?1:.88,isAnimationActive:!0,animationDuration:nr,animationEasing:fr,dot:!1,activeDot:{r:5,strokeWidth:2,stroke:"var(--bg-card)",fill:k.color}},k.key)),y.zoomNodes]})})]})}function ia({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:b=Nt,yDomain:f,ariaLabel:g="Gráfico de área",stacked:h=!1,opacity:E=.22,zoomable:v=!1,zoomMode:S="both",brushHeight:A,onZoomChange:C}){const O=aa(e,n),N=hn(n),y=sa(e,r,{zoomable:v,zoomMode:S,brushHeight:A,onZoomChange:C}),M=pn({...m,...y.marginExtra});return l?t.jsx(kt,{height:a}):O?t.jsx(St,{height:a,text:i}):t.jsxs("div",{className:`bonsaif-chart bonsaif-area-chart w-full ${o}`,role:"img","aria-label":g,style:{height:a},children:[t.jsx(la,{visible:y.isZoomed,onReset:y.resetZoom}),t.jsx(Me.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Me.AreaChart,{data:y.viewData,margin:M,...y.chartHandlers,children:[t.jsx("defs",{children:N.map(k=>t.jsxs("linearGradient",{id:si(k.key),x1:"0",y1:"0",x2:"0",y2:"1",children:[t.jsx("stop",{offset:"0%",stopColor:k.color,stopOpacity:Math.min(.55,E+.28)}),t.jsx("stop",{offset:"48%",stopColor:k.color,stopOpacity:E*.5}),t.jsx("stop",{offset:"100%",stopColor:k.color,stopOpacity:0})]},k.key))}),c?t.jsx(Me.CartesianGrid,{strokeDasharray:"2 8",stroke:gn(),vertical:!1}):null,t.jsx(Me.XAxis,{dataKey:r,tick:Et(),tickLine:!1,axisLine:!1,padding:{left:0,right:0},interval:"preserveStartEnd",minTickGap:52,dy:6}),t.jsx(Me.YAxis,{tick:Et(),tickLine:!1,axisLine:!1,width:44,domain:f??["auto","auto"],tickFormatter:k=>b(Number(k)),dx:-2}),u?t.jsx(_r,{valueFormat:b,cursor:{stroke:oi(),strokeWidth:1.25,strokeDasharray:"4 4"}}):null,d?t.jsx(Me.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:oa()}):null,N.map(k=>t.jsx(Me.Area,{type:"monotone",dataKey:k.key,name:k.label,stroke:k.color,fill:`url(#${si(k.key)})`,strokeWidth:2.25,stackId:h?"stack":void 0,isAnimationActive:!0,animationDuration:nr,animationEasing:fr,dot:!1,activeDot:{r:5,strokeWidth:2,stroke:"var(--bg-card)",fill:k.color}},k.key)),y.zoomNodes]})})]})}function Sb({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:b=Nt,yDomain:f,ariaLabel:g="Gráfico de barras",layout:h="vertical",mode:E="grouped",barRadius:v=6,categoryAxisWidth:S=64,zoomable:A=!1,zoomMode:C="both",brushHeight:O,onZoomChange:N}){const y=aa(e,n),M=hn(n),k=h==="horizontal",_=sa(e,r,{zoomable:A&&!k,zoomMode:C,brushHeight:O,onZoomChange:N}),Y=pn({...m,..._.marginExtra});return l?t.jsx(kt,{height:a}):y?t.jsx(St,{height:a,text:i}):t.jsxs("div",{className:`bonsaif-chart bonsaif-bar-chart w-full ${o}`,role:"img","aria-label":g,style:{height:a},children:[t.jsx(la,{visible:_.isZoomed,onReset:_.resetZoom}),t.jsx(Me.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Me.BarChart,{data:_.viewData,margin:Y,layout:k?"vertical":"horizontal",barCategoryGap:"34%",barGap:3,..._.chartHandlers,children:[c?t.jsx(Me.CartesianGrid,{strokeDasharray:"2 8",stroke:gn(),horizontal:!k,vertical:k}):null,k?t.jsxs(t.Fragment,{children:[t.jsx(Me.XAxis,{type:"number",tick:Et(),tickLine:!1,axisLine:!1,tickFormatter:K=>b(Number(K)),domain:f??["auto","auto"]}),t.jsx(Me.YAxis,{type:"category",dataKey:r,tick:Et(),tickLine:!1,axisLine:!1,width:S})]}):t.jsxs(t.Fragment,{children:[t.jsx(Me.XAxis,{dataKey:r,tick:Et(),tickLine:!1,axisLine:!1,interval:"preserveStartEnd",minTickGap:36,dy:6}),t.jsx(Me.YAxis,{tick:Et(),tickLine:!1,axisLine:!1,width:44,domain:f??["auto","auto"],tickFormatter:K=>b(Number(K)),dx:-2})]}),u?t.jsx(_r,{valueFormat:b,cursor:{fill:"color-mix(in srgb, var(--primary) 8%, transparent)"}}):null,d?t.jsx(Me.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:oa()}):null,M.map((K,D)=>t.jsx(Me.Bar,{dataKey:K.key,name:K.label,fill:K.color,fillOpacity:D===0?1:.82,radius:k?[0,v,v,0]:[v,v,2,2],maxBarSize:20,stackId:E==="stacked"?"stack":void 0,isAnimationActive:!0,animationDuration:nr,animationEasing:fr},K.key)),_.zoomNodes]})})]})}function Eb(e){return t.jsx(di,{...e,variant:"pie"})}function Cb(e){return t.jsx(di,{...e,variant:"donut",innerRadius:e.innerRadius??.62,cornerRadius:e.cornerRadius??10,padAngle:e.padAngle??2})}function ci(e,r){return e==null||!Number.isFinite(e)?r:e>0&&e<=1?e*100:e}function di({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=Nt,ariaLabel:m,innerRadius:b,outerRadius:f,colors:g=[...bn],padAngle:h,cornerRadius:E,variant:v}){const S=e.map((D,G)=>({name:String(D[r]??""),value:Ir(D[n])??0,fill:g[G%g.length],row:D})).filter(D=>D.value>0),A=!S.length,C=v==="donut",O=S.length,N=ci(b,C?62:12),y=ci(f,78),M=Math.min(h??(C?2:3),Math.max(.5,10/Math.max(1,O))),k=Math.min(E??(C?10:8),Math.max(2,36/Math.max(1,O)));if(l)return t.jsx(kt,{height:a});if(A)return t.jsx(St,{height:a,text:i});const _=S.reduce((D,G)=>D+G.value,0),Y=c?Math.min(96,28+Math.ceil(O/3)*22):0,K=Math.max(140,a-Y);return t.jsx("div",{className:`bonsaif-chart bonsaif-${v}-chart w-full ${o}`,role:"img","aria-label":m??(v==="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:K},children:t.jsx(Me.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Me.PieChart,{margin:{top:4,right:4,bottom:4,left:4},children:[d?t.jsx(_r,{valueFormat:u,isAnimationActive:!1}):null,t.jsx(Me.Pie,{data:S,dataKey:"value",nameKey:"name",cx:"50%",cy:"50%",innerRadius:`${N}%`,outerRadius:`${y}%`,startAngle:90,endAngle:-270,paddingAngle:M,cornerRadius:k,minAngle:O>6?3:2,stroke:"var(--bg-card)",strokeWidth:2,isAnimationActive:!0,animationDuration:nr,animationEasing:fr,label:!1,activeShape:Mb,children:S.map(D=>t.jsx(Me.Cell,{fill:D.fill},D.name))}),C?t.jsx("text",{x:"50%",y:"50%",textAnchor:"middle",dominantBaseline:"middle",fill:"var(--text-main)",fontSize:18,fontWeight:700,letterSpacing:"-0.02em",children:u(_)}):null]})})}),c?t.jsx("ul",{className:"bonsaif-pie-legend","aria-label":"Leyenda",children:S.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 Mb(e){const{outerRadius:r=0,...n}=e;return t.jsx(Me.Sector,{...n,outerRadius:Number(r)+4,stroke:"var(--bg-card)",strokeWidth:2})}function Tb({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??_t(o),m=e.map(y=>Ir(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,g=3,h=1,E=Math.min(...m),S=Math.max(...m)-E||1,A=m.map((y,M)=>{const k=h+M/(m.length-1)*(b-h*2),_=f-g-(y-E)/S*(f-g*2);return{x:k,y:_}}),C=A.map((y,M)=>`${M===0?"M":"L"}${y.x.toFixed(2)} ${y.y.toFixed(2)}`).join(" "),O=`${C} L${A[A.length-1].x.toFixed(2)} ${f} L${A[0].x.toFixed(2)} ${f} Z`,N=`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 ${b} ${f}`,preserveAspectRatio:"none",focusable:"false",children:[i?t.jsx("defs",{children:t.jsxs("linearGradient",{id:N,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:O,fill:`url(#${N})`}):null,t.jsx("path",{d:C,fill:"none",stroke:u,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",vectorEffect:"non-scaling-stroke"})]})})}function $b({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:b=!0,margin:f,valueFormat:g=Nt,yDomain:h,ariaLabel:E="Gráfico combinado",barRadius:v=6,zoomable:S=!1,zoomMode:A="both",brushHeight:C,onZoomChange:O}){const N=a??n.slice(0,Math.max(1,n.length-1)),y=o??(n.length>1?n.slice(-1):n.length?[n[0]]:[]),M=[...N,...y.filter(U=>!N.some(ne=>ne.key===U.key))],k=aa(e,M),_=hn(N),Y=hn(M),K=y.map(U=>{var J;const ne=Y.find(R=>R.key===U.key);return{...U,label:U.label??U.key,color:U.color??(ne==null?void 0:ne.color)??((J=Y[0])==null?void 0:J.color)}}),D=sa(e,r,{zoomable:S,zoomMode:A,brushHeight:C,onZoomChange:O}),G=pn({...f,...D.marginExtra});return c?t.jsx(kt,{height:l}):k?t.jsx(St,{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(la,{visible:D.isZoomed,onReset:D.resetZoom}),t.jsx(Me.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Me.ComposedChart,{data:D.viewData,margin:G,barCategoryGap:"34%",...D.chartHandlers,children:[u?t.jsx(Me.CartesianGrid,{strokeDasharray:"2 8",stroke:gn(),vertical:!1}):null,t.jsx(Me.XAxis,{dataKey:r,tick:Et(),tickLine:!1,axisLine:!1,interval:"preserveStartEnd",minTickGap:36,dy:6}),t.jsx(Me.YAxis,{tick:Et(),tickLine:!1,axisLine:!1,width:44,domain:h??["auto","auto"],tickFormatter:U=>g(Number(U)),dx:-2}),b?t.jsx(_r,{valueFormat:g,cursor:{fill:"color-mix(in srgb, var(--primary) 8%, transparent)"}}):null,m?t.jsx(Me.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:oa()}):null,_.map(U=>t.jsx(Me.Bar,{dataKey:U.key,name:U.label,fill:U.color,fillOpacity:.88,radius:[v,v,2,2],maxBarSize:18,isAnimationActive:!0,animationDuration:nr,animationEasing:fr},U.key)),K.map(U=>t.jsx(Me.Line,{type:"monotone",dataKey:U.key,name:U.label,stroke:U.color,strokeWidth:2.5,isAnimationActive:!0,animationDuration:nr,animationEasing:fr,dot:!1,activeDot:{r:5,strokeWidth:2,stroke:"var(--bg-card)",fill:U.color}},U.key)),D.zoomNodes]})})]})}function Ab({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:b=Nt,ariaLabel:f="Gráfico waterfall",increaseColor:g="#34d399",decreaseColor:h="#f87171",totalColor:E="var(--primary)"}){const v=s.useMemo(()=>Lb(e,{xKey:r,valueKey:n,typeKey:a,increaseColor:g,decreaseColor:h,totalColor:E}),[e,r,n,a,g,h,E]),S=!v.length,A=pn(m);return i?t.jsx(kt,{height:o}):S?t.jsx(St,{height:o,text:c}):t.jsx("div",{className:`bonsaif-chart bonsaif-waterfall-chart w-full ${l}`,role:"img","aria-label":f,style:{height:o},children:t.jsx(Me.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Me.BarChart,{data:v,margin:A,barCategoryGap:"42%",children:[d?t.jsx(Me.CartesianGrid,{strokeDasharray:"2 8",stroke:gn(),vertical:!1}):null,t.jsx(Me.XAxis,{dataKey:"label",tick:Et(),tickLine:!1,axisLine:!1,interval:0,dy:6}),t.jsx(Me.YAxis,{tick:Et(),tickLine:!1,axisLine:!1,width:44,tickFormatter:C=>b(Number(C)),dx:-2}),u?t.jsx(_r,{valueFormat:b,cursor:{fill:"color-mix(in srgb, var(--primary) 8%, transparent)"}}):null,t.jsx(Me.Bar,{dataKey:"base",stackId:"wf",fill:"transparent",isAnimationActive:!1,legendType:"none",maxBarSize:22}),t.jsx(Me.Bar,{dataKey:"delta",name:"Valor",stackId:"wf",radius:[6,6,2,2],maxBarSize:22,isAnimationActive:!0,animationDuration:nr,animationEasing:fr,children:v.map(C=>t.jsx(Me.Cell,{fill:C.color},C.label))})]})})})}function Lb(e,r){let n=0;return e.map((a,o)=>{const l=Ir(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,b=l;return c&&i==="total"?(d="total",u=0,m=Math.abs(l),b=l,n=l):c&&o===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 ui="bonsaif-funnel-chart-keyframes",Db=`
|
|
44
|
+
`}),H.map(F=>{const y=Tf(F.colorIndex);return M===F.id?t.jsx("input",{ref:J,value:z,disabled:o,onChange:T=>X(T.target.value),onKeyDown:T=>S(T,F.id),onBlur:()=>le(F.id,z),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(z.length+2,6)}ch`}},F.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:y.bg,color:y.text,border:`1px solid ${y.border}`},children:[t.jsx("span",{className:"truncate",children:F.value}),t.jsx("button",{type:"button","aria-label":`Editar "${F.value}"`,disabled:o,tabIndex:-1,onClick:T=>{T.stopPropagation(),O(F)},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(j.HiPencil,{className:"h-3 w-3"})}),t.jsx("button",{type:"button","aria-label":`Eliminar "${F.value}"`,disabled:o,tabIndex:-1,onClick:T=>{T.stopPropagation(),B(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(j.HiXMark,{className:"h-3.5 w-3.5"})})]},F.id)}),!re&&t.jsx("input",{ref:ne,value:k,disabled:o,placeholder:H.length===0?a:"",onChange:F=>x(F.target.value),onKeyDown:ae,onPaste:_,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(Tr,{error:g,helperText:b,helperDisplay:f})]})}const Of=/^(\d{1,2}):(\d{2})(?::(\d{2}))?$/;function rt(e){return String(e).padStart(2,"0")}function So(e,r=Hr()){const n=e.trim();if(!n)return r;const a=n.match(Of);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 un(e,r=!0){const n=`${rt(e.hour24)}:${rt(e.minute)}`;return r?`${n}:${rt(e.second)}`:n}function ta(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 fn(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 Hf(e,r){const n=(r==null?void 0:r.use12Hour)??!1,a=(r==null?void 0:r.showSeconds)??!0,o=So(e);if(n){const l=ta(o),i=`${l.hour12}:${rt(l.minute)}`;return`${a?`${i}:${rt(l.second)}`:i} ${l.meridiem}`}return un(o,a)}function Hr(){const e=new Date;return{hour24:e.getHours(),minute:e.getMinutes(),second:e.getSeconds()}}function If(e=!0){return un(Hr(),e)}function Eo(e,r){const n=[];for(let a=e;a<=r;a+=1)n.push(a);return n}const Nt=36,Co=5,zl=Math.floor(Co/2),Bf=52,Ff=48,Xt=18;function Wl(e){return e*Nt}function jl(e){return Math.round(e/Nt)}function Pf(e){return e.use12Hour??e.hour12??!1}function ra({values:e,selected:r,onSelect:n,syncEpochRef:a,forceSyncAt:o=0,width:l=Bf,label:i,maxNumeric:c=59,isMeridiem:d=!1,isFocused:u=!1,onFocus:m,onAdvance:b,onBack:f,setColumnRef:g}){const p=s.useRef(null),E=s.useRef(null),v=s.useRef(null),w=s.useRef(""),A=s.useRef(0),C=s.useRef(!1),[H,k]=s.useState(r),[x,M]=s.useState(""),N=s.useCallback(O=>{w.current=O,M(O)},[]),z=s.useMemo(()=>[...Array(zl).fill(""),...e,...Array(zl).fill("")],[e]),X=s.useCallback(()=>{const O=p.current;if(!O)return r;const ae=jl(O.scrollTop),S=Math.min(Math.max(ae,0),e.length-1);return e[S]??r},[r,e]),K=s.useCallback((O,ae=!0)=>{const S=Math.min(Math.max(O,0),e.length-1),ee=e[S],_=p.current;!_||!ee||(E.current&&(window.clearTimeout(E.current),E.current=null),C.current=!0,A.current=S,_.scrollTop=Wl(S),k(ee),ae&&ee!==r&&n(ee))},[n,r,e]);s.useLayoutEffect(()=>{E.current&&(window.clearTimeout(E.current),E.current=null),v.current&&(window.clearTimeout(v.current),v.current=null),N(""),k(r);const O=e.indexOf(r);if(O>=0&&(A.current=O),O<0||!p.current)return;const ae=Wl(O);p.current.scrollTop!==ae&&(p.current.scrollTop=ae)},[o,r,N,e]);const D=s.useCallback(()=>{v.current&&(window.clearTimeout(v.current),v.current=null)},[]),G=s.useCallback((O,ae=!1)=>{D(),N("");const S=Number(O);if(!Number.isFinite(S))return;const ee=Math.min(c,Math.max(0,S));let _=rt(ee),I=e.indexOf(_);if(I<0){const de=Math.min(e.length-1,Math.max(0,ee-(c===12?1:0)));_=e[de]??_,I=e.indexOf(_)}I>=0&&K(I),ae&&(b==null||b())},[D,c,b,K,N,e]),V=s.useCallback(O=>{const ae=Math.floor(c/10),S=w.current;if(S===""){if(O>ae){G(String(O),!0);return}const _=String(O);N(_),v.current=window.setTimeout(()=>{G(w.current,!0)},1200);return}D();const ee=+`${S}${O}`;ee<=c?G(String(ee),!0):G(String(O),!0)},[D,G,c,N]),ne=s.useCallback(O=>{D(),N(""),K(A.current+O)},[D,K,N]),J=O=>{if(d){O.key==="a"||O.key==="A"?(O.preventDefault(),n("AM"),b==null||b()):O.key==="p"||O.key==="P"?(O.preventDefault(),n("PM"),b==null||b()):O.key==="ArrowUp"||O.key==="ArrowDown"?(O.preventDefault(),n(r==="AM"?"PM":"AM")):O.key==="Tab"&&(O.preventDefault(),O.shiftKey?f==null||f():b==null||b());return}if(/^\d$/.test(O.key)){O.preventDefault(),V(Number(O.key));return}O.key==="ArrowUp"?(O.preventDefault(),ne(-1)):O.key==="ArrowDown"?(O.preventDefault(),ne(1)):O.key==="Tab"&&(O.preventDefault(),D(),w.current!==""&&G(w.current,!1),O.shiftKey?f==null||f():b==null||b())},R=s.useCallback(()=>{const O=a.current,ae=p.current;ae&&O===a.current&&K(jl(ae.scrollTop))},[K,a]),U=()=>{if(w.current!=="")return;if(C.current){C.current=!1;const ae=X();k(ae);const S=e.indexOf(ae);S>=0&&(A.current=S);return}k(X()),E.current&&window.clearTimeout(E.current);const O=a.current;E.current=window.setTimeout(()=>{O===a.current&&R()},100)},Y="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=Nt*Co,L=ce+Xt*2,B=x!==""?x:null,le=B!==null;return t.jsxs("div",{ref:g,role:"spinbutton",tabIndex:u?0:-1,"aria-label":i,"aria-valuetext":B??r,"aria-valuenow":d?void 0:Number(r),onFocus:m,onMouseDown:()=>m==null?void 0:m(),onKeyDown:J,onBlur:()=>{D(),w.current!==""&&G(w.current,!1)},className:"relative shrink-0 rounded-lg outline-none",style:{width:l,height:L,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:Y,style:{top:0,height:Xt,color:"var(--text-muted)",opacity:.35},onClick:()=>ne(-1),children:t.jsx(j.HiChevronUp,{className:"h-3.5 w-3.5"})}),t.jsx("div",{ref:p,className:"absolute inset-x-0 overflow-y-auto [scrollbar-width:none] [-ms-overflow-style:none] [&::-webkit-scrollbar]:hidden",style:{top:Xt,height:ce,scrollSnapType:"y mandatory",scrollBehavior:"auto"},onScroll:U,onMouseUp:R,onTouchEnd:R,children:z.map((O,ae)=>{const S=O!==""&&O===H;return t.jsx("button",{type:"button",tabIndex:-1,disabled:!O,onClick:()=>{if(!O)return;const ee=e.indexOf(O);ee>=0&&K(ee)},className:"flex w-full items-center justify-center tabular-nums leading-none disabled:cursor-default",style:{height:Nt,scrollSnapAlign:"center",color:S?"var(--text-main)":"var(--text-muted)",fontSize:S?16:14,fontWeight:S?600:400,opacity:O?le?S?0:.35:S?1:.35:0},children:O},`wheel-${ae}-${O}`)})}),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:Xt+ce/2-Nt/2,height:Nt,color:"var(--text-main)",fontSize:16,background:"var(--bg-card)"},children:B}):null,t.jsx("button",{type:"button","aria-label":"Valor siguiente",className:Y,style:{bottom:0,height:Xt,color:"var(--text-muted)",opacity:.35},onClick:()=>ne(1),children:t.jsx(j.HiChevronDown,{className:"h-3.5 w-3.5"})})]})}function ql(){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:Nt,width:14,opacity:.45},"aria-hidden":!0,children:":"})}function Ul({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",b=m||!d,f=Pf({use12Hour:n,hour12:a}),g=s.useRef(e),p=So(e,Hr()),E=ta(p),[v,w]=s.useState(rt(f?E.hour12:p.hour24)),[A,C]=s.useState(rt(p.minute)),[H,k]=s.useState(rt(p.second)),[x,M]=s.useState(E.meridiem),[N,z]=s.useState(0),X=s.useRef(0),K=s.useRef(!1),D=s.useRef({hour:null,minute:null,second:null,meridiem:null}),[G,V]=s.useState("hour"),ne=s.useMemo(()=>{const se=["hour","minute"];return o&&se.push("second"),f&&se.push("meridiem"),se},[f,o]),J=s.useCallback(se=>{V(he=>{const Ae=ne.indexOf(he);return ne[(Ae+se+ne.length)%ne.length]})},[ne]);s.useEffect(()=>{var se;(se=D.current[G])==null||se.focus()},[G]),s.useEffect(()=>{var se;V("hour"),(se=D.current.hour)==null||se.focus()},[]),s.useEffect(()=>{if(e===g.current)return;g.current=e;const se=So(e,Hr()),he=ta(se);w(rt(f?he.hour12:se.hour24)),C(rt(se.minute)),k(rt(se.second)),M(he.meridiem)},[f,e]);const R=s.useMemo(()=>(f?Eo(1,12):Eo(0,23)).map(se=>rt(se)),[f]),U=s.useMemo(()=>Eo(0,59).map(se=>rt(se)),[]),Y=U,ce=s.useMemo(()=>["AM","PM"],[]),L=s.useCallback(()=>f?fn({hour12:Number(v),minute:Number(A),second:Number(H),meridiem:x}):{hour24:Number(v),minute:Number(A),second:Number(H)},[v,f,x,A,H]),B=s.useCallback(se=>{if(K.current)return;const he=un(se,o);g.current=he,r(he)},[r,o]),le=s.useCallback(()=>{B(L())},[L,B]),O=se=>{w(se),b&&B(f?fn({hour12:Number(se),minute:Number(A),second:Number(H),meridiem:x}):{hour24:Number(se),minute:Number(A),second:Number(H)})},ae=se=>{C(se),b&&B(f?fn({hour12:Number(v),minute:Number(se),second:Number(H),meridiem:x}):{hour24:Number(v),minute:Number(se),second:Number(H)})},S=se=>{k(se),b&&B(f?fn({hour12:Number(v),minute:Number(A),second:Number(se),meridiem:x}):{hour24:Number(v),minute:Number(A),second:Number(se)})},ee=se=>{M(se),b&&B(fn({hour12:Number(v),minute:Number(A),second:Number(H),meridiem:se}))},_=s.useCallback(()=>(X.current+=1,z(X.current),X.current),[]),I=s.useCallback(se=>{const he=ta(se),Ae=un(se,o);g.current=Ae,w(rt(f?he.hour12:se.hour24)),C(rt(se.minute)),k(rt(se.second)),M(he.meridiem),r(Ae)},[f,r,o]),de=()=>{K.current=!0,_(),I(Hr()),queueMicrotask(()=>{const se=Hr();un(se,o)!==g.current&&(_(),I(se)),K.current=!1})},re=()=>{le(),d==null||d()},F=Nt*Co,y=F+Xt*2,T=Xt+F/2-Nt/2,te=t.jsx("div",{className:"relative px-4 py-2",children:t.jsxs("div",{className:"relative mx-auto",style:{height:y,maxWidth:"100%"},children:[t.jsx("div",{className:"pointer-events-none absolute inset-x-1 z-10 rounded-xl",style:{top:T,height:Nt,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:Xt,height:Nt*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:Xt,height:Nt*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(ra,{syncEpochRef:X,forceSyncAt:N,values:R,selected:v,onSelect:O,label:"Horas",maxNumeric:f?12:23,isFocused:G==="hour",onFocus:()=>V("hour"),onAdvance:()=>J(1),onBack:()=>J(-1),setColumnRef:se=>{D.current.hour=se}}),t.jsx(ql,{}),t.jsx(ra,{syncEpochRef:X,forceSyncAt:N,values:U,selected:A,onSelect:ae,label:"Minutos",maxNumeric:59,isFocused:G==="minute",onFocus:()=>V("minute"),onAdvance:()=>J(1),onBack:()=>J(-1),setColumnRef:se=>{D.current.minute=se}}),o?t.jsxs(t.Fragment,{children:[t.jsx(ql,{}),t.jsx(ra,{syncEpochRef:X,forceSyncAt:N,values:Y,selected:H,onSelect:S,label:"Segundos",maxNumeric:59,isFocused:G==="second",onFocus:()=>V("second"),onAdvance:()=>J(1),onBack:()=>J(-1),setColumnRef:se=>{D.current.second=se}})]}):null,f?t.jsx("div",{className:"ml-3 shrink-0 pl-1",children:t.jsx(ra,{syncEpochRef:X,forceSyncAt:N,values:ce,selected:x,onSelect:se=>ee(se),width:Ff,label:"AM o PM",isMeridiem:!0,isFocused:G==="meridiem",onFocus:()=>V("meridiem"),onAdvance:()=>J(1),onBack:()=>J(-1),setColumnRef:se=>{D.current.meridiem=se}})}):null]})]})}),fe=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(Qe,{variant:"ghost",size:"sm",onClick:de,className:m?"text-xs":void 0,children:"Ahora"}),!m&&(c||d)?t.jsxs("div",{className:"flex items-center gap-2",children:[c?t.jsx(Qe,{variant:"ghost",size:"sm",onClick:c,children:"Cancelar"}):null,d?t.jsx(Qe,{variant:"primary",size:"sm",onClick:re,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?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,te,fe]})}function _f(e){return e.use12Hour??e.hour12??!1}function zf({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:b,helperText:f,helperDisplay:g,className:p,contentClassName:E,className:v=""}){const w=u==="popover",[A,C]=s.useState(!1),H=s.useRef(null),[k,x]=s.useState({horizontal:"left",vertical:"bottom"}),M=_f({use12Hour:a,hour12:o}),N=s.useMemo(()=>r?Hf(r,{use12Hour:M,showSeconds:l}):"",[M,l,r]);s.useEffect(()=>{if(!w||!A||!H.current)return;const K=H.current.getBoundingClientRect(),D=8,G=M?l?300:260:l?252:212,V=276,ne=K.left+G>window.innerWidth-D,J=K.right-G>=D,R=K.bottom+8+V>window.innerHeight-D,U=K.top-8-V>=D;x({horizontal:ne&&J?"right":"left",vertical:R&&U?"top":"bottom"})},[M,w,A,l]),s.useEffect(()=>{if(!w||!A)return;function K(G){H.current&&(H.current.contains(G.target)||C(!1))}function D(G){G.key==="Escape"&&C(!1)}return document.addEventListener("mousedown",K),document.addEventListener("keydown",D),()=>{document.removeEventListener("mousedown",K),document.removeEventListener("keydown",D)}},[w,A]);const z=t.jsxs("button",{type:"button",disabled:d,onClick:()=>{d||C(K=>!K)},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 ${v}`,style:{background:"var(--bg-input)",borderColor:b?"var(--danger)":A?"var(--primary)":"var(--border)",color:N?"var(--text-main)":"var(--text-muted)",boxShadow:A?"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(j.HiClock,{className:"h-4 w-4 shrink-0 text-[var(--text-muted)]"}),t.jsx("span",{className:"truncate",children:N||c})]}),w?t.jsx(j.HiChevronDown,{className:`h-4 w-4 shrink-0 text-[var(--text-muted)] transition-transform duration-150 ${A?"rotate-180":""}`}):null]}),X=t.jsx(Ul,{variant:w?"popover":"panel",value:r||If(l),onChange:n,use12Hour:M,showSeconds:l,title:i,onClose:()=>C(!1)});return t.jsx(zn,{label:e,required:m,error:b,helperText:f,helperDisplay:g,className:p,contentClassName:E,children:w?t.jsxs("div",{ref:H,className:"relative w-full",children:[z,A?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:X}):null]}):t.jsxs("div",{className:"space-y-2",children:[z,A?X:null]})})}const Wf={xs:{width:28,height:16,thumb:12,padding:2},sm:{width:36,height:20,thumb:16,padding:2}};function jf({checked:e,disabled:r,onCheckedChange:n,size:a="sm",className:o="",...l}){const i=Wf[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 Vl=[".sidebar-scroll",".app-scroll",".showcase-nav-scroll","[data-overlay-scroll='true']"].join(","),qf=[":scope > [data-overlayscrollbars-contents]",":scope > .sidebar-scroll-body",":scope > .showcase-nav-scroll-body",":scope > .app-scroll-body"].join(", ");function Uf(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 Xl(e){return e.classList.contains("sidebar-scroll")||e.classList.contains("showcase-nav-scroll")}function Yl(e){Xl(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(qf);return r instanceof HTMLElement?r:null}function Kl(){return s.useEffect(()=>{const e=new WeakMap;let r=0;const n=()=>{r=0,document.querySelectorAll(Vl).forEach(l=>{if(!(l instanceof HTMLElement))return;if(Oa.OverlayScrollbars(l)){Yl(l);return}if(!Uf(l))return;const c={overflow:Xl(l)?{x:"hidden",y:"scroll"}:void 0,scrollbars:{autoHide:"leave",autoHideDelay:180}},d=Vf(l),u=d?Oa.OverlayScrollbars({target:l,elements:{viewport:d}},c):Oa.OverlayScrollbars(l,c);Yl(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(Vl).forEach(l=>{var i;l instanceof HTMLElement&&((i=e.get(l))==null||i.destroy())})}},[]),null}function rr(e){const r=e.trim();return!r||r==="/"||r==="/."?"":(r.startsWith("/")?r:`/${r}`).replace(/\/+$/,"")}function Gl(e){try{const r=new URL(e);return rr(r.pathname)}catch{return""}}function Xf(e){const r=rr(e);if(!r)return"";const n=r.match(/^\/apps\/[^/]+/i);if(n)return rr(n[0]);const a=r.split("/").filter(Boolean);return a.length===0?"":a.length>=2&&a[0].toLowerCase()==="apps"?rr(`/${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())?"":rr(`/${a[0]}`)}const Mo="primeSuiteAppUrl",Yf={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"}},Zl={xs:20,sm:28,md:36,lg:48,xl:64},Ql=["bg-indigo-500","bg-blue-500","bg-emerald-500","bg-violet-500","bg-amber-500","bg-teal-500","bg-rose-500","bg-cyan-500"],Kf={xs:"text-xs",sm:"text-sm",md:"text-base",lg:"text-lg"},Gf="bonsaif.bot",Zf="Bonsaif Bot",Qf={xs:"p-0.5",sm:"p-1",md:"p-1.5",lg:"p-2",xl:"p-2.5"};function Jl(e){return typeof e=="string"?e.trim():""}function Jf(e){var o;if(e!==void 0)return rr(e);const r=rr(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(Mo)||"";i&&window.sessionStorage.setItem(Mo,i);const c=window.sessionStorage.getItem(Mo)||"",d=i||c;if(d){const u=Gl(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")?Gl(a):rr(a);if(l&&!/^\/admin(\/|$)/i.test(l))return l}return Xf(window.location.pathname)}function Rf(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 eb(e){let r=0;for(const n of e)r=r*31+n.charCodeAt(0)&65535;return Ql[r%Ql.length]}function tb(e,r){return e===Gf||r===Zf}function rb(e,r){return`${e.replace(/\/$/,"")}${r}`}function Rl({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:b="xs",avatarVersion:f=0,className:g="",style:p}){const[E,v]=s.useState(!1),w=typeof e=="string"&&e.trim()&&e!=="undefined"&&e!=="null"?e.trim():"";s.useEffect(()=>{v(!1)},[w,f]);const{wh:A,text:C}=Yf[a],H=Jl(n)||Jl(r)||c,k=Rf(H),x=Jf(d),M=tb(r,n),N=rb(x,"/favicon.svg"),z=s.useMemo(()=>{if(!w)return"";const V=new URLSearchParams;V.set("size",String(Zl[a])),f&&V.set("v",String(f));const ne=V.toString();return`${x}/api/user/avatar/${encodeURIComponent(w)}${ne?`?${ne}`:""}`},[f,x,w,a]),X=Zl[a],K=M?t.jsx("span",{className:`${A} ${Qf[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 ${g}`,style:p,children:t.jsx("img",{src:N,alt:H,width:X,height:X,className:"h-full w-full object-contain"})}):z&&!E?t.jsx("img",{src:z,alt:H,width:X,height:X,className:`${A} rounded-full object-cover flex-shrink-0 ${g}`,style:p,loading:"lazy",referrerPolicy:"no-referrer",onError:()=>v(!0)},`${w}-${f}`):t.jsx("span",{className:`${A} ${eb(H)} ${C} rounded-full flex items-center justify-center font-black text-white uppercase flex-shrink-0 ${g}`,style:p,title:H,children:k});if(o)return t.jsxs("span",{className:`inline-flex min-w-0 items-center gap-2 ${u}`,children:[K,t.jsx("span",{className:`min-w-0 truncate ${Kf[b]} font-medium text-[var(--text-main)] ${m}`,title:H,children:H})]});const D=l??!0,G=i??H;return D&&G?t.jsx(Bt,{as:"span",content:G,className:`inline-flex flex-shrink-0 ${u}`,children:K}):K}function nb({href:e,className:r,children:n}){return t.jsx("a",{href:e,className:r,children:n})}function ab(e){return e.reduce((r,n)=>{const a=n.section??"Principal";return r[a]=[...r[a]??[],n],r},{})}function ei({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=nb}){const[m,b]=s.useState(!1),f=ab(r);return t.jsxs("div",{className:"min-h-screen bg-[var(--bg-main)] text-[var(--text-main)]",children:[t.jsx(Kl,{}),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(j.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(j.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:()=>b(!1),children:t.jsx(j.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(([g,p])=>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(j.HiChevronDown,{className:"h-3.5 w-3.5"}),g]}),t.jsx("div",{className:"space-y-1",children:p.map(E=>{const v=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 ${v?"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(j.HiHome,{className:"h-4 w-4"})}),t.jsx("span",{className:"truncate",children:E.label})]},E.href)})})]},g))})}),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(Rl,{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(Qe,{variant:"ghost",className:"w-full justify-start text-white hover:bg-white/10",onClick:d,children:[t.jsx(j.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 ti="bonsaif-ui:prime-auth-sso",ob={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"},To={dashboard:t.jsx(j.HiChartBar,{className:"h-5 w-5"}),tickets:t.jsx(j.HiTicket,{className:"h-5 w-5"}),teams:t.jsx(j.HiUsers,{className:"h-5 w-5"}),projects:t.jsx(j.HiRectangleGroup,{className:"h-5 w-5"}),clients:t.jsx(j.HiBuildingOffice2,{className:"h-5 w-5"}),surveys:t.jsx(j.HiClipboardDocumentList,{className:"h-5 w-5"}),profile:t.jsx(j.HiUser,{className:"h-5 w-5"}),settings:t.jsx(j.HiCog6Tooth,{className:"h-5 w-5"}),notifications:t.jsx(j.HiBell,{className:"h-5 w-5"}),changelog:t.jsx(j.HiDocumentText,{className:"h-5 w-5"}),admin:t.jsx(j.HiShieldCheck,{className:"h-5 w-5"}),users:t.jsx(j.HiUsers,{className:"h-5 w-5"}),roles:t.jsx(j.HiShieldCheck,{className:"h-5 w-5"}),menus:t.jsx(j.HiCog6Tooth,{className:"h-5 w-5"}),guards:t.jsx(j.HiCalendarDays,{className:"h-5 w-5"}),vacations:t.jsx(j.HiCalendarDays,{className:"h-5 w-5"}),audit:t.jsx(j.HiListBullet,{className:"h-5 w-5"}),positions:t.jsx(j.HiBriefcase,{className:"h-5 w-5"}),ranks:t.jsx(j.HiListBullet,{className:"h-5 w-5"}),"email-inbox":t.jsx(j.HiInbox,{className:"h-5 w-5"}),"security-incidents":t.jsx(j.HiShieldCheck,{className:"h-5 w-5"})};function sb(e){return e.split("-").map(r=>r.charAt(0).toUpperCase()+r.slice(1)).join(" ")}function lb(e){return/^\d+$/.test(e)||/^[a-f0-9]{8,}$/i.test(e)}function ib(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=lb(n)&&a?a:n,l=ob[o]??sb(o);return[{label:"Inicio",href:"/"},{label:l}]}function $o(e){return(e==null?void 0:e.querySelector(":scope > .os-viewport"))??(e==null?void 0:e.querySelector(":scope > [data-overlayscrollbars-viewport]"))}function cb(e){const r=e.split("/").filter(Boolean),n=r[r.length-1];if(!n)return t.jsx(j.HiHome,{className:"h-5 w-5"});if(To[n])return To[n];const a=r.length>1?r[r.length-2]:"";return To[a]??t.jsx(j.HiHome,{className:"h-5 w-5"})}function db(e){return e.includes("primeAuthOrigin")||e.includes("primeAuthProjectKey")}function ri(){if(typeof window>"u")return!1;if(db(window.location.href)){try{window.sessionStorage.setItem(ti,"true")}catch{}return!0}try{return window.sessionStorage.getItem(ti)==="true"}catch{return!1}}function ub({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 b=s.useRef(null),[f,g]=s.useState(!1),[p,E]=s.useState(d??"/"),[v,w]=s.useState(()=>ri()),[A,C]=s.useState(null),H=d??p,k=c??ib(H),x=o??cb(H),M=u&&!v&&k.length>1,N=!M;s.useEffect(()=>{d||E(window.location.pathname)},[d]),s.useEffect(()=>{w(ri())},[]),s.useEffect(()=>{if(m){g(!1);return}let X=null,K=0,D=0;const G=()=>{const J=b.current,R=document.querySelector("[data-app-scroll='true']");return(J==null?void 0:J.closest(".os-viewport"))??(J==null?void 0:J.closest("[data-overlayscrollbars-viewport]"))??$o(R)??R??window},V=()=>{const J=X&&X!==window?X.scrollTop:window.scrollY;g(R=>R?J>24:J>72)},ne=()=>{X==null||X.removeEventListener("scroll",V),X=G(),X.addEventListener("scroll",V,{passive:!0}),V()};return ne(),K=window.requestAnimationFrame(ne),D=window.setTimeout(ne,120),()=>{window.cancelAnimationFrame(K),window.clearTimeout(D),X==null||X.removeEventListener("scroll",V)}},[m]),s.useEffect(()=>{if(m){C(null);return}let X=0;const K=[],D=()=>{const Y=b.current,ce=Y==null?void 0:Y.parentElement,L=document.querySelector("[data-app-scroll='true']"),B=$o(L)??L;if(!Y||!ce||!B){C(null);return}const le=ce.getBoundingClientRect(),O=window.getComputedStyle(ce),ae=B.getBoundingClientRect(),S=B instanceof HTMLElement&&B.clientWidth>0?B.clientWidth:ae.width,ee=le.left+parseFloat(O.paddingLeft||"0"),_={marginLeft:Math.round(ae.left-ee),width:Math.round(S)};C(I=>I&&I.marginLeft===_.marginLeft&&I.width===_.width?I:_)},G=()=>{window.cancelAnimationFrame(X),X=window.requestAnimationFrame(D)};G(),window.addEventListener("resize",G);const V=new ResizeObserver(G),ne=b.current,J=ne==null?void 0:ne.parentElement,R=document.querySelector("[data-app-scroll='true']"),U=$o(R)??R;return[J,R,U].forEach(Y=>{Y&&V.observe(Y)}),K.push(window.setTimeout(G,120)),K.push(window.setTimeout(G,280)),()=>{window.cancelAnimationFrame(X),window.removeEventListener("resize",G),V.disconnect(),K.forEach(Y=>window.clearTimeout(Y))}},[m]);const z={...A?{marginLeft:A.marginLeft,width:A.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:z,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":N?"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||N?"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||N?"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:M?"var(--text-secondary)":"var(--text-muted)"},children:x}),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(Jo.Provider,{value:{compact:!0,headerAction:!0},children:n})})]})})}function fb({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(ei,{currentPath:r,...a,children:e})}function ni(){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 bb(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 mb({name:e,src:r,projectKey:n}){const[a,o]=s.useState("system"),l=s.useRef(null);s.useEffect(()=>{o(ni());const d=new MutationObserver(()=>o(ni()));return d.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>d.disconnect()},[]);const i=s.useMemo(()=>bb(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 g,p,E;if(m.source!==((g=l.current)==null?void 0:g.contentWindow)||c&&m.origin!==c)return;if(((p=m.data)==null?void 0:p.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 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 hb(){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:ai(c.data.width,96,720),height:ai(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 ai(e,r,n){const a=typeof e=="number"&&Number.isFinite(e)?e:r;return Math.max(r,Math.min(n,Math.ceil(a)))}function pb(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 gb(){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 vb(){return"light"}function xb({position:e="bottom-center"}){const r=s.useSyncExternalStore(pb,gb,vb);return t.jsx(Ha.Toaster,{position:e,theme:r,richColors:!0,closeButton:!0})}function yb({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 bn=["var(--primary)","#38bdf8","#34d399","#a78bfa","#2dd4bf","#fbbf24","#60a5fa","#94a3b8"];function oi(e,r){return e.color??bn[r%bn.length]}function zt(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 kt=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 Ir(e){if(e==null||e==="")return null;const r=typeof e=="number"?e:Number(e);return Number.isFinite(r)?r:null}const Ao={warning:70,danger:90};function na(e,r=Ao){const n=r.warning??Ao.warning,a=r.danger??Ao.danger;return e>=a?"danger":e>=n?"warning":e<=0?"primary":"success"}function mn(e,r){return zt(na(e,r))}function Br(e,r=0){return Number.isFinite(e)?`${e.toFixed(r)}%`:"—"}function Fr(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 si(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 Pr(e,r){var n;for(let a=e.length-1;a>=0;a-=1){const o=Ir((n=e[a])==null?void 0:n[r]);if(o!==null)return o}return null}function St({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 Et({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 nr=680,fr="ease-out",wb={top:18,right:8,bottom:12,left:0};function hn(e){return{...wb,...e}}function pn(e){return e.map((r,n)=>({...r,color:oi(r,n),label:r.label??r.key}))}function aa(e,r){return!e.length||!r.length||e.every(n=>r.every(a=>Ir(n[a.key])===null))}function Ct(){return{fill:"var(--text-muted)",fontSize:10,fontWeight:500,letterSpacing:"0.02em"}}function gn(){return"color-mix(in srgb, var(--border) 55%, transparent)"}function li(){return"color-mix(in srgb, var(--primary) 45%, var(--border))"}function oa(){return{paddingBottom:12,paddingLeft:4,fontSize:11,fontWeight:600,letterSpacing:"0.04em",textTransform:"uppercase",color:"var(--text-muted)"}}function Nb(e,r=kt){if(e==null||e==="")return"—";const n=typeof e=="number"?e:Number(e);return Number.isFinite(n)?r(n):String(e)}function ii(e){return`bonsaif-grad-${e.replace(/[^a-zA-Z0-9_-]/g,"")}`}function kb({active:e,label:r,payload:n,valueFormat:a=kt}){var c,d,u,m,b,f;if(!e||!(n!=null&&n.length))return null;const o=n.filter(g=>g.dataKey!=="base"&&g.name!=="base"&&g.value!==null&&g.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)??((f=(b=o[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:o.map((g,p)=>{const E=g.payload,v=E&&typeof E.display=="number"?E.display:g.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:g.color??"var(--primary)"}}),g.name??g.dataKey]}),t.jsx("span",{className:"bonsaif-chart-tooltip-value",children:Nb(v,a)})]},String(g.dataKey??g.name??p))})})]})}function _r({valueFormat:e,content:r,cursor:n,offset:a=12,wrapperStyle:o,allowEscapeViewBox:l,reverseDirection:i,...c}){return t.jsx(Me.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(kb,{valueFormat:e})})}function ci(e,r,n){return n==null?-1:e.findIndex(a=>String(a[r])===String(n))}function di(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 sa(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),b=!!a&&e.length>1,f=b&&(o==="brush"||o==="both"),g=b&&(o==="drag"||o==="both"),p=s.useCallback(K=>{d(K),i==null||i(K)},[i]),E=s.useCallback(()=>{m(null),p(null)},[p]),v=!!c,w=s.useMemo(()=>!c||f?e:e.slice(c.startIndex,c.endIndex+1),[e,f,c]),A=s.useCallback((K,D)=>{const G=ci(e,r,K),V=ci(e,r,D);G<0||V<0||p(di(G,V,e.length))},[p,e,r]),C=s.useCallback(K=>{g&&((K==null?void 0:K.activeLabel)===void 0||(K==null?void 0:K.activeLabel)===null||m({leftLabel:K.activeLabel,rightLabel:K.activeLabel}))},[g]),H=s.useCallback(K=>{!g||!u||(K==null?void 0:K.activeLabel)===void 0||(K==null?void 0:K.activeLabel)===null||m(D=>D&&{...D,rightLabel:K.activeLabel})},[u,g]),k=s.useCallback(()=>{if(g){if(!u||u.rightLabel===null||u.rightLabel===void 0){m(null);return}A(u.leftLabel,u.rightLabel),m(null)}},[A,u,g]),x=s.useCallback(K=>{if(f){if(!K){p(null);return}p(di(K.startIndex??0,K.endIndex??e.length-1,e.length))}},[p,e.length,f]),M=g?{onMouseDown:C,onMouseMove:H,onMouseUp:k,onMouseLeave:()=>{u&&k()}}:{},N=c??{startIndex:0,endIndex:Math.max(0,e.length-1)},z=t.jsxs(t.Fragment,{children:[g&&u&&u.rightLabel!==null&&u.rightLabel!==void 0?t.jsx(Me.ReferenceArea,{x1:u.leftLabel,x2:u.rightLabel,strokeOpacity:.18,fill:"var(--primary)",fillOpacity:.12,stroke:"var(--primary)"}):null,f?t.jsx(Me.Brush,{dataKey:r,height:l,stroke:"var(--primary)",fill:"color-mix(in srgb, var(--primary) 10%, var(--bg-card))",travellerWidth:8,startIndex:N.startIndex,endIndex:N.endIndex,onChange:x,tickFormatter:K=>String(K)}):null]}),X=f?{bottom:Math.max(l+10,36)}:void 0;return{enabled:b,showBrush:f,showDrag:g,viewData:w,isZoomed:v,resetZoom:E,chartHandlers:M,zoomNodes:z,marginExtra:X}}function la({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 Sb({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:b=kt,yDomain:f,ariaLabel:g="Gráfico de líneas",curve:p=!0,strokeWidth:E=2.25,zoomable:v=!1,zoomMode:w="both",brushHeight:A,onZoomChange:C}){const H=aa(e,n),k=pn(n),x=sa(e,r,{zoomable:v,zoomMode:w,brushHeight:A,onZoomChange:C}),M=hn({...m,...x.marginExtra});return l?t.jsx(St,{height:a}):H?t.jsx(Et,{height:a,text:i}):t.jsxs("div",{className:`bonsaif-chart bonsaif-line-chart w-full ${o}`,role:"img","aria-label":g,style:{height:a},children:[t.jsx(la,{visible:x.isZoomed,onReset:x.resetZoom}),t.jsx(Me.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Me.LineChart,{data:x.viewData,margin:M,...x.chartHandlers,children:[c?t.jsx(Me.CartesianGrid,{strokeDasharray:"2 8",stroke:gn(),vertical:!1}):null,t.jsx(Me.XAxis,{dataKey:r,tick:Ct(),tickLine:!1,axisLine:!1,padding:{left:0,right:0},interval:"preserveStartEnd",minTickGap:52,dy:6}),t.jsx(Me.YAxis,{tick:Ct(),tickLine:!1,axisLine:!1,width:44,domain:f??["auto","auto"],tickFormatter:N=>b(Number(N)),dx:-2}),u?t.jsx(_r,{valueFormat:b,cursor:{stroke:li(),strokeWidth:1.25,strokeDasharray:"4 4"}}):null,d?t.jsx(Me.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:oa()}):null,k.map((N,z)=>t.jsx(Me.Line,{type:p?"monotone":"linear",dataKey:N.key,name:N.label,stroke:N.color,strokeWidth:z===0?E+.35:E,strokeOpacity:z===0?1:.88,isAnimationActive:!0,animationDuration:nr,animationEasing:fr,dot:!1,activeDot:{r:5,strokeWidth:2,stroke:"var(--bg-card)",fill:N.color}},N.key)),x.zoomNodes]})})]})}function ia({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:b=kt,yDomain:f,ariaLabel:g="Gráfico de área",stacked:p=!1,opacity:E=.22,zoomable:v=!1,zoomMode:w="both",brushHeight:A,onZoomChange:C}){const H=aa(e,n),k=pn(n),x=sa(e,r,{zoomable:v,zoomMode:w,brushHeight:A,onZoomChange:C}),M=hn({...m,...x.marginExtra});return l?t.jsx(St,{height:a}):H?t.jsx(Et,{height:a,text:i}):t.jsxs("div",{className:`bonsaif-chart bonsaif-area-chart w-full ${o}`,role:"img","aria-label":g,style:{height:a},children:[t.jsx(la,{visible:x.isZoomed,onReset:x.resetZoom}),t.jsx(Me.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Me.AreaChart,{data:x.viewData,margin:M,...x.chartHandlers,children:[t.jsx("defs",{children:k.map(N=>t.jsxs("linearGradient",{id:ii(N.key),x1:"0",y1:"0",x2:"0",y2:"1",children:[t.jsx("stop",{offset:"0%",stopColor:N.color,stopOpacity:Math.min(.55,E+.28)}),t.jsx("stop",{offset:"48%",stopColor:N.color,stopOpacity:E*.5}),t.jsx("stop",{offset:"100%",stopColor:N.color,stopOpacity:0})]},N.key))}),c?t.jsx(Me.CartesianGrid,{strokeDasharray:"2 8",stroke:gn(),vertical:!1}):null,t.jsx(Me.XAxis,{dataKey:r,tick:Ct(),tickLine:!1,axisLine:!1,padding:{left:0,right:0},interval:"preserveStartEnd",minTickGap:52,dy:6}),t.jsx(Me.YAxis,{tick:Ct(),tickLine:!1,axisLine:!1,width:44,domain:f??["auto","auto"],tickFormatter:N=>b(Number(N)),dx:-2}),u?t.jsx(_r,{valueFormat:b,cursor:{stroke:li(),strokeWidth:1.25,strokeDasharray:"4 4"}}):null,d?t.jsx(Me.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:oa()}):null,k.map(N=>t.jsx(Me.Area,{type:"monotone",dataKey:N.key,name:N.label,stroke:N.color,fill:`url(#${ii(N.key)})`,strokeWidth:2.25,stackId:p?"stack":void 0,isAnimationActive:!0,animationDuration:nr,animationEasing:fr,dot:!1,activeDot:{r:5,strokeWidth:2,stroke:"var(--bg-card)",fill:N.color}},N.key)),x.zoomNodes]})})]})}function Eb({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:b=kt,yDomain:f,ariaLabel:g="Gráfico de barras",layout:p="vertical",mode:E="grouped",barRadius:v=6,categoryAxisWidth:w=64,zoomable:A=!1,zoomMode:C="both",brushHeight:H,onZoomChange:k}){const x=aa(e,n),M=pn(n),N=p==="horizontal",z=sa(e,r,{zoomable:A&&!N,zoomMode:C,brushHeight:H,onZoomChange:k}),X=hn({...m,...z.marginExtra});return l?t.jsx(St,{height:a}):x?t.jsx(Et,{height:a,text:i}):t.jsxs("div",{className:`bonsaif-chart bonsaif-bar-chart w-full ${o}`,role:"img","aria-label":g,style:{height:a},children:[t.jsx(la,{visible:z.isZoomed,onReset:z.resetZoom}),t.jsx(Me.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Me.BarChart,{data:z.viewData,margin:X,layout:N?"vertical":"horizontal",barCategoryGap:"34%",barGap:3,...z.chartHandlers,children:[c?t.jsx(Me.CartesianGrid,{strokeDasharray:"2 8",stroke:gn(),horizontal:!N,vertical:N}):null,N?t.jsxs(t.Fragment,{children:[t.jsx(Me.XAxis,{type:"number",tick:Ct(),tickLine:!1,axisLine:!1,tickFormatter:K=>b(Number(K)),domain:f??["auto","auto"]}),t.jsx(Me.YAxis,{type:"category",dataKey:r,tick:Ct(),tickLine:!1,axisLine:!1,width:w})]}):t.jsxs(t.Fragment,{children:[t.jsx(Me.XAxis,{dataKey:r,tick:Ct(),tickLine:!1,axisLine:!1,interval:"preserveStartEnd",minTickGap:36,dy:6}),t.jsx(Me.YAxis,{tick:Ct(),tickLine:!1,axisLine:!1,width:44,domain:f??["auto","auto"],tickFormatter:K=>b(Number(K)),dx:-2})]}),u?t.jsx(_r,{valueFormat:b,cursor:{fill:"color-mix(in srgb, var(--primary) 8%, transparent)"}}):null,d?t.jsx(Me.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:oa()}):null,M.map((K,D)=>t.jsx(Me.Bar,{dataKey:K.key,name:K.label,fill:K.color,fillOpacity:D===0?1:.82,radius:N?[0,v,v,0]:[v,v,2,2],maxBarSize:20,stackId:E==="stacked"?"stack":void 0,isAnimationActive:!0,animationDuration:nr,animationEasing:fr},K.key)),z.zoomNodes]})})]})}function Cb(e){return t.jsx(fi,{...e,variant:"pie"})}function Mb(e){return t.jsx(fi,{...e,variant:"donut",innerRadius:e.innerRadius??.62,cornerRadius:e.cornerRadius??10,padAngle:e.padAngle??2})}function ui(e,r){return e==null||!Number.isFinite(e)?r:e>0&&e<=1?e*100:e}function fi({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=kt,ariaLabel:m,innerRadius:b,outerRadius:f,colors:g=[...bn],padAngle:p,cornerRadius:E,variant:v}){const w=e.map((D,G)=>({name:String(D[r]??""),value:Ir(D[n])??0,fill:g[G%g.length],row:D})).filter(D=>D.value>0),A=!w.length,C=v==="donut",H=w.length,k=ui(b,C?62:12),x=ui(f,78),M=Math.min(p??(C?2:3),Math.max(.5,10/Math.max(1,H))),N=Math.min(E??(C?10:8),Math.max(2,36/Math.max(1,H)));if(l)return t.jsx(St,{height:a});if(A)return t.jsx(Et,{height:a,text:i});const z=w.reduce((D,G)=>D+G.value,0),X=c?Math.min(96,28+Math.ceil(H/3)*22):0,K=Math.max(140,a-X);return t.jsx("div",{className:`bonsaif-chart bonsaif-${v}-chart w-full ${o}`,role:"img","aria-label":m??(v==="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:K},children:t.jsx(Me.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Me.PieChart,{margin:{top:4,right:4,bottom:4,left:4},children:[d?t.jsx(_r,{valueFormat:u,isAnimationActive:!1}):null,t.jsx(Me.Pie,{data:w,dataKey:"value",nameKey:"name",cx:"50%",cy:"50%",innerRadius:`${k}%`,outerRadius:`${x}%`,startAngle:90,endAngle:-270,paddingAngle:M,cornerRadius:N,minAngle:H>6?3:2,stroke:"var(--bg-card)",strokeWidth:2,isAnimationActive:!0,animationDuration:nr,animationEasing:fr,label:!1,activeShape:Tb,children:w.map(D=>t.jsx(Me.Cell,{fill:D.fill},D.name))}),C?t.jsx("text",{x:"50%",y:"50%",textAnchor:"middle",dominantBaseline:"middle",fill:"var(--text-main)",fontSize:18,fontWeight:700,letterSpacing:"-0.02em",children:u(z)}):null]})})}),c?t.jsx("ul",{className:"bonsaif-pie-legend","aria-label":"Leyenda",children:w.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(Me.Sector,{...n,outerRadius:Number(r)+4,stroke:"var(--bg-card)",strokeWidth:2})}function $b({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??zt(o),m=e.map(x=>Ir(x[r])).filter(x=>x!==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,g=3,p=1,E=Math.min(...m),w=Math.max(...m)-E||1,A=m.map((x,M)=>{const N=p+M/(m.length-1)*(b-p*2),z=f-g-(x-E)/w*(f-g*2);return{x:N,y:z}}),C=A.map((x,M)=>`${M===0?"M":"L"}${x.x.toFixed(2)} ${x.y.toFixed(2)}`).join(" "),H=`${C} L${A[A.length-1].x.toFixed(2)} ${f} L${A[0].x.toFixed(2)} ${f} 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 ${b} ${f}`,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:H,fill:`url(#${k})`}):null,t.jsx("path",{d:C,fill:"none",stroke:u,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",vectorEffect:"non-scaling-stroke"})]})})}function Ab({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:b=!0,margin:f,valueFormat:g=kt,yDomain:p,ariaLabel:E="Gráfico combinado",barRadius:v=6,zoomable:w=!1,zoomMode:A="both",brushHeight:C,onZoomChange:H}){const k=a??n.slice(0,Math.max(1,n.length-1)),x=o??(n.length>1?n.slice(-1):n.length?[n[0]]:[]),M=[...k,...x.filter(V=>!k.some(ne=>ne.key===V.key))],N=aa(e,M),z=pn(k),X=pn(M),K=x.map(V=>{var J;const ne=X.find(R=>R.key===V.key);return{...V,label:V.label??V.key,color:V.color??(ne==null?void 0:ne.color)??((J=X[0])==null?void 0:J.color)}}),D=sa(e,r,{zoomable:w,zoomMode:A,brushHeight:C,onZoomChange:H}),G=hn({...f,...D.marginExtra});return c?t.jsx(St,{height:l}):N?t.jsx(Et,{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(la,{visible:D.isZoomed,onReset:D.resetZoom}),t.jsx(Me.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Me.ComposedChart,{data:D.viewData,margin:G,barCategoryGap:"34%",...D.chartHandlers,children:[u?t.jsx(Me.CartesianGrid,{strokeDasharray:"2 8",stroke:gn(),vertical:!1}):null,t.jsx(Me.XAxis,{dataKey:r,tick:Ct(),tickLine:!1,axisLine:!1,interval:"preserveStartEnd",minTickGap:36,dy:6}),t.jsx(Me.YAxis,{tick:Ct(),tickLine:!1,axisLine:!1,width:44,domain:p??["auto","auto"],tickFormatter:V=>g(Number(V)),dx:-2}),b?t.jsx(_r,{valueFormat:g,cursor:{fill:"color-mix(in srgb, var(--primary) 8%, transparent)"}}):null,m?t.jsx(Me.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:oa()}):null,z.map(V=>t.jsx(Me.Bar,{dataKey:V.key,name:V.label,fill:V.color,fillOpacity:.88,radius:[v,v,2,2],maxBarSize:18,isAnimationActive:!0,animationDuration:nr,animationEasing:fr},V.key)),K.map(V=>t.jsx(Me.Line,{type:"monotone",dataKey:V.key,name:V.label,stroke:V.color,strokeWidth:2.5,isAnimationActive:!0,animationDuration:nr,animationEasing:fr,dot:!1,activeDot:{r:5,strokeWidth:2,stroke:"var(--bg-card)",fill:V.color}},V.key)),D.zoomNodes]})})]})}function Lb({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:b=kt,ariaLabel:f="Gráfico waterfall",increaseColor:g="#34d399",decreaseColor:p="#f87171",totalColor:E="var(--primary)"}){const v=s.useMemo(()=>Db(e,{xKey:r,valueKey:n,typeKey:a,increaseColor:g,decreaseColor:p,totalColor:E}),[e,r,n,a,g,p,E]),w=!v.length,A=hn(m);return i?t.jsx(St,{height:o}):w?t.jsx(Et,{height:o,text:c}):t.jsx("div",{className:`bonsaif-chart bonsaif-waterfall-chart w-full ${l}`,role:"img","aria-label":f,style:{height:o},children:t.jsx(Me.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Me.BarChart,{data:v,margin:A,barCategoryGap:"42%",children:[d?t.jsx(Me.CartesianGrid,{strokeDasharray:"2 8",stroke:gn(),vertical:!1}):null,t.jsx(Me.XAxis,{dataKey:"label",tick:Ct(),tickLine:!1,axisLine:!1,interval:0,dy:6}),t.jsx(Me.YAxis,{tick:Ct(),tickLine:!1,axisLine:!1,width:44,tickFormatter:C=>b(Number(C)),dx:-2}),u?t.jsx(_r,{valueFormat:b,cursor:{fill:"color-mix(in srgb, var(--primary) 8%, transparent)"}}):null,t.jsx(Me.Bar,{dataKey:"base",stackId:"wf",fill:"transparent",isAnimationActive:!1,legendType:"none",maxBarSize:22}),t.jsx(Me.Bar,{dataKey:"delta",name:"Valor",stackId:"wf",radius:[6,6,2,2],maxBarSize:22,isAnimationActive:!0,animationDuration:nr,animationEasing:fr,children:v.map(C=>t.jsx(Me.Cell,{fill:C.color},C.label))})]})})})}function Db(e,r){let n=0;return e.map((a,o)=>{const l=Ir(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,b=l;return c&&i==="total"?(d="total",u=0,m=Math.abs(l),b=l,n=l):c&&o===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 bi="bonsaif-funnel-chart-keyframes",Ob=`
|
|
45
45
|
@keyframes bonsaif-funnel-stage-in {
|
|
46
46
|
from {
|
|
47
47
|
opacity: 0;
|
|
@@ -81,4 +81,4 @@ ${P}`,ve=new Blob(["\uFEFF"+se],{type:"text/csv;charset=utf-8;"}),Ce=URL.createO
|
|
|
81
81
|
animation: none !important;
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
|
-
`;function Ob(){if(typeof document>"u"||document.getElementById(ui))return;const e=document.createElement("style");e.id=ui,e.textContent=Db,document.head.appendChild(e)}function fi(e,r,n){return Math.min(n,Math.max(r,e))}function ca(e,r,n){const a=fi(n,0,1);return`color-mix(in srgb, ${e} ${Math.round((1-a)*100)}%, ${r} ${Math.round(a*100)}%)`}function Hb(e,r,n,a,o,l){const i=e.map((d,u)=>{const m=Ir(d[n])??0,b=String(d[r]??""),f=a?String(d[a]??"").trim():"",g=o?String(d[o]??"").trim():"";return{name:b,value:m,color:l[u%l.length],...f?{title:f}:{},...g?{description:g}:{}}}).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 Ib(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,b=l+(i-l)*u,f=l+(i-l)*m;return{...c,index:d,y:r.topY+d*(o+r.gap),h:o,topW:b,bottomW:f,cx:r.cx}})}function Bb({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,b=a-c/2,f=a+c/2,g=o+l,h=Math.max(4,Math.min(14,l*.18)),E=ca(d,"#000",r?.12:.22),v=ca(d,"#fff",r?.08:0),S=ca(d,"#fff",.22),A=[`M ${u} ${o}`,`L ${m} ${o}`,`L ${f} ${g}`,`L ${b} ${g}`,"Z"].join(" ");return t.jsxs("g",{onMouseEnter:()=>n(e.index),onMouseLeave:()=>n(null),style:{cursor:"default"},children:[t.jsx("path",{d:A,fill:E}),t.jsx("path",{d:[`M ${u} ${o}`,`L ${m} ${o}`,`L ${m} ${o+1}`,`L ${f} ${g}`,`L ${a} ${g}`,`L ${u} ${o}`,"Z"].join(" "),fill:v,opacity:.55}),t.jsx("ellipse",{cx:a,cy:o,rx:i/2,ry:h,fill:S,stroke:ca(d,"#000",.15),strokeWidth:1}),r?t.jsx("ellipse",{cx:a,cy:o,rx:i/2,ry:h,fill:"none",stroke:"var(--text-main)",strokeOpacity:.25,strokeWidth:1.5}):null]})}function Fb({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:b=!0,showBottomArrow:f=!0,taper:g=.42,colors:h=[...bn],animationDuration:E=nr,valueFormat:v=Nt,ariaLabel:S="Gráfico embudo"}){const[A,C]=s.useState(null),[O,N]=s.useState(!1),y=s.useMemo(()=>Hb(e,r,n,a,o,h),[e,r,n,a,o,h]),M=s.useMemo(()=>y.map(w=>`${w.name}:${w.value}`).join("|"),[y]);if(s.useEffect(()=>{if(Ob(),typeof window>"u")return;const w=window.matchMedia("(prefers-reduced-motion: reduce)");N(w.matches);const te=()=>N(w.matches);return w.addEventListener("change",te),()=>w.removeEventListener("change",te)},[]),c)return t.jsx(kt,{height:l});if(!y.length)return t.jsx(St,{height:l,text:d});const k=E>0&&!O,_=E,Y=Math.min(90,Math.max(40,Math.round(E/8))),K=Math.round(_*.15),D=y.length*Y+Math.round(_*.35),G=y.some(w=>w.title||w.description),U=m?160:24,ne=G?168:24,J=f?36:8,R=U+220+ne,V=l,X=18,de=Math.max(120,V-X-J-8),H=U+110,le=Ib(y,{cx:H,topY:X,plotH:de,maxTopW:200,taper:fi(g,.2,.95),gap:10}),L=A!=null?le[A]:null,oe="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":S,style:{height:l},children:[t.jsxs("svg",{viewBox:`0 0 ${R} ${V}`,width:"100%",height:"100%",preserveAspectRatio:"xMidYMid meet",children:[m?t.jsx("line",{className:k?"bonsaif-funnel-label":void 0,style:k?{animation:`bonsaif-funnel-fade-in ${_}ms ${oe} both`}:void 0,x1:U-12,y1:X,x2:U-12,y2:X+de,stroke:"var(--border)",strokeDasharray:"3 5",strokeWidth:1}):null,le.map(w=>{const te=w.y+w.h/2,B=w.cx-w.topW/2,F=w.index*Y,ue=k?{animation:`bonsaif-funnel-stage-in ${_}ms ${oe} ${F}ms both`}:void 0,re=k?{animation:`bonsaif-funnel-fade-in ${Math.round(_*.85)}ms ${oe} ${F+K}ms both`}:void 0;return t.jsxs("g",{children:[t.jsx("g",{className:"bonsaif-funnel-stage",style:ue,children:t.jsx(Bb,{stage:w,hovered:A===w.index,onHover:C})}),m?t.jsxs("g",{className:"bonsaif-funnel-label",style:re,children:[t.jsx("line",{x1:24,y1:te,x2:U-12,y2:te,stroke:w.color,strokeOpacity:.55,strokeDasharray:"3 4",strokeWidth:1}),t.jsx("line",{x1:U-12,y1:te,x2:B-6,y2:te,stroke:w.color,strokeOpacity:.35,strokeDasharray:"3 4",strokeWidth:1}),t.jsx("text",{x:20,y:te-(b?6:0),textAnchor:"end",fill:w.color,fontSize:12,fontWeight:600,children:w.name.length>18?`${w.name.slice(0,16)}…`:w.name}),b?t.jsx("text",{x:20,y:te+10,textAnchor:"end",fill:"var(--text-muted)",fontSize:11,children:v(w.value)}):null]}):null,(w.title||w.description)&&G?t.jsxs("g",{className:"bonsaif-funnel-anno",style:re,children:[t.jsx("line",{x1:w.cx+w.bottomW/2+6,y1:te,x2:U+220+8,y2:te,stroke:w.color,strokeOpacity:.35,strokeDasharray:"3 4",strokeWidth:1}),w.title?t.jsx("text",{x:U+220+14,y:te-(w.description?6:0),fill:"var(--text-main)",fontSize:12,fontWeight:700,children:w.title.length>22?`${w.title.slice(0,20)}…`:w.title}):null,w.description?t.jsx("text",{x:U+220+14,y:te+(w.title?10:0),fill:"var(--text-muted)",fontSize:11,children:w.description.length>28?`${w.description.slice(0,26)}…`:w.description}):null]}):null]},`${w.name}-${w.index}`)}),f?t.jsx("g",{className:"bonsaif-funnel-arrow",transform:`translate(${H}, ${X+de+8})`,fill:"var(--primary)",style:k?{animation:`bonsaif-funnel-arrow-in ${Math.round(_*.7)}ms ${oe} ${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]},M),u&&L?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:L.color},children:L.name}),t.jsx("span",{style:{color:"var(--text-muted)"},children:" · "}),v(L.value),t.jsxs("span",{style:{color:"var(--text-muted)"},children:[" ","(",Math.round(L.pct*100),"% del top)"]})]}):null]})}const zr=135*Math.PI/180,Lo=270*Math.PI/180;function Pb({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=Nt,tone:m="primary",color:b,thresholds:f,ariaLabel:g="Gauge",animationDuration:h=700,thickness:E=9,showScale:v=!1}){const S=s.useId().replace(/:/g,""),A=n-r||1,C=Math.min(1,Math.max(0,(e-r)/A)),[O,N]=s.useState(h>0?0:C);if(s.useEffect(()=>{if(l||i)return;if(h<=0){N(C);return}if(typeof window<"u"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches){N(C);return}let R=0,V=0;N(H=>(V=H,H));const X=performance.now(),de=H=>{const I=Math.min(1,(H-X)/h),le=1-(1-I)**3;N(V+(C-V)*le),I<1&&(R=requestAnimationFrame(de))};return R=requestAnimationFrame(de),()=>cancelAnimationFrame(R)},[C,h,l,i]),l)return t.jsx(kt,{height:a});if(i)return t.jsx(St,{height:a,text:c});const y=100,M=108,k=72,_=b??_b(e,n,m,f),Y=r+O*A,K=bi(y,M,k,zr,zr+Lo),D=zr+Math.max(.001,O)*Lo,G=bi(y,M,k,zr,D),U=da(y,M,k,zr),ne=da(y,M,k,zr+Lo);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":g,className:"overflow-visible",children:[t.jsx("defs",{children:t.jsxs("linearGradient",{id:`bonsaif-gauge-${S}`,x1:"0",y1:"0",x2:"1",y2:"0",children:[t.jsx("stop",{offset:"0%",stopColor:_,stopOpacity:.82}),t.jsx("stop",{offset:"100%",stopColor:_,stopOpacity:1})]})}),t.jsx("path",{d:K,fill:"none",stroke:"color-mix(in srgb, var(--border) 70%, transparent)",strokeWidth:E,strokeLinecap:"butt"}),t.jsx("path",{d:G,fill:"none",stroke:`url(#bonsaif-gauge-${S})`,strokeWidth:E,strokeLinecap:"butt",className:"bonsaif-chart-gauge-value"}),t.jsx("text",{x:y,y:M-(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(Y)}),d?t.jsx("text",{x:y,y:M+18,textAnchor:"middle",fill:"var(--text-muted)",fontSize:11,fontWeight:600,letterSpacing:"0.06em",children:d}):null,v?t.jsxs(t.Fragment,{children:[t.jsx("text",{x:U.x-2,y:U.y+E+14,textAnchor:"middle",fill:"var(--text-muted)",fontSize:10,children:u(r)}),t.jsx("text",{x:ne.x+2,y:ne.y+E+14,textAnchor:"middle",fill:"var(--text-muted)",fontSize:10,children:u(n)})]}):null]})})}function _b(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 _t(n);const o=e/(r||1);return o>=.8?_t("success"):o>=.5?_t("warning"):_t("danger")}function da(e,r,n,a){return{x:e+n*Math.cos(a),y:r+n*Math.sin(a)}}function bi(e,r,n,a,o){const l=da(e,r,n,a),i=da(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 zb({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:b=Nt,tone:f="primary",showScale:g=!0,showStatus:h=!0,ariaLabel:E="Bullet chart"}){if(i)return t.jsx(kt,{height:o});if(c)return t.jsx(St,{height:o,text:d});const v=n??Math.max(e,r,...(a==null?void 0:a.map(_=>_.value))??[],1)*1.05,A=[...a??[{value:v*.5,color:"color-mix(in srgb, var(--border) 72%, transparent)"},{value:v*.75,color:"color-mix(in srgb, var(--border) 48%, transparent)"},{value:v,color:"color-mix(in srgb, var(--border) 28%, transparent)"}]].sort((_,Y)=>_.value-Y.value),C=_t(f),O=Math.min(100,Math.max(0,e/v*100)),N=Math.min(100,Math.max(0,r/v*100)),y=e>=r,M=[0,.25,.5,.75,1].map(_=>_*v),k=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:A.map((_,Y)=>{const K=Y===0?0:A[Y-1].value,D=Math.max(0,(_.value-K)/v*100);return t.jsx("div",{style:{width:`${D}%`,background:_.color??`color-mix(in srgb, var(--border) ${70-Y*18}%, transparent)`}},Y)})}),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:`${O}%`,background:C,borderRadius:"0 999px 999px 0",boxShadow:`0 0 12px color-mix(in srgb, ${C} 35%, transparent)`}})}),t.jsx("div",{className:"bonsaif-bullet-target absolute top-1/2 z-[1]",style:{left:`${N}%`,height:"72%",width:3,transform:"translate(-50%, -50%)",background:C,borderRadius:1,boxShadow:"0 0 0 1px color-mix(in srgb, var(--bg-card) 70%, transparent)"},title:`Meta ${b(r)}`})]}),g?t.jsx("div",{className:"bonsaif-bullet-scale relative mt-1.5 h-4 w-full",children:M.map((_,Y)=>{const K=_/v*100,D=Y===0,G=Y===M.length-1;return t.jsxs("div",{className:"absolute top-0",style:{left:`${K}%`,transform:D?"none":G?"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:G?"auto":void 0,marginRight:G?0:void 0}}),t.jsx("div",{className:"bonsaif-bullet-scale-label mt-0.5 tabular-nums",style:{color:"var(--text-muted)",textAlign:D?"left":G?"right":"center"},children:b(_)})]},_)})}):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:C,fontWeight:600},children:b(e)}),t.jsxs("span",{children:[" / meta ",b(r)]})]}),h?t.jsx("div",{className:"bonsaif-bullet-status mt-1.5 inline-flex text-[10px] font-bold uppercase tracking-wide",style:{color:_t(y?"success":"warning")},children:y?"En meta":"Bajo meta"}):null]}),k]}):k})}function Wb({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:b=!0,thresholds:f,label:g="CPU",ariaLabel:h="Uso de CPU"}){var N;const E=o??[{key:a,label:"Uso",color:mn(r??Pr(e,a)??0,f)}],v=r??Pr(e,a)??Pr(e,((N=E[0])==null?void 0:N.key)??a),S=!d&&(!e.length||v===null);if(d)return t.jsx(kt,{height:i});if(S)return t.jsx(St,{height:i,text:u});const A=Math.min(100,Math.max(0,v??0)),C=na(A,f),O=mn(A,f);return t.jsxs("div",{className:`bonsaif-chart bonsaif-cpu-chart w-full ${c}`,role:"group","aria-label":h,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:[g,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:O},children:Br(A,A<10?1:0)})]}),t.jsx("div",{className:"bonsaif-metric-badge",style:{color:O,background:`color-mix(in srgb, ${O} 14%, transparent)`},children:C==="danger"?"Crítico":C==="warning"?"Alto":"Normal"})]}),t.jsx(ia,{data:e,xKey:n,series:E.map(y=>({...y,color:y.color??O})),height:Math.max(120,i-56),yDomain:[0,100],showLegend:m,showTooltip:b,valueFormat:y=>Br(y,0),ariaLabel:h,opacity:.22,margin:{top:8,right:8,bottom:4,left:0}})]})}function jb({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:b=!0,thresholds:f,label:g="RAM",ariaLabel:h="Uso de memoria"}){const E=r>0?r:1,v=Math.min(100,Math.max(0,e/E*100)),S=!d&&!(Number.isFinite(e)&&Number.isFinite(r)&&r>0);if(d)return t.jsx(kt,{height:i});if(S)return t.jsx(St,{height:i,text:u});const A=na(v,f),C=mn(v,f),O=Math.max(0,r-e),N=a.length>0?Pr(a,l)??v:v,y=mn(N,f),M=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":h,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:g}),t.jsxs("div",{className:"flex items-baseline gap-2",children:[t.jsx("span",{className:"bonsaif-metric-value",style:{color:C},children:Br(v,v<10?1:0)}),t.jsxs("span",{className:"text-sm tabular-nums",style:{color:"var(--text-secondary)"},children:[Fr(e)," / ",Fr(r)]})]})]}),t.jsx("div",{className:"bonsaif-metric-badge",style:{color:C,background:`color-mix(in srgb, ${C} 14%, transparent)`},children:A==="danger"?"Crítico":A==="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(v),"aria-valuemin":0,"aria-valuemax":100,"aria-label":`${g} ${Br(v,0)}`,children:t.jsx("div",{className:"h-full rounded-sm transition-[width] duration-300",style:{width:`${v}%`,background:`linear-gradient(90deg, ${C}, color-mix(in srgb, ${C} 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"})," ",Fr(e)]}),n!=null&&Number.isFinite(n)?t.jsxs("span",{children:[t.jsx("span",{className:"font-medium",style:{color:"var(--text-main)"},children:"Caché"})," ",Fr(n)]}):null,t.jsxs("span",{children:[t.jsx("span",{className:"font-medium",style:{color:"var(--text-main)"},children:"Libre"})," ",Fr(O)]})]})]}),m&&a.length>1?t.jsx(ia,{data:a,xKey:o,series:[{key:l,label:"Uso",color:y}],height:M,yDomain:[0,100],showLegend:!1,showTooltip:b,valueFormat:k=>Br(k,0),ariaLabel:`${h} — historial`,opacity:.22,margin:{top:8,right:8,bottom:4,left:0}}):null]})}const qb="color-mix(in srgb, var(--primary) 25%, #38bdf8)",Ub="color-mix(in srgb, var(--primary) 20%, #2dd4bf)";function Vb({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=qb,outboundColor:m=Ub,height:b=240,className:f="",loading:g=!1,emptyText:h="Sin datos de red",showLegend:E=!1,showTooltip:v=!0,label:S="Network",ariaLabel:A="Tráfico de red"}){const C=o??Pr(e,n)??0,O=l??Pr(e,a)??0,N=!g&&e.length===0;if(g)return t.jsx(kt,{height:b});if(N)return t.jsx(St,{height:b,text:h});const y=_=>ai(_,i),k=Math.max(140,b-76);return t.jsxs("div",{className:`bonsaif-chart bonsaif-network-chart w-full ${f}`,role:"group","aria-label":A,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:S}),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(C),children:y(C)})]}),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(O),children:y(O)})]})]})]})}),t.jsx("div",{className:"bonsaif-network-plot relative z-0",children:t.jsx(ia,{data:e,xKey:r,series:[{key:n,label:c,color:u},{key:a,label:d,color:m}],height:k,showLegend:E,showTooltip:v,valueFormat:y,ariaLabel:A,opacity:.18,margin:{top:8,right:8,bottom:4,left:4}})})]})}const mi=["primeSuiteOrigin","primeAuthOrigin","primeSuiteAppUrl"],pi=["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 mi){const n=e.get(r);if(n){const a=ua(n);if(a)return a}}if(typeof sessionStorage<"u")for(const r of pi){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=ua(n);if(a)return a}}if(document.referrer){const r=ua(document.referrer);if(r&&r!==window.location.origin)return r}return"*"}catch{return"*"}}function Yb(){if(typeof window>"u")return"self";try{if(window.parent===window)return"self";const e=new URLSearchParams(window.location.search);for(const r of mi)if(e.get(r))return"query";if(typeof sessionStorage<"u"){for(const r of pi)if(sessionStorage.getItem(r))return"sessionStorage"}if(document.referrer){const r=ua(document.referrer);if(r&&r!==window.location.origin)return"referrer"}return"wildcard"}catch{return"wildcard"}}function ua(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 Kb(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(q,"toast",{enumerable:!0,get:()=>Ha.toast}),q.Alert=mc,q.AreaChart=ia,q.AuthShell=Jl,q.AutoGrowTextarea=Hl,q.AutoGrowTextareaField=wf,q.BarChart=Sb,q.BonsaifButton=Gi,q.BonsaifUIToaster=vb,q.BulletChart=zb,q.Button=Ve,q.CHART_PALETTE=bn,q.CalendarPicker=yc,q.ChartCard=yb,q.Checkbox=Mn,q.CodeBlock=ed,q.ComboChart=$b,q.CompactFilterSelect=rd,q.CompactSearchInput=td,q.ConfirmDialog=sd,q.CopyButton=Va,q.CopyLinkButton=dd,q.CpuChart=Wb,q.DataSheets=gd,q.DataTable=qa,q.DateRangePicker=Nd,q.DonutChart=Cb,q.Drawer=Dd,q.DropdownMenu=Ad,q.DynamicDetailTabs=fc,q.EmailField=tu,q.EmptyState=Hn,q.EventCalendar=Qc,q.FieldHelperFooter=Tr,q.FieldLabelInfo=Mr,q.FieldLayoutEditor=lu,q.FileUpload=ou,q.FormField=zn,q.FunnelChart=Fb,q.GaugeChart=Pb,q.GlobalScrollbars=Xl,q.ImageLightbox=Vs,q.ImageLightboxHost=hu,q.InputField=to,q.LineChart=kb,q.LoadingState=rs,q.MentionTextEditor=Ll,q.MicroserviceFrame=bb,q.Modal=Xa,q.MouseTooltip=Bt,q.MultiDateCalendar=Ed,q.MultiSelect=vu,q.NetworkChart=Vb,q.NumberField=yu,q.PageHeader=db,q.PageSearchInput=Qo,q.Pagination=wu,q.PhoneField=ku,q.PieChart=Eb,q.PrimeAuthRouteShell=ub,q.PrimeSuiteChatFrame=mb,q.RadioGroup=Su,q.RamChart=jb,q.RichTextEditor=of,q.SearchableSelect=dr,q.SectionPanel=sf,q.Sparkline=Tb,q.StatusBadge=df,q.StatusSelect=pf,q.StepWizard=gf,q.TableSkeleton=Cn,q.Tabs=hf,q.TagInput=Lf,q.TextInput=_n,q.Textarea=Il,q.TextareaField=Cf,q.TimeField=_f,q.TimePicker=jl,q.Toggle=Wf,q.TruncatedWithTooltip=qt,q.UserAvatar=Ql,q.WaterfallChart=Ab,q.YearMultiDateCalendar=Md,q.buildMentionQueryRegex=ul,q.chunkMonthWeeks=xs,q.clearMentionChipSelection=Or,q.cn=Zt,q.computeWeekBars=Ua,q.configureBonsaifUI=Ec,q.dedupeMentions=hl,q.defaultValueFormat=Nt,q.deleteEditorSelection=El,q.describeParentTargetOrigin=Yb,q.emailFormat=Pd,q.ensureMentionChipTrailingSpaces=dn,q.extractMentionUsernames=ho,q.filterSelfMentions=Ju,q.findMentionChipAfterCaret=Ml,q.findMentionChipBeforeCaret=Cl,q.findMentionChipsInSelection=wo,q.findMentionTriggerInEditor=mo,q.formatBytes=Fr,q.formatPercent=Br,q.formatRate=ai,q.getBonsaifUIConfig=Cc,q.getDataTablePreferencesEndpoint=za,q.getEditorPlainText=xo,q.getMonthGrid=ys,q.getPlainTextOffset=Zn,q.getWeekDays=vs,q.groupItemsByDay=ws,q.highlightMentions=gl,q.htmlToText=ml,q.insertMentionInEditor=yl,q.isMentionTriggerBoundary=bl,q.isPlainOffsetInsideMentionChip=fl,q.isValidEmail=Ja,q.isValidPhone=Ra,q.locateTextOffset=Dr,q.matches=Ud,q.maxLength=Wd,q.maxValue=qd,q.mentionDisplayLabel=pl,q.minLength=zd,q.minValue=jd,q.normalizeUsername=po,q.openImageLightboxFromEvent=qs,q.phoneCountryCodeOptions=Ks,q.phoneFormat=_d,q.placeCaretAfterMentionChip=vo,q.placeCaretAtTextOffset=xl,q.preferredMentionSpacer=go,q.removeMentionChip=Rn,q.required=Fd,q.resetBonsaifUIConfig=Mc,q.resolveMentions=Qu,q.resolveParentTargetOrigin=Xb,q.selectAllEditorContents=kl,q.selectMentionChip=Nl,q.selectionIncludesNonChipText=Sl,q.seriesColor=ni,q.setBonsaifDataTablePreferencesEndpoint=Tc,q.syncMentionChipSelectionHighlight=Jn,q.toDateKey=Rt,q.toneColor=_t,q.usageColor=mn,q.usageTone=na,q.useValidationVisibility=Kb,q.validateForm=Vd,Object.defineProperty(q,Symbol.toStringTag,{value:"Module"})}));
|
|
84
|
+
`;function Hb(){if(typeof document>"u"||document.getElementById(bi))return;const e=document.createElement("style");e.id=bi,e.textContent=Ob,document.head.appendChild(e)}function mi(e,r,n){return Math.min(n,Math.max(r,e))}function ca(e,r,n){const a=mi(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,o,l){const i=e.map((d,u)=>{const m=Ir(d[n])??0,b=String(d[r]??""),f=a?String(d[a]??"").trim():"",g=o?String(d[o]??"").trim():"";return{name:b,value:m,color:l[u%l.length],...f?{title:f}:{},...g?{description:g}:{}}}).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 Bb(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,b=l+(i-l)*u,f=l+(i-l)*m;return{...c,index:d,y:r.topY+d*(o+r.gap),h:o,topW:b,bottomW:f,cx:r.cx}})}function Fb({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,b=a-c/2,f=a+c/2,g=o+l,p=Math.max(4,Math.min(14,l*.18)),E=ca(d,"#000",r?.12:.22),v=ca(d,"#fff",r?.08:0),w=ca(d,"#fff",.22),A=[`M ${u} ${o}`,`L ${m} ${o}`,`L ${f} ${g}`,`L ${b} ${g}`,"Z"].join(" ");return t.jsxs("g",{onMouseEnter:()=>n(e.index),onMouseLeave:()=>n(null),style:{cursor:"default"},children:[t.jsx("path",{d:A,fill:E}),t.jsx("path",{d:[`M ${u} ${o}`,`L ${m} ${o}`,`L ${m} ${o+1}`,`L ${f} ${g}`,`L ${a} ${g}`,`L ${u} ${o}`,"Z"].join(" "),fill:v,opacity:.55}),t.jsx("ellipse",{cx:a,cy:o,rx:i/2,ry:p,fill:w,stroke:ca(d,"#000",.15),strokeWidth:1}),r?t.jsx("ellipse",{cx:a,cy:o,rx:i/2,ry:p,fill:"none",stroke:"var(--text-main)",strokeOpacity:.25,strokeWidth:1.5}):null]})}function Pb({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:b=!0,showBottomArrow:f=!0,taper:g=.42,colors:p=[...bn],animationDuration:E=nr,valueFormat:v=kt,ariaLabel:w="Gráfico embudo"}){const[A,C]=s.useState(null),[H,k]=s.useState(!1),x=s.useMemo(()=>Ib(e,r,n,a,o,p),[e,r,n,a,o,p]),M=s.useMemo(()=>x.map(S=>`${S.name}:${S.value}`).join("|"),[x]);if(s.useEffect(()=>{if(Hb(),typeof window>"u")return;const S=window.matchMedia("(prefers-reduced-motion: reduce)");k(S.matches);const ee=()=>k(S.matches);return S.addEventListener("change",ee),()=>S.removeEventListener("change",ee)},[]),c)return t.jsx(St,{height:l});if(!x.length)return t.jsx(Et,{height:l,text:d});const N=E>0&&!H,z=E,X=Math.min(90,Math.max(40,Math.round(E/8))),K=Math.round(z*.15),D=x.length*X+Math.round(z*.35),G=x.some(S=>S.title||S.description),V=m?160:24,ne=G?168:24,J=f?36:8,R=V+220+ne,U=l,Y=18,ce=Math.max(120,U-Y-J-8),L=V+110,le=Bb(x,{cx:L,topY:Y,plotH:ce,maxTopW:200,taper:mi(g,.2,.95),gap:10}),O=A!=null?le[A]:null,ae="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":w,style:{height:l},children:[t.jsxs("svg",{viewBox:`0 0 ${R} ${U}`,width:"100%",height:"100%",preserveAspectRatio:"xMidYMid meet",children:[m?t.jsx("line",{className:N?"bonsaif-funnel-label":void 0,style:N?{animation:`bonsaif-funnel-fade-in ${z}ms ${ae} both`}:void 0,x1:V-12,y1:Y,x2:V-12,y2:Y+ce,stroke:"var(--border)",strokeDasharray:"3 5",strokeWidth:1}):null,le.map(S=>{const ee=S.y+S.h/2,_=S.cx-S.topW/2,I=S.index*X,de=N?{animation:`bonsaif-funnel-stage-in ${z}ms ${ae} ${I}ms both`}:void 0,re=N?{animation:`bonsaif-funnel-fade-in ${Math.round(z*.85)}ms ${ae} ${I+K}ms both`}:void 0;return t.jsxs("g",{children:[t.jsx("g",{className:"bonsaif-funnel-stage",style:de,children:t.jsx(Fb,{stage:S,hovered:A===S.index,onHover:C})}),m?t.jsxs("g",{className:"bonsaif-funnel-label",style:re,children:[t.jsx("line",{x1:24,y1:ee,x2:V-12,y2:ee,stroke:S.color,strokeOpacity:.55,strokeDasharray:"3 4",strokeWidth:1}),t.jsx("line",{x1:V-12,y1:ee,x2:_-6,y2:ee,stroke:S.color,strokeOpacity:.35,strokeDasharray:"3 4",strokeWidth:1}),t.jsx("text",{x:20,y:ee-(b?6:0),textAnchor:"end",fill:S.color,fontSize:12,fontWeight:600,children:S.name.length>18?`${S.name.slice(0,16)}…`:S.name}),b?t.jsx("text",{x:20,y:ee+10,textAnchor:"end",fill:"var(--text-muted)",fontSize:11,children:v(S.value)}):null]}):null,(S.title||S.description)&&G?t.jsxs("g",{className:"bonsaif-funnel-anno",style:re,children:[t.jsx("line",{x1:S.cx+S.bottomW/2+6,y1:ee,x2:V+220+8,y2:ee,stroke:S.color,strokeOpacity:.35,strokeDasharray:"3 4",strokeWidth:1}),S.title?t.jsx("text",{x:V+220+14,y:ee-(S.description?6:0),fill:"var(--text-main)",fontSize:12,fontWeight:700,children:S.title.length>22?`${S.title.slice(0,20)}…`:S.title}):null,S.description?t.jsx("text",{x:V+220+14,y:ee+(S.title?10:0),fill:"var(--text-muted)",fontSize:11,children:S.description.length>28?`${S.description.slice(0,26)}…`:S.description}):null]}):null]},`${S.name}-${S.index}`)}),f?t.jsx("g",{className:"bonsaif-funnel-arrow",transform:`translate(${L}, ${Y+ce+8})`,fill:"var(--primary)",style:N?{animation:`bonsaif-funnel-arrow-in ${Math.round(z*.7)}ms ${ae} ${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]},M),u&&O?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:O.color},children:O.name}),t.jsx("span",{style:{color:"var(--text-muted)"},children:" · "}),v(O.value),t.jsxs("span",{style:{color:"var(--text-muted)"},children:[" ","(",Math.round(O.pct*100),"% del top)"]})]}):null]})}const zr=135*Math.PI/180,Lo=270*Math.PI/180;function _b({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=kt,tone:m="primary",color:b,thresholds:f,ariaLabel:g="Gauge",animationDuration:p=700,thickness:E=9,showScale:v=!1}){const w=s.useId().replace(/:/g,""),A=n-r||1,C=Math.min(1,Math.max(0,(e-r)/A)),[H,k]=s.useState(p>0?0:C);if(s.useEffect(()=>{if(l||i)return;if(p<=0){k(C);return}if(typeof window<"u"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches){k(C);return}let R=0,U=0;k(L=>(U=L,L));const Y=performance.now(),ce=L=>{const B=Math.min(1,(L-Y)/p),le=1-(1-B)**3;k(U+(C-U)*le),B<1&&(R=requestAnimationFrame(ce))};return R=requestAnimationFrame(ce),()=>cancelAnimationFrame(R)},[C,p,l,i]),l)return t.jsx(St,{height:a});if(i)return t.jsx(Et,{height:a,text:c});const x=100,M=108,N=72,z=b??zb(e,n,m,f),X=r+H*A,K=hi(x,M,N,zr,zr+Lo),D=zr+Math.max(.001,H)*Lo,G=hi(x,M,N,zr,D),V=da(x,M,N,zr),ne=da(x,M,N,zr+Lo);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":g,className:"overflow-visible",children:[t.jsx("defs",{children:t.jsxs("linearGradient",{id:`bonsaif-gauge-${w}`,x1:"0",y1:"0",x2:"1",y2:"0",children:[t.jsx("stop",{offset:"0%",stopColor:z,stopOpacity:.82}),t.jsx("stop",{offset:"100%",stopColor:z,stopOpacity:1})]})}),t.jsx("path",{d:K,fill:"none",stroke:"color-mix(in srgb, var(--border) 70%, transparent)",strokeWidth:E,strokeLinecap:"butt"}),t.jsx("path",{d:G,fill:"none",stroke:`url(#bonsaif-gauge-${w})`,strokeWidth:E,strokeLinecap:"butt",className:"bonsaif-chart-gauge-value"}),t.jsx("text",{x,y:M-(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:M+18,textAnchor:"middle",fill:"var(--text-muted)",fontSize:11,fontWeight:600,letterSpacing:"0.06em",children:d}):null,v?t.jsxs(t.Fragment,{children:[t.jsx("text",{x:V.x-2,y:V.y+E+14,textAnchor:"middle",fill:"var(--text-muted)",fontSize:10,children:u(r)}),t.jsx("text",{x:ne.x+2,y:ne.y+E+14,textAnchor:"middle",fill:"var(--text-muted)",fontSize:10,children:u(n)})]}):null]})})}function zb(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 zt(n);const o=e/(r||1);return o>=.8?zt("success"):o>=.5?zt("warning"):zt("danger")}function da(e,r,n,a){return{x:e+n*Math.cos(a),y:r+n*Math.sin(a)}}function hi(e,r,n,a,o){const l=da(e,r,n,a),i=da(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 Wb({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:b=kt,tone:f="primary",showScale:g=!0,showStatus:p=!0,ariaLabel:E="Bullet chart"}){if(i)return t.jsx(St,{height:o});if(c)return t.jsx(Et,{height:o,text:d});const v=n??Math.max(e,r,...(a==null?void 0:a.map(z=>z.value))??[],1)*1.05,A=[...a??[{value:v*.5,color:"color-mix(in srgb, var(--border) 72%, transparent)"},{value:v*.75,color:"color-mix(in srgb, var(--border) 48%, transparent)"},{value:v,color:"color-mix(in srgb, var(--border) 28%, transparent)"}]].sort((z,X)=>z.value-X.value),C=zt(f),H=Math.min(100,Math.max(0,e/v*100)),k=Math.min(100,Math.max(0,r/v*100)),x=e>=r,M=[0,.25,.5,.75,1].map(z=>z*v),N=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:A.map((z,X)=>{const K=X===0?0:A[X-1].value,D=Math.max(0,(z.value-K)/v*100);return t.jsx("div",{style:{width:`${D}%`,background:z.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:`${H}%`,background:C,borderRadius:"0 999px 999px 0",boxShadow:`0 0 12px color-mix(in srgb, ${C} 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:C,borderRadius:1,boxShadow:"0 0 0 1px color-mix(in srgb, var(--bg-card) 70%, transparent)"},title:`Meta ${b(r)}`})]}),g?t.jsx("div",{className:"bonsaif-bullet-scale relative mt-1.5 h-4 w-full",children:M.map((z,X)=>{const K=z/v*100,D=X===0,G=X===M.length-1;return t.jsxs("div",{className:"absolute top-0",style:{left:`${K}%`,transform:D?"none":G?"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:G?"auto":void 0,marginRight:G?0:void 0}}),t.jsx("div",{className:"bonsaif-bullet-scale-label mt-0.5 tabular-nums",style:{color:"var(--text-muted)",textAlign:D?"left":G?"right":"center"},children:b(z)})]},z)})}):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:C,fontWeight:600},children:b(e)}),t.jsxs("span",{children:[" / meta ",b(r)]})]}),p?t.jsx("div",{className:"bonsaif-bullet-status mt-1.5 inline-flex text-[10px] font-bold uppercase tracking-wide",style:{color:zt(x?"success":"warning")},children:x?"En meta":"Bajo meta"}):null]}),N]}):N})}function jb({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:b=!0,thresholds:f,label:g="CPU",ariaLabel:p="Uso de CPU"}){var k;const E=o??[{key:a,label:"Uso",color:mn(r??Pr(e,a)??0,f)}],v=r??Pr(e,a)??Pr(e,((k=E[0])==null?void 0:k.key)??a),w=!d&&(!e.length||v===null);if(d)return t.jsx(St,{height:i});if(w)return t.jsx(Et,{height:i,text:u});const A=Math.min(100,Math.max(0,v??0)),C=na(A,f),H=mn(A,f);return t.jsxs("div",{className:`bonsaif-chart bonsaif-cpu-chart w-full ${c}`,role:"group","aria-label":p,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:[g,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:H},children:Br(A,A<10?1:0)})]}),t.jsx("div",{className:"bonsaif-metric-badge",style:{color:H,background:`color-mix(in srgb, ${H} 14%, transparent)`},children:C==="danger"?"Crítico":C==="warning"?"Alto":"Normal"})]}),t.jsx(ia,{data:e,xKey:n,series:E.map(x=>({...x,color:x.color??H})),height:Math.max(120,i-56),yDomain:[0,100],showLegend:m,showTooltip:b,valueFormat:x=>Br(x,0),ariaLabel:p,opacity:.22,margin:{top:8,right:8,bottom:4,left:0}})]})}function qb({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:b=!0,thresholds:f,label:g="RAM",ariaLabel:p="Uso de memoria"}){const E=r>0?r:1,v=Math.min(100,Math.max(0,e/E*100)),w=!d&&!(Number.isFinite(e)&&Number.isFinite(r)&&r>0);if(d)return t.jsx(St,{height:i});if(w)return t.jsx(Et,{height:i,text:u});const A=na(v,f),C=mn(v,f),H=Math.max(0,r-e),k=a.length>0?Pr(a,l)??v:v,x=mn(k,f),M=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":p,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:g}),t.jsxs("div",{className:"flex items-baseline gap-2",children:[t.jsx("span",{className:"bonsaif-metric-value",style:{color:C},children:Br(v,v<10?1:0)}),t.jsxs("span",{className:"text-sm tabular-nums",style:{color:"var(--text-secondary)"},children:[Fr(e)," / ",Fr(r)]})]})]}),t.jsx("div",{className:"bonsaif-metric-badge",style:{color:C,background:`color-mix(in srgb, ${C} 14%, transparent)`},children:A==="danger"?"Crítico":A==="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(v),"aria-valuemin":0,"aria-valuemax":100,"aria-label":`${g} ${Br(v,0)}`,children:t.jsx("div",{className:"h-full rounded-sm transition-[width] duration-300",style:{width:`${v}%`,background:`linear-gradient(90deg, ${C}, color-mix(in srgb, ${C} 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"})," ",Fr(e)]}),n!=null&&Number.isFinite(n)?t.jsxs("span",{children:[t.jsx("span",{className:"font-medium",style:{color:"var(--text-main)"},children:"Caché"})," ",Fr(n)]}):null,t.jsxs("span",{children:[t.jsx("span",{className:"font-medium",style:{color:"var(--text-main)"},children:"Libre"})," ",Fr(H)]})]})]}),m&&a.length>1?t.jsx(ia,{data:a,xKey:o,series:[{key:l,label:"Uso",color:x}],height:M,yDomain:[0,100],showLegend:!1,showTooltip:b,valueFormat:N=>Br(N,0),ariaLabel:`${p} — historial`,opacity:.22,margin:{top:8,right:8,bottom:4,left:0}}):null]})}const Ub="color-mix(in srgb, var(--primary) 25%, #38bdf8)",Vb="color-mix(in srgb, var(--primary) 20%, #2dd4bf)";function Xb({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=Ub,outboundColor:m=Vb,height:b=240,className:f="",loading:g=!1,emptyText:p="Sin datos de red",showLegend:E=!1,showTooltip:v=!0,label:w="Network",ariaLabel:A="Tráfico de red"}){const C=o??Pr(e,n)??0,H=l??Pr(e,a)??0,k=!g&&e.length===0;if(g)return t.jsx(St,{height:b});if(k)return t.jsx(Et,{height:b,text:p});const x=z=>si(z,i),N=Math.max(140,b-76);return t.jsxs("div",{className:`bonsaif-chart bonsaif-network-chart w-full ${f}`,role:"group","aria-label":A,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:w}),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:x(C),children:x(C)})]}),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:x(H),children:x(H)})]})]})]})}),t.jsx("div",{className:"bonsaif-network-plot relative z-0",children:t.jsx(ia,{data:e,xKey:r,series:[{key:n,label:c,color:u},{key:a,label:d,color:m}],height:N,showLegend:E,showTooltip:v,valueFormat:x,ariaLabel:A,opacity:.18,margin:{top:8,right:8,bottom:4,left:4}})})]})}const pi=["primeSuiteOrigin","primeAuthOrigin","primeSuiteAppUrl"],gi=["primeSuiteOrigin","primeSuiteProjectKey"];function Yb(){if(typeof window>"u")return"*";try{if(window.parent===window)return"*";const e=new URLSearchParams(window.location.search);for(const r of pi){const n=e.get(r);if(n){const a=ua(n);if(a)return a}}if(typeof sessionStorage<"u")for(const r of gi){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=ua(n);if(a)return a}}if(document.referrer){const r=ua(document.referrer);if(r&&r!==window.location.origin)return r}return"*"}catch{return"*"}}function Kb(){if(typeof window>"u")return"self";try{if(window.parent===window)return"self";const e=new URLSearchParams(window.location.search);for(const r of pi)if(e.get(r))return"query";if(typeof sessionStorage<"u"){for(const r of gi)if(sessionStorage.getItem(r))return"sessionStorage"}if(document.referrer){const r=ua(document.referrer);if(r&&r!==window.location.origin)return"referrer"}return"wildcard"}catch{return"wildcard"}}function ua(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 Gb(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(q,"toast",{enumerable:!0,get:()=>Ha.toast}),q.Alert=pc,q.AreaChart=ia,q.AuthShell=ei,q.AutoGrowTextarea=Bl,q.AutoGrowTextareaField=Nf,q.BarChart=Eb,q.BonsaifButton=Qi,q.BonsaifUIToaster=xb,q.BulletChart=Wb,q.Button=Qe,q.CHART_PALETTE=bn,q.CalendarPicker=wc,q.ChartCard=yb,q.Checkbox=Mn,q.CodeBlock=td,q.ComboChart=Ab,q.CompactFilterSelect=nd,q.CompactSearchInput=rd,q.ConfirmDialog=ld,q.CopyButton=Va,q.CopyLinkButton=ud,q.CpuChart=jb,q.DataSheets=vd,q.DataTable=qa,q.DateRangePicker=kd,q.DonutChart=Mb,q.Drawer=Od,q.DropdownMenu=Ld,q.DynamicDetailTabs=mc,q.EmailField=ru,q.EmptyState=Hn,q.EventCalendar=Jc,q.FieldHelperFooter=Tr,q.FieldLabelInfo=Mr,q.FieldLayoutEditor=iu,q.FileUpload=su,q.FormField=zn,q.FunnelChart=Pb,q.GaugeChart=_b,q.GlobalScrollbars=Kl,q.ImageLightbox=Ys,q.ImageLightboxHost=gu,q.InputField=to,q.LineChart=Sb,q.LoadingState=rs,q.MentionTextEditor=Ol,q.MicroserviceFrame=mb,q.Modal=Xa,q.MouseTooltip=Bt,q.MultiDateCalendar=Cd,q.MultiSelect=xu,q.NetworkChart=Xb,q.NumberField=yu,q.PageHeader=ub,q.PageSearchInput=Qo,q.Pagination=Nu,q.PhoneField=Su,q.PieChart=Cb,q.PrimeAuthRouteShell=fb,q.PrimeSuiteChatFrame=hb,q.RadioGroup=Eu,q.RamChart=qb,q.RichTextEditor=sf,q.SearchableSelect=dr,q.SectionPanel=lf,q.Sparkline=$b,q.StatusBadge=uf,q.StatusSelect=pf,q.StepWizard=vf,q.TableSkeleton=Cn,q.Tabs=gf,q.TagInput=Df,q.TextInput=_n,q.Textarea=Fl,q.TextareaField=Mf,q.TimeField=zf,q.TimePicker=Ul,q.Toggle=jf,q.TruncatedWithTooltip=Ut,q.UserAvatar=Rl,q.WaterfallChart=Lb,q.YearMultiDateCalendar=Td,q.buildMentionQueryRegex=bl,q.chunkMonthWeeks=ys,q.clearMentionChipSelection=Or,q.cn=Qt,q.computeWeekBars=Ua,q.configureBonsaifUI=Mc,q.dedupeMentions=vl,q.defaultValueFormat=kt,q.deleteEditorSelection=Ml,q.describeParentTargetOrigin=Kb,q.emailFormat=_d,q.ensureMentionChipTrailingSpaces=dn,q.extractMentionUsernames=po,q.filterSelfMentions=Ru,q.findMentionChipAfterCaret=$l,q.findMentionChipBeforeCaret=Tl,q.findMentionChipsInSelection=wo,q.findMentionTriggerInEditor=mo,q.formatBytes=Fr,q.formatPercent=Br,q.formatRate=si,q.getBonsaifUIConfig=Tc,q.getDataTablePreferencesEndpoint=za,q.getEditorPlainText=yo,q.getMonthGrid=xs,q.getPlainTextOffset=Zn,q.getWeekDays=vs,q.groupItemsByDay=ws,q.highlightMentions=xl,q.htmlToText=pl,q.insertMentionInEditor=wl,q.isMentionTriggerBoundary=hl,q.isPlainOffsetInsideMentionChip=ml,q.isValidEmail=Ja,q.isValidPhone=Ra,q.locateTextOffset=Dr,q.matches=Vd,q.maxLength=jd,q.maxValue=Ud,q.mentionDisplayLabel=gl,q.minLength=Wd,q.minValue=qd,q.normalizeUsername=ho,q.openImageLightboxFromEvent=Vs,q.phoneCountryCodeOptions=Zs,q.phoneFormat=zd,q.placeCaretAfterMentionChip=vo,q.placeCaretAtTextOffset=Nl,q.preferredMentionSpacer=go,q.removeMentionChip=Rn,q.required=Pd,q.resetBonsaifUIConfig=$c,q.resolveMentions=Ju,q.resolveParentTargetOrigin=Yb,q.selectAllEditorContents=El,q.selectMentionChip=Sl,q.selectionIncludesNonChipText=Cl,q.seriesColor=oi,q.setBonsaifDataTablePreferencesEndpoint=Ac,q.syncMentionChipSelectionHighlight=Jn,q.toDateKey=Ft,q.toneColor=zt,q.usageColor=mn,q.usageTone=na,q.useValidationVisibility=Gb,q.validateForm=Xd,Object.defineProperty(q,Symbol.toStringTag,{value:"Module"})}));
|