import{r as d,j as e,a as f}from"./app-BwDemWQz.js";import{A as Ms,S as se,P as ae,o as R,a as te,b as re,c as le,W as ye,F as fe}from"./AppLayout-3zbhnyYw.js";import{u as je,D as be}from"./useBulkHandler-CbpUUtsW.js";import{B as Ne}from"./Button-B-KWyoQR.js";import{I as j}from"./Input-BJaxI6jp.js";import{L as o}from"./Label-1lm7x8-L.js";import{D as ve}from"./DeleteModal-DqFQpSwl.js";import{T as $s,a as Bs,b as ke,c as we}from"./Tabs-BWJM2jyE.js";import{S as I,a as M,b as $,c as B,d as _}from"./Select-CfDsuz_M.js";import{C as ie}from"./Checkbox-DUX0c0Hg.js";import"./Card-DJ3wHKN-.js";import{u as Ce}from"./useDeleteHandler-C9Bb7ZON.js";import{u as Se}from"./useToggleHandler-CyjBJk2W.js";import{u as Ls}from"./LanguageContext-zkEAKPTE.js";import{s as g}from"./index-CkDmAPFS.js";import{U as L}from"./users-g1HvrzO9.js";import{m as _e}from"./proxy-DQ767J20.js";import{c as ce}from"./createLucideIcon-BASx8f0E.js";import{S as ne}from"./square-pen-BMLwbTJW.js";import{E as De}from"./eye-C30qcgue.js";import{T as Ue}from"./trash-2-DJCIoKoz.js";import{L as Re}from"./lock-BkJ6aXiy.js";import{S as de}from"./shield-2tv7FdsG.js";import{K as Ts}from"./key-C-v0nTrj.js";import{G as Ae}from"./globe-C_ZhZ5i9.js";import{D as zs}from"./database-D44wTjxU.js";/* empty css            */import"./index-DxJALBsh.js";import"./zap-BsHQ4DWF.js";import"./rocket-Dt03WmgU.js";import"./Pagination-BlNwi_HH.js";import"./search-sQ0SJSXK.js";import"./funnel-BGG8ZS5h.js";import"./settings-2-LSCqa0oL.js";import"./index-B0gxmCHE.js";/**
 * @license lucide-react v0.539.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Hs=[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]],Vs=ce("layers",Hs);/**
 * @license lucide-react v0.539.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Ps=[["path",{d:"m10 17 5-5-5-5",key:"1bsop3"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4",key:"u53s6r"}]],qs=ce("log-in",Ps);/**
 * @license lucide-react v0.539.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Qs=[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]],Ee=ce("monitor",Qs),Oe=({label:v,value:k,onChange:u,accept:A="image/*",placeholder:c="No file chosen",helperText:t,showViewLink:D=!1,onViewClick:b,className:T=""})=>{const[z,w]=d.useState(!1),H=x=>{const i=x.target.files[0];u&&u(i)},U=x=>{x.preventDefault(),w(!0)},E=x=>{x.preventDefault(),w(!1)},V=x=>{x.preventDefault(),w(!1);const i=x.dataTransfer.files[0];i&&u&&u(i)};return e.jsxs("div",{className:T,children:[v&&e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-200 mb-2",children:v}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:"file",accept:A,onChange:H,className:"absolute inset-0 w-full h-full opacity-0 cursor-pointer z-10"}),e.jsxs("div",{className:`flex border rounded-md overflow-hidden transition-colors
                        ${z?"border-primary bg-primary/10 dark:bg-primary/20":"border-gray-200 bg-gray-50 dark:border-gray-700 dark:bg-gray-800"}`,onDragOver:U,onDragLeave:E,onDrop:V,children:[e.jsx("div",{className:"bg-gray-200 dark:bg-gray-700 px-3 py-2 text-sm text-gray-600 dark:text-gray-300 border-r border-gray-300 dark:border-gray-600",children:"Choose file"}),e.jsx("div",{className:"flex-1 px-3 py-2 text-sm text-gray-500 dark:text-gray-400",children:k?k.name:c})]})]}),t&&e.jsxs("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:[t,D&&b&&e.jsxs(e.Fragment,{children:[" ",e.jsx("span",{className:"text-primary cursor-pointer hover:text-primary-dark",onClick:b,children:"View image"})]})]})]})]})};function Aa({users:v,roles:k,allRoles:u,statusEnum:A,rolePermissions:c}){var ue;const t=Ls(),[D,b]=d.useState(v.data||[]),[T,z]=d.useState(""),[w,H]=d.useState("all"),[U,E]=d.useState(null),[V,x]=d.useState(!1),[i,Fe]=d.useState(null),[Ie,oe]=d.useState(!1),[O,P]=d.useState(k.data||[]),[Me,$e]=d.useState(""),[me,Be]=d.useState("all"),[q,xe]=d.useState(null),[Le,Q]=d.useState(!1),[Te,G]=d.useState(!1),[ze,K]=d.useState(!1),[He,W]=d.useState(!1),[Ve,J]=d.useState(!1),[Gs,pe]=d.useState(null),[Ks,he]=d.useState(null),[Ws,Pe]=d.useState("users"),[m,N]=d.useState({name:"",email:"",status:"",role_id:"0",profile_image:null,password:"",password_confirmation:""}),[p,C]=d.useState({id:"",name:"",email:"",status:"",role_id:"0",profile_image:null}),[X,Y]=d.useState({name:"",description:""}),[y,S]=d.useState({id:"",name:"",permissions:{}}),qe=[{label:t("Home"),href:g("user.home")},{label:t("Access Control")}],Qe=[{key:"id",label:"No",className:"w-16",cellClassName:"font-medium",render:(s,a)=>a+1},{key:"name",label:"Name",render:s=>{var a;return e.jsxs("div",{className:"flex items-center space-x-3",children:[e.jsxs(te,{className:"h-8 w-8 bg-gradient-to-br from-primary/20 to-secondary/20 border border-gray-200 dark:border-gray-600",children:[e.jsx(re,{src:s.avatar_url,alt:s.name}),e.jsx(le,{className:"bg-gradient-to-br from-primary to-secondary text-white font-semibold text-sm",children:((a=s.name)==null?void 0:a.split(" ").map(r=>r[0]).join("").toUpperCase().slice(0,2))||"U"})]}),e.jsx("span",{className:"font-medium",children:s.name})]})}},{key:"status",label:"Status",render:s=>e.jsxs("div",{className:"flex w-full items-center gap-3",children:[e.jsxs("span",{className:`inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-medium ${s.status==="1"?"bg-green-50 text-green-700 border border-green-200 dark:bg-green-900/20 dark:text-green-400 dark:border-green-800":"bg-red-50 text-red-700 border border-red-200 dark:bg-red-900/20 dark:text-red-400 dark:border-red-800"}`,children:[e.jsx("div",{className:`w-2 h-2 rounded-full ${s.status==="1"?"bg-green-500":"bg-red-500"}`}),s.status==="1"?"Active":"Inactive"]}),e.jsx("button",{className:`relative inline-flex h-5 w-9 items-center rounded-full transition-colors ${s.status==="1"?"bg-gradient-to-r from-green-500 to-green-600":"bg-gray-300 dark:bg-gray-600"}`,onClick:()=>ss(s.id),children:e.jsx("span",{className:`inline-block h-3 w-3 transform rounded-full bg-white transition-transform shadow-sm ${s.status==="1"?"translate-x-5":"translate-x-1"}`})})]})},{key:"email",label:"Email",render:s=>e.jsxs("div",{className:"space-y-1",children:[e.jsx("span",{className:"text-gray-900 dark:text-gray-200 text-sm font-medium",children:s.email}),e.jsxs("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:["Member since ",new Date(s.created_at).toLocaleDateString()]})]})},{key:"role",label:"Role & Permissions",render:s=>e.jsxs("div",{className:"space-y-1",children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2 py-1 rounded-md text-xs font-medium bg-blue-50 text-blue-700 border border-blue-200 dark:bg-blue-900/20 dark:text-blue-400 dark:border-blue-800",children:[e.jsx("svg",{className:"w-3 h-3",fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{fillRule:"evenodd",d:"M10 9a3 3 0 100-6 3 3 0 000 6zm-7 9a7 7 0 1114 0H3z",clipRule:"evenodd"})}),s.role?s.role.name:"supperadmin"]}),e.jsxs("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:[s.role?s.role.permissions_count||Object.keys(s.role.permissions||{}).reduce((a,r)=>{var l;return a+(((l=s.role.permissions[r])==null?void 0:l.length)||0)},0)||0:"All"," permissions"]})]})}],Ge=[{key:"id",label:"No",className:"w-16",cellClassName:"font-medium",render:(s,a)=>a+1},{key:"name",label:"Role Name",render:s=>e.jsx("span",{className:"font-medium",children:s.name})},{key:"status",label:"Status",render:s=>e.jsxs("div",{className:"flex w-full items-center gap-3",children:[e.jsxs("span",{className:`inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-medium ${s.status==="1"?"bg-green-50 text-green-700 border border-green-200 dark:bg-green-900/20 dark:text-green-400 dark:border-green-800":"bg-red-50 text-red-700 border border-red-200 dark:bg-red-900/20 dark:text-red-400 dark:border-red-800"}`,children:[e.jsx("div",{className:`w-2 h-2 rounded-full ${s.status==="1"?"bg-green-500":"bg-red-500"}`}),s.status==="1"?"Active":"Inactive"]}),e.jsx("button",{className:`relative inline-flex h-5 w-9 items-center rounded-full transition-colors ${s.status==="1"?"bg-gradient-to-r from-green-500 to-green-600":"bg-gray-300 dark:bg-gray-600"}`,onClick:()=>hs(s.id),children:e.jsx("span",{className:`inline-block h-3 w-3 transform rounded-full bg-white transition-transform shadow-sm ${s.status==="1"?"translate-x-5":"translate-x-1"}`})})]})},{key:"created_by",label:"Created By & Date",render:s=>{var a,r,l,n,h;return e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(te,{className:"h-6 w-6 bg-gradient-to-br from-primary/20 to-secondary/20",children:[e.jsx(re,{src:(a=s.created_by)==null?void 0:a.avatar_url,alt:(r=s.created_by)==null?void 0:r.name}),e.jsx(le,{className:"bg-gradient-to-br from-primary to-secondary text-white font-semibold text-xs",children:((n=(l=s.created_by)==null?void 0:l.name)==null?void 0:n.split(" ").map(F=>F[0]).join("").toUpperCase().slice(0,2))||"S"})]}),e.jsx("span",{className:"text-gray-900 dark:text-gray-200 text-sm font-medium",children:((h=s.created_by)==null?void 0:h.name)||"System"})]}),e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:new Date(s.created_at).toLocaleDateString()})]})}},{key:"permissions",label:"Permissions",render:s=>e.jsxs("div",{className:"space-y-1",children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2 py-1 rounded-md text-xs font-medium bg-purple-50 text-purple-700 border border-purple-200 dark:bg-purple-900/20 dark:text-purple-400 dark:border-purple-800",children:[e.jsx("svg",{className:"w-3 h-3",fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{fillRule:"evenodd",d:"M5 9V7a5 5 0 0110 0v2a2 2 0 012 2v5a2 2 0 01-2 2H5a2 2 0 01-2-2v-5a2 2 0 012-2zm8-2v2H7V7a3 3 0 016 0z",clipRule:"evenodd"})}),s.permissions_count||Object.keys(s.permissions||{}).reduce((a,r)=>{var l;return a+(((l=s.permissions[r])==null?void 0:l.length)||0)},0)||0," permissions"]}),e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:s.description||"No description"})]})}],Ke=[{key:"login",label:"Login",icon:qs},{key:"edit",label:"Edit",icon:ne},{key:"show",label:"Show",icon:De},{key:"delete",label:"Delete",icon:Ue,className:"text-red-600 hover:text-red-700"}],We=[{key:"edit",label:"Edit",icon:De},{key:"delete",label:"Delete",icon:Ue,className:"text-red-600 hover:text-red-700"}],Je=[{label:"Active",value:"1"},{label:"Inactive",value:"0"}],Xe=[{label:"Active",value:"1"},{label:"Inactive",value:"0"}],Ye=s=>{z(s),f.get(g("user.access-control.index"),{key:"user-search",search:s,status:w!=="all"?w:void 0,page:1},{preserveState:!0,replace:!0})},Ze=s=>{H(s),f.get(g("user.access-control.index"),{key:"user-search",search:T,status:s!=="all"?s:void 0,page:1},{preserveState:!0,replace:!0})},{handleToggle:es}=Se("user.access-control.status.update",(s,a)=>{b(r=>r.map(l=>l.id===s?{...l,status:a}:l))}),ss=s=>{const a=D.find(r=>r.id===s);a&&es(s,String(a.status))},{handleDelete:as,isDeleting:ts}=Ce("user.access-control.delete",s=>{b(a=>a.filter(r=>r.id!==s)),x(!1),E(null)}),{handleBulkAction:Z}=je("user.access-control.bulk",(s,a,r)=>{b(l=>{switch(s){case"active":return l.map(n=>a.includes(n.id)?{...n,status:r.Active}:n);case"inactive":return l.map(n=>a.includes(n.id)?{...n,status:r.Inactive}:n);case"delete":return l.filter(n=>!a.includes(n.id));default:return l}})}),rs=(s,a)=>{switch(s){case"login":ls(a.id);break;case"edit":ns(a);break;case"show":is(a);break;case"delete":ds(a);break}},ls=s=>{f.post(g("user.access-control.login"),{id:s})},is=s=>{Fe(s),oe(!0)},ns=s=>{pe(s),C({id:s.id,name:s.name,email:s.email,status:s.status,role_id:s.role&&s.role.id?s.role.id.toString():"0",profile_image:null}),W(!0)},ds=s=>{E(s),x(!0)},cs=()=>{const s=new FormData;s.append("name",m.name),s.append("email",m.email),s.append("status",m.status),s.append("role_id",m.role_id),s.append("password",m.password),s.append("password_confirmation",m.password_confirmation),m.profile_image&&s.append("profile_image",m.profile_image),f.post(g("user.access-control.store"),s,{onSuccess:()=>{G(!1),N({name:"",email:"",status:"",role_id:"0",profile_image:null,password:"",password_confirmation:""})}})},os=()=>{const s=new FormData;s.append("id",p.id),s.append("name",p.name),s.append("email",p.email),s.append("status",p.status),s.append("role_id",p.role_id),p.profile_image&&s.append("profile_image",p.profile_image),f.post(g("user.access-control.update"),s,{onSuccess:()=>{W(!1),C({id:"",name:"",email:"",status:"",role_id:"0",profile_image:null}),pe(null)}})},ge=s=>{const{name:a,value:r}=s.target;C(l=>({...l,[a]:r}))},ms=s=>{$e(s),f.get(g("user.access-control.index"),{key:"role-search",search:s,status:me!=="all"?me:void 0,page:1},{preserveState:!0,replace:!0})},xs=s=>{Be(s),f.get(g("user.access-control.index"),{key:"role-search",search:Me,status:s!=="all"?s:void 0,page:1},{preserveState:!0,replace:!0})},{handleToggle:ps}=Se("user.role.status.update",(s,a)=>{P(r=>r.map(l=>l.id===s?{...l,status:a}:l))}),hs=s=>{const a=O.find(r=>r.id===s);a&&ps(s,String(a.status))},{handleDelete:gs,isDeleting:us}=Ce("user.role.delete",s=>{P(a=>a.filter(r=>r.id!==s)),Q(!1),xe(null)}),{handleBulkAction:ee}=je("user.role.bulk",(s,a,r)=>{b(l=>{switch(s){case"active":return l.map(n=>a.includes(n.id)?{...n,status:r.Active}:n);case"inactive":return l.map(n=>a.includes(n.id)?{...n,status:r.Inactive}:n);case"delete":return l.filter(n=>!a.includes(n.id));default:return l}})}),ys=(s,a)=>{switch(s){case"edit":js(a.id);break;case"delete":bs(a);break}},fs=s=>{if(!s||!Array.isArray(s))return{};const a={};return c&&Object.keys(c).forEach(r=>{a[r]=[]}),s.forEach(r=>{c&&Object.entries(c).forEach(([l,n])=>{n.includes(r)&&a[l].push(r)})}),a},js=s=>{const a=O.find(r=>r.id===s);a&&(he(a),S({id:a.id,name:a.name,permissions:fs(a.permissions)}),J(!0))},bs=s=>{xe(s),Q(!0)},Ns=()=>{f.post(g("user.role.store"),X,{onSuccess:()=>{K(!1),Y({name:"",description:""})}})},vs=s=>{const a=[];return Object.values(s).forEach(r=>{Array.isArray(r)&&a.push(...r)}),a},ks=()=>{const s={...y,permissions:vs(y.permissions)};f.post(g("user.role.update"),s,{onSuccess:()=>{J(!1),S({id:"",name:"",permissions:{}}),he(null)}})},ws=(s,a,r)=>{S(l=>({...l,permissions:{...l.permissions,[s]:r?[...l.permissions[s]||[],a]:(l.permissions[s]||[]).filter(n=>n!==a)}}))},Cs=(s,a)=>{!c||!c[s]||S(r=>({...r,permissions:{...r.permissions,[s]:a?c[s]:[]}}))},Ss=(s,a)=>(y.permissions[s]||[]).includes(a),_s=s=>{if(!c||!c[s])return!1;const a=c[s]||[],r=y.permissions[s]||[];return a.length>0&&a.length===r.length},Ds=s=>{if(!c||!c[s])return!1;const a=c[s]||[],r=y.permissions[s]||[];return r.length>0&&r.length<a.length},Us=()=>c?Object.entries(c).every(([s,a])=>{const r=y.permissions[s]||[];return a.length>0&&r.length===a.length}):!1,Rs=()=>{if(!c)return!1;let s=!1,a=!1;return Object.entries(c).forEach(([r,l])=>{const n=y.permissions[r]||[];n.length>0&&(s=!0),n.length<l.length&&(a=!0)}),s&&a},As=s=>{if(!c)return;const a={};Object.entries(c).forEach(([r,l])=>{a[r]=s?[...l]:[]}),S(r=>({...r,permissions:a}))},Es=s=>s.split("_").map(a=>a.charAt(0).toUpperCase()+a.slice(1)).join(" "),Os=s=>s.split("_").map(a=>a.charAt(0).toUpperCase()+a.slice(1)).join(" "),Fs=s=>({language:Ae,staff:L,social_account:Vs,social_post:fe,user:L,role:de,category:zs,ai_template:Ee,content:fe,security_settings:Re,platform:Ae,gateway:Ts,notification_template:ye,notification:ye,settings:se,dashboard:Ee})[s]||de;return d.useEffect(()=>{b(v.data||[])},[v]),d.useEffect(()=>{P(k.data||[])},[k]),e.jsx(Ms,{breadcrumbs:qe,children:e.jsxs("div",{className:"flex-1 p-6 overflow-auto bg-gray-50 dark:bg-black",children:[e.jsxs("div",{className:"mb-6",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("div",{children:e.jsx(L,{className:"h-6 w-6 text-primary"})}),e.jsx("h1",{className:"text-xl sm:text-2xl dark:text-gray-200 font-bold",children:t("Access Control")})]}),e.jsx("p",{className:"text-gray-500 dark:text-gray-200",children:t("Manage users, roles, and permissions across your organization")})]}),e.jsxs($s,{defaultValue:"users",onValueChange:Pe,className:"space-y-6",children:[e.jsx("div",{className:"flex justify-between items-center mb-6",children:e.jsx("div",{className:"flex gap-1",children:e.jsxs(Bs,{className:"inline-flex bg-white dark:bg-zinc-900 rounded-lg p-1 shadow-sm gap-1",children:[e.jsxs(ke,{value:"users",className:"data-[state=active]:bg-gradient-to-r data-[state=active]:from-primary data-[state=active]:to-secondary data-[state=active]:text-white data-[state=active]:shadow-sm rounded-md px-4 py-2 text-sm font-medium transition-colors flex items-center gap-2",children:[e.jsx(L,{className:"w-4 h-4"}),"Users",e.jsx("span",{className:"bg-white/20 text-current text-xs px-2 py-0.5 rounded-full",children:D.length})]}),e.jsxs(ke,{value:"roles",className:"data-[state=active]:bg-gradient-to-r data-[state=active]:from-primary data-[state=active]:to-secondary data-[state=active]:text-white data-[state=active]:shadow-sm rounded-md px-4 py-2 text-sm font-medium transition-colors flex items-center gap-2",children:[e.jsx(se,{className:"w-4 h-4"}),"Roles",e.jsx("span",{className:"bg-white/20 text-current text-xs px-2 py-0.5 rounded-full",children:O.length})]})]})})}),e.jsx(_e.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.6,delay:.2},children:e.jsx(we,{value:"users",children:e.jsx(be,{data:D,propName:"users",paginationData:v,columns:Qe,searchFields:["name","email"],searchPlaceholder:t("Search by name or email"),filterOptions:Je,actionMenuItems:Ke,onSearch:Ye,onFilterChange:Ze,onBulkActive:s=>Z("active",s),onBulkInactive:s=>Z("inactive",s),onBulkDelete:s=>Z("delete",s),onRowAction:rs,actionButton:e.jsxs(Ne,{onClick:()=>G(!0),className:"bg-gradient-to-r from-primary to-secondary text-white hover:from-secondary hover:to-primary shadow-md hover:shadow-lg transition-all duration-200",size:"sm",children:[e.jsx(ae,{className:"h-4 w-4 mr-2"}),t("Add User")]})})})}),e.jsx(_e.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.6,delay:.2},children:e.jsx(we,{value:"roles",children:e.jsx(be,{data:O,propName:"roles",paginationData:k,columns:Ge,searchFields:["name","description"],searchPlaceholder:t("Search by name"),filterOptions:Xe,actionMenuItems:We,onSearch:ms,onFilterChange:xs,onBulkActive:s=>ee("active",s),onBulkInactive:s=>ee("inactive",s),onBulkDelete:s=>ee("delete",s),onRowAction:ys,actionButton:e.jsxs(Ne,{onClick:()=>K(!0),className:"bg-gradient-to-r from-primary to-secondary text-white hover:from-secondary hover:to-primary shadow-md hover:shadow-lg transition-all duration-200",size:"sm",children:[e.jsx(ae,{className:"h-4 w-4 mr-2"}),t("Create Role")]})})})})]}),e.jsxs(R,{isOpen:Te,onClose:()=>G(!1),title:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 bg-gradient-to-r from-primary to-secondary rounded-lg flex items-center justify-center",children:e.jsx(ae,{className:"w-4 h-4 text-white"})}),e.jsx("div",{children:e.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100",children:t("Add User")})})]}),onSubmit:cs,submitText:t("Add User"),children:[e.jsx("div",{className:"space-y-4",children:e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 text-start",children:t("Create a new user account with appropriate permissions")})}),e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{className:"grid lg:grid-cols-2 grid-cols-1 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"name",className:"dark:text-neutral-200",children:t("Name")}),e.jsx(j,{id:"name",placeholder:t("Enter name"),value:m.name,onChange:s=>N(a=>({...a,name:s.target.value}))}),e.jsxs("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:[t("Enter the full name of the user"),"."]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"email",className:"dark:text-neutral-200",children:t("Email")}),e.jsx(j,{id:"email",type:"email",placeholder:t("Enter email"),value:m.email,onChange:s=>N(a=>({...a,email:s.target.value}))}),e.jsxs("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:[t("Enter a valid email address"),"."]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"status",className:"dark:text-neutral-200",children:t("Status")}),e.jsxs(I,{value:m.status,onValueChange:s=>N(a=>({...a,status:s})),children:[e.jsx(M,{className:"w-full",children:e.jsx($,{placeholder:t("Status")})}),e.jsx(B,{children:Object.entries(A).map(([s,a])=>e.jsx(_,{value:a,children:s},a))})]}),e.jsxs("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:[t("Select the user's account status"),"."]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"role",className:"dark:text-neutral-200",children:t("Role")}),e.jsxs(I,{value:m.role_id,onValueChange:s=>N(a=>({...a,role_id:s})),children:[e.jsx(M,{className:"w-full",children:e.jsx($,{placeholder:t("Select Role")})}),e.jsxs(B,{children:[e.jsx(_,{value:"0",children:t("No Role Assigned")}),u&&u.map(s=>e.jsx(_,{value:s.id.toString(),children:s.name},s.id))]})]}),e.jsxs("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:[t("Assign a role to define user permissions"),"."]})]}),e.jsx("div",{className:"col-span-full",children:e.jsx(Oe,{label:t("Profile Image"),value:m.profile_image,onChange:s=>N(a=>({...a,profile_image:s})),accept:"image/*",helperText:t("Upload a profile picture (optional)")})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"password",className:"dark:text-neutral-200",children:t("Password")}),e.jsx(j,{id:"password",type:"password",placeholder:t("Enter password"),value:m.password,onChange:s=>N(a=>({...a,password:s.target.value}))}),e.jsxs("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:[t("Enter a secure password for the user"),"."]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"password_confirmation",className:"dark:text-neutral-200",children:t("Confirm Password")}),e.jsx(j,{id:"password_confirmation",type:"password",placeholder:t("Confirm password"),value:m.password_confirmation,onChange:s=>N(a=>({...a,password_confirmation:s.target.value}))}),e.jsxs("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:[t("Re-enter the password to confirm"),"."]})]})]})})]}),e.jsx(R,{isOpen:Ie,onClose:()=>oe(!1),title:"User Information",showSubmit:!1,children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs(te,{className:"h-12 w-12 bg-gradient-to-br from-primary/20 to-secondary/20 border border-gray-200 dark:border-gray-600",children:[e.jsx(re,{src:i==null?void 0:i.avatar_url,alt:i==null?void 0:i.name}),e.jsx(le,{className:"bg-gradient-to-br from-primary to-secondary text-white font-semibold text-lg",children:((ue=i==null?void 0:i.name)==null?void 0:ue.split(" ").map(s=>s[0]).join("").toUpperCase().slice(0,2))||"U"})]}),e.jsx("div",{children:e.jsx("h2",{className:"text-lg font-semibold dark:text-gray-200",children:i==null?void 0:i.name})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"Email"}),e.jsx("p",{className:"font-medium dark:text-gray-200",children:i==null?void 0:i.email})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"Phone"}),e.jsx("p",{className:"font-medium dark:text-gray-200",children:(i==null?void 0:i.phone)??"-"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"Joined"}),e.jsx("p",{className:"font-medium dark:text-gray-200",children:i==null?void 0:i.created_at})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"Status"}),e.jsx("span",{className:`px-2 py-1 text-xs rounded-full ${(i==null?void 0:i.status)==="1"?"bg-green-100 text-green-700 dark:bg-gray-400":"bg-red-100 text-red-700"}`,children:(i==null?void 0:i.status)==="1"?"Active":"Inactive"})]})]})]})}),e.jsxs(R,{isOpen:He,onClose:()=>W(!1),title:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 bg-gradient-to-r from-primary to-secondary rounded-lg flex items-center justify-center",children:e.jsx(ne,{className:"w-4 h-4 text-white"})}),e.jsx("div",{children:e.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100",children:t("Edit User")})})]}),onSubmit:os,submitText:t("Update User"),children:[e.jsx("div",{className:"space-y-4",children:e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 text-center",children:t("Update user information and permissions")})}),e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"edit_name",className:"dark:text-neutral-200",children:t("Name")}),e.jsx(j,{id:"edit_name",name:"name",placeholder:t("Enter name"),value:p.name,onChange:ge}),e.jsxs("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:[t("Enter the full name of the user"),"."]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"edit_email",className:"dark:text-neutral-200",children:t("Email")}),e.jsx(j,{id:"edit_email",name:"email",type:"email",placeholder:t("Enter email"),value:p.email,onChange:ge}),e.jsxs("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:[t("Enter a valid email address"),"."]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"edit_status",className:"dark:text-neutral-200",children:t("Status")}),e.jsxs(I,{value:p.status,onValueChange:s=>C(a=>({...a,status:s})),children:[e.jsx(M,{className:"w-full",children:e.jsx($,{placeholder:t("Status")})}),e.jsx(B,{children:Object.entries(A).map(([s,a])=>e.jsx(_,{value:a,children:s},a))})]}),e.jsxs("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:[t("Select the user's account status"),"."]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"edit_role",className:"dark:text-neutral-200",children:t("Role")}),e.jsxs(I,{value:p.role_id,onValueChange:s=>C(a=>({...a,role_id:s})),children:[e.jsx(M,{className:"w-full",children:e.jsx($,{placeholder:t("Select Role")})}),e.jsxs(B,{children:[e.jsx(_,{value:"0",children:t("No Role Assigned")}),u&&u.map(s=>e.jsx(_,{value:s.id.toString(),children:s.name},s.id))]})]}),e.jsxs("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:[t("Assign a role to define user permissions"),"."]})]}),e.jsx("div",{className:"col-span-2",children:e.jsx(Oe,{label:t("Profile Image"),value:p.profile_image,onChange:s=>C(a=>({...a,profile_image:s})),accept:"image/*",helperText:t("Upload a new profile picture (optional)")})})]})})]}),e.jsx(ve,{isOpen:V,onClose:()=>x(!1),title:"Delete this user?",description:"Are you really sure you want to delete this user?",onConfirm:()=>as(U==null?void 0:U.id),isDeleting:ts}),e.jsxs(R,{isOpen:ze,onClose:()=>K(!1),title:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 bg-gradient-to-r from-primary to-secondary rounded-lg flex items-center justify-center",children:e.jsx(se,{className:"w-4 h-4 text-white"})}),e.jsx("div",{children:e.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100",children:t("Create Role")})})]}),onSubmit:Ns,submitText:t("Create Role"),width:"w-[28rem]",buttonWidth:"w-full",children:[e.jsx("div",{className:"space-y-4",children:e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 text-center",children:t("Create a new role to organize user permissions and access levels")})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"roleName",className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:t("Role Name")}),e.jsx(j,{id:"roleName",placeholder:t("Enter role name"),value:X.name,onChange:s=>Y(a=>({...a,name:s.target.value})),className:"w-full"}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:t("Choose a descriptive name for this role")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(o,{htmlFor:"roleDescription",className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:[t("Description")," ",e.jsxs("span",{className:"text-gray-400",children:["(",t("Optional"),")"]})]}),e.jsx(j,{id:"roleDescription",placeholder:t("Brief description of this role"),value:X.description,onChange:s=>Y(a=>({...a,description:s.target.value})),className:"w-full"}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:t("Briefly describe what this role is for")})]})]})]}),e.jsx(R,{isOpen:Ve,onClose:()=>J(!1),title:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 bg-gradient-to-r from-primary to-secondary rounded-xl flex items-center justify-center shadow-lg",children:e.jsx(de,{className:"w-5 h-5 text-white"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-bold text-gray-900 dark:text-gray-100",children:t("Edit Role")}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-0.5",children:t("Configure role permissions and access levels")})]})]}),onSubmit:ks,submitText:t("Update Role"),width:"w-[72rem] max-w-xl",maxHeight:"max-h-[85vh]",children:e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-800/50 rounded-xl p-5",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("div",{className:"w-10 h-10 bg-primary/10 dark:bg-primary/20 rounded-lg flex items-center justify-center",children:e.jsx(ne,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx(o,{className:"text-base font-semibold dark:text-gray-200",children:t("Role Name")}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:t("Define the role identifier")})]})]}),e.jsxs("div",{className:"max-w-md",children:[e.jsx(j,{id:"editRoleName",placeholder:t("Enter role name"),value:y.name,onChange:s=>S(a=>({...a,name:s.target.value})),className:"bg-white dark:bg-gray-900 text-base"}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-2",children:t("Choose a descriptive name for this role that clearly identifies its purpose")})]})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-8 h-8 bg-primary/10 dark:bg-primary/20 rounded-lg flex items-center justify-center",children:e.jsx(Re,{className:"h-4 w-4 text-primary"})}),e.jsxs("div",{children:[e.jsx(o,{className:"text-base font-medium dark:text-gray-200",children:t("Permissions")}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:t("Select the modules and actions this role can access")})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(ie,{id:"all-permissions",checked:Us(),indeterminate:Rs(),onCheckedChange:As,className:"data-[state=checked]:bg-primary data-[state=checked]:border-primary"}),e.jsx(o,{htmlFor:"all-permissions",className:"text-sm font-medium cursor-pointer select-none dark:text-gray-200",children:t("All")})]})]}),e.jsx("div",{className:"space-y-3 max-h-[55vh] overflow-y-auto pr-2 custom-scrollbar",children:c&&Object.entries(c).map(([s,a])=>{const r=Fs(s),l=_s(s),n=Ds(s);return e.jsx("div",{className:"group",children:e.jsxs("div",{className:`border rounded-xl transition-all duration-200 ${l?"border-primary/30 bg-primary/5 dark:border-primary/40 dark:bg-primary/10":"border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800/50"}`,children:[e.jsx("div",{className:"px-5 py-4 border-b border-gray-100 dark:border-gray-700/50",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:`w-8 h-8 rounded-lg flex items-center justify-center transition-colors ${l?"bg-primary/20 dark:bg-primary/30":"bg-gray-100 dark:bg-gray-700/50"}`,children:e.jsx(r,{className:`h-4 w-4 ${l?"text-primary":"text-gray-500 dark:text-gray-400"}`})}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(ie,{id:`edit-category-${s}`,checked:l,indeterminate:n,onCheckedChange:h=>Cs(s,h),className:"data-[state=checked]:bg-primary data-[state=checked]:border-primary"}),e.jsx(o,{htmlFor:`edit-category-${s}`,className:"text-base font-medium dark:text-gray-200 cursor-pointer select-none",children:Os(s)})]})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs("span",{className:"text-xs px-2 py-1 rounded-full bg-gray-100 dark:bg-gray-700 text-gray-600 dark:text-gray-400",children:[(y.permissions[s]||[]).length,"/",a.length]})})]})}),e.jsx("div",{className:`px-5 py-4 ${l||n?"":"opacity-60"}`,children:e.jsx("div",{className:"grid grid-cols-3 gap-x-8 gap-y-2.5",children:a.map(h=>{const F=Ss(s,h);return e.jsxs("div",{className:"flex items-center gap-2 py-1",children:[e.jsx(ie,{id:`edit-${s}-${h}`,checked:F,onCheckedChange:Is=>ws(s,h,Is),className:"data-[state=checked]:bg-primary data-[state=checked]:border-primary"}),e.jsx(o,{htmlFor:`edit-${s}-${h}`,className:`text-xs cursor-pointer select-none ${F?"text-gray-700 dark:text-gray-200 font-medium":"text-gray-500 dark:text-gray-400"}`,children:Es(h)})]},h)})})})]})},s)})})]})]})}),e.jsx(ve,{isOpen:Le,onClose:()=>Q(!1),title:"Delete this role?",description:"Are you really sure you want to delete this role?",onConfirm:()=>gs(q==null?void 0:q.id),isDeleting:us})]})})}export{Aa as default};
