import{O as f,P as a,Q as m,d9 as u,dB as c,x as q,w as P,dT as _,p as $,aU as p,a$ as N,l as B,dr as M,A as h,dU as C}from"./index-_eM6l4Nf.js";import{w as U}from"./where-B0yrqZx2.js";const y=P({items:$(p(U({role:M(h("groupName","AGENT"))})),p(U({role:B,accountType:N("M_ACCOUNT_TYPE")})))}),R=r=>{if(!r||r.length<1)return"";const e=r.map(t=>`sort_by=${t.name}:${t.value}`).join("&");return e?`&${e}`:""},w=r=>{if(!r||r.length<1)return"";const e=r.map(t=>`filter_by=${t.name}:${t.value}`).join("&");return e?`&${e}`:""},E=r=>`?${C.stringify({limit:r.limit,offset:r.offset})}${R(r.sortBy)}${w(r.filterBy)}`,d={name:_.EMAIL,value:"ASC"},g=(r,e,t)=>{const s=t?{...t}:{sortBy:[],filterBy:[]};return s.sortBy=s.sortBy?[...s.sortBy,e]:[e],s.filterBy=s.filterBy?[...s.filterBy,...r]:[...r],E(s)},j=f.injectEndpoints({endpoints:r=>({getGroups:r.query({query:()=>({url:"/admin/users/groups"}),providesTags:m.providesList(a.AdminUsersTags.Groups),transformResponse:e=>e.count>0?e.items:[]}),getUsersAsAdmin:r.query({query:()=>({url:"/admin/users"}),providesTags:m.providesList(a.AdminUsersTags.All),transformResponse:e=>e.count>0?y(e).items:[]}),getFilteredUsers:r.query({query:e=>{const t={name:c.STATUS_IN,value:`${u.ACTIVATED_ACCOUNT.toString()},${u.TEMP_PASSWORD.toString()}`};return{url:`/admin/users${g([t],d,e)}`}},providesTags:m.providesList(a.AdminUsersTags.Filtered),transformResponse:e=>e.count>0?y(e).items:[]}),getActiveUsers:r.query({query:e=>{const t={name:c.STATUS_IN,value:`${u.ACTIVATED_ACCOUNT.toString()},${u.TEMP_PASSWORD.toString()}`};return{url:`/admin/users${g([t],d,e)}`}},providesTags:e=>m.providesList(a.AdminUsersTags.Active)(e==null?void 0:e.items),transformResponse:q(y)}),getNewUsers:r.query({query:e=>{const t={name:c.STATUS_LT,value:u.ACTIVATED_ACCOUNT.toString()};return{url:`/admin/users${g([t],d,e)}`}},providesTags:m.providesList(a.AdminUsersTags.New),transformResponse:e=>e.count>0?e.items:[]}),getBlockedUsers:r.query({query:e=>{const t={name:c.STATUS_GT,value:u.ACTIVATED_ACCOUNT.toString()},s={name:c.STATUS_LT,value:u.TEMP_PASSWORD.toString()};return{url:`/admin/users${g([s,t],d,e)}`}},providesTags:e=>m.providesList(a.AdminUsersTags.Blocked)(e==null?void 0:e.items)}),changeUserRole:r.mutation({query:({id:e,role:t})=>({url:`/admin/users/${e}/role`,method:"put",data:t.toString()}),invalidatesTags:(e,t,{id:s})=>[{type:a.AdminUsersTags.Active,id:s}]}),updateUserMaxNumProjects:r.mutation({query:({id:e,max:t})=>({url:`/admin/users/${e}`,method:"put",data:{maxNumProjects:t}}),invalidatesTags:(e,t,{id:s})=>[{type:a.AdminUsersTags.Active,id:s}]}),acceptUser:r.mutation({query:({id:e})=>({url:`/admin/users/${e}/accepted`,method:"put"}),invalidatesTags:(e,t,{id:s})=>[{type:a.AdminUsersTags.Active},{type:a.AdminUsersTags.New,id:s},{type:a.AdminUsersTags.Blocked,id:s}]}),acceptUsers:r.mutation({query:({ids:e})=>({url:"/admin/users/accepted",method:"put",data:{ids:e}}),invalidatesTags:(e,t,{ids:s})=>[...s.flatMap(o=>[{type:a.AdminUsersTags.New,id:o},{type:a.AdminUsersTags.Blocked,id:o}]),{type:a.AdminUsersTags.Active}],transformResponse:e=>e.count>0?e.items:[]}),rejectUser:r.mutation({query:({id:e})=>({url:`/admin/users/${e}/rejected`,method:"put"}),invalidatesTags:(e,t,{id:s})=>[{type:a.AdminUsersTags.Active,id:s},{type:a.AdminUsersTags.New,id:s},{type:a.AdminUsersTags.Blocked}]}),rejectUsers:r.mutation({query:({ids:e})=>({url:"/admin/users/rejected",method:"put",data:{ids:e}}),invalidatesTags:(e,t,{ids:s})=>[...s.flatMap(o=>[{type:a.AdminUsersTags.Active,id:o},{type:a.AdminUsersTags.New,id:o}]),{type:a.AdminUsersTags.Blocked}],transformResponse:e=>e.count>0?e.items:[]}),resetUserPassword:r.mutation({query:({id:e})=>({url:`/admin/users/${e}/reset`,method:"put"})}),deleteUser:r.mutation({query:({id:e})=>({url:`/admin/users/${e}`,method:"delete"}),invalidatesTags:(e,t,{id:s})=>[{type:a.AdminUsersTags.All,id:s},{type:a.AdminUsersTags.Active,id:s},{type:a.UsersTags.Users}]}),createUser:r.mutation({query:({accountType:e,uuid:t,subject:s,clientId:i,email:o,givenName:A,surname:l,maxNumProjects:v,role:S,type:T})=>{let n={accountType:e.toString(),email:o,givenName:A,surname:l,maxNumProjects:v,role:S.toString()};return t&&(n={...n,uuid:t}),s&&(n={...n,subject:s}),i&&(n={...n,clientId:i}),T&&(n={...n,type:T.toString()}),{url:`/admin/users?${new URLSearchParams(n).toString()}`,method:"post"}},invalidatesTags:[{type:a.AdminUsersTags.Active},{type:a.AdminUsersTags.All},{type:a.UsersTags.Users}]})})}),{useGetGroupsQuery:O,useGetUsersAsAdminQuery:Q,useGetFilteredUsersQuery:D,useGetActiveUsersQuery:I,useGetNewUsersQuery:x,useGetBlockedUsersQuery:F,useAcceptUserMutation:V,useAcceptUsersMutation:W,useChangeUserRoleMutation:Y,useRejectUserMutation:z,useRejectUsersMutation:H,useResetUserPasswordMutation:J,useDeleteUserMutation:K,useCreateUserMutation:X,useUpdateUserMaxNumProjectsMutation:Z}=j;export{J as a,x as b,O as c,Y as d,Z as e,I as f,F as g,Q as h,V as i,W as j,z as k,H as l,K as m,X as n,D as u};
