local-operator-ui 0.35.2 → 0.36.1

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 (96) hide show
  1. package/out/main/index.js +11857 -160
  2. package/out/preload/index.js +240 -4
  3. package/out/renderer/assets/{_basePickBy-NBZVf3x_.js → _basePickBy-Bb37xTRz.js} +1 -1
  4. package/out/renderer/assets/{_baseUniq-BpOXfy9b.js → _baseUniq-Dni9iHST.js} +1 -1
  5. package/out/renderer/assets/{agent-details-page-CI5V0mco.js → agent-details-page-CgHbzH_i.js} +1 -1
  6. package/out/renderer/assets/{agent-hub-page-C7UV5Z02.js → agent-hub-page-2Ga-oDu_.js} +1 -1
  7. package/out/renderer/assets/{agents-page-BHUCzpZE.js → agents-page-D9lw4aXB.js} +3 -3
  8. package/out/renderer/assets/{arc-DTlm2-sN.js → arc-ova03XOc.js} +1 -1
  9. package/out/renderer/assets/{architectureDiagram-IEHRJDOE-uA5hYBWO.js → architectureDiagram-IEHRJDOE-BqEEHStp.js} +1 -1
  10. package/out/renderer/assets/arrow-up-CQI5PWkj.js +6 -0
  11. package/out/renderer/assets/{blockDiagram-JOT3LUYC-Awo08lrR.js → blockDiagram-JOT3LUYC-CGDwWpMK.js} +1 -1
  12. package/out/renderer/assets/{book-open-DBUibLWP.js → book-open-BSyul6vT.js} +1 -1
  13. package/out/renderer/assets/browser-page-BokpB_3E.js +1 -0
  14. package/out/renderer/assets/{browser-webauthn-prompt-egKdqzbk.js → browser-webauthn-prompt-B6aF1Dhh.js} +1 -1
  15. package/out/renderer/assets/{c4Diagram-VJAJSXHY-DAHoIxNf.js → c4Diagram-VJAJSXHY-B_diNzWl.js} +1 -1
  16. package/out/renderer/assets/channel-BzDZCdO-.js +1 -0
  17. package/out/renderer/assets/{chunk-4BMEZGHF-QvFtu74J.js → chunk-4BMEZGHF-C9SwUS8n.js} +1 -1
  18. package/out/renderer/assets/{chunk-A2AXSNBT-EcRDJZN6.js → chunk-A2AXSNBT-DaBX04_5.js} +1 -1
  19. package/out/renderer/assets/{chunk-AEK57VVT-CKf_yBAg.js → chunk-AEK57VVT-qbLu6qUx.js} +1 -1
  20. package/out/renderer/assets/{chunk-D6G4REZN-CoixV4aq.js → chunk-D6G4REZN-DvK2vlg2.js} +1 -1
  21. package/out/renderer/assets/{chunk-RZ5BOZE2-CtEEDTp-.js → chunk-RZ5BOZE2-BJ0QjQ_v.js} +1 -1
  22. package/out/renderer/assets/{chunk-XZIHB7SX-BOgT03N8.js → chunk-XZIHB7SX-n65ojqSW.js} +1 -1
  23. package/out/renderer/assets/classDiagram-GIVACNV2-CvOU5M3P.js +1 -0
  24. package/out/renderer/assets/classDiagram-v2-COTLJTTW-CvOU5M3P.js +1 -0
  25. package/out/renderer/assets/clone-DHxQeWmi.js +1 -0
  26. package/out/renderer/assets/{console-mirror-D7dfGxrD.js → console-mirror-D0KKDQl3.js} +1 -1
  27. package/out/renderer/assets/{consoleCapture-DczATgZh.js → consoleCapture-F0nqNi_2.js} +1 -1
  28. package/out/renderer/assets/{conversation-input-sync-GlFEQKuo.js → conversation-input-sync-BaU2f8nc.js} +258 -258
  29. package/out/renderer/assets/{dagre-OKDRZEBW-CijtV3o0.js → dagre-OKDRZEBW-CE5mY9Av.js} +1 -1
  30. package/out/renderer/assets/{diagram-SSKATNLV-Dxx1RpmY.js → diagram-SSKATNLV-EmZWZBnZ.js} +1 -1
  31. package/out/renderer/assets/{diagram-VNBRO52H-DZg2hjvO.js → diagram-VNBRO52H-BgRKuGa5.js} +1 -1
  32. package/out/renderer/assets/{erDiagram-Q7BY3M3F-CjvMMGLo.js → erDiagram-Q7BY3M3F-1tQnA6hA.js} +1 -1
  33. package/out/renderer/assets/{error-boundary-CLT6U8jT.js → error-boundary-h4sP8tdS.js} +2 -2
  34. package/out/renderer/assets/{flowDiagram-4HSFHLVR-EjagIE01.js → flowDiagram-4HSFHLVR-DqCLQ87c.js} +1 -1
  35. package/out/renderer/assets/{ganttDiagram-APWFNJXF-OfsWfUyW.js → ganttDiagram-APWFNJXF-CsYNZe0u.js} +1 -1
  36. package/out/renderer/assets/{gitGraphDiagram-7IBYFJ6S-nYTyKs0s.js → gitGraphDiagram-7IBYFJ6S-DLnRaxVs.js} +1 -1
  37. package/out/renderer/assets/{graph-BnL8m22f.js → graph-BKUD4S8x.js} +1 -1
  38. package/out/renderer/assets/index-CU8sWhx0.css +1 -0
  39. package/out/renderer/assets/index-DnJx-GT2.js +829 -0
  40. package/out/renderer/assets/{index-CO7sxKWb.js → index-DsdX_gGL.js} +1 -1
  41. package/out/renderer/assets/{index-C866kR_k.js → index-JwCvHr79.js} +1 -1
  42. package/out/renderer/assets/index-jSdScOuX.js +57 -0
  43. package/out/renderer/assets/{infoDiagram-PH2N3AL5-LE2dCnxc.js → infoDiagram-PH2N3AL5-BgvR1kcA.js} +1 -1
  44. package/out/renderer/assets/{installer-Wpfa8xHM.js → installer-9-IkNP6M.js} +1 -1
  45. package/out/renderer/assets/{journeyDiagram-U35MCT3I-BhpegMd0.js → journeyDiagram-U35MCT3I-THzpQ4f_.js} +1 -1
  46. package/out/renderer/assets/{kanban-definition-NDS4AKOZ-OoMW68Bt.js → kanban-definition-NDS4AKOZ-Dkrr1AV_.js} +1 -1
  47. package/out/renderer/assets/{layout-BdaXfJXz.js → layout-BqAKXOXc.js} +1 -1
  48. package/out/renderer/assets/legacy-agents-page-6-ryob8H.js +33 -0
  49. package/out/renderer/assets/library-page-Bq2GfKjB.js +162 -0
  50. package/out/renderer/assets/{mermaid.core-DmdT5IgP.js → mermaid.core-BtMOwfxh.js} +5 -5
  51. package/out/renderer/assets/mesh-page-DCnkCtuI.js +1 -0
  52. package/out/renderer/assets/{mindmap-definition-ALO5MXBD-BCXX8n68.js → mindmap-definition-ALO5MXBD-Ci3FJP8j.js} +1 -1
  53. package/out/renderer/assets/{mini-DsJCW_H3.js → mini-BtcMFfoh.js} +1 -1
  54. package/out/renderer/assets/{notebook-pen-CAZF-xgd.js → notebook-pen--Xi3fV6p.js} +1 -1
  55. package/out/renderer/assets/{org-access-DCQGHh2Y.js → org-access-CLHvmuSm.js} +1 -1
  56. package/out/renderer/assets/{org-surface-gate-Cq3kOR7u.js → org-surface-gate-BvVBCRMH.js} +1 -1
  57. package/out/renderer/assets/{page-header-CQ6qN4O4.js → page-header-BC5wA_0S.js} +1 -1
  58. package/out/renderer/assets/{pieDiagram-IB7DONF6-BRK1MBQO.js → pieDiagram-IB7DONF6-C8ihg5ur.js} +1 -1
  59. package/out/renderer/assets/{projects-page-DpAhuoA7.js → projects-page-D0SNgdlC.js} +12 -17
  60. package/out/renderer/assets/{publication-validation-CZn6wbD0.js → publication-validation-Cz7fxfa-.js} +1 -1
  61. package/out/renderer/assets/{quadrantDiagram-7GDLP6J5-CtQwUI4m.js → quadrantDiagram-7GDLP6J5-DYzTpBbR.js} +1 -1
  62. package/out/renderer/assets/{radar-MK3ICKWK-o9_lRR0v.js → radar-MK3ICKWK-CqXcPbUD.js} +1 -1
  63. package/out/renderer/assets/{radient-auth-buttons-BWhD8ldO.js → radient-auth-buttons-FUVVHa4X.js} +1 -1
  64. package/out/renderer/assets/{requirementDiagram-KVF5MWMF-aEEiUjHx.js → requirementDiagram-KVF5MWMF-DJm-bxrM.js} +1 -1
  65. package/out/renderer/assets/{sankeyDiagram-QLVOVGJD-CtjAQQYG.js → sankeyDiagram-QLVOVGJD-Dw05QUfu.js} +1 -1
  66. package/out/renderer/assets/{schedules-page-C4-FWwsb.js → schedules-page-Czido6cv.js} +1 -1
  67. package/out/renderer/assets/{sequenceDiagram-X6HHIX6F-QOpgwrwA.js → sequenceDiagram-X6HHIX6F-CgwdpctZ.js} +1 -1
  68. package/out/renderer/assets/settings-page--rl5E5Gf.js +287 -0
  69. package/out/renderer/assets/smartart-CMc4mYHj.js +1 -0
  70. package/out/renderer/assets/{stateDiagram-DGXRK772-D99A_n2H.js → stateDiagram-DGXRK772-uxab6dZ6.js} +1 -1
  71. package/out/renderer/assets/stateDiagram-v2-YXO3MK2T-DFAfO8jf.js +1 -0
  72. package/out/renderer/assets/tags-input-chips-TaE87pEw.js +1 -0
  73. package/out/renderer/assets/{timeline-definition-BDJGKUSR-C_Op_i7D.js → timeline-definition-BDJGKUSR-C18eACei.js} +1 -1
  74. package/out/renderer/assets/ui-preferences-store-SQZFW3cf.js +1 -0
  75. package/out/renderer/assets/{use-download-agent-mutation-PP3ZbZ7V.js → use-download-agent-mutation-DavUIoqV.js} +1 -1
  76. package/out/renderer/assets/{use-memberships-query-TOFQHH-q.js → use-memberships-query-DlpZRSwv.js} +1 -1
  77. package/out/renderer/assets/{use-session-snapshot-BOMni_bJ.js → use-session-snapshot-CJ2UW6J0.js} +1 -1
  78. package/out/renderer/assets/{xychartDiagram-VJFVF3MP-Bq2H6JYU.js → xychartDiagram-VJFVF3MP-uWlww-vq.js} +1 -1
  79. package/out/renderer/console-capture.html +5 -5
  80. package/out/renderer/index.html +7 -7
  81. package/out/renderer/installer.html +4 -4
  82. package/out/renderer/mini.html +7 -7
  83. package/package.json +3 -2
  84. package/out/renderer/assets/browser-page-DuKCLrh5.js +0 -1
  85. package/out/renderer/assets/channel-BZ9uCAQo.js +0 -1
  86. package/out/renderer/assets/classDiagram-GIVACNV2-D6kkk-4_.js +0 -1
  87. package/out/renderer/assets/classDiagram-v2-COTLJTTW-D6kkk-4_.js +0 -1
  88. package/out/renderer/assets/clone-BgCd73kI.js +0 -1
  89. package/out/renderer/assets/index-CGcU9-Py.css +0 -1
  90. package/out/renderer/assets/index-Cj2bZws8.js +0 -57
  91. package/out/renderer/assets/index-p3NO0LL-.js +0 -824
  92. package/out/renderer/assets/legacy-agents-page-lVj0d18U.js +0 -33
  93. package/out/renderer/assets/mesh-page-D0-4HVNk.js +0 -1
  94. package/out/renderer/assets/settings-page-BJZ7ozTY.js +0 -287
  95. package/out/renderer/assets/stateDiagram-v2-YXO3MK2T-D0CTAsLQ.js +0 -1
  96. package/out/renderer/assets/ui-preferences-store-Dz1Kg_SA.js +0 -1
