bonsaif-ui 0.1.102 → 0.1.104
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 +12 -0
- package/dist/bonsaif-ui.js +1807 -1691
- package/dist/bonsaif-ui.umd.cjs +13 -13
- package/dist/components/ui/Drawer.d.ts +6 -1
- package/dist/components/ui/Drawer.d.ts.map +1 -1
- package/dist/components/ui/LoadingState.d.ts +14 -1
- package/dist/components/ui/LoadingState.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/bonsaif-ui.umd.cjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
(function(z,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):(z=typeof globalThis<"u"?globalThis:z||self,o(z.BonsaifUI={},z.React,z.jsxRuntime,z.ReactIconsHi2,z.ReactDOM,z.Recharts,z.OverlayScrollbarsGlobal,z.Sonner,z.OverlayScrollbarsReact,z.ReactDayPicker,z.ReactDayPickerStyles,z.ReactIconsFi))})(this,(function(z,o,e,T,er,ve,Hn,$a,Aa,Da,Iu,Vs){"use strict";"use client";function gr(...r){return r.filter(Boolean).join(" ")}function Gs({variant:r="primary",className:t,type:n="button",children:a,...s}){return e.jsx("button",{className:gr("bonsaif-ui-button",`bonsaif-ui-button--${r}`,t),type:n,...s,children:a})}function Ia({value:r,onChange:t,placeholder:n,className:a="",autoFocus:s=!1,forceExpanded:l=!1,onEscape:i,size:c="default",inputTabIndex:u}){const f=o.useRef(null),[p,b]=o.useState(!1),m=l||p||r.trim().length>0,v=c==="sm"?"h-9 rounded-md":"h-10 rounded-lg",y=a||"w-48 max-w-full sm:w-64 lg:w-72";o.useEffect(()=>{var h;s&&((h=f.current)==null||h.focus())},[s]);const S=()=>{var h;b(!0),(h=f.current)==null||h.focus()};return e.jsxs("div",{className:`relative min-w-0 max-w-full flex-shrink-0 overflow-visible transition-[width] duration-200 ease-out ${m?y:"w-24 sm:w-28"}`,onMouseDown:h=>{m||(h.preventDefault(),S())},children:[e.jsx(T.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)"}}),e.jsx("input",{ref:f,type:"text",tabIndex:u,"aria-label":n,value:r,onChange:h=>t(h.target.value),onKeyDown:h=>{h.key==="Escape"&&(i==null||i())},placeholder:m?n:"Buscar",className:`${v} w-full py-0 text-sm leading-none placeholder:text-[var(--text-muted)] focus:outline-none transition-all duration-200 ${m?"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:m?"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"}}),r&&e.jsx("button",{type:"button",onClick:()=>t(""),className:"absolute right-2 top-1/2 flex !h-6 !w-6 -translate-y-1/2 items-center justify-center rounded-full !p-0 leading-none transition-colors hover:bg-black/5",style:{color:"var(--text-muted)",right:"var(--page-header-control-padding-x, 8px)"},"aria-label":"Limpiar búsqueda",children:e.jsx(T.HiXMark,{className:"h-3.5 w-3.5 flex-shrink-0"})})]})}const Ba=o.createContext({});let Oa=0;const Ha="bonsaif-ui:hide-tooltips";function zt(r=700){Oa=Date.now()+r}function Ks(){return Date.now()>Oa}function _t(r){if(typeof document>"u")return!1;const t=Array.from(document.querySelectorAll('[data-bonsaif-overlay="true"], [role="menu"], [role="dialog"][aria-modal="true"], [aria-hidden="false"] [aria-modal="true"]'));return r&&t.some(n=>n.contains(r))?!1:t.length>0}function Xs(r){var a;const t=Array.from(r.querySelectorAll("*")).filter(s=>{var l;return s.scrollWidth>s.clientWidth&&!!((l=s.textContent)!=null&&l.trim())&&s.tagName.toLowerCase()!=="svg"&&!s.closest("svg")});return(r.scrollWidth>r.clientWidth||t.length>0)&&(((a=t[0])==null?void 0:a.textContent)??r.textContent??"").trim()||null}function Mr({children:r,content:t,onlyWhenOverflow:n=!1,interactive:a=!1,followCursor:s=!0,placement:l="bottom",showArrow:i=!1,className:c="",tooltipClassName:u="",style:f,tooltipStyle:p,as:b="div"}){const m=o.useRef(null),v=o.useRef(null),y=o.useRef(null),S=o.useRef(!1),[h,H]=o.useState(null),[_,E]=o.useState("");o.useEffect(()=>{const C=m.current;C&&(C.querySelectorAll("[title]").forEach(te=>{const j=te.getAttribute("title");j&&(te.getAttribute("aria-label")||te.setAttribute("aria-label",j),te.removeAttribute("title"))}),C.querySelectorAll("svg title").forEach(te=>te.remove()))}),o.useLayoutEffect(()=>{if(!h)return;const C=v.current;if(!C)return;const te=12,j=14,W=C.getBoundingClientRect(),ae=window.innerWidth-W.width-te,Z=window.innerHeight-W.height-te;let $=h.mouseX+j,ee=h.mouseY+j,se,M;if(!s&&m.current){const O=m.current.getBoundingClientRect(),oe=O.left+O.width/2,A=O.top+O.height/2;l==="top"?($=oe-W.width/2,ee=O.top-W.height-j,M=W.height-1):l==="left"?($=O.left-W.width-j,ee=A-W.height/2,se=W.width-1):l==="right"?($=O.right+j,ee=A-W.height/2,se=-7):($=oe-W.width/2,ee=O.bottom+j,M=-7)}if(s&&($>ae&&($=h.mouseX-W.width-j),ee>Z&&(ee=h.mouseY-W.height-j)),$=Math.min(Math.max(te,$),Math.max(te,ae)),ee=Math.min(Math.max(te,ee),Math.max(te,Z)),!s&&m.current){const O=m.current.getBoundingClientRect(),oe=O.left+O.width/2,A=O.top+O.height/2;l==="top"||l==="bottom"?se=Math.min(Math.max(14,oe-$),W.width-14):M=Math.min(Math.max(14,A-ee),W.height-14)}(Math.abs($-h.x)>.5||Math.abs(ee-h.y)>.5||se!==h.arrowX||M!==h.arrowY)&&H(O=>O&&{...O,x:$,y:ee,arrowX:se,arrowY:M})},[s,l,h]);const L=()=>{y.current&&(window.clearTimeout(y.current),y.current=null)},N=(C,te)=>{if(!Ks()||S.current)return;const j=m.current;if(j&&!_t(j)){if(n){const W=Xs(j);if(!W)return;E(W)}!n&&!t||H({mouseX:C,mouseY:te,x:C+14,y:te+14})}},k=()=>{const C=m.current;if(!C)return;const te=C.getBoundingClientRect();N(te.left+te.width/2,te.bottom)},K=()=>{L(),H(null)},P=()=>{if(!a){K();return}L(),y.current=window.setTimeout(()=>H(null),120)},q=()=>{zt(),S.current=!0,K()},X=()=>{S.current=!1};o.useEffect(()=>{if(!h)return;if(_t(m.current)){H(null);return}const C=()=>H(null),te=()=>{zt(),S.current=!0,H(null)};document.addEventListener("pointerdown",te,!0),document.addEventListener("click",te,!0),document.addEventListener("scroll",C,!0),window.addEventListener("blur",C),document.addEventListener("visibilitychange",C),document.addEventListener("keydown",C,!0);const j=new MutationObserver(()=>{_t(m.current)&&H(null)});return j.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["role","aria-modal","aria-hidden","class"]}),()=>{document.removeEventListener("pointerdown",te,!0),document.removeEventListener("click",te,!0),document.removeEventListener("scroll",C,!0),window.removeEventListener("blur",C),document.removeEventListener("visibilitychange",C),document.removeEventListener("keydown",C,!0),j.disconnect()}},[h]),o.useEffect(()=>{const C=()=>zt(),te=()=>{zt(),S.current=!0,H(null)};return document.addEventListener("pointerdown",C,!0),document.addEventListener("click",C,!0),document.addEventListener("keydown",C,!0),window.addEventListener(Ha,te),()=>{document.removeEventListener("pointerdown",C,!0),document.removeEventListener("click",C,!0),document.removeEventListener("keydown",C,!0),window.removeEventListener(Ha,te)}},[]);const J=n?_:t;return e.jsxs(e.Fragment,{children:[e.jsx(b,{ref:C=>{m.current=C},className:c,style:f,onMouseEnter:C=>{L(),X(),s?N(C.clientX,C.clientY):k()},onMouseMove:C=>{h&&s&&N(C.clientX,C.clientY)},onMouseDown:q,onClick:q,onMouseLeave:()=>{X(),P()},onFocus:k,onBlur:K,children:r}),h&&J&&!_t(m.current)?er.createPortal(e.jsxs("div",{ref:v,role:"tooltip",className:u,onMouseEnter:a?L:void 0,onMouseLeave:a?P: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",...p},children:[i&&e.jsx("span",{"aria-hidden":"true",style:{position:"absolute",width:12,height:12,background:(p==null?void 0:p.background)??"var(--bg-card)",borderLeft:l==="right"?(p==null?void 0:p.border)??"1px solid var(--border)":void 0,borderTop:l==="bottom"||l==="right"?(p==null?void 0:p.border)??"1px solid var(--border)":void 0,borderRight:l==="left"?(p==null?void 0:p.border)??"1px solid var(--border)":void 0,borderBottom:l==="top"||l==="left"?(p==null?void 0:p.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}}),J]}),document.body):null]})}function Pa(r){if(r!==void 0)return typeof r=="number"?`${r}px`:r}const Ys="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",Zs={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"},Qs="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",Js={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"},Rs={xs:"h-8 w-8",sm:"h-9 w-9",md:"h-10 w-10",lg:"h-10 w-10"},el={primary:{background:"var(--bg-card)"},secondary:{background:"var(--bg-card)"},danger:{background:"var(--bg-card)"},ghost:{},icon:{}};function Pn(r){return typeof r=="string"||typeof r=="number"?String(r):Array.isArray(r)?r.map(Pn).join(" ").trim():o.isValidElement(r)?Pn(r.props.children):""}function rl(r){return o.Children.toArray(r).find(o.isValidElement)??null}function Fe({variant:r="primary",size:t="md",loading:n=!1,icon:a,tooltip:s,iconOnly:l,height:i,padding:c,children:u,className:f="",disabled:p,style:b,...m}){const v=o.useContext(Ba),y=l??v.iconOnly??r==="icon",S=v.compact??!1,h=v.headerAction??!1,H=h&&t==="md"?"sm":S&&!h&&t==="md"?"xs":t,_=r==="icon"||y,E=h&&_,L=Pn(u),N=s??m.title??m["aria-label"]??(y?L:void 0),k=N?void 0:m.title,K=m["aria-label"]??(typeof N=="string"?N:L||void 0),P=n?null:a??(y?rl(u):null),q=e.jsxs("button",{...m,title:k,"aria-label":K,"data-variant":r,"data-size":H,"data-icon":_?"true":void 0,disabled:p||n,className:`${Ys} ${E?Qs:Zs[r]} ${_?Rs[H]:Js[H]} ${S&&!_?"px-2.5":""} ${f}`,style:{...el[r],height:Pa(i),padding:Pa(c),...b,...h&&!_?{height:"var(--page-header-control-height, 34px)",padding:"0 var(--page-header-control-padding-x, 10px)",borderRadius:"8px"}:null,...E?{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?e.jsx("span",{className:"h-3.5 w-3.5 animate-spin rounded-full border-2 border-current border-t-transparent"}):P,!y&&u]});return N?e.jsx(Mr,{as:"span",content:N,className:"inline-flex shrink-0",children:q}):q}const Ge={background:"color-mix(in srgb, var(--text-muted) 26%, var(--bg-input))"};function jt({rows:r=8,columns:t=7,showToolbar:n=!0,showPagination:a=!0,compact:s=!1,className:l=""}){const i=Math.max(3,Math.min(t,12)),c=Math.max(3,Math.min(r,20)),u=s?"px-2 py-2":"px-3 py-2.5",f=s?"px-2 py-2":"px-3 py-3";return e.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&&e.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-[var(--border)] px-3 py-2",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[e.jsx("div",{className:"h-7 w-14 shrink-0 animate-pulse rounded-md",style:Ge}),e.jsx("div",{className:"h-7 max-w-md flex-1 animate-pulse rounded-md",style:Ge})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[e.jsx("div",{className:"h-7 w-7 animate-pulse rounded-md",style:Ge}),e.jsx("div",{className:"h-7 w-7 animate-pulse rounded-md",style:Ge})]})]}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("div",{className:"min-w-full",style:{display:"grid",gridTemplateColumns:`repeat(${i}, minmax(96px, 1fr))`},children:[Array.from({length:i}).map((p,b)=>e.jsx("div",{className:`${f} border-b border-[var(--border)]`,style:{background:"color-mix(in srgb, var(--bg-input) 55%, transparent)"},children:e.jsx("div",{className:"h-3 animate-pulse rounded-md",style:{...Ge,width:`${48+b*17%40}%`}})},`h-${b}`)),Array.from({length:c}).map((p,b)=>Array.from({length:i}).map((m,v)=>e.jsx("div",{className:`${u} ${b<c-1?"border-b border-[var(--border)]":""}`,children:e.jsx("div",{className:"h-3.5 animate-pulse rounded-md",style:{...Ge,width:`${46+(b*13+v*11)%42}%`,minWidth:28}})},`c-${b}-${v}`)))]})}),a&&e.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:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-3 w-28 animate-pulse rounded-md",style:Ge}),e.jsx("div",{className:"h-7 w-14 animate-pulse rounded-md",style:Ge})]}),e.jsx("div",{className:"flex items-center gap-1",children:Array.from({length:4}).map((p,b)=>e.jsx("div",{className:"h-7 w-7 animate-pulse rounded-md",style:Ge},b))}),e.jsx("div",{className:"h-3 w-16 animate-pulse rounded-md",style:Ge})]})]})}function Fa({variant:r="page",title:t="Cargando...",rows:n=6,columns:a=7,children:s}){return r==="table"?e.jsx(jt,{rows:n,columns:a}):r==="sections"?e.jsx(tl,{rows:n}):r==="cards"?e.jsx(nl,{rows:n}):e.jsx("div",{className:"flex min-h-[240px] items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-6",children:e.jsxs("div",{className:"flex flex-col items-center gap-3 text-center",children:[e.jsx("div",{className:"h-9 w-9 animate-spin rounded-full border-2 border-[var(--border)] border-t-[var(--primary)]"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold text-[var(--text-main)]",children:t}),s&&e.jsx("div",{className:"mt-1 text-xs text-[var(--text-muted)]",children:s})]})]})})}function tl({rows:r}){return e.jsx(jt,{rows:r,columns:7})}function nl({rows:r}){return e.jsx("div",{className:"grid gap-3 md:grid-cols-2 xl:grid-cols-3",children:Array.from({length:r}).map((t,n)=>e.jsxs("div",{className:"rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-4",children:[e.jsx("div",{className:"h-4 w-2/3 animate-pulse rounded-md",style:Ge}),e.jsx("div",{className:"mt-3 h-3 w-full animate-pulse rounded-md",style:Ge}),e.jsx("div",{className:"mt-2 h-3 w-4/5 animate-pulse rounded-md",style:Ge})]},n))})}function za(r){const t=r.split("/").filter(Boolean);return(t[t.length-1]??r).replace(/^lv_/,"").split(/[-_]/).filter(Boolean).map(a=>a.charAt(0).toUpperCase()+a.slice(1)).join(" ")}function _a(r){return r.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().trim()}function al(r){return[r.label,za(r.service),r.description,r.service].filter(Boolean).join(" ")}function ol(r){return typeof r=="function"?r:r.default}function sl(r,t){return e.jsx("div",{className:"flex min-h-[220px] items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-6 text-center",children:e.jsxs("div",{className:"max-w-md",children:[e.jsx("p",{className:"text-sm font-semibold text-[var(--text-main)]",children:"No se pudo cargar este modulo"}),e.jsx("p",{className:"mt-1 text-xs text-[var(--text-muted)]",children:r.message}),e.jsx(Fe,{className:"mt-4",height:36,padding:"0 14px",onClick:t,children:"Reintentar"})]})})}function ll({parentPanel:r,parentPanelComponent:t,renderParentPanel:n,parent:a,context:s,links:l,moduleRegistry:i,loadModule:c,activeService:u,initialService:f,onActiveServiceChange:p,canAccess:b,keepAlive:m=!0,title:v,subtitle:y,emptyState:S,loadingState:h,errorState:H=sl,renderTabLabel:_,searchableTabs:E="auto",tabsSearchThreshold:L=6,tabsSearchPlaceholder:N="Buscar modulo...",tabsSearchValue:k,onTabsSearchChange:K,emptySearchState:P,showTabCount:q=!0,className:X="",parentClassName:J="",contentClassName:C="",tabsClassName:te=""}){var lr;const j=o.useMemo(()=>l.filter(fe=>!fe.hidden&&((b==null?void 0:b(fe,s))??!0)),[b,s,l]),W=(lr=j.find(fe=>!fe.disabled))==null?void 0:lr.service,[ae,Z]=o.useState(f??W??""),[$,ee]=o.useState({}),[se,M]=o.useState({}),[O,oe]=o.useState(""),[A,U]=o.useState(!1),ne=o.useRef(se),ie=o.useRef(0),Q=k??O,V=_a(Q),w=E===!0||E==="auto"&&j.length>=L,R=w&&Q.trim().length>0,B=o.useMemo(()=>V?j.filter(fe=>_a(al(fe)).includes(V)):j,[V,j]),re=u??ae,F=j.find(fe=>fe.service===re)??j.find(fe=>!fe.disabled);o.useEffect(()=>{!F&&W&&Z(W)},[W,F]),o.useEffect(()=>{ne.current=se},[se]);const le=fe=>{fe.disabled||(u||Z(fe.service),p==null||p(fe.service,fe))},Ee=fe=>{k===void 0&&oe(fe),K==null||K(fe)},Le=(fe,I)=>{const Y=B.filter(be=>!be.disabled),ue=Y.findIndex(be=>be.service===I.service);ue<0||((fe.key==="ArrowRight"||fe.key==="ArrowDown")&&(fe.preventDefault(),le(Y[(ue+1)%Y.length])),(fe.key==="ArrowLeft"||fe.key==="ArrowUp")&&(fe.preventDefault(),le(Y[(ue-1+Y.length)%Y.length])),fe.key==="Home"&&(fe.preventDefault(),le(Y[0])),fe.key==="End"&&(fe.preventDefault(),le(Y[Y.length-1])))},xe=o.useCallback(()=>{if(!F)return;const fe=F.service,I=ne.current[fe];if(I!=null&&I.loading||I!=null&&I.component&&m)return;const Y=(i==null?void 0:i[fe])??c;if(!Y){M(be=>({...be,[fe]:{loading:!1,error:new Error(`No module loader found for service "${fe}".`)}}));return}const ue=++ie.current;M(be=>({...be,[fe]:{...be[fe],loading:!0,error:void 0}})),Y(F,s).then(be=>{if(ue!==ie.current&&!m)return;const De=ol(be);M(Ce=>({...Ce,[fe]:{component:De,loading:!1}}))}).catch(be=>{const De=be instanceof Error?be:new Error(String(be));M(Ce=>({...Ce,[fe]:{...Ce[fe],loading:!1,error:De}}))})},[s,m,c,i,F]);o.useEffect(xe,[xe]);const Se=F?$[F.service]??null:null,Te=F?se[F.service]:void 0,kr=Te==null?void 0:Te.component,pr=fe=>{F&&ee(I=>({...I,[F.service]:fe}))},qe=()=>{F&&ee(fe=>({...fe,[F.service]:null}))},ce={context:s,parent:a,links:l,visibleLinks:j,filteredLinks:B,selectedLink:F,selectedService:F==null?void 0:F.service,activeItemId:Se,tabsSearch:Q,onSelectService:le,onOpenDetail:pr,onBackToList:qe},Qe=n?n(ce):t?e.jsx(t,{...ce}):r;return e.jsxs("section",{className:`grid min-h-[520px] gap-4 lg:grid-cols-[minmax(260px,360px)_minmax(0,1fr)] ${X}`,children:[e.jsx("aside",{className:`min-w-0 rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-4 ${J}`,children:Qe}),e.jsxs("div",{className:`relative min-w-0 overflow-visible rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${C}`,children:[(v||y||w||q)&&e.jsx("div",{className:"relative border-b border-[var(--border)] px-4 py-3",children:e.jsxs("div",{className:"flex min-w-0 items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[v&&e.jsx("h2",{className:"truncate text-sm font-semibold text-[var(--text-main)]",children:v}),y&&e.jsx("p",{className:"mt-1 line-clamp-2 text-xs text-[var(--text-muted)]",children:y})]}),(w||q)&&e.jsxs("div",{className:"flex min-w-0 flex-shrink-0 items-center justify-end gap-2",children:[q&&e.jsxs("span",{className:"hidden text-xs font-semibold text-[var(--text-muted)] transition-opacity duration-200 sm:inline",children:[B.length," / ",j.length]}),w&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:`origin-right overflow-hidden transition-[width,opacity,transform] duration-200 ease-out ${A?"w-[min(20rem,44vw)] translate-x-0 opacity-100":"w-0 translate-x-2 opacity-0"}`,"aria-hidden":!A,children:e.jsx(Ia,{value:Q,onChange:Ee,placeholder:N,className:"w-full",autoFocus:A,forceExpanded:!0,onEscape:()=>U(!1),size:"sm",inputTabIndex:A?0:-1})}),e.jsx("button",{type:"button","aria-label":A?"Cerrar busqueda":"Buscar tabs","aria-expanded":A,onClick:()=>{A&&Q&&Ee(""),U(fe=>!fe)},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 ${A||R?"border-[var(--primary)] bg-[var(--bg-input)] text-[var(--text-main)] shadow-sm":"border-[var(--border)] text-[var(--text-muted)] hover:bg-[var(--bg-input)] hover:text-[var(--text-main)]"}`,children:e.jsx("span",{className:"grid h-4 w-4 place-items-center transition-transform duration-200",children:A||R?e.jsx(T.HiXMark,{className:"h-4 w-4"}):e.jsx(T.HiMagnifyingGlass,{className:"h-4 w-4"})})})]})]})]})}),e.jsx("div",{role:"tablist","aria-label":v??"Modulos relacionados",className:`flex gap-1 overflow-x-auto border-b border-[var(--border)] bg-[var(--bg-input)] px-2 py-1.5 transition-colors duration-200 ${te}`,children:B.length>0?B.map(fe=>{const I=fe.service===(F==null?void 0:F.service);return e.jsx("button",{type:"button",role:"tab","aria-selected":I,disabled:fe.disabled,onClick:()=>le(fe),onKeyDown:Y=>Le(Y,fe),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 ${I?"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:_?_(fe,I):e.jsxs(e.Fragment,{children:[fe.icon,e.jsx("span",{children:fe.label??za(fe.service)}),fe.badge&&e.jsx("span",{className:"rounded-full bg-[var(--bg-input)] px-1.5 py-0.5 text-[10px] text-[var(--text-muted)]",children:fe.badge})]})},fe.service)}):e.jsx("div",{className:"flex min-h-9 flex-1 items-center rounded-md border border-dashed border-[var(--border)] px-3 text-xs text-[var(--text-muted)]",children:P??"No hay modulos que coincidan con la busqueda."})}),(F==null?void 0:F.description)&&e.jsx("div",{className:"border-b border-[var(--border)] px-4 py-2 text-xs text-[var(--text-muted)]",children:F.description}),e.jsxs("div",{className:"min-h-[420px] p-4",children:[!F&&(S??e.jsx("div",{className:"flex min-h-[220px] items-center justify-center rounded-lg border border-dashed border-[var(--border)] text-sm text-[var(--text-muted)]",children:"No hay modulos disponibles."})),F&&(Te==null?void 0:Te.loading)&&(h??e.jsx(Fa,{title:"Cargando modulo..."})),F&&(Te==null?void 0:Te.error)&&H(Te.error,xe),F&&kr&&!(Te!=null&&Te.loading)&&!(Te!=null&&Te.error)&&e.jsx(kr,{context:s,parent:a,link:F,activeItemId:Se,onOpenDetail:pr,onBackToList:qe})]})]})]})}const il={info:{color:"#2563eb",background:"rgba(59, 130, 246, 0.1)",border:"rgba(59, 130, 246, 0.24)",icon:e.jsx(T.HiInformationCircle,{className:"h-5 w-5"})},success:{color:"#047857",background:"rgba(16, 185, 129, 0.1)",border:"rgba(16, 185, 129, 0.24)",icon:e.jsx(T.HiCheckCircle,{className:"h-5 w-5"})},warning:{color:"#b45309",background:"rgba(245, 158, 11, 0.12)",border:"rgba(245, 158, 11, 0.26)",icon:e.jsx(T.HiExclamationTriangle,{className:"h-5 w-5"})},danger:{color:"var(--danger)",background:"var(--danger-bg)",border:"color-mix(in srgb, var(--danger) 20%, var(--border))",icon:e.jsx(T.HiExclamationCircle,{className:"h-5 w-5"})},neutral:{color:"var(--text-secondary)",background:"var(--bg-input)",border:"var(--border)",icon:e.jsx(T.HiInformationCircle,{className:"h-5 w-5"})}};function cl({variant:r="info",title:t,children:n,icon:a,action:s,onDismiss:l,className:i=""}){const c=il[r];return e.jsxs("div",{role:r==="danger"||r==="warning"?"alert":"status",className:`flex items-start gap-3 rounded-lg border px-3 py-3 ${i}`,style:{background:c.background,borderColor:c.border},children:[e.jsx("div",{className:"mt-0.5 shrink-0",style:{color:c.color},children:a??c.icon}),e.jsxs("div",{className:"min-w-0 flex-1",children:[t&&e.jsx("div",{className:"text-sm font-semibold text-[var(--text-main)]",children:t}),n&&e.jsx("div",{className:"mt-0.5 text-sm leading-5 text-[var(--text-secondary)]",children:n}),s&&e.jsx("div",{className:"mt-3",children:s})]}),l&&e.jsx(Fe,{variant:"icon",size:"xs","aria-label":"Cerrar alerta",onClick:l,className:"-mr-1 -mt-1",children:e.jsx(T.HiXMark,{className:"h-4 w-4"})})]})}const ja=["Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre"],dl=["Ene","Feb","Mar","Abr","May","Jun","Jul","Ago","Sep","Oct","Nov","Dic"],ul=["Do","Lu","Ma","Mi","Ju","Vi","Sá"],Fn=6;function zn(r,t,n){return`${r}-${String(t).padStart(2,"0")}-${String(n).padStart(2,"0")}`}function fl(){const r=new Date;return zn(r.getFullYear(),r.getMonth()+1,r.getDate())}function Wa(r){const[t,n,a]=r.split("-").map(Number);return{year:t,month:n,day:a}}function bl(r){if(!r)return"Seleccionar fecha";const{year:t,month:n,day:a}=Wa(r);return!t||!n||!a?"Seleccionar fecha":`${String(a).padStart(2,"0")} ${ja[n-1]} ${t}`}function pl({value:r,onChange:t,minDate:n,displayMode:a="inline"}){const s=fl(),i=Wa(r||s),c=a==="popover",[u,f]=o.useState(!1),p=o.useRef(null),[b,m]=o.useState({horizontal:"left",vertical:"bottom"}),[v,y]=o.useState(i.year),[S,h]=o.useState(i.month),[H,_]=o.useState("days"),E=16,[L,N]=o.useState(0),k=v-7+L,K=Array.from({length:E},(Z,$)=>k+$);o.useEffect(()=>{if(!c||!u||!p.current)return;const Z=p.current.getBoundingClientRect(),$=8,ee=280,se=340,M=Z.left+ee>window.innerWidth-$,O=Z.right-ee>=$,oe=Z.bottom+8+se>window.innerHeight-$,A=Z.top-8-se>=$;m({horizontal:M&&O?"right":"left",vertical:oe&&A?"top":"bottom"})},[c,u]),o.useEffect(()=>{if(!c||!u)return;function Z(ee){p.current&&(p.current.contains(ee.target)||f(!1))}function $(ee){ee.key==="Escape"&&f(!1)}return document.addEventListener("mousedown",Z),document.addEventListener("keydown",$),()=>{document.removeEventListener("mousedown",Z),document.removeEventListener("keydown",$)}},[c,u]);function P(){S===1?(y(Z=>Z-1),h(12)):h(Z=>Z-1)}function q(){S===12?(y(Z=>Z+1),h(1)):h(Z=>Z+1)}const X=new Date(v,S-1,1).getDay(),J=new Date(v,S,0).getDate(),C=[...Array(X).fill(null),...Array.from({length:J},(Z,$)=>$+1)];for(;C.length<Fn*7;)C.push(null);const te=C.slice(0,Fn*7);function j(Z){const $=zn(v,S,Z);n&&$<n||(t($),c&&f(!1))}const W={background:"none",border:"none",cursor:"pointer",color:"var(--text-muted)",padding:4,borderRadius:6,display:"flex",alignItems:"center"},ae=e.jsxs("div",{style:{background:"var(--bg-input)",border:"1px solid var(--border)",borderRadius:10,overflow:"hidden",userSelect:"none",width:280},children:[e.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 12px",borderBottom:"1px solid var(--border)"},children:H==="days"?e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:P,style:W,title:"Mes anterior",children:e.jsx(T.HiChevronLeft,{size:16})}),e.jsxs("button",{type:"button",onClick:()=>{_("years"),N(0)},style:{background:"none",border:"none",cursor:"pointer",display:"flex",alignItems:"center",gap:4,fontSize:13,fontWeight:700,color:"var(--text-main)",borderRadius:6,padding:"2px 6px"},children:[ja[S-1]," ",v,e.jsx(T.HiChevronDown,{size:13,style:{color:"var(--text-muted)"}})]}),e.jsx("button",{type:"button",onClick:q,style:W,title:"Mes siguiente",children:e.jsx(T.HiChevronRight,{size:16})})]}):e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:()=>N(Z=>Z-E),style:W,children:e.jsx(T.HiChevronLeft,{size:16})}),e.jsxs("button",{type:"button",onClick:()=>_("days"),style:{background:"none",border:"none",cursor:"pointer",fontSize:13,fontWeight:700,color:"var(--text-main)",borderRadius:6,padding:"2px 6px"},children:[K[0]," – ",K[K.length-1]]}),e.jsx("button",{type:"button",onClick:()=>N(Z=>Z+E),style:W,children:e.jsx(T.HiChevronRight,{size:16})})]})}),H==="years"&&e.jsxs("div",{style:{padding:"8px 10px 10px"},children:[e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(4,1fr)",gap:3,marginBottom:8},children:dl.map((Z,$)=>{const ee=$+1===S;return e.jsx("button",{type:"button",onClick:()=>h($+1),style:{border:"none",cursor:"pointer",borderRadius:6,fontSize:11,fontWeight:ee?700:400,padding:"4px 0",background:ee?"var(--primary)":"transparent",color:ee?"var(--primary-fg, #ffffff)":"var(--text-secondary)"},children:Z},Z)})}),e.jsx("div",{style:{height:1,background:"var(--border)",marginBottom:8}}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(4,1fr)",gap:3},children:K.map(Z=>{const $=Z===v;return e.jsx("button",{type:"button",onClick:()=>{y(Z),_("days")},style:{border:"none",cursor:"pointer",borderRadius:6,fontSize:12,fontWeight:$?700:400,padding:"6px 0",background:$?"var(--primary)":"transparent",color:$?"var(--primary-fg, #ffffff)":"var(--text-main)",outline:Z===new Date().getFullYear()&&!$?"2px solid var(--primary)":"none",outlineOffset:"-2px"},children:Z},Z)})})]}),H==="days"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(7,1fr)",padding:"6px 8px 0"},children:ul.map(Z=>e.jsx("div",{style:{textAlign:"center",fontSize:10,fontWeight:700,color:"var(--text-muted)",padding:"2px 0",textTransform:"uppercase"},children:Z},Z))}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(7,1fr)",gridTemplateRows:`repeat(${Fn},1fr)`,padding:"4px 8px 10px",gap:2},children:te.map((Z,$)=>{if(Z===null)return e.jsx("div",{style:{aspectRatio:"1"}},$);const ee=zn(v,S,Z),se=ee===r,M=ee===s,O=!!(n&&ee<n);return e.jsx("button",{type:"button",onClick:()=>!O&&j(Z),style:{width:"100%",aspectRatio:"1",borderRadius:6,border:"none",cursor:O?"not-allowed":"pointer",fontSize:12,fontWeight:se||M?700:400,background:se?"var(--primary)":"transparent",color:se?"var(--primary-fg, #ffffff)":O?"var(--text-muted)":"var(--text-main)",opacity:O?.4:1,outline:M&&!se?"2px solid var(--primary)":"none",outlineOffset:"-2px"},children:Z},$)})})]})]});return c?e.jsxs("div",{ref:p,className:"relative w-full",children:[e.jsxs("button",{type:"button",onClick:()=>f(Z=>!Z),className:"flex h-10 w-full items-center justify-between gap-2 rounded-lg px-2.5 py-0 text-sm transition-all duration-150 focus:outline-none",style:{background:"var(--bg-input)",border:`1px solid ${u?"var(--primary)":"var(--border)"}`,color:"var(--text-main)",boxShadow:u?"0 0 0 3px rgba(59,130,246,0.12)":"none"},children:[e.jsxs("span",{className:"inline-flex items-center gap-2 min-w-0",children:[e.jsx(T.HiCalendarDays,{className:"w-4 h-4 text-[var(--text-muted)]"}),e.jsx("span",{className:"truncate",children:bl(r)})]}),e.jsx(T.HiChevronDown,{className:`w-4 h-4 text-[var(--text-muted)] transition-transform ${u?"rotate-180":""}`})]}),u&&e.jsx("div",{className:"absolute z-50",style:{...b.horizontal==="left"?{left:0}:{right:0},...b.vertical==="bottom"?{top:"calc(100% + 8px)"}:{bottom:"calc(100% + 8px)"}},children:ae})]}):ae}const ml={sm:"h-4 w-4",md:"h-5 w-5"};function hl(r,t){if(typeof r=="function"){r(t);return}r&&(r.current=t)}const Wt=o.forwardRef(function({label:t,description:n,error:a,size:s="md",indeterminate:l=!1,className:i="",containerClassName:c="",disabled:u,...f},p){const b=o.useRef(null);return o.useEffect(()=>{b.current&&(b.current.indeterminate=l)},[l]),e.jsxs("label",{className:`group inline-flex items-start gap-2.5 ${u?"cursor-not-allowed opacity-60":"cursor-pointer"} ${c}`,children:[e.jsxs("span",{className:"relative mt-0.5 inline-flex shrink-0",children:[e.jsx("input",{...f,ref:m=>{b.current=m,hl(p,m)},type:"checkbox",disabled:u,"aria-checked":l?"mixed":f["aria-checked"],"aria-invalid":!!a||f["aria-invalid"],className:`peer ${ml[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}`}),e.jsx(T.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"})]}),(t||n||a)&&e.jsxs("span",{className:"min-w-0",children:[t&&e.jsx("span",{className:"block text-sm font-medium leading-5 text-[var(--text-main)]",children:t}),n&&!a&&e.jsx("span",{className:"block text-xs leading-5 text-[var(--text-muted)]",children:n}),a&&e.jsx("span",{className:"block text-xs leading-5 text-[var(--danger)]",children:a})]})]})});function qa(r){const t=document.createElement("textarea");t.value=r,t.style.position="fixed",t.style.opacity="0",t.style.pointerEvents="none",document.body.appendChild(t),t.select(),document.execCommand("copy"),document.body.removeChild(t)}async function gl(r){var t;if((t=navigator.clipboard)!=null&&t.writeText){await navigator.clipboard.writeText(r);return}qa(r)}function vl(r){return typeof r=="function"?r():r}function _n({value:r,resetDelay:t=2e3,title:n,copiedTitle:a="Copiado",copiedLabel:s,icon:l=e.jsx(T.HiClipboardDocument,{size:14}),copiedIcon:i=e.jsx(T.HiCheck,{size:14}),stopPropagation:c=!0,onCopied:u,onCopyError:f,className:p="",style:b,children:m,onClick:v,type:y="button",...S}){const[h,H]=o.useState(!1),_=o.useRef(null);o.useEffect(()=>()=>{_.current&&window.clearTimeout(_.current)},[]);function E(N){H(!0),u==null||u(N),_.current&&window.clearTimeout(_.current),_.current=window.setTimeout(()=>{H(!1),_.current=null},t)}async function L(N){var K;if(c&&N.stopPropagation(),v==null||v(N),N.defaultPrevented)return;const k=vl(r);if(k)try{await gl(k),E(k)}catch(P){try{qa(k),E(k)}catch(q){f==null||f(q,k);return}(K=navigator.clipboard)!=null&&K.writeText||f==null||f(P,k)}}return e.jsxs("button",{...S,type:y,onClick:L,title:h?a:n,"aria-label":S["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 ${m?"min-w-7 px-2":"w-7"} ${p}`,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:[e.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}),m&&e.jsx("span",{className:"text-xs font-semibold leading-none",children:h?s??m:m})]})}function xl({code:r,children:t,title:n="Codigo",language:a,copyLabel:s="Copiar",copiedLabel:l="Copiado",className:i="",style:c,onCopied:u}){const f=(r??t??"").trim();return e.jsxs("div",{className:`overflow-hidden rounded-lg border ${i}`,style:{borderColor:"rgba(148, 163, 184, 0.22)",background:"#0f172a",color:"#e2e8f0",...c},children:[e.jsxs("div",{className:"flex min-h-9 items-center justify-between gap-3 border-b px-3 py-1.5",style:{borderColor:"rgba(148, 163, 184, 0.18)",background:"#111827",color:"#94a3b8"},children:[e.jsx("span",{className:"min-w-0 truncate text-[11px] font-black uppercase tracking-[0.08em]",children:n}),e.jsx(_n,{value:f,title:"Copiar codigo",copiedTitle:"Codigo copiado",copiedLabel:l,onCopied:u,className:"h-7 min-w-[72px] px-2",style:{background:"#182235",border:"1px solid rgba(148, 163, 184, 0.28)",color:"#f8fafc"},children:s})]}),e.jsx("pre",{className:"m-0 overflow-x-auto p-3 text-xs leading-6",style:{background:"#0f172a",color:"#e2e8f0",fontFamily:'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace'},children:e.jsx("code",{className:a?`language-${a}`:void 0,children:f})})]})}function jn(r){if(r!==void 0)return typeof r=="number"?`${r}px`:r}function Wn(r){return r.normalize("NFD").replace(new RegExp("\\p{M}","gu"),"").toLowerCase()}function yl(r,t){if(!t.trim())return!0;const n=Wn(t);return Wn(r.label).includes(n)||!!(r.sublabel&&Wn(r.sublabel).includes(n))}function Lr({value:r,onChange:t,options:n,status:a="default",ariaLabel:s,triggerVariant:l="default",showSelectedSublabel:i=!0,placeholder:c="Seleccionar…",emptyLabel:u,disabled:f=!1,className:p="",style:b,dropdownMinWidth:m,height:v=40,padding:y="0 10px",searchable:S=!0,minOptionsForSearch:h=6}){const[H,_]=o.useState(!1),[E,L]=o.useState(""),[N,k]=o.useState(-1),[K,P]=o.useState(!1),[q,X]=o.useState({}),J=o.useRef(null),C=o.useRef(null),te=o.useRef(null),j=o.useRef(null),W=S&&n.length>=h,ae=n.find(Q=>Q.value===r)??null,Z=l==="ghost",$=a==="error"?"var(--danger)":H?"var(--primary)":"var(--border)",ee=W&&E.trim()?n.filter(Q=>yl(Q,E)):n,se=o.useCallback(()=>{const Q=J.current;if(!Q)return;const V=Q.getBoundingClientRect(),w=W?272:212,R=window.innerHeight-V.bottom,B=R<w&&V.top>R;X({position:"fixed",left:V.left,top:B?void 0:V.bottom+4,bottom:B?window.innerHeight-V.top+4:void 0,width:V.width,minWidth:jn(m),zIndex:9999})},[m,W]);o.useEffect(()=>P(!0),[]),o.useEffect(()=>{if(!H)return;function Q(V){var R,B;const w=V.target;!((R=J.current)!=null&&R.contains(w))&&!((B=C.current)!=null&&B.contains(w))&&(_(!1),L(""))}return document.addEventListener("mousedown",Q),()=>document.removeEventListener("mousedown",Q)},[H]),o.useEffect(()=>{H&&(k(-1),se(),W&&setTimeout(()=>{var Q;return(Q=te.current)==null?void 0:Q.focus()},0))},[H,W,se]),o.useEffect(()=>{if(H)return window.addEventListener("resize",se),window.addEventListener("scroll",se,!0),()=>{window.removeEventListener("resize",se),window.removeEventListener("scroll",se,!0)}},[H,se]),o.useEffect(()=>{if(N<0||!j.current)return;const Q=j.current.children[N];Q==null||Q.scrollIntoView({block:"nearest"})},[N]);const M=o.useCallback(Q=>{t(Q),_(!1),L("")},[t]),O=o.useRef(H);O.current=H;const oe=o.useRef(ee);oe.current=ee;const A=o.useRef(N);A.current=N;const U=o.useRef(u);U.current=u;const ne=o.useRef(M);ne.current=M,o.useEffect(()=>{function Q(V){var re,F;const w=document.activeElement,R=((re=J.current)==null?void 0:re.contains(w))??!1,B=((F=C.current)==null?void 0:F.contains(w))??!1;if(!(!R&&!B)){if(!O.current){(V.key==="Enter"||V.key===" "||V.key==="ArrowDown")&&(V.preventDefault(),_(!0));return}switch(V.key){case"ArrowDown":V.preventDefault(),k(le=>Math.min(le+1,oe.current.length-1));break;case"ArrowUp":V.preventDefault(),k(le=>Math.max(le-1,U.current?-1:0));break;case"Enter":{V.preventDefault();const le=A.current,Ee=oe.current;le===-1&&U.current?ne.current(""):Ee[le]&&!Ee[le].disabled&&ne.current(Ee[le].value);break}case"Escape":V.preventDefault(),V.stopPropagation(),_(!1),L("");break}}}return document.addEventListener("keydown",Q),()=>document.removeEventListener("keydown",Q)},[]);const ie=e.jsxs("div",{ref:C,"data-bonsaif-select-dropdown":"true",className:"rounded-xl shadow-xl overflow-hidden",style:{...q,background:"var(--bg-card)",border:"1px solid var(--border)"},children:[W&&e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",style:{borderBottom:"1px solid var(--border)"},children:[e.jsx(T.HiMagnifyingGlass,{className:"w-3.5 h-3.5 flex-shrink-0",style:{color:"var(--text-muted)"}}),e.jsx("input",{ref:te,value:E,onChange:Q=>{L(Q.target.value),k(-1)},placeholder:"Buscar…",className:"min-w-0 flex-1 text-sm bg-transparent outline-none",style:{color:"var(--text-main)"}}),E&&e.jsx("button",{type:"button",onMouseDown:Q=>{Q.preventDefault(),L("")},children:e.jsx(T.HiXMark,{className:"w-3.5 h-3.5",style:{color:"var(--text-muted)"}})})]}),e.jsxs("ul",{ref:j,role:"listbox",className:"overflow-y-auto",style:{maxHeight:W?220:180,scrollbarWidth:"thin",scrollbarColor:"var(--border) transparent",overscrollBehavior:"contain"},children:[u&&e.jsx("li",{role:"option","aria-selected":r==="",onMouseDown:Q=>{Q.preventDefault(),M("")},onMouseEnter:()=>k(-1),className:"flex items-center gap-2 px-3 py-2 cursor-pointer text-sm transition-colors",style:{background:N===-1&&!E.trim()?"var(--bg-hover)":"transparent",color:"var(--text-muted)",fontStyle:"italic"},children:u}),ee.map((Q,V)=>{const R=V===N,B=Q.value===r;return e.jsxs("li",{role:"option","aria-selected":B,onMouseDown:re=>{re.preventDefault(),Q.disabled||M(Q.value)},onMouseEnter:()=>!Q.disabled&&k(V),className:"flex items-center gap-2 px-3 py-2 cursor-pointer text-sm transition-colors",style:{background:R?"var(--bg-hover)":B?"color-mix(in srgb, var(--primary) 6%, transparent)":"transparent",color:Q.disabled?"var(--text-muted)":"var(--text-main)",cursor:Q.disabled?"not-allowed":"pointer",boxShadow:B?"inset 2px 0 0 var(--primary)":void 0},children:[Q.color&&e.jsx("span",{className:"flex-shrink-0 w-2.5 h-2.5 rounded-full",style:{background:Q.color}}),e.jsxs("span",{className:"min-w-0 flex flex-1 items-baseline gap-1 overflow-hidden",children:[e.jsx("span",{className:"truncate",children:Q.label}),Q.sublabel&&e.jsx("span",{className:"min-w-0 flex-shrink truncate",style:{color:"var(--text-muted)",fontSize:12},children:Q.sublabel})]}),Q.badge&&e.jsx("span",{className:"text-xs flex-shrink-0",style:{color:"var(--text-muted)"},children:Q.badge})]},Q.value)}),ee.length===0&&e.jsx("li",{className:"px-3 py-4 text-sm text-center",style:{color:"var(--text-muted)"},children:"Sin resultados"})]})]});return e.jsxs("div",{ref:J,className:`relative ${p||"w-full"}`,style:b,children:[e.jsxs("button",{type:"button",disabled:f,onClick:()=>!f&&_(Q=>!Q),className:"flex w-full items-center gap-2 rounded-lg text-left text-sm transition-colors focus:outline-none",style:{height:jn(v),padding:jn(y),background:Z?"transparent":"var(--bg-input)",color:ae?"var(--text-main)":"var(--text-muted)",border:Z?"1px solid transparent":`1px solid ${$}`,opacity:f?.5:1,cursor:f?"not-allowed":"pointer"},"aria-haspopup":"listbox","aria-expanded":H,"aria-label":s,children:[(ae==null?void 0:ae.color)&&e.jsx("span",{className:"flex-shrink-0 w-2.5 h-2.5 rounded-full",style:{background:ae.color}}),e.jsx("span",{className:"min-w-0 flex flex-1 items-baseline gap-1 overflow-hidden",children:ae?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"truncate",children:ae.label}),i&&ae.sublabel&&e.jsx("span",{className:"min-w-0 flex-shrink truncate",style:{color:"var(--text-muted)",fontSize:12},children:ae.sublabel})]}):e.jsx("span",{className:"truncate",children:c})}),ae&&u?e.jsx("span",{role:"button",tabIndex:-1,onMouseDown:Q=>{Q.preventDefault(),Q.stopPropagation(),M("")},className:"flex-shrink-0 rounded-full p-0.5 transition-colors hover:bg-black/10",style:{color:"var(--text-muted)"},children:e.jsx(T.HiXMark,{className:"w-3 h-3"})}):e.jsx(T.HiChevronDown,{className:"flex-shrink-0 w-4 h-4 transition-transform",style:{color:"var(--text-muted)",transform:H?"rotate(180deg)":"rotate(0deg)"}})]}),H&&K&&er.createPortal(ie,document.body)]})}function qt(r){if(r!==void 0)return typeof r=="number"?`${r}px`:r}function wl({value:r,onChange:t,placeholder:n="Buscar...",className:a="",height:s=40,padding:l="0 10px 0 30px",iconLeft:i=10}){return e.jsxs("div",{className:`relative ${a}`,children:[e.jsx(T.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:qt(i)}}),e.jsx("input",{type:"text",value:r,onChange:c=>t(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:qt(s),padding:qt(l)}})]})}function kl({value:r,onChange:t,options:n,placeholder:a,icon:s,className:l="",height:i=40,padding:c,iconLeft:u=10,searchable:f=!0}){const p=s?n.map((b,m)=>m===0&&!b.color?{...b,sublabel:b.sublabel??void 0}:b):n;return e.jsxs("div",{className:`relative ${l}`,children:[s&&e.jsx("span",{className:"pointer-events-none absolute top-1/2 z-10 -translate-y-1/2 text-[var(--text-muted)]",style:{left:qt(u)},children:s}),e.jsx(Lr,{value:r,onChange:t,options:p,placeholder:a,searchable:f,minOptionsForSearch:5,height:i,padding:c??(s?"0 10px 0 30px":"0 10px"),className:"[&>button]:text-sm [&>button]:[background:var(--bg-card)]"})]})}const Nl={sm:"24rem",md:"28rem",lg:"32rem",xl:"40rem","2xl":"48rem","4xl":"56rem","5xl":"64rem"},Ut=180,Sl="bg-[color-mix(in_srgb,var(--bg-main)_72%,transparent)] backdrop-blur-sm";function qn({open:r,onClose:t,title:n,subtitle:a,leadingIcon:s,headerActions:l,footer:i,children:c,size:u="md",maxWidth:f,zIndex:p=1e3,closeOnBackdrop:b=!0,closeOnEscape:m=!0,showCloseButton:v=!0,placement:y="center",bodyClassName:S="px-6 py-5",panelClassName:h="",backdropClassName:H=Sl,contentClassName:_="p-4",ariaLabel:E,frameless:L=!1,disabled:N=!1}){const[k,K]=o.useState(!1),[P,q]=o.useState(!1),X=o.useRef(null);if(o.useEffect(()=>(r?(X.current&&clearTimeout(X.current),K(!0),requestAnimationFrame(()=>requestAnimationFrame(()=>q(!0)))):(q(!1),X.current=setTimeout(()=>K(!1),Ut+40)),()=>{X.current&&clearTimeout(X.current)}),[r]),o.useEffect(()=>{if(r)return document.body.style.overflow="hidden",()=>{document.body.style.overflow=""}},[r]),o.useEffect(()=>{if(!r||!m)return;const ae=Z=>{Z.key==="Escape"&&t()};return window.addEventListener("keydown",ae),()=>window.removeEventListener("keydown",ae)},[m,t,r]),!k)return null;const J=n||a||s||l||v,C=f??Nl[u],te=y==="bottom-mobile"?"items-end sm:items-center justify-center p-0 sm:p-4":"items-center justify-center",j=y==="bottom-mobile"?"rounded-t-2xl sm:rounded-2xl":"rounded-2xl",W=P?"translateY(0) scale(1)":y==="bottom-mobile"?"translateY(16px) scale(0.98)":"translateY(10px) scale(0.96)";return er.createPortal(e.jsxs("div",{role:"dialog","aria-modal":"true","data-bonsaif-overlay":"true","aria-label":E??n,className:`fixed inset-0 flex ${te} ${_}`,style:{zIndex:p},children:[e.jsx("div",{className:`absolute inset-0 ${H}`,onClick:b?t:void 0,style:{opacity:P?1:0,transition:`opacity ${Ut}ms ease`}}),e.jsxs("div",{className:`relative z-10 flex max-h-[92dvh] w-full flex-col overflow-hidden ${L?"shadow-none":"shadow-2xl"} ${j} ${h}`,style:{maxWidth:C,background:L?"transparent":"var(--bg-card)",border:L?"none":"1px solid var(--border)",opacity:P?1:0,transform:W,transition:`opacity ${Ut}ms ease, transform ${Ut}ms ease`},onClick:ae=>ae.stopPropagation(),children:[N&&e.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)"}}),J&&e.jsxs("div",{className:"flex flex-shrink-0 items-center justify-between gap-3 px-6 py-4",style:{borderBottom:"1px solid var(--border)"},children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[s&&e.jsx("div",{className:"flex-shrink-0",children:s}),(n||a)&&e.jsxs("div",{className:"min-w-0",children:[n&&e.jsx("h2",{className:"truncate text-base font-semibold",style:{color:"var(--text-main)"},children:n}),a&&e.jsx("p",{className:"truncate text-xs",style:{color:"var(--text-muted)"},children:a})]})]}),e.jsxs("div",{className:"flex flex-shrink-0 items-center gap-2",children:[l,v&&e.jsx(Fe,{variant:"icon",onClick:t,title:"Cerrar",children:e.jsx(T.HiXMark,{className:"h-5 w-5"})})]})]}),e.jsx("div",{className:`min-h-0 flex-1 overflow-y-auto ${S}`,children:c}),i&&e.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 Cl={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 El({open:r,title:t,description:n,confirmLabel:a="Confirmar",cancelLabel:s="Cancelar",variant:l="danger",closeOnBackdrop:i=!0,onConfirm:c,onCancel:u}){const f=Cl[l];return e.jsx(qn,{open:r,onClose:u,size:"md",zIndex:9998,showCloseButton:!1,bodyClassName:"p-0",panelClassName:"overflow-visible",ariaLabel:t,closeOnBackdrop:i,children:e.jsxs("div",{className:"relative px-6 pb-6 pt-6",children:[e.jsx(Fe,{variant:"icon",onClick:u,className:"absolute right-3 top-3 h-8 w-8 hover:opacity-70",style:{color:"var(--text-muted)"},"aria-label":"Cancelar",children:e.jsx(T.HiXMark,{className:"h-4 w-4"})}),e.jsxs("div",{className:"flex gap-3 pr-8",children:[e.jsx("div",{className:"mt-0.5 flex h-10 w-10 flex-shrink-0 items-center justify-center rounded-xl",style:{background:f.iconBg},children:e.jsx(T.HiExclamationTriangle,{className:"h-5 w-5",style:{color:f.iconColor}})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h2",{className:"text-base font-semibold leading-snug",style:{color:"var(--text-main)"},children:t}),n?e.jsx("div",{className:"mt-1.5 text-sm leading-relaxed",style:{color:"var(--text-muted)"},children:n}):null]})]}),e.jsxs("div",{className:"mt-6 flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",children:[e.jsx(Fe,{variant:"secondary",onClick:u,className:"w-full sm:w-auto sm:min-w-[7.5rem]",style:{background:"var(--bg-input)"},children:s}),e.jsx(Fe,{variant:"danger",onClick:c,className:"w-full sm:w-auto sm:min-w-[7.5rem]",style:{background:f.btnBg,color:f.btnColor,borderColor:"transparent"},children:a})]})]})})}function Ml(r){return r?typeof r=="function"?r():r:""}function Ll(r){return/^https?:\/\//i.test(r)}function Ua(r,t){try{return new URL(r,t).toString()}catch{return r}}function Tl(r,t,n,a=!1){const s=typeof r=="function"?r():r,l=t?t(s):s;if(!l||Ll(l))return l;const i=Ml(n);return i?Ua(l,i):a&&typeof window<"u"?Ua(l,window.location.origin):l}function $l({url:r,resolveUrl:t,baseUrl:n,useWindowOriginForRelative:a=!1,title:s="Copiar link",copiedTitle:l="Link copiado",icon:i=e.jsx(T.HiLink,{className:"h-3.5 w-3.5"}),...c}){return e.jsx(_n,{...c,value:()=>Tl(r,t,n,a),title:s,copiedTitle:l,icon:i})}const Vt=[25,50,100,200,500];let rr={dataTable:{pageSizeOptions:[...Vt]}};function Al(){if(typeof window>"u")return;const t=window.__BONSAIF_DATA_TABLE_PREFERENCES_ENDPOINT__;return typeof t=="string"&&t.trim().length>0?t.trim().replace(/\/+$/,""):void 0}function Un(){const r=rr.dataTable.preferencesEndpoint,t=Al();return r&&r.trim().length>0?r.trim().replace(/\/+$/,""):t}function Dl(r){if(!Array.isArray(r))return[...Vt];const t=Array.from(new Set(r.map(n=>typeof n=="number"?Math.floor(n):Number.NaN).filter(n=>Number.isFinite(n)&&n>0)));return t.length>0?t:[...Vt]}function Va(r){if(typeof r!="string")return;const t=r.trim();if(t)return t.replace(/\/+$/,"")}function Il(r){if(!r||typeof r!="object"||!r.dataTable)return;const t=Va(r.dataTable.preferencesEndpoint);rr={...rr,dataTable:{...rr.dataTable,pageSizeOptions:Dl(r.dataTable.pageSizeOptions),preferencesEndpoint:t??rr.dataTable.preferencesEndpoint}}}function Bl(){return{dataTable:{pageSizeOptions:[...rr.dataTable.pageSizeOptions]}}}function mt(){return[...rr.dataTable.pageSizeOptions]}function Ol(){rr={dataTable:{pageSizeOptions:[...Vt]}}}function Hl(r){rr={...rr,dataTable:{...rr.dataTable,preferencesEndpoint:Va(r)}}}const Gt=[{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"}],Pl=Gt.map(r=>({value:r.value,label:r.label})),Fl=12,zl={layout:!0,filters:!1,sort:!1,bql:!1,pagination:!0},Ga={layout:!0,filters:!0,sort:!0,bql:!0,pagination:!0},_l="bonsaif-ui:datatable:",jl="[&_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",Wl=[],ql=52;function br(r){if(!r)return 150;const t=parseInt(r,10);return isNaN(t)||t<=0?150:t}function Ka(r){return!!(r&&(Array.isArray(r.columnOrder)&&r.columnOrder.length>0||r.columnWidths&&Object.keys(r.columnWidths).length>0||Array.isArray(r.hiddenColumnKeys)&&r.hiddenColumnKeys.length>0||r.filters&&Object.keys(r.filters).length>0||r.conditionFilters&&Object.keys(r.conditionFilters).length>0||r.sort||typeof r.bql=="string"||Array.isArray(r.bqlHistory)&&r.bqlHistory.length>0||typeof r.pageSize=="number"))}function Xa(r){return`${_l}${r}`}function Kt(r){try{const t=window.localStorage.getItem(Xa(r));if(!t)return null;const n=JSON.parse(t);return n&&typeof n=="object"?n:null}catch{return null}}function Ul(r,t){try{window.localStorage.setItem(Xa(r),JSON.stringify(t))}catch{}}function Vl(r,t){if(r===!0)return{...Ga};if(r===!1)return{layout:!1,filters:!1,sort:!1,bql:!1,pagination:!1};if(t&&r==null)return{...Ga};const n={...zl,...r??{}};return t&&(typeof r!="object"||r.pagination!==!1)&&(n.pagination=!0),n}function Ya(...r){return r.reduce((t,n)=>({...t,...n??{}}),{})}function Vn(r,t,n){return typeof r!="number"||r<=0?n:yt(t).includes(r)?r:n}function ht(r){if(!r||typeof r!="object")return!1;const t=r;return typeof t.key=="string"&&(t.dir==="asc"||t.dir==="desc")}function gt(r,t){if(!r||typeof r!="object"||Array.isArray(r))return{};const n=Object.entries(r).flatMap(([a,s])=>{if(!t.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 vt(r,t){if(!r||typeof r!="object"||Array.isArray(r))return{};const n=new Set(Gt.map(s=>s.value)),a=Object.entries(r).flatMap(([s,l])=>{if(!t.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 Ye(r,t){if(Tr(r))return ql;const n=r.minWidth??80,a=r.maxWidth??1/0;return Math.min(a,Math.max(n,t))}function Gl(r){const t=window.getComputedStyle(r);return parseFloat(t.paddingLeft)+parseFloat(t.paddingRight)}function Tr(r){return r.key==="actions"||r.key==="acciones"?!0:typeof r.header=="string"&&r.header.trim().toLowerCase()==="acciones"}function Gn(r){return r.sticky===!0}function Za(r){return!(r.reorderable===!1||r.sticky&&r.reorderable!==!0)}function vr(r,t){const n=t.filter(Gn).map(i=>i.key);if(n.length===0)return r;const a=new Set(n),s=n.filter(i=>r.includes(i)),l=r.filter(i=>!a.has(i));return[...s,...l]}function Kl(r,t){if(t<=7)return Array.from({length:t},(a,s)=>s+1);const n=[1];r>3&&n.push("...");for(let a=Math.max(2,r-1);a<=Math.min(t-1,r+1);a++)n.push(a);return r<t-2&&n.push("..."),n.push(t),n}function xr(r,t){var i;const n=new Set(t.filter(c=>c.hideable!==!1).map(c=>c.key)),a=Array.from(new Set(r??[])).filter(c=>n.has(c));if(t.filter(c=>!a.includes(c.key)).length>0)return a;const l=(i=t.find(c=>c.hideable!==!1))==null?void 0:i.key;return l?a.filter(c=>c!==l):[]}function Xl(r){return r==null||r===""?"(Vacio)":r instanceof Date?r.toLocaleDateString():String(r)}function Vr(r){return r==null||typeof r=="boolean"?"":typeof r=="string"||typeof r=="number"?String(r):Array.isArray(r)?r.map(Vr).join(" ").trim():o.isValidElement(r)?Vr(r.props.children):""}function Xt(r,t){const n=r.filterValue?r.filterValue(t):r.sortKey?t[r.sortKey]:r.cell(t);return typeof n=="string"||typeof n=="number"||typeof n=="boolean"||n===null||n===void 0||n instanceof Date?Xl(n):Vr(n).trim()}function xt(r){const t=r.replace(/,/g,"").trim();if(!t)return null;const n=Number(t);return Number.isFinite(n)?n:null}function Gr(r,t){const n=xt(r),a=xt(t);return n!==null&&a!==null?n-a:r.localeCompare(t,void 0,{numeric:!0,sensitivity:"base"})}function yt(r){const t=Array.from(new Set(r.map(n=>Math.floor(n)).filter(n=>Number.isFinite(n)&&n>0)));return t.length>0?t:mt()}function Yl(r,t,n){var i,c;const a=((i=t.value)==null?void 0:i.trim())??"",s=((c=t.valueTo)==null?void 0:c.trim())??"",l=Gt.find(u=>u.value===t.operator);if((l==null?void 0:l.valueMode)==="single"&&!a||(l==null?void 0:l.valueMode)==="between"&&(!a||!s))return!0;switch(t.operator){case"equals":return r.toLowerCase()===a.toLowerCase();case"notEquals":return r.toLowerCase()!==a.toLowerCase();case"greaterThan":return Gr(r,a)>0;case"greaterThanOrEqual":return Gr(r,a)>=0;case"lessThan":return Gr(r,a)<0;case"lessThanOrEqual":return Gr(r,a)<=0;case"between":return Gr(r,a)>=0&&Gr(r,s)<=0;case"top10":case"bottom10":{const f=n.map(b=>({value:b,number:xt(b)})).filter(b=>b.number!==null).sort((b,m)=>b.number-m.number).map(b=>b.value);return(t.operator==="top10"?f.slice(-10):f.slice(0,10)).includes(r)}case"aboveAverage":case"belowAverage":{const u=n.map(xt).filter(b=>b!==null);if(u.length===0)return!1;const f=u.reduce((b,m)=>b+m,0)/u.length,p=xt(r);return p===null?!1:t.operator==="aboveAverage"?p>f:p<f}default:return!0}}function Qa({children:r,className:t="",style:n}){return e.jsx(Mr,{onlyWhenOverflow:!0,className:t,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",...n},children:r})}function Ja({columns:r,data:t,getRowId:n,loading:a=!1,skeletonRows:s=8,emptyIcon:l,emptyText:i="Sin resultados",initialEmptyDelay:c=450,onRowClick:u,renderExpandedRow:f,getRowCanExpand:p,expandedRowIds:b,defaultExpandedRowIds:m=[],onExpandedRowIdsChange:v,expandOnRowClick:y=!1,selected:S,onToggleOne:h,onToggleAll:H,highlightSelected:_=!0,rowClassName:E,getRowCategory:L,stickyHeader:N=!0,pageSize:k=25,pageSizeOptions:K,pageSizeSelectWidth:P=62,pageSizeSelectHeight:q=30,pageSizeSelectPadding:X="0 7px",totalRows:J,page:C,onPageChange:te,onPageSizeChange:j,storageKey:W,stickyFirstColumn:ae=!1,bottomOffset:Z=0,compact:$=!0,restrictHeight:ee=!0,maxHeight:se,minTableWidth:M,enableColumnVisibility:O=!0,enableColumnFilters:oe=!0,hiddenColumnKeys:A,defaultHiddenColumnKeys:U=Wl,onHiddenColumnKeysChange:ne,columnVisibilityLabel:ie="Columnas",enableBql:Q=!1,bqlValue:V,defaultBqlValue:w="",onBqlChange:R,bqlDescription:B="Filtra registros con Bonsaif Query Language",bqlPlaceholder:re=`status = activo
|
|
2
|
-
rol IN (admin, employee)`,bqlQuickFilters:
|
|
3
|
-
`).map(
|
|
4
|
-
${g}`;ya(x,ma.current??void 0),requestAnimationFrame(()=>{const G=ma.current;if(!G)return;G.focus();const de=G.value.length;G.setSelectionRange(de,de),ya(G.value,G)})}o.useEffect(()=>{mn(mr)},[mr]);const En=o.useCallback(()=>{const d=pa.current;if(!d)return;const g=d.getBoundingClientRect(),D=12,x=8,G=Math.min(780,Math.max(320,window.innerWidth-32)),de=Math.max(D,window.innerWidth-G-D),pe=Math.min(Math.max(D,g.left),de),we=g.bottom+x,je=window.innerHeight-g.top+x,ze=window.innerHeight-we-D,Ue=g.top-D-x,ke=ze<280&&Ue>ze,ye=Math.max(240,ke?Ue:ze);Yd({position:"fixed",zIndex:1e4,left:pe,top:ke?void 0:we,bottom:ke?je:void 0,width:G,maxWidth:"calc(100vw - 24px)",maxHeight:ye,overflowY:"auto"})},[]);o.useEffect(()=>{if(!hr)return;function d(x){var de,pe;if(Date.now()<hs.current)return;const G=x.target;(de=pa.current)!=null&&de.contains(G)||(pe=ms.current)!=null&&pe.contains(G)||(Br(!1),tt(!1),nt(!1))}function g(x){x.key==="Escape"&&(Br(!1),tt(!1),nt(!1))}function D(){En()}return En(),document.addEventListener("mousedown",d),window.addEventListener("keydown",g),window.addEventListener("resize",D),window.addEventListener("scroll",D,!0),()=>{document.removeEventListener("mousedown",d),window.removeEventListener("keydown",g),window.removeEventListener("resize",D),window.removeEventListener("scroll",D,!0)}},[hr,En]);function Ts(d){const g=xr(d,r);He||Ke(g),ne==null||ne(g)}function bu(d){Ts(_e.includes(d)?_e.filter(g=>g!==d):[..._e,d])}function pu(){Ts([])}const wa=o.useCallback((d=yn.current)=>{if(!d)return;const g=d.getBoundingClientRect(),D=Math.min(292,Math.max(240,window.innerWidth-16)),x=Math.max(8,window.innerWidth-D-8),G=Math.min(Math.max(8,g.right-D),x),de=window.innerHeight-g.bottom,pe=g.bottom+6,we=window.innerHeight-g.top+6,ze=de<360&&g.top>de?void 0:pe,Ue=ze===void 0?we:void 0,ke=Math.max(220,ze===void 0?g.top-16:window.innerHeight-pe-8),ye={position:"fixed",zIndex:9999,left:G,top:ze,bottom:Ue,width:D,maxWidth:"calc(100vw - 16px)",maxHeight:ke,"--dt-column-menu-max-height":`${ke}px`};Qd(ye)},[]);function $s(d,g,D=null){d.preventDefault(),d.stopPropagation();const x=yn.current===d.currentTarget&&ir===g&&Tt===D;if(Xe&&x){Dr(!1),pn(null);return}yn.current=d.currentTarget,Ud(g),pn(D),us(""),wa(d.currentTarget),Dr(!0)}function mu(d){if(Tr(d))return;const g=Nr.current;if(!g)return;const x=Array.from(g.querySelectorAll("[data-dt-column-key]")).filter(G=>G.dataset.dtColumnKey===d.key).reduce((G,de)=>{const pe=de.querySelector("[data-dt-autofit-content]"),we=pe?pe.scrollWidth:Math.max(de.scrollWidth,de.offsetWidth);return Math.max(G,Math.ceil(we+Gl(de)))},0);x<=0||it(G=>({...G,[d.key]:Ye(d,x+12)}))}o.useEffect(()=>{it(d=>{const g=Object.fromEntries(r.map(D=>[D.key,Ye(D,br(D.width))]));return Object.fromEntries(r.map(D=>[D.key,Ye(D,d[D.key]??g[D.key])]))})},[lr,r]),o.useEffect(()=>{He||Ke(d=>xr(d,r))},[lr,r,He]),o.useEffect(()=>{function d(x){var pe,we;const G=x.target,de=x.target;de!=null&&de.closest("[data-bonsaif-select-dropdown='true']")||!((pe=gs.current)!=null&&pe.contains(G))&&!((we=yn.current)!=null&&we.contains(G))&&(Dr(!1),pn(null))}function g(x){x.key==="Escape"&&(Dr(!1),pn(null))}function D(){wa()}return Xe&&(document.addEventListener("mousedown",d),window.addEventListener("keydown",g),window.addEventListener("resize",D),window.addEventListener("scroll",D,!0)),()=>{document.removeEventListener("mousedown",d),window.removeEventListener("keydown",g),window.removeEventListener("resize",D),window.removeEventListener("scroll",D,!0)}},[Xe,wa]);const Ot=o.useRef(null);o.useEffect(()=>{function d(D){const x=Ot.current;if(!x)return;const G=D.clientX-x.startX,de=r.find(pe=>pe.key===x.colKey);de&&it(pe=>({...pe,[x.colKey]:Ye(de,x.startWidth+G)}))}function g(){Ot.current&&(Ot.current=null,document.body.style.cursor="",document.body.style.userSelect="")}return document.addEventListener("pointermove",d),document.addEventListener("pointerup",g),()=>{document.removeEventListener("pointermove",d),document.removeEventListener("pointerup",g)}},[r]);const Ht=o.useRef(null),[As,ka]=o.useState(null);function hu(d,g){const D=r.find(x=>x.key===d);if(!D||!Za(D)){g.preventDefault();return}Ht.current=st.indexOf(d),g.dataTransfer.effectAllowed="move"}function gu(d,g){g.preventDefault(),g.dataTransfer.dropEffect="move";const D=st.indexOf(d);As!==D&&ka(D)}function vu(d,g){g.preventDefault();const D=Ht.current,x=st.indexOf(d);D!==null&&D!==x&<(G=>{const de=[...G],[pe]=de.splice(D,1);return de.splice(x,0,pe),vr(de,r)}),Ht.current=null,ka(null)}function xu(){Ht.current=null,ka(null)}function yu(d){d.sortKey&&Pr(g=>(g==null?void 0:g.key)===d.key?{key:d.key,dir:g.dir==="asc"?"desc":"asc"}:{key:d.key,dir:"asc"})}o.useEffect(()=>{wn(1)},[t]),o.useEffect(()=>{wn(1)},[cr,Je]);const Fr=!!(te&&j),zr=k!==!1,Ds=o.useMemo(()=>yt(K??mt()),[K]),We=Fr?C??1:ou,ur=Fr||zr?kn:t.length,fr=!!S&&!!h&&!!H,ct=!!f,Is=o.useMemo(()=>new Set(ba?Array.from(b??[]):fs),[ba,b,fs]),wu=(ct?40:0)+(fr?40:0),Na=!nu&&(Ns||ae),Mn=(()=>{if(!Na)return{};let d=wu;const g={};return Re.forEach((D,x)=>{(Gn(D)||!Ns&&ae&&x===0)&&(g[D.key]=d,d+=Hr[D.key]??Ye(D,br(D.width)))}),g})(),Sa=Object.keys(Mn),Ca=Sa.length>0?Sa[Sa.length-1]:null,ku=fr&&t.length>0&&S.size===t.length,Nu=fr&&S.size>0&&S.size<t.length,Ln=o.useMemo(()=>{const d=Object.entries(Je),g=Object.entries(cr);return d.length===0&&g.length===0?t:t.filter(D=>d.every(([x,G])=>{const de=r.find(pe=>pe.key===x);return de?G.includes(Xt(de,D)):!0})&&g.every(([x,G])=>{const de=r.find(we=>we.key===x);if(!de)return!0;const pe=t.map(we=>Xt(de,we));return Yl(Xt(de,D),G,pe)}))},[cr,Je,r,t]),_r=o.useMemo(()=>{if(!Be)return Ln;const d=r.find(g=>g.key===Be.key&&g.sortKey);return d!=null&&d.sortKey?[...Ln].sort((g,D)=>{const x=g[d.sortKey],G=D[d.sortKey],de=x===G?0:x==null?1:G==null||x<G?-1:1;return Be.dir==="asc"?de:-de}):Ln},[Ln,Be,r]),Bs=o.useMemo(()=>{if(Fr||!zr)return _r;const d=(We-1)*ur;return _r.slice(d,d+ur)},[_r,Fr,zr,We,ur]),jr=Fr?J??t.length:_r.length,Ea=zr?Math.max(1,Math.ceil(jr/ur)):1,Su=Math.min(...Ds),Cu=zr&&(jr>ur||jr>Su),Eu=zr?(We-1)*ur+1:1,Mu=zr?Math.min(We*ur,jr):jr;function Ma(d){if(a)return;const g=Math.max(1,Math.min(d,Ea));Fr?te(g):wn(g)}function Lu(d){a||(W&&(Or.current=W),Nn(d),Fr?(j(d),te(1)):(wn(1),j==null||j(d)))}function Os(d){const g=new Set(Is);g.has(d)?g.delete(d):g.add(d);const D=Array.from(g);ba||Vd(D),v==null||v(D)}o.useEffect(()=>{Se==null||Se({bql:mr,filters:Je,conditionFilters:cr,sort:Be,page:We,pageSize:ur,hiddenColumnKeys:_e})},[mr,Je,cr,Be,We,ur,_e,Se]);const Hs=d=>d==="center"?"text-center":d==="right"?"text-right":"text-left",Tu="color-mix(in srgb, var(--primary) 6%, var(--bg-card))",La="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%)",Me="color-mix(in srgb, var(--border) 62%, var(--bg-card))",Wr="color-mix(in srgb, var(--primary) 24%, var(--border))",Tn=`inset 0 0 0 1px ${Me}`,Ps=Re.reduce((d,g)=>d+(Hr[g.key]??br(g.width)),(ct?40:0)+(fr?40:0)),Fs=typeof M=="number"?M:typeof M=="string"?Number(((qs=M.match(/^(\d+(?:\.\d+)?)px$/))==null?void 0:qs[1])??NaN):NaN,Pt=Number.isFinite(Fs)?Math.max(Ps,Fs,ys):Math.max(Ps,ys),$n=M??Pt,dt=`${ct?"40px ":""}${fr?"40px ":""}${Re.map(d=>`${Hr[d.key]??br(d.width)}px`).join(" ")}`;o.useEffect(()=>{Be&&_e.includes(Be.key)&&Pr(null)},[_e,Be]);function zs(d){return d?typeof d=="string"?{key:d,label:d}:d:null}const An=()=>e.jsxs("div",{role:"row",className:"grid",style:{gridTemplateColumns:dt,background:La,borderBottom:`1px solid ${Wr}`},children:[ct&&e.jsx("div",{role:"columnheader",className:`${$?"px-2 py-1.5":"px-3 py-2.5"} w-10`,style:{borderBottom:`1px solid ${Wr}`,borderRight:`1px solid ${Me}`}}),fr&&e.jsx("div",{role:"columnheader",className:`${$?"px-2 py-1.5":"px-3 py-2.5"} w-10`,style:Na?{position:"sticky",left:0,zIndex:12,background:La,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)",boxShadow:`inset 0 -1px 0 ${Wr}`,borderRight:`1px solid ${Me}`}:{borderBottom:`1px solid ${Wr}`,borderRight:`1px solid ${Me}`},children:e.jsx(Wt,{size:"sm",checked:ku,indeterminate:Nu,onChange:H,"aria-label":"Seleccionar todos",containerClassName:"items-center",className:"cursor-pointer"})}),Re.map((d,g)=>{const D=(Be==null?void 0:Be.key)===d.key,x=!!d.sortKey,G=Tr(d),de=Mn[d.key],pe=de!==void 0,we=d.key===Ca,je=Za(d),ze=As===g,ke=(Hr[d.key]??br(d.width))<120,ye=Object.prototype.hasOwnProperty.call(Je,d.key)||Object.prototype.hasOwnProperty.call(cr,d.key);return e.jsxs("div",{role:"columnheader","data-dt-column-key":d.key,className:`group select-none ${ke?"text-left":Hs(d.align)}`,style:{...pe?{position:"sticky",left:de,zIndex:12,background:La,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)",boxShadow:we?`3px 0 6px -2px rgba(0,0,0,0.10), inset 0 -1px 0 ${Wr}`:`inset 0 -1px 0 ${Wr}`,borderRight:`1px solid ${Me}`}:{position:"relative",borderBottom:`1px solid ${Wr}`,borderRight:`1px solid ${Me}`},color:D?"var(--primary)":"var(--text-muted)",whiteSpace:"nowrap",transition:"color 0.15s",borderLeft:ze?"2px solid var(--primary)":"2px solid transparent",cursor:"default",padding:G?$?"7px 6px":"9px 8px":$?"8px 6px 10px":"10px 8px 12px"},onDragOver:Ne=>{(je||Ht.current!==null)&&gu(d.key,Ne)},onDrop:Ne=>vu(d.key,Ne),children:[e.jsxs("div",{className:`flex min-w-0 items-center gap-1 ${G?"justify-center":ke?"justify-start":d.align==="center"?"justify-center":d.align==="right"?"justify-end":"justify-start"}`,children:[je?e.jsx("span",{draggable:!0,onDragStart:Ne=>{Ne.stopPropagation(),hu(d.key,Ne)},onDragEnd:Ne=>{Ne.stopPropagation(),xu()},onClick:Ne=>Ne.stopPropagation(),title:"Arrastrar para mover columna","aria-label":"Arrastrar para mover columna",className:`absolute left-0 top-0 z-10 inline-flex h-full w-3 shrink-0 rounded-sm transition-colors duration-150 hover:bg-[var(--primary)]/15 ${ze?"bg-[var(--primary)]/20":""}`,style:{cursor:"grab"}}):null,G?e.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:e.jsx(T.HiCog6Tooth,{className:"h-3.5 w-3.5"})}):e.jsx(Qa,{className:"min-w-0 flex-1",children:e.jsx("span",{"data-dt-autofit-content":!0,className:`inline-flex max-w-full items-center font-semibold uppercase tracking-wider ${$?"text-[11px]":"text-xs"}`,children:e.jsx("span",{className:"min-w-0 truncate",children:d.header})})}),x&&e.jsx("button",{type:"button","aria-label":`Ordenar por ${String(d.header)}`,title:"Ordenar",onClick:Ne=>{Ne.stopPropagation(),yu(d)},"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 ${D?"opacity-100":"opacity-0 group-hover:opacity-100 group-focus-within:opacity-100"}`,style:{bottom:"-0.5rem",top:"auto"},children:D?Be.dir==="asc"?e.jsx(T.HiChevronUp,{className:"h-3 w-3"}):e.jsx(T.HiChevronDown,{className:"h-3 w-3"}):e.jsx(T.HiChevronUpDown,{className:"h-3 w-3"})}),oe&&!G&&cu(d)&&e.jsx("button",{type:"button","aria-haspopup":"menu","aria-expanded":Xe&&Tt===d.key,"aria-label":`Filtrar ${String(d.header)}`,title:"Filtrar",onClick:Ne=>$s(Ne,"filter",d.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 ${Xe&&ir==="filter"&&Tt===d.key?"bg-[var(--bg-card)] text-[var(--primary)] opacity-100":ye?"text-[var(--primary)] opacity-100":""}`,children:ye?e.jsx(T.HiFunnel,{className:"h-3.5 w-3.5"}):e.jsx(T.HiEllipsisVertical,{className:"h-3.5 w-3.5"})})]}),!G&&e.jsx("span",{role:"separator","aria-orientation":"vertical",title:"Arrastrar para redimensionar. Doble click para autoajustar",onPointerDown:Ne=>{Ne.preventDefault(),Ne.stopPropagation(),Ot.current={colKey:d.key,startX:Ne.clientX,startWidth:Hr[d.key]??150},document.body.style.cursor="col-resize",document.body.style.userSelect="none"},onDoubleClick:Ne=>{Ne.preventDefault(),Ne.stopPropagation(),Ot.current=null,document.body.style.cursor="",document.body.style.userSelect="",mu(d)},onClick:Ne=>Ne.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:e.jsxs("span",{style:{display:"flex",gap:4,alignItems:"center",height:"calc(100% - 8px)"},children:[e.jsx("span",{style:{width:2,height:"100%",borderRadius:2,background:"var(--primary)",display:"block"}}),e.jsx("span",{style:{width:2,height:"100%",borderRadius:2,background:"var(--primary)",display:"block"}})]})})]},d.key)})]}),Dn=()=>{if(!Xe||typeof document>"u"||ir==="visibility"&&!O||ir==="filter"&&!oe)return null;const d=r.find(ye=>ye.key===Tt),g=iu(),D=d?Object.prototype.hasOwnProperty.call(Je,d.key):!1,x=d?cr[d.key]:void 0,G=Gt.find(ye=>ye.value===(x==null?void 0:x.operator)),de=d?Je[d.key]??[]:[],pe=ds.trim().toLowerCase(),we=pe?g.filter(ye=>ye.label.toLowerCase().includes(pe)):g,je=d&&g.length>0&&(!D||de.length===g.length),ze=d&&D&&de.length>0&&de.length<g.length,Ue=_e.length,ke=()=>{d&&(xa(d.key),Es(d.key))};return er.createPortal(e.jsx("div",{ref:gs,role:"menu",className:"overflow-hidden rounded-lg border p-1 shadow-xl",style:{...Zd,borderColor:"var(--border)",background:"var(--bg-card)"},children:ir==="visibility"?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-[var(--border)] px-2 py-1.5",children:[e.jsx("span",{className:"min-w-0 truncate text-xs font-semibold uppercase text-[var(--text-muted)]",children:Ue>0?`${Re.length} de ${r.length} visibles`:`${r.length} visibles`}),e.jsx("button",{type:"button",onClick:pu,disabled:Ue===0,className:"rounded px-1.5 py-0.5 text-xs font-medium text-[var(--primary)] transition-colors hover:bg-[var(--bg-input)] disabled:opacity-40",children:"Mostrar todas"})]}),e.jsx("div",{className:"max-h-72 overflow-auto py-1",children:ks.map(ye=>{const Ne=!_e.includes(ye.key),me=!(ye.hideable!==!1)||Ne&&Re.length<=1;return e.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":Ne,disabled:me,onClick:()=>bu(ye.key),className:"flex w-full min-w-0 items-center gap-2 rounded-md px-2.5 py-1.5 text-left transition-colors hover:bg-[var(--bg-input)] disabled:cursor-not-allowed disabled:opacity-50",style:{color:"var(--text-main)"},children:[e.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center rounded border",style:{borderColor:Ne?"var(--primary)":"var(--border)",background:Ne?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:Ne&&e.jsx(T.HiCheck,{className:"h-3 w-3"})}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:ye.header})]},ye.key)})})]}):d?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-[var(--border)] px-2 py-1.5",children:[e.jsxs("span",{className:"min-w-0 truncate text-xs font-semibold uppercase text-[var(--text-muted)]",children:["Filtrar ",d.header]}),e.jsx("button",{type:"button",onClick:ke,disabled:!D&&!x,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"})]}),d.sortKey&&e.jsxs("div",{className:"grid grid-cols-2 gap-1 border-b border-[var(--border)] p-1",children:[e.jsxs("button",{type:"button",onClick:()=>Pr({key:d.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:[e.jsxs("span",{className:"flex min-w-0 items-center gap-1.5 truncate",children:[e.jsx(T.HiChevronUp,{className:"h-4 w-4 shrink-0 text-[var(--primary)]"}),e.jsx("span",{className:"truncate",children:"Ascendente"})]}),(Be==null?void 0:Be.key)===d.key&&Be.dir==="asc"&&e.jsx(T.HiCheck,{className:"h-4 w-4 shrink-0 text-[var(--primary)]"})]}),e.jsxs("button",{type:"button",onClick:()=>Pr({key:d.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:[e.jsxs("span",{className:"flex min-w-0 items-center gap-1.5 truncate",children:[e.jsx(T.HiChevronDown,{className:"h-4 w-4 shrink-0 text-[var(--primary)]"}),e.jsx("span",{className:"truncate",children:"Descendente"})]}),(Be==null?void 0:Be.key)===d.key&&Be.dir==="desc"&&e.jsx(T.HiCheck,{className:"h-4 w-4 shrink-0 text-[var(--primary)]"})]})]}),e.jsxs("div",{className:"border-b border-[var(--border)] p-2",children:[e.jsxs("div",{className:"grid grid-cols-[minmax(0,1.05fr)_minmax(0,0.95fr)] gap-2",children:[e.jsx(Lr,{value:(x==null?void 0:x.operator)??"",onChange:ye=>{if(!ye){Es(d.key);return}Sn(d.key,{operator:ye,value:(x==null?void 0:x.value)??"",valueTo:(x==null?void 0:x.valueTo)??""})},options:Pl,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"}),(G==null?void 0:G.valueMode)!=="none"?e.jsx("input",{value:(x==null?void 0:x.value)??"",onChange:ye=>{x&&Sn(d.key,{...x,value:ye.target.value})},disabled:!x,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)"}}):e.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"})]}),(G==null?void 0:G.valueMode)==="between"&&e.jsx("input",{value:(x==null?void 0:x.valueTo)??"",onChange:ye=>{x&&Sn(d.key,{...x,valueTo:ye.target.value})},placeholder:"Valor final",className:"mt-2 w-full rounded-md border px-2 py-1.5 text-xs outline-none transition-colors placeholder:text-[var(--text-muted)] focus:border-[var(--primary)]",style:{borderColor:"var(--border)",background:"var(--bg-input)",color:"var(--text-main)"}})]}),e.jsx("div",{className:"border-b border-[var(--border)] p-2",children:e.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:[e.jsx(T.HiMagnifyingGlass,{className:"h-4 w-4 shrink-0 text-[var(--text-muted)]"}),e.jsx("input",{value:ds,onChange:ye=>us(ye.target.value),placeholder:"Buscar",className:"min-w-0 flex-1 bg-transparent text-sm outline-none placeholder:text-[var(--text-muted)]",style:{color:"var(--text-main)"}})]})}),e.jsxs("div",{className:"overflow-auto py-1",style:{maxHeight:"max(96px, calc(var(--dt-column-menu-max-height, 520px) - 236px))"},children:[e.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":ze?"mixed":!!je,onClick:()=>{d&&(je&&!D?Cs(d.key,[]):xa(d.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:[e.jsxs("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center rounded border",style:{borderColor:je||ze?"var(--primary)":"var(--border)",background:je||ze?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:[ze&&e.jsx(T.HiMinus,{className:"h-3 w-3"}),je&&!ze&&e.jsx(T.HiCheck,{className:"h-3 w-3"})]}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:"Seleccionar todo"})]}),we.map(ye=>{const Ne=!D||de.includes(ye.value);return e.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":Ne,onClick:()=>du(d.key,ye.value,g.map(he=>he.value),D),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:[e.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center rounded border",style:{borderColor:Ne?"var(--primary)":"var(--border)",background:Ne?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:Ne&&e.jsx(T.HiCheck,{className:"h-3 w-3"})}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:ye.label})]},ye.value)}),we.length===0&&e.jsx("div",{className:"px-3 py-3 text-sm text-[var(--text-muted)]",children:"Sin valores"})]})]}):null}),document.body)};o.useEffect(()=>{if(!Bt)return;function d(g){ha.current&&!ha.current.contains(g.target)&&xn.current&&!xn.current.contains(g.target)&&vn(!1)}return document.addEventListener("mousedown",d),()=>document.removeEventListener("mousedown",d)},[Bt]);function _s(d,g){if(d.filterValue){const D=d.filterValue(g);return D==null||D===""?"":String(D)}return Vr(d.cell(g))}function js(d){return`"${d.replace(/"/g,'""')}"`}function In(d){return d.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function $u(){const d=Re.filter(we=>!Tr(we)),g=d.map(we=>js(Vr(we.header))).join(","),D=_r.map(we=>d.map(je=>js(_s(je,we))).join(",")).join(`
|
|
1
|
+
(function(_,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):(_=typeof globalThis<"u"?globalThis:_||self,o(_.BonsaifUI={},_.React,_.jsxRuntime,_.ReactIconsHi2,_.ReactDOM,_.Recharts,_.OverlayScrollbarsGlobal,_.Sonner,_.OverlayScrollbarsReact,_.ReactDayPicker,_.ReactDayPickerStyles,_.ReactIconsFi))})(this,(function(_,o,e,T,er,ve,Hn,$a,Aa,Da,Ou,Vs){"use strict";"use client";function gr(...r){return r.filter(Boolean).join(" ")}function Gs({variant:r="primary",className:t,type:n="button",children:a,...s}){return e.jsx("button",{className:gr("bonsaif-ui-button",`bonsaif-ui-button--${r}`,t),type:n,...s,children:a})}function Ia({value:r,onChange:t,placeholder:n,className:a="",autoFocus:s=!1,forceExpanded:l=!1,onEscape:i,size:c="default",inputTabIndex:u}){const f=o.useRef(null),[p,b]=o.useState(!1),m=l||p||r.trim().length>0,v=c==="sm"?"h-9 rounded-md":"h-10 rounded-lg",y=a||"w-48 max-w-full sm:w-64 lg:w-72";o.useEffect(()=>{var h;s&&((h=f.current)==null||h.focus())},[s]);const S=()=>{var h;b(!0),(h=f.current)==null||h.focus()};return e.jsxs("div",{className:`relative min-w-0 max-w-full flex-shrink-0 overflow-visible transition-[width] duration-200 ease-out ${m?y:"w-24 sm:w-28"}`,onMouseDown:h=>{m||(h.preventDefault(),S())},children:[e.jsx(T.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)"}}),e.jsx("input",{ref:f,type:"text",tabIndex:u,"aria-label":n,value:r,onChange:h=>t(h.target.value),onKeyDown:h=>{h.key==="Escape"&&(i==null||i())},placeholder:m?n:"Buscar",className:`${v} w-full py-0 text-sm leading-none placeholder:text-[var(--text-muted)] focus:outline-none transition-all duration-200 ${m?"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:m?"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"}}),r&&e.jsx("button",{type:"button",onClick:()=>t(""),className:"absolute right-2 top-1/2 flex !h-6 !w-6 -translate-y-1/2 items-center justify-center rounded-full !p-0 leading-none transition-colors hover:bg-black/5",style:{color:"var(--text-muted)",right:"var(--page-header-control-padding-x, 8px)"},"aria-label":"Limpiar búsqueda",children:e.jsx(T.HiXMark,{className:"h-3.5 w-3.5 flex-shrink-0"})})]})}const Ba=o.createContext({});let Oa=0;const Ha="bonsaif-ui:hide-tooltips";function zt(r=700){Oa=Date.now()+r}function Ks(){return Date.now()>Oa}function _t(r){if(typeof document>"u")return!1;const t=Array.from(document.querySelectorAll('[data-bonsaif-overlay="true"], [role="menu"], [role="dialog"][aria-modal="true"], [aria-hidden="false"] [aria-modal="true"]'));return r&&t.some(n=>n.contains(r))?!1:t.length>0}function Xs(r){var a;const t=Array.from(r.querySelectorAll("*")).filter(s=>{var l;return s.scrollWidth>s.clientWidth&&!!((l=s.textContent)!=null&&l.trim())&&s.tagName.toLowerCase()!=="svg"&&!s.closest("svg")});return(r.scrollWidth>r.clientWidth||t.length>0)&&(((a=t[0])==null?void 0:a.textContent)??r.textContent??"").trim()||null}function Mr({children:r,content:t,onlyWhenOverflow:n=!1,interactive:a=!1,followCursor:s=!0,placement:l="bottom",showArrow:i=!1,className:c="",tooltipClassName:u="",style:f,tooltipStyle:p,as:b="div"}){const m=o.useRef(null),v=o.useRef(null),y=o.useRef(null),S=o.useRef(!1),[h,P]=o.useState(null),[O,E]=o.useState("");o.useEffect(()=>{const C=m.current;C&&(C.querySelectorAll("[title]").forEach(re=>{const W=re.getAttribute("title");W&&(re.getAttribute("aria-label")||re.setAttribute("aria-label",W),re.removeAttribute("title"))}),C.querySelectorAll("svg title").forEach(re=>re.remove()))}),o.useLayoutEffect(()=>{if(!h)return;const C=v.current;if(!C)return;const re=12,W=14,j=C.getBoundingClientRect(),ae=window.innerWidth-j.width-re,Z=window.innerHeight-j.height-re;let $=h.mouseX+W,ee=h.mouseY+W,se,M;if(!s&&m.current){const H=m.current.getBoundingClientRect(),oe=H.left+H.width/2,A=H.top+H.height/2;l==="top"?($=oe-j.width/2,ee=H.top-j.height-W,M=j.height-1):l==="left"?($=H.left-j.width-W,ee=A-j.height/2,se=j.width-1):l==="right"?($=H.right+W,ee=A-j.height/2,se=-7):($=oe-j.width/2,ee=H.bottom+W,M=-7)}if(s&&($>ae&&($=h.mouseX-j.width-W),ee>Z&&(ee=h.mouseY-j.height-W)),$=Math.min(Math.max(re,$),Math.max(re,ae)),ee=Math.min(Math.max(re,ee),Math.max(re,Z)),!s&&m.current){const H=m.current.getBoundingClientRect(),oe=H.left+H.width/2,A=H.top+H.height/2;l==="top"||l==="bottom"?se=Math.min(Math.max(14,oe-$),j.width-14):M=Math.min(Math.max(14,A-ee),j.height-14)}(Math.abs($-h.x)>.5||Math.abs(ee-h.y)>.5||se!==h.arrowX||M!==h.arrowY)&&P(H=>H&&{...H,x:$,y:ee,arrowX:se,arrowY:M})},[s,l,h]);const L=()=>{y.current&&(window.clearTimeout(y.current),y.current=null)},N=(C,re)=>{if(!Ks()||S.current)return;const W=m.current;if(W&&!_t(W)){if(n){const j=Xs(W);if(!j)return;E(j)}!n&&!t||P({mouseX:C,mouseY:re,x:C+14,y:re+14})}},k=()=>{const C=m.current;if(!C)return;const re=C.getBoundingClientRect();N(re.left+re.width/2,re.bottom)},Y=()=>{L(),P(null)},F=()=>{if(!a){Y();return}L(),y.current=window.setTimeout(()=>P(null),120)},U=()=>{zt(),S.current=!0,Y()},V=()=>{S.current=!1};o.useEffect(()=>{if(!h)return;if(_t(m.current)){P(null);return}const C=()=>P(null),re=()=>{zt(),S.current=!0,P(null)};document.addEventListener("pointerdown",re,!0),document.addEventListener("click",re,!0),document.addEventListener("scroll",C,!0),window.addEventListener("blur",C),document.addEventListener("visibilitychange",C),document.addEventListener("keydown",C,!0);const W=new MutationObserver(()=>{_t(m.current)&&P(null)});return W.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["role","aria-modal","aria-hidden","class"]}),()=>{document.removeEventListener("pointerdown",re,!0),document.removeEventListener("click",re,!0),document.removeEventListener("scroll",C,!0),window.removeEventListener("blur",C),document.removeEventListener("visibilitychange",C),document.removeEventListener("keydown",C,!0),W.disconnect()}},[h]),o.useEffect(()=>{const C=()=>zt(),re=()=>{zt(),S.current=!0,P(null)};return document.addEventListener("pointerdown",C,!0),document.addEventListener("click",C,!0),document.addEventListener("keydown",C,!0),window.addEventListener(Ha,re),()=>{document.removeEventListener("pointerdown",C,!0),document.removeEventListener("click",C,!0),document.removeEventListener("keydown",C,!0),window.removeEventListener(Ha,re)}},[]);const J=n?O:t;return e.jsxs(e.Fragment,{children:[e.jsx(b,{ref:C=>{m.current=C},className:c,style:f,onMouseEnter:C=>{L(),V(),s?N(C.clientX,C.clientY):k()},onMouseMove:C=>{h&&s&&N(C.clientX,C.clientY)},onMouseDown:U,onClick:U,onMouseLeave:()=>{V(),F()},onFocus:k,onBlur:Y,children:r}),h&&J&&!_t(m.current)?er.createPortal(e.jsxs("div",{ref:v,role:"tooltip",className:u,onMouseEnter:a?L:void 0,onMouseLeave:a?F: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",...p},children:[i&&e.jsx("span",{"aria-hidden":"true",style:{position:"absolute",width:12,height:12,background:(p==null?void 0:p.background)??"var(--bg-card)",borderLeft:l==="right"?(p==null?void 0:p.border)??"1px solid var(--border)":void 0,borderTop:l==="bottom"||l==="right"?(p==null?void 0:p.border)??"1px solid var(--border)":void 0,borderRight:l==="left"?(p==null?void 0:p.border)??"1px solid var(--border)":void 0,borderBottom:l==="top"||l==="left"?(p==null?void 0:p.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}}),J]}),document.body):null]})}function Pa(r){if(r!==void 0)return typeof r=="number"?`${r}px`:r}const Ys="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",Zs={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"},Qs="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",Js={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"},Rs={xs:"h-8 w-8",sm:"h-9 w-9",md:"h-10 w-10",lg:"h-10 w-10"},el={primary:{background:"var(--bg-card)"},secondary:{background:"var(--bg-card)"},danger:{background:"var(--bg-card)"},ghost:{},icon:{}};function Pn(r){return typeof r=="string"||typeof r=="number"?String(r):Array.isArray(r)?r.map(Pn).join(" ").trim():o.isValidElement(r)?Pn(r.props.children):""}function rl(r){return o.Children.toArray(r).find(o.isValidElement)??null}function Fe({variant:r="primary",size:t="md",loading:n=!1,icon:a,tooltip:s,iconOnly:l,height:i,padding:c,children:u,className:f="",disabled:p,style:b,...m}){const v=o.useContext(Ba),y=l??v.iconOnly??r==="icon",S=v.compact??!1,h=v.headerAction??!1,P=h&&t==="md"?"sm":S&&!h&&t==="md"?"xs":t,O=r==="icon"||y,E=h&&O,L=Pn(u),N=s??m.title??m["aria-label"]??(y?L:void 0),k=N?void 0:m.title,Y=m["aria-label"]??(typeof N=="string"?N:L||void 0),F=n?null:a??(y?rl(u):null),U=e.jsxs("button",{...m,title:k,"aria-label":Y,"data-variant":r,"data-size":P,"data-icon":O?"true":void 0,disabled:p||n,className:`${Ys} ${E?Qs:Zs[r]} ${O?Rs[P]:Js[P]} ${S&&!O?"px-2.5":""} ${f}`,style:{...el[r],height:Pa(i),padding:Pa(c),...b,...h&&!O?{height:"var(--page-header-control-height, 34px)",padding:"0 var(--page-header-control-padding-x, 10px)",borderRadius:"8px"}:null,...E?{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?e.jsx("span",{className:"h-3.5 w-3.5 animate-spin rounded-full border-2 border-current border-t-transparent"}):F,!y&&u]});return N?e.jsx(Mr,{as:"span",content:N,className:"inline-flex shrink-0",children:U}):U}const Ge={background:"color-mix(in srgb, var(--text-muted) 26%, var(--bg-input))"};function jt({rows:r=8,columns:t=7,showToolbar:n=!0,showPagination:a=!0,compact:s=!1,className:l=""}){const i=Math.max(3,Math.min(t,12)),c=Math.max(3,Math.min(r,20)),u=s?"px-2 py-2":"px-3 py-2.5",f=s?"px-2 py-2":"px-3 py-3";return e.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&&e.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-[var(--border)] px-3 py-2",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[e.jsx("div",{className:"h-7 w-14 shrink-0 animate-pulse rounded-md",style:Ge}),e.jsx("div",{className:"h-7 max-w-md flex-1 animate-pulse rounded-md",style:Ge})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[e.jsx("div",{className:"h-7 w-7 animate-pulse rounded-md",style:Ge}),e.jsx("div",{className:"h-7 w-7 animate-pulse rounded-md",style:Ge})]})]}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("div",{className:"min-w-full",style:{display:"grid",gridTemplateColumns:`repeat(${i}, minmax(96px, 1fr))`},children:[Array.from({length:i}).map((p,b)=>e.jsx("div",{className:`${f} border-b border-[var(--border)]`,style:{background:"color-mix(in srgb, var(--bg-input) 55%, transparent)"},children:e.jsx("div",{className:"h-3 animate-pulse rounded-md",style:{...Ge,width:`${48+b*17%40}%`}})},`h-${b}`)),Array.from({length:c}).map((p,b)=>Array.from({length:i}).map((m,v)=>e.jsx("div",{className:`${u} ${b<c-1?"border-b border-[var(--border)]":""}`,children:e.jsx("div",{className:"h-3.5 animate-pulse rounded-md",style:{...Ge,width:`${46+(b*13+v*11)%42}%`,minWidth:28}})},`c-${b}-${v}`)))]})}),a&&e.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:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-3 w-28 animate-pulse rounded-md",style:Ge}),e.jsx("div",{className:"h-7 w-14 animate-pulse rounded-md",style:Ge})]}),e.jsx("div",{className:"flex items-center gap-1",children:Array.from({length:4}).map((p,b)=>e.jsx("div",{className:"h-7 w-7 animate-pulse rounded-md",style:Ge},b))}),e.jsx("div",{className:"h-3 w-16 animate-pulse rounded-md",style:Ge})]})]})}function tl({size:r="md"}){const t=r==="sm"?"h-7 w-7":"h-9 w-9";return e.jsx("div",{className:`${t} animate-spin rounded-full border-2 border-[var(--border)] border-t-[var(--primary)]`,"aria-hidden":!0})}function nl({logoSrc:r,logoAlt:t}){return r?e.jsxs("span",{className:"relative flex h-16 w-16 items-center justify-center","aria-hidden":!1,children:[e.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%)"}}),e.jsx("img",{src:r,alt:t,className:"relative h-14 w-14 rounded-2xl object-contain shadow-sm shadow-black/10"})]}):null}function Fa({variant:r="page",title:t="Cargando...",description:n,logoSrc:a,logoAlt:s,appearance:l="card",rows:i=6,columns:c=7,children:u,className:f=""}){if(r==="table")return e.jsx(jt,{rows:i,columns:c,className:f});if(r==="sections")return e.jsx(al,{rows:i});if(r==="cards")return e.jsx(ol,{rows:i});const p=s||(typeof t=="string"?t:"Aplicación"),b=l==="bare",m=e.jsxs("div",{className:`flex flex-col items-center text-center ${b?"gap-5":"gap-3"}`,children:[a?e.jsx(nl,{logoSrc:a,logoAlt:p}):null,e.jsx(tl,{size:b?"md":"sm"}),e.jsxs("div",{className:b?"space-y-1.5":"",children:[e.jsx("p",{className:b?"text-base font-semibold tracking-tight text-[var(--text-main)]":"text-sm font-semibold text-[var(--text-main)]",children:t}),n?e.jsx("p",{className:b?"text-sm font-medium text-[var(--text-muted)]":"mt-1 text-xs text-[var(--text-muted)]",children:n}):null,u&&e.jsx("div",{className:"mt-1 text-xs text-[var(--text-muted)]",children:u})]})]});return b?e.jsx("div",{className:`flex min-h-[240px] w-full items-center justify-center p-8 ${f}`,role:"status","aria-live":"polite","aria-busy":"true",children:m}):e.jsx("div",{className:`flex min-h-[240px] items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-6 ${f}`,role:"status","aria-live":"polite","aria-busy":"true",children:m})}function al({rows:r}){return e.jsx(jt,{rows:r,columns:7})}function ol({rows:r}){return e.jsx("div",{className:"grid gap-3 md:grid-cols-2 xl:grid-cols-3",children:Array.from({length:r}).map((t,n)=>e.jsxs("div",{className:"rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-4",children:[e.jsx("div",{className:"h-4 w-2/3 animate-pulse rounded-md",style:Ge}),e.jsx("div",{className:"mt-3 h-3 w-full animate-pulse rounded-md",style:Ge}),e.jsx("div",{className:"mt-2 h-3 w-4/5 animate-pulse rounded-md",style:Ge})]},n))})}function za(r){const t=r.split("/").filter(Boolean);return(t[t.length-1]??r).replace(/^lv_/,"").split(/[-_]/).filter(Boolean).map(a=>a.charAt(0).toUpperCase()+a.slice(1)).join(" ")}function _a(r){return r.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().trim()}function sl(r){return[r.label,za(r.service),r.description,r.service].filter(Boolean).join(" ")}function ll(r){return typeof r=="function"?r:r.default}function il(r,t){return e.jsx("div",{className:"flex min-h-[220px] items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-6 text-center",children:e.jsxs("div",{className:"max-w-md",children:[e.jsx("p",{className:"text-sm font-semibold text-[var(--text-main)]",children:"No se pudo cargar este modulo"}),e.jsx("p",{className:"mt-1 text-xs text-[var(--text-muted)]",children:r.message}),e.jsx(Fe,{className:"mt-4",height:36,padding:"0 14px",onClick:t,children:"Reintentar"})]})})}function cl({parentPanel:r,parentPanelComponent:t,renderParentPanel:n,parent:a,context:s,links:l,moduleRegistry:i,loadModule:c,activeService:u,initialService:f,onActiveServiceChange:p,canAccess:b,keepAlive:m=!0,title:v,subtitle:y,emptyState:S,loadingState:h,errorState:P=il,renderTabLabel:O,searchableTabs:E="auto",tabsSearchThreshold:L=6,tabsSearchPlaceholder:N="Buscar modulo...",tabsSearchValue:k,onTabsSearchChange:Y,emptySearchState:F,showTabCount:U=!0,className:V="",parentClassName:J="",contentClassName:C="",tabsClassName:re=""}){var lr;const W=o.useMemo(()=>l.filter(fe=>!fe.hidden&&((b==null?void 0:b(fe,s))??!0)),[b,s,l]),j=(lr=W.find(fe=>!fe.disabled))==null?void 0:lr.service,[ae,Z]=o.useState(f??j??""),[$,ee]=o.useState({}),[se,M]=o.useState({}),[H,oe]=o.useState(""),[A,q]=o.useState(!1),ne=o.useRef(se),ie=o.useRef(0),Q=k??H,G=_a(Q),w=E===!0||E==="auto"&&W.length>=L,R=w&&Q.trim().length>0,B=o.useMemo(()=>G?W.filter(fe=>_a(sl(fe)).includes(G)):W,[G,W]),te=u??ae,z=W.find(fe=>fe.service===te)??W.find(fe=>!fe.disabled);o.useEffect(()=>{!z&&j&&Z(j)},[j,z]),o.useEffect(()=>{ne.current=se},[se]);const le=fe=>{fe.disabled||(u||Z(fe.service),p==null||p(fe.service,fe))},Ee=fe=>{k===void 0&&oe(fe),Y==null||Y(fe)},Le=(fe,I)=>{const X=B.filter(be=>!be.disabled),ue=X.findIndex(be=>be.service===I.service);ue<0||((fe.key==="ArrowRight"||fe.key==="ArrowDown")&&(fe.preventDefault(),le(X[(ue+1)%X.length])),(fe.key==="ArrowLeft"||fe.key==="ArrowUp")&&(fe.preventDefault(),le(X[(ue-1+X.length)%X.length])),fe.key==="Home"&&(fe.preventDefault(),le(X[0])),fe.key==="End"&&(fe.preventDefault(),le(X[X.length-1])))},xe=o.useCallback(()=>{if(!z)return;const fe=z.service,I=ne.current[fe];if(I!=null&&I.loading||I!=null&&I.component&&m)return;const X=(i==null?void 0:i[fe])??c;if(!X){M(be=>({...be,[fe]:{loading:!1,error:new Error(`No module loader found for service "${fe}".`)}}));return}const ue=++ie.current;M(be=>({...be,[fe]:{...be[fe],loading:!0,error:void 0}})),X(z,s).then(be=>{if(ue!==ie.current&&!m)return;const De=ll(be);M(Ce=>({...Ce,[fe]:{component:De,loading:!1}}))}).catch(be=>{const De=be instanceof Error?be:new Error(String(be));M(Ce=>({...Ce,[fe]:{...Ce[fe],loading:!1,error:De}}))})},[s,m,c,i,z]);o.useEffect(xe,[xe]);const Se=z?$[z.service]??null:null,Te=z?se[z.service]:void 0,kr=Te==null?void 0:Te.component,pr=fe=>{z&&ee(I=>({...I,[z.service]:fe}))},qe=()=>{z&&ee(fe=>({...fe,[z.service]:null}))},ce={context:s,parent:a,links:l,visibleLinks:W,filteredLinks:B,selectedLink:z,selectedService:z==null?void 0:z.service,activeItemId:Se,tabsSearch:Q,onSelectService:le,onOpenDetail:pr,onBackToList:qe},Qe=n?n(ce):t?e.jsx(t,{...ce}):r;return e.jsxs("section",{className:`grid min-h-[520px] gap-4 lg:grid-cols-[minmax(260px,360px)_minmax(0,1fr)] ${V}`,children:[e.jsx("aside",{className:`min-w-0 rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-4 ${J}`,children:Qe}),e.jsxs("div",{className:`relative min-w-0 overflow-visible rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${C}`,children:[(v||y||w||U)&&e.jsx("div",{className:"relative border-b border-[var(--border)] px-4 py-3",children:e.jsxs("div",{className:"flex min-w-0 items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[v&&e.jsx("h2",{className:"truncate text-sm font-semibold text-[var(--text-main)]",children:v}),y&&e.jsx("p",{className:"mt-1 line-clamp-2 text-xs text-[var(--text-muted)]",children:y})]}),(w||U)&&e.jsxs("div",{className:"flex min-w-0 flex-shrink-0 items-center justify-end gap-2",children:[U&&e.jsxs("span",{className:"hidden text-xs font-semibold text-[var(--text-muted)] transition-opacity duration-200 sm:inline",children:[B.length," / ",W.length]}),w&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:`origin-right overflow-hidden transition-[width,opacity,transform] duration-200 ease-out ${A?"w-[min(20rem,44vw)] translate-x-0 opacity-100":"w-0 translate-x-2 opacity-0"}`,"aria-hidden":!A,children:e.jsx(Ia,{value:Q,onChange:Ee,placeholder:N,className:"w-full",autoFocus:A,forceExpanded:!0,onEscape:()=>q(!1),size:"sm",inputTabIndex:A?0:-1})}),e.jsx("button",{type:"button","aria-label":A?"Cerrar busqueda":"Buscar tabs","aria-expanded":A,onClick:()=>{A&&Q&&Ee(""),q(fe=>!fe)},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 ${A||R?"border-[var(--primary)] bg-[var(--bg-input)] text-[var(--text-main)] shadow-sm":"border-[var(--border)] text-[var(--text-muted)] hover:bg-[var(--bg-input)] hover:text-[var(--text-main)]"}`,children:e.jsx("span",{className:"grid h-4 w-4 place-items-center transition-transform duration-200",children:A||R?e.jsx(T.HiXMark,{className:"h-4 w-4"}):e.jsx(T.HiMagnifyingGlass,{className:"h-4 w-4"})})})]})]})]})}),e.jsx("div",{role:"tablist","aria-label":v??"Modulos relacionados",className:`flex gap-1 overflow-x-auto border-b border-[var(--border)] bg-[var(--bg-input)] px-2 py-1.5 transition-colors duration-200 ${re}`,children:B.length>0?B.map(fe=>{const I=fe.service===(z==null?void 0:z.service);return e.jsx("button",{type:"button",role:"tab","aria-selected":I,disabled:fe.disabled,onClick:()=>le(fe),onKeyDown:X=>Le(X,fe),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 ${I?"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:O?O(fe,I):e.jsxs(e.Fragment,{children:[fe.icon,e.jsx("span",{children:fe.label??za(fe.service)}),fe.badge&&e.jsx("span",{className:"rounded-full bg-[var(--bg-input)] px-1.5 py-0.5 text-[10px] text-[var(--text-muted)]",children:fe.badge})]})},fe.service)}):e.jsx("div",{className:"flex min-h-9 flex-1 items-center rounded-md border border-dashed border-[var(--border)] px-3 text-xs text-[var(--text-muted)]",children:F??"No hay modulos que coincidan con la busqueda."})}),(z==null?void 0:z.description)&&e.jsx("div",{className:"border-b border-[var(--border)] px-4 py-2 text-xs text-[var(--text-muted)]",children:z.description}),e.jsxs("div",{className:"min-h-[420px] p-4",children:[!z&&(S??e.jsx("div",{className:"flex min-h-[220px] items-center justify-center rounded-lg border border-dashed border-[var(--border)] text-sm text-[var(--text-muted)]",children:"No hay modulos disponibles."})),z&&(Te==null?void 0:Te.loading)&&(h??e.jsx(Fa,{title:"Cargando modulo..."})),z&&(Te==null?void 0:Te.error)&&P(Te.error,xe),z&&kr&&!(Te!=null&&Te.loading)&&!(Te!=null&&Te.error)&&e.jsx(kr,{context:s,parent:a,link:z,activeItemId:Se,onOpenDetail:pr,onBackToList:qe})]})]})]})}const dl={info:{color:"#2563eb",background:"rgba(59, 130, 246, 0.1)",border:"rgba(59, 130, 246, 0.24)",icon:e.jsx(T.HiInformationCircle,{className:"h-5 w-5"})},success:{color:"#047857",background:"rgba(16, 185, 129, 0.1)",border:"rgba(16, 185, 129, 0.24)",icon:e.jsx(T.HiCheckCircle,{className:"h-5 w-5"})},warning:{color:"#b45309",background:"rgba(245, 158, 11, 0.12)",border:"rgba(245, 158, 11, 0.26)",icon:e.jsx(T.HiExclamationTriangle,{className:"h-5 w-5"})},danger:{color:"var(--danger)",background:"var(--danger-bg)",border:"color-mix(in srgb, var(--danger) 20%, var(--border))",icon:e.jsx(T.HiExclamationCircle,{className:"h-5 w-5"})},neutral:{color:"var(--text-secondary)",background:"var(--bg-input)",border:"var(--border)",icon:e.jsx(T.HiInformationCircle,{className:"h-5 w-5"})}};function ul({variant:r="info",title:t,children:n,icon:a,action:s,onDismiss:l,className:i=""}){const c=dl[r];return e.jsxs("div",{role:r==="danger"||r==="warning"?"alert":"status",className:`flex items-start gap-3 rounded-lg border px-3 py-3 ${i}`,style:{background:c.background,borderColor:c.border},children:[e.jsx("div",{className:"mt-0.5 shrink-0",style:{color:c.color},children:a??c.icon}),e.jsxs("div",{className:"min-w-0 flex-1",children:[t&&e.jsx("div",{className:"text-sm font-semibold text-[var(--text-main)]",children:t}),n&&e.jsx("div",{className:"mt-0.5 text-sm leading-5 text-[var(--text-secondary)]",children:n}),s&&e.jsx("div",{className:"mt-3",children:s})]}),l&&e.jsx(Fe,{variant:"icon",size:"xs","aria-label":"Cerrar alerta",onClick:l,className:"-mr-1 -mt-1",children:e.jsx(T.HiXMark,{className:"h-4 w-4"})})]})}const ja=["Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre"],fl=["Ene","Feb","Mar","Abr","May","Jun","Jul","Ago","Sep","Oct","Nov","Dic"],bl=["Do","Lu","Ma","Mi","Ju","Vi","Sá"],Fn=6;function zn(r,t,n){return`${r}-${String(t).padStart(2,"0")}-${String(n).padStart(2,"0")}`}function pl(){const r=new Date;return zn(r.getFullYear(),r.getMonth()+1,r.getDate())}function Wa(r){const[t,n,a]=r.split("-").map(Number);return{year:t,month:n,day:a}}function ml(r){if(!r)return"Seleccionar fecha";const{year:t,month:n,day:a}=Wa(r);return!t||!n||!a?"Seleccionar fecha":`${String(a).padStart(2,"0")} ${ja[n-1]} ${t}`}function hl({value:r,onChange:t,minDate:n,displayMode:a="inline"}){const s=pl(),i=Wa(r||s),c=a==="popover",[u,f]=o.useState(!1),p=o.useRef(null),[b,m]=o.useState({horizontal:"left",vertical:"bottom"}),[v,y]=o.useState(i.year),[S,h]=o.useState(i.month),[P,O]=o.useState("days"),E=16,[L,N]=o.useState(0),k=v-7+L,Y=Array.from({length:E},(Z,$)=>k+$);o.useEffect(()=>{if(!c||!u||!p.current)return;const Z=p.current.getBoundingClientRect(),$=8,ee=280,se=340,M=Z.left+ee>window.innerWidth-$,H=Z.right-ee>=$,oe=Z.bottom+8+se>window.innerHeight-$,A=Z.top-8-se>=$;m({horizontal:M&&H?"right":"left",vertical:oe&&A?"top":"bottom"})},[c,u]),o.useEffect(()=>{if(!c||!u)return;function Z(ee){p.current&&(p.current.contains(ee.target)||f(!1))}function $(ee){ee.key==="Escape"&&f(!1)}return document.addEventListener("mousedown",Z),document.addEventListener("keydown",$),()=>{document.removeEventListener("mousedown",Z),document.removeEventListener("keydown",$)}},[c,u]);function F(){S===1?(y(Z=>Z-1),h(12)):h(Z=>Z-1)}function U(){S===12?(y(Z=>Z+1),h(1)):h(Z=>Z+1)}const V=new Date(v,S-1,1).getDay(),J=new Date(v,S,0).getDate(),C=[...Array(V).fill(null),...Array.from({length:J},(Z,$)=>$+1)];for(;C.length<Fn*7;)C.push(null);const re=C.slice(0,Fn*7);function W(Z){const $=zn(v,S,Z);n&&$<n||(t($),c&&f(!1))}const j={background:"none",border:"none",cursor:"pointer",color:"var(--text-muted)",padding:4,borderRadius:6,display:"flex",alignItems:"center"},ae=e.jsxs("div",{style:{background:"var(--bg-input)",border:"1px solid var(--border)",borderRadius:10,overflow:"hidden",userSelect:"none",width:280},children:[e.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 12px",borderBottom:"1px solid var(--border)"},children:P==="days"?e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:F,style:j,title:"Mes anterior",children:e.jsx(T.HiChevronLeft,{size:16})}),e.jsxs("button",{type:"button",onClick:()=>{O("years"),N(0)},style:{background:"none",border:"none",cursor:"pointer",display:"flex",alignItems:"center",gap:4,fontSize:13,fontWeight:700,color:"var(--text-main)",borderRadius:6,padding:"2px 6px"},children:[ja[S-1]," ",v,e.jsx(T.HiChevronDown,{size:13,style:{color:"var(--text-muted)"}})]}),e.jsx("button",{type:"button",onClick:U,style:j,title:"Mes siguiente",children:e.jsx(T.HiChevronRight,{size:16})})]}):e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:()=>N(Z=>Z-E),style:j,children:e.jsx(T.HiChevronLeft,{size:16})}),e.jsxs("button",{type:"button",onClick:()=>O("days"),style:{background:"none",border:"none",cursor:"pointer",fontSize:13,fontWeight:700,color:"var(--text-main)",borderRadius:6,padding:"2px 6px"},children:[Y[0]," – ",Y[Y.length-1]]}),e.jsx("button",{type:"button",onClick:()=>N(Z=>Z+E),style:j,children:e.jsx(T.HiChevronRight,{size:16})})]})}),P==="years"&&e.jsxs("div",{style:{padding:"8px 10px 10px"},children:[e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(4,1fr)",gap:3,marginBottom:8},children:fl.map((Z,$)=>{const ee=$+1===S;return e.jsx("button",{type:"button",onClick:()=>h($+1),style:{border:"none",cursor:"pointer",borderRadius:6,fontSize:11,fontWeight:ee?700:400,padding:"4px 0",background:ee?"var(--primary)":"transparent",color:ee?"var(--primary-fg, #ffffff)":"var(--text-secondary)"},children:Z},Z)})}),e.jsx("div",{style:{height:1,background:"var(--border)",marginBottom:8}}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(4,1fr)",gap:3},children:Y.map(Z=>{const $=Z===v;return e.jsx("button",{type:"button",onClick:()=>{y(Z),O("days")},style:{border:"none",cursor:"pointer",borderRadius:6,fontSize:12,fontWeight:$?700:400,padding:"6px 0",background:$?"var(--primary)":"transparent",color:$?"var(--primary-fg, #ffffff)":"var(--text-main)",outline:Z===new Date().getFullYear()&&!$?"2px solid var(--primary)":"none",outlineOffset:"-2px"},children:Z},Z)})})]}),P==="days"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(7,1fr)",padding:"6px 8px 0"},children:bl.map(Z=>e.jsx("div",{style:{textAlign:"center",fontSize:10,fontWeight:700,color:"var(--text-muted)",padding:"2px 0",textTransform:"uppercase"},children:Z},Z))}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(7,1fr)",gridTemplateRows:`repeat(${Fn},1fr)`,padding:"4px 8px 10px",gap:2},children:re.map((Z,$)=>{if(Z===null)return e.jsx("div",{style:{aspectRatio:"1"}},$);const ee=zn(v,S,Z),se=ee===r,M=ee===s,H=!!(n&&ee<n);return e.jsx("button",{type:"button",onClick:()=>!H&&W(Z),style:{width:"100%",aspectRatio:"1",borderRadius:6,border:"none",cursor:H?"not-allowed":"pointer",fontSize:12,fontWeight:se||M?700:400,background:se?"var(--primary)":"transparent",color:se?"var(--primary-fg, #ffffff)":H?"var(--text-muted)":"var(--text-main)",opacity:H?.4:1,outline:M&&!se?"2px solid var(--primary)":"none",outlineOffset:"-2px"},children:Z},$)})})]})]});return c?e.jsxs("div",{ref:p,className:"relative w-full",children:[e.jsxs("button",{type:"button",onClick:()=>f(Z=>!Z),className:"flex h-10 w-full items-center justify-between gap-2 rounded-lg px-2.5 py-0 text-sm transition-all duration-150 focus:outline-none",style:{background:"var(--bg-input)",border:`1px solid ${u?"var(--primary)":"var(--border)"}`,color:"var(--text-main)",boxShadow:u?"0 0 0 3px rgba(59,130,246,0.12)":"none"},children:[e.jsxs("span",{className:"inline-flex items-center gap-2 min-w-0",children:[e.jsx(T.HiCalendarDays,{className:"w-4 h-4 text-[var(--text-muted)]"}),e.jsx("span",{className:"truncate",children:ml(r)})]}),e.jsx(T.HiChevronDown,{className:`w-4 h-4 text-[var(--text-muted)] transition-transform ${u?"rotate-180":""}`})]}),u&&e.jsx("div",{className:"absolute z-50",style:{...b.horizontal==="left"?{left:0}:{right:0},...b.vertical==="bottom"?{top:"calc(100% + 8px)"}:{bottom:"calc(100% + 8px)"}},children:ae})]}):ae}const gl={sm:"h-4 w-4",md:"h-5 w-5"};function vl(r,t){if(typeof r=="function"){r(t);return}r&&(r.current=t)}const Wt=o.forwardRef(function({label:t,description:n,error:a,size:s="md",indeterminate:l=!1,className:i="",containerClassName:c="",disabled:u,...f},p){const b=o.useRef(null);return o.useEffect(()=>{b.current&&(b.current.indeterminate=l)},[l]),e.jsxs("label",{className:`group inline-flex items-start gap-2.5 ${u?"cursor-not-allowed opacity-60":"cursor-pointer"} ${c}`,children:[e.jsxs("span",{className:"relative mt-0.5 inline-flex shrink-0",children:[e.jsx("input",{...f,ref:m=>{b.current=m,vl(p,m)},type:"checkbox",disabled:u,"aria-checked":l?"mixed":f["aria-checked"],"aria-invalid":!!a||f["aria-invalid"],className:`peer ${gl[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}`}),e.jsx(T.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"})]}),(t||n||a)&&e.jsxs("span",{className:"min-w-0",children:[t&&e.jsx("span",{className:"block text-sm font-medium leading-5 text-[var(--text-main)]",children:t}),n&&!a&&e.jsx("span",{className:"block text-xs leading-5 text-[var(--text-muted)]",children:n}),a&&e.jsx("span",{className:"block text-xs leading-5 text-[var(--danger)]",children:a})]})]})});function qa(r){const t=document.createElement("textarea");t.value=r,t.style.position="fixed",t.style.opacity="0",t.style.pointerEvents="none",document.body.appendChild(t),t.select(),document.execCommand("copy"),document.body.removeChild(t)}async function xl(r){var t;if((t=navigator.clipboard)!=null&&t.writeText){await navigator.clipboard.writeText(r);return}qa(r)}function yl(r){return typeof r=="function"?r():r}function _n({value:r,resetDelay:t=2e3,title:n,copiedTitle:a="Copiado",copiedLabel:s,icon:l=e.jsx(T.HiClipboardDocument,{size:14}),copiedIcon:i=e.jsx(T.HiCheck,{size:14}),stopPropagation:c=!0,onCopied:u,onCopyError:f,className:p="",style:b,children:m,onClick:v,type:y="button",...S}){const[h,P]=o.useState(!1),O=o.useRef(null);o.useEffect(()=>()=>{O.current&&window.clearTimeout(O.current)},[]);function E(N){P(!0),u==null||u(N),O.current&&window.clearTimeout(O.current),O.current=window.setTimeout(()=>{P(!1),O.current=null},t)}async function L(N){var Y;if(c&&N.stopPropagation(),v==null||v(N),N.defaultPrevented)return;const k=yl(r);if(k)try{await xl(k),E(k)}catch(F){try{qa(k),E(k)}catch(U){f==null||f(U,k);return}(Y=navigator.clipboard)!=null&&Y.writeText||f==null||f(F,k)}}return e.jsxs("button",{...S,type:y,onClick:L,title:h?a:n,"aria-label":S["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 ${m?"min-w-7 px-2":"w-7"} ${p}`,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:[e.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}),m&&e.jsx("span",{className:"text-xs font-semibold leading-none",children:h?s??m:m})]})}function wl({code:r,children:t,title:n="Codigo",language:a,copyLabel:s="Copiar",copiedLabel:l="Copiado",className:i="",style:c,onCopied:u}){const f=(r??t??"").trim();return e.jsxs("div",{className:`overflow-hidden rounded-lg border ${i}`,style:{borderColor:"rgba(148, 163, 184, 0.22)",background:"#0f172a",color:"#e2e8f0",...c},children:[e.jsxs("div",{className:"flex min-h-9 items-center justify-between gap-3 border-b px-3 py-1.5",style:{borderColor:"rgba(148, 163, 184, 0.18)",background:"#111827",color:"#94a3b8"},children:[e.jsx("span",{className:"min-w-0 truncate text-[11px] font-black uppercase tracking-[0.08em]",children:n}),e.jsx(_n,{value:f,title:"Copiar codigo",copiedTitle:"Codigo copiado",copiedLabel:l,onCopied:u,className:"h-7 min-w-[72px] px-2",style:{background:"#182235",border:"1px solid rgba(148, 163, 184, 0.28)",color:"#f8fafc"},children:s})]}),e.jsx("pre",{className:"m-0 overflow-x-auto p-3 text-xs leading-6",style:{background:"#0f172a",color:"#e2e8f0",fontFamily:'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace'},children:e.jsx("code",{className:a?`language-${a}`:void 0,children:f})})]})}function jn(r){if(r!==void 0)return typeof r=="number"?`${r}px`:r}function Wn(r){return r.normalize("NFD").replace(new RegExp("\\p{M}","gu"),"").toLowerCase()}function kl(r,t){if(!t.trim())return!0;const n=Wn(t);return Wn(r.label).includes(n)||!!(r.sublabel&&Wn(r.sublabel).includes(n))}function Lr({value:r,onChange:t,options:n,status:a="default",ariaLabel:s,triggerVariant:l="default",showSelectedSublabel:i=!0,placeholder:c="Seleccionar…",emptyLabel:u,disabled:f=!1,className:p="",style:b,dropdownMinWidth:m,height:v=40,padding:y="0 10px",searchable:S=!0,minOptionsForSearch:h=6}){const[P,O]=o.useState(!1),[E,L]=o.useState(""),[N,k]=o.useState(-1),[Y,F]=o.useState(!1),[U,V]=o.useState({}),J=o.useRef(null),C=o.useRef(null),re=o.useRef(null),W=o.useRef(null),j=S&&n.length>=h,ae=n.find(Q=>Q.value===r)??null,Z=l==="ghost",$=a==="error"?"var(--danger)":P?"var(--primary)":"var(--border)",ee=j&&E.trim()?n.filter(Q=>kl(Q,E)):n,se=o.useCallback(()=>{const Q=J.current;if(!Q)return;const G=Q.getBoundingClientRect(),w=j?272:212,R=window.innerHeight-G.bottom,B=R<w&&G.top>R;V({position:"fixed",left:G.left,top:B?void 0:G.bottom+4,bottom:B?window.innerHeight-G.top+4:void 0,width:G.width,minWidth:jn(m),zIndex:9999})},[m,j]);o.useEffect(()=>F(!0),[]),o.useEffect(()=>{if(!P)return;function Q(G){var R,B;const w=G.target;!((R=J.current)!=null&&R.contains(w))&&!((B=C.current)!=null&&B.contains(w))&&(O(!1),L(""))}return document.addEventListener("mousedown",Q),()=>document.removeEventListener("mousedown",Q)},[P]),o.useEffect(()=>{P&&(k(-1),se(),j&&setTimeout(()=>{var Q;return(Q=re.current)==null?void 0:Q.focus()},0))},[P,j,se]),o.useEffect(()=>{if(P)return window.addEventListener("resize",se),window.addEventListener("scroll",se,!0),()=>{window.removeEventListener("resize",se),window.removeEventListener("scroll",se,!0)}},[P,se]),o.useEffect(()=>{if(N<0||!W.current)return;const Q=W.current.children[N];Q==null||Q.scrollIntoView({block:"nearest"})},[N]);const M=o.useCallback(Q=>{t(Q),O(!1),L("")},[t]),H=o.useRef(P);H.current=P;const oe=o.useRef(ee);oe.current=ee;const A=o.useRef(N);A.current=N;const q=o.useRef(u);q.current=u;const ne=o.useRef(M);ne.current=M,o.useEffect(()=>{function Q(G){var te,z;const w=document.activeElement,R=((te=J.current)==null?void 0:te.contains(w))??!1,B=((z=C.current)==null?void 0:z.contains(w))??!1;if(!(!R&&!B)){if(!H.current){(G.key==="Enter"||G.key===" "||G.key==="ArrowDown")&&(G.preventDefault(),O(!0));return}switch(G.key){case"ArrowDown":G.preventDefault(),k(le=>Math.min(le+1,oe.current.length-1));break;case"ArrowUp":G.preventDefault(),k(le=>Math.max(le-1,q.current?-1:0));break;case"Enter":{G.preventDefault();const le=A.current,Ee=oe.current;le===-1&&q.current?ne.current(""):Ee[le]&&!Ee[le].disabled&&ne.current(Ee[le].value);break}case"Escape":G.preventDefault(),G.stopPropagation(),O(!1),L("");break}}}return document.addEventListener("keydown",Q),()=>document.removeEventListener("keydown",Q)},[]);const ie=e.jsxs("div",{ref:C,"data-bonsaif-select-dropdown":"true",className:"rounded-xl shadow-xl overflow-hidden",style:{...U,background:"var(--bg-card)",border:"1px solid var(--border)"},children:[j&&e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",style:{borderBottom:"1px solid var(--border)"},children:[e.jsx(T.HiMagnifyingGlass,{className:"w-3.5 h-3.5 flex-shrink-0",style:{color:"var(--text-muted)"}}),e.jsx("input",{ref:re,value:E,onChange:Q=>{L(Q.target.value),k(-1)},placeholder:"Buscar…",className:"min-w-0 flex-1 text-sm bg-transparent outline-none",style:{color:"var(--text-main)"}}),E&&e.jsx("button",{type:"button",onMouseDown:Q=>{Q.preventDefault(),L("")},children:e.jsx(T.HiXMark,{className:"w-3.5 h-3.5",style:{color:"var(--text-muted)"}})})]}),e.jsxs("ul",{ref:W,role:"listbox",className:"overflow-y-auto",style:{maxHeight:j?220:180,scrollbarWidth:"thin",scrollbarColor:"var(--border) transparent",overscrollBehavior:"contain"},children:[u&&e.jsx("li",{role:"option","aria-selected":r==="",onMouseDown:Q=>{Q.preventDefault(),M("")},onMouseEnter:()=>k(-1),className:"flex items-center gap-2 px-3 py-2 cursor-pointer text-sm transition-colors",style:{background:N===-1&&!E.trim()?"var(--bg-hover)":"transparent",color:"var(--text-muted)",fontStyle:"italic"},children:u}),ee.map((Q,G)=>{const R=G===N,B=Q.value===r;return e.jsxs("li",{role:"option","aria-selected":B,onMouseDown:te=>{te.preventDefault(),Q.disabled||M(Q.value)},onMouseEnter:()=>!Q.disabled&&k(G),className:"flex items-center gap-2 px-3 py-2 cursor-pointer text-sm transition-colors",style:{background:R?"var(--bg-hover)":B?"color-mix(in srgb, var(--primary) 6%, transparent)":"transparent",color:Q.disabled?"var(--text-muted)":"var(--text-main)",cursor:Q.disabled?"not-allowed":"pointer",boxShadow:B?"inset 2px 0 0 var(--primary)":void 0},children:[Q.color&&e.jsx("span",{className:"flex-shrink-0 w-2.5 h-2.5 rounded-full",style:{background:Q.color}}),e.jsxs("span",{className:"min-w-0 flex flex-1 items-baseline gap-1 overflow-hidden",children:[e.jsx("span",{className:"truncate",children:Q.label}),Q.sublabel&&e.jsx("span",{className:"min-w-0 flex-shrink truncate",style:{color:"var(--text-muted)",fontSize:12},children:Q.sublabel})]}),Q.badge&&e.jsx("span",{className:"text-xs flex-shrink-0",style:{color:"var(--text-muted)"},children:Q.badge})]},Q.value)}),ee.length===0&&e.jsx("li",{className:"px-3 py-4 text-sm text-center",style:{color:"var(--text-muted)"},children:"Sin resultados"})]})]});return e.jsxs("div",{ref:J,className:`relative ${p||"w-full"}`,style:b,children:[e.jsxs("button",{type:"button",disabled:f,onClick:()=>!f&&O(Q=>!Q),className:"flex w-full items-center gap-2 rounded-lg text-left text-sm transition-colors focus:outline-none",style:{height:jn(v),padding:jn(y),background:Z?"transparent":"var(--bg-input)",color:ae?"var(--text-main)":"var(--text-muted)",border:Z?"1px solid transparent":`1px solid ${$}`,opacity:f?.5:1,cursor:f?"not-allowed":"pointer"},"aria-haspopup":"listbox","aria-expanded":P,"aria-label":s,children:[(ae==null?void 0:ae.color)&&e.jsx("span",{className:"flex-shrink-0 w-2.5 h-2.5 rounded-full",style:{background:ae.color}}),e.jsx("span",{className:"min-w-0 flex flex-1 items-baseline gap-1 overflow-hidden",children:ae?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"truncate",children:ae.label}),i&&ae.sublabel&&e.jsx("span",{className:"min-w-0 flex-shrink truncate",style:{color:"var(--text-muted)",fontSize:12},children:ae.sublabel})]}):e.jsx("span",{className:"truncate",children:c})}),ae&&u?e.jsx("span",{role:"button",tabIndex:-1,onMouseDown:Q=>{Q.preventDefault(),Q.stopPropagation(),M("")},className:"flex-shrink-0 rounded-full p-0.5 transition-colors hover:bg-black/10",style:{color:"var(--text-muted)"},children:e.jsx(T.HiXMark,{className:"w-3 h-3"})}):e.jsx(T.HiChevronDown,{className:"flex-shrink-0 w-4 h-4 transition-transform",style:{color:"var(--text-muted)",transform:P?"rotate(180deg)":"rotate(0deg)"}})]}),P&&Y&&er.createPortal(ie,document.body)]})}function qt(r){if(r!==void 0)return typeof r=="number"?`${r}px`:r}function Nl({value:r,onChange:t,placeholder:n="Buscar...",className:a="",height:s=40,padding:l="0 10px 0 30px",iconLeft:i=10}){return e.jsxs("div",{className:`relative ${a}`,children:[e.jsx(T.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:qt(i)}}),e.jsx("input",{type:"text",value:r,onChange:c=>t(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:qt(s),padding:qt(l)}})]})}function Sl({value:r,onChange:t,options:n,placeholder:a,icon:s,className:l="",height:i=40,padding:c,iconLeft:u=10,searchable:f=!0}){const p=s?n.map((b,m)=>m===0&&!b.color?{...b,sublabel:b.sublabel??void 0}:b):n;return e.jsxs("div",{className:`relative ${l}`,children:[s&&e.jsx("span",{className:"pointer-events-none absolute top-1/2 z-10 -translate-y-1/2 text-[var(--text-muted)]",style:{left:qt(u)},children:s}),e.jsx(Lr,{value:r,onChange:t,options:p,placeholder:a,searchable:f,minOptionsForSearch:5,height:i,padding:c??(s?"0 10px 0 30px":"0 10px"),className:"[&>button]:text-sm [&>button]:[background:var(--bg-card)]"})]})}const Cl={sm:"24rem",md:"28rem",lg:"32rem",xl:"40rem","2xl":"48rem","4xl":"56rem","5xl":"64rem"},Ut=180,El="bg-[color-mix(in_srgb,var(--bg-main)_72%,transparent)] backdrop-blur-sm";function qn({open:r,onClose:t,title:n,subtitle:a,leadingIcon:s,headerActions:l,footer:i,children:c,size:u="md",maxWidth:f,zIndex:p=1e3,closeOnBackdrop:b=!0,closeOnEscape:m=!0,showCloseButton:v=!0,placement:y="center",bodyClassName:S="px-6 py-5",panelClassName:h="",backdropClassName:P=El,contentClassName:O="p-4",ariaLabel:E,frameless:L=!1,disabled:N=!1}){const[k,Y]=o.useState(!1),[F,U]=o.useState(!1),V=o.useRef(null);if(o.useEffect(()=>(r?(V.current&&clearTimeout(V.current),Y(!0),requestAnimationFrame(()=>requestAnimationFrame(()=>U(!0)))):(U(!1),V.current=setTimeout(()=>Y(!1),Ut+40)),()=>{V.current&&clearTimeout(V.current)}),[r]),o.useEffect(()=>{if(r)return document.body.style.overflow="hidden",()=>{document.body.style.overflow=""}},[r]),o.useEffect(()=>{if(!r||!m)return;const ae=Z=>{Z.key==="Escape"&&t()};return window.addEventListener("keydown",ae),()=>window.removeEventListener("keydown",ae)},[m,t,r]),!k)return null;const J=n||a||s||l||v,C=f??Cl[u],re=y==="bottom-mobile"?"items-end sm:items-center justify-center p-0 sm:p-4":"items-center justify-center",W=y==="bottom-mobile"?"rounded-t-2xl sm:rounded-2xl":"rounded-2xl",j=F?"translateY(0) scale(1)":y==="bottom-mobile"?"translateY(16px) scale(0.98)":"translateY(10px) scale(0.96)";return er.createPortal(e.jsxs("div",{role:"dialog","aria-modal":"true","data-bonsaif-overlay":"true","aria-label":E??n,className:`fixed inset-0 flex ${re} ${O}`,style:{zIndex:p},children:[e.jsx("div",{className:`absolute inset-0 ${P}`,onClick:b?t:void 0,style:{opacity:F?1:0,transition:`opacity ${Ut}ms ease`}}),e.jsxs("div",{className:`relative z-10 flex max-h-[92dvh] w-full flex-col overflow-hidden ${L?"shadow-none":"shadow-2xl"} ${W} ${h}`,style:{maxWidth:C,background:L?"transparent":"var(--bg-card)",border:L?"none":"1px solid var(--border)",opacity:F?1:0,transform:j,transition:`opacity ${Ut}ms ease, transform ${Ut}ms ease`},onClick:ae=>ae.stopPropagation(),children:[N&&e.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)"}}),J&&e.jsxs("div",{className:"flex flex-shrink-0 items-center justify-between gap-3 px-6 py-4",style:{borderBottom:"1px solid var(--border)"},children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[s&&e.jsx("div",{className:"flex-shrink-0",children:s}),(n||a)&&e.jsxs("div",{className:"min-w-0",children:[n&&e.jsx("h2",{className:"truncate text-base font-semibold",style:{color:"var(--text-main)"},children:n}),a&&e.jsx("p",{className:"truncate text-xs",style:{color:"var(--text-muted)"},children:a})]})]}),e.jsxs("div",{className:"flex flex-shrink-0 items-center gap-2",children:[l,v&&e.jsx(Fe,{variant:"icon",onClick:t,title:"Cerrar",children:e.jsx(T.HiXMark,{className:"h-5 w-5"})})]})]}),e.jsx("div",{className:`min-h-0 flex-1 overflow-y-auto ${S}`,children:c}),i&&e.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 Ml={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 Ll({open:r,title:t,description:n,confirmLabel:a="Confirmar",cancelLabel:s="Cancelar",variant:l="danger",closeOnBackdrop:i=!0,onConfirm:c,onCancel:u}){const f=Ml[l];return e.jsx(qn,{open:r,onClose:u,size:"md",zIndex:9998,showCloseButton:!1,bodyClassName:"p-0",panelClassName:"overflow-visible",ariaLabel:t,closeOnBackdrop:i,children:e.jsxs("div",{className:"relative px-6 pb-6 pt-6",children:[e.jsx(Fe,{variant:"icon",onClick:u,className:"absolute right-3 top-3 h-8 w-8 hover:opacity-70",style:{color:"var(--text-muted)"},"aria-label":"Cancelar",children:e.jsx(T.HiXMark,{className:"h-4 w-4"})}),e.jsxs("div",{className:"flex gap-3 pr-8",children:[e.jsx("div",{className:"mt-0.5 flex h-10 w-10 flex-shrink-0 items-center justify-center rounded-xl",style:{background:f.iconBg},children:e.jsx(T.HiExclamationTriangle,{className:"h-5 w-5",style:{color:f.iconColor}})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h2",{className:"text-base font-semibold leading-snug",style:{color:"var(--text-main)"},children:t}),n?e.jsx("div",{className:"mt-1.5 text-sm leading-relaxed",style:{color:"var(--text-muted)"},children:n}):null]})]}),e.jsxs("div",{className:"mt-6 flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",children:[e.jsx(Fe,{variant:"secondary",onClick:u,className:"w-full sm:w-auto sm:min-w-[7.5rem]",style:{background:"var(--bg-input)"},children:s}),e.jsx(Fe,{variant:"danger",onClick:c,className:"w-full sm:w-auto sm:min-w-[7.5rem]",style:{background:f.btnBg,color:f.btnColor,borderColor:"transparent"},children:a})]})]})})}function Tl(r){return r?typeof r=="function"?r():r:""}function $l(r){return/^https?:\/\//i.test(r)}function Ua(r,t){try{return new URL(r,t).toString()}catch{return r}}function Al(r,t,n,a=!1){const s=typeof r=="function"?r():r,l=t?t(s):s;if(!l||$l(l))return l;const i=Tl(n);return i?Ua(l,i):a&&typeof window<"u"?Ua(l,window.location.origin):l}function Dl({url:r,resolveUrl:t,baseUrl:n,useWindowOriginForRelative:a=!1,title:s="Copiar link",copiedTitle:l="Link copiado",icon:i=e.jsx(T.HiLink,{className:"h-3.5 w-3.5"}),...c}){return e.jsx(_n,{...c,value:()=>Al(r,t,n,a),title:s,copiedTitle:l,icon:i})}const Vt=[25,50,100,200,500];let rr={dataTable:{pageSizeOptions:[...Vt]}};function Il(){if(typeof window>"u")return;const t=window.__BONSAIF_DATA_TABLE_PREFERENCES_ENDPOINT__;return typeof t=="string"&&t.trim().length>0?t.trim().replace(/\/+$/,""):void 0}function Un(){const r=rr.dataTable.preferencesEndpoint,t=Il();return r&&r.trim().length>0?r.trim().replace(/\/+$/,""):t}function Bl(r){if(!Array.isArray(r))return[...Vt];const t=Array.from(new Set(r.map(n=>typeof n=="number"?Math.floor(n):Number.NaN).filter(n=>Number.isFinite(n)&&n>0)));return t.length>0?t:[...Vt]}function Va(r){if(typeof r!="string")return;const t=r.trim();if(t)return t.replace(/\/+$/,"")}function Ol(r){if(!r||typeof r!="object"||!r.dataTable)return;const t=Va(r.dataTable.preferencesEndpoint);rr={...rr,dataTable:{...rr.dataTable,pageSizeOptions:Bl(r.dataTable.pageSizeOptions),preferencesEndpoint:t??rr.dataTable.preferencesEndpoint}}}function Hl(){return{dataTable:{pageSizeOptions:[...rr.dataTable.pageSizeOptions]}}}function mt(){return[...rr.dataTable.pageSizeOptions]}function Pl(){rr={dataTable:{pageSizeOptions:[...Vt]}}}function Fl(r){rr={...rr,dataTable:{...rr.dataTable,preferencesEndpoint:Va(r)}}}const Gt=[{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"}],zl=Gt.map(r=>({value:r.value,label:r.label})),_l=12,jl={layout:!0,filters:!1,sort:!1,bql:!1,pagination:!0},Ga={layout:!0,filters:!0,sort:!0,bql:!0,pagination:!0},Wl="bonsaif-ui:datatable:",ql="[&_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",Ul=[],Vl=52;function br(r){if(!r)return 150;const t=parseInt(r,10);return isNaN(t)||t<=0?150:t}function Ka(r){return!!(r&&(Array.isArray(r.columnOrder)&&r.columnOrder.length>0||r.columnWidths&&Object.keys(r.columnWidths).length>0||Array.isArray(r.hiddenColumnKeys)&&r.hiddenColumnKeys.length>0||r.filters&&Object.keys(r.filters).length>0||r.conditionFilters&&Object.keys(r.conditionFilters).length>0||r.sort||typeof r.bql=="string"||Array.isArray(r.bqlHistory)&&r.bqlHistory.length>0||typeof r.pageSize=="number"))}function Xa(r){return`${Wl}${r}`}function Kt(r){try{const t=window.localStorage.getItem(Xa(r));if(!t)return null;const n=JSON.parse(t);return n&&typeof n=="object"?n:null}catch{return null}}function Gl(r,t){try{window.localStorage.setItem(Xa(r),JSON.stringify(t))}catch{}}function Kl(r,t){if(r===!0)return{...Ga};if(r===!1)return{layout:!1,filters:!1,sort:!1,bql:!1,pagination:!1};if(t&&r==null)return{...Ga};const n={...jl,...r??{}};return t&&(typeof r!="object"||r.pagination!==!1)&&(n.pagination=!0),n}function Ya(...r){return r.reduce((t,n)=>({...t,...n??{}}),{})}function Vn(r,t,n){return typeof r!="number"||r<=0?n:yt(t).includes(r)?r:n}function ht(r){if(!r||typeof r!="object")return!1;const t=r;return typeof t.key=="string"&&(t.dir==="asc"||t.dir==="desc")}function gt(r,t){if(!r||typeof r!="object"||Array.isArray(r))return{};const n=Object.entries(r).flatMap(([a,s])=>{if(!t.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 vt(r,t){if(!r||typeof r!="object"||Array.isArray(r))return{};const n=new Set(Gt.map(s=>s.value)),a=Object.entries(r).flatMap(([s,l])=>{if(!t.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 Ye(r,t){if(Tr(r))return Vl;const n=r.minWidth??80,a=r.maxWidth??1/0;return Math.min(a,Math.max(n,t))}function Xl(r){const t=window.getComputedStyle(r);return parseFloat(t.paddingLeft)+parseFloat(t.paddingRight)}function Tr(r){return r.key==="actions"||r.key==="acciones"?!0:typeof r.header=="string"&&r.header.trim().toLowerCase()==="acciones"}function Gn(r){return r.sticky===!0}function Za(r){return!(r.reorderable===!1||r.sticky&&r.reorderable!==!0)}function vr(r,t){const n=t.filter(Gn).map(i=>i.key);if(n.length===0)return r;const a=new Set(n),s=n.filter(i=>r.includes(i)),l=r.filter(i=>!a.has(i));return[...s,...l]}function Yl(r,t){if(t<=7)return Array.from({length:t},(a,s)=>s+1);const n=[1];r>3&&n.push("...");for(let a=Math.max(2,r-1);a<=Math.min(t-1,r+1);a++)n.push(a);return r<t-2&&n.push("..."),n.push(t),n}function xr(r,t){var i;const n=new Set(t.filter(c=>c.hideable!==!1).map(c=>c.key)),a=Array.from(new Set(r??[])).filter(c=>n.has(c));if(t.filter(c=>!a.includes(c.key)).length>0)return a;const l=(i=t.find(c=>c.hideable!==!1))==null?void 0:i.key;return l?a.filter(c=>c!==l):[]}function Zl(r){return r==null||r===""?"(Vacio)":r instanceof Date?r.toLocaleDateString():String(r)}function Vr(r){return r==null||typeof r=="boolean"?"":typeof r=="string"||typeof r=="number"?String(r):Array.isArray(r)?r.map(Vr).join(" ").trim():o.isValidElement(r)?Vr(r.props.children):""}function Xt(r,t){const n=r.filterValue?r.filterValue(t):r.sortKey?t[r.sortKey]:r.cell(t);return typeof n=="string"||typeof n=="number"||typeof n=="boolean"||n===null||n===void 0||n instanceof Date?Zl(n):Vr(n).trim()}function xt(r){const t=r.replace(/,/g,"").trim();if(!t)return null;const n=Number(t);return Number.isFinite(n)?n:null}function Gr(r,t){const n=xt(r),a=xt(t);return n!==null&&a!==null?n-a:r.localeCompare(t,void 0,{numeric:!0,sensitivity:"base"})}function yt(r){const t=Array.from(new Set(r.map(n=>Math.floor(n)).filter(n=>Number.isFinite(n)&&n>0)));return t.length>0?t:mt()}function Ql(r,t,n){var i,c;const a=((i=t.value)==null?void 0:i.trim())??"",s=((c=t.valueTo)==null?void 0:c.trim())??"",l=Gt.find(u=>u.value===t.operator);if((l==null?void 0:l.valueMode)==="single"&&!a||(l==null?void 0:l.valueMode)==="between"&&(!a||!s))return!0;switch(t.operator){case"equals":return r.toLowerCase()===a.toLowerCase();case"notEquals":return r.toLowerCase()!==a.toLowerCase();case"greaterThan":return Gr(r,a)>0;case"greaterThanOrEqual":return Gr(r,a)>=0;case"lessThan":return Gr(r,a)<0;case"lessThanOrEqual":return Gr(r,a)<=0;case"between":return Gr(r,a)>=0&&Gr(r,s)<=0;case"top10":case"bottom10":{const f=n.map(b=>({value:b,number:xt(b)})).filter(b=>b.number!==null).sort((b,m)=>b.number-m.number).map(b=>b.value);return(t.operator==="top10"?f.slice(-10):f.slice(0,10)).includes(r)}case"aboveAverage":case"belowAverage":{const u=n.map(xt).filter(b=>b!==null);if(u.length===0)return!1;const f=u.reduce((b,m)=>b+m,0)/u.length,p=xt(r);return p===null?!1:t.operator==="aboveAverage"?p>f:p<f}default:return!0}}function Qa({children:r,className:t="",style:n}){return e.jsx(Mr,{onlyWhenOverflow:!0,className:t,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",...n},children:r})}function Ja({columns:r,data:t,getRowId:n,loading:a=!1,skeletonRows:s=8,emptyIcon:l,emptyText:i="Sin resultados",initialEmptyDelay:c=450,onRowClick:u,renderExpandedRow:f,getRowCanExpand:p,expandedRowIds:b,defaultExpandedRowIds:m=[],onExpandedRowIdsChange:v,expandOnRowClick:y=!1,selected:S,onToggleOne:h,onToggleAll:P,highlightSelected:O=!0,rowClassName:E,getRowCategory:L,stickyHeader:N=!0,pageSize:k=25,pageSizeOptions:Y,pageSizeSelectWidth:F=62,pageSizeSelectHeight:U=30,pageSizeSelectPadding:V="0 7px",totalRows:J,page:C,onPageChange:re,onPageSizeChange:W,storageKey:j,stickyFirstColumn:ae=!1,bottomOffset:Z=0,compact:$=!0,restrictHeight:ee=!0,maxHeight:se,minTableWidth:M,enableColumnVisibility:H=!0,enableColumnFilters:oe=!0,hiddenColumnKeys:A,defaultHiddenColumnKeys:q=Ul,onHiddenColumnKeysChange:ne,columnVisibilityLabel:ie="Columnas",enableBql:Q=!1,bqlValue:G,defaultBqlValue:w="",onBqlChange:R,bqlDescription:B="Filtra registros con Bonsaif Query Language",bqlPlaceholder:te=`status = activo
|
|
2
|
+
rol IN (admin, employee)`,bqlQuickFilters:z=[],bqlExamples:le=[],bqlSuggestions:Ee=[],bqlActiveFilters:Le,bqlError:xe,onQueryChange:Se,persistState:Te,onPreferencesReady:kr,enableExport:pr=!1,exportFilename:qe="datos"}){var qs;const ce=Kl(Te,j),Qe=Object.values(ce).some(Boolean),lr=r.map(d=>d.key).join(","),fe=q.join(","),I=o.useRef(r),X=o.useRef(q);I.current=r,X.current=q;const[ue,be]=o.useState(!j||!Qe),De=o.useRef(null),Ce=o.useRef(!j),Oe=o.useRef(!1),$e=o.useRef(kr);$e.current=kr;const Ve=o.useRef(!j||!Qe?j??"__none__":null),He=A!==void 0,[bn,Ke]=o.useState(()=>xr(q,r)),_e=xr(He?A:bn,r),[Xe,Dr]=o.useState(!1),[ir,Gd]=o.useState("filter"),[Tt,pn]=o.useState(null),[ds,us]=o.useState(""),[Je,rt]=o.useState({}),[cr,$t]=o.useState({}),ba=b!==void 0,[fs,Kd]=o.useState(m),Ir=G!==void 0,[Xd,At]=o.useState(w),mr=Ir?G:Xd,[Dt,mn]=o.useState(mr),[hr,Br]=o.useState(!1),[bs,tt]=o.useState(!1),[ps,nt]=o.useState(!1),[It,at]=o.useState([]),ot=o.useRef(null),Or=o.useRef(null),dr=o.useRef(R);dr.current=R;const hn=o.useRef(k);hn.current=k;const gn=o.useRef(Y);gn.current=Y;const Yd=Array.isArray(Y)?Y.join(","):"",pa=o.useRef(null),ms=o.useRef(null),ma=o.useRef(null),hs=o.useRef(0),[Zd,Qd]=o.useState({}),[Jd,Rd]=o.useState({}),[Bt,vn]=o.useState(!1),ha=o.useRef(null),xn=o.useRef(null),[eu,ru]=o.useState({}),gs=o.useRef(null),yn=o.useRef(null),[ga,vs]=o.useState(t.length>0||a||c===!1),xs=(d,g)=>50+(d*17+g*13+7)%40,Nr=o.useRef(null),[tu,nu]=o.useState(void 0),[ys,au]=o.useState(0),[ou,su]=o.useState(!1);o.useEffect(()=>{function d(){su(window.innerWidth<640)}if(!ee||se!==void 0)return d(),window.addEventListener("resize",d),()=>window.removeEventListener("resize",d);const D=k!==!1?48:0,x=12;function K(){if(d(),!Nr.current)return;const de=Nr.current.getBoundingClientRect().top;nu(Math.max(120,window.innerHeight-de-D-x-Z))}return K(),window.addEventListener("resize",K),()=>window.removeEventListener("resize",K)},[a,k,Z,ee,se]);const ws=ee?se??tu:void 0;o.useEffect(()=>{const d=Nr.current;if(!d)return;const g=()=>au(d.clientWidth);if(g(),typeof ResizeObserver>"u")return window.addEventListener("resize",g),()=>window.removeEventListener("resize",g);const D=new ResizeObserver(g);return D.observe(d),()=>D.disconnect()},[a,ue,t.length]),o.useEffect(()=>{if(c===!1||a||t.length>0){vs(!0);return}if(ga)return;const d=window.setTimeout(()=>{vs(!0)},c);return()=>window.clearTimeout(d)},[t.length,c,ga,a]);const[st,lt]=o.useState(()=>vr(r.map(d=>d.key),r)),[Hr,it]=o.useState(()=>Object.fromEntries(r.map(d=>[d.key,Ye(d,br(d.width))]))),[Be,Pr]=o.useState(null),[lu,wn]=o.useState(1),[kn,Nn]=o.useState(k===!1?0:k);o.useEffect(()=>{var Ne;const d=I.current,g=X.current,D=d.map(he=>he.key),x=new Set(D),K=()=>{var he;Oe.current||(Oe.current=!0,(he=$e.current)==null||he.call($e))};if(!j||!Qe){ce.layout&<(vr(D,d)),He||Ke(xr(g,d)),Ce.current=!1,be(!0),K();return}let de=!1;const pe=Ve.current===j;pe||(Ce.current=!1,be(!1),Oe.current=!1);const we=Kt(j);if(Ka(we)&&!pe){const he=we,me=yt(gn.current??mt()),ge=hn.current,qr=ge===!1?0:ge,Sr=ce.layout?he==null?void 0:he.columnOrder:void 0,Cr=Array.isArray(Sr)?Sr.filter(Ae=>D.includes(Ae)):[],Er=D.filter(Ae=>!Cr.includes(Ae)),Ur=vr(Cr.length>0?[...Cr,...Er]:D,d),ut=Object.fromEntries(d.map(Ae=>[Ae.key,Ye(Ae,br(Ae.width))])),ft=ce.layout?(he==null?void 0:he.columnWidths)??{}:{},Ft=Object.fromEntries(d.map(Ae=>[Ae.key,Ye(Ae,ft[Ae.key]??ut[Ae.key])])),bt=xr(ce.layout?(he==null?void 0:he.hiddenColumnKeys)??g:g,d);if(ce.layout&&(lt(Ur),it(Ft)),He||Ke(bt),ce.filters&&(rt(gt(he==null?void 0:he.filters,x)),$t(vt(he==null?void 0:he.conditionFilters,x))),ce.sort){const Ae=ht(he==null?void 0:he.sort)?he.sort:null;Pr(Ae&&x.has(Ae.key)?Ae:null)}if(ce.bql){if(ot.current!==j){ot.current=j;const Ae=typeof(he==null?void 0:he.bql)=="string"?he.bql:w;Ir?(Ne=dr.current)==null||Ne.call(dr,Ae):At(Ae)}at(Array.isArray(he==null?void 0:he.bqlHistory)?he.bqlHistory.filter(Ae=>typeof Ae=="string"):[])}ce.pagination&&Or.current!==j&&(Or.current=j,Nn(Vn(he==null?void 0:he.pageSize,me,qr))),Ve.current=j,be(!0),K()}const Ue=`${Un()??"/api/user/preferences/datatables"}?key=${encodeURIComponent(j)}`,ke=new AbortController,ye=window.setTimeout(()=>ke.abort(),2500);return fetch(Ue,{cache:"no-store",signal:ke.signal}).then(he=>he.ok?he.json():null).then(he=>{var Us;if(de)return;const me=Kt(j),ge=Ya(Ka(he==null?void 0:he.settings)?he==null?void 0:he.settings:null,me),qr=yt(gn.current??mt()),Sr=hn.current,Cr=Sr===!1?0:Sr,Er=ce.layout?ge==null?void 0:ge.columnOrder:void 0,Ur=Array.isArray(Er)?Er.filter(Pe=>D.includes(Pe)):[],ut=D.filter(Pe=>!Ur.includes(Pe)),ft=vr(Ur.length>0?[...Ur,...ut]:D,d),Ft=Object.fromEntries(d.map(Pe=>[Pe.key,Ye(Pe,br(Pe.width))])),bt=ce.layout?(ge==null?void 0:ge.columnWidths)??{}:{},Ae=Object.fromEntries(d.map(Pe=>[Pe.key,Ye(Pe,bt[Pe.key]??Ft[Pe.key])])),pt=xr(ce.layout?(ge==null?void 0:ge.hiddenColumnKeys)??g:g,d);if(ce.layout&&(lt(ft),it(Ae)),He||Ke(pt),ce.filters&&(rt(gt(ge==null?void 0:ge.filters,x)),$t(vt(ge==null?void 0:ge.conditionFilters,x))),ce.sort){const Pe=ht(ge==null?void 0:ge.sort)?ge.sort:null;Pr(Pe&&x.has(Pe.key)?Pe:null)}if(ce.bql){if(ot.current!==j){ot.current=j;const Pe=typeof(ge==null?void 0:ge.bql)=="string"?ge.bql:w;Ir?(Us=dr.current)==null||Us.call(dr,Pe):At(Pe)}at(Array.isArray(ge==null?void 0:ge.bqlHistory)?ge.bqlHistory.filter(Pe=>typeof Pe=="string"):[])}let Ie;ce.pagination&&(Ie=Vn(ge==null?void 0:ge.pageSize,qr,Cr),Or.current!==j&&(Or.current=j,Nn(Ie))),De.current=JSON.stringify({columnOrder:ft,columnWidths:Ae,hiddenColumnKeys:pt,filters:gt(ge==null?void 0:ge.filters,x),conditionFilters:vt(ge==null?void 0:ge.conditionFilters,x),sort:ht(ge==null?void 0:ge.sort)?ge.sort:null,bql:typeof(ge==null?void 0:ge.bql)=="string"?ge.bql:"",bqlHistory:Array.isArray(ge==null?void 0:ge.bqlHistory)?ge.bqlHistory:[],pageSize:ce.pagination&&Sr!==!1?Ie:void 0}),Ce.current=!0}).catch(()=>{var he;if(!de){const me=Kt(j),ge=yt(gn.current??mt()),qr=hn.current,Sr=qr===!1?0:qr,Cr=ce.layout?me==null?void 0:me.columnOrder:void 0,Er=Array.isArray(Cr)?Cr.filter(Ie=>D.includes(Ie)):[],Ur=D.filter(Ie=>!Er.includes(Ie)),ut=vr(Er.length>0?[...Er,...Ur]:D,d),ft=Object.fromEntries(d.map(Ie=>[Ie.key,Ye(Ie,br(Ie.width))])),Ft=ce.layout?(me==null?void 0:me.columnWidths)??{}:{},bt=Object.fromEntries(d.map(Ie=>[Ie.key,Ye(Ie,Ft[Ie.key]??ft[Ie.key])]));ce.layout&&(lt(ut),it(bt));const Ae=xr(ce.layout?(me==null?void 0:me.hiddenColumnKeys)??g:g,d);if(He||Ke(Ae),ce.filters&&(rt(gt(me==null?void 0:me.filters,x)),$t(vt(me==null?void 0:me.conditionFilters,x))),ce.sort){const Ie=ht(me==null?void 0:me.sort)?me.sort:null;Pr(Ie&&x.has(Ie.key)?Ie:null)}if(ce.bql){if(ot.current!==j){ot.current=j;const Ie=typeof(me==null?void 0:me.bql)=="string"?me.bql:w;Ir?(he=dr.current)==null||he.call(dr,Ie):At(Ie)}at(Array.isArray(me==null?void 0:me.bqlHistory)?me.bqlHistory.filter(Ie=>typeof Ie=="string"):[])}let pt;ce.pagination&&(pt=Vn(me==null?void 0:me.pageSize,ge,Sr),Or.current!==j&&(Or.current=j,Nn(pt))),De.current=JSON.stringify({columnOrder:ut,columnWidths:bt,hiddenColumnKeys:Ae,filters:gt(me==null?void 0:me.filters,x),conditionFilters:vt(me==null?void 0:me.conditionFilters,x),sort:ht(me==null?void 0:me.sort)?me.sort:null,bql:typeof(me==null?void 0:me.bql)=="string"?me.bql:"",bqlHistory:Array.isArray(me==null?void 0:me.bqlHistory)?me.bqlHistory:[],pageSize:ce.pagination&&qr!==!1?pt:void 0}),Ce.current=!0}}).finally(()=>{window.clearTimeout(ye),de||(Ve.current=j,be(!0),K())}),()=>{de=!0,ke.abort(),window.clearTimeout(ye)}},[j,Qe,lr,fe,He,ce.layout,ce.filters,ce.sort,ce.bql,ce.pagination,Ir,w,Yd]),o.useEffect(()=>{if(!j||!ue||!Qe||!Ce.current)return;const d={};ce.layout&&(d.columnOrder=st,d.columnWidths=Hr,d.hiddenColumnKeys=_e),ce.filters&&(d.filters=Je,d.conditionFilters=cr),ce.sort&&(d.sort=Be),ce.bql&&(d.bql=mr,d.bqlHistory=It),ce.pagination&&k!==!1&&(d.pageSize=kn);const g=Kt(j),D=Ya(g,d),x=JSON.stringify(D);if(x===De.current)return;Gl(j,D),De.current=x;const K=window.setTimeout(()=>{const de=Un()??"/api/user/preferences/datatables";fetch(de,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({key:j,settings:D})}).then(()=>{}).catch(()=>{})},300);return()=>window.clearTimeout(K)},[st,Hr,_e,Je,cr,Be,mr,It,kn,k,j,ue,Qe,ce.layout,ce.filters,ce.sort,ce.bql,ce.pagination]),o.useEffect(()=>{lt(d=>{const g=r.map(K=>K.key),D=d.filter(K=>g.includes(K)),x=g.filter(K=>!D.includes(K));return vr([...D,...x],r)})},[lr,r]);const ks=vr(st,r).map(d=>r.find(g=>g.key===d)).filter(d=>!!d),Re=ks.filter(d=>!_e.includes(d.key)),Ns=r.some(Gn),iu=Object.keys(Je).length,cu=Object.keys(cr).length,va=iu+cu;function Ss(d){const g=new Set;return t.reduce((D,x)=>{const K=Xt(d,x);return!K||g.has(K)||(g.add(K),D.push({value:K,label:K})),D},[])}function du(){const d=r.find(g=>g.key===Tt);return d?Ss(d):[]}function uu(d){return!!(oe&&!Tr(d)&&(d.filterValue||d.sortKey||Ss(d).length>0))}function Cs(d,g){rt(D=>{const x={...D};return x[d]=g,x})}function fu(d,g,D,x){const K=Je[d]??[],de=x?K:D.filter(we=>we!==g),pe=x?K.includes(g)?K.filter(we=>we!==g):[...K,g]:de;pe.length===D.length?xa(d):Cs(d,pe)}function xa(d){rt(g=>{const D={...g};return delete D[d],D})}function Sn(d,g){$t(D=>{const x={...D};return g?x[d]=g:delete x[d],x})}function Es(d){Sn(d,null)}function bu(){rt({}),$t({})}function pu(d){Ir||At(d),R==null||R(d)}function Ms(d){const g=d.trim();mn(g),(R==null?void 0:R(g))!==!1&&(Ir||At(g),Br(!1),tt(!1),nt(!1),g&&at(x=>[g,...x.filter(K=>K!==g)].slice(0,_l)))}function Ls(){mn(""),pu(""),Br(!1),tt(!1),nt(!1)}function ya(d,g){mn(d),g&&(g.style.height="auto",g.style.height=`${Math.min(g.scrollHeight,180)}px`)}function Cn(d){const g=d.trim();if(!g)return;hs.current=Date.now()+500;const D=Dt.replace(/\s+$/u,""),x=D.length===0?g:D.split(`
|
|
3
|
+
`).map(K=>K.trim()).includes(g)?D:`${D}
|
|
4
|
+
${g}`;ya(x,ma.current??void 0),requestAnimationFrame(()=>{const K=ma.current;if(!K)return;K.focus();const de=K.value.length;K.setSelectionRange(de,de),ya(K.value,K)})}o.useEffect(()=>{mn(mr)},[mr]);const En=o.useCallback(()=>{const d=pa.current;if(!d)return;const g=d.getBoundingClientRect(),D=12,x=8,K=Math.min(780,Math.max(320,window.innerWidth-32)),de=Math.max(D,window.innerWidth-K-D),pe=Math.min(Math.max(D,g.left),de),we=g.bottom+x,je=window.innerHeight-g.top+x,ze=window.innerHeight-we-D,Ue=g.top-D-x,ke=ze<280&&Ue>ze,ye=Math.max(240,ke?Ue:ze);Qd({position:"fixed",zIndex:1e4,left:pe,top:ke?void 0:we,bottom:ke?je:void 0,width:K,maxWidth:"calc(100vw - 24px)",maxHeight:ye,overflowY:"auto"})},[]);o.useEffect(()=>{if(!hr)return;function d(x){var de,pe;if(Date.now()<hs.current)return;const K=x.target;(de=pa.current)!=null&&de.contains(K)||(pe=ms.current)!=null&&pe.contains(K)||(Br(!1),tt(!1),nt(!1))}function g(x){x.key==="Escape"&&(Br(!1),tt(!1),nt(!1))}function D(){En()}return En(),document.addEventListener("mousedown",d),window.addEventListener("keydown",g),window.addEventListener("resize",D),window.addEventListener("scroll",D,!0),()=>{document.removeEventListener("mousedown",d),window.removeEventListener("keydown",g),window.removeEventListener("resize",D),window.removeEventListener("scroll",D,!0)}},[hr,En]);function Ts(d){const g=xr(d,r);He||Ke(g),ne==null||ne(g)}function mu(d){Ts(_e.includes(d)?_e.filter(g=>g!==d):[..._e,d])}function hu(){Ts([])}const wa=o.useCallback((d=yn.current)=>{if(!d)return;const g=d.getBoundingClientRect(),D=Math.min(292,Math.max(240,window.innerWidth-16)),x=Math.max(8,window.innerWidth-D-8),K=Math.min(Math.max(8,g.right-D),x),de=window.innerHeight-g.bottom,pe=g.bottom+6,we=window.innerHeight-g.top+6,ze=de<360&&g.top>de?void 0:pe,Ue=ze===void 0?we:void 0,ke=Math.max(220,ze===void 0?g.top-16:window.innerHeight-pe-8),ye={position:"fixed",zIndex:9999,left:K,top:ze,bottom:Ue,width:D,maxWidth:"calc(100vw - 16px)",maxHeight:ke,"--dt-column-menu-max-height":`${ke}px`};Rd(ye)},[]);function $s(d,g,D=null){d.preventDefault(),d.stopPropagation();const x=yn.current===d.currentTarget&&ir===g&&Tt===D;if(Xe&&x){Dr(!1),pn(null);return}yn.current=d.currentTarget,Gd(g),pn(D),us(""),wa(d.currentTarget),Dr(!0)}function gu(d){if(Tr(d))return;const g=Nr.current;if(!g)return;const x=Array.from(g.querySelectorAll("[data-dt-column-key]")).filter(K=>K.dataset.dtColumnKey===d.key).reduce((K,de)=>{const pe=de.querySelector("[data-dt-autofit-content]"),we=pe?pe.scrollWidth:Math.max(de.scrollWidth,de.offsetWidth);return Math.max(K,Math.ceil(we+Xl(de)))},0);x<=0||it(K=>({...K,[d.key]:Ye(d,x+12)}))}o.useEffect(()=>{it(d=>{const g=Object.fromEntries(r.map(D=>[D.key,Ye(D,br(D.width))]));return Object.fromEntries(r.map(D=>[D.key,Ye(D,d[D.key]??g[D.key])]))})},[lr,r]),o.useEffect(()=>{He||Ke(d=>xr(d,r))},[lr,r,He]),o.useEffect(()=>{function d(x){var pe,we;const K=x.target,de=x.target;de!=null&&de.closest("[data-bonsaif-select-dropdown='true']")||!((pe=gs.current)!=null&&pe.contains(K))&&!((we=yn.current)!=null&&we.contains(K))&&(Dr(!1),pn(null))}function g(x){x.key==="Escape"&&(Dr(!1),pn(null))}function D(){wa()}return Xe&&(document.addEventListener("mousedown",d),window.addEventListener("keydown",g),window.addEventListener("resize",D),window.addEventListener("scroll",D,!0)),()=>{document.removeEventListener("mousedown",d),window.removeEventListener("keydown",g),window.removeEventListener("resize",D),window.removeEventListener("scroll",D,!0)}},[Xe,wa]);const Ot=o.useRef(null);o.useEffect(()=>{function d(D){const x=Ot.current;if(!x)return;const K=D.clientX-x.startX,de=r.find(pe=>pe.key===x.colKey);de&&it(pe=>({...pe,[x.colKey]:Ye(de,x.startWidth+K)}))}function g(){Ot.current&&(Ot.current=null,document.body.style.cursor="",document.body.style.userSelect="")}return document.addEventListener("pointermove",d),document.addEventListener("pointerup",g),()=>{document.removeEventListener("pointermove",d),document.removeEventListener("pointerup",g)}},[r]);const Ht=o.useRef(null),[As,ka]=o.useState(null);function vu(d,g){const D=r.find(x=>x.key===d);if(!D||!Za(D)){g.preventDefault();return}Ht.current=st.indexOf(d),g.dataTransfer.effectAllowed="move"}function xu(d,g){g.preventDefault(),g.dataTransfer.dropEffect="move";const D=st.indexOf(d);As!==D&&ka(D)}function yu(d,g){g.preventDefault();const D=Ht.current,x=st.indexOf(d);D!==null&&D!==x&<(K=>{const de=[...K],[pe]=de.splice(D,1);return de.splice(x,0,pe),vr(de,r)}),Ht.current=null,ka(null)}function wu(){Ht.current=null,ka(null)}function ku(d){d.sortKey&&Pr(g=>(g==null?void 0:g.key)===d.key?{key:d.key,dir:g.dir==="asc"?"desc":"asc"}:{key:d.key,dir:"asc"})}o.useEffect(()=>{wn(1)},[t]),o.useEffect(()=>{wn(1)},[cr,Je]);const Fr=!!(re&&W),zr=k!==!1,Ds=o.useMemo(()=>yt(Y??mt()),[Y]),We=Fr?C??1:lu,ur=Fr||zr?kn:t.length,fr=!!S&&!!h&&!!P,ct=!!f,Is=o.useMemo(()=>new Set(ba?Array.from(b??[]):fs),[ba,b,fs]),Nu=(ct?40:0)+(fr?40:0),Na=!ou&&(Ns||ae),Mn=(()=>{if(!Na)return{};let d=Nu;const g={};return Re.forEach((D,x)=>{(Gn(D)||!Ns&&ae&&x===0)&&(g[D.key]=d,d+=Hr[D.key]??Ye(D,br(D.width)))}),g})(),Sa=Object.keys(Mn),Ca=Sa.length>0?Sa[Sa.length-1]:null,Su=fr&&t.length>0&&S.size===t.length,Cu=fr&&S.size>0&&S.size<t.length,Ln=o.useMemo(()=>{const d=Object.entries(Je),g=Object.entries(cr);return d.length===0&&g.length===0?t:t.filter(D=>d.every(([x,K])=>{const de=r.find(pe=>pe.key===x);return de?K.includes(Xt(de,D)):!0})&&g.every(([x,K])=>{const de=r.find(we=>we.key===x);if(!de)return!0;const pe=t.map(we=>Xt(de,we));return Ql(Xt(de,D),K,pe)}))},[cr,Je,r,t]),_r=o.useMemo(()=>{if(!Be)return Ln;const d=r.find(g=>g.key===Be.key&&g.sortKey);return d!=null&&d.sortKey?[...Ln].sort((g,D)=>{const x=g[d.sortKey],K=D[d.sortKey],de=x===K?0:x==null?1:K==null||x<K?-1:1;return Be.dir==="asc"?de:-de}):Ln},[Ln,Be,r]),Bs=o.useMemo(()=>{if(Fr||!zr)return _r;const d=(We-1)*ur;return _r.slice(d,d+ur)},[_r,Fr,zr,We,ur]),jr=Fr?J??t.length:_r.length,Ea=zr?Math.max(1,Math.ceil(jr/ur)):1,Eu=Math.min(...Ds),Mu=zr&&(jr>ur||jr>Eu),Lu=zr?(We-1)*ur+1:1,Tu=zr?Math.min(We*ur,jr):jr;function Ma(d){if(a)return;const g=Math.max(1,Math.min(d,Ea));Fr?re(g):wn(g)}function $u(d){a||(j&&(Or.current=j),Nn(d),Fr?(W(d),re(1)):(wn(1),W==null||W(d)))}function Os(d){const g=new Set(Is);g.has(d)?g.delete(d):g.add(d);const D=Array.from(g);ba||Kd(D),v==null||v(D)}o.useEffect(()=>{Se==null||Se({bql:mr,filters:Je,conditionFilters:cr,sort:Be,page:We,pageSize:ur,hiddenColumnKeys:_e})},[mr,Je,cr,Be,We,ur,_e,Se]);const Hs=d=>d==="center"?"text-center":d==="right"?"text-right":"text-left",Au="color-mix(in srgb, var(--primary) 6%, var(--bg-card))",La="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%)",Me="color-mix(in srgb, var(--border) 62%, var(--bg-card))",Wr="color-mix(in srgb, var(--primary) 24%, var(--border))",Tn=`inset 0 0 0 1px ${Me}`,Ps=Re.reduce((d,g)=>d+(Hr[g.key]??br(g.width)),(ct?40:0)+(fr?40:0)),Fs=typeof M=="number"?M:typeof M=="string"?Number(((qs=M.match(/^(\d+(?:\.\d+)?)px$/))==null?void 0:qs[1])??NaN):NaN,Pt=Number.isFinite(Fs)?Math.max(Ps,Fs,ys):Math.max(Ps,ys),$n=M??Pt,dt=`${ct?"40px ":""}${fr?"40px ":""}${Re.map(d=>`${Hr[d.key]??br(d.width)}px`).join(" ")}`;o.useEffect(()=>{Be&&_e.includes(Be.key)&&Pr(null)},[_e,Be]);function zs(d){return d?typeof d=="string"?{key:d,label:d}:d:null}const An=()=>e.jsxs("div",{role:"row",className:"grid",style:{gridTemplateColumns:dt,background:La,borderBottom:`1px solid ${Wr}`},children:[ct&&e.jsx("div",{role:"columnheader",className:`${$?"px-2 py-1.5":"px-3 py-2.5"} w-10`,style:{borderBottom:`1px solid ${Wr}`,borderRight:`1px solid ${Me}`}}),fr&&e.jsx("div",{role:"columnheader",className:`${$?"px-2 py-1.5":"px-3 py-2.5"} w-10`,style:Na?{position:"sticky",left:0,zIndex:12,background:La,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)",boxShadow:`inset 0 -1px 0 ${Wr}`,borderRight:`1px solid ${Me}`}:{borderBottom:`1px solid ${Wr}`,borderRight:`1px solid ${Me}`},children:e.jsx(Wt,{size:"sm",checked:Su,indeterminate:Cu,onChange:P,"aria-label":"Seleccionar todos",containerClassName:"items-center",className:"cursor-pointer"})}),Re.map((d,g)=>{const D=(Be==null?void 0:Be.key)===d.key,x=!!d.sortKey,K=Tr(d),de=Mn[d.key],pe=de!==void 0,we=d.key===Ca,je=Za(d),ze=As===g,ke=(Hr[d.key]??br(d.width))<120,ye=Object.prototype.hasOwnProperty.call(Je,d.key)||Object.prototype.hasOwnProperty.call(cr,d.key);return e.jsxs("div",{role:"columnheader","data-dt-column-key":d.key,className:`group select-none ${ke?"text-left":Hs(d.align)}`,style:{...pe?{position:"sticky",left:de,zIndex:12,background:La,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)",boxShadow:we?`3px 0 6px -2px rgba(0,0,0,0.10), inset 0 -1px 0 ${Wr}`:`inset 0 -1px 0 ${Wr}`,borderRight:`1px solid ${Me}`}:{position:"relative",borderBottom:`1px solid ${Wr}`,borderRight:`1px solid ${Me}`},color:D?"var(--primary)":"var(--text-muted)",whiteSpace:"nowrap",transition:"color 0.15s",borderLeft:ze?"2px solid var(--primary)":"2px solid transparent",cursor:"default",padding:K?$?"7px 6px":"9px 8px":$?"8px 6px 10px":"10px 8px 12px"},onDragOver:Ne=>{(je||Ht.current!==null)&&xu(d.key,Ne)},onDrop:Ne=>yu(d.key,Ne),children:[e.jsxs("div",{className:`flex min-w-0 items-center gap-1 ${K?"justify-center":ke?"justify-start":d.align==="center"?"justify-center":d.align==="right"?"justify-end":"justify-start"}`,children:[je?e.jsx("span",{draggable:!0,onDragStart:Ne=>{Ne.stopPropagation(),vu(d.key,Ne)},onDragEnd:Ne=>{Ne.stopPropagation(),wu()},onClick:Ne=>Ne.stopPropagation(),title:"Arrastrar para mover columna","aria-label":"Arrastrar para mover columna",className:`absolute left-0 top-0 z-10 inline-flex h-full w-3 shrink-0 rounded-sm transition-colors duration-150 hover:bg-[var(--primary)]/15 ${ze?"bg-[var(--primary)]/20":""}`,style:{cursor:"grab"}}):null,K?e.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:e.jsx(T.HiCog6Tooth,{className:"h-3.5 w-3.5"})}):e.jsx(Qa,{className:"min-w-0 flex-1",children:e.jsx("span",{"data-dt-autofit-content":!0,className:`inline-flex max-w-full items-center font-semibold uppercase tracking-wider ${$?"text-[11px]":"text-xs"}`,children:e.jsx("span",{className:"min-w-0 truncate",children:d.header})})}),x&&e.jsx("button",{type:"button","aria-label":`Ordenar por ${String(d.header)}`,title:"Ordenar",onClick:Ne=>{Ne.stopPropagation(),ku(d)},"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 ${D?"opacity-100":"opacity-0 group-hover:opacity-100 group-focus-within:opacity-100"}`,style:{bottom:"-0.5rem",top:"auto"},children:D?Be.dir==="asc"?e.jsx(T.HiChevronUp,{className:"h-3 w-3"}):e.jsx(T.HiChevronDown,{className:"h-3 w-3"}):e.jsx(T.HiChevronUpDown,{className:"h-3 w-3"})}),oe&&!K&&uu(d)&&e.jsx("button",{type:"button","aria-haspopup":"menu","aria-expanded":Xe&&Tt===d.key,"aria-label":`Filtrar ${String(d.header)}`,title:"Filtrar",onClick:Ne=>$s(Ne,"filter",d.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 ${Xe&&ir==="filter"&&Tt===d.key?"bg-[var(--bg-card)] text-[var(--primary)] opacity-100":ye?"text-[var(--primary)] opacity-100":""}`,children:ye?e.jsx(T.HiFunnel,{className:"h-3.5 w-3.5"}):e.jsx(T.HiEllipsisVertical,{className:"h-3.5 w-3.5"})})]}),!K&&e.jsx("span",{role:"separator","aria-orientation":"vertical",title:"Arrastrar para redimensionar. Doble click para autoajustar",onPointerDown:Ne=>{Ne.preventDefault(),Ne.stopPropagation(),Ot.current={colKey:d.key,startX:Ne.clientX,startWidth:Hr[d.key]??150},document.body.style.cursor="col-resize",document.body.style.userSelect="none"},onDoubleClick:Ne=>{Ne.preventDefault(),Ne.stopPropagation(),Ot.current=null,document.body.style.cursor="",document.body.style.userSelect="",gu(d)},onClick:Ne=>Ne.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:e.jsxs("span",{style:{display:"flex",gap:4,alignItems:"center",height:"calc(100% - 8px)"},children:[e.jsx("span",{style:{width:2,height:"100%",borderRadius:2,background:"var(--primary)",display:"block"}}),e.jsx("span",{style:{width:2,height:"100%",borderRadius:2,background:"var(--primary)",display:"block"}})]})})]},d.key)})]}),Dn=()=>{if(!Xe||typeof document>"u"||ir==="visibility"&&!H||ir==="filter"&&!oe)return null;const d=r.find(ye=>ye.key===Tt),g=du(),D=d?Object.prototype.hasOwnProperty.call(Je,d.key):!1,x=d?cr[d.key]:void 0,K=Gt.find(ye=>ye.value===(x==null?void 0:x.operator)),de=d?Je[d.key]??[]:[],pe=ds.trim().toLowerCase(),we=pe?g.filter(ye=>ye.label.toLowerCase().includes(pe)):g,je=d&&g.length>0&&(!D||de.length===g.length),ze=d&&D&&de.length>0&&de.length<g.length,Ue=_e.length,ke=()=>{d&&(xa(d.key),Es(d.key))};return er.createPortal(e.jsx("div",{ref:gs,role:"menu",className:"overflow-hidden rounded-lg border p-1 shadow-xl",style:{...Jd,borderColor:"var(--border)",background:"var(--bg-card)"},children:ir==="visibility"?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-[var(--border)] px-2 py-1.5",children:[e.jsx("span",{className:"min-w-0 truncate text-xs font-semibold uppercase text-[var(--text-muted)]",children:Ue>0?`${Re.length} de ${r.length} visibles`:`${r.length} visibles`}),e.jsx("button",{type:"button",onClick:hu,disabled:Ue===0,className:"rounded px-1.5 py-0.5 text-xs font-medium text-[var(--primary)] transition-colors hover:bg-[var(--bg-input)] disabled:opacity-40",children:"Mostrar todas"})]}),e.jsx("div",{className:"max-h-72 overflow-auto py-1",children:ks.map(ye=>{const Ne=!_e.includes(ye.key),me=!(ye.hideable!==!1)||Ne&&Re.length<=1;return e.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":Ne,disabled:me,onClick:()=>mu(ye.key),className:"flex w-full min-w-0 items-center gap-2 rounded-md px-2.5 py-1.5 text-left transition-colors hover:bg-[var(--bg-input)] disabled:cursor-not-allowed disabled:opacity-50",style:{color:"var(--text-main)"},children:[e.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center rounded border",style:{borderColor:Ne?"var(--primary)":"var(--border)",background:Ne?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:Ne&&e.jsx(T.HiCheck,{className:"h-3 w-3"})}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:ye.header})]},ye.key)})})]}):d?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-[var(--border)] px-2 py-1.5",children:[e.jsxs("span",{className:"min-w-0 truncate text-xs font-semibold uppercase text-[var(--text-muted)]",children:["Filtrar ",d.header]}),e.jsx("button",{type:"button",onClick:ke,disabled:!D&&!x,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"})]}),d.sortKey&&e.jsxs("div",{className:"grid grid-cols-2 gap-1 border-b border-[var(--border)] p-1",children:[e.jsxs("button",{type:"button",onClick:()=>Pr({key:d.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:[e.jsxs("span",{className:"flex min-w-0 items-center gap-1.5 truncate",children:[e.jsx(T.HiChevronUp,{className:"h-4 w-4 shrink-0 text-[var(--primary)]"}),e.jsx("span",{className:"truncate",children:"Ascendente"})]}),(Be==null?void 0:Be.key)===d.key&&Be.dir==="asc"&&e.jsx(T.HiCheck,{className:"h-4 w-4 shrink-0 text-[var(--primary)]"})]}),e.jsxs("button",{type:"button",onClick:()=>Pr({key:d.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:[e.jsxs("span",{className:"flex min-w-0 items-center gap-1.5 truncate",children:[e.jsx(T.HiChevronDown,{className:"h-4 w-4 shrink-0 text-[var(--primary)]"}),e.jsx("span",{className:"truncate",children:"Descendente"})]}),(Be==null?void 0:Be.key)===d.key&&Be.dir==="desc"&&e.jsx(T.HiCheck,{className:"h-4 w-4 shrink-0 text-[var(--primary)]"})]})]}),e.jsxs("div",{className:"border-b border-[var(--border)] p-2",children:[e.jsxs("div",{className:"grid grid-cols-[minmax(0,1.05fr)_minmax(0,0.95fr)] gap-2",children:[e.jsx(Lr,{value:(x==null?void 0:x.operator)??"",onChange:ye=>{if(!ye){Es(d.key);return}Sn(d.key,{operator:ye,value:(x==null?void 0:x.value)??"",valueTo:(x==null?void 0:x.valueTo)??""})},options:zl,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"}),(K==null?void 0:K.valueMode)!=="none"?e.jsx("input",{value:(x==null?void 0:x.value)??"",onChange:ye=>{x&&Sn(d.key,{...x,value:ye.target.value})},disabled:!x,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)"}}):e.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"})]}),(K==null?void 0:K.valueMode)==="between"&&e.jsx("input",{value:(x==null?void 0:x.valueTo)??"",onChange:ye=>{x&&Sn(d.key,{...x,valueTo:ye.target.value})},placeholder:"Valor final",className:"mt-2 w-full rounded-md border px-2 py-1.5 text-xs outline-none transition-colors placeholder:text-[var(--text-muted)] focus:border-[var(--primary)]",style:{borderColor:"var(--border)",background:"var(--bg-input)",color:"var(--text-main)"}})]}),e.jsx("div",{className:"border-b border-[var(--border)] p-2",children:e.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:[e.jsx(T.HiMagnifyingGlass,{className:"h-4 w-4 shrink-0 text-[var(--text-muted)]"}),e.jsx("input",{value:ds,onChange:ye=>us(ye.target.value),placeholder:"Buscar",className:"min-w-0 flex-1 bg-transparent text-sm outline-none placeholder:text-[var(--text-muted)]",style:{color:"var(--text-main)"}})]})}),e.jsxs("div",{className:"overflow-auto py-1",style:{maxHeight:"max(96px, calc(var(--dt-column-menu-max-height, 520px) - 236px))"},children:[e.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":ze?"mixed":!!je,onClick:()=>{d&&(je&&!D?Cs(d.key,[]):xa(d.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:[e.jsxs("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center rounded border",style:{borderColor:je||ze?"var(--primary)":"var(--border)",background:je||ze?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:[ze&&e.jsx(T.HiMinus,{className:"h-3 w-3"}),je&&!ze&&e.jsx(T.HiCheck,{className:"h-3 w-3"})]}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:"Seleccionar todo"})]}),we.map(ye=>{const Ne=!D||de.includes(ye.value);return e.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":Ne,onClick:()=>fu(d.key,ye.value,g.map(he=>he.value),D),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:[e.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center rounded border",style:{borderColor:Ne?"var(--primary)":"var(--border)",background:Ne?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:Ne&&e.jsx(T.HiCheck,{className:"h-3 w-3"})}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:ye.label})]},ye.value)}),we.length===0&&e.jsx("div",{className:"px-3 py-3 text-sm text-[var(--text-muted)]",children:"Sin valores"})]})]}):null}),document.body)};o.useEffect(()=>{if(!Bt)return;function d(g){ha.current&&!ha.current.contains(g.target)&&xn.current&&!xn.current.contains(g.target)&&vn(!1)}return document.addEventListener("mousedown",d),()=>document.removeEventListener("mousedown",d)},[Bt]);function _s(d,g){if(d.filterValue){const D=d.filterValue(g);return D==null||D===""?"":String(D)}return Vr(d.cell(g))}function js(d){return`"${d.replace(/"/g,'""')}"`}function In(d){return d.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function Du(){const d=Re.filter(we=>!Tr(we)),g=d.map(we=>js(Vr(we.header))).join(","),D=_r.map(we=>d.map(je=>js(_s(je,we))).join(",")).join(`
|
|
5
5
|
`),x=`${g}
|
|
6
|
-
${D}`,
|
|
6
|
+
${D}`,K=new Blob(["\uFEFF"+x],{type:"text/csv;charset=utf-8;"}),de=URL.createObjectURL(K),pe=document.createElement("a");pe.href=de,pe.download=`${qe}.csv`,document.body.appendChild(pe),pe.click(),document.body.removeChild(pe),URL.revokeObjectURL(de)}function Iu(){const d=Re.filter(pe=>!Tr(pe)),g=d.map(pe=>In(Vr(pe.header))),x=_r.map(pe=>d.map(we=>In(_s(we,pe)))).map(pe=>`<tr>${pe.map(we=>`<td>${we}</td>`).join("")}</tr>`).join(""),K=`<!DOCTYPE html>
|
|
7
7
|
<html lang="es"><head><meta charset="utf-8"><title>${In(qe)}</title>
|
|
8
8
|
<style>
|
|
9
9
|
body{font-family:system-ui,sans-serif;font-size:11px;margin:20px;color:#111}
|
|
@@ -20,17 +20,17 @@ ${D}`,G=new Blob(["\uFEFF"+x],{type:"text/csv;charset=utf-8;"}),de=URL.createObj
|
|
|
20
20
|
<table><thead><tr>${g.map(pe=>`<th>${pe}</th>`).join("")}</tr></thead>
|
|
21
21
|
<tbody>${x}</tbody></table>
|
|
22
22
|
<script>window.onload=()=>{window.print()}<\/script>
|
|
23
|
-
</body></html>`,de=window.open("","_blank");de&&(de.document.write(
|
|
24
|
-
`).map(pe=>pe.trim()).filter(Boolean)).has(G):!1}).slice(0,8);return!O&&va===0&&!Q&&!pr?null:e.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:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[va>0&&e.jsxs("button",{type:"button",onClick:uu,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:[e.jsx(T.HiXMark,{className:"h-3.5 w-3.5"}),va," filtros"]}),Q&&e.jsxs("div",{ref:pa,className:"relative flex min-w-0 flex-1 items-center gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>{if(hr){Br(!1);return}En(),Br(!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:hr?"var(--primary)":d?"color-mix(in srgb, var(--primary) 12%, transparent)":"var(--bg-card)",borderColor:hr||d?"var(--primary)":"var(--border)",color:hr?"var(--primary-fg)":"var(--primary)"},"aria-expanded":hr,title:"Abrir filtros BQL",children:[e.jsx(T.HiCommandLine,{className:"h-3.5 w-3.5"}),"BQL",d&&e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-current"}),hr?e.jsx(T.HiChevronUp,{className:"h-3.5 w-3.5"}):e.jsx(T.HiChevronDown,{className:"h-3.5 w-3.5"})]}),e.jsx("span",{className:"hidden truncate text-xs text-[var(--text-muted)] sm:inline",children:B}),g.length>0&&e.jsxs("div",{className:"hidden min-w-0 items-center gap-1.5 overflow-hidden lg:flex",children:[g.slice(0,3).map(x=>e.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:[e.jsxs("span",{className:"text-[var(--text-muted)]",children:[x.label,":"]}),e.jsx("span",{className:"truncate",children:x.value})]},x.key)),g.length>3&&e.jsxs("span",{className:"text-xs text-[var(--text-muted)]",children:["+",g.length-3]})]}),d&&e.jsx("button",{type:"button","aria-label":"Limpiar BQL",title:"Limpiar BQL",onClick:Ls,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:e.jsx(T.HiXMark,{className:"h-4 w-4"})}),hr&&er.createPortal(e.jsxs("div",{ref:ms,className:"flex flex-col gap-3 rounded-lg p-3 shadow-2xl",style:{...Xd,background:"var(--bg-card)",border:"1px solid color-mix(in srgb, var(--primary) 35%, var(--border))"},children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[F.map(x=>e.jsxs("button",{type:"button",onMouseDown:G=>{G.preventDefault(),G.stopPropagation()},onClick:G=>{G.preventDefault(),G.stopPropagation(),Cn(x.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:[x.icon,x.label]},x.label)),le.length>0&&e.jsxs("button",{type:"button",onClick:()=>tt(x=>!x),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":bs,children:[e.jsx(T.HiInformationCircle,{className:"h-3.5 w-3.5"}),"Ejemplos"]}),It.length>0&&e.jsxs("button",{type:"button",onClick:()=>nt(x=>!x),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":ps,children:[e.jsx(T.HiClock,{className:"h-3.5 w-3.5"}),"Historial"]})]}),e.jsxs("div",{className:"overflow-hidden rounded-lg",style:{background:"var(--bg-input)",border:`1.5px solid ${xe?"var(--danger)":d?"var(--primary)":"var(--border)"}`},children:[e.jsx("textarea",{ref:ma,value:Dt,rows:3,onChange:x=>ya(x.target.value,x.target),onKeyDown:x=>{x.key==="Enter"&&!x.shiftKey&&(x.preventDefault(),Ms(Dt)),x.key==="Escape"&&Br(!1)},placeholder:re,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"}}),D.length>0&&e.jsx("div",{className:"border-t border-[var(--border)] bg-[var(--bg-card)]",children:D.map(x=>e.jsx("button",{type:"button",onMouseDown:G=>{G.preventDefault(),G.stopPropagation()},onClick:G=>{G.preventDefault(),G.stopPropagation(),Cn(x)},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:x},x))})]}),e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[e.jsx("span",{className:"min-w-0 text-xs",style:{color:xe?"var(--danger)":"var(--text-muted)"},children:xe??(d?`${g.length||1} filtro${(g.length||1)===1?"":"s"} activo${(g.length||1)===1?"":"s"}`:"Enter aplica la consulta. Shift + Enter agrega linea.")}),g.map(x=>e.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:[e.jsxs("span",{className:"text-[var(--text-muted)]",children:[x.label,":"]}),e.jsx("span",{className:"truncate",children:x.value})]},x.key))]}),ps&&It.length>0&&e.jsxs("div",{className:"overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-input)]",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-[var(--border)] px-3 py-2",children:[e.jsxs("span",{className:"flex items-center gap-1.5 text-xs font-semibold text-[var(--text-secondary)]",children:[e.jsx(T.HiClock,{className:"h-3.5 w-3.5"}),"Historial"]}),e.jsxs("button",{type:"button",onClick:()=>{at([]),nt(!1)},className:"inline-flex items-center gap-1 rounded px-2 py-0.5 text-xs text-[var(--text-muted)]",children:[e.jsx(T.HiTrash,{className:"h-3 w-3"}),"Limpiar"]})]}),It.map(x=>e.jsxs("div",{className:"group flex items-center gap-2 border-b border-[var(--border)] px-3 py-2 last:border-b-0",children:[e.jsx("button",{type:"button",onMouseDown:G=>{G.preventDefault(),G.stopPropagation()},onClick:G=>{G.preventDefault(),G.stopPropagation(),Cn(x)},className:"min-w-0 flex-1 text-left",children:e.jsx("code",{className:"block truncate text-xs text-[var(--primary)]",children:x})}),e.jsx("button",{type:"button",onClick:()=>at(G=>G.filter(de=>de!==x)),className:"rounded p-1 text-[var(--text-muted)] opacity-0 transition-opacity group-hover:opacity-100",children:e.jsx(T.HiXMark,{className:"h-3.5 w-3.5"})})]},x))]}),bs&&le.length>0&&e.jsx("div",{className:"grid gap-2 sm:grid-cols-2 lg:grid-cols-3",children:le.map(x=>e.jsxs("button",{type:"button",onMouseDown:G=>{G.preventDefault(),G.stopPropagation()},onClick:G=>{G.preventDefault(),G.stopPropagation(),Cn(x.bql),tt(!1)},className:"rounded-lg border border-[var(--border)] bg-[var(--bg-input)] p-2 text-left transition-colors hover:border-[var(--primary)]",children:[e.jsx("code",{className:"block truncate text-xs text-[var(--primary)]",children:x.bql}),x.description&&e.jsx("span",{className:"mt-1 block text-xs text-[var(--text-muted)]",children:x.description})]},x.bql))}),e.jsxs("div",{className:"flex items-center justify-end gap-2 border-t border-[var(--border)] pt-3",children:[d&&e.jsxs("button",{type:"button",onClick:Ls,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:[e.jsx(T.HiXMark,{className:"h-3.5 w-3.5"}),"Limpiar"]}),e.jsxs("button",{type:"button",onClick:()=>Ms(Dt),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:[e.jsx(T.HiCheck,{className:"h-3.5 w-3.5"}),"Aplicar"]})]})]}),document.body)]})]}),pr&&e.jsx("button",{ref:xn,type:"button","aria-haspopup":"menu","aria-expanded":Bt,"aria-label":"Exportar datos",title:"Exportar datos",onClick:()=>{var G;const x=(G=xn.current)==null?void 0:G.getBoundingClientRect();x&&Rd({top:x.bottom+4,right:window.innerWidth-x.right}),vn(de=>!de)},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)] ${Bt?"bg-[var(--bg-card)] text-[var(--primary)]":""}`,children:e.jsx(T.HiArrowDownTray,{className:"h-4 w-4"})}),O&&e.jsx("button",{type:"button","aria-haspopup":"menu","aria-expanded":Xe&&ir==="visibility","aria-label":ie,title:ie,onClick:x=>$s(x,"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)] ${Xe&&ir==="visibility"?"bg-[var(--bg-card)] text-[var(--primary)]":""}`,children:e.jsx(T.HiCog6Tooth,{className:"h-4 w-4"})})]})},Ws=()=>{if(!Cu)return null;const d=Kl(We,Ea);return e.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 ${$?"px-2 py-0.5":"px-3 py-1"}`,style:{borderColor:"var(--border)",background:"var(--bg-input)"},children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{style:{color:"var(--text-muted)"},children:jr===0?"0 filas":`${Eu}–${Mu} de ${jr}`}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{style:{color:"var(--text-muted)"},children:"Filas:"}),e.jsx(Lr,{value:String(ur),onChange:g=>Lu(Number(g)),options:Ds.map(g=>({value:String(g),label:String(g)})),placeholder:"Filas",searchable:!1,disabled:a,height:q,padding:X,className:"shrink-0 [&>button]:rounded-md [&>button]:text-xs [&_svg]:h-3.5 [&_svg]:w-3.5",style:{width:P}})]})]}),e.jsxs("div",{className:"flex items-center justify-center gap-0.5",children:[e.jsx("button",{disabled:a||We<=1,onClick:()=>Ma(We-1),onMouseEnter:g=>{g.currentTarget.disabled||(g.currentTarget.style.background="color-mix(in srgb, var(--primary) 14%, var(--bg-card))",g.currentTarget.style.color="var(--primary)")},onMouseLeave:g=>{g.currentTarget.style.background="transparent",g.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:e.jsx(T.HiChevronLeft,{className:"h-3.5 w-3.5"})}),d.map((g,D)=>g==="..."?e.jsx("span",{className:"px-1",style:{color:"var(--text-muted)"},children:"…"},`e${D}`):e.jsx("button",{disabled:a,onClick:()=>Ma(g),onMouseEnter:x=>{x.currentTarget.disabled||g===We||(x.currentTarget.style.background="color-mix(in srgb, var(--primary) 14%, var(--bg-card))",x.currentTarget.style.color="var(--primary)")},onMouseLeave:x=>{x.currentTarget.style.background=g===We?"var(--primary)":"transparent",x.currentTarget.style.color=g===We?"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:g===We?"var(--primary)":"transparent",color:g===We?"var(--primary-fg)":"var(--text-muted)"},children:g},g)),e.jsx("button",{disabled:a||We>=Ea,onClick:()=>Ma(We+1),onMouseEnter:g=>{g.currentTarget.disabled||(g.currentTarget.style.background="color-mix(in srgb, var(--primary) 14%, var(--bg-card))",g.currentTarget.style.color="var(--primary)")},onMouseLeave:g=>{g.currentTarget.style.background="transparent",g.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:e.jsx(T.HiChevronRight,{className:"h-3.5 w-3.5"})})]}),e.jsx("div",{"aria-hidden":"true"})]})},Du=()=>e.jsxs("div",{className:"w-full min-w-0 max-w-full flex flex-col rounded-lg overflow-hidden",style:{background:"var(--bg-card)",boxShadow:Tn},children:[Dn(),Bn(),On(),e.jsx("div",{ref:Nr,className:"min-w-0 max-w-full overflow-hidden",children:e.jsxs("div",{role:"table",className:"text-sm",style:{width:Pt,minWidth:$n},children:[e.jsx("div",{role:"rowgroup",style:N?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:An()}),e.jsx("div",{role:"rowgroup",children:Array.from({length:Math.min(6,s)}).map((d,g)=>e.jsxs("div",{role:"row",className:"grid",style:{gridTemplateColumns:dt,borderBottom:`1px solid ${Me}`},children:[fr&&e.jsx("div",{role:"cell",className:`${$?"px-2 py-1.5":"px-3 py-2"} w-10`,style:{borderBottom:`1px solid ${Me}`,borderRight:`1px solid ${Me}`}},"select-cell"),Re.map((D,x)=>e.jsx("div",{role:"cell",className:$?"px-2 py-1.5":"px-3 py-2",style:{borderBottom:`1px solid ${Me}`,borderRight:`1px solid ${Me}`},children:e.jsx("div",{className:"h-3.5 rounded-full animate-pulse",style:{background:"var(--border)",width:`${xs(g,x)}%`,minWidth:32}})},D.key))]},g))})]})})]}),Ta="min-w-0 max-w-full overflow-hidden";return W&&Qe&&!ue?e.jsx(jt,{rows:s,columns:Math.max(4,Re.length||7)}):!a&&t.length===0&&!ga?Du():a&&t.length===0?e.jsxs("div",{className:"w-full min-w-0 max-w-full flex flex-col rounded-lg overflow-hidden",style:{background:"var(--bg-card)",boxShadow:Tn},children:[Dn(),Bn(),On(),e.jsx("div",{ref:Nr,className:Ta,children:e.jsx(Aa.OverlayScrollbarsComponent,{options:{scrollbars:{autoHide:"leave",autoHideDelay:200}},className:"w-full",style:{maxHeight:ws,maxWidth:"100%"},defer:!0,children:e.jsxs("div",{role:"table",className:"text-sm",style:{width:Pt,minWidth:$n},children:[e.jsx("div",{role:"rowgroup",style:N?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:An()}),e.jsx("div",{role:"rowgroup",children:Array.from({length:s}).map((d,g)=>e.jsxs("div",{role:"row",className:"grid",style:{gridTemplateColumns:dt,borderBottom:`1px solid ${Me}`},children:[fr&&e.jsx("div",{role:"cell",className:`${$?"px-2 py-1.5":"px-3 py-2"} w-10`,style:{borderBottom:`1px solid ${Me}`,borderRight:`1px solid ${Me}`}},"select-cell"),Re.map((D,x)=>{const G=Mn[D.key],de=G!==void 0,pe=D.key===Ca;return e.jsx("div",{role:"cell","data-dt-column-key":D.key,className:$?"px-2 py-1.5":"px-3 py-2",style:de?{position:"sticky",left:G,zIndex:1,background:"color-mix(in srgb, var(--bg-card) 72%, transparent)",backdropFilter:"blur(10px)",WebkitBackdropFilter:"blur(10px)",boxShadow:pe?`3px 0 6px -2px rgba(0,0,0,0.10), inset 0 -1px 0 ${Me}`:`inset 0 -1px 0 ${Me}`,borderRight:`1px solid ${Me}`}:{borderBottom:`1px solid ${Me}`,borderRight:`1px solid ${Me}`},children:e.jsx("div",{className:"h-3.5 rounded-full animate-pulse",style:{background:"var(--border)",width:`${xs(g,x)}%`,minWidth:32}})},D.key)})]},g))})]})})}),Ws()]}):!a&&t.length===0?e.jsxs("div",{className:"w-full min-w-0 max-w-full flex flex-col rounded-lg overflow-hidden",style:{background:"var(--bg-card)",boxShadow:Tn},children:[Dn(),Bn(),On(),e.jsx("div",{ref:Nr,className:Ta,children:e.jsx("div",{role:"table",className:"text-sm",style:{width:Pt,minWidth:$n},children:e.jsx("div",{role:"rowgroup",style:N?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:An()})})}),e.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:Me,background:"linear-gradient(180deg, color-mix(in srgb, var(--bg-input) 58%, transparent), var(--bg-card))"},children:[e.jsx("div",{className:"flex h-12 w-12 items-center justify-center rounded-full border",style:{borderColor:"color-mix(in srgb, var(--primary) 24%, var(--border))",background:"color-mix(in srgb, var(--primary) 8%, var(--bg-card))",color:"var(--primary)"},children:l??e.jsx(T.HiMagnifyingGlass,{className:"h-5 w-5"})}),e.jsx("p",{className:"max-w-sm text-sm font-medium",style:{color:"var(--text-main)"},children:i}),e.jsx("span",{className:"text-xs",style:{color:"var(--text-muted)"},children:"Ajusta la busqueda o cambia los filtros para ver mas informacion."})]})]}):e.jsxs("div",{className:"w-full min-w-0 max-w-full flex flex-col rounded-lg overflow-hidden",style:{background:"var(--bg-card)",boxShadow:Tn},children:[Dn(),Bn(),On(),e.jsx("div",{ref:Nr,className:Ta,children:e.jsx(Aa.OverlayScrollbarsComponent,{options:{scrollbars:{autoHide:"leave",autoHideDelay:200}},className:"w-full",style:{maxHeight:ws,maxWidth:"100%"},defer:!0,children:e.jsxs("div",{role:"table",className:"text-sm",style:{width:Pt,minWidth:$n},children:[e.jsx("div",{role:"rowgroup",style:N?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:An()}),e.jsx("div",{role:"rowgroup",children:Bs.map((d,g)=>{const D=n(d),x=zs(L==null?void 0:L(d)),G=g>0?zs(L==null?void 0:L(Bs[g-1])):null,de=x&&x.key!==(G==null?void 0:G.key),pe=fr&&S.has(D),we=ct?(p==null?void 0:p(d))??!0:!1,je=we&&Is.has(D),ze=!!u||y&&we,Ue=pe&&_?"color-mix(in srgb, var(--primary) 8%, var(--bg-card))":g%2===1?"color-mix(in srgb, var(--bg-input) 30%, var(--bg-card))":"var(--bg-card)";return e.jsxs(o.Fragment,{children:[de&&e.jsx("div",{role:"row",className:`grid ${x.className??""}`,style:{gridTemplateColumns:dt},children:e.jsx("div",{role:"cell",className:$?"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 ${Me}`,borderRight:`1px solid ${Me}`},children:e.jsx("div",{className:"flex min-w-0 items-center justify-between gap-3",children:e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate text-xs font-semibold uppercase tracking-wider text-[var(--text-main)]",children:x.label}),x.description&&e.jsx("div",{className:"mt-0.5 truncate text-xs text-[var(--text-muted)]",children:x.description})]})})})}),e.jsxs("div",{role:"row",onClick:ze?ke=>{const ye=ke.target;if(!(ye!=null&&ye.closest('[data-dt-disable-row-click="true"]'))){if(y&&we){Os(D);return}u==null||u(d)}}:void 0,className:`grid transition-colors ${ze?"cursor-pointer":""} ${E?E(d):""}`,style:{gridTemplateColumns:dt,"--dt-row-bg":Ue,"--dt-sticky-bg":Ue,background:"var(--dt-row-bg)",borderBottom:`1px solid ${Me}`},onMouseEnter:ke=>{pe||(ke.currentTarget.style.setProperty("--dt-row-bg","var(--bg-hover)"),ke.currentTarget.style.setProperty("--dt-sticky-bg",Tu))},onMouseLeave:ke=>{ke.currentTarget.style.setProperty("--dt-row-bg",Ue),ke.currentTarget.style.setProperty("--dt-sticky-bg",Ue)},children:[ct&&e.jsx("div",{role:"cell",className:`${$?"px-2 py-1.5":"px-3 py-2"} flex w-10 items-center justify-center`,style:{borderBottom:`1px solid ${Me}`,borderRight:`1px solid ${Me}`},"data-dt-disable-row-click":"true",children:we&&e.jsx("button",{type:"button","aria-label":je?"Contraer fila":"Desplegar fila","aria-expanded":je,onClick:ke=>{ke.stopPropagation(),Os(D)},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:je?e.jsx(T.HiChevronDown,{className:"h-4 w-4"}):e.jsx(T.HiChevronRight,{className:"h-4 w-4"})})}),fr&&e.jsx("div",{role:"cell",className:`${$?"px-2 py-1.5":"px-3 py-2"} w-10`,style:Na?{position:"sticky",left:0,zIndex:3,background:"var(--dt-sticky-bg)",boxShadow:`inset 0 -1px 0 ${Me}`}:{borderBottom:`1px solid ${Me}`,borderRight:`1px solid ${Me}`},onClick:ke=>{ke.stopPropagation(),h(D)},children:e.jsx(Wt,{size:"sm",checked:pe,"aria-label":"Seleccionar fila",containerClassName:"items-center",className:"cursor-pointer",onClick:ke=>ke.stopPropagation(),onChange:()=>h(D)})}),Re.map(ke=>{const ye=Mn[ke.key],Ne=ye!==void 0,he=ke.key===Ca,me=Tr(ke);return e.jsx("div",{role:"cell","data-dt-column-key":ke.key,"data-dt-disable-row-click":ke.disableRowClick||me?"true":void 0,className:`${me?"px-2 py-1.5 text-center":`${$?"px-2 py-1.5":"px-3 py-2"} ${Hs(ke.align)}`} ${jl} ${ke.className??""}`,style:{overflow:"hidden",whiteSpace:"nowrap",...Ne?{position:"sticky",left:ye,zIndex:3,background:"var(--dt-sticky-bg)",boxShadow:he?`3px 0 6px -2px rgba(0,0,0,0.10), inset 0 -1px 0 ${Me}`:`inset 0 -1px 0 ${Me}`,borderRight:`1px solid ${Me}`}:{borderBottom:`1px solid ${Me}`,borderRight:`1px solid ${Me}`}},children:e.jsx(Qa,{children:e.jsx("div",{"data-dt-autofit-content":!0,className:"inline-block max-w-none align-middle",children:ke.cell(d)})})},ke.key)})]}),je&&f&&e.jsx("div",{role:"row",className:"grid",style:{gridTemplateColumns:dt},children:e.jsx("div",{role:"cell",className:$?"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 ${Me}`},children:f(d)})})]},D)})})]})})}),Ws()]})}const Zl={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 Ql(r,t){if(t.minLength!==void 0&&r.length<t.minLength)return t.message??`Mínimo ${t.minLength} caracteres`;if(t.maxLength!==void 0&&r.length>t.maxLength)return t.message??`Máximo ${t.maxLength} caracteres`;if(!r)return null;if(t.preset){const n=Zl[t.preset];if(!n.pattern.test(r))return t.message??n.message}return t.pattern&&!t.pattern.test(r)?t.message??"Formato inválido":null}const Jl=new Set(["Backspace","Delete","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Tab","Home","End","Enter","Escape"]);function Rl({initialValue:r,type:t,mask:n,onCommit:a,onCancel:s}){const[l,i]=o.useState(r),c=o.useRef(null),u=(n==null?void 0:n.preset)==="date",f=u?"date":t==="number"?"number":"text";return o.useEffect(()=>{var p,b;(p=c.current)==null||p.focus(),u||(b=c.current)==null||b.select()},[u]),e.jsx("input",{ref:c,type:f,value:l,maxLength:n==null?void 0:n.maxLength,onChange:p=>i(p.target.value),onBlur:()=>s(),onKeyDown:p=>{p.key==="Enter"&&(p.preventDefault(),a(l)),p.key==="Escape"&&(p.preventDefault(),s()),(n==null?void 0:n.preset)==="integer"&&!p.ctrlKey&&!p.metaKey&&!Jl.has(p.key)&&!/^[\d-]$/.test(p.key)&&p.preventDefault()},onClick:p=>p.stopPropagation(),className:"w-full min-w-0 border-0 bg-transparent p-0 text-sm text-[var(--text-main)] outline-none"})}function ei({initialValue:r,options:t,loading:n,onCommit:a,onCancel:s}){const l=o.useRef(null);return o.useEffect(()=>{if(n)return;const i=setTimeout(()=>{var c,u;(u=(c=l.current)==null?void 0:c.querySelector("button"))==null||u.click()},0);return()=>clearTimeout(i)},[n]),e.jsx("div",{ref:l,className:"w-full",tabIndex:-1,onKeyDown:i=>{i.key==="Escape"&&(i.stopPropagation(),s())},children:e.jsx(Lr,{value:r,onChange:i=>{a(i)},options:t,disabled:n,placeholder:n?"Cargando…":"Seleccionar…",triggerVariant:"ghost",height:30,padding:"0 6px",minOptionsForSearch:1,className:"w-full"})})}const ri={outline:"2px solid var(--primary)",outlineOffset:"-2px",borderRadius:"4px",background:"color-mix(in srgb, var(--primary) 5%, var(--bg-card))"},Kn={outline:"2px solid var(--primary)",outlineOffset:"-2px",borderRadius:"4px"};function ti({columns:r,data:t,getRowId:n,onCellUpdate:a,readOnly:s=!1,...l}){const[i,c]=o.useState(t),u=o.useRef(null);o.useEffect(()=>{u.current||c(t)},[t]);const[f,p]=o.useState(null);u.current=f;const[b,m]=o.useState(null),v=o.useRef(null);v.current=b;const[y,S]=o.useState({}),[h,H]=o.useState(null),_=o.useRef(null);_.current=h;const[E,L]=o.useState({}),[N,k]=o.useState({}),K=o.useRef(new Set),P=o.useRef(null);o.useEffect(()=>{var O;const M=document.activeElement;(!M||M===document.body)&&((O=P.current)==null||O.focus({preventScroll:!0}))},[]);const q=r.map(M=>{var O,oe,A;return`${M.key}:${((A=(oe=(O=M.editable)==null?void 0:O.select)==null?void 0:oe.options)==null?void 0:A.length)??-1}`}).join("|");o.useEffect(()=>{r.forEach(M=>{var A,U;const O=(U=(A=M.editable)==null?void 0:A.select)==null?void 0:U.options;if(!O)return;const oe=E[M.key];(!K.current.has(M.key)||(oe==null?void 0:oe.length)===0&&O.length>0)&&(K.current.add(M.key),L(ne=>({...ne,[M.key]:O})))})},[q]);const X=o.useCallback(async(M,O)=>{if(K.current.has(M))return;K.current.add(M);const{url:oe,fetchOptions:A}=O.select??{};if(!(!oe&&!A)){k(U=>({...U,[M]:!0}));try{let U=[];if(A)U=await A();else if(oe){const ne=await fetch(oe);if(!ne.ok)throw new Error("fetch failed");U=await ne.json()}L(ne=>({...ne,[M]:U}))}catch{L(U=>({...U,[M]:[]}))}finally{k(U=>({...U,[M]:!1}))}}},[]),J=o.useRef(i);J.current=i;const C=o.useRef(a);C.current=a;const te=o.useRef(n);te.current=n;const j=o.useRef(r);j.current=r;const W=o.useRef(s);W.current=s,o.useEffect(()=>{if(r.length>0&&t.length>0){const M=r.find(O=>O.selectable!==!1);M&&m({rowId:n(t[0]),colKey:M.key})}},[]),o.useEffect(()=>{if(!b)return;const M=P.current;if(!M)return;const O=M.querySelector(`[data-cell-id="${b.rowId}:${b.colKey}"]`);if(!O)return;const oe=M.querySelector('[role="rowgroup"]');O.style.scrollMarginTop=`${(oe==null?void 0:oe.offsetHeight)??0}px`;const A=M.querySelector('[role="row"]');let U=0;A&&A.querySelectorAll('[role="cell"], [role="columnheader"]').forEach(ne=>{ne.style.position==="sticky"&&ne.style.left!==""&&(U=Math.max(U,parseFloat(ne.style.left)+ne.offsetWidth))}),O.style.scrollMarginLeft=`${U}px`,O.scrollIntoView({block:"nearest",inline:"nearest"})},[b]);const ae=o.useCallback(M=>{var U;const O=j.current,oe=new Set,A=[];(U=P.current)==null||U.querySelectorAll("[data-cell-id]").forEach(ne=>{const ie=ne.dataset.cellId.split(":")[0];oe.has(ie)||(oe.add(ie),A.push(ie))}),m(ne=>{if(!ne)return ne;const ie=O.findIndex(R=>R.key===ne.colKey),Q=A.indexOf(ne.rowId);let V=ie,w=Q;if(M==="up")w=Math.max(0,Q-1);else if(M==="down")w=Math.min(A.length-1,Q+1);else if(M==="left"){let R=ie-1;for(;R>=0&&O[R].selectable===!1;)R--;R>=0&&(V=R)}else if(M==="right"){let R=ie+1;for(;R<O.length&&O[R].selectable===!1;)R++;R<O.length&&(V=R)}return V===ie&&w===Q?ne:{rowId:A[w],colKey:O[V].key}})},[]),Z=o.useCallback((M=!0)=>{const O=u.current;p(null),O&&m(O),M&&setTimeout(()=>{var oe;return(oe=P.current)==null?void 0:oe.focus({preventScroll:!0})},0)},[]),$=o.useCallback(async(M,O,oe)=>{var Le;const A=j.current.find(xe=>xe.key===O);if(!(A!=null&&A.editable))return;const{field:U,type:ne,mask:ie,validate:Q}=A.editable,V=ne==="number"?oe===""?null:Number(oe):oe;if(ie){const xe=Ql(oe,ie);if(xe){S(Se=>({...Se,[`${M}:${O}`]:xe}));return}}if(Q){const xe=Q(V);if(xe){S(Se=>({...Se,[`${M}:${O}`]:xe}));return}}const w=te.current,R=J.current.find(xe=>w(xe)===M);if(!R)return;const B=R[U];p(null),S(xe=>{const Se={...xe};return delete Se[`${M}:${O}`],Se});const re=J.current,F=re.findIndex(xe=>w(xe)===M),le=re[Math.min(re.length-1,F+1)];if(m({rowId:w(le),colKey:O}),setTimeout(()=>{var Se,Te;const xe=document.activeElement;(!xe||xe===document.body||(Se=P.current)!=null&&Se.contains(xe))&&((Te=P.current)==null||Te.focus({preventScroll:!0}))},0),String(B??"")===String(V??""))return;const Ee={...R,[U]:V};c(xe=>xe.map(Se=>w(Se)===M?Ee:Se)),H({rowId:M,colKey:O});try{await((Le=C.current)==null?void 0:Le.call(C,{row:R,rowId:M,field:U,oldValue:B,newValue:V}))}catch{c(xe=>xe.map(Se=>w(Se)===M?R:Se)),S(xe=>({...xe,[`${M}:${O}`]:"Error al guardar. Intenta de nuevo."}))}finally{H(null)}},[]),ee=o.useCallback(M=>{if(_.current){M.preventDefault();return}if(u.current)return;const O=v.current;if(!(!O||!["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Enter","Escape","Tab"].includes(M.key)))switch(M.preventDefault(),M.key){case"ArrowUp":ae("up");break;case"ArrowDown":ae("down");break;case"ArrowLeft":ae("left");break;case"ArrowRight":ae("right");break;case"Tab":ae(M.shiftKey?"left":"right");break;case"Enter":{const A=j.current.find(U=>U.key===O.colKey);A!=null&&A.editable&&!W.current?(p(O),A.editable.type==="select"&&!K.current.has(O.colKey)&&X(O.colKey,A.editable)):ae("down");break}}},[ae,X]),se=o.useMemo(()=>r.map(M=>{if(!M.editable||s){const oe={...M};if(delete oe.editable,delete oe.selectable,M.selectable===!1)return{...oe,disableRowClick:!0};const A=oe.cell;return{...oe,className:`relative ${oe.className??""}`.trim(),disableRowClick:!0,cell:U=>{const ne=n(U),ie=(b==null?void 0:b.rowId)===ne&&(b==null?void 0:b.colKey)===M.key;return e.jsxs(e.Fragment,{children:[e.jsx("span",{"data-cell-id":`${ne}:${M.key}`,className:"absolute inset-0 z-10 cursor-default",onClick:()=>{var Q;_.current||(m({rowId:ne,colKey:M.key}),(Q=P.current)==null||Q.focus({preventScroll:!0}))}}),ie&&e.jsx("div",{className:"pointer-events-none absolute inset-0 z-20",style:Kn}),e.jsx("span",{className:"relative z-0 pointer-events-none",children:A(U)})]})}}}const O=M.editable;return{...M,className:`relative ${M.className??""}`.trim(),disableRowClick:!0,cell:oe=>{const A=n(oe),U=M.key,ne=(f==null?void 0:f.rowId)===A&&(f==null?void 0:f.colKey)===U,ie=(b==null?void 0:b.rowId)===A&&(b==null?void 0:b.colKey)===U,Q=y[`${A}:${U}`],V=(h==null?void 0:h.rowId)===A&&(h==null?void 0:h.colKey)===U,w=oe[O.field],R=String(w??""),B=()=>{var F;_.current||(m({rowId:A,colKey:U}),p({rowId:A,colKey:U}),(F=P.current)==null||F.focus({preventScroll:!0}),O.type==="select"&&!K.current.has(U)&&X(U,O))};if(ne){const F=O.type==="select"?e.jsx(ei,{initialValue:R,options:E[U]??[],loading:N[U]??!1,onCommit:le=>$(A,U,le),onCancel:Z}):e.jsx(Rl,{initialValue:R,type:O.type??"text",mask:O.mask,onCommit:le=>$(A,U,le),onCancel:Z});return e.jsx("div",{className:"absolute inset-0 flex items-center px-2",style:ri,onClick:le=>le.stopPropagation(),children:F})}const re=M.cell(oe);return e.jsxs(e.Fragment,{children:[e.jsx("span",{"data-cell-id":`${A}:${U}`,className:`peer absolute inset-0 z-10 ${V?"cursor-wait":"cursor-pointer"}`,onClick:B}),ie&&!V&&e.jsx("div",{className:"pointer-events-none absolute inset-0 z-20",style:Kn}),V&&e.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:Kn,children:[e.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}),e.jsx("span",{className:"truncate text-xs text-[var(--text-muted)]",children:"Guardando…"})]}),e.jsx("span",{className:"relative z-0 inline-flex items-center gap-1 pointer-events-none",children:Q?e.jsxs("span",{className:"flex items-center gap-1 text-red-500",children:[e.jsx(T.HiExclamationCircle,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"truncate text-xs",children:Q})]}):e.jsx("span",{className:"truncate",children:re})}),!V&&e.jsx(T.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"})]})}}}),[r,s,f,b,h,y,E,N,n,$,Z,X]);return e.jsx("div",{ref:P,tabIndex:0,onKeyDown:ee,onBlur:M=>{var O;(O=P.current)!=null&&O.contains(M.relatedTarget)||setTimeout(()=>{var A,U;const oe=document.activeElement;oe&&((A=oe.closest)!=null&&A.call(oe,"[data-bonsaif-select-dropdown]"))||(U=P.current)!=null&&U.contains(oe)||Z(!1)},0)},style:{width:"100%",minWidth:0,outline:"none"},children:e.jsx(Ja,{...l,columns:se,data:i,getRowId:n})})}function wt(r){return r?new Date(`${r}T12:00:00`):void 0}function Ra(r){return r.toISOString().slice(0,10)}function ni({calendarMonth:r,displayIndex:t}){const{previousMonth:n,nextMonth:a,goToMonth:s,months:l,labels:i,formatters:c}=Da.useDayPicker(),u=!!n&&t===0,f=!!a&&t===l.length-1;return e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",gap:8,width:"100%",color:"var(--text-main)",marginBottom:6},children:[e.jsx("span",{style:{fontWeight:700},children:c.formatCaption(r.date)}),e.jsx("button",{type:"button","aria-label":i.labelPrevious(n),onClick:()=>n&&s(n),disabled:!u,style:{height:28,width:28,borderRadius:8,border:"1px solid var(--border)",background:"var(--bg-card)",display:"inline-flex",alignItems:"center",justifyContent:"center",color:"var(--text-main)",opacity:u?1:.45,cursor:u?"pointer":"not-allowed"},children:e.jsx(T.HiChevronLeft,{size:16})}),e.jsx("button",{type:"button","aria-label":i.labelNext(a),onClick:()=>a&&s(a),disabled:!f,style:{height:28,width:28,borderRadius:8,border:"1px solid var(--border)",background:"var(--bg-card)",display:"inline-flex",alignItems:"center",justifyContent:"center",color:"var(--text-main)",opacity:f?1:.45,cursor:f?"pointer":"not-allowed"},children:e.jsx(T.HiChevronRight,{size:16})})]})}function ai(r){return r.charAt(0).toUpperCase()+r.slice(1)}function oi({startDate:r,endDate:t,onChange:n,minDate:a,viewMonth:s,numberOfMonths:l=1,showSummary:i=!0,startLabel:c="Inicio",endLabel:u="Regreso"}){const f={from:wt(r),to:wt(t)},p=wt(a),[b,m]=o.useState(wt(s||r));return o.useEffect(()=>{m(wt(s||r))},[s,r]),e.jsxs("div",{children:[e.jsx("div",{style:{borderRadius:10,overflow:"hidden",border:"1px solid var(--border)",background:"var(--bg-input)",display:"flex",justifyContent:"center",padding:"10px 8px"},children:e.jsx(Da.DayPicker,{mode:"range",selected:f,month:b,onMonthChange:m,onSelect:v=>{const y=v!=null&&v.from?Ra(v.from):r,S=v!=null&&v.to?Ra(v.to):"";n({startDate:y,endDate:S})},numberOfMonths:l,hideNavigation:!0,disabled:p?{before:p}:void 0,showOutsideDays:!1,components:{MonthCaption:ni},className:"text-sm",classNames:{root:"w-full",months:"flex gap-3 justify-center",month:"space-y-2",month_caption:"flex items-center justify-between px-1",caption_label:"capitalize",nav:"flex items-center gap-1",button_previous:"h-8 w-8 inline-flex items-center justify-center rounded-md transition-colors",button_next:"h-8 w-8 inline-flex items-center justify-center rounded-md transition-colors",month_grid:"w-full border-collapse",weekdays:"grid grid-cols-7 gap-1 mb-1",weekday:"text-[11px] font-semibold text-center",week:"grid grid-cols-7 gap-1",day:"h-9 w-9 p-0 flex items-center justify-center",day_button:"h-9 w-9 rounded-md text-sm font-medium transition-colors outline-none",selected:"font-semibold",range_start:"font-semibold",range_middle:"font-medium",range_end:"font-semibold",today:"font-bold",disabled:"opacity-40 cursor-not-allowed",hidden:"invisible"},styles:{month_caption:{color:"var(--text-main)",marginBottom:6,display:"flex",alignItems:"center",justifyContent:"space-between"},caption_label:{color:"var(--text-main)",fontWeight:700},nav:{position:"static",display:"flex",alignItems:"center",gap:6},weekday:{color:"var(--text-muted)",textTransform:"lowercase"},button_previous:{height:32,width:32,background:"var(--bg-card)",color:"var(--text-main)",border:"1px solid var(--border)"},button_next:{height:32,width:32,background:"var(--bg-card)",color:"var(--text-main)",border:"1px solid var(--border)"},day_button:{color:"var(--text-main)",borderRadius:8},chevron:{fill:"var(--text-main)"},today:{border:"1px solid color-mix(in srgb, var(--primary) 35%, transparent)"},disabled:{color:"var(--text-muted)"}},modifiersStyles:{selected:{background:"var(--primary)",color:"var(--primary-fg, #ffffff)"},range_start:{background:"var(--primary)",color:"var(--primary-fg, #ffffff)"},range_end:{background:"var(--primary)",color:"var(--primary-fg, #ffffff)"},range_middle:{background:"color-mix(in srgb, var(--primary) 20%, transparent)",color:"var(--text-main)"}},formatters:{formatCaption:v=>ai(new Intl.DateTimeFormat("es-MX",{month:"long",year:"numeric"}).format(v)),formatWeekdayName:v=>new Intl.DateTimeFormat("es-MX",{weekday:"short"}).format(v)},labels:{labelMonthDropdown:()=>"Mes",labelYearDropdown:()=>"Año"}})}),i&&r&&e.jsxs("div",{style:{marginTop:8,fontSize:12,color:"var(--text-muted)",display:"flex",gap:8,flexWrap:"wrap"},children:[e.jsxs("span",{children:[c,":"," ",e.jsx("strong",{style:{color:"var(--text-main)"},children:r})]}),t&&e.jsxs("span",{children:[u,":"," ",e.jsx("strong",{style:{color:"var(--text-main)"},children:t})]})]})]})}const si="bonsaif-ui:hide-tooltips";function eo(){window.dispatchEvent(new CustomEvent(si))}function li(r){if(r!==void 0)return typeof r=="number"?`${r}px`:r}function ii({trigger:r,items:t,align:n="end",width:a=220,disabled:s=!1,className:l="",menuClassName:i="",onOpenChange:c}){const[u,f]=o.useState(!1),[p,b]=o.useState(!1),[m,v]=o.useState({}),y=o.useRef(null),S=o.useRef(null),h=o.useCallback(N=>{f(N),c==null||c(N)},[c]),H=o.useCallback(()=>{const N=y.current;if(!N)return;const k=N.getBoundingClientRect(),K=typeof a=="number"?a:k.width,P=typeof a=="number"?a:Math.max(k.width,180),q=n==="end"?Math.max(8,k.right-P):Math.min(k.left,window.innerWidth-P-8),X=window.innerHeight-k.bottom,J=X<240&&k.top>X?void 0:k.bottom+6,C=J===void 0?window.innerHeight-k.top+6:void 0;v({position:"fixed",zIndex:9999,left:q,top:J,bottom:C,width:li(typeof a=="number"?K:a)})},[n,a]);o.useEffect(()=>b(!0),[]),o.useEffect(()=>{if(!u)return;H();const N=K=>{var q,X;const P=K.target;!((q=y.current)!=null&&q.contains(P))&&!((X=S.current)!=null&&X.contains(P))&&h(!1)},k=K=>{K.key==="Escape"&&h(!1)};return document.addEventListener("mousedown",N),window.addEventListener("keydown",k),window.addEventListener("resize",H),window.addEventListener("scroll",H,!0),()=>{document.removeEventListener("mousedown",N),window.removeEventListener("keydown",k),window.removeEventListener("resize",H),window.removeEventListener("scroll",H,!0)}},[u,h,H]);const _=N=>{s||(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),h(!u))},E=o.isValidElement(r)?o.cloneElement(r,{onClick:()=>{s||(eo(),h(!u))}}):r,L=u?e.jsx("div",{ref:S,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:m,children:t.map(N=>e.jsxs("div",{children:[N.separatorBefore&&e.jsx("div",{className:"my-1 border-t border-[var(--border)]"}),e.jsxs("button",{type:"button",role:"menuitem",disabled:N.disabled,onClick:()=>{var k;N.disabled||(eo(),(k=N.onSelect)==null||k.call(N),h(!1))},className:"flex w-full min-w-0 items-start gap-2 rounded-md px-2.5 py-1.5 text-left transition-colors hover:bg-[var(--bg-input)] disabled:cursor-not-allowed disabled:opacity-50",style:{color:N.danger?"var(--danger)":"var(--text-main)"},children:[N.icon&&e.jsx("span",{className:"mt-0.5 shrink-0",children:N.icon}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block truncate text-sm font-medium",children:N.label}),N.description&&e.jsx("span",{className:"block truncate text-xs text-[var(--text-muted)]",children:N.description})]})]})]},N.id))}):null;return e.jsxs("span",{ref:y,role:"button",tabIndex:s?-1:0,"aria-haspopup":"menu","aria-expanded":u,onKeyDown:_,className:`inline-flex ${s?"pointer-events-none opacity-60":""} ${l}`,children:[E,p&&L?er.createPortal(L,document.body):null]})}const ci=180,ro="bg-[color-mix(in_srgb,var(--bg-main)_72%,transparent)] backdrop-blur-sm";function di({open:r,onClose:t,title:n,subtitle:a,leadingIcon:s,confirmLabel:l="Guardar",onConfirm:i,loading:c=!1,confirmDisabled:u=!1,headerActions:f,bodyClassName:p="flex-1 overflow-y-auto px-6 py-5",width:b=440,hasUnsavedChanges:m=!1,unsavedChangesTitle:v="Descartar cambios",unsavedChangesDescription:y="Hay cambios sin guardar. Si cierras el drawer se perderán.",unsavedChangesConfirmLabel:S="Descartar",unsavedChangesCancelLabel:h="Seguir editando",onDiscardChanges:H,disabled:_=!1,children:E}){const[L,N]=o.useState(!1),[k,K]=o.useState(!1),[P,q]=o.useState(!1),X=o.useCallback(()=>{K(!0),requestAnimationFrame(()=>{requestAnimationFrame(()=>q(!0))})},[]),J=o.useCallback(()=>{q(!1),window.setTimeout(()=>K(!1),ci)},[]),C=o.useCallback(()=>{if(m){X();return}t()},[m,t,X]),te=o.useCallback(()=>{q(!1),K(!1),H==null||H(),t()},[t,H]);return o.useEffect(()=>{N(!0)},[]),o.useEffect(()=>(document.body.style.overflow=r?"hidden":"",r||(q(!1),K(!1)),()=>{document.body.style.overflow=""}),[r]),o.useEffect(()=>{if(!r)return;const j=W=>{if(W.key==="Escape"){if(k){J();return}C()}};return window.addEventListener("keydown",j),()=>window.removeEventListener("keydown",j)},[J,k,r,C]),L?er.createPortal(e.jsxs("div",{"aria-hidden":!r,"data-bonsaif-overlay":r?"true":void 0,className:`fixed inset-0 z-[1000] flex transition-opacity duration-300 ${r?"opacity-100":"opacity-0 pointer-events-none"}`,children:[e.jsx("div",{className:`absolute inset-0 ${ro}`,onClick:C}),e.jsxs("div",{className:`absolute inset-y-0 right-0 flex flex-col shadow-2xl transition-transform duration-300 ${r?"translate-x-0":"translate-x-full"}`,style:{width:`min(100vw, ${b}px)`,background:"var(--bg-card)",borderLeft:"1px solid var(--border)"},children:[e.jsxs("div",{className:"flex items-center justify-between px-6 py-4 flex-shrink-0",style:{borderBottom:"1px solid var(--border)"},children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx(Fe,{variant:"icon",onClick:C,title:"Cerrar",children:e.jsx(T.HiXMark,{className:"w-5 h-5"})}),s&&e.jsx("div",{className:"flex-shrink-0",children:s}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h3",{className:"text-base font-semibold truncate",style:{color:"var(--text-main)"},children:n}),a&&e.jsx("p",{className:"text-xs truncate",style:{color:"var(--text-muted)"},children:a})]})]}),(f||i)&&e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[f,i&&e.jsxs(e.Fragment,{children:[e.jsx(Fe,{variant:"secondary",size:"sm",onClick:C,style:{background:"var(--bg-input)"},children:"Cancelar"}),e.jsx(Fe,{variant:"primary",size:"sm",icon:e.jsx(Vs.FiSave,{className:"w-4 h-4"}),onClick:i,loading:c,disabled:u,title:l})]})]})]}),e.jsx("div",{"data-drawer-scroll":"true",className:p,children:E})]}),_&&e.jsx("div",{className:"absolute inset-0 z-[1002] cursor-not-allowed",style:{background:"color-mix(in srgb, var(--bg-card, #ffffff) 60%, transparent)",backdropFilter:"blur(2px)"}}),k&&e.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":v,className:"fixed inset-0 z-[1001] flex items-center justify-center p-4",children:[e.jsx("div",{className:`absolute inset-0 ${ro} transition-opacity duration-200 ease-out ${P?"opacity-100":"opacity-0"}`,onClick:J}),e.jsxs("div",{className:`relative z-10 w-full max-w-sm rounded-2xl border p-6 shadow-2xl transition-[opacity,transform] duration-200 ease-out ${P?"translate-y-0 scale-100 opacity-100":"translate-y-2 scale-[0.96] opacity-0"}`,style:{background:"var(--bg-card, #ffffff)",borderColor:"var(--border, #d8e1dc)"},children:[e.jsx(Fe,{variant:"icon",onClick:J,className:"absolute right-3 top-3 h-7 w-7 hover:opacity-70",style:{color:"var(--text-muted, #6b7f78)"},"aria-label":h,children:e.jsx(T.HiXMark,{className:"h-4 w-4"})}),e.jsx("div",{className:"mb-4 flex h-11 w-11 items-center justify-center rounded-xl",style:{background:"var(--warning-bg, #fff7ed)"},children:e.jsx(T.HiExclamationTriangle,{className:"h-5 w-5",style:{color:"var(--warning, #d97706)"}})}),e.jsx("h2",{className:"mb-1 text-base font-semibold",style:{color:"var(--text-main, #0f2f2c)"},children:v}),e.jsx("p",{className:"text-sm",style:{color:"var(--text-muted, #6b7f78)"},children:y}),e.jsxs("div",{className:"mt-6 flex gap-2",children:[e.jsx(Fe,{variant:"secondary",onClick:J,className:"flex-1 border",style:{background:"var(--bg-input, #f7faf8)",borderColor:"var(--border, #d8e1dc)",color:"var(--text-main, #0f2f2c)"},children:h}),e.jsx(Fe,{variant:"secondary",onClick:te,className:"flex-1 border",style:{background:"var(--warning, #d97706)",borderColor:"transparent",color:"#fff",boxShadow:"0 10px 22px rgba(217, 119, 6, 0.22)"},children:S})]})]})]})]}),document.body):null}const ui=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,fi=/^\+?[0-9\s().-]+$/,bi=7,pi=15;function or(r){return r==null||String(r).trim()===""}function to(r){return typeof r=="number"?r:typeof r=="string"&&r.trim()!==""?Number(r):Number.NaN}function Xn(r){return or(r)?!1:ui.test(String(r))}function Yn(r){if(or(r))return!1;const t=String(r),n=t.replace(/\D/g,"");return fi.test(t)&&n.length>=bi&&n.length<=pi}function mi(r="Este campo es requerido."){return t=>or(t)?r:void 0}function hi(r="Ingresa un correo valido."){return t=>or(t)||Xn(t)?void 0:r}function gi(r="Ingresa un telefono valido."){return t=>or(t)||Yn(t)?void 0:r}function vi(r,t){return n=>or(n)||String(n).length>=r?void 0:t??`Debe tener al menos ${r} caracteres.`}function xi(r,t){return n=>or(n)||String(n).length<=r?void 0:t??`Debe tener ${r} caracteres o menos.`}function yi(r,t){return n=>{if(or(n))return;const a=to(n);return Number.isFinite(a)&&a>=r?void 0:t??`Debe ser mayor o igual a ${r}.`}}function wi(r,t){return n=>{if(or(n))return;const a=to(n);return Number.isFinite(a)&&a<=r?void 0:t??`Debe ser menor o igual a ${r}.`}}function ki(r,t="El formato no es valido."){return n=>or(n)||r.test(String(n))?void 0:t}function Ni(r,t){const n={};for(const a of Object.keys(t)){const s=t[a];if(!s)continue;const l=Array.isArray(s)?s:[s];for(const i of l){const c=i(r[a],r);if(c){n[a]=c;break}}}return{valid:Object.keys(n).length===0,errors:n}}var no={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},ao=o.createContext&&o.createContext(no),Si=["attr","size","title"];function Ci(r,t){if(r==null)return{};var n,a,s=Ei(r,t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(r);for(a=0;a<l.length;a++)n=l[a],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(r,n)&&(s[n]=r[n])}return s}function Ei(r,t){if(r==null)return{};var n={};for(var a in r)if({}.hasOwnProperty.call(r,a)){if(t.indexOf(a)!==-1)continue;n[a]=r[a]}return n}function Yt(){return Yt=Object.assign?Object.assign.bind():function(r){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)({}).hasOwnProperty.call(n,a)&&(r[a]=n[a])}return r},Yt.apply(null,arguments)}function oo(r,t){var n=Object.keys(r);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(r);t&&(a=a.filter(function(s){return Object.getOwnPropertyDescriptor(r,s).enumerable})),n.push.apply(n,a)}return n}function Zt(r){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?oo(Object(n),!0).forEach(function(a){Mi(r,a,n[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(n)):oo(Object(n)).forEach(function(a){Object.defineProperty(r,a,Object.getOwnPropertyDescriptor(n,a))})}return r}function Mi(r,t,n){return(t=Li(t))in r?Object.defineProperty(r,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):r[t]=n,r}function Li(r){var t=Ti(r,"string");return typeof t=="symbol"?t:t+""}function Ti(r,t){if(typeof r!="object"||!r)return r;var n=r[Symbol.toPrimitive];if(n!==void 0){var a=n.call(r,t);if(typeof a!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(r)}function so(r){return r&&r.map((t,n)=>o.createElement(t.tag,Zt({key:n},t.attr),so(t.child)))}function Zn(r){return t=>o.createElement($i,Yt({attr:Zt({},r.attr)},t),so(r.child))}function $i(r){var t=n=>{var{attr:a,size:s,title:l}=r,i=Ci(r,Si),c=s||n.size||"1em",u;return n.className&&(u=n.className),r.className&&(u=(u?u+" ":"")+r.className),o.createElement("svg",Yt({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},n.attr,a,i,{className:u,style:Zt(Zt({color:r.color||n.color},n.style),r.style),height:c,width:c,xmlns:"http://www.w3.org/2000/svg"}),l&&o.createElement("title",null,l),r.children)};return ao!==void 0?o.createElement(ao.Consumer,null,n=>t(n)):t(no)}function lo(r){return Zn({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:[]}]})(r)}function Ai(r){return Zn({attr:{viewBox:"0 0 256 256",fill:"currentColor"},child:[{tag:"path",attr:{d:"M247.31,124.76c-.35-.79-8.82-19.58-27.65-38.41C194.57,61.26,162.88,48,128,48S61.43,61.26,36.34,86.35C17.51,105.18,9,124,8.69,124.76a8,8,0,0,0,0,6.5c.35.79,8.82,19.57,27.65,38.4C61.43,194.74,93.12,208,128,208s66.57-13.26,91.66-38.34c18.83-18.83,27.3-37.61,27.65-38.4A8,8,0,0,0,247.31,124.76ZM128,192c-30.78,0-57.67-11.19-79.93-33.25A133.47,133.47,0,0,1,25,128,133.33,133.33,0,0,1,48.07,97.25C70.33,75.19,97.22,64,128,64s57.67,11.19,79.93,33.25A133.46,133.46,0,0,1,231.05,128C223.84,141.46,192.43,192,128,192Zm0-112a48,48,0,1,0,48,48A48.05,48.05,0,0,0,128,80Zm0,80a32,32,0,1,1,32-32A32,32,0,0,1,128,160Z"},child:[]}]})(r)}function Di(r){return Zn({attr:{viewBox:"0 0 256 256",fill:"currentColor"},child:[{tag:"path",attr:{d:"M228,175a8,8,0,0,1-10.92-3l-19-33.2A123.23,123.23,0,0,1,162,155.46l5.87,35.22a8,8,0,0,1-6.58,9.21A8.4,8.4,0,0,1,160,200a8,8,0,0,1-7.88-6.69l-5.77-34.58a133.06,133.06,0,0,1-36.68,0l-5.77,34.58A8,8,0,0,1,96,200a8.4,8.4,0,0,1-1.32-.11,8,8,0,0,1-6.58-9.21L94,155.46a123.23,123.23,0,0,1-36.06-16.69L39,172A8,8,0,1,1,25.06,164l20-35a153.47,153.47,0,0,1-19.3-20A8,8,0,1,1,38.22,99c16.6,20.54,45.64,45,89.78,45s73.18-24.49,89.78-45A8,8,0,1,1,230.22,109a153.47,153.47,0,0,1-19.3,20l20,35A8,8,0,0,1,228,175Z"},child:[]}]})(r)}function Kr({content:r,ariaLabel:t="Más información",className:n=""}){return e.jsx(Mr,{as:"span",content:r,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:e.jsx("span",{tabIndex:0,role:"img","aria-label":t,className:"inline-flex items-center justify-center outline-none",children:e.jsx(T.HiInformationCircle,{className:"h-3.5 w-3.5"})})})}function Xr({error:r,helperText:t,helperDisplay:n="inline"}){return r?e.jsx("span",{className:"text-xs font-medium normal-case text-[var(--danger)]",children:r}):t&&n!=="tooltip"?e.jsx("span",{className:"text-xs font-medium normal-case text-[var(--text-muted)]",children:t}):null}function Qt({className:r="",...t}){return e.jsx("input",{...t,className:`h-10 rounded-lg border border-[var(--border)] bg-[var(--bg-input)] px-2.5 py-1.5 text-sm text-[var(--text-main)] outline-none placeholder:text-[var(--text-muted)] transition-colors focus:border-[var(--primary)] ${r}`})}function Qn({label:r,containerClassName:t="",helperText:n,helperDisplay:a="inline",error:s,errorDisplay:l="inline",errorTooltipLabel:i="Error de validacion",labelAction:c,floatingLabel:u=!1,showPasswordToggle:f=!0,nativeValidation:p=!1,className:b="",required:m,...v}){const[y,S]=o.useState(()=>!!v.autoFocus),[h,H]=o.useState(!1),_=v.type==="password"&&f,E=_&&h?"text":v.type,L=!!s,N=L&&l!=="tooltip",k=L&&l!=="inline",K=!!n&&a==="tooltip"&&!N,P=p?m:void 0,q=L?"border-[var(--danger)] focus:border-[var(--danger)]":"",X=k?_?"pr-20":"pr-10":_?"pr-10":"",J=v.value!==void 0?String(v.value).length>0:v.defaultValue!==void 0&&String(v.defaultValue).length>0,C=y||J,te={top:C?7:12,color:y?"var(--primary)":"var(--text-muted)",fontSize:C?10:13,fontWeight:C?600:400,textTransform:C?"uppercase":"none"},j=ee=>{var se;S(!0),(se=v.onFocus)==null||se.call(v,ee)},W=ee=>{var se;S(!1),(se=v.onBlur)==null||se.call(v,ee)},ae=_?e.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:()=>H(ee=>!ee),children:[e.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:e.jsx(Ai,{className:"h-[18px] w-[18px]"})}),e.jsx("span",{"aria-hidden":"true",className:`absolute inset-0 flex items-center justify-center transition-[opacity,transform] duration-200 ease-out ${h?"scale-y-100 rotate-0 opacity-100":"scale-y-0 rotate-[8deg] opacity-0"}`,children:e.jsx(Di,{className:"h-[18px] w-[18px]"})})]}):null,Z=k?e.jsx(Mr,{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:e.jsx("span",{tabIndex:0,role:"img","aria-label":i,className:"flex h-full w-full items-center justify-center outline-none",children:e.jsx(lo,{className:"h-[18px] w-[18px]"})})}):null,$=e.jsx(Xr,{error:N?s:void 0,helperText:n,helperDisplay:a});return u?e.jsxs("label",{className:`flex flex-col gap-2 ${t}`,children:[e.jsxs("span",{className:"relative block",children:[e.jsx(Qt,{...v,type:E,required:P,placeholder:" ","aria-invalid":L||v["aria-invalid"],"data-has-value":J?"true":void 0,className:`h-11 w-full pt-5 ${X} ${q} ${b}`,onFocus:j,onBlur:W}),e.jsxs("span",{className:"pointer-events-none absolute left-3 transition-all duration-150",style:te,children:[r,m&&e.jsx("span",{className:"ml-1 text-[var(--danger)]",children:"*"})]}),c&&e.jsx("span",{className:"absolute right-2 transition-all duration-150",style:{top:C?7:12},children:c}),Z,ae]}),$]}):e.jsxs("label",{className:`flex flex-col gap-2 ${t}`,children:[e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-semibold uppercase text-[var(--text-muted)]",children:[e.jsx("span",{children:r}),m&&e.jsx("span",{className:"text-[var(--danger)]",children:"*"}),K?e.jsx(Kr,{content:n}):null,c&&e.jsx("span",{className:"ml-auto normal-case",children:c})]}),_?e.jsxs("span",{className:"relative block",children:[e.jsx(Qt,{...v,type:E,required:P,"aria-invalid":L||v["aria-invalid"],className:`w-full ${X} ${q} ${b}`,onFocus:j,onBlur:W}),Z,ae]}):e.jsxs("span",{className:"relative block",children:[e.jsx(Qt,{...v,required:P,"aria-invalid":L||v["aria-invalid"],className:`w-full ${X} ${q} ${b}`}),Z]}),$]})}function io(r){return r==null?"":String(r)}function Ii({autoComplete:r="email",inputMode:t="email",validate:n=!0,invalidMessage:a="Ingresa un correo valido.",errorDisplay:s="tooltip",error:l,value:i,defaultValue:c,onChange:u,...f}){const[p,b]=o.useState(()=>io(c)),m=i!==void 0?io(i):p,v=n&&m.length>0&&!Xn(m)?a:void 0,y=S=>{i===void 0&&b(S.currentTarget.value),u==null||u(S)};return e.jsx(Qn,{...f,value:i,defaultValue:c,type:"text",inputMode:t,autoComplete:r,error:l??v,errorDisplay:s,onChange:y})}const Bi={sm:"min-h-[160px] p-4",md:"min-h-[220px] p-6",lg:"min-h-[300px] p-8"};function Oi({title:r="Sin resultados",description:t,icon:n=e.jsx(T.HiInbox,{className:"h-5 w-5"}),action:a,secondaryAction:s,size:l="md",className:i=""}){return e.jsx("div",{className:`flex items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-card)] text-center ${Bi[l]} ${i}`,children:e.jsxs("div",{className:"flex max-w-sm flex-col items-center gap-3",children:[n&&e.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-input)] text-[var(--text-muted)]",children:n}),e.jsxs("div",{className:"space-y-1",children:[r&&e.jsx("h3",{className:"text-sm font-semibold text-[var(--text-main)]",children:r}),t&&e.jsx("div",{className:"text-sm leading-5 text-[var(--text-muted)]",children:t})]}),(a||s)&&e.jsxs("div",{className:"mt-1 flex flex-wrap items-center justify-center gap-2",children:[s,a]})]})})}const Hi={sm:"min-h-[112px] p-4",md:"min-h-[148px] p-5",lg:"min-h-[184px] p-6"};function Pi(r){if(r===0)return"0 B";const t=["B","KB","MB","GB"],n=Math.min(Math.floor(Math.log(r)/Math.log(1024)),t.length-1),a=r/1024**n;return`${a>=10||n===0?a.toFixed(0):a.toFixed(1)} ${t[n]}`}function co(r,t){return t?t.split(",").map(n=>n.trim().toLowerCase()).filter(Boolean).some(n=>{const a=r.name.toLowerCase(),s=r.type.toLowerCase();return n.startsWith(".")?a.endsWith(n):n.endsWith("/*")?s.startsWith(n.slice(0,-1)):s===n}):!0}function Fi(r,t,n){return t?n===void 0?r:r.slice(0,Math.max(0,n)):r.slice(0,1)}function zi({label:r,helperText:t,helperDisplay:n="inline",error:a,labelAction:s,value:l,defaultValue:i=[],onFilesChange:c,onRejectedFiles:u,multiple:f=!1,maxFiles:p,appendFiles:b=!1,showFileList:m=!0,clearable:v=!0,browseLabel:y="Buscar archivos",dropLabel:S="Suelta los archivos aqui",emptyLabel:h="Arrastra y suelta archivos",emptyDescription:H="o haz click para buscarlos en tu equipo",selectedLabel:_="Archivos seleccionados",size:E="md",containerClassName:L="",dropzoneClassName:N="",fileListClassName:k="",className:K="",id:P,accept:q,disabled:X,required:J,...C}){const te=o.useId(),j=P??te,W=o.useRef(null),[ae,Z]=o.useState(!1),[$,ee]=o.useState(i),se=l??$,M=!!a,O=!!t&&n==="tooltip"&&!M,oe=v&&se.length>0&&!X,A=(F,le)=>{l===void 0&&ee(F),c==null||c(F,le)},U=(F,le)=>{const Ee=F.filter(Te=>co(Te,q)),Le=F.filter(Te=>!co(Te,q)),xe=b?[...se,...Ee]:Ee,Se=Fi(xe,f,p);Le.length>0&&(u==null||u(Le)),A(Se,le)},ne=()=>{var F;X||(F=W.current)==null||F.click()},ie=F=>{U(Array.from(F.target.files??[]),F),F.target.value=""},Q=F=>{F.preventDefault(),X||Z(!0)},V=F=>{F.currentTarget.contains(F.relatedTarget)||Z(!1)},w=F=>{F.preventDefault(),Z(!1),!X&&U(Array.from(F.dataTransfer.files),F)},R=F=>{F.key!=="Enter"&&F.key!==" "||(F.preventDefault(),ne())},B=F=>{A(se.filter((le,Ee)=>Ee!==F))},re=()=>{A([])};return e.jsxs("div",{className:`flex flex-col gap-2 ${L}`,children:[(r||s||O)&&e.jsxs("div",{className:"inline-flex items-center gap-1 text-xs font-semibold uppercase text-[var(--text-muted)]",children:[r&&e.jsx("span",{children:r}),J&&e.jsx("span",{className:"text-[var(--danger)]",children:"*"}),O?e.jsx(Kr,{content:t}):null,s&&e.jsx("span",{className:"ml-auto normal-case",children:s})]}),e.jsx("input",{...C,ref:W,id:j,type:"file",accept:q,multiple:f,disabled:X,required:J&&se.length===0,"aria-invalid":M||C["aria-invalid"],className:"sr-only",onChange:ie}),e.jsxs("div",{role:"button",tabIndex:X?-1:0,"aria-controls":j,"aria-disabled":X||void 0,"aria-invalid":M||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)] ${Hi[E]} ${ae?"border-[var(--primary)] bg-[var(--bg-input)]":M?"border-[var(--danger)]":"border-[var(--border)]"} ${X?"cursor-not-allowed opacity-60":"hover:border-[var(--primary)] hover:bg-[var(--bg-input)]"} ${N} ${K}`,onClick:ne,onDragOver:Q,onDragLeave:V,onDrop:w,onKeyDown:R,children:[e.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:e.jsx(T.HiArrowUpTray,{className:"h-5 w-5"})}),e.jsxs("span",{className:"space-y-1",children:[e.jsx("span",{className:"block text-sm font-semibold text-[var(--text-main)]",children:ae?S:h}),H&&e.jsx("span",{className:"block text-sm text-[var(--text-muted)]",children:H})]}),y&&e.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:y})]}),m&&se.length>0&&e.jsxs("div",{className:`rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${k}`,children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-[var(--border)] px-3 py-2",children:[e.jsx("span",{className:"text-xs font-semibold uppercase text-[var(--text-muted)]",children:_}),oe&&e.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:e.jsx(T.HiTrash,{className:"h-4 w-4"})})]}),e.jsx("ul",{className:"divide-y divide-[var(--border)]",children:se.map((F,le)=>e.jsxs("li",{className:"flex items-center gap-3 px-3 py-2",children:[e.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:e.jsx(T.HiDocument,{className:"h-4 w-4"})}),e.jsxs("span",{className:"min-w-0 flex-1 text-left",children:[e.jsx("span",{className:"block truncate text-sm font-medium text-[var(--text-main)]",children:F.name}),e.jsx("span",{className:"block text-xs text-[var(--text-muted)]",children:Pi(F.size)})]}),!X&&e.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 ${F.name}`,onClick:()=>B(le),children:e.jsx(T.HiXMark,{className:"h-4 w-4"})})]},`${F.name}-${F.lastModified}-${le}`))})]}),e.jsx(Xr,{error:a,helperText:t,helperDisplay:n})]})}const _i=[{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 ji({fields:r,title:t="Layout",fieldTypes:n=_i,saveLabel:a="Guardar",allowAddField:s=!1,addFieldPlaceholder:l="Nuevo campo",addFieldLabel:i="Anadir",loading:c=!1,onSave:u,onChange:f}){const[p,b]=o.useState(()=>r.map(E=>({key:!1,type:"",...E}))),[m,v]=o.useState(""),[y,S]=o.useState(""),h=o.useCallback((E,L)=>{b(N=>{const k=N.map((K,P)=>P===E?{...K,...L}:K);return f==null||f(k),k})},[f]),H=o.useCallback(()=>{u==null||u(p)},[p,u]),_=o.useCallback(()=>{var k;const E=m.trim();if(!E){S("Ingresa un nombre de campo.");return}if(p.some(K=>K.name.toLowerCase()===E.toLowerCase())){S("Ese campo ya existe en el arreglo.");return}const N={name:E,key:!1,type:((k=n[0])==null?void 0:k.value)??""};b(K=>{const P=[...K,N];return f==null||f(P),P}),v(""),S("")},[n,p,m,f]);return e.jsxs("div",{className:"flex flex-col rounded-xl border shadow-sm",style:{borderColor:"var(--border)",background:"var(--bg-card)",color:"var(--text-main)"},children:[e.jsx("div",{className:"border-b px-6 py-4",style:{borderColor:"var(--border)"},children:e.jsx("span",{className:"text-base font-semibold",style:{color:"var(--text-main)"},children:t})}),e.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:[e.jsx("span",{children:"Campo"}),e.jsx("span",{className:"text-center",children:"Llave"}),e.jsx("span",{children:"Tipo de Campo"})]}),e.jsxs("div",{className:"max-h-[420px] overflow-y-auto",children:[p.map((E,L)=>e.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:[e.jsx("span",{className:"text-sm font-medium",style:{color:"var(--text-main)"},children:E.name}),e.jsx("div",{className:"flex justify-center",children:e.jsx(Wt,{size:"sm",checked:E.key??!1,onChange:N=>h(L,{key:N.target.checked}),"aria-label":`${E.name} es clave`})}),e.jsx(Lr,{value:E.type??"",onChange:N=>h(L,{type:N}),options:n,placeholder:"—",emptyLabel:"—",height:36,searchable:!1,ariaLabel:`Tipo de ${E.name}`})]},E.name)),p.length===0&&e.jsx("p",{className:"px-6 py-8 text-center text-sm",style:{color:"var(--text-muted)"},children:"No hay campos disponibles."})]}),e.jsx("div",{className:"flex justify-end border-t px-6 py-4",style:{borderColor:"var(--border)"},children:e.jsxs("div",{className:"w-full space-y-2",children:[s&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"text",value:m,onChange:E=>{v(E.currentTarget.value),y&&S("")},onKeyDown:E=>{E.key==="Enter"&&(E.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"}),e.jsx(Fe,{variant:"secondary",onClick:_,height:36,padding:"0 12px",children:i})]}),y&&e.jsx("p",{className:"text-xs",style:{color:"var(--danger)"},children:y})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(Fe,{variant:"primary",onClick:H,disabled:c,loading:c,children:a})})]})})]})}function uo({label:r,children:t,helperText:n,helperDisplay:a="inline",error:s,labelAction:l,required:i=!1,className:c="",contentClassName:u=""}){const f=!!n&&a==="tooltip"&&!s;return e.jsxs("label",{className:`flex flex-col gap-2 ${c}`,children:[(r||l||f)&&e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-semibold uppercase text-[var(--text-muted)]",children:[r&&e.jsx("span",{children:r}),i&&e.jsx("span",{className:"text-[var(--danger)]",children:"*"}),f?e.jsx(Kr,{content:n}):null,l&&e.jsx("span",{className:"ml-auto normal-case",children:l})]}),e.jsx("span",{className:`block ${u}`,children:t}),e.jsx(Xr,{error:s,helperText:n,helperDisplay:a})]})}function fo(r){if(r!==void 0)return typeof r=="number"?`${r}px`:r}function bo(r,t){if(r.length!==t.length)return!1;const n=new Set(t);return r.every(a=>n.has(a))}function Jn(r){return r.normalize("NFD").replace(new RegExp("\\p{M}","gu"),"").toLowerCase()}function Wi(r,t){if(!t)return!0;const n=Jn(t);return Jn(r.label).includes(n)||!!(r.sublabel&&Jn(r.sublabel).includes(n))}function qi({value:r,onChange:t,options:n,placeholder:a="Seleccionar…",disabled:s=!1,className:l="",style:i,height:c=40,padding:u="6px 10px",searchable:f=!0,minOptionsForSearch:p=6,maxVisibleValues:b=2,truncateSelectedValues:m=!0,emptyText:v="Sin resultados",clearLabel:y="Limpiar seleccion",pruneMissingValues:S=!0}){const[h,H]=o.useState(!1),[_,E]=o.useState(""),[L,N]=o.useState(0),[k,K]=o.useState(!1),[P,q]=o.useState({}),X=o.useRef(null),J=o.useRef(null),C=o.useRef(null),te=o.useRef(null),j=f&&n.length>=p,W=o.useMemo(()=>new Set(r),[r]),ae=o.useMemo(()=>{const w=new Map;for(const R of n)w.set(R.value,R);return w},[n]),Z=o.useMemo(()=>{const w=[];for(const R of r){const B=ae.get(R);B&&w.push(B)}return w},[ae,r]),$=b==="all"?Z.length:b,ee=Z.slice(0,$),se=Math.max(0,Z.length-ee.length),M=o.useMemo(()=>{const w=_.trim();return!j||!w?n:n.filter(R=>Wi(R,w))},[n,_,j]),O=o.useCallback(()=>{const w=X.current;if(!w)return;const R=w.getBoundingClientRect(),B=j?304:244,re=window.innerHeight-R.bottom,F=re<B&&R.top>re;q({position:"fixed",left:R.left,top:F?void 0:R.bottom+4,bottom:F?window.innerHeight-R.top+4:void 0,width:Math.max(R.width,240),zIndex:9999})},[j]),oe=o.useCallback(w=>{bo(r,w)||t(w)},[t,r]),A=o.useCallback(w=>{const R=ae.get(w);if(R!=null&&R.disabled)return;const B=W.has(w)?r.filter(re=>re!==w):[...r,w];oe(B)},[oe,ae,r,W]),U=o.useCallback(()=>oe([]),[oe]),ne=o.useCallback(()=>{H(!1),E(""),N(0)},[]);o.useEffect(()=>K(!0),[]);const ie=o.useMemo(()=>n.map(w=>w.value).join("\0"),[n]);o.useEffect(()=>{if(!S||r.length===0||n.length===0)return;const w=new Set(n.map(B=>B.value)),R=r.filter(B=>w.has(B));bo(r,R)||t(R)},[ie]),o.useEffect(()=>{if(!h)return;function w(R){var re,F;const B=R.target;!((re=X.current)!=null&&re.contains(B))&&!((F=J.current)!=null&&F.contains(B))&&ne()}return document.addEventListener("mousedown",w),()=>document.removeEventListener("mousedown",w)},[ne,h]),o.useEffect(()=>{h&&(N(0),O(),j&&setTimeout(()=>{var w;return(w=C.current)==null?void 0:w.focus()},0))},[h,j,O]),o.useEffect(()=>{if(h)return window.addEventListener("resize",O),window.addEventListener("scroll",O,!0),()=>{window.removeEventListener("resize",O),window.removeEventListener("scroll",O,!0)}},[h,O]),o.useEffect(()=>{if(M.length===0){N(0);return}N(w=>Math.min(w,M.length-1))},[M.length]),o.useEffect(()=>{if(L<0||!te.current)return;const w=te.current.children[L];w==null||w.scrollIntoView({block:"nearest"})},[L]);function Q(w){if(!s){if(!h){(w.key==="Enter"||w.key===" "||w.key==="ArrowDown")&&(w.preventDefault(),H(!0));return}if(w.key==="Escape"){w.preventDefault(),ne();return}if(w.key==="ArrowDown"){if(w.preventDefault(),M.length===0)return;N(R=>Math.min(R+1,M.length-1));return}if(w.key==="ArrowUp"){w.preventDefault(),N(R=>Math.max(R-1,0));return}if(w.key==="Enter"&&M[L]&&!M[L].disabled){w.preventDefault(),A(M[L].value);return}w.key==="Backspace"&&!_&&r.length&&(w.preventDefault(),oe(r.slice(0,-1)))}}const V=e.jsxs("div",{ref:J,className:"overflow-hidden rounded-xl shadow-xl",style:{...P,background:"var(--bg-card)",border:"1px solid var(--border)"},children:[j&&e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",style:{borderBottom:"1px solid var(--border)"},children:[e.jsx(T.HiMagnifyingGlass,{className:"h-3.5 w-3.5 flex-shrink-0",style:{color:"var(--text-muted)"}}),e.jsx("input",{ref:C,value:_,onChange:w=>{E(w.target.value),N(0)},onKeyDown:w=>{(w.key==="ArrowDown"||w.key==="ArrowUp"||w.key==="Enter"||w.key==="Escape")&&(w.stopPropagation(),Q(w))},placeholder:"Buscar…",className:"min-w-0 flex-1 bg-transparent text-sm outline-none",style:{color:"var(--text-main)"}}),_&&e.jsx("button",{type:"button","aria-label":"Limpiar búsqueda",onMouseDown:w=>{w.preventDefault(),E(""),N(0)},children:e.jsx(T.HiXMark,{className:"h-3.5 w-3.5",style:{color:"var(--text-muted)"}})})]}),r.length>0&&e.jsxs("div",{className:"flex items-center justify-between gap-3 px-3 py-2 text-xs",style:{borderBottom:"1px solid var(--border)",color:"var(--text-muted)"},children:[e.jsxs("span",{children:[Z.length," seleccionados",r.length>Z.length?` (${r.length-Z.length} no disponibles)`:""]}),e.jsx("button",{type:"button",onMouseDown:w=>{w.preventDefault(),U()},className:"font-semibold transition-colors hover:text-[var(--primary)]",children:y})]}),e.jsxs("ul",{ref:te,role:"listbox","aria-multiselectable":"true",className:"overflow-y-auto",style:{maxHeight:j?220:200,scrollbarWidth:"thin",scrollbarColor:"var(--border) transparent",overscrollBehavior:"contain"},children:[M.map((w,R)=>{const B=R===L,re=W.has(w.value);return e.jsxs("li",{role:"option","aria-selected":re,onMouseDown:F=>{F.preventDefault(),!w.disabled&&A(w.value)},onMouseEnter:()=>!w.disabled&&N(R),className:"flex cursor-pointer items-center gap-2 px-3 py-2 text-sm transition-colors",style:{background:B?"var(--bg-hover)":re?"color-mix(in srgb, var(--primary) 6%, transparent)":"transparent",color:w.disabled?"var(--text-muted)":"var(--text-main)",cursor:w.disabled?"not-allowed":"pointer",opacity:w.disabled?.58:1},children:[e.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&&e.jsx(T.HiCheck,{className:"h-3 w-3"})}),w.color&&e.jsx("span",{className:"h-2.5 w-2.5 flex-shrink-0 rounded-full",style:{background:w.color}}),e.jsxs("span",{className:"flex min-w-0 flex-1 items-baseline gap-1 overflow-hidden",children:[e.jsx("span",{className:"truncate",children:w.label}),w.sublabel&&e.jsx("span",{className:"min-w-0 flex-shrink truncate",style:{color:"var(--text-muted)",fontSize:12},children:w.sublabel})]}),w.badge&&e.jsx("span",{className:"flex-shrink-0 text-xs",style:{color:"var(--text-muted)"},children:w.badge})]},w.value)}),M.length===0&&e.jsx("li",{className:"px-3 py-4 text-center text-sm",style:{color:"var(--text-muted)"},children:v})]})]});return e.jsxs("div",{ref:X,className:`relative ${l||"w-full"}`,style:i,onKeyDown:Q,children:[e.jsxs("button",{type:"button",disabled:s,onClick:()=>{s||(h?ne():H(!0))},className:"flex w-full items-center gap-2 rounded-lg text-left text-sm transition-colors focus:outline-none",style:{minHeight:fo(c),padding:fo(u),background:"var(--bg-input)",color:Z.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:[e.jsx("span",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-1.5 overflow-hidden",children:ee.length?e.jsxs(e.Fragment,{children:[ee.map(w=>e.jsxs("span",{className:`inline-flex items-center gap-1 rounded-md border px-1.5 py-0.5 text-xs font-semibold ${m?"max-w-[160px]":"max-w-full whitespace-normal"}`,style:{background:"var(--bg-card)",borderColor:"var(--border)",color:"var(--text-main)"},children:[w.color&&e.jsx("span",{className:"h-1.5 w-1.5 flex-shrink-0 rounded-full",style:{background:w.color}}),e.jsx("span",{className:m?"truncate":"break-words",children:w.label}),e.jsx("span",{role:"button",tabIndex:-1,"aria-label":`Quitar ${w.label}`,onMouseDown:R=>{R.preventDefault(),R.stopPropagation(),A(w.value)},className:"flex-shrink-0 rounded-full p-0.5 transition-colors hover:bg-black/10",style:{color:"var(--text-muted)"},children:e.jsx(T.HiXMark,{className:"h-3 w-3"})})]},w.value)),se>0&&e.jsxs("span",{className:"inline-flex items-center rounded-md px-1.5 py-0.5 text-xs font-semibold",style:{background:"color-mix(in srgb, var(--primary) 10%, transparent)",color:"var(--primary)"},children:["+",se]})]}):e.jsx("span",{className:"truncate",children:a})}),Z.length?e.jsx("span",{role:"button",tabIndex:-1,"aria-label":y,onMouseDown:w=>{w.preventDefault(),w.stopPropagation(),U()},className:"flex-shrink-0 rounded-full p-0.5 transition-colors hover:bg-black/10",style:{color:"var(--text-muted)"},children:e.jsx(T.HiXMark,{className:"h-3.5 w-3.5"})}):e.jsx(T.HiChevronDown,{className:"h-4 w-4 flex-shrink-0 transition-transform",style:{color:"var(--text-muted)",transform:h?"rotate(180deg)":"rotate(0deg)"}})]}),h&&k&&er.createPortal(V,document.body)]})}function Ui({inputMode:r="decimal",...t}){return e.jsx(Qn,{...t,type:"number",inputMode:r})}function Vi(r,t,n){const a=[],s=Math.max(2,r-n),l=Math.min(t-1,r+n);a.push(1),s>2&&a.push("...");for(let i=s;i<=l;i+=1)a.push(i);return l<t-1&&a.push("..."),t>1&&a.push(t),a}function Gi({page:r,totalPages:t,onPageChange:n,disabled:a=!1,siblingCount:s=1,className:l=""}){const i=Math.max(1,t),c=Math.min(Math.max(1,r),i),u=Vi(c,i,s);return e.jsxs("nav",{"aria-label":"Paginacion",className:`inline-flex items-center gap-1 ${l}`,children:[e.jsx(Fe,{variant:"icon",size:"xs","aria-label":"Pagina anterior",disabled:a||c<=1,onClick:()=>n(c-1),children:e.jsx(T.HiChevronLeft,{className:"h-4 w-4"})}),u.map((f,p)=>f==="..."?e.jsx("span",{className:"flex h-8 min-w-8 items-center justify-center text-xs font-semibold text-[var(--text-muted)]",children:"..."},`ellipsis-${p}`):e.jsx("button",{type:"button","aria-current":f===c?"page":void 0,disabled:a,onClick:()=>n(f),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:f===c?"var(--primary)":"var(--border)",background:f===c?"var(--primary)":"var(--bg-card)",color:f===c?"var(--primary-fg)":"var(--text-secondary)"},children:f},f)),e.jsx(Fe,{variant:"icon",size:"xs","aria-label":"Pagina siguiente",disabled:a||c>=i,onClick:()=>n(c+1),children:e.jsx(T.HiChevronRight,{className:"h-4 w-4"})})]})}const po=[{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 mo(r){return r==null?"":String(r)}function Jt(r){return r?r.startsWith("+")?r:`+${r}`:"+1"}function Ki(r){return typeof r=="number"?`${r}px`:r}function Xi({autoComplete:r="tel",inputMode:t="tel",validate:n=!0,invalidMessage:a="Ingresa un telefono valido.",errorDisplay:s="tooltip",error:l,value:i,defaultValue:c,onChange:u,countryCode:f,defaultCountryCode:p="+1",onCountryCodeChange:b,allowedCountryCodes:m,countryCodeOptions:v,countryCodePlaceholder:y="Codigo",countryCodeClassName:S="",countryCodeWidth:h=84,onPhoneValueChange:H,label:_,containerClassName:E="",helperText:L,helperDisplay:N="inline",labelAction:k,className:K="",required:P,disabled:q,floatingLabel:X,showPasswordToggle:J,nativeValidation:C,errorTooltipLabel:te="Error de validacion",...j}){var F;const[W,ae]=o.useState(()=>mo(c)),[Z,$]=o.useState(()=>Jt(p)),ee=o.useMemo(()=>{const le=v??po,Ee=m==null?void 0:m.map(Jt);return Ee!=null&&Ee.length?le.filter(Le=>Ee.includes(Le.value)):le},[m,v]),se=((F=ee[0])==null?void 0:F.value)??"+1",M=ee.some(le=>le.value===Jt(f??Z))?Jt(f??Z):se,O=i!==void 0?mo(i):W,oe=`${M} ${O}`.trim(),A=n&&O.length>0&&!Yn(oe)?a:void 0,U=l??A,ne=!!U,ie=ne&&s!=="tooltip",Q=ne&&s!=="inline",V=!!L&&N==="tooltip"&&!ie,w=ne?"border-[var(--danger)] focus-within:border-[var(--danger)]":"border-[var(--border)] focus-within:border-[var(--primary)]",R=le=>{const Ee=le.currentTarget.value;i===void 0&&ae(Ee),H==null||H(Ee,{countryCode:M,nationalNumber:Ee,fullNumber:`${M} ${Ee}`.trim()}),u==null||u(le)},B=le=>{f===void 0&&$(le),b==null||b(le),H==null||H(O,{countryCode:le,nationalNumber:O,fullNumber:`${le} ${O}`.trim()})},re=Q?e.jsx(Mr,{as:"span",content:U,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:e.jsx("span",{tabIndex:0,role:"img","aria-label":te,className:"flex h-full w-full items-center justify-center outline-none",children:e.jsx(lo,{className:"h-[18px] w-[18px]"})})}):null;return e.jsxs("div",{className:`flex flex-col gap-2 ${E}`,children:[e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-semibold uppercase text-[var(--text-muted)]",children:[e.jsx("span",{children:_}),P&&e.jsx("span",{className:"text-[var(--danger)]",children:"*"}),V?e.jsx(Kr,{content:L}):null,k&&e.jsx("span",{className:"ml-auto normal-case",children:k})]}),e.jsxs("span",{className:`flex h-10 min-w-0 items-center overflow-hidden rounded-lg border bg-[var(--bg-input)] transition-colors ${w}`,children:[e.jsx(Lr,{value:M,onChange:B,options:ee,placeholder:y,disabled:q,ariaLabel:"Codigo telefonico",triggerVariant:"ghost",showSelectedSublabel:!1,searchable:!0,minOptionsForSearch:0,dropdownMinWidth:300,className:`shrink-0 ${S}`,style:{width:Ki(h)},height:38,padding:"0 8px 0 10px"}),e.jsx("span",{className:"h-5 w-px shrink-0 bg-[var(--border)]"}),e.jsxs("span",{className:"relative min-w-0 flex-1 self-stretch",children:[e.jsx("input",{...j,value:i,defaultValue:c,type:"tel",inputMode:t,autoComplete:r,disabled:q,required:void 0,"aria-label":j["aria-label"]??(typeof _=="string"?_:void 0),"aria-invalid":ne||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 ${Q?"pr-10":""} ${K}`,onChange:R}),re]})]}),e.jsx(Xr,{error:ie?U:void 0,helperText:L,helperDisplay:N})]})}function Yi({value:r,onChange:t,options:n,name:a,label:s,orientation:l="vertical",disabled:i=!1,className:c="",optionClassName:u=""}){return e.jsxs("fieldset",{className:`min-w-0 ${c}`,disabled:i,children:[s&&e.jsx("legend",{className:"mb-2 text-xs font-semibold uppercase text-[var(--text-muted)]",children:s}),e.jsx("div",{className:l==="horizontal"?"flex flex-wrap gap-2":"flex flex-col gap-2",children:n.map(f=>{const p=f.value===r,b=i||f.disabled;return e.jsxs("label",{className:`inline-flex min-w-0 items-start gap-2 rounded-lg border px-2.5 py-1.5 transition-colors ${b?"cursor-not-allowed opacity-60":"cursor-pointer hover:bg-[var(--bg-input)]"} ${u}`,style:{borderColor:p?"color-mix(in srgb, var(--primary) 48%, var(--border))":"var(--border)",background:p?"color-mix(in srgb, var(--primary) 8%, transparent)":"var(--bg-card)"},children:[e.jsxs("span",{className:"relative mt-0.5 inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-full border border-[var(--border)] bg-[var(--bg-input)]",children:[e.jsx("input",{type:"radio",name:a,value:f.value,checked:p,disabled:b,onChange:()=>t(f.value),className:"absolute inset-0 opacity-0"}),e.jsx("span",{className:`h-2 w-2 rounded-full transition ${p?"scale-100 opacity-100":"scale-50 opacity-0"}`,style:{background:"var(--primary)"}})]}),e.jsxs("span",{className:"min-w-0",children:[e.jsx("span",{className:"block text-sm font-medium leading-5 text-[var(--text-main)]",children:f.label}),f.description&&e.jsx("span",{className:"block text-xs leading-5 text-[var(--text-muted)]",children:f.description})]})]},f.value)})})]})}const ho=()=>'<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>',kt=r=>r.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'"),go=r=>r.toLocaleLowerCase().replace(new RegExp("(^|[^\\p{L}\\p{N}])(\\p{L})","gu"),(t,n,a)=>`${n}${a.toLocaleUpperCase()}`),Zi=r=>r.replace(/[<>]/g,"").toLowerCase(),Qi=new Set(["p","br","div","span","b","strong","i","em","u","s","strike","ul","ol","li","h1","h2","h3","h4","blockquote","a","img","hr"]),Ji=/^[\s\u00a0]*([•●○■▪▫◆◇►▶➢❖✓✔\-–—*])[\s\u00a0]+/,Ri=r=>{const t=r.indexOf("<!--StartFragment-->"),n=r.indexOf("<!--EndFragment-->");if(t!==-1&&n!==-1&&n>t)return r.slice(t+20,n);const a=r.match(/<body[^>]*>([\s\S]*)<\/body>/i);return a?a[1]:r},Rt=(r,t)=>t.test(r),ec=r=>Rt(r,/font-weight\s*:\s*(bold|[6-9]00)/i),rc=r=>Rt(r,/font-style\s*:\s*italic/i),tc=r=>Rt(r,/text-decoration(?:-line)?\s*:[^;]*underline/i),nc=r=>Rt(r,/text-decoration(?:-line)?\s*:[^;]*(line-through|linethrough)/i),en=(r,t)=>{var a;if(!r.childNodes.length||r.childNodes.length===1&&((a=r.firstChild)==null?void 0:a.nodeType)===Node.ELEMENT_NODE&&r.firstChild.tagName.toLowerCase()===t)return;const n=r.ownerDocument.createElement(t);for(;r.firstChild;)n.appendChild(r.firstChild);r.appendChild(n)},rn=r=>{const t=r.parentNode;if(!t){r.remove();return}for(;r.firstChild;)t.insertBefore(r.firstChild,r);t.removeChild(r)},ac=r=>{const t=r.getAttribute("class")??"",n=r.getAttribute("style")??"";return/mso-list/i.test(n)||/MsoListParagraph/i.test(t)||/MsoList/i.test(t)},vo=r=>{const t=r.getAttribute("style")??"",n=r.textContent??"";return/mso-level-number-format\s*:\s*(decimal|arabic|roman|alpha)/i.test(t)||/^\s*\d+[.)]\s/.test(n)||/^\s*[a-zA-Z][.)]\s/.test(n)?"ol":"ul"},oc=r=>{const n=r.ownerDocument.createTreeWalker(r,NodeFilter.SHOW_TEXT).nextNode();if(!n||!n.textContent)return;const a=n.textContent.replace(Ji,"").replace(/^\s*\d+[.)]\s+/,"").replace(/^\s*[a-zA-Z][.)]\s+/,"");a!==n.textContent&&(n.textContent=a)},sc=r=>{const t=Array.from(r.querySelectorAll("span, font, p, div, li, h1, h2, h3, h4"));t.sort((n,a)=>a.querySelectorAll("*").length-n.querySelectorAll("*").length),t.forEach(n=>{const a=n.getAttribute("style")??"";a&&(ec(a)&&en(n,"strong"),rc(a)&&en(n,"em"),tc(a)&&en(n,"u"),nc(a)&&en(n,"s"))})},lc=r=>{const t=Array.from(r.querySelectorAll("p, div")).filter(ac);if(!t.length)return;let n=0;for(;n<t.length;){const a=t[n],s=vo(a),l=[a];let i=n+1;for(;i<t.length;){const f=t[i];if(vo(f)!==s)break;let p=l[l.length-1].nextSibling;for(;p&&p.nodeType===Node.TEXT_NODE&&!(p.textContent??"").trim();)p=p.nextSibling;if(p!==f)break;l.push(f),i++}const c=a.parentNode;if(!c){n=i;continue}const u=a.ownerDocument.createElement(s);c.insertBefore(u,a),l.forEach(f=>{oc(f);const p=f.ownerDocument.createElement("li");for(;f.firstChild;)p.appendChild(f.firstChild);u.appendChild(p),f.remove()}),n=i}},ic=r=>r==="h1"?"h2":r==="h4"||r==="h5"||r==="h6"?"h3":r==="div"?"p":r,cc=r=>{const t=Ri(r.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>${t}</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()),sc(s),lc(s);const l=i=>{const c=Array.from(i.childNodes);if(i.nodeType===Node.ELEMENT_NODE){const u=i,f=u.tagName.toLowerCase();if(f==="html"||f==="body"){c.forEach(l);return}if(f==="font"){rn(u),c.forEach(l);return}if(!Qi.has(f)){rn(u),c.forEach(l);return}const p=ic(f);if(p!==f){const b=u.ownerDocument.createElement(p);for(;u.firstChild;)b.appendChild(u.firstChild);u.replaceWith(b),l(b);return}if(Array.from(u.attributes).forEach(b=>{const m=b.name.toLowerCase(),v=b.value;if(m.startsWith("on")||m==="style"||m==="class"){u.removeAttribute(b.name);return}if(m==="lang"||m.startsWith("data-")||m.startsWith("mso-")){u.removeAttribute(b.name);return}if((m==="href"||m==="src")&&/^\s*javascript:/i.test(v)){u.removeAttribute(b.name);return}f!=="a"&&f!=="img"&&m!=="href"&&m!=="src"&&m!=="alt"&&(["href","src","alt","target","rel"].includes(m)||u.removeAttribute(b.name))}),f==="a"){const b=u.getAttribute("href");if(!b||/^\s*#/.test(b)&&b.length<2){rn(u),c.forEach(l);return}u.setAttribute("target","_blank"),u.setAttribute("rel","noopener noreferrer"),u.classList.add("rich-link")}if(f==="img"){const b=u.getAttribute("src")??"";if(!b||/^\s*javascript:/i.test(b)||/^file:/i.test(b)||/scheme\s*=\s*["']?file/i.test(b)){u.remove();return}u.classList.add("rich-img"),Array.from(u.attributes).forEach(m=>{["src","alt","class"].includes(m.name.toLowerCase())||u.removeAttribute(m.name)})}if(f==="span"){rn(u),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(),u=i.querySelector("img, hr"),f=!c&&!u&&Array.from(i.childNodes).every(p=>p.nodeType===Node.TEXT_NODE||p.nodeType===Node.ELEMENT_NODE&&p.tagName.toLowerCase()==="br");(!c&&!u||f)&&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 u=c;for(;u.firstChild;)i.appendChild(u.firstChild);u.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()},Rn=r=>kt(r).replace(/\r\n?/g,`
|
|
25
|
-
`).split(/\n{2,}/).map(t=>`<p>${t.replace(/\n/g,"<br>")||"<br>"}</p>`).join(""),dc=r=>new RegExp("\\p{L}","u").test(r),ea=(r,t)=>{const n=r.trim();return!n||!dc(n)?!1:t==="uppercase"?n===n.toLocaleUpperCase():t==="lowercase"?n===n.toLocaleLowerCase():n===go(n)},xo=r=>{const t=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",ho())}(l=a.closest(".rich-img-wrap"))==null||l.classList.add("rich-img-broken")};r.querySelectorAll("img").forEach(a=>{if(!a.complete||a.naturalWidth===0){a.addEventListener("error",()=>t(a),{once:!0}),a.addEventListener("load",()=>{a.naturalWidth===0&&t(a)},{once:!0});const s=a.src;a.src="",a.src=s}});const n=a=>{const s=a.target;s.tagName==="IMG"&&t(s)};return r.addEventListener("error",n,!0),()=>r.removeEventListener("error",n,!0)};function yo({value:r,onChange:t,placeholder:n="Escribe algo...",minHeight:a="80px",instanceId:s}){const l=o.useId(),i=s||l,c=o.useCallback(()=>document,[]),u=o.useRef(null),f=o.useRef(null),p=o.useRef(new Map),b=o.useRef(null),m=o.useRef(!1),v=o.useRef(r??""),y=o.useRef(t),S=o.useRef(!1),[h,H]=o.useState(()=>!r||r.trim()===""),[_,E]=o.useState(new Set),[L,N]=o.useState(null),[k,K]=o.useState(""),[P,q]=o.useState(""),[X,J]=o.useState(""),[C,te]=o.useState(""),[j,W]=o.useState(!1),ae=o.useCallback(()=>m.current?f.current:u.current,[]);o.useEffect(()=>{y.current=t},[t]);const Z=o.useCallback(()=>{const I=window.getSelection(),Y=ae();if(!I||!Y||I.rangeCount===0||I.isCollapsed)return"";const ue=I.getRangeAt(0);return!Y.contains(ue.startContainer)||!Y.contains(ue.endContainer)?"":I.toString()},[ae]);o.useEffect(()=>{const I=r??"";if(S.current&&I===v.current){S.current=!1,H(!I||I.trim()==="");return}S.current=!1,v.current=I;const Y=[u.current,f.current].filter(be=>!!be);Y.forEach(be=>{be.innerHTML!==I&&(be.innerHTML=I)}),H(!I||I.trim()==="");const ue=Y.map(be=>xo(be));return()=>ue.forEach(be=>be())},[r]),o.useEffect(()=>{var be,De;m.current=j;let I,Y=0,ue;if(j){const Ce=u.current;Ce&&(v.current=Ce.innerHTML);const Oe=()=>{var Ve;const $e=f.current;if(!$e){Y=requestAnimationFrame(Oe);return}$e.innerHTML!==v.current&&($e.innerHTML=v.current),I=xo($e),H(((Ve=$e.textContent)==null?void 0:Ve.trim())===""),ue=setTimeout(()=>$e.focus(),60)};Y=requestAnimationFrame(Oe)}else{const Ce=f.current,Oe=u.current,$e=(Ce==null?void 0:Ce.innerHTML)??v.current,Ve=v.current;v.current=$e,Oe&&Oe.innerHTML!==$e&&(Oe.innerHTML=$e),$e!==Ve&&y.current($e),H(((De=(be=Ce??Oe)==null?void 0:be.textContent)==null?void 0:De.trim())==="")}return()=>{Y&&cancelAnimationFrame(Y),ue&&clearTimeout(ue),I==null||I()}},[j]);const $=o.useCallback(()=>{const I=["bold","italic","underline","strikeThrough","insertUnorderedList","insertOrderedList","justifyLeft","justifyCenter","justifyRight","justifyFull"],Y=new Set;I.forEach(be=>{try{c().queryCommandState(be)&&Y.add(be)}catch{return}});try{const be=Zi(c().queryCommandValue("formatBlock"));be&&Y.add(`formatBlock:${be}`)}catch{}const ue=Z();ea(ue,"uppercase")&&Y.add("__upper"),ea(ue,"lowercase")&&Y.add("__lower"),ea(ue,"capitalize")&&Y.add("__cap"),E(Y)},[Z,c]),ee=()=>{var Y;const I=ae();I&&(v.current=I.innerHTML,S.current=!0,y.current(v.current),H(((Y=I.textContent)==null?void 0:Y.trim())===""))},se=I=>{if(!I){const Y=u.current;Y&&(v.current=Y.innerHTML)}W(!I)},M=(I,Y)=>{var ue;(ue=ae())==null||ue.focus(),c().execCommand(I,!1,Y),ee(),$()},O=I=>{M("formatBlock",I)},oe=()=>{var I;(I=ae())==null||I.focus(),c().execCommand("insertHTML",!1,"<hr><p><br></p>"),ee(),$()},A=()=>{const I=window.getSelection();I&&I.rangeCount>0&&(b.current=I.getRangeAt(0).cloneRange())},U=()=>{const I=window.getSelection();I&&b.current&&(I.removeAllRanges(),I.addRange(b.current))},ne=I=>{if(A(),I==="link"){const Y=window.getSelection();q(Y&&!Y.isCollapsed?Y.toString():""),K("")}I==="image"&&(J(""),te("")),N(I)},ie=()=>{var be;if(!k.trim())return;U(),(be=ae())==null||be.focus();const I=window.getSelection(),ue=(I&&!I.isCollapsed?I.toString():"")||P.trim()||k.trim();c().execCommand("insertHTML",!1,`<a href="${kt(k.trim())}" target="_blank" rel="noopener noreferrer" class="rich-link">${kt(ue)}</a>`),ee(),N(null)},Q=(I,Y="")=>`<span class="rich-img-wrap" contenteditable="false"><img src="${kt(I)}" alt="${kt(Y)}" class="rich-img" />${ho()}</span>`,V=()=>{var I;X.trim()&&(U(),(I=ae())==null||I.focus(),c().execCommand("insertHTML",!1,Q(X.trim(),C.trim())),ee(),N(null))},w=(I,Y=1200,ue=1200,be=.72)=>new Promise((De,Ce)=>{const Oe=new FileReader;Oe.onerror=Ce,Oe.onload=$e=>{var bn;const Ve=(bn=$e.target)==null?void 0:bn.result,He=new Image;He.onerror=Ce,He.onload=()=>{let{width:Ke,height:_e}=He;if(Ke>Y||_e>ue){const ir=Math.min(Y/Ke,ue/_e);Ke=Math.round(Ke*ir),_e=Math.round(_e*ir)}const Xe=document.createElement("canvas");Xe.width=Ke,Xe.height=_e;const Dr=Xe.getContext("2d");if(!Dr){De(Ve);return}Dr.drawImage(He,0,0,Ke,_e),De(Xe.toDataURL("image/jpeg",be))},He.src=Ve},Oe.readAsDataURL(I)}),R=I=>{I.focus();const Y=window.getSelection();if(!Y||Y.rangeCount===0||!I.contains(Y.anchorNode)){const ue=document.createRange();ue.selectNodeContents(I),ue.collapse(!1),Y==null||Y.removeAllRanges(),Y==null||Y.addRange(ue)}},B=o.useRef(()=>{});B.current=I=>{const Y=ae();Y&&(R(Y),c().execCommand("insertHTML",!1,I),Y.querySelectorAll("p").forEach(ue=>{!(ue.textContent??"").replace(/[\u00a0\s]+/g,"")&&!ue.querySelector("img, hr")&&ue.remove()}),ee(),$())};const re=o.useRef(w);re.current=w;const F=o.useRef(Q);F.current=Q;const le=o.useCallback(I=>{if(!I||p.current.has(I))return;const Y=ue=>{const be=ue.clipboardData;if(!be)return;const De=be.getData("text/html"),Ce=be.getData("text/plain");if(De||Ce){ue.preventDefault(),ue.stopPropagation();try{const He=De?cc(De):Rn(Ce);if(!He){Ce&&B.current(Rn(Ce));return}B.current(He)}catch{Ce&&B.current(Rn(Ce))}return}const $e=Array.from(be.items).find(He=>He.type.startsWith("image/"));if(!$e)return;ue.preventDefault(),ue.stopPropagation();const Ve=$e.getAsFile();Ve&&re.current(Ve).then(He=>{B.current(F.current(He,"imagen"))})};I.addEventListener("paste",Y,!0),p.current.set(I,()=>{I.removeEventListener("paste",Y,!0),p.current.delete(I)})},[]),Ee=o.useCallback(I=>{var ue;const Y=u.current;Y&&Y!==I&&((ue=p.current.get(Y))==null||ue()),u.current=I,I&&le(I)},[le]),Le=o.useCallback(I=>{var ue;const Y=f.current;Y&&Y!==I&&((ue=p.current.get(Y))==null||ue()),f.current=I,I&&le(I)},[le]);o.useEffect(()=>{const I=p.current;return()=>{I.forEach(Y=>Y()),I.clear()}},[]);const xe=I=>{const Y=window.getSelection(),ue=ae();if(!Y||!ue||Y.rangeCount===0||Y.isCollapsed)return;const be=Y.getRangeAt(0);if(!ue.contains(be.startContainer)||!ue.contains(be.endContainer))return;const De=be.toString();if(!De)return;let Ce=De;I==="uppercase"?Ce=De.toLocaleUpperCase():I==="lowercase"?Ce=De.toLocaleLowerCase():Ce=go(De),be.deleteContents();const Oe=document.createTextNode(Ce);be.insertNode(Oe);const $e=document.createRange();$e.setStart(Oe,0),$e.setEnd(Oe,Ce.length),Y.removeAllRanges(),Y.addRange($e),b.current=$e.cloneRange(),ee(),$()},Se=()=>{A(),$()},Te=()=>{ee(),$()},kr=()=>{requestAnimationFrame(()=>{var I;(I=ae())==null||I.focus()})},pr=I=>{var Y,ue;if((I.metaKey||I.ctrlKey)&&I.key==="Enter"){if(I.preventDefault(),I.stopPropagation(),I.repeat)return;(Y=ae())==null||Y.focus(),c().execCommand("insertLineBreak",!1)||c().execCommand("insertHTML",!1,"<br>"),ee(),$();return}if(I.key==="Tab"){I.preventDefault(),(ue=ae())==null||ue.focus(),c().execCommand("insertText",!1," "),ee(),$();return}if(I.key==="Escape"){if(L){N(null);return}if(m.current){W(!1);return}}L||(I.ctrlKey||I.metaKey)&&(I.key==="b"&&(I.preventDefault(),M("bold")),I.key==="i"&&(I.preventDefault(),M("italic")),I.key==="u"&&(I.preventDefault(),M("underline")),I.key==="k"&&(I.preventDefault(),ne("link")))},qe=()=>e.jsx("div",{className:"h-4 w-px flex-shrink-0 mx-1",style:{background:"var(--border)"}}),ce=(I,Y,ue,be,De)=>{const Ce=De??(_.has(ue)||ue==="__link"&&L==="link"||ue==="__img"&&L==="image");return e.jsx("button",{type:"button",title:Y,tabIndex:-1,onFocus:kr,onMouseDown:Oe=>{Oe.preventDefault(),be?be():M(ue)},className:"flex h-7 w-7 items-center justify-center rounded text-xs font-bold transition-colors",style:{color:Ce?"var(--primary)":"var(--text-secondary)",background:Ce?"rgba(59,130,246,0.12)":"transparent"},children:I},ue)},Qe=I=>{const Y=I.target;if(Y.closest("[data-action='delete-img']")){I.preventDefault();const ue=Y.closest(".rich-img-wrap");ue&&(ue.remove(),ee())}},lr=I=>e.jsxs(e.Fragment,{children:[L==="link"&&e.jsxs("div",{className:"flex flex-shrink-0 flex-wrap items-center gap-2 border-t px-3 py-2",style:{borderColor:"var(--border)",background:I},children:[e.jsx("input",{autoFocus:!0,type:"url",value:k,onChange:Y=>K(Y.target.value),onKeyDown:Y=>{Y.key==="Enter"&&(Y.preventDefault(),ie()),Y.key==="Escape"&&N(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)"}}),e.jsx("input",{type:"text",value:P,onChange:Y=>q(Y.target.value),onKeyDown:Y=>{Y.key==="Enter"&&(Y.preventDefault(),ie()),Y.key==="Escape"&&N(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)"}}),e.jsx("button",{type:"button",onClick:ie,className:"rounded px-2.5 py-1 text-xs font-semibold text-white",style:{background:"var(--primary)"},children:"OK"}),e.jsx("button",{type:"button",onClick:()=>N(null),className:"rounded px-2 py-1 text-xs",style:{color:"var(--text-muted)"},children:"x"})]}),L==="image"&&e.jsxs("div",{className:"flex flex-shrink-0 flex-wrap items-center gap-2 border-t px-3 py-2",style:{borderColor:"var(--border)",background:I},children:[e.jsx("input",{autoFocus:!0,type:"url",value:X,onChange:Y=>J(Y.target.value),onKeyDown:Y=>{Y.key==="Enter"&&(Y.preventDefault(),V()),Y.key==="Escape"&&N(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)"}}),e.jsx("input",{type:"text",value:C,onChange:Y=>te(Y.target.value),onKeyDown:Y=>{Y.key==="Enter"&&(Y.preventDefault(),V()),Y.key==="Escape"&&N(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)"}}),e.jsx("button",{type:"button",onClick:V,className:"rounded px-2.5 py-1 text-xs font-semibold text-white",style:{background:"var(--primary)"},children:"OK"}),e.jsx("button",{type:"button",onClick:()=>N(null),className:"rounded px-2 py-1 text-xs",style:{color:"var(--text-muted)"},children:"x"})]})]}),fe=(I,Y)=>e.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:Y},children:[ce(e.jsx(T.HiArrowUturnLeft,{className:"h-4 w-4"}),"Deshacer","undo"),ce(e.jsx(T.HiArrowUturnRight,{className:"h-4 w-4"}),"Rehacer","redo"),qe(),ce(e.jsx("span",{style:{fontSize:"10px"},children:"P"}),"Parrafo","__paragraph",()=>O("p"),_.has("formatBlock:p")||_.has("formatBlock:div")),ce(e.jsx(T.HiH2,{className:"h-4 w-4"}),"Titulo 2","__h2",()=>O("h2"),_.has("formatBlock:h2")),ce(e.jsx(T.HiH3,{className:"h-4 w-4"}),"Titulo 3","__h3",()=>O("h3"),_.has("formatBlock:h3")),ce(e.jsx("span",{style:{fontSize:"13px",lineHeight:1},children:"“"}),"Cita","__quote",()=>O("blockquote"),_.has("formatBlock:blockquote")),qe(),ce(e.jsx("b",{children:"B"}),"Negrita (Ctrl+B)","bold"),ce(e.jsx("i",{children:"I"}),"Cursiva (Ctrl+I)","italic"),ce(e.jsx("u",{children:"U"}),"Subrayado (Ctrl+U)","underline"),ce(e.jsx("s",{children:"S"}),"Tachado","strikeThrough"),qe(),ce(e.jsx(T.HiListBullet,{className:"h-4 w-4"}),"Lista sin orden","insertUnorderedList"),ce(e.jsx(T.HiNumberedList,{className:"h-4 w-4"}),"Lista numerada","insertOrderedList"),ce(e.jsx(T.HiArrowTurnUpLeft,{className:"h-4 w-4"}),"Disminuir sangria","outdent"),ce(e.jsx(T.HiArrowTurnDownRight,{className:"h-4 w-4"}),"Aumentar sangria","indent"),qe(),ce(e.jsx(T.HiBars3BottomLeft,{className:"h-4 w-4"}),"Alinear izquierda","justifyLeft"),ce(e.jsx(T.HiBars3CenterLeft,{className:"h-4 w-4"}),"Centrar","justifyCenter"),ce(e.jsx(T.HiBars3BottomRight,{className:"h-4 w-4"}),"Alinear derecha","justifyRight"),ce(e.jsx(T.HiBars3,{className:"h-4 w-4"}),"Justificar","justifyFull"),qe(),ce(e.jsx("span",{style:{fontSize:"10px"},children:"AA"}),"Mayusculas","__upper",()=>xe("uppercase")),ce(e.jsx("span",{style:{fontSize:"10px"},children:"aa"}),"Minusculas","__lower",()=>xe("lowercase")),ce(e.jsx("span",{style:{fontSize:"10px"},children:"Aa"}),"Capitalizar","__cap",()=>xe("capitalize")),qe(),ce(e.jsx(T.HiLink,{className:"h-4 w-4"}),"Insertar enlace (Ctrl+K)","__link",()=>ne("link")),ce(e.jsx(T.HiLinkSlash,{className:"h-4 w-4"}),"Quitar enlace","unlink"),ce(e.jsx(T.HiPhoto,{className:"h-4 w-4"}),"Insertar imagen","__img",()=>ne("image")),ce(e.jsx(T.HiMinus,{className:"h-4 w-4"}),"Insertar separador","__divider",oe),qe(),ce(e.jsx(T.HiOutlinePaintBrush,{className:"h-4 w-4"}),"Limpiar formato","removeFormat"),ce(e.jsx(T.HiNoSymbol,{className:"h-4 w-4"}),"Quitar bloque","__clearBlock",()=>O("p")),qe(),e.jsx("button",{type:"button",title:I?"Salir del modo de enfoque (Esc)":"Modo de enfoque",tabIndex:-1,onFocus:kr,onMouseDown:ue=>{ue.preventDefault(),se(I)},className:"flex h-7 w-7 items-center justify-center rounded transition-colors",style:{color:"var(--text-secondary)"},children:I?e.jsx(T.HiArrowsPointingIn,{className:"h-4 w-4"}):e.jsx(T.HiArrowsPointingOut,{className:"h-4 w-4"})})]});return e.jsxs(e.Fragment,{children:[e.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:[e.jsx("div",{ref:Ee,contentEditable:!0,suppressContentEditableWarning:!0,"data-bonsaif-rich-instance":i,onInput:Te,onKeyDown:pr,onKeyUp:Se,onSelect:Se,onMouseUp:Se,onMouseDown:Qe,"data-placeholder":n,className:`rich-editor px-3 py-2 text-sm focus:outline-none${h?" is-empty":""}`,style:{color:"var(--text-main)",background:"var(--bg-input)",minHeight:a,maxHeight:"320px",overflowY:"auto",lineHeight:"1.6"}}),lr("var(--bg-input)"),fe(!1,"var(--bg-input)")]}),e.jsxs(qn,{open:j,onClose:()=>W(!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:[e.jsx("div",{ref:Le,contentEditable:!0,suppressContentEditableWarning:!0,"data-bonsaif-rich-instance":i,onInput:Te,onKeyDown:pr,onKeyUp:Se,onSelect:Se,onMouseUp:Se,onMouseDown:Qe,"data-placeholder":n,className:`rich-editor min-h-0 flex-1 overflow-y-auto px-8 py-6 text-sm focus:outline-none${h?" is-empty":""}`,style:{color:"var(--text-main)",background:"var(--bg-card)",lineHeight:"1.75"}}),lr("var(--bg-input)"),fe(!0,"var(--bg-input)")]})]})}const wo="[a-zA-Z0-9._@-]+",ra=new RegExp(`@(${wo})`,"g"),uc=/[a-zA-Z0-9._@-]/,Nt=new Set([" ",`
|
|
26
|
-
`," ","\r"," ","(","[","{",".",",",";",":","!","?","¿","¡",")","]","}",'"',"'","«","»","/","\\","|","-","—","–"]);function ko(r,t){if(t<=0)return!0;const n=r[t-1]??"";return Nt.has(n)}function No(r,t,n){var a;if(t<0||t>r.length)return null;for(let s=t-1;s>=0;s-=1){if(r[s]!=="@"){const c=r[s]??"";if(Nt.has(c)||!
|
|
23
|
+
</body></html>`,de=window.open("","_blank");de&&(de.document.write(K),de.document.close())}const Bn=()=>!pr||!Bt?null:er.createPortal(e.jsxs("div",{ref:ha,role:"menu",className:"overflow-hidden rounded-lg border p-1 shadow-xl",style:{...eu,position:"fixed",zIndex:9999,minWidth:170,borderColor:"var(--border)",background:"var(--bg-card)"},children:[e.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:()=>{Du(),vn(!1)},children:[e.jsx(T.HiTableCells,{className:"h-4 w-4 shrink-0 text-emerald-500"}),"Descargar CSV / Excel"]}),e.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:()=>{Iu(),vn(!1)},children:[e.jsx(T.HiDocumentText,{className:"h-4 w-4 shrink-0 text-red-500"}),"Imprimir / PDF"]})]}),document.body),On=()=>{const d=Q&&mr.trim().length>0,g=Le!=null&&Le.length?Le:d?[{key:"bql",label:"BQL",value:mr}]:[],D=Ee.filter(x=>{const K=x.trim();return K?!new Set(Dt.split(`
|
|
24
|
+
`).map(pe=>pe.trim()).filter(Boolean)).has(K):!1}).slice(0,8);return!H&&va===0&&!Q&&!pr?null:e.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:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[va>0&&e.jsxs("button",{type:"button",onClick:bu,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:[e.jsx(T.HiXMark,{className:"h-3.5 w-3.5"}),va," filtros"]}),Q&&e.jsxs("div",{ref:pa,className:"relative flex min-w-0 flex-1 items-center gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>{if(hr){Br(!1);return}En(),Br(!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:hr?"var(--primary)":d?"color-mix(in srgb, var(--primary) 12%, transparent)":"var(--bg-card)",borderColor:hr||d?"var(--primary)":"var(--border)",color:hr?"var(--primary-fg)":"var(--primary)"},"aria-expanded":hr,title:"Abrir filtros BQL",children:[e.jsx(T.HiCommandLine,{className:"h-3.5 w-3.5"}),"BQL",d&&e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-current"}),hr?e.jsx(T.HiChevronUp,{className:"h-3.5 w-3.5"}):e.jsx(T.HiChevronDown,{className:"h-3.5 w-3.5"})]}),e.jsx("span",{className:"hidden truncate text-xs text-[var(--text-muted)] sm:inline",children:B}),g.length>0&&e.jsxs("div",{className:"hidden min-w-0 items-center gap-1.5 overflow-hidden lg:flex",children:[g.slice(0,3).map(x=>e.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:[e.jsxs("span",{className:"text-[var(--text-muted)]",children:[x.label,":"]}),e.jsx("span",{className:"truncate",children:x.value})]},x.key)),g.length>3&&e.jsxs("span",{className:"text-xs text-[var(--text-muted)]",children:["+",g.length-3]})]}),d&&e.jsx("button",{type:"button","aria-label":"Limpiar BQL",title:"Limpiar BQL",onClick:Ls,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:e.jsx(T.HiXMark,{className:"h-4 w-4"})}),hr&&er.createPortal(e.jsxs("div",{ref:ms,className:"flex flex-col gap-3 rounded-lg p-3 shadow-2xl",style:{...Zd,background:"var(--bg-card)",border:"1px solid color-mix(in srgb, var(--primary) 35%, var(--border))"},children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[z.map(x=>e.jsxs("button",{type:"button",onMouseDown:K=>{K.preventDefault(),K.stopPropagation()},onClick:K=>{K.preventDefault(),K.stopPropagation(),Cn(x.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:[x.icon,x.label]},x.label)),le.length>0&&e.jsxs("button",{type:"button",onClick:()=>tt(x=>!x),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":bs,children:[e.jsx(T.HiInformationCircle,{className:"h-3.5 w-3.5"}),"Ejemplos"]}),It.length>0&&e.jsxs("button",{type:"button",onClick:()=>nt(x=>!x),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":ps,children:[e.jsx(T.HiClock,{className:"h-3.5 w-3.5"}),"Historial"]})]}),e.jsxs("div",{className:"overflow-hidden rounded-lg",style:{background:"var(--bg-input)",border:`1.5px solid ${xe?"var(--danger)":d?"var(--primary)":"var(--border)"}`},children:[e.jsx("textarea",{ref:ma,value:Dt,rows:3,onChange:x=>ya(x.target.value,x.target),onKeyDown:x=>{x.key==="Enter"&&!x.shiftKey&&(x.preventDefault(),Ms(Dt)),x.key==="Escape"&&Br(!1)},placeholder:te,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"}}),D.length>0&&e.jsx("div",{className:"border-t border-[var(--border)] bg-[var(--bg-card)]",children:D.map(x=>e.jsx("button",{type:"button",onMouseDown:K=>{K.preventDefault(),K.stopPropagation()},onClick:K=>{K.preventDefault(),K.stopPropagation(),Cn(x)},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:x},x))})]}),e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[e.jsx("span",{className:"min-w-0 text-xs",style:{color:xe?"var(--danger)":"var(--text-muted)"},children:xe??(d?`${g.length||1} filtro${(g.length||1)===1?"":"s"} activo${(g.length||1)===1?"":"s"}`:"Enter aplica la consulta. Shift + Enter agrega linea.")}),g.map(x=>e.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:[e.jsxs("span",{className:"text-[var(--text-muted)]",children:[x.label,":"]}),e.jsx("span",{className:"truncate",children:x.value})]},x.key))]}),ps&&It.length>0&&e.jsxs("div",{className:"overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-input)]",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-[var(--border)] px-3 py-2",children:[e.jsxs("span",{className:"flex items-center gap-1.5 text-xs font-semibold text-[var(--text-secondary)]",children:[e.jsx(T.HiClock,{className:"h-3.5 w-3.5"}),"Historial"]}),e.jsxs("button",{type:"button",onClick:()=>{at([]),nt(!1)},className:"inline-flex items-center gap-1 rounded px-2 py-0.5 text-xs text-[var(--text-muted)]",children:[e.jsx(T.HiTrash,{className:"h-3 w-3"}),"Limpiar"]})]}),It.map(x=>e.jsxs("div",{className:"group flex items-center gap-2 border-b border-[var(--border)] px-3 py-2 last:border-b-0",children:[e.jsx("button",{type:"button",onMouseDown:K=>{K.preventDefault(),K.stopPropagation()},onClick:K=>{K.preventDefault(),K.stopPropagation(),Cn(x)},className:"min-w-0 flex-1 text-left",children:e.jsx("code",{className:"block truncate text-xs text-[var(--primary)]",children:x})}),e.jsx("button",{type:"button",onClick:()=>at(K=>K.filter(de=>de!==x)),className:"rounded p-1 text-[var(--text-muted)] opacity-0 transition-opacity group-hover:opacity-100",children:e.jsx(T.HiXMark,{className:"h-3.5 w-3.5"})})]},x))]}),bs&&le.length>0&&e.jsx("div",{className:"grid gap-2 sm:grid-cols-2 lg:grid-cols-3",children:le.map(x=>e.jsxs("button",{type:"button",onMouseDown:K=>{K.preventDefault(),K.stopPropagation()},onClick:K=>{K.preventDefault(),K.stopPropagation(),Cn(x.bql),tt(!1)},className:"rounded-lg border border-[var(--border)] bg-[var(--bg-input)] p-2 text-left transition-colors hover:border-[var(--primary)]",children:[e.jsx("code",{className:"block truncate text-xs text-[var(--primary)]",children:x.bql}),x.description&&e.jsx("span",{className:"mt-1 block text-xs text-[var(--text-muted)]",children:x.description})]},x.bql))}),e.jsxs("div",{className:"flex items-center justify-end gap-2 border-t border-[var(--border)] pt-3",children:[d&&e.jsxs("button",{type:"button",onClick:Ls,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:[e.jsx(T.HiXMark,{className:"h-3.5 w-3.5"}),"Limpiar"]}),e.jsxs("button",{type:"button",onClick:()=>Ms(Dt),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:[e.jsx(T.HiCheck,{className:"h-3.5 w-3.5"}),"Aplicar"]})]})]}),document.body)]})]}),pr&&e.jsx("button",{ref:xn,type:"button","aria-haspopup":"menu","aria-expanded":Bt,"aria-label":"Exportar datos",title:"Exportar datos",onClick:()=>{var K;const x=(K=xn.current)==null?void 0:K.getBoundingClientRect();x&&ru({top:x.bottom+4,right:window.innerWidth-x.right}),vn(de=>!de)},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)] ${Bt?"bg-[var(--bg-card)] text-[var(--primary)]":""}`,children:e.jsx(T.HiArrowDownTray,{className:"h-4 w-4"})}),H&&e.jsx("button",{type:"button","aria-haspopup":"menu","aria-expanded":Xe&&ir==="visibility","aria-label":ie,title:ie,onClick:x=>$s(x,"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)] ${Xe&&ir==="visibility"?"bg-[var(--bg-card)] text-[var(--primary)]":""}`,children:e.jsx(T.HiCog6Tooth,{className:"h-4 w-4"})})]})},Ws=()=>{if(!Mu)return null;const d=Yl(We,Ea);return e.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 ${$?"px-2 py-0.5":"px-3 py-1"}`,style:{borderColor:"var(--border)",background:"var(--bg-input)"},children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{style:{color:"var(--text-muted)"},children:jr===0?"0 filas":`${Lu}–${Tu} de ${jr}`}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{style:{color:"var(--text-muted)"},children:"Filas:"}),e.jsx(Lr,{value:String(ur),onChange:g=>$u(Number(g)),options:Ds.map(g=>({value:String(g),label:String(g)})),placeholder:"Filas",searchable:!1,disabled:a,height:U,padding:V,className:"shrink-0 [&>button]:rounded-md [&>button]:text-xs [&_svg]:h-3.5 [&_svg]:w-3.5",style:{width:F}})]})]}),e.jsxs("div",{className:"flex items-center justify-center gap-0.5",children:[e.jsx("button",{disabled:a||We<=1,onClick:()=>Ma(We-1),onMouseEnter:g=>{g.currentTarget.disabled||(g.currentTarget.style.background="color-mix(in srgb, var(--primary) 14%, var(--bg-card))",g.currentTarget.style.color="var(--primary)")},onMouseLeave:g=>{g.currentTarget.style.background="transparent",g.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:e.jsx(T.HiChevronLeft,{className:"h-3.5 w-3.5"})}),d.map((g,D)=>g==="..."?e.jsx("span",{className:"px-1",style:{color:"var(--text-muted)"},children:"…"},`e${D}`):e.jsx("button",{disabled:a,onClick:()=>Ma(g),onMouseEnter:x=>{x.currentTarget.disabled||g===We||(x.currentTarget.style.background="color-mix(in srgb, var(--primary) 14%, var(--bg-card))",x.currentTarget.style.color="var(--primary)")},onMouseLeave:x=>{x.currentTarget.style.background=g===We?"var(--primary)":"transparent",x.currentTarget.style.color=g===We?"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:g===We?"var(--primary)":"transparent",color:g===We?"var(--primary-fg)":"var(--text-muted)"},children:g},g)),e.jsx("button",{disabled:a||We>=Ea,onClick:()=>Ma(We+1),onMouseEnter:g=>{g.currentTarget.disabled||(g.currentTarget.style.background="color-mix(in srgb, var(--primary) 14%, var(--bg-card))",g.currentTarget.style.color="var(--primary)")},onMouseLeave:g=>{g.currentTarget.style.background="transparent",g.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:e.jsx(T.HiChevronRight,{className:"h-3.5 w-3.5"})})]}),e.jsx("div",{"aria-hidden":"true"})]})},Bu=()=>e.jsxs("div",{className:"w-full min-w-0 max-w-full flex flex-col rounded-lg overflow-hidden",style:{background:"var(--bg-card)",boxShadow:Tn},children:[Dn(),Bn(),On(),e.jsx("div",{ref:Nr,className:"min-w-0 max-w-full overflow-hidden",children:e.jsxs("div",{role:"table",className:"text-sm",style:{width:Pt,minWidth:$n},children:[e.jsx("div",{role:"rowgroup",style:N?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:An()}),e.jsx("div",{role:"rowgroup",children:Array.from({length:Math.min(6,s)}).map((d,g)=>e.jsxs("div",{role:"row",className:"grid",style:{gridTemplateColumns:dt,borderBottom:`1px solid ${Me}`},children:[fr&&e.jsx("div",{role:"cell",className:`${$?"px-2 py-1.5":"px-3 py-2"} w-10`,style:{borderBottom:`1px solid ${Me}`,borderRight:`1px solid ${Me}`}},"select-cell"),Re.map((D,x)=>e.jsx("div",{role:"cell",className:$?"px-2 py-1.5":"px-3 py-2",style:{borderBottom:`1px solid ${Me}`,borderRight:`1px solid ${Me}`},children:e.jsx("div",{className:"h-3.5 rounded-full animate-pulse",style:{background:"var(--border)",width:`${xs(g,x)}%`,minWidth:32}})},D.key))]},g))})]})})]}),Ta="min-w-0 max-w-full overflow-hidden";return j&&Qe&&!ue?e.jsx(jt,{rows:s,columns:Math.max(4,Re.length||7)}):!a&&t.length===0&&!ga?Bu():a&&t.length===0?e.jsxs("div",{className:"w-full min-w-0 max-w-full flex flex-col rounded-lg overflow-hidden",style:{background:"var(--bg-card)",boxShadow:Tn},children:[Dn(),Bn(),On(),e.jsx("div",{ref:Nr,className:Ta,children:e.jsx(Aa.OverlayScrollbarsComponent,{options:{scrollbars:{autoHide:"leave",autoHideDelay:200}},className:"w-full",style:{maxHeight:ws,maxWidth:"100%"},defer:!0,children:e.jsxs("div",{role:"table",className:"text-sm",style:{width:Pt,minWidth:$n},children:[e.jsx("div",{role:"rowgroup",style:N?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:An()}),e.jsx("div",{role:"rowgroup",children:Array.from({length:s}).map((d,g)=>e.jsxs("div",{role:"row",className:"grid",style:{gridTemplateColumns:dt,borderBottom:`1px solid ${Me}`},children:[fr&&e.jsx("div",{role:"cell",className:`${$?"px-2 py-1.5":"px-3 py-2"} w-10`,style:{borderBottom:`1px solid ${Me}`,borderRight:`1px solid ${Me}`}},"select-cell"),Re.map((D,x)=>{const K=Mn[D.key],de=K!==void 0,pe=D.key===Ca;return e.jsx("div",{role:"cell","data-dt-column-key":D.key,className:$?"px-2 py-1.5":"px-3 py-2",style:de?{position:"sticky",left:K,zIndex:1,background:"color-mix(in srgb, var(--bg-card) 72%, transparent)",backdropFilter:"blur(10px)",WebkitBackdropFilter:"blur(10px)",boxShadow:pe?`3px 0 6px -2px rgba(0,0,0,0.10), inset 0 -1px 0 ${Me}`:`inset 0 -1px 0 ${Me}`,borderRight:`1px solid ${Me}`}:{borderBottom:`1px solid ${Me}`,borderRight:`1px solid ${Me}`},children:e.jsx("div",{className:"h-3.5 rounded-full animate-pulse",style:{background:"var(--border)",width:`${xs(g,x)}%`,minWidth:32}})},D.key)})]},g))})]})})}),Ws()]}):!a&&t.length===0?e.jsxs("div",{className:"w-full min-w-0 max-w-full flex flex-col rounded-lg overflow-hidden",style:{background:"var(--bg-card)",boxShadow:Tn},children:[Dn(),Bn(),On(),e.jsx("div",{ref:Nr,className:Ta,children:e.jsx("div",{role:"table",className:"text-sm",style:{width:Pt,minWidth:$n},children:e.jsx("div",{role:"rowgroup",style:N?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:An()})})}),e.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:Me,background:"linear-gradient(180deg, color-mix(in srgb, var(--bg-input) 58%, transparent), var(--bg-card))"},children:[e.jsx("div",{className:"flex h-12 w-12 items-center justify-center rounded-full border",style:{borderColor:"color-mix(in srgb, var(--primary) 24%, var(--border))",background:"color-mix(in srgb, var(--primary) 8%, var(--bg-card))",color:"var(--primary)"},children:l??e.jsx(T.HiMagnifyingGlass,{className:"h-5 w-5"})}),e.jsx("p",{className:"max-w-sm text-sm font-medium",style:{color:"var(--text-main)"},children:i}),e.jsx("span",{className:"text-xs",style:{color:"var(--text-muted)"},children:"Ajusta la busqueda o cambia los filtros para ver mas informacion."})]})]}):e.jsxs("div",{className:"w-full min-w-0 max-w-full flex flex-col rounded-lg overflow-hidden",style:{background:"var(--bg-card)",boxShadow:Tn},children:[Dn(),Bn(),On(),e.jsx("div",{ref:Nr,className:Ta,children:e.jsx(Aa.OverlayScrollbarsComponent,{options:{scrollbars:{autoHide:"leave",autoHideDelay:200}},className:"w-full",style:{maxHeight:ws,maxWidth:"100%"},defer:!0,children:e.jsxs("div",{role:"table",className:"text-sm",style:{width:Pt,minWidth:$n},children:[e.jsx("div",{role:"rowgroup",style:N?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:An()}),e.jsx("div",{role:"rowgroup",children:Bs.map((d,g)=>{const D=n(d),x=zs(L==null?void 0:L(d)),K=g>0?zs(L==null?void 0:L(Bs[g-1])):null,de=x&&x.key!==(K==null?void 0:K.key),pe=fr&&S.has(D),we=ct?(p==null?void 0:p(d))??!0:!1,je=we&&Is.has(D),ze=!!u||y&&we,Ue=pe&&O?"color-mix(in srgb, var(--primary) 8%, var(--bg-card))":g%2===1?"color-mix(in srgb, var(--bg-input) 30%, var(--bg-card))":"var(--bg-card)";return e.jsxs(o.Fragment,{children:[de&&e.jsx("div",{role:"row",className:`grid ${x.className??""}`,style:{gridTemplateColumns:dt},children:e.jsx("div",{role:"cell",className:$?"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 ${Me}`,borderRight:`1px solid ${Me}`},children:e.jsx("div",{className:"flex min-w-0 items-center justify-between gap-3",children:e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate text-xs font-semibold uppercase tracking-wider text-[var(--text-main)]",children:x.label}),x.description&&e.jsx("div",{className:"mt-0.5 truncate text-xs text-[var(--text-muted)]",children:x.description})]})})})}),e.jsxs("div",{role:"row",onClick:ze?ke=>{const ye=ke.target;if(!(ye!=null&&ye.closest('[data-dt-disable-row-click="true"]'))){if(y&&we){Os(D);return}u==null||u(d)}}:void 0,className:`grid transition-colors ${ze?"cursor-pointer":""} ${E?E(d):""}`,style:{gridTemplateColumns:dt,"--dt-row-bg":Ue,"--dt-sticky-bg":Ue,background:"var(--dt-row-bg)",borderBottom:`1px solid ${Me}`},onMouseEnter:ke=>{pe||(ke.currentTarget.style.setProperty("--dt-row-bg","var(--bg-hover)"),ke.currentTarget.style.setProperty("--dt-sticky-bg",Au))},onMouseLeave:ke=>{ke.currentTarget.style.setProperty("--dt-row-bg",Ue),ke.currentTarget.style.setProperty("--dt-sticky-bg",Ue)},children:[ct&&e.jsx("div",{role:"cell",className:`${$?"px-2 py-1.5":"px-3 py-2"} flex w-10 items-center justify-center`,style:{borderBottom:`1px solid ${Me}`,borderRight:`1px solid ${Me}`},"data-dt-disable-row-click":"true",children:we&&e.jsx("button",{type:"button","aria-label":je?"Contraer fila":"Desplegar fila","aria-expanded":je,onClick:ke=>{ke.stopPropagation(),Os(D)},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:je?e.jsx(T.HiChevronDown,{className:"h-4 w-4"}):e.jsx(T.HiChevronRight,{className:"h-4 w-4"})})}),fr&&e.jsx("div",{role:"cell",className:`${$?"px-2 py-1.5":"px-3 py-2"} w-10`,style:Na?{position:"sticky",left:0,zIndex:3,background:"var(--dt-sticky-bg)",boxShadow:`inset 0 -1px 0 ${Me}`}:{borderBottom:`1px solid ${Me}`,borderRight:`1px solid ${Me}`},onClick:ke=>{ke.stopPropagation(),h(D)},children:e.jsx(Wt,{size:"sm",checked:pe,"aria-label":"Seleccionar fila",containerClassName:"items-center",className:"cursor-pointer",onClick:ke=>ke.stopPropagation(),onChange:()=>h(D)})}),Re.map(ke=>{const ye=Mn[ke.key],Ne=ye!==void 0,he=ke.key===Ca,me=Tr(ke);return e.jsx("div",{role:"cell","data-dt-column-key":ke.key,"data-dt-disable-row-click":ke.disableRowClick||me?"true":void 0,className:`${me?"px-2 py-1.5 text-center":`${$?"px-2 py-1.5":"px-3 py-2"} ${Hs(ke.align)}`} ${ql} ${ke.className??""}`,style:{overflow:"hidden",whiteSpace:"nowrap",...Ne?{position:"sticky",left:ye,zIndex:3,background:"var(--dt-sticky-bg)",boxShadow:he?`3px 0 6px -2px rgba(0,0,0,0.10), inset 0 -1px 0 ${Me}`:`inset 0 -1px 0 ${Me}`,borderRight:`1px solid ${Me}`}:{borderBottom:`1px solid ${Me}`,borderRight:`1px solid ${Me}`}},children:e.jsx(Qa,{children:e.jsx("div",{"data-dt-autofit-content":!0,className:"inline-block max-w-none align-middle",children:ke.cell(d)})})},ke.key)})]}),je&&f&&e.jsx("div",{role:"row",className:"grid",style:{gridTemplateColumns:dt},children:e.jsx("div",{role:"cell",className:$?"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 ${Me}`},children:f(d)})})]},D)})})]})})}),Ws()]})}const Jl={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 Rl(r,t){if(t.minLength!==void 0&&r.length<t.minLength)return t.message??`Mínimo ${t.minLength} caracteres`;if(t.maxLength!==void 0&&r.length>t.maxLength)return t.message??`Máximo ${t.maxLength} caracteres`;if(!r)return null;if(t.preset){const n=Jl[t.preset];if(!n.pattern.test(r))return t.message??n.message}return t.pattern&&!t.pattern.test(r)?t.message??"Formato inválido":null}const ei=new Set(["Backspace","Delete","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Tab","Home","End","Enter","Escape"]);function ri({initialValue:r,type:t,mask:n,onCommit:a,onCancel:s}){const[l,i]=o.useState(r),c=o.useRef(null),u=(n==null?void 0:n.preset)==="date",f=u?"date":t==="number"?"number":"text";return o.useEffect(()=>{var p,b;(p=c.current)==null||p.focus(),u||(b=c.current)==null||b.select()},[u]),e.jsx("input",{ref:c,type:f,value:l,maxLength:n==null?void 0:n.maxLength,onChange:p=>i(p.target.value),onBlur:()=>s(),onKeyDown:p=>{p.key==="Enter"&&(p.preventDefault(),a(l)),p.key==="Escape"&&(p.preventDefault(),s()),(n==null?void 0:n.preset)==="integer"&&!p.ctrlKey&&!p.metaKey&&!ei.has(p.key)&&!/^[\d-]$/.test(p.key)&&p.preventDefault()},onClick:p=>p.stopPropagation(),className:"w-full min-w-0 border-0 bg-transparent p-0 text-sm text-[var(--text-main)] outline-none"})}function ti({initialValue:r,options:t,loading:n,onCommit:a,onCancel:s}){const l=o.useRef(null);return o.useEffect(()=>{if(n)return;const i=setTimeout(()=>{var c,u;(u=(c=l.current)==null?void 0:c.querySelector("button"))==null||u.click()},0);return()=>clearTimeout(i)},[n]),e.jsx("div",{ref:l,className:"w-full",tabIndex:-1,onKeyDown:i=>{i.key==="Escape"&&(i.stopPropagation(),s())},children:e.jsx(Lr,{value:r,onChange:i=>{a(i)},options:t,disabled:n,placeholder:n?"Cargando…":"Seleccionar…",triggerVariant:"ghost",height:30,padding:"0 6px",minOptionsForSearch:1,className:"w-full"})})}const ni={outline:"2px solid var(--primary)",outlineOffset:"-2px",borderRadius:"4px",background:"color-mix(in srgb, var(--primary) 5%, var(--bg-card))"},Kn={outline:"2px solid var(--primary)",outlineOffset:"-2px",borderRadius:"4px"};function ai({columns:r,data:t,getRowId:n,onCellUpdate:a,readOnly:s=!1,...l}){const[i,c]=o.useState(t),u=o.useRef(null);o.useEffect(()=>{u.current||c(t)},[t]);const[f,p]=o.useState(null);u.current=f;const[b,m]=o.useState(null),v=o.useRef(null);v.current=b;const[y,S]=o.useState({}),[h,P]=o.useState(null),O=o.useRef(null);O.current=h;const[E,L]=o.useState({}),[N,k]=o.useState({}),Y=o.useRef(new Set),F=o.useRef(null);o.useEffect(()=>{var H;const M=document.activeElement;(!M||M===document.body)&&((H=F.current)==null||H.focus({preventScroll:!0}))},[]);const U=r.map(M=>{var H,oe,A;return`${M.key}:${((A=(oe=(H=M.editable)==null?void 0:H.select)==null?void 0:oe.options)==null?void 0:A.length)??-1}`}).join("|");o.useEffect(()=>{r.forEach(M=>{var A,q;const H=(q=(A=M.editable)==null?void 0:A.select)==null?void 0:q.options;if(!H)return;const oe=E[M.key];(!Y.current.has(M.key)||(oe==null?void 0:oe.length)===0&&H.length>0)&&(Y.current.add(M.key),L(ne=>({...ne,[M.key]:H})))})},[U]);const V=o.useCallback(async(M,H)=>{if(Y.current.has(M))return;Y.current.add(M);const{url:oe,fetchOptions:A}=H.select??{};if(!(!oe&&!A)){k(q=>({...q,[M]:!0}));try{let q=[];if(A)q=await A();else if(oe){const ne=await fetch(oe);if(!ne.ok)throw new Error("fetch failed");q=await ne.json()}L(ne=>({...ne,[M]:q}))}catch{L(q=>({...q,[M]:[]}))}finally{k(q=>({...q,[M]:!1}))}}},[]),J=o.useRef(i);J.current=i;const C=o.useRef(a);C.current=a;const re=o.useRef(n);re.current=n;const W=o.useRef(r);W.current=r;const j=o.useRef(s);j.current=s,o.useEffect(()=>{if(r.length>0&&t.length>0){const M=r.find(H=>H.selectable!==!1);M&&m({rowId:n(t[0]),colKey:M.key})}},[]),o.useEffect(()=>{if(!b)return;const M=F.current;if(!M)return;const H=M.querySelector(`[data-cell-id="${b.rowId}:${b.colKey}"]`);if(!H)return;const oe=M.querySelector('[role="rowgroup"]');H.style.scrollMarginTop=`${(oe==null?void 0:oe.offsetHeight)??0}px`;const A=M.querySelector('[role="row"]');let q=0;A&&A.querySelectorAll('[role="cell"], [role="columnheader"]').forEach(ne=>{ne.style.position==="sticky"&&ne.style.left!==""&&(q=Math.max(q,parseFloat(ne.style.left)+ne.offsetWidth))}),H.style.scrollMarginLeft=`${q}px`,H.scrollIntoView({block:"nearest",inline:"nearest"})},[b]);const ae=o.useCallback(M=>{var q;const H=W.current,oe=new Set,A=[];(q=F.current)==null||q.querySelectorAll("[data-cell-id]").forEach(ne=>{const ie=ne.dataset.cellId.split(":")[0];oe.has(ie)||(oe.add(ie),A.push(ie))}),m(ne=>{if(!ne)return ne;const ie=H.findIndex(R=>R.key===ne.colKey),Q=A.indexOf(ne.rowId);let G=ie,w=Q;if(M==="up")w=Math.max(0,Q-1);else if(M==="down")w=Math.min(A.length-1,Q+1);else if(M==="left"){let R=ie-1;for(;R>=0&&H[R].selectable===!1;)R--;R>=0&&(G=R)}else if(M==="right"){let R=ie+1;for(;R<H.length&&H[R].selectable===!1;)R++;R<H.length&&(G=R)}return G===ie&&w===Q?ne:{rowId:A[w],colKey:H[G].key}})},[]),Z=o.useCallback((M=!0)=>{const H=u.current;p(null),H&&m(H),M&&setTimeout(()=>{var oe;return(oe=F.current)==null?void 0:oe.focus({preventScroll:!0})},0)},[]),$=o.useCallback(async(M,H,oe)=>{var Le;const A=W.current.find(xe=>xe.key===H);if(!(A!=null&&A.editable))return;const{field:q,type:ne,mask:ie,validate:Q}=A.editable,G=ne==="number"?oe===""?null:Number(oe):oe;if(ie){const xe=Rl(oe,ie);if(xe){S(Se=>({...Se,[`${M}:${H}`]:xe}));return}}if(Q){const xe=Q(G);if(xe){S(Se=>({...Se,[`${M}:${H}`]:xe}));return}}const w=re.current,R=J.current.find(xe=>w(xe)===M);if(!R)return;const B=R[q];p(null),S(xe=>{const Se={...xe};return delete Se[`${M}:${H}`],Se});const te=J.current,z=te.findIndex(xe=>w(xe)===M),le=te[Math.min(te.length-1,z+1)];if(m({rowId:w(le),colKey:H}),setTimeout(()=>{var Se,Te;const xe=document.activeElement;(!xe||xe===document.body||(Se=F.current)!=null&&Se.contains(xe))&&((Te=F.current)==null||Te.focus({preventScroll:!0}))},0),String(B??"")===String(G??""))return;const Ee={...R,[q]:G};c(xe=>xe.map(Se=>w(Se)===M?Ee:Se)),P({rowId:M,colKey:H});try{await((Le=C.current)==null?void 0:Le.call(C,{row:R,rowId:M,field:q,oldValue:B,newValue:G}))}catch{c(xe=>xe.map(Se=>w(Se)===M?R:Se)),S(xe=>({...xe,[`${M}:${H}`]:"Error al guardar. Intenta de nuevo."}))}finally{P(null)}},[]),ee=o.useCallback(M=>{if(O.current){M.preventDefault();return}if(u.current)return;const H=v.current;if(!(!H||!["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Enter","Escape","Tab"].includes(M.key)))switch(M.preventDefault(),M.key){case"ArrowUp":ae("up");break;case"ArrowDown":ae("down");break;case"ArrowLeft":ae("left");break;case"ArrowRight":ae("right");break;case"Tab":ae(M.shiftKey?"left":"right");break;case"Enter":{const A=W.current.find(q=>q.key===H.colKey);A!=null&&A.editable&&!j.current?(p(H),A.editable.type==="select"&&!Y.current.has(H.colKey)&&V(H.colKey,A.editable)):ae("down");break}}},[ae,V]),se=o.useMemo(()=>r.map(M=>{if(!M.editable||s){const oe={...M};if(delete oe.editable,delete oe.selectable,M.selectable===!1)return{...oe,disableRowClick:!0};const A=oe.cell;return{...oe,className:`relative ${oe.className??""}`.trim(),disableRowClick:!0,cell:q=>{const ne=n(q),ie=(b==null?void 0:b.rowId)===ne&&(b==null?void 0:b.colKey)===M.key;return e.jsxs(e.Fragment,{children:[e.jsx("span",{"data-cell-id":`${ne}:${M.key}`,className:"absolute inset-0 z-10 cursor-default",onClick:()=>{var Q;O.current||(m({rowId:ne,colKey:M.key}),(Q=F.current)==null||Q.focus({preventScroll:!0}))}}),ie&&e.jsx("div",{className:"pointer-events-none absolute inset-0 z-20",style:Kn}),e.jsx("span",{className:"relative z-0 pointer-events-none",children:A(q)})]})}}}const H=M.editable;return{...M,className:`relative ${M.className??""}`.trim(),disableRowClick:!0,cell:oe=>{const A=n(oe),q=M.key,ne=(f==null?void 0:f.rowId)===A&&(f==null?void 0:f.colKey)===q,ie=(b==null?void 0:b.rowId)===A&&(b==null?void 0:b.colKey)===q,Q=y[`${A}:${q}`],G=(h==null?void 0:h.rowId)===A&&(h==null?void 0:h.colKey)===q,w=oe[H.field],R=String(w??""),B=()=>{var z;O.current||(m({rowId:A,colKey:q}),p({rowId:A,colKey:q}),(z=F.current)==null||z.focus({preventScroll:!0}),H.type==="select"&&!Y.current.has(q)&&V(q,H))};if(ne){const z=H.type==="select"?e.jsx(ti,{initialValue:R,options:E[q]??[],loading:N[q]??!1,onCommit:le=>$(A,q,le),onCancel:Z}):e.jsx(ri,{initialValue:R,type:H.type??"text",mask:H.mask,onCommit:le=>$(A,q,le),onCancel:Z});return e.jsx("div",{className:"absolute inset-0 flex items-center px-2",style:ni,onClick:le=>le.stopPropagation(),children:z})}const te=M.cell(oe);return e.jsxs(e.Fragment,{children:[e.jsx("span",{"data-cell-id":`${A}:${q}`,className:`peer absolute inset-0 z-10 ${G?"cursor-wait":"cursor-pointer"}`,onClick:B}),ie&&!G&&e.jsx("div",{className:"pointer-events-none absolute inset-0 z-20",style:Kn}),G&&e.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:Kn,children:[e.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}),e.jsx("span",{className:"truncate text-xs text-[var(--text-muted)]",children:"Guardando…"})]}),e.jsx("span",{className:"relative z-0 inline-flex items-center gap-1 pointer-events-none",children:Q?e.jsxs("span",{className:"flex items-center gap-1 text-red-500",children:[e.jsx(T.HiExclamationCircle,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"truncate text-xs",children:Q})]}):e.jsx("span",{className:"truncate",children:te})}),!G&&e.jsx(T.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"})]})}}}),[r,s,f,b,h,y,E,N,n,$,Z,V]);return e.jsx("div",{ref:F,tabIndex:0,onKeyDown:ee,onBlur:M=>{var H;(H=F.current)!=null&&H.contains(M.relatedTarget)||setTimeout(()=>{var A,q;const oe=document.activeElement;oe&&((A=oe.closest)!=null&&A.call(oe,"[data-bonsaif-select-dropdown]"))||(q=F.current)!=null&&q.contains(oe)||Z(!1)},0)},style:{width:"100%",minWidth:0,outline:"none"},children:e.jsx(Ja,{...l,columns:se,data:i,getRowId:n})})}function wt(r){return r?new Date(`${r}T12:00:00`):void 0}function Ra(r){return r.toISOString().slice(0,10)}function oi({calendarMonth:r,displayIndex:t}){const{previousMonth:n,nextMonth:a,goToMonth:s,months:l,labels:i,formatters:c}=Da.useDayPicker(),u=!!n&&t===0,f=!!a&&t===l.length-1;return e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",gap:8,width:"100%",color:"var(--text-main)",marginBottom:6},children:[e.jsx("span",{style:{fontWeight:700},children:c.formatCaption(r.date)}),e.jsx("button",{type:"button","aria-label":i.labelPrevious(n),onClick:()=>n&&s(n),disabled:!u,style:{height:28,width:28,borderRadius:8,border:"1px solid var(--border)",background:"var(--bg-card)",display:"inline-flex",alignItems:"center",justifyContent:"center",color:"var(--text-main)",opacity:u?1:.45,cursor:u?"pointer":"not-allowed"},children:e.jsx(T.HiChevronLeft,{size:16})}),e.jsx("button",{type:"button","aria-label":i.labelNext(a),onClick:()=>a&&s(a),disabled:!f,style:{height:28,width:28,borderRadius:8,border:"1px solid var(--border)",background:"var(--bg-card)",display:"inline-flex",alignItems:"center",justifyContent:"center",color:"var(--text-main)",opacity:f?1:.45,cursor:f?"pointer":"not-allowed"},children:e.jsx(T.HiChevronRight,{size:16})})]})}function si(r){return r.charAt(0).toUpperCase()+r.slice(1)}function li({startDate:r,endDate:t,onChange:n,minDate:a,viewMonth:s,numberOfMonths:l=1,showSummary:i=!0,startLabel:c="Inicio",endLabel:u="Regreso"}){const f={from:wt(r),to:wt(t)},p=wt(a),[b,m]=o.useState(wt(s||r));return o.useEffect(()=>{m(wt(s||r))},[s,r]),e.jsxs("div",{children:[e.jsx("div",{style:{borderRadius:10,overflow:"hidden",border:"1px solid var(--border)",background:"var(--bg-input)",display:"flex",justifyContent:"center",padding:"10px 8px"},children:e.jsx(Da.DayPicker,{mode:"range",selected:f,month:b,onMonthChange:m,onSelect:v=>{const y=v!=null&&v.from?Ra(v.from):r,S=v!=null&&v.to?Ra(v.to):"";n({startDate:y,endDate:S})},numberOfMonths:l,hideNavigation:!0,disabled:p?{before:p}:void 0,showOutsideDays:!1,components:{MonthCaption:oi},className:"text-sm",classNames:{root:"w-full",months:"flex gap-3 justify-center",month:"space-y-2",month_caption:"flex items-center justify-between px-1",caption_label:"capitalize",nav:"flex items-center gap-1",button_previous:"h-8 w-8 inline-flex items-center justify-center rounded-md transition-colors",button_next:"h-8 w-8 inline-flex items-center justify-center rounded-md transition-colors",month_grid:"w-full border-collapse",weekdays:"grid grid-cols-7 gap-1 mb-1",weekday:"text-[11px] font-semibold text-center",week:"grid grid-cols-7 gap-1",day:"h-9 w-9 p-0 flex items-center justify-center",day_button:"h-9 w-9 rounded-md text-sm font-medium transition-colors outline-none",selected:"font-semibold",range_start:"font-semibold",range_middle:"font-medium",range_end:"font-semibold",today:"font-bold",disabled:"opacity-40 cursor-not-allowed",hidden:"invisible"},styles:{month_caption:{color:"var(--text-main)",marginBottom:6,display:"flex",alignItems:"center",justifyContent:"space-between"},caption_label:{color:"var(--text-main)",fontWeight:700},nav:{position:"static",display:"flex",alignItems:"center",gap:6},weekday:{color:"var(--text-muted)",textTransform:"lowercase"},button_previous:{height:32,width:32,background:"var(--bg-card)",color:"var(--text-main)",border:"1px solid var(--border)"},button_next:{height:32,width:32,background:"var(--bg-card)",color:"var(--text-main)",border:"1px solid var(--border)"},day_button:{color:"var(--text-main)",borderRadius:8},chevron:{fill:"var(--text-main)"},today:{border:"1px solid color-mix(in srgb, var(--primary) 35%, transparent)"},disabled:{color:"var(--text-muted)"}},modifiersStyles:{selected:{background:"var(--primary)",color:"var(--primary-fg, #ffffff)"},range_start:{background:"var(--primary)",color:"var(--primary-fg, #ffffff)"},range_end:{background:"var(--primary)",color:"var(--primary-fg, #ffffff)"},range_middle:{background:"color-mix(in srgb, var(--primary) 20%, transparent)",color:"var(--text-main)"}},formatters:{formatCaption:v=>si(new Intl.DateTimeFormat("es-MX",{month:"long",year:"numeric"}).format(v)),formatWeekdayName:v=>new Intl.DateTimeFormat("es-MX",{weekday:"short"}).format(v)},labels:{labelMonthDropdown:()=>"Mes",labelYearDropdown:()=>"Año"}})}),i&&r&&e.jsxs("div",{style:{marginTop:8,fontSize:12,color:"var(--text-muted)",display:"flex",gap:8,flexWrap:"wrap"},children:[e.jsxs("span",{children:[c,":"," ",e.jsx("strong",{style:{color:"var(--text-main)"},children:r})]}),t&&e.jsxs("span",{children:[u,":"," ",e.jsx("strong",{style:{color:"var(--text-main)"},children:t})]})]})]})}const ii="bonsaif-ui:hide-tooltips";function eo(){window.dispatchEvent(new CustomEvent(ii))}function ci(r){if(r!==void 0)return typeof r=="number"?`${r}px`:r}function di({trigger:r,items:t,align:n="end",width:a=220,disabled:s=!1,className:l="",menuClassName:i="",onOpenChange:c}){const[u,f]=o.useState(!1),[p,b]=o.useState(!1),[m,v]=o.useState({}),y=o.useRef(null),S=o.useRef(null),h=o.useCallback(N=>{f(N),c==null||c(N)},[c]),P=o.useCallback(()=>{const N=y.current;if(!N)return;const k=N.getBoundingClientRect(),Y=typeof a=="number"?a:k.width,F=typeof a=="number"?a:Math.max(k.width,180),U=n==="end"?Math.max(8,k.right-F):Math.min(k.left,window.innerWidth-F-8),V=window.innerHeight-k.bottom,J=V<240&&k.top>V?void 0:k.bottom+6,C=J===void 0?window.innerHeight-k.top+6:void 0;v({position:"fixed",zIndex:9999,left:U,top:J,bottom:C,width:ci(typeof a=="number"?Y:a)})},[n,a]);o.useEffect(()=>b(!0),[]),o.useEffect(()=>{if(!u)return;P();const N=Y=>{var U,V;const F=Y.target;!((U=y.current)!=null&&U.contains(F))&&!((V=S.current)!=null&&V.contains(F))&&h(!1)},k=Y=>{Y.key==="Escape"&&h(!1)};return document.addEventListener("mousedown",N),window.addEventListener("keydown",k),window.addEventListener("resize",P),window.addEventListener("scroll",P,!0),()=>{document.removeEventListener("mousedown",N),window.removeEventListener("keydown",k),window.removeEventListener("resize",P),window.removeEventListener("scroll",P,!0)}},[u,h,P]);const O=N=>{s||(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),h(!u))},E=o.isValidElement(r)?o.cloneElement(r,{onClick:()=>{s||(eo(),h(!u))}}):r,L=u?e.jsx("div",{ref:S,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:m,children:t.map(N=>e.jsxs("div",{children:[N.separatorBefore&&e.jsx("div",{className:"my-1 border-t border-[var(--border)]"}),e.jsxs("button",{type:"button",role:"menuitem",disabled:N.disabled,onClick:()=>{var k;N.disabled||(eo(),(k=N.onSelect)==null||k.call(N),h(!1))},className:"flex w-full min-w-0 items-start gap-2 rounded-md px-2.5 py-1.5 text-left transition-colors hover:bg-[var(--bg-input)] disabled:cursor-not-allowed disabled:opacity-50",style:{color:N.danger?"var(--danger)":"var(--text-main)"},children:[N.icon&&e.jsx("span",{className:"mt-0.5 shrink-0",children:N.icon}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block truncate text-sm font-medium",children:N.label}),N.description&&e.jsx("span",{className:"block truncate text-xs text-[var(--text-muted)]",children:N.description})]})]})]},N.id))}):null;return e.jsxs("span",{ref:y,role:"button",tabIndex:s?-1:0,"aria-haspopup":"menu","aria-expanded":u,onKeyDown:O,className:`inline-flex ${s?"pointer-events-none opacity-60":""} ${l}`,children:[E,p&&L?er.createPortal(L,document.body):null]})}const ui=180,ro="bg-[color-mix(in_srgb,var(--bg-main)_72%,transparent)] backdrop-blur-sm";function fi({open:r,onClose:t,title:n,subtitle:a,leadingIcon:s,confirmLabel:l="Guardar",onConfirm:i,loading:c=!1,confirmDisabled:u=!1,headerActions:f,bodyClassName:p="flex-1 overflow-y-auto px-6 py-5",width:b=440,hasUnsavedChanges:m=!1,unsavedChangesTitle:v="Descartar cambios",unsavedChangesDescription:y="Hay cambios sin guardar. Si cierras el drawer se perderán.",unsavedChangesConfirmLabel:S="Descartar",unsavedChangesCancelLabel:h="Seguir editando",onDiscardChanges:P,disabled:O=!1,disabledMessage:E,children:L}){const[N,k]=o.useState(!1),[Y,F]=o.useState(!1),[U,V]=o.useState(!1),J=o.useCallback(()=>{F(!0),requestAnimationFrame(()=>{requestAnimationFrame(()=>V(!0))})},[]),C=o.useCallback(()=>{V(!1),window.setTimeout(()=>F(!1),ui)},[]),re=o.useCallback(()=>{if(!O){if(m){J();return}t()}},[O,m,t,J]),W=o.useCallback(()=>{V(!1),F(!1),P==null||P(),t()},[t,P]);if(o.useEffect(()=>{k(!0)},[]),o.useEffect(()=>(document.body.style.overflow=r?"hidden":"",r||(V(!1),F(!1)),()=>{document.body.style.overflow=""}),[r]),o.useEffect(()=>{if(!r)return;const ae=Z=>{if(Z.key==="Escape"&&!O){if(Y){C();return}re()}};return window.addEventListener("keydown",ae),()=>window.removeEventListener("keydown",ae)},[C,O,Y,r,re]),!N)return null;const j=E!==void 0?E:c?"Guardando…":null;return er.createPortal(e.jsxs("div",{"aria-hidden":!r,"data-bonsaif-overlay":r?"true":void 0,className:`fixed inset-0 z-[1000] flex transition-opacity duration-300 ${r?"opacity-100":"opacity-0 pointer-events-none"}`,children:[e.jsx("div",{className:`absolute inset-0 ${ro}`,onClick:re}),e.jsxs("div",{className:`absolute inset-y-0 right-0 flex flex-col shadow-2xl transition-transform duration-300 ${r?"translate-x-0":"translate-x-full"}`,style:{width:`min(100vw, ${b}px)`,background:"var(--bg-card)",borderLeft:"1px solid var(--border)"},children:[e.jsxs("div",{className:"flex items-center justify-between px-6 py-4 flex-shrink-0",style:{borderBottom:"1px solid var(--border)"},children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx(Fe,{variant:"icon",onClick:re,title:"Cerrar",disabled:O,children:e.jsx(T.HiXMark,{className:"w-5 h-5"})}),s&&e.jsx("div",{className:"flex-shrink-0",children:s}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h3",{className:"text-base font-semibold truncate",style:{color:"var(--text-main)"},children:n}),a&&e.jsx("p",{className:"text-xs truncate",style:{color:"var(--text-muted)"},children:a})]})]}),(f||i)&&e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[f,i&&e.jsxs(e.Fragment,{children:[e.jsx(Fe,{variant:"secondary",size:"sm",onClick:re,disabled:O,style:{background:"var(--bg-input)"},children:"Cancelar"}),e.jsx(Fe,{variant:"primary",size:"sm",icon:e.jsx(Vs.FiSave,{className:"w-4 h-4"}),onClick:i,loading:c,disabled:u||O,title:l})]})]})]}),e.jsx("div",{"data-drawer-scroll":"true",className:p,children:L}),O&&e.jsx("div",{className:"absolute inset-0 z-[1002] flex cursor-not-allowed items-center justify-center p-6",style:{background:"color-mix(in srgb, var(--bg-card, #ffffff) 72%, transparent)",backdropFilter:"blur(3px)"},role:"status","aria-live":"polite","aria-busy":"true",children:j?e.jsxs("div",{className:"flex max-w-xs flex-col items-center gap-3 text-center",children:[e.jsx("div",{className:"h-9 w-9 animate-spin rounded-full border-2 border-[var(--border)] border-t-[var(--primary)]","aria-hidden":!0}),e.jsx("p",{className:"text-sm font-semibold text-[var(--text-main)]",children:j})]}):null})]}),Y&&e.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":v,className:"fixed inset-0 z-[1001] flex items-center justify-center p-4",children:[e.jsx("div",{className:`absolute inset-0 ${ro} transition-opacity duration-200 ease-out ${U?"opacity-100":"opacity-0"}`,onClick:C}),e.jsxs("div",{className:`relative z-10 w-full max-w-sm rounded-2xl border p-6 shadow-2xl transition-[opacity,transform] duration-200 ease-out ${U?"translate-y-0 scale-100 opacity-100":"translate-y-2 scale-[0.96] opacity-0"}`,style:{background:"var(--bg-card, #ffffff)",borderColor:"var(--border, #d8e1dc)"},children:[e.jsx(Fe,{variant:"icon",onClick:C,className:"absolute right-3 top-3 h-7 w-7 hover:opacity-70",style:{color:"var(--text-muted, #6b7f78)"},"aria-label":h,children:e.jsx(T.HiXMark,{className:"h-4 w-4"})}),e.jsx("div",{className:"mb-4 flex h-11 w-11 items-center justify-center rounded-xl",style:{background:"var(--warning-bg, #fff7ed)"},children:e.jsx(T.HiExclamationTriangle,{className:"h-5 w-5",style:{color:"var(--warning, #d97706)"}})}),e.jsx("h2",{className:"mb-1 text-base font-semibold",style:{color:"var(--text-main, #0f2f2c)"},children:v}),e.jsx("p",{className:"text-sm",style:{color:"var(--text-muted, #6b7f78)"},children:y}),e.jsxs("div",{className:"mt-6 flex gap-2",children:[e.jsx(Fe,{variant:"secondary",onClick:C,className:"flex-1 border",style:{background:"var(--bg-input, #f7faf8)",borderColor:"var(--border, #d8e1dc)",color:"var(--text-main, #0f2f2c)"},children:h}),e.jsx(Fe,{variant:"secondary",onClick:W,className:"flex-1 border",style:{background:"var(--warning, #d97706)",borderColor:"transparent",color:"#fff",boxShadow:"0 10px 22px rgba(217, 119, 6, 0.22)"},children:S})]})]})]})]}),document.body)}const bi=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,pi=/^\+?[0-9\s().-]+$/,mi=7,hi=15;function or(r){return r==null||String(r).trim()===""}function to(r){return typeof r=="number"?r:typeof r=="string"&&r.trim()!==""?Number(r):Number.NaN}function Xn(r){return or(r)?!1:bi.test(String(r))}function Yn(r){if(or(r))return!1;const t=String(r),n=t.replace(/\D/g,"");return pi.test(t)&&n.length>=mi&&n.length<=hi}function gi(r="Este campo es requerido."){return t=>or(t)?r:void 0}function vi(r="Ingresa un correo valido."){return t=>or(t)||Xn(t)?void 0:r}function xi(r="Ingresa un telefono valido."){return t=>or(t)||Yn(t)?void 0:r}function yi(r,t){return n=>or(n)||String(n).length>=r?void 0:t??`Debe tener al menos ${r} caracteres.`}function wi(r,t){return n=>or(n)||String(n).length<=r?void 0:t??`Debe tener ${r} caracteres o menos.`}function ki(r,t){return n=>{if(or(n))return;const a=to(n);return Number.isFinite(a)&&a>=r?void 0:t??`Debe ser mayor o igual a ${r}.`}}function Ni(r,t){return n=>{if(or(n))return;const a=to(n);return Number.isFinite(a)&&a<=r?void 0:t??`Debe ser menor o igual a ${r}.`}}function Si(r,t="El formato no es valido."){return n=>or(n)||r.test(String(n))?void 0:t}function Ci(r,t){const n={};for(const a of Object.keys(t)){const s=t[a];if(!s)continue;const l=Array.isArray(s)?s:[s];for(const i of l){const c=i(r[a],r);if(c){n[a]=c;break}}}return{valid:Object.keys(n).length===0,errors:n}}var no={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},ao=o.createContext&&o.createContext(no),Ei=["attr","size","title"];function Mi(r,t){if(r==null)return{};var n,a,s=Li(r,t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(r);for(a=0;a<l.length;a++)n=l[a],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(r,n)&&(s[n]=r[n])}return s}function Li(r,t){if(r==null)return{};var n={};for(var a in r)if({}.hasOwnProperty.call(r,a)){if(t.indexOf(a)!==-1)continue;n[a]=r[a]}return n}function Yt(){return Yt=Object.assign?Object.assign.bind():function(r){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)({}).hasOwnProperty.call(n,a)&&(r[a]=n[a])}return r},Yt.apply(null,arguments)}function oo(r,t){var n=Object.keys(r);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(r);t&&(a=a.filter(function(s){return Object.getOwnPropertyDescriptor(r,s).enumerable})),n.push.apply(n,a)}return n}function Zt(r){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?oo(Object(n),!0).forEach(function(a){Ti(r,a,n[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(n)):oo(Object(n)).forEach(function(a){Object.defineProperty(r,a,Object.getOwnPropertyDescriptor(n,a))})}return r}function Ti(r,t,n){return(t=$i(t))in r?Object.defineProperty(r,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):r[t]=n,r}function $i(r){var t=Ai(r,"string");return typeof t=="symbol"?t:t+""}function Ai(r,t){if(typeof r!="object"||!r)return r;var n=r[Symbol.toPrimitive];if(n!==void 0){var a=n.call(r,t);if(typeof a!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(r)}function so(r){return r&&r.map((t,n)=>o.createElement(t.tag,Zt({key:n},t.attr),so(t.child)))}function Zn(r){return t=>o.createElement(Di,Yt({attr:Zt({},r.attr)},t),so(r.child))}function Di(r){var t=n=>{var{attr:a,size:s,title:l}=r,i=Mi(r,Ei),c=s||n.size||"1em",u;return n.className&&(u=n.className),r.className&&(u=(u?u+" ":"")+r.className),o.createElement("svg",Yt({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},n.attr,a,i,{className:u,style:Zt(Zt({color:r.color||n.color},n.style),r.style),height:c,width:c,xmlns:"http://www.w3.org/2000/svg"}),l&&o.createElement("title",null,l),r.children)};return ao!==void 0?o.createElement(ao.Consumer,null,n=>t(n)):t(no)}function lo(r){return Zn({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:[]}]})(r)}function Ii(r){return Zn({attr:{viewBox:"0 0 256 256",fill:"currentColor"},child:[{tag:"path",attr:{d:"M247.31,124.76c-.35-.79-8.82-19.58-27.65-38.41C194.57,61.26,162.88,48,128,48S61.43,61.26,36.34,86.35C17.51,105.18,9,124,8.69,124.76a8,8,0,0,0,0,6.5c.35.79,8.82,19.57,27.65,38.4C61.43,194.74,93.12,208,128,208s66.57-13.26,91.66-38.34c18.83-18.83,27.3-37.61,27.65-38.4A8,8,0,0,0,247.31,124.76ZM128,192c-30.78,0-57.67-11.19-79.93-33.25A133.47,133.47,0,0,1,25,128,133.33,133.33,0,0,1,48.07,97.25C70.33,75.19,97.22,64,128,64s57.67,11.19,79.93,33.25A133.46,133.46,0,0,1,231.05,128C223.84,141.46,192.43,192,128,192Zm0-112a48,48,0,1,0,48,48A48.05,48.05,0,0,0,128,80Zm0,80a32,32,0,1,1,32-32A32,32,0,0,1,128,160Z"},child:[]}]})(r)}function Bi(r){return Zn({attr:{viewBox:"0 0 256 256",fill:"currentColor"},child:[{tag:"path",attr:{d:"M228,175a8,8,0,0,1-10.92-3l-19-33.2A123.23,123.23,0,0,1,162,155.46l5.87,35.22a8,8,0,0,1-6.58,9.21A8.4,8.4,0,0,1,160,200a8,8,0,0,1-7.88-6.69l-5.77-34.58a133.06,133.06,0,0,1-36.68,0l-5.77,34.58A8,8,0,0,1,96,200a8.4,8.4,0,0,1-1.32-.11,8,8,0,0,1-6.58-9.21L94,155.46a123.23,123.23,0,0,1-36.06-16.69L39,172A8,8,0,1,1,25.06,164l20-35a153.47,153.47,0,0,1-19.3-20A8,8,0,1,1,38.22,99c16.6,20.54,45.64,45,89.78,45s73.18-24.49,89.78-45A8,8,0,1,1,230.22,109a153.47,153.47,0,0,1-19.3,20l20,35A8,8,0,0,1,228,175Z"},child:[]}]})(r)}function Kr({content:r,ariaLabel:t="Más información",className:n=""}){return e.jsx(Mr,{as:"span",content:r,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:e.jsx("span",{tabIndex:0,role:"img","aria-label":t,className:"inline-flex items-center justify-center outline-none",children:e.jsx(T.HiInformationCircle,{className:"h-3.5 w-3.5"})})})}function Xr({error:r,helperText:t,helperDisplay:n="inline"}){return r?e.jsx("span",{className:"text-xs font-medium normal-case text-[var(--danger)]",children:r}):t&&n!=="tooltip"?e.jsx("span",{className:"text-xs font-medium normal-case text-[var(--text-muted)]",children:t}):null}function Qt({className:r="",...t}){return e.jsx("input",{...t,className:`h-10 rounded-lg border border-[var(--border)] bg-[var(--bg-input)] px-2.5 py-1.5 text-sm text-[var(--text-main)] outline-none placeholder:text-[var(--text-muted)] transition-colors focus:border-[var(--primary)] ${r}`})}function Qn({label:r,containerClassName:t="",helperText:n,helperDisplay:a="inline",error:s,errorDisplay:l="inline",errorTooltipLabel:i="Error de validacion",labelAction:c,floatingLabel:u=!1,showPasswordToggle:f=!0,nativeValidation:p=!1,className:b="",required:m,...v}){const[y,S]=o.useState(()=>!!v.autoFocus),[h,P]=o.useState(!1),O=v.type==="password"&&f,E=O&&h?"text":v.type,L=!!s,N=L&&l!=="tooltip",k=L&&l!=="inline",Y=!!n&&a==="tooltip"&&!N,F=p?m:void 0,U=L?"border-[var(--danger)] focus:border-[var(--danger)]":"",V=k?O?"pr-20":"pr-10":O?"pr-10":"",J=v.value!==void 0?String(v.value).length>0:v.defaultValue!==void 0&&String(v.defaultValue).length>0,C=y||J,re={top:C?7:12,color:y?"var(--primary)":"var(--text-muted)",fontSize:C?10:13,fontWeight:C?600:400,textTransform:C?"uppercase":"none"},W=ee=>{var se;S(!0),(se=v.onFocus)==null||se.call(v,ee)},j=ee=>{var se;S(!1),(se=v.onBlur)==null||se.call(v,ee)},ae=O?e.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:()=>P(ee=>!ee),children:[e.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:e.jsx(Ii,{className:"h-[18px] w-[18px]"})}),e.jsx("span",{"aria-hidden":"true",className:`absolute inset-0 flex items-center justify-center transition-[opacity,transform] duration-200 ease-out ${h?"scale-y-100 rotate-0 opacity-100":"scale-y-0 rotate-[8deg] opacity-0"}`,children:e.jsx(Bi,{className:"h-[18px] w-[18px]"})})]}):null,Z=k?e.jsx(Mr,{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)] ${O?"right-10":"right-2.5"}`,children:e.jsx("span",{tabIndex:0,role:"img","aria-label":i,className:"flex h-full w-full items-center justify-center outline-none",children:e.jsx(lo,{className:"h-[18px] w-[18px]"})})}):null,$=e.jsx(Xr,{error:N?s:void 0,helperText:n,helperDisplay:a});return u?e.jsxs("label",{className:`flex flex-col gap-2 ${t}`,children:[e.jsxs("span",{className:"relative block",children:[e.jsx(Qt,{...v,type:E,required:F,placeholder:" ","aria-invalid":L||v["aria-invalid"],"data-has-value":J?"true":void 0,className:`h-11 w-full pt-5 ${V} ${U} ${b}`,onFocus:W,onBlur:j}),e.jsxs("span",{className:"pointer-events-none absolute left-3 transition-all duration-150",style:re,children:[r,m&&e.jsx("span",{className:"ml-1 text-[var(--danger)]",children:"*"})]}),c&&e.jsx("span",{className:"absolute right-2 transition-all duration-150",style:{top:C?7:12},children:c}),Z,ae]}),$]}):e.jsxs("label",{className:`flex flex-col gap-2 ${t}`,children:[e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-semibold uppercase text-[var(--text-muted)]",children:[e.jsx("span",{children:r}),m&&e.jsx("span",{className:"text-[var(--danger)]",children:"*"}),Y?e.jsx(Kr,{content:n}):null,c&&e.jsx("span",{className:"ml-auto normal-case",children:c})]}),O?e.jsxs("span",{className:"relative block",children:[e.jsx(Qt,{...v,type:E,required:F,"aria-invalid":L||v["aria-invalid"],className:`w-full ${V} ${U} ${b}`,onFocus:W,onBlur:j}),Z,ae]}):e.jsxs("span",{className:"relative block",children:[e.jsx(Qt,{...v,required:F,"aria-invalid":L||v["aria-invalid"],className:`w-full ${V} ${U} ${b}`}),Z]}),$]})}function io(r){return r==null?"":String(r)}function Oi({autoComplete:r="email",inputMode:t="email",validate:n=!0,invalidMessage:a="Ingresa un correo valido.",errorDisplay:s="tooltip",error:l,value:i,defaultValue:c,onChange:u,...f}){const[p,b]=o.useState(()=>io(c)),m=i!==void 0?io(i):p,v=n&&m.length>0&&!Xn(m)?a:void 0,y=S=>{i===void 0&&b(S.currentTarget.value),u==null||u(S)};return e.jsx(Qn,{...f,value:i,defaultValue:c,type:"text",inputMode:t,autoComplete:r,error:l??v,errorDisplay:s,onChange:y})}const Hi={sm:"min-h-[160px] p-4",md:"min-h-[220px] p-6",lg:"min-h-[300px] p-8"};function Pi({title:r="Sin resultados",description:t,icon:n=e.jsx(T.HiInbox,{className:"h-5 w-5"}),action:a,secondaryAction:s,size:l="md",className:i=""}){return e.jsx("div",{className:`flex items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-card)] text-center ${Hi[l]} ${i}`,children:e.jsxs("div",{className:"flex max-w-sm flex-col items-center gap-3",children:[n&&e.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-input)] text-[var(--text-muted)]",children:n}),e.jsxs("div",{className:"space-y-1",children:[r&&e.jsx("h3",{className:"text-sm font-semibold text-[var(--text-main)]",children:r}),t&&e.jsx("div",{className:"text-sm leading-5 text-[var(--text-muted)]",children:t})]}),(a||s)&&e.jsxs("div",{className:"mt-1 flex flex-wrap items-center justify-center gap-2",children:[s,a]})]})})}const Fi={sm:"min-h-[112px] p-4",md:"min-h-[148px] p-5",lg:"min-h-[184px] p-6"};function zi(r){if(r===0)return"0 B";const t=["B","KB","MB","GB"],n=Math.min(Math.floor(Math.log(r)/Math.log(1024)),t.length-1),a=r/1024**n;return`${a>=10||n===0?a.toFixed(0):a.toFixed(1)} ${t[n]}`}function co(r,t){return t?t.split(",").map(n=>n.trim().toLowerCase()).filter(Boolean).some(n=>{const a=r.name.toLowerCase(),s=r.type.toLowerCase();return n.startsWith(".")?a.endsWith(n):n.endsWith("/*")?s.startsWith(n.slice(0,-1)):s===n}):!0}function _i(r,t,n){return t?n===void 0?r:r.slice(0,Math.max(0,n)):r.slice(0,1)}function ji({label:r,helperText:t,helperDisplay:n="inline",error:a,labelAction:s,value:l,defaultValue:i=[],onFilesChange:c,onRejectedFiles:u,multiple:f=!1,maxFiles:p,appendFiles:b=!1,showFileList:m=!0,clearable:v=!0,browseLabel:y="Buscar archivos",dropLabel:S="Suelta los archivos aqui",emptyLabel:h="Arrastra y suelta archivos",emptyDescription:P="o haz click para buscarlos en tu equipo",selectedLabel:O="Archivos seleccionados",size:E="md",containerClassName:L="",dropzoneClassName:N="",fileListClassName:k="",className:Y="",id:F,accept:U,disabled:V,required:J,...C}){const re=o.useId(),W=F??re,j=o.useRef(null),[ae,Z]=o.useState(!1),[$,ee]=o.useState(i),se=l??$,M=!!a,H=!!t&&n==="tooltip"&&!M,oe=v&&se.length>0&&!V,A=(z,le)=>{l===void 0&&ee(z),c==null||c(z,le)},q=(z,le)=>{const Ee=z.filter(Te=>co(Te,U)),Le=z.filter(Te=>!co(Te,U)),xe=b?[...se,...Ee]:Ee,Se=_i(xe,f,p);Le.length>0&&(u==null||u(Le)),A(Se,le)},ne=()=>{var z;V||(z=j.current)==null||z.click()},ie=z=>{q(Array.from(z.target.files??[]),z),z.target.value=""},Q=z=>{z.preventDefault(),V||Z(!0)},G=z=>{z.currentTarget.contains(z.relatedTarget)||Z(!1)},w=z=>{z.preventDefault(),Z(!1),!V&&q(Array.from(z.dataTransfer.files),z)},R=z=>{z.key!=="Enter"&&z.key!==" "||(z.preventDefault(),ne())},B=z=>{A(se.filter((le,Ee)=>Ee!==z))},te=()=>{A([])};return e.jsxs("div",{className:`flex flex-col gap-2 ${L}`,children:[(r||s||H)&&e.jsxs("div",{className:"inline-flex items-center gap-1 text-xs font-semibold uppercase text-[var(--text-muted)]",children:[r&&e.jsx("span",{children:r}),J&&e.jsx("span",{className:"text-[var(--danger)]",children:"*"}),H?e.jsx(Kr,{content:t}):null,s&&e.jsx("span",{className:"ml-auto normal-case",children:s})]}),e.jsx("input",{...C,ref:j,id:W,type:"file",accept:U,multiple:f,disabled:V,required:J&&se.length===0,"aria-invalid":M||C["aria-invalid"],className:"sr-only",onChange:ie}),e.jsxs("div",{role:"button",tabIndex:V?-1:0,"aria-controls":W,"aria-disabled":V||void 0,"aria-invalid":M||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)] ${Fi[E]} ${ae?"border-[var(--primary)] bg-[var(--bg-input)]":M?"border-[var(--danger)]":"border-[var(--border)]"} ${V?"cursor-not-allowed opacity-60":"hover:border-[var(--primary)] hover:bg-[var(--bg-input)]"} ${N} ${Y}`,onClick:ne,onDragOver:Q,onDragLeave:G,onDrop:w,onKeyDown:R,children:[e.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:e.jsx(T.HiArrowUpTray,{className:"h-5 w-5"})}),e.jsxs("span",{className:"space-y-1",children:[e.jsx("span",{className:"block text-sm font-semibold text-[var(--text-main)]",children:ae?S:h}),P&&e.jsx("span",{className:"block text-sm text-[var(--text-muted)]",children:P})]}),y&&e.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:y})]}),m&&se.length>0&&e.jsxs("div",{className:`rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${k}`,children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-[var(--border)] px-3 py-2",children:[e.jsx("span",{className:"text-xs font-semibold uppercase text-[var(--text-muted)]",children:O}),oe&&e.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:te,children:e.jsx(T.HiTrash,{className:"h-4 w-4"})})]}),e.jsx("ul",{className:"divide-y divide-[var(--border)]",children:se.map((z,le)=>e.jsxs("li",{className:"flex items-center gap-3 px-3 py-2",children:[e.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:e.jsx(T.HiDocument,{className:"h-4 w-4"})}),e.jsxs("span",{className:"min-w-0 flex-1 text-left",children:[e.jsx("span",{className:"block truncate text-sm font-medium text-[var(--text-main)]",children:z.name}),e.jsx("span",{className:"block text-xs text-[var(--text-muted)]",children:zi(z.size)})]}),!V&&e.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:()=>B(le),children:e.jsx(T.HiXMark,{className:"h-4 w-4"})})]},`${z.name}-${z.lastModified}-${le}`))})]}),e.jsx(Xr,{error:a,helperText:t,helperDisplay:n})]})}const Wi=[{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 qi({fields:r,title:t="Layout",fieldTypes:n=Wi,saveLabel:a="Guardar",allowAddField:s=!1,addFieldPlaceholder:l="Nuevo campo",addFieldLabel:i="Anadir",loading:c=!1,onSave:u,onChange:f}){const[p,b]=o.useState(()=>r.map(E=>({key:!1,type:"",...E}))),[m,v]=o.useState(""),[y,S]=o.useState(""),h=o.useCallback((E,L)=>{b(N=>{const k=N.map((Y,F)=>F===E?{...Y,...L}:Y);return f==null||f(k),k})},[f]),P=o.useCallback(()=>{u==null||u(p)},[p,u]),O=o.useCallback(()=>{var k;const E=m.trim();if(!E){S("Ingresa un nombre de campo.");return}if(p.some(Y=>Y.name.toLowerCase()===E.toLowerCase())){S("Ese campo ya existe en el arreglo.");return}const N={name:E,key:!1,type:((k=n[0])==null?void 0:k.value)??""};b(Y=>{const F=[...Y,N];return f==null||f(F),F}),v(""),S("")},[n,p,m,f]);return e.jsxs("div",{className:"flex flex-col rounded-xl border shadow-sm",style:{borderColor:"var(--border)",background:"var(--bg-card)",color:"var(--text-main)"},children:[e.jsx("div",{className:"border-b px-6 py-4",style:{borderColor:"var(--border)"},children:e.jsx("span",{className:"text-base font-semibold",style:{color:"var(--text-main)"},children:t})}),e.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:[e.jsx("span",{children:"Campo"}),e.jsx("span",{className:"text-center",children:"Llave"}),e.jsx("span",{children:"Tipo de Campo"})]}),e.jsxs("div",{className:"max-h-[420px] overflow-y-auto",children:[p.map((E,L)=>e.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:[e.jsx("span",{className:"text-sm font-medium",style:{color:"var(--text-main)"},children:E.name}),e.jsx("div",{className:"flex justify-center",children:e.jsx(Wt,{size:"sm",checked:E.key??!1,onChange:N=>h(L,{key:N.target.checked}),"aria-label":`${E.name} es clave`})}),e.jsx(Lr,{value:E.type??"",onChange:N=>h(L,{type:N}),options:n,placeholder:"—",emptyLabel:"—",height:36,searchable:!1,ariaLabel:`Tipo de ${E.name}`})]},E.name)),p.length===0&&e.jsx("p",{className:"px-6 py-8 text-center text-sm",style:{color:"var(--text-muted)"},children:"No hay campos disponibles."})]}),e.jsx("div",{className:"flex justify-end border-t px-6 py-4",style:{borderColor:"var(--border)"},children:e.jsxs("div",{className:"w-full space-y-2",children:[s&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"text",value:m,onChange:E=>{v(E.currentTarget.value),y&&S("")},onKeyDown:E=>{E.key==="Enter"&&(E.preventDefault(),O())},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"}),e.jsx(Fe,{variant:"secondary",onClick:O,height:36,padding:"0 12px",children:i})]}),y&&e.jsx("p",{className:"text-xs",style:{color:"var(--danger)"},children:y})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(Fe,{variant:"primary",onClick:P,disabled:c,loading:c,children:a})})]})})]})}function uo({label:r,children:t,helperText:n,helperDisplay:a="inline",error:s,labelAction:l,required:i=!1,className:c="",contentClassName:u=""}){const f=!!n&&a==="tooltip"&&!s;return e.jsxs("label",{className:`flex flex-col gap-2 ${c}`,children:[(r||l||f)&&e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-semibold uppercase text-[var(--text-muted)]",children:[r&&e.jsx("span",{children:r}),i&&e.jsx("span",{className:"text-[var(--danger)]",children:"*"}),f?e.jsx(Kr,{content:n}):null,l&&e.jsx("span",{className:"ml-auto normal-case",children:l})]}),e.jsx("span",{className:`block ${u}`,children:t}),e.jsx(Xr,{error:s,helperText:n,helperDisplay:a})]})}function fo(r){if(r!==void 0)return typeof r=="number"?`${r}px`:r}function bo(r,t){if(r.length!==t.length)return!1;const n=new Set(t);return r.every(a=>n.has(a))}function Jn(r){return r.normalize("NFD").replace(new RegExp("\\p{M}","gu"),"").toLowerCase()}function Ui(r,t){if(!t)return!0;const n=Jn(t);return Jn(r.label).includes(n)||!!(r.sublabel&&Jn(r.sublabel).includes(n))}function Vi({value:r,onChange:t,options:n,placeholder:a="Seleccionar…",disabled:s=!1,className:l="",style:i,height:c=40,padding:u="6px 10px",searchable:f=!0,minOptionsForSearch:p=6,maxVisibleValues:b=2,truncateSelectedValues:m=!0,emptyText:v="Sin resultados",clearLabel:y="Limpiar seleccion",pruneMissingValues:S=!0}){const[h,P]=o.useState(!1),[O,E]=o.useState(""),[L,N]=o.useState(0),[k,Y]=o.useState(!1),[F,U]=o.useState({}),V=o.useRef(null),J=o.useRef(null),C=o.useRef(null),re=o.useRef(null),W=f&&n.length>=p,j=o.useMemo(()=>new Set(r),[r]),ae=o.useMemo(()=>{const w=new Map;for(const R of n)w.set(R.value,R);return w},[n]),Z=o.useMemo(()=>{const w=[];for(const R of r){const B=ae.get(R);B&&w.push(B)}return w},[ae,r]),$=b==="all"?Z.length:b,ee=Z.slice(0,$),se=Math.max(0,Z.length-ee.length),M=o.useMemo(()=>{const w=O.trim();return!W||!w?n:n.filter(R=>Ui(R,w))},[n,O,W]),H=o.useCallback(()=>{const w=V.current;if(!w)return;const R=w.getBoundingClientRect(),B=W?304:244,te=window.innerHeight-R.bottom,z=te<B&&R.top>te;U({position:"fixed",left:R.left,top:z?void 0:R.bottom+4,bottom:z?window.innerHeight-R.top+4:void 0,width:Math.max(R.width,240),zIndex:9999})},[W]),oe=o.useCallback(w=>{bo(r,w)||t(w)},[t,r]),A=o.useCallback(w=>{const R=ae.get(w);if(R!=null&&R.disabled)return;const B=j.has(w)?r.filter(te=>te!==w):[...r,w];oe(B)},[oe,ae,r,j]),q=o.useCallback(()=>oe([]),[oe]),ne=o.useCallback(()=>{P(!1),E(""),N(0)},[]);o.useEffect(()=>Y(!0),[]);const ie=o.useMemo(()=>n.map(w=>w.value).join("\0"),[n]);o.useEffect(()=>{if(!S||r.length===0||n.length===0)return;const w=new Set(n.map(B=>B.value)),R=r.filter(B=>w.has(B));bo(r,R)||t(R)},[ie]),o.useEffect(()=>{if(!h)return;function w(R){var te,z;const B=R.target;!((te=V.current)!=null&&te.contains(B))&&!((z=J.current)!=null&&z.contains(B))&&ne()}return document.addEventListener("mousedown",w),()=>document.removeEventListener("mousedown",w)},[ne,h]),o.useEffect(()=>{h&&(N(0),H(),W&&setTimeout(()=>{var w;return(w=C.current)==null?void 0:w.focus()},0))},[h,W,H]),o.useEffect(()=>{if(h)return window.addEventListener("resize",H),window.addEventListener("scroll",H,!0),()=>{window.removeEventListener("resize",H),window.removeEventListener("scroll",H,!0)}},[h,H]),o.useEffect(()=>{if(M.length===0){N(0);return}N(w=>Math.min(w,M.length-1))},[M.length]),o.useEffect(()=>{if(L<0||!re.current)return;const w=re.current.children[L];w==null||w.scrollIntoView({block:"nearest"})},[L]);function Q(w){if(!s){if(!h){(w.key==="Enter"||w.key===" "||w.key==="ArrowDown")&&(w.preventDefault(),P(!0));return}if(w.key==="Escape"){w.preventDefault(),ne();return}if(w.key==="ArrowDown"){if(w.preventDefault(),M.length===0)return;N(R=>Math.min(R+1,M.length-1));return}if(w.key==="ArrowUp"){w.preventDefault(),N(R=>Math.max(R-1,0));return}if(w.key==="Enter"&&M[L]&&!M[L].disabled){w.preventDefault(),A(M[L].value);return}w.key==="Backspace"&&!O&&r.length&&(w.preventDefault(),oe(r.slice(0,-1)))}}const G=e.jsxs("div",{ref:J,className:"overflow-hidden rounded-xl shadow-xl",style:{...F,background:"var(--bg-card)",border:"1px solid var(--border)"},children:[W&&e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",style:{borderBottom:"1px solid var(--border)"},children:[e.jsx(T.HiMagnifyingGlass,{className:"h-3.5 w-3.5 flex-shrink-0",style:{color:"var(--text-muted)"}}),e.jsx("input",{ref:C,value:O,onChange:w=>{E(w.target.value),N(0)},onKeyDown:w=>{(w.key==="ArrowDown"||w.key==="ArrowUp"||w.key==="Enter"||w.key==="Escape")&&(w.stopPropagation(),Q(w))},placeholder:"Buscar…",className:"min-w-0 flex-1 bg-transparent text-sm outline-none",style:{color:"var(--text-main)"}}),O&&e.jsx("button",{type:"button","aria-label":"Limpiar búsqueda",onMouseDown:w=>{w.preventDefault(),E(""),N(0)},children:e.jsx(T.HiXMark,{className:"h-3.5 w-3.5",style:{color:"var(--text-muted)"}})})]}),r.length>0&&e.jsxs("div",{className:"flex items-center justify-between gap-3 px-3 py-2 text-xs",style:{borderBottom:"1px solid var(--border)",color:"var(--text-muted)"},children:[e.jsxs("span",{children:[Z.length," seleccionados",r.length>Z.length?` (${r.length-Z.length} no disponibles)`:""]}),e.jsx("button",{type:"button",onMouseDown:w=>{w.preventDefault(),q()},className:"font-semibold transition-colors hover:text-[var(--primary)]",children:y})]}),e.jsxs("ul",{ref:re,role:"listbox","aria-multiselectable":"true",className:"overflow-y-auto",style:{maxHeight:W?220:200,scrollbarWidth:"thin",scrollbarColor:"var(--border) transparent",overscrollBehavior:"contain"},children:[M.map((w,R)=>{const B=R===L,te=j.has(w.value);return e.jsxs("li",{role:"option","aria-selected":te,onMouseDown:z=>{z.preventDefault(),!w.disabled&&A(w.value)},onMouseEnter:()=>!w.disabled&&N(R),className:"flex cursor-pointer items-center gap-2 px-3 py-2 text-sm transition-colors",style:{background:B?"var(--bg-hover)":te?"color-mix(in srgb, var(--primary) 6%, transparent)":"transparent",color:w.disabled?"var(--text-muted)":"var(--text-main)",cursor:w.disabled?"not-allowed":"pointer",opacity:w.disabled?.58:1},children:[e.jsx("span",{className:"flex h-4 w-4 flex-shrink-0 items-center justify-center rounded border",style:{borderColor:te?"var(--primary)":"var(--border)",background:te?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:te&&e.jsx(T.HiCheck,{className:"h-3 w-3"})}),w.color&&e.jsx("span",{className:"h-2.5 w-2.5 flex-shrink-0 rounded-full",style:{background:w.color}}),e.jsxs("span",{className:"flex min-w-0 flex-1 items-baseline gap-1 overflow-hidden",children:[e.jsx("span",{className:"truncate",children:w.label}),w.sublabel&&e.jsx("span",{className:"min-w-0 flex-shrink truncate",style:{color:"var(--text-muted)",fontSize:12},children:w.sublabel})]}),w.badge&&e.jsx("span",{className:"flex-shrink-0 text-xs",style:{color:"var(--text-muted)"},children:w.badge})]},w.value)}),M.length===0&&e.jsx("li",{className:"px-3 py-4 text-center text-sm",style:{color:"var(--text-muted)"},children:v})]})]});return e.jsxs("div",{ref:V,className:`relative ${l||"w-full"}`,style:i,onKeyDown:Q,children:[e.jsxs("button",{type:"button",disabled:s,onClick:()=>{s||(h?ne():P(!0))},className:"flex w-full items-center gap-2 rounded-lg text-left text-sm transition-colors focus:outline-none",style:{minHeight:fo(c),padding:fo(u),background:"var(--bg-input)",color:Z.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:[e.jsx("span",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-1.5 overflow-hidden",children:ee.length?e.jsxs(e.Fragment,{children:[ee.map(w=>e.jsxs("span",{className:`inline-flex items-center gap-1 rounded-md border px-1.5 py-0.5 text-xs font-semibold ${m?"max-w-[160px]":"max-w-full whitespace-normal"}`,style:{background:"var(--bg-card)",borderColor:"var(--border)",color:"var(--text-main)"},children:[w.color&&e.jsx("span",{className:"h-1.5 w-1.5 flex-shrink-0 rounded-full",style:{background:w.color}}),e.jsx("span",{className:m?"truncate":"break-words",children:w.label}),e.jsx("span",{role:"button",tabIndex:-1,"aria-label":`Quitar ${w.label}`,onMouseDown:R=>{R.preventDefault(),R.stopPropagation(),A(w.value)},className:"flex-shrink-0 rounded-full p-0.5 transition-colors hover:bg-black/10",style:{color:"var(--text-muted)"},children:e.jsx(T.HiXMark,{className:"h-3 w-3"})})]},w.value)),se>0&&e.jsxs("span",{className:"inline-flex items-center rounded-md px-1.5 py-0.5 text-xs font-semibold",style:{background:"color-mix(in srgb, var(--primary) 10%, transparent)",color:"var(--primary)"},children:["+",se]})]}):e.jsx("span",{className:"truncate",children:a})}),Z.length?e.jsx("span",{role:"button",tabIndex:-1,"aria-label":y,onMouseDown:w=>{w.preventDefault(),w.stopPropagation(),q()},className:"flex-shrink-0 rounded-full p-0.5 transition-colors hover:bg-black/10",style:{color:"var(--text-muted)"},children:e.jsx(T.HiXMark,{className:"h-3.5 w-3.5"})}):e.jsx(T.HiChevronDown,{className:"h-4 w-4 flex-shrink-0 transition-transform",style:{color:"var(--text-muted)",transform:h?"rotate(180deg)":"rotate(0deg)"}})]}),h&&k&&er.createPortal(G,document.body)]})}function Gi({inputMode:r="decimal",...t}){return e.jsx(Qn,{...t,type:"number",inputMode:r})}function Ki(r,t,n){const a=[],s=Math.max(2,r-n),l=Math.min(t-1,r+n);a.push(1),s>2&&a.push("...");for(let i=s;i<=l;i+=1)a.push(i);return l<t-1&&a.push("..."),t>1&&a.push(t),a}function Xi({page:r,totalPages:t,onPageChange:n,disabled:a=!1,siblingCount:s=1,className:l=""}){const i=Math.max(1,t),c=Math.min(Math.max(1,r),i),u=Ki(c,i,s);return e.jsxs("nav",{"aria-label":"Paginacion",className:`inline-flex items-center gap-1 ${l}`,children:[e.jsx(Fe,{variant:"icon",size:"xs","aria-label":"Pagina anterior",disabled:a||c<=1,onClick:()=>n(c-1),children:e.jsx(T.HiChevronLeft,{className:"h-4 w-4"})}),u.map((f,p)=>f==="..."?e.jsx("span",{className:"flex h-8 min-w-8 items-center justify-center text-xs font-semibold text-[var(--text-muted)]",children:"..."},`ellipsis-${p}`):e.jsx("button",{type:"button","aria-current":f===c?"page":void 0,disabled:a,onClick:()=>n(f),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:f===c?"var(--primary)":"var(--border)",background:f===c?"var(--primary)":"var(--bg-card)",color:f===c?"var(--primary-fg)":"var(--text-secondary)"},children:f},f)),e.jsx(Fe,{variant:"icon",size:"xs","aria-label":"Pagina siguiente",disabled:a||c>=i,onClick:()=>n(c+1),children:e.jsx(T.HiChevronRight,{className:"h-4 w-4"})})]})}const po=[{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 mo(r){return r==null?"":String(r)}function Jt(r){return r?r.startsWith("+")?r:`+${r}`:"+1"}function Yi(r){return typeof r=="number"?`${r}px`:r}function Zi({autoComplete:r="tel",inputMode:t="tel",validate:n=!0,invalidMessage:a="Ingresa un telefono valido.",errorDisplay:s="tooltip",error:l,value:i,defaultValue:c,onChange:u,countryCode:f,defaultCountryCode:p="+1",onCountryCodeChange:b,allowedCountryCodes:m,countryCodeOptions:v,countryCodePlaceholder:y="Codigo",countryCodeClassName:S="",countryCodeWidth:h=84,onPhoneValueChange:P,label:O,containerClassName:E="",helperText:L,helperDisplay:N="inline",labelAction:k,className:Y="",required:F,disabled:U,floatingLabel:V,showPasswordToggle:J,nativeValidation:C,errorTooltipLabel:re="Error de validacion",...W}){var z;const[j,ae]=o.useState(()=>mo(c)),[Z,$]=o.useState(()=>Jt(p)),ee=o.useMemo(()=>{const le=v??po,Ee=m==null?void 0:m.map(Jt);return Ee!=null&&Ee.length?le.filter(Le=>Ee.includes(Le.value)):le},[m,v]),se=((z=ee[0])==null?void 0:z.value)??"+1",M=ee.some(le=>le.value===Jt(f??Z))?Jt(f??Z):se,H=i!==void 0?mo(i):j,oe=`${M} ${H}`.trim(),A=n&&H.length>0&&!Yn(oe)?a:void 0,q=l??A,ne=!!q,ie=ne&&s!=="tooltip",Q=ne&&s!=="inline",G=!!L&&N==="tooltip"&&!ie,w=ne?"border-[var(--danger)] focus-within:border-[var(--danger)]":"border-[var(--border)] focus-within:border-[var(--primary)]",R=le=>{const Ee=le.currentTarget.value;i===void 0&&ae(Ee),P==null||P(Ee,{countryCode:M,nationalNumber:Ee,fullNumber:`${M} ${Ee}`.trim()}),u==null||u(le)},B=le=>{f===void 0&&$(le),b==null||b(le),P==null||P(H,{countryCode:le,nationalNumber:H,fullNumber:`${le} ${H}`.trim()})},te=Q?e.jsx(Mr,{as:"span",content:q,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:e.jsx("span",{tabIndex:0,role:"img","aria-label":re,className:"flex h-full w-full items-center justify-center outline-none",children:e.jsx(lo,{className:"h-[18px] w-[18px]"})})}):null;return e.jsxs("div",{className:`flex flex-col gap-2 ${E}`,children:[e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-semibold uppercase text-[var(--text-muted)]",children:[e.jsx("span",{children:O}),F&&e.jsx("span",{className:"text-[var(--danger)]",children:"*"}),G?e.jsx(Kr,{content:L}):null,k&&e.jsx("span",{className:"ml-auto normal-case",children:k})]}),e.jsxs("span",{className:`flex h-10 min-w-0 items-center overflow-hidden rounded-lg border bg-[var(--bg-input)] transition-colors ${w}`,children:[e.jsx(Lr,{value:M,onChange:B,options:ee,placeholder:y,disabled:U,ariaLabel:"Codigo telefonico",triggerVariant:"ghost",showSelectedSublabel:!1,searchable:!0,minOptionsForSearch:0,dropdownMinWidth:300,className:`shrink-0 ${S}`,style:{width:Yi(h)},height:38,padding:"0 8px 0 10px"}),e.jsx("span",{className:"h-5 w-px shrink-0 bg-[var(--border)]"}),e.jsxs("span",{className:"relative min-w-0 flex-1 self-stretch",children:[e.jsx("input",{...W,value:i,defaultValue:c,type:"tel",inputMode:t,autoComplete:r,disabled:U,required:void 0,"aria-label":W["aria-label"]??(typeof O=="string"?O:void 0),"aria-invalid":ne||W["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 ${Q?"pr-10":""} ${Y}`,onChange:R}),te]})]}),e.jsx(Xr,{error:ie?q:void 0,helperText:L,helperDisplay:N})]})}function Qi({value:r,onChange:t,options:n,name:a,label:s,orientation:l="vertical",disabled:i=!1,className:c="",optionClassName:u=""}){return e.jsxs("fieldset",{className:`min-w-0 ${c}`,disabled:i,children:[s&&e.jsx("legend",{className:"mb-2 text-xs font-semibold uppercase text-[var(--text-muted)]",children:s}),e.jsx("div",{className:l==="horizontal"?"flex flex-wrap gap-2":"flex flex-col gap-2",children:n.map(f=>{const p=f.value===r,b=i||f.disabled;return e.jsxs("label",{className:`inline-flex min-w-0 items-start gap-2 rounded-lg border px-2.5 py-1.5 transition-colors ${b?"cursor-not-allowed opacity-60":"cursor-pointer hover:bg-[var(--bg-input)]"} ${u}`,style:{borderColor:p?"color-mix(in srgb, var(--primary) 48%, var(--border))":"var(--border)",background:p?"color-mix(in srgb, var(--primary) 8%, transparent)":"var(--bg-card)"},children:[e.jsxs("span",{className:"relative mt-0.5 inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-full border border-[var(--border)] bg-[var(--bg-input)]",children:[e.jsx("input",{type:"radio",name:a,value:f.value,checked:p,disabled:b,onChange:()=>t(f.value),className:"absolute inset-0 opacity-0"}),e.jsx("span",{className:`h-2 w-2 rounded-full transition ${p?"scale-100 opacity-100":"scale-50 opacity-0"}`,style:{background:"var(--primary)"}})]}),e.jsxs("span",{className:"min-w-0",children:[e.jsx("span",{className:"block text-sm font-medium leading-5 text-[var(--text-main)]",children:f.label}),f.description&&e.jsx("span",{className:"block text-xs leading-5 text-[var(--text-muted)]",children:f.description})]})]},f.value)})})]})}const ho=()=>'<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>',kt=r=>r.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'"),go=r=>r.toLocaleLowerCase().replace(new RegExp("(^|[^\\p{L}\\p{N}])(\\p{L})","gu"),(t,n,a)=>`${n}${a.toLocaleUpperCase()}`),Ji=r=>r.replace(/[<>]/g,"").toLowerCase(),Ri=new Set(["p","br","div","span","b","strong","i","em","u","s","strike","ul","ol","li","h1","h2","h3","h4","blockquote","a","img","hr"]),ec=/^[\s\u00a0]*([•●○■▪▫◆◇►▶➢❖✓✔\-–—*])[\s\u00a0]+/,rc=r=>{const t=r.indexOf("<!--StartFragment-->"),n=r.indexOf("<!--EndFragment-->");if(t!==-1&&n!==-1&&n>t)return r.slice(t+20,n);const a=r.match(/<body[^>]*>([\s\S]*)<\/body>/i);return a?a[1]:r},Rt=(r,t)=>t.test(r),tc=r=>Rt(r,/font-weight\s*:\s*(bold|[6-9]00)/i),nc=r=>Rt(r,/font-style\s*:\s*italic/i),ac=r=>Rt(r,/text-decoration(?:-line)?\s*:[^;]*underline/i),oc=r=>Rt(r,/text-decoration(?:-line)?\s*:[^;]*(line-through|linethrough)/i),en=(r,t)=>{var a;if(!r.childNodes.length||r.childNodes.length===1&&((a=r.firstChild)==null?void 0:a.nodeType)===Node.ELEMENT_NODE&&r.firstChild.tagName.toLowerCase()===t)return;const n=r.ownerDocument.createElement(t);for(;r.firstChild;)n.appendChild(r.firstChild);r.appendChild(n)},rn=r=>{const t=r.parentNode;if(!t){r.remove();return}for(;r.firstChild;)t.insertBefore(r.firstChild,r);t.removeChild(r)},sc=r=>{const t=r.getAttribute("class")??"",n=r.getAttribute("style")??"";return/mso-list/i.test(n)||/MsoListParagraph/i.test(t)||/MsoList/i.test(t)},vo=r=>{const t=r.getAttribute("style")??"",n=r.textContent??"";return/mso-level-number-format\s*:\s*(decimal|arabic|roman|alpha)/i.test(t)||/^\s*\d+[.)]\s/.test(n)||/^\s*[a-zA-Z][.)]\s/.test(n)?"ol":"ul"},lc=r=>{const n=r.ownerDocument.createTreeWalker(r,NodeFilter.SHOW_TEXT).nextNode();if(!n||!n.textContent)return;const a=n.textContent.replace(ec,"").replace(/^\s*\d+[.)]\s+/,"").replace(/^\s*[a-zA-Z][.)]\s+/,"");a!==n.textContent&&(n.textContent=a)},ic=r=>{const t=Array.from(r.querySelectorAll("span, font, p, div, li, h1, h2, h3, h4"));t.sort((n,a)=>a.querySelectorAll("*").length-n.querySelectorAll("*").length),t.forEach(n=>{const a=n.getAttribute("style")??"";a&&(tc(a)&&en(n,"strong"),nc(a)&&en(n,"em"),ac(a)&&en(n,"u"),oc(a)&&en(n,"s"))})},cc=r=>{const t=Array.from(r.querySelectorAll("p, div")).filter(sc);if(!t.length)return;let n=0;for(;n<t.length;){const a=t[n],s=vo(a),l=[a];let i=n+1;for(;i<t.length;){const f=t[i];if(vo(f)!==s)break;let p=l[l.length-1].nextSibling;for(;p&&p.nodeType===Node.TEXT_NODE&&!(p.textContent??"").trim();)p=p.nextSibling;if(p!==f)break;l.push(f),i++}const c=a.parentNode;if(!c){n=i;continue}const u=a.ownerDocument.createElement(s);c.insertBefore(u,a),l.forEach(f=>{lc(f);const p=f.ownerDocument.createElement("li");for(;f.firstChild;)p.appendChild(f.firstChild);u.appendChild(p),f.remove()}),n=i}},dc=r=>r==="h1"?"h2":r==="h4"||r==="h5"||r==="h6"?"h3":r==="div"?"p":r,uc=r=>{const t=rc(r.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>${t}</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()),ic(s),cc(s);const l=i=>{const c=Array.from(i.childNodes);if(i.nodeType===Node.ELEMENT_NODE){const u=i,f=u.tagName.toLowerCase();if(f==="html"||f==="body"){c.forEach(l);return}if(f==="font"){rn(u),c.forEach(l);return}if(!Ri.has(f)){rn(u),c.forEach(l);return}const p=dc(f);if(p!==f){const b=u.ownerDocument.createElement(p);for(;u.firstChild;)b.appendChild(u.firstChild);u.replaceWith(b),l(b);return}if(Array.from(u.attributes).forEach(b=>{const m=b.name.toLowerCase(),v=b.value;if(m.startsWith("on")||m==="style"||m==="class"){u.removeAttribute(b.name);return}if(m==="lang"||m.startsWith("data-")||m.startsWith("mso-")){u.removeAttribute(b.name);return}if((m==="href"||m==="src")&&/^\s*javascript:/i.test(v)){u.removeAttribute(b.name);return}f!=="a"&&f!=="img"&&m!=="href"&&m!=="src"&&m!=="alt"&&(["href","src","alt","target","rel"].includes(m)||u.removeAttribute(b.name))}),f==="a"){const b=u.getAttribute("href");if(!b||/^\s*#/.test(b)&&b.length<2){rn(u),c.forEach(l);return}u.setAttribute("target","_blank"),u.setAttribute("rel","noopener noreferrer"),u.classList.add("rich-link")}if(f==="img"){const b=u.getAttribute("src")??"";if(!b||/^\s*javascript:/i.test(b)||/^file:/i.test(b)||/scheme\s*=\s*["']?file/i.test(b)){u.remove();return}u.classList.add("rich-img"),Array.from(u.attributes).forEach(m=>{["src","alt","class"].includes(m.name.toLowerCase())||u.removeAttribute(m.name)})}if(f==="span"){rn(u),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(),u=i.querySelector("img, hr"),f=!c&&!u&&Array.from(i.childNodes).every(p=>p.nodeType===Node.TEXT_NODE||p.nodeType===Node.ELEMENT_NODE&&p.tagName.toLowerCase()==="br");(!c&&!u||f)&&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 u=c;for(;u.firstChild;)i.appendChild(u.firstChild);u.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()},Rn=r=>kt(r).replace(/\r\n?/g,`
|
|
25
|
+
`).split(/\n{2,}/).map(t=>`<p>${t.replace(/\n/g,"<br>")||"<br>"}</p>`).join(""),fc=r=>new RegExp("\\p{L}","u").test(r),ea=(r,t)=>{const n=r.trim();return!n||!fc(n)?!1:t==="uppercase"?n===n.toLocaleUpperCase():t==="lowercase"?n===n.toLocaleLowerCase():n===go(n)},xo=r=>{const t=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",ho())}(l=a.closest(".rich-img-wrap"))==null||l.classList.add("rich-img-broken")};r.querySelectorAll("img").forEach(a=>{if(!a.complete||a.naturalWidth===0){a.addEventListener("error",()=>t(a),{once:!0}),a.addEventListener("load",()=>{a.naturalWidth===0&&t(a)},{once:!0});const s=a.src;a.src="",a.src=s}});const n=a=>{const s=a.target;s.tagName==="IMG"&&t(s)};return r.addEventListener("error",n,!0),()=>r.removeEventListener("error",n,!0)};function yo({value:r,onChange:t,placeholder:n="Escribe algo...",minHeight:a="80px",instanceId:s}){const l=o.useId(),i=s||l,c=o.useCallback(()=>document,[]),u=o.useRef(null),f=o.useRef(null),p=o.useRef(new Map),b=o.useRef(null),m=o.useRef(!1),v=o.useRef(r??""),y=o.useRef(t),S=o.useRef(!1),[h,P]=o.useState(()=>!r||r.trim()===""),[O,E]=o.useState(new Set),[L,N]=o.useState(null),[k,Y]=o.useState(""),[F,U]=o.useState(""),[V,J]=o.useState(""),[C,re]=o.useState(""),[W,j]=o.useState(!1),ae=o.useCallback(()=>m.current?f.current:u.current,[]);o.useEffect(()=>{y.current=t},[t]);const Z=o.useCallback(()=>{const I=window.getSelection(),X=ae();if(!I||!X||I.rangeCount===0||I.isCollapsed)return"";const ue=I.getRangeAt(0);return!X.contains(ue.startContainer)||!X.contains(ue.endContainer)?"":I.toString()},[ae]);o.useEffect(()=>{const I=r??"";if(S.current&&I===v.current){S.current=!1,P(!I||I.trim()==="");return}S.current=!1,v.current=I;const X=[u.current,f.current].filter(be=>!!be);X.forEach(be=>{be.innerHTML!==I&&(be.innerHTML=I)}),P(!I||I.trim()==="");const ue=X.map(be=>xo(be));return()=>ue.forEach(be=>be())},[r]),o.useEffect(()=>{var be,De;m.current=W;let I,X=0,ue;if(W){const Ce=u.current;Ce&&(v.current=Ce.innerHTML);const Oe=()=>{var Ve;const $e=f.current;if(!$e){X=requestAnimationFrame(Oe);return}$e.innerHTML!==v.current&&($e.innerHTML=v.current),I=xo($e),P(((Ve=$e.textContent)==null?void 0:Ve.trim())===""),ue=setTimeout(()=>$e.focus(),60)};X=requestAnimationFrame(Oe)}else{const Ce=f.current,Oe=u.current,$e=(Ce==null?void 0:Ce.innerHTML)??v.current,Ve=v.current;v.current=$e,Oe&&Oe.innerHTML!==$e&&(Oe.innerHTML=$e),$e!==Ve&&y.current($e),P(((De=(be=Ce??Oe)==null?void 0:be.textContent)==null?void 0:De.trim())==="")}return()=>{X&&cancelAnimationFrame(X),ue&&clearTimeout(ue),I==null||I()}},[W]);const $=o.useCallback(()=>{const I=["bold","italic","underline","strikeThrough","insertUnorderedList","insertOrderedList","justifyLeft","justifyCenter","justifyRight","justifyFull"],X=new Set;I.forEach(be=>{try{c().queryCommandState(be)&&X.add(be)}catch{return}});try{const be=Ji(c().queryCommandValue("formatBlock"));be&&X.add(`formatBlock:${be}`)}catch{}const ue=Z();ea(ue,"uppercase")&&X.add("__upper"),ea(ue,"lowercase")&&X.add("__lower"),ea(ue,"capitalize")&&X.add("__cap"),E(X)},[Z,c]),ee=()=>{var X;const I=ae();I&&(v.current=I.innerHTML,S.current=!0,y.current(v.current),P(((X=I.textContent)==null?void 0:X.trim())===""))},se=I=>{if(!I){const X=u.current;X&&(v.current=X.innerHTML)}j(!I)},M=(I,X)=>{var ue;(ue=ae())==null||ue.focus(),c().execCommand(I,!1,X),ee(),$()},H=I=>{M("formatBlock",I)},oe=()=>{var I;(I=ae())==null||I.focus(),c().execCommand("insertHTML",!1,"<hr><p><br></p>"),ee(),$()},A=()=>{const I=window.getSelection();I&&I.rangeCount>0&&(b.current=I.getRangeAt(0).cloneRange())},q=()=>{const I=window.getSelection();I&&b.current&&(I.removeAllRanges(),I.addRange(b.current))},ne=I=>{if(A(),I==="link"){const X=window.getSelection();U(X&&!X.isCollapsed?X.toString():""),Y("")}I==="image"&&(J(""),re("")),N(I)},ie=()=>{var be;if(!k.trim())return;q(),(be=ae())==null||be.focus();const I=window.getSelection(),ue=(I&&!I.isCollapsed?I.toString():"")||F.trim()||k.trim();c().execCommand("insertHTML",!1,`<a href="${kt(k.trim())}" target="_blank" rel="noopener noreferrer" class="rich-link">${kt(ue)}</a>`),ee(),N(null)},Q=(I,X="")=>`<span class="rich-img-wrap" contenteditable="false"><img src="${kt(I)}" alt="${kt(X)}" class="rich-img" />${ho()}</span>`,G=()=>{var I;V.trim()&&(q(),(I=ae())==null||I.focus(),c().execCommand("insertHTML",!1,Q(V.trim(),C.trim())),ee(),N(null))},w=(I,X=1200,ue=1200,be=.72)=>new Promise((De,Ce)=>{const Oe=new FileReader;Oe.onerror=Ce,Oe.onload=$e=>{var bn;const Ve=(bn=$e.target)==null?void 0:bn.result,He=new Image;He.onerror=Ce,He.onload=()=>{let{width:Ke,height:_e}=He;if(Ke>X||_e>ue){const ir=Math.min(X/Ke,ue/_e);Ke=Math.round(Ke*ir),_e=Math.round(_e*ir)}const Xe=document.createElement("canvas");Xe.width=Ke,Xe.height=_e;const Dr=Xe.getContext("2d");if(!Dr){De(Ve);return}Dr.drawImage(He,0,0,Ke,_e),De(Xe.toDataURL("image/jpeg",be))},He.src=Ve},Oe.readAsDataURL(I)}),R=I=>{I.focus();const X=window.getSelection();if(!X||X.rangeCount===0||!I.contains(X.anchorNode)){const ue=document.createRange();ue.selectNodeContents(I),ue.collapse(!1),X==null||X.removeAllRanges(),X==null||X.addRange(ue)}},B=o.useRef(()=>{});B.current=I=>{const X=ae();X&&(R(X),c().execCommand("insertHTML",!1,I),X.querySelectorAll("p").forEach(ue=>{!(ue.textContent??"").replace(/[\u00a0\s]+/g,"")&&!ue.querySelector("img, hr")&&ue.remove()}),ee(),$())};const te=o.useRef(w);te.current=w;const z=o.useRef(Q);z.current=Q;const le=o.useCallback(I=>{if(!I||p.current.has(I))return;const X=ue=>{const be=ue.clipboardData;if(!be)return;const De=be.getData("text/html"),Ce=be.getData("text/plain");if(De||Ce){ue.preventDefault(),ue.stopPropagation();try{const He=De?uc(De):Rn(Ce);if(!He){Ce&&B.current(Rn(Ce));return}B.current(He)}catch{Ce&&B.current(Rn(Ce))}return}const $e=Array.from(be.items).find(He=>He.type.startsWith("image/"));if(!$e)return;ue.preventDefault(),ue.stopPropagation();const Ve=$e.getAsFile();Ve&&te.current(Ve).then(He=>{B.current(z.current(He,"imagen"))})};I.addEventListener("paste",X,!0),p.current.set(I,()=>{I.removeEventListener("paste",X,!0),p.current.delete(I)})},[]),Ee=o.useCallback(I=>{var ue;const X=u.current;X&&X!==I&&((ue=p.current.get(X))==null||ue()),u.current=I,I&&le(I)},[le]),Le=o.useCallback(I=>{var ue;const X=f.current;X&&X!==I&&((ue=p.current.get(X))==null||ue()),f.current=I,I&&le(I)},[le]);o.useEffect(()=>{const I=p.current;return()=>{I.forEach(X=>X()),I.clear()}},[]);const xe=I=>{const X=window.getSelection(),ue=ae();if(!X||!ue||X.rangeCount===0||X.isCollapsed)return;const be=X.getRangeAt(0);if(!ue.contains(be.startContainer)||!ue.contains(be.endContainer))return;const De=be.toString();if(!De)return;let Ce=De;I==="uppercase"?Ce=De.toLocaleUpperCase():I==="lowercase"?Ce=De.toLocaleLowerCase():Ce=go(De),be.deleteContents();const Oe=document.createTextNode(Ce);be.insertNode(Oe);const $e=document.createRange();$e.setStart(Oe,0),$e.setEnd(Oe,Ce.length),X.removeAllRanges(),X.addRange($e),b.current=$e.cloneRange(),ee(),$()},Se=()=>{A(),$()},Te=()=>{ee(),$()},kr=()=>{requestAnimationFrame(()=>{var I;(I=ae())==null||I.focus()})},pr=I=>{var X,ue;if((I.metaKey||I.ctrlKey)&&I.key==="Enter"){if(I.preventDefault(),I.stopPropagation(),I.repeat)return;(X=ae())==null||X.focus(),c().execCommand("insertLineBreak",!1)||c().execCommand("insertHTML",!1,"<br>"),ee(),$();return}if(I.key==="Tab"){I.preventDefault(),(ue=ae())==null||ue.focus(),c().execCommand("insertText",!1," "),ee(),$();return}if(I.key==="Escape"){if(L){N(null);return}if(m.current){j(!1);return}}L||(I.ctrlKey||I.metaKey)&&(I.key==="b"&&(I.preventDefault(),M("bold")),I.key==="i"&&(I.preventDefault(),M("italic")),I.key==="u"&&(I.preventDefault(),M("underline")),I.key==="k"&&(I.preventDefault(),ne("link")))},qe=()=>e.jsx("div",{className:"h-4 w-px flex-shrink-0 mx-1",style:{background:"var(--border)"}}),ce=(I,X,ue,be,De)=>{const Ce=De??(O.has(ue)||ue==="__link"&&L==="link"||ue==="__img"&&L==="image");return e.jsx("button",{type:"button",title:X,tabIndex:-1,onFocus:kr,onMouseDown:Oe=>{Oe.preventDefault(),be?be():M(ue)},className:"flex h-7 w-7 items-center justify-center rounded text-xs font-bold transition-colors",style:{color:Ce?"var(--primary)":"var(--text-secondary)",background:Ce?"rgba(59,130,246,0.12)":"transparent"},children:I},ue)},Qe=I=>{const X=I.target;if(X.closest("[data-action='delete-img']")){I.preventDefault();const ue=X.closest(".rich-img-wrap");ue&&(ue.remove(),ee())}},lr=I=>e.jsxs(e.Fragment,{children:[L==="link"&&e.jsxs("div",{className:"flex flex-shrink-0 flex-wrap items-center gap-2 border-t px-3 py-2",style:{borderColor:"var(--border)",background:I},children:[e.jsx("input",{autoFocus:!0,type:"url",value:k,onChange:X=>Y(X.target.value),onKeyDown:X=>{X.key==="Enter"&&(X.preventDefault(),ie()),X.key==="Escape"&&N(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)"}}),e.jsx("input",{type:"text",value:F,onChange:X=>U(X.target.value),onKeyDown:X=>{X.key==="Enter"&&(X.preventDefault(),ie()),X.key==="Escape"&&N(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)"}}),e.jsx("button",{type:"button",onClick:ie,className:"rounded px-2.5 py-1 text-xs font-semibold text-white",style:{background:"var(--primary)"},children:"OK"}),e.jsx("button",{type:"button",onClick:()=>N(null),className:"rounded px-2 py-1 text-xs",style:{color:"var(--text-muted)"},children:"x"})]}),L==="image"&&e.jsxs("div",{className:"flex flex-shrink-0 flex-wrap items-center gap-2 border-t px-3 py-2",style:{borderColor:"var(--border)",background:I},children:[e.jsx("input",{autoFocus:!0,type:"url",value:V,onChange:X=>J(X.target.value),onKeyDown:X=>{X.key==="Enter"&&(X.preventDefault(),G()),X.key==="Escape"&&N(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)"}}),e.jsx("input",{type:"text",value:C,onChange:X=>re(X.target.value),onKeyDown:X=>{X.key==="Enter"&&(X.preventDefault(),G()),X.key==="Escape"&&N(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)"}}),e.jsx("button",{type:"button",onClick:G,className:"rounded px-2.5 py-1 text-xs font-semibold text-white",style:{background:"var(--primary)"},children:"OK"}),e.jsx("button",{type:"button",onClick:()=>N(null),className:"rounded px-2 py-1 text-xs",style:{color:"var(--text-muted)"},children:"x"})]})]}),fe=(I,X)=>e.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:X},children:[ce(e.jsx(T.HiArrowUturnLeft,{className:"h-4 w-4"}),"Deshacer","undo"),ce(e.jsx(T.HiArrowUturnRight,{className:"h-4 w-4"}),"Rehacer","redo"),qe(),ce(e.jsx("span",{style:{fontSize:"10px"},children:"P"}),"Parrafo","__paragraph",()=>H("p"),O.has("formatBlock:p")||O.has("formatBlock:div")),ce(e.jsx(T.HiH2,{className:"h-4 w-4"}),"Titulo 2","__h2",()=>H("h2"),O.has("formatBlock:h2")),ce(e.jsx(T.HiH3,{className:"h-4 w-4"}),"Titulo 3","__h3",()=>H("h3"),O.has("formatBlock:h3")),ce(e.jsx("span",{style:{fontSize:"13px",lineHeight:1},children:"“"}),"Cita","__quote",()=>H("blockquote"),O.has("formatBlock:blockquote")),qe(),ce(e.jsx("b",{children:"B"}),"Negrita (Ctrl+B)","bold"),ce(e.jsx("i",{children:"I"}),"Cursiva (Ctrl+I)","italic"),ce(e.jsx("u",{children:"U"}),"Subrayado (Ctrl+U)","underline"),ce(e.jsx("s",{children:"S"}),"Tachado","strikeThrough"),qe(),ce(e.jsx(T.HiListBullet,{className:"h-4 w-4"}),"Lista sin orden","insertUnorderedList"),ce(e.jsx(T.HiNumberedList,{className:"h-4 w-4"}),"Lista numerada","insertOrderedList"),ce(e.jsx(T.HiArrowTurnUpLeft,{className:"h-4 w-4"}),"Disminuir sangria","outdent"),ce(e.jsx(T.HiArrowTurnDownRight,{className:"h-4 w-4"}),"Aumentar sangria","indent"),qe(),ce(e.jsx(T.HiBars3BottomLeft,{className:"h-4 w-4"}),"Alinear izquierda","justifyLeft"),ce(e.jsx(T.HiBars3CenterLeft,{className:"h-4 w-4"}),"Centrar","justifyCenter"),ce(e.jsx(T.HiBars3BottomRight,{className:"h-4 w-4"}),"Alinear derecha","justifyRight"),ce(e.jsx(T.HiBars3,{className:"h-4 w-4"}),"Justificar","justifyFull"),qe(),ce(e.jsx("span",{style:{fontSize:"10px"},children:"AA"}),"Mayusculas","__upper",()=>xe("uppercase")),ce(e.jsx("span",{style:{fontSize:"10px"},children:"aa"}),"Minusculas","__lower",()=>xe("lowercase")),ce(e.jsx("span",{style:{fontSize:"10px"},children:"Aa"}),"Capitalizar","__cap",()=>xe("capitalize")),qe(),ce(e.jsx(T.HiLink,{className:"h-4 w-4"}),"Insertar enlace (Ctrl+K)","__link",()=>ne("link")),ce(e.jsx(T.HiLinkSlash,{className:"h-4 w-4"}),"Quitar enlace","unlink"),ce(e.jsx(T.HiPhoto,{className:"h-4 w-4"}),"Insertar imagen","__img",()=>ne("image")),ce(e.jsx(T.HiMinus,{className:"h-4 w-4"}),"Insertar separador","__divider",oe),qe(),ce(e.jsx(T.HiOutlinePaintBrush,{className:"h-4 w-4"}),"Limpiar formato","removeFormat"),ce(e.jsx(T.HiNoSymbol,{className:"h-4 w-4"}),"Quitar bloque","__clearBlock",()=>H("p")),qe(),e.jsx("button",{type:"button",title:I?"Salir del modo de enfoque (Esc)":"Modo de enfoque",tabIndex:-1,onFocus:kr,onMouseDown:ue=>{ue.preventDefault(),se(I)},className:"flex h-7 w-7 items-center justify-center rounded transition-colors",style:{color:"var(--text-secondary)"},children:I?e.jsx(T.HiArrowsPointingIn,{className:"h-4 w-4"}):e.jsx(T.HiArrowsPointingOut,{className:"h-4 w-4"})})]});return e.jsxs(e.Fragment,{children:[e.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:[e.jsx("div",{ref:Ee,contentEditable:!0,suppressContentEditableWarning:!0,"data-bonsaif-rich-instance":i,onInput:Te,onKeyDown:pr,onKeyUp:Se,onSelect:Se,onMouseUp:Se,onMouseDown:Qe,"data-placeholder":n,className:`rich-editor px-3 py-2 text-sm focus:outline-none${h?" is-empty":""}`,style:{color:"var(--text-main)",background:"var(--bg-input)",minHeight:a,maxHeight:"320px",overflowY:"auto",lineHeight:"1.6"}}),lr("var(--bg-input)"),fe(!1,"var(--bg-input)")]}),e.jsxs(qn,{open:W,onClose:()=>j(!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:[e.jsx("div",{ref:Le,contentEditable:!0,suppressContentEditableWarning:!0,"data-bonsaif-rich-instance":i,onInput:Te,onKeyDown:pr,onKeyUp:Se,onSelect:Se,onMouseUp:Se,onMouseDown:Qe,"data-placeholder":n,className:`rich-editor min-h-0 flex-1 overflow-y-auto px-8 py-6 text-sm focus:outline-none${h?" is-empty":""}`,style:{color:"var(--text-main)",background:"var(--bg-card)",lineHeight:"1.75"}}),lr("var(--bg-input)"),fe(!0,"var(--bg-input)")]})]})}const wo="[a-zA-Z0-9._@-]+",ra=new RegExp(`@(${wo})`,"g"),bc=/[a-zA-Z0-9._@-]/,Nt=new Set([" ",`
|
|
26
|
+
`," ","\r"," ","(","[","{",".",",",";",":","!","?","¿","¡",")","]","}",'"',"'","«","»","/","\\","|","-","—","–"]);function ko(r,t){if(t<=0)return!0;const n=r[t-1]??"";return Nt.has(n)}function No(r,t,n){var a;if(t<0||t>r.length)return null;for(let s=t-1;s>=0;s-=1){if(r[s]!=="@"){const c=r[s]??"";if(Nt.has(c)||!bc.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):ko(r,s)))continue;const i=r.slice(s+1,t);return i.length>0&&!new RegExp(`^${wo}$`).test(i)?null:{query:i,triggerIndex:s,caretIndex:t}}return null}function So(r,t){var a;const n=Yr(r,t);return n?!!((a=n.node.parentElement)!=null&&a.closest(".mention-chip")):!1}function Co(r,t){if(t<=0)return!0;const n=Yr(r,t);if(!n){const s=r.textContent??"";return ko(s,t)}if(n.offset>0){const s=n.node.data[n.offset-1]??"";return Nt.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 Nt.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 Nt.has(l[l.length-1]??"")}a=a.previousSibling}return!0}function ta(r,t){const n=r.textContent??"";return No(n,t,{isTriggerBoundary:a=>Co(r,a),isInsideExistingMention:a=>So(r,a)})}function na(r){return r.toLowerCase().trim()}function Eo(r){return r?r.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 aa(r){if(!r)return[];const t=new Set,n=[],a=u=>{const f=na(u);!f||t.has(f)||(t.add(f),n.push(f))},s=/data-username\s*=\s*["']([^"']+)["']/gi;let l;for(;(l=s.exec(r))!==null;)a(l[1]??"");const i=Eo(r);ra.lastIndex=0;let c;for(;(c=ra.exec(i))!==null;)a(c[1]??"");return n}function Mo(r){const t=String(r.name??"").trim();return t||String(r.username??"").trim()||"usuario"}function fc(r,t){const n=aa(r);if(!n.length)return[];const a=new Map;t.forEach(i=>{i.username&&a.set(na(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 Lo(r){const t=new Set,n=[];for(const a of r)t.has(a.userId)||(t.add(a.userId),n.push(a));return n}function bc(r,t){return t?r.filter(n=>n.userId!==t):r}function To(r){return!r||!/@/.test(r)?r:r.replace(ra,(t,n,a,s)=>{const l=s.slice(0,a),i=l.lastIndexOf("<"),c=l.lastIndexOf(">");return i>c?t:`<span class="mention-chip" contenteditable="false" data-username="${(n??"").toLowerCase()}">${t}</span>`})}function Yr(r,t){if(t<0)return null;const n=r.ownerDocument;if(!n)return null;const a=n.createTreeWalker(r,NodeFilter.SHOW_TEXT);let s=t,l=null,i=a.nextNode();for(;i;){l=i;const c=i.data.length;if(s<=c)return{node:i,offset:s};s-=c,i=a.nextNode()}return l&&s===0?{node:l,offset:l.data.length}:null}function oa(r,t,n){var s;const a=r.ownerDocument;if(!a||r!==t&&!r.contains(t))return-1;try{const l=a.createRange();return l.selectNodeContents(r),l.setEnd(t,n),((s=l.cloneContents().textContent)==null?void 0:s.length)??0}catch{return-1}}function $o(r,t){const{triggerIndex:n,caretIndex:a,username:s}=t;if(a<n)return null;const l=Yr(r,n),i=Yr(r,a);if(!l||!i)return null;const c=r.ownerDocument,u=c.createRange();u.setStart(l.node,l.offset),u.setEnd(i.node,i.offset),u.deleteContents();const f=Mo({name:t.display,username:s}),p=c.createElement("span");p.className="mention-chip",p.setAttribute("data-username",s.toLowerCase()),t.userId&&p.setAttribute("data-userid",String(t.userId)),p.contentEditable="false",p.textContent=f,p.title=`@${s}`;const b=c.createTextNode(" ");u.insertNode(b),u.insertNode(p);const m=c.defaultView,v=m==null?void 0:m.getSelection();if(v){const y=c.createRange();y.setStart(b,b.data.length),y.collapse(!0),v.removeAllRanges(),v.addRange(y)}return{caretPlainOffset:n+f.length+1}}function Ao(r,t){const n=r.ownerDocument,a=n.defaultView;if(!a)return;const s=a.getSelection();if(!s)return;const l=n.createRange(),i=Yr(r,t);i?(l.setStart(i.node,i.offset),l.collapse(!0)):(l.selectNodeContents(r),l.collapse(!1)),s.removeAllRanges(),s.addRange(l)}const sa=280,tn=6,Do=260,pc=new Set(["ArrowDown","ArrowUp","Enter","Tab","Escape"]),mc={position:"relative"},hc={position:"fixed",zIndex:11050,minWidth:Do,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},Io={padding:"10px 12px",fontSize:12,color:"var(--text-muted, #656d76)"};function gc(r){return Array.from(document.querySelectorAll(`[data-bonsaif-rich-instance="${CSS.escape(r)}"]`))}function vc(r,t){const n=Math.max(8,Math.min(r.left,window.innerWidth-Do-8)),a=t==null?void 0:t.getBoundingClientRect(),s=a?Math.min(window.innerHeight-8,a.bottom):window.innerHeight-8,l=a?Math.max(8,a.top):8,i=s-r.bottom-tn,c=r.top-l-tn;return i<Math.min(sa,160)&&c>i?{left:n,bottom:window.innerHeight-r.top+tn,maxHeight:Math.max(120,Math.min(sa,c))}:{left:n,top:r.bottom+tn,maxHeight:Math.max(120,Math.min(sa,i))}}function Bo({value:r,onChange:t,onSearchUsers:n,onMentionsChange:a,minHeight:s,placeholder:l,className:i,maxSuggestions:c=8,searchDebounceMs:u=140,highlightInEditor:f=!1,searchCacheKey:p=""}){const b=o.useId().replace(/:/g,""),m=o.useRef(null),v=o.useRef(null),y=o.useRef(new Map),S=o.useRef(n);S.current=n;const h=o.useRef(null),H=o.useRef(0),_=o.useRef([]),[E,L]=o.useState(null),[N,k]=o.useState([]),[K,P]=o.useState(0),[q,X]=o.useState([]),[J,C]=o.useState(!1),[te,j]=o.useState(!1);H.current=K,o.useEffect(()=>{j(!0)},[]);const W=(E==null?void 0:E.query)??null;o.useEffect(()=>{if(W===null){k([]);return}const A=W.trim(),U=`${p}|${A.toLowerCase()||"*"}`,ne=y.current.get(U);if(ne){k(ne),C(!1),P(0);return}const ie=new AbortController;C(!0);const Q=window.setTimeout(()=>{(async()=>{try{const V=await S.current(A,{signal:ie.signal,limit:c});if(ie.signal.aborted)return;const w=Array.isArray(V)?V:[];y.current.set(U,w),k(w),P(0)}catch{ie.signal.aborted||k([])}finally{ie.signal.aborted||C(!1)}})()},u);return()=>{ie.abort(),window.clearTimeout(Q)}},[W,c,u,p]);const ae=o.useRef(a);ae.current=a,o.useEffect(()=>{var A;(A=ae.current)==null||A.call(ae,Lo(q))},[q]);const Z=o.useCallback(()=>{const A=gc(b);if(A.length===0)return null;const U=window.getSelection();if(U!=null&&U.rangeCount){const ie=U.getRangeAt(0).startContainer;for(const Q of A)if(Q.contains(ie))return Q}const ne=document.activeElement;for(const ie of A)if(ne===ie||ne&&ie.contains(ne))return ie;for(const ie of A)if(ie.closest('[role="dialog"]'))return ie;return A[0]??null},[b]),$=o.useCallback(()=>{const A=Z(),U=window.getSelection();if(!A||!U||U.rangeCount===0){L(null);return}const ne=U.getRangeAt(0);if(!A.contains(ne.startContainer)){L(null);return}const ie=oa(A,ne.startContainer,ne.startOffset);if(ie<0){L(null);return}const Q=ta(A,ie);if(!Q){L(null);return}const V=ne.getBoundingClientRect(),w=V.width===0&&V.height===0?(()=>{const B=document.createRange();return B.selectNodeContents(ne.startContainer),B.collapse(!0),B.getBoundingClientRect()})():V;h.current={query:Q.query,caretIndex:Q.caretIndex,triggerIndex:Q.triggerIndex};const R=vc(w,A);L(B=>{const re={query:Q.query,...R};return B&&B.query===re.query&&B.top===re.top&&B.bottom===re.bottom&&B.left===re.left&&B.maxHeight===re.maxHeight?B:re})},[Z]),ee=o.useCallback(A=>{t(A),$()},[t,$]);o.useEffect(()=>{const A=U=>{if(pc.has(U.key))return;const ne=Z(),ie=U.target;!ne||!ie||!ne.contains(ie)||$()};return document.addEventListener("keyup",A,!0),()=>document.removeEventListener("keyup",A,!0)},[Z,$]);const se=o.useCallback(A=>{const U=Z();if(!U)return;let ne=-1;const ie=window.getSelection();if(ie&&ie.rangeCount>0){const B=ie.getRangeAt(0);U.contains(B.startContainer)&&(ne=oa(U,B.startContainer,B.startOffset))}if(ne<0&&h.current&&(ne=h.current.caretIndex),ne<0)return;const Q=ta(U,ne);if(!Q)return;const V=$o(U,{triggerIndex:Q.triggerIndex,caretIndex:ne,username:A.username,display:A.name,userId:A.userId});if(!V)return;t(U.innerHTML);const w={userId:A.userId,username:A.username,email:A.email??void 0,display:A.name??A.username};X(B=>{const re=new Map(B.map(F=>[F.userId,F]));return re.set(w.userId,w),Array.from(re.values())}),L(null),h.current=null;const R=V.caretPlainOffset;requestAnimationFrame(()=>{requestAnimationFrame(()=>{var Ee,Le;const B=Z();if(!B)return;B.focus(),Ao(B,R);const re=window.getSelection(),F=re==null?void 0:re.anchorNode,le=F instanceof Element?F.closest(".mention-chip"):(Ee=F==null?void 0:F.parentElement)==null?void 0:Ee.closest(".mention-chip");if(le!=null&&le.parentNode){const xe=document.createRange(),Se=le.nextSibling;Se&&Se.nodeType===Node.TEXT_NODE?xe.setStart(Se,((Le=Se.textContent)==null?void 0:Le.length)??0):xe.setStartAfter(le),xe.collapse(!0),re==null||re.removeAllRanges(),re==null||re.addRange(xe)}})})},[Z,t]);o.useEffect(()=>{const A=new Set(aa(r).map(U=>U.toLowerCase()));X(U=>{const ne=U.filter(ie=>A.has(ie.username.toLowerCase()));return ne.length===U.length?U:ne})},[r]),o.useEffect(()=>{if(!E)return;const A=U=>{const ne=U.target;if(!ne||m.current&&m.current.contains(ne)||v.current&&v.current.contains(ne))return;const ie=Z();ie&&ie.contains(ne)||L(null)};return document.addEventListener("mousedown",A),()=>{document.removeEventListener("mousedown",A)}},[E,Z]);const M=o.useMemo(()=>N.slice(0,c),[N,c]);_.current=M,o.useEffect(()=>{if(!E)return;const A=U=>{const ne=Z(),ie=U.target;if(!ne||!ie||!ne.contains(ie))return;const Q=_.current;if(!(Q.length===0&&U.key!=="Escape"))if(U.key==="ArrowDown")U.preventDefault(),U.stopPropagation(),P(V=>(V+1)%Math.max(Q.length,1));else if(U.key==="ArrowUp")U.preventDefault(),U.stopPropagation(),P(V=>(V-1+Q.length)%Math.max(Q.length,1));else if(U.key==="Enter"||U.key==="Tab"){const V=Q[H.current];V&&(U.preventDefault(),U.stopPropagation(),se(V))}else U.key==="Escape"&&(U.preventDefault(),U.stopPropagation(),L(null))};return document.addEventListener("keydown",A,!0),()=>document.removeEventListener("keydown",A,!0)},[Z,se,E]),o.useEffect(()=>{if(!E||!v.current)return;const A=v.current.querySelector(`[data-mention-index="${K}"]`);A==null||A.scrollIntoView({block:"nearest"})},[K,E]);const O=f?To(r):r,oe=E&&te?er.createPortal(e.jsxs("ul",{ref:v,style:{...hc,left:E.left,top:E.top,bottom:E.bottom,maxHeight:E.maxHeight},role:"listbox","aria-label":"Menciones sugeridas",children:[J&&M.length===0&&e.jsx("li",{style:Io,children:"Buscando…"}),!J&&M.length===0&&e.jsx("li",{style:Io,children:E.query.trim().length===0?"Escribe un nombre o usuario":`Sin coincidencias para “${E.query}”`}),M.map((A,U)=>{var ne,ie;return e.jsx("li",{children:e.jsxs("button",{type:"button","data-mention-index":U,onMouseDown:Q=>{Q.preventDefault(),se(A)},onMouseEnter:()=>P(U),style:{width:"100%",textAlign:"left",padding:"8px 10px",border:"none",background:U===K?"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:[e.jsx("span",{style:{fontWeight:600,fontSize:13},children:((ne=A.name)==null?void 0:ne.trim())||`@${A.username}`}),e.jsx("span",{style:{fontSize:11,color:"var(--text-muted, #656d76)"},children:[(ie=A.name)!=null&&ie.trim()?`@${A.username}`:null,A.email].filter(Boolean).join(" · ")||`@${A.username}`})]})},A.userId)})]}),document.body):null;return e.jsxs("div",{ref:m,style:mc,className:i,children:[e.jsx(yo,{value:O,onChange:ee,placeholder:l,minHeight:s,instanceId:b}),oe]})}function xc({value:r,onChange:t,placeholder:n,minHeight:a,onSearchUsers:s,onMentionsChange:l,className:i,maxSuggestions:c,searchDebounceMs:u,highlightInEditor:f,searchCacheKey:p}){return s?e.jsx(Bo,{value:r,onChange:t,onSearchUsers:s,onMentionsChange:l,placeholder:n,minHeight:a,className:i,maxSuggestions:c,searchDebounceMs:u,highlightInEditor:f,searchCacheKey:p}):e.jsx(yo,{value:r,onChange:t,placeholder:n,minHeight:a})}function yc({title:r,subtitle:t,icon:n,actions:a,children:s,footer:l,className:i="",bodyClassName:c="p-4"}){const u=r||t||n||a;return e.jsxs("section",{className:`overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${i}`,children:[u&&e.jsxs("header",{className:"flex items-center justify-between gap-3 border-b border-[var(--border)] px-4 py-3",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[n&&e.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-input)] text-[var(--primary)]",children:n}),e.jsxs("div",{className:"min-w-0",children:[r&&e.jsx("h3",{className:"truncate text-sm font-semibold text-[var(--text-main)]",children:r}),t&&e.jsx("div",{className:"truncate text-xs text-[var(--text-muted)]",children:t})]})]}),a&&e.jsx("div",{className:"shrink-0",children:a})]}),e.jsx("div",{className:c,children:s}),l&&e.jsx("footer",{className:"border-t border-[var(--border)] px-4 py-3",children:l})]})}const wc={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)"}},kc={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 Nc({children:r,tone:t="neutral",size:n="sm",icon:a,dot:s=!1,className:l=""}){const i=wc[t];return e.jsxs("span",{className:`inline-flex max-w-full shrink-0 items-center gap-1.5 rounded-full border font-semibold leading-none ${kc[n]} ${l}`,style:{color:i.text,background:i.bg,borderColor:i.border},children:[s&&e.jsx("span",{"aria-hidden":"true",className:"h-1.5 w-1.5 shrink-0 rounded-full",style:{background:i.text}}),a&&e.jsx("span",{className:"shrink-0",children:a}),e.jsx("span",{className:"min-w-0 truncate",children:r})]})}const Oo={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)"}},Sc={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"},Cc={xs:"right-1 h-3 w-3",sm:"right-1.5 h-3 w-3",md:"right-2 h-3.5 w-3.5"},Ec={xs:148,sm:164,md:184},Mc={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 Lc({value:r,options:t,onChange:n,size:a="sm",disabled:s=!1,loading:l=!1,stopPropagation:i=!1,ariaLabel:c="Cambiar estado",title:u="Cambiar estado",className:f,selectClassName:p,menuClassName:b,optionClassName:m,spinnerClassName:v}){const[y,S]=o.useState(!1),[h,H]=o.useState(!1),[_,E]=o.useState(-1),[L,N]=o.useState({}),k=o.useRef(null),K=o.useRef(null),P=o.useRef(null),q=t.find($=>$.value===r)??t[0],X={...q!=null&&q.tone?Oo[q.tone]:void 0,...q==null?void 0:q.style},J=s||l||t.length===0,C=$=>{i&&$.stopPropagation()},te=o.useCallback(()=>{S(!1),E(-1)},[]),j=o.useCallback(()=>{const $=k.current;if(!$)return;const ee=$.getBoundingClientRect(),se=Math.max(ee.width,Ec[a]),M=Math.min(Math.max(t.length,1)*38+12,260),O=window.innerHeight-ee.bottom,oe=O<M&&ee.top>O,A=Math.min(Math.max(8,ee.left+ee.width/2-se/2),window.innerWidth-se-8);N({position:"fixed",left:A,top:oe?void 0:ee.bottom+6,bottom:oe?window.innerHeight-ee.top+6:void 0,width:se,zIndex:9999})},[t.length,a]),W=o.useCallback($=>{$.disabled||(n($.value),te())},[te,n]);o.useEffect(()=>H(!0),[]),o.useEffect(()=>{if(!y)return;j();const $=t.findIndex(ee=>ee.value===r);E($>=0?$:0)},[y,t,j,r]),o.useEffect(()=>{if(!y)return;function $(ee){var M,O;const se=ee.target;!((M=k.current)!=null&&M.contains(se))&&!((O=K.current)!=null&&O.contains(se))&&te()}return document.addEventListener("mousedown",$),()=>document.removeEventListener("mousedown",$)},[te,y]),o.useEffect(()=>{if(y)return window.addEventListener("resize",j),window.addEventListener("scroll",j,!0),()=>{window.removeEventListener("resize",j),window.removeEventListener("scroll",j,!0)}},[y,j]),o.useEffect(()=>{if(_<0||!P.current)return;const $=P.current.children[_];$==null||$.scrollIntoView({block:"nearest"})},[_]);function ae($){if(!J){if(!y){["Enter"," ","ArrowDown","ArrowUp"].includes($.key)&&($.preventDefault(),S(!0));return}if($.key==="Escape"){$.preventDefault(),te();return}if($.key==="ArrowDown"){$.preventDefault(),E(ee=>Math.min(ee+1,t.length-1));return}if($.key==="ArrowUp"){$.preventDefault(),E(ee=>Math.max(ee-1,0));return}if($.key==="Enter"||$.key===" "){$.preventDefault();const ee=t[_];ee&&W(ee)}}}const Z=e.jsx("div",{ref:K,role:"listbox","aria-label":c,className:gr("overflow-hidden rounded-xl border shadow-xl backdrop-blur-md",b),style:{...L,background:"color-mix(in srgb, var(--bg-card) 92%, transparent)",borderColor:"var(--border)",color:"var(--text-main)"},onClick:C,onMouseDown:C,onPointerDown:C,children:e.jsx("div",{ref:P,className:"max-h-64 overflow-y-auto p-1",style:{scrollbarWidth:"thin",scrollbarColor:"var(--border) transparent",overscrollBehavior:"contain"},children:t.map(($,ee)=>{const se=$.value===r,M=ee===_,O={...$.tone?Oo[$.tone]:void 0,...$.style};return e.jsxs("button",{type:"button",role:"option","aria-selected":se,disabled:$.disabled,onMouseEnter:()=>!$.disabled&&E(ee),onMouseDown:oe=>{oe.preventDefault(),W($)},className:gr("flex w-full items-center gap-2 rounded-lg font-medium text-left transition-colors disabled:cursor-not-allowed disabled:opacity-45",Mc[a],se?$.className:void 0,m),style:{...se?O:void 0,background:se?O.background??"color-mix(in srgb, var(--primary) 12%, transparent)":M?"var(--bg-hover)":"transparent",color:se?O.color??"var(--primary)":"var(--text-main)"},children:[e.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center",children:se?e.jsx(T.HiCheck,{className:"h-4 w-4"}):null}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:$.label})]},$.value)})})});return e.jsxs("span",{ref:k,className:gr("relative inline-flex shrink-0 items-center",f),onKeyDown:ae,onClick:C,onPointerDown:C,children:[e.jsx("button",{type:"button",disabled:J,"aria-label":c,"aria-haspopup":"listbox","aria-expanded":y,title:u,onClick:()=>!J&&S($=>!$),className:gr("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",Sc[a],q==null?void 0:q.className,p),style:X,children:e.jsx("span",{className:"min-w-0 truncate",children:(q==null?void 0:q.label)??r})}),e.jsx(T.HiChevronDown,{"aria-hidden":"true",className:gr("pointer-events-none absolute opacity-70 transition-transform",Cc[a],y?"rotate-180":"rotate-0")}),l&&e.jsx("span",{"aria-hidden":"true",className:gr("absolute -right-1 -top-1 h-2.5 w-2.5 rounded-full border border-current border-t-transparent animate-spin",v)}),y&&h&&er.createPortal(Z,document.body)]})}function Tc({tabs:r,activeTabId:t,defaultActiveTabId:n,onTabChange:a,ariaLabel:s="Pestanas",variant:l="underline",className:i="",listClassName:c="",panelClassName:u=""}){const f=r.find(y=>!y.disabled)??r[0],p=t??n??(f==null?void 0:f.id),b=r.find(y=>y.id===p)??f,m=y=>{y.disabled||a==null||a(y.id)},v=y=>{const S=r.filter(H=>!H.disabled);if(!S.length||!b)return;const h=S.findIndex(H=>H.id===b.id);(y.key==="ArrowRight"||y.key==="ArrowDown")&&(y.preventDefault(),m(S[(h+1)%S.length])),(y.key==="ArrowLeft"||y.key==="ArrowUp")&&(y.preventDefault(),m(S[(h-1+S.length)%S.length])),y.key==="Home"&&(y.preventDefault(),m(S[0])),y.key==="End"&&(y.preventDefault(),m(S[S.length-1]))};return e.jsxs("div",{className:i,children:[e.jsx("div",{role:"tablist","aria-label":s,onKeyDown:v,className:`flex min-w-0 gap-1 overflow-x-auto ${l==="underline"?"border-b border-[var(--border)]":"rounded-lg border border-[var(--border)] bg-[var(--bg-input)] p-1"} ${c}`,children:r.map(y=>{const S=y.id===(b==null?void 0:b.id);return e.jsxs("button",{type:"button",role:"tab","aria-selected":S,"aria-controls":`${y.id}-panel`,id:`${y.id}-tab`,disabled:y.disabled,tabIndex:S?0:-1,onClick:()=>m(y),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:S?"var(--primary)":"var(--text-muted)",borderColor:S?"var(--primary)":"transparent",background:l==="pills"&&S?"var(--bg-card)":"transparent"},children:[y.icon&&e.jsx("span",{className:"shrink-0",children:y.icon}),e.jsx("span",{children:y.label}),y.badge&&e.jsx("span",{className:"shrink-0",children:y.badge})]},y.id)})}),(b==null?void 0:b.content)!==void 0&&e.jsx("div",{role:"tabpanel",id:`${b.id}-panel`,"aria-labelledby":`${b.id}-tab`,className:`pt-4 ${u}`,children:b.content})]})}function yr(...r){return r.filter(Boolean).join(" ")}function $c({steps:r,activeStepId:t,initialStepId:n,completedStepIds:a,defaultCompletedStepIds:s=[],onActiveStepChange:l,onCompletedStepIdsChange:i,onBlockedStep:c,allowBackNavigation:u=!0,showFooter:f=!0,previousLabel:p="Anterior",nextLabel:b="Siguiente",blockedNextLabel:m="Completa este paso",className:v="",headerClassName:y="",contentClassName:S="",footerClassName:h=""}){var Q;const H=((Q=r[0])==null?void 0:Q.id)??"",[_,E]=o.useState(n??H),[L,N]=o.useState(s),k=t??_,K=a??L,P=o.useMemo(()=>new Set(K),[K]),q=Math.max(0,r.findIndex(V=>V.id===k)),X=r[q]??r[0],J=r.length<=1?100:q/(r.length-1)*100,C=V=>{a||N(V),i==null||i(V)},te=V=>{const w=r.find(R=>R.id===V);w&&(t||E(V),l==null||l(V,w))},j=V=>P.has(V),W=V=>r.slice(0,V).find(w=>!w.optional&&!P.has(w.id)),ae=V=>{const w=r[V];return!w||w.disabled?!1:V===q||u&&V<q?!0:!W(V)},Z=V=>{const w=r.findIndex(R=>R.id===V);return w>=0&&ae(w)},$=V=>{const w=r.findIndex(R=>R.id===V);if(w<0)return!1;if(!ae(w)){const R=W(w);return R&&(c==null||c(r[w],R)),!1}return te(V),!0},ee=(V=X==null?void 0:X.id)=>{!V||P.has(V)||C([...K,V])},se=(V=X==null?void 0:X.id)=>{if(!V)return;const w=r.findIndex(B=>B.id===V),R=K.filter(B=>{const re=r.findIndex(F=>F.id===B);return re>=0&&re<w});C(R),w>=0&&q>w&&te(V)},M=()=>q<=0?!1:$(r[q-1].id),O=()=>{const V=r[q+1];return V?$(V.id):!1},oe={activeStep:X,activeIndex:q,completedStepIds:K,isCompleted:j,isUnlocked:Z,completeStep:ee,uncompleteStep:se,goToStep:$,goNext:O,goPrevious:M};if(!X)return null;const A=r[q+1],U=q>0,ne=A?Z(A.id):!1,ie=typeof X.content=="function"?X.content(oe):X.content;return e.jsxs("section",{className:yr("overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)]",v),children:[e.jsxs("div",{className:yr("border-b border-[var(--border)] bg-[var(--bg-input)]",y),children:[e.jsx("div",{className:"relative h-1 overflow-hidden bg-[var(--border)]/55",children:e.jsx("div",{className:"h-full rounded-r-full bg-[var(--primary)] transition-[width] duration-500 ease-out",style:{width:`${J}%`}})}),e.jsx("div",{className:"grid gap-2 p-2",style:{gridTemplateColumns:`repeat(${r.length}, minmax(0, 1fr))`},children:r.map((V,w)=>{const R=V.id===X.id,B=j(V.id),re=ae(w),F=W(w);return e.jsxs("button",{type:"button",disabled:!re,"aria-current":R?"step":void 0,"aria-disabled":!re,title:!re&&F?`Completa ${F.title}`:V.title,onClick:()=>$(V.id),className:yr("group relative min-h-16 min-w-0 overflow-hidden rounded-md border p-3 text-left transition-all duration-200 focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--primary)]/35 disabled:cursor-not-allowed",R&&"border-[var(--primary)] bg-[var(--bg-card)] shadow-sm",B&&!R&&"border-[var(--primary)]/35 bg-[var(--bg-card)]",!R&&!B&&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:[e.jsx("span",{className:yr("absolute inset-x-0 top-0 h-0.5 origin-left scale-x-0 bg-[var(--primary)] transition-transform duration-300",R&&"scale-x-100")}),e.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:yr("grid h-7 w-7 shrink-0 place-items-center rounded-full border text-xs font-bold transition-all duration-200",R&&"border-[var(--primary)] bg-[var(--primary)] text-[var(--primary-fg)]",B&&!R&&"border-[var(--primary)] bg-[var(--primary)]/12 text-[var(--primary)]",!B&&!R&&re&&"border-[var(--border)] text-[var(--text-muted)]",!re&&"border-[var(--border)] text-[var(--text-muted)]"),children:B?e.jsx(T.HiCheck,{className:"h-4 w-4"}):re?w+1:e.jsx(T.HiLockClosed,{className:"h-3.5 w-3.5"})}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsxs("span",{className:yr("block truncate text-xs font-semibold transition-colors duration-200",R?"text-[var(--text-main)]":"text-[var(--text-secondary)]"),children:[w+1,". ",V.title]}),V.description&&e.jsx("span",{className:"mt-1 block truncate text-[11px] text-[var(--text-muted)]",children:V.description})]}),V.badge&&e.jsx("span",{className:"shrink-0",children:V.badge})]})]},V.id)})})]}),e.jsx("div",{className:yr("min-h-72 animate-[stepWizardIn_220ms_ease-out] p-5",S),children:ie},X.id),f&&e.jsxs("div",{className:yr("flex flex-wrap items-center justify-between gap-3 border-t border-[var(--border)] bg-[var(--bg-input)] px-4 py-3",h),children:[e.jsx(Fe,{variant:"secondary",height:38,padding:"0 14px",icon:e.jsx(T.HiChevronLeft,{}),disabled:!U,onClick:M,children:p}),e.jsxs("div",{className:"flex items-center gap-3 text-xs text-[var(--text-muted)]",children:[e.jsxs("span",{children:["Paso ",q+1," de ",r.length]}),e.jsx("span",{className:"h-1 w-1 rounded-full bg-[var(--border)]"}),e.jsxs("span",{children:[K.length," completados"]})]}),e.jsx(Fe,{height:38,padding:"0 14px",icon:e.jsx(T.HiChevronRight,{}),disabled:!A||!ne,onClick:O,children:A&&!ne?m:b})]})]})}const Ac={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"},Dc={none:"resize-none",vertical:"resize-y",horizontal:"resize-x",both:"resize"};function Ic(r,t){if(r){if(typeof r=="function"){r(t);return}r.current=t}}function Bc(r,t){return r!==void 0?String(r).length:t!==void 0?String(t).length:0}const Ho=o.forwardRef(function({className:t="",wrapperClassName:n="",size:a="md",resize:s="vertical",autoResize:l=!1,minRows:i,maxRows:c,showCount:u=!1,maxCount:f,status:p="default",icon:b,action:m,style:v,value:y,defaultValue:S,maxLength:h,onInput:H,..._},E){const L=o.useRef(null),N=Bc(y,S),k=f??h,K=!!(b||m||u),P=p==="error"?"var(--danger)":p==="success"?"#16a34a":"var(--border)",q={...v??{},...i?{minHeight:`${i*24+18}px`}:null,...c?{maxHeight:`${c*24+18}px`}:null},X=()=>{const C=L.current;!C||!l||(C.style.height="auto",C.style.height=`${C.scrollHeight}px`)};o.useEffect(X,[l,y]);const J=e.jsx("textarea",{..._,ref:C=>{L.current=C,Ic(E,C)},value:y,defaultValue:S,maxLength:h,"aria-invalid":p==="error"||_["aria-invalid"],onInput:C=>{X(),H==null||H(C)},style:{...q,borderColor:P},className:`w-full rounded-lg border bg-[var(--bg-input)] text-[var(--text-main)] outline-none placeholder:text-[var(--text-muted)] transition-colors focus:border-[var(--primary)] disabled:cursor-not-allowed disabled:opacity-60 ${Ac[a]} ${Dc[l?"none":s]} ${b?"pl-8":""} ${m?"pr-10":""} ${t}`});return K?e.jsxs("span",{className:`relative block ${n}`,children:[b&&e.jsx("span",{className:"pointer-events-none absolute left-2.5 top-2.5 flex h-4 w-4 items-center justify-center text-[var(--text-muted)]",children:b}),J,m&&e.jsx("span",{className:"absolute right-2 top-2 flex items-center justify-center",children:m}),u&&e.jsxs("span",{className:"absolute bottom-1.5 right-2 rounded bg-[var(--bg-input)] px-1.5 text-[10px] font-semibold text-[var(--text-muted)]",children:[N,k?`/${k}`:""]})]}):J});function Oc({label:r,containerClassName:t="",helperText:n,helperDisplay:a,error:s,labelAction:l,required:i,className:c="",status:u,...f}){return e.jsx(uo,{label:r,required:i,helperText:n,helperDisplay:a,error:s,labelAction:l,className:t,children:e.jsx(Ho,{...f,required:i,status:s?"error":u,className:`w-full ${c}`})})}const Po=[{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 Hc(r){return Po[r%Po.length]}let Pc=0;function la(){return++Pc}function Fo(r,t){return t?t instanceof RegExp?t.test(r):t(r):!0}function Fc(r){return r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function zc(r,t){const n=t.filter(Boolean);if(n.length===0)return[r.trim()].filter(Boolean);const a=new RegExp(`${n.map(s=>Fc(s)).join("|")}|\\r?\\n`,"g");return r.split(a).map(s=>s.trim()).filter(Boolean)}function _c({value:r,defaultValue:t,onChange:n,placeholder:a="Escribe y presiona Enter…",disabled:s=!1,className:l="",delimiters:i=[","],maxTags:c,allowDuplicates:u=!1,validate:f,label:p,helperText:b,helperDisplay:m="inline",error:v,required:y=!1}){const S=r!==void 0,h=!!v,H=!!b&&m==="tooltip"&&!h,[_,E]=o.useState(()=>(t??[]).map((B,re)=>({id:la(),value:B.trim(),colorIndex:re})));o.useEffect(()=>{S&&E(B=>{const re=r??[],F=new Map(B.map(le=>[le.value,le]));return re.map((le,Ee)=>F.get(le)??{id:la(),value:le,colorIndex:Ee})})},[S,r]);const L=_,[N,k]=o.useState(""),[K,P]=o.useState(null),[q,X]=o.useState(""),[J,C]=o.useState(!1),[te,j]=o.useState(!1),W=o.useRef(null),ae=o.useRef(null),Z=o.useRef(null);function $(){j(!0),setTimeout(()=>j(!1),400)}function ee(B){E(B),n==null||n(B.map(re=>re.value))}function se(B){let re=L,F=!1,le=!1;for(const Ee of B){const Le=Ee.trim();if(Le){if(c!==void 0&&re.length>=c){le=!0;break}if(!u&&re.some(xe=>xe.value.toLowerCase()===Le.toLowerCase())){le=!0;continue}if(!Fo(Le,f)){le=!0;continue}re=[...re,{id:la(),value:Le,colorIndex:re.length}],F=!0}}return F&&ee(re),le&&$(),F}function M(B){return se([B])}function O(B){const re=L.filter(F=>F.id!==B);ee(re.map((F,le)=>({...F,colorIndex:le})))}function oe(B,re){const F=re.trim();if(P(null),X(""),!F){O(B);return}if(!(!u&&L.some(le=>le.id!==B&&le.value.toLowerCase()===F.toLowerCase()))){if(!Fo(F,f)){$();return}ee(L.map(le=>le.id===B?{...le,value:F}:le))}}function A(B){s||(P(B.id),X(B.value),setTimeout(()=>{var re;return(re=ae.current)==null?void 0:re.select()},0))}function U(B){if(B.key==="Enter"||i.includes(B.key)){B.preventDefault(),M(N)&&k("");return}if(B.key==="Backspace"&&N===""&&L.length>0){B.preventDefault();const re=L[L.length-1];O(re.id)}}function ne(B,re){if(B.key==="Enter"){B.preventDefault(),oe(re,q),setTimeout(()=>{var F;return(F=W.current)==null?void 0:F.focus()},0);return}B.key==="Escape"&&(B.preventDefault(),P(null),X(""),setTimeout(()=>{var F;return(F=W.current)==null?void 0:F.focus()},0))}function ie(){var B;s||(B=W.current)==null||B.focus()}function Q(B){if(s)return;const re=B.clipboardData.getData("text");if(!re||!(i.some(Le=>Le&&re.includes(Le))||re.includes(`
|
|
29
|
-
`)))return;B.preventDefault();const le=
|
|
28
|
+
`).replace(/<[^>]+>/g," ").replace(/ /g," ").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'").replace(/\s+/g," ").trim():""}function aa(r){if(!r)return[];const t=new Set,n=[],a=u=>{const f=na(u);!f||t.has(f)||(t.add(f),n.push(f))},s=/data-username\s*=\s*["']([^"']+)["']/gi;let l;for(;(l=s.exec(r))!==null;)a(l[1]??"");const i=Eo(r);ra.lastIndex=0;let c;for(;(c=ra.exec(i))!==null;)a(c[1]??"");return n}function Mo(r){const t=String(r.name??"").trim();return t||String(r.username??"").trim()||"usuario"}function pc(r,t){const n=aa(r);if(!n.length)return[];const a=new Map;t.forEach(i=>{i.username&&a.set(na(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 Lo(r){const t=new Set,n=[];for(const a of r)t.has(a.userId)||(t.add(a.userId),n.push(a));return n}function mc(r,t){return t?r.filter(n=>n.userId!==t):r}function To(r){return!r||!/@/.test(r)?r:r.replace(ra,(t,n,a,s)=>{const l=s.slice(0,a),i=l.lastIndexOf("<"),c=l.lastIndexOf(">");return i>c?t:`<span class="mention-chip" contenteditable="false" data-username="${(n??"").toLowerCase()}">${t}</span>`})}function Yr(r,t){if(t<0)return null;const n=r.ownerDocument;if(!n)return null;const a=n.createTreeWalker(r,NodeFilter.SHOW_TEXT);let s=t,l=null,i=a.nextNode();for(;i;){l=i;const c=i.data.length;if(s<=c)return{node:i,offset:s};s-=c,i=a.nextNode()}return l&&s===0?{node:l,offset:l.data.length}:null}function oa(r,t,n){var s;const a=r.ownerDocument;if(!a||r!==t&&!r.contains(t))return-1;try{const l=a.createRange();return l.selectNodeContents(r),l.setEnd(t,n),((s=l.cloneContents().textContent)==null?void 0:s.length)??0}catch{return-1}}function $o(r,t){const{triggerIndex:n,caretIndex:a,username:s}=t;if(a<n)return null;const l=Yr(r,n),i=Yr(r,a);if(!l||!i)return null;const c=r.ownerDocument,u=c.createRange();u.setStart(l.node,l.offset),u.setEnd(i.node,i.offset),u.deleteContents();const f=Mo({name:t.display,username:s}),p=c.createElement("span");p.className="mention-chip",p.setAttribute("data-username",s.toLowerCase()),t.userId&&p.setAttribute("data-userid",String(t.userId)),p.contentEditable="false",p.textContent=f,p.title=`@${s}`;const b=c.createTextNode(" ");u.insertNode(b),u.insertNode(p);const m=c.defaultView,v=m==null?void 0:m.getSelection();if(v){const y=c.createRange();y.setStart(b,b.data.length),y.collapse(!0),v.removeAllRanges(),v.addRange(y)}return{caretPlainOffset:n+f.length+1}}function Ao(r,t){const n=r.ownerDocument,a=n.defaultView;if(!a)return;const s=a.getSelection();if(!s)return;const l=n.createRange(),i=Yr(r,t);i?(l.setStart(i.node,i.offset),l.collapse(!0)):(l.selectNodeContents(r),l.collapse(!1)),s.removeAllRanges(),s.addRange(l)}const sa=280,tn=6,Do=260,hc=new Set(["ArrowDown","ArrowUp","Enter","Tab","Escape"]),gc={position:"relative"},vc={position:"fixed",zIndex:11050,minWidth:Do,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},Io={padding:"10px 12px",fontSize:12,color:"var(--text-muted, #656d76)"};function xc(r){return Array.from(document.querySelectorAll(`[data-bonsaif-rich-instance="${CSS.escape(r)}"]`))}function yc(r,t){const n=Math.max(8,Math.min(r.left,window.innerWidth-Do-8)),a=t==null?void 0:t.getBoundingClientRect(),s=a?Math.min(window.innerHeight-8,a.bottom):window.innerHeight-8,l=a?Math.max(8,a.top):8,i=s-r.bottom-tn,c=r.top-l-tn;return i<Math.min(sa,160)&&c>i?{left:n,bottom:window.innerHeight-r.top+tn,maxHeight:Math.max(120,Math.min(sa,c))}:{left:n,top:r.bottom+tn,maxHeight:Math.max(120,Math.min(sa,i))}}function Bo({value:r,onChange:t,onSearchUsers:n,onMentionsChange:a,minHeight:s,placeholder:l,className:i,maxSuggestions:c=8,searchDebounceMs:u=140,highlightInEditor:f=!1,searchCacheKey:p=""}){const b=o.useId().replace(/:/g,""),m=o.useRef(null),v=o.useRef(null),y=o.useRef(new Map),S=o.useRef(n);S.current=n;const h=o.useRef(null),P=o.useRef(0),O=o.useRef([]),[E,L]=o.useState(null),[N,k]=o.useState([]),[Y,F]=o.useState(0),[U,V]=o.useState([]),[J,C]=o.useState(!1),[re,W]=o.useState(!1);P.current=Y,o.useEffect(()=>{W(!0)},[]);const j=(E==null?void 0:E.query)??null;o.useEffect(()=>{if(j===null){k([]);return}const A=j.trim(),q=`${p}|${A.toLowerCase()||"*"}`,ne=y.current.get(q);if(ne){k(ne),C(!1),F(0);return}const ie=new AbortController;C(!0);const Q=window.setTimeout(()=>{(async()=>{try{const G=await S.current(A,{signal:ie.signal,limit:c});if(ie.signal.aborted)return;const w=Array.isArray(G)?G:[];y.current.set(q,w),k(w),F(0)}catch{ie.signal.aborted||k([])}finally{ie.signal.aborted||C(!1)}})()},u);return()=>{ie.abort(),window.clearTimeout(Q)}},[j,c,u,p]);const ae=o.useRef(a);ae.current=a,o.useEffect(()=>{var A;(A=ae.current)==null||A.call(ae,Lo(U))},[U]);const Z=o.useCallback(()=>{const A=xc(b);if(A.length===0)return null;const q=window.getSelection();if(q!=null&&q.rangeCount){const ie=q.getRangeAt(0).startContainer;for(const Q of A)if(Q.contains(ie))return Q}const ne=document.activeElement;for(const ie of A)if(ne===ie||ne&&ie.contains(ne))return ie;for(const ie of A)if(ie.closest('[role="dialog"]'))return ie;return A[0]??null},[b]),$=o.useCallback(()=>{const A=Z(),q=window.getSelection();if(!A||!q||q.rangeCount===0){L(null);return}const ne=q.getRangeAt(0);if(!A.contains(ne.startContainer)){L(null);return}const ie=oa(A,ne.startContainer,ne.startOffset);if(ie<0){L(null);return}const Q=ta(A,ie);if(!Q){L(null);return}const G=ne.getBoundingClientRect(),w=G.width===0&&G.height===0?(()=>{const B=document.createRange();return B.selectNodeContents(ne.startContainer),B.collapse(!0),B.getBoundingClientRect()})():G;h.current={query:Q.query,caretIndex:Q.caretIndex,triggerIndex:Q.triggerIndex};const R=yc(w,A);L(B=>{const te={query:Q.query,...R};return B&&B.query===te.query&&B.top===te.top&&B.bottom===te.bottom&&B.left===te.left&&B.maxHeight===te.maxHeight?B:te})},[Z]),ee=o.useCallback(A=>{t(A),$()},[t,$]);o.useEffect(()=>{const A=q=>{if(hc.has(q.key))return;const ne=Z(),ie=q.target;!ne||!ie||!ne.contains(ie)||$()};return document.addEventListener("keyup",A,!0),()=>document.removeEventListener("keyup",A,!0)},[Z,$]);const se=o.useCallback(A=>{const q=Z();if(!q)return;let ne=-1;const ie=window.getSelection();if(ie&&ie.rangeCount>0){const B=ie.getRangeAt(0);q.contains(B.startContainer)&&(ne=oa(q,B.startContainer,B.startOffset))}if(ne<0&&h.current&&(ne=h.current.caretIndex),ne<0)return;const Q=ta(q,ne);if(!Q)return;const G=$o(q,{triggerIndex:Q.triggerIndex,caretIndex:ne,username:A.username,display:A.name,userId:A.userId});if(!G)return;t(q.innerHTML);const w={userId:A.userId,username:A.username,email:A.email??void 0,display:A.name??A.username};V(B=>{const te=new Map(B.map(z=>[z.userId,z]));return te.set(w.userId,w),Array.from(te.values())}),L(null),h.current=null;const R=G.caretPlainOffset;requestAnimationFrame(()=>{requestAnimationFrame(()=>{var Ee,Le;const B=Z();if(!B)return;B.focus(),Ao(B,R);const te=window.getSelection(),z=te==null?void 0:te.anchorNode,le=z instanceof Element?z.closest(".mention-chip"):(Ee=z==null?void 0:z.parentElement)==null?void 0:Ee.closest(".mention-chip");if(le!=null&&le.parentNode){const xe=document.createRange(),Se=le.nextSibling;Se&&Se.nodeType===Node.TEXT_NODE?xe.setStart(Se,((Le=Se.textContent)==null?void 0:Le.length)??0):xe.setStartAfter(le),xe.collapse(!0),te==null||te.removeAllRanges(),te==null||te.addRange(xe)}})})},[Z,t]);o.useEffect(()=>{const A=new Set(aa(r).map(q=>q.toLowerCase()));V(q=>{const ne=q.filter(ie=>A.has(ie.username.toLowerCase()));return ne.length===q.length?q:ne})},[r]),o.useEffect(()=>{if(!E)return;const A=q=>{const ne=q.target;if(!ne||m.current&&m.current.contains(ne)||v.current&&v.current.contains(ne))return;const ie=Z();ie&&ie.contains(ne)||L(null)};return document.addEventListener("mousedown",A),()=>{document.removeEventListener("mousedown",A)}},[E,Z]);const M=o.useMemo(()=>N.slice(0,c),[N,c]);O.current=M,o.useEffect(()=>{if(!E)return;const A=q=>{const ne=Z(),ie=q.target;if(!ne||!ie||!ne.contains(ie))return;const Q=O.current;if(!(Q.length===0&&q.key!=="Escape"))if(q.key==="ArrowDown")q.preventDefault(),q.stopPropagation(),F(G=>(G+1)%Math.max(Q.length,1));else if(q.key==="ArrowUp")q.preventDefault(),q.stopPropagation(),F(G=>(G-1+Q.length)%Math.max(Q.length,1));else if(q.key==="Enter"||q.key==="Tab"){const G=Q[P.current];G&&(q.preventDefault(),q.stopPropagation(),se(G))}else q.key==="Escape"&&(q.preventDefault(),q.stopPropagation(),L(null))};return document.addEventListener("keydown",A,!0),()=>document.removeEventListener("keydown",A,!0)},[Z,se,E]),o.useEffect(()=>{if(!E||!v.current)return;const A=v.current.querySelector(`[data-mention-index="${Y}"]`);A==null||A.scrollIntoView({block:"nearest"})},[Y,E]);const H=f?To(r):r,oe=E&&re?er.createPortal(e.jsxs("ul",{ref:v,style:{...vc,left:E.left,top:E.top,bottom:E.bottom,maxHeight:E.maxHeight},role:"listbox","aria-label":"Menciones sugeridas",children:[J&&M.length===0&&e.jsx("li",{style:Io,children:"Buscando…"}),!J&&M.length===0&&e.jsx("li",{style:Io,children:E.query.trim().length===0?"Escribe un nombre o usuario":`Sin coincidencias para “${E.query}”`}),M.map((A,q)=>{var ne,ie;return e.jsx("li",{children:e.jsxs("button",{type:"button","data-mention-index":q,onMouseDown:Q=>{Q.preventDefault(),se(A)},onMouseEnter:()=>F(q),style:{width:"100%",textAlign:"left",padding:"8px 10px",border:"none",background:q===Y?"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:[e.jsx("span",{style:{fontWeight:600,fontSize:13},children:((ne=A.name)==null?void 0:ne.trim())||`@${A.username}`}),e.jsx("span",{style:{fontSize:11,color:"var(--text-muted, #656d76)"},children:[(ie=A.name)!=null&&ie.trim()?`@${A.username}`:null,A.email].filter(Boolean).join(" · ")||`@${A.username}`})]})},A.userId)})]}),document.body):null;return e.jsxs("div",{ref:m,style:gc,className:i,children:[e.jsx(yo,{value:H,onChange:ee,placeholder:l,minHeight:s,instanceId:b}),oe]})}function wc({value:r,onChange:t,placeholder:n,minHeight:a,onSearchUsers:s,onMentionsChange:l,className:i,maxSuggestions:c,searchDebounceMs:u,highlightInEditor:f,searchCacheKey:p}){return s?e.jsx(Bo,{value:r,onChange:t,onSearchUsers:s,onMentionsChange:l,placeholder:n,minHeight:a,className:i,maxSuggestions:c,searchDebounceMs:u,highlightInEditor:f,searchCacheKey:p}):e.jsx(yo,{value:r,onChange:t,placeholder:n,minHeight:a})}function kc({title:r,subtitle:t,icon:n,actions:a,children:s,footer:l,className:i="",bodyClassName:c="p-4"}){const u=r||t||n||a;return e.jsxs("section",{className:`overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${i}`,children:[u&&e.jsxs("header",{className:"flex items-center justify-between gap-3 border-b border-[var(--border)] px-4 py-3",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[n&&e.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-input)] text-[var(--primary)]",children:n}),e.jsxs("div",{className:"min-w-0",children:[r&&e.jsx("h3",{className:"truncate text-sm font-semibold text-[var(--text-main)]",children:r}),t&&e.jsx("div",{className:"truncate text-xs text-[var(--text-muted)]",children:t})]})]}),a&&e.jsx("div",{className:"shrink-0",children:a})]}),e.jsx("div",{className:c,children:s}),l&&e.jsx("footer",{className:"border-t border-[var(--border)] px-4 py-3",children:l})]})}const Nc={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)"}},Sc={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 Cc({children:r,tone:t="neutral",size:n="sm",icon:a,dot:s=!1,className:l=""}){const i=Nc[t];return e.jsxs("span",{className:`inline-flex max-w-full shrink-0 items-center gap-1.5 rounded-full border font-semibold leading-none ${Sc[n]} ${l}`,style:{color:i.text,background:i.bg,borderColor:i.border},children:[s&&e.jsx("span",{"aria-hidden":"true",className:"h-1.5 w-1.5 shrink-0 rounded-full",style:{background:i.text}}),a&&e.jsx("span",{className:"shrink-0",children:a}),e.jsx("span",{className:"min-w-0 truncate",children:r})]})}const Oo={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)"}},Ec={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"},Mc={xs:"right-1 h-3 w-3",sm:"right-1.5 h-3 w-3",md:"right-2 h-3.5 w-3.5"},Lc={xs:148,sm:164,md:184},Tc={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 $c({value:r,options:t,onChange:n,size:a="sm",disabled:s=!1,loading:l=!1,stopPropagation:i=!1,ariaLabel:c="Cambiar estado",title:u="Cambiar estado",className:f,selectClassName:p,menuClassName:b,optionClassName:m,spinnerClassName:v}){const[y,S]=o.useState(!1),[h,P]=o.useState(!1),[O,E]=o.useState(-1),[L,N]=o.useState({}),k=o.useRef(null),Y=o.useRef(null),F=o.useRef(null),U=t.find($=>$.value===r)??t[0],V={...U!=null&&U.tone?Oo[U.tone]:void 0,...U==null?void 0:U.style},J=s||l||t.length===0,C=$=>{i&&$.stopPropagation()},re=o.useCallback(()=>{S(!1),E(-1)},[]),W=o.useCallback(()=>{const $=k.current;if(!$)return;const ee=$.getBoundingClientRect(),se=Math.max(ee.width,Lc[a]),M=Math.min(Math.max(t.length,1)*38+12,260),H=window.innerHeight-ee.bottom,oe=H<M&&ee.top>H,A=Math.min(Math.max(8,ee.left+ee.width/2-se/2),window.innerWidth-se-8);N({position:"fixed",left:A,top:oe?void 0:ee.bottom+6,bottom:oe?window.innerHeight-ee.top+6:void 0,width:se,zIndex:9999})},[t.length,a]),j=o.useCallback($=>{$.disabled||(n($.value),re())},[re,n]);o.useEffect(()=>P(!0),[]),o.useEffect(()=>{if(!y)return;W();const $=t.findIndex(ee=>ee.value===r);E($>=0?$:0)},[y,t,W,r]),o.useEffect(()=>{if(!y)return;function $(ee){var M,H;const se=ee.target;!((M=k.current)!=null&&M.contains(se))&&!((H=Y.current)!=null&&H.contains(se))&&re()}return document.addEventListener("mousedown",$),()=>document.removeEventListener("mousedown",$)},[re,y]),o.useEffect(()=>{if(y)return window.addEventListener("resize",W),window.addEventListener("scroll",W,!0),()=>{window.removeEventListener("resize",W),window.removeEventListener("scroll",W,!0)}},[y,W]),o.useEffect(()=>{if(O<0||!F.current)return;const $=F.current.children[O];$==null||$.scrollIntoView({block:"nearest"})},[O]);function ae($){if(!J){if(!y){["Enter"," ","ArrowDown","ArrowUp"].includes($.key)&&($.preventDefault(),S(!0));return}if($.key==="Escape"){$.preventDefault(),re();return}if($.key==="ArrowDown"){$.preventDefault(),E(ee=>Math.min(ee+1,t.length-1));return}if($.key==="ArrowUp"){$.preventDefault(),E(ee=>Math.max(ee-1,0));return}if($.key==="Enter"||$.key===" "){$.preventDefault();const ee=t[O];ee&&j(ee)}}}const Z=e.jsx("div",{ref:Y,role:"listbox","aria-label":c,className:gr("overflow-hidden rounded-xl border shadow-xl backdrop-blur-md",b),style:{...L,background:"color-mix(in srgb, var(--bg-card) 92%, transparent)",borderColor:"var(--border)",color:"var(--text-main)"},onClick:C,onMouseDown:C,onPointerDown:C,children:e.jsx("div",{ref:F,className:"max-h-64 overflow-y-auto p-1",style:{scrollbarWidth:"thin",scrollbarColor:"var(--border) transparent",overscrollBehavior:"contain"},children:t.map(($,ee)=>{const se=$.value===r,M=ee===O,H={...$.tone?Oo[$.tone]:void 0,...$.style};return e.jsxs("button",{type:"button",role:"option","aria-selected":se,disabled:$.disabled,onMouseEnter:()=>!$.disabled&&E(ee),onMouseDown:oe=>{oe.preventDefault(),j($)},className:gr("flex w-full items-center gap-2 rounded-lg font-medium text-left transition-colors disabled:cursor-not-allowed disabled:opacity-45",Tc[a],se?$.className:void 0,m),style:{...se?H:void 0,background:se?H.background??"color-mix(in srgb, var(--primary) 12%, transparent)":M?"var(--bg-hover)":"transparent",color:se?H.color??"var(--primary)":"var(--text-main)"},children:[e.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center",children:se?e.jsx(T.HiCheck,{className:"h-4 w-4"}):null}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:$.label})]},$.value)})})});return e.jsxs("span",{ref:k,className:gr("relative inline-flex shrink-0 items-center",f),onKeyDown:ae,onClick:C,onPointerDown:C,children:[e.jsx("button",{type:"button",disabled:J,"aria-label":c,"aria-haspopup":"listbox","aria-expanded":y,title:u,onClick:()=>!J&&S($=>!$),className:gr("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",Ec[a],U==null?void 0:U.className,p),style:V,children:e.jsx("span",{className:"min-w-0 truncate",children:(U==null?void 0:U.label)??r})}),e.jsx(T.HiChevronDown,{"aria-hidden":"true",className:gr("pointer-events-none absolute opacity-70 transition-transform",Mc[a],y?"rotate-180":"rotate-0")}),l&&e.jsx("span",{"aria-hidden":"true",className:gr("absolute -right-1 -top-1 h-2.5 w-2.5 rounded-full border border-current border-t-transparent animate-spin",v)}),y&&h&&er.createPortal(Z,document.body)]})}function Ac({tabs:r,activeTabId:t,defaultActiveTabId:n,onTabChange:a,ariaLabel:s="Pestanas",variant:l="underline",className:i="",listClassName:c="",panelClassName:u=""}){const f=r.find(y=>!y.disabled)??r[0],p=t??n??(f==null?void 0:f.id),b=r.find(y=>y.id===p)??f,m=y=>{y.disabled||a==null||a(y.id)},v=y=>{const S=r.filter(P=>!P.disabled);if(!S.length||!b)return;const h=S.findIndex(P=>P.id===b.id);(y.key==="ArrowRight"||y.key==="ArrowDown")&&(y.preventDefault(),m(S[(h+1)%S.length])),(y.key==="ArrowLeft"||y.key==="ArrowUp")&&(y.preventDefault(),m(S[(h-1+S.length)%S.length])),y.key==="Home"&&(y.preventDefault(),m(S[0])),y.key==="End"&&(y.preventDefault(),m(S[S.length-1]))};return e.jsxs("div",{className:i,children:[e.jsx("div",{role:"tablist","aria-label":s,onKeyDown:v,className:`flex min-w-0 gap-1 overflow-x-auto ${l==="underline"?"border-b border-[var(--border)]":"rounded-lg border border-[var(--border)] bg-[var(--bg-input)] p-1"} ${c}`,children:r.map(y=>{const S=y.id===(b==null?void 0:b.id);return e.jsxs("button",{type:"button",role:"tab","aria-selected":S,"aria-controls":`${y.id}-panel`,id:`${y.id}-tab`,disabled:y.disabled,tabIndex:S?0:-1,onClick:()=>m(y),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:S?"var(--primary)":"var(--text-muted)",borderColor:S?"var(--primary)":"transparent",background:l==="pills"&&S?"var(--bg-card)":"transparent"},children:[y.icon&&e.jsx("span",{className:"shrink-0",children:y.icon}),e.jsx("span",{children:y.label}),y.badge&&e.jsx("span",{className:"shrink-0",children:y.badge})]},y.id)})}),(b==null?void 0:b.content)!==void 0&&e.jsx("div",{role:"tabpanel",id:`${b.id}-panel`,"aria-labelledby":`${b.id}-tab`,className:`pt-4 ${u}`,children:b.content})]})}function yr(...r){return r.filter(Boolean).join(" ")}function Dc({steps:r,activeStepId:t,initialStepId:n,completedStepIds:a,defaultCompletedStepIds:s=[],onActiveStepChange:l,onCompletedStepIdsChange:i,onBlockedStep:c,allowBackNavigation:u=!0,showFooter:f=!0,previousLabel:p="Anterior",nextLabel:b="Siguiente",blockedNextLabel:m="Completa este paso",className:v="",headerClassName:y="",contentClassName:S="",footerClassName:h=""}){var Q;const P=((Q=r[0])==null?void 0:Q.id)??"",[O,E]=o.useState(n??P),[L,N]=o.useState(s),k=t??O,Y=a??L,F=o.useMemo(()=>new Set(Y),[Y]),U=Math.max(0,r.findIndex(G=>G.id===k)),V=r[U]??r[0],J=r.length<=1?100:U/(r.length-1)*100,C=G=>{a||N(G),i==null||i(G)},re=G=>{const w=r.find(R=>R.id===G);w&&(t||E(G),l==null||l(G,w))},W=G=>F.has(G),j=G=>r.slice(0,G).find(w=>!w.optional&&!F.has(w.id)),ae=G=>{const w=r[G];return!w||w.disabled?!1:G===U||u&&G<U?!0:!j(G)},Z=G=>{const w=r.findIndex(R=>R.id===G);return w>=0&&ae(w)},$=G=>{const w=r.findIndex(R=>R.id===G);if(w<0)return!1;if(!ae(w)){const R=j(w);return R&&(c==null||c(r[w],R)),!1}return re(G),!0},ee=(G=V==null?void 0:V.id)=>{!G||F.has(G)||C([...Y,G])},se=(G=V==null?void 0:V.id)=>{if(!G)return;const w=r.findIndex(B=>B.id===G),R=Y.filter(B=>{const te=r.findIndex(z=>z.id===B);return te>=0&&te<w});C(R),w>=0&&U>w&&re(G)},M=()=>U<=0?!1:$(r[U-1].id),H=()=>{const G=r[U+1];return G?$(G.id):!1},oe={activeStep:V,activeIndex:U,completedStepIds:Y,isCompleted:W,isUnlocked:Z,completeStep:ee,uncompleteStep:se,goToStep:$,goNext:H,goPrevious:M};if(!V)return null;const A=r[U+1],q=U>0,ne=A?Z(A.id):!1,ie=typeof V.content=="function"?V.content(oe):V.content;return e.jsxs("section",{className:yr("overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)]",v),children:[e.jsxs("div",{className:yr("border-b border-[var(--border)] bg-[var(--bg-input)]",y),children:[e.jsx("div",{className:"relative h-1 overflow-hidden bg-[var(--border)]/55",children:e.jsx("div",{className:"h-full rounded-r-full bg-[var(--primary)] transition-[width] duration-500 ease-out",style:{width:`${J}%`}})}),e.jsx("div",{className:"grid gap-2 p-2",style:{gridTemplateColumns:`repeat(${r.length}, minmax(0, 1fr))`},children:r.map((G,w)=>{const R=G.id===V.id,B=W(G.id),te=ae(w),z=j(w);return e.jsxs("button",{type:"button",disabled:!te,"aria-current":R?"step":void 0,"aria-disabled":!te,title:!te&&z?`Completa ${z.title}`:G.title,onClick:()=>$(G.id),className:yr("group relative min-h-16 min-w-0 overflow-hidden rounded-md border p-3 text-left transition-all duration-200 focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--primary)]/35 disabled:cursor-not-allowed",R&&"border-[var(--primary)] bg-[var(--bg-card)] shadow-sm",B&&!R&&"border-[var(--primary)]/35 bg-[var(--bg-card)]",!R&&!B&&te&&"border-transparent bg-[var(--bg-card)]/45 hover:border-[var(--border)] hover:bg-[var(--bg-card)]",!te&&"border-transparent bg-[var(--bg-card)]/35 opacity-60"),children:[e.jsx("span",{className:yr("absolute inset-x-0 top-0 h-0.5 origin-left scale-x-0 bg-[var(--primary)] transition-transform duration-300",R&&"scale-x-100")}),e.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:yr("grid h-7 w-7 shrink-0 place-items-center rounded-full border text-xs font-bold transition-all duration-200",R&&"border-[var(--primary)] bg-[var(--primary)] text-[var(--primary-fg)]",B&&!R&&"border-[var(--primary)] bg-[var(--primary)]/12 text-[var(--primary)]",!B&&!R&&te&&"border-[var(--border)] text-[var(--text-muted)]",!te&&"border-[var(--border)] text-[var(--text-muted)]"),children:B?e.jsx(T.HiCheck,{className:"h-4 w-4"}):te?w+1:e.jsx(T.HiLockClosed,{className:"h-3.5 w-3.5"})}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsxs("span",{className:yr("block truncate text-xs font-semibold transition-colors duration-200",R?"text-[var(--text-main)]":"text-[var(--text-secondary)]"),children:[w+1,". ",G.title]}),G.description&&e.jsx("span",{className:"mt-1 block truncate text-[11px] text-[var(--text-muted)]",children:G.description})]}),G.badge&&e.jsx("span",{className:"shrink-0",children:G.badge})]})]},G.id)})})]}),e.jsx("div",{className:yr("min-h-72 animate-[stepWizardIn_220ms_ease-out] p-5",S),children:ie},V.id),f&&e.jsxs("div",{className:yr("flex flex-wrap items-center justify-between gap-3 border-t border-[var(--border)] bg-[var(--bg-input)] px-4 py-3",h),children:[e.jsx(Fe,{variant:"secondary",height:38,padding:"0 14px",icon:e.jsx(T.HiChevronLeft,{}),disabled:!q,onClick:M,children:p}),e.jsxs("div",{className:"flex items-center gap-3 text-xs text-[var(--text-muted)]",children:[e.jsxs("span",{children:["Paso ",U+1," de ",r.length]}),e.jsx("span",{className:"h-1 w-1 rounded-full bg-[var(--border)]"}),e.jsxs("span",{children:[Y.length," completados"]})]}),e.jsx(Fe,{height:38,padding:"0 14px",icon:e.jsx(T.HiChevronRight,{}),disabled:!A||!ne,onClick:H,children:A&&!ne?m:b})]})]})}const Ic={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"},Bc={none:"resize-none",vertical:"resize-y",horizontal:"resize-x",both:"resize"};function Oc(r,t){if(r){if(typeof r=="function"){r(t);return}r.current=t}}function Hc(r,t){return r!==void 0?String(r).length:t!==void 0?String(t).length:0}const Ho=o.forwardRef(function({className:t="",wrapperClassName:n="",size:a="md",resize:s="vertical",autoResize:l=!1,minRows:i,maxRows:c,showCount:u=!1,maxCount:f,status:p="default",icon:b,action:m,style:v,value:y,defaultValue:S,maxLength:h,onInput:P,...O},E){const L=o.useRef(null),N=Hc(y,S),k=f??h,Y=!!(b||m||u),F=p==="error"?"var(--danger)":p==="success"?"#16a34a":"var(--border)",U={...v??{},...i?{minHeight:`${i*24+18}px`}:null,...c?{maxHeight:`${c*24+18}px`}:null},V=()=>{const C=L.current;!C||!l||(C.style.height="auto",C.style.height=`${C.scrollHeight}px`)};o.useEffect(V,[l,y]);const J=e.jsx("textarea",{...O,ref:C=>{L.current=C,Oc(E,C)},value:y,defaultValue:S,maxLength:h,"aria-invalid":p==="error"||O["aria-invalid"],onInput:C=>{V(),P==null||P(C)},style:{...U,borderColor:F},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 ${Ic[a]} ${Bc[l?"none":s]} ${b?"pl-8":""} ${m?"pr-10":""} ${t}`});return Y?e.jsxs("span",{className:`relative block ${n}`,children:[b&&e.jsx("span",{className:"pointer-events-none absolute left-2.5 top-2.5 flex h-4 w-4 items-center justify-center text-[var(--text-muted)]",children:b}),J,m&&e.jsx("span",{className:"absolute right-2 top-2 flex items-center justify-center",children:m}),u&&e.jsxs("span",{className:"absolute bottom-1.5 right-2 rounded bg-[var(--bg-input)] px-1.5 text-[10px] font-semibold text-[var(--text-muted)]",children:[N,k?`/${k}`:""]})]}):J});function Pc({label:r,containerClassName:t="",helperText:n,helperDisplay:a,error:s,labelAction:l,required:i,className:c="",status:u,...f}){return e.jsx(uo,{label:r,required:i,helperText:n,helperDisplay:a,error:s,labelAction:l,className:t,children:e.jsx(Ho,{...f,required:i,status:s?"error":u,className:`w-full ${c}`})})}const Po=[{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 Fc(r){return Po[r%Po.length]}let zc=0;function la(){return++zc}function Fo(r,t){return t?t instanceof RegExp?t.test(r):t(r):!0}function _c(r){return r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function jc(r,t){const n=t.filter(Boolean);if(n.length===0)return[r.trim()].filter(Boolean);const a=new RegExp(`${n.map(s=>_c(s)).join("|")}|\\r?\\n`,"g");return r.split(a).map(s=>s.trim()).filter(Boolean)}function Wc({value:r,defaultValue:t,onChange:n,placeholder:a="Escribe y presiona Enter…",disabled:s=!1,className:l="",delimiters:i=[","],maxTags:c,allowDuplicates:u=!1,validate:f,label:p,helperText:b,helperDisplay:m="inline",error:v,required:y=!1}){const S=r!==void 0,h=!!v,P=!!b&&m==="tooltip"&&!h,[O,E]=o.useState(()=>(t??[]).map((B,te)=>({id:la(),value:B.trim(),colorIndex:te})));o.useEffect(()=>{S&&E(B=>{const te=r??[],z=new Map(B.map(le=>[le.value,le]));return te.map((le,Ee)=>z.get(le)??{id:la(),value:le,colorIndex:Ee})})},[S,r]);const L=O,[N,k]=o.useState(""),[Y,F]=o.useState(null),[U,V]=o.useState(""),[J,C]=o.useState(!1),[re,W]=o.useState(!1),j=o.useRef(null),ae=o.useRef(null),Z=o.useRef(null);function $(){W(!0),setTimeout(()=>W(!1),400)}function ee(B){E(B),n==null||n(B.map(te=>te.value))}function se(B){let te=L,z=!1,le=!1;for(const Ee of B){const Le=Ee.trim();if(Le){if(c!==void 0&&te.length>=c){le=!0;break}if(!u&&te.some(xe=>xe.value.toLowerCase()===Le.toLowerCase())){le=!0;continue}if(!Fo(Le,f)){le=!0;continue}te=[...te,{id:la(),value:Le,colorIndex:te.length}],z=!0}}return z&&ee(te),le&&$(),z}function M(B){return se([B])}function H(B){const te=L.filter(z=>z.id!==B);ee(te.map((z,le)=>({...z,colorIndex:le})))}function oe(B,te){const z=te.trim();if(F(null),V(""),!z){H(B);return}if(!(!u&&L.some(le=>le.id!==B&&le.value.toLowerCase()===z.toLowerCase()))){if(!Fo(z,f)){$();return}ee(L.map(le=>le.id===B?{...le,value:z}:le))}}function A(B){s||(F(B.id),V(B.value),setTimeout(()=>{var te;return(te=ae.current)==null?void 0:te.select()},0))}function q(B){if(B.key==="Enter"||i.includes(B.key)){B.preventDefault(),M(N)&&k("");return}if(B.key==="Backspace"&&N===""&&L.length>0){B.preventDefault();const te=L[L.length-1];H(te.id)}}function ne(B,te){if(B.key==="Enter"){B.preventDefault(),oe(te,U),setTimeout(()=>{var z;return(z=j.current)==null?void 0:z.focus()},0);return}B.key==="Escape"&&(B.preventDefault(),F(null),V(""),setTimeout(()=>{var z;return(z=j.current)==null?void 0:z.focus()},0))}function ie(){var B;s||(B=j.current)==null||B.focus()}function Q(B){if(s)return;const te=B.clipboardData.getData("text");if(!te||!(i.some(Le=>Le&&te.includes(Le))||te.includes(`
|
|
29
|
+
`)))return;B.preventDefault();const le=jc(te,i);se(le)&&k("")}function G(){const B=N.trim();B&&M(B)&&k("")}const w=h?"var(--danger)":J?"var(--primary)":"var(--border)",R=c!==void 0&&L.length>=c;return e.jsxs("div",{className:`flex flex-col gap-2 ${l}`,children:[(p||y||P)&&e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-semibold uppercase text-[var(--text-muted)]",children:[p&&e.jsx("span",{children:p}),y&&e.jsx("span",{className:"text-[var(--danger)]",children:"*"}),P?e.jsx(Kr,{content:b}):null]}),e.jsxs("div",{ref:Z,onClick:ie,onFocus:()=>C(!0),onBlur:B=>{var te;(te=Z.current)!=null&&te.contains(B.relatedTarget)||(C(!1),Y!==null&&oe(Y,U),Y===null&&G())},style:{borderColor:w},className:`
|
|
30
30
|
flex min-h-10 flex-wrap items-center gap-1.5 rounded-lg border
|
|
31
31
|
bg-[var(--bg-input)] px-2.5 py-2 transition-colors
|
|
32
32
|
${s?"cursor-not-allowed opacity-60":"cursor-text"}
|
|
33
|
-
${
|
|
33
|
+
${re?"animate-[tag-shake_0.4s_ease]":""}
|
|
34
34
|
`,children:[e.jsx("style",{children:`
|
|
35
35
|
@keyframes tag-shake {
|
|
36
36
|
0%,100% { transform: translateX(0); }
|
|
@@ -39,4 +39,4 @@ ${D}`,G=new Blob(["\uFEFF"+x],{type:"text/csv;charset=utf-8;"}),de=URL.createObj
|
|
|
39
39
|
60% { transform: translateX(-3px); }
|
|
40
40
|
80% { transform: translateX(3px); }
|
|
41
41
|
}
|
|
42
|
-
`}),L.map(B=>{const re=Hc(B.colorIndex);return K===B.id?e.jsx("input",{ref:ae,value:q,disabled:s,onChange:F=>X(F.target.value),onKeyDown:F=>ne(F,B.id),onBlur:()=>oe(B.id,q),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(q.length+2,6)}ch`}},B.id):e.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:[e.jsx("span",{className:"truncate",children:B.value}),e.jsx("button",{type:"button","aria-label":`Editar "${B.value}"`,disabled:s,tabIndex:-1,onClick:F=>{F.stopPropagation(),A(B)},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:e.jsx(T.HiPencil,{className:"h-3 w-3"})}),e.jsx("button",{type:"button","aria-label":`Eliminar "${B.value}"`,disabled:s,tabIndex:-1,onClick:F=>{F.stopPropagation(),O(B.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:e.jsx(T.HiXMark,{className:"h-3.5 w-3.5"})})]},B.id)}),!R&&e.jsx("input",{ref:W,value:N,disabled:s,placeholder:L.length===0?a:"",onChange:B=>k(B.target.value),onKeyDown:U,onPaste:Q,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"})]}),e.jsx(Xr,{error:v,helperText:b,helperDisplay:m})]})}const jc={xs:{width:28,height:16,thumb:12,padding:2},sm:{width:36,height:20,thumb:16,padding:2}};function Wc({checked:r,disabled:t,onCheckedChange:n,size:a="sm",className:s="",...l}){const i=jc[a],c=r?i.width-i.thumb-i.padding*2:0;return e.jsx("button",{...l,type:"button",role:"switch","aria-checked":r,disabled:t,onClick:()=>!t&&n(!r),className:`relative inline-flex shrink-0 items-center rounded-full transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--primary)]/50 disabled:cursor-not-allowed disabled:opacity-50 ${s}`,style:{width:i.width,height:i.height,background:r?"color-mix(in srgb, var(--primary) 85%, transparent)":"var(--bg-input)",border:r?"1px solid color-mix(in srgb, var(--primary) 55%, transparent)":"1px solid var(--border)"},children:e.jsx("span",{className:"absolute inline-block rounded-full transition-transform",style:{width:i.thumb,height:i.thumb,left:i.padding,top:"50%",transform:`translate(${c}px, -50%)`,background:r?"var(--primary-fg)":"var(--text-muted)"}})})}const zo=[".sidebar-scroll",".app-scroll",".showcase-nav-scroll","[data-overlay-scroll='true']"].join(","),qc=[":scope > [data-overlayscrollbars-contents]",":scope > .sidebar-scroll-body",":scope > .showcase-nav-scroll-body",":scope > .app-scroll-body"].join(", ");function Uc(r){if(!(r instanceof HTMLElement)||r.dataset.overlayScroll==="false"||r.matches("[data-overlayscrollbars]")||r.closest("[data-overlayscrollbars]")||r.matches("textarea,input,select,[contenteditable='true']"))return!1;const t=window.getComputedStyle(r);return!(![t.overflow,t.overflowX,t.overflowY].join(" ").match(/auto|scroll/)||r.clientWidth===0&&r.clientHeight===0)}function _o(r){return r.classList.contains("sidebar-scroll")||r.classList.contains("showcase-nav-scroll")}function jo(r){_o(r)&&r.querySelectorAll(".os-scrollbar-horizontal").forEach(t=>{t.style.display="none",t.style.height="0",t.style.pointerEvents="none"})}function Vc(r){const t=r.querySelector(qc);return t instanceof HTMLElement?t:null}function Wo(){return o.useEffect(()=>{const r=new WeakMap;let t=0;const n=()=>{t=0,document.querySelectorAll(zo).forEach(l=>{if(!(l instanceof HTMLElement))return;if(Hn.OverlayScrollbars(l)){jo(l);return}if(!Uc(l))return;const c={overflow:_o(l)?{x:"hidden",y:"scroll"}:void 0,scrollbars:{autoHide:"leave",autoHideDelay:180}},u=Vc(l),f=u?Hn.OverlayScrollbars({target:l,elements:{viewport:u}},c):Hn.OverlayScrollbars(l,c);jo(l),r.set(l,f)})},a=()=>{t||(t=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),()=>{t&&window.cancelAnimationFrame(t),s.disconnect(),window.removeEventListener("resize",a),document.querySelectorAll(zo).forEach(l=>{var i;l instanceof HTMLElement&&((i=r.get(l))==null||i.destroy())})}},[]),null}function wr(r){const t=r.trim();return!t||t==="/"||t==="/."?"":(t.startsWith("/")?t:`/${t}`).replace(/\/+$/,"")}function qo(r){try{const t=new URL(r);return wr(t.pathname)}catch{return""}}function Gc(r){const t=wr(r);if(!t)return"";const n=t.match(/^\/apps\/[^/]+/i);if(n)return wr(n[0]);const a=t.split("/").filter(Boolean);return a.length===0?"":a.length>=2&&a[0].toLowerCase()==="apps"?wr(`/${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())?"":wr(`/${a[0]}`)}const ia="primeSuiteAppUrl",Kc={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"}},Uo={xs:20,sm:28,md:36,lg:48,xl:64},Vo=["bg-indigo-500","bg-blue-500","bg-emerald-500","bg-violet-500","bg-amber-500","bg-teal-500","bg-rose-500","bg-cyan-500"],Xc={xs:"text-xs",sm:"text-sm",md:"text-base",lg:"text-lg"},Yc="bonsaif.bot",Zc="Bonsaif Bot",Qc={xs:"p-0.5",sm:"p-1",md:"p-1.5",lg:"p-2",xl:"p-2.5"};function Go(r){return typeof r=="string"?r.trim():""}function Jc(r){var s;if(r!==void 0)return wr(r);const t=wr(typeof process<"u"&&((s=process.env)==null?void 0:s.NEXT_PUBLIC_BASE_PATH)||"");if(t)return t;if(typeof window>"u")return"";try{const i=new URLSearchParams(window.location.search).get(ia)||"";i&&window.sessionStorage.setItem(ia,i);const c=window.sessionStorage.getItem(ia)||"",u=i||c;if(u){const f=qo(u);if(f&&!/^\/admin(\/|$)/i.test(f))return f}}catch{}const n=window.__NEXT_DATA__,a=(n==null?void 0:n.assetPrefix)||"";if(a){const l=a.startsWith("http")?qo(a):wr(a);if(l&&!/^\/admin(\/|$)/i.test(l))return l}return Gc(window.location.pathname)}function Rc(r){const t=r.split(/\s+/).map(n=>n.trim()).filter(Boolean);return t.length===0?"?":t.length===1?t[0].slice(0,1).toUpperCase():`${t[0].slice(0,1)}${t[1].slice(0,1)}`.toUpperCase()}function ed(r){let t=0;for(const n of r)t=t*31+n.charCodeAt(0)&65535;return Vo[t%Vo.length]}function rd(r,t){return r===Yc||t===Zc}function td(r,t){return`${r.replace(/\/$/,"")}${t}`}function Ko({userId:r,username:t,name:n,size:a="md",showName:s=!1,showTooltip:l,tooltipContent:i,fallbackLabel:c="Usuario",basePath:u,wrapperClassName:f="",labelClassName:p="",labelSize:b="xs",avatarVersion:m=0,className:v="",style:y}){const[S,h]=o.useState(!1),H=typeof r=="string"&&r.trim()&&r!=="undefined"&&r!=="null"?r.trim():"";o.useEffect(()=>{h(!1)},[H,m]);const{wh:_,text:E}=Kc[a],L=Go(n)||Go(t)||c,N=Rc(L),k=Jc(u),K=rd(t,n),P=td(k,"/favicon.svg"),q=o.useMemo(()=>{if(!H)return"";const j=new URLSearchParams;j.set("size",String(Uo[a])),m&&j.set("v",String(m));const W=j.toString();return`${k}/api/user/avatar/${encodeURIComponent(H)}${W?`?${W}`:""}`},[m,k,H,a]),X=Uo[a],J=K?e.jsx("span",{className:`${_} ${Qc[a]} rounded-full flex items-center justify-center bg-[#071f1a] ring-1 ring-emerald-400/35 shadow-[0_0_0_1px_rgba(255,255,255,0.06)] flex-shrink-0 ${v}`,style:y,children:e.jsx("img",{src:P,alt:L,width:X,height:X,className:"h-full w-full object-contain"})}):q&&!S?e.jsx("img",{src:q,alt:L,width:X,height:X,className:`${_} rounded-full object-cover flex-shrink-0 ${v}`,style:y,loading:"lazy",referrerPolicy:"no-referrer",onError:()=>h(!0)},`${H}-${m}`):e.jsx("span",{className:`${_} ${ed(L)} ${E} rounded-full flex items-center justify-center font-black text-white uppercase flex-shrink-0 ${v}`,style:y,title:L,children:N});if(s)return e.jsxs("span",{className:`inline-flex min-w-0 items-center gap-2 ${f}`,children:[J,e.jsx("span",{className:`min-w-0 truncate ${Xc[b]} font-medium text-[var(--text-main)] ${p}`,title:L,children:L})]});const C=l??!0,te=i??L;return C&&te?e.jsx(Mr,{as:"span",content:te,className:`inline-flex flex-shrink-0 ${f}`,children:J}):J}function nd({href:r,className:t,children:n}){return e.jsx("a",{href:r,className:t,children:n})}function ad(r){return r.reduce((t,n)=>{const a=n.section??"Principal";return t[a]=[...t[a]??[],n],t},{})}function Xo({children:r,navItems:t=[],currentPath:n=typeof window>"u"?"/":window.location.pathname,user:a,appName:s="Bonsaif",appLogo:l,header:i,footer:c,onLogout:u,LinkComponent:f=nd}){const[p,b]=o.useState(!1),m=ad(t);return e.jsxs("div",{className:"min-h-screen bg-[var(--bg-main)] text-[var(--text-main)]",children:[e.jsx(Wo,{}),e.jsx("button",{type:"button","aria-label":"Abrir navegación",className:"fixed left-3 top-3 z-50 inline-flex h-9 w-9 items-center justify-center rounded-md border border-white/10 bg-black/70 text-white lg:hidden",onClick:()=>b(!0),children:e.jsx(T.HiBars3,{className:"h-5 w-5"})}),p&&e.jsx("button",{type:"button","aria-label":"Cerrar navegación",className:"fixed inset-0 z-40 bg-black/45 lg:hidden",onClick:()=>b(!1)}),e.jsxs("aside",{className:`fixed inset-y-0 left-0 z-50 flex w-72 flex-col bg-[#071716] text-white shadow-2xl transition-transform duration-200 lg:translate-x-0 ${p?"translate-x-0":"-translate-x-full"}`,children:[e.jsxs("div",{className:"flex h-16 items-center gap-3 border-b border-white/10 px-4",children:[e.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg bg-white/10 text-white",children:l??e.jsx(T.HiHome,{className:"h-5 w-5"})}),e.jsx("div",{className:"min-w-0 flex-1 truncate text-sm font-semibold",children:s}),e.jsx("button",{type:"button","aria-label":"Cerrar navegación",className:"inline-flex h-8 w-8 items-center justify-center rounded-md text-white/70 hover:bg-white/10 lg:hidden",onClick:()=>b(!1),children:e.jsx(T.HiXMark,{className:"h-5 w-5"})})]}),e.jsx("nav",{className:"sidebar-scroll min-h-0 flex-1 overflow-y-auto px-3 py-4","data-overlay-scroll":"true",children:e.jsx("div",{className:"sidebar-scroll-body",children:Object.entries(m).map(([v,y])=>e.jsxs("div",{className:"mb-5",children:[e.jsxs("div",{className:"mb-2 flex items-center gap-2 px-2 text-[11px] font-semibold uppercase tracking-wide text-white/35",children:[e.jsx(T.HiChevronDown,{className:"h-3.5 w-3.5"}),v]}),e.jsx("div",{className:"space-y-1",children:y.map(S=>{const h=n===S.href||n.startsWith(`${S.href}/`);return e.jsxs(f,{href:S.href,className:`flex min-w-0 items-center gap-2 rounded-md px-2 py-2 text-sm transition-colors ${h?"bg-white/10 text-white":"text-white/55 hover:bg-white/[0.06] hover:text-white/85"}`,children:[e.jsx("span",{className:"flex h-5 w-5 flex-shrink-0 items-center justify-center",children:S.icon??e.jsx(T.HiHome,{className:"h-4 w-4"})}),e.jsx("span",{className:"truncate",children:S.label})]},S.href)})})]},v))})}),e.jsxs("div",{className:"border-t border-white/10 p-3",children:[a&&e.jsxs("div",{className:"mb-3 flex min-w-0 items-center gap-3 rounded-lg bg-white/[0.04] p-2",children:[e.jsx(Ko,{name:a.initials??a.name??a.email??"Usuario",size:"md"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate text-sm font-medium text-white",children:a.name??"Usuario"}),a.email&&e.jsx("div",{className:"truncate text-xs text-white/45",children:a.email})]})]}),u&&e.jsxs(Fe,{variant:"ghost",className:"w-full justify-start text-white hover:bg-white/10",onClick:u,children:[e.jsx(T.HiArrowRightOnRectangle,{className:"h-4 w-4"})," Salir"]}),c]})]}),e.jsxs("div",{className:"min-h-screen lg:pl-72",children:[i,e.jsx("main",{className:"min-h-screen",children:r})]})]})}const Yo="bonsaif-ui:prime-auth-sso",od={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"},ca={dashboard:e.jsx(T.HiChartBar,{className:"h-5 w-5"}),tickets:e.jsx(T.HiTicket,{className:"h-5 w-5"}),teams:e.jsx(T.HiUsers,{className:"h-5 w-5"}),projects:e.jsx(T.HiRectangleGroup,{className:"h-5 w-5"}),clients:e.jsx(T.HiBuildingOffice2,{className:"h-5 w-5"}),surveys:e.jsx(T.HiClipboardDocumentList,{className:"h-5 w-5"}),profile:e.jsx(T.HiUser,{className:"h-5 w-5"}),settings:e.jsx(T.HiCog6Tooth,{className:"h-5 w-5"}),notifications:e.jsx(T.HiBell,{className:"h-5 w-5"}),changelog:e.jsx(T.HiDocumentText,{className:"h-5 w-5"}),admin:e.jsx(T.HiShieldCheck,{className:"h-5 w-5"}),users:e.jsx(T.HiUsers,{className:"h-5 w-5"}),roles:e.jsx(T.HiShieldCheck,{className:"h-5 w-5"}),menus:e.jsx(T.HiCog6Tooth,{className:"h-5 w-5"}),guards:e.jsx(T.HiCalendarDays,{className:"h-5 w-5"}),vacations:e.jsx(T.HiCalendarDays,{className:"h-5 w-5"}),audit:e.jsx(T.HiListBullet,{className:"h-5 w-5"}),positions:e.jsx(T.HiBriefcase,{className:"h-5 w-5"}),ranks:e.jsx(T.HiListBullet,{className:"h-5 w-5"}),"email-inbox":e.jsx(T.HiInbox,{className:"h-5 w-5"}),"security-incidents":e.jsx(T.HiShieldCheck,{className:"h-5 w-5"})};function sd(r){return r.split("-").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}function ld(r){return/^\d+$/.test(r)||/^[a-f0-9]{8,}$/i.test(r)}function id(r){const t=r.split("/").filter(Boolean);if(t.length===0||t.length===1&&t[0]==="dashboard")return[];const n=decodeURIComponent(t[t.length-1]),a=t.length>1?decodeURIComponent(t[t.length-2]):void 0,s=ld(n)&&a?a:n,l=od[s]??sd(s);return[{label:"Inicio",href:"/"},{label:l}]}function da(r){return(r==null?void 0:r.querySelector(":scope > .os-viewport"))??(r==null?void 0:r.querySelector(":scope > [data-overlayscrollbars-viewport]"))}function cd(r){const t=r.split("/").filter(Boolean),n=t[t.length-1];if(!n)return e.jsx(T.HiHome,{className:"h-5 w-5"});if(ca[n])return ca[n];const a=t.length>1?t[t.length-2]:"";return ca[a]??e.jsx(T.HiHome,{className:"h-5 w-5"})}function dd(r){return r.includes("primeAuthOrigin")||r.includes("primeAuthProjectKey")}function Zo(){if(typeof window>"u")return!1;if(dd(window.location.href)){try{window.sessionStorage.setItem(Yo,"true")}catch{}return!0}try{return window.sessionStorage.getItem(Yo)==="true"}catch{return!1}}function ud({title:r,subtitle:t,action:n,meta:a,icon:s,className:l="",contentClassName:i="",breadcrumbs:c,currentPath:u,showBreadcrumbs:f=!0,contained:p=!1}){const b=o.useRef(null),[m,v]=o.useState(!1),[y,S]=o.useState(u??"/"),[h,H]=o.useState(()=>Zo()),[_,E]=o.useState(null),L=u??y,N=c??id(L),k=s??cd(L),K=f&&!h&&N.length>1,P=!K;o.useEffect(()=>{u||S(window.location.pathname)},[u]),o.useEffect(()=>{H(Zo())},[]),o.useEffect(()=>{if(p){v(!1);return}let X=null,J=0,C=0;const te=()=>{const ae=b.current,Z=document.querySelector("[data-app-scroll='true']");return(ae==null?void 0:ae.closest(".os-viewport"))??(ae==null?void 0:ae.closest("[data-overlayscrollbars-viewport]"))??da(Z)??Z??window},j=()=>{const ae=X&&X!==window?X.scrollTop:window.scrollY;v(Z=>Z?ae>24:ae>72)},W=()=>{X==null||X.removeEventListener("scroll",j),X=te(),X.addEventListener("scroll",j,{passive:!0}),j()};return W(),J=window.requestAnimationFrame(W),C=window.setTimeout(W,120),()=>{window.cancelAnimationFrame(J),window.clearTimeout(C),X==null||X.removeEventListener("scroll",j)}},[p]),o.useEffect(()=>{if(p){E(null);return}let X=0;const J=[],C=()=>{const ee=b.current,se=ee==null?void 0:ee.parentElement,M=document.querySelector("[data-app-scroll='true']"),O=da(M)??M;if(!ee||!se||!O){E(null);return}const oe=se.getBoundingClientRect(),A=window.getComputedStyle(se),U=O.getBoundingClientRect(),ne=O instanceof HTMLElement&&O.clientWidth>0?O.clientWidth:U.width,ie=oe.left+parseFloat(A.paddingLeft||"0"),Q={marginLeft:Math.round(U.left-ie),width:Math.round(ne)};E(V=>V&&V.marginLeft===Q.marginLeft&&V.width===Q.width?V:Q)},te=()=>{window.cancelAnimationFrame(X),X=window.requestAnimationFrame(C)};te(),window.addEventListener("resize",te);const j=new ResizeObserver(te),W=b.current,ae=W==null?void 0:W.parentElement,Z=document.querySelector("[data-app-scroll='true']"),$=da(Z)??Z;return[ae,Z,$].forEach(ee=>{ee&&j.observe(ee)}),J.push(window.setTimeout(te,120)),J.push(window.setTimeout(te,280)),()=>{window.cancelAnimationFrame(X),window.removeEventListener("resize",te),j.disconnect(),J.forEach(ee=>window.clearTimeout(ee))}},[p]);const q={..._?{marginLeft:_.marginLeft,width:_.width}:null,"--page-header-control-height":m?"34px":"40px","--page-header-control-padding-x":m?"10px":"14px","--page-header-control-icon-left":m?"10px":"12px",background:p?"var(--bg-card)":m?"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:p||m?"1px solid var(--border)":"1px solid transparent",boxShadow:m?"0 10px 28px rgba(12, 54, 53, 0.12)":"none"};return e.jsx("div",{ref:b,"data-page-header":"true","data-compact":m?"true":"false",className:`sticky top-0 z-30 overflow-visible py-0 transition-[background-color,box-shadow,border-color] duration-300 ease-out ${p?"mb-0 flex-shrink-0":"mb-4 sm:mb-0"} ${l}`,style:q,children:e.jsxs("div",{className:`flex flex-wrap items-center justify-between transition-[gap,min-height,padding] duration-300 ease-out ${m?"min-h-8 gap-1.5 px-3 py-0 sm:min-h-9 sm:gap-2":P?"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:[e.jsx("div",{className:`min-w-0 flex flex-1 flex-col justify-center transition-[gap,transform] duration-300 ease-out ${m||P?"gap-1":"gap-1.5 sm:gap-2"}`,children:e.jsxs("div",{className:`flex min-w-0 items-center transition-[gap,transform] duration-300 ease-out ${m||P?"gap-2":"gap-2.5 sm:gap-3"}`,children:[e.jsx("span",{className:`flex-shrink-0 transition-[color,transform,opacity] duration-300 ease-out ${m?"scale-75 opacity-80":"scale-90 opacity-100"}`,style:{color:K?"var(--text-secondary)":"var(--text-muted)"},children:k}),e.jsxs("div",{className:`flex min-w-0 flex-1 flex-wrap items-center transition-[gap] duration-300 ease-out ${m?"gap-x-2 gap-y-1":"gap-x-3 gap-y-2"}`,children:[e.jsxs("div",{className:"min-w-0 flex-shrink transition-[transform] duration-300 ease-out",children:[e.jsx("h1",{className:`truncate font-bold tracking-tight transition-[font-size,line-height,color] duration-300 ease-out ${m?"text-sm sm:text-base":"text-lg sm:text-xl"}`,style:{color:"var(--text-main)"},children:r}),t&&e.jsx("p",{"aria-hidden":m,className:`overflow-hidden text-xs transition-[max-height,opacity,transform,margin] duration-300 ease-out ${m?"mt-0 max-h-0 -translate-y-1 opacity-0":"mt-0.5 max-h-5 translate-y-0 opacity-100"}`,style:{color:"var(--text-muted)"},children:t})]}),a&&e.jsx("div",{className:`page-header-meta flex min-w-0 flex-1 basis-full items-center overflow-visible transition-[gap,opacity,transform] duration-300 ease-out sm:basis-auto ${m?"translate-y-0 gap-1.5 opacity-95":"gap-2 opacity-100"}`,children:a})]})]})}),n&&e.jsx("div",{className:`page-header-actions ml-auto flex max-w-full flex-shrink-0 flex-wrap items-center justify-end self-center overflow-visible transition-[gap,min-height,opacity,transform] duration-300 ease-out ${m?"min-h-9 gap-1 opacity-95":"min-h-9 gap-1.5 opacity-100"}`,children:e.jsx(Ba.Provider,{value:{compact:!0,headerAction:!0},children:n})})]})})}function fd({children:r,currentPath:t=typeof window>"u"?"/":window.location.pathname,publicRoutes:n=["/","/login","/reset-password"],...a}){return n.includes(t)?e.jsx(e.Fragment,{children:r}):e.jsx(Xo,{currentPath:t,...a,children:r})}function Qo(){if(typeof window>"u")return"system";const r=localStorage.getItem("theme");return r==="light"||r==="dark"?r:r==="system"?"system":document.documentElement.classList.contains("dark")?"dark":"light"}function bd(r,t,n){try{const a=new URL(r),s=a.searchParams.get("callbackUrl");if(s){const l=new URL(s,a.origin);return l.searchParams.set("theme",t),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",t),n&&(a.searchParams.set("primeAuthOrigin",window.location.origin),a.searchParams.set("primeAuthProjectKey",n)),a.toString()}catch{return r}}function pd({name:r,src:t,projectKey:n}){const[a,s]=o.useState("system"),l=o.useRef(null);o.useEffect(()=>{s(Qo());const u=new MutationObserver(()=>s(Qo()));return u.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>u.disconnect()},[]);const i=o.useMemo(()=>bd(t,a,n),[n,t,a]),c=o.useMemo(()=>{try{return new URL(i).origin}catch{return""}},[i]);return o.useEffect(()=>{if(!n)return;const u=n;function f(p){var v,y,S;if(p.source!==((v=l.current)==null?void 0:v.contentWindow)||c&&p.origin!==c)return;if(((y=p.data)==null?void 0:y.type)==="prime-microservice:overlay"){window.dispatchEvent(new CustomEvent("prime-auth:microservice-overlay",{detail:{active:!!p.data.active}}));return}if(((S=p.data)==null?void 0:S.type)!=="prime-microservice:navigation")return;const b=p.data.path;if(!b||!b.startsWith("/")||b.startsWith("//"))return;const m=`/apps/${encodeURIComponent(u)}${b}`;`${window.location.pathname}${window.location.search}${window.location.hash}`!==m&&(window.history.replaceState(window.history.state,"",m),window.dispatchEvent(new CustomEvent("prime-auth:microservice-navigation")))}return window.addEventListener("message",f),()=>{window.removeEventListener("message",f),window.dispatchEvent(new CustomEvent("prime-auth:microservice-overlay",{detail:{active:!1}}))}},[c,n]),e.jsx("div",{className:"flex h-full min-h-screen flex-col bg-[var(--bg-main)]",children:e.jsx("iframe",{ref:l,src:i,title:r,className:"min-h-0 flex-1 border-0 bg-[var(--bg-main)]",allow:"clipboard-write",sandbox:"allow-downloads allow-forms allow-modals allow-popups allow-same-origin allow-scripts",referrerPolicy:"strict-origin-when-cross-origin"})})}function md(){const[r,t]=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)&&t(c.src)}).catch(()=>{}),()=>{i=!0}},[]),o.useEffect(()=>{const i=c=>{var f;if(((f=c.data)==null?void 0:f.type)!=="prime-suite-chat:state")return;const u=!!c.data.active;a(u),l({width:Jo(c.data.width,96,720),height:Jo(c.data.height,96,560)})};return window.addEventListener("message",i),()=>window.removeEventListener("message",i)},[]),r?e.jsx("iframe",{title:"Chat Bonsaif",src:r,allow:"clipboard-write",className:"fixed bottom-0 right-0 z-[70] border-0 bg-transparent transition-[width,height] duration-200",style:{width:n?`min(${s.width}px, 100vw)`:96,height:n?`min(${s.height}px, 100vh)`:96,background:"transparent",backgroundColor:"transparent",colorScheme:"normal"}}):null}function Jo(r,t,n){const a=typeof r=="number"&&Number.isFinite(r)?r:t;return Math.max(t,Math.min(n,Math.ceil(a)))}function hd(r){const t=document.documentElement,n=new MutationObserver(r);n.observe(t,{attributes:!0,attributeFilter:["class"]});const a=window.matchMedia("(prefers-color-scheme: dark)");return a.addEventListener("change",r),()=>{n.disconnect(),a.removeEventListener("change",r)}}function gd(){const r=localStorage.getItem("theme")||"system",t=window.matchMedia("(prefers-color-scheme: dark)").matches;return document.documentElement.classList.contains("dark")||r==="dark"||r==="system"&&t?"dark":"light"}function vd(){return"light"}function xd({position:r="bottom-center"}){const t=o.useSyncExternalStore(hd,gd,vd);return e.jsx($a.Toaster,{position:r,theme:t,richColors:!0,closeButton:!0})}function yd({title:r,subtitle:t,actions:n,loading:a=!1,empty:s=!1,emptyText:l="Sin datos para mostrar",className:i="",children:c}){return e.jsxs("div",{className:`bonsaif-chart-card w-full overflow-visible ${i}`,children:[(r||t||n)&&e.jsxs("div",{className:"bonsaif-chart-card-head",children:[e.jsx("div",{className:"bonsaif-chart-card-accent","aria-hidden":!0}),e.jsxs("div",{className:"bonsaif-chart-card-copy min-w-0",children:[r?e.jsx("div",{className:"bonsaif-chart-card-title",children:r}):null,t?e.jsx("div",{className:"bonsaif-chart-card-subtitle",children:t}):null]}),n?e.jsx("div",{className:"bonsaif-chart-card-actions shrink-0",children:n}):null]}),e.jsx("div",{className:"bonsaif-chart-card-body",children:a?e.jsx("div",{className:"flex h-48 items-center justify-center",children:e.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?e.jsx("div",{className:"flex h-48 items-center justify-center text-sm",style:{color:"var(--text-muted)"},children:l}):c})]})}const nn=["var(--primary)","#38bdf8","#34d399","#a78bfa","#2dd4bf","#fbbf24","#60a5fa","#94a3b8"];function Ro(r,t){return r.color??nn[t%nn.length]}function sr(r="primary"){switch(r){case"success":return"#34d399";case"warning":return"#fbbf24";case"danger":return"#f87171";case"neutral":return"var(--text-muted)";default:return"var(--primary)"}}const tr=r=>{if(!Number.isFinite(r))return"—";const t=Math.abs(r);return t>=1e9?`${(r/1e9).toFixed(1).replace(/\.0$/,"")}B`:t>=1e6?`${(r/1e6).toFixed(1).replace(/\.0$/,"")}M`:t>=1e4?`${(r/1e3).toFixed(1).replace(/\.0$/,"")}k`:r.toLocaleString(void 0,{maximumFractionDigits:2})};function St(r){if(r==null||r==="")return null;const t=typeof r=="number"?r:Number(r);return Number.isFinite(t)?t:null}const ua={warning:70,danger:90};function an(r,t=ua){const n=t.warning??ua.warning,a=t.danger??ua.danger;return r>=a?"danger":r>=n?"warning":r<=0?"primary":"success"}function Ct(r,t){return sr(an(r,t))}function Zr(r,t=0){return Number.isFinite(r)?`${r.toFixed(t)}%`:"—"}function Qr(r,t=1){if(!Number.isFinite(r))return"—";const n=r<0?"-":"",a=Math.abs(r);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(t);return`${n}${c.replace(/\.0$/,"")} ${s[i]}`}function es(r,t="bytes",n=1){if(!Number.isFinite(r))return"—";const a=r<0?"-":"",s=Math.abs(r),l=t==="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 u=i>=100?i.toFixed(0):i.toFixed(n);return`${a}${u.replace(/\.0$/,"")} ${l[c]}`}function Jr(r,t){var n;for(let a=r.length-1;a>=0;a-=1){const s=St((n=r[a])==null?void 0:n[t]);if(s!==null)return s}return null}function nr({height:r}){return e.jsx("div",{className:"flex items-center justify-center",style:{height:r},"aria-busy":!0,children:e.jsx("div",{className:"h-7 w-7 animate-spin rounded-full border-2",style:{borderColor:"var(--border)",borderTopColor:"var(--primary)"}})})}function ar({height:r,text:t}){return e.jsx("div",{className:"flex items-center justify-center text-sm",style:{height:r,color:"var(--text-muted)"},children:t})}const $r=680,Ar="ease-out",wd={top:18,right:8,bottom:12,left:0};function Et(r){return{...wd,...r}}function Mt(r){return r.map((t,n)=>({...t,color:Ro(t,n),label:t.label??t.key}))}function on(r,t){return!r.length||!t.length||r.every(n=>t.every(a=>St(n[a.key])===null))}function Ze(){return{fill:"var(--text-muted)",fontSize:10,fontWeight:500,letterSpacing:"0.02em"}}function Lt(){return"color-mix(in srgb, var(--border) 55%, transparent)"}function rs(){return"color-mix(in srgb, var(--primary) 45%, var(--border))"}function sn(){return{paddingBottom:12,paddingLeft:4,fontSize:11,fontWeight:600,letterSpacing:"0.04em",textTransform:"uppercase",color:"var(--text-muted)"}}function kd(r,t=tr){if(r==null||r==="")return"—";const n=typeof r=="number"?r:Number(r);return Number.isFinite(n)?t(n):String(r)}function ts(r){return`bonsaif-grad-${r.replace(/[^a-zA-Z0-9_-]/g,"")}`}function Nd({active:r,label:t,payload:n,valueFormat:a=tr}){var c,u,f,p,b,m;if(!r||!(n!=null&&n.length))return null;const s=n.filter(v=>v.dataKey!=="base"&&v.name!=="base"&&v.value!==null&&v.value!==void 0);if(!s.length)return null;const l=((u=(c=s[0])==null?void 0:c.payload)==null?void 0:u.fullName)??((p=(f=s[0])==null?void 0:f.payload)==null?void 0:p.tooltipLabel)??((m=(b=s[0])==null?void 0:b.payload)==null?void 0:m.display),i=typeof l=="string"&&l.length>0?l:t;return e.jsxs("div",{className:"bonsaif-chart-tooltip-panel",children:[i!=null&&i!==""?e.jsx("div",{className:"bonsaif-chart-tooltip-label",children:String(i)}):null,e.jsx("div",{className:"bonsaif-chart-tooltip-items",children:s.map((v,y)=>{const S=v.payload,h=S&&typeof S.display=="number"?S.display:v.value;return e.jsxs("div",{className:"bonsaif-chart-tooltip-row",children:[e.jsxs("span",{className:"bonsaif-chart-tooltip-name",children:[e.jsx("span",{className:"bonsaif-chart-tooltip-swatch",style:{background:v.color??"var(--primary)"}}),v.name??v.dataKey]}),e.jsx("span",{className:"bonsaif-chart-tooltip-value",children:kd(h,a)})]},String(v.dataKey??v.name??y))})})]})}function Rr({valueFormat:r,content:t,cursor:n,offset:a=12,wrapperStyle:s,allowEscapeViewBox:l,reverseDirection:i,...c}){return e.jsx(ve.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:t??e.jsx(Nd,{valueFormat:r})})}function ns(r,t,n){return n==null?-1:r.findIndex(a=>String(a[t])===String(n))}function as(r,t,n){if(n<=1)return null;const a=Math.max(0,Math.min(r,t)),s=Math.min(n-1,Math.max(r,t));return s-a<1||a===0&&s>=n-1?null:{startIndex:a,endIndex:s}}function ln(r,t,n={}){const{zoomable:a=!1,zoomMode:s="both",brushHeight:l=28,onZoomChange:i}=n,[c,u]=o.useState(null),[f,p]=o.useState(null),b=!!a&&r.length>1,m=b&&(s==="brush"||s==="both"),v=b&&(s==="drag"||s==="both"),y=o.useCallback(J=>{u(J),i==null||i(J)},[i]),S=o.useCallback(()=>{p(null),y(null)},[y]),h=!!c,H=o.useMemo(()=>!c||m?r:r.slice(c.startIndex,c.endIndex+1),[r,m,c]),_=o.useCallback((J,C)=>{const te=ns(r,t,J),j=ns(r,t,C);te<0||j<0||y(as(te,j,r.length))},[y,r,t]),E=o.useCallback(J=>{v&&((J==null?void 0:J.activeLabel)===void 0||(J==null?void 0:J.activeLabel)===null||p({leftLabel:J.activeLabel,rightLabel:J.activeLabel}))},[v]),L=o.useCallback(J=>{!v||!f||(J==null?void 0:J.activeLabel)===void 0||(J==null?void 0:J.activeLabel)===null||p(C=>C&&{...C,rightLabel:J.activeLabel})},[f,v]),N=o.useCallback(()=>{if(v){if(!f||f.rightLabel===null||f.rightLabel===void 0){p(null);return}_(f.leftLabel,f.rightLabel),p(null)}},[_,f,v]),k=o.useCallback(J=>{if(m){if(!J){y(null);return}y(as(J.startIndex??0,J.endIndex??r.length-1,r.length))}},[y,r.length,m]),K=v?{onMouseDown:E,onMouseMove:L,onMouseUp:N,onMouseLeave:()=>{f&&N()}}:{},P=c??{startIndex:0,endIndex:Math.max(0,r.length-1)},q=e.jsxs(e.Fragment,{children:[v&&f&&f.rightLabel!==null&&f.rightLabel!==void 0?e.jsx(ve.ReferenceArea,{x1:f.leftLabel,x2:f.rightLabel,strokeOpacity:.18,fill:"var(--primary)",fillOpacity:.12,stroke:"var(--primary)"}):null,m?e.jsx(ve.Brush,{dataKey:t,height:l,stroke:"var(--primary)",fill:"color-mix(in srgb, var(--primary) 10%, var(--bg-card))",travellerWidth:8,startIndex:P.startIndex,endIndex:P.endIndex,onChange:k,tickFormatter:J=>String(J)}):null]}),X=m?{bottom:Math.max(l+10,36)}:void 0;return{enabled:b,showBrush:m,showDrag:v,viewData:H,isZoomed:h,resetZoom:S,chartHandlers:K,zoomNodes:q,marginExtra:X}}function cn({visible:r,onReset:t}){return r?e.jsx("button",{type:"button",className:"bonsaif-chart-zoom-reset",onClick:t,"aria-label":"Restablecer zoom",children:"Restablecer zoom"}):null}function Sd({data:r,xKey:t,series:n,height:a=280,className:s="",loading:l=!1,emptyText:i="Sin datos para mostrar",showGrid:c=!0,showLegend:u=!0,showTooltip:f=!0,margin:p,valueFormat:b=tr,yDomain:m,ariaLabel:v="Gráfico de líneas",curve:y=!0,strokeWidth:S=2.25,zoomable:h=!1,zoomMode:H="both",brushHeight:_,onZoomChange:E}){const L=on(r,n),N=Mt(n),k=ln(r,t,{zoomable:h,zoomMode:H,brushHeight:_,onZoomChange:E}),K=Et({...p,...k.marginExtra});return l?e.jsx(nr,{height:a}):L?e.jsx(ar,{height:a,text:i}):e.jsxs("div",{className:`bonsaif-chart bonsaif-line-chart w-full ${s}`,role:"img","aria-label":v,style:{height:a},children:[e.jsx(cn,{visible:k.isZoomed,onReset:k.resetZoom}),e.jsx(ve.ResponsiveContainer,{width:"100%",height:"100%",children:e.jsxs(ve.LineChart,{data:k.viewData,margin:K,...k.chartHandlers,children:[c?e.jsx(ve.CartesianGrid,{strokeDasharray:"2 8",stroke:Lt(),vertical:!1}):null,e.jsx(ve.XAxis,{dataKey:t,tick:Ze(),tickLine:!1,axisLine:!1,padding:{left:0,right:0},interval:"preserveStartEnd",minTickGap:52,dy:6}),e.jsx(ve.YAxis,{tick:Ze(),tickLine:!1,axisLine:!1,width:44,domain:m??["auto","auto"],tickFormatter:P=>b(Number(P)),dx:-2}),f?e.jsx(Rr,{valueFormat:b,cursor:{stroke:rs(),strokeWidth:1.25,strokeDasharray:"4 4"}}):null,u?e.jsx(ve.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:sn()}):null,N.map((P,q)=>e.jsx(ve.Line,{type:y?"monotone":"linear",dataKey:P.key,name:P.label,stroke:P.color,strokeWidth:q===0?S+.35:S,strokeOpacity:q===0?1:.88,isAnimationActive:!0,animationDuration:$r,animationEasing:Ar,dot:!1,activeDot:{r:5,strokeWidth:2,stroke:"var(--bg-card)",fill:P.color}},P.key)),k.zoomNodes]})})]})}function dn({data:r,xKey:t,series:n,height:a=280,className:s="",loading:l=!1,emptyText:i="Sin datos para mostrar",showGrid:c=!0,showLegend:u=!0,showTooltip:f=!0,margin:p,valueFormat:b=tr,yDomain:m,ariaLabel:v="Gráfico de área",stacked:y=!1,opacity:S=.22,zoomable:h=!1,zoomMode:H="both",brushHeight:_,onZoomChange:E}){const L=on(r,n),N=Mt(n),k=ln(r,t,{zoomable:h,zoomMode:H,brushHeight:_,onZoomChange:E}),K=Et({...p,...k.marginExtra});return l?e.jsx(nr,{height:a}):L?e.jsx(ar,{height:a,text:i}):e.jsxs("div",{className:`bonsaif-chart bonsaif-area-chart w-full ${s}`,role:"img","aria-label":v,style:{height:a},children:[e.jsx(cn,{visible:k.isZoomed,onReset:k.resetZoom}),e.jsx(ve.ResponsiveContainer,{width:"100%",height:"100%",children:e.jsxs(ve.AreaChart,{data:k.viewData,margin:K,...k.chartHandlers,children:[e.jsx("defs",{children:N.map(P=>e.jsxs("linearGradient",{id:ts(P.key),x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:P.color,stopOpacity:Math.min(.55,S+.28)}),e.jsx("stop",{offset:"48%",stopColor:P.color,stopOpacity:S*.5}),e.jsx("stop",{offset:"100%",stopColor:P.color,stopOpacity:0})]},P.key))}),c?e.jsx(ve.CartesianGrid,{strokeDasharray:"2 8",stroke:Lt(),vertical:!1}):null,e.jsx(ve.XAxis,{dataKey:t,tick:Ze(),tickLine:!1,axisLine:!1,padding:{left:0,right:0},interval:"preserveStartEnd",minTickGap:52,dy:6}),e.jsx(ve.YAxis,{tick:Ze(),tickLine:!1,axisLine:!1,width:44,domain:m??["auto","auto"],tickFormatter:P=>b(Number(P)),dx:-2}),f?e.jsx(Rr,{valueFormat:b,cursor:{stroke:rs(),strokeWidth:1.25,strokeDasharray:"4 4"}}):null,u?e.jsx(ve.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:sn()}):null,N.map(P=>e.jsx(ve.Area,{type:"monotone",dataKey:P.key,name:P.label,stroke:P.color,fill:`url(#${ts(P.key)})`,strokeWidth:2.25,stackId:y?"stack":void 0,isAnimationActive:!0,animationDuration:$r,animationEasing:Ar,dot:!1,activeDot:{r:5,strokeWidth:2,stroke:"var(--bg-card)",fill:P.color}},P.key)),k.zoomNodes]})})]})}function Cd({data:r,xKey:t,series:n,height:a=280,className:s="",loading:l=!1,emptyText:i="Sin datos para mostrar",showGrid:c=!0,showLegend:u=!0,showTooltip:f=!0,margin:p,valueFormat:b=tr,yDomain:m,ariaLabel:v="Gráfico de barras",layout:y="vertical",mode:S="grouped",barRadius:h=6,categoryAxisWidth:H=64,zoomable:_=!1,zoomMode:E="both",brushHeight:L,onZoomChange:N}){const k=on(r,n),K=Mt(n),P=y==="horizontal",q=ln(r,t,{zoomable:_&&!P,zoomMode:E,brushHeight:L,onZoomChange:N}),X=Et({...p,...q.marginExtra});return l?e.jsx(nr,{height:a}):k?e.jsx(ar,{height:a,text:i}):e.jsxs("div",{className:`bonsaif-chart bonsaif-bar-chart w-full ${s}`,role:"img","aria-label":v,style:{height:a},children:[e.jsx(cn,{visible:q.isZoomed,onReset:q.resetZoom}),e.jsx(ve.ResponsiveContainer,{width:"100%",height:"100%",children:e.jsxs(ve.BarChart,{data:q.viewData,margin:X,layout:P?"vertical":"horizontal",barCategoryGap:"34%",barGap:3,...q.chartHandlers,children:[c?e.jsx(ve.CartesianGrid,{strokeDasharray:"2 8",stroke:Lt(),horizontal:!P,vertical:P}):null,P?e.jsxs(e.Fragment,{children:[e.jsx(ve.XAxis,{type:"number",tick:Ze(),tickLine:!1,axisLine:!1,tickFormatter:J=>b(Number(J)),domain:m??["auto","auto"]}),e.jsx(ve.YAxis,{type:"category",dataKey:t,tick:Ze(),tickLine:!1,axisLine:!1,width:H})]}):e.jsxs(e.Fragment,{children:[e.jsx(ve.XAxis,{dataKey:t,tick:Ze(),tickLine:!1,axisLine:!1,interval:"preserveStartEnd",minTickGap:36,dy:6}),e.jsx(ve.YAxis,{tick:Ze(),tickLine:!1,axisLine:!1,width:44,domain:m??["auto","auto"],tickFormatter:J=>b(Number(J)),dx:-2})]}),f?e.jsx(Rr,{valueFormat:b,cursor:{fill:"color-mix(in srgb, var(--primary) 8%, transparent)"}}):null,u?e.jsx(ve.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:sn()}):null,K.map((J,C)=>e.jsx(ve.Bar,{dataKey:J.key,name:J.label,fill:J.color,fillOpacity:C===0?1:.82,radius:P?[0,h,h,0]:[h,h,2,2],maxBarSize:20,stackId:S==="stacked"?"stack":void 0,isAnimationActive:!0,animationDuration:$r,animationEasing:Ar},J.key)),q.zoomNodes]})})]})}function Ed(r){return e.jsx(ss,{...r,variant:"pie"})}function Md(r){return e.jsx(ss,{...r,variant:"donut",innerRadius:r.innerRadius??.62,cornerRadius:r.cornerRadius??10,padAngle:r.padAngle??2})}function os(r,t){return r==null||!Number.isFinite(r)?t:r>0&&r<=1?r*100:r}function ss({data:r,nameKey:t,valueKey:n,height:a=280,className:s="",loading:l=!1,emptyText:i="Sin datos para mostrar",showLegend:c=!0,showTooltip:u=!0,valueFormat:f=tr,ariaLabel:p,innerRadius:b,outerRadius:m,colors:v=[...nn],padAngle:y,cornerRadius:S,variant:h}){const H=r.map((C,te)=>({name:String(C[t]??""),value:St(C[n])??0,fill:v[te%v.length],row:C})).filter(C=>C.value>0),_=!H.length,E=h==="donut",L=H.length,N=os(b,E?62:12),k=os(m,78),K=Math.min(y??(E?2:3),Math.max(.5,10/Math.max(1,L))),P=Math.min(S??(E?10:8),Math.max(2,36/Math.max(1,L)));if(l)return e.jsx(nr,{height:a});if(_)return e.jsx(ar,{height:a,text:i});const q=H.reduce((C,te)=>C+te.value,0),X=c?Math.min(96,28+Math.ceil(L/3)*22):0,J=Math.max(140,a-X);return e.jsx("div",{className:`bonsaif-chart bonsaif-${h}-chart w-full ${s}`,role:"img","aria-label":p??(h==="donut"?"Donut chart":"Pie chart"),style:{height:a},children:e.jsxs("div",{className:"bonsaif-pie-layout",children:[e.jsx("div",{className:"bonsaif-pie-plot",style:{height:J},children:e.jsx(ve.ResponsiveContainer,{width:"100%",height:"100%",children:e.jsxs(ve.PieChart,{margin:{top:4,right:4,bottom:4,left:4},children:[u?e.jsx(Rr,{valueFormat:f,isAnimationActive:!1}):null,e.jsx(ve.Pie,{data:H,dataKey:"value",nameKey:"name",cx:"50%",cy:"50%",innerRadius:`${N}%`,outerRadius:`${k}%`,startAngle:90,endAngle:-270,paddingAngle:K,cornerRadius:P,minAngle:L>6?3:2,stroke:"var(--bg-card)",strokeWidth:2,isAnimationActive:!0,animationDuration:$r,animationEasing:Ar,label:!1,activeShape:Ld,children:H.map(C=>e.jsx(ve.Cell,{fill:C.fill},C.name))}),E?e.jsx("text",{x:"50%",y:"50%",textAnchor:"middle",dominantBaseline:"middle",fill:"var(--text-main)",fontSize:18,fontWeight:700,letterSpacing:"-0.02em",children:f(q)}):null]})})}),c?e.jsx("ul",{className:"bonsaif-pie-legend","aria-label":"Leyenda",children:H.map(C=>e.jsxs("li",{className:"bonsaif-pie-legend-item",children:[e.jsx("span",{className:"bonsaif-pie-legend-swatch",style:{background:C.fill},"aria-hidden":!0}),e.jsx("span",{className:"bonsaif-pie-legend-label",title:C.name,children:C.name}),e.jsx("span",{className:"bonsaif-pie-legend-value",children:f(C.value)})]},C.name))}):null]})})}function Ld(r){const{outerRadius:t=0,...n}=r;return e.jsx(ve.Sector,{...n,outerRadius:Number(t)+4,stroke:"var(--bg-card)",strokeWidth:2})}function Td({data:r,dataKey:t,width:n="100%",height:a=36,tone:s="primary",color:l,fill:i=!0,className:c="",ariaLabel:u="Sparkline"}){const f=l??sr(s),p=r.map(k=>St(k[t])).filter(k=>k!==null);if(p.length<2)return e.jsx("div",{className:c,style:{width:n,height:a,color:"var(--text-muted)"},"aria-label":u});const b=120,m=36,v=3,y=1,S=Math.min(...p),H=Math.max(...p)-S||1,_=p.map((k,K)=>{const P=y+K/(p.length-1)*(b-y*2),q=m-v-(k-S)/H*(m-v*2);return{x:P,y:q}}),E=_.map((k,K)=>`${K===0?"M":"L"}${k.x.toFixed(2)} ${k.y.toFixed(2)}`).join(" "),L=`${E} L${_[_.length-1].x.toFixed(2)} ${m} L${_[0].x.toFixed(2)} ${m} Z`,N=`bonsaif-spark-${t.replace(/[^a-zA-Z0-9_-]/g,"")}-${s}`;return e.jsx("div",{className:`bonsaif-sparkline ${c}`,style:{width:n,height:a},role:"img","aria-label":u,children:e.jsxs("svg",{width:"100%",height:"100%",viewBox:`0 0 ${b} ${m}`,preserveAspectRatio:"none",focusable:"false",children:[i?e.jsx("defs",{children:e.jsxs("linearGradient",{id:N,x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:f,stopOpacity:.38}),e.jsx("stop",{offset:"100%",stopColor:f,stopOpacity:0})]})}):null,i?e.jsx("path",{d:L,fill:`url(#${N})`}):null,e.jsx("path",{d:E,fill:"none",stroke:f,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",vectorEffect:"non-scaling-stroke"})]})})}function $d({data:r,xKey:t,series:n,barSeries:a,lineSeries:s,height:l=280,className:i="",loading:c=!1,emptyText:u="Sin datos para mostrar",showGrid:f=!0,showLegend:p=!0,showTooltip:b=!0,margin:m,valueFormat:v=tr,yDomain:y,ariaLabel:S="Gráfico combinado",barRadius:h=6,zoomable:H=!1,zoomMode:_="both",brushHeight:E,onZoomChange:L}){const N=a??n.slice(0,Math.max(1,n.length-1)),k=s??(n.length>1?n.slice(-1):n.length?[n[0]]:[]),K=[...N,...k.filter(j=>!N.some(W=>W.key===j.key))],P=on(r,K),q=Mt(N),X=Mt(K),J=k.map(j=>{var ae;const W=X.find(Z=>Z.key===j.key);return{...j,label:j.label??j.key,color:j.color??(W==null?void 0:W.color)??((ae=X[0])==null?void 0:ae.color)}}),C=ln(r,t,{zoomable:H,zoomMode:_,brushHeight:E,onZoomChange:L}),te=Et({...m,...C.marginExtra});return c?e.jsx(nr,{height:l}):P?e.jsx(ar,{height:l,text:u}):e.jsxs("div",{className:`bonsaif-chart bonsaif-combo-chart w-full ${i}`,role:"img","aria-label":S,style:{height:l},children:[e.jsx(cn,{visible:C.isZoomed,onReset:C.resetZoom}),e.jsx(ve.ResponsiveContainer,{width:"100%",height:"100%",children:e.jsxs(ve.ComposedChart,{data:C.viewData,margin:te,barCategoryGap:"34%",...C.chartHandlers,children:[f?e.jsx(ve.CartesianGrid,{strokeDasharray:"2 8",stroke:Lt(),vertical:!1}):null,e.jsx(ve.XAxis,{dataKey:t,tick:Ze(),tickLine:!1,axisLine:!1,interval:"preserveStartEnd",minTickGap:36,dy:6}),e.jsx(ve.YAxis,{tick:Ze(),tickLine:!1,axisLine:!1,width:44,domain:y??["auto","auto"],tickFormatter:j=>v(Number(j)),dx:-2}),b?e.jsx(Rr,{valueFormat:v,cursor:{fill:"color-mix(in srgb, var(--primary) 8%, transparent)"}}):null,p?e.jsx(ve.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:sn()}):null,q.map(j=>e.jsx(ve.Bar,{dataKey:j.key,name:j.label,fill:j.color,fillOpacity:.88,radius:[h,h,2,2],maxBarSize:18,isAnimationActive:!0,animationDuration:$r,animationEasing:Ar},j.key)),J.map(j=>e.jsx(ve.Line,{type:"monotone",dataKey:j.key,name:j.label,stroke:j.color,strokeWidth:2.5,isAnimationActive:!0,animationDuration:$r,animationEasing:Ar,dot:!1,activeDot:{r:5,strokeWidth:2,stroke:"var(--bg-card)",fill:j.color}},j.key)),C.zoomNodes]})})]})}function Ad({data:r,xKey:t,valueKey:n,typeKey:a,height:s=280,className:l="",loading:i=!1,emptyText:c="Sin datos para mostrar",showGrid:u=!0,showTooltip:f=!0,margin:p,valueFormat:b=tr,ariaLabel:m="Gráfico waterfall",increaseColor:v="#34d399",decreaseColor:y="#f87171",totalColor:S="var(--primary)"}){const h=o.useMemo(()=>Dd(r,{xKey:t,valueKey:n,typeKey:a,increaseColor:v,decreaseColor:y,totalColor:S}),[r,t,n,a,v,y,S]),H=!h.length,_=Et(p);return i?e.jsx(nr,{height:s}):H?e.jsx(ar,{height:s,text:c}):e.jsx("div",{className:`bonsaif-chart bonsaif-waterfall-chart w-full ${l}`,role:"img","aria-label":m,style:{height:s},children:e.jsx(ve.ResponsiveContainer,{width:"100%",height:"100%",children:e.jsxs(ve.BarChart,{data:h,margin:_,barCategoryGap:"42%",children:[u?e.jsx(ve.CartesianGrid,{strokeDasharray:"2 8",stroke:Lt(),vertical:!1}):null,e.jsx(ve.XAxis,{dataKey:"label",tick:Ze(),tickLine:!1,axisLine:!1,interval:0,dy:6}),e.jsx(ve.YAxis,{tick:Ze(),tickLine:!1,axisLine:!1,width:44,tickFormatter:E=>b(Number(E)),dx:-2}),f?e.jsx(Rr,{valueFormat:b,cursor:{fill:"color-mix(in srgb, var(--primary) 8%, transparent)"}}):null,e.jsx(ve.Bar,{dataKey:"base",stackId:"wf",fill:"transparent",isAnimationActive:!1,legendType:"none",maxBarSize:22}),e.jsx(ve.Bar,{dataKey:"delta",name:"Valor",stackId:"wf",radius:[6,6,2,2],maxBarSize:22,isAnimationActive:!0,animationDuration:$r,animationEasing:Ar,children:h.map(E=>e.jsx(ve.Cell,{fill:E.color},E.label))})]})})})}function Dd(r,t){let n=0;return r.map((a,s)=>{const l=St(a[t.valueKey])??0,i=t.typeKey?String(a[t.typeKey]??""):"",c=i==="total"||s===r.length-1&&i!=="increase"&&i!=="decrease";let u="increase",f=0,p=0,b=l;return c&&i==="total"?(u="total",f=0,p=Math.abs(l),b=l,n=l):c&&s===r.length-1&&!i?(u="total",f=0,p=Math.abs(n),b=n):(u=i==="decrease"||l<0?"decrease":"increase",u==="decrease"?(f=n+l,p=Math.abs(l),n=n+l):(f=n,p=Math.abs(l),n=n+l),b=l),{label:String(a[t.xKey]??""),base:f,delta:p,display:b,kind:u,color:u==="total"?t.totalColor:u==="decrease"?t.decreaseColor:t.increaseColor}})}const et=135*Math.PI/180,fa=270*Math.PI/180;function Id({value:r,min:t=0,max:n=100,height:a=180,className:s="",loading:l=!1,empty:i=!1,emptyText:c="Sin datos para mostrar",label:u,valueFormat:f=tr,tone:p="primary",color:b,thresholds:m,ariaLabel:v="Gauge",animationDuration:y=700,thickness:S=9,showScale:h=!1}){const H=o.useId().replace(/:/g,""),_=n-t||1,E=Math.min(1,Math.max(0,(r-t)/_)),[L,N]=o.useState(y>0?0:E);if(o.useEffect(()=>{if(l||i)return;if(y<=0){N(E);return}if(typeof window<"u"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches){N(E);return}let Z=0,$=0;N(M=>($=M,M));const ee=performance.now(),se=M=>{const O=Math.min(1,(M-ee)/y),oe=1-(1-O)**3;N($+(E-$)*oe),O<1&&(Z=requestAnimationFrame(se))};return Z=requestAnimationFrame(se),()=>cancelAnimationFrame(Z)},[E,y,l,i]),l)return e.jsx(nr,{height:a});if(i)return e.jsx(ar,{height:a,text:c});const k=100,K=108,P=72,q=b??Bd(r,n,p,m),X=t+L*_,J=ls(k,K,P,et,et+fa),C=et+Math.max(.001,L)*fa,te=ls(k,K,P,et,C),j=un(k,K,P,et),W=un(k,K,P,et+fa);return e.jsx("div",{className:`bonsaif-chart bonsaif-gauge-chart flex flex-col items-center justify-center ${s}`,style:{height:a},children:e.jsxs("svg",{viewBox:"0 0 200 168",width:"100%",height:"100%",role:"img","aria-label":v,className:"overflow-visible",children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:`bonsaif-gauge-${H}`,x1:"0",y1:"0",x2:"1",y2:"0",children:[e.jsx("stop",{offset:"0%",stopColor:q,stopOpacity:.82}),e.jsx("stop",{offset:"100%",stopColor:q,stopOpacity:1})]})}),e.jsx("path",{d:J,fill:"none",stroke:"color-mix(in srgb, var(--border) 70%, transparent)",strokeWidth:S,strokeLinecap:"butt"}),e.jsx("path",{d:te,fill:"none",stroke:`url(#bonsaif-gauge-${H})`,strokeWidth:S,strokeLinecap:"butt",className:"bonsaif-chart-gauge-value"}),e.jsx("text",{x:k,y:K-(u?4:0),textAnchor:"middle",dominantBaseline:"middle",fill:"var(--text-main)",fontSize:28,fontWeight:700,letterSpacing:"-0.04em",className:"bonsaif-chart-gauge-label",children:f(X)}),u?e.jsx("text",{x:k,y:K+18,textAnchor:"middle",fill:"var(--text-muted)",fontSize:11,fontWeight:600,letterSpacing:"0.06em",children:u}):null,h?e.jsxs(e.Fragment,{children:[e.jsx("text",{x:j.x-2,y:j.y+S+14,textAnchor:"middle",fill:"var(--text-muted)",fontSize:10,children:f(t)}),e.jsx("text",{x:W.x+2,y:W.y+S+14,textAnchor:"middle",fill:"var(--text-muted)",fontSize:10,children:f(n)})]}):null]})})}function Bd(r,t,n,a){if(a!=null&&a.length){const l=[...a].sort((c,u)=>c.value-u.value);let i=l[0].color;for(const c of l)r>=c.value&&(i=c.color);return i}if(n)return sr(n);const s=r/(t||1);return s>=.8?sr("success"):s>=.5?sr("warning"):sr("danger")}function un(r,t,n,a){return{x:r+n*Math.cos(a),y:t+n*Math.sin(a)}}function ls(r,t,n,a,s){const l=un(r,t,n,a),i=un(r,t,n,s),c=s-a,u=Math.abs(c)>Math.PI?1:0;return`M ${l.x} ${l.y} A ${n} ${n} 0 ${u} 1 ${i.x} ${i.y}`}function Od({value:r,target:t,max:n,ranges:a,height:s=72,className:l="",loading:i=!1,empty:c=!1,emptyText:u="Sin datos para mostrar",label:f,subtitle:p,valueFormat:b=tr,tone:m="primary",showScale:v=!0,showStatus:y=!0,ariaLabel:S="Bullet chart"}){if(i)return e.jsx(nr,{height:s});if(c)return e.jsx(ar,{height:s,text:u});const h=n??Math.max(r,t,...(a==null?void 0:a.map(q=>q.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((q,X)=>q.value-X.value),E=sr(m),L=Math.min(100,Math.max(0,r/h*100)),N=Math.min(100,Math.max(0,t/h*100)),k=r>=t,K=[0,.25,.5,.75,1].map(q=>q*h),P=e.jsxs("div",{className:"bonsaif-bullet-plot min-w-0 flex-1",children:[e.jsxs("div",{className:"bonsaif-bullet-track relative w-full",style:{height:Math.max(22,f?28:s*.42)},role:"img","aria-label":S,children:[e.jsx("div",{className:"bonsaif-bullet-ranges absolute inset-0 flex overflow-hidden",children:_.map((q,X)=>{const J=X===0?0:_[X-1].value,C=Math.max(0,(q.value-J)/h*100);return e.jsx("div",{style:{width:`${C}%`,background:q.color??`color-mix(in srgb, var(--border) ${70-X*18}%, transparent)`}},X)})}),e.jsx("div",{className:"absolute left-0 top-1/2 w-full",style:{height:"34%",transform:"translateY(-50%)"},children:e.jsx("div",{className:"bonsaif-bullet-value h-full",style:{width:`${L}%`,background:E,borderRadius:"0 999px 999px 0",boxShadow:`0 0 12px color-mix(in srgb, ${E} 35%, transparent)`}})}),e.jsx("div",{className:"bonsaif-bullet-target absolute top-1/2 z-[1]",style:{left:`${N}%`,height:"72%",width:3,transform:"translate(-50%, -50%)",background:E,borderRadius:1,boxShadow:"0 0 0 1px color-mix(in srgb, var(--bg-card) 70%, transparent)"},title:`Meta ${b(t)}`})]}),v?e.jsx("div",{className:"bonsaif-bullet-scale relative mt-1.5 h-4 w-full",children:K.map((q,X)=>{const J=q/h*100,C=X===0,te=X===K.length-1;return e.jsxs("div",{className:"absolute top-0",style:{left:`${J}%`,transform:C?"none":te?"translateX(-100%)":"translateX(-50%)"},children:[e.jsx("div",{className:"mx-auto h-1.5 w-px",style:{background:"color-mix(in srgb, var(--text-muted) 55%, transparent)",marginLeft:C?0:te?"auto":void 0,marginRight:te?0:void 0}}),e.jsx("div",{className:"bonsaif-bullet-scale-label mt-0.5 tabular-nums",style:{color:"var(--text-muted)",textAlign:C?"left":te?"right":"center"},children:b(q)})]},q)})}):null]});return e.jsx("div",{className:`bonsaif-chart bonsaif-bullet-chart w-full ${l}`,children:f?e.jsxs("div",{className:"bonsaif-bullet-row flex flex-col gap-2 sm:flex-row sm:items-start sm:gap-4",children:[e.jsxs("div",{className:"bonsaif-bullet-label shrink-0 sm:w-[7.5rem] sm:pt-1 sm:text-right",children:[e.jsx("div",{className:"text-sm font-semibold tracking-tight",style:{color:"var(--text-main)"},children:f}),p?e.jsx("div",{className:"mt-0.5 text-[11px] leading-snug",style:{color:"var(--text-muted)"},children:p}):e.jsxs("div",{className:"mt-0.5 text-[11px] tabular-nums leading-snug",style:{color:"var(--text-muted)"},children:[e.jsx("span",{style:{color:E,fontWeight:600},children:b(r)}),e.jsxs("span",{children:[" / meta ",b(t)]})]}),y?e.jsx("div",{className:"bonsaif-bullet-status mt-1.5 inline-flex text-[10px] font-bold uppercase tracking-wide",style:{color:sr(k?"success":"warning")},children:k?"En meta":"Bajo meta"}):null]}),P]}):P})}function Hd({data:r,value:t,timeKey:n="t",usageKey:a="usage",series:s,cores:l,height:i=220,className:c="",loading:u=!1,emptyText:f="Sin datos de CPU",showLegend:p=!1,showTooltip:b=!0,thresholds:m,label:v="CPU",ariaLabel:y="Uso de CPU"}){var N;const S=s??[{key:a,label:"Uso",color:Ct(t??Jr(r,a)??0,m)}],h=t??Jr(r,a)??Jr(r,((N=S[0])==null?void 0:N.key)??a),H=!u&&(!r.length||h===null);if(u)return e.jsx(nr,{height:i});if(H)return e.jsx(ar,{height:i,text:f});const _=Math.min(100,Math.max(0,h??0)),E=an(_,m),L=Ct(_,m);return e.jsxs("div",{className:`bonsaif-chart bonsaif-cpu-chart w-full ${c}`,role:"group","aria-label":y,children:[e.jsxs("div",{className:"bonsaif-metric-head",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"bonsaif-metric-kicker",children:[v,l!=null?e.jsxs("span",{className:"ml-1.5 normal-case tracking-normal opacity-80",children:["· ",l," ",l===1?"core":"cores"]}):null]}),e.jsx("div",{className:"bonsaif-metric-value",style:{color:L},children:Zr(_,_<10?1:0)})]}),e.jsx("div",{className:"bonsaif-metric-badge",style:{color:L,background:`color-mix(in srgb, ${L} 14%, transparent)`},children:E==="danger"?"Crítico":E==="warning"?"Alto":"Normal"})]}),e.jsx(dn,{data:r,xKey:n,series:S.map(k=>({...k,color:k.color??L})),height:Math.max(120,i-56),yDomain:[0,100],showLegend:p,showTooltip:b,valueFormat:k=>Zr(k,0),ariaLabel:y,opacity:.22,margin:{top:8,right:8,bottom:4,left:0}})]})}function Pd({used:r,total:t,cached:n,data:a=[],timeKey:s="t",usageKey:l="usage",height:i=220,className:c="",loading:u=!1,emptyText:f="Sin datos de memoria",showHistory:p=!0,showTooltip:b=!0,thresholds:m,label:v="RAM",ariaLabel:y="Uso de memoria"}){const S=t>0?t:1,h=Math.min(100,Math.max(0,r/S*100)),H=!u&&!(Number.isFinite(r)&&Number.isFinite(t)&&t>0);if(u)return e.jsx(nr,{height:i});if(H)return e.jsx(ar,{height:i,text:f});const _=an(h,m),E=Ct(h,m),L=Math.max(0,t-r),N=a.length>0?Jr(a,l)??h:h,k=Ct(N,m),K=p&&a.length>1?Math.max(100,i-110):0;return e.jsxs("div",{className:`bonsaif-chart bonsaif-ram-chart w-full ${c}`,role:"group","aria-label":y,children:[e.jsxs("div",{className:"bonsaif-metric-head",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"bonsaif-metric-kicker",children:v}),e.jsxs("div",{className:"flex items-baseline gap-2",children:[e.jsx("span",{className:"bonsaif-metric-value",style:{color:E},children:Zr(h,h<10?1:0)}),e.jsxs("span",{className:"text-sm tabular-nums",style:{color:"var(--text-secondary)"},children:[Qr(r)," / ",Qr(t)]})]})]}),e.jsx("div",{className:"bonsaif-metric-badge",style:{color:E,background:`color-mix(in srgb, ${E} 14%, transparent)`},children:_==="danger"?"Crítico":_==="warning"?"Alto":"Normal"})]}),e.jsxs("div",{className:"mb-2",children:[e.jsx("div",{className:"h-2 w-full overflow-hidden rounded-sm",style:{background:"color-mix(in srgb, var(--border) 55%, transparent)"},role:"progressbar","aria-valuenow":Math.round(h),"aria-valuemin":0,"aria-valuemax":100,"aria-label":`${v} ${Zr(h,0)}`,children:e.jsx("div",{className:"h-full rounded-sm transition-[width] duration-300",style:{width:`${h}%`,background:`linear-gradient(90deg, ${E}, color-mix(in srgb, ${E} 55%, #38bdf8))`}})}),e.jsxs("div",{className:"mt-2 flex flex-wrap gap-x-4 gap-y-1 text-[11px] tabular-nums",style:{color:"var(--text-muted)"},children:[e.jsxs("span",{children:[e.jsx("span",{className:"font-medium",style:{color:"var(--text-main)"},children:"Usada"})," ",Qr(r)]}),n!=null&&Number.isFinite(n)?e.jsxs("span",{children:[e.jsx("span",{className:"font-medium",style:{color:"var(--text-main)"},children:"Caché"})," ",Qr(n)]}):null,e.jsxs("span",{children:[e.jsx("span",{className:"font-medium",style:{color:"var(--text-main)"},children:"Libre"})," ",Qr(L)]})]})]}),p&&a.length>1?e.jsx(dn,{data:a,xKey:s,series:[{key:l,label:"Uso",color:k}],height:K,yDomain:[0,100],showLegend:!1,showTooltip:b,valueFormat:P=>Zr(P,0),ariaLabel:`${y} — historial`,opacity:.22,margin:{top:8,right:8,bottom:4,left:0}}):null]})}const Fd="color-mix(in srgb, var(--primary) 25%, #38bdf8)",zd="color-mix(in srgb, var(--primary) 20%, #2dd4bf)";function _d({data:r,timeKey:t="t",inboundKey:n="in",outboundKey:a="out",inbound:s,outbound:l,unit:i="bytes",inboundLabel:c="Entrada",outboundLabel:u="Salida",inboundColor:f=Fd,outboundColor:p=zd,height:b=240,className:m="",loading:v=!1,emptyText:y="Sin datos de red",showLegend:S=!1,showTooltip:h=!0,label:H="Network",ariaLabel:_="Tráfico de red"}){const E=s??Jr(r,n)??0,L=l??Jr(r,a)??0,N=!v&&r.length===0;if(v)return e.jsx(nr,{height:b});if(N)return e.jsx(ar,{height:b,text:y});const k=q=>es(q,i),P=Math.max(140,b-76);return e.jsxs("div",{className:`bonsaif-chart bonsaif-network-chart w-full ${m}`,role:"group","aria-label":_,children:[e.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:e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"bonsaif-metric-kicker",children:H}),e.jsxs("div",{className:"mt-2 grid grid-cols-2 gap-5 sm:max-w-lg",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-[11px]",style:{color:"var(--text-muted)"},children:[e.jsx("span",{className:"h-3 w-1.5 shrink-0 rounded-sm",style:{background:f},"aria-hidden":!0}),c]}),e.jsx("div",{className:"mt-1 truncate text-xl font-bold tabular-nums leading-tight tracking-tight",style:{color:f},title:k(E),children:k(E)})]}),e.jsxs("div",{className:"min-w-0 pl-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-[11px]",style:{color:"var(--text-muted)"},children:[e.jsx("span",{className:"h-3 w-1.5 shrink-0 rounded-sm",style:{background:p},"aria-hidden":!0}),u]}),e.jsx("div",{className:"mt-1 truncate text-lg font-semibold tabular-nums leading-tight tracking-tight opacity-95",style:{color:p},title:k(L),children:k(L)})]})]})]})}),e.jsx("div",{className:"bonsaif-network-plot relative z-0",children:e.jsx(dn,{data:r,xKey:t,series:[{key:n,label:c,color:f},{key:a,label:u,color:p}],height:P,showLegend:S,showTooltip:h,valueFormat:k,ariaLabel:_,opacity:.18,margin:{top:8,right:8,bottom:4,left:4}})})]})}const is=["primeSuiteOrigin","primeAuthOrigin","primeSuiteAppUrl"],cs=["primeSuiteOrigin","primeSuiteProjectKey"];function jd(){if(typeof window>"u")return"*";try{if(window.parent===window)return"*";const r=new URLSearchParams(window.location.search);for(const t of is){const n=r.get(t);if(n){const a=fn(n);if(a)return a}}if(typeof sessionStorage<"u")for(const t of cs){const n=sessionStorage.getItem(t);if(n)try{const a=new URL(n);if(a.origin&&a.origin!==window.location.origin)return a.origin}catch{const a=fn(n);if(a)return a}}if(document.referrer){const t=fn(document.referrer);if(t&&t!==window.location.origin)return t}return"*"}catch{return"*"}}function Wd(){if(typeof window>"u")return"self";try{if(window.parent===window)return"self";const r=new URLSearchParams(window.location.search);for(const t of is)if(r.get(t))return"query";if(typeof sessionStorage<"u"){for(const t of cs)if(sessionStorage.getItem(t))return"sessionStorage"}if(document.referrer){const t=fn(document.referrer);if(t&&t!==window.location.origin)return"referrer"}return"wildcard"}catch{return"wildcard"}}function fn(r){if(!r)return null;const t=r.trim().replace(/\/+$/,"");if(!t)return null;if(/^https?:\/\/[^/]+$/.test(t))return t;try{return new URL(t).origin}catch{return null}}function qd(r){const[t,n]=o.useState({}),[a,s]=o.useState(!1),l=o.useCallback(f=>a||t[f]?r[f]:void 0,[r,a,t]),i=o.useCallback(f=>{n(p=>({...p,[f]:!0}))},[]),c=o.useCallback(()=>{s(!0)},[]),u=o.useCallback(()=>{n({}),s(!1)},[]);return{submitted:a,touchedFields:t,getFieldError:l,touchField:i,submit:c,reset:u}}Object.defineProperty(z,"toast",{enumerable:!0,get:()=>$a.toast}),z.Alert=cl,z.AreaChart=dn,z.AuthShell=Xo,z.BarChart=Cd,z.BonsaifButton=Gs,z.BonsaifUIToaster=xd,z.BulletChart=Od,z.Button=Fe,z.CHART_PALETTE=nn,z.CalendarPicker=pl,z.ChartCard=yd,z.Checkbox=Wt,z.CodeBlock=xl,z.ComboChart=$d,z.CompactFilterSelect=kl,z.CompactSearchInput=wl,z.ConfirmDialog=El,z.CopyButton=_n,z.CopyLinkButton=$l,z.CpuChart=Hd,z.DataSheets=ti,z.DataTable=Ja,z.DateRangePicker=oi,z.DonutChart=Md,z.Drawer=di,z.DropdownMenu=ii,z.DynamicDetailTabs=ll,z.EmailField=Ii,z.EmptyState=Oi,z.FieldHelperFooter=Xr,z.FieldLabelInfo=Kr,z.FieldLayoutEditor=ji,z.FileUpload=zi,z.FormField=uo,z.GaugeChart=Id,z.GlobalScrollbars=Wo,z.InputField=Qn,z.LineChart=Sd,z.LoadingState=Fa,z.MentionTextEditor=Bo,z.MicroserviceFrame=pd,z.Modal=qn,z.MouseTooltip=Mr,z.MultiSelect=qi,z.NetworkChart=_d,z.NumberField=Ui,z.PageHeader=ud,z.PageSearchInput=Ia,z.Pagination=Gi,z.PhoneField=Xi,z.PieChart=Ed,z.PrimeAuthRouteShell=fd,z.PrimeSuiteChatFrame=md,z.RadioGroup=Yi,z.RamChart=Pd,z.RichTextEditor=xc,z.SearchableSelect=Lr,z.SectionPanel=yc,z.Sparkline=Td,z.StatusBadge=Nc,z.StatusSelect=Lc,z.StepWizard=$c,z.TableSkeleton=jt,z.Tabs=Tc,z.TagInput=_c,z.TextInput=Qt,z.Textarea=Ho,z.TextareaField=Oc,z.Toggle=Wc,z.UserAvatar=Ko,z.WaterfallChart=Ad,z.buildMentionQueryRegex=No,z.cn=gr,z.configureBonsaifUI=Il,z.dedupeMentions=Lo,z.defaultValueFormat=tr,z.describeParentTargetOrigin=Wd,z.emailFormat=hi,z.extractMentionUsernames=aa,z.filterSelfMentions=bc,z.findMentionTriggerInEditor=ta,z.formatBytes=Qr,z.formatPercent=Zr,z.formatRate=es,z.getBonsaifUIConfig=Bl,z.getDataTablePreferencesEndpoint=Un,z.getPlainTextOffset=oa,z.highlightMentions=To,z.htmlToText=Eo,z.insertMentionInEditor=$o,z.isMentionTriggerBoundary=Co,z.isPlainOffsetInsideMentionChip=So,z.isValidEmail=Xn,z.isValidPhone=Yn,z.locateTextOffset=Yr,z.matches=ki,z.maxLength=xi,z.maxValue=wi,z.mentionDisplayLabel=Mo,z.minLength=vi,z.minValue=yi,z.normalizeUsername=na,z.phoneCountryCodeOptions=po,z.phoneFormat=gi,z.placeCaretAtTextOffset=Ao,z.required=mi,z.resetBonsaifUIConfig=Ol,z.resolveMentions=fc,z.resolveParentTargetOrigin=jd,z.seriesColor=Ro,z.setBonsaifDataTablePreferencesEndpoint=Hl,z.toneColor=sr,z.usageColor=Ct,z.usageTone=an,z.useValidationVisibility=qd,z.validateForm=Ni,Object.defineProperty(z,Symbol.toStringTag,{value:"Module"})}));
|
|
42
|
+
`}),L.map(B=>{const te=Fc(B.colorIndex);return Y===B.id?e.jsx("input",{ref:ae,value:U,disabled:s,onChange:z=>V(z.target.value),onKeyDown:z=>ne(z,B.id),onBlur:()=>oe(B.id,U),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(U.length+2,6)}ch`}},B.id):e.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:te.bg,color:te.text,border:`1px solid ${te.border}`},children:[e.jsx("span",{className:"truncate",children:B.value}),e.jsx("button",{type:"button","aria-label":`Editar "${B.value}"`,disabled:s,tabIndex:-1,onClick:z=>{z.stopPropagation(),A(B)},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:e.jsx(T.HiPencil,{className:"h-3 w-3"})}),e.jsx("button",{type:"button","aria-label":`Eliminar "${B.value}"`,disabled:s,tabIndex:-1,onClick:z=>{z.stopPropagation(),H(B.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:e.jsx(T.HiXMark,{className:"h-3.5 w-3.5"})})]},B.id)}),!R&&e.jsx("input",{ref:j,value:N,disabled:s,placeholder:L.length===0?a:"",onChange:B=>k(B.target.value),onKeyDown:q,onPaste:Q,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"})]}),e.jsx(Xr,{error:v,helperText:b,helperDisplay:m})]})}const qc={xs:{width:28,height:16,thumb:12,padding:2},sm:{width:36,height:20,thumb:16,padding:2}};function Uc({checked:r,disabled:t,onCheckedChange:n,size:a="sm",className:s="",...l}){const i=qc[a],c=r?i.width-i.thumb-i.padding*2:0;return e.jsx("button",{...l,type:"button",role:"switch","aria-checked":r,disabled:t,onClick:()=>!t&&n(!r),className:`relative inline-flex shrink-0 items-center rounded-full transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--primary)]/50 disabled:cursor-not-allowed disabled:opacity-50 ${s}`,style:{width:i.width,height:i.height,background:r?"color-mix(in srgb, var(--primary) 85%, transparent)":"var(--bg-input)",border:r?"1px solid color-mix(in srgb, var(--primary) 55%, transparent)":"1px solid var(--border)"},children:e.jsx("span",{className:"absolute inline-block rounded-full transition-transform",style:{width:i.thumb,height:i.thumb,left:i.padding,top:"50%",transform:`translate(${c}px, -50%)`,background:r?"var(--primary-fg)":"var(--text-muted)"}})})}const zo=[".sidebar-scroll",".app-scroll",".showcase-nav-scroll","[data-overlay-scroll='true']"].join(","),Vc=[":scope > [data-overlayscrollbars-contents]",":scope > .sidebar-scroll-body",":scope > .showcase-nav-scroll-body",":scope > .app-scroll-body"].join(", ");function Gc(r){if(!(r instanceof HTMLElement)||r.dataset.overlayScroll==="false"||r.matches("[data-overlayscrollbars]")||r.closest("[data-overlayscrollbars]")||r.matches("textarea,input,select,[contenteditable='true']"))return!1;const t=window.getComputedStyle(r);return!(![t.overflow,t.overflowX,t.overflowY].join(" ").match(/auto|scroll/)||r.clientWidth===0&&r.clientHeight===0)}function _o(r){return r.classList.contains("sidebar-scroll")||r.classList.contains("showcase-nav-scroll")}function jo(r){_o(r)&&r.querySelectorAll(".os-scrollbar-horizontal").forEach(t=>{t.style.display="none",t.style.height="0",t.style.pointerEvents="none"})}function Kc(r){const t=r.querySelector(Vc);return t instanceof HTMLElement?t:null}function Wo(){return o.useEffect(()=>{const r=new WeakMap;let t=0;const n=()=>{t=0,document.querySelectorAll(zo).forEach(l=>{if(!(l instanceof HTMLElement))return;if(Hn.OverlayScrollbars(l)){jo(l);return}if(!Gc(l))return;const c={overflow:_o(l)?{x:"hidden",y:"scroll"}:void 0,scrollbars:{autoHide:"leave",autoHideDelay:180}},u=Kc(l),f=u?Hn.OverlayScrollbars({target:l,elements:{viewport:u}},c):Hn.OverlayScrollbars(l,c);jo(l),r.set(l,f)})},a=()=>{t||(t=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),()=>{t&&window.cancelAnimationFrame(t),s.disconnect(),window.removeEventListener("resize",a),document.querySelectorAll(zo).forEach(l=>{var i;l instanceof HTMLElement&&((i=r.get(l))==null||i.destroy())})}},[]),null}function wr(r){const t=r.trim();return!t||t==="/"||t==="/."?"":(t.startsWith("/")?t:`/${t}`).replace(/\/+$/,"")}function qo(r){try{const t=new URL(r);return wr(t.pathname)}catch{return""}}function Xc(r){const t=wr(r);if(!t)return"";const n=t.match(/^\/apps\/[^/]+/i);if(n)return wr(n[0]);const a=t.split("/").filter(Boolean);return a.length===0?"":a.length>=2&&a[0].toLowerCase()==="apps"?wr(`/${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())?"":wr(`/${a[0]}`)}const ia="primeSuiteAppUrl",Yc={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"}},Uo={xs:20,sm:28,md:36,lg:48,xl:64},Vo=["bg-indigo-500","bg-blue-500","bg-emerald-500","bg-violet-500","bg-amber-500","bg-teal-500","bg-rose-500","bg-cyan-500"],Zc={xs:"text-xs",sm:"text-sm",md:"text-base",lg:"text-lg"},Qc="bonsaif.bot",Jc="Bonsaif Bot",Rc={xs:"p-0.5",sm:"p-1",md:"p-1.5",lg:"p-2",xl:"p-2.5"};function Go(r){return typeof r=="string"?r.trim():""}function ed(r){var s;if(r!==void 0)return wr(r);const t=wr(typeof process<"u"&&((s=process.env)==null?void 0:s.NEXT_PUBLIC_BASE_PATH)||"");if(t)return t;if(typeof window>"u")return"";try{const i=new URLSearchParams(window.location.search).get(ia)||"";i&&window.sessionStorage.setItem(ia,i);const c=window.sessionStorage.getItem(ia)||"",u=i||c;if(u){const f=qo(u);if(f&&!/^\/admin(\/|$)/i.test(f))return f}}catch{}const n=window.__NEXT_DATA__,a=(n==null?void 0:n.assetPrefix)||"";if(a){const l=a.startsWith("http")?qo(a):wr(a);if(l&&!/^\/admin(\/|$)/i.test(l))return l}return Xc(window.location.pathname)}function rd(r){const t=r.split(/\s+/).map(n=>n.trim()).filter(Boolean);return t.length===0?"?":t.length===1?t[0].slice(0,1).toUpperCase():`${t[0].slice(0,1)}${t[1].slice(0,1)}`.toUpperCase()}function td(r){let t=0;for(const n of r)t=t*31+n.charCodeAt(0)&65535;return Vo[t%Vo.length]}function nd(r,t){return r===Qc||t===Jc}function ad(r,t){return`${r.replace(/\/$/,"")}${t}`}function Ko({userId:r,username:t,name:n,size:a="md",showName:s=!1,showTooltip:l,tooltipContent:i,fallbackLabel:c="Usuario",basePath:u,wrapperClassName:f="",labelClassName:p="",labelSize:b="xs",avatarVersion:m=0,className:v="",style:y}){const[S,h]=o.useState(!1),P=typeof r=="string"&&r.trim()&&r!=="undefined"&&r!=="null"?r.trim():"";o.useEffect(()=>{h(!1)},[P,m]);const{wh:O,text:E}=Yc[a],L=Go(n)||Go(t)||c,N=rd(L),k=ed(u),Y=nd(t,n),F=ad(k,"/favicon.svg"),U=o.useMemo(()=>{if(!P)return"";const W=new URLSearchParams;W.set("size",String(Uo[a])),m&&W.set("v",String(m));const j=W.toString();return`${k}/api/user/avatar/${encodeURIComponent(P)}${j?`?${j}`:""}`},[m,k,P,a]),V=Uo[a],J=Y?e.jsx("span",{className:`${O} ${Rc[a]} rounded-full flex items-center justify-center bg-[#071f1a] ring-1 ring-emerald-400/35 shadow-[0_0_0_1px_rgba(255,255,255,0.06)] flex-shrink-0 ${v}`,style:y,children:e.jsx("img",{src:F,alt:L,width:V,height:V,className:"h-full w-full object-contain"})}):U&&!S?e.jsx("img",{src:U,alt:L,width:V,height:V,className:`${O} rounded-full object-cover flex-shrink-0 ${v}`,style:y,loading:"lazy",referrerPolicy:"no-referrer",onError:()=>h(!0)},`${P}-${m}`):e.jsx("span",{className:`${O} ${td(L)} ${E} rounded-full flex items-center justify-center font-black text-white uppercase flex-shrink-0 ${v}`,style:y,title:L,children:N});if(s)return e.jsxs("span",{className:`inline-flex min-w-0 items-center gap-2 ${f}`,children:[J,e.jsx("span",{className:`min-w-0 truncate ${Zc[b]} font-medium text-[var(--text-main)] ${p}`,title:L,children:L})]});const C=l??!0,re=i??L;return C&&re?e.jsx(Mr,{as:"span",content:re,className:`inline-flex flex-shrink-0 ${f}`,children:J}):J}function od({href:r,className:t,children:n}){return e.jsx("a",{href:r,className:t,children:n})}function sd(r){return r.reduce((t,n)=>{const a=n.section??"Principal";return t[a]=[...t[a]??[],n],t},{})}function Xo({children:r,navItems:t=[],currentPath:n=typeof window>"u"?"/":window.location.pathname,user:a,appName:s="Bonsaif",appLogo:l,header:i,footer:c,onLogout:u,LinkComponent:f=od}){const[p,b]=o.useState(!1),m=sd(t);return e.jsxs("div",{className:"min-h-screen bg-[var(--bg-main)] text-[var(--text-main)]",children:[e.jsx(Wo,{}),e.jsx("button",{type:"button","aria-label":"Abrir navegación",className:"fixed left-3 top-3 z-50 inline-flex h-9 w-9 items-center justify-center rounded-md border border-white/10 bg-black/70 text-white lg:hidden",onClick:()=>b(!0),children:e.jsx(T.HiBars3,{className:"h-5 w-5"})}),p&&e.jsx("button",{type:"button","aria-label":"Cerrar navegación",className:"fixed inset-0 z-40 bg-black/45 lg:hidden",onClick:()=>b(!1)}),e.jsxs("aside",{className:`fixed inset-y-0 left-0 z-50 flex w-72 flex-col bg-[#071716] text-white shadow-2xl transition-transform duration-200 lg:translate-x-0 ${p?"translate-x-0":"-translate-x-full"}`,children:[e.jsxs("div",{className:"flex h-16 items-center gap-3 border-b border-white/10 px-4",children:[e.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg bg-white/10 text-white",children:l??e.jsx(T.HiHome,{className:"h-5 w-5"})}),e.jsx("div",{className:"min-w-0 flex-1 truncate text-sm font-semibold",children:s}),e.jsx("button",{type:"button","aria-label":"Cerrar navegación",className:"inline-flex h-8 w-8 items-center justify-center rounded-md text-white/70 hover:bg-white/10 lg:hidden",onClick:()=>b(!1),children:e.jsx(T.HiXMark,{className:"h-5 w-5"})})]}),e.jsx("nav",{className:"sidebar-scroll min-h-0 flex-1 overflow-y-auto px-3 py-4","data-overlay-scroll":"true",children:e.jsx("div",{className:"sidebar-scroll-body",children:Object.entries(m).map(([v,y])=>e.jsxs("div",{className:"mb-5",children:[e.jsxs("div",{className:"mb-2 flex items-center gap-2 px-2 text-[11px] font-semibold uppercase tracking-wide text-white/35",children:[e.jsx(T.HiChevronDown,{className:"h-3.5 w-3.5"}),v]}),e.jsx("div",{className:"space-y-1",children:y.map(S=>{const h=n===S.href||n.startsWith(`${S.href}/`);return e.jsxs(f,{href:S.href,className:`flex min-w-0 items-center gap-2 rounded-md px-2 py-2 text-sm transition-colors ${h?"bg-white/10 text-white":"text-white/55 hover:bg-white/[0.06] hover:text-white/85"}`,children:[e.jsx("span",{className:"flex h-5 w-5 flex-shrink-0 items-center justify-center",children:S.icon??e.jsx(T.HiHome,{className:"h-4 w-4"})}),e.jsx("span",{className:"truncate",children:S.label})]},S.href)})})]},v))})}),e.jsxs("div",{className:"border-t border-white/10 p-3",children:[a&&e.jsxs("div",{className:"mb-3 flex min-w-0 items-center gap-3 rounded-lg bg-white/[0.04] p-2",children:[e.jsx(Ko,{name:a.initials??a.name??a.email??"Usuario",size:"md"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate text-sm font-medium text-white",children:a.name??"Usuario"}),a.email&&e.jsx("div",{className:"truncate text-xs text-white/45",children:a.email})]})]}),u&&e.jsxs(Fe,{variant:"ghost",className:"w-full justify-start text-white hover:bg-white/10",onClick:u,children:[e.jsx(T.HiArrowRightOnRectangle,{className:"h-4 w-4"})," Salir"]}),c]})]}),e.jsxs("div",{className:"min-h-screen lg:pl-72",children:[i,e.jsx("main",{className:"min-h-screen",children:r})]})]})}const Yo="bonsaif-ui:prime-auth-sso",ld={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"},ca={dashboard:e.jsx(T.HiChartBar,{className:"h-5 w-5"}),tickets:e.jsx(T.HiTicket,{className:"h-5 w-5"}),teams:e.jsx(T.HiUsers,{className:"h-5 w-5"}),projects:e.jsx(T.HiRectangleGroup,{className:"h-5 w-5"}),clients:e.jsx(T.HiBuildingOffice2,{className:"h-5 w-5"}),surveys:e.jsx(T.HiClipboardDocumentList,{className:"h-5 w-5"}),profile:e.jsx(T.HiUser,{className:"h-5 w-5"}),settings:e.jsx(T.HiCog6Tooth,{className:"h-5 w-5"}),notifications:e.jsx(T.HiBell,{className:"h-5 w-5"}),changelog:e.jsx(T.HiDocumentText,{className:"h-5 w-5"}),admin:e.jsx(T.HiShieldCheck,{className:"h-5 w-5"}),users:e.jsx(T.HiUsers,{className:"h-5 w-5"}),roles:e.jsx(T.HiShieldCheck,{className:"h-5 w-5"}),menus:e.jsx(T.HiCog6Tooth,{className:"h-5 w-5"}),guards:e.jsx(T.HiCalendarDays,{className:"h-5 w-5"}),vacations:e.jsx(T.HiCalendarDays,{className:"h-5 w-5"}),audit:e.jsx(T.HiListBullet,{className:"h-5 w-5"}),positions:e.jsx(T.HiBriefcase,{className:"h-5 w-5"}),ranks:e.jsx(T.HiListBullet,{className:"h-5 w-5"}),"email-inbox":e.jsx(T.HiInbox,{className:"h-5 w-5"}),"security-incidents":e.jsx(T.HiShieldCheck,{className:"h-5 w-5"})};function id(r){return r.split("-").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}function cd(r){return/^\d+$/.test(r)||/^[a-f0-9]{8,}$/i.test(r)}function dd(r){const t=r.split("/").filter(Boolean);if(t.length===0||t.length===1&&t[0]==="dashboard")return[];const n=decodeURIComponent(t[t.length-1]),a=t.length>1?decodeURIComponent(t[t.length-2]):void 0,s=cd(n)&&a?a:n,l=ld[s]??id(s);return[{label:"Inicio",href:"/"},{label:l}]}function da(r){return(r==null?void 0:r.querySelector(":scope > .os-viewport"))??(r==null?void 0:r.querySelector(":scope > [data-overlayscrollbars-viewport]"))}function ud(r){const t=r.split("/").filter(Boolean),n=t[t.length-1];if(!n)return e.jsx(T.HiHome,{className:"h-5 w-5"});if(ca[n])return ca[n];const a=t.length>1?t[t.length-2]:"";return ca[a]??e.jsx(T.HiHome,{className:"h-5 w-5"})}function fd(r){return r.includes("primeAuthOrigin")||r.includes("primeAuthProjectKey")}function Zo(){if(typeof window>"u")return!1;if(fd(window.location.href)){try{window.sessionStorage.setItem(Yo,"true")}catch{}return!0}try{return window.sessionStorage.getItem(Yo)==="true"}catch{return!1}}function bd({title:r,subtitle:t,action:n,meta:a,icon:s,className:l="",contentClassName:i="",breadcrumbs:c,currentPath:u,showBreadcrumbs:f=!0,contained:p=!1}){const b=o.useRef(null),[m,v]=o.useState(!1),[y,S]=o.useState(u??"/"),[h,P]=o.useState(()=>Zo()),[O,E]=o.useState(null),L=u??y,N=c??dd(L),k=s??ud(L),Y=f&&!h&&N.length>1,F=!Y;o.useEffect(()=>{u||S(window.location.pathname)},[u]),o.useEffect(()=>{P(Zo())},[]),o.useEffect(()=>{if(p){v(!1);return}let V=null,J=0,C=0;const re=()=>{const ae=b.current,Z=document.querySelector("[data-app-scroll='true']");return(ae==null?void 0:ae.closest(".os-viewport"))??(ae==null?void 0:ae.closest("[data-overlayscrollbars-viewport]"))??da(Z)??Z??window},W=()=>{const ae=V&&V!==window?V.scrollTop:window.scrollY;v(Z=>Z?ae>24:ae>72)},j=()=>{V==null||V.removeEventListener("scroll",W),V=re(),V.addEventListener("scroll",W,{passive:!0}),W()};return j(),J=window.requestAnimationFrame(j),C=window.setTimeout(j,120),()=>{window.cancelAnimationFrame(J),window.clearTimeout(C),V==null||V.removeEventListener("scroll",W)}},[p]),o.useEffect(()=>{if(p){E(null);return}let V=0;const J=[],C=()=>{const ee=b.current,se=ee==null?void 0:ee.parentElement,M=document.querySelector("[data-app-scroll='true']"),H=da(M)??M;if(!ee||!se||!H){E(null);return}const oe=se.getBoundingClientRect(),A=window.getComputedStyle(se),q=H.getBoundingClientRect(),ne=H instanceof HTMLElement&&H.clientWidth>0?H.clientWidth:q.width,ie=oe.left+parseFloat(A.paddingLeft||"0"),Q={marginLeft:Math.round(q.left-ie),width:Math.round(ne)};E(G=>G&&G.marginLeft===Q.marginLeft&&G.width===Q.width?G:Q)},re=()=>{window.cancelAnimationFrame(V),V=window.requestAnimationFrame(C)};re(),window.addEventListener("resize",re);const W=new ResizeObserver(re),j=b.current,ae=j==null?void 0:j.parentElement,Z=document.querySelector("[data-app-scroll='true']"),$=da(Z)??Z;return[ae,Z,$].forEach(ee=>{ee&&W.observe(ee)}),J.push(window.setTimeout(re,120)),J.push(window.setTimeout(re,280)),()=>{window.cancelAnimationFrame(V),window.removeEventListener("resize",re),W.disconnect(),J.forEach(ee=>window.clearTimeout(ee))}},[p]);const U={...O?{marginLeft:O.marginLeft,width:O.width}:null,"--page-header-control-height":m?"34px":"40px","--page-header-control-padding-x":m?"10px":"14px","--page-header-control-icon-left":m?"10px":"12px",background:p?"var(--bg-card)":m?"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:p||m?"1px solid var(--border)":"1px solid transparent",boxShadow:m?"0 10px 28px rgba(12, 54, 53, 0.12)":"none"};return e.jsx("div",{ref:b,"data-page-header":"true","data-compact":m?"true":"false",className:`sticky top-0 z-30 overflow-visible py-0 transition-[background-color,box-shadow,border-color] duration-300 ease-out ${p?"mb-0 flex-shrink-0":"mb-4 sm:mb-0"} ${l}`,style:U,children:e.jsxs("div",{className:`flex flex-wrap items-center justify-between transition-[gap,min-height,padding] duration-300 ease-out ${m?"min-h-8 gap-1.5 px-3 py-0 sm:min-h-9 sm:gap-2":F?"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:[e.jsx("div",{className:`min-w-0 flex flex-1 flex-col justify-center transition-[gap,transform] duration-300 ease-out ${m||F?"gap-1":"gap-1.5 sm:gap-2"}`,children:e.jsxs("div",{className:`flex min-w-0 items-center transition-[gap,transform] duration-300 ease-out ${m||F?"gap-2":"gap-2.5 sm:gap-3"}`,children:[e.jsx("span",{className:`flex-shrink-0 transition-[color,transform,opacity] duration-300 ease-out ${m?"scale-75 opacity-80":"scale-90 opacity-100"}`,style:{color:Y?"var(--text-secondary)":"var(--text-muted)"},children:k}),e.jsxs("div",{className:`flex min-w-0 flex-1 flex-wrap items-center transition-[gap] duration-300 ease-out ${m?"gap-x-2 gap-y-1":"gap-x-3 gap-y-2"}`,children:[e.jsxs("div",{className:"min-w-0 flex-shrink transition-[transform] duration-300 ease-out",children:[e.jsx("h1",{className:`truncate font-bold tracking-tight transition-[font-size,line-height,color] duration-300 ease-out ${m?"text-sm sm:text-base":"text-lg sm:text-xl"}`,style:{color:"var(--text-main)"},children:r}),t&&e.jsx("p",{"aria-hidden":m,className:`overflow-hidden text-xs transition-[max-height,opacity,transform,margin] duration-300 ease-out ${m?"mt-0 max-h-0 -translate-y-1 opacity-0":"mt-0.5 max-h-5 translate-y-0 opacity-100"}`,style:{color:"var(--text-muted)"},children:t})]}),a&&e.jsx("div",{className:`page-header-meta flex min-w-0 flex-1 basis-full items-center overflow-visible transition-[gap,opacity,transform] duration-300 ease-out sm:basis-auto ${m?"translate-y-0 gap-1.5 opacity-95":"gap-2 opacity-100"}`,children:a})]})]})}),n&&e.jsx("div",{className:`page-header-actions ml-auto flex max-w-full flex-shrink-0 flex-wrap items-center justify-end self-center overflow-visible transition-[gap,min-height,opacity,transform] duration-300 ease-out ${m?"min-h-9 gap-1 opacity-95":"min-h-9 gap-1.5 opacity-100"}`,children:e.jsx(Ba.Provider,{value:{compact:!0,headerAction:!0},children:n})})]})})}function pd({children:r,currentPath:t=typeof window>"u"?"/":window.location.pathname,publicRoutes:n=["/","/login","/reset-password"],...a}){return n.includes(t)?e.jsx(e.Fragment,{children:r}):e.jsx(Xo,{currentPath:t,...a,children:r})}function Qo(){if(typeof window>"u")return"system";const r=localStorage.getItem("theme");return r==="light"||r==="dark"?r:r==="system"?"system":document.documentElement.classList.contains("dark")?"dark":"light"}function md(r,t,n){try{const a=new URL(r),s=a.searchParams.get("callbackUrl");if(s){const l=new URL(s,a.origin);return l.searchParams.set("theme",t),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",t),n&&(a.searchParams.set("primeAuthOrigin",window.location.origin),a.searchParams.set("primeAuthProjectKey",n)),a.toString()}catch{return r}}function hd({name:r,src:t,projectKey:n}){const[a,s]=o.useState("system"),l=o.useRef(null);o.useEffect(()=>{s(Qo());const u=new MutationObserver(()=>s(Qo()));return u.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>u.disconnect()},[]);const i=o.useMemo(()=>md(t,a,n),[n,t,a]),c=o.useMemo(()=>{try{return new URL(i).origin}catch{return""}},[i]);return o.useEffect(()=>{if(!n)return;const u=n;function f(p){var v,y,S;if(p.source!==((v=l.current)==null?void 0:v.contentWindow)||c&&p.origin!==c)return;if(((y=p.data)==null?void 0:y.type)==="prime-microservice:overlay"){window.dispatchEvent(new CustomEvent("prime-auth:microservice-overlay",{detail:{active:!!p.data.active}}));return}if(((S=p.data)==null?void 0:S.type)!=="prime-microservice:navigation")return;const b=p.data.path;if(!b||!b.startsWith("/")||b.startsWith("//"))return;const m=`/apps/${encodeURIComponent(u)}${b}`;`${window.location.pathname}${window.location.search}${window.location.hash}`!==m&&(window.history.replaceState(window.history.state,"",m),window.dispatchEvent(new CustomEvent("prime-auth:microservice-navigation")))}return window.addEventListener("message",f),()=>{window.removeEventListener("message",f),window.dispatchEvent(new CustomEvent("prime-auth:microservice-overlay",{detail:{active:!1}}))}},[c,n]),e.jsx("div",{className:"flex h-full min-h-screen flex-col bg-[var(--bg-main)]",children:e.jsx("iframe",{ref:l,src:i,title:r,className:"min-h-0 flex-1 border-0 bg-[var(--bg-main)]",allow:"clipboard-write",sandbox:"allow-downloads allow-forms allow-modals allow-popups allow-same-origin allow-scripts",referrerPolicy:"strict-origin-when-cross-origin"})})}function gd(){const[r,t]=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)&&t(c.src)}).catch(()=>{}),()=>{i=!0}},[]),o.useEffect(()=>{const i=c=>{var f;if(((f=c.data)==null?void 0:f.type)!=="prime-suite-chat:state")return;const u=!!c.data.active;a(u),l({width:Jo(c.data.width,96,720),height:Jo(c.data.height,96,560)})};return window.addEventListener("message",i),()=>window.removeEventListener("message",i)},[]),r?e.jsx("iframe",{title:"Chat Bonsaif",src:r,allow:"clipboard-write",className:"fixed bottom-0 right-0 z-[70] border-0 bg-transparent transition-[width,height] duration-200",style:{width:n?`min(${s.width}px, 100vw)`:96,height:n?`min(${s.height}px, 100vh)`:96,background:"transparent",backgroundColor:"transparent",colorScheme:"normal"}}):null}function Jo(r,t,n){const a=typeof r=="number"&&Number.isFinite(r)?r:t;return Math.max(t,Math.min(n,Math.ceil(a)))}function vd(r){const t=document.documentElement,n=new MutationObserver(r);n.observe(t,{attributes:!0,attributeFilter:["class"]});const a=window.matchMedia("(prefers-color-scheme: dark)");return a.addEventListener("change",r),()=>{n.disconnect(),a.removeEventListener("change",r)}}function xd(){const r=localStorage.getItem("theme")||"system",t=window.matchMedia("(prefers-color-scheme: dark)").matches;return document.documentElement.classList.contains("dark")||r==="dark"||r==="system"&&t?"dark":"light"}function yd(){return"light"}function wd({position:r="bottom-center"}){const t=o.useSyncExternalStore(vd,xd,yd);return e.jsx($a.Toaster,{position:r,theme:t,richColors:!0,closeButton:!0})}function kd({title:r,subtitle:t,actions:n,loading:a=!1,empty:s=!1,emptyText:l="Sin datos para mostrar",className:i="",children:c}){return e.jsxs("div",{className:`bonsaif-chart-card w-full overflow-visible ${i}`,children:[(r||t||n)&&e.jsxs("div",{className:"bonsaif-chart-card-head",children:[e.jsx("div",{className:"bonsaif-chart-card-accent","aria-hidden":!0}),e.jsxs("div",{className:"bonsaif-chart-card-copy min-w-0",children:[r?e.jsx("div",{className:"bonsaif-chart-card-title",children:r}):null,t?e.jsx("div",{className:"bonsaif-chart-card-subtitle",children:t}):null]}),n?e.jsx("div",{className:"bonsaif-chart-card-actions shrink-0",children:n}):null]}),e.jsx("div",{className:"bonsaif-chart-card-body",children:a?e.jsx("div",{className:"flex h-48 items-center justify-center",children:e.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?e.jsx("div",{className:"flex h-48 items-center justify-center text-sm",style:{color:"var(--text-muted)"},children:l}):c})]})}const nn=["var(--primary)","#38bdf8","#34d399","#a78bfa","#2dd4bf","#fbbf24","#60a5fa","#94a3b8"];function Ro(r,t){return r.color??nn[t%nn.length]}function sr(r="primary"){switch(r){case"success":return"#34d399";case"warning":return"#fbbf24";case"danger":return"#f87171";case"neutral":return"var(--text-muted)";default:return"var(--primary)"}}const tr=r=>{if(!Number.isFinite(r))return"—";const t=Math.abs(r);return t>=1e9?`${(r/1e9).toFixed(1).replace(/\.0$/,"")}B`:t>=1e6?`${(r/1e6).toFixed(1).replace(/\.0$/,"")}M`:t>=1e4?`${(r/1e3).toFixed(1).replace(/\.0$/,"")}k`:r.toLocaleString(void 0,{maximumFractionDigits:2})};function St(r){if(r==null||r==="")return null;const t=typeof r=="number"?r:Number(r);return Number.isFinite(t)?t:null}const ua={warning:70,danger:90};function an(r,t=ua){const n=t.warning??ua.warning,a=t.danger??ua.danger;return r>=a?"danger":r>=n?"warning":r<=0?"primary":"success"}function Ct(r,t){return sr(an(r,t))}function Zr(r,t=0){return Number.isFinite(r)?`${r.toFixed(t)}%`:"—"}function Qr(r,t=1){if(!Number.isFinite(r))return"—";const n=r<0?"-":"",a=Math.abs(r);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(t);return`${n}${c.replace(/\.0$/,"")} ${s[i]}`}function es(r,t="bytes",n=1){if(!Number.isFinite(r))return"—";const a=r<0?"-":"",s=Math.abs(r),l=t==="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 u=i>=100?i.toFixed(0):i.toFixed(n);return`${a}${u.replace(/\.0$/,"")} ${l[c]}`}function Jr(r,t){var n;for(let a=r.length-1;a>=0;a-=1){const s=St((n=r[a])==null?void 0:n[t]);if(s!==null)return s}return null}function nr({height:r}){return e.jsx("div",{className:"flex items-center justify-center",style:{height:r},"aria-busy":!0,children:e.jsx("div",{className:"h-7 w-7 animate-spin rounded-full border-2",style:{borderColor:"var(--border)",borderTopColor:"var(--primary)"}})})}function ar({height:r,text:t}){return e.jsx("div",{className:"flex items-center justify-center text-sm",style:{height:r,color:"var(--text-muted)"},children:t})}const $r=680,Ar="ease-out",Nd={top:18,right:8,bottom:12,left:0};function Et(r){return{...Nd,...r}}function Mt(r){return r.map((t,n)=>({...t,color:Ro(t,n),label:t.label??t.key}))}function on(r,t){return!r.length||!t.length||r.every(n=>t.every(a=>St(n[a.key])===null))}function Ze(){return{fill:"var(--text-muted)",fontSize:10,fontWeight:500,letterSpacing:"0.02em"}}function Lt(){return"color-mix(in srgb, var(--border) 55%, transparent)"}function rs(){return"color-mix(in srgb, var(--primary) 45%, var(--border))"}function sn(){return{paddingBottom:12,paddingLeft:4,fontSize:11,fontWeight:600,letterSpacing:"0.04em",textTransform:"uppercase",color:"var(--text-muted)"}}function Sd(r,t=tr){if(r==null||r==="")return"—";const n=typeof r=="number"?r:Number(r);return Number.isFinite(n)?t(n):String(r)}function ts(r){return`bonsaif-grad-${r.replace(/[^a-zA-Z0-9_-]/g,"")}`}function Cd({active:r,label:t,payload:n,valueFormat:a=tr}){var c,u,f,p,b,m;if(!r||!(n!=null&&n.length))return null;const s=n.filter(v=>v.dataKey!=="base"&&v.name!=="base"&&v.value!==null&&v.value!==void 0);if(!s.length)return null;const l=((u=(c=s[0])==null?void 0:c.payload)==null?void 0:u.fullName)??((p=(f=s[0])==null?void 0:f.payload)==null?void 0:p.tooltipLabel)??((m=(b=s[0])==null?void 0:b.payload)==null?void 0:m.display),i=typeof l=="string"&&l.length>0?l:t;return e.jsxs("div",{className:"bonsaif-chart-tooltip-panel",children:[i!=null&&i!==""?e.jsx("div",{className:"bonsaif-chart-tooltip-label",children:String(i)}):null,e.jsx("div",{className:"bonsaif-chart-tooltip-items",children:s.map((v,y)=>{const S=v.payload,h=S&&typeof S.display=="number"?S.display:v.value;return e.jsxs("div",{className:"bonsaif-chart-tooltip-row",children:[e.jsxs("span",{className:"bonsaif-chart-tooltip-name",children:[e.jsx("span",{className:"bonsaif-chart-tooltip-swatch",style:{background:v.color??"var(--primary)"}}),v.name??v.dataKey]}),e.jsx("span",{className:"bonsaif-chart-tooltip-value",children:Sd(h,a)})]},String(v.dataKey??v.name??y))})})]})}function Rr({valueFormat:r,content:t,cursor:n,offset:a=12,wrapperStyle:s,allowEscapeViewBox:l,reverseDirection:i,...c}){return e.jsx(ve.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:t??e.jsx(Cd,{valueFormat:r})})}function ns(r,t,n){return n==null?-1:r.findIndex(a=>String(a[t])===String(n))}function as(r,t,n){if(n<=1)return null;const a=Math.max(0,Math.min(r,t)),s=Math.min(n-1,Math.max(r,t));return s-a<1||a===0&&s>=n-1?null:{startIndex:a,endIndex:s}}function ln(r,t,n={}){const{zoomable:a=!1,zoomMode:s="both",brushHeight:l=28,onZoomChange:i}=n,[c,u]=o.useState(null),[f,p]=o.useState(null),b=!!a&&r.length>1,m=b&&(s==="brush"||s==="both"),v=b&&(s==="drag"||s==="both"),y=o.useCallback(J=>{u(J),i==null||i(J)},[i]),S=o.useCallback(()=>{p(null),y(null)},[y]),h=!!c,P=o.useMemo(()=>!c||m?r:r.slice(c.startIndex,c.endIndex+1),[r,m,c]),O=o.useCallback((J,C)=>{const re=ns(r,t,J),W=ns(r,t,C);re<0||W<0||y(as(re,W,r.length))},[y,r,t]),E=o.useCallback(J=>{v&&((J==null?void 0:J.activeLabel)===void 0||(J==null?void 0:J.activeLabel)===null||p({leftLabel:J.activeLabel,rightLabel:J.activeLabel}))},[v]),L=o.useCallback(J=>{!v||!f||(J==null?void 0:J.activeLabel)===void 0||(J==null?void 0:J.activeLabel)===null||p(C=>C&&{...C,rightLabel:J.activeLabel})},[f,v]),N=o.useCallback(()=>{if(v){if(!f||f.rightLabel===null||f.rightLabel===void 0){p(null);return}O(f.leftLabel,f.rightLabel),p(null)}},[O,f,v]),k=o.useCallback(J=>{if(m){if(!J){y(null);return}y(as(J.startIndex??0,J.endIndex??r.length-1,r.length))}},[y,r.length,m]),Y=v?{onMouseDown:E,onMouseMove:L,onMouseUp:N,onMouseLeave:()=>{f&&N()}}:{},F=c??{startIndex:0,endIndex:Math.max(0,r.length-1)},U=e.jsxs(e.Fragment,{children:[v&&f&&f.rightLabel!==null&&f.rightLabel!==void 0?e.jsx(ve.ReferenceArea,{x1:f.leftLabel,x2:f.rightLabel,strokeOpacity:.18,fill:"var(--primary)",fillOpacity:.12,stroke:"var(--primary)"}):null,m?e.jsx(ve.Brush,{dataKey:t,height:l,stroke:"var(--primary)",fill:"color-mix(in srgb, var(--primary) 10%, var(--bg-card))",travellerWidth:8,startIndex:F.startIndex,endIndex:F.endIndex,onChange:k,tickFormatter:J=>String(J)}):null]}),V=m?{bottom:Math.max(l+10,36)}:void 0;return{enabled:b,showBrush:m,showDrag:v,viewData:P,isZoomed:h,resetZoom:S,chartHandlers:Y,zoomNodes:U,marginExtra:V}}function cn({visible:r,onReset:t}){return r?e.jsx("button",{type:"button",className:"bonsaif-chart-zoom-reset",onClick:t,"aria-label":"Restablecer zoom",children:"Restablecer zoom"}):null}function Ed({data:r,xKey:t,series:n,height:a=280,className:s="",loading:l=!1,emptyText:i="Sin datos para mostrar",showGrid:c=!0,showLegend:u=!0,showTooltip:f=!0,margin:p,valueFormat:b=tr,yDomain:m,ariaLabel:v="Gráfico de líneas",curve:y=!0,strokeWidth:S=2.25,zoomable:h=!1,zoomMode:P="both",brushHeight:O,onZoomChange:E}){const L=on(r,n),N=Mt(n),k=ln(r,t,{zoomable:h,zoomMode:P,brushHeight:O,onZoomChange:E}),Y=Et({...p,...k.marginExtra});return l?e.jsx(nr,{height:a}):L?e.jsx(ar,{height:a,text:i}):e.jsxs("div",{className:`bonsaif-chart bonsaif-line-chart w-full ${s}`,role:"img","aria-label":v,style:{height:a},children:[e.jsx(cn,{visible:k.isZoomed,onReset:k.resetZoom}),e.jsx(ve.ResponsiveContainer,{width:"100%",height:"100%",children:e.jsxs(ve.LineChart,{data:k.viewData,margin:Y,...k.chartHandlers,children:[c?e.jsx(ve.CartesianGrid,{strokeDasharray:"2 8",stroke:Lt(),vertical:!1}):null,e.jsx(ve.XAxis,{dataKey:t,tick:Ze(),tickLine:!1,axisLine:!1,padding:{left:0,right:0},interval:"preserveStartEnd",minTickGap:52,dy:6}),e.jsx(ve.YAxis,{tick:Ze(),tickLine:!1,axisLine:!1,width:44,domain:m??["auto","auto"],tickFormatter:F=>b(Number(F)),dx:-2}),f?e.jsx(Rr,{valueFormat:b,cursor:{stroke:rs(),strokeWidth:1.25,strokeDasharray:"4 4"}}):null,u?e.jsx(ve.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:sn()}):null,N.map((F,U)=>e.jsx(ve.Line,{type:y?"monotone":"linear",dataKey:F.key,name:F.label,stroke:F.color,strokeWidth:U===0?S+.35:S,strokeOpacity:U===0?1:.88,isAnimationActive:!0,animationDuration:$r,animationEasing:Ar,dot:!1,activeDot:{r:5,strokeWidth:2,stroke:"var(--bg-card)",fill:F.color}},F.key)),k.zoomNodes]})})]})}function dn({data:r,xKey:t,series:n,height:a=280,className:s="",loading:l=!1,emptyText:i="Sin datos para mostrar",showGrid:c=!0,showLegend:u=!0,showTooltip:f=!0,margin:p,valueFormat:b=tr,yDomain:m,ariaLabel:v="Gráfico de área",stacked:y=!1,opacity:S=.22,zoomable:h=!1,zoomMode:P="both",brushHeight:O,onZoomChange:E}){const L=on(r,n),N=Mt(n),k=ln(r,t,{zoomable:h,zoomMode:P,brushHeight:O,onZoomChange:E}),Y=Et({...p,...k.marginExtra});return l?e.jsx(nr,{height:a}):L?e.jsx(ar,{height:a,text:i}):e.jsxs("div",{className:`bonsaif-chart bonsaif-area-chart w-full ${s}`,role:"img","aria-label":v,style:{height:a},children:[e.jsx(cn,{visible:k.isZoomed,onReset:k.resetZoom}),e.jsx(ve.ResponsiveContainer,{width:"100%",height:"100%",children:e.jsxs(ve.AreaChart,{data:k.viewData,margin:Y,...k.chartHandlers,children:[e.jsx("defs",{children:N.map(F=>e.jsxs("linearGradient",{id:ts(F.key),x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:F.color,stopOpacity:Math.min(.55,S+.28)}),e.jsx("stop",{offset:"48%",stopColor:F.color,stopOpacity:S*.5}),e.jsx("stop",{offset:"100%",stopColor:F.color,stopOpacity:0})]},F.key))}),c?e.jsx(ve.CartesianGrid,{strokeDasharray:"2 8",stroke:Lt(),vertical:!1}):null,e.jsx(ve.XAxis,{dataKey:t,tick:Ze(),tickLine:!1,axisLine:!1,padding:{left:0,right:0},interval:"preserveStartEnd",minTickGap:52,dy:6}),e.jsx(ve.YAxis,{tick:Ze(),tickLine:!1,axisLine:!1,width:44,domain:m??["auto","auto"],tickFormatter:F=>b(Number(F)),dx:-2}),f?e.jsx(Rr,{valueFormat:b,cursor:{stroke:rs(),strokeWidth:1.25,strokeDasharray:"4 4"}}):null,u?e.jsx(ve.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:sn()}):null,N.map(F=>e.jsx(ve.Area,{type:"monotone",dataKey:F.key,name:F.label,stroke:F.color,fill:`url(#${ts(F.key)})`,strokeWidth:2.25,stackId:y?"stack":void 0,isAnimationActive:!0,animationDuration:$r,animationEasing:Ar,dot:!1,activeDot:{r:5,strokeWidth:2,stroke:"var(--bg-card)",fill:F.color}},F.key)),k.zoomNodes]})})]})}function Md({data:r,xKey:t,series:n,height:a=280,className:s="",loading:l=!1,emptyText:i="Sin datos para mostrar",showGrid:c=!0,showLegend:u=!0,showTooltip:f=!0,margin:p,valueFormat:b=tr,yDomain:m,ariaLabel:v="Gráfico de barras",layout:y="vertical",mode:S="grouped",barRadius:h=6,categoryAxisWidth:P=64,zoomable:O=!1,zoomMode:E="both",brushHeight:L,onZoomChange:N}){const k=on(r,n),Y=Mt(n),F=y==="horizontal",U=ln(r,t,{zoomable:O&&!F,zoomMode:E,brushHeight:L,onZoomChange:N}),V=Et({...p,...U.marginExtra});return l?e.jsx(nr,{height:a}):k?e.jsx(ar,{height:a,text:i}):e.jsxs("div",{className:`bonsaif-chart bonsaif-bar-chart w-full ${s}`,role:"img","aria-label":v,style:{height:a},children:[e.jsx(cn,{visible:U.isZoomed,onReset:U.resetZoom}),e.jsx(ve.ResponsiveContainer,{width:"100%",height:"100%",children:e.jsxs(ve.BarChart,{data:U.viewData,margin:V,layout:F?"vertical":"horizontal",barCategoryGap:"34%",barGap:3,...U.chartHandlers,children:[c?e.jsx(ve.CartesianGrid,{strokeDasharray:"2 8",stroke:Lt(),horizontal:!F,vertical:F}):null,F?e.jsxs(e.Fragment,{children:[e.jsx(ve.XAxis,{type:"number",tick:Ze(),tickLine:!1,axisLine:!1,tickFormatter:J=>b(Number(J)),domain:m??["auto","auto"]}),e.jsx(ve.YAxis,{type:"category",dataKey:t,tick:Ze(),tickLine:!1,axisLine:!1,width:P})]}):e.jsxs(e.Fragment,{children:[e.jsx(ve.XAxis,{dataKey:t,tick:Ze(),tickLine:!1,axisLine:!1,interval:"preserveStartEnd",minTickGap:36,dy:6}),e.jsx(ve.YAxis,{tick:Ze(),tickLine:!1,axisLine:!1,width:44,domain:m??["auto","auto"],tickFormatter:J=>b(Number(J)),dx:-2})]}),f?e.jsx(Rr,{valueFormat:b,cursor:{fill:"color-mix(in srgb, var(--primary) 8%, transparent)"}}):null,u?e.jsx(ve.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:sn()}):null,Y.map((J,C)=>e.jsx(ve.Bar,{dataKey:J.key,name:J.label,fill:J.color,fillOpacity:C===0?1:.82,radius:F?[0,h,h,0]:[h,h,2,2],maxBarSize:20,stackId:S==="stacked"?"stack":void 0,isAnimationActive:!0,animationDuration:$r,animationEasing:Ar},J.key)),U.zoomNodes]})})]})}function Ld(r){return e.jsx(ss,{...r,variant:"pie"})}function Td(r){return e.jsx(ss,{...r,variant:"donut",innerRadius:r.innerRadius??.62,cornerRadius:r.cornerRadius??10,padAngle:r.padAngle??2})}function os(r,t){return r==null||!Number.isFinite(r)?t:r>0&&r<=1?r*100:r}function ss({data:r,nameKey:t,valueKey:n,height:a=280,className:s="",loading:l=!1,emptyText:i="Sin datos para mostrar",showLegend:c=!0,showTooltip:u=!0,valueFormat:f=tr,ariaLabel:p,innerRadius:b,outerRadius:m,colors:v=[...nn],padAngle:y,cornerRadius:S,variant:h}){const P=r.map((C,re)=>({name:String(C[t]??""),value:St(C[n])??0,fill:v[re%v.length],row:C})).filter(C=>C.value>0),O=!P.length,E=h==="donut",L=P.length,N=os(b,E?62:12),k=os(m,78),Y=Math.min(y??(E?2:3),Math.max(.5,10/Math.max(1,L))),F=Math.min(S??(E?10:8),Math.max(2,36/Math.max(1,L)));if(l)return e.jsx(nr,{height:a});if(O)return e.jsx(ar,{height:a,text:i});const U=P.reduce((C,re)=>C+re.value,0),V=c?Math.min(96,28+Math.ceil(L/3)*22):0,J=Math.max(140,a-V);return e.jsx("div",{className:`bonsaif-chart bonsaif-${h}-chart w-full ${s}`,role:"img","aria-label":p??(h==="donut"?"Donut chart":"Pie chart"),style:{height:a},children:e.jsxs("div",{className:"bonsaif-pie-layout",children:[e.jsx("div",{className:"bonsaif-pie-plot",style:{height:J},children:e.jsx(ve.ResponsiveContainer,{width:"100%",height:"100%",children:e.jsxs(ve.PieChart,{margin:{top:4,right:4,bottom:4,left:4},children:[u?e.jsx(Rr,{valueFormat:f,isAnimationActive:!1}):null,e.jsx(ve.Pie,{data:P,dataKey:"value",nameKey:"name",cx:"50%",cy:"50%",innerRadius:`${N}%`,outerRadius:`${k}%`,startAngle:90,endAngle:-270,paddingAngle:Y,cornerRadius:F,minAngle:L>6?3:2,stroke:"var(--bg-card)",strokeWidth:2,isAnimationActive:!0,animationDuration:$r,animationEasing:Ar,label:!1,activeShape:$d,children:P.map(C=>e.jsx(ve.Cell,{fill:C.fill},C.name))}),E?e.jsx("text",{x:"50%",y:"50%",textAnchor:"middle",dominantBaseline:"middle",fill:"var(--text-main)",fontSize:18,fontWeight:700,letterSpacing:"-0.02em",children:f(U)}):null]})})}),c?e.jsx("ul",{className:"bonsaif-pie-legend","aria-label":"Leyenda",children:P.map(C=>e.jsxs("li",{className:"bonsaif-pie-legend-item",children:[e.jsx("span",{className:"bonsaif-pie-legend-swatch",style:{background:C.fill},"aria-hidden":!0}),e.jsx("span",{className:"bonsaif-pie-legend-label",title:C.name,children:C.name}),e.jsx("span",{className:"bonsaif-pie-legend-value",children:f(C.value)})]},C.name))}):null]})})}function $d(r){const{outerRadius:t=0,...n}=r;return e.jsx(ve.Sector,{...n,outerRadius:Number(t)+4,stroke:"var(--bg-card)",strokeWidth:2})}function Ad({data:r,dataKey:t,width:n="100%",height:a=36,tone:s="primary",color:l,fill:i=!0,className:c="",ariaLabel:u="Sparkline"}){const f=l??sr(s),p=r.map(k=>St(k[t])).filter(k=>k!==null);if(p.length<2)return e.jsx("div",{className:c,style:{width:n,height:a,color:"var(--text-muted)"},"aria-label":u});const b=120,m=36,v=3,y=1,S=Math.min(...p),P=Math.max(...p)-S||1,O=p.map((k,Y)=>{const F=y+Y/(p.length-1)*(b-y*2),U=m-v-(k-S)/P*(m-v*2);return{x:F,y:U}}),E=O.map((k,Y)=>`${Y===0?"M":"L"}${k.x.toFixed(2)} ${k.y.toFixed(2)}`).join(" "),L=`${E} L${O[O.length-1].x.toFixed(2)} ${m} L${O[0].x.toFixed(2)} ${m} Z`,N=`bonsaif-spark-${t.replace(/[^a-zA-Z0-9_-]/g,"")}-${s}`;return e.jsx("div",{className:`bonsaif-sparkline ${c}`,style:{width:n,height:a},role:"img","aria-label":u,children:e.jsxs("svg",{width:"100%",height:"100%",viewBox:`0 0 ${b} ${m}`,preserveAspectRatio:"none",focusable:"false",children:[i?e.jsx("defs",{children:e.jsxs("linearGradient",{id:N,x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:f,stopOpacity:.38}),e.jsx("stop",{offset:"100%",stopColor:f,stopOpacity:0})]})}):null,i?e.jsx("path",{d:L,fill:`url(#${N})`}):null,e.jsx("path",{d:E,fill:"none",stroke:f,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",vectorEffect:"non-scaling-stroke"})]})})}function Dd({data:r,xKey:t,series:n,barSeries:a,lineSeries:s,height:l=280,className:i="",loading:c=!1,emptyText:u="Sin datos para mostrar",showGrid:f=!0,showLegend:p=!0,showTooltip:b=!0,margin:m,valueFormat:v=tr,yDomain:y,ariaLabel:S="Gráfico combinado",barRadius:h=6,zoomable:P=!1,zoomMode:O="both",brushHeight:E,onZoomChange:L}){const N=a??n.slice(0,Math.max(1,n.length-1)),k=s??(n.length>1?n.slice(-1):n.length?[n[0]]:[]),Y=[...N,...k.filter(W=>!N.some(j=>j.key===W.key))],F=on(r,Y),U=Mt(N),V=Mt(Y),J=k.map(W=>{var ae;const j=V.find(Z=>Z.key===W.key);return{...W,label:W.label??W.key,color:W.color??(j==null?void 0:j.color)??((ae=V[0])==null?void 0:ae.color)}}),C=ln(r,t,{zoomable:P,zoomMode:O,brushHeight:E,onZoomChange:L}),re=Et({...m,...C.marginExtra});return c?e.jsx(nr,{height:l}):F?e.jsx(ar,{height:l,text:u}):e.jsxs("div",{className:`bonsaif-chart bonsaif-combo-chart w-full ${i}`,role:"img","aria-label":S,style:{height:l},children:[e.jsx(cn,{visible:C.isZoomed,onReset:C.resetZoom}),e.jsx(ve.ResponsiveContainer,{width:"100%",height:"100%",children:e.jsxs(ve.ComposedChart,{data:C.viewData,margin:re,barCategoryGap:"34%",...C.chartHandlers,children:[f?e.jsx(ve.CartesianGrid,{strokeDasharray:"2 8",stroke:Lt(),vertical:!1}):null,e.jsx(ve.XAxis,{dataKey:t,tick:Ze(),tickLine:!1,axisLine:!1,interval:"preserveStartEnd",minTickGap:36,dy:6}),e.jsx(ve.YAxis,{tick:Ze(),tickLine:!1,axisLine:!1,width:44,domain:y??["auto","auto"],tickFormatter:W=>v(Number(W)),dx:-2}),b?e.jsx(Rr,{valueFormat:v,cursor:{fill:"color-mix(in srgb, var(--primary) 8%, transparent)"}}):null,p?e.jsx(ve.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:sn()}):null,U.map(W=>e.jsx(ve.Bar,{dataKey:W.key,name:W.label,fill:W.color,fillOpacity:.88,radius:[h,h,2,2],maxBarSize:18,isAnimationActive:!0,animationDuration:$r,animationEasing:Ar},W.key)),J.map(W=>e.jsx(ve.Line,{type:"monotone",dataKey:W.key,name:W.label,stroke:W.color,strokeWidth:2.5,isAnimationActive:!0,animationDuration:$r,animationEasing:Ar,dot:!1,activeDot:{r:5,strokeWidth:2,stroke:"var(--bg-card)",fill:W.color}},W.key)),C.zoomNodes]})})]})}function Id({data:r,xKey:t,valueKey:n,typeKey:a,height:s=280,className:l="",loading:i=!1,emptyText:c="Sin datos para mostrar",showGrid:u=!0,showTooltip:f=!0,margin:p,valueFormat:b=tr,ariaLabel:m="Gráfico waterfall",increaseColor:v="#34d399",decreaseColor:y="#f87171",totalColor:S="var(--primary)"}){const h=o.useMemo(()=>Bd(r,{xKey:t,valueKey:n,typeKey:a,increaseColor:v,decreaseColor:y,totalColor:S}),[r,t,n,a,v,y,S]),P=!h.length,O=Et(p);return i?e.jsx(nr,{height:s}):P?e.jsx(ar,{height:s,text:c}):e.jsx("div",{className:`bonsaif-chart bonsaif-waterfall-chart w-full ${l}`,role:"img","aria-label":m,style:{height:s},children:e.jsx(ve.ResponsiveContainer,{width:"100%",height:"100%",children:e.jsxs(ve.BarChart,{data:h,margin:O,barCategoryGap:"42%",children:[u?e.jsx(ve.CartesianGrid,{strokeDasharray:"2 8",stroke:Lt(),vertical:!1}):null,e.jsx(ve.XAxis,{dataKey:"label",tick:Ze(),tickLine:!1,axisLine:!1,interval:0,dy:6}),e.jsx(ve.YAxis,{tick:Ze(),tickLine:!1,axisLine:!1,width:44,tickFormatter:E=>b(Number(E)),dx:-2}),f?e.jsx(Rr,{valueFormat:b,cursor:{fill:"color-mix(in srgb, var(--primary) 8%, transparent)"}}):null,e.jsx(ve.Bar,{dataKey:"base",stackId:"wf",fill:"transparent",isAnimationActive:!1,legendType:"none",maxBarSize:22}),e.jsx(ve.Bar,{dataKey:"delta",name:"Valor",stackId:"wf",radius:[6,6,2,2],maxBarSize:22,isAnimationActive:!0,animationDuration:$r,animationEasing:Ar,children:h.map(E=>e.jsx(ve.Cell,{fill:E.color},E.label))})]})})})}function Bd(r,t){let n=0;return r.map((a,s)=>{const l=St(a[t.valueKey])??0,i=t.typeKey?String(a[t.typeKey]??""):"",c=i==="total"||s===r.length-1&&i!=="increase"&&i!=="decrease";let u="increase",f=0,p=0,b=l;return c&&i==="total"?(u="total",f=0,p=Math.abs(l),b=l,n=l):c&&s===r.length-1&&!i?(u="total",f=0,p=Math.abs(n),b=n):(u=i==="decrease"||l<0?"decrease":"increase",u==="decrease"?(f=n+l,p=Math.abs(l),n=n+l):(f=n,p=Math.abs(l),n=n+l),b=l),{label:String(a[t.xKey]??""),base:f,delta:p,display:b,kind:u,color:u==="total"?t.totalColor:u==="decrease"?t.decreaseColor:t.increaseColor}})}const et=135*Math.PI/180,fa=270*Math.PI/180;function Od({value:r,min:t=0,max:n=100,height:a=180,className:s="",loading:l=!1,empty:i=!1,emptyText:c="Sin datos para mostrar",label:u,valueFormat:f=tr,tone:p="primary",color:b,thresholds:m,ariaLabel:v="Gauge",animationDuration:y=700,thickness:S=9,showScale:h=!1}){const P=o.useId().replace(/:/g,""),O=n-t||1,E=Math.min(1,Math.max(0,(r-t)/O)),[L,N]=o.useState(y>0?0:E);if(o.useEffect(()=>{if(l||i)return;if(y<=0){N(E);return}if(typeof window<"u"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches){N(E);return}let Z=0,$=0;N(M=>($=M,M));const ee=performance.now(),se=M=>{const H=Math.min(1,(M-ee)/y),oe=1-(1-H)**3;N($+(E-$)*oe),H<1&&(Z=requestAnimationFrame(se))};return Z=requestAnimationFrame(se),()=>cancelAnimationFrame(Z)},[E,y,l,i]),l)return e.jsx(nr,{height:a});if(i)return e.jsx(ar,{height:a,text:c});const k=100,Y=108,F=72,U=b??Hd(r,n,p,m),V=t+L*O,J=ls(k,Y,F,et,et+fa),C=et+Math.max(.001,L)*fa,re=ls(k,Y,F,et,C),W=un(k,Y,F,et),j=un(k,Y,F,et+fa);return e.jsx("div",{className:`bonsaif-chart bonsaif-gauge-chart flex flex-col items-center justify-center ${s}`,style:{height:a},children:e.jsxs("svg",{viewBox:"0 0 200 168",width:"100%",height:"100%",role:"img","aria-label":v,className:"overflow-visible",children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:`bonsaif-gauge-${P}`,x1:"0",y1:"0",x2:"1",y2:"0",children:[e.jsx("stop",{offset:"0%",stopColor:U,stopOpacity:.82}),e.jsx("stop",{offset:"100%",stopColor:U,stopOpacity:1})]})}),e.jsx("path",{d:J,fill:"none",stroke:"color-mix(in srgb, var(--border) 70%, transparent)",strokeWidth:S,strokeLinecap:"butt"}),e.jsx("path",{d:re,fill:"none",stroke:`url(#bonsaif-gauge-${P})`,strokeWidth:S,strokeLinecap:"butt",className:"bonsaif-chart-gauge-value"}),e.jsx("text",{x:k,y:Y-(u?4:0),textAnchor:"middle",dominantBaseline:"middle",fill:"var(--text-main)",fontSize:28,fontWeight:700,letterSpacing:"-0.04em",className:"bonsaif-chart-gauge-label",children:f(V)}),u?e.jsx("text",{x:k,y:Y+18,textAnchor:"middle",fill:"var(--text-muted)",fontSize:11,fontWeight:600,letterSpacing:"0.06em",children:u}):null,h?e.jsxs(e.Fragment,{children:[e.jsx("text",{x:W.x-2,y:W.y+S+14,textAnchor:"middle",fill:"var(--text-muted)",fontSize:10,children:f(t)}),e.jsx("text",{x:j.x+2,y:j.y+S+14,textAnchor:"middle",fill:"var(--text-muted)",fontSize:10,children:f(n)})]}):null]})})}function Hd(r,t,n,a){if(a!=null&&a.length){const l=[...a].sort((c,u)=>c.value-u.value);let i=l[0].color;for(const c of l)r>=c.value&&(i=c.color);return i}if(n)return sr(n);const s=r/(t||1);return s>=.8?sr("success"):s>=.5?sr("warning"):sr("danger")}function un(r,t,n,a){return{x:r+n*Math.cos(a),y:t+n*Math.sin(a)}}function ls(r,t,n,a,s){const l=un(r,t,n,a),i=un(r,t,n,s),c=s-a,u=Math.abs(c)>Math.PI?1:0;return`M ${l.x} ${l.y} A ${n} ${n} 0 ${u} 1 ${i.x} ${i.y}`}function Pd({value:r,target:t,max:n,ranges:a,height:s=72,className:l="",loading:i=!1,empty:c=!1,emptyText:u="Sin datos para mostrar",label:f,subtitle:p,valueFormat:b=tr,tone:m="primary",showScale:v=!0,showStatus:y=!0,ariaLabel:S="Bullet chart"}){if(i)return e.jsx(nr,{height:s});if(c)return e.jsx(ar,{height:s,text:u});const h=n??Math.max(r,t,...(a==null?void 0:a.map(U=>U.value))??[],1)*1.05,O=[...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((U,V)=>U.value-V.value),E=sr(m),L=Math.min(100,Math.max(0,r/h*100)),N=Math.min(100,Math.max(0,t/h*100)),k=r>=t,Y=[0,.25,.5,.75,1].map(U=>U*h),F=e.jsxs("div",{className:"bonsaif-bullet-plot min-w-0 flex-1",children:[e.jsxs("div",{className:"bonsaif-bullet-track relative w-full",style:{height:Math.max(22,f?28:s*.42)},role:"img","aria-label":S,children:[e.jsx("div",{className:"bonsaif-bullet-ranges absolute inset-0 flex overflow-hidden",children:O.map((U,V)=>{const J=V===0?0:O[V-1].value,C=Math.max(0,(U.value-J)/h*100);return e.jsx("div",{style:{width:`${C}%`,background:U.color??`color-mix(in srgb, var(--border) ${70-V*18}%, transparent)`}},V)})}),e.jsx("div",{className:"absolute left-0 top-1/2 w-full",style:{height:"34%",transform:"translateY(-50%)"},children:e.jsx("div",{className:"bonsaif-bullet-value h-full",style:{width:`${L}%`,background:E,borderRadius:"0 999px 999px 0",boxShadow:`0 0 12px color-mix(in srgb, ${E} 35%, transparent)`}})}),e.jsx("div",{className:"bonsaif-bullet-target absolute top-1/2 z-[1]",style:{left:`${N}%`,height:"72%",width:3,transform:"translate(-50%, -50%)",background:E,borderRadius:1,boxShadow:"0 0 0 1px color-mix(in srgb, var(--bg-card) 70%, transparent)"},title:`Meta ${b(t)}`})]}),v?e.jsx("div",{className:"bonsaif-bullet-scale relative mt-1.5 h-4 w-full",children:Y.map((U,V)=>{const J=U/h*100,C=V===0,re=V===Y.length-1;return e.jsxs("div",{className:"absolute top-0",style:{left:`${J}%`,transform:C?"none":re?"translateX(-100%)":"translateX(-50%)"},children:[e.jsx("div",{className:"mx-auto h-1.5 w-px",style:{background:"color-mix(in srgb, var(--text-muted) 55%, transparent)",marginLeft:C?0:re?"auto":void 0,marginRight:re?0:void 0}}),e.jsx("div",{className:"bonsaif-bullet-scale-label mt-0.5 tabular-nums",style:{color:"var(--text-muted)",textAlign:C?"left":re?"right":"center"},children:b(U)})]},U)})}):null]});return e.jsx("div",{className:`bonsaif-chart bonsaif-bullet-chart w-full ${l}`,children:f?e.jsxs("div",{className:"bonsaif-bullet-row flex flex-col gap-2 sm:flex-row sm:items-start sm:gap-4",children:[e.jsxs("div",{className:"bonsaif-bullet-label shrink-0 sm:w-[7.5rem] sm:pt-1 sm:text-right",children:[e.jsx("div",{className:"text-sm font-semibold tracking-tight",style:{color:"var(--text-main)"},children:f}),p?e.jsx("div",{className:"mt-0.5 text-[11px] leading-snug",style:{color:"var(--text-muted)"},children:p}):e.jsxs("div",{className:"mt-0.5 text-[11px] tabular-nums leading-snug",style:{color:"var(--text-muted)"},children:[e.jsx("span",{style:{color:E,fontWeight:600},children:b(r)}),e.jsxs("span",{children:[" / meta ",b(t)]})]}),y?e.jsx("div",{className:"bonsaif-bullet-status mt-1.5 inline-flex text-[10px] font-bold uppercase tracking-wide",style:{color:sr(k?"success":"warning")},children:k?"En meta":"Bajo meta"}):null]}),F]}):F})}function Fd({data:r,value:t,timeKey:n="t",usageKey:a="usage",series:s,cores:l,height:i=220,className:c="",loading:u=!1,emptyText:f="Sin datos de CPU",showLegend:p=!1,showTooltip:b=!0,thresholds:m,label:v="CPU",ariaLabel:y="Uso de CPU"}){var N;const S=s??[{key:a,label:"Uso",color:Ct(t??Jr(r,a)??0,m)}],h=t??Jr(r,a)??Jr(r,((N=S[0])==null?void 0:N.key)??a),P=!u&&(!r.length||h===null);if(u)return e.jsx(nr,{height:i});if(P)return e.jsx(ar,{height:i,text:f});const O=Math.min(100,Math.max(0,h??0)),E=an(O,m),L=Ct(O,m);return e.jsxs("div",{className:`bonsaif-chart bonsaif-cpu-chart w-full ${c}`,role:"group","aria-label":y,children:[e.jsxs("div",{className:"bonsaif-metric-head",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"bonsaif-metric-kicker",children:[v,l!=null?e.jsxs("span",{className:"ml-1.5 normal-case tracking-normal opacity-80",children:["· ",l," ",l===1?"core":"cores"]}):null]}),e.jsx("div",{className:"bonsaif-metric-value",style:{color:L},children:Zr(O,O<10?1:0)})]}),e.jsx("div",{className:"bonsaif-metric-badge",style:{color:L,background:`color-mix(in srgb, ${L} 14%, transparent)`},children:E==="danger"?"Crítico":E==="warning"?"Alto":"Normal"})]}),e.jsx(dn,{data:r,xKey:n,series:S.map(k=>({...k,color:k.color??L})),height:Math.max(120,i-56),yDomain:[0,100],showLegend:p,showTooltip:b,valueFormat:k=>Zr(k,0),ariaLabel:y,opacity:.22,margin:{top:8,right:8,bottom:4,left:0}})]})}function zd({used:r,total:t,cached:n,data:a=[],timeKey:s="t",usageKey:l="usage",height:i=220,className:c="",loading:u=!1,emptyText:f="Sin datos de memoria",showHistory:p=!0,showTooltip:b=!0,thresholds:m,label:v="RAM",ariaLabel:y="Uso de memoria"}){const S=t>0?t:1,h=Math.min(100,Math.max(0,r/S*100)),P=!u&&!(Number.isFinite(r)&&Number.isFinite(t)&&t>0);if(u)return e.jsx(nr,{height:i});if(P)return e.jsx(ar,{height:i,text:f});const O=an(h,m),E=Ct(h,m),L=Math.max(0,t-r),N=a.length>0?Jr(a,l)??h:h,k=Ct(N,m),Y=p&&a.length>1?Math.max(100,i-110):0;return e.jsxs("div",{className:`bonsaif-chart bonsaif-ram-chart w-full ${c}`,role:"group","aria-label":y,children:[e.jsxs("div",{className:"bonsaif-metric-head",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"bonsaif-metric-kicker",children:v}),e.jsxs("div",{className:"flex items-baseline gap-2",children:[e.jsx("span",{className:"bonsaif-metric-value",style:{color:E},children:Zr(h,h<10?1:0)}),e.jsxs("span",{className:"text-sm tabular-nums",style:{color:"var(--text-secondary)"},children:[Qr(r)," / ",Qr(t)]})]})]}),e.jsx("div",{className:"bonsaif-metric-badge",style:{color:E,background:`color-mix(in srgb, ${E} 14%, transparent)`},children:O==="danger"?"Crítico":O==="warning"?"Alto":"Normal"})]}),e.jsxs("div",{className:"mb-2",children:[e.jsx("div",{className:"h-2 w-full overflow-hidden rounded-sm",style:{background:"color-mix(in srgb, var(--border) 55%, transparent)"},role:"progressbar","aria-valuenow":Math.round(h),"aria-valuemin":0,"aria-valuemax":100,"aria-label":`${v} ${Zr(h,0)}`,children:e.jsx("div",{className:"h-full rounded-sm transition-[width] duration-300",style:{width:`${h}%`,background:`linear-gradient(90deg, ${E}, color-mix(in srgb, ${E} 55%, #38bdf8))`}})}),e.jsxs("div",{className:"mt-2 flex flex-wrap gap-x-4 gap-y-1 text-[11px] tabular-nums",style:{color:"var(--text-muted)"},children:[e.jsxs("span",{children:[e.jsx("span",{className:"font-medium",style:{color:"var(--text-main)"},children:"Usada"})," ",Qr(r)]}),n!=null&&Number.isFinite(n)?e.jsxs("span",{children:[e.jsx("span",{className:"font-medium",style:{color:"var(--text-main)"},children:"Caché"})," ",Qr(n)]}):null,e.jsxs("span",{children:[e.jsx("span",{className:"font-medium",style:{color:"var(--text-main)"},children:"Libre"})," ",Qr(L)]})]})]}),p&&a.length>1?e.jsx(dn,{data:a,xKey:s,series:[{key:l,label:"Uso",color:k}],height:Y,yDomain:[0,100],showLegend:!1,showTooltip:b,valueFormat:F=>Zr(F,0),ariaLabel:`${y} — historial`,opacity:.22,margin:{top:8,right:8,bottom:4,left:0}}):null]})}const _d="color-mix(in srgb, var(--primary) 25%, #38bdf8)",jd="color-mix(in srgb, var(--primary) 20%, #2dd4bf)";function Wd({data:r,timeKey:t="t",inboundKey:n="in",outboundKey:a="out",inbound:s,outbound:l,unit:i="bytes",inboundLabel:c="Entrada",outboundLabel:u="Salida",inboundColor:f=_d,outboundColor:p=jd,height:b=240,className:m="",loading:v=!1,emptyText:y="Sin datos de red",showLegend:S=!1,showTooltip:h=!0,label:P="Network",ariaLabel:O="Tráfico de red"}){const E=s??Jr(r,n)??0,L=l??Jr(r,a)??0,N=!v&&r.length===0;if(v)return e.jsx(nr,{height:b});if(N)return e.jsx(ar,{height:b,text:y});const k=U=>es(U,i),F=Math.max(140,b-76);return e.jsxs("div",{className:`bonsaif-chart bonsaif-network-chart w-full ${m}`,role:"group","aria-label":O,children:[e.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:e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"bonsaif-metric-kicker",children:P}),e.jsxs("div",{className:"mt-2 grid grid-cols-2 gap-5 sm:max-w-lg",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-[11px]",style:{color:"var(--text-muted)"},children:[e.jsx("span",{className:"h-3 w-1.5 shrink-0 rounded-sm",style:{background:f},"aria-hidden":!0}),c]}),e.jsx("div",{className:"mt-1 truncate text-xl font-bold tabular-nums leading-tight tracking-tight",style:{color:f},title:k(E),children:k(E)})]}),e.jsxs("div",{className:"min-w-0 pl-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-[11px]",style:{color:"var(--text-muted)"},children:[e.jsx("span",{className:"h-3 w-1.5 shrink-0 rounded-sm",style:{background:p},"aria-hidden":!0}),u]}),e.jsx("div",{className:"mt-1 truncate text-lg font-semibold tabular-nums leading-tight tracking-tight opacity-95",style:{color:p},title:k(L),children:k(L)})]})]})]})}),e.jsx("div",{className:"bonsaif-network-plot relative z-0",children:e.jsx(dn,{data:r,xKey:t,series:[{key:n,label:c,color:f},{key:a,label:u,color:p}],height:F,showLegend:S,showTooltip:h,valueFormat:k,ariaLabel:O,opacity:.18,margin:{top:8,right:8,bottom:4,left:4}})})]})}const is=["primeSuiteOrigin","primeAuthOrigin","primeSuiteAppUrl"],cs=["primeSuiteOrigin","primeSuiteProjectKey"];function qd(){if(typeof window>"u")return"*";try{if(window.parent===window)return"*";const r=new URLSearchParams(window.location.search);for(const t of is){const n=r.get(t);if(n){const a=fn(n);if(a)return a}}if(typeof sessionStorage<"u")for(const t of cs){const n=sessionStorage.getItem(t);if(n)try{const a=new URL(n);if(a.origin&&a.origin!==window.location.origin)return a.origin}catch{const a=fn(n);if(a)return a}}if(document.referrer){const t=fn(document.referrer);if(t&&t!==window.location.origin)return t}return"*"}catch{return"*"}}function Ud(){if(typeof window>"u")return"self";try{if(window.parent===window)return"self";const r=new URLSearchParams(window.location.search);for(const t of is)if(r.get(t))return"query";if(typeof sessionStorage<"u"){for(const t of cs)if(sessionStorage.getItem(t))return"sessionStorage"}if(document.referrer){const t=fn(document.referrer);if(t&&t!==window.location.origin)return"referrer"}return"wildcard"}catch{return"wildcard"}}function fn(r){if(!r)return null;const t=r.trim().replace(/\/+$/,"");if(!t)return null;if(/^https?:\/\/[^/]+$/.test(t))return t;try{return new URL(t).origin}catch{return null}}function Vd(r){const[t,n]=o.useState({}),[a,s]=o.useState(!1),l=o.useCallback(f=>a||t[f]?r[f]:void 0,[r,a,t]),i=o.useCallback(f=>{n(p=>({...p,[f]:!0}))},[]),c=o.useCallback(()=>{s(!0)},[]),u=o.useCallback(()=>{n({}),s(!1)},[]);return{submitted:a,touchedFields:t,getFieldError:l,touchField:i,submit:c,reset:u}}Object.defineProperty(_,"toast",{enumerable:!0,get:()=>$a.toast}),_.Alert=ul,_.AreaChart=dn,_.AuthShell=Xo,_.BarChart=Md,_.BonsaifButton=Gs,_.BonsaifUIToaster=wd,_.BulletChart=Pd,_.Button=Fe,_.CHART_PALETTE=nn,_.CalendarPicker=hl,_.ChartCard=kd,_.Checkbox=Wt,_.CodeBlock=wl,_.ComboChart=Dd,_.CompactFilterSelect=Sl,_.CompactSearchInput=Nl,_.ConfirmDialog=Ll,_.CopyButton=_n,_.CopyLinkButton=Dl,_.CpuChart=Fd,_.DataSheets=ai,_.DataTable=Ja,_.DateRangePicker=li,_.DonutChart=Td,_.Drawer=fi,_.DropdownMenu=di,_.DynamicDetailTabs=cl,_.EmailField=Oi,_.EmptyState=Pi,_.FieldHelperFooter=Xr,_.FieldLabelInfo=Kr,_.FieldLayoutEditor=qi,_.FileUpload=ji,_.FormField=uo,_.GaugeChart=Od,_.GlobalScrollbars=Wo,_.InputField=Qn,_.LineChart=Ed,_.LoadingState=Fa,_.MentionTextEditor=Bo,_.MicroserviceFrame=hd,_.Modal=qn,_.MouseTooltip=Mr,_.MultiSelect=Vi,_.NetworkChart=Wd,_.NumberField=Gi,_.PageHeader=bd,_.PageSearchInput=Ia,_.Pagination=Xi,_.PhoneField=Zi,_.PieChart=Ld,_.PrimeAuthRouteShell=pd,_.PrimeSuiteChatFrame=gd,_.RadioGroup=Qi,_.RamChart=zd,_.RichTextEditor=wc,_.SearchableSelect=Lr,_.SectionPanel=kc,_.Sparkline=Ad,_.StatusBadge=Cc,_.StatusSelect=$c,_.StepWizard=Dc,_.TableSkeleton=jt,_.Tabs=Ac,_.TagInput=Wc,_.TextInput=Qt,_.Textarea=Ho,_.TextareaField=Pc,_.Toggle=Uc,_.UserAvatar=Ko,_.WaterfallChart=Id,_.buildMentionQueryRegex=No,_.cn=gr,_.configureBonsaifUI=Ol,_.dedupeMentions=Lo,_.defaultValueFormat=tr,_.describeParentTargetOrigin=Ud,_.emailFormat=vi,_.extractMentionUsernames=aa,_.filterSelfMentions=mc,_.findMentionTriggerInEditor=ta,_.formatBytes=Qr,_.formatPercent=Zr,_.formatRate=es,_.getBonsaifUIConfig=Hl,_.getDataTablePreferencesEndpoint=Un,_.getPlainTextOffset=oa,_.highlightMentions=To,_.htmlToText=Eo,_.insertMentionInEditor=$o,_.isMentionTriggerBoundary=Co,_.isPlainOffsetInsideMentionChip=So,_.isValidEmail=Xn,_.isValidPhone=Yn,_.locateTextOffset=Yr,_.matches=Si,_.maxLength=wi,_.maxValue=Ni,_.mentionDisplayLabel=Mo,_.minLength=yi,_.minValue=ki,_.normalizeUsername=na,_.phoneCountryCodeOptions=po,_.phoneFormat=xi,_.placeCaretAtTextOffset=Ao,_.required=gi,_.resetBonsaifUIConfig=Pl,_.resolveMentions=pc,_.resolveParentTargetOrigin=qd,_.seriesColor=Ro,_.setBonsaifDataTablePreferencesEndpoint=Fl,_.toneColor=sr,_.usageColor=Ct,_.usageTone=an,_.useValidationVisibility=Vd,_.validateForm=Ci,Object.defineProperty(_,Symbol.toStringTag,{value:"Module"})}));
|