import{u as v,b as f,j as s,l as m,T as U,af as C,p as _,q as g,s as h,ag as L,m as j,ah as $}from"./main-BiT4j4N5.js";import{c as q,b as k}from"./Heading-CvufBt0-.js";import{B as x}from"./ButtonLink-MFNyI4rM.js";import{s as B,E as F,g as R,a as P}from"./EndOAuth2SessionButton-D0rrwtbQ.js";import{b as D,F as M,E as K}from"./Filter-Dk-lkHif.js";import{p as u,L as y,D as w}from"./LastActive-Ceb4QxH0.js";import{R as S,L as b,H as N,N as T,C as E,M as I,I as d,A as O}from"./EndBrowserSessionButton-Di6zgty2.js";import{S as z}from"./Separator-Bb4mxhob.js";import{L as G}from"./Link-BUiyV9Kq.js";import"./_commonjsHelpers-DaWZu8wl.js";/* empty css               */import"./computer-BrA2K14l.js";const H=m(`
  fragment CompatSession_session on CompatSession {
    id
    createdAt
    deviceId
    finishedAt
    lastActiveIp
    lastActiveAt
    humanName
    ...EndCompatSessionButton_session
    userAgent {
      name
      os
      model
      deviceType
    }
    ssoLogin {
      id
      redirectUri
    }
  }
`),Q=({session:t})=>{const{t:n}=v(),e=f(H,t),o=e.humanName??(e.ssoLogin?.redirectUri?B(e.ssoLogin.redirectUri):void 0),c=e.userAgent?.deviceType??"UNKNOWN",i=e.userAgent?.model??(e.userAgent?.name?e.userAgent?.os?n("frontend.session.name_for_platform",{name:e.userAgent.name,platform:e.userAgent.os}):e.userAgent.name:n("frontend.session.unknown_device")),a=u(e.createdAt),r=e.lastActiveAt?u(e.lastActiveAt):void 0;return s.jsxs(S,{children:[s.jsxs(b,{to:"/sessions/$id",params:{id:e.id},disabled:!!e.finishedAt,children:[s.jsxs(N,{type:c,children:[s.jsx(T,{name:i}),o&&s.jsx(E,{name:o,logoUri:D(e.userAgent?.name??void 0)})]}),s.jsxs(I,{children:[r&&s.jsx(d,{label:n("frontend.session.last_active_label"),children:s.jsx(y,{lastActive:r})}),s.jsx(d,{label:n("frontend.session.signed_in_label"),children:s.jsx(w,{datetime:a})}),s.jsx(d,{label:n("frontend.session.device_id_label"),children:e.deviceId})]})]}),!e.finishedAt&&s.jsx(O,{children:s.jsx(F,{session:e,size:"sm"})})]})},W=m(`
  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
    }
  }
`),V=t=>t==="WEB"?"PC":t==="NATIVE"?"MOBILE":"UNKNOWN",Y=({session:t})=>{const{t:n}=v(),e=f(W,t),o=R(e.scope),c=u(e.createdAt),i=e.lastActiveAt?u(e.lastActiveAt):void 0,a=(e.userAgent?.deviceType==="UNKNOWN"?null:e.userAgent?.deviceType)??V(e.client.applicationType),r=e.client.clientName||e.client.clientId,p=e.humanName??e.userAgent?.model??(e.userAgent?.name?e.userAgent?.os?n("frontend.session.name_for_platform",{name:e.userAgent.name,platform:e.userAgent.os}):e.userAgent.name:n("frontend.session.unknown_device"));return s.jsxs(S,{children:[s.jsxs(b,{to:"/sessions/$id",params:{id:e.id},disabled:!!e.finishedAt,children:[s.jsxs(N,{type:a,children:[s.jsx(T,{name:p}),s.jsx(E,{name:r,logoUri:e.client.logoUri??void 0})]}),s.jsxs(I,{children:[i&&s.jsx(d,{label:n("frontend.session.last_active_label"),children:s.jsx(y,{lastActive:i})}),s.jsx(d,{label:n("frontend.session.signed_in_label"),children:s.jsx(w,{datetime:c})}),o&&s.jsx(d,{label:n("frontend.session.device_id_label"),children:o})]})]}),!e.finishedAt&&s.jsx(O,{children:s.jsx(P,{session:e,size:"sm"})})]})},Z="_browser-sessions-overview_xlk0o_8",J={browserSessionsOverview:Z},X=m(`
  fragment BrowserSessionsOverview_user on User {
    id

    browserSessions(first: 0, state: ACTIVE) {
      totalCount
    }
  }
`),ee=({user:t})=>{const n=f(X,t),{t:e}=v();return s.jsxs("div",{className:J.browserSessionsOverview,children:[s.jsxs("div",{className:"flex flex-1 flex-col",children:[s.jsx(q,{children:e("frontend.browser_sessions_overview.heading")}),s.jsx(U,{children:e("frontend.browser_sessions_overview.body",{count:n.browserSessions.totalCount})})]}),s.jsx(G,{to:"/sessions/browsers",children:e("frontend.browser_sessions_overview.view_all_button")})]})},se=6,ne=m(`
  query SessionsOverview {
    viewer {
      __typename

      ... on User {
        id
        ...BrowserSessionsOverview_user
      }
    }
  }
`),te=g({queryKey:["sessionsOverview"],queryFn:({signal:t})=>j({query:ne,signal:t})}),oe=m(`
  query AppSessionsList(
    $before: String
    $after: String
    $first: Int
    $last: Int
    $lastActive: DateFilter
  ) {
    viewer {
      __typename

      ... on User {
        id
        appSessions(
          before: $before
          after: $after
          first: $first
          last: $last
          lastActive: $lastActive
          state: ACTIVE
        ) {
          edges {
            cursor
            node {
              __typename
              ...CompatSession_session
              ...OAuth2Session_session
            }
          }

          totalCount
          pageInfo {
            startCursor
            endCursor
            hasNextPage
            hasPreviousPage
          }
        }
      }
    }
  }
`),ie=(t,n)=>g({queryKey:["appSessionList",n,t],queryFn:({signal:e})=>j({query:oe,variables:{lastActive:n?{before:$()}:void 0,...t},signal:e})}),re=t=>{throw new Error(`Unknown session type: ${t}`)};function xe(){const{t}=v(),{inactive:n,pagination:e}=C.useLoaderDeps(),{data:{viewer:o}}=_(te);if(o.__typename!=="User")throw h();const{data:c}=_(ie(e,n));if(c.viewer.__typename!=="User")throw h();const i=c.viewer.appSessions,[a,r]=L(e,i.pageInfo,se),p=[...i.edges].reverse();return s.jsxs("div",{className:"flex flex-col gap-6",children:[s.jsx(k,{children:t("frontend.user_sessions_overview.heading")}),s.jsx(ee,{user:o}),s.jsx(z,{kind:"section"}),s.jsx("div",{className:"flex gap-2 justify-start items-center",children:s.jsx(M,{to:"/sessions",enabled:n,search:{inactive:n?void 0:!0},children:t("frontend.last_active.inactive_90_days")})}),p.map(l=>{const A=l.node.__typename;switch(A){case"Oauth2Session":return s.jsx(Y,{session:l.node},l.cursor);case"CompatSession":return s.jsx(Q,{session:l.node},l.cursor);default:return re(A)}}),i.totalCount===0&&s.jsx(K,{children:t(n?"frontend.user_sessions_overview.no_active_sessions.inactive_90_days":"frontend.user_sessions_overview.no_active_sessions.default")}),(r||a)&&s.jsxs("div",{className:"flex *:flex-1",children:[s.jsx(x,{kind:"secondary",size:"sm",disabled:!r,to:"/sessions",search:{inactive:n,...r||e},resetScroll:!0,children:t("common.previous")}),s.jsx("div",{}),s.jsx(x,{kind:"secondary",size:"sm",disabled:!a,to:"/sessions",search:{inactive:n,...a||e},resetScroll:!0,children:t("common.next")})]})]})}export{xe as component};
//# sourceMappingURL=_account.sessions.index-DHL8ZcD1.js.map
