import{t as e}from"./axios-m7YkukvY.js";import{A as t,L as n,N as r,St as i,W as a,_ as o,c as s,d as c,et as l,h as u,l as d,m as f,s as p,u as m,xt as h}from"./runtime-core.esm-bundler-Babufkcf.js";import{o as g}from"./runtime-dom.esm-bundler-Ce9t-RuK.js";import{t as _}from"./QIcon-cTVL6ikA.js";import{G as v,K as y,L as b}from"./index-uCtpzrM3.js";import{t as x}from"./QChip-Bsee2q-S.js";import{t as S}from"./QTd-mJJNUD6x.js";import{t as C}from"./QPage-eKZDij2L.js";var w={class:`row my_radio_less q-pa-sm`},T={class:`col-12`},E={class:`col-12 q-mt-sm`},D={class:`row q-col-gutter-md`},O={class:`col-6 col-sm-4`},k={class:`col-6 col-sm-4`},A={class:`col-6 col-sm-4`},j={class:`col-12`},M={class:`row items-center no-wrap`},N={class:`column`},P=[`onClick`],F={key:0,class:`text-caption text-grey-6 role-fa`},I=y({__name:`RolesPage`,setup(y){let{proxy:I}=o(),L=v(),R=l([]),z=l(!1),B=l(``),V=l([]),H=l(0),U=p(()=>R.value.reduce((e,t)=>e+(t.users_count||0),0)),W=[{name:`created_at`,label:`#`,field:`id`,align:`left`},{name:`name`,label:`RoleName`,field:`name`,align:`left`,sortable:!0},{name:`modules_count`,label:`Modules`,field:`modules_count`,align:`center`,sortable:!0},{name:`permissions_count`,label:`Permissions`,field:`permissions_count`,align:`center`,sortable:!0},{name:`users_count`,label:`AssignedUsers`,field:`users_count`,align:`center`,sortable:!0},{name:`actions`,label:`Actions`,field:`actions`,align:`right`}],G=[`#175A8C`,`#0D9488`,`#7C3AED`,`#D97706`,`#DC2626`,`#0284C7`,`#B45309`,`#059669`];function K(e){let t=0;for(let n=0;n<(e||``).length;n++)t=t*31+e.charCodeAt(n)>>>0;return G[t%G.length]}async function q(){z.value=!0;try{let{data:t}=await e.get(`/roles`);R.value=t}finally{z.value=!1}try{let{data:t}=await e.get(`/permissions`);H.value=(t||[]).length}catch{}}function J(){L.push(`/roles/create`)}function Y(e){L.push(`/roles/edit/${e}`)}function X(e){I.$delete(`roles/${e}`,q)}return t(q),(e,t)=>{let o=n(`m-header`),l=n(`stat-card`),p=n(`action-bar`),v=n(`n-table`),y=n(`m-backgrounds`);return r(),d(C,null,{default:a(()=>[u(y,null,{default:a(()=>[s(`div`,w,[s(`div`,T,[u(o,{icon:`badge`,controlRoomButton:`false`,class:`q-mt-xs`},{default:a(()=>[f(i(e.$t(`Roles`)),1)]),_:1})]),s(`div`,E,[s(`div`,D,[s(`div`,O,[u(l,{dense:``,icon:`badge`,label:e.$t(`TotalRoles`),value:R.value.length,color:`#175A8C`,tint:`#E0EDF7`},null,8,[`label`,`value`])]),s(`div`,k,[u(l,{dense:``,icon:`verified_user`,label:e.$t(`AvailablePermissions`),value:H.value,color:`#0D9488`,tint:`#CCFBF1`},null,8,[`label`,`value`])]),s(`div`,A,[u(l,{dense:``,icon:`group`,label:e.$t(`AssignedUsers`),value:U.value,color:`#7C3AED`,tint:`#EDE9FE`},null,8,[`label`,`value`])])])]),u(p,{rows:R.value,columns:W,filename:`roles`,"create-perm":`role-create`,onAdd:J,"onUpdate:filtered":t[0]||=e=>V.value=e},null,8,[`rows`]),s(`div`,j,[u(v,{"config-key":`page.roles`,loading:z.value,data:R.value,columns:W,filter:B.value,"onUpdate:filter":t[1]||=e=>B.value=e,can_edit:`role-edit`,can_delete:`role-delete`,onEdit:Y,onDel:X},{"body-cell-name":a(e=>[u(S,{props:e},{default:a(()=>[s(`div`,M,[u(b,{size:`32px`,class:`q-mr-sm`,style:h(`background:${K(e.row.name)}1a;color:${K(e.row.name)}`)},{default:a(()=>[u(_,{name:`badge`,size:`18px`})]),_:1},8,[`style`]),s(`div`,N,[s(`a`,{class:`role-link`,onClick:g(t=>Y(e.row.id),[`prevent`])},i(e.row.name),9,P),e.row.name_fa?(r(),c(`span`,F,i(e.row.name_fa),1)):m(``,!0)])])]),_:2},1032,[`props`])]),"body-cell-modules_count":a(t=>[u(S,{props:t,class:`text-center`},{default:a(()=>[u(x,{dense:``,size:`sm`,color:`blue-grey-1`,"text-color":`blue-grey-8`},{default:a(()=>[f(i(t.row.modules_count)+` `+i(e.$t(`Modules`)),1)]),_:2},1024)]),_:2},1032,[`props`])]),"body-cell-permissions_count":a(e=>[u(S,{props:e,class:`text-center`},{default:a(()=>[u(x,{dense:``,size:`sm`,color:`teal-1`,"text-color":`teal-9`},{default:a(()=>[u(_,{name:`verified_user`,size:`13px`,class:`q-mr-xs`}),f(i(e.row.permissions_count),1)]),_:2},1024)]),_:2},1032,[`props`])]),"body-cell-users_count":a(e=>[u(S,{props:e,class:`text-center`},{default:a(()=>[u(x,{dense:``,size:`sm`,color:e.row.users_count?`deep-purple-1`:`grey-2`,"text-color":e.row.users_count?`deep-purple-9`:`grey-6`},{default:a(()=>[u(_,{name:`group`,size:`13px`,class:`q-mr-xs`}),f(i(e.row.users_count),1)]),_:2},1032,[`color`,`text-color`])]),_:2},1032,[`props`])]),_:1},8,[`loading`,`data`,`filter`])])])]),_:1})]),_:1})}}},[[`__scopeId`,`data-v-779a294d`]]);export{I as default};