"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkOB3KKIKAjs = require('./chunk-OB3KKIKA.js');var _chunkQ4RWV3MAjs = require('./chunk-Q4RWV3MA.js');var _chunk5A32CO6Ijs = require('./chunk-5A32CO6I.js');var _chunkUQGTFMMXjs = require('./chunk-UQGTFMMX.js');var _chunkOT6EXTQMjs = require('./chunk-OT6EXTQM.js');var _chunkXYEPI42Pjs = require('./chunk-XYEPI42P.js');var _chunkKIVWK2EBjs = require('./chunk-KIVWK2EB.js');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 _reactrelay = require('react-relay');var _jsxruntime = require('react/jsx-runtime');function c(e){"@babel/helpers - typeof";return c=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},c(e)}function T(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);r&&(o=o.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),t.push.apply(t,o)}return t}function L(e){for(var r=1;r<arguments.length;r++){var t=arguments[r]!=null?arguments[r]:{};r%2?T(Object(t),!0).forEach(function(o){oe(e,o,t[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):T(Object(t)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(t,o))})}return e}function oe(e,r,t){return(r=ie(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function ie(e){var r=ne(e,"string");return c(r)=="symbol"?r:r+""}function ne(e,r){if(c(e)!="object"||!e)return e;var t=e[Symbol.toPrimitive];if(t!==void 0){var o=t.call(e,r||"default");if(c(o)!="object")return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(e)}function ae(e,r){return me(e)||se(e,r)||ue(e,r)||le()}function le(){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 ue(e,r){if(e){if(typeof e=="string")return G(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)?G(e,r):void 0}}function G(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,n,d,u,s=[],l=!0,f=!1;try{if(d=(t=t.call(e)).next,r===0){if(Object(t)!==t)return;l=!1}else for(;!(l=(o=d.call(t)).done)&&(s.push(o.value),s.length!==r);l=!0);}catch(b){f=!0,n=b}finally{try{if(!l&&t.return!=null&&(u=t.return(),Object(u)!==u))return}finally{if(f)throw n}}return s}}function me(e){if(Array.isArray(e))return e}var Oe=function(r){var t=r.profileId,o=r.queryRef,n=r.roomId,d=r.onCancellation,u=r.onRemovalFromGroup,s=r.onValidSubmission,l=_utils.useNotification.call(void 0, ),f=l.sendToast,b=_reactrelay.usePreloadedQuery.call(void 0, _chunkUQGTFMMXjs.a,o),k=b.chatRoom,S=_chunkKIVWK2EBjs.a.call(void 0, k),N=S.avatar,B=S.title;_chunkOT6EXTQMjs.b.call(void 0, {profileId:t,connections:[],onRemoval:u});var i=_reacthookform.useForm.call(void 0, {defaultValues:_chunk5A32CO6Ijs.b.call(void 0, B||"",N),resolver:_zod.zodResolver.call(void 0, _chunk5A32CO6Ijs.c),mode:"onBlur"}),z=i.control,I=i.setValue,Q=i.watch,W=i.getFieldState,$=i.clearErrors,q=i.trigger,H=i.handleSubmit,v=i.formState,K=v.isValid,J=v.isDirty,X=v.dirtyFields,Y=_chunkXYEPI42Pjs.b.call(void 0, ),O=ae(Y,2),Z=O[0],j=O[1],ee=H(function(p){if(n){var y=_utils.filterDirtyValues.call(void 0, {values:p,dirtyFields:X}),R=p.image,A={};"image"in y&&(R?A.image=R:y.deleteImage=!0,delete y.image),Z({variables:{input:L({roomId:n,profileId:t},y),connections:[]},uploadables:A,onCompleted:function(g){var h,P=g==null||(h=g.chatRoomUpdate)===null||h===void 0?void 0:h.errors;P?(f("Something went wrong",{type:"error"}),_utils.setFormRelayErrors.call(void 0, i,P)):s()}})}}),re=function(){$(_chunk5A32CO6Ijs.a.image),I(_chunk5A32CO6Ijs.a.image,null,{shouldValidate:!0,shouldDirty:!0,shouldTouch:!0})},te=!K||!J;return _jsxruntime.jsxs.call(void 0, _material.Box,{children:[_jsxruntime.jsxs.call(void 0, _chunkOB3KKIKAjs.a,{children:[_jsxruntime.jsx.call(void 0, _buttons.IconButton,{onClick:d,"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:te,isLoading:j,onClick:function(){ee()},children:_jsxruntime.jsx.call(void 0, _icons.CheckMarkIcon,{sx:{fontSize:"24px"}})})]}),_jsxruntime.jsx.call(void 0, _chunkQ4RWV3MAjs.a,{control:z,FORM_VALUE:_chunk5A32CO6Ijs.a,handleRemoveImage:re,imageError:W(_chunk5A32CO6Ijs.a.image).error,isMutationInFlight:j,setValue:I,trigger:q,watch:Q})]})},je=function(r){var t=_authentication.useCurrentProfile.call(void 0, ),o=t.currentProfile;return o!=null&&o.id?_jsxruntime.jsx.call(void 0, Oe,L({profileId:o.id},r)):null},Ue= exports.a =je;exports.a = Ue;
//# sourceMappingURL=chunk-DN7WAWJM.js.map