bonsaif-ui 0.1.51 → 0.1.52
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/dist/bonsaif-ui.js +1 -1
- package/dist/bonsaif-ui.umd.cjs +1 -1
- package/package.json +1 -1
package/dist/bonsaif-ui.js
CHANGED
|
@@ -4730,7 +4730,7 @@ function gi({
|
|
|
4730
4730
|
value: c,
|
|
4731
4731
|
maxLength: n == null ? void 0 : n.maxLength,
|
|
4732
4732
|
onChange: (h) => u(h.target.value),
|
|
4733
|
-
onBlur: () =>
|
|
4733
|
+
onBlur: () => i(),
|
|
4734
4734
|
onKeyDown: (h) => {
|
|
4735
4735
|
h.key === "Enter" && (h.preventDefault(), a(c)), h.key === "Escape" && (h.preventDefault(), i()), (n == null ? void 0 : n.preset) === "integer" && !h.ctrlKey && !h.metaKey && !xi.has(h.key) && !/^[\d-]$/.test(h.key) && h.preventDefault();
|
|
4736
4736
|
},
|
package/dist/bonsaif-ui.umd.cjs
CHANGED
|
@@ -18,4 +18,4 @@ ${E}`,K=new Blob(["\uFEFF"+f],{type:"text/csv;charset=utf-8;"}),k=URL.createObje
|
|
|
18
18
|
<table><thead><tr>${d.map(ce=>`<th>${ce}</th>`).join("")}</tr></thead>
|
|
19
19
|
<tbody>${f}</tbody></table>
|
|
20
20
|
<script>window.onload=()=>{window.print()}<\/script>
|
|
21
|
-
</body></html>`,k=window.open("","_blank");k&&(k.document.write(K),k.document.close())}const ht=()=>!Se||!Tr?null:je.createPortal(e.jsxs("div",{ref:Ot,role:"menu",className:"overflow-hidden rounded-lg border p-1 shadow-xl",style:{...Ls,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:()=>{ai(),rt(!1)},children:[e.jsx(v.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:()=>{ni(),rt(!1)},children:[e.jsx(v.HiDocumentText,{className:"h-4 w-4 shrink-0 text-red-500"}),"Imprimir / PDF"]})]}),document.body),vt=()=>{const o=F&&Xe.trim().length>0,d=de!=null&&de.length?de:o?[{key:"bql",label:"BQL",value:Xe}]:[],E=I.filter(f=>f.trim()&&f!==Rr).slice(0,8);return!D&&jt===0&&!F&&!Se?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:[jt>0&&e.jsxs("button",{type:"button",onClick:_s,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(v.HiXMark,{className:"h-3.5 w-3.5"}),jt," filtros"]}),F&&e.jsxs("div",{ref:Bt,className:"relative flex min-w-0 flex-1 items-center gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>{if(Ze){or(!1);return}it(),or(!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:Ze?"var(--primary)":o?"color-mix(in srgb, var(--primary) 12%, transparent)":"var(--bg-card)",borderColor:Ze||o?"var(--primary)":"var(--border)",color:Ze?"var(--primary-fg)":"var(--primary)"},"aria-expanded":Ze,title:"Abrir filtros BQL",children:[e.jsx(v.HiCommandLine,{className:"h-3.5 w-3.5"}),"BQL",o&&e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-current"}),Ze?e.jsx(v.HiChevronUp,{className:"h-3.5 w-3.5"}):e.jsx(v.HiChevronDown,{className:"h-3.5 w-3.5"})]}),e.jsx("span",{className:"hidden truncate text-xs text-[var(--text-muted)] sm:inline",children:te}),d.length>0&&e.jsxs("div",{className:"hidden min-w-0 items-center gap-1.5 overflow-hidden lg:flex",children:[d.slice(0,3).map(f=>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:[f.label,":"]}),e.jsx("span",{className:"truncate",children:f.value})]},f.key)),d.length>3&&e.jsxs("span",{className:"text-xs text-[var(--text-muted)]",children:["+",d.length-3]})]}),o&&e.jsx("button",{type:"button","aria-label":"Limpiar BQL",title:"Limpiar BQL",onClick:bn,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(v.HiXMark,{className:"h-4 w-4"})}),Ze&&je.createPortal(e.jsxs("div",{ref:en,className:"flex flex-col gap-3 rounded-lg p-3 shadow-2xl",style:{...Cs,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:[se.map(f=>e.jsxs("button",{type:"button",onClick:()=>st(f.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:[f.icon,f.label]},f.label)),w.length>0&&e.jsxs("button",{type:"button",onClick:()=>fr(f=>!f),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":Qa,children:[e.jsx(v.HiInformationCircle,{className:"h-3.5 w-3.5"}),"Ejemplos"]}),$r.length>0&&e.jsxs("button",{type:"button",onClick:()=>pr(f=>!f),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":Ra,children:[e.jsx(v.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 ${be?"var(--danger)":o?"var(--primary)":"var(--border)"}`},children:[e.jsx("textarea",{ref:It,value:Rr,rows:3,onChange:f=>Wt(f.target.value,f.target),onKeyDown:f=>{f.key==="Enter"&&!f.shiftKey&&(f.preventDefault(),st(Rr)),f.key==="Escape"&&or(!1)},placeholder:ue,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"}}),E.length>0&&e.jsx("div",{className:"border-t border-[var(--border)] bg-[var(--bg-card)]",children:E.map(f=>e.jsx("button",{type:"button",onMouseDown:K=>{var k;K.preventDefault(),Wt(f),(k=It.current)==null||k.focus()},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:f},f))})]}),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:be?"var(--danger)":"var(--text-muted)"},children:be??(o?`${d.length||1} filtro${(d.length||1)===1?"":"s"} activo${(d.length||1)===1?"":"s"}`:"Enter aplica la consulta. Shift + Enter agrega linea.")}),d.map(f=>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:[f.label,":"]}),e.jsx("span",{className:"truncate",children:f.value})]},f.key))]}),Ra&&$r.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(v.HiClock,{className:"h-3.5 w-3.5"}),"Historial"]}),e.jsxs("button",{type:"button",onClick:()=>{Lr([]),pr(!1)},className:"inline-flex items-center gap-1 rounded px-2 py-0.5 text-xs text-[var(--text-muted)]",children:[e.jsx(v.HiTrash,{className:"h-3 w-3"}),"Limpiar"]})]}),$r.map(f=>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",onClick:()=>st(f),className:"min-w-0 flex-1 text-left",children:e.jsx("code",{className:"block truncate text-xs text-[var(--primary)]",children:f})}),e.jsx("button",{type:"button",onClick:()=>Lr(K=>K.filter(k=>k!==f)),className:"rounded p-1 text-[var(--text-muted)] opacity-0 transition-opacity group-hover:opacity-100",children:e.jsx(v.HiXMark,{className:"h-3.5 w-3.5"})})]},f))]}),Qa&&w.length>0&&e.jsx("div",{className:"grid gap-2 sm:grid-cols-2 lg:grid-cols-3",children:w.map(f=>e.jsxs("button",{type:"button",onClick:()=>{var K;Wt(f.bql),fr(!1),(K=It.current)==null||K.focus()},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:f.bql}),f.description&&e.jsx("span",{className:"mt-1 block text-xs text-[var(--text-muted)]",children:f.description})]},f.bql))}),e.jsxs("div",{className:"flex items-center justify-end gap-2 border-t border-[var(--border)] pt-3",children:[o&&e.jsxs("button",{type:"button",onClick:bn,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(v.HiXMark,{className:"h-3.5 w-3.5"}),"Limpiar"]}),e.jsxs("button",{type:"button",onClick:()=>st(Rr),className:"inline-flex h-8 items-center gap-1.5 rounded-md bg-[var(--primary)] px-4 text-xs font-semibold text-[var(--primary-fg)] transition-opacity hover:opacity-90",children:[e.jsx(v.HiCheck,{className:"h-3.5 w-3.5"}),"Aplicar"]})]})]}),document.body)]})]}),Se&&e.jsx("button",{ref:tt,type:"button","aria-haspopup":"menu","aria-expanded":Tr,"aria-label":"Exportar datos",title:"Exportar datos",onClick:()=>{var K;const f=(K=tt.current)==null?void 0:K.getBoundingClientRect();f&&Ts({top:f.bottom+4,right:window.innerWidth-f.right}),rt(k=>!k)},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)] ${Tr?"bg-[var(--bg-card)] text-[var(--primary)]":""}`,children:e.jsx(v.HiArrowDownTray,{className:"h-4 w-4"})}),D&&e.jsx("button",{type:"button","aria-haspopup":"menu","aria-expanded":Re&&lr==="visibility","aria-label":oe,title:oe,onClick:f=>pn(f,"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)] ${Re&&lr==="visibility"?"bg-[var(--bg-card)] text-[var(--primary)]":""}`,children:e.jsx(v.HiCog6Tooth,{className:"h-4 w-4"})})]})},Cn=()=>{if(!Qs)return null;const o=Nl(De,Kt);return e.jsxs("div",{"aria-busy":n,className:`grid grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)] items-center gap-2 rounded-b-xl border-t text-xs select-none ${i?"px-2 py-0.5":"px-3 py-1"}`,style:{borderColor:"var(--border)",background:"var(--bg-input)"},children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{style:{color:"var(--text-muted)"},children:xr===0?"0 filas":`${Rs}–${ei} de ${xr}`}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{style:{color:"var(--text-muted)"},children:"Filas:"}),e.jsx(rr,{value:String(Ue),onChange:d=>ri(Number(d)),options:Q.map(d=>({value:String(d),label:String(d)})),placeholder:"Filas",searchable:!1,disabled:n,height:W,padding:J,className:"shrink-0 [&>button]:rounded-md [&>button]:text-xs [&_svg]:h-3.5 [&_svg]:w-3.5",style:{width:re}})]})]}),e.jsxs("div",{className:"flex items-center justify-center gap-0.5",children:[e.jsx("button",{disabled:n||De<=1,onClick:()=>Gt(De-1),onMouseEnter:d=>{d.currentTarget.disabled||(d.currentTarget.style.background="color-mix(in srgb, var(--primary) 14%, var(--bg-card))",d.currentTarget.style.color="var(--primary)")},onMouseLeave:d=>{d.currentTarget.style.background="transparent",d.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(v.HiChevronLeft,{className:"h-3.5 w-3.5"})}),o.map((d,E)=>d==="..."?e.jsx("span",{className:"px-1",style:{color:"var(--text-muted)"},children:"…"},`e${E}`):e.jsx("button",{disabled:n,onClick:()=>Gt(d),onMouseEnter:f=>{f.currentTarget.disabled||d===De||(f.currentTarget.style.background="color-mix(in srgb, var(--primary) 14%, var(--bg-card))",f.currentTarget.style.color="var(--primary)")},onMouseLeave:f=>{f.currentTarget.style.background=d===De?"var(--primary)":"transparent",f.currentTarget.style.color=d===De?"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:d===De?"var(--primary)":"transparent",color:d===De?"var(--primary-fg)":"var(--text-muted)"},children:d},d)),e.jsx("button",{disabled:n||De>=Kt,onClick:()=>Gt(De+1),onMouseEnter:d=>{d.currentTarget.disabled||(d.currentTarget.style.background="color-mix(in srgb, var(--primary) 14%, var(--bg-card))",d.currentTarget.style.color="var(--primary)")},onMouseLeave:d=>{d.currentTarget.style.background="transparent",d.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(v.HiChevronRight,{className:"h-3.5 w-3.5"})})]}),e.jsx("div",{"aria-hidden":"true"})]})},En=()=>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:ut},children:[pt(),ht(),vt(),e.jsx("div",{ref:er,className:"min-w-0 max-w-full overflow-hidden",children:e.jsxs("div",{role:"table",className:"text-sm",style:{width:Br,minWidth:bt},children:[e.jsx("div",{role:"rowgroup",style:L?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:ft()}),e.jsx("div",{role:"rowgroup",children:Array.from({length:Math.min(6,s)}).map((o,d)=>e.jsxs("div",{role:"row",className:"grid",style:{gridTemplateColumns:wr,borderBottom:`1px solid ${xe}`},children:[Ve&&e.jsx("div",{role:"cell",className:`${i?"px-2 py-1.5":"px-3 py-2"} w-10`,style:{borderBottom:`1px solid ${xe}`,borderRight:`1px solid ${xe}`}},"select-cell"),qe.map((E,f)=>e.jsx("div",{role:"cell",className:i?"px-2 py-1.5":"px-3 py-2",style:{borderBottom:`1px solid ${xe}`,borderRight:`1px solid ${xe}`},children:e.jsx("div",{className:"h-3.5 rounded-full animate-pulse",style:{background:"var(--border)",width:`${an(d,f)}%`,minWidth:32}})},E.key))]},d))})]})})]}),Xt="min-w-0 max-w-full overflow-hidden";return _&&!$e&&t.length===0||!n&&t.length===0&&!Ft?En():n&&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:ut},children:[pt(),ht(),vt(),e.jsx("div",{ref:er,className:Xt,children:e.jsx(Qt.OverlayScrollbarsComponent,{options:{scrollbars:{autoHide:"leave",autoHideDelay:200}},className:"w-full",style:{maxHeight:ln,maxWidth:"100%"},defer:!0,children:e.jsxs("div",{role:"table",className:"text-sm",style:{width:Br,minWidth:bt},children:[e.jsx("div",{role:"rowgroup",style:L?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:ft()}),e.jsx("div",{role:"rowgroup",children:Array.from({length:s}).map((o,d)=>e.jsxs("div",{role:"row",className:"grid",style:{gridTemplateColumns:wr,borderBottom:`1px solid ${xe}`},children:[Ve&&e.jsx("div",{role:"cell",className:`${i?"px-2 py-1.5":"px-3 py-2"} w-10`,style:{borderBottom:`1px solid ${xe}`,borderRight:`1px solid ${xe}`}},"select-cell"),qe.map((E,f)=>{const K=le&&!Pt&&f===0;return e.jsx("div",{role:"cell","data-dt-column-key":E.key,className:i?"px-2 py-1.5":"px-3 py-2",style:K?{position:"sticky",left:Vt,zIndex:1,background:"color-mix(in srgb, var(--bg-card) 72%, transparent)",backdropFilter:"blur(10px)",WebkitBackdropFilter:"blur(10px)",boxShadow:`3px 0 6px -2px rgba(0,0,0,0.10), inset 0 -1px 0 ${xe}`,borderRight:`1px solid ${xe}`}:{borderBottom:`1px solid ${xe}`,borderRight:`1px solid ${xe}`},children:e.jsx("div",{className:"h-3.5 rounded-full animate-pulse",style:{background:"var(--border)",width:`${an(d,f)}%`,minWidth:32}})},E.key)})]},d))})]})})}),Cn()]}):!n&&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:ut},children:[pt(),ht(),vt(),e.jsx("div",{ref:er,className:Xt,children:e.jsx("div",{role:"table",className:"text-sm",style:{width:Br,minWidth:bt},children:e.jsx("div",{role:"rowgroup",style:L?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:ft()})})}),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:xe,background:"linear-gradient(180deg, color-mix(in srgb, var(--bg-input) 58%, transparent), var(--bg-card))"},children:[e.jsx("div",{className:"flex h-12 w-12 items-center justify-center rounded-full border",style:{borderColor:"color-mix(in srgb, var(--primary) 24%, var(--border))",background:"color-mix(in srgb, var(--primary) 8%, var(--bg-card))",color:"var(--primary)"},children:c??e.jsx(v.HiMagnifyingGlass,{className:"h-5 w-5"})}),e.jsx("p",{className:"max-w-sm text-sm font-medium",style:{color:"var(--text-main)"},children:u}),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:ut},children:[pt(),ht(),vt(),e.jsx("div",{ref:er,className:Xt,children:e.jsx(Qt.OverlayScrollbarsComponent,{options:{scrollbars:{autoHide:"leave",autoHideDelay:200}},className:"w-full",style:{maxHeight:ln,maxWidth:"100%"},defer:!0,children:e.jsxs("div",{role:"table",className:"text-sm",style:{width:Br,minWidth:bt},children:[e.jsx("div",{role:"rowgroup",style:L?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:ft()}),e.jsx("div",{role:"rowgroup",children:vn.map((o,d)=>{const E=a(o),f=Nn(X==null?void 0:X(o)),K=d>0?Nn(X==null?void 0:X(vn[d-1])):null,k=f&&f.key!==(K==null?void 0:K.key),ce=Ve&&N.has(E),j=gr?(h==null?void 0:h(o))??!0:!1,Ee=j&&hn.has(E),Ne=!!p||C&&j,he=ce&&ee?"color-mix(in srgb, var(--primary) 8%, var(--bg-card))":d%2===1?"color-mix(in srgb, var(--bg-input) 30%, var(--bg-card))":"var(--bg-card)";return e.jsxs(l.Fragment,{children:[k&&e.jsx("div",{role:"row",className:`grid ${f.className??""}`,style:{gridTemplateColumns:wr},children:e.jsx("div",{role:"cell",className:i?"px-2 py-2":"px-3 py-3",style:{gridColumn:"1 / -1",background:"color-mix(in srgb, var(--primary) 8%, var(--bg-input))",borderBottom:`1px solid ${xe}`,borderRight:`1px solid ${xe}`},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:f.label}),f.description&&e.jsx("div",{className:"mt-0.5 truncate text-xs text-[var(--text-muted)]",children:f.description})]})})})}),e.jsxs("div",{role:"row",onClick:Ne?ge=>{const ve=ge.target;if(!(ve!=null&&ve.closest('[data-dt-disable-row-click="true"]'))){if(C&&j){gn(E);return}p==null||p(o)}}:void 0,className:`grid transition-colors ${Ne?"cursor-pointer":""} ${z?z(o):""}`,style:{gridTemplateColumns:wr,"--dt-row-bg":he,"--dt-sticky-bg":he,background:"var(--dt-row-bg)",borderBottom:`1px solid ${xe}`},onMouseEnter:ge=>{ce||(ge.currentTarget.style.setProperty("--dt-row-bg","var(--bg-hover)"),ge.currentTarget.style.setProperty("--dt-sticky-bg",ti))},onMouseLeave:ge=>{ge.currentTarget.style.setProperty("--dt-row-bg",he),ge.currentTarget.style.setProperty("--dt-sticky-bg",he)},children:[gr&&e.jsx("div",{role:"cell",className:`${i?"px-2 py-1.5":"px-3 py-2"} flex w-10 items-center justify-center`,style:{borderBottom:`1px solid ${xe}`,borderRight:`1px solid ${xe}`},"data-dt-disable-row-click":"true",children:j&&e.jsx("button",{type:"button","aria-label":Ee?"Contraer fila":"Desplegar fila","aria-expanded":Ee,onClick:ge=>{ge.stopPropagation(),gn(E)},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:Ee?e.jsx(v.HiChevronDown,{className:"h-4 w-4"}):e.jsx(v.HiChevronRight,{className:"h-4 w-4"})})}),Ve&&e.jsx("div",{role:"cell",className:`${i?"px-2 py-1.5":"px-3 py-2"} w-10`,style:le?{position:"sticky",left:0,zIndex:3,background:"var(--dt-sticky-bg)",boxShadow:`inset 0 -1px 0 ${xe}`}:{borderBottom:`1px solid ${xe}`,borderRight:`1px solid ${xe}`},onClick:ge=>{ge.stopPropagation(),S(E)},children:e.jsx(Fr,{size:"sm",checked:ce,"aria-label":"Seleccionar fila",containerClassName:"items-center",className:"cursor-pointer",onClick:ge=>ge.stopPropagation(),onChange:()=>S(E)})}),qe.map((ge,ve)=>{const He=le&&!Pt&&ve===0,ye=ar(ge);return e.jsx("div",{role:"cell","data-dt-column-key":ge.key,"data-dt-disable-row-click":ge.disableRowClick||ye?"true":void 0,className:`${ye?"px-2 py-1.5 text-center":`${i?"px-2 py-1.5":"px-3 py-2"} ${xn(ge.align)}`} ${ml} ${ge.className??""}`,style:{overflow:"hidden",whiteSpace:"nowrap",...He?{position:"sticky",left:Vt,zIndex:3,background:"var(--dt-sticky-bg)",boxShadow:`3px 0 6px -2px rgba(0,0,0,0.10), inset 0 -1px 0 ${xe}`,borderRight:`1px solid ${xe}`}:{borderBottom:`1px solid ${xe}`,borderRight:`1px solid ${xe}`}},children:e.jsx(pa,{children:e.jsx("div",{"data-dt-autofit-content":!0,className:"inline-block max-w-none align-middle",children:ge.cell(o)})})},ge.key)})]}),Ee&&m&&e.jsx("div",{role:"row",className:"grid",style:{gridTemplateColumns:wr},children:e.jsx("div",{role:"cell",className:i?"px-2 py-2":"px-3 py-3",style:{gridColumn:"1 / -1",background:"color-mix(in srgb, var(--bg-input) 60%, var(--bg-card))",borderBottom:`1px solid ${xe}`},children:m(o)})})]},E)})})]})})}),Cn()]})}const Cl={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 El(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 a=Cl[t.preset];if(!a.pattern.test(r))return t.message??a.message}return t.pattern&&!t.pattern.test(r)?t.message??"Formato inválido":null}const Ml=new Set(["Backspace","Delete","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Tab","Home","End","Enter","Escape"]);function $l({initialValue:r,type:t,mask:a,onCommit:n,onCancel:s}){const[c,u]=l.useState(r),b=l.useRef(null),p=(a==null?void 0:a.preset)==="date",m=p?"date":t==="number"?"number":"text";return l.useEffect(()=>{var h,x;(h=b.current)==null||h.focus(),p||(x=b.current)==null||x.select()},[p]),e.jsx("input",{ref:b,type:m,value:c,maxLength:a==null?void 0:a.maxLength,onChange:h=>u(h.target.value),onBlur:()=>n(c),onKeyDown:h=>{h.key==="Enter"&&(h.preventDefault(),n(c)),h.key==="Escape"&&(h.preventDefault(),s()),(a==null?void 0:a.preset)==="integer"&&!h.ctrlKey&&!h.metaKey&&!Ml.has(h.key)&&!/^[\d-]$/.test(h.key)&&h.preventDefault()},onClick:h=>h.stopPropagation(),className:"w-full min-w-0 border-0 bg-transparent p-0 text-sm text-[var(--text-main)] outline-none"})}function Ll({initialValue:r,options:t,loading:a,onCommit:n,onCancel:s}){const c=l.useRef(null),[u,b]=l.useState(r);return l.useEffect(()=>{if(a)return;const p=setTimeout(()=>{var m,h;(h=(m=c.current)==null?void 0:m.querySelector("button"))==null||h.click()},0);return()=>clearTimeout(p)},[a]),e.jsx("div",{ref:c,className:"w-full",tabIndex:-1,onKeyDown:p=>{p.key==="Escape"&&(p.stopPropagation(),s()),p.key==="Enter"&&(p.preventDefault(),p.stopPropagation(),n(u))},children:e.jsx(rr,{value:u,onChange:p=>{b(p),setTimeout(()=>{var m;return(m=c.current)==null?void 0:m.focus({preventScroll:!0})},0)},options:t,disabled:a,placeholder:a?"Cargando…":"Seleccionar…",triggerVariant:"ghost",height:30,padding:"0 6px",minOptionsForSearch:1,className:"w-full"})})}const Tl={outline:"2px solid var(--primary)",outlineOffset:"-2px",borderRadius:"4px",background:"color-mix(in srgb, var(--primary) 5%, var(--bg-card))"},ha={outline:"2px solid var(--primary)",outlineOffset:"-2px",borderRadius:"4px"};function Al({columns:r,data:t,getRowId:a,onCellUpdate:n,readOnly:s=!1,...c}){const[u,b]=l.useState(t),p=l.useRef(null);l.useEffect(()=>{p.current||b(t)},[t]);const[m,h]=l.useState(null);p.current=m;const[x,g]=l.useState(null),$=l.useRef(null);$.current=x;const[C,N]=l.useState({}),[S,B]=l.useState({}),[ee,z]=l.useState({}),X=l.useRef(new Set),L=l.useRef(null);l.useEffect(()=>{var y;const i=document.activeElement;(!i||i===document.body)&&((y=L.current)==null||y.focus({preventScroll:!0}))},[]);const U=r.map(i=>{var y,M,O;return`${i.key}:${((O=(M=(y=i.editable)==null?void 0:y.select)==null?void 0:M.options)==null?void 0:O.length)??-1}`}).join("|");l.useEffect(()=>{r.forEach(i=>{var O,D;const y=(D=(O=i.editable)==null?void 0:O.select)==null?void 0:D.options;if(!y)return;const M=S[i.key];(!X.current.has(i.key)||(M==null?void 0:M.length)===0&&y.length>0)&&(X.current.add(i.key),B(ae=>({...ae,[i.key]:y})))})},[U]);const Q=l.useCallback(async(i,y)=>{if(X.current.has(i))return;X.current.add(i);const{url:M,fetchOptions:O}=y.select??{};if(!(!M&&!O)){z(D=>({...D,[i]:!0}));try{let D=[];if(O)D=await O();else if(M){const ae=await fetch(M);if(!ae.ok)throw new Error("fetch failed");D=await ae.json()}B(ae=>({...ae,[i]:D}))}catch{B(D=>({...D,[i]:[]}))}finally{z(D=>({...D,[i]:!1}))}}},[]),re=l.useRef(u);re.current=u;const W=l.useRef(n);W.current=n;const J=l.useRef(a);J.current=a;const R=l.useRef(r);R.current=r;const T=l.useRef(s);T.current=s,l.useEffect(()=>{if(r.length>0&&t.length>0){const i=r.find(y=>y.selectable!==!1);i&&g({rowId:a(t[0]),colKey:i.key})}},[]),l.useEffect(()=>{if(!x)return;const i=L.current;if(!i)return;const y=i.querySelector(`[data-cell-id="${x.rowId}:${x.colKey}"]`);if(!y)return;const M=i.querySelector('[role="rowgroup"]');y.style.scrollMarginTop=`${(M==null?void 0:M.offsetHeight)??0}px`;const O=i.querySelector('[role="row"]');let D=0;O&&O.querySelectorAll('[role="cell"], [role="columnheader"]').forEach(ae=>{ae.style.position==="sticky"&&ae.style.left!==""&&(D=Math.max(D,parseFloat(ae.style.left)+ae.offsetWidth))}),y.style.scrollMarginLeft=`${D}px`,y.scrollIntoView({block:"nearest",inline:"nearest"})},[x]);const P=l.useCallback(i=>{var D;const y=R.current,M=new Set,O=[];(D=L.current)==null||D.querySelectorAll("[data-cell-id]").forEach(ae=>{const ie=ae.dataset.cellId.split(":")[0];M.has(ie)||(M.add(ie),O.push(ie))}),g(ae=>{if(!ae)return ae;const ie=y.findIndex(F=>F.key===ae.colKey),pe=O.indexOf(ae.rowId);let A=ie,oe=pe;if(i==="up")oe=Math.max(0,pe-1);else if(i==="down")oe=Math.min(O.length-1,pe+1);else if(i==="left"){let F=ie-1;for(;F>=0&&y[F].selectable===!1;)F--;F>=0&&(A=F)}else if(i==="right"){let F=ie+1;for(;F<y.length&&y[F].selectable===!1;)F++;F<y.length&&(A=F)}return A===ie&&oe===pe?ae:{rowId:O[oe],colKey:y[A].key}})},[]),V=l.useCallback((i=!0)=>{const y=p.current;h(null),y&&g(y),i&&setTimeout(()=>{var M;return(M=L.current)==null?void 0:M.focus({preventScroll:!0})},0)},[]),_=l.useCallback(async(i,y,M)=>{var se;const O=R.current.find(w=>w.key===y);if(!(O!=null&&O.editable))return;const{field:D,type:ae,mask:ie,validate:pe}=O.editable,A=ae==="number"?M===""?null:Number(M):M;if(ie){const w=El(M,ie);if(w){N(I=>({...I,[`${i}:${y}`]:w}));return}}if(pe){const w=pe(A);if(w){N(I=>({...I,[`${i}:${y}`]:w}));return}}const oe=J.current,F=re.current.find(w=>oe(w)===i);if(!F)return;const H=F[D];h(null),N(w=>{const I={...w};return delete I[`${i}:${y}`],I});const Z=re.current,G=Z.findIndex(w=>oe(w)===i),te=Z[Math.min(Z.length-1,G+1)];if(g({rowId:oe(te),colKey:y}),setTimeout(()=>{var I,de;const w=document.activeElement;(!w||w===document.body||(I=L.current)!=null&&I.contains(w))&&((de=L.current)==null||de.focus({preventScroll:!0}))},0),String(H??"")===String(A??""))return;const ue={...F,[D]:A};b(w=>w.map(I=>oe(I)===i?ue:I));try{await((se=W.current)==null?void 0:se.call(W,{row:F,rowId:i,field:D,oldValue:H,newValue:A}))}catch{b(w=>w.map(I=>oe(I)===i?F:I)),N(w=>({...w,[`${i}:${y}`]:"Error al guardar. Intenta de nuevo."}))}},[]),le=l.useCallback(i=>{if(p.current)return;const y=$.current;if(!(!y||!["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Enter","Escape","Tab"].includes(i.key)))switch(i.preventDefault(),i.key){case"ArrowUp":P("up");break;case"ArrowDown":P("down");break;case"ArrowLeft":P("left");break;case"ArrowRight":P("right");break;case"Tab":P(i.shiftKey?"left":"right");break;case"Enter":{const O=R.current.find(D=>D.key===y.colKey);O!=null&&O.editable&&!T.current?(h(y),O.editable.type==="select"&&!X.current.has(y.colKey)&&Q(y.colKey,O.editable)):P("down");break}}},[P,Q]),q=l.useMemo(()=>r.map(i=>{if(!i.editable||s){const{editable:M,selectable:O,...D}=i;if(i.selectable===!1)return{...D,disableRowClick:!0};const ae=D.cell;return{...D,className:`relative ${D.className??""}`.trim(),disableRowClick:!0,cell:ie=>{const pe=a(ie),A=(x==null?void 0:x.rowId)===pe&&(x==null?void 0:x.colKey)===i.key;return e.jsxs(e.Fragment,{children:[e.jsx("span",{"data-cell-id":`${pe}:${i.key}`,className:"absolute inset-0 z-10 cursor-default",onClick:()=>{var oe;g({rowId:pe,colKey:i.key}),(oe=L.current)==null||oe.focus({preventScroll:!0})}}),A&&e.jsx("div",{className:"pointer-events-none absolute inset-0 z-20",style:ha}),e.jsx("span",{className:"relative z-0 pointer-events-none",children:ae(ie)})]})}}}const y=i.editable;return{...i,className:`relative ${i.className??""}`.trim(),disableRowClick:!0,cell:M=>{const O=a(M),D=i.key,ae=(m==null?void 0:m.rowId)===O&&(m==null?void 0:m.colKey)===D,ie=(x==null?void 0:x.rowId)===O&&(x==null?void 0:x.colKey)===D,pe=C[`${O}:${D}`],A=M[y.field],oe=String(A??""),F=()=>{var Z;g({rowId:O,colKey:D}),h({rowId:O,colKey:D}),(Z=L.current)==null||Z.focus({preventScroll:!0}),y.type==="select"&&!X.current.has(D)&&Q(D,y)};if(ae){const Z=y.type==="select"?e.jsx(Ll,{initialValue:oe,options:S[D]??[],loading:ee[D]??!1,onCommit:G=>_(O,D,G),onCancel:V}):e.jsx($l,{initialValue:oe,type:y.type??"text",mask:y.mask,onCommit:G=>_(O,D,G),onCancel:V});return e.jsx("div",{className:"absolute inset-0 flex items-center px-2",style:Tl,onClick:G=>G.stopPropagation(),children:Z})}const H=i.cell(M);return e.jsxs(e.Fragment,{children:[e.jsx("span",{"data-cell-id":`${O}:${D}`,className:"peer absolute inset-0 z-10 cursor-pointer",onClick:F}),ie&&e.jsx("div",{className:"pointer-events-none absolute inset-0 z-20",style:ha}),e.jsx("span",{className:"relative z-0 inline-flex items-center gap-1 pointer-events-none",children:pe?e.jsxs("span",{className:"flex items-center gap-1 text-red-500",children:[e.jsx(v.HiExclamationCircle,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"truncate text-xs",children:pe})]}):e.jsx("span",{className:"truncate",children:H})}),e.jsx(v.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,m,x,C,S,ee,a,_,V,Q]);return e.jsx("div",{ref:L,tabIndex:0,onKeyDown:le,onBlur:i=>{var y;(y=L.current)!=null&&y.contains(i.relatedTarget)||setTimeout(()=>{var O,D;const M=document.activeElement;M&&((O=M.closest)!=null&&O.call(M,"[data-bonsaif-select-dropdown]"))||(D=L.current)!=null&&D.contains(M)||V(!1)},0)},style:{width:"100%",minWidth:0,outline:"none"},children:e.jsx(ma,{...c,columns:q,data:u,getRowId:a})})}function kr(r){return r?new Date(`${r}T12:00:00`):void 0}function va(r){return r.toISOString().slice(0,10)}function Hl({calendarMonth:r,displayIndex:t}){const{previousMonth:a,nextMonth:n,goToMonth:s,months:c,labels:u,formatters:b}=Rt.useDayPicker(),p=!!a&&t===0,m=!!n&&t===c.length-1;return e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",gap:8,width:"100%",color:"var(--text-main)",marginBottom:6},children:[e.jsx("span",{style:{fontWeight:700},children:b.formatCaption(r.date)}),e.jsx("button",{type:"button","aria-label":u.labelPrevious(a),onClick:()=>a&&s(a),disabled:!p,style:{height:28,width:28,borderRadius:8,border:"1px solid var(--border)",background:"var(--bg-card)",display:"inline-flex",alignItems:"center",justifyContent:"center",color:"var(--text-main)",opacity:p?1:.45,cursor:p?"pointer":"not-allowed"},children:e.jsx(v.HiChevronLeft,{size:16})}),e.jsx("button",{type:"button","aria-label":u.labelNext(n),onClick:()=>n&&s(n),disabled:!m,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:m?1:.45,cursor:m?"pointer":"not-allowed"},children:e.jsx(v.HiChevronRight,{size:16})})]})}function Dl(r){return r.charAt(0).toUpperCase()+r.slice(1)}function Bl({startDate:r,endDate:t,onChange:a,minDate:n,viewMonth:s,numberOfMonths:c=1,showSummary:u=!0,startLabel:b="Inicio",endLabel:p="Regreso"}){const m={from:kr(r),to:kr(t)},h=kr(n),[x,g]=l.useState(kr(s||r));return l.useEffect(()=>{g(kr(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(Rt.DayPicker,{mode:"range",selected:m,month:x,onMonthChange:g,onSelect:$=>{const C=$!=null&&$.from?va($.from):r,N=$!=null&&$.to?va($.to):"";a({startDate:C,endDate:N})},numberOfMonths:c,hideNavigation:!0,disabled:h?{before:h}:void 0,showOutsideDays:!1,components:{MonthCaption:Hl},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:$=>Dl(new Intl.DateTimeFormat("es-MX",{month:"long",year:"numeric"}).format($)),formatWeekdayName:$=>new Intl.DateTimeFormat("es-MX",{weekday:"short"}).format($)},labels:{labelMonthDropdown:()=>"Mes",labelYearDropdown:()=>"Año"}})}),u&&r&&e.jsxs("div",{style:{marginTop:8,fontSize:12,color:"var(--text-muted)",display:"flex",gap:8,flexWrap:"wrap"},children:[e.jsxs("span",{children:[b,":"," ",e.jsx("strong",{style:{color:"var(--text-main)"},children:r})]}),t&&e.jsxs("span",{children:[p,":"," ",e.jsx("strong",{style:{color:"var(--text-main)"},children:t})]})]})]})}const Il="bonsaif-ui:hide-tooltips";function ga(){window.dispatchEvent(new CustomEvent(Il))}function Ol(r){if(r!==void 0)return typeof r=="number"?`${r}px`:r}function Fl({trigger:r,items:t,align:a="end",width:n=220,disabled:s=!1,className:c="",menuClassName:u="",onOpenChange:b}){const[p,m]=l.useState(!1),[h,x]=l.useState(!1),[g,$]=l.useState({}),C=l.useRef(null),N=l.useRef(null),S=l.useCallback(L=>{m(L),b==null||b(L)},[b]),B=l.useCallback(()=>{const L=C.current;if(!L)return;const U=L.getBoundingClientRect(),Q=typeof n=="number"?n:U.width,re=typeof n=="number"?n:Math.max(U.width,180),W=a==="end"?Math.max(8,U.right-re):Math.min(U.left,window.innerWidth-re-8),J=window.innerHeight-U.bottom,R=J<240&&U.top>J?void 0:U.bottom+6,T=R===void 0?window.innerHeight-U.top+6:void 0;$({position:"fixed",zIndex:9999,left:W,top:R,bottom:T,width:Ol(typeof n=="number"?Q:n)})},[a,n]);l.useEffect(()=>x(!0),[]),l.useEffect(()=>{if(!p)return;B();const L=Q=>{var W,J;const re=Q.target;!((W=C.current)!=null&&W.contains(re))&&!((J=N.current)!=null&&J.contains(re))&&S(!1)},U=Q=>{Q.key==="Escape"&&S(!1)};return document.addEventListener("mousedown",L),window.addEventListener("keydown",U),window.addEventListener("resize",B),window.addEventListener("scroll",B,!0),()=>{document.removeEventListener("mousedown",L),window.removeEventListener("keydown",U),window.removeEventListener("resize",B),window.removeEventListener("scroll",B,!0)}},[p,S,B]);const ee=L=>{s||(L.key==="Enter"||L.key===" ")&&(L.preventDefault(),S(!p))},z=l.isValidElement(r)?l.cloneElement(r,{onClick:()=>{s||(ga(),S(!p))}}):r,X=p?e.jsx("div",{ref:N,role:"menu","data-bonsaif-overlay":"true",className:`overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-1 shadow-xl ${u}`,style:g,children:t.map(L=>e.jsxs("div",{children:[L.separatorBefore&&e.jsx("div",{className:"my-1 border-t border-[var(--border)]"}),e.jsxs("button",{type:"button",role:"menuitem",disabled:L.disabled,onClick:()=>{var U;L.disabled||(ga(),(U=L.onSelect)==null||U.call(L),S(!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:L.danger?"var(--danger)":"var(--text-main)"},children:[L.icon&&e.jsx("span",{className:"mt-0.5 shrink-0",children:L.icon}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block truncate text-sm font-medium",children:L.label}),L.description&&e.jsx("span",{className:"block truncate text-xs text-[var(--text-muted)]",children:L.description})]})]})]},L.id))}):null;return e.jsxs("span",{ref:C,role:"button",tabIndex:s?-1:0,"aria-haspopup":"menu","aria-expanded":p,onKeyDown:ee,className:`inline-flex ${s?"pointer-events-none opacity-60":""} ${c}`,children:[z,h&&X?je.createPortal(X,document.body):null]})}const Pl=180,xa="bg-[color-mix(in_srgb,var(--bg-main)_72%,transparent)] backdrop-blur-sm";function zl({open:r,onClose:t,title:a,subtitle:n,leadingIcon:s,confirmLabel:c="Guardar",onConfirm:u,loading:b=!1,confirmDisabled:p=!1,headerActions:m,bodyClassName:h="flex-1 overflow-y-auto px-6 py-5",width:x=440,hasUnsavedChanges:g=!1,unsavedChangesTitle:$="Descartar cambios",unsavedChangesDescription:C="Hay cambios sin guardar. Si cierras el drawer se perderán.",unsavedChangesConfirmLabel:N="Descartar",unsavedChangesCancelLabel:S="Seguir editando",onDiscardChanges:B,disabled:ee=!1,children:z}){const[X,L]=l.useState(!1),[U,Q]=l.useState(!1),[re,W]=l.useState(!1),J=l.useCallback(()=>{Q(!0),requestAnimationFrame(()=>{requestAnimationFrame(()=>W(!0))})},[]),R=l.useCallback(()=>{W(!1),window.setTimeout(()=>Q(!1),Pl)},[]),T=l.useCallback(()=>{if(g){J();return}t()},[g,t,J]),P=l.useCallback(()=>{W(!1),Q(!1),B==null||B(),t()},[t,B]);return l.useEffect(()=>{L(!0)},[]),l.useEffect(()=>(document.body.style.overflow=r?"hidden":"",r||(W(!1),Q(!1)),()=>{document.body.style.overflow=""}),[r]),l.useEffect(()=>{if(!r)return;const V=_=>{if(_.key==="Escape"){if(U){R();return}T()}};return window.addEventListener("keydown",V),()=>window.removeEventListener("keydown",V)},[R,U,r,T]),X?je.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 ${xa}`,onClick:T}),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, ${x}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(Te,{variant:"icon",onClick:T,title:"Cerrar",children:e.jsx(v.HiXMark,{className:"w-5 h-5"})}),s&&e.jsx("div",{className:"flex-shrink-0",children:s}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h3",{className:"text-base font-semibold truncate",style:{color:"var(--text-main)"},children:a}),n&&e.jsx("p",{className:"text-xs truncate",style:{color:"var(--text-muted)"},children:n})]})]}),(m||u)&&e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[m,u&&e.jsxs(e.Fragment,{children:[e.jsx(Te,{variant:"secondary",size:"sm",onClick:T,style:{background:"var(--bg-input)"},children:"Cancelar"}),e.jsx(Te,{variant:"primary",size:"sm",icon:e.jsx($n.FiSave,{className:"w-4 h-4"}),onClick:u,loading:b,disabled:p,title:c})]})]})]}),e.jsx("div",{"data-drawer-scroll":"true",className:h,children:z})]}),ee&&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)"}}),U&&e.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":$,className:"fixed inset-0 z-[1001] flex items-center justify-center p-4",children:[e.jsx("div",{className:`absolute inset-0 ${xa} transition-opacity duration-200 ease-out ${re?"opacity-100":"opacity-0"}`,onClick:R}),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 ${re?"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(Te,{variant:"icon",onClick:R,className:"absolute right-3 top-3 h-7 w-7 hover:opacity-70",style:{color:"var(--text-muted, #6b7f78)"},"aria-label":S,children:e.jsx(v.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(v.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:$}),e.jsx("p",{className:"text-sm",style:{color:"var(--text-muted, #6b7f78)"},children:C}),e.jsxs("div",{className:"mt-6 flex gap-2",children:[e.jsx(Te,{variant:"secondary",onClick:R,className:"flex-1 border",style:{background:"var(--bg-input, #f7faf8)",borderColor:"var(--border, #d8e1dc)",color:"var(--text-main, #0f2f2c)"},children:S}),e.jsx(Te,{variant:"secondary",onClick:P,className:"flex-1 border",style:{background:"var(--warning, #d97706)",borderColor:"transparent",color:"#fff",boxShadow:"0 10px 22px rgba(217, 119, 6, 0.22)"},children:N})]})]})]})]}),document.body):null}const jl=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,_l=/^\+?[0-9\s().-]+$/,Wl=7,ql=15;function _e(r){return r==null||String(r).trim()===""}function ya(r){return typeof r=="number"?r:typeof r=="string"&&r.trim()!==""?Number(r):Number.NaN}function Ct(r){return _e(r)?!1:jl.test(String(r))}function Et(r){if(_e(r))return!1;const t=String(r),a=t.replace(/\D/g,"");return _l.test(t)&&a.length>=Wl&&a.length<=ql}function Ul(r="Este campo es requerido."){return t=>_e(t)?r:void 0}function Vl(r="Ingresa un correo valido."){return t=>_e(t)||Ct(t)?void 0:r}function Kl(r="Ingresa un telefono valido."){return t=>_e(t)||Et(t)?void 0:r}function Gl(r,t){return a=>_e(a)||String(a).length>=r?void 0:t??`Debe tener al menos ${r} caracteres.`}function Yl(r,t){return a=>_e(a)||String(a).length<=r?void 0:t??`Debe tener ${r} caracteres o menos.`}function Xl(r,t){return a=>{if(_e(a))return;const n=ya(a);return Number.isFinite(n)&&n>=r?void 0:t??`Debe ser mayor o igual a ${r}.`}}function Zl(r,t){return a=>{if(_e(a))return;const n=ya(a);return Number.isFinite(n)&&n<=r?void 0:t??`Debe ser menor o igual a ${r}.`}}function Jl(r,t="El formato no es valido."){return a=>_e(a)||r.test(String(a))?void 0:t}function Ql(r,t){const a={};for(const n of Object.keys(t)){const s=t[n];if(!s)continue;const c=Array.isArray(s)?s:[s];for(const u of c){const b=u(r[n],r);if(b){a[n]=b;break}}}return{valid:Object.keys(a).length===0,errors:a}}var wa={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},Na=l.createContext&&l.createContext(wa),Rl=["attr","size","title"];function eo(r,t){if(r==null)return{};var a,n,s=ro(r,t);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(r);for(n=0;n<c.length;n++)a=c[n],t.indexOf(a)===-1&&{}.propertyIsEnumerable.call(r,a)&&(s[a]=r[a])}return s}function ro(r,t){if(r==null)return{};var a={};for(var n in r)if({}.hasOwnProperty.call(r,n)){if(t.indexOf(n)!==-1)continue;a[n]=r[n]}return a}function Vr(){return Vr=Object.assign?Object.assign.bind():function(r){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var n in a)({}).hasOwnProperty.call(a,n)&&(r[n]=a[n])}return r},Vr.apply(null,arguments)}function ka(r,t){var a=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);t&&(n=n.filter(function(s){return Object.getOwnPropertyDescriptor(r,s).enumerable})),a.push.apply(a,n)}return a}function Kr(r){for(var t=1;t<arguments.length;t++){var a=arguments[t]!=null?arguments[t]:{};t%2?ka(Object(a),!0).forEach(function(n){to(r,n,a[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(a)):ka(Object(a)).forEach(function(n){Object.defineProperty(r,n,Object.getOwnPropertyDescriptor(a,n))})}return r}function to(r,t,a){return(t=ao(t))in r?Object.defineProperty(r,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):r[t]=a,r}function ao(r){var t=no(r,"string");return typeof t=="symbol"?t:t+""}function no(r,t){if(typeof r!="object"||!r)return r;var a=r[Symbol.toPrimitive];if(a!==void 0){var n=a.call(r,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(r)}function Sa(r){return r&&r.map((t,a)=>l.createElement(t.tag,Kr({key:a},t.attr),Sa(t.child)))}function Mt(r){return t=>l.createElement(lo,Vr({attr:Kr({},r.attr)},t),Sa(r.child))}function lo(r){var t=a=>{var{attr:n,size:s,title:c}=r,u=eo(r,Rl),b=s||a.size||"1em",p;return a.className&&(p=a.className),r.className&&(p=(p?p+" ":"")+r.className),l.createElement("svg",Vr({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},a.attr,n,u,{className:p,style:Kr(Kr({color:r.color||a.color},a.style),r.style),height:b,width:b,xmlns:"http://www.w3.org/2000/svg"}),c&&l.createElement("title",null,c),r.children)};return Na!==void 0?l.createElement(Na.Consumer,null,a=>t(a)):t(wa)}function Ca(r){return Mt({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 oo(r){return Mt({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 so(r){return Mt({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 Gr({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 $t({label:r,containerClassName:t="",helperText:a,error:n,errorDisplay:s="inline",errorTooltipLabel:c="Error de validacion",labelAction:u,floatingLabel:b=!1,showPasswordToggle:p=!0,nativeValidation:m=!1,className:h="",required:x,...g}){const[$,C]=l.useState(()=>!!g.autoFocus),[N,S]=l.useState(!1),B=g.type==="password"&&p,ee=B&&N?"text":g.type,z=!!n,X=z&&s!=="tooltip",L=z&&s!=="inline",U=m?x:void 0,Q=z?"border-[var(--danger)] focus:border-[var(--danger)]":"",re=L?B?"pr-20":"pr-10":B?"pr-10":"",W=g.value!==void 0?String(g.value).length>0:g.defaultValue!==void 0&&String(g.defaultValue).length>0,J=$||W,R={top:J?7:12,color:$?"var(--primary)":"var(--text-muted)",fontSize:J?10:13,fontWeight:J?600:400,textTransform:J?"uppercase":"none"},T=le=>{var q;C(!0),(q=g.onFocus)==null||q.call(g,le)},P=le=>{var q;C(!1),(q=g.onBlur)==null||q.call(g,le)},V=B?e.jsxs("button",{type:"button","aria-label":N?"Ocultar contraseña":"Mostrar contraseña","aria-pressed":N,className:"absolute right-2.5 top-1/2 flex h-7 w-7 -translate-y-1/2 items-center justify-center rounded-md text-[var(--text-muted)] transition-colors duration-200 hover:text-[var(--primary)] focus:outline-none",tabIndex:-1,onClick:()=>S(le=>!le),children:[e.jsx("span",{"aria-hidden":"true",className:`absolute inset-0 flex items-center justify-center transition-[opacity,transform] duration-200 ease-out ${N?"scale-y-0 rotate-[-8deg] opacity-0":"scale-y-100 rotate-0 opacity-100"}`,children:e.jsx(oo,{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 ${N?"scale-y-100 rotate-0 opacity-100":"scale-y-0 rotate-[8deg] opacity-0"}`,children:e.jsx(so,{className:"h-[18px] w-[18px]"})})]}):null,_=L?e.jsx(dr,{as:"span",content:n,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)] ${B?"right-10":"right-2.5"}`,children:e.jsx("span",{tabIndex:0,role:"img","aria-label":c,className:"flex h-full w-full items-center justify-center outline-none",children:e.jsx(Ca,{className:"h-[18px] w-[18px]"})})}):null;return b?e.jsxs("label",{className:`flex flex-col gap-2 ${t}`,children:[e.jsxs("span",{className:"relative block",children:[e.jsx(Gr,{...g,type:ee,required:U,placeholder:" ","aria-invalid":z||g["aria-invalid"],"data-has-value":W?"true":void 0,className:`h-11 w-full pt-5 ${re} ${Q} ${h}`,onFocus:T,onBlur:P}),e.jsxs("span",{className:"pointer-events-none absolute left-3 transition-all duration-150",style:R,children:[r,x&&e.jsx("span",{className:"ml-1 text-[var(--danger)]",children:"*"})]}),u&&e.jsx("span",{className:"absolute right-2 transition-all duration-150",style:{top:J?7:12},children:u}),_,V]}),X?e.jsx("span",{className:"text-xs font-medium normal-case text-[var(--danger)]",children:n}):a?e.jsx("span",{className:"text-xs font-medium normal-case text-[var(--text-muted)]",children:a}):null]}):e.jsxs("label",{className:`flex flex-col gap-2 ${t}`,children:[e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-semibold uppercase text-[var(--text-muted)]",children:[e.jsx("span",{children:r}),x&&e.jsx("span",{className:"text-[var(--danger)]",children:"*"}),u&&e.jsx("span",{className:"ml-auto normal-case",children:u})]}),B?e.jsxs("span",{className:"relative block",children:[e.jsx(Gr,{...g,type:ee,required:U,"aria-invalid":z||g["aria-invalid"],className:`w-full ${re} ${Q} ${h}`,onFocus:T,onBlur:P}),_,V]}):e.jsxs("span",{className:"relative block",children:[e.jsx(Gr,{...g,required:U,"aria-invalid":z||g["aria-invalid"],className:`w-full ${re} ${Q} ${h}`}),_]}),X?e.jsx("span",{className:"text-xs font-medium normal-case text-[var(--danger)]",children:n}):a?e.jsx("span",{className:"text-xs font-medium normal-case text-[var(--text-muted)]",children:a}):null]})}function Ea(r){return r==null?"":String(r)}function io({autoComplete:r="email",inputMode:t="email",validate:a=!0,invalidMessage:n="Ingresa un correo valido.",errorDisplay:s="tooltip",error:c,value:u,defaultValue:b,onChange:p,...m}){const[h,x]=l.useState(()=>Ea(b)),g=u!==void 0?Ea(u):h,$=a&&g.length>0&&!Ct(g)?n:void 0,C=N=>{u===void 0&&x(N.currentTarget.value),p==null||p(N)};return e.jsx($t,{...m,value:u,defaultValue:b,type:"text",inputMode:t,autoComplete:r,error:c??$,errorDisplay:s,onChange:C})}const co={sm:"min-h-[160px] p-4",md:"min-h-[220px] p-6",lg:"min-h-[300px] p-8"};function uo({title:r="Sin resultados",description:t,icon:a=e.jsx(v.HiInbox,{className:"h-5 w-5"}),action:n,secondaryAction:s,size:c="md",className:u=""}){return e.jsx("div",{className:`flex items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-card)] text-center ${co[c]} ${u}`,children:e.jsxs("div",{className:"flex max-w-sm flex-col items-center gap-3",children:[a&&e.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-input)] text-[var(--text-muted)]",children:a}),e.jsxs("div",{className:"space-y-1",children:[r&&e.jsx("h3",{className:"text-sm font-semibold text-[var(--text-main)]",children:r}),t&&e.jsx("div",{className:"text-sm leading-5 text-[var(--text-muted)]",children:t})]}),(n||s)&&e.jsxs("div",{className:"mt-1 flex flex-wrap items-center justify-center gap-2",children:[s,n]})]})})}const bo={sm:"min-h-[112px] p-4",md:"min-h-[148px] p-5",lg:"min-h-[184px] p-6"};function fo(r){if(r===0)return"0 B";const t=["B","KB","MB","GB"],a=Math.min(Math.floor(Math.log(r)/Math.log(1024)),t.length-1),n=r/1024**a;return`${n>=10||a===0?n.toFixed(0):n.toFixed(1)} ${t[a]}`}function Ma(r,t){return t?t.split(",").map(a=>a.trim().toLowerCase()).filter(Boolean).some(a=>{const n=r.name.toLowerCase(),s=r.type.toLowerCase();return a.startsWith(".")?n.endsWith(a):a.endsWith("/*")?s.startsWith(a.slice(0,-1)):s===a}):!0}function po(r,t,a){return t?a===void 0?r:r.slice(0,Math.max(0,a)):r.slice(0,1)}function mo({label:r,helperText:t,error:a,labelAction:n,value:s,defaultValue:c=[],onFilesChange:u,onRejectedFiles:b,multiple:p=!1,maxFiles:m,appendFiles:h=!1,showFileList:x=!0,clearable:g=!0,browseLabel:$="Buscar archivos",dropLabel:C="Suelta los archivos aqui",emptyLabel:N="Arrastra y suelta archivos",emptyDescription:S="o haz click para buscarlos en tu equipo",selectedLabel:B="Archivos seleccionados",size:ee="md",containerClassName:z="",dropzoneClassName:X="",fileListClassName:L="",className:U="",id:Q,accept:re,disabled:W,required:J,...R}){const T=l.useId(),P=Q??T,V=l.useRef(null),[_,le]=l.useState(!1),[q,i]=l.useState(c),y=s??q,M=!!a,O=g&&y.length>0&&!W,D=(te,ue)=>{s===void 0&&i(te),u==null||u(te,ue)},ae=(te,ue)=>{const se=te.filter(be=>Ma(be,re)),w=te.filter(be=>!Ma(be,re)),I=h?[...y,...se]:se,de=po(I,p,m);w.length>0&&(b==null||b(w)),D(de,ue)},ie=()=>{var te;W||(te=V.current)==null||te.click()},pe=te=>{ae(Array.from(te.target.files??[]),te),te.target.value=""},A=te=>{te.preventDefault(),W||le(!0)},oe=te=>{te.currentTarget.contains(te.relatedTarget)||le(!1)},F=te=>{te.preventDefault(),le(!1),!W&&ae(Array.from(te.dataTransfer.files),te)},H=te=>{te.key!=="Enter"&&te.key!==" "||(te.preventDefault(),ie())},Z=te=>{D(y.filter((ue,se)=>se!==te))},G=()=>{D([])};return e.jsxs("div",{className:`flex flex-col gap-2 ${z}`,children:[(r||n)&&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:"*"}),n&&e.jsx("span",{className:"ml-auto normal-case",children:n})]}),e.jsx("input",{...R,ref:V,id:P,type:"file",accept:re,multiple:p,disabled:W,required:J&&y.length===0,"aria-invalid":M||R["aria-invalid"],className:"sr-only",onChange:pe}),e.jsxs("div",{role:"button",tabIndex:W?-1:0,"aria-controls":P,"aria-disabled":W||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)] ${bo[ee]} ${_?"border-[var(--primary)] bg-[var(--bg-input)]":M?"border-[var(--danger)]":"border-[var(--border)]"} ${W?"cursor-not-allowed opacity-60":"hover:border-[var(--primary)] hover:bg-[var(--bg-input)]"} ${X} ${U}`,onClick:ie,onDragOver:A,onDragLeave:oe,onDrop:F,onKeyDown:H,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(v.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:_?C:N}),S&&e.jsx("span",{className:"block text-sm text-[var(--text-muted)]",children:S})]}),$&&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:$})]}),x&&y.length>0&&e.jsxs("div",{className:`rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${L}`,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:B}),O&&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:G,children:e.jsx(v.HiTrash,{className:"h-4 w-4"})})]}),e.jsx("ul",{className:"divide-y divide-[var(--border)]",children:y.map((te,ue)=>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(v.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:te.name}),e.jsx("span",{className:"block text-xs text-[var(--text-muted)]",children:fo(te.size)})]}),!W&&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 ${te.name}`,onClick:()=>Z(ue),children:e.jsx(v.HiXMark,{className:"h-4 w-4"})})]},`${te.name}-${te.lastModified}-${ue}`))})]}),a?e.jsx("span",{className:"text-xs font-medium normal-case text-[var(--danger)]",children:a}):t?e.jsx("span",{className:"text-xs font-medium normal-case text-[var(--text-muted)]",children:t}):null]})}const ho=[{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 vo({fields:r,title:t="Layout",fieldTypes:a=ho,saveLabel:n="Guardar",allowAddField:s=!1,addFieldPlaceholder:c="Nuevo campo",addFieldLabel:u="Anadir",loading:b=!1,onSave:p,onChange:m}){const[h,x]=l.useState(()=>r.map(z=>({key:!1,type:"",...z}))),[g,$]=l.useState(""),[C,N]=l.useState(""),S=l.useCallback((z,X)=>{x(L=>{const U=L.map((Q,re)=>re===z?{...Q,...X}:Q);return m==null||m(U),U})},[m]),B=l.useCallback(()=>{p==null||p(h)},[h,p]),ee=l.useCallback(()=>{var U;const z=g.trim();if(!z){N("Ingresa un nombre de campo.");return}if(h.some(Q=>Q.name.toLowerCase()===z.toLowerCase())){N("Ese campo ya existe en el arreglo.");return}const L={name:z,key:!1,type:((U=a[0])==null?void 0:U.value)??""};x(Q=>{const re=[...Q,L];return m==null||m(re),re}),$(""),N("")},[a,h,g,m]);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:[h.map((z,X)=>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:z.name}),e.jsx("div",{className:"flex justify-center",children:e.jsx(Fr,{size:"sm",checked:z.key??!1,onChange:L=>S(X,{key:L.target.checked}),"aria-label":`${z.name} es clave`})}),e.jsx(rr,{value:z.type??"",onChange:L=>S(X,{type:L}),options:a,placeholder:"—",emptyLabel:"—",height:36,searchable:!1,ariaLabel:`Tipo de ${z.name}`})]},z.name)),h.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:g,onChange:z=>{$(z.currentTarget.value),C&&N("")},onKeyDown:z=>{z.key==="Enter"&&(z.preventDefault(),ee())},placeholder:c,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(Te,{variant:"secondary",onClick:ee,height:36,padding:"0 12px",children:u})]}),C&&e.jsx("p",{className:"text-xs",style:{color:"var(--danger)"},children:C})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(Te,{variant:"primary",onClick:B,disabled:b,loading:b,children:n})})]})})]})}function $a({label:r,children:t,helperText:a,error:n,labelAction:s,required:c=!1,className:u="",contentClassName:b=""}){return e.jsxs("label",{className:`flex flex-col gap-2 ${u}`,children:[(r||s)&&e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-semibold uppercase text-[var(--text-muted)]",children:[r&&e.jsx("span",{children:r}),c&&e.jsx("span",{className:"text-[var(--danger)]",children:"*"}),s&&e.jsx("span",{className:"ml-auto normal-case",children:s})]}),e.jsx("span",{className:`block ${b}`,children:t}),n?e.jsx("span",{className:"text-xs font-medium normal-case text-[var(--danger)]",children:n}):a?e.jsx("span",{className:"text-xs font-medium normal-case text-[var(--text-muted)]",children:a}):null]})}function La(r){if(r!==void 0)return typeof r=="number"?`${r}px`:r}function go(r,t){return r.length!==t.length?!1:r.every((a,n)=>a===t[n])}function xo({value:r,onChange:t,options:a,placeholder:n="Seleccionar…",disabled:s=!1,className:c="",style:u,height:b=40,padding:p="6px 10px",searchable:m=!0,minOptionsForSearch:h=6,maxVisibleValues:x=2,truncateSelectedValues:g=!0,emptyText:$="Sin resultados",clearLabel:C="Limpiar seleccion"}){const[N,S]=l.useState(!1),[B,ee]=l.useState(""),[z,X]=l.useState(0),[L,U]=l.useState(!1),[Q,re]=l.useState({}),W=l.useRef(null),J=l.useRef(null),R=l.useRef(null),T=l.useRef(null),P=m&&a.length>=h,V=l.useMemo(()=>new Set(r),[r]),_=l.useMemo(()=>a.filter(A=>V.has(A.value)),[a,V]),le=x==="all"?_.length:x,q=_.slice(0,le),i=Math.max(0,_.length-q.length),y=P&&B.trim()?a.filter(A=>{var oe;return A.label.toLowerCase().includes(B.toLowerCase())||((oe=A.sublabel)==null?void 0:oe.toLowerCase().includes(B.toLowerCase()))}):a,M=l.useCallback(()=>{const A=W.current;if(!A)return;const oe=A.getBoundingClientRect(),F=P?304:244,H=window.innerHeight-oe.bottom,Z=H<F&&oe.top>H;re({position:"fixed",left:oe.left,top:Z?void 0:oe.bottom+4,bottom:Z?window.innerHeight-oe.top+4:void 0,width:oe.width,zIndex:9999})},[P]),O=l.useCallback(A=>{go(r,A)||t(A)},[t,r]),D=l.useCallback(A=>{const oe=a.find(H=>H.value===A);if(oe!=null&&oe.disabled)return;const F=V.has(A)?r.filter(H=>H!==A):[...r,A];O(F)},[O,a,r,V]),ae=l.useCallback(()=>O([]),[O]);l.useEffect(()=>U(!0),[]),l.useEffect(()=>{if(!N)return;function A(oe){var H,Z;const F=oe.target;!((H=W.current)!=null&&H.contains(F))&&!((Z=J.current)!=null&&Z.contains(F))&&(S(!1),ee(""))}return document.addEventListener("mousedown",A),()=>document.removeEventListener("mousedown",A)},[N]),l.useEffect(()=>{N&&(X(0),M(),P&&setTimeout(()=>{var A;return(A=R.current)==null?void 0:A.focus()},0))},[N,P,M]),l.useEffect(()=>{if(N)return window.addEventListener("resize",M),window.addEventListener("scroll",M,!0),()=>{window.removeEventListener("resize",M),window.removeEventListener("scroll",M,!0)}},[N,M]),l.useEffect(()=>{if(z<0||!T.current)return;const A=T.current.children[z];A==null||A.scrollIntoView({block:"nearest"})},[z]);function ie(A){if(!N){(A.key==="Enter"||A.key===" "||A.key==="ArrowDown")&&(A.preventDefault(),S(!0));return}A.key==="Escape"&&(A.preventDefault(),S(!1),ee("")),A.key==="ArrowDown"&&(A.preventDefault(),X(oe=>Math.min(oe+1,y.length-1))),A.key==="ArrowUp"&&(A.preventDefault(),X(oe=>Math.max(oe-1,0))),A.key==="Enter"&&y[z]&&(A.preventDefault(),D(y[z].value)),A.key==="Backspace"&&!B&&r.length&&(A.preventDefault(),O(r.slice(0,-1)))}const pe=e.jsxs("div",{ref:J,className:"overflow-hidden rounded-xl shadow-xl",style:{...Q,background:"var(--bg-card)",border:"1px solid var(--border)"},children:[P&&e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",style:{borderBottom:"1px solid var(--border)"},children:[e.jsx(v.HiMagnifyingGlass,{className:"h-3.5 w-3.5 flex-shrink-0",style:{color:"var(--text-muted)"}}),e.jsx("input",{ref:R,value:B,onChange:A=>{ee(A.target.value),X(0)},placeholder:"Buscar…",className:"min-w-0 flex-1 bg-transparent text-sm outline-none",style:{color:"var(--text-main)"}}),B&&e.jsx("button",{type:"button",onMouseDown:A=>{A.preventDefault(),ee("")},children:e.jsx(v.HiXMark,{className:"h-3.5 w-3.5",style:{color:"var(--text-muted)"}})})]}),_.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:[_.length," seleccionados"]}),e.jsx("button",{type:"button",onMouseDown:A=>{A.preventDefault(),ae()},className:"font-semibold transition-colors hover:text-[var(--primary)]",children:C})]}),e.jsxs("ul",{ref:T,role:"listbox","aria-multiselectable":"true",className:"overflow-y-auto",style:{maxHeight:P?220:200,scrollbarWidth:"thin",scrollbarColor:"var(--border) transparent",overscrollBehavior:"contain"},children:[y.map((A,oe)=>{const F=oe===z,H=V.has(A.value);return e.jsxs("li",{role:"option","aria-selected":H,onMouseDown:Z=>{Z.preventDefault(),D(A.value)},onMouseEnter:()=>!A.disabled&&X(oe),className:"flex cursor-pointer items-center gap-2 px-3 py-2 text-sm transition-colors",style:{background:F?"var(--bg-hover)":H?"color-mix(in srgb, var(--primary) 6%, transparent)":"transparent",color:A.disabled?"var(--text-muted)":"var(--text-main)",cursor:A.disabled?"not-allowed":"pointer",opacity:A.disabled?.58:1},children:[e.jsx("span",{className:"flex h-4 w-4 flex-shrink-0 items-center justify-center rounded border",style:{borderColor:H?"var(--primary)":"var(--border)",background:H?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:H&&e.jsx(v.HiCheck,{className:"h-3 w-3"})}),A.color&&e.jsx("span",{className:"h-2.5 w-2.5 flex-shrink-0 rounded-full",style:{background:A.color}}),e.jsxs("span",{className:"flex min-w-0 flex-1 items-baseline gap-1 overflow-hidden",children:[e.jsx("span",{className:"truncate",children:A.label}),A.sublabel&&e.jsx("span",{className:"min-w-0 flex-shrink truncate",style:{color:"var(--text-muted)",fontSize:12},children:A.sublabel})]}),A.badge&&e.jsx("span",{className:"flex-shrink-0 text-xs",style:{color:"var(--text-muted)"},children:A.badge})]},A.value)}),y.length===0&&e.jsx("li",{className:"px-3 py-4 text-center text-sm",style:{color:"var(--text-muted)"},children:$})]})]});return e.jsxs("div",{ref:W,className:`relative ${c||"w-full"}`,style:u,onKeyDown:ie,children:[e.jsxs("button",{type:"button",disabled:s,onClick:()=>!s&&S(A=>!A),className:"flex w-full items-center gap-2 rounded-lg text-left text-sm transition-colors focus:outline-none",style:{minHeight:La(b),padding:La(p),background:"var(--bg-input)",color:_.length?"var(--text-main)":"var(--text-muted)",border:N?"1px solid var(--primary)":"1px solid var(--border)",opacity:s?.5:1,cursor:s?"not-allowed":"pointer"},"aria-haspopup":"listbox","aria-expanded":N,children:[e.jsx("span",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-1.5 overflow-hidden",children:q.length?e.jsxs(e.Fragment,{children:[q.map(A=>e.jsxs("span",{className:`inline-flex items-center gap-1 rounded-md border px-1.5 py-0.5 text-xs font-semibold ${g?"max-w-[160px]":"max-w-full whitespace-normal"}`,style:{background:"var(--bg-card)",borderColor:"var(--border)",color:"var(--text-main)"},children:[A.color&&e.jsx("span",{className:"h-1.5 w-1.5 flex-shrink-0 rounded-full",style:{background:A.color}}),e.jsx("span",{className:g?"truncate":"break-words",children:A.label})]},A.value)),i>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:["+",i]})]}):e.jsx("span",{className:"truncate",children:n})}),_.length?e.jsx("span",{role:"button",tabIndex:-1,"aria-label":C,onMouseDown:A=>{A.preventDefault(),A.stopPropagation(),ae()},className:"flex-shrink-0 rounded-full p-0.5 transition-colors hover:bg-black/10",style:{color:"var(--text-muted)"},children:e.jsx(v.HiXMark,{className:"h-3 w-3"})}):e.jsx(v.HiChevronDown,{className:"h-4 w-4 flex-shrink-0 transition-transform",style:{color:"var(--text-muted)",transform:N?"rotate(180deg)":"rotate(0deg)"}})]}),N&&L&&je.createPortal(pe,document.body)]})}function yo({inputMode:r="decimal",...t}){return e.jsx($t,{...t,type:"number",inputMode:r})}function wo(r,t,a){const n=[],s=Math.max(2,r-a),c=Math.min(t-1,r+a);n.push(1),s>2&&n.push("...");for(let u=s;u<=c;u+=1)n.push(u);return c<t-1&&n.push("..."),t>1&&n.push(t),n}function No({page:r,totalPages:t,onPageChange:a,disabled:n=!1,siblingCount:s=1,className:c=""}){const u=Math.max(1,t),b=Math.min(Math.max(1,r),u),p=wo(b,u,s);return e.jsxs("nav",{"aria-label":"Paginacion",className:`inline-flex items-center gap-1 ${c}`,children:[e.jsx(Te,{variant:"icon",size:"xs","aria-label":"Pagina anterior",disabled:n||b<=1,onClick:()=>a(b-1),children:e.jsx(v.HiChevronLeft,{className:"h-4 w-4"})}),p.map((m,h)=>m==="..."?e.jsx("span",{className:"flex h-8 min-w-8 items-center justify-center text-xs font-semibold text-[var(--text-muted)]",children:"..."},`ellipsis-${h}`):e.jsx("button",{type:"button","aria-current":m===b?"page":void 0,disabled:n,onClick:()=>a(m),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:m===b?"var(--primary)":"var(--border)",background:m===b?"var(--primary)":"var(--bg-card)",color:m===b?"var(--primary-fg)":"var(--text-secondary)"},children:m},m)),e.jsx(Te,{variant:"icon",size:"xs","aria-label":"Pagina siguiente",disabled:n||b>=u,onClick:()=>a(b+1),children:e.jsx(v.HiChevronRight,{className:"h-4 w-4"})})]})}const Ta=[{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 Aa(r){return r==null?"":String(r)}function Yr(r){return r?r.startsWith("+")?r:`+${r}`:"+1"}function ko(r){return typeof r=="number"?`${r}px`:r}function So({autoComplete:r="tel",inputMode:t="tel",validate:a=!0,invalidMessage:n="Ingresa un telefono valido.",errorDisplay:s="tooltip",error:c,value:u,defaultValue:b,onChange:p,countryCode:m,defaultCountryCode:h="+1",onCountryCodeChange:x,allowedCountryCodes:g,countryCodeOptions:$,countryCodePlaceholder:C="Codigo",countryCodeClassName:N="",countryCodeWidth:S=84,onPhoneValueChange:B,label:ee,containerClassName:z="",helperText:X,labelAction:L,className:U="",required:Q,disabled:re,floatingLabel:W,showPasswordToggle:J,nativeValidation:R,errorTooltipLabel:T="Error de validacion",...P}){var te;const[V,_]=l.useState(()=>Aa(b)),[le,q]=l.useState(()=>Yr(h)),i=l.useMemo(()=>{const ue=$??Ta,se=g==null?void 0:g.map(Yr);return se!=null&&se.length?ue.filter(w=>se.includes(w.value)):ue},[g,$]),y=((te=i[0])==null?void 0:te.value)??"+1",M=i.some(ue=>ue.value===Yr(m??le))?Yr(m??le):y,O=u!==void 0?Aa(u):V,D=`${M} ${O}`.trim(),ae=a&&O.length>0&&!Et(D)?n:void 0,ie=c??ae,pe=!!ie,A=pe&&s!=="tooltip",oe=pe&&s!=="inline",F=pe?"border-[var(--danger)] focus-within:border-[var(--danger)]":"border-[var(--border)] focus-within:border-[var(--primary)]",H=ue=>{const se=ue.currentTarget.value;u===void 0&&_(se),B==null||B(se,{countryCode:M,nationalNumber:se,fullNumber:`${M} ${se}`.trim()}),p==null||p(ue)},Z=ue=>{m===void 0&&q(ue),x==null||x(ue),B==null||B(O,{countryCode:ue,nationalNumber:O,fullNumber:`${ue} ${O}`.trim()})},G=oe?e.jsx(dr,{as:"span",content:ie,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":T,className:"flex h-full w-full items-center justify-center outline-none",children:e.jsx(Ca,{className:"h-[18px] w-[18px]"})})}):null;return e.jsxs("div",{className:`flex flex-col gap-2 ${z}`,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:ee}),Q&&e.jsx("span",{className:"text-[var(--danger)]",children:"*"}),L&&e.jsx("span",{className:"ml-auto normal-case",children:L})]}),e.jsxs("span",{className:`flex h-10 min-w-0 items-center overflow-hidden rounded-lg border bg-[var(--bg-input)] transition-colors ${F}`,children:[e.jsx(rr,{value:M,onChange:Z,options:i,placeholder:C,disabled:re,ariaLabel:"Codigo telefonico",triggerVariant:"ghost",showSelectedSublabel:!1,searchable:!0,minOptionsForSearch:0,dropdownMinWidth:300,className:`shrink-0 ${N}`,style:{width:ko(S)},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",{...P,value:u,defaultValue:b,type:"tel",inputMode:t,autoComplete:r,disabled:re,required:void 0,"aria-label":P["aria-label"]??(typeof ee=="string"?ee:void 0),"aria-invalid":pe||P["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 ${oe?"pr-10":""} ${U}`,onChange:H}),G]})]}),A?e.jsx("span",{className:"text-xs font-medium normal-case text-[var(--danger)]",children:ie}):X?e.jsx("span",{className:"text-xs font-medium normal-case text-[var(--text-muted)]",children:X}):null]})}function Co({value:r,onChange:t,options:a,name:n,label:s,orientation:c="vertical",disabled:u=!1,className:b="",optionClassName:p=""}){return e.jsxs("fieldset",{className:`min-w-0 ${b}`,disabled:u,children:[s&&e.jsx("legend",{className:"mb-2 text-xs font-semibold uppercase text-[var(--text-muted)]",children:s}),e.jsx("div",{className:c==="horizontal"?"flex flex-wrap gap-2":"flex flex-col gap-2",children:a.map(m=>{const h=m.value===r,x=u||m.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 ${x?"cursor-not-allowed opacity-60":"cursor-pointer hover:bg-[var(--bg-input)]"} ${p}`,style:{borderColor:h?"color-mix(in srgb, var(--primary) 48%, var(--border))":"var(--border)",background:h?"color-mix(in srgb, var(--primary) 8%, transparent)":"var(--bg-card)"},children:[e.jsxs("span",{className:"relative mt-0.5 inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-full border border-[var(--border)] bg-[var(--bg-input)]",children:[e.jsx("input",{type:"radio",name:n,value:m.value,checked:h,disabled:x,onChange:()=>t(m.value),className:"absolute inset-0 opacity-0"}),e.jsx("span",{className:`h-2 w-2 rounded-full transition ${h?"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:m.label}),m.description&&e.jsx("span",{className:"block text-xs leading-5 text-[var(--text-muted)]",children:m.description})]})]},m.value)})})]})}const Ha=()=>'<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>',Xr=r=>r.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'"),Da=r=>r.toLocaleLowerCase().replace(new RegExp("(^|[^\\p{L}\\p{N}])(\\p{L})","gu"),(t,a,n)=>`${a}${n.toLocaleUpperCase()}`),Eo=r=>r.replace(/[<>]/g,"").toLowerCase(),Mo=r=>new RegExp("\\p{L}","u").test(r),Lt=(r,t)=>{const a=r.trim();return!a||!Mo(a)?!1:t==="uppercase"?a===a.toLocaleUpperCase():t==="lowercase"?a===a.toLocaleLowerCase():a===Da(a)},Ba=r=>{const t=n=>{var s,c;if(!n.closest(".rich-img-wrap")){const u=document.createElement("span");u.className="rich-img-wrap",u.contentEditable="false",(s=n.parentNode)==null||s.insertBefore(u,n),u.appendChild(n),u.insertAdjacentHTML("beforeend",Ha())}(c=n.closest(".rich-img-wrap"))==null||c.classList.add("rich-img-broken")};r.querySelectorAll("img").forEach(n=>{if(!n.complete||n.naturalWidth===0){n.addEventListener("error",()=>t(n),{once:!0}),n.addEventListener("load",()=>{n.naturalWidth===0&&t(n)},{once:!0});const s=n.src;n.src="",n.src=s}});const a=n=>{const s=n.target;s.tagName==="IMG"&&t(s)};return r.addEventListener("error",a,!0),()=>r.removeEventListener("error",a,!0)};function $o({value:r,onChange:t,placeholder:a="Escribe algo...",minHeight:n="80px"}){const s=l.useRef(null),c=l.useRef(null),u=l.useRef(null),b=l.useRef(!1),p=l.useRef(r??""),m=l.useRef(t),[h,x]=l.useState(()=>!r||r.trim()===""),[g,$]=l.useState(new Set),[C,N]=l.useState(null),[S,B]=l.useState(""),[ee,z]=l.useState(""),[X,L]=l.useState(""),[U,Q]=l.useState(""),[re,W]=l.useState(!1),J=l.useCallback(()=>b.current?c.current:s.current,[]);l.useEffect(()=>{m.current=t},[t]);const R=l.useCallback(()=>{const w=window.getSelection(),I=J();if(!w||!I||w.rangeCount===0||w.isCollapsed)return"";const de=w.getRangeAt(0);return!I.contains(de.startContainer)||!I.contains(de.endContainer)?"":w.toString()},[J]);l.useEffect(()=>{const w=r??"";p.current=w;const I=[s.current,c.current].filter(be=>!!be);I.forEach(be=>{be.innerHTML!==w&&(be.innerHTML=w)}),x(!w||w.trim()==="");const de=I.map(be=>Ba(be));return()=>de.forEach(be=>be())},[r]),l.useEffect(()=>{var be,ke;b.current=re;let w,I=0,de;if(re){const me=s.current;me&&(p.current=me.innerHTML);const Se=()=>{var fe;const we=c.current;if(!we){I=requestAnimationFrame(Se);return}we.innerHTML!==p.current&&(we.innerHTML=p.current),w=Ba(we),x(((fe=we.textContent)==null?void 0:fe.trim())===""),de=setTimeout(()=>we.focus(),60)};I=requestAnimationFrame(Se)}else{const me=c.current,Se=s.current,we=(me==null?void 0:me.innerHTML)??p.current,fe=p.current;p.current=we,Se&&Se.innerHTML!==we&&(Se.innerHTML=we),we!==fe&&m.current(we),x(((ke=(be=me??Se)==null?void 0:be.textContent)==null?void 0:ke.trim())==="")}return()=>{I&&cancelAnimationFrame(I),de&&clearTimeout(de),w==null||w()}},[re]);const T=l.useCallback(()=>{const w=["bold","italic","underline","strikeThrough","insertUnorderedList","insertOrderedList","justifyLeft","justifyCenter","justifyRight","justifyFull"],I=new Set;w.forEach(be=>{try{document.queryCommandState(be)&&I.add(be)}catch{return}});try{const be=Eo(document.queryCommandValue("formatBlock"));be&&I.add(`formatBlock:${be}`)}catch{return}const de=R();Lt(de,"uppercase")&&I.add("__upper"),Lt(de,"lowercase")&&I.add("__lower"),Lt(de,"capitalize")&&I.add("__cap"),$(I)},[R]),P=()=>{var I;const w=J();w&&(p.current=w.innerHTML,m.current(p.current),x(((I=w.textContent)==null?void 0:I.trim())===""))},V=w=>{if(!w){const I=s.current;I&&(p.current=I.innerHTML)}W(!w)},_=(w,I)=>{var de;(de=J())==null||de.focus(),document.execCommand(w,!1,I),P(),T()},le=w=>{_("formatBlock",w)},q=()=>{var w;(w=J())==null||w.focus(),document.execCommand("insertHTML",!1,"<hr><p><br></p>"),P(),T()},i=()=>{const w=window.getSelection();w&&w.rangeCount>0&&(u.current=w.getRangeAt(0).cloneRange())},y=()=>{const w=window.getSelection();w&&u.current&&(w.removeAllRanges(),w.addRange(u.current))},M=w=>{if(i(),w==="link"){const I=window.getSelection();z(I&&!I.isCollapsed?I.toString():""),B("")}w==="image"&&(L(""),Q("")),N(w)},O=()=>{var be;if(!S.trim())return;y(),(be=J())==null||be.focus();const w=window.getSelection(),de=(w&&!w.isCollapsed?w.toString():"")||ee.trim()||S.trim();document.execCommand("insertHTML",!1,`<a href="${Xr(S.trim())}" target="_blank" rel="noopener noreferrer" class="rich-link">${Xr(de)}</a>`),P(),N(null)},D=(w,I="")=>`<span class="rich-img-wrap" contenteditable="false"><img src="${Xr(w)}" alt="${Xr(I)}" class="rich-img" />${Ha()}</span>`,ae=()=>{var w;X.trim()&&(y(),(w=J())==null||w.focus(),document.execCommand("insertHTML",!1,D(X.trim(),U.trim())),P(),N(null))},ie=(w,I=1200,de=1200,be=.72)=>new Promise((ke,me)=>{const Se=new FileReader;Se.onerror=me,Se.onload=we=>{var Ge;const fe=(Ge=we.target)==null?void 0:Ge.result,Be=new Image;Be.onerror=me,Be.onload=()=>{let{width:ze,height:ne}=Be;if(ze>I||ne>de){const Oe=Math.min(I/ze,de/ne);ze=Math.round(ze*Oe),ne=Math.round(ne*Oe)}const Me=document.createElement("canvas");Me.width=ze,Me.height=ne;const $e=Me.getContext("2d");if(!$e){ke(fe);return}$e.drawImage(Be,0,0,ze,ne),ke(Me.toDataURL("image/jpeg",be))},Be.src=fe},Se.readAsDataURL(w)}),pe=w=>{const de=Array.from(w.clipboardData.items).find(ke=>ke.type.startsWith("image/"));if(!de)return;w.preventDefault();const be=de.getAsFile();be&&ie(be).then(ke=>{var me;(me=J())==null||me.focus(),document.execCommand("insertHTML",!1,D(ke,"imagen")),P()})},A=w=>{const I=window.getSelection(),de=J();if(!I||!de||I.rangeCount===0||I.isCollapsed)return;const be=I.getRangeAt(0);if(!de.contains(be.startContainer)||!de.contains(be.endContainer))return;const ke=be.toString();if(!ke)return;let me=ke;w==="uppercase"?me=ke.toLocaleUpperCase():w==="lowercase"?me=ke.toLocaleLowerCase():me=Da(ke),be.deleteContents();const Se=document.createTextNode(me);be.insertNode(Se);const we=document.createRange();we.setStart(Se,0),we.setEnd(Se,me.length),I.removeAllRanges(),I.addRange(we),u.current=we.cloneRange(),P(),T()},oe=()=>{i(),T()},F=()=>{P(),T()},H=w=>{if(w.key==="Escape"){if(C){N(null);return}if(b.current){W(!1);return}}C||(w.ctrlKey||w.metaKey)&&(w.key==="b"&&(w.preventDefault(),_("bold")),w.key==="i"&&(w.preventDefault(),_("italic")),w.key==="u"&&(w.preventDefault(),_("underline")),w.key==="k"&&(w.preventDefault(),M("link")))},Z=()=>e.jsx("div",{className:"h-4 w-px flex-shrink-0 mx-1",style:{background:"var(--border)"}}),G=(w,I,de,be,ke)=>{const me=ke??(g.has(de)||de==="__link"&&C==="link"||de==="__img"&&C==="image");return e.jsx("button",{type:"button",title:I,onMouseDown:Se=>{Se.preventDefault(),be?be():_(de)},className:"flex h-7 w-7 items-center justify-center rounded text-xs font-bold transition-colors",style:{color:me?"var(--primary)":"var(--text-secondary)",background:me?"rgba(59,130,246,0.12)":"transparent"},children:w},de)},te=w=>{const I=w.target;if(I.closest("[data-action='delete-img']")){w.preventDefault();const de=I.closest(".rich-img-wrap");de&&(de.remove(),P())}},ue=w=>e.jsxs(e.Fragment,{children:[C==="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:w},children:[e.jsx("input",{autoFocus:!0,type:"url",value:S,onChange:I=>B(I.target.value),onKeyDown:I=>{I.key==="Enter"&&(I.preventDefault(),O()),I.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:ee,onChange:I=>z(I.target.value),onKeyDown:I=>{I.key==="Enter"&&(I.preventDefault(),O()),I.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:O,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"})]}),C==="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:w},children:[e.jsx("input",{autoFocus:!0,type:"url",value:X,onChange:I=>L(I.target.value),onKeyDown:I=>{I.key==="Enter"&&(I.preventDefault(),ae()),I.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:U,onChange:I=>Q(I.target.value),onKeyDown:I=>{I.key==="Enter"&&(I.preventDefault(),ae()),I.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:ae,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"})]})]}),se=(w,I)=>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:I},children:[G(e.jsx(v.HiArrowUturnLeft,{className:"h-4 w-4"}),"Deshacer","undo"),G(e.jsx(v.HiArrowUturnRight,{className:"h-4 w-4"}),"Rehacer","redo"),Z(),G(e.jsx("span",{style:{fontSize:"10px"},children:"P"}),"Parrafo","__paragraph",()=>le("p"),g.has("formatBlock:p")||g.has("formatBlock:div")),G(e.jsx(v.HiH2,{className:"h-4 w-4"}),"Titulo 2","__h2",()=>le("h2"),g.has("formatBlock:h2")),G(e.jsx(v.HiH3,{className:"h-4 w-4"}),"Titulo 3","__h3",()=>le("h3"),g.has("formatBlock:h3")),G(e.jsx("span",{style:{fontSize:"13px",lineHeight:1},children:"“"}),"Cita","__quote",()=>le("blockquote"),g.has("formatBlock:blockquote")),Z(),G(e.jsx("b",{children:"B"}),"Negrita (Ctrl+B)","bold"),G(e.jsx("i",{children:"I"}),"Cursiva (Ctrl+I)","italic"),G(e.jsx("u",{children:"U"}),"Subrayado (Ctrl+U)","underline"),G(e.jsx("s",{children:"S"}),"Tachado","strikeThrough"),Z(),G(e.jsx(v.HiListBullet,{className:"h-4 w-4"}),"Lista sin orden","insertUnorderedList"),G(e.jsx(v.HiNumberedList,{className:"h-4 w-4"}),"Lista numerada","insertOrderedList"),G(e.jsx(v.HiArrowTurnUpLeft,{className:"h-4 w-4"}),"Disminuir sangria","outdent"),G(e.jsx(v.HiArrowTurnDownRight,{className:"h-4 w-4"}),"Aumentar sangria","indent"),Z(),G(e.jsx(v.HiBars3BottomLeft,{className:"h-4 w-4"}),"Alinear izquierda","justifyLeft"),G(e.jsx(v.HiBars3CenterLeft,{className:"h-4 w-4"}),"Centrar","justifyCenter"),G(e.jsx(v.HiBars3BottomRight,{className:"h-4 w-4"}),"Alinear derecha","justifyRight"),G(e.jsx(v.HiBars3,{className:"h-4 w-4"}),"Justificar","justifyFull"),Z(),G(e.jsx("span",{style:{fontSize:"10px"},children:"AA"}),"Mayusculas","__upper",()=>A("uppercase")),G(e.jsx("span",{style:{fontSize:"10px"},children:"aa"}),"Minusculas","__lower",()=>A("lowercase")),G(e.jsx("span",{style:{fontSize:"10px"},children:"Aa"}),"Capitalizar","__cap",()=>A("capitalize")),Z(),G(e.jsx(v.HiLink,{className:"h-4 w-4"}),"Insertar enlace (Ctrl+K)","__link",()=>M("link")),G(e.jsx(v.HiLinkSlash,{className:"h-4 w-4"}),"Quitar enlace","unlink"),G(e.jsx(v.HiPhoto,{className:"h-4 w-4"}),"Insertar imagen","__img",()=>M("image")),G(e.jsx(v.HiMinus,{className:"h-4 w-4"}),"Insertar separador","__divider",q),Z(),G(e.jsx(v.HiOutlinePaintBrush,{className:"h-4 w-4"}),"Limpiar formato","removeFormat"),G(e.jsx(v.HiNoSymbol,{className:"h-4 w-4"}),"Quitar bloque","__clearBlock",()=>le("p")),Z(),e.jsx("button",{type:"button",title:w?"Salir del modo de enfoque (Esc)":"Modo de enfoque",onMouseDown:de=>{de.preventDefault(),V(w)},className:"flex h-7 w-7 items-center justify-center rounded transition-colors",style:{color:"var(--text-secondary)"},children:w?e.jsx(v.HiArrowsPointingIn,{className:"h-4 w-4"}):e.jsx(v.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:s,contentEditable:!0,suppressContentEditableWarning:!0,onInput:F,onKeyDown:H,onKeyUp:oe,onSelect:oe,onMouseUp:oe,onPaste:pe,onMouseDown:te,"data-placeholder":a,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:n,maxHeight:"320px",overflowY:"auto",lineHeight:"1.6"}}),ue("var(--bg-input)"),se(!1,"var(--bg-input)")]}),e.jsxs(St,{open:re,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:c,contentEditable:!0,suppressContentEditableWarning:!0,onInput:F,onKeyDown:H,onKeyUp:oe,onSelect:oe,onMouseUp:oe,onPaste:pe,onMouseDown:te,"data-placeholder":a,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"}}),ue("var(--bg-input)"),se(!0,"var(--bg-input)")]})]})}function Lo({title:r,subtitle:t,icon:a,actions:n,children:s,footer:c,className:u="",bodyClassName:b="p-4"}){const p=r||t||a||n;return e.jsxs("section",{className:`overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${u}`,children:[p&&e.jsxs("header",{className:"flex items-center justify-between gap-3 border-b border-[var(--border)] px-4 py-3",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[a&&e.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-input)] text-[var(--primary)]",children:a}),e.jsxs("div",{className:"min-w-0",children:[r&&e.jsx("h3",{className:"truncate text-sm font-semibold text-[var(--text-main)]",children:r}),t&&e.jsx("div",{className:"truncate text-xs text-[var(--text-muted)]",children:t})]})]}),n&&e.jsx("div",{className:"shrink-0",children:n})]}),e.jsx("div",{className:b,children:s}),c&&e.jsx("footer",{className:"border-t border-[var(--border)] px-4 py-3",children:c})]})}const To={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)"}},Ao={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 Ho({children:r,tone:t="neutral",size:a="sm",icon:n,dot:s=!1,className:c=""}){const u=To[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 ${Ao[a]} ${c}`,style:{color:u.text,background:u.bg,borderColor:u.border},children:[s&&e.jsx("span",{"aria-hidden":"true",className:"h-1.5 w-1.5 shrink-0 rounded-full",style:{background:u.text}}),n&&e.jsx("span",{className:"shrink-0",children:n}),e.jsx("span",{className:"min-w-0 truncate",children:r})]})}const Ia={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)"}},Do={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"},Bo={xs:"right-1 h-3 w-3",sm:"right-1.5 h-3 w-3",md:"right-2 h-3.5 w-3.5"},Io={xs:148,sm:164,md:184},Oo={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 Fo({value:r,options:t,onChange:a,size:n="sm",disabled:s=!1,loading:c=!1,stopPropagation:u=!1,ariaLabel:b="Cambiar estado",title:p="Cambiar estado",className:m,selectClassName:h,menuClassName:x,optionClassName:g,spinnerClassName:$}){const[C,N]=l.useState(!1),[S,B]=l.useState(!1),[ee,z]=l.useState(-1),[X,L]=l.useState({}),U=l.useRef(null),Q=l.useRef(null),re=l.useRef(null),W=t.find(i=>i.value===r)??t[0],J={...W!=null&&W.tone?Ia[W.tone]:void 0,...W==null?void 0:W.style},R=s||c||t.length===0,T=i=>{u&&i.stopPropagation()},P=l.useCallback(()=>{N(!1),z(-1)},[]),V=l.useCallback(()=>{const i=U.current;if(!i)return;const y=i.getBoundingClientRect(),M=Math.max(y.width,Io[n]),O=Math.min(Math.max(t.length,1)*38+12,260),D=window.innerHeight-y.bottom,ae=D<O&&y.top>D,ie=Math.min(Math.max(8,y.left+y.width/2-M/2),window.innerWidth-M-8);L({position:"fixed",left:ie,top:ae?void 0:y.bottom+6,bottom:ae?window.innerHeight-y.top+6:void 0,width:M,zIndex:9999})},[t.length,n]),_=l.useCallback(i=>{i.disabled||(a(i.value),P())},[P,a]);l.useEffect(()=>B(!0),[]),l.useEffect(()=>{if(!C)return;V();const i=t.findIndex(y=>y.value===r);z(i>=0?i:0)},[C,t,V,r]),l.useEffect(()=>{if(!C)return;function i(y){var O,D;const M=y.target;!((O=U.current)!=null&&O.contains(M))&&!((D=Q.current)!=null&&D.contains(M))&&P()}return document.addEventListener("mousedown",i),()=>document.removeEventListener("mousedown",i)},[P,C]),l.useEffect(()=>{if(C)return window.addEventListener("resize",V),window.addEventListener("scroll",V,!0),()=>{window.removeEventListener("resize",V),window.removeEventListener("scroll",V,!0)}},[C,V]),l.useEffect(()=>{if(ee<0||!re.current)return;const i=re.current.children[ee];i==null||i.scrollIntoView({block:"nearest"})},[ee]);function le(i){if(!R){if(!C){["Enter"," ","ArrowDown","ArrowUp"].includes(i.key)&&(i.preventDefault(),N(!0));return}if(i.key==="Escape"){i.preventDefault(),P();return}if(i.key==="ArrowDown"){i.preventDefault(),z(y=>Math.min(y+1,t.length-1));return}if(i.key==="ArrowUp"){i.preventDefault(),z(y=>Math.max(y-1,0));return}if(i.key==="Enter"||i.key===" "){i.preventDefault();const y=t[ee];y&&_(y)}}}const q=e.jsx("div",{ref:Q,role:"listbox","aria-label":b,className:Je("overflow-hidden rounded-xl border shadow-xl backdrop-blur-md",x),style:{...X,background:"color-mix(in srgb, var(--bg-card) 92%, transparent)",borderColor:"var(--border)",color:"var(--text-main)"},onClick:T,onMouseDown:T,onPointerDown:T,children:e.jsx("div",{ref:re,className:"max-h-64 overflow-y-auto p-1",style:{scrollbarWidth:"thin",scrollbarColor:"var(--border) transparent",overscrollBehavior:"contain"},children:t.map((i,y)=>{const M=i.value===r,O=y===ee,D={...i.tone?Ia[i.tone]:void 0,...i.style};return e.jsxs("button",{type:"button",role:"option","aria-selected":M,disabled:i.disabled,onMouseEnter:()=>!i.disabled&&z(y),onMouseDown:ae=>{ae.preventDefault(),_(i)},className:Je("flex w-full items-center gap-2 rounded-lg font-medium text-left transition-colors disabled:cursor-not-allowed disabled:opacity-45",Oo[n],M?i.className:void 0,g),style:{...M?D:void 0,background:M?D.background??"color-mix(in srgb, var(--primary) 12%, transparent)":O?"var(--bg-hover)":"transparent",color:M?D.color??"var(--primary)":"var(--text-main)"},children:[e.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center",children:M?e.jsx(v.HiCheck,{className:"h-4 w-4"}):null}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:i.label})]},i.value)})})});return e.jsxs("span",{ref:U,className:Je("relative inline-flex shrink-0 items-center",m),onKeyDown:le,onClick:T,onPointerDown:T,children:[e.jsx("button",{type:"button",disabled:R,"aria-label":b,"aria-haspopup":"listbox","aria-expanded":C,title:p,onClick:()=>!R&&N(i=>!i),className:Je("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",Do[n],W==null?void 0:W.className,h),style:J,children:e.jsx("span",{className:"min-w-0 truncate",children:(W==null?void 0:W.label)??r})}),e.jsx(v.HiChevronDown,{"aria-hidden":"true",className:Je("pointer-events-none absolute opacity-70 transition-transform",Bo[n],C?"rotate-180":"rotate-0")}),c&&e.jsx("span",{"aria-hidden":"true",className:Je("absolute -right-1 -top-1 h-2.5 w-2.5 rounded-full border border-current border-t-transparent animate-spin",$)}),C&&S&&je.createPortal(q,document.body)]})}function Po({tabs:r,activeTabId:t,defaultActiveTabId:a,onTabChange:n,ariaLabel:s="Pestanas",variant:c="underline",className:u="",listClassName:b="",panelClassName:p=""}){const m=r.find(C=>!C.disabled)??r[0],h=t??a??(m==null?void 0:m.id),x=r.find(C=>C.id===h)??m,g=C=>{C.disabled||n==null||n(C.id)},$=C=>{const N=r.filter(B=>!B.disabled);if(!N.length||!x)return;const S=N.findIndex(B=>B.id===x.id);(C.key==="ArrowRight"||C.key==="ArrowDown")&&(C.preventDefault(),g(N[(S+1)%N.length])),(C.key==="ArrowLeft"||C.key==="ArrowUp")&&(C.preventDefault(),g(N[(S-1+N.length)%N.length])),C.key==="Home"&&(C.preventDefault(),g(N[0])),C.key==="End"&&(C.preventDefault(),g(N[N.length-1]))};return e.jsxs("div",{className:u,children:[e.jsx("div",{role:"tablist","aria-label":s,onKeyDown:$,className:`flex min-w-0 gap-1 overflow-x-auto ${c==="underline"?"border-b border-[var(--border)]":"rounded-lg border border-[var(--border)] bg-[var(--bg-input)] p-1"} ${b}`,children:r.map(C=>{const N=C.id===(x==null?void 0:x.id);return e.jsxs("button",{type:"button",role:"tab","aria-selected":N,"aria-controls":`${C.id}-panel`,id:`${C.id}-tab`,disabled:C.disabled,tabIndex:N?0:-1,onClick:()=>g(C),className:`inline-flex min-h-8 shrink-0 items-center justify-center gap-1.5 whitespace-nowrap px-2.5 text-sm font-semibold transition-colors focus:outline-none disabled:cursor-not-allowed disabled:opacity-50 ${c==="underline"?"border-b-2":"rounded-md border"}`,style:{color:N?"var(--primary)":"var(--text-muted)",borderColor:N?"var(--primary)":"transparent",background:c==="pills"&&N?"var(--bg-card)":"transparent"},children:[C.icon&&e.jsx("span",{className:"shrink-0",children:C.icon}),e.jsx("span",{children:C.label}),C.badge&&e.jsx("span",{className:"shrink-0",children:C.badge})]},C.id)})}),(x==null?void 0:x.content)!==void 0&&e.jsx("div",{role:"tabpanel",id:`${x.id}-panel`,"aria-labelledby":`${x.id}-tab`,className:`pt-4 ${p}`,children:x.content})]})}function Qe(...r){return r.filter(Boolean).join(" ")}function zo({steps:r,activeStepId:t,initialStepId:a,completedStepIds:n,defaultCompletedStepIds:s=[],onActiveStepChange:c,onCompletedStepIdsChange:u,onBlockedStep:b,allowBackNavigation:p=!0,showFooter:m=!0,previousLabel:h="Anterior",nextLabel:x="Siguiente",blockedNextLabel:g="Completa este paso",className:$="",headerClassName:C="",contentClassName:N="",footerClassName:S=""}){var F;const B=((F=r[0])==null?void 0:F.id)??"",[ee,z]=l.useState(a??B),[X,L]=l.useState(s),U=t??ee,Q=n??X,re=l.useMemo(()=>new Set(Q),[Q]),W=Math.max(0,r.findIndex(H=>H.id===U)),J=r[W]??r[0],R=r.length<=1?100:W/(r.length-1)*100,T=H=>{n||L(H),u==null||u(H)},P=H=>{const Z=r.find(G=>G.id===H);Z&&(t||z(H),c==null||c(H,Z))},V=H=>re.has(H),_=H=>r.slice(0,H).find(Z=>!Z.optional&&!re.has(Z.id)),le=H=>{const Z=r[H];return!Z||Z.disabled?!1:H===W||p&&H<W?!0:!_(H)},q=H=>{const Z=r.findIndex(G=>G.id===H);return Z>=0&&le(Z)},i=H=>{const Z=r.findIndex(G=>G.id===H);if(Z<0)return!1;if(!le(Z)){const G=_(Z);return G&&(b==null||b(r[Z],G)),!1}return P(H),!0},y=(H=J==null?void 0:J.id)=>{!H||re.has(H)||T([...Q,H])},M=(H=J==null?void 0:J.id)=>{if(!H)return;const Z=r.findIndex(te=>te.id===H),G=Q.filter(te=>{const ue=r.findIndex(se=>se.id===te);return ue>=0&&ue<Z});T(G),Z>=0&&W>Z&&P(H)},O=()=>W<=0?!1:i(r[W-1].id),D=()=>{const H=r[W+1];return H?i(H.id):!1},ae={activeStep:J,activeIndex:W,completedStepIds:Q,isCompleted:V,isUnlocked:q,completeStep:y,uncompleteStep:M,goToStep:i,goNext:D,goPrevious:O};if(!J)return null;const ie=r[W+1],pe=W>0,A=ie?q(ie.id):!1,oe=typeof J.content=="function"?J.content(ae):J.content;return e.jsxs("section",{className:Qe("overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)]",$),children:[e.jsxs("div",{className:Qe("border-b border-[var(--border)] bg-[var(--bg-input)]",C),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:`${R}%`}})}),e.jsx("div",{className:"grid gap-2 p-2",style:{gridTemplateColumns:`repeat(${r.length}, minmax(0, 1fr))`},children:r.map((H,Z)=>{const G=H.id===J.id,te=V(H.id),ue=le(Z),se=_(Z);return e.jsxs("button",{type:"button",disabled:!ue,"aria-current":G?"step":void 0,"aria-disabled":!ue,title:!ue&&se?`Completa ${se.title}`:H.title,onClick:()=>i(H.id),className:Qe("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",G&&"border-[var(--primary)] bg-[var(--bg-card)] shadow-sm",te&&!G&&"border-[var(--primary)]/35 bg-[var(--bg-card)]",!G&&!te&&ue&&"border-transparent bg-[var(--bg-card)]/45 hover:border-[var(--border)] hover:bg-[var(--bg-card)]",!ue&&"border-transparent bg-[var(--bg-card)]/35 opacity-60"),children:[e.jsx("span",{className:Qe("absolute inset-x-0 top-0 h-0.5 origin-left scale-x-0 bg-[var(--primary)] transition-transform duration-300",G&&"scale-x-100")}),e.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:Qe("grid h-7 w-7 shrink-0 place-items-center rounded-full border text-xs font-bold transition-all duration-200",G&&"border-[var(--primary)] bg-[var(--primary)] text-[var(--primary-fg)]",te&&!G&&"border-[var(--primary)] bg-[var(--primary)]/12 text-[var(--primary)]",!te&&!G&&ue&&"border-[var(--border)] text-[var(--text-muted)]",!ue&&"border-[var(--border)] text-[var(--text-muted)]"),children:te?e.jsx(v.HiCheck,{className:"h-4 w-4"}):ue?Z+1:e.jsx(v.HiLockClosed,{className:"h-3.5 w-3.5"})}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsxs("span",{className:Qe("block truncate text-xs font-semibold transition-colors duration-200",G?"text-[var(--text-main)]":"text-[var(--text-secondary)]"),children:[Z+1,". ",H.title]}),H.description&&e.jsx("span",{className:"mt-1 block truncate text-[11px] text-[var(--text-muted)]",children:H.description})]}),H.badge&&e.jsx("span",{className:"shrink-0",children:H.badge})]})]},H.id)})})]}),e.jsx("div",{className:Qe("min-h-72 animate-[stepWizardIn_220ms_ease-out] p-5",N),children:oe},J.id),m&&e.jsxs("div",{className:Qe("flex flex-wrap items-center justify-between gap-3 border-t border-[var(--border)] bg-[var(--bg-input)] px-4 py-3",S),children:[e.jsx(Te,{variant:"secondary",height:38,padding:"0 14px",icon:e.jsx(v.HiChevronLeft,{}),disabled:!pe,onClick:O,children:h}),e.jsxs("div",{className:"flex items-center gap-3 text-xs text-[var(--text-muted)]",children:[e.jsxs("span",{children:["Paso ",W+1," de ",r.length]}),e.jsx("span",{className:"h-1 w-1 rounded-full bg-[var(--border)]"}),e.jsxs("span",{children:[Q.length," completados"]})]}),e.jsx(Te,{height:38,padding:"0 14px",icon:e.jsx(v.HiChevronRight,{}),disabled:!ie||!A,onClick:D,children:ie&&!A?g:x})]})]})}const jo={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"},_o={none:"resize-none",vertical:"resize-y",horizontal:"resize-x",both:"resize"};function Wo(r,t){if(r){if(typeof r=="function"){r(t);return}r.current=t}}function qo(r,t){return r!==void 0?String(r).length:t!==void 0?String(t).length:0}const Oa=l.forwardRef(function({className:t="",wrapperClassName:a="",size:n="md",resize:s="vertical",autoResize:c=!1,minRows:u,maxRows:b,showCount:p=!1,maxCount:m,status:h="default",icon:x,action:g,style:$,value:C,defaultValue:N,maxLength:S,onInput:B,...ee},z){const X=l.useRef(null),L=qo(C,N),U=m??S,Q=!!(x||g||p),re=h==="error"?"var(--danger)":h==="success"?"#16a34a":"var(--border)",W={...$??{},...u?{minHeight:`${u*24+18}px`}:null,...b?{maxHeight:`${b*24+18}px`}:null},J=()=>{const T=X.current;!T||!c||(T.style.height="auto",T.style.height=`${T.scrollHeight}px`)};l.useEffect(J,[c,C]);const R=e.jsx("textarea",{...ee,ref:T=>{X.current=T,Wo(z,T)},value:C,defaultValue:N,maxLength:S,"aria-invalid":h==="error"||ee["aria-invalid"],onInput:T=>{J(),B==null||B(T)},style:{...W,borderColor:re},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 ${jo[n]} ${_o[c?"none":s]} ${x?"pl-8":""} ${g?"pr-10":""} ${t}`});return Q?e.jsxs("span",{className:`relative block ${a}`,children:[x&&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:x}),R,g&&e.jsx("span",{className:"absolute right-2 top-2 flex items-center justify-center",children:g}),p&&e.jsxs("span",{className:"absolute bottom-1.5 right-2 rounded bg-[var(--bg-input)] px-1.5 text-[10px] font-semibold text-[var(--text-muted)]",children:[L,U?`/${U}`:""]})]}):R});function Uo({label:r,containerClassName:t="",helperText:a,error:n,labelAction:s,required:c,className:u="",status:b,...p}){return e.jsx($a,{label:r,required:c,helperText:a,error:n,labelAction:s,className:t,children:e.jsx(Oa,{...p,required:c,status:n?"error":b,className:`w-full ${u}`})})}const Vo={xs:{width:28,height:16,thumb:12,padding:2},sm:{width:36,height:20,thumb:16,padding:2}};function Ko({checked:r,disabled:t,onCheckedChange:a,size:n="sm",className:s="",...c}){const u=Vo[n],b=r?u.width-u.thumb-u.padding*2:0;return e.jsx("button",{...c,type:"button",role:"switch","aria-checked":r,disabled:t,onClick:()=>!t&&a(!r),className:`relative inline-flex shrink-0 items-center rounded-full transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--primary)]/50 disabled:cursor-not-allowed disabled:opacity-50 ${s}`,style:{width:u.width,height:u.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:u.thumb,height:u.thumb,left:u.padding,top:"50%",transform:`translate(${b}px, -50%)`,background:r?"var(--primary-fg)":"var(--text-muted)"}})})}const Fa=[".sidebar-scroll","[data-overlay-scroll='true']"].join(",");function Go(r){if(!(r instanceof HTMLElement)||r.dataset.overlayScroll==="false"||r.closest("[data-overlayscrollbars]")||r.matches("textarea,input,select,[contenteditable='true']"))return!1;const t=window.getComputedStyle(r);return!(![t.overflow,t.overflowX,t.overflowY].join(" ").match(/auto|scroll/)||r.clientWidth===0&&r.clientHeight===0)}function Pa(r){return r.classList.contains("sidebar-scroll")}function za(r){Pa(r)&&r.querySelectorAll(".os-scrollbar-horizontal").forEach(t=>{t.style.display="none",t.style.height="0",t.style.pointerEvents="none"})}function ja(){return l.useEffect(()=>{const r=new WeakMap;let t=0;const a=()=>{t=0,document.querySelectorAll(Fa).forEach(c=>{if(!Go(c))return;if(Zt.OverlayScrollbars(c)){za(c);return}const b=Zt.OverlayScrollbars(c,{overflow:Pa(c)?{x:"hidden",y:"scroll"}:void 0,scrollbars:{autoHide:"leave",autoHideDelay:180}});za(c),r.set(c,b)})},n=()=>{t||(t=window.requestAnimationFrame(a))};a();const s=new MutationObserver(n);return s.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["class","data-overlay-scroll"]}),window.addEventListener("resize",n),()=>{t&&window.cancelAnimationFrame(t),s.disconnect(),window.removeEventListener("resize",n),document.querySelectorAll(Fa).forEach(c=>{var u;c instanceof HTMLElement&&((u=r.get(c))==null||u.destroy())})}},[]),null}const Yo={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"}},_a=["bg-indigo-500","bg-blue-500","bg-emerald-500","bg-violet-500","bg-amber-500","bg-teal-500","bg-rose-500","bg-cyan-500"],Xo={xs:"text-xs",sm:"text-sm",md:"text-base",lg:"text-lg"},Zo="bonsaif.bot",Jo="Bonsaif Bot",Qo={xs:"p-0.5",sm:"p-1",md:"p-1.5",lg:"p-2",xl:"p-2.5"};function Wa(r){return typeof r=="string"?r.trim():""}function Ro(r){let t=0;for(const a of r)t=t*31+a.charCodeAt(0)&65535;return _a[t%_a.length]}function es(r,t){return r===Zo||t===Jo}function rs(r,t){return`${r.replace(/\/$/,"")}${t}`}function qa({userId:r,username:t,name:a,size:n="md",showName:s=!1,showTooltip:c,tooltipContent:u,fallbackLabel:b="Usuario",wrapperClassName:p="",labelClassName:m="",labelSize:h="xs",avatarVersion:x=0,className:g="",style:$}){var V;const[C,N]=l.useState(!1),S=typeof r=="string"&&r.trim()&&r!=="undefined"&&r!=="null"?r.trim():"";l.useEffect(()=>{N(!1)},[S,x]);const{wh:B,text:ee}=Yo[n],z=Wa(a)||Wa(t)||b,X=z.trim()[0]||"?",L=typeof process<"u"&&((V=process.env)==null?void 0:V.NEXT_PUBLIC_BASE_PATH)||"",U=es(t,a),Q=rs(L,"/favicon.svg"),re=S?`${L}/api/user/avatar/${S}${x?`?v=${x}`:""}`:"",J={xs:20,sm:28,md:36,lg:48,xl:64}[n],R=U?e.jsx("span",{className:`${B} ${Qo[n]} rounded-full flex items-center justify-center bg-[#071f1a] ring-1 ring-emerald-400/35 shadow-[0_0_0_1px_rgba(255,255,255,0.06)] flex-shrink-0 ${g}`,style:$,children:e.jsx("img",{src:Q,alt:z,width:J,height:J,className:"h-full w-full object-contain"})}):re&&!C?e.jsx("img",{src:re,alt:z,width:J,height:J,className:`${B} rounded-full object-cover flex-shrink-0 ${g}`,style:$,onError:()=>N(!0)},`${S}-${x}`):e.jsx("span",{className:`${B} ${Ro(z)} ${ee} rounded-full flex items-center justify-center font-black text-white uppercase flex-shrink-0 ${g}`,style:$,title:z,children:X});if(s)return e.jsxs("span",{className:`inline-flex min-w-0 items-center gap-2 ${p}`,children:[R,e.jsx("span",{className:`min-w-0 truncate ${Xo[h]} font-medium text-[var(--text-main)] ${m}`,title:z,children:z})]});const T=c??!0,P=u??z;return T&&P?e.jsx(dr,{as:"span",content:P,className:`inline-flex flex-shrink-0 ${p}`,children:R}):R}function ts({href:r,className:t,children:a}){return e.jsx("a",{href:r,className:t,children:a})}function as(r){return r.reduce((t,a)=>{const n=a.section??"Principal";return t[n]=[...t[n]??[],a],t},{})}function Ua({children:r,navItems:t=[],currentPath:a=typeof window>"u"?"/":window.location.pathname,user:n,appName:s="Bonsaif",appLogo:c,header:u,footer:b,onLogout:p,LinkComponent:m=ts}){const[h,x]=l.useState(!1),g=as(t);return e.jsxs("div",{className:"min-h-screen bg-[var(--bg-main)] text-[var(--text-main)]",children:[e.jsx(ja,{}),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:()=>x(!0),children:e.jsx(v.HiBars3,{className:"h-5 w-5"})}),h&&e.jsx("button",{type:"button","aria-label":"Cerrar navegación",className:"fixed inset-0 z-40 bg-black/45 lg:hidden",onClick:()=>x(!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 ${h?"translate-x-0":"-translate-x-full"}`,children:[e.jsxs("div",{className:"flex h-16 items-center gap-3 border-b border-white/10 px-4",children:[e.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg bg-white/10 text-white",children:c??e.jsx(v.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:()=>x(!1),children:e.jsx(v.HiXMark,{className:"h-5 w-5"})})]}),e.jsx("nav",{className:"sidebar-scroll min-h-0 flex-1 overflow-y-auto px-3 py-4","data-overlay-scroll":"true",children:Object.entries(g).map(([$,C])=>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(v.HiChevronDown,{className:"h-3.5 w-3.5"}),$]}),e.jsx("div",{className:"space-y-1",children:C.map(N=>{const S=a===N.href||a.startsWith(`${N.href}/`);return e.jsxs(m,{href:N.href,className:`flex min-w-0 items-center gap-2 rounded-md px-2 py-2 text-sm transition-colors ${S?"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:N.icon??e.jsx(v.HiHome,{className:"h-4 w-4"})}),e.jsx("span",{className:"truncate",children:N.label})]},N.href)})})]},$))}),e.jsxs("div",{className:"border-t border-white/10 p-3",children:[n&&e.jsxs("div",{className:"mb-3 flex min-w-0 items-center gap-3 rounded-lg bg-white/[0.04] p-2",children:[e.jsx(qa,{name:n.initials??n.name??n.email??"Usuario",size:"md"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate text-sm font-medium text-white",children:n.name??"Usuario"}),n.email&&e.jsx("div",{className:"truncate text-xs text-white/45",children:n.email})]})]}),p&&e.jsxs(Te,{variant:"ghost",className:"w-full justify-start text-white hover:bg-white/10",onClick:p,children:[e.jsx(v.HiArrowRightOnRectangle,{className:"h-4 w-4"})," Salir"]}),b]})]}),e.jsxs("div",{className:"min-h-screen lg:pl-72",children:[u,e.jsx("main",{className:"min-h-screen",children:r})]})]})}const Va="bonsaif-ui:prime-auth-sso",ns={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"},Tt={dashboard:e.jsx(v.HiChartBar,{className:"h-5 w-5"}),tickets:e.jsx(v.HiTicket,{className:"h-5 w-5"}),teams:e.jsx(v.HiUsers,{className:"h-5 w-5"}),projects:e.jsx(v.HiRectangleGroup,{className:"h-5 w-5"}),clients:e.jsx(v.HiBuildingOffice2,{className:"h-5 w-5"}),surveys:e.jsx(v.HiClipboardDocumentList,{className:"h-5 w-5"}),profile:e.jsx(v.HiUser,{className:"h-5 w-5"}),settings:e.jsx(v.HiCog6Tooth,{className:"h-5 w-5"}),notifications:e.jsx(v.HiBell,{className:"h-5 w-5"}),changelog:e.jsx(v.HiDocumentText,{className:"h-5 w-5"}),admin:e.jsx(v.HiShieldCheck,{className:"h-5 w-5"}),users:e.jsx(v.HiUsers,{className:"h-5 w-5"}),roles:e.jsx(v.HiShieldCheck,{className:"h-5 w-5"}),menus:e.jsx(v.HiCog6Tooth,{className:"h-5 w-5"}),guards:e.jsx(v.HiCalendarDays,{className:"h-5 w-5"}),vacations:e.jsx(v.HiCalendarDays,{className:"h-5 w-5"}),audit:e.jsx(v.HiListBullet,{className:"h-5 w-5"}),positions:e.jsx(v.HiBriefcase,{className:"h-5 w-5"}),ranks:e.jsx(v.HiListBullet,{className:"h-5 w-5"}),"email-inbox":e.jsx(v.HiInbox,{className:"h-5 w-5"}),"security-incidents":e.jsx(v.HiShieldCheck,{className:"h-5 w-5"})};function ls({href:r,className:t,style:a,children:n}){return e.jsx("a",{href:r,className:t,style:a,children:n})}function os(r){return r.split("-").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}function ss(r){return/^\d+$/.test(r)||/^[a-f0-9]{8,}$/i.test(r)}function is(r){const t=r.split("/").filter(Boolean);if(t.length===0||t.length===1&&t[0]==="dashboard")return[];const a=decodeURIComponent(t[t.length-1]),n=t.length>1?decodeURIComponent(t[t.length-2]):void 0,s=ss(a)&&n?n:a,c=ns[s]??os(s);return[{label:"Inicio",href:"/"},{label:c}]}function At(r){return(r==null?void 0:r.querySelector(":scope > .os-viewport"))??(r==null?void 0:r.querySelector(":scope > [data-overlayscrollbars-viewport]"))}function cs(r){const t=r.split("/").filter(Boolean),a=t[t.length-1];if(!a)return e.jsx(v.HiHome,{className:"h-5 w-5"});if(Tt[a])return Tt[a];const n=t.length>1?t[t.length-2]:"";return Tt[n]??e.jsx(v.HiHome,{className:"h-5 w-5"})}function ds(r){return r.includes("primeAuthOrigin")||r.includes("primeAuthProjectKey")}function Ka(){if(typeof window>"u")return!1;if(ds(window.location.href)){try{window.sessionStorage.setItem(Va,"true")}catch{}return!0}try{return window.sessionStorage.getItem(Va)==="true"}catch{return!1}}function us({title:r,subtitle:t,action:a,meta:n,icon:s,className:c="",contentClassName:u="",breadcrumbs:b,currentPath:p,showBreadcrumbs:m=!0,contained:h=!1,LinkComponent:x=ls}){const g=l.useRef(null),[$,C]=l.useState(!1),[N,S]=l.useState(p??"/"),[B,ee]=l.useState(()=>Ka()),[z,X]=l.useState(null),L=p??N,U=b??is(L),Q=s??cs(L),re=m&&!B&&U.length>1,W=!re;l.useEffect(()=>{p||S(window.location.pathname)},[p]),l.useEffect(()=>{ee(Ka())},[]),l.useEffect(()=>{if(h){C(!1);return}let R=null,T=0,P=0;const V=()=>{const q=g.current,i=document.querySelector("[data-app-scroll='true']");return(q==null?void 0:q.closest(".os-viewport"))??(q==null?void 0:q.closest("[data-overlayscrollbars-viewport]"))??At(i)??i??window},_=()=>{const q=R&&R!==window?R.scrollTop:window.scrollY;C(i=>i?q>24:q>72)},le=()=>{R==null||R.removeEventListener("scroll",_),R=V(),R.addEventListener("scroll",_,{passive:!0}),_()};return le(),T=window.requestAnimationFrame(le),P=window.setTimeout(le,120),()=>{window.cancelAnimationFrame(T),window.clearTimeout(P),R==null||R.removeEventListener("scroll",_)}},[h]),l.useEffect(()=>{if(h){X(null);return}let R=0;const T=[],P=()=>{const M=g.current,O=M==null?void 0:M.parentElement,D=document.querySelector("[data-app-scroll='true']"),ae=At(D)??D;if(!M||!O||!ae){X(null);return}const ie=O.getBoundingClientRect(),pe=window.getComputedStyle(O),A=ae.getBoundingClientRect(),oe=ae instanceof HTMLElement&&ae.clientWidth>0?ae.clientWidth:A.width,F=ie.left+parseFloat(pe.paddingLeft||"0"),H={marginLeft:Math.round(A.left-F),width:Math.round(oe)};X(Z=>Z&&Z.marginLeft===H.marginLeft&&Z.width===H.width?Z:H)},V=()=>{window.cancelAnimationFrame(R),R=window.requestAnimationFrame(P)};V(),window.addEventListener("resize",V);const _=new ResizeObserver(V),le=g.current,q=le==null?void 0:le.parentElement,i=document.querySelector("[data-app-scroll='true']"),y=At(i)??i;return[q,i,y].forEach(M=>{M&&_.observe(M)}),T.push(window.setTimeout(V,120)),T.push(window.setTimeout(V,280)),()=>{window.cancelAnimationFrame(R),window.removeEventListener("resize",V),_.disconnect(),T.forEach(M=>window.clearTimeout(M))}},[h]);const J={...z?{marginLeft:z.marginLeft,width:z.width}:null,"--page-header-control-height":$?"34px":"40px","--page-header-control-padding-x":$?"10px":"14px","--page-header-control-icon-left":$?"10px":"12px",background:h?"var(--bg-card)":$?"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:h||$?"1px solid var(--border)":"1px solid transparent",boxShadow:$?"0 10px 28px rgba(12, 54, 53, 0.12)":"none"};return e.jsx("div",{ref:g,"data-page-header":"true","data-compact":$?"true":"false",className:`sticky top-0 z-30 overflow-visible py-0 transition-[background-color,box-shadow,border-color] duration-300 ease-out ${h?"mb-0 flex-shrink-0":"mb-4 sm:mb-0"} ${c}`,style:J,children:e.jsxs("div",{className:`flex flex-wrap items-center justify-between transition-[gap,min-height,padding] duration-300 ease-out ${$?"min-h-8 gap-1.5 px-3 py-0 sm:min-h-9 sm:gap-2":W?"min-h-9 gap-2 px-4 py-0 sm:min-h-10 sm:gap-2.5":"min-h-10 gap-2.5 px-4 pt-0.5 sm:min-h-11 sm:gap-3"} ${u}`,children:[e.jsxs("div",{className:`min-w-0 flex flex-1 flex-col justify-center transition-[gap,transform] duration-300 ease-out ${$||W?"gap-1":"gap-1.5 sm:gap-2"}`,children:[re&&e.jsx("nav",{"aria-label":"Breadcrumb",className:"min-w-0 flex-shrink-0 transition-[opacity,transform] duration-300 ease-out",children:e.jsx("ol",{className:`flex flex-wrap items-center gap-1.5 leading-none transition-[font-size,line-height] duration-300 ease-out ${$?"text-[10px]":"text-[10px] sm:text-[11px]"}`,children:U.map((R,T)=>{const P=T===U.length-1;return e.jsxs("li",{className:"flex min-w-0 items-center gap-1.5",children:[T>0&&e.jsx(v.HiChevronRight,{className:"h-3.5 w-3.5 transition-[color,transform] duration-300 ease-out",style:{color:"var(--text-muted)"}}),R.href&&!P?e.jsx(x,{href:R.href,className:"truncate transition-colors duration-300 hover:underline",style:{color:"var(--text-muted)"},children:R.label}):e.jsx("span",{"aria-current":P?"page":void 0,className:P?"truncate font-semibold":"truncate",style:{color:P?"var(--text-main)":"var(--text-muted)"},children:R.label})]},`${R.label}-${T}`)})})}),e.jsxs("div",{className:`flex min-w-0 items-center transition-[gap,transform] duration-300 ease-out ${$||W?"gap-2":"gap-2.5 sm:gap-3"}`,children:[e.jsx("span",{className:`flex-shrink-0 transition-[color,transform,opacity] duration-300 ease-out ${$?"scale-75 opacity-80":"scale-90 opacity-100"}`,style:{color:re?"var(--text-secondary)":"var(--text-muted)"},children:Q}),e.jsxs("div",{className:`flex min-w-0 flex-1 flex-wrap items-center transition-[gap] duration-300 ease-out ${$?"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 ${$?"text-sm sm:text-base":"text-lg sm:text-xl"}`,style:{color:"var(--text-main)"},children:r}),t&&e.jsx("p",{"aria-hidden":$,className:`overflow-hidden text-xs transition-[max-height,opacity,transform,margin] duration-300 ease-out ${$?"mt-0 max-h-0 -translate-y-1 opacity-0":"mt-0.5 max-h-5 translate-y-0 opacity-100"}`,style:{color:"var(--text-muted)"},children:t})]}),n&&e.jsx("div",{className:`page-header-meta flex min-w-0 flex-1 basis-full items-center overflow-visible transition-[gap,opacity,transform] duration-300 ease-out sm:basis-auto ${$?"translate-y-0 gap-1.5 opacity-95":"gap-2 opacity-100"}`,children:n})]})]})]}),a&&e.jsx("div",{className:`page-header-actions ml-auto flex max-w-full flex-shrink-0 flex-wrap items-center justify-end self-center overflow-visible transition-[gap,min-height,opacity,transform] duration-300 ease-out ${$?"min-h-9 gap-1 opacity-95":"min-h-9 gap-1.5 opacity-100"}`,children:e.jsx(ra.Provider,{value:{compact:!0,headerAction:!0},children:a})})]})})}function bs({children:r,currentPath:t=typeof window>"u"?"/":window.location.pathname,publicRoutes:a=["/","/login","/reset-password"],...n}){return a.includes(t)?e.jsx(e.Fragment,{children:r}):e.jsx(Ua,{currentPath:t,...n,children:r})}function Ga(){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 fs(r,t,a){try{const n=new URL(r),s=n.searchParams.get("callbackUrl");if(s){const c=new URL(s,n.origin);return c.searchParams.set("theme",t),a&&(c.searchParams.set("primeAuthOrigin",window.location.origin),c.searchParams.set("primeAuthProjectKey",a)),n.searchParams.set("callbackUrl",`${c.pathname}${c.search}${c.hash}`),n.toString()}return n.searchParams.set("theme",t),a&&(n.searchParams.set("primeAuthOrigin",window.location.origin),n.searchParams.set("primeAuthProjectKey",a)),n.toString()}catch{return r}}function ps({name:r,src:t,projectKey:a}){const[n,s]=l.useState("system"),c=l.useRef(null);l.useEffect(()=>{s(Ga());const p=new MutationObserver(()=>s(Ga()));return p.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>p.disconnect()},[]);const u=l.useMemo(()=>fs(t,n,a),[a,t,n]),b=l.useMemo(()=>{try{return new URL(u).origin}catch{return""}},[u]);return l.useEffect(()=>{if(!a)return;const p=a;function m(h){var $,C,N;if(h.source!==(($=c.current)==null?void 0:$.contentWindow)||b&&h.origin!==b)return;if(((C=h.data)==null?void 0:C.type)==="prime-microservice:overlay"){window.dispatchEvent(new CustomEvent("prime-auth:microservice-overlay",{detail:{active:!!h.data.active}}));return}if(((N=h.data)==null?void 0:N.type)!=="prime-microservice:navigation")return;const x=h.data.path;if(!x||!x.startsWith("/")||x.startsWith("//"))return;const g=`/apps/${encodeURIComponent(p)}${x}`;`${window.location.pathname}${window.location.search}${window.location.hash}`!==g&&(window.history.replaceState(window.history.state,"",g),window.dispatchEvent(new CustomEvent("prime-auth:microservice-navigation")))}return window.addEventListener("message",m),()=>{window.removeEventListener("message",m),window.dispatchEvent(new CustomEvent("prime-auth:microservice-overlay",{detail:{active:!1}}))}},[b,a]),e.jsx("div",{className:"flex h-full min-h-screen flex-col bg-[var(--bg-main)]",children:e.jsx("iframe",{ref:c,src:u,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 ms(){const[r,t]=l.useState(""),[a,n]=l.useState(!1),[s,c]=l.useState({width:96,height:96});return l.useEffect(()=>{let u=!1;return fetch("/api/microservices/prime-suite/chat-url",{cache:"no-store"}).then(b=>b.ok?b.json():null).then(b=>{!u&&(b!=null&&b.src)&&t(b.src)}).catch(()=>{}),()=>{u=!0}},[]),l.useEffect(()=>{const u=b=>{var m;if(((m=b.data)==null?void 0:m.type)!=="prime-suite-chat:state")return;const p=!!b.data.active;n(p),c({width:Ya(b.data.width,96,720),height:Ya(b.data.height,96,560)})};return window.addEventListener("message",u),()=>window.removeEventListener("message",u)},[]),r?e.jsx("iframe",{title:"Chat Bonsaif",src:r,allow:"clipboard-write",className:"fixed bottom-0 right-0 z-[70] border-0 bg-transparent transition-[width,height] duration-200",style:{width:a?`min(${s.width}px, 100vw)`:96,height:a?`min(${s.height}px, 100vh)`:96,background:"transparent",backgroundColor:"transparent",colorScheme:"normal"}}):null}function Ya(r,t,a){const n=typeof r=="number"&&Number.isFinite(r)?r:t;return Math.max(t,Math.min(a,Math.ceil(n)))}function hs(r){const t=document.documentElement,a=new MutationObserver(r);a.observe(t,{attributes:!0,attributeFilter:["class"]});const n=window.matchMedia("(prefers-color-scheme: dark)");return n.addEventListener("change",r),()=>{a.disconnect(),n.removeEventListener("change",r)}}function vs(){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 gs(){return"light"}function xs({position:r="bottom-center"}){const t=l.useSyncExternalStore(hs,vs,gs);return e.jsx(Jt.Toaster,{position:r,theme:t,richColors:!0,closeButton:!0})}function ys(r){const[t,a]=l.useState({}),[n,s]=l.useState(!1),c=l.useCallback(m=>n||t[m]?r[m]:void 0,[r,n,t]),u=l.useCallback(m=>{a(h=>({...h,[m]:!0}))},[]),b=l.useCallback(()=>{s(!0)},[]),p=l.useCallback(()=>{a({}),s(!1)},[]);return{submitted:n,touchedFields:t,getFieldError:c,touchField:u,submit:b,reset:p}}Object.defineProperty(Y,"toast",{enumerable:!0,get:()=>Jt.toast}),Y.Alert=Kn,Y.AuthShell=Ua,Y.BonsaifButton=Ln,Y.BonsaifUIToaster=xs,Y.Button=Te,Y.CalendarPicker=Jn,Y.Checkbox=Fr,Y.CodeBlock=tl,Y.CompactFilterSelect=nl,Y.CompactSearchInput=al,Y.ConfirmDialog=il,Y.CopyButton=Nt,Y.CopyLinkButton=dl,Y.DataSheets=Al,Y.DataTable=ma,Y.DateRangePicker=Bl,Y.Drawer=zl,Y.DropdownMenu=Fl,Y.DynamicDetailTabs=Un,Y.EmailField=io,Y.EmptyState=uo,Y.FieldLayoutEditor=vo,Y.FileUpload=mo,Y.FormField=$a,Y.GlobalScrollbars=ja,Y.InputField=$t,Y.LoadingState=la,Y.MicroserviceFrame=ps,Y.Modal=St,Y.MouseTooltip=dr,Y.MultiSelect=xo,Y.NumberField=yo,Y.PageHeader=us,Y.PageSearchInput=ea,Y.Pagination=No,Y.PhoneField=So,Y.PrimeAuthRouteShell=bs,Y.PrimeSuiteChatFrame=ms,Y.RadioGroup=Co,Y.RichTextEditor=$o,Y.SearchableSelect=rr,Y.SectionPanel=Lo,Y.StatusBadge=Ho,Y.StatusSelect=Fo,Y.StepWizard=zo,Y.Tabs=Po,Y.TextInput=Gr,Y.Textarea=Oa,Y.TextareaField=Uo,Y.Toggle=Ko,Y.UserAvatar=qa,Y.cn=Je,Y.emailFormat=Vl,Y.isValidEmail=Ct,Y.isValidPhone=Et,Y.matches=Jl,Y.maxLength=Yl,Y.maxValue=Zl,Y.minLength=Gl,Y.minValue=Xl,Y.phoneCountryCodeOptions=Ta,Y.phoneFormat=Kl,Y.required=Ul,Y.useValidationVisibility=ys,Y.validateForm=Ql,Object.defineProperty(Y,Symbol.toStringTag,{value:"Module"})}));
|
|
21
|
+
</body></html>`,k=window.open("","_blank");k&&(k.document.write(K),k.document.close())}const ht=()=>!Se||!Tr?null:je.createPortal(e.jsxs("div",{ref:Ot,role:"menu",className:"overflow-hidden rounded-lg border p-1 shadow-xl",style:{...Ls,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:()=>{ai(),rt(!1)},children:[e.jsx(v.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:()=>{ni(),rt(!1)},children:[e.jsx(v.HiDocumentText,{className:"h-4 w-4 shrink-0 text-red-500"}),"Imprimir / PDF"]})]}),document.body),vt=()=>{const o=F&&Xe.trim().length>0,d=de!=null&&de.length?de:o?[{key:"bql",label:"BQL",value:Xe}]:[],E=I.filter(f=>f.trim()&&f!==Rr).slice(0,8);return!D&&jt===0&&!F&&!Se?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:[jt>0&&e.jsxs("button",{type:"button",onClick:_s,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(v.HiXMark,{className:"h-3.5 w-3.5"}),jt," filtros"]}),F&&e.jsxs("div",{ref:Bt,className:"relative flex min-w-0 flex-1 items-center gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>{if(Ze){or(!1);return}it(),or(!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:Ze?"var(--primary)":o?"color-mix(in srgb, var(--primary) 12%, transparent)":"var(--bg-card)",borderColor:Ze||o?"var(--primary)":"var(--border)",color:Ze?"var(--primary-fg)":"var(--primary)"},"aria-expanded":Ze,title:"Abrir filtros BQL",children:[e.jsx(v.HiCommandLine,{className:"h-3.5 w-3.5"}),"BQL",o&&e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-current"}),Ze?e.jsx(v.HiChevronUp,{className:"h-3.5 w-3.5"}):e.jsx(v.HiChevronDown,{className:"h-3.5 w-3.5"})]}),e.jsx("span",{className:"hidden truncate text-xs text-[var(--text-muted)] sm:inline",children:te}),d.length>0&&e.jsxs("div",{className:"hidden min-w-0 items-center gap-1.5 overflow-hidden lg:flex",children:[d.slice(0,3).map(f=>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:[f.label,":"]}),e.jsx("span",{className:"truncate",children:f.value})]},f.key)),d.length>3&&e.jsxs("span",{className:"text-xs text-[var(--text-muted)]",children:["+",d.length-3]})]}),o&&e.jsx("button",{type:"button","aria-label":"Limpiar BQL",title:"Limpiar BQL",onClick:bn,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(v.HiXMark,{className:"h-4 w-4"})}),Ze&&je.createPortal(e.jsxs("div",{ref:en,className:"flex flex-col gap-3 rounded-lg p-3 shadow-2xl",style:{...Cs,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:[se.map(f=>e.jsxs("button",{type:"button",onClick:()=>st(f.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:[f.icon,f.label]},f.label)),w.length>0&&e.jsxs("button",{type:"button",onClick:()=>fr(f=>!f),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":Qa,children:[e.jsx(v.HiInformationCircle,{className:"h-3.5 w-3.5"}),"Ejemplos"]}),$r.length>0&&e.jsxs("button",{type:"button",onClick:()=>pr(f=>!f),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":Ra,children:[e.jsx(v.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 ${be?"var(--danger)":o?"var(--primary)":"var(--border)"}`},children:[e.jsx("textarea",{ref:It,value:Rr,rows:3,onChange:f=>Wt(f.target.value,f.target),onKeyDown:f=>{f.key==="Enter"&&!f.shiftKey&&(f.preventDefault(),st(Rr)),f.key==="Escape"&&or(!1)},placeholder:ue,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"}}),E.length>0&&e.jsx("div",{className:"border-t border-[var(--border)] bg-[var(--bg-card)]",children:E.map(f=>e.jsx("button",{type:"button",onMouseDown:K=>{var k;K.preventDefault(),Wt(f),(k=It.current)==null||k.focus()},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:f},f))})]}),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:be?"var(--danger)":"var(--text-muted)"},children:be??(o?`${d.length||1} filtro${(d.length||1)===1?"":"s"} activo${(d.length||1)===1?"":"s"}`:"Enter aplica la consulta. Shift + Enter agrega linea.")}),d.map(f=>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:[f.label,":"]}),e.jsx("span",{className:"truncate",children:f.value})]},f.key))]}),Ra&&$r.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(v.HiClock,{className:"h-3.5 w-3.5"}),"Historial"]}),e.jsxs("button",{type:"button",onClick:()=>{Lr([]),pr(!1)},className:"inline-flex items-center gap-1 rounded px-2 py-0.5 text-xs text-[var(--text-muted)]",children:[e.jsx(v.HiTrash,{className:"h-3 w-3"}),"Limpiar"]})]}),$r.map(f=>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",onClick:()=>st(f),className:"min-w-0 flex-1 text-left",children:e.jsx("code",{className:"block truncate text-xs text-[var(--primary)]",children:f})}),e.jsx("button",{type:"button",onClick:()=>Lr(K=>K.filter(k=>k!==f)),className:"rounded p-1 text-[var(--text-muted)] opacity-0 transition-opacity group-hover:opacity-100",children:e.jsx(v.HiXMark,{className:"h-3.5 w-3.5"})})]},f))]}),Qa&&w.length>0&&e.jsx("div",{className:"grid gap-2 sm:grid-cols-2 lg:grid-cols-3",children:w.map(f=>e.jsxs("button",{type:"button",onClick:()=>{var K;Wt(f.bql),fr(!1),(K=It.current)==null||K.focus()},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:f.bql}),f.description&&e.jsx("span",{className:"mt-1 block text-xs text-[var(--text-muted)]",children:f.description})]},f.bql))}),e.jsxs("div",{className:"flex items-center justify-end gap-2 border-t border-[var(--border)] pt-3",children:[o&&e.jsxs("button",{type:"button",onClick:bn,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(v.HiXMark,{className:"h-3.5 w-3.5"}),"Limpiar"]}),e.jsxs("button",{type:"button",onClick:()=>st(Rr),className:"inline-flex h-8 items-center gap-1.5 rounded-md bg-[var(--primary)] px-4 text-xs font-semibold text-[var(--primary-fg)] transition-opacity hover:opacity-90",children:[e.jsx(v.HiCheck,{className:"h-3.5 w-3.5"}),"Aplicar"]})]})]}),document.body)]})]}),Se&&e.jsx("button",{ref:tt,type:"button","aria-haspopup":"menu","aria-expanded":Tr,"aria-label":"Exportar datos",title:"Exportar datos",onClick:()=>{var K;const f=(K=tt.current)==null?void 0:K.getBoundingClientRect();f&&Ts({top:f.bottom+4,right:window.innerWidth-f.right}),rt(k=>!k)},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)] ${Tr?"bg-[var(--bg-card)] text-[var(--primary)]":""}`,children:e.jsx(v.HiArrowDownTray,{className:"h-4 w-4"})}),D&&e.jsx("button",{type:"button","aria-haspopup":"menu","aria-expanded":Re&&lr==="visibility","aria-label":oe,title:oe,onClick:f=>pn(f,"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)] ${Re&&lr==="visibility"?"bg-[var(--bg-card)] text-[var(--primary)]":""}`,children:e.jsx(v.HiCog6Tooth,{className:"h-4 w-4"})})]})},Cn=()=>{if(!Qs)return null;const o=Nl(De,Kt);return e.jsxs("div",{"aria-busy":n,className:`grid grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)] items-center gap-2 rounded-b-xl border-t text-xs select-none ${i?"px-2 py-0.5":"px-3 py-1"}`,style:{borderColor:"var(--border)",background:"var(--bg-input)"},children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{style:{color:"var(--text-muted)"},children:xr===0?"0 filas":`${Rs}–${ei} de ${xr}`}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{style:{color:"var(--text-muted)"},children:"Filas:"}),e.jsx(rr,{value:String(Ue),onChange:d=>ri(Number(d)),options:Q.map(d=>({value:String(d),label:String(d)})),placeholder:"Filas",searchable:!1,disabled:n,height:W,padding:J,className:"shrink-0 [&>button]:rounded-md [&>button]:text-xs [&_svg]:h-3.5 [&_svg]:w-3.5",style:{width:re}})]})]}),e.jsxs("div",{className:"flex items-center justify-center gap-0.5",children:[e.jsx("button",{disabled:n||De<=1,onClick:()=>Gt(De-1),onMouseEnter:d=>{d.currentTarget.disabled||(d.currentTarget.style.background="color-mix(in srgb, var(--primary) 14%, var(--bg-card))",d.currentTarget.style.color="var(--primary)")},onMouseLeave:d=>{d.currentTarget.style.background="transparent",d.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(v.HiChevronLeft,{className:"h-3.5 w-3.5"})}),o.map((d,E)=>d==="..."?e.jsx("span",{className:"px-1",style:{color:"var(--text-muted)"},children:"…"},`e${E}`):e.jsx("button",{disabled:n,onClick:()=>Gt(d),onMouseEnter:f=>{f.currentTarget.disabled||d===De||(f.currentTarget.style.background="color-mix(in srgb, var(--primary) 14%, var(--bg-card))",f.currentTarget.style.color="var(--primary)")},onMouseLeave:f=>{f.currentTarget.style.background=d===De?"var(--primary)":"transparent",f.currentTarget.style.color=d===De?"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:d===De?"var(--primary)":"transparent",color:d===De?"var(--primary-fg)":"var(--text-muted)"},children:d},d)),e.jsx("button",{disabled:n||De>=Kt,onClick:()=>Gt(De+1),onMouseEnter:d=>{d.currentTarget.disabled||(d.currentTarget.style.background="color-mix(in srgb, var(--primary) 14%, var(--bg-card))",d.currentTarget.style.color="var(--primary)")},onMouseLeave:d=>{d.currentTarget.style.background="transparent",d.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(v.HiChevronRight,{className:"h-3.5 w-3.5"})})]}),e.jsx("div",{"aria-hidden":"true"})]})},En=()=>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:ut},children:[pt(),ht(),vt(),e.jsx("div",{ref:er,className:"min-w-0 max-w-full overflow-hidden",children:e.jsxs("div",{role:"table",className:"text-sm",style:{width:Br,minWidth:bt},children:[e.jsx("div",{role:"rowgroup",style:L?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:ft()}),e.jsx("div",{role:"rowgroup",children:Array.from({length:Math.min(6,s)}).map((o,d)=>e.jsxs("div",{role:"row",className:"grid",style:{gridTemplateColumns:wr,borderBottom:`1px solid ${xe}`},children:[Ve&&e.jsx("div",{role:"cell",className:`${i?"px-2 py-1.5":"px-3 py-2"} w-10`,style:{borderBottom:`1px solid ${xe}`,borderRight:`1px solid ${xe}`}},"select-cell"),qe.map((E,f)=>e.jsx("div",{role:"cell",className:i?"px-2 py-1.5":"px-3 py-2",style:{borderBottom:`1px solid ${xe}`,borderRight:`1px solid ${xe}`},children:e.jsx("div",{className:"h-3.5 rounded-full animate-pulse",style:{background:"var(--border)",width:`${an(d,f)}%`,minWidth:32}})},E.key))]},d))})]})})]}),Xt="min-w-0 max-w-full overflow-hidden";return _&&!$e&&t.length===0||!n&&t.length===0&&!Ft?En():n&&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:ut},children:[pt(),ht(),vt(),e.jsx("div",{ref:er,className:Xt,children:e.jsx(Qt.OverlayScrollbarsComponent,{options:{scrollbars:{autoHide:"leave",autoHideDelay:200}},className:"w-full",style:{maxHeight:ln,maxWidth:"100%"},defer:!0,children:e.jsxs("div",{role:"table",className:"text-sm",style:{width:Br,minWidth:bt},children:[e.jsx("div",{role:"rowgroup",style:L?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:ft()}),e.jsx("div",{role:"rowgroup",children:Array.from({length:s}).map((o,d)=>e.jsxs("div",{role:"row",className:"grid",style:{gridTemplateColumns:wr,borderBottom:`1px solid ${xe}`},children:[Ve&&e.jsx("div",{role:"cell",className:`${i?"px-2 py-1.5":"px-3 py-2"} w-10`,style:{borderBottom:`1px solid ${xe}`,borderRight:`1px solid ${xe}`}},"select-cell"),qe.map((E,f)=>{const K=le&&!Pt&&f===0;return e.jsx("div",{role:"cell","data-dt-column-key":E.key,className:i?"px-2 py-1.5":"px-3 py-2",style:K?{position:"sticky",left:Vt,zIndex:1,background:"color-mix(in srgb, var(--bg-card) 72%, transparent)",backdropFilter:"blur(10px)",WebkitBackdropFilter:"blur(10px)",boxShadow:`3px 0 6px -2px rgba(0,0,0,0.10), inset 0 -1px 0 ${xe}`,borderRight:`1px solid ${xe}`}:{borderBottom:`1px solid ${xe}`,borderRight:`1px solid ${xe}`},children:e.jsx("div",{className:"h-3.5 rounded-full animate-pulse",style:{background:"var(--border)",width:`${an(d,f)}%`,minWidth:32}})},E.key)})]},d))})]})})}),Cn()]}):!n&&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:ut},children:[pt(),ht(),vt(),e.jsx("div",{ref:er,className:Xt,children:e.jsx("div",{role:"table",className:"text-sm",style:{width:Br,minWidth:bt},children:e.jsx("div",{role:"rowgroup",style:L?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:ft()})})}),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:xe,background:"linear-gradient(180deg, color-mix(in srgb, var(--bg-input) 58%, transparent), var(--bg-card))"},children:[e.jsx("div",{className:"flex h-12 w-12 items-center justify-center rounded-full border",style:{borderColor:"color-mix(in srgb, var(--primary) 24%, var(--border))",background:"color-mix(in srgb, var(--primary) 8%, var(--bg-card))",color:"var(--primary)"},children:c??e.jsx(v.HiMagnifyingGlass,{className:"h-5 w-5"})}),e.jsx("p",{className:"max-w-sm text-sm font-medium",style:{color:"var(--text-main)"},children:u}),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:ut},children:[pt(),ht(),vt(),e.jsx("div",{ref:er,className:Xt,children:e.jsx(Qt.OverlayScrollbarsComponent,{options:{scrollbars:{autoHide:"leave",autoHideDelay:200}},className:"w-full",style:{maxHeight:ln,maxWidth:"100%"},defer:!0,children:e.jsxs("div",{role:"table",className:"text-sm",style:{width:Br,minWidth:bt},children:[e.jsx("div",{role:"rowgroup",style:L?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:ft()}),e.jsx("div",{role:"rowgroup",children:vn.map((o,d)=>{const E=a(o),f=Nn(X==null?void 0:X(o)),K=d>0?Nn(X==null?void 0:X(vn[d-1])):null,k=f&&f.key!==(K==null?void 0:K.key),ce=Ve&&N.has(E),j=gr?(h==null?void 0:h(o))??!0:!1,Ee=j&&hn.has(E),Ne=!!p||C&&j,he=ce&&ee?"color-mix(in srgb, var(--primary) 8%, var(--bg-card))":d%2===1?"color-mix(in srgb, var(--bg-input) 30%, var(--bg-card))":"var(--bg-card)";return e.jsxs(l.Fragment,{children:[k&&e.jsx("div",{role:"row",className:`grid ${f.className??""}`,style:{gridTemplateColumns:wr},children:e.jsx("div",{role:"cell",className:i?"px-2 py-2":"px-3 py-3",style:{gridColumn:"1 / -1",background:"color-mix(in srgb, var(--primary) 8%, var(--bg-input))",borderBottom:`1px solid ${xe}`,borderRight:`1px solid ${xe}`},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:f.label}),f.description&&e.jsx("div",{className:"mt-0.5 truncate text-xs text-[var(--text-muted)]",children:f.description})]})})})}),e.jsxs("div",{role:"row",onClick:Ne?ge=>{const ve=ge.target;if(!(ve!=null&&ve.closest('[data-dt-disable-row-click="true"]'))){if(C&&j){gn(E);return}p==null||p(o)}}:void 0,className:`grid transition-colors ${Ne?"cursor-pointer":""} ${z?z(o):""}`,style:{gridTemplateColumns:wr,"--dt-row-bg":he,"--dt-sticky-bg":he,background:"var(--dt-row-bg)",borderBottom:`1px solid ${xe}`},onMouseEnter:ge=>{ce||(ge.currentTarget.style.setProperty("--dt-row-bg","var(--bg-hover)"),ge.currentTarget.style.setProperty("--dt-sticky-bg",ti))},onMouseLeave:ge=>{ge.currentTarget.style.setProperty("--dt-row-bg",he),ge.currentTarget.style.setProperty("--dt-sticky-bg",he)},children:[gr&&e.jsx("div",{role:"cell",className:`${i?"px-2 py-1.5":"px-3 py-2"} flex w-10 items-center justify-center`,style:{borderBottom:`1px solid ${xe}`,borderRight:`1px solid ${xe}`},"data-dt-disable-row-click":"true",children:j&&e.jsx("button",{type:"button","aria-label":Ee?"Contraer fila":"Desplegar fila","aria-expanded":Ee,onClick:ge=>{ge.stopPropagation(),gn(E)},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:Ee?e.jsx(v.HiChevronDown,{className:"h-4 w-4"}):e.jsx(v.HiChevronRight,{className:"h-4 w-4"})})}),Ve&&e.jsx("div",{role:"cell",className:`${i?"px-2 py-1.5":"px-3 py-2"} w-10`,style:le?{position:"sticky",left:0,zIndex:3,background:"var(--dt-sticky-bg)",boxShadow:`inset 0 -1px 0 ${xe}`}:{borderBottom:`1px solid ${xe}`,borderRight:`1px solid ${xe}`},onClick:ge=>{ge.stopPropagation(),S(E)},children:e.jsx(Fr,{size:"sm",checked:ce,"aria-label":"Seleccionar fila",containerClassName:"items-center",className:"cursor-pointer",onClick:ge=>ge.stopPropagation(),onChange:()=>S(E)})}),qe.map((ge,ve)=>{const He=le&&!Pt&&ve===0,ye=ar(ge);return e.jsx("div",{role:"cell","data-dt-column-key":ge.key,"data-dt-disable-row-click":ge.disableRowClick||ye?"true":void 0,className:`${ye?"px-2 py-1.5 text-center":`${i?"px-2 py-1.5":"px-3 py-2"} ${xn(ge.align)}`} ${ml} ${ge.className??""}`,style:{overflow:"hidden",whiteSpace:"nowrap",...He?{position:"sticky",left:Vt,zIndex:3,background:"var(--dt-sticky-bg)",boxShadow:`3px 0 6px -2px rgba(0,0,0,0.10), inset 0 -1px 0 ${xe}`,borderRight:`1px solid ${xe}`}:{borderBottom:`1px solid ${xe}`,borderRight:`1px solid ${xe}`}},children:e.jsx(pa,{children:e.jsx("div",{"data-dt-autofit-content":!0,className:"inline-block max-w-none align-middle",children:ge.cell(o)})})},ge.key)})]}),Ee&&m&&e.jsx("div",{role:"row",className:"grid",style:{gridTemplateColumns:wr},children:e.jsx("div",{role:"cell",className:i?"px-2 py-2":"px-3 py-3",style:{gridColumn:"1 / -1",background:"color-mix(in srgb, var(--bg-input) 60%, var(--bg-card))",borderBottom:`1px solid ${xe}`},children:m(o)})})]},E)})})]})})}),Cn()]})}const Cl={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 El(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 a=Cl[t.preset];if(!a.pattern.test(r))return t.message??a.message}return t.pattern&&!t.pattern.test(r)?t.message??"Formato inválido":null}const Ml=new Set(["Backspace","Delete","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Tab","Home","End","Enter","Escape"]);function $l({initialValue:r,type:t,mask:a,onCommit:n,onCancel:s}){const[c,u]=l.useState(r),b=l.useRef(null),p=(a==null?void 0:a.preset)==="date",m=p?"date":t==="number"?"number":"text";return l.useEffect(()=>{var h,x;(h=b.current)==null||h.focus(),p||(x=b.current)==null||x.select()},[p]),e.jsx("input",{ref:b,type:m,value:c,maxLength:a==null?void 0:a.maxLength,onChange:h=>u(h.target.value),onBlur:()=>s(),onKeyDown:h=>{h.key==="Enter"&&(h.preventDefault(),n(c)),h.key==="Escape"&&(h.preventDefault(),s()),(a==null?void 0:a.preset)==="integer"&&!h.ctrlKey&&!h.metaKey&&!Ml.has(h.key)&&!/^[\d-]$/.test(h.key)&&h.preventDefault()},onClick:h=>h.stopPropagation(),className:"w-full min-w-0 border-0 bg-transparent p-0 text-sm text-[var(--text-main)] outline-none"})}function Ll({initialValue:r,options:t,loading:a,onCommit:n,onCancel:s}){const c=l.useRef(null),[u,b]=l.useState(r);return l.useEffect(()=>{if(a)return;const p=setTimeout(()=>{var m,h;(h=(m=c.current)==null?void 0:m.querySelector("button"))==null||h.click()},0);return()=>clearTimeout(p)},[a]),e.jsx("div",{ref:c,className:"w-full",tabIndex:-1,onKeyDown:p=>{p.key==="Escape"&&(p.stopPropagation(),s()),p.key==="Enter"&&(p.preventDefault(),p.stopPropagation(),n(u))},children:e.jsx(rr,{value:u,onChange:p=>{b(p),setTimeout(()=>{var m;return(m=c.current)==null?void 0:m.focus({preventScroll:!0})},0)},options:t,disabled:a,placeholder:a?"Cargando…":"Seleccionar…",triggerVariant:"ghost",height:30,padding:"0 6px",minOptionsForSearch:1,className:"w-full"})})}const Tl={outline:"2px solid var(--primary)",outlineOffset:"-2px",borderRadius:"4px",background:"color-mix(in srgb, var(--primary) 5%, var(--bg-card))"},ha={outline:"2px solid var(--primary)",outlineOffset:"-2px",borderRadius:"4px"};function Al({columns:r,data:t,getRowId:a,onCellUpdate:n,readOnly:s=!1,...c}){const[u,b]=l.useState(t),p=l.useRef(null);l.useEffect(()=>{p.current||b(t)},[t]);const[m,h]=l.useState(null);p.current=m;const[x,g]=l.useState(null),$=l.useRef(null);$.current=x;const[C,N]=l.useState({}),[S,B]=l.useState({}),[ee,z]=l.useState({}),X=l.useRef(new Set),L=l.useRef(null);l.useEffect(()=>{var y;const i=document.activeElement;(!i||i===document.body)&&((y=L.current)==null||y.focus({preventScroll:!0}))},[]);const U=r.map(i=>{var y,M,O;return`${i.key}:${((O=(M=(y=i.editable)==null?void 0:y.select)==null?void 0:M.options)==null?void 0:O.length)??-1}`}).join("|");l.useEffect(()=>{r.forEach(i=>{var O,D;const y=(D=(O=i.editable)==null?void 0:O.select)==null?void 0:D.options;if(!y)return;const M=S[i.key];(!X.current.has(i.key)||(M==null?void 0:M.length)===0&&y.length>0)&&(X.current.add(i.key),B(ae=>({...ae,[i.key]:y})))})},[U]);const Q=l.useCallback(async(i,y)=>{if(X.current.has(i))return;X.current.add(i);const{url:M,fetchOptions:O}=y.select??{};if(!(!M&&!O)){z(D=>({...D,[i]:!0}));try{let D=[];if(O)D=await O();else if(M){const ae=await fetch(M);if(!ae.ok)throw new Error("fetch failed");D=await ae.json()}B(ae=>({...ae,[i]:D}))}catch{B(D=>({...D,[i]:[]}))}finally{z(D=>({...D,[i]:!1}))}}},[]),re=l.useRef(u);re.current=u;const W=l.useRef(n);W.current=n;const J=l.useRef(a);J.current=a;const R=l.useRef(r);R.current=r;const T=l.useRef(s);T.current=s,l.useEffect(()=>{if(r.length>0&&t.length>0){const i=r.find(y=>y.selectable!==!1);i&&g({rowId:a(t[0]),colKey:i.key})}},[]),l.useEffect(()=>{if(!x)return;const i=L.current;if(!i)return;const y=i.querySelector(`[data-cell-id="${x.rowId}:${x.colKey}"]`);if(!y)return;const M=i.querySelector('[role="rowgroup"]');y.style.scrollMarginTop=`${(M==null?void 0:M.offsetHeight)??0}px`;const O=i.querySelector('[role="row"]');let D=0;O&&O.querySelectorAll('[role="cell"], [role="columnheader"]').forEach(ae=>{ae.style.position==="sticky"&&ae.style.left!==""&&(D=Math.max(D,parseFloat(ae.style.left)+ae.offsetWidth))}),y.style.scrollMarginLeft=`${D}px`,y.scrollIntoView({block:"nearest",inline:"nearest"})},[x]);const P=l.useCallback(i=>{var D;const y=R.current,M=new Set,O=[];(D=L.current)==null||D.querySelectorAll("[data-cell-id]").forEach(ae=>{const ie=ae.dataset.cellId.split(":")[0];M.has(ie)||(M.add(ie),O.push(ie))}),g(ae=>{if(!ae)return ae;const ie=y.findIndex(F=>F.key===ae.colKey),pe=O.indexOf(ae.rowId);let A=ie,oe=pe;if(i==="up")oe=Math.max(0,pe-1);else if(i==="down")oe=Math.min(O.length-1,pe+1);else if(i==="left"){let F=ie-1;for(;F>=0&&y[F].selectable===!1;)F--;F>=0&&(A=F)}else if(i==="right"){let F=ie+1;for(;F<y.length&&y[F].selectable===!1;)F++;F<y.length&&(A=F)}return A===ie&&oe===pe?ae:{rowId:O[oe],colKey:y[A].key}})},[]),V=l.useCallback((i=!0)=>{const y=p.current;h(null),y&&g(y),i&&setTimeout(()=>{var M;return(M=L.current)==null?void 0:M.focus({preventScroll:!0})},0)},[]),_=l.useCallback(async(i,y,M)=>{var se;const O=R.current.find(w=>w.key===y);if(!(O!=null&&O.editable))return;const{field:D,type:ae,mask:ie,validate:pe}=O.editable,A=ae==="number"?M===""?null:Number(M):M;if(ie){const w=El(M,ie);if(w){N(I=>({...I,[`${i}:${y}`]:w}));return}}if(pe){const w=pe(A);if(w){N(I=>({...I,[`${i}:${y}`]:w}));return}}const oe=J.current,F=re.current.find(w=>oe(w)===i);if(!F)return;const H=F[D];h(null),N(w=>{const I={...w};return delete I[`${i}:${y}`],I});const Z=re.current,G=Z.findIndex(w=>oe(w)===i),te=Z[Math.min(Z.length-1,G+1)];if(g({rowId:oe(te),colKey:y}),setTimeout(()=>{var I,de;const w=document.activeElement;(!w||w===document.body||(I=L.current)!=null&&I.contains(w))&&((de=L.current)==null||de.focus({preventScroll:!0}))},0),String(H??"")===String(A??""))return;const ue={...F,[D]:A};b(w=>w.map(I=>oe(I)===i?ue:I));try{await((se=W.current)==null?void 0:se.call(W,{row:F,rowId:i,field:D,oldValue:H,newValue:A}))}catch{b(w=>w.map(I=>oe(I)===i?F:I)),N(w=>({...w,[`${i}:${y}`]:"Error al guardar. Intenta de nuevo."}))}},[]),le=l.useCallback(i=>{if(p.current)return;const y=$.current;if(!(!y||!["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Enter","Escape","Tab"].includes(i.key)))switch(i.preventDefault(),i.key){case"ArrowUp":P("up");break;case"ArrowDown":P("down");break;case"ArrowLeft":P("left");break;case"ArrowRight":P("right");break;case"Tab":P(i.shiftKey?"left":"right");break;case"Enter":{const O=R.current.find(D=>D.key===y.colKey);O!=null&&O.editable&&!T.current?(h(y),O.editable.type==="select"&&!X.current.has(y.colKey)&&Q(y.colKey,O.editable)):P("down");break}}},[P,Q]),q=l.useMemo(()=>r.map(i=>{if(!i.editable||s){const{editable:M,selectable:O,...D}=i;if(i.selectable===!1)return{...D,disableRowClick:!0};const ae=D.cell;return{...D,className:`relative ${D.className??""}`.trim(),disableRowClick:!0,cell:ie=>{const pe=a(ie),A=(x==null?void 0:x.rowId)===pe&&(x==null?void 0:x.colKey)===i.key;return e.jsxs(e.Fragment,{children:[e.jsx("span",{"data-cell-id":`${pe}:${i.key}`,className:"absolute inset-0 z-10 cursor-default",onClick:()=>{var oe;g({rowId:pe,colKey:i.key}),(oe=L.current)==null||oe.focus({preventScroll:!0})}}),A&&e.jsx("div",{className:"pointer-events-none absolute inset-0 z-20",style:ha}),e.jsx("span",{className:"relative z-0 pointer-events-none",children:ae(ie)})]})}}}const y=i.editable;return{...i,className:`relative ${i.className??""}`.trim(),disableRowClick:!0,cell:M=>{const O=a(M),D=i.key,ae=(m==null?void 0:m.rowId)===O&&(m==null?void 0:m.colKey)===D,ie=(x==null?void 0:x.rowId)===O&&(x==null?void 0:x.colKey)===D,pe=C[`${O}:${D}`],A=M[y.field],oe=String(A??""),F=()=>{var Z;g({rowId:O,colKey:D}),h({rowId:O,colKey:D}),(Z=L.current)==null||Z.focus({preventScroll:!0}),y.type==="select"&&!X.current.has(D)&&Q(D,y)};if(ae){const Z=y.type==="select"?e.jsx(Ll,{initialValue:oe,options:S[D]??[],loading:ee[D]??!1,onCommit:G=>_(O,D,G),onCancel:V}):e.jsx($l,{initialValue:oe,type:y.type??"text",mask:y.mask,onCommit:G=>_(O,D,G),onCancel:V});return e.jsx("div",{className:"absolute inset-0 flex items-center px-2",style:Tl,onClick:G=>G.stopPropagation(),children:Z})}const H=i.cell(M);return e.jsxs(e.Fragment,{children:[e.jsx("span",{"data-cell-id":`${O}:${D}`,className:"peer absolute inset-0 z-10 cursor-pointer",onClick:F}),ie&&e.jsx("div",{className:"pointer-events-none absolute inset-0 z-20",style:ha}),e.jsx("span",{className:"relative z-0 inline-flex items-center gap-1 pointer-events-none",children:pe?e.jsxs("span",{className:"flex items-center gap-1 text-red-500",children:[e.jsx(v.HiExclamationCircle,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"truncate text-xs",children:pe})]}):e.jsx("span",{className:"truncate",children:H})}),e.jsx(v.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,m,x,C,S,ee,a,_,V,Q]);return e.jsx("div",{ref:L,tabIndex:0,onKeyDown:le,onBlur:i=>{var y;(y=L.current)!=null&&y.contains(i.relatedTarget)||setTimeout(()=>{var O,D;const M=document.activeElement;M&&((O=M.closest)!=null&&O.call(M,"[data-bonsaif-select-dropdown]"))||(D=L.current)!=null&&D.contains(M)||V(!1)},0)},style:{width:"100%",minWidth:0,outline:"none"},children:e.jsx(ma,{...c,columns:q,data:u,getRowId:a})})}function kr(r){return r?new Date(`${r}T12:00:00`):void 0}function va(r){return r.toISOString().slice(0,10)}function Hl({calendarMonth:r,displayIndex:t}){const{previousMonth:a,nextMonth:n,goToMonth:s,months:c,labels:u,formatters:b}=Rt.useDayPicker(),p=!!a&&t===0,m=!!n&&t===c.length-1;return e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",gap:8,width:"100%",color:"var(--text-main)",marginBottom:6},children:[e.jsx("span",{style:{fontWeight:700},children:b.formatCaption(r.date)}),e.jsx("button",{type:"button","aria-label":u.labelPrevious(a),onClick:()=>a&&s(a),disabled:!p,style:{height:28,width:28,borderRadius:8,border:"1px solid var(--border)",background:"var(--bg-card)",display:"inline-flex",alignItems:"center",justifyContent:"center",color:"var(--text-main)",opacity:p?1:.45,cursor:p?"pointer":"not-allowed"},children:e.jsx(v.HiChevronLeft,{size:16})}),e.jsx("button",{type:"button","aria-label":u.labelNext(n),onClick:()=>n&&s(n),disabled:!m,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:m?1:.45,cursor:m?"pointer":"not-allowed"},children:e.jsx(v.HiChevronRight,{size:16})})]})}function Dl(r){return r.charAt(0).toUpperCase()+r.slice(1)}function Bl({startDate:r,endDate:t,onChange:a,minDate:n,viewMonth:s,numberOfMonths:c=1,showSummary:u=!0,startLabel:b="Inicio",endLabel:p="Regreso"}){const m={from:kr(r),to:kr(t)},h=kr(n),[x,g]=l.useState(kr(s||r));return l.useEffect(()=>{g(kr(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(Rt.DayPicker,{mode:"range",selected:m,month:x,onMonthChange:g,onSelect:$=>{const C=$!=null&&$.from?va($.from):r,N=$!=null&&$.to?va($.to):"";a({startDate:C,endDate:N})},numberOfMonths:c,hideNavigation:!0,disabled:h?{before:h}:void 0,showOutsideDays:!1,components:{MonthCaption:Hl},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:$=>Dl(new Intl.DateTimeFormat("es-MX",{month:"long",year:"numeric"}).format($)),formatWeekdayName:$=>new Intl.DateTimeFormat("es-MX",{weekday:"short"}).format($)},labels:{labelMonthDropdown:()=>"Mes",labelYearDropdown:()=>"Año"}})}),u&&r&&e.jsxs("div",{style:{marginTop:8,fontSize:12,color:"var(--text-muted)",display:"flex",gap:8,flexWrap:"wrap"},children:[e.jsxs("span",{children:[b,":"," ",e.jsx("strong",{style:{color:"var(--text-main)"},children:r})]}),t&&e.jsxs("span",{children:[p,":"," ",e.jsx("strong",{style:{color:"var(--text-main)"},children:t})]})]})]})}const Il="bonsaif-ui:hide-tooltips";function ga(){window.dispatchEvent(new CustomEvent(Il))}function Ol(r){if(r!==void 0)return typeof r=="number"?`${r}px`:r}function Fl({trigger:r,items:t,align:a="end",width:n=220,disabled:s=!1,className:c="",menuClassName:u="",onOpenChange:b}){const[p,m]=l.useState(!1),[h,x]=l.useState(!1),[g,$]=l.useState({}),C=l.useRef(null),N=l.useRef(null),S=l.useCallback(L=>{m(L),b==null||b(L)},[b]),B=l.useCallback(()=>{const L=C.current;if(!L)return;const U=L.getBoundingClientRect(),Q=typeof n=="number"?n:U.width,re=typeof n=="number"?n:Math.max(U.width,180),W=a==="end"?Math.max(8,U.right-re):Math.min(U.left,window.innerWidth-re-8),J=window.innerHeight-U.bottom,R=J<240&&U.top>J?void 0:U.bottom+6,T=R===void 0?window.innerHeight-U.top+6:void 0;$({position:"fixed",zIndex:9999,left:W,top:R,bottom:T,width:Ol(typeof n=="number"?Q:n)})},[a,n]);l.useEffect(()=>x(!0),[]),l.useEffect(()=>{if(!p)return;B();const L=Q=>{var W,J;const re=Q.target;!((W=C.current)!=null&&W.contains(re))&&!((J=N.current)!=null&&J.contains(re))&&S(!1)},U=Q=>{Q.key==="Escape"&&S(!1)};return document.addEventListener("mousedown",L),window.addEventListener("keydown",U),window.addEventListener("resize",B),window.addEventListener("scroll",B,!0),()=>{document.removeEventListener("mousedown",L),window.removeEventListener("keydown",U),window.removeEventListener("resize",B),window.removeEventListener("scroll",B,!0)}},[p,S,B]);const ee=L=>{s||(L.key==="Enter"||L.key===" ")&&(L.preventDefault(),S(!p))},z=l.isValidElement(r)?l.cloneElement(r,{onClick:()=>{s||(ga(),S(!p))}}):r,X=p?e.jsx("div",{ref:N,role:"menu","data-bonsaif-overlay":"true",className:`overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-1 shadow-xl ${u}`,style:g,children:t.map(L=>e.jsxs("div",{children:[L.separatorBefore&&e.jsx("div",{className:"my-1 border-t border-[var(--border)]"}),e.jsxs("button",{type:"button",role:"menuitem",disabled:L.disabled,onClick:()=>{var U;L.disabled||(ga(),(U=L.onSelect)==null||U.call(L),S(!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:L.danger?"var(--danger)":"var(--text-main)"},children:[L.icon&&e.jsx("span",{className:"mt-0.5 shrink-0",children:L.icon}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block truncate text-sm font-medium",children:L.label}),L.description&&e.jsx("span",{className:"block truncate text-xs text-[var(--text-muted)]",children:L.description})]})]})]},L.id))}):null;return e.jsxs("span",{ref:C,role:"button",tabIndex:s?-1:0,"aria-haspopup":"menu","aria-expanded":p,onKeyDown:ee,className:`inline-flex ${s?"pointer-events-none opacity-60":""} ${c}`,children:[z,h&&X?je.createPortal(X,document.body):null]})}const Pl=180,xa="bg-[color-mix(in_srgb,var(--bg-main)_72%,transparent)] backdrop-blur-sm";function zl({open:r,onClose:t,title:a,subtitle:n,leadingIcon:s,confirmLabel:c="Guardar",onConfirm:u,loading:b=!1,confirmDisabled:p=!1,headerActions:m,bodyClassName:h="flex-1 overflow-y-auto px-6 py-5",width:x=440,hasUnsavedChanges:g=!1,unsavedChangesTitle:$="Descartar cambios",unsavedChangesDescription:C="Hay cambios sin guardar. Si cierras el drawer se perderán.",unsavedChangesConfirmLabel:N="Descartar",unsavedChangesCancelLabel:S="Seguir editando",onDiscardChanges:B,disabled:ee=!1,children:z}){const[X,L]=l.useState(!1),[U,Q]=l.useState(!1),[re,W]=l.useState(!1),J=l.useCallback(()=>{Q(!0),requestAnimationFrame(()=>{requestAnimationFrame(()=>W(!0))})},[]),R=l.useCallback(()=>{W(!1),window.setTimeout(()=>Q(!1),Pl)},[]),T=l.useCallback(()=>{if(g){J();return}t()},[g,t,J]),P=l.useCallback(()=>{W(!1),Q(!1),B==null||B(),t()},[t,B]);return l.useEffect(()=>{L(!0)},[]),l.useEffect(()=>(document.body.style.overflow=r?"hidden":"",r||(W(!1),Q(!1)),()=>{document.body.style.overflow=""}),[r]),l.useEffect(()=>{if(!r)return;const V=_=>{if(_.key==="Escape"){if(U){R();return}T()}};return window.addEventListener("keydown",V),()=>window.removeEventListener("keydown",V)},[R,U,r,T]),X?je.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 ${xa}`,onClick:T}),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, ${x}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(Te,{variant:"icon",onClick:T,title:"Cerrar",children:e.jsx(v.HiXMark,{className:"w-5 h-5"})}),s&&e.jsx("div",{className:"flex-shrink-0",children:s}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h3",{className:"text-base font-semibold truncate",style:{color:"var(--text-main)"},children:a}),n&&e.jsx("p",{className:"text-xs truncate",style:{color:"var(--text-muted)"},children:n})]})]}),(m||u)&&e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[m,u&&e.jsxs(e.Fragment,{children:[e.jsx(Te,{variant:"secondary",size:"sm",onClick:T,style:{background:"var(--bg-input)"},children:"Cancelar"}),e.jsx(Te,{variant:"primary",size:"sm",icon:e.jsx($n.FiSave,{className:"w-4 h-4"}),onClick:u,loading:b,disabled:p,title:c})]})]})]}),e.jsx("div",{"data-drawer-scroll":"true",className:h,children:z})]}),ee&&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)"}}),U&&e.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":$,className:"fixed inset-0 z-[1001] flex items-center justify-center p-4",children:[e.jsx("div",{className:`absolute inset-0 ${xa} transition-opacity duration-200 ease-out ${re?"opacity-100":"opacity-0"}`,onClick:R}),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 ${re?"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(Te,{variant:"icon",onClick:R,className:"absolute right-3 top-3 h-7 w-7 hover:opacity-70",style:{color:"var(--text-muted, #6b7f78)"},"aria-label":S,children:e.jsx(v.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(v.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:$}),e.jsx("p",{className:"text-sm",style:{color:"var(--text-muted, #6b7f78)"},children:C}),e.jsxs("div",{className:"mt-6 flex gap-2",children:[e.jsx(Te,{variant:"secondary",onClick:R,className:"flex-1 border",style:{background:"var(--bg-input, #f7faf8)",borderColor:"var(--border, #d8e1dc)",color:"var(--text-main, #0f2f2c)"},children:S}),e.jsx(Te,{variant:"secondary",onClick:P,className:"flex-1 border",style:{background:"var(--warning, #d97706)",borderColor:"transparent",color:"#fff",boxShadow:"0 10px 22px rgba(217, 119, 6, 0.22)"},children:N})]})]})]})]}),document.body):null}const jl=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,_l=/^\+?[0-9\s().-]+$/,Wl=7,ql=15;function _e(r){return r==null||String(r).trim()===""}function ya(r){return typeof r=="number"?r:typeof r=="string"&&r.trim()!==""?Number(r):Number.NaN}function Ct(r){return _e(r)?!1:jl.test(String(r))}function Et(r){if(_e(r))return!1;const t=String(r),a=t.replace(/\D/g,"");return _l.test(t)&&a.length>=Wl&&a.length<=ql}function Ul(r="Este campo es requerido."){return t=>_e(t)?r:void 0}function Vl(r="Ingresa un correo valido."){return t=>_e(t)||Ct(t)?void 0:r}function Kl(r="Ingresa un telefono valido."){return t=>_e(t)||Et(t)?void 0:r}function Gl(r,t){return a=>_e(a)||String(a).length>=r?void 0:t??`Debe tener al menos ${r} caracteres.`}function Yl(r,t){return a=>_e(a)||String(a).length<=r?void 0:t??`Debe tener ${r} caracteres o menos.`}function Xl(r,t){return a=>{if(_e(a))return;const n=ya(a);return Number.isFinite(n)&&n>=r?void 0:t??`Debe ser mayor o igual a ${r}.`}}function Zl(r,t){return a=>{if(_e(a))return;const n=ya(a);return Number.isFinite(n)&&n<=r?void 0:t??`Debe ser menor o igual a ${r}.`}}function Jl(r,t="El formato no es valido."){return a=>_e(a)||r.test(String(a))?void 0:t}function Ql(r,t){const a={};for(const n of Object.keys(t)){const s=t[n];if(!s)continue;const c=Array.isArray(s)?s:[s];for(const u of c){const b=u(r[n],r);if(b){a[n]=b;break}}}return{valid:Object.keys(a).length===0,errors:a}}var wa={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},Na=l.createContext&&l.createContext(wa),Rl=["attr","size","title"];function eo(r,t){if(r==null)return{};var a,n,s=ro(r,t);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(r);for(n=0;n<c.length;n++)a=c[n],t.indexOf(a)===-1&&{}.propertyIsEnumerable.call(r,a)&&(s[a]=r[a])}return s}function ro(r,t){if(r==null)return{};var a={};for(var n in r)if({}.hasOwnProperty.call(r,n)){if(t.indexOf(n)!==-1)continue;a[n]=r[n]}return a}function Vr(){return Vr=Object.assign?Object.assign.bind():function(r){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var n in a)({}).hasOwnProperty.call(a,n)&&(r[n]=a[n])}return r},Vr.apply(null,arguments)}function ka(r,t){var a=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);t&&(n=n.filter(function(s){return Object.getOwnPropertyDescriptor(r,s).enumerable})),a.push.apply(a,n)}return a}function Kr(r){for(var t=1;t<arguments.length;t++){var a=arguments[t]!=null?arguments[t]:{};t%2?ka(Object(a),!0).forEach(function(n){to(r,n,a[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(a)):ka(Object(a)).forEach(function(n){Object.defineProperty(r,n,Object.getOwnPropertyDescriptor(a,n))})}return r}function to(r,t,a){return(t=ao(t))in r?Object.defineProperty(r,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):r[t]=a,r}function ao(r){var t=no(r,"string");return typeof t=="symbol"?t:t+""}function no(r,t){if(typeof r!="object"||!r)return r;var a=r[Symbol.toPrimitive];if(a!==void 0){var n=a.call(r,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(r)}function Sa(r){return r&&r.map((t,a)=>l.createElement(t.tag,Kr({key:a},t.attr),Sa(t.child)))}function Mt(r){return t=>l.createElement(lo,Vr({attr:Kr({},r.attr)},t),Sa(r.child))}function lo(r){var t=a=>{var{attr:n,size:s,title:c}=r,u=eo(r,Rl),b=s||a.size||"1em",p;return a.className&&(p=a.className),r.className&&(p=(p?p+" ":"")+r.className),l.createElement("svg",Vr({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},a.attr,n,u,{className:p,style:Kr(Kr({color:r.color||a.color},a.style),r.style),height:b,width:b,xmlns:"http://www.w3.org/2000/svg"}),c&&l.createElement("title",null,c),r.children)};return Na!==void 0?l.createElement(Na.Consumer,null,a=>t(a)):t(wa)}function Ca(r){return Mt({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 oo(r){return Mt({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 so(r){return Mt({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 Gr({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 $t({label:r,containerClassName:t="",helperText:a,error:n,errorDisplay:s="inline",errorTooltipLabel:c="Error de validacion",labelAction:u,floatingLabel:b=!1,showPasswordToggle:p=!0,nativeValidation:m=!1,className:h="",required:x,...g}){const[$,C]=l.useState(()=>!!g.autoFocus),[N,S]=l.useState(!1),B=g.type==="password"&&p,ee=B&&N?"text":g.type,z=!!n,X=z&&s!=="tooltip",L=z&&s!=="inline",U=m?x:void 0,Q=z?"border-[var(--danger)] focus:border-[var(--danger)]":"",re=L?B?"pr-20":"pr-10":B?"pr-10":"",W=g.value!==void 0?String(g.value).length>0:g.defaultValue!==void 0&&String(g.defaultValue).length>0,J=$||W,R={top:J?7:12,color:$?"var(--primary)":"var(--text-muted)",fontSize:J?10:13,fontWeight:J?600:400,textTransform:J?"uppercase":"none"},T=le=>{var q;C(!0),(q=g.onFocus)==null||q.call(g,le)},P=le=>{var q;C(!1),(q=g.onBlur)==null||q.call(g,le)},V=B?e.jsxs("button",{type:"button","aria-label":N?"Ocultar contraseña":"Mostrar contraseña","aria-pressed":N,className:"absolute right-2.5 top-1/2 flex h-7 w-7 -translate-y-1/2 items-center justify-center rounded-md text-[var(--text-muted)] transition-colors duration-200 hover:text-[var(--primary)] focus:outline-none",tabIndex:-1,onClick:()=>S(le=>!le),children:[e.jsx("span",{"aria-hidden":"true",className:`absolute inset-0 flex items-center justify-center transition-[opacity,transform] duration-200 ease-out ${N?"scale-y-0 rotate-[-8deg] opacity-0":"scale-y-100 rotate-0 opacity-100"}`,children:e.jsx(oo,{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 ${N?"scale-y-100 rotate-0 opacity-100":"scale-y-0 rotate-[8deg] opacity-0"}`,children:e.jsx(so,{className:"h-[18px] w-[18px]"})})]}):null,_=L?e.jsx(dr,{as:"span",content:n,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)] ${B?"right-10":"right-2.5"}`,children:e.jsx("span",{tabIndex:0,role:"img","aria-label":c,className:"flex h-full w-full items-center justify-center outline-none",children:e.jsx(Ca,{className:"h-[18px] w-[18px]"})})}):null;return b?e.jsxs("label",{className:`flex flex-col gap-2 ${t}`,children:[e.jsxs("span",{className:"relative block",children:[e.jsx(Gr,{...g,type:ee,required:U,placeholder:" ","aria-invalid":z||g["aria-invalid"],"data-has-value":W?"true":void 0,className:`h-11 w-full pt-5 ${re} ${Q} ${h}`,onFocus:T,onBlur:P}),e.jsxs("span",{className:"pointer-events-none absolute left-3 transition-all duration-150",style:R,children:[r,x&&e.jsx("span",{className:"ml-1 text-[var(--danger)]",children:"*"})]}),u&&e.jsx("span",{className:"absolute right-2 transition-all duration-150",style:{top:J?7:12},children:u}),_,V]}),X?e.jsx("span",{className:"text-xs font-medium normal-case text-[var(--danger)]",children:n}):a?e.jsx("span",{className:"text-xs font-medium normal-case text-[var(--text-muted)]",children:a}):null]}):e.jsxs("label",{className:`flex flex-col gap-2 ${t}`,children:[e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-semibold uppercase text-[var(--text-muted)]",children:[e.jsx("span",{children:r}),x&&e.jsx("span",{className:"text-[var(--danger)]",children:"*"}),u&&e.jsx("span",{className:"ml-auto normal-case",children:u})]}),B?e.jsxs("span",{className:"relative block",children:[e.jsx(Gr,{...g,type:ee,required:U,"aria-invalid":z||g["aria-invalid"],className:`w-full ${re} ${Q} ${h}`,onFocus:T,onBlur:P}),_,V]}):e.jsxs("span",{className:"relative block",children:[e.jsx(Gr,{...g,required:U,"aria-invalid":z||g["aria-invalid"],className:`w-full ${re} ${Q} ${h}`}),_]}),X?e.jsx("span",{className:"text-xs font-medium normal-case text-[var(--danger)]",children:n}):a?e.jsx("span",{className:"text-xs font-medium normal-case text-[var(--text-muted)]",children:a}):null]})}function Ea(r){return r==null?"":String(r)}function io({autoComplete:r="email",inputMode:t="email",validate:a=!0,invalidMessage:n="Ingresa un correo valido.",errorDisplay:s="tooltip",error:c,value:u,defaultValue:b,onChange:p,...m}){const[h,x]=l.useState(()=>Ea(b)),g=u!==void 0?Ea(u):h,$=a&&g.length>0&&!Ct(g)?n:void 0,C=N=>{u===void 0&&x(N.currentTarget.value),p==null||p(N)};return e.jsx($t,{...m,value:u,defaultValue:b,type:"text",inputMode:t,autoComplete:r,error:c??$,errorDisplay:s,onChange:C})}const co={sm:"min-h-[160px] p-4",md:"min-h-[220px] p-6",lg:"min-h-[300px] p-8"};function uo({title:r="Sin resultados",description:t,icon:a=e.jsx(v.HiInbox,{className:"h-5 w-5"}),action:n,secondaryAction:s,size:c="md",className:u=""}){return e.jsx("div",{className:`flex items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-card)] text-center ${co[c]} ${u}`,children:e.jsxs("div",{className:"flex max-w-sm flex-col items-center gap-3",children:[a&&e.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-input)] text-[var(--text-muted)]",children:a}),e.jsxs("div",{className:"space-y-1",children:[r&&e.jsx("h3",{className:"text-sm font-semibold text-[var(--text-main)]",children:r}),t&&e.jsx("div",{className:"text-sm leading-5 text-[var(--text-muted)]",children:t})]}),(n||s)&&e.jsxs("div",{className:"mt-1 flex flex-wrap items-center justify-center gap-2",children:[s,n]})]})})}const bo={sm:"min-h-[112px] p-4",md:"min-h-[148px] p-5",lg:"min-h-[184px] p-6"};function fo(r){if(r===0)return"0 B";const t=["B","KB","MB","GB"],a=Math.min(Math.floor(Math.log(r)/Math.log(1024)),t.length-1),n=r/1024**a;return`${n>=10||a===0?n.toFixed(0):n.toFixed(1)} ${t[a]}`}function Ma(r,t){return t?t.split(",").map(a=>a.trim().toLowerCase()).filter(Boolean).some(a=>{const n=r.name.toLowerCase(),s=r.type.toLowerCase();return a.startsWith(".")?n.endsWith(a):a.endsWith("/*")?s.startsWith(a.slice(0,-1)):s===a}):!0}function po(r,t,a){return t?a===void 0?r:r.slice(0,Math.max(0,a)):r.slice(0,1)}function mo({label:r,helperText:t,error:a,labelAction:n,value:s,defaultValue:c=[],onFilesChange:u,onRejectedFiles:b,multiple:p=!1,maxFiles:m,appendFiles:h=!1,showFileList:x=!0,clearable:g=!0,browseLabel:$="Buscar archivos",dropLabel:C="Suelta los archivos aqui",emptyLabel:N="Arrastra y suelta archivos",emptyDescription:S="o haz click para buscarlos en tu equipo",selectedLabel:B="Archivos seleccionados",size:ee="md",containerClassName:z="",dropzoneClassName:X="",fileListClassName:L="",className:U="",id:Q,accept:re,disabled:W,required:J,...R}){const T=l.useId(),P=Q??T,V=l.useRef(null),[_,le]=l.useState(!1),[q,i]=l.useState(c),y=s??q,M=!!a,O=g&&y.length>0&&!W,D=(te,ue)=>{s===void 0&&i(te),u==null||u(te,ue)},ae=(te,ue)=>{const se=te.filter(be=>Ma(be,re)),w=te.filter(be=>!Ma(be,re)),I=h?[...y,...se]:se,de=po(I,p,m);w.length>0&&(b==null||b(w)),D(de,ue)},ie=()=>{var te;W||(te=V.current)==null||te.click()},pe=te=>{ae(Array.from(te.target.files??[]),te),te.target.value=""},A=te=>{te.preventDefault(),W||le(!0)},oe=te=>{te.currentTarget.contains(te.relatedTarget)||le(!1)},F=te=>{te.preventDefault(),le(!1),!W&&ae(Array.from(te.dataTransfer.files),te)},H=te=>{te.key!=="Enter"&&te.key!==" "||(te.preventDefault(),ie())},Z=te=>{D(y.filter((ue,se)=>se!==te))},G=()=>{D([])};return e.jsxs("div",{className:`flex flex-col gap-2 ${z}`,children:[(r||n)&&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:"*"}),n&&e.jsx("span",{className:"ml-auto normal-case",children:n})]}),e.jsx("input",{...R,ref:V,id:P,type:"file",accept:re,multiple:p,disabled:W,required:J&&y.length===0,"aria-invalid":M||R["aria-invalid"],className:"sr-only",onChange:pe}),e.jsxs("div",{role:"button",tabIndex:W?-1:0,"aria-controls":P,"aria-disabled":W||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)] ${bo[ee]} ${_?"border-[var(--primary)] bg-[var(--bg-input)]":M?"border-[var(--danger)]":"border-[var(--border)]"} ${W?"cursor-not-allowed opacity-60":"hover:border-[var(--primary)] hover:bg-[var(--bg-input)]"} ${X} ${U}`,onClick:ie,onDragOver:A,onDragLeave:oe,onDrop:F,onKeyDown:H,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(v.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:_?C:N}),S&&e.jsx("span",{className:"block text-sm text-[var(--text-muted)]",children:S})]}),$&&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:$})]}),x&&y.length>0&&e.jsxs("div",{className:`rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${L}`,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:B}),O&&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:G,children:e.jsx(v.HiTrash,{className:"h-4 w-4"})})]}),e.jsx("ul",{className:"divide-y divide-[var(--border)]",children:y.map((te,ue)=>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(v.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:te.name}),e.jsx("span",{className:"block text-xs text-[var(--text-muted)]",children:fo(te.size)})]}),!W&&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 ${te.name}`,onClick:()=>Z(ue),children:e.jsx(v.HiXMark,{className:"h-4 w-4"})})]},`${te.name}-${te.lastModified}-${ue}`))})]}),a?e.jsx("span",{className:"text-xs font-medium normal-case text-[var(--danger)]",children:a}):t?e.jsx("span",{className:"text-xs font-medium normal-case text-[var(--text-muted)]",children:t}):null]})}const ho=[{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 vo({fields:r,title:t="Layout",fieldTypes:a=ho,saveLabel:n="Guardar",allowAddField:s=!1,addFieldPlaceholder:c="Nuevo campo",addFieldLabel:u="Anadir",loading:b=!1,onSave:p,onChange:m}){const[h,x]=l.useState(()=>r.map(z=>({key:!1,type:"",...z}))),[g,$]=l.useState(""),[C,N]=l.useState(""),S=l.useCallback((z,X)=>{x(L=>{const U=L.map((Q,re)=>re===z?{...Q,...X}:Q);return m==null||m(U),U})},[m]),B=l.useCallback(()=>{p==null||p(h)},[h,p]),ee=l.useCallback(()=>{var U;const z=g.trim();if(!z){N("Ingresa un nombre de campo.");return}if(h.some(Q=>Q.name.toLowerCase()===z.toLowerCase())){N("Ese campo ya existe en el arreglo.");return}const L={name:z,key:!1,type:((U=a[0])==null?void 0:U.value)??""};x(Q=>{const re=[...Q,L];return m==null||m(re),re}),$(""),N("")},[a,h,g,m]);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:[h.map((z,X)=>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:z.name}),e.jsx("div",{className:"flex justify-center",children:e.jsx(Fr,{size:"sm",checked:z.key??!1,onChange:L=>S(X,{key:L.target.checked}),"aria-label":`${z.name} es clave`})}),e.jsx(rr,{value:z.type??"",onChange:L=>S(X,{type:L}),options:a,placeholder:"—",emptyLabel:"—",height:36,searchable:!1,ariaLabel:`Tipo de ${z.name}`})]},z.name)),h.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:g,onChange:z=>{$(z.currentTarget.value),C&&N("")},onKeyDown:z=>{z.key==="Enter"&&(z.preventDefault(),ee())},placeholder:c,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(Te,{variant:"secondary",onClick:ee,height:36,padding:"0 12px",children:u})]}),C&&e.jsx("p",{className:"text-xs",style:{color:"var(--danger)"},children:C})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(Te,{variant:"primary",onClick:B,disabled:b,loading:b,children:n})})]})})]})}function $a({label:r,children:t,helperText:a,error:n,labelAction:s,required:c=!1,className:u="",contentClassName:b=""}){return e.jsxs("label",{className:`flex flex-col gap-2 ${u}`,children:[(r||s)&&e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-semibold uppercase text-[var(--text-muted)]",children:[r&&e.jsx("span",{children:r}),c&&e.jsx("span",{className:"text-[var(--danger)]",children:"*"}),s&&e.jsx("span",{className:"ml-auto normal-case",children:s})]}),e.jsx("span",{className:`block ${b}`,children:t}),n?e.jsx("span",{className:"text-xs font-medium normal-case text-[var(--danger)]",children:n}):a?e.jsx("span",{className:"text-xs font-medium normal-case text-[var(--text-muted)]",children:a}):null]})}function La(r){if(r!==void 0)return typeof r=="number"?`${r}px`:r}function go(r,t){return r.length!==t.length?!1:r.every((a,n)=>a===t[n])}function xo({value:r,onChange:t,options:a,placeholder:n="Seleccionar…",disabled:s=!1,className:c="",style:u,height:b=40,padding:p="6px 10px",searchable:m=!0,minOptionsForSearch:h=6,maxVisibleValues:x=2,truncateSelectedValues:g=!0,emptyText:$="Sin resultados",clearLabel:C="Limpiar seleccion"}){const[N,S]=l.useState(!1),[B,ee]=l.useState(""),[z,X]=l.useState(0),[L,U]=l.useState(!1),[Q,re]=l.useState({}),W=l.useRef(null),J=l.useRef(null),R=l.useRef(null),T=l.useRef(null),P=m&&a.length>=h,V=l.useMemo(()=>new Set(r),[r]),_=l.useMemo(()=>a.filter(A=>V.has(A.value)),[a,V]),le=x==="all"?_.length:x,q=_.slice(0,le),i=Math.max(0,_.length-q.length),y=P&&B.trim()?a.filter(A=>{var oe;return A.label.toLowerCase().includes(B.toLowerCase())||((oe=A.sublabel)==null?void 0:oe.toLowerCase().includes(B.toLowerCase()))}):a,M=l.useCallback(()=>{const A=W.current;if(!A)return;const oe=A.getBoundingClientRect(),F=P?304:244,H=window.innerHeight-oe.bottom,Z=H<F&&oe.top>H;re({position:"fixed",left:oe.left,top:Z?void 0:oe.bottom+4,bottom:Z?window.innerHeight-oe.top+4:void 0,width:oe.width,zIndex:9999})},[P]),O=l.useCallback(A=>{go(r,A)||t(A)},[t,r]),D=l.useCallback(A=>{const oe=a.find(H=>H.value===A);if(oe!=null&&oe.disabled)return;const F=V.has(A)?r.filter(H=>H!==A):[...r,A];O(F)},[O,a,r,V]),ae=l.useCallback(()=>O([]),[O]);l.useEffect(()=>U(!0),[]),l.useEffect(()=>{if(!N)return;function A(oe){var H,Z;const F=oe.target;!((H=W.current)!=null&&H.contains(F))&&!((Z=J.current)!=null&&Z.contains(F))&&(S(!1),ee(""))}return document.addEventListener("mousedown",A),()=>document.removeEventListener("mousedown",A)},[N]),l.useEffect(()=>{N&&(X(0),M(),P&&setTimeout(()=>{var A;return(A=R.current)==null?void 0:A.focus()},0))},[N,P,M]),l.useEffect(()=>{if(N)return window.addEventListener("resize",M),window.addEventListener("scroll",M,!0),()=>{window.removeEventListener("resize",M),window.removeEventListener("scroll",M,!0)}},[N,M]),l.useEffect(()=>{if(z<0||!T.current)return;const A=T.current.children[z];A==null||A.scrollIntoView({block:"nearest"})},[z]);function ie(A){if(!N){(A.key==="Enter"||A.key===" "||A.key==="ArrowDown")&&(A.preventDefault(),S(!0));return}A.key==="Escape"&&(A.preventDefault(),S(!1),ee("")),A.key==="ArrowDown"&&(A.preventDefault(),X(oe=>Math.min(oe+1,y.length-1))),A.key==="ArrowUp"&&(A.preventDefault(),X(oe=>Math.max(oe-1,0))),A.key==="Enter"&&y[z]&&(A.preventDefault(),D(y[z].value)),A.key==="Backspace"&&!B&&r.length&&(A.preventDefault(),O(r.slice(0,-1)))}const pe=e.jsxs("div",{ref:J,className:"overflow-hidden rounded-xl shadow-xl",style:{...Q,background:"var(--bg-card)",border:"1px solid var(--border)"},children:[P&&e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",style:{borderBottom:"1px solid var(--border)"},children:[e.jsx(v.HiMagnifyingGlass,{className:"h-3.5 w-3.5 flex-shrink-0",style:{color:"var(--text-muted)"}}),e.jsx("input",{ref:R,value:B,onChange:A=>{ee(A.target.value),X(0)},placeholder:"Buscar…",className:"min-w-0 flex-1 bg-transparent text-sm outline-none",style:{color:"var(--text-main)"}}),B&&e.jsx("button",{type:"button",onMouseDown:A=>{A.preventDefault(),ee("")},children:e.jsx(v.HiXMark,{className:"h-3.5 w-3.5",style:{color:"var(--text-muted)"}})})]}),_.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:[_.length," seleccionados"]}),e.jsx("button",{type:"button",onMouseDown:A=>{A.preventDefault(),ae()},className:"font-semibold transition-colors hover:text-[var(--primary)]",children:C})]}),e.jsxs("ul",{ref:T,role:"listbox","aria-multiselectable":"true",className:"overflow-y-auto",style:{maxHeight:P?220:200,scrollbarWidth:"thin",scrollbarColor:"var(--border) transparent",overscrollBehavior:"contain"},children:[y.map((A,oe)=>{const F=oe===z,H=V.has(A.value);return e.jsxs("li",{role:"option","aria-selected":H,onMouseDown:Z=>{Z.preventDefault(),D(A.value)},onMouseEnter:()=>!A.disabled&&X(oe),className:"flex cursor-pointer items-center gap-2 px-3 py-2 text-sm transition-colors",style:{background:F?"var(--bg-hover)":H?"color-mix(in srgb, var(--primary) 6%, transparent)":"transparent",color:A.disabled?"var(--text-muted)":"var(--text-main)",cursor:A.disabled?"not-allowed":"pointer",opacity:A.disabled?.58:1},children:[e.jsx("span",{className:"flex h-4 w-4 flex-shrink-0 items-center justify-center rounded border",style:{borderColor:H?"var(--primary)":"var(--border)",background:H?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:H&&e.jsx(v.HiCheck,{className:"h-3 w-3"})}),A.color&&e.jsx("span",{className:"h-2.5 w-2.5 flex-shrink-0 rounded-full",style:{background:A.color}}),e.jsxs("span",{className:"flex min-w-0 flex-1 items-baseline gap-1 overflow-hidden",children:[e.jsx("span",{className:"truncate",children:A.label}),A.sublabel&&e.jsx("span",{className:"min-w-0 flex-shrink truncate",style:{color:"var(--text-muted)",fontSize:12},children:A.sublabel})]}),A.badge&&e.jsx("span",{className:"flex-shrink-0 text-xs",style:{color:"var(--text-muted)"},children:A.badge})]},A.value)}),y.length===0&&e.jsx("li",{className:"px-3 py-4 text-center text-sm",style:{color:"var(--text-muted)"},children:$})]})]});return e.jsxs("div",{ref:W,className:`relative ${c||"w-full"}`,style:u,onKeyDown:ie,children:[e.jsxs("button",{type:"button",disabled:s,onClick:()=>!s&&S(A=>!A),className:"flex w-full items-center gap-2 rounded-lg text-left text-sm transition-colors focus:outline-none",style:{minHeight:La(b),padding:La(p),background:"var(--bg-input)",color:_.length?"var(--text-main)":"var(--text-muted)",border:N?"1px solid var(--primary)":"1px solid var(--border)",opacity:s?.5:1,cursor:s?"not-allowed":"pointer"},"aria-haspopup":"listbox","aria-expanded":N,children:[e.jsx("span",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-1.5 overflow-hidden",children:q.length?e.jsxs(e.Fragment,{children:[q.map(A=>e.jsxs("span",{className:`inline-flex items-center gap-1 rounded-md border px-1.5 py-0.5 text-xs font-semibold ${g?"max-w-[160px]":"max-w-full whitespace-normal"}`,style:{background:"var(--bg-card)",borderColor:"var(--border)",color:"var(--text-main)"},children:[A.color&&e.jsx("span",{className:"h-1.5 w-1.5 flex-shrink-0 rounded-full",style:{background:A.color}}),e.jsx("span",{className:g?"truncate":"break-words",children:A.label})]},A.value)),i>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:["+",i]})]}):e.jsx("span",{className:"truncate",children:n})}),_.length?e.jsx("span",{role:"button",tabIndex:-1,"aria-label":C,onMouseDown:A=>{A.preventDefault(),A.stopPropagation(),ae()},className:"flex-shrink-0 rounded-full p-0.5 transition-colors hover:bg-black/10",style:{color:"var(--text-muted)"},children:e.jsx(v.HiXMark,{className:"h-3 w-3"})}):e.jsx(v.HiChevronDown,{className:"h-4 w-4 flex-shrink-0 transition-transform",style:{color:"var(--text-muted)",transform:N?"rotate(180deg)":"rotate(0deg)"}})]}),N&&L&&je.createPortal(pe,document.body)]})}function yo({inputMode:r="decimal",...t}){return e.jsx($t,{...t,type:"number",inputMode:r})}function wo(r,t,a){const n=[],s=Math.max(2,r-a),c=Math.min(t-1,r+a);n.push(1),s>2&&n.push("...");for(let u=s;u<=c;u+=1)n.push(u);return c<t-1&&n.push("..."),t>1&&n.push(t),n}function No({page:r,totalPages:t,onPageChange:a,disabled:n=!1,siblingCount:s=1,className:c=""}){const u=Math.max(1,t),b=Math.min(Math.max(1,r),u),p=wo(b,u,s);return e.jsxs("nav",{"aria-label":"Paginacion",className:`inline-flex items-center gap-1 ${c}`,children:[e.jsx(Te,{variant:"icon",size:"xs","aria-label":"Pagina anterior",disabled:n||b<=1,onClick:()=>a(b-1),children:e.jsx(v.HiChevronLeft,{className:"h-4 w-4"})}),p.map((m,h)=>m==="..."?e.jsx("span",{className:"flex h-8 min-w-8 items-center justify-center text-xs font-semibold text-[var(--text-muted)]",children:"..."},`ellipsis-${h}`):e.jsx("button",{type:"button","aria-current":m===b?"page":void 0,disabled:n,onClick:()=>a(m),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:m===b?"var(--primary)":"var(--border)",background:m===b?"var(--primary)":"var(--bg-card)",color:m===b?"var(--primary-fg)":"var(--text-secondary)"},children:m},m)),e.jsx(Te,{variant:"icon",size:"xs","aria-label":"Pagina siguiente",disabled:n||b>=u,onClick:()=>a(b+1),children:e.jsx(v.HiChevronRight,{className:"h-4 w-4"})})]})}const Ta=[{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 Aa(r){return r==null?"":String(r)}function Yr(r){return r?r.startsWith("+")?r:`+${r}`:"+1"}function ko(r){return typeof r=="number"?`${r}px`:r}function So({autoComplete:r="tel",inputMode:t="tel",validate:a=!0,invalidMessage:n="Ingresa un telefono valido.",errorDisplay:s="tooltip",error:c,value:u,defaultValue:b,onChange:p,countryCode:m,defaultCountryCode:h="+1",onCountryCodeChange:x,allowedCountryCodes:g,countryCodeOptions:$,countryCodePlaceholder:C="Codigo",countryCodeClassName:N="",countryCodeWidth:S=84,onPhoneValueChange:B,label:ee,containerClassName:z="",helperText:X,labelAction:L,className:U="",required:Q,disabled:re,floatingLabel:W,showPasswordToggle:J,nativeValidation:R,errorTooltipLabel:T="Error de validacion",...P}){var te;const[V,_]=l.useState(()=>Aa(b)),[le,q]=l.useState(()=>Yr(h)),i=l.useMemo(()=>{const ue=$??Ta,se=g==null?void 0:g.map(Yr);return se!=null&&se.length?ue.filter(w=>se.includes(w.value)):ue},[g,$]),y=((te=i[0])==null?void 0:te.value)??"+1",M=i.some(ue=>ue.value===Yr(m??le))?Yr(m??le):y,O=u!==void 0?Aa(u):V,D=`${M} ${O}`.trim(),ae=a&&O.length>0&&!Et(D)?n:void 0,ie=c??ae,pe=!!ie,A=pe&&s!=="tooltip",oe=pe&&s!=="inline",F=pe?"border-[var(--danger)] focus-within:border-[var(--danger)]":"border-[var(--border)] focus-within:border-[var(--primary)]",H=ue=>{const se=ue.currentTarget.value;u===void 0&&_(se),B==null||B(se,{countryCode:M,nationalNumber:se,fullNumber:`${M} ${se}`.trim()}),p==null||p(ue)},Z=ue=>{m===void 0&&q(ue),x==null||x(ue),B==null||B(O,{countryCode:ue,nationalNumber:O,fullNumber:`${ue} ${O}`.trim()})},G=oe?e.jsx(dr,{as:"span",content:ie,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":T,className:"flex h-full w-full items-center justify-center outline-none",children:e.jsx(Ca,{className:"h-[18px] w-[18px]"})})}):null;return e.jsxs("div",{className:`flex flex-col gap-2 ${z}`,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:ee}),Q&&e.jsx("span",{className:"text-[var(--danger)]",children:"*"}),L&&e.jsx("span",{className:"ml-auto normal-case",children:L})]}),e.jsxs("span",{className:`flex h-10 min-w-0 items-center overflow-hidden rounded-lg border bg-[var(--bg-input)] transition-colors ${F}`,children:[e.jsx(rr,{value:M,onChange:Z,options:i,placeholder:C,disabled:re,ariaLabel:"Codigo telefonico",triggerVariant:"ghost",showSelectedSublabel:!1,searchable:!0,minOptionsForSearch:0,dropdownMinWidth:300,className:`shrink-0 ${N}`,style:{width:ko(S)},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",{...P,value:u,defaultValue:b,type:"tel",inputMode:t,autoComplete:r,disabled:re,required:void 0,"aria-label":P["aria-label"]??(typeof ee=="string"?ee:void 0),"aria-invalid":pe||P["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 ${oe?"pr-10":""} ${U}`,onChange:H}),G]})]}),A?e.jsx("span",{className:"text-xs font-medium normal-case text-[var(--danger)]",children:ie}):X?e.jsx("span",{className:"text-xs font-medium normal-case text-[var(--text-muted)]",children:X}):null]})}function Co({value:r,onChange:t,options:a,name:n,label:s,orientation:c="vertical",disabled:u=!1,className:b="",optionClassName:p=""}){return e.jsxs("fieldset",{className:`min-w-0 ${b}`,disabled:u,children:[s&&e.jsx("legend",{className:"mb-2 text-xs font-semibold uppercase text-[var(--text-muted)]",children:s}),e.jsx("div",{className:c==="horizontal"?"flex flex-wrap gap-2":"flex flex-col gap-2",children:a.map(m=>{const h=m.value===r,x=u||m.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 ${x?"cursor-not-allowed opacity-60":"cursor-pointer hover:bg-[var(--bg-input)]"} ${p}`,style:{borderColor:h?"color-mix(in srgb, var(--primary) 48%, var(--border))":"var(--border)",background:h?"color-mix(in srgb, var(--primary) 8%, transparent)":"var(--bg-card)"},children:[e.jsxs("span",{className:"relative mt-0.5 inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-full border border-[var(--border)] bg-[var(--bg-input)]",children:[e.jsx("input",{type:"radio",name:n,value:m.value,checked:h,disabled:x,onChange:()=>t(m.value),className:"absolute inset-0 opacity-0"}),e.jsx("span",{className:`h-2 w-2 rounded-full transition ${h?"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:m.label}),m.description&&e.jsx("span",{className:"block text-xs leading-5 text-[var(--text-muted)]",children:m.description})]})]},m.value)})})]})}const Ha=()=>'<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>',Xr=r=>r.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'"),Da=r=>r.toLocaleLowerCase().replace(new RegExp("(^|[^\\p{L}\\p{N}])(\\p{L})","gu"),(t,a,n)=>`${a}${n.toLocaleUpperCase()}`),Eo=r=>r.replace(/[<>]/g,"").toLowerCase(),Mo=r=>new RegExp("\\p{L}","u").test(r),Lt=(r,t)=>{const a=r.trim();return!a||!Mo(a)?!1:t==="uppercase"?a===a.toLocaleUpperCase():t==="lowercase"?a===a.toLocaleLowerCase():a===Da(a)},Ba=r=>{const t=n=>{var s,c;if(!n.closest(".rich-img-wrap")){const u=document.createElement("span");u.className="rich-img-wrap",u.contentEditable="false",(s=n.parentNode)==null||s.insertBefore(u,n),u.appendChild(n),u.insertAdjacentHTML("beforeend",Ha())}(c=n.closest(".rich-img-wrap"))==null||c.classList.add("rich-img-broken")};r.querySelectorAll("img").forEach(n=>{if(!n.complete||n.naturalWidth===0){n.addEventListener("error",()=>t(n),{once:!0}),n.addEventListener("load",()=>{n.naturalWidth===0&&t(n)},{once:!0});const s=n.src;n.src="",n.src=s}});const a=n=>{const s=n.target;s.tagName==="IMG"&&t(s)};return r.addEventListener("error",a,!0),()=>r.removeEventListener("error",a,!0)};function $o({value:r,onChange:t,placeholder:a="Escribe algo...",minHeight:n="80px"}){const s=l.useRef(null),c=l.useRef(null),u=l.useRef(null),b=l.useRef(!1),p=l.useRef(r??""),m=l.useRef(t),[h,x]=l.useState(()=>!r||r.trim()===""),[g,$]=l.useState(new Set),[C,N]=l.useState(null),[S,B]=l.useState(""),[ee,z]=l.useState(""),[X,L]=l.useState(""),[U,Q]=l.useState(""),[re,W]=l.useState(!1),J=l.useCallback(()=>b.current?c.current:s.current,[]);l.useEffect(()=>{m.current=t},[t]);const R=l.useCallback(()=>{const w=window.getSelection(),I=J();if(!w||!I||w.rangeCount===0||w.isCollapsed)return"";const de=w.getRangeAt(0);return!I.contains(de.startContainer)||!I.contains(de.endContainer)?"":w.toString()},[J]);l.useEffect(()=>{const w=r??"";p.current=w;const I=[s.current,c.current].filter(be=>!!be);I.forEach(be=>{be.innerHTML!==w&&(be.innerHTML=w)}),x(!w||w.trim()==="");const de=I.map(be=>Ba(be));return()=>de.forEach(be=>be())},[r]),l.useEffect(()=>{var be,ke;b.current=re;let w,I=0,de;if(re){const me=s.current;me&&(p.current=me.innerHTML);const Se=()=>{var fe;const we=c.current;if(!we){I=requestAnimationFrame(Se);return}we.innerHTML!==p.current&&(we.innerHTML=p.current),w=Ba(we),x(((fe=we.textContent)==null?void 0:fe.trim())===""),de=setTimeout(()=>we.focus(),60)};I=requestAnimationFrame(Se)}else{const me=c.current,Se=s.current,we=(me==null?void 0:me.innerHTML)??p.current,fe=p.current;p.current=we,Se&&Se.innerHTML!==we&&(Se.innerHTML=we),we!==fe&&m.current(we),x(((ke=(be=me??Se)==null?void 0:be.textContent)==null?void 0:ke.trim())==="")}return()=>{I&&cancelAnimationFrame(I),de&&clearTimeout(de),w==null||w()}},[re]);const T=l.useCallback(()=>{const w=["bold","italic","underline","strikeThrough","insertUnorderedList","insertOrderedList","justifyLeft","justifyCenter","justifyRight","justifyFull"],I=new Set;w.forEach(be=>{try{document.queryCommandState(be)&&I.add(be)}catch{return}});try{const be=Eo(document.queryCommandValue("formatBlock"));be&&I.add(`formatBlock:${be}`)}catch{return}const de=R();Lt(de,"uppercase")&&I.add("__upper"),Lt(de,"lowercase")&&I.add("__lower"),Lt(de,"capitalize")&&I.add("__cap"),$(I)},[R]),P=()=>{var I;const w=J();w&&(p.current=w.innerHTML,m.current(p.current),x(((I=w.textContent)==null?void 0:I.trim())===""))},V=w=>{if(!w){const I=s.current;I&&(p.current=I.innerHTML)}W(!w)},_=(w,I)=>{var de;(de=J())==null||de.focus(),document.execCommand(w,!1,I),P(),T()},le=w=>{_("formatBlock",w)},q=()=>{var w;(w=J())==null||w.focus(),document.execCommand("insertHTML",!1,"<hr><p><br></p>"),P(),T()},i=()=>{const w=window.getSelection();w&&w.rangeCount>0&&(u.current=w.getRangeAt(0).cloneRange())},y=()=>{const w=window.getSelection();w&&u.current&&(w.removeAllRanges(),w.addRange(u.current))},M=w=>{if(i(),w==="link"){const I=window.getSelection();z(I&&!I.isCollapsed?I.toString():""),B("")}w==="image"&&(L(""),Q("")),N(w)},O=()=>{var be;if(!S.trim())return;y(),(be=J())==null||be.focus();const w=window.getSelection(),de=(w&&!w.isCollapsed?w.toString():"")||ee.trim()||S.trim();document.execCommand("insertHTML",!1,`<a href="${Xr(S.trim())}" target="_blank" rel="noopener noreferrer" class="rich-link">${Xr(de)}</a>`),P(),N(null)},D=(w,I="")=>`<span class="rich-img-wrap" contenteditable="false"><img src="${Xr(w)}" alt="${Xr(I)}" class="rich-img" />${Ha()}</span>`,ae=()=>{var w;X.trim()&&(y(),(w=J())==null||w.focus(),document.execCommand("insertHTML",!1,D(X.trim(),U.trim())),P(),N(null))},ie=(w,I=1200,de=1200,be=.72)=>new Promise((ke,me)=>{const Se=new FileReader;Se.onerror=me,Se.onload=we=>{var Ge;const fe=(Ge=we.target)==null?void 0:Ge.result,Be=new Image;Be.onerror=me,Be.onload=()=>{let{width:ze,height:ne}=Be;if(ze>I||ne>de){const Oe=Math.min(I/ze,de/ne);ze=Math.round(ze*Oe),ne=Math.round(ne*Oe)}const Me=document.createElement("canvas");Me.width=ze,Me.height=ne;const $e=Me.getContext("2d");if(!$e){ke(fe);return}$e.drawImage(Be,0,0,ze,ne),ke(Me.toDataURL("image/jpeg",be))},Be.src=fe},Se.readAsDataURL(w)}),pe=w=>{const de=Array.from(w.clipboardData.items).find(ke=>ke.type.startsWith("image/"));if(!de)return;w.preventDefault();const be=de.getAsFile();be&&ie(be).then(ke=>{var me;(me=J())==null||me.focus(),document.execCommand("insertHTML",!1,D(ke,"imagen")),P()})},A=w=>{const I=window.getSelection(),de=J();if(!I||!de||I.rangeCount===0||I.isCollapsed)return;const be=I.getRangeAt(0);if(!de.contains(be.startContainer)||!de.contains(be.endContainer))return;const ke=be.toString();if(!ke)return;let me=ke;w==="uppercase"?me=ke.toLocaleUpperCase():w==="lowercase"?me=ke.toLocaleLowerCase():me=Da(ke),be.deleteContents();const Se=document.createTextNode(me);be.insertNode(Se);const we=document.createRange();we.setStart(Se,0),we.setEnd(Se,me.length),I.removeAllRanges(),I.addRange(we),u.current=we.cloneRange(),P(),T()},oe=()=>{i(),T()},F=()=>{P(),T()},H=w=>{if(w.key==="Escape"){if(C){N(null);return}if(b.current){W(!1);return}}C||(w.ctrlKey||w.metaKey)&&(w.key==="b"&&(w.preventDefault(),_("bold")),w.key==="i"&&(w.preventDefault(),_("italic")),w.key==="u"&&(w.preventDefault(),_("underline")),w.key==="k"&&(w.preventDefault(),M("link")))},Z=()=>e.jsx("div",{className:"h-4 w-px flex-shrink-0 mx-1",style:{background:"var(--border)"}}),G=(w,I,de,be,ke)=>{const me=ke??(g.has(de)||de==="__link"&&C==="link"||de==="__img"&&C==="image");return e.jsx("button",{type:"button",title:I,onMouseDown:Se=>{Se.preventDefault(),be?be():_(de)},className:"flex h-7 w-7 items-center justify-center rounded text-xs font-bold transition-colors",style:{color:me?"var(--primary)":"var(--text-secondary)",background:me?"rgba(59,130,246,0.12)":"transparent"},children:w},de)},te=w=>{const I=w.target;if(I.closest("[data-action='delete-img']")){w.preventDefault();const de=I.closest(".rich-img-wrap");de&&(de.remove(),P())}},ue=w=>e.jsxs(e.Fragment,{children:[C==="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:w},children:[e.jsx("input",{autoFocus:!0,type:"url",value:S,onChange:I=>B(I.target.value),onKeyDown:I=>{I.key==="Enter"&&(I.preventDefault(),O()),I.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:ee,onChange:I=>z(I.target.value),onKeyDown:I=>{I.key==="Enter"&&(I.preventDefault(),O()),I.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:O,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"})]}),C==="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:w},children:[e.jsx("input",{autoFocus:!0,type:"url",value:X,onChange:I=>L(I.target.value),onKeyDown:I=>{I.key==="Enter"&&(I.preventDefault(),ae()),I.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:U,onChange:I=>Q(I.target.value),onKeyDown:I=>{I.key==="Enter"&&(I.preventDefault(),ae()),I.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:ae,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"})]})]}),se=(w,I)=>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:I},children:[G(e.jsx(v.HiArrowUturnLeft,{className:"h-4 w-4"}),"Deshacer","undo"),G(e.jsx(v.HiArrowUturnRight,{className:"h-4 w-4"}),"Rehacer","redo"),Z(),G(e.jsx("span",{style:{fontSize:"10px"},children:"P"}),"Parrafo","__paragraph",()=>le("p"),g.has("formatBlock:p")||g.has("formatBlock:div")),G(e.jsx(v.HiH2,{className:"h-4 w-4"}),"Titulo 2","__h2",()=>le("h2"),g.has("formatBlock:h2")),G(e.jsx(v.HiH3,{className:"h-4 w-4"}),"Titulo 3","__h3",()=>le("h3"),g.has("formatBlock:h3")),G(e.jsx("span",{style:{fontSize:"13px",lineHeight:1},children:"“"}),"Cita","__quote",()=>le("blockquote"),g.has("formatBlock:blockquote")),Z(),G(e.jsx("b",{children:"B"}),"Negrita (Ctrl+B)","bold"),G(e.jsx("i",{children:"I"}),"Cursiva (Ctrl+I)","italic"),G(e.jsx("u",{children:"U"}),"Subrayado (Ctrl+U)","underline"),G(e.jsx("s",{children:"S"}),"Tachado","strikeThrough"),Z(),G(e.jsx(v.HiListBullet,{className:"h-4 w-4"}),"Lista sin orden","insertUnorderedList"),G(e.jsx(v.HiNumberedList,{className:"h-4 w-4"}),"Lista numerada","insertOrderedList"),G(e.jsx(v.HiArrowTurnUpLeft,{className:"h-4 w-4"}),"Disminuir sangria","outdent"),G(e.jsx(v.HiArrowTurnDownRight,{className:"h-4 w-4"}),"Aumentar sangria","indent"),Z(),G(e.jsx(v.HiBars3BottomLeft,{className:"h-4 w-4"}),"Alinear izquierda","justifyLeft"),G(e.jsx(v.HiBars3CenterLeft,{className:"h-4 w-4"}),"Centrar","justifyCenter"),G(e.jsx(v.HiBars3BottomRight,{className:"h-4 w-4"}),"Alinear derecha","justifyRight"),G(e.jsx(v.HiBars3,{className:"h-4 w-4"}),"Justificar","justifyFull"),Z(),G(e.jsx("span",{style:{fontSize:"10px"},children:"AA"}),"Mayusculas","__upper",()=>A("uppercase")),G(e.jsx("span",{style:{fontSize:"10px"},children:"aa"}),"Minusculas","__lower",()=>A("lowercase")),G(e.jsx("span",{style:{fontSize:"10px"},children:"Aa"}),"Capitalizar","__cap",()=>A("capitalize")),Z(),G(e.jsx(v.HiLink,{className:"h-4 w-4"}),"Insertar enlace (Ctrl+K)","__link",()=>M("link")),G(e.jsx(v.HiLinkSlash,{className:"h-4 w-4"}),"Quitar enlace","unlink"),G(e.jsx(v.HiPhoto,{className:"h-4 w-4"}),"Insertar imagen","__img",()=>M("image")),G(e.jsx(v.HiMinus,{className:"h-4 w-4"}),"Insertar separador","__divider",q),Z(),G(e.jsx(v.HiOutlinePaintBrush,{className:"h-4 w-4"}),"Limpiar formato","removeFormat"),G(e.jsx(v.HiNoSymbol,{className:"h-4 w-4"}),"Quitar bloque","__clearBlock",()=>le("p")),Z(),e.jsx("button",{type:"button",title:w?"Salir del modo de enfoque (Esc)":"Modo de enfoque",onMouseDown:de=>{de.preventDefault(),V(w)},className:"flex h-7 w-7 items-center justify-center rounded transition-colors",style:{color:"var(--text-secondary)"},children:w?e.jsx(v.HiArrowsPointingIn,{className:"h-4 w-4"}):e.jsx(v.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:s,contentEditable:!0,suppressContentEditableWarning:!0,onInput:F,onKeyDown:H,onKeyUp:oe,onSelect:oe,onMouseUp:oe,onPaste:pe,onMouseDown:te,"data-placeholder":a,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:n,maxHeight:"320px",overflowY:"auto",lineHeight:"1.6"}}),ue("var(--bg-input)"),se(!1,"var(--bg-input)")]}),e.jsxs(St,{open:re,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:c,contentEditable:!0,suppressContentEditableWarning:!0,onInput:F,onKeyDown:H,onKeyUp:oe,onSelect:oe,onMouseUp:oe,onPaste:pe,onMouseDown:te,"data-placeholder":a,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"}}),ue("var(--bg-input)"),se(!0,"var(--bg-input)")]})]})}function Lo({title:r,subtitle:t,icon:a,actions:n,children:s,footer:c,className:u="",bodyClassName:b="p-4"}){const p=r||t||a||n;return e.jsxs("section",{className:`overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${u}`,children:[p&&e.jsxs("header",{className:"flex items-center justify-between gap-3 border-b border-[var(--border)] px-4 py-3",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[a&&e.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-input)] text-[var(--primary)]",children:a}),e.jsxs("div",{className:"min-w-0",children:[r&&e.jsx("h3",{className:"truncate text-sm font-semibold text-[var(--text-main)]",children:r}),t&&e.jsx("div",{className:"truncate text-xs text-[var(--text-muted)]",children:t})]})]}),n&&e.jsx("div",{className:"shrink-0",children:n})]}),e.jsx("div",{className:b,children:s}),c&&e.jsx("footer",{className:"border-t border-[var(--border)] px-4 py-3",children:c})]})}const To={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)"}},Ao={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 Ho({children:r,tone:t="neutral",size:a="sm",icon:n,dot:s=!1,className:c=""}){const u=To[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 ${Ao[a]} ${c}`,style:{color:u.text,background:u.bg,borderColor:u.border},children:[s&&e.jsx("span",{"aria-hidden":"true",className:"h-1.5 w-1.5 shrink-0 rounded-full",style:{background:u.text}}),n&&e.jsx("span",{className:"shrink-0",children:n}),e.jsx("span",{className:"min-w-0 truncate",children:r})]})}const Ia={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)"}},Do={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"},Bo={xs:"right-1 h-3 w-3",sm:"right-1.5 h-3 w-3",md:"right-2 h-3.5 w-3.5"},Io={xs:148,sm:164,md:184},Oo={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 Fo({value:r,options:t,onChange:a,size:n="sm",disabled:s=!1,loading:c=!1,stopPropagation:u=!1,ariaLabel:b="Cambiar estado",title:p="Cambiar estado",className:m,selectClassName:h,menuClassName:x,optionClassName:g,spinnerClassName:$}){const[C,N]=l.useState(!1),[S,B]=l.useState(!1),[ee,z]=l.useState(-1),[X,L]=l.useState({}),U=l.useRef(null),Q=l.useRef(null),re=l.useRef(null),W=t.find(i=>i.value===r)??t[0],J={...W!=null&&W.tone?Ia[W.tone]:void 0,...W==null?void 0:W.style},R=s||c||t.length===0,T=i=>{u&&i.stopPropagation()},P=l.useCallback(()=>{N(!1),z(-1)},[]),V=l.useCallback(()=>{const i=U.current;if(!i)return;const y=i.getBoundingClientRect(),M=Math.max(y.width,Io[n]),O=Math.min(Math.max(t.length,1)*38+12,260),D=window.innerHeight-y.bottom,ae=D<O&&y.top>D,ie=Math.min(Math.max(8,y.left+y.width/2-M/2),window.innerWidth-M-8);L({position:"fixed",left:ie,top:ae?void 0:y.bottom+6,bottom:ae?window.innerHeight-y.top+6:void 0,width:M,zIndex:9999})},[t.length,n]),_=l.useCallback(i=>{i.disabled||(a(i.value),P())},[P,a]);l.useEffect(()=>B(!0),[]),l.useEffect(()=>{if(!C)return;V();const i=t.findIndex(y=>y.value===r);z(i>=0?i:0)},[C,t,V,r]),l.useEffect(()=>{if(!C)return;function i(y){var O,D;const M=y.target;!((O=U.current)!=null&&O.contains(M))&&!((D=Q.current)!=null&&D.contains(M))&&P()}return document.addEventListener("mousedown",i),()=>document.removeEventListener("mousedown",i)},[P,C]),l.useEffect(()=>{if(C)return window.addEventListener("resize",V),window.addEventListener("scroll",V,!0),()=>{window.removeEventListener("resize",V),window.removeEventListener("scroll",V,!0)}},[C,V]),l.useEffect(()=>{if(ee<0||!re.current)return;const i=re.current.children[ee];i==null||i.scrollIntoView({block:"nearest"})},[ee]);function le(i){if(!R){if(!C){["Enter"," ","ArrowDown","ArrowUp"].includes(i.key)&&(i.preventDefault(),N(!0));return}if(i.key==="Escape"){i.preventDefault(),P();return}if(i.key==="ArrowDown"){i.preventDefault(),z(y=>Math.min(y+1,t.length-1));return}if(i.key==="ArrowUp"){i.preventDefault(),z(y=>Math.max(y-1,0));return}if(i.key==="Enter"||i.key===" "){i.preventDefault();const y=t[ee];y&&_(y)}}}const q=e.jsx("div",{ref:Q,role:"listbox","aria-label":b,className:Je("overflow-hidden rounded-xl border shadow-xl backdrop-blur-md",x),style:{...X,background:"color-mix(in srgb, var(--bg-card) 92%, transparent)",borderColor:"var(--border)",color:"var(--text-main)"},onClick:T,onMouseDown:T,onPointerDown:T,children:e.jsx("div",{ref:re,className:"max-h-64 overflow-y-auto p-1",style:{scrollbarWidth:"thin",scrollbarColor:"var(--border) transparent",overscrollBehavior:"contain"},children:t.map((i,y)=>{const M=i.value===r,O=y===ee,D={...i.tone?Ia[i.tone]:void 0,...i.style};return e.jsxs("button",{type:"button",role:"option","aria-selected":M,disabled:i.disabled,onMouseEnter:()=>!i.disabled&&z(y),onMouseDown:ae=>{ae.preventDefault(),_(i)},className:Je("flex w-full items-center gap-2 rounded-lg font-medium text-left transition-colors disabled:cursor-not-allowed disabled:opacity-45",Oo[n],M?i.className:void 0,g),style:{...M?D:void 0,background:M?D.background??"color-mix(in srgb, var(--primary) 12%, transparent)":O?"var(--bg-hover)":"transparent",color:M?D.color??"var(--primary)":"var(--text-main)"},children:[e.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center",children:M?e.jsx(v.HiCheck,{className:"h-4 w-4"}):null}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:i.label})]},i.value)})})});return e.jsxs("span",{ref:U,className:Je("relative inline-flex shrink-0 items-center",m),onKeyDown:le,onClick:T,onPointerDown:T,children:[e.jsx("button",{type:"button",disabled:R,"aria-label":b,"aria-haspopup":"listbox","aria-expanded":C,title:p,onClick:()=>!R&&N(i=>!i),className:Je("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",Do[n],W==null?void 0:W.className,h),style:J,children:e.jsx("span",{className:"min-w-0 truncate",children:(W==null?void 0:W.label)??r})}),e.jsx(v.HiChevronDown,{"aria-hidden":"true",className:Je("pointer-events-none absolute opacity-70 transition-transform",Bo[n],C?"rotate-180":"rotate-0")}),c&&e.jsx("span",{"aria-hidden":"true",className:Je("absolute -right-1 -top-1 h-2.5 w-2.5 rounded-full border border-current border-t-transparent animate-spin",$)}),C&&S&&je.createPortal(q,document.body)]})}function Po({tabs:r,activeTabId:t,defaultActiveTabId:a,onTabChange:n,ariaLabel:s="Pestanas",variant:c="underline",className:u="",listClassName:b="",panelClassName:p=""}){const m=r.find(C=>!C.disabled)??r[0],h=t??a??(m==null?void 0:m.id),x=r.find(C=>C.id===h)??m,g=C=>{C.disabled||n==null||n(C.id)},$=C=>{const N=r.filter(B=>!B.disabled);if(!N.length||!x)return;const S=N.findIndex(B=>B.id===x.id);(C.key==="ArrowRight"||C.key==="ArrowDown")&&(C.preventDefault(),g(N[(S+1)%N.length])),(C.key==="ArrowLeft"||C.key==="ArrowUp")&&(C.preventDefault(),g(N[(S-1+N.length)%N.length])),C.key==="Home"&&(C.preventDefault(),g(N[0])),C.key==="End"&&(C.preventDefault(),g(N[N.length-1]))};return e.jsxs("div",{className:u,children:[e.jsx("div",{role:"tablist","aria-label":s,onKeyDown:$,className:`flex min-w-0 gap-1 overflow-x-auto ${c==="underline"?"border-b border-[var(--border)]":"rounded-lg border border-[var(--border)] bg-[var(--bg-input)] p-1"} ${b}`,children:r.map(C=>{const N=C.id===(x==null?void 0:x.id);return e.jsxs("button",{type:"button",role:"tab","aria-selected":N,"aria-controls":`${C.id}-panel`,id:`${C.id}-tab`,disabled:C.disabled,tabIndex:N?0:-1,onClick:()=>g(C),className:`inline-flex min-h-8 shrink-0 items-center justify-center gap-1.5 whitespace-nowrap px-2.5 text-sm font-semibold transition-colors focus:outline-none disabled:cursor-not-allowed disabled:opacity-50 ${c==="underline"?"border-b-2":"rounded-md border"}`,style:{color:N?"var(--primary)":"var(--text-muted)",borderColor:N?"var(--primary)":"transparent",background:c==="pills"&&N?"var(--bg-card)":"transparent"},children:[C.icon&&e.jsx("span",{className:"shrink-0",children:C.icon}),e.jsx("span",{children:C.label}),C.badge&&e.jsx("span",{className:"shrink-0",children:C.badge})]},C.id)})}),(x==null?void 0:x.content)!==void 0&&e.jsx("div",{role:"tabpanel",id:`${x.id}-panel`,"aria-labelledby":`${x.id}-tab`,className:`pt-4 ${p}`,children:x.content})]})}function Qe(...r){return r.filter(Boolean).join(" ")}function zo({steps:r,activeStepId:t,initialStepId:a,completedStepIds:n,defaultCompletedStepIds:s=[],onActiveStepChange:c,onCompletedStepIdsChange:u,onBlockedStep:b,allowBackNavigation:p=!0,showFooter:m=!0,previousLabel:h="Anterior",nextLabel:x="Siguiente",blockedNextLabel:g="Completa este paso",className:$="",headerClassName:C="",contentClassName:N="",footerClassName:S=""}){var F;const B=((F=r[0])==null?void 0:F.id)??"",[ee,z]=l.useState(a??B),[X,L]=l.useState(s),U=t??ee,Q=n??X,re=l.useMemo(()=>new Set(Q),[Q]),W=Math.max(0,r.findIndex(H=>H.id===U)),J=r[W]??r[0],R=r.length<=1?100:W/(r.length-1)*100,T=H=>{n||L(H),u==null||u(H)},P=H=>{const Z=r.find(G=>G.id===H);Z&&(t||z(H),c==null||c(H,Z))},V=H=>re.has(H),_=H=>r.slice(0,H).find(Z=>!Z.optional&&!re.has(Z.id)),le=H=>{const Z=r[H];return!Z||Z.disabled?!1:H===W||p&&H<W?!0:!_(H)},q=H=>{const Z=r.findIndex(G=>G.id===H);return Z>=0&&le(Z)},i=H=>{const Z=r.findIndex(G=>G.id===H);if(Z<0)return!1;if(!le(Z)){const G=_(Z);return G&&(b==null||b(r[Z],G)),!1}return P(H),!0},y=(H=J==null?void 0:J.id)=>{!H||re.has(H)||T([...Q,H])},M=(H=J==null?void 0:J.id)=>{if(!H)return;const Z=r.findIndex(te=>te.id===H),G=Q.filter(te=>{const ue=r.findIndex(se=>se.id===te);return ue>=0&&ue<Z});T(G),Z>=0&&W>Z&&P(H)},O=()=>W<=0?!1:i(r[W-1].id),D=()=>{const H=r[W+1];return H?i(H.id):!1},ae={activeStep:J,activeIndex:W,completedStepIds:Q,isCompleted:V,isUnlocked:q,completeStep:y,uncompleteStep:M,goToStep:i,goNext:D,goPrevious:O};if(!J)return null;const ie=r[W+1],pe=W>0,A=ie?q(ie.id):!1,oe=typeof J.content=="function"?J.content(ae):J.content;return e.jsxs("section",{className:Qe("overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)]",$),children:[e.jsxs("div",{className:Qe("border-b border-[var(--border)] bg-[var(--bg-input)]",C),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:`${R}%`}})}),e.jsx("div",{className:"grid gap-2 p-2",style:{gridTemplateColumns:`repeat(${r.length}, minmax(0, 1fr))`},children:r.map((H,Z)=>{const G=H.id===J.id,te=V(H.id),ue=le(Z),se=_(Z);return e.jsxs("button",{type:"button",disabled:!ue,"aria-current":G?"step":void 0,"aria-disabled":!ue,title:!ue&&se?`Completa ${se.title}`:H.title,onClick:()=>i(H.id),className:Qe("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",G&&"border-[var(--primary)] bg-[var(--bg-card)] shadow-sm",te&&!G&&"border-[var(--primary)]/35 bg-[var(--bg-card)]",!G&&!te&&ue&&"border-transparent bg-[var(--bg-card)]/45 hover:border-[var(--border)] hover:bg-[var(--bg-card)]",!ue&&"border-transparent bg-[var(--bg-card)]/35 opacity-60"),children:[e.jsx("span",{className:Qe("absolute inset-x-0 top-0 h-0.5 origin-left scale-x-0 bg-[var(--primary)] transition-transform duration-300",G&&"scale-x-100")}),e.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:Qe("grid h-7 w-7 shrink-0 place-items-center rounded-full border text-xs font-bold transition-all duration-200",G&&"border-[var(--primary)] bg-[var(--primary)] text-[var(--primary-fg)]",te&&!G&&"border-[var(--primary)] bg-[var(--primary)]/12 text-[var(--primary)]",!te&&!G&&ue&&"border-[var(--border)] text-[var(--text-muted)]",!ue&&"border-[var(--border)] text-[var(--text-muted)]"),children:te?e.jsx(v.HiCheck,{className:"h-4 w-4"}):ue?Z+1:e.jsx(v.HiLockClosed,{className:"h-3.5 w-3.5"})}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsxs("span",{className:Qe("block truncate text-xs font-semibold transition-colors duration-200",G?"text-[var(--text-main)]":"text-[var(--text-secondary)]"),children:[Z+1,". ",H.title]}),H.description&&e.jsx("span",{className:"mt-1 block truncate text-[11px] text-[var(--text-muted)]",children:H.description})]}),H.badge&&e.jsx("span",{className:"shrink-0",children:H.badge})]})]},H.id)})})]}),e.jsx("div",{className:Qe("min-h-72 animate-[stepWizardIn_220ms_ease-out] p-5",N),children:oe},J.id),m&&e.jsxs("div",{className:Qe("flex flex-wrap items-center justify-between gap-3 border-t border-[var(--border)] bg-[var(--bg-input)] px-4 py-3",S),children:[e.jsx(Te,{variant:"secondary",height:38,padding:"0 14px",icon:e.jsx(v.HiChevronLeft,{}),disabled:!pe,onClick:O,children:h}),e.jsxs("div",{className:"flex items-center gap-3 text-xs text-[var(--text-muted)]",children:[e.jsxs("span",{children:["Paso ",W+1," de ",r.length]}),e.jsx("span",{className:"h-1 w-1 rounded-full bg-[var(--border)]"}),e.jsxs("span",{children:[Q.length," completados"]})]}),e.jsx(Te,{height:38,padding:"0 14px",icon:e.jsx(v.HiChevronRight,{}),disabled:!ie||!A,onClick:D,children:ie&&!A?g:x})]})]})}const jo={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"},_o={none:"resize-none",vertical:"resize-y",horizontal:"resize-x",both:"resize"};function Wo(r,t){if(r){if(typeof r=="function"){r(t);return}r.current=t}}function qo(r,t){return r!==void 0?String(r).length:t!==void 0?String(t).length:0}const Oa=l.forwardRef(function({className:t="",wrapperClassName:a="",size:n="md",resize:s="vertical",autoResize:c=!1,minRows:u,maxRows:b,showCount:p=!1,maxCount:m,status:h="default",icon:x,action:g,style:$,value:C,defaultValue:N,maxLength:S,onInput:B,...ee},z){const X=l.useRef(null),L=qo(C,N),U=m??S,Q=!!(x||g||p),re=h==="error"?"var(--danger)":h==="success"?"#16a34a":"var(--border)",W={...$??{},...u?{minHeight:`${u*24+18}px`}:null,...b?{maxHeight:`${b*24+18}px`}:null},J=()=>{const T=X.current;!T||!c||(T.style.height="auto",T.style.height=`${T.scrollHeight}px`)};l.useEffect(J,[c,C]);const R=e.jsx("textarea",{...ee,ref:T=>{X.current=T,Wo(z,T)},value:C,defaultValue:N,maxLength:S,"aria-invalid":h==="error"||ee["aria-invalid"],onInput:T=>{J(),B==null||B(T)},style:{...W,borderColor:re},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 ${jo[n]} ${_o[c?"none":s]} ${x?"pl-8":""} ${g?"pr-10":""} ${t}`});return Q?e.jsxs("span",{className:`relative block ${a}`,children:[x&&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:x}),R,g&&e.jsx("span",{className:"absolute right-2 top-2 flex items-center justify-center",children:g}),p&&e.jsxs("span",{className:"absolute bottom-1.5 right-2 rounded bg-[var(--bg-input)] px-1.5 text-[10px] font-semibold text-[var(--text-muted)]",children:[L,U?`/${U}`:""]})]}):R});function Uo({label:r,containerClassName:t="",helperText:a,error:n,labelAction:s,required:c,className:u="",status:b,...p}){return e.jsx($a,{label:r,required:c,helperText:a,error:n,labelAction:s,className:t,children:e.jsx(Oa,{...p,required:c,status:n?"error":b,className:`w-full ${u}`})})}const Vo={xs:{width:28,height:16,thumb:12,padding:2},sm:{width:36,height:20,thumb:16,padding:2}};function Ko({checked:r,disabled:t,onCheckedChange:a,size:n="sm",className:s="",...c}){const u=Vo[n],b=r?u.width-u.thumb-u.padding*2:0;return e.jsx("button",{...c,type:"button",role:"switch","aria-checked":r,disabled:t,onClick:()=>!t&&a(!r),className:`relative inline-flex shrink-0 items-center rounded-full transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--primary)]/50 disabled:cursor-not-allowed disabled:opacity-50 ${s}`,style:{width:u.width,height:u.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:u.thumb,height:u.thumb,left:u.padding,top:"50%",transform:`translate(${b}px, -50%)`,background:r?"var(--primary-fg)":"var(--text-muted)"}})})}const Fa=[".sidebar-scroll","[data-overlay-scroll='true']"].join(",");function Go(r){if(!(r instanceof HTMLElement)||r.dataset.overlayScroll==="false"||r.closest("[data-overlayscrollbars]")||r.matches("textarea,input,select,[contenteditable='true']"))return!1;const t=window.getComputedStyle(r);return!(![t.overflow,t.overflowX,t.overflowY].join(" ").match(/auto|scroll/)||r.clientWidth===0&&r.clientHeight===0)}function Pa(r){return r.classList.contains("sidebar-scroll")}function za(r){Pa(r)&&r.querySelectorAll(".os-scrollbar-horizontal").forEach(t=>{t.style.display="none",t.style.height="0",t.style.pointerEvents="none"})}function ja(){return l.useEffect(()=>{const r=new WeakMap;let t=0;const a=()=>{t=0,document.querySelectorAll(Fa).forEach(c=>{if(!Go(c))return;if(Zt.OverlayScrollbars(c)){za(c);return}const b=Zt.OverlayScrollbars(c,{overflow:Pa(c)?{x:"hidden",y:"scroll"}:void 0,scrollbars:{autoHide:"leave",autoHideDelay:180}});za(c),r.set(c,b)})},n=()=>{t||(t=window.requestAnimationFrame(a))};a();const s=new MutationObserver(n);return s.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["class","data-overlay-scroll"]}),window.addEventListener("resize",n),()=>{t&&window.cancelAnimationFrame(t),s.disconnect(),window.removeEventListener("resize",n),document.querySelectorAll(Fa).forEach(c=>{var u;c instanceof HTMLElement&&((u=r.get(c))==null||u.destroy())})}},[]),null}const Yo={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"}},_a=["bg-indigo-500","bg-blue-500","bg-emerald-500","bg-violet-500","bg-amber-500","bg-teal-500","bg-rose-500","bg-cyan-500"],Xo={xs:"text-xs",sm:"text-sm",md:"text-base",lg:"text-lg"},Zo="bonsaif.bot",Jo="Bonsaif Bot",Qo={xs:"p-0.5",sm:"p-1",md:"p-1.5",lg:"p-2",xl:"p-2.5"};function Wa(r){return typeof r=="string"?r.trim():""}function Ro(r){let t=0;for(const a of r)t=t*31+a.charCodeAt(0)&65535;return _a[t%_a.length]}function es(r,t){return r===Zo||t===Jo}function rs(r,t){return`${r.replace(/\/$/,"")}${t}`}function qa({userId:r,username:t,name:a,size:n="md",showName:s=!1,showTooltip:c,tooltipContent:u,fallbackLabel:b="Usuario",wrapperClassName:p="",labelClassName:m="",labelSize:h="xs",avatarVersion:x=0,className:g="",style:$}){var V;const[C,N]=l.useState(!1),S=typeof r=="string"&&r.trim()&&r!=="undefined"&&r!=="null"?r.trim():"";l.useEffect(()=>{N(!1)},[S,x]);const{wh:B,text:ee}=Yo[n],z=Wa(a)||Wa(t)||b,X=z.trim()[0]||"?",L=typeof process<"u"&&((V=process.env)==null?void 0:V.NEXT_PUBLIC_BASE_PATH)||"",U=es(t,a),Q=rs(L,"/favicon.svg"),re=S?`${L}/api/user/avatar/${S}${x?`?v=${x}`:""}`:"",J={xs:20,sm:28,md:36,lg:48,xl:64}[n],R=U?e.jsx("span",{className:`${B} ${Qo[n]} rounded-full flex items-center justify-center bg-[#071f1a] ring-1 ring-emerald-400/35 shadow-[0_0_0_1px_rgba(255,255,255,0.06)] flex-shrink-0 ${g}`,style:$,children:e.jsx("img",{src:Q,alt:z,width:J,height:J,className:"h-full w-full object-contain"})}):re&&!C?e.jsx("img",{src:re,alt:z,width:J,height:J,className:`${B} rounded-full object-cover flex-shrink-0 ${g}`,style:$,onError:()=>N(!0)},`${S}-${x}`):e.jsx("span",{className:`${B} ${Ro(z)} ${ee} rounded-full flex items-center justify-center font-black text-white uppercase flex-shrink-0 ${g}`,style:$,title:z,children:X});if(s)return e.jsxs("span",{className:`inline-flex min-w-0 items-center gap-2 ${p}`,children:[R,e.jsx("span",{className:`min-w-0 truncate ${Xo[h]} font-medium text-[var(--text-main)] ${m}`,title:z,children:z})]});const T=c??!0,P=u??z;return T&&P?e.jsx(dr,{as:"span",content:P,className:`inline-flex flex-shrink-0 ${p}`,children:R}):R}function ts({href:r,className:t,children:a}){return e.jsx("a",{href:r,className:t,children:a})}function as(r){return r.reduce((t,a)=>{const n=a.section??"Principal";return t[n]=[...t[n]??[],a],t},{})}function Ua({children:r,navItems:t=[],currentPath:a=typeof window>"u"?"/":window.location.pathname,user:n,appName:s="Bonsaif",appLogo:c,header:u,footer:b,onLogout:p,LinkComponent:m=ts}){const[h,x]=l.useState(!1),g=as(t);return e.jsxs("div",{className:"min-h-screen bg-[var(--bg-main)] text-[var(--text-main)]",children:[e.jsx(ja,{}),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:()=>x(!0),children:e.jsx(v.HiBars3,{className:"h-5 w-5"})}),h&&e.jsx("button",{type:"button","aria-label":"Cerrar navegación",className:"fixed inset-0 z-40 bg-black/45 lg:hidden",onClick:()=>x(!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 ${h?"translate-x-0":"-translate-x-full"}`,children:[e.jsxs("div",{className:"flex h-16 items-center gap-3 border-b border-white/10 px-4",children:[e.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg bg-white/10 text-white",children:c??e.jsx(v.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:()=>x(!1),children:e.jsx(v.HiXMark,{className:"h-5 w-5"})})]}),e.jsx("nav",{className:"sidebar-scroll min-h-0 flex-1 overflow-y-auto px-3 py-4","data-overlay-scroll":"true",children:Object.entries(g).map(([$,C])=>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(v.HiChevronDown,{className:"h-3.5 w-3.5"}),$]}),e.jsx("div",{className:"space-y-1",children:C.map(N=>{const S=a===N.href||a.startsWith(`${N.href}/`);return e.jsxs(m,{href:N.href,className:`flex min-w-0 items-center gap-2 rounded-md px-2 py-2 text-sm transition-colors ${S?"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:N.icon??e.jsx(v.HiHome,{className:"h-4 w-4"})}),e.jsx("span",{className:"truncate",children:N.label})]},N.href)})})]},$))}),e.jsxs("div",{className:"border-t border-white/10 p-3",children:[n&&e.jsxs("div",{className:"mb-3 flex min-w-0 items-center gap-3 rounded-lg bg-white/[0.04] p-2",children:[e.jsx(qa,{name:n.initials??n.name??n.email??"Usuario",size:"md"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate text-sm font-medium text-white",children:n.name??"Usuario"}),n.email&&e.jsx("div",{className:"truncate text-xs text-white/45",children:n.email})]})]}),p&&e.jsxs(Te,{variant:"ghost",className:"w-full justify-start text-white hover:bg-white/10",onClick:p,children:[e.jsx(v.HiArrowRightOnRectangle,{className:"h-4 w-4"})," Salir"]}),b]})]}),e.jsxs("div",{className:"min-h-screen lg:pl-72",children:[u,e.jsx("main",{className:"min-h-screen",children:r})]})]})}const Va="bonsaif-ui:prime-auth-sso",ns={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"},Tt={dashboard:e.jsx(v.HiChartBar,{className:"h-5 w-5"}),tickets:e.jsx(v.HiTicket,{className:"h-5 w-5"}),teams:e.jsx(v.HiUsers,{className:"h-5 w-5"}),projects:e.jsx(v.HiRectangleGroup,{className:"h-5 w-5"}),clients:e.jsx(v.HiBuildingOffice2,{className:"h-5 w-5"}),surveys:e.jsx(v.HiClipboardDocumentList,{className:"h-5 w-5"}),profile:e.jsx(v.HiUser,{className:"h-5 w-5"}),settings:e.jsx(v.HiCog6Tooth,{className:"h-5 w-5"}),notifications:e.jsx(v.HiBell,{className:"h-5 w-5"}),changelog:e.jsx(v.HiDocumentText,{className:"h-5 w-5"}),admin:e.jsx(v.HiShieldCheck,{className:"h-5 w-5"}),users:e.jsx(v.HiUsers,{className:"h-5 w-5"}),roles:e.jsx(v.HiShieldCheck,{className:"h-5 w-5"}),menus:e.jsx(v.HiCog6Tooth,{className:"h-5 w-5"}),guards:e.jsx(v.HiCalendarDays,{className:"h-5 w-5"}),vacations:e.jsx(v.HiCalendarDays,{className:"h-5 w-5"}),audit:e.jsx(v.HiListBullet,{className:"h-5 w-5"}),positions:e.jsx(v.HiBriefcase,{className:"h-5 w-5"}),ranks:e.jsx(v.HiListBullet,{className:"h-5 w-5"}),"email-inbox":e.jsx(v.HiInbox,{className:"h-5 w-5"}),"security-incidents":e.jsx(v.HiShieldCheck,{className:"h-5 w-5"})};function ls({href:r,className:t,style:a,children:n}){return e.jsx("a",{href:r,className:t,style:a,children:n})}function os(r){return r.split("-").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}function ss(r){return/^\d+$/.test(r)||/^[a-f0-9]{8,}$/i.test(r)}function is(r){const t=r.split("/").filter(Boolean);if(t.length===0||t.length===1&&t[0]==="dashboard")return[];const a=decodeURIComponent(t[t.length-1]),n=t.length>1?decodeURIComponent(t[t.length-2]):void 0,s=ss(a)&&n?n:a,c=ns[s]??os(s);return[{label:"Inicio",href:"/"},{label:c}]}function At(r){return(r==null?void 0:r.querySelector(":scope > .os-viewport"))??(r==null?void 0:r.querySelector(":scope > [data-overlayscrollbars-viewport]"))}function cs(r){const t=r.split("/").filter(Boolean),a=t[t.length-1];if(!a)return e.jsx(v.HiHome,{className:"h-5 w-5"});if(Tt[a])return Tt[a];const n=t.length>1?t[t.length-2]:"";return Tt[n]??e.jsx(v.HiHome,{className:"h-5 w-5"})}function ds(r){return r.includes("primeAuthOrigin")||r.includes("primeAuthProjectKey")}function Ka(){if(typeof window>"u")return!1;if(ds(window.location.href)){try{window.sessionStorage.setItem(Va,"true")}catch{}return!0}try{return window.sessionStorage.getItem(Va)==="true"}catch{return!1}}function us({title:r,subtitle:t,action:a,meta:n,icon:s,className:c="",contentClassName:u="",breadcrumbs:b,currentPath:p,showBreadcrumbs:m=!0,contained:h=!1,LinkComponent:x=ls}){const g=l.useRef(null),[$,C]=l.useState(!1),[N,S]=l.useState(p??"/"),[B,ee]=l.useState(()=>Ka()),[z,X]=l.useState(null),L=p??N,U=b??is(L),Q=s??cs(L),re=m&&!B&&U.length>1,W=!re;l.useEffect(()=>{p||S(window.location.pathname)},[p]),l.useEffect(()=>{ee(Ka())},[]),l.useEffect(()=>{if(h){C(!1);return}let R=null,T=0,P=0;const V=()=>{const q=g.current,i=document.querySelector("[data-app-scroll='true']");return(q==null?void 0:q.closest(".os-viewport"))??(q==null?void 0:q.closest("[data-overlayscrollbars-viewport]"))??At(i)??i??window},_=()=>{const q=R&&R!==window?R.scrollTop:window.scrollY;C(i=>i?q>24:q>72)},le=()=>{R==null||R.removeEventListener("scroll",_),R=V(),R.addEventListener("scroll",_,{passive:!0}),_()};return le(),T=window.requestAnimationFrame(le),P=window.setTimeout(le,120),()=>{window.cancelAnimationFrame(T),window.clearTimeout(P),R==null||R.removeEventListener("scroll",_)}},[h]),l.useEffect(()=>{if(h){X(null);return}let R=0;const T=[],P=()=>{const M=g.current,O=M==null?void 0:M.parentElement,D=document.querySelector("[data-app-scroll='true']"),ae=At(D)??D;if(!M||!O||!ae){X(null);return}const ie=O.getBoundingClientRect(),pe=window.getComputedStyle(O),A=ae.getBoundingClientRect(),oe=ae instanceof HTMLElement&&ae.clientWidth>0?ae.clientWidth:A.width,F=ie.left+parseFloat(pe.paddingLeft||"0"),H={marginLeft:Math.round(A.left-F),width:Math.round(oe)};X(Z=>Z&&Z.marginLeft===H.marginLeft&&Z.width===H.width?Z:H)},V=()=>{window.cancelAnimationFrame(R),R=window.requestAnimationFrame(P)};V(),window.addEventListener("resize",V);const _=new ResizeObserver(V),le=g.current,q=le==null?void 0:le.parentElement,i=document.querySelector("[data-app-scroll='true']"),y=At(i)??i;return[q,i,y].forEach(M=>{M&&_.observe(M)}),T.push(window.setTimeout(V,120)),T.push(window.setTimeout(V,280)),()=>{window.cancelAnimationFrame(R),window.removeEventListener("resize",V),_.disconnect(),T.forEach(M=>window.clearTimeout(M))}},[h]);const J={...z?{marginLeft:z.marginLeft,width:z.width}:null,"--page-header-control-height":$?"34px":"40px","--page-header-control-padding-x":$?"10px":"14px","--page-header-control-icon-left":$?"10px":"12px",background:h?"var(--bg-card)":$?"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:h||$?"1px solid var(--border)":"1px solid transparent",boxShadow:$?"0 10px 28px rgba(12, 54, 53, 0.12)":"none"};return e.jsx("div",{ref:g,"data-page-header":"true","data-compact":$?"true":"false",className:`sticky top-0 z-30 overflow-visible py-0 transition-[background-color,box-shadow,border-color] duration-300 ease-out ${h?"mb-0 flex-shrink-0":"mb-4 sm:mb-0"} ${c}`,style:J,children:e.jsxs("div",{className:`flex flex-wrap items-center justify-between transition-[gap,min-height,padding] duration-300 ease-out ${$?"min-h-8 gap-1.5 px-3 py-0 sm:min-h-9 sm:gap-2":W?"min-h-9 gap-2 px-4 py-0 sm:min-h-10 sm:gap-2.5":"min-h-10 gap-2.5 px-4 pt-0.5 sm:min-h-11 sm:gap-3"} ${u}`,children:[e.jsxs("div",{className:`min-w-0 flex flex-1 flex-col justify-center transition-[gap,transform] duration-300 ease-out ${$||W?"gap-1":"gap-1.5 sm:gap-2"}`,children:[re&&e.jsx("nav",{"aria-label":"Breadcrumb",className:"min-w-0 flex-shrink-0 transition-[opacity,transform] duration-300 ease-out",children:e.jsx("ol",{className:`flex flex-wrap items-center gap-1.5 leading-none transition-[font-size,line-height] duration-300 ease-out ${$?"text-[10px]":"text-[10px] sm:text-[11px]"}`,children:U.map((R,T)=>{const P=T===U.length-1;return e.jsxs("li",{className:"flex min-w-0 items-center gap-1.5",children:[T>0&&e.jsx(v.HiChevronRight,{className:"h-3.5 w-3.5 transition-[color,transform] duration-300 ease-out",style:{color:"var(--text-muted)"}}),R.href&&!P?e.jsx(x,{href:R.href,className:"truncate transition-colors duration-300 hover:underline",style:{color:"var(--text-muted)"},children:R.label}):e.jsx("span",{"aria-current":P?"page":void 0,className:P?"truncate font-semibold":"truncate",style:{color:P?"var(--text-main)":"var(--text-muted)"},children:R.label})]},`${R.label}-${T}`)})})}),e.jsxs("div",{className:`flex min-w-0 items-center transition-[gap,transform] duration-300 ease-out ${$||W?"gap-2":"gap-2.5 sm:gap-3"}`,children:[e.jsx("span",{className:`flex-shrink-0 transition-[color,transform,opacity] duration-300 ease-out ${$?"scale-75 opacity-80":"scale-90 opacity-100"}`,style:{color:re?"var(--text-secondary)":"var(--text-muted)"},children:Q}),e.jsxs("div",{className:`flex min-w-0 flex-1 flex-wrap items-center transition-[gap] duration-300 ease-out ${$?"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 ${$?"text-sm sm:text-base":"text-lg sm:text-xl"}`,style:{color:"var(--text-main)"},children:r}),t&&e.jsx("p",{"aria-hidden":$,className:`overflow-hidden text-xs transition-[max-height,opacity,transform,margin] duration-300 ease-out ${$?"mt-0 max-h-0 -translate-y-1 opacity-0":"mt-0.5 max-h-5 translate-y-0 opacity-100"}`,style:{color:"var(--text-muted)"},children:t})]}),n&&e.jsx("div",{className:`page-header-meta flex min-w-0 flex-1 basis-full items-center overflow-visible transition-[gap,opacity,transform] duration-300 ease-out sm:basis-auto ${$?"translate-y-0 gap-1.5 opacity-95":"gap-2 opacity-100"}`,children:n})]})]})]}),a&&e.jsx("div",{className:`page-header-actions ml-auto flex max-w-full flex-shrink-0 flex-wrap items-center justify-end self-center overflow-visible transition-[gap,min-height,opacity,transform] duration-300 ease-out ${$?"min-h-9 gap-1 opacity-95":"min-h-9 gap-1.5 opacity-100"}`,children:e.jsx(ra.Provider,{value:{compact:!0,headerAction:!0},children:a})})]})})}function bs({children:r,currentPath:t=typeof window>"u"?"/":window.location.pathname,publicRoutes:a=["/","/login","/reset-password"],...n}){return a.includes(t)?e.jsx(e.Fragment,{children:r}):e.jsx(Ua,{currentPath:t,...n,children:r})}function Ga(){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 fs(r,t,a){try{const n=new URL(r),s=n.searchParams.get("callbackUrl");if(s){const c=new URL(s,n.origin);return c.searchParams.set("theme",t),a&&(c.searchParams.set("primeAuthOrigin",window.location.origin),c.searchParams.set("primeAuthProjectKey",a)),n.searchParams.set("callbackUrl",`${c.pathname}${c.search}${c.hash}`),n.toString()}return n.searchParams.set("theme",t),a&&(n.searchParams.set("primeAuthOrigin",window.location.origin),n.searchParams.set("primeAuthProjectKey",a)),n.toString()}catch{return r}}function ps({name:r,src:t,projectKey:a}){const[n,s]=l.useState("system"),c=l.useRef(null);l.useEffect(()=>{s(Ga());const p=new MutationObserver(()=>s(Ga()));return p.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>p.disconnect()},[]);const u=l.useMemo(()=>fs(t,n,a),[a,t,n]),b=l.useMemo(()=>{try{return new URL(u).origin}catch{return""}},[u]);return l.useEffect(()=>{if(!a)return;const p=a;function m(h){var $,C,N;if(h.source!==(($=c.current)==null?void 0:$.contentWindow)||b&&h.origin!==b)return;if(((C=h.data)==null?void 0:C.type)==="prime-microservice:overlay"){window.dispatchEvent(new CustomEvent("prime-auth:microservice-overlay",{detail:{active:!!h.data.active}}));return}if(((N=h.data)==null?void 0:N.type)!=="prime-microservice:navigation")return;const x=h.data.path;if(!x||!x.startsWith("/")||x.startsWith("//"))return;const g=`/apps/${encodeURIComponent(p)}${x}`;`${window.location.pathname}${window.location.search}${window.location.hash}`!==g&&(window.history.replaceState(window.history.state,"",g),window.dispatchEvent(new CustomEvent("prime-auth:microservice-navigation")))}return window.addEventListener("message",m),()=>{window.removeEventListener("message",m),window.dispatchEvent(new CustomEvent("prime-auth:microservice-overlay",{detail:{active:!1}}))}},[b,a]),e.jsx("div",{className:"flex h-full min-h-screen flex-col bg-[var(--bg-main)]",children:e.jsx("iframe",{ref:c,src:u,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 ms(){const[r,t]=l.useState(""),[a,n]=l.useState(!1),[s,c]=l.useState({width:96,height:96});return l.useEffect(()=>{let u=!1;return fetch("/api/microservices/prime-suite/chat-url",{cache:"no-store"}).then(b=>b.ok?b.json():null).then(b=>{!u&&(b!=null&&b.src)&&t(b.src)}).catch(()=>{}),()=>{u=!0}},[]),l.useEffect(()=>{const u=b=>{var m;if(((m=b.data)==null?void 0:m.type)!=="prime-suite-chat:state")return;const p=!!b.data.active;n(p),c({width:Ya(b.data.width,96,720),height:Ya(b.data.height,96,560)})};return window.addEventListener("message",u),()=>window.removeEventListener("message",u)},[]),r?e.jsx("iframe",{title:"Chat Bonsaif",src:r,allow:"clipboard-write",className:"fixed bottom-0 right-0 z-[70] border-0 bg-transparent transition-[width,height] duration-200",style:{width:a?`min(${s.width}px, 100vw)`:96,height:a?`min(${s.height}px, 100vh)`:96,background:"transparent",backgroundColor:"transparent",colorScheme:"normal"}}):null}function Ya(r,t,a){const n=typeof r=="number"&&Number.isFinite(r)?r:t;return Math.max(t,Math.min(a,Math.ceil(n)))}function hs(r){const t=document.documentElement,a=new MutationObserver(r);a.observe(t,{attributes:!0,attributeFilter:["class"]});const n=window.matchMedia("(prefers-color-scheme: dark)");return n.addEventListener("change",r),()=>{a.disconnect(),n.removeEventListener("change",r)}}function vs(){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 gs(){return"light"}function xs({position:r="bottom-center"}){const t=l.useSyncExternalStore(hs,vs,gs);return e.jsx(Jt.Toaster,{position:r,theme:t,richColors:!0,closeButton:!0})}function ys(r){const[t,a]=l.useState({}),[n,s]=l.useState(!1),c=l.useCallback(m=>n||t[m]?r[m]:void 0,[r,n,t]),u=l.useCallback(m=>{a(h=>({...h,[m]:!0}))},[]),b=l.useCallback(()=>{s(!0)},[]),p=l.useCallback(()=>{a({}),s(!1)},[]);return{submitted:n,touchedFields:t,getFieldError:c,touchField:u,submit:b,reset:p}}Object.defineProperty(Y,"toast",{enumerable:!0,get:()=>Jt.toast}),Y.Alert=Kn,Y.AuthShell=Ua,Y.BonsaifButton=Ln,Y.BonsaifUIToaster=xs,Y.Button=Te,Y.CalendarPicker=Jn,Y.Checkbox=Fr,Y.CodeBlock=tl,Y.CompactFilterSelect=nl,Y.CompactSearchInput=al,Y.ConfirmDialog=il,Y.CopyButton=Nt,Y.CopyLinkButton=dl,Y.DataSheets=Al,Y.DataTable=ma,Y.DateRangePicker=Bl,Y.Drawer=zl,Y.DropdownMenu=Fl,Y.DynamicDetailTabs=Un,Y.EmailField=io,Y.EmptyState=uo,Y.FieldLayoutEditor=vo,Y.FileUpload=mo,Y.FormField=$a,Y.GlobalScrollbars=ja,Y.InputField=$t,Y.LoadingState=la,Y.MicroserviceFrame=ps,Y.Modal=St,Y.MouseTooltip=dr,Y.MultiSelect=xo,Y.NumberField=yo,Y.PageHeader=us,Y.PageSearchInput=ea,Y.Pagination=No,Y.PhoneField=So,Y.PrimeAuthRouteShell=bs,Y.PrimeSuiteChatFrame=ms,Y.RadioGroup=Co,Y.RichTextEditor=$o,Y.SearchableSelect=rr,Y.SectionPanel=Lo,Y.StatusBadge=Ho,Y.StatusSelect=Fo,Y.StepWizard=zo,Y.Tabs=Po,Y.TextInput=Gr,Y.Textarea=Oa,Y.TextareaField=Uo,Y.Toggle=Ko,Y.UserAvatar=qa,Y.cn=Je,Y.emailFormat=Vl,Y.isValidEmail=Ct,Y.isValidPhone=Et,Y.matches=Jl,Y.maxLength=Yl,Y.maxValue=Zl,Y.minLength=Gl,Y.minValue=Xl,Y.phoneCountryCodeOptions=Ta,Y.phoneFormat=Kl,Y.required=Ul,Y.useValidationVisibility=ys,Y.validateForm=Ql,Object.defineProperty(Y,Symbol.toStringTag,{value:"Module"})}));
|