"use strict";(globalThis.webpackChunk_clerk_ui=globalThis.webpackChunk_clerk_ui||[]).push([["99"],{66240:function(e,n,o){o.r(n),o.d(n,{UserButton:()=>O});var r=o(61564),t=o(35074),i=o(63269),l=o(74373),s=o(39233),a=o(43264),c=o(44607),d=o(11577),u=o(90231),p=o(67591),h=o(31005),Y=o(29345),m=o(97697),g=o(58920),f=o(61052),k=o(2540);let C=t.forwardRef((e,n)=>{let{close:o,...t}=e,i=()=>null==o?void 0:o(!1),{session:l}=(0,u.wV)(),a=(0,s.Y)(),{__experimental_asStandalone:c}=a,{authConfig:d}=(0,m.O)(),{user:C}=(0,u.Jd)(),{handleAddAccountClicked:B,handleManageAccountClicked:$,handleSessionClicked:b,handleSignOutAllClicked:v,handleSignOutSessionClicked:D,handleUserProfileActionClicked:x,otherSessions:S}=(0,k.u)({...a,actionCompleteCallback:i,user:C});return(0,r.Y)(h.M,{elementDescriptor:g.$z.userButtonPopoverRootBox,children:(0,r.FD)(p.Y.Root,{elementDescriptor:g.$z.userButtonPopoverCard,ref:n,role:"dialog","aria-label":"User button popover",shouldEntryAnimate:!c,...t,children:[(0,r.FD)(p.Y.Content,{elementDescriptor:g.$z.userButtonPopoverMain,children:[(0,r.Y)(Y.c,{elementId:"userButton",user:C,sx:e=>({width:"100%",padding:"".concat(e.space.$4," ").concat(e.space.$5)})}),d.singleSessionMode?(0,r.Y)(f.iR,{handleManageAccountClicked:$,handleSignOutSessionClicked:D,handleUserProfileActionClicked:x,session:l,completedCallback:i}):(0,r.Y)(f.pS,{session:l,otherSessions:S,handleManageAccountClicked:$,handleSignOutSessionClicked:D,handleSessionClicked:b,handleAddAccountClicked:B,handleUserProfileActionClicked:x,completedCallback:i})]}),(0,r.Y)(p.Y.Footer,{elementDescriptor:g.$z.userButtonPopoverFooter,children:!d.singleSessionMode&&S.length>0&&(0,r.Y)(f.ww,{handleSignOutAllClicked:v})})]})})});var B=o(99538),$=o(31778),b=o(10078),v=o(18272),D=o(22861),x=o(8095);let S=e=>{let{showName:n}=e,{user:o}=(0,u.Jd)();return o&&n?(0,r.Y)(v.EY,{variant:"subtitle",as:"span",elementDescriptor:g.$z.userButtonOuterIdentifier,sx:[e=>({paddingInlineStart:e.space.$2})],children:(0,x.dS)(o)||(0,x.Cm)(o)}):null},z=(0,$.H)((0,t.forwardRef)((e,n)=>{let{sx:o,...t}=e,{user:i}=(0,u.Jd)(),{showName:l}=(0,s.Y)(),{t:a}=(0,b._)();return(0,r.Y)(v.$n,{elementDescriptor:g.$z.userButtonTrigger,variant:"roundWrapper",sx:[e=>({borderRadius:l?e.radii.$md:e.radii.$circle,color:e.colors.$colorForeground}),o],ref:n,"aria-label":"".concat(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,r.FD)(v.so,{elementDescriptor:g.$z.userButtonBox,isOpen:e.isOpen,align:"center",as:"span",gap:2,children:[(0,r.Y)(S,{showName:l}),(0,r.Y)(B.H,{boxElementDescriptor:g.$z.userButtonAvatarBox,imageElementDescriptor:g.$z.userButtonAvatarImage,...i,size:e=>e.sizes.$7})]})})})),A=(0,i.P4)(e=>{let{children:n}=e,{defaultOpen:o}=(0,s.Y)(),{floating:i,reference:a,styles:c,toggle:u,isOpen:p,nodeId:h,context:Y}=(0,d.f)({defaultOpen:o,placement:"bottom-end",offset:8}),m=(0,t.useId)();return(0,r.FD)(r.FK,{children:[(0,r.Y)(z,{ref:a,onClick:u,isOpen:p,"aria-controls":p?m:void 0,"aria-expanded":p}),(0,r.Y)(l.A,{nodeId:h,context:Y,isOpen:p,children:(0,t.cloneElement)(n,{id:m,close:u,ref:i,style:c})})]})}),O=(0,a.G)((0,i.dm)(()=>{let{__experimental_asStandalone:e}=(0,s.Y)();return(0,r.Y)(c.n.Root,{flow:"userButton",sx:{display:"inline-flex"},children:e?(0,r.Y)(C,{close:"function"==typeof e?e:void 0}):(0,r.Y)(A,{children:(0,r.Y)(C,{})})})}))}}]);