import{c as N,h as D,r as h,j as e,e as v,u as w,a as b,L as k}from"./index-DiwDH9aE.js";import{u as C}from"./useAuth-DEWkUfUW.js";import{H as U,B as j,L as S}from"./log-out-C3ghZd_W.js";import{U as $}from"./users-BLfoITz0.js";import{C as P,G as g}from"./graduation-cap-B3zNhUOw.js";import{M as L}from"./map-pin-C8p0ntE-.js";import{S as _}from"./school-CCnutwvi.js";import{S as z}from"./settings-L85C4ab2.js";import{C as y}from"./Can-w-eLoK-Q.js";import{C as E}from"./chevron-down-4ep2ftiY.js";import{M as T}from"./menu-Da05vmTL.js";/**
 * @license lucide-react v0.544.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const I=[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"M9 9h.01",key:"1q5me6"}],["path",{d:"M15 15h.01",key:"lqbp3k"}]],R=N("badge-percent",I);/**
 * @license lucide-react v0.544.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const O=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]],F=N("globe",O),A=[{id:"dashboard",label:"Dashboard",icon:U,path:"/admin",exact:!0},{id:"users",label:"Usuarios",icon:$,path:"/admin/users",permission:"users.index"},{id:"cycles",label:"Ciclos",icon:P,path:"/admin/cycles",permission:"cycles.index"},{id:"ubigeo",label:"Ubigeo",icon:L,permissions:["countries.index","departments.index","provinces.index","districts.index"],any:!0,children:[{label:"Países",path:"/admin/countries",icon:F,permission:"countries.index"},{label:"Departamentos",path:"/admin/departments",icon:j,permission:"departments.index"},{label:"Provincias",path:"/admin/provinces",icon:j,permission:"provinces.index"},{label:"Distritos",path:"/admin/districts",icon:j,permission:"districts.index"}]},{id:"education",label:"Educación",icon:g,permissions:["careers.index","schools.index"],any:!0,children:[{label:"Carreras",path:"/admin/careers",icon:g,permission:"careers.index"},{label:"Colegios",path:"/admin/schools",icon:_,permission:"schools.index"}]},{id:"discounts",label:"Descuentos",icon:R,path:"/admin/discount-types",permission:"discount_types.index"},{id:"students",label:"Estudiantes",icon:g,path:"/admin/students",permission:"students.index"},{id:"config",label:"Configuración",icon:z,permissions:["permissions.index","roles.index"],any:!0,children:[{label:"Permisos",path:"/admin/permissions",permission:"permissions.index"},{label:"Roles",path:"/admin/roles",permission:"roles.index"}]}],B=()=>{const a=D(),[r,i]=h.useState({}),o=s=>s?s==="/admin"?a.pathname===s:a.pathname.startsWith(s):!1,l=s=>s?s.some(n=>o(n.path)):!1;return h.useEffect(()=>{const s={};A.forEach(n=>{n.children&&l(n.children)&&(s[n.id]=!0)}),i(n=>({...n,...s}))},[a.pathname]),{isActive:o,isDropdownActive:l,openDropdowns:r,toggleDropdown:s=>{i(n=>({...n,[s]:!n[s]}))}}},M=({photoUrl:a,name:r,size:i="w-10 h-10",textSize:o="text-sm"})=>{const l=r?.charAt(0).toUpperCase()||"U";return e.jsx("div",{className:`${i} rounded-full overflow-hidden ring-2 ring-[#ef7d00]/20 flex-shrink-0 bg-[#ef7d00]/10 flex items-center justify-center`,children:a?e.jsx("img",{src:a,alt:r||"Usuario",className:"w-full h-full object-cover",onError:d=>{d.target.style.display="none";const s=document.createElement("span");s.className=`text-[#ef7d00] font-semibold ${o}`,s.textContent=l,d.target.parentElement.appendChild(s)}}):e.jsx("span",{className:`text-[#ef7d00] font-semibold ${o}`,children:l})})},c={link:{base:"flex items-center gap-3 px-3 py-2.5 rounded-lg transition-all duration-200 font-medium text-sm",active:"bg-[#00306e] text-white shadow-sm",inactive:"text-gray-700 hover:bg-gray-100"},dropdown:{item:{base:"flex items-center gap-3 px-3 py-2 rounded-lg text-sm transition-all duration-200",active:"bg-[#00306e] text-white font-medium",inactive:"text-gray-600 hover:bg-gray-50 hover:text-gray-900"},border:{active:"border-[#00306e]",inactive:"border-gray-200"}}},G=({item:a,isActive:r,isDropdownActive:i,isOpen:o,onToggle:l,onNavigate:d})=>{const s=a.icon,n=t=>{const m={};return t.permission&&(m.permission=t.permission),t.permissions&&(m.permissions=t.permissions),t.any&&(m.any=t.any),m};return a.children?e.jsx(y,{...n(a),children:e.jsxs("div",{children:[e.jsxs("button",{onClick:l,className:`w-full ${c.link.base} justify-between ${i?c.link.active:c.link.inactive}`,children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(s,{className:"w-5 h-5"}),e.jsx("span",{children:a.label})]}),e.jsx(E,{className:`w-4 h-4 transition-transform duration-200 ${o?"rotate-180":""}`})]}),e.jsx("div",{className:`mt-1 ml-4 border-l-2 pl-3 space-y-1 overflow-hidden transition-all duration-200 ${i?c.dropdown.border.active:c.dropdown.border.inactive} ${o?"max-h-96 opacity-100":"max-h-0 opacity-0"}`,children:a.children.map((t,m)=>{const p=t.icon;return e.jsx(y,{...n(t),children:e.jsxs(v,{to:t.path,onClick:d,className:`${c.dropdown.item.base} ${r(t.path)?c.dropdown.item.active:c.dropdown.item.inactive}`,children:[p&&e.jsx(p,{className:"w-4 h-4"}),e.jsx("span",{children:t.label})]})},m)})})]})}):e.jsx(y,{...n(a),children:e.jsxs(v,{to:a.path,onClick:d,className:`${c.link.base} ${r(a.path)?c.link.active:c.link.inactive}`,children:[e.jsx(s,{className:"w-5 h-5"}),e.jsx("span",{children:a.label})]})})},q=({onNavigate:a})=>{const[r,i]=h.useState("Cerrando sesión..."),o=w(),l=b(x=>x.user),d=b(x=>x.getUserType()),{loading:s,logout:n}=C(),{isActive:t,isDropdownActive:m,openDropdowns:p,toggleDropdown:f}=B(),u=async()=>{await n(d),o("/")};return e.jsxs(e.Fragment,{children:[s&&e.jsx(k,{message:r,variant:"light",portal:!0}),e.jsxs("div",{className:"h-full flex flex-col bg-white",children:[e.jsx("div",{className:"p-4 border-b border-gray-200",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 bg-gradient-to-br from-[#00306e] to-[#00439e] rounded-lg flex items-center justify-center shadow-sm",children:e.jsx(g,{className:"w-6 h-6 text-white"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"font-semibold text-[#00306e] text-base",children:"CEPRE"}),e.jsx("p",{className:"text-xs text-gray-500",children:"UNAJMA"})]})]})}),e.jsx("div",{className:"p-4 border-b border-gray-200 bg-gray-50",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(M,{photoUrl:l?.photo_profile_url,name:l?.names}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm text-gray-900 truncate capitalize",children:l?.names||"Usuario"}),e.jsx("p",{className:"text-xs text-gray-500 truncate uppercase",children:d})]})]})}),e.jsx("nav",{className:"flex-1 overflow-y-auto p-3 space-y-1",children:A.map(x=>e.jsx(G,{item:x,isActive:t,isDropdownActive:x.children?m(x.children):!1,isOpen:p[x.id],onToggle:()=>f(x.id),onNavigate:a},x.id))}),e.jsx("div",{className:"p-3 border-t border-gray-200",children:e.jsxs("button",{onClick:u,className:"w-full flex items-center gap-3 px-3 py-2.5 rounded-lg text-red-600 hover:bg-red-50 transition-colors duration-200 font-medium text-sm",children:[e.jsx(S,{className:"w-5 h-5"}),e.jsx("span",{children:"Cerrar Sesión"})]})})]})]})},H=({onMenuClick:a})=>{const r=b(u=>u.user),i=b(u=>u.getUserType()),[o,l]=h.useState(!1),[d,s]=h.useState(!1),n=w(),{loading:t,message:m,logout:p}=C(),f=async()=>{await p(i),n("/")};return e.jsxs(e.Fragment,{children:[t&&e.jsx(k,{message:m,variant:"light",portal:!0}),e.jsxs("nav",{className:"h-18 px-4 lg:px-6 flex items-center justify-between bg-white",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("button",{onClick:a,className:"lg:hidden p-2 rounded-lg text-gray-600 hover:bg-gray-100 transition-colors duration-200","aria-label":"Abrir menú",children:e.jsx(T,{className:"w-6 h-6"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-lg font-semibold text-[#00306e]",children:"CEPRE"}),e.jsx("p",{className:"text-xs text-gray-500 hidden sm:block",children:"Sistema Integral del CEPRE"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-px h-6 bg-gray-300 mx-1"}),e.jsxs("div",{className:"relative",children:[e.jsxs("button",{onClick:()=>l(!o),className:"flex items-center gap-2 px-3 py-2 rounded-lg hover:bg-gray-100 transition-colors duration-200",children:[e.jsx(M,{photoUrl:r?.photo_profile_url,name:r?.names}),e.jsxs("div",{className:"hidden lg:block text-left",children:[e.jsx("p",{className:"text-sm font-medium text-gray-900 capitalize",children:r?.names||"Administrador"}),e.jsx("p",{className:"text-xs text-gray-500 uppercase",children:i||"Admin"})]}),e.jsx(E,{className:"w-4 h-4 text-gray-500"})]}),o&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>l(!1)}),e.jsxs("div",{className:"absolute right-0 top-12 w-56 bg-white rounded-xl shadow-lg border border-gray-200 z-20 overflow-hidden",children:[e.jsxs("div",{className:"px-4 py-3 border-b border-gray-200 bg-gray-50",children:[e.jsx("p",{className:"text-sm font-medium text-gray-900",children:r?.names||"Administrador"}),e.jsx("p",{className:"text-xs text-gray-500",children:r?.email||""})]}),e.jsx("div",{className:"border-t border-gray-200",children:e.jsxs("button",{onClick:f,className:"w-full flex items-center gap-3 px-4 py-2 text-sm text-red-600 hover:bg-red-50 transition-colors duration-200 cursor-pointer",children:[e.jsx(S,{className:"w-4 h-4"}),e.jsx("span",{children:"Cerrar Sesión"})]})})]})]})]})]})]})]})},re=({children:a})=>{const[r,i]=h.useState(!1),o=()=>{window.innerWidth<1024&&i(!1)};return e.jsxs("div",{className:"min-h-screen bg-gray-50 flex",children:[r&&e.jsx("div",{className:"fixed inset-0 bg-black/50 z-40 lg:hidden",onClick:()=>i(!1)}),e.jsx("aside",{className:`
          fixed lg:sticky top-0 left-0 h-screen z-50
          w-64 bg-white border-r border-gray-200
          transform transition-transform duration-300 ease-in-out
          ${r?"translate-x-0":"-translate-x-full lg:translate-x-0"}
        `,children:e.jsx(q,{onNavigate:o})}),e.jsxs("div",{className:"flex-1 flex flex-col min-h-screen",children:[e.jsx("header",{className:"sticky top-0 z-30 bg-white border-b border-gray-200 shadow-sm",children:e.jsx(H,{onMenuClick:()=>i(!r)})}),e.jsx("main",{className:"flex-1 p-4 lg:p-6 overflow-y-auto",children:a}),e.jsx("footer",{className:"bg-white border-t border-gray-200 py-4 px-6",children:e.jsxs("div",{className:"text-center text-sm text-gray-600",children:["© ",new Date().getFullYear()," CEPRE UNAJMA - Todos los derechos reservados"]})})]})]})};export{re as D};
