import{n as e}from"./chunk-Bh1tDfsg.js";import{i as t,n,r,t as i}from"./LastActive-DmnP-QeR.js";import{t as a}from"./Heading-B3YO_p87.js";import{n as o}from"./VisualListItem-DRPpOUh4.js";import{A as s,At as c,D as l,Dt as u,Et as d,M as f,Mt as p,O as m,P as h,Q as g,W as _,Z as v,b as y,ft as b,h as x,jt as S,k as C,kt as ee,m as w,mt as T,pt as E,y as D,yt as te}from"./main-ChC-SNZa.js";import{n as ne}from"./computer-BCuRsBkK.js";import{t as O}from"./EndBrowserSessionButton-l-4WagCS.js";import{i as k,n as A,r as j,t as M}from"./EndOAuth2SessionButton-CyXBjTJw.js";import{t as N}from"./edit-COFX0spr.js";import{a as P,c as F,i as I,l as L,n as R,o as z,r as B,s as V,t as H,u as U}from"./SessionInfo-DBWH0iCC.js";var W=e(p(),1),G=S();function K(e,t){return(0,G.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`1em`,height:`1em`,fill:`currentColor`,viewBox:`0 0 24 24`,ref:t,...e,children:(0,G.jsx)(`path`,{d:`m13.3 17.3-4.6-4.6a.9.9 0 0 1-.213-.325A1.1 1.1 0 0 1 8.425 12q0-.2.062-.375A.9.9 0 0 1 8.7 11.3l4.6-4.6a.95.95 0 0 1 .7-.275q.425 0 .7.275a.95.95 0 0 1 .275.7.95.95 0 0 1-.275.7L10.8 12l3.9 3.9a.95.95 0 0 1 .275.7.95.95 0 0 1-.275.7.95.95 0 0 1-.7.275.95.95 0 0 1-.7-.275`})})}K.displayName=`ChevronLeftIcon`;var q=(0,W.forwardRef)(K),J={header:`_header_1crjt_8`,backButton:`_back-button_1crjt_16`},Y=({children:e,...t})=>(0,G.jsxs)(`header`,{className:J.header,children:[(0,G.jsx)(te,{className:J.backButton,...t,children:(0,G.jsx)(q,{})}),(0,G.jsx)(a,{children:e})]}),X=s(`
  fragment BrowserSession_detail on BrowserSession {
    id
    createdAt
    finishedAt
    ...EndBrowserSessionButton_session
    userAgent {
      name
      model
      os
    }
    lastActiveIp
    lastActiveAt
    lastAuthentication {
      id
      createdAt
    }
    user {
      id
      username
    }
  }
`),Z=({session:e,isCurrent:a})=>{let o=f(X,e),{t:s}=h(),c=s(`frontend.session.generic_browser_session`);return o.userAgent&&(o.userAgent.model&&o.userAgent.name?c=s(`frontend.session.name_for_platform`,{name:o.userAgent.name,platform:o.userAgent.model}):o.userAgent.name&&o.userAgent.os?c=s(`frontend.session.name_for_platform`,{name:o.userAgent.name,platform:o.userAgent.os}):o.userAgent.name&&(c=o.userAgent.name)),(0,G.jsxs)(`div`,{className:`flex flex-col gap-10`,children:[a&&(0,G.jsx)(t,{className:`self-start`,kind:`green`,children:s(`frontend.browser_session_details.current_badge`)}),(0,G.jsx)(Y,{to:`/sessions/browsers`,children:c}),(0,G.jsxs)(I,{children:[(0,G.jsx)(P,{children:s(`frontend.session.title`)}),(0,G.jsxs)(B,{children:[o.lastActiveAt&&(0,G.jsxs)(H,{children:[(0,G.jsx)(R,{children:s(`frontend.session.last_active_label`)}),(0,G.jsx)(z,{children:(0,G.jsx)(i,{lastActive:r(o.lastActiveAt)})})]}),(0,G.jsxs)(H,{children:[(0,G.jsx)(R,{children:s(`frontend.session.signed_in_label`)}),(0,G.jsx)(z,{children:(0,G.jsx)(n,{datetime:o.createdAt})})]}),o.finishedAt&&(0,G.jsxs)(H,{children:[(0,G.jsx)(R,{children:s(`frontend.session.finished_label`)}),(0,G.jsx)(z,{children:(0,G.jsx)(n,{datetime:o.finishedAt})})]}),o.lastActiveIp&&(0,G.jsxs)(H,{children:[(0,G.jsx)(R,{children:s(`frontend.session.ip_label`)}),(0,G.jsx)(z,{children:(0,G.jsx)(`code`,{children:o.lastActiveIp})})]})]})]}),!o.finishedAt&&(0,G.jsx)(O,{session:o,size:`lg`})]})},re=(0,W.forwardRef)(({label:e,...t},n)=>(0,G.jsx)(E,{label:e,children:(0,G.jsx)(b,{ref:n,type:`button`,size:`var(--cpd-space-6x)`,style:{marginInline:`var(--cpd-space-2x)`},...t,children:(0,G.jsx)(N,{})})})),Q=({mutation:e,deviceName:t})=>{let{t:n}=h(),r=(0,W.useRef)(null),[i,a]=(0,W.useState)(!1);return(0,G.jsxs)(D,{trigger:(0,G.jsx)(re,{label:n(`action.edit`)}),open:i,onOpenChange:e=>{r.current?.form?.reset(),a(e)},children:[(0,G.jsx)(y,{children:n(`frontend.session.set_device_name.title`)}),(0,G.jsx)(g,{asChild:!0,children:(0,G.jsxs)(_.Root,{onSubmit:async t=>{t.preventDefault();let n=t.currentTarget,r=new FormData(n).get(`name`);await e.mutateAsync(r),a(!1)},children:[(0,G.jsxs)(_.Field,{name:`name`,children:[(0,G.jsx)(_.Label,{children:n(`frontend.session.set_device_name.label`)}),(0,G.jsx)(_.TextControl,{type:`text`,required:!0,defaultValue:t,ref:r}),(0,G.jsx)(_.HelpMessage,{children:n(`frontend.session.set_device_name.help`)})]}),(0,G.jsxs)(_.Submit,{disabled:e.isPending,children:[e.isPending&&(0,G.jsx)(l,{inline:!0}),n(`action.save`)]})]})}),(0,G.jsx)(v,{asChild:!0,children:(0,G.jsx)(T,{kind:`tertiary`,children:n(`action.cancel`)})})]})},ie=s(`
  mutation SetCompatSessionName($sessionId: ID!, $displayName: String!) {
    setCompatSessionName(input: { compatSessionId: $sessionId, humanName: $displayName }) {
      status
    }
  }
`),ae=s(`
  fragment CompatSession_detail on CompatSession {
    id
    createdAt
    deviceId
    finishedAt
    lastActiveIp
    lastActiveAt
    humanName

    ...EndCompatSessionButton_session

    userAgent {
      name
      os
      model
    }

    ssoLogin {
      id
      redirectUri
    }
  }
`),oe=({session:e})=>{let t=f(ae,e),{t:a}=h(),s=c(),l=u({mutationFn:e=>C({query:ie,variables:{sessionId:t.id,displayName:e}}),onSuccess:()=>{s.invalidateQueries({queryKey:[`sessionDetail`,t.id]}),s.invalidateQueries({queryKey:[`sessionsOverview`]})}}),d=t.userAgent?.model??(t.userAgent?.name?t.userAgent?.os?a(`frontend.session.name_for_platform`,{name:t.userAgent.name,platform:t.userAgent.os}):t.userAgent.name:a(`frontend.session.unknown_device`)),p=t.ssoLogin?.redirectUri?k(t.ssoLogin.redirectUri):t.deviceId||t.id,m=t.humanName??`${p}: ${d}`;return(0,G.jsxs)(`div`,{className:`flex flex-col gap-10`,children:[(0,G.jsxs)(Y,{to:`/sessions`,children:[m,(0,G.jsx)(Q,{mutation:l,deviceName:m})]}),(0,G.jsxs)(I,{children:[(0,G.jsx)(P,{children:a(`frontend.session.title`)}),(0,G.jsxs)(B,{children:[t.lastActiveAt&&(0,G.jsxs)(H,{children:[(0,G.jsx)(R,{children:a(`frontend.session.last_active_label`)}),(0,G.jsx)(z,{children:(0,G.jsx)(i,{lastActive:r(t.lastActiveAt)})})]}),(0,G.jsxs)(H,{children:[(0,G.jsx)(R,{children:a(`frontend.session.signed_in_label`)}),(0,G.jsx)(z,{children:(0,G.jsx)(n,{datetime:t.createdAt})})]}),t.finishedAt&&(0,G.jsxs)(H,{children:[(0,G.jsx)(R,{children:a(`frontend.session.finished_label`)}),(0,G.jsx)(z,{children:(0,G.jsx)(n,{datetime:t.finishedAt})})]}),(0,G.jsxs)(H,{children:[(0,G.jsx)(R,{children:a(`frontend.session.device_id_label`)}),(0,G.jsx)(z,{children:t.deviceId})]}),t.lastActiveIp&&(0,G.jsxs)(H,{children:[(0,G.jsx)(R,{children:a(`frontend.session.ip_label`)}),(0,G.jsx)(z,{children:(0,G.jsx)(`code`,{children:t.lastActiveIp})})]})]}),(0,G.jsxs)(H,{children:[(0,G.jsx)(R,{children:a(`frontend.session.scopes_label`)}),(0,G.jsxs)(o,{className:`mt-1`,children:[(0,G.jsx)(U,{}),(0,G.jsx)(L,{}),(0,G.jsx)(F,{})]})]})]}),(0,G.jsxs)(I,{children:[(0,G.jsx)(P,{children:a(`frontend.compat_session_detail.client_details_title`)}),(0,G.jsxs)(B,{children:[(0,G.jsxs)(H,{children:[(0,G.jsx)(R,{children:a(`frontend.compat_session_detail.name`)}),(0,G.jsx)(z,{children:d})]}),t.ssoLogin&&(0,G.jsxs)(H,{children:[(0,G.jsx)(R,{children:a(`frontend.session.uri_label`)}),(0,G.jsx)(z,{children:t.ssoLogin?.redirectUri})]})]})]}),!t.finishedAt&&(0,G.jsx)(j,{session:t,size:`lg`})]})},se=s(`
  mutation SetOAuth2SessionName($sessionId: ID!, $displayName: String!) {
    setOauth2SessionName(input: { oauth2SessionId: $sessionId, humanName: $displayName }) {
      status
    }
  }
`),ce=s(`
  fragment OAuth2Session_detail on Oauth2Session {
    id
    scope
    createdAt
    finishedAt
    lastActiveIp
    lastActiveAt
    humanName

    ...EndOAuth2SessionButton_session

    userAgent {
      name
      model
      os
    }

    client {
      id
      clientId
      clientName
      clientUri
      logoUri
    }
  }
`),le=({session:e})=>{let t=f(ce,e),{t:a}=h(),o=c(),s=u({mutationFn:e=>C({query:se,variables:{sessionId:t.id,displayName:e}}),onSuccess:()=>{o.invalidateQueries({queryKey:[`sessionDetail`,t.id]}),o.invalidateQueries({queryKey:[`sessionsOverview`]})}}),l=A(t.scope),d=t.client.clientName||t.client.clientId,p=t.humanName??t.userAgent?.model??(t.userAgent?.name?t.userAgent?.os?a(`frontend.session.name_for_platform`,{name:t.userAgent.name,platform:t.userAgent.os}):t.userAgent.name:a(`frontend.session.unknown_device`));return(0,G.jsxs)(`div`,{className:`flex flex-col gap-10`,children:[(0,G.jsxs)(Y,{to:`/sessions`,children:[d,`: `,p,(0,G.jsx)(Q,{mutation:s,deviceName:p})]}),(0,G.jsxs)(I,{children:[(0,G.jsx)(P,{children:a(`frontend.session.title`)}),(0,G.jsxs)(B,{children:[t.lastActiveAt&&(0,G.jsxs)(H,{children:[(0,G.jsx)(R,{children:a(`frontend.session.last_active_label`)}),(0,G.jsx)(z,{children:(0,G.jsx)(i,{lastActive:r(t.lastActiveAt)})})]}),(0,G.jsxs)(H,{children:[(0,G.jsx)(R,{children:a(`frontend.session.signed_in_label`)}),(0,G.jsx)(z,{children:(0,G.jsx)(n,{datetime:t.createdAt})})]}),t.finishedAt&&(0,G.jsxs)(H,{children:[(0,G.jsx)(R,{children:a(`frontend.session.finished_label`)}),(0,G.jsx)(z,{children:(0,G.jsx)(n,{datetime:t.finishedAt})})]}),(0,G.jsxs)(H,{children:[(0,G.jsx)(R,{children:a(`frontend.session.device_id_label`)}),(0,G.jsx)(z,{children:l})]}),t.lastActiveIp&&(0,G.jsxs)(H,{children:[(0,G.jsx)(R,{children:a(`frontend.session.ip_label`)}),(0,G.jsx)(z,{children:(0,G.jsx)(`code`,{children:t.lastActiveIp})})]})]}),(0,G.jsxs)(H,{children:[(0,G.jsx)(R,{children:a(`frontend.session.scopes_label`)}),(0,G.jsx)(V,{scope:t.scope})]})]}),(0,G.jsxs)(I,{children:[(0,G.jsx)(P,{children:a(`frontend.oauth2_session_detail.client_title`)}),(0,G.jsxs)(B,{children:[(0,G.jsxs)(H,{children:[(0,G.jsx)(R,{children:a(`frontend.oauth2_session_detail.client_details_name`)}),(0,G.jsxs)(z,{children:[(0,G.jsx)(ne,{name:t.client.clientName||t.client.clientId,logoUri:t.client.logoUri||void 0,size:`var(--cpd-space-4x)`}),t.client.clientName]})]}),(0,G.jsxs)(H,{children:[(0,G.jsx)(R,{children:a(`frontend.session.client_id_label`)}),(0,G.jsx)(z,{children:(0,G.jsx)(`code`,{children:t.client.clientId})})]}),(0,G.jsxs)(H,{children:[(0,G.jsx)(R,{children:a(`frontend.session.uri_label`)}),(0,G.jsx)(z,{children:(0,G.jsx)(`a`,{target:`_blank`,rel:`noreferrer`,href:t.client.clientUri||void 0,children:t.client.clientUri})})]})]})]}),!t.finishedAt&&(0,G.jsx)(M,{session:t,size:`lg`})]})};function $(){let{id:e}=w.useParams(),{data:{node:t,viewerSession:n}}=ee(x(e));if(!t)throw d();switch(t.__typename){case`CompatSession`:return(0,G.jsx)(m,{wide:!0,children:(0,G.jsx)(oe,{session:t})});case`Oauth2Session`:return(0,G.jsx)(m,{wide:!0,children:(0,G.jsx)(le,{session:t})});case`BrowserSession`:return(0,G.jsx)(m,{wide:!0,children:(0,G.jsx)(Z,{session:t,isCurrent:t.id===n.id})});default:throw Error(`Unknown session type`)}}export{$ as component};
//# sourceMappingURL=sessions._id-D29Q__Li.js.map