@@ -1,33 +0,0 @@
1
- import{r,j as e,t as s,c as $}from"./index-Cj2bZws8.js";import{bP as Ze,aM as Ct,bG as St,bQ as It,C as et,u as tt,ah as Re,ai as X,aK as at,aL as Dt,bR as Pt,a4 as ue,bt as Lt,bS as Et,aR as ne,aS as ye,a3 as st,bE as Tt,bT as Ot,aQ as Rt,bJ as Ee,aN as ze,a as zt,c as Ut,bL as qt,aX as $t,bz as Mt,a0 as Bt,$ as Ht,B as nt,ar as it,by as Wt,aW as Kt}from"./conversation-input-sync-GlFEQKuo.js";import{P as Qt}from"./page-header-CQ6qN4O4.js";import{c as oe,u as R,q as ot,r as rt,B as L,s as lt,w as Y,y as ct,S as ut,l as W,I as dt,x as Vt,a0 as je,L as ce,z as mt,X as ht,a1 as Gt,a2 as At,a3 as Yt,A as _e,m as Se,n as le,F as Ft,G as Jt,H as Xt,J as Zt,K as Ie,C as ea,a4 as ta,i as aa,j as sa}from"./error-boundary-CLT6U8jT.js";import{aQ as na,aR as pt,aS as Te,aT as Oe,aU as ia,aV as Ge,aW as oa,aX as ra,aH as gt,aY as se,aZ as ie,a_ as la,a$ as ca,b0 as ua,b1 as da,b2 as De,b3 as ma,aO as ha,b4 as pa,f as Ue,b5 as xt,aG as ga,ao as xa,aq as ba,au as fa,b6 as bt,b7 as ya,b8 as ft,aK as _a,b9 as ja,ba as Ae}from"./index-p3NO0LL-.js";import{N as ka}from"./notebook-pen-CAZF-xgd.js";import{e as va,g as wa,i as Na,u as Ca}from"./ui-preferences-store-Dz1Kg_SA.js";import{f as Sa}from"./use-memberships-query-TOFQHH-q.js";import{n as Pe,u as Ia,a as Da,H as Pa,p as La}from"./org-access-DCQGHh2Y.js";import{o as Ea,a as Ta}from"./org-surface-gate-Cq3kOR7u.js";import{R as Ye}from"./radient-auth-buttons-BWhD8ldO.js";import{c as Oa,i as Ra,d as za,e as Ua,t as qa,p as Fe,P as Je}from"./publication-validation-CZn6wbD0.js";import"./console-mirror-D7dfGxrD.js";/**
2
- * @license lucide-react v0.507.0 - ISC
3
- *
4
- * This source code is licensed under the ISC license.
5
- * See the LICENSE file in the root directory of this source tree.
6
- */const $a=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}]],Ma=oe("ellipsis-vertical",$a);/**
7
- * @license lucide-react v0.507.0 - ISC
8
- *
9
- * This source code is licensed under the ISC license.
10
- * See the LICENSE file in the root directory of this source tree.
11
- */const Ba=[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M2 15h10",key:"jfw4w8"}],["path",{d:"m9 18 3-3-3-3",key:"112psh"}]],Xe=oe("file-input",Ba);/**
12
- * @license lucide-react v0.507.0 - ISC
13
- *
14
- * This source code is licensed under the ISC license.
15
- * See the LICENSE file in the root directory of this source tree.
16
- */const Ha=[["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M4 7V4a2 2 0 0 1 2-2 2 2 0 0 0-2 2",key:"1vk7w2"}],["path",{d:"M4.063 20.999a2 2 0 0 0 2 1L18 22a2 2 0 0 0 2-2V7l-5-5H6",key:"1jink5"}],["path",{d:"m5 11-3 3",key:"1dgrs4"}],["path",{d:"m5 17-3-3h10",key:"1mvvaf"}]],Wa=oe("file-output",Ha);/**
17
- * @license lucide-react v0.507.0 - ISC
18
- *
19
- * This source code is licensed under the ISC license.
20
- * See the LICENSE file in the root directory of this source tree.
21
- */const Ka=[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]],Qa=oe("git-branch",Ka);/**
22
- * @license lucide-react v0.507.0 - ISC
23
- *
24
- * This source code is licensed under the ISC license.
25
- * See the LICENSE file in the root directory of this source tree.
26
- */const Va=[["path",{d:"M16 10h2",key:"8sgtl7"}],["path",{d:"M16 14h2",key:"epxaof"}],["path",{d:"M6.17 15a3 3 0 0 1 5.66 0",key:"n6f512"}],["circle",{cx:"9",cy:"11",r:"2",key:"yxgjnd"}],["rect",{x:"2",y:"5",width:"20",height:"14",rx:"2",key:"qneu4z"}]],Ga=oe("id-card",Va);/**
27
- * @license lucide-react v0.507.0 - ISC
28
- *
29
- * This source code is licensed under the ISC license.
30
- * See the LICENSE file in the root directory of this source tree.
31
- */const Aa=[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m8 11 4 4 4-4",key:"1dohi6"}],["path",{d:"M8 5H4a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2h-4",key:"1ywtjm"}]],Ya=oe("import",Aa),Fa=({agentId:t,agentName:n,onAgentDeleted:a,buttonSx:o={},isAgentsPage:i=!1,onViewAgentSettings:l,onChatWithAgent:u,onExportAgent:b,onClearConversation:h,onUploadAgentToHub:k})=>{R();const[_,f]=r.useState(!1),[c,d]=r.useState(!1),[m,y]=r.useState(!1),v=r.useRef(!1),S=na(),{clearAgentFromAllPages:I}=Ze(),D=async()=>{try{await S.mutateAsync(t),I(t),a?.(t)}catch(C){console.error("Failed to delete agent:",C)}finally{d(!1)}};return e.jsxs(e.Fragment,{children:[e.jsxs(ot,{open:_,onOpenChange:f,modal:!1,children:[e.jsx(rt,{asChild:!0,children:e.jsx(L,{variant:"ghost",size:"icon-sm","aria-label":s("ui.agents.dialogs.menu.accessible"),"data-tour-tag":"agent-options-button",onClick:C=>{C.stopPropagation(),C.detail===0&&f(E=>!E)},style:o,children:e.jsx(Ma,{"aria-hidden":"true"})})}),e.jsxs(lt,{align:"end",className:"min-w-45",onClick:C=>C.stopPropagation(),onInteractOutside:C=>{const E=C.detail.originalEvent.target;E instanceof Element&&E.closest(".shepherd-element")&&C.preventDefault()},onCloseAutoFocus:C=>{v.current&&(v.current=!1,C.preventDefault())},children:[i&&u&&e.jsxs(Y,{onSelect:u,children:[e.jsx(pt,{"aria-hidden":"true"}),e.jsx("span",{children:s("ui.agents.dialogs.menu.chat")})]}),!i&&l&&e.jsxs(Y,{"data-tour-tag":"view-agent-settings-menu-item",onSelect:l,children:[e.jsx(Te,{"aria-hidden":"true"}),e.jsx("span",{children:s("ui.agents.dialogs.menu.settings")})]}),b&&e.jsxs(Y,{onSelect:b,children:[e.jsx(Wa,{"aria-hidden":"true"}),e.jsx("span",{children:s("ui.agents.dialogs.menu.export")})]}),k&&e.jsxs(Y,{"data-tour-tag":"upload-to-hub-menu-item",onSelect:k,children:[e.jsx(Oe,{"aria-hidden":"true"}),e.jsx("span",{children:s("ui.agents.dialogs.menu.upload")})]}),h&&e.jsxs(Y,{className:"text-warning data-[highlighted]:bg-warning-wash",onSelect:()=>{v.current=!0,y(!0)},children:[e.jsx(ia,{"aria-hidden":"true"}),e.jsx("span",{children:s("ui.agents.dialogs.menu.clear")})]}),e.jsxs(Y,{destructive:!0,onSelect:()=>{v.current=!0,d(!0)},children:[e.jsx(Ct,{"aria-hidden":"true"}),e.jsx("span",{children:s("ui.agents.dialogs.menu.delete")})]})]})]}),e.jsx(Ge,{open:c,title:s("ui.agents.dialogs.delete.title"),message:e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-body text-ink",children:s("ui.agents.dialogs.delete.question",{name:n})}),e.jsx("p",{className:"mt-2 text-body-sm text-ink-muted",children:s("ui.agents.dialogs.delete.warning")})]}),confirmText:s("ui.agents.dialogs.delete.confirm"),cancelText:s("ui.agents.dialogs.delete.cancel"),isDangerous:!0,onConfirm:D,onCancel:()=>d(!1)}),e.jsx(Ge,{open:m,title:s("ui.agents.dialogs.clear.title"),message:s("ui.agents.dialogs.clear.warning"),confirmText:s("ui.agents.dialogs.clear.confirm"),cancelText:s("ui.agents.dialogs.clear.cancel"),isDangerous:!0,onConfirm:()=>{h?.(),y(!1)},onCancel:()=>y(!1)})]})},Ja=({page:t,count:n,onChange:a})=>{R();const o=()=>{t>1&&a(t-1)},i=()=>{t<n&&a(t+1)};return n<=1?null:e.jsxs("div",{className:"sticky bottom-0 left-0 right-0 z-10 flex min-h-13 items-center justify-between border-t border-hairline bg-surface px-4 py-2",children:[e.jsx(L,{variant:"ghost",size:"icon-sm",onClick:o,disabled:t<=1,"aria-label":s("ui.common.forms.compact_pagination.previous_page"),children:e.jsx(St,{})}),e.jsx("span",{className:"select-none text-meta text-ink-dim",children:s("ui.common.forms.pagination.position",{page:String(t),count:String(n)})}),e.jsx(L,{variant:"ghost",size:"icon-sm",onClick:i,disabled:t>=n,"aria-label":s("ui.common.forms.compact_pagination.next_page"),children:e.jsx(ct,{})})]})},yt=t=>["agent-system-prompt",t],_t=t=>{const{shouldEnableQuery:n}=It();return et({enabled:n({bypassInternetCheck:!0})&&!!t,queryKey:yt(t),queryFn:async()=>{try{const o=await Re(X.baseUrl).agents.getAgentSystemPrompt(t);if(o.status>=400)throw new Error(o.message||"Failed to fetch agent system prompt");return o.result?.system_prompt||""}catch(a){const o=a instanceof Error?a.message:"An unknown error occurred while fetching agent system prompt";throw ue(o),a}},refetchOnWindowFocus:!1,staleTime:5e3})},Xa=t=>{const n=tt(),a=Re(X.baseUrl);return at({mutationFn:async o=>{const i=Pt(o);if(i)throw ue(i),new Error(i);try{const l=await a.agents.updateAgentSystemPrompt(t,o);if(l.status>=400)throw new Error(l.message||"Failed to update agent system prompt");return l}catch(l){const u=l instanceof Error?l.message:"An unknown error occurred while updating agent system prompt";throw ue(u),l}},onSuccess:async()=>{await n.invalidateQueries({queryKey:yt(t)}),Dt("Agent system prompt updated")},onError:o=>{console.error("Error updating agent system prompt:",o)}})},Za=()=>{const[t,n]=Lt(),a=Et(),o=()=>{const l=t.get("page");return l?Number.parseInt(l,10):1},i=l=>{const u=new URLSearchParams(t);l===1?u.delete("page"):u.set("page",l.toString()),n(u)};return{page:o(),setPage:i,isView:l=>a.pathname.startsWith(`/${l}`)}},es=({open:t,onClose:n,onAgentImported:a})=>{R();const[o,i]=r.useState(null),[l,u]=r.useState(!1),[b,h]=r.useState(null),k=r.useRef(null),_=oa(),f=r.useCallback(j=>{j.preventDefault(),j.stopPropagation(),u(!0)},[]),c=r.useCallback(j=>{j.preventDefault(),j.stopPropagation(),u(!1)},[]),d=r.useCallback(j=>{j.preventDefault(),j.stopPropagation()},[]),m=r.useCallback(j=>j.name.toLowerCase().endsWith(".zip")?(h(null),!0):(h("ui.agents.dialogs.import.invalid_zip"),!1),[]),y=r.useCallback(j=>{if(j.preventDefault(),j.stopPropagation(),u(!1),j.dataTransfer.files&&j.dataTransfer.files.length>0){const T=j.dataTransfer.files[0];m(T)&&i(T)}},[m]),v=r.useCallback(j=>{if(j.target.files&&j.target.files.length>0){const T=j.target.files[0];m(T)&&i(T)}},[m]),S=r.useCallback(()=>{k.current?.click()},[]),I=async()=>{if(o)try{const j=await _.mutateAsync(o);i(null),h(null),a&&j&&a(j.id),n()}catch(j){console.error("Failed to import agent:",j)}},D=()=>{i(null),h(null),n()},C=_.isPending,E=C||!o,x=e.jsxs(e.Fragment,{children:[e.jsx(Xe,{size:19,className:"text-accent","aria-hidden":"true"}),s("ui.agents.dialogs.import.title")]}),w=e.jsxs(e.Fragment,{children:[e.jsx(ne,{onClick:D,disabled:C,children:s("ui.agents.dialogs.import.cancel")}),e.jsx(ye,{onClick:I,disabled:E,startIcon:C?e.jsx(ut,{}):null,children:s("ui.agents.dialogs.import.submit")})]});return e.jsxs(st,{open:t,onClose:D,title:x,actions:w,maxWidth:"sm",children:[e.jsx("p",{className:"mb-4 text-body-sm text-ink-muted",children:s("ui.agents.dialogs.import.intro")}),e.jsxs("div",{className:"flex flex-col gap-5",children:[e.jsx("input",{ref:k,type:"file",accept:".zip",onChange:v,disabled:C,className:"hidden"}),e.jsx("button",{type:"button",onClick:S,onDragEnter:f,onDragLeave:c,onDragOver:d,onDrop:y,disabled:C,className:$("cursor-pointer rounded-lg border-2 border-control border-dashed bg-surface p-4 text-center","transition-colors duration-base ease-out-quart","hover:bg-accent-wash","disabled:border-hairline disabled:bg-sunken disabled:text-ink-disabled",l&&"border-accent bg-accent-wash"),children:o?e.jsxs(e.Fragment,{children:[e.jsx(Xe,{size:32,className:"mx-auto mb-2 text-ink-muted","aria-hidden":"true"}),e.jsx("p",{className:"text-body text-ink",children:o.name}),e.jsx("p",{className:"text-body-sm text-ink-muted",children:s("ui.agents.dialogs.import.replace_file")})]}):e.jsxs(e.Fragment,{children:[e.jsx(ra,{size:32,className:"mx-auto mb-2 text-ink-muted","aria-hidden":"true"}),e.jsx("p",{className:"text-body text-ink",children:s("ui.agents.dialogs.import.drop_file")}),e.jsx("p",{className:"text-body-sm text-ink-muted",children:s("ui.agents.dialogs.import.choose_file")})]})}),b&&e.jsx("p",{role:"alert",className:"text-body-sm text-danger",children:s(b)})]})]})},ts=({title:t,searchQuery:n,onSearchChange:a,onNewAgentClick:o,searchPlaceholder:i="Search agents",newAgentTooltip:l="Create a new agent",onImportAgentClick:u,importAgentTooltip:b="Import an agent from a ZIP file"})=>e.jsxs("div",{className:"p-4",children:[e.jsxs("div",{className:"mb-3 flex items-center justify-between gap-2",children:[e.jsx("h2",{className:"truncate text-heading text-ink",children:t}),e.jsxs("div",{className:"flex shrink-0 gap-1",children:[u&&e.jsx(W,{content:b,children:e.jsx(L,{variant:"ghost",size:"icon",onClick:u,"aria-label":"Import agent",children:e.jsx(Ya,{"aria-hidden":"true"})})}),e.jsx(W,{content:l,children:e.jsx(L,{variant:"primary",size:"icon",onClick:o,"aria-label":"New agent","data-tour-tag":"create-new-agent-button",children:e.jsx(gt,{"aria-hidden":"true"})})})]})]}),e.jsxs("div",{className:"relative",children:[e.jsx(Tt,{size:16,"aria-hidden":"true",className:"pointer-events-none absolute top-1/2 left-3 -translate-y-1/2 text-ink-dim"}),e.jsx(dt,{type:"search",inputSize:"lg",placeholder:i,value:n,onChange:h=>a(h.target.value),"aria-label":i,className:"pl-9"})]})]}),N={temperature:.2,top_p:.9,top_k:40,max_tokens:4096,frequency_penalty:0,presence_penalty:0,seed:42},A=({label:t,description:n,defaultLabel:a,onSet:o})=>(R(),e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-baseline gap-2",children:[e.jsx("span",{className:"text-body-sm text-ink",children:t}),e.jsx("span",{className:"text-meta text-ink-dim",children:s("ui.agents.settings.chat.not_set_yet")})]}),e.jsx("p",{className:"mt-1 text-meta text-ink-dim",children:n})]}),e.jsx(L,{variant:"secondary",size:"sm",className:"shrink-0",onClick:o,children:s("ui.agents.settings.chat.set_to_default",{value:String(a)})})]})),Le=({title:t,children:n})=>e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx("h3",{className:"text-body-sm font-semibold text-ink-muted",children:t}),n]}),as=({selectedAgent:t,savingField:n,setSavingField:a,updateAgentMutation:o,refetchAgent:i,initialSelectedAgentId:l})=>{R();const[u,b]=r.useState(t);r.useEffect(()=>{b(t)},[t]);const[h,k]=r.useState(!1),_=r.useId(),f=h?Vt:ct;return e.jsxs("div",{children:[e.jsxs("h2",{className:"flex items-center gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>k(!h),"aria-expanded":h,"aria-controls":_,className:"group flex items-center gap-2 py-1 text-left text-heading text-ink",children:[e.jsx(f,{size:14,"aria-hidden":"true",className:"shrink-0 text-ink-dim transition-colors duration-fast ease-out-quart group-hover:text-ink"}),s("ui.agents.settings.chat.advanced_chat_settings")]}),e.jsx(W,{content:s("ui.agents.settings.chat.advanced_settings_to_change_how_the_agent"),children:e.jsx(L,{variant:"ghost",size:"icon-sm","aria-label":s("ui.agents.settings.chat.about_advanced_chat_settings"),children:e.jsx(je,{})})})]}),h&&e.jsxs("div",{id:_,className:"mt-3",children:[e.jsx("p",{className:"max-w-2xl text-body-sm text-ink-muted",children:s("ui.agents.settings.chat.set_custom_values_for_any_of_these")}),e.jsxs("div",{className:"mt-6 flex flex-col gap-8",children:[e.jsxs(Le,{title:s("ui.agents.settings.chat.sampling"),children:[u.temperature===null?e.jsx(A,{label:s("ui.agents.settings.chat.temperature"),description:s("ui.agents.settings.chat.controls_randomness_in_responses_0_0_1"),defaultLabel:N.temperature,onSet:async()=>{a("temperature");try{const c={temperature:N.temperature};await o.mutateAsync({agentId:t.id,update:c}),b(d=>({...d,temperature:N.temperature})),t.id===l&&i&&await i()}catch{}finally{a(null)}}}):e.jsx(se,{value:u.temperature??N.temperature,label:s("ui.agents.settings.chat.temperature"),description:s("ui.agents.settings.chat.controls_randomness_in_responses_0_0_1"),min:0,max:1,step:.01,isSaving:n==="temperature",onChange:async c=>{a("temperature");try{const d={temperature:c};await o.mutateAsync({agentId:t.id,update:d}),t.id===l&&i&&await i()}catch{}finally{a(null)}}}),u.top_p===null?e.jsx(A,{label:s("ui.agents.settings.chat.top_p"),description:s("ui.agents.settings.chat.controls_cumulative_probability_of_tokens_to_sample"),defaultLabel:N.top_p,onSet:async()=>{a("top_p");try{const c={top_p:N.top_p};await o.mutateAsync({agentId:t.id,update:c}),b(d=>({...d,top_p:N.top_p})),t.id===l&&i&&await i()}catch{}finally{a(null)}}}):e.jsx(se,{value:u.top_p??N.top_p,label:s("ui.agents.settings.chat.top_p"),description:s("ui.agents.settings.chat.controls_cumulative_probability_of_tokens_to_sample"),min:0,max:1,step:.01,isSaving:n==="top_p",onChange:async c=>{a("top_p");try{const d={top_p:c};await o.mutateAsync({agentId:t.id,update:d}),t.id===l&&i&&await i()}catch{}finally{a(null)}}}),u.top_k===null?e.jsx(A,{label:s("ui.agents.settings.chat.top_k"),description:s("ui.agents.settings.chat.limits_tokens_to_sample_from_at_each"),defaultLabel:N.top_k,onSet:async()=>{a("top_k");try{const c={top_k:N.top_k};await o.mutateAsync({agentId:t.id,update:c}),b(d=>({...d,top_k:N.top_k})),t.id===l&&i&&await i()}catch{}finally{a(null)}}}):e.jsx(se,{value:u.top_k??N.top_k,label:s("ui.agents.settings.chat.top_k"),description:s("ui.agents.settings.chat.limits_tokens_to_sample_from_at_each"),min:1,max:100,step:1,isSaving:n==="top_k",onChange:async c=>{a("top_k");try{const d={top_k:c};await o.mutateAsync({agentId:t.id,update:d}),t.id===l&&i&&await i()}catch{}finally{a(null)}}}),u.seed===null?e.jsx(A,{label:s("ui.agents.settings.chat.seed"),description:s("ui.agents.settings.chat.random_number_seed_for_deterministic_generation"),defaultLabel:N.seed,onSet:async()=>{a("seed");try{const c={seed:N.seed};await o.mutateAsync({agentId:t.id,update:c}),b(d=>({...d,seed:N.seed})),t.id===l&&i&&await i()}catch{}finally{a(null)}}}):e.jsx(ie,{value:u.seed?.toString()||"",label:s("ui.agents.settings.chat.seed"),placeholder:s("ui.agents.settings.chat.random_number_seed_for_deterministic_generation_detail"),icon:e.jsx(Te,{size:16}),isSaving:n==="seed",onSave:async c=>{a("seed");try{const d=c.trim()?Number.parseInt(c,10):void 0;if(c.trim()&&Number.isNaN(d)){ue(s("ui.agents.settings.chat.error.invalid_seed"));return}const m={seed:d};await o.mutateAsync({agentId:t.id,update:m}),t.id===l&&i&&await i()}catch{}finally{a(null)}}})]}),e.jsxs(Le,{title:s("ui.agents.settings.chat.repetition"),children:[u.frequency_penalty===null?e.jsx(A,{label:s("ui.agents.settings.chat.frequency_penalty"),description:s("ui.agents.settings.chat.reduces_repetition_by_lowering_likelihood_of_repeated"),defaultLabel:N.frequency_penalty,onSet:async()=>{a("frequency_penalty");try{const c={frequency_penalty:N.frequency_penalty};await o.mutateAsync({agentId:t.id,update:c}),b(d=>({...d,frequency_penalty:N.frequency_penalty})),t.id===l&&i&&await i()}catch{}finally{a(null)}}}):e.jsx(se,{value:u.frequency_penalty??N.frequency_penalty,label:s("ui.agents.settings.chat.frequency_penalty"),description:s("ui.agents.settings.chat.reduces_repetition_by_lowering_likelihood_of_repeated"),min:-2,max:2,step:.01,isSaving:n==="frequency_penalty",onChange:async c=>{a("frequency_penalty");try{const d={frequency_penalty:c};await o.mutateAsync({agentId:t.id,update:d}),t.id===l&&i&&await i()}catch{}finally{a(null)}}}),u.presence_penalty===null?e.jsx(A,{label:s("ui.agents.settings.chat.presence_penalty"),description:s("ui.agents.settings.chat.increases_diversity_by_lowering_likelihood_of_prompt"),defaultLabel:N.presence_penalty,onSet:async()=>{a("presence_penalty");try{const c={presence_penalty:N.presence_penalty};await o.mutateAsync({agentId:t.id,update:c}),b(d=>({...d,presence_penalty:N.presence_penalty})),t.id===l&&i&&await i()}catch{}finally{a(null)}}}):e.jsx(se,{value:u.presence_penalty??N.presence_penalty,label:s("ui.agents.settings.chat.presence_penalty"),description:s("ui.agents.settings.chat.increases_diversity_by_lowering_likelihood_of_prompt"),min:-2,max:2,step:.01,isSaving:n==="presence_penalty",onChange:async c=>{a("presence_penalty");try{const d={presence_penalty:c};await o.mutateAsync({agentId:t.id,update:d}),t.id===l&&i&&await i()}catch{}finally{a(null)}}})]}),e.jsxs(Le,{title:s("ui.agents.settings.chat.length_and_stopping"),children:[u.max_tokens===null?e.jsx(A,{label:s("ui.agents.settings.chat.max_tokens"),description:s("ui.agents.settings.chat.maximum_tokens_to_generate_in_response"),defaultLabel:N.max_tokens,onSet:async()=>{a("max_tokens");try{const c={max_tokens:N.max_tokens};await o.mutateAsync({agentId:t.id,update:c}),b(d=>({...d,max_tokens:N.max_tokens})),t.id===l&&i&&await i()}catch{}finally{a(null)}}}):e.jsx(se,{value:u.max_tokens??N.max_tokens,label:s("ui.agents.settings.chat.max_tokens"),description:s("ui.agents.settings.chat.maximum_tokens_to_generate_in_response"),min:1,max:8192,step:1,isSaving:n==="max_tokens",onChange:async c=>{a("max_tokens");try{const d={max_tokens:c};await o.mutateAsync({agentId:t.id,update:d}),t.id===l&&i&&await i()}catch{}finally{a(null)}}}),u.stop===null?e.jsx(A,{label:s("ui.agents.settings.chat.stop_sequences"),description:s("ui.agents.settings.chat.sequences_that_will_cause_the_model_to"),defaultLabel:s("ui.agents.settings.chat.empty"),onSet:async()=>{a("stop");try{const c={stop:[]};await o.mutateAsync({agentId:t.id,update:c}),b(d=>({...d,stop:[]})),t.id===l&&i&&await i()}catch{}finally{a(null)}}}):e.jsx(ie,{value:u.stop?.join(`
32
- `)||"",label:s("ui.agents.settings.chat.stop_sequences"),placeholder:s("ui.agents.settings.chat.enter_stop_sequences_one_per_line"),icon:e.jsx(Te,{size:16}),multiline:!0,rows:3,isSaving:n==="stop",onSave:async c=>{a("stop");try{const d=c.split(`
33
- `).map(y=>y.trim()).filter(y=>y.length>0),m={stop:d.length>0?d:void 0};await o.mutateAsync({agentId:t.id,update:m}),t.id===l&&i&&await i()}catch{}finally{a(null)}}})]})]})]})]})},jt=["investment","accounting","healthcare","legal","software","security","role_play","personal_assistance","education","marketing","sales","research","analysis","management","social_media","other"],be=Object.fromEntries(jt.map(t=>[t,t.split("_").map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join(" ")])),ss=({value:t,label:n,onChange:a,placeholder:o="Add category...",disabled:i=!1,icon:l})=>{const[u,b]=r.useState(""),[h,k]=r.useState(!1),[_,f]=r.useState(0),c=r.useRef(null),d=r.useRef([]),m=r.useId(),y=r.useId(),v=r.useMemo(()=>{const x=u.trim().toLowerCase();return jt.filter(w=>!t.includes(w)&&(!x||be[w].toLowerCase().includes(x)))},[t,u]);r.useEffect(()=>{h&&d.current[_]?.scrollIntoView({block:"nearest"})},[_,h]);const S=x=>{t.includes(x)||a([...t,x]),b(""),k(!1),f(0),c.current?.focus()},I=x=>{b(x.target.value),f(0),k(!0)},D=x=>{const w=v.length;switch(x.key){case"ArrowDown":if(x.preventDefault(),w===0)break;h?f((_+1)%w):(f(0),k(!0));break;case"ArrowUp":if(x.preventDefault(),w===0)break;h?f((_-1+w)%w):(f(w-1),k(!0));break;case"Enter":h&&v[_]&&(x.preventDefault(),S(v[_]));break;case"Escape":h&&(x.preventDefault(),k(!1));break;case"Home":h&&(x.preventDefault(),f(0));break;case"End":h&&(x.preventDefault(),f(v.length-1));break}},C=x=>{a(t.filter(w=>w!==x)),f(0)},E=h&&v[_]?`${y}-option-${_}`:void 0;return e.jsxs("div",{children:[e.jsxs(ce,{htmlFor:m,className:"mb-1.5 flex items-center gap-2 text-ink-muted",children:[l,n]}),e.jsxs("div",{className:$("flex min-h-11 flex-wrap items-center gap-2 rounded-sm border border-control bg-surface p-2","has-[input:focus-visible]:outline-solid has-[input:focus-visible]:outline-2","has-[input:focus-visible]:outline-accent has-[input:focus-visible]:outline-offset-2",i&&"border-hairline bg-sunken"),children:[t.map(x=>e.jsxs(mt,{className:"gap-1 pr-1 text-ink",children:[be[x]||x,e.jsx("button",{type:"button","aria-label":`Remove category ${be[x]||x}`,disabled:i,onClick:()=>C(x),className:$("rounded-xs text-ink-dim","transition-colors duration-fast ease-out-quart","hover:text-danger disabled:text-ink-disabled"),children:e.jsx(ht,{})})]},x)),e.jsxs(Gt,{open:h,onOpenChange:k,children:[e.jsx(At,{asChild:!0,children:e.jsx("input",{id:m,ref:c,type:"text",role:"combobox","aria-expanded":h,"aria-controls":y,"aria-autocomplete":"list","aria-activedescendant":E,autoComplete:"off",value:u,placeholder:o,disabled:i,"aria-label":n,onChange:I,onKeyDown:D,onClick:()=>{v.length>0&&k(!0)},className:$("min-w-20 flex-1 bg-transparent px-1 py-0.5 outline-none","text-body-sm text-ink placeholder:text-ink-dim","disabled:text-ink-disabled disabled:placeholder:text-ink-disabled")})}),e.jsx(Yt,{align:"start",sideOffset:4,onOpenAutoFocus:x=>x.preventDefault(),className:"max-h-60 w-(--radix-popover-trigger-width) overflow-y-auto p-1",children:e.jsx("div",{id:y,role:"listbox","aria-label":n,children:v.map((x,w)=>e.jsx("div",{id:`${y}-option-${w}`,ref:j=>{d.current[w]=j},role:"option","aria-selected":w===_,onMouseDown:j=>{j.preventDefault()},onMouseEnter:()=>f(w),onClick:()=>S(x),className:$("cursor-pointer rounded-sm px-3 py-1.5 font-medium text-body-sm",w===_?"bg-accent-wash":void 0,"text-ink"),children:be[x]||x},x))})})]})]}),t.length===0&&e.jsx("span",{className:"mt-1 ml-1 block text-ink-dim text-meta",children:"No categories selected"})]})},ns=({value:t,label:n,onChange:a,placeholder:o="Add tag...",disabled:i=!1,icon:l})=>{const[u,b]=r.useState(""),h=r.useRef(null),k=r.useId(),_=m=>{b(m.target.value)},f=()=>{const m=u.trim().toLowerCase();m&&!t.includes(m)&&a([...t,m]),b("")},c=m=>{m.key==="Enter"&&u.trim()?(m.preventDefault(),f()):m.key==="Backspace"&&!u&&t.length>0&&a(t.slice(0,-1))},d=m=>{a(t.filter(y=>y!==m))};return e.jsxs("div",{children:[e.jsxs(ce,{htmlFor:k,className:"mb-1.5 flex items-center gap-2 text-ink-muted",children:[l,n]}),e.jsxs("div",{className:$("flex min-h-11 flex-wrap items-center gap-2 rounded-sm border border-control bg-surface p-2","has-[input:focus-visible]:outline-solid has-[input:focus-visible]:outline-2","has-[input:focus-visible]:outline-accent has-[input:focus-visible]:outline-offset-2",i&&"border-hairline bg-sunken"),children:[t.map(m=>e.jsxs(mt,{className:"gap-1 pr-1 text-ink",children:[m,e.jsx("button",{type:"button","aria-label":`Remove tag ${m}`,disabled:i,onClick:()=>d(m),className:$("rounded-xs text-ink-dim","transition-colors duration-fast ease-out-quart","hover:text-danger disabled:text-ink-disabled"),children:e.jsx(ht,{})})]},m)),e.jsx("input",{id:k,ref:h,type:"text",value:u,onChange:_,onKeyDown:c,placeholder:o,disabled:i,"aria-label":n,className:$("min-w-20 flex-1 bg-transparent px-1 py-0.5 outline-none","text-body-sm text-ink placeholder:text-ink-dim","disabled:text-ink-disabled disabled:placeholder:text-ink-disabled")}),u.trim()&&e.jsx(L,{variant:"ghost",size:"icon-sm","aria-label":"Add tag",disabled:i,onClick:()=>{f(),h.current?.focus()},className:"text-accent hover:text-accent",children:e.jsx(gt,{})})]}),t.length===0&&!u&&e.jsx("span",{className:"mt-1 ml-1 block text-ink-dim text-meta",children:"No tags added"})]})},is=({selectedAgent:t,savingField:n,setSavingField:a,updateAgentMutation:o,refetchAgent:i,initialSelectedAgentId:l})=>{R();const{data:u,isLoading:b}=Ot(),[h,k]=r.useState("");r.useEffect(()=>{!b&&u?.values?k(t.hosting||u.values.hosting||""):b||k(t.hosting||"")},[t,u,b]);const[_,f]=r.useState(!1),[c,d]=r.useState(!1);return e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx(ie,{value:t.name,label:s("ui.agents.settings.general.agent_name"),placeholder:s("ui.agents.settings.general.enter_agent_name"),isSaving:n==="name",onSave:async m=>{if(!m.trim()){ue(s("ui.agents.settings.general.error.empty_name"));return}a("name");try{const y={name:m};await o.mutateAsync({agentId:t.id,update:y}),t.id===l&&i&&await i()}catch{}finally{a(null)}}}),e.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[e.jsx("div",{"data-tour-tag":"agent-settings-hosting-select",children:e.jsx(la,{value:t.hosting||(u?.values.hosting??""),isSaving:n==="hosting",onSave:async m=>{a("hosting"),k(m);try{const y={hosting:m,model:""};await o.mutateAsync({agentId:t.id,update:y}),t.id===l&&i&&await i()}catch{k(t.hosting||"")}finally{a(null)}},filterByCredentials:!0,allowDefault:!0},`hosting-select-${t.id}-${t.hosting||(u?.values.hosting??"default")}`)}),e.jsx("div",{"data-tour-tag":"agent-settings-model-select",children:h?e.jsx(ca,{value:t.hosting?t.model||"":t.model||(u?.values.model_name??""),hostingId:h,isSaving:n==="model",allowDefault:!0,onSave:async m=>{a("model");try{const y={model:m};await o.mutateAsync({agentId:t.id,update:y}),t.id===l&&i&&await i()}catch{}finally{a(null)}}},`model-select-${t.id}-${h}-${t.model||(!t.hosting&&u?.values.model_name?u.values.model_name:"default")}`):e.jsxs("div",{className:"relative",children:[e.jsx(W,{content:s("ui.agents.settings.general.select_a_hosting_provider_first_and_then"),children:e.jsxs("div",{className:"mb-1.5 flex w-fit items-center gap-2 text-body-sm text-ink-muted",children:[e.jsx(ua,{size:16,"aria-hidden":"true"}),s("ui.agents.settings.general.model")]})}),e.jsx("div",{className:"flex h-8 w-full items-center rounded-sm border border-control bg-surface px-3",children:e.jsx("span",{className:"truncate text-body-sm text-ink-disabled",children:s("ui.agents.settings.general.select_a_hosting_provider_first")})})]})})]}),e.jsxs("h2",{className:"mt-4 flex items-center gap-2 text-heading text-ink",children:[e.jsx(je,{size:16,className:"shrink-0 text-ink-dim"}),s("ui.agents.settings.general.agent_information")]}),e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx(ie,{value:t.description||"",label:s("ui.agents.settings.general.description"),placeholder:s("ui.agents.settings.general.enter_agent_description"),multiline:!0,rows:3,isSaving:n==="description",onSave:async m=>{a("description");try{const y={description:m};await o.mutateAsync({agentId:t.id,update:y}),t.id===l&&i&&await i()}catch{}finally{a(null)}}}),e.jsx(ns,{value:t.tags||[],label:s("ui.agents.settings.general.tags"),placeholder:s("ui.agents.settings.general.add_tag"),disabled:_,onChange:async m=>{if(!(Array.isArray(t.tags)&&m.length===t.tags.length&&m.every((y,v)=>y===t.tags?.[v]))){f(!0);try{const y={tags:m};await o.mutateAsync({agentId:t.id,update:y}),t.id===l&&i&&await i()}catch{}finally{f(!1)}}}}),e.jsx(ss,{value:t.categories||[],label:s("ui.agents.settings.general.categories"),placeholder:s("ui.agents.settings.general.add_category"),disabled:c,onChange:async m=>{if(!(Array.isArray(t.categories)&&m.length===t.categories.length&&m.every((y,v)=>y===t.categories?.[v]))){d(!0);try{const y={categories:m};await o.mutateAsync({agentId:t.id,update:y}),t.id===l&&i&&await i()}catch{}finally{d(!1)}}}}),e.jsxs(da,{children:[e.jsx(De,{label:e.jsxs(e.Fragment,{children:[e.jsx(Ga,{size:12,"aria-hidden":"true"}),s("ui.agents.settings.general.id")]}),value:e.jsx("span",{className:"font-mono text-mono-sm",children:t.id})}),e.jsx(De,{label:e.jsxs(e.Fragment,{children:[e.jsx(ma,{size:12,"aria-hidden":"true"}),s("ui.agents.settings.general.created")]}),value:Rt(t.created_date)}),e.jsx(De,{label:e.jsxs(e.Fragment,{children:[e.jsx(Qa,{size:12,"aria-hidden":"true"}),s("ui.agents.settings.general.version")]}),value:t.version})]})]})]})},os=({selectedAgent:t,savingField:n,setSavingField:a,updateAgentMutation:o,refetchAgent:i,initialSelectedAgentId:l})=>(R(),e.jsxs("div",{"data-tour-tag":"agent-settings-security",children:[e.jsxs("h2",{className:"flex items-center gap-2 text-heading text-ink",children:[e.jsx(ha,{size:16,className:"shrink-0 text-ink-dim"}),s("ui.agents.settings.security.security_instructions"),e.jsx(W,{content:s("ui.agents.settings.security.security_instructions_that_guide_the_agent_s"),children:e.jsx(L,{variant:"ghost",size:"icon-sm","aria-label":s("ui.agents.settings.security.about_security_instructions"),children:e.jsx(je,{})})})]}),e.jsx("p",{className:"mt-1 max-w-2xl text-body-sm text-ink-muted",children:s("ui.agents.settings.security.this_prompt_is_directed_to_the_ai")}),e.jsx("div",{className:"mt-4",children:e.jsx(ie,{value:t.security_prompt||"",label:"",placeholder:s("ui.agents.settings.security.enter_instructions_for_the_security_agent"),multiline:!0,rows:6,isSaving:n==="security_prompt",onSave:async u=>{a("security_prompt");try{const b={security_prompt:u};await o.mutateAsync({agentId:t.id,update:b}),t.id===l&&i&&await i()}catch{}finally{a(null)}}})})]})),rs=({selectedAgent:t,savingField:n,setSavingField:a,refetchAgent:o,initialSelectedAgentId:i})=>{R();const{data:l,isLoading:u}=_t(t.id),b=Xa(t.id),[h,k]=r.useState("");return r.useEffect(()=>{l!==void 0&&k(l)},[l]),e.jsxs("div",{"data-tour-tag":"agent-settings-system-prompt",children:[e.jsxs("h2",{className:"flex items-center gap-2 text-heading text-ink",children:[e.jsx(ka,{size:16,className:"shrink-0 text-ink-dim"}),s("ui.agents.settings.system_prompt.agent_instructions"),e.jsx(W,{content:s("ui.agents.settings.system_prompt.system_instructions_that_define_the_agent_s"),children:e.jsx(L,{variant:"ghost",size:"icon-sm","aria-label":s("ui.agents.settings.system_prompt.about_agent_instructions"),children:e.jsx(je,{})})})]}),e.jsx("p",{className:"mt-1 max-w-2xl text-body-sm text-ink-muted",children:s("ui.agents.settings.system_prompt.define_the_agent_s_role_personality_or")}),e.jsx("div",{className:"mt-4",children:e.jsx(ie,{value:h,label:"",placeholder:u?s("ui.agents.settings.system_prompt.loading_system_prompt"):s("ui.agents.settings.system_prompt.enter_instructions_for_the_agent"),multiline:!0,rows:6,isSaving:n==="system_prompt",onSave:async _=>{a("system_prompt");try{await b.mutateAsync(_),t.id===i&&o&&await o()}finally{a(null)}}})})]})},ls=({selectedAgent:t,refetchAgent:n,initialSelectedAgentId:a})=>{R();const[o,i]=r.useState(null),l=pa();return e.jsx("div",{"data-tour-tag":"agent-settings-details-paper",className:"h-full overflow-hidden",children:t?e.jsx("div",{className:"h-full overflow-y-auto",children:e.jsxs("div",{className:"mx-auto flex w-full max-w-4xl flex-col gap-8 pb-8",children:[e.jsx(is,{selectedAgent:t,savingField:o,setSavingField:i,updateAgentMutation:l,refetchAgent:n,initialSelectedAgentId:a}),e.jsx(rs,{selectedAgent:t,savingField:o,setSavingField:i,refetchAgent:n,initialSelectedAgentId:a}),e.jsx(os,{selectedAgent:t,savingField:o,setSavingField:i,updateAgentMutation:l,refetchAgent:n,initialSelectedAgentId:a}),e.jsx(as,{selectedAgent:t,savingField:o,setSavingField:i,updateAgentMutation:l,refetchAgent:n,initialSelectedAgentId:a})]})}):e.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2 p-8 text-center",children:[e.jsx(Ue,{size:48,className:"text-ink-dim","aria-hidden":"true"}),e.jsx("h2",{className:"text-heading text-ink",children:s("ui.agents.settings.agent.no_agent_selected")}),e.jsx("p",{className:"max-w-md text-body-sm text-ink-muted",children:s("ui.agents.settings.agent.select_an_agent_from_the_list_on")})]})})},qe=va()(wa(t=>({listings:{},remember:(n,a)=>{t(o=>({listings:{...o.listings,[n]:a}}))},forget:n=>{t(a=>{if(!(n in a.listings))return a;const o={...a.listings};return delete o[n],{listings:o}})}}),{name:"published-listings-storage"})),cs=t=>qe(n=>t?n.listings[t]??null:null),us=400,ds=2,ms=t=>[...t].length>=ds;function hs(t){if(!t)return{state:"unknown",builtinName:null};if(t.available)return{state:"available",builtinName:null};const n=t.details?.builtin_name??null;return t.code==="name_taken"?{state:"taken",builtinName:null}:t.code==="name_reserved_builtin"?{state:"reserved",builtinName:n}:{state:"unknown",builtinName:null}}const ps=(t,n)=>{const a=t.trim(),o=xt(a,us),i=n&&o===a&&ms(o)&&Na(o),l=et({queryKey:["agent-name-availability",o],enabled:i,queryFn:async()=>(await Ee.getAgentNameAvailability(X.baseUrl,o)).result,retry:!1,staleTime:15e3,refetchOnWindowFocus:!1});return!i||l.isPending?{state:i?"checking":"idle",builtinName:null}:l.isError?{state:"unknown",builtinName:null}:hs(l.data)},gs=()=>{const t=tt();return at({mutationFn:async({agentId:n,document:a,hubAgentId:o,target:i,policy:l})=>{if(!X.baseUrl)throw new Error("Local Operator API URL is not configured.");return o?Ee.republishAgentInstructionSet(X.baseUrl,n,o,a,i,l):Ee.publishAgentInstructionSet(X.baseUrl,n,a,i,l)},onSuccess:(n,a)=>{const o=n.result;o?.agent_id&&!a.target&&qe.getState().remember(a.agentId,{hubAgentId:o.agent_id,name:o.name,publishedAt:new Date().toISOString()}),o?.local_link_receipt&&t.invalidateQueries({queryKey:ga}),a.target?Oa(t,a.target.tenantId):Ra(t)},onError:n=>{console.error("Publishing an agent to the hub failed:",n)}})},fe="public",kt=({open:t,onClose:n,agent:a,isAuthenticated:o,onSignInSuccess:i,onPublished:l})=>{const[u,b]=r.useState(!1),[h,k]=r.useState(""),[_,f]=r.useState(null),[c,d]=r.useState(null),[m,y]=r.useState(!1),v=r.useRef(null),S=r.useRef(null),I=ze(),D=gs();R();const[C,E]=r.useState(Pe),x=r.useRef(null),w=r.useRef({open:!1,id:null}),j=cs(a?.id??null),T=zt(),z=Ut(T.data,"hub_links"),K=xa(t&&z),ke=qt(),de=$t(T.data,"radient_org"),ve=Ta(de),me=o?Ea(de,ke??null):null,{memberships:F,isError:we}=Sa({enabled:t&&o&&ve}),Z=r.useMemo(()=>Ia(F),[F]),J=r.useMemo(()=>Da(F),[F]),[M,he]=r.useState(fe),g=M!==fe,O=(K.data?.links??[]).filter(p=>p.kind==="agent"&&p.local_id===a?.id),P=O.find(p=>p.visibility===(g?"org":"public")&&p.tenant_id===(g?M:null)),B=O.find(p=>p.link_id!==P?.link_id),V=K.data?.unresolved.some(p=>p.kind==="agent"&&p.local_id===a?.id),H=Z.find(p=>p.tenant_id===M),pe=g?H?.tenant_name?s("ui.hub.links.source_private",{organization:H.tenant_name}):s("ui.hub.links.source_unavailable"):s("ui.hub.links.source_public"),re=Z.find(p=>p.tenant_id===M)?.tenant_name||"this organization",ge=r.useId(),xe=r.useId(),{data:$e}=_t(t&&a?a.id:""),{data:Me}=Mt(t);r.useEffect(()=>{t&&(!w.current.open||w.current.id!==(a?.id??null))&&k(a?.name??""),w.current={open:t,id:a?.id??null}},[t,a?.id,a?.name]),r.useEffect(()=>{t||(b(!1),f(null),d(null),y(!1),he(fe),E(Pe()),x.current=null)},[t]);const vt=r.useMemo(()=>(Me??[]).filter(p=>p.source==="builtin").map(p=>p.name),[Me]),Be=za(h,vt),He=ps(h,t&&o),ee=r.useMemo(()=>{const p=Ua({name:h,description:a?.description??"",instructions:$e??null,tools:qa(a?.tags)});return Be&&p.unshift({field:"name",message:Fe({code:"name_reserved_builtin",message:""},{name:h,hubAgentId:null}).body}),p},[h,a?.description,a?.tags,$e,Be]),U=_?Fe(_,{name:h,hubAgentId:j?.hubAgentId??null}):null,te=D.isPending,Ne=async p=>{if(!a||te||ee.length>0||g&&!H)return;f(null);const q=p?.asNewListing?null:P?.hub_id??(g?null:j?.hubAgentId??null),Ke=!!q;if(!(z&&(!K.isSuccess||B||V)))try{const G={name:h.trim()},Qe=JSON.stringify({agent:a.id,document:G,hubAgentId:q,target:M,policy:P?null:C}),Ce=x.current?.tuple===Qe?x.current:{tuple:Qe,id:crypto.randomUUID()};x.current=Ce;const ae=(await D.mutateAsync({agentId:a.id,document:G,hubAgentId:q,...z?{policy:P?{requestId:Ce.id,...P.remote_revision&&Ke?{expectedRemoteRevision:P.remote_revision}:{}}:{requestId:Ce.id,...C}}:{},target:g?{visibility:"org",tenantId:M}:void 0})).result,Ve={name:ae?.name??h.trim(),hubAgentId:ae?.agent_id??null,republished:Ke,orgName:g?re:null,localPolicies:ae?.local_link_receipt?La(ae)?"complete":"pending":z?"pending":null};d(Ve),ae&&l?.(ae,Ve.republished)}catch(G){f(Ht(G)?{code:G.code,message:G.message,details:G.details}:{message:Bt(G,"The agent could not be published. Try again.")})}},We=p=>{switch(p){case"focus-name":f(null),requestAnimationFrame(()=>{v.current?.focus(),v.current?.select()});break;case"update-listing":{const q=_?.details?.existing_agent_id??j?.hubAgentId;q&&(n(),I(`/agent-hub/${q}`));break}case"install-builtin":{const q=_?.details?.builtin_name??He.builtinName;q&&(n(),I(`/agents?kind=agent&name=${encodeURIComponent(q)}`));break}case"edit-instructions":case"edit-agent":a&&(n(),I(`/agents/${a.id}`));break;case"publish-as-new":a&&qe.getState().forget(a.id),Ne({asNewListing:!0});break;case"sign-in":y(!0);break;case"refresh-hub":n(),I("/agent-hub");break;case"retry":Ne();break}},Q=a?.name??"",wt=c?c.orgName?`Published "${Q}" to ${c.orgName}`:c.republished?`Updated the Agent hub listing for "${Q}"`:`Published "${Q}" to the Agent hub`:g?`Publish "${Q}" to ${re}?`:j?`Update the Agent hub listing for "${Q}"?`:`Publish "${Q}" to the Agent hub?`;r.useLayoutEffect(()=>{!_&&!c||S.current?.focus()},[_,c]);const Nt=c?e.jsxs(e.Fragment,{children:[e.jsx(ne,{onClick:n,"data-tour-tag":"upload-agent-dialog-cancel-button",children:"Close"}),c.hubAgentId&&e.jsx(ye,{onClick:()=>{n(),I(`/agent-hub/${c.hubAgentId}`)},children:"Open the listing"})]}):U?e.jsxs(e.Fragment,{children:[e.jsx(ne,{onClick:n,"data-tour-tag":"upload-agent-dialog-cancel-button",children:"Close"}),U.actions.map((p,q)=>q===0?e.jsx(ye,{onClick:()=>We(p),disabled:te,children:Je[p]},p):e.jsx(ne,{onClick:()=>We(p),disabled:te,children:Je[p]},p))]}):e.jsxs(e.Fragment,{children:[e.jsx(ne,{onClick:n,"data-tour-tag":"upload-agent-dialog-cancel-button",children:"Cancel"}),ee.some(p=>p.field!=="name")&&e.jsx(ne,{onClick:()=>{a&&(n(),I(`/agents/${a.id}`))},children:"Edit the agent"}),o&&e.jsx(ye,{"data-testid":"publish-submit",onClick:()=>void Ne(),disabled:g&&!H||!u||ee.length>0||!h.trim()||te||z&&(!K.isSuccess||!!B||!!V),children:te?"Publishing…":j&&!g?"Update listing":"Publish"})]});return e.jsx(st,{open:t,onClose:n,title:wt,maxWidth:"sm",fullWidth:!0,actions:Nt,dataTourTag:"upload-agent-dialog",dialogProps:{className:"outline-none"},children:e.jsxs("div",{ref:S,tabIndex:_||c?-1:void 0,className:$("flex flex-col gap-4",(_||c)&&"outline-none"),children:[o?c?e.jsxs(_e,{variant:"success","aria-live":"polite",children:[e.jsx(Se,{children:c.orgName?`Published to ${c.orgName}`:c.republished?"Listing updated":"Published to the hub"}),e.jsx(le,{children:c.orgName?`"${c.name}" is in ${c.orgName}'s shared agents as an instruction set. Its members can read and install it; nobody outside the organization can.`:c.republished?`The hub now holds the current instruction set of "${c.name}".`:`"${c.name}" is on the hub as an instruction set. Anyone can read and install it.`}),e.jsx(le,{className:"text-ink-muted",children:"Nothing else left this machine: no conversation, no execution history, no memory, no plan and no machine-specific configuration."})]}):U&&_?e.jsxs(_e,{variant:U.variant,role:"alert",children:[e.jsx(Se,{children:U.headline}),e.jsx(le,{children:U.body}),U.note&&e.jsx(le,{className:"text-ink-muted",children:U.note})]}):null:e.jsxs("div",{className:"flex flex-col items-center gap-6 text-center",children:[e.jsx("p",{className:"text-body text-ink",children:"You need to be signed in to Radient to publish agents to the Agent hub."}),e.jsx(Ye,{titleText:"Sign in to continue",descriptionText:"",onSignInSuccess:i})]}),U&&m&&e.jsxs("div",{className:"flex flex-col items-center gap-6 text-center",children:[e.jsx("p",{className:"text-body text-ink",children:"Sign in to Radient again to replace the credential the hub refused."}),e.jsx(Ye,{titleText:"Sign in again",descriptionText:"",onSignInSuccess:()=>{y(!1),f(null),i?.()}})]}),c?.localPolicies==="pending"&&e.jsx("p",{role:"alert",className:"text-body-sm text-warning",children:s("ui.hub.skills.policy_pending")}),!c&&z&&e.jsx("div",{className:"flex flex-col gap-3",children:K.isLoading?e.jsx("p",{className:"text-meta text-ink-muted",children:s("ui.hub.links.loading")}):K.error?e.jsx("p",{role:"alert",className:"text-body-sm text-warning",children:s("ui.hub.links.load_failed")}):B?e.jsx("p",{className:"text-body-sm text-warning",children:s("ui.hub.subscriptions.source_separation",{currentSource:ba(B),newSource:pe})}):V?e.jsx("p",{className:"text-body-sm text-warning",children:s("ui.hub.links.source_unavailable")}):P?e.jsx(fa,{link:P}):e.jsx(Pa,{value:C,onChange:E,source:pe,item:h||Q,visibility:g?"org":"public",organization:g?re:null,destinationKey:`${M}:${a?.id??""}`,canEnableAutoPush:!1,disabled:te||!K.isSuccess})}),!c&&!U&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-body text-ink",children:g?`You are about to publish this agent's instruction set into ${re}, where only its members can read and install it. What is published is what describes the agent:`:"You are about to publish this agent's instruction set to the public Agent hub. What is published is what describes the agent:"}),e.jsxs("ul",{className:"list-disc space-y-1 pl-5 text-body text-ink-muted",children:[e.jsx("li",{children:"Its name and description"}),e.jsx("li",{children:"Its instructions"}),e.jsx("li",{children:"Its tool surface, effort and delegation, when it has them"})]}),e.jsx("p",{className:"text-body text-ink",children:g?`Nothing else leaves this machine: no conversation, no execution history, no memory or learnings, no plan, and no machine-specific configuration. ${re}'s members can read and install what you publish; nobody outside it can.`:"Nothing else leaves this machine: no conversation, no execution history, no memory or learnings, no plan, and no machine-specific configuration. Anyone can read and install what you publish."}),Z.length>0||J.length>0?e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(ce,{htmlFor:`${ge}-target`,children:"Publish to"}),e.jsxs(Ft,{value:M,onValueChange:p=>{he(p),E(Pe()),x.current=null},children:[e.jsx(Jt,{id:`${ge}-target`,className:"w-full","data-testid":"publish-target",children:e.jsx(Xt,{})}),e.jsxs(Zt,{children:[e.jsx(Ie,{value:fe,children:"Public hub"}),Z.map(p=>e.jsx(Ie,{value:p.tenant_id,children:p.tenant_name||"Organization"},p.tenant_id)),J.map(p=>e.jsxs(Ie,{value:p.tenant_id,disabled:!0,children:[p.tenant_name||"Organization"," (upgrade needed)"]},p.tenant_id))]})]}),e.jsx("p",{className:"text-meta text-ink-muted","data-testid":"publish-target-hint",children:J.length>0?`Sharing agents inside an organization is part of the Team plan. An owner of ${J.length===1?J[0].tenant_name||"this organization":"any of the organizations marked above"} can activate it in the Radient console.`:"Public hub publications are readable by anyone. An organization's agents are readable by its members only."})]}):me?e.jsx("p",{className:"text-meta text-ink-muted","data-testid":"publish-target-unavailable",children:me}):we?e.jsx("p",{className:"text-meta text-ink-muted","data-testid":"publish-target-failed",children:"Your organizations could not be read, so this publishes to the public hub. Try again in a moment to publish into an organization."}):null,ee.length>0&&e.jsxs(_e,{variant:"danger",children:[e.jsx(Se,{children:"This agent cannot be published yet"}),e.jsx("ul",{className:"list-disc space-y-1 pl-5",children:ee.map(p=>e.jsx("li",{children:p.message},`${p.field}:${p.message}`))})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(ce,{htmlFor:xe,children:"Name on the hub"}),e.jsx(dt,{id:xe,ref:v,value:h,onChange:p=>k(p.target.value),autoComplete:"off",spellCheck:!1,"aria-invalid":ee.some(p=>p.field==="name"),"aria-describedby":`${xe}-hint`}),e.jsx("p",{id:`${xe}-hint`,className:"text-meta text-ink-muted",children:'No "/", "\\" or ":". Up to 128 characters.'}),!g&&xs(He)]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx("span",{className:"flex h-5 shrink-0 items-center",children:e.jsx(ea,{id:ge,name:"termsAgreement","data-testid":"publish-consent",checked:u,onCheckedChange:p=>b(p===!0)})}),e.jsxs(ce,{htmlFor:ge,className:"block font-normal text-body text-ink",children:["I confirm that I have read and agree to the"," ",e.jsx("a",{href:"https://radienthq.com/terms",target:"_blank",rel:"noopener noreferrer",className:"text-accent underline-offset-4 hover:text-accent-hover hover:underline",children:"terms and conditions"})," ","and that this agent does not contain malicious content or violate usage policies."]})]})]}),(c||U)&&Q&&e.jsxs("p",{className:"text-meta text-ink-muted",children:["Agent: ",Q]})]})})},xs=t=>{switch(t.state){case"checking":return e.jsx("p",{className:"text-meta text-ink-muted",children:"Checking whether this name is free…"});case"available":return e.jsx("p",{className:"text-meta text-ink-muted",children:"This name looks free."});case"taken":return e.jsx("p",{className:"text-meta text-ink",children:"This name is already published on the hub."});case"reserved":return e.jsx("p",{className:"text-meta text-ink-muted",children:t.builtinName?`The hub reserves "${t.builtinName}" for one of its built-in agents.`:"The hub reserves this name for one of its built-in agents."});default:return null}},bs=1200,fs=({agent:t,isSelected:n,onSelectAgent:a,onChatWithAgent:o,onExportAgent:i,onAgentDeleted:l,onUploadAgentToHub:u})=>{R();const b=t.description||s("ui.agents.navigation.sidebar.no_description");return e.jsxs("li",{className:"group relative",children:[e.jsxs("button",{type:"button",onClick:()=>a(t),"aria-current":n?"true":void 0,"data-tour-tag":"agent-list-item-button",className:$("flex w-full items-center gap-2 rounded-sm py-1.5 pr-9 pl-2 text-left","transition-colors duration-fast ease-out-quart",n?_a:"hover:bg-row-hover"),children:[e.jsx(aa,{className:"size-8 shrink-0",children:e.jsx(sa,{className:"border border-control bg-sunken",children:e.jsx(Ue,{size:16,"aria-hidden":!0})})}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx(W,{content:t.name,side:"top",align:"start",children:e.jsx("span",{className:"block truncate font-medium text-body-sm text-ink",children:t.name})}),e.jsx(W,{content:b,side:"bottom",align:"start",children:e.jsx("span",{className:"block truncate text-meta text-ink-dim",children:b})})]})]}),e.jsx("div",{className:$("pointer-events-none absolute top-0 right-1 flex h-full items-center","opacity-0 transition-opacity duration-fast ease-out-quart","group-hover:pointer-events-auto group-hover:opacity-100","group-focus-within:pointer-events-auto group-focus-within:opacity-100"),children:e.jsx(W,{content:s("ui.agents.navigation.sidebar.options"),children:e.jsx("span",{children:e.jsx(Fa,{agentId:t.id,agentName:t.name,isAgentsPage:!0,onAgentDeleted:()=>l(t.id),onChatWithAgent:()=>o(t),onExportAgent:()=>i(t.id),onUploadAgentToHub:()=>u(t),buttonSx:{width:24,height:24,borderRadius:"6px",display:"flex",justifyContent:"center",alignItems:"center"}})})})})]})},ys=(t,n)=>t.isSelected===n.isSelected&&t.agent.id===n.agent.id&&t.agent.name===n.agent.name&&t.agent.description===n.agent.description&&t.onSelectAgent===n.onSelectAgent&&t.onChatWithAgent===n.onChatWithAgent&&t.onExportAgent===n.onExportAgent&&t.onAgentDeleted===n.onAgentDeleted&&t.onUploadAgentToHub===n.onUploadAgentToHub,_s=r.memo(fs,ys),js=({selectedAgentId:t,onSelectAgent:n})=>{const a=ze();R();const[o,i]=r.useState(""),l=Ca(g=>g.openCreateAgentDialog),u=xt(o.trim(),250),[b,h]=r.useState(!1),k=50,[_,f]=r.useState(!1),[c,d]=r.useState(null),{isAuthenticated:m}=nt(),y=r.useMemo(()=>Re(X.baseUrl),[]),v=bt(),{page:S,setPage:I}=Za(),{data:D,isLoading:C,isError:E,refetch:x}=ya(S,k,0,u||void 0,"created_date","desc"),w=D?.agents||[],j=D?.total||0,{data:T}=ft(t&&!w.find(g=>g.id===t)?t:void 0),z=r.useMemo(()=>{const g=[...w];return T&&!g.find(O=>O.id===T.id)&&g.push(T),g.sort((O,P)=>new Date(P.created_date).getTime()-new Date(O.created_date).getTime()),g},[w,T]),K=r.useCallback(g=>{I(g)},[I]),ke=r.useCallback(g=>{n(g)},[n]),de=r.useCallback(()=>{h(!0)},[]),ve=r.useCallback(()=>{h(!1)},[]),me=r.useCallback(async g=>{try{const O=await v.mutateAsync(g),P=z.find(pe=>pe.id===g),B=P?P.name.replace(/\s+/g,"-").toLowerCase():g,V=URL.createObjectURL(O),H=document.createElement("a");H.href=V,H.download=`${B}-export.zip`,document.body.appendChild(H),H.click(),URL.revokeObjectURL(V),document.body.removeChild(H)}catch(O){console.error("Failed to export agent:",O)}},[z,v]),F=r.useCallback(g=>{d(g),f(!0)},[]),we=r.useCallback(()=>{f(!1),d(null)},[]),Z=r.useCallback(async g=>{try{const P=((await x()).data?.agents||[]).find(V=>V.id===g);if(P){n(P);return}const B=await y.agents.getAgent(g);B.status<400&&B.result&&n(B.result)}catch(O){console.error("Error selecting newly created agent:",O)}},[n,x,y]),J=r.useCallback(g=>{it.getState().stageDraft({kind:"agent",name:g.name}),a("/chat")},[a]),M=r.useCallback(g=>{x(),a("/agents")},[t,x,a]),he=r.useCallback(g=>{F(g)},[F]);return e.jsxs("div",{"data-glass-region":"page-sidebar",className:"flex h-full w-full flex-col overflow-hidden bg-surface",children:[e.jsx(ts,{title:s("ui.agents.navigation.sidebar.title"),searchQuery:o,onSearchChange:g=>i(g),onNewAgentClick:l,onImportAgentClick:de,importAgentTooltip:s("ui.agents.navigation.sidebar.import_hint")}),C?e.jsx("div",{className:"flex flex-1 items-center justify-center",children:e.jsx(ut,{size:"lg",label:s("ui.agents.navigation.sidebar.loading")})}):E?e.jsxs(_e,{variant:"danger",role:"alert",className:"m-4 w-auto",children:[e.jsx(le,{children:s("ui.agents.navigation.sidebar.error")}),e.jsx(L,{variant:"ghost",size:"sm",className:"self-start",onClick:()=>x(),children:s("ui.agents.navigation.sidebar.retry")})]}):z.length===0&&!C?e.jsx("p",{className:"p-6 text-center text-body-sm text-ink-muted",children:o?s("ui.agents.navigation.sidebar.search_empty"):s("ui.agents.navigation.sidebar.empty")}):e.jsx(ta,{delayDuration:bs,skipDelayDuration:0,children:e.jsx("ul",{className:"flex min-h-0 flex-1 flex-col gap-1 overflow-y-auto p-2",children:z.map(g=>e.jsx(_s,{agent:g,isSelected:t===g.id||T?.id===g.id,onSelectAgent:ke,onChatWithAgent:J,onExportAgent:me,onAgentDeleted:M,onUploadAgentToHub:he},g.id))})}),e.jsx(es,{open:b,onClose:ve,onAgentImported:Z}),j>0&&e.jsx(Ja,{page:S,count:Math.max(1,Math.ceil(j/k)),onChange:K}),e.jsx(kt,{open:_,onClose:we,agent:c,isAuthenticated:m})]})},ks=r.memo(js),Us=()=>{R();const t=Wt("surface"),{agentId:n,navigateToAgent:a}=ja(),o=ze(),{isAuthenticated:i}=nt(),[l,u]=r.useState(!1),b=bt(),{setLastAgentsPageAgentId:h,getLastAgentId:k}=Ze(),_=n||k("agents"),{data:f,refetch:c}=ft(_||void 0);r.useEffect(()=>{n&&h(n)},[n,h]);const d=async()=>{if(f)try{const S=await b.mutateAsync(f.id),I=URL.createObjectURL(S),D=document.createElement("a");D.href=I,D.download=`${f.name.replace(/\s+/g,"-").toLowerCase()}-lo-agent.zip`,document.body.appendChild(D),D.click(),URL.revokeObjectURL(I),document.body.removeChild(D)}catch(S){console.error("Failed to export agent:",S)}},m=()=>{u(!0)},y=()=>{u(!1)},v=S=>{h(S.id),a(S.id,"agents")};return e.jsxs("div",{"data-glass-split":"",className:"flex h-full w-full overflow-hidden",children:[e.jsx("div",{ref:t,className:"h-full w-70 shrink-0",children:e.jsx(ks,{selectedAgentId:f?.id,onSelectAgent:v})}),e.jsx("div",{"data-glass-region":"canvas-content",className:"h-full grow overflow-hidden",children:e.jsxs("div",{className:"flex h-full flex-col gap-8 p-4 sm:p-6 lg:p-8",children:[e.jsx("div",{className:"mx-auto w-full max-w-4xl",children:e.jsx(Qt,{title:s("ui.agents.navigation.legacy.title"),icon:Ue,subtitle:s("ui.agents.navigation.legacy.subtitle"),children:f&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(ot,{children:[e.jsx(rt,{asChild:!0,children:e.jsx(L,{"data-tour-tag":"upload-to-hub-header-button",variant:"secondary",size:"icon","aria-label":s("ui.agents.navigation.legacy.more_actions"),className:"@min-[400px]:hidden",children:e.jsx(Kt,{"aria-hidden":"true"})})}),e.jsxs(lt,{align:"end",className:"min-w-45",children:[e.jsxs(Y,{disabled:b.isPending,onSelect:d,children:[e.jsx(Ae,{"aria-hidden":"true"}),e.jsx("span",{children:s("ui.agents.navigation.legacy.export")})]}),e.jsxs(Y,{onSelect:m,children:[e.jsx(Oe,{"aria-hidden":"true"}),e.jsx("span",{children:s("ui.agents.navigation.legacy.upload")})]})]})]}),e.jsxs(L,{variant:"secondary",onClick:d,disabled:b.isPending,className:"hidden @min-[400px]:inline-flex",children:[e.jsx(Ae,{"aria-hidden":"true"}),s("ui.agents.navigation.legacy.export")]}),e.jsxs(L,{"data-tour-tag":"upload-to-hub-header-button","data-tour-action":"open-upload-dialog",variant:"secondary",onClick:m,className:"hidden @min-[400px]:inline-flex",children:[e.jsx(Oe,{"aria-hidden":"true"}),s("ui.agents.navigation.legacy.upload")]}),e.jsx(W,{content:s("ui.agents.navigation.legacy.chat_named",{name:f.name||s("ui.agents.navigation.legacy.unnamed_agent")}),children:e.jsxs(L,{variant:"primary",onClick:()=>{it.getState().stageDraft({kind:"agent",name:f.name}),o("/chat")},children:[e.jsx(pt,{"aria-hidden":"true"}),s("ui.agents.navigation.legacy.chat")]})})]})})}),e.jsx("div",{className:"min-h-0 grow overflow-hidden",children:e.jsx(ls,{selectedAgent:f??null,refetchAgent:c,initialSelectedAgentId:n})})]})}),f&&e.jsx(kt,{open:l,onClose:y,agent:f,isAuthenticated:i})]})};export{Us as LegacyAgentsPage};
@@ -1 +0,0 @@
1
- import{r as g,j as t,t as a,c as L}from"./index-Cj2bZws8.js";import{aT as He,aU as ye,aV as et,aW as qe,a as tt,aX as be,ar as Ce,aY as st}from"./conversation-input-sync-GlFEQKuo.js";import{P as nt}from"./page-header-CQ6qN4O4.js";import{u as W,B as G,A as fe,p as at,h as re,q as it,r as rt,s as lt,t as ot,v as Se,w as Me,k as Ee}from"./error-boundary-CLT6U8jT.js";import{i as ce,h as dt,j as ct,k as ut,l as mt,m as ht,o as pt,p as xt,q as ft,s as gt,t as vt,v as bt,x as _t,N as kt,y as je,z as wt,C as ue,D as yt,E as jt,F as Nt,G as Ne,H as Fe,R as It,I as me,J as Ye,K as Be,L as Ct,M as xe,O as _e,Q as St,T as Mt,U as ge,V as De,W as Et,X as Dt,Y as ke,Z as Rt,_ as Ue,$ as At,a0 as Ge,a1 as Lt,a2 as Pt,a3 as Tt,a4 as Ot,a5 as $t,a6 as zt,a7 as Wt,a8 as Ht,a9 as qt,aa as Ft,ab as Yt,ac as Bt,ad as Ut,ae as Gt,af as Vt,ag as Kt,ah as Xt,ai as Zt,aj as Jt,ak as de,al as Qt}from"./index-p3NO0LL-.js";import"./ui-preferences-store-Dz1Kg_SA.js";import"./console-mirror-D7dfGxrD.js";function es(e){return e==="failed"?"text-danger":ce(e)?"text-ink-muted":"text-ink-dim"}function ts(e){return e==="failed"?a("ui.mesh.mesh_approvals_tray.abandon"):a("ui.mesh.mesh_approvals_tray.stop")}function ss(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:s,pending:r,refusal:i,onDecide:d,onRetry:u,nowSeconds:x,networkNames:l})=>{W();const v=r!==null,_=g.useMemo(()=>e.filter(h=>ce(h.state)),[e]),j=g.useMemo(()=>e.filter(h=>!ce(h.state)),[e]),[I,C]=g.useState(!1),o=g.useRef(null),c=g.useRef(null),f=g.useRef(null),N=(h,D)=>{D==="deny"&&_.some(S=>S.approvalId===h&&S.kind==="credential")&&(f.current={id:h,origin:document.activeElement,sawPending:!1}),d(h,D)};g.useLayoutEffect(()=>{const h=f.current;if(!h)return;if(r?.approvalId===h.id&&(h.sawPending=!0),i?.approvalId===h.id){f.current=null;return}const D=e.find(E=>E.approvalId===h.id);if(D?.state==="requested"){!r&&h.sawPending&&(f.current=null);return}if(D?.state==="denied"&&r||(f.current=null,D?.state!=="denied"||document.activeElement!==document.body&&document.activeElement!==h.origin))return;(_.length?o.current?.querySelector('[data-tour-tag="mesh-approval-controls"] button:not(:disabled)'):c.current?.querySelector("button"))?.focus({preventScroll:!0})},[e,r,i,_.length]);const k=j.some(h=>h.state==="failed"),p=j.filter(h=>h.state==="failed").length,M=i!==null&&e.some(h=>h.approvalId===i.approvalId&&(ce(h.state)||I));return _.length===0&&j.length===0&&!s&&!i?null:t.jsxs("section",{ref:o,"aria-label":a("ui.mesh.mesh_approvals_tray.approvals"),"data-tour-tag":"mesh-approvals-tray",className:"flex flex-col gap-3",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx(dt,{"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")}),_.length>0&&t.jsx("span",{className:"text-meta text-ink-dim",children:a("ui.mesh.mesh_approvals_tray.waiting_count",{count:_.length})})]}),s&&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:s}),t.jsx(G,{variant:"secondary",size:"sm",onClick:u,children:a("ui.mesh.mesh_approvals_tray.ask_again")})]}),_.length>0&&t.jsx("ul",{className:"flex flex-col divide-y divide-hairline",children:_.map(h=>t.jsx(Re,{row:h,pending:r?.approvalId===h.approvalId?r:null,busy:v,refusal:i?.approvalId===h.approvalId?i:null,onDecide:N,nowSeconds:x,networkNames:l},h.approvalId))}),i&&!M&&t.jsx(Ve,{refusal:i}),j.length>0&&t.jsx("div",{ref:c,children:t.jsx(He,{open:I,onOpenChange:C,chevronClassName:"text-ink-dim",className:L(_.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:["(",j.length,")"]}),k&&t.jsx("span",{"aria-hidden":"true",className:"size-1.5 rounded-full bg-danger"}),p>0&&t.jsx("span",{className:"text-danger",children:a("ui.mesh.mesh_approvals_tray.failed_count",{count:p})})]}),children:t.jsx("ul",{className:"flex flex-col divide-y divide-hairline","data-tour-tag":"mesh-approvals-records",children:j.map(h=>t.jsx(Re,{row:h,pending:r?.approvalId===h.approvalId?r:null,busy:v,refusal:i?.approvalId===h.approvalId?i:null,onDecide:N,nowSeconds:x,networkNames:l},h.approvalId))})})})]})},Re=({row:e,pending:s,busy:r,refusal:i,onDecide:d,nowSeconds:u,networkNames:x})=>{W();const l=ce(e.state),v=ct(e),_=ut(e,x),j=mt(e,x),I=ht(e),C=pt(e),o=xt(e),c=ft(e.expiresAt,u),f=e.kind==="credential"||e.kind==="unknown",N=f||e.canApproveHere===!1,k=N?[]:ss(e.state),p=gt(e),M=vt(e.state);return t.jsxs("li",{className:"flex flex-col gap-2 py-3 first:pt-0 last:pb-0","data-tour-tag":"mesh-approval-card",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("span",{className:L("text-meta",es(e.state)),children:e.kind==="credential"&&e.state==="approved"?a("ui.mesh.approval.approved_pending_apply"):bt(e.state)}),t.jsx("div",{className:"grow"}),l&&c&&t.jsx("span",{className:"text-meta text-ink-dim",children:e.kind==="credential"?a("ui.mesh.approval.request_window",{remaining:c}):c})]}),t.jsx("p",{className:"text-body-sm text-ink [overflow-wrap:anywhere]","data-tour-tag":"mesh-approval-summary",children:l?_:v}),!N&&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")}),l&&N&&t.jsx("p",{className:"text-meta text-ink-muted whitespace-pre-wrap [overflow-wrap:anywhere]","data-tour-tag":"mesh-approval-cli-remedy",children:e.approveRemedy||a("ui.mesh.approval.cli_review")}),e.kind==="credential"&&e.state==="approved"&&t.jsx("p",{className:"text-meta text-ink-muted","data-tour-tag":"mesh-approval-apply-hint",children:e.details?.length?a("ui.mesh.approval.approved_apply_hint"):a("ui.mesh.approval.approved_details_missing")}),(p||M)&&t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[p&&t.jsx(G,{variant:"primary",size:"sm",disabled:r,onClick:()=>d(e.approvalId,"approve"),"data-tour-tag":"mesh-approval-approve",children:a("ui.mesh.mesh_approvals_tray.approve")}),M&&t.jsx(G,{variant:"ghost",size:"sm",disabled:r,onClick:()=>d(e.approvalId,"deny"),"data-tour-tag":l?"mesh-approval-deny":"mesh-approval-stop",children:l?a("ui.mesh.mesh_approvals_tray.deny"):ts(e.state)}),s&&t.jsx("span",{className:"text-meta text-ink-dim",children:s.decision==="approve"?a("ui.mesh.mesh_approvals_tray.waiting_for_the_signing_prompt"):a("ui.mesh.mesh_approvals_tray.writing_the_decision")})]}),t.jsxs(He,{chevronClassName:"text-ink-dim",summary:t.jsx("span",{className:"text-meta",children:a("ui.mesh.mesh_approvals_tray.details")}),children:[f&&(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((h,D)=>t.jsx("li",{className:"whitespace-pre-wrap",children:h},`${D}:${h}`))}):t.jsx("p",{className:"text-meta text-ink-muted",children:a("ui.mesh.approval.details_unavailable")})),j.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:j.map(h=>t.jsxs(g.Fragment,{children:[t.jsx("dt",{className:"text-ink-muted",children:h.term}),t.jsx("dd",{children:h.consequence})]},h.term))}),(I||C)&&t.jsxs("p",{className:"text-meta text-ink-muted",children:[I&&t.jsx("span",{children:I}),I&&C&&t.jsx("span",{children:" · "}),C&&t.jsx("span",{className:"font-mono",children:C})]}),o&&t.jsx("p",{className:"text-meta text-ink-dim",children:o}),k.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:k.map(h=>t.jsxs(g.Fragment,{children:[t.jsx("dt",{className:"text-ink-muted",children:h.term}),t.jsx("dd",{className:"text-ink-muted",children:h.text})]},h.term))})]}),i&&t.jsx(Ve,{refusal:i})]})},Ve=({refusal:e})=>(W(),t.jsx(fe,{variant:"warning",className:"text-meta","data-tour-tag":"mesh-approval-refusal",children:t.jsxs("span",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[t.jsx("span",{className:"min-w-0 flex-1",children:e.sentence}),t.jsx("span",{className:"shrink-0 font-mono text-ink-dim",children:e.code})]})})),as=4,ve={kind:"idle"};function is(e){switch(e.kind){case"dragging":case"settling":return e.payload.session.id;case"pressing":return null;default:return null}}function te(e,s){switch(s.kind){case"press":return e.kind!=="idle"?e:{kind:"pressing",payload:s.payload,originX:s.x,originY:s.y,pointerId:s.pointerId};case"move":return e.kind==="pressing"?Math.max(Math.abs(s.x-e.originX),Math.abs(s.y-e.originY))<as?e:{kind:"dragging",payload:e.payload,x:s.x,y:s.y,target:s.target,pointerId:e.pointerId}:e.kind==="dragging"?{...e,x:s.x,y:s.y,target:s.target}:e;case"release":return e.kind==="dragging"?{kind:"settling",payload:e.payload,target:e.target}:e.kind==="pressing"?ve:e;case"cancel":case"settled":return ve;default:return e}}const rs=({edges:e,geometry:s,selectedDeviceId:r})=>t.jsx("svg",{"aria-hidden":"true",className:"pointer-events-none absolute top-0 left-0 overflow-visible",width:s.bounds.width,height:s.bounds.height,children:e.map(i=>{const d=s.networks.get(i.networkId),u=s.devices.get(i.deviceId);if(!d||!u)return null;const x=r!==null&&i.deviceId===r;return t.jsx("path",{"data-mesh-edge":i.key,d:_t(d,u),fill:"none",strokeWidth:x?2:1.5,strokeDasharray:i.active?void 0:"4 4",className:x?"stroke-ink":"stroke-ink-dim"},i.key)})}),ls={self:"border-l-hairline",reached:"border-l-hairline",unanswered:"border-l-warning","not-attempted":"border-l-hairline",unknown:"border-l-hairline"};function os(e){return e.suspect?"border-l-danger":ls[ue(e)]}const ds={self:"ring-2 ring-accent",reachable:null,unreachable:null,suspect:null},cs={accept:"border-accent bg-accent-wash",refuse:"border-warning"};function us(e,s,r){return[e.label,Be(e,s),r].filter(Boolean).join(", ")}function se(e){return e.name.trim()||e.id.slice(-6)}function Ke(e,s,r){if(r!=="reached"&&r!=="self"){const i=me(r);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:s})}const ms={resting:"border-l-2 border-l-hairline",attention:"border-l-2 border-l-warning"},hs=({network:e,x:s,y:r,refused:i})=>(W(),t.jsxs("li",{"data-mesh-network":e.id,"data-mesh-network-refused":i?"true":void 0,"data-glass-block":"",className:L("absolute flex items-center gap-2 rounded-md border bg-elevated px-3",i?"border-warning":"border-hairline"),style:{left:s,top:r,width:je,height:kt},children:[t.jsx(ye,{"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?a("ui.mesh.mesh_list.revoked_count",{count:e.revokedCount}):""]})]})]})),ps=({device:e,x:s,y:r,nowSeconds:i,selected:d,sessions:u,sessionTotal:x,dropState:l,movingSessionId:v,draggedSessionId:_,onOpen:j,onChipPointerDown:I,onChipClick:C,onShowAllSessions:o})=>{W();const{activity:c}=wt(e,u.rows),f=c==="working",N=us(e,i,f?"working":null),k=ue(e);return t.jsxs("li",{"data-mesh-device":e.id,"data-mesh-state":e.state,"data-mesh-drop":l??void 0,"aria-current":d?"true":void 0,"data-glass-block":"",className:L("absolute flex flex-col rounded-md border border-l-4 border-control bg-elevated","hover:bg-row-hover",d&&"border-y-ink border-r-ink bg-row-selected",os(e),ds[e.state],l&&cs[l]),style:{left:s,top:r,width:je,height:yt},children:[t.jsxs("button",{type:"button","data-mesh-device-open":e.id,"data-mesh-reach":k,"aria-label":N,title:Nt(e),onClick:()=>j(e.id),className:L("flex w-full flex-col justify-between rounded-t-[5px] px-3 pt-2 pb-2 text-left","cursor-pointer","focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent focus-visible:outline-offset-[-2px]"),style:{height:jt},children:[t.jsxs("span",{className:"flex w-full min-w-0 items-center gap-2",children:[t.jsx(et,{"aria-hidden":"true",className:"size-4 shrink-0 text-ink-muted"}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-body-sm text-ink",children:e.label}),e.suspect&&t.jsx(Ne,{"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:L("min-w-0 truncate text-meta",e.sessionCount===null?"text-ink-dim":"text-ink-muted"),children:Fe(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:It[k]}),t.jsx("span",{className:L("shrink-0",Ye[k]),children:me(k)}),f&&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:e.label}),className:L("m-0 flex h-6 list-none items-center gap-1 overflow-hidden px-3",l==="accept"&&"opacity-40"),children:[u.shown.map(p=>t.jsx(xs,{session:p,ownerLabel:e.label,ownerReach:k,ownerReachable:e.reachable,moving:v===p.id,dragging:_===p.id,onPointerDown:I,onClick:()=>C(p)},p.id)),u.hidden>0&&t.jsx("li",{className:"shrink-0",children:t.jsxs("button",{type:"button","data-mesh-more":e.id,onClick:()=>o(e.id),className:L("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:u.shown.length,total:x}),"aria-label":a("ui.mesh.mesh_node.show_all_conversations",{count:x}),children:["+",u.hidden]})})]})]})},xs=({session:e,ownerLabel:s,ownerReach:r,ownerReachable:i,moving:d,dragging:u,onPointerDown:x,onClick:l})=>{W();const v=Ke(e,s,r);return d?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":u?"true":void 0,children:t.jsx("button",{type:"button","data-mesh-session":e.id,style:{touchAction:"none"},title:`${se(e)} · ${v}`,"aria-label":a("ui.mesh.mesh_node.open_conversation",{conversation:se(e),fact:v,owner:s}),onPointerDown:_=>x(_,e),onClick:()=>l(e),className:L("flex min-h-6 w-full max-w-32 items-center rounded-sm border border-hairline bg-surface px-1.5 text-left text-meta text-ink-muted","cursor-grab active:cursor-grabbing","hover:text-ink",ms[Ct(e,i)],u&&"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:se(e)})})})};function Ae(e){const s=e.trim();if(!s)return null;if(s.startsWith("[")){const i=s.indexOf("]");if(i<=1)return null;const d=s.slice(1,i),u=s.slice(i+1);if(!u)return{host:d,port:null};if(!u.startsWith(":"))return null;const x=Number(u.slice(1));return{host:d,port:Number.isInteger(x)?x:null}}const r=s.lastIndexOf(":");if(r>0){const i=s.slice(r+1);if(/^\d+$/.test(i))return{host:s.slice(0,r),port:Number(i)}}return{host:s,port:null}}function Le(e){const s=e.trim().split(".");if(s.length!==4)return null;for(const r of s)if(!/^\d{1,3}$/.test(r)||Number(r)>255)return null;return`${s[0]}.${s[1]}.${s[2]}`}function fs(e){return`${e}.x`}function gs(e){const s=new Map;for(const i of e.values())for(const d of i)s.set(d,(s.get(d)??0)+1);const r=new Set;for(const[i,d]of s)d>1&&r.add(i);return r}function we(e){return new Set(e.endpoints.map(s=>s.trim()).filter(Boolean))}function vs(e,s){const r=e.filter(o=>o.id!==s),i=e.find(o=>o.id===s)??null,d=new Map;for(const o of e)d.set(o.id,we(o));const u=gs(d),x=new Set;for(const o of i?we(i):[]){if(u.has(o))continue;const c=Ae(o),f=c?Le(c.host):null;f&&x.add(f)}const l=o=>{const c=new Set;for(const f of we(o)){if(u.has(f))continue;const N=Ae(f),k=N?Le(N.host):null;k&&c.add(k)}return c},v=new Map,_=new Map;for(const o of r){const c=bs(o);if(c){v.set(c,[...v.get(c)??[],o.id]);continue}for(const f of l(o))_.set(f,[..._.get(f)??[],o.id])}const j=new Map(e.map((o,c)=>[o.id,c])),I=o=>[...o].sort((c,f)=>(j.get(c)??0)-(j.get(f)??0)),C=[];for(const[o,c]of v)C.push({prefix:o,tier:"declared",deviceIds:I(c),get words(){return a("ui.mesh.mesh_scope.declared")}});for(const[o,c]of _)x.has(o)?C.push({prefix:o,tier:"shared",deviceIds:I(c),get words(){return a("ui.mesh.mesh_scope.shared_with_this_device")}}):c.length>1&&C.push({prefix:o,tier:"probable",deviceIds:I(c),get words(){return a("ui.mesh.mesh_scope.same_prefix")}});return C.sort((o,c)=>o.tier.localeCompare(c.tier)||o.prefix.localeCompare(c.prefix))}function bs(e){for(const s of e.memberships){const r=s.scope.trim();if(r)return r}return""}const Pe={declared:0,shared:1,probable:2};function _s(e,s){const r=new Map;for(const d of e){let u=null;for(const l of d.deviceIds){const v=s.get(l);v!==void 0&&(u===null||v<u.slot)&&(u={id:l,slot:v})}if(u===null)continue;const x=r.get(u.id);x===void 0?r.set(u.id,{slot:u.slot,groups:[d]}):x.groups.push(d)}const i=d=>{let u=-1;for(const x of d.deviceIds){const l=s.get(x);l!==void 0&&l>u&&(u=l)}return u};return[...r.entries()].sort((d,u)=>d[1].slot-u[1].slot).map(([d,u])=>({deviceId:d,groups:u.groups.sort((x,l)=>i(l)-i(x)||Pe[x.tier]-Pe[l.tier]||x.prefix.localeCompare(l.prefix))}))}function ks(e){return new Map(e.map(s=>[s.deviceId,s.groups.length]))}function ws(e){return`${e.tier==="declared"?e.prefix:fs(e.prefix)} · ${e.words}`}const Te=(e,s)=>e.deviceIds.map(r=>s.devices.get(r)).filter(r=>r!==void 0),ys=({stacks:e,geometry:s})=>(W(),t.jsx("div",{"aria-hidden":"true",className:"pointer-events-none absolute top-0 left-0",children:e.map(r=>{const i=r.groups.length,d=new Array(i).fill(0);let u=null;for(let l=i-1;l>=0;l-=1){const v=Te(r.groups[l],s),_=(v.length===0?0:Math.max(...v.map(j=>j.y+j.height)))+xe;u=u===null?_:Math.max(_,u+_e),d[l]=u}const x=s.devices.get(r.deviceId);return r.groups.map((l,v)=>{const _=Te(l,s);if(_.length===0)return null;const j=i-1-v,I=Math.min(..._.map(k=>k.x)),C=Math.max(..._.map(k=>k.x)),c=(x?.y??Math.min(..._.map(k=>k.y)))-xe-St*j,f=l.tier==="declared",N=ws(l);return t.jsx("div",{"data-mesh-scope":`${l.tier}:${l.prefix}`,"data-mesh-scope-level":v,className:L("absolute rounded-lg",l.tier==="probable"?"border border-dashed border-hairline-strong":"border border-control"),style:{left:I-xe-_e*j,top:c,width:C+je-I+(xe+_e*j)*2,height:d[v]-c},children:t.jsx("span",{"data-mesh-scope-label":"",className:L("absolute bottom-full left-1 mb-0.5 whitespace-nowrap text-meta",l.tier==="probable"?"text-ink-dim":"text-ink-muted",f&&"font-medium"),children:N})},`${l.tier}:${l.prefix}`)})})})),Oe=48,$e=1.25,js=.0015,Ns=({graph:e,slots:s,nowSeconds:r,selectedDeviceId:i,sessions:d,sessionTotals:u,movingSessionId:x,canMove:l,onOpenDevice:v,onAskMove:_,onDropRefused:j,onShowAllSessions:I,summaryId:C})=>{W();const o=g.useRef(null),[c,f]=g.useState({width:0,height:0,clipWidth:0,clipHeight:0,left:0,top:0}),[N,k]=g.useState({k:1,tx:0,ty:0}),p=g.useRef(!1),M=g.useRef(!1),h=g.useRef(null),D=g.useMemo(()=>vs(e.devices,e.selfDeviceId),[e.devices,e.selfDeviceId]),S=g.useMemo(()=>_s(D,s.devices),[D,s]),E=g.useMemo(()=>Mt(s,ks(S)),[s,S]),Y=g.useMemo(()=>({selfDeviceId:e.selfDeviceId,devices:new Map(e.devices.map(n=>[n.id,n])),networks:new Map(e.networks.map(n=>[n.id,n]))}),[e]),[y,H]=g.useState(ve),ne=g.useRef({kind:"ground"}),q=g.useCallback((n,m)=>{const b=document.elementFromPoint(n,m),A=b?.closest("[data-mesh-device]");if(A){const K=A.getAttribute("data-mesh-device");if(K)return{kind:"device",deviceId:K}}const z=b?.closest("[data-mesh-network]");if(z){const K=z.getAttribute("data-mesh-network");if(K)return{kind:"network",networkId:K}}return{kind:"ground"}},[]),O=g.useMemo(()=>y.kind!=="dragging"&&y.kind!=="settling"?null:ge(y.payload,y.target,Y),[y,Y]),ae=g.useCallback(n=>{if(!O)return null;if(O.kind==="plan"){const m=y.kind==="dragging"||y.kind==="settling"?y.target:null;return m&&m.kind==="device"&&m.deviceId===n?"accept":null}if(O.kind==="refused"){const m=y.kind==="dragging"||y.kind==="settling"?y.target:null;return m&&m.kind==="device"&&m.deviceId===n?"refuse":null}return null},[O,y]),ie=g.useCallback((n,m)=>{if(!l||n.button!==0)return;M.current=!1;const b=m.locality==="local"?e.selfDeviceId??"":m.owner_device,A=Y.devices.get(b),z={session:m,ownerDeviceId:b,ownerLabel:A?.label??m.owner_device_name};try{n.currentTarget.setPointerCapture(n.pointerId)}catch{}H(K=>te(K,{kind:"press",payload:z,x:n.clientX,y:n.clientY,pointerId:n.pointerId}))},[l,Y,e.selfDeviceId]),le=n=>{if(y.kind==="pressing"||y.kind==="dragging"){const m=q(n.clientX,n.clientY);ne.current=m,H(b=>te(b,{kind:"move",x:n.clientX,y:n.clientY,target:m}));return}he(n)},oe=n=>{if(ee(n),y.kind!=="pressing"&&y.kind!=="dragging")return;if(y.kind==="pressing"){H(b=>te(b,{kind:"cancel"}));return}const m=ge(y.payload,y.target,Y);M.current=!0,H(b=>te(b,{kind:"release"})),m.kind==="plan"?_({plan:m.plan,alternatives:m.alternatives,risky:m.risky}):m.kind==="refused"&&j({code:m.code,sentence:m.sentence,remedy:m.remedy,plan:m.plan??null}),H(b=>te(b,{kind:"settled"}))};g.useEffect(()=>()=>H(ve),[]);const Q=g.useCallback(()=>{k(De(E.bounds,c))},[E.bounds,c]);g.useEffect(()=>{const n=o.current;if(!n)return;const m=()=>{const A=n.getBoundingClientRect();f({width:A.width,height:A.height,clipWidth:n.clientWidth,clipHeight:n.clientHeight,left:A.left,top:A.top})};m();const b=new ResizeObserver(m);return b.observe(n),()=>b.disconnect()},[]),g.useEffect(()=>{p.current||c.width<=0||c.height<=0||(p.current=!0,k(De(E.bounds,c)))},[c,E.bounds]),g.useEffect(()=>{const n=h.current;if(h.current={width:c.width,height:c.height},!n||!p.current||c.width<=0||c.height<=0||c.width>=n.width&&c.height>=n.height||!i)return;const m=E.devices.get(i);m&&k(b=>{const A={width:c.clipWidth,height:c.clipHeight},z=Math.max(0,Math.min(A.width-E.bounds.width*b.k,A.height-E.bounds.height*b.k));return Et(b,m,A,Math.min(Rt,z))})},[c,i,E]);const B=y.kind==="dragging"?{x:y.x-c.left+12,y:y.y-c.top+12}:{x:0,y:0},Z=O?Dt(O):null,w=g.useRef(null),R=g.useRef(null),T=g.useRef(null),$=g.useRef(null),P=g.useCallback(()=>{T.current=null;const n=w.current,m=R.current;if(w.current=null,R.current=null,n){const b=$.current;if(!b)return;k({k:b.transform.k,tx:b.transform.tx+(n.x-b.x),ty:b.transform.ty+(n.y-b.y)});return}m&&k(b=>ke(b,{x:m.x,y:m.y},b.k*Math.exp(-m.deltaY*js)))},[]),U=g.useCallback(()=>{T.current===null&&(T.current=requestAnimationFrame(P))},[P]);g.useEffect(()=>()=>{T.current!==null&&cancelAnimationFrame(T.current)},[]);const V=n=>{!(n.target===n.currentTarget)&&n.button!==1||n.button!==0&&n.button!==1||($.current={x:n.clientX,y:n.clientY,transform:N},n.currentTarget.setPointerCapture(n.pointerId),n.preventDefault())},he=n=>{$.current&&(w.current={x:n.clientX,y:n.clientY},U())},ee=n=>{$.current&&($.current=null,w.current=null,n.currentTarget.hasPointerCapture(n.pointerId)&&n.currentTarget.releasePointerCapture(n.pointerId))},J=g.useCallback(n=>{if(n.deltaY===0)return;n.preventDefault();const m=n.currentTarget.getBoundingClientRect();R.current={x:n.clientX-m.left,y:n.clientY-m.top,deltaY:n.deltaY},U()},[U]);g.useEffect(()=>{const n=o.current;if(n)return n.addEventListener("wheel",J,{passive:!1}),()=>n.removeEventListener("wheel",J)},[J]);const pe=n=>{const m=n.shiftKey?Oe*4:Oe;switch(n.key){case"Escape":if(y.kind!=="pressing"&&y.kind!=="dragging")return;n.preventDefault(),y.kind==="dragging"&&(M.current=!0),H(b=>te(b,{kind:"cancel"}));return;case"0":n.preventDefault(),Q();return;case"+":case"=":n.preventDefault(),k(b=>ke(b,{x:c.width/2,y:c.height/2},b.k*$e));return;case"-":case"_":n.preventDefault(),k(b=>ke(b,{x:c.width/2,y:c.height/2},b.k/$e));return;case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"ArrowDown":{n.preventDefault();const b=n.key==="ArrowLeft"?m:n.key==="ArrowRight"?-m:0,A=n.key==="ArrowUp"?m:n.key==="ArrowDown"?-m:0;k(z=>({...z,tx:z.tx+b,ty:z.ty+A}));return}}};return t.jsxs("div",{ref:o,"data-mesh-canvas":"",role:"group","aria-labelledby":C,tabIndex:0,onPointerDown:V,onPointerMove:le,onPointerUp:oe,onPointerCancel:n=>{y.kind==="dragging"&&(M.current=!0),H(m=>te(m,{kind:"cancel"})),ee(n)},"data-mesh-gesture":y.kind,"data-glass-well":"clear",onKeyDown:pe,onDoubleClick:n=>{n.target===n.currentTarget&&Q()},className:L("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:`${N.tx}px ${N.ty}px`}}),t.jsxs("div",{"data-mesh-world":"",className:"absolute top-0 left-0",style:{transform:`translate3d(${N.tx}px, ${N.ty}px, 0) scale(${N.k})`,transformOrigin:"0 0",width:E.bounds.width,height:E.bounds.height},children:[t.jsx(ys,{stacks:S,geometry:E}),t.jsx(rs,{edges:e.edges,geometry:E,selectedDeviceId:i}),t.jsx("ul",{"aria-label":a("ui.mesh.mesh_canvas.networks"),className:"m-0 list-none p-0",children:e.networks.map(n=>{const m=E.networks.get(n.id);return m?t.jsx(hs,{network:n,x:m.x,y:m.y,refused:O?.kind==="refused"&&y.kind==="dragging"&&y.target.kind==="network"&&y.target.networkId===n.id},n.id):null})}),t.jsx("ul",{"aria-label":a("ui.mesh.mesh_canvas.devices"),className:"m-0 list-none p-0",children:e.devices.map(n=>{const m=E.devices.get(n.id);return m?t.jsx(ps,{device:n,x:m.x,y:m.y,nowSeconds:r,selected:n.id===i,sessions:d.get(n.id)??{rows:[],shown:[],hidden:0},sessionTotal:u.get(n.id)??n.sessionCount??0,dropState:ae(n.id),movingSessionId:x,draggedSessionId:is(y),onOpen:v,onChipPointerDown:ie,onChipClick:()=>{if(M.current){M.current=!1;return}v(n.id)},onShowAllSessions:I},n.id):null})})]}),y.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:B.x,top:B.y},children:y.payload.session.name||"untitled"}),y.kind==="dragging"&&Z&&t.jsx("div",{"data-mesh-indicator":"",className:L("pointer-events-none absolute z-10 rounded-sm border bg-surface px-2 py-1 text-meta",O?.kind==="refused"?"border-warning text-warning":"border-control text-ink"),style:{left:B.x,maxWidth:Math.max(160,c.width-B.x-12),...B.y>c.height*.6?{bottom:Math.max(12,c.height-B.y+8)}:{top:B.y+24}},children:Z})]})};function Is(e,s,r,i){const d=r.locality==="local"?s:r.owner_device,u=[];for(const x of e)if(x.id!==d){if(x.id===s){u.push({deviceId:x.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}u.push({deviceId:x.id,label:x.label,verb:a("ui.mesh.mesh_card.move_to",{device:x.label}),keepVerb:a("ui.mesh.mesh_card.copy_to",{device:x.label})})}return u}function Cs(e,s,r){return Is(e.devices,e.selfDeviceId,s,r)}function Xe(e,s,r){const i=Cs(e,s,r),d={selfDeviceId:e.selfDeviceId,devices:new Map(e.devices.map(l=>[l.id,l])),networks:new Map(e.networks.map(l=>[l.id,l]))},u=s.locality==="local"?e.selfDeviceId??"":s.owner_device,x=d.devices.get(u);return i.map(l=>{const v=ge({session:s,ownerDeviceId:u,ownerLabel:x?.label??s.owner_device_name},{kind:"device",deviceId:l.deviceId},d);return{...l,refused:v.kind==="refused"&&v.code!=="busy"?v.sentence:null}})}const Ze=({session:e,destinations:s,disabled:r,onChoose:i,onOpenChange:d,trigger:u,triggerLabel:x})=>(W(),t.jsxs(it,{onOpenChange:d,children:[t.jsx(rt,{asChild:!0,children:t.jsx("button",{type:"button","aria-label":x,"data-mesh-session-menu":e.id,disabled:r||s.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:u})}),t.jsxs(lt,{align:"start",className:"min-w-56",children:[t.jsx(ot,{children:se(e)}),t.jsx(Se,{}),s.map(l=>t.jsx(Me,{"data-mesh-move-to":l.deviceId,disabled:!!l.refused,title:l.refused??void 0,onSelect:()=>i(l,!1),children:l.verb},l.deviceId)),t.jsx(Se,{}),s.map(l=>t.jsx(Me,{"data-mesh-copy-to":l.deviceId,disabled:!!l.refused,title:l.refused??void 0,onSelect:()=>i(l,!0),children:l.keepVerb},`keep-${l.deviceId}`))]})]})),Ss=({device:e,sessions:s,sessionTotal:r,nowSeconds:i,destinationsFor:d,movingSessionId:u,canMove:x,canInvite:l,onClose:v,onMove:_,onShowInList:j,onInvite:I,onRemoveMember:C})=>{W();const o=ue(e);g.useEffect(()=>{const p=M=>{M.key!=="Escape"||M.defaultPrevented||M.target?.closest('[role="menu"],[role="dialog"]')||(document.querySelector(`[data-mesh-device-open="${e.id}"]`)?.focus(),v())};return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[e.id,v]);const c=e.memberships.every(p=>!p.active),f=e.sessionCount===null?Fe(null):a("ui.mesh.mesh_card.conversation_count",{count:e.sessionCount}),N=e.suspect?Ue():[c?a("ui.mesh.mesh_card.revoked_membership"):f,me(o)].filter(Boolean).join(" · "),k=r>s.rows.length?a("ui.mesh.mesh_card.shown_of",{shown:s.rows.length,total:r}):`${s.rows.length}`;return t.jsxs("aside",{"aria-label":a("ui.mesh.mesh_card.device_details",{device:e.label}),"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(G,{size:"sm",variant:"ghost",className:"w-fit self-end","data-mesh-panel-close":"",onClick:v,children:a("ui.mesh.mesh_actions.close")}),t.jsx("h2",{className:"text-body-sm text-ink",children:e.label}),t.jsxs("p",{className:"flex items-center gap-1.5 text-meta text-ink-muted",children:[e.suspect&&t.jsx(Ne,{"aria-hidden":"true",className:"size-3.5 text-danger"}),!e.suspect&&o==="unanswered"&&t.jsx(at,{"aria-hidden":"true",className:"size-3.5 text-warning"}),N]})]}),t.jsx(re,{}),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(p=>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(ye,{"aria-hidden":"true",className:"size-3.5 text-ink-muted"}),p.networkName]}),t.jsxs("span",{className:"text-meta text-ink-dim",children:[p.role||"member",p.capabilities.length>0?` · ${p.capabilities.join(", ")}`:"",p.active?"":a("ui.mesh.mesh_card.revoked")]}),l&&p.active&&t.jsxs(G,{size:"sm",variant:"ghost",className:"w-fit","data-mesh-remove-member":`${p.networkId}:${e.id}`,onClick:()=>C(e,p.networkId),children:[a("ui.mesh.mesh_card.remove_from"),p.networkName,"…"]})]},p.networkId))}),l&&t.jsx(G,{size:"sm",variant:"secondary",className:"w-fit","data-mesh-invite":e.id,onClick:()=>I(e),children:a("ui.mesh.mesh_actions.invite_to_a_network")})]}),t.jsx(re,{}),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:["(",k,")"]})]}),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(p=>t.jsxs("li",{"data-mesh-panel-session":p.id,className:L("flex items-center gap-2 rounded-sm px-2 py-1","border border-hairline bg-elevated",u===p.id&&"border-control"),children:[t.jsx("span",{className:"min-w-0 flex-1 truncate text-body-sm text-ink",title:se(p),children:se(p)}),t.jsx("span",{className:"shrink-0 text-meta text-ink-dim",children:Ke(p,e.label,ue(e))}),u===p.id?t.jsx("span",{className:"shrink-0 text-meta text-ink-muted",children:a("ui.mesh.mesh_card.moving")}):t.jsx(Ze,{session:p,destinations:d(p),disabled:!x,onChoose:(M,h)=>_(p,M,h),trigger:t.jsx(qe,{"aria-hidden":"true",className:"size-4"}),triggerLabel:a("ui.mesh.mesh_card.move_conversation",{conversation:se(p)})})]},p.id))})]}),t.jsx(re,{}),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(p=>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:p}),t.jsx("span",{className:"shrink-0 text-meta text-ink-dim",children:a("ui.mesh.mesh_card.advertised")})]},p))})]}),t.jsx(re,{}),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:me(o)})]}),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"):At(i-e.lastSeenAt)})]})]}),e.reason&&t.jsx("p",{className:"text-meta text-warning",children:e.reason})]}),t.jsx(re,{}),t.jsx(G,{size:"sm",variant:"ghost",className:"w-fit","data-mesh-show-in-list":e.id,onClick:()=>j(e.id),children:a("ui.mesh.mesh_card.show_in_list")})]})},Ms=["name","chats","state"],Es={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")}},ze={suspect:0,unreachable:1,self:2,reachable:3};function Ds(e,s){const r=[...e];switch(s){case"chats":return r.sort((i,d)=>(d.sessionCount??-1)-(i.sessionCount??-1)||i.label.localeCompare(d.label)),r;case"state":return r.sort((i,d)=>ze[i.state]-ze[d.state]||i.label.localeCompare(d.label)),r;default:return r.sort((i,d)=>i.label.localeCompare(d.label))}}const We=8;function Rs(e,s){if(e.locality==="local")return e.live_state||"here";const r=e.owner_device_name||s,i=e.live_state?` · ${e.live_state}`:"";return e.reachable?a("ui.mesh.mesh_list.on_device_state",{device:r,state:i}):a("ui.mesh.mesh_list.on_device_no_answer",{device:r})}const As=({graph:e,nowSeconds:s,selectedDeviceId:r,sessions:i,selfLabel:d,canMove:u,onSelect:x,onMove:l,onInvite:v,onRemove:_})=>{W();const[j,I]=g.useState("name"),C=g.useMemo(()=>e.networks.map(o=>({network:o,members:Ds(e.devices.filter(c=>c.memberships.some(f=>f.networkId===o.id)),j)})),[e,j]);return t.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto pr-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:Ms.map(o=>t.jsx("button",{type:"button","aria-pressed":j===o,onClick:()=>I(o),className:L("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",j===o&&"bg-surface text-ink"),children:Es[o]},o))})]}),C.map(({network:o,members:c})=>t.jsxs("section",{"data-mesh-network-group":o.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:o.epoch}),children:[o.label,t.jsxs("span",{className:"text-meta text-ink-dim",children:[o.trust," ·"," ",a("ui.mesh.mesh_graph.device_count",{count:o.memberCount}),o.revokedCount>0?a("ui.mesh.mesh_list.revoked_count",{count:o.revokedCount}):""]})]}),t.jsx("ul",{className:"m-0 flex list-none flex-col gap-1 p-0",children:c.map(f=>{const N=f.memberships.find(S=>S.networkId===o.id),k=f.id===r,p=i.get(f.id),M=p?.rows??[],h=p?Ge(p,f.sessionCount):f.sessionCount??0,D=ue(f);return t.jsxs("li",{"data-mesh-device-row":f.id,"data-mesh-state":f.state,"aria-current":k?"true":void 0,className:L("flex flex-col gap-1 rounded-md px-3 py-2","border border-hairline bg-surface",k&&"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":f.id,onClick:()=>x(f.id),className:L("min-w-0 flex-1 truncate text-left 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:f.label}),t.jsxs("span",{className:L("flex shrink-0 items-center gap-1 text-meta",Ye[D]),"data-mesh-reach":D,children:[f.suspect&&t.jsx(Ne,{"aria-hidden":"true",className:"size-3.5 shrink-0 text-danger"}),f.suspect?me(D):Be(f,s),f.suspect&&t.jsx("span",{className:"shrink-0 rounded-sm border border-danger px-1 text-danger",children:Ue()})]}),t.jsxs("span",{className:"shrink-0 text-meta text-ink-dim",children:[N?.role?`${N.role} · `:"",N&&!N.active?a("ui.mesh.mesh_list.revoked"):a("ui.mesh.mesh_list.member")]})]}),M.length>0?t.jsxs(t.Fragment,{children:[t.jsx(re,{className:"my-1"}),t.jsx("ul",{className:"m-0 flex list-none flex-col gap-0.5 p-0",children:M.slice(0,We).map(S=>t.jsxs("li",{"data-mesh-row-session":S.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:S.name||S.id}),t.jsx("span",{className:"shrink-0 text-meta text-ink-dim",children:Rs(S,d)}),t.jsx(Ze,{session:S,destinations:Xe(e,S,d),disabled:!u,onChoose:(E,Y)=>l(S,E,Y),trigger:t.jsx(qe,{"aria-hidden":"true",className:"size-3.5"}),triggerLabel:a("ui.mesh.mesh_list.move_conversation",{conversation:S.name||S.id})})]},S.id))}),h>M.slice(0,We).length&&t.jsx("button",{type:"button",onClick:()=>x(f.id),className:"w-fit text-meta text-ink-dim hover:text-ink",children:a("ui.mesh.mesh_list.show_all_panel",{count:h})})]}):t.jsx("span",{className:"text-meta text-ink-dim",children:a("ui.mesh.mesh_list.conversation_count",{count:h})}),(N?.active||f.state!=="self")&&t.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[t.jsx(G,{size:"sm",variant:"ghost","data-mesh-invite":f.id,onClick:()=>v({deviceId:f.id,deviceLabel:f.label}),children:a("ui.mesh.mesh_actions.invite_to_a_network")}),N?.active&&t.jsxs(G,{size:"sm",variant:"ghost","data-mesh-remove-member":`${o.id}:${f.id}`,onClick:()=>_({networkId:o.id,networkLabel:o.label,deviceId:f.id,deviceLabel:f.label}),children:[a("ui.mesh.mesh_card.remove_from"),o.label,"…"]})]})]},f.id)})})]},o.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")]})]})},Ls=["canvas","list"],Ps={get canvas(){return a("ui.mesh.mesh_page.canvas")},get list(){return a("ui.mesh.mesh_page.list")}},Ts=({state:e,graph:s,nowSeconds:r,checking:i,staleError:d,onRetry:u,approvals:x,sessions:l,sessionError:v,selfLabel:_,movingSessionId:j,canMove:I,pendingMove:C,onAskMove:o,onDropRefused:c,onChooseMove:f,onCancelMove:N,moveBusy:k,moveReport:p,onDismissReport:M,onWaitForIdle:h,onUndoCopy:D,invite:S,onOpenInvite:E,onInvite:Y,onCloseInvite:y,inviteBusy:H,inviteReceipt:ne,inviteRefusal:q,remove:O,onOpenRemove:ae,onRemove:ie,onCloseRemove:le,removeBusy:oe,removeRefusal:Q,removed:B})=>{W();const[Z,w]=g.useState("canvas"),[R,T]=g.useState(null),$=s?Lt(s):"",P="mesh-summary",U=Pt(s),V=Tt(s,l,s?.selfDeviceId??null),he=g.useMemo(()=>{const n=new Map;for(const m of s?.devices??[]){const b=V.byDevice.get(m.id);n.set(m.id,b?Ge(b,m.sessionCount):m.sessionCount??0)}return n},[s,V]),ee=g.useCallback(n=>{T(n)},[]),J=s?s.devices.find(n=>n.id===R)??null:null,pe=g.useCallback((n,m,b)=>{if(!s)return null;const A={selfDeviceId:s.selfDeviceId,devices:new Map(s.devices.map(X=>[X.id,X])),networks:new Map(s.networks.map(X=>[X.id,X]))},z=n.locality==="local"?s.selfDeviceId??"":n.owner_device,K=A.devices.get(z),F=ge({session:n,ownerDeviceId:z,ownerLabel:K?.label??n.owner_device_name},{kind:"device",deviceId:m.deviceId},A);if(F.kind==="refused")return c({code:F.code,sentence:F.sentence,remedy:F.remedy,plan:F.plan??null}),null;if(F.kind==="none")return null;const Ie=b?F.alternatives.find(X=>X.keep)??F.plan:F.plan,Je=[F.plan,...F.alternatives].filter(X=>X.keep!==Ie.keep),Qe={plan:Ie,alternatives:Je,risky:F.risky};o(Qe)},[s,o,c]);return t.jsxs("div",{className:"flex h-full min-h-0 flex-col gap-6 overflow-y-auto p-6",children:[t.jsx(nt,{title:a("ui.mesh.mesh_page.mesh"),icon:ye,subtitle:a("ui.mesh.mesh_page.devices_this_app_is_paired_with_and"),children:t.jsxs("div",{className:"flex items-center gap-4",children:[i&&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:Ls.map(n=>t.jsx("button",{type:"button","aria-pressed":Z===n,disabled:e.kind!=="ready",onClick:()=>w(n),className:L("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",Z===n&&"bg-surface text-ink"),children:Ps[n]},n))})]})]})}),t.jsx(ns,{rows:x.rows,error:x.error,pending:x.pending,refusal:x.decisionRefusal,onDecide:x.onDecide,onRetry:x.onRetry,nowSeconds:x.nowSeconds,networkNames:new Map((s?.networks??[]).map(n=>[n.id,n.label]))}),e.kind==="loading"&&t.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-3",children:[t.jsx(Ee,{className:"h-4 w-64"}),t.jsx(Ee,{className:"min-h-40 w-full flex-1"})]}),e.kind==="error"&&t.jsxs(fe,{variant:"warning",className:"flex-col items-start gap-2",children:[t.jsx("p",{children:e.message}),t.jsx(G,{variant:"secondary",size:"sm",onClick:u,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.jsx("p",{id:P,className:"text-meta text-ink-muted","data-mesh-summary":"",children:$}),d&&t.jsx(fe,{variant:"warning",children:t.jsx("p",{children:d})}),v&&t.jsx(fe,{variant:"warning",children:t.jsx("p",{children:v})}),p&&t.jsx(Ot,{receipt:p.kind==="moved"?{verb:p.verb,detail:p.detail,undo:p.undo}:null,refusal:p.kind==="refused"?p.refusal:null,canWait:p.kind==="refused"&&p.plan!==null,onWait:h,onRecheck:u,onUndo:D,onDismiss:M,pending:k}),Z==="canvas"?t.jsx(Ns,{graph:s,slots:U,nowSeconds:r,selectedDeviceId:R,sessions:V.byDevice,sessionTotals:he,movingSessionId:j,canMove:I,onOpenDevice:ee,onAskMove:o,onDropRefused:c,onShowAllSessions:ee,summaryId:P}):t.jsx(As,{graph:s,nowSeconds:r,selectedDeviceId:R,sessions:V.byDevice,selfLabel:_,canMove:I,onSelect:ee,onMove:pe,onInvite:E,onRemove:ae})]}),J&&t.jsx(Ss,{device:J,sessions:V.byDevice.get(J.id)??{rows:[],shown:[],hidden:0},sessionTotal:he.get(J.id)??0,nowSeconds:r,canMove:I,canInvite:e.kind==="ready",movingSessionId:j,destinationsFor:n=>Xe(s,n,_),onClose:()=>T(null),onMove:pe,onInvite:n=>E({deviceId:n.id,deviceLabel:n.label}),onRemoveMember:(n,m)=>{const b=s.networks.find(A=>A.id===m);ae({networkId:m,networkLabel:b?.label??m,deviceId:n.id,deviceLabel:n.label})},onShowInList:n=>{ee(n),w("list")}})]})}),t.jsx($t,{open:C!==null,plan:C?.plan??Os,alternatives:C?.alternatives??[],risky:C?.risky??!1,busy:k,onCancel:N,onChoose:f}),S&&t.jsx(zt,{open:S.open,options:S.options,deviceId:S.deviceId,deviceLabel:S.deviceLabel,onClose:y,onInvite:Y,pending:H,receipt:ne,refusal:q}),O&&t.jsx(Wt,{open:O.open,networkLabel:O.networkLabel,deviceLabel:O.deviceLabel,onClose:le,onConfirm:ie,pending:oe,refusal:Q,removed:B})]})},Os={sessionId:"",to:"",keep:!1,verb:"",waitS:0,lost:null},Us=()=>{W();const e=tt(),s=be(e.data,"peers")==="enabled",r=be(e.data,"session_transfer")==="enabled",i=Ht(s),d=qt(s),u=Ft(s,{poll:!1,stamp:()=>Ce.getState().beginAnswer()}),x=g.useMemo(()=>({peers:i,networks:d}),[i,d]),l=Yt(x),v=Bt(x),_=Ut(),j=be(e.data,"approvals")==="enabled",I=Gt(s&&j,{poll:!1}),C=Vt(),o=C.isError?{approvalId:C.variables?.approvalId??null,...Kt(C.error)}:null,c=g.useMemo(()=>Math.floor((I.dataUpdatedAt||Date.now())/1e3),[I.dataUpdatedAt]),f=Ce(w=>w.settlePlacement),N=Xt(),k=Zt(),[p,M]=g.useState(null),[h,D]=g.useState(null),[S,E]=g.useState(null),[Y,y]=g.useState(null),[H,ne]=g.useState(null),[q,O]=g.useState(null),[ae,ie]=g.useState(null),le=g.useMemo(()=>{const w=Math.max(i.dataUpdatedAt,d.dataUpdatedAt);return Math.floor((w||Date.now())/1e3)},[i.dataUpdatedAt,d.dataUpdatedAt]),oe=g.useCallback(()=>{i.refetch(),d.refetch(),u.refetch()},[i,d,u]),Q=g.useCallback((w,R)=>{M(null);const T={sessionId:w.sessionId,to:w.to,keep:w.keep,waitS:R??w.waitS};_.mutate(T,{onSuccess:$=>{if($.kind==="moved"){const{receipt:P}=$;f(w.sessionId,P);const U=P.locality==="local"?a("ui.mesh.mesh_drop.this_device"):v?.devices.find(V=>V.id===P.owner_device)?.label??P.owner_device;D({kind:"moved",verb:P.mode==="keep"?a("ui.mesh.mesh_page.copied"):a("ui.mesh.mesh_page.moved"),detail:P.mode==="keep"?a("ui.mesh.mesh_page.copy_receipt",{destination:U,suffix:P.new_session_id.slice(-6)}):a("ui.mesh.mesh_page.move_receipt",{destination:U,retirement:P.source_retired?a("ui.mesh.mesh_page.the_copy_here_is_gone"):""}),undo:P.mode==="keep"?{sessionId:P.new_session_id,to:"local",keep:!1,verb:a("ui.mesh.mesh_page.bring_copy_back",{device:U}),waitS:0,lost:Jt(U,a("ui.mesh.mesh_drop.this_device"))}:null});return}D({kind:"refused",refusal:$.refusal,plan:w})},onError:()=>{D({kind:"refused",refusal:{code:"move_failed",sentence:a("ui.mesh.mesh_page.the_move_could_not_be_sent_nothing"),status:null,unconfirmed:!1},plan:w})}})},[v,_,f]),B=g.useMemo(()=>{if(!v)return[];const w=S?.deviceId,R=w?v.devices.find(T=>T.id===w):void 0;return v.networks.filter(T=>{if(!R)return!0;const $=R.memberships.find(P=>P.networkId===T.id);return!$||!$.active}).map(T=>({id:T.id,label:T.label}))},[v,S]);if(!s)return t.jsx(st,{to:"/chat",replace:!0});const Z=l.kind==="ready"?i.error?de(i.error):d.error?de(d.error):null:null;return t.jsx(Ts,{state:l,graph:v,nowSeconds:le,checking:i.isFetching||d.isFetching,staleError:Z,onRetry:oe,approvals:{rows:I.data??[],error:I.isError?Qt(I.error):null,pending:C.isPending?C.variables??null:null,decisionRefusal:o,onDecide:(w,R)=>C.mutate({approvalId:w,decision:R}),onRetry:()=>void I.refetch(),nowSeconds:c},sessions:u.data?.rows??[],movingSessionId:_.isPending?_.variables?.sessionId??null:null,sessionError:u.isError?de(u.error):null,selfLabel:v?.devices.find(w=>w.state==="self")?.label??a("ui.mesh.mesh_drop.this_device"),canMove:r,pendingMove:p,onAskMove:M,onDropRefused:w=>D({kind:"refused",refusal:{code:w.code,sentence:w.sentence,status:null,unconfirmed:!1},plan:w.plan}),onChooseMove:w=>Q(w),onCancelMove:()=>M(null),moveBusy:_.isPending,moveReport:h,onDismissReport:()=>D(null),onWaitForIdle:()=>{h?.kind!=="refused"||!h.plan||Q(h.plan,$s)},onUndoCopy:()=>{h?.kind!=="moved"||!h.undo||M({plan:h.undo,alternatives:[],risky:!1})},invite:S===null?null:{open:!0,deviceId:S.deviceId,deviceLabel:S.deviceLabel,options:B},onOpenInvite:w=>{y(null),ne(null),E(w)},onInvite:w=>{N.mutate(w,{onSuccess:R=>y(R),onError:R=>ne({code:"invite_refused",sentence:de(R),status:null,unconfirmed:!1})})},onCloseInvite:()=>E(null),inviteBusy:N.isPending,inviteReceipt:Y,inviteRefusal:H,remove:q===null?null:{open:!0,networkId:q.networkId,networkLabel:q.networkLabel,deviceId:q.deviceId,deviceLabel:q.deviceLabel},onOpenRemove:w=>{ie(null),O(w)},onRemove:w=>{q&&k.mutate({networkId:q.networkId,deviceId:q.deviceId,confirm:w},{onSuccess:R=>ie(R)})},onCloseRemove:()=>O(null),removeBusy:k.isPending,removeRefusal:k.isError?{code:"remove_refused",sentence:de(k.error),status:null,unconfirmed:!1}:null,removed:ae})},$s=300;export{Us as MeshPage,Ts as MeshSurface,Us as default};