local-operator-ui 0.48.4 → 0.48.5

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.
Files changed (83) hide show
  1. package/out/main/index.js +62 -7
  2. package/out/renderer/assets/{_basePickBy-DlMOauKA.js → _basePickBy-TWuKvVpC.js} +1 -1
  3. package/out/renderer/assets/{_baseUniq-Dq2J0Rqa.js → _baseUniq-Bhe44p7o.js} +1 -1
  4. package/out/renderer/assets/{agent-details-page-CppqTiuO.js → agent-details-page-zCxYkFNQ.js} +1 -1
  5. package/out/renderer/assets/{agent-hub-page-By2yRXfH.js → agent-hub-page-Cu0a6aRJ.js} +1 -1
  6. package/out/renderer/assets/{agents-page-CUwiT9MP.js → agents-page-Cdvz8Ecb.js} +3 -3
  7. package/out/renderer/assets/{arc-BeF5upzH.js → arc-D5IdgXnV.js} +1 -1
  8. package/out/renderer/assets/{architectureDiagram-IEHRJDOE-B2cOHDfe.js → architectureDiagram-IEHRJDOE-BofF0Xoc.js} +1 -1
  9. package/out/renderer/assets/{avatar-cropper-BLB8m9P5.js → avatar-cropper-BV9pfbSJ.js} +1 -1
  10. package/out/renderer/assets/{blockDiagram-JOT3LUYC-CSGfMrrt.js → blockDiagram-JOT3LUYC-CXNhCa3p.js} +1 -1
  11. package/out/renderer/assets/browser-page-BXHeGHJF.js +1 -0
  12. package/out/renderer/assets/{browser-webauthn-prompt-CH2Sk3Y-.js → browser-webauthn-prompt-hBFTXi1F.js} +1 -1
  13. package/out/renderer/assets/{c4Diagram-VJAJSXHY-DUIMDZ5W.js → c4Diagram-VJAJSXHY-B3mz6Z9m.js} +1 -1
  14. package/out/renderer/assets/channel-LsNleWKO.js +1 -0
  15. package/out/renderer/assets/{chunk-4BMEZGHF-Cwvwl5jI.js → chunk-4BMEZGHF-D7rjLAgd.js} +1 -1
  16. package/out/renderer/assets/{chunk-A2AXSNBT-CY22tphO.js → chunk-A2AXSNBT-iEFmm6OB.js} +1 -1
  17. package/out/renderer/assets/{chunk-AEK57VVT-DsykAvWn.js → chunk-AEK57VVT-U4kT85HV.js} +1 -1
  18. package/out/renderer/assets/{chunk-D6G4REZN-DFaqqtJA.js → chunk-D6G4REZN-B9UuBdm5.js} +1 -1
  19. package/out/renderer/assets/{chunk-RZ5BOZE2-BJ2dZxWB.js → chunk-RZ5BOZE2-BysIzka2.js} +1 -1
  20. package/out/renderer/assets/{chunk-XZIHB7SX-bwI3_dRf.js → chunk-XZIHB7SX-XwISeGT9.js} +1 -1
  21. package/out/renderer/assets/classDiagram-GIVACNV2-lwFVEeSj.js +1 -0
  22. package/out/renderer/assets/classDiagram-v2-COTLJTTW-lwFVEeSj.js +1 -0
  23. package/out/renderer/assets/clone-BaybiQWJ.js +1 -0
  24. package/out/renderer/assets/{console-mirror-DEmWiLpt.js → console-mirror-1z96hWwG.js} +1 -1
  25. package/out/renderer/assets/{consoleCapture-DcwfprGC.js → consoleCapture-DSbKoJkH.js} +1 -1
  26. package/out/renderer/assets/{conversation-input-sync-BnhCcKxP.js → conversation-input-sync-CA-NlH9A.js} +4 -4
  27. package/out/renderer/assets/{dagre-OKDRZEBW-BwJjs7rU.js → dagre-OKDRZEBW-CVkzqUwx.js} +1 -1
  28. package/out/renderer/assets/{diagram-SSKATNLV-CRk_QUs1.js → diagram-SSKATNLV-DrMzRRC7.js} +1 -1
  29. package/out/renderer/assets/{diagram-VNBRO52H-pTLpqpTT.js → diagram-VNBRO52H-Dg9_oxJB.js} +1 -1
  30. package/out/renderer/assets/{erDiagram-Q7BY3M3F-jPapdqDm.js → erDiagram-Q7BY3M3F-Bv_01_vO.js} +1 -1
  31. package/out/renderer/assets/{flowDiagram-4HSFHLVR-Crk3w_n0.js → flowDiagram-4HSFHLVR-BEdIcLOk.js} +1 -1
  32. package/out/renderer/assets/{ganttDiagram-APWFNJXF-1D5q3U16.js → ganttDiagram-APWFNJXF-DwBMBn0B.js} +1 -1
  33. package/out/renderer/assets/{gitGraphDiagram-7IBYFJ6S-BgsuWJko.js → gitGraphDiagram-7IBYFJ6S-D9Xfi585.js} +1 -1
  34. package/out/renderer/assets/{graph-DibP2uwH.js → graph--_6YRvNt.js} +1 -1
  35. package/out/renderer/assets/{index-CYc5bpbU.js → index-ClKLYxFA.js} +156 -156
  36. package/out/renderer/assets/{index-DsDWrtgg.js → index-CyVnGJyK.js} +1 -1
  37. package/out/renderer/assets/{index-DHNzUcWc.js → index-k_ibS7OP.js} +1 -1
  38. package/out/renderer/assets/infoDiagram-PH2N3AL5-BXUllDL6.js +2 -0
  39. package/out/renderer/assets/{journeyDiagram-U35MCT3I-DgRDuk9c.js → journeyDiagram-U35MCT3I-D4ysR0_X.js} +1 -1
  40. package/out/renderer/assets/{kanban-definition-NDS4AKOZ-BgaT_CKZ.js → kanban-definition-NDS4AKOZ-CKjV_xoh.js} +1 -1
  41. package/out/renderer/assets/{layout-CL9i8GIL.js → layout-B1sQcfBm.js} +1 -1
  42. package/out/renderer/assets/{legacy-agents-page-C8k7XEfH.js → legacy-agents-page-C3fCx_4w.js} +1 -1
  43. package/out/renderer/assets/{library-page-BNzW9PA1.js → library-page-BWTRx0RD.js} +3 -3
  44. package/out/renderer/assets/{mermaid.core-JpXo0jSk.js → mermaid.core-BFagl5M0.js} +5 -5
  45. package/out/renderer/assets/{mesh-page-y0l6tYVm.js → mesh-page-nF_pkDfu.js} +1 -1
  46. package/out/renderer/assets/{mindmap-definition-ALO5MXBD-6ioY9dCZ.js → mindmap-definition-ALO5MXBD-BU4sAzTF.js} +1 -1
  47. package/out/renderer/assets/{mini-wXsWE9jZ.js → mini-D7qJkiP2.js} +1 -1
  48. package/out/renderer/assets/{notifications-page-DhdUb4dS.js → notifications-page-BrfQXjv0.js} +1 -1
  49. package/out/renderer/assets/{org-access-BQxjOcXr.js → org-access-4sUREjsN.js} +1 -1
  50. package/out/renderer/assets/{org-surface-gate-CJ94TLpg.js → org-surface-gate-Dcew35UJ.js} +1 -1
  51. package/out/renderer/assets/{path-utils-nzl9T4lF.js → path-utils-D8EGhun0.js} +32 -32
  52. package/out/renderer/assets/{pieDiagram-IB7DONF6-CjxN4LDg.js → pieDiagram-IB7DONF6-DiOrqvCg.js} +1 -1
  53. package/out/renderer/assets/{project-markdown-CQuaJRQV.js → project-markdown-DRTB-eF8.js} +1 -1
  54. package/out/renderer/assets/{projects-page-Dol_9wd5.js → projects-page-Ce1Ncgqc.js} +1 -1
  55. package/out/renderer/assets/{publication-validation-B7kEFH2c.js → publication-validation-BJvhF9QM.js} +1 -1
  56. package/out/renderer/assets/{quadrantDiagram-7GDLP6J5-BZ5xgzQ_.js → quadrantDiagram-7GDLP6J5-Bkv8fZSt.js} +1 -1
  57. package/out/renderer/assets/{radar-MK3ICKWK-DmvnHlMM.js → radar-MK3ICKWK-CGB-9AQb.js} +1 -1
  58. package/out/renderer/assets/{radient-auth-buttons-Bm2Y7IBD.js → radient-auth-buttons-89F5YrRW.js} +1 -1
  59. package/out/renderer/assets/{requirementDiagram-KVF5MWMF-DCeDlpmZ.js → requirementDiagram-KVF5MWMF-0dxFI-J5.js} +1 -1
  60. package/out/renderer/assets/{sankeyDiagram-QLVOVGJD-DdXx42AR.js → sankeyDiagram-QLVOVGJD-BDSYzFoN.js} +1 -1
  61. package/out/renderer/assets/{schedules-page-Ba4HGzlz.js → schedules-page-CxGBhfL5.js} +1 -1
  62. package/out/renderer/assets/{sequenceDiagram-X6HHIX6F-DPy4_lsG.js → sequenceDiagram-X6HHIX6F-Csei-YXd.js} +1 -1
  63. package/out/renderer/assets/{settings-page-BhZcJ-U5.js → settings-page-DJ0aFYTv.js} +1 -1
  64. package/out/renderer/assets/{smartart-Biwi1vs8.js → smartart-DWwS7qRw.js} +1 -1
  65. package/out/renderer/assets/{stateDiagram-DGXRK772-f4dFZZRz.js → stateDiagram-DGXRK772-CBwyxyKR.js} +1 -1
  66. package/out/renderer/assets/stateDiagram-v2-YXO3MK2T-jS1LVmLM.js +1 -0
  67. package/out/renderer/assets/{team-bridge-page-DLu06lk4.js → team-bridge-page-DD1d63nj.js} +1 -1
  68. package/out/renderer/assets/{team-bridge-scope-preference-W11YdS2M.js → team-bridge-scope-preference-D3OA1yyw.js} +1 -1
  69. package/out/renderer/assets/{timeline-definition-BDJGKUSR-CDz8zL5s.js → timeline-definition-BDJGKUSR-CrVyfj7p.js} +1 -1
  70. package/out/renderer/assets/{use-download-agent-mutation-CTGsmTPP.js → use-download-agent-mutation-DmsgPFVR.js} +1 -1
  71. package/out/renderer/assets/{use-session-snapshot-BzJRC7az.js → use-session-snapshot-ZwSI2jWI.js} +1 -1
  72. package/out/renderer/assets/{xychartDiagram-VJFVF3MP-BOQuMgjD.js → xychartDiagram-VJFVF3MP-PfcVrXID.js} +1 -1
  73. package/out/renderer/console-capture.html +3 -3
  74. package/out/renderer/index.html +4 -4
  75. package/out/renderer/mini.html +4 -4
  76. package/package.json +1 -1
  77. package/out/renderer/assets/browser-page-BniH2C4q.js +0 -1
  78. package/out/renderer/assets/channel-BkxTeyzk.js +0 -1
  79. package/out/renderer/assets/classDiagram-GIVACNV2-CUX0Pf8a.js +0 -1
  80. package/out/renderer/assets/classDiagram-v2-COTLJTTW-CUX0Pf8a.js +0 -1
  81. package/out/renderer/assets/clone-DwyyWGcA.js +0 -1
  82. package/out/renderer/assets/infoDiagram-PH2N3AL5-B5DuyqTN.js +0 -2
  83. package/out/renderer/assets/stateDiagram-v2-YXO3MK2T-B3X88xXR.js +0 -1
