import{a as O}from"./chunk-4QFQAY4C.mjs";import{a as W}from"./chunk-6JUOH5M3.mjs";import{a as $,b as H,c as V}from"./chunk-LRPGUKWO.mjs";import{a as F}from"./chunk-HJ3UWYSU.mjs";import{b as M}from"./chunk-K4NCOIN3.mjs";import{a as L}from"./chunk-O5PFQIB5.mjs";import{a as N}from"./chunk-K5BDVSIZ.mjs";import{a as T,c as E,e as G}from"./chunk-AZ65ECT7.mjs";import{Suspense as je,useRef as xe,useState as ke}from"react";import{useCurrentProfile as Be}from"@baseapp-frontend/authentication";import{CircledAvatar as _e}from"@baseapp-frontend/design-system/components/web/avatars";import{LoadingState as z}from"@baseapp-frontend/design-system/components/web/displays";import{TypographyWithEllipsis as Ae}from"@baseapp-frontend/design-system/components/web/typographies";import{Box as P,Typography as K,useTheme as we}from"@mui/material";import{ConnectionHandler as Ie,usePaginationFragment as Re,usePreloadedQuery as De}from"react-relay";import{Virtuoso as Te}from"react-virtuoso";import{jsx as n,jsxs as c,Fragment as U}from"react/jsx-runtime";function m(e){"@babel/helpers - typeof";return m=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},m(e)}var me=["onBackButtonClicked"];function fe(e,r){if(e==null)return{};var t,o,a=ve(e,r);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(o=0;o<l.length;o++)t=l[o],r.indexOf(t)===-1&&{}.propertyIsEnumerable.call(e,t)&&(a[t]=e[t])}return a}function ve(e,r){if(e==null)return{};var t={};for(var o in e)if({}.hasOwnProperty.call(e,o)){if(r.indexOf(o)!==-1)continue;t[o]=e[o]}return t}function Q(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);r&&(o=o.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),t.push.apply(t,o)}return t}function j(e){for(var r=1;r<arguments.length;r++){var t=arguments[r]!=null?arguments[r]:{};r%2?Q(Object(t),!0).forEach(function(o){ye(e,o,t[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):Q(Object(t)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(t,o))})}return e}function ye(e,r,t){return(r=be(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function be(e){var r=ge(e,"string");return m(r)=="symbol"?r:r+""}function ge(e,r){if(m(e)!="object"||!e)return e;var t=e[Symbol.toPrimitive];if(t!==void 0){var o=t.call(e,r||"default");if(m(o)!="object")return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(e)}function he(e,r){return Oe(e)||Se(e,r)||Ce(e,r)||Pe()}function Pe(){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 Ce(e,r){if(e){if(typeof e=="string")return q(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)?q(e,r):void 0}}function q(e,r){(r==null||r>e.length)&&(r=e.length);for(var t=0,o=Array(r);t<r;t++)o[t]=e[t];return o}function Se(e,r){var t=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(t!=null){var o,a,l,d,p=[],u=!0,f=!1;try{if(l=(t=t.call(e)).next,r===0){if(Object(t)!==t)return;u=!1}else for(;!(u=(o=l.call(t)).done)&&(p.push(o.value),p.length!==r);u=!0);}catch(v){f=!0,a=v}finally{try{if(!u&&t.return!=null&&(d=t.return(),Object(d)!==d))return}finally{if(f)throw a}}return p}}function Oe(e){if(Array.isArray(e))return e}var Ee=function(r){var t,o=r.onBackButtonClicked,a=r.onEditButtonClicked,l=r.queryRef,d=r.ProfileCard,p=d===void 0?W:d,u=r.ProfileCardProps,f=u===void 0?{}:u,v=r.VirtuosoProps,J=v===void 0?{}:v,X=De(L,l),i=X.chatRoom,Y=Be(),C=Y.currentProfile,x=T(i),Z=x.avatar,ee=x.title,k=we(),B=(t=C?.id)!==null&&t!==void 0?t:"",re=i!=null&&i.id?[Ie.getConnectionID(i.id,"ChatRoom_participants")]:[];M({profileId:B,connections:re,onRemoval:o});var y=Re(N,i),S=y.data,te=y.loadNext,oe=y.isLoadingNext,ne=y.hasNext,b=S?.participants,_=G(b),A=_.isAdmin,ie=_.isSoleAdmin,ae=function(){return oe?n(z,{sx:{paddingTop:3,paddingBottom:1},CircularProgressProps:{size:15},"aria-label":"loading more profiles"}):n(P,{sx:{paddingTop:3}})},le=ke(void 0),w=he(le,2),g=w[0],I=w[1],R=xe(void 0),ue=function(s,D){I(s),R.current=D},de=function(){I(void 0),R.current=void 0},se=function(s){return s.node?n(p,j({groupMember:s.node,initiateRemoval:ue,hasAdminPermissions:A},f)):null},ce=function(){return n(Te,j({data:b?.edges,itemContent:function(D,pe){return se(pe)},style:{scrollbarWidth:"none"},components:{Footer:ae},endReached:function(){ne&&te(5)}},J))};return c(U,{children:[n(F,{profileId:B,roomId:i?.id,open:!!g,removingParticipantId:g??"",onClose:de,isSoleAdmin:ie}),n(O,{onBackButtonClicked:o,onEditButtonClicked:a,shouldDisplayEditButton:A}),c(P,{sx:{display:"grid",gridTemplateRows:"auto 1fr"},children:[c($,{children:[n(_e,{src:Z,width:144,height:144,hasError:!1}),c(H,{children:[n(Ae,{variant:"subtitle1",color:"text.primary",children:ee}),n(K,{variant:"body2",color:"text.secondary",children:E(i?.participantsCount)})]})]}),c(P,{sx:{display:"grid",gridTemplateRows:"auto 1fr"},children:[n(P,{role:"list","aria-label":"group members",children:n(K,{variant:"subtitle2",color:"text.primary",sx:{padding:k.spacing(2),borderBottom:"1px solid ".concat(k.palette.divider)},children:"Members"})}),n(V,{children:ce()})]})]})]})},Ge=function(r){var t=r.onBackButtonClicked,o=fe(r,me);return n(je,{fallback:c(U,{children:[n(O,{onBackButtonClicked:t,shouldDisplayEditButton:!1}),n(z,{})]}),children:n(Ee,j({onBackButtonClicked:t},o))})},Xe=Ge;export{Xe as a};
//# sourceMappingURL=chunk-SBFYGNQT.mjs.map