import{n as e}from"./chunk-Bh1tDfsg.js";import{a as t,i as n,l as r,t as i}from"./graphql-Dsv3IYEA.js";import{n as a,t as o}from"./LoadingSpinner-B8ofpgbZ.js";import{n as s,t as c}from"./jsx-runtime-BKZ-v_4m.js";import{n as l}from"./link-7TH0lj3S.js";import{d as u,t as d}from"./useTranslation-l30fIyqu.js";import{t as f}from"./Button-BIiT28Ux.js";import{L as p,R as m,b as h,x as g,y as _}from"./main-CxGi0fIe.js";import{n as v,t as y}from"./computer-DaLupJB4.js";var b=e(u(),1),x=e(s(),1),S=c();function C(e,t){return(0,S.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,S.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`})})}C.displayName=`MobileIcon`;var w=(0,x.forwardRef)(C);function T(e,t){return(0,S.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`1em`,height:`1em`,fill:`currentColor`,viewBox:`0 0 24 24`,ref:t,...e,children:[(0,S.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`}),(0,S.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`})]})}T.displayName=`UnknownIcon`;var E=(0,x.forwardRef)(T);function D(e,t){return(0,S.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,S.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`})})}D.displayName=`WebBrowserIcon`;var O=(0,x.forwardRef)(D),k={deviceTypeIcon:`_device-type-icon_10tr1_8`},A={UNKNOWN:E,PC:y,MOBILE:w,TABLET:O},j=({deviceType:e})=>{let{t}=d(),n=A[e],r={UNKNOWN:t(`frontend.device_type_icon_label.unknown`),PC:t(`frontend.device_type_icon_label.pc`),MOBILE:t(`frontend.device_type_icon_label.mobile`),TABLET:t(`frontend.device_type_icon_label.tablet`)}[e];return(0,S.jsx)(n,{className:k.deviceTypeIcon,"aria-label":r})},M={sessionCardRoot:`_session-card-root_8sc98_8`,action:`_action_8sc98_13`,sessionCard:`_session-card_8sc98_8`,cardHeader:`_card-header_8sc98_13`,disabled:`_disabled_8sc98_59`,compact:`_compact_8sc98_65`,content:`_content_8sc98_75`,auto:`_auto_8sc98_83`,name:`_name_8sc98_84`,client:`_client_8sc98_94`,metadata:`_metadata_8sc98_109`,key:`_key_8sc98_118`,value:`_value_8sc98_124`},N=({children:e})=>(0,S.jsx)(`section`,{className:M.sessionCardRoot,children:e}),P=l((0,x.forwardRef)(({children:e,compact:t,className:n,...r},i)=>{let a=!!r.disabled||!!r[`aria-disabled`]||!1;return(0,S.jsx)(`a`,{className:(0,b.default)(n,M.sessionCard,t&&M.compact,a&&M.disabled),...r,ref:i,children:e})})),F=({children:e,compact:t,disabled:n})=>(0,S.jsx)(`div`,{className:(0,b.default)(M.sessionCard,t&&M.compact,n&&M.disabled),children:e}),I=({type:e,children:t})=>(0,S.jsxs)(`header`,{className:M.cardHeader,children:[(0,S.jsx)(j,{deviceType:e}),(0,S.jsx)(`div`,{className:M.content,children:t})]}),L=({name:e})=>(0,S.jsx)(`div`,{className:M.name,children:e}),R=({name:e,logoUri:t})=>(0,S.jsxs)(`div`,{className:M.client,children:[(0,S.jsx)(v,{name:e,size:`var(--cpd-space-5x)`,logoUri:t}),e]}),z=({children:e})=>(0,S.jsx)(`ul`,{className:M.metadata,children:e}),B=({label:e,children:t})=>(0,S.jsxs)(`li`,{children:[(0,S.jsx)(`div`,{className:M.key,children:e}),(0,S.jsx)(`div`,{className:M.value,children:t})]}),V=({children:e})=>(0,S.jsx)(`div`,{className:M.action,children:e}),H=({children:e,mutation:t,size:n})=>{let[r,i]=(0,x.useState)(!1),{t:a}=d();return(0,S.jsxs)(_,{open:r,onOpenChange:i,trigger:(0,S.jsx)(f,{kind:`secondary`,destructive:!0,size:n,Icon:g,children:a(`frontend.end_session_button.text`)}),children:[(0,S.jsx)(h,{children:a(`frontend.end_session_button.confirmation_modal_title`)}),(0,S.jsx)(m,{children:a(`frontend.end_session_button.confirmation_modal_body_text`)}),e&&(0,S.jsx)(m,{asChild:!0,children:e}),(0,S.jsxs)(f,{type:`button`,kind:`primary`,destructive:!0,onClick:e=>{e.preventDefault(),t.mutate(void 0,{onSuccess:()=>i(!1)})},disabled:t.isPending,Icon:t.isPending?void 0:g,children:[t.isPending&&(0,S.jsx)(o,{inline:!0}),a(`frontend.end_session_button.text`)]}),(0,S.jsx)(p,{asChild:!0,children:(0,S.jsx)(f,{kind:`tertiary`,children:a(`action.cancel`)})})]})},U=n(`
  fragment EndBrowserSessionButton_session on BrowserSession {
    id
    userAgent {
      name
      os
      model
      deviceType
    }
  }
`),W=n(`
  mutation EndBrowserSession($id: ID!) {
    endBrowserSession(input: { browserSessionId: $id }) {
      status
      browserSession {
        id
      }
    }
  }
`),G=(e,t)=>{let n=r();return a({mutationFn:()=>i({query:W,variables:{id:e}}),onSuccess:e=>{n.invalidateQueries({queryKey:[`sessionsOverview`]}),n.invalidateQueries({queryKey:[`browserSessionList`]}),n.invalidateQueries({queryKey:[`sessionDetail`,e.endBrowserSession.browserSession?.id]}),t&&window.location.reload()}})},K=({session:e,size:n})=>{let{t:o}=d(),s=t(U,e),c=r(),l=a({mutationFn:()=>i({query:W,variables:{id:s.id}}),onSuccess:e=>{c.invalidateQueries({queryKey:[`sessionsOverview`]}),c.invalidateQueries({queryKey:[`appSessionList`]}),c.invalidateQueries({queryKey:[`sessionDetail`,e.endBrowserSession.browserSession?.id]})}}),u=s.userAgent?.deviceType??`UNKNOWN`,f=null,p=null;return s.userAgent?.model?(f=s.userAgent.model,s.userAgent?.name&&(p=s.userAgent?.os?o(`frontend.session.name_for_platform`,{name:s.userAgent.name,platform:s.userAgent.os}):s.userAgent.name)):(f=s.userAgent?.name??o(`frontend.session.unknown_browser`),p=s.userAgent?.os??null),(0,S.jsx)(H,{mutation:l,size:n,children:(0,S.jsx)(F,{compact:!0,children:(0,S.jsxs)(I,{type:u,children:[(0,S.jsx)(L,{name:f}),p&&(0,S.jsx)(R,{name:p})]})})})};export{F as a,B as c,L as d,N as f,V as i,P as l,G as n,R as o,H as r,I as s,K as t,z as u};
//# sourceMappingURL=EndBrowserSessionButton-JiSgCdmR.js.map