"use strict";(globalThis.webpackChunk_clerk_ui=globalThis.webpackChunk_clerk_ui||[]).push([["917"],{7399:function(e,t,n){n.r(t),n.d(t,{ImpersonationFab:()=>y});var i=n(1564),o=n(8095),r=n(4180),s=n(630),a=n.n(s),l=n(9599),c=n(3264),d=n(8272),u=n(8920),p=n(78),f=n(8074),m=n(2861),h=n(1986),g=n(8691),w=n(6294),$=n(7591),b=n(9406);let v=({width:e,height:t,...n})=>{let{sx:o,...r}=n;return(0,i.Y)(d.fv,{elementDescriptor:u.$z.impersonationFabIconContainer,center:!0,sx:[n=>({width:e,height:t,backgroundColor:n.colors.$danger500,borderRadius:n.radii.$circle}),o],...r,children:(0,i.Y)(d.In,{elementDescriptor:u.$z.impersonationFabIcon,icon:w.A,sx:e=>({color:e.colors.$white}),size:"lg"})})},x=({title:e,signOutText:t})=>{let{session:n}=(0,r.wV)(),{user:o}=(0,r.Jd)(),{signOut:s}=(0,r.ho)(),{otherSessions:a}=(0,g.z)({user:o}),{navigateAfterSignOut:c,navigateAfterMultiSessionSingleSignOutUrl:p}=(0,l.g)();return(0,i.FD)(d.fv,{sx:e=>({width:"100%",paddingInlineStart:e.sizes.$4,paddingInlineEnd:e.sizes.$6,whiteSpace:"nowrap"}),children:[(0,i.Y)(d.EY,{colorScheme:"secondary",elementDescriptor:u.$z.impersonationFabTitle,variant:"buttonLarge",truncate:!0,localizationKey:e}),(0,i.Y)(d.N_,{variant:"buttonLarge",elementDescriptor:u.$z.impersonationFabActionLink,sx:e=>({alignSelf:"flex-start",color:e.colors.$primary500,":hover":{cursor:"pointer"}}),localizationKey:t,onClick:()=>0===a.length?s(c):s(p,{sessionId:n.id})})]})},S=()=>{let{session:e}=(0,r.wV)(),{t}=(0,p._)(),{parsedInternalTheme:n}=(0,f.K)(),l=(0,s.useRef)(null),c=e?.actor,g=e?.agent,w=n.sizes.$16,b="--cl-impersonation-fab-top",S="--cl-impersonation-fab-right",y=()=>{let e=l.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(S,"23px"),document.documentElement.style.setProperty(b,"109px"))},z=a().useCallback(e=>{e.stopPropagation(),e.preventDefault();let t=l.current;if(!t)return;let n=`${window.innerWidth-t.offsetLeft-t.offsetWidth-e.movementX}px`;document.documentElement.style.setProperty(S,n),document.documentElement.style.setProperty(b,`${t.offsetTop- -e.movementY}px`)},[]);if((0,s.useEffect)(()=>(window.addEventListener("resize",y),()=>{window.removeEventListener("resize",y)}),[]),!(c&&!g)||!e.user)return null;let D=(0,m.G)("impersonationFab.title",{identifier:(0,o.dS)(e.user)||(0,o.Cm)(e.user)}),E=t(D).length;return(0,i.Y)(h.Z,{children:(0,i.FD)(d.so,{ref:l,elementDescriptor:u.$z.impersonationFab,onPointerDown:()=>{window.addEventListener("pointermove",z),window.addEventListener("pointerup",()=>{window.removeEventListener("pointermove",z),y()},{once:!0})},align:"center",sx:e=>({touchAction:"none",position:"fixed",overflow:"hidden",top:`var(${b}, 109px)`,right:`var(${S}, 23px)`,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 ${e.transitionDuration.$slowest} ease, opacity ${e.transitionDuration.$slower} ease ${e.transitionDuration.$slowest}`,maxWidth:`min(calc(50vw - ${w} - 2 * 23px), ${E}ch)`,[$.g.md]:{maxWidth:`min(calc(100vw - ${w} - 2 * 23px), ${E}ch)`},opacity:1},":hover #cl-impersonationEye":{transform:"rotate(-180deg)"}}),children:[(0,i.Y)(v,{id:"cl-impersonationEye",width:w,height:w,sx:e=>({transition:`transform ${e.transitionDuration.$slowest} ease`})}),(0,i.Y)(d.so,{id:"cl-impersonationText",sx:e=>({transition:`max-width ${e.transitionDuration.$slowest} ease, opacity ${e.transitionDuration.$fast} ease`,maxWidth:"0px",opacity:0}),children:(0,i.Y)(x,{title:D,signOutText:(0,m.G)("impersonationFab.action__signOut")})})]})})},y=(0,c.G)(()=>(0,i.Y)(b.S,{children:(0,i.Y)(S,{})}))},9599:function(e,t,n){n.d(t,{g:()=>r});var i=n(4180),o=n(4964);let r=()=>{let{navigate:e}=(0,o.r)(),t=(0,i.ho)();return{navigateAfterSignOut:()=>e(t.buildAfterSignOutUrl()),navigateAfterMultiSessionSingleSignOutUrl:()=>e(t.buildAfterMultiSessionSingleSignOutUrl()),afterSignOutUrl:t.buildAfterSignOutUrl(),afterMultiSessionSingleSignOutUrl:t.buildAfterMultiSessionSingleSignOutUrl()}}}}]);