bonsaif-ui 0.1.128 → 0.1.129
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 +4 -0
- package/dist/bonsaif-ui.js +1395 -1376
- package/dist/bonsaif-ui.umd.cjs +16 -16
- package/dist/components/ui/MentionTextEditor.d.ts.map +1 -1
- package/dist/lib/mentions.d.ts +3 -0
- package/dist/lib/mentions.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/bonsaif-ui.umd.cjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
(function(V,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("react"),require("react/jsx-runtime"),require("react-icons/hi2"),require("react-dom"),require("recharts"),require("overlayscrollbars"),require("sonner"),require("overlayscrollbars-react"),require("react-day-picker"),require("react-day-picker/dist/style.css"),require("react-icons/fi")):typeof define=="function"&&define.amd?define(["exports","react","react/jsx-runtime","react-icons/hi2","react-dom","recharts","overlayscrollbars","sonner","overlayscrollbars-react","react-day-picker","react-day-picker/dist/style.css","react-icons/fi"],o):(V=typeof globalThis<"u"?globalThis:V||self,o(V.BonsaifUI={},V.React,V.jsxRuntime,V.ReactIconsHi2,V.ReactDOM,V.Recharts,V.OverlayScrollbarsGlobal,V.Sonner,V.OverlayScrollbarsReact,V.ReactDayPicker,V.ReactDayPickerStyles,V.ReactIconsFi))})(this,(function(V,o,t,q,ct,Se,Ea,Ma,_o,Ta,im,Ai){"use strict";"use client";function Vt(...e){return e.filter(Boolean).join(" ")}function Li({variant:e="primary",className:r,type:n="button",children:a,...s}){return t.jsx("button",{className:Vt("bonsaif-ui-button",`bonsaif-ui-button--${e}`,r),type:n,...s,children:a})}function zo({value:e,onChange:r,placeholder:n,className:a="",autoFocus:s=!1,forceExpanded:l=!1,onEscape:i,size:c="default",inputTabIndex:d}){const u=o.useRef(null),[m,b]=o.useState(!1),f=l||m||e.trim().length>0,h=c==="sm"?"h-9 rounded-md":"h-10 rounded-lg",v=a||"w-48 max-w-full sm:w-64 lg:w-72";o.useEffect(()=>{var g;s&&((g=u.current)==null||g.focus())},[s]);const k=()=>{var g;b(!0),(g=u.current)==null||g.focus()};return t.jsxs("div",{className:`relative min-w-0 max-w-full flex-shrink-0 overflow-visible transition-[width] duration-200 ease-out ${f?v:"w-24 sm:w-28"}`,onMouseDown:g=>{f||(g.preventDefault(),k())},children:[t.jsx(q.HiMagnifyingGlass,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 pointer-events-none transition-colors duration-200",style:{color:"var(--text-muted)",left:"var(--page-header-control-icon-left, 12px)"}}),t.jsx("input",{ref:u,type:"text",tabIndex:d,"aria-label":n,value:e,onChange:g=>r(g.target.value),onKeyDown:g=>{g.key==="Escape"&&(i==null||i())},placeholder:f?n:"Buscar",className:`${h} w-full py-0 text-sm leading-none placeholder:text-[var(--text-muted)] focus:outline-none transition-all duration-200 ${f?"pl-9 pr-8":"cursor-pointer pl-9 pr-3"}`,style:{height:`var(--page-header-control-height, ${c==="sm"?"36px":"40px"})`,paddingLeft:"calc(var(--page-header-control-icon-left, 12px) + 24px)",paddingRight:f?"calc(var(--page-header-control-padding-x, 14px) + 18px)":"var(--page-header-control-padding-x, 14px)",background:"color-mix(in srgb, var(--bg-card) 86%, transparent)",border:"1px solid var(--border)",color:"var(--text-main)"},onFocus:g=>{b(!0),g.currentTarget.style.borderColor="var(--primary)",g.currentTarget.style.boxShadow="0 0 0 3px rgba(59,130,246,0.12)"},onBlur:g=>{b(!1),g.currentTarget.style.borderColor="var(--border)",g.currentTarget.style.boxShadow="none"}}),e&&t.jsx("button",{type:"button",onClick:()=>r(""),className:"absolute right-2 top-1/2 flex !h-6 !w-6 -translate-y-1/2 items-center justify-center rounded-full !p-0 leading-none transition-colors hover:bg-black/5",style:{color:"var(--text-muted)",right:"var(--page-header-control-padding-x, 8px)"},"aria-label":"Limpiar búsqueda",children:t.jsx(q.HiXMark,{className:"h-3.5 w-3.5 flex-shrink-0"})})]})}const Wo=o.createContext({});let jo=0;const qo="bonsaif-ui:hide-tooltips";function yn(e=700){jo=Date.now()+e}function Di(){return Date.now()>jo}function xn(e){if(typeof document>"u")return!1;const r=Array.from(document.querySelectorAll('[data-bonsaif-overlay="true"], [role="menu"], [role="dialog"][aria-modal="true"], [aria-hidden="false"] [aria-modal="true"]'));return e&&r.some(n=>n.contains(e))?!1:r.length>0}function Ii(e){var a;const r=Array.from(e.querySelectorAll("*")).filter(s=>{var l;return s.scrollWidth>s.clientWidth&&!!((l=s.textContent)!=null&&l.trim())&&s.tagName.toLowerCase()!=="svg"&&!s.closest("svg")});return(e.scrollWidth>e.clientWidth||r.length>0)&&(((a=r[0])==null?void 0:a.textContent)??e.textContent??"").trim()||null}function Yt({children:e,content:r,onlyWhenOverflow:n=!1,interactive:a=!1,followCursor:s=!0,placement:l="bottom",showArrow:i=!1,className:c="",tooltipClassName:d="",style:u,tooltipStyle:m,as:b="div"}){const f=o.useRef(null),h=o.useRef(null),v=o.useRef(null),k=o.useRef(!1),[g,A]=o.useState(null),[$,N]=o.useState("");o.useEffect(()=>{const D=f.current;D&&(D.querySelectorAll("[title]").forEach(Q=>{const j=Q.getAttribute("title");j&&(Q.getAttribute("aria-label")||Q.setAttribute("aria-label",j),Q.removeAttribute("title"))}),D.querySelectorAll("svg title").forEach(Q=>Q.remove()))}),o.useLayoutEffect(()=>{if(!g)return;const D=h.current;if(!D)return;const Q=12,j=14,se=D.getBoundingClientRect(),te=window.innerWidth-se.width-Q,ee=window.innerHeight-se.height-Q;let U=g.mouseX+j,J=g.mouseY+j,ce,C;if(!s&&f.current){const _=f.current.getBoundingClientRect(),ae=_.left+_.width/2,B=_.top+_.height/2;l==="top"?(U=ae-se.width/2,J=_.top-se.height-j,C=se.height-1):l==="left"?(U=_.left-se.width-j,J=B-se.height/2,ce=se.width-1):l==="right"?(U=_.right+j,J=B-se.height/2,ce=-7):(U=ae-se.width/2,J=_.bottom+j,C=-7)}if(s&&(U>te&&(U=g.mouseX-se.width-j),J>ee&&(J=g.mouseY-se.height-j)),U=Math.min(Math.max(Q,U),Math.max(Q,te)),J=Math.min(Math.max(Q,J),Math.max(Q,ee)),!s&&f.current){const _=f.current.getBoundingClientRect(),ae=_.left+_.width/2,B=_.top+_.height/2;l==="top"||l==="bottom"?ce=Math.min(Math.max(14,ae-U),se.width-14):C=Math.min(Math.max(14,B-J),se.height-14)}(Math.abs(U-g.x)>.5||Math.abs(J-g.y)>.5||ce!==g.arrowX||C!==g.arrowY)&&A(_=>_&&{..._,x:U,y:J,arrowX:ce,arrowY:C})},[s,l,g]);const T=()=>{v.current&&(window.clearTimeout(v.current),v.current=null)},x=(D,Q)=>{if(!Di()||k.current)return;const j=f.current;if(j&&!xn(j)){if(n){const se=Ii(j);if(!se)return;N(se)}!n&&!r||A({mouseX:D,mouseY:Q,x:D+14,y:Q+14})}},y=()=>{const D=f.current;if(!D)return;const Q=D.getBoundingClientRect();x(Q.left+Q.width/2,Q.bottom)},L=()=>{T(),A(null)},w=()=>{if(!a){L();return}T(),v.current=window.setTimeout(()=>A(null),120)},W=()=>{yn(),k.current=!0,L()},X=()=>{k.current=!1};o.useEffect(()=>{if(!g)return;if(xn(f.current)){A(null);return}const D=()=>A(null),Q=()=>{yn(),k.current=!0,A(null)};document.addEventListener("pointerdown",Q,!0),document.addEventListener("click",Q,!0),document.addEventListener("scroll",D,!0),window.addEventListener("blur",D),document.addEventListener("visibilitychange",D),document.addEventListener("keydown",D,!0);const j=new MutationObserver(()=>{xn(f.current)&&A(null)});return j.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["role","aria-modal","aria-hidden","class"]}),()=>{document.removeEventListener("pointerdown",Q,!0),document.removeEventListener("click",Q,!0),document.removeEventListener("scroll",D,!0),window.removeEventListener("blur",D),document.removeEventListener("visibilitychange",D),document.removeEventListener("keydown",D,!0),j.disconnect()}},[g]),o.useEffect(()=>{const D=()=>yn(),Q=()=>{yn(),k.current=!0,A(null)};return document.addEventListener("pointerdown",D,!0),document.addEventListener("click",D,!0),document.addEventListener("keydown",D,!0),window.addEventListener(qo,Q),()=>{document.removeEventListener("pointerdown",D,!0),document.removeEventListener("click",D,!0),document.removeEventListener("keydown",D,!0),window.removeEventListener(qo,Q)}},[]);const Z=n?$:r;return t.jsxs(t.Fragment,{children:[t.jsx(b,{ref:D=>{f.current=D},className:c,style:u,onMouseEnter:D=>{T(),X(),s?x(D.clientX,D.clientY):y()},onMouseMove:D=>{g&&s&&x(D.clientX,D.clientY)},onMouseDown:W,onClick:W,onMouseLeave:()=>{X(),w()},onFocus:y,onBlur:L,children:e}),g&&Z&&!xn(f.current)?ct.createPortal(t.jsxs("div",{ref:h,role:"tooltip",className:d,onMouseEnter:a?T:void 0,onMouseLeave:a?w:void 0,style:{position:"fixed",top:g.y,left:g.x,zIndex:9999,background:"var(--bg-card)",border:"1px solid var(--border)",borderRadius:6,padding:"5px 10px",fontSize:12,color:"var(--text-main)",boxShadow:"0 4px 16px rgba(0,0,0,0.35)",pointerEvents:a?"auto":"none",maxWidth:"min(420px, calc(100vw - 24px))",whiteSpace:"normal",lineHeight:1.6,overflowWrap:"anywhere",...m},children:[i&&t.jsx("span",{"aria-hidden":"true",style:{position:"absolute",width:12,height:12,background:(m==null?void 0:m.background)??"var(--bg-card)",borderLeft:l==="right"?(m==null?void 0:m.border)??"1px solid var(--border)":void 0,borderTop:l==="bottom"||l==="right"?(m==null?void 0:m.border)??"1px solid var(--border)":void 0,borderRight:l==="left"?(m==null?void 0:m.border)??"1px solid var(--border)":void 0,borderBottom:l==="top"||l==="left"?(m==null?void 0:m.border)??"1px solid var(--border)":void 0,transform:"rotate(45deg)",left:g.arrowX===void 0?void 0:g.arrowX-6,top:g.arrowY===void 0?void 0:g.arrowY-6,zIndex:-1}}),Z]}),document.body):null]})}function Uo(e){if(e!==void 0)return typeof e=="number"?`${e}px`:e}const Oi="inline-flex shrink-0 items-center justify-center gap-2 whitespace-nowrap leading-none font-medium transition-all duration-150 focus:outline-none disabled:opacity-50 rounded-lg",Hi={primary:"border border-[var(--border)] text-[var(--text-main)] hover:border-[var(--border)] hover:bg-[var(--bg-input)] active:scale-[0.98] transition-colors",secondary:"border border-[var(--border)] text-[var(--text-main)] hover:border-[var(--border)] hover:bg-[var(--bg-input)] active:scale-[0.98] transition-colors",danger:"border border-[var(--border)] text-[var(--danger)] hover:border-[var(--danger)] hover:bg-[var(--danger-bg)] active:scale-[0.98] transition-colors",ghost:"text-[var(--text-secondary)] hover:opacity-70",icon:"text-[var(--text-muted)] hover:text-[var(--primary)] hover:bg-primary/5"},Bi="border border-[var(--border)] text-[var(--text-muted)] shadow-sm shadow-black/5 hover:border-[var(--border)] hover:bg-[var(--bg-input)] hover:text-[var(--primary)] active:scale-[0.98] transition-colors",Fi={xs:"h-8 px-2.5 text-xs",sm:"h-9 px-3.5 text-xs",md:"h-10 px-3.5 text-sm",lg:"h-11 px-4 text-sm font-semibold"},Pi={xs:"h-8 w-8",sm:"h-9 w-9",md:"h-10 w-10",lg:"h-10 w-10"},_i={primary:{background:"var(--bg-card)"},secondary:{background:"var(--bg-card)"},danger:{background:"var(--bg-card)"},ghost:{},icon:{}};function $a(e){return typeof e=="string"||typeof e=="number"?String(e):Array.isArray(e)?e.map($a).join(" ").trim():o.isValidElement(e)?$a(e.props.children):""}function zi(e){return o.Children.toArray(e).find(o.isValidElement)??null}function Ue({variant:e="primary",size:r="md",loading:n=!1,icon:a,tooltip:s,iconOnly:l,height:i,padding:c,children:d,className:u="",disabled:m,style:b,...f}){const h=o.useContext(Wo),v=l??h.iconOnly??e==="icon",k=h.compact??!1,g=h.headerAction??!1,A=g&&r==="md"?"sm":k&&!g&&r==="md"?"xs":r,$=e==="icon"||v,N=g&&$,T=$a(d),x=s??f.title??f["aria-label"]??(v?T:void 0),y=x?void 0:f.title,L=f["aria-label"]??(typeof x=="string"?x:T||void 0),w=n?null:a??(v?zi(d):null),W=t.jsxs("button",{...f,title:y,"aria-label":L,"data-variant":e,"data-size":A,"data-icon":$?"true":void 0,disabled:m||n,className:`${Oi} ${N?Bi:Hi[e]} ${$?Pi[A]:Fi[A]} ${k&&!$?"px-2.5":""} ${u}`,style:{..._i[e],height:Uo(i),padding:Uo(c),...b,...g&&!$?{height:"var(--page-header-control-height, 34px)",padding:"0 var(--page-header-control-padding-x, 10px)",borderRadius:"8px"}:null,...N?{width:"var(--page-header-control-height, 40px)",height:"var(--page-header-control-height, 40px)",padding:0,background:"var(--bg-card)",borderRadius:"8px"}:null},children:[n?t.jsx("span",{className:"h-3.5 w-3.5 animate-spin rounded-full border-2 border-current border-t-transparent"}):w,!v&&d]});return x?t.jsx(Yt,{as:"span",content:x,className:"inline-flex shrink-0",children:W}):W}const dt={background:"color-mix(in srgb, var(--text-muted) 26%, var(--bg-input))"};function wn({rows:e=8,columns:r=7,showToolbar:n=!0,showPagination:a=!0,compact:s=!1,className:l=""}){const i=Math.max(3,Math.min(r,12)),c=Math.max(3,Math.min(e,20)),d=s?"px-2 py-2":"px-3 py-2.5",u=s?"px-2 py-2":"px-3 py-3";return t.jsxs("div",{className:`w-full min-w-0 overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${l}`,"aria-busy":"true","aria-label":"Cargando tabla",children:[n&&t.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-[var(--border)] px-3 py-2",children:[t.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[t.jsx("div",{className:"h-7 w-14 shrink-0 animate-pulse rounded-md",style:dt}),t.jsx("div",{className:"h-7 max-w-md flex-1 animate-pulse rounded-md",style:dt})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[t.jsx("div",{className:"h-7 w-7 animate-pulse rounded-md",style:dt}),t.jsx("div",{className:"h-7 w-7 animate-pulse rounded-md",style:dt})]})]}),t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("div",{className:"min-w-full",style:{display:"grid",gridTemplateColumns:`repeat(${i}, minmax(96px, 1fr))`},children:[Array.from({length:i}).map((m,b)=>t.jsx("div",{className:`${u} border-b border-[var(--border)]`,style:{background:"color-mix(in srgb, var(--bg-input) 55%, transparent)"},children:t.jsx("div",{className:"h-3 animate-pulse rounded-md",style:{...dt,width:`${48+b*17%40}%`}})},`h-${b}`)),Array.from({length:c}).map((m,b)=>Array.from({length:i}).map((f,h)=>t.jsx("div",{className:`${d} ${b<c-1?"border-b border-[var(--border)]":""}`,children:t.jsx("div",{className:"h-3.5 animate-pulse rounded-md",style:{...dt,width:`${46+(b*13+h*11)%42}%`,minWidth:28}})},`c-${b}-${h}`)))]})}),a&&t.jsxs("div",{className:"flex items-center justify-between gap-3 border-t border-[var(--border)] px-3 py-2",style:{background:"color-mix(in srgb, var(--bg-input) 40%, transparent)"},children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"h-3 w-28 animate-pulse rounded-md",style:dt}),t.jsx("div",{className:"h-7 w-14 animate-pulse rounded-md",style:dt})]}),t.jsx("div",{className:"flex items-center gap-1",children:Array.from({length:4}).map((m,b)=>t.jsx("div",{className:"h-7 w-7 animate-pulse rounded-md",style:dt},b))}),t.jsx("div",{className:"h-3 w-16 animate-pulse rounded-md",style:dt})]})]})}function Wi({size:e="md"}){const r=e==="sm"?"h-7 w-7":"h-9 w-9";return t.jsx("div",{className:`${r} animate-spin rounded-full border-2 border-[var(--border)] border-t-[var(--primary)]`,"aria-hidden":!0})}function ji({logoSrc:e,logoAlt:r}){return e?t.jsxs("span",{className:"relative flex h-16 w-16 items-center justify-center","aria-hidden":!1,children:[t.jsx("span",{className:"absolute inset-0 rounded-2xl opacity-40 blur-xl",style:{background:"radial-gradient(circle, color-mix(in srgb, var(--primary) 45%, transparent) 0%, transparent 70%)"}}),t.jsx("img",{src:e,alt:r,className:"relative h-14 w-14 rounded-2xl object-contain shadow-sm shadow-black/10"})]}):null}function Vo({variant:e="page",title:r="Cargando...",description:n,logoSrc:a,logoAlt:s,appearance:l="card",rows:i=6,columns:c=7,children:d,className:u=""}){if(e==="table")return t.jsx(wn,{rows:i,columns:c,className:u});if(e==="sections")return t.jsx(qi,{rows:i});if(e==="cards")return t.jsx(Ui,{rows:i});const m=s||(typeof r=="string"?r:"Aplicación"),b=l==="bare",f=t.jsxs("div",{className:`flex flex-col items-center text-center ${b?"gap-5":"gap-3"}`,children:[a?t.jsx(ji,{logoSrc:a,logoAlt:m}):null,t.jsx(Wi,{size:b?"md":"sm"}),t.jsxs("div",{className:b?"space-y-1.5":"",children:[t.jsx("p",{className:b?"text-base font-semibold tracking-tight text-[var(--text-main)]":"text-sm font-semibold text-[var(--text-main)]",children:r}),n?t.jsx("p",{className:b?"text-sm font-medium text-[var(--text-muted)]":"mt-1 text-xs text-[var(--text-muted)]",children:n}):null,d&&t.jsx("div",{className:"mt-1 text-xs text-[var(--text-muted)]",children:d})]})]});return b?t.jsx("div",{className:`flex min-h-[240px] w-full items-center justify-center p-8 ${u}`,role:"status","aria-live":"polite","aria-busy":"true",children:f}):t.jsx("div",{className:`flex min-h-[240px] items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-6 ${u}`,role:"status","aria-live":"polite","aria-busy":"true",children:f})}function qi({rows:e}){return t.jsx(wn,{rows:e,columns:7})}function Ui({rows:e}){return t.jsx("div",{className:"grid gap-3 md:grid-cols-2 xl:grid-cols-3",children:Array.from({length:e}).map((r,n)=>t.jsxs("div",{className:"rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-4",children:[t.jsx("div",{className:"h-4 w-2/3 animate-pulse rounded-md",style:dt}),t.jsx("div",{className:"mt-3 h-3 w-full animate-pulse rounded-md",style:dt}),t.jsx("div",{className:"mt-2 h-3 w-4/5 animate-pulse rounded-md",style:dt})]},n))})}function Yo(e){const r=e.split("/").filter(Boolean);return(r[r.length-1]??e).replace(/^lv_/,"").split(/[-_]/).filter(Boolean).map(a=>a.charAt(0).toUpperCase()+a.slice(1)).join(" ")}function Xo(e){return e.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().trim()}function Vi(e){return[e.label,Yo(e.service),e.description,e.service].filter(Boolean).join(" ")}function Yi(e){return typeof e=="function"?e:e.default}function Xi(e,r){return t.jsx("div",{className:"flex min-h-[220px] items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-6 text-center",children:t.jsxs("div",{className:"max-w-md",children:[t.jsx("p",{className:"text-sm font-semibold text-[var(--text-main)]",children:"No se pudo cargar este modulo"}),t.jsx("p",{className:"mt-1 text-xs text-[var(--text-muted)]",children:e.message}),t.jsx(Ue,{className:"mt-4",height:36,padding:"0 14px",onClick:r,children:"Reintentar"})]})})}function Ki({parentPanel:e,parentPanelComponent:r,renderParentPanel:n,parent:a,context:s,links:l,moduleRegistry:i,loadModule:c,activeService:d,initialService:u,onActiveServiceChange:m,canAccess:b,keepAlive:f=!0,title:h,subtitle:v,emptyState:k,loadingState:g,errorState:A=Xi,renderTabLabel:$,searchableTabs:N="auto",tabsSearchThreshold:T=6,tabsSearchPlaceholder:x="Buscar modulo...",tabsSearchValue:y,onTabsSearchChange:L,emptySearchState:w,showTabCount:W=!0,className:X="",parentClassName:Z="",contentClassName:D="",tabsClassName:Q=""}){var Et;const j=o.useMemo(()=>l.filter(le=>!le.hidden&&((b==null?void 0:b(le,s))??!0)),[b,s,l]),se=(Et=j.find(le=>!le.disabled))==null?void 0:Et.service,[te,ee]=o.useState(u??se??""),[U,J]=o.useState({}),[ce,C]=o.useState({}),[_,ae]=o.useState(""),[B,I]=o.useState(!1),M=o.useRef(ce),oe=o.useRef(0),K=y??_,Y=Xo(K),S=N===!0||N==="auto"&&j.length>=T,H=S&&K.trim().length>0,O=o.useMemo(()=>Y?j.filter(le=>Xo(Vi(le)).includes(Y)):j,[Y,j]),re=d??te,z=j.find(le=>le.service===re)??j.find(le=>!le.disabled);o.useEffect(()=>{!z&&se&&ee(se)},[se,z]),o.useEffect(()=>{M.current=ce},[ce]);const de=le=>{le.disabled||(d||ee(le.service),m==null||m(le.service,le))},he=le=>{y===void 0&&ae(le),L==null||L(le)},ie=(le,Fe)=>{const ze=O.filter(Ve=>!Ve.disabled),ft=ze.findIndex(Ve=>Ve.service===Fe.service);ft<0||((le.key==="ArrowRight"||le.key==="ArrowDown")&&(le.preventDefault(),de(ze[(ft+1)%ze.length])),(le.key==="ArrowLeft"||le.key==="ArrowUp")&&(le.preventDefault(),de(ze[(ft-1+ze.length)%ze.length])),le.key==="Home"&&(le.preventDefault(),de(ze[0])),le.key==="End"&&(le.preventDefault(),de(ze[ze.length-1])))},ge=o.useCallback(()=>{if(!z)return;const le=z.service,Fe=M.current[le];if(Fe!=null&&Fe.loading||Fe!=null&&Fe.component&&f)return;const ze=(i==null?void 0:i[le])??c;if(!ze){C(Ve=>({...Ve,[le]:{loading:!1,error:new Error(`No module loader found for service "${le}".`)}}));return}const ft=++oe.current;C(Ve=>({...Ve,[le]:{...Ve[le],loading:!0,error:void 0}})),ze(z,s).then(Ve=>{if(ft!==oe.current&&!f)return;const Mt=Yi(Ve);C(bt=>({...bt,[le]:{component:Mt,loading:!1}}))}).catch(Ve=>{const Mt=Ve instanceof Error?Ve:new Error(String(Ve));C(bt=>({...bt,[le]:{...bt[le],loading:!1,error:Mt}}))})},[s,f,c,i,z]);o.useEffect(ge,[ge]);const Me=z?U[z.service]??null:null,$e=z?ce[z.service]:void 0,Dt=$e==null?void 0:$e.component,ut=le=>{z&&J(Fe=>({...Fe,[z.service]:le}))},Re=()=>{z&&J(le=>({...le,[z.service]:null}))},It={context:s,parent:a,links:l,visibleLinks:j,filteredLinks:O,selectedLink:z,selectedService:z==null?void 0:z.service,activeItemId:Me,tabsSearch:K,onSelectService:de,onOpenDetail:ut,onBackToList:Re},Ct=n?n(It):r?t.jsx(r,{...It}):e;return t.jsxs("section",{className:`grid min-h-[520px] gap-4 lg:grid-cols-[minmax(260px,360px)_minmax(0,1fr)] ${X}`,children:[t.jsx("aside",{className:`min-w-0 rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-4 ${Z}`,children:Ct}),t.jsxs("div",{className:`relative min-w-0 overflow-visible rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${D}`,children:[(h||v||S||W)&&t.jsx("div",{className:"relative border-b border-[var(--border)] px-4 py-3",children:t.jsxs("div",{className:"flex min-w-0 items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[h&&t.jsx("h2",{className:"truncate text-sm font-semibold text-[var(--text-main)]",children:h}),v&&t.jsx("p",{className:"mt-1 line-clamp-2 text-xs text-[var(--text-muted)]",children:v})]}),(S||W)&&t.jsxs("div",{className:"flex min-w-0 flex-shrink-0 items-center justify-end gap-2",children:[W&&t.jsxs("span",{className:"hidden text-xs font-semibold text-[var(--text-muted)] transition-opacity duration-200 sm:inline",children:[O.length," / ",j.length]}),S&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:`origin-right overflow-hidden transition-[width,opacity,transform] duration-200 ease-out ${B?"w-[min(20rem,44vw)] translate-x-0 opacity-100":"w-0 translate-x-2 opacity-0"}`,"aria-hidden":!B,children:t.jsx(zo,{value:K,onChange:he,placeholder:x,className:"w-full",autoFocus:B,forceExpanded:!0,onEscape:()=>I(!1),size:"sm",inputTabIndex:B?0:-1})}),t.jsx("button",{type:"button","aria-label":B?"Cerrar busqueda":"Buscar tabs","aria-expanded":B,onClick:()=>{B&&K&&he(""),I(le=>!le)},className:`inline-flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-md border transition-all duration-200 hover:scale-[1.03] active:scale-95 ${B||H?"border-[var(--primary)] bg-[var(--bg-input)] text-[var(--text-main)] shadow-sm":"border-[var(--border)] text-[var(--text-muted)] hover:bg-[var(--bg-input)] hover:text-[var(--text-main)]"}`,children:t.jsx("span",{className:"grid h-4 w-4 place-items-center transition-transform duration-200",children:B||H?t.jsx(q.HiXMark,{className:"h-4 w-4"}):t.jsx(q.HiMagnifyingGlass,{className:"h-4 w-4"})})})]})]})]})}),t.jsx("div",{role:"tablist","aria-label":h??"Modulos relacionados",className:`flex gap-1 overflow-x-auto border-b border-[var(--border)] bg-[var(--bg-input)] px-2 py-1.5 transition-colors duration-200 ${Q}`,children:O.length>0?O.map(le=>{const Fe=le.service===(z==null?void 0:z.service);return t.jsx("button",{type:"button",role:"tab","aria-selected":Fe,disabled:le.disabled,onClick:()=>de(le),onKeyDown:ze=>ie(ze,le),className:`inline-flex h-9 min-w-max items-center gap-2 rounded-md border px-3 text-xs font-semibold transition-all duration-200 disabled:cursor-not-allowed disabled:opacity-50 ${Fe?"border-[var(--primary)] bg-[var(--bg-card)] text-[var(--text-main)] shadow-sm":"border-transparent text-[var(--text-muted)] hover:bg-[var(--bg-card)] hover:text-[var(--text-main)]"}`,children:$?$(le,Fe):t.jsxs(t.Fragment,{children:[le.icon,t.jsx("span",{children:le.label??Yo(le.service)}),le.badge&&t.jsx("span",{className:"rounded-full bg-[var(--bg-input)] px-1.5 py-0.5 text-[10px] text-[var(--text-muted)]",children:le.badge})]})},le.service)}):t.jsx("div",{className:"flex min-h-9 flex-1 items-center rounded-md border border-dashed border-[var(--border)] px-3 text-xs text-[var(--text-muted)]",children:w??"No hay modulos que coincidan con la busqueda."})}),(z==null?void 0:z.description)&&t.jsx("div",{className:"border-b border-[var(--border)] px-4 py-2 text-xs text-[var(--text-muted)]",children:z.description}),t.jsxs("div",{className:"min-h-[420px] p-4",children:[!z&&(k??t.jsx("div",{className:"flex min-h-[220px] items-center justify-center rounded-lg border border-dashed border-[var(--border)] text-sm text-[var(--text-muted)]",children:"No hay modulos disponibles."})),z&&($e==null?void 0:$e.loading)&&(g??t.jsx(Vo,{title:"Cargando modulo..."})),z&&($e==null?void 0:$e.error)&&A($e.error,ge),z&&Dt&&!($e!=null&&$e.loading)&&!($e!=null&&$e.error)&&t.jsx(Dt,{context:s,parent:a,link:z,activeItemId:Me,onOpenDetail:ut,onBackToList:Re})]})]})]})}const Gi={info:{color:"#2563eb",background:"rgba(59, 130, 246, 0.1)",border:"rgba(59, 130, 246, 0.24)",icon:t.jsx(q.HiInformationCircle,{className:"h-5 w-5"})},success:{color:"#047857",background:"rgba(16, 185, 129, 0.1)",border:"rgba(16, 185, 129, 0.24)",icon:t.jsx(q.HiCheckCircle,{className:"h-5 w-5"})},warning:{color:"#b45309",background:"rgba(245, 158, 11, 0.12)",border:"rgba(245, 158, 11, 0.26)",icon:t.jsx(q.HiExclamationTriangle,{className:"h-5 w-5"})},danger:{color:"var(--danger)",background:"var(--danger-bg)",border:"color-mix(in srgb, var(--danger) 20%, var(--border))",icon:t.jsx(q.HiExclamationCircle,{className:"h-5 w-5"})},neutral:{color:"var(--text-secondary)",background:"var(--bg-input)",border:"var(--border)",icon:t.jsx(q.HiInformationCircle,{className:"h-5 w-5"})}};function Zi({variant:e="info",title:r,children:n,icon:a,action:s,onDismiss:l,className:i=""}){const c=Gi[e];return t.jsxs("div",{role:e==="danger"||e==="warning"?"alert":"status",className:`flex items-start gap-3 rounded-lg border px-3 py-3 ${i}`,style:{background:c.background,borderColor:c.border},children:[t.jsx("div",{className:"mt-0.5 shrink-0",style:{color:c.color},children:a??c.icon}),t.jsxs("div",{className:"min-w-0 flex-1",children:[r&&t.jsx("div",{className:"text-sm font-semibold text-[var(--text-main)]",children:r}),n&&t.jsx("div",{className:"mt-0.5 text-sm leading-5 text-[var(--text-secondary)]",children:n}),s&&t.jsx("div",{className:"mt-3",children:s})]}),l&&t.jsx(Ue,{variant:"icon",size:"xs","aria-label":"Cerrar alerta",onClick:l,className:"-mr-1 -mt-1",children:t.jsx(q.HiXMark,{className:"h-4 w-4"})})]})}const Ko=["Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre"],Qi=["Ene","Feb","Mar","Abr","May","Jun","Jul","Ago","Sep","Oct","Nov","Dic"],Ji=["lu","ma","mi","ju","vi","sá","do"],Go=6;function Aa(e,r,n){return`${e}-${String(r).padStart(2,"0")}-${String(n).padStart(2,"0")}`}function Ri(){const e=new Date;return Aa(e.getFullYear(),e.getMonth()+1,e.getDate())}function Zo(e){const[r,n,a]=e.split("-").map(Number);return{year:r,month:n,day:a}}function ec(e){if(!e)return"Seleccionar fecha";const{year:r,month:n,day:a}=Zo(e);return!r||!n||!a?"Seleccionar fecha":`${String(a).padStart(2,"0")} ${Ko[n-1]} ${r}`}function tc({value:e,onChange:r,minDate:n,displayMode:a="inline",className:s=""}){const l=Ri(),c=Zo(e||l),d=a==="popover",[u,m]=o.useState(!1),b=o.useRef(null),[f,h]=o.useState({horizontal:"left",vertical:"bottom"}),[v,k]=o.useState(c.year),[g,A]=o.useState(c.month),[$,N]=o.useState("days"),T=16,[x,y]=o.useState(0),L=v-7+x,w=Array.from({length:T},(ee,U)=>L+U);o.useEffect(()=>{if(!d||!u||!b.current)return;const ee=b.current.getBoundingClientRect(),U=8,J=280,ce=340,C=ee.left+J>window.innerWidth-U,_=ee.right-J>=U,ae=ee.bottom+8+ce>window.innerHeight-U,B=ee.top-8-ce>=U;h({horizontal:C&&_?"right":"left",vertical:ae&&B?"top":"bottom"})},[d,u]),o.useEffect(()=>{if(!d||!u)return;function ee(J){b.current&&(b.current.contains(J.target)||m(!1))}function U(J){J.key==="Escape"&&m(!1)}return document.addEventListener("mousedown",ee),document.addEventListener("keydown",U),()=>{document.removeEventListener("mousedown",ee),document.removeEventListener("keydown",U)}},[d,u]);function W(){g===1?(k(ee=>ee-1),A(12)):A(ee=>ee-1)}function X(){g===12?(k(ee=>ee+1),A(1)):A(ee=>ee+1)}const Z=(new Date(v,g-1,1).getDay()+6)%7,D=new Date(v,g,0).getDate(),Q=[...Array(Z).fill(null),...Array.from({length:D},(ee,U)=>U+1)];for(;Q.length<Go*7;)Q.push(null);const j=Q.slice(0,Go*7);function se(ee){const U=Aa(v,g,ee);n&&U<n||(r(U),d&&m(!1))}const te=t.jsx("div",{className:`bonsaif-calendar bonsaif-calendar-picker ${s}`.trim(),children:t.jsxs("div",{className:"bonsaif-cal-shell",children:[t.jsx("div",{className:"bonsaif-cal-toolbar",children:$==="days"?t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn",onClick:W,"aria-label":"Mes anterior",children:t.jsx(q.HiChevronLeft,{size:16})}),t.jsxs("button",{type:"button",className:"bonsaif-cal-title-btn",onClick:()=>{N("years"),y(0)},children:[t.jsxs("span",{className:"bonsaif-cal-title",children:[Ko[g-1]," ",v]}),t.jsx(q.HiChevronDown,{size:13})]}),t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn",onClick:X,"aria-label":"Mes siguiente",children:t.jsx(q.HiChevronRight,{size:16})})]}):t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn",onClick:()=>y(ee=>ee-T),"aria-label":"Años anteriores",children:t.jsx(q.HiChevronLeft,{size:16})}),t.jsx("button",{type:"button",className:"bonsaif-cal-title-btn",onClick:()=>N("days"),children:t.jsxs("span",{className:"bonsaif-cal-title",children:[w[0]," – ",w[w.length-1]]})}),t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn",onClick:()=>y(ee=>ee+T),"aria-label":"Años siguientes",children:t.jsx(q.HiChevronRight,{size:16})})]})}),$==="years"?t.jsxs("div",{className:"bonsaif-cal-picker-years",children:[t.jsx("div",{className:"bonsaif-cal-picker-months",children:Qi.map((ee,U)=>{const J=U+1===g;return t.jsx("button",{type:"button",className:`bonsaif-cal-pill-btn${J?" is-active":""}`,onClick:()=>A(U+1),children:ee},ee)})}),t.jsx("div",{className:"bonsaif-cal-picker-year-grid",children:w.map(ee=>{const U=ee===v,J=ee===new Date().getFullYear();return t.jsx("button",{type:"button",className:`bonsaif-cal-pill-btn${U?" is-active":""}${J&&!U?" is-today":""}`,onClick:()=>{k(ee),N("days")},children:ee},ee)})})]}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"bonsaif-multi-weekdays bonsaif-cal-picker-weekdays",children:Ji.map(ee=>t.jsx("div",{className:"bonsaif-multi-weekday",children:ee},ee))}),t.jsx("div",{className:"bonsaif-cal-picker-days",children:j.map((ee,U)=>{if(ee===null)return t.jsx("div",{className:"bonsaif-multi-day bonsaif-multi-day-hidden"},U);const J=Aa(v,g,ee),ce=J===e,C=J===l,_=!!(n&&J<n);return t.jsx("div",{className:`bonsaif-multi-day${ce?" bonsaif-multi-day-selected":""}${C?" bonsaif-multi-day-today":""}${_?" bonsaif-multi-day-disabled":""}`,children:t.jsx("button",{type:"button",className:"bonsaif-multi-day-btn",disabled:_,"aria-pressed":ce,onClick:()=>!_&&se(ee),children:ee})},U)})})]})]})});return d?t.jsxs("div",{ref:b,className:`relative w-full ${s}`.trim(),children:[t.jsxs("button",{type:"button",onClick:()=>m(ee=>!ee),className:"bonsaif-cal-trigger","data-open":u?"true":"false",children:[t.jsxs("span",{className:"inline-flex items-center gap-2 min-w-0",children:[t.jsx(q.HiCalendarDays,{className:"w-4 h-4 text-[var(--text-muted)]"}),t.jsx("span",{className:"truncate",children:ec(e)})]}),t.jsx(q.HiChevronDown,{className:`w-4 h-4 text-[var(--text-muted)] transition-transform ${u?"rotate-180":""}`})]}),u&&t.jsx("div",{className:"absolute z-50",style:{...f.horizontal==="left"?{left:0}:{right:0},...f.vertical==="bottom"?{top:"calc(100% + 8px)"}:{bottom:"calc(100% + 8px)"}},children:te})]}):te}const rc={sm:"h-4 w-4",md:"h-5 w-5"};function nc(e,r){if(typeof e=="function"){e(r);return}e&&(e.current=r)}const Nn=o.forwardRef(function({label:r,description:n,error:a,size:s="md",indeterminate:l=!1,className:i="",containerClassName:c="",disabled:d,...u},m){const b=o.useRef(null);return o.useEffect(()=>{b.current&&(b.current.indeterminate=l)},[l]),t.jsxs("label",{className:`group inline-flex items-start gap-2.5 ${d?"cursor-not-allowed opacity-60":"cursor-pointer"} ${c}`,children:[t.jsxs("span",{className:"relative mt-0.5 inline-flex shrink-0",children:[t.jsx("input",{...u,ref:f=>{b.current=f,nc(m,f)},type:"checkbox",disabled:d,"aria-checked":l?"mixed":u["aria-checked"],"aria-invalid":!!a||u["aria-invalid"],className:`peer ${rc[s]} appearance-none rounded border border-[var(--border)] bg-[var(--bg-input)] transition-colors checked:border-[var(--primary)] checked:bg-[var(--primary)] focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--primary)]/40 ${i}`}),t.jsx(q.HiCheck,{className:"pointer-events-none absolute left-1/2 top-1/2 h-3.5 w-3.5 -translate-x-1/2 -translate-y-1/2 scale-75 text-[var(--primary-fg)] opacity-0 transition peer-checked:scale-100 peer-checked:opacity-100 peer-aria-checked:mixed:scale-100 peer-aria-checked:mixed:opacity-100"})]}),(r||n||a)&&t.jsxs("span",{className:"min-w-0",children:[r&&t.jsx("span",{className:"block text-sm font-medium leading-5 text-[var(--text-main)]",children:r}),n&&!a&&t.jsx("span",{className:"block text-xs leading-5 text-[var(--text-muted)]",children:n}),a&&t.jsx("span",{className:"block text-xs leading-5 text-[var(--danger)]",children:a})]})]})});function Qo(e){const r=document.createElement("textarea");r.value=e,r.style.position="fixed",r.style.opacity="0",r.style.pointerEvents="none",document.body.appendChild(r),r.select(),document.execCommand("copy"),document.body.removeChild(r)}async function ac(e){var r;if((r=navigator.clipboard)!=null&&r.writeText){await navigator.clipboard.writeText(e);return}Qo(e)}function oc(e){return typeof e=="function"?e():e}function La({value:e,resetDelay:r=2e3,title:n,copiedTitle:a="Copiado",copiedLabel:s,icon:l=t.jsx(q.HiClipboardDocument,{size:14}),copiedIcon:i=t.jsx(q.HiCheck,{size:14}),stopPropagation:c=!0,onCopied:d,onCopyError:u,className:m="",style:b,children:f,onClick:h,type:v="button",...k}){const[g,A]=o.useState(!1),$=o.useRef(null);o.useEffect(()=>()=>{$.current&&window.clearTimeout($.current)},[]);function N(x){A(!0),d==null||d(x),$.current&&window.clearTimeout($.current),$.current=window.setTimeout(()=>{A(!1),$.current=null},r)}async function T(x){var L;if(c&&x.stopPropagation(),h==null||h(x),x.defaultPrevented)return;const y=oc(e);if(y)try{await ac(y),N(y)}catch(w){try{Qo(y),N(y)}catch(W){u==null||u(W,y);return}(L=navigator.clipboard)!=null&&L.writeText||u==null||u(w,y)}}return t.jsxs("button",{...k,type:v,onClick:T,title:g?a:n,"aria-label":k["aria-label"]??(g?a:n),"data-copied":g?"true":void 0,className:`relative inline-flex h-7 shrink-0 items-center justify-center gap-1.5 rounded-md transition-all duration-200 ${f?"min-w-7 px-2":"w-7"} ${m}`,style:{cursor:"pointer",background:g?"rgba(22,163,74,0.15)":"var(--bg-card)",border:g?"1px solid rgba(22,163,74,0.4)":"1px solid var(--border)",color:g?"#16a34a":"var(--text-secondary)",boxShadow:g?"0 0 0 3px rgba(22,163,74,0.12)":"none",...b},children:[t.jsx("span",{className:"inline-flex items-center justify-center transition-all duration-150",style:{transform:g?"scale(1.15)":"scale(1)"},children:g?i:l}),f&&t.jsx("span",{className:"text-xs font-semibold leading-none",children:g?s??f:f})]})}function sc({code:e,children:r,title:n="Codigo",language:a,copyLabel:s="Copiar",copiedLabel:l="Copiado",className:i="",style:c,onCopied:d}){const u=(e??r??"").trim();return t.jsxs("div",{className:`overflow-hidden rounded-lg border ${i}`,style:{borderColor:"rgba(148, 163, 184, 0.22)",background:"#0f172a",color:"#e2e8f0",...c},children:[t.jsxs("div",{className:"flex min-h-9 items-center justify-between gap-3 border-b px-3 py-1.5",style:{borderColor:"rgba(148, 163, 184, 0.18)",background:"#111827",color:"#94a3b8"},children:[t.jsx("span",{className:"min-w-0 truncate text-[11px] font-black uppercase tracking-[0.08em]",children:n}),t.jsx(La,{value:u,title:"Copiar codigo",copiedTitle:"Codigo copiado",copiedLabel:l,onCopied:d,className:"h-7 min-w-[72px] px-2",style:{background:"#182235",border:"1px solid rgba(148, 163, 184, 0.28)",color:"#f8fafc"},children:s})]}),t.jsx("pre",{className:"m-0 overflow-x-auto p-3 text-xs leading-6",style:{background:"#0f172a",color:"#e2e8f0",fontFamily:'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace'},children:t.jsx("code",{className:a?`language-${a}`:void 0,children:u})})]})}function Pt({children:e,className:r="",style:n,as:a="span",followCursor:s=!1,placement:l="top"}){return t.jsx(Yt,{onlyWhenOverflow:!0,as:a,followCursor:s,placement:l,showArrow:!s,className:r,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",minWidth:0,...n},children:e})}function Da(e){if(e!==void 0)return typeof e=="number"?`${e}px`:e}function Ia(e){return e.normalize("NFD").replace(new RegExp("\\p{M}","gu"),"").toLowerCase()}function lc(e,r){if(!r.trim())return!0;const n=Ia(r);return Ia(e.label).includes(n)||!!(e.sublabel&&Ia(e.sublabel).includes(n))}function ar({value:e,onChange:r,options:n,status:a="default",ariaLabel:s,triggerVariant:l="default",showSelectedSublabel:i=!0,placeholder:c="Seleccionar…",emptyLabel:d,disabled:u=!1,className:m="",style:b,dropdownMinWidth:f,height:h=40,padding:v="0 10px",searchable:k=!0,minOptionsForSearch:g=6}){const[A,$]=o.useState(!1),[N,T]=o.useState(""),[x,y]=o.useState(-1),[L,w]=o.useState(!1),[W,X]=o.useState({}),Z=o.useRef(null),D=o.useRef(null),Q=o.useRef(null),j=o.useRef(null),se=k&&n.length>=g,te=n.find(K=>K.value===e)??null,ee=l==="ghost",U=a==="error"?"var(--danger)":A?"var(--primary)":"var(--border)",J=se&&N.trim()?n.filter(K=>lc(K,N)):n,ce=o.useCallback(()=>{const K=Z.current;if(!K)return;const Y=K.getBoundingClientRect(),S=se?272:212,H=window.innerHeight-Y.bottom,O=H<S&&Y.top>H;X({position:"fixed",left:Y.left,top:O?void 0:Y.bottom+4,bottom:O?window.innerHeight-Y.top+4:void 0,width:Y.width,minWidth:Da(f),zIndex:9999})},[f,se]);o.useEffect(()=>w(!0),[]),o.useEffect(()=>{if(!A)return;function K(Y){var H,O;const S=Y.target;!((H=Z.current)!=null&&H.contains(S))&&!((O=D.current)!=null&&O.contains(S))&&($(!1),T(""))}return document.addEventListener("mousedown",K),()=>document.removeEventListener("mousedown",K)},[A]),o.useEffect(()=>{A&&(y(-1),ce(),se&&setTimeout(()=>{var K;return(K=Q.current)==null?void 0:K.focus()},0))},[A,se,ce]),o.useEffect(()=>{if(A)return window.addEventListener("resize",ce),window.addEventListener("scroll",ce,!0),()=>{window.removeEventListener("resize",ce),window.removeEventListener("scroll",ce,!0)}},[A,ce]),o.useEffect(()=>{if(x<0||!j.current)return;const K=j.current.children[x];K==null||K.scrollIntoView({block:"nearest"})},[x]);const C=o.useCallback(K=>{r(K),$(!1),T("")},[r]),_=o.useRef(A);_.current=A;const ae=o.useRef(J);ae.current=J;const B=o.useRef(x);B.current=x;const I=o.useRef(d);I.current=d;const M=o.useRef(C);M.current=C,o.useEffect(()=>{function K(Y){var re,z;const S=document.activeElement,H=((re=Z.current)==null?void 0:re.contains(S))??!1,O=((z=D.current)==null?void 0:z.contains(S))??!1;if(!(!H&&!O)){if(!_.current){(Y.key==="Enter"||Y.key===" "||Y.key==="ArrowDown")&&(Y.preventDefault(),$(!0));return}switch(Y.key){case"ArrowDown":Y.preventDefault(),y(de=>Math.min(de+1,ae.current.length-1));break;case"ArrowUp":Y.preventDefault(),y(de=>Math.max(de-1,I.current?-1:0));break;case"Enter":{Y.preventDefault();const de=B.current,he=ae.current;de===-1&&I.current?M.current(""):he[de]&&!he[de].disabled&&M.current(he[de].value);break}case"Escape":Y.preventDefault(),Y.stopPropagation(),$(!1),T("");break}}}return document.addEventListener("keydown",K),()=>document.removeEventListener("keydown",K)},[]);const oe=t.jsxs("div",{ref:D,"data-bonsaif-select-dropdown":"true",className:"rounded-xl shadow-xl overflow-hidden",style:{...W,background:"var(--bg-card)",border:"1px solid var(--border)"},children:[se&&t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",style:{borderBottom:"1px solid var(--border)"},children:[t.jsx(q.HiMagnifyingGlass,{className:"w-3.5 h-3.5 flex-shrink-0",style:{color:"var(--text-muted)"}}),t.jsx("input",{ref:Q,value:N,onChange:K=>{T(K.target.value),y(-1)},placeholder:"Buscar…",className:"min-w-0 flex-1 text-sm bg-transparent outline-none",style:{color:"var(--text-main)"}}),N&&t.jsx("button",{type:"button",onMouseDown:K=>{K.preventDefault(),T("")},children:t.jsx(q.HiXMark,{className:"w-3.5 h-3.5",style:{color:"var(--text-muted)"}})})]}),t.jsxs("ul",{ref:j,role:"listbox",className:"overflow-y-auto",style:{maxHeight:se?220:180,scrollbarWidth:"thin",scrollbarColor:"var(--border) transparent",overscrollBehavior:"contain"},children:[d&&t.jsx("li",{role:"option","aria-selected":e==="",onMouseDown:K=>{K.preventDefault(),C("")},onMouseEnter:()=>y(-1),className:"flex items-center gap-2 px-3 py-2 cursor-pointer text-sm transition-colors",style:{background:x===-1&&!N.trim()?"var(--bg-hover)":"transparent",color:"var(--text-muted)",fontStyle:"italic"},children:d}),J.map((K,Y)=>{const H=Y===x,O=K.value===e;return t.jsxs("li",{role:"option","aria-selected":O,onMouseDown:re=>{re.preventDefault(),K.disabled||C(K.value)},onMouseEnter:()=>!K.disabled&&y(Y),className:"flex items-center gap-2 px-3 py-2 cursor-pointer text-sm transition-colors",style:{background:H?"var(--bg-hover)":O?"color-mix(in srgb, var(--primary) 6%, transparent)":"transparent",color:K.disabled?"var(--text-muted)":"var(--text-main)",cursor:K.disabled?"not-allowed":"pointer",boxShadow:O?"inset 2px 0 0 var(--primary)":void 0},children:[K.color&&t.jsx("span",{className:"flex-shrink-0 w-2.5 h-2.5 rounded-full",style:{background:K.color}}),t.jsxs("span",{className:"min-w-0 flex flex-1 items-baseline gap-1 overflow-hidden",children:[t.jsx(Pt,{className:"min-w-0 flex-1",children:K.label}),K.sublabel&&t.jsx(Pt,{className:"min-w-0 flex-shrink",style:{color:"var(--text-muted)",fontSize:12},children:K.sublabel})]}),K.badge&&t.jsx("span",{className:"text-xs flex-shrink-0",style:{color:"var(--text-muted)"},children:K.badge})]},K.value)}),J.length===0&&t.jsx("li",{className:"px-3 py-4 text-sm text-center",style:{color:"var(--text-muted)"},children:"Sin resultados"})]})]});return t.jsxs("div",{ref:Z,className:`relative ${m||"w-full"}`,style:b,children:[t.jsxs("button",{type:"button",disabled:u,onClick:()=>!u&&$(K=>!K),className:"flex w-full items-center gap-2 rounded-lg text-left text-sm transition-colors focus:outline-none",style:{height:Da(h),padding:Da(v),background:ee?"transparent":"var(--bg-input)",color:te?"var(--text-main)":"var(--text-muted)",border:ee?"1px solid transparent":`1px solid ${U}`,opacity:u?.5:1,cursor:u?"not-allowed":"pointer"},"aria-haspopup":"listbox","aria-expanded":A,"aria-label":s,children:[(te==null?void 0:te.color)&&t.jsx("span",{className:"flex-shrink-0 w-2.5 h-2.5 rounded-full",style:{background:te.color}}),t.jsx("span",{className:"min-w-0 flex flex-1 items-baseline gap-1 overflow-hidden",children:te?t.jsxs(t.Fragment,{children:[t.jsx(Pt,{className:"min-w-0 flex-1",children:te.label}),i&&te.sublabel&&t.jsx(Pt,{className:"min-w-0 flex-shrink",style:{color:"var(--text-muted)",fontSize:12},children:te.sublabel})]}):t.jsx(Pt,{className:"min-w-0 flex-1",children:c})}),te&&d?t.jsx("span",{role:"button",tabIndex:-1,onMouseDown:K=>{K.preventDefault(),K.stopPropagation(),C("")},className:"flex-shrink-0 rounded-full p-0.5 transition-colors hover:bg-black/10",style:{color:"var(--text-muted)"},children:t.jsx(q.HiXMark,{className:"w-3 h-3"})}):t.jsx(q.HiChevronDown,{className:"flex-shrink-0 w-4 h-4 transition-transform",style:{color:"var(--text-muted)",transform:A?"rotate(180deg)":"rotate(0deg)"}})]}),A&&L&&ct.createPortal(oe,document.body)]})}function kn(e){if(e!==void 0)return typeof e=="number"?`${e}px`:e}function ic({value:e,onChange:r,placeholder:n="Buscar...",className:a="",height:s=40,padding:l="0 10px 0 30px",iconLeft:i=10}){return t.jsxs("div",{className:`relative ${a}`,children:[t.jsx(q.HiMagnifyingGlass,{className:"absolute top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-[var(--text-muted)] pointer-events-none",style:{left:kn(i)}}),t.jsx("input",{type:"text",value:e,onChange:c=>r(c.target.value),placeholder:n,className:"w-full rounded-lg border border-[var(--border)] [background:var(--bg-card)] text-sm text-[var(--text-main)] placeholder:text-[var(--text-muted)] outline-none transition-[border-color,box-shadow] focus:border-primary focus:ring-2 focus:ring-primary/20",style:{height:kn(s),padding:kn(l)}})]})}function cc({value:e,onChange:r,options:n,placeholder:a,icon:s,className:l="",height:i=40,padding:c,iconLeft:d=10,searchable:u=!0}){const m=s?n.map((b,f)=>f===0&&!b.color?{...b,sublabel:b.sublabel??void 0}:b):n;return t.jsxs("div",{className:`relative ${l}`,children:[s&&t.jsx("span",{className:"pointer-events-none absolute top-1/2 z-10 -translate-y-1/2 text-[var(--text-muted)]",style:{left:kn(d)},children:s}),t.jsx(ar,{value:e,onChange:r,options:m,placeholder:a,searchable:u,minOptionsForSearch:5,height:i,padding:c??(s?"0 10px 0 30px":"0 10px"),className:"[&>button]:text-sm [&>button]:[background:var(--bg-card)]"})]})}const dc={sm:"24rem",md:"28rem",lg:"32rem",xl:"40rem","2xl":"48rem","4xl":"56rem","5xl":"64rem"},Sn=180,uc="bg-[color-mix(in_srgb,var(--bg-main)_72%,transparent)] backdrop-blur-sm";function Oa({open:e,onClose:r,title:n,subtitle:a,leadingIcon:s,headerActions:l,footer:i,children:c,size:d="md",maxWidth:u,zIndex:m=1e3,closeOnBackdrop:b=!0,closeOnEscape:f=!0,showCloseButton:h=!0,placement:v="center",bodyClassName:k="px-6 py-5",panelClassName:g="",backdropClassName:A=uc,contentClassName:$="p-4",ariaLabel:N,frameless:T=!1,disabled:x=!1}){const[y,L]=o.useState(!1),[w,W]=o.useState(!1),X=o.useRef(null);if(o.useEffect(()=>(e?(X.current&&clearTimeout(X.current),L(!0),requestAnimationFrame(()=>requestAnimationFrame(()=>W(!0)))):(W(!1),X.current=setTimeout(()=>L(!1),Sn+40)),()=>{X.current&&clearTimeout(X.current)}),[e]),o.useEffect(()=>{if(e)return document.body.style.overflow="hidden",()=>{document.body.style.overflow=""}},[e]),o.useEffect(()=>{if(!e||!f)return;const te=ee=>{ee.key==="Escape"&&r()};return window.addEventListener("keydown",te),()=>window.removeEventListener("keydown",te)},[f,r,e]),!y)return null;const Z=n||a||s||l||h,D=u??dc[d],Q=v==="bottom-mobile"?"items-end sm:items-center justify-center p-0 sm:p-4":"items-center justify-center",j=v==="bottom-mobile"?"rounded-t-2xl sm:rounded-2xl":"rounded-2xl",se=w?"translateY(0) scale(1)":v==="bottom-mobile"?"translateY(16px) scale(0.98)":"translateY(10px) scale(0.96)";return ct.createPortal(t.jsxs("div",{role:"dialog","aria-modal":"true","data-bonsaif-overlay":"true","aria-label":N??n,className:`fixed inset-0 flex ${Q} ${$}`,style:{zIndex:m},children:[t.jsx("div",{className:`absolute inset-0 ${A}`,onClick:b?r:void 0,style:{opacity:w?1:0,transition:`opacity ${Sn}ms ease`}}),t.jsxs("div",{className:`relative z-10 flex max-h-[92dvh] w-full flex-col overflow-hidden ${T?"shadow-none":"shadow-2xl"} ${j} ${g}`,style:{maxWidth:D,background:T?"transparent":"var(--bg-card)",border:T?"none":"1px solid var(--border)",opacity:w?1:0,transform:se,transition:`opacity ${Sn}ms ease, transform ${Sn}ms ease`},onClick:te=>te.stopPropagation(),children:[x&&t.jsx("div",{className:"absolute inset-0 z-[1002] cursor-not-allowed rounded-2xl",style:{background:"color-mix(in srgb, var(--bg-card, #ffffff) 60%, transparent)",backdropFilter:"blur(2px)"}}),Z&&t.jsxs("div",{className:"flex flex-shrink-0 items-center justify-between gap-3 px-6 py-4",style:{borderBottom:"1px solid var(--border)"},children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[s&&t.jsx("div",{className:"flex-shrink-0",children:s}),(n||a)&&t.jsxs("div",{className:"min-w-0",children:[n&&t.jsx("h2",{className:"truncate text-base font-semibold",style:{color:"var(--text-main)"},children:n}),a&&t.jsx("p",{className:"truncate text-xs",style:{color:"var(--text-muted)"},children:a})]})]}),t.jsxs("div",{className:"flex flex-shrink-0 items-center gap-2",children:[l,h&&t.jsx(Ue,{variant:"icon",onClick:r,title:"Cerrar",children:t.jsx(q.HiXMark,{className:"h-5 w-5"})})]})]}),t.jsx("div",{className:`min-h-0 flex-1 overflow-y-auto ${k}`,children:c}),i&&t.jsx("div",{className:"flex flex-shrink-0 justify-end gap-2 px-6 py-4",style:{borderTop:"1px solid var(--border)"},children:i})]})]}),document.body)}const fc={danger:{iconBg:"rgba(239,68,68,0.12)",iconColor:"var(--danger)",btnBg:"var(--danger)",btnColor:"#fff"},warning:{iconBg:"rgba(245,158,11,0.12)",iconColor:"var(--warning)",btnBg:"var(--warning)",btnColor:"#fff"},primary:{iconBg:"rgba(59,130,246,0.12)",iconColor:"var(--primary)",btnBg:"var(--primary)",btnColor:"#fff"}};function bc({open:e,title:r,description:n,confirmLabel:a="Confirmar",cancelLabel:s="Cancelar",variant:l="danger",closeOnBackdrop:i=!0,onConfirm:c,onCancel:d}){const u=fc[l];return t.jsx(Oa,{open:e,onClose:d,size:"md",zIndex:9998,showCloseButton:!1,bodyClassName:"p-0",panelClassName:"overflow-visible",ariaLabel:r,closeOnBackdrop:i,children:t.jsxs("div",{className:"relative px-6 pb-6 pt-6",children:[t.jsx(Ue,{variant:"icon",onClick:d,className:"absolute right-3 top-3 h-8 w-8 hover:opacity-70",style:{color:"var(--text-muted)"},"aria-label":"Cancelar",children:t.jsx(q.HiXMark,{className:"h-4 w-4"})}),t.jsxs("div",{className:"flex gap-3 pr-8",children:[t.jsx("div",{className:"mt-0.5 flex h-10 w-10 flex-shrink-0 items-center justify-center rounded-xl",style:{background:u.iconBg},children:t.jsx(q.HiExclamationTriangle,{className:"h-5 w-5",style:{color:u.iconColor}})}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("h2",{className:"text-base font-semibold leading-snug",style:{color:"var(--text-main)"},children:r}),n?t.jsx("div",{className:"mt-1.5 text-sm leading-relaxed",style:{color:"var(--text-muted)"},children:n}):null]})]}),t.jsxs("div",{className:"mt-6 flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",children:[t.jsx(Ue,{variant:"secondary",onClick:d,className:"w-full sm:w-auto sm:min-w-[7.5rem]",style:{background:"var(--bg-input)"},children:s}),t.jsx(Ue,{variant:"danger",onClick:c,className:"w-full sm:w-auto sm:min-w-[7.5rem]",style:{background:u.btnBg,color:u.btnColor,borderColor:"transparent"},children:a})]})]})})}function mc(e){return e?typeof e=="function"?e():e:""}function pc(e){return/^https?:\/\//i.test(e)}function Jo(e,r){try{return new URL(e,r).toString()}catch{return e}}function hc(e,r,n,a=!1){const s=typeof e=="function"?e():e,l=r?r(s):s;if(!l||pc(l))return l;const i=mc(n);return i?Jo(l,i):a&&typeof window<"u"?Jo(l,window.location.origin):l}function gc({url:e,resolveUrl:r,baseUrl:n,useWindowOriginForRelative:a=!1,title:s="Copiar link",copiedTitle:l="Link copiado",icon:i=t.jsx(q.HiLink,{className:"h-3.5 w-3.5"}),...c}){return t.jsx(La,{...c,value:()=>hc(e,r,n,a),title:s,copiedTitle:l,icon:i})}const Ro=32767;function Cn(e){let r=String(e??"");return r=r.split("\0").join(""),r.length<=Ro?r:`${r.slice(0,Ro-1)}…`}const En=[25,50,100,200,500];let Nt={dataTable:{pageSizeOptions:[...En]}};function vc(){if(typeof window>"u")return;const r=window.__BONSAIF_DATA_TABLE_PREFERENCES_ENDPOINT__;return typeof r=="string"&&r.trim().length>0?r.trim().replace(/\/+$/,""):void 0}function Ha(){const e=Nt.dataTable.preferencesEndpoint,r=vc();return e&&e.trim().length>0?e.trim().replace(/\/+$/,""):r}function yc(e){if(!Array.isArray(e))return[...En];const r=Array.from(new Set(e.map(n=>typeof n=="number"?Math.floor(n):Number.NaN).filter(n=>Number.isFinite(n)&&n>0)));return r.length>0?r:[...En]}function es(e){if(typeof e!="string")return;const r=e.trim();if(r)return r.replace(/\/+$/,"")}function xc(e){if(!e||typeof e!="object"||!e.dataTable)return;const r=es(e.dataTable.preferencesEndpoint);Nt={...Nt,dataTable:{...Nt.dataTable,pageSizeOptions:yc(e.dataTable.pageSizeOptions),preferencesEndpoint:r??Nt.dataTable.preferencesEndpoint}}}function wc(){return{dataTable:{pageSizeOptions:[...Nt.dataTable.pageSizeOptions]}}}function Xr(){return[...Nt.dataTable.pageSizeOptions]}function Nc(){Nt={dataTable:{pageSizeOptions:[...En]}}}function kc(e){Nt={...Nt,dataTable:{...Nt.dataTable,preferencesEndpoint:es(e)}}}const Mn=[{value:"equals",label:"Igual a",valueMode:"single"},{value:"notEquals",label:"No es igual a",valueMode:"single"},{value:"greaterThan",label:"Mayor que",valueMode:"single"},{value:"greaterThanOrEqual",label:"Mayor o igual que",valueMode:"single"},{value:"lessThan",label:"Menor que",valueMode:"single"},{value:"lessThanOrEqual",label:"Menor o igual que",valueMode:"single"},{value:"between",label:"Entre",valueMode:"between"},{value:"top10",label:"10 superiores",valueMode:"none"},{value:"bottom10",label:"10 inferiores",valueMode:"none"},{value:"aboveAverage",label:"Sobre promedio",valueMode:"none"},{value:"belowAverage",label:"Bajo promedio",valueMode:"none"}],Sc=Mn.map(e=>({value:e.value,label:e.label})),Cc=12,Ec={layout:!0,filters:!1,sort:!1,bql:!1,pagination:!0},ts={layout:!0,filters:!0,sort:!0,bql:!0,pagination:!0},Mc="bonsaif-ui:datatable:",Tc="[&_button]:h-7 [&_button]:min-h-0 [&_button]:gap-1 [&_button]:px-2 [&_button]:text-xs [&_button_svg]:h-3.5 [&_button_svg]:w-3.5 [&_button[data-icon=true]]:w-7 [&_button[data-icon=true]]:px-0",$c=[],Ac=52;function _t(e){if(!e)return 150;const r=parseInt(e,10);return isNaN(r)||r<=0?150:r}function rs(e){return!!(e&&(Array.isArray(e.columnOrder)&&e.columnOrder.length>0||e.columnWidths&&Object.keys(e.columnWidths).length>0||Array.isArray(e.hiddenColumnKeys)&&e.hiddenColumnKeys.length>0||e.filters&&Object.keys(e.filters).length>0||e.conditionFilters&&Object.keys(e.conditionFilters).length>0||e.sort||typeof e.bql=="string"||Array.isArray(e.bqlHistory)&&e.bqlHistory.length>0||typeof e.pageSize=="number"))}function ns(e){return`${Mc}${e}`}function Tn(e){try{const r=window.localStorage.getItem(ns(e));if(!r)return null;const n=JSON.parse(r);return n&&typeof n=="object"?n:null}catch{return null}}function Lc(e,r){try{window.localStorage.setItem(ns(e),JSON.stringify(r))}catch{}}function Dc(e,r){if(e===!0)return{...ts};if(e===!1)return{layout:!1,filters:!1,sort:!1,bql:!1,pagination:!1};if(r&&e==null)return{...ts};const n={...Ec,...e??{}};return r&&(typeof e!="object"||e.pagination!==!1)&&(n.pagination=!0),n}function as(...e){return e.reduce((r,n)=>({...r,...n??{}}),{})}function Ba(e,r,n){return typeof e!="number"||e<=0?n:Jr(r).includes(e)?e:n}function Kr(e){if(!e||typeof e!="object")return!1;const r=e;return typeof r.key=="string"&&(r.dir==="asc"||r.dir==="desc")}function Gr(e,r){if(!e||typeof e!="object"||Array.isArray(e))return{};const n=Object.entries(e).flatMap(([a,s])=>{if(!r.has(a)||!Array.isArray(s))return[];const l=s.filter(i=>typeof i=="string");return l.length>0?[[a,l]]:[]});return Object.fromEntries(n)}function Zr(e,r){if(!e||typeof e!="object"||Array.isArray(e))return{};const n=new Set(Mn.map(s=>s.value)),a=Object.entries(e).flatMap(([s,l])=>{if(!r.has(s)||!l||typeof l!="object")return[];const i=l;return!i.operator||!n.has(i.operator)?[]:[[s,{operator:i.operator,value:typeof i.value=="string"?i.value:"",valueTo:typeof i.valueTo=="string"?i.valueTo:""}]]});return Object.fromEntries(a)}function pt(e,r){if(or(e))return Ac;const n=e.minWidth??80,a=e.maxWidth??1/0;return Math.min(a,Math.max(n,r))}function Ic(e){const r=window.getComputedStyle(e);return parseFloat(r.paddingLeft)+parseFloat(r.paddingRight)}function or(e){return e.key==="actions"||e.key==="acciones"?!0:typeof e.header=="string"&&e.header.trim().toLowerCase()==="acciones"}function Fa(e){return e.sticky===!0}function os(e){return!(e.reorderable===!1||e.sticky&&e.reorderable!==!0)}function Xt(e,r){const n=r.filter(Fa).map(i=>i.key);if(n.length===0)return e;const a=new Set(n),s=n.filter(i=>e.includes(i)),l=e.filter(i=>!a.has(i));return[...s,...l]}function Oc(e,r){if(r<=7)return Array.from({length:r},(a,s)=>s+1);const n=[1];e>3&&n.push("...");for(let a=Math.max(2,e-1);a<=Math.min(r-1,e+1);a++)n.push(a);return e<r-2&&n.push("..."),n.push(r),n}function Kt(e,r){var i;const n=new Set(r.filter(c=>c.hideable!==!1).map(c=>c.key)),a=Array.from(new Set(e??[])).filter(c=>n.has(c));if(r.filter(c=>!a.includes(c.key)).length>0)return a;const l=(i=r.find(c=>c.hideable!==!1))==null?void 0:i.key;return l?a.filter(c=>c!==l):[]}function Hc(e){return e==null||e===""?"(Vacio)":e instanceof Date?e.toLocaleDateString():String(e)}function gr(e){return e==null||typeof e=="boolean"?"":typeof e=="string"||typeof e=="number"?String(e):Array.isArray(e)?e.map(gr).join(" ").trim():o.isValidElement(e)?gr(e.props.children):""}function $n(e,r){const n=e.filterValue?e.filterValue(r):e.sortKey?r[e.sortKey]:e.cell(r);return typeof n=="string"||typeof n=="number"||typeof n=="boolean"||n===null||n===void 0||n instanceof Date?Hc(n):gr(n).trim()}function Qr(e){const r=e.replace(/,/g,"").trim();if(!r)return null;const n=Number(r);return Number.isFinite(n)?n:null}function vr(e,r){const n=Qr(e),a=Qr(r);return n!==null&&a!==null?n-a:e.localeCompare(r,void 0,{numeric:!0,sensitivity:"base"})}function Jr(e){const r=Array.from(new Set(e.map(n=>Math.floor(n)).filter(n=>Number.isFinite(n)&&n>0)));return r.length>0?r:Xr()}function Bc(e,r,n){var i,c;const a=((i=r.value)==null?void 0:i.trim())??"",s=((c=r.valueTo)==null?void 0:c.trim())??"",l=Mn.find(d=>d.value===r.operator);if((l==null?void 0:l.valueMode)==="single"&&!a||(l==null?void 0:l.valueMode)==="between"&&(!a||!s))return!0;switch(r.operator){case"equals":return e.toLowerCase()===a.toLowerCase();case"notEquals":return e.toLowerCase()!==a.toLowerCase();case"greaterThan":return vr(e,a)>0;case"greaterThanOrEqual":return vr(e,a)>=0;case"lessThan":return vr(e,a)<0;case"lessThanOrEqual":return vr(e,a)<=0;case"between":return vr(e,a)>=0&&vr(e,s)<=0;case"top10":case"bottom10":{const u=n.map(b=>({value:b,number:Qr(b)})).filter(b=>b.number!==null).sort((b,f)=>b.number-f.number).map(b=>b.value);return(r.operator==="top10"?u.slice(-10):u.slice(0,10)).includes(e)}case"aboveAverage":case"belowAverage":{const d=n.map(Qr).filter(b=>b!==null);if(d.length===0)return!1;const u=d.reduce((b,f)=>b+f,0)/d.length,m=Qr(e);return m===null?!1:r.operator==="aboveAverage"?m>u:m<u}default:return!0}}function ss({children:e,className:r="",style:n}){return t.jsx(Yt,{onlyWhenOverflow:!0,className:r,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,...n},children:e})}function ls({columns:e,data:r,getRowId:n,loading:a=!1,skeletonRows:s=8,emptyIcon:l,emptyText:i="Sin resultados",initialEmptyDelay:c=450,onRowClick:d,renderExpandedRow:u,getRowCanExpand:m,expandedRowIds:b,defaultExpandedRowIds:f=[],onExpandedRowIdsChange:h,expandOnRowClick:v=!1,selected:k,onToggleOne:g,onToggleAll:A,getRowSelectable:$,highlightSelected:N=!0,rowClassName:T,getRowCategory:x,stickyHeader:y=!0,pageSize:L=25,pageSizeOptions:w,pageSizeSelectWidth:W=62,pageSizeSelectHeight:X=30,pageSizeSelectPadding:Z="0 7px",totalRows:D,page:Q,onPageChange:j,onPageSizeChange:se,storageKey:te,stickyFirstColumn:ee=!1,bottomOffset:U=0,compact:J=!0,restrictHeight:ce=!0,maxHeight:C,minTableWidth:_,enableColumnVisibility:ae=!0,enableColumnFilters:B=!0,hiddenColumnKeys:I,defaultHiddenColumnKeys:M=$c,onHiddenColumnKeysChange:oe,columnVisibilityLabel:K="Columnas",enableBql:Y=!1,bqlValue:S,defaultBqlValue:H="",onBqlChange:O,bqlDescription:re="Filtra registros con Bonsaif Query Language",bqlPlaceholder:z=`status = activo
|
|
2
|
-
rol IN (admin, employee)`,bqlQuickFilters:de=[],bqlExamples:he=[],bqlSuggestions:ie=[],bqlActiveFilters:ge,bqlError:Me,onQueryChange:$e,persistState:Dt,onPreferencesReady:ut,enableExport:Re=!1,exportFilename:It="datos",onExportCsv:Ct,onExportPdf:Et}){var
|
|
3
|
-
`).map(ne=>ne.trim()).includes(
|
|
4
|
-
${E}`;Mo(P,No.current??void 0),requestAnimationFrame(()=>{const ne=No.current;if(!ne)return;ne.focus();const me=ne.value.length;ne.setSelectionRange(me,me),Mo(ne.value,ne)})}o.useEffect(()=>{Ot(Ye)},[Ye]);const ha=o.useCallback(()=>{const p=wo.current;if(!p)return;const E=p.getBoundingClientRect(),R=12,P=8,ne=Math.min(780,Math.max(320,window.innerWidth-32)),me=Math.max(R,window.innerWidth-ne-R),ke=Math.min(Math.max(R,E.left),me),Ce=E.bottom+P,Pe=window.innerHeight-E.top+P,qe=window.innerHeight-Ce-R,mt=E.top-R-P,et=qe<280&&mt>qe,ve=Math.max(240,et?mt:qe);Cb({position:"fixed",zIndex:1e4,left:ke,top:et?void 0:Ce,bottom:et?Pe:void 0,width:ne,maxWidth:"calc(100vw - 24px)",maxHeight:ve,overflowY:"auto"})},[]);o.useEffect(()=>{if(!ot)return;function p(P){var me,ke;if(Date.now()<Rl.current)return;const ne=P.target;(me=wo.current)!=null&&me.contains(ne)||(ke=Jl.current)!=null&&ke.contains(ne)||(it(!1),qt(!1),Hr(!1))}function E(P){P.key==="Escape"&&(it(!1),qt(!1),Hr(!1))}function R(){ha()}return ha(),document.addEventListener("mousedown",p),window.addEventListener("keydown",E),window.addEventListener("resize",R),window.addEventListener("scroll",R,!0),()=>{document.removeEventListener("mousedown",p),window.removeEventListener("keydown",E),window.removeEventListener("resize",R),window.removeEventListener("scroll",R,!0)}},[ot,ha]);function fi(p){const E=Kt(p,e);Ie||at(E),oe==null||oe(E)}function qb(p){fi(We.includes(p)?We.filter(E=>E!==p):[...We,p])}function Ub(){fi([])}const To=o.useCallback((p=da.current)=>{if(!p)return;const E=p.getBoundingClientRect(),R=Math.min(292,Math.max(240,window.innerWidth-16)),P=Math.max(8,window.innerWidth-R-8),ne=Math.min(Math.max(8,E.right-R),P),me=window.innerHeight-E.bottom,ke=E.bottom+6,Ce=window.innerHeight-E.top+6,qe=me<360&&E.top>me?void 0:ke,mt=qe===void 0?Ce:void 0,et=Math.max(220,qe===void 0?E.top-16:window.innerHeight-ke-8),ve={position:"fixed",zIndex:9999,left:ne,top:qe,bottom:mt,width:R,maxWidth:"calc(100vw - 16px)",maxHeight:et,"--dt-column-menu-max-height":`${et}px`};Mb(ve)},[]);function bi(p,E,R=null){p.preventDefault(),p.stopPropagation();const P=da.current===p.currentTarget&&Ae===E&&ir===R;if(Ke&&P){Ge(!1),Or(null);return}da.current=p.currentTarget,lr(E),Or(R),oa(""),To(p.currentTarget),Ge(!0)}function Vb(p){if(or(p))return;const E=Rt.current;if(!E)return;const P=Array.from(E.querySelectorAll("[data-dt-column-key]")).filter(ne=>ne.dataset.dtColumnKey===p.key).reduce((ne,me)=>{const ke=me.querySelector("[data-dt-autofit-content]"),Ce=ke?ke.scrollWidth:Math.max(me.scrollWidth,me.offsetWidth);return Math.max(ne,Math.ceil(Ce+Ic(me)))},0);P<=0||zr(ne=>({...ne,[p.key]:pt(p,P+12)}))}o.useEffect(()=>{zr(p=>{const E=Object.fromEntries(e.map(R=>[R.key,pt(R,_t(R.width))]));return Object.fromEntries(e.map(R=>[R.key,pt(R,p[R.key]??E[R.key])]))})},[ze,e]),o.useEffect(()=>{Ie||at(p=>Kt(p,e))},[ze,e,Ie]),o.useEffect(()=>{function p(P){var ke,Ce;const ne=P.target,me=P.target;me!=null&&me.closest("[data-bonsaif-select-dropdown='true']")||!((ke=ei.current)!=null&&ke.contains(ne))&&!((Ce=da.current)!=null&&Ce.contains(ne))&&(Ge(!1),Or(null))}function E(P){P.key==="Escape"&&(Ge(!1),Or(null))}function R(){To()}return Ke&&(document.addEventListener("mousedown",p),window.addEventListener("keydown",E),window.addEventListener("resize",R),window.addEventListener("scroll",R,!0)),()=>{document.removeEventListener("mousedown",p),window.removeEventListener("keydown",E),window.removeEventListener("resize",R),window.removeEventListener("scroll",R,!0)}},[Ke,To]);const pn=o.useRef(null);o.useEffect(()=>{function p(R){const P=pn.current;if(!P)return;const ne=R.clientX-P.startX,me=e.find(ke=>ke.key===P.colKey);me&&zr(ke=>({...ke,[P.colKey]:pt(me,P.startWidth+ne)}))}function E(){pn.current&&(pn.current=null,document.body.style.cursor="",document.body.style.userSelect="")}return document.addEventListener("pointermove",p),document.addEventListener("pointerup",E),()=>{document.removeEventListener("pointermove",p),document.removeEventListener("pointerup",E)}},[e]);const hn=o.useRef(null),[mi,$o]=o.useState(null);function Yb(p,E){const R=e.find(P=>P.key===p);if(!R||!os(R)){E.preventDefault();return}hn.current=Pr.indexOf(p),E.dataTransfer.effectAllowed="move"}function Xb(p,E){E.preventDefault(),E.dataTransfer.dropEffect="move";const R=Pr.indexOf(p);mi!==R&&$o(R)}function Kb(p,E){E.preventDefault();const R=hn.current,P=Pr.indexOf(p);R!==null&&R!==P&&_r(ne=>{const me=[...ne],[ke]=me.splice(R,1);return me.splice(P,0,ke),Xt(me,e)}),hn.current=null,$o(null)}function Gb(){hn.current=null,$o(null)}function Zb(p){p.sortKey&&fr(E=>(E==null?void 0:E.key)===p.key?{key:p.key,dir:E.dir==="asc"?"desc":"asc"}:{key:p.key,dir:"asc"})}o.useEffect(()=>{ua(1)},[r]),o.useEffect(()=>{ua(1)},[F,lt]);const Bt=!!(j&&se),er=L!==!1,Ao=o.useMemo(()=>Jr(w??Xr()),[w]),st=Bt?Q??1:Hb,pi=er&&fa<1?typeof L=="number"&&L>0?L:Ao[0]??25:fa,Ft=Bt||er?pi:r.length,Tt=!!k&&!!g&&!!A,Lo=o.useMemo(()=>$?r.filter(p=>$(p)):r,[r,$]),Wr=!!u,hi=o.useMemo(()=>new Set(fe?Array.from(b??[]):be),[fe,b,be]),Qb=(Wr?40:0)+(Tt?40:0),Do=!Ib&&(si||ee),ga=(()=>{if(!Do)return{};let p=Qb;const E={};return wt.forEach((R,P)=>{(Fa(R)||!si&&ee&&P===0)&&(E[R.key]=p,p+=ur[R.key]??pt(R,_t(R.width)))}),E})(),Io=Object.keys(ga),Oo=Io.length>0?Io[Io.length-1]:null,gi=Tt&&Lo.length>0&&Lo.every(p=>k.has(n(p))),Jb=Tt&&k.size>0&&Lo.some(p=>k.has(n(p)))&&!gi,va=o.useMemo(()=>{if(Bt)return r;const p=Object.entries(lt),E=Object.entries(F);return p.length===0&&E.length===0?r:r.filter(R=>p.every(([P,ne])=>{const me=e.find(ke=>ke.key===P);return me?ne.includes($n(me,R)):!0})&&E.every(([P,ne])=>{const me=e.find(Ce=>Ce.key===P);if(!me)return!0;const ke=r.map(Ce=>$n(me,Ce));return Bc($n(me,R),ne,ke)}))},[F,lt,e,r,Bt]),br=o.useMemo(()=>{if(!Xe)return va;const p=e.find(E=>E.key===Xe.key&&E.sortKey);return p!=null&&p.sortKey?[...va].sort((E,R)=>{const P=E[p.sortKey],ne=R[p.sortKey],me=P===ne?0:P==null?1:ne==null||P<ne?-1:1;return Xe.dir==="asc"?me:-me}):va},[va,Xe,e]),vi=o.useMemo(()=>{if(Bt||!er)return br;const p=(st-1)*Ft;return br.slice(p,p+Ft)},[br,Bt,er,st,Ft]),Ut=Bt?D??r.length:br.length,Ho=er?Math.max(1,Math.ceil(Ut/Ft)):1,Rb=Math.min(...Ao),em=er&&(Ut>Ft||Ut>Rb),tm=er?(st-1)*Ft+1:1,rm=er?Math.min(st*Ft,Ut):Ut;function Bo(p){if(a)return;const E=Math.max(1,Math.min(p,Ho));Bt?j(E):ua(E)}function nm(p){a||(te&&(dr.current=te),ba(p),Bt?(se(p),j(1)):(ua(1),se==null||se(p)))}function yi(p){const E=new Set(hi);E.has(p)?E.delete(p):E.add(p);const R=Array.from(E);fe||Te(R),h==null||h(R)}o.useEffect(()=>{$e==null||$e({bql:Ye,filters:lt,conditionFilters:F,sort:Xe,page:st,pageSize:Ft,hiddenColumnKeys:We})},[Ye,lt,F,Xe,st,Ft,We,$e]);const xi=p=>p==="center"?"justify-center text-center":p==="right"?"justify-end text-right":"justify-start text-left",am="color-mix(in srgb, var(--primary) 6%, var(--bg-card))",Fo="linear-gradient(180deg, color-mix(in srgb, var(--bg-input) 90%, var(--bg-card)) 0%, color-mix(in srgb, var(--bg-input) 70%, var(--bg-card)) 100%)",Oe="color-mix(in srgb, var(--border) 62%, var(--bg-card))",mr="color-mix(in srgb, var(--primary) 24%, var(--border))",ya=`inset 0 0 0 1px ${Oe}`,wi=wt.reduce((p,E)=>p+(ur[E.key]??_t(E.width)),(Wr?40:0)+(Tt?40:0)),Ni=typeof _=="number"?_:typeof _=="string"?Number(((Ti=_.match(/^(\d+(?:\.\d+)?)px$/))==null?void 0:Ti[1])??NaN):NaN,gn=Number.isFinite(Ni)?Math.max(wi,Ni,ni):Math.max(wi,ni),xa=_??gn,jr=`${Wr?"40px ":""}${Tt?"40px ":""}${wt.map(p=>`${ur[p.key]??_t(p.width)}px`).join(" ")}`;o.useEffect(()=>{Xe&&We.includes(Xe.key)&&fr(null)},[We,Xe]);function ki(p){return p?typeof p=="string"?{key:p,label:p}:p:null}const wa=()=>t.jsxs("div",{role:"row",className:"grid",style:{gridTemplateColumns:jr,background:Fo,borderBottom:`1px solid ${mr}`},children:[Wr&&t.jsx("div",{role:"columnheader",className:`${J?"px-2 py-1.5":"px-3 py-2.5"} w-10`,style:{borderBottom:`1px solid ${mr}`,borderRight:`1px solid ${Oe}`}}),Tt&&t.jsx("div",{role:"columnheader",className:`${J?"px-2 py-1.5":"px-3 py-2.5"} flex w-10 items-center justify-center`,style:Do?{position:"sticky",left:0,zIndex:12,background:Fo,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)",boxShadow:`inset 0 -1px 0 ${mr}`,borderRight:`1px solid ${Oe}`}:{borderBottom:`1px solid ${mr}`,borderRight:`1px solid ${Oe}`},children:t.jsx(Nn,{size:"sm",checked:gi,indeterminate:Jb,onChange:A,"aria-label":"Seleccionar todos",containerClassName:"items-center",className:"cursor-pointer"})}),wt.map((p,E)=>{const R=(Xe==null?void 0:Xe.key)===p.key,P=!!p.sortKey,ne=or(p),me=ga[p.key],ke=me!==void 0,Ce=p.key===Oo,Pe=os(p),qe=mi===E,et=(ur[p.key]??_t(p.width))<120,ve=Object.prototype.hasOwnProperty.call(lt,p.key)||Object.prototype.hasOwnProperty.call(F,p.key);return t.jsxs("div",{role:"columnheader","data-dt-column-key":p.key,className:`group select-none ${et?"text-left":xi(p.align)}`,style:{...ke?{position:"sticky",left:me,zIndex:12,background:Fo,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)",boxShadow:Ce?`3px 0 6px -2px rgba(0,0,0,0.10), inset 0 -1px 0 ${mr}`:`inset 0 -1px 0 ${mr}`,borderRight:`1px solid ${Oe}`}:{position:"relative",borderBottom:`1px solid ${mr}`,borderRight:`1px solid ${Oe}`},color:R?"var(--primary)":"var(--text-muted)",whiteSpace:"nowrap",transition:"color 0.15s",borderLeft:qe?"2px solid var(--primary)":"2px solid transparent",cursor:"default",padding:ne?J?"7px 6px":"9px 8px":J?"8px 6px 10px":"10px 8px 12px"},onDragOver:Ee=>{(Pe||hn.current!==null)&&Xb(p.key,Ee)},onDrop:Ee=>Kb(p.key,Ee),children:[t.jsxs("div",{className:`flex min-w-0 items-center gap-1 ${ne?"justify-center":et?"justify-start":p.align==="center"?"justify-center":p.align==="right"?"justify-end":"justify-start"}`,children:[Pe?t.jsx("span",{draggable:!0,onDragStart:Ee=>{Ee.stopPropagation(),Yb(p.key,Ee)},onDragEnd:Ee=>{Ee.stopPropagation(),Gb()},onClick:Ee=>Ee.stopPropagation(),title:"Arrastrar para mover columna","aria-label":"Arrastrar para mover columna",className:`absolute left-0 top-0 z-10 inline-flex h-full w-3 shrink-0 rounded-sm transition-colors duration-150 hover:bg-[var(--primary)]/15 ${qe?"bg-[var(--primary)]/20":""}`,style:{cursor:"grab"}}):null,ne?t.jsx("span",{className:"inline-flex h-5 w-5 items-center justify-center rounded-md text-[var(--text-muted)]",title:"Acciones","aria-label":"Acciones",children:t.jsx(q.HiCog6Tooth,{className:"h-3.5 w-3.5"})}):t.jsx(ss,{className:"min-w-0 flex-1",children:t.jsx("span",{"data-dt-autofit-content":!0,className:`inline-flex max-w-full items-center font-semibold uppercase tracking-wider ${J?"text-[11px]":"text-xs"}`,children:t.jsx("span",{className:"min-w-0 truncate",children:p.header})})}),P&&t.jsx("button",{type:"button","aria-label":`Ordenar por ${String(p.header)}`,title:"Ordenar",onClick:Ee=>{Ee.stopPropagation(),Zb(p)},"data-dt-sort-button":!0,className:`absolute -bottom-2 left-1/2 z-20 inline-flex h-4 w-4 -translate-x-1/2 items-center justify-center rounded-full bg-[var(--primary)] text-[var(--primary-fg)] shadow-[0_1px_3px_rgba(15,23,42,0.22)] transition-[opacity,transform] duration-150 hover:scale-105 focus:scale-105 focus:opacity-100 focus:outline-none ${R?"opacity-100":"opacity-0 group-hover:opacity-100 group-focus-within:opacity-100"}`,style:{bottom:"-0.5rem",top:"auto"},children:R?Xe.dir==="asc"?t.jsx(q.HiChevronUp,{className:"h-3 w-3"}):t.jsx(q.HiChevronDown,{className:"h-3 w-3"}):t.jsx(q.HiChevronUpDown,{className:"h-3 w-3"})}),B&&!ne&&_b(p)&&t.jsx("button",{type:"button","aria-haspopup":"menu","aria-expanded":Ke&&ir===p.key,"aria-label":`Filtrar ${String(p.header)}`,title:"Filtrar",onClick:Ee=>bi(Ee,"filter",p.key),className:`inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-sm bg-transparent text-[var(--text-muted)] opacity-0 transition-[opacity,color,background-color] duration-150 hover:bg-[var(--bg-card)] hover:text-[var(--primary)] focus:bg-[var(--bg-card)] focus:text-[var(--primary)] focus:opacity-100 group-hover:opacity-100 ${Ke&&Ae==="filter"&&ir===p.key?"bg-[var(--bg-card)] text-[var(--primary)] opacity-100":ve?"text-[var(--primary)] opacity-100":""}`,children:ve?t.jsx(q.HiFunnel,{className:"h-3.5 w-3.5"}):t.jsx(q.HiEllipsisVertical,{className:"h-3.5 w-3.5"})})]}),!ne&&t.jsx("span",{role:"separator","aria-orientation":"vertical",title:"Arrastrar para redimensionar. Doble click para autoajustar",onPointerDown:Ee=>{Ee.preventDefault(),Ee.stopPropagation(),pn.current={colKey:p.key,startX:Ee.clientX,startWidth:ur[p.key]??150},document.body.style.cursor="col-resize",document.body.style.userSelect="none"},onDoubleClick:Ee=>{Ee.preventDefault(),Ee.stopPropagation(),pn.current=null,document.body.style.cursor="",document.body.style.userSelect="",Vb(p)},onClick:Ee=>Ee.stopPropagation(),className:"absolute top-0 flex h-full items-center justify-center opacity-0 transition-opacity duration-200 hover:opacity-100",style:{right:0,width:12,cursor:"col-resize",zIndex:6,transform:"translateX(50%)"},children:t.jsxs("span",{style:{display:"flex",gap:4,alignItems:"center",height:"calc(100% - 8px)"},children:[t.jsx("span",{style:{width:2,height:"100%",borderRadius:2,background:"var(--primary)",display:"block"}}),t.jsx("span",{style:{width:2,height:"100%",borderRadius:2,background:"var(--primary)",display:"block"}})]})})]},p.key)})]}),Na=()=>{if(!Ke||typeof document>"u"||Ae==="visibility"&&!ae||Ae==="filter"&&!B)return null;const p=e.find(ve=>ve.key===ir),E=Pb(),R=p?Object.prototype.hasOwnProperty.call(lt,p.key):!1,P=p?F[p.key]:void 0,ne=Mn.find(ve=>ve.value===(P==null?void 0:P.operator)),me=p?lt[p.key]??[]:[],ke=Jt.trim().toLowerCase(),Ce=ke?E.filter(ve=>ve.label.toLowerCase().includes(ke)):E,Pe=p&&E.length>0&&(!R||me.length===E.length),qe=p&&R&&me.length>0&&me.length<E.length,mt=We.length,et=()=>{p&&(Eo(p.key),ci(p.key))};return ct.createPortal(t.jsx("div",{ref:ei,role:"menu",className:"overflow-hidden rounded-lg border p-1 shadow-xl",style:{...Eb,borderColor:"var(--border)",background:"var(--bg-card)"},children:Ae==="visibility"?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-[var(--border)] px-2 py-1.5",children:[t.jsx("span",{className:"min-w-0 truncate text-xs font-semibold uppercase text-[var(--text-muted)]",children:mt>0?`${wt.length} de ${e.length} visibles`:`${e.length} visibles`}),t.jsx("button",{type:"button",onClick:Ub,disabled:mt===0,className:"rounded px-1.5 py-0.5 text-xs font-medium text-[var(--primary)] transition-colors hover:bg-[var(--bg-input)] disabled:opacity-40",children:"Mostrar todas"})]}),t.jsx("div",{className:"max-h-72 overflow-auto py-1",children:oi.map(ve=>{const Ee=!We.includes(ve.key),xe=!(ve.hideable!==!1)||Ee&&wt.length<=1;return t.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":Ee,disabled:xe,onClick:()=>qb(ve.key),className:"flex w-full min-w-0 items-center gap-2 rounded-md px-2.5 py-1.5 text-left transition-colors hover:bg-[var(--bg-input)] disabled:cursor-not-allowed disabled:opacity-50",style:{color:"var(--text-main)"},children:[t.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center rounded border",style:{borderColor:Ee?"var(--primary)":"var(--border)",background:Ee?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:Ee&&t.jsx(q.HiCheck,{className:"h-3 w-3"})}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:ve.header})]},ve.key)})})]}):p?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-[var(--border)] px-2 py-1.5",children:[t.jsxs("span",{className:"min-w-0 truncate text-xs font-semibold uppercase text-[var(--text-muted)]",children:["Filtrar ",p.header]}),t.jsx("button",{type:"button",onClick:et,disabled:!R&&!P,className:"rounded px-1.5 py-0.5 text-xs font-medium text-[var(--primary)] transition-colors hover:bg-[var(--bg-input)] disabled:opacity-40",children:"Limpiar"})]}),p.sortKey&&t.jsxs("div",{className:"grid grid-cols-2 gap-1 border-b border-[var(--border)] p-1",children:[t.jsxs("button",{type:"button",onClick:()=>fr({key:p.key,dir:"asc"}),className:"flex min-w-0 items-center justify-between rounded-md px-2 py-1.5 text-left text-sm transition-colors hover:bg-[var(--bg-input)]",style:{color:"var(--text-main)"},children:[t.jsxs("span",{className:"flex min-w-0 items-center gap-1.5 truncate",children:[t.jsx(q.HiChevronUp,{className:"h-4 w-4 shrink-0 text-[var(--primary)]"}),t.jsx("span",{className:"truncate",children:"Ascendente"})]}),(Xe==null?void 0:Xe.key)===p.key&&Xe.dir==="asc"&&t.jsx(q.HiCheck,{className:"h-4 w-4 shrink-0 text-[var(--primary)]"})]}),t.jsxs("button",{type:"button",onClick:()=>fr({key:p.key,dir:"desc"}),className:"flex min-w-0 items-center justify-between rounded-md px-2 py-1.5 text-left text-sm transition-colors hover:bg-[var(--bg-input)]",style:{color:"var(--text-main)"},children:[t.jsxs("span",{className:"flex min-w-0 items-center gap-1.5 truncate",children:[t.jsx(q.HiChevronDown,{className:"h-4 w-4 shrink-0 text-[var(--primary)]"}),t.jsx("span",{className:"truncate",children:"Descendente"})]}),(Xe==null?void 0:Xe.key)===p.key&&Xe.dir==="desc"&&t.jsx(q.HiCheck,{className:"h-4 w-4 shrink-0 text-[var(--primary)]"})]})]}),t.jsxs("div",{className:"border-b border-[var(--border)] p-2",children:[t.jsxs("div",{className:"grid grid-cols-[minmax(0,1.05fr)_minmax(0,0.95fr)] gap-2",children:[t.jsx(ar,{value:(P==null?void 0:P.operator)??"",onChange:ve=>{if(!ve){ci(p.key);return}ma(p.key,{operator:ve,value:(P==null?void 0:P.value)??"",valueTo:(P==null?void 0:P.valueTo)??""})},options:Sc,placeholder:"Opcion",emptyLabel:"Sin condicion",ariaLabel:"Operador de filtro",searchable:!1,height:34,padding:"0 9px",dropdownMinWidth:260,className:"min-w-0 [&>button]:rounded-md [&>button]:text-sm [&>button]:font-medium"}),(ne==null?void 0:ne.valueMode)!=="none"?t.jsx("input",{value:(P==null?void 0:P.value)??"",onChange:ve=>{P&&ma(p.key,{...P,value:ve.target.value})},disabled:!P,placeholder:"Valor",className:"min-w-0 rounded-md border px-2 py-1.5 text-sm outline-none transition-colors placeholder:text-[var(--text-muted)] focus:border-[var(--primary)] disabled:opacity-50",style:{borderColor:"var(--border)",background:"var(--bg-input)",color:"var(--text-main)"}}):t.jsx("div",{className:"min-h-8 rounded-md border px-2 py-1.5 text-sm text-[var(--text-muted)]",style:{borderColor:"var(--border)",background:"var(--bg-input)"},children:"Automatico"})]}),(ne==null?void 0:ne.valueMode)==="between"&&t.jsx("input",{value:(P==null?void 0:P.valueTo)??"",onChange:ve=>{P&&ma(p.key,{...P,valueTo:ve.target.value})},placeholder:"Valor final",className:"mt-2 w-full rounded-md border px-2 py-1.5 text-xs outline-none transition-colors placeholder:text-[var(--text-muted)] focus:border-[var(--primary)]",style:{borderColor:"var(--border)",background:"var(--bg-input)",color:"var(--text-main)"}})]}),t.jsx("div",{className:"border-b border-[var(--border)] p-2",children:t.jsxs("div",{className:"flex items-center gap-1 rounded-md border px-2 py-1.5 text-sm",style:{borderColor:"var(--border)",background:"var(--bg-input)"},children:[t.jsx(q.HiMagnifyingGlass,{className:"h-4 w-4 shrink-0 text-[var(--text-muted)]"}),t.jsx("input",{value:Jt,onChange:ve=>oa(ve.target.value),placeholder:"Buscar",className:"min-w-0 flex-1 bg-transparent text-sm outline-none placeholder:text-[var(--text-muted)]",style:{color:"var(--text-main)"}})]})}),t.jsxs("div",{className:"overflow-auto py-1",style:{maxHeight:"max(96px, calc(var(--dt-column-menu-max-height, 520px) - 236px))"},children:[t.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":qe?"mixed":!!Pe,onClick:()=>{p&&(Pe&&!R?ii(p.key,[]):Eo(p.key))},className:"flex w-full min-w-0 items-center gap-2 rounded-md px-2.5 py-1.5 text-left transition-colors hover:bg-[var(--bg-input)]",style:{color:"var(--text-main)"},children:[t.jsxs("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center rounded border",style:{borderColor:Pe||qe?"var(--primary)":"var(--border)",background:Pe||qe?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:[qe&&t.jsx(q.HiMinus,{className:"h-3 w-3"}),Pe&&!qe&&t.jsx(q.HiCheck,{className:"h-3 w-3"})]}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:"Seleccionar todo"})]}),Ce.map(ve=>{const Ee=!R||me.includes(ve.value);return t.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":Ee,onClick:()=>zb(p.key,ve.value,E.map(Ne=>Ne.value),R),className:"flex w-full min-w-0 items-center gap-2 rounded-md px-2.5 py-1.5 text-left transition-colors hover:bg-[var(--bg-input)]",style:{color:"var(--text-main)"},children:[t.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center rounded border",style:{borderColor:Ee?"var(--primary)":"var(--border)",background:Ee?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:Ee&&t.jsx(q.HiCheck,{className:"h-3 w-3"})}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:ve.label})]},ve.value)}),Ce.length===0&&t.jsx("div",{className:"px-3 py-3 text-sm text-[var(--text-muted)]",children:"Sin valores"})]})]}):null}),document.body)};o.useEffect(()=>{if(!mn)return;function p(E){ko.current&&!ko.current.contains(E.target)&&ca.current&&!ca.current.contains(E.target)&&ia(!1)}return document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[mn]);function Si(p,E){if(p.filterValue){const R=p.filterValue(E);return R==null||R===""?"":Cn(R)}return Cn(gr(p.cell(E)))}function Ci(p){return`"${Cn(p).replace(/"/g,'""')}"`}function ka(p){return Cn(p).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function Ei(){return Bt&&Ut>br.length&&Ma.toast.warning(`Exportando ${br.length.toLocaleString("es-MX")} de ${Ut.toLocaleString("es-MX")} (página actual). Usa exportación completa si está disponible.`),br}function om(){const p=wt.filter(Pe=>!or(Pe)),E=Ei(),R=p.map(Pe=>Ci(gr(Pe.header))).join(","),P=E.map(Pe=>p.map(qe=>Ci(Si(qe,Pe))).join(",")).join(`
|
|
1
|
+
(function(V,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("react"),require("react/jsx-runtime"),require("react-icons/hi2"),require("react-dom"),require("recharts"),require("overlayscrollbars"),require("sonner"),require("overlayscrollbars-react"),require("react-day-picker"),require("react-day-picker/dist/style.css"),require("react-icons/fi")):typeof define=="function"&&define.amd?define(["exports","react","react/jsx-runtime","react-icons/hi2","react-dom","recharts","overlayscrollbars","sonner","overlayscrollbars-react","react-day-picker","react-day-picker/dist/style.css","react-icons/fi"],o):(V=typeof globalThis<"u"?globalThis:V||self,o(V.BonsaifUI={},V.React,V.jsxRuntime,V.ReactIconsHi2,V.ReactDOM,V.Recharts,V.OverlayScrollbarsGlobal,V.Sonner,V.OverlayScrollbarsReact,V.ReactDayPicker,V.ReactDayPickerStyles,V.ReactIconsFi))})(this,(function(V,o,t,q,ct,Se,Ea,Ma,zo,Ta,cm,Li){"use strict";"use client";function Vt(...e){return e.filter(Boolean).join(" ")}function Di({variant:e="primary",className:r,type:n="button",children:a,...s}){return t.jsx("button",{className:Vt("bonsaif-ui-button",`bonsaif-ui-button--${e}`,r),type:n,...s,children:a})}function Wo({value:e,onChange:r,placeholder:n,className:a="",autoFocus:s=!1,forceExpanded:l=!1,onEscape:i,size:c="default",inputTabIndex:d}){const u=o.useRef(null),[m,b]=o.useState(!1),f=l||m||e.trim().length>0,g=c==="sm"?"h-9 rounded-md":"h-10 rounded-lg",v=a||"w-48 max-w-full sm:w-64 lg:w-72";o.useEffect(()=>{var h;s&&((h=u.current)==null||h.focus())},[s]);const k=()=>{var h;b(!0),(h=u.current)==null||h.focus()};return t.jsxs("div",{className:`relative min-w-0 max-w-full flex-shrink-0 overflow-visible transition-[width] duration-200 ease-out ${f?v:"w-24 sm:w-28"}`,onMouseDown:h=>{f||(h.preventDefault(),k())},children:[t.jsx(q.HiMagnifyingGlass,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 pointer-events-none transition-colors duration-200",style:{color:"var(--text-muted)",left:"var(--page-header-control-icon-left, 12px)"}}),t.jsx("input",{ref:u,type:"text",tabIndex:d,"aria-label":n,value:e,onChange:h=>r(h.target.value),onKeyDown:h=>{h.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:h=>{b(!0),h.currentTarget.style.borderColor="var(--primary)",h.currentTarget.style.boxShadow="0 0 0 3px rgba(59,130,246,0.12)"},onBlur:h=>{b(!1),h.currentTarget.style.borderColor="var(--border)",h.currentTarget.style.boxShadow="none"}}),e&&t.jsx("button",{type:"button",onClick:()=>r(""),className:"absolute right-2 top-1/2 flex !h-6 !w-6 -translate-y-1/2 items-center justify-center rounded-full !p-0 leading-none transition-colors hover:bg-black/5",style:{color:"var(--text-muted)",right:"var(--page-header-control-padding-x, 8px)"},"aria-label":"Limpiar búsqueda",children:t.jsx(q.HiXMark,{className:"h-3.5 w-3.5 flex-shrink-0"})})]})}const jo=o.createContext({});let qo=0;const Uo="bonsaif-ui:hide-tooltips";function yn(e=700){qo=Date.now()+e}function Ii(){return Date.now()>qo}function xn(e){if(typeof document>"u")return!1;const r=Array.from(document.querySelectorAll('[data-bonsaif-overlay="true"], [role="menu"], [role="dialog"][aria-modal="true"], [aria-hidden="false"] [aria-modal="true"]'));return e&&r.some(n=>n.contains(e))?!1:r.length>0}function Oi(e){var a;const r=Array.from(e.querySelectorAll("*")).filter(s=>{var l;return s.scrollWidth>s.clientWidth&&!!((l=s.textContent)!=null&&l.trim())&&s.tagName.toLowerCase()!=="svg"&&!s.closest("svg")});return(e.scrollWidth>e.clientWidth||r.length>0)&&(((a=r[0])==null?void 0:a.textContent)??e.textContent??"").trim()||null}function Yt({children:e,content:r,onlyWhenOverflow:n=!1,interactive:a=!1,followCursor:s=!0,placement:l="bottom",showArrow:i=!1,className:c="",tooltipClassName:d="",style:u,tooltipStyle:m,as:b="div"}){const f=o.useRef(null),g=o.useRef(null),v=o.useRef(null),k=o.useRef(!1),[h,A]=o.useState(null),[$,N]=o.useState("");o.useEffect(()=>{const D=f.current;D&&(D.querySelectorAll("[title]").forEach(Q=>{const j=Q.getAttribute("title");j&&(Q.getAttribute("aria-label")||Q.setAttribute("aria-label",j),Q.removeAttribute("title"))}),D.querySelectorAll("svg title").forEach(Q=>Q.remove()))}),o.useLayoutEffect(()=>{if(!h)return;const D=g.current;if(!D)return;const Q=12,j=14,se=D.getBoundingClientRect(),te=window.innerWidth-se.width-Q,ee=window.innerHeight-se.height-Q;let U=h.mouseX+j,J=h.mouseY+j,ce,C;if(!s&&f.current){const _=f.current.getBoundingClientRect(),ae=_.left+_.width/2,B=_.top+_.height/2;l==="top"?(U=ae-se.width/2,J=_.top-se.height-j,C=se.height-1):l==="left"?(U=_.left-se.width-j,J=B-se.height/2,ce=se.width-1):l==="right"?(U=_.right+j,J=B-se.height/2,ce=-7):(U=ae-se.width/2,J=_.bottom+j,C=-7)}if(s&&(U>te&&(U=h.mouseX-se.width-j),J>ee&&(J=h.mouseY-se.height-j)),U=Math.min(Math.max(Q,U),Math.max(Q,te)),J=Math.min(Math.max(Q,J),Math.max(Q,ee)),!s&&f.current){const _=f.current.getBoundingClientRect(),ae=_.left+_.width/2,B=_.top+_.height/2;l==="top"||l==="bottom"?ce=Math.min(Math.max(14,ae-U),se.width-14):C=Math.min(Math.max(14,B-J),se.height-14)}(Math.abs(U-h.x)>.5||Math.abs(J-h.y)>.5||ce!==h.arrowX||C!==h.arrowY)&&A(_=>_&&{..._,x:U,y:J,arrowX:ce,arrowY:C})},[s,l,h]);const T=()=>{v.current&&(window.clearTimeout(v.current),v.current=null)},x=(D,Q)=>{if(!Ii()||k.current)return;const j=f.current;if(j&&!xn(j)){if(n){const se=Oi(j);if(!se)return;N(se)}!n&&!r||A({mouseX:D,mouseY:Q,x:D+14,y:Q+14})}},y=()=>{const D=f.current;if(!D)return;const Q=D.getBoundingClientRect();x(Q.left+Q.width/2,Q.bottom)},L=()=>{T(),A(null)},w=()=>{if(!a){L();return}T(),v.current=window.setTimeout(()=>A(null),120)},W=()=>{yn(),k.current=!0,L()},X=()=>{k.current=!1};o.useEffect(()=>{if(!h)return;if(xn(f.current)){A(null);return}const D=()=>A(null),Q=()=>{yn(),k.current=!0,A(null)};document.addEventListener("pointerdown",Q,!0),document.addEventListener("click",Q,!0),document.addEventListener("scroll",D,!0),window.addEventListener("blur",D),document.addEventListener("visibilitychange",D),document.addEventListener("keydown",D,!0);const j=new MutationObserver(()=>{xn(f.current)&&A(null)});return j.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["role","aria-modal","aria-hidden","class"]}),()=>{document.removeEventListener("pointerdown",Q,!0),document.removeEventListener("click",Q,!0),document.removeEventListener("scroll",D,!0),window.removeEventListener("blur",D),document.removeEventListener("visibilitychange",D),document.removeEventListener("keydown",D,!0),j.disconnect()}},[h]),o.useEffect(()=>{const D=()=>yn(),Q=()=>{yn(),k.current=!0,A(null)};return document.addEventListener("pointerdown",D,!0),document.addEventListener("click",D,!0),document.addEventListener("keydown",D,!0),window.addEventListener(Uo,Q),()=>{document.removeEventListener("pointerdown",D,!0),document.removeEventListener("click",D,!0),document.removeEventListener("keydown",D,!0),window.removeEventListener(Uo,Q)}},[]);const Z=n?$:r;return t.jsxs(t.Fragment,{children:[t.jsx(b,{ref:D=>{f.current=D},className:c,style:u,onMouseEnter:D=>{T(),X(),s?x(D.clientX,D.clientY):y()},onMouseMove:D=>{h&&s&&x(D.clientX,D.clientY)},onMouseDown:W,onClick:W,onMouseLeave:()=>{X(),w()},onFocus:y,onBlur:L,children:e}),h&&Z&&!xn(f.current)?ct.createPortal(t.jsxs("div",{ref:g,role:"tooltip",className:d,onMouseEnter:a?T:void 0,onMouseLeave:a?w:void 0,style:{position:"fixed",top:h.y,left:h.x,zIndex:9999,background:"var(--bg-card)",border:"1px solid var(--border)",borderRadius:6,padding:"5px 10px",fontSize:12,color:"var(--text-main)",boxShadow:"0 4px 16px rgba(0,0,0,0.35)",pointerEvents:a?"auto":"none",maxWidth:"min(420px, calc(100vw - 24px))",whiteSpace:"normal",lineHeight:1.6,overflowWrap:"anywhere",...m},children:[i&&t.jsx("span",{"aria-hidden":"true",style:{position:"absolute",width:12,height:12,background:(m==null?void 0:m.background)??"var(--bg-card)",borderLeft:l==="right"?(m==null?void 0:m.border)??"1px solid var(--border)":void 0,borderTop:l==="bottom"||l==="right"?(m==null?void 0:m.border)??"1px solid var(--border)":void 0,borderRight:l==="left"?(m==null?void 0:m.border)??"1px solid var(--border)":void 0,borderBottom:l==="top"||l==="left"?(m==null?void 0:m.border)??"1px solid var(--border)":void 0,transform:"rotate(45deg)",left:h.arrowX===void 0?void 0:h.arrowX-6,top:h.arrowY===void 0?void 0:h.arrowY-6,zIndex:-1}}),Z]}),document.body):null]})}function Vo(e){if(e!==void 0)return typeof e=="number"?`${e}px`:e}const Hi="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",Bi={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"},Fi="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",Pi={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"},_i={xs:"h-8 w-8",sm:"h-9 w-9",md:"h-10 w-10",lg:"h-10 w-10"},zi={primary:{background:"var(--bg-card)"},secondary:{background:"var(--bg-card)"},danger:{background:"var(--bg-card)"},ghost:{},icon:{}};function $a(e){return typeof e=="string"||typeof e=="number"?String(e):Array.isArray(e)?e.map($a).join(" ").trim():o.isValidElement(e)?$a(e.props.children):""}function Wi(e){return o.Children.toArray(e).find(o.isValidElement)??null}function Ue({variant:e="primary",size:r="md",loading:n=!1,icon:a,tooltip:s,iconOnly:l,height:i,padding:c,children:d,className:u="",disabled:m,style:b,...f}){const g=o.useContext(jo),v=l??g.iconOnly??e==="icon",k=g.compact??!1,h=g.headerAction??!1,A=h&&r==="md"?"sm":k&&!h&&r==="md"?"xs":r,$=e==="icon"||v,N=h&&$,T=$a(d),x=s??f.title??f["aria-label"]??(v?T:void 0),y=x?void 0:f.title,L=f["aria-label"]??(typeof x=="string"?x:T||void 0),w=n?null:a??(v?Wi(d):null),W=t.jsxs("button",{...f,title:y,"aria-label":L,"data-variant":e,"data-size":A,"data-icon":$?"true":void 0,disabled:m||n,className:`${Hi} ${N?Fi:Bi[e]} ${$?_i[A]:Pi[A]} ${k&&!$?"px-2.5":""} ${u}`,style:{...zi[e],height:Vo(i),padding:Vo(c),...b,...h&&!$?{height:"var(--page-header-control-height, 34px)",padding:"0 var(--page-header-control-padding-x, 10px)",borderRadius:"8px"}:null,...N?{width:"var(--page-header-control-height, 40px)",height:"var(--page-header-control-height, 40px)",padding:0,background:"var(--bg-card)",borderRadius:"8px"}:null},children:[n?t.jsx("span",{className:"h-3.5 w-3.5 animate-spin rounded-full border-2 border-current border-t-transparent"}):w,!v&&d]});return x?t.jsx(Yt,{as:"span",content:x,className:"inline-flex shrink-0",children:W}):W}const dt={background:"color-mix(in srgb, var(--text-muted) 26%, var(--bg-input))"};function wn({rows:e=8,columns:r=7,showToolbar:n=!0,showPagination:a=!0,compact:s=!1,className:l=""}){const i=Math.max(3,Math.min(r,12)),c=Math.max(3,Math.min(e,20)),d=s?"px-2 py-2":"px-3 py-2.5",u=s?"px-2 py-2":"px-3 py-3";return t.jsxs("div",{className:`w-full min-w-0 overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${l}`,"aria-busy":"true","aria-label":"Cargando tabla",children:[n&&t.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-[var(--border)] px-3 py-2",children:[t.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[t.jsx("div",{className:"h-7 w-14 shrink-0 animate-pulse rounded-md",style:dt}),t.jsx("div",{className:"h-7 max-w-md flex-1 animate-pulse rounded-md",style:dt})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[t.jsx("div",{className:"h-7 w-7 animate-pulse rounded-md",style:dt}),t.jsx("div",{className:"h-7 w-7 animate-pulse rounded-md",style:dt})]})]}),t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("div",{className:"min-w-full",style:{display:"grid",gridTemplateColumns:`repeat(${i}, minmax(96px, 1fr))`},children:[Array.from({length:i}).map((m,b)=>t.jsx("div",{className:`${u} border-b border-[var(--border)]`,style:{background:"color-mix(in srgb, var(--bg-input) 55%, transparent)"},children:t.jsx("div",{className:"h-3 animate-pulse rounded-md",style:{...dt,width:`${48+b*17%40}%`}})},`h-${b}`)),Array.from({length:c}).map((m,b)=>Array.from({length:i}).map((f,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:{...dt,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:dt}),t.jsx("div",{className:"h-7 w-14 animate-pulse rounded-md",style:dt})]}),t.jsx("div",{className:"flex items-center gap-1",children:Array.from({length:4}).map((m,b)=>t.jsx("div",{className:"h-7 w-7 animate-pulse rounded-md",style:dt},b))}),t.jsx("div",{className:"h-3 w-16 animate-pulse rounded-md",style:dt})]})]})}function ji({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 qi({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 Yo({variant:e="page",title:r="Cargando...",description:n,logoSrc:a,logoAlt:s,appearance:l="card",rows:i=6,columns:c=7,children:d,className:u=""}){if(e==="table")return t.jsx(wn,{rows:i,columns:c,className:u});if(e==="sections")return t.jsx(Ui,{rows:i});if(e==="cards")return t.jsx(Vi,{rows:i});const m=s||(typeof r=="string"?r:"Aplicación"),b=l==="bare",f=t.jsxs("div",{className:`flex flex-col items-center text-center ${b?"gap-5":"gap-3"}`,children:[a?t.jsx(qi,{logoSrc:a,logoAlt:m}):null,t.jsx(ji,{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 Ui({rows:e}){return t.jsx(wn,{rows:e,columns:7})}function Vi({rows:e}){return t.jsx("div",{className:"grid gap-3 md:grid-cols-2 xl:grid-cols-3",children:Array.from({length:e}).map((r,n)=>t.jsxs("div",{className:"rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-4",children:[t.jsx("div",{className:"h-4 w-2/3 animate-pulse rounded-md",style:dt}),t.jsx("div",{className:"mt-3 h-3 w-full animate-pulse rounded-md",style:dt}),t.jsx("div",{className:"mt-2 h-3 w-4/5 animate-pulse rounded-md",style:dt})]},n))})}function Xo(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 Ko(e){return e.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().trim()}function Yi(e){return[e.label,Xo(e.service),e.description,e.service].filter(Boolean).join(" ")}function Xi(e){return typeof e=="function"?e:e.default}function Ki(e,r){return t.jsx("div",{className:"flex min-h-[220px] items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-6 text-center",children:t.jsxs("div",{className:"max-w-md",children:[t.jsx("p",{className:"text-sm font-semibold text-[var(--text-main)]",children:"No se pudo cargar este modulo"}),t.jsx("p",{className:"mt-1 text-xs text-[var(--text-muted)]",children:e.message}),t.jsx(Ue,{className:"mt-4",height:36,padding:"0 14px",onClick:r,children:"Reintentar"})]})})}function Gi({parentPanel:e,parentPanelComponent:r,renderParentPanel:n,parent:a,context:s,links:l,moduleRegistry:i,loadModule:c,activeService:d,initialService:u,onActiveServiceChange:m,canAccess:b,keepAlive:f=!0,title:g,subtitle:v,emptyState:k,loadingState:h,errorState:A=Ki,renderTabLabel:$,searchableTabs:N="auto",tabsSearchThreshold:T=6,tabsSearchPlaceholder:x="Buscar modulo...",tabsSearchValue:y,onTabsSearchChange:L,emptySearchState:w,showTabCount:W=!0,className:X="",parentClassName:Z="",contentClassName:D="",tabsClassName:Q=""}){var Et;const j=o.useMemo(()=>l.filter(le=>!le.hidden&&((b==null?void 0:b(le,s))??!0)),[b,s,l]),se=(Et=j.find(le=>!le.disabled))==null?void 0:Et.service,[te,ee]=o.useState(u??se??""),[U,J]=o.useState({}),[ce,C]=o.useState({}),[_,ae]=o.useState(""),[B,I]=o.useState(!1),E=o.useRef(ce),oe=o.useRef(0),K=y??_,Y=Ko(K),S=N===!0||N==="auto"&&j.length>=T,H=S&&K.trim().length>0,O=o.useMemo(()=>Y?j.filter(le=>Ko(Yi(le)).includes(Y)):j,[Y,j]),re=d??te,z=j.find(le=>le.service===re)??j.find(le=>!le.disabled);o.useEffect(()=>{!z&&se&&ee(se)},[se,z]),o.useEffect(()=>{E.current=ce},[ce]);const de=le=>{le.disabled||(d||ee(le.service),m==null||m(le.service,le))},he=le=>{y===void 0&&ae(le),L==null||L(le)},ie=(le,Fe)=>{const ze=O.filter(Ve=>!Ve.disabled),ft=ze.findIndex(Ve=>Ve.service===Fe.service);ft<0||((le.key==="ArrowRight"||le.key==="ArrowDown")&&(le.preventDefault(),de(ze[(ft+1)%ze.length])),(le.key==="ArrowLeft"||le.key==="ArrowUp")&&(le.preventDefault(),de(ze[(ft-1+ze.length)%ze.length])),le.key==="Home"&&(le.preventDefault(),de(ze[0])),le.key==="End"&&(le.preventDefault(),de(ze[ze.length-1])))},ge=o.useCallback(()=>{if(!z)return;const le=z.service,Fe=E.current[le];if(Fe!=null&&Fe.loading||Fe!=null&&Fe.component&&f)return;const ze=(i==null?void 0:i[le])??c;if(!ze){C(Ve=>({...Ve,[le]:{loading:!1,error:new Error(`No module loader found for service "${le}".`)}}));return}const ft=++oe.current;C(Ve=>({...Ve,[le]:{...Ve[le],loading:!0,error:void 0}})),ze(z,s).then(Ve=>{if(ft!==oe.current&&!f)return;const Mt=Xi(Ve);C(bt=>({...bt,[le]:{component:Mt,loading:!1}}))}).catch(Ve=>{const Mt=Ve instanceof Error?Ve:new Error(String(Ve));C(bt=>({...bt,[le]:{...bt[le],loading:!1,error:Mt}}))})},[s,f,c,i,z]);o.useEffect(ge,[ge]);const Me=z?U[z.service]??null:null,$e=z?ce[z.service]:void 0,Dt=$e==null?void 0:$e.component,ut=le=>{z&&J(Fe=>({...Fe,[z.service]:le}))},Re=()=>{z&&J(le=>({...le,[z.service]:null}))},It={context:s,parent:a,links:l,visibleLinks:j,filteredLinks:O,selectedLink:z,selectedService:z==null?void 0:z.service,activeItemId:Me,tabsSearch:K,onSelectService:de,onOpenDetail:ut,onBackToList:Re},Ct=n?n(It):r?t.jsx(r,{...It}):e;return t.jsxs("section",{className:`grid min-h-[520px] gap-4 lg:grid-cols-[minmax(260px,360px)_minmax(0,1fr)] ${X}`,children:[t.jsx("aside",{className:`min-w-0 rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-4 ${Z}`,children:Ct}),t.jsxs("div",{className:`relative min-w-0 overflow-visible rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${D}`,children:[(g||v||S||W)&&t.jsx("div",{className:"relative border-b border-[var(--border)] px-4 py-3",children:t.jsxs("div",{className:"flex min-w-0 items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[g&&t.jsx("h2",{className:"truncate text-sm font-semibold text-[var(--text-main)]",children:g}),v&&t.jsx("p",{className:"mt-1 line-clamp-2 text-xs text-[var(--text-muted)]",children:v})]}),(S||W)&&t.jsxs("div",{className:"flex min-w-0 flex-shrink-0 items-center justify-end gap-2",children:[W&&t.jsxs("span",{className:"hidden text-xs font-semibold text-[var(--text-muted)] transition-opacity duration-200 sm:inline",children:[O.length," / ",j.length]}),S&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:`origin-right overflow-hidden transition-[width,opacity,transform] duration-200 ease-out ${B?"w-[min(20rem,44vw)] translate-x-0 opacity-100":"w-0 translate-x-2 opacity-0"}`,"aria-hidden":!B,children:t.jsx(Wo,{value:K,onChange:he,placeholder:x,className:"w-full",autoFocus:B,forceExpanded:!0,onEscape:()=>I(!1),size:"sm",inputTabIndex:B?0:-1})}),t.jsx("button",{type:"button","aria-label":B?"Cerrar busqueda":"Buscar tabs","aria-expanded":B,onClick:()=>{B&&K&&he(""),I(le=>!le)},className:`inline-flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-md border transition-all duration-200 hover:scale-[1.03] active:scale-95 ${B||H?"border-[var(--primary)] bg-[var(--bg-input)] text-[var(--text-main)] shadow-sm":"border-[var(--border)] text-[var(--text-muted)] hover:bg-[var(--bg-input)] hover:text-[var(--text-main)]"}`,children:t.jsx("span",{className:"grid h-4 w-4 place-items-center transition-transform duration-200",children:B||H?t.jsx(q.HiXMark,{className:"h-4 w-4"}):t.jsx(q.HiMagnifyingGlass,{className:"h-4 w-4"})})})]})]})]})}),t.jsx("div",{role:"tablist","aria-label":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 ${Q}`,children:O.length>0?O.map(le=>{const Fe=le.service===(z==null?void 0:z.service);return t.jsx("button",{type:"button",role:"tab","aria-selected":Fe,disabled:le.disabled,onClick:()=>de(le),onKeyDown:ze=>ie(ze,le),className:`inline-flex h-9 min-w-max items-center gap-2 rounded-md border px-3 text-xs font-semibold transition-all duration-200 disabled:cursor-not-allowed disabled:opacity-50 ${Fe?"border-[var(--primary)] bg-[var(--bg-card)] text-[var(--text-main)] shadow-sm":"border-transparent text-[var(--text-muted)] hover:bg-[var(--bg-card)] hover:text-[var(--text-main)]"}`,children:$?$(le,Fe):t.jsxs(t.Fragment,{children:[le.icon,t.jsx("span",{children:le.label??Xo(le.service)}),le.badge&&t.jsx("span",{className:"rounded-full bg-[var(--bg-input)] px-1.5 py-0.5 text-[10px] text-[var(--text-muted)]",children:le.badge})]})},le.service)}):t.jsx("div",{className:"flex min-h-9 flex-1 items-center rounded-md border border-dashed border-[var(--border)] px-3 text-xs text-[var(--text-muted)]",children:w??"No hay modulos que coincidan con la busqueda."})}),(z==null?void 0:z.description)&&t.jsx("div",{className:"border-b border-[var(--border)] px-4 py-2 text-xs text-[var(--text-muted)]",children:z.description}),t.jsxs("div",{className:"min-h-[420px] p-4",children:[!z&&(k??t.jsx("div",{className:"flex min-h-[220px] items-center justify-center rounded-lg border border-dashed border-[var(--border)] text-sm text-[var(--text-muted)]",children:"No hay modulos disponibles."})),z&&($e==null?void 0:$e.loading)&&(h??t.jsx(Yo,{title:"Cargando modulo..."})),z&&($e==null?void 0:$e.error)&&A($e.error,ge),z&&Dt&&!($e!=null&&$e.loading)&&!($e!=null&&$e.error)&&t.jsx(Dt,{context:s,parent:a,link:z,activeItemId:Me,onOpenDetail:ut,onBackToList:Re})]})]})]})}const Zi={info:{color:"#2563eb",background:"rgba(59, 130, 246, 0.1)",border:"rgba(59, 130, 246, 0.24)",icon:t.jsx(q.HiInformationCircle,{className:"h-5 w-5"})},success:{color:"#047857",background:"rgba(16, 185, 129, 0.1)",border:"rgba(16, 185, 129, 0.24)",icon:t.jsx(q.HiCheckCircle,{className:"h-5 w-5"})},warning:{color:"#b45309",background:"rgba(245, 158, 11, 0.12)",border:"rgba(245, 158, 11, 0.26)",icon:t.jsx(q.HiExclamationTriangle,{className:"h-5 w-5"})},danger:{color:"var(--danger)",background:"var(--danger-bg)",border:"color-mix(in srgb, var(--danger) 20%, var(--border))",icon:t.jsx(q.HiExclamationCircle,{className:"h-5 w-5"})},neutral:{color:"var(--text-secondary)",background:"var(--bg-input)",border:"var(--border)",icon:t.jsx(q.HiInformationCircle,{className:"h-5 w-5"})}};function Qi({variant:e="info",title:r,children:n,icon:a,action:s,onDismiss:l,className:i=""}){const c=Zi[e];return t.jsxs("div",{role:e==="danger"||e==="warning"?"alert":"status",className:`flex items-start gap-3 rounded-lg border px-3 py-3 ${i}`,style:{background:c.background,borderColor:c.border},children:[t.jsx("div",{className:"mt-0.5 shrink-0",style:{color:c.color},children:a??c.icon}),t.jsxs("div",{className:"min-w-0 flex-1",children:[r&&t.jsx("div",{className:"text-sm font-semibold text-[var(--text-main)]",children:r}),n&&t.jsx("div",{className:"mt-0.5 text-sm leading-5 text-[var(--text-secondary)]",children:n}),s&&t.jsx("div",{className:"mt-3",children:s})]}),l&&t.jsx(Ue,{variant:"icon",size:"xs","aria-label":"Cerrar alerta",onClick:l,className:"-mr-1 -mt-1",children:t.jsx(q.HiXMark,{className:"h-4 w-4"})})]})}const Go=["Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre"],Ji=["Ene","Feb","Mar","Abr","May","Jun","Jul","Ago","Sep","Oct","Nov","Dic"],Ri=["lu","ma","mi","ju","vi","sá","do"],Zo=6;function Aa(e,r,n){return`${e}-${String(r).padStart(2,"0")}-${String(n).padStart(2,"0")}`}function ec(){const e=new Date;return Aa(e.getFullYear(),e.getMonth()+1,e.getDate())}function Qo(e){const[r,n,a]=e.split("-").map(Number);return{year:r,month:n,day:a}}function tc(e){if(!e)return"Seleccionar fecha";const{year:r,month:n,day:a}=Qo(e);return!r||!n||!a?"Seleccionar fecha":`${String(a).padStart(2,"0")} ${Go[n-1]} ${r}`}function rc({value:e,onChange:r,minDate:n,displayMode:a="inline",className:s=""}){const l=ec(),c=Qo(e||l),d=a==="popover",[u,m]=o.useState(!1),b=o.useRef(null),[f,g]=o.useState({horizontal:"left",vertical:"bottom"}),[v,k]=o.useState(c.year),[h,A]=o.useState(c.month),[$,N]=o.useState("days"),T=16,[x,y]=o.useState(0),L=v-7+x,w=Array.from({length:T},(ee,U)=>L+U);o.useEffect(()=>{if(!d||!u||!b.current)return;const ee=b.current.getBoundingClientRect(),U=8,J=280,ce=340,C=ee.left+J>window.innerWidth-U,_=ee.right-J>=U,ae=ee.bottom+8+ce>window.innerHeight-U,B=ee.top-8-ce>=U;g({horizontal:C&&_?"right":"left",vertical:ae&&B?"top":"bottom"})},[d,u]),o.useEffect(()=>{if(!d||!u)return;function ee(J){b.current&&(b.current.contains(J.target)||m(!1))}function U(J){J.key==="Escape"&&m(!1)}return document.addEventListener("mousedown",ee),document.addEventListener("keydown",U),()=>{document.removeEventListener("mousedown",ee),document.removeEventListener("keydown",U)}},[d,u]);function W(){h===1?(k(ee=>ee-1),A(12)):A(ee=>ee-1)}function X(){h===12?(k(ee=>ee+1),A(1)):A(ee=>ee+1)}const Z=(new Date(v,h-1,1).getDay()+6)%7,D=new Date(v,h,0).getDate(),Q=[...Array(Z).fill(null),...Array.from({length:D},(ee,U)=>U+1)];for(;Q.length<Zo*7;)Q.push(null);const j=Q.slice(0,Zo*7);function se(ee){const U=Aa(v,h,ee);n&&U<n||(r(U),d&&m(!1))}const te=t.jsx("div",{className:`bonsaif-calendar bonsaif-calendar-picker ${s}`.trim(),children:t.jsxs("div",{className:"bonsaif-cal-shell",children:[t.jsx("div",{className:"bonsaif-cal-toolbar",children:$==="days"?t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn",onClick:W,"aria-label":"Mes anterior",children:t.jsx(q.HiChevronLeft,{size:16})}),t.jsxs("button",{type:"button",className:"bonsaif-cal-title-btn",onClick:()=>{N("years"),y(0)},children:[t.jsxs("span",{className:"bonsaif-cal-title",children:[Go[h-1]," ",v]}),t.jsx(q.HiChevronDown,{size:13})]}),t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn",onClick:X,"aria-label":"Mes siguiente",children:t.jsx(q.HiChevronRight,{size:16})})]}):t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn",onClick:()=>y(ee=>ee-T),"aria-label":"Años anteriores",children:t.jsx(q.HiChevronLeft,{size:16})}),t.jsx("button",{type:"button",className:"bonsaif-cal-title-btn",onClick:()=>N("days"),children:t.jsxs("span",{className:"bonsaif-cal-title",children:[w[0]," – ",w[w.length-1]]})}),t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn",onClick:()=>y(ee=>ee+T),"aria-label":"Años siguientes",children:t.jsx(q.HiChevronRight,{size:16})})]})}),$==="years"?t.jsxs("div",{className:"bonsaif-cal-picker-years",children:[t.jsx("div",{className:"bonsaif-cal-picker-months",children:Ji.map((ee,U)=>{const J=U+1===h;return t.jsx("button",{type:"button",className:`bonsaif-cal-pill-btn${J?" is-active":""}`,onClick:()=>A(U+1),children:ee},ee)})}),t.jsx("div",{className:"bonsaif-cal-picker-year-grid",children:w.map(ee=>{const U=ee===v,J=ee===new Date().getFullYear();return t.jsx("button",{type:"button",className:`bonsaif-cal-pill-btn${U?" is-active":""}${J&&!U?" is-today":""}`,onClick:()=>{k(ee),N("days")},children:ee},ee)})})]}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"bonsaif-multi-weekdays bonsaif-cal-picker-weekdays",children:Ri.map(ee=>t.jsx("div",{className:"bonsaif-multi-weekday",children:ee},ee))}),t.jsx("div",{className:"bonsaif-cal-picker-days",children:j.map((ee,U)=>{if(ee===null)return t.jsx("div",{className:"bonsaif-multi-day bonsaif-multi-day-hidden"},U);const J=Aa(v,h,ee),ce=J===e,C=J===l,_=!!(n&&J<n);return t.jsx("div",{className:`bonsaif-multi-day${ce?" bonsaif-multi-day-selected":""}${C?" bonsaif-multi-day-today":""}${_?" bonsaif-multi-day-disabled":""}`,children:t.jsx("button",{type:"button",className:"bonsaif-multi-day-btn",disabled:_,"aria-pressed":ce,onClick:()=>!_&&se(ee),children:ee})},U)})})]})]})});return d?t.jsxs("div",{ref:b,className:`relative w-full ${s}`.trim(),children:[t.jsxs("button",{type:"button",onClick:()=>m(ee=>!ee),className:"bonsaif-cal-trigger","data-open":u?"true":"false",children:[t.jsxs("span",{className:"inline-flex items-center gap-2 min-w-0",children:[t.jsx(q.HiCalendarDays,{className:"w-4 h-4 text-[var(--text-muted)]"}),t.jsx("span",{className:"truncate",children:tc(e)})]}),t.jsx(q.HiChevronDown,{className:`w-4 h-4 text-[var(--text-muted)] transition-transform ${u?"rotate-180":""}`})]}),u&&t.jsx("div",{className:"absolute z-50",style:{...f.horizontal==="left"?{left:0}:{right:0},...f.vertical==="bottom"?{top:"calc(100% + 8px)"}:{bottom:"calc(100% + 8px)"}},children:te})]}):te}const nc={sm:"h-4 w-4",md:"h-5 w-5"};function ac(e,r){if(typeof e=="function"){e(r);return}e&&(e.current=r)}const Nn=o.forwardRef(function({label:r,description:n,error:a,size:s="md",indeterminate:l=!1,className:i="",containerClassName:c="",disabled:d,...u},m){const b=o.useRef(null);return o.useEffect(()=>{b.current&&(b.current.indeterminate=l)},[l]),t.jsxs("label",{className:`group inline-flex items-start gap-2.5 ${d?"cursor-not-allowed opacity-60":"cursor-pointer"} ${c}`,children:[t.jsxs("span",{className:"relative mt-0.5 inline-flex shrink-0",children:[t.jsx("input",{...u,ref:f=>{b.current=f,ac(m,f)},type:"checkbox",disabled:d,"aria-checked":l?"mixed":u["aria-checked"],"aria-invalid":!!a||u["aria-invalid"],className:`peer ${nc[s]} appearance-none rounded border border-[var(--border)] bg-[var(--bg-input)] transition-colors checked:border-[var(--primary)] checked:bg-[var(--primary)] focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--primary)]/40 ${i}`}),t.jsx(q.HiCheck,{className:"pointer-events-none absolute left-1/2 top-1/2 h-3.5 w-3.5 -translate-x-1/2 -translate-y-1/2 scale-75 text-[var(--primary-fg)] opacity-0 transition peer-checked:scale-100 peer-checked:opacity-100 peer-aria-checked:mixed:scale-100 peer-aria-checked:mixed:opacity-100"})]}),(r||n||a)&&t.jsxs("span",{className:"min-w-0",children:[r&&t.jsx("span",{className:"block text-sm font-medium leading-5 text-[var(--text-main)]",children:r}),n&&!a&&t.jsx("span",{className:"block text-xs leading-5 text-[var(--text-muted)]",children:n}),a&&t.jsx("span",{className:"block text-xs leading-5 text-[var(--danger)]",children:a})]})]})});function Jo(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 oc(e){var r;if((r=navigator.clipboard)!=null&&r.writeText){await navigator.clipboard.writeText(e);return}Jo(e)}function sc(e){return typeof e=="function"?e():e}function La({value:e,resetDelay:r=2e3,title:n,copiedTitle:a="Copiado",copiedLabel:s,icon:l=t.jsx(q.HiClipboardDocument,{size:14}),copiedIcon:i=t.jsx(q.HiCheck,{size:14}),stopPropagation:c=!0,onCopied:d,onCopyError:u,className:m="",style:b,children:f,onClick:g,type:v="button",...k}){const[h,A]=o.useState(!1),$=o.useRef(null);o.useEffect(()=>()=>{$.current&&window.clearTimeout($.current)},[]);function N(x){A(!0),d==null||d(x),$.current&&window.clearTimeout($.current),$.current=window.setTimeout(()=>{A(!1),$.current=null},r)}async function T(x){var L;if(c&&x.stopPropagation(),g==null||g(x),x.defaultPrevented)return;const y=sc(e);if(y)try{await oc(y),N(y)}catch(w){try{Jo(y),N(y)}catch(W){u==null||u(W,y);return}(L=navigator.clipboard)!=null&&L.writeText||u==null||u(w,y)}}return t.jsxs("button",{...k,type:v,onClick:T,title:h?a:n,"aria-label":k["aria-label"]??(h?a:n),"data-copied":h?"true":void 0,className:`relative inline-flex h-7 shrink-0 items-center justify-center gap-1.5 rounded-md transition-all duration-200 ${f?"min-w-7 px-2":"w-7"} ${m}`,style:{cursor:"pointer",background:h?"rgba(22,163,74,0.15)":"var(--bg-card)",border:h?"1px solid rgba(22,163,74,0.4)":"1px solid var(--border)",color:h?"#16a34a":"var(--text-secondary)",boxShadow:h?"0 0 0 3px rgba(22,163,74,0.12)":"none",...b},children:[t.jsx("span",{className:"inline-flex items-center justify-center transition-all duration-150",style:{transform:h?"scale(1.15)":"scale(1)"},children:h?i:l}),f&&t.jsx("span",{className:"text-xs font-semibold leading-none",children:h?s??f:f})]})}function lc({code:e,children:r,title:n="Codigo",language:a,copyLabel:s="Copiar",copiedLabel:l="Copiado",className:i="",style:c,onCopied:d}){const u=(e??r??"").trim();return t.jsxs("div",{className:`overflow-hidden rounded-lg border ${i}`,style:{borderColor:"rgba(148, 163, 184, 0.22)",background:"#0f172a",color:"#e2e8f0",...c},children:[t.jsxs("div",{className:"flex min-h-9 items-center justify-between gap-3 border-b px-3 py-1.5",style:{borderColor:"rgba(148, 163, 184, 0.18)",background:"#111827",color:"#94a3b8"},children:[t.jsx("span",{className:"min-w-0 truncate text-[11px] font-black uppercase tracking-[0.08em]",children:n}),t.jsx(La,{value:u,title:"Copiar codigo",copiedTitle:"Codigo copiado",copiedLabel:l,onCopied:d,className:"h-7 min-w-[72px] px-2",style:{background:"#182235",border:"1px solid rgba(148, 163, 184, 0.28)",color:"#f8fafc"},children:s})]}),t.jsx("pre",{className:"m-0 overflow-x-auto p-3 text-xs leading-6",style:{background:"#0f172a",color:"#e2e8f0",fontFamily:'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace'},children:t.jsx("code",{className:a?`language-${a}`:void 0,children:u})})]})}function Pt({children:e,className:r="",style:n,as:a="span",followCursor:s=!1,placement:l="top"}){return t.jsx(Yt,{onlyWhenOverflow:!0,as:a,followCursor:s,placement:l,showArrow:!s,className:r,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",minWidth:0,...n},children:e})}function Da(e){if(e!==void 0)return typeof e=="number"?`${e}px`:e}function Ia(e){return e.normalize("NFD").replace(new RegExp("\\p{M}","gu"),"").toLowerCase()}function ic(e,r){if(!r.trim())return!0;const n=Ia(r);return Ia(e.label).includes(n)||!!(e.sublabel&&Ia(e.sublabel).includes(n))}function ar({value:e,onChange:r,options:n,status:a="default",ariaLabel:s,triggerVariant:l="default",showSelectedSublabel:i=!0,placeholder:c="Seleccionar…",emptyLabel:d,disabled:u=!1,className:m="",style:b,dropdownMinWidth:f,height:g=40,padding:v="0 10px",searchable:k=!0,minOptionsForSearch:h=6}){const[A,$]=o.useState(!1),[N,T]=o.useState(""),[x,y]=o.useState(-1),[L,w]=o.useState(!1),[W,X]=o.useState({}),Z=o.useRef(null),D=o.useRef(null),Q=o.useRef(null),j=o.useRef(null),se=k&&n.length>=h,te=n.find(K=>K.value===e)??null,ee=l==="ghost",U=a==="error"?"var(--danger)":A?"var(--primary)":"var(--border)",J=se&&N.trim()?n.filter(K=>ic(K,N)):n,ce=o.useCallback(()=>{const K=Z.current;if(!K)return;const Y=K.getBoundingClientRect(),S=se?272:212,H=window.innerHeight-Y.bottom,O=H<S&&Y.top>H;X({position:"fixed",left:Y.left,top:O?void 0:Y.bottom+4,bottom:O?window.innerHeight-Y.top+4:void 0,width:Y.width,minWidth:Da(f),zIndex:9999})},[f,se]);o.useEffect(()=>w(!0),[]),o.useEffect(()=>{if(!A)return;function K(Y){var H,O;const S=Y.target;!((H=Z.current)!=null&&H.contains(S))&&!((O=D.current)!=null&&O.contains(S))&&($(!1),T(""))}return document.addEventListener("mousedown",K),()=>document.removeEventListener("mousedown",K)},[A]),o.useEffect(()=>{A&&(y(-1),ce(),se&&setTimeout(()=>{var K;return(K=Q.current)==null?void 0:K.focus()},0))},[A,se,ce]),o.useEffect(()=>{if(A)return window.addEventListener("resize",ce),window.addEventListener("scroll",ce,!0),()=>{window.removeEventListener("resize",ce),window.removeEventListener("scroll",ce,!0)}},[A,ce]),o.useEffect(()=>{if(x<0||!j.current)return;const K=j.current.children[x];K==null||K.scrollIntoView({block:"nearest"})},[x]);const C=o.useCallback(K=>{r(K),$(!1),T("")},[r]),_=o.useRef(A);_.current=A;const ae=o.useRef(J);ae.current=J;const B=o.useRef(x);B.current=x;const I=o.useRef(d);I.current=d;const E=o.useRef(C);E.current=C,o.useEffect(()=>{function K(Y){var re,z;const S=document.activeElement,H=((re=Z.current)==null?void 0:re.contains(S))??!1,O=((z=D.current)==null?void 0:z.contains(S))??!1;if(!(!H&&!O)){if(!_.current){(Y.key==="Enter"||Y.key===" "||Y.key==="ArrowDown")&&(Y.preventDefault(),$(!0));return}switch(Y.key){case"ArrowDown":Y.preventDefault(),y(de=>Math.min(de+1,ae.current.length-1));break;case"ArrowUp":Y.preventDefault(),y(de=>Math.max(de-1,I.current?-1:0));break;case"Enter":{Y.preventDefault();const de=B.current,he=ae.current;de===-1&&I.current?E.current(""):he[de]&&!he[de].disabled&&E.current(he[de].value);break}case"Escape":Y.preventDefault(),Y.stopPropagation(),$(!1),T("");break}}}return document.addEventListener("keydown",K),()=>document.removeEventListener("keydown",K)},[]);const oe=t.jsxs("div",{ref:D,"data-bonsaif-select-dropdown":"true",className:"rounded-xl shadow-xl overflow-hidden",style:{...W,background:"var(--bg-card)",border:"1px solid var(--border)"},children:[se&&t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",style:{borderBottom:"1px solid var(--border)"},children:[t.jsx(q.HiMagnifyingGlass,{className:"w-3.5 h-3.5 flex-shrink-0",style:{color:"var(--text-muted)"}}),t.jsx("input",{ref:Q,value:N,onChange:K=>{T(K.target.value),y(-1)},placeholder:"Buscar…",className:"min-w-0 flex-1 text-sm bg-transparent outline-none",style:{color:"var(--text-main)"}}),N&&t.jsx("button",{type:"button",onMouseDown:K=>{K.preventDefault(),T("")},children:t.jsx(q.HiXMark,{className:"w-3.5 h-3.5",style:{color:"var(--text-muted)"}})})]}),t.jsxs("ul",{ref:j,role:"listbox",className:"overflow-y-auto",style:{maxHeight:se?220:180,scrollbarWidth:"thin",scrollbarColor:"var(--border) transparent",overscrollBehavior:"contain"},children:[d&&t.jsx("li",{role:"option","aria-selected":e==="",onMouseDown:K=>{K.preventDefault(),C("")},onMouseEnter:()=>y(-1),className:"flex items-center gap-2 px-3 py-2 cursor-pointer text-sm transition-colors",style:{background:x===-1&&!N.trim()?"var(--bg-hover)":"transparent",color:"var(--text-muted)",fontStyle:"italic"},children:d}),J.map((K,Y)=>{const H=Y===x,O=K.value===e;return t.jsxs("li",{role:"option","aria-selected":O,onMouseDown:re=>{re.preventDefault(),K.disabled||C(K.value)},onMouseEnter:()=>!K.disabled&&y(Y),className:"flex items-center gap-2 px-3 py-2 cursor-pointer text-sm transition-colors",style:{background:H?"var(--bg-hover)":O?"color-mix(in srgb, var(--primary) 6%, transparent)":"transparent",color:K.disabled?"var(--text-muted)":"var(--text-main)",cursor:K.disabled?"not-allowed":"pointer",boxShadow:O?"inset 2px 0 0 var(--primary)":void 0},children:[K.color&&t.jsx("span",{className:"flex-shrink-0 w-2.5 h-2.5 rounded-full",style:{background:K.color}}),t.jsxs("span",{className:"min-w-0 flex flex-1 items-baseline gap-1 overflow-hidden",children:[t.jsx(Pt,{className:"min-w-0 flex-1",children:K.label}),K.sublabel&&t.jsx(Pt,{className:"min-w-0 flex-shrink",style:{color:"var(--text-muted)",fontSize:12},children:K.sublabel})]}),K.badge&&t.jsx("span",{className:"text-xs flex-shrink-0",style:{color:"var(--text-muted)"},children:K.badge})]},K.value)}),J.length===0&&t.jsx("li",{className:"px-3 py-4 text-sm text-center",style:{color:"var(--text-muted)"},children:"Sin resultados"})]})]});return t.jsxs("div",{ref:Z,className:`relative ${m||"w-full"}`,style:b,children:[t.jsxs("button",{type:"button",disabled:u,onClick:()=>!u&&$(K=>!K),className:"flex w-full items-center gap-2 rounded-lg text-left text-sm transition-colors focus:outline-none",style:{height:Da(g),padding:Da(v),background:ee?"transparent":"var(--bg-input)",color:te?"var(--text-main)":"var(--text-muted)",border:ee?"1px solid transparent":`1px solid ${U}`,opacity:u?.5:1,cursor:u?"not-allowed":"pointer"},"aria-haspopup":"listbox","aria-expanded":A,"aria-label":s,children:[(te==null?void 0:te.color)&&t.jsx("span",{className:"flex-shrink-0 w-2.5 h-2.5 rounded-full",style:{background:te.color}}),t.jsx("span",{className:"min-w-0 flex flex-1 items-baseline gap-1 overflow-hidden",children:te?t.jsxs(t.Fragment,{children:[t.jsx(Pt,{className:"min-w-0 flex-1",children:te.label}),i&&te.sublabel&&t.jsx(Pt,{className:"min-w-0 flex-shrink",style:{color:"var(--text-muted)",fontSize:12},children:te.sublabel})]}):t.jsx(Pt,{className:"min-w-0 flex-1",children:c})}),te&&d?t.jsx("span",{role:"button",tabIndex:-1,onMouseDown:K=>{K.preventDefault(),K.stopPropagation(),C("")},className:"flex-shrink-0 rounded-full p-0.5 transition-colors hover:bg-black/10",style:{color:"var(--text-muted)"},children:t.jsx(q.HiXMark,{className:"w-3 h-3"})}):t.jsx(q.HiChevronDown,{className:"flex-shrink-0 w-4 h-4 transition-transform",style:{color:"var(--text-muted)",transform:A?"rotate(180deg)":"rotate(0deg)"}})]}),A&&L&&ct.createPortal(oe,document.body)]})}function kn(e){if(e!==void 0)return typeof e=="number"?`${e}px`:e}function cc({value:e,onChange:r,placeholder:n="Buscar...",className:a="",height:s=40,padding:l="0 10px 0 30px",iconLeft:i=10}){return t.jsxs("div",{className:`relative ${a}`,children:[t.jsx(q.HiMagnifyingGlass,{className:"absolute top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-[var(--text-muted)] pointer-events-none",style:{left:kn(i)}}),t.jsx("input",{type:"text",value:e,onChange:c=>r(c.target.value),placeholder:n,className:"w-full rounded-lg border border-[var(--border)] [background:var(--bg-card)] text-sm text-[var(--text-main)] placeholder:text-[var(--text-muted)] outline-none transition-[border-color,box-shadow] focus:border-primary focus:ring-2 focus:ring-primary/20",style:{height:kn(s),padding:kn(l)}})]})}function dc({value:e,onChange:r,options:n,placeholder:a,icon:s,className:l="",height:i=40,padding:c,iconLeft:d=10,searchable:u=!0}){const m=s?n.map((b,f)=>f===0&&!b.color?{...b,sublabel:b.sublabel??void 0}:b):n;return t.jsxs("div",{className:`relative ${l}`,children:[s&&t.jsx("span",{className:"pointer-events-none absolute top-1/2 z-10 -translate-y-1/2 text-[var(--text-muted)]",style:{left:kn(d)},children:s}),t.jsx(ar,{value:e,onChange:r,options:m,placeholder:a,searchable:u,minOptionsForSearch:5,height:i,padding:c??(s?"0 10px 0 30px":"0 10px"),className:"[&>button]:text-sm [&>button]:[background:var(--bg-card)]"})]})}const uc={sm:"24rem",md:"28rem",lg:"32rem",xl:"40rem","2xl":"48rem","4xl":"56rem","5xl":"64rem"},Sn=180,fc="bg-[color-mix(in_srgb,var(--bg-main)_72%,transparent)] backdrop-blur-sm";function Oa({open:e,onClose:r,title:n,subtitle:a,leadingIcon:s,headerActions:l,footer:i,children:c,size:d="md",maxWidth:u,zIndex:m=1e3,closeOnBackdrop:b=!0,closeOnEscape:f=!0,showCloseButton:g=!0,placement:v="center",bodyClassName:k="px-6 py-5",panelClassName:h="",backdropClassName:A=fc,contentClassName:$="p-4",ariaLabel:N,frameless:T=!1,disabled:x=!1}){const[y,L]=o.useState(!1),[w,W]=o.useState(!1),X=o.useRef(null);if(o.useEffect(()=>(e?(X.current&&clearTimeout(X.current),L(!0),requestAnimationFrame(()=>requestAnimationFrame(()=>W(!0)))):(W(!1),X.current=setTimeout(()=>L(!1),Sn+40)),()=>{X.current&&clearTimeout(X.current)}),[e]),o.useEffect(()=>{if(e)return document.body.style.overflow="hidden",()=>{document.body.style.overflow=""}},[e]),o.useEffect(()=>{if(!e||!f)return;const te=ee=>{ee.key==="Escape"&&r()};return window.addEventListener("keydown",te),()=>window.removeEventListener("keydown",te)},[f,r,e]),!y)return null;const Z=n||a||s||l||g,D=u??uc[d],Q=v==="bottom-mobile"?"items-end sm:items-center justify-center p-0 sm:p-4":"items-center justify-center",j=v==="bottom-mobile"?"rounded-t-2xl sm:rounded-2xl":"rounded-2xl",se=w?"translateY(0) scale(1)":v==="bottom-mobile"?"translateY(16px) scale(0.98)":"translateY(10px) scale(0.96)";return ct.createPortal(t.jsxs("div",{role:"dialog","aria-modal":"true","data-bonsaif-overlay":"true","aria-label":N??n,className:`fixed inset-0 flex ${Q} ${$}`,style:{zIndex:m},children:[t.jsx("div",{className:`absolute inset-0 ${A}`,onClick:b?r:void 0,style:{opacity:w?1:0,transition:`opacity ${Sn}ms ease`}}),t.jsxs("div",{className:`relative z-10 flex max-h-[92dvh] w-full flex-col overflow-hidden ${T?"shadow-none":"shadow-2xl"} ${j} ${h}`,style:{maxWidth:D,background:T?"transparent":"var(--bg-card)",border:T?"none":"1px solid var(--border)",opacity:w?1:0,transform:se,transition:`opacity ${Sn}ms ease, transform ${Sn}ms ease`},onClick:te=>te.stopPropagation(),children:[x&&t.jsx("div",{className:"absolute inset-0 z-[1002] cursor-not-allowed rounded-2xl",style:{background:"color-mix(in srgb, var(--bg-card, #ffffff) 60%, transparent)",backdropFilter:"blur(2px)"}}),Z&&t.jsxs("div",{className:"flex flex-shrink-0 items-center justify-between gap-3 px-6 py-4",style:{borderBottom:"1px solid var(--border)"},children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[s&&t.jsx("div",{className:"flex-shrink-0",children:s}),(n||a)&&t.jsxs("div",{className:"min-w-0",children:[n&&t.jsx("h2",{className:"truncate text-base font-semibold",style:{color:"var(--text-main)"},children:n}),a&&t.jsx("p",{className:"truncate text-xs",style:{color:"var(--text-muted)"},children:a})]})]}),t.jsxs("div",{className:"flex flex-shrink-0 items-center gap-2",children:[l,g&&t.jsx(Ue,{variant:"icon",onClick:r,title:"Cerrar",children:t.jsx(q.HiXMark,{className:"h-5 w-5"})})]})]}),t.jsx("div",{className:`min-h-0 flex-1 overflow-y-auto ${k}`,children:c}),i&&t.jsx("div",{className:"flex flex-shrink-0 justify-end gap-2 px-6 py-4",style:{borderTop:"1px solid var(--border)"},children:i})]})]}),document.body)}const bc={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 mc({open:e,title:r,description:n,confirmLabel:a="Confirmar",cancelLabel:s="Cancelar",variant:l="danger",closeOnBackdrop:i=!0,onConfirm:c,onCancel:d}){const u=bc[l];return t.jsx(Oa,{open:e,onClose:d,size:"md",zIndex:9998,showCloseButton:!1,bodyClassName:"p-0",panelClassName:"overflow-visible",ariaLabel:r,closeOnBackdrop:i,children:t.jsxs("div",{className:"relative px-6 pb-6 pt-6",children:[t.jsx(Ue,{variant:"icon",onClick:d,className:"absolute right-3 top-3 h-8 w-8 hover:opacity-70",style:{color:"var(--text-muted)"},"aria-label":"Cancelar",children:t.jsx(q.HiXMark,{className:"h-4 w-4"})}),t.jsxs("div",{className:"flex gap-3 pr-8",children:[t.jsx("div",{className:"mt-0.5 flex h-10 w-10 flex-shrink-0 items-center justify-center rounded-xl",style:{background:u.iconBg},children:t.jsx(q.HiExclamationTriangle,{className:"h-5 w-5",style:{color:u.iconColor}})}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("h2",{className:"text-base font-semibold leading-snug",style:{color:"var(--text-main)"},children:r}),n?t.jsx("div",{className:"mt-1.5 text-sm leading-relaxed",style:{color:"var(--text-muted)"},children:n}):null]})]}),t.jsxs("div",{className:"mt-6 flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",children:[t.jsx(Ue,{variant:"secondary",onClick:d,className:"w-full sm:w-auto sm:min-w-[7.5rem]",style:{background:"var(--bg-input)"},children:s}),t.jsx(Ue,{variant:"danger",onClick:c,className:"w-full sm:w-auto sm:min-w-[7.5rem]",style:{background:u.btnBg,color:u.btnColor,borderColor:"transparent"},children:a})]})]})})}function pc(e){return e?typeof e=="function"?e():e:""}function hc(e){return/^https?:\/\//i.test(e)}function Ro(e,r){try{return new URL(e,r).toString()}catch{return e}}function gc(e,r,n,a=!1){const s=typeof e=="function"?e():e,l=r?r(s):s;if(!l||hc(l))return l;const i=pc(n);return i?Ro(l,i):a&&typeof window<"u"?Ro(l,window.location.origin):l}function vc({url:e,resolveUrl:r,baseUrl:n,useWindowOriginForRelative:a=!1,title:s="Copiar link",copiedTitle:l="Link copiado",icon:i=t.jsx(q.HiLink,{className:"h-3.5 w-3.5"}),...c}){return t.jsx(La,{...c,value:()=>gc(e,r,n,a),title:s,copiedTitle:l,icon:i})}const es=32767;function Cn(e){let r=String(e??"");return r=r.split("\0").join(""),r.length<=es?r:`${r.slice(0,es-1)}…`}const En=[25,50,100,200,500];let Nt={dataTable:{pageSizeOptions:[...En]}};function yc(){if(typeof window>"u")return;const r=window.__BONSAIF_DATA_TABLE_PREFERENCES_ENDPOINT__;return typeof r=="string"&&r.trim().length>0?r.trim().replace(/\/+$/,""):void 0}function Ha(){const e=Nt.dataTable.preferencesEndpoint,r=yc();return e&&e.trim().length>0?e.trim().replace(/\/+$/,""):r}function xc(e){if(!Array.isArray(e))return[...En];const r=Array.from(new Set(e.map(n=>typeof n=="number"?Math.floor(n):Number.NaN).filter(n=>Number.isFinite(n)&&n>0)));return r.length>0?r:[...En]}function ts(e){if(typeof e!="string")return;const r=e.trim();if(r)return r.replace(/\/+$/,"")}function wc(e){if(!e||typeof e!="object"||!e.dataTable)return;const r=ts(e.dataTable.preferencesEndpoint);Nt={...Nt,dataTable:{...Nt.dataTable,pageSizeOptions:xc(e.dataTable.pageSizeOptions),preferencesEndpoint:r??Nt.dataTable.preferencesEndpoint}}}function Nc(){return{dataTable:{pageSizeOptions:[...Nt.dataTable.pageSizeOptions]}}}function Xr(){return[...Nt.dataTable.pageSizeOptions]}function kc(){Nt={dataTable:{pageSizeOptions:[...En]}}}function Sc(e){Nt={...Nt,dataTable:{...Nt.dataTable,preferencesEndpoint:ts(e)}}}const Mn=[{value:"equals",label:"Igual a",valueMode:"single"},{value:"notEquals",label:"No es igual a",valueMode:"single"},{value:"greaterThan",label:"Mayor que",valueMode:"single"},{value:"greaterThanOrEqual",label:"Mayor o igual que",valueMode:"single"},{value:"lessThan",label:"Menor que",valueMode:"single"},{value:"lessThanOrEqual",label:"Menor o igual que",valueMode:"single"},{value:"between",label:"Entre",valueMode:"between"},{value:"top10",label:"10 superiores",valueMode:"none"},{value:"bottom10",label:"10 inferiores",valueMode:"none"},{value:"aboveAverage",label:"Sobre promedio",valueMode:"none"},{value:"belowAverage",label:"Bajo promedio",valueMode:"none"}],Cc=Mn.map(e=>({value:e.value,label:e.label})),Ec=12,Mc={layout:!0,filters:!1,sort:!1,bql:!1,pagination:!0},rs={layout:!0,filters:!0,sort:!0,bql:!0,pagination:!0},Tc="bonsaif-ui:datatable:",$c="[&_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",Ac=[],Lc=52;function _t(e){if(!e)return 150;const r=parseInt(e,10);return isNaN(r)||r<=0?150:r}function ns(e){return!!(e&&(Array.isArray(e.columnOrder)&&e.columnOrder.length>0||e.columnWidths&&Object.keys(e.columnWidths).length>0||Array.isArray(e.hiddenColumnKeys)&&e.hiddenColumnKeys.length>0||e.filters&&Object.keys(e.filters).length>0||e.conditionFilters&&Object.keys(e.conditionFilters).length>0||e.sort||typeof e.bql=="string"||Array.isArray(e.bqlHistory)&&e.bqlHistory.length>0||typeof e.pageSize=="number"))}function as(e){return`${Tc}${e}`}function Tn(e){try{const r=window.localStorage.getItem(as(e));if(!r)return null;const n=JSON.parse(r);return n&&typeof n=="object"?n:null}catch{return null}}function Dc(e,r){try{window.localStorage.setItem(as(e),JSON.stringify(r))}catch{}}function Ic(e,r){if(e===!0)return{...rs};if(e===!1)return{layout:!1,filters:!1,sort:!1,bql:!1,pagination:!1};if(r&&e==null)return{...rs};const n={...Mc,...e??{}};return r&&(typeof e!="object"||e.pagination!==!1)&&(n.pagination=!0),n}function os(...e){return e.reduce((r,n)=>({...r,...n??{}}),{})}function Ba(e,r,n){return typeof e!="number"||e<=0?n:Jr(r).includes(e)?e:n}function Kr(e){if(!e||typeof e!="object")return!1;const r=e;return typeof r.key=="string"&&(r.dir==="asc"||r.dir==="desc")}function Gr(e,r){if(!e||typeof e!="object"||Array.isArray(e))return{};const n=Object.entries(e).flatMap(([a,s])=>{if(!r.has(a)||!Array.isArray(s))return[];const l=s.filter(i=>typeof i=="string");return l.length>0?[[a,l]]:[]});return Object.fromEntries(n)}function Zr(e,r){if(!e||typeof e!="object"||Array.isArray(e))return{};const n=new Set(Mn.map(s=>s.value)),a=Object.entries(e).flatMap(([s,l])=>{if(!r.has(s)||!l||typeof l!="object")return[];const i=l;return!i.operator||!n.has(i.operator)?[]:[[s,{operator:i.operator,value:typeof i.value=="string"?i.value:"",valueTo:typeof i.valueTo=="string"?i.valueTo:""}]]});return Object.fromEntries(a)}function pt(e,r){if(or(e))return Lc;const n=e.minWidth??80,a=e.maxWidth??1/0;return Math.min(a,Math.max(n,r))}function Oc(e){const r=window.getComputedStyle(e);return parseFloat(r.paddingLeft)+parseFloat(r.paddingRight)}function or(e){return e.key==="actions"||e.key==="acciones"?!0:typeof e.header=="string"&&e.header.trim().toLowerCase()==="acciones"}function Fa(e){return e.sticky===!0}function ss(e){return!(e.reorderable===!1||e.sticky&&e.reorderable!==!0)}function Xt(e,r){const n=r.filter(Fa).map(i=>i.key);if(n.length===0)return e;const a=new Set(n),s=n.filter(i=>e.includes(i)),l=e.filter(i=>!a.has(i));return[...s,...l]}function Hc(e,r){if(r<=7)return Array.from({length:r},(a,s)=>s+1);const n=[1];e>3&&n.push("...");for(let a=Math.max(2,e-1);a<=Math.min(r-1,e+1);a++)n.push(a);return e<r-2&&n.push("..."),n.push(r),n}function Kt(e,r){var i;const n=new Set(r.filter(c=>c.hideable!==!1).map(c=>c.key)),a=Array.from(new Set(e??[])).filter(c=>n.has(c));if(r.filter(c=>!a.includes(c.key)).length>0)return a;const l=(i=r.find(c=>c.hideable!==!1))==null?void 0:i.key;return l?a.filter(c=>c!==l):[]}function Bc(e){return e==null||e===""?"(Vacio)":e instanceof Date?e.toLocaleDateString():String(e)}function gr(e){return e==null||typeof e=="boolean"?"":typeof e=="string"||typeof e=="number"?String(e):Array.isArray(e)?e.map(gr).join(" ").trim():o.isValidElement(e)?gr(e.props.children):""}function $n(e,r){const n=e.filterValue?e.filterValue(r):e.sortKey?r[e.sortKey]:e.cell(r);return typeof n=="string"||typeof n=="number"||typeof n=="boolean"||n===null||n===void 0||n instanceof Date?Bc(n):gr(n).trim()}function Qr(e){const r=e.replace(/,/g,"").trim();if(!r)return null;const n=Number(r);return Number.isFinite(n)?n:null}function vr(e,r){const n=Qr(e),a=Qr(r);return n!==null&&a!==null?n-a:e.localeCompare(r,void 0,{numeric:!0,sensitivity:"base"})}function Jr(e){const r=Array.from(new Set(e.map(n=>Math.floor(n)).filter(n=>Number.isFinite(n)&&n>0)));return r.length>0?r:Xr()}function Fc(e,r,n){var i,c;const a=((i=r.value)==null?void 0:i.trim())??"",s=((c=r.valueTo)==null?void 0:c.trim())??"",l=Mn.find(d=>d.value===r.operator);if((l==null?void 0:l.valueMode)==="single"&&!a||(l==null?void 0:l.valueMode)==="between"&&(!a||!s))return!0;switch(r.operator){case"equals":return e.toLowerCase()===a.toLowerCase();case"notEquals":return e.toLowerCase()!==a.toLowerCase();case"greaterThan":return vr(e,a)>0;case"greaterThanOrEqual":return vr(e,a)>=0;case"lessThan":return vr(e,a)<0;case"lessThanOrEqual":return vr(e,a)<=0;case"between":return vr(e,a)>=0&&vr(e,s)<=0;case"top10":case"bottom10":{const u=n.map(b=>({value:b,number:Qr(b)})).filter(b=>b.number!==null).sort((b,f)=>b.number-f.number).map(b=>b.value);return(r.operator==="top10"?u.slice(-10):u.slice(0,10)).includes(e)}case"aboveAverage":case"belowAverage":{const d=n.map(Qr).filter(b=>b!==null);if(d.length===0)return!1;const u=d.reduce((b,f)=>b+f,0)/d.length,m=Qr(e);return m===null?!1:r.operator==="aboveAverage"?m>u:m<u}default:return!0}}function ls({children:e,className:r="",style:n}){return t.jsx(Yt,{onlyWhenOverflow:!0,className:r,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,...n},children:e})}function is({columns:e,data:r,getRowId:n,loading:a=!1,skeletonRows:s=8,emptyIcon:l,emptyText:i="Sin resultados",initialEmptyDelay:c=450,onRowClick:d,renderExpandedRow:u,getRowCanExpand:m,expandedRowIds:b,defaultExpandedRowIds:f=[],onExpandedRowIdsChange:g,expandOnRowClick:v=!1,selected:k,onToggleOne:h,onToggleAll:A,getRowSelectable:$,highlightSelected:N=!0,rowClassName:T,getRowCategory:x,stickyHeader:y=!0,pageSize:L=25,pageSizeOptions:w,pageSizeSelectWidth:W=62,pageSizeSelectHeight:X=30,pageSizeSelectPadding:Z="0 7px",totalRows:D,page:Q,onPageChange:j,onPageSizeChange:se,storageKey:te,stickyFirstColumn:ee=!1,bottomOffset:U=0,compact:J=!0,restrictHeight:ce=!0,maxHeight:C,minTableWidth:_,enableColumnVisibility:ae=!0,enableColumnFilters:B=!0,hiddenColumnKeys:I,defaultHiddenColumnKeys:E=Ac,onHiddenColumnKeysChange:oe,columnVisibilityLabel:K="Columnas",enableBql:Y=!1,bqlValue:S,defaultBqlValue:H="",onBqlChange:O,bqlDescription:re="Filtra registros con Bonsaif Query Language",bqlPlaceholder:z=`status = activo
|
|
2
|
+
rol IN (admin, employee)`,bqlQuickFilters:de=[],bqlExamples:he=[],bqlSuggestions:ie=[],bqlActiveFilters:ge,bqlError:Me,onQueryChange:$e,persistState:Dt,onPreferencesReady:ut,enableExport:Re=!1,exportFilename:It="datos",onExportCsv:Ct,onExportPdf:Et}){var $i;const le=Ic(Dt,te),Fe=Object.values(le).some(Boolean),ze=e.map(p=>p.key).join(","),ft=E.join(","),Ve=o.useRef(e),Mt=o.useRef(E);Ve.current=e,Mt.current=E;const[bt,rt]=o.useState(!te||!Fe),Wt=o.useRef(null),ue=o.useRef(!te),pe=o.useRef(!1),Le=o.useRef(ut);Le.current=ut;const He=o.useRef(!te||!Fe?te??"__none__":null),Ie=I!==void 0,[tt,at]=o.useState(()=>Kt(E,e)),We=Kt(Ie?I:tt,e),[Ke,Ge]=o.useState(!1),[Ae,lr]=o.useState("filter"),[ir,Or]=o.useState(null),[Jt,oa]=o.useState(""),[lt,jt]=o.useState({}),[F,G]=o.useState({}),fe=b!==void 0,[be,Te]=o.useState(f),ye=S!==void 0,[Be,De]=o.useState(H),Ye=ye?S:Be,[Ze,Ot]=o.useState(Ye),[ot,it]=o.useState(!1),[cr,qt]=o.useState(!1),[fn,Hr]=o.useState(!1),[bn,Br]=o.useState([]),Fr=o.useRef(null),dr=o.useRef(null),Ht=o.useRef(O);Ht.current=O;const sa=o.useRef(L);sa.current=L;const la=o.useRef(w);la.current=w;const Sb=Array.isArray(w)?w.join(","):"",No=o.useRef(null),Rl=o.useRef(null),ko=o.useRef(null),ei=o.useRef(0),[Cb,Eb]=o.useState({}),[Mb,Tb]=o.useState({}),[mn,ia]=o.useState(!1),So=o.useRef(null),ca=o.useRef(null),[$b,Ab]=o.useState({}),ti=o.useRef(null),da=o.useRef(null),[Co,ri]=o.useState(r.length>0||a||c===!1),ni=(p,M)=>50+(p*17+M*13+7)%40,Rt=o.useRef(null),[Lb,Db]=o.useState(void 0),[ai,Ib]=o.useState(0),[Ob,Hb]=o.useState(!1);o.useEffect(()=>{function p(){Hb(window.innerWidth<640)}if(!ce||C!==void 0)return p(),window.addEventListener("resize",p),()=>window.removeEventListener("resize",p);const R=L!==!1?48:0,P=12;function ne(){if(p(),!Rt.current)return;const me=Rt.current.getBoundingClientRect().top;Db(Math.max(120,window.innerHeight-me-R-P-U))}return ne(),window.addEventListener("resize",ne),()=>window.removeEventListener("resize",ne)},[a,L,U,ce,C]);const oi=ce?C??Lb:void 0;o.useEffect(()=>{const p=Rt.current;if(!p)return;const M=()=>Ib(p.clientWidth);if(M(),typeof ResizeObserver>"u")return window.addEventListener("resize",M),()=>window.removeEventListener("resize",M);const R=new ResizeObserver(M);return R.observe(p),()=>R.disconnect()},[a,bt,r.length]),o.useEffect(()=>{if(c===!1||a||r.length>0){ri(!0);return}if(Co)return;const p=window.setTimeout(()=>{ri(!0)},c);return()=>window.clearTimeout(p)},[r.length,c,Co,a]);const[Pr,_r]=o.useState(()=>Xt(e.map(p=>p.key),e)),[ur,zr]=o.useState(()=>Object.fromEntries(e.map(p=>[p.key,pt(p,_t(p.width))]))),[Xe,fr]=o.useState(null),[Bb,ua]=o.useState(1),[fa,ba]=o.useState(L===!1?0:L);o.useEffect(()=>{var Ee;const p=Ve.current,M=Mt.current,R=p.map(Ne=>Ne.key),P=new Set(R),ne=()=>{var Ne;pe.current||(pe.current=!0,(Ne=Le.current)==null||Ne.call(Le))};if(!te||!Fe){le.layout&&_r(Xt(R,p)),Ie||at(Kt(M,p)),ue.current=!1,rt(!0),ne();return}let me=!1;const ke=He.current===te;ke||(ue.current=!1,rt(!1),pe.current=!1);const Ce=Tn(te);if(ns(Ce)&&!ke){const Ne=Ce,xe=Jr(la.current??Xr()),we=sa.current,pr=we===!1?0:we,tr=le.layout?Ne==null?void 0:Ne.columnOrder:void 0,rr=Array.isArray(tr)?tr.filter(_e=>R.includes(_e)):[],nr=R.filter(_e=>!rr.includes(_e)),hr=Xt(rr.length>0?[...rr,...nr]:R,p),qr=Object.fromEntries(p.map(_e=>[_e.key,pt(_e,_t(_e.width))])),Ur=le.layout?(Ne==null?void 0:Ne.columnWidths)??{}:{},vn=Object.fromEntries(p.map(_e=>[_e.key,pt(_e,Ur[_e.key]??qr[_e.key])])),Vr=Kt(le.layout?(Ne==null?void 0:Ne.hiddenColumnKeys)??M:M,p);if(le.layout&&(_r(hr),zr(vn)),Ie||at(Vr),le.filters&&(jt(Gr(Ne==null?void 0:Ne.filters,P)),G(Zr(Ne==null?void 0:Ne.conditionFilters,P))),le.sort){const _e=Kr(Ne==null?void 0:Ne.sort)?Ne.sort:null;fr(_e&&P.has(_e.key)?_e:null)}if(le.bql){if(Fr.current!==te){Fr.current=te;const _e=typeof(Ne==null?void 0:Ne.bql)=="string"?Ne.bql:H;ye?(Ee=Ht.current)==null||Ee.call(Ht,_e):De(_e)}Br(Array.isArray(Ne==null?void 0:Ne.bqlHistory)?Ne.bqlHistory.filter(_e=>typeof _e=="string"):[])}le.pagination&&dr.current!==te&&(dr.current=te,ba(Ba(Ne==null?void 0:Ne.pageSize,xe,pr))),He.current=te,rt(!0),ne()}const mt=`${Ha()??"/api/user/preferences/datatables"}?key=${encodeURIComponent(te)}`,et=new AbortController,ve=window.setTimeout(()=>et.abort(),2500);return fetch(mt,{cache:"no-store",signal:et.signal}).then(Ne=>Ne.ok?Ne.json():null).then(Ne=>{var Ai;if(me)return;const xe=Tn(te),we=os(ns(Ne==null?void 0:Ne.settings)?Ne==null?void 0:Ne.settings:null,xe),pr=Jr(la.current??Xr()),tr=sa.current,rr=tr===!1?0:tr,nr=le.layout?we==null?void 0:we.columnOrder:void 0,hr=Array.isArray(nr)?nr.filter(Qe=>R.includes(Qe)):[],qr=R.filter(Qe=>!hr.includes(Qe)),Ur=Xt(hr.length>0?[...hr,...qr]:R,p),vn=Object.fromEntries(p.map(Qe=>[Qe.key,pt(Qe,_t(Qe.width))])),Vr=le.layout?(we==null?void 0:we.columnWidths)??{}:{},_e=Object.fromEntries(p.map(Qe=>[Qe.key,pt(Qe,Vr[Qe.key]??vn[Qe.key])])),Yr=Kt(le.layout?(we==null?void 0:we.hiddenColumnKeys)??M:M,p);if(le.layout&&(_r(Ur),zr(_e)),Ie||at(Yr),le.filters&&(jt(Gr(we==null?void 0:we.filters,P)),G(Zr(we==null?void 0:we.conditionFilters,P))),le.sort){const Qe=Kr(we==null?void 0:we.sort)?we.sort:null;fr(Qe&&P.has(Qe.key)?Qe:null)}if(le.bql){if(Fr.current!==te){Fr.current=te;const Qe=typeof(we==null?void 0:we.bql)=="string"?we.bql:H;ye?(Ai=Ht.current)==null||Ai.call(Ht,Qe):De(Qe)}Br(Array.isArray(we==null?void 0:we.bqlHistory)?we.bqlHistory.filter(Qe=>typeof Qe=="string"):[])}let je;le.pagination&&(je=Ba(we==null?void 0:we.pageSize,pr,rr),dr.current!==te&&(dr.current=te,ba(je))),Wt.current=JSON.stringify({columnOrder:Ur,columnWidths:_e,hiddenColumnKeys:Yr,filters:Gr(we==null?void 0:we.filters,P),conditionFilters:Zr(we==null?void 0:we.conditionFilters,P),sort:Kr(we==null?void 0:we.sort)?we.sort:null,bql:typeof(we==null?void 0:we.bql)=="string"?we.bql:"",bqlHistory:Array.isArray(we==null?void 0:we.bqlHistory)?we.bqlHistory:[],pageSize:le.pagination&&tr!==!1?je:void 0}),ue.current=!0}).catch(()=>{var Ne;if(!me){const xe=Tn(te),we=Jr(la.current??Xr()),pr=sa.current,tr=pr===!1?0:pr,rr=le.layout?xe==null?void 0:xe.columnOrder:void 0,nr=Array.isArray(rr)?rr.filter(je=>R.includes(je)):[],hr=R.filter(je=>!nr.includes(je)),qr=Xt(nr.length>0?[...nr,...hr]:R,p),Ur=Object.fromEntries(p.map(je=>[je.key,pt(je,_t(je.width))])),vn=le.layout?(xe==null?void 0:xe.columnWidths)??{}:{},Vr=Object.fromEntries(p.map(je=>[je.key,pt(je,vn[je.key]??Ur[je.key])]));le.layout&&(_r(qr),zr(Vr));const _e=Kt(le.layout?(xe==null?void 0:xe.hiddenColumnKeys)??M:M,p);if(Ie||at(_e),le.filters&&(jt(Gr(xe==null?void 0:xe.filters,P)),G(Zr(xe==null?void 0:xe.conditionFilters,P))),le.sort){const je=Kr(xe==null?void 0:xe.sort)?xe.sort:null;fr(je&&P.has(je.key)?je:null)}if(le.bql){if(Fr.current!==te){Fr.current=te;const je=typeof(xe==null?void 0:xe.bql)=="string"?xe.bql:H;ye?(Ne=Ht.current)==null||Ne.call(Ht,je):De(je)}Br(Array.isArray(xe==null?void 0:xe.bqlHistory)?xe.bqlHistory.filter(je=>typeof je=="string"):[])}let Yr;le.pagination&&(Yr=Ba(xe==null?void 0:xe.pageSize,we,tr),dr.current!==te&&(dr.current=te,ba(Yr))),Wt.current=JSON.stringify({columnOrder:qr,columnWidths:Vr,hiddenColumnKeys:_e,filters:Gr(xe==null?void 0:xe.filters,P),conditionFilters:Zr(xe==null?void 0:xe.conditionFilters,P),sort:Kr(xe==null?void 0:xe.sort)?xe.sort:null,bql:typeof(xe==null?void 0:xe.bql)=="string"?xe.bql:"",bqlHistory:Array.isArray(xe==null?void 0:xe.bqlHistory)?xe.bqlHistory:[],pageSize:le.pagination&&pr!==!1?Yr:void 0}),ue.current=!0}}).finally(()=>{window.clearTimeout(ve),me||(He.current=te,rt(!0),ne())}),()=>{me=!0,et.abort(),window.clearTimeout(ve)}},[te,Fe,ze,ft,Ie,le.layout,le.filters,le.sort,le.bql,le.pagination,ye,H,Sb]),o.useEffect(()=>{if(!te||!bt||!Fe||!ue.current)return;const p={};le.layout&&(p.columnOrder=Pr,p.columnWidths=ur,p.hiddenColumnKeys=We),le.filters&&(p.filters=lt,p.conditionFilters=F),le.sort&&(p.sort=Xe),le.bql&&(p.bql=Ye,p.bqlHistory=bn),le.pagination&&L!==!1&&(p.pageSize=fa);const M=Tn(te),R=os(M,p),P=JSON.stringify(R);if(P===Wt.current)return;Dc(te,R),Wt.current=P;const ne=window.setTimeout(()=>{const me=Ha()??"/api/user/preferences/datatables";fetch(me,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({key:te,settings:R})}).then(()=>{}).catch(()=>{})},300);return()=>window.clearTimeout(ne)},[Pr,ur,We,lt,F,Xe,Ye,bn,fa,L,te,bt,Fe,le.layout,le.filters,le.sort,le.bql,le.pagination]),o.useEffect(()=>{_r(p=>{const M=e.map(ne=>ne.key),R=p.filter(ne=>M.includes(ne)),P=M.filter(ne=>!R.includes(ne));return Xt([...R,...P],e)})},[ze,e]);const si=Xt(Pr,e).map(p=>e.find(M=>M.key===p)).filter(p=>!!p),wt=si.filter(p=>!We.includes(p.key)),li=e.some(Fa),Fb=Object.keys(lt).length,Pb=Object.keys(F).length,Eo=Fb+Pb;function ii(p){const M=new Set;return r.reduce((R,P)=>{const ne=$n(p,P);return!ne||M.has(ne)||(M.add(ne),R.push({value:ne,label:ne})),R},[])}function _b(){const p=e.find(M=>M.key===ir);return p?ii(p):[]}function zb(p){return!!(B&&!or(p)&&(p.filterValue||p.sortKey||ii(p).length>0))}function ci(p,M){jt(R=>{const P={...R};return P[p]=M,P})}function Wb(p,M,R,P){const ne=lt[p]??[],me=P?ne:R.filter(Ce=>Ce!==M),ke=P?ne.includes(M)?ne.filter(Ce=>Ce!==M):[...ne,M]:me;ke.length===R.length?Mo(p):ci(p,ke)}function Mo(p){jt(M=>{const R={...M};return delete R[p],R})}function ma(p,M){G(R=>{const P={...R};return M?P[p]=M:delete P[p],P})}function di(p){ma(p,null)}function jb(){jt({}),G({})}function qb(p){ye||De(p),O==null||O(p)}function ui(p){const M=p.trim();Ot(M),(O==null?void 0:O(M))!==!1&&(ye||De(M),it(!1),qt(!1),Hr(!1),M&&Br(P=>[M,...P.filter(ne=>ne!==M)].slice(0,Ec)))}function fi(){Ot(""),qb(""),it(!1),qt(!1),Hr(!1)}function To(p,M){Ot(p),M&&(M.style.height="auto",M.style.height=`${Math.min(M.scrollHeight,180)}px`)}function pa(p){const M=p.trim();if(!M)return;ei.current=Date.now()+500;const R=Ze.replace(/\s+$/u,""),P=R.length===0?M:R.split(`
|
|
3
|
+
`).map(ne=>ne.trim()).includes(M)?R:`${R}
|
|
4
|
+
${M}`;To(P,ko.current??void 0),requestAnimationFrame(()=>{const ne=ko.current;if(!ne)return;ne.focus();const me=ne.value.length;ne.setSelectionRange(me,me),To(ne.value,ne)})}o.useEffect(()=>{Ot(Ye)},[Ye]);const ha=o.useCallback(()=>{const p=No.current;if(!p)return;const M=p.getBoundingClientRect(),R=12,P=8,ne=Math.min(780,Math.max(320,window.innerWidth-32)),me=Math.max(R,window.innerWidth-ne-R),ke=Math.min(Math.max(R,M.left),me),Ce=M.bottom+P,Pe=window.innerHeight-M.top+P,qe=window.innerHeight-Ce-R,mt=M.top-R-P,et=qe<280&&mt>qe,ve=Math.max(240,et?mt:qe);Eb({position:"fixed",zIndex:1e4,left:ke,top:et?void 0:Ce,bottom:et?Pe:void 0,width:ne,maxWidth:"calc(100vw - 24px)",maxHeight:ve,overflowY:"auto"})},[]);o.useEffect(()=>{if(!ot)return;function p(P){var me,ke;if(Date.now()<ei.current)return;const ne=P.target;(me=No.current)!=null&&me.contains(ne)||(ke=Rl.current)!=null&&ke.contains(ne)||(it(!1),qt(!1),Hr(!1))}function M(P){P.key==="Escape"&&(it(!1),qt(!1),Hr(!1))}function R(){ha()}return ha(),document.addEventListener("mousedown",p),window.addEventListener("keydown",M),window.addEventListener("resize",R),window.addEventListener("scroll",R,!0),()=>{document.removeEventListener("mousedown",p),window.removeEventListener("keydown",M),window.removeEventListener("resize",R),window.removeEventListener("scroll",R,!0)}},[ot,ha]);function bi(p){const M=Kt(p,e);Ie||at(M),oe==null||oe(M)}function Ub(p){bi(We.includes(p)?We.filter(M=>M!==p):[...We,p])}function Vb(){bi([])}const $o=o.useCallback((p=da.current)=>{if(!p)return;const M=p.getBoundingClientRect(),R=Math.min(292,Math.max(240,window.innerWidth-16)),P=Math.max(8,window.innerWidth-R-8),ne=Math.min(Math.max(8,M.right-R),P),me=window.innerHeight-M.bottom,ke=M.bottom+6,Ce=window.innerHeight-M.top+6,qe=me<360&&M.top>me?void 0:ke,mt=qe===void 0?Ce:void 0,et=Math.max(220,qe===void 0?M.top-16:window.innerHeight-ke-8),ve={position:"fixed",zIndex:9999,left:ne,top:qe,bottom:mt,width:R,maxWidth:"calc(100vw - 16px)",maxHeight:et,"--dt-column-menu-max-height":`${et}px`};Tb(ve)},[]);function mi(p,M,R=null){p.preventDefault(),p.stopPropagation();const P=da.current===p.currentTarget&&Ae===M&&ir===R;if(Ke&&P){Ge(!1),Or(null);return}da.current=p.currentTarget,lr(M),Or(R),oa(""),$o(p.currentTarget),Ge(!0)}function Yb(p){if(or(p))return;const M=Rt.current;if(!M)return;const P=Array.from(M.querySelectorAll("[data-dt-column-key]")).filter(ne=>ne.dataset.dtColumnKey===p.key).reduce((ne,me)=>{const ke=me.querySelector("[data-dt-autofit-content]"),Ce=ke?ke.scrollWidth:Math.max(me.scrollWidth,me.offsetWidth);return Math.max(ne,Math.ceil(Ce+Oc(me)))},0);P<=0||zr(ne=>({...ne,[p.key]:pt(p,P+12)}))}o.useEffect(()=>{zr(p=>{const M=Object.fromEntries(e.map(R=>[R.key,pt(R,_t(R.width))]));return Object.fromEntries(e.map(R=>[R.key,pt(R,p[R.key]??M[R.key])]))})},[ze,e]),o.useEffect(()=>{Ie||at(p=>Kt(p,e))},[ze,e,Ie]),o.useEffect(()=>{function p(P){var ke,Ce;const ne=P.target,me=P.target;me!=null&&me.closest("[data-bonsaif-select-dropdown='true']")||!((ke=ti.current)!=null&&ke.contains(ne))&&!((Ce=da.current)!=null&&Ce.contains(ne))&&(Ge(!1),Or(null))}function M(P){P.key==="Escape"&&(Ge(!1),Or(null))}function R(){$o()}return Ke&&(document.addEventListener("mousedown",p),window.addEventListener("keydown",M),window.addEventListener("resize",R),window.addEventListener("scroll",R,!0)),()=>{document.removeEventListener("mousedown",p),window.removeEventListener("keydown",M),window.removeEventListener("resize",R),window.removeEventListener("scroll",R,!0)}},[Ke,$o]);const pn=o.useRef(null);o.useEffect(()=>{function p(R){const P=pn.current;if(!P)return;const ne=R.clientX-P.startX,me=e.find(ke=>ke.key===P.colKey);me&&zr(ke=>({...ke,[P.colKey]:pt(me,P.startWidth+ne)}))}function M(){pn.current&&(pn.current=null,document.body.style.cursor="",document.body.style.userSelect="")}return document.addEventListener("pointermove",p),document.addEventListener("pointerup",M),()=>{document.removeEventListener("pointermove",p),document.removeEventListener("pointerup",M)}},[e]);const hn=o.useRef(null),[pi,Ao]=o.useState(null);function Xb(p,M){const R=e.find(P=>P.key===p);if(!R||!ss(R)){M.preventDefault();return}hn.current=Pr.indexOf(p),M.dataTransfer.effectAllowed="move"}function Kb(p,M){M.preventDefault(),M.dataTransfer.dropEffect="move";const R=Pr.indexOf(p);pi!==R&&Ao(R)}function Gb(p,M){M.preventDefault();const R=hn.current,P=Pr.indexOf(p);R!==null&&R!==P&&_r(ne=>{const me=[...ne],[ke]=me.splice(R,1);return me.splice(P,0,ke),Xt(me,e)}),hn.current=null,Ao(null)}function Zb(){hn.current=null,Ao(null)}function Qb(p){p.sortKey&&fr(M=>(M==null?void 0:M.key)===p.key?{key:p.key,dir:M.dir==="asc"?"desc":"asc"}:{key:p.key,dir:"asc"})}o.useEffect(()=>{ua(1)},[r]),o.useEffect(()=>{ua(1)},[F,lt]);const Bt=!!(j&&se),er=L!==!1,Lo=o.useMemo(()=>Jr(w??Xr()),[w]),st=Bt?Q??1:Bb,hi=er&&fa<1?typeof L=="number"&&L>0?L:Lo[0]??25:fa,Ft=Bt||er?hi:r.length,Tt=!!k&&!!h&&!!A,Do=o.useMemo(()=>$?r.filter(p=>$(p)):r,[r,$]),Wr=!!u,gi=o.useMemo(()=>new Set(fe?Array.from(b??[]):be),[fe,b,be]),Jb=(Wr?40:0)+(Tt?40:0),Io=!Ob&&(li||ee),ga=(()=>{if(!Io)return{};let p=Jb;const M={};return wt.forEach((R,P)=>{(Fa(R)||!li&&ee&&P===0)&&(M[R.key]=p,p+=ur[R.key]??pt(R,_t(R.width)))}),M})(),Oo=Object.keys(ga),Ho=Oo.length>0?Oo[Oo.length-1]:null,vi=Tt&&Do.length>0&&Do.every(p=>k.has(n(p))),Rb=Tt&&k.size>0&&Do.some(p=>k.has(n(p)))&&!vi,va=o.useMemo(()=>{if(Bt)return r;const p=Object.entries(lt),M=Object.entries(F);return p.length===0&&M.length===0?r:r.filter(R=>p.every(([P,ne])=>{const me=e.find(ke=>ke.key===P);return me?ne.includes($n(me,R)):!0})&&M.every(([P,ne])=>{const me=e.find(Ce=>Ce.key===P);if(!me)return!0;const ke=r.map(Ce=>$n(me,Ce));return Fc($n(me,R),ne,ke)}))},[F,lt,e,r,Bt]),br=o.useMemo(()=>{if(!Xe)return va;const p=e.find(M=>M.key===Xe.key&&M.sortKey);return p!=null&&p.sortKey?[...va].sort((M,R)=>{const P=M[p.sortKey],ne=R[p.sortKey],me=P===ne?0:P==null?1:ne==null||P<ne?-1:1;return Xe.dir==="asc"?me:-me}):va},[va,Xe,e]),yi=o.useMemo(()=>{if(Bt||!er)return br;const p=(st-1)*Ft;return br.slice(p,p+Ft)},[br,Bt,er,st,Ft]),Ut=Bt?D??r.length:br.length,Bo=er?Math.max(1,Math.ceil(Ut/Ft)):1,em=Math.min(...Lo),tm=er&&(Ut>Ft||Ut>em),rm=er?(st-1)*Ft+1:1,nm=er?Math.min(st*Ft,Ut):Ut;function Fo(p){if(a)return;const M=Math.max(1,Math.min(p,Bo));Bt?j(M):ua(M)}function am(p){a||(te&&(dr.current=te),ba(p),Bt?(se(p),j(1)):(ua(1),se==null||se(p)))}function xi(p){const M=new Set(gi);M.has(p)?M.delete(p):M.add(p);const R=Array.from(M);fe||Te(R),g==null||g(R)}o.useEffect(()=>{$e==null||$e({bql:Ye,filters:lt,conditionFilters:F,sort:Xe,page:st,pageSize:Ft,hiddenColumnKeys:We})},[Ye,lt,F,Xe,st,Ft,We,$e]);const wi=p=>p==="center"?"justify-center text-center":p==="right"?"justify-end text-right":"justify-start text-left",om="color-mix(in srgb, var(--primary) 6%, var(--bg-card))",Po="linear-gradient(180deg, color-mix(in srgb, var(--bg-input) 90%, var(--bg-card)) 0%, color-mix(in srgb, var(--bg-input) 70%, var(--bg-card)) 100%)",Oe="color-mix(in srgb, var(--border) 62%, var(--bg-card))",mr="color-mix(in srgb, var(--primary) 24%, var(--border))",ya=`inset 0 0 0 1px ${Oe}`,Ni=wt.reduce((p,M)=>p+(ur[M.key]??_t(M.width)),(Wr?40:0)+(Tt?40:0)),ki=typeof _=="number"?_:typeof _=="string"?Number((($i=_.match(/^(\d+(?:\.\d+)?)px$/))==null?void 0:$i[1])??NaN):NaN,gn=Number.isFinite(ki)?Math.max(Ni,ki,ai):Math.max(Ni,ai),xa=_??gn,jr=`${Wr?"40px ":""}${Tt?"40px ":""}${wt.map(p=>`${ur[p.key]??_t(p.width)}px`).join(" ")}`;o.useEffect(()=>{Xe&&We.includes(Xe.key)&&fr(null)},[We,Xe]);function Si(p){return p?typeof p=="string"?{key:p,label:p}:p:null}const wa=()=>t.jsxs("div",{role:"row",className:"grid",style:{gridTemplateColumns:jr,background:Po,borderBottom:`1px solid ${mr}`},children:[Wr&&t.jsx("div",{role:"columnheader",className:`${J?"px-2 py-1.5":"px-3 py-2.5"} w-10`,style:{borderBottom:`1px solid ${mr}`,borderRight:`1px solid ${Oe}`}}),Tt&&t.jsx("div",{role:"columnheader",className:`${J?"px-2 py-1.5":"px-3 py-2.5"} flex w-10 items-center justify-center`,style:Io?{position:"sticky",left:0,zIndex:12,background:Po,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)",boxShadow:`inset 0 -1px 0 ${mr}`,borderRight:`1px solid ${Oe}`}:{borderBottom:`1px solid ${mr}`,borderRight:`1px solid ${Oe}`},children:t.jsx(Nn,{size:"sm",checked:vi,indeterminate:Rb,onChange:A,"aria-label":"Seleccionar todos",containerClassName:"items-center",className:"cursor-pointer"})}),wt.map((p,M)=>{const R=(Xe==null?void 0:Xe.key)===p.key,P=!!p.sortKey,ne=or(p),me=ga[p.key],ke=me!==void 0,Ce=p.key===Ho,Pe=ss(p),qe=pi===M,et=(ur[p.key]??_t(p.width))<120,ve=Object.prototype.hasOwnProperty.call(lt,p.key)||Object.prototype.hasOwnProperty.call(F,p.key);return t.jsxs("div",{role:"columnheader","data-dt-column-key":p.key,className:`group select-none ${et?"text-left":wi(p.align)}`,style:{...ke?{position:"sticky",left:me,zIndex:12,background:Po,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)",boxShadow:Ce?`3px 0 6px -2px rgba(0,0,0,0.10), inset 0 -1px 0 ${mr}`:`inset 0 -1px 0 ${mr}`,borderRight:`1px solid ${Oe}`}:{position:"relative",borderBottom:`1px solid ${mr}`,borderRight:`1px solid ${Oe}`},color:R?"var(--primary)":"var(--text-muted)",whiteSpace:"nowrap",transition:"color 0.15s",borderLeft:qe?"2px solid var(--primary)":"2px solid transparent",cursor:"default",padding:ne?J?"7px 6px":"9px 8px":J?"8px 6px 10px":"10px 8px 12px"},onDragOver:Ee=>{(Pe||hn.current!==null)&&Kb(p.key,Ee)},onDrop:Ee=>Gb(p.key,Ee),children:[t.jsxs("div",{className:`flex min-w-0 items-center gap-1 ${ne?"justify-center":et?"justify-start":p.align==="center"?"justify-center":p.align==="right"?"justify-end":"justify-start"}`,children:[Pe?t.jsx("span",{draggable:!0,onDragStart:Ee=>{Ee.stopPropagation(),Xb(p.key,Ee)},onDragEnd:Ee=>{Ee.stopPropagation(),Zb()},onClick:Ee=>Ee.stopPropagation(),title:"Arrastrar para mover columna","aria-label":"Arrastrar para mover columna",className:`absolute left-0 top-0 z-10 inline-flex h-full w-3 shrink-0 rounded-sm transition-colors duration-150 hover:bg-[var(--primary)]/15 ${qe?"bg-[var(--primary)]/20":""}`,style:{cursor:"grab"}}):null,ne?t.jsx("span",{className:"inline-flex h-5 w-5 items-center justify-center rounded-md text-[var(--text-muted)]",title:"Acciones","aria-label":"Acciones",children:t.jsx(q.HiCog6Tooth,{className:"h-3.5 w-3.5"})}):t.jsx(ls,{className:"min-w-0 flex-1",children:t.jsx("span",{"data-dt-autofit-content":!0,className:`inline-flex max-w-full items-center font-semibold uppercase tracking-wider ${J?"text-[11px]":"text-xs"}`,children:t.jsx("span",{className:"min-w-0 truncate",children:p.header})})}),P&&t.jsx("button",{type:"button","aria-label":`Ordenar por ${String(p.header)}`,title:"Ordenar",onClick:Ee=>{Ee.stopPropagation(),Qb(p)},"data-dt-sort-button":!0,className:`absolute -bottom-2 left-1/2 z-20 inline-flex h-4 w-4 -translate-x-1/2 items-center justify-center rounded-full bg-[var(--primary)] text-[var(--primary-fg)] shadow-[0_1px_3px_rgba(15,23,42,0.22)] transition-[opacity,transform] duration-150 hover:scale-105 focus:scale-105 focus:opacity-100 focus:outline-none ${R?"opacity-100":"opacity-0 group-hover:opacity-100 group-focus-within:opacity-100"}`,style:{bottom:"-0.5rem",top:"auto"},children:R?Xe.dir==="asc"?t.jsx(q.HiChevronUp,{className:"h-3 w-3"}):t.jsx(q.HiChevronDown,{className:"h-3 w-3"}):t.jsx(q.HiChevronUpDown,{className:"h-3 w-3"})}),B&&!ne&&zb(p)&&t.jsx("button",{type:"button","aria-haspopup":"menu","aria-expanded":Ke&&ir===p.key,"aria-label":`Filtrar ${String(p.header)}`,title:"Filtrar",onClick:Ee=>mi(Ee,"filter",p.key),className:`inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-sm bg-transparent text-[var(--text-muted)] opacity-0 transition-[opacity,color,background-color] duration-150 hover:bg-[var(--bg-card)] hover:text-[var(--primary)] focus:bg-[var(--bg-card)] focus:text-[var(--primary)] focus:opacity-100 group-hover:opacity-100 ${Ke&&Ae==="filter"&&ir===p.key?"bg-[var(--bg-card)] text-[var(--primary)] opacity-100":ve?"text-[var(--primary)] opacity-100":""}`,children:ve?t.jsx(q.HiFunnel,{className:"h-3.5 w-3.5"}):t.jsx(q.HiEllipsisVertical,{className:"h-3.5 w-3.5"})})]}),!ne&&t.jsx("span",{role:"separator","aria-orientation":"vertical",title:"Arrastrar para redimensionar. Doble click para autoajustar",onPointerDown:Ee=>{Ee.preventDefault(),Ee.stopPropagation(),pn.current={colKey:p.key,startX:Ee.clientX,startWidth:ur[p.key]??150},document.body.style.cursor="col-resize",document.body.style.userSelect="none"},onDoubleClick:Ee=>{Ee.preventDefault(),Ee.stopPropagation(),pn.current=null,document.body.style.cursor="",document.body.style.userSelect="",Yb(p)},onClick:Ee=>Ee.stopPropagation(),className:"absolute top-0 flex h-full items-center justify-center opacity-0 transition-opacity duration-200 hover:opacity-100",style:{right:0,width:12,cursor:"col-resize",zIndex:6,transform:"translateX(50%)"},children:t.jsxs("span",{style:{display:"flex",gap:4,alignItems:"center",height:"calc(100% - 8px)"},children:[t.jsx("span",{style:{width:2,height:"100%",borderRadius:2,background:"var(--primary)",display:"block"}}),t.jsx("span",{style:{width:2,height:"100%",borderRadius:2,background:"var(--primary)",display:"block"}})]})})]},p.key)})]}),Na=()=>{if(!Ke||typeof document>"u"||Ae==="visibility"&&!ae||Ae==="filter"&&!B)return null;const p=e.find(ve=>ve.key===ir),M=_b(),R=p?Object.prototype.hasOwnProperty.call(lt,p.key):!1,P=p?F[p.key]:void 0,ne=Mn.find(ve=>ve.value===(P==null?void 0:P.operator)),me=p?lt[p.key]??[]:[],ke=Jt.trim().toLowerCase(),Ce=ke?M.filter(ve=>ve.label.toLowerCase().includes(ke)):M,Pe=p&&M.length>0&&(!R||me.length===M.length),qe=p&&R&&me.length>0&&me.length<M.length,mt=We.length,et=()=>{p&&(Mo(p.key),di(p.key))};return ct.createPortal(t.jsx("div",{ref:ti,role:"menu",className:"overflow-hidden rounded-lg border p-1 shadow-xl",style:{...Mb,borderColor:"var(--border)",background:"var(--bg-card)"},children:Ae==="visibility"?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-[var(--border)] px-2 py-1.5",children:[t.jsx("span",{className:"min-w-0 truncate text-xs font-semibold uppercase text-[var(--text-muted)]",children:mt>0?`${wt.length} de ${e.length} visibles`:`${e.length} visibles`}),t.jsx("button",{type:"button",onClick:Vb,disabled:mt===0,className:"rounded px-1.5 py-0.5 text-xs font-medium text-[var(--primary)] transition-colors hover:bg-[var(--bg-input)] disabled:opacity-40",children:"Mostrar todas"})]}),t.jsx("div",{className:"max-h-72 overflow-auto py-1",children:si.map(ve=>{const Ee=!We.includes(ve.key),xe=!(ve.hideable!==!1)||Ee&&wt.length<=1;return t.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":Ee,disabled:xe,onClick:()=>Ub(ve.key),className:"flex w-full min-w-0 items-center gap-2 rounded-md px-2.5 py-1.5 text-left transition-colors hover:bg-[var(--bg-input)] disabled:cursor-not-allowed disabled:opacity-50",style:{color:"var(--text-main)"},children:[t.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center rounded border",style:{borderColor:Ee?"var(--primary)":"var(--border)",background:Ee?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:Ee&&t.jsx(q.HiCheck,{className:"h-3 w-3"})}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:ve.header})]},ve.key)})})]}):p?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-[var(--border)] px-2 py-1.5",children:[t.jsxs("span",{className:"min-w-0 truncate text-xs font-semibold uppercase text-[var(--text-muted)]",children:["Filtrar ",p.header]}),t.jsx("button",{type:"button",onClick:et,disabled:!R&&!P,className:"rounded px-1.5 py-0.5 text-xs font-medium text-[var(--primary)] transition-colors hover:bg-[var(--bg-input)] disabled:opacity-40",children:"Limpiar"})]}),p.sortKey&&t.jsxs("div",{className:"grid grid-cols-2 gap-1 border-b border-[var(--border)] p-1",children:[t.jsxs("button",{type:"button",onClick:()=>fr({key:p.key,dir:"asc"}),className:"flex min-w-0 items-center justify-between rounded-md px-2 py-1.5 text-left text-sm transition-colors hover:bg-[var(--bg-input)]",style:{color:"var(--text-main)"},children:[t.jsxs("span",{className:"flex min-w-0 items-center gap-1.5 truncate",children:[t.jsx(q.HiChevronUp,{className:"h-4 w-4 shrink-0 text-[var(--primary)]"}),t.jsx("span",{className:"truncate",children:"Ascendente"})]}),(Xe==null?void 0:Xe.key)===p.key&&Xe.dir==="asc"&&t.jsx(q.HiCheck,{className:"h-4 w-4 shrink-0 text-[var(--primary)]"})]}),t.jsxs("button",{type:"button",onClick:()=>fr({key:p.key,dir:"desc"}),className:"flex min-w-0 items-center justify-between rounded-md px-2 py-1.5 text-left text-sm transition-colors hover:bg-[var(--bg-input)]",style:{color:"var(--text-main)"},children:[t.jsxs("span",{className:"flex min-w-0 items-center gap-1.5 truncate",children:[t.jsx(q.HiChevronDown,{className:"h-4 w-4 shrink-0 text-[var(--primary)]"}),t.jsx("span",{className:"truncate",children:"Descendente"})]}),(Xe==null?void 0:Xe.key)===p.key&&Xe.dir==="desc"&&t.jsx(q.HiCheck,{className:"h-4 w-4 shrink-0 text-[var(--primary)]"})]})]}),t.jsxs("div",{className:"border-b border-[var(--border)] p-2",children:[t.jsxs("div",{className:"grid grid-cols-[minmax(0,1.05fr)_minmax(0,0.95fr)] gap-2",children:[t.jsx(ar,{value:(P==null?void 0:P.operator)??"",onChange:ve=>{if(!ve){di(p.key);return}ma(p.key,{operator:ve,value:(P==null?void 0:P.value)??"",valueTo:(P==null?void 0:P.valueTo)??""})},options:Cc,placeholder:"Opcion",emptyLabel:"Sin condicion",ariaLabel:"Operador de filtro",searchable:!1,height:34,padding:"0 9px",dropdownMinWidth:260,className:"min-w-0 [&>button]:rounded-md [&>button]:text-sm [&>button]:font-medium"}),(ne==null?void 0:ne.valueMode)!=="none"?t.jsx("input",{value:(P==null?void 0:P.value)??"",onChange:ve=>{P&&ma(p.key,{...P,value:ve.target.value})},disabled:!P,placeholder:"Valor",className:"min-w-0 rounded-md border px-2 py-1.5 text-sm outline-none transition-colors placeholder:text-[var(--text-muted)] focus:border-[var(--primary)] disabled:opacity-50",style:{borderColor:"var(--border)",background:"var(--bg-input)",color:"var(--text-main)"}}):t.jsx("div",{className:"min-h-8 rounded-md border px-2 py-1.5 text-sm text-[var(--text-muted)]",style:{borderColor:"var(--border)",background:"var(--bg-input)"},children:"Automatico"})]}),(ne==null?void 0:ne.valueMode)==="between"&&t.jsx("input",{value:(P==null?void 0:P.valueTo)??"",onChange:ve=>{P&&ma(p.key,{...P,valueTo:ve.target.value})},placeholder:"Valor final",className:"mt-2 w-full rounded-md border px-2 py-1.5 text-xs outline-none transition-colors placeholder:text-[var(--text-muted)] focus:border-[var(--primary)]",style:{borderColor:"var(--border)",background:"var(--bg-input)",color:"var(--text-main)"}})]}),t.jsx("div",{className:"border-b border-[var(--border)] p-2",children:t.jsxs("div",{className:"flex items-center gap-1 rounded-md border px-2 py-1.5 text-sm",style:{borderColor:"var(--border)",background:"var(--bg-input)"},children:[t.jsx(q.HiMagnifyingGlass,{className:"h-4 w-4 shrink-0 text-[var(--text-muted)]"}),t.jsx("input",{value:Jt,onChange:ve=>oa(ve.target.value),placeholder:"Buscar",className:"min-w-0 flex-1 bg-transparent text-sm outline-none placeholder:text-[var(--text-muted)]",style:{color:"var(--text-main)"}})]})}),t.jsxs("div",{className:"overflow-auto py-1",style:{maxHeight:"max(96px, calc(var(--dt-column-menu-max-height, 520px) - 236px))"},children:[t.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":qe?"mixed":!!Pe,onClick:()=>{p&&(Pe&&!R?ci(p.key,[]):Mo(p.key))},className:"flex w-full min-w-0 items-center gap-2 rounded-md px-2.5 py-1.5 text-left transition-colors hover:bg-[var(--bg-input)]",style:{color:"var(--text-main)"},children:[t.jsxs("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center rounded border",style:{borderColor:Pe||qe?"var(--primary)":"var(--border)",background:Pe||qe?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:[qe&&t.jsx(q.HiMinus,{className:"h-3 w-3"}),Pe&&!qe&&t.jsx(q.HiCheck,{className:"h-3 w-3"})]}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:"Seleccionar todo"})]}),Ce.map(ve=>{const Ee=!R||me.includes(ve.value);return t.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":Ee,onClick:()=>Wb(p.key,ve.value,M.map(Ne=>Ne.value),R),className:"flex w-full min-w-0 items-center gap-2 rounded-md px-2.5 py-1.5 text-left transition-colors hover:bg-[var(--bg-input)]",style:{color:"var(--text-main)"},children:[t.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center rounded border",style:{borderColor:Ee?"var(--primary)":"var(--border)",background:Ee?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:Ee&&t.jsx(q.HiCheck,{className:"h-3 w-3"})}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:ve.label})]},ve.value)}),Ce.length===0&&t.jsx("div",{className:"px-3 py-3 text-sm text-[var(--text-muted)]",children:"Sin valores"})]})]}):null}),document.body)};o.useEffect(()=>{if(!mn)return;function p(M){So.current&&!So.current.contains(M.target)&&ca.current&&!ca.current.contains(M.target)&&ia(!1)}return document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[mn]);function Ci(p,M){if(p.filterValue){const R=p.filterValue(M);return R==null||R===""?"":Cn(R)}return Cn(gr(p.cell(M)))}function Ei(p){return`"${Cn(p).replace(/"/g,'""')}"`}function ka(p){return Cn(p).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function Mi(){return Bt&&Ut>br.length&&Ma.toast.warning(`Exportando ${br.length.toLocaleString("es-MX")} de ${Ut.toLocaleString("es-MX")} (página actual). Usa exportación completa si está disponible.`),br}function sm(){const p=wt.filter(Pe=>!or(Pe)),M=Mi(),R=p.map(Pe=>Ei(gr(Pe.header))).join(","),P=M.map(Pe=>p.map(qe=>Ei(Ci(qe,Pe))).join(",")).join(`
|
|
5
5
|
`),ne=`${R}
|
|
6
|
-
${P}`,me=new Blob(["\uFEFF"+ne],{type:"text/csv;charset=utf-8;"}),ke=URL.createObjectURL(me),Ce=document.createElement("a");Ce.href=ke,Ce.download=`${It}.csv`,document.body.appendChild(Ce),Ce.click(),document.body.removeChild(Ce),URL.revokeObjectURL(ke)}function
|
|
6
|
+
${P}`,me=new Blob(["\uFEFF"+ne],{type:"text/csv;charset=utf-8;"}),ke=URL.createObjectURL(me),Ce=document.createElement("a");Ce.href=ke,Ce.download=`${It}.csv`,document.body.appendChild(Ce),Ce.click(),document.body.removeChild(Ce),URL.revokeObjectURL(ke)}function lm(){const p=wt.filter(Ce=>!or(Ce)),M=Mi(),R=p.map(Ce=>ka(gr(Ce.header))),ne=M.map(Ce=>p.map(Pe=>ka(Ci(Pe,Ce)))).map(Ce=>`<tr>${Ce.map(Pe=>`<td>${Pe}</td>`).join("")}</tr>`).join(""),me=`<!DOCTYPE html>
|
|
7
7
|
<html lang="es"><head><meta charset="utf-8"><title>${ka(It)}</title>
|
|
8
8
|
<style>
|
|
9
9
|
body{font-family:system-ui,sans-serif;font-size:11px;margin:20px;color:#111}
|
|
@@ -16,19 +16,19 @@ ${P}`,me=new Blob(["\uFEFF"+ne],{type:"text/csv;charset=utf-8;"}),ke=URL.createO
|
|
|
16
16
|
@media print{body{margin:0}@page{margin:1cm}}
|
|
17
17
|
</style></head><body>
|
|
18
18
|
<h3>${ka(It)}</h3>
|
|
19
|
-
<p>${
|
|
19
|
+
<p>${M.length} registros · ${new Date().toLocaleDateString("es")}</p>
|
|
20
20
|
<table><thead><tr>${R.map(Ce=>`<th>${Ce}</th>`).join("")}</tr></thead>
|
|
21
21
|
<tbody>${ne}</tbody></table>
|
|
22
22
|
<script>window.onload=()=>{window.print()}<\/script>
|
|
23
|
-
</body></html>`,ke=window.open("","_blank");ke&&(ke.document.write(me),ke.document.close())}const Sa=()=>!Re||!mn?null:ct.createPortal(t.jsxs("div",{ref:
|
|
24
|
-
`).map(ke=>ke.trim()).filter(Boolean)).has(ne):!1}).slice(0,8);return!ae&&Co===0&&!Y&&!Re?null:t.jsxs("div",{className:"relative flex min-h-9 flex-wrap items-center justify-between gap-2 border-b rounded-t-lg px-2 py-1",style:{borderColor:"var(--border)",background:"var(--bg-input)"},children:[t.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[Co>0&&t.jsxs("button",{type:"button",onClick:Wb,className:"inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs font-medium text-[var(--primary)] transition-colors hover:bg-[var(--bg-card)]",children:[t.jsx(q.HiXMark,{className:"h-3.5 w-3.5"}),Co," filtros"]}),Y&&t.jsxs("div",{ref:wo,className:"relative flex min-w-0 flex-1 items-center gap-2",children:[t.jsxs("button",{type:"button",onClick:()=>{if(ot){it(!1);return}ha(),it(!0)},className:"inline-flex h-7 shrink-0 items-center gap-1.5 rounded-md border px-2 text-xs font-bold transition-colors",style:{background:ot?"var(--primary)":p?"color-mix(in srgb, var(--primary) 12%, transparent)":"var(--bg-card)",borderColor:ot||p?"var(--primary)":"var(--border)",color:ot?"var(--primary-fg)":"var(--primary)"},"aria-expanded":ot,title:"Abrir filtros BQL",children:[t.jsx(q.HiCommandLine,{className:"h-3.5 w-3.5"}),"BQL",p&&t.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-current"}),ot?t.jsx(q.HiChevronUp,{className:"h-3.5 w-3.5"}):t.jsx(q.HiChevronDown,{className:"h-3.5 w-3.5"})]}),t.jsx("span",{className:"hidden truncate text-xs text-[var(--text-muted)] sm:inline",children:re}),E.length>0&&t.jsxs("div",{className:"hidden min-w-0 items-center gap-1.5 overflow-hidden lg:flex",children:[E.slice(0,3).map(P=>t.jsxs("span",{className:"inline-flex max-w-44 items-center gap-1 truncate rounded-full px-2 py-1 text-xs font-medium",style:{background:"var(--bg-hover)",border:"1px solid var(--primary)",color:"var(--primary)"},children:[t.jsxs("span",{className:"text-[var(--text-muted)]",children:[P.label,":"]}),t.jsx("span",{className:"truncate",children:P.value})]},P.key)),E.length>3&&t.jsxs("span",{className:"text-xs text-[var(--text-muted)]",children:["+",E.length-3]})]}),p&&t.jsx("button",{type:"button","aria-label":"Limpiar BQL",title:"Limpiar BQL",onClick:ui,className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-[var(--text-muted)] transition-colors hover:bg-[var(--bg-card)] hover:text-[var(--primary)]",children:t.jsx(q.HiXMark,{className:"h-4 w-4"})}),ot&&ct.createPortal(t.jsxs("div",{ref:Jl,className:"flex flex-col gap-3 rounded-lg p-3 shadow-2xl",style:{...Sb,background:"var(--bg-card)",border:"1px solid color-mix(in srgb, var(--primary) 35%, var(--border))"},children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[de.map(P=>t.jsxs("button",{type:"button",onMouseDown:ne=>{ne.preventDefault(),ne.stopPropagation()},onClick:ne=>{ne.preventDefault(),ne.stopPropagation(),pa(P.bql)},className:"inline-flex h-7 items-center gap-1.5 rounded-md border px-2.5 text-xs font-semibold transition-colors hover:border-[var(--primary)] hover:text-[var(--primary)]",style:{background:"var(--bg-input)",borderColor:"var(--border)",color:"var(--text-secondary)"},children:[P.icon,P.label]},P.label)),he.length>0&&t.jsxs("button",{type:"button",onClick:()=>qt(P=>!P),className:"inline-flex h-7 items-center gap-1.5 rounded-md px-2 text-xs font-medium text-[var(--text-muted)] transition-colors hover:bg-[var(--bg-input)] hover:text-[var(--primary)]","aria-expanded":cr,children:[t.jsx(q.HiInformationCircle,{className:"h-3.5 w-3.5"}),"Ejemplos"]}),bn.length>0&&t.jsxs("button",{type:"button",onClick:()=>Hr(P=>!P),className:"inline-flex h-7 items-center gap-1.5 rounded-md px-2 text-xs font-medium text-[var(--text-muted)] transition-colors hover:bg-[var(--bg-input)] hover:text-[var(--primary)]","aria-expanded":fn,children:[t.jsx(q.HiClock,{className:"h-3.5 w-3.5"}),"Historial"]})]}),t.jsxs("div",{className:"overflow-hidden rounded-lg",style:{background:"var(--bg-input)",border:`1.5px solid ${Me?"var(--danger)":p?"var(--primary)":"var(--border)"}`},children:[t.jsx("textarea",{ref:No,value:Ze,rows:3,onChange:P=>Mo(P.target.value,P.target),onKeyDown:P=>{P.key==="Enter"&&!P.shiftKey&&(P.preventDefault(),di(Ze)),P.key==="Escape"&&it(!1)},placeholder:z,autoComplete:"off",spellCheck:!1,className:"block w-full px-4 py-3 text-sm outline-none",style:{background:"var(--bg-input)",color:"var(--text-main)",border:"none",fontFamily:"'SF Mono', 'Fira Code', 'Consolas', monospace",lineHeight:1.6,maxHeight:180,minHeight:88,overflowY:"auto",resize:"vertical"}}),R.length>0&&t.jsx("div",{className:"border-t border-[var(--border)] bg-[var(--bg-card)]",children:R.map(P=>t.jsx("button",{type:"button",onMouseDown:ne=>{ne.preventDefault(),ne.stopPropagation()},onClick:ne=>{ne.preventDefault(),ne.stopPropagation(),pa(P)},className:"block w-full px-4 py-2 text-left text-xs transition-colors hover:bg-[var(--bg-hover)] hover:text-[var(--primary)]",style:{fontFamily:"'SF Mono', 'Fira Code', 'Consolas', monospace"},children:P},P))})]}),t.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[t.jsx("span",{className:"min-w-0 text-xs",style:{color:Me?"var(--danger)":"var(--text-muted)"},children:Me??(p?`${E.length||1} filtro${(E.length||1)===1?"":"s"} activo${(E.length||1)===1?"":"s"}`:"Enter aplica la consulta. Shift + Enter agrega linea.")}),E.map(P=>t.jsxs("span",{className:"inline-flex max-w-56 items-center gap-1 truncate rounded-full px-2 py-1 text-xs font-medium",style:{background:"var(--bg-hover)",border:"1px solid var(--primary)",color:"var(--primary)"},children:[t.jsxs("span",{className:"text-[var(--text-muted)]",children:[P.label,":"]}),t.jsx("span",{className:"truncate",children:P.value})]},P.key))]}),fn&&bn.length>0&&t.jsxs("div",{className:"overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-input)]",children:[t.jsxs("div",{className:"flex items-center justify-between border-b border-[var(--border)] px-3 py-2",children:[t.jsxs("span",{className:"flex items-center gap-1.5 text-xs font-semibold text-[var(--text-secondary)]",children:[t.jsx(q.HiClock,{className:"h-3.5 w-3.5"}),"Historial"]}),t.jsxs("button",{type:"button",onClick:()=>{Br([]),Hr(!1)},className:"inline-flex items-center gap-1 rounded px-2 py-0.5 text-xs text-[var(--text-muted)]",children:[t.jsx(q.HiTrash,{className:"h-3 w-3"}),"Limpiar"]})]}),bn.map(P=>t.jsxs("div",{className:"group flex items-center gap-2 border-b border-[var(--border)] px-3 py-2 last:border-b-0",children:[t.jsx("button",{type:"button",onMouseDown:ne=>{ne.preventDefault(),ne.stopPropagation()},onClick:ne=>{ne.preventDefault(),ne.stopPropagation(),pa(P)},className:"min-w-0 flex-1 text-left",children:t.jsx("code",{className:"block truncate text-xs text-[var(--primary)]",children:P})}),t.jsx("button",{type:"button",onClick:()=>Br(ne=>ne.filter(me=>me!==P)),className:"rounded p-1 text-[var(--text-muted)] opacity-0 transition-opacity group-hover:opacity-100",children:t.jsx(q.HiXMark,{className:"h-3.5 w-3.5"})})]},P))]}),cr&&he.length>0&&t.jsx("div",{className:"grid gap-2 sm:grid-cols-2 lg:grid-cols-3",children:he.map(P=>t.jsxs("button",{type:"button",onMouseDown:ne=>{ne.preventDefault(),ne.stopPropagation()},onClick:ne=>{ne.preventDefault(),ne.stopPropagation(),pa(P.bql),qt(!1)},className:"rounded-lg border border-[var(--border)] bg-[var(--bg-input)] p-2 text-left transition-colors hover:border-[var(--primary)]",children:[t.jsx("code",{className:"block truncate text-xs text-[var(--primary)]",children:P.bql}),P.description&&t.jsx("span",{className:"mt-1 block text-xs text-[var(--text-muted)]",children:P.description})]},P.bql))}),t.jsxs("div",{className:"flex items-center justify-end gap-2 border-t border-[var(--border)] pt-3",children:[p&&t.jsxs("button",{type:"button",onClick:ui,className:"inline-flex h-8 items-center gap-1 rounded-md px-2.5 text-xs font-medium text-[var(--text-muted)] transition-colors hover:bg-[var(--bg-input)] hover:text-[var(--primary)]",children:[t.jsx(q.HiXMark,{className:"h-3.5 w-3.5"}),"Limpiar"]}),t.jsxs("button",{type:"button",onClick:()=>di(Ze),className:"inline-flex h-8 items-center gap-1.5 rounded-md bg-[var(--primary)] px-4 text-xs font-semibold text-[var(--primary-fg)] transition-opacity hover:opacity-90",children:[t.jsx(q.HiCheck,{className:"h-3.5 w-3.5"}),"Aplicar"]})]})]}),document.body)]})]}),Re&&t.jsx("button",{ref:ca,type:"button","aria-haspopup":"menu","aria-expanded":mn,"aria-label":"Exportar datos",title:"Exportar datos",onClick:()=>{var ne;const P=(ne=ca.current)==null?void 0:ne.getBoundingClientRect();P&&$b({top:P.bottom+4,right:window.innerWidth-P.right}),ia(me=>!me)},className:`inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-[var(--text-muted)] transition-colors hover:bg-[var(--bg-card)] hover:text-[var(--primary)] focus:bg-[var(--bg-card)] focus:text-[var(--primary)] ${mn?"bg-[var(--bg-card)] text-[var(--primary)]":""}`,children:t.jsx(q.HiArrowDownTray,{className:"h-4 w-4"})}),ae&&t.jsx("button",{type:"button","aria-haspopup":"menu","aria-expanded":Ke&&Ae==="visibility","aria-label":K,title:K,onClick:P=>bi(P,"visibility"),className:`inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-[var(--text-muted)] transition-colors hover:bg-[var(--bg-card)] hover:text-[var(--primary)] focus:bg-[var(--bg-card)] focus:text-[var(--primary)] ${Ke&&Ae==="visibility"?"bg-[var(--bg-card)] text-[var(--primary)]":""}`,children:t.jsx(q.HiCog6Tooth,{className:"h-4 w-4"})})]})},Mi=()=>{if(!em)return null;const p=Oc(st,Ho);return t.jsxs("div",{"aria-busy":a,className:`grid grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)] items-center gap-2 rounded-b-xl border-t text-xs select-none ${J?"px-2 py-0.5":"px-3 py-1"}`,style:{borderColor:"var(--border)",background:"var(--bg-input)"},children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx("span",{style:{color:"var(--text-muted)"},children:Ut===0?"0 filas":`${tm}–${rm} de ${Ut}`}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("span",{style:{color:"var(--text-muted)"},children:"Filas:"}),t.jsx(ar,{value:String(Ft),onChange:E=>nm(Number(E)),options:Ao.map(E=>({value:String(E),label:String(E)})),placeholder:"Filas",searchable:!1,disabled:a,height:X,padding:Z,className:"shrink-0 [&>button]:rounded-md [&>button]:text-xs [&_svg]:h-3.5 [&_svg]:w-3.5",style:{width:W}})]})]}),t.jsxs("div",{className:"flex items-center justify-center gap-0.5",children:[t.jsx("button",{disabled:a||st<=1,onClick:()=>Bo(st-1),onMouseEnter:E=>{E.currentTarget.disabled||(E.currentTarget.style.background="color-mix(in srgb, var(--primary) 14%, var(--bg-card))",E.currentTarget.style.color="var(--primary)")},onMouseLeave:E=>{E.currentTarget.style.background="transparent",E.currentTarget.style.color="var(--text-muted)"},className:"cursor-pointer rounded p-0.5 transition-colors disabled:cursor-not-allowed disabled:opacity-30",style:{background:"transparent",color:"var(--text-muted)"},children:t.jsx(q.HiChevronLeft,{className:"h-3.5 w-3.5"})}),p.map((E,R)=>E==="..."?t.jsx("span",{className:"px-1",style:{color:"var(--text-muted)"},children:"…"},`e${R}`):t.jsx("button",{disabled:a,onClick:()=>Bo(E),onMouseEnter:P=>{P.currentTarget.disabled||E===st||(P.currentTarget.style.background="color-mix(in srgb, var(--primary) 14%, var(--bg-card))",P.currentTarget.style.color="var(--primary)")},onMouseLeave:P=>{P.currentTarget.style.background=E===st?"var(--primary)":"transparent",P.currentTarget.style.color=E===st?"var(--primary-fg)":"var(--text-muted)"},className:"h-5 w-5 cursor-pointer rounded text-[11px] font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-60",style:{background:E===st?"var(--primary)":"transparent",color:E===st?"var(--primary-fg)":"var(--text-muted)"},children:E},E)),t.jsx("button",{disabled:a||st>=Ho,onClick:()=>Bo(st+1),onMouseEnter:E=>{E.currentTarget.disabled||(E.currentTarget.style.background="color-mix(in srgb, var(--primary) 14%, var(--bg-card))",E.currentTarget.style.color="var(--primary)")},onMouseLeave:E=>{E.currentTarget.style.background="transparent",E.currentTarget.style.color="var(--text-muted)"},className:"cursor-pointer rounded p-0.5 transition-colors disabled:cursor-not-allowed disabled:opacity-30",style:{background:"transparent",color:"var(--text-muted)"},children:t.jsx(q.HiChevronRight,{className:"h-3.5 w-3.5"})})]}),t.jsx("div",{"aria-hidden":"true"})]})},lm=()=>t.jsxs("div",{className:"w-full min-w-0 max-w-full flex flex-col rounded-lg overflow-hidden",style:{background:"var(--bg-card)",boxShadow:ya},children:[Na(),Sa(),Ca(),t.jsx("div",{ref:Rt,className:"min-w-0 max-w-full overflow-hidden",children:t.jsxs("div",{role:"table",className:"text-sm",style:{width:gn,minWidth:xa},children:[t.jsx("div",{role:"rowgroup",style:y?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:wa()}),t.jsx("div",{role:"rowgroup",children:Array.from({length:Math.min(6,s)}).map((p,E)=>t.jsxs("div",{role:"row",className:"grid",style:{gridTemplateColumns:jr,borderBottom:`1px solid ${Oe}`},children:[Tt&&t.jsx("div",{role:"cell",className:`${J?"px-2 py-1.5":"px-3 py-2"} w-10`,style:{borderBottom:`1px solid ${Oe}`,borderRight:`1px solid ${Oe}`}},"select-cell"),wt.map((R,P)=>t.jsx("div",{role:"cell",className:J?"px-2 py-1.5":"px-3 py-2",style:{borderBottom:`1px solid ${Oe}`,borderRight:`1px solid ${Oe}`},children:t.jsx("div",{className:"h-3.5 rounded-full animate-pulse",style:{background:"var(--border)",width:`${ri(E,P)}%`,minWidth:32}})},R.key))]},E))})]})})]}),Po="min-w-0 max-w-full overflow-hidden";return te&&Fe&&!bt?t.jsx(wn,{rows:s,columns:Math.max(4,wt.length||7)}):!a&&r.length===0&&!So?lm():a&&r.length===0?t.jsxs("div",{className:"w-full min-w-0 max-w-full flex flex-col rounded-lg overflow-hidden",style:{background:"var(--bg-card)",boxShadow:ya},children:[Na(),Sa(),Ca(),t.jsx("div",{ref:Rt,className:Po,children:t.jsx(_o.OverlayScrollbarsComponent,{options:{scrollbars:{autoHide:"leave",autoHideDelay:200}},className:"w-full",style:{maxHeight:ai,maxWidth:"100%"},defer:!0,children:t.jsxs("div",{role:"table",className:"text-sm",style:{width:gn,minWidth:xa},children:[t.jsx("div",{role:"rowgroup",style:y?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:wa()}),t.jsx("div",{role:"rowgroup",children:Array.from({length:s}).map((p,E)=>t.jsxs("div",{role:"row",className:"grid",style:{gridTemplateColumns:jr,borderBottom:`1px solid ${Oe}`},children:[Tt&&t.jsx("div",{role:"cell",className:`${J?"px-2 py-1.5":"px-3 py-2"} w-10`,style:{borderBottom:`1px solid ${Oe}`,borderRight:`1px solid ${Oe}`}},"select-cell"),wt.map((R,P)=>{const ne=ga[R.key],me=ne!==void 0,ke=R.key===Oo;return t.jsx("div",{role:"cell","data-dt-column-key":R.key,className:J?"px-2 py-1.5":"px-3 py-2",style:me?{position:"sticky",left:ne,zIndex:1,background:"color-mix(in srgb, var(--bg-card) 72%, transparent)",backdropFilter:"blur(10px)",WebkitBackdropFilter:"blur(10px)",boxShadow:ke?`3px 0 6px -2px rgba(0,0,0,0.10), inset 0 -1px 0 ${Oe}`:`inset 0 -1px 0 ${Oe}`,borderRight:`1px solid ${Oe}`}:{borderBottom:`1px solid ${Oe}`,borderRight:`1px solid ${Oe}`},children:t.jsx("div",{className:"h-3.5 rounded-full animate-pulse",style:{background:"var(--border)",width:`${ri(E,P)}%`,minWidth:32}})},R.key)})]},E))})]})})}),Mi()]}):!a&&r.length===0?t.jsxs("div",{className:"w-full min-w-0 max-w-full flex flex-col rounded-lg overflow-hidden",style:{background:"var(--bg-card)",boxShadow:ya},children:[Na(),Sa(),Ca(),t.jsx("div",{ref:Rt,className:Po,children:t.jsx("div",{role:"table",className:"text-sm",style:{width:gn,minWidth:xa},children:t.jsx("div",{role:"rowgroup",style:y?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:wa()})})}),t.jsxs("div",{className:"flex min-h-[180px] flex-col items-center justify-center gap-3 border-t px-6 py-12 text-center",style:{borderColor:Oe,background:"linear-gradient(180deg, color-mix(in srgb, var(--bg-input) 58%, transparent), var(--bg-card))"},children:[t.jsx("div",{className:"flex h-12 w-12 items-center justify-center rounded-full border",style:{borderColor:"color-mix(in srgb, var(--primary) 24%, var(--border))",background:"color-mix(in srgb, var(--primary) 8%, var(--bg-card))",color:"var(--primary)"},children:l??t.jsx(q.HiMagnifyingGlass,{className:"h-5 w-5"})}),t.jsx("p",{className:"max-w-sm text-sm font-medium",style:{color:"var(--text-main)"},children:i}),t.jsx("span",{className:"text-xs",style:{color:"var(--text-muted)"},children:"Ajusta la busqueda o cambia los filtros para ver mas informacion."})]})]}):t.jsxs("div",{className:"w-full min-w-0 max-w-full flex flex-col rounded-lg overflow-hidden",style:{background:"var(--bg-card)",boxShadow:ya},children:[Na(),Sa(),Ca(),t.jsx("div",{ref:Rt,className:Po,children:t.jsx(_o.OverlayScrollbarsComponent,{options:{scrollbars:{autoHide:"leave",autoHideDelay:200}},className:"w-full",style:{maxHeight:ai,maxWidth:"100%"},defer:!0,children:t.jsxs("div",{role:"table",className:"text-sm",style:{width:gn,minWidth:xa},children:[t.jsx("div",{role:"rowgroup",style:y?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:wa()}),t.jsx("div",{role:"rowgroup",children:vi.map((p,E)=>{const R=n(p),P=ki(x==null?void 0:x(p)),ne=E>0?ki(x==null?void 0:x(vi[E-1])):null,me=P&&P.key!==(ne==null?void 0:ne.key),ke=Tt&&k.has(R),Ce=Tt&&(!$||$(p)),Pe=Wr?(m==null?void 0:m(p))??!0:!1,qe=Pe&&hi.has(R),mt=!!d||v&&Pe,et=ke&&N?"color-mix(in srgb, var(--primary) 8%, var(--bg-card))":E%2===1?"color-mix(in srgb, var(--bg-input) 30%, var(--bg-card))":"var(--bg-card)";return t.jsxs(o.Fragment,{children:[me&&t.jsx("div",{role:"row",className:`grid ${P.className??""}`,style:{gridTemplateColumns:jr},children:t.jsx("div",{role:"cell",className:J?"px-2 py-2":"px-3 py-3",style:{gridColumn:"1 / -1",background:"color-mix(in srgb, var(--primary) 8%, var(--bg-input))",borderBottom:`1px solid ${Oe}`,borderRight:`1px solid ${Oe}`},children:t.jsx("div",{className:"flex min-w-0 items-center justify-between gap-3",children:t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"truncate text-xs font-semibold uppercase tracking-wider text-[var(--text-main)]",children:P.label}),P.description&&t.jsx("div",{className:"mt-0.5 truncate text-xs text-[var(--text-muted)]",children:P.description})]})})})}),t.jsxs("div",{role:"row",onClick:mt?ve=>{const Ee=ve.target;if(!(Ee!=null&&Ee.closest('[data-dt-disable-row-click="true"]'))){if(v&&Pe){yi(R);return}d==null||d(p)}}:void 0,className:`grid transition-colors ${mt?"cursor-pointer":""} ${T?T(p):""}`,style:{gridTemplateColumns:jr,"--dt-row-bg":et,"--dt-sticky-bg":et,background:"var(--dt-row-bg)",borderBottom:`1px solid ${Oe}`},onMouseEnter:ve=>{ke||(ve.currentTarget.style.setProperty("--dt-row-bg","var(--bg-hover)"),ve.currentTarget.style.setProperty("--dt-sticky-bg",am))},onMouseLeave:ve=>{ve.currentTarget.style.setProperty("--dt-row-bg",et),ve.currentTarget.style.setProperty("--dt-sticky-bg",et)},children:[Wr&&t.jsx("div",{role:"cell",className:`${J?"px-2 py-1.5":"px-3 py-2"} flex w-10 items-center justify-center`,style:{borderBottom:`1px solid ${Oe}`,borderRight:`1px solid ${Oe}`},"data-dt-disable-row-click":"true",children:Pe&&t.jsx("button",{type:"button","aria-label":qe?"Contraer fila":"Desplegar fila","aria-expanded":qe,onClick:ve=>{ve.stopPropagation(),yi(R)},className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-[var(--text-muted)] transition-colors hover:bg-[var(--bg-input)] hover:text-[var(--primary)]",children:qe?t.jsx(q.HiChevronDown,{className:"h-4 w-4"}):t.jsx(q.HiChevronRight,{className:"h-4 w-4"})})}),Tt&&t.jsx("div",{role:"cell",className:`${J?"px-2 py-1.5":"px-3 py-2"} flex w-10 items-center justify-center`,style:Do?{position:"sticky",left:0,zIndex:3,background:"var(--dt-sticky-bg)",boxShadow:`inset 0 -1px 0 ${Oe}`}:{borderBottom:`1px solid ${Oe}`,borderRight:`1px solid ${Oe}`},onClick:ve=>{ve.stopPropagation(),Ce&&g(R)},children:t.jsx(Nn,{size:"sm",checked:ke,disabled:!Ce,"aria-label":Ce?"Seleccionar fila":"Fila no seleccionable",containerClassName:"items-center",className:Ce?"cursor-pointer":"cursor-not-allowed opacity-50",onClick:ve=>ve.stopPropagation(),onChange:()=>{Ce&&g(R)}})}),wt.map(ve=>{const Ee=ga[ve.key],Ne=Ee!==void 0,xe=ve.key===Oo,we=or(ve);return t.jsx("div",{role:"cell","data-dt-column-key":ve.key,"data-dt-disable-row-click":ve.disableRowClick||we?"true":void 0,className:`${we?"px-2 py-1.5 justify-center text-center":`${J?"px-2 py-1.5":"px-3 py-2"} ${xi(ve.align)}`} flex min-w-0 items-center ${Tc} ${ve.className??""}`,style:{overflow:"hidden",whiteSpace:"nowrap",...Ne?{position:"sticky",left:Ee,zIndex:3,background:"var(--dt-sticky-bg)",boxShadow:xe?`3px 0 6px -2px rgba(0,0,0,0.10), inset 0 -1px 0 ${Oe}`:`inset 0 -1px 0 ${Oe}`,borderRight:`1px solid ${Oe}`}:{borderBottom:`1px solid ${Oe}`,borderRight:`1px solid ${Oe}`}},children:t.jsx(ss,{children:t.jsx("div",{"data-dt-autofit-content":!0,className:"inline-block max-w-none align-middle",children:ve.cell(p)})})},ve.key)})]}),qe&&u&&t.jsx("div",{role:"row",className:"grid",style:{gridTemplateColumns:jr},children:t.jsx("div",{role:"cell",className:J?"px-2 py-2":"px-3 py-3",style:{gridColumn:"1 / -1",background:"color-mix(in srgb, var(--bg-input) 60%, var(--bg-card))",borderBottom:`1px solid ${Oe}`},children:u(p)})})]},R)})})]})})}),Mi()]})}const Fc={email:{pattern:/^[^\s@]+@[^\s@]+\.[^\s@]+$/,message:"Correo inválido"},integer:{pattern:/^-?\d+$/,message:"Debe ser un número entero"},date:{pattern:/^\d{4}-\d{2}-\d{2}$/,message:"Fecha inválida"}};function Pc(e,r){if(r.minLength!==void 0&&e.length<r.minLength)return r.message??`Mínimo ${r.minLength} caracteres`;if(r.maxLength!==void 0&&e.length>r.maxLength)return r.message??`Máximo ${r.maxLength} caracteres`;if(!e)return null;if(r.preset){const n=Fc[r.preset];if(!n.pattern.test(e))return r.message??n.message}return r.pattern&&!r.pattern.test(e)?r.message??"Formato inválido":null}const _c=new Set(["Backspace","Delete","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Tab","Home","End","Enter","Escape"]);function zc({initialValue:e,type:r,mask:n,onCommit:a,onCancel:s}){const[l,i]=o.useState(e),c=o.useRef(null),d=(n==null?void 0:n.preset)==="date",u=d?"date":r==="number"?"number":"text";return o.useEffect(()=>{var m,b;(m=c.current)==null||m.focus(),d||(b=c.current)==null||b.select()},[d]),t.jsx("input",{ref:c,type:u,value:l,maxLength:n==null?void 0:n.maxLength,onChange:m=>i(m.target.value),onBlur:()=>s(),onKeyDown:m=>{m.key==="Enter"&&(m.preventDefault(),a(l)),m.key==="Escape"&&(m.preventDefault(),s()),(n==null?void 0:n.preset)==="integer"&&!m.ctrlKey&&!m.metaKey&&!_c.has(m.key)&&!/^[\d-]$/.test(m.key)&&m.preventDefault()},onClick:m=>m.stopPropagation(),className:"w-full min-w-0 border-0 bg-transparent p-0 text-sm text-[var(--text-main)] outline-none"})}function Wc({initialValue:e,options:r,loading:n,onCommit:a,onCancel:s}){const l=o.useRef(null);return o.useEffect(()=>{if(n)return;const i=setTimeout(()=>{var c,d;(d=(c=l.current)==null?void 0:c.querySelector("button"))==null||d.click()},0);return()=>clearTimeout(i)},[n]),t.jsx("div",{ref:l,className:"w-full",tabIndex:-1,onKeyDown:i=>{i.key==="Escape"&&(i.stopPropagation(),s())},children:t.jsx(ar,{value:e,onChange:i=>{a(i)},options:r,disabled:n,placeholder:n?"Cargando…":"Seleccionar…",triggerVariant:"ghost",height:30,padding:"0 6px",minOptionsForSearch:1,className:"w-full"})})}const jc={outline:"2px solid var(--primary)",outlineOffset:"-2px",borderRadius:"4px",background:"color-mix(in srgb, var(--primary) 5%, var(--bg-card))"},Pa={outline:"2px solid var(--primary)",outlineOffset:"-2px",borderRadius:"4px"};function qc({columns:e,data:r,getRowId:n,onCellUpdate:a,readOnly:s=!1,...l}){const[i,c]=o.useState(r),d=o.useRef(null);o.useEffect(()=>{d.current||c(r)},[r]);const[u,m]=o.useState(null);d.current=u;const[b,f]=o.useState(null),h=o.useRef(null);h.current=b;const[v,k]=o.useState({}),[g,A]=o.useState(null),$=o.useRef(null);$.current=g;const[N,T]=o.useState({}),[x,y]=o.useState({}),L=o.useRef(new Set),w=o.useRef(null);o.useEffect(()=>{var _;const C=document.activeElement;(!C||C===document.body)&&((_=w.current)==null||_.focus({preventScroll:!0}))},[]);const W=e.map(C=>{var _,ae,B;return`${C.key}:${((B=(ae=(_=C.editable)==null?void 0:_.select)==null?void 0:ae.options)==null?void 0:B.length)??-1}`}).join("|");o.useEffect(()=>{e.forEach(C=>{var B,I;const _=(I=(B=C.editable)==null?void 0:B.select)==null?void 0:I.options;if(!_)return;const ae=N[C.key];(!L.current.has(C.key)||(ae==null?void 0:ae.length)===0&&_.length>0)&&(L.current.add(C.key),T(M=>({...M,[C.key]:_})))})},[W]);const X=o.useCallback(async(C,_)=>{if(L.current.has(C))return;L.current.add(C);const{url:ae,fetchOptions:B}=_.select??{};if(!(!ae&&!B)){y(I=>({...I,[C]:!0}));try{let I=[];if(B)I=await B();else if(ae){const M=await fetch(ae);if(!M.ok)throw new Error("fetch failed");I=await M.json()}T(M=>({...M,[C]:I}))}catch{T(I=>({...I,[C]:[]}))}finally{y(I=>({...I,[C]:!1}))}}},[]),Z=o.useRef(i);Z.current=i;const D=o.useRef(a);D.current=a;const Q=o.useRef(n);Q.current=n;const j=o.useRef(e);j.current=e;const se=o.useRef(s);se.current=s,o.useEffect(()=>{if(e.length>0&&r.length>0){const C=e.find(_=>_.selectable!==!1);C&&f({rowId:n(r[0]),colKey:C.key})}},[]),o.useEffect(()=>{if(!b)return;const C=w.current;if(!C)return;const _=C.querySelector(`[data-cell-id="${b.rowId}:${b.colKey}"]`);if(!_)return;const ae=C.querySelector('[role="rowgroup"]');_.style.scrollMarginTop=`${(ae==null?void 0:ae.offsetHeight)??0}px`;const B=C.querySelector('[role="row"]');let I=0;B&&B.querySelectorAll('[role="cell"], [role="columnheader"]').forEach(M=>{M.style.position==="sticky"&&M.style.left!==""&&(I=Math.max(I,parseFloat(M.style.left)+M.offsetWidth))}),_.style.scrollMarginLeft=`${I}px`,_.scrollIntoView({block:"nearest",inline:"nearest"})},[b]);const te=o.useCallback(C=>{var I;const _=j.current,ae=new Set,B=[];(I=w.current)==null||I.querySelectorAll("[data-cell-id]").forEach(M=>{const oe=M.dataset.cellId.split(":")[0];ae.has(oe)||(ae.add(oe),B.push(oe))}),f(M=>{if(!M)return M;const oe=_.findIndex(H=>H.key===M.colKey),K=B.indexOf(M.rowId);let Y=oe,S=K;if(C==="up")S=Math.max(0,K-1);else if(C==="down")S=Math.min(B.length-1,K+1);else if(C==="left"){let H=oe-1;for(;H>=0&&_[H].selectable===!1;)H--;H>=0&&(Y=H)}else if(C==="right"){let H=oe+1;for(;H<_.length&&_[H].selectable===!1;)H++;H<_.length&&(Y=H)}return Y===oe&&S===K?M:{rowId:B[S],colKey:_[Y].key}})},[]),ee=o.useCallback((C=!0)=>{const _=d.current;m(null),_&&f(_),C&&setTimeout(()=>{var ae;return(ae=w.current)==null?void 0:ae.focus({preventScroll:!0})},0)},[]),U=o.useCallback(async(C,_,ae)=>{var ie;const B=j.current.find(ge=>ge.key===_);if(!(B!=null&&B.editable))return;const{field:I,type:M,mask:oe,validate:K}=B.editable,Y=M==="number"?ae===""?null:Number(ae):ae;if(oe){const ge=Pc(ae,oe);if(ge){k(Me=>({...Me,[`${C}:${_}`]:ge}));return}}if(K){const ge=K(Y);if(ge){k(Me=>({...Me,[`${C}:${_}`]:ge}));return}}const S=Q.current,H=Z.current.find(ge=>S(ge)===C);if(!H)return;const O=H[I];m(null),k(ge=>{const Me={...ge};return delete Me[`${C}:${_}`],Me});const re=Z.current,z=re.findIndex(ge=>S(ge)===C),de=re[Math.min(re.length-1,z+1)];if(f({rowId:S(de),colKey:_}),setTimeout(()=>{var Me,$e;const ge=document.activeElement;(!ge||ge===document.body||(Me=w.current)!=null&&Me.contains(ge))&&(($e=w.current)==null||$e.focus({preventScroll:!0}))},0),String(O??"")===String(Y??""))return;const he={...H,[I]:Y};c(ge=>ge.map(Me=>S(Me)===C?he:Me)),A({rowId:C,colKey:_});try{await((ie=D.current)==null?void 0:ie.call(D,{row:H,rowId:C,field:I,oldValue:O,newValue:Y}))}catch{c(ge=>ge.map(Me=>S(Me)===C?H:Me)),k(ge=>({...ge,[`${C}:${_}`]:"Error al guardar. Intenta de nuevo."}))}finally{A(null)}},[]),J=o.useCallback(C=>{if($.current){C.preventDefault();return}if(d.current)return;const _=h.current;if(!(!_||!["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Enter","Escape","Tab"].includes(C.key)))switch(C.preventDefault(),C.key){case"ArrowUp":te("up");break;case"ArrowDown":te("down");break;case"ArrowLeft":te("left");break;case"ArrowRight":te("right");break;case"Tab":te(C.shiftKey?"left":"right");break;case"Enter":{const B=j.current.find(I=>I.key===_.colKey);B!=null&&B.editable&&!se.current?(m(_),B.editable.type==="select"&&!L.current.has(_.colKey)&&X(_.colKey,B.editable)):te("down");break}}},[te,X]),ce=o.useMemo(()=>e.map(C=>{if(!C.editable||s){const ae={...C};if(delete ae.editable,delete ae.selectable,C.selectable===!1)return{...ae,disableRowClick:!0};const B=ae.cell;return{...ae,className:`relative ${ae.className??""}`.trim(),disableRowClick:!0,cell:I=>{const M=n(I),oe=(b==null?void 0:b.rowId)===M&&(b==null?void 0:b.colKey)===C.key;return t.jsxs(t.Fragment,{children:[t.jsx("span",{"data-cell-id":`${M}:${C.key}`,className:"absolute inset-0 z-10 cursor-default",onClick:()=>{var K;$.current||(f({rowId:M,colKey:C.key}),(K=w.current)==null||K.focus({preventScroll:!0}))}}),oe&&t.jsx("div",{className:"pointer-events-none absolute inset-0 z-20",style:Pa}),t.jsx("span",{className:"relative z-0 pointer-events-none",children:B(I)})]})}}}const _=C.editable;return{...C,className:`relative ${C.className??""}`.trim(),disableRowClick:!0,cell:ae=>{const B=n(ae),I=C.key,M=(u==null?void 0:u.rowId)===B&&(u==null?void 0:u.colKey)===I,oe=(b==null?void 0:b.rowId)===B&&(b==null?void 0:b.colKey)===I,K=v[`${B}:${I}`],Y=(g==null?void 0:g.rowId)===B&&(g==null?void 0:g.colKey)===I,S=ae[_.field],H=String(S??""),O=()=>{var z;$.current||(f({rowId:B,colKey:I}),m({rowId:B,colKey:I}),(z=w.current)==null||z.focus({preventScroll:!0}),_.type==="select"&&!L.current.has(I)&&X(I,_))};if(M){const z=_.type==="select"?t.jsx(Wc,{initialValue:H,options:N[I]??[],loading:x[I]??!1,onCommit:de=>U(B,I,de),onCancel:ee}):t.jsx(zc,{initialValue:H,type:_.type??"text",mask:_.mask,onCommit:de=>U(B,I,de),onCancel:ee});return t.jsx("div",{className:"absolute inset-0 flex items-center px-2",style:jc,onClick:de=>de.stopPropagation(),children:z})}const re=C.cell(ae);return t.jsxs(t.Fragment,{children:[t.jsx("span",{"data-cell-id":`${B}:${I}`,className:`peer absolute inset-0 z-10 ${Y?"cursor-wait":"cursor-pointer"}`,onClick:O}),oe&&!Y&&t.jsx("div",{className:"pointer-events-none absolute inset-0 z-20",style:Pa}),Y&&t.jsxs("div",{className:"pointer-events-none absolute inset-0 z-20 flex items-center gap-1.5 bg-[var(--bg-card)]/80 px-2",style:Pa,children:[t.jsx("span",{className:"h-3 w-3 shrink-0 animate-spin rounded-full border-2 border-[var(--text-muted)] border-t-transparent","aria-hidden":!0}),t.jsx("span",{className:"truncate text-xs text-[var(--text-muted)]",children:"Guardando…"})]}),t.jsx("span",{className:"relative z-0 inline-flex items-center gap-1 pointer-events-none",children:K?t.jsxs("span",{className:"flex items-center gap-1 text-red-500",children:[t.jsx(q.HiExclamationCircle,{className:"h-3.5 w-3.5 shrink-0"}),t.jsx("span",{className:"truncate text-xs",children:K})]}):t.jsx("span",{className:"truncate",children:re})}),!Y&&t.jsx(q.HiPencil,{className:"pointer-events-none absolute right-1 top-1/2 z-0 h-3 w-3 -translate-y-1/2 shrink-0 text-[var(--text-muted)] opacity-0 transition-opacity peer-hover:opacity-40"})]})}}}),[e,s,u,b,g,v,N,x,n,U,ee,X]);return t.jsx("div",{ref:w,tabIndex:0,onKeyDown:J,onBlur:C=>{var _;(_=w.current)!=null&&_.contains(C.relatedTarget)||setTimeout(()=>{var B,I;const ae=document.activeElement;ae&&((B=ae.closest)!=null&&B.call(ae,"[data-bonsaif-select-dropdown]"))||(I=w.current)!=null&&I.contains(ae)||ee(!1)},0)},style:{width:"100%",minWidth:0,outline:"none"},children:t.jsx(ls,{...l,columns:ce,data:i,getRowId:n})})}function nt(e){if(e)return new Date(`${e}T12:00:00`)}function kt(e){const r=e.getFullYear(),n=String(e.getMonth()+1).padStart(2,"0"),a=String(e.getDate()).padStart(2,"0");return`${r}-${n}-${a}`}function yr(e){return e.charAt(0).toUpperCase()+e.slice(1)}function is(e){return e.map(r=>nt(r)).filter(r=>!!r)}function Uc(e){if(!(e!=null&&e.length))return[];const r=new Set(e.map(kt));return Array.from(r).sort()}function _a(e){return new Intl.DateTimeFormat("es-MX",{weekday:"short"}).format(e)}function cs(e){const r=nt(e);if(!r)return e;const n=_a(r).replace(/\.$/u,"").replace(/^\w/u,s=>s.toUpperCase()),a=new Intl.DateTimeFormat("es-MX",{month:"short"}).format(r).replace(/\.$/u,"").toLowerCase();return`${n} - ${r.getDate()} ${a} ${r.getFullYear()}`}const za={weekend:{dayOfWeek:[0,6]}},Wa={weekend:"bonsaif-weekend"};function ja({children:e,className:r="",...n}){const a=String(e??"").toLowerCase().normalize("NFD").replace(new RegExp("\\p{M}","gu"),"").trim(),s=a.startsWith("sab")||a.startsWith("dom")||a==="s"||a==="d";return t.jsx("th",{...n,className:`${r} ${s?"bonsaif-weekday-weekend":""}`.trim(),children:e})}const Vc={background:"var(--primary)",color:"var(--primary-fg, #ffffff)",borderRadius:999},Yc={background:"color-mix(in srgb, var(--primary) 22%, transparent)",color:"var(--text-main)",borderRadius:999};function Xc({day:e,modifiers:r,...n}){const a=r.range_start||r.range_end||r.selected&&!r.range_middle,s=!!r.range_middle,l=!!r.weekend||e.date.getDay()===0||e.date.getDay()===6;return t.jsx("button",{...n,type:"button",className:`bonsaif-multi-day-btn${a?" is-range-edge":""}${s?" is-range-middle":""}${l?" bonsaif-day-weekend":""} ${n.className??""}`,style:{...a?Vc:null,...s?Yc:null,...l?{fontWeight:800}:null,...n.style}})}function Kc({startDate:e,endDate:r,onChange:n,minDate:a,viewMonth:s,numberOfMonths:l=1,orientation:i="horizontal",showSummary:c=!0,startLabel:d="Inicio",endLabel:u="Regreso",className:m=""}){const b={from:nt(e),to:nt(r)},f=nt(a),[h,v]=o.useState(()=>nt(s||e)??new Date);o.useEffect(()=>{const N=nt(s||e);N&&v(N)},[s,e]);const k=o.useMemo(()=>{if(l<=1)return yr(new Intl.DateTimeFormat("es-MX",{month:"long",year:"numeric"}).format(h));const N=new Date(h.getFullYear(),h.getMonth()+l-1,1),T=h.getFullYear()===N.getFullYear(),x=new Intl.DateTimeFormat("es-MX",{month:"short",...T?{}:{year:"numeric"}}).format(h),y=new Intl.DateTimeFormat("es-MX",{month:"short",year:"numeric"}).format(N);return`${yr(x)} – ${yr(y)}`},[h,l]);function g(){v(new Date(h.getFullYear(),h.getMonth()-1,1))}function A(){v(new Date(h.getFullYear(),h.getMonth()+1,1))}const $=l>1?`bonsaif-range-months bonsaif-range-months--multi bonsaif-range-months--${i}`:"bonsaif-range-months";return t.jsxs("div",{className:`bonsaif-calendar bonsaif-date-range-picker ${m}`.trim(),children:[t.jsxs("div",{className:"bonsaif-cal-shell",children:[t.jsxs("div",{className:"bonsaif-cal-toolbar",children:[t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn","aria-label":"Mes anterior",onClick:g,children:t.jsx(q.HiChevronLeft,{size:16})}),t.jsx("span",{className:"bonsaif-cal-title",children:k}),t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn","aria-label":"Mes siguiente",onClick:A,children:t.jsx(q.HiChevronRight,{size:16})})]}),t.jsx(Ta.DayPicker,{mode:"range",selected:b,month:h,onMonthChange:v,onSelect:N=>{const T=N!=null&&N.from?kt(N.from):e,x=N!=null&&N.to?kt(N.to):"";n({startDate:T,endDate:x})},numberOfMonths:l,hideNavigation:!0,weekStartsOn:1,disabled:f?{before:f}:void 0,showOutsideDays:!1,modifiers:za,modifiersClassNames:Wa,components:{DayButton:Xc,Weekday:ja},classNames:{root:"bonsaif-range-daypicker w-full",months:$,month:l>1?"bonsaif-multi-month bonsaif-range-month-card":"bonsaif-multi-month",month_caption:l>1?"bonsaif-range-month-caption":"bonsaif-multi-caption-hidden",month_grid:"bonsaif-multi-month-grid",weekdays:"bonsaif-multi-weekdays",weekday:"bonsaif-multi-weekday",week:"bonsaif-multi-week",day:"bonsaif-multi-day",day_button:"bonsaif-multi-day-btn",selected:"bonsaif-range-day-selected",range_start:"bonsaif-range-start",range_middle:"bonsaif-range-middle",range_end:"bonsaif-range-end",today:"bonsaif-multi-day-today",disabled:"bonsaif-multi-day-disabled",hidden:"bonsaif-multi-day-hidden"},formatters:{formatCaption:N=>`${yr(new Intl.DateTimeFormat("es-MX",{month:"long"}).format(N))} ${N.getFullYear()}`,formatWeekdayName:_a}})]}),c?t.jsx("div",{className:"bonsaif-cal-summary",children:e?t.jsxs("div",{className:"bonsaif-cal-chips",children:[t.jsxs("span",{className:"bonsaif-cal-chip bonsaif-cal-chip--static",children:[d,": ",e]}),r?t.jsxs("span",{className:"bonsaif-cal-chip bonsaif-cal-chip--static",children:[u,": ",r]}):null]}):t.jsx("span",{children:"Sin rango seleccionado"})}):null]})}function ds({day:e,modifiers:r,onDayPointerDown:n,onDayPointerEnter:a,onDayClickSelect:s,...l}){const i=!!(r.disabled||r.hidden),c=!!r.weekend||e.date.getDay()===0||e.date.getDay()===6;return t.jsx("button",{...l,type:"button",disabled:i||l.disabled,className:`${l.className??""}${c?" bonsaif-day-weekend":""}`,style:{...c?{fontWeight:800}:null,...l.style},onPointerDown:d=>{var u;i||(n==null||n(e.date,d),(u=l.onPointerDown)==null||u.call(l,d))},onPointerEnter:()=>{i||a==null||a(e.date)},onClick:d=>{i||(d.preventDefault(),d.stopPropagation(),s==null||s(e.date,d))}})}function us(e,r){const n=nt(e),a=nt(r);if(!n||!a)return[];const s=n<=a?n:a,l=n<=a?a:n,i=[],c=new Date(s);for(;c<=l;)i.push(kt(c)),c.setDate(c.getDate()+1);return i}function fs(e,r=1){const n=e.getDay(),a=r===1?(n+6)%7:n,s=new Date(e);return s.setHours(12,0,0,0),s.setDate(s.getDate()-a),Array.from({length:7},(l,i)=>{const c=new Date(s);return c.setDate(s.getDate()+i),c})}function Rr(e,r,n){const a=new Set(e);for(const s of r)n==="add"?a.add(s):n==="remove"||a.has(s)?a.delete(s):a.add(s);return Array.from(a).sort()}function Gc(e,r){return typeof r!="number"||r<=0||e.length<=r?e:e.slice(-r)}function Zc(e,r,n){return!!(r&&e<r||n&&e>n)}function bs({value:e,onChange:r,disabled:n=!1,minDate:a,maxDate:s,maxDates:l,isDateDisabled:i,retainOutsidePrefix:c}){const d=o.useRef(null),u=o.useRef(null),m=o.useRef(!1),b=o.useRef(e);b.current=e;const f=o.useCallback(x=>{let y=x;if(c){const L=b.current.filter(W=>!W.startsWith(c)),w=x.filter(W=>W.startsWith(c));y=[...L,...w].sort()}r==null||r(Gc(y,l))},[l,r,c]),h=o.useCallback((x,y=!1)=>Zc(x,a,s)?!0:!(!(i!=null&&i(x))||y&&b.current.includes(x)),[i,s,a]),v=o.useCallback(x=>x.filter(y=>!h(y)),[h]),k=o.useCallback(()=>{u.current=null},[]);o.useEffect(()=>{const x=()=>k();return window.addEventListener("pointerup",x),window.addEventListener("pointercancel",x),()=>{window.removeEventListener("pointerup",x),window.removeEventListener("pointercancel",x)}},[k]);const g=o.useCallback((x,y,L,w)=>{const W=v(us(x,y));f(L==="add"?Rr(w,W,"add"):Rr(w,W,"remove"))},[f,v]),A=o.useCallback((x,y)=>{if(n||y.button!==0)return;const L=kt(x);if(h(L,!0)||y.shiftKey)return;m.current=!0;const w=[...b.current],W=w.includes(L)?"remove":"add";W==="add"&&h(L)||(u.current={active:!0,mode:W,anchor:L,latest:L,baseline:w},d.current=L,g(L,L,W,w),y.preventDefault())},[g,n,h]),$=o.useCallback(x=>{const y=u.current;if(!(y!=null&&y.active)||n)return;const L=kt(x);y.mode==="add"&&h(L)||y.latest!==L&&(y.latest=L,g(y.anchor,L,y.mode,y.baseline))},[g,n,h]),N=o.useCallback((x,y)=>{if(n)return;const L=kt(x);if(!h(L,!0)){if(m.current&&!y.shiftKey){m.current=!1,y.preventDefault(),y.stopPropagation();return}if(m.current=!1,y.shiftKey&&d.current){y.preventDefault(),y.stopPropagation();const w=v(us(d.current,L));f(Rr(b.current,w,"add"));return}!b.current.includes(L)&&h(L)||(d.current=L,f(Rr(b.current,[L],"toggle")))}},[f,n,v,h]),T=o.useCallback(x=>{if(n)return;const y=v(Uc(x));if(!y.length)return;const L=y.every(w=>b.current.includes(w));f(Rr(b.current,y,L?"remove":"add")),d.current=y[0]??d.current},[f,n,v]);return{onDayPointerDown:A,onDayPointerEnter:$,onDayClick:N,toggleWeek:T,endDrag:k}}function en(e){return fs(e,1)[0]}function ms(e,r){const n=new Date(e);return n.setDate(n.getDate()+r),n}function Qc({value:e=[],onChange:r,minDate:n,maxDate:a,isDateDisabled:s,viewMonth:l,maxDates:i,showWeekNumbers:c=!1,viewMode:d,defaultViewMode:u="month",onViewModeChange:m,showSummary:b=!0,className:f="",disabled:h=!1}){const v=o.useMemo(()=>is(e),[e]),k=o.useMemo(()=>new Set(e),[e]),g=nt(n),A=nt(a),[$,N]=o.useState(()=>nt(l||e[0])??new Date),[T,x]=o.useState(()=>en(nt(l||e[0])??new Date)),[y,L]=o.useState(u),w=d??y;function W(C){d===void 0&&L(C),m==null||m(C)}o.useEffect(()=>{const C=nt(l);C&&(N(C),x(en(C)))},[l]);const{onDayPointerDown:X,onDayPointerEnter:Z,onDayClick:D,toggleWeek:Q}=bs({value:e,onChange:r,disabled:h,minDate:n,maxDate:a,maxDates:i,isDateDisabled:s}),j=o.useMemo(()=>{if(h)return!0;const C=[];return g&&C.push({before:g}),A&&C.push({after:A}),s&&C.push(_=>s(kt(_))),C.length>0?C:void 0},[h,s,A,g]),se=o.useCallback(C=>t.jsx(ds,{...C,className:`bonsaif-multi-day-btn ${C.className??""}`,onDayPointerDown:X,onDayPointerEnter:Z,onDayClickSelect:D}),[D,X,Z]),te=o.useMemo(()=>fs(T,1),[T]),ee=te[6],U=w==="week"?`${new Intl.DateTimeFormat("es-MX",{day:"numeric",month:"short"}).format(te[0])} – ${new Intl.DateTimeFormat("es-MX",{day:"numeric",month:"short",year:"numeric"}).format(ee)}`:yr(new Intl.DateTimeFormat("es-MX",{month:"long",year:"numeric"}).format($));function J(){if(w==="week"){const C=ms(T,-7);x(en(C)),N(C);return}N(new Date($.getFullYear(),$.getMonth()-1,1))}function ce(){if(w==="week"){const C=ms(T,7);x(en(C)),N(C);return}N(new Date($.getFullYear(),$.getMonth()+1,1))}return t.jsxs("div",{className:`bonsaif-calendar bonsaif-multi-date-calendar ${f}`,children:[t.jsxs("div",{className:"bonsaif-cal-shell",children:[t.jsxs("div",{className:"bonsaif-cal-view-toggle",role:"tablist","aria-label":"Vista",children:[t.jsx("button",{type:"button",role:"tab","aria-selected":w==="month",className:`bonsaif-cal-view-btn${w==="month"?" is-active":""}`,disabled:h,onClick:()=>{W("month"),N(T)},children:"Mes"}),t.jsx("button",{type:"button",role:"tab","aria-selected":w==="week",className:`bonsaif-cal-view-btn${w==="week"?" is-active":""}`,disabled:h,onClick:()=>{W("week"),x(en($))},children:"Semana"})]}),t.jsxs("div",{className:"bonsaif-cal-toolbar",children:[t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn","aria-label":w==="week"?"Semana anterior":"Mes anterior",disabled:h,onClick:J,children:t.jsx(q.HiChevronLeft,{size:16})}),t.jsx("span",{className:"bonsaif-cal-title",children:U}),t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn","aria-label":w==="week"?"Semana siguiente":"Mes siguiente",disabled:h,onClick:ce,children:t.jsx(q.HiChevronRight,{size:16})})]}),t.jsxs("p",{className:"bonsaif-cal-hint",children:["Click · Shift+click rango · Arrastra",c&&w==="month"?" · Semana (nº)":"",w==="week"?" · Botón semana completa":""]}),w==="month"?t.jsx(Ta.DayPicker,{mode:"multiple",required:!1,selected:v,month:$,onMonthChange:N,onSelect:()=>{},hideNavigation:!0,showOutsideDays:!1,weekStartsOn:1,showWeekNumber:c,onWeekNumberClick:(C,_)=>{Q(_)},disabled:j,className:"bonsaif-multi-daypicker",modifiers:za,modifiersClassNames:Wa,classNames:{root:"bonsaif-multi-daypicker",months:"bonsaif-multi-months",month:"bonsaif-multi-month",month_caption:"bonsaif-multi-caption-hidden",month_grid:"bonsaif-multi-month-grid",weekdays:c?"bonsaif-multi-weekdays bonsaif-multi-weekdays--with-week":"bonsaif-multi-weekdays",weekday:"bonsaif-multi-weekday",week:c?"bonsaif-multi-week bonsaif-multi-week--with-week":"bonsaif-multi-week",week_number:"bonsaif-week-number",week_number_header:"bonsaif-week-number-header",day:"bonsaif-multi-day",day_button:"bonsaif-multi-day-btn",selected:"bonsaif-multi-day-selected",today:"bonsaif-multi-day-today",disabled:"bonsaif-multi-day-disabled",hidden:"bonsaif-multi-day-hidden"},components:{DayButton:se,Weekday:ja},formatters:{formatWeekdayName:_a}}):t.jsxs("div",{className:"bonsaif-week-view",children:[t.jsx("div",{className:"bonsaif-week-view-head",children:te.map(C=>t.jsx("div",{className:"bonsaif-multi-weekday",children:new Intl.DateTimeFormat("es-MX",{weekday:"short"}).format(C)},`h-${kt(C)}`))}),t.jsx("div",{className:"bonsaif-week-view-days",children:te.map(C=>{const _=kt(C),ae=k.has(_),B=h||(n?_<n:!1)||(a?_>a:!1)||!!(s!=null&&s(_)),I=_===kt(new Date);return t.jsx("div",{className:`bonsaif-multi-day${ae?" bonsaif-multi-day-selected":""}${I?" bonsaif-multi-day-today":""}${B?" bonsaif-multi-day-disabled":""}`,children:t.jsxs("button",{type:"button",className:"bonsaif-multi-day-btn",disabled:B,"aria-pressed":ae,onPointerDown:M=>X(C,M),onPointerEnter:()=>Z(C),onClick:M=>D(C,M),children:[t.jsx("span",{className:"bonsaif-week-day-num",children:C.getDate()}),t.jsx("span",{className:"bonsaif-week-day-month",children:new Intl.DateTimeFormat("es-MX",{month:"short"}).format(C)})]})},_)})}),t.jsx("button",{type:"button",className:"bonsaif-week-select-all",disabled:h,onClick:()=>Q(te),children:"Marcar / desmarcar semana"})]})]}),b?t.jsx("div",{className:"bonsaif-cal-summary",children:e.length===0?t.jsx("span",{children:"Sin fechas seleccionadas"}):t.jsxs(t.Fragment,{children:[t.jsxs("span",{children:[e.length," ",e.length===1?"fecha":"fechas"]}),t.jsx("div",{className:"bonsaif-cal-chips",children:e.map(C=>t.jsxs("button",{type:"button",className:"bonsaif-cal-chip",disabled:h,onClick:()=>r==null?void 0:r(e.filter(_=>_!==C)),title:`Quitar ${C}`,children:[cs(C),t.jsx("span",{"aria-hidden":!0,children:"×"})]},C))})]})}):null]})}const Jc=Array.from({length:12},(e,r)=>r);function Rc({value:e=[],onChange:r,year:n,onYearChange:a,minDate:s,maxDate:l,maxDates:i,showSummary:c=!0,className:d="",disabled:u=!1,readOnly:m=!1}){const b=o.useMemo(()=>is(e),[e]),f=nt(s),h=nt(l),v=n??(e[0]?Number(e[0].slice(0,4)):new Date().getFullYear()),[k,g]=o.useState(v);o.useEffect(()=>{typeof n=="number"&&g(n)},[n]);function A(w){g(w),a==null||a(w)}const{onDayPointerDown:$,onDayPointerEnter:N,onDayClick:T}=bs({value:e,onChange:r,disabled:u||m,minDate:s,maxDate:l,maxDates:i,retainOutsidePrefix:`${k}-`}),x=o.useCallback(w=>t.jsx(ds,{...w,className:`bonsaif-year-day-btn ${w.className??""}`,onDayPointerDown:$,onDayPointerEnter:N,onDayClickSelect:T}),[T,$,N]),y=b.filter(w=>w.getFullYear()===k),L=u?!0:[...f?[{before:f}]:[],...h?[{after:h}]:[]];return t.jsxs("div",{className:`bonsaif-calendar bonsaif-year-multi-date-calendar${m?" bonsaif-year-multi-date-calendar--readonly":""} ${d}`,children:[t.jsxs("div",{className:"bonsaif-cal-shell bonsaif-year-cal-shell",children:[t.jsxs("div",{className:"bonsaif-cal-toolbar",children:[t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn","aria-label":"Año anterior",disabled:u,onClick:()=>A(k-1),children:t.jsx(q.HiChevronLeft,{size:16})}),t.jsx("span",{className:"bonsaif-cal-title",children:k}),t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn","aria-label":"Año siguiente",disabled:u,onClick:()=>A(k+1),children:t.jsx(q.HiChevronRight,{size:16})})]}),!m&&!u?t.jsx("p",{className:"bonsaif-cal-hint",children:"Click · Shift+click rango · Arrastra para marcar varias"}):null,t.jsx("div",{className:"bonsaif-year-cal-grid",children:Jc.map(w=>{const W=new Date(k,w,1);return t.jsxs("div",{className:"bonsaif-year-cal-month",children:[t.jsx("div",{className:"bonsaif-year-cal-month-title",children:yr(new Intl.DateTimeFormat("es-MX",{month:"long"}).format(W))}),t.jsx(Ta.DayPicker,{mode:"multiple",required:!1,selected:y,month:W,onMonthChange:()=>{},onSelect:()=>{},numberOfMonths:1,hideNavigation:!0,showOutsideDays:!1,weekStartsOn:1,disabled:L,className:"bonsaif-year-month-picker",modifiers:za,modifiersClassNames:Wa,classNames:{root:"bonsaif-year-month-picker",months:"bonsaif-year-month-months",month:"bonsaif-year-month-inner",month_caption:"bonsaif-year-month-caption-hidden",month_grid:"bonsaif-year-month-grid",weekdays:"bonsaif-year-weekdays",weekday:"bonsaif-year-weekday",week:"bonsaif-year-week",day:"bonsaif-year-day",day_button:"bonsaif-year-day-btn",selected:"bonsaif-year-day-selected",today:"bonsaif-year-day-today",disabled:"bonsaif-year-day-disabled",hidden:"bonsaif-year-day-hidden"},components:{DayButton:x,Weekday:ja},formatters:{formatWeekdayName:X=>new Intl.DateTimeFormat("es-MX",{weekday:"narrow"}).format(X)}})]},`${k}-${w}`)})})]}),c?t.jsx("div",{className:"bonsaif-cal-summary",children:e.length===0?t.jsx("span",{children:"Sin fechas seleccionadas"}):t.jsxs(t.Fragment,{children:[t.jsxs("span",{children:[e.length," ",e.length===1?"fecha":"fechas"," ·"," ",k]}),t.jsx("div",{className:"bonsaif-cal-chips",children:e.map(w=>t.jsxs("button",{type:"button",className:"bonsaif-cal-chip",disabled:u||m,onClick:()=>r==null?void 0:r(e.filter(W=>W!==w)),title:`Quitar ${w}`,children:[cs(w),t.jsx("span",{"aria-hidden":!0,children:"×"})]},w))})]})}):null]})}const ed="bonsaif-ui:hide-tooltips";function ps(){window.dispatchEvent(new CustomEvent(ed))}function td(e){if(e!==void 0)return typeof e=="number"?`${e}px`:e}function rd({trigger:e,items:r,align:n="end",width:a=220,disabled:s=!1,className:l="",menuClassName:i="",onOpenChange:c}){const[d,u]=o.useState(!1),[m,b]=o.useState(!1),[f,h]=o.useState({}),v=o.useRef(null),k=o.useRef(null),g=o.useCallback(x=>{u(x),c==null||c(x)},[c]),A=o.useCallback(()=>{const x=v.current;if(!x)return;const y=x.getBoundingClientRect(),L=typeof a=="number"?a:y.width,w=typeof a=="number"?a:Math.max(y.width,180),W=n==="end"?Math.max(8,y.right-w):Math.min(y.left,window.innerWidth-w-8),X=window.innerHeight-y.bottom,Z=X<240&&y.top>X?void 0:y.bottom+6,D=Z===void 0?window.innerHeight-y.top+6:void 0;h({position:"fixed",zIndex:9999,left:W,top:Z,bottom:D,width:td(typeof a=="number"?L:a)})},[n,a]);o.useEffect(()=>b(!0),[]),o.useEffect(()=>{if(!d)return;A();const x=L=>{var W,X;const w=L.target;!((W=v.current)!=null&&W.contains(w))&&!((X=k.current)!=null&&X.contains(w))&&g(!1)},y=L=>{L.key==="Escape"&&g(!1)};return document.addEventListener("mousedown",x),window.addEventListener("keydown",y),window.addEventListener("resize",A),window.addEventListener("scroll",A,!0),()=>{document.removeEventListener("mousedown",x),window.removeEventListener("keydown",y),window.removeEventListener("resize",A),window.removeEventListener("scroll",A,!0)}},[d,g,A]);const $=x=>{s||(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),g(!d))},N=o.isValidElement(e)?o.cloneElement(e,{onClick:()=>{s||(ps(),g(!d))}}):e,T=d?t.jsx("div",{ref:k,role:"menu","data-bonsaif-overlay":"true",className:`overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-1 shadow-xl ${i}`,style:f,children:r.map(x=>t.jsxs("div",{children:[x.separatorBefore&&t.jsx("div",{className:"my-1 border-t border-[var(--border)]"}),t.jsxs("button",{type:"button",role:"menuitem",disabled:x.disabled,onClick:()=>{var y;x.disabled||(ps(),(y=x.onSelect)==null||y.call(x),g(!1))},className:"flex w-full min-w-0 items-start gap-2 rounded-md px-2.5 py-1.5 text-left transition-colors hover:bg-[var(--bg-input)] disabled:cursor-not-allowed disabled:opacity-50",style:{color:x.danger?"var(--danger)":"var(--text-main)"},children:[x.icon&&t.jsx("span",{className:"mt-0.5 shrink-0",children:x.icon}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"block truncate text-sm font-medium",children:x.label}),x.description&&t.jsx("span",{className:"block truncate text-xs text-[var(--text-muted)]",children:x.description})]})]})]},x.id))}):null;return t.jsxs("span",{ref:v,role:"button",tabIndex:s?-1:0,"aria-haspopup":"menu","aria-expanded":d,onKeyDown:$,className:`inline-flex ${s?"pointer-events-none opacity-60":""} ${l}`,children:[N,m&&T?ct.createPortal(T,document.body):null]})}const nd=180,hs="bg-[color-mix(in_srgb,var(--bg-main)_72%,transparent)] backdrop-blur-sm";function ad({open:e,onClose:r,title:n,subtitle:a,leadingIcon:s,confirmLabel:l="Guardar",onConfirm:i,loading:c=!1,confirmDisabled:d=!1,headerActions:u,bodyClassName:m="flex-1 overflow-y-auto px-6 py-5",width:b=440,hasUnsavedChanges:f=!1,unsavedChangesTitle:h="Descartar cambios",unsavedChangesDescription:v="Hay cambios sin guardar. Si cierras el drawer se perderán.",unsavedChangesConfirmLabel:k="Descartar",unsavedChangesCancelLabel:g="Seguir editando",onDiscardChanges:A,disabled:$=!1,disabledMessage:N,children:T}){const[x,y]=o.useState(!1),[L,w]=o.useState(!1),[W,X]=o.useState(!1),Z=o.useCallback(()=>{w(!0),requestAnimationFrame(()=>{requestAnimationFrame(()=>X(!0))})},[]),D=o.useCallback(()=>{X(!1),window.setTimeout(()=>w(!1),nd)},[]),Q=$||c,j=o.useCallback(()=>{if(!Q){if(f){Z();return}r()}},[Q,f,r,Z]),se=o.useCallback(()=>{X(!1),w(!1),A==null||A(),r()},[r,A]);if(o.useEffect(()=>{y(!0)},[]),o.useEffect(()=>(document.body.style.overflow=e?"hidden":"",e||(X(!1),w(!1)),()=>{document.body.style.overflow=""}),[e]),o.useEffect(()=>{if(!e)return;const ee=U=>{if(U.key==="Escape"&&!Q){if(L){D();return}j()}};return window.addEventListener("keydown",ee),()=>window.removeEventListener("keydown",ee)},[D,Q,L,e,j]),!x)return null;const te=N!==void 0?N:c?"Guardando…":null;return ct.createPortal(t.jsxs("div",{"aria-hidden":!e,"data-bonsaif-overlay":e?"true":void 0,className:`fixed inset-0 z-[1000] flex transition-opacity duration-300 ${e?"opacity-100":"opacity-0 pointer-events-none"}`,children:[t.jsx("div",{className:`absolute inset-0 ${hs}`,onClick:j}),t.jsxs("div",{className:`absolute inset-y-0 right-0 flex flex-col shadow-2xl transition-transform duration-300 ${e?"translate-x-0":"translate-x-full"}`,style:{width:`min(100vw, ${b}px)`,background:"var(--bg-card)",borderLeft:"1px solid var(--border)"},children:[t.jsxs("div",{className:"flex items-center justify-between px-6 py-4 flex-shrink-0",style:{borderBottom:"1px solid var(--border)"},children:[t.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[t.jsx(Ue,{variant:"icon",onClick:j,title:"Cerrar",disabled:Q,children:t.jsx(q.HiXMark,{className:"w-5 h-5"})}),s&&t.jsx("div",{className:"flex-shrink-0",children:s}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("h3",{className:"text-base font-semibold truncate",style:{color:"var(--text-main)"},children:n}),a&&t.jsx("p",{className:"text-xs truncate",style:{color:"var(--text-muted)"},children:a})]})]}),(u||i)&&t.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[u,i&&t.jsxs(t.Fragment,{children:[t.jsx(Ue,{variant:"secondary",size:"sm",onClick:j,disabled:Q,style:{background:"var(--bg-input)"},children:"Cancelar"}),t.jsx(Ue,{variant:"primary",size:"sm",icon:t.jsx(Ai.FiSave,{className:"w-4 h-4"}),onClick:i,loading:c,disabled:d||Q,title:l})]})]})]}),t.jsx("div",{"data-drawer-scroll":"true",className:m,children:T}),Q&&t.jsx("div",{className:"absolute inset-0 z-[1002] flex cursor-not-allowed items-center justify-center p-6",style:{background:"color-mix(in srgb, var(--bg-card, #ffffff) 72%, transparent)",backdropFilter:"blur(3px)"},role:"status","aria-live":"polite","aria-busy":"true",children:te?t.jsxs("div",{className:"flex max-w-xs flex-col items-center gap-3 text-center",children:[t.jsx("div",{className:"h-9 w-9 animate-spin rounded-full border-2 border-[var(--border)] border-t-[var(--primary)]","aria-hidden":!0}),t.jsx("p",{className:"text-sm font-semibold text-[var(--text-main)]",children:te})]}):null})]}),L&&t.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":h,className:"fixed inset-0 z-[1001] flex items-center justify-center p-4",children:[t.jsx("div",{className:`absolute inset-0 ${hs} transition-opacity duration-200 ease-out ${W?"opacity-100":"opacity-0"}`,onClick:D}),t.jsxs("div",{className:`relative z-10 w-full max-w-sm rounded-2xl border p-6 shadow-2xl transition-[opacity,transform] duration-200 ease-out ${W?"translate-y-0 scale-100 opacity-100":"translate-y-2 scale-[0.96] opacity-0"}`,style:{background:"var(--bg-card, #ffffff)",borderColor:"var(--border, #d8e1dc)"},children:[t.jsx(Ue,{variant:"icon",onClick:D,className:"absolute right-3 top-3 h-7 w-7 hover:opacity-70",style:{color:"var(--text-muted, #6b7f78)"},"aria-label":g,children:t.jsx(q.HiXMark,{className:"h-4 w-4"})}),t.jsx("div",{className:"mb-4 flex h-11 w-11 items-center justify-center rounded-xl",style:{background:"var(--warning-bg, #fff7ed)"},children:t.jsx(q.HiExclamationTriangle,{className:"h-5 w-5",style:{color:"var(--warning, #d97706)"}})}),t.jsx("h2",{className:"mb-1 text-base font-semibold",style:{color:"var(--text-main, #0f2f2c)"},children:h}),t.jsx("p",{className:"text-sm",style:{color:"var(--text-muted, #6b7f78)"},children:v}),t.jsxs("div",{className:"mt-6 flex gap-2",children:[t.jsx(Ue,{variant:"secondary",onClick:D,className:"flex-1 border",style:{background:"var(--bg-input, #f7faf8)",borderColor:"var(--border, #d8e1dc)",color:"var(--text-main, #0f2f2c)"},children:g}),t.jsx(Ue,{variant:"secondary",onClick:se,className:"flex-1 border",style:{background:"var(--warning, #d97706)",borderColor:"transparent",color:"#fff",boxShadow:"0 10px 22px rgba(217, 119, 6, 0.22)"},children:k})]})]})]})]}),document.body)}const od=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,sd=/^\+?[0-9\s().-]+$/,ld=7,id=15;function $t(e){return e==null||String(e).trim()===""}function gs(e){return typeof e=="number"?e:typeof e=="string"&&e.trim()!==""?Number(e):Number.NaN}function qa(e){return $t(e)?!1:od.test(String(e))}function Ua(e){if($t(e))return!1;const r=String(e),n=r.replace(/\D/g,"");return sd.test(r)&&n.length>=ld&&n.length<=id}function cd(e="Este campo es requerido."){return r=>$t(r)?e:void 0}function dd(e="Ingresa un correo valido."){return r=>$t(r)||qa(r)?void 0:e}function ud(e="Ingresa un telefono valido."){return r=>$t(r)||Ua(r)?void 0:e}function fd(e,r){return n=>$t(n)||String(n).length>=e?void 0:r??`Debe tener al menos ${e} caracteres.`}function bd(e,r){return n=>$t(n)||String(n).length<=e?void 0:r??`Debe tener ${e} caracteres o menos.`}function md(e,r){return n=>{if($t(n))return;const a=gs(n);return Number.isFinite(a)&&a>=e?void 0:r??`Debe ser mayor o igual a ${e}.`}}function pd(e,r){return n=>{if($t(n))return;const a=gs(n);return Number.isFinite(a)&&a<=e?void 0:r??`Debe ser menor o igual a ${e}.`}}function hd(e,r="El formato no es valido."){return n=>$t(n)||e.test(String(n))?void 0:r}function gd(e,r){const n={};for(const a of Object.keys(r)){const s=r[a];if(!s)continue;const l=Array.isArray(s)?s:[s];for(const i of l){const c=i(e[a],e);if(c){n[a]=c;break}}}return{valid:Object.keys(n).length===0,errors:n}}var vs={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},ys=o.createContext&&o.createContext(vs),vd=["attr","size","title"];function yd(e,r){if(e==null)return{};var n,a,s=xd(e,r);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(a=0;a<l.length;a++)n=l[a],r.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(s[n]=e[n])}return s}function xd(e,r){if(e==null)return{};var n={};for(var a in e)if({}.hasOwnProperty.call(e,a)){if(r.indexOf(a)!==-1)continue;n[a]=e[a]}return n}function An(){return An=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var a in n)({}).hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},An.apply(null,arguments)}function xs(e,r){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);r&&(a=a.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),n.push.apply(n,a)}return n}function Ln(e){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};r%2?xs(Object(n),!0).forEach(function(a){wd(e,a,n[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):xs(Object(n)).forEach(function(a){Object.defineProperty(e,a,Object.getOwnPropertyDescriptor(n,a))})}return e}function wd(e,r,n){return(r=Nd(r))in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}function Nd(e){var r=kd(e,"string");return typeof r=="symbol"?r:r+""}function kd(e,r){if(typeof e!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var a=n.call(e,r);if(typeof a!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(e)}function ws(e){return e&&e.map((r,n)=>o.createElement(r.tag,Ln({key:n},r.attr),ws(r.child)))}function Va(e){return r=>o.createElement(Sd,An({attr:Ln({},e.attr)},r),ws(e.child))}function Sd(e){var r=n=>{var{attr:a,size:s,title:l}=e,i=yd(e,vd),c=s||n.size||"1em",d;return n.className&&(d=n.className),e.className&&(d=(d?d+" ":"")+e.className),o.createElement("svg",An({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},n.attr,a,i,{className:d,style:Ln(Ln({color:e.color||n.color},n.style),e.style),height:c,width:c,xmlns:"http://www.w3.org/2000/svg"}),l&&o.createElement("title",null,l),e.children)};return ys!==void 0?o.createElement(ys.Consumer,null,n=>r(n)):r(vs)}function Ns(e){return Va({attr:{viewBox:"0 0 256 256",fill:"currentColor"},child:[{tag:"path",attr:{d:"M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm0,192a88,88,0,1,1,88-88A88.1,88.1,0,0,1,128,216Zm-8-80V80a8,8,0,0,1,16,0v56a8,8,0,0,1-16,0Zm20,36a12,12,0,1,1-12-12A12,12,0,0,1,140,172Z"},child:[]}]})(e)}function Cd(e){return Va({attr:{viewBox:"0 0 256 256",fill:"currentColor"},child:[{tag:"path",attr:{d:"M247.31,124.76c-.35-.79-8.82-19.58-27.65-38.41C194.57,61.26,162.88,48,128,48S61.43,61.26,36.34,86.35C17.51,105.18,9,124,8.69,124.76a8,8,0,0,0,0,6.5c.35.79,8.82,19.57,27.65,38.4C61.43,194.74,93.12,208,128,208s66.57-13.26,91.66-38.34c18.83-18.83,27.3-37.61,27.65-38.4A8,8,0,0,0,247.31,124.76ZM128,192c-30.78,0-57.67-11.19-79.93-33.25A133.47,133.47,0,0,1,25,128,133.33,133.33,0,0,1,48.07,97.25C70.33,75.19,97.22,64,128,64s57.67,11.19,79.93,33.25A133.46,133.46,0,0,1,231.05,128C223.84,141.46,192.43,192,128,192Zm0-112a48,48,0,1,0,48,48A48.05,48.05,0,0,0,128,80Zm0,80a32,32,0,1,1,32-32A32,32,0,0,1,128,160Z"},child:[]}]})(e)}function Ed(e){return Va({attr:{viewBox:"0 0 256 256",fill:"currentColor"},child:[{tag:"path",attr:{d:"M228,175a8,8,0,0,1-10.92-3l-19-33.2A123.23,123.23,0,0,1,162,155.46l5.87,35.22a8,8,0,0,1-6.58,9.21A8.4,8.4,0,0,1,160,200a8,8,0,0,1-7.88-6.69l-5.77-34.58a133.06,133.06,0,0,1-36.68,0l-5.77,34.58A8,8,0,0,1,96,200a8.4,8.4,0,0,1-1.32-.11,8,8,0,0,1-6.58-9.21L94,155.46a123.23,123.23,0,0,1-36.06-16.69L39,172A8,8,0,1,1,25.06,164l20-35a153.47,153.47,0,0,1-19.3-20A8,8,0,1,1,38.22,99c16.6,20.54,45.64,45,89.78,45s73.18-24.49,89.78-45A8,8,0,1,1,230.22,109a153.47,153.47,0,0,1-19.3,20l20,35A8,8,0,0,1,228,175Z"},child:[]}]})(e)}function xr({content:e,ariaLabel:r="Más información",className:n=""}){return t.jsx(Yt,{as:"span",content:e,className:`inline-flex shrink-0 align-middle text-[var(--text-muted)] outline-none transition-colors hover:text-[var(--primary)] focus-visible:text-[var(--primary)] ${n}`,children:t.jsx("span",{tabIndex:0,role:"img","aria-label":r,className:"inline-flex items-center justify-center outline-none",children:t.jsx(q.HiInformationCircle,{className:"h-3.5 w-3.5"})})})}function wr({error:e,helperText:r,helperDisplay:n="inline"}){return e?t.jsx("span",{className:"text-xs font-medium normal-case text-[var(--danger)]",children:e}):r&&n!=="tooltip"?t.jsx("span",{className:"text-xs font-medium normal-case text-[var(--text-muted)]",children:r}):null}function Dn({className:e="",...r}){return t.jsx("input",{...r,className:`h-10 rounded-lg border border-[var(--border)] bg-[var(--bg-input)] px-2.5 py-1.5 text-sm text-[var(--text-main)] outline-none placeholder:text-[var(--text-muted)] transition-colors focus:border-[var(--primary)] ${e}`})}function Ya({label:e,containerClassName:r="",helperText:n,helperDisplay:a="inline",error:s,errorDisplay:l="inline",errorTooltipLabel:i="Error de validacion",labelAction:c,floatingLabel:d=!1,showPasswordToggle:u=!0,nativeValidation:m=!1,className:b="",required:f,...h}){const[v,k]=o.useState(()=>!!h.autoFocus),[g,A]=o.useState(!1),$=h.type==="password"&&u,N=$&&g?"text":h.type,T=!!s,x=T&&l!=="tooltip",y=T&&l!=="inline",L=!!n&&a==="tooltip"&&!x,w=m?f:void 0,W=T?"border-[var(--danger)] focus:border-[var(--danger)]":"",X=y?$?"pr-20":"pr-10":$?"pr-10":"",Z=h.value!==void 0?String(h.value).length>0:h.defaultValue!==void 0&&String(h.defaultValue).length>0,D=v||Z,Q={top:D?7:12,color:v?"var(--primary)":"var(--text-muted)",fontSize:D?10:13,fontWeight:D?600:400,textTransform:D?"uppercase":"none"},j=J=>{var ce;k(!0),(ce=h.onFocus)==null||ce.call(h,J)},se=J=>{var ce;k(!1),(ce=h.onBlur)==null||ce.call(h,J)},te=$?t.jsxs("button",{type:"button","aria-label":g?"Ocultar contraseña":"Mostrar contraseña","aria-pressed":g,className:"absolute right-2.5 top-1/2 flex h-7 w-7 -translate-y-1/2 items-center justify-center rounded-md text-[var(--text-muted)] transition-colors duration-200 hover:text-[var(--primary)] focus:outline-none",tabIndex:-1,onClick:()=>A(J=>!J),children:[t.jsx("span",{"aria-hidden":"true",className:`absolute inset-0 flex items-center justify-center transition-[opacity,transform] duration-200 ease-out ${g?"scale-y-0 rotate-[-8deg] opacity-0":"scale-y-100 rotate-0 opacity-100"}`,children:t.jsx(Cd,{className:"h-[18px] w-[18px]"})}),t.jsx("span",{"aria-hidden":"true",className:`absolute inset-0 flex items-center justify-center transition-[opacity,transform] duration-200 ease-out ${g?"scale-y-100 rotate-0 opacity-100":"scale-y-0 rotate-[8deg] opacity-0"}`,children:t.jsx(Ed,{className:"h-[18px] w-[18px]"})})]}):null,ee=y?t.jsx(Yt,{as:"span",content:s,className:`absolute top-1/2 flex h-7 w-7 -translate-y-1/2 items-center justify-center rounded-md text-[var(--danger)] outline-none transition-colors hover:bg-[var(--danger-bg)] focus-visible:bg-[var(--danger-bg)] ${$?"right-10":"right-2.5"}`,children:t.jsx("span",{tabIndex:0,role:"img","aria-label":i,className:"flex h-full w-full items-center justify-center outline-none",children:t.jsx(Ns,{className:"h-[18px] w-[18px]"})})}):null,U=t.jsx(wr,{error:x?s:void 0,helperText:n,helperDisplay:a});return d?t.jsxs("label",{className:`flex flex-col gap-2 ${r}`,children:[t.jsxs("span",{className:"relative block",children:[t.jsx(Dn,{...h,type:N,required:w,placeholder:" ","aria-invalid":T||h["aria-invalid"],"data-has-value":Z?"true":void 0,className:`h-11 w-full pt-5 ${X} ${W} ${b}`,onFocus:j,onBlur:se}),t.jsxs("span",{className:"pointer-events-none absolute left-3 transition-all duration-150",style:Q,children:[e,f&&t.jsx("span",{className:"ml-1 text-[var(--danger)]",children:"*"})]}),c&&t.jsx("span",{className:"absolute right-2 transition-all duration-150",style:{top:D?7:12},children:c}),ee,te]}),U]}):t.jsxs("label",{className:`flex flex-col gap-2 ${r}`,children:[t.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-semibold uppercase text-[var(--text-muted)]",children:[t.jsx("span",{children:e}),f&&t.jsx("span",{className:"text-[var(--danger)]",children:"*"}),L?t.jsx(xr,{content:n}):null,c&&t.jsx("span",{className:"ml-auto normal-case",children:c})]}),$?t.jsxs("span",{className:"relative block",children:[t.jsx(Dn,{...h,type:N,required:w,"aria-invalid":T||h["aria-invalid"],className:`w-full ${X} ${W} ${b}`,onFocus:j,onBlur:se}),ee,te]}):t.jsxs("span",{className:"relative block",children:[t.jsx(Dn,{...h,required:w,"aria-invalid":T||h["aria-invalid"],className:`w-full ${X} ${W} ${b}`}),ee]}),U]})}function ks(e){return e==null?"":String(e)}function Md({autoComplete:e="email",inputMode:r="email",validate:n=!0,invalidMessage:a="Ingresa un correo valido.",errorDisplay:s="tooltip",error:l,value:i,defaultValue:c,onChange:d,...u}){const[m,b]=o.useState(()=>ks(c)),f=i!==void 0?ks(i):m,h=n&&f.length>0&&!qa(f)?a:void 0,v=k=>{i===void 0&&b(k.currentTarget.value),d==null||d(k)};return t.jsx(Ya,{...u,value:i,defaultValue:c,type:"text",inputMode:r,autoComplete:e,error:l??h,errorDisplay:s,onChange:v})}const Td={sm:"min-h-[160px] p-4",md:"min-h-[220px] p-6",lg:"min-h-[300px] p-8"};function $d({title:e="Sin resultados",description:r,icon:n=t.jsx(q.HiInbox,{className:"h-5 w-5"}),action:a,secondaryAction:s,size:l="md",className:i=""}){return t.jsx("div",{className:`flex items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-card)] text-center ${Td[l]} ${i}`,children:t.jsxs("div",{className:"flex max-w-sm flex-col items-center gap-3",children:[n&&t.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-input)] text-[var(--text-muted)]",children:n}),t.jsxs("div",{className:"space-y-1",children:[e&&t.jsx("h3",{className:"text-sm font-semibold text-[var(--text-main)]",children:e}),r&&t.jsx("div",{className:"text-sm leading-5 text-[var(--text-muted)]",children:r})]}),(a||s)&&t.jsxs("div",{className:"mt-1 flex flex-wrap items-center justify-center gap-2",children:[s,a]})]})})}const Ad={sm:"min-h-[112px] p-4",md:"min-h-[148px] p-5",lg:"min-h-[184px] p-6"};function Ld(e){if(e===0)return"0 B";const r=["B","KB","MB","GB"],n=Math.min(Math.floor(Math.log(e)/Math.log(1024)),r.length-1),a=e/1024**n;return`${a>=10||n===0?a.toFixed(0):a.toFixed(1)} ${r[n]}`}function Ss(e,r){return r?r.split(",").map(n=>n.trim().toLowerCase()).filter(Boolean).some(n=>{const a=e.name.toLowerCase(),s=e.type.toLowerCase();return n.startsWith(".")?a.endsWith(n):n.endsWith("/*")?s.startsWith(n.slice(0,-1)):s===n}):!0}function Dd(e,r,n){return r?n===void 0?e:e.slice(0,Math.max(0,n)):e.slice(0,1)}function Id({label:e,helperText:r,helperDisplay:n="inline",error:a,labelAction:s,value:l,defaultValue:i=[],onFilesChange:c,onRejectedFiles:d,multiple:u=!1,maxFiles:m,appendFiles:b=!1,showFileList:f=!0,clearable:h=!0,browseLabel:v="Buscar archivos",dropLabel:k="Suelta los archivos aqui",emptyLabel:g="Arrastra y suelta archivos",emptyDescription:A="o haz click para buscarlos en tu equipo",selectedLabel:$="Archivos seleccionados",size:N="md",containerClassName:T="",dropzoneClassName:x="",fileListClassName:y="",className:L="",id:w,accept:W,disabled:X,required:Z,...D}){const Q=o.useId(),j=w??Q,se=o.useRef(null),[te,ee]=o.useState(!1),[U,J]=o.useState(i),ce=l??U,C=!!a,_=!!r&&n==="tooltip"&&!C,ae=h&&ce.length>0&&!X,B=(z,de)=>{l===void 0&&J(z),c==null||c(z,de)},I=(z,de)=>{const he=z.filter($e=>Ss($e,W)),ie=z.filter($e=>!Ss($e,W)),ge=b?[...ce,...he]:he,Me=Dd(ge,u,m);ie.length>0&&(d==null||d(ie)),B(Me,de)},M=()=>{var z;X||(z=se.current)==null||z.click()},oe=z=>{I(Array.from(z.target.files??[]),z),z.target.value=""},K=z=>{z.preventDefault(),X||ee(!0)},Y=z=>{z.currentTarget.contains(z.relatedTarget)||ee(!1)},S=z=>{z.preventDefault(),ee(!1),!X&&I(Array.from(z.dataTransfer.files),z)},H=z=>{z.key!=="Enter"&&z.key!==" "||(z.preventDefault(),M())},O=z=>{B(ce.filter((de,he)=>he!==z))},re=()=>{B([])};return t.jsxs("div",{className:`flex flex-col gap-2 ${T}`,children:[(e||s||_)&&t.jsxs("div",{className:"inline-flex items-center gap-1 text-xs font-semibold uppercase text-[var(--text-muted)]",children:[e&&t.jsx("span",{children:e}),Z&&t.jsx("span",{className:"text-[var(--danger)]",children:"*"}),_?t.jsx(xr,{content:r}):null,s&&t.jsx("span",{className:"ml-auto normal-case",children:s})]}),t.jsx("input",{...D,ref:se,id:j,type:"file",accept:W,multiple:u,disabled:X,required:Z&&ce.length===0,"aria-invalid":C||D["aria-invalid"],className:"sr-only",onChange:oe}),t.jsxs("div",{role:"button",tabIndex:X?-1:0,"aria-controls":j,"aria-disabled":X||void 0,"aria-invalid":C||void 0,className:`flex cursor-pointer flex-col items-center justify-center gap-3 rounded-lg border border-dashed bg-[var(--bg-card)] text-center outline-none transition-colors focus:border-[var(--primary)] focus:bg-[var(--bg-input)] ${Ad[N]} ${te?"border-[var(--primary)] bg-[var(--bg-input)]":C?"border-[var(--danger)]":"border-[var(--border)]"} ${X?"cursor-not-allowed opacity-60":"hover:border-[var(--primary)] hover:bg-[var(--bg-input)]"} ${x} ${L}`,onClick:M,onDragOver:K,onDragLeave:Y,onDrop:S,onKeyDown:H,children:[t.jsx("span",{className:"flex h-10 w-10 items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-input)] text-[var(--text-muted)]",children:t.jsx(q.HiArrowUpTray,{className:"h-5 w-5"})}),t.jsxs("span",{className:"space-y-1",children:[t.jsx("span",{className:"block text-sm font-semibold text-[var(--text-main)]",children:te?k:g}),A&&t.jsx("span",{className:"block text-sm text-[var(--text-muted)]",children:A})]}),v&&t.jsx("span",{className:"inline-flex h-9 items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-card)] px-3 text-xs font-semibold text-[var(--text-main)] shadow-sm shadow-black/5 transition-colors",children:v})]}),f&&ce.length>0&&t.jsxs("div",{className:`rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${y}`,children:[t.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-[var(--border)] px-3 py-2",children:[t.jsx("span",{className:"text-xs font-semibold uppercase text-[var(--text-muted)]",children:$}),ae&&t.jsx("button",{type:"button",className:"inline-flex h-7 w-7 items-center justify-center rounded-md text-[var(--text-muted)] transition-colors hover:bg-[var(--bg-input)] hover:text-[var(--danger)] focus:outline-none","aria-label":"Quitar todos los archivos",onClick:re,children:t.jsx(q.HiTrash,{className:"h-4 w-4"})})]}),t.jsx("ul",{className:"divide-y divide-[var(--border)]",children:ce.map((z,de)=>t.jsxs("li",{className:"flex items-center gap-3 px-3 py-2",children:[t.jsx("span",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-md bg-[var(--bg-input)] text-[var(--text-muted)]",children:t.jsx(q.HiDocument,{className:"h-4 w-4"})}),t.jsxs("span",{className:"min-w-0 flex-1 text-left",children:[t.jsx("span",{className:"block truncate text-sm font-medium text-[var(--text-main)]",children:z.name}),t.jsx("span",{className:"block text-xs text-[var(--text-muted)]",children:Ld(z.size)})]}),!X&&t.jsx("button",{type:"button",className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-[var(--text-muted)] transition-colors hover:bg-[var(--bg-input)] hover:text-[var(--danger)] focus:outline-none","aria-label":`Quitar ${z.name}`,onClick:()=>O(de),children:t.jsx(q.HiXMark,{className:"h-4 w-4"})})]},`${z.name}-${z.lastModified}-${de}`))})]}),t.jsx(wr,{error:a,helperText:r,helperDisplay:n})]})}const Od=[{value:"texto",label:"texto"},{value:"numero",label:"número"},{value:"fecha",label:"fecha"},{value:"booleano",label:"booleano"},{value:"email",label:"email"},{value:"telefono",label:"teléfono"},{value:"select",label:"select"},{value:"textarea",label:"textarea"},{value:"archivo",label:"archivo"},{value:"imagen",label:"imagen"}];function Hd({fields:e,title:r="Layout",fieldTypes:n=Od,saveLabel:a="Guardar",allowAddField:s=!1,addFieldPlaceholder:l="Nuevo campo",addFieldLabel:i="Anadir",loading:c=!1,onSave:d,onChange:u}){const[m,b]=o.useState(()=>e.map(N=>({key:!1,type:"",...N}))),[f,h]=o.useState(""),[v,k]=o.useState(""),g=o.useCallback((N,T)=>{b(x=>{const y=x.map((L,w)=>w===N?{...L,...T}:L);return u==null||u(y),y})},[u]),A=o.useCallback(()=>{d==null||d(m)},[m,d]),$=o.useCallback(()=>{var y;const N=f.trim();if(!N){k("Ingresa un nombre de campo.");return}if(m.some(L=>L.name.toLowerCase()===N.toLowerCase())){k("Ese campo ya existe en el arreglo.");return}const x={name:N,key:!1,type:((y=n[0])==null?void 0:y.value)??""};b(L=>{const w=[...L,x];return u==null||u(w),w}),h(""),k("")},[n,m,f,u]);return t.jsxs("div",{className:"flex flex-col rounded-xl border shadow-sm",style:{borderColor:"var(--border)",background:"var(--bg-card)",color:"var(--text-main)"},children:[t.jsx("div",{className:"border-b px-6 py-4",style:{borderColor:"var(--border)"},children:t.jsx("span",{className:"text-base font-semibold",style:{color:"var(--text-main)"},children:r})}),t.jsxs("div",{className:"grid grid-cols-[1fr_80px_1fr] gap-4 border-b px-6 py-2 text-xs font-medium uppercase tracking-wide",style:{borderColor:"var(--border)",color:"var(--text-muted)"},children:[t.jsx("span",{children:"Campo"}),t.jsx("span",{className:"text-center",children:"Llave"}),t.jsx("span",{children:"Tipo de Campo"})]}),t.jsxs("div",{className:"max-h-[420px] overflow-y-auto",children:[m.map((N,T)=>t.jsxs("div",{className:"grid grid-cols-[1fr_80px_1fr] items-center gap-4 border-b px-6 py-3 last:border-0 hover:bg-[var(--bg-input)] transition-colors",style:{borderColor:"var(--border)"},children:[t.jsx("span",{className:"text-sm font-medium",style:{color:"var(--text-main)"},children:N.name}),t.jsx("div",{className:"flex justify-center",children:t.jsx(Nn,{size:"sm",checked:N.key??!1,onChange:x=>g(T,{key:x.target.checked}),"aria-label":`${N.name} es clave`})}),t.jsx(ar,{value:N.type??"",onChange:x=>g(T,{type:x}),options:n,placeholder:"—",emptyLabel:"—",height:36,searchable:!1,ariaLabel:`Tipo de ${N.name}`})]},N.name)),m.length===0&&t.jsx("p",{className:"px-6 py-8 text-center text-sm",style:{color:"var(--text-muted)"},children:"No hay campos disponibles."})]}),t.jsx("div",{className:"flex justify-end border-t px-6 py-4",style:{borderColor:"var(--border)"},children:t.jsxs("div",{className:"w-full space-y-2",children:[s&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{type:"text",value:f,onChange:N=>{h(N.currentTarget.value),v&&k("")},onKeyDown:N=>{N.key==="Enter"&&(N.preventDefault(),$())},placeholder:l,className:"min-w-0 flex-1 rounded-lg border px-3 py-2 text-sm outline-none transition-colors",style:{borderColor:"var(--border)",background:"var(--bg-input)",color:"var(--text-main)"},"aria-label":"Nombre del nuevo campo"}),t.jsx(Ue,{variant:"secondary",onClick:$,height:36,padding:"0 12px",children:i})]}),v&&t.jsx("p",{className:"text-xs",style:{color:"var(--danger)"},children:v})]}),t.jsx("div",{className:"flex justify-end",children:t.jsx(Ue,{variant:"primary",onClick:A,disabled:c,loading:c,children:a})})]})})]})}function In({label:e,children:r,helperText:n,helperDisplay:a="inline",error:s,labelAction:l,required:i=!1,className:c="",contentClassName:d=""}){const u=!!n&&a==="tooltip"&&!s;return t.jsxs("label",{className:`flex flex-col gap-2 ${c}`,children:[(e||l||u)&&t.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-semibold uppercase text-[var(--text-muted)]",children:[e&&t.jsx("span",{children:e}),i&&t.jsx("span",{className:"text-[var(--danger)]",children:"*"}),u?t.jsx(xr,{content:n}):null,l&&t.jsx("span",{className:"ml-auto normal-case",children:l})]}),t.jsx("span",{className:`block ${d}`,children:r}),t.jsx(wr,{error:s,helperText:n,helperDisplay:a})]})}function Bd(e){return Array.from(e.querySelectorAll("img")).filter(r=>!!(r.currentSrc||r.src||"").trim())}function Cs(e,r){const n=e.target;if(!(n instanceof HTMLImageElement))return!1;const a=e.currentTarget,s=Bd(a),l=s.indexOf(n);if(l<0)return!1;e.preventDefault(),e.stopPropagation();const i=n.getBoundingClientRect();return r(s.map(c=>({src:c.currentSrc||c.src,alt:c.alt||void 0})),l,{left:i.left,top:i.top,width:i.width,height:i.height}),!0}const St=260,Nr=420,Xa=380,At="cubic-bezier(0.22, 1, 0.36, 1)",Fd="cubic-bezier(0.16, 1, 0.3, 1)",Ka="cubic-bezier(0.22, 1, 0.36, 1)",Pd="cubic-bezier(0.22, 1, 0.36, 1)",_d=8,zd=1,Wd=1.25,Ga={background:"color-mix(in srgb, var(--bg-card) 90%, transparent)",border:"1px solid var(--border)",boxShadow:"0 10px 28px color-mix(in srgb, var(--bg-main) 28%, transparent), inset 0 1px 0 color-mix(in srgb, var(--bg-card) 55%, transparent)",color:"var(--text-main)",backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)"},jd="color-mix(in srgb, var(--bg-card) 88%, var(--primary) 12%)",Za=10;function tn(e,r,n){return Math.min(n,Math.max(r,e))}function qd(e){return!e||e.width<1||e.height<1?null:{left:e.left,top:e.top,width:e.width,height:e.height}}function Es(e,r){if(r.width<1||r.height<1)return{dx:0,dy:0,scale:1};const n=Math.min(e.width/r.width,e.height/r.height),a=e.left+e.width/2-(r.left+r.width/2),s=e.top+e.height/2-(r.top+r.height/2);return{dx:a,dy:s,scale:Number.isFinite(n)?n:1}}function kr({label:e,onClick:r,children:n,disabled:a,size:s="md"}){const l=s==="lg"?44:40;return t.jsx("button",{type:"button","aria-label":e,title:e,disabled:a,onClick:i=>{i.stopPropagation(),r()},className:"inline-flex items-center justify-center rounded-full disabled:cursor-not-allowed disabled:opacity-35",style:{...Ga,width:l,height:l,transition:"background 160ms ease, transform 160ms cubic-bezier(0.22, 1, 0.36, 1), opacity 160ms ease"},onMouseEnter:i=>{a||(i.currentTarget.style.background=jd,i.currentTarget.style.transform="scale(1.06)")},onMouseLeave:i=>{i.currentTarget.style.background=String(Ga.background??""),i.currentTarget.style.transform="scale(1)"},onMouseDown:i=>{a||(i.currentTarget.style.transform="scale(0.94)")},onMouseUp:i=>{a||(i.currentTarget.style.transform="scale(1.06)")},children:n})}function Ms({open:e,onClose:r,slides:n,index:a,onIndexChange:s,originRect:l=null,maxZoom:i=_d,minZoom:c=zd,zoomStep:d=Wd,closeOnBackdrop:u=!0,closeOnEscape:m=!0,showCounter:b=!0,showZoomControls:f=!0,loop:h=!0,showThumbnails:v=!0,zIndex:k=1100,ariaLabel:g="Visor de imagen"}){const[A,$]=o.useState(!1),[N,T]=o.useState(!1),[x,y]=o.useState(a??0),[L,w]=o.useState(1),[W,X]=o.useState({x:0,y:0}),[Z,D]=o.useState({opacity:1,x:0,scale:1,blur:0,animate:!1}),[Q,j]=o.useState({dx:0,dy:0,scale:1,animate:!1,enabled:!1}),[se,te]=o.useState(!1),ee=o.useRef(null),U=o.useRef(null),J=o.useRef(null),ce=o.useRef(null),C=o.useRef(null),_=o.useRef(!1),ae=o.useRef(!1),B=o.useRef(null),I=o.useRef(null),M=o.useRef(null),oe=o.useRef(null),K=o.useRef(null),Y=o.useRef(a??0),S=a??x,H=n.length===0?0:tn(S,0,Math.max(0,n.length-1)),O=n[H],re=n.length>1,z=Math.max(c,i),de=v&&re,he=o.useCallback(ue=>{if(n.length===0)return;const pe=n.length-1,Le=h?(ue%n.length+n.length)%n.length:tn(ue,0,pe);a===void 0&&y(Le),s==null||s(Le)},[a,h,s,n.length]),ie=o.useCallback(()=>{w(1),X({x:0,y:0})},[]),ge=o.useCallback((ue,pe)=>{if(pe<=c+.001)return{x:0,y:0};const Le=oe.current,He=K.current;if(!Le||!He)return ue;const Ie=Le.getBoundingClientRect(),tt=He.offsetWidth*pe,at=He.offsetHeight*pe,We=Math.max(0,(tt-Ie.width)/2+Ie.width*.15),Ke=Math.max(0,(at-Ie.height)/2+Ie.height*.15);return{x:tn(ue.x,-We,We),y:tn(ue.y,-Ke,Ke)}},[c]),Me=o.useCallback(()=>{$(!1),j({dx:0,dy:0,scale:1,animate:!1,enabled:!1}),ce.current=null,C.current=null,_.current=!1,ae.current=!1,B.current&&(clearTimeout(B.current),B.current=null)},[]),$e=o.useCallback(()=>{if(_.current)return;_.current=!0,T(!1),ie();const ue=ce.current,pe=ue!=null&&C.current!=null&&C.current===H;if(ue&&pe){J.current!=null&&cancelAnimationFrame(J.current),J.current=requestAnimationFrame(()=>{J.current=requestAnimationFrame(()=>{const Le=K.current;if(!Le){J.current=null,ee.current&&clearTimeout(ee.current),ee.current=setTimeout(Me,St+40);return}const He=Le.getBoundingClientRect(),Ie=Es(ue,He);j({enabled:!0,dx:0,dy:0,scale:1,animate:!1}),J.current=requestAnimationFrame(()=>{j({enabled:!0,dx:Ie.dx,dy:Ie.dy,scale:Ie.scale,animate:!0}),J.current=null})})}),ee.current&&clearTimeout(ee.current),ee.current=setTimeout(Me,Nr+80);return}j({dx:0,dy:0,scale:1,animate:!1,enabled:!1}),ee.current&&clearTimeout(ee.current),ee.current=setTimeout(Me,St+40)},[Me,ie,H]);o.useEffect(()=>(e?(ee.current&&clearTimeout(ee.current),B.current&&(clearTimeout(B.current),B.current=null),_.current=!1,ae.current=!1,ce.current=qd(l),C.current=ce.current!=null?a??x:null,$(!0),T(!1),ce.current?j({dx:0,dy:0,scale:1,animate:!1,enabled:!0}):(C.current=null,requestAnimationFrame(()=>requestAnimationFrame(()=>{T(!0),j({dx:0,dy:0,scale:1,animate:!1,enabled:!1})})))):A&&$e(),()=>{ee.current&&clearTimeout(ee.current),J.current!=null&&cancelAnimationFrame(J.current)}),[e]);const Dt=o.useCallback(()=>{if(!e||_.current||ae.current)return;const ue=ce.current,pe=K.current;if(!ue||!pe){ue||(T(!0),ae.current=!0);return}const Le=pe.getBoundingClientRect();if(Le.width<2||Le.height<2)return;ae.current=!0;const He=Es(ue,Le);j({enabled:!0,dx:He.dx,dy:He.dy,scale:He.scale,animate:!1}),J.current!=null&&cancelAnimationFrame(J.current),J.current=requestAnimationFrame(()=>{J.current=requestAnimationFrame(()=>{j({enabled:!0,dx:0,dy:0,scale:1,animate:!0}),T(!0),J.current=null,B.current&&clearTimeout(B.current),B.current=setTimeout(()=>{j({dx:0,dy:0,scale:1,animate:!1,enabled:!1}),B.current=null},Nr+20)})})},[e]);o.useLayoutEffect(()=>{!A||!e||!ce.current||ae.current||Dt()},[A,e,Dt]),o.useEffect(()=>{!e||_.current||C.current!=null&&C.current!==H&&j(ue=>ue.enabled?{dx:0,dy:0,scale:1,animate:!1,enabled:!1}:ue)},[e,H]),o.useEffect(()=>{if(!e)return;const ue=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=ue}},[e]),o.useEffect(()=>{e&&ie()},[e,H,ie]),o.useEffect(()=>{a!==void 0&&y(a)},[a]),o.useEffect(()=>{if(!e){Y.current=H,D({opacity:1,x:0,scale:1,blur:0,animate:!1});return}const ue=Y.current;if(ue===H)return;Y.current=H;const pe=n.length;let Le=1;if(pe>1){const He=(ue+1)%pe===H,Ie=(ue-1+pe)%pe===H;Ie&&!He?Le=-1:He&&!Ie?Le=1:Le=H>ue?1:-1}return U.current!=null&&(cancelAnimationFrame(U.current),U.current=null),D({opacity:0,x:Le*56,scale:.94,blur:8,animate:!1}),U.current=requestAnimationFrame(()=>{U.current=requestAnimationFrame(()=>{D({opacity:1,x:0,scale:1,blur:0,animate:!0}),U.current=null})}),()=>{U.current!=null&&(cancelAnimationFrame(U.current),U.current=null)}},[e,H,n.length]);const ut=L<=c+.001&&Math.abs(W.x)<.5&&Math.abs(W.y)<.5,Re=o.useCallback((ue,pe,Le)=>{w(He=>{const Ie=tn(ue,c,z);if(Math.abs(Ie-He)<1e-4)return He;const tt=Ie/He,at=Ie<He;return Ie<=c+.001?(X({x:0,y:0}),c):(X(We=>{let Ke=We;if(typeof pe=="number"&&typeof Le=="number"&&oe.current&&!at){const Ge=oe.current.getBoundingClientRect(),Ae=pe-Ge.left-Ge.width/2,lr=Le-Ge.top-Ge.height/2;Ke={x:Ae-(Ae-We.x)*tt,y:lr-(lr-We.y)*tt}}else if(at){Ke={x:We.x*tt,y:We.y*tt};const Ge=Math.min(1,(He-Ie)/Math.max(.01,He-c));Ke={x:Ke.x*(1-Ge*.65),y:Ke.y*(1-Ge*.65)}}else Ke={x:We.x*tt,y:We.y*tt};return ge(Ke,Ie)}),Ie)})},[ge,c,z]),It=o.useCallback(()=>{Re(L*d)},[Re,L,d]),Ct=o.useCallback(()=>{const ue=Math.max(c,L/d);if(ue<=c+.001){ie();return}w(ue),X({x:0,y:0})},[c,ie,L,d]);o.useEffect(()=>{if(!e)return;const ue=pe=>{if(pe.key==="Escape"&&m){pe.preventDefault(),r();return}pe.key==="ArrowLeft"&&re?(pe.preventDefault(),he(H-1)):pe.key==="ArrowRight"&&re?(pe.preventDefault(),he(H+1)):pe.key==="+"||pe.key==="="?(pe.preventDefault(),Re(L*d)):pe.key==="-"||pe.key==="_"?(pe.preventDefault(),Ct()):pe.key==="0"&&(pe.preventDefault(),ie())};return window.addEventListener("keydown",ue),()=>window.removeEventListener("keydown",ue)},[Re,m,re,r,e,ie,H,L,he,Ct,d]);const Et=ue=>{ue.preventDefault();const pe=ue.deltaY>0?1/d:d;Re(L*pe,ue.clientX,ue.clientY)},le=ue=>{L<=c+.001||(ue.currentTarget.setPointerCapture(ue.pointerId),te(!0),I.current={pointerId:ue.pointerId,startX:ue.clientX,startY:ue.clientY,originX:W.x,originY:W.y})},Fe=ue=>{const pe=I.current;!pe||pe.pointerId!==ue.pointerId||X(ge({x:pe.originX+(ue.clientX-pe.startX),y:pe.originY+(ue.clientY-pe.startY)},L))},ze=ue=>{var pe;((pe=I.current)==null?void 0:pe.pointerId)===ue.pointerId&&(I.current=null,te(!1))},ft=ue=>{if(ue.stopPropagation(),L>c+.05){ie();return}Re(Math.min(z,3),ue.clientX,ue.clientY)},Ve=ue=>{if(ue.touches.length!==2)return;te(!0);const[pe,Le]=[ue.touches[0],ue.touches[1]],He=Math.hypot(pe.clientX-Le.clientX,pe.clientY-Le.clientY);M.current={distance:He,scale:L}},Mt=ue=>{if(ue.touches.length!==2||!M.current)return;ue.preventDefault();const[pe,Le]=[ue.touches[0],ue.touches[1]],He=Math.hypot(pe.clientX-Le.clientX,pe.clientY-Le.clientY),Ie=(pe.clientX+Le.clientX)/2,tt=(pe.clientY+Le.clientY)/2,at=M.current.scale*(He/Math.max(1,M.current.distance));Re(at,Ie,tt)},bt=()=>{M.current=null,te(!1)};if(!A||!O)return null;const rt=Q.enabled,Wt=Q.animate?`transform ${Nr}ms ${Pd}`:"none";return ct.createPortal(t.jsxs("div",{className:"fixed inset-0",style:{zIndex:k},role:"dialog","aria-modal":"true","aria-label":g,children:[t.jsx("button",{type:"button","aria-label":"Cerrar",className:"absolute inset-0 border-0",style:{background:"color-mix(in srgb, var(--bg-sidebar, var(--primary)) 72%, transparent)",backdropFilter:"blur(10px)",WebkitBackdropFilter:"blur(10px)",opacity:N?1:0,transition:`opacity ${rt?Nr:St}ms ${At}`,cursor:"default",zIndex:0},onClick:()=>{u&&r()}}),t.jsx("div",{ref:oe,className:"absolute inset-0 flex items-center justify-center",style:{zIndex:1,padding:de?"4.5rem 3.5rem 6.5rem":"4.5rem 3.5rem 2.5rem",opacity:rt||N?1:0,transform:rt||N?"translateY(0) scale(1)":"translateY(10px) scale(0.96)",transition:rt?"none":`opacity ${St}ms ${At}, transform ${St}ms ${At}`},onClick:ue=>{ue.target===ue.currentTarget&&u&&r()},onWheel:Et,children:t.jsx("div",{className:"relative flex max-h-full max-w-full items-center justify-center will-change-transform",style:{transform:Q.enabled?`translate3d(${Q.dx}px, ${Q.dy}px, 0) scale(${Q.scale})`:void 0,transformOrigin:"center center",transition:Q.enabled?Wt:void 0},children:t.jsx("div",{className:"relative flex max-h-full max-w-full items-center justify-center will-change-transform",style:{opacity:Z.opacity,filter:Z.blur?`blur(${Z.blur}px)`:"blur(0px)",transform:`translate3d(${Z.x}px, 0, 0) scale(${Z.scale})`,transition:Z.animate?[`opacity ${Xa}ms ${Ka}`,`transform ${Xa}ms ${Ka}`,`filter ${Xa}ms ${Ka}`].join(", "):"none"},children:t.jsx("div",{ref:K,className:"pointer-events-auto relative max-h-full max-w-full touch-none select-none will-change-transform",style:{cursor:L>c+.001?"grab":"zoom-in",transform:`translate3d(${W.x}px, ${W.y}px, 0) scale(${L})`,transformOrigin:"center center",transition:se?"none":`transform 220ms ${Fd}`},onClick:ue=>ue.stopPropagation(),onDoubleClick:ft,onPointerDown:le,onPointerMove:Fe,onPointerUp:ze,onPointerCancel:ze,onTouchStart:Ve,onTouchMove:Mt,onTouchEnd:bt,children:t.jsx("img",{src:O.src,alt:O.alt||"",draggable:!1,className:"block max-h-[min(78vh,820px)] max-w-[min(86vw,1100px)] object-contain",style:{display:"block",borderRadius:Za,imageRendering:L>2.5?"pixelated":"auto"},onLoad:()=>{Dt()}},O.src+String(H))})})})}),t.jsxs("div",{className:"pointer-events-none absolute inset-0",style:{zIndex:2,opacity:N?1:0,transform:N?"translateY(0)":"translateY(-6px)",transition:`opacity ${rt?Nr:St}ms ${At}, transform ${rt?Nr:St}ms ${At}`},children:[t.jsxs("div",{className:"pointer-events-none absolute inset-x-0 top-0 flex items-center justify-between gap-3 px-4 pt-4",children:[t.jsx("div",{className:"pointer-events-auto flex items-center gap-2",children:b&&n.length>0?t.jsxs("span",{className:"rounded-full px-3 py-1.5 text-xs font-semibold tracking-wide",style:Ga,children:[H+1," / ",n.length]}):null}),t.jsxs("div",{className:"pointer-events-auto flex items-center gap-2",children:[f?t.jsxs(t.Fragment,{children:[t.jsx(kr,{label:"Alejar",onClick:Ct,disabled:L<=c+.001,children:t.jsx(q.HiMinus,{className:"h-5 w-5"})}),t.jsx(kr,{label:"Restablecer tamaño",onClick:ie,disabled:ut,children:t.jsx(q.HiArrowsPointingIn,{className:"h-5 w-5"})}),t.jsx(kr,{label:"Acercar",onClick:It,disabled:L>=z-.001,children:t.jsx(q.HiPlus,{className:"h-5 w-5"})})]}):null,t.jsx(kr,{label:"Cerrar",onClick:r,children:t.jsx(q.HiXMark,{className:"h-5 w-5"})})]})]}),re?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"pointer-events-auto absolute left-3 top-1/2",style:{opacity:N?1:0,transform:N?"translate(0, -50%)":"translate(-8px, -50%)",transition:`opacity ${St}ms ${At}, transform ${St}ms ${At}`},children:t.jsx(kr,{label:"Anterior",size:"lg",onClick:()=>he(H-1),disabled:!h&&H<=0,children:t.jsx(q.HiChevronLeft,{className:"h-6 w-6"})})}),t.jsx("div",{className:"pointer-events-auto absolute right-3 top-1/2",style:{opacity:N?1:0,transform:N?"translate(0, -50%)":"translate(8px, -50%)",transition:`opacity ${St}ms ${At}, transform ${St}ms ${At}`},children:t.jsx(kr,{label:"Siguiente",size:"lg",onClick:()=>he(H+1),disabled:!h&&H>=n.length-1,children:t.jsx(q.HiChevronRight,{className:"h-6 w-6"})})})]}):null,de?t.jsx("div",{className:"pointer-events-none absolute inset-x-0 bottom-0 flex justify-center px-4 pb-4 pt-8",style:{background:"linear-gradient(to top, color-mix(in srgb, var(--bg-sidebar, var(--primary)) 72%, transparent), transparent)"},children:t.jsx("div",{className:"pointer-events-auto flex max-w-full items-end gap-2.5 overflow-x-auto rounded-2xl px-2 py-2",style:{background:"color-mix(in srgb, var(--bg-card) 55%, transparent)",backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)",scrollbarWidth:"thin"},role:"tablist","aria-label":"Miniaturas",children:n.map((ue,pe)=>{const Le=pe===H;return t.jsx("button",{type:"button",role:"tab","aria-selected":Le,"aria-label":ue.alt||`Imagen ${pe+1}`,onClick:He=>{He.stopPropagation(),he(pe)},className:"relative shrink-0 overflow-hidden transition-opacity",style:{width:56,height:42,borderRadius:Za,opacity:Le?1:.42,transition:`opacity 180ms ${At}`},children:t.jsx("img",{src:ue.src,alt:"",draggable:!1,className:"h-full w-full object-cover",style:{borderRadius:Za}})},`${ue.src}-${pe}`)})})}):null]})]}),document.body)}function Ud({children:e,className:r,style:n,maxZoom:a,minZoom:s,zoomStep:l,loop:i,showThumbnails:c}){const[d,u]=o.useState(!1),[m,b]=o.useState(0),[f,h]=o.useState([]),[v,k]=o.useState(null),g=o.useCallback(($,N,T)=>{h($),k(T??null),b(N),u(!0)},[]),A=o.useCallback($=>{Cs($,g)},[g]);return t.jsxs(t.Fragment,{children:[t.jsx("div",{className:`[&_img]:cursor-zoom-in ${r??""}`,style:n,onClick:A,children:e}),t.jsx(Ms,{open:d,onClose:()=>u(!1),index:m,onIndexChange:b,slides:f,originRect:v,maxZoom:a,minZoom:s,zoomStep:l,loop:i,showThumbnails:c})]})}function Ts(e){if(e!==void 0)return typeof e=="number"?`${e}px`:e}function $s(e,r){if(e.length!==r.length)return!1;const n=new Set(r);return e.every(a=>n.has(a))}function Qa(e){return e.normalize("NFD").replace(new RegExp("\\p{M}","gu"),"").toLowerCase()}function Vd(e,r){if(!r)return!0;const n=Qa(r);return Qa(e.label).includes(n)||!!(e.sublabel&&Qa(e.sublabel).includes(n))}function Yd({value:e,onChange:r,options:n,placeholder:a="Seleccionar…",disabled:s=!1,className:l="",style:i,height:c=40,padding:d="6px 10px",searchable:u=!0,minOptionsForSearch:m=6,maxVisibleValues:b=2,truncateSelectedValues:f=!0,emptyText:h="Sin resultados",clearLabel:v="Limpiar seleccion",pruneMissingValues:k=!0}){const[g,A]=o.useState(!1),[$,N]=o.useState(""),[T,x]=o.useState(0),[y,L]=o.useState(!1),[w,W]=o.useState({}),X=o.useRef(null),Z=o.useRef(null),D=o.useRef(null),Q=o.useRef(null),j=u&&n.length>=m,se=o.useMemo(()=>new Set(e),[e]),te=o.useMemo(()=>{const S=new Map;for(const H of n)S.set(H.value,H);return S},[n]),ee=o.useMemo(()=>{const S=[];for(const H of e){const O=te.get(H);O&&S.push(O)}return S},[te,e]),U=b==="all"?ee.length:b,J=ee.slice(0,U),ce=Math.max(0,ee.length-J.length),C=o.useMemo(()=>{const S=$.trim();return!j||!S?n:n.filter(H=>Vd(H,S))},[n,$,j]),_=o.useCallback(()=>{const S=X.current;if(!S)return;const H=S.getBoundingClientRect(),O=j?304:244,re=window.innerHeight-H.bottom,z=re<O&&H.top>re;W({position:"fixed",left:H.left,top:z?void 0:H.bottom+4,bottom:z?window.innerHeight-H.top+4:void 0,width:Math.max(H.width,240),zIndex:9999})},[j]),ae=o.useCallback(S=>{$s(e,S)||r(S)},[r,e]),B=o.useCallback(S=>{const H=te.get(S);if(H!=null&&H.disabled)return;const O=se.has(S)?e.filter(re=>re!==S):[...e,S];ae(O)},[ae,te,e,se]),I=o.useCallback(()=>ae([]),[ae]),M=o.useCallback(()=>{A(!1),N(""),x(0)},[]);o.useEffect(()=>L(!0),[]);const oe=o.useMemo(()=>n.map(S=>S.value).join("\0"),[n]);o.useEffect(()=>{if(!k||e.length===0||n.length===0)return;const S=new Set(n.map(O=>O.value)),H=e.filter(O=>S.has(O));$s(e,H)||r(H)},[oe]),o.useEffect(()=>{if(!g)return;function S(H){var re,z;const O=H.target;!((re=X.current)!=null&&re.contains(O))&&!((z=Z.current)!=null&&z.contains(O))&&M()}return document.addEventListener("mousedown",S),()=>document.removeEventListener("mousedown",S)},[M,g]),o.useEffect(()=>{g&&(x(0),_(),j&&setTimeout(()=>{var S;return(S=D.current)==null?void 0:S.focus()},0))},[g,j,_]),o.useEffect(()=>{if(g)return window.addEventListener("resize",_),window.addEventListener("scroll",_,!0),()=>{window.removeEventListener("resize",_),window.removeEventListener("scroll",_,!0)}},[g,_]),o.useEffect(()=>{if(C.length===0){x(0);return}x(S=>Math.min(S,C.length-1))},[C.length]),o.useEffect(()=>{if(T<0||!Q.current)return;const S=Q.current.children[T];S==null||S.scrollIntoView({block:"nearest"})},[T]);function K(S){if(!s){if(!g){(S.key==="Enter"||S.key===" "||S.key==="ArrowDown")&&(S.preventDefault(),A(!0));return}if(S.key==="Escape"){S.preventDefault(),M();return}if(S.key==="ArrowDown"){if(S.preventDefault(),C.length===0)return;x(H=>Math.min(H+1,C.length-1));return}if(S.key==="ArrowUp"){S.preventDefault(),x(H=>Math.max(H-1,0));return}if(S.key==="Enter"&&C[T]&&!C[T].disabled){S.preventDefault(),B(C[T].value);return}S.key==="Backspace"&&!$&&e.length&&(S.preventDefault(),ae(e.slice(0,-1)))}}const Y=t.jsxs("div",{ref:Z,className:"overflow-hidden rounded-xl shadow-xl",style:{...w,background:"var(--bg-card)",border:"1px solid var(--border)"},children:[j&&t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",style:{borderBottom:"1px solid var(--border)"},children:[t.jsx(q.HiMagnifyingGlass,{className:"h-3.5 w-3.5 flex-shrink-0",style:{color:"var(--text-muted)"}}),t.jsx("input",{ref:D,value:$,onChange:S=>{N(S.target.value),x(0)},onKeyDown:S=>{(S.key==="ArrowDown"||S.key==="ArrowUp"||S.key==="Enter"||S.key==="Escape")&&(S.stopPropagation(),K(S))},placeholder:"Buscar…",className:"min-w-0 flex-1 bg-transparent text-sm outline-none",style:{color:"var(--text-main)"}}),$&&t.jsx("button",{type:"button","aria-label":"Limpiar búsqueda",onMouseDown:S=>{S.preventDefault(),N(""),x(0)},children:t.jsx(q.HiXMark,{className:"h-3.5 w-3.5",style:{color:"var(--text-muted)"}})})]}),e.length>0&&t.jsxs("div",{className:"flex items-center justify-between gap-3 px-3 py-2 text-xs",style:{borderBottom:"1px solid var(--border)",color:"var(--text-muted)"},children:[t.jsxs("span",{children:[ee.length," seleccionados",e.length>ee.length?` (${e.length-ee.length} no disponibles)`:""]}),t.jsx("button",{type:"button",onMouseDown:S=>{S.preventDefault(),I()},className:"font-semibold transition-colors hover:text-[var(--primary)]",children:v})]}),t.jsxs("ul",{ref:Q,role:"listbox","aria-multiselectable":"true",className:"overflow-y-auto",style:{maxHeight:j?220:200,scrollbarWidth:"thin",scrollbarColor:"var(--border) transparent",overscrollBehavior:"contain"},children:[C.map((S,H)=>{const O=H===T,re=se.has(S.value);return t.jsxs("li",{role:"option","aria-selected":re,onMouseDown:z=>{z.preventDefault(),!S.disabled&&B(S.value)},onMouseEnter:()=>!S.disabled&&x(H),className:"flex cursor-pointer items-center gap-2 px-3 py-2 text-sm transition-colors",style:{background:O?"var(--bg-hover)":re?"color-mix(in srgb, var(--primary) 6%, transparent)":"transparent",color:S.disabled?"var(--text-muted)":"var(--text-main)",cursor:S.disabled?"not-allowed":"pointer",opacity:S.disabled?.58:1},children:[t.jsx("span",{className:"flex h-4 w-4 flex-shrink-0 items-center justify-center rounded border",style:{borderColor:re?"var(--primary)":"var(--border)",background:re?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:re&&t.jsx(q.HiCheck,{className:"h-3 w-3"})}),S.color&&t.jsx("span",{className:"h-2.5 w-2.5 flex-shrink-0 rounded-full",style:{background:S.color}}),t.jsxs("span",{className:"flex min-w-0 flex-1 items-baseline gap-1 overflow-hidden",children:[t.jsx(Pt,{className:"min-w-0 flex-1",children:S.label}),S.sublabel&&t.jsx(Pt,{className:"min-w-0 flex-shrink",style:{color:"var(--text-muted)",fontSize:12},children:S.sublabel})]}),S.badge&&t.jsx("span",{className:"flex-shrink-0 text-xs",style:{color:"var(--text-muted)"},children:S.badge})]},S.value)}),C.length===0&&t.jsx("li",{className:"px-3 py-4 text-center text-sm",style:{color:"var(--text-muted)"},children:h})]})]});return t.jsxs("div",{ref:X,className:`relative ${l||"w-full"}`,style:i,onKeyDown:K,children:[t.jsxs("button",{type:"button",disabled:s,onClick:()=>{s||(g?M():A(!0))},className:"flex w-full items-center gap-2 rounded-lg text-left text-sm transition-colors focus:outline-none",style:{minHeight:Ts(c),padding:Ts(d),background:"var(--bg-input)",color:ee.length?"var(--text-main)":"var(--text-muted)",border:g?"1px solid var(--primary)":"1px solid var(--border)",opacity:s?.5:1,cursor:s?"not-allowed":"pointer"},"aria-haspopup":"listbox","aria-expanded":g,children:[t.jsx("span",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-1.5 overflow-hidden",children:J.length?t.jsxs(t.Fragment,{children:[J.map(S=>t.jsxs("span",{className:`inline-flex items-center gap-1 rounded-md border px-1.5 py-0.5 text-xs font-semibold ${f?"max-w-[160px]":"max-w-full whitespace-normal"}`,style:{background:"var(--bg-card)",borderColor:"var(--border)",color:"var(--text-main)"},children:[S.color&&t.jsx("span",{className:"h-1.5 w-1.5 flex-shrink-0 rounded-full",style:{background:S.color}}),f?t.jsx(Pt,{className:"min-w-0 flex-1",children:S.label}):t.jsx("span",{className:"break-words",children:S.label}),t.jsx("span",{role:"button",tabIndex:-1,"aria-label":`Quitar ${S.label}`,onMouseDown:H=>{H.preventDefault(),H.stopPropagation(),B(S.value)},className:"flex-shrink-0 rounded-full p-0.5 transition-colors hover:bg-black/10",style:{color:"var(--text-muted)"},children:t.jsx(q.HiXMark,{className:"h-3 w-3"})})]},S.value)),ce>0&&t.jsxs("span",{className:"inline-flex items-center rounded-md px-1.5 py-0.5 text-xs font-semibold",style:{background:"color-mix(in srgb, var(--primary) 10%, transparent)",color:"var(--primary)"},children:["+",ce]})]}):t.jsx("span",{className:"truncate",children:a})}),ee.length?t.jsx("span",{role:"button",tabIndex:-1,"aria-label":v,onMouseDown:S=>{S.preventDefault(),S.stopPropagation(),I()},className:"flex-shrink-0 rounded-full p-0.5 transition-colors hover:bg-black/10",style:{color:"var(--text-muted)"},children:t.jsx(q.HiXMark,{className:"h-3.5 w-3.5"})}):t.jsx(q.HiChevronDown,{className:"h-4 w-4 flex-shrink-0 transition-transform",style:{color:"var(--text-muted)",transform:g?"rotate(180deg)":"rotate(0deg)"}})]}),g&&y&&ct.createPortal(Y,document.body)]})}function Xd({inputMode:e="decimal",...r}){return t.jsx(Ya,{...r,type:"number",inputMode:e})}function Kd(e,r,n){const a=[],s=Math.max(2,e-n),l=Math.min(r-1,e+n);a.push(1),s>2&&a.push("...");for(let i=s;i<=l;i+=1)a.push(i);return l<r-1&&a.push("..."),r>1&&a.push(r),a}function Gd({page:e,totalPages:r,onPageChange:n,disabled:a=!1,siblingCount:s=1,className:l=""}){const i=Math.max(1,r),c=Math.min(Math.max(1,e),i),d=Kd(c,i,s);return t.jsxs("nav",{"aria-label":"Paginacion",className:`inline-flex items-center gap-1 ${l}`,children:[t.jsx(Ue,{variant:"icon",size:"xs","aria-label":"Pagina anterior",disabled:a||c<=1,onClick:()=>n(c-1),children:t.jsx(q.HiChevronLeft,{className:"h-4 w-4"})}),d.map((u,m)=>u==="..."?t.jsx("span",{className:"flex h-8 min-w-8 items-center justify-center text-xs font-semibold text-[var(--text-muted)]",children:"..."},`ellipsis-${m}`):t.jsx("button",{type:"button","aria-current":u===c?"page":void 0,disabled:a,onClick:()=>n(u),className:"flex h-8 min-w-8 items-center justify-center rounded-md border px-2 text-xs font-semibold transition-colors disabled:cursor-not-allowed disabled:opacity-50",style:{borderColor:u===c?"var(--primary)":"var(--border)",background:u===c?"var(--primary)":"var(--bg-card)",color:u===c?"var(--primary-fg)":"var(--text-secondary)"},children:u},u)),t.jsx(Ue,{variant:"icon",size:"xs","aria-label":"Pagina siguiente",disabled:a||c>=i,onClick:()=>n(c+1),children:t.jsx(q.HiChevronRight,{className:"h-4 w-4"})})]})}const As=[{value:"+1",label:"+1",sublabel:"Estados Unidos, Canada, Caribe"},{value:"+7",label:"+7",sublabel:"Rusia, Kazajistan"},{value:"+20",label:"+20",sublabel:"Egipto"},{value:"+27",label:"+27",sublabel:"Sudafrica"},{value:"+30",label:"+30",sublabel:"Grecia"},{value:"+31",label:"+31",sublabel:"Paises Bajos"},{value:"+32",label:"+32",sublabel:"Belgica"},{value:"+33",label:"+33",sublabel:"Francia"},{value:"+34",label:"+34",sublabel:"Espana"},{value:"+36",label:"+36",sublabel:"Hungria"},{value:"+39",label:"+39",sublabel:"Italia, Vaticano"},{value:"+40",label:"+40",sublabel:"Rumania"},{value:"+41",label:"+41",sublabel:"Suiza"},{value:"+43",label:"+43",sublabel:"Austria"},{value:"+44",label:"+44",sublabel:"Reino Unido"},{value:"+45",label:"+45",sublabel:"Dinamarca"},{value:"+46",label:"+46",sublabel:"Suecia"},{value:"+47",label:"+47",sublabel:"Noruega"},{value:"+48",label:"+48",sublabel:"Polonia"},{value:"+49",label:"+49",sublabel:"Alemania"},{value:"+51",label:"+51",sublabel:"Peru"},{value:"+52",label:"+52",sublabel:"Mexico"},{value:"+53",label:"+53",sublabel:"Cuba"},{value:"+54",label:"+54",sublabel:"Argentina"},{value:"+55",label:"+55",sublabel:"Brasil"},{value:"+56",label:"+56",sublabel:"Chile"},{value:"+57",label:"+57",sublabel:"Colombia"},{value:"+58",label:"+58",sublabel:"Venezuela"},{value:"+60",label:"+60",sublabel:"Malasia"},{value:"+61",label:"+61",sublabel:"Australia"},{value:"+62",label:"+62",sublabel:"Indonesia"},{value:"+63",label:"+63",sublabel:"Filipinas"},{value:"+64",label:"+64",sublabel:"Nueva Zelanda"},{value:"+65",label:"+65",sublabel:"Singapur"},{value:"+66",label:"+66",sublabel:"Tailandia"},{value:"+81",label:"+81",sublabel:"Japon"},{value:"+82",label:"+82",sublabel:"Corea del Sur"},{value:"+84",label:"+84",sublabel:"Vietnam"},{value:"+86",label:"+86",sublabel:"China"},{value:"+90",label:"+90",sublabel:"Turquia"},{value:"+91",label:"+91",sublabel:"India"},{value:"+92",label:"+92",sublabel:"Pakistan"},{value:"+93",label:"+93",sublabel:"Afganistan"},{value:"+94",label:"+94",sublabel:"Sri Lanka"},{value:"+95",label:"+95",sublabel:"Myanmar"},{value:"+98",label:"+98",sublabel:"Iran"},{value:"+211",label:"+211",sublabel:"Sudan del Sur"},{value:"+212",label:"+212",sublabel:"Marruecos, Sahara Occidental"},{value:"+213",label:"+213",sublabel:"Argelia"},{value:"+216",label:"+216",sublabel:"Tunez"},{value:"+218",label:"+218",sublabel:"Libia"},{value:"+220",label:"+220",sublabel:"Gambia"},{value:"+221",label:"+221",sublabel:"Senegal"},{value:"+222",label:"+222",sublabel:"Mauritania"},{value:"+223",label:"+223",sublabel:"Mali"},{value:"+224",label:"+224",sublabel:"Guinea"},{value:"+225",label:"+225",sublabel:"Costa de Marfil"},{value:"+226",label:"+226",sublabel:"Burkina Faso"},{value:"+227",label:"+227",sublabel:"Niger"},{value:"+228",label:"+228",sublabel:"Togo"},{value:"+229",label:"+229",sublabel:"Benin"},{value:"+230",label:"+230",sublabel:"Mauricio"},{value:"+231",label:"+231",sublabel:"Liberia"},{value:"+232",label:"+232",sublabel:"Sierra Leona"},{value:"+233",label:"+233",sublabel:"Ghana"},{value:"+234",label:"+234",sublabel:"Nigeria"},{value:"+235",label:"+235",sublabel:"Chad"},{value:"+236",label:"+236",sublabel:"Republica Centroafricana"},{value:"+237",label:"+237",sublabel:"Camerun"},{value:"+238",label:"+238",sublabel:"Cabo Verde"},{value:"+239",label:"+239",sublabel:"Santo Tome y Principe"},{value:"+240",label:"+240",sublabel:"Guinea Ecuatorial"},{value:"+241",label:"+241",sublabel:"Gabon"},{value:"+242",label:"+242",sublabel:"Republica del Congo"},{value:"+243",label:"+243",sublabel:"Republica Democratica del Congo"},{value:"+244",label:"+244",sublabel:"Angola"},{value:"+245",label:"+245",sublabel:"Guinea-Bisau"},{value:"+246",label:"+246",sublabel:"Territorio Britanico del Oceano Indico"},{value:"+248",label:"+248",sublabel:"Seychelles"},{value:"+249",label:"+249",sublabel:"Sudan"},{value:"+250",label:"+250",sublabel:"Ruanda"},{value:"+251",label:"+251",sublabel:"Etiopia"},{value:"+252",label:"+252",sublabel:"Somalia"},{value:"+253",label:"+253",sublabel:"Yibuti"},{value:"+254",label:"+254",sublabel:"Kenia"},{value:"+255",label:"+255",sublabel:"Tanzania"},{value:"+256",label:"+256",sublabel:"Uganda"},{value:"+257",label:"+257",sublabel:"Burundi"},{value:"+258",label:"+258",sublabel:"Mozambique"},{value:"+260",label:"+260",sublabel:"Zambia"},{value:"+261",label:"+261",sublabel:"Madagascar"},{value:"+262",label:"+262",sublabel:"Reunion, Mayotte"},{value:"+263",label:"+263",sublabel:"Zimbabue"},{value:"+264",label:"+264",sublabel:"Namibia"},{value:"+265",label:"+265",sublabel:"Malaui"},{value:"+266",label:"+266",sublabel:"Lesoto"},{value:"+267",label:"+267",sublabel:"Botsuana"},{value:"+268",label:"+268",sublabel:"Esuatini"},{value:"+269",label:"+269",sublabel:"Comoras"},{value:"+290",label:"+290",sublabel:"Santa Elena"},{value:"+291",label:"+291",sublabel:"Eritrea"},{value:"+297",label:"+297",sublabel:"Aruba"},{value:"+298",label:"+298",sublabel:"Islas Feroe"},{value:"+299",label:"+299",sublabel:"Groenlandia"},{value:"+350",label:"+350",sublabel:"Gibraltar"},{value:"+351",label:"+351",sublabel:"Portugal"},{value:"+352",label:"+352",sublabel:"Luxemburgo"},{value:"+353",label:"+353",sublabel:"Irlanda"},{value:"+354",label:"+354",sublabel:"Islandia"},{value:"+355",label:"+355",sublabel:"Albania"},{value:"+356",label:"+356",sublabel:"Malta"},{value:"+357",label:"+357",sublabel:"Chipre"},{value:"+358",label:"+358",sublabel:"Finlandia, Aland"},{value:"+359",label:"+359",sublabel:"Bulgaria"},{value:"+370",label:"+370",sublabel:"Lituania"},{value:"+371",label:"+371",sublabel:"Letonia"},{value:"+372",label:"+372",sublabel:"Estonia"},{value:"+373",label:"+373",sublabel:"Moldavia"},{value:"+374",label:"+374",sublabel:"Armenia"},{value:"+375",label:"+375",sublabel:"Bielorrusia"},{value:"+376",label:"+376",sublabel:"Andorra"},{value:"+377",label:"+377",sublabel:"Monaco"},{value:"+378",label:"+378",sublabel:"San Marino"},{value:"+380",label:"+380",sublabel:"Ucrania"},{value:"+381",label:"+381",sublabel:"Serbia"},{value:"+382",label:"+382",sublabel:"Montenegro"},{value:"+383",label:"+383",sublabel:"Kosovo"},{value:"+385",label:"+385",sublabel:"Croacia"},{value:"+386",label:"+386",sublabel:"Eslovenia"},{value:"+387",label:"+387",sublabel:"Bosnia y Herzegovina"},{value:"+389",label:"+389",sublabel:"Macedonia del Norte"},{value:"+420",label:"+420",sublabel:"Chequia"},{value:"+421",label:"+421",sublabel:"Eslovaquia"},{value:"+423",label:"+423",sublabel:"Liechtenstein"},{value:"+500",label:"+500",sublabel:"Islas Malvinas"},{value:"+501",label:"+501",sublabel:"Belice"},{value:"+502",label:"+502",sublabel:"Guatemala"},{value:"+503",label:"+503",sublabel:"El Salvador"},{value:"+504",label:"+504",sublabel:"Honduras"},{value:"+505",label:"+505",sublabel:"Nicaragua"},{value:"+506",label:"+506",sublabel:"Costa Rica"},{value:"+507",label:"+507",sublabel:"Panama"},{value:"+508",label:"+508",sublabel:"San Pedro y Miquelon"},{value:"+509",label:"+509",sublabel:"Haiti"},{value:"+590",label:"+590",sublabel:"Guadalupe, San Bartolome"},{value:"+591",label:"+591",sublabel:"Bolivia"},{value:"+592",label:"+592",sublabel:"Guyana"},{value:"+593",label:"+593",sublabel:"Ecuador"},{value:"+594",label:"+594",sublabel:"Guayana Francesa"},{value:"+595",label:"+595",sublabel:"Paraguay"},{value:"+596",label:"+596",sublabel:"Martinica"},{value:"+597",label:"+597",sublabel:"Surinam"},{value:"+598",label:"+598",sublabel:"Uruguay"},{value:"+599",label:"+599",sublabel:"Caribe Neerlandes, Curazao"},{value:"+670",label:"+670",sublabel:"Timor Oriental"},{value:"+672",label:"+672",sublabel:"Antartida, Isla Norfolk"},{value:"+673",label:"+673",sublabel:"Brunei"},{value:"+674",label:"+674",sublabel:"Nauru"},{value:"+675",label:"+675",sublabel:"Papua Nueva Guinea"},{value:"+676",label:"+676",sublabel:"Tonga"},{value:"+677",label:"+677",sublabel:"Islas Salomon"},{value:"+678",label:"+678",sublabel:"Vanuatu"},{value:"+679",label:"+679",sublabel:"Fiyi"},{value:"+680",label:"+680",sublabel:"Palaos"},{value:"+681",label:"+681",sublabel:"Wallis y Futuna"},{value:"+682",label:"+682",sublabel:"Islas Cook"},{value:"+683",label:"+683",sublabel:"Niue"},{value:"+685",label:"+685",sublabel:"Samoa"},{value:"+686",label:"+686",sublabel:"Kiribati"},{value:"+687",label:"+687",sublabel:"Nueva Caledonia"},{value:"+688",label:"+688",sublabel:"Tuvalu"},{value:"+689",label:"+689",sublabel:"Polinesia Francesa"},{value:"+690",label:"+690",sublabel:"Tokelau"},{value:"+691",label:"+691",sublabel:"Micronesia"},{value:"+692",label:"+692",sublabel:"Islas Marshall"},{value:"+850",label:"+850",sublabel:"Corea del Norte"},{value:"+852",label:"+852",sublabel:"Hong Kong"},{value:"+853",label:"+853",sublabel:"Macao"},{value:"+855",label:"+855",sublabel:"Camboya"},{value:"+856",label:"+856",sublabel:"Laos"},{value:"+880",label:"+880",sublabel:"Banglades"},{value:"+886",label:"+886",sublabel:"Taiwan"},{value:"+960",label:"+960",sublabel:"Maldivas"},{value:"+961",label:"+961",sublabel:"Libano"},{value:"+962",label:"+962",sublabel:"Jordania"},{value:"+963",label:"+963",sublabel:"Siria"},{value:"+964",label:"+964",sublabel:"Irak"},{value:"+965",label:"+965",sublabel:"Kuwait"},{value:"+966",label:"+966",sublabel:"Arabia Saudita"},{value:"+967",label:"+967",sublabel:"Yemen"},{value:"+968",label:"+968",sublabel:"Oman"},{value:"+970",label:"+970",sublabel:"Palestina"},{value:"+971",label:"+971",sublabel:"Emiratos Arabes Unidos"},{value:"+972",label:"+972",sublabel:"Israel"},{value:"+973",label:"+973",sublabel:"Barein"},{value:"+974",label:"+974",sublabel:"Catar"},{value:"+975",label:"+975",sublabel:"Butan"},{value:"+976",label:"+976",sublabel:"Mongolia"},{value:"+977",label:"+977",sublabel:"Nepal"},{value:"+992",label:"+992",sublabel:"Tayikistan"},{value:"+993",label:"+993",sublabel:"Turkmenistan"},{value:"+994",label:"+994",sublabel:"Azerbaiyan"},{value:"+995",label:"+995",sublabel:"Georgia"},{value:"+996",label:"+996",sublabel:"Kirguistan"},{value:"+998",label:"+998",sublabel:"Uzbekistan"}];function Ls(e){return e==null?"":String(e)}function On(e){return e?e.startsWith("+")?e:`+${e}`:"+1"}function Zd(e){return typeof e=="number"?`${e}px`:e}function Qd({autoComplete:e="tel",inputMode:r="tel",validate:n=!0,invalidMessage:a="Ingresa un telefono valido.",errorDisplay:s="tooltip",error:l,value:i,defaultValue:c,onChange:d,countryCode:u,defaultCountryCode:m="+1",onCountryCodeChange:b,allowedCountryCodes:f,countryCodeOptions:h,countryCodePlaceholder:v="Codigo",countryCodeClassName:k="",countryCodeWidth:g=84,onPhoneValueChange:A,label:$,containerClassName:N="",helperText:T,helperDisplay:x="inline",labelAction:y,className:L="",required:w,disabled:W,floatingLabel:X,showPasswordToggle:Z,nativeValidation:D,errorTooltipLabel:Q="Error de validacion",...j}){var z;const[se,te]=o.useState(()=>Ls(c)),[ee,U]=o.useState(()=>On(m)),J=o.useMemo(()=>{const de=h??As,he=f==null?void 0:f.map(On);return he!=null&&he.length?de.filter(ie=>he.includes(ie.value)):de},[f,h]),ce=((z=J[0])==null?void 0:z.value)??"+1",C=J.some(de=>de.value===On(u??ee))?On(u??ee):ce,_=i!==void 0?Ls(i):se,ae=`${C} ${_}`.trim(),B=n&&_.length>0&&!Ua(ae)?a:void 0,I=l??B,M=!!I,oe=M&&s!=="tooltip",K=M&&s!=="inline",Y=!!T&&x==="tooltip"&&!oe,S=M?"border-[var(--danger)] focus-within:border-[var(--danger)]":"border-[var(--border)] focus-within:border-[var(--primary)]",H=de=>{const he=de.currentTarget.value;i===void 0&&te(he),A==null||A(he,{countryCode:C,nationalNumber:he,fullNumber:`${C} ${he}`.trim()}),d==null||d(de)},O=de=>{u===void 0&&U(de),b==null||b(de),A==null||A(_,{countryCode:de,nationalNumber:_,fullNumber:`${de} ${_}`.trim()})},re=K?t.jsx(Yt,{as:"span",content:I,className:"absolute right-2.5 top-1/2 flex h-7 w-7 -translate-y-1/2 items-center justify-center rounded-md text-[var(--danger)] outline-none transition-colors hover:bg-[var(--danger-bg)] focus-visible:bg-[var(--danger-bg)]",children:t.jsx("span",{tabIndex:0,role:"img","aria-label":Q,className:"flex h-full w-full items-center justify-center outline-none",children:t.jsx(Ns,{className:"h-[18px] w-[18px]"})})}):null;return t.jsxs("div",{className:`flex flex-col gap-2 ${N}`,children:[t.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-semibold uppercase text-[var(--text-muted)]",children:[t.jsx("span",{children:$}),w&&t.jsx("span",{className:"text-[var(--danger)]",children:"*"}),Y?t.jsx(xr,{content:T}):null,y&&t.jsx("span",{className:"ml-auto normal-case",children:y})]}),t.jsxs("span",{className:`flex h-10 min-w-0 items-center overflow-hidden rounded-lg border bg-[var(--bg-input)] transition-colors ${S}`,children:[t.jsx(ar,{value:C,onChange:O,options:J,placeholder:v,disabled:W,ariaLabel:"Codigo telefonico",triggerVariant:"ghost",showSelectedSublabel:!1,searchable:!0,minOptionsForSearch:0,dropdownMinWidth:300,className:`shrink-0 ${k}`,style:{width:Zd(g)},height:38,padding:"0 8px 0 10px"}),t.jsx("span",{className:"h-5 w-px shrink-0 bg-[var(--border)]"}),t.jsxs("span",{className:"relative min-w-0 flex-1 self-stretch",children:[t.jsx("input",{...j,value:i,defaultValue:c,type:"tel",inputMode:r,autoComplete:e,disabled:W,required:void 0,"aria-label":j["aria-label"]??(typeof $=="string"?$:void 0),"aria-invalid":M||j["aria-invalid"],className:`h-full w-full min-w-0 bg-transparent px-2 py-1.5 text-sm text-[var(--text-main)] outline-none placeholder:text-[var(--text-muted)] disabled:cursor-not-allowed disabled:opacity-60 ${K?"pr-10":""} ${L}`,onChange:H}),re]})]}),t.jsx(wr,{error:oe?I:void 0,helperText:T,helperDisplay:x})]})}function Jd({value:e,onChange:r,options:n,name:a,label:s,orientation:l="vertical",disabled:i=!1,className:c="",optionClassName:d=""}){return t.jsxs("fieldset",{className:`min-w-0 ${c}`,disabled:i,children:[s&&t.jsx("legend",{className:"mb-2 text-xs font-semibold uppercase text-[var(--text-muted)]",children:s}),t.jsx("div",{className:l==="horizontal"?"flex flex-wrap gap-2":"flex flex-col gap-2",children:n.map(u=>{const m=u.value===e,b=i||u.disabled;return t.jsxs("label",{className:`inline-flex min-w-0 items-start gap-2 rounded-lg border px-2.5 py-1.5 transition-colors ${b?"cursor-not-allowed opacity-60":"cursor-pointer hover:bg-[var(--bg-input)]"} ${d}`,style:{borderColor:m?"color-mix(in srgb, var(--primary) 48%, var(--border))":"var(--border)",background:m?"color-mix(in srgb, var(--primary) 8%, transparent)":"var(--bg-card)"},children:[t.jsxs("span",{className:"relative mt-0.5 inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-full border border-[var(--border)] bg-[var(--bg-input)]",children:[t.jsx("input",{type:"radio",name:a,value:u.value,checked:m,disabled:b,onChange:()=>r(u.value),className:"absolute inset-0 opacity-0"}),t.jsx("span",{className:`h-2 w-2 rounded-full transition ${m?"scale-100 opacity-100":"scale-50 opacity-0"}`,style:{background:"var(--primary)"}})]}),t.jsxs("span",{className:"min-w-0",children:[t.jsx("span",{className:"block text-sm font-medium leading-5 text-[var(--text-main)]",children:u.label}),u.description&&t.jsx("span",{className:"block text-xs leading-5 text-[var(--text-muted)]",children:u.description})]})]},u.value)})})]})}const Rd=new Set(["table","thead","tbody","tfoot","tr","th","td","caption"]),Hn=(e,r,n)=>Math.min(n,Math.max(r,Math.round(e)||r)),Sr=12,Bn=8,Ja=(e,r,n)=>{const a=Pn(n),s=e.insertRow(r);for(let l=0;l<a;l+=1){const i=s.insertCell(-1);i.innerHTML="<br>"}return s.cells[0]??null},Ds=(e,r)=>{const n=e.rows[r];if(!n)return null;const a=n.parentElement;if(!a)return null;if(a.tagName==="THEAD"){const l=e.tBodies[0]??e.createTBody();return l.rows.length>=Sr?null:Ja(l,0,e)}if(a.tagName==="TBODY"&&a.rows.length>=Sr)return null;const s=Array.from(a.rows).indexOf(n);return Ja(a,s+1,e)},eu=(e,r)=>{var s;const n=e.rows[r];if(!n)return!1;const a=n.parentElement;return(a==null?void 0:a.tagName)==="TBODY"&&a.rows.length<=1||(a==null?void 0:a.tagName)==="THEAD"&&((s=e.tBodies[0])==null?void 0:s.rows.length)===0&&e.rows.length<=1?!1:(n.remove(),!0)},Is=(e,r)=>Pn(e)>=Bn?!1:(e.querySelectorAll("tr").forEach(n=>{const a=n.closest("thead")!==null,s=document.createElement(a?"th":"td");a?s.textContent=`Columna ${n.cells.length+1}`:s.innerHTML="<br>";const l=n.cells[r];l!=null&&l.nextSibling?n.insertBefore(s,l.nextSibling):n.appendChild(s)}),!0),tu=(e,r)=>Pn(e)<=1?!1:(e.querySelectorAll("tr").forEach(n=>{var a;(a=n.cells[r])==null||a.remove()}),!0),Os=e=>{e.querySelectorAll(".rich-table-row-active").forEach(r=>{r.classList.remove("rich-table-row-active")}),e.querySelectorAll(".rich-table-col-active").forEach(r=>{r.classList.remove("rich-table-col-active")})},Hs=(e,r,n)=>{Os(e),r&&(r.classList.add("rich-table-row-active"),e.querySelectorAll("tr").forEach(a=>{var s;(s=a.cells[n])==null||s.classList.add("rich-table-col-active")}))},ru=(e,r,n)=>{const a=e.getBoundingClientRect();return{rowIndex:Array.from(e.rows).indexOf(r),colIndex:n.cellIndex,bar:{x:a.left+a.width/2,y:a.top-6}}},Fn=e=>{const r=e.cloneNode(!0);return r.querySelectorAll(".rich-table-ui").forEach(n=>n.remove()),r.querySelectorAll(".rich-table-wrap").forEach(n=>{const a=n.querySelector("table");a?n.replaceWith(a):n.remove()}),r.querySelectorAll("table").forEach(n=>{n.classList.add("rich-table")}),r.querySelectorAll(".rich-table-row-active, .rich-table-col-active").forEach(n=>{n.classList.remove("rich-table-row-active","rich-table-col-active")}),r.innerHTML},Bs=e=>{e.querySelectorAll(".rich-table-wrap").forEach(r=>{const n=r.querySelector("table");n&&r.replaceWith(n)}),e.querySelectorAll(".rich-table-ui").forEach(r=>r.remove()),e.querySelectorAll("table").forEach(r=>{r.classList.add("rich-table")})},nu=(e,r,n,a,s)=>{switch(e){case"table-delete":return r.remove(),!0;case"table-row-add":{const l=Number.isFinite(n)?Ds(r,n):Ra(r);return l&&_n(l,s,!0),!!l}case"table-row-del":return Number.isFinite(n)?eu(r,n):!1;case"table-col-add":return Number.isFinite(a)?Is(r,a):lu(r);case"table-col-del":return Number.isFinite(a)?tu(r,a):!1;default:return!1}},Pn=e=>{let r=0;return e.querySelectorAll("tr").forEach(n=>{r=Math.max(r,n.cells.length)}),r||1},au=e=>{const r=e.tBodies[0]??e.createTBody();return Array.from(r.rows)},Fs=e=>(e==null?void 0:e.closest("table"))??null,Ps=e=>{if(!e)return null;const r=e.nodeType===Node.ELEMENT_NODE?e:e.parentElement;return(r==null?void 0:r.closest("td, th"))??null},ou=e=>Array.from(e.querySelectorAll("th, td")),_s=(e,r)=>{if(e.closest("thead"))return!1;const n=e.closest("tbody")??r.tBodies[0];if(!n)return!1;const a=Array.from(n.rows),s=e.closest("tr");return!s||s!==a[a.length-1]?!1:e===s.cells[s.cells.length-1]},su=e=>{const r=window.getSelection();if(!r||!r.isCollapsed||r.rangeCount===0)return!1;const n=r.getRangeAt(0);if(!e.contains(n.startContainer))return!1;const a=n.cloneRange();return a.selectNodeContents(e),a.setStart(n.endContainer,n.endOffset),a.toString().trim()===""},_n=(e,r,n=!0)=>{r==null||r.focus();const a=document.createRange();a.selectNodeContents(e),a.collapse(n);const s=window.getSelection();s==null||s.removeAllRanges(),s==null||s.addRange(a)},Ra=e=>{const r=au(e);if(r.length>=Sr)return null;const n=r[r.length-1];if(!n){const a=e.tBodies[0]??e.createTBody();return Ja(a,0,e)}return Ds(e,Array.from(e.rows).indexOf(n))},lu=e=>{const r=Pn(e)-1;return r<0?!1:Is(e,r)},eo=e=>{Bs(e)},iu=(e,r,n)=>{const a=Hn(e,1,Sr),s=Hn(r,1,Bn),l=n?`<thead><tr>${Array.from({length:s},(c,d)=>`<th>Columna ${d+1}</th>`).join("")}</tr></thead>`:"",i=Array.from({length:a},()=>`<tr>${Array.from({length:s},()=>"<td><br></td>").join("")}</tr>`).join("");return`<table class="rich-table">${l}<tbody>${i}</tbody></table><p><br></p>`},zs=()=>'<button type="button" class="rich-img-del" data-action="delete-img" title="Eliminar imagen"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor"><path fill-rule="evenodd" d="M9 2a1 1 0 0 0-.894.553L7.382 4H4a1 1 0 0 0 0 2v10a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V6a1 1 0 0 0 0-2h-3.382l-.724-1.447A1 1 0 0 0 11 2H9zm-1 6a1 1 0 1 1 2 0v4a1 1 0 1 1-2 0V8zm4 0a1 1 0 1 1 2 0v4a1 1 0 1 1-2 0V8z" clip-rule="evenodd"/></svg></button>',rn=e=>e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'"),Ws=e=>e.toLocaleLowerCase().replace(new RegExp("(^|[^\\p{L}\\p{N}])(\\p{L})","gu"),(r,n,a)=>`${n}${a.toLocaleUpperCase()}`),cu=e=>e.replace(/[<>]/g,"").toLowerCase(),du=new Set(["p","br","div","span","b","strong","i","em","u","s","strike","ul","ol","li","h1","h2","h3","h4","blockquote","a","img","hr","table","thead","tbody","tfoot","tr","th","td","caption"]),uu=/^[\s\u00a0]*([•●○■▪▫◆◇►▶➢❖✓✔\-–—*])[\s\u00a0]+/,fu=e=>{const r=e.indexOf("<!--StartFragment-->"),n=e.indexOf("<!--EndFragment-->");if(r!==-1&&n!==-1&&n>r)return e.slice(r+20,n);const a=e.match(/<body[^>]*>([\s\S]*)<\/body>/i);return a?a[1]:e},zn=(e,r)=>r.test(e),bu=e=>zn(e,/font-weight\s*:\s*(bold|[6-9]00)/i),mu=e=>zn(e,/font-style\s*:\s*italic/i),pu=e=>zn(e,/text-decoration(?:-line)?\s*:[^;]*underline/i),hu=e=>zn(e,/text-decoration(?:-line)?\s*:[^;]*(line-through|linethrough)/i),Wn=(e,r)=>{var a;if(!e.childNodes.length||e.childNodes.length===1&&((a=e.firstChild)==null?void 0:a.nodeType)===Node.ELEMENT_NODE&&e.firstChild.tagName.toLowerCase()===r)return;const n=e.ownerDocument.createElement(r);for(;e.firstChild;)n.appendChild(e.firstChild);e.appendChild(n)},jn=e=>{const r=e.parentNode;if(!r){e.remove();return}for(;e.firstChild;)r.insertBefore(e.firstChild,e);r.removeChild(e)},gu=e=>{const r=e.getAttribute("class")??"",n=e.getAttribute("style")??"";return/mso-list/i.test(n)||/MsoListParagraph/i.test(r)||/MsoList/i.test(r)},js=e=>{const r=e.getAttribute("style")??"",n=e.textContent??"";return/mso-level-number-format\s*:\s*(decimal|arabic|roman|alpha)/i.test(r)||/^\s*\d+[.)]\s/.test(n)||/^\s*[a-zA-Z][.)]\s/.test(n)?"ol":"ul"},vu=e=>{const n=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_TEXT).nextNode();if(!n||!n.textContent)return;const a=n.textContent.replace(uu,"").replace(/^\s*\d+[.)]\s+/,"").replace(/^\s*[a-zA-Z][.)]\s+/,"");a!==n.textContent&&(n.textContent=a)},yu=e=>{const r=Array.from(e.querySelectorAll("span, font, p, div, li, h1, h2, h3, h4"));r.sort((n,a)=>a.querySelectorAll("*").length-n.querySelectorAll("*").length),r.forEach(n=>{const a=n.getAttribute("style")??"";a&&(bu(a)&&Wn(n,"strong"),mu(a)&&Wn(n,"em"),pu(a)&&Wn(n,"u"),hu(a)&&Wn(n,"s"))})},xu=e=>{const r=Array.from(e.querySelectorAll("p, div")).filter(gu);if(!r.length)return;let n=0;for(;n<r.length;){const a=r[n],s=js(a),l=[a];let i=n+1;for(;i<r.length;){const u=r[i];if(js(u)!==s)break;let m=l[l.length-1].nextSibling;for(;m&&m.nodeType===Node.TEXT_NODE&&!(m.textContent??"").trim();)m=m.nextSibling;if(m!==u)break;l.push(u),i++}const c=a.parentNode;if(!c){n=i;continue}const d=a.ownerDocument.createElement(s);c.insertBefore(d,a),l.forEach(u=>{vu(u);const m=u.ownerDocument.createElement("li");for(;u.firstChild;)m.appendChild(u.firstChild);d.appendChild(m),u.remove()}),n=i}},wu=e=>e==="h1"?"h2":e==="h4"||e==="h5"||e==="h6"?"h3":e==="div"?"p":e,Nu=e=>{const r=fu(e.replace(/<!--\[if[\s\S]*?<!\[endif\]-->/gi,"").replace(/<xml[\s\S]*?<\/xml>/gi,"").replace(/<style[\s\S]*?<\/style>/gi,"").replace(/<\/?o:[^>]*>/gi,"").replace(/<\/?w:[^>]*>/gi,"").replace(/<\/?m:[^>]*>/gi,"")),s=new DOMParser().parseFromString(`<!DOCTYPE html><html><body>${r}</body></html>`,"text/html").body;s.querySelectorAll("script, style, meta, link, xml, title, head, iframe, object, embed, form, input, button, textarea, select, noscript").forEach(i=>i.remove()),yu(s),xu(s);const l=i=>{const c=Array.from(i.childNodes);if(i.nodeType===Node.ELEMENT_NODE){const d=i,u=d.tagName.toLowerCase();if(u==="html"||u==="body"){c.forEach(l);return}if(u==="font"){jn(d),c.forEach(l);return}if(!du.has(u)){jn(d),c.forEach(l);return}if(u==="div"){const b=d.getAttribute("class")??"";if(/rich-table-wrap/.test(b)){Array.from(d.attributes).forEach(f=>{f.name.toLowerCase()!=="class"&&d.removeAttribute(f.name)}),d.className="rich-table-wrap",c.forEach(l);return}}const m=wu(u);if(m!==u){const b=d.ownerDocument.createElement(m);for(;d.firstChild;)b.appendChild(d.firstChild);d.replaceWith(b),l(b);return}if(Rd.has(u)){Array.from(d.attributes).forEach(b=>{const f=b.name.toLowerCase();if(u==="td"||u==="th"){["colspan","rowspan"].includes(f)||d.removeAttribute(b.name);return}d.removeAttribute(b.name)}),u==="table"&&d.classList.add("rich-table"),c.forEach(l);return}if(Array.from(d.attributes).forEach(b=>{const f=b.name.toLowerCase(),h=b.value;if(f.startsWith("on")||f==="style"||f==="class"){d.removeAttribute(b.name);return}if(f==="lang"||f.startsWith("data-")||f.startsWith("mso-")){d.removeAttribute(b.name);return}if((f==="href"||f==="src")&&/^\s*javascript:/i.test(h)){d.removeAttribute(b.name);return}u!=="a"&&u!=="img"&&f!=="href"&&f!=="src"&&f!=="alt"&&(["href","src","alt","target","rel"].includes(f)||d.removeAttribute(b.name))}),u==="a"){const b=d.getAttribute("href");if(!b||/^\s*#/.test(b)&&b.length<2){jn(d),c.forEach(l);return}d.setAttribute("target","_blank"),d.setAttribute("rel","noopener noreferrer"),d.classList.add("rich-link")}if(u==="img"){const b=d.getAttribute("src")??"";if(!b||/^\s*javascript:/i.test(b)||/^file:/i.test(b)||/scheme\s*=\s*["']?file/i.test(b)){d.remove();return}d.classList.add("rich-img"),Array.from(d.attributes).forEach(f=>{["src","alt","class"].includes(f.name.toLowerCase())||d.removeAttribute(f.name)})}if(u==="span"){jn(d),c.forEach(l);return}}c.forEach(l)};return l(s),s.querySelectorAll("p, h2, h3, li").forEach(i=>{const c=(i.textContent??"").replace(/[\u00a0\s]+/g,"").trim(),d=i.querySelector("img, hr"),u=!c&&!d&&Array.from(i.childNodes).every(m=>m.nodeType===Node.TEXT_NODE||m.nodeType===Node.ELEMENT_NODE&&m.tagName.toLowerCase()==="br");(!c&&!d||u)&&i.remove()}),s.querySelectorAll("strong, b, em, i, u, s").forEach(i=>{let c=i.nextSibling;for(;c&&c.nodeType===Node.TEXT_NODE&&!(c.textContent??"").trim();)c=c.nextSibling;if(c&&c.nodeType===Node.ELEMENT_NODE&&c.tagName===i.tagName){const d=c;for(;d.firstChild;)i.appendChild(d.firstChild);d.remove()}}),s.innerHTML.replace(/<!--[\s\S]*?-->/g,"").replace(/ /gi," ").replace(/(<br\s*\/?>\s*){3,}/gi,"<br><br>").replace(/<p>(?:\s|<br\s*\/?>)*<\/p>/gi,"").trim()},to=e=>rn(e).replace(/\r\n?/g,`
|
|
25
|
-
`).split(/\n{2,}/).map(r=>`<p>${r.replace(/\n/g,"<br>")||"<br>"}</p>`).join(""),ku=e=>new RegExp("\\p{L}","u").test(e),ro=(e,r)=>{const n=e.trim();return!n||!ku(n)?!1:r==="uppercase"?n===n.toLocaleUpperCase():r==="lowercase"?n===n.toLocaleLowerCase():n===Ws(n)},qs=e=>{const r=a=>{var s,l;if(!a.closest(".rich-img-wrap")){const i=document.createElement("span");i.className="rich-img-wrap",i.contentEditable="false",(s=a.parentNode)==null||s.insertBefore(i,a),i.appendChild(a),i.insertAdjacentHTML("beforeend",zs())}(l=a.closest(".rich-img-wrap"))==null||l.classList.add("rich-img-broken")};e.querySelectorAll("img").forEach(a=>{if(!a.complete||a.naturalWidth===0){a.addEventListener("error",()=>r(a),{once:!0}),a.addEventListener("load",()=>{a.naturalWidth===0&&r(a)},{once:!0});const s=a.src;a.src="",a.src=s}});const n=a=>{const s=a.target;s.tagName==="IMG"&&r(s)};return e.addEventListener("error",n,!0),()=>e.removeEventListener("error",n,!0)};function Us({value:e,onChange:r,placeholder:n="Escribe algo...",minHeight:a="80px",instanceId:s}){const l=o.useId(),i=s||l,c=o.useCallback(()=>document,[]),d=o.useRef(null),u=o.useRef(null),m=o.useRef(new Map),b=o.useRef(null),f=o.useRef(!1),h=o.useRef(e??""),v=o.useRef(r),k=o.useRef(()=>{}),g=o.useRef(!1),[A,$]=o.useState(()=>!e||e.trim()===""),[N,T]=o.useState(new Set),[x,y]=o.useState(null),[L,w]=o.useState(""),[W,X]=o.useState(""),[Z,D]=o.useState(""),[Q,j]=o.useState(""),[se,te]=o.useState(3),[ee,U]=o.useState(3),[J,ce]=o.useState(!0),[C,_]=o.useState(!1),[ae,B]=o.useState(null),[I,M]=o.useState(null),oe=o.useRef(null),K=o.useRef(!1),Y=o.useRef(null),S=o.useCallback(()=>f.current?u.current:d.current,[]);o.useEffect(()=>{v.current=r},[r]);const H=o.useCallback(()=>{const F=window.getSelection(),G=S();if(!F||!G||F.rangeCount===0||F.isCollapsed)return"";const fe=F.getRangeAt(0);return!G.contains(fe.startContainer)||!G.contains(fe.endContainer)?"":F.toString()},[S]);o.useEffect(()=>{const F=e??"";if(g.current&&F===h.current){g.current=!1,$(!F||F.trim()==="");return}g.current=!1,h.current=F;const G=[d.current,u.current].filter(be=>!!be);G.forEach(be=>{be.innerHTML!==F&&(be.innerHTML=F)}),$(!F||F.trim()===""),G.forEach(be=>eo(be));const fe=G.map(be=>qs(be));return()=>fe.forEach(be=>be())},[e]),o.useEffect(()=>{var be,Te;f.current=C;let F,G=0,fe;if(C){const ye=d.current;ye&&(h.current=Fn(ye));const Be=()=>{var Ye;const De=u.current;if(!De){G=requestAnimationFrame(Be);return}De.innerHTML!==h.current&&(De.innerHTML=h.current),F=qs(De),eo(De),$(((Ye=De.textContent)==null?void 0:Ye.trim())===""),fe=setTimeout(()=>De.focus(),60)};G=requestAnimationFrame(Be)}else{const ye=u.current,Be=d.current,De=ye?Fn(ye):h.current,Ye=h.current;h.current=De,Be&&Be.innerHTML!==De&&(Be.innerHTML=De),De!==Ye&&v.current(De),$(((Te=(be=ye??Be)==null?void 0:be.textContent)==null?void 0:Te.trim())==="")}return()=>{G&&cancelAnimationFrame(G),fe&&clearTimeout(fe),F==null||F()}},[C]);const O=o.useCallback(()=>{const F=["bold","italic","underline","strikeThrough","insertUnorderedList","insertOrderedList","justifyLeft","justifyCenter","justifyRight","justifyFull"],G=new Set;F.forEach(be=>{try{c().queryCommandState(be)&&G.add(be)}catch{return}});try{const be=cu(c().queryCommandValue("formatBlock"));be&&G.add(`formatBlock:${be}`)}catch{}const fe=H();ro(fe,"uppercase")&&G.add("__upper"),ro(fe,"lowercase")&&G.add("__lower"),ro(fe,"capitalize")&&G.add("__cap"),T(G)},[H,c]),re=()=>{var G;const F=S();F&&(h.current=Fn(F),g.current=!0,v.current(h.current),$(((G=F.textContent)==null?void 0:G.trim())===""))};k.current=re;const z=o.useCallback(()=>{Y.current&&(clearTimeout(Y.current),Y.current=null),oe.current&&(Os(oe.current),oe.current=null),K.current=!1,B(null),M(null)},[]),de=o.useCallback(()=>{Y.current&&(clearTimeout(Y.current),Y.current=null)},[]),he=o.useCallback(()=>{de(),Y.current=setTimeout(()=>{K.current||z()},280)},[de,z]);o.useEffect(()=>()=>{Y.current&&clearTimeout(Y.current)},[]);const ie=o.useCallback(F=>{const G=oe.current;if(!G||!G.isConnected){z();return}const fe=(ae==null?void 0:ae.rowIndex)??(I==null?void 0:I.rowIndex)??-1,be=(ae==null?void 0:ae.colIndex)??(I==null?void 0:I.colIndex)??-1;nu(F,G,fe,be,S()),z(),k.current(),O()},[S,z,O,I,ae]),ge=o.useCallback(F=>{if(I)return;const G=F.currentTarget,fe=F.target;if(fe.closest(".rich-table-action-bar, .rich-table-context-menu")){de();return}const be=fe.closest("td, th");if(!be||!G.contains(be)){he();return}const Te=be.closest("tr"),ye=be.closest("table");if(!Te||!ye||!G.contains(ye)){he();return}de(),ye.classList.add("rich-table"),oe.current=ye,Hs(ye,Te,be.cellIndex),B(ru(ye,Te,be))},[de,he,I]),Me=o.useCallback(F=>{const G=F.relatedTarget;if(G instanceof Element&&(G.closest(".rich-table-action-bar")||G.closest(".rich-table-context-menu"))){de();return}he()},[de,he]),$e=o.useCallback(F=>{const G=F.currentTarget,be=F.target.closest("td, th");if(!be||!G.contains(be))return;const Te=be.closest("tr"),ye=be.closest("table");if(!Te||!ye||!G.contains(ye))return;F.preventDefault(),ye.classList.add("rich-table"),oe.current=ye;const Be=Array.from(ye.rows).indexOf(Te),De=be.cellIndex;Hs(ye,Te,De),B(null),M({x:F.clientX,y:F.clientY,rowIndex:Be,colIndex:De})},[]);o.useEffect(()=>{if(!ae&&!I)return;const F=()=>he();return window.addEventListener("scroll",F,!0),window.addEventListener("resize",F),()=>{window.removeEventListener("scroll",F,!0),window.removeEventListener("resize",F)}},[he,I,ae]),o.useEffect(()=>{if(!I)return;const F=G=>{const fe=G.target;fe instanceof Element&&fe.closest(".rich-table-context-menu")||M(null)};return window.addEventListener("mousedown",F),()=>window.removeEventListener("mousedown",F)},[I]);const Dt=F=>{if(!F){const G=d.current;G&&(h.current=Fn(G))}_(!F)},ut=(F,G)=>{var fe;(fe=S())==null||fe.focus(),c().execCommand(F,!1,G),re(),O()},Re=F=>{ut("formatBlock",F)},It=()=>{var F;(F=S())==null||F.focus(),c().execCommand("insertHTML",!1,"<hr><p><br></p>"),re(),O()},Ct=()=>{const F=window.getSelection();F&&F.rangeCount>0&&(b.current=F.getRangeAt(0).cloneRange())},Et=()=>{const F=window.getSelection();F&&b.current&&(F.removeAllRanges(),F.addRange(b.current))},le=F=>{if(Ct(),F==="link"){const G=window.getSelection();X(G&&!G.isCollapsed?G.toString():""),w("")}F==="image"&&(D(""),j("")),F==="table"&&(te(3),U(3),ce(!0)),y(F)},Fe=()=>{var be;if(!L.trim())return;Et(),(be=S())==null||be.focus();const F=window.getSelection(),fe=(F&&!F.isCollapsed?F.toString():"")||W.trim()||L.trim();c().execCommand("insertHTML",!1,`<a href="${rn(L.trim())}" target="_blank" rel="noopener noreferrer" class="rich-link">${rn(fe)}</a>`),re(),y(null)},ze=(F,G="")=>`<span class="rich-img-wrap" contenteditable="false"><img src="${rn(F)}" alt="${rn(G)}" class="rich-img" />${zs()}</span>`,ft=()=>{var F;Z.trim()&&(Et(),(F=S())==null||F.focus(),c().execCommand("insertHTML",!1,ze(Z.trim(),Q.trim())),re(),y(null))},Ve=()=>{var F;Et(),(F=S())==null||F.focus(),c().execCommand("insertHTML",!1,iu(se,ee,J)),re(),y(null)},Mt=(F,G=1200,fe=1200,be=.72)=>new Promise((Te,ye)=>{const Be=new FileReader;Be.onerror=ye,Be.onload=De=>{var Ot;const Ye=(Ot=De.target)==null?void 0:Ot.result,Ze=new Image;Ze.onerror=ye,Ze.onload=()=>{let{width:ot,height:it}=Ze;if(ot>G||it>fe){const fn=Math.min(G/ot,fe/it);ot=Math.round(ot*fn),it=Math.round(it*fn)}const cr=document.createElement("canvas");cr.width=ot,cr.height=it;const qt=cr.getContext("2d");if(!qt){Te(Ye);return}qt.drawImage(Ze,0,0,ot,it),Te(cr.toDataURL("image/jpeg",be))},Ze.src=Ye},Be.readAsDataURL(F)}),bt=F=>{F.focus();const G=window.getSelection();if(!G||G.rangeCount===0||!F.contains(G.anchorNode)){const fe=document.createRange();fe.selectNodeContents(F),fe.collapse(!1),G==null||G.removeAllRanges(),G==null||G.addRange(fe)}},rt=o.useRef(()=>{});rt.current=F=>{const G=S();G&&(bt(G),c().execCommand("insertHTML",!1,F),eo(G),G.querySelectorAll("p").forEach(fe=>{!(fe.textContent??"").replace(/[\u00a0\s]+/g,"")&&!fe.querySelector("img, hr, table")&&fe.remove()}),re(),O())};const Wt=o.useRef(Mt);Wt.current=Mt;const ue=o.useRef(ze);ue.current=ze;const pe=o.useCallback(F=>{if(!F||m.current.has(F))return;const G=fe=>{const be=fe.clipboardData;if(!be)return;const Te=be.getData("text/html"),ye=be.getData("text/plain");if(Te||ye){fe.preventDefault(),fe.stopPropagation();try{const Ze=Te?Nu(Te):to(ye);if(!Ze){ye&&rt.current(to(ye));return}rt.current(Ze)}catch{ye&&rt.current(to(ye))}return}const De=Array.from(be.items).find(Ze=>Ze.type.startsWith("image/"));if(!De)return;fe.preventDefault(),fe.stopPropagation();const Ye=De.getAsFile();Ye&&Wt.current(Ye).then(Ze=>{rt.current(ue.current(Ze,"imagen"))})};F.addEventListener("paste",G,!0),m.current.set(F,()=>{F.removeEventListener("paste",G,!0),m.current.delete(F)})},[]),Le=o.useCallback(F=>{var fe;const G=d.current;G&&G!==F&&((fe=m.current.get(G))==null||fe()),d.current=F,F&&pe(F)},[pe]),He=o.useCallback(F=>{var fe;const G=u.current;G&&G!==F&&((fe=m.current.get(G))==null||fe()),u.current=F,F&&pe(F)},[pe]);o.useEffect(()=>{const F=m.current;return()=>{F.forEach(G=>G()),F.clear()}},[]);const Ie=F=>{const G=window.getSelection(),fe=S();if(!G||!fe||G.rangeCount===0||G.isCollapsed)return;const be=G.getRangeAt(0);if(!fe.contains(be.startContainer)||!fe.contains(be.endContainer))return;const Te=be.toString();if(!Te)return;let ye=Te;F==="uppercase"?ye=Te.toLocaleUpperCase():F==="lowercase"?ye=Te.toLocaleLowerCase():ye=Ws(Te),be.deleteContents();const Be=document.createTextNode(ye);be.insertNode(Be);const De=document.createRange();De.setStart(Be,0),De.setEnd(Be,ye.length),G.removeAllRanges(),G.addRange(De),b.current=De.cloneRange(),re(),O()},tt=()=>{Ct(),O()},at=()=>{const F=S();F&&Bs(F),re(),O()},We=()=>{requestAnimationFrame(()=>{var F;(F=S())==null||F.focus()})},Ke=F=>{var G,fe;if((F.metaKey||F.ctrlKey)&&F.key==="Enter"){if(F.preventDefault(),F.stopPropagation(),F.repeat)return;(G=S())==null||G.focus(),c().execCommand("insertLineBreak",!1)||c().execCommand("insertHTML",!1,"<br>"),re(),O();return}if(F.key==="Tab"){const be=window.getSelection(),Te=Ps((be==null?void 0:be.anchorNode)??null),ye=S(),Be=Fs(Te);if(Te&&Be&&(ye!=null&&ye.contains(Te))){F.preventDefault();const De=ou(Be),Ye=De.indexOf(Te),Ze=Ye>=0?De[Ye+1]:null;if(Ze)_n(Ze,ye,!0);else if(_s(Te,Be)){const Ot=Ra(Be);Ot&&_n(Ot,ye,!0)}re(),O();return}F.preventDefault(),(fe=S())==null||fe.focus(),c().execCommand("insertText",!1," "),re(),O();return}if(F.key==="Enter"&&!F.shiftKey&&!(F.metaKey||F.ctrlKey)){const be=window.getSelection(),Te=Ps((be==null?void 0:be.anchorNode)??null),ye=S(),Be=Fs(Te);if(Te&&Be&&(ye!=null&&ye.contains(Te))&&_s(Te,Be)&&su(Te)){F.preventDefault();const De=Ra(Be);De&&_n(De,ye,!0),re(),O();return}}if(F.key==="Escape"){if(I){M(null);return}if(x){y(null);return}if(f.current){_(!1);return}}x||(F.ctrlKey||F.metaKey)&&(F.key==="b"&&(F.preventDefault(),ut("bold")),F.key==="i"&&(F.preventDefault(),ut("italic")),F.key==="u"&&(F.preventDefault(),ut("underline")),F.key==="k"&&(F.preventDefault(),le("link")))},Ge=()=>t.jsx("div",{className:"h-4 w-px flex-shrink-0 mx-1",style:{background:"var(--border)"}}),Ae=(F,G,fe,be,Te)=>{const ye=Te??(N.has(fe)||fe==="__link"&&x==="link"||fe==="__img"&&x==="image"||fe==="__table"&&x==="table");return t.jsx("button",{type:"button",title:G,tabIndex:-1,onFocus:We,onMouseDown:Be=>{Be.preventDefault(),be?be():ut(fe)},className:"flex h-7 w-7 items-center justify-center rounded text-xs font-bold transition-colors",style:{color:ye?"var(--primary)":"var(--text-secondary)",background:ye?"rgba(59,130,246,0.12)":"transparent"},children:F},fe)},lr=F=>{const G=F.target;if(G.closest("[data-action='delete-img']")){F.preventDefault();const fe=G.closest(".rich-img-wrap");fe&&(fe.remove(),re())}},ir=()=>{de(),K.current=!0},Or=()=>{K.current=!1,he()},Jt=(F,G,fe,be=!1)=>t.jsx("button",{type:"button",className:`rich-table-action-btn${be?" rich-table-action-btn--danger":""}`,title:F,"aria-label":F,onMouseDown:Te=>{Te.preventDefault(),Te.stopPropagation(),ie(fe)},children:G}),oa=()=>typeof document>"u"||!ae&&!I?null:ct.createPortal(t.jsxs(t.Fragment,{children:[ae&&!I&&t.jsxs("div",{className:"rich-table-action-bar",style:{left:ae.bar.x,top:ae.bar.y},onMouseEnter:ir,onMouseLeave:Or,children:[t.jsxs("span",{className:"rich-table-action-hint",children:["Fila ",ae.rowIndex+1," · Col ",ae.colIndex+1]}),t.jsxs("div",{className:"rich-table-action-group",children:[t.jsx("span",{className:"rich-table-action-label",children:"Fila"}),Jt("Añadir fila abajo","+","table-row-add"),Jt("Eliminar fila","−","table-row-del")]}),t.jsxs("div",{className:"rich-table-action-group",children:[t.jsx("span",{className:"rich-table-action-label",children:"Columna"}),Jt("Añadir columna a la derecha","+","table-col-add"),Jt("Eliminar columna","−","table-col-del")]}),Jt("Eliminar tabla","Eliminar","table-delete",!0)]}),I&&t.jsx("div",{className:"rich-table-context-menu",style:{left:I.x,top:I.y},onMouseDown:F=>F.stopPropagation(),children:[["Añadir fila abajo","table-row-add"],["Eliminar fila","table-row-del"],["Añadir columna a la derecha","table-col-add"],["Eliminar columna","table-col-del"],["Eliminar tabla","table-delete"]].map(([F,G])=>t.jsx("button",{type:"button",onMouseDown:fe=>{fe.preventDefault(),ie(G)},children:F},G))})]}),document.body),lt=F=>t.jsxs(t.Fragment,{children:[x==="link"&&t.jsxs("div",{className:"flex flex-shrink-0 flex-wrap items-center gap-2 border-t px-3 py-2",style:{borderColor:"var(--border)",background:F},children:[t.jsx("input",{autoFocus:!0,type:"url",value:L,onChange:G=>w(G.target.value),onKeyDown:G=>{G.key==="Enter"&&(G.preventDefault(),Fe()),G.key==="Escape"&&y(null)},placeholder:"https://...",className:"min-w-0 flex-1 rounded px-2 py-1 text-xs focus:outline-none",style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-main)"}}),t.jsx("input",{type:"text",value:W,onChange:G=>X(G.target.value),onKeyDown:G=>{G.key==="Enter"&&(G.preventDefault(),Fe()),G.key==="Escape"&&y(null)},placeholder:"Texto (opcional)",className:"w-32 rounded px-2 py-1 text-xs focus:outline-none",style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-main)"}}),t.jsx("button",{type:"button",onClick:Fe,className:"rounded px-2.5 py-1 text-xs font-semibold text-white",style:{background:"var(--primary)"},children:"OK"}),t.jsx("button",{type:"button",onClick:()=>y(null),className:"rounded px-2 py-1 text-xs",style:{color:"var(--text-muted)"},children:"x"})]}),x==="table"&&t.jsxs("div",{className:"flex flex-shrink-0 flex-wrap items-center gap-2 border-t px-3 py-2",style:{borderColor:"var(--border)",background:F},children:[t.jsxs("label",{className:"flex items-center gap-1 text-xs",style:{color:"var(--text-secondary)"},children:["Filas",t.jsx("input",{autoFocus:!0,type:"number",min:1,max:Sr,value:se,onChange:G=>te(Hn(Number(G.target.value),1,Sr)),onKeyDown:G=>{G.key==="Enter"&&(G.preventDefault(),Ve()),G.key==="Escape"&&y(null)},className:"w-14 rounded px-2 py-1 text-xs focus:outline-none",style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-main)"}})]}),t.jsxs("label",{className:"flex items-center gap-1 text-xs",style:{color:"var(--text-secondary)"},children:["Columnas",t.jsx("input",{type:"number",min:1,max:Bn,value:ee,onChange:G=>U(Hn(Number(G.target.value),1,Bn)),onKeyDown:G=>{G.key==="Enter"&&(G.preventDefault(),Ve()),G.key==="Escape"&&y(null)},className:"w-14 rounded px-2 py-1 text-xs focus:outline-none",style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-main)"}})]}),t.jsxs("label",{className:"flex items-center gap-1.5 text-xs",style:{color:"var(--text-secondary)"},children:[t.jsx("input",{type:"checkbox",checked:J,onChange:G=>ce(G.target.checked)}),"Encabezado"]}),t.jsx("button",{type:"button",onClick:Ve,className:"rounded px-2.5 py-1 text-xs font-semibold text-white",style:{background:"var(--primary)"},children:"OK"}),t.jsx("button",{type:"button",onClick:()=>y(null),className:"rounded px-2 py-1 text-xs",style:{color:"var(--text-muted)"},children:"x"})]}),x==="image"&&t.jsxs("div",{className:"flex flex-shrink-0 flex-wrap items-center gap-2 border-t px-3 py-2",style:{borderColor:"var(--border)",background:F},children:[t.jsx("input",{autoFocus:!0,type:"url",value:Z,onChange:G=>D(G.target.value),onKeyDown:G=>{G.key==="Enter"&&(G.preventDefault(),ft()),G.key==="Escape"&&y(null)},placeholder:"URL de la imagen...",className:"min-w-0 flex-1 rounded px-2 py-1 text-xs focus:outline-none",style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-main)"}}),t.jsx("input",{type:"text",value:Q,onChange:G=>j(G.target.value),onKeyDown:G=>{G.key==="Enter"&&(G.preventDefault(),ft()),G.key==="Escape"&&y(null)},placeholder:"Texto alt",className:"w-28 rounded px-2 py-1 text-xs focus:outline-none",style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-main)"}}),t.jsx("button",{type:"button",onClick:ft,className:"rounded px-2.5 py-1 text-xs font-semibold text-white",style:{background:"var(--primary)"},children:"OK"}),t.jsx("button",{type:"button",onClick:()=>y(null),className:"rounded px-2 py-1 text-xs",style:{color:"var(--text-muted)"},children:"x"})]})]}),jt=(F,G)=>t.jsxs("div",{className:"flex flex-shrink-0 flex-wrap items-center gap-0.5 border-t px-2 py-1",style:{borderColor:"var(--border)",background:G},children:[Ae(t.jsx(q.HiArrowUturnLeft,{className:"h-4 w-4"}),"Deshacer","undo"),Ae(t.jsx(q.HiArrowUturnRight,{className:"h-4 w-4"}),"Rehacer","redo"),Ge(),Ae(t.jsx("span",{style:{fontSize:"10px"},children:"P"}),"Parrafo","__paragraph",()=>Re("p"),N.has("formatBlock:p")||N.has("formatBlock:div")),Ae(t.jsx(q.HiH2,{className:"h-4 w-4"}),"Titulo 2","__h2",()=>Re("h2"),N.has("formatBlock:h2")),Ae(t.jsx(q.HiH3,{className:"h-4 w-4"}),"Titulo 3","__h3",()=>Re("h3"),N.has("formatBlock:h3")),Ae(t.jsx("span",{style:{fontSize:"13px",lineHeight:1},children:"“"}),"Cita","__quote",()=>Re("blockquote"),N.has("formatBlock:blockquote")),Ge(),Ae(t.jsx("b",{children:"B"}),"Negrita (Ctrl+B)","bold"),Ae(t.jsx("i",{children:"I"}),"Cursiva (Ctrl+I)","italic"),Ae(t.jsx("u",{children:"U"}),"Subrayado (Ctrl+U)","underline"),Ae(t.jsx("s",{children:"S"}),"Tachado","strikeThrough"),Ge(),Ae(t.jsx(q.HiListBullet,{className:"h-4 w-4"}),"Lista sin orden","insertUnorderedList"),Ae(t.jsx(q.HiNumberedList,{className:"h-4 w-4"}),"Lista numerada","insertOrderedList"),Ae(t.jsx(q.HiArrowTurnUpLeft,{className:"h-4 w-4"}),"Disminuir sangria","outdent"),Ae(t.jsx(q.HiArrowTurnDownRight,{className:"h-4 w-4"}),"Aumentar sangria","indent"),Ge(),Ae(t.jsx(q.HiBars3BottomLeft,{className:"h-4 w-4"}),"Alinear izquierda","justifyLeft"),Ae(t.jsx(q.HiBars3CenterLeft,{className:"h-4 w-4"}),"Centrar","justifyCenter"),Ae(t.jsx(q.HiBars3BottomRight,{className:"h-4 w-4"}),"Alinear derecha","justifyRight"),Ae(t.jsx(q.HiBars3,{className:"h-4 w-4"}),"Justificar","justifyFull"),Ge(),Ae(t.jsx("span",{style:{fontSize:"10px"},children:"AA"}),"Mayusculas","__upper",()=>Ie("uppercase")),Ae(t.jsx("span",{style:{fontSize:"10px"},children:"aa"}),"Minusculas","__lower",()=>Ie("lowercase")),Ae(t.jsx("span",{style:{fontSize:"10px"},children:"Aa"}),"Capitalizar","__cap",()=>Ie("capitalize")),Ge(),Ae(t.jsx(q.HiLink,{className:"h-4 w-4"}),"Insertar enlace (Ctrl+K)","__link",()=>le("link")),Ae(t.jsx(q.HiLinkSlash,{className:"h-4 w-4"}),"Quitar enlace","unlink"),Ae(t.jsx(q.HiPhoto,{className:"h-4 w-4"}),"Insertar imagen","__img",()=>le("image")),Ae(t.jsx(q.HiTableCells,{className:"h-4 w-4"}),"Insertar tabla","__table",()=>le("table")),Ae(t.jsx(q.HiMinus,{className:"h-4 w-4"}),"Insertar separador","__divider",It),Ge(),Ae(t.jsx(q.HiOutlinePaintBrush,{className:"h-4 w-4"}),"Limpiar formato","removeFormat"),Ae(t.jsx(q.HiNoSymbol,{className:"h-4 w-4"}),"Quitar bloque","__clearBlock",()=>Re("p")),Ge(),t.jsx("button",{type:"button",title:F?"Salir del modo de enfoque (Esc)":"Modo de enfoque",tabIndex:-1,onFocus:We,onMouseDown:fe=>{fe.preventDefault(),Dt(F)},className:"flex h-7 w-7 items-center justify-center rounded transition-colors",style:{color:"var(--text-secondary)"},children:F?t.jsx(q.HiArrowsPointingIn,{className:"h-4 w-4"}):t.jsx(q.HiArrowsPointingOut,{className:"h-4 w-4"})})]});return t.jsxs(t.Fragment,{children:[oa(),t.jsxs("div",{className:"overflow-hidden rounded-lg transition-all duration-150 ring-1 ring-transparent focus-within:ring-primary/30",style:{border:"1px solid var(--border)"},children:[t.jsx("div",{ref:Le,contentEditable:!0,suppressContentEditableWarning:!0,"data-bonsaif-rich-instance":i,onInput:at,onKeyDown:Ke,onKeyUp:tt,onSelect:tt,onMouseUp:tt,onMouseMove:ge,onMouseLeave:Me,onContextMenu:$e,onMouseDown:lr,"data-placeholder":n,className:`rich-editor px-3 py-2 text-sm focus:outline-none${A?" is-empty":""}`,style:{color:"var(--text-main)",background:"var(--bg-input)",minHeight:a,maxHeight:"320px",overflowY:"auto",lineHeight:"1.6"}}),lt("var(--bg-input)"),jt(!1,"var(--bg-input)")]}),t.jsxs(Oa,{open:C,onClose:()=>_(!1),title:"Modo de enfoque",subtitle:"Esc para salir",maxWidth:"920px",bodyClassName:"flex min-h-0 flex-col p-0",panelClassName:"h-[88vh]",backdropClassName:"bg-black/50 backdrop-blur-[2px]",children:[t.jsx("div",{ref:He,contentEditable:!0,suppressContentEditableWarning:!0,"data-bonsaif-rich-instance":i,onInput:at,onKeyDown:Ke,onKeyUp:tt,onSelect:tt,onMouseUp:tt,onMouseMove:ge,onMouseLeave:Me,onContextMenu:$e,onMouseDown:lr,"data-placeholder":n,className:`rich-editor min-h-0 flex-1 overflow-y-auto px-8 py-6 text-sm focus:outline-none${A?" is-empty":""}`,style:{color:"var(--text-main)",background:"var(--bg-card)",lineHeight:"1.75"}}),lt("var(--bg-input)"),jt(!0,"var(--bg-input)")]})]})}const Vs="[a-zA-Z0-9._@-]+",no=new RegExp(`@(${Vs})`,"g"),Su=/[a-zA-Z0-9._@-]/,nn=new Set([" ",`
|
|
26
|
-
`," ","\r"," ","(","[","{",".",",",";",":","!","?","¿","¡",")","]","}",'"',"'","«","»","/","\\","|","-","—","–"]);function
|
|
23
|
+
</body></html>`,ke=window.open("","_blank");ke&&(ke.document.write(me),ke.document.close())}const Sa=()=>!Re||!mn?null:ct.createPortal(t.jsxs("div",{ref:So,role:"menu",className:"overflow-hidden rounded-lg border p-1 shadow-xl",style:{...$b,position:"fixed",zIndex:9999,minWidth:170,borderColor:"var(--border)",background:"var(--bg-card)"},children:[t.jsxs("button",{type:"button",role:"menuitem",className:"flex w-full items-center gap-2.5 rounded-md px-2.5 py-1.5 text-sm transition-colors hover:bg-[var(--bg-input)]",style:{color:"var(--text-main)"},onClick:()=>{(async()=>(Ct?await Ct():sm(),ia(!1)))()},children:[t.jsx(q.HiTableCells,{className:"h-4 w-4 shrink-0 text-emerald-500"}),"Descargar CSV / Excel"]}),t.jsxs("button",{type:"button",role:"menuitem",className:"flex w-full items-center gap-2.5 rounded-md px-2.5 py-1.5 text-sm transition-colors hover:bg-[var(--bg-input)]",style:{color:"var(--text-main)"},onClick:()=>{(async()=>(Et?await Et():lm(),ia(!1)))()},children:[t.jsx(q.HiDocumentText,{className:"h-4 w-4 shrink-0 text-red-500"}),"Imprimir / PDF"]})]}),document.body),Ca=()=>{const p=Y&&Ye.trim().length>0,M=ge!=null&&ge.length?ge:p?[{key:"bql",label:"BQL",value:Ye}]:[],R=ie.filter(P=>{const ne=P.trim();return ne?!new Set(Ze.split(`
|
|
24
|
+
`).map(ke=>ke.trim()).filter(Boolean)).has(ne):!1}).slice(0,8);return!ae&&Eo===0&&!Y&&!Re?null:t.jsxs("div",{className:"relative flex min-h-9 flex-wrap items-center justify-between gap-2 border-b rounded-t-lg px-2 py-1",style:{borderColor:"var(--border)",background:"var(--bg-input)"},children:[t.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[Eo>0&&t.jsxs("button",{type:"button",onClick:jb,className:"inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs font-medium text-[var(--primary)] transition-colors hover:bg-[var(--bg-card)]",children:[t.jsx(q.HiXMark,{className:"h-3.5 w-3.5"}),Eo," filtros"]}),Y&&t.jsxs("div",{ref:No,className:"relative flex min-w-0 flex-1 items-center gap-2",children:[t.jsxs("button",{type:"button",onClick:()=>{if(ot){it(!1);return}ha(),it(!0)},className:"inline-flex h-7 shrink-0 items-center gap-1.5 rounded-md border px-2 text-xs font-bold transition-colors",style:{background:ot?"var(--primary)":p?"color-mix(in srgb, var(--primary) 12%, transparent)":"var(--bg-card)",borderColor:ot||p?"var(--primary)":"var(--border)",color:ot?"var(--primary-fg)":"var(--primary)"},"aria-expanded":ot,title:"Abrir filtros BQL",children:[t.jsx(q.HiCommandLine,{className:"h-3.5 w-3.5"}),"BQL",p&&t.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-current"}),ot?t.jsx(q.HiChevronUp,{className:"h-3.5 w-3.5"}):t.jsx(q.HiChevronDown,{className:"h-3.5 w-3.5"})]}),t.jsx("span",{className:"hidden truncate text-xs text-[var(--text-muted)] sm:inline",children:re}),M.length>0&&t.jsxs("div",{className:"hidden min-w-0 items-center gap-1.5 overflow-hidden lg:flex",children:[M.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)),M.length>3&&t.jsxs("span",{className:"text-xs text-[var(--text-muted)]",children:["+",M.length-3]})]}),p&&t.jsx("button",{type:"button","aria-label":"Limpiar BQL",title:"Limpiar BQL",onClick:fi,className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-[var(--text-muted)] transition-colors hover:bg-[var(--bg-card)] hover:text-[var(--primary)]",children:t.jsx(q.HiXMark,{className:"h-4 w-4"})}),ot&&ct.createPortal(t.jsxs("div",{ref:Rl,className:"flex flex-col gap-3 rounded-lg p-3 shadow-2xl",style:{...Cb,background:"var(--bg-card)",border:"1px solid color-mix(in srgb, var(--primary) 35%, var(--border))"},children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[de.map(P=>t.jsxs("button",{type:"button",onMouseDown:ne=>{ne.preventDefault(),ne.stopPropagation()},onClick:ne=>{ne.preventDefault(),ne.stopPropagation(),pa(P.bql)},className:"inline-flex h-7 items-center gap-1.5 rounded-md border px-2.5 text-xs font-semibold transition-colors hover:border-[var(--primary)] hover:text-[var(--primary)]",style:{background:"var(--bg-input)",borderColor:"var(--border)",color:"var(--text-secondary)"},children:[P.icon,P.label]},P.label)),he.length>0&&t.jsxs("button",{type:"button",onClick:()=>qt(P=>!P),className:"inline-flex h-7 items-center gap-1.5 rounded-md px-2 text-xs font-medium text-[var(--text-muted)] transition-colors hover:bg-[var(--bg-input)] hover:text-[var(--primary)]","aria-expanded":cr,children:[t.jsx(q.HiInformationCircle,{className:"h-3.5 w-3.5"}),"Ejemplos"]}),bn.length>0&&t.jsxs("button",{type:"button",onClick:()=>Hr(P=>!P),className:"inline-flex h-7 items-center gap-1.5 rounded-md px-2 text-xs font-medium text-[var(--text-muted)] transition-colors hover:bg-[var(--bg-input)] hover:text-[var(--primary)]","aria-expanded":fn,children:[t.jsx(q.HiClock,{className:"h-3.5 w-3.5"}),"Historial"]})]}),t.jsxs("div",{className:"overflow-hidden rounded-lg",style:{background:"var(--bg-input)",border:`1.5px solid ${Me?"var(--danger)":p?"var(--primary)":"var(--border)"}`},children:[t.jsx("textarea",{ref:ko,value:Ze,rows:3,onChange:P=>To(P.target.value,P.target),onKeyDown:P=>{P.key==="Enter"&&!P.shiftKey&&(P.preventDefault(),ui(Ze)),P.key==="Escape"&&it(!1)},placeholder:z,autoComplete:"off",spellCheck:!1,className:"block w-full px-4 py-3 text-sm outline-none",style:{background:"var(--bg-input)",color:"var(--text-main)",border:"none",fontFamily:"'SF Mono', 'Fira Code', 'Consolas', monospace",lineHeight:1.6,maxHeight:180,minHeight:88,overflowY:"auto",resize:"vertical"}}),R.length>0&&t.jsx("div",{className:"border-t border-[var(--border)] bg-[var(--bg-card)]",children:R.map(P=>t.jsx("button",{type:"button",onMouseDown:ne=>{ne.preventDefault(),ne.stopPropagation()},onClick:ne=>{ne.preventDefault(),ne.stopPropagation(),pa(P)},className:"block w-full px-4 py-2 text-left text-xs transition-colors hover:bg-[var(--bg-hover)] hover:text-[var(--primary)]",style:{fontFamily:"'SF Mono', 'Fira Code', 'Consolas', monospace"},children:P},P))})]}),t.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[t.jsx("span",{className:"min-w-0 text-xs",style:{color:Me?"var(--danger)":"var(--text-muted)"},children:Me??(p?`${M.length||1} filtro${(M.length||1)===1?"":"s"} activo${(M.length||1)===1?"":"s"}`:"Enter aplica la consulta. Shift + Enter agrega linea.")}),M.map(P=>t.jsxs("span",{className:"inline-flex max-w-56 items-center gap-1 truncate rounded-full px-2 py-1 text-xs font-medium",style:{background:"var(--bg-hover)",border:"1px solid var(--primary)",color:"var(--primary)"},children:[t.jsxs("span",{className:"text-[var(--text-muted)]",children:[P.label,":"]}),t.jsx("span",{className:"truncate",children:P.value})]},P.key))]}),fn&&bn.length>0&&t.jsxs("div",{className:"overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-input)]",children:[t.jsxs("div",{className:"flex items-center justify-between border-b border-[var(--border)] px-3 py-2",children:[t.jsxs("span",{className:"flex items-center gap-1.5 text-xs font-semibold text-[var(--text-secondary)]",children:[t.jsx(q.HiClock,{className:"h-3.5 w-3.5"}),"Historial"]}),t.jsxs("button",{type:"button",onClick:()=>{Br([]),Hr(!1)},className:"inline-flex items-center gap-1 rounded px-2 py-0.5 text-xs text-[var(--text-muted)]",children:[t.jsx(q.HiTrash,{className:"h-3 w-3"}),"Limpiar"]})]}),bn.map(P=>t.jsxs("div",{className:"group flex items-center gap-2 border-b border-[var(--border)] px-3 py-2 last:border-b-0",children:[t.jsx("button",{type:"button",onMouseDown:ne=>{ne.preventDefault(),ne.stopPropagation()},onClick:ne=>{ne.preventDefault(),ne.stopPropagation(),pa(P)},className:"min-w-0 flex-1 text-left",children:t.jsx("code",{className:"block truncate text-xs text-[var(--primary)]",children:P})}),t.jsx("button",{type:"button",onClick:()=>Br(ne=>ne.filter(me=>me!==P)),className:"rounded p-1 text-[var(--text-muted)] opacity-0 transition-opacity group-hover:opacity-100",children:t.jsx(q.HiXMark,{className:"h-3.5 w-3.5"})})]},P))]}),cr&&he.length>0&&t.jsx("div",{className:"grid gap-2 sm:grid-cols-2 lg:grid-cols-3",children:he.map(P=>t.jsxs("button",{type:"button",onMouseDown:ne=>{ne.preventDefault(),ne.stopPropagation()},onClick:ne=>{ne.preventDefault(),ne.stopPropagation(),pa(P.bql),qt(!1)},className:"rounded-lg border border-[var(--border)] bg-[var(--bg-input)] p-2 text-left transition-colors hover:border-[var(--primary)]",children:[t.jsx("code",{className:"block truncate text-xs text-[var(--primary)]",children:P.bql}),P.description&&t.jsx("span",{className:"mt-1 block text-xs text-[var(--text-muted)]",children:P.description})]},P.bql))}),t.jsxs("div",{className:"flex items-center justify-end gap-2 border-t border-[var(--border)] pt-3",children:[p&&t.jsxs("button",{type:"button",onClick:fi,className:"inline-flex h-8 items-center gap-1 rounded-md px-2.5 text-xs font-medium text-[var(--text-muted)] transition-colors hover:bg-[var(--bg-input)] hover:text-[var(--primary)]",children:[t.jsx(q.HiXMark,{className:"h-3.5 w-3.5"}),"Limpiar"]}),t.jsxs("button",{type:"button",onClick:()=>ui(Ze),className:"inline-flex h-8 items-center gap-1.5 rounded-md bg-[var(--primary)] px-4 text-xs font-semibold text-[var(--primary-fg)] transition-opacity hover:opacity-90",children:[t.jsx(q.HiCheck,{className:"h-3.5 w-3.5"}),"Aplicar"]})]})]}),document.body)]})]}),Re&&t.jsx("button",{ref:ca,type:"button","aria-haspopup":"menu","aria-expanded":mn,"aria-label":"Exportar datos",title:"Exportar datos",onClick:()=>{var ne;const P=(ne=ca.current)==null?void 0:ne.getBoundingClientRect();P&&Ab({top:P.bottom+4,right:window.innerWidth-P.right}),ia(me=>!me)},className:`inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-[var(--text-muted)] transition-colors hover:bg-[var(--bg-card)] hover:text-[var(--primary)] focus:bg-[var(--bg-card)] focus:text-[var(--primary)] ${mn?"bg-[var(--bg-card)] text-[var(--primary)]":""}`,children:t.jsx(q.HiArrowDownTray,{className:"h-4 w-4"})}),ae&&t.jsx("button",{type:"button","aria-haspopup":"menu","aria-expanded":Ke&&Ae==="visibility","aria-label":K,title:K,onClick:P=>mi(P,"visibility"),className:`inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-[var(--text-muted)] transition-colors hover:bg-[var(--bg-card)] hover:text-[var(--primary)] focus:bg-[var(--bg-card)] focus:text-[var(--primary)] ${Ke&&Ae==="visibility"?"bg-[var(--bg-card)] text-[var(--primary)]":""}`,children:t.jsx(q.HiCog6Tooth,{className:"h-4 w-4"})})]})},Ti=()=>{if(!tm)return null;const p=Hc(st,Bo);return t.jsxs("div",{"aria-busy":a,className:`grid grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)] items-center gap-2 rounded-b-xl border-t text-xs select-none ${J?"px-2 py-0.5":"px-3 py-1"}`,style:{borderColor:"var(--border)",background:"var(--bg-input)"},children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx("span",{style:{color:"var(--text-muted)"},children:Ut===0?"0 filas":`${rm}–${nm} de ${Ut}`}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("span",{style:{color:"var(--text-muted)"},children:"Filas:"}),t.jsx(ar,{value:String(Ft),onChange:M=>am(Number(M)),options:Lo.map(M=>({value:String(M),label:String(M)})),placeholder:"Filas",searchable:!1,disabled:a,height:X,padding:Z,className:"shrink-0 [&>button]:rounded-md [&>button]:text-xs [&_svg]:h-3.5 [&_svg]:w-3.5",style:{width:W}})]})]}),t.jsxs("div",{className:"flex items-center justify-center gap-0.5",children:[t.jsx("button",{disabled:a||st<=1,onClick:()=>Fo(st-1),onMouseEnter:M=>{M.currentTarget.disabled||(M.currentTarget.style.background="color-mix(in srgb, var(--primary) 14%, var(--bg-card))",M.currentTarget.style.color="var(--primary)")},onMouseLeave:M=>{M.currentTarget.style.background="transparent",M.currentTarget.style.color="var(--text-muted)"},className:"cursor-pointer rounded p-0.5 transition-colors disabled:cursor-not-allowed disabled:opacity-30",style:{background:"transparent",color:"var(--text-muted)"},children:t.jsx(q.HiChevronLeft,{className:"h-3.5 w-3.5"})}),p.map((M,R)=>M==="..."?t.jsx("span",{className:"px-1",style:{color:"var(--text-muted)"},children:"…"},`e${R}`):t.jsx("button",{disabled:a,onClick:()=>Fo(M),onMouseEnter:P=>{P.currentTarget.disabled||M===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=M===st?"var(--primary)":"transparent",P.currentTarget.style.color=M===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:M===st?"var(--primary)":"transparent",color:M===st?"var(--primary-fg)":"var(--text-muted)"},children:M},M)),t.jsx("button",{disabled:a||st>=Bo,onClick:()=>Fo(st+1),onMouseEnter:M=>{M.currentTarget.disabled||(M.currentTarget.style.background="color-mix(in srgb, var(--primary) 14%, var(--bg-card))",M.currentTarget.style.color="var(--primary)")},onMouseLeave:M=>{M.currentTarget.style.background="transparent",M.currentTarget.style.color="var(--text-muted)"},className:"cursor-pointer rounded p-0.5 transition-colors disabled:cursor-not-allowed disabled:opacity-30",style:{background:"transparent",color:"var(--text-muted)"},children:t.jsx(q.HiChevronRight,{className:"h-3.5 w-3.5"})})]}),t.jsx("div",{"aria-hidden":"true"})]})},im=()=>t.jsxs("div",{className:"w-full min-w-0 max-w-full flex flex-col rounded-lg overflow-hidden",style:{background:"var(--bg-card)",boxShadow:ya},children:[Na(),Sa(),Ca(),t.jsx("div",{ref:Rt,className:"min-w-0 max-w-full overflow-hidden",children:t.jsxs("div",{role:"table",className:"text-sm",style:{width:gn,minWidth:xa},children:[t.jsx("div",{role:"rowgroup",style:y?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:wa()}),t.jsx("div",{role:"rowgroup",children:Array.from({length:Math.min(6,s)}).map((p,M)=>t.jsxs("div",{role:"row",className:"grid",style:{gridTemplateColumns:jr,borderBottom:`1px solid ${Oe}`},children:[Tt&&t.jsx("div",{role:"cell",className:`${J?"px-2 py-1.5":"px-3 py-2"} w-10`,style:{borderBottom:`1px solid ${Oe}`,borderRight:`1px solid ${Oe}`}},"select-cell"),wt.map((R,P)=>t.jsx("div",{role:"cell",className:J?"px-2 py-1.5":"px-3 py-2",style:{borderBottom:`1px solid ${Oe}`,borderRight:`1px solid ${Oe}`},children:t.jsx("div",{className:"h-3.5 rounded-full animate-pulse",style:{background:"var(--border)",width:`${ni(M,P)}%`,minWidth:32}})},R.key))]},M))})]})})]}),_o="min-w-0 max-w-full overflow-hidden";return te&&Fe&&!bt?t.jsx(wn,{rows:s,columns:Math.max(4,wt.length||7)}):!a&&r.length===0&&!Co?im():a&&r.length===0?t.jsxs("div",{className:"w-full min-w-0 max-w-full flex flex-col rounded-lg overflow-hidden",style:{background:"var(--bg-card)",boxShadow:ya},children:[Na(),Sa(),Ca(),t.jsx("div",{ref:Rt,className:_o,children:t.jsx(zo.OverlayScrollbarsComponent,{options:{scrollbars:{autoHide:"leave",autoHideDelay:200}},className:"w-full",style:{maxHeight:oi,maxWidth:"100%"},defer:!0,children:t.jsxs("div",{role:"table",className:"text-sm",style:{width:gn,minWidth:xa},children:[t.jsx("div",{role:"rowgroup",style:y?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:wa()}),t.jsx("div",{role:"rowgroup",children:Array.from({length:s}).map((p,M)=>t.jsxs("div",{role:"row",className:"grid",style:{gridTemplateColumns:jr,borderBottom:`1px solid ${Oe}`},children:[Tt&&t.jsx("div",{role:"cell",className:`${J?"px-2 py-1.5":"px-3 py-2"} w-10`,style:{borderBottom:`1px solid ${Oe}`,borderRight:`1px solid ${Oe}`}},"select-cell"),wt.map((R,P)=>{const ne=ga[R.key],me=ne!==void 0,ke=R.key===Ho;return t.jsx("div",{role:"cell","data-dt-column-key":R.key,className:J?"px-2 py-1.5":"px-3 py-2",style:me?{position:"sticky",left:ne,zIndex:1,background:"color-mix(in srgb, var(--bg-card) 72%, transparent)",backdropFilter:"blur(10px)",WebkitBackdropFilter:"blur(10px)",boxShadow:ke?`3px 0 6px -2px rgba(0,0,0,0.10), inset 0 -1px 0 ${Oe}`:`inset 0 -1px 0 ${Oe}`,borderRight:`1px solid ${Oe}`}:{borderBottom:`1px solid ${Oe}`,borderRight:`1px solid ${Oe}`},children:t.jsx("div",{className:"h-3.5 rounded-full animate-pulse",style:{background:"var(--border)",width:`${ni(M,P)}%`,minWidth:32}})},R.key)})]},M))})]})})}),Ti()]}):!a&&r.length===0?t.jsxs("div",{className:"w-full min-w-0 max-w-full flex flex-col rounded-lg overflow-hidden",style:{background:"var(--bg-card)",boxShadow:ya},children:[Na(),Sa(),Ca(),t.jsx("div",{ref:Rt,className:_o,children:t.jsx("div",{role:"table",className:"text-sm",style:{width:gn,minWidth:xa},children:t.jsx("div",{role:"rowgroup",style:y?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:wa()})})}),t.jsxs("div",{className:"flex min-h-[180px] flex-col items-center justify-center gap-3 border-t px-6 py-12 text-center",style:{borderColor:Oe,background:"linear-gradient(180deg, color-mix(in srgb, var(--bg-input) 58%, transparent), var(--bg-card))"},children:[t.jsx("div",{className:"flex h-12 w-12 items-center justify-center rounded-full border",style:{borderColor:"color-mix(in srgb, var(--primary) 24%, var(--border))",background:"color-mix(in srgb, var(--primary) 8%, var(--bg-card))",color:"var(--primary)"},children:l??t.jsx(q.HiMagnifyingGlass,{className:"h-5 w-5"})}),t.jsx("p",{className:"max-w-sm text-sm font-medium",style:{color:"var(--text-main)"},children:i}),t.jsx("span",{className:"text-xs",style:{color:"var(--text-muted)"},children:"Ajusta la busqueda o cambia los filtros para ver mas informacion."})]})]}):t.jsxs("div",{className:"w-full min-w-0 max-w-full flex flex-col rounded-lg overflow-hidden",style:{background:"var(--bg-card)",boxShadow:ya},children:[Na(),Sa(),Ca(),t.jsx("div",{ref:Rt,className:_o,children:t.jsx(zo.OverlayScrollbarsComponent,{options:{scrollbars:{autoHide:"leave",autoHideDelay:200}},className:"w-full",style:{maxHeight:oi,maxWidth:"100%"},defer:!0,children:t.jsxs("div",{role:"table",className:"text-sm",style:{width:gn,minWidth:xa},children:[t.jsx("div",{role:"rowgroup",style:y?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:wa()}),t.jsx("div",{role:"rowgroup",children:yi.map((p,M)=>{const R=n(p),P=Si(x==null?void 0:x(p)),ne=M>0?Si(x==null?void 0:x(yi[M-1])):null,me=P&&P.key!==(ne==null?void 0:ne.key),ke=Tt&&k.has(R),Ce=Tt&&(!$||$(p)),Pe=Wr?(m==null?void 0:m(p))??!0:!1,qe=Pe&&gi.has(R),mt=!!d||v&&Pe,et=ke&&N?"color-mix(in srgb, var(--primary) 8%, var(--bg-card))":M%2===1?"color-mix(in srgb, var(--bg-input) 30%, var(--bg-card))":"var(--bg-card)";return t.jsxs(o.Fragment,{children:[me&&t.jsx("div",{role:"row",className:`grid ${P.className??""}`,style:{gridTemplateColumns:jr},children:t.jsx("div",{role:"cell",className:J?"px-2 py-2":"px-3 py-3",style:{gridColumn:"1 / -1",background:"color-mix(in srgb, var(--primary) 8%, var(--bg-input))",borderBottom:`1px solid ${Oe}`,borderRight:`1px solid ${Oe}`},children:t.jsx("div",{className:"flex min-w-0 items-center justify-between gap-3",children:t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"truncate text-xs font-semibold uppercase tracking-wider text-[var(--text-main)]",children:P.label}),P.description&&t.jsx("div",{className:"mt-0.5 truncate text-xs text-[var(--text-muted)]",children:P.description})]})})})}),t.jsxs("div",{role:"row",onClick:mt?ve=>{const Ee=ve.target;if(!(Ee!=null&&Ee.closest('[data-dt-disable-row-click="true"]'))){if(v&&Pe){xi(R);return}d==null||d(p)}}:void 0,className:`grid transition-colors ${mt?"cursor-pointer":""} ${T?T(p):""}`,style:{gridTemplateColumns:jr,"--dt-row-bg":et,"--dt-sticky-bg":et,background:"var(--dt-row-bg)",borderBottom:`1px solid ${Oe}`},onMouseEnter:ve=>{ke||(ve.currentTarget.style.setProperty("--dt-row-bg","var(--bg-hover)"),ve.currentTarget.style.setProperty("--dt-sticky-bg",om))},onMouseLeave:ve=>{ve.currentTarget.style.setProperty("--dt-row-bg",et),ve.currentTarget.style.setProperty("--dt-sticky-bg",et)},children:[Wr&&t.jsx("div",{role:"cell",className:`${J?"px-2 py-1.5":"px-3 py-2"} flex w-10 items-center justify-center`,style:{borderBottom:`1px solid ${Oe}`,borderRight:`1px solid ${Oe}`},"data-dt-disable-row-click":"true",children:Pe&&t.jsx("button",{type:"button","aria-label":qe?"Contraer fila":"Desplegar fila","aria-expanded":qe,onClick:ve=>{ve.stopPropagation(),xi(R)},className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-[var(--text-muted)] transition-colors hover:bg-[var(--bg-input)] hover:text-[var(--primary)]",children:qe?t.jsx(q.HiChevronDown,{className:"h-4 w-4"}):t.jsx(q.HiChevronRight,{className:"h-4 w-4"})})}),Tt&&t.jsx("div",{role:"cell",className:`${J?"px-2 py-1.5":"px-3 py-2"} flex w-10 items-center justify-center`,style:Io?{position:"sticky",left:0,zIndex:3,background:"var(--dt-sticky-bg)",boxShadow:`inset 0 -1px 0 ${Oe}`}:{borderBottom:`1px solid ${Oe}`,borderRight:`1px solid ${Oe}`},onClick:ve=>{ve.stopPropagation(),Ce&&h(R)},children:t.jsx(Nn,{size:"sm",checked:ke,disabled:!Ce,"aria-label":Ce?"Seleccionar fila":"Fila no seleccionable",containerClassName:"items-center",className:Ce?"cursor-pointer":"cursor-not-allowed opacity-50",onClick:ve=>ve.stopPropagation(),onChange:()=>{Ce&&h(R)}})}),wt.map(ve=>{const Ee=ga[ve.key],Ne=Ee!==void 0,xe=ve.key===Ho,we=or(ve);return t.jsx("div",{role:"cell","data-dt-column-key":ve.key,"data-dt-disable-row-click":ve.disableRowClick||we?"true":void 0,className:`${we?"px-2 py-1.5 justify-center text-center":`${J?"px-2 py-1.5":"px-3 py-2"} ${wi(ve.align)}`} flex min-w-0 items-center ${$c} ${ve.className??""}`,style:{overflow:"hidden",whiteSpace:"nowrap",...Ne?{position:"sticky",left:Ee,zIndex:3,background:"var(--dt-sticky-bg)",boxShadow:xe?`3px 0 6px -2px rgba(0,0,0,0.10), inset 0 -1px 0 ${Oe}`:`inset 0 -1px 0 ${Oe}`,borderRight:`1px solid ${Oe}`}:{borderBottom:`1px solid ${Oe}`,borderRight:`1px solid ${Oe}`}},children:t.jsx(ls,{children:t.jsx("div",{"data-dt-autofit-content":!0,className:"inline-block max-w-none align-middle",children:ve.cell(p)})})},ve.key)})]}),qe&&u&&t.jsx("div",{role:"row",className:"grid",style:{gridTemplateColumns:jr},children:t.jsx("div",{role:"cell",className:J?"px-2 py-2":"px-3 py-3",style:{gridColumn:"1 / -1",background:"color-mix(in srgb, var(--bg-input) 60%, var(--bg-card))",borderBottom:`1px solid ${Oe}`},children:u(p)})})]},R)})})]})})}),Ti()]})}const Pc={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 _c(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=Pc[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 zc=new Set(["Backspace","Delete","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Tab","Home","End","Enter","Escape"]);function Wc({initialValue:e,type:r,mask:n,onCommit:a,onCancel:s}){const[l,i]=o.useState(e),c=o.useRef(null),d=(n==null?void 0:n.preset)==="date",u=d?"date":r==="number"?"number":"text";return o.useEffect(()=>{var m,b;(m=c.current)==null||m.focus(),d||(b=c.current)==null||b.select()},[d]),t.jsx("input",{ref:c,type:u,value:l,maxLength:n==null?void 0:n.maxLength,onChange:m=>i(m.target.value),onBlur:()=>s(),onKeyDown:m=>{m.key==="Enter"&&(m.preventDefault(),a(l)),m.key==="Escape"&&(m.preventDefault(),s()),(n==null?void 0:n.preset)==="integer"&&!m.ctrlKey&&!m.metaKey&&!zc.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 jc({initialValue:e,options:r,loading:n,onCommit:a,onCancel:s}){const l=o.useRef(null);return o.useEffect(()=>{if(n)return;const i=setTimeout(()=>{var c,d;(d=(c=l.current)==null?void 0:c.querySelector("button"))==null||d.click()},0);return()=>clearTimeout(i)},[n]),t.jsx("div",{ref:l,className:"w-full",tabIndex:-1,onKeyDown:i=>{i.key==="Escape"&&(i.stopPropagation(),s())},children:t.jsx(ar,{value:e,onChange:i=>{a(i)},options:r,disabled:n,placeholder:n?"Cargando…":"Seleccionar…",triggerVariant:"ghost",height:30,padding:"0 6px",minOptionsForSearch:1,className:"w-full"})})}const qc={outline:"2px solid var(--primary)",outlineOffset:"-2px",borderRadius:"4px",background:"color-mix(in srgb, var(--primary) 5%, var(--bg-card))"},Pa={outline:"2px solid var(--primary)",outlineOffset:"-2px",borderRadius:"4px"};function Uc({columns:e,data:r,getRowId:n,onCellUpdate:a,readOnly:s=!1,...l}){const[i,c]=o.useState(r),d=o.useRef(null);o.useEffect(()=>{d.current||c(r)},[r]);const[u,m]=o.useState(null);d.current=u;const[b,f]=o.useState(null),g=o.useRef(null);g.current=b;const[v,k]=o.useState({}),[h,A]=o.useState(null),$=o.useRef(null);$.current=h;const[N,T]=o.useState({}),[x,y]=o.useState({}),L=o.useRef(new Set),w=o.useRef(null);o.useEffect(()=>{var _;const C=document.activeElement;(!C||C===document.body)&&((_=w.current)==null||_.focus({preventScroll:!0}))},[]);const W=e.map(C=>{var _,ae,B;return`${C.key}:${((B=(ae=(_=C.editable)==null?void 0:_.select)==null?void 0:ae.options)==null?void 0:B.length)??-1}`}).join("|");o.useEffect(()=>{e.forEach(C=>{var B,I;const _=(I=(B=C.editable)==null?void 0:B.select)==null?void 0:I.options;if(!_)return;const ae=N[C.key];(!L.current.has(C.key)||(ae==null?void 0:ae.length)===0&&_.length>0)&&(L.current.add(C.key),T(E=>({...E,[C.key]:_})))})},[W]);const X=o.useCallback(async(C,_)=>{if(L.current.has(C))return;L.current.add(C);const{url:ae,fetchOptions:B}=_.select??{};if(!(!ae&&!B)){y(I=>({...I,[C]:!0}));try{let I=[];if(B)I=await B();else if(ae){const E=await fetch(ae);if(!E.ok)throw new Error("fetch failed");I=await E.json()}T(E=>({...E,[C]:I}))}catch{T(I=>({...I,[C]:[]}))}finally{y(I=>({...I,[C]:!1}))}}},[]),Z=o.useRef(i);Z.current=i;const D=o.useRef(a);D.current=a;const Q=o.useRef(n);Q.current=n;const j=o.useRef(e);j.current=e;const se=o.useRef(s);se.current=s,o.useEffect(()=>{if(e.length>0&&r.length>0){const C=e.find(_=>_.selectable!==!1);C&&f({rowId:n(r[0]),colKey:C.key})}},[]),o.useEffect(()=>{if(!b)return;const C=w.current;if(!C)return;const _=C.querySelector(`[data-cell-id="${b.rowId}:${b.colKey}"]`);if(!_)return;const ae=C.querySelector('[role="rowgroup"]');_.style.scrollMarginTop=`${(ae==null?void 0:ae.offsetHeight)??0}px`;const B=C.querySelector('[role="row"]');let I=0;B&&B.querySelectorAll('[role="cell"], [role="columnheader"]').forEach(E=>{E.style.position==="sticky"&&E.style.left!==""&&(I=Math.max(I,parseFloat(E.style.left)+E.offsetWidth))}),_.style.scrollMarginLeft=`${I}px`,_.scrollIntoView({block:"nearest",inline:"nearest"})},[b]);const te=o.useCallback(C=>{var I;const _=j.current,ae=new Set,B=[];(I=w.current)==null||I.querySelectorAll("[data-cell-id]").forEach(E=>{const oe=E.dataset.cellId.split(":")[0];ae.has(oe)||(ae.add(oe),B.push(oe))}),f(E=>{if(!E)return E;const oe=_.findIndex(H=>H.key===E.colKey),K=B.indexOf(E.rowId);let Y=oe,S=K;if(C==="up")S=Math.max(0,K-1);else if(C==="down")S=Math.min(B.length-1,K+1);else if(C==="left"){let H=oe-1;for(;H>=0&&_[H].selectable===!1;)H--;H>=0&&(Y=H)}else if(C==="right"){let H=oe+1;for(;H<_.length&&_[H].selectable===!1;)H++;H<_.length&&(Y=H)}return Y===oe&&S===K?E:{rowId:B[S],colKey:_[Y].key}})},[]),ee=o.useCallback((C=!0)=>{const _=d.current;m(null),_&&f(_),C&&setTimeout(()=>{var ae;return(ae=w.current)==null?void 0:ae.focus({preventScroll:!0})},0)},[]),U=o.useCallback(async(C,_,ae)=>{var ie;const B=j.current.find(ge=>ge.key===_);if(!(B!=null&&B.editable))return;const{field:I,type:E,mask:oe,validate:K}=B.editable,Y=E==="number"?ae===""?null:Number(ae):ae;if(oe){const ge=_c(ae,oe);if(ge){k(Me=>({...Me,[`${C}:${_}`]:ge}));return}}if(K){const ge=K(Y);if(ge){k(Me=>({...Me,[`${C}:${_}`]:ge}));return}}const S=Q.current,H=Z.current.find(ge=>S(ge)===C);if(!H)return;const O=H[I];m(null),k(ge=>{const Me={...ge};return delete Me[`${C}:${_}`],Me});const re=Z.current,z=re.findIndex(ge=>S(ge)===C),de=re[Math.min(re.length-1,z+1)];if(f({rowId:S(de),colKey:_}),setTimeout(()=>{var Me,$e;const ge=document.activeElement;(!ge||ge===document.body||(Me=w.current)!=null&&Me.contains(ge))&&(($e=w.current)==null||$e.focus({preventScroll:!0}))},0),String(O??"")===String(Y??""))return;const he={...H,[I]:Y};c(ge=>ge.map(Me=>S(Me)===C?he:Me)),A({rowId:C,colKey:_});try{await((ie=D.current)==null?void 0:ie.call(D,{row:H,rowId:C,field:I,oldValue:O,newValue:Y}))}catch{c(ge=>ge.map(Me=>S(Me)===C?H:Me)),k(ge=>({...ge,[`${C}:${_}`]:"Error al guardar. Intenta de nuevo."}))}finally{A(null)}},[]),J=o.useCallback(C=>{if($.current){C.preventDefault();return}if(d.current)return;const _=g.current;if(!(!_||!["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Enter","Escape","Tab"].includes(C.key)))switch(C.preventDefault(),C.key){case"ArrowUp":te("up");break;case"ArrowDown":te("down");break;case"ArrowLeft":te("left");break;case"ArrowRight":te("right");break;case"Tab":te(C.shiftKey?"left":"right");break;case"Enter":{const B=j.current.find(I=>I.key===_.colKey);B!=null&&B.editable&&!se.current?(m(_),B.editable.type==="select"&&!L.current.has(_.colKey)&&X(_.colKey,B.editable)):te("down");break}}},[te,X]),ce=o.useMemo(()=>e.map(C=>{if(!C.editable||s){const ae={...C};if(delete ae.editable,delete ae.selectable,C.selectable===!1)return{...ae,disableRowClick:!0};const B=ae.cell;return{...ae,className:`relative ${ae.className??""}`.trim(),disableRowClick:!0,cell:I=>{const E=n(I),oe=(b==null?void 0:b.rowId)===E&&(b==null?void 0:b.colKey)===C.key;return t.jsxs(t.Fragment,{children:[t.jsx("span",{"data-cell-id":`${E}:${C.key}`,className:"absolute inset-0 z-10 cursor-default",onClick:()=>{var K;$.current||(f({rowId:E,colKey:C.key}),(K=w.current)==null||K.focus({preventScroll:!0}))}}),oe&&t.jsx("div",{className:"pointer-events-none absolute inset-0 z-20",style:Pa}),t.jsx("span",{className:"relative z-0 pointer-events-none",children:B(I)})]})}}}const _=C.editable;return{...C,className:`relative ${C.className??""}`.trim(),disableRowClick:!0,cell:ae=>{const B=n(ae),I=C.key,E=(u==null?void 0:u.rowId)===B&&(u==null?void 0:u.colKey)===I,oe=(b==null?void 0:b.rowId)===B&&(b==null?void 0:b.colKey)===I,K=v[`${B}:${I}`],Y=(h==null?void 0:h.rowId)===B&&(h==null?void 0:h.colKey)===I,S=ae[_.field],H=String(S??""),O=()=>{var z;$.current||(f({rowId:B,colKey:I}),m({rowId:B,colKey:I}),(z=w.current)==null||z.focus({preventScroll:!0}),_.type==="select"&&!L.current.has(I)&&X(I,_))};if(E){const z=_.type==="select"?t.jsx(jc,{initialValue:H,options:N[I]??[],loading:x[I]??!1,onCommit:de=>U(B,I,de),onCancel:ee}):t.jsx(Wc,{initialValue:H,type:_.type??"text",mask:_.mask,onCommit:de=>U(B,I,de),onCancel:ee});return t.jsx("div",{className:"absolute inset-0 flex items-center px-2",style:qc,onClick:de=>de.stopPropagation(),children:z})}const re=C.cell(ae);return t.jsxs(t.Fragment,{children:[t.jsx("span",{"data-cell-id":`${B}:${I}`,className:`peer absolute inset-0 z-10 ${Y?"cursor-wait":"cursor-pointer"}`,onClick:O}),oe&&!Y&&t.jsx("div",{className:"pointer-events-none absolute inset-0 z-20",style:Pa}),Y&&t.jsxs("div",{className:"pointer-events-none absolute inset-0 z-20 flex items-center gap-1.5 bg-[var(--bg-card)]/80 px-2",style:Pa,children:[t.jsx("span",{className:"h-3 w-3 shrink-0 animate-spin rounded-full border-2 border-[var(--text-muted)] border-t-transparent","aria-hidden":!0}),t.jsx("span",{className:"truncate text-xs text-[var(--text-muted)]",children:"Guardando…"})]}),t.jsx("span",{className:"relative z-0 inline-flex items-center gap-1 pointer-events-none",children:K?t.jsxs("span",{className:"flex items-center gap-1 text-red-500",children:[t.jsx(q.HiExclamationCircle,{className:"h-3.5 w-3.5 shrink-0"}),t.jsx("span",{className:"truncate text-xs",children:K})]}):t.jsx("span",{className:"truncate",children:re})}),!Y&&t.jsx(q.HiPencil,{className:"pointer-events-none absolute right-1 top-1/2 z-0 h-3 w-3 -translate-y-1/2 shrink-0 text-[var(--text-muted)] opacity-0 transition-opacity peer-hover:opacity-40"})]})}}}),[e,s,u,b,h,v,N,x,n,U,ee,X]);return t.jsx("div",{ref:w,tabIndex:0,onKeyDown:J,onBlur:C=>{var _;(_=w.current)!=null&&_.contains(C.relatedTarget)||setTimeout(()=>{var B,I;const ae=document.activeElement;ae&&((B=ae.closest)!=null&&B.call(ae,"[data-bonsaif-select-dropdown]"))||(I=w.current)!=null&&I.contains(ae)||ee(!1)},0)},style:{width:"100%",minWidth:0,outline:"none"},children:t.jsx(is,{...l,columns:ce,data:i,getRowId:n})})}function nt(e){if(e)return new Date(`${e}T12:00:00`)}function kt(e){const r=e.getFullYear(),n=String(e.getMonth()+1).padStart(2,"0"),a=String(e.getDate()).padStart(2,"0");return`${r}-${n}-${a}`}function yr(e){return e.charAt(0).toUpperCase()+e.slice(1)}function cs(e){return e.map(r=>nt(r)).filter(r=>!!r)}function Vc(e){if(!(e!=null&&e.length))return[];const r=new Set(e.map(kt));return Array.from(r).sort()}function _a(e){return new Intl.DateTimeFormat("es-MX",{weekday:"short"}).format(e)}function ds(e){const r=nt(e);if(!r)return e;const n=_a(r).replace(/\.$/u,"").replace(/^\w/u,s=>s.toUpperCase()),a=new Intl.DateTimeFormat("es-MX",{month:"short"}).format(r).replace(/\.$/u,"").toLowerCase();return`${n} - ${r.getDate()} ${a} ${r.getFullYear()}`}const za={weekend:{dayOfWeek:[0,6]}},Wa={weekend:"bonsaif-weekend"};function ja({children:e,className:r="",...n}){const a=String(e??"").toLowerCase().normalize("NFD").replace(new RegExp("\\p{M}","gu"),"").trim(),s=a.startsWith("sab")||a.startsWith("dom")||a==="s"||a==="d";return t.jsx("th",{...n,className:`${r} ${s?"bonsaif-weekday-weekend":""}`.trim(),children:e})}const Yc={background:"var(--primary)",color:"var(--primary-fg, #ffffff)",borderRadius:999},Xc={background:"color-mix(in srgb, var(--primary) 22%, transparent)",color:"var(--text-main)",borderRadius:999};function Kc({day:e,modifiers:r,...n}){const a=r.range_start||r.range_end||r.selected&&!r.range_middle,s=!!r.range_middle,l=!!r.weekend||e.date.getDay()===0||e.date.getDay()===6;return t.jsx("button",{...n,type:"button",className:`bonsaif-multi-day-btn${a?" is-range-edge":""}${s?" is-range-middle":""}${l?" bonsaif-day-weekend":""} ${n.className??""}`,style:{...a?Yc:null,...s?Xc:null,...l?{fontWeight:800}:null,...n.style}})}function Gc({startDate:e,endDate:r,onChange:n,minDate:a,viewMonth:s,numberOfMonths:l=1,orientation:i="horizontal",showSummary:c=!0,startLabel:d="Inicio",endLabel:u="Regreso",className:m=""}){const b={from:nt(e),to:nt(r)},f=nt(a),[g,v]=o.useState(()=>nt(s||e)??new Date);o.useEffect(()=>{const N=nt(s||e);N&&v(N)},[s,e]);const k=o.useMemo(()=>{if(l<=1)return yr(new Intl.DateTimeFormat("es-MX",{month:"long",year:"numeric"}).format(g));const N=new Date(g.getFullYear(),g.getMonth()+l-1,1),T=g.getFullYear()===N.getFullYear(),x=new Intl.DateTimeFormat("es-MX",{month:"short",...T?{}:{year:"numeric"}}).format(g),y=new Intl.DateTimeFormat("es-MX",{month:"short",year:"numeric"}).format(N);return`${yr(x)} – ${yr(y)}`},[g,l]);function h(){v(new Date(g.getFullYear(),g.getMonth()-1,1))}function A(){v(new Date(g.getFullYear(),g.getMonth()+1,1))}const $=l>1?`bonsaif-range-months bonsaif-range-months--multi bonsaif-range-months--${i}`:"bonsaif-range-months";return t.jsxs("div",{className:`bonsaif-calendar bonsaif-date-range-picker ${m}`.trim(),children:[t.jsxs("div",{className:"bonsaif-cal-shell",children:[t.jsxs("div",{className:"bonsaif-cal-toolbar",children:[t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn","aria-label":"Mes anterior",onClick:h,children:t.jsx(q.HiChevronLeft,{size:16})}),t.jsx("span",{className:"bonsaif-cal-title",children:k}),t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn","aria-label":"Mes siguiente",onClick:A,children:t.jsx(q.HiChevronRight,{size:16})})]}),t.jsx(Ta.DayPicker,{mode:"range",selected:b,month:g,onMonthChange:v,onSelect:N=>{const T=N!=null&&N.from?kt(N.from):e,x=N!=null&&N.to?kt(N.to):"";n({startDate:T,endDate:x})},numberOfMonths:l,hideNavigation:!0,weekStartsOn:1,disabled:f?{before:f}:void 0,showOutsideDays:!1,modifiers:za,modifiersClassNames:Wa,components:{DayButton:Kc,Weekday:ja},classNames:{root:"bonsaif-range-daypicker w-full",months:$,month:l>1?"bonsaif-multi-month bonsaif-range-month-card":"bonsaif-multi-month",month_caption:l>1?"bonsaif-range-month-caption":"bonsaif-multi-caption-hidden",month_grid:"bonsaif-multi-month-grid",weekdays:"bonsaif-multi-weekdays",weekday:"bonsaif-multi-weekday",week:"bonsaif-multi-week",day:"bonsaif-multi-day",day_button:"bonsaif-multi-day-btn",selected:"bonsaif-range-day-selected",range_start:"bonsaif-range-start",range_middle:"bonsaif-range-middle",range_end:"bonsaif-range-end",today:"bonsaif-multi-day-today",disabled:"bonsaif-multi-day-disabled",hidden:"bonsaif-multi-day-hidden"},formatters:{formatCaption:N=>`${yr(new Intl.DateTimeFormat("es-MX",{month:"long"}).format(N))} ${N.getFullYear()}`,formatWeekdayName:_a}})]}),c?t.jsx("div",{className:"bonsaif-cal-summary",children:e?t.jsxs("div",{className:"bonsaif-cal-chips",children:[t.jsxs("span",{className:"bonsaif-cal-chip bonsaif-cal-chip--static",children:[d,": ",e]}),r?t.jsxs("span",{className:"bonsaif-cal-chip bonsaif-cal-chip--static",children:[u,": ",r]}):null]}):t.jsx("span",{children:"Sin rango seleccionado"})}):null]})}function us({day:e,modifiers:r,onDayPointerDown:n,onDayPointerEnter:a,onDayClickSelect:s,...l}){const i=!!(r.disabled||r.hidden),c=!!r.weekend||e.date.getDay()===0||e.date.getDay()===6;return t.jsx("button",{...l,type:"button",disabled:i||l.disabled,className:`${l.className??""}${c?" bonsaif-day-weekend":""}`,style:{...c?{fontWeight:800}:null,...l.style},onPointerDown:d=>{var u;i||(n==null||n(e.date,d),(u=l.onPointerDown)==null||u.call(l,d))},onPointerEnter:()=>{i||a==null||a(e.date)},onClick:d=>{i||(d.preventDefault(),d.stopPropagation(),s==null||s(e.date,d))}})}function fs(e,r){const n=nt(e),a=nt(r);if(!n||!a)return[];const s=n<=a?n:a,l=n<=a?a:n,i=[],c=new Date(s);for(;c<=l;)i.push(kt(c)),c.setDate(c.getDate()+1);return i}function bs(e,r=1){const n=e.getDay(),a=r===1?(n+6)%7:n,s=new Date(e);return s.setHours(12,0,0,0),s.setDate(s.getDate()-a),Array.from({length:7},(l,i)=>{const c=new Date(s);return c.setDate(s.getDate()+i),c})}function Rr(e,r,n){const a=new Set(e);for(const s of r)n==="add"?a.add(s):n==="remove"||a.has(s)?a.delete(s):a.add(s);return Array.from(a).sort()}function Zc(e,r){return typeof r!="number"||r<=0||e.length<=r?e:e.slice(-r)}function Qc(e,r,n){return!!(r&&e<r||n&&e>n)}function ms({value:e,onChange:r,disabled:n=!1,minDate:a,maxDate:s,maxDates:l,isDateDisabled:i,retainOutsidePrefix:c}){const d=o.useRef(null),u=o.useRef(null),m=o.useRef(!1),b=o.useRef(e);b.current=e;const f=o.useCallback(x=>{let y=x;if(c){const L=b.current.filter(W=>!W.startsWith(c)),w=x.filter(W=>W.startsWith(c));y=[...L,...w].sort()}r==null||r(Zc(y,l))},[l,r,c]),g=o.useCallback((x,y=!1)=>Qc(x,a,s)?!0:!(!(i!=null&&i(x))||y&&b.current.includes(x)),[i,s,a]),v=o.useCallback(x=>x.filter(y=>!g(y)),[g]),k=o.useCallback(()=>{u.current=null},[]);o.useEffect(()=>{const x=()=>k();return window.addEventListener("pointerup",x),window.addEventListener("pointercancel",x),()=>{window.removeEventListener("pointerup",x),window.removeEventListener("pointercancel",x)}},[k]);const h=o.useCallback((x,y,L,w)=>{const W=v(fs(x,y));f(L==="add"?Rr(w,W,"add"):Rr(w,W,"remove"))},[f,v]),A=o.useCallback((x,y)=>{if(n||y.button!==0)return;const L=kt(x);if(g(L,!0)||y.shiftKey)return;m.current=!0;const w=[...b.current],W=w.includes(L)?"remove":"add";W==="add"&&g(L)||(u.current={active:!0,mode:W,anchor:L,latest:L,baseline:w},d.current=L,h(L,L,W,w),y.preventDefault())},[h,n,g]),$=o.useCallback(x=>{const y=u.current;if(!(y!=null&&y.active)||n)return;const L=kt(x);y.mode==="add"&&g(L)||y.latest!==L&&(y.latest=L,h(y.anchor,L,y.mode,y.baseline))},[h,n,g]),N=o.useCallback((x,y)=>{if(n)return;const L=kt(x);if(!g(L,!0)){if(m.current&&!y.shiftKey){m.current=!1,y.preventDefault(),y.stopPropagation();return}if(m.current=!1,y.shiftKey&&d.current){y.preventDefault(),y.stopPropagation();const w=v(fs(d.current,L));f(Rr(b.current,w,"add"));return}!b.current.includes(L)&&g(L)||(d.current=L,f(Rr(b.current,[L],"toggle")))}},[f,n,v,g]),T=o.useCallback(x=>{if(n)return;const y=v(Vc(x));if(!y.length)return;const L=y.every(w=>b.current.includes(w));f(Rr(b.current,y,L?"remove":"add")),d.current=y[0]??d.current},[f,n,v]);return{onDayPointerDown:A,onDayPointerEnter:$,onDayClick:N,toggleWeek:T,endDrag:k}}function en(e){return bs(e,1)[0]}function ps(e,r){const n=new Date(e);return n.setDate(n.getDate()+r),n}function Jc({value:e=[],onChange:r,minDate:n,maxDate:a,isDateDisabled:s,viewMonth:l,maxDates:i,showWeekNumbers:c=!1,viewMode:d,defaultViewMode:u="month",onViewModeChange:m,showSummary:b=!0,className:f="",disabled:g=!1}){const v=o.useMemo(()=>cs(e),[e]),k=o.useMemo(()=>new Set(e),[e]),h=nt(n),A=nt(a),[$,N]=o.useState(()=>nt(l||e[0])??new Date),[T,x]=o.useState(()=>en(nt(l||e[0])??new Date)),[y,L]=o.useState(u),w=d??y;function W(C){d===void 0&&L(C),m==null||m(C)}o.useEffect(()=>{const C=nt(l);C&&(N(C),x(en(C)))},[l]);const{onDayPointerDown:X,onDayPointerEnter:Z,onDayClick:D,toggleWeek:Q}=ms({value:e,onChange:r,disabled:g,minDate:n,maxDate:a,maxDates:i,isDateDisabled:s}),j=o.useMemo(()=>{if(g)return!0;const C=[];return h&&C.push({before:h}),A&&C.push({after:A}),s&&C.push(_=>s(kt(_))),C.length>0?C:void 0},[g,s,A,h]),se=o.useCallback(C=>t.jsx(us,{...C,className:`bonsaif-multi-day-btn ${C.className??""}`,onDayPointerDown:X,onDayPointerEnter:Z,onDayClickSelect:D}),[D,X,Z]),te=o.useMemo(()=>bs(T,1),[T]),ee=te[6],U=w==="week"?`${new Intl.DateTimeFormat("es-MX",{day:"numeric",month:"short"}).format(te[0])} – ${new Intl.DateTimeFormat("es-MX",{day:"numeric",month:"short",year:"numeric"}).format(ee)}`:yr(new Intl.DateTimeFormat("es-MX",{month:"long",year:"numeric"}).format($));function J(){if(w==="week"){const C=ps(T,-7);x(en(C)),N(C);return}N(new Date($.getFullYear(),$.getMonth()-1,1))}function ce(){if(w==="week"){const C=ps(T,7);x(en(C)),N(C);return}N(new Date($.getFullYear(),$.getMonth()+1,1))}return t.jsxs("div",{className:`bonsaif-calendar bonsaif-multi-date-calendar ${f}`,children:[t.jsxs("div",{className:"bonsaif-cal-shell",children:[t.jsxs("div",{className:"bonsaif-cal-view-toggle",role:"tablist","aria-label":"Vista",children:[t.jsx("button",{type:"button",role:"tab","aria-selected":w==="month",className:`bonsaif-cal-view-btn${w==="month"?" is-active":""}`,disabled:g,onClick:()=>{W("month"),N(T)},children:"Mes"}),t.jsx("button",{type:"button",role:"tab","aria-selected":w==="week",className:`bonsaif-cal-view-btn${w==="week"?" is-active":""}`,disabled:g,onClick:()=>{W("week"),x(en($))},children:"Semana"})]}),t.jsxs("div",{className:"bonsaif-cal-toolbar",children:[t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn","aria-label":w==="week"?"Semana anterior":"Mes anterior",disabled:g,onClick:J,children:t.jsx(q.HiChevronLeft,{size:16})}),t.jsx("span",{className:"bonsaif-cal-title",children:U}),t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn","aria-label":w==="week"?"Semana siguiente":"Mes siguiente",disabled:g,onClick:ce,children:t.jsx(q.HiChevronRight,{size:16})})]}),t.jsxs("p",{className:"bonsaif-cal-hint",children:["Click · Shift+click rango · Arrastra",c&&w==="month"?" · Semana (nº)":"",w==="week"?" · Botón semana completa":""]}),w==="month"?t.jsx(Ta.DayPicker,{mode:"multiple",required:!1,selected:v,month:$,onMonthChange:N,onSelect:()=>{},hideNavigation:!0,showOutsideDays:!1,weekStartsOn:1,showWeekNumber:c,onWeekNumberClick:(C,_)=>{Q(_)},disabled:j,className:"bonsaif-multi-daypicker",modifiers:za,modifiersClassNames:Wa,classNames:{root:"bonsaif-multi-daypicker",months:"bonsaif-multi-months",month:"bonsaif-multi-month",month_caption:"bonsaif-multi-caption-hidden",month_grid:"bonsaif-multi-month-grid",weekdays:c?"bonsaif-multi-weekdays bonsaif-multi-weekdays--with-week":"bonsaif-multi-weekdays",weekday:"bonsaif-multi-weekday",week:c?"bonsaif-multi-week bonsaif-multi-week--with-week":"bonsaif-multi-week",week_number:"bonsaif-week-number",week_number_header:"bonsaif-week-number-header",day:"bonsaif-multi-day",day_button:"bonsaif-multi-day-btn",selected:"bonsaif-multi-day-selected",today:"bonsaif-multi-day-today",disabled:"bonsaif-multi-day-disabled",hidden:"bonsaif-multi-day-hidden"},components:{DayButton:se,Weekday:ja},formatters:{formatWeekdayName:_a}}):t.jsxs("div",{className:"bonsaif-week-view",children:[t.jsx("div",{className:"bonsaif-week-view-head",children:te.map(C=>t.jsx("div",{className:"bonsaif-multi-weekday",children:new Intl.DateTimeFormat("es-MX",{weekday:"short"}).format(C)},`h-${kt(C)}`))}),t.jsx("div",{className:"bonsaif-week-view-days",children:te.map(C=>{const _=kt(C),ae=k.has(_),B=g||(n?_<n:!1)||(a?_>a:!1)||!!(s!=null&&s(_)),I=_===kt(new Date);return t.jsx("div",{className:`bonsaif-multi-day${ae?" bonsaif-multi-day-selected":""}${I?" bonsaif-multi-day-today":""}${B?" bonsaif-multi-day-disabled":""}`,children:t.jsxs("button",{type:"button",className:"bonsaif-multi-day-btn",disabled:B,"aria-pressed":ae,onPointerDown:E=>X(C,E),onPointerEnter:()=>Z(C),onClick:E=>D(C,E),children:[t.jsx("span",{className:"bonsaif-week-day-num",children:C.getDate()}),t.jsx("span",{className:"bonsaif-week-day-month",children:new Intl.DateTimeFormat("es-MX",{month:"short"}).format(C)})]})},_)})}),t.jsx("button",{type:"button",className:"bonsaif-week-select-all",disabled:g,onClick:()=>Q(te),children:"Marcar / desmarcar semana"})]})]}),b?t.jsx("div",{className:"bonsaif-cal-summary",children:e.length===0?t.jsx("span",{children:"Sin fechas seleccionadas"}):t.jsxs(t.Fragment,{children:[t.jsxs("span",{children:[e.length," ",e.length===1?"fecha":"fechas"]}),t.jsx("div",{className:"bonsaif-cal-chips",children:e.map(C=>t.jsxs("button",{type:"button",className:"bonsaif-cal-chip",disabled:g,onClick:()=>r==null?void 0:r(e.filter(_=>_!==C)),title:`Quitar ${C}`,children:[ds(C),t.jsx("span",{"aria-hidden":!0,children:"×"})]},C))})]})}):null]})}const Rc=Array.from({length:12},(e,r)=>r);function ed({value:e=[],onChange:r,year:n,onYearChange:a,minDate:s,maxDate:l,maxDates:i,showSummary:c=!0,className:d="",disabled:u=!1,readOnly:m=!1}){const b=o.useMemo(()=>cs(e),[e]),f=nt(s),g=nt(l),v=n??(e[0]?Number(e[0].slice(0,4)):new Date().getFullYear()),[k,h]=o.useState(v);o.useEffect(()=>{typeof n=="number"&&h(n)},[n]);function A(w){h(w),a==null||a(w)}const{onDayPointerDown:$,onDayPointerEnter:N,onDayClick:T}=ms({value:e,onChange:r,disabled:u||m,minDate:s,maxDate:l,maxDates:i,retainOutsidePrefix:`${k}-`}),x=o.useCallback(w=>t.jsx(us,{...w,className:`bonsaif-year-day-btn ${w.className??""}`,onDayPointerDown:$,onDayPointerEnter:N,onDayClickSelect:T}),[T,$,N]),y=b.filter(w=>w.getFullYear()===k),L=u?!0:[...f?[{before:f}]:[],...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:()=>A(k-1),children:t.jsx(q.HiChevronLeft,{size:16})}),t.jsx("span",{className:"bonsaif-cal-title",children:k}),t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn","aria-label":"Año siguiente",disabled:u,onClick:()=>A(k+1),children:t.jsx(q.HiChevronRight,{size:16})})]}),!m&&!u?t.jsx("p",{className:"bonsaif-cal-hint",children:"Click · Shift+click rango · Arrastra para marcar varias"}):null,t.jsx("div",{className:"bonsaif-year-cal-grid",children:Rc.map(w=>{const W=new Date(k,w,1);return t.jsxs("div",{className:"bonsaif-year-cal-month",children:[t.jsx("div",{className:"bonsaif-year-cal-month-title",children:yr(new Intl.DateTimeFormat("es-MX",{month:"long"}).format(W))}),t.jsx(Ta.DayPicker,{mode:"multiple",required:!1,selected:y,month:W,onMonthChange:()=>{},onSelect:()=>{},numberOfMonths:1,hideNavigation:!0,showOutsideDays:!1,weekStartsOn:1,disabled:L,className:"bonsaif-year-month-picker",modifiers:za,modifiersClassNames:Wa,classNames:{root:"bonsaif-year-month-picker",months:"bonsaif-year-month-months",month:"bonsaif-year-month-inner",month_caption:"bonsaif-year-month-caption-hidden",month_grid:"bonsaif-year-month-grid",weekdays:"bonsaif-year-weekdays",weekday:"bonsaif-year-weekday",week:"bonsaif-year-week",day:"bonsaif-year-day",day_button:"bonsaif-year-day-btn",selected:"bonsaif-year-day-selected",today:"bonsaif-year-day-today",disabled:"bonsaif-year-day-disabled",hidden:"bonsaif-year-day-hidden"},components:{DayButton:x,Weekday:ja},formatters:{formatWeekdayName:X=>new Intl.DateTimeFormat("es-MX",{weekday:"narrow"}).format(X)}})]},`${k}-${w}`)})})]}),c?t.jsx("div",{className:"bonsaif-cal-summary",children:e.length===0?t.jsx("span",{children:"Sin fechas seleccionadas"}):t.jsxs(t.Fragment,{children:[t.jsxs("span",{children:[e.length," ",e.length===1?"fecha":"fechas"," ·"," ",k]}),t.jsx("div",{className:"bonsaif-cal-chips",children:e.map(w=>t.jsxs("button",{type:"button",className:"bonsaif-cal-chip",disabled:u||m,onClick:()=>r==null?void 0:r(e.filter(W=>W!==w)),title:`Quitar ${w}`,children:[ds(w),t.jsx("span",{"aria-hidden":!0,children:"×"})]},w))})]})}):null]})}const td="bonsaif-ui:hide-tooltips";function hs(){window.dispatchEvent(new CustomEvent(td))}function rd(e){if(e!==void 0)return typeof e=="number"?`${e}px`:e}function nd({trigger:e,items:r,align:n="end",width:a=220,disabled:s=!1,className:l="",menuClassName:i="",onOpenChange:c}){const[d,u]=o.useState(!1),[m,b]=o.useState(!1),[f,g]=o.useState({}),v=o.useRef(null),k=o.useRef(null),h=o.useCallback(x=>{u(x),c==null||c(x)},[c]),A=o.useCallback(()=>{const x=v.current;if(!x)return;const y=x.getBoundingClientRect(),L=typeof a=="number"?a:y.width,w=typeof a=="number"?a:Math.max(y.width,180),W=n==="end"?Math.max(8,y.right-w):Math.min(y.left,window.innerWidth-w-8),X=window.innerHeight-y.bottom,Z=X<240&&y.top>X?void 0:y.bottom+6,D=Z===void 0?window.innerHeight-y.top+6:void 0;g({position:"fixed",zIndex:9999,left:W,top:Z,bottom:D,width:rd(typeof a=="number"?L:a)})},[n,a]);o.useEffect(()=>b(!0),[]),o.useEffect(()=>{if(!d)return;A();const x=L=>{var W,X;const w=L.target;!((W=v.current)!=null&&W.contains(w))&&!((X=k.current)!=null&&X.contains(w))&&h(!1)},y=L=>{L.key==="Escape"&&h(!1)};return document.addEventListener("mousedown",x),window.addEventListener("keydown",y),window.addEventListener("resize",A),window.addEventListener("scroll",A,!0),()=>{document.removeEventListener("mousedown",x),window.removeEventListener("keydown",y),window.removeEventListener("resize",A),window.removeEventListener("scroll",A,!0)}},[d,h,A]);const $=x=>{s||(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),h(!d))},N=o.isValidElement(e)?o.cloneElement(e,{onClick:()=>{s||(hs(),h(!d))}}):e,T=d?t.jsx("div",{ref:k,role:"menu","data-bonsaif-overlay":"true",className:`overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-1 shadow-xl ${i}`,style:f,children:r.map(x=>t.jsxs("div",{children:[x.separatorBefore&&t.jsx("div",{className:"my-1 border-t border-[var(--border)]"}),t.jsxs("button",{type:"button",role:"menuitem",disabled:x.disabled,onClick:()=>{var y;x.disabled||(hs(),(y=x.onSelect)==null||y.call(x),h(!1))},className:"flex w-full min-w-0 items-start gap-2 rounded-md px-2.5 py-1.5 text-left transition-colors hover:bg-[var(--bg-input)] disabled:cursor-not-allowed disabled:opacity-50",style:{color:x.danger?"var(--danger)":"var(--text-main)"},children:[x.icon&&t.jsx("span",{className:"mt-0.5 shrink-0",children:x.icon}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"block truncate text-sm font-medium",children:x.label}),x.description&&t.jsx("span",{className:"block truncate text-xs text-[var(--text-muted)]",children:x.description})]})]})]},x.id))}):null;return t.jsxs("span",{ref:v,role:"button",tabIndex:s?-1:0,"aria-haspopup":"menu","aria-expanded":d,onKeyDown:$,className:`inline-flex ${s?"pointer-events-none opacity-60":""} ${l}`,children:[N,m&&T?ct.createPortal(T,document.body):null]})}const ad=180,gs="bg-[color-mix(in_srgb,var(--bg-main)_72%,transparent)] backdrop-blur-sm";function od({open:e,onClose:r,title:n,subtitle:a,leadingIcon:s,confirmLabel:l="Guardar",onConfirm:i,loading:c=!1,confirmDisabled:d=!1,headerActions:u,bodyClassName:m="flex-1 overflow-y-auto px-6 py-5",width:b=440,hasUnsavedChanges:f=!1,unsavedChangesTitle:g="Descartar cambios",unsavedChangesDescription:v="Hay cambios sin guardar. Si cierras el drawer se perderán.",unsavedChangesConfirmLabel:k="Descartar",unsavedChangesCancelLabel:h="Seguir editando",onDiscardChanges:A,disabled:$=!1,disabledMessage:N,children:T}){const[x,y]=o.useState(!1),[L,w]=o.useState(!1),[W,X]=o.useState(!1),Z=o.useCallback(()=>{w(!0),requestAnimationFrame(()=>{requestAnimationFrame(()=>X(!0))})},[]),D=o.useCallback(()=>{X(!1),window.setTimeout(()=>w(!1),ad)},[]),Q=$||c,j=o.useCallback(()=>{if(!Q){if(f){Z();return}r()}},[Q,f,r,Z]),se=o.useCallback(()=>{X(!1),w(!1),A==null||A(),r()},[r,A]);if(o.useEffect(()=>{y(!0)},[]),o.useEffect(()=>(document.body.style.overflow=e?"hidden":"",e||(X(!1),w(!1)),()=>{document.body.style.overflow=""}),[e]),o.useEffect(()=>{if(!e)return;const ee=U=>{if(U.key==="Escape"&&!Q){if(L){D();return}j()}};return window.addEventListener("keydown",ee),()=>window.removeEventListener("keydown",ee)},[D,Q,L,e,j]),!x)return null;const te=N!==void 0?N:c?"Guardando…":null;return ct.createPortal(t.jsxs("div",{"aria-hidden":!e,"data-bonsaif-overlay":e?"true":void 0,className:`fixed inset-0 z-[1000] flex transition-opacity duration-300 ${e?"opacity-100":"opacity-0 pointer-events-none"}`,children:[t.jsx("div",{className:`absolute inset-0 ${gs}`,onClick:j}),t.jsxs("div",{className:`absolute inset-y-0 right-0 flex flex-col shadow-2xl transition-transform duration-300 ${e?"translate-x-0":"translate-x-full"}`,style:{width:`min(100vw, ${b}px)`,background:"var(--bg-card)",borderLeft:"1px solid var(--border)"},children:[t.jsxs("div",{className:"flex items-center justify-between px-6 py-4 flex-shrink-0",style:{borderBottom:"1px solid var(--border)"},children:[t.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[t.jsx(Ue,{variant:"icon",onClick:j,title:"Cerrar",disabled:Q,children:t.jsx(q.HiXMark,{className:"w-5 h-5"})}),s&&t.jsx("div",{className:"flex-shrink-0",children:s}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("h3",{className:"text-base font-semibold truncate",style:{color:"var(--text-main)"},children:n}),a&&t.jsx("p",{className:"text-xs truncate",style:{color:"var(--text-muted)"},children:a})]})]}),(u||i)&&t.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[u,i&&t.jsxs(t.Fragment,{children:[t.jsx(Ue,{variant:"secondary",size:"sm",onClick:j,disabled:Q,style:{background:"var(--bg-input)"},children:"Cancelar"}),t.jsx(Ue,{variant:"primary",size:"sm",icon:t.jsx(Li.FiSave,{className:"w-4 h-4"}),onClick:i,loading:c,disabled:d||Q,title:l})]})]})]}),t.jsx("div",{"data-drawer-scroll":"true",className:m,children:T}),Q&&t.jsx("div",{className:"absolute inset-0 z-[1002] flex cursor-not-allowed items-center justify-center p-6",style:{background:"color-mix(in srgb, var(--bg-card, #ffffff) 72%, transparent)",backdropFilter:"blur(3px)"},role:"status","aria-live":"polite","aria-busy":"true",children:te?t.jsxs("div",{className:"flex max-w-xs flex-col items-center gap-3 text-center",children:[t.jsx("div",{className:"h-9 w-9 animate-spin rounded-full border-2 border-[var(--border)] border-t-[var(--primary)]","aria-hidden":!0}),t.jsx("p",{className:"text-sm font-semibold text-[var(--text-main)]",children:te})]}):null})]}),L&&t.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":g,className:"fixed inset-0 z-[1001] flex items-center justify-center p-4",children:[t.jsx("div",{className:`absolute inset-0 ${gs} transition-opacity duration-200 ease-out ${W?"opacity-100":"opacity-0"}`,onClick:D}),t.jsxs("div",{className:`relative z-10 w-full max-w-sm rounded-2xl border p-6 shadow-2xl transition-[opacity,transform] duration-200 ease-out ${W?"translate-y-0 scale-100 opacity-100":"translate-y-2 scale-[0.96] opacity-0"}`,style:{background:"var(--bg-card, #ffffff)",borderColor:"var(--border, #d8e1dc)"},children:[t.jsx(Ue,{variant:"icon",onClick:D,className:"absolute right-3 top-3 h-7 w-7 hover:opacity-70",style:{color:"var(--text-muted, #6b7f78)"},"aria-label":h,children:t.jsx(q.HiXMark,{className:"h-4 w-4"})}),t.jsx("div",{className:"mb-4 flex h-11 w-11 items-center justify-center rounded-xl",style:{background:"var(--warning-bg, #fff7ed)"},children:t.jsx(q.HiExclamationTriangle,{className:"h-5 w-5",style:{color:"var(--warning, #d97706)"}})}),t.jsx("h2",{className:"mb-1 text-base font-semibold",style:{color:"var(--text-main, #0f2f2c)"},children:g}),t.jsx("p",{className:"text-sm",style:{color:"var(--text-muted, #6b7f78)"},children:v}),t.jsxs("div",{className:"mt-6 flex gap-2",children:[t.jsx(Ue,{variant:"secondary",onClick:D,className:"flex-1 border",style:{background:"var(--bg-input, #f7faf8)",borderColor:"var(--border, #d8e1dc)",color:"var(--text-main, #0f2f2c)"},children:h}),t.jsx(Ue,{variant:"secondary",onClick:se,className:"flex-1 border",style:{background:"var(--warning, #d97706)",borderColor:"transparent",color:"#fff",boxShadow:"0 10px 22px rgba(217, 119, 6, 0.22)"},children:k})]})]})]})]}),document.body)}const sd=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,ld=/^\+?[0-9\s().-]+$/,id=7,cd=15;function $t(e){return e==null||String(e).trim()===""}function vs(e){return typeof e=="number"?e:typeof e=="string"&&e.trim()!==""?Number(e):Number.NaN}function qa(e){return $t(e)?!1:sd.test(String(e))}function Ua(e){if($t(e))return!1;const r=String(e),n=r.replace(/\D/g,"");return ld.test(r)&&n.length>=id&&n.length<=cd}function dd(e="Este campo es requerido."){return r=>$t(r)?e:void 0}function ud(e="Ingresa un correo valido."){return r=>$t(r)||qa(r)?void 0:e}function fd(e="Ingresa un telefono valido."){return r=>$t(r)||Ua(r)?void 0:e}function bd(e,r){return n=>$t(n)||String(n).length>=e?void 0:r??`Debe tener al menos ${e} caracteres.`}function md(e,r){return n=>$t(n)||String(n).length<=e?void 0:r??`Debe tener ${e} caracteres o menos.`}function pd(e,r){return n=>{if($t(n))return;const a=vs(n);return Number.isFinite(a)&&a>=e?void 0:r??`Debe ser mayor o igual a ${e}.`}}function hd(e,r){return n=>{if($t(n))return;const a=vs(n);return Number.isFinite(a)&&a<=e?void 0:r??`Debe ser menor o igual a ${e}.`}}function gd(e,r="El formato no es valido."){return n=>$t(n)||e.test(String(n))?void 0:r}function vd(e,r){const n={};for(const a of Object.keys(r)){const s=r[a];if(!s)continue;const l=Array.isArray(s)?s:[s];for(const i of l){const c=i(e[a],e);if(c){n[a]=c;break}}}return{valid:Object.keys(n).length===0,errors:n}}var ys={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},xs=o.createContext&&o.createContext(ys),yd=["attr","size","title"];function xd(e,r){if(e==null)return{};var n,a,s=wd(e,r);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(a=0;a<l.length;a++)n=l[a],r.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(s[n]=e[n])}return s}function wd(e,r){if(e==null)return{};var n={};for(var a in e)if({}.hasOwnProperty.call(e,a)){if(r.indexOf(a)!==-1)continue;n[a]=e[a]}return n}function An(){return An=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var a in n)({}).hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},An.apply(null,arguments)}function ws(e,r){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);r&&(a=a.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),n.push.apply(n,a)}return n}function Ln(e){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};r%2?ws(Object(n),!0).forEach(function(a){Nd(e,a,n[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ws(Object(n)).forEach(function(a){Object.defineProperty(e,a,Object.getOwnPropertyDescriptor(n,a))})}return e}function Nd(e,r,n){return(r=kd(r))in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}function kd(e){var r=Sd(e,"string");return typeof r=="symbol"?r:r+""}function Sd(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 Ns(e){return e&&e.map((r,n)=>o.createElement(r.tag,Ln({key:n},r.attr),Ns(r.child)))}function Va(e){return r=>o.createElement(Cd,An({attr:Ln({},e.attr)},r),Ns(e.child))}function Cd(e){var r=n=>{var{attr:a,size:s,title:l}=e,i=xd(e,yd),c=s||n.size||"1em",d;return n.className&&(d=n.className),e.className&&(d=(d?d+" ":"")+e.className),o.createElement("svg",An({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},n.attr,a,i,{className:d,style:Ln(Ln({color:e.color||n.color},n.style),e.style),height:c,width:c,xmlns:"http://www.w3.org/2000/svg"}),l&&o.createElement("title",null,l),e.children)};return xs!==void 0?o.createElement(xs.Consumer,null,n=>r(n)):r(ys)}function ks(e){return Va({attr:{viewBox:"0 0 256 256",fill:"currentColor"},child:[{tag:"path",attr:{d:"M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm0,192a88,88,0,1,1,88-88A88.1,88.1,0,0,1,128,216Zm-8-80V80a8,8,0,0,1,16,0v56a8,8,0,0,1-16,0Zm20,36a12,12,0,1,1-12-12A12,12,0,0,1,140,172Z"},child:[]}]})(e)}function Ed(e){return Va({attr:{viewBox:"0 0 256 256",fill:"currentColor"},child:[{tag:"path",attr:{d:"M247.31,124.76c-.35-.79-8.82-19.58-27.65-38.41C194.57,61.26,162.88,48,128,48S61.43,61.26,36.34,86.35C17.51,105.18,9,124,8.69,124.76a8,8,0,0,0,0,6.5c.35.79,8.82,19.57,27.65,38.4C61.43,194.74,93.12,208,128,208s66.57-13.26,91.66-38.34c18.83-18.83,27.3-37.61,27.65-38.4A8,8,0,0,0,247.31,124.76ZM128,192c-30.78,0-57.67-11.19-79.93-33.25A133.47,133.47,0,0,1,25,128,133.33,133.33,0,0,1,48.07,97.25C70.33,75.19,97.22,64,128,64s57.67,11.19,79.93,33.25A133.46,133.46,0,0,1,231.05,128C223.84,141.46,192.43,192,128,192Zm0-112a48,48,0,1,0,48,48A48.05,48.05,0,0,0,128,80Zm0,80a32,32,0,1,1,32-32A32,32,0,0,1,128,160Z"},child:[]}]})(e)}function Md(e){return Va({attr:{viewBox:"0 0 256 256",fill:"currentColor"},child:[{tag:"path",attr:{d:"M228,175a8,8,0,0,1-10.92-3l-19-33.2A123.23,123.23,0,0,1,162,155.46l5.87,35.22a8,8,0,0,1-6.58,9.21A8.4,8.4,0,0,1,160,200a8,8,0,0,1-7.88-6.69l-5.77-34.58a133.06,133.06,0,0,1-36.68,0l-5.77,34.58A8,8,0,0,1,96,200a8.4,8.4,0,0,1-1.32-.11,8,8,0,0,1-6.58-9.21L94,155.46a123.23,123.23,0,0,1-36.06-16.69L39,172A8,8,0,1,1,25.06,164l20-35a153.47,153.47,0,0,1-19.3-20A8,8,0,1,1,38.22,99c16.6,20.54,45.64,45,89.78,45s73.18-24.49,89.78-45A8,8,0,1,1,230.22,109a153.47,153.47,0,0,1-19.3,20l20,35A8,8,0,0,1,228,175Z"},child:[]}]})(e)}function xr({content:e,ariaLabel:r="Más información",className:n=""}){return t.jsx(Yt,{as:"span",content:e,className:`inline-flex shrink-0 align-middle text-[var(--text-muted)] outline-none transition-colors hover:text-[var(--primary)] focus-visible:text-[var(--primary)] ${n}`,children:t.jsx("span",{tabIndex:0,role:"img","aria-label":r,className:"inline-flex items-center justify-center outline-none",children:t.jsx(q.HiInformationCircle,{className:"h-3.5 w-3.5"})})})}function wr({error:e,helperText:r,helperDisplay:n="inline"}){return e?t.jsx("span",{className:"text-xs font-medium normal-case text-[var(--danger)]",children:e}):r&&n!=="tooltip"?t.jsx("span",{className:"text-xs font-medium normal-case text-[var(--text-muted)]",children:r}):null}function Dn({className:e="",...r}){return t.jsx("input",{...r,className:`h-10 rounded-lg border border-[var(--border)] bg-[var(--bg-input)] px-2.5 py-1.5 text-sm text-[var(--text-main)] outline-none placeholder:text-[var(--text-muted)] transition-colors focus:border-[var(--primary)] ${e}`})}function Ya({label:e,containerClassName:r="",helperText:n,helperDisplay:a="inline",error:s,errorDisplay:l="inline",errorTooltipLabel:i="Error de validacion",labelAction:c,floatingLabel:d=!1,showPasswordToggle:u=!0,nativeValidation:m=!1,className:b="",required:f,...g}){const[v,k]=o.useState(()=>!!g.autoFocus),[h,A]=o.useState(!1),$=g.type==="password"&&u,N=$&&h?"text":g.type,T=!!s,x=T&&l!=="tooltip",y=T&&l!=="inline",L=!!n&&a==="tooltip"&&!x,w=m?f:void 0,W=T?"border-[var(--danger)] focus:border-[var(--danger)]":"",X=y?$?"pr-20":"pr-10":$?"pr-10":"",Z=g.value!==void 0?String(g.value).length>0:g.defaultValue!==void 0&&String(g.defaultValue).length>0,D=v||Z,Q={top:D?7:12,color:v?"var(--primary)":"var(--text-muted)",fontSize:D?10:13,fontWeight:D?600:400,textTransform:D?"uppercase":"none"},j=J=>{var ce;k(!0),(ce=g.onFocus)==null||ce.call(g,J)},se=J=>{var ce;k(!1),(ce=g.onBlur)==null||ce.call(g,J)},te=$?t.jsxs("button",{type:"button","aria-label":h?"Ocultar contraseña":"Mostrar contraseña","aria-pressed":h,className:"absolute right-2.5 top-1/2 flex h-7 w-7 -translate-y-1/2 items-center justify-center rounded-md text-[var(--text-muted)] transition-colors duration-200 hover:text-[var(--primary)] focus:outline-none",tabIndex:-1,onClick:()=>A(J=>!J),children:[t.jsx("span",{"aria-hidden":"true",className:`absolute inset-0 flex items-center justify-center transition-[opacity,transform] duration-200 ease-out ${h?"scale-y-0 rotate-[-8deg] opacity-0":"scale-y-100 rotate-0 opacity-100"}`,children:t.jsx(Ed,{className:"h-[18px] w-[18px]"})}),t.jsx("span",{"aria-hidden":"true",className:`absolute inset-0 flex items-center justify-center transition-[opacity,transform] duration-200 ease-out ${h?"scale-y-100 rotate-0 opacity-100":"scale-y-0 rotate-[8deg] opacity-0"}`,children:t.jsx(Md,{className:"h-[18px] w-[18px]"})})]}):null,ee=y?t.jsx(Yt,{as:"span",content:s,className:`absolute top-1/2 flex h-7 w-7 -translate-y-1/2 items-center justify-center rounded-md text-[var(--danger)] outline-none transition-colors hover:bg-[var(--danger-bg)] focus-visible:bg-[var(--danger-bg)] ${$?"right-10":"right-2.5"}`,children:t.jsx("span",{tabIndex:0,role:"img","aria-label":i,className:"flex h-full w-full items-center justify-center outline-none",children:t.jsx(ks,{className:"h-[18px] w-[18px]"})})}):null,U=t.jsx(wr,{error:x?s:void 0,helperText:n,helperDisplay:a});return d?t.jsxs("label",{className:`flex flex-col gap-2 ${r}`,children:[t.jsxs("span",{className:"relative block",children:[t.jsx(Dn,{...g,type:N,required:w,placeholder:" ","aria-invalid":T||g["aria-invalid"],"data-has-value":Z?"true":void 0,className:`h-11 w-full pt-5 ${X} ${W} ${b}`,onFocus:j,onBlur:se}),t.jsxs("span",{className:"pointer-events-none absolute left-3 transition-all duration-150",style:Q,children:[e,f&&t.jsx("span",{className:"ml-1 text-[var(--danger)]",children:"*"})]}),c&&t.jsx("span",{className:"absolute right-2 transition-all duration-150",style:{top:D?7:12},children:c}),ee,te]}),U]}):t.jsxs("label",{className:`flex flex-col gap-2 ${r}`,children:[t.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-semibold uppercase text-[var(--text-muted)]",children:[t.jsx("span",{children:e}),f&&t.jsx("span",{className:"text-[var(--danger)]",children:"*"}),L?t.jsx(xr,{content:n}):null,c&&t.jsx("span",{className:"ml-auto normal-case",children:c})]}),$?t.jsxs("span",{className:"relative block",children:[t.jsx(Dn,{...g,type:N,required:w,"aria-invalid":T||g["aria-invalid"],className:`w-full ${X} ${W} ${b}`,onFocus:j,onBlur:se}),ee,te]}):t.jsxs("span",{className:"relative block",children:[t.jsx(Dn,{...g,required:w,"aria-invalid":T||g["aria-invalid"],className:`w-full ${X} ${W} ${b}`}),ee]}),U]})}function Ss(e){return e==null?"":String(e)}function Td({autoComplete:e="email",inputMode:r="email",validate:n=!0,invalidMessage:a="Ingresa un correo valido.",errorDisplay:s="tooltip",error:l,value:i,defaultValue:c,onChange:d,...u}){const[m,b]=o.useState(()=>Ss(c)),f=i!==void 0?Ss(i):m,g=n&&f.length>0&&!qa(f)?a:void 0,v=k=>{i===void 0&&b(k.currentTarget.value),d==null||d(k)};return t.jsx(Ya,{...u,value:i,defaultValue:c,type:"text",inputMode:r,autoComplete:e,error:l??g,errorDisplay:s,onChange:v})}const $d={sm:"min-h-[160px] p-4",md:"min-h-[220px] p-6",lg:"min-h-[300px] p-8"};function Ad({title:e="Sin resultados",description:r,icon:n=t.jsx(q.HiInbox,{className:"h-5 w-5"}),action:a,secondaryAction:s,size:l="md",className:i=""}){return t.jsx("div",{className:`flex items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-card)] text-center ${$d[l]} ${i}`,children:t.jsxs("div",{className:"flex max-w-sm flex-col items-center gap-3",children:[n&&t.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-input)] text-[var(--text-muted)]",children:n}),t.jsxs("div",{className:"space-y-1",children:[e&&t.jsx("h3",{className:"text-sm font-semibold text-[var(--text-main)]",children:e}),r&&t.jsx("div",{className:"text-sm leading-5 text-[var(--text-muted)]",children:r})]}),(a||s)&&t.jsxs("div",{className:"mt-1 flex flex-wrap items-center justify-center gap-2",children:[s,a]})]})})}const Ld={sm:"min-h-[112px] p-4",md:"min-h-[148px] p-5",lg:"min-h-[184px] p-6"};function Dd(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 Cs(e,r){return r?r.split(",").map(n=>n.trim().toLowerCase()).filter(Boolean).some(n=>{const a=e.name.toLowerCase(),s=e.type.toLowerCase();return n.startsWith(".")?a.endsWith(n):n.endsWith("/*")?s.startsWith(n.slice(0,-1)):s===n}):!0}function Id(e,r,n){return r?n===void 0?e:e.slice(0,Math.max(0,n)):e.slice(0,1)}function Od({label:e,helperText:r,helperDisplay:n="inline",error:a,labelAction:s,value:l,defaultValue:i=[],onFilesChange:c,onRejectedFiles:d,multiple:u=!1,maxFiles:m,appendFiles:b=!1,showFileList:f=!0,clearable:g=!0,browseLabel:v="Buscar archivos",dropLabel:k="Suelta los archivos aqui",emptyLabel:h="Arrastra y suelta archivos",emptyDescription:A="o haz click para buscarlos en tu equipo",selectedLabel:$="Archivos seleccionados",size:N="md",containerClassName:T="",dropzoneClassName:x="",fileListClassName:y="",className:L="",id:w,accept:W,disabled:X,required:Z,...D}){const Q=o.useId(),j=w??Q,se=o.useRef(null),[te,ee]=o.useState(!1),[U,J]=o.useState(i),ce=l??U,C=!!a,_=!!r&&n==="tooltip"&&!C,ae=g&&ce.length>0&&!X,B=(z,de)=>{l===void 0&&J(z),c==null||c(z,de)},I=(z,de)=>{const he=z.filter($e=>Cs($e,W)),ie=z.filter($e=>!Cs($e,W)),ge=b?[...ce,...he]:he,Me=Id(ge,u,m);ie.length>0&&(d==null||d(ie)),B(Me,de)},E=()=>{var z;X||(z=se.current)==null||z.click()},oe=z=>{I(Array.from(z.target.files??[]),z),z.target.value=""},K=z=>{z.preventDefault(),X||ee(!0)},Y=z=>{z.currentTarget.contains(z.relatedTarget)||ee(!1)},S=z=>{z.preventDefault(),ee(!1),!X&&I(Array.from(z.dataTransfer.files),z)},H=z=>{z.key!=="Enter"&&z.key!==" "||(z.preventDefault(),E())},O=z=>{B(ce.filter((de,he)=>he!==z))},re=()=>{B([])};return t.jsxs("div",{className:`flex flex-col gap-2 ${T}`,children:[(e||s||_)&&t.jsxs("div",{className:"inline-flex items-center gap-1 text-xs font-semibold uppercase text-[var(--text-muted)]",children:[e&&t.jsx("span",{children:e}),Z&&t.jsx("span",{className:"text-[var(--danger)]",children:"*"}),_?t.jsx(xr,{content:r}):null,s&&t.jsx("span",{className:"ml-auto normal-case",children:s})]}),t.jsx("input",{...D,ref:se,id:j,type:"file",accept:W,multiple:u,disabled:X,required:Z&&ce.length===0,"aria-invalid":C||D["aria-invalid"],className:"sr-only",onChange:oe}),t.jsxs("div",{role:"button",tabIndex:X?-1:0,"aria-controls":j,"aria-disabled":X||void 0,"aria-invalid":C||void 0,className:`flex cursor-pointer flex-col items-center justify-center gap-3 rounded-lg border border-dashed bg-[var(--bg-card)] text-center outline-none transition-colors focus:border-[var(--primary)] focus:bg-[var(--bg-input)] ${Ld[N]} ${te?"border-[var(--primary)] bg-[var(--bg-input)]":C?"border-[var(--danger)]":"border-[var(--border)]"} ${X?"cursor-not-allowed opacity-60":"hover:border-[var(--primary)] hover:bg-[var(--bg-input)]"} ${x} ${L}`,onClick:E,onDragOver:K,onDragLeave:Y,onDrop:S,onKeyDown:H,children:[t.jsx("span",{className:"flex h-10 w-10 items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-input)] text-[var(--text-muted)]",children:t.jsx(q.HiArrowUpTray,{className:"h-5 w-5"})}),t.jsxs("span",{className:"space-y-1",children:[t.jsx("span",{className:"block text-sm font-semibold text-[var(--text-main)]",children:te?k:h}),A&&t.jsx("span",{className:"block text-sm text-[var(--text-muted)]",children:A})]}),v&&t.jsx("span",{className:"inline-flex h-9 items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-card)] px-3 text-xs font-semibold text-[var(--text-main)] shadow-sm shadow-black/5 transition-colors",children:v})]}),f&&ce.length>0&&t.jsxs("div",{className:`rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${y}`,children:[t.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-[var(--border)] px-3 py-2",children:[t.jsx("span",{className:"text-xs font-semibold uppercase text-[var(--text-muted)]",children:$}),ae&&t.jsx("button",{type:"button",className:"inline-flex h-7 w-7 items-center justify-center rounded-md text-[var(--text-muted)] transition-colors hover:bg-[var(--bg-input)] hover:text-[var(--danger)] focus:outline-none","aria-label":"Quitar todos los archivos",onClick:re,children:t.jsx(q.HiTrash,{className:"h-4 w-4"})})]}),t.jsx("ul",{className:"divide-y divide-[var(--border)]",children:ce.map((z,de)=>t.jsxs("li",{className:"flex items-center gap-3 px-3 py-2",children:[t.jsx("span",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-md bg-[var(--bg-input)] text-[var(--text-muted)]",children:t.jsx(q.HiDocument,{className:"h-4 w-4"})}),t.jsxs("span",{className:"min-w-0 flex-1 text-left",children:[t.jsx("span",{className:"block truncate text-sm font-medium text-[var(--text-main)]",children:z.name}),t.jsx("span",{className:"block text-xs text-[var(--text-muted)]",children:Dd(z.size)})]}),!X&&t.jsx("button",{type:"button",className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-[var(--text-muted)] transition-colors hover:bg-[var(--bg-input)] hover:text-[var(--danger)] focus:outline-none","aria-label":`Quitar ${z.name}`,onClick:()=>O(de),children:t.jsx(q.HiXMark,{className:"h-4 w-4"})})]},`${z.name}-${z.lastModified}-${de}`))})]}),t.jsx(wr,{error:a,helperText:r,helperDisplay:n})]})}const Hd=[{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 Bd({fields:e,title:r="Layout",fieldTypes:n=Hd,saveLabel:a="Guardar",allowAddField:s=!1,addFieldPlaceholder:l="Nuevo campo",addFieldLabel:i="Anadir",loading:c=!1,onSave:d,onChange:u}){const[m,b]=o.useState(()=>e.map(N=>({key:!1,type:"",...N}))),[f,g]=o.useState(""),[v,k]=o.useState(""),h=o.useCallback((N,T)=>{b(x=>{const y=x.map((L,w)=>w===N?{...L,...T}:L);return u==null||u(y),y})},[u]),A=o.useCallback(()=>{d==null||d(m)},[m,d]),$=o.useCallback(()=>{var y;const N=f.trim();if(!N){k("Ingresa un nombre de campo.");return}if(m.some(L=>L.name.toLowerCase()===N.toLowerCase())){k("Ese campo ya existe en el arreglo.");return}const x={name:N,key:!1,type:((y=n[0])==null?void 0:y.value)??""};b(L=>{const w=[...L,x];return u==null||u(w),w}),g(""),k("")},[n,m,f,u]);return t.jsxs("div",{className:"flex flex-col rounded-xl border shadow-sm",style:{borderColor:"var(--border)",background:"var(--bg-card)",color:"var(--text-main)"},children:[t.jsx("div",{className:"border-b px-6 py-4",style:{borderColor:"var(--border)"},children:t.jsx("span",{className:"text-base font-semibold",style:{color:"var(--text-main)"},children:r})}),t.jsxs("div",{className:"grid grid-cols-[1fr_80px_1fr] gap-4 border-b px-6 py-2 text-xs font-medium uppercase tracking-wide",style:{borderColor:"var(--border)",color:"var(--text-muted)"},children:[t.jsx("span",{children:"Campo"}),t.jsx("span",{className:"text-center",children:"Llave"}),t.jsx("span",{children:"Tipo de Campo"})]}),t.jsxs("div",{className:"max-h-[420px] overflow-y-auto",children:[m.map((N,T)=>t.jsxs("div",{className:"grid grid-cols-[1fr_80px_1fr] items-center gap-4 border-b px-6 py-3 last:border-0 hover:bg-[var(--bg-input)] transition-colors",style:{borderColor:"var(--border)"},children:[t.jsx("span",{className:"text-sm font-medium",style:{color:"var(--text-main)"},children:N.name}),t.jsx("div",{className:"flex justify-center",children:t.jsx(Nn,{size:"sm",checked:N.key??!1,onChange:x=>h(T,{key:x.target.checked}),"aria-label":`${N.name} es clave`})}),t.jsx(ar,{value:N.type??"",onChange:x=>h(T,{type:x}),options:n,placeholder:"—",emptyLabel:"—",height:36,searchable:!1,ariaLabel:`Tipo de ${N.name}`})]},N.name)),m.length===0&&t.jsx("p",{className:"px-6 py-8 text-center text-sm",style:{color:"var(--text-muted)"},children:"No hay campos disponibles."})]}),t.jsx("div",{className:"flex justify-end border-t px-6 py-4",style:{borderColor:"var(--border)"},children:t.jsxs("div",{className:"w-full space-y-2",children:[s&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{type:"text",value:f,onChange:N=>{g(N.currentTarget.value),v&&k("")},onKeyDown:N=>{N.key==="Enter"&&(N.preventDefault(),$())},placeholder:l,className:"min-w-0 flex-1 rounded-lg border px-3 py-2 text-sm outline-none transition-colors",style:{borderColor:"var(--border)",background:"var(--bg-input)",color:"var(--text-main)"},"aria-label":"Nombre del nuevo campo"}),t.jsx(Ue,{variant:"secondary",onClick:$,height:36,padding:"0 12px",children:i})]}),v&&t.jsx("p",{className:"text-xs",style:{color:"var(--danger)"},children:v})]}),t.jsx("div",{className:"flex justify-end",children:t.jsx(Ue,{variant:"primary",onClick:A,disabled:c,loading:c,children:a})})]})})]})}function In({label:e,children:r,helperText:n,helperDisplay:a="inline",error:s,labelAction:l,required:i=!1,className:c="",contentClassName:d=""}){const u=!!n&&a==="tooltip"&&!s;return t.jsxs("label",{className:`flex flex-col gap-2 ${c}`,children:[(e||l||u)&&t.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-semibold uppercase text-[var(--text-muted)]",children:[e&&t.jsx("span",{children:e}),i&&t.jsx("span",{className:"text-[var(--danger)]",children:"*"}),u?t.jsx(xr,{content:n}):null,l&&t.jsx("span",{className:"ml-auto normal-case",children:l})]}),t.jsx("span",{className:`block ${d}`,children:r}),t.jsx(wr,{error:s,helperText:n,helperDisplay:a})]})}function Fd(e){return Array.from(e.querySelectorAll("img")).filter(r=>!!(r.currentSrc||r.src||"").trim())}function Es(e,r){const n=e.target;if(!(n instanceof HTMLImageElement))return!1;const a=e.currentTarget,s=Fd(a),l=s.indexOf(n);if(l<0)return!1;e.preventDefault(),e.stopPropagation();const i=n.getBoundingClientRect();return r(s.map(c=>({src:c.currentSrc||c.src,alt:c.alt||void 0})),l,{left:i.left,top:i.top,width:i.width,height:i.height}),!0}const St=260,Nr=420,Xa=380,At="cubic-bezier(0.22, 1, 0.36, 1)",Pd="cubic-bezier(0.16, 1, 0.3, 1)",Ka="cubic-bezier(0.22, 1, 0.36, 1)",_d="cubic-bezier(0.22, 1, 0.36, 1)",zd=8,Wd=1,jd=1.25,Ga={background:"color-mix(in srgb, var(--bg-card) 90%, transparent)",border:"1px solid var(--border)",boxShadow:"0 10px 28px color-mix(in srgb, var(--bg-main) 28%, transparent), inset 0 1px 0 color-mix(in srgb, var(--bg-card) 55%, transparent)",color:"var(--text-main)",backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)"},qd="color-mix(in srgb, var(--bg-card) 88%, var(--primary) 12%)",Za=10;function tn(e,r,n){return Math.min(n,Math.max(r,e))}function Ud(e){return!e||e.width<1||e.height<1?null:{left:e.left,top:e.top,width:e.width,height:e.height}}function Ms(e,r){if(r.width<1||r.height<1)return{dx:0,dy:0,scale:1};const n=Math.min(e.width/r.width,e.height/r.height),a=e.left+e.width/2-(r.left+r.width/2),s=e.top+e.height/2-(r.top+r.height/2);return{dx:a,dy:s,scale:Number.isFinite(n)?n:1}}function kr({label:e,onClick:r,children:n,disabled:a,size:s="md"}){const l=s==="lg"?44:40;return t.jsx("button",{type:"button","aria-label":e,title:e,disabled:a,onClick:i=>{i.stopPropagation(),r()},className:"inline-flex items-center justify-center rounded-full disabled:cursor-not-allowed disabled:opacity-35",style:{...Ga,width:l,height:l,transition:"background 160ms ease, transform 160ms cubic-bezier(0.22, 1, 0.36, 1), opacity 160ms ease"},onMouseEnter:i=>{a||(i.currentTarget.style.background=qd,i.currentTarget.style.transform="scale(1.06)")},onMouseLeave:i=>{i.currentTarget.style.background=String(Ga.background??""),i.currentTarget.style.transform="scale(1)"},onMouseDown:i=>{a||(i.currentTarget.style.transform="scale(0.94)")},onMouseUp:i=>{a||(i.currentTarget.style.transform="scale(1.06)")},children:n})}function Ts({open:e,onClose:r,slides:n,index:a,onIndexChange:s,originRect:l=null,maxZoom:i=zd,minZoom:c=Wd,zoomStep:d=jd,closeOnBackdrop:u=!0,closeOnEscape:m=!0,showCounter:b=!0,showZoomControls:f=!0,loop:g=!0,showThumbnails:v=!0,zIndex:k=1100,ariaLabel:h="Visor de imagen"}){const[A,$]=o.useState(!1),[N,T]=o.useState(!1),[x,y]=o.useState(a??0),[L,w]=o.useState(1),[W,X]=o.useState({x:0,y:0}),[Z,D]=o.useState({opacity:1,x:0,scale:1,blur:0,animate:!1}),[Q,j]=o.useState({dx:0,dy:0,scale:1,animate:!1,enabled:!1}),[se,te]=o.useState(!1),ee=o.useRef(null),U=o.useRef(null),J=o.useRef(null),ce=o.useRef(null),C=o.useRef(null),_=o.useRef(!1),ae=o.useRef(!1),B=o.useRef(null),I=o.useRef(null),E=o.useRef(null),oe=o.useRef(null),K=o.useRef(null),Y=o.useRef(a??0),S=a??x,H=n.length===0?0:tn(S,0,Math.max(0,n.length-1)),O=n[H],re=n.length>1,z=Math.max(c,i),de=v&&re,he=o.useCallback(ue=>{if(n.length===0)return;const pe=n.length-1,Le=g?(ue%n.length+n.length)%n.length:tn(ue,0,pe);a===void 0&&y(Le),s==null||s(Le)},[a,g,s,n.length]),ie=o.useCallback(()=>{w(1),X({x:0,y:0})},[]),ge=o.useCallback((ue,pe)=>{if(pe<=c+.001)return{x:0,y:0};const Le=oe.current,He=K.current;if(!Le||!He)return ue;const Ie=Le.getBoundingClientRect(),tt=He.offsetWidth*pe,at=He.offsetHeight*pe,We=Math.max(0,(tt-Ie.width)/2+Ie.width*.15),Ke=Math.max(0,(at-Ie.height)/2+Ie.height*.15);return{x:tn(ue.x,-We,We),y:tn(ue.y,-Ke,Ke)}},[c]),Me=o.useCallback(()=>{$(!1),j({dx:0,dy:0,scale:1,animate:!1,enabled:!1}),ce.current=null,C.current=null,_.current=!1,ae.current=!1,B.current&&(clearTimeout(B.current),B.current=null)},[]),$e=o.useCallback(()=>{if(_.current)return;_.current=!0,T(!1),ie();const ue=ce.current,pe=ue!=null&&C.current!=null&&C.current===H;if(ue&&pe){J.current!=null&&cancelAnimationFrame(J.current),J.current=requestAnimationFrame(()=>{J.current=requestAnimationFrame(()=>{const Le=K.current;if(!Le){J.current=null,ee.current&&clearTimeout(ee.current),ee.current=setTimeout(Me,St+40);return}const He=Le.getBoundingClientRect(),Ie=Ms(ue,He);j({enabled:!0,dx:0,dy:0,scale:1,animate:!1}),J.current=requestAnimationFrame(()=>{j({enabled:!0,dx:Ie.dx,dy:Ie.dy,scale:Ie.scale,animate:!0}),J.current=null})})}),ee.current&&clearTimeout(ee.current),ee.current=setTimeout(Me,Nr+80);return}j({dx:0,dy:0,scale:1,animate:!1,enabled:!1}),ee.current&&clearTimeout(ee.current),ee.current=setTimeout(Me,St+40)},[Me,ie,H]);o.useEffect(()=>(e?(ee.current&&clearTimeout(ee.current),B.current&&(clearTimeout(B.current),B.current=null),_.current=!1,ae.current=!1,ce.current=Ud(l),C.current=ce.current!=null?a??x:null,$(!0),T(!1),ce.current?j({dx:0,dy:0,scale:1,animate:!1,enabled:!0}):(C.current=null,requestAnimationFrame(()=>requestAnimationFrame(()=>{T(!0),j({dx:0,dy:0,scale:1,animate:!1,enabled:!1})})))):A&&$e(),()=>{ee.current&&clearTimeout(ee.current),J.current!=null&&cancelAnimationFrame(J.current)}),[e]);const Dt=o.useCallback(()=>{if(!e||_.current||ae.current)return;const ue=ce.current,pe=K.current;if(!ue||!pe){ue||(T(!0),ae.current=!0);return}const Le=pe.getBoundingClientRect();if(Le.width<2||Le.height<2)return;ae.current=!0;const He=Ms(ue,Le);j({enabled:!0,dx:He.dx,dy:He.dy,scale:He.scale,animate:!1}),J.current!=null&&cancelAnimationFrame(J.current),J.current=requestAnimationFrame(()=>{J.current=requestAnimationFrame(()=>{j({enabled:!0,dx:0,dy:0,scale:1,animate:!0}),T(!0),J.current=null,B.current&&clearTimeout(B.current),B.current=setTimeout(()=>{j({dx:0,dy:0,scale:1,animate:!1,enabled:!1}),B.current=null},Nr+20)})})},[e]);o.useLayoutEffect(()=>{!A||!e||!ce.current||ae.current||Dt()},[A,e,Dt]),o.useEffect(()=>{!e||_.current||C.current!=null&&C.current!==H&&j(ue=>ue.enabled?{dx:0,dy:0,scale:1,animate:!1,enabled:!1}:ue)},[e,H]),o.useEffect(()=>{if(!e)return;const ue=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=ue}},[e]),o.useEffect(()=>{e&&ie()},[e,H,ie]),o.useEffect(()=>{a!==void 0&&y(a)},[a]),o.useEffect(()=>{if(!e){Y.current=H,D({opacity:1,x:0,scale:1,blur:0,animate:!1});return}const ue=Y.current;if(ue===H)return;Y.current=H;const pe=n.length;let Le=1;if(pe>1){const He=(ue+1)%pe===H,Ie=(ue-1+pe)%pe===H;Ie&&!He?Le=-1:He&&!Ie?Le=1:Le=H>ue?1:-1}return U.current!=null&&(cancelAnimationFrame(U.current),U.current=null),D({opacity:0,x:Le*56,scale:.94,blur:8,animate:!1}),U.current=requestAnimationFrame(()=>{U.current=requestAnimationFrame(()=>{D({opacity:1,x:0,scale:1,blur:0,animate:!0}),U.current=null})}),()=>{U.current!=null&&(cancelAnimationFrame(U.current),U.current=null)}},[e,H,n.length]);const ut=L<=c+.001&&Math.abs(W.x)<.5&&Math.abs(W.y)<.5,Re=o.useCallback((ue,pe,Le)=>{w(He=>{const Ie=tn(ue,c,z);if(Math.abs(Ie-He)<1e-4)return He;const tt=Ie/He,at=Ie<He;return Ie<=c+.001?(X({x:0,y:0}),c):(X(We=>{let Ke=We;if(typeof pe=="number"&&typeof Le=="number"&&oe.current&&!at){const Ge=oe.current.getBoundingClientRect(),Ae=pe-Ge.left-Ge.width/2,lr=Le-Ge.top-Ge.height/2;Ke={x:Ae-(Ae-We.x)*tt,y:lr-(lr-We.y)*tt}}else if(at){Ke={x:We.x*tt,y:We.y*tt};const Ge=Math.min(1,(He-Ie)/Math.max(.01,He-c));Ke={x:Ke.x*(1-Ge*.65),y:Ke.y*(1-Ge*.65)}}else Ke={x:We.x*tt,y:We.y*tt};return ge(Ke,Ie)}),Ie)})},[ge,c,z]),It=o.useCallback(()=>{Re(L*d)},[Re,L,d]),Ct=o.useCallback(()=>{const ue=Math.max(c,L/d);if(ue<=c+.001){ie();return}w(ue),X({x:0,y:0})},[c,ie,L,d]);o.useEffect(()=>{if(!e)return;const ue=pe=>{if(pe.key==="Escape"&&m){pe.preventDefault(),r();return}pe.key==="ArrowLeft"&&re?(pe.preventDefault(),he(H-1)):pe.key==="ArrowRight"&&re?(pe.preventDefault(),he(H+1)):pe.key==="+"||pe.key==="="?(pe.preventDefault(),Re(L*d)):pe.key==="-"||pe.key==="_"?(pe.preventDefault(),Ct()):pe.key==="0"&&(pe.preventDefault(),ie())};return window.addEventListener("keydown",ue),()=>window.removeEventListener("keydown",ue)},[Re,m,re,r,e,ie,H,L,he,Ct,d]);const Et=ue=>{ue.preventDefault();const pe=ue.deltaY>0?1/d:d;Re(L*pe,ue.clientX,ue.clientY)},le=ue=>{L<=c+.001||(ue.currentTarget.setPointerCapture(ue.pointerId),te(!0),I.current={pointerId:ue.pointerId,startX:ue.clientX,startY:ue.clientY,originX:W.x,originY:W.y})},Fe=ue=>{const pe=I.current;!pe||pe.pointerId!==ue.pointerId||X(ge({x:pe.originX+(ue.clientX-pe.startX),y:pe.originY+(ue.clientY-pe.startY)},L))},ze=ue=>{var pe;((pe=I.current)==null?void 0:pe.pointerId)===ue.pointerId&&(I.current=null,te(!1))},ft=ue=>{if(ue.stopPropagation(),L>c+.05){ie();return}Re(Math.min(z,3),ue.clientX,ue.clientY)},Ve=ue=>{if(ue.touches.length!==2)return;te(!0);const[pe,Le]=[ue.touches[0],ue.touches[1]],He=Math.hypot(pe.clientX-Le.clientX,pe.clientY-Le.clientY);E.current={distance:He,scale:L}},Mt=ue=>{if(ue.touches.length!==2||!E.current)return;ue.preventDefault();const[pe,Le]=[ue.touches[0],ue.touches[1]],He=Math.hypot(pe.clientX-Le.clientX,pe.clientY-Le.clientY),Ie=(pe.clientX+Le.clientX)/2,tt=(pe.clientY+Le.clientY)/2,at=E.current.scale*(He/Math.max(1,E.current.distance));Re(at,Ie,tt)},bt=()=>{E.current=null,te(!1)};if(!A||!O)return null;const rt=Q.enabled,Wt=Q.animate?`transform ${Nr}ms ${_d}`:"none";return ct.createPortal(t.jsxs("div",{className:"fixed inset-0",style:{zIndex:k},role:"dialog","aria-modal":"true","aria-label":h,children:[t.jsx("button",{type:"button","aria-label":"Cerrar",className:"absolute inset-0 border-0",style:{background:"color-mix(in srgb, var(--bg-sidebar, var(--primary)) 72%, transparent)",backdropFilter:"blur(10px)",WebkitBackdropFilter:"blur(10px)",opacity:N?1:0,transition:`opacity ${rt?Nr:St}ms ${At}`,cursor:"default",zIndex:0},onClick:()=>{u&&r()}}),t.jsx("div",{ref:oe,className:"absolute inset-0 flex items-center justify-center",style:{zIndex:1,padding:de?"4.5rem 3.5rem 6.5rem":"4.5rem 3.5rem 2.5rem",opacity:rt||N?1:0,transform:rt||N?"translateY(0) scale(1)":"translateY(10px) scale(0.96)",transition:rt?"none":`opacity ${St}ms ${At}, transform ${St}ms ${At}`},onClick:ue=>{ue.target===ue.currentTarget&&u&&r()},onWheel:Et,children:t.jsx("div",{className:"relative flex max-h-full max-w-full items-center justify-center will-change-transform",style:{transform:Q.enabled?`translate3d(${Q.dx}px, ${Q.dy}px, 0) scale(${Q.scale})`:void 0,transformOrigin:"center center",transition:Q.enabled?Wt:void 0},children:t.jsx("div",{className:"relative flex max-h-full max-w-full items-center justify-center will-change-transform",style:{opacity:Z.opacity,filter:Z.blur?`blur(${Z.blur}px)`:"blur(0px)",transform:`translate3d(${Z.x}px, 0, 0) scale(${Z.scale})`,transition:Z.animate?[`opacity ${Xa}ms ${Ka}`,`transform ${Xa}ms ${Ka}`,`filter ${Xa}ms ${Ka}`].join(", "):"none"},children:t.jsx("div",{ref:K,className:"pointer-events-auto relative max-h-full max-w-full touch-none select-none will-change-transform",style:{cursor:L>c+.001?"grab":"zoom-in",transform:`translate3d(${W.x}px, ${W.y}px, 0) scale(${L})`,transformOrigin:"center center",transition:se?"none":`transform 220ms ${Pd}`},onClick:ue=>ue.stopPropagation(),onDoubleClick:ft,onPointerDown:le,onPointerMove:Fe,onPointerUp:ze,onPointerCancel:ze,onTouchStart:Ve,onTouchMove:Mt,onTouchEnd:bt,children:t.jsx("img",{src:O.src,alt:O.alt||"",draggable:!1,className:"block max-h-[min(78vh,820px)] max-w-[min(86vw,1100px)] object-contain",style:{display:"block",borderRadius:Za,imageRendering:L>2.5?"pixelated":"auto"},onLoad:()=>{Dt()}},O.src+String(H))})})})}),t.jsxs("div",{className:"pointer-events-none absolute inset-0",style:{zIndex:2,opacity:N?1:0,transform:N?"translateY(0)":"translateY(-6px)",transition:`opacity ${rt?Nr:St}ms ${At}, transform ${rt?Nr:St}ms ${At}`},children:[t.jsxs("div",{className:"pointer-events-none absolute inset-x-0 top-0 flex items-center justify-between gap-3 px-4 pt-4",children:[t.jsx("div",{className:"pointer-events-auto flex items-center gap-2",children:b&&n.length>0?t.jsxs("span",{className:"rounded-full px-3 py-1.5 text-xs font-semibold tracking-wide",style:Ga,children:[H+1," / ",n.length]}):null}),t.jsxs("div",{className:"pointer-events-auto flex items-center gap-2",children:[f?t.jsxs(t.Fragment,{children:[t.jsx(kr,{label:"Alejar",onClick:Ct,disabled:L<=c+.001,children:t.jsx(q.HiMinus,{className:"h-5 w-5"})}),t.jsx(kr,{label:"Restablecer tamaño",onClick:ie,disabled:ut,children:t.jsx(q.HiArrowsPointingIn,{className:"h-5 w-5"})}),t.jsx(kr,{label:"Acercar",onClick:It,disabled:L>=z-.001,children:t.jsx(q.HiPlus,{className:"h-5 w-5"})})]}):null,t.jsx(kr,{label:"Cerrar",onClick:r,children:t.jsx(q.HiXMark,{className:"h-5 w-5"})})]})]}),re?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"pointer-events-auto absolute left-3 top-1/2",style:{opacity:N?1:0,transform:N?"translate(0, -50%)":"translate(-8px, -50%)",transition:`opacity ${St}ms ${At}, transform ${St}ms ${At}`},children:t.jsx(kr,{label:"Anterior",size:"lg",onClick:()=>he(H-1),disabled:!g&&H<=0,children:t.jsx(q.HiChevronLeft,{className:"h-6 w-6"})})}),t.jsx("div",{className:"pointer-events-auto absolute right-3 top-1/2",style:{opacity:N?1:0,transform:N?"translate(0, -50%)":"translate(8px, -50%)",transition:`opacity ${St}ms ${At}, transform ${St}ms ${At}`},children:t.jsx(kr,{label:"Siguiente",size:"lg",onClick:()=>he(H+1),disabled:!g&&H>=n.length-1,children:t.jsx(q.HiChevronRight,{className:"h-6 w-6"})})})]}):null,de?t.jsx("div",{className:"pointer-events-none absolute inset-x-0 bottom-0 flex justify-center px-4 pb-4 pt-8",style:{background:"linear-gradient(to top, color-mix(in srgb, var(--bg-sidebar, var(--primary)) 72%, transparent), transparent)"},children:t.jsx("div",{className:"pointer-events-auto flex max-w-full items-end gap-2.5 overflow-x-auto rounded-2xl px-2 py-2",style:{background:"color-mix(in srgb, var(--bg-card) 55%, transparent)",backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)",scrollbarWidth:"thin"},role:"tablist","aria-label":"Miniaturas",children:n.map((ue,pe)=>{const Le=pe===H;return t.jsx("button",{type:"button",role:"tab","aria-selected":Le,"aria-label":ue.alt||`Imagen ${pe+1}`,onClick:He=>{He.stopPropagation(),he(pe)},className:"relative shrink-0 overflow-hidden transition-opacity",style:{width:56,height:42,borderRadius:Za,opacity:Le?1:.42,transition:`opacity 180ms ${At}`},children:t.jsx("img",{src:ue.src,alt:"",draggable:!1,className:"h-full w-full object-cover",style:{borderRadius:Za}})},`${ue.src}-${pe}`)})})}):null]})]}),document.body)}function Vd({children:e,className:r,style:n,maxZoom:a,minZoom:s,zoomStep:l,loop:i,showThumbnails:c}){const[d,u]=o.useState(!1),[m,b]=o.useState(0),[f,g]=o.useState([]),[v,k]=o.useState(null),h=o.useCallback(($,N,T)=>{g($),k(T??null),b(N),u(!0)},[]),A=o.useCallback($=>{Es($,h)},[h]);return t.jsxs(t.Fragment,{children:[t.jsx("div",{className:`[&_img]:cursor-zoom-in ${r??""}`,style:n,onClick:A,children:e}),t.jsx(Ts,{open:d,onClose:()=>u(!1),index:m,onIndexChange:b,slides:f,originRect:v,maxZoom:a,minZoom:s,zoomStep:l,loop:i,showThumbnails:c})]})}function $s(e){if(e!==void 0)return typeof e=="number"?`${e}px`:e}function As(e,r){if(e.length!==r.length)return!1;const n=new Set(r);return e.every(a=>n.has(a))}function Qa(e){return e.normalize("NFD").replace(new RegExp("\\p{M}","gu"),"").toLowerCase()}function Yd(e,r){if(!r)return!0;const n=Qa(r);return Qa(e.label).includes(n)||!!(e.sublabel&&Qa(e.sublabel).includes(n))}function Xd({value:e,onChange:r,options:n,placeholder:a="Seleccionar…",disabled:s=!1,className:l="",style:i,height:c=40,padding:d="6px 10px",searchable:u=!0,minOptionsForSearch:m=6,maxVisibleValues:b=2,truncateSelectedValues:f=!0,emptyText:g="Sin resultados",clearLabel:v="Limpiar seleccion",pruneMissingValues:k=!0}){const[h,A]=o.useState(!1),[$,N]=o.useState(""),[T,x]=o.useState(0),[y,L]=o.useState(!1),[w,W]=o.useState({}),X=o.useRef(null),Z=o.useRef(null),D=o.useRef(null),Q=o.useRef(null),j=u&&n.length>=m,se=o.useMemo(()=>new Set(e),[e]),te=o.useMemo(()=>{const S=new Map;for(const H of n)S.set(H.value,H);return S},[n]),ee=o.useMemo(()=>{const S=[];for(const H of e){const O=te.get(H);O&&S.push(O)}return S},[te,e]),U=b==="all"?ee.length:b,J=ee.slice(0,U),ce=Math.max(0,ee.length-J.length),C=o.useMemo(()=>{const S=$.trim();return!j||!S?n:n.filter(H=>Yd(H,S))},[n,$,j]),_=o.useCallback(()=>{const S=X.current;if(!S)return;const H=S.getBoundingClientRect(),O=j?304:244,re=window.innerHeight-H.bottom,z=re<O&&H.top>re;W({position:"fixed",left:H.left,top:z?void 0:H.bottom+4,bottom:z?window.innerHeight-H.top+4:void 0,width:Math.max(H.width,240),zIndex:9999})},[j]),ae=o.useCallback(S=>{As(e,S)||r(S)},[r,e]),B=o.useCallback(S=>{const H=te.get(S);if(H!=null&&H.disabled)return;const O=se.has(S)?e.filter(re=>re!==S):[...e,S];ae(O)},[ae,te,e,se]),I=o.useCallback(()=>ae([]),[ae]),E=o.useCallback(()=>{A(!1),N(""),x(0)},[]);o.useEffect(()=>L(!0),[]);const oe=o.useMemo(()=>n.map(S=>S.value).join("\0"),[n]);o.useEffect(()=>{if(!k||e.length===0||n.length===0)return;const S=new Set(n.map(O=>O.value)),H=e.filter(O=>S.has(O));As(e,H)||r(H)},[oe]),o.useEffect(()=>{if(!h)return;function S(H){var re,z;const O=H.target;!((re=X.current)!=null&&re.contains(O))&&!((z=Z.current)!=null&&z.contains(O))&&E()}return document.addEventListener("mousedown",S),()=>document.removeEventListener("mousedown",S)},[E,h]),o.useEffect(()=>{h&&(x(0),_(),j&&setTimeout(()=>{var S;return(S=D.current)==null?void 0:S.focus()},0))},[h,j,_]),o.useEffect(()=>{if(h)return window.addEventListener("resize",_),window.addEventListener("scroll",_,!0),()=>{window.removeEventListener("resize",_),window.removeEventListener("scroll",_,!0)}},[h,_]),o.useEffect(()=>{if(C.length===0){x(0);return}x(S=>Math.min(S,C.length-1))},[C.length]),o.useEffect(()=>{if(T<0||!Q.current)return;const S=Q.current.children[T];S==null||S.scrollIntoView({block:"nearest"})},[T]);function K(S){if(!s){if(!h){(S.key==="Enter"||S.key===" "||S.key==="ArrowDown")&&(S.preventDefault(),A(!0));return}if(S.key==="Escape"){S.preventDefault(),E();return}if(S.key==="ArrowDown"){if(S.preventDefault(),C.length===0)return;x(H=>Math.min(H+1,C.length-1));return}if(S.key==="ArrowUp"){S.preventDefault(),x(H=>Math.max(H-1,0));return}if(S.key==="Enter"&&C[T]&&!C[T].disabled){S.preventDefault(),B(C[T].value);return}S.key==="Backspace"&&!$&&e.length&&(S.preventDefault(),ae(e.slice(0,-1)))}}const Y=t.jsxs("div",{ref:Z,className:"overflow-hidden rounded-xl shadow-xl",style:{...w,background:"var(--bg-card)",border:"1px solid var(--border)"},children:[j&&t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",style:{borderBottom:"1px solid var(--border)"},children:[t.jsx(q.HiMagnifyingGlass,{className:"h-3.5 w-3.5 flex-shrink-0",style:{color:"var(--text-muted)"}}),t.jsx("input",{ref:D,value:$,onChange:S=>{N(S.target.value),x(0)},onKeyDown:S=>{(S.key==="ArrowDown"||S.key==="ArrowUp"||S.key==="Enter"||S.key==="Escape")&&(S.stopPropagation(),K(S))},placeholder:"Buscar…",className:"min-w-0 flex-1 bg-transparent text-sm outline-none",style:{color:"var(--text-main)"}}),$&&t.jsx("button",{type:"button","aria-label":"Limpiar búsqueda",onMouseDown:S=>{S.preventDefault(),N(""),x(0)},children:t.jsx(q.HiXMark,{className:"h-3.5 w-3.5",style:{color:"var(--text-muted)"}})})]}),e.length>0&&t.jsxs("div",{className:"flex items-center justify-between gap-3 px-3 py-2 text-xs",style:{borderBottom:"1px solid var(--border)",color:"var(--text-muted)"},children:[t.jsxs("span",{children:[ee.length," seleccionados",e.length>ee.length?` (${e.length-ee.length} no disponibles)`:""]}),t.jsx("button",{type:"button",onMouseDown:S=>{S.preventDefault(),I()},className:"font-semibold transition-colors hover:text-[var(--primary)]",children:v})]}),t.jsxs("ul",{ref:Q,role:"listbox","aria-multiselectable":"true",className:"overflow-y-auto",style:{maxHeight:j?220:200,scrollbarWidth:"thin",scrollbarColor:"var(--border) transparent",overscrollBehavior:"contain"},children:[C.map((S,H)=>{const O=H===T,re=se.has(S.value);return t.jsxs("li",{role:"option","aria-selected":re,onMouseDown:z=>{z.preventDefault(),!S.disabled&&B(S.value)},onMouseEnter:()=>!S.disabled&&x(H),className:"flex cursor-pointer items-center gap-2 px-3 py-2 text-sm transition-colors",style:{background:O?"var(--bg-hover)":re?"color-mix(in srgb, var(--primary) 6%, transparent)":"transparent",color:S.disabled?"var(--text-muted)":"var(--text-main)",cursor:S.disabled?"not-allowed":"pointer",opacity:S.disabled?.58:1},children:[t.jsx("span",{className:"flex h-4 w-4 flex-shrink-0 items-center justify-center rounded border",style:{borderColor:re?"var(--primary)":"var(--border)",background:re?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:re&&t.jsx(q.HiCheck,{className:"h-3 w-3"})}),S.color&&t.jsx("span",{className:"h-2.5 w-2.5 flex-shrink-0 rounded-full",style:{background:S.color}}),t.jsxs("span",{className:"flex min-w-0 flex-1 items-baseline gap-1 overflow-hidden",children:[t.jsx(Pt,{className:"min-w-0 flex-1",children:S.label}),S.sublabel&&t.jsx(Pt,{className:"min-w-0 flex-shrink",style:{color:"var(--text-muted)",fontSize:12},children:S.sublabel})]}),S.badge&&t.jsx("span",{className:"flex-shrink-0 text-xs",style:{color:"var(--text-muted)"},children:S.badge})]},S.value)}),C.length===0&&t.jsx("li",{className:"px-3 py-4 text-center text-sm",style:{color:"var(--text-muted)"},children:g})]})]});return t.jsxs("div",{ref:X,className:`relative ${l||"w-full"}`,style:i,onKeyDown:K,children:[t.jsxs("button",{type:"button",disabled:s,onClick:()=>{s||(h?E():A(!0))},className:"flex w-full items-center gap-2 rounded-lg text-left text-sm transition-colors focus:outline-none",style:{minHeight:$s(c),padding:$s(d),background:"var(--bg-input)",color:ee.length?"var(--text-main)":"var(--text-muted)",border:h?"1px solid var(--primary)":"1px solid var(--border)",opacity:s?.5:1,cursor:s?"not-allowed":"pointer"},"aria-haspopup":"listbox","aria-expanded":h,children:[t.jsx("span",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-1.5 overflow-hidden",children:J.length?t.jsxs(t.Fragment,{children:[J.map(S=>t.jsxs("span",{className:`inline-flex items-center gap-1 rounded-md border px-1.5 py-0.5 text-xs font-semibold ${f?"max-w-[160px]":"max-w-full whitespace-normal"}`,style:{background:"var(--bg-card)",borderColor:"var(--border)",color:"var(--text-main)"},children:[S.color&&t.jsx("span",{className:"h-1.5 w-1.5 flex-shrink-0 rounded-full",style:{background:S.color}}),f?t.jsx(Pt,{className:"min-w-0 flex-1",children:S.label}):t.jsx("span",{className:"break-words",children:S.label}),t.jsx("span",{role:"button",tabIndex:-1,"aria-label":`Quitar ${S.label}`,onMouseDown:H=>{H.preventDefault(),H.stopPropagation(),B(S.value)},className:"flex-shrink-0 rounded-full p-0.5 transition-colors hover:bg-black/10",style:{color:"var(--text-muted)"},children:t.jsx(q.HiXMark,{className:"h-3 w-3"})})]},S.value)),ce>0&&t.jsxs("span",{className:"inline-flex items-center rounded-md px-1.5 py-0.5 text-xs font-semibold",style:{background:"color-mix(in srgb, var(--primary) 10%, transparent)",color:"var(--primary)"},children:["+",ce]})]}):t.jsx("span",{className:"truncate",children:a})}),ee.length?t.jsx("span",{role:"button",tabIndex:-1,"aria-label":v,onMouseDown:S=>{S.preventDefault(),S.stopPropagation(),I()},className:"flex-shrink-0 rounded-full p-0.5 transition-colors hover:bg-black/10",style:{color:"var(--text-muted)"},children:t.jsx(q.HiXMark,{className:"h-3.5 w-3.5"})}):t.jsx(q.HiChevronDown,{className:"h-4 w-4 flex-shrink-0 transition-transform",style:{color:"var(--text-muted)",transform:h?"rotate(180deg)":"rotate(0deg)"}})]}),h&&y&&ct.createPortal(Y,document.body)]})}function Kd({inputMode:e="decimal",...r}){return t.jsx(Ya,{...r,type:"number",inputMode:e})}function Gd(e,r,n){const a=[],s=Math.max(2,e-n),l=Math.min(r-1,e+n);a.push(1),s>2&&a.push("...");for(let i=s;i<=l;i+=1)a.push(i);return l<r-1&&a.push("..."),r>1&&a.push(r),a}function Zd({page:e,totalPages:r,onPageChange:n,disabled:a=!1,siblingCount:s=1,className:l=""}){const i=Math.max(1,r),c=Math.min(Math.max(1,e),i),d=Gd(c,i,s);return t.jsxs("nav",{"aria-label":"Paginacion",className:`inline-flex items-center gap-1 ${l}`,children:[t.jsx(Ue,{variant:"icon",size:"xs","aria-label":"Pagina anterior",disabled:a||c<=1,onClick:()=>n(c-1),children:t.jsx(q.HiChevronLeft,{className:"h-4 w-4"})}),d.map((u,m)=>u==="..."?t.jsx("span",{className:"flex h-8 min-w-8 items-center justify-center text-xs font-semibold text-[var(--text-muted)]",children:"..."},`ellipsis-${m}`):t.jsx("button",{type:"button","aria-current":u===c?"page":void 0,disabled:a,onClick:()=>n(u),className:"flex h-8 min-w-8 items-center justify-center rounded-md border px-2 text-xs font-semibold transition-colors disabled:cursor-not-allowed disabled:opacity-50",style:{borderColor:u===c?"var(--primary)":"var(--border)",background:u===c?"var(--primary)":"var(--bg-card)",color:u===c?"var(--primary-fg)":"var(--text-secondary)"},children:u},u)),t.jsx(Ue,{variant:"icon",size:"xs","aria-label":"Pagina siguiente",disabled:a||c>=i,onClick:()=>n(c+1),children:t.jsx(q.HiChevronRight,{className:"h-4 w-4"})})]})}const Ls=[{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 Ds(e){return e==null?"":String(e)}function On(e){return e?e.startsWith("+")?e:`+${e}`:"+1"}function Qd(e){return typeof e=="number"?`${e}px`:e}function Jd({autoComplete:e="tel",inputMode:r="tel",validate:n=!0,invalidMessage:a="Ingresa un telefono valido.",errorDisplay:s="tooltip",error:l,value:i,defaultValue:c,onChange:d,countryCode:u,defaultCountryCode:m="+1",onCountryCodeChange:b,allowedCountryCodes:f,countryCodeOptions:g,countryCodePlaceholder:v="Codigo",countryCodeClassName:k="",countryCodeWidth:h=84,onPhoneValueChange:A,label:$,containerClassName:N="",helperText:T,helperDisplay:x="inline",labelAction:y,className:L="",required:w,disabled:W,floatingLabel:X,showPasswordToggle:Z,nativeValidation:D,errorTooltipLabel:Q="Error de validacion",...j}){var z;const[se,te]=o.useState(()=>Ds(c)),[ee,U]=o.useState(()=>On(m)),J=o.useMemo(()=>{const de=g??Ls,he=f==null?void 0:f.map(On);return he!=null&&he.length?de.filter(ie=>he.includes(ie.value)):de},[f,g]),ce=((z=J[0])==null?void 0:z.value)??"+1",C=J.some(de=>de.value===On(u??ee))?On(u??ee):ce,_=i!==void 0?Ds(i):se,ae=`${C} ${_}`.trim(),B=n&&_.length>0&&!Ua(ae)?a:void 0,I=l??B,E=!!I,oe=E&&s!=="tooltip",K=E&&s!=="inline",Y=!!T&&x==="tooltip"&&!oe,S=E?"border-[var(--danger)] focus-within:border-[var(--danger)]":"border-[var(--border)] focus-within:border-[var(--primary)]",H=de=>{const he=de.currentTarget.value;i===void 0&&te(he),A==null||A(he,{countryCode:C,nationalNumber:he,fullNumber:`${C} ${he}`.trim()}),d==null||d(de)},O=de=>{u===void 0&&U(de),b==null||b(de),A==null||A(_,{countryCode:de,nationalNumber:_,fullNumber:`${de} ${_}`.trim()})},re=K?t.jsx(Yt,{as:"span",content:I,className:"absolute right-2.5 top-1/2 flex h-7 w-7 -translate-y-1/2 items-center justify-center rounded-md text-[var(--danger)] outline-none transition-colors hover:bg-[var(--danger-bg)] focus-visible:bg-[var(--danger-bg)]",children:t.jsx("span",{tabIndex:0,role:"img","aria-label":Q,className:"flex h-full w-full items-center justify-center outline-none",children:t.jsx(ks,{className:"h-[18px] w-[18px]"})})}):null;return t.jsxs("div",{className:`flex flex-col gap-2 ${N}`,children:[t.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-semibold uppercase text-[var(--text-muted)]",children:[t.jsx("span",{children:$}),w&&t.jsx("span",{className:"text-[var(--danger)]",children:"*"}),Y?t.jsx(xr,{content:T}):null,y&&t.jsx("span",{className:"ml-auto normal-case",children:y})]}),t.jsxs("span",{className:`flex h-10 min-w-0 items-center overflow-hidden rounded-lg border bg-[var(--bg-input)] transition-colors ${S}`,children:[t.jsx(ar,{value:C,onChange:O,options:J,placeholder:v,disabled:W,ariaLabel:"Codigo telefonico",triggerVariant:"ghost",showSelectedSublabel:!1,searchable:!0,minOptionsForSearch:0,dropdownMinWidth:300,className:`shrink-0 ${k}`,style:{width:Qd(h)},height:38,padding:"0 8px 0 10px"}),t.jsx("span",{className:"h-5 w-px shrink-0 bg-[var(--border)]"}),t.jsxs("span",{className:"relative min-w-0 flex-1 self-stretch",children:[t.jsx("input",{...j,value:i,defaultValue:c,type:"tel",inputMode:r,autoComplete:e,disabled:W,required:void 0,"aria-label":j["aria-label"]??(typeof $=="string"?$:void 0),"aria-invalid":E||j["aria-invalid"],className:`h-full w-full min-w-0 bg-transparent px-2 py-1.5 text-sm text-[var(--text-main)] outline-none placeholder:text-[var(--text-muted)] disabled:cursor-not-allowed disabled:opacity-60 ${K?"pr-10":""} ${L}`,onChange:H}),re]})]}),t.jsx(wr,{error:oe?I:void 0,helperText:T,helperDisplay:x})]})}function Rd({value:e,onChange:r,options:n,name:a,label:s,orientation:l="vertical",disabled:i=!1,className:c="",optionClassName:d=""}){return t.jsxs("fieldset",{className:`min-w-0 ${c}`,disabled:i,children:[s&&t.jsx("legend",{className:"mb-2 text-xs font-semibold uppercase text-[var(--text-muted)]",children:s}),t.jsx("div",{className:l==="horizontal"?"flex flex-wrap gap-2":"flex flex-col gap-2",children:n.map(u=>{const m=u.value===e,b=i||u.disabled;return t.jsxs("label",{className:`inline-flex min-w-0 items-start gap-2 rounded-lg border px-2.5 py-1.5 transition-colors ${b?"cursor-not-allowed opacity-60":"cursor-pointer hover:bg-[var(--bg-input)]"} ${d}`,style:{borderColor:m?"color-mix(in srgb, var(--primary) 48%, var(--border))":"var(--border)",background:m?"color-mix(in srgb, var(--primary) 8%, transparent)":"var(--bg-card)"},children:[t.jsxs("span",{className:"relative mt-0.5 inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-full border border-[var(--border)] bg-[var(--bg-input)]",children:[t.jsx("input",{type:"radio",name:a,value:u.value,checked:m,disabled:b,onChange:()=>r(u.value),className:"absolute inset-0 opacity-0"}),t.jsx("span",{className:`h-2 w-2 rounded-full transition ${m?"scale-100 opacity-100":"scale-50 opacity-0"}`,style:{background:"var(--primary)"}})]}),t.jsxs("span",{className:"min-w-0",children:[t.jsx("span",{className:"block text-sm font-medium leading-5 text-[var(--text-main)]",children:u.label}),u.description&&t.jsx("span",{className:"block text-xs leading-5 text-[var(--text-muted)]",children:u.description})]})]},u.value)})})]})}const eu=new Set(["table","thead","tbody","tfoot","tr","th","td","caption"]),Hn=(e,r,n)=>Math.min(n,Math.max(r,Math.round(e)||r)),Sr=12,Bn=8,Ja=(e,r,n)=>{const a=Pn(n),s=e.insertRow(r);for(let l=0;l<a;l+=1){const i=s.insertCell(-1);i.innerHTML="<br>"}return s.cells[0]??null},Is=(e,r)=>{const n=e.rows[r];if(!n)return null;const a=n.parentElement;if(!a)return null;if(a.tagName==="THEAD"){const l=e.tBodies[0]??e.createTBody();return l.rows.length>=Sr?null:Ja(l,0,e)}if(a.tagName==="TBODY"&&a.rows.length>=Sr)return null;const s=Array.from(a.rows).indexOf(n);return Ja(a,s+1,e)},tu=(e,r)=>{var s;const n=e.rows[r];if(!n)return!1;const a=n.parentElement;return(a==null?void 0:a.tagName)==="TBODY"&&a.rows.length<=1||(a==null?void 0:a.tagName)==="THEAD"&&((s=e.tBodies[0])==null?void 0:s.rows.length)===0&&e.rows.length<=1?!1:(n.remove(),!0)},Os=(e,r)=>Pn(e)>=Bn?!1:(e.querySelectorAll("tr").forEach(n=>{const a=n.closest("thead")!==null,s=document.createElement(a?"th":"td");a?s.textContent=`Columna ${n.cells.length+1}`:s.innerHTML="<br>";const l=n.cells[r];l!=null&&l.nextSibling?n.insertBefore(s,l.nextSibling):n.appendChild(s)}),!0),ru=(e,r)=>Pn(e)<=1?!1:(e.querySelectorAll("tr").forEach(n=>{var a;(a=n.cells[r])==null||a.remove()}),!0),Hs=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")})},Bs=(e,r,n)=>{Hs(e),r&&(r.classList.add("rich-table-row-active"),e.querySelectorAll("tr").forEach(a=>{var s;(s=a.cells[n])==null||s.classList.add("rich-table-col-active")}))},nu=(e,r,n)=>{const a=e.getBoundingClientRect();return{rowIndex:Array.from(e.rows).indexOf(r),colIndex:n.cellIndex,bar:{x:a.left+a.width/2,y:a.top-6}}},Fn=e=>{const r=e.cloneNode(!0);return r.querySelectorAll(".rich-table-ui").forEach(n=>n.remove()),r.querySelectorAll(".rich-table-wrap").forEach(n=>{const a=n.querySelector("table");a?n.replaceWith(a):n.remove()}),r.querySelectorAll("table").forEach(n=>{n.classList.add("rich-table")}),r.querySelectorAll(".rich-table-row-active, .rich-table-col-active").forEach(n=>{n.classList.remove("rich-table-row-active","rich-table-col-active")}),r.innerHTML},Fs=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,s)=>{switch(e){case"table-delete":return r.remove(),!0;case"table-row-add":{const l=Number.isFinite(n)?Is(r,n):Ra(r);return l&&_n(l,s,!0),!!l}case"table-row-del":return Number.isFinite(n)?tu(r,n):!1;case"table-col-add":return Number.isFinite(a)?Os(r,a):iu(r);case"table-col-del":return Number.isFinite(a)?ru(r,a):!1;default:return!1}},Pn=e=>{let r=0;return e.querySelectorAll("tr").forEach(n=>{r=Math.max(r,n.cells.length)}),r||1},ou=e=>{const r=e.tBodies[0]??e.createTBody();return Array.from(r.rows)},Ps=e=>(e==null?void 0:e.closest("table"))??null,_s=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},su=e=>Array.from(e.querySelectorAll("th, td")),zs=(e,r)=>{if(e.closest("thead"))return!1;const n=e.closest("tbody")??r.tBodies[0];if(!n)return!1;const a=Array.from(n.rows),s=e.closest("tr");return!s||s!==a[a.length-1]?!1:e===s.cells[s.cells.length-1]},lu=e=>{const r=window.getSelection();if(!r||!r.isCollapsed||r.rangeCount===0)return!1;const n=r.getRangeAt(0);if(!e.contains(n.startContainer))return!1;const a=n.cloneRange();return a.selectNodeContents(e),a.setStart(n.endContainer,n.endOffset),a.toString().trim()===""},_n=(e,r,n=!0)=>{r==null||r.focus();const a=document.createRange();a.selectNodeContents(e),a.collapse(n);const s=window.getSelection();s==null||s.removeAllRanges(),s==null||s.addRange(a)},Ra=e=>{const r=ou(e);if(r.length>=Sr)return null;const n=r[r.length-1];if(!n){const a=e.tBodies[0]??e.createTBody();return Ja(a,0,e)}return Is(e,Array.from(e.rows).indexOf(n))},iu=e=>{const r=Pn(e)-1;return r<0?!1:Os(e,r)},eo=e=>{Fs(e)},cu=(e,r,n)=>{const a=Hn(e,1,Sr),s=Hn(r,1,Bn),l=n?`<thead><tr>${Array.from({length:s},(c,d)=>`<th>Columna ${d+1}</th>`).join("")}</tr></thead>`:"",i=Array.from({length:a},()=>`<tr>${Array.from({length:s},()=>"<td><br></td>").join("")}</tr>`).join("");return`<table class="rich-table">${l}<tbody>${i}</tbody></table><p><br></p>`},Ws=()=>'<button type="button" class="rich-img-del" data-action="delete-img" title="Eliminar imagen"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor"><path fill-rule="evenodd" d="M9 2a1 1 0 0 0-.894.553L7.382 4H4a1 1 0 0 0 0 2v10a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V6a1 1 0 0 0 0-2h-3.382l-.724-1.447A1 1 0 0 0 11 2H9zm-1 6a1 1 0 1 1 2 0v4a1 1 0 1 1-2 0V8zm4 0a1 1 0 1 1 2 0v4a1 1 0 1 1-2 0V8z" clip-rule="evenodd"/></svg></button>',rn=e=>e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'"),js=e=>e.toLocaleLowerCase().replace(new RegExp("(^|[^\\p{L}\\p{N}])(\\p{L})","gu"),(r,n,a)=>`${n}${a.toLocaleUpperCase()}`),du=e=>e.replace(/[<>]/g,"").toLowerCase(),uu=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]+/,bu=e=>{const r=e.indexOf("<!--StartFragment-->"),n=e.indexOf("<!--EndFragment-->");if(r!==-1&&n!==-1&&n>r)return e.slice(r+20,n);const a=e.match(/<body[^>]*>([\s\S]*)<\/body>/i);return a?a[1]:e},zn=(e,r)=>r.test(e),mu=e=>zn(e,/font-weight\s*:\s*(bold|[6-9]00)/i),pu=e=>zn(e,/font-style\s*:\s*italic/i),hu=e=>zn(e,/text-decoration(?:-line)?\s*:[^;]*underline/i),gu=e=>zn(e,/text-decoration(?:-line)?\s*:[^;]*(line-through|linethrough)/i),Wn=(e,r)=>{var a;if(!e.childNodes.length||e.childNodes.length===1&&((a=e.firstChild)==null?void 0:a.nodeType)===Node.ELEMENT_NODE&&e.firstChild.tagName.toLowerCase()===r)return;const n=e.ownerDocument.createElement(r);for(;e.firstChild;)n.appendChild(e.firstChild);e.appendChild(n)},jn=e=>{const r=e.parentNode;if(!r){e.remove();return}for(;e.firstChild;)r.insertBefore(e.firstChild,e);r.removeChild(e)},vu=e=>{const r=e.getAttribute("class")??"",n=e.getAttribute("style")??"";return/mso-list/i.test(n)||/MsoListParagraph/i.test(r)||/MsoList/i.test(r)},qs=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"},yu=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)},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&&(mu(a)&&Wn(n,"strong"),pu(a)&&Wn(n,"em"),hu(a)&&Wn(n,"u"),gu(a)&&Wn(n,"s"))})},wu=e=>{const r=Array.from(e.querySelectorAll("p, div")).filter(vu);if(!r.length)return;let n=0;for(;n<r.length;){const a=r[n],s=qs(a),l=[a];let i=n+1;for(;i<r.length;){const u=r[i];if(qs(u)!==s)break;let m=l[l.length-1].nextSibling;for(;m&&m.nodeType===Node.TEXT_NODE&&!(m.textContent??"").trim();)m=m.nextSibling;if(m!==u)break;l.push(u),i++}const c=a.parentNode;if(!c){n=i;continue}const d=a.ownerDocument.createElement(s);c.insertBefore(d,a),l.forEach(u=>{yu(u);const m=u.ownerDocument.createElement("li");for(;u.firstChild;)m.appendChild(u.firstChild);d.appendChild(m),u.remove()}),n=i}},Nu=e=>e==="h1"?"h2":e==="h4"||e==="h5"||e==="h6"?"h3":e==="div"?"p":e,ku=e=>{const r=bu(e.replace(/<!--\[if[\s\S]*?<!\[endif\]-->/gi,"").replace(/<xml[\s\S]*?<\/xml>/gi,"").replace(/<style[\s\S]*?<\/style>/gi,"").replace(/<\/?o:[^>]*>/gi,"").replace(/<\/?w:[^>]*>/gi,"").replace(/<\/?m:[^>]*>/gi,"")),s=new DOMParser().parseFromString(`<!DOCTYPE html><html><body>${r}</body></html>`,"text/html").body;s.querySelectorAll("script, style, meta, link, xml, title, head, iframe, object, embed, form, input, button, textarea, select, noscript").forEach(i=>i.remove()),xu(s),wu(s);const l=i=>{const c=Array.from(i.childNodes);if(i.nodeType===Node.ELEMENT_NODE){const d=i,u=d.tagName.toLowerCase();if(u==="html"||u==="body"){c.forEach(l);return}if(u==="font"){jn(d),c.forEach(l);return}if(!uu.has(u)){jn(d),c.forEach(l);return}if(u==="div"){const b=d.getAttribute("class")??"";if(/rich-table-wrap/.test(b)){Array.from(d.attributes).forEach(f=>{f.name.toLowerCase()!=="class"&&d.removeAttribute(f.name)}),d.className="rich-table-wrap",c.forEach(l);return}}const m=Nu(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){jn(d),c.forEach(l);return}d.setAttribute("target","_blank"),d.setAttribute("rel","noopener noreferrer"),d.classList.add("rich-link")}if(u==="img"){const b=d.getAttribute("src")??"";if(!b||/^\s*javascript:/i.test(b)||/^file:/i.test(b)||/scheme\s*=\s*["']?file/i.test(b)){d.remove();return}d.classList.add("rich-img"),Array.from(d.attributes).forEach(f=>{["src","alt","class"].includes(f.name.toLowerCase())||d.removeAttribute(f.name)})}if(u==="span"){jn(d),c.forEach(l);return}}c.forEach(l)};return l(s),s.querySelectorAll("p, h2, h3, li").forEach(i=>{const c=(i.textContent??"").replace(/[\u00a0\s]+/g,"").trim(),d=i.querySelector("img, hr"),u=!c&&!d&&Array.from(i.childNodes).every(m=>m.nodeType===Node.TEXT_NODE||m.nodeType===Node.ELEMENT_NODE&&m.tagName.toLowerCase()==="br");(!c&&!d||u)&&i.remove()}),s.querySelectorAll("strong, b, em, i, u, s").forEach(i=>{let c=i.nextSibling;for(;c&&c.nodeType===Node.TEXT_NODE&&!(c.textContent??"").trim();)c=c.nextSibling;if(c&&c.nodeType===Node.ELEMENT_NODE&&c.tagName===i.tagName){const d=c;for(;d.firstChild;)i.appendChild(d.firstChild);d.remove()}}),s.innerHTML.replace(/<!--[\s\S]*?-->/g,"").replace(/ /gi," ").replace(/(<br\s*\/?>\s*){3,}/gi,"<br><br>").replace(/<p>(?:\s|<br\s*\/?>)*<\/p>/gi,"").trim()},to=e=>rn(e).replace(/\r\n?/g,`
|
|
25
|
+
`).split(/\n{2,}/).map(r=>`<p>${r.replace(/\n/g,"<br>")||"<br>"}</p>`).join(""),Su=e=>new RegExp("\\p{L}","u").test(e),ro=(e,r)=>{const n=e.trim();return!n||!Su(n)?!1:r==="uppercase"?n===n.toLocaleUpperCase():r==="lowercase"?n===n.toLocaleLowerCase():n===js(n)},Us=e=>{const r=a=>{var s,l;if(!a.closest(".rich-img-wrap")){const i=document.createElement("span");i.className="rich-img-wrap",i.contentEditable="false",(s=a.parentNode)==null||s.insertBefore(i,a),i.appendChild(a),i.insertAdjacentHTML("beforeend",Ws())}(l=a.closest(".rich-img-wrap"))==null||l.classList.add("rich-img-broken")};e.querySelectorAll("img").forEach(a=>{if(!a.complete||a.naturalWidth===0){a.addEventListener("error",()=>r(a),{once:!0}),a.addEventListener("load",()=>{a.naturalWidth===0&&r(a)},{once:!0});const s=a.src;a.src="",a.src=s}});const n=a=>{const s=a.target;s.tagName==="IMG"&&r(s)};return e.addEventListener("error",n,!0),()=>e.removeEventListener("error",n,!0)};function Vs({value:e,onChange:r,placeholder:n="Escribe algo...",minHeight:a="80px",instanceId:s}){const l=o.useId(),i=s||l,c=o.useCallback(()=>document,[]),d=o.useRef(null),u=o.useRef(null),m=o.useRef(new Map),b=o.useRef(null),f=o.useRef(!1),g=o.useRef(e??""),v=o.useRef(r),k=o.useRef(()=>{}),h=o.useRef(!1),[A,$]=o.useState(()=>!e||e.trim()===""),[N,T]=o.useState(new Set),[x,y]=o.useState(null),[L,w]=o.useState(""),[W,X]=o.useState(""),[Z,D]=o.useState(""),[Q,j]=o.useState(""),[se,te]=o.useState(3),[ee,U]=o.useState(3),[J,ce]=o.useState(!0),[C,_]=o.useState(!1),[ae,B]=o.useState(null),[I,E]=o.useState(null),oe=o.useRef(null),K=o.useRef(!1),Y=o.useRef(null),S=o.useCallback(()=>f.current?u.current:d.current,[]);o.useEffect(()=>{v.current=r},[r]);const H=o.useCallback(()=>{const F=window.getSelection(),G=S();if(!F||!G||F.rangeCount===0||F.isCollapsed)return"";const fe=F.getRangeAt(0);return!G.contains(fe.startContainer)||!G.contains(fe.endContainer)?"":F.toString()},[S]);o.useEffect(()=>{const F=e??"";if(h.current&&F===g.current){h.current=!1,$(!F||F.trim()==="");return}h.current=!1,g.current=F;const G=[d.current,u.current].filter(be=>!!be);G.forEach(be=>{be.innerHTML!==F&&(be.innerHTML=F)}),$(!F||F.trim()===""),G.forEach(be=>eo(be));const fe=G.map(be=>Us(be));return()=>fe.forEach(be=>be())},[e]),o.useEffect(()=>{var be,Te;f.current=C;let F,G=0,fe;if(C){const ye=d.current;ye&&(g.current=Fn(ye));const Be=()=>{var Ye;const De=u.current;if(!De){G=requestAnimationFrame(Be);return}De.innerHTML!==g.current&&(De.innerHTML=g.current),F=Us(De),eo(De),$(((Ye=De.textContent)==null?void 0:Ye.trim())===""),fe=setTimeout(()=>De.focus(),60)};G=requestAnimationFrame(Be)}else{const ye=u.current,Be=d.current,De=ye?Fn(ye):g.current,Ye=g.current;g.current=De,Be&&Be.innerHTML!==De&&(Be.innerHTML=De),De!==Ye&&v.current(De),$(((Te=(be=ye??Be)==null?void 0:be.textContent)==null?void 0:Te.trim())==="")}return()=>{G&&cancelAnimationFrame(G),fe&&clearTimeout(fe),F==null||F()}},[C]);const O=o.useCallback(()=>{const F=["bold","italic","underline","strikeThrough","insertUnorderedList","insertOrderedList","justifyLeft","justifyCenter","justifyRight","justifyFull"],G=new Set;F.forEach(be=>{try{c().queryCommandState(be)&&G.add(be)}catch{return}});try{const be=du(c().queryCommandValue("formatBlock"));be&&G.add(`formatBlock:${be}`)}catch{}const fe=H();ro(fe,"uppercase")&&G.add("__upper"),ro(fe,"lowercase")&&G.add("__lower"),ro(fe,"capitalize")&&G.add("__cap"),T(G)},[H,c]),re=()=>{var G;const F=S();F&&(g.current=Fn(F),h.current=!0,v.current(g.current),$(((G=F.textContent)==null?void 0:G.trim())===""))};k.current=re;const z=o.useCallback(()=>{Y.current&&(clearTimeout(Y.current),Y.current=null),oe.current&&(Hs(oe.current),oe.current=null),K.current=!1,B(null),E(null)},[]),de=o.useCallback(()=>{Y.current&&(clearTimeout(Y.current),Y.current=null)},[]),he=o.useCallback(()=>{de(),Y.current=setTimeout(()=>{K.current||z()},280)},[de,z]);o.useEffect(()=>()=>{Y.current&&clearTimeout(Y.current)},[]);const ie=o.useCallback(F=>{const G=oe.current;if(!G||!G.isConnected){z();return}const fe=(ae==null?void 0:ae.rowIndex)??(I==null?void 0:I.rowIndex)??-1,be=(ae==null?void 0:ae.colIndex)??(I==null?void 0:I.colIndex)??-1;au(F,G,fe,be,S()),z(),k.current(),O()},[S,z,O,I,ae]),ge=o.useCallback(F=>{if(I)return;const G=F.currentTarget,fe=F.target;if(fe.closest(".rich-table-action-bar, .rich-table-context-menu")){de();return}const be=fe.closest("td, th");if(!be||!G.contains(be)){he();return}const Te=be.closest("tr"),ye=be.closest("table");if(!Te||!ye||!G.contains(ye)){he();return}de(),ye.classList.add("rich-table"),oe.current=ye,Bs(ye,Te,be.cellIndex),B(nu(ye,Te,be))},[de,he,I]),Me=o.useCallback(F=>{const G=F.relatedTarget;if(G instanceof Element&&(G.closest(".rich-table-action-bar")||G.closest(".rich-table-context-menu"))){de();return}he()},[de,he]),$e=o.useCallback(F=>{const G=F.currentTarget,be=F.target.closest("td, th");if(!be||!G.contains(be))return;const Te=be.closest("tr"),ye=be.closest("table");if(!Te||!ye||!G.contains(ye))return;F.preventDefault(),ye.classList.add("rich-table"),oe.current=ye;const Be=Array.from(ye.rows).indexOf(Te),De=be.cellIndex;Bs(ye,Te,De),B(null),E({x:F.clientX,y:F.clientY,rowIndex:Be,colIndex:De})},[]);o.useEffect(()=>{if(!ae&&!I)return;const F=()=>he();return window.addEventListener("scroll",F,!0),window.addEventListener("resize",F),()=>{window.removeEventListener("scroll",F,!0),window.removeEventListener("resize",F)}},[he,I,ae]),o.useEffect(()=>{if(!I)return;const F=G=>{const fe=G.target;fe instanceof Element&&fe.closest(".rich-table-context-menu")||E(null)};return window.addEventListener("mousedown",F),()=>window.removeEventListener("mousedown",F)},[I]);const Dt=F=>{if(!F){const G=d.current;G&&(g.current=Fn(G))}_(!F)},ut=(F,G)=>{var fe;(fe=S())==null||fe.focus(),c().execCommand(F,!1,G),re(),O()},Re=F=>{ut("formatBlock",F)},It=()=>{var F;(F=S())==null||F.focus(),c().execCommand("insertHTML",!1,"<hr><p><br></p>"),re(),O()},Ct=()=>{const F=window.getSelection();F&&F.rangeCount>0&&(b.current=F.getRangeAt(0).cloneRange())},Et=()=>{const F=window.getSelection();F&&b.current&&(F.removeAllRanges(),F.addRange(b.current))},le=F=>{if(Ct(),F==="link"){const G=window.getSelection();X(G&&!G.isCollapsed?G.toString():""),w("")}F==="image"&&(D(""),j("")),F==="table"&&(te(3),U(3),ce(!0)),y(F)},Fe=()=>{var be;if(!L.trim())return;Et(),(be=S())==null||be.focus();const F=window.getSelection(),fe=(F&&!F.isCollapsed?F.toString():"")||W.trim()||L.trim();c().execCommand("insertHTML",!1,`<a href="${rn(L.trim())}" target="_blank" rel="noopener noreferrer" class="rich-link">${rn(fe)}</a>`),re(),y(null)},ze=(F,G="")=>`<span class="rich-img-wrap" contenteditable="false"><img src="${rn(F)}" alt="${rn(G)}" class="rich-img" />${Ws()}</span>`,ft=()=>{var F;Z.trim()&&(Et(),(F=S())==null||F.focus(),c().execCommand("insertHTML",!1,ze(Z.trim(),Q.trim())),re(),y(null))},Ve=()=>{var F;Et(),(F=S())==null||F.focus(),c().execCommand("insertHTML",!1,cu(se,ee,J)),re(),y(null)},Mt=(F,G=1200,fe=1200,be=.72)=>new Promise((Te,ye)=>{const Be=new FileReader;Be.onerror=ye,Be.onload=De=>{var Ot;const Ye=(Ot=De.target)==null?void 0:Ot.result,Ze=new Image;Ze.onerror=ye,Ze.onload=()=>{let{width:ot,height:it}=Ze;if(ot>G||it>fe){const fn=Math.min(G/ot,fe/it);ot=Math.round(ot*fn),it=Math.round(it*fn)}const cr=document.createElement("canvas");cr.width=ot,cr.height=it;const qt=cr.getContext("2d");if(!qt){Te(Ye);return}qt.drawImage(Ze,0,0,ot,it),Te(cr.toDataURL("image/jpeg",be))},Ze.src=Ye},Be.readAsDataURL(F)}),bt=F=>{F.focus();const G=window.getSelection();if(!G||G.rangeCount===0||!F.contains(G.anchorNode)){const fe=document.createRange();fe.selectNodeContents(F),fe.collapse(!1),G==null||G.removeAllRanges(),G==null||G.addRange(fe)}},rt=o.useRef(()=>{});rt.current=F=>{const G=S();G&&(bt(G),c().execCommand("insertHTML",!1,F),eo(G),G.querySelectorAll("p").forEach(fe=>{!(fe.textContent??"").replace(/[\u00a0\s]+/g,"")&&!fe.querySelector("img, hr, table")&&fe.remove()}),re(),O())};const Wt=o.useRef(Mt);Wt.current=Mt;const ue=o.useRef(ze);ue.current=ze;const pe=o.useCallback(F=>{if(!F||m.current.has(F))return;const G=fe=>{const be=fe.clipboardData;if(!be)return;const Te=be.getData("text/html"),ye=be.getData("text/plain");if(Te||ye){fe.preventDefault(),fe.stopPropagation();try{const Ze=Te?ku(Te):to(ye);if(!Ze){ye&&rt.current(to(ye));return}rt.current(Ze)}catch{ye&&rt.current(to(ye))}return}const De=Array.from(be.items).find(Ze=>Ze.type.startsWith("image/"));if(!De)return;fe.preventDefault(),fe.stopPropagation();const Ye=De.getAsFile();Ye&&Wt.current(Ye).then(Ze=>{rt.current(ue.current(Ze,"imagen"))})};F.addEventListener("paste",G,!0),m.current.set(F,()=>{F.removeEventListener("paste",G,!0),m.current.delete(F)})},[]),Le=o.useCallback(F=>{var fe;const G=d.current;G&&G!==F&&((fe=m.current.get(G))==null||fe()),d.current=F,F&&pe(F)},[pe]),He=o.useCallback(F=>{var fe;const G=u.current;G&&G!==F&&((fe=m.current.get(G))==null||fe()),u.current=F,F&&pe(F)},[pe]);o.useEffect(()=>{const F=m.current;return()=>{F.forEach(G=>G()),F.clear()}},[]);const Ie=F=>{const G=window.getSelection(),fe=S();if(!G||!fe||G.rangeCount===0||G.isCollapsed)return;const be=G.getRangeAt(0);if(!fe.contains(be.startContainer)||!fe.contains(be.endContainer))return;const Te=be.toString();if(!Te)return;let ye=Te;F==="uppercase"?ye=Te.toLocaleUpperCase():F==="lowercase"?ye=Te.toLocaleLowerCase():ye=js(Te),be.deleteContents();const Be=document.createTextNode(ye);be.insertNode(Be);const De=document.createRange();De.setStart(Be,0),De.setEnd(Be,ye.length),G.removeAllRanges(),G.addRange(De),b.current=De.cloneRange(),re(),O()},tt=()=>{Ct(),O()},at=()=>{const F=S();F&&Fs(F),re(),O()},We=()=>{requestAnimationFrame(()=>{var F;(F=S())==null||F.focus()})},Ke=F=>{var G,fe;if((F.metaKey||F.ctrlKey)&&F.key==="Enter"){if(F.preventDefault(),F.stopPropagation(),F.repeat)return;(G=S())==null||G.focus(),c().execCommand("insertLineBreak",!1)||c().execCommand("insertHTML",!1,"<br>"),re(),O();return}if(F.key==="Tab"){const be=window.getSelection(),Te=_s((be==null?void 0:be.anchorNode)??null),ye=S(),Be=Ps(Te);if(Te&&Be&&(ye!=null&&ye.contains(Te))){F.preventDefault();const De=su(Be),Ye=De.indexOf(Te),Ze=Ye>=0?De[Ye+1]:null;if(Ze)_n(Ze,ye,!0);else if(zs(Te,Be)){const Ot=Ra(Be);Ot&&_n(Ot,ye,!0)}re(),O();return}F.preventDefault(),(fe=S())==null||fe.focus(),c().execCommand("insertText",!1," "),re(),O();return}if(F.key==="Enter"&&!F.shiftKey&&!(F.metaKey||F.ctrlKey)){const be=window.getSelection(),Te=_s((be==null?void 0:be.anchorNode)??null),ye=S(),Be=Ps(Te);if(Te&&Be&&(ye!=null&&ye.contains(Te))&&zs(Te,Be)&&lu(Te)){F.preventDefault();const De=Ra(Be);De&&_n(De,ye,!0),re(),O();return}}if(F.key==="Escape"){if(I){E(null);return}if(x){y(null);return}if(f.current){_(!1);return}}x||(F.ctrlKey||F.metaKey)&&(F.key==="b"&&(F.preventDefault(),ut("bold")),F.key==="i"&&(F.preventDefault(),ut("italic")),F.key==="u"&&(F.preventDefault(),ut("underline")),F.key==="k"&&(F.preventDefault(),le("link")))},Ge=()=>t.jsx("div",{className:"h-4 w-px flex-shrink-0 mx-1",style:{background:"var(--border)"}}),Ae=(F,G,fe,be,Te)=>{const ye=Te??(N.has(fe)||fe==="__link"&&x==="link"||fe==="__img"&&x==="image"||fe==="__table"&&x==="table");return t.jsx("button",{type:"button",title:G,tabIndex:-1,onFocus:We,onMouseDown:Be=>{Be.preventDefault(),be?be():ut(fe)},className:"flex h-7 w-7 items-center justify-center rounded text-xs font-bold transition-colors",style:{color:ye?"var(--primary)":"var(--text-secondary)",background:ye?"rgba(59,130,246,0.12)":"transparent"},children:F},fe)},lr=F=>{const G=F.target;if(G.closest("[data-action='delete-img']")){F.preventDefault();const fe=G.closest(".rich-img-wrap");fe&&(fe.remove(),re())}},ir=()=>{de(),K.current=!0},Or=()=>{K.current=!1,he()},Jt=(F,G,fe,be=!1)=>t.jsx("button",{type:"button",className:`rich-table-action-btn${be?" rich-table-action-btn--danger":""}`,title:F,"aria-label":F,onMouseDown:Te=>{Te.preventDefault(),Te.stopPropagation(),ie(fe)},children:G}),oa=()=>typeof document>"u"||!ae&&!I?null:ct.createPortal(t.jsxs(t.Fragment,{children:[ae&&!I&&t.jsxs("div",{className:"rich-table-action-bar",style:{left:ae.bar.x,top:ae.bar.y},onMouseEnter:ir,onMouseLeave:Or,children:[t.jsxs("span",{className:"rich-table-action-hint",children:["Fila ",ae.rowIndex+1," · Col ",ae.colIndex+1]}),t.jsxs("div",{className:"rich-table-action-group",children:[t.jsx("span",{className:"rich-table-action-label",children:"Fila"}),Jt("Añadir fila abajo","+","table-row-add"),Jt("Eliminar fila","−","table-row-del")]}),t.jsxs("div",{className:"rich-table-action-group",children:[t.jsx("span",{className:"rich-table-action-label",children:"Columna"}),Jt("Añadir columna a la derecha","+","table-col-add"),Jt("Eliminar columna","−","table-col-del")]}),Jt("Eliminar tabla","Eliminar","table-delete",!0)]}),I&&t.jsx("div",{className:"rich-table-context-menu",style:{left:I.x,top:I.y},onMouseDown:F=>F.stopPropagation(),children:[["Añadir fila abajo","table-row-add"],["Eliminar fila","table-row-del"],["Añadir columna a la derecha","table-col-add"],["Eliminar columna","table-col-del"],["Eliminar tabla","table-delete"]].map(([F,G])=>t.jsx("button",{type:"button",onMouseDown:fe=>{fe.preventDefault(),ie(G)},children:F},G))})]}),document.body),lt=F=>t.jsxs(t.Fragment,{children:[x==="link"&&t.jsxs("div",{className:"flex flex-shrink-0 flex-wrap items-center gap-2 border-t px-3 py-2",style:{borderColor:"var(--border)",background:F},children:[t.jsx("input",{autoFocus:!0,type:"url",value:L,onChange:G=>w(G.target.value),onKeyDown:G=>{G.key==="Enter"&&(G.preventDefault(),Fe()),G.key==="Escape"&&y(null)},placeholder:"https://...",className:"min-w-0 flex-1 rounded px-2 py-1 text-xs focus:outline-none",style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-main)"}}),t.jsx("input",{type:"text",value:W,onChange:G=>X(G.target.value),onKeyDown:G=>{G.key==="Enter"&&(G.preventDefault(),Fe()),G.key==="Escape"&&y(null)},placeholder:"Texto (opcional)",className:"w-32 rounded px-2 py-1 text-xs focus:outline-none",style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-main)"}}),t.jsx("button",{type:"button",onClick:Fe,className:"rounded px-2.5 py-1 text-xs font-semibold text-white",style:{background:"var(--primary)"},children:"OK"}),t.jsx("button",{type:"button",onClick:()=>y(null),className:"rounded px-2 py-1 text-xs",style:{color:"var(--text-muted)"},children:"x"})]}),x==="table"&&t.jsxs("div",{className:"flex flex-shrink-0 flex-wrap items-center gap-2 border-t px-3 py-2",style:{borderColor:"var(--border)",background:F},children:[t.jsxs("label",{className:"flex items-center gap-1 text-xs",style:{color:"var(--text-secondary)"},children:["Filas",t.jsx("input",{autoFocus:!0,type:"number",min:1,max:Sr,value:se,onChange:G=>te(Hn(Number(G.target.value),1,Sr)),onKeyDown:G=>{G.key==="Enter"&&(G.preventDefault(),Ve()),G.key==="Escape"&&y(null)},className:"w-14 rounded px-2 py-1 text-xs focus:outline-none",style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-main)"}})]}),t.jsxs("label",{className:"flex items-center gap-1 text-xs",style:{color:"var(--text-secondary)"},children:["Columnas",t.jsx("input",{type:"number",min:1,max:Bn,value:ee,onChange:G=>U(Hn(Number(G.target.value),1,Bn)),onKeyDown:G=>{G.key==="Enter"&&(G.preventDefault(),Ve()),G.key==="Escape"&&y(null)},className:"w-14 rounded px-2 py-1 text-xs focus:outline-none",style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-main)"}})]}),t.jsxs("label",{className:"flex items-center gap-1.5 text-xs",style:{color:"var(--text-secondary)"},children:[t.jsx("input",{type:"checkbox",checked:J,onChange:G=>ce(G.target.checked)}),"Encabezado"]}),t.jsx("button",{type:"button",onClick:Ve,className:"rounded px-2.5 py-1 text-xs font-semibold text-white",style:{background:"var(--primary)"},children:"OK"}),t.jsx("button",{type:"button",onClick:()=>y(null),className:"rounded px-2 py-1 text-xs",style:{color:"var(--text-muted)"},children:"x"})]}),x==="image"&&t.jsxs("div",{className:"flex flex-shrink-0 flex-wrap items-center gap-2 border-t px-3 py-2",style:{borderColor:"var(--border)",background:F},children:[t.jsx("input",{autoFocus:!0,type:"url",value:Z,onChange:G=>D(G.target.value),onKeyDown:G=>{G.key==="Enter"&&(G.preventDefault(),ft()),G.key==="Escape"&&y(null)},placeholder:"URL de la imagen...",className:"min-w-0 flex-1 rounded px-2 py-1 text-xs focus:outline-none",style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-main)"}}),t.jsx("input",{type:"text",value:Q,onChange:G=>j(G.target.value),onKeyDown:G=>{G.key==="Enter"&&(G.preventDefault(),ft()),G.key==="Escape"&&y(null)},placeholder:"Texto alt",className:"w-28 rounded px-2 py-1 text-xs focus:outline-none",style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-main)"}}),t.jsx("button",{type:"button",onClick:ft,className:"rounded px-2.5 py-1 text-xs font-semibold text-white",style:{background:"var(--primary)"},children:"OK"}),t.jsx("button",{type:"button",onClick:()=>y(null),className:"rounded px-2 py-1 text-xs",style:{color:"var(--text-muted)"},children:"x"})]})]}),jt=(F,G)=>t.jsxs("div",{className:"flex flex-shrink-0 flex-wrap items-center gap-0.5 border-t px-2 py-1",style:{borderColor:"var(--border)",background:G},children:[Ae(t.jsx(q.HiArrowUturnLeft,{className:"h-4 w-4"}),"Deshacer","undo"),Ae(t.jsx(q.HiArrowUturnRight,{className:"h-4 w-4"}),"Rehacer","redo"),Ge(),Ae(t.jsx("span",{style:{fontSize:"10px"},children:"P"}),"Parrafo","__paragraph",()=>Re("p"),N.has("formatBlock:p")||N.has("formatBlock:div")),Ae(t.jsx(q.HiH2,{className:"h-4 w-4"}),"Titulo 2","__h2",()=>Re("h2"),N.has("formatBlock:h2")),Ae(t.jsx(q.HiH3,{className:"h-4 w-4"}),"Titulo 3","__h3",()=>Re("h3"),N.has("formatBlock:h3")),Ae(t.jsx("span",{style:{fontSize:"13px",lineHeight:1},children:"“"}),"Cita","__quote",()=>Re("blockquote"),N.has("formatBlock:blockquote")),Ge(),Ae(t.jsx("b",{children:"B"}),"Negrita (Ctrl+B)","bold"),Ae(t.jsx("i",{children:"I"}),"Cursiva (Ctrl+I)","italic"),Ae(t.jsx("u",{children:"U"}),"Subrayado (Ctrl+U)","underline"),Ae(t.jsx("s",{children:"S"}),"Tachado","strikeThrough"),Ge(),Ae(t.jsx(q.HiListBullet,{className:"h-4 w-4"}),"Lista sin orden","insertUnorderedList"),Ae(t.jsx(q.HiNumberedList,{className:"h-4 w-4"}),"Lista numerada","insertOrderedList"),Ae(t.jsx(q.HiArrowTurnUpLeft,{className:"h-4 w-4"}),"Disminuir sangria","outdent"),Ae(t.jsx(q.HiArrowTurnDownRight,{className:"h-4 w-4"}),"Aumentar sangria","indent"),Ge(),Ae(t.jsx(q.HiBars3BottomLeft,{className:"h-4 w-4"}),"Alinear izquierda","justifyLeft"),Ae(t.jsx(q.HiBars3CenterLeft,{className:"h-4 w-4"}),"Centrar","justifyCenter"),Ae(t.jsx(q.HiBars3BottomRight,{className:"h-4 w-4"}),"Alinear derecha","justifyRight"),Ae(t.jsx(q.HiBars3,{className:"h-4 w-4"}),"Justificar","justifyFull"),Ge(),Ae(t.jsx("span",{style:{fontSize:"10px"},children:"AA"}),"Mayusculas","__upper",()=>Ie("uppercase")),Ae(t.jsx("span",{style:{fontSize:"10px"},children:"aa"}),"Minusculas","__lower",()=>Ie("lowercase")),Ae(t.jsx("span",{style:{fontSize:"10px"},children:"Aa"}),"Capitalizar","__cap",()=>Ie("capitalize")),Ge(),Ae(t.jsx(q.HiLink,{className:"h-4 w-4"}),"Insertar enlace (Ctrl+K)","__link",()=>le("link")),Ae(t.jsx(q.HiLinkSlash,{className:"h-4 w-4"}),"Quitar enlace","unlink"),Ae(t.jsx(q.HiPhoto,{className:"h-4 w-4"}),"Insertar imagen","__img",()=>le("image")),Ae(t.jsx(q.HiTableCells,{className:"h-4 w-4"}),"Insertar tabla","__table",()=>le("table")),Ae(t.jsx(q.HiMinus,{className:"h-4 w-4"}),"Insertar separador","__divider",It),Ge(),Ae(t.jsx(q.HiOutlinePaintBrush,{className:"h-4 w-4"}),"Limpiar formato","removeFormat"),Ae(t.jsx(q.HiNoSymbol,{className:"h-4 w-4"}),"Quitar bloque","__clearBlock",()=>Re("p")),Ge(),t.jsx("button",{type:"button",title:F?"Salir del modo de enfoque (Esc)":"Modo de enfoque",tabIndex:-1,onFocus:We,onMouseDown:fe=>{fe.preventDefault(),Dt(F)},className:"flex h-7 w-7 items-center justify-center rounded transition-colors",style:{color:"var(--text-secondary)"},children:F?t.jsx(q.HiArrowsPointingIn,{className:"h-4 w-4"}):t.jsx(q.HiArrowsPointingOut,{className:"h-4 w-4"})})]});return t.jsxs(t.Fragment,{children:[oa(),t.jsxs("div",{className:"overflow-hidden rounded-lg transition-all duration-150 ring-1 ring-transparent focus-within:ring-primary/30",style:{border:"1px solid var(--border)"},children:[t.jsx("div",{ref:Le,contentEditable:!0,suppressContentEditableWarning:!0,"data-bonsaif-rich-instance":i,onInput:at,onKeyDown:Ke,onKeyUp:tt,onSelect:tt,onMouseUp:tt,onMouseMove:ge,onMouseLeave:Me,onContextMenu:$e,onMouseDown:lr,"data-placeholder":n,className:`rich-editor px-3 py-2 text-sm focus:outline-none${A?" is-empty":""}`,style:{color:"var(--text-main)",background:"var(--bg-input)",minHeight:a,maxHeight:"320px",overflowY:"auto",lineHeight:"1.6"}}),lt("var(--bg-input)"),jt(!1,"var(--bg-input)")]}),t.jsxs(Oa,{open:C,onClose:()=>_(!1),title:"Modo de enfoque",subtitle:"Esc para salir",maxWidth:"920px",bodyClassName:"flex min-h-0 flex-col p-0",panelClassName:"h-[88vh]",backdropClassName:"bg-black/50 backdrop-blur-[2px]",children:[t.jsx("div",{ref:He,contentEditable:!0,suppressContentEditableWarning:!0,"data-bonsaif-rich-instance":i,onInput:at,onKeyDown:Ke,onKeyUp:tt,onSelect:tt,onMouseUp:tt,onMouseMove:ge,onMouseLeave:Me,onContextMenu:$e,onMouseDown:lr,"data-placeholder":n,className:`rich-editor min-h-0 flex-1 overflow-y-auto px-8 py-6 text-sm focus:outline-none${A?" is-empty":""}`,style:{color:"var(--text-main)",background:"var(--bg-card)",lineHeight:"1.75"}}),lt("var(--bg-input)"),jt(!0,"var(--bg-input)")]})]})}const Ys="[a-zA-Z0-9._@-]+",no=new RegExp(`@(${Ys})`,"g"),Cu=/[a-zA-Z0-9._@-]/,nn=new Set([" ",`
|
|
26
|
+
`," ","\r"," ","(","[","{",".",",",";",":","!","?","¿","¡",")","]","}",'"',"'","«","»","/","\\","|","-","—","–"]);function Xs(e,r){if(r<=0)return!0;const n=e[r-1]??"";return nn.has(n)}function Ks(e,r,n){var a;if(r<0||r>e.length)return null;for(let s=r-1;s>=0;s-=1){if(e[s]!=="@"){const c=e[s]??"";if(nn.has(c)||!Cu.test(c))return null;continue}if((a=n==null?void 0:n.isInsideExistingMention)!=null&&a.call(n,s)||!(n!=null&&n.isTriggerBoundary?n.isTriggerBoundary(s):Xs(e,s)))continue;const i=e.slice(s+1,r);return i.length>0&&!new RegExp(`^${Ys}$`).test(i)?null:{query:i,triggerIndex:s,caretIndex:r}}return null}function Gs(e,r){var a;const n=Cr(e,r);return n?!!((a=n.node.parentElement)!=null&&a.closest(".mention-chip")):!1}function Zs(e,r){if(r<=0)return!0;const n=Cr(e,r);if(!n){const s=co(e);return Xs(s,r)}if(n.offset>0){const s=n.node.data[n.offset-1]??"";return nn.has(s)}let a=n.node.previousSibling;for(;a;){if(a.nodeType===Node.TEXT_NODE){const s=a.textContent??"";if(s.length===0){a=a.previousSibling;continue}return nn.has(s[s.length-1]??"")}if(a.nodeType===Node.ELEMENT_NODE){const s=a;if(s.classList.contains("mention-chip")||s.tagName==="BR"||/^(P|DIV|LI|H[1-6]|BLOCKQUOTE)$/i.test(s.tagName))return!0;const l=s.textContent??"";if(l.length===0){a=a.previousSibling;continue}return nn.has(l[l.length-1]??"")}a=a.previousSibling}return!0}function ao(e,r){const n=co(e);return Ks(n,r,{isTriggerBoundary:a=>Zs(e,a),isInsideExistingMention:a=>Gs(e,a)})}function oo(e){return e.toLowerCase().trim()}function Qs(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 so(e){if(!e)return[];const r=new Set,n=[],a=d=>{const u=oo(d);!u||r.has(u)||(r.add(u),n.push(u))},s=/data-username\s*=\s*["']([^"']+)["']/gi;let l;for(;(l=s.exec(e))!==null;)a(l[1]??"");const i=
|
|
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
|
|
30
|
-
`)&&d(f)==="matched")return!0;if(f.nodeType===Node.TEXT_NODE)return u(f);if(f.nodeType!==Node.ELEMENT_NODE)return!1;const v=f;if(v.tagName==="BR")return i(v,0),d(v.nextSibling??void 0)==="matched";const k=Array.from(f.childNodes);for(let g=0;g<k.length;g+=1){const A=k[g],$=g>0&&A.nodeType===Node.ELEMENT_NODE&&el(A,e);if(m(A,$))return!0}return!1},b=Array.from(e.childNodes);for(let f=0;f<b.length;f+=1){const h=b[f],v=f>0&&h.nodeType===Node.ELEMENT_NODE&&el(h,e);if(m(h,v))break}if((r==null?void 0:r.locatePlain)===n.length&&!a){const f=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_TEXT);let h=f.nextNode(),v=h;for(;v;)h=v,v=f.nextNode();h&&(a={node:h,offset:h.data.length})}return{plain:n,locate:a,domOffset:s}}function io(e){return lo(e).plain}function Cr(e,r){return r<0?null:lo(e,{locatePlain:r}).locate??null}function qn(e,r,n){return e!==r&&!e.contains(r)?-1:lo(e,{domPoint:{container:r,offset:n}}).domOffset??-1}function tl(e,r){const{triggerIndex:n,caretIndex:a,username:s}=r;if(a<n)return null;const l=Cr(e,n),i=Cr(e,a);if(!l||!i)return null;const c=e.ownerDocument,d=c.createRange();d.setStart(l.node,l.offset),d.setEnd(i.node,i.offset),d.deleteContents();const u=Qs({name:r.display,username:s}),m=c.createElement("span");m.className="mention-chip",m.setAttribute("data-username",s.toLowerCase()),r.userId&&m.setAttribute("data-userid",String(r.userId)),m.contentEditable="false",m.textContent=u,m.title=`@${s}`;const b=c.createTextNode(" ");d.insertNode(b),d.insertNode(m);const f=c.defaultView,h=f==null?void 0:f.getSelection();if(h){const k=c.createRange();k.setStart(b,b.data.length),k.collapse(!0),h.removeAllRanges(),h.addRange(k)}const v=h!=null&&h.rangeCount?qn(e,h.getRangeAt(0).startContainer,h.getRangeAt(0).startOffset):n+u.length+1;return{caretPlainOffset:v>=0?v:n+u.length+1}}function rl(e,r){const n=e.ownerDocument,a=n.defaultView;if(!a)return;const s=a.getSelection();if(!s)return;const l=n.createRange(),i=Cr(e,r);i?(l.setStart(i.node,i.offset),l.collapse(!0)):(l.selectNodeContents(e),l.collapse(!1)),s.removeAllRanges(),s.addRange(l)}function Un(e){return e instanceof HTMLElement&&e.classList.contains("mention-chip")}function nl(e,r){let n=e;for(;n&&n.nodeType===Node.TEXT_NODE&&!(n.textContent??"").replace(/\u00a0/g," ").trim();)n=r==="prev"?n.previousSibling:n.nextSibling;return n}function al(e){var s;const r=e.ownerDocument,n=(s=r.defaultView)==null?void 0:s.getSelection();if(!n)return;const a=r.createRange();a.selectNode(e),n.removeAllRanges(),n.addRange(a),e.classList.add("is-selected")}function Er(e=document){var r;(r=e.querySelectorAll)==null||r.call(e,".mention-chip.is-selected").forEach(n=>{n.classList.remove("is-selected")})}function Vn(e){var a;const r=(a=e.ownerDocument.defaultView)==null?void 0:a.getSelection();e.querySelectorAll(".mention-chip").forEach(s=>{let l=!1;if(r&&r.rangeCount>0)try{const i=r.getRangeAt(0);(!r.isCollapsed&&i.intersectsNode(s)||r.isCollapsed&&i.startContainer===s&&i.endContainer===s)&&(l=!0)}catch{l=!1}s.classList.toggle("is-selected",l)})}function ol(e){var s;const r=e.ownerDocument,n=(s=r.defaultView)==null?void 0:s.getSelection();if(!n)return;const a=r.createRange();a.selectNodeContents(e),n.removeAllRanges(),n.addRange(a),Vn(e)}function sl(e){const r=e.cloneContents();return r.querySelectorAll(".mention-chip").forEach(n=>n.remove()),(r.textContent??"").replace(/\u00a0/g," ").trim().length>0}function ll(e){var a;const r=(a=e.ownerDocument.defaultView)==null?void 0:a.getSelection();if(!r||r.isCollapsed||r.rangeCount===0)return!1;const n=r.getRangeAt(0);return e.contains(n.commonAncestorContainer)?(n.deleteContents(),Er(e),!0):!1}function Yn(e){var m,b;const r=e.ownerDocument,n=e.parentNode;if(!n)return;const a=(f,h)=>{let v=f;for(;v&&v.nodeType===Node.TEXT_NODE&&(v.textContent??"")==="";){const k=v;v=v[h],k.remove()}return v},s=a(e.nextSibling,"nextSibling");if(s&&s.nodeType===Node.TEXT_NODE&&/^( |\u00a0)/.test(s.textContent??"")){const f=s;(f.data.length??0)<=1?f.remove():f.data=f.data.slice(1)}const l=a(e.previousSibling,"previousSibling"),i=n,c=Array.from(n.childNodes).indexOf(e);e.remove();const d=(m=r.defaultView)==null?void 0:m.getSelection();if(!d)return;const u=r.createRange();if(l)if(l.nodeType===Node.TEXT_NODE){const f=((b=l.textContent)==null?void 0:b.length)??0;u.setStart(l,f)}else u.setStartAfter(l);else i.childNodes[c]?u.setStart(i,c):(u.selectNodeContents(i),u.collapse(!1));u.collapse(!0),d.removeAllRanges(),d.addRange(u)}function il(e){var l;const r=(l=e.ownerDocument.defaultView)==null?void 0:l.getSelection();if(!r||!r.isCollapsed||r.rangeCount===0)return null;const n=r.getRangeAt(0);if(!e.contains(n.startContainer))return null;const{startContainer:a,startOffset:s}=n;if(a.nodeType===Node.TEXT_NODE){const i=a.textContent??"",c=nl(a.previousSibling,"prev");return Un(c)&&(s===0||s===1&&(i.charAt(0)===" "||i.charAt(0)===" "))?c:null}if(a.nodeType===Node.ELEMENT_NODE){const i=a.childNodes;let c=s-1;for(;c>=0;){const d=i[c];if(Un(d))return d;if(d.nodeType===Node.TEXT_NODE&&!(d.textContent??"").replace(/\u00a0/g," ").trim()){c-=1;continue}break}}return null}function cl(e){var l;const r=(l=e.ownerDocument.defaultView)==null?void 0:l.getSelection();if(!r||!r.isCollapsed||r.rangeCount===0)return null;const n=r.getRangeAt(0);if(!e.contains(n.startContainer))return null;const{startContainer:a,startOffset:s}=n;if(a.nodeType===Node.TEXT_NODE){const i=a.textContent??"";if(s>=i.length){const c=nl(a.nextSibling,"next");if(Un(c))return c}return null}if(a.nodeType===Node.ELEMENT_NODE){const i=a.childNodes;let c=s;for(;c<i.length;){const d=i[c];if(Un(d))return d;if(d.nodeType===Node.TEXT_NODE&&!(d.textContent??"").replace(/\u00a0/g," ").trim()){c+=1;continue}break}}return null}function co(e){var s;const r=(s=e.ownerDocument.defaultView)==null?void 0:s.getSelection();if(!r||r.isCollapsed||r.rangeCount===0)return[];const n=r.getRangeAt(0);return e.contains(n.commonAncestorContainer)?Array.from(e.querySelectorAll(".mention-chip")).filter(l=>{try{return n.intersectsNode(l)}catch{return!1}}):[]}const uo=280,Xn=6,dl=260,Tu=new Set(["ArrowDown","ArrowUp","Enter","Tab","Escape"]),ul=4,$u={position:"relative"},Au={position:"fixed",zIndex:11050,minWidth:dl,overflowY:"auto",background:"var(--bg-card, var(--bonsaif-ui-surface, #fff))",border:"1px solid var(--border, var(--bonsaif-ui-border, #d0d7de))",borderRadius:10,boxShadow:"0 12px 32px rgba(0,0,0,0.18)",padding:4},fl={padding:"10px 12px",fontSize:12,color:"var(--text-muted, #656d76)"};function Lu(e){return Array.from(document.querySelectorAll(`[data-bonsaif-rich-instance="${CSS.escape(e)}"]`))}function Du(e,r){const n=Math.max(8,Math.min(e.left,window.innerWidth-dl-8)),a=r==null?void 0:r.getBoundingClientRect(),s=a?Math.min(window.innerHeight-8,a.bottom):window.innerHeight-8,l=a?Math.max(8,a.top):8,i=s-e.bottom-Xn,c=e.top-l-Xn;return i<Math.min(uo,160)&&c>i?{left:n,bottom:window.innerHeight-e.top+Xn,maxHeight:Math.max(120,Math.min(uo,c))}:{left:n,top:e.bottom+Xn,maxHeight:Math.max(120,Math.min(uo,i))}}function bl({value:e,onChange:r,onSearchUsers:n,onMentionsChange:a,minHeight:s,placeholder:l,className:i,maxSuggestions:c=8,searchDebounceMs:d=140,highlightInEditor:u=!1,searchCacheKey:m=""}){const b=o.useId().replace(/:/g,""),f=o.useRef(null),h=o.useRef(null),v=o.useRef(new Map),k=o.useRef(n);k.current=n;const g=o.useRef(null),A=o.useRef(0),$=o.useRef([]),N=o.useRef(null),[T,x]=o.useState(null),[y,L]=o.useState([]),[w,W]=o.useState(0),[X,Z]=o.useState([]),[D,Q]=o.useState(!1),[j,se]=o.useState(!1);A.current=w,o.useEffect(()=>{se(!0)},[]);const te=(T==null?void 0:T.query)??null;o.useEffect(()=>{if(te===null){L([]);return}const I=te.trim(),M=`${m}|${I.toLowerCase()||"*"}`,oe=v.current.get(M);if(oe){L(oe),Q(!1),W(0);return}const K=new AbortController;Q(!0);const Y=window.setTimeout(()=>{(async()=>{try{const S=await k.current(I,{signal:K.signal,limit:c});if(K.signal.aborted)return;const H=Array.isArray(S)?S:[];v.current.set(M,H),L(H),W(0)}catch{K.signal.aborted||L([])}finally{K.signal.aborted||Q(!1)}})()},d);return()=>{K.abort(),window.clearTimeout(Y)}},[te,c,d,m]);const ee=o.useRef(a);ee.current=a,o.useEffect(()=>{var I;(I=ee.current)==null||I.call(ee,Js(X))},[X]);const U=o.useCallback(()=>{const I=Lu(b);if(I.length===0)return null;const M=window.getSelection();if(M!=null&&M.rangeCount){const K=M.getRangeAt(0).startContainer;for(const Y of I)if(Y.contains(K))return Y}const oe=document.activeElement;for(const K of I)if(oe===K||oe&&K.contains(oe))return K;for(const K of I)if(K.closest('[role="dialog"]'))return K;return I[0]??null},[b]),J=o.useCallback(()=>{const I=U(),M=window.getSelection();if(!I||!M||M.rangeCount===0){x(null);return}const oe=M.getRangeAt(0);if(!I.contains(oe.startContainer)){x(null);return}const K=qn(I,oe.startContainer,oe.startOffset);if(K<0){x(null);return}const Y=ao(I,K);if(!Y){x(null);return}const S=oe.getBoundingClientRect(),H=S.width===0&&S.height===0?(()=>{const re=document.createRange();return re.selectNodeContents(oe.startContainer),re.collapse(!0),re.getBoundingClientRect()})():S;g.current={query:Y.query,caretIndex:Y.caretIndex,triggerIndex:Y.triggerIndex};const O=Du(H,I);x(re=>{const z={query:Y.query,...O};return re&&re.query===z.query&&re.top===z.top&&re.bottom===z.bottom&&re.left===z.left&&re.maxHeight===z.maxHeight?re:z})},[U]),ce=o.useCallback(I=>{r(I),J()},[r,J]);o.useEffect(()=>{const I=M=>{if(Tu.has(M.key))return;const oe=U(),K=M.target;!oe||!K||!oe.contains(K)||J()};return document.addEventListener("keyup",I,!0),()=>document.removeEventListener("keyup",I,!0)},[U,J]);const C=o.useCallback(I=>{const M=U();if(!M)return;let oe=-1;const K=window.getSelection();if(K&&K.rangeCount>0){const re=K.getRangeAt(0);M.contains(re.startContainer)&&(oe=qn(M,re.startContainer,re.startOffset))}if(oe<0&&g.current&&(oe=g.current.caretIndex),oe<0)return;const Y=ao(M,oe);if(!Y)return;const S=tl(M,{triggerIndex:Y.triggerIndex,caretIndex:oe,username:I.username,display:I.name,userId:I.userId});if(!S)return;M.dispatchEvent(new InputEvent("input",{bubbles:!0,cancelable:!0}));const H={userId:I.userId,username:I.username,email:I.email??void 0,display:I.name??I.username};Z(re=>{const z=new Map(re.map(de=>[de.userId,de]));return z.set(H.userId,H),Array.from(z.values())}),x(null),g.current=null;const O=S.caretPlainOffset;requestAnimationFrame(()=>{requestAnimationFrame(()=>{var ie,ge;const re=U();if(!re)return;re.focus(),rl(re,O);const z=window.getSelection(),de=z==null?void 0:z.anchorNode,he=de instanceof Element?de.closest(".mention-chip"):(ie=de==null?void 0:de.parentElement)==null?void 0:ie.closest(".mention-chip");if(he!=null&&he.parentNode){const Me=document.createRange(),$e=he.nextSibling;$e&&$e.nodeType===Node.TEXT_NODE?Me.setStart($e,((ge=$e.textContent)==null?void 0:ge.length)??0):Me.setStartAfter(he),Me.collapse(!0),z==null||z.removeAllRanges(),z==null||z.addRange(Me)}})})},[U]);o.useEffect(()=>{const I=new Set(so(e).map(M=>M.toLowerCase()));Z(M=>{const oe=M.filter(K=>I.has(K.username.toLowerCase()));return oe.length===M.length?M:oe})},[e]),o.useEffect(()=>{if(!T)return;const I=M=>{const oe=M.target;if(!oe||f.current&&f.current.contains(oe)||h.current&&h.current.contains(oe))return;const K=U();K&&K.contains(oe)||x(null)};return document.addEventListener("mousedown",I),()=>{document.removeEventListener("mousedown",I)}},[T,U]);const _=o.useMemo(()=>y.slice(0,c),[y,c]);$.current=_,o.useEffect(()=>{if(!T)return;const I=M=>{const oe=U(),K=M.target;if(!oe||!K||!oe.contains(K))return;const Y=$.current;if(!(Y.length===0&&M.key!=="Escape"))if(M.key==="ArrowDown")M.preventDefault(),M.stopPropagation(),W(S=>(S+1)%Math.max(Y.length,1));else if(M.key==="ArrowUp")M.preventDefault(),M.stopPropagation(),W(S=>(S-1+Y.length)%Math.max(Y.length,1));else if(M.key==="Enter"||M.key==="Tab"){const S=Y[A.current];S&&(M.preventDefault(),M.stopPropagation(),C(S))}else M.key==="Escape"&&(M.preventDefault(),M.stopPropagation(),x(null))};return document.addEventListener("keydown",I,!0),()=>document.removeEventListener("keydown",I,!0)},[U,C,T]),o.useEffect(()=>{const I=H=>{H.dispatchEvent(new InputEvent("input",{bubbles:!0,cancelable:!0}))},M=H=>{const O=U(),re=H.target;if(!O||!re||!O.contains(re))return;if((H.metaKey||H.ctrlKey)&&H.key.toLowerCase()==="a"){H.preventDefault(),H.stopPropagation(),O.focus(),ol(O);return}if(H.key!=="Backspace"&&H.key!=="Delete")return;const z=window.getSelection();if(z&&!z.isCollapsed&&z.rangeCount>0){const ie=z.getRangeAt(0);if(O.contains(ie.commonAncestorContainer)&&co(O).length>0&&sl(ie)){H.preventDefault(),H.stopPropagation(),ll(O)&&I(O);return}}const de=co(O);if(de.length>0){H.preventDefault(),H.stopPropagation();for(const ie of de)Yn(ie);Er(O),I(O);return}if(H.key==="Backspace"){const ie=il(O);if(!ie)return;H.preventDefault(),H.stopPropagation(),Yn(ie),Er(O),I(O);return}const he=cl(O);he&&(H.preventDefault(),H.stopPropagation(),Yn(he),Er(O),I(O))},oe=H=>{const O=U();if(!O)return;const re=H.target;if(!(re instanceof Element)||!O.contains(re))return;const z=re.closest(".mention-chip");if(!(z instanceof HTMLElement)||!O.contains(z)){N.current=null,Er(O);return}H.shiftKey||H.button!==0||(N.current={chip:z,x:H.clientX,y:H.clientY})},K=H=>{const O=N.current;if(!O)return;const re=Math.abs(H.clientX-O.x),z=Math.abs(H.clientY-O.y);(re>ul||z>ul)&&(N.current=null)},Y=H=>{var he;const O=U(),re=N.current;if(N.current=null,!O||!re)return;const z=H.target;if(!(z instanceof Element)||!O.contains(z)||!((he=z.closest(".mention-chip"))!=null&&he.isSameNode(re.chip)))return;const de=window.getSelection();if(de){if(!de.isCollapsed){Vn(O);return}O.focus(),al(re.chip)}},S=()=>{const H=U();if(!H)return;const O=window.getSelection();!O||O.rangeCount===0||!O.anchorNode||!H.contains(O.anchorNode)||!O.focusNode||!H.contains(O.focusNode)||Vn(H)};return document.addEventListener("keydown",M,!0),document.addEventListener("mousedown",oe,!0),document.addEventListener("mousemove",K,!0),document.addEventListener("mouseup",Y,!0),document.addEventListener("selectionchange",S),()=>{document.removeEventListener("keydown",M,!0),document.removeEventListener("mousedown",oe,!0),document.removeEventListener("mousemove",K,!0),document.removeEventListener("mouseup",Y,!0),document.removeEventListener("selectionchange",S)}},[U]),o.useEffect(()=>{if(!T||!h.current)return;const I=h.current.querySelector(`[data-mention-index="${w}"]`);I==null||I.scrollIntoView({block:"nearest"})},[w,T]);const ae=u?Rs(e):e,B=T&&j?ct.createPortal(t.jsxs("ul",{ref:h,style:{...Au,left:T.left,top:T.top,bottom:T.bottom,maxHeight:T.maxHeight},role:"listbox","aria-label":"Menciones sugeridas",children:[D&&_.length===0&&t.jsx("li",{style:fl,children:"Buscando…"}),!D&&_.length===0&&t.jsx("li",{style:fl,children:T.query.trim().length===0?"Escribe un nombre o usuario":`Sin coincidencias para “${T.query}”`}),_.map((I,M)=>{var oe,K;return t.jsx("li",{children:t.jsxs("button",{type:"button","data-mention-index":M,onMouseDown:Y=>{Y.preventDefault(),C(I)},onMouseEnter:()=>W(M),style:{width:"100%",textAlign:"left",padding:"8px 10px",border:"none",background:M===w?"color-mix(in srgb, var(--primary, var(--bonsaif-ui-primary, #1f6feb)) 14%, transparent)":"transparent",color:"var(--text-main, var(--bonsaif-ui-text, #24292f))",borderRadius:6,cursor:"pointer",display:"flex",flexDirection:"column",gap:2},children:[t.jsx("span",{style:{fontWeight:600,fontSize:13},children:((oe=I.name)==null?void 0:oe.trim())||`@${I.username}`}),t.jsx("span",{style:{fontSize:11,color:"var(--text-muted, #656d76)"},children:[(K=I.name)!=null&&K.trim()?`@${I.username}`:null,I.email].filter(Boolean).join(" · ")||`@${I.username}`})]})},I.userId)})]}),document.body):null;return t.jsxs("div",{ref:f,style:$u,className:i,children:[t.jsx(Us,{value:ae,onChange:ce,placeholder:l,minHeight:s,instanceId:b}),B]})}function Iu({value:e,onChange:r,placeholder:n,minHeight:a,onSearchUsers:s,onMentionsChange:l,className:i,maxSuggestions:c,searchDebounceMs:d,highlightInEditor:u,searchCacheKey:m}){return s?t.jsx(bl,{value:e,onChange:r,onSearchUsers:s,onMentionsChange:l,placeholder:n,minHeight:a,className:i,maxSuggestions:c,searchDebounceMs:d,highlightInEditor:u,searchCacheKey:m}):t.jsx(Us,{value:e,onChange:r,placeholder:n,minHeight:a})}function Ou({title:e,subtitle:r,icon:n,actions:a,children:s,footer:l,className:i="",bodyClassName:c="p-4"}){const d=e||r||n||a;return t.jsxs("section",{className:`overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${i}`,children:[d&&t.jsxs("header",{className:"flex items-center justify-between gap-3 border-b border-[var(--border)] px-4 py-3",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[n&&t.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-input)] text-[var(--primary)]",children:n}),t.jsxs("div",{className:"min-w-0",children:[e&&t.jsx("h3",{className:"truncate text-sm font-semibold text-[var(--text-main)]",children:e}),r&&t.jsx("div",{className:"truncate text-xs text-[var(--text-muted)]",children:r})]})]}),a&&t.jsx("div",{className:"shrink-0",children:a})]}),t.jsx("div",{className:c,children:s}),l&&t.jsx("footer",{className:"border-t border-[var(--border)] px-4 py-3",children:l})]})}const Hu={neutral:{text:"var(--text-secondary)",bg:"var(--bg-input)",border:"var(--border)"},primary:{text:"var(--primary)",bg:"color-mix(in srgb, var(--primary) 10%, transparent)",border:"color-mix(in srgb, var(--primary) 24%, var(--border))"},success:{text:"#047857",bg:"rgba(16, 185, 129, 0.11)",border:"rgba(16, 185, 129, 0.24)"},warning:{text:"#b45309",bg:"rgba(245, 158, 11, 0.12)",border:"rgba(245, 158, 11, 0.26)"},danger:{text:"var(--danger)",bg:"var(--danger-bg)",border:"color-mix(in srgb, var(--danger) 20%, var(--border))"},info:{text:"#2563eb",bg:"rgba(59, 130, 246, 0.11)",border:"rgba(59, 130, 246, 0.24)"}},Bu={xs:"min-h-5 px-1.5 text-[10px]",sm:"min-h-6 px-2 text-xs",md:"min-h-7 px-2.5 text-sm"};function Fu({children:e,tone:r="neutral",size:n="sm",icon:a,dot:s=!1,className:l=""}){const i=Hu[r];return t.jsxs("span",{className:`inline-flex max-w-full shrink-0 items-center gap-1.5 rounded-full border font-semibold leading-none ${Bu[n]} ${l}`,style:{color:i.text,background:i.bg,borderColor:i.border},children:[s&&t.jsx("span",{"aria-hidden":"true",className:"h-1.5 w-1.5 shrink-0 rounded-full",style:{background:i.text}}),a&&t.jsx("span",{className:"shrink-0",children:a}),t.jsx("span",{className:"min-w-0 truncate",children:e})]})}const ml={neutral:{color:"var(--text-secondary)",background:"var(--bg-input)"},primary:{color:"var(--primary)",background:"color-mix(in srgb, var(--primary) 10%, transparent)"},success:{color:"#047857",background:"rgba(16, 185, 129, 0.11)"},warning:{color:"#b45309",background:"rgba(245, 158, 11, 0.12)"},danger:{color:"var(--danger)",background:"var(--danger-bg)"},info:{color:"#2563eb",background:"rgba(59, 130, 246, 0.11)"}},Pu={xs:"min-h-5 px-1.5 pr-6 text-[10px]",sm:"min-h-6 px-2 pr-7 text-xs",md:"min-h-7 px-2.5 pr-8 text-sm"},_u={xs:"right-1 h-3 w-3",sm:"right-1.5 h-3 w-3",md:"right-2 h-3.5 w-3.5"},zu={xs:148,sm:164,md:184},Wu={xs:"px-2.5 py-1.5 text-xs",sm:"px-3 py-2 text-sm",md:"px-3.5 py-2.5 text-sm"};function ju({value:e,options:r,onChange:n,size:a="sm",disabled:s=!1,loading:l=!1,stopPropagation:i=!1,ariaLabel:c="Cambiar estado",title:d="Cambiar estado",className:u,selectClassName:m,menuClassName:b,optionClassName:f,spinnerClassName:h}){const[v,k]=o.useState(!1),[g,A]=o.useState(!1),[$,N]=o.useState(-1),[T,x]=o.useState({}),y=o.useRef(null),L=o.useRef(null),w=o.useRef(null),W=r.find(U=>U.value===e)??r[0],X={...W!=null&&W.tone?ml[W.tone]:void 0,...W==null?void 0:W.style},Z=s||l||r.length===0,D=U=>{i&&U.stopPropagation()},Q=o.useCallback(()=>{k(!1),N(-1)},[]),j=o.useCallback(()=>{const U=y.current;if(!U)return;const J=U.getBoundingClientRect(),ce=Math.max(J.width,zu[a]),C=Math.min(Math.max(r.length,1)*38+12,260),_=window.innerHeight-J.bottom,ae=_<C&&J.top>_,B=Math.min(Math.max(8,J.left+J.width/2-ce/2),window.innerWidth-ce-8);x({position:"fixed",left:B,top:ae?void 0:J.bottom+6,bottom:ae?window.innerHeight-J.top+6:void 0,width:ce,zIndex:9999})},[r.length,a]),se=o.useCallback(U=>{U.disabled||(n(U.value),Q())},[Q,n]);o.useEffect(()=>A(!0),[]),o.useEffect(()=>{if(!v)return;j();const U=r.findIndex(J=>J.value===e);N(U>=0?U:0)},[v,r,j,e]),o.useEffect(()=>{if(!v)return;function U(J){var C,_;const ce=J.target;!((C=y.current)!=null&&C.contains(ce))&&!((_=L.current)!=null&&_.contains(ce))&&Q()}return document.addEventListener("mousedown",U),()=>document.removeEventListener("mousedown",U)},[Q,v]),o.useEffect(()=>{if(v)return window.addEventListener("resize",j),window.addEventListener("scroll",j,!0),()=>{window.removeEventListener("resize",j),window.removeEventListener("scroll",j,!0)}},[v,j]),o.useEffect(()=>{if($<0||!w.current)return;const U=w.current.children[$];U==null||U.scrollIntoView({block:"nearest"})},[$]);function te(U){if(!Z){if(!v){["Enter"," ","ArrowDown","ArrowUp"].includes(U.key)&&(U.preventDefault(),k(!0));return}if(U.key==="Escape"){U.preventDefault(),Q();return}if(U.key==="ArrowDown"){U.preventDefault(),N(J=>Math.min(J+1,r.length-1));return}if(U.key==="ArrowUp"){U.preventDefault(),N(J=>Math.max(J-1,0));return}if(U.key==="Enter"||U.key===" "){U.preventDefault();const J=r[$];J&&se(J)}}}const ee=t.jsx("div",{ref:L,role:"listbox","aria-label":c,className:Vt("overflow-hidden rounded-xl border shadow-xl backdrop-blur-md",b),style:{...T,background:"color-mix(in srgb, var(--bg-card) 92%, transparent)",borderColor:"var(--border)",color:"var(--text-main)"},onClick:D,onMouseDown:D,onPointerDown:D,children:t.jsx("div",{ref:w,className:"max-h-64 overflow-y-auto p-1",style:{scrollbarWidth:"thin",scrollbarColor:"var(--border) transparent",overscrollBehavior:"contain"},children:r.map((U,J)=>{const ce=U.value===e,C=J===$,_={...U.tone?ml[U.tone]:void 0,...U.style};return t.jsxs("button",{type:"button",role:"option","aria-selected":ce,disabled:U.disabled,onMouseEnter:()=>!U.disabled&&N(J),onMouseDown:ae=>{ae.preventDefault(),se(U)},className:Vt("flex w-full items-center gap-2 rounded-lg font-medium text-left transition-colors disabled:cursor-not-allowed disabled:opacity-45",Wu[a],ce?U.className:void 0,f),style:{...ce?_:void 0,background:ce?_.background??"color-mix(in srgb, var(--primary) 12%, transparent)":C?"var(--bg-hover)":"transparent",color:ce?_.color??"var(--primary)":"var(--text-main)"},children:[t.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center",children:ce?t.jsx(q.HiCheck,{className:"h-4 w-4"}):null}),t.jsx("span",{className:"min-w-0 flex-1 truncate",children:U.label})]},U.value)})})});return t.jsxs("span",{ref:y,className:Vt("relative inline-flex shrink-0 items-center",u),onKeyDown:te,onClick:D,onPointerDown:D,children:[t.jsx("button",{type:"button",disabled:Z,"aria-label":c,"aria-haspopup":"listbox","aria-expanded":v,title:d,onClick:()=>!Z&&k(U=>!U),className:Vt("inline-flex items-center rounded-full border border-transparent font-medium leading-none outline-none transition-colors hover:border-current focus:border-current disabled:cursor-wait disabled:opacity-70",Pu[a],W==null?void 0:W.className,m),style:X,children:t.jsx("span",{className:"min-w-0 truncate",children:(W==null?void 0:W.label)??e})}),t.jsx(q.HiChevronDown,{"aria-hidden":"true",className:Vt("pointer-events-none absolute opacity-70 transition-transform",_u[a],v?"rotate-180":"rotate-0")}),l&&t.jsx("span",{"aria-hidden":"true",className:Vt("absolute -right-1 -top-1 h-2.5 w-2.5 rounded-full border border-current border-t-transparent animate-spin",h)}),v&&g&&ct.createPortal(ee,document.body)]})}function qu({tabs:e,activeTabId:r,defaultActiveTabId:n,onTabChange:a,ariaLabel:s="Pestanas",variant:l="underline",className:i="",listClassName:c="",panelClassName:d=""}){const u=e.find(v=>!v.disabled)??e[0],m=r??n??(u==null?void 0:u.id),b=e.find(v=>v.id===m)??u,f=v=>{v.disabled||a==null||a(v.id)},h=v=>{const k=e.filter(A=>!A.disabled);if(!k.length||!b)return;const g=k.findIndex(A=>A.id===b.id);(v.key==="ArrowRight"||v.key==="ArrowDown")&&(v.preventDefault(),f(k[(g+1)%k.length])),(v.key==="ArrowLeft"||v.key==="ArrowUp")&&(v.preventDefault(),f(k[(g-1+k.length)%k.length])),v.key==="Home"&&(v.preventDefault(),f(k[0])),v.key==="End"&&(v.preventDefault(),f(k[k.length-1]))};return t.jsxs("div",{className:i,children:[t.jsx("div",{role:"tablist","aria-label":s,onKeyDown:h,className:`flex min-w-0 gap-1 overflow-x-auto ${l==="underline"?"border-b border-[var(--border)]":"rounded-lg border border-[var(--border)] bg-[var(--bg-input)] p-1"} ${c}`,children:e.map(v=>{const k=v.id===(b==null?void 0:b.id);return t.jsxs("button",{type:"button",role:"tab","aria-selected":k,"aria-controls":`${v.id}-panel`,id:`${v.id}-tab`,disabled:v.disabled,tabIndex:k?0:-1,onClick:()=>f(v),className:`inline-flex min-h-8 shrink-0 items-center justify-center gap-1.5 whitespace-nowrap px-2.5 text-sm font-semibold transition-colors focus:outline-none disabled:cursor-not-allowed disabled:opacity-50 ${l==="underline"?"border-b-2":"rounded-md border"}`,style:{color:k?"var(--primary)":"var(--text-muted)",borderColor:k?"var(--primary)":"transparent",background:l==="pills"&&k?"var(--bg-card)":"transparent"},children:[v.icon&&t.jsx("span",{className:"shrink-0",children:v.icon}),t.jsx("span",{children:v.label}),v.badge&&t.jsx("span",{className:"shrink-0",children:v.badge})]},v.id)})}),(b==null?void 0:b.content)!==void 0&&t.jsx("div",{role:"tabpanel",id:`${b.id}-panel`,"aria-labelledby":`${b.id}-tab`,className:`pt-4 ${d}`,children:b.content})]})}function Gt(...e){return e.filter(Boolean).join(" ")}function Uu({steps:e,activeStepId:r,initialStepId:n,completedStepIds:a,defaultCompletedStepIds:s=[],onActiveStepChange:l,onCompletedStepIdsChange:i,onBlockedStep:c,allowBackNavigation:d=!0,showFooter:u=!0,previousLabel:m="Anterior",nextLabel:b="Siguiente",blockedNextLabel:f="Completa este paso",className:h="",headerClassName:v="",contentClassName:k="",footerClassName:g=""}){var K;const A=((K=e[0])==null?void 0:K.id)??"",[$,N]=o.useState(n??A),[T,x]=o.useState(s),y=r??$,L=a??T,w=o.useMemo(()=>new Set(L),[L]),W=Math.max(0,e.findIndex(Y=>Y.id===y)),X=e[W]??e[0],Z=e.length<=1?100:W/(e.length-1)*100,D=Y=>{a||x(Y),i==null||i(Y)},Q=Y=>{const S=e.find(H=>H.id===Y);S&&(r||N(Y),l==null||l(Y,S))},j=Y=>w.has(Y),se=Y=>e.slice(0,Y).find(S=>!S.optional&&!w.has(S.id)),te=Y=>{const S=e[Y];return!S||S.disabled?!1:Y===W||d&&Y<W?!0:!se(Y)},ee=Y=>{const S=e.findIndex(H=>H.id===Y);return S>=0&&te(S)},U=Y=>{const S=e.findIndex(H=>H.id===Y);if(S<0)return!1;if(!te(S)){const H=se(S);return H&&(c==null||c(e[S],H)),!1}return Q(Y),!0},J=(Y=X==null?void 0:X.id)=>{!Y||w.has(Y)||D([...L,Y])},ce=(Y=X==null?void 0:X.id)=>{if(!Y)return;const S=e.findIndex(O=>O.id===Y),H=L.filter(O=>{const re=e.findIndex(z=>z.id===O);return re>=0&&re<S});D(H),S>=0&&W>S&&Q(Y)},C=()=>W<=0?!1:U(e[W-1].id),_=()=>{const Y=e[W+1];return Y?U(Y.id):!1},ae={activeStep:X,activeIndex:W,completedStepIds:L,isCompleted:j,isUnlocked:ee,completeStep:J,uncompleteStep:ce,goToStep:U,goNext:_,goPrevious:C};if(!X)return null;const B=e[W+1],I=W>0,M=B?ee(B.id):!1,oe=typeof X.content=="function"?X.content(ae):X.content;return t.jsxs("section",{className:Gt("overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)]",h),children:[t.jsxs("div",{className:Gt("border-b border-[var(--border)] bg-[var(--bg-input)]",v),children:[t.jsx("div",{className:"relative h-1 overflow-hidden bg-[var(--border)]/55",children:t.jsx("div",{className:"h-full rounded-r-full bg-[var(--primary)] transition-[width] duration-500 ease-out",style:{width:`${Z}%`}})}),t.jsx("div",{className:"grid gap-2 p-2",style:{gridTemplateColumns:`repeat(${e.length}, minmax(0, 1fr))`},children:e.map((Y,S)=>{const H=Y.id===X.id,O=j(Y.id),re=te(S),z=se(S);return t.jsxs("button",{type:"button",disabled:!re,"aria-current":H?"step":void 0,"aria-disabled":!re,title:!re&&z?`Completa ${z.title}`:Y.title,onClick:()=>U(Y.id),className:Gt("group relative min-h-16 min-w-0 overflow-hidden rounded-md border p-3 text-left transition-all duration-200 focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--primary)]/35 disabled:cursor-not-allowed",H&&"border-[var(--primary)] bg-[var(--bg-card)] shadow-sm",O&&!H&&"border-[var(--primary)]/35 bg-[var(--bg-card)]",!H&&!O&&re&&"border-transparent bg-[var(--bg-card)]/45 hover:border-[var(--border)] hover:bg-[var(--bg-card)]",!re&&"border-transparent bg-[var(--bg-card)]/35 opacity-60"),children:[t.jsx("span",{className:Gt("absolute inset-x-0 top-0 h-0.5 origin-left scale-x-0 bg-[var(--primary)] transition-transform duration-300",H&&"scale-x-100")}),t.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[t.jsx("span",{className:Gt("grid h-7 w-7 shrink-0 place-items-center rounded-full border text-xs font-bold transition-all duration-200",H&&"border-[var(--primary)] bg-[var(--primary)] text-[var(--primary-fg)]",O&&!H&&"border-[var(--primary)] bg-[var(--primary)]/12 text-[var(--primary)]",!O&&!H&&re&&"border-[var(--border)] text-[var(--text-muted)]",!re&&"border-[var(--border)] text-[var(--text-muted)]"),children:O?t.jsx(q.HiCheck,{className:"h-4 w-4"}):re?S+1:t.jsx(q.HiLockClosed,{className:"h-3.5 w-3.5"})}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsxs("span",{className:Gt("block truncate text-xs font-semibold transition-colors duration-200",H?"text-[var(--text-main)]":"text-[var(--text-secondary)]"),children:[S+1,". ",Y.title]}),Y.description&&t.jsx("span",{className:"mt-1 block truncate text-[11px] text-[var(--text-muted)]",children:Y.description})]}),Y.badge&&t.jsx("span",{className:"shrink-0",children:Y.badge})]})]},Y.id)})})]}),t.jsx("div",{className:Gt("min-h-72 animate-[stepWizardIn_220ms_ease-out] p-5",k),children:oe},X.id),u&&t.jsxs("div",{className:Gt("flex flex-wrap items-center justify-between gap-3 border-t border-[var(--border)] bg-[var(--bg-input)] px-4 py-3",g),children:[t.jsx(Ue,{variant:"secondary",height:38,padding:"0 14px",icon:t.jsx(q.HiChevronLeft,{}),disabled:!I,onClick:C,children:m}),t.jsxs("div",{className:"flex items-center gap-3 text-xs text-[var(--text-muted)]",children:[t.jsxs("span",{children:["Paso ",W+1," de ",e.length]}),t.jsx("span",{className:"h-1 w-1 rounded-full bg-[var(--border)]"}),t.jsxs("span",{children:[L.length," completados"]})]}),t.jsx(Ue,{height:38,padding:"0 14px",icon:t.jsx(q.HiChevronRight,{}),disabled:!B||!M,onClick:_,children:B&&!M?f:b})]})]})}const Vu={sm:"px-2.5 py-1.5 text-xs leading-5",md:"px-2.5 py-1.5 text-sm leading-5",lg:"px-3 py-2 text-sm leading-6"};function Yu(e,r){if(e){if(typeof e=="function"){e(r);return}e.current=r}}function Xu(e){const r=getComputedStyle(e),n=Number.parseFloat(r.lineHeight),a=Number.parseFloat(r.paddingTop)+Number.parseFloat(r.paddingBottom),s=Number.parseFloat(r.borderTopWidth)+Number.parseFloat(r.borderBottomWidth);return{lineHeight:Number.isFinite(n)?n:20,paddingY:Number.isFinite(a)?a:12,borderY:Number.isFinite(s)?s:2}}function pl(e,r){const{lineHeight:n,paddingY:a,borderY:s}=Xu(e);return Math.ceil(r*n+a+s)}const hl=o.forwardRef(function({className:r="",size:n="md",status:a="default",maxHeight:s,maxRows:l,minRows:i=1,style:c,value:d,defaultValue:u,onInput:m,...b},f){const h=o.useRef(null),v=a==="error"?"var(--danger)":a==="success"?"#16a34a":"var(--border)",k=o.useCallback(()=>{const g=h.current;if(!g)return;g.style.height="auto";const A=g.scrollHeight,$=pl(g,i),N=s??(l!==void 0?pl(g,l):void 0),T=N!==void 0?Math.min(Math.max(A,$),N):Math.max(A,$);g.style.height=`${T}px`,g.style.overflowY=N!==void 0&&A>N?"auto":"hidden"},[s,l,i]);return o.useLayoutEffect(()=>{k()},[k,d,u]),o.useEffect(()=>{const g=h.current;if(!g||typeof ResizeObserver>"u")return;const A=new ResizeObserver(()=>k());return A.observe(g),()=>A.disconnect()},[k]),t.jsx("textarea",{...b,ref:g=>{h.current=g,Yu(f,g)},rows:i,value:d,defaultValue:u,"aria-invalid":a==="error"||b["aria-invalid"],onInput:g=>{k(),m==null||m(g)},style:{...c,borderColor:v,minHeight:void 0},className:`w-full resize-none overflow-hidden rounded-lg border bg-[var(--bg-input)] text-[var(--text-main)] outline-none placeholder:text-[var(--text-muted)] transition-colors focus:border-[var(--primary)] disabled:cursor-not-allowed disabled:opacity-60 ${Vu[n]} ${r}`})});function Ku({label:e,containerClassName:r="",helperText:n,helperDisplay:a,error:s,labelAction:l,required:i,className:c="",status:d,...u}){return t.jsx(In,{label:e,required:i,helperText:n,helperDisplay:a,error:s,labelAction:l,className:r,children:t.jsx(hl,{...u,required:i,status:s?"error":d,className:`w-full ${c}`})})}const Gu={sm:"min-h-20 px-2.5 py-1.5 text-xs leading-5",md:"min-h-24 px-2.5 py-2 text-sm leading-5",lg:"min-h-32 px-3 py-2.5 text-sm leading-6"},Zu={none:"resize-none",vertical:"resize-y",horizontal:"resize-x",both:"resize"};function Qu(e,r){if(e){if(typeof e=="function"){e(r);return}e.current=r}}function Ju(e,r){return e!==void 0?String(e).length:r!==void 0?String(r).length:0}const gl=o.forwardRef(function({className:r="",wrapperClassName:n="",size:a="md",resize:s="vertical",autoResize:l=!1,minRows:i,maxRows:c,showCount:d=!1,maxCount:u,status:m="default",icon:b,action:f,style:h,value:v,defaultValue:k,maxLength:g,onInput:A,...$},N){const T=o.useRef(null),x=Ju(v,k),y=u??g,L=!!(b||f||d),w=m==="error"?"var(--danger)":m==="success"?"#16a34a":"var(--border)",W={...h??{},...i?{minHeight:`${i*24+18}px`}:null,...c?{maxHeight:`${c*24+18}px`}:null},X=()=>{const D=T.current;!D||!l||(D.style.height="auto",D.style.height=`${D.scrollHeight}px`)};o.useEffect(X,[l,v]);const Z=t.jsx("textarea",{...$,ref:D=>{T.current=D,Qu(N,D)},value:v,defaultValue:k,maxLength:g,"aria-invalid":m==="error"||$["aria-invalid"],onInput:D=>{X(),A==null||A(D)},style:{...W,borderColor:w},className:`w-full rounded-lg border bg-[var(--bg-input)] text-[var(--text-main)] outline-none placeholder:text-[var(--text-muted)] transition-colors focus:border-[var(--primary)] disabled:cursor-not-allowed disabled:opacity-60 ${Gu[a]} ${Zu[l?"none":s]} ${b?"pl-8":""} ${f?"pr-10":""} ${r}`});return L?t.jsxs("span",{className:`relative block ${n}`,children:[b&&t.jsx("span",{className:"pointer-events-none absolute left-2.5 top-2.5 flex h-4 w-4 items-center justify-center text-[var(--text-muted)]",children:b}),Z,f&&t.jsx("span",{className:"absolute right-2 top-2 flex items-center justify-center",children:f}),d&&t.jsxs("span",{className:"absolute bottom-1.5 right-2 rounded bg-[var(--bg-input)] px-1.5 text-[10px] font-semibold text-[var(--text-muted)]",children:[x,y?`/${y}`:""]})]}):Z});function Ru({label:e,containerClassName:r="",helperText:n,helperDisplay:a,error:s,labelAction:l,required:i,className:c="",status:d,...u}){return t.jsx(In,{label:e,required:i,helperText:n,helperDisplay:a,error:s,labelAction:l,className:r,children:t.jsx(gl,{...u,required:i,status:s?"error":d,className:`w-full ${c}`})})}const vl=[{bg:"#dbeafe",text:"#1e40af",border:"#bfdbfe"},{bg:"#dcfce7",text:"#166534",border:"#bbf7d0"},{bg:"#fce7f3",text:"#9d174d",border:"#fbcfe8"},{bg:"#fef9c3",text:"#854d0e",border:"#fef08a"},{bg:"#ede9fe",text:"#5b21b6",border:"#ddd6fe"},{bg:"#ffedd5",text:"#9a3412",border:"#fed7aa"},{bg:"#cffafe",text:"#155e75",border:"#a5f3fc"},{bg:"#f0fdf4",text:"#14532d",border:"#bbf7d0"}];function ef(e){return vl[e%vl.length]}let tf=0;function fo(){return++tf}function yl(e,r){return r?r instanceof RegExp?r.test(e):r(e):!0}function rf(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function nf(e,r){const n=r.filter(Boolean);if(n.length===0)return[e.trim()].filter(Boolean);const a=new RegExp(`${n.map(s=>rf(s)).join("|")}|\\r?\\n`,"g");return e.split(a).map(s=>s.trim()).filter(Boolean)}function af({value:e,defaultValue:r,onChange:n,placeholder:a="Escribe y presiona Enter…",disabled:s=!1,className:l="",delimiters:i=[","],maxTags:c,allowDuplicates:d=!1,validate:u,label:m,helperText:b,helperDisplay:f="inline",error:h,required:v=!1}){const k=e!==void 0,g=!!h,A=!!b&&f==="tooltip"&&!g,[$,N]=o.useState(()=>(r??[]).map((O,re)=>({id:fo(),value:O.trim(),colorIndex:re})));o.useEffect(()=>{k&&N(O=>{const re=e??[],z=new Map(O.map(de=>[de.value,de]));return re.map((de,he)=>z.get(de)??{id:fo(),value:de,colorIndex:he})})},[k,e]);const T=$,[x,y]=o.useState(""),[L,w]=o.useState(null),[W,X]=o.useState(""),[Z,D]=o.useState(!1),[Q,j]=o.useState(!1),se=o.useRef(null),te=o.useRef(null),ee=o.useRef(null);function U(){j(!0),setTimeout(()=>j(!1),400)}function J(O){N(O),n==null||n(O.map(re=>re.value))}function ce(O){let re=T,z=!1,de=!1;for(const he of O){const ie=he.trim();if(ie){if(c!==void 0&&re.length>=c){de=!0;break}if(!d&&re.some(ge=>ge.value.toLowerCase()===ie.toLowerCase())){de=!0;continue}if(!yl(ie,u)){de=!0;continue}re=[...re,{id:fo(),value:ie,colorIndex:re.length}],z=!0}}return z&&J(re),de&&U(),z}function C(O){return ce([O])}function _(O){const re=T.filter(z=>z.id!==O);J(re.map((z,de)=>({...z,colorIndex:de})))}function ae(O,re){const z=re.trim();if(w(null),X(""),!z){_(O);return}if(!(!d&&T.some(de=>de.id!==O&&de.value.toLowerCase()===z.toLowerCase()))){if(!yl(z,u)){U();return}J(T.map(de=>de.id===O?{...de,value:z}:de))}}function B(O){s||(w(O.id),X(O.value),setTimeout(()=>{var re;return(re=te.current)==null?void 0:re.select()},0))}function I(O){if(O.key==="Enter"||i.includes(O.key)){O.preventDefault(),C(x)&&y("");return}if(O.key==="Backspace"&&x===""&&T.length>0){O.preventDefault();const re=T[T.length-1];_(re.id)}}function M(O,re){if(O.key==="Enter"){O.preventDefault(),ae(re,W),setTimeout(()=>{var z;return(z=se.current)==null?void 0:z.focus()},0);return}O.key==="Escape"&&(O.preventDefault(),w(null),X(""),setTimeout(()=>{var z;return(z=se.current)==null?void 0:z.focus()},0))}function oe(){var O;s||(O=se.current)==null||O.focus()}function K(O){if(s)return;const re=O.clipboardData.getData("text");if(!re||!(i.some(ie=>ie&&re.includes(ie))||re.includes(`
|
|
31
|
-
`)))return;O.preventDefault();const de=
|
|
28
|
+
`).replace(/<[^>]+>/g," ").replace(/ /g," ").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'").replace(/\s+/g," ").trim():""}function so(e){if(!e)return[];const r=new Set,n=[],a=d=>{const u=oo(d);!u||r.has(u)||(r.add(u),n.push(u))},s=/data-username\s*=\s*["']([^"']+)["']/gi;let l;for(;(l=s.exec(e))!==null;)a(l[1]??"");const i=Qs(e);no.lastIndex=0;let c;for(;(c=no.exec(i))!==null;)a(c[1]??"");return n}function Js(e){const r=String(e.name??"").trim();return r||String(e.username??"").trim()||"usuario"}function Eu(e,r){const n=so(e);if(!n.length)return[];const a=new Map;r.forEach(i=>{i.username&&a.set(oo(i.username),i)});const s=new Set,l=[];for(const i of n){const c=a.get(i);c&&(s.has(c.userId)||(s.add(c.userId),l.push({userId:c.userId,username:c.username,email:c.email??void 0,display:c.name??c.username})))}return l}function Rs(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 Mu(e,r){return r?e.filter(n=>n.userId!==r):e}function el(e){return!e||!/@/.test(e)?e:e.replace(no,(r,n,a,s)=>{const l=s.slice(0,a),i=l.lastIndexOf("<"),c=l.lastIndexOf(">");if(i>c)return r;const d=(n??"").toLowerCase(),u=s[a+r.length]??"";return`<span class="mention-chip" contenteditable="false" data-username="${d}">${r}</span>${u===" "||u===" "?"":" "}`})}function lo(e){var r;(r=e.querySelectorAll)==null||r.call(e,".mention-chip").forEach(n=>{if(!(n instanceof HTMLElement))return;const a=n.ownerDocument,s=n.nextSibling;if((s==null?void 0:s.nodeType)===Node.TEXT_NODE){const l=s.textContent??"";if(l.startsWith(" ")||l.startsWith(" "))return;if(l.length>0){s.textContent=` ${l}`;return}}n.after(a.createTextNode(" "))})}const Tu=new Set(["P","DIV","LI","H1","H2","H3","H4","H5","H6","BLOCKQUOTE"]);function tl(e,r){return Tu.has(e.tagName)&&e!==r}function io(e,r){let n="",a,s,l=!1;const i=(f,g)=>{if(l||!(r!=null&&r.domPoint))return;const{container:v,offset:k}=r.domPoint;v===f&&k===g&&(s=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 v=0;v<=g.length;v+=1){if(i(f,v),c(f,v))return!0;v<g.length&&(n+=g[v])}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 v=f;if(v.tagName==="BR")return i(v,0),d(v.nextSibling??void 0)==="matched";const k=Array.from(f.childNodes);for(let h=0;h<k.length;h+=1){const A=k[h],$=h>0&&A.nodeType===Node.ELEMENT_NODE&&tl(A,e);if(m(A,$))return!0}return!1},b=Array.from(e.childNodes);for(let f=0;f<b.length;f+=1){const g=b[f],v=f>0&&g.nodeType===Node.ELEMENT_NODE&&tl(g,e);if(m(g,v))break}if((r==null?void 0:r.locatePlain)===n.length&&!a){const f=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_TEXT);let g=f.nextNode(),v=g;for(;v;)g=v,v=f.nextNode();g&&(a={node:g,offset:g.data.length})}return{plain:n,locate:a,domOffset:s}}function co(e){return io(e).plain}function Cr(e,r){return r<0?null:io(e,{locatePlain:r}).locate??null}function qn(e,r,n){return e!==r&&!e.contains(r)?-1:io(e,{domPoint:{container:r,offset:n}}).domOffset??-1}function rl(e,r){const{triggerIndex:n,caretIndex:a,username:s}=r;if(a<n)return null;const l=Cr(e,n),i=Cr(e,a);if(!l||!i)return null;const c=e.ownerDocument,d=c.createRange();d.setStart(l.node,l.offset),d.setEnd(i.node,i.offset),d.deleteContents();const u=Js({name:r.display,username:s}),m=c.createElement("span");m.className="mention-chip",m.setAttribute("data-username",s.toLowerCase()),r.userId&&m.setAttribute("data-userid",String(r.userId)),m.contentEditable="false",m.textContent=u,m.title=`@${s}`;const b=c.createTextNode(" "),f=c.createDocumentFragment();f.append(m,b),d.insertNode(f),lo(e);const g=c.defaultView,v=g==null?void 0:g.getSelection();if(v){const h=c.createRange();h.setStart(b,b.data.length),h.collapse(!0),v.removeAllRanges(),v.addRange(h)}const k=v!=null&&v.rangeCount?qn(e,v.getRangeAt(0).startContainer,v.getRangeAt(0).startOffset):n+u.length+1;return{caretPlainOffset:k>=0?k:n+u.length+1}}function nl(e,r){const n=e.ownerDocument,a=n.defaultView;if(!a)return;const s=a.getSelection();if(!s)return;const l=n.createRange(),i=Cr(e,r);i?(l.setStart(i.node,i.offset),l.collapse(!0)):(l.selectNodeContents(e),l.collapse(!1)),s.removeAllRanges(),s.addRange(l)}function Un(e){return e instanceof HTMLElement&&e.classList.contains("mention-chip")}function al(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 ol(e){var s;const r=e.ownerDocument,n=(s=r.defaultView)==null?void 0:s.getSelection();if(!n)return;const a=r.createRange();a.selectNode(e),n.removeAllRanges(),n.addRange(a),e.classList.add("is-selected")}function Er(e=document){var r;(r=e.querySelectorAll)==null||r.call(e,".mention-chip.is-selected").forEach(n=>{n.classList.remove("is-selected")})}function Vn(e){var a;const r=(a=e.ownerDocument.defaultView)==null?void 0:a.getSelection();e.querySelectorAll(".mention-chip").forEach(s=>{let l=!1;if(r&&r.rangeCount>0)try{const i=r.getRangeAt(0);(!r.isCollapsed&&i.intersectsNode(s)||r.isCollapsed&&i.startContainer===s&&i.endContainer===s)&&(l=!0)}catch{l=!1}s.classList.toggle("is-selected",l)})}function sl(e){var s;const r=e.ownerDocument,n=(s=r.defaultView)==null?void 0:s.getSelection();if(!n)return;const a=r.createRange();a.selectNodeContents(e),n.removeAllRanges(),n.addRange(a),Vn(e)}function ll(e){const r=e.cloneContents();return r.querySelectorAll(".mention-chip").forEach(n=>n.remove()),(r.textContent??"").replace(/\u00a0/g," ").trim().length>0}function il(e){var a;const r=(a=e.ownerDocument.defaultView)==null?void 0:a.getSelection();if(!r||r.isCollapsed||r.rangeCount===0)return!1;const n=r.getRangeAt(0);return e.contains(n.commonAncestorContainer)?(n.deleteContents(),Er(e),!0):!1}function Yn(e){var m,b;const r=e.ownerDocument,n=e.parentNode;if(!n)return;const a=(f,g)=>{let v=f;for(;v&&v.nodeType===Node.TEXT_NODE&&(v.textContent??"")==="";){const k=v;v=v[g],k.remove()}return v},s=a(e.nextSibling,"nextSibling");if(s&&s.nodeType===Node.TEXT_NODE&&/^( |\u00a0)/.test(s.textContent??"")){const f=s;(f.data.length??0)<=1?f.remove():f.data=f.data.slice(1)}const l=a(e.previousSibling,"previousSibling"),i=n,c=Array.from(n.childNodes).indexOf(e);e.remove();const d=(m=r.defaultView)==null?void 0:m.getSelection();if(!d)return;const u=r.createRange();if(l)if(l.nodeType===Node.TEXT_NODE){const f=((b=l.textContent)==null?void 0:b.length)??0;u.setStart(l,f)}else u.setStartAfter(l);else i.childNodes[c]?u.setStart(i,c):(u.selectNodeContents(i),u.collapse(!1));u.collapse(!0),d.removeAllRanges(),d.addRange(u)}function cl(e){var l;const r=(l=e.ownerDocument.defaultView)==null?void 0:l.getSelection();if(!r||!r.isCollapsed||r.rangeCount===0)return null;const n=r.getRangeAt(0);if(!e.contains(n.startContainer))return null;const{startContainer:a,startOffset:s}=n;if(a.nodeType===Node.TEXT_NODE){const i=a.textContent??"",c=al(a.previousSibling,"prev");return Un(c)&&(s===0||s===1&&(i.charAt(0)===" "||i.charAt(0)===" "))?c:null}if(a.nodeType===Node.ELEMENT_NODE){const i=a.childNodes;let c=s-1;for(;c>=0;){const d=i[c];if(Un(d))return d;if(d.nodeType===Node.TEXT_NODE&&!(d.textContent??"").replace(/\u00a0/g," ").trim()){c-=1;continue}break}}return null}function dl(e){var l;const r=(l=e.ownerDocument.defaultView)==null?void 0:l.getSelection();if(!r||!r.isCollapsed||r.rangeCount===0)return null;const n=r.getRangeAt(0);if(!e.contains(n.startContainer))return null;const{startContainer:a,startOffset:s}=n;if(a.nodeType===Node.TEXT_NODE){const i=a.textContent??"";if(s>=i.length){const c=al(a.nextSibling,"next");if(Un(c))return c}return null}if(a.nodeType===Node.ELEMENT_NODE){const i=a.childNodes;let c=s;for(;c<i.length;){const d=i[c];if(Un(d))return d;if(d.nodeType===Node.TEXT_NODE&&!(d.textContent??"").replace(/\u00a0/g," ").trim()){c+=1;continue}break}}return null}function uo(e){var s;const r=(s=e.ownerDocument.defaultView)==null?void 0:s.getSelection();if(!r||r.isCollapsed||r.rangeCount===0)return[];const n=r.getRangeAt(0);return e.contains(n.commonAncestorContainer)?Array.from(e.querySelectorAll(".mention-chip")).filter(l=>{try{return n.intersectsNode(l)}catch{return!1}}):[]}const fo=280,Xn=6,ul=260,$u=new Set(["ArrowDown","ArrowUp","Enter","Tab","Escape"]),fl=4,Au={position:"relative"},Lu={position:"fixed",zIndex:11050,minWidth:ul,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},bl={padding:"10px 12px",fontSize:12,color:"var(--text-muted, #656d76)"};function Du(e){return Array.from(document.querySelectorAll(`[data-bonsaif-rich-instance="${CSS.escape(e)}"]`))}function Iu(e,r){const n=Math.max(8,Math.min(e.left,window.innerWidth-ul-8)),a=r==null?void 0:r.getBoundingClientRect(),s=a?Math.min(window.innerHeight-8,a.bottom):window.innerHeight-8,l=a?Math.max(8,a.top):8,i=s-e.bottom-Xn,c=e.top-l-Xn;return i<Math.min(fo,160)&&c>i?{left:n,bottom:window.innerHeight-e.top+Xn,maxHeight:Math.max(120,Math.min(fo,c))}:{left:n,top:e.bottom+Xn,maxHeight:Math.max(120,Math.min(fo,i))}}function ml({value:e,onChange:r,onSearchUsers:n,onMentionsChange:a,minHeight:s,placeholder:l,className:i,maxSuggestions:c=8,searchDebounceMs:d=140,highlightInEditor:u=!1,searchCacheKey:m=""}){const b=o.useId().replace(/:/g,""),f=o.useRef(null),g=o.useRef(null),v=o.useRef(new Map),k=o.useRef(n);k.current=n;const h=o.useRef(null),A=o.useRef(0),$=o.useRef([]),N=o.useRef(null),[T,x]=o.useState(null),[y,L]=o.useState([]),[w,W]=o.useState(0),[X,Z]=o.useState([]),[D,Q]=o.useState(!1),[j,se]=o.useState(!1);A.current=w,o.useEffect(()=>{se(!0)},[]);const te=(T==null?void 0:T.query)??null;o.useEffect(()=>{if(te===null){L([]);return}const I=te.trim(),E=`${m}|${I.toLowerCase()||"*"}`,oe=v.current.get(E);if(oe){L(oe),Q(!1),W(0);return}const K=new AbortController;Q(!0);const Y=window.setTimeout(()=>{(async()=>{try{const S=await k.current(I,{signal:K.signal,limit:c});if(K.signal.aborted)return;const H=Array.isArray(S)?S:[];v.current.set(E,H),L(H),W(0)}catch{K.signal.aborted||L([])}finally{K.signal.aborted||Q(!1)}})()},d);return()=>{K.abort(),window.clearTimeout(Y)}},[te,c,d,m]);const ee=o.useRef(a);ee.current=a,o.useEffect(()=>{var I;(I=ee.current)==null||I.call(ee,Rs(X))},[X]);const U=o.useCallback(()=>{const I=Du(b);if(I.length===0)return null;const E=window.getSelection();if(E!=null&&E.rangeCount){const K=E.getRangeAt(0).startContainer;for(const Y of I)if(Y.contains(K))return Y}const oe=document.activeElement;for(const K of I)if(oe===K||oe&&K.contains(oe))return K;for(const K of I)if(K.closest('[role="dialog"]'))return K;return I[0]??null},[b]),J=o.useCallback(()=>{const I=U(),E=window.getSelection();if(!I||!E||E.rangeCount===0){x(null);return}const oe=E.getRangeAt(0);if(!I.contains(oe.startContainer)){x(null);return}const K=qn(I,oe.startContainer,oe.startOffset);if(K<0){x(null);return}const Y=ao(I,K);if(!Y){x(null);return}const S=oe.getBoundingClientRect(),H=S.width===0&&S.height===0?(()=>{const re=document.createRange();return re.selectNodeContents(oe.startContainer),re.collapse(!0),re.getBoundingClientRect()})():S;h.current={query:Y.query,caretIndex:Y.caretIndex,triggerIndex:Y.triggerIndex};const O=Iu(H,I);x(re=>{const z={query:Y.query,...O};return re&&re.query===z.query&&re.top===z.top&&re.bottom===z.bottom&&re.left===z.left&&re.maxHeight===z.maxHeight?re:z})},[U]),ce=o.useCallback(I=>{r(I),J()},[r,J]);o.useEffect(()=>{const I=E=>{if($u.has(E.key))return;const oe=U(),K=E.target;!oe||!K||!oe.contains(K)||J()};return document.addEventListener("keyup",I,!0),()=>document.removeEventListener("keyup",I,!0)},[U,J]);const C=o.useCallback(I=>{const E=U();if(!E)return;let oe=-1;const K=window.getSelection();if(K&&K.rangeCount>0){const re=K.getRangeAt(0);E.contains(re.startContainer)&&(oe=qn(E,re.startContainer,re.startOffset))}if(oe<0&&h.current&&(oe=h.current.caretIndex),oe<0)return;const Y=ao(E,oe);if(!Y)return;const S=rl(E,{triggerIndex:Y.triggerIndex,caretIndex:oe,username:I.username,display:I.name,userId:I.userId});if(!S)return;lo(E),E.dispatchEvent(new InputEvent("input",{bubbles:!0,cancelable:!0}));const H={userId:I.userId,username:I.username,email:I.email??void 0,display:I.name??I.username};Z(re=>{const z=new Map(re.map(de=>[de.userId,de]));return z.set(H.userId,H),Array.from(z.values())}),x(null),h.current=null;const O=S.caretPlainOffset;requestAnimationFrame(()=>{requestAnimationFrame(()=>{var ie,ge;const re=U();if(!re)return;re.focus(),nl(re,O);const z=window.getSelection(),de=z==null?void 0:z.anchorNode,he=de instanceof Element?de.closest(".mention-chip"):(ie=de==null?void 0:de.parentElement)==null?void 0:ie.closest(".mention-chip");if(he!=null&&he.parentNode){const Me=document.createRange(),$e=he.nextSibling;$e&&$e.nodeType===Node.TEXT_NODE?Me.setStart($e,((ge=$e.textContent)==null?void 0:ge.length)??0):Me.setStartAfter(he),Me.collapse(!0),z==null||z.removeAllRanges(),z==null||z.addRange(Me)}})})},[U]);o.useEffect(()=>{const I=new Set(so(e).map(E=>E.toLowerCase()));Z(E=>{const oe=E.filter(K=>I.has(K.username.toLowerCase()));return oe.length===E.length?E:oe})},[e]),o.useEffect(()=>{if(!T)return;const I=E=>{const oe=E.target;if(!oe||f.current&&f.current.contains(oe)||g.current&&g.current.contains(oe))return;const K=U();K&&K.contains(oe)||x(null)};return document.addEventListener("mousedown",I),()=>{document.removeEventListener("mousedown",I)}},[T,U]);const _=o.useMemo(()=>y.slice(0,c),[y,c]);$.current=_,o.useEffect(()=>{if(!T)return;const I=E=>{const oe=U(),K=E.target;if(!oe||!K||!oe.contains(K))return;const Y=$.current;if(!(Y.length===0&&E.key!=="Escape"))if(E.key==="ArrowDown")E.preventDefault(),E.stopPropagation(),W(S=>(S+1)%Math.max(Y.length,1));else if(E.key==="ArrowUp")E.preventDefault(),E.stopPropagation(),W(S=>(S-1+Y.length)%Math.max(Y.length,1));else if(E.key==="Enter"||E.key==="Tab"){const S=Y[A.current];S&&(E.preventDefault(),E.stopPropagation(),C(S))}else E.key==="Escape"&&(E.preventDefault(),E.stopPropagation(),x(null))};return document.addEventListener("keydown",I,!0),()=>document.removeEventListener("keydown",I,!0)},[U,C,T]),o.useEffect(()=>{const I=H=>{H.dispatchEvent(new InputEvent("input",{bubbles:!0,cancelable:!0}))},E=H=>{const O=U(),re=H.target;if(!O||!re||!O.contains(re))return;if((H.metaKey||H.ctrlKey)&&H.key.toLowerCase()==="a"){H.preventDefault(),H.stopPropagation(),O.focus(),sl(O);return}if(H.key!=="Backspace"&&H.key!=="Delete")return;const z=window.getSelection();if(z&&!z.isCollapsed&&z.rangeCount>0){const ie=z.getRangeAt(0);if(O.contains(ie.commonAncestorContainer)&&uo(O).length>0&&ll(ie)){H.preventDefault(),H.stopPropagation(),il(O)&&I(O);return}}const de=uo(O);if(de.length>0){H.preventDefault(),H.stopPropagation();for(const ie of de)Yn(ie);Er(O),I(O);return}if(H.key==="Backspace"){const ie=cl(O);if(!ie)return;H.preventDefault(),H.stopPropagation(),Yn(ie),Er(O),I(O);return}const he=dl(O);he&&(H.preventDefault(),H.stopPropagation(),Yn(he),Er(O),I(O))},oe=H=>{const O=U();if(!O)return;const re=H.target;if(!(re instanceof Element)||!O.contains(re))return;const z=re.closest(".mention-chip");if(!(z instanceof HTMLElement)||!O.contains(z)){N.current=null,Er(O);return}H.shiftKey||H.button!==0||(N.current={chip:z,x:H.clientX,y:H.clientY})},K=H=>{const O=N.current;if(!O)return;const re=Math.abs(H.clientX-O.x),z=Math.abs(H.clientY-O.y);(re>fl||z>fl)&&(N.current=null)},Y=H=>{var he;const O=U(),re=N.current;if(N.current=null,!O||!re)return;const z=H.target;if(!(z instanceof Element)||!O.contains(z)||!((he=z.closest(".mention-chip"))!=null&&he.isSameNode(re.chip)))return;const de=window.getSelection();if(de){if(!de.isCollapsed){Vn(O);return}O.focus(),ol(re.chip)}},S=()=>{const H=U();if(!H)return;const O=window.getSelection();!O||O.rangeCount===0||!O.anchorNode||!H.contains(O.anchorNode)||!O.focusNode||!H.contains(O.focusNode)||Vn(H)};return document.addEventListener("keydown",E,!0),document.addEventListener("mousedown",oe,!0),document.addEventListener("mousemove",K,!0),document.addEventListener("mouseup",Y,!0),document.addEventListener("selectionchange",S),()=>{document.removeEventListener("keydown",E,!0),document.removeEventListener("mousedown",oe,!0),document.removeEventListener("mousemove",K,!0),document.removeEventListener("mouseup",Y,!0),document.removeEventListener("selectionchange",S)}},[U]),o.useEffect(()=>{if(!T||!g.current)return;const I=g.current.querySelector(`[data-mention-index="${w}"]`);I==null||I.scrollIntoView({block:"nearest"})},[w,T]);const ae=u?el(e):e,B=T&&j?ct.createPortal(t.jsxs("ul",{ref:g,style:{...Lu,left:T.left,top:T.top,bottom:T.bottom,maxHeight:T.maxHeight},role:"listbox","aria-label":"Menciones sugeridas",children:[D&&_.length===0&&t.jsx("li",{style:bl,children:"Buscando…"}),!D&&_.length===0&&t.jsx("li",{style:bl,children:T.query.trim().length===0?"Escribe un nombre o usuario":`Sin coincidencias para “${T.query}”`}),_.map((I,E)=>{var oe,K;return t.jsx("li",{children:t.jsxs("button",{type:"button","data-mention-index":E,onMouseDown:Y=>{Y.preventDefault(),C(I)},onMouseEnter:()=>W(E),style:{width:"100%",textAlign:"left",padding:"8px 10px",border:"none",background:E===w?"color-mix(in srgb, var(--primary, var(--bonsaif-ui-primary, #1f6feb)) 14%, transparent)":"transparent",color:"var(--text-main, var(--bonsaif-ui-text, #24292f))",borderRadius:6,cursor:"pointer",display:"flex",flexDirection:"column",gap:2},children:[t.jsx("span",{style:{fontWeight:600,fontSize:13},children:((oe=I.name)==null?void 0:oe.trim())||`@${I.username}`}),t.jsx("span",{style:{fontSize:11,color:"var(--text-muted, #656d76)"},children:[(K=I.name)!=null&&K.trim()?`@${I.username}`:null,I.email].filter(Boolean).join(" · ")||`@${I.username}`})]})},I.userId)})]}),document.body):null;return t.jsxs("div",{ref:f,style:Au,className:i,children:[t.jsx(Vs,{value:ae,onChange:ce,placeholder:l,minHeight:s,instanceId:b}),B]})}function Ou({value:e,onChange:r,placeholder:n,minHeight:a,onSearchUsers:s,onMentionsChange:l,className:i,maxSuggestions:c,searchDebounceMs:d,highlightInEditor:u,searchCacheKey:m}){return s?t.jsx(ml,{value:e,onChange:r,onSearchUsers:s,onMentionsChange:l,placeholder:n,minHeight:a,className:i,maxSuggestions:c,searchDebounceMs:d,highlightInEditor:u,searchCacheKey:m}):t.jsx(Vs,{value:e,onChange:r,placeholder:n,minHeight:a})}function Hu({title:e,subtitle:r,icon:n,actions:a,children:s,footer:l,className:i="",bodyClassName:c="p-4"}){const d=e||r||n||a;return t.jsxs("section",{className:`overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${i}`,children:[d&&t.jsxs("header",{className:"flex items-center justify-between gap-3 border-b border-[var(--border)] px-4 py-3",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[n&&t.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-input)] text-[var(--primary)]",children:n}),t.jsxs("div",{className:"min-w-0",children:[e&&t.jsx("h3",{className:"truncate text-sm font-semibold text-[var(--text-main)]",children:e}),r&&t.jsx("div",{className:"truncate text-xs text-[var(--text-muted)]",children:r})]})]}),a&&t.jsx("div",{className:"shrink-0",children:a})]}),t.jsx("div",{className:c,children:s}),l&&t.jsx("footer",{className:"border-t border-[var(--border)] px-4 py-3",children:l})]})}const Bu={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)"}},Fu={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 Pu({children:e,tone:r="neutral",size:n="sm",icon:a,dot:s=!1,className:l=""}){const i=Bu[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 ${Fu[n]} ${l}`,style:{color:i.text,background:i.bg,borderColor:i.border},children:[s&&t.jsx("span",{"aria-hidden":"true",className:"h-1.5 w-1.5 shrink-0 rounded-full",style:{background:i.text}}),a&&t.jsx("span",{className:"shrink-0",children:a}),t.jsx("span",{className:"min-w-0 truncate",children:e})]})}const pl={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)"}},_u={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"},zu={xs:"right-1 h-3 w-3",sm:"right-1.5 h-3 w-3",md:"right-2 h-3.5 w-3.5"},Wu={xs:148,sm:164,md:184},ju={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 qu({value:e,options:r,onChange:n,size:a="sm",disabled:s=!1,loading:l=!1,stopPropagation:i=!1,ariaLabel:c="Cambiar estado",title:d="Cambiar estado",className:u,selectClassName:m,menuClassName:b,optionClassName:f,spinnerClassName:g}){const[v,k]=o.useState(!1),[h,A]=o.useState(!1),[$,N]=o.useState(-1),[T,x]=o.useState({}),y=o.useRef(null),L=o.useRef(null),w=o.useRef(null),W=r.find(U=>U.value===e)??r[0],X={...W!=null&&W.tone?pl[W.tone]:void 0,...W==null?void 0:W.style},Z=s||l||r.length===0,D=U=>{i&&U.stopPropagation()},Q=o.useCallback(()=>{k(!1),N(-1)},[]),j=o.useCallback(()=>{const U=y.current;if(!U)return;const J=U.getBoundingClientRect(),ce=Math.max(J.width,Wu[a]),C=Math.min(Math.max(r.length,1)*38+12,260),_=window.innerHeight-J.bottom,ae=_<C&&J.top>_,B=Math.min(Math.max(8,J.left+J.width/2-ce/2),window.innerWidth-ce-8);x({position:"fixed",left:B,top:ae?void 0:J.bottom+6,bottom:ae?window.innerHeight-J.top+6:void 0,width:ce,zIndex:9999})},[r.length,a]),se=o.useCallback(U=>{U.disabled||(n(U.value),Q())},[Q,n]);o.useEffect(()=>A(!0),[]),o.useEffect(()=>{if(!v)return;j();const U=r.findIndex(J=>J.value===e);N(U>=0?U:0)},[v,r,j,e]),o.useEffect(()=>{if(!v)return;function U(J){var C,_;const ce=J.target;!((C=y.current)!=null&&C.contains(ce))&&!((_=L.current)!=null&&_.contains(ce))&&Q()}return document.addEventListener("mousedown",U),()=>document.removeEventListener("mousedown",U)},[Q,v]),o.useEffect(()=>{if(v)return window.addEventListener("resize",j),window.addEventListener("scroll",j,!0),()=>{window.removeEventListener("resize",j),window.removeEventListener("scroll",j,!0)}},[v,j]),o.useEffect(()=>{if($<0||!w.current)return;const U=w.current.children[$];U==null||U.scrollIntoView({block:"nearest"})},[$]);function te(U){if(!Z){if(!v){["Enter"," ","ArrowDown","ArrowUp"].includes(U.key)&&(U.preventDefault(),k(!0));return}if(U.key==="Escape"){U.preventDefault(),Q();return}if(U.key==="ArrowDown"){U.preventDefault(),N(J=>Math.min(J+1,r.length-1));return}if(U.key==="ArrowUp"){U.preventDefault(),N(J=>Math.max(J-1,0));return}if(U.key==="Enter"||U.key===" "){U.preventDefault();const J=r[$];J&&se(J)}}}const ee=t.jsx("div",{ref:L,role:"listbox","aria-label":c,className:Vt("overflow-hidden rounded-xl border shadow-xl backdrop-blur-md",b),style:{...T,background:"color-mix(in srgb, var(--bg-card) 92%, transparent)",borderColor:"var(--border)",color:"var(--text-main)"},onClick:D,onMouseDown:D,onPointerDown:D,children:t.jsx("div",{ref:w,className:"max-h-64 overflow-y-auto p-1",style:{scrollbarWidth:"thin",scrollbarColor:"var(--border) transparent",overscrollBehavior:"contain"},children:r.map((U,J)=>{const ce=U.value===e,C=J===$,_={...U.tone?pl[U.tone]:void 0,...U.style};return t.jsxs("button",{type:"button",role:"option","aria-selected":ce,disabled:U.disabled,onMouseEnter:()=>!U.disabled&&N(J),onMouseDown:ae=>{ae.preventDefault(),se(U)},className:Vt("flex w-full items-center gap-2 rounded-lg font-medium text-left transition-colors disabled:cursor-not-allowed disabled:opacity-45",ju[a],ce?U.className:void 0,f),style:{...ce?_:void 0,background:ce?_.background??"color-mix(in srgb, var(--primary) 12%, transparent)":C?"var(--bg-hover)":"transparent",color:ce?_.color??"var(--primary)":"var(--text-main)"},children:[t.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center",children:ce?t.jsx(q.HiCheck,{className:"h-4 w-4"}):null}),t.jsx("span",{className:"min-w-0 flex-1 truncate",children:U.label})]},U.value)})})});return t.jsxs("span",{ref:y,className:Vt("relative inline-flex shrink-0 items-center",u),onKeyDown:te,onClick:D,onPointerDown:D,children:[t.jsx("button",{type:"button",disabled:Z,"aria-label":c,"aria-haspopup":"listbox","aria-expanded":v,title:d,onClick:()=>!Z&&k(U=>!U),className:Vt("inline-flex items-center rounded-full border border-transparent font-medium leading-none outline-none transition-colors hover:border-current focus:border-current disabled:cursor-wait disabled:opacity-70",_u[a],W==null?void 0:W.className,m),style:X,children:t.jsx("span",{className:"min-w-0 truncate",children:(W==null?void 0:W.label)??e})}),t.jsx(q.HiChevronDown,{"aria-hidden":"true",className:Vt("pointer-events-none absolute opacity-70 transition-transform",zu[a],v?"rotate-180":"rotate-0")}),l&&t.jsx("span",{"aria-hidden":"true",className:Vt("absolute -right-1 -top-1 h-2.5 w-2.5 rounded-full border border-current border-t-transparent animate-spin",g)}),v&&h&&ct.createPortal(ee,document.body)]})}function Uu({tabs:e,activeTabId:r,defaultActiveTabId:n,onTabChange:a,ariaLabel:s="Pestanas",variant:l="underline",className:i="",listClassName:c="",panelClassName:d=""}){const u=e.find(v=>!v.disabled)??e[0],m=r??n??(u==null?void 0:u.id),b=e.find(v=>v.id===m)??u,f=v=>{v.disabled||a==null||a(v.id)},g=v=>{const k=e.filter(A=>!A.disabled);if(!k.length||!b)return;const h=k.findIndex(A=>A.id===b.id);(v.key==="ArrowRight"||v.key==="ArrowDown")&&(v.preventDefault(),f(k[(h+1)%k.length])),(v.key==="ArrowLeft"||v.key==="ArrowUp")&&(v.preventDefault(),f(k[(h-1+k.length)%k.length])),v.key==="Home"&&(v.preventDefault(),f(k[0])),v.key==="End"&&(v.preventDefault(),f(k[k.length-1]))};return t.jsxs("div",{className:i,children:[t.jsx("div",{role:"tablist","aria-label":s,onKeyDown: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(v=>{const k=v.id===(b==null?void 0:b.id);return t.jsxs("button",{type:"button",role:"tab","aria-selected":k,"aria-controls":`${v.id}-panel`,id:`${v.id}-tab`,disabled:v.disabled,tabIndex:k?0:-1,onClick:()=>f(v),className:`inline-flex min-h-8 shrink-0 items-center justify-center gap-1.5 whitespace-nowrap px-2.5 text-sm font-semibold transition-colors focus:outline-none disabled:cursor-not-allowed disabled:opacity-50 ${l==="underline"?"border-b-2":"rounded-md border"}`,style:{color:k?"var(--primary)":"var(--text-muted)",borderColor:k?"var(--primary)":"transparent",background:l==="pills"&&k?"var(--bg-card)":"transparent"},children:[v.icon&&t.jsx("span",{className:"shrink-0",children:v.icon}),t.jsx("span",{children:v.label}),v.badge&&t.jsx("span",{className:"shrink-0",children:v.badge})]},v.id)})}),(b==null?void 0:b.content)!==void 0&&t.jsx("div",{role:"tabpanel",id:`${b.id}-panel`,"aria-labelledby":`${b.id}-tab`,className:`pt-4 ${d}`,children:b.content})]})}function Gt(...e){return e.filter(Boolean).join(" ")}function Vu({steps:e,activeStepId:r,initialStepId:n,completedStepIds:a,defaultCompletedStepIds:s=[],onActiveStepChange:l,onCompletedStepIdsChange:i,onBlockedStep:c,allowBackNavigation:d=!0,showFooter:u=!0,previousLabel:m="Anterior",nextLabel:b="Siguiente",blockedNextLabel:f="Completa este paso",className:g="",headerClassName:v="",contentClassName:k="",footerClassName:h=""}){var K;const A=((K=e[0])==null?void 0:K.id)??"",[$,N]=o.useState(n??A),[T,x]=o.useState(s),y=r??$,L=a??T,w=o.useMemo(()=>new Set(L),[L]),W=Math.max(0,e.findIndex(Y=>Y.id===y)),X=e[W]??e[0],Z=e.length<=1?100:W/(e.length-1)*100,D=Y=>{a||x(Y),i==null||i(Y)},Q=Y=>{const S=e.find(H=>H.id===Y);S&&(r||N(Y),l==null||l(Y,S))},j=Y=>w.has(Y),se=Y=>e.slice(0,Y).find(S=>!S.optional&&!w.has(S.id)),te=Y=>{const S=e[Y];return!S||S.disabled?!1:Y===W||d&&Y<W?!0:!se(Y)},ee=Y=>{const S=e.findIndex(H=>H.id===Y);return S>=0&&te(S)},U=Y=>{const S=e.findIndex(H=>H.id===Y);if(S<0)return!1;if(!te(S)){const H=se(S);return H&&(c==null||c(e[S],H)),!1}return Q(Y),!0},J=(Y=X==null?void 0:X.id)=>{!Y||w.has(Y)||D([...L,Y])},ce=(Y=X==null?void 0:X.id)=>{if(!Y)return;const S=e.findIndex(O=>O.id===Y),H=L.filter(O=>{const re=e.findIndex(z=>z.id===O);return re>=0&&re<S});D(H),S>=0&&W>S&&Q(Y)},C=()=>W<=0?!1:U(e[W-1].id),_=()=>{const Y=e[W+1];return Y?U(Y.id):!1},ae={activeStep:X,activeIndex:W,completedStepIds:L,isCompleted:j,isUnlocked:ee,completeStep:J,uncompleteStep:ce,goToStep:U,goNext:_,goPrevious:C};if(!X)return null;const B=e[W+1],I=W>0,E=B?ee(B.id):!1,oe=typeof X.content=="function"?X.content(ae):X.content;return t.jsxs("section",{className:Gt("overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)]",g),children:[t.jsxs("div",{className:Gt("border-b border-[var(--border)] bg-[var(--bg-input)]",v),children:[t.jsx("div",{className:"relative h-1 overflow-hidden bg-[var(--border)]/55",children:t.jsx("div",{className:"h-full rounded-r-full bg-[var(--primary)] transition-[width] duration-500 ease-out",style:{width:`${Z}%`}})}),t.jsx("div",{className:"grid gap-2 p-2",style:{gridTemplateColumns:`repeat(${e.length}, minmax(0, 1fr))`},children:e.map((Y,S)=>{const H=Y.id===X.id,O=j(Y.id),re=te(S),z=se(S);return t.jsxs("button",{type:"button",disabled:!re,"aria-current":H?"step":void 0,"aria-disabled":!re,title:!re&&z?`Completa ${z.title}`:Y.title,onClick:()=>U(Y.id),className:Gt("group relative min-h-16 min-w-0 overflow-hidden rounded-md border p-3 text-left transition-all duration-200 focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--primary)]/35 disabled:cursor-not-allowed",H&&"border-[var(--primary)] bg-[var(--bg-card)] shadow-sm",O&&!H&&"border-[var(--primary)]/35 bg-[var(--bg-card)]",!H&&!O&&re&&"border-transparent bg-[var(--bg-card)]/45 hover:border-[var(--border)] hover:bg-[var(--bg-card)]",!re&&"border-transparent bg-[var(--bg-card)]/35 opacity-60"),children:[t.jsx("span",{className:Gt("absolute inset-x-0 top-0 h-0.5 origin-left scale-x-0 bg-[var(--primary)] transition-transform duration-300",H&&"scale-x-100")}),t.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[t.jsx("span",{className:Gt("grid h-7 w-7 shrink-0 place-items-center rounded-full border text-xs font-bold transition-all duration-200",H&&"border-[var(--primary)] bg-[var(--primary)] text-[var(--primary-fg)]",O&&!H&&"border-[var(--primary)] bg-[var(--primary)]/12 text-[var(--primary)]",!O&&!H&&re&&"border-[var(--border)] text-[var(--text-muted)]",!re&&"border-[var(--border)] text-[var(--text-muted)]"),children:O?t.jsx(q.HiCheck,{className:"h-4 w-4"}):re?S+1:t.jsx(q.HiLockClosed,{className:"h-3.5 w-3.5"})}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsxs("span",{className:Gt("block truncate text-xs font-semibold transition-colors duration-200",H?"text-[var(--text-main)]":"text-[var(--text-secondary)]"),children:[S+1,". ",Y.title]}),Y.description&&t.jsx("span",{className:"mt-1 block truncate text-[11px] text-[var(--text-muted)]",children:Y.description})]}),Y.badge&&t.jsx("span",{className:"shrink-0",children:Y.badge})]})]},Y.id)})})]}),t.jsx("div",{className:Gt("min-h-72 animate-[stepWizardIn_220ms_ease-out] p-5",k),children:oe},X.id),u&&t.jsxs("div",{className:Gt("flex flex-wrap items-center justify-between gap-3 border-t border-[var(--border)] bg-[var(--bg-input)] px-4 py-3",h),children:[t.jsx(Ue,{variant:"secondary",height:38,padding:"0 14px",icon:t.jsx(q.HiChevronLeft,{}),disabled:!I,onClick:C,children:m}),t.jsxs("div",{className:"flex items-center gap-3 text-xs text-[var(--text-muted)]",children:[t.jsxs("span",{children:["Paso ",W+1," de ",e.length]}),t.jsx("span",{className:"h-1 w-1 rounded-full bg-[var(--border)]"}),t.jsxs("span",{children:[L.length," completados"]})]}),t.jsx(Ue,{height:38,padding:"0 14px",icon:t.jsx(q.HiChevronRight,{}),disabled:!B||!E,onClick:_,children:B&&!E?f:b})]})]})}const Yu={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 Xu(e,r){if(e){if(typeof e=="function"){e(r);return}e.current=r}}function Ku(e){const r=getComputedStyle(e),n=Number.parseFloat(r.lineHeight),a=Number.parseFloat(r.paddingTop)+Number.parseFloat(r.paddingBottom),s=Number.parseFloat(r.borderTopWidth)+Number.parseFloat(r.borderBottomWidth);return{lineHeight:Number.isFinite(n)?n:20,paddingY:Number.isFinite(a)?a:12,borderY:Number.isFinite(s)?s:2}}function hl(e,r){const{lineHeight:n,paddingY:a,borderY:s}=Ku(e);return Math.ceil(r*n+a+s)}const gl=o.forwardRef(function({className:r="",size:n="md",status:a="default",maxHeight:s,maxRows:l,minRows:i=1,style:c,value:d,defaultValue:u,onInput:m,...b},f){const g=o.useRef(null),v=a==="error"?"var(--danger)":a==="success"?"#16a34a":"var(--border)",k=o.useCallback(()=>{const h=g.current;if(!h)return;h.style.height="auto";const A=h.scrollHeight,$=hl(h,i),N=s??(l!==void 0?hl(h,l):void 0),T=N!==void 0?Math.min(Math.max(A,$),N):Math.max(A,$);h.style.height=`${T}px`,h.style.overflowY=N!==void 0&&A>N?"auto":"hidden"},[s,l,i]);return o.useLayoutEffect(()=>{k()},[k,d,u]),o.useEffect(()=>{const h=g.current;if(!h||typeof ResizeObserver>"u")return;const A=new ResizeObserver(()=>k());return A.observe(h),()=>A.disconnect()},[k]),t.jsx("textarea",{...b,ref:h=>{g.current=h,Xu(f,h)},rows:i,value:d,defaultValue:u,"aria-invalid":a==="error"||b["aria-invalid"],onInput:h=>{k(),m==null||m(h)},style:{...c,borderColor:v,minHeight:void 0},className:`w-full resize-none overflow-hidden rounded-lg border bg-[var(--bg-input)] text-[var(--text-main)] outline-none placeholder:text-[var(--text-muted)] transition-colors focus:border-[var(--primary)] disabled:cursor-not-allowed disabled:opacity-60 ${Yu[n]} ${r}`})});function Gu({label:e,containerClassName:r="",helperText:n,helperDisplay:a,error:s,labelAction:l,required:i,className:c="",status:d,...u}){return t.jsx(In,{label:e,required:i,helperText:n,helperDisplay:a,error:s,labelAction:l,className:r,children:t.jsx(gl,{...u,required:i,status:s?"error":d,className:`w-full ${c}`})})}const Zu={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"},Qu={none:"resize-none",vertical:"resize-y",horizontal:"resize-x",both:"resize"};function Ju(e,r){if(e){if(typeof e=="function"){e(r);return}e.current=r}}function Ru(e,r){return e!==void 0?String(e).length:r!==void 0?String(r).length:0}const vl=o.forwardRef(function({className:r="",wrapperClassName:n="",size:a="md",resize:s="vertical",autoResize:l=!1,minRows:i,maxRows:c,showCount:d=!1,maxCount:u,status:m="default",icon:b,action:f,style:g,value:v,defaultValue:k,maxLength:h,onInput:A,...$},N){const T=o.useRef(null),x=Ru(v,k),y=u??h,L=!!(b||f||d),w=m==="error"?"var(--danger)":m==="success"?"#16a34a":"var(--border)",W={...g??{},...i?{minHeight:`${i*24+18}px`}:null,...c?{maxHeight:`${c*24+18}px`}:null},X=()=>{const D=T.current;!D||!l||(D.style.height="auto",D.style.height=`${D.scrollHeight}px`)};o.useEffect(X,[l,v]);const Z=t.jsx("textarea",{...$,ref:D=>{T.current=D,Ju(N,D)},value:v,defaultValue:k,maxLength:h,"aria-invalid":m==="error"||$["aria-invalid"],onInput:D=>{X(),A==null||A(D)},style:{...W,borderColor:w},className:`w-full rounded-lg border bg-[var(--bg-input)] text-[var(--text-main)] outline-none placeholder:text-[var(--text-muted)] transition-colors focus:border-[var(--primary)] disabled:cursor-not-allowed disabled:opacity-60 ${Zu[a]} ${Qu[l?"none":s]} ${b?"pl-8":""} ${f?"pr-10":""} ${r}`});return L?t.jsxs("span",{className:`relative block ${n}`,children:[b&&t.jsx("span",{className:"pointer-events-none absolute left-2.5 top-2.5 flex h-4 w-4 items-center justify-center text-[var(--text-muted)]",children:b}),Z,f&&t.jsx("span",{className:"absolute right-2 top-2 flex items-center justify-center",children:f}),d&&t.jsxs("span",{className:"absolute bottom-1.5 right-2 rounded bg-[var(--bg-input)] px-1.5 text-[10px] font-semibold text-[var(--text-muted)]",children:[x,y?`/${y}`:""]})]}):Z});function ef({label:e,containerClassName:r="",helperText:n,helperDisplay:a,error:s,labelAction:l,required:i,className:c="",status:d,...u}){return t.jsx(In,{label:e,required:i,helperText:n,helperDisplay:a,error:s,labelAction:l,className:r,children:t.jsx(vl,{...u,required:i,status:s?"error":d,className:`w-full ${c}`})})}const yl=[{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 yl[e%yl.length]}let rf=0;function bo(){return++rf}function xl(e,r){return r?r instanceof RegExp?r.test(e):r(e):!0}function nf(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(s=>nf(s)).join("|")}|\\r?\\n`,"g");return e.split(a).map(s=>s.trim()).filter(Boolean)}function of({value:e,defaultValue:r,onChange:n,placeholder:a="Escribe y presiona Enter…",disabled:s=!1,className:l="",delimiters:i=[","],maxTags:c,allowDuplicates:d=!1,validate:u,label:m,helperText:b,helperDisplay:f="inline",error:g,required:v=!1}){const k=e!==void 0,h=!!g,A=!!b&&f==="tooltip"&&!h,[$,N]=o.useState(()=>(r??[]).map((O,re)=>({id:bo(),value:O.trim(),colorIndex:re})));o.useEffect(()=>{k&&N(O=>{const re=e??[],z=new Map(O.map(de=>[de.value,de]));return re.map((de,he)=>z.get(de)??{id:bo(),value:de,colorIndex:he})})},[k,e]);const T=$,[x,y]=o.useState(""),[L,w]=o.useState(null),[W,X]=o.useState(""),[Z,D]=o.useState(!1),[Q,j]=o.useState(!1),se=o.useRef(null),te=o.useRef(null),ee=o.useRef(null);function U(){j(!0),setTimeout(()=>j(!1),400)}function J(O){N(O),n==null||n(O.map(re=>re.value))}function ce(O){let re=T,z=!1,de=!1;for(const he of O){const ie=he.trim();if(ie){if(c!==void 0&&re.length>=c){de=!0;break}if(!d&&re.some(ge=>ge.value.toLowerCase()===ie.toLowerCase())){de=!0;continue}if(!xl(ie,u)){de=!0;continue}re=[...re,{id:bo(),value:ie,colorIndex:re.length}],z=!0}}return z&&J(re),de&&U(),z}function C(O){return ce([O])}function _(O){const re=T.filter(z=>z.id!==O);J(re.map((z,de)=>({...z,colorIndex:de})))}function ae(O,re){const z=re.trim();if(w(null),X(""),!z){_(O);return}if(!(!d&&T.some(de=>de.id!==O&&de.value.toLowerCase()===z.toLowerCase()))){if(!xl(z,u)){U();return}J(T.map(de=>de.id===O?{...de,value:z}:de))}}function B(O){s||(w(O.id),X(O.value),setTimeout(()=>{var re;return(re=te.current)==null?void 0:re.select()},0))}function I(O){if(O.key==="Enter"||i.includes(O.key)){O.preventDefault(),C(x)&&y("");return}if(O.key==="Backspace"&&x===""&&T.length>0){O.preventDefault();const re=T[T.length-1];_(re.id)}}function E(O,re){if(O.key==="Enter"){O.preventDefault(),ae(re,W),setTimeout(()=>{var z;return(z=se.current)==null?void 0:z.focus()},0);return}O.key==="Escape"&&(O.preventDefault(),w(null),X(""),setTimeout(()=>{var z;return(z=se.current)==null?void 0:z.focus()},0))}function oe(){var O;s||(O=se.current)==null||O.focus()}function K(O){if(s)return;const re=O.clipboardData.getData("text");if(!re||!(i.some(ie=>ie&&re.includes(ie))||re.includes(`
|
|
31
|
+
`)))return;O.preventDefault();const de=af(re,i);ce(de)&&y("")}function Y(){const O=x.trim();O&&C(O)&&y("")}const S=h?"var(--danger)":Z?"var(--primary)":"var(--border)",H=c!==void 0&&T.length>=c;return t.jsxs("div",{className:`flex flex-col gap-2 ${l}`,children:[(m||v||A)&&t.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-semibold uppercase text-[var(--text-muted)]",children:[m&&t.jsx("span",{children:m}),v&&t.jsx("span",{className:"text-[var(--danger)]",children:"*"}),A?t.jsx(xr,{content:b}):null]}),t.jsxs("div",{ref:ee,onClick:oe,onFocus:()=>D(!0),onBlur:O=>{var re;(re=ee.current)!=null&&re.contains(O.relatedTarget)||(D(!1),L!==null&&ae(L,W),L===null&&Y())},style:{borderColor:S},className:`
|
|
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
|
${s?"cursor-not-allowed opacity-60":"cursor-text"}
|
|
@@ -41,7 +41,7 @@ ${P}`,me=new Blob(["\uFEFF"+ne],{type:"text/csv;charset=utf-8;"}),ke=URL.createO
|
|
|
41
41
|
60% { transform: translateX(-3px); }
|
|
42
42
|
80% { transform: translateX(3px); }
|
|
43
43
|
}
|
|
44
|
-
`}),T.map(O=>{const re=ef(O.colorIndex);return L===O.id?t.jsx("input",{ref:te,value:W,disabled:s,onChange:z=>X(z.target.value),onKeyDown:z=>M(z,O.id),onBlur:()=>ae(O.id,W),className:"min-w-[4rem] rounded border border-[var(--primary)] bg-transparent px-1 py-0.5 text-sm text-[var(--text-main)] outline-none",style:{width:`${Math.max(W.length+2,6)}ch`}},O.id):t.jsxs("span",{className:"inline-flex max-w-[240px] items-center gap-1 rounded-md px-2 py-0.5 text-xs font-medium",style:{backgroundColor:re.bg,color:re.text,border:`1px solid ${re.border}`},children:[t.jsx("span",{className:"truncate",children:O.value}),t.jsx("button",{type:"button","aria-label":`Editar "${O.value}"`,disabled:s,tabIndex:-1,onClick:z=>{z.stopPropagation(),B(O)},className:"flex h-4 w-4 flex-shrink-0 items-center justify-center rounded opacity-60 transition-opacity hover:opacity-100 focus:outline-none disabled:pointer-events-none",children:t.jsx(q.HiPencil,{className:"h-3 w-3"})}),t.jsx("button",{type:"button","aria-label":`Eliminar "${O.value}"`,disabled:s,tabIndex:-1,onClick:z=>{z.stopPropagation(),_(O.id)},className:"flex h-4 w-4 flex-shrink-0 items-center justify-center rounded opacity-60 transition-opacity hover:opacity-100 focus:outline-none disabled:pointer-events-none",children:t.jsx(q.HiXMark,{className:"h-3.5 w-3.5"})})]},O.id)}),!H&&t.jsx("input",{ref:se,value:x,disabled:s,placeholder:T.length===0?a:"",onChange:O=>y(O.target.value),onKeyDown:I,onPaste:K,className:"min-w-[8rem] flex-1 bg-transparent text-sm text-[var(--text-main)] outline-none placeholder:text-[var(--text-muted)] disabled:cursor-not-allowed"})]}),t.jsx(wr,{error:h,helperText:b,helperDisplay:f})]})}const of=/^(\d{1,2}):(\d{2})(?::(\d{2}))?$/;function Je(e){return String(e).padStart(2,"0")}function bo(e,r=Mr()){const n=e.trim();if(!n)return r;const a=n.match(of);if(!a)return r;const s=Number(a[1]),l=Number(a[2]),i=a[3]?Number(a[3]):0;return!Number.isFinite(s)||!Number.isFinite(l)||!Number.isFinite(i)||s<0||s>23||l<0||l>59||i<0||i>59?r:{hour24:s,minute:l,second:i}}function an(e,r=!0){const n=`${Je(e.hour24)}:${Je(e.minute)}`;return r?`${n}:${Je(e.second)}`:n}function Kn(e){const r=e.hour24>=12?"PM":"AM";return{hour12:e.hour24%12===0?12:e.hour24%12,minute:e.minute,second:e.second,meridiem:r}}function on(e){let n=Math.min(12,Math.max(1,e.hour12))%12;return e.meridiem==="PM"&&(n+=12),{hour24:n,minute:Math.min(59,Math.max(0,e.minute)),second:Math.min(59,Math.max(0,e.second))}}function sf(e,r){const n=(r==null?void 0:r.use12Hour)??!1,a=(r==null?void 0:r.showSeconds)??!0,s=bo(e);if(n){const l=Kn(s),i=`${l.hour12}:${Je(l.minute)}`;return`${a?`${i}:${Je(l.second)}`:i} ${l.meridiem}`}return an(s,a)}function Mr(){const e=new Date;return{hour24:e.getHours(),minute:e.getMinutes(),second:e.getSeconds()}}function lf(e=!0){return an(Mr(),e)}function mo(e,r){const n=[];for(let a=e;a<=r;a+=1)n.push(a);return n}const ht=36,po=5,xl=Math.floor(po/2),cf=52,df=48,zt=18;function wl(e){return e*ht}function Nl(e){return Math.round(e/ht)}function uf(e){return e.use12Hour??e.hour12??!1}function Gn({values:e,selected:r,onSelect:n,syncEpochRef:a,forceSyncAt:s=0,width:l=cf,label:i,maxNumeric:c=59,isMeridiem:d=!1,isFocused:u=!1,onFocus:m,onAdvance:b,onBack:f,setColumnRef:h}){const v=o.useRef(null),k=o.useRef(null),g=o.useRef(null),A=o.useRef(""),$=o.useRef(0),N=o.useRef(!1),[T,x]=o.useState(r),[y,L]=o.useState(""),w=o.useCallback(B=>{A.current=B,L(B)},[]),W=o.useMemo(()=>[...Array(xl).fill(""),...e,...Array(xl).fill("")],[e]),X=o.useCallback(()=>{const B=v.current;if(!B)return r;const I=Nl(B.scrollTop),M=Math.min(Math.max(I,0),e.length-1);return e[M]??r},[r,e]),Z=o.useCallback((B,I=!0)=>{const M=Math.min(Math.max(B,0),e.length-1),oe=e[M],K=v.current;!K||!oe||(k.current&&(window.clearTimeout(k.current),k.current=null),N.current=!0,$.current=M,K.scrollTop=wl(M),x(oe),I&&oe!==r&&n(oe))},[n,r,e]);o.useLayoutEffect(()=>{k.current&&(window.clearTimeout(k.current),k.current=null),g.current&&(window.clearTimeout(g.current),g.current=null),w(""),x(r);const B=e.indexOf(r);if(B>=0&&($.current=B),B<0||!v.current)return;const I=wl(B);v.current.scrollTop!==I&&(v.current.scrollTop=I)},[s,r,w,e]);const D=o.useCallback(()=>{g.current&&(window.clearTimeout(g.current),g.current=null)},[]),Q=o.useCallback((B,I=!1)=>{D(),w("");const M=Number(B);if(!Number.isFinite(M))return;const oe=Math.min(c,Math.max(0,M));let K=Je(oe),Y=e.indexOf(K);if(Y<0){const S=Math.min(e.length-1,Math.max(0,oe-(c===12?1:0)));K=e[S]??K,Y=e.indexOf(K)}Y>=0&&Z(Y),I&&(b==null||b())},[D,c,b,Z,w,e]),j=o.useCallback(B=>{const I=Math.floor(c/10),M=A.current;if(M===""){if(B>I){Q(String(B),!0);return}const K=String(B);w(K),g.current=window.setTimeout(()=>{Q(A.current,!0)},1200);return}D();const oe=+`${M}${B}`;oe<=c?Q(String(oe),!0):Q(String(B),!0)},[D,Q,c,w]),se=o.useCallback(B=>{D(),w(""),Z($.current+B)},[D,Z,w]),te=B=>{if(d){B.key==="a"||B.key==="A"?(B.preventDefault(),n("AM"),b==null||b()):B.key==="p"||B.key==="P"?(B.preventDefault(),n("PM"),b==null||b()):B.key==="ArrowUp"||B.key==="ArrowDown"?(B.preventDefault(),n(r==="AM"?"PM":"AM")):B.key==="Tab"&&(B.preventDefault(),B.shiftKey?f==null||f():b==null||b());return}if(/^\d$/.test(B.key)){B.preventDefault(),j(Number(B.key));return}B.key==="ArrowUp"?(B.preventDefault(),se(-1)):B.key==="ArrowDown"?(B.preventDefault(),se(1)):B.key==="Tab"&&(B.preventDefault(),D(),A.current!==""&&Q(A.current,!1),B.shiftKey?f==null||f():b==null||b())},ee=o.useCallback(()=>{const B=a.current,I=v.current;I&&B===a.current&&Z(Nl(I.scrollTop))},[Z,a]),U=()=>{if(A.current!=="")return;if(N.current){N.current=!1;const I=X();x(I);const M=e.indexOf(I);M>=0&&($.current=M);return}x(X()),k.current&&window.clearTimeout(k.current);const B=a.current;k.current=window.setTimeout(()=>{B===a.current&&ee()},100)},J="absolute left-0 right-0 z-40 flex items-center justify-center border-0 bg-transparent p-0 transition-opacity duration-150 hover:opacity-80 focus:outline-none",ce=ht*po,C=ce+zt*2,_=y!==""?y:null,ae=_!==null;return t.jsxs("div",{ref:h,role:"spinbutton",tabIndex:u?0:-1,"aria-label":i,"aria-valuetext":_??r,"aria-valuenow":d?void 0:Number(r),onFocus:m,onMouseDown:()=>m==null?void 0:m(),onKeyDown:te,onBlur:()=>{D(),A.current!==""&&Q(A.current,!1)},className:"relative shrink-0 rounded-lg outline-none",style:{width:l,height:C,boxShadow:u?"0 0 0 2px color-mix(in srgb, var(--primary) 35%, transparent)":"none"},children:[t.jsx("button",{type:"button","aria-label":"Valor anterior",className:J,style:{top:0,height:zt,color:"var(--text-muted)",opacity:.35},onClick:()=>se(-1),children:t.jsx(q.HiChevronUp,{className:"h-3.5 w-3.5"})}),t.jsx("div",{ref:v,className:"absolute inset-x-0 overflow-y-auto [scrollbar-width:none] [-ms-overflow-style:none] [&::-webkit-scrollbar]:hidden",style:{top:zt,height:ce,scrollSnapType:"y mandatory",scrollBehavior:"auto"},onScroll:U,onMouseUp:ee,onTouchEnd:ee,children:W.map((B,I)=>{const M=B!==""&&B===T;return t.jsx("button",{type:"button",tabIndex:-1,disabled:!B,onClick:()=>{if(!B)return;const oe=e.indexOf(B);oe>=0&&Z(oe)},className:"flex w-full items-center justify-center tabular-nums leading-none disabled:cursor-default",style:{height:ht,scrollSnapAlign:"center",color:M?"var(--text-main)":"var(--text-muted)",fontSize:M?16:14,fontWeight:M?600:400,opacity:B?ae?M?0:.35:M?1:.35:0},children:B},`wheel-${I}-${B}`)})}),_!==null?t.jsx("div",{className:"pointer-events-none absolute inset-x-0 z-50 flex items-center justify-center tabular-nums font-semibold leading-none",style:{top:zt+ce/2-ht/2,height:ht,color:"var(--text-main)",fontSize:16,background:"var(--bg-card)"},children:_}):null,t.jsx("button",{type:"button","aria-label":"Valor siguiente",className:J,style:{bottom:0,height:zt,color:"var(--text-muted)",opacity:.35},onClick:()=>se(1),children:t.jsx(q.HiChevronDown,{className:"h-3.5 w-3.5"})})]})}function kl(){return t.jsx("span",{className:"flex shrink-0 items-center justify-center self-center text-base font-medium tabular-nums leading-none",style:{color:"var(--text-muted)",height:ht,width:14,opacity:.45},"aria-hidden":!0,children:":"})}function Sl({value:e,onChange:r,use12Hour:n,hour12:a,showSeconds:s=!1,title:l="Seleccionar hora",variant:i="panel",onCancel:c,onConfirm:d,className:u=""}){const m=i==="popover",b=m||!d,f=uf({use12Hour:n,hour12:a}),h=o.useRef(e),v=bo(e,Mr()),k=Kn(v),[g,A]=o.useState(Je(f?k.hour12:v.hour24)),[$,N]=o.useState(Je(v.minute)),[T,x]=o.useState(Je(v.second)),[y,L]=o.useState(k.meridiem),[w,W]=o.useState(0),X=o.useRef(0),Z=o.useRef(!1),D=o.useRef({hour:null,minute:null,second:null,meridiem:null}),[Q,j]=o.useState("hour"),se=o.useMemo(()=>{const ie=["hour","minute"];return s&&ie.push("second"),f&&ie.push("meridiem"),ie},[f,s]),te=o.useCallback(ie=>{j(ge=>{const Me=se.indexOf(ge);return se[(Me+ie+se.length)%se.length]})},[se]);o.useEffect(()=>{var ie;(ie=D.current[Q])==null||ie.focus()},[Q]),o.useEffect(()=>{var ie;j("hour"),(ie=D.current.hour)==null||ie.focus()},[]),o.useEffect(()=>{if(e===h.current)return;h.current=e;const ie=bo(e,Mr()),ge=Kn(ie);A(Je(f?ge.hour12:ie.hour24)),N(Je(ie.minute)),x(Je(ie.second)),L(ge.meridiem)},[f,e]);const ee=o.useMemo(()=>(f?mo(1,12):mo(0,23)).map(ie=>Je(ie)),[f]),U=o.useMemo(()=>mo(0,59).map(ie=>Je(ie)),[]),J=U,ce=o.useMemo(()=>["AM","PM"],[]),C=o.useCallback(()=>f?on({hour12:Number(g),minute:Number($),second:Number(T),meridiem:y}):{hour24:Number(g),minute:Number($),second:Number(T)},[g,f,y,$,T]),_=o.useCallback(ie=>{if(Z.current)return;const ge=an(ie,s);h.current=ge,r(ge)},[r,s]),ae=o.useCallback(()=>{_(C())},[C,_]),B=ie=>{A(ie),b&&_(f?on({hour12:Number(ie),minute:Number($),second:Number(T),meridiem:y}):{hour24:Number(ie),minute:Number($),second:Number(T)})},I=ie=>{N(ie),b&&_(f?on({hour12:Number(g),minute:Number(ie),second:Number(T),meridiem:y}):{hour24:Number(g),minute:Number(ie),second:Number(T)})},M=ie=>{x(ie),b&&_(f?on({hour12:Number(g),minute:Number($),second:Number(ie),meridiem:y}):{hour24:Number(g),minute:Number($),second:Number(ie)})},oe=ie=>{L(ie),b&&_(on({hour12:Number(g),minute:Number($),second:Number(T),meridiem:ie}))},K=o.useCallback(()=>(X.current+=1,W(X.current),X.current),[]),Y=o.useCallback(ie=>{const ge=Kn(ie),Me=an(ie,s);h.current=Me,A(Je(f?ge.hour12:ie.hour24)),N(Je(ie.minute)),x(Je(ie.second)),L(ge.meridiem),r(Me)},[f,r,s]),S=()=>{Z.current=!0,K(),Y(Mr()),queueMicrotask(()=>{const ie=Mr();an(ie,s)!==h.current&&(K(),Y(ie)),Z.current=!1})},H=()=>{ae(),d==null||d()},O=ht*po,re=O+zt*2,z=zt+O/2-ht/2,de=t.jsx("div",{className:"relative px-4 py-2",children:t.jsxs("div",{className:"relative mx-auto",style:{height:re,maxWidth:"100%"},children:[t.jsx("div",{className:"pointer-events-none absolute inset-x-1 z-10 rounded-xl",style:{top:z,height:ht,background:"color-mix(in srgb, var(--primary) 10%, var(--bg-input))",border:"1px solid color-mix(in srgb, var(--primary) 22%, transparent)"}}),t.jsx("div",{className:"pointer-events-none absolute inset-x-0 z-20",style:{top:zt,height:ht*1.35,background:"linear-gradient(to bottom, var(--bg-card) 40%, transparent 100%)"}}),t.jsx("div",{className:"pointer-events-none absolute inset-x-0 z-20",style:{bottom:zt,height:ht*1.35,background:"linear-gradient(to top, var(--bg-card) 40%, transparent 100%)"}}),t.jsxs("div",{className:"relative z-30 flex h-full items-center justify-center gap-1",children:[t.jsx(Gn,{syncEpochRef:X,forceSyncAt:w,values:ee,selected:g,onSelect:B,label:"Horas",maxNumeric:f?12:23,isFocused:Q==="hour",onFocus:()=>j("hour"),onAdvance:()=>te(1),onBack:()=>te(-1),setColumnRef:ie=>{D.current.hour=ie}}),t.jsx(kl,{}),t.jsx(Gn,{syncEpochRef:X,forceSyncAt:w,values:U,selected:$,onSelect:I,label:"Minutos",maxNumeric:59,isFocused:Q==="minute",onFocus:()=>j("minute"),onAdvance:()=>te(1),onBack:()=>te(-1),setColumnRef:ie=>{D.current.minute=ie}}),s?t.jsxs(t.Fragment,{children:[t.jsx(kl,{}),t.jsx(Gn,{syncEpochRef:X,forceSyncAt:w,values:J,selected:T,onSelect:M,label:"Segundos",maxNumeric:59,isFocused:Q==="second",onFocus:()=>j("second"),onAdvance:()=>te(1),onBack:()=>te(-1),setColumnRef:ie=>{D.current.second=ie}})]}):null,f?t.jsx("div",{className:"ml-3 shrink-0 pl-1",children:t.jsx(Gn,{syncEpochRef:X,forceSyncAt:w,values:ce,selected:y,onSelect:ie=>oe(ie),width:df,label:"AM o PM",isMeridiem:!0,isFocused:Q==="meridiem",onFocus:()=>j("meridiem"),onAdvance:()=>te(1),onBack:()=>te(-1),setColumnRef:ie=>{D.current.meridiem=ie}})}):null]})]})}),he=t.jsxs("div",{className:`flex items-center ${m?"justify-center px-3 py-2":"justify-between gap-2 px-3 py-2.5"}`,style:{borderTop:m?"none":"1px solid color-mix(in srgb, var(--border) 80%, transparent)"},children:[t.jsx(Ue,{variant:"ghost",size:"sm",onClick:S,className:m?"text-xs":void 0,children:"Ahora"}),!m&&(c||d)?t.jsxs("div",{className:"flex items-center gap-2",children:[c?t.jsx(Ue,{variant:"ghost",size:"sm",onClick:c,children:"Cancelar"}):null,d?t.jsx(Ue,{variant:"primary",size:"sm",onClick:H,children:"Listo"}):null]}):null]});return t.jsxs("div",{className:`overflow-hidden ${u}`,style:{borderRadius:m?12:14,border:m?"1px solid color-mix(in srgb, var(--border) 85%, transparent)":"1px solid var(--border)",background:"var(--bg-card)",boxShadow:m?"0 12px 40px rgba(15, 23, 42, 0.14), 0 2px 8px rgba(15, 23, 42, 0.06)":"0 1px 3px rgba(15, 23, 42, 0.06)",minWidth:f?s?300:260:s?252:212},children:[!m&&l?t.jsx("div",{className:"border-b px-3 py-2.5",style:{borderColor:"color-mix(in srgb, var(--border) 80%, transparent)"},children:t.jsx("h3",{className:"text-sm font-semibold",style:{color:"var(--text-main)"},children:l})}):null,de,he]})}function ff(e){return e.use12Hour??e.hour12??!1}function bf({label:e,value:r,onChange:n,use12Hour:a,hour12:s,showSeconds:l=!1,title:i="Seleccionar hora",placeholder:c="Seleccionar hora",disabled:d=!1,displayMode:u="popover",required:m,error:b,helperText:f,helperDisplay:h,className:v,contentClassName:k,className:g=""}){const A=u==="popover",[$,N]=o.useState(!1),T=o.useRef(null),[x,y]=o.useState({horizontal:"left",vertical:"bottom"}),L=ff({use12Hour:a,hour12:s}),w=o.useMemo(()=>r?sf(r,{use12Hour:L,showSeconds:l}):"",[L,l,r]);o.useEffect(()=>{if(!A||!$||!T.current)return;const Z=T.current.getBoundingClientRect(),D=8,Q=L?l?300:260:l?252:212,j=276,se=Z.left+Q>window.innerWidth-D,te=Z.right-Q>=D,ee=Z.bottom+8+j>window.innerHeight-D,U=Z.top-8-j>=D;y({horizontal:se&&te?"right":"left",vertical:ee&&U?"top":"bottom"})},[L,A,$,l]),o.useEffect(()=>{if(!A||!$)return;function Z(Q){T.current&&(T.current.contains(Q.target)||N(!1))}function D(Q){Q.key==="Escape"&&N(!1)}return document.addEventListener("mousedown",Z),document.addEventListener("keydown",D),()=>{document.removeEventListener("mousedown",Z),document.removeEventListener("keydown",D)}},[A,$]);const W=t.jsxs("button",{type:"button",disabled:d,onClick:()=>{d||N(Z=>!Z)},className:`flex h-10 w-full items-center justify-between gap-2 rounded-lg border px-2.5 text-sm transition-all duration-150 focus:outline-none disabled:cursor-not-allowed disabled:opacity-60 ${g}`,style:{background:"var(--bg-input)",borderColor:b?"var(--danger)":$?"var(--primary)":"var(--border)",color:w?"var(--text-main)":"var(--text-muted)",boxShadow:$?"0 0 0 3px color-mix(in srgb, var(--primary) 14%, transparent)":"none"},children:[t.jsxs("span",{className:"inline-flex min-w-0 items-center gap-2",children:[t.jsx(q.HiClock,{className:"h-4 w-4 shrink-0 text-[var(--text-muted)]"}),t.jsx("span",{className:"truncate",children:w||c})]}),A?t.jsx(q.HiChevronDown,{className:`h-4 w-4 shrink-0 text-[var(--text-muted)] transition-transform duration-150 ${$?"rotate-180":""}`}):null]}),X=t.jsx(Sl,{variant:A?"popover":"panel",value:r||lf(l),onChange:n,use12Hour:L,showSeconds:l,title:i,onClose:()=>N(!1)});return t.jsx(In,{label:e,required:m,error:b,helperText:f,helperDisplay:h,className:v,contentClassName:k,children:A?t.jsxs("div",{ref:T,className:"relative w-full",children:[W,$?t.jsx("div",{className:"absolute z-50",style:{...x.horizontal==="left"?{left:0}:{right:0},...x.vertical==="bottom"?{top:"calc(100% + 6px)"}:{bottom:"calc(100% + 6px)"}},children:X}):null]}):t.jsxs("div",{className:"space-y-2",children:[W,$?X:null]})})}const mf={xs:{width:28,height:16,thumb:12,padding:2},sm:{width:36,height:20,thumb:16,padding:2}};function pf({checked:e,disabled:r,onCheckedChange:n,size:a="sm",className:s="",...l}){const i=mf[a],c=e?i.width-i.thumb-i.padding*2:0;return t.jsx("button",{...l,type:"button",role:"switch","aria-checked":e,disabled:r,onClick:()=>!r&&n(!e),className:`relative inline-flex shrink-0 items-center rounded-full transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--primary)]/50 disabled:cursor-not-allowed disabled:opacity-50 ${s}`,style:{width:i.width,height:i.height,background:e?"color-mix(in srgb, var(--primary) 85%, transparent)":"var(--bg-input)",border:e?"1px solid color-mix(in srgb, var(--primary) 55%, transparent)":"1px solid var(--border)"},children:t.jsx("span",{className:"absolute inline-block rounded-full transition-transform",style:{width:i.thumb,height:i.thumb,left:i.padding,top:"50%",transform:`translate(${c}px, -50%)`,background:e?"var(--primary-fg)":"var(--text-muted)"}})})}const Cl=[".sidebar-scroll",".app-scroll",".showcase-nav-scroll","[data-overlay-scroll='true']"].join(","),hf=[":scope > [data-overlayscrollbars-contents]",":scope > .sidebar-scroll-body",":scope > .showcase-nav-scroll-body",":scope > .app-scroll-body"].join(", ");function gf(e){if(!(e instanceof HTMLElement)||e.dataset.overlayScroll==="false"||e.matches("[data-overlayscrollbars]")||e.closest("[data-overlayscrollbars]")||e.matches("textarea,input,select,[contenteditable='true']"))return!1;const r=window.getComputedStyle(e);return!(![r.overflow,r.overflowX,r.overflowY].join(" ").match(/auto|scroll/)||e.clientWidth===0&&e.clientHeight===0)}function El(e){return e.classList.contains("sidebar-scroll")||e.classList.contains("showcase-nav-scroll")}function Ml(e){El(e)&&e.querySelectorAll(".os-scrollbar-horizontal").forEach(r=>{r.style.display="none",r.style.height="0",r.style.pointerEvents="none"})}function vf(e){const r=e.querySelector(hf);return r instanceof HTMLElement?r:null}function Tl(){return o.useEffect(()=>{const e=new WeakMap;let r=0;const n=()=>{r=0,document.querySelectorAll(Cl).forEach(l=>{if(!(l instanceof HTMLElement))return;if(Ea.OverlayScrollbars(l)){Ml(l);return}if(!gf(l))return;const c={overflow:El(l)?{x:"hidden",y:"scroll"}:void 0,scrollbars:{autoHide:"leave",autoHideDelay:180}},d=vf(l),u=d?Ea.OverlayScrollbars({target:l,elements:{viewport:d}},c):Ea.OverlayScrollbars(l,c);Ml(l),e.set(l,u)})},a=()=>{r||(r=window.requestAnimationFrame(n))};n();const s=new MutationObserver(a);return s.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["class","data-overlay-scroll"]}),window.addEventListener("resize",a),()=>{r&&window.cancelAnimationFrame(r),s.disconnect(),window.removeEventListener("resize",a),document.querySelectorAll(Cl).forEach(l=>{var i;l instanceof HTMLElement&&((i=e.get(l))==null||i.destroy())})}},[]),null}function Zt(e){const r=e.trim();return!r||r==="/"||r==="/."?"":(r.startsWith("/")?r:`/${r}`).replace(/\/+$/,"")}function $l(e){try{const r=new URL(e);return Zt(r.pathname)}catch{return""}}function yf(e){const r=Zt(e);if(!r)return"";const n=r.match(/^\/apps\/[^/]+/i);if(n)return Zt(n[0]);const a=r.split("/").filter(Boolean);return a.length===0?"":a.length>=2&&a[0].toLowerCase()==="apps"?Zt(`/${a[0]}/${a[1]}`):new Set(["admin","apps","apps-list","tickets","my-tickets","projects","projects-calendars","dashboard","teams","clients","services","settings","profile","messages","notifications","my-access","my-registers","my-pings","security-incidents","email-inbox","webhook-config","webphone-config","vobo","auth","api","login","forbidden","unauthorized","change-password","reset-password","chat-widget"]).has(a[0].toLowerCase())?"":Zt(`/${a[0]}`)}const ho="primeSuiteAppUrl",xf={xs:{wh:"w-5 h-5",text:"text-[8px]"},sm:{wh:"w-7 h-7",text:"text-[11px]"},md:{wh:"w-9 h-9",text:"text-sm"},lg:{wh:"w-12 h-12",text:"text-base"},xl:{wh:"w-16 h-16",text:"text-xl"}},Al={xs:20,sm:28,md:36,lg:48,xl:64},Ll=["bg-indigo-500","bg-blue-500","bg-emerald-500","bg-violet-500","bg-amber-500","bg-teal-500","bg-rose-500","bg-cyan-500"],wf={xs:"text-xs",sm:"text-sm",md:"text-base",lg:"text-lg"},Nf="bonsaif.bot",kf="Bonsaif Bot",Sf={xs:"p-0.5",sm:"p-1",md:"p-1.5",lg:"p-2",xl:"p-2.5"};function Dl(e){return typeof e=="string"?e.trim():""}function Cf(e){var s;if(e!==void 0)return Zt(e);const r=Zt(typeof process<"u"&&((s=process.env)==null?void 0:s.NEXT_PUBLIC_BASE_PATH)||"");if(r)return r;if(typeof window>"u")return"";try{const i=new URLSearchParams(window.location.search).get(ho)||"";i&&window.sessionStorage.setItem(ho,i);const c=window.sessionStorage.getItem(ho)||"",d=i||c;if(d){const u=$l(d);if(u&&!/^\/admin(\/|$)/i.test(u))return u}}catch{}const n=window.__NEXT_DATA__,a=(n==null?void 0:n.assetPrefix)||"";if(a){const l=a.startsWith("http")?$l(a):Zt(a);if(l&&!/^\/admin(\/|$)/i.test(l))return l}return yf(window.location.pathname)}function Ef(e){const r=e.split(/\s+/).map(n=>n.trim()).filter(Boolean);return r.length===0?"?":r.length===1?r[0].slice(0,1).toUpperCase():`${r[0].slice(0,1)}${r[1].slice(0,1)}`.toUpperCase()}function Mf(e){let r=0;for(const n of e)r=r*31+n.charCodeAt(0)&65535;return Ll[r%Ll.length]}function Tf(e,r){return e===Nf||r===kf}function $f(e,r){return`${e.replace(/\/$/,"")}${r}`}function Il({userId:e,username:r,name:n,size:a="md",showName:s=!1,showTooltip:l,tooltipContent:i,fallbackLabel:c="Usuario",basePath:d,wrapperClassName:u="",labelClassName:m="",labelSize:b="xs",avatarVersion:f=0,className:h="",style:v}){const[k,g]=o.useState(!1),A=typeof e=="string"&&e.trim()&&e!=="undefined"&&e!=="null"?e.trim():"";o.useEffect(()=>{g(!1)},[A,f]);const{wh:$,text:N}=xf[a],T=Dl(n)||Dl(r)||c,x=Ef(T),y=Cf(d),L=Tf(r,n),w=$f(y,"/favicon.svg"),W=o.useMemo(()=>{if(!A)return"";const j=new URLSearchParams;j.set("size",String(Al[a])),f&&j.set("v",String(f));const se=j.toString();return`${y}/api/user/avatar/${encodeURIComponent(A)}${se?`?${se}`:""}`},[f,y,A,a]),X=Al[a],Z=L?t.jsx("span",{className:`${$} ${Sf[a]} rounded-full flex items-center justify-center bg-[#071f1a] ring-1 ring-emerald-400/35 shadow-[0_0_0_1px_rgba(255,255,255,0.06)] flex-shrink-0 ${h}`,style:v,children:t.jsx("img",{src:w,alt:T,width:X,height:X,className:"h-full w-full object-contain"})}):W&&!k?t.jsx("img",{src:W,alt:T,width:X,height:X,className:`${$} rounded-full object-cover flex-shrink-0 ${h}`,style:v,loading:"lazy",referrerPolicy:"no-referrer",onError:()=>g(!0)},`${A}-${f}`):t.jsx("span",{className:`${$} ${Mf(T)} ${N} rounded-full flex items-center justify-center font-black text-white uppercase flex-shrink-0 ${h}`,style:v,title:T,children:x});if(s)return t.jsxs("span",{className:`inline-flex min-w-0 items-center gap-2 ${u}`,children:[Z,t.jsx("span",{className:`min-w-0 truncate ${wf[b]} font-medium text-[var(--text-main)] ${m}`,title:T,children:T})]});const D=l??!0,Q=i??T;return D&&Q?t.jsx(Yt,{as:"span",content:Q,className:`inline-flex flex-shrink-0 ${u}`,children:Z}):Z}function Af({href:e,className:r,children:n}){return t.jsx("a",{href:e,className:r,children:n})}function Lf(e){return e.reduce((r,n)=>{const a=n.section??"Principal";return r[a]=[...r[a]??[],n],r},{})}function Ol({children:e,navItems:r=[],currentPath:n=typeof window>"u"?"/":window.location.pathname,user:a,appName:s="Bonsaif",appLogo:l,header:i,footer:c,onLogout:d,LinkComponent:u=Af}){const[m,b]=o.useState(!1),f=Lf(r);return t.jsxs("div",{className:"min-h-screen bg-[var(--bg-main)] text-[var(--text-main)]",children:[t.jsx(Tl,{}),t.jsx("button",{type:"button","aria-label":"Abrir navegación",className:"fixed left-3 top-3 z-50 inline-flex h-9 w-9 items-center justify-center rounded-md border border-white/10 bg-black/70 text-white lg:hidden",onClick:()=>b(!0),children:t.jsx(q.HiBars3,{className:"h-5 w-5"})}),m&&t.jsx("button",{type:"button","aria-label":"Cerrar navegación",className:"fixed inset-0 z-40 bg-black/45 lg:hidden",onClick:()=>b(!1)}),t.jsxs("aside",{className:`fixed inset-y-0 left-0 z-50 flex w-72 flex-col bg-[#071716] text-white shadow-2xl transition-transform duration-200 lg:translate-x-0 ${m?"translate-x-0":"-translate-x-full"}`,children:[t.jsxs("div",{className:"flex h-16 items-center gap-3 border-b border-white/10 px-4",children:[t.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg bg-white/10 text-white",children:l??t.jsx(q.HiHome,{className:"h-5 w-5"})}),t.jsx("div",{className:"min-w-0 flex-1 truncate text-sm font-semibold",children:s}),t.jsx("button",{type:"button","aria-label":"Cerrar navegación",className:"inline-flex h-8 w-8 items-center justify-center rounded-md text-white/70 hover:bg-white/10 lg:hidden",onClick:()=>b(!1),children:t.jsx(q.HiXMark,{className:"h-5 w-5"})})]}),t.jsx("nav",{className:"sidebar-scroll min-h-0 flex-1 overflow-y-auto px-3 py-4","data-overlay-scroll":"true",children:t.jsx("div",{className:"sidebar-scroll-body",children:Object.entries(f).map(([h,v])=>t.jsxs("div",{className:"mb-5",children:[t.jsxs("div",{className:"mb-2 flex items-center gap-2 px-2 text-[11px] font-semibold uppercase tracking-wide text-white/35",children:[t.jsx(q.HiChevronDown,{className:"h-3.5 w-3.5"}),h]}),t.jsx("div",{className:"space-y-1",children:v.map(k=>{const g=n===k.href||n.startsWith(`${k.href}/`);return t.jsxs(u,{href:k.href,className:`flex min-w-0 items-center gap-2 rounded-md px-2 py-2 text-sm transition-colors ${g?"bg-white/10 text-white":"text-white/55 hover:bg-white/[0.06] hover:text-white/85"}`,children:[t.jsx("span",{className:"flex h-5 w-5 flex-shrink-0 items-center justify-center",children:k.icon??t.jsx(q.HiHome,{className:"h-4 w-4"})}),t.jsx("span",{className:"truncate",children:k.label})]},k.href)})})]},h))})}),t.jsxs("div",{className:"border-t border-white/10 p-3",children:[a&&t.jsxs("div",{className:"mb-3 flex min-w-0 items-center gap-3 rounded-lg bg-white/[0.04] p-2",children:[t.jsx(Il,{name:a.initials??a.name??a.email??"Usuario",size:"md"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"truncate text-sm font-medium text-white",children:a.name??"Usuario"}),a.email&&t.jsx("div",{className:"truncate text-xs text-white/45",children:a.email})]})]}),d&&t.jsxs(Ue,{variant:"ghost",className:"w-full justify-start text-white hover:bg-white/10",onClick:d,children:[t.jsx(q.HiArrowRightOnRectangle,{className:"h-4 w-4"})," Salir"]}),c]})]}),t.jsxs("div",{className:"min-h-screen lg:pl-72",children:[i,t.jsx("main",{className:"min-h-screen",children:e})]})]})}const Hl="bonsaif-ui:prime-auth-sso",Df={dashboard:"Dashboard",tickets:"Tickets",teams:"Equipos",projects:"Proyectos",clients:"Clientes",surveys:"Encuestas",profile:"Perfil",settings:"Configuración",notifications:"Notificaciones",changelog:"Historial",admin:"Inicio",users:"Usuarios",roles:"Roles",menus:"Menús",guards:"Guardias",vacations:"Vacaciones",audit:"Auditoría",positions:"Puestos",ranks:"Rangos","email-inbox":"Buzones","security-incidents":"Incidentes","guard-schedule":"Guardias"},go={dashboard:t.jsx(q.HiChartBar,{className:"h-5 w-5"}),tickets:t.jsx(q.HiTicket,{className:"h-5 w-5"}),teams:t.jsx(q.HiUsers,{className:"h-5 w-5"}),projects:t.jsx(q.HiRectangleGroup,{className:"h-5 w-5"}),clients:t.jsx(q.HiBuildingOffice2,{className:"h-5 w-5"}),surveys:t.jsx(q.HiClipboardDocumentList,{className:"h-5 w-5"}),profile:t.jsx(q.HiUser,{className:"h-5 w-5"}),settings:t.jsx(q.HiCog6Tooth,{className:"h-5 w-5"}),notifications:t.jsx(q.HiBell,{className:"h-5 w-5"}),changelog:t.jsx(q.HiDocumentText,{className:"h-5 w-5"}),admin:t.jsx(q.HiShieldCheck,{className:"h-5 w-5"}),users:t.jsx(q.HiUsers,{className:"h-5 w-5"}),roles:t.jsx(q.HiShieldCheck,{className:"h-5 w-5"}),menus:t.jsx(q.HiCog6Tooth,{className:"h-5 w-5"}),guards:t.jsx(q.HiCalendarDays,{className:"h-5 w-5"}),vacations:t.jsx(q.HiCalendarDays,{className:"h-5 w-5"}),audit:t.jsx(q.HiListBullet,{className:"h-5 w-5"}),positions:t.jsx(q.HiBriefcase,{className:"h-5 w-5"}),ranks:t.jsx(q.HiListBullet,{className:"h-5 w-5"}),"email-inbox":t.jsx(q.HiInbox,{className:"h-5 w-5"}),"security-incidents":t.jsx(q.HiShieldCheck,{className:"h-5 w-5"})};function If(e){return e.split("-").map(r=>r.charAt(0).toUpperCase()+r.slice(1)).join(" ")}function Of(e){return/^\d+$/.test(e)||/^[a-f0-9]{8,}$/i.test(e)}function Hf(e){const r=e.split("/").filter(Boolean);if(r.length===0||r.length===1&&r[0]==="dashboard")return[];const n=decodeURIComponent(r[r.length-1]),a=r.length>1?decodeURIComponent(r[r.length-2]):void 0,s=Of(n)&&a?a:n,l=Df[s]??If(s);return[{label:"Inicio",href:"/"},{label:l}]}function vo(e){return(e==null?void 0:e.querySelector(":scope > .os-viewport"))??(e==null?void 0:e.querySelector(":scope > [data-overlayscrollbars-viewport]"))}function Bf(e){const r=e.split("/").filter(Boolean),n=r[r.length-1];if(!n)return t.jsx(q.HiHome,{className:"h-5 w-5"});if(go[n])return go[n];const a=r.length>1?r[r.length-2]:"";return go[a]??t.jsx(q.HiHome,{className:"h-5 w-5"})}function Ff(e){return e.includes("primeAuthOrigin")||e.includes("primeAuthProjectKey")}function Bl(){if(typeof window>"u")return!1;if(Ff(window.location.href)){try{window.sessionStorage.setItem(Hl,"true")}catch{}return!0}try{return window.sessionStorage.getItem(Hl)==="true"}catch{return!1}}function Pf({title:e,subtitle:r,action:n,meta:a,icon:s,className:l="",contentClassName:i="",breadcrumbs:c,currentPath:d,showBreadcrumbs:u=!0,contained:m=!1}){const b=o.useRef(null),[f,h]=o.useState(!1),[v,k]=o.useState(d??"/"),[g,A]=o.useState(()=>Bl()),[$,N]=o.useState(null),T=d??v,x=c??Hf(T),y=s??Bf(T),L=u&&!g&&x.length>1,w=!L;o.useEffect(()=>{d||k(window.location.pathname)},[d]),o.useEffect(()=>{A(Bl())},[]),o.useEffect(()=>{if(m){h(!1);return}let X=null,Z=0,D=0;const Q=()=>{const te=b.current,ee=document.querySelector("[data-app-scroll='true']");return(te==null?void 0:te.closest(".os-viewport"))??(te==null?void 0:te.closest("[data-overlayscrollbars-viewport]"))??vo(ee)??ee??window},j=()=>{const te=X&&X!==window?X.scrollTop:window.scrollY;h(ee=>ee?te>24:te>72)},se=()=>{X==null||X.removeEventListener("scroll",j),X=Q(),X.addEventListener("scroll",j,{passive:!0}),j()};return se(),Z=window.requestAnimationFrame(se),D=window.setTimeout(se,120),()=>{window.cancelAnimationFrame(Z),window.clearTimeout(D),X==null||X.removeEventListener("scroll",j)}},[m]),o.useEffect(()=>{if(m){N(null);return}let X=0;const Z=[],D=()=>{const J=b.current,ce=J==null?void 0:J.parentElement,C=document.querySelector("[data-app-scroll='true']"),_=vo(C)??C;if(!J||!ce||!_){N(null);return}const ae=ce.getBoundingClientRect(),B=window.getComputedStyle(ce),I=_.getBoundingClientRect(),M=_ instanceof HTMLElement&&_.clientWidth>0?_.clientWidth:I.width,oe=ae.left+parseFloat(B.paddingLeft||"0"),K={marginLeft:Math.round(I.left-oe),width:Math.round(M)};N(Y=>Y&&Y.marginLeft===K.marginLeft&&Y.width===K.width?Y:K)},Q=()=>{window.cancelAnimationFrame(X),X=window.requestAnimationFrame(D)};Q(),window.addEventListener("resize",Q);const j=new ResizeObserver(Q),se=b.current,te=se==null?void 0:se.parentElement,ee=document.querySelector("[data-app-scroll='true']"),U=vo(ee)??ee;return[te,ee,U].forEach(J=>{J&&j.observe(J)}),Z.push(window.setTimeout(Q,120)),Z.push(window.setTimeout(Q,280)),()=>{window.cancelAnimationFrame(X),window.removeEventListener("resize",Q),j.disconnect(),Z.forEach(J=>window.clearTimeout(J))}},[m]);const W={...$?{marginLeft:$.marginLeft,width:$.width}:null,"--page-header-control-height":f?"34px":"40px","--page-header-control-padding-x":f?"10px":"14px","--page-header-control-icon-left":f?"10px":"12px",background:m?"var(--bg-card)":f?"color-mix(in srgb, var(--bg-main) 82%, transparent)":"color-mix(in srgb, var(--bg-main) 58%, transparent)",backdropFilter:"saturate(1.25) blur(18px)",WebkitBackdropFilter:"saturate(1.25) blur(18px)",borderBottom:m||f?"1px solid var(--border)":"1px solid transparent",boxShadow:f?"0 10px 28px rgba(12, 54, 53, 0.12)":"none"};return t.jsx("div",{ref:b,"data-page-header":"true","data-compact":f?"true":"false",className:`sticky top-0 z-30 overflow-visible py-0 transition-[background-color,box-shadow,border-color] duration-300 ease-out ${m?"mb-0 flex-shrink-0":"mb-4 sm:mb-0"} ${l}`,style:W,children:t.jsxs("div",{className:`flex flex-wrap items-center justify-between transition-[gap,min-height,padding] duration-300 ease-out ${f?"min-h-8 gap-1.5 px-3 py-0 sm:min-h-9 sm:gap-2":w?"min-h-9 gap-2 px-4 py-0 sm:min-h-10 sm:gap-2.5":"min-h-10 gap-2.5 px-4 pt-0.5 sm:min-h-11 sm:gap-3"} ${i}`,children:[t.jsx("div",{className:`min-w-0 flex flex-1 flex-col justify-center transition-[gap,transform] duration-300 ease-out ${f||w?"gap-1":"gap-1.5 sm:gap-2"}`,children:t.jsxs("div",{className:`flex min-w-0 items-center transition-[gap,transform] duration-300 ease-out ${f||w?"gap-2":"gap-2.5 sm:gap-3"}`,children:[t.jsx("span",{className:`flex-shrink-0 transition-[color,transform,opacity] duration-300 ease-out ${f?"scale-75 opacity-80":"scale-90 opacity-100"}`,style:{color:L?"var(--text-secondary)":"var(--text-muted)"},children:y}),t.jsxs("div",{className:`flex min-w-0 flex-1 flex-wrap items-center transition-[gap] duration-300 ease-out ${f?"gap-x-2 gap-y-1":"gap-x-3 gap-y-2"}`,children:[t.jsxs("div",{className:"min-w-0 flex-shrink transition-[transform] duration-300 ease-out",children:[t.jsx("h1",{className:`truncate font-bold tracking-tight transition-[font-size,line-height,color] duration-300 ease-out ${f?"text-sm sm:text-base":"text-lg sm:text-xl"}`,style:{color:"var(--text-main)"},children:e}),r&&t.jsx("div",{"aria-hidden":f,className:`overflow-hidden text-xs transition-[max-height,opacity,transform,margin] duration-300 ease-out ${f?"mt-0 max-h-0 -translate-y-1 opacity-0":"mt-0.5 max-h-8 translate-y-0 opacity-100"}`,style:{color:"var(--text-muted)"},children:r})]}),a&&t.jsx("div",{className:`page-header-meta flex min-w-0 flex-1 basis-full items-center overflow-visible transition-[gap,opacity,transform] duration-300 ease-out sm:basis-auto ${f?"translate-y-0 gap-1.5 opacity-95":"gap-2 opacity-100"}`,children:a})]})]})}),n&&t.jsx("div",{className:`page-header-actions ml-auto flex max-w-full flex-shrink-0 flex-wrap items-center justify-end self-center overflow-visible transition-[gap,min-height,opacity,transform] duration-300 ease-out ${f?"min-h-9 gap-1 opacity-95":"min-h-9 gap-1.5 opacity-100"}`,children:t.jsx(Wo.Provider,{value:{compact:!0,headerAction:!0},children:n})})]})})}function _f({children:e,currentPath:r=typeof window>"u"?"/":window.location.pathname,publicRoutes:n=["/","/login","/reset-password"],...a}){return n.includes(r)?t.jsx(t.Fragment,{children:e}):t.jsx(Ol,{currentPath:r,...a,children:e})}function Fl(){if(typeof window>"u")return"system";const e=localStorage.getItem("theme");return e==="light"||e==="dark"?e:e==="system"?"system":document.documentElement.classList.contains("dark")?"dark":"light"}function zf(e,r,n){try{const a=new URL(e),s=a.searchParams.get("callbackUrl");if(s){const l=new URL(s,a.origin);return l.searchParams.set("theme",r),n&&(l.searchParams.set("primeAuthOrigin",window.location.origin),l.searchParams.set("primeAuthProjectKey",n)),a.searchParams.set("callbackUrl",`${l.pathname}${l.search}${l.hash}`),a.toString()}return a.searchParams.set("theme",r),n&&(a.searchParams.set("primeAuthOrigin",window.location.origin),a.searchParams.set("primeAuthProjectKey",n)),a.toString()}catch{return e}}function Wf({name:e,src:r,projectKey:n}){const[a,s]=o.useState("system"),l=o.useRef(null);o.useEffect(()=>{s(Fl());const d=new MutationObserver(()=>s(Fl()));return d.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>d.disconnect()},[]);const i=o.useMemo(()=>zf(r,a,n),[n,r,a]),c=o.useMemo(()=>{try{return new URL(i).origin}catch{return""}},[i]);return o.useEffect(()=>{if(!n)return;const d=n;function u(m){var h,v,k;if(m.source!==((h=l.current)==null?void 0:h.contentWindow)||c&&m.origin!==c)return;if(((v=m.data)==null?void 0:v.type)==="prime-microservice:overlay"){window.dispatchEvent(new CustomEvent("prime-auth:microservice-overlay",{detail:{active:!!m.data.active}}));return}if(((k=m.data)==null?void 0:k.type)!=="prime-microservice:navigation")return;const b=m.data.path;if(!b||!b.startsWith("/")||b.startsWith("//"))return;const f=`/apps/${encodeURIComponent(d)}${b}`;`${window.location.pathname}${window.location.search}${window.location.hash}`!==f&&(window.history.replaceState(window.history.state,"",f),window.dispatchEvent(new CustomEvent("prime-auth:microservice-navigation")))}return window.addEventListener("message",u),()=>{window.removeEventListener("message",u),window.dispatchEvent(new CustomEvent("prime-auth:microservice-overlay",{detail:{active:!1}}))}},[c,n]),t.jsx("div",{className:"flex h-full min-h-screen flex-col bg-[var(--bg-main)]",children:t.jsx("iframe",{ref:l,src:i,title:e,className:"min-h-0 flex-1 border-0 bg-[var(--bg-main)]",allow:"clipboard-write",sandbox:"allow-downloads allow-forms allow-modals allow-popups allow-same-origin allow-scripts",referrerPolicy:"strict-origin-when-cross-origin"})})}function jf(){const[e,r]=o.useState(""),[n,a]=o.useState(!1),[s,l]=o.useState({width:96,height:96});return o.useEffect(()=>{let i=!1;return fetch("/api/microservices/prime-suite/chat-url",{cache:"no-store"}).then(c=>c.ok?c.json():null).then(c=>{!i&&(c!=null&&c.src)&&r(c.src)}).catch(()=>{}),()=>{i=!0}},[]),o.useEffect(()=>{const i=c=>{var u;if(((u=c.data)==null?void 0:u.type)!=="prime-suite-chat:state")return;const d=!!c.data.active;a(d),l({width:Pl(c.data.width,96,720),height:Pl(c.data.height,96,560)})};return window.addEventListener("message",i),()=>window.removeEventListener("message",i)},[]),e?t.jsx("iframe",{title:"Chat Bonsaif",src:e,allow:"clipboard-write",className:"fixed bottom-0 right-0 z-[70] border-0 bg-transparent transition-[width,height] duration-200",style:{width:n?`min(${s.width}px, 100vw)`:96,height:n?`min(${s.height}px, 100vh)`:96,background:"transparent",backgroundColor:"transparent",colorScheme:"normal"}}):null}function Pl(e,r,n){const a=typeof e=="number"&&Number.isFinite(e)?e:r;return Math.max(r,Math.min(n,Math.ceil(a)))}function qf(e){const r=document.documentElement,n=new MutationObserver(e);n.observe(r,{attributes:!0,attributeFilter:["class"]});const a=window.matchMedia("(prefers-color-scheme: dark)");return a.addEventListener("change",e),()=>{n.disconnect(),a.removeEventListener("change",e)}}function Uf(){const e=localStorage.getItem("theme")||"system",r=window.matchMedia("(prefers-color-scheme: dark)").matches;return document.documentElement.classList.contains("dark")||e==="dark"||e==="system"&&r?"dark":"light"}function Vf(){return"light"}function Yf({position:e="bottom-center"}){const r=o.useSyncExternalStore(qf,Uf,Vf);return t.jsx(Ma.Toaster,{position:e,theme:r,richColors:!0,closeButton:!0})}function Xf({title:e,subtitle:r,actions:n,loading:a=!1,empty:s=!1,emptyText:l="Sin datos para mostrar",className:i="",children:c}){return t.jsxs("div",{className:`bonsaif-chart-card w-full overflow-visible ${i}`,children:[(e||r||n)&&t.jsxs("div",{className:"bonsaif-chart-card-head",children:[t.jsx("div",{className:"bonsaif-chart-card-accent","aria-hidden":!0}),t.jsxs("div",{className:"bonsaif-chart-card-copy min-w-0",children:[e?t.jsx("div",{className:"bonsaif-chart-card-title",children:e}):null,r?t.jsx("div",{className:"bonsaif-chart-card-subtitle",children:r}):null]}),n?t.jsx("div",{className:"bonsaif-chart-card-actions shrink-0",children:n}):null]}),t.jsx("div",{className:"bonsaif-chart-card-body",children:a?t.jsx("div",{className:"flex h-48 items-center justify-center",children:t.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-2 border-t-transparent",style:{borderColor:"var(--border)",borderTopColor:"var(--primary)"},"aria-label":"Cargando"})}):s?t.jsx("div",{className:"flex h-48 items-center justify-center text-sm",style:{color:"var(--text-muted)"},children:l}):c})]})}const sn=["var(--primary)","#38bdf8","#34d399","#a78bfa","#2dd4bf","#fbbf24","#60a5fa","#94a3b8"];function _l(e,r){return e.color??sn[r%sn.length]}function Lt(e="primary"){switch(e){case"success":return"#34d399";case"warning":return"#fbbf24";case"danger":return"#f87171";case"neutral":return"var(--text-muted)";default:return"var(--primary)"}}const gt=e=>{if(!Number.isFinite(e))return"—";const r=Math.abs(e);return r>=1e9?`${(e/1e9).toFixed(1).replace(/\.0$/,"")}B`:r>=1e6?`${(e/1e6).toFixed(1).replace(/\.0$/,"")}M`:r>=1e4?`${(e/1e3).toFixed(1).replace(/\.0$/,"")}k`:e.toLocaleString(void 0,{maximumFractionDigits:2})};function Tr(e){if(e==null||e==="")return null;const r=typeof e=="number"?e:Number(e);return Number.isFinite(r)?r:null}const yo={warning:70,danger:90};function Zn(e,r=yo){const n=r.warning??yo.warning,a=r.danger??yo.danger;return e>=a?"danger":e>=n?"warning":e<=0?"primary":"success"}function ln(e,r){return Lt(Zn(e,r))}function $r(e,r=0){return Number.isFinite(e)?`${e.toFixed(r)}%`:"—"}function Ar(e,r=1){if(!Number.isFinite(e))return"—";const n=e<0?"-":"",a=Math.abs(e);if(a<1024)return`${n}${Math.round(a)} B`;const s=["KB","MB","GB","TB","PB"];let l=a/1024,i=0;for(;l>=1024&&i<s.length-1;)l/=1024,i+=1;const c=l>=100?l.toFixed(0):l.toFixed(r);return`${n}${c.replace(/\.0$/,"")} ${s[i]}`}function zl(e,r="bytes",n=1){if(!Number.isFinite(e))return"—";const a=e<0?"-":"",s=Math.abs(e),l=r==="bits"?["b/s","Kb/s","Mb/s","Gb/s","Tb/s"]:["B/s","KB/s","MB/s","GB/s","TB/s"];if(s<1024)return`${a}${Math.round(s)} ${l[0]}`;let i=s/1024,c=1;for(;i>=1024&&c<l.length-1;)i/=1024,c+=1;const d=i>=100?i.toFixed(0):i.toFixed(n);return`${a}${d.replace(/\.0$/,"")} ${l[c]}`}function Lr(e,r){var n;for(let a=e.length-1;a>=0;a-=1){const s=Tr((n=e[a])==null?void 0:n[r]);if(s!==null)return s}return null}function vt({height:e}){return t.jsx("div",{className:"flex items-center justify-center",style:{height:e},"aria-busy":!0,children:t.jsx("div",{className:"h-7 w-7 animate-spin rounded-full border-2",style:{borderColor:"var(--border)",borderTopColor:"var(--primary)"}})})}function yt({height:e,text:r}){return t.jsx("div",{className:"flex items-center justify-center text-sm",style:{height:e,color:"var(--text-muted)"},children:r})}const Qt=680,sr="ease-out",Kf={top:18,right:8,bottom:12,left:0};function cn(e){return{...Kf,...e}}function dn(e){return e.map((r,n)=>({...r,color:_l(r,n),label:r.label??r.key}))}function Qn(e,r){return!e.length||!r.length||e.every(n=>r.every(a=>Tr(n[a.key])===null))}function xt(){return{fill:"var(--text-muted)",fontSize:10,fontWeight:500,letterSpacing:"0.02em"}}function un(){return"color-mix(in srgb, var(--border) 55%, transparent)"}function Wl(){return"color-mix(in srgb, var(--primary) 45%, var(--border))"}function Jn(){return{paddingBottom:12,paddingLeft:4,fontSize:11,fontWeight:600,letterSpacing:"0.04em",textTransform:"uppercase",color:"var(--text-muted)"}}function Gf(e,r=gt){if(e==null||e==="")return"—";const n=typeof e=="number"?e:Number(e);return Number.isFinite(n)?r(n):String(e)}function jl(e){return`bonsaif-grad-${e.replace(/[^a-zA-Z0-9_-]/g,"")}`}function Zf({active:e,label:r,payload:n,valueFormat:a=gt}){var c,d,u,m,b,f;if(!e||!(n!=null&&n.length))return null;const s=n.filter(h=>h.dataKey!=="base"&&h.name!=="base"&&h.value!==null&&h.value!==void 0);if(!s.length)return null;const l=((d=(c=s[0])==null?void 0:c.payload)==null?void 0:d.fullName)??((m=(u=s[0])==null?void 0:u.payload)==null?void 0:m.tooltipLabel)??((f=(b=s[0])==null?void 0:b.payload)==null?void 0:f.display),i=typeof l=="string"&&l.length>0?l:r;return t.jsxs("div",{className:"bonsaif-chart-tooltip-panel",children:[i!=null&&i!==""?t.jsx("div",{className:"bonsaif-chart-tooltip-label",children:String(i)}):null,t.jsx("div",{className:"bonsaif-chart-tooltip-items",children:s.map((h,v)=>{const k=h.payload,g=k&&typeof k.display=="number"?k.display:h.value;return t.jsxs("div",{className:"bonsaif-chart-tooltip-row",children:[t.jsxs("span",{className:"bonsaif-chart-tooltip-name",children:[t.jsx("span",{className:"bonsaif-chart-tooltip-swatch",style:{background:h.color??"var(--primary)"}}),h.name??h.dataKey]}),t.jsx("span",{className:"bonsaif-chart-tooltip-value",children:Gf(g,a)})]},String(h.dataKey??h.name??v))})})]})}function Dr({valueFormat:e,content:r,cursor:n,offset:a=12,wrapperStyle:s,allowEscapeViewBox:l,reverseDirection:i,...c}){return t.jsx(Se.Tooltip,{...c,cursor:n,offset:a,allowEscapeViewBox:l??{x:!1,y:!1},reverseDirection:i??{x:!1,y:!1},wrapperStyle:{outline:"none",zIndex:60,pointerEvents:"none",overflow:"visible",...s},content:r??t.jsx(Zf,{valueFormat:e})})}function ql(e,r,n){return n==null?-1:e.findIndex(a=>String(a[r])===String(n))}function Ul(e,r,n){if(n<=1)return null;const a=Math.max(0,Math.min(e,r)),s=Math.min(n-1,Math.max(e,r));return s-a<1||a===0&&s>=n-1?null:{startIndex:a,endIndex:s}}function Rn(e,r,n={}){const{zoomable:a=!1,zoomMode:s="both",brushHeight:l=28,onZoomChange:i}=n,[c,d]=o.useState(null),[u,m]=o.useState(null),b=!!a&&e.length>1,f=b&&(s==="brush"||s==="both"),h=b&&(s==="drag"||s==="both"),v=o.useCallback(Z=>{d(Z),i==null||i(Z)},[i]),k=o.useCallback(()=>{m(null),v(null)},[v]),g=!!c,A=o.useMemo(()=>!c||f?e:e.slice(c.startIndex,c.endIndex+1),[e,f,c]),$=o.useCallback((Z,D)=>{const Q=ql(e,r,Z),j=ql(e,r,D);Q<0||j<0||v(Ul(Q,j,e.length))},[v,e,r]),N=o.useCallback(Z=>{h&&((Z==null?void 0:Z.activeLabel)===void 0||(Z==null?void 0:Z.activeLabel)===null||m({leftLabel:Z.activeLabel,rightLabel:Z.activeLabel}))},[h]),T=o.useCallback(Z=>{!h||!u||(Z==null?void 0:Z.activeLabel)===void 0||(Z==null?void 0:Z.activeLabel)===null||m(D=>D&&{...D,rightLabel:Z.activeLabel})},[u,h]),x=o.useCallback(()=>{if(h){if(!u||u.rightLabel===null||u.rightLabel===void 0){m(null);return}$(u.leftLabel,u.rightLabel),m(null)}},[$,u,h]),y=o.useCallback(Z=>{if(f){if(!Z){v(null);return}v(Ul(Z.startIndex??0,Z.endIndex??e.length-1,e.length))}},[v,e.length,f]),L=h?{onMouseDown:N,onMouseMove:T,onMouseUp:x,onMouseLeave:()=>{u&&x()}}:{},w=c??{startIndex:0,endIndex:Math.max(0,e.length-1)},W=t.jsxs(t.Fragment,{children:[h&&u&&u.rightLabel!==null&&u.rightLabel!==void 0?t.jsx(Se.ReferenceArea,{x1:u.leftLabel,x2:u.rightLabel,strokeOpacity:.18,fill:"var(--primary)",fillOpacity:.12,stroke:"var(--primary)"}):null,f?t.jsx(Se.Brush,{dataKey:r,height:l,stroke:"var(--primary)",fill:"color-mix(in srgb, var(--primary) 10%, var(--bg-card))",travellerWidth:8,startIndex:w.startIndex,endIndex:w.endIndex,onChange:y,tickFormatter:Z=>String(Z)}):null]}),X=f?{bottom:Math.max(l+10,36)}:void 0;return{enabled:b,showBrush:f,showDrag:h,viewData:A,isZoomed:g,resetZoom:k,chartHandlers:L,zoomNodes:W,marginExtra:X}}function ea({visible:e,onReset:r}){return e?t.jsx("button",{type:"button",className:"bonsaif-chart-zoom-reset",onClick:r,"aria-label":"Restablecer zoom",children:"Restablecer zoom"}):null}function Qf({data:e,xKey:r,series:n,height:a=280,className:s="",loading:l=!1,emptyText:i="Sin datos para mostrar",showGrid:c=!0,showLegend:d=!0,showTooltip:u=!0,margin:m,valueFormat:b=gt,yDomain:f,ariaLabel:h="Gráfico de líneas",curve:v=!0,strokeWidth:k=2.25,zoomable:g=!1,zoomMode:A="both",brushHeight:$,onZoomChange:N}){const T=Qn(e,n),x=dn(n),y=Rn(e,r,{zoomable:g,zoomMode:A,brushHeight:$,onZoomChange:N}),L=cn({...m,...y.marginExtra});return l?t.jsx(vt,{height:a}):T?t.jsx(yt,{height:a,text:i}):t.jsxs("div",{className:`bonsaif-chart bonsaif-line-chart w-full ${s}`,role:"img","aria-label":h,style:{height:a},children:[t.jsx(ea,{visible:y.isZoomed,onReset:y.resetZoom}),t.jsx(Se.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Se.LineChart,{data:y.viewData,margin:L,...y.chartHandlers,children:[c?t.jsx(Se.CartesianGrid,{strokeDasharray:"2 8",stroke:un(),vertical:!1}):null,t.jsx(Se.XAxis,{dataKey:r,tick:xt(),tickLine:!1,axisLine:!1,padding:{left:0,right:0},interval:"preserveStartEnd",minTickGap:52,dy:6}),t.jsx(Se.YAxis,{tick:xt(),tickLine:!1,axisLine:!1,width:44,domain:f??["auto","auto"],tickFormatter:w=>b(Number(w)),dx:-2}),u?t.jsx(Dr,{valueFormat:b,cursor:{stroke:Wl(),strokeWidth:1.25,strokeDasharray:"4 4"}}):null,d?t.jsx(Se.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:Jn()}):null,x.map((w,W)=>t.jsx(Se.Line,{type:v?"monotone":"linear",dataKey:w.key,name:w.label,stroke:w.color,strokeWidth:W===0?k+.35:k,strokeOpacity:W===0?1:.88,isAnimationActive:!0,animationDuration:Qt,animationEasing:sr,dot:!1,activeDot:{r:5,strokeWidth:2,stroke:"var(--bg-card)",fill:w.color}},w.key)),y.zoomNodes]})})]})}function ta({data:e,xKey:r,series:n,height:a=280,className:s="",loading:l=!1,emptyText:i="Sin datos para mostrar",showGrid:c=!0,showLegend:d=!0,showTooltip:u=!0,margin:m,valueFormat:b=gt,yDomain:f,ariaLabel:h="Gráfico de área",stacked:v=!1,opacity:k=.22,zoomable:g=!1,zoomMode:A="both",brushHeight:$,onZoomChange:N}){const T=Qn(e,n),x=dn(n),y=Rn(e,r,{zoomable:g,zoomMode:A,brushHeight:$,onZoomChange:N}),L=cn({...m,...y.marginExtra});return l?t.jsx(vt,{height:a}):T?t.jsx(yt,{height:a,text:i}):t.jsxs("div",{className:`bonsaif-chart bonsaif-area-chart w-full ${s}`,role:"img","aria-label":h,style:{height:a},children:[t.jsx(ea,{visible:y.isZoomed,onReset:y.resetZoom}),t.jsx(Se.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Se.AreaChart,{data:y.viewData,margin:L,...y.chartHandlers,children:[t.jsx("defs",{children:x.map(w=>t.jsxs("linearGradient",{id:jl(w.key),x1:"0",y1:"0",x2:"0",y2:"1",children:[t.jsx("stop",{offset:"0%",stopColor:w.color,stopOpacity:Math.min(.55,k+.28)}),t.jsx("stop",{offset:"48%",stopColor:w.color,stopOpacity:k*.5}),t.jsx("stop",{offset:"100%",stopColor:w.color,stopOpacity:0})]},w.key))}),c?t.jsx(Se.CartesianGrid,{strokeDasharray:"2 8",stroke:un(),vertical:!1}):null,t.jsx(Se.XAxis,{dataKey:r,tick:xt(),tickLine:!1,axisLine:!1,padding:{left:0,right:0},interval:"preserveStartEnd",minTickGap:52,dy:6}),t.jsx(Se.YAxis,{tick:xt(),tickLine:!1,axisLine:!1,width:44,domain:f??["auto","auto"],tickFormatter:w=>b(Number(w)),dx:-2}),u?t.jsx(Dr,{valueFormat:b,cursor:{stroke:Wl(),strokeWidth:1.25,strokeDasharray:"4 4"}}):null,d?t.jsx(Se.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:Jn()}):null,x.map(w=>t.jsx(Se.Area,{type:"monotone",dataKey:w.key,name:w.label,stroke:w.color,fill:`url(#${jl(w.key)})`,strokeWidth:2.25,stackId:v?"stack":void 0,isAnimationActive:!0,animationDuration:Qt,animationEasing:sr,dot:!1,activeDot:{r:5,strokeWidth:2,stroke:"var(--bg-card)",fill:w.color}},w.key)),y.zoomNodes]})})]})}function Jf({data:e,xKey:r,series:n,height:a=280,className:s="",loading:l=!1,emptyText:i="Sin datos para mostrar",showGrid:c=!0,showLegend:d=!0,showTooltip:u=!0,margin:m,valueFormat:b=gt,yDomain:f,ariaLabel:h="Gráfico de barras",layout:v="vertical",mode:k="grouped",barRadius:g=6,categoryAxisWidth:A=64,zoomable:$=!1,zoomMode:N="both",brushHeight:T,onZoomChange:x}){const y=Qn(e,n),L=dn(n),w=v==="horizontal",W=Rn(e,r,{zoomable:$&&!w,zoomMode:N,brushHeight:T,onZoomChange:x}),X=cn({...m,...W.marginExtra});return l?t.jsx(vt,{height:a}):y?t.jsx(yt,{height:a,text:i}):t.jsxs("div",{className:`bonsaif-chart bonsaif-bar-chart w-full ${s}`,role:"img","aria-label":h,style:{height:a},children:[t.jsx(ea,{visible:W.isZoomed,onReset:W.resetZoom}),t.jsx(Se.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Se.BarChart,{data:W.viewData,margin:X,layout:w?"vertical":"horizontal",barCategoryGap:"34%",barGap:3,...W.chartHandlers,children:[c?t.jsx(Se.CartesianGrid,{strokeDasharray:"2 8",stroke:un(),horizontal:!w,vertical:w}):null,w?t.jsxs(t.Fragment,{children:[t.jsx(Se.XAxis,{type:"number",tick:xt(),tickLine:!1,axisLine:!1,tickFormatter:Z=>b(Number(Z)),domain:f??["auto","auto"]}),t.jsx(Se.YAxis,{type:"category",dataKey:r,tick:xt(),tickLine:!1,axisLine:!1,width:A})]}):t.jsxs(t.Fragment,{children:[t.jsx(Se.XAxis,{dataKey:r,tick:xt(),tickLine:!1,axisLine:!1,interval:"preserveStartEnd",minTickGap:36,dy:6}),t.jsx(Se.YAxis,{tick:xt(),tickLine:!1,axisLine:!1,width:44,domain:f??["auto","auto"],tickFormatter:Z=>b(Number(Z)),dx:-2})]}),u?t.jsx(Dr,{valueFormat:b,cursor:{fill:"color-mix(in srgb, var(--primary) 8%, transparent)"}}):null,d?t.jsx(Se.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:Jn()}):null,L.map((Z,D)=>t.jsx(Se.Bar,{dataKey:Z.key,name:Z.label,fill:Z.color,fillOpacity:D===0?1:.82,radius:w?[0,g,g,0]:[g,g,2,2],maxBarSize:20,stackId:k==="stacked"?"stack":void 0,isAnimationActive:!0,animationDuration:Qt,animationEasing:sr},Z.key)),W.zoomNodes]})})]})}function Rf(e){return t.jsx(Yl,{...e,variant:"pie"})}function eb(e){return t.jsx(Yl,{...e,variant:"donut",innerRadius:e.innerRadius??.62,cornerRadius:e.cornerRadius??10,padAngle:e.padAngle??2})}function Vl(e,r){return e==null||!Number.isFinite(e)?r:e>0&&e<=1?e*100:e}function Yl({data:e,nameKey:r,valueKey:n,height:a=280,className:s="",loading:l=!1,emptyText:i="Sin datos para mostrar",showLegend:c=!0,showTooltip:d=!0,valueFormat:u=gt,ariaLabel:m,innerRadius:b,outerRadius:f,colors:h=[...sn],padAngle:v,cornerRadius:k,variant:g}){const A=e.map((D,Q)=>({name:String(D[r]??""),value:Tr(D[n])??0,fill:h[Q%h.length],row:D})).filter(D=>D.value>0),$=!A.length,N=g==="donut",T=A.length,x=Vl(b,N?62:12),y=Vl(f,78),L=Math.min(v??(N?2:3),Math.max(.5,10/Math.max(1,T))),w=Math.min(k??(N?10:8),Math.max(2,36/Math.max(1,T)));if(l)return t.jsx(vt,{height:a});if($)return t.jsx(yt,{height:a,text:i});const W=A.reduce((D,Q)=>D+Q.value,0),X=c?Math.min(96,28+Math.ceil(T/3)*22):0,Z=Math.max(140,a-X);return t.jsx("div",{className:`bonsaif-chart bonsaif-${g}-chart w-full ${s}`,role:"img","aria-label":m??(g==="donut"?"Donut chart":"Pie chart"),style:{height:a},children:t.jsxs("div",{className:"bonsaif-pie-layout",children:[t.jsx("div",{className:"bonsaif-pie-plot",style:{height:Z},children:t.jsx(Se.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Se.PieChart,{margin:{top:4,right:4,bottom:4,left:4},children:[d?t.jsx(Dr,{valueFormat:u,isAnimationActive:!1}):null,t.jsx(Se.Pie,{data:A,dataKey:"value",nameKey:"name",cx:"50%",cy:"50%",innerRadius:`${x}%`,outerRadius:`${y}%`,startAngle:90,endAngle:-270,paddingAngle:L,cornerRadius:w,minAngle:T>6?3:2,stroke:"var(--bg-card)",strokeWidth:2,isAnimationActive:!0,animationDuration:Qt,animationEasing:sr,label:!1,activeShape:tb,children:A.map(D=>t.jsx(Se.Cell,{fill:D.fill},D.name))}),N?t.jsx("text",{x:"50%",y:"50%",textAnchor:"middle",dominantBaseline:"middle",fill:"var(--text-main)",fontSize:18,fontWeight:700,letterSpacing:"-0.02em",children:u(W)}):null]})})}),c?t.jsx("ul",{className:"bonsaif-pie-legend","aria-label":"Leyenda",children:A.map(D=>t.jsxs("li",{className:"bonsaif-pie-legend-item",children:[t.jsx("span",{className:"bonsaif-pie-legend-swatch",style:{background:D.fill},"aria-hidden":!0}),t.jsx("span",{className:"bonsaif-pie-legend-label",title:D.name,children:D.name}),t.jsx("span",{className:"bonsaif-pie-legend-value",children:u(D.value)})]},D.name))}):null]})})}function tb(e){const{outerRadius:r=0,...n}=e;return t.jsx(Se.Sector,{...n,outerRadius:Number(r)+4,stroke:"var(--bg-card)",strokeWidth:2})}function rb({data:e,dataKey:r,width:n="100%",height:a=36,tone:s="primary",color:l,fill:i=!0,className:c="",ariaLabel:d="Sparkline"}){const u=l??Lt(s),m=e.map(y=>Tr(y[r])).filter(y=>y!==null);if(m.length<2)return t.jsx("div",{className:c,style:{width:n,height:a,color:"var(--text-muted)"},"aria-label":d});const b=120,f=36,h=3,v=1,k=Math.min(...m),A=Math.max(...m)-k||1,$=m.map((y,L)=>{const w=v+L/(m.length-1)*(b-v*2),W=f-h-(y-k)/A*(f-h*2);return{x:w,y:W}}),N=$.map((y,L)=>`${L===0?"M":"L"}${y.x.toFixed(2)} ${y.y.toFixed(2)}`).join(" "),T=`${N} L${$[$.length-1].x.toFixed(2)} ${f} L${$[0].x.toFixed(2)} ${f} Z`,x=`bonsaif-spark-${r.replace(/[^a-zA-Z0-9_-]/g,"")}-${s}`;return t.jsx("div",{className:`bonsaif-sparkline ${c}`,style:{width:n,height:a},role:"img","aria-label":d,children:t.jsxs("svg",{width:"100%",height:"100%",viewBox:`0 0 ${b} ${f}`,preserveAspectRatio:"none",focusable:"false",children:[i?t.jsx("defs",{children:t.jsxs("linearGradient",{id:x,x1:"0",y1:"0",x2:"0",y2:"1",children:[t.jsx("stop",{offset:"0%",stopColor:u,stopOpacity:.38}),t.jsx("stop",{offset:"100%",stopColor:u,stopOpacity:0})]})}):null,i?t.jsx("path",{d:T,fill:`url(#${x})`}):null,t.jsx("path",{d:N,fill:"none",stroke:u,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",vectorEffect:"non-scaling-stroke"})]})})}function nb({data:e,xKey:r,series:n,barSeries:a,lineSeries:s,height:l=280,className:i="",loading:c=!1,emptyText:d="Sin datos para mostrar",showGrid:u=!0,showLegend:m=!0,showTooltip:b=!0,margin:f,valueFormat:h=gt,yDomain:v,ariaLabel:k="Gráfico combinado",barRadius:g=6,zoomable:A=!1,zoomMode:$="both",brushHeight:N,onZoomChange:T}){const x=a??n.slice(0,Math.max(1,n.length-1)),y=s??(n.length>1?n.slice(-1):n.length?[n[0]]:[]),L=[...x,...y.filter(j=>!x.some(se=>se.key===j.key))],w=Qn(e,L),W=dn(x),X=dn(L),Z=y.map(j=>{var te;const se=X.find(ee=>ee.key===j.key);return{...j,label:j.label??j.key,color:j.color??(se==null?void 0:se.color)??((te=X[0])==null?void 0:te.color)}}),D=Rn(e,r,{zoomable:A,zoomMode:$,brushHeight:N,onZoomChange:T}),Q=cn({...f,...D.marginExtra});return c?t.jsx(vt,{height:l}):w?t.jsx(yt,{height:l,text:d}):t.jsxs("div",{className:`bonsaif-chart bonsaif-combo-chart w-full ${i}`,role:"img","aria-label":k,style:{height:l},children:[t.jsx(ea,{visible:D.isZoomed,onReset:D.resetZoom}),t.jsx(Se.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Se.ComposedChart,{data:D.viewData,margin:Q,barCategoryGap:"34%",...D.chartHandlers,children:[u?t.jsx(Se.CartesianGrid,{strokeDasharray:"2 8",stroke:un(),vertical:!1}):null,t.jsx(Se.XAxis,{dataKey:r,tick:xt(),tickLine:!1,axisLine:!1,interval:"preserveStartEnd",minTickGap:36,dy:6}),t.jsx(Se.YAxis,{tick:xt(),tickLine:!1,axisLine:!1,width:44,domain:v??["auto","auto"],tickFormatter:j=>h(Number(j)),dx:-2}),b?t.jsx(Dr,{valueFormat:h,cursor:{fill:"color-mix(in srgb, var(--primary) 8%, transparent)"}}):null,m?t.jsx(Se.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:Jn()}):null,W.map(j=>t.jsx(Se.Bar,{dataKey:j.key,name:j.label,fill:j.color,fillOpacity:.88,radius:[g,g,2,2],maxBarSize:18,isAnimationActive:!0,animationDuration:Qt,animationEasing:sr},j.key)),Z.map(j=>t.jsx(Se.Line,{type:"monotone",dataKey:j.key,name:j.label,stroke:j.color,strokeWidth:2.5,isAnimationActive:!0,animationDuration:Qt,animationEasing:sr,dot:!1,activeDot:{r:5,strokeWidth:2,stroke:"var(--bg-card)",fill:j.color}},j.key)),D.zoomNodes]})})]})}function ab({data:e,xKey:r,valueKey:n,typeKey:a,height:s=280,className:l="",loading:i=!1,emptyText:c="Sin datos para mostrar",showGrid:d=!0,showTooltip:u=!0,margin:m,valueFormat:b=gt,ariaLabel:f="Gráfico waterfall",increaseColor:h="#34d399",decreaseColor:v="#f87171",totalColor:k="var(--primary)"}){const g=o.useMemo(()=>ob(e,{xKey:r,valueKey:n,typeKey:a,increaseColor:h,decreaseColor:v,totalColor:k}),[e,r,n,a,h,v,k]),A=!g.length,$=cn(m);return i?t.jsx(vt,{height:s}):A?t.jsx(yt,{height:s,text:c}):t.jsx("div",{className:`bonsaif-chart bonsaif-waterfall-chart w-full ${l}`,role:"img","aria-label":f,style:{height:s},children:t.jsx(Se.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Se.BarChart,{data:g,margin:$,barCategoryGap:"42%",children:[d?t.jsx(Se.CartesianGrid,{strokeDasharray:"2 8",stroke:un(),vertical:!1}):null,t.jsx(Se.XAxis,{dataKey:"label",tick:xt(),tickLine:!1,axisLine:!1,interval:0,dy:6}),t.jsx(Se.YAxis,{tick:xt(),tickLine:!1,axisLine:!1,width:44,tickFormatter:N=>b(Number(N)),dx:-2}),u?t.jsx(Dr,{valueFormat:b,cursor:{fill:"color-mix(in srgb, var(--primary) 8%, transparent)"}}):null,t.jsx(Se.Bar,{dataKey:"base",stackId:"wf",fill:"transparent",isAnimationActive:!1,legendType:"none",maxBarSize:22}),t.jsx(Se.Bar,{dataKey:"delta",name:"Valor",stackId:"wf",radius:[6,6,2,2],maxBarSize:22,isAnimationActive:!0,animationDuration:Qt,animationEasing:sr,children:g.map(N=>t.jsx(Se.Cell,{fill:N.color},N.label))})]})})})}function ob(e,r){let n=0;return e.map((a,s)=>{const l=Tr(a[r.valueKey])??0,i=r.typeKey?String(a[r.typeKey]??""):"",c=i==="total"||s===e.length-1&&i!=="increase"&&i!=="decrease";let d="increase",u=0,m=0,b=l;return c&&i==="total"?(d="total",u=0,m=Math.abs(l),b=l,n=l):c&&s===e.length-1&&!i?(d="total",u=0,m=Math.abs(n),b=n):(d=i==="decrease"||l<0?"decrease":"increase",d==="decrease"?(u=n+l,m=Math.abs(l),n=n+l):(u=n,m=Math.abs(l),n=n+l),b=l),{label:String(a[r.xKey]??""),base:u,delta:m,display:b,kind:d,color:d==="total"?r.totalColor:d==="decrease"?r.decreaseColor:r.increaseColor}})}const Xl="bonsaif-funnel-chart-keyframes",sb=`
|
|
44
|
+
`}),T.map(O=>{const re=tf(O.colorIndex);return L===O.id?t.jsx("input",{ref:te,value:W,disabled:s,onChange:z=>X(z.target.value),onKeyDown:z=>E(z,O.id),onBlur:()=>ae(O.id,W),className:"min-w-[4rem] rounded border border-[var(--primary)] bg-transparent px-1 py-0.5 text-sm text-[var(--text-main)] outline-none",style:{width:`${Math.max(W.length+2,6)}ch`}},O.id):t.jsxs("span",{className:"inline-flex max-w-[240px] items-center gap-1 rounded-md px-2 py-0.5 text-xs font-medium",style:{backgroundColor:re.bg,color:re.text,border:`1px solid ${re.border}`},children:[t.jsx("span",{className:"truncate",children:O.value}),t.jsx("button",{type:"button","aria-label":`Editar "${O.value}"`,disabled:s,tabIndex:-1,onClick:z=>{z.stopPropagation(),B(O)},className:"flex h-4 w-4 flex-shrink-0 items-center justify-center rounded opacity-60 transition-opacity hover:opacity-100 focus:outline-none disabled:pointer-events-none",children:t.jsx(q.HiPencil,{className:"h-3 w-3"})}),t.jsx("button",{type:"button","aria-label":`Eliminar "${O.value}"`,disabled:s,tabIndex:-1,onClick:z=>{z.stopPropagation(),_(O.id)},className:"flex h-4 w-4 flex-shrink-0 items-center justify-center rounded opacity-60 transition-opacity hover:opacity-100 focus:outline-none disabled:pointer-events-none",children:t.jsx(q.HiXMark,{className:"h-3.5 w-3.5"})})]},O.id)}),!H&&t.jsx("input",{ref:se,value:x,disabled:s,placeholder:T.length===0?a:"",onChange:O=>y(O.target.value),onKeyDown:I,onPaste:K,className:"min-w-[8rem] flex-1 bg-transparent text-sm text-[var(--text-main)] outline-none placeholder:text-[var(--text-muted)] disabled:cursor-not-allowed"})]}),t.jsx(wr,{error:g,helperText:b,helperDisplay:f})]})}const sf=/^(\d{1,2}):(\d{2})(?::(\d{2}))?$/;function Je(e){return String(e).padStart(2,"0")}function mo(e,r=Mr()){const n=e.trim();if(!n)return r;const a=n.match(sf);if(!a)return r;const s=Number(a[1]),l=Number(a[2]),i=a[3]?Number(a[3]):0;return!Number.isFinite(s)||!Number.isFinite(l)||!Number.isFinite(i)||s<0||s>23||l<0||l>59||i<0||i>59?r:{hour24:s,minute:l,second:i}}function an(e,r=!0){const n=`${Je(e.hour24)}:${Je(e.minute)}`;return r?`${n}:${Je(e.second)}`:n}function Kn(e){const r=e.hour24>=12?"PM":"AM";return{hour12:e.hour24%12===0?12:e.hour24%12,minute:e.minute,second:e.second,meridiem:r}}function on(e){let n=Math.min(12,Math.max(1,e.hour12))%12;return e.meridiem==="PM"&&(n+=12),{hour24:n,minute:Math.min(59,Math.max(0,e.minute)),second:Math.min(59,Math.max(0,e.second))}}function lf(e,r){const n=(r==null?void 0:r.use12Hour)??!1,a=(r==null?void 0:r.showSeconds)??!0,s=mo(e);if(n){const l=Kn(s),i=`${l.hour12}:${Je(l.minute)}`;return`${a?`${i}:${Je(l.second)}`:i} ${l.meridiem}`}return an(s,a)}function Mr(){const e=new Date;return{hour24:e.getHours(),minute:e.getMinutes(),second:e.getSeconds()}}function cf(e=!0){return an(Mr(),e)}function po(e,r){const n=[];for(let a=e;a<=r;a+=1)n.push(a);return n}const ht=36,ho=5,wl=Math.floor(ho/2),df=52,uf=48,zt=18;function Nl(e){return e*ht}function kl(e){return Math.round(e/ht)}function ff(e){return e.use12Hour??e.hour12??!1}function Gn({values:e,selected:r,onSelect:n,syncEpochRef:a,forceSyncAt:s=0,width:l=df,label:i,maxNumeric:c=59,isMeridiem:d=!1,isFocused:u=!1,onFocus:m,onAdvance:b,onBack:f,setColumnRef:g}){const v=o.useRef(null),k=o.useRef(null),h=o.useRef(null),A=o.useRef(""),$=o.useRef(0),N=o.useRef(!1),[T,x]=o.useState(r),[y,L]=o.useState(""),w=o.useCallback(B=>{A.current=B,L(B)},[]),W=o.useMemo(()=>[...Array(wl).fill(""),...e,...Array(wl).fill("")],[e]),X=o.useCallback(()=>{const B=v.current;if(!B)return r;const I=kl(B.scrollTop),E=Math.min(Math.max(I,0),e.length-1);return e[E]??r},[r,e]),Z=o.useCallback((B,I=!0)=>{const E=Math.min(Math.max(B,0),e.length-1),oe=e[E],K=v.current;!K||!oe||(k.current&&(window.clearTimeout(k.current),k.current=null),N.current=!0,$.current=E,K.scrollTop=Nl(E),x(oe),I&&oe!==r&&n(oe))},[n,r,e]);o.useLayoutEffect(()=>{k.current&&(window.clearTimeout(k.current),k.current=null),h.current&&(window.clearTimeout(h.current),h.current=null),w(""),x(r);const B=e.indexOf(r);if(B>=0&&($.current=B),B<0||!v.current)return;const I=Nl(B);v.current.scrollTop!==I&&(v.current.scrollTop=I)},[s,r,w,e]);const D=o.useCallback(()=>{h.current&&(window.clearTimeout(h.current),h.current=null)},[]),Q=o.useCallback((B,I=!1)=>{D(),w("");const E=Number(B);if(!Number.isFinite(E))return;const oe=Math.min(c,Math.max(0,E));let K=Je(oe),Y=e.indexOf(K);if(Y<0){const S=Math.min(e.length-1,Math.max(0,oe-(c===12?1:0)));K=e[S]??K,Y=e.indexOf(K)}Y>=0&&Z(Y),I&&(b==null||b())},[D,c,b,Z,w,e]),j=o.useCallback(B=>{const I=Math.floor(c/10),E=A.current;if(E===""){if(B>I){Q(String(B),!0);return}const K=String(B);w(K),h.current=window.setTimeout(()=>{Q(A.current,!0)},1200);return}D();const oe=+`${E}${B}`;oe<=c?Q(String(oe),!0):Q(String(B),!0)},[D,Q,c,w]),se=o.useCallback(B=>{D(),w(""),Z($.current+B)},[D,Z,w]),te=B=>{if(d){B.key==="a"||B.key==="A"?(B.preventDefault(),n("AM"),b==null||b()):B.key==="p"||B.key==="P"?(B.preventDefault(),n("PM"),b==null||b()):B.key==="ArrowUp"||B.key==="ArrowDown"?(B.preventDefault(),n(r==="AM"?"PM":"AM")):B.key==="Tab"&&(B.preventDefault(),B.shiftKey?f==null||f():b==null||b());return}if(/^\d$/.test(B.key)){B.preventDefault(),j(Number(B.key));return}B.key==="ArrowUp"?(B.preventDefault(),se(-1)):B.key==="ArrowDown"?(B.preventDefault(),se(1)):B.key==="Tab"&&(B.preventDefault(),D(),A.current!==""&&Q(A.current,!1),B.shiftKey?f==null||f():b==null||b())},ee=o.useCallback(()=>{const B=a.current,I=v.current;I&&B===a.current&&Z(kl(I.scrollTop))},[Z,a]),U=()=>{if(A.current!=="")return;if(N.current){N.current=!1;const I=X();x(I);const E=e.indexOf(I);E>=0&&($.current=E);return}x(X()),k.current&&window.clearTimeout(k.current);const B=a.current;k.current=window.setTimeout(()=>{B===a.current&&ee()},100)},J="absolute left-0 right-0 z-40 flex items-center justify-center border-0 bg-transparent p-0 transition-opacity duration-150 hover:opacity-80 focus:outline-none",ce=ht*ho,C=ce+zt*2,_=y!==""?y:null,ae=_!==null;return t.jsxs("div",{ref:g,role:"spinbutton",tabIndex:u?0:-1,"aria-label":i,"aria-valuetext":_??r,"aria-valuenow":d?void 0:Number(r),onFocus:m,onMouseDown:()=>m==null?void 0:m(),onKeyDown:te,onBlur:()=>{D(),A.current!==""&&Q(A.current,!1)},className:"relative shrink-0 rounded-lg outline-none",style:{width:l,height:C,boxShadow:u?"0 0 0 2px color-mix(in srgb, var(--primary) 35%, transparent)":"none"},children:[t.jsx("button",{type:"button","aria-label":"Valor anterior",className:J,style:{top:0,height:zt,color:"var(--text-muted)",opacity:.35},onClick:()=>se(-1),children:t.jsx(q.HiChevronUp,{className:"h-3.5 w-3.5"})}),t.jsx("div",{ref:v,className:"absolute inset-x-0 overflow-y-auto [scrollbar-width:none] [-ms-overflow-style:none] [&::-webkit-scrollbar]:hidden",style:{top:zt,height:ce,scrollSnapType:"y mandatory",scrollBehavior:"auto"},onScroll:U,onMouseUp:ee,onTouchEnd:ee,children:W.map((B,I)=>{const E=B!==""&&B===T;return t.jsx("button",{type:"button",tabIndex:-1,disabled:!B,onClick:()=>{if(!B)return;const oe=e.indexOf(B);oe>=0&&Z(oe)},className:"flex w-full items-center justify-center tabular-nums leading-none disabled:cursor-default",style:{height:ht,scrollSnapAlign:"center",color:E?"var(--text-main)":"var(--text-muted)",fontSize:E?16:14,fontWeight:E?600:400,opacity:B?ae?E?0:.35:E?1:.35:0},children:B},`wheel-${I}-${B}`)})}),_!==null?t.jsx("div",{className:"pointer-events-none absolute inset-x-0 z-50 flex items-center justify-center tabular-nums font-semibold leading-none",style:{top:zt+ce/2-ht/2,height:ht,color:"var(--text-main)",fontSize:16,background:"var(--bg-card)"},children:_}):null,t.jsx("button",{type:"button","aria-label":"Valor siguiente",className:J,style:{bottom:0,height:zt,color:"var(--text-muted)",opacity:.35},onClick:()=>se(1),children:t.jsx(q.HiChevronDown,{className:"h-3.5 w-3.5"})})]})}function Sl(){return t.jsx("span",{className:"flex shrink-0 items-center justify-center self-center text-base font-medium tabular-nums leading-none",style:{color:"var(--text-muted)",height:ht,width:14,opacity:.45},"aria-hidden":!0,children:":"})}function Cl({value:e,onChange:r,use12Hour:n,hour12:a,showSeconds:s=!1,title:l="Seleccionar hora",variant:i="panel",onCancel:c,onConfirm:d,className:u=""}){const m=i==="popover",b=m||!d,f=ff({use12Hour:n,hour12:a}),g=o.useRef(e),v=mo(e,Mr()),k=Kn(v),[h,A]=o.useState(Je(f?k.hour12:v.hour24)),[$,N]=o.useState(Je(v.minute)),[T,x]=o.useState(Je(v.second)),[y,L]=o.useState(k.meridiem),[w,W]=o.useState(0),X=o.useRef(0),Z=o.useRef(!1),D=o.useRef({hour:null,minute:null,second:null,meridiem:null}),[Q,j]=o.useState("hour"),se=o.useMemo(()=>{const ie=["hour","minute"];return s&&ie.push("second"),f&&ie.push("meridiem"),ie},[f,s]),te=o.useCallback(ie=>{j(ge=>{const Me=se.indexOf(ge);return se[(Me+ie+se.length)%se.length]})},[se]);o.useEffect(()=>{var ie;(ie=D.current[Q])==null||ie.focus()},[Q]),o.useEffect(()=>{var ie;j("hour"),(ie=D.current.hour)==null||ie.focus()},[]),o.useEffect(()=>{if(e===g.current)return;g.current=e;const ie=mo(e,Mr()),ge=Kn(ie);A(Je(f?ge.hour12:ie.hour24)),N(Je(ie.minute)),x(Je(ie.second)),L(ge.meridiem)},[f,e]);const ee=o.useMemo(()=>(f?po(1,12):po(0,23)).map(ie=>Je(ie)),[f]),U=o.useMemo(()=>po(0,59).map(ie=>Je(ie)),[]),J=U,ce=o.useMemo(()=>["AM","PM"],[]),C=o.useCallback(()=>f?on({hour12:Number(h),minute:Number($),second:Number(T),meridiem:y}):{hour24:Number(h),minute:Number($),second:Number(T)},[h,f,y,$,T]),_=o.useCallback(ie=>{if(Z.current)return;const ge=an(ie,s);g.current=ge,r(ge)},[r,s]),ae=o.useCallback(()=>{_(C())},[C,_]),B=ie=>{A(ie),b&&_(f?on({hour12:Number(ie),minute:Number($),second:Number(T),meridiem:y}):{hour24:Number(ie),minute:Number($),second:Number(T)})},I=ie=>{N(ie),b&&_(f?on({hour12:Number(h),minute:Number(ie),second:Number(T),meridiem:y}):{hour24:Number(h),minute:Number(ie),second:Number(T)})},E=ie=>{x(ie),b&&_(f?on({hour12:Number(h),minute:Number($),second:Number(ie),meridiem:y}):{hour24:Number(h),minute:Number($),second:Number(ie)})},oe=ie=>{L(ie),b&&_(on({hour12:Number(h),minute:Number($),second:Number(T),meridiem:ie}))},K=o.useCallback(()=>(X.current+=1,W(X.current),X.current),[]),Y=o.useCallback(ie=>{const ge=Kn(ie),Me=an(ie,s);g.current=Me,A(Je(f?ge.hour12:ie.hour24)),N(Je(ie.minute)),x(Je(ie.second)),L(ge.meridiem),r(Me)},[f,r,s]),S=()=>{Z.current=!0,K(),Y(Mr()),queueMicrotask(()=>{const ie=Mr();an(ie,s)!==g.current&&(K(),Y(ie)),Z.current=!1})},H=()=>{ae(),d==null||d()},O=ht*ho,re=O+zt*2,z=zt+O/2-ht/2,de=t.jsx("div",{className:"relative px-4 py-2",children:t.jsxs("div",{className:"relative mx-auto",style:{height:re,maxWidth:"100%"},children:[t.jsx("div",{className:"pointer-events-none absolute inset-x-1 z-10 rounded-xl",style:{top:z,height:ht,background:"color-mix(in srgb, var(--primary) 10%, var(--bg-input))",border:"1px solid color-mix(in srgb, var(--primary) 22%, transparent)"}}),t.jsx("div",{className:"pointer-events-none absolute inset-x-0 z-20",style:{top:zt,height:ht*1.35,background:"linear-gradient(to bottom, var(--bg-card) 40%, transparent 100%)"}}),t.jsx("div",{className:"pointer-events-none absolute inset-x-0 z-20",style:{bottom:zt,height:ht*1.35,background:"linear-gradient(to top, var(--bg-card) 40%, transparent 100%)"}}),t.jsxs("div",{className:"relative z-30 flex h-full items-center justify-center gap-1",children:[t.jsx(Gn,{syncEpochRef:X,forceSyncAt:w,values:ee,selected:h,onSelect:B,label:"Horas",maxNumeric:f?12:23,isFocused:Q==="hour",onFocus:()=>j("hour"),onAdvance:()=>te(1),onBack:()=>te(-1),setColumnRef:ie=>{D.current.hour=ie}}),t.jsx(Sl,{}),t.jsx(Gn,{syncEpochRef:X,forceSyncAt:w,values:U,selected:$,onSelect:I,label:"Minutos",maxNumeric:59,isFocused:Q==="minute",onFocus:()=>j("minute"),onAdvance:()=>te(1),onBack:()=>te(-1),setColumnRef:ie=>{D.current.minute=ie}}),s?t.jsxs(t.Fragment,{children:[t.jsx(Sl,{}),t.jsx(Gn,{syncEpochRef:X,forceSyncAt:w,values:J,selected:T,onSelect:E,label:"Segundos",maxNumeric:59,isFocused:Q==="second",onFocus:()=>j("second"),onAdvance:()=>te(1),onBack:()=>te(-1),setColumnRef:ie=>{D.current.second=ie}})]}):null,f?t.jsx("div",{className:"ml-3 shrink-0 pl-1",children:t.jsx(Gn,{syncEpochRef:X,forceSyncAt:w,values:ce,selected:y,onSelect:ie=>oe(ie),width:uf,label:"AM o PM",isMeridiem:!0,isFocused:Q==="meridiem",onFocus:()=>j("meridiem"),onAdvance:()=>te(1),onBack:()=>te(-1),setColumnRef:ie=>{D.current.meridiem=ie}})}):null]})]})}),he=t.jsxs("div",{className:`flex items-center ${m?"justify-center px-3 py-2":"justify-between gap-2 px-3 py-2.5"}`,style:{borderTop:m?"none":"1px solid color-mix(in srgb, var(--border) 80%, transparent)"},children:[t.jsx(Ue,{variant:"ghost",size:"sm",onClick:S,className:m?"text-xs":void 0,children:"Ahora"}),!m&&(c||d)?t.jsxs("div",{className:"flex items-center gap-2",children:[c?t.jsx(Ue,{variant:"ghost",size:"sm",onClick:c,children:"Cancelar"}):null,d?t.jsx(Ue,{variant:"primary",size:"sm",onClick:H,children:"Listo"}):null]}):null]});return t.jsxs("div",{className:`overflow-hidden ${u}`,style:{borderRadius:m?12:14,border:m?"1px solid color-mix(in srgb, var(--border) 85%, transparent)":"1px solid var(--border)",background:"var(--bg-card)",boxShadow:m?"0 12px 40px rgba(15, 23, 42, 0.14), 0 2px 8px rgba(15, 23, 42, 0.06)":"0 1px 3px rgba(15, 23, 42, 0.06)",minWidth:f?s?300:260:s?252:212},children:[!m&&l?t.jsx("div",{className:"border-b px-3 py-2.5",style:{borderColor:"color-mix(in srgb, var(--border) 80%, transparent)"},children:t.jsx("h3",{className:"text-sm font-semibold",style:{color:"var(--text-main)"},children:l})}):null,de,he]})}function bf(e){return e.use12Hour??e.hour12??!1}function mf({label:e,value:r,onChange:n,use12Hour:a,hour12:s,showSeconds:l=!1,title:i="Seleccionar hora",placeholder:c="Seleccionar hora",disabled:d=!1,displayMode:u="popover",required:m,error:b,helperText:f,helperDisplay:g,className:v,contentClassName:k,className:h=""}){const A=u==="popover",[$,N]=o.useState(!1),T=o.useRef(null),[x,y]=o.useState({horizontal:"left",vertical:"bottom"}),L=bf({use12Hour:a,hour12:s}),w=o.useMemo(()=>r?lf(r,{use12Hour:L,showSeconds:l}):"",[L,l,r]);o.useEffect(()=>{if(!A||!$||!T.current)return;const Z=T.current.getBoundingClientRect(),D=8,Q=L?l?300:260:l?252:212,j=276,se=Z.left+Q>window.innerWidth-D,te=Z.right-Q>=D,ee=Z.bottom+8+j>window.innerHeight-D,U=Z.top-8-j>=D;y({horizontal:se&&te?"right":"left",vertical:ee&&U?"top":"bottom"})},[L,A,$,l]),o.useEffect(()=>{if(!A||!$)return;function Z(Q){T.current&&(T.current.contains(Q.target)||N(!1))}function D(Q){Q.key==="Escape"&&N(!1)}return document.addEventListener("mousedown",Z),document.addEventListener("keydown",D),()=>{document.removeEventListener("mousedown",Z),document.removeEventListener("keydown",D)}},[A,$]);const W=t.jsxs("button",{type:"button",disabled:d,onClick:()=>{d||N(Z=>!Z)},className:`flex h-10 w-full items-center justify-between gap-2 rounded-lg border px-2.5 text-sm transition-all duration-150 focus:outline-none disabled:cursor-not-allowed disabled:opacity-60 ${h}`,style:{background:"var(--bg-input)",borderColor:b?"var(--danger)":$?"var(--primary)":"var(--border)",color:w?"var(--text-main)":"var(--text-muted)",boxShadow:$?"0 0 0 3px color-mix(in srgb, var(--primary) 14%, transparent)":"none"},children:[t.jsxs("span",{className:"inline-flex min-w-0 items-center gap-2",children:[t.jsx(q.HiClock,{className:"h-4 w-4 shrink-0 text-[var(--text-muted)]"}),t.jsx("span",{className:"truncate",children:w||c})]}),A?t.jsx(q.HiChevronDown,{className:`h-4 w-4 shrink-0 text-[var(--text-muted)] transition-transform duration-150 ${$?"rotate-180":""}`}):null]}),X=t.jsx(Cl,{variant:A?"popover":"panel",value:r||cf(l),onChange:n,use12Hour:L,showSeconds:l,title:i,onClose:()=>N(!1)});return t.jsx(In,{label:e,required:m,error:b,helperText:f,helperDisplay:g,className:v,contentClassName:k,children:A?t.jsxs("div",{ref:T,className:"relative w-full",children:[W,$?t.jsx("div",{className:"absolute z-50",style:{...x.horizontal==="left"?{left:0}:{right:0},...x.vertical==="bottom"?{top:"calc(100% + 6px)"}:{bottom:"calc(100% + 6px)"}},children:X}):null]}):t.jsxs("div",{className:"space-y-2",children:[W,$?X:null]})})}const pf={xs:{width:28,height:16,thumb:12,padding:2},sm:{width:36,height:20,thumb:16,padding:2}};function hf({checked:e,disabled:r,onCheckedChange:n,size:a="sm",className:s="",...l}){const i=pf[a],c=e?i.width-i.thumb-i.padding*2:0;return t.jsx("button",{...l,type:"button",role:"switch","aria-checked":e,disabled:r,onClick:()=>!r&&n(!e),className:`relative inline-flex shrink-0 items-center rounded-full transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--primary)]/50 disabled:cursor-not-allowed disabled:opacity-50 ${s}`,style:{width:i.width,height:i.height,background:e?"color-mix(in srgb, var(--primary) 85%, transparent)":"var(--bg-input)",border:e?"1px solid color-mix(in srgb, var(--primary) 55%, transparent)":"1px solid var(--border)"},children:t.jsx("span",{className:"absolute inline-block rounded-full transition-transform",style:{width:i.thumb,height:i.thumb,left:i.padding,top:"50%",transform:`translate(${c}px, -50%)`,background:e?"var(--primary-fg)":"var(--text-muted)"}})})}const El=[".sidebar-scroll",".app-scroll",".showcase-nav-scroll","[data-overlay-scroll='true']"].join(","),gf=[":scope > [data-overlayscrollbars-contents]",":scope > .sidebar-scroll-body",":scope > .showcase-nav-scroll-body",":scope > .app-scroll-body"].join(", ");function vf(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 Ml(e){return e.classList.contains("sidebar-scroll")||e.classList.contains("showcase-nav-scroll")}function Tl(e){Ml(e)&&e.querySelectorAll(".os-scrollbar-horizontal").forEach(r=>{r.style.display="none",r.style.height="0",r.style.pointerEvents="none"})}function yf(e){const r=e.querySelector(gf);return r instanceof HTMLElement?r:null}function $l(){return o.useEffect(()=>{const e=new WeakMap;let r=0;const n=()=>{r=0,document.querySelectorAll(El).forEach(l=>{if(!(l instanceof HTMLElement))return;if(Ea.OverlayScrollbars(l)){Tl(l);return}if(!vf(l))return;const c={overflow:Ml(l)?{x:"hidden",y:"scroll"}:void 0,scrollbars:{autoHide:"leave",autoHideDelay:180}},d=yf(l),u=d?Ea.OverlayScrollbars({target:l,elements:{viewport:d}},c):Ea.OverlayScrollbars(l,c);Tl(l),e.set(l,u)})},a=()=>{r||(r=window.requestAnimationFrame(n))};n();const s=new MutationObserver(a);return s.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["class","data-overlay-scroll"]}),window.addEventListener("resize",a),()=>{r&&window.cancelAnimationFrame(r),s.disconnect(),window.removeEventListener("resize",a),document.querySelectorAll(El).forEach(l=>{var i;l instanceof HTMLElement&&((i=e.get(l))==null||i.destroy())})}},[]),null}function Zt(e){const r=e.trim();return!r||r==="/"||r==="/."?"":(r.startsWith("/")?r:`/${r}`).replace(/\/+$/,"")}function Al(e){try{const r=new URL(e);return Zt(r.pathname)}catch{return""}}function xf(e){const r=Zt(e);if(!r)return"";const n=r.match(/^\/apps\/[^/]+/i);if(n)return Zt(n[0]);const a=r.split("/").filter(Boolean);return a.length===0?"":a.length>=2&&a[0].toLowerCase()==="apps"?Zt(`/${a[0]}/${a[1]}`):new Set(["admin","apps","apps-list","tickets","my-tickets","projects","projects-calendars","dashboard","teams","clients","services","settings","profile","messages","notifications","my-access","my-registers","my-pings","security-incidents","email-inbox","webhook-config","webphone-config","vobo","auth","api","login","forbidden","unauthorized","change-password","reset-password","chat-widget"]).has(a[0].toLowerCase())?"":Zt(`/${a[0]}`)}const go="primeSuiteAppUrl",wf={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"}},Ll={xs:20,sm:28,md:36,lg:48,xl:64},Dl=["bg-indigo-500","bg-blue-500","bg-emerald-500","bg-violet-500","bg-amber-500","bg-teal-500","bg-rose-500","bg-cyan-500"],Nf={xs:"text-xs",sm:"text-sm",md:"text-base",lg:"text-lg"},kf="bonsaif.bot",Sf="Bonsaif Bot",Cf={xs:"p-0.5",sm:"p-1",md:"p-1.5",lg:"p-2",xl:"p-2.5"};function Il(e){return typeof e=="string"?e.trim():""}function Ef(e){var s;if(e!==void 0)return Zt(e);const r=Zt(typeof process<"u"&&((s=process.env)==null?void 0:s.NEXT_PUBLIC_BASE_PATH)||"");if(r)return r;if(typeof window>"u")return"";try{const i=new URLSearchParams(window.location.search).get(go)||"";i&&window.sessionStorage.setItem(go,i);const c=window.sessionStorage.getItem(go)||"",d=i||c;if(d){const u=Al(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")?Al(a):Zt(a);if(l&&!/^\/admin(\/|$)/i.test(l))return l}return xf(window.location.pathname)}function Mf(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 Tf(e){let r=0;for(const n of e)r=r*31+n.charCodeAt(0)&65535;return Dl[r%Dl.length]}function $f(e,r){return e===kf||r===Sf}function Af(e,r){return`${e.replace(/\/$/,"")}${r}`}function Ol({userId:e,username:r,name:n,size:a="md",showName:s=!1,showTooltip:l,tooltipContent:i,fallbackLabel:c="Usuario",basePath:d,wrapperClassName:u="",labelClassName:m="",labelSize:b="xs",avatarVersion:f=0,className:g="",style:v}){const[k,h]=o.useState(!1),A=typeof e=="string"&&e.trim()&&e!=="undefined"&&e!=="null"?e.trim():"";o.useEffect(()=>{h(!1)},[A,f]);const{wh:$,text:N}=wf[a],T=Il(n)||Il(r)||c,x=Mf(T),y=Ef(d),L=$f(r,n),w=Af(y,"/favicon.svg"),W=o.useMemo(()=>{if(!A)return"";const j=new URLSearchParams;j.set("size",String(Ll[a])),f&&j.set("v",String(f));const se=j.toString();return`${y}/api/user/avatar/${encodeURIComponent(A)}${se?`?${se}`:""}`},[f,y,A,a]),X=Ll[a],Z=L?t.jsx("span",{className:`${$} ${Cf[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:v,children:t.jsx("img",{src:w,alt:T,width:X,height:X,className:"h-full w-full object-contain"})}):W&&!k?t.jsx("img",{src:W,alt:T,width:X,height:X,className:`${$} rounded-full object-cover flex-shrink-0 ${g}`,style:v,loading:"lazy",referrerPolicy:"no-referrer",onError:()=>h(!0)},`${A}-${f}`):t.jsx("span",{className:`${$} ${Tf(T)} ${N} rounded-full flex items-center justify-center font-black text-white uppercase flex-shrink-0 ${g}`,style:v,title:T,children:x});if(s)return t.jsxs("span",{className:`inline-flex min-w-0 items-center gap-2 ${u}`,children:[Z,t.jsx("span",{className:`min-w-0 truncate ${Nf[b]} font-medium text-[var(--text-main)] ${m}`,title:T,children:T})]});const D=l??!0,Q=i??T;return D&&Q?t.jsx(Yt,{as:"span",content:Q,className:`inline-flex flex-shrink-0 ${u}`,children:Z}):Z}function Lf({href:e,className:r,children:n}){return t.jsx("a",{href:e,className:r,children:n})}function Df(e){return e.reduce((r,n)=>{const a=n.section??"Principal";return r[a]=[...r[a]??[],n],r},{})}function Hl({children:e,navItems:r=[],currentPath:n=typeof window>"u"?"/":window.location.pathname,user:a,appName:s="Bonsaif",appLogo:l,header:i,footer:c,onLogout:d,LinkComponent:u=Lf}){const[m,b]=o.useState(!1),f=Df(r);return t.jsxs("div",{className:"min-h-screen bg-[var(--bg-main)] text-[var(--text-main)]",children:[t.jsx($l,{}),t.jsx("button",{type:"button","aria-label":"Abrir navegación",className:"fixed left-3 top-3 z-50 inline-flex h-9 w-9 items-center justify-center rounded-md border border-white/10 bg-black/70 text-white lg:hidden",onClick:()=>b(!0),children:t.jsx(q.HiBars3,{className:"h-5 w-5"})}),m&&t.jsx("button",{type:"button","aria-label":"Cerrar navegación",className:"fixed inset-0 z-40 bg-black/45 lg:hidden",onClick:()=>b(!1)}),t.jsxs("aside",{className:`fixed inset-y-0 left-0 z-50 flex w-72 flex-col bg-[#071716] text-white shadow-2xl transition-transform duration-200 lg:translate-x-0 ${m?"translate-x-0":"-translate-x-full"}`,children:[t.jsxs("div",{className:"flex h-16 items-center gap-3 border-b border-white/10 px-4",children:[t.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg bg-white/10 text-white",children:l??t.jsx(q.HiHome,{className:"h-5 w-5"})}),t.jsx("div",{className:"min-w-0 flex-1 truncate text-sm font-semibold",children:s}),t.jsx("button",{type:"button","aria-label":"Cerrar navegación",className:"inline-flex h-8 w-8 items-center justify-center rounded-md text-white/70 hover:bg-white/10 lg:hidden",onClick:()=>b(!1),children:t.jsx(q.HiXMark,{className:"h-5 w-5"})})]}),t.jsx("nav",{className:"sidebar-scroll min-h-0 flex-1 overflow-y-auto px-3 py-4","data-overlay-scroll":"true",children:t.jsx("div",{className:"sidebar-scroll-body",children:Object.entries(f).map(([g,v])=>t.jsxs("div",{className:"mb-5",children:[t.jsxs("div",{className:"mb-2 flex items-center gap-2 px-2 text-[11px] font-semibold uppercase tracking-wide text-white/35",children:[t.jsx(q.HiChevronDown,{className:"h-3.5 w-3.5"}),g]}),t.jsx("div",{className:"space-y-1",children:v.map(k=>{const h=n===k.href||n.startsWith(`${k.href}/`);return t.jsxs(u,{href:k.href,className:`flex min-w-0 items-center gap-2 rounded-md px-2 py-2 text-sm transition-colors ${h?"bg-white/10 text-white":"text-white/55 hover:bg-white/[0.06] hover:text-white/85"}`,children:[t.jsx("span",{className:"flex h-5 w-5 flex-shrink-0 items-center justify-center",children:k.icon??t.jsx(q.HiHome,{className:"h-4 w-4"})}),t.jsx("span",{className:"truncate",children:k.label})]},k.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(Ol,{name:a.initials??a.name??a.email??"Usuario",size:"md"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"truncate text-sm font-medium text-white",children:a.name??"Usuario"}),a.email&&t.jsx("div",{className:"truncate text-xs text-white/45",children:a.email})]})]}),d&&t.jsxs(Ue,{variant:"ghost",className:"w-full justify-start text-white hover:bg-white/10",onClick:d,children:[t.jsx(q.HiArrowRightOnRectangle,{className:"h-4 w-4"})," Salir"]}),c]})]}),t.jsxs("div",{className:"min-h-screen lg:pl-72",children:[i,t.jsx("main",{className:"min-h-screen",children:e})]})]})}const Bl="bonsaif-ui:prime-auth-sso",If={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"},vo={dashboard:t.jsx(q.HiChartBar,{className:"h-5 w-5"}),tickets:t.jsx(q.HiTicket,{className:"h-5 w-5"}),teams:t.jsx(q.HiUsers,{className:"h-5 w-5"}),projects:t.jsx(q.HiRectangleGroup,{className:"h-5 w-5"}),clients:t.jsx(q.HiBuildingOffice2,{className:"h-5 w-5"}),surveys:t.jsx(q.HiClipboardDocumentList,{className:"h-5 w-5"}),profile:t.jsx(q.HiUser,{className:"h-5 w-5"}),settings:t.jsx(q.HiCog6Tooth,{className:"h-5 w-5"}),notifications:t.jsx(q.HiBell,{className:"h-5 w-5"}),changelog:t.jsx(q.HiDocumentText,{className:"h-5 w-5"}),admin:t.jsx(q.HiShieldCheck,{className:"h-5 w-5"}),users:t.jsx(q.HiUsers,{className:"h-5 w-5"}),roles:t.jsx(q.HiShieldCheck,{className:"h-5 w-5"}),menus:t.jsx(q.HiCog6Tooth,{className:"h-5 w-5"}),guards:t.jsx(q.HiCalendarDays,{className:"h-5 w-5"}),vacations:t.jsx(q.HiCalendarDays,{className:"h-5 w-5"}),audit:t.jsx(q.HiListBullet,{className:"h-5 w-5"}),positions:t.jsx(q.HiBriefcase,{className:"h-5 w-5"}),ranks:t.jsx(q.HiListBullet,{className:"h-5 w-5"}),"email-inbox":t.jsx(q.HiInbox,{className:"h-5 w-5"}),"security-incidents":t.jsx(q.HiShieldCheck,{className:"h-5 w-5"})};function Of(e){return e.split("-").map(r=>r.charAt(0).toUpperCase()+r.slice(1)).join(" ")}function Hf(e){return/^\d+$/.test(e)||/^[a-f0-9]{8,}$/i.test(e)}function Bf(e){const r=e.split("/").filter(Boolean);if(r.length===0||r.length===1&&r[0]==="dashboard")return[];const n=decodeURIComponent(r[r.length-1]),a=r.length>1?decodeURIComponent(r[r.length-2]):void 0,s=Hf(n)&&a?a:n,l=If[s]??Of(s);return[{label:"Inicio",href:"/"},{label:l}]}function yo(e){return(e==null?void 0:e.querySelector(":scope > .os-viewport"))??(e==null?void 0:e.querySelector(":scope > [data-overlayscrollbars-viewport]"))}function Ff(e){const r=e.split("/").filter(Boolean),n=r[r.length-1];if(!n)return t.jsx(q.HiHome,{className:"h-5 w-5"});if(vo[n])return vo[n];const a=r.length>1?r[r.length-2]:"";return vo[a]??t.jsx(q.HiHome,{className:"h-5 w-5"})}function Pf(e){return e.includes("primeAuthOrigin")||e.includes("primeAuthProjectKey")}function Fl(){if(typeof window>"u")return!1;if(Pf(window.location.href)){try{window.sessionStorage.setItem(Bl,"true")}catch{}return!0}try{return window.sessionStorage.getItem(Bl)==="true"}catch{return!1}}function _f({title:e,subtitle:r,action:n,meta:a,icon:s,className:l="",contentClassName:i="",breadcrumbs:c,currentPath:d,showBreadcrumbs:u=!0,contained:m=!1}){const b=o.useRef(null),[f,g]=o.useState(!1),[v,k]=o.useState(d??"/"),[h,A]=o.useState(()=>Fl()),[$,N]=o.useState(null),T=d??v,x=c??Bf(T),y=s??Ff(T),L=u&&!h&&x.length>1,w=!L;o.useEffect(()=>{d||k(window.location.pathname)},[d]),o.useEffect(()=>{A(Fl())},[]),o.useEffect(()=>{if(m){g(!1);return}let X=null,Z=0,D=0;const Q=()=>{const te=b.current,ee=document.querySelector("[data-app-scroll='true']");return(te==null?void 0:te.closest(".os-viewport"))??(te==null?void 0:te.closest("[data-overlayscrollbars-viewport]"))??yo(ee)??ee??window},j=()=>{const te=X&&X!==window?X.scrollTop:window.scrollY;g(ee=>ee?te>24:te>72)},se=()=>{X==null||X.removeEventListener("scroll",j),X=Q(),X.addEventListener("scroll",j,{passive:!0}),j()};return se(),Z=window.requestAnimationFrame(se),D=window.setTimeout(se,120),()=>{window.cancelAnimationFrame(Z),window.clearTimeout(D),X==null||X.removeEventListener("scroll",j)}},[m]),o.useEffect(()=>{if(m){N(null);return}let X=0;const Z=[],D=()=>{const J=b.current,ce=J==null?void 0:J.parentElement,C=document.querySelector("[data-app-scroll='true']"),_=yo(C)??C;if(!J||!ce||!_){N(null);return}const ae=ce.getBoundingClientRect(),B=window.getComputedStyle(ce),I=_.getBoundingClientRect(),E=_ instanceof HTMLElement&&_.clientWidth>0?_.clientWidth:I.width,oe=ae.left+parseFloat(B.paddingLeft||"0"),K={marginLeft:Math.round(I.left-oe),width:Math.round(E)};N(Y=>Y&&Y.marginLeft===K.marginLeft&&Y.width===K.width?Y:K)},Q=()=>{window.cancelAnimationFrame(X),X=window.requestAnimationFrame(D)};Q(),window.addEventListener("resize",Q);const j=new ResizeObserver(Q),se=b.current,te=se==null?void 0:se.parentElement,ee=document.querySelector("[data-app-scroll='true']"),U=yo(ee)??ee;return[te,ee,U].forEach(J=>{J&&j.observe(J)}),Z.push(window.setTimeout(Q,120)),Z.push(window.setTimeout(Q,280)),()=>{window.cancelAnimationFrame(X),window.removeEventListener("resize",Q),j.disconnect(),Z.forEach(J=>window.clearTimeout(J))}},[m]);const W={...$?{marginLeft:$.marginLeft,width:$.width}:null,"--page-header-control-height":f?"34px":"40px","--page-header-control-padding-x":f?"10px":"14px","--page-header-control-icon-left":f?"10px":"12px",background:m?"var(--bg-card)":f?"color-mix(in srgb, var(--bg-main) 82%, transparent)":"color-mix(in srgb, var(--bg-main) 58%, transparent)",backdropFilter:"saturate(1.25) blur(18px)",WebkitBackdropFilter:"saturate(1.25) blur(18px)",borderBottom:m||f?"1px solid var(--border)":"1px solid transparent",boxShadow:f?"0 10px 28px rgba(12, 54, 53, 0.12)":"none"};return t.jsx("div",{ref:b,"data-page-header":"true","data-compact":f?"true":"false",className:`sticky top-0 z-30 overflow-visible py-0 transition-[background-color,box-shadow,border-color] duration-300 ease-out ${m?"mb-0 flex-shrink-0":"mb-4 sm:mb-0"} ${l}`,style:W,children:t.jsxs("div",{className:`flex flex-wrap items-center justify-between transition-[gap,min-height,padding] duration-300 ease-out ${f?"min-h-8 gap-1.5 px-3 py-0 sm:min-h-9 sm:gap-2":w?"min-h-9 gap-2 px-4 py-0 sm:min-h-10 sm:gap-2.5":"min-h-10 gap-2.5 px-4 pt-0.5 sm:min-h-11 sm:gap-3"} ${i}`,children:[t.jsx("div",{className:`min-w-0 flex flex-1 flex-col justify-center transition-[gap,transform] duration-300 ease-out ${f||w?"gap-1":"gap-1.5 sm:gap-2"}`,children:t.jsxs("div",{className:`flex min-w-0 items-center transition-[gap,transform] duration-300 ease-out ${f||w?"gap-2":"gap-2.5 sm:gap-3"}`,children:[t.jsx("span",{className:`flex-shrink-0 transition-[color,transform,opacity] duration-300 ease-out ${f?"scale-75 opacity-80":"scale-90 opacity-100"}`,style:{color:L?"var(--text-secondary)":"var(--text-muted)"},children:y}),t.jsxs("div",{className:`flex min-w-0 flex-1 flex-wrap items-center transition-[gap] duration-300 ease-out ${f?"gap-x-2 gap-y-1":"gap-x-3 gap-y-2"}`,children:[t.jsxs("div",{className:"min-w-0 flex-shrink transition-[transform] duration-300 ease-out",children:[t.jsx("h1",{className:`truncate font-bold tracking-tight transition-[font-size,line-height,color] duration-300 ease-out ${f?"text-sm sm:text-base":"text-lg sm:text-xl"}`,style:{color:"var(--text-main)"},children:e}),r&&t.jsx("div",{"aria-hidden":f,className:`overflow-hidden text-xs transition-[max-height,opacity,transform,margin] duration-300 ease-out ${f?"mt-0 max-h-0 -translate-y-1 opacity-0":"mt-0.5 max-h-8 translate-y-0 opacity-100"}`,style:{color:"var(--text-muted)"},children:r})]}),a&&t.jsx("div",{className:`page-header-meta flex min-w-0 flex-1 basis-full items-center overflow-visible transition-[gap,opacity,transform] duration-300 ease-out sm:basis-auto ${f?"translate-y-0 gap-1.5 opacity-95":"gap-2 opacity-100"}`,children:a})]})]})}),n&&t.jsx("div",{className:`page-header-actions ml-auto flex max-w-full flex-shrink-0 flex-wrap items-center justify-end self-center overflow-visible transition-[gap,min-height,opacity,transform] duration-300 ease-out ${f?"min-h-9 gap-1 opacity-95":"min-h-9 gap-1.5 opacity-100"}`,children:t.jsx(jo.Provider,{value:{compact:!0,headerAction:!0},children:n})})]})})}function zf({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(Hl,{currentPath:r,...a,children:e})}function Pl(){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 Wf(e,r,n){try{const a=new URL(e),s=a.searchParams.get("callbackUrl");if(s){const l=new URL(s,a.origin);return l.searchParams.set("theme",r),n&&(l.searchParams.set("primeAuthOrigin",window.location.origin),l.searchParams.set("primeAuthProjectKey",n)),a.searchParams.set("callbackUrl",`${l.pathname}${l.search}${l.hash}`),a.toString()}return a.searchParams.set("theme",r),n&&(a.searchParams.set("primeAuthOrigin",window.location.origin),a.searchParams.set("primeAuthProjectKey",n)),a.toString()}catch{return e}}function jf({name:e,src:r,projectKey:n}){const[a,s]=o.useState("system"),l=o.useRef(null);o.useEffect(()=>{s(Pl());const d=new MutationObserver(()=>s(Pl()));return d.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>d.disconnect()},[]);const i=o.useMemo(()=>Wf(r,a,n),[n,r,a]),c=o.useMemo(()=>{try{return new URL(i).origin}catch{return""}},[i]);return o.useEffect(()=>{if(!n)return;const d=n;function u(m){var g,v,k;if(m.source!==((g=l.current)==null?void 0:g.contentWindow)||c&&m.origin!==c)return;if(((v=m.data)==null?void 0:v.type)==="prime-microservice:overlay"){window.dispatchEvent(new CustomEvent("prime-auth:microservice-overlay",{detail:{active:!!m.data.active}}));return}if(((k=m.data)==null?void 0:k.type)!=="prime-microservice:navigation")return;const b=m.data.path;if(!b||!b.startsWith("/")||b.startsWith("//"))return;const f=`/apps/${encodeURIComponent(d)}${b}`;`${window.location.pathname}${window.location.search}${window.location.hash}`!==f&&(window.history.replaceState(window.history.state,"",f),window.dispatchEvent(new CustomEvent("prime-auth:microservice-navigation")))}return window.addEventListener("message",u),()=>{window.removeEventListener("message",u),window.dispatchEvent(new CustomEvent("prime-auth:microservice-overlay",{detail:{active:!1}}))}},[c,n]),t.jsx("div",{className:"flex h-full min-h-screen flex-col bg-[var(--bg-main)]",children:t.jsx("iframe",{ref:l,src:i,title:e,className:"min-h-0 flex-1 border-0 bg-[var(--bg-main)]",allow:"clipboard-write",sandbox:"allow-downloads allow-forms allow-modals allow-popups allow-same-origin allow-scripts",referrerPolicy:"strict-origin-when-cross-origin"})})}function qf(){const[e,r]=o.useState(""),[n,a]=o.useState(!1),[s,l]=o.useState({width:96,height:96});return o.useEffect(()=>{let i=!1;return fetch("/api/microservices/prime-suite/chat-url",{cache:"no-store"}).then(c=>c.ok?c.json():null).then(c=>{!i&&(c!=null&&c.src)&&r(c.src)}).catch(()=>{}),()=>{i=!0}},[]),o.useEffect(()=>{const i=c=>{var u;if(((u=c.data)==null?void 0:u.type)!=="prime-suite-chat:state")return;const d=!!c.data.active;a(d),l({width:_l(c.data.width,96,720),height:_l(c.data.height,96,560)})};return window.addEventListener("message",i),()=>window.removeEventListener("message",i)},[]),e?t.jsx("iframe",{title:"Chat Bonsaif",src:e,allow:"clipboard-write",className:"fixed bottom-0 right-0 z-[70] border-0 bg-transparent transition-[width,height] duration-200",style:{width:n?`min(${s.width}px, 100vw)`:96,height:n?`min(${s.height}px, 100vh)`:96,background:"transparent",backgroundColor:"transparent",colorScheme:"normal"}}):null}function _l(e,r,n){const a=typeof e=="number"&&Number.isFinite(e)?e:r;return Math.max(r,Math.min(n,Math.ceil(a)))}function Uf(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 Vf(){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 Yf(){return"light"}function Xf({position:e="bottom-center"}){const r=o.useSyncExternalStore(Uf,Vf,Yf);return t.jsx(Ma.Toaster,{position:e,theme:r,richColors:!0,closeButton:!0})}function Kf({title:e,subtitle:r,actions:n,loading:a=!1,empty:s=!1,emptyText:l="Sin datos para mostrar",className:i="",children:c}){return t.jsxs("div",{className:`bonsaif-chart-card w-full overflow-visible ${i}`,children:[(e||r||n)&&t.jsxs("div",{className:"bonsaif-chart-card-head",children:[t.jsx("div",{className:"bonsaif-chart-card-accent","aria-hidden":!0}),t.jsxs("div",{className:"bonsaif-chart-card-copy min-w-0",children:[e?t.jsx("div",{className:"bonsaif-chart-card-title",children:e}):null,r?t.jsx("div",{className:"bonsaif-chart-card-subtitle",children:r}):null]}),n?t.jsx("div",{className:"bonsaif-chart-card-actions shrink-0",children:n}):null]}),t.jsx("div",{className:"bonsaif-chart-card-body",children:a?t.jsx("div",{className:"flex h-48 items-center justify-center",children:t.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-2 border-t-transparent",style:{borderColor:"var(--border)",borderTopColor:"var(--primary)"},"aria-label":"Cargando"})}):s?t.jsx("div",{className:"flex h-48 items-center justify-center text-sm",style:{color:"var(--text-muted)"},children:l}):c})]})}const sn=["var(--primary)","#38bdf8","#34d399","#a78bfa","#2dd4bf","#fbbf24","#60a5fa","#94a3b8"];function zl(e,r){return e.color??sn[r%sn.length]}function Lt(e="primary"){switch(e){case"success":return"#34d399";case"warning":return"#fbbf24";case"danger":return"#f87171";case"neutral":return"var(--text-muted)";default:return"var(--primary)"}}const gt=e=>{if(!Number.isFinite(e))return"—";const r=Math.abs(e);return r>=1e9?`${(e/1e9).toFixed(1).replace(/\.0$/,"")}B`:r>=1e6?`${(e/1e6).toFixed(1).replace(/\.0$/,"")}M`:r>=1e4?`${(e/1e3).toFixed(1).replace(/\.0$/,"")}k`:e.toLocaleString(void 0,{maximumFractionDigits:2})};function Tr(e){if(e==null||e==="")return null;const r=typeof e=="number"?e:Number(e);return Number.isFinite(r)?r:null}const xo={warning:70,danger:90};function Zn(e,r=xo){const n=r.warning??xo.warning,a=r.danger??xo.danger;return e>=a?"danger":e>=n?"warning":e<=0?"primary":"success"}function ln(e,r){return Lt(Zn(e,r))}function $r(e,r=0){return Number.isFinite(e)?`${e.toFixed(r)}%`:"—"}function Ar(e,r=1){if(!Number.isFinite(e))return"—";const n=e<0?"-":"",a=Math.abs(e);if(a<1024)return`${n}${Math.round(a)} B`;const s=["KB","MB","GB","TB","PB"];let l=a/1024,i=0;for(;l>=1024&&i<s.length-1;)l/=1024,i+=1;const c=l>=100?l.toFixed(0):l.toFixed(r);return`${n}${c.replace(/\.0$/,"")} ${s[i]}`}function Wl(e,r="bytes",n=1){if(!Number.isFinite(e))return"—";const a=e<0?"-":"",s=Math.abs(e),l=r==="bits"?["b/s","Kb/s","Mb/s","Gb/s","Tb/s"]:["B/s","KB/s","MB/s","GB/s","TB/s"];if(s<1024)return`${a}${Math.round(s)} ${l[0]}`;let i=s/1024,c=1;for(;i>=1024&&c<l.length-1;)i/=1024,c+=1;const d=i>=100?i.toFixed(0):i.toFixed(n);return`${a}${d.replace(/\.0$/,"")} ${l[c]}`}function Lr(e,r){var n;for(let a=e.length-1;a>=0;a-=1){const s=Tr((n=e[a])==null?void 0:n[r]);if(s!==null)return s}return null}function vt({height:e}){return t.jsx("div",{className:"flex items-center justify-center",style:{height:e},"aria-busy":!0,children:t.jsx("div",{className:"h-7 w-7 animate-spin rounded-full border-2",style:{borderColor:"var(--border)",borderTopColor:"var(--primary)"}})})}function yt({height:e,text:r}){return t.jsx("div",{className:"flex items-center justify-center text-sm",style:{height:e,color:"var(--text-muted)"},children:r})}const Qt=680,sr="ease-out",Gf={top:18,right:8,bottom:12,left:0};function cn(e){return{...Gf,...e}}function dn(e){return e.map((r,n)=>({...r,color:zl(r,n),label:r.label??r.key}))}function Qn(e,r){return!e.length||!r.length||e.every(n=>r.every(a=>Tr(n[a.key])===null))}function xt(){return{fill:"var(--text-muted)",fontSize:10,fontWeight:500,letterSpacing:"0.02em"}}function un(){return"color-mix(in srgb, var(--border) 55%, transparent)"}function jl(){return"color-mix(in srgb, var(--primary) 45%, var(--border))"}function Jn(){return{paddingBottom:12,paddingLeft:4,fontSize:11,fontWeight:600,letterSpacing:"0.04em",textTransform:"uppercase",color:"var(--text-muted)"}}function Zf(e,r=gt){if(e==null||e==="")return"—";const n=typeof e=="number"?e:Number(e);return Number.isFinite(n)?r(n):String(e)}function ql(e){return`bonsaif-grad-${e.replace(/[^a-zA-Z0-9_-]/g,"")}`}function Qf({active:e,label:r,payload:n,valueFormat:a=gt}){var c,d,u,m,b,f;if(!e||!(n!=null&&n.length))return null;const s=n.filter(g=>g.dataKey!=="base"&&g.name!=="base"&&g.value!==null&&g.value!==void 0);if(!s.length)return null;const l=((d=(c=s[0])==null?void 0:c.payload)==null?void 0:d.fullName)??((m=(u=s[0])==null?void 0:u.payload)==null?void 0:m.tooltipLabel)??((f=(b=s[0])==null?void 0:b.payload)==null?void 0:f.display),i=typeof l=="string"&&l.length>0?l:r;return t.jsxs("div",{className:"bonsaif-chart-tooltip-panel",children:[i!=null&&i!==""?t.jsx("div",{className:"bonsaif-chart-tooltip-label",children:String(i)}):null,t.jsx("div",{className:"bonsaif-chart-tooltip-items",children:s.map((g,v)=>{const k=g.payload,h=k&&typeof k.display=="number"?k.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:Zf(h,a)})]},String(g.dataKey??g.name??v))})})]})}function Dr({valueFormat:e,content:r,cursor:n,offset:a=12,wrapperStyle:s,allowEscapeViewBox:l,reverseDirection:i,...c}){return t.jsx(Se.Tooltip,{...c,cursor:n,offset:a,allowEscapeViewBox:l??{x:!1,y:!1},reverseDirection:i??{x:!1,y:!1},wrapperStyle:{outline:"none",zIndex:60,pointerEvents:"none",overflow:"visible",...s},content:r??t.jsx(Qf,{valueFormat:e})})}function Ul(e,r,n){return n==null?-1:e.findIndex(a=>String(a[r])===String(n))}function Vl(e,r,n){if(n<=1)return null;const a=Math.max(0,Math.min(e,r)),s=Math.min(n-1,Math.max(e,r));return s-a<1||a===0&&s>=n-1?null:{startIndex:a,endIndex:s}}function Rn(e,r,n={}){const{zoomable:a=!1,zoomMode:s="both",brushHeight:l=28,onZoomChange:i}=n,[c,d]=o.useState(null),[u,m]=o.useState(null),b=!!a&&e.length>1,f=b&&(s==="brush"||s==="both"),g=b&&(s==="drag"||s==="both"),v=o.useCallback(Z=>{d(Z),i==null||i(Z)},[i]),k=o.useCallback(()=>{m(null),v(null)},[v]),h=!!c,A=o.useMemo(()=>!c||f?e:e.slice(c.startIndex,c.endIndex+1),[e,f,c]),$=o.useCallback((Z,D)=>{const Q=Ul(e,r,Z),j=Ul(e,r,D);Q<0||j<0||v(Vl(Q,j,e.length))},[v,e,r]),N=o.useCallback(Z=>{g&&((Z==null?void 0:Z.activeLabel)===void 0||(Z==null?void 0:Z.activeLabel)===null||m({leftLabel:Z.activeLabel,rightLabel:Z.activeLabel}))},[g]),T=o.useCallback(Z=>{!g||!u||(Z==null?void 0:Z.activeLabel)===void 0||(Z==null?void 0:Z.activeLabel)===null||m(D=>D&&{...D,rightLabel:Z.activeLabel})},[u,g]),x=o.useCallback(()=>{if(g){if(!u||u.rightLabel===null||u.rightLabel===void 0){m(null);return}$(u.leftLabel,u.rightLabel),m(null)}},[$,u,g]),y=o.useCallback(Z=>{if(f){if(!Z){v(null);return}v(Vl(Z.startIndex??0,Z.endIndex??e.length-1,e.length))}},[v,e.length,f]),L=g?{onMouseDown:N,onMouseMove:T,onMouseUp:x,onMouseLeave:()=>{u&&x()}}:{},w=c??{startIndex:0,endIndex:Math.max(0,e.length-1)},W=t.jsxs(t.Fragment,{children:[g&&u&&u.rightLabel!==null&&u.rightLabel!==void 0?t.jsx(Se.ReferenceArea,{x1:u.leftLabel,x2:u.rightLabel,strokeOpacity:.18,fill:"var(--primary)",fillOpacity:.12,stroke:"var(--primary)"}):null,f?t.jsx(Se.Brush,{dataKey:r,height:l,stroke:"var(--primary)",fill:"color-mix(in srgb, var(--primary) 10%, var(--bg-card))",travellerWidth:8,startIndex:w.startIndex,endIndex:w.endIndex,onChange:y,tickFormatter:Z=>String(Z)}):null]}),X=f?{bottom:Math.max(l+10,36)}:void 0;return{enabled:b,showBrush:f,showDrag:g,viewData:A,isZoomed:h,resetZoom:k,chartHandlers:L,zoomNodes:W,marginExtra:X}}function ea({visible:e,onReset:r}){return e?t.jsx("button",{type:"button",className:"bonsaif-chart-zoom-reset",onClick:r,"aria-label":"Restablecer zoom",children:"Restablecer zoom"}):null}function Jf({data:e,xKey:r,series:n,height:a=280,className:s="",loading:l=!1,emptyText:i="Sin datos para mostrar",showGrid:c=!0,showLegend:d=!0,showTooltip:u=!0,margin:m,valueFormat:b=gt,yDomain:f,ariaLabel:g="Gráfico de líneas",curve:v=!0,strokeWidth:k=2.25,zoomable:h=!1,zoomMode:A="both",brushHeight:$,onZoomChange:N}){const T=Qn(e,n),x=dn(n),y=Rn(e,r,{zoomable:h,zoomMode:A,brushHeight:$,onZoomChange:N}),L=cn({...m,...y.marginExtra});return l?t.jsx(vt,{height:a}):T?t.jsx(yt,{height:a,text:i}):t.jsxs("div",{className:`bonsaif-chart bonsaif-line-chart w-full ${s}`,role:"img","aria-label":g,style:{height:a},children:[t.jsx(ea,{visible:y.isZoomed,onReset:y.resetZoom}),t.jsx(Se.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Se.LineChart,{data:y.viewData,margin:L,...y.chartHandlers,children:[c?t.jsx(Se.CartesianGrid,{strokeDasharray:"2 8",stroke:un(),vertical:!1}):null,t.jsx(Se.XAxis,{dataKey:r,tick:xt(),tickLine:!1,axisLine:!1,padding:{left:0,right:0},interval:"preserveStartEnd",minTickGap:52,dy:6}),t.jsx(Se.YAxis,{tick:xt(),tickLine:!1,axisLine:!1,width:44,domain:f??["auto","auto"],tickFormatter:w=>b(Number(w)),dx:-2}),u?t.jsx(Dr,{valueFormat:b,cursor:{stroke:jl(),strokeWidth:1.25,strokeDasharray:"4 4"}}):null,d?t.jsx(Se.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:Jn()}):null,x.map((w,W)=>t.jsx(Se.Line,{type:v?"monotone":"linear",dataKey:w.key,name:w.label,stroke:w.color,strokeWidth:W===0?k+.35:k,strokeOpacity:W===0?1:.88,isAnimationActive:!0,animationDuration:Qt,animationEasing:sr,dot:!1,activeDot:{r:5,strokeWidth:2,stroke:"var(--bg-card)",fill:w.color}},w.key)),y.zoomNodes]})})]})}function ta({data:e,xKey:r,series:n,height:a=280,className:s="",loading:l=!1,emptyText:i="Sin datos para mostrar",showGrid:c=!0,showLegend:d=!0,showTooltip:u=!0,margin:m,valueFormat:b=gt,yDomain:f,ariaLabel:g="Gráfico de área",stacked:v=!1,opacity:k=.22,zoomable:h=!1,zoomMode:A="both",brushHeight:$,onZoomChange:N}){const T=Qn(e,n),x=dn(n),y=Rn(e,r,{zoomable:h,zoomMode:A,brushHeight:$,onZoomChange:N}),L=cn({...m,...y.marginExtra});return l?t.jsx(vt,{height:a}):T?t.jsx(yt,{height:a,text:i}):t.jsxs("div",{className:`bonsaif-chart bonsaif-area-chart w-full ${s}`,role:"img","aria-label":g,style:{height:a},children:[t.jsx(ea,{visible:y.isZoomed,onReset:y.resetZoom}),t.jsx(Se.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Se.AreaChart,{data:y.viewData,margin:L,...y.chartHandlers,children:[t.jsx("defs",{children:x.map(w=>t.jsxs("linearGradient",{id:ql(w.key),x1:"0",y1:"0",x2:"0",y2:"1",children:[t.jsx("stop",{offset:"0%",stopColor:w.color,stopOpacity:Math.min(.55,k+.28)}),t.jsx("stop",{offset:"48%",stopColor:w.color,stopOpacity:k*.5}),t.jsx("stop",{offset:"100%",stopColor:w.color,stopOpacity:0})]},w.key))}),c?t.jsx(Se.CartesianGrid,{strokeDasharray:"2 8",stroke:un(),vertical:!1}):null,t.jsx(Se.XAxis,{dataKey:r,tick:xt(),tickLine:!1,axisLine:!1,padding:{left:0,right:0},interval:"preserveStartEnd",minTickGap:52,dy:6}),t.jsx(Se.YAxis,{tick:xt(),tickLine:!1,axisLine:!1,width:44,domain:f??["auto","auto"],tickFormatter:w=>b(Number(w)),dx:-2}),u?t.jsx(Dr,{valueFormat:b,cursor:{stroke:jl(),strokeWidth:1.25,strokeDasharray:"4 4"}}):null,d?t.jsx(Se.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:Jn()}):null,x.map(w=>t.jsx(Se.Area,{type:"monotone",dataKey:w.key,name:w.label,stroke:w.color,fill:`url(#${ql(w.key)})`,strokeWidth:2.25,stackId:v?"stack":void 0,isAnimationActive:!0,animationDuration:Qt,animationEasing:sr,dot:!1,activeDot:{r:5,strokeWidth:2,stroke:"var(--bg-card)",fill:w.color}},w.key)),y.zoomNodes]})})]})}function Rf({data:e,xKey:r,series:n,height:a=280,className:s="",loading:l=!1,emptyText:i="Sin datos para mostrar",showGrid:c=!0,showLegend:d=!0,showTooltip:u=!0,margin:m,valueFormat:b=gt,yDomain:f,ariaLabel:g="Gráfico de barras",layout:v="vertical",mode:k="grouped",barRadius:h=6,categoryAxisWidth:A=64,zoomable:$=!1,zoomMode:N="both",brushHeight:T,onZoomChange:x}){const y=Qn(e,n),L=dn(n),w=v==="horizontal",W=Rn(e,r,{zoomable:$&&!w,zoomMode:N,brushHeight:T,onZoomChange:x}),X=cn({...m,...W.marginExtra});return l?t.jsx(vt,{height:a}):y?t.jsx(yt,{height:a,text:i}):t.jsxs("div",{className:`bonsaif-chart bonsaif-bar-chart w-full ${s}`,role:"img","aria-label":g,style:{height:a},children:[t.jsx(ea,{visible:W.isZoomed,onReset:W.resetZoom}),t.jsx(Se.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Se.BarChart,{data:W.viewData,margin:X,layout:w?"vertical":"horizontal",barCategoryGap:"34%",barGap:3,...W.chartHandlers,children:[c?t.jsx(Se.CartesianGrid,{strokeDasharray:"2 8",stroke:un(),horizontal:!w,vertical:w}):null,w?t.jsxs(t.Fragment,{children:[t.jsx(Se.XAxis,{type:"number",tick:xt(),tickLine:!1,axisLine:!1,tickFormatter:Z=>b(Number(Z)),domain:f??["auto","auto"]}),t.jsx(Se.YAxis,{type:"category",dataKey:r,tick:xt(),tickLine:!1,axisLine:!1,width:A})]}):t.jsxs(t.Fragment,{children:[t.jsx(Se.XAxis,{dataKey:r,tick:xt(),tickLine:!1,axisLine:!1,interval:"preserveStartEnd",minTickGap:36,dy:6}),t.jsx(Se.YAxis,{tick:xt(),tickLine:!1,axisLine:!1,width:44,domain:f??["auto","auto"],tickFormatter:Z=>b(Number(Z)),dx:-2})]}),u?t.jsx(Dr,{valueFormat:b,cursor:{fill:"color-mix(in srgb, var(--primary) 8%, transparent)"}}):null,d?t.jsx(Se.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:Jn()}):null,L.map((Z,D)=>t.jsx(Se.Bar,{dataKey:Z.key,name:Z.label,fill:Z.color,fillOpacity:D===0?1:.82,radius:w?[0,h,h,0]:[h,h,2,2],maxBarSize:20,stackId:k==="stacked"?"stack":void 0,isAnimationActive:!0,animationDuration:Qt,animationEasing:sr},Z.key)),W.zoomNodes]})})]})}function eb(e){return t.jsx(Xl,{...e,variant:"pie"})}function tb(e){return t.jsx(Xl,{...e,variant:"donut",innerRadius:e.innerRadius??.62,cornerRadius:e.cornerRadius??10,padAngle:e.padAngle??2})}function Yl(e,r){return e==null||!Number.isFinite(e)?r:e>0&&e<=1?e*100:e}function Xl({data:e,nameKey:r,valueKey:n,height:a=280,className:s="",loading:l=!1,emptyText:i="Sin datos para mostrar",showLegend:c=!0,showTooltip:d=!0,valueFormat:u=gt,ariaLabel:m,innerRadius:b,outerRadius:f,colors:g=[...sn],padAngle:v,cornerRadius:k,variant:h}){const A=e.map((D,Q)=>({name:String(D[r]??""),value:Tr(D[n])??0,fill:g[Q%g.length],row:D})).filter(D=>D.value>0),$=!A.length,N=h==="donut",T=A.length,x=Yl(b,N?62:12),y=Yl(f,78),L=Math.min(v??(N?2:3),Math.max(.5,10/Math.max(1,T))),w=Math.min(k??(N?10:8),Math.max(2,36/Math.max(1,T)));if(l)return t.jsx(vt,{height:a});if($)return t.jsx(yt,{height:a,text:i});const W=A.reduce((D,Q)=>D+Q.value,0),X=c?Math.min(96,28+Math.ceil(T/3)*22):0,Z=Math.max(140,a-X);return t.jsx("div",{className:`bonsaif-chart bonsaif-${h}-chart w-full ${s}`,role:"img","aria-label":m??(h==="donut"?"Donut chart":"Pie chart"),style:{height:a},children:t.jsxs("div",{className:"bonsaif-pie-layout",children:[t.jsx("div",{className:"bonsaif-pie-plot",style:{height:Z},children:t.jsx(Se.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Se.PieChart,{margin:{top:4,right:4,bottom:4,left:4},children:[d?t.jsx(Dr,{valueFormat:u,isAnimationActive:!1}):null,t.jsx(Se.Pie,{data:A,dataKey:"value",nameKey:"name",cx:"50%",cy:"50%",innerRadius:`${x}%`,outerRadius:`${y}%`,startAngle:90,endAngle:-270,paddingAngle:L,cornerRadius:w,minAngle:T>6?3:2,stroke:"var(--bg-card)",strokeWidth:2,isAnimationActive:!0,animationDuration:Qt,animationEasing:sr,label:!1,activeShape:rb,children:A.map(D=>t.jsx(Se.Cell,{fill:D.fill},D.name))}),N?t.jsx("text",{x:"50%",y:"50%",textAnchor:"middle",dominantBaseline:"middle",fill:"var(--text-main)",fontSize:18,fontWeight:700,letterSpacing:"-0.02em",children:u(W)}):null]})})}),c?t.jsx("ul",{className:"bonsaif-pie-legend","aria-label":"Leyenda",children:A.map(D=>t.jsxs("li",{className:"bonsaif-pie-legend-item",children:[t.jsx("span",{className:"bonsaif-pie-legend-swatch",style:{background:D.fill},"aria-hidden":!0}),t.jsx("span",{className:"bonsaif-pie-legend-label",title:D.name,children:D.name}),t.jsx("span",{className:"bonsaif-pie-legend-value",children:u(D.value)})]},D.name))}):null]})})}function rb(e){const{outerRadius:r=0,...n}=e;return t.jsx(Se.Sector,{...n,outerRadius:Number(r)+4,stroke:"var(--bg-card)",strokeWidth:2})}function nb({data:e,dataKey:r,width:n="100%",height:a=36,tone:s="primary",color:l,fill:i=!0,className:c="",ariaLabel:d="Sparkline"}){const u=l??Lt(s),m=e.map(y=>Tr(y[r])).filter(y=>y!==null);if(m.length<2)return t.jsx("div",{className:c,style:{width:n,height:a,color:"var(--text-muted)"},"aria-label":d});const b=120,f=36,g=3,v=1,k=Math.min(...m),A=Math.max(...m)-k||1,$=m.map((y,L)=>{const w=v+L/(m.length-1)*(b-v*2),W=f-g-(y-k)/A*(f-g*2);return{x:w,y:W}}),N=$.map((y,L)=>`${L===0?"M":"L"}${y.x.toFixed(2)} ${y.y.toFixed(2)}`).join(" "),T=`${N} L${$[$.length-1].x.toFixed(2)} ${f} L${$[0].x.toFixed(2)} ${f} Z`,x=`bonsaif-spark-${r.replace(/[^a-zA-Z0-9_-]/g,"")}-${s}`;return t.jsx("div",{className:`bonsaif-sparkline ${c}`,style:{width:n,height:a},role:"img","aria-label":d,children:t.jsxs("svg",{width:"100%",height:"100%",viewBox:`0 0 ${b} ${f}`,preserveAspectRatio:"none",focusable:"false",children:[i?t.jsx("defs",{children:t.jsxs("linearGradient",{id:x,x1:"0",y1:"0",x2:"0",y2:"1",children:[t.jsx("stop",{offset:"0%",stopColor:u,stopOpacity:.38}),t.jsx("stop",{offset:"100%",stopColor:u,stopOpacity:0})]})}):null,i?t.jsx("path",{d:T,fill:`url(#${x})`}):null,t.jsx("path",{d:N,fill:"none",stroke:u,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",vectorEffect:"non-scaling-stroke"})]})})}function ab({data:e,xKey:r,series:n,barSeries:a,lineSeries:s,height:l=280,className:i="",loading:c=!1,emptyText:d="Sin datos para mostrar",showGrid:u=!0,showLegend:m=!0,showTooltip:b=!0,margin:f,valueFormat:g=gt,yDomain:v,ariaLabel:k="Gráfico combinado",barRadius:h=6,zoomable:A=!1,zoomMode:$="both",brushHeight:N,onZoomChange:T}){const x=a??n.slice(0,Math.max(1,n.length-1)),y=s??(n.length>1?n.slice(-1):n.length?[n[0]]:[]),L=[...x,...y.filter(j=>!x.some(se=>se.key===j.key))],w=Qn(e,L),W=dn(x),X=dn(L),Z=y.map(j=>{var te;const se=X.find(ee=>ee.key===j.key);return{...j,label:j.label??j.key,color:j.color??(se==null?void 0:se.color)??((te=X[0])==null?void 0:te.color)}}),D=Rn(e,r,{zoomable:A,zoomMode:$,brushHeight:N,onZoomChange:T}),Q=cn({...f,...D.marginExtra});return c?t.jsx(vt,{height:l}):w?t.jsx(yt,{height:l,text:d}):t.jsxs("div",{className:`bonsaif-chart bonsaif-combo-chart w-full ${i}`,role:"img","aria-label":k,style:{height:l},children:[t.jsx(ea,{visible:D.isZoomed,onReset:D.resetZoom}),t.jsx(Se.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Se.ComposedChart,{data:D.viewData,margin:Q,barCategoryGap:"34%",...D.chartHandlers,children:[u?t.jsx(Se.CartesianGrid,{strokeDasharray:"2 8",stroke:un(),vertical:!1}):null,t.jsx(Se.XAxis,{dataKey:r,tick:xt(),tickLine:!1,axisLine:!1,interval:"preserveStartEnd",minTickGap:36,dy:6}),t.jsx(Se.YAxis,{tick:xt(),tickLine:!1,axisLine:!1,width:44,domain:v??["auto","auto"],tickFormatter:j=>g(Number(j)),dx:-2}),b?t.jsx(Dr,{valueFormat:g,cursor:{fill:"color-mix(in srgb, var(--primary) 8%, transparent)"}}):null,m?t.jsx(Se.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:Jn()}):null,W.map(j=>t.jsx(Se.Bar,{dataKey:j.key,name:j.label,fill:j.color,fillOpacity:.88,radius:[h,h,2,2],maxBarSize:18,isAnimationActive:!0,animationDuration:Qt,animationEasing:sr},j.key)),Z.map(j=>t.jsx(Se.Line,{type:"monotone",dataKey:j.key,name:j.label,stroke:j.color,strokeWidth:2.5,isAnimationActive:!0,animationDuration:Qt,animationEasing:sr,dot:!1,activeDot:{r:5,strokeWidth:2,stroke:"var(--bg-card)",fill:j.color}},j.key)),D.zoomNodes]})})]})}function ob({data:e,xKey:r,valueKey:n,typeKey:a,height:s=280,className:l="",loading:i=!1,emptyText:c="Sin datos para mostrar",showGrid:d=!0,showTooltip:u=!0,margin:m,valueFormat:b=gt,ariaLabel:f="Gráfico waterfall",increaseColor:g="#34d399",decreaseColor:v="#f87171",totalColor:k="var(--primary)"}){const h=o.useMemo(()=>sb(e,{xKey:r,valueKey:n,typeKey:a,increaseColor:g,decreaseColor:v,totalColor:k}),[e,r,n,a,g,v,k]),A=!h.length,$=cn(m);return i?t.jsx(vt,{height:s}):A?t.jsx(yt,{height:s,text:c}):t.jsx("div",{className:`bonsaif-chart bonsaif-waterfall-chart w-full ${l}`,role:"img","aria-label":f,style:{height:s},children:t.jsx(Se.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Se.BarChart,{data:h,margin:$,barCategoryGap:"42%",children:[d?t.jsx(Se.CartesianGrid,{strokeDasharray:"2 8",stroke:un(),vertical:!1}):null,t.jsx(Se.XAxis,{dataKey:"label",tick:xt(),tickLine:!1,axisLine:!1,interval:0,dy:6}),t.jsx(Se.YAxis,{tick:xt(),tickLine:!1,axisLine:!1,width:44,tickFormatter:N=>b(Number(N)),dx:-2}),u?t.jsx(Dr,{valueFormat:b,cursor:{fill:"color-mix(in srgb, var(--primary) 8%, transparent)"}}):null,t.jsx(Se.Bar,{dataKey:"base",stackId:"wf",fill:"transparent",isAnimationActive:!1,legendType:"none",maxBarSize:22}),t.jsx(Se.Bar,{dataKey:"delta",name:"Valor",stackId:"wf",radius:[6,6,2,2],maxBarSize:22,isAnimationActive:!0,animationDuration:Qt,animationEasing:sr,children:h.map(N=>t.jsx(Se.Cell,{fill:N.color},N.label))})]})})})}function sb(e,r){let n=0;return e.map((a,s)=>{const l=Tr(a[r.valueKey])??0,i=r.typeKey?String(a[r.typeKey]??""):"",c=i==="total"||s===e.length-1&&i!=="increase"&&i!=="decrease";let d="increase",u=0,m=0,b=l;return c&&i==="total"?(d="total",u=0,m=Math.abs(l),b=l,n=l):c&&s===e.length-1&&!i?(d="total",u=0,m=Math.abs(n),b=n):(d=i==="decrease"||l<0?"decrease":"increase",d==="decrease"?(u=n+l,m=Math.abs(l),n=n+l):(u=n,m=Math.abs(l),n=n+l),b=l),{label:String(a[r.xKey]??""),base:u,delta:m,display:b,kind:d,color:d==="total"?r.totalColor:d==="decrease"?r.decreaseColor:r.increaseColor}})}const Kl="bonsaif-funnel-chart-keyframes",lb=`
|
|
45
45
|
@keyframes bonsaif-funnel-stage-in {
|
|
46
46
|
from {
|
|
47
47
|
opacity: 0;
|
|
@@ -81,4 +81,4 @@ ${P}`,me=new Blob(["\uFEFF"+ne],{type:"text/csv;charset=utf-8;"}),ke=URL.createO
|
|
|
81
81
|
animation: none !important;
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
|
-
`;function lb(){if(typeof document>"u"||document.getElementById(Xl))return;const e=document.createElement("style");e.id=Xl,e.textContent=sb,document.head.appendChild(e)}function Kl(e,r,n){return Math.min(n,Math.max(r,e))}function ra(e,r,n){const a=Kl(n,0,1);return`color-mix(in srgb, ${e} ${Math.round((1-a)*100)}%, ${r} ${Math.round(a*100)}%)`}function ib(e,r,n,a,s,l){const i=e.map((d,u)=>{const m=Tr(d[n])??0,b=String(d[r]??""),f=a?String(d[a]??"").trim():"",h=s?String(d[s]??"").trim():"";return{name:b,value:m,color:l[u%l.length],...f?{title:f}:{},...h?{description:h}:{}}}).filter(d=>d.value>0&&d.name),c=Math.max(...i.map(d=>d.value),1);return i.map(d=>({...d,pct:d.value/c}))}function cb(e,r){const n=e.length;if(n===0)return[];const a=r.gap*Math.max(0,n-1),s=(r.plotH-a)/n,l=r.maxTopW,i=r.maxTopW*r.taper;return e.map((c,d)=>{const u=n===1?0:d/n,m=n===1?1:(d+1)/n,b=l+(i-l)*u,f=l+(i-l)*m;return{...c,index:d,y:r.topY+d*(s+r.gap),h:s,topW:b,bottomW:f,cx:r.cx}})}function db({stage:e,hovered:r,onHover:n}){const{cx:a,y:s,h:l,topW:i,bottomW:c,color:d}=e,u=a-i/2,m=a+i/2,b=a-c/2,f=a+c/2,h=s+l,v=Math.max(4,Math.min(14,l*.18)),k=ra(d,"#000",r?.12:.22),g=ra(d,"#fff",r?.08:0),A=ra(d,"#fff",.22),$=[`M ${u} ${s}`,`L ${m} ${s}`,`L ${f} ${h}`,`L ${b} ${h}`,"Z"].join(" ");return t.jsxs("g",{onMouseEnter:()=>n(e.index),onMouseLeave:()=>n(null),style:{cursor:"default"},children:[t.jsx("path",{d:$,fill:k}),t.jsx("path",{d:[`M ${u} ${s}`,`L ${m} ${s}`,`L ${m} ${s+1}`,`L ${f} ${h}`,`L ${a} ${h}`,`L ${u} ${s}`,"Z"].join(" "),fill:g,opacity:.55}),t.jsx("ellipse",{cx:a,cy:s,rx:i/2,ry:v,fill:A,stroke:ra(d,"#000",.15),strokeWidth:1}),r?t.jsx("ellipse",{cx:a,cy:s,rx:i/2,ry:v,fill:"none",stroke:"var(--text-main)",strokeOpacity:.25,strokeWidth:1.5}):null]})}function ub({data:e,nameKey:r,valueKey:n,titleKey:a,descriptionKey:s,height:l=360,className:i="",loading:c=!1,emptyText:d="Sin datos para mostrar",showTooltip:u=!0,showLabels:m=!0,showValues:b=!0,showBottomArrow:f=!0,taper:h=.42,colors:v=[...sn],animationDuration:k=Qt,valueFormat:g=gt,ariaLabel:A="Gráfico embudo"}){const[$,N]=o.useState(null),[T,x]=o.useState(!1),y=o.useMemo(()=>ib(e,r,n,a,s,v),[e,r,n,a,s,v]),L=o.useMemo(()=>y.map(M=>`${M.name}:${M.value}`).join("|"),[y]);if(o.useEffect(()=>{if(lb(),typeof window>"u")return;const M=window.matchMedia("(prefers-reduced-motion: reduce)");x(M.matches);const oe=()=>x(M.matches);return M.addEventListener("change",oe),()=>M.removeEventListener("change",oe)},[]),c)return t.jsx(vt,{height:l});if(!y.length)return t.jsx(yt,{height:l,text:d});const w=k>0&&!T,W=k,X=Math.min(90,Math.max(40,Math.round(k/8))),Z=Math.round(W*.15),D=y.length*X+Math.round(W*.35),Q=y.some(M=>M.title||M.description),j=m?160:24,se=Q?168:24,te=f?36:8,ee=j+220+se,U=l,J=18,ce=Math.max(120,U-J-te-8),C=j+110,ae=cb(y,{cx:C,topY:J,plotH:ce,maxTopW:200,taper:Kl(h,.2,.95),gap:10}),B=$!=null?ae[$]:null,I="cubic-bezier(0.22, 1, 0.36, 1)";return t.jsxs("div",{className:`bonsaif-chart bonsaif-funnel-chart relative w-full ${i}`,role:"img","aria-label":A,style:{height:l},children:[t.jsxs("svg",{viewBox:`0 0 ${ee} ${U}`,width:"100%",height:"100%",preserveAspectRatio:"xMidYMid meet",children:[m?t.jsx("line",{className:w?"bonsaif-funnel-label":void 0,style:w?{animation:`bonsaif-funnel-fade-in ${W}ms ${I} both`}:void 0,x1:j-12,y1:J,x2:j-12,y2:J+ce,stroke:"var(--border)",strokeDasharray:"3 5",strokeWidth:1}):null,ae.map(M=>{const oe=M.y+M.h/2,K=M.cx-M.topW/2,Y=M.index*X,S=w?{animation:`bonsaif-funnel-stage-in ${W}ms ${I} ${Y}ms both`}:void 0,H=w?{animation:`bonsaif-funnel-fade-in ${Math.round(W*.85)}ms ${I} ${Y+Z}ms both`}:void 0;return t.jsxs("g",{children:[t.jsx("g",{className:"bonsaif-funnel-stage",style:S,children:t.jsx(db,{stage:M,hovered:$===M.index,onHover:N})}),m?t.jsxs("g",{className:"bonsaif-funnel-label",style:H,children:[t.jsx("line",{x1:24,y1:oe,x2:j-12,y2:oe,stroke:M.color,strokeOpacity:.55,strokeDasharray:"3 4",strokeWidth:1}),t.jsx("line",{x1:j-12,y1:oe,x2:K-6,y2:oe,stroke:M.color,strokeOpacity:.35,strokeDasharray:"3 4",strokeWidth:1}),t.jsx("text",{x:20,y:oe-(b?6:0),textAnchor:"end",fill:M.color,fontSize:12,fontWeight:600,children:M.name.length>18?`${M.name.slice(0,16)}…`:M.name}),b?t.jsx("text",{x:20,y:oe+10,textAnchor:"end",fill:"var(--text-muted)",fontSize:11,children:g(M.value)}):null]}):null,(M.title||M.description)&&Q?t.jsxs("g",{className:"bonsaif-funnel-anno",style:H,children:[t.jsx("line",{x1:M.cx+M.bottomW/2+6,y1:oe,x2:j+220+8,y2:oe,stroke:M.color,strokeOpacity:.35,strokeDasharray:"3 4",strokeWidth:1}),M.title?t.jsx("text",{x:j+220+14,y:oe-(M.description?6:0),fill:"var(--text-main)",fontSize:12,fontWeight:700,children:M.title.length>22?`${M.title.slice(0,20)}…`:M.title}):null,M.description?t.jsx("text",{x:j+220+14,y:oe+(M.title?10:0),fill:"var(--text-muted)",fontSize:11,children:M.description.length>28?`${M.description.slice(0,26)}…`:M.description}):null]}):null]},`${M.name}-${M.index}`)}),f?t.jsx("g",{className:"bonsaif-funnel-arrow",transform:`translate(${C}, ${J+ce+8})`,fill:"var(--primary)",style:w?{animation:`bonsaif-funnel-arrow-in ${Math.round(W*.7)}ms ${I} ${D}ms both`}:void 0,children:t.jsx("path",{d:"M0,22 L10,8 L4,8 L4,0 L-4,0 L-4,8 L-10,8 Z"})}):null]},L),u&&B?t.jsxs("div",{className:"pointer-events-none absolute z-10 rounded-md border px-2.5 py-1.5 text-xs shadow-sm",style:{left:"50%",top:8,transform:"translateX(-50%)",background:"var(--bg-card)",borderColor:"var(--border)",color:"var(--text-main)"},children:[t.jsx("span",{className:"font-semibold",style:{color:B.color},children:B.name}),t.jsx("span",{style:{color:"var(--text-muted)"},children:" · "}),g(B.value),t.jsxs("span",{style:{color:"var(--text-muted)"},children:[" ","(",Math.round(B.pct*100),"% del top)"]})]}):null]})}const Ir=135*Math.PI/180,xo=270*Math.PI/180;function fb({value:e,min:r=0,max:n=100,height:a=180,className:s="",loading:l=!1,empty:i=!1,emptyText:c="Sin datos para mostrar",label:d,valueFormat:u=gt,tone:m="primary",color:b,thresholds:f,ariaLabel:h="Gauge",animationDuration:v=700,thickness:k=9,showScale:g=!1}){const A=o.useId().replace(/:/g,""),$=n-r||1,N=Math.min(1,Math.max(0,(e-r)/$)),[T,x]=o.useState(v>0?0:N);if(o.useEffect(()=>{if(l||i)return;if(v<=0){x(N);return}if(typeof window<"u"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches){x(N);return}let ee=0,U=0;x(C=>(U=C,C));const J=performance.now(),ce=C=>{const _=Math.min(1,(C-J)/v),ae=1-(1-_)**3;x(U+(N-U)*ae),_<1&&(ee=requestAnimationFrame(ce))};return ee=requestAnimationFrame(ce),()=>cancelAnimationFrame(ee)},[N,v,l,i]),l)return t.jsx(vt,{height:a});if(i)return t.jsx(yt,{height:a,text:c});const y=100,L=108,w=72,W=b??bb(e,n,m,f),X=r+T*$,Z=Gl(y,L,w,Ir,Ir+xo),D=Ir+Math.max(.001,T)*xo,Q=Gl(y,L,w,Ir,D),j=na(y,L,w,Ir),se=na(y,L,w,Ir+xo);return t.jsx("div",{className:`bonsaif-chart bonsaif-gauge-chart flex flex-col items-center justify-center ${s}`,style:{height:a},children:t.jsxs("svg",{viewBox:"0 0 200 168",width:"100%",height:"100%",role:"img","aria-label":h,className:"overflow-visible",children:[t.jsx("defs",{children:t.jsxs("linearGradient",{id:`bonsaif-gauge-${A}`,x1:"0",y1:"0",x2:"1",y2:"0",children:[t.jsx("stop",{offset:"0%",stopColor:W,stopOpacity:.82}),t.jsx("stop",{offset:"100%",stopColor:W,stopOpacity:1})]})}),t.jsx("path",{d:Z,fill:"none",stroke:"color-mix(in srgb, var(--border) 70%, transparent)",strokeWidth:k,strokeLinecap:"butt"}),t.jsx("path",{d:Q,fill:"none",stroke:`url(#bonsaif-gauge-${A})`,strokeWidth:k,strokeLinecap:"butt",className:"bonsaif-chart-gauge-value"}),t.jsx("text",{x:y,y:L-(d?4:0),textAnchor:"middle",dominantBaseline:"middle",fill:"var(--text-main)",fontSize:28,fontWeight:700,letterSpacing:"-0.04em",className:"bonsaif-chart-gauge-label",children:u(X)}),d?t.jsx("text",{x:y,y:L+18,textAnchor:"middle",fill:"var(--text-muted)",fontSize:11,fontWeight:600,letterSpacing:"0.06em",children:d}):null,g?t.jsxs(t.Fragment,{children:[t.jsx("text",{x:j.x-2,y:j.y+k+14,textAnchor:"middle",fill:"var(--text-muted)",fontSize:10,children:u(r)}),t.jsx("text",{x:se.x+2,y:se.y+k+14,textAnchor:"middle",fill:"var(--text-muted)",fontSize:10,children:u(n)})]}):null]})})}function bb(e,r,n,a){if(a!=null&&a.length){const l=[...a].sort((c,d)=>c.value-d.value);let i=l[0].color;for(const c of l)e>=c.value&&(i=c.color);return i}if(n)return Lt(n);const s=e/(r||1);return s>=.8?Lt("success"):s>=.5?Lt("warning"):Lt("danger")}function na(e,r,n,a){return{x:e+n*Math.cos(a),y:r+n*Math.sin(a)}}function Gl(e,r,n,a,s){const l=na(e,r,n,a),i=na(e,r,n,s),c=s-a,d=Math.abs(c)>Math.PI?1:0;return`M ${l.x} ${l.y} A ${n} ${n} 0 ${d} 1 ${i.x} ${i.y}`}function mb({value:e,target:r,max:n,ranges:a,height:s=72,className:l="",loading:i=!1,empty:c=!1,emptyText:d="Sin datos para mostrar",label:u,subtitle:m,valueFormat:b=gt,tone:f="primary",showScale:h=!0,showStatus:v=!0,ariaLabel:k="Bullet chart"}){if(i)return t.jsx(vt,{height:s});if(c)return t.jsx(yt,{height:s,text:d});const g=n??Math.max(e,r,...(a==null?void 0:a.map(W=>W.value))??[],1)*1.05,$=[...a??[{value:g*.5,color:"color-mix(in srgb, var(--border) 72%, transparent)"},{value:g*.75,color:"color-mix(in srgb, var(--border) 48%, transparent)"},{value:g,color:"color-mix(in srgb, var(--border) 28%, transparent)"}]].sort((W,X)=>W.value-X.value),N=Lt(f),T=Math.min(100,Math.max(0,e/g*100)),x=Math.min(100,Math.max(0,r/g*100)),y=e>=r,L=[0,.25,.5,.75,1].map(W=>W*g),w=t.jsxs("div",{className:"bonsaif-bullet-plot min-w-0 flex-1",children:[t.jsxs("div",{className:"bonsaif-bullet-track relative w-full",style:{height:Math.max(22,u?28:s*.42)},role:"img","aria-label":k,children:[t.jsx("div",{className:"bonsaif-bullet-ranges absolute inset-0 flex overflow-hidden",children:$.map((W,X)=>{const Z=X===0?0:$[X-1].value,D=Math.max(0,(W.value-Z)/g*100);return t.jsx("div",{style:{width:`${D}%`,background:W.color??`color-mix(in srgb, var(--border) ${70-X*18}%, transparent)`}},X)})}),t.jsx("div",{className:"absolute left-0 top-1/2 w-full",style:{height:"34%",transform:"translateY(-50%)"},children:t.jsx("div",{className:"bonsaif-bullet-value h-full",style:{width:`${T}%`,background:N,borderRadius:"0 999px 999px 0",boxShadow:`0 0 12px color-mix(in srgb, ${N} 35%, transparent)`}})}),t.jsx("div",{className:"bonsaif-bullet-target absolute top-1/2 z-[1]",style:{left:`${x}%`,height:"72%",width:3,transform:"translate(-50%, -50%)",background:N,borderRadius:1,boxShadow:"0 0 0 1px color-mix(in srgb, var(--bg-card) 70%, transparent)"},title:`Meta ${b(r)}`})]}),h?t.jsx("div",{className:"bonsaif-bullet-scale relative mt-1.5 h-4 w-full",children:L.map((W,X)=>{const Z=W/g*100,D=X===0,Q=X===L.length-1;return t.jsxs("div",{className:"absolute top-0",style:{left:`${Z}%`,transform:D?"none":Q?"translateX(-100%)":"translateX(-50%)"},children:[t.jsx("div",{className:"mx-auto h-1.5 w-px",style:{background:"color-mix(in srgb, var(--text-muted) 55%, transparent)",marginLeft:D?0:Q?"auto":void 0,marginRight:Q?0:void 0}}),t.jsx("div",{className:"bonsaif-bullet-scale-label mt-0.5 tabular-nums",style:{color:"var(--text-muted)",textAlign:D?"left":Q?"right":"center"},children:b(W)})]},W)})}):null]});return t.jsx("div",{className:`bonsaif-chart bonsaif-bullet-chart w-full ${l}`,children:u?t.jsxs("div",{className:"bonsaif-bullet-row flex flex-col gap-2 sm:flex-row sm:items-start sm:gap-4",children:[t.jsxs("div",{className:"bonsaif-bullet-label shrink-0 sm:w-[7.5rem] sm:pt-1 sm:text-right",children:[t.jsx("div",{className:"text-sm font-semibold tracking-tight",style:{color:"var(--text-main)"},children:u}),m?t.jsx("div",{className:"mt-0.5 text-[11px] leading-snug",style:{color:"var(--text-muted)"},children:m}):t.jsxs("div",{className:"mt-0.5 text-[11px] tabular-nums leading-snug",style:{color:"var(--text-muted)"},children:[t.jsx("span",{style:{color:N,fontWeight:600},children:b(e)}),t.jsxs("span",{children:[" / meta ",b(r)]})]}),v?t.jsx("div",{className:"bonsaif-bullet-status mt-1.5 inline-flex text-[10px] font-bold uppercase tracking-wide",style:{color:Lt(y?"success":"warning")},children:y?"En meta":"Bajo meta"}):null]}),w]}):w})}function pb({data:e,value:r,timeKey:n="t",usageKey:a="usage",series:s,cores:l,height:i=220,className:c="",loading:d=!1,emptyText:u="Sin datos de CPU",showLegend:m=!1,showTooltip:b=!0,thresholds:f,label:h="CPU",ariaLabel:v="Uso de CPU"}){var x;const k=s??[{key:a,label:"Uso",color:ln(r??Lr(e,a)??0,f)}],g=r??Lr(e,a)??Lr(e,((x=k[0])==null?void 0:x.key)??a),A=!d&&(!e.length||g===null);if(d)return t.jsx(vt,{height:i});if(A)return t.jsx(yt,{height:i,text:u});const $=Math.min(100,Math.max(0,g??0)),N=Zn($,f),T=ln($,f);return t.jsxs("div",{className:`bonsaif-chart bonsaif-cpu-chart w-full ${c}`,role:"group","aria-label":v,children:[t.jsxs("div",{className:"bonsaif-metric-head",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"bonsaif-metric-kicker",children:[h,l!=null?t.jsxs("span",{className:"ml-1.5 normal-case tracking-normal opacity-80",children:["· ",l," ",l===1?"core":"cores"]}):null]}),t.jsx("div",{className:"bonsaif-metric-value",style:{color:T},children:$r($,$<10?1:0)})]}),t.jsx("div",{className:"bonsaif-metric-badge",style:{color:T,background:`color-mix(in srgb, ${T} 14%, transparent)`},children:N==="danger"?"Crítico":N==="warning"?"Alto":"Normal"})]}),t.jsx(ta,{data:e,xKey:n,series:k.map(y=>({...y,color:y.color??T})),height:Math.max(120,i-56),yDomain:[0,100],showLegend:m,showTooltip:b,valueFormat:y=>$r(y,0),ariaLabel:v,opacity:.22,margin:{top:8,right:8,bottom:4,left:0}})]})}function hb({used:e,total:r,cached:n,data:a=[],timeKey:s="t",usageKey:l="usage",height:i=220,className:c="",loading:d=!1,emptyText:u="Sin datos de memoria",showHistory:m=!0,showTooltip:b=!0,thresholds:f,label:h="RAM",ariaLabel:v="Uso de memoria"}){const k=r>0?r:1,g=Math.min(100,Math.max(0,e/k*100)),A=!d&&!(Number.isFinite(e)&&Number.isFinite(r)&&r>0);if(d)return t.jsx(vt,{height:i});if(A)return t.jsx(yt,{height:i,text:u});const $=Zn(g,f),N=ln(g,f),T=Math.max(0,r-e),x=a.length>0?Lr(a,l)??g:g,y=ln(x,f),L=m&&a.length>1?Math.max(100,i-110):0;return t.jsxs("div",{className:`bonsaif-chart bonsaif-ram-chart w-full ${c}`,role:"group","aria-label":v,children:[t.jsxs("div",{className:"bonsaif-metric-head",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"bonsaif-metric-kicker",children:h}),t.jsxs("div",{className:"flex items-baseline gap-2",children:[t.jsx("span",{className:"bonsaif-metric-value",style:{color:N},children:$r(g,g<10?1:0)}),t.jsxs("span",{className:"text-sm tabular-nums",style:{color:"var(--text-secondary)"},children:[Ar(e)," / ",Ar(r)]})]})]}),t.jsx("div",{className:"bonsaif-metric-badge",style:{color:N,background:`color-mix(in srgb, ${N} 14%, transparent)`},children:$==="danger"?"Crítico":$==="warning"?"Alto":"Normal"})]}),t.jsxs("div",{className:"mb-2",children:[t.jsx("div",{className:"h-2 w-full overflow-hidden rounded-sm",style:{background:"color-mix(in srgb, var(--border) 55%, transparent)"},role:"progressbar","aria-valuenow":Math.round(g),"aria-valuemin":0,"aria-valuemax":100,"aria-label":`${h} ${$r(g,0)}`,children:t.jsx("div",{className:"h-full rounded-sm transition-[width] duration-300",style:{width:`${g}%`,background:`linear-gradient(90deg, ${N}, color-mix(in srgb, ${N} 55%, #38bdf8))`}})}),t.jsxs("div",{className:"mt-2 flex flex-wrap gap-x-4 gap-y-1 text-[11px] tabular-nums",style:{color:"var(--text-muted)"},children:[t.jsxs("span",{children:[t.jsx("span",{className:"font-medium",style:{color:"var(--text-main)"},children:"Usada"})," ",Ar(e)]}),n!=null&&Number.isFinite(n)?t.jsxs("span",{children:[t.jsx("span",{className:"font-medium",style:{color:"var(--text-main)"},children:"Caché"})," ",Ar(n)]}):null,t.jsxs("span",{children:[t.jsx("span",{className:"font-medium",style:{color:"var(--text-main)"},children:"Libre"})," ",Ar(T)]})]})]}),m&&a.length>1?t.jsx(ta,{data:a,xKey:s,series:[{key:l,label:"Uso",color:y}],height:L,yDomain:[0,100],showLegend:!1,showTooltip:b,valueFormat:w=>$r(w,0),ariaLabel:`${v} — historial`,opacity:.22,margin:{top:8,right:8,bottom:4,left:0}}):null]})}const gb="color-mix(in srgb, var(--primary) 25%, #38bdf8)",vb="color-mix(in srgb, var(--primary) 20%, #2dd4bf)";function yb({data:e,timeKey:r="t",inboundKey:n="in",outboundKey:a="out",inbound:s,outbound:l,unit:i="bytes",inboundLabel:c="Entrada",outboundLabel:d="Salida",inboundColor:u=gb,outboundColor:m=vb,height:b=240,className:f="",loading:h=!1,emptyText:v="Sin datos de red",showLegend:k=!1,showTooltip:g=!0,label:A="Network",ariaLabel:$="Tráfico de red"}){const N=s??Lr(e,n)??0,T=l??Lr(e,a)??0,x=!h&&e.length===0;if(h)return t.jsx(vt,{height:b});if(x)return t.jsx(yt,{height:b,text:v});const y=W=>zl(W,i),w=Math.max(140,b-76);return t.jsxs("div",{className:`bonsaif-chart bonsaif-network-chart w-full ${f}`,role:"group","aria-label":$,children:[t.jsx("div",{className:"bonsaif-network-header relative z-10 mb-4 grid gap-3 border-b pb-3 sm:grid-cols-[minmax(0,1.4fr)_minmax(0,1fr)]",style:{borderColor:"var(--border)"},children:t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"bonsaif-metric-kicker",children:A}),t.jsxs("div",{className:"mt-2 grid grid-cols-2 gap-5 sm:max-w-lg",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-1.5 text-[11px]",style:{color:"var(--text-muted)"},children:[t.jsx("span",{className:"h-3 w-1.5 shrink-0 rounded-sm",style:{background:u},"aria-hidden":!0}),c]}),t.jsx("div",{className:"mt-1 truncate text-xl font-bold tabular-nums leading-tight tracking-tight",style:{color:u},title:y(N),children:y(N)})]}),t.jsxs("div",{className:"min-w-0 pl-1",children:[t.jsxs("div",{className:"flex items-center gap-1.5 text-[11px]",style:{color:"var(--text-muted)"},children:[t.jsx("span",{className:"h-3 w-1.5 shrink-0 rounded-sm",style:{background:m},"aria-hidden":!0}),d]}),t.jsx("div",{className:"mt-1 truncate text-lg font-semibold tabular-nums leading-tight tracking-tight opacity-95",style:{color:m},title:y(T),children:y(T)})]})]})]})}),t.jsx("div",{className:"bonsaif-network-plot relative z-0",children:t.jsx(ta,{data:e,xKey:r,series:[{key:n,label:c,color:u},{key:a,label:d,color:m}],height:w,showLegend:k,showTooltip:g,valueFormat:y,ariaLabel:$,opacity:.18,margin:{top:8,right:8,bottom:4,left:4}})})]})}const Zl=["primeSuiteOrigin","primeAuthOrigin","primeSuiteAppUrl"],Ql=["primeSuiteOrigin","primeSuiteProjectKey"];function xb(){if(typeof window>"u")return"*";try{if(window.parent===window)return"*";const e=new URLSearchParams(window.location.search);for(const r of Zl){const n=e.get(r);if(n){const a=aa(n);if(a)return a}}if(typeof sessionStorage<"u")for(const r of Ql){const n=sessionStorage.getItem(r);if(n)try{const a=new URL(n);if(a.origin&&a.origin!==window.location.origin)return a.origin}catch{const a=aa(n);if(a)return a}}if(document.referrer){const r=aa(document.referrer);if(r&&r!==window.location.origin)return r}return"*"}catch{return"*"}}function wb(){if(typeof window>"u")return"self";try{if(window.parent===window)return"self";const e=new URLSearchParams(window.location.search);for(const r of Zl)if(e.get(r))return"query";if(typeof sessionStorage<"u"){for(const r of Ql)if(sessionStorage.getItem(r))return"sessionStorage"}if(document.referrer){const r=aa(document.referrer);if(r&&r!==window.location.origin)return"referrer"}return"wildcard"}catch{return"wildcard"}}function aa(e){if(!e)return null;const r=e.trim().replace(/\/+$/,"");if(!r)return null;if(/^https?:\/\/[^/]+$/.test(r))return r;try{return new URL(r).origin}catch{return null}}function Nb(e){const[r,n]=o.useState({}),[a,s]=o.useState(!1),l=o.useCallback(u=>a||r[u]?e[u]:void 0,[e,a,r]),i=o.useCallback(u=>{n(m=>({...m,[u]:!0}))},[]),c=o.useCallback(()=>{s(!0)},[]),d=o.useCallback(()=>{n({}),s(!1)},[]);return{submitted:a,touchedFields:r,getFieldError:l,touchField:i,submit:c,reset:d}}Object.defineProperty(V,"toast",{enumerable:!0,get:()=>Ma.toast}),V.Alert=Zi,V.AreaChart=ta,V.AuthShell=Ol,V.AutoGrowTextarea=hl,V.AutoGrowTextareaField=Ku,V.BarChart=Jf,V.BonsaifButton=Li,V.BonsaifUIToaster=Yf,V.BulletChart=mb,V.Button=Ue,V.CHART_PALETTE=sn,V.CalendarPicker=tc,V.ChartCard=Xf,V.Checkbox=Nn,V.CodeBlock=sc,V.ComboChart=nb,V.CompactFilterSelect=cc,V.CompactSearchInput=ic,V.ConfirmDialog=bc,V.CopyButton=La,V.CopyLinkButton=gc,V.CpuChart=pb,V.DataSheets=qc,V.DataTable=ls,V.DateRangePicker=Kc,V.DonutChart=eb,V.Drawer=ad,V.DropdownMenu=rd,V.DynamicDetailTabs=Ki,V.EmailField=Md,V.EmptyState=$d,V.FieldHelperFooter=wr,V.FieldLabelInfo=xr,V.FieldLayoutEditor=Hd,V.FileUpload=Id,V.FormField=In,V.FunnelChart=ub,V.GaugeChart=fb,V.GlobalScrollbars=Tl,V.ImageLightbox=Ms,V.ImageLightboxHost=Ud,V.InputField=Ya,V.LineChart=Qf,V.LoadingState=Vo,V.MentionTextEditor=bl,V.MicroserviceFrame=Wf,V.Modal=Oa,V.MouseTooltip=Yt,V.MultiDateCalendar=Qc,V.MultiSelect=Yd,V.NetworkChart=yb,V.NumberField=Xd,V.PageHeader=Pf,V.PageSearchInput=zo,V.Pagination=Gd,V.PhoneField=Qd,V.PieChart=Rf,V.PrimeAuthRouteShell=_f,V.PrimeSuiteChatFrame=jf,V.RadioGroup=Jd,V.RamChart=hb,V.RichTextEditor=Iu,V.SearchableSelect=ar,V.SectionPanel=Ou,V.Sparkline=rb,V.StatusBadge=Fu,V.StatusSelect=ju,V.StepWizard=Uu,V.TableSkeleton=wn,V.Tabs=qu,V.TagInput=af,V.TextInput=Dn,V.Textarea=gl,V.TextareaField=Ru,V.TimeField=bf,V.TimePicker=Sl,V.Toggle=pf,V.TruncatedWithTooltip=Pt,V.UserAvatar=Il,V.WaterfallChart=ab,V.YearMultiDateCalendar=Rc,V.buildMentionQueryRegex=Xs,V.clearMentionChipSelection=Er,V.cn=Vt,V.configureBonsaifUI=xc,V.dedupeMentions=Js,V.defaultValueFormat=gt,V.deleteEditorSelection=ll,V.describeParentTargetOrigin=wb,V.emailFormat=dd,V.extractMentionUsernames=so,V.filterSelfMentions=Eu,V.findMentionChipAfterCaret=cl,V.findMentionChipBeforeCaret=il,V.findMentionChipsInSelection=co,V.findMentionTriggerInEditor=ao,V.formatBytes=Ar,V.formatPercent=$r,V.formatRate=zl,V.getBonsaifUIConfig=wc,V.getDataTablePreferencesEndpoint=Ha,V.getEditorPlainText=io,V.getPlainTextOffset=qn,V.highlightMentions=Rs,V.htmlToText=Zs,V.insertMentionInEditor=tl,V.isMentionTriggerBoundary=Gs,V.isPlainOffsetInsideMentionChip=Ks,V.isValidEmail=qa,V.isValidPhone=Ua,V.locateTextOffset=Cr,V.matches=hd,V.maxLength=bd,V.maxValue=pd,V.mentionDisplayLabel=Qs,V.minLength=fd,V.minValue=md,V.normalizeUsername=oo,V.openImageLightboxFromEvent=Cs,V.phoneCountryCodeOptions=As,V.phoneFormat=ud,V.placeCaretAtTextOffset=rl,V.removeMentionChip=Yn,V.required=cd,V.resetBonsaifUIConfig=Nc,V.resolveMentions=Cu,V.resolveParentTargetOrigin=xb,V.selectAllEditorContents=ol,V.selectMentionChip=al,V.selectionIncludesNonChipText=sl,V.seriesColor=_l,V.setBonsaifDataTablePreferencesEndpoint=kc,V.syncMentionChipSelectionHighlight=Vn,V.toneColor=Lt,V.usageColor=ln,V.usageTone=Zn,V.useValidationVisibility=Nb,V.validateForm=gd,Object.defineProperty(V,Symbol.toStringTag,{value:"Module"})}));
|
|
84
|
+
`;function ib(){if(typeof document>"u"||document.getElementById(Kl))return;const e=document.createElement("style");e.id=Kl,e.textContent=lb,document.head.appendChild(e)}function Gl(e,r,n){return Math.min(n,Math.max(r,e))}function ra(e,r,n){const a=Gl(n,0,1);return`color-mix(in srgb, ${e} ${Math.round((1-a)*100)}%, ${r} ${Math.round(a*100)}%)`}function cb(e,r,n,a,s,l){const i=e.map((d,u)=>{const m=Tr(d[n])??0,b=String(d[r]??""),f=a?String(d[a]??"").trim():"",g=s?String(d[s]??"").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 db(e,r){const n=e.length;if(n===0)return[];const a=r.gap*Math.max(0,n-1),s=(r.plotH-a)/n,l=r.maxTopW,i=r.maxTopW*r.taper;return e.map((c,d)=>{const u=n===1?0:d/n,m=n===1?1:(d+1)/n,b=l+(i-l)*u,f=l+(i-l)*m;return{...c,index:d,y:r.topY+d*(s+r.gap),h:s,topW:b,bottomW:f,cx:r.cx}})}function ub({stage:e,hovered:r,onHover:n}){const{cx:a,y:s,h:l,topW:i,bottomW:c,color:d}=e,u=a-i/2,m=a+i/2,b=a-c/2,f=a+c/2,g=s+l,v=Math.max(4,Math.min(14,l*.18)),k=ra(d,"#000",r?.12:.22),h=ra(d,"#fff",r?.08:0),A=ra(d,"#fff",.22),$=[`M ${u} ${s}`,`L ${m} ${s}`,`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:$,fill:k}),t.jsx("path",{d:[`M ${u} ${s}`,`L ${m} ${s}`,`L ${m} ${s+1}`,`L ${f} ${g}`,`L ${a} ${g}`,`L ${u} ${s}`,"Z"].join(" "),fill:h,opacity:.55}),t.jsx("ellipse",{cx:a,cy:s,rx:i/2,ry:v,fill:A,stroke:ra(d,"#000",.15),strokeWidth:1}),r?t.jsx("ellipse",{cx:a,cy:s,rx:i/2,ry:v,fill:"none",stroke:"var(--text-main)",strokeOpacity:.25,strokeWidth:1.5}):null]})}function fb({data:e,nameKey:r,valueKey:n,titleKey:a,descriptionKey:s,height:l=360,className:i="",loading:c=!1,emptyText:d="Sin datos para mostrar",showTooltip:u=!0,showLabels:m=!0,showValues:b=!0,showBottomArrow:f=!0,taper:g=.42,colors:v=[...sn],animationDuration:k=Qt,valueFormat:h=gt,ariaLabel:A="Gráfico embudo"}){const[$,N]=o.useState(null),[T,x]=o.useState(!1),y=o.useMemo(()=>cb(e,r,n,a,s,v),[e,r,n,a,s,v]),L=o.useMemo(()=>y.map(E=>`${E.name}:${E.value}`).join("|"),[y]);if(o.useEffect(()=>{if(ib(),typeof window>"u")return;const E=window.matchMedia("(prefers-reduced-motion: reduce)");x(E.matches);const oe=()=>x(E.matches);return E.addEventListener("change",oe),()=>E.removeEventListener("change",oe)},[]),c)return t.jsx(vt,{height:l});if(!y.length)return t.jsx(yt,{height:l,text:d});const w=k>0&&!T,W=k,X=Math.min(90,Math.max(40,Math.round(k/8))),Z=Math.round(W*.15),D=y.length*X+Math.round(W*.35),Q=y.some(E=>E.title||E.description),j=m?160:24,se=Q?168:24,te=f?36:8,ee=j+220+se,U=l,J=18,ce=Math.max(120,U-J-te-8),C=j+110,ae=db(y,{cx:C,topY:J,plotH:ce,maxTopW:200,taper:Gl(g,.2,.95),gap:10}),B=$!=null?ae[$]:null,I="cubic-bezier(0.22, 1, 0.36, 1)";return t.jsxs("div",{className:`bonsaif-chart bonsaif-funnel-chart relative w-full ${i}`,role:"img","aria-label":A,style:{height:l},children:[t.jsxs("svg",{viewBox:`0 0 ${ee} ${U}`,width:"100%",height:"100%",preserveAspectRatio:"xMidYMid meet",children:[m?t.jsx("line",{className:w?"bonsaif-funnel-label":void 0,style:w?{animation:`bonsaif-funnel-fade-in ${W}ms ${I} both`}:void 0,x1:j-12,y1:J,x2:j-12,y2:J+ce,stroke:"var(--border)",strokeDasharray:"3 5",strokeWidth:1}):null,ae.map(E=>{const oe=E.y+E.h/2,K=E.cx-E.topW/2,Y=E.index*X,S=w?{animation:`bonsaif-funnel-stage-in ${W}ms ${I} ${Y}ms both`}:void 0,H=w?{animation:`bonsaif-funnel-fade-in ${Math.round(W*.85)}ms ${I} ${Y+Z}ms both`}:void 0;return t.jsxs("g",{children:[t.jsx("g",{className:"bonsaif-funnel-stage",style:S,children:t.jsx(ub,{stage:E,hovered:$===E.index,onHover:N})}),m?t.jsxs("g",{className:"bonsaif-funnel-label",style:H,children:[t.jsx("line",{x1:24,y1:oe,x2:j-12,y2:oe,stroke:E.color,strokeOpacity:.55,strokeDasharray:"3 4",strokeWidth:1}),t.jsx("line",{x1:j-12,y1:oe,x2:K-6,y2:oe,stroke:E.color,strokeOpacity:.35,strokeDasharray:"3 4",strokeWidth:1}),t.jsx("text",{x:20,y:oe-(b?6:0),textAnchor:"end",fill:E.color,fontSize:12,fontWeight:600,children:E.name.length>18?`${E.name.slice(0,16)}…`:E.name}),b?t.jsx("text",{x:20,y:oe+10,textAnchor:"end",fill:"var(--text-muted)",fontSize:11,children:h(E.value)}):null]}):null,(E.title||E.description)&&Q?t.jsxs("g",{className:"bonsaif-funnel-anno",style:H,children:[t.jsx("line",{x1:E.cx+E.bottomW/2+6,y1:oe,x2:j+220+8,y2:oe,stroke:E.color,strokeOpacity:.35,strokeDasharray:"3 4",strokeWidth:1}),E.title?t.jsx("text",{x:j+220+14,y:oe-(E.description?6:0),fill:"var(--text-main)",fontSize:12,fontWeight:700,children:E.title.length>22?`${E.title.slice(0,20)}…`:E.title}):null,E.description?t.jsx("text",{x:j+220+14,y:oe+(E.title?10:0),fill:"var(--text-muted)",fontSize:11,children:E.description.length>28?`${E.description.slice(0,26)}…`:E.description}):null]}):null]},`${E.name}-${E.index}`)}),f?t.jsx("g",{className:"bonsaif-funnel-arrow",transform:`translate(${C}, ${J+ce+8})`,fill:"var(--primary)",style:w?{animation:`bonsaif-funnel-arrow-in ${Math.round(W*.7)}ms ${I} ${D}ms both`}:void 0,children:t.jsx("path",{d:"M0,22 L10,8 L4,8 L4,0 L-4,0 L-4,8 L-10,8 Z"})}):null]},L),u&&B?t.jsxs("div",{className:"pointer-events-none absolute z-10 rounded-md border px-2.5 py-1.5 text-xs shadow-sm",style:{left:"50%",top:8,transform:"translateX(-50%)",background:"var(--bg-card)",borderColor:"var(--border)",color:"var(--text-main)"},children:[t.jsx("span",{className:"font-semibold",style:{color:B.color},children:B.name}),t.jsx("span",{style:{color:"var(--text-muted)"},children:" · "}),h(B.value),t.jsxs("span",{style:{color:"var(--text-muted)"},children:[" ","(",Math.round(B.pct*100),"% del top)"]})]}):null]})}const Ir=135*Math.PI/180,wo=270*Math.PI/180;function bb({value:e,min:r=0,max:n=100,height:a=180,className:s="",loading:l=!1,empty:i=!1,emptyText:c="Sin datos para mostrar",label:d,valueFormat:u=gt,tone:m="primary",color:b,thresholds:f,ariaLabel:g="Gauge",animationDuration:v=700,thickness:k=9,showScale:h=!1}){const A=o.useId().replace(/:/g,""),$=n-r||1,N=Math.min(1,Math.max(0,(e-r)/$)),[T,x]=o.useState(v>0?0:N);if(o.useEffect(()=>{if(l||i)return;if(v<=0){x(N);return}if(typeof window<"u"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches){x(N);return}let ee=0,U=0;x(C=>(U=C,C));const J=performance.now(),ce=C=>{const _=Math.min(1,(C-J)/v),ae=1-(1-_)**3;x(U+(N-U)*ae),_<1&&(ee=requestAnimationFrame(ce))};return ee=requestAnimationFrame(ce),()=>cancelAnimationFrame(ee)},[N,v,l,i]),l)return t.jsx(vt,{height:a});if(i)return t.jsx(yt,{height:a,text:c});const y=100,L=108,w=72,W=b??mb(e,n,m,f),X=r+T*$,Z=Zl(y,L,w,Ir,Ir+wo),D=Ir+Math.max(.001,T)*wo,Q=Zl(y,L,w,Ir,D),j=na(y,L,w,Ir),se=na(y,L,w,Ir+wo);return t.jsx("div",{className:`bonsaif-chart bonsaif-gauge-chart flex flex-col items-center justify-center ${s}`,style:{height:a},children:t.jsxs("svg",{viewBox:"0 0 200 168",width:"100%",height:"100%",role:"img","aria-label":g,className:"overflow-visible",children:[t.jsx("defs",{children:t.jsxs("linearGradient",{id:`bonsaif-gauge-${A}`,x1:"0",y1:"0",x2:"1",y2:"0",children:[t.jsx("stop",{offset:"0%",stopColor:W,stopOpacity:.82}),t.jsx("stop",{offset:"100%",stopColor:W,stopOpacity:1})]})}),t.jsx("path",{d:Z,fill:"none",stroke:"color-mix(in srgb, var(--border) 70%, transparent)",strokeWidth:k,strokeLinecap:"butt"}),t.jsx("path",{d:Q,fill:"none",stroke:`url(#bonsaif-gauge-${A})`,strokeWidth:k,strokeLinecap:"butt",className:"bonsaif-chart-gauge-value"}),t.jsx("text",{x:y,y:L-(d?4:0),textAnchor:"middle",dominantBaseline:"middle",fill:"var(--text-main)",fontSize:28,fontWeight:700,letterSpacing:"-0.04em",className:"bonsaif-chart-gauge-label",children:u(X)}),d?t.jsx("text",{x:y,y:L+18,textAnchor:"middle",fill:"var(--text-muted)",fontSize:11,fontWeight:600,letterSpacing:"0.06em",children:d}):null,h?t.jsxs(t.Fragment,{children:[t.jsx("text",{x:j.x-2,y:j.y+k+14,textAnchor:"middle",fill:"var(--text-muted)",fontSize:10,children:u(r)}),t.jsx("text",{x:se.x+2,y:se.y+k+14,textAnchor:"middle",fill:"var(--text-muted)",fontSize:10,children:u(n)})]}):null]})})}function mb(e,r,n,a){if(a!=null&&a.length){const l=[...a].sort((c,d)=>c.value-d.value);let i=l[0].color;for(const c of l)e>=c.value&&(i=c.color);return i}if(n)return Lt(n);const s=e/(r||1);return s>=.8?Lt("success"):s>=.5?Lt("warning"):Lt("danger")}function na(e,r,n,a){return{x:e+n*Math.cos(a),y:r+n*Math.sin(a)}}function Zl(e,r,n,a,s){const l=na(e,r,n,a),i=na(e,r,n,s),c=s-a,d=Math.abs(c)>Math.PI?1:0;return`M ${l.x} ${l.y} A ${n} ${n} 0 ${d} 1 ${i.x} ${i.y}`}function pb({value:e,target:r,max:n,ranges:a,height:s=72,className:l="",loading:i=!1,empty:c=!1,emptyText:d="Sin datos para mostrar",label:u,subtitle:m,valueFormat:b=gt,tone:f="primary",showScale:g=!0,showStatus:v=!0,ariaLabel:k="Bullet chart"}){if(i)return t.jsx(vt,{height:s});if(c)return t.jsx(yt,{height:s,text:d});const h=n??Math.max(e,r,...(a==null?void 0:a.map(W=>W.value))??[],1)*1.05,$=[...a??[{value:h*.5,color:"color-mix(in srgb, var(--border) 72%, transparent)"},{value:h*.75,color:"color-mix(in srgb, var(--border) 48%, transparent)"},{value:h,color:"color-mix(in srgb, var(--border) 28%, transparent)"}]].sort((W,X)=>W.value-X.value),N=Lt(f),T=Math.min(100,Math.max(0,e/h*100)),x=Math.min(100,Math.max(0,r/h*100)),y=e>=r,L=[0,.25,.5,.75,1].map(W=>W*h),w=t.jsxs("div",{className:"bonsaif-bullet-plot min-w-0 flex-1",children:[t.jsxs("div",{className:"bonsaif-bullet-track relative w-full",style:{height:Math.max(22,u?28:s*.42)},role:"img","aria-label":k,children:[t.jsx("div",{className:"bonsaif-bullet-ranges absolute inset-0 flex overflow-hidden",children:$.map((W,X)=>{const Z=X===0?0:$[X-1].value,D=Math.max(0,(W.value-Z)/h*100);return t.jsx("div",{style:{width:`${D}%`,background:W.color??`color-mix(in srgb, var(--border) ${70-X*18}%, transparent)`}},X)})}),t.jsx("div",{className:"absolute left-0 top-1/2 w-full",style:{height:"34%",transform:"translateY(-50%)"},children:t.jsx("div",{className:"bonsaif-bullet-value h-full",style:{width:`${T}%`,background:N,borderRadius:"0 999px 999px 0",boxShadow:`0 0 12px color-mix(in srgb, ${N} 35%, transparent)`}})}),t.jsx("div",{className:"bonsaif-bullet-target absolute top-1/2 z-[1]",style:{left:`${x}%`,height:"72%",width:3,transform:"translate(-50%, -50%)",background:N,borderRadius:1,boxShadow:"0 0 0 1px color-mix(in srgb, var(--bg-card) 70%, transparent)"},title:`Meta ${b(r)}`})]}),g?t.jsx("div",{className:"bonsaif-bullet-scale relative mt-1.5 h-4 w-full",children:L.map((W,X)=>{const Z=W/h*100,D=X===0,Q=X===L.length-1;return t.jsxs("div",{className:"absolute top-0",style:{left:`${Z}%`,transform:D?"none":Q?"translateX(-100%)":"translateX(-50%)"},children:[t.jsx("div",{className:"mx-auto h-1.5 w-px",style:{background:"color-mix(in srgb, var(--text-muted) 55%, transparent)",marginLeft:D?0:Q?"auto":void 0,marginRight:Q?0:void 0}}),t.jsx("div",{className:"bonsaif-bullet-scale-label mt-0.5 tabular-nums",style:{color:"var(--text-muted)",textAlign:D?"left":Q?"right":"center"},children:b(W)})]},W)})}):null]});return t.jsx("div",{className:`bonsaif-chart bonsaif-bullet-chart w-full ${l}`,children:u?t.jsxs("div",{className:"bonsaif-bullet-row flex flex-col gap-2 sm:flex-row sm:items-start sm:gap-4",children:[t.jsxs("div",{className:"bonsaif-bullet-label shrink-0 sm:w-[7.5rem] sm:pt-1 sm:text-right",children:[t.jsx("div",{className:"text-sm font-semibold tracking-tight",style:{color:"var(--text-main)"},children:u}),m?t.jsx("div",{className:"mt-0.5 text-[11px] leading-snug",style:{color:"var(--text-muted)"},children:m}):t.jsxs("div",{className:"mt-0.5 text-[11px] tabular-nums leading-snug",style:{color:"var(--text-muted)"},children:[t.jsx("span",{style:{color:N,fontWeight:600},children:b(e)}),t.jsxs("span",{children:[" / meta ",b(r)]})]}),v?t.jsx("div",{className:"bonsaif-bullet-status mt-1.5 inline-flex text-[10px] font-bold uppercase tracking-wide",style:{color:Lt(y?"success":"warning")},children:y?"En meta":"Bajo meta"}):null]}),w]}):w})}function hb({data:e,value:r,timeKey:n="t",usageKey:a="usage",series:s,cores:l,height:i=220,className:c="",loading:d=!1,emptyText:u="Sin datos de CPU",showLegend:m=!1,showTooltip:b=!0,thresholds:f,label:g="CPU",ariaLabel:v="Uso de CPU"}){var x;const k=s??[{key:a,label:"Uso",color:ln(r??Lr(e,a)??0,f)}],h=r??Lr(e,a)??Lr(e,((x=k[0])==null?void 0:x.key)??a),A=!d&&(!e.length||h===null);if(d)return t.jsx(vt,{height:i});if(A)return t.jsx(yt,{height:i,text:u});const $=Math.min(100,Math.max(0,h??0)),N=Zn($,f),T=ln($,f);return t.jsxs("div",{className:`bonsaif-chart bonsaif-cpu-chart w-full ${c}`,role:"group","aria-label":v,children:[t.jsxs("div",{className:"bonsaif-metric-head",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"bonsaif-metric-kicker",children:[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:T},children:$r($,$<10?1:0)})]}),t.jsx("div",{className:"bonsaif-metric-badge",style:{color:T,background:`color-mix(in srgb, ${T} 14%, transparent)`},children:N==="danger"?"Crítico":N==="warning"?"Alto":"Normal"})]}),t.jsx(ta,{data:e,xKey:n,series:k.map(y=>({...y,color:y.color??T})),height:Math.max(120,i-56),yDomain:[0,100],showLegend:m,showTooltip:b,valueFormat:y=>$r(y,0),ariaLabel:v,opacity:.22,margin:{top:8,right:8,bottom:4,left:0}})]})}function gb({used:e,total:r,cached:n,data:a=[],timeKey:s="t",usageKey:l="usage",height:i=220,className:c="",loading:d=!1,emptyText:u="Sin datos de memoria",showHistory:m=!0,showTooltip:b=!0,thresholds:f,label:g="RAM",ariaLabel:v="Uso de memoria"}){const k=r>0?r:1,h=Math.min(100,Math.max(0,e/k*100)),A=!d&&!(Number.isFinite(e)&&Number.isFinite(r)&&r>0);if(d)return t.jsx(vt,{height:i});if(A)return t.jsx(yt,{height:i,text:u});const $=Zn(h,f),N=ln(h,f),T=Math.max(0,r-e),x=a.length>0?Lr(a,l)??h:h,y=ln(x,f),L=m&&a.length>1?Math.max(100,i-110):0;return t.jsxs("div",{className:`bonsaif-chart bonsaif-ram-chart w-full ${c}`,role:"group","aria-label":v,children:[t.jsxs("div",{className:"bonsaif-metric-head",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"bonsaif-metric-kicker",children:g}),t.jsxs("div",{className:"flex items-baseline gap-2",children:[t.jsx("span",{className:"bonsaif-metric-value",style:{color:N},children:$r(h,h<10?1:0)}),t.jsxs("span",{className:"text-sm tabular-nums",style:{color:"var(--text-secondary)"},children:[Ar(e)," / ",Ar(r)]})]})]}),t.jsx("div",{className:"bonsaif-metric-badge",style:{color:N,background:`color-mix(in srgb, ${N} 14%, transparent)`},children:$==="danger"?"Crítico":$==="warning"?"Alto":"Normal"})]}),t.jsxs("div",{className:"mb-2",children:[t.jsx("div",{className:"h-2 w-full overflow-hidden rounded-sm",style:{background:"color-mix(in srgb, var(--border) 55%, transparent)"},role:"progressbar","aria-valuenow":Math.round(h),"aria-valuemin":0,"aria-valuemax":100,"aria-label":`${g} ${$r(h,0)}`,children:t.jsx("div",{className:"h-full rounded-sm transition-[width] duration-300",style:{width:`${h}%`,background:`linear-gradient(90deg, ${N}, color-mix(in srgb, ${N} 55%, #38bdf8))`}})}),t.jsxs("div",{className:"mt-2 flex flex-wrap gap-x-4 gap-y-1 text-[11px] tabular-nums",style:{color:"var(--text-muted)"},children:[t.jsxs("span",{children:[t.jsx("span",{className:"font-medium",style:{color:"var(--text-main)"},children:"Usada"})," ",Ar(e)]}),n!=null&&Number.isFinite(n)?t.jsxs("span",{children:[t.jsx("span",{className:"font-medium",style:{color:"var(--text-main)"},children:"Caché"})," ",Ar(n)]}):null,t.jsxs("span",{children:[t.jsx("span",{className:"font-medium",style:{color:"var(--text-main)"},children:"Libre"})," ",Ar(T)]})]})]}),m&&a.length>1?t.jsx(ta,{data:a,xKey:s,series:[{key:l,label:"Uso",color:y}],height:L,yDomain:[0,100],showLegend:!1,showTooltip:b,valueFormat:w=>$r(w,0),ariaLabel:`${v} — historial`,opacity:.22,margin:{top:8,right:8,bottom:4,left:0}}):null]})}const vb="color-mix(in srgb, var(--primary) 25%, #38bdf8)",yb="color-mix(in srgb, var(--primary) 20%, #2dd4bf)";function xb({data:e,timeKey:r="t",inboundKey:n="in",outboundKey:a="out",inbound:s,outbound:l,unit:i="bytes",inboundLabel:c="Entrada",outboundLabel:d="Salida",inboundColor:u=vb,outboundColor:m=yb,height:b=240,className:f="",loading:g=!1,emptyText:v="Sin datos de red",showLegend:k=!1,showTooltip:h=!0,label:A="Network",ariaLabel:$="Tráfico de red"}){const N=s??Lr(e,n)??0,T=l??Lr(e,a)??0,x=!g&&e.length===0;if(g)return t.jsx(vt,{height:b});if(x)return t.jsx(yt,{height:b,text:v});const y=W=>Wl(W,i),w=Math.max(140,b-76);return t.jsxs("div",{className:`bonsaif-chart bonsaif-network-chart w-full ${f}`,role:"group","aria-label":$,children:[t.jsx("div",{className:"bonsaif-network-header relative z-10 mb-4 grid gap-3 border-b pb-3 sm:grid-cols-[minmax(0,1.4fr)_minmax(0,1fr)]",style:{borderColor:"var(--border)"},children:t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"bonsaif-metric-kicker",children:A}),t.jsxs("div",{className:"mt-2 grid grid-cols-2 gap-5 sm:max-w-lg",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-1.5 text-[11px]",style:{color:"var(--text-muted)"},children:[t.jsx("span",{className:"h-3 w-1.5 shrink-0 rounded-sm",style:{background:u},"aria-hidden":!0}),c]}),t.jsx("div",{className:"mt-1 truncate text-xl font-bold tabular-nums leading-tight tracking-tight",style:{color:u},title:y(N),children:y(N)})]}),t.jsxs("div",{className:"min-w-0 pl-1",children:[t.jsxs("div",{className:"flex items-center gap-1.5 text-[11px]",style:{color:"var(--text-muted)"},children:[t.jsx("span",{className:"h-3 w-1.5 shrink-0 rounded-sm",style:{background:m},"aria-hidden":!0}),d]}),t.jsx("div",{className:"mt-1 truncate text-lg font-semibold tabular-nums leading-tight tracking-tight opacity-95",style:{color:m},title:y(T),children:y(T)})]})]})]})}),t.jsx("div",{className:"bonsaif-network-plot relative z-0",children:t.jsx(ta,{data:e,xKey:r,series:[{key:n,label:c,color:u},{key:a,label:d,color:m}],height:w,showLegend:k,showTooltip:h,valueFormat:y,ariaLabel:$,opacity:.18,margin:{top:8,right:8,bottom:4,left:4}})})]})}const Ql=["primeSuiteOrigin","primeAuthOrigin","primeSuiteAppUrl"],Jl=["primeSuiteOrigin","primeSuiteProjectKey"];function wb(){if(typeof window>"u")return"*";try{if(window.parent===window)return"*";const e=new URLSearchParams(window.location.search);for(const r of Ql){const n=e.get(r);if(n){const a=aa(n);if(a)return a}}if(typeof sessionStorage<"u")for(const r of Jl){const n=sessionStorage.getItem(r);if(n)try{const a=new URL(n);if(a.origin&&a.origin!==window.location.origin)return a.origin}catch{const a=aa(n);if(a)return a}}if(document.referrer){const r=aa(document.referrer);if(r&&r!==window.location.origin)return r}return"*"}catch{return"*"}}function Nb(){if(typeof window>"u")return"self";try{if(window.parent===window)return"self";const e=new URLSearchParams(window.location.search);for(const r of Ql)if(e.get(r))return"query";if(typeof sessionStorage<"u"){for(const r of Jl)if(sessionStorage.getItem(r))return"sessionStorage"}if(document.referrer){const r=aa(document.referrer);if(r&&r!==window.location.origin)return"referrer"}return"wildcard"}catch{return"wildcard"}}function aa(e){if(!e)return null;const r=e.trim().replace(/\/+$/,"");if(!r)return null;if(/^https?:\/\/[^/]+$/.test(r))return r;try{return new URL(r).origin}catch{return null}}function kb(e){const[r,n]=o.useState({}),[a,s]=o.useState(!1),l=o.useCallback(u=>a||r[u]?e[u]:void 0,[e,a,r]),i=o.useCallback(u=>{n(m=>({...m,[u]:!0}))},[]),c=o.useCallback(()=>{s(!0)},[]),d=o.useCallback(()=>{n({}),s(!1)},[]);return{submitted:a,touchedFields:r,getFieldError:l,touchField:i,submit:c,reset:d}}Object.defineProperty(V,"toast",{enumerable:!0,get:()=>Ma.toast}),V.Alert=Qi,V.AreaChart=ta,V.AuthShell=Hl,V.AutoGrowTextarea=gl,V.AutoGrowTextareaField=Gu,V.BarChart=Rf,V.BonsaifButton=Di,V.BonsaifUIToaster=Xf,V.BulletChart=pb,V.Button=Ue,V.CHART_PALETTE=sn,V.CalendarPicker=rc,V.ChartCard=Kf,V.Checkbox=Nn,V.CodeBlock=lc,V.ComboChart=ab,V.CompactFilterSelect=dc,V.CompactSearchInput=cc,V.ConfirmDialog=mc,V.CopyButton=La,V.CopyLinkButton=vc,V.CpuChart=hb,V.DataSheets=Uc,V.DataTable=is,V.DateRangePicker=Gc,V.DonutChart=tb,V.Drawer=od,V.DropdownMenu=nd,V.DynamicDetailTabs=Gi,V.EmailField=Td,V.EmptyState=Ad,V.FieldHelperFooter=wr,V.FieldLabelInfo=xr,V.FieldLayoutEditor=Bd,V.FileUpload=Od,V.FormField=In,V.FunnelChart=fb,V.GaugeChart=bb,V.GlobalScrollbars=$l,V.ImageLightbox=Ts,V.ImageLightboxHost=Vd,V.InputField=Ya,V.LineChart=Jf,V.LoadingState=Yo,V.MentionTextEditor=ml,V.MicroserviceFrame=jf,V.Modal=Oa,V.MouseTooltip=Yt,V.MultiDateCalendar=Jc,V.MultiSelect=Xd,V.NetworkChart=xb,V.NumberField=Kd,V.PageHeader=_f,V.PageSearchInput=Wo,V.Pagination=Zd,V.PhoneField=Jd,V.PieChart=eb,V.PrimeAuthRouteShell=zf,V.PrimeSuiteChatFrame=qf,V.RadioGroup=Rd,V.RamChart=gb,V.RichTextEditor=Ou,V.SearchableSelect=ar,V.SectionPanel=Hu,V.Sparkline=nb,V.StatusBadge=Pu,V.StatusSelect=qu,V.StepWizard=Vu,V.TableSkeleton=wn,V.Tabs=Uu,V.TagInput=of,V.TextInput=Dn,V.Textarea=vl,V.TextareaField=ef,V.TimeField=mf,V.TimePicker=Cl,V.Toggle=hf,V.TruncatedWithTooltip=Pt,V.UserAvatar=Ol,V.WaterfallChart=ob,V.YearMultiDateCalendar=ed,V.buildMentionQueryRegex=Ks,V.clearMentionChipSelection=Er,V.cn=Vt,V.configureBonsaifUI=wc,V.dedupeMentions=Rs,V.defaultValueFormat=gt,V.deleteEditorSelection=il,V.describeParentTargetOrigin=Nb,V.emailFormat=ud,V.ensureMentionChipTrailingSpaces=lo,V.extractMentionUsernames=so,V.filterSelfMentions=Mu,V.findMentionChipAfterCaret=dl,V.findMentionChipBeforeCaret=cl,V.findMentionChipsInSelection=uo,V.findMentionTriggerInEditor=ao,V.formatBytes=Ar,V.formatPercent=$r,V.formatRate=Wl,V.getBonsaifUIConfig=Nc,V.getDataTablePreferencesEndpoint=Ha,V.getEditorPlainText=co,V.getPlainTextOffset=qn,V.highlightMentions=el,V.htmlToText=Qs,V.insertMentionInEditor=rl,V.isMentionTriggerBoundary=Zs,V.isPlainOffsetInsideMentionChip=Gs,V.isValidEmail=qa,V.isValidPhone=Ua,V.locateTextOffset=Cr,V.matches=gd,V.maxLength=md,V.maxValue=hd,V.mentionDisplayLabel=Js,V.minLength=bd,V.minValue=pd,V.normalizeUsername=oo,V.openImageLightboxFromEvent=Es,V.phoneCountryCodeOptions=Ls,V.phoneFormat=fd,V.placeCaretAtTextOffset=nl,V.removeMentionChip=Yn,V.required=dd,V.resetBonsaifUIConfig=kc,V.resolveMentions=Eu,V.resolveParentTargetOrigin=wb,V.selectAllEditorContents=sl,V.selectMentionChip=ol,V.selectionIncludesNonChipText=ll,V.seriesColor=zl,V.setBonsaifDataTablePreferencesEndpoint=Sc,V.syncMentionChipSelectionHighlight=Vn,V.toneColor=Lt,V.usageColor=ln,V.usageTone=Zn,V.useValidationVisibility=kb,V.validateForm=vd,Object.defineProperty(V,Symbol.toStringTag,{value:"Module"})}));
|