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