import{a as M}from"./chunk-BCDOL5MA.mjs";import{a as I}from"./chunk-OLBTMLJ6.mjs";import{a as P}from"./chunk-PJQWPBLU.mjs";import{a as N,b as _}from"./chunk-SG5QMJHR.mjs";import{a as w}from"./chunk-VNTMNFVS.mjs";import{a as j}from"./chunk-X535DCK5.mjs";import{Suspense as Z,useMemo as X}from"react";import{useCurrentProfile as $}from"@baseapp-frontend/authentication";import{ChevronIcon as ee}from"@baseapp-frontend/design-system/components/web/icons";import{useNotification as te}from"@baseapp-frontend/utils";import{Box as c,ButtonBase as ne,Divider as re,Slide as oe}from"@mui/material";import{useLazyLoadQuery as ie,usePaginationFragment as ae}from"react-relay";import{Virtuoso as ue}from"react-virtuoso";import{jsx as i,jsxs as E}from"react/jsx-runtime";function m(t){"@babel/helpers - typeof";return m=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},m(t)}function k(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);e&&(o=o.filter(function(l){return Object.getOwnPropertyDescriptor(t,l).enumerable})),n.push.apply(n,o)}return n}function S(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?k(Object(n),!0).forEach(function(o){J(t,o,n[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):k(Object(n)).forEach(function(o){Object.defineProperty(t,o,Object.getOwnPropertyDescriptor(n,o))})}return t}function J(t,e,n){return(e=U(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function U(t){var e=Y(t,"string");return m(e)=="symbol"?e:e+""}function Y(t,e){if(m(t)!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var o=n.call(t,e||"default");if(m(o)!="object")return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var le=function(e){var n,o=e.handleCloseSubmenu,l=e.MenuItemProps,v=e.LoadingStateProps,L=v===void 0?{}:v,x=e.listMaxHeight,g=x===void 0?300:x,H={count:10},D=ie(w,H,{fetchPolicy:"store-and-network"}),F=D.me,R=te(),T=R.sendToast,C=$(),y=C.currentProfile,z=C.setCurrentProfile,B=function(r){if(y?.id!==r.id){var u,d,f,h,G=(u=process.env.NEXT_PUBLIC_API_BASE_URL)===null||u===void 0?void 0:u.replace("/v1",""),O=null;r.image&&(O=r.image.url.startsWith("http")?r.image.url:"".concat(G).concat(r.image.url)),z({id:r.id,name:(d=r.name)!==null&&d!==void 0?d:null,image:O,urlPath:(f=(h=r.urlPath)===null||h===void 0?void 0:h.path)!==null&&f!==void 0?f:null}),T("Switched to ".concat(r.name)),o()}},p=ae(j,F),s=p.data,Q=p.loadNext,V=p.isLoadingNext,A=p.hasNext,b=X(function(){var a;return(s==null||(a=s.profiles)===null||a===void 0?void 0:a.edges.filter(function(r){return r?.node}).map(function(r){return r?.node}))||[]},[s==null||(n=s.profiles)===null||n===void 0?void 0:n.edges]),K=function(){return V?i(P,S({sx:{paddingTop:3},CircularProgressProps:{size:15}},L)):i(c,{sx:{paddingTop:3}})},W=function(r,u){return r?i(M,S({profileRef:r,onProfileChange:B},l),"profile-".concat(u)):null},q=function(){if(b.length===0)return i(I,{});var r=b.length*56>g?g:b.length*56;return i(c,{sx:{backgroundColor:"common.white"},children:i(ue,{data:b,style:{height:"auto",minHeight:r},itemContent:function(d,f){return W(f,d)},components:{Footer:K},endReached:function(){A&&Q(10)}})})};return i(c,{children:i(N,{disablePadding:!0,maxHeight:g,"aria-label":"List of available profiles",children:q()})})},se=function(e){var n=e.openSubmenu,o=e.handleCloseSubmenu,l=e.cancelLabel,v=l===void 0?"Cancel":l;return i(oe,{direction:n?"left":"right",in:n,mountOnEnter:!0,unmountOnExit:!0,children:E(c,{children:[i(c,{sx:{p:1},children:E(_,{tabIndex:0,component:ne,onClick:function(){return o()},children:[i(ee,{position:"left",color:"action"}),v]})}),i(re,{sx:{borderStyle:"solid"}}),i(c,{sx:{p:1},children:i(Z,{fallback:i(P,{}),children:i(le,S({},e))})})]})})},xe=se;export{xe as a};
//# sourceMappingURL=chunk-56W43V5X.mjs.map