import{n as e}from"./rolldown-runtime-Bh1tDfsg.js";import{a as t,i as n,l as r,s as i,t as a}from"./graphql-w47gyQE9.js";import{n as o,t as s}from"./LoadingSpinner-0XRXvdGq.js";import{n as c,t as l}from"./jsx-runtime-BHz_hoGM.js";import{n as u}from"./not-found-i5RsCZif.js";import{t as d}from"./link-RG1Klsig.js";import{t as f}from"./useTranslation-CWZfA4RN.js";import{t as p}from"./Button-CfjN5AeH.js";import{n as m}from"./close-C3FZSJFY.js";import{i as h,n as g,r as _,t as v}from"./LastActive-jC1gM3cS.js";import{t as y}from"./Heading-fQbpz6tX.js";import{n as b}from"./VisualListItem-CwwXB3Zo.js";import{A as x,D as S,L as C,R as ee,X as w,b as T,h as E,m as D,y as te}from"./main-CqHK_FoX.js";import{n as ne}from"./computer-DIo7Ad43.js";import{t as O}from"./EndBrowserSessionButton-B-g1OryL.js";import{i as k,n as A,r as j,t as M}from"./EndOAuth2SessionButton-uV-hRH4G.js";import{t as N}from"./edit-peBclVB2.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-Bqu6Tebr.js";var W=e(c(),1),G=l();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)(d,{className:J.backButton,...t,children:(0,G.jsx)(q,{})}),(0,G.jsx)(y,{children:e})]}),X=n(`
  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:n})=>{let r=t(X,e),{t:i}=f(),a=i(`frontend.session.generic_browser_session`);return r.userAgent&&(r.userAgent.model&&r.userAgent.name?a=i(`frontend.session.name_for_platform`,{name:r.userAgent.name,platform:r.userAgent.model}):r.userAgent.name&&r.userAgent.os?a=i(`frontend.session.name_for_platform`,{name:r.userAgent.name,platform:r.userAgent.os}):r.userAgent.name&&(a=r.userAgent.name)),(0,G.jsxs)(`div`,{className:`flex flex-col gap-10`,children:[n&&(0,G.jsx)(h,{className:`self-start`,kind:`green`,children:i(`frontend.browser_session_details.current_badge`)}),(0,G.jsx)(Y,{to:`/sessions/browsers`,children:a}),(0,G.jsxs)(I,{children:[(0,G.jsx)(P,{children:i(`frontend.session.title`)}),(0,G.jsxs)(B,{children:[r.lastActiveAt&&(0,G.jsxs)(H,{children:[(0,G.jsx)(R,{children:i(`frontend.session.last_active_label`)}),(0,G.jsx)(z,{children:(0,G.jsx)(v,{lastActive:_(r.lastActiveAt)})})]}),(0,G.jsxs)(H,{children:[(0,G.jsx)(R,{children:i(`frontend.session.signed_in_label`)}),(0,G.jsx)(z,{children:(0,G.jsx)(g,{datetime:r.createdAt})})]}),r.finishedAt&&(0,G.jsxs)(H,{children:[(0,G.jsx)(R,{children:i(`frontend.session.finished_label`)}),(0,G.jsx)(z,{children:(0,G.jsx)(g,{datetime:r.finishedAt})})]}),r.lastActiveIp&&(0,G.jsxs)(H,{children:[(0,G.jsx)(R,{children:i(`frontend.session.ip_label`)}),(0,G.jsx)(z,{children:(0,G.jsx)(`code`,{children:r.lastActiveIp})})]})]})]}),!r.finishedAt&&(0,G.jsx)(O,{session:r,size:`lg`})]})},re=(0,W.forwardRef)(({label:e,...t},n)=>(0,G.jsx)(m,{label:e,children:(0,G.jsx)(w,{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}=f(),r=(0,W.useRef)(null),[i,a]=(0,W.useState)(!1);return(0,G.jsxs)(te,{trigger:(0,G.jsx)(re,{label:n(`action.edit`)}),open:i,onOpenChange:e=>{r.current?.form?.reset(),a(e)},children:[(0,G.jsx)(T,{children:n(`frontend.session.set_device_name.title`)}),(0,G.jsx)(ee,{asChild:!0,children:(0,G.jsxs)(x.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)(x.Field,{name:`name`,children:[(0,G.jsx)(x.Label,{children:n(`frontend.session.set_device_name.label`)}),(0,G.jsx)(x.TextControl,{type:`text`,required:!0,defaultValue:t,ref:r}),(0,G.jsx)(x.HelpMessage,{children:n(`frontend.session.set_device_name.help`)})]}),(0,G.jsxs)(x.Submit,{disabled:e.isPending,children:[e.isPending&&(0,G.jsx)(s,{inline:!0}),n(`action.save`)]})]})}),(0,G.jsx)(C,{asChild:!0,children:(0,G.jsx)(p,{kind:`tertiary`,children:n(`action.cancel`)})})]})},ie=n(`
  mutation SetCompatSessionName($sessionId: ID!, $displayName: String!) {
    setCompatSessionName(input: { compatSessionId: $sessionId, humanName: $displayName }) {
      status
    }
  }
`),ae=n(`
  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 n=t(ae,e),{t:i}=f(),s=r(),c=o({mutationFn:e=>a({query:ie,variables:{sessionId:n.id,displayName:e}}),onSuccess:()=>{s.invalidateQueries({queryKey:[`sessionDetail`,n.id]}),s.invalidateQueries({queryKey:[`sessionsOverview`]})}}),l=n.userAgent?.model??(n.userAgent?.name?n.userAgent?.os?i(`frontend.session.name_for_platform`,{name:n.userAgent.name,platform:n.userAgent.os}):n.userAgent.name:i(`frontend.session.unknown_device`)),u=n.ssoLogin?.redirectUri?k(n.ssoLogin.redirectUri):n.deviceId||n.id,d=n.humanName??`${u}: ${l}`;return(0,G.jsxs)(`div`,{className:`flex flex-col gap-10`,children:[(0,G.jsxs)(Y,{to:`/sessions`,children:[d,(0,G.jsx)(Q,{mutation:c,deviceName:d})]}),(0,G.jsxs)(I,{children:[(0,G.jsx)(P,{children:i(`frontend.session.title`)}),(0,G.jsxs)(B,{children:[n.lastActiveAt&&(0,G.jsxs)(H,{children:[(0,G.jsx)(R,{children:i(`frontend.session.last_active_label`)}),(0,G.jsx)(z,{children:(0,G.jsx)(v,{lastActive:_(n.lastActiveAt)})})]}),(0,G.jsxs)(H,{children:[(0,G.jsx)(R,{children:i(`frontend.session.signed_in_label`)}),(0,G.jsx)(z,{children:(0,G.jsx)(g,{datetime:n.createdAt})})]}),n.finishedAt&&(0,G.jsxs)(H,{children:[(0,G.jsx)(R,{children:i(`frontend.session.finished_label`)}),(0,G.jsx)(z,{children:(0,G.jsx)(g,{datetime:n.finishedAt})})]}),(0,G.jsxs)(H,{children:[(0,G.jsx)(R,{children:i(`frontend.session.device_id_label`)}),(0,G.jsx)(z,{children:n.deviceId})]}),n.lastActiveIp&&(0,G.jsxs)(H,{children:[(0,G.jsx)(R,{children:i(`frontend.session.ip_label`)}),(0,G.jsx)(z,{children:(0,G.jsx)(`code`,{children:n.lastActiveIp})})]})]}),(0,G.jsxs)(H,{children:[(0,G.jsx)(R,{children:i(`frontend.session.scopes_label`)}),(0,G.jsxs)(b,{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:i(`frontend.compat_session_detail.client_details_title`)}),(0,G.jsxs)(B,{children:[(0,G.jsxs)(H,{children:[(0,G.jsx)(R,{children:i(`frontend.compat_session_detail.name`)}),(0,G.jsx)(z,{children:l})]}),n.ssoLogin&&(0,G.jsxs)(H,{children:[(0,G.jsx)(R,{children:i(`frontend.session.uri_label`)}),(0,G.jsx)(z,{children:n.ssoLogin?.redirectUri})]})]})]}),!n.finishedAt&&(0,G.jsx)(j,{session:n,size:`lg`})]})},se=n(`
  mutation SetOAuth2SessionName($sessionId: ID!, $displayName: String!) {
    setOauth2SessionName(input: { oauth2SessionId: $sessionId, humanName: $displayName }) {
      status
    }
  }
`),ce=n(`
  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 n=t(ce,e),{t:i}=f(),s=r(),c=o({mutationFn:e=>a({query:se,variables:{sessionId:n.id,displayName:e}}),onSuccess:()=>{s.invalidateQueries({queryKey:[`sessionDetail`,n.id]}),s.invalidateQueries({queryKey:[`sessionsOverview`]})}}),l=A(n.scope),u=n.client.clientName||n.client.clientId,d=n.humanName??n.userAgent?.model??(n.userAgent?.name?n.userAgent?.os?i(`frontend.session.name_for_platform`,{name:n.userAgent.name,platform:n.userAgent.os}):n.userAgent.name:i(`frontend.session.unknown_device`));return(0,G.jsxs)(`div`,{className:`flex flex-col gap-10`,children:[(0,G.jsxs)(Y,{to:`/sessions`,children:[u,`: `,d,(0,G.jsx)(Q,{mutation:c,deviceName:d})]}),(0,G.jsxs)(I,{children:[(0,G.jsx)(P,{children:i(`frontend.session.title`)}),(0,G.jsxs)(B,{children:[n.lastActiveAt&&(0,G.jsxs)(H,{children:[(0,G.jsx)(R,{children:i(`frontend.session.last_active_label`)}),(0,G.jsx)(z,{children:(0,G.jsx)(v,{lastActive:_(n.lastActiveAt)})})]}),(0,G.jsxs)(H,{children:[(0,G.jsx)(R,{children:i(`frontend.session.signed_in_label`)}),(0,G.jsx)(z,{children:(0,G.jsx)(g,{datetime:n.createdAt})})]}),n.finishedAt&&(0,G.jsxs)(H,{children:[(0,G.jsx)(R,{children:i(`frontend.session.finished_label`)}),(0,G.jsx)(z,{children:(0,G.jsx)(g,{datetime:n.finishedAt})})]}),(0,G.jsxs)(H,{children:[(0,G.jsx)(R,{children:i(`frontend.session.device_id_label`)}),(0,G.jsx)(z,{children:l})]}),n.lastActiveIp&&(0,G.jsxs)(H,{children:[(0,G.jsx)(R,{children:i(`frontend.session.ip_label`)}),(0,G.jsx)(z,{children:(0,G.jsx)(`code`,{children:n.lastActiveIp})})]})]}),(0,G.jsxs)(H,{children:[(0,G.jsx)(R,{children:i(`frontend.session.scopes_label`)}),(0,G.jsx)(V,{scope:n.scope})]})]}),(0,G.jsxs)(I,{children:[(0,G.jsx)(P,{children:i(`frontend.oauth2_session_detail.client_title`)}),(0,G.jsxs)(B,{children:[(0,G.jsxs)(H,{children:[(0,G.jsx)(R,{children:i(`frontend.oauth2_session_detail.client_details_name`)}),(0,G.jsxs)(z,{children:[(0,G.jsx)(ne,{name:n.client.clientName||n.client.clientId,logoUri:n.client.logoUri||void 0,size:`var(--cpd-space-4x)`}),n.client.clientName]})]}),(0,G.jsxs)(H,{children:[(0,G.jsx)(R,{children:i(`frontend.session.client_id_label`)}),(0,G.jsx)(z,{children:(0,G.jsx)(`code`,{children:n.client.clientId})})]}),(0,G.jsxs)(H,{children:[(0,G.jsx)(R,{children:i(`frontend.session.uri_label`)}),(0,G.jsx)(z,{children:(0,G.jsx)(`a`,{target:`_blank`,rel:`noreferrer`,href:n.client.clientUri||void 0,children:n.client.clientUri})})]})]})]}),!n.finishedAt&&(0,G.jsx)(M,{session:n,size:`lg`})]})};function $(){let{id:e}=D.useParams(),{data:{node:t,viewerSession:n}}=i(E(e));if(!t)throw u();switch(t.__typename){case`CompatSession`:return(0,G.jsx)(S,{wide:!0,children:(0,G.jsx)(oe,{session:t})});case`Oauth2Session`:return(0,G.jsx)(S,{wide:!0,children:(0,G.jsx)(le,{session:t})});case`BrowserSession`:return(0,G.jsx)(S,{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-FkvRNn9T.js.map