"use strict";(globalThis.webpackChunk_clerk_ui=globalThis.webpackChunk_clerk_ui||[]).push([["917"],{37399:function(e,t,n){n.r(t),n.d(t,{ImpersonationFab:()=>$}),n(19161),n(89305);var o=n(14518),i=n(8095),r=n(54775),a=n(35074),s=n(49599),c=n(43264),l=n(18272),d=n(58920),u=n(10078),p=n(67725),f=n(22861),m=n(81986),h=n(38691),g=n(6294),w=n(37591),v=n(29406);let b=e=>{let{width:t,height:n,...i}=e,{sx:r,...a}=i;return(0,o.Y)(l.fv,{elementDescriptor:d.$z.impersonationFabIconContainer,center:!0,sx:[e=>({width:t,height:n,backgroundColor:e.colors.$danger500,borderRadius:e.radii.$circle}),r],...a,children:(0,o.Y)(l.In,{elementDescriptor:d.$z.impersonationFabIcon,icon:g.A,sx:e=>({color:e.colors.$white}),size:"lg"})})},x=e=>{let{title:t,signOutText:n}=e,{session:i}=(0,r.wV)(),{user:a}=(0,r.Jd)(),{signOut:c}=(0,r.ho)(),{otherSessions:u}=(0,h.z)({user:a}),{navigateAfterSignOut:p,navigateAfterMultiSessionSingleSignOutUrl:f}=(0,s.g)();return(0,o.FD)(l.fv,{sx:e=>({width:"100%",paddingLeft:e.sizes.$4,paddingRight:e.sizes.$6,whiteSpace:"nowrap"}),children:[(0,o.Y)(l.EY,{colorScheme:"secondary",elementDescriptor:d.$z.impersonationFabTitle,variant:"buttonLarge",truncate:!0,localizationKey:t}),(0,o.Y)(l.N_,{variant:"buttonLarge",elementDescriptor:d.$z.impersonationFabActionLink,sx:e=>({alignSelf:"flex-start",color:e.colors.$primary500,":hover":{cursor:"pointer"}}),localizationKey:n,onClick:()=>0===u.length?c(p):c(f,{sessionId:i.id})})]})},S=()=>{let{session:e}=(0,r.wV)(),{t}=(0,u._)(),{parsedInternalTheme:n}=(0,p.K)(),s=(0,a.useRef)(null),c=null==e?void 0:e.actor,h=n.sizes.$16,g="--cl-impersonation-fab-top",v="--cl-impersonation-fab-right",S=()=>{let e=s.current;if(!e)return;let t=window.innerWidth-e.offsetLeft-e.offsetWidth,n=window.innerHeight-e.offsetTop-e.offsetHeight;[e.offsetLeft,t,e.offsetTop,n].some(e=>e<0)&&(document.documentElement.style.setProperty(v,"".concat(23,"px")),document.documentElement.style.setProperty(g,"".concat(109,"px")))},$=a.useCallback(e=>{e.stopPropagation(),e.preventDefault();let t=s.current;if(!t)return;let n="".concat(window.innerWidth-t.offsetLeft-t.offsetWidth-e.movementX,"px");document.documentElement.style.setProperty(v,n),document.documentElement.style.setProperty(g,"".concat(t.offsetTop- -e.movementY,"px"))},[]);if((0,a.useEffect)(()=>(window.addEventListener("resize",S),()=>{window.removeEventListener("resize",S)}),[]),!c||!e.user)return null;let y=(0,f.G)("impersonationFab.title",{identifier:(0,i.dS)(e.user)||(0,i.Cm)(e.user)}),z=t(y).length;return(0,o.Y)(m.Z,{children:(0,o.FD)(l.so,{ref:s,elementDescriptor:d.$z.impersonationFab,onPointerDown:()=>{window.addEventListener("pointermove",$),window.addEventListener("pointerup",()=>{window.removeEventListener("pointermove",$),S()},{once:!0})},align:"center",sx:e=>({touchAction:"none",position:"fixed",overflow:"hidden",top:"var(".concat(g,", ").concat(109,"px)"),right:"var(".concat(v,", ").concat(23,"px)"),zIndex:e.zIndices.$fab,boxShadow:e.shadows.$fabShadow,borderRadius:e.radii.$halfHeight,backgroundColor:e.colors.$white,fontFamily:e.fonts.$main,":hover":{cursor:"grab"},":hover #cl-impersonationText":{transition:"max-width ".concat(e.transitionDuration.$slowest," ease, opacity ").concat(e.transitionDuration.$slower," ease ").concat(e.transitionDuration.$slowest),maxWidth:"min(calc(50vw - ".concat(h," - 2 * ").concat(23,"px), ").concat(z,"ch)"),[w.g.md]:{maxWidth:"min(calc(100vw - ".concat(h," - 2 * ").concat(23,"px), ").concat(z,"ch)")},opacity:1},":hover #cl-impersonationEye":{transform:"rotate(-180deg)"}}),children:[(0,o.Y)(b,{id:"cl-impersonationEye",width:h,height:h,sx:e=>({transition:"transform ".concat(e.transitionDuration.$slowest," ease")})}),(0,o.Y)(l.so,{id:"cl-impersonationText",sx:e=>({transition:"max-width ".concat(e.transitionDuration.$slowest," ease, opacity ").concat(e.transitionDuration.$fast," ease"),maxWidth:"0px",opacity:0}),children:(0,o.Y)(x,{title:y,signOutText:(0,f.G)("impersonationFab.action__signOut")})})]})})},$=(0,c.G)(()=>(0,o.Y)(v.S,{children:(0,o.Y)(S,{})}))},49599:function(e,t,n){n.d(t,{g:()=>r});var o=n(54775),i=n(4964);let r=()=>{let{navigate:e}=(0,i.r)(),t=(0,o.ho)();return{navigateAfterSignOut:()=>e(t.buildAfterSignOutUrl()),navigateAfterMultiSessionSingleSignOutUrl:()=>e(t.buildAfterMultiSessionSingleSignOutUrl()),afterSignOutUrl:t.buildAfterSignOutUrl(),afterMultiSessionSingleSignOutUrl:t.buildAfterMultiSessionSingleSignOutUrl()}}}}]);