import{r as l,j as e,u as _,x as p,ai as A,D as I,e as C,f as B,B as m,N as v,i as S,k as q,c as x,d as w,m as y,l as h,b as T}from"./main-BiT4j4N5.js";import{I as k,C as E}from"./computer-BrA2K14l.js";function f(s,n){return e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",fill:"currentColor",viewBox:"0 0 24 24",ref:n,...s,children:e.jsx("path",{d:"M7 23q-.824 0-1.412-.587A1.93 1.93 0 0 1 5 21V3q0-.824.588-1.412A1.93 1.93 0 0 1 7 1h10q.824 0 1.413.587Q19 2.176 19 3v18q0 .824-.587 1.413A1.93 1.93 0 0 1 17 23zm0-5h10V6H7z"})})}f.displayName="MobileIcon";const M=l.forwardRef(f);function b(s,n){return e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",fill:"currentColor",viewBox:"0 0 24 24",ref:n,...s,children:[e.jsx("path",{d:"M5 21q-.824 0-1.412-.587A1.93 1.93 0 0 1 3 19V5q0-.824.587-1.412A1.93 1.93 0 0 1 5 3h14q.824 0 1.413.587Q21 4.176 21 5v14q0 .824-.587 1.413A1.93 1.93 0 0 1 19 21zm0-2h14V5H5z"}),e.jsx("path",{d:"M11 10a1 1 0 1 1 1.479.878c-.31.17-.659.413-.94.741-.286.334-.539.8-.539 1.381a1 1 0 0 0 2 .006.3.3 0 0 1 .057-.085 1.4 1.4 0 0 1 .382-.288A3 3 0 1 0 9 10a1 1 0 1 0 2 0m1.999 3.012v-.005zM12 17a1 1 0 1 0 0-2 1 1 0 0 0 0 2"})]})}b.displayName="UnknownIcon";const L=l.forwardRef(b);function j(s,n){return e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",fill:"currentColor",viewBox:"0 0 24 24",ref:n,...s,children:e.jsx("path",{d:"M4 20q-.824 0-1.412-.587A1.93 1.93 0 0 1 2 18V6q0-.824.587-1.412A1.93 1.93 0 0 1 4 4h16q.824 0 1.413.588Q22 5.175 22 6v12q0 .824-.587 1.413A1.93 1.93 0 0 1 20 20zm0-2h16V8H4z"})})}j.displayName="WebBrowserIcon";const R=l.forwardRef(j),D="_device-type-icon_10tr1_8",O={deviceTypeIcon:D},Q={UNKNOWN:L,PC:k,MOBILE:M,TABLET:R},K=({deviceType:s})=>{const{t:n}=_(),a=Q[s],i={UNKNOWN:n("frontend.device_type_icon_label.unknown"),PC:n("frontend.device_type_icon_label.pc"),MOBILE:n("frontend.device_type_icon_label.mobile"),TABLET:n("frontend.device_type_icon_label.tablet")}[s];return e.jsx(a,{className:O.deviceTypeIcon,"aria-label":i})},z="_session-card-root_8sc98_8",H="_action_8sc98_13",U="_session-card_8sc98_8",V="_card-header_8sc98_13",P="_disabled_8sc98_59",W="_compact_8sc98_65",F="_content_8sc98_75",$="_name_8sc98_84",G="_client_8sc98_94",J="_metadata_8sc98_109",X="_key_8sc98_118",Y="_value_8sc98_124",t={sessionCardRoot:z,action:H,sessionCard:U,cardHeader:V,disabled:P,compact:W,content:F,name:$,client:G,metadata:J,key:X,value:Y},re=({children:s})=>e.jsx("section",{className:t.sessionCardRoot,children:s}),ce=A(l.forwardRef(({children:s,compact:n,className:a,...o},i)=>{const r=!!o.disabled||!!o["aria-disabled"]||!1;return e.jsx("a",{className:p(a,t.sessionCard,n&&t.compact,r&&t.disabled),...o,ref:i,children:s})})),Z=({children:s,compact:n,disabled:a})=>e.jsx("div",{className:p(t.sessionCard,n&&t.compact,a&&t.disabled),children:s}),ee=({type:s,children:n})=>e.jsxs("header",{className:t.cardHeader,children:[e.jsx(K,{deviceType:s}),e.jsx("div",{className:t.content,children:n})]}),se=({name:s})=>e.jsx("div",{className:t.name,children:s}),ne=({name:s,logoUri:n})=>e.jsxs("div",{className:t.client,children:[e.jsx(E,{name:s,size:"var(--cpd-space-5x)",logoUri:n}),s]}),de=({children:s})=>e.jsx("ul",{className:t.metadata,children:s}),le=({label:s,children:n})=>e.jsxs("li",{children:[e.jsx("div",{className:t.key,children:s}),e.jsx("div",{className:t.value,children:n})]}),ue=({children:s})=>e.jsx("div",{className:t.action,children:s}),oe=({children:s,mutation:n,size:a})=>{const[o,i]=l.useState(!1),{t:r}=_(),u=c=>{c.preventDefault(),n.mutate(void 0,{onSuccess:()=>i(!1)})};return e.jsxs(I,{open:o,onOpenChange:i,trigger:e.jsx(m,{kind:"secondary",destructive:!0,size:a,Icon:v,children:r("frontend.end_session_button.text")}),children:[e.jsx(C,{children:r("frontend.end_session_button.confirmation_modal_title")}),s&&e.jsx(B,{asChild:!0,children:s}),e.jsxs(m,{type:"button",kind:"primary",destructive:!0,onClick:u,disabled:n.isPending,Icon:n.isPending?void 0:v,children:[n.isPending&&e.jsx(S,{inline:!0}),r("frontend.end_session_button.text")]}),e.jsx(q,{asChild:!0,children:e.jsx(m,{kind:"tertiary",children:r("action.cancel")})})]})},te=h(`
  fragment EndBrowserSessionButton_session on BrowserSession {
    id
    userAgent {
      name
      os
      model
      deviceType
    }
  }
`),g=h(`
  mutation EndBrowserSession($id: ID!) {
    endBrowserSession(input: { browserSessionId: $id }) {
      status
      browserSession {
        id
      }
    }
  }
`),me=(s,n)=>{const a=x();return w({mutationFn:()=>y({query:g,variables:{id:s}}),onSuccess:i=>{a.invalidateQueries({queryKey:["sessionsOverview"]}),a.invalidateQueries({queryKey:["browserSessionList"]}),a.invalidateQueries({queryKey:["sessionDetail",i.endBrowserSession.browserSession?.id]}),window.location.reload()}})},_e=({session:s,size:n})=>{const{t:a}=_(),o=T(te,s),i=x(),r=w({mutationFn:()=>y({query:g,variables:{id:o.id}}),onSuccess:N=>{i.invalidateQueries({queryKey:["sessionsOverview"]}),i.invalidateQueries({queryKey:["appSessionList"]}),i.invalidateQueries({queryKey:["sessionDetail",N.endBrowserSession.browserSession?.id]})}}),u=o.userAgent?.deviceType??"UNKNOWN";let c=null,d=null;return o.userAgent?.model?(c=o.userAgent.model,o.userAgent?.name&&(o.userAgent?.os?d=a("frontend.session.name_for_platform",{name:o.userAgent.name,platform:o.userAgent.os}):d=o.userAgent.name)):(c=o.userAgent?.name??a("frontend.session.unknown_browser"),d=o.userAgent?.os??null),e.jsx(oe,{mutation:r,size:n,children:e.jsx(Z,{compact:!0,children:e.jsxs(ee,{type:u,children:[e.jsx(se,{name:c}),d&&e.jsx(ne,{name:d})]})})})};export{ue as A,Z as B,ne as C,_e as E,ee as H,le as I,ce as L,de as M,se as N,re as R,oe as a,me as u};
//# sourceMappingURL=EndBrowserSessionButton-Di6zgty2.js.map
