"use strict";(globalThis.webpackChunk_clerk_ui=globalThis.webpackChunk_clerk_ui||[]).push([["917"],{3014(e,t,i){i.r(t),i.d(t,{ImpersonationFab:()=>S});var n=i(9763),o=i(3974),r=i(2959),s=i(9701),a=i(9832),l=i(9203),d=i(2597),c=i(6447),u=i(4722),p=i(9735),m=i(8342),f=i(4883),h=i(4672),g=i(6069),w=i(4260),$=i(4629);let b=({width:e,height:t,...i})=>{let{sx:o,...r}=i;return(0,n.Y)(d.fv,{elementDescriptor:c.$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:c.$z.impersonationFabIcon,icon:g.A,sx:e=>({color:e.colors.$white}),size:"lg"})})},v=({title:e,signOutText:t})=>{let{session:i}=(0,r.wV)(),{user:o}=(0,r.Jd)(),{signOut:s}=(0,r.ho)(),{otherSessions:l}=(0,h.z)({user:o}),{navigateAfterSignOut:u,navigateAfterMultiSessionSingleSignOutUrl:p}=(0,a.g)();return(0,n.FD)(d.fv,{sx:e=>({width:"100%",paddingInlineStart:e.sizes.$4,paddingInlineEnd:e.sizes.$6,whiteSpace:"nowrap"}),children:[(0,n.Y)(d.EY,{colorScheme:"secondary",elementDescriptor:c.$z.impersonationFabTitle,variant:"buttonLarge",truncate:!0,localizationKey:e}),(0,n.Y)(d.N_,{variant:"buttonLarge",elementDescriptor:c.$z.impersonationFabActionLink,sx:e=>({alignSelf:"flex-start",color:e.colors.$primary500,":hover":{cursor:"pointer"}}),localizationKey:t,onClick:()=>0===l.length?s(u):s(p,{sessionId:i.id})})]})},x=()=>{let{session:e}=(0,r.wV)(),{t}=(0,u._)(),{parsedInternalTheme:i}=(0,p.K)(),a=(0,s.useRef)(null),l=e?.actor,h=e?.agent,g=i.sizes.$16,$="--cl-impersonation-fab-top",x="--cl-impersonation-fab-right",S=()=>{let e=a.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(x,"23px"),document.documentElement.style.setProperty($,"109px"))},y=s.useCallback(e=>{e.stopPropagation(),e.preventDefault();let t=a.current;if(!t)return;let i=`${window.innerWidth-t.offsetLeft-t.offsetWidth-e.movementX}px`;document.documentElement.style.setProperty(x,i),document.documentElement.style.setProperty($,`${t.offsetTop- -e.movementY}px`)},[]);if((0,s.useEffect)(()=>(window.addEventListener("resize",S),()=>{window.removeEventListener("resize",S)}),[]),!(l&&!h)||!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)(f.Z,{children:(0,n.FD)(d.so,{ref:a,elementDescriptor:c.$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(${$}, 109px)`,right:`var(${x}, 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)`,[w.g.md]:{maxWidth:`min(calc(100vw - ${g} - 2 * 23px), ${D}ch)`},opacity:1},":hover #cl-impersonationEye":{transform:"rotate(-180deg)"}}),children:[(0,n.Y)(b,{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)(v,{title:z,signOutText:(0,m.G)("impersonationFab.action__signOut")})})]})})},S=(0,l.G)(()=>(0,n.Y)($.S,{children:(0,n.Y)(x,{})}))},9832(e,t,i){i.d(t,{g:()=>r});var n=i(2959),o=i(8029);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()}}}}]);