import{a as B}from"./chunk-3BRG5XI3.mjs";import{a as E}from"./chunk-YAXVE3V7.mjs";import{a as g}from"./chunk-RRO3YLO6.mjs";import{a as k}from"./chunk-CIROWHZJ.mjs";import{a as F}from"./chunk-BU6SH46A.mjs";import{a as x}from"./chunk-YXBUSSMP.mjs";import{a as T}from"./chunk-56W43V5X.mjs";import{a as U}from"./chunk-JHNTUQIY.mjs";import{a as h}from"./chunk-SZXZJTVL.mjs";import{useEffect as le,useState as ue}from"react";import{useCurrentProfile as se}from"@baseapp-frontend/authentication";import{ClickableAvatar as fe}from"@baseapp-frontend/design-system/components/web/avatars";import{Popover as ae}from"@baseapp-frontend/design-system/components/web/popovers";import{usePopover as pe}from"@baseapp-frontend/design-system/hooks/common";import{Box as ce}from"@mui/material";import me from"@mui/material/Divider";import{jsx as u,jsxs as M,Fragment as Pe}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 K(r,e){var o=Object.keys(r);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(r);e&&(t=t.filter(function(n){return Object.getOwnPropertyDescriptor(r,n).enumerable})),o.push.apply(o,t)}return o}function p(r){for(var e=1;e<arguments.length;e++){var o=arguments[e]!=null?arguments[e]:{};e%2?K(Object(o),!0).forEach(function(t){Y(r,t,o[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(o)):K(Object(o)).forEach(function(t){Object.defineProperty(r,t,Object.getOwnPropertyDescriptor(o,t))})}return r}function Y(r,e,o){return(e=Z(e))in r?Object.defineProperty(r,e,{value:o,enumerable:!0,configurable:!0,writable:!0}):r[e]=o,r}function Z(r){var e=ee(r,"string");return c(e)=="symbol"?e:e+""}function ee(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 re(r,e){return ie(r)||ne(r,e)||te(r,e)||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 te(r,e){if(r){if(typeof r=="string")return R(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)?R(r,e):void 0}}function R(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 ne(r,e){var o=r==null?null:typeof Symbol<"u"&&r[Symbol.iterator]||r["@@iterator"];if(o!=null){var t,n,s,f,i=[],l=!0,a=!1;try{if(s=(o=o.call(r)).next,e===0){if(Object(o)!==o)return;l=!1}else for(;!(l=(t=s.call(o)).done)&&(i.push(t.value),i.length!==e);l=!0);}catch(y){a=!0,n=y}finally{try{if(!l&&o.return!=null&&(f=o.return(),Object(f)!==f))return}finally{if(a)throw n}}return i}}function ie(r){if(Array.isArray(r))return r}var de=function(e){var o,t=e.PopoverStyles,n=t===void 0?{}:t,s=e.MenuItems,f=s===void 0?k:s,i=e.MenuItemsProps,l=i===void 0?{}:i,a=e.CurrentUser,y=a===void 0?E:a,O=e.CurrentProfile,H=O===void 0?x:O,I=e.SwitchProfileMenu,N=I===void 0?U:I,C=e.SwitchProfileMenuProps,W=C===void 0?{}:C,j=e.ProfilesList,w=j===void 0?T:j,A=e.ProfilesListProps,q=A===void 0?{}:A,_=e.AddProfileMenuItem,z=_===void 0?h:_,L=e.AddProfileMenuItemProps,G=L===void 0?{}:L,$=e.LogoutItemProps,J=$===void 0?{}:$,Q=se({noSSR:!1}),v=Q.currentProfile,m=pe(),V=ue(!1),D=re(V,2),P=D[0],b=D[1],d=null,S=function(){m.onClose(),P&&(d=setTimeout(function(){b(!1)},500))};return le(function(){return function(){d&&clearTimeout(d)}},[d]),M(Pe,{children:[u(fe,{color:"secondary",src:(o=v?.image)!==null&&o!==void 0?o:"",alt:"User avatar",onClick:m.onOpen,isOpen:!!m.open}),M(ae,{open:m.open,onClose:S,sx:p(p({},F),n),children:[w&&P?u(w,p({openSubmenu:P,handleCloseSubmenu:function(){return b(!1)}},q)):u(B,{CurrentUser:y,CurrentProfile:H,SwitchProfileMenu:N,SwitchProfileMenuProps:W,MenuItems:f,MenuItemsProps:l,handlePopoverOnClose:S,setOpenProfilesList:b}),!!g&&u(me,{sx:{borderStyle:"solid"}}),M(ce,{margin:1.5,display:"flex",flexDirection:"column",gap:.5,children:[P&&!!z&&u(h,p({},G)),u(g,p({handlePopoverOnClose:S},J))]})]})]})},Le=de;export{Le as a};
//# sourceMappingURL=chunk-EHSRYW7A.mjs.map