"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _chunkQHRRSLBOjs = require('./chunk-QHRRSLBO.js');var _chunkSJCZROJBjs = require('./chunk-SJCZROJB.js');var _chunkOB3KKIKAjs = require('./chunk-OB3KKIKA.js');var _chunk4MKL7U2Gjs = require('./chunk-4MKL7U2G.js');var _chunkBKZDG57Zjs = require('./chunk-BKZDG57Z.js');var _chunkGK5JJHZ7js = require('./chunk-GK5JJHZ7.js');var _chunkZPUIVRPUjs = require('./chunk-ZPUIVRPU.js');var _chunkVYNCIM3Gjs = require('./chunk-VYNCIM3G.js');var _chunkL4PBARWDjs = require('./chunk-L4PBARWD.js');var _chunkUQGTFMMXjs = require('./chunk-UQGTFMMX.js');var _chunkCMMAL7DUjs = require('./chunk-CMMAL7DU.js');var _chunk74X4UOY6js = require('./chunk-74X4UOY6.js');var _react = require('react');var _authentication = require('@baseapp-frontend/authentication');var _buttons = require('@baseapp-frontend/design-system/components/web/buttons');var _icons = require('@baseapp-frontend/design-system/components/web/icons');var _web = require('@baseapp-frontend/design-system/hooks/web');var _utils = require('@baseapp-frontend/utils');var _zod = require('@hookform/resolvers/zod');var _material = require('@mui/material');var _reacthookform = require('react-hook-form');var _reactrelay = require('react-relay');var _jsxruntime = require('react/jsx-runtime');function y(r){"@babel/helpers - typeof";return y=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},y(r)}function Z(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(r);e&&(o=o.filter(function(s){return Object.getOwnPropertyDescriptor(r,s).enumerable})),t.push.apply(t,o)}return t}function M(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?Z(Object(t),!0).forEach(function(o){Ee(r,o,t[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):Z(Object(t)).forEach(function(o){Object.defineProperty(r,o,Object.getOwnPropertyDescriptor(t,o))})}return r}function Ee(r,e,t){return(e=je(e))in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}function je(r){var e=we(r,"string");return y(e)=="symbol"?e:e+""}function we(r,e){if(y(r)!="object"||!r)return r;var t=r[Symbol.toPrimitive];if(t!==void 0){var o=t.call(r,e||"default");if(y(o)!="object")return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(r)}function O(r,e){return Ve(r)||Te(r,e)||Ge(r,e)||Fe()}function Fe(){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 Ge(r,e){if(r){if(typeof r=="string")return ee(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)?ee(r,e):void 0}}function ee(r,e){(e==null||e>r.length)&&(e=r.length);for(var t=0,o=Array(e);t<e;t++)o[t]=r[t];return o}function Te(r,e){var t=r==null?null:typeof Symbol<"u"&&r[Symbol.iterator]||r["@@iterator"];if(t!=null){var o,s,g,u,m=[],d=!0,b=!1;try{if(g=(t=t.call(r)).next,e===0){if(Object(t)!==t)return;d=!1}else for(;!(d=(o=g.call(t)).done)&&(m.push(o.value),m.length!==e);d=!0);}catch(c){b=!0,s=c}finally{try{if(!d&&t.return!=null&&(u=t.return(),Object(u)!==u))return}finally{if(b)throw s}}return m}}function Ve(r){if(Array.isArray(r))return r}var er=function(e){var t,o=e.profileId,s=e.allProfilesRef,g=e.queryRef,u=e.roomId,m=e.GroupChatMembersList,d=m===void 0?_chunkBKZDG57Zjs.a:m,b=e.GroupChatMembersListProps,c=b===void 0?{}:b,oe=e.onCancellation,ie=e.onRemovalFromGroup,ne=e.onValidSubmission,ae=_utils.useNotification.call(void 0, ),le=ae.sendToast,ue=_react.useState.call(void 0, !1),L=O(ue,2),x=L[0],h=L[1],se=_web.useResponsive.call(void 0, "down","sm"),me=_reactrelay.usePreloadedQuery.call(void 0, _chunkUQGTFMMXjs.a,g),E=me.chatRoom,j=_chunk74X4UOY6js.a.call(void 0, E),de=j.avatar,ce=j.title;_chunkVYNCIM3Gjs.b.call(void 0, {profileId:o,connections:[],onRemoval:ie});var v=_reactrelay.usePaginationFragment.call(void 0, _chunkCMMAL7DUjs.a,E),S=v.data,pe=v.loadNext,fe=v.isLoadingNext,be=v.hasNext,P=v.refetch,R=_react.useMemo.call(void 0, function(){var i;return S==null||(i=S.participants)===null||i===void 0||(i=i.edges)===null||i===void 0?void 0:i.map(function(n){var p;return(n==null||(p=n.node)===null||p===void 0?void 0:p.profile)&&n.node.profile})},[S]),l=_reacthookform.useForm.call(void 0, {defaultValues:_chunkGK5JJHZ7js.a.call(void 0, ce||"",de),resolver:_zod.zodResolver.call(void 0, _chunkGK5JJHZ7js.b),mode:"onBlur"}),ve=l.control,_=l.setValue,w=l.watch,ye=l.getFieldState,ge=l.clearErrors,he=l.trigger,Se=l.handleSubmit,A=l.formState,Pe=A.isValid,Me=A.isDirty,Re=A.dirtyFields,_e=_chunkL4PBARWDjs.b.call(void 0, ),F=O(_e,2),Ae=F[0],G=F[1],Ce=Se(function(i){if(u){var n=_utils.filterDirtyValues.call(void 0, {values:i,dirtyFields:Re}),p=i.image,N={};"image"in n&&(p?N.image=p:n.deleteImage=!0,delete n.image),delete n.participants,Ae({variables:{input:M({roomId:u,profileId:o},n),connections:[]},uploadables:N,onCompleted:function(C){var I,U=C==null||(I=C.chatRoomUpdate)===null||I===void 0?void 0:I.errors;U?(le("Something went wrong",{type:"error"}),_utils.setFormRelayErrors.call(void 0, l,U)):ne()}})}}),Ie=function(){ge(_chunkZPUIVRPUjs.a.image),_(_chunkZPUIVRPUjs.a.image,null,{shouldValidate:!0,shouldDirty:!0,shouldTouch:!0})},Oe=!Pe||!Me,Le=_react.useTransition.call(void 0, ),T=O(Le,2),V=T[0],xe=T[1],D=function(){h(!1),xe(function(){_optionalChain([P, 'optionalCall', _2 => _2({})])})};return se&&x?_jsxruntime.jsx.call(void 0, _chunkSJCZROJBjs.a,{allProfilesRef:s,onClose:function(){return h(!1)},handleSubmitSuccess:D,profileId:o,roomId:u,isPending:V,existingMembers:R}):_jsxruntime.jsxs.call(void 0, _material.Box,{children:[_jsxruntime.jsx.call(void 0, _chunkQHRRSLBOjs.a,{open:x,allProfilesRef:s,onClose:function(){return h(!1)},handleSubmitSuccess:D,profileId:o,roomId:u,isPending:V,existingMembers:R}),_jsxruntime.jsxs.call(void 0, _chunkOB3KKIKAjs.a,{children:[_jsxruntime.jsx.call(void 0, _buttons.IconButton,{onClick:oe,"aria-label":"cancel editing group",children:_jsxruntime.jsx.call(void 0, _icons.CloseIcon,{sx:{fontSize:"24px"}})}),_jsxruntime.jsx.call(void 0, _material.Typography,{component:"span",variant:"subtitle2",sx:{textAlign:"center"},children:"Edit Group"}),_jsxruntime.jsx.call(void 0, _buttons.IconButton,{"aria-label":"Edit group",disabled:Oe,isLoading:G,onClick:function(){Ce()},children:_jsxruntime.jsx.call(void 0, _icons.CheckMarkIcon,{sx:{fontSize:"24px"}})})]}),_jsxruntime.jsx.call(void 0, _chunk4MKL7U2Gjs.a,{control:ve,FORM_VALUE:_chunkZPUIVRPUjs.a,handleRemoveImage:Ie,imageError:ye(_chunkZPUIVRPUjs.a.image).error,isMutationInFlight:G,setValue:_,trigger:he,watch:w}),_jsxruntime.jsx.call(void 0, d,M({FORM_VALUE:_chunkZPUIVRPUjs.a,setValue:_,watch:w,currentParticipants:R,refetch:P,membersLoadNext:pe,membersHasNext:be,membersIsLoadingNext:fe,MembersListProps:M({allowAddMember:!0,onAddMemberClick:function(){return h(!0)}},(t=_optionalChain([c, 'optionalAccess', _3 => _3.MembersListProps]))!==null&&t!==void 0?t:{})},c))]})},rr=function(e){var t=_authentication.useCurrentProfile.call(void 0, ),o=t.currentProfile;return o!=null&&o.id?_jsxruntime.jsx.call(void 0, er,M({profileId:o.id},e)):null},Mr= exports.a =rr;exports.a = Mr;
//# sourceMappingURL=chunk-3JCAKVAM.js.map