"use strict";(globalThis.webpackChunk_clerk_ui=globalThis.webpackChunk_clerk_ui||[]).push([["99"],{6240:function(e,n,r){r.r(n),r.d(n,{UserButton:()=>O});var o=r(1564),t=r(5074),i=r(3269),l=r(4373),s=r(9233),a=r(3264),d=r(4607),c=r(1577),u=r(4180),p=r(9972),h=r(1005),Y=r(9345),m=r(7697),g=r(8920),$=r(1052),f=r(2540);let k=t.forwardRef((e,n)=>{let{close:r,...t}=e,i=()=>r?.(!1),{session:l}=(0,u.wV)(),a=(0,s.Y)(),{__experimental_asStandalone:d}=a,{authConfig:c}=(0,m.O)(),{user:k}=(0,u.Jd)(),{handleAddAccountClicked:C,handleManageAccountClicked:B,handleSessionClicked:b,handleSignOutAllClicked:v,handleSignOutSessionClicked:D,handleUserProfileActionClicked:x,otherSessions:S}=(0,f.u)({...a,actionCompleteCallback:i,user:k});return(0,o.Y)(h.M,{elementDescriptor:g.$z.userButtonPopoverRootBox,children:(0,o.FD)(p.Y.Root,{elementDescriptor:g.$z.userButtonPopoverCard,ref:n,role:"dialog","aria-label":"User button popover",shouldEntryAnimate:!d,...t,children:[(0,o.FD)(p.Y.Content,{elementDescriptor:g.$z.userButtonPopoverMain,children:[(0,o.Y)(Y.c,{elementId:"userButton",user:k,sx:e=>({width:"100%",padding:`${e.space.$4} ${e.space.$5}`})}),c.singleSessionMode?(0,o.Y)($.iR,{handleManageAccountClicked:B,handleSignOutSessionClicked:D,handleUserProfileActionClicked:x,session:l,completedCallback:i}):(0,o.Y)($.pS,{session:l,otherSessions:S,handleManageAccountClicked:B,handleSignOutSessionClicked:D,handleSessionClicked:b,handleAddAccountClicked:C,handleUserProfileActionClicked:x,completedCallback:i})]}),(0,o.Y)(p.Y.Footer,{elementDescriptor:g.$z.userButtonPopoverFooter,children:!c.singleSessionMode&&S.length>0&&(0,o.Y)($.ww,{handleSignOutAllClicked:v})})]})})});var C=r(9538),B=r(1778),b=r(78),v=r(8272),D=r(2861),x=r(8095);let S=({showName:e})=>{let{user:n}=(0,u.Jd)();return n&&e?(0,o.Y)(v.EY,{variant:"subtitle",as:"span",elementDescriptor:g.$z.userButtonOuterIdentifier,sx:[e=>({paddingInlineStart:e.space.$2})],children:(0,x.dS)(n)||(0,x.Cm)(n)}):null},z=(0,B.H)((0,t.forwardRef)((e,n)=>{let{sx:r,...t}=e,{user:i}=(0,u.Jd)(),{showName:l}=(0,s.Y)(),{t:a}=(0,b._)();return(0,o.Y)(v.$n,{elementDescriptor:g.$z.userButtonTrigger,variant:"roundWrapper",sx:[e=>({borderRadius:l?e.radii.$md:e.radii.$circle,color:e.colors.$colorForeground}),r],ref:n,"aria-label":`${a(e.isOpen?(0,D.G)("userButton.action__closeUserMenu"):(0,D.G)("userButton.action__openUserMenu"))}`,"aria-expanded":e.isOpen,"aria-haspopup":"dialog",...t,children:(0,o.FD)(v.so,{elementDescriptor:g.$z.userButtonBox,isOpen:e.isOpen,align:"center",as:"span",gap:2,children:[(0,o.Y)(S,{showName:l}),(0,o.Y)(C.H,{boxElementDescriptor:g.$z.userButtonAvatarBox,imageElementDescriptor:g.$z.userButtonAvatarImage,...i,size:e=>e.sizes.$7})]})})})),A=(0,i.P4)(({children:e})=>{let{defaultOpen:n}=(0,s.Y)(),{floating:r,reference:i,styles:a,toggle:d,isOpen:u,nodeId:p,context:h}=(0,c.f)({defaultOpen:n,placement:"bottom-end",offset:8}),Y=(0,t.useId)();return(0,o.FD)(o.FK,{children:[(0,o.Y)(z,{ref:i,onClick:d,isOpen:u,"aria-controls":u?Y:void 0,"aria-expanded":u}),(0,o.Y)(l.A,{nodeId:p,context:h,isOpen:u,children:(0,t.cloneElement)(e,{id:Y,close:d,ref:r,style:a})})]})}),O=(0,a.G)((0,i.dm)(()=>{let{__experimental_asStandalone:e}=(0,s.Y)();return(0,o.Y)(d.n.Root,{flow:"userButton",sx:{display:"inline-flex"},children:e?(0,o.Y)(k,{close:"function"==typeof e?e:void 0}):(0,o.Y)(A,{children:(0,o.Y)(k,{})})})}))}}]);