"use strict";(globalThis.webpackChunk_clerk_ui=globalThis.webpackChunk_clerk_ui||[]).push([["99"],{3597(e,n,r){r.r(n),r.d(n,{UserButton:()=>w});var o=r(9763),t=r(630),i=r.n(t),l=r(7308),s=r(5113),a=r(3592),d=r(9203),c=r(1522),u=r(2484),p=r(2959),h=r(8316),Y=r(9094),m=r(5682),g=r(1868),$=r(6447),k=r(3623),C=r(7847);let f=i().forwardRef((e,n)=>{let{close:r,...t}=e,i=()=>r?.(!1),{session:l}=(0,p.wV)(),s=(0,a.Y)(),{__experimental_asStandalone:d}=s,{authConfig:c}=(0,g.O)(),{user:u}=(0,p.Jd)(),{handleAddAccountClicked:f,handleManageAccountClicked:B,handleSessionClicked:b,handleSignOutAllClicked:v,handleSignOutSessionClicked:D,handleUserProfileActionClicked:x,otherSessions:S}=(0,C.u)({...s,actionCompleteCallback:i,user:u});return(0,o.Y)(Y.M,{elementDescriptor:$.$z.userButtonPopoverRootBox,children:(0,o.FD)(h.Y.Root,{elementDescriptor:$.$z.userButtonPopoverCard,ref:n,role:"dialog","aria-label":"User button popover",shouldEntryAnimate:!d,...t,children:[(0,o.FD)(h.Y.Content,{elementDescriptor:$.$z.userButtonPopoverMain,children:[(0,o.Y)(m.c,{elementId:"userButton",user:u,sx:e=>({width:"100%",padding:`${e.space.$4} ${e.space.$5}`})}),c.singleSessionMode?(0,o.Y)(k.iR,{handleManageAccountClicked:B,handleSignOutSessionClicked:D,handleUserProfileActionClicked:x,session:l,completedCallback:i}):(0,o.Y)(k.pS,{session:l,otherSessions:S,handleManageAccountClicked:B,handleSignOutSessionClicked:D,handleSessionClicked:b,handleAddAccountClicked:f,handleUserProfileActionClicked:x,completedCallback:i})]}),(0,o.Y)(h.Y.Footer,{elementDescriptor:$.$z.userButtonPopoverFooter,children:!c.singleSessionMode&&S.length>0&&(0,o.Y)(k.ww,{handleSignOutAllClicked:v})})]})})});var B=r(2983),b=r(7353),v=r(4722),D=r(2597),x=r(8342),S=r(3974);let z=({showName:e})=>{let{user:n}=(0,p.Jd)();return n&&e?(0,o.Y)(D.EY,{variant:"subtitle",as:"span",elementDescriptor:$.$z.userButtonOuterIdentifier,sx:[e=>({paddingInlineStart:e.space.$2})],children:(0,S.dS)(n)||(0,S.Cm)(n)}):null},A=(0,b.H)((0,t.forwardRef)((e,n)=>{let{sx:r,...t}=e,{user:i}=(0,p.Jd)(),{showName:l}=(0,a.Y)(),{t:s}=(0,v._)();return(0,o.Y)(D.$n,{elementDescriptor:$.$z.userButtonTrigger,variant:"roundWrapper",sx:[e=>({borderRadius:l?e.radii.$md:e.radii.$circle,color:e.colors.$colorForeground}),r],ref:n,"aria-label":`${s(e.isOpen?(0,x.G)("userButton.action__closeUserMenu"):(0,x.G)("userButton.action__openUserMenu"))}`,"aria-expanded":e.isOpen,"aria-haspopup":"dialog",...t,children:(0,o.FD)(D.so,{elementDescriptor:$.$z.userButtonBox,isOpen:e.isOpen,align:"center",as:"span",gap:2,children:[(0,o.Y)(z,{showName:l}),(0,o.Y)(B.H,{boxElementDescriptor:$.$z.userButtonAvatarBox,imageElementDescriptor:$.$z.userButtonAvatarImage,...i,size:e=>e.sizes.$7})]})})})),O=(0,l.P4)(({children:e})=>{let{defaultOpen:n}=(0,a.Y)(),{floating:r,reference:i,styles:l,toggle:d,isOpen:c,nodeId:p,context:h}=(0,u.f)({defaultOpen:n,placement:"bottom-end",offset:8}),Y=(0,t.useId)();return(0,o.FD)(o.FK,{children:[(0,o.Y)(A,{ref:i,onClick:d,isOpen:c,"aria-controls":c?Y:void 0,"aria-expanded":c}),(0,o.Y)(s.A,{nodeId:p,context:h,isOpen:c,children:(0,t.cloneElement)(e,{id:Y,close:d,ref:r,style:l})})]})}),w=(0,d.G)((0,l.dm)(()=>{let{__experimental_asStandalone:e}=(0,a.Y)();return(0,o.Y)(c.n.Root,{flow:"userButton",sx:{display:"inline-flex"},children:e?(0,o.Y)(f,{close:"function"==typeof e?e:void 0}):(0,o.Y)(O,{children:(0,o.Y)(f,{})})})}))}}]);