import{r as e}from"./rolldown-runtime-hePW80VL.js";import{o as t}from"./vendor-forms-yQg41KHz.js";import{l as n,t as r}from"./vendor-react-CAGJwf-T.js";import{t as i}from"./DataTable-BFSm8gty.js";import{t as a}from"./arrow-right-lxz0iUkq.js";import{t as o}from"./plus-oCcDgsDC.js";import{t as s}from"./shield-Ch0xbH9b.js";import{t as c}from"./users-CYR7ECMV.js";import{t as l}from"./format-BVO_kFTb.js";import{l as u}from"./usersRtkApi-CxqBEUpQ.js";import{D as d,S as f}from"./index-Z_bdWDpJ.js";import{r as p}from"./vendor-table-DrED5BwI.js";import{t as m}from"./PageHeader-UI75nV23.js";import{t as h}from"./Tooltip-Cdo7Ly5B.js";import{n as g,t as _}from"./Breadcrumb-BHdHGcrA.js";var v=e(t(),1),y=r(),b=p();function x(){let e=n(),[t,r]=(0,v.useState)(1),[p,x]=(0,v.useState)(20),[S,C]=(0,v.useState)(``),[w,T]=(0,v.useState)(!1),E=(0,v.useMemo)(()=>{let e={page:String(t),page_size:String(p)};return S&&(e.search=S),e},[t,p,S]),{data:D,isLoading:O,isFetching:k}=u(E),A=D?.results??[],j=D?.count??0,M=(0,v.useMemo)(()=>[b.accessor(`name`,{header:`Role`,cell:e=>(0,y.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,y.jsx)(`div`,{className:`w-9 h-9 rounded-lg bg-slate-100 dark:bg-slate-800 flex items-center justify-center flex-shrink-0`,children:(0,y.jsx)(s,{className:`w-4 h-4 text-[var(--color-text-muted)]`})}),(0,y.jsxs)(`div`,{className:`min-w-0`,children:[(0,y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,y.jsx)(`p`,{className:`text-[13px] font-medium text-[var(--color-text-primary)] truncate`,children:e.getValue()}),e.row.original.is_system&&(0,y.jsx)(f,{variant:`warning`,size:`sm`,children:`System`})]}),e.row.original.description&&(0,y.jsx)(`p`,{className:`text-[11px] text-[var(--color-text-muted)] truncate max-w-[300px] mt-px`,children:e.row.original.description})]})]})}),b.accessor(`user_count`,{header:`Users`,cell:e=>(0,y.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,y.jsx)(c,{className:`w-3.5 h-3.5 text-[var(--color-text-muted)]`}),(0,y.jsx)(`span`,{className:`text-[13px] text-[var(--color-text-secondary)] tabular-nums`,children:e.getValue()})]})}),b.accessor(`is_active`,{header:`Status`,cell:e=>(0,y.jsx)(f,{variant:e.getValue()?`success`:`error`,size:`sm`,dot:!0,children:e.getValue()?`Active`:`Inactive`})}),b.accessor(`created_at`,{header:`Created`,cell:e=>(0,y.jsx)(`span`,{className:`text-[12px] text-[var(--color-text-muted)] tabular-nums`,children:l(new Date(e.getValue()),`dd MMM yyyy`)})}),b.display({id:`actions`,header:``,cell:t=>(0,y.jsx)(h,{content:`Configure permissions`,children:(0,y.jsx)(`button`,{"aria-label":`Configure permissions`,onClick:()=>e(`/admin/users/roles/${t.row.original.id}`),className:`p-1.5 rounded-md text-[var(--color-text-muted)] hover:bg-slate-100 dark:hover:bg-slate-700 hover:text-[var(--color-primary)] transition-colors`,children:(0,y.jsx)(a,{className:`w-4 h-4`})})})})],[e]);return(0,y.jsxs)(`div`,{children:[(0,y.jsx)(_,{items:[{label:`User Management`,href:`/admin/users`},{label:`Roles & Permissions`}],className:`mb-4`}),(0,y.jsx)(m,{title:`Roles & Permissions`,description:`Define roles and configure what each role can access across the platform.`,actions:(0,y.jsxs)(d,{onClick:()=>T(!0),className:`gap-1.5`,children:[(0,y.jsx)(o,{className:`w-4 h-4`}),`Create Role`]})}),(0,y.jsx)(i,{columns:M,data:A,isLoading:O,isFetching:k,searchPlaceholder:`Search roles...`,totalItems:j,currentPage:t,pageSize:p,totalPages:Math.ceil(j/p),onPageChange:r,onPageSizeChange:e=>{x(e),r(1)},onSearch:e=>{C(e),r(1)},emptyTitle:`No roles defined`,emptyDescription:`Create roles to control what admin users can do.`,emptyActionLabel:`Create Role`,onEmptyAction:()=>T(!0)}),w&&(0,y.jsx)(g,{onClose:()=>T(!1),onSuccess:()=>{T(!1)}})]})}export{x as default};