import{n as e}from"./chunk-Bh1tDfsg.js";import{A as t,At as n,D as r,Dt as i,M as a,Mt as o,P as s,Q as c,Z as l,_t as u,b as d,bt as f,jt as p,k as m,mt as h,x as g,y as _}from"./main-ChC-SNZa.js";import{n as v,t as y}from"./computer-BCuRsBkK.js";var b=e(u(),1),x=e(o(),1),S=p();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}=s(),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=f((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[i,a]=(0,x.useState)(!1),{t:o}=s();return(0,S.jsxs)(_,{open:i,onOpenChange:a,trigger:(0,S.jsx)(h,{kind:`secondary`,destructive:!0,size:n,Icon:g,children:o(`frontend.end_session_button.text`)}),children:[(0,S.jsx)(d,{children:o(`frontend.end_session_button.confirmation_modal_title`)}),(0,S.jsx)(c,{children:o(`frontend.end_session_button.confirmation_modal_body_text`)}),e&&(0,S.jsx)(c,{asChild:!0,children:e}),(0,S.jsxs)(h,{type:`button`,kind:`primary`,destructive:!0,onClick:e=>{e.preventDefault(),t.mutate(void 0,{onSuccess:()=>a(!1)})},disabled:t.isPending,Icon:t.isPending?void 0:g,children:[t.isPending&&(0,S.jsx)(r,{inline:!0}),o(`frontend.end_session_button.text`)]}),(0,S.jsx)(l,{asChild:!0,children:(0,S.jsx)(h,{kind:`tertiary`,children:o(`action.cancel`)})})]})},U=t(`
  fragment EndBrowserSessionButton_session on BrowserSession {
    id
    userAgent {
      name
      os
      model
      deviceType
    }
  }
`),W=t(`
  mutation EndBrowserSession($id: ID!) {
    endBrowserSession(input: { browserSessionId: $id }) {
      status
      browserSession {
        id
      }
    }
  }
`),G=(e,t)=>{let r=n();return i({mutationFn:()=>m({query:W,variables:{id:e}}),onSuccess:e=>{r.invalidateQueries({queryKey:[`sessionsOverview`]}),r.invalidateQueries({queryKey:[`browserSessionList`]}),r.invalidateQueries({queryKey:[`sessionDetail`,e.endBrowserSession.browserSession?.id]}),t&&window.location.reload()}})},K=({session:e,size:t})=>{let{t:r}=s(),o=a(U,e),c=n(),l=i({mutationFn:()=>m({query:W,variables:{id:o.id}}),onSuccess:e=>{c.invalidateQueries({queryKey:[`sessionsOverview`]}),c.invalidateQueries({queryKey:[`appSessionList`]}),c.invalidateQueries({queryKey:[`sessionDetail`,e.endBrowserSession.browserSession?.id]})}}),u=o.userAgent?.deviceType??`UNKNOWN`,d=null,f=null;return o.userAgent?.model?(d=o.userAgent.model,o.userAgent?.name&&(f=o.userAgent?.os?r(`frontend.session.name_for_platform`,{name:o.userAgent.name,platform:o.userAgent.os}):o.userAgent.name)):(d=o.userAgent?.name??r(`frontend.session.unknown_browser`),f=o.userAgent?.os??null),(0,S.jsx)(H,{mutation:l,size:t,children:(0,S.jsx)(F,{compact:!0,children:(0,S.jsxs)(I,{type:u,children:[(0,S.jsx)(L,{name:d}),f&&(0,S.jsx)(R,{name:f})]})})})};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-l-4WagCS.js.map