"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 _chunk6KAB7IRCjs = require('./chunk-6KAB7IRC.js');var _chunkVRDITBGOjs = require('./chunk-VRDITBGO.js');var _chunkPFTS3ZKLjs = require('./chunk-PFTS3ZKL.js');var _chunkSXDU5O3Ljs = require('./chunk-SXDU5O3L.js');var _chunkVYNCIM3Gjs = require('./chunk-VYNCIM3G.js');var _chunk62TMIDT4js = require('./chunk-62TMIDT4.js');var _chunkMBKDZBVUjs = require('./chunk-MBKDZBVU.js');var _chunk6H7YCGHOjs = require('./chunk-6H7YCGHO.js');var _react = require('react');var _displays = require('@baseapp-frontend/design-system/components/web/displays');var _inputs = require('@baseapp-frontend/design-system/components/web/inputs');var _material = require('@mui/material');var _reacthookform = require('react-hook-form');var _reactvirtuoso = require('react-virtuoso');var _jsxruntime = require('react/jsx-runtime');function b(e){"@babel/helpers - typeof";return b=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},b(e)}function ee(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter(function(u){return Object.getOwnPropertyDescriptor(e,u).enumerable})),r.push.apply(r,o)}return r}function T(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?ee(Object(r),!0).forEach(function(o){je(e,o,r[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ee(Object(r)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(r,o))})}return e}function je(e,t,r){return(t=Le(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Le(e){var t=xe(e,"string");return b(t)=="symbol"?t:t+""}function xe(e,t){if(b(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var o=r.call(e,t||"default");if(b(o)!="object")return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function C(e,t){return we(e)||Ie(e,t)||Ae(e,t)||Oe()}function Oe(){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 Ae(e,t){if(e){if(typeof e=="string")return te(e,t);var r={}.toString.call(e).slice(8,-1);return r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set"?Array.from(e):r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?te(e,t):void 0}}function te(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,o=Array(t);r<t;r++)o[r]=e[r];return o}function Ie(e,t){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var o,u,f,h,d=[],m=!0,p=!1;try{if(f=(r=r.call(e)).next,t===0){if(Object(r)!==r)return;m=!1}else for(;!(m=(o=f.call(r)).done)&&(d.push(o.value),d.length!==t);m=!0);}catch(g){p=!0,u=g}finally{try{if(!m&&r.return!=null&&(h=r.return(),Object(h)!==h))return}finally{if(p)throw u}}return d}}function we(e){if(Array.isArray(e))return e}var He=function(t){var r,o,u=t.targetRef,f=t.Searchbar,h=f===void 0?_inputs.Searchbar:f,d=t.SearchbarProps,m=d===void 0?{}:d,p=t.ChatRoomItem,g=p===void 0?_chunkVRDITBGOjs.a:p,O=t.ChatRoomItemProps,A=O===void 0?{}:O,I=t.EmptyChatRoomsState,ne=I===void 0?_chunk6KAB7IRCjs.a:I,w=t.VirtuosoProps,ae=w===void 0?{}:w,ie=_react.useState.call(void 0, _chunkPFTS3ZKLjs.a.active),E=C(ie,2),v=E[0],se=E[1],ue=_react.useState.call(void 0, !0),$=C(ue,2),le=$[0],k=$[1],ce=_react.useTransition.call(void 0, ),N=C(ce,2),de=N[0],me=N[1],y=_chunk62TMIDT4js.b.call(void 0, u==null||(r=u.me)===null||r===void 0?void 0:r.profile),l=y.data,fe=y.loadNext,he=y.isLoadingNext,pe=y.hasNext,R=y.refetch,ve=_react.useTransition.call(void 0, ),D=C(ve,2),V=D[0],B=D[1],P=_reacthookform.useForm.call(void 0, {defaultValues:{search:""}}),ye=P.control,be=P.reset,ge=P.watch,S=v===_chunkPFTS3ZKLjs.a.archived,M=v===_chunkPFTS3ZKLjs.a.unread,F=ge("search"),Se=function(a){var c=a.target.value||"";B(function(){R({q:c,unreadMessages:M,archived:S},{fetchPolicy:"network-only"})})},Ce=function(){B(function(){be(),R({q:"",unreadMessages:M,archived:S},{fetchPolicy:"network-only"})})},Re=function(a,c){se(c),me(function(){k(!1),R({q:F,unreadMessages:c===_chunkPFTS3ZKLjs.a.unread,archived:c===_chunkPFTS3ZKLjs.a.archived},{fetchPolicy:"network-only"})})};_react.useEffect.call(void 0, function(){k(!0)},[l]);var q=_chunkMBKDZBVUjs.a.call(void 0, ),H=q.id,U=q.setChatRoom,W=_react.useMemo.call(void 0, function(){var n;return(l==null||(n=l.chatRooms)===null||n===void 0||(n=n.edges)===null||n===void 0?void 0:n.filter(function(a){return _optionalChain([a, 'optionalAccess', _2 => _2.node])}).map(function(a){return _optionalChain([a, 'optionalAccess', _3 => _3.node])}))||[]},[l==null||(o=l.chatRooms)===null||o===void 0?void 0:o.edges]);_chunkVYNCIM3Gjs.b.call(void 0, {profileId:l.id,connections:[]});var Pe=_react.useCallback.call(void 0, function(n){return n?_jsxruntime.jsx.call(void 0, g,T({roomRef:n,isCardSelected:H===n.id,handleClick:function(){U({id:n.id})},isInArchivedTab:S},A)):null},[H,U,A,g,S]),_e=function(){return he?_jsxruntime.jsx.call(void 0, _displays.LoadingState,{sx:{paddingTop:3,paddingBottom:1},CircularProgressProps:{size:15},"aria-label":"loading more rooms"}):_jsxruntime.jsx.call(void 0, _material.Box,{sx:{paddingTop:3}})},_=function(a){return _jsxruntime.jsxs.call(void 0, _material.Box,{display:"grid",gap:1,gridTemplateColumns:"1fr min-content",alignItems:"center",children:[_jsxruntime.jsx.call(void 0, _material.Typography,{variant:"subtitle2",color:"text.primary",children:_chunkPFTS3ZKLjs.b[a]}),de&&v===a&&_jsxruntime.jsx.call(void 0, _material.CircularProgress,{size:15})]})},Te=function(){var a=!V&&W.length===0;if(a)return F?_jsxruntime.jsx.call(void 0, _chunk6H7YCGHOjs.a,{}):_jsxruntime.jsx.call(void 0, ne,{})};return _jsxruntime.jsxs.call(void 0, _chunkSXDU5O3Ljs.a,{children:[_jsxruntime.jsx.call(void 0, _material.Box,{sx:{paddingX:{xs:1.5,sm:2.5},paddingTop:2},children:_jsxruntime.jsx.call(void 0, h,T({name:"search",control:ye,onChange:Se,onClear:Ce,isPending:V},m),v)}),_jsxruntime.jsxs.call(void 0, _material.Tabs,{value:v,onChange:Re,centered:!0,variant:"fullWidth",sx:{paddingX:{xs:0,sm:2.5},paddingTop:2},children:[_jsxruntime.jsx.call(void 0, _material.Tab,{label:_(_chunkPFTS3ZKLjs.a.active),value:_chunkPFTS3ZKLjs.a.active}),_jsxruntime.jsx.call(void 0, _material.Tab,{label:_(_chunkPFTS3ZKLjs.a.unread),value:_chunkPFTS3ZKLjs.a.unread}),_jsxruntime.jsx.call(void 0, _material.Tab,{label:_(_chunkPFTS3ZKLjs.a.archived),value:_chunkPFTS3ZKLjs.a.archived})]}),Te(),le&&_jsxruntime.jsx.call(void 0, _reactvirtuoso.Virtuoso,T({data:W,overscan:1,itemContent:function(a,c){return Pe(c)},style:{scrollbarWidth:"none"},components:{Footer:_e},endReached:function(){pe&&fe(5)}},ae))]})},ot= exports.a =He;exports.a = ot;
//# sourceMappingURL=chunk-FYOKGMMV.js.map