local-operator-ui 0.44.2 → 0.45.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 (108) hide show
  1. package/out/main/index.js +1931 -19
  2. package/out/preload/index.js +140 -4
  3. package/out/renderer/assets/{_basePickBy-LPJBKSk3.js → _basePickBy-CVZ8Tl0V.js} +1 -1
  4. package/out/renderer/assets/{_baseUniq-D8M8HOYM.js → _baseUniq-BobmJdk5.js} +1 -1
  5. package/out/renderer/assets/{agent-details-page-CZuUDIS7.js → agent-details-page-D8Tarcuy.js} +2 -2
  6. package/out/renderer/assets/{agent-hub-page-B2h53zmZ.js → agent-hub-page-CBGln8EN.js} +2 -2
  7. package/out/renderer/assets/{agents-page-DxPAtB0k.js → agents-page-CYG5qf21.js} +3 -3
  8. package/out/renderer/assets/{approvalsOverlay-BjR3EVfg.js → approvalsOverlay-S8pdZ3-7.js} +1 -1
  9. package/out/renderer/assets/arc-Dg6ybBgr.js +1 -0
  10. package/out/renderer/assets/{architectureDiagram-IEHRJDOE-BKX_zyB3.js → architectureDiagram-IEHRJDOE-DHAX1jW8.js} +1 -1
  11. package/out/renderer/assets/{blockDiagram-JOT3LUYC-DesagpJf.js → blockDiagram-JOT3LUYC-DZcxg05T.js} +1 -1
  12. package/out/renderer/assets/{book-open-BGI5fs27.js → book-open-CdC2zEgH.js} +1 -1
  13. package/out/renderer/assets/browser-page-vhGc40ZY.js +1 -0
  14. package/out/renderer/assets/{browser-webauthn-prompt-dv7y6_dA.js → browser-webauthn-prompt-CdK-HuAT.js} +1 -1
  15. package/out/renderer/assets/{building-2-D2OTMmkt.js → building-2-Benl7pk9.js} +1 -1
  16. package/out/renderer/assets/{c4Diagram-VJAJSXHY-CWsH54Hv.js → c4Diagram-VJAJSXHY-Cx4qX_yG.js} +1 -1
  17. package/out/renderer/assets/channel-DExCwSCX.js +1 -0
  18. package/out/renderer/assets/{chunk-4BMEZGHF-B0-zmu4b.js → chunk-4BMEZGHF-BtkfVpFr.js} +1 -1
  19. package/out/renderer/assets/{chunk-A2AXSNBT-RQCYYGRS.js → chunk-A2AXSNBT-afZjtcpb.js} +1 -1
  20. package/out/renderer/assets/{chunk-AEK57VVT-DwkZ07Wr.js → chunk-AEK57VVT-Bpj7-5H4.js} +1 -1
  21. package/out/renderer/assets/{chunk-D6G4REZN-BWg_1fD9.js → chunk-D6G4REZN-BKkq1UmK.js} +1 -1
  22. package/out/renderer/assets/{chunk-RZ5BOZE2-3EjCkn2h.js → chunk-RZ5BOZE2-Dg2i64O_.js} +1 -1
  23. package/out/renderer/assets/{chunk-XZIHB7SX-DoadzlFd.js → chunk-XZIHB7SX-CaES14PJ.js} +1 -1
  24. package/out/renderer/assets/classDiagram-GIVACNV2-DLQDM2Ay.js +1 -0
  25. package/out/renderer/assets/classDiagram-v2-COTLJTTW-DLQDM2Ay.js +1 -0
  26. package/out/renderer/assets/clone-B68rMBW5.js +1 -0
  27. package/out/renderer/assets/{console-mirror-Cx1_mcwT.js → console-mirror-DSWcncyi.js} +1 -1
  28. package/out/renderer/assets/{consoleCapture-CBiwH6qH.js → consoleCapture-CUT0XggJ.js} +1 -1
  29. package/out/renderer/assets/{conversation-input-sync-6W6mDd5c.js → conversation-input-sync-zEjzdlxD.js} +269 -252
  30. package/out/renderer/assets/{dagre-OKDRZEBW-CkNv39Aw.js → dagre-OKDRZEBW-CCmRW0yR.js} +1 -1
  31. package/out/renderer/assets/{diagram-SSKATNLV-DKGhEDc0.js → diagram-SSKATNLV-CydNMulU.js} +1 -1
  32. package/out/renderer/assets/{diagram-VNBRO52H-2dRMMinF.js → diagram-VNBRO52H-Jg3izSnT.js} +1 -1
  33. package/out/renderer/assets/{erDiagram-Q7BY3M3F-BaZqUE9f.js → erDiagram-Q7BY3M3F-BE0KyDQW.js} +1 -1
  34. package/out/renderer/assets/{error-boundary-BhcUnSSp.js → error-boundary-D6IZ3d5-.js} +2 -2
  35. package/out/renderer/assets/{flowDiagram-4HSFHLVR-DO71jsf7.js → flowDiagram-4HSFHLVR-IF60u56J.js} +1 -1
  36. package/out/renderer/assets/{ganttDiagram-APWFNJXF-aaChmBo1.js → ganttDiagram-APWFNJXF-Ct9VCrPe.js} +4 -4
  37. package/out/renderer/assets/{gitGraphDiagram-7IBYFJ6S-DH2o95aG.js → gitGraphDiagram-7IBYFJ6S-Cm0QXAxs.js} +1 -1
  38. package/out/renderer/assets/{graph-BzuMIyA9.js → graph-CECEq7w7.js} +1 -1
  39. package/out/renderer/assets/{hash-Bof-oLZ7.js → hash-mEjOcoLm.js} +1 -1
  40. package/out/renderer/assets/{heart-Bd5kZnjR.js → heart-CjmRir0P.js} +1 -1
  41. package/out/renderer/assets/{index-CNnTZGuV.js → index-CoWefa1B.js} +1 -1
  42. package/out/renderer/assets/{index-Bf_5C9hH.js → index-DK94pJ0b.js} +202 -212
  43. package/out/renderer/assets/index-XEWoUf3I.js +1 -0
  44. package/out/renderer/assets/index-aqB-N4KQ.css +1 -0
  45. package/out/renderer/assets/index-k5Cho3oR.js +7 -0
  46. package/out/renderer/assets/infoDiagram-PH2N3AL5-B8el69WJ.js +2 -0
  47. package/out/renderer/assets/installer-CAaGsgAe.js +1 -0
  48. package/out/renderer/assets/{journeyDiagram-U35MCT3I-B1iYgquG.js → journeyDiagram-U35MCT3I-CYzjtyDG.js} +1 -1
  49. package/out/renderer/assets/{kanban-definition-NDS4AKOZ-D6b_9SBk.js → kanban-definition-NDS4AKOZ-DC4RazVr.js} +1 -1
  50. package/out/renderer/assets/{layout-BYe1V9vC.js → layout-DAYjqs7X.js} +1 -1
  51. package/out/renderer/assets/{legacy-agents-page-B4QsRAZI.js → legacy-agents-page-yWew17m3.js} +6 -6
  52. package/out/renderer/assets/library-page-DDZSxu8V.js +157 -0
  53. package/out/renderer/assets/{mermaid.core-CENNKUw2.js → mermaid.core-C3Fh0aVF.js} +5 -5
  54. package/out/renderer/assets/mesh-page-C-BLbDFS.js +1 -0
  55. package/out/renderer/assets/{messages-Bst4VOU3.js → messages-Du2guuiW.js} +10 -10
  56. package/out/renderer/assets/{mindmap-definition-ALO5MXBD-DPYnshtf.js → mindmap-definition-ALO5MXBD-BwYwzJXX.js} +1 -1
  57. package/out/renderer/assets/mini-aiIXUMzz.js +1 -0
  58. package/out/renderer/assets/{notebook-pen-CZVJiq5R.js → notebook-pen-Cbl0LGX4.js} +1 -1
  59. package/out/renderer/assets/notifications-page-CEtRrueI.js +1 -0
  60. package/out/renderer/assets/{org-access-DZc8cPye.js → org-access-Kw828GQV.js} +1 -1
  61. package/out/renderer/assets/{org-surface-gate-Bj7rZIwL.js → org-surface-gate-CT3zfrdt.js} +1 -1
  62. package/out/renderer/assets/{page-header-Dtg6CqtK.js → page-header-Nw5c8tPb.js} +1 -1
  63. package/out/renderer/assets/path-utils-CPnlSslq.js +58 -0
  64. package/out/renderer/assets/{pieDiagram-IB7DONF6-1_U-X3IZ.js → pieDiagram-IB7DONF6-K902j96U.js} +2 -2
  65. package/out/renderer/assets/project-markdown-BGwzkGeB.js +1 -0
  66. package/out/renderer/assets/{projects-page-Bw-AAZ11.js → projects-page-CwK1EUHo.js} +13 -13
  67. package/out/renderer/assets/publication-validation-_q5dCFqY.js +1 -0
  68. package/out/renderer/assets/{quadrantDiagram-7GDLP6J5-kbwdrehe.js → quadrantDiagram-7GDLP6J5-CMxcmmaj.js} +1 -1
  69. package/out/renderer/assets/{radar-MK3ICKWK-DpsIZo-R.js → radar-MK3ICKWK-BoTD7NCk.js} +1 -1
  70. package/out/renderer/assets/{radient-auth-buttons-C1Juzc0D.js → radient-auth-buttons-B3TH2lPK.js} +1 -1
  71. package/out/renderer/assets/{requirementDiagram-KVF5MWMF-qtUg8gWV.js → requirementDiagram-KVF5MWMF-CkhXXt7a.js} +1 -1
  72. package/out/renderer/assets/{sankeyDiagram-QLVOVGJD-B6i8Lf5L.js → sankeyDiagram-QLVOVGJD-D9vzlZ4F.js} +1 -1
  73. package/out/renderer/assets/{schedules-page-DjiYevaS.js → schedules-page-lflLstHa.js} +1 -1
  74. package/out/renderer/assets/{sequenceDiagram-X6HHIX6F-B3NVLrcT.js → sequenceDiagram-X6HHIX6F-BY5Td94x.js} +1 -1
  75. package/out/renderer/assets/{settings-page-BUpTYpEG.js → settings-page-DjSt92Lz.js} +6 -6
  76. package/out/renderer/assets/{smartart-BTOCcWLh.js → smartart-enfyFmW9.js} +1 -1
  77. package/out/renderer/assets/{stateDiagram-DGXRK772-nACatGwh.js → stateDiagram-DGXRK772-CvU5I-Gh.js} +1 -1
  78. package/out/renderer/assets/stateDiagram-v2-YXO3MK2T-C9OxG4rC.js +1 -0
  79. package/out/renderer/assets/team-bridge-page-EdYZwdEw.js +21 -0
  80. package/out/renderer/assets/{timeline-definition-BDJGKUSR-BXO43hMG.js → timeline-definition-BDJGKUSR-gpDmrz_j.js} +1 -1
  81. package/out/renderer/assets/{use-default-on-banner-DjHLTfeK.js → use-default-on-banner-D4ExL869.js} +1 -1
  82. package/out/renderer/assets/{use-download-agent-mutation-D6QgUMMQ.js → use-download-agent-mutation-Ddu_n321.js} +2 -2
  83. package/out/renderer/assets/{use-session-snapshot-CI2ND9fV.js → use-session-snapshot-DtZtLFCM.js} +1 -1
  84. package/out/renderer/assets/{xychartDiagram-VJFVF3MP-CA90n1Qk.js → xychartDiagram-VJFVF3MP-DgiVkF0W.js} +1 -1
  85. package/out/renderer/browser-approvals-overlay.html +2 -2
  86. package/out/renderer/console-capture.html +6 -6
  87. package/out/renderer/index.html +8 -8
  88. package/out/renderer/installer.html +5 -5
  89. package/out/renderer/mini.html +8 -8
  90. package/package.json +2 -2
  91. package/out/renderer/assets/arc-Blq81BHO.js +0 -1
  92. package/out/renderer/assets/browser-page-C156D5SG.js +0 -1
  93. package/out/renderer/assets/channel-DEPypRI4.js +0 -1
  94. package/out/renderer/assets/classDiagram-GIVACNV2-D64NGwBp.js +0 -1
  95. package/out/renderer/assets/classDiagram-v2-COTLJTTW-D64NGwBp.js +0 -1
  96. package/out/renderer/assets/clone-BrsLxtaK.js +0 -1
  97. package/out/renderer/assets/index-B0Ue5RBi.js +0 -7
  98. package/out/renderer/assets/index-BABrnwf5.css +0 -1
  99. package/out/renderer/assets/index-CxK1ypFa.js +0 -1
  100. package/out/renderer/assets/infoDiagram-PH2N3AL5-DZJ-3Hbl.js +0 -2
  101. package/out/renderer/assets/installer-BTKc-9AM.js +0 -1
  102. package/out/renderer/assets/library-page-VgK0BSR2.js +0 -157
  103. package/out/renderer/assets/mesh-page-CEgyAVW-.js +0 -1
  104. package/out/renderer/assets/mini-DjdzboAc.js +0 -1
  105. package/out/renderer/assets/path-utils-CzhWDDSj.js +0 -58
  106. package/out/renderer/assets/publication-validation-Iutn5hzY.js +0 -1
  107. package/out/renderer/assets/stateDiagram-v2-YXO3MK2T-LbiD2EL_.js +0 -1
  108. package/out/renderer/assets/team-bridge-page-BW45aiP2.js +0 -21
