import{a as $}from"./chunk-H3AKUSDZ.mjs";import{a as E}from"./chunk-ZKTW7U2A.mjs";import{a as F,c as N}from"./chunk-BHP27HO3.mjs";import{a as T}from"./chunk-KY323GRB.mjs";import{b as A}from"./chunk-7PGPVSIJ.mjs";import{useMemo as se,useTransition as le}from"react";import{LoadingState as ce}from"@baseapp-frontend/design-system/components/web/displays";import{Searchbar as B}from"@baseapp-frontend/design-system/components/web/inputs";import{Box as fe,Typography as z}from"@mui/material";import{useForm as be}from"react-hook-form";import{useFragment as de,usePaginationFragment as pe}from"react-relay";import{Virtuoso as ve}from"react-virtuoso";import{jsx as m,Fragment as H,jsxs as U}from"react/jsx-runtime";function g(e){"@babel/helpers - typeof";return g=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(r){return typeof r}:function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},g(e)}function R(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter(function(u){return Object.getOwnPropertyDescriptor(e,u).enumerable})),t.push.apply(t,n)}return t}function ee(e){for(var r=1;r<arguments.length;r++){var t=arguments[r]!=null?arguments[r]:{};r%2?R(Object(t),!0).forEach(function(n){re(e,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):R(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))})}return e}function re(e,r,t){return(r=te(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function te(e){var r=ne(e,"string");return g(r)=="symbol"?r:r+""}function ne(e,r){if(g(e)!="object"||!e)return e;var t=e[Symbol.toPrimitive];if(t!==void 0){var n=t.call(e,r||"default");if(g(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(e)}function oe(e,r){return ue(e)||me(e,r)||ie(e,r)||ae()}function ae(){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 ie(e,r){if(e){if(typeof e=="string")return D(e,r);var t={}.toString.call(e).slice(8,-1);return t==="Object"&&e.constructor&&(t=e.constructor.name),t==="Map"||t==="Set"?Array.from(e):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?D(e,r):void 0}}function D(e,r){(r==null||r>e.length)&&(r=e.length);for(var t=0,n=Array(r);t<r;t++)n[t]=e[t];return n}function me(e,r){var t=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(t!=null){var n,u,d,s,l=[],c=!0,p=!1;try{if(d=(t=t.call(e)).next,r===0){if(Object(t)!==t)return;c=!1}else for(;!(c=(n=d.call(t)).done)&&(l.push(n.value),l.length!==r);c=!0);}catch(h){p=!0,u=h}finally{try{if(!c&&t.return!=null&&(s=t.return(),Object(s)!==s))return}finally{if(p)throw u}}return l}}function ue(e){if(Array.isArray(e))return e}var ye=function(r){var t,n,u=r.userRef,d=r.MemberItem,s=d===void 0?$:d,l=r.MemberItemProps,c=l===void 0?{}:l,p=r.LoadingState,h=p===void 0?ce:p,j=r.LoadingStateProps,V=j===void 0?{}:j,M=r.membersContainerHeight,k=M===void 0?400:M,K=le(),C=oe(K,2),w=C[0],L=C[1],S=be({defaultValues:{search:""}}),I=S.control,Q=S.reset,P=S.watch,v=pe(A,u),i=v.data,q=v.loadNext,W=v.hasNext,X=v.isLoadingNext,G=v.refetch,_=de(T,i),O=function(o){L(function(){G({q:o})})},x=function(){L(function(){Q(),O("")})},f=se(function(){var a;return(i==null||(a=i.members)===null||a===void 0?void 0:a.edges.filter(function(o){return o?.node}).map(function(o){return o?.node}))||[]},[i==null||(t=i.members)===null||t===void 0?void 0:t.edges]),J=_==null||(n=_.name)===null||n===void 0?void 0:n.includes(P("search")),b=J?f.length+1:f.length,Y=function(){return X?m(h,ee({sx:{paddingTop:3,paddingBottom:1},CircularProgressProps:{size:15}},V)):m(fe,{sx:{paddingTop:3}})},Z=function(o,y){return m(E,{member:o,data:i,prevMember:f[y-1],nextMember:f[y+1],MemberItemComponent:s,memberItemComponentProps:c,searchQuery:P("search")})};return f.length===0?U(H,{children:[m(B,{variant:"outlined",size:"small",isPending:w,onChange:function(o){return O(o.target.value)},onClear:function(){return x()},name:"search",control:I,sx:{mb:4}}),m(z,{variant:"subtitle2",mb:4,children:b===1?"".concat(b," member"):"".concat(b," members")}),m(s,{member:i,memberRole:"owner",status:N.active,searchQuery:P("search")})]}):U(H,{children:[m(B,{variant:"outlined",size:"small",isPending:w,onChange:function(o){return O(o.target.value)},onClear:function(){return x()},name:"search",control:I,sx:{mb:4}}),m(z,{variant:"subtitle2",mb:4,children:b===1?"".concat(b," member"):"".concat(b," members")}),m(ve,{style:{height:k},data:f,itemContent:function(o,y){return y&&Z(y,o)},components:{Footer:Y},endReached:function(){W&&q(F)}})]})},xe=ye;export{xe as a};
//# sourceMappingURL=chunk-LIACMRTC.mjs.map