openmausbot 0.1.99 → 0.1.100
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{ActivityPanel-CgUgtumZ.js → ActivityPanel-CA9zfl3_.js} +1 -1
- package/dist/assets/{BotSettingsDialog-lJj6oiir.js → BotSettingsDialog-3i_izROu.js} +1 -1
- package/dist/assets/{CloudBackendPicker-C5-_arUz.js → CloudBackendPicker-BR42-xBg.js} +1 -1
- package/dist/assets/{ComputerPanel-euJ2CSlH.js → ComputerPanel-CvThnFmt.js} +1 -1
- package/dist/assets/{DesktopViewer-XCln1Pn_.js → DesktopViewer-CqovWUic.js} +1 -1
- package/dist/assets/{InspectorPanel-DKYyQZlo.js → InspectorPanel-Cbjm86gt.js} +1 -1
- package/dist/assets/{KeyboardShortcutsModal-DkkZWZRI.js → KeyboardShortcutsModal-X13pVrkh.js} +1 -1
- package/dist/assets/{LocalVmWorkspace-Cwt3_XSx.js → LocalVmWorkspace-BGD3Tvd3.js} +1 -1
- package/dist/assets/{MacLocalControl-B28RbdCS.js → MacLocalControl-ExdXHVUv.js} +1 -1
- package/dist/assets/{NewBotDialog-dMWDs5xm.js → NewBotDialog-ftDBMjWR.js} +1 -1
- package/dist/assets/{RemoteAgentSettingsPanel-B5KWXnqH.js → RemoteAgentSettingsPanel-BUHLV_vC.js} +1 -1
- package/dist/assets/{RoutinesPage-DOosRYDK.js → RoutinesPage-Buk5-r3o.js} +1 -1
- package/dist/assets/{RoutinesSection-uOfOTfkB.js → RoutinesSection-NyReOXr8.js} +1 -1
- package/dist/assets/{SettingsModal-BTGkFbj1.js → SettingsModal-DkkhdxKM.js} +1 -1
- package/dist/assets/{TeamMapPage-DqNdJn96.js → TeamMapPage-BIxeHoy3.js} +1 -1
- package/dist/assets/{TriggersPanel-c6xkG9mi.js → TriggersPanel-m5iqc43H.js} +1 -1
- package/dist/assets/{VisibilitySection-DD4ffIR5.js → VisibilitySection-y8Adk-c4.js} +1 -1
- package/dist/assets/{WebhooksPanel-Cz17K-_O.js → WebhooksPanel-G_NWjHOP.js} +1 -1
- package/dist/assets/{abnfDiagram-O67JEVCF-CX6tDpkg.js → abnfDiagram-O67JEVCF-D56ZgyPf.js} +1 -1
- package/dist/assets/{activity-BAVWO0Zj.js → activity-D_puBfZo.js} +1 -1
- package/dist/assets/{arc-h45-9NFk.js → arc-DzduGHbq.js} +1 -1
- package/dist/assets/{architectureDiagram-NJMV4G6O-CgLFXbg6.js → architectureDiagram-NJMV4G6O-C4NS6DQF.js} +1 -1
- package/dist/assets/{blockDiagram-BEXU5L5S-DGDFFc9M.js → blockDiagram-BEXU5L5S-BNvsskiE.js} +1 -1
- package/dist/assets/{brain-CeCdoTb2.js → brain-oq48IgWl.js} +1 -1
- package/dist/assets/{c4Diagram-YGBWAQC7-B9aklAUj.js → c4Diagram-YGBWAQC7-ch3B7xZy.js} +1 -1
- package/dist/assets/channel-CmFDMHrN.js +1 -0
- package/dist/assets/{chunk-2Q5K7J3B-BC0KmWsM.js → chunk-2Q5K7J3B-D9dL9ZS7.js} +1 -1
- package/dist/assets/{chunk-3FUC2YCW-BbDFHsJ1.js → chunk-3FUC2YCW-DmLUUuNr.js} +2 -2
- package/dist/assets/{chunk-5VM5RSS4-DtGbsjOM.js → chunk-5VM5RSS4-B90ODeo2.js} +1 -1
- package/dist/assets/{chunk-GTNCS2PH-VMghMcEl.js → chunk-GTNCS2PH-BtlGIG3W.js} +1 -1
- package/dist/assets/{chunk-GWA4HPMP-BP_JyGWQ.js → chunk-GWA4HPMP-CurBwFFG.js} +1 -1
- package/dist/assets/{chunk-JWPE2WC7-CYFyzgAU.js → chunk-JWPE2WC7-DTjNNXcd.js} +1 -1
- package/dist/assets/{chunk-NETBCI7D-DBNa_kqm.js → chunk-NETBCI7D-xS7hOqBJ.js} +1 -1
- package/dist/assets/{chunk-WEXAMYUT-BKEeM7CJ.js → chunk-WEXAMYUT-DJZBSyA9.js} +1 -1
- package/dist/assets/{chunk-XXDRQBXY-C__m3ZXl.js → chunk-XXDRQBXY-CbiNRzjt.js} +1 -1
- package/dist/assets/{classDiagram-v2-NBCMYWYE-CBUrTSAX.js → classDiagram-v2-NBCMYWYE-DyON9tUb.js} +1 -1
- package/dist/assets/{core-6lvx-ypA.js → core-CRkAXD3N.js} +1 -1
- package/dist/assets/{cose-bilkent-JH36ORCC-GRfL-1Vb.js → cose-bilkent-JH36ORCC-C7UwNnp8.js} +1 -1
- package/dist/assets/{cynefin-OW5HDTMX-LopwGUjm.js → cynefin-OW5HDTMX-Dv1GTekc.js} +1 -1
- package/dist/assets/{cynefinDiagram-VND7K2PF-DSB8ZRNS.js → cynefinDiagram-VND7K2PF-CKgpyZxo.js} +1 -1
- package/dist/assets/{dagre-6A5THRUB-DL3Kgdfk.js → dagre-6A5THRUB-BY3cYc8R.js} +1 -1
- package/dist/assets/{diagram-22UHCM2B-DIxN34BM.js → diagram-22UHCM2B-D71jBFCO.js} +1 -1
- package/dist/assets/{diagram-3UASUU5V-CJnSvXaI.js → diagram-3UASUU5V-Bc3i6JGD.js} +1 -1
- package/dist/assets/{diagram-ATOU4E4O-C-XF-lO8.js → diagram-ATOU4E4O-BPDSHISG.js} +1 -1
- package/dist/assets/{diagram-CDSNMT55-Df2yZPi_.js → diagram-CDSNMT55-xuCT1v32.js} +1 -1
- package/dist/assets/{diagram-MLGK6HIB-BBs9oZFs.js → diagram-MLGK6HIB-LEDTXDPg.js} +1 -1
- package/dist/assets/{diagram-MPIPVDR6-CEbK11mM.js → diagram-MPIPVDR6-B0kfscRD.js} +1 -1
- package/dist/assets/{ebnfDiagram-ZINNZB2B-BNq6Yv3C.js → ebnfDiagram-ZINNZB2B-B-Z0HLzJ.js} +1 -1
- package/dist/assets/{elk-276RUBZZ-CFbQ2bGm.js → elk-276RUBZZ-Bzypn7lU.js} +1 -1
- package/dist/assets/{erDiagram-OPXOYQCR-Bz8vmjN4.js → erDiagram-OPXOYQCR-vl1xKmbS.js} +1 -1
- package/dist/assets/{flowDiagram-KWPJA3E3-cQUfEYrx.js → flowDiagram-KWPJA3E3-DQXCXm7z.js} +1 -1
- package/dist/assets/{ganttDiagram-FUAMR5RP-BY8n9tbI.js → ganttDiagram-FUAMR5RP-B0wwnP2j.js} +1 -1
- package/dist/assets/{gitGraphDiagram-X574FWY7-KduSOMDN.js → gitGraphDiagram-X574FWY7-HfEVZRuR.js} +1 -1
- package/dist/assets/{image-plus-DNIWU160.js → image-plus-D9o3v9bi.js} +1 -1
- package/dist/assets/{index-C8xb62XS.js → index-CyM91z0J.js} +111 -111
- package/dist/assets/{infoDiagram-VRGFBTTK-xBKgUkpL.js → infoDiagram-VRGFBTTK-BcCklxlu.js} +1 -1
- package/dist/assets/{ishikawaDiagram-OU5B5YK6-_ei09tAJ.js → ishikawaDiagram-OU5B5YK6-Bw7Fp8yZ.js} +1 -1
- package/dist/assets/{journeyDiagram-ZHPQQLJL-Fp49MkSp.js → journeyDiagram-ZHPQQLJL-BqFaTPiB.js} +1 -1
- package/dist/assets/{kanban-definition-PNTS6WVX-CY9lLm7V.js → kanban-definition-PNTS6WVX-BdGyimUh.js} +1 -1
- package/dist/assets/{linear-D2ai4eM2.js → linear-DezKjgv7.js} +1 -1
- package/dist/assets/{mermaid.core-DP6qPqu1.js → mermaid.core-97L7xtx0.js} +5 -5
- package/dist/assets/{mindmap-definition-NLK3R4M7-g1ynEw_d.js → mindmap-definition-NLK3R4M7-DP6qz87C.js} +1 -1
- package/dist/assets/{page-visible-BZn8304W.js → page-visible-BehtKJDm.js} +1 -1
- package/dist/assets/{pegDiagram-GJSIUBJH-Bt4ObsZj.js → pegDiagram-GJSIUBJH-CsYSloVz.js} +1 -1
- package/dist/assets/{pieDiagram-5QR66LMP-CeLld8bY.js → pieDiagram-5QR66LMP-CFI2Dcix.js} +1 -1
- package/dist/assets/{quadrantDiagram-O4NWA36T-D4WWZw3x.js → quadrantDiagram-O4NWA36T-DqTdAE5z.js} +1 -1
- package/dist/assets/{railroadDiagram-XR7U4H2S-D95P5NqU.js → railroadDiagram-XR7U4H2S-t_rszRIF.js} +1 -1
- package/dist/assets/{remote-desktop-panel-DOIMmT4T.js → remote-desktop-panel-WTaz_HI9.js} +1 -1
- package/dist/assets/{requirementDiagram-PLB6GJNP-D12p3RhR.js → requirementDiagram-PLB6GJNP-1MU-l7p8.js} +1 -1
- package/dist/assets/{sankeyDiagram-IPEJSGJF-Co26Dwcs.js → sankeyDiagram-IPEJSGJF-CtkrwAvo.js} +1 -1
- package/dist/assets/{sequenceDiagram-PO4LG4MO-y5YxaDKt.js → sequenceDiagram-PO4LG4MO-CJOwBubv.js} +1 -1
- package/dist/assets/{sizeCapture-INFHLROL-D49hZ8U5.js → sizeCapture-INFHLROL-DhQVhKCc.js} +1 -1
- package/dist/assets/{stateDiagram-v2-GCMORJYK-C0sylr-r.js → stateDiagram-v2-GCMORJYK-CaQK9yA9.js} +1 -1
- package/dist/assets/{swimlanes-2SLR337P-DmRWsDIs.js → swimlanes-2SLR337P-Ct8cqf01.js} +1 -1
- package/dist/assets/swimlanesDiagram-TC7HE7FX-BBUcFKOA.js +8 -0
- package/dist/assets/{timeline-definition-EJHVYXUP-DVmHYs3w.js → timeline-definition-EJHVYXUP-qim2Km3q.js} +1 -1
- package/dist/assets/{usecaseDiagram-POWQR4AR-BQ1q0VV6.js → usecaseDiagram-POWQR4AR-BIzcxmgX.js} +1 -1
- package/dist/assets/{user-B9lohN4n.js → user-EQ8rI0f4.js} +1 -1
- package/dist/assets/{vennDiagram-UO4OBE2U-C_cnfST0.js → vennDiagram-UO4OBE2U-BFEuz8Ba.js} +1 -1
- package/dist/assets/{wardleyDiagram-VNRHLVJA-Bb3BSu12.js → wardleyDiagram-VNRHLVJA-JRkAN01c.js} +1 -1
- package/dist/assets/{xychartDiagram-PMCCYNJV-CcwEuuEi.js → xychartDiagram-PMCCYNJV-WBsvmu0R.js} +1 -1
- package/dist/index.html +1 -1
- package/dist-server/index.js +9 -6
- package/dist-server/server/mcp-probe.js +18 -10
- package/package.json +1 -1
- package/dist/assets/channel-TsOXCiPg.js +0 -1
- package/dist/assets/swimlanesDiagram-TC7HE7FX-DzhbBHtd.js +0 -8
|
@@ -1 +1 @@
|
|
|
1
|
-
import{m as et,u as Tt,ax as Pt,j as e,t as r,aV as Ln,aU as kn,F as er,a7 as tr,r as a,d as U,bb as It,M as Fe,bc as Vn,ag as nr,bd as Fn,a4 as rr,aW as Zt,g as W,be as Qt,aw as We,X as St,P as sr,n as ar,Q as _e,bf as or,c as Ve,O as Wt,a3 as ir,bg as pt,E as lr,a as cr,bh as ur,bi as dr,bj as pr,aO as jn,bk as mr,bl as xr,bm as fr,bn as br,bo as hr,ba as gr,bp as Nn,bq as vr,br as Sn,bs as Cn,bt as yr,l as wr,v as kr,bu as jr,bv as Nr,aQ as Sr,w as Cr,aL as Er,bw as Rr,bx as Ir,by as En,bz as Tr,bA as Pr,C as Rn,bB as zr,p as Ar,bC as Ht,bD as Dr,bE as Mr,am as Or,bF as Lr,A as Vr,D as Fr,G as _r,H as $r,bG as Br,bH as Kr,bI as Ur,bJ as qr}from"./index-C8xb62XS.js";import{R as Wr,g as Hr,h as Xr,b as Yr,i as Jr,j as Gr}from"./WebhooksPanel-Cz17K-_O.js";import{B as Qr,A as Zr,M as In,a as es,w as ts}from"./MacLocalControl-B28RbdCS.js";import{u as en}from"./page-visible-BZn8304W.js";import{C as ns}from"./CloudBackendPicker-C5-_arUz.js";import{R as rs}from"./RoutinesSection-uOfOTfkB.js";import{t as ss}from"./computer-control-NLov352p.js";import"./RoutinesPage-DOosRYDK.js";const as=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]],os=et("columns-2",as);const is=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}]],ls=et("ellipsis-vertical",is);const cs=[["path",{d:"m14 10 7-7",key:"oa77jy"}],["path",{d:"M20 10h-6V4",key:"mjg0md"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M4 14h6v6",key:"rmj7iw"}]],us=et("minimize-2",cs);const ds=[["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"m14.305 7.53.923-.382",key:"1mlnsw"}],["path",{d:"m15.228 4.852-.923-.383",key:"82mpwg"}],["path",{d:"m16.852 3.228-.383-.924",key:"ln4sir"}],["path",{d:"m16.852 8.772-.383.923",key:"1dejw0"}],["path",{d:"m19.148 3.228.383-.924",key:"192kgf"}],["path",{d:"m19.53 9.696-.382-.924",key:"fiavlr"}],["path",{d:"m20.772 4.852.924-.383",key:"1j8mgp"}],["path",{d:"m20.772 7.148.924.383",key:"zix9be"}],["path",{d:"M22 13v2a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7",key:"1tnzv8"}],["path",{d:"M8 21h8",key:"1ev6f3"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}]],ps=et("monitor-cog",ds);const ms=[["circle",{cx:"10",cy:"7",r:"1",key:"dypaad"}],["circle",{cx:"4",cy:"20",r:"1",key:"22iqad"}],["path",{d:"M4.7 19.3 19 5",key:"1enqfc"}],["path",{d:"m21 3-3 1 2 2Z",key:"d3ov82"}],["path",{d:"M9.26 7.68 5 12l2 5",key:"1esawj"}],["path",{d:"m10 14 5 2 3.5-3.5",key:"v8oal5"}],["path",{d:"m18 12 1-1 1 1-1 1Z",key:"1bh22v"}]],xs=et("usb",ms);const fs=[["circle",{cx:"12",cy:"8",r:"5",key:"1hypcn"}],["path",{d:"M20 21a8 8 0 0 0-16 0",key:"rfgkzh"}]],bs=et("user-round",fs),hs=20;function gs(t,c=hs){const l=new Set,d=[],p=tr(t);for(let b=p.length-1;b>=0&&d.length<c;b-=1){const E=p[b].digest?.files;if(E){for(const w of E.deleted)l.add(w);for(const w of[...E.added,...E.changed])if(!l.has(w)&&(l.add(w),d.push(w),d.length>=c))break}}return d}function vs(t){const c=Math.max(t.lastIndexOf("/"),t.lastIndexOf("\\"));return c<0?{name:t,folder:""}:{name:t.slice(c+1),folder:t.slice(0,c)}}function ys({bot:t}){const{dispatch:c}=Tt(),{capabilities:l}=Pt(),d=l.host.homeDir,p=gs(t);return e.jsxs("div",{className:"flex-1 overflow-y-auto px-5 pb-5","data-testid":"computer-files",children:[e.jsxs("div",{className:"mt-2 rounded-xl bg-card p-4",children:[e.jsx("div",{className:"text-[13px] font-medium text-ink",children:r("computer.files.folder")}),e.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[e.jsx(Ln,{size:15,className:"shrink-0 text-ink-secondary","aria-hidden":"true"}),e.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-[12px] text-ink",title:t.cwd??void 0,children:t.cwd?kn(t.cwd,d):r("computer.files.privateFolder",{name:t.name})}),e.jsx("button",{type:"button",onClick:()=>{c({type:"toggleComputer",open:!1}),c({type:"toggleSettings",open:!0,section:"access"})},className:"shrink-0 rounded-lg bg-control px-2.5 py-1 text-[12px] text-ink hover:bg-raised-hover",children:r("computer.files.changeFolder")})]})]}),e.jsxs("div",{className:"mt-3 rounded-xl bg-card p-4",children:[e.jsx("div",{className:"text-[13px] font-medium text-ink",children:r("computer.files.recent")}),p.length===0?e.jsx("p",{className:"mt-2 text-[12px] leading-5 text-ink-secondary",children:r("computer.files.empty",{name:t.name})}):e.jsx("ul",{className:"mt-2 flex flex-col gap-1",children:p.map(b=>{const{name:E,folder:w}=vs(b);return e.jsxs("li",{className:"flex min-w-0 items-center gap-2 rounded-lg px-1 py-1",title:b,children:[e.jsx(er,{size:14,className:"shrink-0 text-ink-secondary","aria-hidden":"true"}),e.jsx("span",{className:"min-w-0 truncate text-[12.5px] text-ink",children:E}),w&&e.jsx("span",{className:"min-w-0 flex-1 truncate text-right text-[11px] text-ink-tertiary",children:kn(w,d)})]},b)})})]})]})}function ws({src:t,name:c,error:l,starting:d,opening:p,disabled:b,refreshing:E=!1,retry:w=0,onOpen:f,onRetry:C}){const[z,N]=a.useState(null),[j,T]=a.useState(null);a.useEffect(()=>{T(null)},[w]);const S=!!(t&&z===t&&j!==t),h=l??(t&&j===t?r("computer.preview.imageFailed"):null);return e.jsxs("div",{className:"relative h-full w-full","aria-busy":!h&&(!S||p||E),children:[t&&e.jsxs("button",{type:"button",onClick:f,disabled:b||d||p||!S,className:"group absolute inset-0 flex h-full w-full items-center justify-center disabled:cursor-wait","aria-label":r("computer.openLiveDesktopAria",{name:c}),title:r("computer.openLiveDesktop"),children:[e.jsx("img",{src:t,alt:r("computer.screenOf",{name:c}),onLoad:()=>{N(t),T(null)},onError:()=>T(t),className:`h-full w-full object-contain transition group-hover:brightness-75 ${S?"":"invisible"}`},w),S&&e.jsxs("span",{className:"absolute right-2 top-2 flex items-center gap-1 rounded-md bg-black/70 px-2 py-1 text-[11px] font-medium text-white",children:[p?e.jsx(U,{size:12,className:"animate-spin"}):e.jsx(It,{size:12}),p?r("computer.preview.connecting"):r("computer.open")]})]}),!S&&!h&&e.jsxs("div",{role:"status",className:"absolute inset-0 flex flex-col items-center justify-center gap-2 px-6 text-center text-[12px] text-ink-secondary",children:[e.jsx(U,{size:18,className:"animate-spin"}),d?r("computer.phase.starting"):r("computer.preview.connectingScreen")]}),S&&E&&!h&&e.jsxs("div",{role:"status",className:"absolute bottom-2 left-2 flex items-center gap-1 rounded-md bg-black/70 px-2 py-1 text-[11px] text-white",children:[e.jsx(U,{size:12,className:"animate-spin"}),r("computer.preview.connectingScreen")]}),h&&e.jsxs("div",{role:"alert",className:`absolute inset-x-0 flex flex-col items-center justify-center gap-2 bg-card/95 p-4 text-center text-[12px] text-ink-secondary ${S?"bottom-0":"inset-y-0"}`,children:[!S&&e.jsx(Fe,{size:22}),e.jsxs("span",{children:[S?r("computer.preview.paused"):r("computer.preview.cantConnect")," ",h]}),e.jsx("button",{type:"button",onClick:()=>C(!S),className:"rounded-md bg-control px-3 py-1.5 text-ink hover:bg-raised-hover",children:r("computer.preview.retry")})]})]})}const ks={available:!1,devices:[]};function js(){const t=window.ogb?.androidDevice,[c,l]=a.useState(ks),d=en();return a.useEffect(()=>{if(!t||!d)return;let p=!0;const b=async()=>{try{const w=await t.status();p&&l(w)}catch(w){p&&l({available:!1,devices:[],reasonCode:"adb-failed",message:w instanceof Error?w.message:String(w)})}};b();const E=window.setInterval(()=>{b()},2e3);return()=>{p=!1,window.clearInterval(E)}},[t,d]),c}function kt(t){return t.model==="Android device"?t.serial:t.model}function Ns({status:t}){const c=window.ogb?.androidDevice,l=en(),d=t.devices.filter(u=>u.state==="device"),[p,b]=a.useState(d[0]?.serial??t.devices[0]?.serial??""),[E,w]=a.useState(null),[f,C]=a.useState({width:0,height:0}),[z,N]=a.useState(null),j=a.useRef(null),T=a.useRef(null),S=a.useRef({x:0,y:0,timer:null}),h=t.devices.find(u=>u.serial===p)??t.devices[0],R=h?.serial,O=h?.state;a.useEffect(()=>{!h&&t.devices[0]&&b(t.devices[0].serial),h&&!t.devices.some(u=>u.serial===h.serial)&&b(t.devices[0]?.serial??"")},[h,t.devices]),a.useEffect(()=>{if(!c||!R||O!=="device"||!l){if(!l)return;w(null);return}let u=!0,v=null;const A=async()=>{try{const s=await c.frame(R);u&&(w(s.dataUrl),N(null))}catch(s){u&&N(s instanceof Error?s.message:String(s))}finally{u&&(v=window.setTimeout(()=>{A()},850))}};return A(),()=>{u=!1,v!==null&&window.clearTimeout(v)}},[c,R,O,l]),a.useEffect(()=>()=>{S.current.timer&&clearTimeout(S.current.timer)},[]);const D=u=>{!c||!h||h.state!=="device"||c.input(h.serial,u).catch(v=>{N(v instanceof Error?v.message:String(v))})},o=(u,v=!1)=>{if(!j.current||!f.width||!f.height)return null;const s=u.currentTarget.getBoundingClientRect(),le=Math.min(s.width/f.width,s.height/f.height),je=f.width*le,Q=f.height*le,q=s.left+(s.width-je)/2,F=s.top+(s.height-Q)/2,H=(u.clientX-q)/je,ce=(u.clientY-F)/Q;return v?{x:Math.max(0,Math.min(1,H)),y:Math.max(0,Math.min(1,ce))}:H>=0&&H<=1&&ce>=0&&ce<=1?{x:H,y:ce}:null},B=u=>{if(u.metaKey||u.ctrlKey||u.altKey)return;const v={ArrowDown:"down",ArrowLeft:"left",ArrowRight:"right",ArrowUp:"up",Backspace:"delete",Delete:"delete",Enter:"enter",Escape:"back",Tab:"tab"};v[u.key]?(u.preventDefault(),D({type:"key",key:v[u.key]})):/^[A-Za-z0-9 _.,@-]$/.test(u.key)&&(u.preventDefault(),D({type:"text",text:u.key}))},_=u=>{if(!f.width||!f.height)return;u.preventDefault();const v=S.current;v.x+=u.deltaX,v.y+=u.deltaY,v.timer&&clearTimeout(v.timer),v.timer=setTimeout(()=>{const A=Math.abs(v.x)>Math.abs(v.y),s=A?v.x:v.y;if(v.x=0,v.y=0,v.timer=null,Math.abs(s)<2)return;const le=Math.max(.18,Math.min(.45,Math.abs(s)/500)),je=s>0?-1:1,Q=A?{x:.5,y:.5}:{x:.5,y:.65},q=A?{x:Q.x+je*le,y:Q.y}:{x:Q.x,y:Q.y+je*le};D({type:"swipe",fromX:Q.x,fromY:Q.y,toX:q.x,toY:q.y,durationMs:260,width:f.width,height:f.height})},80)};if(!h)return null;const G=h.state==="device";return e.jsxs("div",{className:"space-y-3 pb-5",children:[e.jsxs("div",{className:"rounded-xl bg-card p-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 text-[15px] font-medium text-ink",children:[e.jsx(Vn,{size:16,className:"text-success"})," ",kt(h)]}),e.jsx("div",{className:"mt-1 text-[12px] leading-relaxed text-ink-secondary",children:r("computer.android.usbSubtitle")})]}),e.jsxs("span",{className:"flex shrink-0 items-center gap-1 text-[11px] text-success",children:[e.jsx(nr,{size:12})," ",r("computer.android.usb")]})]}),t.devices.length>1&&e.jsx("select",{value:h.serial,onChange:u=>b(u.target.value),className:"mt-3 w-full rounded-lg border border-hairline/40 bg-inset px-3 py-2 text-[12px] text-ink",children:t.devices.map(u=>e.jsxs("option",{value:u.serial,children:[kt(u)," · ",u.state]},u.serial))})]}),G?e.jsxs(e.Fragment,{children:[e.jsx("div",{role:"application","aria-label":r("computer.android.screenAria",{name:kt(h)}),tabIndex:0,onKeyDown:B,onWheel:_,onPointerDown:u=>{const v=o(u);v&&(u.currentTarget.setPointerCapture(u.pointerId),T.current={point:v,at:performance.now()})},onPointerUp:u=>{const v=T.current,A=o(u,!0);if(T.current=null,!v||!A)return;Math.hypot(A.x-v.point.x,A.y-v.point.y)<.012?D({type:"tap",...A,...f}):D({type:"swipe",fromX:v.point.x,fromY:v.point.y,toX:A.x,toY:A.y,durationMs:performance.now()-v.at,...f}),u.currentTarget.focus()},onPointerCancel:()=>{T.current=null},className:"mx-auto flex h-[520px] w-full touch-none cursor-pointer items-center justify-center overflow-hidden overscroll-none rounded-[28px] bg-black outline-none ring-1 ring-white/10 focus:ring-2 focus:ring-accent",children:E?e.jsx("img",{ref:j,src:E,alt:r("computer.android.screenAlt",{name:kt(h)}),draggable:!1,onLoad:u=>{C({width:u.currentTarget.naturalWidth,height:u.currentTarget.naturalHeight})},className:"pointer-events-none h-full w-full select-none object-contain"}):e.jsx(U,{size:20,className:"animate-spin text-ink-secondary"})}),e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[e.jsxs("button",{onClick:()=>D({type:"key",key:"back"}),className:"flex items-center justify-center gap-1.5 rounded-lg bg-raised py-2 text-[12px] text-ink hover:bg-raised-hover",children:[e.jsx(Fn,{size:13})," ",r("computer.android.back")]}),e.jsxs("button",{onClick:()=>D({type:"key",key:"home"}),className:"flex items-center justify-center gap-1.5 rounded-lg bg-raised py-2 text-[12px] text-ink hover:bg-raised-hover",children:[e.jsx(rr,{size:12})," ",r("computer.android.home")]}),e.jsxs("button",{onClick:()=>D({type:"key",key:"recent"}),className:"flex items-center justify-center gap-1.5 rounded-lg bg-raised py-2 text-[12px] text-ink hover:bg-raised-hover",children:[e.jsx(Zt,{size:13})," ",r("computer.android.recent")]})]}),e.jsx("div",{className:"text-center text-[11px] leading-relaxed text-ink-secondary",children:r("computer.android.hint")})]}):e.jsx("div",{className:"rounded-xl border border-warning/25 bg-warning/10 p-4 text-[12px] leading-relaxed text-warning",children:h.state==="unauthorized"?r("computer.android.unauthorized"):r("computer.android.badState",{state:h.state})}),z&&e.jsx("div",{className:"rounded-lg border border-danger/30 bg-danger/10 px-3 py-2 text-[12px] text-danger",children:z}),e.jsxs("div",{className:"rounded-xl bg-card p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-[13px] font-medium text-ink",children:[e.jsx(xs,{size:15,className:"text-accent"})," ",r("computer.android.setupTitle")]}),e.jsxs("ol",{className:"mt-2 list-decimal space-y-1.5 pl-4 text-[11.5px] leading-relaxed text-ink-secondary",children:[e.jsx("li",{children:r("computer.android.step1")}),e.jsx("li",{children:r("computer.android.step2").split(/(\{buildNumber\}|\{usbDebugging\})/).map((u,v)=>u==="{buildNumber}"||u==="{usbDebugging}"?e.jsx("span",{className:"text-ink",children:r(u==="{buildNumber}"?"computer.android.buildNumber":"computer.android.usbDebugging")},v):u)}),e.jsxs("li",{children:[r("computer.android.step3a")," ",e.jsx("span",{className:"text-ink",children:r("computer.android.allowUsbDebugging")})," ",r("computer.android.step3b")]})]}),e.jsx("div",{className:"mt-2 text-[11px] leading-relaxed text-ink-secondary",children:r("computer.android.agentNote")}),e.jsx("div",{className:"mt-2 rounded-lg bg-inset px-3 py-2 text-[11px] leading-relaxed text-ink-secondary",children:r("computer.android.harnessNote")})]})]})}const Ze=t=>Number(t.altKey)+Number(t.ctrlKey)*2+Number(t.metaKey)*4+Number(t.shiftKey)*8,Ss=new Set(["Alt","Control","Meta","Shift"]);function _n(t,c,l,d){const p=c*l/t;return Math.abs(p-d)<=Math.max(1,l/t)?{width:l,height:d}:{width:l,height:Math.round(p)}}function Cs(t,c,l,d,p,b,E,w=!1){if(![t.width,t.height,c,l,d,p].every(h=>Number.isFinite(h)&&h>0)||![b,E].every(Number.isFinite))return null;const{width:f,height:C}=_n(c,l,d,p),z=Math.min(t.width/c,t.height/l),N=c*z,j=l*z,T=b-t.left-(t.width-N)/2,S=E-t.top-(t.height-j)/2;return!w&&(T<0||S<0||T>=N||S>=j)?null:{x:Math.max(0,Math.min(f-1,T*f/N)),y:Math.max(0,Math.min(C-1,S*C/j))}}function Es(t){const c=new Map;return{send(l){const p=l.type==="input_keyboard"?`key:${l.code||l.key}`:`mouse:${l.button}`;if((l.eventType==="keyDown"||l.eventType==="mousePressed")&&c.set(p,{...l}),(l.eventType==="keyUp"||l.eventType==="mouseReleased")&&c.delete(p),l.eventType==="mouseMoved")for(const b of c.values())b.type==="input_mouse"&&(b.x=l.x,b.y=l.y);t(l)},release(){const l=[...c.values()].reverse();c.clear();for(const{text:d,...p}of l)t({...p,eventType:p.type==="input_keyboard"?"keyUp":"mouseReleased",modifiers:0})}}}function Rs({frame:t,width:c,height:l,driving:d,input:p,acknowledge:b,onDecodeError:E,onReturnToToolbar:w}){const f=a.useRef(null),C=a.useRef(""),z=a.useRef(-1),N=t.metadata?.deviceWidth??c,j=t.metadata?.deviceHeight??l,T=`data:image/${t.format==="png"?"png":"jpeg"};base64,${t.data}`,S=a.useMemo(()=>Es(p),[p]),h=S.send,R=a.useRef(!1);a.useLayoutEffect(()=>(d||S.release(),S.release),[d,S]),a.useEffect(()=>(window.addEventListener("blur",S.release),()=>window.removeEventListener("blur",S.release)),[S]);const O=()=>{if(f.current?.complete&&f.current.naturalWidth>0&&f.current.currentSrc===T){if(f.current.currentSrc===C.current&&t.seq===z.current)return;C.current=f.current.currentSrc,z.current=t.seq,b(t.seq)}};a.useEffect(()=>{const o=requestAnimationFrame(O);return()=>cancelAnimationFrame(o)},[t]);const D=(o,B,_=!1)=>{const G=f.current;return!G?.complete||G.currentSrc!==T?null:Cs(G.getBoundingClientRect(),G.naturalWidth,G.naturalHeight,N,j,o,B,_)};return a.useEffect(()=>{const o=f.current;if(!o||!d)return;const B=_=>{_.preventDefault();const G=D(_.clientX,_.clientY);if(!G)return;const u=_.deltaMode===2?_n(o.naturalWidth,o.naturalHeight,N,j).height:0,v=_.deltaMode===1?16:_.deltaMode===2?u:1,A=s=>Math.max(-1e4,Math.min(1e4,s*v));h({type:"input_mouse",eventType:"mouseWheel",...G,deltaX:A(_.deltaX),deltaY:A(_.deltaY),modifiers:Ze(_)})};return o.addEventListener("wheel",B,{passive:!1}),()=>o.removeEventListener("wheel",B)},[d,h,N,j,T]),e.jsx(e.Fragment,{children:e.jsx("img",{ref:f,src:T,alt:"Live bot browser",draggable:!1,tabIndex:d?0:-1,title:d?"Shift+Escape returns to the browser address bar.":void 0,"aria-description":d?r("browser.viewport.keysHint"):void 0,"aria-keyshortcuts":d?"Shift+Escape":void 0,className:`block h-full w-full object-contain select-none outline-none focus:ring-2 focus:ring-inset focus:ring-accent ${d?"cursor-default touch-none":"cursor-not-allowed"}`,onLoad:O,onError:E,onBlur:()=>{R.current=!1,S.release()},onContextMenu:o=>{d&&o.preventDefault()},onPointerDown:o=>{if(!d)return;const B=D(o.clientX,o.clientY);B&&(o.preventDefault(),o.currentTarget.focus(),o.currentTarget.setPointerCapture(o.pointerId),R.current=!0,h({type:"input_mouse",eventType:"mousePressed",...B,button:o.button===2?"right":o.button===1?"middle":"left",clickCount:Math.min(3,o.detail||1),modifiers:Ze(o)}))},onPointerUp:o=>{if(!d)return;o.preventDefault();const B=D(o.clientX,o.clientY,o.currentTarget.hasPointerCapture(o.pointerId));if(!B){S.release();return}h({type:"input_mouse",eventType:"mouseReleased",...B,button:o.button===2?"right":o.button===1?"middle":"left",clickCount:Math.min(3,o.detail||1),modifiers:Ze(o)})},onPointerCancel:S.release,onPointerMove:o=>{if(!d)return;const B=D(o.clientX,o.clientY,o.currentTarget.hasPointerCapture(o.pointerId));B&&h({type:"input_mouse",eventType:"mouseMoved",...B,button:o.buttons&1?"left":o.buttons&2?"right":o.buttons&4?"middle":"none",modifiers:Ze(o)})},onKeyDown:o=>{if(!(!d||o.nativeEvent.isComposing)){if(o.key==="Escape"&&o.shiftKey){o.preventDefault(),o.stopPropagation(),S.release(),w();return}o.key==="Tab"&&!R.current||(Ss.has(o.key)||(R.current=!0),!((o.metaKey||o.ctrlKey)&&o.key.toLowerCase()==="v")&&(o.preventDefault(),h({type:"input_keyboard",eventType:"keyDown",key:o.key,code:o.code,windowsVirtualKeyCode:o.keyCode,modifiers:Ze(o),...o.key.length===1&&!o.metaKey&&!o.ctrlKey&&!o.altKey?{text:o.key}:{}})))}},onKeyUp:o=>{if(!(!d||(o.metaKey||o.ctrlKey)&&o.key.toLowerCase()==="v")){if(o.key==="Escape"&&o.shiftKey){o.preventDefault(),o.stopPropagation();return}o.key==="Tab"&&!R.current||(o.preventDefault(),h({type:"input_keyboard",eventType:"keyUp",key:o.key,code:o.code,windowsVirtualKeyCode:o.keyCode,modifiers:Ze(o)}))}},onPaste:o=>{d&&(o.preventDefault(),R.current=!0,h({type:"input_keyboard",eventType:"char",text:o.clipboardData.getData("text/plain").slice(0,4096)}))}})})}const jt=t=>t.type==="input_mouse"&&["mouseMoved","mouseWheel"].includes(String(t.eventType)),Xt=t=>t.type==="input_mouse"&&t.eventType==="mouseReleased"||t.type==="input_keyboard"&&t.eventType==="keyUp",Nt=t=>typeof t=="number"&&Number.isFinite(t)?t:0,Tn=t=>Math.max(-1e4,Math.min(1e4,t));function Is(t,c){let l=[],d=null,p=0,b=!1;const E=f=>{l=l.filter(Xt),b||(b=!0,c(f))},w=()=>{if(d||!l.length)return;const f=p;d=(async()=>{for(;f===p&&l.length;){const C=l.shift();try{await t(C)}catch(z){f===p&&E(z)}}})().finally(()=>{d=null,w()})};return{enqueue(f){if(b&&!Xt(f))return;const C=l.at(-1);if(C&&jt(f)&&C.type===f.type&&C.eventType===f.eventType&&C.modifiers===f.modifiers&&C.button===f.button){l[l.length-1]=f.eventType==="mouseWheel"?{...f,deltaX:Tn(Nt(C.deltaX)+Nt(f.deltaX)),deltaY:Tn(Nt(C.deltaY)+Nt(f.deltaY))}:{...f};return}if(l.length>=32){if(jt(f))return;const z=l.findIndex(jt);if(z>=0)l.splice(z,1);else if(E(new Error(r("browser.input.tooSlow"))),!Xt(f)||l.length>=32)return}l.push({...f}),w()},async drain(){for(l=l.filter(f=>!jt(f));d||l.length;)w(),await d},async settle(){for(;d||l.length;)w(),await d},size(){return l.length+(d?1:0)},clear(){p++,l=[],b=!1},stopped(){return b}}}const Ts=8e3,Ps=300,zs=16,$n=new Set(["Alt","Control","Meta","Shift"]),As=new Set(["Backspace","Enter","Tab","Escape","Delete","ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Home","End","PageUp","PageDown"]),Ds=new Set(["navigate","tab-new"]);function Yt(t){if("command"in t)return!0;const{eventType:c,key:l}=t.input;return c==="mousePressed"||c==="mouseWheel"||c==="char"||c==="keyDown"&&!$n.has(String(l))}const Jt=({type:t,code:c,key:l,button:d})=>t==="input_keyboard"?`key:${c||l}`:`mouse:${d}`,Pn=({eventType:t})=>t==="keyDown"||t==="mousePressed",zn=({eventType:t})=>t==="keyUp"||t==="mouseReleased";function Ms(t){if(t.type!=="input_keyboard")return!0;const c=String(t.key);return $n.has(c)?!0:As.has(c)?!1:!t.modifiers||t.modifiers===8&&[...c].length===1}const Os=t=>t?.waited===!0;function Ls(t){let c="bot",l="",d=[],p=!1,b=!1,E=!1,w=!1,f=0,C=Promise.resolve(),z,N;const j=new Set,T=new Set,S=u=>{l=u,t.onTakeStatus(u)},h=u=>{Pn(u)&&Ms(u)?j.add(Jt(u)):zn(u)&&j.delete(Jt(u))},R=()=>!b&&!E&&!p&&!j.size&&!t.busy()&&(c==="held"||c==="bot"&&t.owned()),O=()=>{clearTimeout(z),z=b?void 0:setTimeout(()=>{z=void 0,o()},w?0:Ts)},D=()=>{c="releasing",l==="stale"&&S(""),C=C.then(()=>b?void 0:t.release()).catch(()=>{}).then(()=>{c==="releasing"&&(c="bot")})},o=async()=>{if(!R())return;const u=f;await t.queue.drain(),u===f&&R()&&D()},B=()=>{const u=d.filter(A=>"command"in A&&Ds.has(String(A.command.type))),v=d.some(A=>!u.includes(A)&&Yt(A));d=u;for(const A of j)T.add(A);return j.clear(),v},_=async()=>{p=!0;try{for(let u=d.shift();u&&!b;u=d.shift())"command"in u?await t.command(u.command):(t.queue.enqueue(u.input),t.queue.size()>=zs&&await t.queue.settle())}finally{p=!1,d=[]}},G=()=>{c="taking",t.onError(""),S("pending"),clearTimeout(N),N=setTimeout(()=>{!b&&c==="taking"&&S("slow")},Ps),C=C.then(async()=>{if(b)return;const u=await t.take().then(v=>({reply:v}),v=>(b||t.onError(v instanceof Error?v.message:String(v)),null));clearTimeout(N),!b&&(u?(c="held",S(Os(u.reply)&&B()?"stale":""),await _()):(S(""),c="bot",d=[],j.clear()),O())}).catch(()=>{})};return{interact(u){if(b)return;if("input"in u){const A=Jt(u.input);if(zn(u.input)&&T.delete(A))return;Pn(u.input)&&T.delete(A)}const v=c==="taking"||p;if(c!=="held"&&!v){if(!Yt(u))return;if("input"in u&&t.queue.stopped()){t.onHalted();return}}if(!("command"in u&&v&&d.some(A=>"command"in A))){if(Yt(u)&&(w=!1,l==="stale"&&S("")),"input"in u&&h(u.input),f++,O(),c==="held"&&!v){"input"in u?t.queue.enqueue(u.input):t.command(u.command).then(O);return}d.push(u),v||G()}},observe(){!b&&z===void 0&&t.owned()&&O()},handBack(){b||(w=!0,O())},hold(u){b||E===u||(E=u,u||O())},leave(){!R()||t.queue.size()||(c="releasing",t.release().catch(()=>{}))},close(){b=!0,clearTimeout(z),clearTimeout(N),d=[],j.clear(),T.clear()}}}const Ne="rounded-md p-1.5 text-ink-secondary hover:bg-inset hover:text-ink disabled:opacity-40 disabled:cursor-not-allowed",Vs=[1e3,2e3,4e3,8e3,15e3],An="Connection interrupted. Reconnecting the browser view…",Gt={held:!1,controlling:!1,owned:!1};function Fs({bot:t}){const{state:c}=Tt(),[l,d]=a.useState(0),[p,b]=a.useState(null),[E,w]=a.useState([]),[f,C]=a.useState(""),[z,N]=a.useState(!1),[j,T]=a.useState({held:!1,controlling:!1,owned:!1}),[S,h]=a.useState(!1),[R,O]=a.useState(""),[D,o]=a.useState(!1),[B,_]=a.useState(!1),[G,u]=a.useState({width:1280,height:720}),[v,A]=a.useState(""),[s,le]=a.useState(!1),[je,Q]=a.useState(!1),q=a.useRef(""),F=a.useRef(0),H=a.useRef(null),ce=a.useRef(null),Se=a.useRef(null),$e=a.useRef(null),tt=a.useRef(null),se=a.useRef(null),ne=a.useRef(null),Ce=a.useRef(Gt),Ae=a.useRef(""),Ee=a.useRef(!1),De=a.useRef(0),mt=a.useRef(""),m=t.browserProfile==="guest"?"Temporary browser":c.config?.browserProfiles?.find(g=>g.id===t.browserProfile)?.name??`${t.name}’s own browser`;a.useEffect(()=>{D?$e.current?.showModal():$e.current?.close()},[D]),a.useEffect(()=>{ne.current?.hold(B),B?tt.current?.showModal():tt.current?.close()},[B]);const k=a.useCallback(async(g,X=q.current)=>{if(!X)throw new Error("Open the browser connection first.");return W(`/api/bots/${encodeURIComponent(t.id)}/browser/action`,{method:"POST",body:JSON.stringify({...g,viewerId:X}),timeoutMs:12e4})},[t.id]),Re=a.useCallback(g=>{Ce.current.held&&!Ce.current.owned||ne.current?.interact(g)},[]),nt=a.useCallback(g=>Re({input:g}),[Re]),ie=g=>Re({command:g}),ae=a.useCallback(()=>{F.current++,De.current=0,q.current="",se.current?.clear(),se.current=null,ne.current?.close(),ne.current=null,H.current=null,d(g=>g+1)},[]);a.useEffect(()=>{const g=++F.current,X=()=>F.current===g,ue=JSON.stringify([t.id,t.browserProfile]);mt.current!==ue&&(mt.current=ue,De.current=0);let Oe=!1,oe;q.current="",H.current=null,Ae.current="",Ee.current=!1,b(null),w([]),C(""),N(!1),O(""),Q(!1),T({held:!1,controlling:!1,owned:!1}),h(!1),Ce.current=Gt,A("");const Xe=new EventSource(`/api/bots/${encodeURIComponent(t.id)}/browser/live`),de=(V,Z)=>Xe.addEventListener(V,ge=>{if(!(Oe||!X()))try{Z(JSON.parse(ge.data))}catch{}});return de("waiting",()=>{q.current||Q(!0)}),de("ready",V=>{if(typeof V.viewerId!="string"||!V.viewerId)return;Q(!1);const Z=V.viewerId;q.current=Z;const ge=Is(async me=>{X()&&q.current===Z&&await k(me,Z)},me=>{!X()||q.current!==Z||(Ae.current=me instanceof Error?me.message:String(me),O(Ae.current))});se.current=ge,ne.current=Ls({queue:ge,take:()=>k({type:"take"},Z),release:()=>k({type:"release"},Z),command:me=>He(me),busy:()=>H.current!==null,owned:()=>Ce.current.owned,onTakeStatus:A,onError:O,onHalted:()=>O(Ae.current)}),N(!0)}),de("heartbeat",()=>{De.current=0}),de("frame",V=>{q.current&&b({...V,viewerId:q.current,generation:g})}),de("tabs",V=>{if(!Array.isArray(V.tabs))return;w(V.tabs);const Z=V.tabs.find(ge=>ge.active);Z&&!Ee.current&&C(Z.url==="about:blank"?"":Z.url)}),de("url",V=>{typeof V.url=="string"&&!Ee.current&&C(V.url==="about:blank"?"":V.url)}),de("status",V=>{V.viewportWidth>0&&V.viewportHeight>0&&u({width:V.viewportWidth,height:V.viewportHeight})}),de("control",V=>{Ce.current=V,T(V),V.held&&!V.owned&&(b(null),w([]),C("")),ne.current?.observe()}),Xe.addEventListener("error",V=>{if(Oe||!X())return;Oe=!0;let Z="Browser connection ended. Reconnect to continue watching.",ge=!(V instanceof MessageEvent);if(V instanceof MessageEvent)try{const ve=JSON.parse(V.data);Z=ve.message||Z,ge=ve.retryable===!0}catch{}const me=ge?Vs[De.current]:void 0;me!==void 0&&(De.current++,Z=An,oe=setTimeout(()=>{X()&&(F.current++,d(ve=>ve+1))},me)),O(Z),Q(!1),N(!1),b(null),T({held:!1,controlling:!1,owned:!1}),Ce.current=Gt,A(""),q.current="",se.current?.clear(),se.current=null,ne.current?.close(),ne.current=null,Xe.close()}),()=>{Oe=!0,clearTimeout(oe),X()&&(ne.current?.leave(),ne.current?.close(),ne.current=null,F.current++,q.current="",H.current=null,se.current?.clear(),se.current=null),Xe.close()}},[t.id,t.browserProfile,l,k]),a.useEffect(()=>{const g=()=>le(!!ce.current&&document.fullscreenElement===ce.current);return document.addEventListener("fullscreenchange",g),()=>document.removeEventListener("fullscreenchange",g)},[]);const rt=()=>{const g=!!ce.current&&document.fullscreenElement===ce.current;(g?document.exitFullscreen():ce.current?.requestFullscreen())?.catch(()=>O(g?"Could not leave full screen. Press Esc instead.":"Full screen is unavailable in this browser."))},He=async g=>{if(H.current!==null)return;const X=q.current,ue=F.current,Oe=se.current;H.current=ue,h(!0),O("");try{if(await Oe?.drain(),F.current!==ue||q.current!==X)return;await k(g,X),se.current?.stopped()&&F.current===ue&&O(Ae.current),F.current===ue&&g.type==="restart"&&ae()}catch(oe){F.current===ue&&O(oe instanceof Error?oe.message:String(oe))}finally{F.current===ue&&H.current===ue&&(H.current=null,h(!1))}},M=j.held&&!j.owned,Me=z&&!M&&!S,re=Me&&j.owned&&j.controlling,he=v==="pending"||v==="slow",K=Me&&!he,Ie=R===An,Te="flex max-w-full items-center gap-1.5 whitespace-nowrap rounded-full border bg-menu px-2.5 py-1 text-[11px] shadow-sm sm:text-[12px]";return e.jsxs("div",{ref:ce,className:"flex min-h-0 flex-1 flex-col overflow-hidden rounded-2xl border border-hairline/40 bg-card text-ink",children:[e.jsxs("div",{className:"flex min-h-12 items-center gap-1 px-2 pt-1.5",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1 overflow-x-auto",children:[E.length?E.map(g=>e.jsxs("div",{className:`flex max-w-52 shrink-0 items-center gap-1 rounded-xl px-1 text-[12px] ${g.active?"bg-inset text-ink":"text-ink-secondary"}`,children:[e.jsx(We,{size:13,className:"ml-1.5 shrink-0 opacity-60"}),e.jsx("button",{className:"truncate px-1 py-2 text-left disabled:cursor-default",disabled:!K,onClick:()=>ie({type:"tab-select",tabId:g.tabId}),title:g.title||g.url,children:g.title||"New tab"}),e.jsx("button",{className:Ne,"aria-label":`Close ${g.title||"tab"}`,disabled:!K,onClick:()=>ie({type:"tab-close",tabId:g.tabId}),children:e.jsx(St,{size:13})})]},g.tabId)):e.jsxs("div",{className:"flex items-center gap-2 rounded-xl bg-inset px-3 py-2 text-[12px] text-ink-secondary",children:[e.jsx(We,{size:13}),"New tab"]}),e.jsx("button",{className:`${Ne} shrink-0`,disabled:!K,"aria-label":"New tab",title:"New tab",onClick:()=>ie({type:"tab-new"}),children:e.jsx(sr,{size:17})})]}),e.jsx("button",{className:Ne,title:s?"Exit full screen":"Full screen","aria-label":s?"Exit full screen":"Full screen",onClick:rt,children:s?e.jsx(us,{size:16}):e.jsx(It,{size:16})}),e.jsx("button",{className:`${Ne} rounded-xl bg-inset p-2`,title:`Browser profile: ${m}`,"aria-label":"Browser profiles","aria-expanded":D,onClick:()=>{ne.current?.handBack(),o(!0)},children:e.jsx(bs,{size:16})})]}),e.jsxs("form",{className:"flex h-12 items-center gap-1 border-b border-hairline/40 px-2",onSubmit:g=>{g.preventDefault(),K&&f.trim()&&ie({type:"navigate",url:/^https?:\/\//i.test(f.trim())?f.trim():`https://${f.trim()}`})},children:[e.jsxs("div",{className:"flex shrink-0 items-center",children:[e.jsx("button",{type:"button",className:Ne,disabled:!K,"aria-label":"Back",onClick:()=>ie({type:"back"}),children:e.jsx(Fn,{size:17})}),e.jsx("button",{type:"button",className:Ne,disabled:!K,"aria-label":"Forward",onClick:()=>ie({type:"forward"}),children:e.jsx(ar,{size:17})}),e.jsx("button",{type:"button",className:Ne,disabled:!K,"aria-label":"Reload page",onClick:()=>ie({type:"reload"}),children:e.jsx(Wr,{size:17})})]}),e.jsx("input",{ref:Se,"aria-label":"Browser address",readOnly:!K,value:f,onChange:g=>C(g.target.value),onFocus:g=>{Ee.current=!0,K&&g.target.select()},onBlur:()=>{Ee.current=!1},placeholder:z?"about:blank":"Connecting…",spellCheck:!1,className:"mx-1 min-w-0 flex-1 rounded-lg bg-transparent px-2 py-1.5 text-center text-[12px] outline-none placeholder:text-ink-secondary focus:bg-inset focus:text-left"}),e.jsxs("details",{className:"relative shrink-0",children:[e.jsx("summary",{className:`${Ne} list-none cursor-pointer [&::-webkit-details-marker]:hidden`,"aria-label":"Browser menu",title:"Browser menu",children:e.jsx(ls,{size:17})}),e.jsxs("div",{className:"absolute right-0 top-full z-20 mt-2 flex w-44 flex-col rounded-xl border border-hairline/50 bg-card p-1.5 text-[12px] shadow-xl",children:[e.jsx("button",{type:"button",className:"rounded-md px-3 py-2 text-left hover:bg-inset disabled:opacity-40",disabled:!re,onClick:g=>{g.currentTarget.closest("details")?.removeAttribute("open"),_(!0)},children:"Type or paste text…"}),e.jsx("button",{type:"button",className:"rounded-md px-3 py-2 text-left hover:bg-inset",onClick:g=>{g.currentTarget.closest("details")?.removeAttribute("open"),ae()},children:"Reconnect view"}),e.jsx("button",{type:"button",className:"rounded-md px-3 py-2 text-left hover:bg-inset disabled:opacity-40",disabled:!z||S||he,onClick:g=>{g.currentTarget.closest("details")?.removeAttribute("open"),window.confirm("Restart this profile’s browser? Open tabs will close. Saved logins are kept. Stop any bots using it first.")&&He({type:"restart"})},children:"Restart browser…"})]})]})]}),R&&e.jsxs("div",{role:Ie?"status":"alert",className:`flex items-center justify-between gap-2 border-b border-hairline/30 px-3 py-2 text-[12px] ${Ie?"text-ink-secondary":"text-danger"}`,children:[e.jsx("span",{children:R}),!z&&e.jsx("button",{className:"shrink-0 underline",onClick:ae,children:"Reconnect"})]}),e.jsxs("div",{className:"relative min-h-0 flex-1 overflow-hidden bg-inset/40",children:[p?e.jsx(Rs,{frame:p,...G,driving:Me,input:nt,onReturnToToolbar:()=>Se.current?.focus(),acknowledge:g=>{F.current===p.generation&&q.current===p.viewerId&&k({type:"ack",seq:g},p.viewerId).catch(()=>{})},onDecodeError:()=>{F.current===p.generation&&q.current===p.viewerId&&O("A browser frame could not be decoded. Close and reopen the panel to reconnect.")}}):e.jsxs("div",{className:"flex min-h-64 flex-col items-center justify-center gap-3 p-6 text-center text-[13px] text-ink-secondary",children:[z&&M?e.jsx(_e,{size:24}):R&&!Ie?e.jsx(We,{size:24}):e.jsx(U,{size:24,className:"animate-spin"}),e.jsx("span",{children:M?"Live view paused for human control":Ie?"Reconnecting…":R?"Browser disconnected":je?r("browser.live.botBusy",{name:t.name}):"Opening the live browser…"})]}),e.jsx("div",{role:"status",className:"pointer-events-none absolute inset-x-0 top-2 flex justify-center px-3",children:v==="slow"?e.jsxs("span",{className:`${Te} border-hairline text-ink-secondary`,children:[e.jsx(U,{size:13,className:"shrink-0 animate-spin","aria-hidden":"true"}),e.jsx("span",{className:"truncate",children:r("browser.control.waiting",{name:t.name})})]}):v==="stale"?e.jsxs("span",{className:`${Te} border-accent-border text-accent-text`,children:[e.jsx(_e,{size:13,className:"shrink-0","aria-hidden":"true"}),e.jsx("span",{className:"truncate",children:r("browser.control.stale",{name:t.name})})]}):!v&&j.owned&&j.controlling?e.jsxs("span",{className:`${Te} border-accent-border text-accent-text`,"aria-description":r("browser.control.yoursHint",{name:t.name}),children:[e.jsx(_e,{size:13,className:"shrink-0","aria-hidden":"true"}),e.jsx("span",{className:"truncate",children:r("browser.control.yours")})]}):null})]}),e.jsxs("dialog",{ref:$e,onClose:()=>o(!1),onClick:g=>{g.target===g.currentTarget&&o(!1)},className:"m-auto w-[min(420px,calc(100%-32px))] max-h-[80vh] overflow-auto rounded-2xl border border-hairline/50 bg-card p-5 text-ink shadow-2xl backdrop:bg-black/40",children:[e.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[e.jsx("h2",{className:"text-[15px] font-medium",children:"Browser profiles"}),e.jsx("button",{className:Ne,"aria-label":"Close browser profiles",onClick:()=>o(!1),children:e.jsx(St,{size:16})})]}),(M||j.owned&&(S||he))&&e.jsx("p",{className:"mb-3 text-[12px] text-ink-secondary",children:r(M?"browser.profiles.heldElsewhere":"browser.profiles.busy")}),e.jsx(Qr,{bot:t,disabled:S||j.held,onProfileChanged:()=>{o(!1),ae()}})]}),e.jsxs("dialog",{ref:tt,onClose:()=>_(!1),className:"m-auto w-[min(420px,calc(100%-32px))] rounded-2xl border border-hairline/50 bg-card p-5 text-ink shadow-2xl backdrop:bg-black/40",children:[e.jsxs("div",{className:"mb-3 flex items-center justify-between",children:[e.jsx("h2",{className:"text-[14px] font-medium",children:"Type into the selected page field"}),e.jsx("button",{className:Ne,"aria-label":"Close typing",onClick:()=>_(!1),children:e.jsx(St,{size:16})})]}),e.jsxs("form",{className:"flex flex-col gap-3",onSubmit:g=>{g.preventDefault();const X=g.currentTarget.elements.namedItem("pageText");re&&X.value&&(nt({type:"input_keyboard",eventType:"char",text:X.value}),X.value="",_(!1))},children:[e.jsx("input",{name:"pageText","aria-label":"Text for the page",autoComplete:"off",maxLength:4096,placeholder:"Type or paste text",className:"rounded-lg bg-inset px-3 py-2 text-[13px] outline-none focus:ring-1 focus:ring-accent"}),e.jsx("button",{disabled:!re,className:"self-end rounded-lg bg-accent px-4 py-2 text-[12px] text-accent-ink disabled:opacity-40",children:"Type"})]})]})]})}function _s({bot:t}){const{state:c}=Tt(),l=c.config?.browserEngine,[d,p]=a.useState(!1),[b,E]=a.useState(null),[w,f]=a.useState(null);a.useEffect(()=>{let N=!0;return W("/api/auth/session").then(j=>{N&&f(j.scopes.includes("admin"))}).catch(()=>{N&&f(!1)}),()=>{N=!1}},[]);const C=d||l?.installing===!0,z=async()=>{E(null),p(!0);try{await W("/api/browser-engine/install",{method:"POST"})}catch(N){E(N instanceof Error?N.message:String(N))}finally{p(!1)}};return w===!1?e.jsx("div",{className:"p-5 text-[13px] text-ink-secondary",children:"Only admins of this installation can view or control saved browser sessions."}):t.browser===!1?e.jsx("div",{className:"p-5 text-[13px] text-ink-secondary",children:"Enable the browser in this bot’s profile to use it."}):l?.kind==="engine"&&!C&&!l.installError?w===null?e.jsx("div",{className:"p-5 text-[13px] text-ink-secondary",children:"Loading browser…"}):e.jsx(Fs,{bot:t},t.id):e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col items-start justify-center gap-3 rounded-xl bg-card p-5",children:[e.jsx("div",{className:"text-[15px] font-medium text-ink",children:l?.kind==="engine"?"Browser installation incomplete":"Browser engine not installed"}),e.jsx("p",{className:"text-[13px] leading-relaxed text-ink-secondary",children:l?.kind==="engine"?"agent-browser is installed, but Chrome setup has not finished. Retry the browser installation.":Qt(c.config)}),l?.installable||l?.kind==="engine"?e.jsx("button",{type:"button",onClick:()=>{z()},disabled:C||w!==!0,className:"rounded-lg bg-accent px-3 py-1.5 text-[13px] font-medium text-accent-ink disabled:opacity-60",children:C?"Installing… (a one-time download of about 160 MB)":l?.kind==="engine"?"Retry browser installation":"Install the browser engine"}):null,(l?.installError||b)&&e.jsx("p",{role:"alert",className:"text-[12px] text-danger",children:b??l?.installError})]})}function Ct(t){for(const c of t?.getTracks()??[])c.stop()}function $s(t){const c=t instanceof DOMException?t.name:"";return c==="NotAllowedError"||c==="AbortError"?{ok:!1,phase:"cancelled",messageKey:"computer.screen.cancelled"}:c==="NotFoundError"||c==="NotReadableError"||c==="NotSupportedError"||c==="SecurityError"?{ok:!1,phase:"unavailable",messageKey:"computer.screen.unavailableNow"}:{ok:!1,phase:"error",messageKey:"computer.screen.error"}}async function Bs({beginIntent:t,getDisplayMedia:c}){try{if(!t())return{ok:!1,phase:"unavailable",messageKey:"computer.screen.unavailableWindow"};const l=await c({video:!0,audio:!1});return l.getVideoTracks().length===0?(Ct(l),{ok:!1,phase:"unavailable",messageKey:"computer.screen.noVideoTrack"}):{ok:!0,stream:l}}catch(l){return $s(l)}}const dt={idle:"computer.screen.idle",ended:"computer.screen.ended",unavailable:"computer.screen.unavailable"};function Ks(){const{capabilities:t,ready:c}=Pt(),l=t.screenPreview,d=t.host.platform==="linux",[p,b]=a.useState("idle"),[E,w]=a.useState(dt.idle),[f,C]=a.useState(""),z=a.useRef(null),N=a.useRef(null),j=a.useRef(0),T=a.useCallback((O,D)=>{j.current+=1;const o=N.current;N.current=null,z.current&&(z.current.srcObject=null),Ct(o),b(O),w(D)},[]);a.useEffect(()=>()=>{j.current+=1;const O=N.current;N.current=null,Ct(O)},[]);const S=async()=>{if(!l.available||!window.ogb?.beginScreenPreviewIntent||!navigator.mediaDevices?.getDisplayMedia){b("unavailable"),w(dt.unavailable);return}T("requesting","computer.screen.waiting");const O=j.current,D=await Bs({beginIntent:()=>window.ogb.beginScreenPreviewIntent(),getDisplayMedia:G=>navigator.mediaDevices.getDisplayMedia(G)});if(O!==j.current){D.ok&&Ct(D.stream);return}if(!D.ok){b(D.phase),w(D.messageKey);return}const o=D.stream,B=o.getVideoTracks()[0];N.current=o,C(B.label),B.addEventListener("ended",()=>{N.current===o&&T("ended",dt.ended)},{once:!0});const _=z.current;if(!_){T("error","computer.screen.displayFailed");return}_.srcObject=o;try{await _.play()}catch{O===j.current&&N.current===o&&T("error","computer.screen.displayFailed");return}O!==j.current||N.current!==o||(b("streaming"),w("computer.screen.active"))};if(!d)return null;const h=f||r("computer.screen.selected"),R=p==="cancelled"||p==="ended"||p==="unavailable"||p==="error";return e.jsxs("section",{className:"mt-4 rounded-xl bg-card p-4","aria-labelledby":"local-preview-title",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{id:"local-preview-title",className:"text-[15px] font-medium text-ink",children:r("computer.screen.title")}),e.jsx("div",{className:"mt-0.5 text-[12px] leading-relaxed text-ink-secondary",children:r("computer.screen.subtitle")})]}),e.jsx("span",{className:"shrink-0 rounded-full bg-raised px-2 py-1 text-[10px] font-medium text-ink-secondary",children:r("computer.screen.badge")})]}),e.jsxs("div",{className:"relative mt-3 flex aspect-[16/10] items-center justify-center overflow-hidden rounded-lg bg-panel",children:[e.jsx("video",{ref:z,autoPlay:!0,muted:!0,playsInline:!0,"aria-label":r("computer.screen.videoAria"),className:p==="streaming"?"h-full w-full object-contain":"hidden"}),p!=="streaming"&&e.jsxs("div",{className:"flex flex-col items-center gap-2 px-6 text-center text-ink-secondary",children:[p==="requesting"?e.jsx(U,{size:18,className:"animate-spin"}):e.jsx(Fe,{size:22}),e.jsx("span",{className:"text-[12px]","aria-live":"polite",children:c?r(l.available?E:dt.unavailable):r("computer.screen.checking")})]})]}),p==="streaming"&&e.jsxs("div",{className:"mt-2 flex items-center justify-between gap-3 text-[11px] text-ink-secondary",children:[e.jsx("span",{className:"truncate",title:h,children:l.interaction==="portal-picker"?h:r("vm.dest.local")}),e.jsxs("span",{className:"flex items-center gap-1.5 text-success",children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-success"})," ",r("computer.screen.sharing")]})]}),e.jsxs("button",{type:"button",disabled:p==="requesting"||!l.available&&p!=="streaming",onClick:p==="streaming"?()=>T("idle",dt.idle):()=>{S()},className:"mt-3 flex w-full items-center justify-center gap-2 rounded-lg bg-raised py-2 text-[13px] text-ink hover:bg-raised-hover disabled:cursor-not-allowed disabled:opacity-50",children:[p==="requesting"?e.jsx(U,{size:14,className:"animate-spin"}):p==="streaming"?e.jsx(or,{size:13}):R?e.jsx(Zt,{size:14}):e.jsx(Fe,{size:14}),p==="requesting"?r("computer.screen.choosing"):p==="streaming"?r("computer.screen.stop"):R?r("computer.linux.tryAgain"):l.interaction==="portal-picker"?r("computer.screen.choose"):r("computer.screen.start")]})]})}const Us="https://github.com/milind-soni/OpenMausBot/blob/main/docs/linux-desktop.md#enable-local-control";function qs(){const{capabilities:t}=Pt(),c=t.localComputer,[l,d]=a.useState(null),[p,b]=a.useState(null);if(t.host.platform!=="linux")return null;const E=l!==null||c.status==="checking"||c.status==="starting",w=c.available,f=c.reasonCode==="linux-wayland-seat-safety-blocked",C=t.host.session==="wayland",z=c.driverSource==="bundled",N=async j=>{if(window.ogb?.localControl){d(j),b(null);try{if((j==="disable"||j==="retry")&&!(await fetch("/api/local-computer/interrupt",{method:"POST"})).ok){b({key:"computer.linux.stopFailed"});return}await window.ogb.localControl[j]()}catch(T){b(T instanceof Error?T.message:String(T))}finally{d(null)}}};return e.jsxs("section",{className:"mt-4 rounded-xl bg-card p-4","aria-labelledby":"linux-local-control-title",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs("div",{id:"linux-local-control-title",className:"flex items-center gap-2 text-[15px] font-medium text-ink",children:[e.jsx(ps,{size:16,className:w?"text-success":"text-ink-secondary"}),r("computer.linux.title")]}),e.jsx("div",{className:"mt-1 text-[12px] leading-relaxed text-ink-secondary",children:r("computer.linux.meta",{session:C?"Wayland":"Xorg"})})]}),e.jsx("span",{className:Ve("shrink-0 rounded-full px-2 py-1 text-[10px] font-medium",w?"bg-success/10 text-success":f?"bg-danger/10 text-danger":c.enabled?"bg-warning/10 text-warning":"bg-raised text-ink-secondary"),children:w?r("computer.linux.ready"):f?r("computer.linux.waylandBadge"):c.enabled?r("vm.state.attention"):r("vm.dest.off")})]}),f?e.jsx("div",{className:"mt-3 rounded-lg border border-danger/20 bg-danger/5 p-3",children:e.jsxs("div",{className:"flex gap-2 text-[12px] leading-relaxed text-ink-secondary",children:[e.jsx(Wt,{size:15,className:"mt-0.5 shrink-0 text-danger"}),e.jsxs("span",{children:[r("computer.linux.waylandBefore")," ",e.jsx("strong",{className:"font-medium text-ink",children:r("computer.linux.waylandXorg")})," ",r("computer.linux.waylandAfter")]})]})}):c.enabled?e.jsxs("div",{className:"mt-3 rounded-lg bg-panel p-3 text-[12px] text-ink-secondary",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[w?e.jsx(ir,{size:15,className:"mt-0.5 shrink-0 text-success"}):E?e.jsx(U,{size:15,className:"mt-0.5 shrink-0 animate-spin"}):e.jsx(Wt,{size:15,className:"mt-0.5 shrink-0 text-warning"}),e.jsx("span",{"aria-live":"polite",children:w?r("computer.linux.readyMsg"):c.message??r("computer.linux.checking")})]}),c.driverPath&&e.jsxs("div",{className:"mt-2 break-all font-mono text-[10px] text-ink-tertiary",title:c.driverPath,children:[z?r("computer.linux.bundledDriver"):c.driverPath,c.driverVersion?` · ${c.driverVersion}`:""]})]}):e.jsx("div",{className:"mt-3 rounded-lg border border-warning/20 bg-warning/5 p-3",children:e.jsxs("div",{className:"flex gap-2 text-[12px] leading-relaxed text-ink-secondary",children:[e.jsx(Wt,{size:15,className:"mt-0.5 shrink-0 text-warning"}),e.jsxs("span",{children:[r("computer.linux.enableBefore")," ",e.jsx("strong",{className:"font-medium text-ink",children:r("vm.dest.local")})," ",r("computer.linux.enableAfter"),C&&` ${r("computer.linux.waylandInput")}`]})]})}),p&&e.jsx("div",{className:"mt-2 text-[12px] text-danger",children:typeof p=="string"?p:r(p.key)}),!f&&e.jsx("div",{className:"mt-3 flex gap-2",children:c.enabled?e.jsxs(e.Fragment,{children:[!w&&e.jsxs("button",{type:"button",disabled:E,onClick:()=>{N("retry")},className:"flex flex-1 items-center justify-center gap-2 rounded-lg bg-raised py-2 text-[13px] text-ink hover:bg-raised-hover disabled:opacity-50",children:[l==="retry"?e.jsx(U,{size:14,className:"animate-spin"}):e.jsx(Zt,{size:14}),r("computer.linux.tryAgain")]}),e.jsxs("button",{type:"button",disabled:l!==null,onClick:()=>{N("disable")},className:"flex flex-1 items-center justify-center gap-2 rounded-lg bg-raised py-2 text-[13px] text-ink hover:bg-raised-hover disabled:opacity-50",children:[l==="disable"?e.jsx(U,{size:14,className:"animate-spin"}):e.jsx(pt,{size:14}),r("computer.linux.disable")]})]}):e.jsxs("button",{type:"button",disabled:E,onClick:()=>{N("enable")},className:"flex flex-1 items-center justify-center gap-2 rounded-lg bg-accent py-2 text-[13px] font-medium text-white hover:opacity-90 disabled:opacity-50",children:[l==="enable"?e.jsx(U,{size:14,className:"animate-spin"}):e.jsx(pt,{size:14}),r("computer.linux.enable")]})}),e.jsxs("button",{type:"button",onClick:()=>window.open(Us,"_blank","noopener,noreferrer"),className:"mt-2 flex w-full items-center justify-center gap-1.5 rounded-lg py-1.5 text-[11px] text-ink-secondary hover:bg-raised hover:text-ink",children:[t.host.packaged?r("computer.linux.guide"):r("computer.linux.driverSetup")," ",e.jsx(lr,{size:11})]})]})}class te extends Error{constructor(c,l,d){super(c),this.key=c,this.problem=l,this.fallbackKey=d}key;problem;fallbackKey}function Dn(t){return t instanceof te?r(t.key,t.fallbackKey?{problem:t.problem??r(t.fallbackKey)}:void 0):t instanceof Error?t.message:t}const Mn=Fr({held:$r().optional().default(!1),helpReason:_r().nullable().optional().default(null)}).passthrough(),Bn="omb-computer-panel-width",Et=360,Rt=960,Ws=400,On=40;function Hs(){try{const t=Number(localStorage.getItem(Bn));if(Number.isFinite(t)&&t>=Et&&t<=Rt)return t}catch{}return Ws}function na({bot:t,onOpenVmWorkspace:c}){const{padClass:l}=cr(),[d,p]=a.useState(Hs),b=a.useRef(null),E=n=>{try{localStorage.setItem(Bn,String(n))}catch{}},w=n=>{b.current={x:n.clientX,width:d},n.currentTarget.setPointerCapture(n.pointerId)},f=n=>{if(!b.current)return;const i=Math.min(Rt,Math.max(Et,b.current.width+(b.current.x-n.clientX)));p(i)},C=n=>{b.current&&(b.current=null,n.currentTarget.releasePointerCapture(n.pointerId),E(d))},z=n=>{p(i=>{const x=Math.min(Rt,Math.max(Et,i+n));return E(x),x})},N=a.useRef(null),[j,T]=a.useState(null);a.useEffect(()=>{const n=N.current?.closest("aside");if(!n)return;const i=()=>T(n.offsetWidth);i();const x=new ResizeObserver(i);return x.observe(n),()=>x.disconnect()},[]);const S=n=>{if(n.ctrlKey||n.metaKey||n.altKey)return;const i=n.key==="ArrowLeft"?On:n.key==="ArrowRight"?-On:null;i===null||j===null||(n.preventDefault(),z(i))},{state:h,dispatch:R,flushBotPatches:O}=Tt(),D=t.tasks?.find(n=>n.threadId===t.threadId),o=ur(t,D),B=dr(t),_=`${t.id}:${t.threadId}:${o}:${t.cloudBackend??"box"}:${B.modelSelection.instanceId}`,[G,u]=a.useState(null),v=G?.key===_,A=o!=="auto"||v,s={...B,computer:o==="auto"?v?G.surface:void 0:o},le=`${s.id}:${s.threadId}:${s.computer}:${s.cloudBackend??"box"}`,je=a.useRef(le);je.current=le;const Q=a.useRef(null);a.useEffect(()=>()=>Q.current?.abort(),[le]);const q=!!s.busy,F=a.useCallback(n=>`/api/bots/${t.id}/${n}?threadId=${encodeURIComponent(t.threadId)}`,[t.id,t.threadId]),H=t.computer==="cloud"&&o==="cloud",ce=t.computer==="vm"&&o==="vm",{capabilities:Se,ready:$e}=Pt(),tt=Se.localComputer.available,se=Se.host.platform==="linux",ne=pr(h.instances,s),Ce=jn("local",h.config)&&mr({capabilities:Se,providerSupportsLocal:ne}),[Ae,Ee]=a.useState(null),De=xr({capabilities:Se,providerSupportsLocal:ne}),mt=fr(h.config,Se.host.platform),[m,k]=a.useState("checking"),[Re,nt]=a.useState(null),[ie,ae]=a.useState(null),[rt,He]=a.useState(null),M=s.cloudBackend??"box",Me=!!(Re&&Re.botId===s.id&&Re.computer===t.computer&&Re.cloudBackend===M&&Re.section===(s.section?.trim()??"")),re=!!(ie&&ie.botId===s.id&&ie.threadId===s.threadId&&ie.computer===s.computer&&ie.cloudBackend===M),he=re&&o==="auto"&&M==="box"&&rt?.botId===s.id&&rt.section===(s.section?.trim()??"")?rt:null,K=re&&br({computer:s.computer,cloudBackend:M,phase:m,botId:s.id,resolvedBotId:ie?.botId??null,resolvedComputer:ie?.computer??null,resolvedCloudBackend:ie?.cloudBackend??null}),Ie=a.useCallback(n=>{ae(null),He(null),k("checking"),R({type:"updateBot",botId:s.id,patch:n})},[s.id,R]);a.useEffect(()=>{let n=!0;return nt(null),O(s.id).then(i=>{n&&(i&&!hr({computer:t.computer,cloudBackend:M,persistedBot:i})||i&&(i.section?.trim()??"")!==(s.section?.trim()??"")||nt({botId:s.id,computer:t.computer,cloudBackend:M,section:s.section?.trim()??""}))}),()=>{n=!1}},[s.id,t.computer,s.section,M,O]);const[Te,g]=a.useState(null),[X,ue]=a.useState(null),[Oe,oe]=a.useState(null),[Xe,de]=a.useState(!1),[V,Z]=a.useState(0),[ge,me]=a.useState(null),[ve,tn]=a.useState(null),[ye,xt]=a.useState(null),[nn,zt]=a.useState(null),[Kn,rn]=a.useState(null),[P,we]=a.useState(null),[ke,ft]=a.useState(!1),[bt,sn]=a.useState(!1),[ht,L]=a.useState(null),Be=Dn(ht),ee=gr(),[st,At]=a.useState(()=>Nn(s.id)),$=ee?st==="files"?"computer":st:st==="routines"||st==="android"?"computer":st,an=js(),gt=an.devices.length>0,on=vr(h.config),Le=Sn(h.config)&&s.browser!==!1&&(on||h.config?.browserEngine?.installable===!0),[ln,Ye]=a.useState(0);a.useEffect(()=>{if(o!=="auto"||!Me)return;const n=new AbortController;return u(null),W(F("computer"),{signal:n.signal}).then(i=>{if(n.signal.aborted)return;const x=i.surface;u({key:_,surface:x==="cloud"||x==="vm"||x==="local"||x==="browser"||x==="off"?x:void 0})}).catch(i=>{n.signal.aborted||(L(i instanceof Error?i:String(i)),k("error"))}),()=>n.abort()},[_,o,Me,F,ln]);const Dt=m==="vm-unavailable"&&ye?.resumable===!0,at=a.useRef(0),Ke=a.useRef(null);a.useEffect(()=>(Ke.current?.signal.aborted&&(Ke.current=null,we(null)),()=>{Ke.current?.abort()}),[s.id,s.threadId,s.computer,$]);const vt=h.instances.find(n=>n.instanceId===s.modelSelection.instanceId),Ue=n=>{At(n),Cn(s.id,n)},cn=a.useRef(null);a.useEffect(()=>{const n=cn.current;n===le&&!(s.computer==="browser"&&Le)||(cn.current=le,At(s.computer==="browser"&&Le?"browser":n===null?Nn(s.id):"computer"))},[le,s.id,s.computer,Le]),a.useEffect(()=>{let n=!0;const i=window.ogb?.desktopViewer;i?.currentState&&i.currentState().then(y=>{n&&sn(y.open&&y.contextId===s.id)}).catch(()=>{});const x=i?.onState(y=>{y.contextId===s.id&&sn(y.open)});return()=>{n=!1,x?.()}},[s.id]),a.useEffect(()=>{!gt&&$==="android"&&(At("computer"),Cn(s.id,"computer"))},[gt,s.id,$]),a.useEffect(()=>{at.current=0},[s.id,s.computer]);const un=!!(vt?.snapshot.state==="available"&&vt.capabilities?.computerMcp),Mt=Hr(Xr(vt)),dn=h.routines.filter(n=>n.botId===s.id).sort((n,i)=>Number(i.enabled)-Number(n.enabled)||(n.nextRunAt??1/0)-(i.nextRunAt??1/0)),Un=!!(h.config?.box.configured&&Yr(h.instances,s.modelSelection.instanceId)?.snapshot.state==="available"),ot=h.routineRuns.find(n=>n.botId===s.id&&["queued","running","waiting"].includes(n.status));a.useEffect(()=>{if($!=="computer")return;let n=!0;if(ae(null),He(null),k("checking"),ue(null),oe(null),me(null),tn(null),xt(null),zt(null),rn(null),L(null),!(!Me||!A)){if(s.computer===void 0){k("auto-unavailable");return}if(s.computer==="off"){k("off");return}if(s.computer==="browser"){k("browser");return}if(s.computer==="local"){ne||L(new te("computer.err.localEngine")),k($e&&tt&&ne?"local":"local-unavailable"),ae({botId:s.id,threadId:s.threadId,computer:s.computer,cloudBackend:M});return}if(s.computer==="vm"){if(!un){L(new te("computer.err.vmEngine")),k("vm-unavailable");return}let i;return W(F("local-computer")).then(x=>{if(!n)return;const y=x;ae({botId:s.id,threadId:s.threadId,computer:s.computer,cloudBackend:M}),xt(y);const I=String(y.viewer_url??"");if((I.startsWith("http")||I.startsWith("/desktop-viewer#"))&&tn(new URL(I,window.location.href).href),y.ready)at.current=0,k("vm");else if(y.container==="running"&&y.imageMatches&&y.managed&&y.network==="loopback"&&y.security==="hardened"&&y.persistence==="durable"&&!y.desktopReady&&at.current<15)at.current+=1,L(null),k("checking"),i=window.setTimeout(()=>Ye(Y=>Y+1),2e3);else{const Y=y.mode==="per-bot"&&y.container==="missing"&&y.image&&y.create_supported;L(Y||y.resumable?null:new te("computer.err.vmOpenSettings",y.problem,"computer.err.vmNotReady")),k("vm-unavailable")}}).catch(x=>{n&&(L(x.message),k("vm-unavailable"))}),()=>{n=!1,i!==void 0&&window.clearTimeout(i)}}if(s.computer==="cloud"&&!Mt){k("error");return}if(!(s.computer!=="cloud"&&!$e))return M==="vps"?(W(F("computer")).then(i=>{if(!n)return;const x=i;if(zt(x),ae({botId:s.id,threadId:s.threadId,computer:s.computer,cloudBackend:M}),!x.configured){L(new te("computer.err.vpsAlias")),k("vps-unconfigured");return}if(x.ready){g(x.container??null),k("ready");return}if(x.managed&&x.container!=="missing"&&!x.imageMatches){L(x.problem),k("vps-incompatible");return}if(H)return k("starting"),W(`/api/bots/${s.id}/computer/provision`,{method:"POST"}).then(y=>{n&&(g(y.container??null),y.ready?(ae({botId:s.id,threadId:s.threadId,computer:s.computer,cloudBackend:M}),k("ready")):(L(y.problem??new te("computer.err.vpsNotReady")),k("error")))});g(x.container??null),L(s.autoStartVps?new te("computer.err.vpsAuto",x.problem,"computer.err.vpsNoContainer"):new te("computer.err.vpsManual",x.problem,"computer.err.vpsNoContainer")),k(x.container==="stopped"?"vps-stopped":"vps-unconfigured")}).catch(i=>{n&&(L(i.message),k("error"))}),()=>{n=!1}):(W(F("computer")).then(i=>{if(!n)return;const x=yr({computer:o==="cloud"?"cloud":void 0,configured:!!i.configured,boatState:typeof i.box?.state=="string"?i.box.state:null,canUseCloud:Mt,autoLocal:!1,teamComputer:typeof i.teamComputer?.id=="string"&&typeof i.teamComputer?.name=="string",busy:t.busy});if(ae({botId:s.id,threadId:s.threadId,computer:s.computer,cloudBackend:M}),!i.configured&&s.computer==="cloud"&&!i.teamComputer){k("unconfigured");return}if(x==="team-boat"){He({id:i.teamComputer.id,name:i.teamComputer.name,botId:s.id,section:s.section?.trim()??""}),g(typeof i.box?.state=="string"?i.box.state:i.configured?"missing":"unavailable"),L(typeof i.problem=="string"?i.problem:null),k("team-boat");return}if(x==="attach-ready-boat"||s.computer==="cloud"&&x==="show-ready-boat"){g(typeof i.box?.state=="string"?i.box.state:null),k("ready");return}g(typeof i.box?.state=="string"?i.box.state:null),k(x)}).catch(i=>{n&&(L(i.message),k("error"))}),()=>{n=!1})}},[s.id,s.threadId,s.computer,s.section,s.autoStartVps,M,ln,$e,Ce,se,ne,vt?.driverKind,un,Mt,h.config?.vps?.sshAlias,$,Me,A,H,o,F]),a.useEffect(()=>{if(m!=="busy-boat")return;let n=!0;const i=()=>{if(!t.busy&&o==="cloud"){Ye(y=>y+1);return}W(F("computer")).then(y=>{if(!n)return;const I=typeof y.box?.state=="string"?y.box.state:null;g(I),Lr(I)&&k("ready")}).catch(()=>{})},x=window.setInterval(i,5e3);return()=>{n=!1,window.clearInterval(x)}},[m,F,t.busy,o]);const Je=en(),Ge=a.useRef(0),Ot=a.useRef(s.busy);a.useEffect(()=>{Ot.current=s.busy},[s.busy]),a.useEffect(()=>{if(Ge.current=0,!!K)return wr({onFrame:n=>{n.kind!=="screen"||n.botId!==s.id||n.threadId!==s.threadId||(Ge.current=Date.now(),ue({png:n.png,mime:n.mime??"image/png"}),oe(null),de(!1))}})},[K,s.id,s.threadId]),a.useEffect(()=>{if($!=="computer"||!K||bt||!Je||P||ke)return;let n=!1,i=-1/0,x=null,y=null;const I=new AbortController;oe(null),de(!0);const Y=async()=>{if(n||I.signal.aborted||Date.now()-i<(x??(Ot.current?4e3:3e4))||Ot.current&&Date.now()-Ge.current<1e4)return;n=!0,x=null;const J=Date.now();try{const{png:pe,format:ze}=await W(F("computer/screenshot"),{method:"POST",signal:AbortSignal.any([I.signal,AbortSignal.timeout(9e4)])});if(!I.signal.aborted&&Ge.current<=J){if(typeof pe!="string"||!pe.trim())throw new te("computer.err.emptyFrame");ue({png:pe,mime:ze==="jpeg"?"image/jpeg":"image/png"}),oe(null),de(!1),y=null}}catch(pe){if(!I.signal.aborted&&Ge.current<=J)if(pe instanceof Vr&&Jr(pe)){x=1e3,y??=Date.now();const ze=Date.now()-y>=1e4;oe(ze?pe:null),de(!ze)}else y=null,de(!1),oe(pe instanceof Error&&pe.name==="TimeoutError"?new te("computer.err.frameTimeout"):pe instanceof Error?pe:new te("computer.err.screenUnavailable"))}finally{n=!1,i=Date.now()}};Y();const fe=setInterval(Y,1e3);return()=>{I.abort(),clearInterval(fe)}},[$,K,F,M,bt,Je,P,ke,V]),a.useEffect(()=>{if($!=="computer"||m!=="vm"||!re||bt||!Je)return;const n=new AbortController;let i=!1,x=-1/0,y=null,I=!0;const Y=async()=>{if(!(i||n.signal.aborted)&&!(Date.now()-x<(y??(s.busy?3e3:3e4)))){i=!0,y=null;try{const{image:J}=await W(F("local-computer/screenshot"),{method:"POST",signal:n.signal});!n.signal.aborted&&typeof J=="string"&&(me(J),oe(null))}catch(J){n.signal.aborted||(y=5e3,I?L(J instanceof Error?J.message:String(J)):oe(J instanceof Error?J:new te("computer.err.screenUnavailable")))}finally{i=!1,I=!1,x=Date.now()}}};Y();const fe=window.setInterval(()=>{Y()},s.busy?3e3:3e4);return()=>{n.abort(),window.clearInterval(fe)}},[$,m,re,F,bt,Je,s.busy,L,oe,me]);const[pn,Lt]=a.useState(0);a.useEffect(()=>{if($!=="computer"||m!=="local"||!re||!window.ogb||se||!Je)return;let n=!0;Lt(0);const i=async()=>{try{const y=await window.ogb.screenFrame();n&&y?rn(y):n&&Lt(I=>I+1)}catch{n&&Lt(y=>y+1)}};i();const x=setInterval(i,s.busy?3e3:3e4);return()=>{n=!1,clearInterval(x)}},[$,m,re,se,Je,s.busy,s.id,s.threadId]);const Qe=re?m==="vm"?ge:m==="local"&&!se?Kn:K||s.computer==="cloud"&&m==="starting"?X&&`data:${X.mime};base64,${X.png}`:null:null,qn=!!(Qe&&(m==="vm"&&ve||K)),xe=h.computerControl[s.id]??{held:!1,helpReason:null};a.useEffect(()=>{let n=!0;return W(`/api/bots/${s.id}/computer/control`).then(i=>{if(!n)return;const x=Mn.parse(i);R({type:"computerControl",botId:s.id,held:x.held===!0,helpReason:x.helpReason})}).catch(()=>{}),()=>{n=!1}},[s.id]);const mn=a.useCallback(async n=>{const i=Mn.parse(await W(`/api/bots/${s.id}/computer/control`,{method:"POST",body:JSON.stringify({action:n})}));return R({type:"computerControl",botId:s.id,held:i.held===!0,helpReason:i.helpReason}),i},[s.id,R]),xn=a.useCallback(async()=>!0,[]),yt=a.useCallback(async n=>ss({action:n,syncNativeBrowser:$!=="browser",requestControl:mn,setNativeBrowserControl:xn}),[$,mn,xn]),Vt=a.useCallback(async n=>{ft(!0),L(null);try{return await yt(n),!0}catch(i){return L(i instanceof Error?i.message:String(i)),!1}finally{ft(!1)}},[yt]),Pe=async()=>{const n=new AbortController;Q.current=n;const i=()=>!n.signal.aborted&&je.current===le;we("join"),ft(!0),L(null);let x=!1,y=null;!window.ogb?.desktopViewer&&!window.ogb?.openExternal&&(y=window.open("","_blank"),y&&(y.opener=null));try{if(xe.held||(await yt("take"),x=!0),!i())throw new DOMException("The selected conversation changed","AbortError");let I=ve;if(K){const Y=await W(F("computer/join"),{method:"POST",signal:n.signal});I=Y.joinUrl?.constructor===String?String(Y.joinUrl):null}if(!i())throw new DOMException("The selected conversation changed","AbortError");if(!I)throw new te("computer.err.noDesktopLink");if(window.ogb?.desktopViewer){if(!await window.ogb.desktopViewer.open(I,r("computer.viewerTitle",{name:s.name}),s.id))throw new te("computer.err.openDesktop")}else if(y)y.location.replace(I);else if(window.ogb?.openExternal){if(!await window.ogb.openExternal(I))throw new te("computer.err.openDesktopLink")}else if(!window.open(I,"_blank","noopener"))throw new te("computer.err.popupBlocked")}catch(I){y?.close(),x&&await yt("release").catch(()=>{}),K&&M==="vps"&&await W(F("computer/viewer-close"),{method:"POST",body:"{}"}).catch(()=>{}),i()&&L(I instanceof Error?I:String(I))}finally{Q.current===n&&(Q.current=null,we(null),ft(!1))}},Ft=n=>{we(n),L(null),W(`/api/bots/${s.id}/computer/${n}`,{method:"POST"}).then(i=>{n==="provision"&&(g(i.container??null),i.ready?(s.computer==="cloud"&&ae({botId:s.id,threadId:s.threadId,computer:s.computer,cloudBackend:M}),k("ready")):(L(i.problem??new te("computer.err.vpsNotReady")),k("error"))),n==="sleep"&&(ae(null),g(M==="vps"?"stopped":"archived"),k(M==="vps"?"vps-stopped":H?"cloud-asleep":"show-sleeping-boat"))}).catch(i=>{L(i.message)}).finally(()=>we(null))},Wn=()=>{we("provision"),L(null),k("starting"),W(`/api/bots/${s.id}/computer/provision`,{method:"POST"}).then(n=>{g(n.state??null),ae({botId:s.id,threadId:s.threadId,computer:s.computer,cloudBackend:M}),k("ready")}).catch(n=>{if(Gr(n)){k("busy-boat");return}L(n.message),k("error")}).finally(()=>we(null))},_t=async n=>{if((n==="vm-recreate"||n==="vm-delete")&&!window.confirm(n==="vm-delete"?r("computer.confirm.deleteVm",{name:s.name}):r("computer.confirm.replaceVm",{name:s.name}))||Ke.current)return;const i=new AbortController;Ke.current=i,we(n),L(null),at.current=0;try{if((n==="vm-recreate"||n==="vm-delete")&&await W(`/api/bots/${s.id}/local-computer/remove`,{method:"POST",body:"{}",signal:i.signal}),n!=="vm-delete"){const x=n==="vm-start"&&ye?.mode!=="per-bot"?"/api/local-computer/start":`/api/bots/${s.id}/local-computer/${n==="vm-start"?"start":"run"}`,y=await W(x,{method:"POST",body:"{}",signal:i.signal}),I=await ts(y,()=>W(F("local-computer"),{signal:i.signal}),i.signal);if(!I.ready)throw new Error(I.problem??r("computer.err.vmNotReady"));xt(I),k("vm")}else xt(x=>x&&{...x,container:"missing",ready:!1}),k("vm-unavailable")}catch(x){if(i.signal.aborted)return;L(x instanceof Error?x.message:String(x)),k("vm-unavailable")}finally{Ke.current===i&&!i.signal.aborted&&(Ke.current=null,we(null),Ye(x=>x+1))}},Hn=async()=>{if(window.confirm(r("computer.confirm.replaceVps",{name:s.name}))){we("vps-replace"),L(null);try{await W(`/api/bots/${s.id}/computer/remove`,{method:"POST",body:"{}"});const n=await W(`/api/bots/${s.id}/computer/provision`,{method:"POST",body:"{}"});zt(n),g(n.container??null),n.ready&&s.computer==="cloud"&&ae({botId:s.id,threadId:s.threadId,computer:s.computer,cloudBackend:M}),k(n.ready?"ready":"error"),n.ready||L(n.problem??new te("computer.err.vpsReplaceNotReady"))}catch(n){L(n instanceof Error?n.message:String(n)),k("error")}finally{we(null),Ye(n=>n+1)}}},fn=()=>{window.sessionStorage.setItem("openmausbot.settings.section","computer"),R({type:"toggleAppSettings",open:!0})},bn=()=>{R({type:"toggleAppSettings",open:!0,section:"connections"})},$t=on||h.config?.browserEngine?.installable===!0,[hn,gn]=a.useState(!1),vn=async()=>{if(!hn){gn(!0),L(null);try{if(!Sn(h.config)){const n=await W("/api/config",{method:"PATCH",body:JSON.stringify({features:{browser:!0}})});R({type:"configStatus",config:n})}t.browser===!1&&R({type:"updateBot",botId:t.id,patch:{browser:!0}})}catch(n){L(n instanceof Error?n.message:r("settings.experimental.error"))}finally{gn(!1)}}},Xn=()=>{L(null),R({type:"updateBot",botId:t.id,patch:{browser:!1}})},yn=e.jsxs("div",{"data-testid":"browser-switch-row",className:"mb-3 flex items-center gap-3 rounded-xl bg-card px-3 py-2.5",children:[e.jsx(We,{size:15,className:"shrink-0 text-ink-secondary","aria-hidden":"true"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-[13px] font-medium text-ink",children:r("computer.browserSwitch.title",{name:s.name})}),!$t&&e.jsx("div",{className:"text-[11.5px] text-ink-secondary",children:Qt(h.config)})]}),e.jsx(kr,{checked:Le,disabled:hn||!Le&&!$t,"aria-label":r("computer.browserSwitch.title",{name:s.name}),onClick:()=>Le?Xn():void vn()})]}),Bt=h.config?.managedPolicy,Kt=jr(Te,t.busy===!0),Yn=!re||o!=="cloud"||M!=="box"?void 0:m==="starting"?"starting":m==="busy-boat"?Kt.spinner?"starting":Kt.line==="computer.cloud.asleep"?"asleep":"none":m==="ready"?"on":Te==="archived"||Te==="stopped"?"asleep":void 0,it=(n,i)=>Br({...Kr({bot:s,place:n,seat:mt,config:h.config,instances:h.instances,local:{ready:Ce,reason:De??r("computer.unavailableLocal")},...n==="cloud"?{computer:Yn}:{},...n==="auto"&&he?{teamComputer:he.name}:{}}),...i?{refusal:i}:{}}),Ut=s.computer==="cloud"&&M==="box"&&m==="error"&&ht&&!(ht instanceof te)?Nr({message:Be??"",status:Number(ht.status??0)||void 0},h.config?.box?.included===!0):void 0,be=it("cloud",Ut),qe=it("auto"),lt=[[null,"vm.dest.auto","computer.dest.autoDesc",Sr],["cloud","place.cloud","computer.dest.cloudDesc",Cr],["vm","vm.dest.vm","computer.dest.vmDesc",Er],["local","vm.dest.local","computer.dest.localDesc",Fe],["browser","vm.dest.browser","computer.dest.browserDesc",We],["off","vm.dest.off","computer.dest.offDesc",pt]].filter(([n])=>n===null||n==="off"||jn(n,h.config)).map(([n,i,x,y])=>{const I=n===null?!t.computer:t.computer===n,Y=n==="local"?"thisComputer":n==="vm"?"localVm":n==="cloud"?t.cloudBackend==="vps"?"vps":"box":null,fe=Bt&&Y&&!Bt.computers[Y]?r("policy.managedBy",{organization:Bt.organizationName}):void 0,J=n===null?qe:n==="cloud"?be:it(n),pe=!!fe||En(J),ze=!fe&&Rr(J),Zn=fe??(ze?J.line:n==="browser"?r("computer.browserOnlyTitle"):void 0);return{mode:n,labelKey:i,descriptionKey:x,Icon:y,simpleLabel:Ir(n??void 0,Se.host.platform),selected:I,managedBy:fe,disabled:pe,unavailableTitle:Zn,view:J,issue:ze}}),wt=lt.find(({selected:n})=>n)?.view??qe,Jn=n=>{if(n==="start"||n==="wake")return Wn();if(n==="try-again")return Ye(i=>i+1);if(n==="turn-on-browser")return void vn();if(n==="open-vm-settings")return fn();qr(n,{botId:t.id,threadId:t.threadId},R)},Gn=n=>!!n&&n!=="watch"&&n!=="open-computer-panel"&&(n!=="start"&&n!=="wake"||H&&!t.busy),ct=(n,i="mt-1 rounded-lg bg-control px-3 py-1.5 text-[12px] text-ink hover:bg-raised-hover")=>n.action&&Gn(n.action.id)?e.jsx("button",{type:"button","data-testid":"place-action",onClick:()=>Jn(n.action.id),className:i,children:n.action.label}):null,wn=n=>{n===null&&t.computer===void 0||n===t.computer||(n==="local"&&Ur(t)==="auto"?Ee(s.id):Ie(n==="browser"?{computer:n,browser:!0}:{computer:n}))},qt=D?.surface&&!D.surfaceAuto&&t.computer!=="off"&&D.surface!==t.computer?D.surface:void 0,ut=n=>Ve("flex items-center gap-1.5 rounded-full px-3 py-1 text-[12.5px] transition-colors",n?"bg-raised text-ink shadow-sm":"text-ink-secondary hover:text-ink"),Qn={checking:r("computer.phase.checking"),starting:M==="vps"?r("computer.phase.starting"):be.line,"busy-boat":be.line,unconfigured:be.line,"auto-unavailable":qe.line,"team-boat":qe.line,"show-ready-boat":r("computer.phase.showReadyBoat"),"show-sleeping-boat":r("computer.phase.showSleepingBoat"),"show-pending-boat":r("computer.phase.showPendingBoat"),"cloud-new":be.line,"cloud-asleep":be.line,"vps-unconfigured":r("computer.phase.vpsUnconfigured"),"vps-incompatible":r("computer.phase.vpsIncompatible"),"vps-stopped":r("computer.phase.vpsStopped"),"local-unavailable":De??r("computer.phase.localUnavailable"),"vm-unavailable":r("computer.phase.vmUnavailable"),browser:it("browser").line,off:it("off").line,error:s.computer==="cloud"&&(Ut||En(be))?be.line:r("computer.phase.error")};return e.jsxs(e.Fragment,{children:[e.jsxs("aside",{className:Ve("animate-panel-in relative flex h-full shrink-0 flex-col border-l border-hairline/40 bg-panel","max-md:absolute max-md:inset-0 max-md:z-40 max-md:w-full!"),style:{width:d},children:[e.jsx("div",{ref:N,role:"separator","aria-orientation":"vertical","aria-label":r("computer.resizeAria"),"aria-valuemin":Et,"aria-valuemax":Rt,"aria-valuenow":j??void 0,tabIndex:0,onKeyDown:S,onPointerDown:w,onPointerMove:f,onPointerUp:C,onPointerCancel:C,className:"absolute inset-y-0 left-0 z-10 w-1.5 cursor-col-resize hover:bg-accent/40 focus-visible:bg-accent/60 max-md:hidden"}),e.jsx("div",{className:Ve("px-4 py-3",l),children:e.jsxs("div",{className:"relative flex min-h-7 items-center justify-center",children:[ee&&e.jsx("button",{onClick:()=>{R({type:"toggleComputer",open:!1}),R({type:"toggleSettings",open:!0,section:"access"})},className:"absolute left-0 top-1/2 -translate-y-1/2 rounded-md p-1 text-ink-secondary hover:bg-control hover:text-ink",title:r("computer.botSettings"),children:e.jsx(Tr,{size:18})}),e.jsxs("div",{className:"mx-9 flex min-w-0 flex-wrap justify-center gap-0.5 rounded-full bg-inset p-0.5","data-tour":"computer-tabs","data-testid":"computer-tabs","aria-label":"Bot panel view",children:[e.jsxs("button",{onClick:()=>Ue("computer"),"aria-pressed":$==="computer",className:ut($==="computer"),children:[e.jsx(Fe,{size:13})," ",r("computer.tab.computer"),q&&Pr(o)&&e.jsx("span",{className:"size-1.5 animate-pulse rounded-full bg-success",role:"img","aria-label":r("place.live"),"data-testid":"computer-tab-live"})]}),ee&&e.jsxs("button",{type:"button",onClick:()=>Ue("routines"),"aria-pressed":$==="routines",className:ut($==="routines"),children:[e.jsx(Rn,{size:13}),r("computer.tab.routines")]}),ee&>&&e.jsxs("button",{onClick:()=>Ue("android"),"aria-pressed":$==="android",className:ut($==="android"),children:[e.jsx(Vn,{size:13})," ",r("computer.tab.android")]}),e.jsxs("button",{"data-tour":"computer-browser",onClick:()=>{L(null),Ue("browser")},"aria-pressed":$==="browser",className:ut($==="browser"),children:[e.jsx(We,{size:13})," ",r("computer.tab.browser"),q&&o==="browser"&&e.jsx("span",{className:"size-1.5 animate-pulse rounded-full bg-success",role:"img","aria-label":r("place.live"),"data-testid":"browser-tab-live"})]}),!ee&&e.jsxs("button",{type:"button",onClick:()=>Ue("files"),"aria-pressed":$==="files",className:ut($==="files"),children:[e.jsx(Ln,{size:13})," ",r("computer.tab.files")]})]}),e.jsx("button",{onClick:()=>R({type:"toggleComputer",open:!1}),className:"absolute right-0 top-1/2 -translate-y-1/2 rounded-md p-1 text-ink-secondary hover:bg-control hover:text-ink","aria-label":r("computer.close"),title:r("computer.close"),children:e.jsx(St,{size:18})})]})}),$==="routines"?e.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-4 pb-4",children:e.jsx(rs,{bot:s,routines:dn,runs:h.routineRuns,defaultRunOn:Un?"cloud":"maus"},s.id)}):$==="browser"&&Le?e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col px-4 pb-4",children:[yn,e.jsx(_s,{bot:s}),Be&&e.jsx("div",{role:"alert",className:"mt-2 rounded-lg border border-danger/30 bg-danger/10 px-3 py-2 text-[12px] text-danger",children:Be})]}):$==="browser"?e.jsxs("div",{className:"flex-1 overflow-y-auto px-5 pb-5","data-testid":"browser-off",children:[yn,e.jsxs("div",{className:"mt-2 flex flex-col items-center gap-3 rounded-xl bg-card px-6 py-8 text-center",children:[e.jsx(We,{size:22,className:"text-ink-secondary","aria-hidden":"true"}),e.jsx("div",{className:"text-[14px] font-medium text-ink",children:r("computer.browserOff.title")}),e.jsx("p",{className:"text-[12px] leading-5 text-ink-secondary",children:$t?r("computer.browserOff.body",{name:s.name}):Qt(h.config)}),Be&&e.jsx("div",{role:"alert",className:"w-full rounded-lg border border-danger/30 bg-danger/10 px-3 py-2 text-[12px] text-danger",children:Be})]})]}):$==="files"?e.jsx(ys,{bot:s}):$==="android"&>?e.jsx("div",{className:"flex-1 overflow-y-auto px-4 pt-2",children:e.jsx(Ns,{status:an})}):e.jsxs("div",{className:"flex-1 overflow-y-auto px-5 pb-5",children:[e.jsxs("div",{className:"mb-1.5 mt-2 flex items-center justify-between text-[13px] text-ink-secondary",children:[e.jsx("span",{children:r("computer.screenOf",{name:s.name})}),he&&e.jsx("span",{className:"text-[11px]",children:qe.short}),m==="local"&&e.jsx("span",{className:"text-[11px]",children:r("computer.badge.local")}),m==="vm"&&e.jsx("span",{className:"text-[11px]",children:r("vm.dest.vm")}),(m==="show-ready-boat"||m==="show-sleeping-boat"||m==="show-pending-boat")&&e.jsx("span",{className:"text-[11px]",children:r("computer.badge.autoBoat")}),re&&s.computer==="cloud"&&M==="vps"&&(m==="ready"||m==="starting")&&e.jsx("span",{className:"text-[11px]",children:r("computer.badge.vps")})]}),e.jsx("div",{className:"relative flex aspect-[16/10] w-full items-center justify-center overflow-hidden rounded-xl bg-card",children:K||s.computer==="cloud"&&m==="starting"?e.jsx(ws,{src:Qe,name:s.name,error:Dn(Oe),refreshing:Xe,retry:V,starting:m==="starting",opening:P==="join",disabled:ke,onOpen:()=>{Pe()},onRetry:n=>{Ge.current=0,n&&ue(null),oe(null),de(!0),Z(i=>i+1)}},`${s.id}:${s.threadId}:${s.computer}:${M}`):Qe&&qn?e.jsxs("button",{type:"button",onClick:()=>{Pe()},disabled:ke||P==="join",className:"group relative flex h-full w-full cursor-pointer items-center justify-center focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:cursor-wait","aria-label":r("computer.openLiveDesktopAria",{name:s.name}),title:r("computer.openLiveDesktop"),children:[e.jsx("img",{src:Qe,alt:r("computer.screenOf",{name:s.name}),className:"h-full w-full object-contain transition group-hover:brightness-75 group-focus-visible:brightness-75"}),e.jsxs("span",{className:"pointer-events-none absolute right-2 top-2 flex items-center gap-1 rounded-md bg-black/70 px-2 py-1 text-[11px] font-medium text-white opacity-80 shadow-sm transition group-hover:opacity-100 group-focus-visible:opacity-100",children:[P==="join"?e.jsx(U,{size:12,className:"animate-spin"}):e.jsx(It,{size:12}),r("computer.open")]})]}):Qe?e.jsx("img",{src:Qe,alt:r("computer.screenOf",{name:s.name}),className:"h-full w-full object-contain",title:m==="vm"?r("computer.watchOnly"):void 0}):e.jsxs("div",{className:"flex flex-col items-center gap-2 px-6 text-center text-ink-secondary",children:[m==="checking"||m==="starting"||m==="busy-boat"&&Kt.spinner||m==="vm"||m==="local"&&!se?e.jsx(U,{size:18,className:"animate-spin"}):m==="off"?e.jsx(pt,{size:22}):e.jsx(Fe,{size:22}),e.jsx("span",{className:"text-[12px]",children:he?qe.line:K?r("computer.waitingFrame"):m==="ready"?r("computer.autoChooseCloudOpen"):m==="vm"?r("computer.capturingVm"):m==="local"?se?r("computer.linuxReady"):pn>=3?r("computer.needsScreenPerm"):r("computer.capturingLocal"):Dt?r(P==="vm-start"?"vm.setup.starting":"computer.phase.vmStopped"):Qn[m]}),he&&ct(qe),s.computer==="cloud"&&(m==="unconfigured"||m==="error")&&be.action?.id!=="add-boat-key"&&ct(be),m==="local"&&!se&&pn>=3&&e.jsx("button",{onClick:()=>window.ogb?.permOpenSettings?.("screen"),className:"mt-1 rounded-lg bg-control px-3 py-1.5 text-[12px] text-ink hover:bg-raised-hover",children:r("computer.openSettings")}),m==="browser"&&Le&&e.jsx("button",{onClick:()=>Ue("browser"),className:"mt-1 rounded-lg bg-control px-3 py-1.5 text-[12px] text-ink hover:bg-raised-hover",children:r("computer.openBrowserTab")}),(m==="show-ready-boat"||m==="show-sleeping-boat"||m==="show-pending-boat")&&e.jsx("button",{type:"button",onClick:()=>Ie({computer:"cloud"}),className:"mt-1 rounded-lg bg-control px-3 py-1.5 text-[12px] text-ink hover:bg-raised-hover",children:m==="show-sleeping-boat"?r("computer.chooseCloudWake"):m==="show-ready-boat"?r("computer.chooseCloudOpen"):r("computer.chooseCloudManage")}),P===null&&(m==="cloud-new"||m==="cloud-asleep")&&ct(be),Dt&&P!=="vm-start"&&e.jsx("p",{className:"text-[12px]",children:r(ye?.stop_reason==="idle"?"vm.stopped.idle":"vm.stopped.detail")}),m==="vm-unavailable"&&(ce&&Dt&&ye.mode!=="pool"?e.jsxs("button",{onClick:()=>{_t("vm-start")},disabled:P!==null,"aria-busy":P==="vm-start",className:"mt-1 flex items-center gap-1.5 rounded-lg bg-accent px-3 py-1.5 text-[12px] font-medium text-white hover:brightness-110 disabled:opacity-50",children:[P==="vm-start"&&e.jsx(U,{size:13,className:"animate-spin"}),r(P==="vm-start"?"vm.setup.starting":"vm.setup.start")]}):ce&&ye?.mode==="per-bot"&&ye.image&&ye.create_supported?e.jsxs("button",{onClick:()=>{_t(ye.container==="missing"?"vm-create":"vm-recreate")},disabled:P!==null,className:"mt-1 rounded-lg bg-accent px-3 py-1.5 text-[12px] font-medium text-white hover:brightness-110 disabled:opacity-50",children:[(P==="vm-create"||P==="vm-recreate")&&e.jsx(U,{size:13,className:"mr-1.5 inline animate-spin"}),ye.container==="missing"?r("computer.createVm",{name:s.name}):r("computer.replaceVm",{name:s.name})]}):e.jsx("button",{onClick:fn,className:"mt-1 rounded-lg bg-control px-3 py-1.5 text-[12px] text-ink hover:bg-raised-hover",children:r("computer.openVmSetup")})),!ee&&re&&(m==="vps-unconfigured"||m==="vps-stopped"||m==="vps-incompatible")&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-[12px]",children:r("computer.simple.needsSetup",{name:s.name})}),e.jsx("button",{type:"button",onClick:()=>zr(!0),className:"mt-1 rounded-lg bg-control px-3 py-1.5 text-[12px] text-ink hover:bg-raised-hover",children:r("computer.simple.showAdvanced")})]}),ee&&re&&(m==="vps-unconfigured"||m==="vps-stopped")&&e.jsx("button",{onClick:bn,className:"mt-1 rounded-lg bg-control px-3 py-1.5 text-[12px] text-ink hover:bg-raised-hover",children:r("computer.openVpsSettings")}),ee&&re&&(m==="vps-stopped"||m==="vps-unconfigured"&&nn?.configured)&&H&&e.jsxs("button",{onClick:()=>Ft("provision"),disabled:P==="provision",className:"mt-1 rounded-lg bg-control px-3 py-1.5 text-[12px] text-ink hover:bg-raised-hover disabled:opacity-50",children:[P==="provision"&&e.jsx(U,{size:13,className:"mr-1.5 inline animate-spin"}),m==="vps-stopped"?r("computer.startVps"):r("computer.prepareVps")]}),ee&&re&&m==="vps-incompatible"&&nn?.managed&&H&&e.jsxs("button",{onClick:()=>{Hn()},disabled:P==="vps-replace",className:"mt-1 rounded-lg bg-accent px-3 py-1.5 text-[12px] font-medium text-white hover:brightness-110 disabled:opacity-50",children:[P==="vps-replace"&&e.jsx(U,{size:13,className:"mr-1.5 inline animate-spin"}),r("computer.replaceVps")]})]})}),Be&&!Ut&&e.jsx("div",{className:"mt-2 rounded-lg border border-danger/30 bg-danger/10 px-3 py-2 text-[12px] text-danger",children:Be}),m==="unconfigured"&&be.action?.id==="add-boat-key"&&e.jsx("div",{className:"mt-3 rounded-xl bg-card p-4",children:e.jsx(Zr,{section:"box",onSaved:n=>n&&Ye(i=>i+1)})}),ee&&m==="vps-unconfigured"&&e.jsxs("div",{className:"mt-3 rounded-xl bg-card p-4",children:[e.jsx("div",{className:"mb-3 text-[13px] text-ink-secondary",children:r("computer.vpsAliasHint")}),e.jsx("button",{onClick:bn,className:"rounded-lg bg-control px-3 py-2 text-[13px] text-ink hover:bg-raised-hover",children:r("computer.openVpsSettings")})]}),ee&&m==="vm"&&ye?.mode==="per-bot"&&window.ogb?.desktopWorkspace&&c&&e.jsxs("button",{type:"button",onClick:()=>c(s.id),disabled:P!==null,className:"mt-3 flex w-full items-center justify-center gap-2 rounded-lg border border-accent/30 bg-accent/10 py-2 text-[13px] font-medium text-ink hover:bg-accent/15 disabled:opacity-50",title:r("computer.twoDesktopsTitle"),children:[e.jsx(os,{size:14}),r("computer.twoDesktops")]}),(K||m==="vm"||he)&&xe.helpReason&&!xe.held&&e.jsxs("div",{className:"mt-3 rounded-xl border border-warning/25 bg-warning/10 p-4",children:[e.jsxs("div",{className:"text-[13px] leading-relaxed text-warning",children:[e.jsx("b",{children:s.name})," ",r("computer.askedHands")," ",xe.helpReason]}),e.jsxs("div",{className:"mt-2 flex gap-2",children:[e.jsxs("button",{onClick:()=>m==="vm"||K?void Pe():Vt("take"),disabled:ke||P==="join",className:"flex flex-1 items-center justify-center gap-2 rounded-lg bg-accent py-2 text-[13px] font-medium text-white hover:brightness-110 disabled:opacity-50",children:[P==="join"?e.jsx(U,{size:14,className:"animate-spin"}):e.jsx(_e,{size:14}),r("computer.takeControl")]}),e.jsx("button",{onClick:()=>Vt("dismiss-help"),disabled:ke,className:"rounded-lg bg-control px-3 py-2 text-[13px] text-ink hover:bg-raised-hover disabled:opacity-50",children:r("computer.dismiss")})]})]}),(K||m==="vm"||he)&&xe.held&&e.jsxs("div",{className:"mt-3 rounded-xl border border-accent/25 bg-accent/10 p-4",children:[e.jsxs("div",{className:"text-[13px] leading-relaxed text-ink",children:[r("computer.youHaveWheel"),K&&` ${r(ee?"computer.useOpenDesktop":"computer.simple.useFullScreen")}`,m==="vm"&&` ${r(ee?"computer.useOpenDesktopVm":"computer.simple.useFullScreenVm")}`]}),e.jsxs("button",{onClick:()=>{Vt("release"),window.ogb?.desktopViewer?.close(s.id)},disabled:ke,className:"mt-2 flex w-full items-center justify-center gap-2 rounded-lg bg-accent py-2 text-[13px] font-medium text-white hover:brightness-110 disabled:opacity-50",children:[e.jsx(_e,{size:14}),r("computer.handBack")]})]}),ee&&m==="vm"&&ve&&xe.held&&e.jsxs("button",{onClick:()=>{Pe()},disabled:P==="join",className:"mt-3 flex w-full items-center justify-center gap-2 rounded-lg bg-control py-2 text-[13px] text-ink hover:bg-raised-hover disabled:opacity-50",title:r("computer.openVmDesktopTitle"),children:[P==="join"?e.jsx(U,{size:14,className:"animate-spin"}):e.jsx(Fe,{size:14}),r("computer.openLiveDesktop")]}),ee&&m==="vm"&&!xe.held&&!xe.helpReason&&e.jsxs("button",{onClick:()=>{Pe()},disabled:ke||P==="join"||!ve,className:"mt-3 flex w-full items-center justify-center gap-2 rounded-lg bg-control py-2 text-[13px] text-ink hover:bg-raised-hover disabled:opacity-50",title:r("computer.takeControlVmTitle"),children:[P==="join"?e.jsx(U,{size:14,className:"animate-spin"}):e.jsx(_e,{size:14}),r("computer.takeControl")]}),ee&&ce&&m==="vm"&&ye?.mode==="per-bot"&&e.jsxs("button",{onClick:()=>{_t("vm-delete")},disabled:P!==null||t.busy,className:"mt-2 flex w-full items-center justify-center gap-2 rounded-lg border border-danger/30 py-2 text-[13px] text-danger hover:bg-danger/10 disabled:opacity-50",title:t.busy?r("computer.deleteVmBlocked"):r("computer.deleteVmTitle",{name:s.name}),children:[P==="vm-delete"?e.jsx(U,{size:14,className:"animate-spin"}):e.jsx(pt,{size:14}),r("computer.deleteVm")]}),!ee&&(K||m==="vm")&&e.jsxs("div",{className:"mt-3 flex gap-2","data-testid":"computer-actions",children:[!xe.held&&!xe.helpReason&&e.jsxs("button",{type:"button",onClick:()=>{Pe()},disabled:ke||P==="join"||m==="vm"&&!ve,className:"flex flex-1 items-center justify-center gap-2 rounded-lg bg-accent py-2 text-[13px] font-medium text-accent-ink hover:brightness-110 disabled:opacity-50",title:m==="vm"?r("computer.takeControlVmTitle"):r("computer.takeControlTitle"),children:[P==="join"?e.jsx(U,{size:14,className:"animate-spin"}):e.jsx(_e,{size:14}),r("computer.takeControl")]}),e.jsxs("button",{type:"button",onClick:()=>{Pe()},disabled:P==="join"||!xe.held&&ke||m==="vm"&&!ve,className:"flex flex-1 items-center justify-center gap-2 rounded-lg bg-control py-2 text-[13px] text-ink hover:bg-raised-hover disabled:opacity-50",title:r("computer.openLiveDesktop"),children:[e.jsx(It,{size:14}),r("computer.fullScreen")]}),K&&H&&(M==="vps"||Te!=="archived")&&e.jsxs("button",{type:"button",onClick:()=>Ft("sleep"),disabled:P==="sleep"||t.busy,className:"flex flex-1 items-center justify-center gap-2 rounded-lg bg-control px-3 py-2 text-[13px] text-ink hover:bg-raised-hover disabled:opacity-50",title:r("computer.sleepTitle"),children:[P==="sleep"?e.jsx(U,{size:14,className:"animate-spin"}):e.jsx(In,{size:14}),r("vm.cloud.sleep")]})]}),ee&&K&&e.jsxs("div",{className:"mt-3 flex gap-2",children:[!xe.held&&!xe.helpReason&&e.jsxs("button",{onClick:()=>{Pe()},disabled:ke||P==="join",className:"flex flex-1 items-center justify-center gap-2 rounded-lg bg-control py-2 text-[13px] text-ink hover:bg-raised-hover disabled:opacity-50",title:r("computer.takeControlTitle"),children:[P==="join"?e.jsx(U,{size:14,className:"animate-spin"}):e.jsx(_e,{size:14}),r("computer.takeControl")]}),xe.held&&e.jsxs("button",{onClick:()=>{Pe()},disabled:P==="join",className:"flex flex-1 items-center justify-center gap-2 rounded-lg bg-control py-2 text-[13px] text-ink hover:bg-raised-hover disabled:opacity-50",children:[P==="join"?e.jsx(U,{size:14,className:"animate-spin"}):e.jsx(Fe,{size:14}),r("computer.openLiveDesktop")]}),H&&(M==="vps"||Te!=="archived")&&e.jsxs("button",{onClick:()=>Ft("sleep"),disabled:P==="sleep"||t.busy,className:"flex flex-1 items-center justify-center gap-2 rounded-lg bg-control px-3 py-2 text-[13px] text-ink hover:bg-raised-hover disabled:opacity-50",title:r("computer.sleepTitle"),children:[P==="sleep"?e.jsx(U,{size:14,className:"animate-spin"}):e.jsx(In,{size:14}),r("vm.cloud.sleep")]})]}),m!=="team-boat"&&(s.computer!==void 0||re)&&e.jsxs(e.Fragment,{children:[e.jsx(Ks,{}),e.jsx(qs,{}),e.jsx(es,{})]}),ee?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mt-4 rounded-xl bg-card p-4",children:[e.jsx("div",{className:"text-[15px] font-medium text-ink",children:r("computer.worksOn")}),e.jsx("p",{className:"mt-1 text-[12px] leading-5 text-ink-secondary",children:r(h.config?.cloudHome?"computer.worksOnHintCloudHome":"computer.worksOnHint")}),e.jsx("div",{role:"group","aria-label":r("computer.destinationAria"),className:"mt-3 grid auto-rows-fr grid-cols-2 gap-2",children:lt.map(({mode:n,labelKey:i,descriptionKey:x,Icon:y,selected:I,managedBy:Y,disabled:fe,unavailableTitle:J,issue:pe,view:ze})=>e.jsxs("button",{disabled:fe,title:J,onClick:()=>wn(n),type:"button","aria-pressed":I,className:Ve("min-w-0 rounded-lg border px-2.5 py-3 text-left transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-card",I?"border-accent/60 bg-accent/10 text-ink":"border-hairline/50 bg-panel/30 text-ink-secondary",fe?"cursor-not-allowed":"hover:border-accent/40 hover:bg-control/60"),children:[e.jsxs("span",{className:"flex items-center gap-2 text-[12px] font-medium leading-4",children:[I?e.jsx(Ar,{size:14,className:"shrink-0 text-accent"}):e.jsx(y,{size:14,className:"shrink-0 text-ink-secondary"}),e.jsx("span",{children:r(i)})]}),e.jsx("span",{className:"mt-1.5 block text-[11px] leading-4 text-ink-secondary",children:Y??(pe?ze.short:r(x))})]},n??"auto"))}),D?.surface&&e.jsx("p",{className:"mt-2 text-[11.5px] leading-5 text-ink-secondary","data-testid":"place-pinned-note",children:r("place.pinnedNote",{place:r(Ht(D.surface))})}),e.jsxs("div",{className:"mt-3 border-t border-hairline/40 pt-3 text-[11.5px] leading-5 text-ink-secondary","aria-live":"polite","data-testid":"place-line",children:[wt.line,ct(wt,"mt-1 block font-medium text-accent hover:underline")]}),t.computer==="cloud"&&e.jsx(ns,{compact:!0,value:M,onChange:n=>Ie({cloudBackend:n})})]}),e.jsxs("button",{type:"button",onClick:()=>Ue("routines"),className:"mt-4 flex w-full items-start gap-3 rounded-xl bg-card p-4 text-left hover:bg-raised",children:[e.jsx(Rn,{size:17,className:"mt-0.5 shrink-0 text-accent"}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsxs("span",{className:"block text-[14px] font-medium text-ink",children:[r("computer.tab.routines")," ",e.jsx("span",{className:"ml-1 text-[11px] text-ink-secondary",children:dn.length})]}),e.jsx("span",{className:Ve("mt-1 block truncate text-[11.5px]",ot?Mr(ot):"text-ink-secondary"),children:ot?`${ot.routineName} · ${Dr(ot)}`:r("computer.routines.openTitle")})]}),e.jsx("span",{className:"text-ink-secondary","aria-hidden":"true",children:"→"})]})]}):e.jsxs("div",{className:"mt-4 rounded-xl bg-card p-4","data-testid":"where-works",children:[e.jsx("div",{className:"text-[15px] font-medium text-ink",children:r("computer.simple.whereWorks",{name:s.name})}),e.jsx("div",{role:"group","aria-label":r("computer.destinationAria"),className:"mt-3 grid grid-cols-3 gap-2",children:lt.map(({mode:n,Icon:i,selected:x,disabled:y,unavailableTitle:I,simpleLabel:Y,issue:fe,view:J})=>e.jsxs("button",{type:"button",disabled:y,title:I,"aria-pressed":x,onClick:()=>wn(n),className:Ve("flex min-w-0 flex-col items-center gap-1.5 rounded-lg border px-1.5 py-2.5 text-center transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-card",x?"border-accent/60 bg-accent/10 text-ink":"border-hairline/50 bg-panel/30 text-ink-secondary",y?"cursor-not-allowed opacity-50":"hover:border-accent/40 hover:bg-control/60"),children:[e.jsx(i,{size:16,className:Ve("shrink-0",x?"text-accent":"text-ink-secondary"),"aria-hidden":"true"}),e.jsx("span",{className:"w-full truncate text-[12px] font-medium leading-4",children:Y}),fe&&e.jsx("span",{className:"w-full truncate text-[10.5px] leading-3 text-ink-secondary",children:J.short})]},n??"auto"))}),e.jsxs("div",{className:"mt-3 text-[11.5px] leading-5 text-ink-secondary","data-testid":"place-line",children:[wt.line,ct(wt,"mt-1 block font-medium text-accent hover:underline")]}),qt&&e.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[e.jsx("p",{className:"min-w-0 flex-1 text-[11.5px] leading-5 text-ink-secondary","data-testid":"place-pinned-note",children:r("place.pinnedNoteSimple",{place:lt.find(({mode:n})=>n===qt)?.simpleLabel??r(Ht(qt))})}),e.jsx("button",{type:"button",disabled:!!s.busy,title:s.busy?r("place.busy"):void 0,onClick:()=>R({type:"updateTask",botId:t.id,threadId:t.threadId,patch:{surface:null}}),className:"shrink-0 rounded-md px-2 py-0.5 text-[11.5px] font-medium leading-5 text-accent-text transition-colors hover:bg-control focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:cursor-not-allowed disabled:opacity-45 disabled:hover:bg-transparent","data-testid":"place-unpin",children:r("place.unpinSimple",{place:lt.find(({selected:n})=>n)?.simpleLabel??r(Ht(t.computer??"auto"))})})]})]})]})]}),e.jsx(Or,{open:Ae!==null,onCancel:()=>Ee(null),onConfirm:()=>{const n=Ae;Ee(null),n&&(n===s.id&&(ae(null),k("checking")),R({type:"updateBot",botId:n,patch:{computer:"local",acknowledgeLocalAuto:!0}}))}})]})}export{na as ComputerPanel};
|
|
1
|
+
import{m as et,u as Tt,ax as Pt,j as e,t as r,aV as Ln,aU as kn,F as er,a7 as tr,r as a,d as U,bb as It,M as Fe,bc as Vn,ag as nr,bd as Fn,a4 as rr,aW as Zt,g as W,be as Qt,aw as We,X as St,P as sr,n as ar,Q as _e,bf as or,c as Ve,O as Wt,a3 as ir,bg as pt,E as lr,a as cr,bh as ur,bi as dr,bj as pr,aO as jn,bk as mr,bl as xr,bm as fr,bn as br,bo as hr,ba as gr,bp as Nn,bq as vr,br as Sn,bs as Cn,bt as yr,l as wr,v as kr,bu as jr,bv as Nr,aQ as Sr,w as Cr,aL as Er,bw as Rr,bx as Ir,by as En,bz as Tr,bA as Pr,C as Rn,bB as zr,p as Ar,bC as Ht,bD as Dr,bE as Mr,am as Or,bF as Lr,A as Vr,D as Fr,G as _r,H as $r,bG as Br,bH as Kr,bI as Ur,bJ as qr}from"./index-CyM91z0J.js";import{R as Wr,g as Hr,h as Xr,b as Yr,i as Jr,j as Gr}from"./WebhooksPanel-G_NWjHOP.js";import{B as Qr,A as Zr,M as In,a as es,w as ts}from"./MacLocalControl-ExdXHVUv.js";import{u as en}from"./page-visible-BehtKJDm.js";import{C as ns}from"./CloudBackendPicker-BR42-xBg.js";import{R as rs}from"./RoutinesSection-NyReOXr8.js";import{t as ss}from"./computer-control-NLov352p.js";import"./RoutinesPage-Buk5-r3o.js";const as=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]],os=et("columns-2",as);const is=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}]],ls=et("ellipsis-vertical",is);const cs=[["path",{d:"m14 10 7-7",key:"oa77jy"}],["path",{d:"M20 10h-6V4",key:"mjg0md"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M4 14h6v6",key:"rmj7iw"}]],us=et("minimize-2",cs);const ds=[["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"m14.305 7.53.923-.382",key:"1mlnsw"}],["path",{d:"m15.228 4.852-.923-.383",key:"82mpwg"}],["path",{d:"m16.852 3.228-.383-.924",key:"ln4sir"}],["path",{d:"m16.852 8.772-.383.923",key:"1dejw0"}],["path",{d:"m19.148 3.228.383-.924",key:"192kgf"}],["path",{d:"m19.53 9.696-.382-.924",key:"fiavlr"}],["path",{d:"m20.772 4.852.924-.383",key:"1j8mgp"}],["path",{d:"m20.772 7.148.924.383",key:"zix9be"}],["path",{d:"M22 13v2a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7",key:"1tnzv8"}],["path",{d:"M8 21h8",key:"1ev6f3"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}]],ps=et("monitor-cog",ds);const ms=[["circle",{cx:"10",cy:"7",r:"1",key:"dypaad"}],["circle",{cx:"4",cy:"20",r:"1",key:"22iqad"}],["path",{d:"M4.7 19.3 19 5",key:"1enqfc"}],["path",{d:"m21 3-3 1 2 2Z",key:"d3ov82"}],["path",{d:"M9.26 7.68 5 12l2 5",key:"1esawj"}],["path",{d:"m10 14 5 2 3.5-3.5",key:"v8oal5"}],["path",{d:"m18 12 1-1 1 1-1 1Z",key:"1bh22v"}]],xs=et("usb",ms);const fs=[["circle",{cx:"12",cy:"8",r:"5",key:"1hypcn"}],["path",{d:"M20 21a8 8 0 0 0-16 0",key:"rfgkzh"}]],bs=et("user-round",fs),hs=20;function gs(t,c=hs){const l=new Set,d=[],p=tr(t);for(let b=p.length-1;b>=0&&d.length<c;b-=1){const E=p[b].digest?.files;if(E){for(const w of E.deleted)l.add(w);for(const w of[...E.added,...E.changed])if(!l.has(w)&&(l.add(w),d.push(w),d.length>=c))break}}return d}function vs(t){const c=Math.max(t.lastIndexOf("/"),t.lastIndexOf("\\"));return c<0?{name:t,folder:""}:{name:t.slice(c+1),folder:t.slice(0,c)}}function ys({bot:t}){const{dispatch:c}=Tt(),{capabilities:l}=Pt(),d=l.host.homeDir,p=gs(t);return e.jsxs("div",{className:"flex-1 overflow-y-auto px-5 pb-5","data-testid":"computer-files",children:[e.jsxs("div",{className:"mt-2 rounded-xl bg-card p-4",children:[e.jsx("div",{className:"text-[13px] font-medium text-ink",children:r("computer.files.folder")}),e.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[e.jsx(Ln,{size:15,className:"shrink-0 text-ink-secondary","aria-hidden":"true"}),e.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-[12px] text-ink",title:t.cwd??void 0,children:t.cwd?kn(t.cwd,d):r("computer.files.privateFolder",{name:t.name})}),e.jsx("button",{type:"button",onClick:()=>{c({type:"toggleComputer",open:!1}),c({type:"toggleSettings",open:!0,section:"access"})},className:"shrink-0 rounded-lg bg-control px-2.5 py-1 text-[12px] text-ink hover:bg-raised-hover",children:r("computer.files.changeFolder")})]})]}),e.jsxs("div",{className:"mt-3 rounded-xl bg-card p-4",children:[e.jsx("div",{className:"text-[13px] font-medium text-ink",children:r("computer.files.recent")}),p.length===0?e.jsx("p",{className:"mt-2 text-[12px] leading-5 text-ink-secondary",children:r("computer.files.empty",{name:t.name})}):e.jsx("ul",{className:"mt-2 flex flex-col gap-1",children:p.map(b=>{const{name:E,folder:w}=vs(b);return e.jsxs("li",{className:"flex min-w-0 items-center gap-2 rounded-lg px-1 py-1",title:b,children:[e.jsx(er,{size:14,className:"shrink-0 text-ink-secondary","aria-hidden":"true"}),e.jsx("span",{className:"min-w-0 truncate text-[12.5px] text-ink",children:E}),w&&e.jsx("span",{className:"min-w-0 flex-1 truncate text-right text-[11px] text-ink-tertiary",children:kn(w,d)})]},b)})})]})]})}function ws({src:t,name:c,error:l,starting:d,opening:p,disabled:b,refreshing:E=!1,retry:w=0,onOpen:f,onRetry:C}){const[z,N]=a.useState(null),[j,T]=a.useState(null);a.useEffect(()=>{T(null)},[w]);const S=!!(t&&z===t&&j!==t),h=l??(t&&j===t?r("computer.preview.imageFailed"):null);return e.jsxs("div",{className:"relative h-full w-full","aria-busy":!h&&(!S||p||E),children:[t&&e.jsxs("button",{type:"button",onClick:f,disabled:b||d||p||!S,className:"group absolute inset-0 flex h-full w-full items-center justify-center disabled:cursor-wait","aria-label":r("computer.openLiveDesktopAria",{name:c}),title:r("computer.openLiveDesktop"),children:[e.jsx("img",{src:t,alt:r("computer.screenOf",{name:c}),onLoad:()=>{N(t),T(null)},onError:()=>T(t),className:`h-full w-full object-contain transition group-hover:brightness-75 ${S?"":"invisible"}`},w),S&&e.jsxs("span",{className:"absolute right-2 top-2 flex items-center gap-1 rounded-md bg-black/70 px-2 py-1 text-[11px] font-medium text-white",children:[p?e.jsx(U,{size:12,className:"animate-spin"}):e.jsx(It,{size:12}),p?r("computer.preview.connecting"):r("computer.open")]})]}),!S&&!h&&e.jsxs("div",{role:"status",className:"absolute inset-0 flex flex-col items-center justify-center gap-2 px-6 text-center text-[12px] text-ink-secondary",children:[e.jsx(U,{size:18,className:"animate-spin"}),d?r("computer.phase.starting"):r("computer.preview.connectingScreen")]}),S&&E&&!h&&e.jsxs("div",{role:"status",className:"absolute bottom-2 left-2 flex items-center gap-1 rounded-md bg-black/70 px-2 py-1 text-[11px] text-white",children:[e.jsx(U,{size:12,className:"animate-spin"}),r("computer.preview.connectingScreen")]}),h&&e.jsxs("div",{role:"alert",className:`absolute inset-x-0 flex flex-col items-center justify-center gap-2 bg-card/95 p-4 text-center text-[12px] text-ink-secondary ${S?"bottom-0":"inset-y-0"}`,children:[!S&&e.jsx(Fe,{size:22}),e.jsxs("span",{children:[S?r("computer.preview.paused"):r("computer.preview.cantConnect")," ",h]}),e.jsx("button",{type:"button",onClick:()=>C(!S),className:"rounded-md bg-control px-3 py-1.5 text-ink hover:bg-raised-hover",children:r("computer.preview.retry")})]})]})}const ks={available:!1,devices:[]};function js(){const t=window.ogb?.androidDevice,[c,l]=a.useState(ks),d=en();return a.useEffect(()=>{if(!t||!d)return;let p=!0;const b=async()=>{try{const w=await t.status();p&&l(w)}catch(w){p&&l({available:!1,devices:[],reasonCode:"adb-failed",message:w instanceof Error?w.message:String(w)})}};b();const E=window.setInterval(()=>{b()},2e3);return()=>{p=!1,window.clearInterval(E)}},[t,d]),c}function kt(t){return t.model==="Android device"?t.serial:t.model}function Ns({status:t}){const c=window.ogb?.androidDevice,l=en(),d=t.devices.filter(u=>u.state==="device"),[p,b]=a.useState(d[0]?.serial??t.devices[0]?.serial??""),[E,w]=a.useState(null),[f,C]=a.useState({width:0,height:0}),[z,N]=a.useState(null),j=a.useRef(null),T=a.useRef(null),S=a.useRef({x:0,y:0,timer:null}),h=t.devices.find(u=>u.serial===p)??t.devices[0],R=h?.serial,O=h?.state;a.useEffect(()=>{!h&&t.devices[0]&&b(t.devices[0].serial),h&&!t.devices.some(u=>u.serial===h.serial)&&b(t.devices[0]?.serial??"")},[h,t.devices]),a.useEffect(()=>{if(!c||!R||O!=="device"||!l){if(!l)return;w(null);return}let u=!0,v=null;const A=async()=>{try{const s=await c.frame(R);u&&(w(s.dataUrl),N(null))}catch(s){u&&N(s instanceof Error?s.message:String(s))}finally{u&&(v=window.setTimeout(()=>{A()},850))}};return A(),()=>{u=!1,v!==null&&window.clearTimeout(v)}},[c,R,O,l]),a.useEffect(()=>()=>{S.current.timer&&clearTimeout(S.current.timer)},[]);const D=u=>{!c||!h||h.state!=="device"||c.input(h.serial,u).catch(v=>{N(v instanceof Error?v.message:String(v))})},o=(u,v=!1)=>{if(!j.current||!f.width||!f.height)return null;const s=u.currentTarget.getBoundingClientRect(),le=Math.min(s.width/f.width,s.height/f.height),je=f.width*le,Q=f.height*le,q=s.left+(s.width-je)/2,F=s.top+(s.height-Q)/2,H=(u.clientX-q)/je,ce=(u.clientY-F)/Q;return v?{x:Math.max(0,Math.min(1,H)),y:Math.max(0,Math.min(1,ce))}:H>=0&&H<=1&&ce>=0&&ce<=1?{x:H,y:ce}:null},B=u=>{if(u.metaKey||u.ctrlKey||u.altKey)return;const v={ArrowDown:"down",ArrowLeft:"left",ArrowRight:"right",ArrowUp:"up",Backspace:"delete",Delete:"delete",Enter:"enter",Escape:"back",Tab:"tab"};v[u.key]?(u.preventDefault(),D({type:"key",key:v[u.key]})):/^[A-Za-z0-9 _.,@-]$/.test(u.key)&&(u.preventDefault(),D({type:"text",text:u.key}))},_=u=>{if(!f.width||!f.height)return;u.preventDefault();const v=S.current;v.x+=u.deltaX,v.y+=u.deltaY,v.timer&&clearTimeout(v.timer),v.timer=setTimeout(()=>{const A=Math.abs(v.x)>Math.abs(v.y),s=A?v.x:v.y;if(v.x=0,v.y=0,v.timer=null,Math.abs(s)<2)return;const le=Math.max(.18,Math.min(.45,Math.abs(s)/500)),je=s>0?-1:1,Q=A?{x:.5,y:.5}:{x:.5,y:.65},q=A?{x:Q.x+je*le,y:Q.y}:{x:Q.x,y:Q.y+je*le};D({type:"swipe",fromX:Q.x,fromY:Q.y,toX:q.x,toY:q.y,durationMs:260,width:f.width,height:f.height})},80)};if(!h)return null;const G=h.state==="device";return e.jsxs("div",{className:"space-y-3 pb-5",children:[e.jsxs("div",{className:"rounded-xl bg-card p-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 text-[15px] font-medium text-ink",children:[e.jsx(Vn,{size:16,className:"text-success"})," ",kt(h)]}),e.jsx("div",{className:"mt-1 text-[12px] leading-relaxed text-ink-secondary",children:r("computer.android.usbSubtitle")})]}),e.jsxs("span",{className:"flex shrink-0 items-center gap-1 text-[11px] text-success",children:[e.jsx(nr,{size:12})," ",r("computer.android.usb")]})]}),t.devices.length>1&&e.jsx("select",{value:h.serial,onChange:u=>b(u.target.value),className:"mt-3 w-full rounded-lg border border-hairline/40 bg-inset px-3 py-2 text-[12px] text-ink",children:t.devices.map(u=>e.jsxs("option",{value:u.serial,children:[kt(u)," · ",u.state]},u.serial))})]}),G?e.jsxs(e.Fragment,{children:[e.jsx("div",{role:"application","aria-label":r("computer.android.screenAria",{name:kt(h)}),tabIndex:0,onKeyDown:B,onWheel:_,onPointerDown:u=>{const v=o(u);v&&(u.currentTarget.setPointerCapture(u.pointerId),T.current={point:v,at:performance.now()})},onPointerUp:u=>{const v=T.current,A=o(u,!0);if(T.current=null,!v||!A)return;Math.hypot(A.x-v.point.x,A.y-v.point.y)<.012?D({type:"tap",...A,...f}):D({type:"swipe",fromX:v.point.x,fromY:v.point.y,toX:A.x,toY:A.y,durationMs:performance.now()-v.at,...f}),u.currentTarget.focus()},onPointerCancel:()=>{T.current=null},className:"mx-auto flex h-[520px] w-full touch-none cursor-pointer items-center justify-center overflow-hidden overscroll-none rounded-[28px] bg-black outline-none ring-1 ring-white/10 focus:ring-2 focus:ring-accent",children:E?e.jsx("img",{ref:j,src:E,alt:r("computer.android.screenAlt",{name:kt(h)}),draggable:!1,onLoad:u=>{C({width:u.currentTarget.naturalWidth,height:u.currentTarget.naturalHeight})},className:"pointer-events-none h-full w-full select-none object-contain"}):e.jsx(U,{size:20,className:"animate-spin text-ink-secondary"})}),e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[e.jsxs("button",{onClick:()=>D({type:"key",key:"back"}),className:"flex items-center justify-center gap-1.5 rounded-lg bg-raised py-2 text-[12px] text-ink hover:bg-raised-hover",children:[e.jsx(Fn,{size:13})," ",r("computer.android.back")]}),e.jsxs("button",{onClick:()=>D({type:"key",key:"home"}),className:"flex items-center justify-center gap-1.5 rounded-lg bg-raised py-2 text-[12px] text-ink hover:bg-raised-hover",children:[e.jsx(rr,{size:12})," ",r("computer.android.home")]}),e.jsxs("button",{onClick:()=>D({type:"key",key:"recent"}),className:"flex items-center justify-center gap-1.5 rounded-lg bg-raised py-2 text-[12px] text-ink hover:bg-raised-hover",children:[e.jsx(Zt,{size:13})," ",r("computer.android.recent")]})]}),e.jsx("div",{className:"text-center text-[11px] leading-relaxed text-ink-secondary",children:r("computer.android.hint")})]}):e.jsx("div",{className:"rounded-xl border border-warning/25 bg-warning/10 p-4 text-[12px] leading-relaxed text-warning",children:h.state==="unauthorized"?r("computer.android.unauthorized"):r("computer.android.badState",{state:h.state})}),z&&e.jsx("div",{className:"rounded-lg border border-danger/30 bg-danger/10 px-3 py-2 text-[12px] text-danger",children:z}),e.jsxs("div",{className:"rounded-xl bg-card p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-[13px] font-medium text-ink",children:[e.jsx(xs,{size:15,className:"text-accent"})," ",r("computer.android.setupTitle")]}),e.jsxs("ol",{className:"mt-2 list-decimal space-y-1.5 pl-4 text-[11.5px] leading-relaxed text-ink-secondary",children:[e.jsx("li",{children:r("computer.android.step1")}),e.jsx("li",{children:r("computer.android.step2").split(/(\{buildNumber\}|\{usbDebugging\})/).map((u,v)=>u==="{buildNumber}"||u==="{usbDebugging}"?e.jsx("span",{className:"text-ink",children:r(u==="{buildNumber}"?"computer.android.buildNumber":"computer.android.usbDebugging")},v):u)}),e.jsxs("li",{children:[r("computer.android.step3a")," ",e.jsx("span",{className:"text-ink",children:r("computer.android.allowUsbDebugging")})," ",r("computer.android.step3b")]})]}),e.jsx("div",{className:"mt-2 text-[11px] leading-relaxed text-ink-secondary",children:r("computer.android.agentNote")}),e.jsx("div",{className:"mt-2 rounded-lg bg-inset px-3 py-2 text-[11px] leading-relaxed text-ink-secondary",children:r("computer.android.harnessNote")})]})]})}const Ze=t=>Number(t.altKey)+Number(t.ctrlKey)*2+Number(t.metaKey)*4+Number(t.shiftKey)*8,Ss=new Set(["Alt","Control","Meta","Shift"]);function _n(t,c,l,d){const p=c*l/t;return Math.abs(p-d)<=Math.max(1,l/t)?{width:l,height:d}:{width:l,height:Math.round(p)}}function Cs(t,c,l,d,p,b,E,w=!1){if(![t.width,t.height,c,l,d,p].every(h=>Number.isFinite(h)&&h>0)||![b,E].every(Number.isFinite))return null;const{width:f,height:C}=_n(c,l,d,p),z=Math.min(t.width/c,t.height/l),N=c*z,j=l*z,T=b-t.left-(t.width-N)/2,S=E-t.top-(t.height-j)/2;return!w&&(T<0||S<0||T>=N||S>=j)?null:{x:Math.max(0,Math.min(f-1,T*f/N)),y:Math.max(0,Math.min(C-1,S*C/j))}}function Es(t){const c=new Map;return{send(l){const p=l.type==="input_keyboard"?`key:${l.code||l.key}`:`mouse:${l.button}`;if((l.eventType==="keyDown"||l.eventType==="mousePressed")&&c.set(p,{...l}),(l.eventType==="keyUp"||l.eventType==="mouseReleased")&&c.delete(p),l.eventType==="mouseMoved")for(const b of c.values())b.type==="input_mouse"&&(b.x=l.x,b.y=l.y);t(l)},release(){const l=[...c.values()].reverse();c.clear();for(const{text:d,...p}of l)t({...p,eventType:p.type==="input_keyboard"?"keyUp":"mouseReleased",modifiers:0})}}}function Rs({frame:t,width:c,height:l,driving:d,input:p,acknowledge:b,onDecodeError:E,onReturnToToolbar:w}){const f=a.useRef(null),C=a.useRef(""),z=a.useRef(-1),N=t.metadata?.deviceWidth??c,j=t.metadata?.deviceHeight??l,T=`data:image/${t.format==="png"?"png":"jpeg"};base64,${t.data}`,S=a.useMemo(()=>Es(p),[p]),h=S.send,R=a.useRef(!1);a.useLayoutEffect(()=>(d||S.release(),S.release),[d,S]),a.useEffect(()=>(window.addEventListener("blur",S.release),()=>window.removeEventListener("blur",S.release)),[S]);const O=()=>{if(f.current?.complete&&f.current.naturalWidth>0&&f.current.currentSrc===T){if(f.current.currentSrc===C.current&&t.seq===z.current)return;C.current=f.current.currentSrc,z.current=t.seq,b(t.seq)}};a.useEffect(()=>{const o=requestAnimationFrame(O);return()=>cancelAnimationFrame(o)},[t]);const D=(o,B,_=!1)=>{const G=f.current;return!G?.complete||G.currentSrc!==T?null:Cs(G.getBoundingClientRect(),G.naturalWidth,G.naturalHeight,N,j,o,B,_)};return a.useEffect(()=>{const o=f.current;if(!o||!d)return;const B=_=>{_.preventDefault();const G=D(_.clientX,_.clientY);if(!G)return;const u=_.deltaMode===2?_n(o.naturalWidth,o.naturalHeight,N,j).height:0,v=_.deltaMode===1?16:_.deltaMode===2?u:1,A=s=>Math.max(-1e4,Math.min(1e4,s*v));h({type:"input_mouse",eventType:"mouseWheel",...G,deltaX:A(_.deltaX),deltaY:A(_.deltaY),modifiers:Ze(_)})};return o.addEventListener("wheel",B,{passive:!1}),()=>o.removeEventListener("wheel",B)},[d,h,N,j,T]),e.jsx(e.Fragment,{children:e.jsx("img",{ref:f,src:T,alt:"Live bot browser",draggable:!1,tabIndex:d?0:-1,title:d?"Shift+Escape returns to the browser address bar.":void 0,"aria-description":d?r("browser.viewport.keysHint"):void 0,"aria-keyshortcuts":d?"Shift+Escape":void 0,className:`block h-full w-full object-contain select-none outline-none focus:ring-2 focus:ring-inset focus:ring-accent ${d?"cursor-default touch-none":"cursor-not-allowed"}`,onLoad:O,onError:E,onBlur:()=>{R.current=!1,S.release()},onContextMenu:o=>{d&&o.preventDefault()},onPointerDown:o=>{if(!d)return;const B=D(o.clientX,o.clientY);B&&(o.preventDefault(),o.currentTarget.focus(),o.currentTarget.setPointerCapture(o.pointerId),R.current=!0,h({type:"input_mouse",eventType:"mousePressed",...B,button:o.button===2?"right":o.button===1?"middle":"left",clickCount:Math.min(3,o.detail||1),modifiers:Ze(o)}))},onPointerUp:o=>{if(!d)return;o.preventDefault();const B=D(o.clientX,o.clientY,o.currentTarget.hasPointerCapture(o.pointerId));if(!B){S.release();return}h({type:"input_mouse",eventType:"mouseReleased",...B,button:o.button===2?"right":o.button===1?"middle":"left",clickCount:Math.min(3,o.detail||1),modifiers:Ze(o)})},onPointerCancel:S.release,onPointerMove:o=>{if(!d)return;const B=D(o.clientX,o.clientY,o.currentTarget.hasPointerCapture(o.pointerId));B&&h({type:"input_mouse",eventType:"mouseMoved",...B,button:o.buttons&1?"left":o.buttons&2?"right":o.buttons&4?"middle":"none",modifiers:Ze(o)})},onKeyDown:o=>{if(!(!d||o.nativeEvent.isComposing)){if(o.key==="Escape"&&o.shiftKey){o.preventDefault(),o.stopPropagation(),S.release(),w();return}o.key==="Tab"&&!R.current||(Ss.has(o.key)||(R.current=!0),!((o.metaKey||o.ctrlKey)&&o.key.toLowerCase()==="v")&&(o.preventDefault(),h({type:"input_keyboard",eventType:"keyDown",key:o.key,code:o.code,windowsVirtualKeyCode:o.keyCode,modifiers:Ze(o),...o.key.length===1&&!o.metaKey&&!o.ctrlKey&&!o.altKey?{text:o.key}:{}})))}},onKeyUp:o=>{if(!(!d||(o.metaKey||o.ctrlKey)&&o.key.toLowerCase()==="v")){if(o.key==="Escape"&&o.shiftKey){o.preventDefault(),o.stopPropagation();return}o.key==="Tab"&&!R.current||(o.preventDefault(),h({type:"input_keyboard",eventType:"keyUp",key:o.key,code:o.code,windowsVirtualKeyCode:o.keyCode,modifiers:Ze(o)}))}},onPaste:o=>{d&&(o.preventDefault(),R.current=!0,h({type:"input_keyboard",eventType:"char",text:o.clipboardData.getData("text/plain").slice(0,4096)}))}})})}const jt=t=>t.type==="input_mouse"&&["mouseMoved","mouseWheel"].includes(String(t.eventType)),Xt=t=>t.type==="input_mouse"&&t.eventType==="mouseReleased"||t.type==="input_keyboard"&&t.eventType==="keyUp",Nt=t=>typeof t=="number"&&Number.isFinite(t)?t:0,Tn=t=>Math.max(-1e4,Math.min(1e4,t));function Is(t,c){let l=[],d=null,p=0,b=!1;const E=f=>{l=l.filter(Xt),b||(b=!0,c(f))},w=()=>{if(d||!l.length)return;const f=p;d=(async()=>{for(;f===p&&l.length;){const C=l.shift();try{await t(C)}catch(z){f===p&&E(z)}}})().finally(()=>{d=null,w()})};return{enqueue(f){if(b&&!Xt(f))return;const C=l.at(-1);if(C&&jt(f)&&C.type===f.type&&C.eventType===f.eventType&&C.modifiers===f.modifiers&&C.button===f.button){l[l.length-1]=f.eventType==="mouseWheel"?{...f,deltaX:Tn(Nt(C.deltaX)+Nt(f.deltaX)),deltaY:Tn(Nt(C.deltaY)+Nt(f.deltaY))}:{...f};return}if(l.length>=32){if(jt(f))return;const z=l.findIndex(jt);if(z>=0)l.splice(z,1);else if(E(new Error(r("browser.input.tooSlow"))),!Xt(f)||l.length>=32)return}l.push({...f}),w()},async drain(){for(l=l.filter(f=>!jt(f));d||l.length;)w(),await d},async settle(){for(;d||l.length;)w(),await d},size(){return l.length+(d?1:0)},clear(){p++,l=[],b=!1},stopped(){return b}}}const Ts=8e3,Ps=300,zs=16,$n=new Set(["Alt","Control","Meta","Shift"]),As=new Set(["Backspace","Enter","Tab","Escape","Delete","ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Home","End","PageUp","PageDown"]),Ds=new Set(["navigate","tab-new"]);function Yt(t){if("command"in t)return!0;const{eventType:c,key:l}=t.input;return c==="mousePressed"||c==="mouseWheel"||c==="char"||c==="keyDown"&&!$n.has(String(l))}const Jt=({type:t,code:c,key:l,button:d})=>t==="input_keyboard"?`key:${c||l}`:`mouse:${d}`,Pn=({eventType:t})=>t==="keyDown"||t==="mousePressed",zn=({eventType:t})=>t==="keyUp"||t==="mouseReleased";function Ms(t){if(t.type!=="input_keyboard")return!0;const c=String(t.key);return $n.has(c)?!0:As.has(c)?!1:!t.modifiers||t.modifiers===8&&[...c].length===1}const Os=t=>t?.waited===!0;function Ls(t){let c="bot",l="",d=[],p=!1,b=!1,E=!1,w=!1,f=0,C=Promise.resolve(),z,N;const j=new Set,T=new Set,S=u=>{l=u,t.onTakeStatus(u)},h=u=>{Pn(u)&&Ms(u)?j.add(Jt(u)):zn(u)&&j.delete(Jt(u))},R=()=>!b&&!E&&!p&&!j.size&&!t.busy()&&(c==="held"||c==="bot"&&t.owned()),O=()=>{clearTimeout(z),z=b?void 0:setTimeout(()=>{z=void 0,o()},w?0:Ts)},D=()=>{c="releasing",l==="stale"&&S(""),C=C.then(()=>b?void 0:t.release()).catch(()=>{}).then(()=>{c==="releasing"&&(c="bot")})},o=async()=>{if(!R())return;const u=f;await t.queue.drain(),u===f&&R()&&D()},B=()=>{const u=d.filter(A=>"command"in A&&Ds.has(String(A.command.type))),v=d.some(A=>!u.includes(A)&&Yt(A));d=u;for(const A of j)T.add(A);return j.clear(),v},_=async()=>{p=!0;try{for(let u=d.shift();u&&!b;u=d.shift())"command"in u?await t.command(u.command):(t.queue.enqueue(u.input),t.queue.size()>=zs&&await t.queue.settle())}finally{p=!1,d=[]}},G=()=>{c="taking",t.onError(""),S("pending"),clearTimeout(N),N=setTimeout(()=>{!b&&c==="taking"&&S("slow")},Ps),C=C.then(async()=>{if(b)return;const u=await t.take().then(v=>({reply:v}),v=>(b||t.onError(v instanceof Error?v.message:String(v)),null));clearTimeout(N),!b&&(u?(c="held",S(Os(u.reply)&&B()?"stale":""),await _()):(S(""),c="bot",d=[],j.clear()),O())}).catch(()=>{})};return{interact(u){if(b)return;if("input"in u){const A=Jt(u.input);if(zn(u.input)&&T.delete(A))return;Pn(u.input)&&T.delete(A)}const v=c==="taking"||p;if(c!=="held"&&!v){if(!Yt(u))return;if("input"in u&&t.queue.stopped()){t.onHalted();return}}if(!("command"in u&&v&&d.some(A=>"command"in A))){if(Yt(u)&&(w=!1,l==="stale"&&S("")),"input"in u&&h(u.input),f++,O(),c==="held"&&!v){"input"in u?t.queue.enqueue(u.input):t.command(u.command).then(O);return}d.push(u),v||G()}},observe(){!b&&z===void 0&&t.owned()&&O()},handBack(){b||(w=!0,O())},hold(u){b||E===u||(E=u,u||O())},leave(){!R()||t.queue.size()||(c="releasing",t.release().catch(()=>{}))},close(){b=!0,clearTimeout(z),clearTimeout(N),d=[],j.clear(),T.clear()}}}const Ne="rounded-md p-1.5 text-ink-secondary hover:bg-inset hover:text-ink disabled:opacity-40 disabled:cursor-not-allowed",Vs=[1e3,2e3,4e3,8e3,15e3],An="Connection interrupted. Reconnecting the browser view…",Gt={held:!1,controlling:!1,owned:!1};function Fs({bot:t}){const{state:c}=Tt(),[l,d]=a.useState(0),[p,b]=a.useState(null),[E,w]=a.useState([]),[f,C]=a.useState(""),[z,N]=a.useState(!1),[j,T]=a.useState({held:!1,controlling:!1,owned:!1}),[S,h]=a.useState(!1),[R,O]=a.useState(""),[D,o]=a.useState(!1),[B,_]=a.useState(!1),[G,u]=a.useState({width:1280,height:720}),[v,A]=a.useState(""),[s,le]=a.useState(!1),[je,Q]=a.useState(!1),q=a.useRef(""),F=a.useRef(0),H=a.useRef(null),ce=a.useRef(null),Se=a.useRef(null),$e=a.useRef(null),tt=a.useRef(null),se=a.useRef(null),ne=a.useRef(null),Ce=a.useRef(Gt),Ae=a.useRef(""),Ee=a.useRef(!1),De=a.useRef(0),mt=a.useRef(""),m=t.browserProfile==="guest"?"Temporary browser":c.config?.browserProfiles?.find(g=>g.id===t.browserProfile)?.name??`${t.name}’s own browser`;a.useEffect(()=>{D?$e.current?.showModal():$e.current?.close()},[D]),a.useEffect(()=>{ne.current?.hold(B),B?tt.current?.showModal():tt.current?.close()},[B]);const k=a.useCallback(async(g,X=q.current)=>{if(!X)throw new Error("Open the browser connection first.");return W(`/api/bots/${encodeURIComponent(t.id)}/browser/action`,{method:"POST",body:JSON.stringify({...g,viewerId:X}),timeoutMs:12e4})},[t.id]),Re=a.useCallback(g=>{Ce.current.held&&!Ce.current.owned||ne.current?.interact(g)},[]),nt=a.useCallback(g=>Re({input:g}),[Re]),ie=g=>Re({command:g}),ae=a.useCallback(()=>{F.current++,De.current=0,q.current="",se.current?.clear(),se.current=null,ne.current?.close(),ne.current=null,H.current=null,d(g=>g+1)},[]);a.useEffect(()=>{const g=++F.current,X=()=>F.current===g,ue=JSON.stringify([t.id,t.browserProfile]);mt.current!==ue&&(mt.current=ue,De.current=0);let Oe=!1,oe;q.current="",H.current=null,Ae.current="",Ee.current=!1,b(null),w([]),C(""),N(!1),O(""),Q(!1),T({held:!1,controlling:!1,owned:!1}),h(!1),Ce.current=Gt,A("");const Xe=new EventSource(`/api/bots/${encodeURIComponent(t.id)}/browser/live`),de=(V,Z)=>Xe.addEventListener(V,ge=>{if(!(Oe||!X()))try{Z(JSON.parse(ge.data))}catch{}});return de("waiting",()=>{q.current||Q(!0)}),de("ready",V=>{if(typeof V.viewerId!="string"||!V.viewerId)return;Q(!1);const Z=V.viewerId;q.current=Z;const ge=Is(async me=>{X()&&q.current===Z&&await k(me,Z)},me=>{!X()||q.current!==Z||(Ae.current=me instanceof Error?me.message:String(me),O(Ae.current))});se.current=ge,ne.current=Ls({queue:ge,take:()=>k({type:"take"},Z),release:()=>k({type:"release"},Z),command:me=>He(me),busy:()=>H.current!==null,owned:()=>Ce.current.owned,onTakeStatus:A,onError:O,onHalted:()=>O(Ae.current)}),N(!0)}),de("heartbeat",()=>{De.current=0}),de("frame",V=>{q.current&&b({...V,viewerId:q.current,generation:g})}),de("tabs",V=>{if(!Array.isArray(V.tabs))return;w(V.tabs);const Z=V.tabs.find(ge=>ge.active);Z&&!Ee.current&&C(Z.url==="about:blank"?"":Z.url)}),de("url",V=>{typeof V.url=="string"&&!Ee.current&&C(V.url==="about:blank"?"":V.url)}),de("status",V=>{V.viewportWidth>0&&V.viewportHeight>0&&u({width:V.viewportWidth,height:V.viewportHeight})}),de("control",V=>{Ce.current=V,T(V),V.held&&!V.owned&&(b(null),w([]),C("")),ne.current?.observe()}),Xe.addEventListener("error",V=>{if(Oe||!X())return;Oe=!0;let Z="Browser connection ended. Reconnect to continue watching.",ge=!(V instanceof MessageEvent);if(V instanceof MessageEvent)try{const ve=JSON.parse(V.data);Z=ve.message||Z,ge=ve.retryable===!0}catch{}const me=ge?Vs[De.current]:void 0;me!==void 0&&(De.current++,Z=An,oe=setTimeout(()=>{X()&&(F.current++,d(ve=>ve+1))},me)),O(Z),Q(!1),N(!1),b(null),T({held:!1,controlling:!1,owned:!1}),Ce.current=Gt,A(""),q.current="",se.current?.clear(),se.current=null,ne.current?.close(),ne.current=null,Xe.close()}),()=>{Oe=!0,clearTimeout(oe),X()&&(ne.current?.leave(),ne.current?.close(),ne.current=null,F.current++,q.current="",H.current=null,se.current?.clear(),se.current=null),Xe.close()}},[t.id,t.browserProfile,l,k]),a.useEffect(()=>{const g=()=>le(!!ce.current&&document.fullscreenElement===ce.current);return document.addEventListener("fullscreenchange",g),()=>document.removeEventListener("fullscreenchange",g)},[]);const rt=()=>{const g=!!ce.current&&document.fullscreenElement===ce.current;(g?document.exitFullscreen():ce.current?.requestFullscreen())?.catch(()=>O(g?"Could not leave full screen. Press Esc instead.":"Full screen is unavailable in this browser."))},He=async g=>{if(H.current!==null)return;const X=q.current,ue=F.current,Oe=se.current;H.current=ue,h(!0),O("");try{if(await Oe?.drain(),F.current!==ue||q.current!==X)return;await k(g,X),se.current?.stopped()&&F.current===ue&&O(Ae.current),F.current===ue&&g.type==="restart"&&ae()}catch(oe){F.current===ue&&O(oe instanceof Error?oe.message:String(oe))}finally{F.current===ue&&H.current===ue&&(H.current=null,h(!1))}},M=j.held&&!j.owned,Me=z&&!M&&!S,re=Me&&j.owned&&j.controlling,he=v==="pending"||v==="slow",K=Me&&!he,Ie=R===An,Te="flex max-w-full items-center gap-1.5 whitespace-nowrap rounded-full border bg-menu px-2.5 py-1 text-[11px] shadow-sm sm:text-[12px]";return e.jsxs("div",{ref:ce,className:"flex min-h-0 flex-1 flex-col overflow-hidden rounded-2xl border border-hairline/40 bg-card text-ink",children:[e.jsxs("div",{className:"flex min-h-12 items-center gap-1 px-2 pt-1.5",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1 overflow-x-auto",children:[E.length?E.map(g=>e.jsxs("div",{className:`flex max-w-52 shrink-0 items-center gap-1 rounded-xl px-1 text-[12px] ${g.active?"bg-inset text-ink":"text-ink-secondary"}`,children:[e.jsx(We,{size:13,className:"ml-1.5 shrink-0 opacity-60"}),e.jsx("button",{className:"truncate px-1 py-2 text-left disabled:cursor-default",disabled:!K,onClick:()=>ie({type:"tab-select",tabId:g.tabId}),title:g.title||g.url,children:g.title||"New tab"}),e.jsx("button",{className:Ne,"aria-label":`Close ${g.title||"tab"}`,disabled:!K,onClick:()=>ie({type:"tab-close",tabId:g.tabId}),children:e.jsx(St,{size:13})})]},g.tabId)):e.jsxs("div",{className:"flex items-center gap-2 rounded-xl bg-inset px-3 py-2 text-[12px] text-ink-secondary",children:[e.jsx(We,{size:13}),"New tab"]}),e.jsx("button",{className:`${Ne} shrink-0`,disabled:!K,"aria-label":"New tab",title:"New tab",onClick:()=>ie({type:"tab-new"}),children:e.jsx(sr,{size:17})})]}),e.jsx("button",{className:Ne,title:s?"Exit full screen":"Full screen","aria-label":s?"Exit full screen":"Full screen",onClick:rt,children:s?e.jsx(us,{size:16}):e.jsx(It,{size:16})}),e.jsx("button",{className:`${Ne} rounded-xl bg-inset p-2`,title:`Browser profile: ${m}`,"aria-label":"Browser profiles","aria-expanded":D,onClick:()=>{ne.current?.handBack(),o(!0)},children:e.jsx(bs,{size:16})})]}),e.jsxs("form",{className:"flex h-12 items-center gap-1 border-b border-hairline/40 px-2",onSubmit:g=>{g.preventDefault(),K&&f.trim()&&ie({type:"navigate",url:/^https?:\/\//i.test(f.trim())?f.trim():`https://${f.trim()}`})},children:[e.jsxs("div",{className:"flex shrink-0 items-center",children:[e.jsx("button",{type:"button",className:Ne,disabled:!K,"aria-label":"Back",onClick:()=>ie({type:"back"}),children:e.jsx(Fn,{size:17})}),e.jsx("button",{type:"button",className:Ne,disabled:!K,"aria-label":"Forward",onClick:()=>ie({type:"forward"}),children:e.jsx(ar,{size:17})}),e.jsx("button",{type:"button",className:Ne,disabled:!K,"aria-label":"Reload page",onClick:()=>ie({type:"reload"}),children:e.jsx(Wr,{size:17})})]}),e.jsx("input",{ref:Se,"aria-label":"Browser address",readOnly:!K,value:f,onChange:g=>C(g.target.value),onFocus:g=>{Ee.current=!0,K&&g.target.select()},onBlur:()=>{Ee.current=!1},placeholder:z?"about:blank":"Connecting…",spellCheck:!1,className:"mx-1 min-w-0 flex-1 rounded-lg bg-transparent px-2 py-1.5 text-center text-[12px] outline-none placeholder:text-ink-secondary focus:bg-inset focus:text-left"}),e.jsxs("details",{className:"relative shrink-0",children:[e.jsx("summary",{className:`${Ne} list-none cursor-pointer [&::-webkit-details-marker]:hidden`,"aria-label":"Browser menu",title:"Browser menu",children:e.jsx(ls,{size:17})}),e.jsxs("div",{className:"absolute right-0 top-full z-20 mt-2 flex w-44 flex-col rounded-xl border border-hairline/50 bg-card p-1.5 text-[12px] shadow-xl",children:[e.jsx("button",{type:"button",className:"rounded-md px-3 py-2 text-left hover:bg-inset disabled:opacity-40",disabled:!re,onClick:g=>{g.currentTarget.closest("details")?.removeAttribute("open"),_(!0)},children:"Type or paste text…"}),e.jsx("button",{type:"button",className:"rounded-md px-3 py-2 text-left hover:bg-inset",onClick:g=>{g.currentTarget.closest("details")?.removeAttribute("open"),ae()},children:"Reconnect view"}),e.jsx("button",{type:"button",className:"rounded-md px-3 py-2 text-left hover:bg-inset disabled:opacity-40",disabled:!z||S||he,onClick:g=>{g.currentTarget.closest("details")?.removeAttribute("open"),window.confirm("Restart this profile’s browser? Open tabs will close. Saved logins are kept. Stop any bots using it first.")&&He({type:"restart"})},children:"Restart browser…"})]})]})]}),R&&e.jsxs("div",{role:Ie?"status":"alert",className:`flex items-center justify-between gap-2 border-b border-hairline/30 px-3 py-2 text-[12px] ${Ie?"text-ink-secondary":"text-danger"}`,children:[e.jsx("span",{children:R}),!z&&e.jsx("button",{className:"shrink-0 underline",onClick:ae,children:"Reconnect"})]}),e.jsxs("div",{className:"relative min-h-0 flex-1 overflow-hidden bg-inset/40",children:[p?e.jsx(Rs,{frame:p,...G,driving:Me,input:nt,onReturnToToolbar:()=>Se.current?.focus(),acknowledge:g=>{F.current===p.generation&&q.current===p.viewerId&&k({type:"ack",seq:g},p.viewerId).catch(()=>{})},onDecodeError:()=>{F.current===p.generation&&q.current===p.viewerId&&O("A browser frame could not be decoded. Close and reopen the panel to reconnect.")}}):e.jsxs("div",{className:"flex min-h-64 flex-col items-center justify-center gap-3 p-6 text-center text-[13px] text-ink-secondary",children:[z&&M?e.jsx(_e,{size:24}):R&&!Ie?e.jsx(We,{size:24}):e.jsx(U,{size:24,className:"animate-spin"}),e.jsx("span",{children:M?"Live view paused for human control":Ie?"Reconnecting…":R?"Browser disconnected":je?r("browser.live.botBusy",{name:t.name}):"Opening the live browser…"})]}),e.jsx("div",{role:"status",className:"pointer-events-none absolute inset-x-0 top-2 flex justify-center px-3",children:v==="slow"?e.jsxs("span",{className:`${Te} border-hairline text-ink-secondary`,children:[e.jsx(U,{size:13,className:"shrink-0 animate-spin","aria-hidden":"true"}),e.jsx("span",{className:"truncate",children:r("browser.control.waiting",{name:t.name})})]}):v==="stale"?e.jsxs("span",{className:`${Te} border-accent-border text-accent-text`,children:[e.jsx(_e,{size:13,className:"shrink-0","aria-hidden":"true"}),e.jsx("span",{className:"truncate",children:r("browser.control.stale",{name:t.name})})]}):!v&&j.owned&&j.controlling?e.jsxs("span",{className:`${Te} border-accent-border text-accent-text`,"aria-description":r("browser.control.yoursHint",{name:t.name}),children:[e.jsx(_e,{size:13,className:"shrink-0","aria-hidden":"true"}),e.jsx("span",{className:"truncate",children:r("browser.control.yours")})]}):null})]}),e.jsxs("dialog",{ref:$e,onClose:()=>o(!1),onClick:g=>{g.target===g.currentTarget&&o(!1)},className:"m-auto w-[min(420px,calc(100%-32px))] max-h-[80vh] overflow-auto rounded-2xl border border-hairline/50 bg-card p-5 text-ink shadow-2xl backdrop:bg-black/40",children:[e.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[e.jsx("h2",{className:"text-[15px] font-medium",children:"Browser profiles"}),e.jsx("button",{className:Ne,"aria-label":"Close browser profiles",onClick:()=>o(!1),children:e.jsx(St,{size:16})})]}),(M||j.owned&&(S||he))&&e.jsx("p",{className:"mb-3 text-[12px] text-ink-secondary",children:r(M?"browser.profiles.heldElsewhere":"browser.profiles.busy")}),e.jsx(Qr,{bot:t,disabled:S||j.held,onProfileChanged:()=>{o(!1),ae()}})]}),e.jsxs("dialog",{ref:tt,onClose:()=>_(!1),className:"m-auto w-[min(420px,calc(100%-32px))] rounded-2xl border border-hairline/50 bg-card p-5 text-ink shadow-2xl backdrop:bg-black/40",children:[e.jsxs("div",{className:"mb-3 flex items-center justify-between",children:[e.jsx("h2",{className:"text-[14px] font-medium",children:"Type into the selected page field"}),e.jsx("button",{className:Ne,"aria-label":"Close typing",onClick:()=>_(!1),children:e.jsx(St,{size:16})})]}),e.jsxs("form",{className:"flex flex-col gap-3",onSubmit:g=>{g.preventDefault();const X=g.currentTarget.elements.namedItem("pageText");re&&X.value&&(nt({type:"input_keyboard",eventType:"char",text:X.value}),X.value="",_(!1))},children:[e.jsx("input",{name:"pageText","aria-label":"Text for the page",autoComplete:"off",maxLength:4096,placeholder:"Type or paste text",className:"rounded-lg bg-inset px-3 py-2 text-[13px] outline-none focus:ring-1 focus:ring-accent"}),e.jsx("button",{disabled:!re,className:"self-end rounded-lg bg-accent px-4 py-2 text-[12px] text-accent-ink disabled:opacity-40",children:"Type"})]})]})]})}function _s({bot:t}){const{state:c}=Tt(),l=c.config?.browserEngine,[d,p]=a.useState(!1),[b,E]=a.useState(null),[w,f]=a.useState(null);a.useEffect(()=>{let N=!0;return W("/api/auth/session").then(j=>{N&&f(j.scopes.includes("admin"))}).catch(()=>{N&&f(!1)}),()=>{N=!1}},[]);const C=d||l?.installing===!0,z=async()=>{E(null),p(!0);try{await W("/api/browser-engine/install",{method:"POST"})}catch(N){E(N instanceof Error?N.message:String(N))}finally{p(!1)}};return w===!1?e.jsx("div",{className:"p-5 text-[13px] text-ink-secondary",children:"Only admins of this installation can view or control saved browser sessions."}):t.browser===!1?e.jsx("div",{className:"p-5 text-[13px] text-ink-secondary",children:"Enable the browser in this bot’s profile to use it."}):l?.kind==="engine"&&!C&&!l.installError?w===null?e.jsx("div",{className:"p-5 text-[13px] text-ink-secondary",children:"Loading browser…"}):e.jsx(Fs,{bot:t},t.id):e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col items-start justify-center gap-3 rounded-xl bg-card p-5",children:[e.jsx("div",{className:"text-[15px] font-medium text-ink",children:l?.kind==="engine"?"Browser installation incomplete":"Browser engine not installed"}),e.jsx("p",{className:"text-[13px] leading-relaxed text-ink-secondary",children:l?.kind==="engine"?"agent-browser is installed, but Chrome setup has not finished. Retry the browser installation.":Qt(c.config)}),l?.installable||l?.kind==="engine"?e.jsx("button",{type:"button",onClick:()=>{z()},disabled:C||w!==!0,className:"rounded-lg bg-accent px-3 py-1.5 text-[13px] font-medium text-accent-ink disabled:opacity-60",children:C?"Installing… (a one-time download of about 160 MB)":l?.kind==="engine"?"Retry browser installation":"Install the browser engine"}):null,(l?.installError||b)&&e.jsx("p",{role:"alert",className:"text-[12px] text-danger",children:b??l?.installError})]})}function Ct(t){for(const c of t?.getTracks()??[])c.stop()}function $s(t){const c=t instanceof DOMException?t.name:"";return c==="NotAllowedError"||c==="AbortError"?{ok:!1,phase:"cancelled",messageKey:"computer.screen.cancelled"}:c==="NotFoundError"||c==="NotReadableError"||c==="NotSupportedError"||c==="SecurityError"?{ok:!1,phase:"unavailable",messageKey:"computer.screen.unavailableNow"}:{ok:!1,phase:"error",messageKey:"computer.screen.error"}}async function Bs({beginIntent:t,getDisplayMedia:c}){try{if(!t())return{ok:!1,phase:"unavailable",messageKey:"computer.screen.unavailableWindow"};const l=await c({video:!0,audio:!1});return l.getVideoTracks().length===0?(Ct(l),{ok:!1,phase:"unavailable",messageKey:"computer.screen.noVideoTrack"}):{ok:!0,stream:l}}catch(l){return $s(l)}}const dt={idle:"computer.screen.idle",ended:"computer.screen.ended",unavailable:"computer.screen.unavailable"};function Ks(){const{capabilities:t,ready:c}=Pt(),l=t.screenPreview,d=t.host.platform==="linux",[p,b]=a.useState("idle"),[E,w]=a.useState(dt.idle),[f,C]=a.useState(""),z=a.useRef(null),N=a.useRef(null),j=a.useRef(0),T=a.useCallback((O,D)=>{j.current+=1;const o=N.current;N.current=null,z.current&&(z.current.srcObject=null),Ct(o),b(O),w(D)},[]);a.useEffect(()=>()=>{j.current+=1;const O=N.current;N.current=null,Ct(O)},[]);const S=async()=>{if(!l.available||!window.ogb?.beginScreenPreviewIntent||!navigator.mediaDevices?.getDisplayMedia){b("unavailable"),w(dt.unavailable);return}T("requesting","computer.screen.waiting");const O=j.current,D=await Bs({beginIntent:()=>window.ogb.beginScreenPreviewIntent(),getDisplayMedia:G=>navigator.mediaDevices.getDisplayMedia(G)});if(O!==j.current){D.ok&&Ct(D.stream);return}if(!D.ok){b(D.phase),w(D.messageKey);return}const o=D.stream,B=o.getVideoTracks()[0];N.current=o,C(B.label),B.addEventListener("ended",()=>{N.current===o&&T("ended",dt.ended)},{once:!0});const _=z.current;if(!_){T("error","computer.screen.displayFailed");return}_.srcObject=o;try{await _.play()}catch{O===j.current&&N.current===o&&T("error","computer.screen.displayFailed");return}O!==j.current||N.current!==o||(b("streaming"),w("computer.screen.active"))};if(!d)return null;const h=f||r("computer.screen.selected"),R=p==="cancelled"||p==="ended"||p==="unavailable"||p==="error";return e.jsxs("section",{className:"mt-4 rounded-xl bg-card p-4","aria-labelledby":"local-preview-title",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{id:"local-preview-title",className:"text-[15px] font-medium text-ink",children:r("computer.screen.title")}),e.jsx("div",{className:"mt-0.5 text-[12px] leading-relaxed text-ink-secondary",children:r("computer.screen.subtitle")})]}),e.jsx("span",{className:"shrink-0 rounded-full bg-raised px-2 py-1 text-[10px] font-medium text-ink-secondary",children:r("computer.screen.badge")})]}),e.jsxs("div",{className:"relative mt-3 flex aspect-[16/10] items-center justify-center overflow-hidden rounded-lg bg-panel",children:[e.jsx("video",{ref:z,autoPlay:!0,muted:!0,playsInline:!0,"aria-label":r("computer.screen.videoAria"),className:p==="streaming"?"h-full w-full object-contain":"hidden"}),p!=="streaming"&&e.jsxs("div",{className:"flex flex-col items-center gap-2 px-6 text-center text-ink-secondary",children:[p==="requesting"?e.jsx(U,{size:18,className:"animate-spin"}):e.jsx(Fe,{size:22}),e.jsx("span",{className:"text-[12px]","aria-live":"polite",children:c?r(l.available?E:dt.unavailable):r("computer.screen.checking")})]})]}),p==="streaming"&&e.jsxs("div",{className:"mt-2 flex items-center justify-between gap-3 text-[11px] text-ink-secondary",children:[e.jsx("span",{className:"truncate",title:h,children:l.interaction==="portal-picker"?h:r("vm.dest.local")}),e.jsxs("span",{className:"flex items-center gap-1.5 text-success",children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-success"})," ",r("computer.screen.sharing")]})]}),e.jsxs("button",{type:"button",disabled:p==="requesting"||!l.available&&p!=="streaming",onClick:p==="streaming"?()=>T("idle",dt.idle):()=>{S()},className:"mt-3 flex w-full items-center justify-center gap-2 rounded-lg bg-raised py-2 text-[13px] text-ink hover:bg-raised-hover disabled:cursor-not-allowed disabled:opacity-50",children:[p==="requesting"?e.jsx(U,{size:14,className:"animate-spin"}):p==="streaming"?e.jsx(or,{size:13}):R?e.jsx(Zt,{size:14}):e.jsx(Fe,{size:14}),p==="requesting"?r("computer.screen.choosing"):p==="streaming"?r("computer.screen.stop"):R?r("computer.linux.tryAgain"):l.interaction==="portal-picker"?r("computer.screen.choose"):r("computer.screen.start")]})]})}const Us="https://github.com/milind-soni/OpenMausBot/blob/main/docs/linux-desktop.md#enable-local-control";function qs(){const{capabilities:t}=Pt(),c=t.localComputer,[l,d]=a.useState(null),[p,b]=a.useState(null);if(t.host.platform!=="linux")return null;const E=l!==null||c.status==="checking"||c.status==="starting",w=c.available,f=c.reasonCode==="linux-wayland-seat-safety-blocked",C=t.host.session==="wayland",z=c.driverSource==="bundled",N=async j=>{if(window.ogb?.localControl){d(j),b(null);try{if((j==="disable"||j==="retry")&&!(await fetch("/api/local-computer/interrupt",{method:"POST"})).ok){b({key:"computer.linux.stopFailed"});return}await window.ogb.localControl[j]()}catch(T){b(T instanceof Error?T.message:String(T))}finally{d(null)}}};return e.jsxs("section",{className:"mt-4 rounded-xl bg-card p-4","aria-labelledby":"linux-local-control-title",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs("div",{id:"linux-local-control-title",className:"flex items-center gap-2 text-[15px] font-medium text-ink",children:[e.jsx(ps,{size:16,className:w?"text-success":"text-ink-secondary"}),r("computer.linux.title")]}),e.jsx("div",{className:"mt-1 text-[12px] leading-relaxed text-ink-secondary",children:r("computer.linux.meta",{session:C?"Wayland":"Xorg"})})]}),e.jsx("span",{className:Ve("shrink-0 rounded-full px-2 py-1 text-[10px] font-medium",w?"bg-success/10 text-success":f?"bg-danger/10 text-danger":c.enabled?"bg-warning/10 text-warning":"bg-raised text-ink-secondary"),children:w?r("computer.linux.ready"):f?r("computer.linux.waylandBadge"):c.enabled?r("vm.state.attention"):r("vm.dest.off")})]}),f?e.jsx("div",{className:"mt-3 rounded-lg border border-danger/20 bg-danger/5 p-3",children:e.jsxs("div",{className:"flex gap-2 text-[12px] leading-relaxed text-ink-secondary",children:[e.jsx(Wt,{size:15,className:"mt-0.5 shrink-0 text-danger"}),e.jsxs("span",{children:[r("computer.linux.waylandBefore")," ",e.jsx("strong",{className:"font-medium text-ink",children:r("computer.linux.waylandXorg")})," ",r("computer.linux.waylandAfter")]})]})}):c.enabled?e.jsxs("div",{className:"mt-3 rounded-lg bg-panel p-3 text-[12px] text-ink-secondary",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[w?e.jsx(ir,{size:15,className:"mt-0.5 shrink-0 text-success"}):E?e.jsx(U,{size:15,className:"mt-0.5 shrink-0 animate-spin"}):e.jsx(Wt,{size:15,className:"mt-0.5 shrink-0 text-warning"}),e.jsx("span",{"aria-live":"polite",children:w?r("computer.linux.readyMsg"):c.message??r("computer.linux.checking")})]}),c.driverPath&&e.jsxs("div",{className:"mt-2 break-all font-mono text-[10px] text-ink-tertiary",title:c.driverPath,children:[z?r("computer.linux.bundledDriver"):c.driverPath,c.driverVersion?` · ${c.driverVersion}`:""]})]}):e.jsx("div",{className:"mt-3 rounded-lg border border-warning/20 bg-warning/5 p-3",children:e.jsxs("div",{className:"flex gap-2 text-[12px] leading-relaxed text-ink-secondary",children:[e.jsx(Wt,{size:15,className:"mt-0.5 shrink-0 text-warning"}),e.jsxs("span",{children:[r("computer.linux.enableBefore")," ",e.jsx("strong",{className:"font-medium text-ink",children:r("vm.dest.local")})," ",r("computer.linux.enableAfter"),C&&` ${r("computer.linux.waylandInput")}`]})]})}),p&&e.jsx("div",{className:"mt-2 text-[12px] text-danger",children:typeof p=="string"?p:r(p.key)}),!f&&e.jsx("div",{className:"mt-3 flex gap-2",children:c.enabled?e.jsxs(e.Fragment,{children:[!w&&e.jsxs("button",{type:"button",disabled:E,onClick:()=>{N("retry")},className:"flex flex-1 items-center justify-center gap-2 rounded-lg bg-raised py-2 text-[13px] text-ink hover:bg-raised-hover disabled:opacity-50",children:[l==="retry"?e.jsx(U,{size:14,className:"animate-spin"}):e.jsx(Zt,{size:14}),r("computer.linux.tryAgain")]}),e.jsxs("button",{type:"button",disabled:l!==null,onClick:()=>{N("disable")},className:"flex flex-1 items-center justify-center gap-2 rounded-lg bg-raised py-2 text-[13px] text-ink hover:bg-raised-hover disabled:opacity-50",children:[l==="disable"?e.jsx(U,{size:14,className:"animate-spin"}):e.jsx(pt,{size:14}),r("computer.linux.disable")]})]}):e.jsxs("button",{type:"button",disabled:E,onClick:()=>{N("enable")},className:"flex flex-1 items-center justify-center gap-2 rounded-lg bg-accent py-2 text-[13px] font-medium text-white hover:opacity-90 disabled:opacity-50",children:[l==="enable"?e.jsx(U,{size:14,className:"animate-spin"}):e.jsx(pt,{size:14}),r("computer.linux.enable")]})}),e.jsxs("button",{type:"button",onClick:()=>window.open(Us,"_blank","noopener,noreferrer"),className:"mt-2 flex w-full items-center justify-center gap-1.5 rounded-lg py-1.5 text-[11px] text-ink-secondary hover:bg-raised hover:text-ink",children:[t.host.packaged?r("computer.linux.guide"):r("computer.linux.driverSetup")," ",e.jsx(lr,{size:11})]})]})}class te extends Error{constructor(c,l,d){super(c),this.key=c,this.problem=l,this.fallbackKey=d}key;problem;fallbackKey}function Dn(t){return t instanceof te?r(t.key,t.fallbackKey?{problem:t.problem??r(t.fallbackKey)}:void 0):t instanceof Error?t.message:t}const Mn=Fr({held:$r().optional().default(!1),helpReason:_r().nullable().optional().default(null)}).passthrough(),Bn="omb-computer-panel-width",Et=360,Rt=960,Ws=400,On=40;function Hs(){try{const t=Number(localStorage.getItem(Bn));if(Number.isFinite(t)&&t>=Et&&t<=Rt)return t}catch{}return Ws}function na({bot:t,onOpenVmWorkspace:c}){const{padClass:l}=cr(),[d,p]=a.useState(Hs),b=a.useRef(null),E=n=>{try{localStorage.setItem(Bn,String(n))}catch{}},w=n=>{b.current={x:n.clientX,width:d},n.currentTarget.setPointerCapture(n.pointerId)},f=n=>{if(!b.current)return;const i=Math.min(Rt,Math.max(Et,b.current.width+(b.current.x-n.clientX)));p(i)},C=n=>{b.current&&(b.current=null,n.currentTarget.releasePointerCapture(n.pointerId),E(d))},z=n=>{p(i=>{const x=Math.min(Rt,Math.max(Et,i+n));return E(x),x})},N=a.useRef(null),[j,T]=a.useState(null);a.useEffect(()=>{const n=N.current?.closest("aside");if(!n)return;const i=()=>T(n.offsetWidth);i();const x=new ResizeObserver(i);return x.observe(n),()=>x.disconnect()},[]);const S=n=>{if(n.ctrlKey||n.metaKey||n.altKey)return;const i=n.key==="ArrowLeft"?On:n.key==="ArrowRight"?-On:null;i===null||j===null||(n.preventDefault(),z(i))},{state:h,dispatch:R,flushBotPatches:O}=Tt(),D=t.tasks?.find(n=>n.threadId===t.threadId),o=ur(t,D),B=dr(t),_=`${t.id}:${t.threadId}:${o}:${t.cloudBackend??"box"}:${B.modelSelection.instanceId}`,[G,u]=a.useState(null),v=G?.key===_,A=o!=="auto"||v,s={...B,computer:o==="auto"?v?G.surface:void 0:o},le=`${s.id}:${s.threadId}:${s.computer}:${s.cloudBackend??"box"}`,je=a.useRef(le);je.current=le;const Q=a.useRef(null);a.useEffect(()=>()=>Q.current?.abort(),[le]);const q=!!s.busy,F=a.useCallback(n=>`/api/bots/${t.id}/${n}?threadId=${encodeURIComponent(t.threadId)}`,[t.id,t.threadId]),H=t.computer==="cloud"&&o==="cloud",ce=t.computer==="vm"&&o==="vm",{capabilities:Se,ready:$e}=Pt(),tt=Se.localComputer.available,se=Se.host.platform==="linux",ne=pr(h.instances,s),Ce=jn("local",h.config)&&mr({capabilities:Se,providerSupportsLocal:ne}),[Ae,Ee]=a.useState(null),De=xr({capabilities:Se,providerSupportsLocal:ne}),mt=fr(h.config,Se.host.platform),[m,k]=a.useState("checking"),[Re,nt]=a.useState(null),[ie,ae]=a.useState(null),[rt,He]=a.useState(null),M=s.cloudBackend??"box",Me=!!(Re&&Re.botId===s.id&&Re.computer===t.computer&&Re.cloudBackend===M&&Re.section===(s.section?.trim()??"")),re=!!(ie&&ie.botId===s.id&&ie.threadId===s.threadId&&ie.computer===s.computer&&ie.cloudBackend===M),he=re&&o==="auto"&&M==="box"&&rt?.botId===s.id&&rt.section===(s.section?.trim()??"")?rt:null,K=re&&br({computer:s.computer,cloudBackend:M,phase:m,botId:s.id,resolvedBotId:ie?.botId??null,resolvedComputer:ie?.computer??null,resolvedCloudBackend:ie?.cloudBackend??null}),Ie=a.useCallback(n=>{ae(null),He(null),k("checking"),R({type:"updateBot",botId:s.id,patch:n})},[s.id,R]);a.useEffect(()=>{let n=!0;return nt(null),O(s.id).then(i=>{n&&(i&&!hr({computer:t.computer,cloudBackend:M,persistedBot:i})||i&&(i.section?.trim()??"")!==(s.section?.trim()??"")||nt({botId:s.id,computer:t.computer,cloudBackend:M,section:s.section?.trim()??""}))}),()=>{n=!1}},[s.id,t.computer,s.section,M,O]);const[Te,g]=a.useState(null),[X,ue]=a.useState(null),[Oe,oe]=a.useState(null),[Xe,de]=a.useState(!1),[V,Z]=a.useState(0),[ge,me]=a.useState(null),[ve,tn]=a.useState(null),[ye,xt]=a.useState(null),[nn,zt]=a.useState(null),[Kn,rn]=a.useState(null),[P,we]=a.useState(null),[ke,ft]=a.useState(!1),[bt,sn]=a.useState(!1),[ht,L]=a.useState(null),Be=Dn(ht),ee=gr(),[st,At]=a.useState(()=>Nn(s.id)),$=ee?st==="files"?"computer":st:st==="routines"||st==="android"?"computer":st,an=js(),gt=an.devices.length>0,on=vr(h.config),Le=Sn(h.config)&&s.browser!==!1&&(on||h.config?.browserEngine?.installable===!0),[ln,Ye]=a.useState(0);a.useEffect(()=>{if(o!=="auto"||!Me)return;const n=new AbortController;return u(null),W(F("computer"),{signal:n.signal}).then(i=>{if(n.signal.aborted)return;const x=i.surface;u({key:_,surface:x==="cloud"||x==="vm"||x==="local"||x==="browser"||x==="off"?x:void 0})}).catch(i=>{n.signal.aborted||(L(i instanceof Error?i:String(i)),k("error"))}),()=>n.abort()},[_,o,Me,F,ln]);const Dt=m==="vm-unavailable"&&ye?.resumable===!0,at=a.useRef(0),Ke=a.useRef(null);a.useEffect(()=>(Ke.current?.signal.aborted&&(Ke.current=null,we(null)),()=>{Ke.current?.abort()}),[s.id,s.threadId,s.computer,$]);const vt=h.instances.find(n=>n.instanceId===s.modelSelection.instanceId),Ue=n=>{At(n),Cn(s.id,n)},cn=a.useRef(null);a.useEffect(()=>{const n=cn.current;n===le&&!(s.computer==="browser"&&Le)||(cn.current=le,At(s.computer==="browser"&&Le?"browser":n===null?Nn(s.id):"computer"))},[le,s.id,s.computer,Le]),a.useEffect(()=>{let n=!0;const i=window.ogb?.desktopViewer;i?.currentState&&i.currentState().then(y=>{n&&sn(y.open&&y.contextId===s.id)}).catch(()=>{});const x=i?.onState(y=>{y.contextId===s.id&&sn(y.open)});return()=>{n=!1,x?.()}},[s.id]),a.useEffect(()=>{!gt&&$==="android"&&(At("computer"),Cn(s.id,"computer"))},[gt,s.id,$]),a.useEffect(()=>{at.current=0},[s.id,s.computer]);const un=!!(vt?.snapshot.state==="available"&&vt.capabilities?.computerMcp),Mt=Hr(Xr(vt)),dn=h.routines.filter(n=>n.botId===s.id).sort((n,i)=>Number(i.enabled)-Number(n.enabled)||(n.nextRunAt??1/0)-(i.nextRunAt??1/0)),Un=!!(h.config?.box.configured&&Yr(h.instances,s.modelSelection.instanceId)?.snapshot.state==="available"),ot=h.routineRuns.find(n=>n.botId===s.id&&["queued","running","waiting"].includes(n.status));a.useEffect(()=>{if($!=="computer")return;let n=!0;if(ae(null),He(null),k("checking"),ue(null),oe(null),me(null),tn(null),xt(null),zt(null),rn(null),L(null),!(!Me||!A)){if(s.computer===void 0){k("auto-unavailable");return}if(s.computer==="off"){k("off");return}if(s.computer==="browser"){k("browser");return}if(s.computer==="local"){ne||L(new te("computer.err.localEngine")),k($e&&tt&&ne?"local":"local-unavailable"),ae({botId:s.id,threadId:s.threadId,computer:s.computer,cloudBackend:M});return}if(s.computer==="vm"){if(!un){L(new te("computer.err.vmEngine")),k("vm-unavailable");return}let i;return W(F("local-computer")).then(x=>{if(!n)return;const y=x;ae({botId:s.id,threadId:s.threadId,computer:s.computer,cloudBackend:M}),xt(y);const I=String(y.viewer_url??"");if((I.startsWith("http")||I.startsWith("/desktop-viewer#"))&&tn(new URL(I,window.location.href).href),y.ready)at.current=0,k("vm");else if(y.container==="running"&&y.imageMatches&&y.managed&&y.network==="loopback"&&y.security==="hardened"&&y.persistence==="durable"&&!y.desktopReady&&at.current<15)at.current+=1,L(null),k("checking"),i=window.setTimeout(()=>Ye(Y=>Y+1),2e3);else{const Y=y.mode==="per-bot"&&y.container==="missing"&&y.image&&y.create_supported;L(Y||y.resumable?null:new te("computer.err.vmOpenSettings",y.problem,"computer.err.vmNotReady")),k("vm-unavailable")}}).catch(x=>{n&&(L(x.message),k("vm-unavailable"))}),()=>{n=!1,i!==void 0&&window.clearTimeout(i)}}if(s.computer==="cloud"&&!Mt){k("error");return}if(!(s.computer!=="cloud"&&!$e))return M==="vps"?(W(F("computer")).then(i=>{if(!n)return;const x=i;if(zt(x),ae({botId:s.id,threadId:s.threadId,computer:s.computer,cloudBackend:M}),!x.configured){L(new te("computer.err.vpsAlias")),k("vps-unconfigured");return}if(x.ready){g(x.container??null),k("ready");return}if(x.managed&&x.container!=="missing"&&!x.imageMatches){L(x.problem),k("vps-incompatible");return}if(H)return k("starting"),W(`/api/bots/${s.id}/computer/provision`,{method:"POST"}).then(y=>{n&&(g(y.container??null),y.ready?(ae({botId:s.id,threadId:s.threadId,computer:s.computer,cloudBackend:M}),k("ready")):(L(y.problem??new te("computer.err.vpsNotReady")),k("error")))});g(x.container??null),L(s.autoStartVps?new te("computer.err.vpsAuto",x.problem,"computer.err.vpsNoContainer"):new te("computer.err.vpsManual",x.problem,"computer.err.vpsNoContainer")),k(x.container==="stopped"?"vps-stopped":"vps-unconfigured")}).catch(i=>{n&&(L(i.message),k("error"))}),()=>{n=!1}):(W(F("computer")).then(i=>{if(!n)return;const x=yr({computer:o==="cloud"?"cloud":void 0,configured:!!i.configured,boatState:typeof i.box?.state=="string"?i.box.state:null,canUseCloud:Mt,autoLocal:!1,teamComputer:typeof i.teamComputer?.id=="string"&&typeof i.teamComputer?.name=="string",busy:t.busy});if(ae({botId:s.id,threadId:s.threadId,computer:s.computer,cloudBackend:M}),!i.configured&&s.computer==="cloud"&&!i.teamComputer){k("unconfigured");return}if(x==="team-boat"){He({id:i.teamComputer.id,name:i.teamComputer.name,botId:s.id,section:s.section?.trim()??""}),g(typeof i.box?.state=="string"?i.box.state:i.configured?"missing":"unavailable"),L(typeof i.problem=="string"?i.problem:null),k("team-boat");return}if(x==="attach-ready-boat"||s.computer==="cloud"&&x==="show-ready-boat"){g(typeof i.box?.state=="string"?i.box.state:null),k("ready");return}g(typeof i.box?.state=="string"?i.box.state:null),k(x)}).catch(i=>{n&&(L(i.message),k("error"))}),()=>{n=!1})}},[s.id,s.threadId,s.computer,s.section,s.autoStartVps,M,ln,$e,Ce,se,ne,vt?.driverKind,un,Mt,h.config?.vps?.sshAlias,$,Me,A,H,o,F]),a.useEffect(()=>{if(m!=="busy-boat")return;let n=!0;const i=()=>{if(!t.busy&&o==="cloud"){Ye(y=>y+1);return}W(F("computer")).then(y=>{if(!n)return;const I=typeof y.box?.state=="string"?y.box.state:null;g(I),Lr(I)&&k("ready")}).catch(()=>{})},x=window.setInterval(i,5e3);return()=>{n=!1,window.clearInterval(x)}},[m,F,t.busy,o]);const Je=en(),Ge=a.useRef(0),Ot=a.useRef(s.busy);a.useEffect(()=>{Ot.current=s.busy},[s.busy]),a.useEffect(()=>{if(Ge.current=0,!!K)return wr({onFrame:n=>{n.kind!=="screen"||n.botId!==s.id||n.threadId!==s.threadId||(Ge.current=Date.now(),ue({png:n.png,mime:n.mime??"image/png"}),oe(null),de(!1))}})},[K,s.id,s.threadId]),a.useEffect(()=>{if($!=="computer"||!K||bt||!Je||P||ke)return;let n=!1,i=-1/0,x=null,y=null;const I=new AbortController;oe(null),de(!0);const Y=async()=>{if(n||I.signal.aborted||Date.now()-i<(x??(Ot.current?4e3:3e4))||Ot.current&&Date.now()-Ge.current<1e4)return;n=!0,x=null;const J=Date.now();try{const{png:pe,format:ze}=await W(F("computer/screenshot"),{method:"POST",signal:AbortSignal.any([I.signal,AbortSignal.timeout(9e4)])});if(!I.signal.aborted&&Ge.current<=J){if(typeof pe!="string"||!pe.trim())throw new te("computer.err.emptyFrame");ue({png:pe,mime:ze==="jpeg"?"image/jpeg":"image/png"}),oe(null),de(!1),y=null}}catch(pe){if(!I.signal.aborted&&Ge.current<=J)if(pe instanceof Vr&&Jr(pe)){x=1e3,y??=Date.now();const ze=Date.now()-y>=1e4;oe(ze?pe:null),de(!ze)}else y=null,de(!1),oe(pe instanceof Error&&pe.name==="TimeoutError"?new te("computer.err.frameTimeout"):pe instanceof Error?pe:new te("computer.err.screenUnavailable"))}finally{n=!1,i=Date.now()}};Y();const fe=setInterval(Y,1e3);return()=>{I.abort(),clearInterval(fe)}},[$,K,F,M,bt,Je,P,ke,V]),a.useEffect(()=>{if($!=="computer"||m!=="vm"||!re||bt||!Je)return;const n=new AbortController;let i=!1,x=-1/0,y=null,I=!0;const Y=async()=>{if(!(i||n.signal.aborted)&&!(Date.now()-x<(y??(s.busy?3e3:3e4)))){i=!0,y=null;try{const{image:J}=await W(F("local-computer/screenshot"),{method:"POST",signal:n.signal});!n.signal.aborted&&typeof J=="string"&&(me(J),oe(null))}catch(J){n.signal.aborted||(y=5e3,I?L(J instanceof Error?J.message:String(J)):oe(J instanceof Error?J:new te("computer.err.screenUnavailable")))}finally{i=!1,I=!1,x=Date.now()}}};Y();const fe=window.setInterval(()=>{Y()},s.busy?3e3:3e4);return()=>{n.abort(),window.clearInterval(fe)}},[$,m,re,F,bt,Je,s.busy,L,oe,me]);const[pn,Lt]=a.useState(0);a.useEffect(()=>{if($!=="computer"||m!=="local"||!re||!window.ogb||se||!Je)return;let n=!0;Lt(0);const i=async()=>{try{const y=await window.ogb.screenFrame();n&&y?rn(y):n&&Lt(I=>I+1)}catch{n&&Lt(y=>y+1)}};i();const x=setInterval(i,s.busy?3e3:3e4);return()=>{n=!1,clearInterval(x)}},[$,m,re,se,Je,s.busy,s.id,s.threadId]);const Qe=re?m==="vm"?ge:m==="local"&&!se?Kn:K||s.computer==="cloud"&&m==="starting"?X&&`data:${X.mime};base64,${X.png}`:null:null,qn=!!(Qe&&(m==="vm"&&ve||K)),xe=h.computerControl[s.id]??{held:!1,helpReason:null};a.useEffect(()=>{let n=!0;return W(`/api/bots/${s.id}/computer/control`).then(i=>{if(!n)return;const x=Mn.parse(i);R({type:"computerControl",botId:s.id,held:x.held===!0,helpReason:x.helpReason})}).catch(()=>{}),()=>{n=!1}},[s.id]);const mn=a.useCallback(async n=>{const i=Mn.parse(await W(`/api/bots/${s.id}/computer/control`,{method:"POST",body:JSON.stringify({action:n})}));return R({type:"computerControl",botId:s.id,held:i.held===!0,helpReason:i.helpReason}),i},[s.id,R]),xn=a.useCallback(async()=>!0,[]),yt=a.useCallback(async n=>ss({action:n,syncNativeBrowser:$!=="browser",requestControl:mn,setNativeBrowserControl:xn}),[$,mn,xn]),Vt=a.useCallback(async n=>{ft(!0),L(null);try{return await yt(n),!0}catch(i){return L(i instanceof Error?i.message:String(i)),!1}finally{ft(!1)}},[yt]),Pe=async()=>{const n=new AbortController;Q.current=n;const i=()=>!n.signal.aborted&&je.current===le;we("join"),ft(!0),L(null);let x=!1,y=null;!window.ogb?.desktopViewer&&!window.ogb?.openExternal&&(y=window.open("","_blank"),y&&(y.opener=null));try{if(xe.held||(await yt("take"),x=!0),!i())throw new DOMException("The selected conversation changed","AbortError");let I=ve;if(K){const Y=await W(F("computer/join"),{method:"POST",signal:n.signal});I=Y.joinUrl?.constructor===String?String(Y.joinUrl):null}if(!i())throw new DOMException("The selected conversation changed","AbortError");if(!I)throw new te("computer.err.noDesktopLink");if(window.ogb?.desktopViewer){if(!await window.ogb.desktopViewer.open(I,r("computer.viewerTitle",{name:s.name}),s.id))throw new te("computer.err.openDesktop")}else if(y)y.location.replace(I);else if(window.ogb?.openExternal){if(!await window.ogb.openExternal(I))throw new te("computer.err.openDesktopLink")}else if(!window.open(I,"_blank","noopener"))throw new te("computer.err.popupBlocked")}catch(I){y?.close(),x&&await yt("release").catch(()=>{}),K&&M==="vps"&&await W(F("computer/viewer-close"),{method:"POST",body:"{}"}).catch(()=>{}),i()&&L(I instanceof Error?I:String(I))}finally{Q.current===n&&(Q.current=null,we(null),ft(!1))}},Ft=n=>{we(n),L(null),W(`/api/bots/${s.id}/computer/${n}`,{method:"POST"}).then(i=>{n==="provision"&&(g(i.container??null),i.ready?(s.computer==="cloud"&&ae({botId:s.id,threadId:s.threadId,computer:s.computer,cloudBackend:M}),k("ready")):(L(i.problem??new te("computer.err.vpsNotReady")),k("error"))),n==="sleep"&&(ae(null),g(M==="vps"?"stopped":"archived"),k(M==="vps"?"vps-stopped":H?"cloud-asleep":"show-sleeping-boat"))}).catch(i=>{L(i.message)}).finally(()=>we(null))},Wn=()=>{we("provision"),L(null),k("starting"),W(`/api/bots/${s.id}/computer/provision`,{method:"POST"}).then(n=>{g(n.state??null),ae({botId:s.id,threadId:s.threadId,computer:s.computer,cloudBackend:M}),k("ready")}).catch(n=>{if(Gr(n)){k("busy-boat");return}L(n.message),k("error")}).finally(()=>we(null))},_t=async n=>{if((n==="vm-recreate"||n==="vm-delete")&&!window.confirm(n==="vm-delete"?r("computer.confirm.deleteVm",{name:s.name}):r("computer.confirm.replaceVm",{name:s.name}))||Ke.current)return;const i=new AbortController;Ke.current=i,we(n),L(null),at.current=0;try{if((n==="vm-recreate"||n==="vm-delete")&&await W(`/api/bots/${s.id}/local-computer/remove`,{method:"POST",body:"{}",signal:i.signal}),n!=="vm-delete"){const x=n==="vm-start"&&ye?.mode!=="per-bot"?"/api/local-computer/start":`/api/bots/${s.id}/local-computer/${n==="vm-start"?"start":"run"}`,y=await W(x,{method:"POST",body:"{}",signal:i.signal}),I=await ts(y,()=>W(F("local-computer"),{signal:i.signal}),i.signal);if(!I.ready)throw new Error(I.problem??r("computer.err.vmNotReady"));xt(I),k("vm")}else xt(x=>x&&{...x,container:"missing",ready:!1}),k("vm-unavailable")}catch(x){if(i.signal.aborted)return;L(x instanceof Error?x.message:String(x)),k("vm-unavailable")}finally{Ke.current===i&&!i.signal.aborted&&(Ke.current=null,we(null),Ye(x=>x+1))}},Hn=async()=>{if(window.confirm(r("computer.confirm.replaceVps",{name:s.name}))){we("vps-replace"),L(null);try{await W(`/api/bots/${s.id}/computer/remove`,{method:"POST",body:"{}"});const n=await W(`/api/bots/${s.id}/computer/provision`,{method:"POST",body:"{}"});zt(n),g(n.container??null),n.ready&&s.computer==="cloud"&&ae({botId:s.id,threadId:s.threadId,computer:s.computer,cloudBackend:M}),k(n.ready?"ready":"error"),n.ready||L(n.problem??new te("computer.err.vpsReplaceNotReady"))}catch(n){L(n instanceof Error?n.message:String(n)),k("error")}finally{we(null),Ye(n=>n+1)}}},fn=()=>{window.sessionStorage.setItem("openmausbot.settings.section","computer"),R({type:"toggleAppSettings",open:!0})},bn=()=>{R({type:"toggleAppSettings",open:!0,section:"connections"})},$t=on||h.config?.browserEngine?.installable===!0,[hn,gn]=a.useState(!1),vn=async()=>{if(!hn){gn(!0),L(null);try{if(!Sn(h.config)){const n=await W("/api/config",{method:"PATCH",body:JSON.stringify({features:{browser:!0}})});R({type:"configStatus",config:n})}t.browser===!1&&R({type:"updateBot",botId:t.id,patch:{browser:!0}})}catch(n){L(n instanceof Error?n.message:r("settings.experimental.error"))}finally{gn(!1)}}},Xn=()=>{L(null),R({type:"updateBot",botId:t.id,patch:{browser:!1}})},yn=e.jsxs("div",{"data-testid":"browser-switch-row",className:"mb-3 flex items-center gap-3 rounded-xl bg-card px-3 py-2.5",children:[e.jsx(We,{size:15,className:"shrink-0 text-ink-secondary","aria-hidden":"true"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-[13px] font-medium text-ink",children:r("computer.browserSwitch.title",{name:s.name})}),!$t&&e.jsx("div",{className:"text-[11.5px] text-ink-secondary",children:Qt(h.config)})]}),e.jsx(kr,{checked:Le,disabled:hn||!Le&&!$t,"aria-label":r("computer.browserSwitch.title",{name:s.name}),onClick:()=>Le?Xn():void vn()})]}),Bt=h.config?.managedPolicy,Kt=jr(Te,t.busy===!0),Yn=!re||o!=="cloud"||M!=="box"?void 0:m==="starting"?"starting":m==="busy-boat"?Kt.spinner?"starting":Kt.line==="computer.cloud.asleep"?"asleep":"none":m==="ready"?"on":Te==="archived"||Te==="stopped"?"asleep":void 0,it=(n,i)=>Br({...Kr({bot:s,place:n,seat:mt,config:h.config,instances:h.instances,local:{ready:Ce,reason:De??r("computer.unavailableLocal")},...n==="cloud"?{computer:Yn}:{},...n==="auto"&&he?{teamComputer:he.name}:{}}),...i?{refusal:i}:{}}),Ut=s.computer==="cloud"&&M==="box"&&m==="error"&&ht&&!(ht instanceof te)?Nr({message:Be??"",status:Number(ht.status??0)||void 0},h.config?.box?.included===!0):void 0,be=it("cloud",Ut),qe=it("auto"),lt=[[null,"vm.dest.auto","computer.dest.autoDesc",Sr],["cloud","place.cloud","computer.dest.cloudDesc",Cr],["vm","vm.dest.vm","computer.dest.vmDesc",Er],["local","vm.dest.local","computer.dest.localDesc",Fe],["browser","vm.dest.browser","computer.dest.browserDesc",We],["off","vm.dest.off","computer.dest.offDesc",pt]].filter(([n])=>n===null||n==="off"||jn(n,h.config)).map(([n,i,x,y])=>{const I=n===null?!t.computer:t.computer===n,Y=n==="local"?"thisComputer":n==="vm"?"localVm":n==="cloud"?t.cloudBackend==="vps"?"vps":"box":null,fe=Bt&&Y&&!Bt.computers[Y]?r("policy.managedBy",{organization:Bt.organizationName}):void 0,J=n===null?qe:n==="cloud"?be:it(n),pe=!!fe||En(J),ze=!fe&&Rr(J),Zn=fe??(ze?J.line:n==="browser"?r("computer.browserOnlyTitle"):void 0);return{mode:n,labelKey:i,descriptionKey:x,Icon:y,simpleLabel:Ir(n??void 0,Se.host.platform),selected:I,managedBy:fe,disabled:pe,unavailableTitle:Zn,view:J,issue:ze}}),wt=lt.find(({selected:n})=>n)?.view??qe,Jn=n=>{if(n==="start"||n==="wake")return Wn();if(n==="try-again")return Ye(i=>i+1);if(n==="turn-on-browser")return void vn();if(n==="open-vm-settings")return fn();qr(n,{botId:t.id,threadId:t.threadId},R)},Gn=n=>!!n&&n!=="watch"&&n!=="open-computer-panel"&&(n!=="start"&&n!=="wake"||H&&!t.busy),ct=(n,i="mt-1 rounded-lg bg-control px-3 py-1.5 text-[12px] text-ink hover:bg-raised-hover")=>n.action&&Gn(n.action.id)?e.jsx("button",{type:"button","data-testid":"place-action",onClick:()=>Jn(n.action.id),className:i,children:n.action.label}):null,wn=n=>{n===null&&t.computer===void 0||n===t.computer||(n==="local"&&Ur(t)==="auto"?Ee(s.id):Ie(n==="browser"?{computer:n,browser:!0}:{computer:n}))},qt=D?.surface&&!D.surfaceAuto&&t.computer!=="off"&&D.surface!==t.computer?D.surface:void 0,ut=n=>Ve("flex items-center gap-1.5 rounded-full px-3 py-1 text-[12.5px] transition-colors",n?"bg-raised text-ink shadow-sm":"text-ink-secondary hover:text-ink"),Qn={checking:r("computer.phase.checking"),starting:M==="vps"?r("computer.phase.starting"):be.line,"busy-boat":be.line,unconfigured:be.line,"auto-unavailable":qe.line,"team-boat":qe.line,"show-ready-boat":r("computer.phase.showReadyBoat"),"show-sleeping-boat":r("computer.phase.showSleepingBoat"),"show-pending-boat":r("computer.phase.showPendingBoat"),"cloud-new":be.line,"cloud-asleep":be.line,"vps-unconfigured":r("computer.phase.vpsUnconfigured"),"vps-incompatible":r("computer.phase.vpsIncompatible"),"vps-stopped":r("computer.phase.vpsStopped"),"local-unavailable":De??r("computer.phase.localUnavailable"),"vm-unavailable":r("computer.phase.vmUnavailable"),browser:it("browser").line,off:it("off").line,error:s.computer==="cloud"&&(Ut||En(be))?be.line:r("computer.phase.error")};return e.jsxs(e.Fragment,{children:[e.jsxs("aside",{className:Ve("animate-panel-in relative flex h-full shrink-0 flex-col border-l border-hairline/40 bg-panel","max-md:absolute max-md:inset-0 max-md:z-40 max-md:w-full!"),style:{width:d},children:[e.jsx("div",{ref:N,role:"separator","aria-orientation":"vertical","aria-label":r("computer.resizeAria"),"aria-valuemin":Et,"aria-valuemax":Rt,"aria-valuenow":j??void 0,tabIndex:0,onKeyDown:S,onPointerDown:w,onPointerMove:f,onPointerUp:C,onPointerCancel:C,className:"absolute inset-y-0 left-0 z-10 w-1.5 cursor-col-resize hover:bg-accent/40 focus-visible:bg-accent/60 max-md:hidden"}),e.jsx("div",{className:Ve("px-4 py-3",l),children:e.jsxs("div",{className:"relative flex min-h-7 items-center justify-center",children:[ee&&e.jsx("button",{onClick:()=>{R({type:"toggleComputer",open:!1}),R({type:"toggleSettings",open:!0,section:"access"})},className:"absolute left-0 top-1/2 -translate-y-1/2 rounded-md p-1 text-ink-secondary hover:bg-control hover:text-ink",title:r("computer.botSettings"),children:e.jsx(Tr,{size:18})}),e.jsxs("div",{className:"mx-9 flex min-w-0 flex-wrap justify-center gap-0.5 rounded-full bg-inset p-0.5","data-tour":"computer-tabs","data-testid":"computer-tabs","aria-label":"Bot panel view",children:[e.jsxs("button",{onClick:()=>Ue("computer"),"aria-pressed":$==="computer",className:ut($==="computer"),children:[e.jsx(Fe,{size:13})," ",r("computer.tab.computer"),q&&Pr(o)&&e.jsx("span",{className:"size-1.5 animate-pulse rounded-full bg-success",role:"img","aria-label":r("place.live"),"data-testid":"computer-tab-live"})]}),ee&&e.jsxs("button",{type:"button",onClick:()=>Ue("routines"),"aria-pressed":$==="routines",className:ut($==="routines"),children:[e.jsx(Rn,{size:13}),r("computer.tab.routines")]}),ee&>&&e.jsxs("button",{onClick:()=>Ue("android"),"aria-pressed":$==="android",className:ut($==="android"),children:[e.jsx(Vn,{size:13})," ",r("computer.tab.android")]}),e.jsxs("button",{"data-tour":"computer-browser",onClick:()=>{L(null),Ue("browser")},"aria-pressed":$==="browser",className:ut($==="browser"),children:[e.jsx(We,{size:13})," ",r("computer.tab.browser"),q&&o==="browser"&&e.jsx("span",{className:"size-1.5 animate-pulse rounded-full bg-success",role:"img","aria-label":r("place.live"),"data-testid":"browser-tab-live"})]}),!ee&&e.jsxs("button",{type:"button",onClick:()=>Ue("files"),"aria-pressed":$==="files",className:ut($==="files"),children:[e.jsx(Ln,{size:13})," ",r("computer.tab.files")]})]}),e.jsx("button",{onClick:()=>R({type:"toggleComputer",open:!1}),className:"absolute right-0 top-1/2 -translate-y-1/2 rounded-md p-1 text-ink-secondary hover:bg-control hover:text-ink","aria-label":r("computer.close"),title:r("computer.close"),children:e.jsx(St,{size:18})})]})}),$==="routines"?e.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-4 pb-4",children:e.jsx(rs,{bot:s,routines:dn,runs:h.routineRuns,defaultRunOn:Un?"cloud":"maus"},s.id)}):$==="browser"&&Le?e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col px-4 pb-4",children:[yn,e.jsx(_s,{bot:s}),Be&&e.jsx("div",{role:"alert",className:"mt-2 rounded-lg border border-danger/30 bg-danger/10 px-3 py-2 text-[12px] text-danger",children:Be})]}):$==="browser"?e.jsxs("div",{className:"flex-1 overflow-y-auto px-5 pb-5","data-testid":"browser-off",children:[yn,e.jsxs("div",{className:"mt-2 flex flex-col items-center gap-3 rounded-xl bg-card px-6 py-8 text-center",children:[e.jsx(We,{size:22,className:"text-ink-secondary","aria-hidden":"true"}),e.jsx("div",{className:"text-[14px] font-medium text-ink",children:r("computer.browserOff.title")}),e.jsx("p",{className:"text-[12px] leading-5 text-ink-secondary",children:$t?r("computer.browserOff.body",{name:s.name}):Qt(h.config)}),Be&&e.jsx("div",{role:"alert",className:"w-full rounded-lg border border-danger/30 bg-danger/10 px-3 py-2 text-[12px] text-danger",children:Be})]})]}):$==="files"?e.jsx(ys,{bot:s}):$==="android"&>?e.jsx("div",{className:"flex-1 overflow-y-auto px-4 pt-2",children:e.jsx(Ns,{status:an})}):e.jsxs("div",{className:"flex-1 overflow-y-auto px-5 pb-5",children:[e.jsxs("div",{className:"mb-1.5 mt-2 flex items-center justify-between text-[13px] text-ink-secondary",children:[e.jsx("span",{children:r("computer.screenOf",{name:s.name})}),he&&e.jsx("span",{className:"text-[11px]",children:qe.short}),m==="local"&&e.jsx("span",{className:"text-[11px]",children:r("computer.badge.local")}),m==="vm"&&e.jsx("span",{className:"text-[11px]",children:r("vm.dest.vm")}),(m==="show-ready-boat"||m==="show-sleeping-boat"||m==="show-pending-boat")&&e.jsx("span",{className:"text-[11px]",children:r("computer.badge.autoBoat")}),re&&s.computer==="cloud"&&M==="vps"&&(m==="ready"||m==="starting")&&e.jsx("span",{className:"text-[11px]",children:r("computer.badge.vps")})]}),e.jsx("div",{className:"relative flex aspect-[16/10] w-full items-center justify-center overflow-hidden rounded-xl bg-card",children:K||s.computer==="cloud"&&m==="starting"?e.jsx(ws,{src:Qe,name:s.name,error:Dn(Oe),refreshing:Xe,retry:V,starting:m==="starting",opening:P==="join",disabled:ke,onOpen:()=>{Pe()},onRetry:n=>{Ge.current=0,n&&ue(null),oe(null),de(!0),Z(i=>i+1)}},`${s.id}:${s.threadId}:${s.computer}:${M}`):Qe&&qn?e.jsxs("button",{type:"button",onClick:()=>{Pe()},disabled:ke||P==="join",className:"group relative flex h-full w-full cursor-pointer items-center justify-center focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:cursor-wait","aria-label":r("computer.openLiveDesktopAria",{name:s.name}),title:r("computer.openLiveDesktop"),children:[e.jsx("img",{src:Qe,alt:r("computer.screenOf",{name:s.name}),className:"h-full w-full object-contain transition group-hover:brightness-75 group-focus-visible:brightness-75"}),e.jsxs("span",{className:"pointer-events-none absolute right-2 top-2 flex items-center gap-1 rounded-md bg-black/70 px-2 py-1 text-[11px] font-medium text-white opacity-80 shadow-sm transition group-hover:opacity-100 group-focus-visible:opacity-100",children:[P==="join"?e.jsx(U,{size:12,className:"animate-spin"}):e.jsx(It,{size:12}),r("computer.open")]})]}):Qe?e.jsx("img",{src:Qe,alt:r("computer.screenOf",{name:s.name}),className:"h-full w-full object-contain",title:m==="vm"?r("computer.watchOnly"):void 0}):e.jsxs("div",{className:"flex flex-col items-center gap-2 px-6 text-center text-ink-secondary",children:[m==="checking"||m==="starting"||m==="busy-boat"&&Kt.spinner||m==="vm"||m==="local"&&!se?e.jsx(U,{size:18,className:"animate-spin"}):m==="off"?e.jsx(pt,{size:22}):e.jsx(Fe,{size:22}),e.jsx("span",{className:"text-[12px]",children:he?qe.line:K?r("computer.waitingFrame"):m==="ready"?r("computer.autoChooseCloudOpen"):m==="vm"?r("computer.capturingVm"):m==="local"?se?r("computer.linuxReady"):pn>=3?r("computer.needsScreenPerm"):r("computer.capturingLocal"):Dt?r(P==="vm-start"?"vm.setup.starting":"computer.phase.vmStopped"):Qn[m]}),he&&ct(qe),s.computer==="cloud"&&(m==="unconfigured"||m==="error")&&be.action?.id!=="add-boat-key"&&ct(be),m==="local"&&!se&&pn>=3&&e.jsx("button",{onClick:()=>window.ogb?.permOpenSettings?.("screen"),className:"mt-1 rounded-lg bg-control px-3 py-1.5 text-[12px] text-ink hover:bg-raised-hover",children:r("computer.openSettings")}),m==="browser"&&Le&&e.jsx("button",{onClick:()=>Ue("browser"),className:"mt-1 rounded-lg bg-control px-3 py-1.5 text-[12px] text-ink hover:bg-raised-hover",children:r("computer.openBrowserTab")}),(m==="show-ready-boat"||m==="show-sleeping-boat"||m==="show-pending-boat")&&e.jsx("button",{type:"button",onClick:()=>Ie({computer:"cloud"}),className:"mt-1 rounded-lg bg-control px-3 py-1.5 text-[12px] text-ink hover:bg-raised-hover",children:m==="show-sleeping-boat"?r("computer.chooseCloudWake"):m==="show-ready-boat"?r("computer.chooseCloudOpen"):r("computer.chooseCloudManage")}),P===null&&(m==="cloud-new"||m==="cloud-asleep")&&ct(be),Dt&&P!=="vm-start"&&e.jsx("p",{className:"text-[12px]",children:r(ye?.stop_reason==="idle"?"vm.stopped.idle":"vm.stopped.detail")}),m==="vm-unavailable"&&(ce&&Dt&&ye.mode!=="pool"?e.jsxs("button",{onClick:()=>{_t("vm-start")},disabled:P!==null,"aria-busy":P==="vm-start",className:"mt-1 flex items-center gap-1.5 rounded-lg bg-accent px-3 py-1.5 text-[12px] font-medium text-white hover:brightness-110 disabled:opacity-50",children:[P==="vm-start"&&e.jsx(U,{size:13,className:"animate-spin"}),r(P==="vm-start"?"vm.setup.starting":"vm.setup.start")]}):ce&&ye?.mode==="per-bot"&&ye.image&&ye.create_supported?e.jsxs("button",{onClick:()=>{_t(ye.container==="missing"?"vm-create":"vm-recreate")},disabled:P!==null,className:"mt-1 rounded-lg bg-accent px-3 py-1.5 text-[12px] font-medium text-white hover:brightness-110 disabled:opacity-50",children:[(P==="vm-create"||P==="vm-recreate")&&e.jsx(U,{size:13,className:"mr-1.5 inline animate-spin"}),ye.container==="missing"?r("computer.createVm",{name:s.name}):r("computer.replaceVm",{name:s.name})]}):e.jsx("button",{onClick:fn,className:"mt-1 rounded-lg bg-control px-3 py-1.5 text-[12px] text-ink hover:bg-raised-hover",children:r("computer.openVmSetup")})),!ee&&re&&(m==="vps-unconfigured"||m==="vps-stopped"||m==="vps-incompatible")&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-[12px]",children:r("computer.simple.needsSetup",{name:s.name})}),e.jsx("button",{type:"button",onClick:()=>zr(!0),className:"mt-1 rounded-lg bg-control px-3 py-1.5 text-[12px] text-ink hover:bg-raised-hover",children:r("computer.simple.showAdvanced")})]}),ee&&re&&(m==="vps-unconfigured"||m==="vps-stopped")&&e.jsx("button",{onClick:bn,className:"mt-1 rounded-lg bg-control px-3 py-1.5 text-[12px] text-ink hover:bg-raised-hover",children:r("computer.openVpsSettings")}),ee&&re&&(m==="vps-stopped"||m==="vps-unconfigured"&&nn?.configured)&&H&&e.jsxs("button",{onClick:()=>Ft("provision"),disabled:P==="provision",className:"mt-1 rounded-lg bg-control px-3 py-1.5 text-[12px] text-ink hover:bg-raised-hover disabled:opacity-50",children:[P==="provision"&&e.jsx(U,{size:13,className:"mr-1.5 inline animate-spin"}),m==="vps-stopped"?r("computer.startVps"):r("computer.prepareVps")]}),ee&&re&&m==="vps-incompatible"&&nn?.managed&&H&&e.jsxs("button",{onClick:()=>{Hn()},disabled:P==="vps-replace",className:"mt-1 rounded-lg bg-accent px-3 py-1.5 text-[12px] font-medium text-white hover:brightness-110 disabled:opacity-50",children:[P==="vps-replace"&&e.jsx(U,{size:13,className:"mr-1.5 inline animate-spin"}),r("computer.replaceVps")]})]})}),Be&&!Ut&&e.jsx("div",{className:"mt-2 rounded-lg border border-danger/30 bg-danger/10 px-3 py-2 text-[12px] text-danger",children:Be}),m==="unconfigured"&&be.action?.id==="add-boat-key"&&e.jsx("div",{className:"mt-3 rounded-xl bg-card p-4",children:e.jsx(Zr,{section:"box",onSaved:n=>n&&Ye(i=>i+1)})}),ee&&m==="vps-unconfigured"&&e.jsxs("div",{className:"mt-3 rounded-xl bg-card p-4",children:[e.jsx("div",{className:"mb-3 text-[13px] text-ink-secondary",children:r("computer.vpsAliasHint")}),e.jsx("button",{onClick:bn,className:"rounded-lg bg-control px-3 py-2 text-[13px] text-ink hover:bg-raised-hover",children:r("computer.openVpsSettings")})]}),ee&&m==="vm"&&ye?.mode==="per-bot"&&window.ogb?.desktopWorkspace&&c&&e.jsxs("button",{type:"button",onClick:()=>c(s.id),disabled:P!==null,className:"mt-3 flex w-full items-center justify-center gap-2 rounded-lg border border-accent/30 bg-accent/10 py-2 text-[13px] font-medium text-ink hover:bg-accent/15 disabled:opacity-50",title:r("computer.twoDesktopsTitle"),children:[e.jsx(os,{size:14}),r("computer.twoDesktops")]}),(K||m==="vm"||he)&&xe.helpReason&&!xe.held&&e.jsxs("div",{className:"mt-3 rounded-xl border border-warning/25 bg-warning/10 p-4",children:[e.jsxs("div",{className:"text-[13px] leading-relaxed text-warning",children:[e.jsx("b",{children:s.name})," ",r("computer.askedHands")," ",xe.helpReason]}),e.jsxs("div",{className:"mt-2 flex gap-2",children:[e.jsxs("button",{onClick:()=>m==="vm"||K?void Pe():Vt("take"),disabled:ke||P==="join",className:"flex flex-1 items-center justify-center gap-2 rounded-lg bg-accent py-2 text-[13px] font-medium text-white hover:brightness-110 disabled:opacity-50",children:[P==="join"?e.jsx(U,{size:14,className:"animate-spin"}):e.jsx(_e,{size:14}),r("computer.takeControl")]}),e.jsx("button",{onClick:()=>Vt("dismiss-help"),disabled:ke,className:"rounded-lg bg-control px-3 py-2 text-[13px] text-ink hover:bg-raised-hover disabled:opacity-50",children:r("computer.dismiss")})]})]}),(K||m==="vm"||he)&&xe.held&&e.jsxs("div",{className:"mt-3 rounded-xl border border-accent/25 bg-accent/10 p-4",children:[e.jsxs("div",{className:"text-[13px] leading-relaxed text-ink",children:[r("computer.youHaveWheel"),K&&` ${r(ee?"computer.useOpenDesktop":"computer.simple.useFullScreen")}`,m==="vm"&&` ${r(ee?"computer.useOpenDesktopVm":"computer.simple.useFullScreenVm")}`]}),e.jsxs("button",{onClick:()=>{Vt("release"),window.ogb?.desktopViewer?.close(s.id)},disabled:ke,className:"mt-2 flex w-full items-center justify-center gap-2 rounded-lg bg-accent py-2 text-[13px] font-medium text-white hover:brightness-110 disabled:opacity-50",children:[e.jsx(_e,{size:14}),r("computer.handBack")]})]}),ee&&m==="vm"&&ve&&xe.held&&e.jsxs("button",{onClick:()=>{Pe()},disabled:P==="join",className:"mt-3 flex w-full items-center justify-center gap-2 rounded-lg bg-control py-2 text-[13px] text-ink hover:bg-raised-hover disabled:opacity-50",title:r("computer.openVmDesktopTitle"),children:[P==="join"?e.jsx(U,{size:14,className:"animate-spin"}):e.jsx(Fe,{size:14}),r("computer.openLiveDesktop")]}),ee&&m==="vm"&&!xe.held&&!xe.helpReason&&e.jsxs("button",{onClick:()=>{Pe()},disabled:ke||P==="join"||!ve,className:"mt-3 flex w-full items-center justify-center gap-2 rounded-lg bg-control py-2 text-[13px] text-ink hover:bg-raised-hover disabled:opacity-50",title:r("computer.takeControlVmTitle"),children:[P==="join"?e.jsx(U,{size:14,className:"animate-spin"}):e.jsx(_e,{size:14}),r("computer.takeControl")]}),ee&&ce&&m==="vm"&&ye?.mode==="per-bot"&&e.jsxs("button",{onClick:()=>{_t("vm-delete")},disabled:P!==null||t.busy,className:"mt-2 flex w-full items-center justify-center gap-2 rounded-lg border border-danger/30 py-2 text-[13px] text-danger hover:bg-danger/10 disabled:opacity-50",title:t.busy?r("computer.deleteVmBlocked"):r("computer.deleteVmTitle",{name:s.name}),children:[P==="vm-delete"?e.jsx(U,{size:14,className:"animate-spin"}):e.jsx(pt,{size:14}),r("computer.deleteVm")]}),!ee&&(K||m==="vm")&&e.jsxs("div",{className:"mt-3 flex gap-2","data-testid":"computer-actions",children:[!xe.held&&!xe.helpReason&&e.jsxs("button",{type:"button",onClick:()=>{Pe()},disabled:ke||P==="join"||m==="vm"&&!ve,className:"flex flex-1 items-center justify-center gap-2 rounded-lg bg-accent py-2 text-[13px] font-medium text-accent-ink hover:brightness-110 disabled:opacity-50",title:m==="vm"?r("computer.takeControlVmTitle"):r("computer.takeControlTitle"),children:[P==="join"?e.jsx(U,{size:14,className:"animate-spin"}):e.jsx(_e,{size:14}),r("computer.takeControl")]}),e.jsxs("button",{type:"button",onClick:()=>{Pe()},disabled:P==="join"||!xe.held&&ke||m==="vm"&&!ve,className:"flex flex-1 items-center justify-center gap-2 rounded-lg bg-control py-2 text-[13px] text-ink hover:bg-raised-hover disabled:opacity-50",title:r("computer.openLiveDesktop"),children:[e.jsx(It,{size:14}),r("computer.fullScreen")]}),K&&H&&(M==="vps"||Te!=="archived")&&e.jsxs("button",{type:"button",onClick:()=>Ft("sleep"),disabled:P==="sleep"||t.busy,className:"flex flex-1 items-center justify-center gap-2 rounded-lg bg-control px-3 py-2 text-[13px] text-ink hover:bg-raised-hover disabled:opacity-50",title:r("computer.sleepTitle"),children:[P==="sleep"?e.jsx(U,{size:14,className:"animate-spin"}):e.jsx(In,{size:14}),r("vm.cloud.sleep")]})]}),ee&&K&&e.jsxs("div",{className:"mt-3 flex gap-2",children:[!xe.held&&!xe.helpReason&&e.jsxs("button",{onClick:()=>{Pe()},disabled:ke||P==="join",className:"flex flex-1 items-center justify-center gap-2 rounded-lg bg-control py-2 text-[13px] text-ink hover:bg-raised-hover disabled:opacity-50",title:r("computer.takeControlTitle"),children:[P==="join"?e.jsx(U,{size:14,className:"animate-spin"}):e.jsx(_e,{size:14}),r("computer.takeControl")]}),xe.held&&e.jsxs("button",{onClick:()=>{Pe()},disabled:P==="join",className:"flex flex-1 items-center justify-center gap-2 rounded-lg bg-control py-2 text-[13px] text-ink hover:bg-raised-hover disabled:opacity-50",children:[P==="join"?e.jsx(U,{size:14,className:"animate-spin"}):e.jsx(Fe,{size:14}),r("computer.openLiveDesktop")]}),H&&(M==="vps"||Te!=="archived")&&e.jsxs("button",{onClick:()=>Ft("sleep"),disabled:P==="sleep"||t.busy,className:"flex flex-1 items-center justify-center gap-2 rounded-lg bg-control px-3 py-2 text-[13px] text-ink hover:bg-raised-hover disabled:opacity-50",title:r("computer.sleepTitle"),children:[P==="sleep"?e.jsx(U,{size:14,className:"animate-spin"}):e.jsx(In,{size:14}),r("vm.cloud.sleep")]})]}),m!=="team-boat"&&(s.computer!==void 0||re)&&e.jsxs(e.Fragment,{children:[e.jsx(Ks,{}),e.jsx(qs,{}),e.jsx(es,{})]}),ee?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mt-4 rounded-xl bg-card p-4",children:[e.jsx("div",{className:"text-[15px] font-medium text-ink",children:r("computer.worksOn")}),e.jsx("p",{className:"mt-1 text-[12px] leading-5 text-ink-secondary",children:r(h.config?.cloudHome?"computer.worksOnHintCloudHome":"computer.worksOnHint")}),e.jsx("div",{role:"group","aria-label":r("computer.destinationAria"),className:"mt-3 grid auto-rows-fr grid-cols-2 gap-2",children:lt.map(({mode:n,labelKey:i,descriptionKey:x,Icon:y,selected:I,managedBy:Y,disabled:fe,unavailableTitle:J,issue:pe,view:ze})=>e.jsxs("button",{disabled:fe,title:J,onClick:()=>wn(n),type:"button","aria-pressed":I,className:Ve("min-w-0 rounded-lg border px-2.5 py-3 text-left transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-card",I?"border-accent/60 bg-accent/10 text-ink":"border-hairline/50 bg-panel/30 text-ink-secondary",fe?"cursor-not-allowed":"hover:border-accent/40 hover:bg-control/60"),children:[e.jsxs("span",{className:"flex items-center gap-2 text-[12px] font-medium leading-4",children:[I?e.jsx(Ar,{size:14,className:"shrink-0 text-accent"}):e.jsx(y,{size:14,className:"shrink-0 text-ink-secondary"}),e.jsx("span",{children:r(i)})]}),e.jsx("span",{className:"mt-1.5 block text-[11px] leading-4 text-ink-secondary",children:Y??(pe?ze.short:r(x))})]},n??"auto"))}),D?.surface&&e.jsx("p",{className:"mt-2 text-[11.5px] leading-5 text-ink-secondary","data-testid":"place-pinned-note",children:r("place.pinnedNote",{place:r(Ht(D.surface))})}),e.jsxs("div",{className:"mt-3 border-t border-hairline/40 pt-3 text-[11.5px] leading-5 text-ink-secondary","aria-live":"polite","data-testid":"place-line",children:[wt.line,ct(wt,"mt-1 block font-medium text-accent hover:underline")]}),t.computer==="cloud"&&e.jsx(ns,{compact:!0,value:M,onChange:n=>Ie({cloudBackend:n})})]}),e.jsxs("button",{type:"button",onClick:()=>Ue("routines"),className:"mt-4 flex w-full items-start gap-3 rounded-xl bg-card p-4 text-left hover:bg-raised",children:[e.jsx(Rn,{size:17,className:"mt-0.5 shrink-0 text-accent"}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsxs("span",{className:"block text-[14px] font-medium text-ink",children:[r("computer.tab.routines")," ",e.jsx("span",{className:"ml-1 text-[11px] text-ink-secondary",children:dn.length})]}),e.jsx("span",{className:Ve("mt-1 block truncate text-[11.5px]",ot?Mr(ot):"text-ink-secondary"),children:ot?`${ot.routineName} · ${Dr(ot)}`:r("computer.routines.openTitle")})]}),e.jsx("span",{className:"text-ink-secondary","aria-hidden":"true",children:"→"})]})]}):e.jsxs("div",{className:"mt-4 rounded-xl bg-card p-4","data-testid":"where-works",children:[e.jsx("div",{className:"text-[15px] font-medium text-ink",children:r("computer.simple.whereWorks",{name:s.name})}),e.jsx("div",{role:"group","aria-label":r("computer.destinationAria"),className:"mt-3 grid grid-cols-3 gap-2",children:lt.map(({mode:n,Icon:i,selected:x,disabled:y,unavailableTitle:I,simpleLabel:Y,issue:fe,view:J})=>e.jsxs("button",{type:"button",disabled:y,title:I,"aria-pressed":x,onClick:()=>wn(n),className:Ve("flex min-w-0 flex-col items-center gap-1.5 rounded-lg border px-1.5 py-2.5 text-center transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-card",x?"border-accent/60 bg-accent/10 text-ink":"border-hairline/50 bg-panel/30 text-ink-secondary",y?"cursor-not-allowed opacity-50":"hover:border-accent/40 hover:bg-control/60"),children:[e.jsx(i,{size:16,className:Ve("shrink-0",x?"text-accent":"text-ink-secondary"),"aria-hidden":"true"}),e.jsx("span",{className:"w-full truncate text-[12px] font-medium leading-4",children:Y}),fe&&e.jsx("span",{className:"w-full truncate text-[10.5px] leading-3 text-ink-secondary",children:J.short})]},n??"auto"))}),e.jsxs("div",{className:"mt-3 text-[11.5px] leading-5 text-ink-secondary","data-testid":"place-line",children:[wt.line,ct(wt,"mt-1 block font-medium text-accent hover:underline")]}),qt&&e.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[e.jsx("p",{className:"min-w-0 flex-1 text-[11.5px] leading-5 text-ink-secondary","data-testid":"place-pinned-note",children:r("place.pinnedNoteSimple",{place:lt.find(({mode:n})=>n===qt)?.simpleLabel??r(Ht(qt))})}),e.jsx("button",{type:"button",disabled:!!s.busy,title:s.busy?r("place.busy"):void 0,onClick:()=>R({type:"updateTask",botId:t.id,threadId:t.threadId,patch:{surface:null}}),className:"shrink-0 rounded-md px-2 py-0.5 text-[11.5px] font-medium leading-5 text-accent-text transition-colors hover:bg-control focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:cursor-not-allowed disabled:opacity-45 disabled:hover:bg-transparent","data-testid":"place-unpin",children:r("place.unpinSimple",{place:lt.find(({selected:n})=>n)?.simpleLabel??r(Ht(t.computer??"auto"))})})]})]})]})]}),e.jsx(Or,{open:Ae!==null,onCancel:()=>Ee(null),onConfirm:()=>{const n=Ae;Ee(null),n&&(n===s.id&&(ae(null),k("checking")),R({type:"updateBot",botId:n,patch:{computer:"local",acknowledgeLocalAuto:!0}}))}})]})}export{na as ComputerPanel};
|