import{a as q}from"./chunk-YAXVE3V7.mjs";import{a as z}from"./chunk-CIROWHZJ.mjs";import{a as O}from"./chunk-MHJ23L5Q.mjs";import{a as B}from"./chunk-BU6SH46A.mjs";import{a as N}from"./chunk-73ETP77I.mjs";import{a as W}from"./chunk-JHNTUQIY.mjs";import{a as R}from"./chunk-SZXZJTVL.mjs";import{a as H}from"./chunk-SXU3PXPJ.mjs";import{useEffect as ae,useState as ce}from"react";import{useCurrentProfile as pe}from"@baseapp-frontend/authentication";import{ClickableAvatar as me}from"@baseapp-frontend/design-system/components/web/avatars";import{Popover as Pe}from"@baseapp-frontend/design-system/components/web/popovers";import{usePopover as de}from"@baseapp-frontend/design-system/hooks/common";import Q from"@mui/material/Divider";import{jsx as n,Fragment as M,jsxs as S}from"react/jsx-runtime";function c(r){"@babel/helpers - typeof";return c=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},c(r)}function G(r,e){var o=Object.keys(r);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(r);e&&(t=t.filter(function(l){return Object.getOwnPropertyDescriptor(r,l).enumerable})),o.push.apply(o,t)}return o}function i(r){for(var e=1;e<arguments.length;e++){var o=arguments[e]!=null?arguments[e]:{};e%2?G(Object(o),!0).forEach(function(t){oe(r,t,o[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(o)):G(Object(o)).forEach(function(t){Object.defineProperty(r,t,Object.getOwnPropertyDescriptor(o,t))})}return r}function oe(r,e,o){return(e=te(e))in r?Object.defineProperty(r,e,{value:o,enumerable:!0,configurable:!0,writable:!0}):r[e]=o,r}function te(r){var e=ne(r,"string");return c(e)=="symbol"?e:e+""}function ne(r,e){if(c(r)!="object"||!r)return r;var o=r[Symbol.toPrimitive];if(o!==void 0){var t=o.call(r,e||"default");if(c(t)!="object")return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(r)}function ie(r,e){return fe(r)||se(r,e)||ue(r,e)||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(r,e){if(r){if(typeof r=="string")return J(r,e);var o={}.toString.call(r).slice(8,-1);return o==="Object"&&r.constructor&&(o=r.constructor.name),o==="Map"||o==="Set"?Array.from(r):o==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o)?J(r,e):void 0}}function J(r,e){(e==null||e>r.length)&&(e=r.length);for(var o=0,t=Array(e);o<e;o++)t[o]=r[o];return t}function se(r,e){var o=r==null?null:typeof Symbol<"u"&&r[Symbol.iterator]||r["@@iterator"];if(o!=null){var t,l,p,f,a=[],u=!0,s=!1;try{if(p=(o=o.call(r)).next,e===0){if(Object(o)!==o)return;u=!1}else for(;!(u=(t=p.call(o)).done)&&(a.push(t.value),a.length!==e);u=!0);}catch(m){s=!0,l=m}finally{try{if(!u&&o.return!=null&&(f=o.return(),Object(f)!==f))return}finally{if(s)throw l}}return a}}function fe(r){if(Array.isArray(r))return r}var ve=function(e){var o,t,l=e.PopoverStyles,p=l===void 0?{}:l,f=e.MenuItems,a=f===void 0?z:f,u=e.MenuItemsProps,s=u===void 0?{}:u,m=e.CurrentUser,C=m===void 0?q:m,j=e.CurrentProfile,w=j===void 0?H:j,A=e.SwitchProfileMenu,h=A===void 0?W:A,_=e.SwitchProfileMenuProps,V=_===void 0?{}:_,L=e.ProfilesList,$=L===void 0?N:L,D=e.ProfilesListProps,X=D===void 0?{}:D,x=e.AddProfileMenuItem,T=x===void 0?R:x,U=e.AddProfileMenuItemProps,Y=U===void 0?{}:U,E=e.LogoutItemProps,Z=E===void 0?{}:E,ee=pe({noSSR:!1}),P=ee.currentProfile,d=de(),re=ce(!1),k=ie(re,2),v=k[0],g=k[1],y=null,I=function(){d.onClose(),v&&(y=setTimeout(function(){g(!1)},500))};ae(function(){return function(){y&&clearTimeout(y)}},[y]);var b=!!w&&!!P,F=!b&&!!C;return S(M,{children:[n(me,{color:"secondary",src:(o=P?.image)!==null&&o!==void 0?o:"",alt:"User avatar",onClick:d.onOpen,isOpen:!!d.open}),S(Pe,{open:d.open,onClose:I,sx:i(i({},B),p),children:[$&&v?n($,i({openSubmenu:v,handleCloseSubmenu:function(){return g(!1)}},X)):S(M,{children:[b&&n(w,{}),F&&n(C,{}),b&&!!h&&n(h,i({openProfilesList:function(){return g(!0)}},V)),!!a&&!!(s!=null&&(t=s.menuItems)!==null&&t!==void 0&&t.length)&&S(M,{children:[!!(b||F||h)&&n(Q,{sx:{borderStyle:"solid"}}),n(a,i({handlePopoverOnClose:I},s))]})]}),!!O&&n(Q,{sx:{borderStyle:"solid"}}),n(O,i(i({handlePopoverOnClose:I},Z),{},{children:v&&!!T&&n(T,i({},Y))}))]})]})},_e=ve;export{_e as a};
//# sourceMappingURL=chunk-FHVFO3HY.mjs.map