import{r as A,j as e,a as L,u as _,b as v,l as p,D as O,e as q,f as T,R as U,F as $,g as k,h as R,H as F,i as M,k as Q,B as V,n as z,o as H,c as w,d as y,m as D,a7 as K,p as P,a8 as G,s as J,L as g}from"./main-Bn3jZxQW.js";import{B as W,L as S,p as N,D as h}from"./LastActive-CcqY2swy.js";import{E as X}from"./EndBrowserSessionButton-Dh2DNyLt.js";import{b as Y}from"./Heading-BPu-MP59.js";import{D as j,a as u,b as f,c as i,d as t,e as a,S as Z,f as ee,g as se,h as ne}from"./SessionInfo-DsrzjU_J.js";import{V as ie}from"./VisualListItem-CHylqSsW.js";import{s as te,E as ae,g as re,a as oe}from"./EndOAuth2SessionButton-BPcopEj_.js";import{I as le}from"./edit-CDDdEeO1.js";import{S as de}from"./Submit-s3yrm_WK.js";import{C as ce}from"./computer-BhmLSpYt.js";import"./_commonjsHelpers-DaWZu8wl.js";/* empty css               */import"./Separator-CmDle60m.js";function C(o,s){return e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",fill:"currentColor",viewBox:"0 0 24 24",ref:s,...o,children:e.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"})})}C.displayName="ChevronLeftIcon";const he=A.forwardRef(C),me="_header_1crjt_8",xe="_back-button_1crjt_16",I={header:me,backButton:xe},b=({children:o,...s})=>e.jsxs("header",{className:I.header,children:[e.jsx(L,{className:I.backButton,...s,children:e.jsx(he,{})}),e.jsx(Y,{children:o})]}),je=p(`
  fragment BrowserSession_detail on BrowserSession {
    id
    createdAt
    finishedAt
    ...EndBrowserSessionButton_session
    userAgent {
      name
      model
      os
    }
    lastActiveIp
    lastActiveAt
    lastAuthentication {
      id
      createdAt
    }
    user {
      id
      username
    }
  }
`),ue=({session:o,isCurrent:s})=>{const n=v(je,o),{t:r}=_();let l=r("frontend.session.generic_browser_session");return n.userAgent&&(n.userAgent.model&&n.userAgent.name?l=r("frontend.session.name_for_platform",{name:n.userAgent.name,platform:n.userAgent.model}):n.userAgent.name&&n.userAgent.os?l=r("frontend.session.name_for_platform",{name:n.userAgent.name,platform:n.userAgent.os}):n.userAgent.name&&(l=n.userAgent.name)),e.jsxs("div",{className:"flex flex-col gap-10",children:[s&&e.jsx(W,{className:"self-start",kind:"green",children:r("frontend.browser_session_details.current_badge")}),e.jsx(b,{to:"/sessions/browsers",children:l}),e.jsxs(j,{children:[e.jsx(u,{children:r("frontend.session.title")}),e.jsxs(f,{children:[n.lastActiveAt&&e.jsxs(i,{children:[e.jsx(t,{children:r("frontend.session.last_active_label")}),e.jsx(a,{children:e.jsx(S,{lastActive:N(n.lastActiveAt)})})]}),e.jsxs(i,{children:[e.jsx(t,{children:r("frontend.session.signed_in_label")}),e.jsx(a,{children:e.jsx(h,{datetime:n.createdAt})})]}),n.finishedAt&&e.jsxs(i,{children:[e.jsx(t,{children:r("frontend.session.finished_label")}),e.jsx(a,{children:e.jsx(h,{datetime:n.finishedAt})})]}),n.lastActiveIp&&e.jsxs(i,{children:[e.jsx(t,{children:r("frontend.session.ip_label")}),e.jsx(a,{children:e.jsx("code",{children:n.lastActiveIp})})]})]})]}),!n.finishedAt&&e.jsx(X,{session:n,size:"lg"})]})},fe=A.forwardRef(({label:o,...s},n)=>e.jsx(z,{label:o,children:e.jsx(H,{ref:n,type:"button",size:"var(--cpd-space-6x)",style:{marginInline:"var(--cpd-space-2x)"},...s,children:e.jsx(le,{})})})),E=({mutation:o,deviceName:s})=>{const{t:n}=_(),r=A.useRef(null),[l,c]=A.useState(!1),m=async d=>{d.preventDefault();const x=d.currentTarget,B=new FormData(x).get("name");await o.mutateAsync(B),c(!1)};return e.jsxs(O,{trigger:e.jsx(fe,{label:n("action.edit")}),open:l,onOpenChange:d=>{r.current?.form?.reset(),c(d)},children:[e.jsx(q,{children:n("frontend.session.set_device_name.title")}),e.jsx(T,{asChild:!0,children:e.jsxs(U,{onSubmit:m,children:[e.jsxs($,{name:"name",children:[e.jsx(k,{children:n("frontend.session.set_device_name.label")}),e.jsx(R,{type:"text",required:!0,defaultValue:s,ref:r}),e.jsx(F,{children:n("frontend.session.set_device_name.help")})]}),e.jsxs(de,{disabled:o.isPending,children:[o.isPending&&e.jsx(M,{inline:!0}),n("action.save")]})]})}),e.jsx(Q,{asChild:!0,children:e.jsx(V,{kind:"tertiary",children:n("action.cancel")})})]})},pe=p(`
  mutation SetCompatSessionName($sessionId: ID!, $displayName: String!) {
    setCompatSessionName(input: { compatSessionId: $sessionId, humanName: $displayName }) {
      status
    }
  }
`),Ae=p(`
  fragment CompatSession_detail on CompatSession {
    id
    createdAt
    deviceId
    finishedAt
    lastActiveIp
    lastActiveAt
    humanName

    ...EndCompatSessionButton_session

    userAgent {
      name
      os
      model
    }

    ssoLogin {
      id
      redirectUri
    }
  }
`),_e=({session:o})=>{const s=v(Ae,o),{t:n}=_(),r=w(),l=y({mutationFn:x=>D({query:pe,variables:{sessionId:s.id,displayName:x}}),onSuccess:()=>{r.invalidateQueries({queryKey:["sessionDetail",s.id]}),r.invalidateQueries({queryKey:["sessionsOverview"]})}}),c=s.userAgent?.model??(s.userAgent?.name?s.userAgent?.os?n("frontend.session.name_for_platform",{name:s.userAgent.name,platform:s.userAgent.os}):s.userAgent.name:n("frontend.session.unknown_device")),m=s.ssoLogin?.redirectUri?te(s.ssoLogin.redirectUri):s.deviceId||s.id,d=s.humanName??`${m}: ${c}`;return e.jsxs("div",{className:"flex flex-col gap-10",children:[e.jsxs(b,{to:"/sessions",children:[d,e.jsx(E,{mutation:l,deviceName:d})]}),e.jsxs(j,{children:[e.jsx(u,{children:n("frontend.session.title")}),e.jsxs(f,{children:[s.lastActiveAt&&e.jsxs(i,{children:[e.jsx(t,{children:n("frontend.session.last_active_label")}),e.jsx(a,{children:e.jsx(S,{lastActive:N(s.lastActiveAt)})})]}),e.jsxs(i,{children:[e.jsx(t,{children:n("frontend.session.signed_in_label")}),e.jsx(a,{children:e.jsx(h,{datetime:s.createdAt})})]}),s.finishedAt&&e.jsxs(i,{children:[e.jsx(t,{children:n("frontend.session.finished_label")}),e.jsx(a,{children:e.jsx(h,{datetime:s.finishedAt})})]}),e.jsxs(i,{children:[e.jsx(t,{children:n("frontend.session.device_id_label")}),e.jsx(a,{children:s.deviceId})]}),s.lastActiveIp&&e.jsxs(i,{children:[e.jsx(t,{children:n("frontend.session.ip_label")}),e.jsx(a,{children:e.jsx("code",{children:s.lastActiveIp})})]})]}),e.jsxs(i,{children:[e.jsx(t,{children:n("frontend.session.scopes_label")}),e.jsxs(ie,{className:"mt-1",children:[e.jsx(Z,{}),e.jsx(ee,{}),e.jsx(se,{})]})]})]}),e.jsxs(j,{children:[e.jsx(u,{children:n("frontend.compat_session_detail.client_details_title")}),e.jsxs(f,{children:[e.jsxs(i,{children:[e.jsx(t,{children:n("frontend.compat_session_detail.name")}),e.jsx(a,{children:c})]}),s.ssoLogin&&e.jsxs(i,{children:[e.jsx(t,{children:n("frontend.session.uri_label")}),e.jsx(a,{children:s.ssoLogin?.redirectUri})]})]})]}),!s.finishedAt&&e.jsx(ae,{session:s,size:"lg"})]})},ge=p(`
  mutation SetOAuth2SessionName($sessionId: ID!, $displayName: String!) {
    setOauth2SessionName(input: { oauth2SessionId: $sessionId, humanName: $displayName }) {
      status
    }
  }
`),ve=p(`
  fragment OAuth2Session_detail on Oauth2Session {
    id
    scope
    createdAt
    finishedAt
    lastActiveIp
    lastActiveAt
    humanName

    ...EndOAuth2SessionButton_session

    userAgent {
      name
      model
      os
    }

    client {
      id
      clientId
      clientName
      clientUri
      logoUri
    }
  }
`),Se=({session:o})=>{const s=v(ve,o),{t:n}=_(),r=w(),l=y({mutationFn:x=>D({query:ge,variables:{sessionId:s.id,displayName:x}}),onSuccess:()=>{r.invalidateQueries({queryKey:["sessionDetail",s.id]}),r.invalidateQueries({queryKey:["sessionsOverview"]})}}),c=re(s.scope),m=s.client.clientName||s.client.clientId,d=s.humanName??s.userAgent?.model??(s.userAgent?.name?s.userAgent?.os?n("frontend.session.name_for_platform",{name:s.userAgent.name,platform:s.userAgent.os}):s.userAgent.name:n("frontend.session.unknown_device"));return e.jsxs("div",{className:"flex flex-col gap-10",children:[e.jsxs(b,{to:"/sessions",children:[m,": ",d,e.jsx(E,{mutation:l,deviceName:d})]}),e.jsxs(j,{children:[e.jsx(u,{children:n("frontend.session.title")}),e.jsxs(f,{children:[s.lastActiveAt&&e.jsxs(i,{children:[e.jsx(t,{children:n("frontend.session.last_active_label")}),e.jsx(a,{children:e.jsx(S,{lastActive:N(s.lastActiveAt)})})]}),e.jsxs(i,{children:[e.jsx(t,{children:n("frontend.session.signed_in_label")}),e.jsx(a,{children:e.jsx(h,{datetime:s.createdAt})})]}),s.finishedAt&&e.jsxs(i,{children:[e.jsx(t,{children:n("frontend.session.finished_label")}),e.jsx(a,{children:e.jsx(h,{datetime:s.finishedAt})})]}),e.jsxs(i,{children:[e.jsx(t,{children:n("frontend.session.device_id_label")}),e.jsx(a,{children:c})]}),s.lastActiveIp&&e.jsxs(i,{children:[e.jsx(t,{children:n("frontend.session.ip_label")}),e.jsx(a,{children:e.jsx("code",{children:s.lastActiveIp})})]})]}),e.jsxs(i,{children:[e.jsx(t,{children:n("frontend.session.scopes_label")}),e.jsx(ne,{scope:s.scope})]})]}),e.jsxs(j,{children:[e.jsx(u,{children:n("frontend.oauth2_session_detail.client_title")}),e.jsxs(f,{children:[e.jsxs(i,{children:[e.jsx(t,{children:n("frontend.oauth2_session_detail.client_details_name")}),e.jsxs(a,{children:[e.jsx(ce,{name:s.client.clientName||s.client.clientId,logoUri:s.client.logoUri||void 0,size:"var(--cpd-space-4x)"}),s.client.clientName]})]}),e.jsxs(i,{children:[e.jsx(t,{children:n("frontend.session.client_id_label")}),e.jsx(a,{children:e.jsx("code",{children:s.client.clientId})})]}),e.jsxs(i,{children:[e.jsx(t,{children:n("frontend.session.uri_label")}),e.jsx(a,{children:e.jsx("a",{target:"_blank",rel:"noreferrer",href:s.client.clientUri||void 0,children:s.client.clientUri})})]})]})]}),!s.finishedAt&&e.jsx(oe,{session:s,size:"lg"})]})};function $e(){const{id:o}=K.useParams(),{data:{node:s,viewerSession:n}}=P(G(o));if(!s)throw J();switch(s.__typename){case"CompatSession":return e.jsx(g,{wide:!0,children:e.jsx(_e,{session:s})});case"Oauth2Session":return e.jsx(g,{wide:!0,children:e.jsx(Se,{session:s})});case"BrowserSession":return e.jsx(g,{wide:!0,children:e.jsx(ue,{session:s,isCurrent:s.id===n.id})});default:throw new Error("Unknown session type")}}export{$e as component};
//# sourceMappingURL=sessions._id-M_gJdvjD.js.map
