"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 _chunk4MKL7U2Gjs = require('./chunk-4MKL7U2G.js');var _chunkBKZDG57Zjs = require('./chunk-BKZDG57Z.js');var _chunk3UWNUMUIjs = require('./chunk-3UWNUMUI.js');var _chunkZPUIVRPUjs = require('./chunk-ZPUIVRPU.js');var _chunkO6JUP3I3js = require('./chunk-O6JUP3I3.js');var _chunkCXSDPRQ5js = require('./chunk-CXSDPRQ5.js');var _chunkMBKDZBVUjs = require('./chunk-MBKDZBVU.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 _utils = require('@baseapp-frontend/utils');var _zod = require('@hookform/resolvers/zod');var _material = require('@mui/material');var _reacthookform = require('react-hook-form');var _relayruntime = require('relay-runtime');var _jsxruntime = require('react/jsx-runtime');function g(t){"@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(t)}function z(t,r){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);r&&(o=o.filter(function(c){return Object.getOwnPropertyDescriptor(t,c).enumerable})),e.push.apply(e,o)}return e}function yt(t){for(var r=1;r<arguments.length;r++){var e=arguments[r]!=null?arguments[r]:{};r%2?z(Object(e),!0).forEach(function(o){bt(t,o,e[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):z(Object(e)).forEach(function(o){Object.defineProperty(t,o,Object.getOwnPropertyDescriptor(e,o))})}return t}function bt(t,r,e){return(r=ht(r))in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}function ht(t){var r=gt(t,"string");return g(r)=="symbol"?r:r+""}function gt(t,r){if(g(t)!="object"||!t)return t;var e=t[Symbol.toPrimitive];if(e!==void 0){var o=e.call(t,r||"default");if(g(o)!="object")return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(t)}function _t(t,r){return At(t)||Pt(t,r)||Ct(t,r)||Ot()}function Ot(){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 Ct(t,r){if(t){if(typeof t=="string")return K(t,r);var e={}.toString.call(t).slice(8,-1);return e==="Object"&&t.constructor&&(e=t.constructor.name),e==="Map"||e==="Set"?Array.from(t):e==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?K(t,r):void 0}}function K(t,r){(r==null||r>t.length)&&(r=t.length);for(var e=0,o=Array(r);e<r;e++)o[e]=t[e];return o}function Pt(t,r){var e=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(e!=null){var o,c,m,p,v=[],d=!0,_=!1;try{if(m=(e=e.call(t)).next,r===0){if(Object(e)!==e)return;d=!1}else for(;!(d=(o=m.call(e)).done)&&(v.push(o.value),v.length!==r);d=!0);}catch(P){_=!0,c=P}finally{try{if(!d&&e.return!=null&&(p=e.return(),Object(p)!==p))return}finally{if(_)throw c}}return v}}function At(t){if(Array.isArray(t))return t}var Gt=function(r){var e=r.allProfilesRef,o=r.GroupChatMembersList,c=o===void 0?_chunkBKZDG57Zjs.a:o,m=r.GroupChatMembersListProps,p=m===void 0?{}:m,v=r.onValidSubmission,d=r.onBackButtonClicked,_=_utils.useNotification.call(void 0, ),P=_.sendToast,y=_chunkO6JUP3I3js.b.call(void 0, e),O=y.data.allProfiles,W=y.loadNext,J=y.isLoadingNext,Q=y.hasNext,X=y.refetch,a=_reacthookform.useForm.call(void 0, {defaultValues:_chunkZPUIVRPUjs.b,resolver:_zod.zodResolver.call(void 0, _chunkZPUIVRPUjs.c),mode:"onBlur"}),Y=a.control,A=a.setValue,R=a.watch,Z=a.getFieldState,$=a.clearErrors,tt=a.handleSubmit,E=a.formState,rt=E.isValid,et=E.isDirty,ot=E.dirtyFields,it=a.trigger,nt=_authentication.useCurrentProfile.call(void 0, ),n=nt.currentProfile,at=_chunkCXSDPRQ5js.b.call(void 0, ),j=_t(at,2),lt=j[0],F=j[1],ut=_chunkMBKDZBVUjs.a.call(void 0, ),st=ut.setChatRoom,ct=tt(function(i){var b=_utils.filterDirtyValues.call(void 0, {values:i,dirtyFields:ot}),h=i.title,pt=i.participants,L=i.image,vt=(pt||[]).map(function(C){return _optionalChain([C, 'optionalAccess', _2 => _2.id])}),T={};_chunkZPUIVRPUjs.a.image in b&&L&&typeof L!="string"&&(T.image=L),lt({variables:{input:{title:h,isGroup:!0,profileId:_optionalChain([n, 'optionalAccess', _3 => _3.id]),participants:vt},connections:[_relayruntime.ConnectionHandler.getConnectionID(_optionalChain([n, 'optionalAccess', _4 => _4.id]),"roomsList_chatRooms",{unreadMessages:!1,archived:!1,q:""})]},uploadables:T,onCompleted:function(f){var I,x=f==null||(I=f.chatRoomCreate)===null||I===void 0?void 0:I.errors;if(x)P("Something went wrong",{type:"error"}),_utils.setFormRelayErrors.call(void 0, a,x);else{var l;st({id:f==null||(l=f.chatRoomCreate)===null||l===void 0||(l=l.room)===null||l===void 0||(l=l.node)===null||l===void 0?void 0:l.id}),v()}}})}),S=R(_chunkZPUIVRPUjs.a.participants),dt=_react.useMemo.call(void 0, function(){return _optionalChain([O, 'optionalAccess', _5 => _5.edges, 'access', _6 => _6.filter, 'call', _7 => _7(function(i){return _optionalChain([i, 'optionalAccess', _8 => _8.node])&&_optionalChain([i, 'optionalAccess', _9 => _9.node, 'access', _10 => _10.id])!==_optionalChain([n, 'optionalAccess', _11 => _11.id])&&!S.some(function(b){var h;return _optionalChain([b, 'optionalAccess', _12 => _12.id])===(i==null||(h=i.node)===null||h===void 0?void 0:h.id)})}), 'access', _13 => _13.map, 'call', _14 => _14(function(i){return _optionalChain([i, 'optionalAccess', _15 => _15.node])})])||[]},[O,S,_optionalChain([n, 'optionalAccess', _16 => _16.id])]),ft=function(){$(_chunkZPUIVRPUjs.a.image),A(_chunkZPUIVRPUjs.a.image,null,{shouldValidate:!0,shouldDirty:!0,shouldTouch:!0})},mt=!rt||!et||F;return _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsxs.call(void 0, _material.Box,{children:[_jsxruntime.jsxs.call(void 0, _chunk3UWNUMUIjs.a,{children:[_jsxruntime.jsx.call(void 0, _buttons.IconButton,{onClick:d,"aria-label":"cancel group creation",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:"New Group"}),_jsxruntime.jsx.call(void 0, _buttons.IconButton,{"aria-label":"Create group",disabled:mt,onClick:function(){ct()},children:_jsxruntime.jsx.call(void 0, _icons.CheckMarkIcon,{sx:{fontSize:"24px"}})})]}),_jsxruntime.jsx.call(void 0, _chunk4MKL7U2Gjs.a,{control:Y,FORM_VALUE:_chunkZPUIVRPUjs.a,handleRemoveImage:ft,imageError:Z(_chunkZPUIVRPUjs.a.image).error,isMutationInFlight:F,setValue:A,trigger:it,watch:R})]}),_jsxruntime.jsx.call(void 0, c,yt({FORM_VALUE:_chunkZPUIVRPUjs.a,setValue:A,watch:R,currentParticipants:S,connections:dt,refetch:X,connectionsLoadNext:W,connectionsHasNext:Q,connectionsIsLoadingNext:J,ProfilesContainer:_chunk3UWNUMUIjs.b},p))]})},rr= exports.a =Gt;exports.a = rr;
//# sourceMappingURL=chunk-WVMEW3HP.js.map