import{a7 as h,aQ as t,a4 as p,dx as j,dy as y,aV as f}from"./index-dNe6i2rS.js";import{r as o,j as a}from"./vendor-react-wBh_31cN.js";import{E as l}from"./editable-select-DItn4ZHW.js";import{I as v}from"./input-DFI7JniT.js";import{L as g}from"./label-gPWmc6ow.js";import{u as T}from"./useDebounce-BiuGz9t2.js";import{c as L}from"./index-odFb5xpE.js";const G=h.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:t.providesList(p.AdminProjectMappingTags.Mapping)}),getMapping:s.query({query:({id:e})=>({url:`/admin/group/mapping/${e}`}),providesTags:t.cacheByIdArgProperty(p.AdminProjectMappingTags.Mapping)}),updateMapping:s.mutation({query:({id:e,data:r})=>({url:`/admin/group/mapping/${e}`,method:"put",data:r}),invalidatesTags:t.invalidatesList(p.AdminProjectMappingTags.Mapping)}),createMapping:s.mutation({query:({data:e})=>({url:"/admin/group/mapping",method:"post",data:e}),invalidatesTags:t.invalidatesList(p.AdminProjectMappingTags.Mapping)}),createMappingBulk:s.mutation({query:({data:e})=>({url:"/admin/group/mapping/bulk",method:"post",data:e}),invalidatesTags:t.invalidatesList(p.AdminProjectMappingTags.Mapping)}),deleteMapping:s.mutation({query:({id:e})=>({url:`/admin/group/mapping/${e}`,method:"delete"}),invalidatesTags:t.invalidatesList(p.AdminProjectMappingTags.Mapping)})})}),{useGetMappingsQuery:S,useGetMappingQuery:U,useUpdateMappingMutation:_,useCreateMappingMutation:B,useCreateMappingBulkMutation:H,useDeleteMappingMutation:O}=G,R=j.injectEndpoints({endpoints:s=>({getRemoteGroups:s.query({query:(e="")=>({url:`/mapping/search?query=${encodeURIComponent(e)}`}),providesTags:t.providesList(y.RemoteProjectMappingTags.Groups)}),getRemoteGroupMembers:s.query({query:({groups:e})=>({url:"/mapping/members",query:e}),providesTags:t.providesList(y.RemoteProjectMappingTags.Members)})})}),{useGetRemoteGroupsQuery:q,useGetRemoteGroupMembersQuery:V}=R,A=({isEdit:s,value:e,onChange:r,...i})=>{const[n,u]=o.useState(""),c=T(n,500),{data:m=[],isFetching:d}=q(c),{data:M,isLoading:b}=f("ldap_groups_search_filter");return o.useLayoutEffect(()=>{u(M??"")},[M]),a.jsxs("div",{className:"flex flex-col",children:[a.jsx(g,{className:"mb-2.5",children:"Remote groups"}),a.jsxs("div",{className:"mb-5 flex items-center gap-2.5",children:[a.jsx("div",{className:"w-[400px]",children:a.jsx(v,{placeholder:"filter query",value:n,onChange:x=>u(x.target.value)})}),a.jsx(g,{className:"w-[30px]",children:"->"}),a.jsx(l,{isMulti:!s,noResultsText:"No group found",value:e,options:m,placeholder:"pick remote groups",isLoading:d,preventAdding:!0,onChange:r,...i},`key-${e}`)]})]})},w=o.memo(A),N=({isEdit:s,value:e,onChange:r,...i})=>a.jsxs("div",{className:"flex flex-col",children:[a.jsx(g,{className:"mb-2.5",children:"Remote groups"}),a.jsx("div",{className:"mb-5 flex items-center",children:a.jsx(l,{isMulti:!s,noResultsText:"you have to add groups manually",value:e,options:[],placeholder:"pick remote groups",isLoading:!1,onChange:r,...i},`key-${e}`)})]}),D=o.memo(N),k=({isEdit:s,value:e,onChange:r,...i})=>{const{data:n,isLoading:u}=L(),c=m=>m?m.map(d=>d.groupName):[];return a.jsxs("div",{className:"flex flex-col",children:[a.jsx(g,{className:"mb-2.5",children:"Groups"}),a.jsx("div",{className:"mb-5 flex items-center",children:a.jsx(l,{isMulti:!s,noResultsText:"No group found",value:e,options:c(n),placeholder:"pick groups",isLoading:u,preventAdding:!0,onChange:r,...i},`key-${e}`)})]})},W=o.memo(k);export{W as H,w as L,D as O,O as a,S as b,H as c,_ as u};
