import{M as j,P as a,O as i,e6 as L,e7 as y,r as o,aK as T,cV as q,j as p,q as r,bl as c,F as v,aH as G,bP as M}from"./index-Cox3ZWL0.js";import{c as A}from"./index-Bz0gT19t.js";const R=j.injectEndpoints({endpoints:s=>({getMappings:s.query({query:()=>({url:"/admin/group/mapping?sort_by=id"}),transformResponse:e=>(e==null?void 0:e.count)>0?e.items:[],providesTags:a.providesList(i.AdminProjectMappingTags.Mapping)}),getMapping:s.query({query:({id:e})=>({url:`/admin/group/mapping/${e}`}),providesTags:a.cacheByIdArgProperty(i.AdminProjectMappingTags.Mapping)}),updateMapping:s.mutation({query:({id:e,data:t})=>({url:`/admin/group/mapping/${e}`,method:"put",data:t}),invalidatesTags:a.invalidatesList(i.AdminProjectMappingTags.Mapping)}),createMapping:s.mutation({query:({data:e})=>({url:"/admin/group/mapping",method:"post",data:e}),invalidatesTags:a.invalidatesList(i.AdminProjectMappingTags.Mapping)}),createMappingBulk:s.mutation({query:({data:e})=>({url:"/admin/group/mapping/bulk",method:"post",data:e}),invalidatesTags:a.invalidatesList(i.AdminProjectMappingTags.Mapping)}),deleteMapping:s.mutation({query:({id:e})=>({url:`/admin/group/mapping/${e}`,method:"delete"}),invalidatesTags:a.invalidatesList(i.AdminProjectMappingTags.Mapping)})})}),{useGetMappingsQuery:I,useUpdateMappingMutation:E,useCreateMappingBulkMutation:H,useDeleteMappingMutation:O}=R,f=L.injectEndpoints({endpoints:s=>({getRemoteGroups:s.query({query:(e="")=>({url:`/mapping/search?query=${encodeURIComponent(e)}`}),providesTags:a.providesList(y.RemoteProjectMappingTags.Groups)}),getRemoteGroupMembers:s.query({query:({groups:e})=>({url:"/mapping/members",query:e}),providesTags:a.providesList(y.RemoteProjectMappingTags.Members)})})}),{useGetRemoteGroupsQuery:k}=f,P=({isEdit:s,value:e,onChange:t,...n})=>{const[g,u]=o.useState(""),d=T(g,500),{data:m=[],isFetching:l}=k(d),{data:h,isLoading:F}=q("ldap_groups_search_filter");return o.useLayoutEffect(()=>{u(h??"")},[h]),p.jsxs(r,{flexDirection:"column",children:[p.jsx(c,{mb:"10px",children:"Remote groups"}),p.jsxs(r,{mb:"20px",alignItems:"center",children:[p.jsx(v,{mr:"10px",width:"400px",children:p.jsx(G,{placeholder:"filter query",value:g,onChange:x=>u(x.target.value),width:"100%"})}),p.jsx(c,{width:"30px",children:"->"}),p.jsx(M,{isMulti:!s,noDataMessage:"No group found",value:e,options:m,placeholder:"pick remote groups",isLoading:l,preventAdding:!0,onChange:t,...n},`key-${e}`)]})]})},U=o.memo(P),$=({isEdit:s,value:e,onChange:t,...n})=>p.jsxs(r,{flexDirection:"column",children:[p.jsx(c,{mb:"10px",children:"Remote groups"}),p.jsx(r,{mb:"20px",alignItems:"center",children:p.jsx(M,{isMulti:!s,noDataMessage:"you have to add groups manually",value:e,options:[],placeholder:"pick remote groups",isLoading:!1,onChange:t,...n},`key-${e}`)})]}),_=o.memo($),b=({isEdit:s,value:e,onChange:t,...n})=>{const{data:g,isLoading:u}=A(),d=m=>m?m.map(l=>l.groupName):[];return p.jsxs(r,{flexDirection:"column",children:[p.jsx(c,{mb:"10px",children:"Groups"}),p.jsx(r,{mb:"20px",alignItems:"center",children:p.jsx(M,{isMulti:!s,noDataMessage:"No group found",value:e,options:d(g),placeholder:"pick groups",isLoading:u,preventAdding:!0,onChange:t,...n},`key-${e}`)})]})},w=o.memo(b);export{w as H,U as L,_ as O,O as a,I as b,H as c,E as u};