@@ -1,6 +1,6 @@
1
- import{r,j as e,c as B}from"./index-CNnTZGuV.js";import{B as zs,A as kt,i as oe,u as ne,a as Re,c as ue,r as Ze,d as ke,a5 as bs,g as es,a4 as yt,Q as vt}from"./path-utils-CzhWDDSj.js";import{P as Nt}from"./page-header-Dtg6CqtK.js";import{c as wt,m as re,B as C,l as T,u as Z,y as _t,I as Ae,T as Ds,D as $e,d as He,e as Be,f as Qe,g as Ke,h as Ve,A as ge,a as fe,n as je,Y as St,Z as Ct,_ as Pt,$ as Tt,F as ps,G as gs,H as fs,J as js,K as ks}from"./error-boundary-BhcUnSSp.js";import{ap as ss,at as ys,bg as It,bh as Us,a4 as G,aq as ye,be as Ms,bi as Rt,ar as At,bj as Et,bk as Lt,P as $s,ax as Hs,bl as Ce,bm as Ft,bn as Ot}from"./conversation-input-sync-6W6mDd5c.js";import{t as a}from"./messages-Bst4VOU3.js";import{a as qt,p as Bs,P as ce,u as zt}from"./publication-validation-Iutn5hzY.js";import{h as ie,O as Dt,A as Ut,f as Mt,a as $t,b as Ht,d as Bt,e as Qs,C as Qt,c as Kt,n as Vt,u as Wt,i as Yt}from"./use-download-agent-mutation-D6QgUMMQ.js";import{H as Gt}from"./heart-Bd5kZnjR.js";import{E as Jt,aT as Xt,aO as Zt,aU as Ks,aV as Vs,aW as Ws,aX as ea,aY as sa,aP as ts,aH as ta,aF as Ys,aZ as aa,aD as ia,h as na,j as la,k as vs,p as Ns,aM as ra,a_ as ca,A as ua,a$ as oa}from"./index-Bf_5C9hH.js";import{n as da,i as ma,H as ha,p as ws,c as xa,d as ba,e as _s,h as Ss,a as Cs,s as Ps,S as Ts,b as pa,f as ga,g as fa,o as Gs,u as ja}from"./org-access-DZc8cPye.js";import{R as Js}from"./radient-auth-buttons-C1Juzc0D.js";import{o as ka,a as We}from"./org-surface-gate-Bj7rZIwL.js";import{B as ya}from"./building-2-D2OTMmkt.js";import"./en-US-CW_dDnkH.js";import"./book-open-BGI5fs27.js";import"./console-mirror-Cx1_mcwT.js";/**
1
+ import{r,j as e,c as B}from"./index-CoWefa1B.js";import{B as zs,F as kt,i as oe,u as ne,a as Re,c as ue,r as Ze,d as ke,a6 as bs,g as es,a5 as yt,C as vt}from"./path-utils-CPnlSslq.js";import{P as Nt}from"./page-header-Nw5c8tPb.js";import{c as wt,y as re,B as C,g as T,u as Z,J as _t,K as Ae,T as Ds,o as $e,p as He,r as Be,q as Qe,s as Ke,t as Ve,A as ge,a as fe,z as je,a1 as St,a2 as Ct,a3 as Pt,a4 as Tt,M as ps,N as gs,O as fs,P as js,Q as ks}from"./error-boundary-D6IZ3d5-.js";import{b9 as ss,bc as ys,bZ as It,b_ as Ms,a7 as G,ba as ye,bX as Us,b$ as Rt,aZ as At,c0 as Et,c1 as Lt,S as $s,bg as Hs,c2 as Ce,c3 as Ot,c4 as Ft}from"./conversation-input-sync-zEjzdlxD.js";import{t as a}from"./messages-Du2guuiW.js";import{a as qt,p as Bs,P as ce,u as zt}from"./publication-validation-_q5dCFqY.js";import{h as ie,O as Dt,A as Mt,f as Ut,a as $t,b as Ht,d as Bt,e as Qs,C as Qt,c as Kt,n as Vt,u as Wt,i as Yt}from"./use-download-agent-mutation-Ddu_n321.js";import{H as Gt}from"./heart-CjmRir0P.js";import{I as Jt,aX as Xt,aS as Zt,aY as Ks,aZ as Vs,a_ as Ws,a$ as ea,b0 as sa,aT as ts,aL as ta,aJ as Ys,b1 as aa,aH as ia,i as na,k as la,m as vs,q as Ns,aQ as ra,b2 as ca,E as ua,b3 as oa}from"./index-DK94pJ0b.js";import{n as da,i as ma,H as ha,p as ws,c as xa,d as ba,e as _s,h as Ss,a as Cs,s as Ps,S as Ts,b as pa,f as ga,g as fa,o as Gs,u as ja}from"./org-access-Kw828GQV.js";import{R as Js}from"./radient-auth-buttons-B3TH2lPK.js";import{o as ka,a as We}from"./org-surface-gate-CT3zfrdt.js";import{B as ya}from"./building-2-Benl7pk9.js";import"./en-US-CW_dDnkH.js";import"./book-open-CdC2zEgH.js";import"./console-mirror-DSWcncyi.js";/**
2
2
  * @license lucide-react v0.507.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
5
5
  * See the LICENSE file in the root directory of this source tree.
6
- */const va=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M17 12h.01",key:"1m0b6t"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M7 12h.01",key:"eqddd0"}]],Na=wt("circle-ellipsis",va),wa=({agent:s,isLiked:t,isFavourited:i,onLikeToggle:n,onFavouriteToggle:l,onDownload:d,isLikeActionLoading:m=!1,isFavouriteActionLoading:L=!1,isDownloading:p=!1,actionError:v=null,onRetryAction:F,showActions:S=!0,viewerStateKnown:b=!0,orgName:h=null})=>{const E=zs(),{isAuthenticated:f}=ss(),w=s.description??"",[I,O]=r.useState(!1),P=r.useRef(null),g=r.useCallback(A=>{if(P.current?.disconnect(),P.current=null,!A)return;const z=()=>O(A.scrollHeight-A.clientHeight>1);z();const Q=new ResizeObserver(z);Q.observe(A),P.current=Q},[]),R=f?b?t?"Unlike agent":"Like agent":"Your likes could not be read, so this is not shown as unliked.":"Log in to Radient to like agents",j=f?b?i?"Unfavourite agent":"Favourite agent":"Your favourites could not be read, so this is not shown as unfavourited.":"Log in to Radient to favourite agents",k=b?t?"Unlike agent":"Like agent":"Like state unavailable",y=b?i?"Unfavourite agent":"Favourite agent":"Favourite state unavailable",u=s.visibility==="org",x=ie(s.name);return e.jsxs("div",{"data-glass-block":"",className:"flex h-full flex-col overflow-hidden rounded-md bg-surface transition-colors duration-fast ease-out-quart hover:bg-elevated",children:[e.jsxs("button",{type:"button",onClick:()=>E(`/agent-hub/${s.id}`),className:"flex min-h-0 flex-1 cursor-pointer flex-col gap-2 p-4 text-left","aria-label":`View details for ${x}`,children:[e.jsx("h3",{className:"truncate font-medium text-heading text-ink",children:x}),u&&e.jsx(Dt,{orgName:h}),e.jsx(re,{content:I?w:"",children:e.jsx("span",{ref:g,className:"line-clamp-3 min-h-0 text-body-sm text-ink-muted",children:w})}),e.jsxs("div",{className:"mt-auto flex flex-col gap-2 pt-2",children:[e.jsx(Ut,{tags:s.tags,categories:s.categories}),e.jsxs("p",{className:"truncate text-ink-dim text-meta",children:[s.account_metadata?.name??"Unknown author",e.jsx("span",{"aria-hidden":"true",className:"mx-1.5",children:"·"}),"updated ",Mt(new Date(s.updated_at))," ago"]})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 border-t border-hairline px-3 py-2",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-0.5","data-viewer-state":u?"org":f?b?"known":"unknown":"signed-out",children:[!u&&e.jsxs(e.Fragment,{children:[e.jsx(re,{content:R,children:e.jsx("span",{children:e.jsxs(C,{variant:"ghost",size:"sm",onClick:f&&b?()=>n(s.id):void 0,disabled:m||!f||!b,"aria-label":k,className:B(t&&"text-danger"),children:[e.jsx(Gt,{fill:t?"currentColor":"none","data-testid":"agent-like-heart"}),e.jsx("span",{"data-testid":"agent-like-count",className:"inline-flex h-4 min-w-4 items-center font-mono text-mono-sm text-ink-muted",children:s.like_count??0})]})})}),e.jsx(re,{content:j,children:e.jsx("span",{children:e.jsxs(C,{variant:"ghost",size:"sm",onClick:f?()=>l(s.id):void 0,disabled:L||!f||!b,"aria-label":y,className:B(i&&"text-warning"),children:[e.jsx(Jt,{fill:i?"currentColor":"none","data-testid":"agent-favourite-star"}),e.jsx("span",{"data-testid":"agent-favourite-count",className:"inline-flex h-4 min-w-4 items-center font-mono text-mono-sm text-ink-muted",children:s.favourite_count??0})]})})})]}),e.jsx(re,{content:"Downloads",children:e.jsxs("span",{className:"ml-1 inline-flex items-center gap-1 pr-1 text-ink-dim",children:[e.jsx(ys,{"aria-hidden":"true",className:"size-3.5"}),e.jsx("span",{className:"inline-flex h-4 min-w-6 items-center font-mono text-mono-sm",children:p?e.jsx(T,{className:"h-3 w-6"}):(s.download_count??0).toLocaleString()})]})})]}),S&&d&&e.jsx("div",{className:"ml-auto flex shrink-0 items-center",children:e.jsxs(C,{variant:"secondary",size:"sm",onClick:()=>d(s),disabled:p,"aria-label":`Download ${x}`,"data-tour-tag":"agent-hub-download-button",children:[e.jsx(ys,{"data-testid":"agent-download"}),"Get"]})})]}),v&&e.jsxs("output",{"data-testid":"agent-card-error",className:"flex flex-wrap items-center gap-x-2 gap-y-1 border-t border-hairline px-3 py-2 text-body-sm text-danger",children:[e.jsx("span",{className:"min-w-0 flex-1",children:v}),F&&e.jsx(C,{variant:"ghost",size:"sm",onClick:F,children:"Try again"})]})]})},_a=({agent:s,status:t,viewerStateKnown:i=!0,orgName:n=null})=>{const{isAuthenticated:l}=ss(),[d,m]=r.useState(null),L=t?.liked??!1,p=t?.favourited??!1,v=$t(),F=Ht(),S=Bt(),b=()=>{!l||v.isPending||(m(null),v.mutate({agentId:s.id,isCurrentlyLiked:L},{onError:()=>m("like")}))},h=()=>{!l||F.isPending||(m(null),F.mutate({agentId:s.id,isCurrentlyFavourited:p},{onError:()=>m("favourite")}))},E=()=>{S.isPending||(m(null),S.mutate({agentId:s.id,agentName:s.name},{onError:()=>m("download")}))},f=d?d==="like"?{action:"like",error:v.error,retry:b}:d==="favourite"?{action:"favourite",error:F.error,retry:h}:{action:"download",error:S.error,retry:E}:null;return e.jsx(wa,{agent:s,isLiked:l&&L,isFavourited:l&&p,onLikeToggle:b,onFavouriteToggle:h,onDownload:E,isLikeActionLoading:v.isPending,isFavouriteActionLoading:F.isPending,isDownloading:S.isPending,viewerStateKnown:i,orgName:n,actionError:f?qt(f.action,f.error,ie(s.name)):null,onRetryAction:f?.retry})},Is=({selected:s,onClick:t,children:i,...n})=>e.jsx("button",{type:"button",onClick:t,"aria-pressed":s,className:B("flex w-full cursor-pointer items-center gap-2.5 rounded-sm px-3 py-1.5 text-left","text-body-sm transition-colors duration-fast ease-out-quart",s?Zt:"text-ink hover:bg-row-hover"),...n,children:i}),Rs=Object.keys(Qt),Sa=s=>[...s].sort((t,i)=>{const n=Rs.indexOf(t),l=Rs.indexOf(i);return n!==-1&&l!==-1?n-l:n!==-1?-1:l!==-1?1:t.localeCompare(i)}),Ca=({selectedCategory:s,onSelectCategory:t,categories:i})=>{Z();const n=Sa(s&&!i.includes(s)?[...i,s]:i);return e.jsxs("div",{className:"flex h-full flex-col overflow-y-auto",children:[e.jsx("h2",{className:"mb-2 px-3 font-medium text-ink-dim text-meta",children:a("ui.hub.taxonomy.heading")}),e.jsxs("div",{className:"flex flex-col gap-0.5",children:[e.jsxs(Is,{selected:s===null,onClick:()=>t(null),"data-testid":"category-all",children:[e.jsx("span",{className:"flex size-4 shrink-0 items-center justify-center",children:e.jsx(Xt,{size:16,"aria-hidden":"true"})}),a("ui.hub.taxonomy.all")]}),n.map(l=>{const d=Qs(l),m=l==="other"?e.jsx(Na,{size:16}):d.icon;return e.jsxs(Is,{selected:s===l,onClick:()=>t(l),"data-testid":`category-${l}`,children:[e.jsx("span",{className:"flex size-4 shrink-0 items-center justify-center",children:m}),d.label]},l)})]})]})},as=({page:s,count:t,onChange:i,ariaLabel:n="Agent pages"})=>{const l=r.useRef(null),d=r.useRef(null),m=r.useRef(null);return r.useEffect(()=>{const L=m.current;m.current=null,L==="previous"&&l.current?.focus(),L==="next"&&d.current?.focus()},[s]),t<=1?null:e.jsxs("nav",{"aria-label":n,className:"mt-6 flex min-h-13 items-center justify-between gap-3 border-t border-hairline","data-testid":"agent-hub-pager",children:[e.jsxs("span",{className:"select-none text-meta text-ink-dim",children:["Page ",s," of ",t]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(C,{variant:"secondary",size:"sm",ref:l,onClick:()=>{s-1<=1&&(m.current="next"),i(s-1)},disabled:s<=1,"aria-label":"Previous page",children:[e.jsx(It,{"aria-hidden":"true"}),"Previous"]}),e.jsxs(C,{variant:"secondary",size:"sm",ref:d,onClick:()=>{s+1>=t&&(m.current="previous"),i(s+1)},disabled:s>=t,"aria-label":"Next page",children:["Next",e.jsx(_t,{"aria-hidden":"true"})]})]})]})},Pa=/alias/i;function As(s){return s instanceof kt?s.code==="alias-occupied"?!0:s.code==="origin-conflict"&&Pa.test(s.message):!1}const Ta=/\/+$/;function is(s){const t=s.replace(Ta,"");try{const{pathname:i}=new URL(t);return i===""||i==="/"?`${t}/v1`:t}catch{return`${t}/v1`}}const Es=s=>s?.skills===1&&s.revision_cas===1;function Ia(s,t=1,i=20){const n=new URL(Ks(s,"skills"));return n.searchParams.set("page",String(t)),n.searchParams.set("per_page",String(i)),Vs(n.toString())}function Ra(s,t){return Vs(Ks(s,"skills",t))}function Aa(s){return Us({operation:"org_skills.list",tenantId:s})}function Ea(s,t){return Us({operation:"org_skill.get",tenantId:s,skillId:t})}const ns=12,Pe={all:["public-teams"],list:(s,t)=>[...Pe.all,"list",{page:s,perPage:t}],detail:s=>[...Pe.all,"detail",s]},Ee=(s,t)=>t instanceof Ws?t.status===null?!1:t.status>=500&&s<1:s<1,Xs=({page:s=1,perPage:t=ns,enabled:i=!0}={})=>{const n=oe({queryKey:Pe.list(s,t),queryFn:()=>ea(G.radientBaseUrl,s,t),select:l=>l.result,enabled:i,retry:Ee,staleTime:3e5,gcTime:6e5,refetchOnWindowFocus:!1,placeholderData:l=>l});return{...n,teams:n.data?.records??[],isRefreshing:n.isFetching&&n.data!==void 0,pagination:n.data?{page:n.data.page,perPage:n.data.per_page,totalPages:n.data.total_pages,totalRecords:n.data.total_records}:void 0}},La=({teamId:s,enabled:t=!0})=>{const i=oe({queryKey:Pe.detail(s??""),queryFn:()=>sa(G.radientBaseUrl,s),select:n=>n.result,enabled:t&&!!s,retry:Ee,staleTime:3e5,gcTime:6e5,refetchOnWindowFocus:!1,retryOnMount:!1});return{...i,team:i.data}};function de(s){if(s.getQueryState(bs.capabilities)?.status!=="success"||!ue(s.getQueryData(bs.capabilities),"hub_skills"))throw new Error("This backend does not support the complete Hub Skills adapter.")}function Zs(s,t,i){const n=ne(),l=Re();return oe({queryKey:["hub-skills",G.radientBaseUrl,s.visibility,s.tenantId,t],enabled:i&&!l.isError&&ue(l.data,"hub_skills"),queryFn:async()=>{if(de(n),s.visibility==="org"){const m=(await Aa(s.tenantId)).result;return{rows:m.skills,pages:1,total:m.skills.length,contract:m.sync_contract}}const d=(await Ia(G.radientBaseUrl,t,20)).result;return{rows:d.records,pages:d.total_pages,total:d.total_records,contract:d.sync_contract}},staleTime:3e4,retry:s.visibility==="org"?Ze:Ee,retryOnMount:!1,refetchOnWindowFocus:!1})}function Fa(s,t,i){const n=ne(),l=Re();return oe({queryKey:["hub-skill",G.radientBaseUrl,s.visibility,s.tenantId,t],enabled:i&&t!==null&&!l.isError&&ue(l.data,"hub_skills"),queryFn:async()=>(de(n),(s.visibility==="org"?await Ea(s.tenantId,t):await Ra(G.radientBaseUrl,t)).result),staleTime:3e4,retry:s.visibility==="org"?Ze:Ee,retryOnMount:!1})}function ls(s,t){s.setQueryData(ts,t.links)}function rs(s){s.invalidateQueries({queryKey:ts}),s.invalidateQueries({queryKey:["desktop","skills"]})}function Oa(){const s=ne();return ye({mutationFn:t=>(de(s),ke({op:"hub.skillPull",requestId:t.requestId,hubId:t.remoteId,hubSource:is(G.radientBaseUrl),visibility:t.scope.visibility,tenantId:t.scope.tenantId,localAlias:t.alias,subscribe:t.subscribe,autoPush:t.autoPush,confirmPublicEgress:t.consent})),onSuccess:t=>{ls(s,t)},onSettled:()=>{rs(s)}})}function qa(){const s=ne();return ye({mutationFn:t=>(de(s),ke({op:"hub.skillSubscribe",requestId:t.requestId,hubId:t.remoteId,hubSource:is(G.radientBaseUrl),visibility:t.scope.visibility,tenantId:t.scope.tenantId,localAlias:t.alias})),onSuccess:t=>{ls(s,t)},onSettled:()=>{rs(s)}})}function za(){const s=ne();return ye({mutationFn:t=>(de(s),ke({op:"hub.skillUnpull",requestId:t.requestId,linkId:t.linkId})),onSuccess:t=>{ls(s,t)},onSettled:()=>{rs(s)}})}function Da(){const s=ne();return ye({mutationFn:t=>(de(s),ke({op:"hub.skillPublish",requestId:t.requestId,...t.draft,dryRun:t.previewReceipt===void 0,...t.previewReceipt?{previewReceipt:t.previewReceipt,confirmPublish:!0}:{}})),onSuccess:t=>{t.local_link_receipt?.state==="complete"&&(s.invalidateQueries({queryKey:ts}),s.invalidateQueries({queryKey:["desktop","skills"]}),s.invalidateQueries({queryKey:["hub-skills"]}))}})}function Ua({scope:s,source:t,verifiedCas:i,enabled:n=!0,heading:l=!0}){Z();const d=r.useId(),[m,L]=r.useState(""),[p,v]=r.useState(""),[F,S]=r.useState(da),[b,h]=r.useState(null),[E,f]=r.useState(!1),w=Da(),I=r.useRef(null),O=oe({queryKey:["desktop","skills","hub-publication"],queryFn:()=>ke({op:"skills.list"}),staleTime:3e4,retry:!1}),P=`${s.visibility}:${s.tenantId??""}`,g=r.useRef(P);r.useEffect(()=>{g.current!==P&&(g.current=P,S(y=>({...y,autoPush:!1,confirmPublicEgress:!1})),h(null),f(!0))},[P]);const R={sourceSkill:m,localAlias:p,visibility:s.visibility,tenantId:s.tenantId,...F},j=b?ma(b,R):!1;r.useEffect(()=>{if(!b)return;const y=setTimeout(()=>{h(null),f(!0)},Math.max(0,Math.min(Date.parse(b.expires_at)-Date.now(),2147483647)));return()=>clearTimeout(y)},[b]);const k=y=>{if(!n||w.isPending||!m||!p||y&&!j)return;const u=JSON.stringify({draft:R,receipt:y?b?.preview_receipt:null}),x=I.current&&I.current.tuple===u&&(y||w.error)?I.current:{tuple:u,id:crypto.randomUUID()};I.current=x,y||(h(null),f(!1)),w.mutate({requestId:x.id,draft:R,...y&&b?{previewReceipt:b.preview_receipt}:{}},{onSuccess:A=>{A.preview?(h(A.preview),f(!1)):ws(A)&&h(null)}})};return e.jsxs("section",{className:"flex min-w-0 flex-col gap-4","data-hub-skill-publication":!0,children:[l&&e.jsx("h3",{className:"text-heading text-ink",children:a("ui.hub.skills.publish_title")}),e.jsx("label",{htmlFor:`${d}-source`,className:"text-body-sm text-ink",children:a("ui.hub.skills.select_authored")}),e.jsxs("select",{id:`${d}-source`,"data-testid":"hub-skill-publish-source",value:m,disabled:w.isPending||!n,className:"rounded-md border border-control bg-surface px-3 py-2 text-body-sm text-ink",onChange:y=>{L(y.target.value),v(y.target.value),h(null),S(u=>({...u,autoPush:!1,confirmPublicEgress:!1}))},children:[e.jsx("option",{value:"",children:a("ui.hub.skills.select_authored")}),O.data?.data.skills.map(y=>e.jsx("option",{value:y.name,children:y.name},y.name))]}),e.jsx("label",{htmlFor:`${d}-alias`,className:"text-body-sm text-ink",children:a("ui.hub.subscriptions.alias")}),e.jsx(Ae,{id:`${d}-alias`,"data-testid":"hub-skill-publish-alias",value:p,disabled:w.isPending||!n,onChange:y=>{v(y.target.value),S(u=>({...u,autoPush:!1,confirmPublicEgress:!1}))}}),e.jsx("p",{className:"text-meta text-ink-muted",children:a("ui.hub.skills.text_limits")}),e.jsx(ha,{value:F,onChange:S,source:t,item:m||p,visibility:s.visibility,organization:s.organization,destinationKey:`${P}:${m}`,canEnableAutoPush:i,disabled:w.isPending||!n}),O.isLoading&&e.jsx("output",{className:"text-meta text-ink-muted",children:a("ui.hub.skills.loading")}),O.error&&e.jsx("p",{role:"alert",className:"text-body-sm text-danger",children:a("ui.hub.status.other_error")}),w.error&&e.jsx("p",{role:"alert",className:"text-body-sm text-danger",children:a("ui.hub.links.action_failed",{direction:a("ui.hub.links.direction_push"),item:m||p,source:t})}),(E||b&&!j&&b.can_confirm)&&e.jsx("p",{role:"alert",className:"text-body-sm text-warning",children:a("ui.hub.links.preview_changed")}),b&&b.visibility===s.visibility&&b.tenant_id===s.tenantId&&e.jsxs("div",{className:"flex min-w-0 flex-col gap-3",children:[e.jsx("h4",{className:"text-body-sm text-ink",children:a("ui.hub.links.preview_payload",{source:t})}),e.jsx(Ds,{readOnly:!0,rows:12,"aria-label":a("ui.hub.links.preview_payload",{source:t}),value:JSON.stringify(b.proposal.fields,null,2),className:"max-h-96 bg-sunken text-mono-sm"}),b.warnings.map((y,u)=>e.jsx("p",{className:"break-words text-body-sm text-warning",children:y},`${u}-${y}`)),b.reason&&e.jsx("p",{className:"text-body-sm text-warning",children:ta(b.reason)})]}),w.data?.publication===null&&w.data.local_link_receipt?.state==="pending-reconciliation"&&e.jsx("output",{className:"text-body-sm text-warning","data-testid":"hub-skill-pending-reconcile",children:a("ui.hub.links.publication_pending")}),w.data?.publication&&e.jsx("output",{className:"text-body-sm text-ink","data-testid":"hub-skill-published",children:ws(w.data)?a("ui.hub.links.published",{item:w.data.link?.name??p,source:w.data.link?Ys(w.data.link):t}):a("ui.hub.skills.policy_pending")}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(C,{variant:"outline","data-testid":"hub-skill-publish-preview",disabled:!n||w.isPending||!m||!p,onClick:()=>k(!1),children:a("ui.hub.subscriptions.preview_publish")}),e.jsx(C,{"data-testid":"hub-skill-publish-confirm",disabled:!n||w.isPending||!j,onClick:()=>k(!0),children:a("ui.hub.links.confirm_publish")})]})]})}function Ls(s,t){const i=s.publisher?.trim();return i?a("ui.hub.skills.published_by",{publisher:i}):s.visibility==="org"?t??a("ui.hub.links.source_unavailable"):a("ui.hub.skills.public_hub")}function Ma({scope:s,signedIn:t,accessible:i=!0}){Z();const n=r.useId(),[l,d]=r.useState(1),[m,L]=r.useState(""),[p,v]=r.useState(null),[F,S]=r.useState(!1),[b,h]=r.useState("unsubscribe"),[E,f]=r.useState(!1),w=r.useRef(null),I=s.visibility==="public"?a("ui.hub.links.source_public"):s.organization?a("ui.hub.links.source_private",{organization:s.organization}):a("ui.hub.links.source_unavailable"),O=Re(),P=i&&ue(O.data,"hub_updates"),g=Zs(s,l,i&&(s.visibility==="public"||t)),R=Es(g.data?.contract),j=Fa(s,p,R&&i),k=Oa(),y=qa(),u=za(),x=aa(),A=ia(i&&ue(O.data,"hub_links")),z=na(P),Q=r.useMemo(()=>xa(A.data?.links,is(G.radientBaseUrl)),[A.data]),D=r.useMemo(()=>la(z.data),[z.data]),M=k.data?.link?.link_id,N=!A.isLoading&&!A.error,U=A.error?a("ui.hub.skills.inventory_unknown"):a("ui.hub.links.loading"),te=j.data?.visibility===s.visibility&&(s.visibility==="public"?!j.data.tenant_id:j.data.tenant_id===s.tenantId),ae=i&&!j.error&&!g.error&&te&&Es(j.data?.sync_contract)&&!!j.data?.revision,me=(g.data?.rows??[]).filter(o=>ba(o,s)),ve=me.filter(o=>`${o.name} ${o.description}`.toLocaleLowerCase().includes(m.toLocaleLowerCase())),K=me.find(o=>o.id===p),_=K?Q.get(_s({id:K.id,visibility:K.visibility,tenantId:K.tenant_id??null})):void 0,Ne=_?D.get(vs("skill",_.name)):void 0,he=Ss(_,Ne,N),se=_?Ns(_)==="present":!1,Le=o=>{const q=Q.get(_s({id:o.id,visibility:o.visibility,tenantId:o.tenant_id??null})),X=q?D.get(vs("skill",q.name)):void 0;return{link:q,update:X,state:Ss(q,X,N)}},xe=o=>(w.current?.tuple!==o&&(w.current={tuple:o,id:crypto.randomUUID()}),w.current.id),le=o=>{if(!p||!ae||!t)return;const q=o?.name??K?.name??"";if(!q)return;const X=o?o.policy.subscribe:!1,pe=o?.policy.auto_push??!1,we=!1;k.mutate({requestId:xe(ga({selected:p,scope:s,localAlias:q,subscribe:X,autoPush:pe,consent:we})),remoteId:p,scope:s,alias:q,subscribe:X,autoPush:pe,consent:we})},Fe=()=>{if(!p||!ae||!t)return;if(fa(_)==="policy"&&_){if(_.policy.subscribe||x.isPending)return;h("subscribe"),x.mutate({link:_,patch:{subscribe:!0}});return}const o=K?.name??"";o&&y.mutate({requestId:xe(JSON.stringify({op:"subscribe",selected:p,scope:s,localAlias:o})),remoteId:p,scope:s,alias:o})},Oe=()=>{_&&u.mutate({requestId:xe(JSON.stringify({op:"unpull",link:_.link_id})),linkId:_.link_id},{onSuccess:()=>{k.reset(),y.reset()}})},V=()=>{!_||_.policy.subscribe===!1||x.isPending||!x.canWrite||(h("unsubscribe"),x.mutate({link:_,patch:{subscribe:!1}}))},J=t&&R&&i&&!g.error,be=g.data?.total??me.length,$=g.error?null:g.isLoading?a("ui.hub.skills.loading"):s.organization?a("ui.hub.skills.count_shared",{count:be,organization:s.organization}):a("ui.hub.skills.count",{count:be});return e.jsxs("section",{className:"flex min-w-0 flex-col gap-4","data-hub-skills-library":!0,children:[s.visibility==="org"&&!t?e.jsx("p",{role:"alert",className:"text-body-sm text-warning",children:a("ui.hub.status.no_credential")}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("div",{className:B("flex min-w-56 max-w-md flex-1 items-center rounded-sm border border-control bg-surface","transition-colors duration-fast ease-out-quart","has-[:focus-visible]:outline-solid has-[:focus-visible]:outline-2","has-[:focus-visible]:outline-accent has-[:focus-visible]:outline-offset-2"),children:[e.jsx(Ms,{"aria-hidden":"true",className:"ml-2 shrink-0 text-ink-dim"}),e.jsx(Ae,{id:`${n}-search`,type:"search","data-testid":"hub-skill-search",value:m,placeholder:a("ui.hub.skills.search"),"aria-label":a("ui.hub.skills.search"),onChange:o=>L(o.target.value),className:"h-8 min-w-0 flex-1 border-0 bg-transparent outline-none"})]}),J&&e.jsx(C,{variant:"secondary","data-testid":"hub-skill-publish-open",onClick:()=>f(!0),children:a("ui.hub.skills.publish_title")})]}),$!==null&&e.jsx("p",{"aria-live":"polite",className:"text-meta text-ink-dim","data-testid":"hub-skill-status",children:s.organization||g.isLoading?e.jsx("span",{"data-testid":"hub-skill-source",children:$}):e.jsxs(e.Fragment,{children:[e.jsx("span",{children:$})," · ",e.jsx("span",{"data-testid":"hub-skill-source",children:a("ui.hub.skills.public_hub")})]})}),g.error&&e.jsxs("div",{role:"alert",className:"flex flex-col items-start gap-2 text-body-sm text-warning",children:[e.jsx("p",{children:a("ui.hub.skills.catalogue_failed",{source:I})}),e.jsx(C,{variant:"outline",className:"self-start",disabled:g.isFetching,onClick:()=>void g.refetch(),children:a("ui.hub.links.retry")})]}),g.isSuccess&&!R&&e.jsx("p",{className:"text-body-sm text-warning",children:a("ui.hub.skills.unavailable")}),R&&e.jsxs(e.Fragment,{children:[ve.length===0&&e.jsx("p",{className:"text-body-sm text-ink-muted",children:a(m?"ui.hub.skills.search_empty":"ui.hub.skills.remote_empty")}),e.jsx("ul",{className:"grid list-none grid-cols-[repeat(auto-fill,minmax(17.5rem,1fr))] gap-6 p-0",children:ve.map(o=>{const q=Le(o),X=Cs(q.state,q.update,q.link?Ns(q.link)==="present":!1);return e.jsx("li",{className:"min-w-0",children:e.jsxs("button",{type:"button","aria-haspopup":"dialog","aria-expanded":p===o.id,"aria-label":a("ui.hub.skills.open_detail",{item:o.name}),"data-testid":"hub-skill-open","data-skill-id":o.id,"data-skill-state":q.state.kind,onClick:()=>{v(o.id),k.reset(),y.reset(),u.reset(),x.reset()},className:B("flex h-full w-full flex-col overflow-hidden rounded-md bg-surface text-left","transition-colors duration-fast ease-out-quart hover:bg-elevated","focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent focus-visible:outline-offset-1"),children:[e.jsxs("span",{className:"flex min-h-0 flex-1 flex-col gap-2 p-4",children:[e.jsx("span",{className:"truncate font-medium text-heading text-ink",children:o.name}),o.description?e.jsx("span",{className:"line-clamp-3 text-body-sm text-ink-muted",children:o.description}):null,e.jsx("span",{className:"mt-auto truncate text-ink-dim text-meta",children:Ls(o,s.organization)})]}),e.jsxs("span",{className:"flex items-center justify-between gap-2 border-t border-hairline px-4 py-2 text-meta",children:[e.jsx("span",{className:"truncate text-ink-muted",children:Ps(q.state,U)}),e.jsx(Ts,{mark:X})]})]})},o.id)})}),e.jsx(as,{page:l,count:g.data?.pages??1,onChange:d,ariaLabel:a("ui.hub.skills.title")})]})]}),!i&&e.jsx("p",{role:"alert",className:"text-body-sm text-warning",children:a("ui.hub.status.access_lost")}),e.jsx($e,{open:!!p&&R,onOpenChange:o=>{o||v(null)},children:e.jsxs(He,{"data-hub-skill-detail":"",className:"max-h-[85vh] overflow-y-auto sm:max-w-2xl",children:[e.jsxs(Be,{children:[e.jsx(Qe,{"data-testid":"hub-skill-detail-name",children:j.data?.name??K?.name??a("ui.hub.skills.title")}),e.jsx(Ke,{children:j.data&&te?Ls(j.data,s.organization):I})]}),j.isLoading&&e.jsx("output",{className:"text-meta text-ink-muted",children:a("ui.hub.skills.loading")}),j.error&&e.jsx("p",{role:"alert",className:"text-body-sm text-warning",children:a("ui.hub.status.other_error")}),j.data&&te&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("p",{className:"text-body-sm text-ink-muted",children:[Ps(he,U),e.jsx("span",{"aria-hidden":"true",className:"mx-1.5",children:"·"}),a("ui.hub.skills.revision",{revision:String(j.data.content_revision)})]}),e.jsx(Ts,{mark:Cs(he,Ne,se)})]}),e.jsx("p",{"data-testid":"hub-skill-description",className:"max-w-3xl select-text whitespace-pre-wrap break-words text-body-sm text-ink-muted",children:j.data.description}),_&&se&&_.local_path&&e.jsx("p",{"data-testid":"hub-skill-local-path",className:"break-words font-mono text-meta text-ink-dim",children:a("ui.hub.skills.local_path",{path:`⁨${_.local_path}⁩`})}),e.jsx("h4",{className:"text-body-sm text-ink",children:a("ui.hub.skills.files")}),e.jsx("p",{className:"text-meta text-ink-muted",children:a("ui.hub.skills.file_count",{count:j.data.files.length})}),j.data.files.map(o=>e.jsxs("details",{className:"min-w-0",children:[e.jsx("summary",{className:"break-words text-mono-sm text-ink",children:o.path}),e.jsx(Ds,{readOnly:!0,rows:12,"aria-label":o.path,value:o.content,className:"max-h-96 bg-sunken text-mono-sm"})]},o.path)),_&&e.jsxs("div",{className:"flex flex-col gap-2 border-t border-hairline pt-3",children:[e.jsx(ra,{link:_}),_.policy.subscribe&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(C,{variant:"outline",size:"sm","data-testid":"hub-skill-unsubscribe",disabled:x.isPending||!x.canWrite,onClick:V,children:a("ui.hub.skills.unsubscribe")}),e.jsx("span",{className:"text-meta text-ink-muted",children:a("ui.hub.skills.unsubscribe_help")})]}),x.error&&e.jsx("p",{role:"alert",className:"text-meta text-danger",children:a("ui.hub.subscriptions.save_failed",{setting:b==="subscribe"?a("ui.hub.subscriptions.subscribe"):a("ui.hub.skills.unsubscribe"),source:I})})]}),_&&se&&e.jsx(pa,{kind:"skill",name:_.name,enabled:P}),k.error&&e.jsx("p",{role:"alert",className:"text-body-sm text-danger","data-testid":"hub-skill-pull-failed",children:a(As(k.error)?"ui.hub.skills.local_exists":"ui.hub.skills.pull_failed")}),k.data&&!k.data.reports?.some(o=>o.applied||o.outcome==="unchanged")&&e.jsx("p",{role:"alert",className:"text-body-sm text-danger","data-testid":"hub-skill-pull-failed",children:a("ui.hub.skills.pull_failed")}),k.data?.link&&k.data.reports?.some(o=>o.link_id===M&&o.direction==="pull"&&o.applied)&&e.jsx("output",{"data-testid":"hub-skill-installed",className:"text-body-sm text-ink",children:a("ui.hub.skills.installed_alias",{item:k.data.link.name,source:Ys(k.data.link)})}),u.error&&e.jsx("p",{role:"alert",className:"text-body-sm text-danger","data-testid":"hub-skill-unpull-failed",children:a("ui.hub.skills.unpull_failed")}),y.error&&e.jsx("p",{role:"alert",className:"text-body-sm text-danger","data-testid":"hub-skill-subscribe-failed",children:a(As(y.error)?"ui.hub.skills.local_exists":"ui.hub.skills.subscribe_failed")}),!t&&e.jsx("p",{className:"text-meta text-ink-muted",children:a("ui.hub.status.no_credential")}),(!_||!se)&&e.jsxs(Ve,{className:"flex-row flex-wrap justify-start gap-2",children:[e.jsx(C,{"data-testid":"hub-skill-download",disabled:!t||!ae||k.isPending||!N,"aria-label":a("ui.hub.skills.pull_title",{item:j.data.name,source:I}),onClick:()=>le(_),children:a("ui.hub.skills.download")}),!_?.policy.subscribe&&e.jsx(C,{variant:"outline","data-testid":"hub-skill-subscribe",disabled:!t||!ae||!N||y.isPending||x.isPending||(_?!x.canWrite:!1),onClick:Fe,children:a("ui.hub.subscriptions.subscribe")})]}),_&&se&&e.jsx(Ve,{className:"flex-row flex-wrap justify-start gap-2",children:e.jsx(C,{variant:"outline","data-testid":"hub-skill-unpull",disabled:u.isPending,onClick:()=>{u.reset(),S(!0)},children:a("ui.hub.skills.unpull")})}),(!_||!se)&&e.jsx("p",{className:"text-meta text-ink-muted",children:_?.policy.subscribe?a("ui.hub.skills.download_help"):a("ui.hub.skills.subscribe_help")})]})]})}),e.jsx($e,{open:F,onOpenChange:o=>{o||S(!1)},children:e.jsxs(He,{className:"sm:max-w-md",children:[e.jsxs(Be,{children:[e.jsx(Qe,{children:a("ui.hub.skills.unpull_title",{item:j.data?.name??_?.name??""})}),e.jsx(Ke,{children:a("ui.hub.skills.unpull_body")})]}),e.jsxs(Ve,{children:[e.jsx(C,{variant:"outline",onClick:()=>S(!1),children:a("ui.hub.subscriptions.cancel")}),e.jsx(C,{"data-testid":"hub-skill-unpull-confirm",disabled:u.isPending,onClick:()=>{Oe(),S(!1)},children:a("ui.hub.skills.unpull")})]})]})}),e.jsx($e,{open:E,onOpenChange:f,children:e.jsxs(He,{className:"max-h-[85vh] overflow-y-auto sm:max-w-2xl",children:[e.jsxs(Be,{children:[e.jsx(Qe,{children:a("ui.hub.skills.publish_title")}),e.jsx(Ke,{children:I})]}),e.jsx(Ua,{scope:s,source:I,verifiedCas:R&&i&&t,enabled:R&&i&&t,heading:!1})]})})]})}const et={all:["org-teams"],list:s=>[...et.all,"list",s]},st=({tenantId:s,enabled:t=!0})=>{const i=oe({queryKey:et.list(s??""),queryFn:async()=>(await ca(s)).result??{teams:[]},enabled:t&&!!s,staleTime:3e5,gcTime:6e5,refetchOnWindowFocus:!1,retryOnMount:!1,retry:Ze});return{...i,teams:i.data?.teams??[]}},$a=(s,t)=>{const i=s?.name?.trim()||t?.trim()||"Team",n=s?.renamed_from?.trim()||null;return s?.invalid_name===!0&&n?{level:"warning",message:a("ui.notices.hub.team_pulled_renamed",{stored:i,published:n})}:n?{level:"success",message:a("ui.notices.hub.team_pulled_collision",{stored:i,published:n})}:{level:"success",message:a("ui.notices.hub.team_pulled",{name:i})}},tt=()=>{const s=ne();return ye({mutationFn:async({teamId:t,tenantId:i})=>{if(!G.baseUrl)throw new Error("Local Operator API URL is not configured.");return Et.pullOrgTeamFromRadient(G.baseUrl,t,i)},onSuccess:(t,i)=>{const n=$a(t.result,i.name);n.level==="warning"?Rt(n.message):At(n.message),s.invalidateQueries({queryKey:["desktop","teams"]})},onError:t=>{console.error("Pulling an organization team failed:",t)}})},Ha=/^v/i,at=s=>s.members.reduce((t,i)=>t+i.count,0),Ba=s=>s.count>1?`${s.role} ×${s.count}`:s.role,Je=s=>s.members.map(Ba).join(", "),it=s=>{const t=(s.version??"").trim().replace(Ha,"").trim();return t===""?null:t},nt=s=>{const t=s.account_metadata?.name?.trim();return t||null},Qa=s=>{const t=(s.description??"").trim();return t===""?null:t},Xe=240,Ka=Xe/2,Va=(s,t)=>{if(t||s.length<=Xe)return s;const i=s.slice(0,Xe),n=i.lastIndexOf(" ");return`${(n>=Ka?i.slice(0,n):i).trimEnd()}…`},Te=s=>Lt(s,{day:"numeric",month:"short",year:"numeric"}),Ie=s=>{if(!s)return null;const t=new Date(s);return Number.isNaN(t.getTime())?null:t},Fs=(s,t,i)=>{const n=i-t.getTime();let l;return n<0?l=Te(t):n<6e4?l=a("ui.hub.updates.ago.now"):l=Kt(t,i),{label:s,when:l,iso:t.toISOString(),exact:Te(t)}},Wa=(s,t=Date.now())=>{const i=Ie(s.updated_at);if(i)return Fs("updated",i,t);const n=Ie(s.created_date);return n?Fs("created",n,t):null},Ya=s=>{const t=Ie(s.created_date),i=Ie(s.updated_at);return{created:t?Te(t):null,updated:i?Te(i):null}},Ga=s=>s==="role"?a("ui.hub.teams.kind.role"):s==="specialist"?a("ui.hub.teams.kind.specialist"):s,Ja=["refresh-hub","retry","sign-in"],Xa=({tenantId:s,orgName:t})=>{const{teams:i,isLoading:n,isFetching:l,isError:d,error:m,refetch:L}=st({tenantId:s}),p=Gs(m),v=tt(),[F,S]=r.useState(null),[b,h]=r.useState(null),E=r.useRef(new Map),f=r.useRef(null);r.useEffect(()=>{v.isPending||f.current===null||(E.current.get(f.current)?.focus(),f.current=null)},[v.isPending]);const[w,I]=r.useState(!1),[O,P]=r.useState(()=>new Set),g=(u,x)=>P(A=>{const z=new Set(A);return x?z.add(u):z.delete(u),z}),R=(u,x)=>{u.key!=="Escape"||!O.has(x)||(u.target instanceof Element?u.target:null)?.closest('[data-testid="org-team-pull-error"]')||(g(x,!1),u.currentTarget.querySelector("button[aria-expanded]")?.focus(),u.preventDefault())},j=r.useMemo(()=>{if(!$s(v.error))return null;const u=i.find(x=>x.id===F);return Bs({code:v.error.code,message:v.error.message,details:v.error.details},{name:u?.name??"this team",hubAgentId:null,surface:"pull"})},[v.error,F,i]),k=(u,x)=>{switch(u){case"refresh-hub":L();break;case"retry":y(x);break;case"sign-in":I(!0);break}},y=u=>{v.isPending||(f.current=u.id,S(null),h(u.id),v.mutate({teamId:u.id,tenantId:s,name:u.name},{onSettled:()=>h(null),onError:()=>S(u.id)}))};return e.jsxs("section",{className:"mb-6 max-w-4xl rounded-md bg-surface","aria-label":a("ui.hub.teams.org.aria",{org:t??a("ui.hub.pages.scope.org_unnamed")}),"data-testid":"org-teams",children:[n&&e.jsxs("div",{"aria-hidden":"true",className:"flex flex-col divide-y divide-hairline","data-testid":"org-teams-loading",children:[e.jsx(Ye,{}),e.jsx(Ye,{}),e.jsx(Ye,{})]}),!n&&d&&e.jsxs(ge,{variant:p?"warning":"danger",className:"m-4 w-auto","data-testid":"org-teams-error",children:[e.jsx(fe,{children:p==="plan"?a("ui.hub.teams.org.plan_headline"):p==="no_access"?a("ui.hub.teams.org.no_access_headline"):a("ui.hub.teams.org.load_headline")}),e.jsx(je,{children:p==="plan"?a("ui.hub.teams.org.plan_body",{org:t??a("ui.hub.pages.scope.org_unnamed")}):p==="no_access"?a("ui.hub.teams.org.no_access_body",{org:t??a("ui.hub.teams.org.that_organization")}):es(a("ui.hub.teams.org.unreadable"),m)}),p!=="no_access"&&e.jsx("div",{className:"mt-2",children:e.jsx(C,{variant:"primary",size:"sm",onClick:()=>void L(),disabled:l,"aria-busy":l,children:l?a("ui.hub.teams.public.trying"):ce.retry})})]}),!n&&!d&&i.length===0&&e.jsx("p",{className:"p-4 text-body-sm text-ink-muted","data-testid":"org-teams-empty",children:a("ui.hub.teams.org.empty",{org:t??a("ui.hub.pages.scope.org_unnamed")})}),!n&&!d&&i.length>0&&e.jsx("ul",{className:"flex flex-col divide-y divide-hairline",children:i.map(u=>e.jsxs("li",{className:B(lt,"transition-colors duration-fast ease-out-quart hover:bg-elevated first:rounded-t-md last:rounded-b-md"),onKeyDown:x=>R(x,u.id),children:[e.jsx(Hs,{className:"min-w-0",open:O.has(u.id),onOpenChange:x=>g(u.id,x),summaryAlign:"firstLine",triggerClassName:"min-w-0",chevronClassName:"text-ink-dim mt-1",rowClassName:"py-0",summary:e.jsx(si,{team:u,expanded:O.has(u.id)}),trailing:e.jsx("div",{className:"-mt-1 ml-3 shrink-0 self-start",children:e.jsx(C,{ref:x=>{x?E.current.set(u.id,x):E.current.delete(u.id)},variant:"secondary",size:"sm",onClick:()=>y(u),disabled:v.isPending,"aria-label":a("ui.hub.teams.pull_target",{name:ie(u.name)}),children:b===u.id?a("ui.hub.teams.pulling"):a("ui.hub.teams.pull")})}),children:e.jsx(ti,{team:u})}),F===u.id&&e.jsxs("div",{className:"mt-1 flex flex-col items-start gap-1 pl-5","data-testid":"org-team-pull-error",children:[e.jsx("output",{className:"text-meta text-danger",children:j?.body??v.error?.message??a("ui.hub.teams.pull_failed",{name:ie(u.name)})}),j?.actions.filter(x=>Ja.includes(x)).map(x=>e.jsx(C,{variant:"primary",size:"sm",onClick:()=>k(x,u),children:ce[x]},x)),w&&e.jsx("div",{className:"mt-1","data-testid":"org-team-pull-reauth",children:e.jsx(Js,{titleText:ce["sign-in"],descriptionText:"",onSignInSuccess:()=>{I(!1),S(null),L()}})})]})]},u.id))})]})},lt="px-4 py-3",rt=()=>e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":"true",className:"mx-1.5",children:"·"}),e.jsx("span",{className:"sr-only",children:", "})]}),Za=({team:s})=>{Z();const t=s.manager?.trim(),i=at(s);return e.jsxs("span",{className:"block truncate text-meta",children:[t?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-ink-dim",children:a("ui.hub.teams.manager_label")})," ",e.jsx("span",{className:"text-ink-muted",children:t})]}):null,t?e.jsx(rt,{}):null,s.members.length===0?e.jsx("span",{className:"text-ink-dim",children:a("ui.hub.teams.no_members")}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-ink-dim",children:a("ui.hub.teams.member_count",{count:i})})," ",e.jsx("span",{className:"text-ink-muted",children:Je(s)})]})]})},ei=({team:s})=>{const t=s.project?.trim(),i=nt(s),n=Wa(s),l=[];return t&&l.push({key:"project",node:t}),i&&l.push({key:"author",node:i}),n&&l.push({key:"recency",node:e.jsxs(e.Fragment,{children:[n.label," ",e.jsx(re,{content:n.exact,children:e.jsx("time",{dateTime:n.iso,children:n.when})})]})}),l.length===0?null:e.jsx("span",{className:"block truncate text-ink-dim text-meta",children:l.map((d,m)=>e.jsxs("span",{children:[m>0?e.jsx(rt,{}):null,d.node]},d.key))})},si=({team:s,expanded:t})=>{Z();const i=Qa(s),n=it(s);return e.jsxs("span",{className:"flex min-w-0 flex-col",children:[e.jsxs("span",{className:"flex min-w-0 items-baseline",children:[e.jsx("span",{className:"truncate font-medium text-body text-ink",children:ie(s.name)}),n?e.jsxs("span",{className:"ml-2 shrink-0 text-ink-dim text-meta",children:["v",n]}):null]}),i?e.jsxs(e.Fragment,{children:[e.jsx("span",{...Ce,"aria-hidden":"true",className:B("mt-1 select-text break-words text-body-sm text-ink-muted",t?"line-clamp-[12] whitespace-pre-line":"line-clamp-2"),children:i}),e.jsx("span",{className:"sr-only",children:Va(i,t)})]}):e.jsx("span",{className:"mt-1 text-body-sm text-ink-dim",children:a("ui.hub.teams.no_description")}),e.jsxs("span",{className:"mt-1 flex min-w-0 flex-col",children:[e.jsx(Za,{team:s}),e.jsx(ei,{team:s})]})]})},ti=({team:s})=>{Z();const t=s.manager?.trim(),i=Ya(s),n=[i.created?a("ui.hub.teams.detail.created",{date:i.created}):null,i.updated?a("ui.hub.teams.detail.updated",{date:i.updated}):null].filter(d=>d!==null),l=!!t||s.members.length>0;return e.jsxs("div",{className:"mt-1 flex flex-col gap-2",children:[l||n.length===0?e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("p",{className:"text-ink-dim text-meta",children:a("ui.hub.teams.members")}),e.jsxs("ul",{className:"flex flex-col gap-0.5",children:[t?e.jsxs("li",{className:"flex items-baseline gap-1.5",children:[e.jsx("span",{className:"text-body-sm text-ink-muted",children:t}),e.jsx("span",{className:"text-ink-dim text-meta",children:a("ui.hub.teams.manager")})]}):null,s.members.map(d=>e.jsxs("li",{className:"flex items-baseline gap-1.5",children:[e.jsx("span",{className:"text-body-sm text-ink-muted",children:d.role}),e.jsx("span",{className:"text-ink-dim text-meta",children:Ga(d.kind)}),d.count>1?e.jsxs("span",{className:"text-ink-dim text-meta tabular-nums",children:["×",d.count]}):null]},`${d.kind}:${d.role}`)),l?null:e.jsx("li",{className:"text-ink-dim text-meta",children:a("ui.hub.teams.no_members")})]})]}):null,n.length>0?e.jsx("p",{className:"text-ink-dim text-meta",children:n.join(" · ")}):null]})},Ye=()=>e.jsxs("div",{className:B(lt,"pl-9"),"data-testid":"org-team-skeleton-row",children:[e.jsx("div",{className:"flex h-[1lh] items-center text-body",children:e.jsx(T,{className:"h-4.5 w-40"})}),e.jsxs("div",{className:"mt-1 flex h-[2lh] flex-col justify-evenly text-body-sm",children:[e.jsx(T,{className:"h-3.5 w-full"}),e.jsx(T,{className:"h-3.5 w-2/3"})]}),e.jsx("div",{className:"mt-1 flex h-[1lh] items-center text-meta",children:e.jsx(T,{className:"h-3 w-64"})}),e.jsx("div",{className:"flex h-[1lh] items-center text-meta",children:e.jsx(T,{className:"h-3 w-48"})})]}),ct=(s,t)=>t instanceof Ws?t.message:es(s,t),ai=["refresh-hub","retry","sign-in"],ii=({signedIn:s,onOpenSettings:t})=>{Z();const[i,n]=r.useState(1),[l,d]=r.useState(""),{teams:m,isLoading:L,isFetching:p,isError:v,error:F,refetch:S,pagination:b}=Xs({page:i,perPage:ns}),h=tt(),[E,f]=r.useState(null),[w,I]=r.useState(null),O=r.useRef(new Map),P=r.useRef(null);r.useEffect(()=>{h.isPending||P.current===null||(O.current.get(P.current)?.focus(),P.current=null)},[h.isPending]);const g=Vt(l.trim()),R=r.useMemo(()=>g?m.filter(N=>ie(N.name).toLowerCase().includes(g)||(N.description??"").toLowerCase().includes(g)):m,[m,g]),j=N=>{h.isPending||(f(null),I(N.id),P.current=N.id,h.mutate({teamId:N.id,name:N.name},{onSettled:()=>I(null),onError:()=>f(N.id)}))},k=r.useMemo(()=>{if(!$s(h.error))return null;const N=m.find(U=>U.id===E);return Bs({code:h.error.code,message:h.error.message,details:h.error.details},{name:N?.name??"this team",hubAgentId:null,surface:"pull"})},[h.error,E,m]),y=k?.body??(yt(h.error)==="unauthorized"?a("ui.hub.teams.public.pull_no_signin"):a("ui.hub.teams.public.pull_failed")),[u,x]=r.useState(!1),A=(N,U)=>{switch(N){case"refresh-hub":S();break;case"retry":j(U);break;case"sign-in":x(!0);break}},z=L&&m.length===0,Q=b?.totalRecords??m.length,D=r.useRef(null),M=N=>{const U=l!=="";d(N),U&&N===""&&D.current?.focus()};return e.jsxs("section",{"aria-label":a("ui.hub.teams.public.aria"),className:"flex flex-col","data-testid":"agent-hub-public-teams",children:[e.jsx("h2",{className:"sr-only",children:a("ui.hub.teams.public.aria")}),e.jsx("p",{className:"mb-3 max-w-3xl text-body-sm text-ink-muted",children:a("ui.hub.teams.public.intro")}),s?null:e.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-2","data-testid":"agent-hub-public-teams-signed-out",children:[e.jsx("span",{className:"text-meta text-ink-dim",children:a("ui.hub.teams.public.sign_in_hint")}),e.jsx(C,{variant:"secondary",size:"sm",onClick:t,children:a("ui.hub.teams.public.open_settings")})]}),e.jsx("div",{className:"mb-4 flex flex-wrap items-center gap-2",children:e.jsxs("div",{className:B("flex min-w-56 max-w-md flex-1 items-center rounded-sm border border-control bg-surface","transition-colors duration-fast ease-out-quart","has-[:focus-visible]:outline-solid has-[:focus-visible]:outline-2","has-[:focus-visible]:outline-accent has-[:focus-visible]:outline-offset-2"),children:[e.jsx(Ms,{"aria-hidden":"true",className:"ml-2 shrink-0 text-ink-dim"}),e.jsx(Ae,{ref:D,type:"search",value:l,onChange:N=>M(N.target.value),placeholder:a("ui.hub.teams.public.search_placeholder"),"aria-label":a("ui.hub.teams.public.search_aria"),className:"h-8 min-w-0 flex-1 border-0 bg-transparent outline-none","data-testid":"agent-hub-public-teams-search"})]})}),z&&e.jsxs("div",{"aria-hidden":"true",className:"flex max-w-4xl flex-col gap-3","data-testid":"agent-hub-public-teams-loading",children:[e.jsx(Ge,{}),e.jsx(Ge,{}),e.jsx(Ge,{})]}),!z&&v&&e.jsxs(ge,{variant:"danger",className:"w-auto max-w-2xl","data-testid":"agent-hub-public-teams-error",children:[e.jsx(fe,{children:a("ui.hub.teams.public.load_failed")}),e.jsx(je,{children:ct(a("ui.hub.teams.public.catalogue_unreadable"),F)}),e.jsx("div",{className:"mt-2",children:e.jsx(C,{variant:"primary",size:"sm",onClick:()=>void S(),disabled:p,"aria-busy":p,children:p?a("ui.hub.teams.public.trying"):a("ui.common.actions.retry_again")})})]}),!z&&!v&&m.length===0&&e.jsx("p",{className:"max-w-2xl text-body-sm text-ink-muted","data-testid":"agent-hub-public-teams-empty",children:a("ui.hub.teams.public.empty")}),!z&&!v&&m.length>0&&e.jsxs(e.Fragment,{children:[!g||R.length>0?e.jsxs("p",{className:"mb-3 text-meta text-ink-dim","data-testid":"agent-hub-public-teams-status",children:[g?a("ui.hub.teams.public.match_line",{visible:String(R.length),total:m.length,query:l.trim()}):a("ui.hub.pages.status.count.teams",{count:Q,scope:a("ui.hub.pages.status.scope.public")}),g?e.jsxs("span",{className:"text-ink-dim",children:[" ",a("ui.hub.teams.public.search_scope")]}):null]}):null,R.length===0?e.jsx("p",{className:"max-w-2xl text-body-sm text-ink-muted","data-testid":"agent-hub-public-teams-search-miss",children:a("ui.hub.teams.public.search_miss",{query:l.trim()})}):e.jsx("ul",{className:"flex max-w-4xl flex-col gap-3",children:R.map(N=>e.jsx(ni,{team:N,pulling:w===N.id,pullPending:h.isPending,onPull:j,pullButtonRef:U=>{U?O.current.set(N.id,U):O.current.delete(N.id)},failed:E===N.id,failureBody:y,treatment:k,onTreatmentAction:A,reauthenticating:u,onReauthenticated:()=>{x(!1),f(null),S()}},N.id))}),!g&&b&&b.totalPages>1&&e.jsx(as,{count:b.totalPages,page:b.page,onChange:N=>{n(N),D.current?.scrollIntoView({block:"nearest"})}})]})]})},ni=({team:s,pulling:t,pullPending:i,onPull:n,failed:l,failureBody:d,treatment:m,onTreatmentAction:L,reauthenticating:p,onReauthenticated:v,pullButtonRef:F})=>{Z();const[S,b]=r.useState(!1),h=La({teamId:S?s.id:void 0}),E=ie(s.name),f=it(s),w=nt(s),I=s.manager?.trim(),O=at(s),P=(s.description??"").trim();return e.jsxs("li",{className:"rounded-md bg-surface p-4","data-testid":"agent-hub-public-team","data-team-name":s.name,children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-baseline",children:[e.jsx("h3",{className:"truncate font-medium text-heading text-ink",children:E}),f?e.jsxs("span",{className:"ml-2 shrink-0 text-ink-dim text-meta",children:["v",f]}):null]}),P?e.jsx("p",{...Ce,className:"mt-1 line-clamp-3 max-w-3xl select-text text-body-sm text-ink-muted",children:P}):e.jsx("p",{className:"mt-1 text-body-sm text-ink-dim",children:a("ui.hub.teams.no_description")}),e.jsxs("p",{className:"mt-2 flex flex-wrap items-baseline gap-x-2 text-meta",children:[I?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-ink-dim",children:a("ui.hub.teams.manager_label")}),e.jsx("span",{className:"text-ink-muted",children:I})]}):null,s.members.length===0?e.jsx("span",{className:"text-ink-dim",children:a("ui.hub.teams.no_members")}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-ink-dim",children:a("ui.hub.teams.member_count",{count:O})}),e.jsx(re,{content:Je(s),children:e.jsx("span",{className:"truncate text-ink-muted",children:Je(s)})})]})]}),w?e.jsxs("p",{className:"mt-1 text-ink-dim text-meta",children:[a("ui.hub.teams.public.published_by")," ",e.jsx("span",{className:"text-ink-muted",children:w})]}):null]}),e.jsxs("div",{className:"flex shrink-0 flex-col items-end gap-2",children:[e.jsx(C,{ref:F,variant:"secondary",size:"sm",onClick:()=>n(s),disabled:i,"aria-label":a("ui.hub.teams.pull_target",{name:E}),children:t?a("ui.hub.teams.pulling"):a("ui.hub.teams.pull")}),l&&e.jsxs("div",{className:"flex max-w-56 flex-col items-end gap-1","data-testid":"agent-hub-public-team-pull-error",children:[e.jsx("output",{className:"text-right text-meta text-danger",children:d}),m?.actions.filter(g=>ai.includes(g)).map(g=>e.jsx(C,{variant:"primary",size:"sm",onClick:()=>L(g,s),children:ce[g]},g)),p&&e.jsx("div",{"data-testid":"agent-hub-public-team-pull-reauth",children:e.jsx(Js,{titleText:ce["sign-in"],descriptionText:"",onSignInSuccess:v})})]})]})]}),e.jsx("div",{className:"mt-2",children:e.jsx(Hs,{summary:a("ui.hub.teams.brief.trigger"),open:S,onOpenChange:b,className:"w-full",triggerClassName:"w-full",triggerLabel:a("ui.hub.teams.brief.trigger_aria",{name:E}),chevronClassName:"text-ink-dim",children:e.jsx(li,{detail:h})})})]})},li=({detail:s})=>{if(Z(),s.isLoading)return e.jsxs("div",{className:"flex flex-col gap-1","data-testid":"agent-hub-public-team-brief-loading",children:[e.jsx(T,{className:"h-[1lh] w-2/3"}),e.jsx(T,{className:"h-[2lh] w-full"})]});if(s.isError)return e.jsxs("div",{className:"flex flex-col items-start gap-1",children:[e.jsx("output",{className:"text-meta text-danger",children:ct(a("ui.hub.teams.brief.unreadable"),s.error)}),e.jsx(C,{variant:"primary",size:"sm",onClick:()=>void s.refetch(),disabled:s.isFetching,"aria-busy":s.isFetching,children:s.isFetching?a("ui.hub.teams.public.trying"):ce.retry})]});const t=s.team;if(!t)return null;const i=(t.instructions??"").trim(),n=(t.project??"").trim();return e.jsxs("div",{className:"flex max-w-3xl flex-col gap-3 text-body-sm","data-testid":"agent-hub-public-team-brief",children:[e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("p",{className:"text-ink-dim text-meta",children:a("ui.hub.teams.brief.collaboration")}),i?e.jsx("p",{...Ce,className:"whitespace-pre-line select-text text-ink-muted",children:i}):e.jsx("p",{className:"text-ink-dim",children:a("ui.hub.teams.brief.collaboration_empty")})]}),e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("p",{className:"text-ink-dim text-meta",children:a("ui.hub.teams.brief.project")}),n?e.jsx("p",{...Ce,className:"whitespace-pre-line select-text text-ink-muted",children:n}):e.jsx("p",{className:"text-ink-dim",children:a("ui.hub.teams.brief.project_empty")})]}),e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("p",{className:"text-ink-dim text-meta",children:a("ui.hub.teams.brief.roster")}),e.jsxs("ul",{className:"flex flex-col gap-0.5",children:[t.manager?.trim()?e.jsxs("li",{className:"flex items-baseline gap-1.5",children:[e.jsx("span",{className:"text-body-sm text-ink-muted",children:t.manager.trim()}),e.jsx("span",{className:"text-ink-dim text-meta",children:a("ui.hub.teams.manager")})]}):null,t.members.length===0?e.jsx("li",{className:"text-ink-dim",children:a("ui.hub.teams.no_members")}):t.members.map(l=>e.jsxs("li",{className:"flex items-baseline gap-1.5",children:[e.jsx("span",{className:"text-body-sm text-ink-muted",children:l.count>1?`${l.role} ×${l.count}`:l.role}),e.jsx("span",{className:"text-ink-dim text-meta",children:l.kind})]},`${l.kind}:${l.role}`))]})]})]})},Ge=()=>e.jsxs("div",{className:"rounded-md bg-surface p-4",children:[e.jsx(T,{className:"h-[1lh] w-1/3"}),e.jsx(T,{className:"mt-1 flex h-[3lh] w-full"}),e.jsx(T,{className:"mt-2 h-[1lh] w-2/3"})]}),ri=(s,t)=>{const[i,n]=r.useState(s);return r.useEffect(()=>{const l=setTimeout(()=>n(s),t);return()=>clearTimeout(l)},[s,t]),i},Se=[{value:"download_count:desc",label:"ui.hub.pages.sort.most_downloaded",sort:"download_count",order:"desc"},{value:"like_count:desc",label:"ui.hub.pages.sort.most_liked",sort:"like_count",order:"desc"},{value:"favourite_count:desc",label:"ui.hub.pages.sort.most_favourited",sort:"favourite_count",order:"desc"},{value:"created_at:desc",label:"ui.hub.pages.sort.newest",sort:"created_at",order:"desc"},{value:"updated_at:desc",label:"ui.hub.pages.sort.recently_updated",sort:"updated_at",order:"desc"},{value:"name:asc",label:"ui.hub.pages.sort.name_asc",sort:"name",order:"asc"}],ci=[{value:"name",label:"ui.hub.pages.search_field.name"},{value:"description",label:"ui.hub.pages.search_field.description"}],ui=300,H="public",Os={agents:"agent-hub-view-agents",teams:"agent-hub-view-teams",skills:"agent-hub-view-skills"},qs="agent-hub-view-panel",oi=()=>e.jsxs("div",{className:"flex h-full flex-col overflow-hidden rounded-md bg-surface",children:[e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-2 p-4",children:[e.jsx(T,{className:"h-5.5 w-2/3"}),e.jsx(T,{className:"h-3.5 w-full"}),e.jsx(T,{className:"h-3.5 w-full"}),e.jsx(T,{className:"h-3.5 w-1/2"}),e.jsxs("div",{className:"mt-auto flex flex-col gap-2 pt-2",children:[e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(T,{className:"h-5.5 w-24"}),e.jsx(T,{className:"h-5.5 w-20"})]}),e.jsx("div",{className:"flex items-center gap-1.5",children:e.jsx(T,{className:"h-5.5 w-24"})})]}),e.jsx(T,{className:"h-4.5 w-32"})]})]}),e.jsxs("div",{className:"flex items-center gap-2 border-t border-hairline px-3 py-2",children:[e.jsx(T,{className:"size-4"}),e.jsx(T,{className:"h-4 w-6"}),e.jsx(T,{className:"size-4"}),e.jsx(T,{className:"h-4 w-6"}),e.jsx(T,{className:"ml-auto h-7 w-16"})]})]}),Pi=()=>{const s=zs(),{isAuthenticated:t}=ss(),[i,n]=r.useState(1),[l]=r.useState(12),[d,m]=r.useState(null),[L,p]=r.useState(""),[v,F]=r.useState("name"),[S,b]=r.useState(Se[0].value),[h,E]=r.useState(H),[f,w]=r.useState("agents");Z();const[I,O]=r.useState([]),P=ri(L,ui),g=Se.find(c=>c.value===S)??Se[0],R=Re(),j=!R.isError&&ue(R.data,"hub_skills"),k=f==="skills"&&!j?"agents":f;r.useEffect(()=>{f==="skills"&&!j&&w("agents")},[f,j]);const y=Ft(),u=vt(R.data,"radient_org"),x=t?ka(u,y??null):null,{memberships:A}=ua({enabled:We(u)}),z=r.useMemo(()=>ja(A),[A]),Q=h===H||z.some(c=>c.tenant_id===h);r.useEffect(()=>{!Q&&k!=="skills"&&E(H)},[Q,k]);const D=h===H?null:z.find(c=>c.tenant_id===h)??null,M=D?.tenant_id,N=D?.tenant_name||null,U=d!==null||P!=="",te=st({tenantId:M}),ae=Xs({page:1,perPage:ns,enabled:h===H}),me=M&&te.isSuccess?te.teams.length:null,ve=ae.isSuccess?ae.pagination?.totalRecords??null:null,K=U?null:h===H?ve:me,_=h===H?{visibility:"public",tenantId:null}:{visibility:"org",tenantId:h},Ne=Q&&(h===H||We(u)),he=Zs(_,1,j&&Ne&&(h===H||t)),se=he.isSuccess?he.data.total:null,Le=D?.role==="owner"||D?.role==="admin",xe=r.useMemo(()=>new Map(A.map(c=>[c.tenant_id,c.tenant_name])),[A]),{data:le,agents:Fe,isLoading:Oe,isFetching:V,error:J,refetch:be,pagination:$}=zt({page:i,perPage:l,categories:d?[d]:void 0,name:v==="name"&&P||void 0,description:v==="description"&&P||void 0,sort:g.sort,order:g.order,tenantId:M}),o=D?Gs(J):null,q=Fe??[],X=V&&le!==void 0,{statuses:pe,isKnown:we,isError:ut,isFetching:qe,refetch:ot}=Wt({agentIds:M?[]:q.map(c=>c.id)}),ze=r.useRef(null),De=r.useRef(null),[cs,dt]=r.useState(0);r.useEffect(()=>{cs!==0&&(ze.current??De.current)?.focus()},[cs]);const us=r.useRef(null),Ue=r.useRef(!1),Me=r.useMemo(()=>[...new Set((le?.records??[]).flatMap(c=>c.categories??[]))],[le]);r.useEffect(()=>{O(c=>Me.every(Y=>c.includes(Y))?c:[...new Set([...c,...Me])])},[Me]);const mt=()=>{m(null),p(""),n(1),dt(c=>c+1)},W=(Oe||V)&&le===void 0,os=!W&&!U&&(J!==null||q.length===0);r.useEffect(()=>{!Ue.current||W||(Ue.current=!1,J?us.current?.focus():(ze.current??De.current)?.focus())},[W,J]);const ds=r.useRef(null),ht=c=>{n(c),ds.current?.scrollIntoView({block:"nearest"})},xt=c=>{m(c),n(1)},bt=c=>{p(c),n(1)},pt=c=>{E(c),n(1)},ms=r.useRef(new Map),gt=c=>{F(c),n(1)},ft=$&&!U?$.totalRecords:null,_e=M?a("ui.hub.pages.status.scope.shared_with",{org:N??a("ui.hub.pages.scope.org_unnamed")}):a("ui.hub.pages.status.scope.public"),hs=(c,Y)=>Y==="team"?a("ui.hub.pages.status.count.teams",{count:c,scope:_e}):a("ui.hub.pages.status.count.agents",{count:c,scope:_e});let ee;return k==="skills"?ee=" ":k==="teams"?M?te.isLoading?ee=a("ui.hub.pages.status.loading_teams"):K!==null?ee=hs(K,"team"):ee=a("ui.hub.pages.status.teams_scope",{scope:_e}):ee=" ":W?ee=a("ui.hub.pages.status.loading_agents"):$?ee=hs($.totalRecords,"agent"):ee=a("ui.hub.pages.status.agents_scope",{scope:_e}),e.jsxs("div",{className:"flex h-full flex-col gap-8 p-6",children:[e.jsx(Nt,{title:a("ui.hub.pages.header.title"),subtitle:a("ui.hub.pages.header.subtitle"),icon:oa}),e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-4",children:[x&&e.jsxs(ge,{variant:"warning",className:"max-w-2xl","data-testid":"agent-hub-org-unavailable",children:[e.jsx(fe,{children:a("ui.hub.pages.orgs_unavailable")}),e.jsx(je,{children:x})]}),e.jsxs("div",{className:"flex shrink-0 flex-wrap items-center gap-x-4 gap-y-2","data-testid":"agent-hub-browse-bar",children:[e.jsx(St,{value:k,onValueChange:c=>w(c),children:e.jsx(Ct,{"aria-label":a("ui.hub.pages.browse_aria"),children:["agents","teams",...j?["skills"]:[]].map(c=>{const Y=c==="agents"?ft:c==="teams"?K:se;return e.jsxs(Pt,{value:c,id:Os[c],"aria-controls":k===c?qs:void 0,"data-testid":`agent-hub-view-${c}`,children:[c==="agents"?a("ui.hub.pages.tab.agents"):c==="teams"?a("ui.hub.pages.tab.teams"):a("ui.hub.skills.title"),Y!==null&&e.jsx("span",{className:"min-w-[2ch] font-normal text-ink-dim tabular-nums",children:Y})]},c)})})}),z.length>0&&e.jsxs("div",{className:"ml-auto flex min-w-0 items-center gap-2",children:[e.jsx("span",{"aria-hidden":"true",className:"text-meta text-ink-muted",children:a("ui.hub.pages.scope_label")}),e.jsxs("fieldset",{className:"m-0 min-w-0 border-0 p-0","data-testid":"agent-hub-scope",children:[e.jsx("legend",{className:"sr-only",children:a("ui.hub.pages.scope_legend")}),e.jsx("div",{className:"flex flex-wrap gap-0.5 rounded-md bg-sunken p-0.5",children:[{value:H,label:a("ui.hub.pages.scope.public"),Icon:Ot},...z.map(c=>({value:c.tenant_id,label:c.tenant_name||a("ui.hub.pages.scope.org_label"),Icon:ya}))].map(({value:c,label:Y,Icon:jt})=>e.jsxs(C,{ref:xs=>{xs?ms.current.set(c,xs):ms.current.delete(c)},variant:"ghost",size:"sm","aria-pressed":h===c,onClick:()=>pt(c),title:Y,"data-testid":`agent-hub-scope-${c===H?"public":`org-${c}`}`,className:B("max-w-48",h===c&&"bg-surface text-ink hover:bg-surface"),children:[e.jsx(jt,{"aria-hidden":"true"}),e.jsx("span",{className:"truncate",children:Y})]},c))})]})]})]}),e.jsx(Tt,{id:qs,labelledBy:Os[k],children:e.jsxs("div",{className:"flex min-h-0 flex-1 flex-row overflow-hidden",children:[k==="agents"&&e.jsx(e.Fragment,{children:e.jsx("div",{className:"mr-6 hidden w-60 shrink-0 rounded-md bg-surface p-2 md:block","data-glass-region":"panel","data-tour-tag":"agent-hub-sidebar-container",children:!os&&e.jsx(Ca,{selectedCategory:d,onSelectCategory:xt,categories:I})})}),e.jsxs("div",{className:"flex min-w-0 flex-1 flex-col overflow-y-auto",children:[k==="agents"&&!os&&e.jsxs("div",{className:"mb-4 flex flex-wrap items-center gap-2",children:[e.jsxs("div",{className:B("flex min-w-56 flex-1 items-center rounded-sm border border-control bg-surface","transition-colors duration-fast ease-out-quart","has-[:focus-visible]:outline-solid has-[:focus-visible]:outline-2","has-[:focus-visible]:outline-accent has-[:focus-visible]:outline-offset-2"),children:[e.jsx(Ae,{ref:ze,type:"search",value:L,onChange:c=>bt(c.target.value),placeholder:a("ui.hub.pages.search.placeholder"),"aria-label":a("ui.hub.pages.search.aria"),className:"h-8 min-w-0 flex-1 border-0 bg-transparent outline-none","data-testid":"agent-hub-search"}),e.jsxs(ps,{value:v,onValueChange:gt,children:[e.jsx(gs,{className:"w-auto shrink-0 border-y-0 border-l border-hairline border-r-0 bg-transparent pl-2 outline-none","aria-label":a("ui.hub.pages.search.scope_aria"),"data-testid":"agent-hub-search-scope",children:e.jsx(fs,{})}),e.jsx(js,{children:ci.map(c=>e.jsx(ks,{value:c.value,children:a(c.label)},c.value))})]})]}),e.jsxs(ps,{value:S,onValueChange:b,children:[e.jsx(gs,{className:"w-48","aria-label":a("ui.hub.pages.sort.aria"),"data-testid":"agent-hub-sort",children:e.jsx(fs,{})}),e.jsx(js,{children:Se.map(c=>e.jsx(ks,{value:c.value,children:a(c.label)},c.value))})]})]}),e.jsxs("p",{ref:ds,"aria-live":"polite",className:"mb-3 text-meta text-ink-dim","data-testid":"agent-hub-status",children:[ee,k==="agents"&&X?e.jsxs(e.Fragment,{children:[" ",e.jsx("span",{"data-testid":"agent-hub-updating",children:a("ui.hub.pages.updating")})]}):null]}),k==="agents"&&e.jsxs(e.Fragment,{children:[t&&ut&&e.jsxs("output",{className:"mb-3 flex flex-wrap items-center gap-2 text-meta text-warning","data-testid":"agent-hub-status-unknown",children:[e.jsx("span",{children:a("ui.hub.pages.viewer_unknown")}),e.jsx(C,{variant:"ghost",size:"sm",onClick:()=>void ot(),disabled:qe,"aria-busy":qe,children:qe?"Trying…":"Try again"})]}),W&&e.jsx("div",{"data-testid":"agent-hub-loading",className:"grid grid-cols-[repeat(auto-fill,minmax(17.5rem,1fr))] gap-6",children:Array.from({length:6},(c,Y)=>e.jsx(oi,{},Y))}),W&&$===void 0&&e.jsx("div",{"aria-hidden":"true",className:"mt-6 flex min-h-13 items-center justify-center","data-testid":"agent-hub-pager-placeholder",children:e.jsx(T,{className:"h-4 w-24"})}),e.jsx("output",{"aria-live":"polite","data-testid":"agent-hub-outage",className:B(!W&&J&&!o?"block":"sr-only"),children:!W&&J&&!o&&e.jsxs(ge,{variant:"danger",className:"max-w-2xl","aria-busy":V,"data-testid":"agent-hub-error",children:[e.jsx(fe,{children:t?"The hub could not be loaded":"Sign in to use the hub"}),e.jsx(je,{children:t?es("The agent list could not be loaded.",J):"You are not signed in to Radient, so the hub has no credential to read the agent list with. Sign in on the settings page, then try again."}),e.jsx("div",{className:"mt-2",children:e.jsx(C,{ref:us,variant:"outline",size:"sm",onClick:()=>{Ue.current=!0,be()},disabled:V,"aria-busy":V,children:V?"Trying…":"Try again"})})]})}),!W&&o&&D&&e.jsxs(ge,{variant:"warning",className:"max-w-2xl","data-testid":"agent-hub-org-no-access",children:[e.jsx(fe,{children:o==="plan"?"That organization needs an active Team plan":"You do not have access to that organization"}),e.jsx(je,{children:o==="plan"?`Sharing agents inside an organization is part of the Team plan. An owner of ${D.tenant_name||"this organization"} can activate it in the Radient console, and then its agents will be listed here.`:`You are not a member of ${D.tenant_name||"that organization"}, so its agents are not listed here. An owner can invite you again.`}),o==="plan"&&e.jsx("div",{className:"mt-2",children:e.jsx(C,{variant:"primary",size:"sm",onClick:()=>void be(),disabled:V,"aria-busy":V,children:V?"Trying…":"Try again"})})]}),!W&&!J&&e.jsx("div",{className:"grid grid-cols-[repeat(auto-fill,minmax(17.5rem,1fr))] gap-6","aria-busy":X,children:q.length===0?e.jsxs("div",{"data-testid":"agent-hub-empty",className:B("col-span-full w-full flex flex-col items-center gap-2 rounded-md bg-surface px-6 py-10 text-center",!M&&"max-w-2xl justify-self-center"),children:[e.jsx("p",{className:"text-heading text-ink",children:M?"This organization has no shared agents yet.":d?`No agents in ${Qs(d).label}.`:U?"No agents match that search.":"The hub is empty."}),e.jsx("p",{className:"max-w-md text-body-sm text-ink-muted",children:M?`Agents published into ${D?.tenant_name||"this organization"} appear here for its members.`:d?"Nothing in this category yet. Clear the filter to see the whole hub.":U?"No agent's name or description carries that. Clear it to see the whole hub.":"Nobody has published an agent yet. Yours could be the first."}),e.jsx("div",{className:"mt-2 flex flex-wrap items-center justify-center gap-2",children:U?e.jsx(C,{variant:"secondary",onClick:mt,children:d?"Clear filter":"Clear search"}):M&&!Le?null:e.jsx(C,{ref:De,variant:"secondary",onClick:()=>s("/agents"),children:a("ui.hub.pages.publish")})})]}):q.map(c=>e.jsx(_a,{agent:c,status:t?pe[c.id]:void 0,viewerStateKnown:t&&Yt(we,pe,c.id),orgName:c.visibility==="org"?xe.get(c.tenant_id)??null:null},c.id))}),!W&&$&&$.totalPages>1&&e.jsx(as,{count:$.totalPages,page:$.page,onChange:ht})]}),k==="skills"&&(j?e.jsx(Ma,{scope:h===H?{visibility:"public",tenantId:null,organization:null}:{visibility:"org",tenantId:h,organization:N},signedIn:t,accessible:Q&&(h===H||We(u))},`skills:${h}`):e.jsx("p",{className:"text-body-sm text-warning",children:a("ui.hub.skills.unavailable")})),k==="teams"&&(D?e.jsx(Xa,{tenantId:D.tenant_id,orgName:N}):e.jsx(ii,{signedIn:t,onOpenSettings:()=>s("/settings")}))]})]})})]})]})};export{Pi as AgentHubPage};
6
+ */const va=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M17 12h.01",key:"1m0b6t"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M7 12h.01",key:"eqddd0"}]],Na=wt("circle-ellipsis",va),wa=({agent:s,isLiked:t,isFavourited:i,onLikeToggle:n,onFavouriteToggle:l,onDownload:d,isLikeActionLoading:m=!1,isFavouriteActionLoading:L=!1,isDownloading:p=!1,actionError:v=null,onRetryAction:O,showActions:S=!0,viewerStateKnown:b=!0,orgName:h=null})=>{const E=zs(),{isAuthenticated:f}=ss(),w=s.description??"",[I,F]=r.useState(!1),P=r.useRef(null),g=r.useCallback(A=>{if(P.current?.disconnect(),P.current=null,!A)return;const z=()=>F(A.scrollHeight-A.clientHeight>1);z();const Q=new ResizeObserver(z);Q.observe(A),P.current=Q},[]),R=f?b?t?"Unlike agent":"Like agent":"Your likes could not be read, so this is not shown as unliked.":"Log in to Radient to like agents",j=f?b?i?"Unfavourite agent":"Favourite agent":"Your favourites could not be read, so this is not shown as unfavourited.":"Log in to Radient to favourite agents",k=b?t?"Unlike agent":"Like agent":"Like state unavailable",y=b?i?"Unfavourite agent":"Favourite agent":"Favourite state unavailable",u=s.visibility==="org",x=ie(s.name);return e.jsxs("div",{"data-glass-block":"",className:"flex h-full flex-col overflow-hidden rounded-md bg-surface transition-colors duration-fast ease-out-quart hover:bg-elevated",children:[e.jsxs("button",{type:"button",onClick:()=>E(`/agent-hub/${s.id}`),className:"flex min-h-0 flex-1 cursor-pointer flex-col gap-2 p-4 text-left","aria-label":`View details for ${x}`,children:[e.jsx("h3",{className:"truncate font-medium text-heading text-ink",children:x}),u&&e.jsx(Dt,{orgName:h}),e.jsx(re,{content:I?w:"",children:e.jsx("span",{ref:g,className:"line-clamp-3 min-h-0 text-body-sm text-ink-muted",children:w})}),e.jsxs("div",{className:"mt-auto flex flex-col gap-2 pt-2",children:[e.jsx(Mt,{tags:s.tags,categories:s.categories}),e.jsxs("p",{className:"truncate text-ink-dim text-meta",children:[s.account_metadata?.name??"Unknown author",e.jsx("span",{"aria-hidden":"true",className:"mx-1.5",children:"·"}),"updated ",Ut(new Date(s.updated_at))," ago"]})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 border-t border-hairline px-3 py-2",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-0.5","data-viewer-state":u?"org":f?b?"known":"unknown":"signed-out",children:[!u&&e.jsxs(e.Fragment,{children:[e.jsx(re,{content:R,children:e.jsx("span",{children:e.jsxs(C,{variant:"ghost",size:"sm",onClick:f&&b?()=>n(s.id):void 0,disabled:m||!f||!b,"aria-label":k,className:B(t&&"text-danger"),children:[e.jsx(Gt,{fill:t?"currentColor":"none","data-testid":"agent-like-heart"}),e.jsx("span",{"data-testid":"agent-like-count",className:"inline-flex h-4 min-w-4 items-center font-mono text-mono-sm text-ink-muted",children:s.like_count??0})]})})}),e.jsx(re,{content:j,children:e.jsx("span",{children:e.jsxs(C,{variant:"ghost",size:"sm",onClick:f?()=>l(s.id):void 0,disabled:L||!f||!b,"aria-label":y,className:B(i&&"text-warning"),children:[e.jsx(Jt,{fill:i?"currentColor":"none","data-testid":"agent-favourite-star"}),e.jsx("span",{"data-testid":"agent-favourite-count",className:"inline-flex h-4 min-w-4 items-center font-mono text-mono-sm text-ink-muted",children:s.favourite_count??0})]})})})]}),e.jsx(re,{content:"Downloads",children:e.jsxs("span",{className:"ml-1 inline-flex items-center gap-1 pr-1 text-ink-dim",children:[e.jsx(ys,{"aria-hidden":"true",className:"size-3.5"}),e.jsx("span",{className:"inline-flex h-4 min-w-6 items-center font-mono text-mono-sm",children:p?e.jsx(T,{className:"h-3 w-6"}):(s.download_count??0).toLocaleString()})]})})]}),S&&d&&e.jsx("div",{className:"ml-auto flex shrink-0 items-center",children:e.jsxs(C,{variant:"secondary",size:"sm",onClick:()=>d(s),disabled:p,"aria-label":`Download ${x}`,"data-tour-tag":"agent-hub-download-button",children:[e.jsx(ys,{"data-testid":"agent-download"}),"Get"]})})]}),v&&e.jsxs("output",{"data-testid":"agent-card-error",className:"flex flex-wrap items-center gap-x-2 gap-y-1 border-t border-hairline px-3 py-2 text-body-sm text-danger",children:[e.jsx("span",{className:"min-w-0 flex-1",children:v}),O&&e.jsx(C,{variant:"ghost",size:"sm",onClick:O,children:"Try again"})]})]})},_a=({agent:s,status:t,viewerStateKnown:i=!0,orgName:n=null})=>{const{isAuthenticated:l}=ss(),[d,m]=r.useState(null),L=t?.liked??!1,p=t?.favourited??!1,v=$t(),O=Ht(),S=Bt(),b=()=>{!l||v.isPending||(m(null),v.mutate({agentId:s.id,isCurrentlyLiked:L},{onError:()=>m("like")}))},h=()=>{!l||O.isPending||(m(null),O.mutate({agentId:s.id,isCurrentlyFavourited:p},{onError:()=>m("favourite")}))},E=()=>{S.isPending||(m(null),S.mutate({agentId:s.id,agentName:s.name},{onError:()=>m("download")}))},f=d?d==="like"?{action:"like",error:v.error,retry:b}:d==="favourite"?{action:"favourite",error:O.error,retry:h}:{action:"download",error:S.error,retry:E}:null;return e.jsx(wa,{agent:s,isLiked:l&&L,isFavourited:l&&p,onLikeToggle:b,onFavouriteToggle:h,onDownload:E,isLikeActionLoading:v.isPending,isFavouriteActionLoading:O.isPending,isDownloading:S.isPending,viewerStateKnown:i,orgName:n,actionError:f?qt(f.action,f.error,ie(s.name)):null,onRetryAction:f?.retry})},Is=({selected:s,onClick:t,children:i,...n})=>e.jsx("button",{type:"button",onClick:t,"aria-pressed":s,className:B("flex w-full cursor-pointer items-center gap-2.5 rounded-sm px-3 py-1.5 text-left","text-body-sm transition-colors duration-fast ease-out-quart",s?Zt:"text-ink hover:bg-row-hover"),...n,children:i}),Rs=Object.keys(Qt),Sa=s=>[...s].sort((t,i)=>{const n=Rs.indexOf(t),l=Rs.indexOf(i);return n!==-1&&l!==-1?n-l:n!==-1?-1:l!==-1?1:t.localeCompare(i)}),Ca=({selectedCategory:s,onSelectCategory:t,categories:i})=>{Z();const n=Sa(s&&!i.includes(s)?[...i,s]:i);return e.jsxs("div",{className:"flex h-full flex-col overflow-y-auto",children:[e.jsx("h2",{className:"mb-2 px-3 font-medium text-ink-dim text-meta",children:a("ui.hub.taxonomy.heading")}),e.jsxs("div",{className:"flex flex-col gap-0.5",children:[e.jsxs(Is,{selected:s===null,onClick:()=>t(null),"data-testid":"category-all",children:[e.jsx("span",{className:"flex size-4 shrink-0 items-center justify-center",children:e.jsx(Xt,{size:16,"aria-hidden":"true"})}),a("ui.hub.taxonomy.all")]}),n.map(l=>{const d=Qs(l),m=l==="other"?e.jsx(Na,{size:16}):d.icon;return e.jsxs(Is,{selected:s===l,onClick:()=>t(l),"data-testid":`category-${l}`,children:[e.jsx("span",{className:"flex size-4 shrink-0 items-center justify-center",children:m}),d.label]},l)})]})]})},as=({page:s,count:t,onChange:i,ariaLabel:n="Agent pages"})=>{const l=r.useRef(null),d=r.useRef(null),m=r.useRef(null);return r.useEffect(()=>{const L=m.current;m.current=null,L==="previous"&&l.current?.focus(),L==="next"&&d.current?.focus()},[s]),t<=1?null:e.jsxs("nav",{"aria-label":n,className:"mt-6 flex min-h-13 items-center justify-between gap-3 border-t border-hairline","data-testid":"agent-hub-pager",children:[e.jsxs("span",{className:"select-none text-meta text-ink-dim",children:["Page ",s," of ",t]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(C,{variant:"secondary",size:"sm",ref:l,onClick:()=>{s-1<=1&&(m.current="next"),i(s-1)},disabled:s<=1,"aria-label":"Previous page",children:[e.jsx(It,{"aria-hidden":"true"}),"Previous"]}),e.jsxs(C,{variant:"secondary",size:"sm",ref:d,onClick:()=>{s+1>=t&&(m.current="previous"),i(s+1)},disabled:s>=t,"aria-label":"Next page",children:["Next",e.jsx(_t,{"aria-hidden":"true"})]})]})]})},Pa=/alias/i;function As(s){return s instanceof kt?s.code==="alias-occupied"?!0:s.code==="origin-conflict"&&Pa.test(s.message):!1}const Ta=/\/+$/;function is(s){const t=s.replace(Ta,"");try{const{pathname:i}=new URL(t);return i===""||i==="/"?`${t}/v1`:t}catch{return`${t}/v1`}}const Es=s=>s?.skills===1&&s.revision_cas===1;function Ia(s,t=1,i=20){const n=new URL(Ks(s,"skills"));return n.searchParams.set("page",String(t)),n.searchParams.set("per_page",String(i)),Vs(n.toString())}function Ra(s,t){return Vs(Ks(s,"skills",t))}function Aa(s){return Ms({operation:"org_skills.list",tenantId:s})}function Ea(s,t){return Ms({operation:"org_skill.get",tenantId:s,skillId:t})}const ns=12,Pe={all:["public-teams"],list:(s,t)=>[...Pe.all,"list",{page:s,perPage:t}],detail:s=>[...Pe.all,"detail",s]},Ee=(s,t)=>t instanceof Ws?t.status===null?!1:t.status>=500&&s<1:s<1,Xs=({page:s=1,perPage:t=ns,enabled:i=!0}={})=>{const n=oe({queryKey:Pe.list(s,t),queryFn:()=>ea(G.radientBaseUrl,s,t),select:l=>l.result,enabled:i,retry:Ee,staleTime:3e5,gcTime:6e5,refetchOnWindowFocus:!1,placeholderData:l=>l});return{...n,teams:n.data?.records??[],isRefreshing:n.isFetching&&n.data!==void 0,pagination:n.data?{page:n.data.page,perPage:n.data.per_page,totalPages:n.data.total_pages,totalRecords:n.data.total_records}:void 0}},La=({teamId:s,enabled:t=!0})=>{const i=oe({queryKey:Pe.detail(s??""),queryFn:()=>sa(G.radientBaseUrl,s),select:n=>n.result,enabled:t&&!!s,retry:Ee,staleTime:3e5,gcTime:6e5,refetchOnWindowFocus:!1,retryOnMount:!1});return{...i,team:i.data}};function de(s){if(s.getQueryState(bs.capabilities)?.status!=="success"||!ue(s.getQueryData(bs.capabilities),"hub_skills"))throw new Error("This backend does not support the complete Hub Skills adapter.")}function Zs(s,t,i){const n=ne(),l=Re();return oe({queryKey:["hub-skills",G.radientBaseUrl,s.visibility,s.tenantId,t],enabled:i&&!l.isError&&ue(l.data,"hub_skills"),queryFn:async()=>{if(de(n),s.visibility==="org"){const m=(await Aa(s.tenantId)).result;return{rows:m.skills,pages:1,total:m.skills.length,contract:m.sync_contract}}const d=(await Ia(G.radientBaseUrl,t,20)).result;return{rows:d.records,pages:d.total_pages,total:d.total_records,contract:d.sync_contract}},staleTime:3e4,retry:s.visibility==="org"?Ze:Ee,retryOnMount:!1,refetchOnWindowFocus:!1})}function Oa(s,t,i){const n=ne(),l=Re();return oe({queryKey:["hub-skill",G.radientBaseUrl,s.visibility,s.tenantId,t],enabled:i&&t!==null&&!l.isError&&ue(l.data,"hub_skills"),queryFn:async()=>(de(n),(s.visibility==="org"?await Ea(s.tenantId,t):await Ra(G.radientBaseUrl,t)).result),staleTime:3e4,retry:s.visibility==="org"?Ze:Ee,retryOnMount:!1})}function ls(s,t){s.setQueryData(ts,t.links)}function rs(s){s.invalidateQueries({queryKey:ts}),s.invalidateQueries({queryKey:["desktop","skills"]})}function Fa(){const s=ne();return ye({mutationFn:t=>(de(s),ke({op:"hub.skillPull",requestId:t.requestId,hubId:t.remoteId,hubSource:is(G.radientBaseUrl),visibility:t.scope.visibility,tenantId:t.scope.tenantId,localAlias:t.alias,subscribe:t.subscribe,autoPush:t.autoPush,confirmPublicEgress:t.consent})),onSuccess:t=>{ls(s,t)},onSettled:()=>{rs(s)}})}function qa(){const s=ne();return ye({mutationFn:t=>(de(s),ke({op:"hub.skillSubscribe",requestId:t.requestId,hubId:t.remoteId,hubSource:is(G.radientBaseUrl),visibility:t.scope.visibility,tenantId:t.scope.tenantId,localAlias:t.alias})),onSuccess:t=>{ls(s,t)},onSettled:()=>{rs(s)}})}function za(){const s=ne();return ye({mutationFn:t=>(de(s),ke({op:"hub.skillUnpull",requestId:t.requestId,linkId:t.linkId})),onSuccess:t=>{ls(s,t)},onSettled:()=>{rs(s)}})}function Da(){const s=ne();return ye({mutationFn:t=>(de(s),ke({op:"hub.skillPublish",requestId:t.requestId,...t.draft,dryRun:t.previewReceipt===void 0,...t.previewReceipt?{previewReceipt:t.previewReceipt,confirmPublish:!0}:{}})),onSuccess:t=>{t.local_link_receipt?.state==="complete"&&(s.invalidateQueries({queryKey:ts}),s.invalidateQueries({queryKey:["desktop","skills"]}),s.invalidateQueries({queryKey:["hub-skills"]}))}})}function Ma({scope:s,source:t,verifiedCas:i,enabled:n=!0,heading:l=!0}){Z();const d=r.useId(),[m,L]=r.useState(""),[p,v]=r.useState(""),[O,S]=r.useState(da),[b,h]=r.useState(null),[E,f]=r.useState(!1),w=Da(),I=r.useRef(null),F=oe({queryKey:["desktop","skills","hub-publication"],queryFn:()=>ke({op:"skills.list"}),staleTime:3e4,retry:!1}),P=`${s.visibility}:${s.tenantId??""}`,g=r.useRef(P);r.useEffect(()=>{g.current!==P&&(g.current=P,S(y=>({...y,autoPush:!1,confirmPublicEgress:!1})),h(null),f(!0))},[P]);const R={sourceSkill:m,localAlias:p,visibility:s.visibility,tenantId:s.tenantId,...O},j=b?ma(b,R):!1;r.useEffect(()=>{if(!b)return;const y=setTimeout(()=>{h(null),f(!0)},Math.max(0,Math.min(Date.parse(b.expires_at)-Date.now(),2147483647)));return()=>clearTimeout(y)},[b]);const k=y=>{if(!n||w.isPending||!m||!p||y&&!j)return;const u=JSON.stringify({draft:R,receipt:y?b?.preview_receipt:null}),x=I.current&&I.current.tuple===u&&(y||w.error)?I.current:{tuple:u,id:crypto.randomUUID()};I.current=x,y||(h(null),f(!1)),w.mutate({requestId:x.id,draft:R,...y&&b?{previewReceipt:b.preview_receipt}:{}},{onSuccess:A=>{A.preview?(h(A.preview),f(!1)):ws(A)&&h(null)}})};return e.jsxs("section",{className:"flex min-w-0 flex-col gap-4","data-hub-skill-publication":!0,children:[l&&e.jsx("h3",{className:"text-heading text-ink",children:a("ui.hub.skills.publish_title")}),e.jsx("label",{htmlFor:`${d}-source`,className:"text-body-sm text-ink",children:a("ui.hub.skills.select_authored")}),e.jsxs("select",{id:`${d}-source`,"data-testid":"hub-skill-publish-source",value:m,disabled:w.isPending||!n,className:"rounded-md border border-control bg-surface px-3 py-2 text-body-sm text-ink",onChange:y=>{L(y.target.value),v(y.target.value),h(null),S(u=>({...u,autoPush:!1,confirmPublicEgress:!1}))},children:[e.jsx("option",{value:"",children:a("ui.hub.skills.select_authored")}),F.data?.data.skills.map(y=>e.jsx("option",{value:y.name,children:y.name},y.name))]}),e.jsx("label",{htmlFor:`${d}-alias`,className:"text-body-sm text-ink",children:a("ui.hub.subscriptions.alias")}),e.jsx(Ae,{id:`${d}-alias`,"data-testid":"hub-skill-publish-alias",value:p,disabled:w.isPending||!n,onChange:y=>{v(y.target.value),S(u=>({...u,autoPush:!1,confirmPublicEgress:!1}))}}),e.jsx("p",{className:"text-meta text-ink-muted",children:a("ui.hub.skills.text_limits")}),e.jsx(ha,{value:O,onChange:S,source:t,item:m||p,visibility:s.visibility,organization:s.organization,destinationKey:`${P}:${m}`,canEnableAutoPush:i,disabled:w.isPending||!n}),F.isLoading&&e.jsx("output",{className:"text-meta text-ink-muted",children:a("ui.hub.skills.loading")}),F.error&&e.jsx("p",{role:"alert",className:"text-body-sm text-danger",children:a("ui.hub.status.other_error")}),w.error&&e.jsx("p",{role:"alert",className:"text-body-sm text-danger",children:a("ui.hub.links.action_failed",{direction:a("ui.hub.links.direction_push"),item:m||p,source:t})}),(E||b&&!j&&b.can_confirm)&&e.jsx("p",{role:"alert",className:"text-body-sm text-warning",children:a("ui.hub.links.preview_changed")}),b&&b.visibility===s.visibility&&b.tenant_id===s.tenantId&&e.jsxs("div",{className:"flex min-w-0 flex-col gap-3",children:[e.jsx("h4",{className:"text-body-sm text-ink",children:a("ui.hub.links.preview_payload",{source:t})}),e.jsx(Ds,{readOnly:!0,rows:12,"aria-label":a("ui.hub.links.preview_payload",{source:t}),value:JSON.stringify(b.proposal.fields,null,2),className:"max-h-96 bg-sunken text-mono-sm"}),b.warnings.map((y,u)=>e.jsx("p",{className:"break-words text-body-sm text-warning",children:y},`${u}-${y}`)),b.reason&&e.jsx("p",{className:"text-body-sm text-warning",children:ta(b.reason)})]}),w.data?.publication===null&&w.data.local_link_receipt?.state==="pending-reconciliation"&&e.jsx("output",{className:"text-body-sm text-warning","data-testid":"hub-skill-pending-reconcile",children:a("ui.hub.links.publication_pending")}),w.data?.publication&&e.jsx("output",{className:"text-body-sm text-ink","data-testid":"hub-skill-published",children:ws(w.data)?a("ui.hub.links.published",{item:w.data.link?.name??p,source:w.data.link?Ys(w.data.link):t}):a("ui.hub.skills.policy_pending")}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(C,{variant:"outline","data-testid":"hub-skill-publish-preview",disabled:!n||w.isPending||!m||!p,onClick:()=>k(!1),children:a("ui.hub.subscriptions.preview_publish")}),e.jsx(C,{"data-testid":"hub-skill-publish-confirm",disabled:!n||w.isPending||!j,onClick:()=>k(!0),children:a("ui.hub.links.confirm_publish")})]})]})}function Ls(s,t){const i=s.publisher?.trim();return i?a("ui.hub.skills.published_by",{publisher:i}):s.visibility==="org"?t??a("ui.hub.links.source_unavailable"):a("ui.hub.skills.public_hub")}function Ua({scope:s,signedIn:t,accessible:i=!0}){Z();const n=r.useId(),[l,d]=r.useState(1),[m,L]=r.useState(""),[p,v]=r.useState(null),[O,S]=r.useState(!1),[b,h]=r.useState("unsubscribe"),[E,f]=r.useState(!1),w=r.useRef(null),I=s.visibility==="public"?a("ui.hub.links.source_public"):s.organization?a("ui.hub.links.source_private",{organization:s.organization}):a("ui.hub.links.source_unavailable"),F=Re(),P=i&&ue(F.data,"hub_updates"),g=Zs(s,l,i&&(s.visibility==="public"||t)),R=Es(g.data?.contract),j=Oa(s,p,R&&i),k=Fa(),y=qa(),u=za(),x=aa(),A=ia(i&&ue(F.data,"hub_links")),z=na(P),Q=r.useMemo(()=>xa(A.data?.links,is(G.radientBaseUrl)),[A.data]),D=r.useMemo(()=>la(z.data),[z.data]),U=k.data?.link?.link_id,N=!A.isLoading&&!A.error,M=A.error?a("ui.hub.skills.inventory_unknown"):a("ui.hub.links.loading"),te=j.data?.visibility===s.visibility&&(s.visibility==="public"?!j.data.tenant_id:j.data.tenant_id===s.tenantId),ae=i&&!j.error&&!g.error&&te&&Es(j.data?.sync_contract)&&!!j.data?.revision,me=(g.data?.rows??[]).filter(o=>ba(o,s)),ve=me.filter(o=>`${o.name} ${o.description}`.toLocaleLowerCase().includes(m.toLocaleLowerCase())),K=me.find(o=>o.id===p),_=K?Q.get(_s({id:K.id,visibility:K.visibility,tenantId:K.tenant_id??null})):void 0,Ne=_?D.get(vs("skill",_.name)):void 0,he=Ss(_,Ne,N),se=_?Ns(_)==="present":!1,Le=o=>{const q=Q.get(_s({id:o.id,visibility:o.visibility,tenantId:o.tenant_id??null})),X=q?D.get(vs("skill",q.name)):void 0;return{link:q,update:X,state:Ss(q,X,N)}},xe=o=>(w.current?.tuple!==o&&(w.current={tuple:o,id:crypto.randomUUID()}),w.current.id),le=o=>{if(!p||!ae||!t)return;const q=o?.name??K?.name??"";if(!q)return;const X=o?o.policy.subscribe:!1,pe=o?.policy.auto_push??!1,we=!1;k.mutate({requestId:xe(ga({selected:p,scope:s,localAlias:q,subscribe:X,autoPush:pe,consent:we})),remoteId:p,scope:s,alias:q,subscribe:X,autoPush:pe,consent:we})},Oe=()=>{if(!p||!ae||!t)return;if(fa(_)==="policy"&&_){if(_.policy.subscribe||x.isPending)return;h("subscribe"),x.mutate({link:_,patch:{subscribe:!0}});return}const o=K?.name??"";o&&y.mutate({requestId:xe(JSON.stringify({op:"subscribe",selected:p,scope:s,localAlias:o})),remoteId:p,scope:s,alias:o})},Fe=()=>{_&&u.mutate({requestId:xe(JSON.stringify({op:"unpull",link:_.link_id})),linkId:_.link_id},{onSuccess:()=>{k.reset(),y.reset()}})},V=()=>{!_||_.policy.subscribe===!1||x.isPending||!x.canWrite||(h("unsubscribe"),x.mutate({link:_,patch:{subscribe:!1}}))},J=t&&R&&i&&!g.error,be=g.data?.total??me.length,$=g.error?null:g.isLoading?a("ui.hub.skills.loading"):s.organization?a("ui.hub.skills.count_shared",{count:be,organization:s.organization}):a("ui.hub.skills.count",{count:be});return e.jsxs("section",{className:"flex min-w-0 flex-col gap-4","data-hub-skills-library":!0,children:[s.visibility==="org"&&!t?e.jsx("p",{role:"alert",className:"text-body-sm text-warning",children:a("ui.hub.status.no_credential")}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("div",{className:B("flex min-w-56 max-w-md flex-1 items-center rounded-sm border border-control bg-surface","transition-colors duration-fast ease-out-quart","has-[:focus-visible]:outline-solid has-[:focus-visible]:outline-2","has-[:focus-visible]:outline-accent has-[:focus-visible]:outline-offset-2"),children:[e.jsx(Us,{"aria-hidden":"true",className:"ml-2 shrink-0 text-ink-dim"}),e.jsx(Ae,{id:`${n}-search`,type:"search","data-testid":"hub-skill-search",value:m,placeholder:a("ui.hub.skills.search"),"aria-label":a("ui.hub.skills.search"),onChange:o=>L(o.target.value),className:"h-8 min-w-0 flex-1 border-0 bg-transparent outline-none"})]}),J&&e.jsx(C,{variant:"secondary","data-testid":"hub-skill-publish-open",onClick:()=>f(!0),children:a("ui.hub.skills.publish_title")})]}),$!==null&&e.jsx("p",{"aria-live":"polite",className:"text-meta text-ink-dim","data-testid":"hub-skill-status",children:s.organization||g.isLoading?e.jsx("span",{"data-testid":"hub-skill-source",children:$}):e.jsxs(e.Fragment,{children:[e.jsx("span",{children:$})," · ",e.jsx("span",{"data-testid":"hub-skill-source",children:a("ui.hub.skills.public_hub")})]})}),g.error&&e.jsxs("div",{role:"alert",className:"flex flex-col items-start gap-2 text-body-sm text-warning",children:[e.jsx("p",{children:a("ui.hub.skills.catalogue_failed",{source:I})}),e.jsx(C,{variant:"outline",className:"self-start",disabled:g.isFetching,onClick:()=>void g.refetch(),children:a("ui.hub.links.retry")})]}),g.isSuccess&&!R&&e.jsx("p",{className:"text-body-sm text-warning",children:a("ui.hub.skills.unavailable")}),R&&e.jsxs(e.Fragment,{children:[ve.length===0&&e.jsx("p",{className:"text-body-sm text-ink-muted",children:a(m?"ui.hub.skills.search_empty":"ui.hub.skills.remote_empty")}),e.jsx("ul",{className:"grid list-none grid-cols-[repeat(auto-fill,minmax(17.5rem,1fr))] gap-6 p-0",children:ve.map(o=>{const q=Le(o),X=Cs(q.state,q.update,q.link?Ns(q.link)==="present":!1);return e.jsx("li",{className:"min-w-0",children:e.jsxs("button",{type:"button","aria-haspopup":"dialog","aria-expanded":p===o.id,"aria-label":a("ui.hub.skills.open_detail",{item:o.name}),"data-testid":"hub-skill-open","data-skill-id":o.id,"data-skill-state":q.state.kind,onClick:()=>{v(o.id),k.reset(),y.reset(),u.reset(),x.reset()},className:B("flex h-full w-full flex-col overflow-hidden rounded-md bg-surface text-left","transition-colors duration-fast ease-out-quart hover:bg-elevated","focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent focus-visible:outline-offset-1"),children:[e.jsxs("span",{className:"flex min-h-0 flex-1 flex-col gap-2 p-4",children:[e.jsx("span",{className:"truncate font-medium text-heading text-ink",children:o.name}),o.description?e.jsx("span",{className:"line-clamp-3 text-body-sm text-ink-muted",children:o.description}):null,e.jsx("span",{className:"mt-auto truncate text-ink-dim text-meta",children:Ls(o,s.organization)})]}),e.jsxs("span",{className:"flex items-center justify-between gap-2 border-t border-hairline px-4 py-2 text-meta",children:[e.jsx("span",{className:"truncate text-ink-muted",children:Ps(q.state,M)}),e.jsx(Ts,{mark:X})]})]})},o.id)})}),e.jsx(as,{page:l,count:g.data?.pages??1,onChange:d,ariaLabel:a("ui.hub.skills.title")})]})]}),!i&&e.jsx("p",{role:"alert",className:"text-body-sm text-warning",children:a("ui.hub.status.access_lost")}),e.jsx($e,{open:!!p&&R,onOpenChange:o=>{o||v(null)},children:e.jsxs(He,{"data-hub-skill-detail":"",className:"max-h-[85vh] overflow-y-auto sm:max-w-2xl",children:[e.jsxs(Be,{children:[e.jsx(Qe,{"data-testid":"hub-skill-detail-name",children:j.data?.name??K?.name??a("ui.hub.skills.title")}),e.jsx(Ke,{children:j.data&&te?Ls(j.data,s.organization):I})]}),j.isLoading&&e.jsx("output",{className:"text-meta text-ink-muted",children:a("ui.hub.skills.loading")}),j.error&&e.jsx("p",{role:"alert",className:"text-body-sm text-warning",children:a("ui.hub.status.other_error")}),j.data&&te&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("p",{className:"text-body-sm text-ink-muted",children:[Ps(he,M),e.jsx("span",{"aria-hidden":"true",className:"mx-1.5",children:"·"}),a("ui.hub.skills.revision",{revision:String(j.data.content_revision)})]}),e.jsx(Ts,{mark:Cs(he,Ne,se)})]}),e.jsx("p",{"data-testid":"hub-skill-description",className:"max-w-3xl select-text whitespace-pre-wrap break-words text-body-sm text-ink-muted",children:j.data.description}),_&&se&&_.local_path&&e.jsx("p",{"data-testid":"hub-skill-local-path",className:"break-words font-mono text-meta text-ink-dim",children:a("ui.hub.skills.local_path",{path:`⁨${_.local_path}⁩`})}),e.jsx("h4",{className:"text-body-sm text-ink",children:a("ui.hub.skills.files")}),e.jsx("p",{className:"text-meta text-ink-muted",children:a("ui.hub.skills.file_count",{count:j.data.files.length})}),j.data.files.map(o=>e.jsxs("details",{className:"min-w-0",children:[e.jsx("summary",{className:"break-words text-mono-sm text-ink",children:o.path}),e.jsx(Ds,{readOnly:!0,rows:12,"aria-label":o.path,value:o.content,className:"max-h-96 bg-sunken text-mono-sm"})]},o.path)),_&&e.jsxs("div",{className:"flex flex-col gap-2 border-t border-hairline pt-3",children:[e.jsx(ra,{link:_}),_.policy.subscribe&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(C,{variant:"outline",size:"sm","data-testid":"hub-skill-unsubscribe",disabled:x.isPending||!x.canWrite,onClick:V,children:a("ui.hub.skills.unsubscribe")}),e.jsx("span",{className:"text-meta text-ink-muted",children:a("ui.hub.skills.unsubscribe_help")})]}),x.error&&e.jsx("p",{role:"alert",className:"text-meta text-danger",children:a("ui.hub.subscriptions.save_failed",{setting:b==="subscribe"?a("ui.hub.subscriptions.subscribe"):a("ui.hub.skills.unsubscribe"),source:I})})]}),_&&se&&e.jsx(pa,{kind:"skill",name:_.name,enabled:P}),k.error&&e.jsx("p",{role:"alert",className:"text-body-sm text-danger","data-testid":"hub-skill-pull-failed",children:a(As(k.error)?"ui.hub.skills.local_exists":"ui.hub.skills.pull_failed")}),k.data&&!k.data.reports?.some(o=>o.applied||o.outcome==="unchanged")&&e.jsx("p",{role:"alert",className:"text-body-sm text-danger","data-testid":"hub-skill-pull-failed",children:a("ui.hub.skills.pull_failed")}),k.data?.link&&k.data.reports?.some(o=>o.link_id===U&&o.direction==="pull"&&o.applied)&&e.jsx("output",{"data-testid":"hub-skill-installed",className:"text-body-sm text-ink",children:a("ui.hub.skills.installed_alias",{item:k.data.link.name,source:Ys(k.data.link)})}),u.error&&e.jsx("p",{role:"alert",className:"text-body-sm text-danger","data-testid":"hub-skill-unpull-failed",children:a("ui.hub.skills.unpull_failed")}),y.error&&e.jsx("p",{role:"alert",className:"text-body-sm text-danger","data-testid":"hub-skill-subscribe-failed",children:a(As(y.error)?"ui.hub.skills.local_exists":"ui.hub.skills.subscribe_failed")}),!t&&e.jsx("p",{className:"text-meta text-ink-muted",children:a("ui.hub.status.no_credential")}),(!_||!se)&&e.jsxs(Ve,{className:"flex-row flex-wrap justify-start gap-2",children:[e.jsx(C,{"data-testid":"hub-skill-download",disabled:!t||!ae||k.isPending||!N,"aria-label":a("ui.hub.skills.pull_title",{item:j.data.name,source:I}),onClick:()=>le(_),children:a("ui.hub.skills.download")}),!_?.policy.subscribe&&e.jsx(C,{variant:"outline","data-testid":"hub-skill-subscribe",disabled:!t||!ae||!N||y.isPending||x.isPending||(_?!x.canWrite:!1),onClick:Oe,children:a("ui.hub.subscriptions.subscribe")})]}),_&&se&&e.jsx(Ve,{className:"flex-row flex-wrap justify-start gap-2",children:e.jsx(C,{variant:"outline","data-testid":"hub-skill-unpull",disabled:u.isPending,onClick:()=>{u.reset(),S(!0)},children:a("ui.hub.skills.unpull")})}),(!_||!se)&&e.jsx("p",{className:"text-meta text-ink-muted",children:_?.policy.subscribe?a("ui.hub.skills.download_help"):a("ui.hub.skills.subscribe_help")})]})]})}),e.jsx($e,{open:O,onOpenChange:o=>{o||S(!1)},children:e.jsxs(He,{className:"sm:max-w-md",children:[e.jsxs(Be,{children:[e.jsx(Qe,{children:a("ui.hub.skills.unpull_title",{item:j.data?.name??_?.name??""})}),e.jsx(Ke,{children:a("ui.hub.skills.unpull_body")})]}),e.jsxs(Ve,{children:[e.jsx(C,{variant:"outline",onClick:()=>S(!1),children:a("ui.hub.subscriptions.cancel")}),e.jsx(C,{"data-testid":"hub-skill-unpull-confirm",disabled:u.isPending,onClick:()=>{Fe(),S(!1)},children:a("ui.hub.skills.unpull")})]})]})}),e.jsx($e,{open:E,onOpenChange:f,children:e.jsxs(He,{className:"max-h-[85vh] overflow-y-auto sm:max-w-2xl",children:[e.jsxs(Be,{children:[e.jsx(Qe,{children:a("ui.hub.skills.publish_title")}),e.jsx(Ke,{children:I})]}),e.jsx(Ma,{scope:s,source:I,verifiedCas:R&&i&&t,enabled:R&&i&&t,heading:!1})]})})]})}const et={all:["org-teams"],list:s=>[...et.all,"list",s]},st=({tenantId:s,enabled:t=!0})=>{const i=oe({queryKey:et.list(s??""),queryFn:async()=>(await ca(s)).result??{teams:[]},enabled:t&&!!s,staleTime:3e5,gcTime:6e5,refetchOnWindowFocus:!1,retryOnMount:!1,retry:Ze});return{...i,teams:i.data?.teams??[]}},$a=(s,t)=>{const i=s?.name?.trim()||t?.trim()||"Team",n=s?.renamed_from?.trim()||null;return s?.invalid_name===!0&&n?{level:"warning",message:a("ui.notices.hub.team_pulled_renamed",{stored:i,published:n})}:n?{level:"success",message:a("ui.notices.hub.team_pulled_collision",{stored:i,published:n})}:{level:"success",message:a("ui.notices.hub.team_pulled",{name:i})}},tt=()=>{const s=ne();return ye({mutationFn:async({teamId:t,tenantId:i})=>{if(!G.baseUrl)throw new Error("Local Operator API URL is not configured.");return Et.pullOrgTeamFromRadient(G.baseUrl,t,i)},onSuccess:(t,i)=>{const n=$a(t.result,i.name);n.level==="warning"?Rt(n.message):At(n.message),s.invalidateQueries({queryKey:["desktop","teams"]})},onError:t=>{console.error("Pulling an organization team failed:",t)}})},Ha=/^v/i,at=s=>s.members.reduce((t,i)=>t+i.count,0),Ba=s=>s.count>1?`${s.role} ×${s.count}`:s.role,Je=s=>s.members.map(Ba).join(", "),it=s=>{const t=(s.version??"").trim().replace(Ha,"").trim();return t===""?null:t},nt=s=>{const t=s.account_metadata?.name?.trim();return t||null},Qa=s=>{const t=(s.description??"").trim();return t===""?null:t},Xe=240,Ka=Xe/2,Va=(s,t)=>{if(t||s.length<=Xe)return s;const i=s.slice(0,Xe),n=i.lastIndexOf(" ");return`${(n>=Ka?i.slice(0,n):i).trimEnd()}…`},Te=s=>Lt(s,{day:"numeric",month:"short",year:"numeric"}),Ie=s=>{if(!s)return null;const t=new Date(s);return Number.isNaN(t.getTime())?null:t},Os=(s,t,i)=>{const n=i-t.getTime();let l;return n<0?l=Te(t):n<6e4?l=a("ui.hub.updates.ago.now"):l=Kt(t,i),{label:s,when:l,iso:t.toISOString(),exact:Te(t)}},Wa=(s,t=Date.now())=>{const i=Ie(s.updated_at);if(i)return Os("updated",i,t);const n=Ie(s.created_date);return n?Os("created",n,t):null},Ya=s=>{const t=Ie(s.created_date),i=Ie(s.updated_at);return{created:t?Te(t):null,updated:i?Te(i):null}},Ga=s=>s==="role"?a("ui.hub.teams.kind.role"):s==="specialist"?a("ui.hub.teams.kind.specialist"):s,Ja=["refresh-hub","retry","sign-in"],Xa=({tenantId:s,orgName:t})=>{const{teams:i,isLoading:n,isFetching:l,isError:d,error:m,refetch:L}=st({tenantId:s}),p=Gs(m),v=tt(),[O,S]=r.useState(null),[b,h]=r.useState(null),E=r.useRef(new Map),f=r.useRef(null);r.useEffect(()=>{v.isPending||f.current===null||(E.current.get(f.current)?.focus(),f.current=null)},[v.isPending]);const[w,I]=r.useState(!1),[F,P]=r.useState(()=>new Set),g=(u,x)=>P(A=>{const z=new Set(A);return x?z.add(u):z.delete(u),z}),R=(u,x)=>{u.key!=="Escape"||!F.has(x)||(u.target instanceof Element?u.target:null)?.closest('[data-testid="org-team-pull-error"]')||(g(x,!1),u.currentTarget.querySelector("button[aria-expanded]")?.focus(),u.preventDefault())},j=r.useMemo(()=>{if(!$s(v.error))return null;const u=i.find(x=>x.id===O);return Bs({code:v.error.code,message:v.error.message,details:v.error.details},{name:u?.name??"this team",hubAgentId:null,surface:"pull"})},[v.error,O,i]),k=(u,x)=>{switch(u){case"refresh-hub":L();break;case"retry":y(x);break;case"sign-in":I(!0);break}},y=u=>{v.isPending||(f.current=u.id,S(null),h(u.id),v.mutate({teamId:u.id,tenantId:s,name:u.name},{onSettled:()=>h(null),onError:()=>S(u.id)}))};return e.jsxs("section",{className:"mb-6 max-w-4xl rounded-md bg-surface","aria-label":a("ui.hub.teams.org.aria",{org:t??a("ui.hub.pages.scope.org_unnamed")}),"data-testid":"org-teams",children:[n&&e.jsxs("div",{"aria-hidden":"true",className:"flex flex-col divide-y divide-hairline","data-testid":"org-teams-loading",children:[e.jsx(Ye,{}),e.jsx(Ye,{}),e.jsx(Ye,{})]}),!n&&d&&e.jsxs(ge,{variant:p?"warning":"danger",className:"m-4 w-auto","data-testid":"org-teams-error",children:[e.jsx(fe,{children:p==="plan"?a("ui.hub.teams.org.plan_headline"):p==="no_access"?a("ui.hub.teams.org.no_access_headline"):a("ui.hub.teams.org.load_headline")}),e.jsx(je,{children:p==="plan"?a("ui.hub.teams.org.plan_body",{org:t??a("ui.hub.pages.scope.org_unnamed")}):p==="no_access"?a("ui.hub.teams.org.no_access_body",{org:t??a("ui.hub.teams.org.that_organization")}):es(a("ui.hub.teams.org.unreadable"),m)}),p!=="no_access"&&e.jsx("div",{className:"mt-2",children:e.jsx(C,{variant:"primary",size:"sm",onClick:()=>void L(),disabled:l,"aria-busy":l,children:l?a("ui.hub.teams.public.trying"):ce.retry})})]}),!n&&!d&&i.length===0&&e.jsx("p",{className:"p-4 text-body-sm text-ink-muted","data-testid":"org-teams-empty",children:a("ui.hub.teams.org.empty",{org:t??a("ui.hub.pages.scope.org_unnamed")})}),!n&&!d&&i.length>0&&e.jsx("ul",{className:"flex flex-col divide-y divide-hairline",children:i.map(u=>e.jsxs("li",{className:B(lt,"transition-colors duration-fast ease-out-quart hover:bg-elevated first:rounded-t-md last:rounded-b-md"),onKeyDown:x=>R(x,u.id),children:[e.jsx(Hs,{className:"min-w-0",open:F.has(u.id),onOpenChange:x=>g(u.id,x),summaryAlign:"firstLine",triggerClassName:"min-w-0",chevronClassName:"text-ink-dim mt-1",rowClassName:"py-0",summary:e.jsx(si,{team:u,expanded:F.has(u.id)}),trailing:e.jsx("div",{className:"-mt-1 ml-3 shrink-0 self-start",children:e.jsx(C,{ref:x=>{x?E.current.set(u.id,x):E.current.delete(u.id)},variant:"secondary",size:"sm",onClick:()=>y(u),disabled:v.isPending,"aria-label":a("ui.hub.teams.pull_target",{name:ie(u.name)}),children:b===u.id?a("ui.hub.teams.pulling"):a("ui.hub.teams.pull")})}),children:e.jsx(ti,{team:u})}),O===u.id&&e.jsxs("div",{className:"mt-1 flex flex-col items-start gap-1 pl-5","data-testid":"org-team-pull-error",children:[e.jsx("output",{className:"text-meta text-danger",children:j?.body??v.error?.message??a("ui.hub.teams.pull_failed",{name:ie(u.name)})}),j?.actions.filter(x=>Ja.includes(x)).map(x=>e.jsx(C,{variant:"primary",size:"sm",onClick:()=>k(x,u),children:ce[x]},x)),w&&e.jsx("div",{className:"mt-1","data-testid":"org-team-pull-reauth",children:e.jsx(Js,{titleText:ce["sign-in"],descriptionText:"",onSignInSuccess:()=>{I(!1),S(null),L()}})})]})]},u.id))})]})},lt="px-4 py-3",rt=()=>e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":"true",className:"mx-1.5",children:"·"}),e.jsx("span",{className:"sr-only",children:", "})]}),Za=({team:s})=>{Z();const t=s.manager?.trim(),i=at(s);return e.jsxs("span",{className:"block truncate text-meta",children:[t?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-ink-dim",children:a("ui.hub.teams.manager_label")})," ",e.jsx("span",{className:"text-ink-muted",children:t})]}):null,t?e.jsx(rt,{}):null,s.members.length===0?e.jsx("span",{className:"text-ink-dim",children:a("ui.hub.teams.no_members")}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-ink-dim",children:a("ui.hub.teams.member_count",{count:i})})," ",e.jsx("span",{className:"text-ink-muted",children:Je(s)})]})]})},ei=({team:s})=>{const t=s.project?.trim(),i=nt(s),n=Wa(s),l=[];return t&&l.push({key:"project",node:t}),i&&l.push({key:"author",node:i}),n&&l.push({key:"recency",node:e.jsxs(e.Fragment,{children:[n.label," ",e.jsx(re,{content:n.exact,children:e.jsx("time",{dateTime:n.iso,children:n.when})})]})}),l.length===0?null:e.jsx("span",{className:"block truncate text-ink-dim text-meta",children:l.map((d,m)=>e.jsxs("span",{children:[m>0?e.jsx(rt,{}):null,d.node]},d.key))})},si=({team:s,expanded:t})=>{Z();const i=Qa(s),n=it(s);return e.jsxs("span",{className:"flex min-w-0 flex-col",children:[e.jsxs("span",{className:"flex min-w-0 items-baseline",children:[e.jsx("span",{className:"truncate font-medium text-body text-ink",children:ie(s.name)}),n?e.jsxs("span",{className:"ml-2 shrink-0 text-ink-dim text-meta",children:["v",n]}):null]}),i?e.jsxs(e.Fragment,{children:[e.jsx("span",{...Ce,"aria-hidden":"true",className:B("mt-1 select-text break-words text-body-sm text-ink-muted",t?"line-clamp-[12] whitespace-pre-line":"line-clamp-2"),children:i}),e.jsx("span",{className:"sr-only",children:Va(i,t)})]}):e.jsx("span",{className:"mt-1 text-body-sm text-ink-dim",children:a("ui.hub.teams.no_description")}),e.jsxs("span",{className:"mt-1 flex min-w-0 flex-col",children:[e.jsx(Za,{team:s}),e.jsx(ei,{team:s})]})]})},ti=({team:s})=>{Z();const t=s.manager?.trim(),i=Ya(s),n=[i.created?a("ui.hub.teams.detail.created",{date:i.created}):null,i.updated?a("ui.hub.teams.detail.updated",{date:i.updated}):null].filter(d=>d!==null),l=!!t||s.members.length>0;return e.jsxs("div",{className:"mt-1 flex flex-col gap-2",children:[l||n.length===0?e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("p",{className:"text-ink-dim text-meta",children:a("ui.hub.teams.members")}),e.jsxs("ul",{className:"flex flex-col gap-0.5",children:[t?e.jsxs("li",{className:"flex items-baseline gap-1.5",children:[e.jsx("span",{className:"text-body-sm text-ink-muted",children:t}),e.jsx("span",{className:"text-ink-dim text-meta",children:a("ui.hub.teams.manager")})]}):null,s.members.map(d=>e.jsxs("li",{className:"flex items-baseline gap-1.5",children:[e.jsx("span",{className:"text-body-sm text-ink-muted",children:d.role}),e.jsx("span",{className:"text-ink-dim text-meta",children:Ga(d.kind)}),d.count>1?e.jsxs("span",{className:"text-ink-dim text-meta tabular-nums",children:["×",d.count]}):null]},`${d.kind}:${d.role}`)),l?null:e.jsx("li",{className:"text-ink-dim text-meta",children:a("ui.hub.teams.no_members")})]})]}):null,n.length>0?e.jsx("p",{className:"text-ink-dim text-meta",children:n.join(" · ")}):null]})},Ye=()=>e.jsxs("div",{className:B(lt,"pl-9"),"data-testid":"org-team-skeleton-row",children:[e.jsx("div",{className:"flex h-[1lh] items-center text-body",children:e.jsx(T,{className:"h-4.5 w-40"})}),e.jsxs("div",{className:"mt-1 flex h-[2lh] flex-col justify-evenly text-body-sm",children:[e.jsx(T,{className:"h-3.5 w-full"}),e.jsx(T,{className:"h-3.5 w-2/3"})]}),e.jsx("div",{className:"mt-1 flex h-[1lh] items-center text-meta",children:e.jsx(T,{className:"h-3 w-64"})}),e.jsx("div",{className:"flex h-[1lh] items-center text-meta",children:e.jsx(T,{className:"h-3 w-48"})})]}),ct=(s,t)=>t instanceof Ws?t.message:es(s,t),ai=["refresh-hub","retry","sign-in"],ii=({signedIn:s,onOpenSettings:t})=>{Z();const[i,n]=r.useState(1),[l,d]=r.useState(""),{teams:m,isLoading:L,isFetching:p,isError:v,error:O,refetch:S,pagination:b}=Xs({page:i,perPage:ns}),h=tt(),[E,f]=r.useState(null),[w,I]=r.useState(null),F=r.useRef(new Map),P=r.useRef(null);r.useEffect(()=>{h.isPending||P.current===null||(F.current.get(P.current)?.focus(),P.current=null)},[h.isPending]);const g=Vt(l.trim()),R=r.useMemo(()=>g?m.filter(N=>ie(N.name).toLowerCase().includes(g)||(N.description??"").toLowerCase().includes(g)):m,[m,g]),j=N=>{h.isPending||(f(null),I(N.id),P.current=N.id,h.mutate({teamId:N.id,name:N.name},{onSettled:()=>I(null),onError:()=>f(N.id)}))},k=r.useMemo(()=>{if(!$s(h.error))return null;const N=m.find(M=>M.id===E);return Bs({code:h.error.code,message:h.error.message,details:h.error.details},{name:N?.name??"this team",hubAgentId:null,surface:"pull"})},[h.error,E,m]),y=k?.body??(yt(h.error)==="unauthorized"?a("ui.hub.teams.public.pull_no_signin"):a("ui.hub.teams.public.pull_failed")),[u,x]=r.useState(!1),A=(N,M)=>{switch(N){case"refresh-hub":S();break;case"retry":j(M);break;case"sign-in":x(!0);break}},z=L&&m.length===0,Q=b?.totalRecords??m.length,D=r.useRef(null),U=N=>{const M=l!=="";d(N),M&&N===""&&D.current?.focus()};return e.jsxs("section",{"aria-label":a("ui.hub.teams.public.aria"),className:"flex flex-col","data-testid":"agent-hub-public-teams",children:[e.jsx("h2",{className:"sr-only",children:a("ui.hub.teams.public.aria")}),e.jsx("p",{className:"mb-3 max-w-3xl text-body-sm text-ink-muted",children:a("ui.hub.teams.public.intro")}),s?null:e.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-2","data-testid":"agent-hub-public-teams-signed-out",children:[e.jsx("span",{className:"text-meta text-ink-dim",children:a("ui.hub.teams.public.sign_in_hint")}),e.jsx(C,{variant:"secondary",size:"sm",onClick:t,children:a("ui.hub.teams.public.open_settings")})]}),e.jsx("div",{className:"mb-4 flex flex-wrap items-center gap-2",children:e.jsxs("div",{className:B("flex min-w-56 max-w-md flex-1 items-center rounded-sm border border-control bg-surface","transition-colors duration-fast ease-out-quart","has-[:focus-visible]:outline-solid has-[:focus-visible]:outline-2","has-[:focus-visible]:outline-accent has-[:focus-visible]:outline-offset-2"),children:[e.jsx(Us,{"aria-hidden":"true",className:"ml-2 shrink-0 text-ink-dim"}),e.jsx(Ae,{ref:D,type:"search",value:l,onChange:N=>U(N.target.value),placeholder:a("ui.hub.teams.public.search_placeholder"),"aria-label":a("ui.hub.teams.public.search_aria"),className:"h-8 min-w-0 flex-1 border-0 bg-transparent outline-none","data-testid":"agent-hub-public-teams-search"})]})}),z&&e.jsxs("div",{"aria-hidden":"true",className:"flex max-w-4xl flex-col gap-3","data-testid":"agent-hub-public-teams-loading",children:[e.jsx(Ge,{}),e.jsx(Ge,{}),e.jsx(Ge,{})]}),!z&&v&&e.jsxs(ge,{variant:"danger",className:"w-auto max-w-2xl","data-testid":"agent-hub-public-teams-error",children:[e.jsx(fe,{children:a("ui.hub.teams.public.load_failed")}),e.jsx(je,{children:ct(a("ui.hub.teams.public.catalogue_unreadable"),O)}),e.jsx("div",{className:"mt-2",children:e.jsx(C,{variant:"primary",size:"sm",onClick:()=>void S(),disabled:p,"aria-busy":p,children:p?a("ui.hub.teams.public.trying"):a("ui.common.actions.retry_again")})})]}),!z&&!v&&m.length===0&&e.jsx("p",{className:"max-w-2xl text-body-sm text-ink-muted","data-testid":"agent-hub-public-teams-empty",children:a("ui.hub.teams.public.empty")}),!z&&!v&&m.length>0&&e.jsxs(e.Fragment,{children:[!g||R.length>0?e.jsxs("p",{className:"mb-3 text-meta text-ink-dim","data-testid":"agent-hub-public-teams-status",children:[g?a("ui.hub.teams.public.match_line",{visible:String(R.length),total:m.length,query:l.trim()}):a("ui.hub.pages.status.count.teams",{count:Q,scope:a("ui.hub.pages.status.scope.public")}),g?e.jsxs("span",{className:"text-ink-dim",children:[" ",a("ui.hub.teams.public.search_scope")]}):null]}):null,R.length===0?e.jsx("p",{className:"max-w-2xl text-body-sm text-ink-muted","data-testid":"agent-hub-public-teams-search-miss",children:a("ui.hub.teams.public.search_miss",{query:l.trim()})}):e.jsx("ul",{className:"flex max-w-4xl flex-col gap-3",children:R.map(N=>e.jsx(ni,{team:N,pulling:w===N.id,pullPending:h.isPending,onPull:j,pullButtonRef:M=>{M?F.current.set(N.id,M):F.current.delete(N.id)},failed:E===N.id,failureBody:y,treatment:k,onTreatmentAction:A,reauthenticating:u,onReauthenticated:()=>{x(!1),f(null),S()}},N.id))}),!g&&b&&b.totalPages>1&&e.jsx(as,{count:b.totalPages,page:b.page,onChange:N=>{n(N),D.current?.scrollIntoView({block:"nearest"})}})]})]})},ni=({team:s,pulling:t,pullPending:i,onPull:n,failed:l,failureBody:d,treatment:m,onTreatmentAction:L,reauthenticating:p,onReauthenticated:v,pullButtonRef:O})=>{Z();const[S,b]=r.useState(!1),h=La({teamId:S?s.id:void 0}),E=ie(s.name),f=it(s),w=nt(s),I=s.manager?.trim(),F=at(s),P=(s.description??"").trim();return e.jsxs("li",{className:"rounded-md bg-surface p-4","data-testid":"agent-hub-public-team","data-team-name":s.name,children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-baseline",children:[e.jsx("h3",{className:"truncate font-medium text-heading text-ink",children:E}),f?e.jsxs("span",{className:"ml-2 shrink-0 text-ink-dim text-meta",children:["v",f]}):null]}),P?e.jsx("p",{...Ce,className:"mt-1 line-clamp-3 max-w-3xl select-text text-body-sm text-ink-muted",children:P}):e.jsx("p",{className:"mt-1 text-body-sm text-ink-dim",children:a("ui.hub.teams.no_description")}),e.jsxs("p",{className:"mt-2 flex flex-wrap items-baseline gap-x-2 text-meta",children:[I?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-ink-dim",children:a("ui.hub.teams.manager_label")}),e.jsx("span",{className:"text-ink-muted",children:I})]}):null,s.members.length===0?e.jsx("span",{className:"text-ink-dim",children:a("ui.hub.teams.no_members")}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-ink-dim",children:a("ui.hub.teams.member_count",{count:F})}),e.jsx(re,{content:Je(s),children:e.jsx("span",{className:"truncate text-ink-muted",children:Je(s)})})]})]}),w?e.jsxs("p",{className:"mt-1 text-ink-dim text-meta",children:[a("ui.hub.teams.public.published_by")," ",e.jsx("span",{className:"text-ink-muted",children:w})]}):null]}),e.jsxs("div",{className:"flex shrink-0 flex-col items-end gap-2",children:[e.jsx(C,{ref:O,variant:"secondary",size:"sm",onClick:()=>n(s),disabled:i,"aria-label":a("ui.hub.teams.pull_target",{name:E}),children:t?a("ui.hub.teams.pulling"):a("ui.hub.teams.pull")}),l&&e.jsxs("div",{className:"flex max-w-56 flex-col items-end gap-1","data-testid":"agent-hub-public-team-pull-error",children:[e.jsx("output",{className:"text-right text-meta text-danger",children:d}),m?.actions.filter(g=>ai.includes(g)).map(g=>e.jsx(C,{variant:"primary",size:"sm",onClick:()=>L(g,s),children:ce[g]},g)),p&&e.jsx("div",{"data-testid":"agent-hub-public-team-pull-reauth",children:e.jsx(Js,{titleText:ce["sign-in"],descriptionText:"",onSignInSuccess:v})})]})]})]}),e.jsx("div",{className:"mt-2",children:e.jsx(Hs,{summary:a("ui.hub.teams.brief.trigger"),open:S,onOpenChange:b,className:"w-full",triggerClassName:"w-full",triggerLabel:a("ui.hub.teams.brief.trigger_aria",{name:E}),chevronClassName:"text-ink-dim",children:e.jsx(li,{detail:h})})})]})},li=({detail:s})=>{if(Z(),s.isLoading)return e.jsxs("div",{className:"flex flex-col gap-1","data-testid":"agent-hub-public-team-brief-loading",children:[e.jsx(T,{className:"h-[1lh] w-2/3"}),e.jsx(T,{className:"h-[2lh] w-full"})]});if(s.isError)return e.jsxs("div",{className:"flex flex-col items-start gap-1",children:[e.jsx("output",{className:"text-meta text-danger",children:ct(a("ui.hub.teams.brief.unreadable"),s.error)}),e.jsx(C,{variant:"primary",size:"sm",onClick:()=>void s.refetch(),disabled:s.isFetching,"aria-busy":s.isFetching,children:s.isFetching?a("ui.hub.teams.public.trying"):ce.retry})]});const t=s.team;if(!t)return null;const i=(t.instructions??"").trim(),n=(t.project??"").trim();return e.jsxs("div",{className:"flex max-w-3xl flex-col gap-3 text-body-sm","data-testid":"agent-hub-public-team-brief",children:[e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("p",{className:"text-ink-dim text-meta",children:a("ui.hub.teams.brief.collaboration")}),i?e.jsx("p",{...Ce,className:"whitespace-pre-line select-text text-ink-muted",children:i}):e.jsx("p",{className:"text-ink-dim",children:a("ui.hub.teams.brief.collaboration_empty")})]}),e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("p",{className:"text-ink-dim text-meta",children:a("ui.hub.teams.brief.project")}),n?e.jsx("p",{...Ce,className:"whitespace-pre-line select-text text-ink-muted",children:n}):e.jsx("p",{className:"text-ink-dim",children:a("ui.hub.teams.brief.project_empty")})]}),e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("p",{className:"text-ink-dim text-meta",children:a("ui.hub.teams.brief.roster")}),e.jsxs("ul",{className:"flex flex-col gap-0.5",children:[t.manager?.trim()?e.jsxs("li",{className:"flex items-baseline gap-1.5",children:[e.jsx("span",{className:"text-body-sm text-ink-muted",children:t.manager.trim()}),e.jsx("span",{className:"text-ink-dim text-meta",children:a("ui.hub.teams.manager")})]}):null,t.members.length===0?e.jsx("li",{className:"text-ink-dim",children:a("ui.hub.teams.no_members")}):t.members.map(l=>e.jsxs("li",{className:"flex items-baseline gap-1.5",children:[e.jsx("span",{className:"text-body-sm text-ink-muted",children:l.count>1?`${l.role} ×${l.count}`:l.role}),e.jsx("span",{className:"text-ink-dim text-meta",children:l.kind})]},`${l.kind}:${l.role}`))]})]})]})},Ge=()=>e.jsxs("div",{className:"rounded-md bg-surface p-4",children:[e.jsx(T,{className:"h-[1lh] w-1/3"}),e.jsx(T,{className:"mt-1 flex h-[3lh] w-full"}),e.jsx(T,{className:"mt-2 h-[1lh] w-2/3"})]}),ri=(s,t)=>{const[i,n]=r.useState(s);return r.useEffect(()=>{const l=setTimeout(()=>n(s),t);return()=>clearTimeout(l)},[s,t]),i},Se=[{value:"download_count:desc",label:"ui.hub.pages.sort.most_downloaded",sort:"download_count",order:"desc"},{value:"like_count:desc",label:"ui.hub.pages.sort.most_liked",sort:"like_count",order:"desc"},{value:"favourite_count:desc",label:"ui.hub.pages.sort.most_favourited",sort:"favourite_count",order:"desc"},{value:"created_at:desc",label:"ui.hub.pages.sort.newest",sort:"created_at",order:"desc"},{value:"updated_at:desc",label:"ui.hub.pages.sort.recently_updated",sort:"updated_at",order:"desc"},{value:"name:asc",label:"ui.hub.pages.sort.name_asc",sort:"name",order:"asc"}],ci=[{value:"name",label:"ui.hub.pages.search_field.name"},{value:"description",label:"ui.hub.pages.search_field.description"}],ui=300,H="public",Fs={agents:"agent-hub-view-agents",teams:"agent-hub-view-teams",skills:"agent-hub-view-skills"},qs="agent-hub-view-panel",oi=()=>e.jsxs("div",{className:"flex h-full flex-col overflow-hidden rounded-md bg-surface",children:[e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-2 p-4",children:[e.jsx(T,{className:"h-5.5 w-2/3"}),e.jsx(T,{className:"h-3.5 w-full"}),e.jsx(T,{className:"h-3.5 w-full"}),e.jsx(T,{className:"h-3.5 w-1/2"}),e.jsxs("div",{className:"mt-auto flex flex-col gap-2 pt-2",children:[e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(T,{className:"h-5.5 w-24"}),e.jsx(T,{className:"h-5.5 w-20"})]}),e.jsx("div",{className:"flex items-center gap-1.5",children:e.jsx(T,{className:"h-5.5 w-24"})})]}),e.jsx(T,{className:"h-4.5 w-32"})]})]}),e.jsxs("div",{className:"flex items-center gap-2 border-t border-hairline px-3 py-2",children:[e.jsx(T,{className:"size-4"}),e.jsx(T,{className:"h-4 w-6"}),e.jsx(T,{className:"size-4"}),e.jsx(T,{className:"h-4 w-6"}),e.jsx(T,{className:"ml-auto h-7 w-16"})]})]}),Pi=()=>{const s=zs(),{isAuthenticated:t}=ss(),[i,n]=r.useState(1),[l]=r.useState(12),[d,m]=r.useState(null),[L,p]=r.useState(""),[v,O]=r.useState("name"),[S,b]=r.useState(Se[0].value),[h,E]=r.useState(H),[f,w]=r.useState("agents");Z();const[I,F]=r.useState([]),P=ri(L,ui),g=Se.find(c=>c.value===S)??Se[0],R=Re(),j=!R.isError&&ue(R.data,"hub_skills"),k=f==="skills"&&!j?"agents":f;r.useEffect(()=>{f==="skills"&&!j&&w("agents")},[f,j]);const y=Ot(),u=vt(R.data,"radient_org"),x=t?ka(u,y??null):null,{memberships:A}=ua({enabled:We(u)}),z=r.useMemo(()=>ja(A),[A]),Q=h===H||z.some(c=>c.tenant_id===h);r.useEffect(()=>{!Q&&k!=="skills"&&E(H)},[Q,k]);const D=h===H?null:z.find(c=>c.tenant_id===h)??null,U=D?.tenant_id,N=D?.tenant_name||null,M=d!==null||P!=="",te=st({tenantId:U}),ae=Xs({page:1,perPage:ns,enabled:h===H}),me=U&&te.isSuccess?te.teams.length:null,ve=ae.isSuccess?ae.pagination?.totalRecords??null:null,K=M?null:h===H?ve:me,_=h===H?{visibility:"public",tenantId:null}:{visibility:"org",tenantId:h},Ne=Q&&(h===H||We(u)),he=Zs(_,1,j&&Ne&&(h===H||t)),se=he.isSuccess?he.data.total:null,Le=D?.role==="owner"||D?.role==="admin",xe=r.useMemo(()=>new Map(A.map(c=>[c.tenant_id,c.tenant_name])),[A]),{data:le,agents:Oe,isLoading:Fe,isFetching:V,error:J,refetch:be,pagination:$}=zt({page:i,perPage:l,categories:d?[d]:void 0,name:v==="name"&&P||void 0,description:v==="description"&&P||void 0,sort:g.sort,order:g.order,tenantId:U}),o=D?Gs(J):null,q=Oe??[],X=V&&le!==void 0,{statuses:pe,isKnown:we,isError:ut,isFetching:qe,refetch:ot}=Wt({agentIds:U?[]:q.map(c=>c.id)}),ze=r.useRef(null),De=r.useRef(null),[cs,dt]=r.useState(0);r.useEffect(()=>{cs!==0&&(ze.current??De.current)?.focus()},[cs]);const us=r.useRef(null),Me=r.useRef(!1),Ue=r.useMemo(()=>[...new Set((le?.records??[]).flatMap(c=>c.categories??[]))],[le]);r.useEffect(()=>{F(c=>Ue.every(Y=>c.includes(Y))?c:[...new Set([...c,...Ue])])},[Ue]);const mt=()=>{m(null),p(""),n(1),dt(c=>c+1)},W=(Fe||V)&&le===void 0,os=!W&&!M&&(J!==null||q.length===0);r.useEffect(()=>{!Me.current||W||(Me.current=!1,J?us.current?.focus():(ze.current??De.current)?.focus())},[W,J]);const ds=r.useRef(null),ht=c=>{n(c),ds.current?.scrollIntoView({block:"nearest"})},xt=c=>{m(c),n(1)},bt=c=>{p(c),n(1)},pt=c=>{E(c),n(1)},ms=r.useRef(new Map),gt=c=>{O(c),n(1)},ft=$&&!M?$.totalRecords:null,_e=U?a("ui.hub.pages.status.scope.shared_with",{org:N??a("ui.hub.pages.scope.org_unnamed")}):a("ui.hub.pages.status.scope.public"),hs=(c,Y)=>Y==="team"?a("ui.hub.pages.status.count.teams",{count:c,scope:_e}):a("ui.hub.pages.status.count.agents",{count:c,scope:_e});let ee;return k==="skills"?ee=" ":k==="teams"?U?te.isLoading?ee=a("ui.hub.pages.status.loading_teams"):K!==null?ee=hs(K,"team"):ee=a("ui.hub.pages.status.teams_scope",{scope:_e}):ee=" ":W?ee=a("ui.hub.pages.status.loading_agents"):$?ee=hs($.totalRecords,"agent"):ee=a("ui.hub.pages.status.agents_scope",{scope:_e}),e.jsxs("div",{className:"flex h-full flex-col gap-8 p-6",children:[e.jsx(Nt,{title:a("ui.hub.pages.header.title"),subtitle:a("ui.hub.pages.header.subtitle"),icon:oa}),e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-4",children:[x&&e.jsxs(ge,{variant:"warning",className:"max-w-2xl","data-testid":"agent-hub-org-unavailable",children:[e.jsx(fe,{children:a("ui.hub.pages.orgs_unavailable")}),e.jsx(je,{children:x})]}),e.jsxs("div",{className:"flex shrink-0 flex-wrap items-center gap-x-4 gap-y-2","data-testid":"agent-hub-browse-bar",children:[e.jsx(St,{value:k,onValueChange:c=>w(c),children:e.jsx(Ct,{"aria-label":a("ui.hub.pages.browse_aria"),children:["agents","teams",...j?["skills"]:[]].map(c=>{const Y=c==="agents"?ft:c==="teams"?K:se;return e.jsxs(Pt,{value:c,id:Fs[c],"aria-controls":k===c?qs:void 0,"data-testid":`agent-hub-view-${c}`,children:[c==="agents"?a("ui.hub.pages.tab.agents"):c==="teams"?a("ui.hub.pages.tab.teams"):a("ui.hub.skills.title"),Y!==null&&e.jsx("span",{className:"min-w-[2ch] font-normal text-ink-dim tabular-nums",children:Y})]},c)})})}),z.length>0&&e.jsxs("div",{className:"ml-auto flex min-w-0 items-center gap-2",children:[e.jsx("span",{"aria-hidden":"true",className:"text-meta text-ink-muted",children:a("ui.hub.pages.scope_label")}),e.jsxs("fieldset",{className:"m-0 min-w-0 border-0 p-0","data-testid":"agent-hub-scope",children:[e.jsx("legend",{className:"sr-only",children:a("ui.hub.pages.scope_legend")}),e.jsx("div",{className:"flex flex-wrap gap-0.5 rounded-md bg-sunken p-0.5",children:[{value:H,label:a("ui.hub.pages.scope.public"),Icon:Ft},...z.map(c=>({value:c.tenant_id,label:c.tenant_name||a("ui.hub.pages.scope.org_label"),Icon:ya}))].map(({value:c,label:Y,Icon:jt})=>e.jsxs(C,{ref:xs=>{xs?ms.current.set(c,xs):ms.current.delete(c)},variant:"ghost",size:"sm","aria-pressed":h===c,onClick:()=>pt(c),title:Y,"data-testid":`agent-hub-scope-${c===H?"public":`org-${c}`}`,className:B("max-w-48",h===c&&"bg-surface text-ink hover:bg-surface"),children:[e.jsx(jt,{"aria-hidden":"true"}),e.jsx("span",{className:"truncate",children:Y})]},c))})]})]})]}),e.jsx(Tt,{id:qs,labelledBy:Fs[k],children:e.jsxs("div",{className:"flex min-h-0 flex-1 flex-row overflow-hidden",children:[k==="agents"&&e.jsx(e.Fragment,{children:e.jsx("div",{className:"mr-6 hidden w-60 shrink-0 rounded-md bg-surface p-2 md:block","data-glass-region":"panel","data-tour-tag":"agent-hub-sidebar-container",children:!os&&e.jsx(Ca,{selectedCategory:d,onSelectCategory:xt,categories:I})})}),e.jsxs("div",{className:"flex min-w-0 flex-1 flex-col overflow-y-auto",children:[k==="agents"&&!os&&e.jsxs("div",{className:"mb-4 flex flex-wrap items-center gap-2",children:[e.jsxs("div",{className:B("flex min-w-56 flex-1 items-center rounded-sm border border-control bg-surface","transition-colors duration-fast ease-out-quart","has-[:focus-visible]:outline-solid has-[:focus-visible]:outline-2","has-[:focus-visible]:outline-accent has-[:focus-visible]:outline-offset-2"),children:[e.jsx(Ae,{ref:ze,type:"search",value:L,onChange:c=>bt(c.target.value),placeholder:a("ui.hub.pages.search.placeholder"),"aria-label":a("ui.hub.pages.search.aria"),className:"h-8 min-w-0 flex-1 border-0 bg-transparent outline-none","data-testid":"agent-hub-search"}),e.jsxs(ps,{value:v,onValueChange:gt,children:[e.jsx(gs,{className:"w-auto shrink-0 border-y-0 border-l border-hairline border-r-0 bg-transparent pl-2 outline-none","aria-label":a("ui.hub.pages.search.scope_aria"),"data-testid":"agent-hub-search-scope",children:e.jsx(fs,{})}),e.jsx(js,{children:ci.map(c=>e.jsx(ks,{value:c.value,children:a(c.label)},c.value))})]})]}),e.jsxs(ps,{value:S,onValueChange:b,children:[e.jsx(gs,{className:"w-48","aria-label":a("ui.hub.pages.sort.aria"),"data-testid":"agent-hub-sort",children:e.jsx(fs,{})}),e.jsx(js,{children:Se.map(c=>e.jsx(ks,{value:c.value,children:a(c.label)},c.value))})]})]}),e.jsxs("p",{ref:ds,"aria-live":"polite",className:"mb-3 text-meta text-ink-dim","data-testid":"agent-hub-status",children:[ee,k==="agents"&&X?e.jsxs(e.Fragment,{children:[" ",e.jsx("span",{"data-testid":"agent-hub-updating",children:a("ui.hub.pages.updating")})]}):null]}),k==="agents"&&e.jsxs(e.Fragment,{children:[t&&ut&&e.jsxs("output",{className:"mb-3 flex flex-wrap items-center gap-2 text-meta text-warning","data-testid":"agent-hub-status-unknown",children:[e.jsx("span",{children:a("ui.hub.pages.viewer_unknown")}),e.jsx(C,{variant:"ghost",size:"sm",onClick:()=>void ot(),disabled:qe,"aria-busy":qe,children:qe?"Trying…":"Try again"})]}),W&&e.jsx("div",{"data-testid":"agent-hub-loading",className:"grid grid-cols-[repeat(auto-fill,minmax(17.5rem,1fr))] gap-6",children:Array.from({length:6},(c,Y)=>e.jsx(oi,{},Y))}),W&&$===void 0&&e.jsx("div",{"aria-hidden":"true",className:"mt-6 flex min-h-13 items-center justify-center","data-testid":"agent-hub-pager-placeholder",children:e.jsx(T,{className:"h-4 w-24"})}),e.jsx("output",{"aria-live":"polite","data-testid":"agent-hub-outage",className:B(!W&&J&&!o?"block":"sr-only"),children:!W&&J&&!o&&e.jsxs(ge,{variant:"danger",className:"max-w-2xl","aria-busy":V,"data-testid":"agent-hub-error",children:[e.jsx(fe,{children:t?"The hub could not be loaded":"Sign in to use the hub"}),e.jsx(je,{children:t?es("The agent list could not be loaded.",J):"You are not signed in to Radient, so the hub has no credential to read the agent list with. Sign in on the settings page, then try again."}),e.jsx("div",{className:"mt-2",children:e.jsx(C,{ref:us,variant:"outline",size:"sm",onClick:()=>{Me.current=!0,be()},disabled:V,"aria-busy":V,children:V?"Trying…":"Try again"})})]})}),!W&&o&&D&&e.jsxs(ge,{variant:"warning",className:"max-w-2xl","data-testid":"agent-hub-org-no-access",children:[e.jsx(fe,{children:o==="plan"?"That organization needs an active Team plan":"You do not have access to that organization"}),e.jsx(je,{children:o==="plan"?`Sharing agents inside an organization is part of the Team plan. An owner of ${D.tenant_name||"this organization"} can activate it in the Radient console, and then its agents will be listed here.`:`You are not a member of ${D.tenant_name||"that organization"}, so its agents are not listed here. An owner can invite you again.`}),o==="plan"&&e.jsx("div",{className:"mt-2",children:e.jsx(C,{variant:"primary",size:"sm",onClick:()=>void be(),disabled:V,"aria-busy":V,children:V?"Trying…":"Try again"})})]}),!W&&!J&&e.jsx("div",{className:"grid grid-cols-[repeat(auto-fill,minmax(17.5rem,1fr))] gap-6","aria-busy":X,children:q.length===0?e.jsxs("div",{"data-testid":"agent-hub-empty",className:B("col-span-full w-full flex flex-col items-center gap-2 rounded-md bg-surface px-6 py-10 text-center",!U&&"max-w-2xl justify-self-center"),children:[e.jsx("p",{className:"text-heading text-ink",children:U?"This organization has no shared agents yet.":d?`No agents in ${Qs(d).label}.`:M?"No agents match that search.":"The hub is empty."}),e.jsx("p",{className:"max-w-md text-body-sm text-ink-muted",children:U?`Agents published into ${D?.tenant_name||"this organization"} appear here for its members.`:d?"Nothing in this category yet. Clear the filter to see the whole hub.":M?"No agent's name or description carries that. Clear it to see the whole hub.":"Nobody has published an agent yet. Yours could be the first."}),e.jsx("div",{className:"mt-2 flex flex-wrap items-center justify-center gap-2",children:M?e.jsx(C,{variant:"secondary",onClick:mt,children:d?"Clear filter":"Clear search"}):U&&!Le?null:e.jsx(C,{ref:De,variant:"secondary",onClick:()=>s("/agents"),children:a("ui.hub.pages.publish")})})]}):q.map(c=>e.jsx(_a,{agent:c,status:t?pe[c.id]:void 0,viewerStateKnown:t&&Yt(we,pe,c.id),orgName:c.visibility==="org"?xe.get(c.tenant_id)??null:null},c.id))}),!W&&$&&$.totalPages>1&&e.jsx(as,{count:$.totalPages,page:$.page,onChange:ht})]}),k==="skills"&&(j?e.jsx(Ua,{scope:h===H?{visibility:"public",tenantId:null,organization:null}:{visibility:"org",tenantId:h,organization:N},signedIn:t,accessible:Q&&(h===H||We(u))},`skills:${h}`):e.jsx("p",{className:"text-body-sm text-warning",children:a("ui.hub.skills.unavailable")})),k==="teams"&&(D?e.jsx(Xa,{tenantId:D.tenant_id,orgName:N}):e.jsx(ii,{signedIn:t,onOpenSettings:()=>s("/settings")}))]})]})})]})]})};export{Pi as AgentHubPage};