import{a as e,i as t,s as n}from"./graphql-BME5mLgf.js";import"./LoadingSpinner-BR8GsFxa.js";import{t as r}from"./jsx-runtime-C3uB2UIS.js";import"./useStore-BnK_t0Uy.js";import{n as i}from"./not-found-D2Q6nITs.js";import"./link-DiTuM_g9.js";import{t as a}from"./useTranslation-DVVidJl_.js";import{n as o,r as s,t as c}from"./LastActive-c7Jpp_WC.js";import"./Dialog-B7h_fmap.js";import{r as l,t as u}from"./Heading-CuKRj857.js";import{i as d}from"./pagination-CJI_sjZ6.js";import{E as f,a as p,o as m,s as h}from"./main-BpPO1zAy.js";import{t as g}from"./Separator-DAu78SgA.js";import"./Separator-C1w3hBbl.js";import{t as _}from"./ButtonLink-BlaAAQga.js";import"./computer-BRLj38pU.js";import{c as v,d as y,f as b,i as x,l as S,o as C,s as w,u as T}from"./EndBrowserSessionButton-CfUO0PtZ.js";import{i as E,n as D,t as O}from"./Filter-CpEITKHx.js";import{i as k,n as A,r as j,t as M}from"./EndOAuth2SessionButton-m20JHBOy.js";import{t as N}from"./Link-B21-Pc6j2.js";var P=r(),F=t(`
  fragment CompatSession_session on CompatSession {
    id
    createdAt
    deviceId
    finishedAt
    lastActiveIp
    lastActiveAt
    humanName
    ...EndCompatSessionButton_session
    userAgent {
      name
      os
      model
      deviceType
    }
    ssoLogin {
      id
      redirectUri
    }
  }
`),I=({session:t})=>{let{t:n}=a(),r=e(F,t),i=r.humanName??(r.ssoLogin?.redirectUri?k(r.ssoLogin.redirectUri):void 0),l=r.userAgent?.deviceType??`UNKNOWN`,u=r.userAgent?.model??(r.userAgent?.name?r.userAgent?.os?n(`frontend.session.name_for_platform`,{name:r.userAgent.name,platform:r.userAgent.os}):r.userAgent.name:n(`frontend.session.unknown_device`)),d=s(r.createdAt),f=r.lastActiveAt?s(r.lastActiveAt):void 0;return(0,P.jsxs)(b,{children:[(0,P.jsxs)(S,{to:`/sessions/$id`,params:{id:r.id},disabled:!!r.finishedAt,children:[(0,P.jsxs)(w,{type:l,children:[(0,P.jsx)(y,{name:u}),i&&(0,P.jsx)(C,{name:i,logoUri:E(r.userAgent?.name??void 0)})]}),(0,P.jsxs)(T,{children:[f&&(0,P.jsx)(v,{label:n(`frontend.session.last_active_label`),children:(0,P.jsx)(c,{lastActive:f})}),(0,P.jsx)(v,{label:n(`frontend.session.signed_in_label`),children:(0,P.jsx)(o,{datetime:d})}),(0,P.jsx)(v,{label:n(`frontend.session.device_id_label`),children:r.deviceId})]})]}),!r.finishedAt&&(0,P.jsx)(x,{children:(0,P.jsx)(j,{session:r,size:`sm`})})]})},L=t(`
  fragment OAuth2Session_session on Oauth2Session {
    id
    scope
    createdAt
    finishedAt
    lastActiveIp
    lastActiveAt
    humanName

    ...EndOAuth2SessionButton_session

    userAgent {
      name
      model
      os
      deviceType
    }

    client {
      id
      clientId
      clientName
      applicationType
      logoUri
    }
  }
`),R=e=>e===`WEB`?`PC`:e===`NATIVE`?`MOBILE`:`UNKNOWN`,z=({session:t})=>{let{t:n}=a(),r=e(L,t),i=A(r.scope),l=s(r.createdAt),u=r.lastActiveAt?s(r.lastActiveAt):void 0,d=(r.userAgent?.deviceType===`UNKNOWN`?null:r.userAgent?.deviceType)??R(r.client.applicationType),f=r.client.clientName||r.client.clientId,p=r.humanName??r.userAgent?.model??(r.userAgent?.name?r.userAgent?.os?n(`frontend.session.name_for_platform`,{name:r.userAgent.name,platform:r.userAgent.os}):r.userAgent.name:n(`frontend.session.unknown_device`));return(0,P.jsxs)(b,{children:[(0,P.jsxs)(S,{to:`/sessions/$id`,params:{id:r.id},disabled:!!r.finishedAt,children:[(0,P.jsxs)(w,{type:d,children:[(0,P.jsx)(y,{name:p}),(0,P.jsx)(C,{name:f,logoUri:r.client.logoUri??void 0})]}),(0,P.jsxs)(T,{children:[u&&(0,P.jsx)(v,{label:n(`frontend.session.last_active_label`),children:(0,P.jsx)(c,{lastActive:u})}),(0,P.jsx)(v,{label:n(`frontend.session.signed_in_label`),children:(0,P.jsx)(o,{datetime:l})}),i&&(0,P.jsx)(v,{label:n(`frontend.session.device_id_label`),children:i})]})]}),!r.finishedAt&&(0,P.jsx)(x,{children:(0,P.jsx)(M,{session:r,size:`sm`})})]})},B={browserSessionsOverview:`_browser-sessions-overview_xlk0o_8`},V=t(`
  fragment BrowserSessionsOverview_user on User {
    id

    browserSessions(first: 0, state: ACTIVE) {
      totalCount
    }
  }
`),H=({user:t})=>{let n=e(V,t),{t:r}=a();return(0,P.jsxs)(`div`,{className:B.browserSessionsOverview,children:[(0,P.jsxs)(`div`,{className:`flex flex-1 flex-col`,children:[(0,P.jsx)(l,{children:r(`frontend.browser_sessions_overview.heading`)}),(0,P.jsx)(f,{children:r(`frontend.browser_sessions_overview.body`,{count:n.browserSessions.totalCount})})]}),(0,P.jsx)(N,{to:`/sessions/browsers`,children:r(`frontend.browser_sessions_overview.view_all_button`)})]})},U=e=>{throw Error(`Unknown session type: ${e}`)};function W(){let{t:e}=a(),{inactive:t,pagination:r}=p.useLoaderDeps(),{data:{viewer:o}}=n(h);if(o.__typename!==`User`)throw i();let{data:s}=n(m(r,t));if(s.viewer.__typename!==`User`)throw i();let c=s.viewer.appSessions,[l,f]=d(r,c.pageInfo,6),v=[...c.edges].reverse();return(0,P.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,P.jsx)(u,{children:e(`frontend.user_sessions_overview.heading`)}),(0,P.jsx)(H,{user:o}),(0,P.jsx)(g,{kind:`section`}),(0,P.jsx)(`div`,{className:`flex gap-2 justify-start items-center`,children:(0,P.jsx)(O,{to:`/sessions`,enabled:t,search:{inactive:t?void 0:!0},children:e(`frontend.last_active.inactive_90_days`)})}),v.map(e=>{let t=e.node.__typename;switch(t){case`Oauth2Session`:return(0,P.jsx)(z,{session:e.node},e.cursor);case`CompatSession`:return(0,P.jsx)(I,{session:e.node},e.cursor);default:return U(t)}}),c.totalCount===0&&(0,P.jsx)(D,{children:e(t?`frontend.user_sessions_overview.no_active_sessions.inactive_90_days`:`frontend.user_sessions_overview.no_active_sessions.default`)}),(f||l)&&(0,P.jsxs)(`div`,{className:`flex *:flex-1`,children:[(0,P.jsx)(_,{kind:`secondary`,size:`sm`,disabled:!f,to:`/sessions`,search:{inactive:t,...f||r},resetScroll:!0,children:e(`common.previous`)}),(0,P.jsx)(`div`,{}),(0,P.jsx)(_,{kind:`secondary`,size:`sm`,disabled:!l,to:`/sessions`,search:{inactive:t,...l||r},resetScroll:!0,children:e(`common.next`)})]})]})}export{W as component};
//# sourceMappingURL=_account.sessions.index-DiVjrT7q.js.map