@@ -1 +1 @@
1
- import{r as p,j as t,c as H}from"./index-CW7JpbBx.js";import{H as Ve,I as mt,J as ut,K as ce,L as ht,R as pt,M as fe,N as Ge,O as re,Q as Xe,T as Ze,V as Je,a as xt,q as ge,w as je,W as ft}from"./path-utils-nzl9T4lF.js";import{P as gt}from"./page-header-C_NLT5l1.js";import{u as K,B as ee,w as vt,G as bt,s as pe,D as _t,b as kt,d as yt,H as jt,I as Pe,e as $e,f as Le,A as we}from"./error-boundary-OwA_uKkY.js";import{t as a}from"./messages-DjcNNMrL.js";import{U as de,V as me,W as Te,X as wt,Y as Qe,Z as Nt,_ as It,$ as Ct,a0 as St,a1 as Mt,a2 as At,a3 as Dt,a4 as Rt,a5 as Et,a6 as Pt,a7 as $t,a8 as Lt,a9 as Tt,aa as Ot,ab as Ht,ac as Wt,ad as qt,ae as zt,af as Ft,ag as Se,ah as Bt,ai as Ut,aj as Me,ak as et,al as tt,am as Yt,an as ve,ao as Ne,ap as Kt,aq as Vt,ar as be,as as Oe,at as Gt,au as Xt,av as Ie,aw as Zt,ax as st,ay as _e,az as Jt,aA as at,aB as Qt,aC as es,aD as ts,aE as ss,aF as as,aG as ns,aH as is,aI as rs,aJ as ls,aK as os,aL as ds,aM as cs,aN as ms,aO as us,aP as hs,aQ as ps,aR as xs,aS as fs,aT as gs,aU as xe,aV as vs,aW as bs}from"./index-CYc5bpbU.js";import{bB as ke,bC as _s,bD as Ae,bE as ks,a2 as nt}from"./conversation-input-sync-BnhCcKxP.js";import"./console-mirror-DEmWiLpt.js";function ys(e){return e==="failed"?"text-danger":de(e)?"text-ink-muted":"text-ink-dim"}function js(e){return e==="failed"?a("ui.mesh.mesh_approvals_tray.abandon"):a("ui.mesh.mesh_approvals_tray.stop")}function ws(e){switch(e){case"requested":return[{term:a("ui.mesh.mesh_approvals_tray.signing"),text:a("ui.mesh.mesh_approvals_tray.approving_signs_with_this_machine_s_operator")}];case"approved":return[{term:a("ui.mesh.mesh_approvals_tray.next"),text:a("ui.mesh.mesh_approvals_tray.an_agent_runs_the_install_and_connect")},{term:a("ui.mesh.mesh_approvals_tray.stop"),text:a("ui.mesh.mesh_approvals_tray.stopping_now_denies_the_request_nothing_has")}];case"connecting":return[{term:a("ui.mesh.mesh_approvals_tray.stop"),text:a("ui.mesh.mesh_approvals_tray.stopping_now_denies_the_request_the_runner")}];case"failed":return[{term:a("ui.mesh.mesh_approvals_tray.after_a_stop"),text:a("ui.mesh.mesh_approvals_tray.the_runner_stopped_before_it_finished_abandoning")}];default:return[]}}const Ns=({rows:e,error:n,pending:s,refusal:i,onDecide:u,onRetry:m,nowSeconds:f,networkNames:o,credentialApprovals:v=!1})=>{K();const y=s!==null,[w,R]=p.useState(""),M=p.useRef(null),d=i?JSON.stringify([i.approvalId,i.code,i.sentence]):null,c=p.useMemo(()=>e.filter(x=>de(x.state)||me(x)),[e]),h=p.useMemo(()=>e.filter(x=>!de(x.state)&&!me(x)),[e]),[C,S]=p.useState(!1),D=p.useRef(null),N=p.useRef(null),b=p.useRef(null),P=(x,L)=>{c.some(W=>W.approvalId===x&&W.kind==="credential")&&(b.current={id:x,origin:document.activeElement,rowAtStart:e.find(W=>W.approvalId===x),refusalSubmittedAtStart:i?.submittedAt??0}),u(x,L)};p.useLayoutEffect(()=>{const x=b.current;if(!x)return;const L=e.find(q=>q.approvalId===x.id);if(s)return;const W=i?.approvalId===x.id&&(i.submittedAt??0)>x.refusalSubmittedAtStart;if(L===x.rowAtStart&&!W)return;b.current=null;const G=c.find(q=>q.approvalId!==x.id),Y=G?D.current?.querySelector(`[data-tour-tag="mesh-approvals-live"] [data-approval-id="${CSS.escape(G.approvalId)}"] ${de(G.state)?'[data-tour-tag="mesh-approval-summary"]':'[data-tour-tag="mesh-approval-controls"] button:not(:disabled)'}`):null,te=(c.some(q=>q.approvalId===x.id)?D.current?.querySelector(`[data-approval-id="${CSS.escape(x.id)}"] [data-tour-tag="mesh-approval-refusal"]`):null)??Y??N.current?.querySelector("button"),$=i?D.current?.querySelector(`[data-approval-refusal-id="${CSS.escape(i.approvalId??"")}"]`)??null:null;Te({document,target:te??null,refusalTarget:$,origin:x.origin,allowFocus:!0,sentence:i?.sentence??""}).focused&&(M.current=d)},[e,s,i,c,d]),p.useLayoutEffect(()=>{if(!i||s){M.current=null,R("");return}if(M.current===d){R("");return}const x=D.current?.querySelector(`[data-approval-refusal-id="${CSS.escape(i.approvalId??"")}"]`)??null,L=Te({document,target:null,refusalTarget:x,origin:null,allowFocus:!1,sentence:i.sentence});L.focused&&(M.current=d),R(L.announcement)},[i,d,s,e]);const E=c.filter(x=>de(x.state)).length,I=c.filter(me).length,j=h.filter(x=>x.kind==="credential"&&x.state==="connected").length,_=h.some(x=>x.state==="failed"),A=h.filter(x=>x.state==="failed").length,Z=i!==null&&e.some(x=>x.approvalId===i.approvalId&&(de(x.state)||me(x)||C)),V=e.find(x=>x.approvalId===i?.approvalId);return c.length===0&&h.length===0&&!n&&!i?null:t.jsxs("section",{ref:D,"aria-label":a("ui.mesh.mesh_approvals_tray.approvals"),"data-tour-tag":"mesh-approvals-tray",className:"flex flex-col gap-3",children:[t.jsx("output",{"aria-live":"polite","aria-atomic":"true",className:"sr-only",children:a("ui.mesh.approval.result_status",{shared:j,attention:I})}),t.jsx("output",{"aria-live":"polite","aria-atomic":"true",className:"sr-only","data-tour-tag":"mesh-approval-announcement",children:t.jsx("bdi",{dir:"auto",children:w})}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx(wt,{"aria-hidden":"true",className:"size-4 text-ink-muted"}),t.jsx("h2",{className:"text-body-sm text-ink",children:a("ui.mesh.mesh_approvals_tray.approvals")}),E>0&&t.jsx("span",{className:"text-meta text-ink-dim",children:a("ui.mesh.mesh_approvals_tray.waiting_count",{count:E})}),I>0&&t.jsx("span",{className:"text-meta text-warning",children:a("ui.mesh.approval.needs_attention",{count:I})})]}),n&&t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("p",{className:"min-w-0 flex-1 text-meta text-ink-muted",children:n}),t.jsx(ee,{variant:"secondary",size:"sm",onClick:m,children:a("ui.mesh.mesh_approvals_tray.ask_again")})]}),c.length>0&&t.jsx("ul",{className:"flex flex-col divide-y divide-hairline","data-tour-tag":"mesh-approvals-live",children:c.map(x=>t.jsx(He,{row:x,pending:s?.approvalId===x.approvalId?s:null,busy:y,refusal:i?.approvalId===x.approvalId?i:null,onDecide:P,nowSeconds:f,networkNames:o,credentialApprovals:v},x.approvalId))}),i&&!Z&&t.jsx(it,{approvalId:i.approvalId??"",requestIsBackendSummary:V?Nt(V):!1,refusal:i,request:V?Qe(V):a("ui.mesh.approval.credential_title")}),h.length>0&&t.jsx("div",{ref:N,"data-tour-tag":"mesh-approvals-settled",children:t.jsx(ke,{open:C,onOpenChange:S,chevronClassName:"text-ink-dim",className:H(c.length>0&&"border-hairline border-t pt-3"),summary:t.jsxs("span",{className:"flex items-center gap-1.5 text-meta text-ink-muted",children:[a("ui.mesh.mesh_approvals_tray.settled_approvals"),t.jsxs("span",{className:"text-ink-dim",children:["(",h.length,")"]}),_&&t.jsx("span",{"aria-hidden":"true",className:"size-1.5 rounded-full bg-danger"}),j>0&&t.jsx("span",{className:"text-ink-muted",children:a("ui.mesh.approval.shared_count",{count:j})}),A>0&&t.jsx("span",{className:"text-danger",children:a("ui.mesh.mesh_approvals_tray.failed_count",{count:A})})]}),children:t.jsx("ul",{className:"flex flex-col divide-y divide-hairline","data-tour-tag":"mesh-approvals-records",children:h.map(x=>t.jsx(He,{row:x,pending:s?.approvalId===x.approvalId?s:null,busy:y,refusal:i?.approvalId===x.approvalId?i:null,onDecide:P,nowSeconds:f,networkNames:o,credentialApprovals:v},x.approvalId))})})})]})},He=({row:e,pending:n,busy:s,refusal:i,onDecide:u,nowSeconds:m,networkNames:f,credentialApprovals:o})=>{K();const v=de(e.state),y=It(e,i?.retryable),w=p.useId(),R=p.useId(),M=Qe(e),d=Ct(e,f),c=St(e,f),h=Mt(e),C=At(e),S=Dt(e),D=Rt(e.expiresAt,m,me(e)),N=e.kind==="credential"||e.kind==="unknown",b=N||e.canApproveHere===!1,P=b?[]:ws(e.state),E={credentialApprovals:o},I=Et(e,E),j=Pt(e.state),_=$t(e,E,i?.retryable),A=o?e.typed:void 0,Z=A?Lt(e):[],V=A?.disclosure?Tt(e):null,x=e.typed?.unprovenHuman===!0,L=e.kind==="credential"&&["approved","failed","connecting","connected"].includes(e.state),W=i?.sentence||(A?.applyOutcome?[A.applyOutcome.reason,A.applyOutcome.remedy].filter(Boolean).join(" "):""),G=i?.code||A?.applyOutcome?.code||A?.refusal,Y=Ot(e),te=(e.typed?.refusalMessage??"")||(e.typed?a("ui.mesh.approval.typed_review_unavailable"):e.approveRemedy||a("ui.mesh.approval.cli_review"));return t.jsxs("li",{className:"flex flex-col gap-2 py-3 first:pt-0 last:pb-0","data-tour-tag":"mesh-approval-card","data-approval-id":e.approvalId,children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("span",{className:H("text-meta",me(e)?"text-warning":ys(e.state)),children:y?a("ui.mesh.approval.could_not_apply"):e.kind==="credential"&&e.state==="connected"?a("ui.mesh.approval.shared"):e.kind==="credential"&&(e.state==="approved"||e.state==="failed")?a("ui.mesh.approval.approved_not_applied"):Ht(e.state)}),t.jsx("div",{className:"grow"}),!y&&(v||me(e))&&D&&t.jsx("span",{className:"text-meta text-ink-dim",children:D})]}),t.jsx("p",{className:"text-body-sm text-ink [overflow-wrap:anywhere]","data-tour-tag":"mesh-approval-summary",tabIndex:-1,id:w,children:v?d:M}),Y&&t.jsx("p",{id:R,className:"text-meta text-ink-muted","data-tour-tag":"mesh-approval-critical-facts",children:Y}),!b&&e.state==="failed"&&t.jsx("p",{className:"text-meta text-ink-muted","data-tour-tag":"mesh-approval-stopped-note",children:a("ui.mesh.mesh_approvals_tray.the_runner_stopped_before_it_finished_it")}),v&&b&&!I&&t.jsx("p",{className:"text-meta text-ink-muted whitespace-pre-wrap [overflow-wrap:anywhere]","data-tour-tag":"mesh-approval-cli-remedy",children:te}),e.kind==="credential"&&!e.typed&&e.state==="approved"&&t.jsx("p",{className:"text-meta text-ink-muted","data-tour-tag":"mesh-approval-apply-hint",children:a(e.details?.length?"ui.mesh.approval.approved_apply_hint":"ui.mesh.approval.approved_details_missing")}),x&&t.jsx("p",{className:"text-meta text-ink-dim","data-tour-tag":"mesh-approval-file-key",children:a(L?"ui.mesh.approval.file_key_recorded":"ui.mesh.approval.file_key_disclosure")}),W&&t.jsx(it,{approvalId:e.approvalId,refusal:{code:G??"",sentence:W}}),_&&t.jsx("p",{className:"text-meta text-ink-muted",children:a("ui.mesh.approval.retry_hint")}),L&&j&&t.jsx("p",{className:"text-meta text-ink-muted",children:a("ui.mesh.approval.cancel_hint")}),(I||j||_)&&t.jsxs("div",{className:"flex flex-wrap items-center gap-2","data-tour-tag":"mesh-approval-controls",children:[_&&t.jsx(ee,{variant:"primary",size:"sm",disabled:s,"aria-describedby":Y?`${w} ${R}`:w,onClick:()=>u(e.approvalId,"apply"),"data-tour-tag":"mesh-approval-retry-apply",children:a("ui.mesh.approval.try_again")}),I&&t.jsx(ee,{variant:"primary",size:"sm",disabled:s,"aria-describedby":Y?`${w} ${R}`:w,onClick:()=>u(e.approvalId,"approve"),"data-tour-tag":"mesh-approval-approve",children:a("ui.mesh.mesh_approvals_tray.approve")}),j&&t.jsx(ee,{variant:"ghost",size:"sm",disabled:s,"aria-describedby":Y?`${w} ${R}`:w,onClick:()=>u(e.approvalId,"deny"),"data-tour-tag":v?"mesh-approval-deny":"mesh-approval-stop",children:v?a("ui.mesh.mesh_approvals_tray.deny"):e.kind==="credential"?a("ui.mesh.approval.cancel_sharing"):js(e.state)}),n&&t.jsx("span",{className:"text-meta text-ink-dim",children:n.decision==="approve"?e.typed?.unprovenHuman?a("ui.mesh.approval.signing_applying"):a("ui.mesh.mesh_approvals_tray.waiting_for_the_signing_prompt"):n.decision==="apply"?a("ui.mesh.approval.applying"):a("ui.mesh.mesh_approvals_tray.writing_the_decision")})]}),t.jsxs(ke,{chevronClassName:"text-ink-dim",summary:t.jsx("span",{className:"text-meta",children:a("ui.mesh.mesh_approvals_tray.details")}),children:[Z.length>0&&t.jsx("ul",{className:"flex flex-col gap-1.5 text-meta text-ink-muted [overflow-wrap:anywhere]","data-tour-tag":"mesh-approval-credential-consequences",children:Z.map($=>t.jsx("li",{children:$},$))}),V&&A?.disclosure?.recipient.keyFingerprint&&t.jsxs("p",{className:"text-meta text-ink-dim [overflow-wrap:anywhere]",children:[a("ui.mesh.approval.recipient_key",{device:V})," ",t.jsx("span",{className:"font-mono",children:A.disclosure.recipient.keyFingerprint})]}),G&&t.jsx("p",{className:"text-meta text-ink-dim font-mono",children:G}),A?.disclosure&&t.jsx(ke,{summary:t.jsx("span",{className:"text-meta",children:a("ui.mesh.approval.technical_request")}),children:t.jsx("pre",{className:"max-h-48 overflow-auto whitespace-pre-wrap text-meta text-ink-dim [overflow-wrap:anywhere]","data-tour-tag":"mesh-approval-signed-evidence",children:A.disclosure.evidence})}),N&&Z.length===0&&(e.details?.length?t.jsx("ul",{className:"flex flex-col gap-1.5 text-meta text-ink-muted [overflow-wrap:anywhere]","data-tour-tag":"mesh-approval-server-details",children:e.details.map(($,se)=>t.jsx("li",{className:"whitespace-pre-wrap",children:$},`${se}:${$}`))}):t.jsx("p",{className:"text-meta text-ink-muted",children:a("ui.mesh.approval.details_unavailable")})),c.length>0&&t.jsx("dl",{className:"grid grid-cols-[max-content_1fr] gap-x-4 gap-y-0.5 text-meta text-ink-dim","data-tour-tag":"mesh-approval-consequences",children:c.map($=>t.jsxs(p.Fragment,{children:[t.jsx("dt",{className:"text-ink-muted",children:$.term}),t.jsx("dd",{children:$.consequence})]},$.term))}),(h||C)&&t.jsxs("p",{className:"text-meta text-ink-muted",children:[h&&t.jsx("span",{children:h}),h&&C&&t.jsx("span",{children:" · "}),C&&t.jsx("span",{className:"font-mono",children:C})]}),S&&t.jsx("p",{className:"text-meta text-ink-dim",children:S}),P.length>0&&t.jsx("dl",{className:"grid grid-cols-[max-content_1fr] gap-x-4 gap-y-0.5 text-meta","data-tour-tag":"mesh-approval-consequence",children:P.map($=>t.jsxs(p.Fragment,{children:[t.jsx("dt",{className:"text-ink-muted",children:$.term}),t.jsx("dd",{className:"text-ink-muted",children:$.text})]},$.term))})]})]})},it=({refusal:e,request:n,approvalId:s,requestIsBackendSummary:i=!1})=>{K();const u=_s();return t.jsx("p",{tabIndex:-1,className:"text-meta text-warning [overflow-wrap:anywhere]","data-tour-tag":"mesh-approval-refusal","data-approval-refusal-id":s,children:n?Wt(n,e.sentence).map((m,f)=>m.kind==="literal"?t.jsx(p.Fragment,{children:m.text},`literal:${f}`):t.jsx("bdi",{dir:qt(m.kind,u,i),children:m.text},m.kind)):t.jsx("bdi",{dir:"auto",children:e.sentence})})},Is=4,ye={kind:"idle"};function Cs(e){switch(e.kind){case"dragging":case"settling":return e.payload.session.id;case"pressing":return null;default:return null}}function oe(e,n){switch(n.kind){case"press":return e.kind!=="idle"?e:{kind:"pressing",payload:n.payload,originX:n.x,originY:n.y,pointerId:n.pointerId};case"move":return e.kind==="pressing"?Math.max(Math.abs(n.x-e.originX),Math.abs(n.y-e.originY))<Is?e:{kind:"dragging",payload:e.payload,x:n.x,y:n.y,target:n.target,pointerId:e.pointerId}:e.kind==="dragging"?{...e,x:n.x,y:n.y,target:n.target}:e;case"release":return e.kind==="dragging"?{kind:"settling",payload:e.payload,target:e.target}:e.kind==="pressing"?ye:e;case"cancel":case"settled":return ye;default:return e}}const Ss=({edges:e,geometry:n,selectedDeviceId:s})=>t.jsx("svg",{"aria-hidden":"true",className:"pointer-events-none absolute top-0 left-0 overflow-visible",width:n.bounds.width,height:n.bounds.height,children:e.map(i=>{const u=n.networks.get(i.networkId),m=n.devices.get(i.deviceId);if(!u||!m)return null;const f=s!==null&&i.deviceId===s;return t.jsx("path",{"data-mesh-edge":i.key,d:zt(u,m),fill:"none",strokeWidth:f?2:1.5,className:f?"stroke-ink":"stroke-ink-dim"},i.key)})}),De=({deviceId:e,name:n,compact:s=!1,deviceIds:i,className:u})=>{K();const m=Ve({name:n});return t.jsxs("span",{className:H("flex min-w-0 items-baseline gap-2",u),"data-mesh-device-identity":e,children:[t.jsx(vt,{content:n?.trim()?m:null,children:t.jsx("span",{className:"min-w-0 flex-1 truncate text-start","data-mesh-device-name":"",children:m})}),t.jsx("span",{className:"shrink-0 font-mono text-meta text-ink-muted","data-mesh-device-id":"",title:e,children:s?mt(e,i):e})]})},Ms={self:"border-l-hairline",reached:"border-l-hairline","relay-down":"border-l-warning","handshake-refused":"border-l-warning","address-unreachable":"border-l-warning","no-endpoint":"border-l-hairline","not-a-member":"border-l-hairline",unanswered:"border-l-warning","not-attempted":"border-l-hairline",unknown:"border-l-hairline"};function As(e){return e.suspect?"border-l-danger":Ms[ce(e)]}const Ds={self:"ring-2 ring-accent",reachable:null,relay_down:null,handshake_refused:null,unreachable:null,suspect:null},Rs={accept:"border-accent bg-accent-wash",refuse:"border-warning"};function Es(e,n,s){return[Ve(e),e.id,tt(e,n),s].filter(Boolean).join(", ")}function ue(e){return e.name.trim()||e.id.slice(-6)}function rt(e,n,s){if(s!=="reached"&&s!=="self"){const i=fe(s);return e.unreachable_reason?`${i} (${e.unreachable_reason})`:i}return e.live_state.trim()?e.live_state.trim():e.locality==="local"?a("ui.mesh.mesh_drop.on_this_device"):a("ui.mesh.mesh_node.on_device",{device:n})}const Ps={resting:"border-l-2 border-l-hairline",attention:"border-l-2 border-l-warning"},$s=({network:e,x:n,y:s,refused:i})=>(K(),t.jsxs("li",{"data-mesh-network":e.id,"data-mesh-network-refused":i?"true":void 0,"data-glass-block":"",className:H("absolute flex items-center gap-2 rounded-md border bg-elevated px-3",i?"border-warning":"border-hairline"),style:{left:n,top:s,width:Se,height:Ft},children:[t.jsx(Ae,{"aria-hidden":"true",className:"size-4 shrink-0 text-ink-muted"}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"block truncate text-body-sm text-ink",children:e.label}),t.jsxs("span",{title:a("ui.mesh.mesh_list.epoch",{epoch:e.epoch}),className:"block truncate text-meta text-ink-dim",children:[a("ui.mesh.mesh_graph.device_count",{count:e.memberCount}),e.revokedCount>0?t.jsxs(t.Fragment,{children:[" · ",a("ui.mesh.mesh_list.revoked_count",{count:e.revokedCount})]}):null]})]})]})),Ls=({device:e,deviceIds:n,x:s,y:i,nowSeconds:u,selected:m,sessions:f,sessionTotal:o,dropState:v,movingSessionId:y,draggedSessionId:w,onOpen:R,onChipPointerDown:M,onChipClick:d,onShowAllSessions:c})=>{K();const{activity:h}=ut(e,f.rows),C=h==="working",S=Es(e,u,C?"working":null),D=ce(e);return t.jsxs("li",{"data-mesh-device":e.id,"data-mesh-state":e.state,"data-mesh-drop":v??void 0,"aria-current":m?"true":void 0,"data-glass-block":"",className:H("absolute flex flex-col rounded-md border border-l-4 border-control bg-elevated","hover:bg-row-hover",m&&"border-y-ink border-r-ink bg-row-selected",As(e),Ds[e.state],v&&Rs[v]),style:{left:s,top:i,width:Se,height:Bt},children:[t.jsxs("button",{type:"button","data-mesh-device-open":e.id,"data-mesh-reach":D,"aria-label":S,title:ht(e),onClick:()=>R(e.id),className:H("flex w-full flex-col justify-between rounded-t-[5px] px-3 pt-2 pb-2 text-start","cursor-pointer","focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent focus-visible:outline-offset-[-2px]"),style:{height:Ut},children:[t.jsxs("span",{className:"flex w-full min-w-0 items-center gap-2",children:[t.jsx(ks,{"aria-hidden":"true",className:"size-4 shrink-0 text-ink-muted"}),t.jsx(De,{className:"min-w-0 flex-1 text-body-sm text-ink",deviceId:e.id,deviceIds:n,name:e.name,compact:!0}),e.suspect&&t.jsx(Me,{"aria-hidden":"true",className:"size-3.5 shrink-0 text-danger"})]}),t.jsxs("span",{className:"flex w-full min-w-0 items-baseline gap-1",children:[t.jsx("span",{className:"w-3 shrink-0 font-mono text-body-sm text-ink tabular-nums",children:e.sessionCount??"–"}),t.jsx("span",{className:H("min-w-0 truncate text-meta",e.sessionCount===null?"text-ink-dim":"text-ink-muted"),children:et(e.sessionCount)})]}),t.jsxs("span",{"data-mesh-state-line":"",className:"flex w-full min-w-0 items-baseline gap-1.5 text-meta",children:[t.jsx("span",{"aria-hidden":"true",className:"shrink-0 text-ink-dim",children:pt[D]}),t.jsx("span",{className:H("shrink-0",Ge[D]),children:fe(D)}),C&&t.jsx("span",{"data-mesh-working":"",className:"shrink-0 text-info",children:a("ui.mesh.mesh_node.working")}),e.memberships.length>1&&t.jsx("span",{className:"min-w-0 truncate text-ink-dim",children:a("ui.mesh.mesh_node.memberships",{count:e.memberships.length})})]})]}),t.jsxs("ul",{"aria-label":a("ui.mesh.mesh_node.conversations_on",{device:re(e,n,!0)}),className:H("m-0 flex h-6 list-none items-center gap-1 overflow-hidden px-3",v==="accept"&&"opacity-40"),children:[f.shown.map(N=>t.jsx(Ts,{session:N,ownerLabel:re(e,n,!0),ownerReach:D,ownerReachable:e.reachable,moving:y===N.id,dragging:w===N.id,onPointerDown:M,onClick:()=>d(N)},N.id)),f.hidden>0&&t.jsx("li",{className:"shrink-0",children:t.jsxs("button",{type:"button","data-mesh-more":e.id,onClick:()=>c(e.id),className:H("flex min-h-6 items-center rounded-sm px-1.5 text-meta text-ink-dim","hover:bg-row-hover hover:text-ink","focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent focus-visible:outline-offset-2"),title:a("ui.mesh.mesh_node.shown_conversations",{shown:f.shown.length,total:o}),"aria-label":a("ui.mesh.mesh_node.show_all_conversations",{count:o}),children:["+",f.hidden]})})]})]})},Ts=({session:e,ownerLabel:n,ownerReach:s,ownerReachable:i,moving:u,dragging:m,onPointerDown:f,onClick:o})=>{K();const v=rt(e,n,s);return u?t.jsx("li",{role:"status","data-mesh-session":e.id,"data-mesh-moving":"true",children:t.jsx("span",{className:"flex min-h-6 items-center rounded-sm bg-sunken px-1.5 text-meta text-ink-muted",children:a("ui.mesh.mesh_card.moving")})}):t.jsx("li",{className:"min-w-0 flex-1","data-mesh-session-item":e.id,"data-mesh-dragging":m?"true":void 0,children:t.jsx("button",{type:"button","data-mesh-session":e.id,style:{touchAction:"none"},title:`${ue(e)} · ${v}`,"aria-label":a("ui.mesh.mesh_node.open_conversation",{conversation:ue(e),fact:v,owner:n}),onPointerDown:y=>f(y,e),onClick:()=>o(e),className:H("flex min-h-6 w-full max-w-32 items-center rounded-sm border border-hairline bg-surface px-1.5 text-start text-meta text-ink-muted","cursor-grab active:cursor-grabbing","hover:text-ink",Ps[Yt(e,i)],m&&"opacity-60","focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent focus-visible:outline-offset-2"),children:t.jsx("span",{className:"min-w-0 flex-1 truncate",children:ue(e)})})})};function We(e){const n=e.trim();if(!n)return null;if(n.startsWith("[")){const i=n.indexOf("]");if(i<=1)return null;const u=n.slice(1,i),m=n.slice(i+1);if(!m)return{host:u,port:null};if(!m.startsWith(":"))return null;const f=Number(m.slice(1));return{host:u,port:Number.isInteger(f)?f:null}}const s=n.lastIndexOf(":");if(s>0){const i=n.slice(s+1);if(/^\d+$/.test(i))return{host:n.slice(0,s),port:Number(i)}}return{host:n,port:null}}function qe(e){const n=e.trim().split(".");if(n.length!==4)return null;for(const s of n)if(!/^\d{1,3}$/.test(s)||Number(s)>255)return null;return`${n[0]}.${n[1]}.${n[2]}`}function Os(e){return`${e}.x`}function Hs(e){const n=new Map;for(const i of e.values())for(const u of i)n.set(u,(n.get(u)??0)+1);const s=new Set;for(const[i,u]of n)u>1&&s.add(i);return s}function Ce(e){return new Set(e.endpoints.map(n=>n.trim()).filter(Boolean))}function Ws(e,n){const s=e.filter(d=>d.id!==n),i=e.find(d=>d.id===n)??null,u=new Map;for(const d of e)u.set(d.id,Ce(d));const m=Hs(u),f=new Set;for(const d of i?Ce(i):[]){if(m.has(d))continue;const c=We(d),h=c?qe(c.host):null;h&&f.add(h)}const o=d=>{const c=new Set;for(const h of Ce(d)){if(m.has(h))continue;const C=We(h),S=C?qe(C.host):null;S&&c.add(S)}return c},v=new Map,y=new Map;for(const d of s){const c=qs(d);if(c){v.set(c,[...v.get(c)??[],d.id]);continue}for(const h of o(d))y.set(h,[...y.get(h)??[],d.id])}const w=new Map(e.map((d,c)=>[d.id,c])),R=d=>[...d].sort((c,h)=>(w.get(c)??0)-(w.get(h)??0)),M=[];for(const[d,c]of v)M.push({prefix:d,tier:"declared",deviceIds:R(c),get words(){return a("ui.mesh.mesh_scope.declared")}});for(const[d,c]of y)f.has(d)?M.push({prefix:d,tier:"shared",deviceIds:R(c),get words(){return a("ui.mesh.mesh_scope.shared_with_this_device")}}):c.length>1&&M.push({prefix:d,tier:"probable",deviceIds:R(c),get words(){return a("ui.mesh.mesh_scope.same_prefix")}});return M.sort((d,c)=>d.tier.localeCompare(c.tier)||d.prefix.localeCompare(c.prefix))}function qs(e){for(const n of e.memberships){const s=n.scope.trim();if(s)return s}return""}const ze={declared:0,shared:1,probable:2};function zs(e,n){const s=new Map;for(const u of e){let m=null;for(const o of u.deviceIds){const v=n.get(o);v!==void 0&&(m===null||v<m.slot)&&(m={id:o,slot:v})}if(m===null)continue;const f=s.get(m.id);f===void 0?s.set(m.id,{slot:m.slot,groups:[u]}):f.groups.push(u)}const i=u=>{let m=-1;for(const f of u.deviceIds){const o=n.get(f);o!==void 0&&o>m&&(m=o)}return m};return[...s.entries()].sort((u,m)=>u[1].slot-m[1].slot).map(([u,m])=>({deviceId:u,groups:m.groups.sort((f,o)=>i(o)-i(f)||ze[f.tier]-ze[o.tier]||f.prefix.localeCompare(o.prefix))}))}function Fs(e){return new Map(e.map(n=>[n.deviceId,n.groups.length]))}function Bs(e){return`${e.tier==="declared"?e.prefix:Os(e.prefix)} · ${e.words}`}const Fe=(e,n)=>e.deviceIds.map(s=>n.devices.get(s)).filter(s=>s!==void 0),Us=({stacks:e,geometry:n})=>(K(),t.jsx("div",{"aria-hidden":"true",className:"pointer-events-none absolute top-0 left-0",children:e.map(s=>{const i=s.groups.length,u=new Array(i).fill(0);let m=null;for(let o=i-1;o>=0;o-=1){const v=Fe(s.groups[o],n),y=(v.length===0?0:Math.max(...v.map(w=>w.y+w.height)))+ve;m=m===null?y:Math.max(y,m+Ne),u[o]=m}const f=n.devices.get(s.deviceId);return s.groups.map((o,v)=>{const y=Fe(o,n);if(y.length===0)return null;const w=i-1-v,R=Math.min(...y.map(S=>S.x)),M=Math.max(...y.map(S=>S.x)),c=(f?.y??Math.min(...y.map(S=>S.y)))-ve-Kt*w,h=o.tier==="declared",C=Bs(o);return t.jsx("div",{"data-mesh-scope":`${o.tier}:${o.prefix}`,"data-mesh-scope-level":v,className:H("absolute rounded-lg",o.tier==="probable"?"border border-dashed border-hairline-strong":"border border-control"),style:{left:R-ve-Ne*w,top:c,width:M+Se-R+(ve+Ne*w)*2,height:u[v]-c},children:t.jsx("span",{"data-mesh-scope-label":"",className:H("absolute bottom-full left-1 mb-0.5 whitespace-nowrap text-meta",o.tier==="probable"?"text-ink-dim":"text-ink-muted",h&&"font-medium"),children:C})},`${o.tier}:${o.prefix}`)})})})),Be=48,Ue=1.25,Ys=.0015,Ks=({graph:e,slots:n,nowSeconds:s,selectedDeviceId:i,sessions:u,sessionTotals:m,movingSessionId:f,canMove:o,onOpenDevice:v,onAskMove:y,onDropRefused:w,onShowAllSessions:R,summaryId:M})=>{K();const d=p.useRef(null),[c,h]=p.useState({width:0,height:0,clipWidth:0,clipHeight:0,left:0,top:0}),[C,S]=p.useState({k:1,tx:0,ty:0}),D=p.useRef(!1),N=p.useRef(!1),b=p.useRef(null),P=p.useMemo(()=>Ws(e.devices,e.selfDeviceId),[e.devices,e.selfDeviceId]),E=p.useMemo(()=>zs(P,n.devices),[P,n]),I=p.useMemo(()=>Vt(n,Fs(E)),[n,E]),j=p.useMemo(()=>({selfDeviceId:e.selfDeviceId,devices:new Map(e.devices.map(r=>[r.id,r])),networks:new Map(e.networks.map(r=>[r.id,r]))}),[e]),[_,A]=p.useState(ye),Z=p.useRef({kind:"ground"}),V=p.useCallback((r,l)=>{const g=document.elementFromPoint(r,l),T=g?.closest("[data-mesh-device]");if(T){const ae=T.getAttribute("data-mesh-device");if(ae)return{kind:"device",deviceId:ae}}const U=g?.closest("[data-mesh-network]");if(U){const ae=U.getAttribute("data-mesh-network");if(ae)return{kind:"network",networkId:ae}}return{kind:"ground"}},[]),x=p.useMemo(()=>_.kind!=="dragging"&&_.kind!=="settling"?null:be(_.payload,_.target,j),[_,j]),L=p.useCallback(r=>{if(!x)return null;if(x.kind==="plan"){const l=_.kind==="dragging"||_.kind==="settling"?_.target:null;return l&&l.kind==="device"&&l.deviceId===r?"accept":null}if(x.kind==="refused"){const l=_.kind==="dragging"||_.kind==="settling"?_.target:null;return l&&l.kind==="device"&&l.deviceId===r?"refuse":null}return null},[x,_]),W=p.useCallback((r,l)=>{if(!o||r.button!==0)return;N.current=!1;const g=l.locality==="local"?e.selfDeviceId??"":l.owner_device,T=j.devices.get(g),U={session:l,ownerDeviceId:g,ownerLabel:T?re(T,[...j.devices.keys()],!0):l.owner_device_name};try{r.currentTarget.setPointerCapture(r.pointerId)}catch{}A(ae=>oe(ae,{kind:"press",payload:U,x:r.clientX,y:r.clientY,pointerId:r.pointerId}))},[o,j,e.selfDeviceId]),G=r=>{if(_.kind==="pressing"||_.kind==="dragging"){const l=V(r.clientX,r.clientY);Z.current=l,A(g=>oe(g,{kind:"move",x:r.clientX,y:r.clientY,target:l}));return}J(r)},Y=r=>{if(le(r),_.kind!=="pressing"&&_.kind!=="dragging")return;if(_.kind==="pressing"){A(g=>oe(g,{kind:"cancel"}));return}const l=be(_.payload,_.target,j);N.current=!0,A(g=>oe(g,{kind:"release"})),l.kind==="plan"?y({plan:l.plan,alternatives:l.alternatives,risky:l.risky}):l.kind==="refused"&&w({code:l.code,sentence:l.sentence,reach:l.reach,remedy:l.remedy,plan:l.plan??null}),A(g=>oe(g,{kind:"settled"}))};p.useEffect(()=>()=>A(ye),[]);const te=p.useCallback(()=>{S(Oe(I.bounds,c))},[I.bounds,c]);p.useEffect(()=>{const r=d.current;if(!r)return;const l=()=>{const T=r.getBoundingClientRect();h({width:T.width,height:T.height,clipWidth:r.clientWidth,clipHeight:r.clientHeight,left:T.left,top:T.top})};l();const g=new ResizeObserver(l);return g.observe(r),()=>g.disconnect()},[]),p.useEffect(()=>{D.current||c.width<=0||c.height<=0||(D.current=!0,S(Oe(I.bounds,c)))},[c,I.bounds]),p.useEffect(()=>{const r=b.current;if(b.current={width:c.width,height:c.height},!r||!D.current||c.width<=0||c.height<=0||c.width>=r.width&&c.height>=r.height||!i)return;const l=I.devices.get(i);l&&S(g=>{const T={width:c.clipWidth,height:c.clipHeight},U=Math.max(0,Math.min(T.width-I.bounds.width*g.k,T.height-I.bounds.height*g.k));return Gt(g,l,T,Math.min(Zt,U))})},[c,i,I]);const $=_.kind==="dragging"?{x:_.x-c.left+12,y:_.y-c.top+12}:{x:0,y:0},se=x?Xt(x):null,q=p.useRef(null),ne=p.useRef(null),k=p.useRef(null),O=p.useRef(null),z=p.useCallback(()=>{k.current=null;const r=q.current,l=ne.current;if(q.current=null,ne.current=null,r){const g=O.current;if(!g)return;S({k:g.transform.k,tx:g.transform.tx+(r.x-g.x),ty:g.transform.ty+(r.y-g.y)});return}l&&S(g=>Ie(g,{x:l.x,y:l.y},g.k*Math.exp(-l.deltaY*Ys)))},[]),B=p.useCallback(()=>{k.current===null&&(k.current=requestAnimationFrame(z))},[z]);p.useEffect(()=>()=>{k.current!==null&&cancelAnimationFrame(k.current)},[]);const F=r=>{!(r.target===r.currentTarget)&&r.button!==1||r.button!==0&&r.button!==1||(O.current={x:r.clientX,y:r.clientY,transform:C},r.currentTarget.setPointerCapture(r.pointerId),r.preventDefault())},J=r=>{O.current&&(q.current={x:r.clientX,y:r.clientY},B())},le=r=>{O.current&&(O.current=null,q.current=null,r.currentTarget.hasPointerCapture(r.pointerId)&&r.currentTarget.releasePointerCapture(r.pointerId))},ie=p.useCallback(r=>{if(r.deltaY===0)return;r.preventDefault();const l=r.currentTarget.getBoundingClientRect();ne.current={x:r.clientX-l.left,y:r.clientY-l.top,deltaY:r.deltaY},B()},[B]);p.useEffect(()=>{const r=d.current;if(r)return r.addEventListener("wheel",ie,{passive:!1}),()=>r.removeEventListener("wheel",ie)},[ie]);const he=r=>{const l=r.shiftKey?Be*4:Be;switch(r.key){case"Escape":if(_.kind!=="pressing"&&_.kind!=="dragging")return;r.preventDefault(),_.kind==="dragging"&&(N.current=!0),A(g=>oe(g,{kind:"cancel"}));return;case"0":r.preventDefault(),te();return;case"+":case"=":r.preventDefault(),S(g=>Ie(g,{x:c.width/2,y:c.height/2},g.k*Ue));return;case"-":case"_":r.preventDefault(),S(g=>Ie(g,{x:c.width/2,y:c.height/2},g.k/Ue));return;case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"ArrowDown":{r.preventDefault();const g=r.key==="ArrowLeft"?l:r.key==="ArrowRight"?-l:0,T=r.key==="ArrowUp"?l:r.key==="ArrowDown"?-l:0;S(U=>({...U,tx:U.tx+g,ty:U.ty+T}));return}}};return t.jsxs("div",{ref:d,"data-mesh-canvas":"",role:"group","aria-labelledby":M,tabIndex:0,onPointerDown:F,onPointerMove:G,onPointerUp:Y,onPointerCancel:r=>{_.kind==="dragging"&&(N.current=!0),A(l=>oe(l,{kind:"cancel"})),le(r)},"data-mesh-gesture":_.kind,"data-glass-well":"clear",onKeyDown:he,onDoubleClick:r=>{r.target===r.currentTarget&&te()},className:H("relative min-h-0 flex-1 overflow-hidden rounded-lg border border-hairline bg-sunken","[touch-action:none]","cursor-grab active:cursor-grabbing","focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent focus-visible:outline-offset-[-2px]"),children:[t.jsx("div",{"data-mesh-ground":"","aria-hidden":"true",className:"mesh-ground pointer-events-none absolute inset-0",style:{backgroundPosition:`${C.tx}px ${C.ty}px`}}),t.jsxs("div",{"data-mesh-world":"",className:"absolute top-0 left-0",style:{transform:`translate3d(${C.tx}px, ${C.ty}px, 0) scale(${C.k})`,transformOrigin:"0 0",width:I.bounds.width,height:I.bounds.height},children:[t.jsx(Us,{stacks:E,geometry:I}),t.jsx(Ss,{edges:e.edges,geometry:I,selectedDeviceId:i}),t.jsx("ul",{"aria-label":a("ui.mesh.mesh_canvas.networks"),className:"m-0 list-none p-0",children:e.networks.map(r=>{const l=I.networks.get(r.id);return l?t.jsx($s,{network:r,x:l.x,y:l.y,refused:x?.kind==="refused"&&_.kind==="dragging"&&_.target.kind==="network"&&_.target.networkId===r.id},r.id):null})}),t.jsx("ul",{"aria-label":a("ui.mesh.mesh_canvas.devices"),className:"m-0 list-none p-0",children:e.devices.map(r=>{const l=I.devices.get(r.id);return l?t.jsx(Ls,{device:r,deviceIds:e.devices.map(g=>g.id),x:l.x,y:l.y,nowSeconds:s,selected:r.id===i,sessions:u.get(r.id)??{rows:[],shown:[],hidden:0},sessionTotal:m.get(r.id)??r.sessionCount??0,dropState:L(r.id),movingSessionId:f,draggedSessionId:Cs(_),onOpen:v,onChipPointerDown:W,onChipClick:()=>{if(N.current){N.current=!1;return}v(r.id)},onShowAllSessions:R},r.id):null})})]}),_.kind==="dragging"&&t.jsx("div",{"data-mesh-ghost":"","aria-hidden":"true",className:"pointer-events-none absolute z-10 max-w-40 truncate rounded-sm border border-ink-dim bg-surface px-1.5 py-0.5 text-meta text-ink",style:{left:$.x,top:$.y},children:_.payload.session.name||"untitled"}),_.kind==="dragging"&&se&&t.jsx("div",{"data-mesh-indicator":"",className:H("pointer-events-none absolute z-10 rounded-sm border bg-surface px-2 py-1 text-meta",x?.kind==="refused"?"border-warning text-warning":"border-control text-ink"),style:{left:$.x,maxWidth:Math.max(160,c.width-$.x-12),...$.y>c.height*.6?{bottom:Math.max(12,c.height-$.y+8)}:{top:$.y+24}},children:se})]})};function Vs(e,n,s,i){const u=s.locality==="local"?n:s.owner_device,m=[],f=e.map(o=>o.id);for(const o of e){if(o.id===u)continue;if(o.id===n){m.push({deviceId:o.id,label:i,verb:a("ui.mesh.mesh_card.recall_to_this_device"),keepVerb:a("ui.mesh.mesh_card.copy_here_leave_it_there")});continue}const v=re(o,f,!0);m.push({deviceId:o.id,label:v,verb:a("ui.mesh.mesh_card.move_to",{device:v}),keepVerb:a("ui.mesh.mesh_card.copy_to",{device:v})})}return m}function Gs(e,n,s){return Vs(e.devices,e.selfDeviceId,n,s)}function lt(e,n,s){const i=Gs(e,n,s),u={selfDeviceId:e.selfDeviceId,devices:new Map(e.devices.map(o=>[o.id,o])),networks:new Map(e.networks.map(o=>[o.id,o]))},m=n.locality==="local"?e.selfDeviceId??"":n.owner_device,f=u.devices.get(m);return i.map(o=>{const v=be({session:n,ownerDeviceId:m,ownerLabel:f?re(f,e.devices.map(y=>y.id),!0):n.owner_device_name},{kind:"device",deviceId:o.deviceId},u);return{...o,refused:v.kind==="refused"&&v.code!=="busy"?v.sentence:null}})}const ot=({session:e,destinations:n,disabled:s,onChoose:i,onOpenChange:u,trigger:m,triggerLabel:f})=>(K(),t.jsxs(_t,{onOpenChange:u,children:[t.jsx(kt,{asChild:!0,children:t.jsx("button",{type:"button","aria-label":f,"data-mesh-session-menu":e.id,disabled:s||n.length===0,className:"rounded-sm focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent focus-visible:outline-offset-2 disabled:text-ink-disabled",children:m})}),t.jsxs(yt,{align:"start",className:"min-w-56",children:[t.jsx(jt,{children:ue(e)}),t.jsx(Pe,{}),n.map(o=>t.jsx($e,{"data-mesh-move-to":o.deviceId,disabled:!!o.refused,title:o.refused??void 0,onSelect:()=>i(o,!1),children:o.verb},o.deviceId)),t.jsx(Pe,{}),n.map(o=>t.jsx($e,{"data-mesh-copy-to":o.deviceId,disabled:!!o.refused,title:o.refused??void 0,onSelect:()=>i(o,!0),children:o.keepVerb},`keep-${o.deviceId}`))]})]})),Xs=({device:e,deviceIds:n,sessions:s,sessionTotal:i,nowSeconds:u,destinationsFor:m,movingSessionId:f,canMove:o,canInvite:v,onClose:y,onMove:w,onShowInList:R,onInvite:M,onRemoveMember:d})=>{K();const c=ce(e),h=Xe(e),C=e.reachable?[]:e.attempts??[];p.useEffect(()=>{const b=P=>{P.key!=="Escape"||P.defaultPrevented||P.target?.closest('[role="menu"],[role="dialog"]')||(document.querySelector(`[data-mesh-device-open="${e.id}"]`)?.focus(),y())};return window.addEventListener("keydown",b),()=>window.removeEventListener("keydown",b)},[e.id,y]);const S=e.sessionCount===null?et(null):a("ui.mesh.mesh_card.conversation_count",{count:e.sessionCount}),D=e.suspect?Ze():[S,fe(c)].filter(Boolean).join(" · "),N=i>s.rows.length?a("ui.mesh.mesh_card.shown_of",{shown:s.rows.length,total:i}):`${s.rows.length}`;return t.jsxs("aside",{"aria-label":a("ui.mesh.mesh_card.device_details",{device:re(e)}),"data-mesh-panel":e.id,"data-glass-block":"",className:"flex w-80 shrink-0 flex-col gap-3 overflow-y-auto rounded-md border border-hairline bg-surface p-4",children:[t.jsxs("header",{className:"flex flex-col gap-1",children:[t.jsx(ee,{size:"sm",variant:"ghost",className:"w-fit self-end","data-mesh-panel-close":"",onClick:y,children:a("ui.mesh.mesh_actions.close")}),t.jsx("h2",{className:"text-body-sm text-ink",children:t.jsx(De,{deviceId:e.id,deviceIds:n,name:e.name,compact:!0})}),t.jsxs("p",{className:"flex items-center gap-1.5 text-meta text-ink-muted",children:[e.suspect&&t.jsx(Me,{"aria-hidden":"true",className:"size-3.5 text-danger"}),!e.suspect&&c==="unanswered"&&t.jsx(bt,{"aria-hidden":"true",className:"size-3.5 text-warning"}),D]})]}),t.jsx(pe,{}),t.jsxs("section",{className:"flex flex-col gap-2",children:[t.jsx("h3",{className:"text-meta text-ink-dim",children:a("ui.mesh.mesh_card.memberships")}),t.jsx("ul",{className:"m-0 flex list-none flex-col gap-2 p-0",children:e.memberships.map(b=>t.jsxs("li",{className:"flex flex-col gap-1",children:[t.jsxs("span",{className:"flex items-center gap-2 text-body-sm text-ink",children:[t.jsx(Ae,{"aria-hidden":"true",className:"size-3.5 text-ink-muted"}),b.networkName]}),t.jsxs("span",{className:"text-meta text-ink-dim",children:[b.role||"member",b.capabilities.length>0?` · ${b.capabilities.join(", ")}`:""]}),v&&t.jsxs(ee,{size:"sm",variant:"ghost",className:"w-fit","data-mesh-remove-member":`${b.networkId}:${e.id}`,onClick:()=>d(e,b.networkId),children:[a("ui.mesh.mesh_card.remove_from"),b.networkName,"…"]})]},b.networkId))}),v&&t.jsx(ee,{size:"sm",variant:"secondary",className:"w-fit","data-mesh-invite":e.id,onClick:()=>M(e),children:a("ui.mesh.mesh_actions.invite_to_a_network")})]}),t.jsx(pe,{}),t.jsxs("section",{className:"flex shrink-0 flex-col gap-2",children:[t.jsxs("h3",{className:"text-meta text-ink-dim",children:[a("ui.mesh.mesh_card.conversations"),t.jsxs("span",{className:"text-ink-disabled",children:["(",ce(e)!=="self"&&ce(e)!=="reached"?st(null):N,")"]})]}),_e(e,u)?t.jsx("p",{className:"text-meta text-warning",children:_e(e,u)}):s.rows.length===0?t.jsx("p",{className:"text-meta text-ink-dim",children:e.sessionCount===null?a("ui.mesh.mesh_card.this_device_did_not_report_its_conversations"):a("ui.mesh.mesh_card.no_conversations_here")}):t.jsx("ul",{className:"m-0 flex list-none flex-col gap-1 p-0",children:s.rows.map(b=>t.jsxs("li",{"data-mesh-panel-session":b.id,className:H("flex items-center gap-2 rounded-sm px-2 py-1","border border-hairline bg-elevated",f===b.id&&"border-control"),children:[t.jsx("span",{className:"min-w-0 flex-1 truncate text-body-sm text-ink",title:ue(b),children:ue(b)}),t.jsx("span",{className:"shrink-0 text-meta text-ink-dim",children:rt(b,re(e,n,!0),ce(e))}),f===b.id?t.jsx("span",{className:"shrink-0 text-meta text-ink-muted",children:a("ui.mesh.mesh_card.moving")}):t.jsx(ot,{session:b,destinations:m(b),disabled:!o,onChoose:(P,E)=>w(b,P,E),trigger:t.jsx(nt,{"aria-hidden":"true",className:"size-4"}),triggerLabel:a("ui.mesh.mesh_card.move_conversation",{conversation:ue(b)})})]},b.id))})]}),t.jsx(pe,{}),t.jsxs("section",{className:"flex flex-col gap-2",children:[t.jsx("h3",{className:"text-meta text-ink-dim",children:a("ui.mesh.mesh_card.network_addresses")}),e.endpoints.length===0?t.jsx("p",{className:"text-meta text-ink-dim",children:a("ui.mesh.mesh_card.no_address_published")}):t.jsx("ul",{className:"m-0 flex list-none flex-col gap-1 p-0",children:e.endpoints.map(b=>t.jsxs("li",{className:"flex items-baseline justify-between gap-2",children:[t.jsx("span",{className:"min-w-0 truncate font-mono text-body-sm text-ink",children:b}),t.jsx("span",{className:"shrink-0 text-meta text-ink-dim",children:a("ui.mesh.mesh_card.advertised")})]},b))})]}),t.jsx(pe,{}),t.jsxs("section",{className:"flex flex-col gap-2",children:[t.jsx("h3",{className:"text-meta text-ink-dim",children:a("ui.mesh.mesh_card.status")}),t.jsxs("dl",{className:"m-0 flex flex-col gap-1",children:[t.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[t.jsx("dt",{className:"text-meta text-ink-dim",children:a("ui.mesh.mesh_card.reach")}),t.jsx("dd",{className:"m-0 text-body-sm text-ink",children:fe(c)})]}),t.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[t.jsx("dt",{className:"text-meta text-ink-dim",children:a("ui.mesh.mesh_card.last_status_frame")}),t.jsx("dd",{className:"m-0 text-body-sm text-ink",children:e.lastSeenAt===null?a("ui.mesh.mesh_card.never"):Jt(u-e.lastSeenAt)})]})]}),!e.reachable&&(h!==""||C.length>0)&&t.jsxs("div",{className:"flex flex-col gap-1",children:[h&&t.jsx("p",{className:"m-0 text-meta text-warning",children:h}),e.linkState==="handshake_refused"&&t.jsx("p",{className:"m-0 text-meta text-ink-dim",children:a("ui.mesh.mesh_reach.handshake_refused_hint")}),C.length>0&&t.jsxs(t.Fragment,{children:[t.jsx("span",{id:`mesh-attempts-label-${e.id}`,className:"text-meta text-ink-dim",children:a("ui.mesh.mesh_reach.addresses_tried")}),t.jsx("ul",{role:"list","aria-labelledby":`mesh-attempts-label-${e.id}`,className:"m-0 flex list-none flex-col gap-0.5 p-0",children:C.map((b,P)=>{const E=Je(b.detail);return t.jsxs("li",{"data-mesh-attempt":b.endpoint,className:"flex items-baseline justify-between gap-2",children:[t.jsx("span",{className:"min-w-0 truncate font-mono text-meta text-ink",children:b.endpoint}),t.jsx("span",{className:"shrink-0 text-meta text-ink-dim",children:E})]},`${b.endpoint}:${P}`)})})]})]}),!h&&C.length===0&&e.reason&&t.jsx("p",{className:"text-meta text-warning",children:e.reason})]}),t.jsx(pe,{}),t.jsx(ee,{size:"sm",variant:"ghost",className:"w-fit","data-mesh-show-in-list":e.id,onClick:()=>R(e.id),children:a("ui.mesh.mesh_card.show_in_list")})]})},Zs=["name","chats","state"],Js={get name(){return a("ui.mesh.mesh_list.name")},get chats(){return a("ui.mesh.mesh_list.sort_conversations")},get state(){return a("ui.mesh.mesh_list.state")}},Ye={suspect:0,relay_down:1,handshake_refused:2,unreachable:3,self:4,reachable:5};function Qs(e,n){const s=[...e];switch(n){case"chats":return s.sort((i,u)=>(u.sessionCount??-1)-(i.sessionCount??-1)||i.label.localeCompare(u.label)),s;case"state":return s.sort((i,u)=>Ye[i.state]-Ye[u.state]||i.label.localeCompare(u.label)),s;default:return s.sort((i,u)=>i.label.localeCompare(u.label))}}const Ke=8;function ea(e,n){if(e.locality==="local")return e.live_state||"here";const s=e.owner_device_name||n,i=e.live_state?` · ${e.live_state}`:"";return e.reachable?a("ui.mesh.mesh_list.on_device_state",{device:s,state:i}):a("ui.mesh.mesh_list.on_device_no_answer",{device:s})}const ta=({graph:e,nowSeconds:n,selectedDeviceId:s,sessions:i,selfLabel:u,canMove:m,onSelect:f,onMove:o,onInvite:v,onRemove:y})=>{K();const[w,R]=p.useState("name"),M=p.useMemo(()=>e.networks.map(d=>({network:d,members:Qs(e.devices.filter(c=>c.memberships.some(h=>h.networkId===d.id)),w)})),[e,w]);return t.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto pe-1",children:[t.jsxs("fieldset",{className:"m-0 w-fit border-0 p-0",children:[t.jsx("legend",{className:"sr-only",children:a("ui.mesh.mesh_list.sort_devices_by")}),t.jsx("div",{"data-glass-well":"",className:"flex gap-0.5 rounded-md bg-sunken p-0.5",children:Zs.map(d=>t.jsx("button",{type:"button","aria-pressed":w===d,onClick:()=>R(d),className:H("h-6 rounded-sm px-3 text-body-sm text-ink-muted transition-colors duration-fast ease-out-quart","hover:text-ink","focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent focus-visible:outline-offset-2",w===d&&"bg-surface text-ink"),children:Js[d]},d))})]}),M.map(({network:d,members:c})=>t.jsxs("section",{"data-mesh-network-group":d.id,className:"flex flex-col gap-2",children:[t.jsxs("h2",{className:"flex flex-wrap items-baseline gap-2 text-body-sm text-ink",title:a("ui.mesh.mesh_list.epoch",{epoch:d.epoch}),children:[d.label,t.jsxs("span",{className:"text-meta text-ink-dim",children:[d.trust," ·"," ",a("ui.mesh.mesh_graph.device_count",{count:d.memberCount}),d.revokedCount>0?t.jsxs(t.Fragment,{children:[" · ",a("ui.mesh.mesh_list.revoked_count",{count:d.revokedCount})]}):null]})]}),t.jsx("ul",{className:"m-0 flex list-none flex-col gap-1 p-0",children:c.map(h=>{const C=h.memberships.find(j=>j.networkId===d.id),S=h.id===s,D=i.get(h.id),N=D?.rows??[],b=D?at(D,h.sessionCount):h.sessionCount??0,P=ce(h),E=Xe(h),I=h.reachable?[]:h.attempts??[];return t.jsxs("li",{"data-mesh-device-row":h.id,"data-mesh-state":h.state,"aria-current":S?"true":void 0,className:H("flex flex-col gap-1 rounded-md px-3 py-2","border border-hairline bg-surface",S&&"border-ink bg-row-selected"),children:[t.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-3 gap-y-1",children:[t.jsx("button",{type:"button","data-mesh-device-open":h.id,onClick:()=>f(h.id),className:H("min-w-0 flex-1 text-start text-body-sm text-ink","hover:text-ink-muted","focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent focus-visible:outline-offset-2"),children:t.jsx(De,{deviceId:h.id,name:h.name})}),t.jsxs("span",{className:H("flex shrink-0 items-center gap-1 text-meta",Ge[P]),"data-mesh-reach":P,children:[h.suspect&&t.jsx(Me,{"aria-hidden":"true",className:"size-3.5 shrink-0 text-danger"}),h.suspect?fe(P):tt(h,n),h.suspect&&t.jsx("span",{className:"shrink-0 rounded-sm border border-danger px-1 text-danger",children:Ze()})]}),t.jsxs("span",{className:"shrink-0 text-meta text-ink-dim",children:[C?.role?`${C.role} · `:"",a("ui.mesh.mesh_list.member")]})]}),(E!==""||I.length>0)&&!h.reachable&&t.jsxs("div",{className:"flex flex-col gap-0.5",children:[E&&t.jsx("span",{className:"text-meta text-warning",children:E}),I.map((j,_)=>{const A=Je(j.detail);return t.jsx("span",{"data-mesh-attempt":j.endpoint,className:"text-meta text-ink-dim",children:A?`${j.endpoint} — ${A}`:j.endpoint},`${j.endpoint}:${_}`)})]}),_e(h,n)?t.jsxs("span",{className:"text-meta text-warning",children:[a("ui.mesh.mesh_card.conversations")," (",st(null),") ·"," ",_e(h,n)]}):N.length>0?t.jsxs(t.Fragment,{children:[t.jsx(pe,{className:"my-1"}),t.jsx("ul",{className:"m-0 flex list-none flex-col gap-0.5 p-0",children:N.slice(0,Ke).map(j=>t.jsxs("li",{"data-mesh-row-session":j.id,className:"flex items-center gap-2 py-0.5",children:[t.jsx("span",{className:"min-w-0 flex-1 truncate text-meta text-ink-muted",children:j.name||j.id}),t.jsx("span",{className:"shrink-0 text-meta text-ink-dim",children:ea(j,u)}),t.jsx(ot,{session:j,destinations:lt(e,j,u),disabled:!m,onChoose:(_,A)=>o(j,_,A),trigger:t.jsx(nt,{"aria-hidden":"true",className:"size-3.5"}),triggerLabel:a("ui.mesh.mesh_list.move_conversation",{conversation:j.name||j.id})})]},j.id))}),b>N.slice(0,Ke).length&&t.jsx("button",{type:"button",onClick:()=>f(h.id),className:"w-fit text-meta text-ink-dim hover:text-ink",children:a("ui.mesh.mesh_list.show_all_panel",{count:b})})]}):t.jsx("span",{className:"text-meta text-ink-dim",children:a("ui.mesh.mesh_list.conversation_count",{count:b})}),(C||h.state!=="self")&&t.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[t.jsx(ee,{size:"sm",variant:"ghost","data-mesh-invite":h.id,onClick:()=>v({deviceId:h.id,deviceName:h.name}),children:a("ui.mesh.mesh_actions.invite_to_a_network")}),C&&t.jsxs(ee,{size:"sm",variant:"ghost","data-mesh-remove-member":`${d.id}:${h.id}`,onClick:()=>y({networkId:d.id,networkLabel:d.label,deviceId:h.id,deviceName:h.name}),children:[a("ui.mesh.mesh_card.remove_from"),d.label,"…"]})]})]},h.id)})})]},d.id)),e.unmatchedPeers.length>0&&t.jsxs("p",{className:"text-meta text-warning",children:[a("ui.mesh.mesh_graph.device_count",{count:e.unmatchedPeers.length})," ",a("ui.mesh.mesh_list.answered_the_peer_read_but_is_in")]})]})},sa=({revoked:e})=>{if(e.length===0)return null;const n=a("ui.mesh.mesh_list.revoked_count",{count:e.length});return t.jsx(ke,{className:"contents",chevron:"trailing",chevronClassName:"text-ink-dim",rowClassName:"min-h-auto py-0",triggerClassName:"inline-flex w-auto items-center gap-1 align-baseline text-meta text-ink-dim hover:text-ink",triggerData:{"data-mesh-revoked-toggle":""},triggerLabel:a("ui.mesh.mesh_list.revoked_toggle_label"),summary:t.jsxs(t.Fragment,{children:[t.jsx("span",{"aria-hidden":"true",className:"inline-block whitespace-pre",children:" · "}),n]}),children:t.jsx("ul",{"data-mesh-revoked":"",className:"m-0 flex list-none flex-col gap-1 p-0",children:e.map(s=>t.jsxs("li",{"data-mesh-revoked-member":s.deviceId,className:"flex flex-wrap items-baseline gap-x-2 text-meta text-ink-dim",children:[t.jsx("span",{children:s.networkName}),t.jsx("span",{className:"font-mono text-body-sm text-ink",children:s.deviceId}),t.jsx("span",{className:"text-body-sm text-ink-muted",children:s.label}),t.jsxs("span",{children:[s.role?`${s.role} · `:"",a("ui.mesh.mesh_graph.revoked_membership")]})]},`${s.networkId}:${s.deviceId}`))})})},aa=["canvas","list"],na={get canvas(){return a("ui.mesh.mesh_page.canvas")},get list(){return a("ui.mesh.mesh_page.list")}},ia=({state:e,initialPresentation:n="canvas",graph:s,nowSeconds:i,checking:u,staleError:m,onRetry:f,approvals:o,sessions:v,sessionError:y,selfLabel:w,movingSessionId:R,canMove:M,pendingMove:d,onAskMove:c,onDropRefused:h,onChooseMove:C,onCancelMove:S,moveBusy:D,moveReport:N,onDismissReport:b,onWaitForIdle:P,onUndoCopy:E,invite:I,onOpenInvite:j,onInvite:_,onCloseInvite:A,inviteBusy:Z,inviteReceipt:V,inviteRefusal:x,remove:L,onOpenRemove:W,onRemove:G,onCloseRemove:Y,removeBusy:te,removeRefusal:$,removed:se})=>{K();const[q,ne]=p.useState(n),[k,O]=p.useState(null),z=s?Qt(s):"",B="mesh-summary",F=es(s),J=ts(s,v,s?.selfDeviceId??null),le=p.useMemo(()=>{const l=new Map;for(const g of s?.devices??[]){const T=J.byDevice.get(g.id);l.set(g.id,T?at(T,g.sessionCount):g.sessionCount??0)}return l},[s,J]),ie=p.useCallback(l=>{O(l)},[]),he=s?s.devices.find(l=>l.id===k)??null:null,r=p.useCallback((l,g,T)=>{if(!s)return null;const U={selfDeviceId:s.selfDeviceId,devices:new Map(s.devices.map(Q=>[Q.id,Q])),networks:new Map(s.networks.map(Q=>[Q.id,Q]))},ae=l.locality==="local"?s.selfDeviceId??"":l.owner_device,Re=U.devices.get(ae),X=be({session:l,ownerDeviceId:ae,ownerLabel:Re?re(Re,s.devices.map(Q=>Q.id),!0):l.owner_device_name},{kind:"device",deviceId:g.deviceId},U);if(X.kind==="refused")return h({code:X.code,sentence:X.sentence,reach:X.reach,remedy:X.remedy,plan:X.plan??null}),null;if(X.kind==="none")return null;const Ee=T?X.alternatives.find(Q=>Q.keep)??X.plan:X.plan,dt=[X.plan,...X.alternatives].filter(Q=>Q.keep!==Ee.keep),ct={plan:Ee,alternatives:dt,risky:X.risky};c(ct)},[s,c,h]);return t.jsxs("div",{className:"flex h-full min-h-0 flex-col gap-6 overflow-y-auto p-6",children:[t.jsx(gt,{title:a("ui.mesh.mesh_page.mesh"),icon:Ae,subtitle:a("ui.mesh.mesh_page.devices_this_app_is_paired_with_and"),children:t.jsxs("div",{className:"flex items-center gap-4",children:[u&&t.jsx("output",{className:"text-meta text-ink-dim",children:a("ui.mesh.mesh_page.checking")}),(e.kind==="ready"||e.kind==="loading")&&t.jsxs("fieldset",{className:"m-0 w-fit border-0 p-0",children:[t.jsx("legend",{className:"sr-only",children:a("ui.mesh.mesh_page.presentation")}),t.jsx("div",{"data-glass-well":"",className:"flex gap-0.5 rounded-md bg-sunken p-0.5",children:aa.map(l=>t.jsx("button",{type:"button","data-mesh-presentation":l,"aria-pressed":q===l,disabled:e.kind!=="ready",onClick:()=>ne(l),className:H("h-6 rounded-sm px-3 text-body-sm text-ink-muted transition-colors duration-fast ease-out-quart","hover:text-ink","focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent focus-visible:outline-offset-2","disabled:text-ink-dim disabled:hover:text-ink-dim",q===l&&"bg-surface text-ink"),children:na[l]},l))})]})]})}),t.jsx(Ns,{rows:o.rows,error:o.error,pending:o.pending,refusal:o.decisionRefusal,onDecide:o.onDecide,onRetry:o.onRetry,nowSeconds:o.nowSeconds,credentialApprovals:o.credentialApprovals,networkNames:new Map((s?.networks??[]).map(l=>[l.id,l.label]))}),e.kind==="loading"&&t.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-3",children:[t.jsx(Le,{className:"h-4 w-64"}),t.jsx(Le,{className:"min-h-40 w-full flex-1"})]}),e.kind==="error"&&t.jsxs(we,{variant:"warning",className:"flex-col items-start gap-2",children:[t.jsx("p",{children:e.message}),t.jsx(ee,{variant:"secondary",size:"sm",onClick:f,className:"w-fit",children:a("ui.mesh.mesh_approvals_tray.ask_again")})]}),e.kind==="empty"&&t.jsx("div",{"data-glass-block":"",className:"flex min-h-0 flex-1 items-center justify-center rounded-lg border border-hairline bg-surface p-6",children:t.jsxs("div",{className:"flex flex-col items-start gap-3",children:[t.jsx("h2",{className:"text-heading text-ink",children:a("ui.mesh.mesh_page.no_network_on_this_device")}),t.jsx("p",{className:"max-w-140 text-body-sm text-ink-muted",children:a("ui.mesh.mesh_page.this_device_is_not_in_any_network")}),t.jsx("code",{className:"rounded-sm bg-sunken px-2 py-1 font-mono text-meta text-ink",children:"lop network init <name>"}),t.jsx("p",{className:"text-meta text-ink-dim",children:a("ui.mesh.mesh_page.a_network_appears_here_once_this_device")})]})}),e.kind==="ready"&&s&&t.jsx(t.Fragment,{children:t.jsxs("div",{className:"flex min-h-[22rem] flex-1 gap-4",children:[t.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col gap-3",children:[t.jsxs("div",{id:B,className:"text-meta text-ink-muted","data-mesh-summary":"",children:[t.jsx("span",{children:z}),t.jsx(sa,{revoked:s.revoked})]}),m&&t.jsx(we,{variant:"warning",children:t.jsx("p",{children:m})}),y&&t.jsx(we,{variant:"warning",children:t.jsx("p",{children:y})}),N&&t.jsx(ss,{receipt:N.kind==="moved"?{verb:N.verb,detail:N.detail,undo:N.undo}:null,refusal:N.kind==="refused"?N.refusal:null,canWait:N.kind==="refused"&&N.plan!==null,onWait:P,onRecheck:f,onUndo:E,onDismiss:b,pending:D}),q==="canvas"?t.jsx(Ks,{graph:s,slots:F,nowSeconds:i,selectedDeviceId:k,sessions:J.byDevice,sessionTotals:le,movingSessionId:R,canMove:M,onOpenDevice:ie,onAskMove:c,onDropRefused:h,onShowAllSessions:ie,summaryId:B}):t.jsx(ta,{graph:s,nowSeconds:i,selectedDeviceId:k,sessions:J.byDevice,selfLabel:w,canMove:M,onSelect:ie,onMove:r,onInvite:j,onRemove:W})]}),he&&t.jsx(Xs,{device:he,deviceIds:s.devices.map(l=>l.id),sessions:J.byDevice.get(he.id)??{rows:[],shown:[],hidden:0},sessionTotal:le.get(he.id)??0,nowSeconds:i,canMove:M,canInvite:e.kind==="ready",movingSessionId:R,destinationsFor:l=>lt(s,l,w),onClose:()=>O(null),onMove:r,onInvite:l=>j({deviceId:l.id,deviceName:l.name}),onRemoveMember:(l,g)=>{const T=s.networks.find(U=>U.id===g);W({networkId:g,networkLabel:T?.label??g,deviceId:l.id,deviceName:l.name})},onShowInList:l=>{ie(l),ne("list")}})]})}),t.jsx(as,{open:d!==null,plan:d?.plan??ra,alternatives:d?.alternatives??[],risky:d?.risky??!1,busy:D,onCancel:S,onChoose:C}),I&&t.jsx(ns,{open:I.open,options:I.options,deviceId:I.deviceId,deviceName:I.deviceName,onClose:A,onInvite:_,pending:Z,receipt:V,refusal:x}),L&&t.jsx(is,{open:L.open,networkLabel:L.networkLabel,deviceId:L.deviceId,deviceName:L.deviceName,onClose:Y,onConfirm:G,pending:te,refusal:$,removed:se})]})},ra={sessionId:"",to:"",keep:!1,verb:"",waitS:0,lost:null},fa=({initialPresentation:e})=>{K();const n=xt(),s=ge(n.data,"peers")==="enabled",i=ge(n.data,"session_transfer")==="enabled",u=rs(s,{stamp:()=>je.getState().beginAnswer()}),m=ls(s),f=os(s,{poll:!1,stamp:()=>je.getState().beginAnswer()}),o=p.useMemo(()=>({peers:u,networks:m}),[u,m]),v=ds(o),y=cs(o),w=ms(),R=ge(n.data,"approvals")==="enabled",M=us(s&&R,{poll:!1}),d=hs(),c=ge(n.data,"credential_approvals")==="enabled",h=d.isError?{approvalId:d.variables?.approvalId??null,submittedAt:d.submittedAt,...ps(d.error)}:null,C=p.useMemo(()=>Math.floor((M.dataUpdatedAt||Date.now())/1e3),[M.dataUpdatedAt]),S=je(k=>k.settlePlacement),D=xs(),N=fs(),[b,P]=p.useState(null),[E,I]=p.useState(null),[j,_]=p.useState(null),[A,Z]=p.useState(null),[V,x]=p.useState(null),[L,W]=p.useState(null),[G,Y]=p.useState(null),te=p.useMemo(()=>{const k=Math.max(u.dataUpdatedAt,m.dataUpdatedAt);return Math.floor((k||Date.now())/1e3)},[u.dataUpdatedAt,m.dataUpdatedAt]),$=p.useCallback(()=>{u.refetch(),m.refetch(),f.refetch()},[u,m,f]),se=p.useCallback((k,O)=>{P(null);const z={sessionId:k.sessionId,to:k.to,keep:k.keep,waitS:O??k.waitS};w.mutate(z,{onSuccess:B=>{if(B.kind==="moved"){const{receipt:F}=B;S(k.sessionId,F);const J=F.locality==="local"?a("ui.mesh.mesh_drop.this_device"):y?.devices.find(le=>le.id===F.owner_device)?.label??F.owner_device;I({kind:"moved",verb:F.mode==="keep"?a("ui.mesh.mesh_page.copied"):a("ui.mesh.mesh_page.moved"),detail:F.mode==="keep"?a("ui.mesh.mesh_page.copy_receipt",{destination:J,suffix:F.new_session_id.slice(-6)}):a("ui.mesh.mesh_page.move_receipt",{destination:J,retirement:F.source_retired?a("ui.mesh.mesh_page.the_copy_here_is_gone"):""}),undo:F.mode==="keep"?{sessionId:F.new_session_id,to:"local",keep:!1,verb:a("ui.mesh.mesh_page.bring_copy_back",{device:J}),waitS:0,lost:gs(J,a("ui.mesh.mesh_drop.this_device"))}:null});return}I({kind:"refused",refusal:B.refusal,plan:k})},onError:()=>{I({kind:"refused",refusal:{code:"move_failed",sentence:a("ui.mesh.mesh_page.the_move_could_not_be_sent_nothing"),status:null,unconfirmed:!1},plan:k})}})},[y,w,S]),q=p.useMemo(()=>{if(!y)return[];const k=j?.deviceId,O=k?y.devices.find(z=>z.id===k):void 0;return y.networks.filter(z=>O?!O.memberships.some(B=>B.networkId===z.id):!0).map(z=>({id:z.id,label:z.label}))},[y,j]);if(!s)return t.jsx(ft,{to:"/chat",replace:!0});const ne=v.kind==="ready"?u.error?xe(u.error):m.error?xe(m.error):null:null;return t.jsx(ia,{initialPresentation:e,state:v,graph:y,nowSeconds:te,checking:u.isFetching||m.isFetching,staleError:ne,onRetry:$,approvals:{rows:M.data??[],error:M.isError?vs(M.error):null,pending:d.isPending?d.variables??null:null,decisionRefusal:h,credentialApprovals:c,onDecide:(k,O)=>{const z=M.data?.find(F=>F.approvalId===k),B=z?bs(z,O,{credentialApprovals:c},h?.approvalId===k?h.retryable:void 0):null;B&&d.mutate({approvalId:k,decision:O,request:B})},onRetry:()=>void M.refetch(),nowSeconds:C},sessions:f.data?.rows??[],movingSessionId:w.isPending?w.variables?.sessionId??null:null,sessionError:f.isError?xe(f.error):null,selfLabel:y?.devices.find(k=>k.state==="self")?.label??a("ui.mesh.mesh_drop.this_device"),canMove:i,pendingMove:b,onAskMove:P,onDropRefused:k=>I({kind:"refused",refusal:{code:k.code,sentence:k.sentence,reach:k.reach,status:null,unconfirmed:!1},plan:k.plan}),onChooseMove:k=>se(k),onCancelMove:()=>P(null),moveBusy:w.isPending,moveReport:E,onDismissReport:()=>I(null),onWaitForIdle:()=>{E?.kind!=="refused"||!E.plan||se(E.plan,la)},onUndoCopy:()=>{E?.kind!=="moved"||!E.undo||P({plan:E.undo,alternatives:[],risky:!1})},invite:j===null?null:{open:!0,deviceId:j.deviceId,deviceName:j.deviceName,options:q},onOpenInvite:k=>{Z(null),x(null),_(k)},onInvite:k=>{D.mutate(k,{onSuccess:O=>Z(O),onError:O=>x({code:"invite_refused",sentence:xe(O),status:null,unconfirmed:!1})})},onCloseInvite:()=>_(null),inviteBusy:D.isPending,inviteReceipt:A,inviteRefusal:V,remove:L===null?null:{open:!0,networkId:L.networkId,networkLabel:L.networkLabel,deviceId:L.deviceId,deviceName:L.deviceName},onOpenRemove:k=>{Y(null),W(k)},onRemove:k=>{L&&N.mutate({networkId:L.networkId,deviceId:L.deviceId,confirm:k},{onSuccess:O=>Y(O)})},onCloseRemove:()=>W(null),removeBusy:N.isPending,removeRefusal:N.isError?{code:"remove_refused",sentence:xe(N.error),status:null,unconfirmed:!1}:null,removed:G})},la=300;export{fa as MeshPage,ia as MeshSurface,fa as default};
1
+ import{r as p,j as t,c as H}from"./index-CW7JpbBx.js";import{H as Ve,I as mt,J as ut,K as ce,L as ht,R as pt,M as fe,N as Ge,O as re,Q as Xe,T as Ze,V as Je,a as xt,q as ge,w as je,W as ft}from"./path-utils-D8EGhun0.js";import{P as gt}from"./page-header-C_NLT5l1.js";import{u as K,B as ee,w as vt,G as bt,s as pe,D as _t,b as kt,d as yt,H as jt,I as Pe,e as $e,f as Le,A as we}from"./error-boundary-OwA_uKkY.js";import{t as a}from"./messages-DjcNNMrL.js";import{U as de,V as me,W as Te,X as wt,Y as Qe,Z as Nt,_ as It,$ as Ct,a0 as St,a1 as Mt,a2 as At,a3 as Dt,a4 as Rt,a5 as Et,a6 as Pt,a7 as $t,a8 as Lt,a9 as Tt,aa as Ot,ab as Ht,ac as Wt,ad as qt,ae as zt,af as Ft,ag as Se,ah as Bt,ai as Ut,aj as Me,ak as et,al as tt,am as Yt,an as ve,ao as Ne,ap as Kt,aq as Vt,ar as be,as as Oe,at as Gt,au as Xt,av as Ie,aw as Zt,ax as st,ay as _e,az as Jt,aA as at,aB as Qt,aC as es,aD as ts,aE as ss,aF as as,aG as ns,aH as is,aI as rs,aJ as ls,aK as os,aL as ds,aM as cs,aN as ms,aO as us,aP as hs,aQ as ps,aR as xs,aS as fs,aT as gs,aU as xe,aV as vs,aW as bs}from"./index-ClKLYxFA.js";import{bB as ke,bC as _s,bD as Ae,bE as ks,a2 as nt}from"./conversation-input-sync-CA-NlH9A.js";import"./console-mirror-1z96hWwG.js";function ys(e){return e==="failed"?"text-danger":de(e)?"text-ink-muted":"text-ink-dim"}function js(e){return e==="failed"?a("ui.mesh.mesh_approvals_tray.abandon"):a("ui.mesh.mesh_approvals_tray.stop")}function ws(e){switch(e){case"requested":return[{term:a("ui.mesh.mesh_approvals_tray.signing"),text:a("ui.mesh.mesh_approvals_tray.approving_signs_with_this_machine_s_operator")}];case"approved":return[{term:a("ui.mesh.mesh_approvals_tray.next"),text:a("ui.mesh.mesh_approvals_tray.an_agent_runs_the_install_and_connect")},{term:a("ui.mesh.mesh_approvals_tray.stop"),text:a("ui.mesh.mesh_approvals_tray.stopping_now_denies_the_request_nothing_has")}];case"connecting":return[{term:a("ui.mesh.mesh_approvals_tray.stop"),text:a("ui.mesh.mesh_approvals_tray.stopping_now_denies_the_request_the_runner")}];case"failed":return[{term:a("ui.mesh.mesh_approvals_tray.after_a_stop"),text:a("ui.mesh.mesh_approvals_tray.the_runner_stopped_before_it_finished_abandoning")}];default:return[]}}const Ns=({rows:e,error:n,pending:s,refusal:i,onDecide:u,onRetry:m,nowSeconds:f,networkNames:o,credentialApprovals:v=!1})=>{K();const y=s!==null,[w,R]=p.useState(""),M=p.useRef(null),d=i?JSON.stringify([i.approvalId,i.code,i.sentence]):null,c=p.useMemo(()=>e.filter(x=>de(x.state)||me(x)),[e]),h=p.useMemo(()=>e.filter(x=>!de(x.state)&&!me(x)),[e]),[C,S]=p.useState(!1),D=p.useRef(null),N=p.useRef(null),b=p.useRef(null),P=(x,L)=>{c.some(W=>W.approvalId===x&&W.kind==="credential")&&(b.current={id:x,origin:document.activeElement,rowAtStart:e.find(W=>W.approvalId===x),refusalSubmittedAtStart:i?.submittedAt??0}),u(x,L)};p.useLayoutEffect(()=>{const x=b.current;if(!x)return;const L=e.find(q=>q.approvalId===x.id);if(s)return;const W=i?.approvalId===x.id&&(i.submittedAt??0)>x.refusalSubmittedAtStart;if(L===x.rowAtStart&&!W)return;b.current=null;const G=c.find(q=>q.approvalId!==x.id),Y=G?D.current?.querySelector(`[data-tour-tag="mesh-approvals-live"] [data-approval-id="${CSS.escape(G.approvalId)}"] ${de(G.state)?'[data-tour-tag="mesh-approval-summary"]':'[data-tour-tag="mesh-approval-controls"] button:not(:disabled)'}`):null,te=(c.some(q=>q.approvalId===x.id)?D.current?.querySelector(`[data-approval-id="${CSS.escape(x.id)}"] [data-tour-tag="mesh-approval-refusal"]`):null)??Y??N.current?.querySelector("button"),$=i?D.current?.querySelector(`[data-approval-refusal-id="${CSS.escape(i.approvalId??"")}"]`)??null:null;Te({document,target:te??null,refusalTarget:$,origin:x.origin,allowFocus:!0,sentence:i?.sentence??""}).focused&&(M.current=d)},[e,s,i,c,d]),p.useLayoutEffect(()=>{if(!i||s){M.current=null,R("");return}if(M.current===d){R("");return}const x=D.current?.querySelector(`[data-approval-refusal-id="${CSS.escape(i.approvalId??"")}"]`)??null,L=Te({document,target:null,refusalTarget:x,origin:null,allowFocus:!1,sentence:i.sentence});L.focused&&(M.current=d),R(L.announcement)},[i,d,s,e]);const E=c.filter(x=>de(x.state)).length,I=c.filter(me).length,j=h.filter(x=>x.kind==="credential"&&x.state==="connected").length,_=h.some(x=>x.state==="failed"),A=h.filter(x=>x.state==="failed").length,Z=i!==null&&e.some(x=>x.approvalId===i.approvalId&&(de(x.state)||me(x)||C)),V=e.find(x=>x.approvalId===i?.approvalId);return c.length===0&&h.length===0&&!n&&!i?null:t.jsxs("section",{ref:D,"aria-label":a("ui.mesh.mesh_approvals_tray.approvals"),"data-tour-tag":"mesh-approvals-tray",className:"flex flex-col gap-3",children:[t.jsx("output",{"aria-live":"polite","aria-atomic":"true",className:"sr-only",children:a("ui.mesh.approval.result_status",{shared:j,attention:I})}),t.jsx("output",{"aria-live":"polite","aria-atomic":"true",className:"sr-only","data-tour-tag":"mesh-approval-announcement",children:t.jsx("bdi",{dir:"auto",children:w})}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx(wt,{"aria-hidden":"true",className:"size-4 text-ink-muted"}),t.jsx("h2",{className:"text-body-sm text-ink",children:a("ui.mesh.mesh_approvals_tray.approvals")}),E>0&&t.jsx("span",{className:"text-meta text-ink-dim",children:a("ui.mesh.mesh_approvals_tray.waiting_count",{count:E})}),I>0&&t.jsx("span",{className:"text-meta text-warning",children:a("ui.mesh.approval.needs_attention",{count:I})})]}),n&&t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("p",{className:"min-w-0 flex-1 text-meta text-ink-muted",children:n}),t.jsx(ee,{variant:"secondary",size:"sm",onClick:m,children:a("ui.mesh.mesh_approvals_tray.ask_again")})]}),c.length>0&&t.jsx("ul",{className:"flex flex-col divide-y divide-hairline","data-tour-tag":"mesh-approvals-live",children:c.map(x=>t.jsx(He,{row:x,pending:s?.approvalId===x.approvalId?s:null,busy:y,refusal:i?.approvalId===x.approvalId?i:null,onDecide:P,nowSeconds:f,networkNames:o,credentialApprovals:v},x.approvalId))}),i&&!Z&&t.jsx(it,{approvalId:i.approvalId??"",requestIsBackendSummary:V?Nt(V):!1,refusal:i,request:V?Qe(V):a("ui.mesh.approval.credential_title")}),h.length>0&&t.jsx("div",{ref:N,"data-tour-tag":"mesh-approvals-settled",children:t.jsx(ke,{open:C,onOpenChange:S,chevronClassName:"text-ink-dim",className:H(c.length>0&&"border-hairline border-t pt-3"),summary:t.jsxs("span",{className:"flex items-center gap-1.5 text-meta text-ink-muted",children:[a("ui.mesh.mesh_approvals_tray.settled_approvals"),t.jsxs("span",{className:"text-ink-dim",children:["(",h.length,")"]}),_&&t.jsx("span",{"aria-hidden":"true",className:"size-1.5 rounded-full bg-danger"}),j>0&&t.jsx("span",{className:"text-ink-muted",children:a("ui.mesh.approval.shared_count",{count:j})}),A>0&&t.jsx("span",{className:"text-danger",children:a("ui.mesh.mesh_approvals_tray.failed_count",{count:A})})]}),children:t.jsx("ul",{className:"flex flex-col divide-y divide-hairline","data-tour-tag":"mesh-approvals-records",children:h.map(x=>t.jsx(He,{row:x,pending:s?.approvalId===x.approvalId?s:null,busy:y,refusal:i?.approvalId===x.approvalId?i:null,onDecide:P,nowSeconds:f,networkNames:o,credentialApprovals:v},x.approvalId))})})})]})},He=({row:e,pending:n,busy:s,refusal:i,onDecide:u,nowSeconds:m,networkNames:f,credentialApprovals:o})=>{K();const v=de(e.state),y=It(e,i?.retryable),w=p.useId(),R=p.useId(),M=Qe(e),d=Ct(e,f),c=St(e,f),h=Mt(e),C=At(e),S=Dt(e),D=Rt(e.expiresAt,m,me(e)),N=e.kind==="credential"||e.kind==="unknown",b=N||e.canApproveHere===!1,P=b?[]:ws(e.state),E={credentialApprovals:o},I=Et(e,E),j=Pt(e.state),_=$t(e,E,i?.retryable),A=o?e.typed:void 0,Z=A?Lt(e):[],V=A?.disclosure?Tt(e):null,x=e.typed?.unprovenHuman===!0,L=e.kind==="credential"&&["approved","failed","connecting","connected"].includes(e.state),W=i?.sentence||(A?.applyOutcome?[A.applyOutcome.reason,A.applyOutcome.remedy].filter(Boolean).join(" "):""),G=i?.code||A?.applyOutcome?.code||A?.refusal,Y=Ot(e),te=(e.typed?.refusalMessage??"")||(e.typed?a("ui.mesh.approval.typed_review_unavailable"):e.approveRemedy||a("ui.mesh.approval.cli_review"));return t.jsxs("li",{className:"flex flex-col gap-2 py-3 first:pt-0 last:pb-0","data-tour-tag":"mesh-approval-card","data-approval-id":e.approvalId,children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("span",{className:H("text-meta",me(e)?"text-warning":ys(e.state)),children:y?a("ui.mesh.approval.could_not_apply"):e.kind==="credential"&&e.state==="connected"?a("ui.mesh.approval.shared"):e.kind==="credential"&&(e.state==="approved"||e.state==="failed")?a("ui.mesh.approval.approved_not_applied"):Ht(e.state)}),t.jsx("div",{className:"grow"}),!y&&(v||me(e))&&D&&t.jsx("span",{className:"text-meta text-ink-dim",children:D})]}),t.jsx("p",{className:"text-body-sm text-ink [overflow-wrap:anywhere]","data-tour-tag":"mesh-approval-summary",tabIndex:-1,id:w,children:v?d:M}),Y&&t.jsx("p",{id:R,className:"text-meta text-ink-muted","data-tour-tag":"mesh-approval-critical-facts",children:Y}),!b&&e.state==="failed"&&t.jsx("p",{className:"text-meta text-ink-muted","data-tour-tag":"mesh-approval-stopped-note",children:a("ui.mesh.mesh_approvals_tray.the_runner_stopped_before_it_finished_it")}),v&&b&&!I&&t.jsx("p",{className:"text-meta text-ink-muted whitespace-pre-wrap [overflow-wrap:anywhere]","data-tour-tag":"mesh-approval-cli-remedy",children:te}),e.kind==="credential"&&!e.typed&&e.state==="approved"&&t.jsx("p",{className:"text-meta text-ink-muted","data-tour-tag":"mesh-approval-apply-hint",children:a(e.details?.length?"ui.mesh.approval.approved_apply_hint":"ui.mesh.approval.approved_details_missing")}),x&&t.jsx("p",{className:"text-meta text-ink-dim","data-tour-tag":"mesh-approval-file-key",children:a(L?"ui.mesh.approval.file_key_recorded":"ui.mesh.approval.file_key_disclosure")}),W&&t.jsx(it,{approvalId:e.approvalId,refusal:{code:G??"",sentence:W}}),_&&t.jsx("p",{className:"text-meta text-ink-muted",children:a("ui.mesh.approval.retry_hint")}),L&&j&&t.jsx("p",{className:"text-meta text-ink-muted",children:a("ui.mesh.approval.cancel_hint")}),(I||j||_)&&t.jsxs("div",{className:"flex flex-wrap items-center gap-2","data-tour-tag":"mesh-approval-controls",children:[_&&t.jsx(ee,{variant:"primary",size:"sm",disabled:s,"aria-describedby":Y?`${w} ${R}`:w,onClick:()=>u(e.approvalId,"apply"),"data-tour-tag":"mesh-approval-retry-apply",children:a("ui.mesh.approval.try_again")}),I&&t.jsx(ee,{variant:"primary",size:"sm",disabled:s,"aria-describedby":Y?`${w} ${R}`:w,onClick:()=>u(e.approvalId,"approve"),"data-tour-tag":"mesh-approval-approve",children:a("ui.mesh.mesh_approvals_tray.approve")}),j&&t.jsx(ee,{variant:"ghost",size:"sm",disabled:s,"aria-describedby":Y?`${w} ${R}`:w,onClick:()=>u(e.approvalId,"deny"),"data-tour-tag":v?"mesh-approval-deny":"mesh-approval-stop",children:v?a("ui.mesh.mesh_approvals_tray.deny"):e.kind==="credential"?a("ui.mesh.approval.cancel_sharing"):js(e.state)}),n&&t.jsx("span",{className:"text-meta text-ink-dim",children:n.decision==="approve"?e.typed?.unprovenHuman?a("ui.mesh.approval.signing_applying"):a("ui.mesh.mesh_approvals_tray.waiting_for_the_signing_prompt"):n.decision==="apply"?a("ui.mesh.approval.applying"):a("ui.mesh.mesh_approvals_tray.writing_the_decision")})]}),t.jsxs(ke,{chevronClassName:"text-ink-dim",summary:t.jsx("span",{className:"text-meta",children:a("ui.mesh.mesh_approvals_tray.details")}),children:[Z.length>0&&t.jsx("ul",{className:"flex flex-col gap-1.5 text-meta text-ink-muted [overflow-wrap:anywhere]","data-tour-tag":"mesh-approval-credential-consequences",children:Z.map($=>t.jsx("li",{children:$},$))}),V&&A?.disclosure?.recipient.keyFingerprint&&t.jsxs("p",{className:"text-meta text-ink-dim [overflow-wrap:anywhere]",children:[a("ui.mesh.approval.recipient_key",{device:V})," ",t.jsx("span",{className:"font-mono",children:A.disclosure.recipient.keyFingerprint})]}),G&&t.jsx("p",{className:"text-meta text-ink-dim font-mono",children:G}),A?.disclosure&&t.jsx(ke,{summary:t.jsx("span",{className:"text-meta",children:a("ui.mesh.approval.technical_request")}),children:t.jsx("pre",{className:"max-h-48 overflow-auto whitespace-pre-wrap text-meta text-ink-dim [overflow-wrap:anywhere]","data-tour-tag":"mesh-approval-signed-evidence",children:A.disclosure.evidence})}),N&&Z.length===0&&(e.details?.length?t.jsx("ul",{className:"flex flex-col gap-1.5 text-meta text-ink-muted [overflow-wrap:anywhere]","data-tour-tag":"mesh-approval-server-details",children:e.details.map(($,se)=>t.jsx("li",{className:"whitespace-pre-wrap",children:$},`${se}:${$}`))}):t.jsx("p",{className:"text-meta text-ink-muted",children:a("ui.mesh.approval.details_unavailable")})),c.length>0&&t.jsx("dl",{className:"grid grid-cols-[max-content_1fr] gap-x-4 gap-y-0.5 text-meta text-ink-dim","data-tour-tag":"mesh-approval-consequences",children:c.map($=>t.jsxs(p.Fragment,{children:[t.jsx("dt",{className:"text-ink-muted",children:$.term}),t.jsx("dd",{children:$.consequence})]},$.term))}),(h||C)&&t.jsxs("p",{className:"text-meta text-ink-muted",children:[h&&t.jsx("span",{children:h}),h&&C&&t.jsx("span",{children:" · "}),C&&t.jsx("span",{className:"font-mono",children:C})]}),S&&t.jsx("p",{className:"text-meta text-ink-dim",children:S}),P.length>0&&t.jsx("dl",{className:"grid grid-cols-[max-content_1fr] gap-x-4 gap-y-0.5 text-meta","data-tour-tag":"mesh-approval-consequence",children:P.map($=>t.jsxs(p.Fragment,{children:[t.jsx("dt",{className:"text-ink-muted",children:$.term}),t.jsx("dd",{className:"text-ink-muted",children:$.text})]},$.term))})]})]})},it=({refusal:e,request:n,approvalId:s,requestIsBackendSummary:i=!1})=>{K();const u=_s();return t.jsx("p",{tabIndex:-1,className:"text-meta text-warning [overflow-wrap:anywhere]","data-tour-tag":"mesh-approval-refusal","data-approval-refusal-id":s,children:n?Wt(n,e.sentence).map((m,f)=>m.kind==="literal"?t.jsx(p.Fragment,{children:m.text},`literal:${f}`):t.jsx("bdi",{dir:qt(m.kind,u,i),children:m.text},m.kind)):t.jsx("bdi",{dir:"auto",children:e.sentence})})},Is=4,ye={kind:"idle"};function Cs(e){switch(e.kind){case"dragging":case"settling":return e.payload.session.id;case"pressing":return null;default:return null}}function oe(e,n){switch(n.kind){case"press":return e.kind!=="idle"?e:{kind:"pressing",payload:n.payload,originX:n.x,originY:n.y,pointerId:n.pointerId};case"move":return e.kind==="pressing"?Math.max(Math.abs(n.x-e.originX),Math.abs(n.y-e.originY))<Is?e:{kind:"dragging",payload:e.payload,x:n.x,y:n.y,target:n.target,pointerId:e.pointerId}:e.kind==="dragging"?{...e,x:n.x,y:n.y,target:n.target}:e;case"release":return e.kind==="dragging"?{kind:"settling",payload:e.payload,target:e.target}:e.kind==="pressing"?ye:e;case"cancel":case"settled":return ye;default:return e}}const Ss=({edges:e,geometry:n,selectedDeviceId:s})=>t.jsx("svg",{"aria-hidden":"true",className:"pointer-events-none absolute top-0 left-0 overflow-visible",width:n.bounds.width,height:n.bounds.height,children:e.map(i=>{const u=n.networks.get(i.networkId),m=n.devices.get(i.deviceId);if(!u||!m)return null;const f=s!==null&&i.deviceId===s;return t.jsx("path",{"data-mesh-edge":i.key,d:zt(u,m),fill:"none",strokeWidth:f?2:1.5,className:f?"stroke-ink":"stroke-ink-dim"},i.key)})}),De=({deviceId:e,name:n,compact:s=!1,deviceIds:i,className:u})=>{K();const m=Ve({name:n});return t.jsxs("span",{className:H("flex min-w-0 items-baseline gap-2",u),"data-mesh-device-identity":e,children:[t.jsx(vt,{content:n?.trim()?m:null,children:t.jsx("span",{className:"min-w-0 flex-1 truncate text-start","data-mesh-device-name":"",children:m})}),t.jsx("span",{className:"shrink-0 font-mono text-meta text-ink-muted","data-mesh-device-id":"",title:e,children:s?mt(e,i):e})]})},Ms={self:"border-l-hairline",reached:"border-l-hairline","relay-down":"border-l-warning","handshake-refused":"border-l-warning","address-unreachable":"border-l-warning","no-endpoint":"border-l-hairline","not-a-member":"border-l-hairline",unanswered:"border-l-warning","not-attempted":"border-l-hairline",unknown:"border-l-hairline"};function As(e){return e.suspect?"border-l-danger":Ms[ce(e)]}const Ds={self:"ring-2 ring-accent",reachable:null,relay_down:null,handshake_refused:null,unreachable:null,suspect:null},Rs={accept:"border-accent bg-accent-wash",refuse:"border-warning"};function Es(e,n,s){return[Ve(e),e.id,tt(e,n),s].filter(Boolean).join(", ")}function ue(e){return e.name.trim()||e.id.slice(-6)}function rt(e,n,s){if(s!=="reached"&&s!=="self"){const i=fe(s);return e.unreachable_reason?`${i} (${e.unreachable_reason})`:i}return e.live_state.trim()?e.live_state.trim():e.locality==="local"?a("ui.mesh.mesh_drop.on_this_device"):a("ui.mesh.mesh_node.on_device",{device:n})}const Ps={resting:"border-l-2 border-l-hairline",attention:"border-l-2 border-l-warning"},$s=({network:e,x:n,y:s,refused:i})=>(K(),t.jsxs("li",{"data-mesh-network":e.id,"data-mesh-network-refused":i?"true":void 0,"data-glass-block":"",className:H("absolute flex items-center gap-2 rounded-md border bg-elevated px-3",i?"border-warning":"border-hairline"),style:{left:n,top:s,width:Se,height:Ft},children:[t.jsx(Ae,{"aria-hidden":"true",className:"size-4 shrink-0 text-ink-muted"}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"block truncate text-body-sm text-ink",children:e.label}),t.jsxs("span",{title:a("ui.mesh.mesh_list.epoch",{epoch:e.epoch}),className:"block truncate text-meta text-ink-dim",children:[a("ui.mesh.mesh_graph.device_count",{count:e.memberCount}),e.revokedCount>0?t.jsxs(t.Fragment,{children:[" · ",a("ui.mesh.mesh_list.revoked_count",{count:e.revokedCount})]}):null]})]})]})),Ls=({device:e,deviceIds:n,x:s,y:i,nowSeconds:u,selected:m,sessions:f,sessionTotal:o,dropState:v,movingSessionId:y,draggedSessionId:w,onOpen:R,onChipPointerDown:M,onChipClick:d,onShowAllSessions:c})=>{K();const{activity:h}=ut(e,f.rows),C=h==="working",S=Es(e,u,C?"working":null),D=ce(e);return t.jsxs("li",{"data-mesh-device":e.id,"data-mesh-state":e.state,"data-mesh-drop":v??void 0,"aria-current":m?"true":void 0,"data-glass-block":"",className:H("absolute flex flex-col rounded-md border border-l-4 border-control bg-elevated","hover:bg-row-hover",m&&"border-y-ink border-r-ink bg-row-selected",As(e),Ds[e.state],v&&Rs[v]),style:{left:s,top:i,width:Se,height:Bt},children:[t.jsxs("button",{type:"button","data-mesh-device-open":e.id,"data-mesh-reach":D,"aria-label":S,title:ht(e),onClick:()=>R(e.id),className:H("flex w-full flex-col justify-between rounded-t-[5px] px-3 pt-2 pb-2 text-start","cursor-pointer","focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent focus-visible:outline-offset-[-2px]"),style:{height:Ut},children:[t.jsxs("span",{className:"flex w-full min-w-0 items-center gap-2",children:[t.jsx(ks,{"aria-hidden":"true",className:"size-4 shrink-0 text-ink-muted"}),t.jsx(De,{className:"min-w-0 flex-1 text-body-sm text-ink",deviceId:e.id,deviceIds:n,name:e.name,compact:!0}),e.suspect&&t.jsx(Me,{"aria-hidden":"true",className:"size-3.5 shrink-0 text-danger"})]}),t.jsxs("span",{className:"flex w-full min-w-0 items-baseline gap-1",children:[t.jsx("span",{className:"w-3 shrink-0 font-mono text-body-sm text-ink tabular-nums",children:e.sessionCount??"–"}),t.jsx("span",{className:H("min-w-0 truncate text-meta",e.sessionCount===null?"text-ink-dim":"text-ink-muted"),children:et(e.sessionCount)})]}),t.jsxs("span",{"data-mesh-state-line":"",className:"flex w-full min-w-0 items-baseline gap-1.5 text-meta",children:[t.jsx("span",{"aria-hidden":"true",className:"shrink-0 text-ink-dim",children:pt[D]}),t.jsx("span",{className:H("shrink-0",Ge[D]),children:fe(D)}),C&&t.jsx("span",{"data-mesh-working":"",className:"shrink-0 text-info",children:a("ui.mesh.mesh_node.working")}),e.memberships.length>1&&t.jsx("span",{className:"min-w-0 truncate text-ink-dim",children:a("ui.mesh.mesh_node.memberships",{count:e.memberships.length})})]})]}),t.jsxs("ul",{"aria-label":a("ui.mesh.mesh_node.conversations_on",{device:re(e,n,!0)}),className:H("m-0 flex h-6 list-none items-center gap-1 overflow-hidden px-3",v==="accept"&&"opacity-40"),children:[f.shown.map(N=>t.jsx(Ts,{session:N,ownerLabel:re(e,n,!0),ownerReach:D,ownerReachable:e.reachable,moving:y===N.id,dragging:w===N.id,onPointerDown:M,onClick:()=>d(N)},N.id)),f.hidden>0&&t.jsx("li",{className:"shrink-0",children:t.jsxs("button",{type:"button","data-mesh-more":e.id,onClick:()=>c(e.id),className:H("flex min-h-6 items-center rounded-sm px-1.5 text-meta text-ink-dim","hover:bg-row-hover hover:text-ink","focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent focus-visible:outline-offset-2"),title:a("ui.mesh.mesh_node.shown_conversations",{shown:f.shown.length,total:o}),"aria-label":a("ui.mesh.mesh_node.show_all_conversations",{count:o}),children:["+",f.hidden]})})]})]})},Ts=({session:e,ownerLabel:n,ownerReach:s,ownerReachable:i,moving:u,dragging:m,onPointerDown:f,onClick:o})=>{K();const v=rt(e,n,s);return u?t.jsx("li",{role:"status","data-mesh-session":e.id,"data-mesh-moving":"true",children:t.jsx("span",{className:"flex min-h-6 items-center rounded-sm bg-sunken px-1.5 text-meta text-ink-muted",children:a("ui.mesh.mesh_card.moving")})}):t.jsx("li",{className:"min-w-0 flex-1","data-mesh-session-item":e.id,"data-mesh-dragging":m?"true":void 0,children:t.jsx("button",{type:"button","data-mesh-session":e.id,style:{touchAction:"none"},title:`${ue(e)} · ${v}`,"aria-label":a("ui.mesh.mesh_node.open_conversation",{conversation:ue(e),fact:v,owner:n}),onPointerDown:y=>f(y,e),onClick:()=>o(e),className:H("flex min-h-6 w-full max-w-32 items-center rounded-sm border border-hairline bg-surface px-1.5 text-start text-meta text-ink-muted","cursor-grab active:cursor-grabbing","hover:text-ink",Ps[Yt(e,i)],m&&"opacity-60","focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent focus-visible:outline-offset-2"),children:t.jsx("span",{className:"min-w-0 flex-1 truncate",children:ue(e)})})})};function We(e){const n=e.trim();if(!n)return null;if(n.startsWith("[")){const i=n.indexOf("]");if(i<=1)return null;const u=n.slice(1,i),m=n.slice(i+1);if(!m)return{host:u,port:null};if(!m.startsWith(":"))return null;const f=Number(m.slice(1));return{host:u,port:Number.isInteger(f)?f:null}}const s=n.lastIndexOf(":");if(s>0){const i=n.slice(s+1);if(/^\d+$/.test(i))return{host:n.slice(0,s),port:Number(i)}}return{host:n,port:null}}function qe(e){const n=e.trim().split(".");if(n.length!==4)return null;for(const s of n)if(!/^\d{1,3}$/.test(s)||Number(s)>255)return null;return`${n[0]}.${n[1]}.${n[2]}`}function Os(e){return`${e}.x`}function Hs(e){const n=new Map;for(const i of e.values())for(const u of i)n.set(u,(n.get(u)??0)+1);const s=new Set;for(const[i,u]of n)u>1&&s.add(i);return s}function Ce(e){return new Set(e.endpoints.map(n=>n.trim()).filter(Boolean))}function Ws(e,n){const s=e.filter(d=>d.id!==n),i=e.find(d=>d.id===n)??null,u=new Map;for(const d of e)u.set(d.id,Ce(d));const m=Hs(u),f=new Set;for(const d of i?Ce(i):[]){if(m.has(d))continue;const c=We(d),h=c?qe(c.host):null;h&&f.add(h)}const o=d=>{const c=new Set;for(const h of Ce(d)){if(m.has(h))continue;const C=We(h),S=C?qe(C.host):null;S&&c.add(S)}return c},v=new Map,y=new Map;for(const d of s){const c=qs(d);if(c){v.set(c,[...v.get(c)??[],d.id]);continue}for(const h of o(d))y.set(h,[...y.get(h)??[],d.id])}const w=new Map(e.map((d,c)=>[d.id,c])),R=d=>[...d].sort((c,h)=>(w.get(c)??0)-(w.get(h)??0)),M=[];for(const[d,c]of v)M.push({prefix:d,tier:"declared",deviceIds:R(c),get words(){return a("ui.mesh.mesh_scope.declared")}});for(const[d,c]of y)f.has(d)?M.push({prefix:d,tier:"shared",deviceIds:R(c),get words(){return a("ui.mesh.mesh_scope.shared_with_this_device")}}):c.length>1&&M.push({prefix:d,tier:"probable",deviceIds:R(c),get words(){return a("ui.mesh.mesh_scope.same_prefix")}});return M.sort((d,c)=>d.tier.localeCompare(c.tier)||d.prefix.localeCompare(c.prefix))}function qs(e){for(const n of e.memberships){const s=n.scope.trim();if(s)return s}return""}const ze={declared:0,shared:1,probable:2};function zs(e,n){const s=new Map;for(const u of e){let m=null;for(const o of u.deviceIds){const v=n.get(o);v!==void 0&&(m===null||v<m.slot)&&(m={id:o,slot:v})}if(m===null)continue;const f=s.get(m.id);f===void 0?s.set(m.id,{slot:m.slot,groups:[u]}):f.groups.push(u)}const i=u=>{let m=-1;for(const f of u.deviceIds){const o=n.get(f);o!==void 0&&o>m&&(m=o)}return m};return[...s.entries()].sort((u,m)=>u[1].slot-m[1].slot).map(([u,m])=>({deviceId:u,groups:m.groups.sort((f,o)=>i(o)-i(f)||ze[f.tier]-ze[o.tier]||f.prefix.localeCompare(o.prefix))}))}function Fs(e){return new Map(e.map(n=>[n.deviceId,n.groups.length]))}function Bs(e){return`${e.tier==="declared"?e.prefix:Os(e.prefix)} · ${e.words}`}const Fe=(e,n)=>e.deviceIds.map(s=>n.devices.get(s)).filter(s=>s!==void 0),Us=({stacks:e,geometry:n})=>(K(),t.jsx("div",{"aria-hidden":"true",className:"pointer-events-none absolute top-0 left-0",children:e.map(s=>{const i=s.groups.length,u=new Array(i).fill(0);let m=null;for(let o=i-1;o>=0;o-=1){const v=Fe(s.groups[o],n),y=(v.length===0?0:Math.max(...v.map(w=>w.y+w.height)))+ve;m=m===null?y:Math.max(y,m+Ne),u[o]=m}const f=n.devices.get(s.deviceId);return s.groups.map((o,v)=>{const y=Fe(o,n);if(y.length===0)return null;const w=i-1-v,R=Math.min(...y.map(S=>S.x)),M=Math.max(...y.map(S=>S.x)),c=(f?.y??Math.min(...y.map(S=>S.y)))-ve-Kt*w,h=o.tier==="declared",C=Bs(o);return t.jsx("div",{"data-mesh-scope":`${o.tier}:${o.prefix}`,"data-mesh-scope-level":v,className:H("absolute rounded-lg",o.tier==="probable"?"border border-dashed border-hairline-strong":"border border-control"),style:{left:R-ve-Ne*w,top:c,width:M+Se-R+(ve+Ne*w)*2,height:u[v]-c},children:t.jsx("span",{"data-mesh-scope-label":"",className:H("absolute bottom-full left-1 mb-0.5 whitespace-nowrap text-meta",o.tier==="probable"?"text-ink-dim":"text-ink-muted",h&&"font-medium"),children:C})},`${o.tier}:${o.prefix}`)})})})),Be=48,Ue=1.25,Ys=.0015,Ks=({graph:e,slots:n,nowSeconds:s,selectedDeviceId:i,sessions:u,sessionTotals:m,movingSessionId:f,canMove:o,onOpenDevice:v,onAskMove:y,onDropRefused:w,onShowAllSessions:R,summaryId:M})=>{K();const d=p.useRef(null),[c,h]=p.useState({width:0,height:0,clipWidth:0,clipHeight:0,left:0,top:0}),[C,S]=p.useState({k:1,tx:0,ty:0}),D=p.useRef(!1),N=p.useRef(!1),b=p.useRef(null),P=p.useMemo(()=>Ws(e.devices,e.selfDeviceId),[e.devices,e.selfDeviceId]),E=p.useMemo(()=>zs(P,n.devices),[P,n]),I=p.useMemo(()=>Vt(n,Fs(E)),[n,E]),j=p.useMemo(()=>({selfDeviceId:e.selfDeviceId,devices:new Map(e.devices.map(r=>[r.id,r])),networks:new Map(e.networks.map(r=>[r.id,r]))}),[e]),[_,A]=p.useState(ye),Z=p.useRef({kind:"ground"}),V=p.useCallback((r,l)=>{const g=document.elementFromPoint(r,l),T=g?.closest("[data-mesh-device]");if(T){const ae=T.getAttribute("data-mesh-device");if(ae)return{kind:"device",deviceId:ae}}const U=g?.closest("[data-mesh-network]");if(U){const ae=U.getAttribute("data-mesh-network");if(ae)return{kind:"network",networkId:ae}}return{kind:"ground"}},[]),x=p.useMemo(()=>_.kind!=="dragging"&&_.kind!=="settling"?null:be(_.payload,_.target,j),[_,j]),L=p.useCallback(r=>{if(!x)return null;if(x.kind==="plan"){const l=_.kind==="dragging"||_.kind==="settling"?_.target:null;return l&&l.kind==="device"&&l.deviceId===r?"accept":null}if(x.kind==="refused"){const l=_.kind==="dragging"||_.kind==="settling"?_.target:null;return l&&l.kind==="device"&&l.deviceId===r?"refuse":null}return null},[x,_]),W=p.useCallback((r,l)=>{if(!o||r.button!==0)return;N.current=!1;const g=l.locality==="local"?e.selfDeviceId??"":l.owner_device,T=j.devices.get(g),U={session:l,ownerDeviceId:g,ownerLabel:T?re(T,[...j.devices.keys()],!0):l.owner_device_name};try{r.currentTarget.setPointerCapture(r.pointerId)}catch{}A(ae=>oe(ae,{kind:"press",payload:U,x:r.clientX,y:r.clientY,pointerId:r.pointerId}))},[o,j,e.selfDeviceId]),G=r=>{if(_.kind==="pressing"||_.kind==="dragging"){const l=V(r.clientX,r.clientY);Z.current=l,A(g=>oe(g,{kind:"move",x:r.clientX,y:r.clientY,target:l}));return}J(r)},Y=r=>{if(le(r),_.kind!=="pressing"&&_.kind!=="dragging")return;if(_.kind==="pressing"){A(g=>oe(g,{kind:"cancel"}));return}const l=be(_.payload,_.target,j);N.current=!0,A(g=>oe(g,{kind:"release"})),l.kind==="plan"?y({plan:l.plan,alternatives:l.alternatives,risky:l.risky}):l.kind==="refused"&&w({code:l.code,sentence:l.sentence,reach:l.reach,remedy:l.remedy,plan:l.plan??null}),A(g=>oe(g,{kind:"settled"}))};p.useEffect(()=>()=>A(ye),[]);const te=p.useCallback(()=>{S(Oe(I.bounds,c))},[I.bounds,c]);p.useEffect(()=>{const r=d.current;if(!r)return;const l=()=>{const T=r.getBoundingClientRect();h({width:T.width,height:T.height,clipWidth:r.clientWidth,clipHeight:r.clientHeight,left:T.left,top:T.top})};l();const g=new ResizeObserver(l);return g.observe(r),()=>g.disconnect()},[]),p.useEffect(()=>{D.current||c.width<=0||c.height<=0||(D.current=!0,S(Oe(I.bounds,c)))},[c,I.bounds]),p.useEffect(()=>{const r=b.current;if(b.current={width:c.width,height:c.height},!r||!D.current||c.width<=0||c.height<=0||c.width>=r.width&&c.height>=r.height||!i)return;const l=I.devices.get(i);l&&S(g=>{const T={width:c.clipWidth,height:c.clipHeight},U=Math.max(0,Math.min(T.width-I.bounds.width*g.k,T.height-I.bounds.height*g.k));return Gt(g,l,T,Math.min(Zt,U))})},[c,i,I]);const $=_.kind==="dragging"?{x:_.x-c.left+12,y:_.y-c.top+12}:{x:0,y:0},se=x?Xt(x):null,q=p.useRef(null),ne=p.useRef(null),k=p.useRef(null),O=p.useRef(null),z=p.useCallback(()=>{k.current=null;const r=q.current,l=ne.current;if(q.current=null,ne.current=null,r){const g=O.current;if(!g)return;S({k:g.transform.k,tx:g.transform.tx+(r.x-g.x),ty:g.transform.ty+(r.y-g.y)});return}l&&S(g=>Ie(g,{x:l.x,y:l.y},g.k*Math.exp(-l.deltaY*Ys)))},[]),B=p.useCallback(()=>{k.current===null&&(k.current=requestAnimationFrame(z))},[z]);p.useEffect(()=>()=>{k.current!==null&&cancelAnimationFrame(k.current)},[]);const F=r=>{!(r.target===r.currentTarget)&&r.button!==1||r.button!==0&&r.button!==1||(O.current={x:r.clientX,y:r.clientY,transform:C},r.currentTarget.setPointerCapture(r.pointerId),r.preventDefault())},J=r=>{O.current&&(q.current={x:r.clientX,y:r.clientY},B())},le=r=>{O.current&&(O.current=null,q.current=null,r.currentTarget.hasPointerCapture(r.pointerId)&&r.currentTarget.releasePointerCapture(r.pointerId))},ie=p.useCallback(r=>{if(r.deltaY===0)return;r.preventDefault();const l=r.currentTarget.getBoundingClientRect();ne.current={x:r.clientX-l.left,y:r.clientY-l.top,deltaY:r.deltaY},B()},[B]);p.useEffect(()=>{const r=d.current;if(r)return r.addEventListener("wheel",ie,{passive:!1}),()=>r.removeEventListener("wheel",ie)},[ie]);const he=r=>{const l=r.shiftKey?Be*4:Be;switch(r.key){case"Escape":if(_.kind!=="pressing"&&_.kind!=="dragging")return;r.preventDefault(),_.kind==="dragging"&&(N.current=!0),A(g=>oe(g,{kind:"cancel"}));return;case"0":r.preventDefault(),te();return;case"+":case"=":r.preventDefault(),S(g=>Ie(g,{x:c.width/2,y:c.height/2},g.k*Ue));return;case"-":case"_":r.preventDefault(),S(g=>Ie(g,{x:c.width/2,y:c.height/2},g.k/Ue));return;case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"ArrowDown":{r.preventDefault();const g=r.key==="ArrowLeft"?l:r.key==="ArrowRight"?-l:0,T=r.key==="ArrowUp"?l:r.key==="ArrowDown"?-l:0;S(U=>({...U,tx:U.tx+g,ty:U.ty+T}));return}}};return t.jsxs("div",{ref:d,"data-mesh-canvas":"",role:"group","aria-labelledby":M,tabIndex:0,onPointerDown:F,onPointerMove:G,onPointerUp:Y,onPointerCancel:r=>{_.kind==="dragging"&&(N.current=!0),A(l=>oe(l,{kind:"cancel"})),le(r)},"data-mesh-gesture":_.kind,"data-glass-well":"clear",onKeyDown:he,onDoubleClick:r=>{r.target===r.currentTarget&&te()},className:H("relative min-h-0 flex-1 overflow-hidden rounded-lg border border-hairline bg-sunken","[touch-action:none]","cursor-grab active:cursor-grabbing","focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent focus-visible:outline-offset-[-2px]"),children:[t.jsx("div",{"data-mesh-ground":"","aria-hidden":"true",className:"mesh-ground pointer-events-none absolute inset-0",style:{backgroundPosition:`${C.tx}px ${C.ty}px`}}),t.jsxs("div",{"data-mesh-world":"",className:"absolute top-0 left-0",style:{transform:`translate3d(${C.tx}px, ${C.ty}px, 0) scale(${C.k})`,transformOrigin:"0 0",width:I.bounds.width,height:I.bounds.height},children:[t.jsx(Us,{stacks:E,geometry:I}),t.jsx(Ss,{edges:e.edges,geometry:I,selectedDeviceId:i}),t.jsx("ul",{"aria-label":a("ui.mesh.mesh_canvas.networks"),className:"m-0 list-none p-0",children:e.networks.map(r=>{const l=I.networks.get(r.id);return l?t.jsx($s,{network:r,x:l.x,y:l.y,refused:x?.kind==="refused"&&_.kind==="dragging"&&_.target.kind==="network"&&_.target.networkId===r.id},r.id):null})}),t.jsx("ul",{"aria-label":a("ui.mesh.mesh_canvas.devices"),className:"m-0 list-none p-0",children:e.devices.map(r=>{const l=I.devices.get(r.id);return l?t.jsx(Ls,{device:r,deviceIds:e.devices.map(g=>g.id),x:l.x,y:l.y,nowSeconds:s,selected:r.id===i,sessions:u.get(r.id)??{rows:[],shown:[],hidden:0},sessionTotal:m.get(r.id)??r.sessionCount??0,dropState:L(r.id),movingSessionId:f,draggedSessionId:Cs(_),onOpen:v,onChipPointerDown:W,onChipClick:()=>{if(N.current){N.current=!1;return}v(r.id)},onShowAllSessions:R},r.id):null})})]}),_.kind==="dragging"&&t.jsx("div",{"data-mesh-ghost":"","aria-hidden":"true",className:"pointer-events-none absolute z-10 max-w-40 truncate rounded-sm border border-ink-dim bg-surface px-1.5 py-0.5 text-meta text-ink",style:{left:$.x,top:$.y},children:_.payload.session.name||"untitled"}),_.kind==="dragging"&&se&&t.jsx("div",{"data-mesh-indicator":"",className:H("pointer-events-none absolute z-10 rounded-sm border bg-surface px-2 py-1 text-meta",x?.kind==="refused"?"border-warning text-warning":"border-control text-ink"),style:{left:$.x,maxWidth:Math.max(160,c.width-$.x-12),...$.y>c.height*.6?{bottom:Math.max(12,c.height-$.y+8)}:{top:$.y+24}},children:se})]})};function Vs(e,n,s,i){const u=s.locality==="local"?n:s.owner_device,m=[],f=e.map(o=>o.id);for(const o of e){if(o.id===u)continue;if(o.id===n){m.push({deviceId:o.id,label:i,verb:a("ui.mesh.mesh_card.recall_to_this_device"),keepVerb:a("ui.mesh.mesh_card.copy_here_leave_it_there")});continue}const v=re(o,f,!0);m.push({deviceId:o.id,label:v,verb:a("ui.mesh.mesh_card.move_to",{device:v}),keepVerb:a("ui.mesh.mesh_card.copy_to",{device:v})})}return m}function Gs(e,n,s){return Vs(e.devices,e.selfDeviceId,n,s)}function lt(e,n,s){const i=Gs(e,n,s),u={selfDeviceId:e.selfDeviceId,devices:new Map(e.devices.map(o=>[o.id,o])),networks:new Map(e.networks.map(o=>[o.id,o]))},m=n.locality==="local"?e.selfDeviceId??"":n.owner_device,f=u.devices.get(m);return i.map(o=>{const v=be({session:n,ownerDeviceId:m,ownerLabel:f?re(f,e.devices.map(y=>y.id),!0):n.owner_device_name},{kind:"device",deviceId:o.deviceId},u);return{...o,refused:v.kind==="refused"&&v.code!=="busy"?v.sentence:null}})}const ot=({session:e,destinations:n,disabled:s,onChoose:i,onOpenChange:u,trigger:m,triggerLabel:f})=>(K(),t.jsxs(_t,{onOpenChange:u,children:[t.jsx(kt,{asChild:!0,children:t.jsx("button",{type:"button","aria-label":f,"data-mesh-session-menu":e.id,disabled:s||n.length===0,className:"rounded-sm focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent focus-visible:outline-offset-2 disabled:text-ink-disabled",children:m})}),t.jsxs(yt,{align:"start",className:"min-w-56",children:[t.jsx(jt,{children:ue(e)}),t.jsx(Pe,{}),n.map(o=>t.jsx($e,{"data-mesh-move-to":o.deviceId,disabled:!!o.refused,title:o.refused??void 0,onSelect:()=>i(o,!1),children:o.verb},o.deviceId)),t.jsx(Pe,{}),n.map(o=>t.jsx($e,{"data-mesh-copy-to":o.deviceId,disabled:!!o.refused,title:o.refused??void 0,onSelect:()=>i(o,!0),children:o.keepVerb},`keep-${o.deviceId}`))]})]})),Xs=({device:e,deviceIds:n,sessions:s,sessionTotal:i,nowSeconds:u,destinationsFor:m,movingSessionId:f,canMove:o,canInvite:v,onClose:y,onMove:w,onShowInList:R,onInvite:M,onRemoveMember:d})=>{K();const c=ce(e),h=Xe(e),C=e.reachable?[]:e.attempts??[];p.useEffect(()=>{const b=P=>{P.key!=="Escape"||P.defaultPrevented||P.target?.closest('[role="menu"],[role="dialog"]')||(document.querySelector(`[data-mesh-device-open="${e.id}"]`)?.focus(),y())};return window.addEventListener("keydown",b),()=>window.removeEventListener("keydown",b)},[e.id,y]);const S=e.sessionCount===null?et(null):a("ui.mesh.mesh_card.conversation_count",{count:e.sessionCount}),D=e.suspect?Ze():[S,fe(c)].filter(Boolean).join(" · "),N=i>s.rows.length?a("ui.mesh.mesh_card.shown_of",{shown:s.rows.length,total:i}):`${s.rows.length}`;return t.jsxs("aside",{"aria-label":a("ui.mesh.mesh_card.device_details",{device:re(e)}),"data-mesh-panel":e.id,"data-glass-block":"",className:"flex w-80 shrink-0 flex-col gap-3 overflow-y-auto rounded-md border border-hairline bg-surface p-4",children:[t.jsxs("header",{className:"flex flex-col gap-1",children:[t.jsx(ee,{size:"sm",variant:"ghost",className:"w-fit self-end","data-mesh-panel-close":"",onClick:y,children:a("ui.mesh.mesh_actions.close")}),t.jsx("h2",{className:"text-body-sm text-ink",children:t.jsx(De,{deviceId:e.id,deviceIds:n,name:e.name,compact:!0})}),t.jsxs("p",{className:"flex items-center gap-1.5 text-meta text-ink-muted",children:[e.suspect&&t.jsx(Me,{"aria-hidden":"true",className:"size-3.5 text-danger"}),!e.suspect&&c==="unanswered"&&t.jsx(bt,{"aria-hidden":"true",className:"size-3.5 text-warning"}),D]})]}),t.jsx(pe,{}),t.jsxs("section",{className:"flex flex-col gap-2",children:[t.jsx("h3",{className:"text-meta text-ink-dim",children:a("ui.mesh.mesh_card.memberships")}),t.jsx("ul",{className:"m-0 flex list-none flex-col gap-2 p-0",children:e.memberships.map(b=>t.jsxs("li",{className:"flex flex-col gap-1",children:[t.jsxs("span",{className:"flex items-center gap-2 text-body-sm text-ink",children:[t.jsx(Ae,{"aria-hidden":"true",className:"size-3.5 text-ink-muted"}),b.networkName]}),t.jsxs("span",{className:"text-meta text-ink-dim",children:[b.role||"member",b.capabilities.length>0?` · ${b.capabilities.join(", ")}`:""]}),v&&t.jsxs(ee,{size:"sm",variant:"ghost",className:"w-fit","data-mesh-remove-member":`${b.networkId}:${e.id}`,onClick:()=>d(e,b.networkId),children:[a("ui.mesh.mesh_card.remove_from"),b.networkName,"…"]})]},b.networkId))}),v&&t.jsx(ee,{size:"sm",variant:"secondary",className:"w-fit","data-mesh-invite":e.id,onClick:()=>M(e),children:a("ui.mesh.mesh_actions.invite_to_a_network")})]}),t.jsx(pe,{}),t.jsxs("section",{className:"flex shrink-0 flex-col gap-2",children:[t.jsxs("h3",{className:"text-meta text-ink-dim",children:[a("ui.mesh.mesh_card.conversations"),t.jsxs("span",{className:"text-ink-disabled",children:["(",ce(e)!=="self"&&ce(e)!=="reached"?st(null):N,")"]})]}),_e(e,u)?t.jsx("p",{className:"text-meta text-warning",children:_e(e,u)}):s.rows.length===0?t.jsx("p",{className:"text-meta text-ink-dim",children:e.sessionCount===null?a("ui.mesh.mesh_card.this_device_did_not_report_its_conversations"):a("ui.mesh.mesh_card.no_conversations_here")}):t.jsx("ul",{className:"m-0 flex list-none flex-col gap-1 p-0",children:s.rows.map(b=>t.jsxs("li",{"data-mesh-panel-session":b.id,className:H("flex items-center gap-2 rounded-sm px-2 py-1","border border-hairline bg-elevated",f===b.id&&"border-control"),children:[t.jsx("span",{className:"min-w-0 flex-1 truncate text-body-sm text-ink",title:ue(b),children:ue(b)}),t.jsx("span",{className:"shrink-0 text-meta text-ink-dim",children:rt(b,re(e,n,!0),ce(e))}),f===b.id?t.jsx("span",{className:"shrink-0 text-meta text-ink-muted",children:a("ui.mesh.mesh_card.moving")}):t.jsx(ot,{session:b,destinations:m(b),disabled:!o,onChoose:(P,E)=>w(b,P,E),trigger:t.jsx(nt,{"aria-hidden":"true",className:"size-4"}),triggerLabel:a("ui.mesh.mesh_card.move_conversation",{conversation:ue(b)})})]},b.id))})]}),t.jsx(pe,{}),t.jsxs("section",{className:"flex flex-col gap-2",children:[t.jsx("h3",{className:"text-meta text-ink-dim",children:a("ui.mesh.mesh_card.network_addresses")}),e.endpoints.length===0?t.jsx("p",{className:"text-meta text-ink-dim",children:a("ui.mesh.mesh_card.no_address_published")}):t.jsx("ul",{className:"m-0 flex list-none flex-col gap-1 p-0",children:e.endpoints.map(b=>t.jsxs("li",{className:"flex items-baseline justify-between gap-2",children:[t.jsx("span",{className:"min-w-0 truncate font-mono text-body-sm text-ink",children:b}),t.jsx("span",{className:"shrink-0 text-meta text-ink-dim",children:a("ui.mesh.mesh_card.advertised")})]},b))})]}),t.jsx(pe,{}),t.jsxs("section",{className:"flex flex-col gap-2",children:[t.jsx("h3",{className:"text-meta text-ink-dim",children:a("ui.mesh.mesh_card.status")}),t.jsxs("dl",{className:"m-0 flex flex-col gap-1",children:[t.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[t.jsx("dt",{className:"text-meta text-ink-dim",children:a("ui.mesh.mesh_card.reach")}),t.jsx("dd",{className:"m-0 text-body-sm text-ink",children:fe(c)})]}),t.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[t.jsx("dt",{className:"text-meta text-ink-dim",children:a("ui.mesh.mesh_card.last_status_frame")}),t.jsx("dd",{className:"m-0 text-body-sm text-ink",children:e.lastSeenAt===null?a("ui.mesh.mesh_card.never"):Jt(u-e.lastSeenAt)})]})]}),!e.reachable&&(h!==""||C.length>0)&&t.jsxs("div",{className:"flex flex-col gap-1",children:[h&&t.jsx("p",{className:"m-0 text-meta text-warning",children:h}),e.linkState==="handshake_refused"&&t.jsx("p",{className:"m-0 text-meta text-ink-dim",children:a("ui.mesh.mesh_reach.handshake_refused_hint")}),C.length>0&&t.jsxs(t.Fragment,{children:[t.jsx("span",{id:`mesh-attempts-label-${e.id}`,className:"text-meta text-ink-dim",children:a("ui.mesh.mesh_reach.addresses_tried")}),t.jsx("ul",{role:"list","aria-labelledby":`mesh-attempts-label-${e.id}`,className:"m-0 flex list-none flex-col gap-0.5 p-0",children:C.map((b,P)=>{const E=Je(b.detail);return t.jsxs("li",{"data-mesh-attempt":b.endpoint,className:"flex items-baseline justify-between gap-2",children:[t.jsx("span",{className:"min-w-0 truncate font-mono text-meta text-ink",children:b.endpoint}),t.jsx("span",{className:"shrink-0 text-meta text-ink-dim",children:E})]},`${b.endpoint}:${P}`)})})]})]}),!h&&C.length===0&&e.reason&&t.jsx("p",{className:"text-meta text-warning",children:e.reason})]}),t.jsx(pe,{}),t.jsx(ee,{size:"sm",variant:"ghost",className:"w-fit","data-mesh-show-in-list":e.id,onClick:()=>R(e.id),children:a("ui.mesh.mesh_card.show_in_list")})]})},Zs=["name","chats","state"],Js={get name(){return a("ui.mesh.mesh_list.name")},get chats(){return a("ui.mesh.mesh_list.sort_conversations")},get state(){return a("ui.mesh.mesh_list.state")}},Ye={suspect:0,relay_down:1,handshake_refused:2,unreachable:3,self:4,reachable:5};function Qs(e,n){const s=[...e];switch(n){case"chats":return s.sort((i,u)=>(u.sessionCount??-1)-(i.sessionCount??-1)||i.label.localeCompare(u.label)),s;case"state":return s.sort((i,u)=>Ye[i.state]-Ye[u.state]||i.label.localeCompare(u.label)),s;default:return s.sort((i,u)=>i.label.localeCompare(u.label))}}const Ke=8;function ea(e,n){if(e.locality==="local")return e.live_state||"here";const s=e.owner_device_name||n,i=e.live_state?` · ${e.live_state}`:"";return e.reachable?a("ui.mesh.mesh_list.on_device_state",{device:s,state:i}):a("ui.mesh.mesh_list.on_device_no_answer",{device:s})}const ta=({graph:e,nowSeconds:n,selectedDeviceId:s,sessions:i,selfLabel:u,canMove:m,onSelect:f,onMove:o,onInvite:v,onRemove:y})=>{K();const[w,R]=p.useState("name"),M=p.useMemo(()=>e.networks.map(d=>({network:d,members:Qs(e.devices.filter(c=>c.memberships.some(h=>h.networkId===d.id)),w)})),[e,w]);return t.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto pe-1",children:[t.jsxs("fieldset",{className:"m-0 w-fit border-0 p-0",children:[t.jsx("legend",{className:"sr-only",children:a("ui.mesh.mesh_list.sort_devices_by")}),t.jsx("div",{"data-glass-well":"",className:"flex gap-0.5 rounded-md bg-sunken p-0.5",children:Zs.map(d=>t.jsx("button",{type:"button","aria-pressed":w===d,onClick:()=>R(d),className:H("h-6 rounded-sm px-3 text-body-sm text-ink-muted transition-colors duration-fast ease-out-quart","hover:text-ink","focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent focus-visible:outline-offset-2",w===d&&"bg-surface text-ink"),children:Js[d]},d))})]}),M.map(({network:d,members:c})=>t.jsxs("section",{"data-mesh-network-group":d.id,className:"flex flex-col gap-2",children:[t.jsxs("h2",{className:"flex flex-wrap items-baseline gap-2 text-body-sm text-ink",title:a("ui.mesh.mesh_list.epoch",{epoch:d.epoch}),children:[d.label,t.jsxs("span",{className:"text-meta text-ink-dim",children:[d.trust," ·"," ",a("ui.mesh.mesh_graph.device_count",{count:d.memberCount}),d.revokedCount>0?t.jsxs(t.Fragment,{children:[" · ",a("ui.mesh.mesh_list.revoked_count",{count:d.revokedCount})]}):null]})]}),t.jsx("ul",{className:"m-0 flex list-none flex-col gap-1 p-0",children:c.map(h=>{const C=h.memberships.find(j=>j.networkId===d.id),S=h.id===s,D=i.get(h.id),N=D?.rows??[],b=D?at(D,h.sessionCount):h.sessionCount??0,P=ce(h),E=Xe(h),I=h.reachable?[]:h.attempts??[];return t.jsxs("li",{"data-mesh-device-row":h.id,"data-mesh-state":h.state,"aria-current":S?"true":void 0,className:H("flex flex-col gap-1 rounded-md px-3 py-2","border border-hairline bg-surface",S&&"border-ink bg-row-selected"),children:[t.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-3 gap-y-1",children:[t.jsx("button",{type:"button","data-mesh-device-open":h.id,onClick:()=>f(h.id),className:H("min-w-0 flex-1 text-start text-body-sm text-ink","hover:text-ink-muted","focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent focus-visible:outline-offset-2"),children:t.jsx(De,{deviceId:h.id,name:h.name})}),t.jsxs("span",{className:H("flex shrink-0 items-center gap-1 text-meta",Ge[P]),"data-mesh-reach":P,children:[h.suspect&&t.jsx(Me,{"aria-hidden":"true",className:"size-3.5 shrink-0 text-danger"}),h.suspect?fe(P):tt(h,n),h.suspect&&t.jsx("span",{className:"shrink-0 rounded-sm border border-danger px-1 text-danger",children:Ze()})]}),t.jsxs("span",{className:"shrink-0 text-meta text-ink-dim",children:[C?.role?`${C.role} · `:"",a("ui.mesh.mesh_list.member")]})]}),(E!==""||I.length>0)&&!h.reachable&&t.jsxs("div",{className:"flex flex-col gap-0.5",children:[E&&t.jsx("span",{className:"text-meta text-warning",children:E}),I.map((j,_)=>{const A=Je(j.detail);return t.jsx("span",{"data-mesh-attempt":j.endpoint,className:"text-meta text-ink-dim",children:A?`${j.endpoint} — ${A}`:j.endpoint},`${j.endpoint}:${_}`)})]}),_e(h,n)?t.jsxs("span",{className:"text-meta text-warning",children:[a("ui.mesh.mesh_card.conversations")," (",st(null),") ·"," ",_e(h,n)]}):N.length>0?t.jsxs(t.Fragment,{children:[t.jsx(pe,{className:"my-1"}),t.jsx("ul",{className:"m-0 flex list-none flex-col gap-0.5 p-0",children:N.slice(0,Ke).map(j=>t.jsxs("li",{"data-mesh-row-session":j.id,className:"flex items-center gap-2 py-0.5",children:[t.jsx("span",{className:"min-w-0 flex-1 truncate text-meta text-ink-muted",children:j.name||j.id}),t.jsx("span",{className:"shrink-0 text-meta text-ink-dim",children:ea(j,u)}),t.jsx(ot,{session:j,destinations:lt(e,j,u),disabled:!m,onChoose:(_,A)=>o(j,_,A),trigger:t.jsx(nt,{"aria-hidden":"true",className:"size-3.5"}),triggerLabel:a("ui.mesh.mesh_list.move_conversation",{conversation:j.name||j.id})})]},j.id))}),b>N.slice(0,Ke).length&&t.jsx("button",{type:"button",onClick:()=>f(h.id),className:"w-fit text-meta text-ink-dim hover:text-ink",children:a("ui.mesh.mesh_list.show_all_panel",{count:b})})]}):t.jsx("span",{className:"text-meta text-ink-dim",children:a("ui.mesh.mesh_list.conversation_count",{count:b})}),(C||h.state!=="self")&&t.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[t.jsx(ee,{size:"sm",variant:"ghost","data-mesh-invite":h.id,onClick:()=>v({deviceId:h.id,deviceName:h.name}),children:a("ui.mesh.mesh_actions.invite_to_a_network")}),C&&t.jsxs(ee,{size:"sm",variant:"ghost","data-mesh-remove-member":`${d.id}:${h.id}`,onClick:()=>y({networkId:d.id,networkLabel:d.label,deviceId:h.id,deviceName:h.name}),children:[a("ui.mesh.mesh_card.remove_from"),d.label,"…"]})]})]},h.id)})})]},d.id)),e.unmatchedPeers.length>0&&t.jsxs("p",{className:"text-meta text-warning",children:[a("ui.mesh.mesh_graph.device_count",{count:e.unmatchedPeers.length})," ",a("ui.mesh.mesh_list.answered_the_peer_read_but_is_in")]})]})},sa=({revoked:e})=>{if(e.length===0)return null;const n=a("ui.mesh.mesh_list.revoked_count",{count:e.length});return t.jsx(ke,{className:"contents",chevron:"trailing",chevronClassName:"text-ink-dim",rowClassName:"min-h-auto py-0",triggerClassName:"inline-flex w-auto items-center gap-1 align-baseline text-meta text-ink-dim hover:text-ink",triggerData:{"data-mesh-revoked-toggle":""},triggerLabel:a("ui.mesh.mesh_list.revoked_toggle_label"),summary:t.jsxs(t.Fragment,{children:[t.jsx("span",{"aria-hidden":"true",className:"inline-block whitespace-pre",children:" · "}),n]}),children:t.jsx("ul",{"data-mesh-revoked":"",className:"m-0 flex list-none flex-col gap-1 p-0",children:e.map(s=>t.jsxs("li",{"data-mesh-revoked-member":s.deviceId,className:"flex flex-wrap items-baseline gap-x-2 text-meta text-ink-dim",children:[t.jsx("span",{children:s.networkName}),t.jsx("span",{className:"font-mono text-body-sm text-ink",children:s.deviceId}),t.jsx("span",{className:"text-body-sm text-ink-muted",children:s.label}),t.jsxs("span",{children:[s.role?`${s.role} · `:"",a("ui.mesh.mesh_graph.revoked_membership")]})]},`${s.networkId}:${s.deviceId}`))})})},aa=["canvas","list"],na={get canvas(){return a("ui.mesh.mesh_page.canvas")},get list(){return a("ui.mesh.mesh_page.list")}},ia=({state:e,initialPresentation:n="canvas",graph:s,nowSeconds:i,checking:u,staleError:m,onRetry:f,approvals:o,sessions:v,sessionError:y,selfLabel:w,movingSessionId:R,canMove:M,pendingMove:d,onAskMove:c,onDropRefused:h,onChooseMove:C,onCancelMove:S,moveBusy:D,moveReport:N,onDismissReport:b,onWaitForIdle:P,onUndoCopy:E,invite:I,onOpenInvite:j,onInvite:_,onCloseInvite:A,inviteBusy:Z,inviteReceipt:V,inviteRefusal:x,remove:L,onOpenRemove:W,onRemove:G,onCloseRemove:Y,removeBusy:te,removeRefusal:$,removed:se})=>{K();const[q,ne]=p.useState(n),[k,O]=p.useState(null),z=s?Qt(s):"",B="mesh-summary",F=es(s),J=ts(s,v,s?.selfDeviceId??null),le=p.useMemo(()=>{const l=new Map;for(const g of s?.devices??[]){const T=J.byDevice.get(g.id);l.set(g.id,T?at(T,g.sessionCount):g.sessionCount??0)}return l},[s,J]),ie=p.useCallback(l=>{O(l)},[]),he=s?s.devices.find(l=>l.id===k)??null:null,r=p.useCallback((l,g,T)=>{if(!s)return null;const U={selfDeviceId:s.selfDeviceId,devices:new Map(s.devices.map(Q=>[Q.id,Q])),networks:new Map(s.networks.map(Q=>[Q.id,Q]))},ae=l.locality==="local"?s.selfDeviceId??"":l.owner_device,Re=U.devices.get(ae),X=be({session:l,ownerDeviceId:ae,ownerLabel:Re?re(Re,s.devices.map(Q=>Q.id),!0):l.owner_device_name},{kind:"device",deviceId:g.deviceId},U);if(X.kind==="refused")return h({code:X.code,sentence:X.sentence,reach:X.reach,remedy:X.remedy,plan:X.plan??null}),null;if(X.kind==="none")return null;const Ee=T?X.alternatives.find(Q=>Q.keep)??X.plan:X.plan,dt=[X.plan,...X.alternatives].filter(Q=>Q.keep!==Ee.keep),ct={plan:Ee,alternatives:dt,risky:X.risky};c(ct)},[s,c,h]);return t.jsxs("div",{className:"flex h-full min-h-0 flex-col gap-6 overflow-y-auto p-6",children:[t.jsx(gt,{title:a("ui.mesh.mesh_page.mesh"),icon:Ae,subtitle:a("ui.mesh.mesh_page.devices_this_app_is_paired_with_and"),children:t.jsxs("div",{className:"flex items-center gap-4",children:[u&&t.jsx("output",{className:"text-meta text-ink-dim",children:a("ui.mesh.mesh_page.checking")}),(e.kind==="ready"||e.kind==="loading")&&t.jsxs("fieldset",{className:"m-0 w-fit border-0 p-0",children:[t.jsx("legend",{className:"sr-only",children:a("ui.mesh.mesh_page.presentation")}),t.jsx("div",{"data-glass-well":"",className:"flex gap-0.5 rounded-md bg-sunken p-0.5",children:aa.map(l=>t.jsx("button",{type:"button","data-mesh-presentation":l,"aria-pressed":q===l,disabled:e.kind!=="ready",onClick:()=>ne(l),className:H("h-6 rounded-sm px-3 text-body-sm text-ink-muted transition-colors duration-fast ease-out-quart","hover:text-ink","focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent focus-visible:outline-offset-2","disabled:text-ink-dim disabled:hover:text-ink-dim",q===l&&"bg-surface text-ink"),children:na[l]},l))})]})]})}),t.jsx(Ns,{rows:o.rows,error:o.error,pending:o.pending,refusal:o.decisionRefusal,onDecide:o.onDecide,onRetry:o.onRetry,nowSeconds:o.nowSeconds,credentialApprovals:o.credentialApprovals,networkNames:new Map((s?.networks??[]).map(l=>[l.id,l.label]))}),e.kind==="loading"&&t.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-3",children:[t.jsx(Le,{className:"h-4 w-64"}),t.jsx(Le,{className:"min-h-40 w-full flex-1"})]}),e.kind==="error"&&t.jsxs(we,{variant:"warning",className:"flex-col items-start gap-2",children:[t.jsx("p",{children:e.message}),t.jsx(ee,{variant:"secondary",size:"sm",onClick:f,className:"w-fit",children:a("ui.mesh.mesh_approvals_tray.ask_again")})]}),e.kind==="empty"&&t.jsx("div",{"data-glass-block":"",className:"flex min-h-0 flex-1 items-center justify-center rounded-lg border border-hairline bg-surface p-6",children:t.jsxs("div",{className:"flex flex-col items-start gap-3",children:[t.jsx("h2",{className:"text-heading text-ink",children:a("ui.mesh.mesh_page.no_network_on_this_device")}),t.jsx("p",{className:"max-w-140 text-body-sm text-ink-muted",children:a("ui.mesh.mesh_page.this_device_is_not_in_any_network")}),t.jsx("code",{className:"rounded-sm bg-sunken px-2 py-1 font-mono text-meta text-ink",children:"lop network init <name>"}),t.jsx("p",{className:"text-meta text-ink-dim",children:a("ui.mesh.mesh_page.a_network_appears_here_once_this_device")})]})}),e.kind==="ready"&&s&&t.jsx(t.Fragment,{children:t.jsxs("div",{className:"flex min-h-[22rem] flex-1 gap-4",children:[t.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col gap-3",children:[t.jsxs("div",{id:B,className:"text-meta text-ink-muted","data-mesh-summary":"",children:[t.jsx("span",{children:z}),t.jsx(sa,{revoked:s.revoked})]}),m&&t.jsx(we,{variant:"warning",children:t.jsx("p",{children:m})}),y&&t.jsx(we,{variant:"warning",children:t.jsx("p",{children:y})}),N&&t.jsx(ss,{receipt:N.kind==="moved"?{verb:N.verb,detail:N.detail,undo:N.undo}:null,refusal:N.kind==="refused"?N.refusal:null,canWait:N.kind==="refused"&&N.plan!==null,onWait:P,onRecheck:f,onUndo:E,onDismiss:b,pending:D}),q==="canvas"?t.jsx(Ks,{graph:s,slots:F,nowSeconds:i,selectedDeviceId:k,sessions:J.byDevice,sessionTotals:le,movingSessionId:R,canMove:M,onOpenDevice:ie,onAskMove:c,onDropRefused:h,onShowAllSessions:ie,summaryId:B}):t.jsx(ta,{graph:s,nowSeconds:i,selectedDeviceId:k,sessions:J.byDevice,selfLabel:w,canMove:M,onSelect:ie,onMove:r,onInvite:j,onRemove:W})]}),he&&t.jsx(Xs,{device:he,deviceIds:s.devices.map(l=>l.id),sessions:J.byDevice.get(he.id)??{rows:[],shown:[],hidden:0},sessionTotal:le.get(he.id)??0,nowSeconds:i,canMove:M,canInvite:e.kind==="ready",movingSessionId:R,destinationsFor:l=>lt(s,l,w),onClose:()=>O(null),onMove:r,onInvite:l=>j({deviceId:l.id,deviceName:l.name}),onRemoveMember:(l,g)=>{const T=s.networks.find(U=>U.id===g);W({networkId:g,networkLabel:T?.label??g,deviceId:l.id,deviceName:l.name})},onShowInList:l=>{ie(l),ne("list")}})]})}),t.jsx(as,{open:d!==null,plan:d?.plan??ra,alternatives:d?.alternatives??[],risky:d?.risky??!1,busy:D,onCancel:S,onChoose:C}),I&&t.jsx(ns,{open:I.open,options:I.options,deviceId:I.deviceId,deviceName:I.deviceName,onClose:A,onInvite:_,pending:Z,receipt:V,refusal:x}),L&&t.jsx(is,{open:L.open,networkLabel:L.networkLabel,deviceId:L.deviceId,deviceName:L.deviceName,onClose:Y,onConfirm:G,pending:te,refusal:$,removed:se})]})},ra={sessionId:"",to:"",keep:!1,verb:"",waitS:0,lost:null},fa=({initialPresentation:e})=>{K();const n=xt(),s=ge(n.data,"peers")==="enabled",i=ge(n.data,"session_transfer")==="enabled",u=rs(s,{stamp:()=>je.getState().beginAnswer()}),m=ls(s),f=os(s,{poll:!1,stamp:()=>je.getState().beginAnswer()}),o=p.useMemo(()=>({peers:u,networks:m}),[u,m]),v=ds(o),y=cs(o),w=ms(),R=ge(n.data,"approvals")==="enabled",M=us(s&&R,{poll:!1}),d=hs(),c=ge(n.data,"credential_approvals")==="enabled",h=d.isError?{approvalId:d.variables?.approvalId??null,submittedAt:d.submittedAt,...ps(d.error)}:null,C=p.useMemo(()=>Math.floor((M.dataUpdatedAt||Date.now())/1e3),[M.dataUpdatedAt]),S=je(k=>k.settlePlacement),D=xs(),N=fs(),[b,P]=p.useState(null),[E,I]=p.useState(null),[j,_]=p.useState(null),[A,Z]=p.useState(null),[V,x]=p.useState(null),[L,W]=p.useState(null),[G,Y]=p.useState(null),te=p.useMemo(()=>{const k=Math.max(u.dataUpdatedAt,m.dataUpdatedAt);return Math.floor((k||Date.now())/1e3)},[u.dataUpdatedAt,m.dataUpdatedAt]),$=p.useCallback(()=>{u.refetch(),m.refetch(),f.refetch()},[u,m,f]),se=p.useCallback((k,O)=>{P(null);const z={sessionId:k.sessionId,to:k.to,keep:k.keep,waitS:O??k.waitS};w.mutate(z,{onSuccess:B=>{if(B.kind==="moved"){const{receipt:F}=B;S(k.sessionId,F);const J=F.locality==="local"?a("ui.mesh.mesh_drop.this_device"):y?.devices.find(le=>le.id===F.owner_device)?.label??F.owner_device;I({kind:"moved",verb:F.mode==="keep"?a("ui.mesh.mesh_page.copied"):a("ui.mesh.mesh_page.moved"),detail:F.mode==="keep"?a("ui.mesh.mesh_page.copy_receipt",{destination:J,suffix:F.new_session_id.slice(-6)}):a("ui.mesh.mesh_page.move_receipt",{destination:J,retirement:F.source_retired?a("ui.mesh.mesh_page.the_copy_here_is_gone"):""}),undo:F.mode==="keep"?{sessionId:F.new_session_id,to:"local",keep:!1,verb:a("ui.mesh.mesh_page.bring_copy_back",{device:J}),waitS:0,lost:gs(J,a("ui.mesh.mesh_drop.this_device"))}:null});return}I({kind:"refused",refusal:B.refusal,plan:k})},onError:()=>{I({kind:"refused",refusal:{code:"move_failed",sentence:a("ui.mesh.mesh_page.the_move_could_not_be_sent_nothing"),status:null,unconfirmed:!1},plan:k})}})},[y,w,S]),q=p.useMemo(()=>{if(!y)return[];const k=j?.deviceId,O=k?y.devices.find(z=>z.id===k):void 0;return y.networks.filter(z=>O?!O.memberships.some(B=>B.networkId===z.id):!0).map(z=>({id:z.id,label:z.label}))},[y,j]);if(!s)return t.jsx(ft,{to:"/chat",replace:!0});const ne=v.kind==="ready"?u.error?xe(u.error):m.error?xe(m.error):null:null;return t.jsx(ia,{initialPresentation:e,state:v,graph:y,nowSeconds:te,checking:u.isFetching||m.isFetching,staleError:ne,onRetry:$,approvals:{rows:M.data??[],error:M.isError?vs(M.error):null,pending:d.isPending?d.variables??null:null,decisionRefusal:h,credentialApprovals:c,onDecide:(k,O)=>{const z=M.data?.find(F=>F.approvalId===k),B=z?bs(z,O,{credentialApprovals:c},h?.approvalId===k?h.retryable:void 0):null;B&&d.mutate({approvalId:k,decision:O,request:B})},onRetry:()=>void M.refetch(),nowSeconds:C},sessions:f.data?.rows??[],movingSessionId:w.isPending?w.variables?.sessionId??null:null,sessionError:f.isError?xe(f.error):null,selfLabel:y?.devices.find(k=>k.state==="self")?.label??a("ui.mesh.mesh_drop.this_device"),canMove:i,pendingMove:b,onAskMove:P,onDropRefused:k=>I({kind:"refused",refusal:{code:k.code,sentence:k.sentence,reach:k.reach,status:null,unconfirmed:!1},plan:k.plan}),onChooseMove:k=>se(k),onCancelMove:()=>P(null),moveBusy:w.isPending,moveReport:E,onDismissReport:()=>I(null),onWaitForIdle:()=>{E?.kind!=="refused"||!E.plan||se(E.plan,la)},onUndoCopy:()=>{E?.kind!=="moved"||!E.undo||P({plan:E.undo,alternatives:[],risky:!1})},invite:j===null?null:{open:!0,deviceId:j.deviceId,deviceName:j.deviceName,options:q},onOpenInvite:k=>{Z(null),x(null),_(k)},onInvite:k=>{D.mutate(k,{onSuccess:O=>Z(O),onError:O=>x({code:"invite_refused",sentence:xe(O),status:null,unconfirmed:!1})})},onCloseInvite:()=>_(null),inviteBusy:D.isPending,inviteReceipt:A,inviteRefusal:V,remove:L===null?null:{open:!0,networkId:L.networkId,networkLabel:L.networkLabel,deviceId:L.deviceId,deviceName:L.deviceName},onOpenRemove:k=>{Y(null),W(k)},onRemove:k=>{L&&N.mutate({networkId:L.networkId,deviceId:L.deviceId,confirm:k},{onSuccess:O=>Y(O)})},onCloseRemove:()=>W(null),removeBusy:N.isPending,removeRefusal:N.isError?{code:"remove_refused",sentence:xe(N.error),status:null,unconfirmed:!1}:null,removed:G})},la=300;export{fa as MeshPage,ia as MeshSurface,fa as default};