UNPKG

@birhaus/patterns

Version:

BIRHAUS v3.0 Radical Minimalist Pattern Components - Glass morphism ApprovalWorkflow, RoleManager, SmartSearch, FinancialDashboard, AuditTimeline

13 lines 75.5 kB
'use strict';var ha=require('react'),lucideReact=require('lucide-react'),dateFns=require('date-fns'),locale=require('date-fns/locale'),jsxRuntime=require('react/jsx-runtime'),themes=require('@birhaus/themes');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var ha__default=/*#__PURE__*/_interopDefault(ha);function pa(...e){return e.filter(Boolean).join(" ")}var ba={"iglesia.creada":"cre\xF3 una iglesia","iglesia.actualizada":"actualiz\xF3 una iglesia","iglesia.eliminada":"elimin\xF3 una iglesia","pastor.creado":"registr\xF3 un pastor","pastor.actualizado":"actualiz\xF3 un pastor","pastor.eliminado":"elimin\xF3 un pastor","donacion.registrada":"registr\xF3 una donaci\xF3n","donacion.anulada":"anul\xF3 una donaci\xF3n","transferencia.creada":"cre\xF3 una transferencia","transferencia.completada":"complet\xF3 una transferencia","gasto.registrado":"registr\xF3 un gasto","gasto.aprobado":"aprob\xF3 un gasto","gasto.rechazado":"rechaz\xF3 un gasto","usuario.login":"inici\xF3 sesi\xF3n","usuario.logout":"cerr\xF3 sesi\xF3n","resumen.enviado":"envi\xF3 un resumen","resumen.aprobado":"aprob\xF3 un resumen","resumen.rechazado":"rechaz\xF3 un resumen",create:"cre\xF3",update:"actualiz\xF3",delete:"elimin\xF3",approve:"aprob\xF3",reject:"rechaz\xF3",login:"inici\xF3 sesi\xF3n",logout:"cerr\xF3 sesi\xF3n"},za={creada:"text-green-600",creado:"text-green-600",registrada:"text-green-600",registrado:"text-green-600",actualizada:"text-blue-600",actualizado:"text-blue-600",eliminada:"text-red-600",eliminado:"text-red-600",anulada:"text-yellow-600",aprobado:"text-green-600",rechazado:"text-red-600",completada:"text-green-600",enviado:"text-blue-600",login:"text-gray-500",logout:"text-gray-500"};function Ze({events:e,showFilters:a=true,maxHeight:r="600px",className:s="",emptyMessage:d="No hay eventos que mostrar",filterAllEntitiesLabel:l="Todas las entidades",filterAllActionsLabel:n="Todas las acciones",clearFiltersLabel:v="Limpiar filtros",showDetailsLabel:i="Ver detalles",hideDetailsLabel:h="Ocultar detalles"}){let[f,p]=ha.useState("all"),[y,N]=ha.useState("all"),[k,M]=ha.useState(new Set),{entities:u,verbs:T}=ha.useMemo(()=>{let c=new Set,R=new Set;return e.forEach(L=>{L.entity&&c.add(L.entity),R.add(L.verb);}),{entities:Array.from(c).sort(),verbs:Array.from(R).sort()}},[e]),C=ha.useMemo(()=>e.filter(c=>!(f!=="all"&&c.entity!==f||y!=="all"&&c.verb!==y)),[e,f,y]),S=c=>{let R=new Set(k);R.has(c)?R.delete(c):R.add(c),M(R);},I=c=>{let R=c.split(".").pop()||"";return za[R]||"text-gray-700"},pe=c=>!c||Object.keys(c).length===0?null:jsxRuntime.jsx("div",{className:"mt-2 p-3 bg-gray-50 rounded-md text-xs space-y-1 border",children:Object.entries(c).map(([R,L])=>jsxRuntime.jsxs("div",{className:"flex gap-2",children:[jsxRuntime.jsxs("span",{className:"text-gray-500 font-medium min-w-20",children:[R,":"]}),jsxRuntime.jsx("span",{className:"text-gray-700 flex-1",children:typeof L=="object"?JSON.stringify(L,null,2):String(L)})]},R))});return jsxRuntime.jsxs("div",{className:pa("space-y-4",s),"data-birhaus-component":"audit-timeline",children:[a&&(u.length>0||T.length>0)&&jsxRuntime.jsxs("div",{className:"flex gap-3 items-center p-3 bg-gray-50 border border-gray-200 rounded-md",children:[jsxRuntime.jsx(lucideReact.Filter,{className:"h-4 w-4 text-gray-400"}),u.length>0&&jsxRuntime.jsxs("select",{value:f,onChange:c=>p(c.target.value),className:"px-3 py-1 border border-gray-300 rounded-md text-sm bg-white focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-primary-500",children:[jsxRuntime.jsx("option",{value:"all",children:l}),u.map(c=>jsxRuntime.jsx("option",{value:c,children:c.charAt(0).toUpperCase()+c.slice(1)},c))]}),T.length>0&&jsxRuntime.jsxs("select",{value:y,onChange:c=>N(c.target.value),className:"px-3 py-1 border border-gray-300 rounded-md text-sm bg-white focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-primary-500",children:[jsxRuntime.jsx("option",{value:"all",children:n}),T.map(c=>jsxRuntime.jsx("option",{value:c,children:ba[c]||c},c))]}),(f!=="all"||y!=="all")&&jsxRuntime.jsx("button",{onClick:()=>{p("all"),N("all");},className:"text-sm text-primary-600 hover:text-primary-700 hover:underline focus:outline-none focus:ring-2 focus:ring-primary-500 px-2 py-1 rounded",children:v})]}),jsxRuntime.jsx("div",{className:"space-y-2 overflow-y-auto pr-2 scrollbar-thin scrollbar-thumb-gray-300 scrollbar-track-gray-100",style:{maxHeight:r},children:C.length===0?jsxRuntime.jsxs("div",{className:"text-center py-8 text-gray-500 bg-gray-50 rounded-lg border-2 border-dashed border-gray-200",children:[jsxRuntime.jsx(lucideReact.Clock,{className:"h-8 w-8 text-gray-400 mx-auto mb-2"}),jsxRuntime.jsx("p",{children:d})]}):C.map((c,R)=>{let L=k.has(c.id),O=c.payload&&Object.keys(c.payload).length>0;return jsxRuntime.jsxs("div",{className:"flex gap-3 p-4 bg-white border border-gray-200 rounded-lg hover:border-gray-300 hover:shadow-sm transition-all duration-150",children:[jsxRuntime.jsxs("div",{className:"flex flex-col items-center",children:[jsxRuntime.jsx("div",{className:"w-2 h-2 rounded-full bg-primary-600 mt-2 flex-shrink-0"}),R<C.length-1&&jsxRuntime.jsx("div",{className:"w-px flex-1 bg-gray-200 mt-2"})]}),jsxRuntime.jsx("div",{className:"flex-1 min-w-0",children:jsxRuntime.jsxs("div",{className:"flex items-start justify-between gap-2",children:[jsxRuntime.jsxs("div",{className:"flex-1",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[jsxRuntime.jsx(lucideReact.User,{className:"h-3 w-3 text-gray-400"}),jsxRuntime.jsx("span",{className:"text-sm font-medium text-gray-900",children:c.actor_name||"Usuario"}),jsxRuntime.jsx("span",{className:pa("text-sm font-medium",I(c.verb)),children:ba[c.verb]||c.verb}),c.entity&&jsxRuntime.jsx("span",{className:"text-xs px-2 py-1 bg-gray-200 text-gray-700 rounded-full",children:c.entity})]}),c.entity_id&&jsxRuntime.jsxs("div",{className:"text-xs text-gray-500 mt-1 font-mono",children:["ID: ",c.entity_id]}),O&&jsxRuntime.jsx("button",{onClick:()=>S(c.id),className:"flex items-center gap-1 mt-2 text-xs text-primary-600 hover:text-primary-700 hover:underline focus:outline-none focus:ring-2 focus:ring-primary-500 px-1 py-0.5 rounded",children:L?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(lucideReact.ChevronUp,{className:"h-3 w-3"}),h]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(lucideReact.ChevronDown,{className:"h-3 w-3"}),i]})}),L&&pe(c.payload)]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1 text-xs text-gray-500 whitespace-nowrap",children:[jsxRuntime.jsx(lucideReact.Clock,{className:"h-3 w-3"}),jsxRuntime.jsx("span",{title:new Date(c.created_at).toLocaleString("es-ES"),children:dateFns.formatDistanceToNow(new Date(c.created_at),{addSuffix:true,locale:locale.es})})]})]})})]},c.id)})})]})}function ea(){let[e,a]=ha.useState([]);return {events:e,addEvent:d=>{let l={...d,id:`audit_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,created_at:new Date().toISOString()};return a(n=>[l,...n]),l},clearEvents:()=>{a([]);}}}function _a({events:e,showFilters:a=true,maxHeight:r="600px",glassVariant:s="medium",floatingCards:d=true,magneticEvents:l=true,enableGlass:n=true,reducedMotion:v=false,themeName:i="financial",glowCritical:h=true,emptyMessage:f="No hay eventos de auditor\xEDa para mostrar",filterAllEntitiesLabel:p="Todas las entidades",filterAllActionsLabel:y="Todas las acciones",clearFiltersLabel:N="Limpiar filtros",showDetailsLabel:k="Ver detalles",hideDetailsLabel:M="Ocultar detalles",className:u,...T}){let C=themes.useBirhausThemeV3(i),S=["birhaus-audit-timeline-v3","transition-all duration-500 ease-smooth",n?"backdrop-blur-lg bg-white/70 rounded-3xl border-white/30 border":"bg-white rounded-lg border border-gray-200",d?"p-8 shadow-2xl":"p-6 shadow-lg",u||""].filter(Boolean).join(" ");return jsxRuntime.jsxs("div",{className:S,"data-birhaus-component":"audit-timeline-v3","data-birhaus-version":"3.0","data-birhaus-theme":i,style:{maxHeight:r,"--birhaus-glass-blur":n?"12px":"0px","--birhaus-border-radius":"24px","--birhaus-spacing-generous":"2rem","--birhaus-animation-duration":v?"0ms":"300ms",...C?.cssVariables},children:[jsxRuntime.jsx(Ze,{events:e,showFilters:a,maxHeight:r,emptyMessage:f,filterAllEntitiesLabel:p,filterAllActionsLabel:y,clearFiltersLabel:N,showDetailsLabel:k,hideDetailsLabel:M,className:"space-y-6",...T}),n&&e.length>0&&jsxRuntime.jsx("div",{className:"absolute left-8 top-20 bottom-8 w-0.5 pointer-events-none",style:{background:`linear-gradient(180deg, rgba(59, 130, 246, 0.3) 0%, rgba(156, 163, 175, 0.2) 100%)`,backdropFilter:"blur(8px)",borderRadius:"2px"}})]})}function Ua({glass:e=true,generousSpacing:a=true,radicalBorderRadius:r=true,magnetic:s=true,glow:d=false,severity:l="info",expanded:n=false,onToggleExpanded:v,...i}){let h=()=>{let p=["transition-all duration-300 ease-smooth","border hover:shadow-xl relative"];return e?p.push("backdrop-blur-md bg-white/80 border-white/30"):p.push("bg-white border-gray-200"),a?p.push("p-6"):p.push("p-4"),r?p.push("rounded-2xl"):p.push("rounded-lg"),s&&p.push("hover:scale-[1.02] hover:-translate-y-1 cursor-pointer"),d&&l==="critical"?p.push("shadow-2xl shadow-red-500/20 ring-2 ring-red-500/30"):d&&l==="error"&&p.push("shadow-xl shadow-red-500/10 ring-1 ring-red-500/20"),p.join(" ")},f=()=>{switch(l){case "critical":return "text-red-600 bg-red-100";case "error":return "text-red-600 bg-red-50";case "warning":return "text-yellow-600 bg-yellow-50";default:return "text-blue-600 bg-blue-50"}};return jsxRuntime.jsxs("div",{className:h(),onClick:v,children:[jsxRuntime.jsxs("div",{className:"flex items-start justify-between mb-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center space-x-3",children:[jsxRuntime.jsx("div",{className:`px-3 py-1 rounded-full text-xs font-medium ${f()}`,children:i.verb}),jsxRuntime.jsx("div",{className:"text-sm text-gray-600",children:i.actor_name||i.actor_id})]}),jsxRuntime.jsx("div",{className:"text-xs text-gray-500",children:new Date(i.created_at).toLocaleString("es-ES")})]}),jsxRuntime.jsxs("div",{className:"space-y-3",children:[jsxRuntime.jsxs("div",{className:"text-sm text-gray-800",children:[jsxRuntime.jsx("span",{className:"font-medium",children:i.verb}),i.entity&&jsxRuntime.jsxs("span",{children:[" en ",jsxRuntime.jsx("span",{className:"font-medium",children:i.entity})]}),i.entity_id&&jsxRuntime.jsxs("span",{className:"text-gray-600",children:[" (ID: ",i.entity_id,")"]})]}),n&&Object.keys(i.payload||{}).length>0&&jsxRuntime.jsxs("div",{className:`mt-4 p-4 rounded-xl ${e?"bg-white/50 border border-white/40":"bg-gray-50 border border-gray-200"}`,children:[jsxRuntime.jsx("h4",{className:"text-sm font-medium text-gray-700 mb-2",children:"Detalles del evento:"}),jsxRuntime.jsx("pre",{className:"text-xs text-gray-600 overflow-x-auto",children:JSON.stringify(i.payload,null,2)})]})]}),Object.keys(i.payload||{}).length>0&&jsxRuntime.jsx("div",{className:"mt-3 flex justify-center",children:jsxRuntime.jsxs("button",{className:"text-xs text-gray-500 hover:text-gray-700 flex items-center space-x-1",children:[jsxRuntime.jsx("span",{children:n?"Ocultar detalles":"Ver detalles"}),jsxRuntime.jsx("svg",{className:`h-3 w-3 transition-transform ${n?"rotate-180":""}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]})})]})}function Oa(e,a){let r=ea(),[s,d]=ha__default.default.useState(a||{}),l=ha__default.default.useCallback(n=>{d(v=>({...v,...n}));},[]);return {...r,v3Configuration:s,updateV3Configuration:l,enableGlassMorphism:()=>l({enableGlass:true,glassVariant:"medium"}),enableFloatingCards:()=>l({floatingCards:true}),enableMagneticEvents:()=>l({magneticEvents:true}),setTheme:n=>l({themeName:n}),enablePerformanceMode:()=>l({reducedMotion:true,enableGlass:false,magneticEvents:false}),isV3Enabled:true}}var nt={idioma:"es",moneda:"PYG",formatoNumero:"es-PY",mostrarGraficos:true,mostrarObjetivos:true,mostrarProyecciones:true,diasProyeccion:7,actualizacionAutomatica:false,intervaloActualizacion:15};function ot({datos:e,color:a,altura:r=60,mostrarPuntos:s=false}){let{ruta:d,area:l,minY:n,maxY:v}=ha.useMemo(()=>{if(e.length===0)return {ruta:"",area:"",minY:0,maxY:0};let i=e.map(T=>T.valor),h=Math.min(...i),f=Math.max(...i),p=f-h||1,y=200,N=4,k=e.map((T,C)=>{let S=C/(e.length-1)*(y-N*2)+N,I=r-N-(T.valor-h)/p*(r-N*2);return {x:S,y:I,valor:T.valor}}),M=k.reduce((T,C,S)=>`${T} ${S===0?"M":"L"} ${C.x} ${C.y}`,""),u=`${M} L ${k[k.length-1].x} ${r-N} L ${N} ${r-N} Z`;return {ruta:M,area:u,minY:h,maxY:f}},[e,r]);return e.length===0?jsxRuntime.jsx("div",{className:"flex items-center justify-center h-full text-gray-400",children:jsxRuntime.jsx(lucideReact.BarChart3,{className:"w-6 h-6"})}):jsxRuntime.jsxs("svg",{width:"200",height:r,className:"overflow-visible",children:[jsxRuntime.jsx("path",{d:l,fill:`url(#gradiente-${a.replace("#","")})`,opacity:.2}),jsxRuntime.jsx("path",{d,stroke:a,strokeWidth:2,fill:"none",strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntime.jsx("defs",{children:jsxRuntime.jsxs("linearGradient",{id:`gradiente-${a.replace("#","")}`,x1:"0%",y1:"0%",x2:"0%",y2:"100%",children:[jsxRuntime.jsx("stop",{offset:"0%",stopColor:a,stopOpacity:.4}),jsxRuntime.jsx("stop",{offset:"100%",stopColor:a,stopOpacity:0})]})}),s&&d&&e.map((i,h)=>{let f=h/(e.length-1)*192+4,p=r-4-(i.valor-n)/(v-n||1)*(r-8);return jsxRuntime.jsx("circle",{cx:f,cy:p,r:"2",fill:a,className:"opacity-60 hover:opacity-100 transition-opacity"},h)})]})}function lt({tendencia:e,tama\u00F1o:a="mediano",mostrarTexto:r=true,idioma:s}){let d=e.direccion==="subida"?lucideReact.TrendingUp:e.direccion==="bajada"?lucideReact.TrendingDown:lucideReact.Minus,l=e.direccion==="subida"?"text-green-600":e.direccion==="bajada"?"text-red-600":"text-gray-500",n=a==="peque\xF1o"?"w-3 h-3":a==="grande"?"w-5 h-5":"w-4 h-4",v=s==="es"?e.direccion==="subida"?"Subida":e.direccion==="bajada"?"Bajada":"Estable":e.direccion==="subida"?"Up":e.direccion==="bajada"?"Down":"Stable";return jsxRuntime.jsxs("div",{className:`flex items-center space-x-1 ${l}`,children:[jsxRuntime.jsx(d,{className:n}),r&&jsxRuntime.jsxs("div",{className:"flex items-center space-x-1",children:[jsxRuntime.jsxs("span",{className:`font-medium ${a==="peque\xF1o"?"text-xs":a==="grande"?"text-base":"text-sm"}`,children:[e.porcentaje>=0?"+":"",e.porcentaje.toFixed(1),"%"]}),jsxRuntime.jsxs("span",{className:"text-xs text-gray-500",children:["(",v,")"]})]})]})}function dt({estado:e,tama\u00F1o:a="mediano",idioma:r}){let s={saludable:{icono:lucideReact.CheckCircle,color:"text-green-600 bg-green-100",etiquetaEs:"Saludable",etiquetaEn:"Healthy"},precaucion:{icono:lucideReact.AlertCircle,color:"text-yellow-600 bg-yellow-100",etiquetaEs:"Precauci\xF3n",etiquetaEn:"Warning"},critico:{icono:lucideReact.AlertCircle,color:"text-red-600 bg-red-100",etiquetaEs:"Cr\xEDtico",etiquetaEn:"Critical"}},{icono:d,color:l,etiquetaEs:n,etiquetaEn:v}=s[e],i=a==="peque\xF1o"?"w-3 h-3":a==="grande"?"w-5 h-5":"w-4 h-4";return jsxRuntime.jsxs("div",{className:`flex items-center space-x-1 px-2 py-1 rounded-full text-xs ${l}`,children:[jsxRuntime.jsx(d,{className:i}),jsxRuntime.jsx("span",{className:"font-medium",children:r==="es"?n:v})]})}function ct({metrica:e,configuracion:a,compacto:r=false,mostrarGrafico:s=true,alSeleccionar:d,alMostrarDetalles:l}){let[n,v]=ha.useState(s),i=ha.useMemo(()=>{let y=N=>new Intl.NumberFormat(a.formatoNumero,{style:"currency",currency:a.moneda,minimumFractionDigits:a.moneda==="PYG"?0:2,maximumFractionDigits:a.moneda==="PYG"?0:2}).format(N);return e.unidad==="moneda"?y(e.valor):e.unidad==="porcentaje"?`${e.valor.toFixed(1)}%`:`${e.valor.toLocaleString(a.formatoNumero)}`},[e.valor,e.unidad,a]),h=ha.useMemo(()=>{if(!e.objetivo)return null;let y=e.valor/e.objetivo*100;return Math.min(y,100)},[e.valor,e.objetivo]),f=ha.useMemo(()=>{switch(e.estado){case "saludable":return "#10b981";case "precaucion":return "#f59e0b";case "critico":return "#ef4444";default:return "#6366f1"}},[e.estado]),p=ha.useMemo(()=>{switch(e.categoria){case "ingresos":return "bg-green-100 text-green-800";case "gastos":return "bg-red-100 text-red-800";case "balance":return "bg-blue-100 text-blue-800";case "proyeccion":return "bg-purple-100 text-purple-800";default:return "bg-gray-100 text-gray-800"}},[e.categoria]);return jsxRuntime.jsxs("div",{className:` relative overflow-hidden transition-all duration-200 hover:shadow-lg bg-white rounded-xl shadow-sm border border-gray-200 ${r?"p-4":"p-6"} ${d?"cursor-pointer hover:border-blue-300":""} ${e.estado==="critico"?"ring-2 ring-red-200 ring-opacity-50":""} ${e.estado==="precaucion"?"ring-2 ring-yellow-200 ring-opacity-50":""} ${e.estado==="saludable"?"ring-2 ring-green-200 ring-opacity-30":""} `,onClick:()=>d?.(e.id),children:[jsxRuntime.jsxs("div",{className:"flex items-start justify-between mb-4",children:[jsxRuntime.jsxs("div",{className:"flex-1",children:[jsxRuntime.jsxs("div",{className:"flex items-center space-x-2 mb-1",children:[jsxRuntime.jsx("h3",{className:`font-semibold text-gray-900 ${r?"text-sm":"text-base"}`,children:a.idioma==="es"?e.nombreEs:e.nombreEn}),jsxRuntime.jsx("span",{className:`px-2 py-1 text-xs font-medium rounded-full ${p}`,children:e.categoria})]}),jsxRuntime.jsx("p",{className:`text-gray-600 ${r?"text-xs":"text-sm"}`,children:a.idioma==="es"?e.descripcionEs:e.descripcionEn})]}),jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx(dt,{estado:e.estado,tama\u00F1o:r?"peque\xF1o":"mediano",idioma:a.idioma}),l&&jsxRuntime.jsx("button",{onClick:y=>{y.stopPropagation(),l(e.id);},className:"p-1 text-gray-400 hover:text-gray-600 transition-colors",children:jsxRuntime.jsx(lucideReact.Info,{className:"w-4 h-4"})})]})]}),jsxRuntime.jsxs("div",{className:"mb-4",children:[jsxRuntime.jsx("div",{className:`font-bold text-gray-900 ${r?"text-2xl":"text-3xl"}`,children:i}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between mt-2",children:[jsxRuntime.jsx(lt,{tendencia:e.tendencia,tama\u00F1o:r?"peque\xF1o":"mediano",idioma:a.idioma}),jsxRuntime.jsx("span",{className:`text-gray-500 ${r?"text-xs":"text-sm"}`,children:e.tendencia.periodo})]})]}),a.mostrarObjetivos&&e.objetivo&&h!==null&&jsxRuntime.jsxs("div",{className:"mb-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-1",children:[jsxRuntime.jsxs("span",{className:`text-gray-600 flex items-center space-x-1 ${r?"text-xs":"text-sm"}`,children:[jsxRuntime.jsx(lucideReact.Target,{className:"w-3 h-3"}),jsxRuntime.jsx("span",{children:a.idioma==="es"?"Objetivo":"Target"})]}),jsxRuntime.jsx("span",{className:`font-medium text-gray-900 ${r?"text-xs":"text-sm"}`,children:e.unidad==="moneda"?new Intl.NumberFormat(a.formatoNumero,{style:"currency",currency:a.moneda,minimumFractionDigits:0,maximumFractionDigits:0}).format(e.objetivo):`${e.objetivo} ${e.unidad==="porcentaje"?"%":""}`})]}),jsxRuntime.jsx("div",{className:"w-full bg-gray-200 rounded-full h-2",children:jsxRuntime.jsx("div",{className:`h-2 rounded-full transition-all duration-500 ${e.estado==="saludable"?"bg-green-500":e.estado==="precaucion"?"bg-yellow-500":"bg-red-500"}`,style:{width:`${h}%`}})}),jsxRuntime.jsxs("div",{className:"flex justify-between mt-1",children:[jsxRuntime.jsx("span",{className:"text-xs text-gray-500",children:"0"}),jsxRuntime.jsxs("span",{className:"text-xs text-gray-500",children:[h.toFixed(0),"%"]})]})]}),a.mostrarGraficos&&e.datosTemporales.length>0&&jsxRuntime.jsxs("div",{className:"border-t border-gray-100 pt-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-2",children:[jsxRuntime.jsx("span",{className:`text-gray-600 font-medium ${r?"text-xs":"text-sm"}`,children:a.idioma==="es"?"Tendencia (30 d\xEDas)":"Trend (30 days)"}),jsxRuntime.jsx("button",{onClick:y=>{y.stopPropagation(),v(!n);},className:"p-1 text-gray-400 hover:text-gray-600 transition-colors",children:n?jsxRuntime.jsx(lucideReact.EyeOff,{className:"w-3 h-3"}):jsxRuntime.jsx(lucideReact.Eye,{className:"w-3 h-3"})})]}),n&&jsxRuntime.jsx("div",{className:"flex justify-center",children:jsxRuntime.jsx(ot,{datos:e.datosTemporales,color:f,altura:r?40:60,mostrarPuntos:true})})]}),!r&&jsxRuntime.jsx("div",{className:"mt-4 pt-4 border-t border-gray-100",children:jsxRuntime.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("span",{className:"text-gray-500",children:a.idioma==="es"?"Actual":"Current"}),jsxRuntime.jsx("div",{className:"font-medium text-gray-900",children:e.unidad==="moneda"?new Intl.NumberFormat(a.formatoNumero,{style:"currency",currency:a.moneda,minimumFractionDigits:0,maximumFractionDigits:0}).format(e.tendencia.actual):`${e.tendencia.actual.toFixed(1)} ${e.unidad==="porcentaje"?"%":""}`})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("span",{className:"text-gray-500",children:a.idioma==="es"?"Anterior":"Previous"}),jsxRuntime.jsx("div",{className:"font-medium text-gray-900",children:e.unidad==="moneda"?new Intl.NumberFormat(a.formatoNumero,{style:"currency",currency:a.moneda,minimumFractionDigits:0,maximumFractionDigits:0}).format(e.tendencia.anterior):`${e.tendencia.anterior.toFixed(1)} ${e.unidad==="porcentaje"?"%":""}`})]})]})}),jsxRuntime.jsxs("div",{className:"mt-2 text-xs text-gray-400 flex items-center space-x-1",children:[jsxRuntime.jsx(lucideReact.Clock,{className:"w-3 h-3"}),jsxRuntime.jsxs("span",{children:[a.idioma==="es"?"Actualizado: ":"Updated: ",new Date(e.ultimaActualizacion).toLocaleString(a.formatoNumero)]})]})]})}function ra({metricas:e,posicionCaja:a,proyecciones:r=[],alertas:s=[],configuracion:d={},filtrosPeriodo:l,compacto:n=false,soloLectura:v=false,alCargarDatos:i,alCambiarPeriodo:h,alConfirmarAlerta:f,alExportarDatos:p,alSeleccionarMetrica:y,alMostrarDetalles:N,className:k="",variante:M="completo"}){let[u]=ha.useState({...nt,...d}),[T,C]=ha.useState(false),[S,I]=ha.useState(false),pe=ha.useCallback(async()=>{if(i)try{C(!0),await i();}catch(g){console.error("Error al actualizar datos financieros:",g);}finally{C(false);}},[i]),c=ha.useCallback(g=>new Intl.NumberFormat(u.formatoNumero,{style:"currency",currency:u.moneda,minimumFractionDigits:u.moneda==="PYG"?0:2,maximumFractionDigits:u.moneda==="PYG"?0:2}).format(g),[u]),R=ha.useCallback(g=>g>5e7?"text-green-600":g>1e7?"text-blue-600":g>0?"text-amber-600":"text-red-600",[]),L=ha.useCallback(g=>g>5e7?{icono:lucideReact.TrendingUp,variante:"success"}:g>1e7?{icono:lucideReact.DollarSign,variante:"info"}:g>0?{icono:lucideReact.AlertCircle,variante:"warning"}:{icono:lucideReact.TrendingDown,variante:"error"},[]),O=ha.useMemo(()=>n?e.slice(0,4):e.slice(0,7),[e,n]),_=ha.useMemo(()=>s.filter(g=>g.prioridad==="alta"&&!g.confirmado).slice(0,3),[s]),{icono:le,variante:de}=L(a.balanceTotal);return jsxRuntime.jsxs("div",{className:`space-y-6 ${k}`,children:[_.length>0&&jsxRuntime.jsxs("div",{className:"p-4 bg-red-50 border border-red-200 rounded-xl",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsxs("div",{className:"flex items-center space-x-3",children:[jsxRuntime.jsx(lucideReact.AlertCircle,{className:"w-5 h-5 text-red-600"}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("h3",{className:"font-medium text-red-900",children:[_.length," ",u.idioma==="es"?"Alerta":"Alert",_.length!==1?"s":"",u.idioma==="es"?" Cr\xEDtica":" Critical",_.length!==1?"s":""]}),jsxRuntime.jsx("p",{className:"text-sm text-red-700",children:u.idioma==="es"?"Requieren atenci\xF3n inmediata":"Require immediate attention"})]})]}),f&&jsxRuntime.jsxs("button",{onClick:()=>_.forEach(g=>f(g.id)),className:"px-3 py-1 text-sm font-medium text-red-700 border border-red-300 rounded-lg hover:bg-red-100 transition-colors",children:[jsxRuntime.jsx(lucideReact.CheckCircle,{className:"w-4 h-4 mr-1 inline"}),u.idioma==="es"?"Confirmar Todas":"Confirm All"]})]}),_.slice(0,2).map(g=>jsxRuntime.jsx("div",{className:"mt-3 p-3 bg-white rounded-lg border border-red-200",children:jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h4",{className:"font-medium text-gray-900",children:u.idioma==="es"?g.tituloEs:g.tituloEn}),jsxRuntime.jsx("p",{className:"text-sm text-gray-600",children:u.idioma==="es"?g.mensajeEs:g.mensajeEn})]}),f&&jsxRuntime.jsx("button",{onClick:()=>f(g.id),className:"p-1 text-gray-400 hover:text-gray-600 transition-colors",children:jsxRuntime.jsx(lucideReact.CheckCircle,{className:"w-4 h-4"})})]})},g.id))]}),jsxRuntime.jsxs("div",{className:"overflow-hidden bg-white rounded-xl shadow-sm border border-gray-200",children:[jsxRuntime.jsxs("div",{className:"bg-gradient-to-r from-blue-50 to-indigo-50 p-6 border-b border-blue-100",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center space-x-3",children:[jsxRuntime.jsx("div",{className:"p-2 bg-blue-500 text-white rounded-lg",children:jsxRuntime.jsx(lucideReact.Wallet,{className:"w-5 h-5"})}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h2",{className:"text-lg font-semibold text-gray-900",children:u.idioma==="es"?"Posici\xF3n de Caja":"Cash Position"}),jsxRuntime.jsxs("p",{className:"text-sm text-gray-500",children:[u.idioma==="es"?"Actualizado ":"Updated ",new Date(a.ultimaActualizacion).toLocaleTimeString(u.formatoNumero)]})]})]}),!v&&jsxRuntime.jsxs("button",{onClick:pe,disabled:T,className:"px-3 py-2 text-sm font-medium text-gray-700 bg-white border border-gray-300 rounded-lg hover:bg-gray-50 disabled:opacity-50 transition-colors",children:[jsxRuntime.jsx(lucideReact.RefreshCw,{className:`w-4 h-4 mr-2 inline ${T?"animate-spin":""}`}),u.idioma==="es"?"Actualizar":"Refresh"]})]}),jsxRuntime.jsxs("div",{className:"flex items-end justify-between",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("p",{className:"text-sm font-medium text-gray-600 mb-1",children:u.idioma==="es"?"Balance Total":"Total Balance"}),jsxRuntime.jsx("p",{className:`text-3xl font-bold ${R(a.balanceTotal)}`,children:c(a.balanceTotal)})]}),jsxRuntime.jsx("div",{className:`p-3 rounded-lg ${de==="success"?"bg-green-100 text-green-600":de==="info"?"bg-blue-100 text-blue-600":de==="warning"?"bg-amber-100 text-amber-600":"bg-red-100 text-red-600"}`,children:jsxRuntime.jsx(le,{className:"w-6 h-6"})})]})]}),jsxRuntime.jsx("div",{className:"p-6",children:jsxRuntime.jsxs("div",{className:"grid grid-cols-4 gap-4",children:[jsxRuntime.jsxs("div",{className:"text-center",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-center mb-2",children:[jsxRuntime.jsx(lucideReact.Banknote,{className:"w-4 h-4 text-green-500 mr-1"}),jsxRuntime.jsx("p",{className:"text-sm font-medium text-gray-500",children:u.idioma==="es"?"Efectivo":"Cash"})]}),jsxRuntime.jsx("p",{className:"text-lg font-semibold text-gray-900",children:c(a.cuentas.efectivo)})]}),jsxRuntime.jsxs("div",{className:"text-center border-x border-gray-200",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-center mb-2",children:[jsxRuntime.jsx(lucideReact.Building,{className:"w-4 h-4 text-blue-500 mr-1"}),jsxRuntime.jsx("p",{className:"text-sm font-medium text-gray-500",children:u.idioma==="es"?"Banco":"Bank"})]}),jsxRuntime.jsx("p",{className:"text-lg font-semibold text-gray-900",children:c(a.cuentas.banco)})]}),jsxRuntime.jsxs("div",{className:"text-center border-r border-gray-200",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-center mb-2",children:[jsxRuntime.jsx(lucideReact.Clock,{className:"w-4 h-4 text-amber-500 mr-1"}),jsxRuntime.jsx("p",{className:"text-sm font-medium text-gray-500",children:u.idioma==="es"?"Pendiente":"Pending"})]}),jsxRuntime.jsx("p",{className:"text-lg font-semibold text-amber-600",children:c(a.cuentas.pendiente)})]}),jsxRuntime.jsxs("div",{className:"text-center",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-center mb-2",children:[jsxRuntime.jsx(lucideReact.CreditCard,{className:"w-4 h-4 text-purple-500 mr-1"}),jsxRuntime.jsx("p",{className:"text-sm font-medium text-gray-500",children:u.idioma==="es"?"Otros":"Others"})]}),jsxRuntime.jsx("p",{className:"text-lg font-semibold text-gray-900",children:c(a.cuentas.otros)})]})]})})]}),M!=="metricas-solo"&&jsxRuntime.jsx("div",{className:`grid gap-6 ${n?"grid-cols-1 md:grid-cols-2":"grid-cols-1 md:grid-cols-2 lg:grid-cols-3"}`,children:O.map(g=>jsxRuntime.jsx(ct,{metrica:g,configuracion:u,compacto:n,mostrarGrafico:u.mostrarGraficos,alSeleccionar:y,alMostrarDetalles:N?A=>N("metrica",A):void 0},g.id))}),u.mostrarProyecciones&&r.length>0&&M==="completo"&&jsxRuntime.jsx("div",{className:"bg-white rounded-xl shadow-sm border border-gray-200",children:jsxRuntime.jsxs("div",{className:"p-6",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-6",children:[jsxRuntime.jsxs("div",{className:"flex items-center space-x-3",children:[jsxRuntime.jsx("div",{className:"p-2 bg-gray-100 rounded-lg",children:jsxRuntime.jsx(lucideReact.Calendar,{className:"w-5 h-5 text-gray-600"})}),jsxRuntime.jsx("h3",{className:"text-lg font-semibold text-gray-900",children:u.idioma==="es"?`Proyecci\xF3n de Flujo - Pr\xF3ximos ${u.diasProyeccion} D\xEDas`:`Cash Flow Projection - Next ${u.diasProyeccion} Days`})]}),jsxRuntime.jsx("button",{onClick:()=>I(!S),className:"text-sm text-blue-600 hover:text-blue-700 font-medium transition-colors",children:S?u.idioma==="es"?"Ocultar detalles":"Hide details":u.idioma==="es"?"Ver detalles":"Show details"})]}),jsxRuntime.jsx("div",{className:"space-y-3",children:r.slice(0,u.diasProyeccion).map((g,A)=>{let we=A===0,ce=g.ingresosEsperados-g.gastosEsperados;return jsxRuntime.jsx("div",{className:`p-4 rounded-lg border ${we?"border-blue-200 bg-blue-50":"border-gray-200 bg-gray-50"}`,children:jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsxs("div",{className:"flex-1",children:[jsxRuntime.jsxs("div",{className:"flex items-center space-x-2 mb-2",children:[jsxRuntime.jsx("p",{className:"font-medium text-gray-900",children:new Date(g.fecha).toLocaleDateString(u.formatoNumero,{weekday:"long",day:"numeric"})}),we&&jsxRuntime.jsx("span",{className:"px-2 py-0.5 text-xs font-medium bg-blue-100 text-blue-700 rounded-full",children:u.idioma==="es"?"Hoy":"Today"}),jsxRuntime.jsxs("span",{className:`px-2 py-0.5 text-xs font-medium rounded-full ${g.confianza==="alta"?"bg-green-100 text-green-700":g.confianza==="media"?"bg-amber-100 text-amber-700":"bg-gray-100 text-gray-700"}`,children:[u.idioma==="es"?g.confianza==="alta"?"Alta":g.confianza==="media"?"Media":"Baja":g.confianza==="alta"?"High":g.confianza==="media"?"Medium":"Low"," ",u.idioma==="es"?"certeza":"confidence"]})]}),S&&jsxRuntime.jsxs("div",{className:"grid grid-cols-3 gap-4 mb-2 text-sm",children:[jsxRuntime.jsxs("div",{className:"flex items-center space-x-1",children:[jsxRuntime.jsx(lucideReact.ArrowUpRight,{className:"w-4 h-4 text-green-500"}),jsxRuntime.jsx("span",{className:"text-gray-600",children:u.idioma==="es"?"Ingresos:":"Income:"}),jsxRuntime.jsx("span",{className:"font-medium text-green-600",children:c(g.ingresosEsperados)})]}),jsxRuntime.jsxs("div",{className:"flex items-center space-x-1",children:[jsxRuntime.jsx(lucideReact.ArrowDownRight,{className:"w-4 h-4 text-red-500"}),jsxRuntime.jsx("span",{className:"text-gray-600",children:u.idioma==="es"?"Gastos:":"Expenses:"}),jsxRuntime.jsx("span",{className:"font-medium text-red-600",children:c(g.gastosEsperados)})]}),jsxRuntime.jsxs("div",{className:"flex items-center space-x-1",children:[jsxRuntime.jsx("span",{className:"text-gray-600",children:u.idioma==="es"?"Neto:":"Net:"}),jsxRuntime.jsxs("span",{className:`font-medium ${ce>=0?"text-green-600":"text-red-600"}`,children:[ce>=0?"+":"",c(ce)]})]})]})]}),jsxRuntime.jsxs("div",{className:"text-right",children:[jsxRuntime.jsx("p",{className:"text-sm text-gray-500 mb-1",children:u.idioma==="es"?"Balance proyectado":"Projected balance"}),jsxRuntime.jsx("p",{className:`text-lg font-semibold ${R(g.balanceProyectado)}`,children:c(g.balanceProyectado)})]})]})},A)})}),r.some(g=>g.balanceProyectado<1e7)&&jsxRuntime.jsx("div",{className:"mt-4 p-4 bg-amber-50 border border-amber-200 rounded-lg",children:jsxRuntime.jsxs("div",{className:"flex items-start space-x-3",children:[jsxRuntime.jsx(lucideReact.AlertCircle,{className:"w-5 h-5 text-amber-600 mt-0.5"}),jsxRuntime.jsxs("div",{className:"flex-1",children:[jsxRuntime.jsx("p",{className:"text-sm font-medium text-amber-800",children:u.idioma==="es"?"Alerta de Flujo de Caja":"Cash Flow Alert"}),jsxRuntime.jsx("p",{className:"text-sm text-amber-700 mt-1",children:u.idioma==="es"?"Se proyecta un balance bajo en los pr\xF3ximos d\xEDas. Considere acelerar cobros o postergar pagos no cr\xEDticos.":"A low balance is projected in the coming days. Consider accelerating collections or deferring non-critical payments."})]})]})})]})}),!v&&p&&M==="completo"&&jsxRuntime.jsxs("div",{className:"flex items-center justify-end space-x-2 pt-4 border-t border-gray-200",children:[jsxRuntime.jsxs("button",{onClick:()=>p("json"),className:"px-3 py-2 text-sm font-medium text-gray-700 bg-white border border-gray-300 rounded-lg hover:bg-gray-50 transition-colors",children:[jsxRuntime.jsx(lucideReact.Download,{className:"w-4 h-4 mr-2 inline"}),"JSON"]}),jsxRuntime.jsxs("button",{onClick:()=>p("csv"),className:"px-3 py-2 text-sm font-medium text-gray-700 bg-white border border-gray-300 rounded-lg hover:bg-gray-50 transition-colors",children:[jsxRuntime.jsx(lucideReact.Download,{className:"w-4 h-4 mr-2 inline"}),"CSV"]}),jsxRuntime.jsxs("button",{onClick:()=>p("pdf"),className:"px-3 py-2 text-sm font-medium text-gray-700 bg-white border border-gray-300 rounded-lg hover:bg-gray-50 transition-colors",children:[jsxRuntime.jsx(lucideReact.Download,{className:"w-4 h-4 mr-2 inline"}),"PDF"]})]})]})}function ut({glassVariant:e="medium",floatingCards:a=true,magneticInteractions:r=true,enableGlass:s=true,reducedMotion:d=false,themeName:l="financial",glowAlerts:n=true,className:v,configuracion:i={idioma:"es",moneda:"USD",formatoNumero:"es-PY",mostrarGraficos:true,mostrarObjetivos:true,mostrarProyecciones:true,diasProyeccion:30,actualizacionAutomatica:true,intervaloActualizacion:5},...h}){themes.useBirhausThemeV3(l);let p={...i},y=["birhaus-financial-dashboard-v3","transition-all duration-500 ease-smooth",s?"backdrop-blur-lg bg-white/70 border-white/30":"",a?"p-8 space-y-8":"p-6 space-y-6",v||""].filter(Boolean).join(" ");return jsxRuntime.jsxs("div",{className:y,"data-birhaus-component":"financial-dashboard-v3","data-birhaus-version":"3.0","data-birhaus-theme":l,children:[jsxRuntime.jsx(ra,{...h,configuracion:p,className:"space-y-6"}),s&&jsxRuntime.jsx("div",{className:"absolute inset-0 pointer-events-none rounded-3xl",style:{background:`linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.05) 100%)`,backdropFilter:"blur(16px) saturate(180%)",border:"1px solid rgba(255, 255, 255, 0.2)",zIndex:-1}})]})}function gt({glass:e=true,generousSpacing:a=true,radicalBorderRadius:r=true,magnetic:s=true,glow:d=false,estado:l,...n}){return jsxRuntime.jsxs("div",{className:(()=>{let i=["transition-all duration-300 ease-smooth","border hover:shadow-xl"];return e?i.push("backdrop-blur-md bg-white/80 border-white/30"):i.push("bg-white border-gray-200"),a?i.push("p-8"):i.push("p-6"),r?i.push("rounded-3xl"):i.push("rounded-lg"),s&&i.push("hover:scale-105 hover:-translate-y-1 cursor-pointer"),d&&l==="critico"&&i.push("shadow-2xl shadow-red-500/20 animate-pulse"),i.join(" ")})(),children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-4",children:[jsxRuntime.jsx("h3",{className:"text-lg font-semibold text-gray-900",children:n.nombreEs}),jsxRuntime.jsx("div",{className:`px-3 py-1 rounded-full text-xs font-medium ${l==="saludable"?"bg-green-100 text-green-800":l==="precaucion"?"bg-yellow-100 text-yellow-800":"bg-red-100 text-red-800"}`,children:l==="saludable"?"Saludable":l==="precaucion"?"Precauci\xF3n":"Cr\xEDtico"})]}),jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsx("div",{className:"text-3xl font-bold text-gray-900",children:n.unidad==="moneda"?`$${n.valor.toLocaleString()}`:n.unidad==="porcentaje"?`${n.valor}%`:n.valor.toLocaleString()}),jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx("div",{className:`flex items-center text-sm ${n.tendencia.direccion==="subida"?"text-green-600":n.tendencia.direccion==="bajada"?"text-red-600":"text-gray-600"}`,children:jsxRuntime.jsxs("span",{children:[n.tendencia.porcentaje>0?"+":"",n.tendencia.porcentaje,"%"]})}),jsxRuntime.jsxs("span",{className:"text-sm text-gray-500",children:["vs ",n.tendencia.periodo]})]}),jsxRuntime.jsx("p",{className:"text-sm text-gray-600",children:n.descripcionEs})]})]})}function pt(e){let[a,r]=ha__default.default.useState(e||{}),s=ha__default.default.useCallback(d=>{r(l=>({...l,...d}));},[]);return {configuration:a,updateConfiguration:s,enableGlassMorphism:()=>s({enableGlass:true,glassVariant:"medium"}),enableFloatingCards:()=>s({floatingCards:true}),enableMagneticInteractions:()=>s({magneticInteractions:true}),setTheme:d=>s({themeName:d}),enablePerformanceMode:()=>s({reducedMotion:true,enableGlass:false,magneticInteractions:false}),isV3Enabled:true}}function ye(...e){return e.flat().filter(Boolean).join(" ")}var Ca=ha.forwardRef(({item:e,renderItem:a,actions:r=[],onAction:s,onCancel:d,titleEs:l="Revisar Elemento",titleEn:n="Review Item",reasonLabelEs:v="Comentarios",reasonLabelEn:i="Comments",reasonPlaceholderEs:h="Agregar comentarios...",reasonPlaceholderEn:f="Add comments...",cancelButtonEs:p="Cancelar",cancelButtonEn:y="Cancel",confirmButtonEs:N="Confirmar",confirmButtonEn:k="Confirm",loading:M=false,error:u,locale:T="es",className:C,itemClassName:S,actionsClassName:I,...pe},c)=>{let[R,L]=ha.useState(null),[O,_]=ha.useState(""),[le,de]=ha.useState(false),g=ha.useCallback((B,me)=>T==="es"?B:me||B,[T]);r.length>4&&console.warn(`BIRHAUS ApprovalWorkflow: ${r.length} actions exceed 4-3-1 cognitive rule recommendation of 4. Consider consolidating actions or using progressive disclosure.`);let A=R?r.find(B=>B.key===R):null,we=ha.useCallback(B=>{L(B),_("");},[]),ce=ha.useCallback(async()=>{if(!(!R||!A)&&!(A.requiresReason&&!O.trim()))try{de(!0),await s(R,e,O.trim()||void 0);}catch(B){console.error("Approval action failed:",B);}finally{de(false);}},[R,A,O,s,e]),be=ha.useCallback(()=>{L(null),_(""),d?.();},[d]),fe=ha.useCallback(()=>{L(null),_("");},[]),G=g(l,n);return jsxRuntime.jsxs("div",{ref:c,className:ye("birhaus-approval-workflow space-y-6",C),...pe,children:[jsxRuntime.jsx("div",{className:"flex items-center justify-between",children:jsxRuntime.jsx("h2",{className:"text-xl font-semibold text-gray-900",children:G})}),u&&jsxRuntime.jsx("div",{className:"p-4 bg-red-50 border border-red-200 rounded-lg",children:jsxRuntime.jsxs("div",{className:"flex items-start gap-3",children:[jsxRuntime.jsx(lucideReact.AlertTriangle,{className:"w-5 h-5 text-red-600 mt-0.5 flex-shrink-0"}),jsxRuntime.jsx("p",{className:"text-sm text-red-800",children:u})]})}),jsxRuntime.jsx("div",{className:ye("bg-gray-50 border border-gray-200 rounded-lg p-6",S),children:a(e)}),R?jsxRuntime.jsxs("div",{className:"space-y-4",children:[A&&jsxRuntime.jsx("div",{className:"p-4 bg-amber-50 border border-amber-200 rounded-lg",children:jsxRuntime.jsxs("div",{className:"flex items-start gap-3",children:[jsxRuntime.jsx(lucideReact.AlertTriangle,{className:"w-5 h-5 text-amber-600 mt-0.5 flex-shrink-0"}),jsxRuntime.jsx("div",{className:"flex-1",children:jsxRuntime.jsx("p",{className:"text-sm font-medium text-amber-900",children:g(A.confirmationMessageEs||`Confirmar: ${A.labelEs}`,A.confirmationMessageEn||`Confirm: ${A.labelEn||A.labelEs}`)})})]})}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:[g(v,i),A?.requiresReason&&jsxRuntime.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),jsxRuntime.jsx("textarea",{value:O,onChange:B=>_(B.target.value),placeholder:g(h,f),rows:3,className:ye("w-full px-3 py-2 border border-gray-300 rounded-lg","focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent","disabled:opacity-50 disabled:cursor-not-allowed","resize-none"),disabled:le}),A?.requiresReason&&!O.trim()&&jsxRuntime.jsx("p",{className:"text-xs text-red-600 mt-1",children:T==="es"?"Este campo es requerido":"This field is required"})]}),jsxRuntime.jsxs("div",{className:"flex gap-3",children:[jsxRuntime.jsxs("button",{type:"button",onClick:fe,disabled:le,className:ye("inline-flex items-center px-4 py-2 text-sm font-medium","text-gray-700 bg-white border border-gray-300 rounded-lg","hover:bg-gray-50 hover:border-gray-400","focus:outline-none focus:ring-2 focus:ring-gray-500 focus:ring-offset-1","disabled:opacity-50 disabled:cursor-not-allowed","transition-all duration-200"),children:[jsxRuntime.jsx(lucideReact.RotateCcw,{className:"w-4 h-4 mr-2"}),T==="es"?"Volver":"Back"]}),jsxRuntime.jsx("button",{type:"button",onClick:ce,disabled:le||A?.requiresReason&&!O.trim(),className:ye("inline-flex items-center px-4 py-2 text-sm font-medium rounded-lg","focus:outline-none focus:ring-2 focus:ring-offset-1","disabled:opacity-50 disabled:cursor-not-allowed","transition-all duration-200 flex-1 justify-center",A?.variant==="primary"&&["bg-blue-600 text-white","hover:bg-blue-700 focus:ring-blue-500"],A?.variant==="danger"&&["bg-red-600 text-white","hover:bg-red-700 focus:ring-red-500"],(!A?.variant||A?.variant==="secondary")&&["bg-gray-600 text-white","hover:bg-gray-700 focus:ring-gray-500"]),children:le?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"animate-spin w-4 h-4 border-2 border-current border-t-transparent rounded-full mr-2"}),T==="es"?"Procesando...":"Processing..."]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[A?.icon&&jsxRuntime.jsx(A.icon,{className:"w-4 h-4 mr-2"}),g(N,k)]})})]})]}):jsxRuntime.jsxs("div",{className:ye("space-y-4",I),children:[jsxRuntime.jsx("div",{className:"flex flex-wrap gap-3",children:r.map(B=>{let me=B.icon,q=g(B.labelEs,B.labelEn);return jsxRuntime.jsxs("button",{type:"button",onClick:()=>we(B.key),disabled:M,className:ye("inline-flex items-center px-4 py-2 text-sm font-medium rounded-lg","border transition-all duration-200 flex-1 md:flex-none","focus:outline-none focus:ring-2 focus:ring-offset-1","disabled:opacity-50 disabled:cursor-not-allowed",B.variant==="primary"&&["bg-blue-600 text-white border-blue-600","hover:bg-blue-700 hover:border-blue-700","focus:ring-blue-500"],B.variant==="secondary"&&["bg-white text-gray-700 border-gray-300","hover:bg-gray-50 hover:border-gray-400","focus:ring-gray-500"],B.variant==="danger"&&["bg-red-600 text-white border-red-600","hover:bg-red-700 hover:border-red-700","focus:ring-red-500"]),children:[me&&jsxRuntime.jsx(me,{className:"w-4 h-4 mr-2"}),q]},B.key)})}),d&&jsxRuntime.jsx("div",{className:"flex justify-end",children:jsxRuntime.jsx("button",{type:"button",onClick:be,disabled:M,className:ye("text-sm text-gray-500 hover:text-gray-700","disabled:opacity-50 disabled:cursor-not-allowed"),children:g(p,y)})})]})]})});Ca.displayName="BirhausApprovalWorkflow";function ht(){let[e,a]=ha.useState(null),[r,s]=ha.useState(false),[d,l]=ha.useState(null),n=ha.useCallback(h=>{a(h),l(null);},[]),v=ha.useCallback(()=>{a(null),l(null);},[]),i=ha.useCallback(async(h,f,p,y)=>{if(y)try{s(!0),l(null),await y(h,f,p),v();}catch(N){throw l(N instanceof Error?N.message:"An error occurred"),N}finally{s(false);}},[v]);return {item:e,loading:r,error:d,startApproval:n,clearApproval:v,handleAction:i,setError:l}}var vt={approveReject:[{key:"approve",labelEs:"Aprobar",labelEn:"Approve",variant:"primary",icon:lucideReact.CheckCircle,confirmationMessageEs:"Esta acci\xF3n aprobar\xE1 el elemento.",confirmationMessageEn:"This action will approve the item."},{key:"reject",labelEs:"Rechazar",labelEn:"Reject",variant:"danger",icon:lucideReact.XCircle,requiresReason:true,confirmationMessageEs:"Esta acci\xF3n rechazar\xE1 el elemento.",confirmationMessageEn:"This action will reject the item."}],financialApproval:[{key:"approve",labelEs:"Aprobar Transacci\xF3n",labelEn:"Approve Transaction",variant:"primary",icon:lucideReact.CheckCircle,confirmationMessageEs:"Esta acci\xF3n procesar\xE1 la transacci\xF3n y actualizar\xE1 los registros financieros.",confirmationMessageEn:"This action will process the transaction and update financial records."},{key:"reject",labelEs:"Rechazar Transacci\xF3n",labelEn:"Reject Transaction",variant:"danger",icon:lucideReact.XCircle,requiresReason:true,confirmationMessageEs:"Esta acci\xF3n cancelar\xE1 la transacci\xF3n y notificar\xE1 al solicitante.",confirmationMessageEn:"This action will cancel the transaction and notify the requester."}],documentApproval:[{key:"approve",labelEs:"Aprobar Documento",labelEn:"Approve Document",variant:"primary",icon:lucideReact.CheckCircle,confirmationMessageEs:"Esta acci\xF3n marcar\xE1 el documento como aprobado.",confirmationMessageEn:"This action will mark the document as approved."},{key:"request_changes",labelEs:"Solicitar Cambios",labelEn:"Request Changes",variant:"secondary",requiresReason:true,confirmationMessageEs:"Esta acci\xF3n solicitar\xE1 cambios en el documento.",confirmationMessageEn:"This action will request changes to the document."},{key:"reject",labelEs:"Rechazar Documento",labelEn:"Reject Document",variant:"danger",icon:lucideReact.XCircle,requiresReason:true,confirmationMessageEs:"Esta acci\xF3n rechazar\xE1 permanentemente el documento.",confirmationMessageEn:"This action will permanently reject the document."}]};function ae(...e){return e.flat().filter(Boolean).join(" ")}var Ba={general:lucideReact.Settings,academic:lucideReact.GraduationCap,financial:lucideReact.DollarSign,administrative:lucideReact.Building},Ta={general:"bg-purple-100 text-purple-700 border-purple-200",academic:"bg-blue-100 text-blue-700 border-blue-200",financial:"bg-green-100 text-green-700 border-green-200",administrative:"bg-amber-100 text-amber-700 border-amber-200"},Pa=ha.forwardRef(({user:e,availableRoles:a,onRoleChange:r,onClose:s,onSuccess:d,titleEs:l="Gesti\xF3n de Roles de Usuario",titleEn:n="User Role Management",primaryRoleLabelEs:v="Rol Principal",primaryRoleLabelEn:i="Primary Role",additionalRolesLabelEs:h="Roles Adicionales",additionalRolesLabelEn:f="Additional Roles",assignPrimaryRoleLabelEs:p="Asignar rol principal",assignPrimaryRoleLabelEn:y="Assign primary role",addAdditionalRoleLabelEs:N="Agregar rol adicional",addAdditionalRoleLabelEn:k="Add additional role",changeLabelEs:M="Cambiar",changeLabelEn:u="Change",removeLabelEs:T="Remover",removeLabelEn:C="Remove",showAdvancedLabelEs:S="Mostrar",showAdvancedLabelEn:I="Show",hideAdvancedLabelEs:pe="Ocultar",hideAdvancedLabelEn:c="Hide",cancelLabelEs:R="Cancelar",cancelLabelEn:L="Cancel",saveLabelEs:O="Guardar Cambios",saveLabelEn:_="Save Changes",warningTitleEs:le="Importante sobre los cambios de roles",warningTitleEn:de="Important about role changes",warningMessageEs:g="Los cambios en los roles afectar\xE1n inmediatamente los permisos del usuario. Se recomienda notificar al usuario sobre estos cambios.",warningMessageEn:A="Role changes will immediately affect user permissions. It is recommended to notify the user about these changes.",loading:we=false,error:ce=null,locale:be="es",showAdvancedByDefault:fe=false,maxAdditionalRoles:G=5,allowPrimaryRoleChange:B=true,allowMultipleRoles:me=true,renderUserInfo:q,renderRoleMetadata:he,getRoleIcon:Ie,getRoleColor:X,className:Pe,headerClassName:ze,contentClassName:Z,actionsClassName:Ee,...H},qe)=>{let[D,ue]=ha.useState(e.primaryRole||null),[z,je]=ha.useState(e.additionalRoles||[]),[re,_e]=ha.useState(fe),[Ue,ve]=ha.useState(false),[se,De]=ha.useState("primary"),[W,Oe]=ha.useState(false),[J,xe]=ha.useState([]),Y=ha.useCallback((b,ne)=>be==="es"?b:ne||b,[be]),ke=ha.useCallback(b=>Ie?.(b)||Ba[b]||lucideReact.Settings,[Ie]),Fe=ha.useCallback(b=>X?.(b)||Ta[b]||"bg-gray-100 text-gray-700 border-gray-200",[X]);ha.useEffect(()=>{z.length>G&&console.warn(`BIRHAUS RoleManager: ${z.length} additional roles exceed Miller's Law limit of ${G}. Consider reducing role count or implementing progressive disclosure.`);},[z.length,G]);let Je=ha.useCallback(()=>{let b=[];return B&&b.push(D?"change_primary":"assign_primary"),me&&z.length<G&&b.push("add_additional"),z.length>0&&b.push("manage_additional"),b},[B,me,D,z.length,G]),Ke=ha.useCallback(async b=>{let ne=D;ue(b);let Le={type:"primary_role_assigned",userId:e.id,roleId:b.id,role:b,oldValue:ne,newValue:b,timestamp:new Date().toISOString()};xe(Ce=>[...Ce,Le]),ve(false);},[D,e.id]),Qe=ha.useCallback(async b=>{if(z.some(Ce=>Ce.id===b.id)){ve(false);return}if(z.length>=G){console.warn(`BIRHAUS RoleManager: Cannot add more than ${G} additional roles (Miller's Law compliance)`),ve(false);return}let ne=[...z,b];je(ne);let Le={type:"additional_role_added",userId:e.id,roleId:b.id,role:b,newValue:b,timestamp:new Date().toISOString()};xe(Ce=>[...Ce,Le]),ve(false);},[z,G,e.id]),w=ha.useCallback(b=>{let ne=z.find($e=>$e.id===b);if(!ne)return;let Le=z.filter($e=>$e.id!==b);je(Le);let Ce={type:"additional_role_removed",userId:e.id,roleId:b,role:ne,oldValue:ne,timestamp:new Date().toISOString()};xe($e=>[...$e,Ce]);},[z,e.id]),P=ha.useCallback(async()=>{if(J.length===0){d?.();return}Oe(true);try{for(let b of J)await r(b);xe([]),d?.();}catch(b){console.error("Error processing role changes:",b);}finally{Oe(false);}},[J,r,d]),V=ha.us