import{a as D}from"./chunk-N6FN3HMD.mjs";import{a as v}from"./chunk-K4H7DHEI.mjs";import{a as $,b as V}from"./chunk-BH5YVZU3.mjs";import{useTransition as ye}from"react";import{Searchbar as ve}from"@baseapp-frontend/design-system/components/web/inputs";import{Box as Pe}from"@mui/material";import{useForm as ge}from"react-hook-form";import{jsx as m,jsxs as R}from"react/jsx-runtime";function f(r){"@babel/helpers - typeof";return f=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},f(r)}function E(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);e&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(r,i).enumerable})),t.push.apply(t,n)}return t}function h(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?E(Object(t),!0).forEach(function(n){ae(r,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):E(Object(t)).forEach(function(n){Object.defineProperty(r,n,Object.getOwnPropertyDescriptor(t,n))})}return r}function ae(r,e,t){return(e=se(e))in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}function se(r){var e=le(r,"string");return f(e)=="symbol"?e:e+""}function le(r,e){if(f(r)!="object"||!r)return r;var t=r[Symbol.toPrimitive];if(t!==void 0){var n=t.call(r,e||"default");if(f(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(r)}function ue(r){return me(r)||de(r)||H(r)||ce()}function ce(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function de(r){if(typeof Symbol<"u"&&r[Symbol.iterator]!=null||r["@@iterator"]!=null)return Array.from(r)}function me(r){if(Array.isArray(r))return P(r)}function fe(r,e){return pe(r)||he(r,e)||H(r,e)||be()}function be(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function H(r,e){if(r){if(typeof r=="string")return P(r,e);var t={}.toString.call(r).slice(8,-1);return t==="Object"&&r.constructor&&(t=r.constructor.name),t==="Map"||t==="Set"?Array.from(r):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?P(r,e):void 0}}function P(r,e){(e==null||e>r.length)&&(e=r.length);for(var t=0,n=Array(e);t<e;t++)n[t]=r[t];return n}function he(r,e){var t=r==null?null:typeof Symbol<"u"&&r[Symbol.iterator]||r["@@iterator"];if(t!=null){var n,i,c,a,d=[],l=!0,b=!1;try{if(c=(t=t.call(r)).next,e===0){if(Object(t)!==t)return;l=!1}else for(;!(l=(n=c.call(t)).done)&&(d.push(n.value),d.length!==e);l=!0);}catch(p){b=!0,i=p}finally{try{if(!l&&t.return!=null&&(a=t.return(),Object(a)!==a))return}finally{if(b)throw i}}return d}}function pe(r){if(Array.isArray(r))return r}var Se=function(e){var t=e.FORM_VALUE,n=e.setValue,i=e.refetch,c=e.connections,a=e.currentParticipants,d=e.connectionsLoadNext,l=e.connectionsHasNext,b=e.connectionsIsLoadingNext,p=e.membersLoadNext,F=e.membersHasNext,U=e.membersIsLoadingNext,g=e.ProfilesContainer,W=g===void 0?V:g,S=e.ProfileCard,k=S===void 0?D:S,C=e.ProfileCardProps,q=C===void 0?{}:C,L=e.Searchbar,G=L===void 0?ve:L,x=e.SearchbarProps,K=x===void 0?{}:x,j=e.SearchbarContainer,B=j===void 0?$:j,O=e.ConnectionsList,z=O===void 0?v:O,A=e.ConnectionsListProps,J=A===void 0?{}:A,M=e.MembersList,Q=M===void 0?v:M,N=e.MembersListProps,X=N===void 0?{}:N,Y=ye(),I=fe(Y,2),w=I[0],T=I[1],y=ge({defaultValues:{search:""}}),Z=y.control,ee=y.reset,re=y.watch,te=function(o){var s=o.target.value||"";T(function(){i?.({q:s})})},ne=function(){T(function(){ee(),i?.({q:""})})},oe=function(o){n(t.participants,[].concat(ue(a),[o]),{shouldValidate:!0,shouldDirty:!0,shouldTouch:!0})},ie=function(o){n(t.participants,a.filter(function(s){return s?.id!==o?.id}),{shouldValidate:!0,shouldDirty:!0,shouldTouch:!0})},_=function(o){var s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;return o?m(k,h({profile:o,handleAddMember:oe,handleRemoveMember:ie,isMember:s},q)):null};return R(W,{children:[m(B,{children:m(G,h({name:"search",onChange:te,onClear:ne,control:Z,isPending:w},K))}),R(Pe,{height:"100%",width:"100%",children:[m(Q,h({profiles:a,renderItem:function(o){return _(o,!0)},loadNext:p,hasNext:F,isLoadingNext:U,label:"Selected group members",title:"Members"},X)),c&&m(z,h({profiles:c,renderItem:function(o){return _(o)},loadNext:d,hasNext:l,isLoadingNext:b,isPending:w,searchValue:re("search")},J))]})]})},Ie=Se;export{Ie as a};
//# sourceMappingURL=chunk-N74X2TZF.mjs.map