@lacneu/atrium 0.91.1 → 0.91.3

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 (84) hide show
  1. package/dist/assets/{AccessTab-Cwu9fJwI.js → AccessTab-B7Qb2-lZ.js} +1 -1
  2. package/dist/assets/{AdvancedFilter-DWYTua7e.js → AdvancedFilter-Bm0I1TOa.js} +1 -1
  3. package/dist/assets/AgentFilesTab-CK7t36QE.js +3 -0
  4. package/dist/assets/AnomaliesTab-PBcXokbs.js +1 -0
  5. package/dist/assets/AuditTab-DVjMAHXs.js +1 -0
  6. package/dist/assets/BridgeTab-Dt95NA_7.js +1 -0
  7. package/dist/assets/ChatDefaultsTab-DZ9ZL3EP.js +1 -0
  8. package/dist/assets/{DataTableShell-Dc3I5mkG.js → DataTableShell-P8WPv8pJ.js} +1 -1
  9. package/dist/assets/{DetailChips-Cj0X9b5z.js → DetailChips-Bb_1pD-w.js} +1 -1
  10. package/dist/assets/FeedbacksTab-B6sjorN_.js +1 -0
  11. package/dist/assets/{FieldLabel-BVUMb8MI.js → FieldLabel-DaWvOVaq.js} +1 -1
  12. package/dist/assets/FilesTab-CGrWd9d1.js +1 -0
  13. package/dist/assets/{FilterBar-Bfu-khK5.js → FilterBar-BWsi04G_.js} +1 -1
  14. package/dist/assets/GroupsTab-6-wQE2Ui.js +1 -0
  15. package/dist/assets/InstancesTab-BWYzJd_a.js +1 -0
  16. package/dist/assets/IntegrationsTab-CK7DSB-M.js +1 -0
  17. package/dist/assets/KpiTab-C54gwXNq.js +1 -0
  18. package/dist/assets/PreferencesTab-BBpLdx_-.js +1 -0
  19. package/dist/assets/ProjectPage-BUGdPdmU.js +1 -0
  20. package/dist/assets/PromptInjectionsTab-BHJ0-ZWI.js +4 -0
  21. package/dist/assets/RolesTab-YmvPDwpq.js +1 -0
  22. package/dist/assets/ScheduledTab-BZiFyTay.js +1 -0
  23. package/dist/assets/ServiceAccountsTab-MGyT4mVz.js +1 -0
  24. package/dist/assets/{SubAgentReportsTab-DjKyJxXi.js → SubAgentReportsTab-UQMDNwEo.js} +1 -1
  25. package/dist/assets/ThemeShowroom-KiqSBvlh.js +1 -0
  26. package/dist/assets/{TimeRangePicker-BqClp5BN.js → TimeRangePicker-BVCNIF4U.js} +1 -1
  27. package/dist/assets/{TimezoneCombobox-yZPA1ePa.js → TimezoneCombobox-BB280Bgg.js} +1 -1
  28. package/dist/assets/TracesTab-yAjObtOK.js +1 -0
  29. package/dist/assets/TrashPage-DK0mKtzJ.js +1 -0
  30. package/dist/assets/TrashTab-S6IkI4t6.js +1 -0
  31. package/dist/assets/UsersTab-DTvPti51.js +1 -0
  32. package/dist/assets/VoiceTab-CYJea2dn.js +1 -0
  33. package/dist/assets/api-BiOKjOdr.js +44 -0
  34. package/dist/assets/{button-DDPt-po9.js → button-D0Pgjwxf.js} +1 -1
  35. package/dist/assets/{card-K4Zt5gfO.js → card-BaftCgRb.js} +1 -1
  36. package/dist/assets/chevrons-up-down-CogPekve.js +1 -0
  37. package/dist/assets/{compatView-CVibrgBK.js → compatView-qPB4mG-_.js} +1 -1
  38. package/dist/assets/dispatchErrorInfo-Wn57FY4L.js +1 -0
  39. package/dist/assets/{dist-CRdE-dec.js → dist-By4rZwo-.js} +1 -1
  40. package/dist/assets/{dist-BblNQdHV.js → dist-CH3gjR1_.js} +1 -1
  41. package/dist/assets/{dist-Cwenjp6w.js → dist-CeZTHwrs.js} +1 -1
  42. package/dist/assets/{dist-821wRD_K.js → dist-DAKYY4yE.js} +1 -1
  43. package/dist/assets/{highlighted-body-OFNGDK62-rit1TAaB.js → highlighted-body-OFNGDK62-D4p66OHE.js} +1 -1
  44. package/dist/assets/{index-CkNmrzkS.css → index-qA0SteHp.css} +1 -1
  45. package/dist/assets/index-xhYNLD3V.js +446 -0
  46. package/dist/assets/{list-9tuUpKq3.js → list-Dx86Q3WV.js} +1 -1
  47. package/dist/assets/mermaid-GHXKKRXX-wpDfhXTf.js +1 -0
  48. package/dist/assets/{pdf-BZkOsg6N.js → pdf-BW6qvf4R.js} +1 -1
  49. package/dist/assets/roleDescriptions-DKA8gzL4.js +1 -0
  50. package/dist/assets/{table-CnU0GqDN.js → table-DsK3yFpt.js} +1 -1
  51. package/dist/assets/{use_paginated_query-DHl8KBoi.js → use_paginated_query-JzX-Y80s.js} +1 -1
  52. package/dist/assets/x-BXqaL85P.js +1 -0
  53. package/dist/index.html +9 -9
  54. package/package.json +1 -1
  55. package/dist/assets/AgentFilesTab-DaYXJcuZ.js +0 -3
  56. package/dist/assets/AnomaliesTab-RKY5LYNV.js +0 -1
  57. package/dist/assets/AuditTab-CqLksOpr.js +0 -1
  58. package/dist/assets/BridgeTab-1RNCxXv2.js +0 -1
  59. package/dist/assets/ChatDefaultsTab-BuS1Ihhq.js +0 -1
  60. package/dist/assets/FeedbacksTab-CmhVA188.js +0 -1
  61. package/dist/assets/FilesTab-Bs-qAb6x.js +0 -1
  62. package/dist/assets/GroupsTab-BblkD-Mw.js +0 -1
  63. package/dist/assets/InstancesTab-CykKru2n.js +0 -1
  64. package/dist/assets/IntegrationsTab-BGvWPcJJ.js +0 -1
  65. package/dist/assets/KpiTab-0-fYoy76.js +0 -1
  66. package/dist/assets/PreferencesTab-B7rx5jxG.js +0 -1
  67. package/dist/assets/ProjectPage-DeOofCgG.js +0 -1
  68. package/dist/assets/PromptInjectionsTab-iKx77mc6.js +0 -4
  69. package/dist/assets/RolesTab-CdpxcL32.js +0 -1
  70. package/dist/assets/ScheduledTab-mr_m7UIj.js +0 -1
  71. package/dist/assets/ServiceAccountsTab-Do5kRXXv.js +0 -1
  72. package/dist/assets/ThemeShowroom-wAQ75k0V.js +0 -1
  73. package/dist/assets/TracesTab-n_5fNBHX.js +0 -1
  74. package/dist/assets/TrashPage-DKaJKpYI.js +0 -1
  75. package/dist/assets/TrashTab-C5EAGQ-A.js +0 -1
  76. package/dist/assets/UsersTab-DIGrBmUm.js +0 -1
  77. package/dist/assets/VoiceTab-CaHc9iZY.js +0 -1
  78. package/dist/assets/api-IF2KQFNF.js +0 -44
  79. package/dist/assets/chevrons-up-down-8nG-pF3_.js +0 -1
  80. package/dist/assets/dispatchErrorInfo-CO5iC4yd.js +0 -1
  81. package/dist/assets/index-DaLXKABQ.js +0 -446
  82. package/dist/assets/mermaid-GHXKKRXX-BOZxTT7y.js +0 -1
  83. package/dist/assets/roleDescriptions-DBJFh3-K.js +0 -1
  84. package/dist/assets/x-F4mR_Xu3.js +0 -1
@@ -0,0 +1 @@
1
+ import{$M as e,QM as t,XM as n,YM as r,ZM as i}from"./api-BiOKjOdr.js";var a={pending:e,user:t,admin:i,observer:n,agent:r};function o(e){if(e.builtin){let t=a[e.key];if(t)return t()}return e.description}export{o as t};
@@ -1 +1 @@
1
- import{a as e,r as t}from"./bundle-mjs-C73ZY4La.js";import{r as n}from"./api-IF2KQFNF.js";e();var r=t();function i({className:e,...t}){return(0,r.jsx)(`div`,{"data-slot":`table-container`,className:`relative w-full overflow-x-auto`,children:(0,r.jsx)(`table`,{"data-slot":`table`,className:n(`w-full caption-bottom text-sm`,e),...t})})}function a({className:e,...t}){return(0,r.jsx)(`thead`,{"data-slot":`table-header`,className:n(`[&_tr]:border-b`,e),...t})}function o({className:e,...t}){return(0,r.jsx)(`tbody`,{"data-slot":`table-body`,className:n(`[&_tr:last-child]:border-0`,e),...t})}function s({className:e,...t}){return(0,r.jsx)(`tr`,{"data-slot":`table-row`,className:n(`border-b transition-colors hover:bg-muted/50 has-aria-expanded:bg-muted/50 data-[state=selected]:bg-muted`,e),...t})}function c({className:e,...t}){return(0,r.jsx)(`th`,{"data-slot":`table-head`,className:n(`h-10 px-2 text-left align-middle font-medium whitespace-nowrap text-foreground [&:has([role=checkbox])]:pr-0`,e),...t})}function l({className:e,...t}){return(0,r.jsx)(`td`,{"data-slot":`table-cell`,className:n(`p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0`,e),...t})}export{a,c as i,o as n,s as o,l as r,i as t};
1
+ import{a as e,r as t}from"./bundle-mjs-C73ZY4La.js";import{r as n}from"./api-BiOKjOdr.js";e();var r=t();function i({className:e,...t}){return(0,r.jsx)(`div`,{"data-slot":`table-container`,className:`relative w-full overflow-x-auto`,children:(0,r.jsx)(`table`,{"data-slot":`table`,className:n(`w-full caption-bottom text-sm`,e),...t})})}function a({className:e,...t}){return(0,r.jsx)(`thead`,{"data-slot":`table-header`,className:n(`[&_tr]:border-b`,e),...t})}function o({className:e,...t}){return(0,r.jsx)(`tbody`,{"data-slot":`table-body`,className:n(`[&_tr:last-child]:border-0`,e),...t})}function s({className:e,...t}){return(0,r.jsx)(`tr`,{"data-slot":`table-row`,className:n(`border-b transition-colors hover:bg-muted/50 has-aria-expanded:bg-muted/50 data-[state=selected]:bg-muted`,e),...t})}function c({className:e,...t}){return(0,r.jsx)(`th`,{"data-slot":`table-head`,className:n(`h-10 px-2 text-left align-middle font-medium whitespace-nowrap text-foreground [&:has([role=checkbox])]:pr-0`,e),...t})}function l({className:e,...t}){return(0,r.jsx)(`td`,{"data-slot":`table-cell`,className:n(`p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0`,e),...t})}export{a,c as i,o as n,s as o,l as r,i as t};
@@ -1 +1 @@
1
- import{a as e,l as t}from"./bundle-mjs-C73ZY4La.js";import{_Y as n,jY as r,kY as i,wY as a,xY as o}from"./api-IF2KQFNF.js";var s=t(e(),1),c=(e,t,n)=>r=>{let i={...r.queries},a=r.nextPageKey,o=r.nextPageKey+1,s=r.nextPageKey+2;i[a]={query:r.query,args:{...r.args,paginationOpts:{...r.queries[e].args.paginationOpts,endCursor:t}}},i[o]={query:r.query,args:{...r.args,paginationOpts:{...r.queries[e].args.paginationOpts,cursor:t,endCursor:n}}};let c={...r.ongoingSplits};return c[e]=[a,o],{...r,nextPageKey:s,queries:i,ongoingSplits:c}},l=e=>t=>{let n=t.ongoingSplits[e];if(n===void 0)return t;let r={...t.queries};delete r[e];let i={...t.ongoingSplits};delete i[e];let a=t.pageKeys.slice(),o=t.pageKeys.findIndex(t=>t===e);return o>=0&&(a=[...t.pageKeys.slice(0,o),...n,...t.pageKeys.slice(o+1)]),{...t,queries:r,pageKeys:a,ongoingSplits:i}};function u(e,t,n){let{user:r}=p(e,t,n,!0);return r}var d=Symbol(`includePageKeys`),f=Symbol(`page`);function p(e,t,u,p=!0){if(typeof u?.initialNumItems!=`number`||u.initialNumItems<0)throw Error(`\`options.initialNumItems\` must be a positive number. Received \`${u?.initialNumItems}\`.`);let m=t===`skip`,g=m?{}:t,_=a(e),v=(0,s.useMemo)(()=>()=>{let t=h();return{query:e,args:g,id:t,nextPageKey:1,pageKeys:m?[]:[0],queries:m?{}:{0:{query:e,args:{...g,paginationOpts:{numItems:u.initialNumItems,cursor:null,id:t}}}},ongoingSplits:{},skip:m}},[JSON.stringify(r(g)),_,u.initialNumItems,m]),[y,b]=(0,s.useState)(v),x=y;(a(e)!==a(y.query)||JSON.stringify(r(g))!==JSON.stringify(r(y.args))||m!==y.skip)&&(x=v(),b(x));let S=o().logger,C=n(x.queries),w=u[d]??!1,[T,E,D]=(0,s.useMemo)(()=>{let e,t=[];for(let n of x.pageKeys){if(e=C[n],e===void 0)break;if(e instanceof Error){if(e.message.includes(`InvalidCursor`)||e instanceof i&&typeof e.data==`object`&&e.data?.isConvexSystemError===!0&&e.data?.paginationError===`InvalidCursor`)return S.warn(`usePaginatedQuery hit error, resetting pagination state: `+e.message),b(v),[[],void 0,void 0];if(p)throw e;return[t,void 0,e]}let r=x.ongoingSplits[n];if(r===void 0?e.splitCursor&&(e.pageStatus===`SplitRecommended`||e.pageStatus===`SplitRequired`||e.page.length>u.initialNumItems*2)&&b(c(n,e.splitCursor,e.continueCursor)):C[r[0]]!==void 0&&C[r[1]]!==void 0&&b(l(n)),e.pageStatus===`SplitRequired`)return[t,void 0,void 0];t.push(...w?e.page.map(e=>({...e,[f]:n.toString()})):e.page)}return[t,e,void 0]},[C,x.pageKeys,x.ongoingSplits,u.initialNumItems,v,S,w,p]);return{user:{results:T,...(0,s.useMemo)(()=>{if(D!==void 0)return{status:`Error`,isLoading:!1,error:D,loadMore:()=>{}};if(E===void 0)return x.nextPageKey===1?{status:`LoadingFirstPage`,isLoading:!0,loadMore:()=>{}}:{status:`LoadingMore`,isLoading:!0,loadMore:e=>{}};if(E.isDone)return{status:`Exhausted`,isLoading:!1,loadMore:e=>{}};let e=E.continueCursor,t=!1;return{status:`CanLoadMore`,isLoading:!1,loadMore:n=>{t||(t=!0,b(t=>{let r=[...t.pageKeys,t.nextPageKey],i={...t.queries};return i[t.nextPageKey]={query:t.query,args:{...t.args,paginationOpts:{numItems:n,cursor:e,id:t.id}}},{...t,nextPageKey:t.nextPageKey+1,pageKeys:r,queries:i}}))}}},[D,E,x.nextPageKey])},internal:{state:x}}}var m=0;function h(){return m++,m}export{u as t};
1
+ import{a as e,l as t}from"./bundle-mjs-C73ZY4La.js";import{FY as n,HY as r,YY as i,qY as a,zY as o}from"./api-BiOKjOdr.js";var s=t(e(),1),c=(e,t,n)=>r=>{let i={...r.queries},a=r.nextPageKey,o=r.nextPageKey+1,s=r.nextPageKey+2;i[a]={query:r.query,args:{...r.args,paginationOpts:{...r.queries[e].args.paginationOpts,endCursor:t}}},i[o]={query:r.query,args:{...r.args,paginationOpts:{...r.queries[e].args.paginationOpts,cursor:t,endCursor:n}}};let c={...r.ongoingSplits};return c[e]=[a,o],{...r,nextPageKey:s,queries:i,ongoingSplits:c}},l=e=>t=>{let n=t.ongoingSplits[e];if(n===void 0)return t;let r={...t.queries};delete r[e];let i={...t.ongoingSplits};delete i[e];let a=t.pageKeys.slice(),o=t.pageKeys.findIndex(t=>t===e);return o>=0&&(a=[...t.pageKeys.slice(0,o),...n,...t.pageKeys.slice(o+1)]),{...t,queries:r,pageKeys:a,ongoingSplits:i}};function u(e,t,n){let{user:r}=p(e,t,n,!0);return r}var d=Symbol(`includePageKeys`),f=Symbol(`page`);function p(e,t,u,p=!0){if(typeof u?.initialNumItems!=`number`||u.initialNumItems<0)throw Error(`\`options.initialNumItems\` must be a positive number. Received \`${u?.initialNumItems}\`.`);let m=t===`skip`,g=m?{}:t,_=r(e),v=(0,s.useMemo)(()=>()=>{let t=h();return{query:e,args:g,id:t,nextPageKey:1,pageKeys:m?[]:[0],queries:m?{}:{0:{query:e,args:{...g,paginationOpts:{numItems:u.initialNumItems,cursor:null,id:t}}}},ongoingSplits:{},skip:m}},[JSON.stringify(i(g)),_,u.initialNumItems,m]),[y,b]=(0,s.useState)(v),x=y;(r(e)!==r(y.query)||JSON.stringify(i(g))!==JSON.stringify(i(y.args))||m!==y.skip)&&(x=v(),b(x));let S=o().logger,C=n(x.queries),w=u[d]??!1,[T,E,D]=(0,s.useMemo)(()=>{let e,t=[];for(let n of x.pageKeys){if(e=C[n],e===void 0)break;if(e instanceof Error){if(e.message.includes(`InvalidCursor`)||e instanceof a&&typeof e.data==`object`&&e.data?.isConvexSystemError===!0&&e.data?.paginationError===`InvalidCursor`)return S.warn(`usePaginatedQuery hit error, resetting pagination state: `+e.message),b(v),[[],void 0,void 0];if(p)throw e;return[t,void 0,e]}let r=x.ongoingSplits[n];if(r===void 0?e.splitCursor&&(e.pageStatus===`SplitRecommended`||e.pageStatus===`SplitRequired`||e.page.length>u.initialNumItems*2)&&b(c(n,e.splitCursor,e.continueCursor)):C[r[0]]!==void 0&&C[r[1]]!==void 0&&b(l(n)),e.pageStatus===`SplitRequired`)return[t,void 0,void 0];t.push(...w?e.page.map(e=>({...e,[f]:n.toString()})):e.page)}return[t,e,void 0]},[C,x.pageKeys,x.ongoingSplits,u.initialNumItems,v,S,w,p]);return{user:{results:T,...(0,s.useMemo)(()=>{if(D!==void 0)return{status:`Error`,isLoading:!1,error:D,loadMore:()=>{}};if(E===void 0)return x.nextPageKey===1?{status:`LoadingFirstPage`,isLoading:!0,loadMore:()=>{}}:{status:`LoadingMore`,isLoading:!0,loadMore:e=>{}};if(E.isDone)return{status:`Exhausted`,isLoading:!1,loadMore:e=>{}};let e=E.continueCursor,t=!1;return{status:`CanLoadMore`,isLoading:!1,loadMore:n=>{t||(t=!0,b(t=>{let r=[...t.pageKeys,t.nextPageKey],i={...t.queries};return i[t.nextPageKey]={query:t.query,args:{...t.args,paginationOpts:{numItems:n,cursor:e,id:t.id}}},{...t,nextPageKey:t.nextPageKey+1,pageKeys:r,queries:i}}))}}},[D,E,x.nextPageKey])},internal:{state:x}}}var m=0;function h(){return m++,m}export{u as t};
@@ -0,0 +1 @@
1
+ import{E as e}from"./api-BiOKjOdr.js";var t=e(`x`,[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]);export{t};
package/dist/index.html CHANGED
@@ -62,16 +62,16 @@
62
62
  document.documentElement.dataset.motion = "static";
63
63
  })();
64
64
  </script>
65
- <script type="module" crossorigin src="/assets/index-DaLXKABQ.js"></script>
65
+ <script type="module" crossorigin src="/assets/index-xhYNLD3V.js"></script>
66
66
  <link rel="modulepreload" crossorigin href="/assets/bundle-mjs-C73ZY4La.js">
67
- <link rel="modulepreload" crossorigin href="/assets/api-IF2KQFNF.js">
68
- <link rel="modulepreload" crossorigin href="/assets/dist-CRdE-dec.js">
69
- <link rel="modulepreload" crossorigin href="/assets/dist-Cwenjp6w.js">
70
- <link rel="modulepreload" crossorigin href="/assets/dist-821wRD_K.js">
71
- <link rel="modulepreload" crossorigin href="/assets/dist-BblNQdHV.js">
72
- <link rel="modulepreload" crossorigin href="/assets/x-F4mR_Xu3.js">
73
- <link rel="modulepreload" crossorigin href="/assets/button-DDPt-po9.js">
74
- <link rel="stylesheet" crossorigin href="/assets/index-CkNmrzkS.css">
67
+ <link rel="modulepreload" crossorigin href="/assets/api-BiOKjOdr.js">
68
+ <link rel="modulepreload" crossorigin href="/assets/dist-By4rZwo-.js">
69
+ <link rel="modulepreload" crossorigin href="/assets/dist-CeZTHwrs.js">
70
+ <link rel="modulepreload" crossorigin href="/assets/dist-DAKYY4yE.js">
71
+ <link rel="modulepreload" crossorigin href="/assets/dist-CH3gjR1_.js">
72
+ <link rel="modulepreload" crossorigin href="/assets/x-BXqaL85P.js">
73
+ <link rel="modulepreload" crossorigin href="/assets/button-D0Pgjwxf.js">
74
+ <link rel="stylesheet" crossorigin href="/assets/index-qA0SteHp.css">
75
75
  </head>
76
76
  <body>
77
77
  <div id="root"></div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lacneu/atrium",
3
- "version": "0.91.1",
3
+ "version": "0.91.3",
4
4
  "description": "Atrium — public, self-hostable, Convex-backed web chat UI for AI agent gateways (OpenClaw today, Hermes next). Ships an origin-agnostic static bundle (Convex URL injected at runtime via /config.json).",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -1,3 +0,0 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$d as r,A_ as i,Ad as a,CY as o,C_ as s,D_ as c,E_ as l,F_ as u,Fd as d,M_ as f,Md as p,N_ as m,Nd as h,O_ as g,P_ as _,Pd as v,Qd as y,SY as b,S_ as x,T_ as S,Zd as C,__ as w,_f as T,af as E,bY as D,b_ as O,c_ as ee,cf as k,d_ as A,df as j,ef as M,f_ as N,ff as P,g_ as F,gf as I,hY as L,h_ as R,hf as te,if as z,j_ as ne,jd as B,k_ as re,kd as V,l_ as H,lf as ie,m_ as ae,mf as oe,nf as U,o_ as W,of as se,pY as G,p_ as ce,pf as le,rf as ue,s_ as de,sf as fe,ss as pe,t as K,tf as me,u_ as he,uf as ge,v_ as _e,wB as ve,w_ as ye,x_ as be,xv as q,y_ as xe,yv as Se}from"./api-IF2KQFNF.js";import{t as J}from"./button-DDPt-po9.js";import{Bt as Ce,Ct as we,Dt as Te,Gt as Ee,Ht as De,Jt as Oe,Kt as ke,Ot as Ae,St as je,Tt as Me,Ut as Ne,Vt as Pe,Wt as Fe,Yt as Y,bt as Ie,ft as Le,kn as Re,nt as ze,qt as Be,vt as Ve,wt as He,xt as Ue,yt as We}from"./index-DaLXKABQ.js";import{n as Ge,t as Ke}from"./curation-CQksaIbm.js";import{a as qe}from"./compatView-CVibrgBK.js";/* empty css */var X=t(e(),1),Je=2e4,Ye=6e4;function Xe(e){return typeof e!=`number`||e<=0?0:Math.round(e/Je*100)}function Ze(e){return e<=0?0:Math.round(e/Ye*100)}function Z(e,t){let n=(typeof e==`number`&&e>0?e:0)/1e3;return new Intl.NumberFormat(t,{minimumFractionDigits:1,maximumFractionDigits:1}).format(n)}function Qe(e){return e.reduce((e,t)=>e+(typeof t.size==`number`&&t.size>0?t.size:0),0)}var $e=3;function et(e,t){let n=new Map;for(let t of e.split(`
2
- `))n.set(t,(n.get(t)??0)+1);for(let e of t.split(`
3
- `))n.set(e,(n.get(e)??0)-1);let r=0,i=0,a=[],o=[];for(let[e,t]of n)t<0?(r+=-t,a.length<$e&&a.push(e)):t>0&&(i+=t,o.length<$e&&o.push(e));return{added:r,removed:i,sampleAdded:a,sampleRemoved:o}}function tt(e){return(e instanceof Error?e.message:String(e)).includes(`DASHBOARD_NOT_DEPLOYED`)}function nt(e){return e instanceof Error?e.message.includes(`conflict:`):String(e).includes(`conflict:`)}var Q=n(),$=e=>`${e.instanceName}::${e.agentId}`;function rt(){let e=o(K.me.getMe,{host:Le}),t=e?.role===`admin`,n=(e?.permissions??[]).includes(`bridge.read`),r=o(K.admin.listInstances,e!==void 0&&t?{}:`skip`),[a,d]=(0,X.useState)(null);(0,X.useEffect)(()=>{!t||!r||r.length===0||(!a||!r.some(e=>e.name===a))&&d(r[0].name)},[t,r,a]);let p=o(K.agents.listAgentsForInstance,t&&a?{instanceName:a}:`skip`),h=o(K.agents.listMyAgents,e!==void 0&&!t?{}:`skip`),v=(0,X.useMemo)(()=>{if(e!==void 0){if(t)return a===null||p===void 0?r!==void 0&&r.length===0?[]:void 0:p.agents.map(e=>({instanceName:a,agentId:e.agentId,label:`${e.emoji?`${e.emoji} `:``}${e.displayName??e.agentId}`}));if(h!==void 0)return h.map(e=>({instanceName:e.instanceName,agentId:e.agentId,label:`${e.emoji?`${e.emoji} `:``}${e.displayName??e.agentId}`}))}},[e,t,a,p,r,h]),[y,b]=(0,X.useState)(null);(0,X.useEffect)(()=>{!v||v.length===0||(!y||!v.some(e=>$(e)===y))&&b($(v[0]))},[v,y]);let x=v?.find(e=>$(e)===y)??null,C=D(K.agentFiles.listAgentFiles),[w,T]=(0,X.useState)({status:`idle`}),E=x?.instanceName??null,O=x?.agentId??null,ee=o(K.compat.forInstance,n&&E!==null?{instanceName:E}:`skip`),k=n&&E!==null?ze(ee,`agentFiles`):null,A=k===null?!1:k===`loading`?null:k.blocked,j=(0,X.useCallback)(async()=>{if(!(E===null||O===null)){T({status:`loading`});try{T({status:`done`,files:(await C({instanceName:E,agentId:O})).files})}catch(e){T({status:`error`,dashboardAbsent:tt(e)})}}},[C,E,O]);(0,X.useEffect)(()=>{A===!1&&j()},[j,A]);let[M,N]=(0,X.useState)(null),F=o(K.agentFileCuration.listCurations,t&&E!==null&&O!==null?{instanceName:E,agentId:O}:`skip`),I=o(K.agentFileCuration.curationSettings,t&&E!==null?{instanceName:E}:`skip`),R=D(K.agentFileCuration.requestCuration),[te,z]=(0,X.useState)(null),[B,V]=(0,X.useState)(null),{toast:H}=Y(),ie=(0,X.useMemo)(()=>{let e=new Map;for(let t of F??[])e.has(t.name)||e.set(t.name,t);return e},[F]),ae=(0,X.useCallback)(async e=>{if(!(E===null||O===null)){z(e);try{let t=await R({instanceName:E,agentId:O,name:e,trigger:`manual`});t.ok?H({title:oe(),variant:`success`}):H({title:le({reason:t.reason??`unknown`}),variant:`error`})}catch{H({title:P(),variant:`error`})}finally{z(null)}}},[R,E,O,H]),U=L(),W=(0,X.useMemo)(()=>new Intl.NumberFormat(U,{maximumFractionDigits:0}),[U]);return e===void 0||v===void 0?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:G()}):(0,Q.jsxs)(`div`,{className:`oc-afiles`,children:[(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:u()}),(0,Q.jsxs)(`div`,{className:`oc-afiles__picker`,children:[t&&(r?.length??0)>1?(0,Q.jsxs)(Ve,{value:a??``,onValueChange:e=>d(e),children:[(0,Q.jsx)(Ue,{size:`sm`,"aria-label":_(),children:(0,Q.jsx)(je,{})}),(0,Q.jsx)(We,{children:(r??[]).map(e=>(0,Q.jsx)(Ie,{value:e.name,children:e.name},e.name))})]}):null,v.length>0?(0,Q.jsxs)(Ve,{value:y??``,onValueChange:e=>b(e),children:[(0,Q.jsx)(Ue,{size:`sm`,"aria-label":m(),children:(0,Q.jsx)(je,{})}),(0,Q.jsx)(We,{children:v.map(e=>(0,Q.jsx)(Ie,{value:$(e),children:e.label},$(e)))})]}):(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:f()})]}),x===null?null:k===`loading`?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:G()}):k!==null&&k.blocked?(0,Q.jsxs)(`p`,{className:`oc-compat__blocked`,role:`status`,children:[(0,Q.jsx)(Re,{size:14,"aria-hidden":!0}),` `,qe(k.gatewayVersion,k.provider)]}):w.status===`loading`||w.status===`idle`?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:G()}):w.status===`error`?(0,Q.jsxs)(`p`,{className:`oc-afiles__error`,role:`alert`,children:[w.dashboardAbsent?pe():i(),` `,!w.dashboardAbsent&&(0,Q.jsx)(J,{variant:`outline`,size:`sm`,onClick:()=>void j(),children:Se()})]}):w.files.length===0?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:ne()}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`oc-afiles__list`,children:w.files.map(e=>{let n=Xe(e.size),r=n>=80;return(0,Q.jsxs)(`div`,{className:`oc-afiles__row`,children:[(0,Q.jsx)(`span`,{className:`oc-afiles__name`,title:e.name,children:e.name}),e.missing?(0,Q.jsx)(Oe,{variant:`outline`,children:re()}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`oc-afiles__size`,children:g({size:Z(e.size,U)})}),(0,Q.jsx)(`span`,{className:`oc-afiles__gauge${r?` is-warn`:``}`,"aria-hidden":!0,children:(0,Q.jsx)(`span`,{className:`oc-afiles__gauge-fill`,style:{width:`${Math.min(n,100)}%`}})}),(0,Q.jsx)(`span`,{className:`oc-afiles__pct`,children:c({pct:W.format(n)})}),r?(0,Q.jsx)(Re,{size:14,className:`oc-afiles__warn`,"aria-label":l()}):(0,Q.jsx)(`span`,{className:`oc-afiles__warn-slot`,"aria-hidden":!0})]}),(0,Q.jsx)(J,{variant:`outline`,size:`sm`,className:`oc-afiles__open`,onClick:()=>N(e),children:t?ye():s()}),t&&!e.missing?(0,Q.jsx)(it,{curatable:Ke.includes(e.name),size:e.size??0,budget:I?.budgetChars??null,enabled:I?.enabled??!1,curation:ie.get(e.name)??null,inFlight:te===e.name,onCurate:()=>void ae(e.name),onReview:e=>V(e)}):null]},e.name)})}),(0,Q.jsx)(`p`,{className:`oc-afiles__budget`,children:S({used:Z(Qe(w.files),U),total:Z(Ye,U),pct:W.format(Ze(Qe(w.files)))})})]}),M&&x?(0,Q.jsx)(at,{instanceName:x.instanceName,agentId:x.agentId,name:M.name,isAdmin:t,onClose:()=>N(null),onSaved:()=>void j()}):null,B?(0,Q.jsx)(ot,{curationId:B,onClose:()=>V(null),onApplied:()=>{V(null),j()}}):null]})}function it({curatable:e,size:t,budget:n,enabled:r,curation:i,inFlight:a,onCurate:o,onReview:s}){return i?.status===`proposed`?(0,Q.jsx)(J,{variant:`default`,size:`sm`,className:`oc-afiles__curate`,onClick:()=>s(i._id),children:I()}):a||i?.status===`dispatched`||i?.status===`applying`?(0,Q.jsx)(Oe,{variant:`outline`,className:`oc-afiles__curate-status`,children:te()}):e&&r&&n!==null&&Ge(t,n)?(0,Q.jsx)(J,{variant:`outline`,size:`sm`,className:`oc-afiles__curate`,onClick:o,children:T()}):null}function at({instanceName:e,agentId:t,name:n,isAdmin:r,onClose:i,onSaved:a}){let o=D(K.agentFiles.getAgentFile),s=D(K.agentFiles.setAgentFile),c=Y(),[l,u]=(0,X.useState)(null),[d,f]=(0,X.useState)(!1),[p,m]=(0,X.useState)(``),[h,g]=(0,X.useState)(!1),[_,v]=(0,X.useState)(!1),[y,b]=(0,X.useState)(!1),[S,C]=(0,X.useState)(!1),T=(0,X.useCallback)(async r=>{f(!1);try{let i=await o({instanceName:e,agentId:t,name:n});u({content:i.content,updatedAtMs:i.updatedAtMs}),r||m(i.content),b(!1)}catch{f(!0)}},[o,e,t,n]);(0,X.useEffect)(()=>{T(!1)},[T]);async function E(){if(l!==null){v(!0),C(!1);try{await s({instanceName:e,agentId:t,name:n,content:p,baseUpdatedAtMs:l.updatedAtMs??void 0}),c.success(F({name:n})),a(),await T(!1)}catch(e){nt(e)?b(!0):C(!0)}finally{v(!1)}}}let k=l!==null&&p!==l.content,j=(0,X.useMemo)(()=>l===null?null:et(l.content,p),[l,p]),M=p.length>Je,P=L(),I=(0,X.useMemo)(()=>new Intl.NumberFormat(P),[P]);return(0,Q.jsx)(we,{open:!0,onOpenChange:e=>!e&&i(),children:(0,Q.jsxs)(He,{className:`oc-afiles__editor`,children:[(0,Q.jsxs)(Te,{children:[(0,Q.jsx)(Ae,{children:x({name:n})}),(0,Q.jsxs)(Me,{children:[be({agent:t,instance:e}),r?null:(0,Q.jsxs)(Q.Fragment,{children:[` · `,O()]})]})]}),d?(0,Q.jsxs)(`p`,{className:`oc-afiles__error`,role:`alert`,children:[ae(),` `,(0,Q.jsx)(J,{variant:`outline`,size:`sm`,onClick:()=>void T(!1),children:Se()})]}):l===null?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:G()}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`textarea`,{className:`oc-afiles__source`,value:p,readOnly:!r,spellCheck:!1,onChange:e=>m(e.target.value),"aria-label":x({name:n})}),(0,Q.jsx)(`p`,{className:`oc-afiles__hint`,children:xe()}),y?(0,Q.jsxs)(`p`,{className:`oc-afiles__error`,role:`alert`,children:[ce(),` `,(0,Q.jsx)(J,{variant:`outline`,size:`sm`,onClick:()=>void T(!0),children:N()})]}):null,S?(0,Q.jsx)(`p`,{className:`oc-afiles__error`,role:`alert`,children:R()}):null,(0,Q.jsxs)(`div`,{className:`oc-afiles__editor-foot`,children:[(0,Q.jsx)(`span`,{className:`oc-afiles__count${M?` is-over`:``}`,children:_e({count:I.format(p.length),max:I.format(Je)})}),r?(0,Q.jsx)(J,{size:`sm`,disabled:!k||_||y,onClick:()=>g(!0),children:_?q():w()}):null]})]}),(0,Q.jsx)(Ce,{open:h,onOpenChange:g,children:(0,Q.jsxs)(Ne,{children:[(0,Q.jsxs)(ke,{children:[(0,Q.jsx)(Be,{children:A({name:n})}),(0,Q.jsx)(Fe,{children:he({agent:t})})]}),j?(0,Q.jsxs)(`div`,{className:`oc-afiles__diff`,children:[(0,Q.jsx)(`p`,{className:`oc-afiles__diff-counts`,children:H({added:j.added,removed:j.removed})}),j.sampleAdded.length>0?(0,Q.jsxs)(`div`,{className:`oc-afiles__diff-block`,children:[(0,Q.jsx)(`span`,{className:`oc-afiles__diff-label`,children:ee()}),j.sampleAdded.map((e,t)=>(0,Q.jsx)(`code`,{className:`oc-afiles__diff-line is-add`,children:e||` `},t))]}):null,j.sampleRemoved.length>0?(0,Q.jsxs)(`div`,{className:`oc-afiles__diff-block`,children:[(0,Q.jsx)(`span`,{className:`oc-afiles__diff-label`,children:de()}),j.sampleRemoved.map((e,t)=>(0,Q.jsx)(`code`,{className:`oc-afiles__diff-line is-del`,children:e||` `},t))]}):null]}):null,(0,Q.jsxs)(Ee,{children:[(0,Q.jsx)(De,{children:ve()}),(0,Q.jsx)(Pe,{onClick:()=>void E(),children:W()})]})]})})]})})}function ot({curationId:e,onClose:t,onApplied:n}){let i=o(K.agentFileCuration.getProposal,{curationId:e}),s=D(K.agentFileCuration.approveCuration),c=b(K.agentFileCuration.rejectCuration),{toast:l}=Y(),[u,f]=(0,X.useState)(null),[m,g]=(0,X.useState)(!1),[_,x]=(0,X.useState)(``),S=L(),w=(0,X.useMemo)(()=>i?et(i.beforeContent,i.proposedContent):null,[i]);async function T(){f(`approve`);try{let t=await s({curationId:e});t.ok?(l({title:j(),variant:`success`}),n()):l({title:t.reason===`conflict`?ie():k({reason:t.reason??`unknown`}),variant:`error`})}catch{l({title:P(),variant:`error`})}finally{f(null)}}async function O(n){f(`reject`);try{let r=_.trim();(await c({curationId:e,...r?{comment:r}:{},relaunch:n})).ok?l({title:n?a():ge(),variant:`success`}):l({title:E(),variant:`error`}),t()}catch{l({title:P(),variant:`error`})}finally{f(null)}}return(0,Q.jsx)(we,{open:!0,onOpenChange:e=>e?void 0:t(),children:(0,Q.jsxs)(He,{className:`oc-afiles__review`,children:[(0,Q.jsxs)(Te,{children:[(0,Q.jsx)(Ae,{children:i?fe({name:i.name}):G()}),(0,Q.jsx)(Me,{children:se()})]}),i===void 0?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:G()}):i===null?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:E()}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`p`,{className:`oc-afiles__review-sizes`,children:[z({before:Z(i.beforeSize,S),after:Z(i.proposedSize,S)}),i.overBudget?(0,Q.jsxs)(Q.Fragment,{children:[` `,(0,Q.jsx)(Re,{size:13,"aria-hidden":!0}),` `,ue()]}):null]}),w?(0,Q.jsx)(`p`,{className:`oc-afiles__review-diff`,children:U({added:w.added,removed:w.removed})}):null,i.feedback?(0,Q.jsx)(`p`,{className:`oc-afiles__review-feedback`,children:V({feedback:i.feedback})}):null,w&&w.sampleRemoved.length>0?(0,Q.jsxs)(`div`,{className:`oc-afiles__review-removed`,children:[(0,Q.jsx)(`p`,{className:`oc-afiles__review-label`,children:C()}),(0,Q.jsx)(`ul`,{children:w.sampleRemoved.map((e,t)=>(0,Q.jsx)(`li`,{children:e||`\xA0`},t))})]}):null,(0,Q.jsxs)(`div`,{className:`oc-afiles__review-panes oc-afiles__review-panes--2`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`oc-afiles__review-label`,children:y()}),(0,Q.jsx)(`pre`,{className:`oc-afiles__review-pre`,children:i.beforeContent})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`oc-afiles__review-label`,children:me()}),(0,Q.jsx)(`pre`,{className:`oc-afiles__review-pre`,children:i.proposedContent})]})]})]}),m?(0,Q.jsxs)(`div`,{className:`oc-afiles__reject-form`,children:[(0,Q.jsx)(`label`,{className:`oc-afiles__review-label`,htmlFor:`curation-reject-comment`,children:d()}),(0,Q.jsx)(`textarea`,{id:`curation-reject-comment`,className:`oc-afiles__reject-textarea`,rows:3,placeholder:v(),value:_,onChange:e=>x(e.target.value)}),(0,Q.jsxs)(`div`,{className:`oc-afiles__review-actions`,children:[(0,Q.jsx)(J,{variant:`ghost`,onClick:()=>g(!1),disabled:u!==null,children:h()}),(0,Q.jsx)(J,{variant:`outline`,onClick:()=>void O(!1),disabled:u!==null,children:u===`reject`?q():p()}),(0,Q.jsx)(J,{variant:`default`,onClick:()=>void O(!0),disabled:u!==null,children:u===`reject`?q():B()})]})]}):(0,Q.jsxs)(`div`,{className:`oc-afiles__review-actions`,children:[(0,Q.jsx)(J,{variant:`outline`,onClick:()=>g(!0),disabled:u!==null||i==null,children:M()}),(0,Q.jsx)(J,{variant:`default`,onClick:()=>void T(),disabled:u!==null||i==null,children:u===`approve`?q():r()})]})]})})}export{rt as AgentFilesTab};
@@ -1 +0,0 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$j as r,Aj as i,Bj as ee,CY as a,Dj as o,Fj as te,Gj as ne,Hj as re,Ij as s,Jj as c,Kj as l,Lj as ie,Mj as u,Nj as d,Oj as f,Pj as p,Qj as ae,Rj as oe,SM as m,SY as se,Uj as ce,Vj as le,Wj as ue,Xj as de,Yj as fe,Zj as pe,_M as me,aM as h,bM as g,cM as he,dM as ge,eM as _e,fM as ve,gM as ye,hM as be,iM as xe,jj as _,kj as v,lM as Se,mM as y,nM as b,oM as x,pM as S,qj as C,rM as w,sM as T,t as E,tM as D,uM as O,vM as k,xM as A,yM as j,zj as Ce}from"./api-IF2KQFNF.js";import{At as M,Ct as N,Dt as P,Jt as F,Ot as I,St as L,Yt as we,bt as R,ct as Te,dr as z,fr as Ee,ft as De,i as Oe,o as ke,vt as B,wt as V,xt as H,yt as U}from"./index-DaLXKABQ.js";import{n as Ae}from"./TimeRangePicker-BqClp5BN.js";import{t as je}from"./FilterBar-Bfu-khK5.js";import{t as Me}from"./DataTableShell-Dc3I5mkG.js";import{t as W}from"./dispatchErrorInfo-CO5iC4yd.js";var G=t(e(),1),K=n(),q=`__all__`,Ne=[{value:`open`},{value:`acknowledged`},{value:`resolved`}];function Pe(e){return e===`open`?m():e===`acknowledged`?A():g()}var Fe=[`info`,`warn`,`critical`],Ie=[`detector`,`agent`,`user`],Le={kind:`relative`,from:`now-30d`,to:`now`},Re=200,J=`all`;function Y(){let e=Ee({from:`/settings/anomalies`}),t=z({from:`/settings/anomalies`}),n=e.q??``,i=e.status===J?q:e.status,o=e.severity??q,u=e.kind??q,[d,f]=(0,G.useState)(q),p=Oe(e.from,e.to),{from:m,to:g}=Ae(p),_=e=>void t({search:t=>({...t,q:e||void 0}),replace:!0}),v=e=>void t({search:t=>({...t,status:e===q?J:e})}),A=e=>void t({search:t=>({...t,severity:e===q?void 0:e})}),N=e=>void t({search:t=>({...t,kind:e===q?void 0:e})}),P=e=>void t({search:t=>({...t,...ke(e)})}),I=Te(),V=we(),W=se(E.anomalies.resolveAnomaly),Y=(a(E.me.getMe,{host:De})?.permissions??[]).includes(`admin.manage`),X=a(E.anomalies.listAnomalies,{limit:Re,filter:{q:n||void 0,from:m,to:g,anomalyStatus:i===q?void 0:i,severity:o===q?void 0:o,source:d===q?void 0:d,kind:u===q?void 0:u}}),Z=(0,G.useMemo)(()=>{let e=new Set;for(let t of X??[])e.add(t.kind);return[...e].sort()},[X]),Q=n!==``||i!==`open`||o!==q||d!==q||u!==q||p.kind!==`relative`||p.from!==Le.from;function Ue(){f(q),t({search:{status:`open`},replace:!0})}async function We(e){if(await I({title:j(),description:(0,K.jsxs)(K.Fragment,{children:[k(),` `,(0,K.jsx)(`span`,{className:`font-mono`,children:e.kind}),` `,me(),` `,(0,K.jsx)(`strong`,{children:ye()}),`.`,` `,be()]}),confirmLabel:y()}))try{await W({anomalyId:e._id,status:`resolved`}),V.success(S(),e.kind)}catch(e){V.error(ve(),e)}}async function Ge(e){try{await W({anomalyId:e._id,status:`acknowledged`}),V.success(ge(),e.kind)}catch(e){V.error(O(),e)}}return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`p`,{className:`oc-admin__hint`,children:[Se(),` `,(0,K.jsx)(`strong`,{children:he()}),` `,T(),` `,(0,K.jsx)(`strong`,{children:x()}),` `,h(),` `,(0,K.jsx)(`strong`,{children:xe()}),` `,w(),` `,(0,K.jsx)(`span`,{className:`oc-filter__window`,children:b()})]}),(0,K.jsxs)(je,{q:n,onQChange:_,searchPlaceholder:D(),timeRange:p,onTimeRangeChange:P,onReset:Ue,canReset:Q,children:[(0,K.jsxs)(B,{value:i,onValueChange:v,children:[(0,K.jsx)(H,{size:`sm`,className:`w-36`,children:(0,K.jsx)(L,{})}),(0,K.jsxs)(U,{children:[(0,K.jsx)(R,{value:q,children:_e()}),Ne.map(e=>(0,K.jsx)(R,{value:e.value,children:Pe(e.value)},e.value))]})]}),(0,K.jsxs)(B,{value:o,onValueChange:A,children:[(0,K.jsx)(H,{size:`sm`,className:`w-36`,children:(0,K.jsx)(L,{placeholder:r()})}),(0,K.jsxs)(U,{children:[(0,K.jsx)(R,{value:q,children:fe()}),Fe.map(e=>(0,K.jsx)(R,{value:e,children:e},e))]})]}),(0,K.jsxs)(B,{value:d,onValueChange:f,children:[(0,K.jsx)(H,{size:`sm`,className:`w-32`,children:(0,K.jsx)(L,{placeholder:c()})}),(0,K.jsxs)(U,{children:[(0,K.jsx)(R,{value:q,children:C()}),Ie.map(e=>(0,K.jsx)(R,{value:e,children:e},e))]})]}),(0,K.jsxs)(B,{value:u,onValueChange:N,children:[(0,K.jsx)(H,{size:`sm`,className:`w-36`,children:(0,K.jsx)(L,{placeholder:l()})}),(0,K.jsxs)(U,{children:[(0,K.jsx)(R,{value:q,children:ne()}),Z.map(e=>(0,K.jsx)(R,{value:e,children:e},e))]})]})]}),(0,K.jsx)(Me,{title:ue(),rows:X,emptyHint:i===`open`?ce():re(),rowActions:e=>Y&&e.status===`open`?[{label:le(),onSelect:()=>void We(e)},{label:ee(),onSelect:()=>void Ge(e)}]:[],columns:[{header:Ce(),cell:e=>(0,K.jsx)(`span`,{className:`oc-traces__time`,children:M(e.at)}),sort:e=>e.at},{header:l(),cell:e=>(0,K.jsx)(`code`,{className:`oc-traces__mono`,children:e.kind}),sort:e=>e.kind},{header:ae(),cell:e=>e.occurrenceCount!==null&&e.occurrenceCount>1?(0,K.jsx)(`span`,{className:`oc-traces__time`,title:e.firstAt===null?void 0:de({when:M(e.firstAt)}),children:pe({count:String(e.occurrenceCount)})}):(0,K.jsx)(`span`,{className:`oc-traces__time`,children:`—`}),sort:e=>e.occurrenceCount??0},{header:r(),cell:e=>(0,K.jsx)(Be,{severity:e.severity}),sort:e=>e.severity===`critical`?2:+(e.severity===`warn`)},{header:oe(),cell:e=>(0,K.jsx)(Ve,{status:e.status}),sort:e=>e.status===`resolved`?2:+(e.status===`acknowledged`)},{header:c(),cell:e=>(0,K.jsx)(F,{variant:`outline`,children:e.source}),sort:e=>e.source},{header:ie(),cell:e=>(0,K.jsxs)(`div`,{className:`oc-anomaly__msgcell`,children:[(0,K.jsx)(`span`,{className:`oc-anomaly__msg`,children:e.message}),(0,K.jsx)(ze,{row:e})]}),sort:e=>e.message},{header:s(),cell:e=>(0,K.jsx)($,{row:e}),sort:e=>e.evidence??null},{header:te(),cell:e=>e.correlationId?(0,K.jsx)(`code`,{className:`oc-traces__mono`,children:He(e.correlationId)}):(0,K.jsx)(`span`,{className:`oc-traces__muted`,children:`—`}),sort:e=>e.correlationId}]})]})}var X=new Set([`openclaw.dispatch_failures`,`assistant.announce_errors`]);function Z(e){if(!X.has(e.kind)||!e.evidence)return{};try{let t=JSON.parse(e.evidence);return{dominantCode:t.dominantCode,sampleCorrelationId:t.sampleCorrelationId}}catch{return{}}}function Q(e){if(e.kind!==`subagent.failure`||!e.evidence)return{};try{let t=JSON.parse(e.evidence);return{failedCount:t.failedCount,totalCount:t.totalCount,errorCategories:t.errorCategories}}catch{return{}}}function $({row:e}){let t=z();if(e.kind===`subagent.failure`){let n=Q(e);return(0,K.jsxs)(`div`,{className:`oc-anomaly__cause`,children:[(0,K.jsx)(`div`,{className:`oc-anomaly__cause-head`,children:[...new Set(n.errorCategories??[])].map(e=>(0,K.jsx)(`code`,{className:`oc-traces__mono`,children:e},e))}),e.correlationId?(0,K.jsxs)(`button`,{type:`button`,className:`oc-anomaly__drill`,onClick:()=>void t({to:`/settings/traces`,search:{q:e.correlationId,limit:100}}),children:[`↗ `,p()]}):null]})}let n=Z(e);if(!n.dominantCode){let e=n.sampleCorrelationId;return e?(0,K.jsx)(`div`,{className:`oc-anomaly__cause`,children:(0,K.jsxs)(`button`,{type:`button`,className:`oc-anomaly__drill`,onClick:()=>void t({to:`/settings/traces`,search:{correlationId:e,limit:100}}),children:[`↗ `,p()]})}):(0,K.jsx)(`span`,{className:`oc-traces__muted`,children:`—`})}let r=W(n.dominantCode),i=n.sampleCorrelationId;return(0,K.jsxs)(`div`,{className:`oc-anomaly__cause`,children:[(0,K.jsxs)(`div`,{className:`oc-anomaly__cause-head`,children:[(0,K.jsx)(`span`,{className:`oc-anomaly__cause-label`,children:r.label}),(0,K.jsx)(`code`,{className:`oc-traces__mono`,children:n.dominantCode})]}),(0,K.jsx)(`p`,{className:`oc-anomaly__cause-hint`,children:r.hint}),i?(0,K.jsxs)(`button`,{type:`button`,className:`oc-anomaly__drill`,onClick:()=>void t({to:`/settings/traces`,search:{correlationId:i,limit:100}}),children:[`↗ `,p()]}):null]})}function ze({row:e}){let[t,n]=(0,G.useState)(!1),r=a(E.anomalies.getAnomalyAttachments,t?{anomalyId:e._id}:`skip`);return!e.attachments||e.attachments.length===0?null:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`button`,{type:`button`,className:`oc-anomaly__drill`,onClick:()=>n(!0),children:[d(),e.attachments.length>1?` (${e.attachments.length})`:``]}),(0,K.jsx)(N,{open:t,onOpenChange:n,children:(0,K.jsxs)(V,{className:`oc-anomaly__attachments-dialog`,children:[(0,K.jsx)(P,{children:(0,K.jsx)(I,{children:u()})}),r===void 0?(0,K.jsx)(`p`,{className:`oc-traces__muted`,children:_()}):r.length===0?(0,K.jsx)(`p`,{className:`oc-traces__muted`,children:i()}):(0,K.jsx)(`div`,{className:`oc-anomaly__attachments`,children:r.map(e=>(0,K.jsxs)(`section`,{className:`oc-anomaly__attachment`,children:[(0,K.jsx)(`h4`,{className:`oc-anomaly__attachment-name`,children:(0,K.jsx)(`code`,{className:`oc-traces__mono`,children:e.name})}),(0,K.jsx)(`pre`,{className:`oc-anomaly__attachment-content`,children:e.content})]},e.name))})]})})]})}function Be({severity:e}){return(0,K.jsx)(`span`,{className:`oc-anomaly__sev oc-anomaly__sev--${e}`,children:e})}function Ve({status:e}){return e===`open`?(0,K.jsx)(F,{variant:`destructive`,children:v()}):e===`acknowledged`?(0,K.jsx)(F,{variant:`secondary`,children:f()}):(0,K.jsx)(F,{variant:`outline`,children:o()})}function He(e){return e.length>8?e.slice(0,8):e}export{Y as AnomaliesTab};
@@ -1 +0,0 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{Au as r,CN as i,CY as a,DN as o,Du as s,EN as c,Eu as l,ON as u,Ou as d,SN as f,TN as p,_N as m,bN as h,gN as g,hN as _,ju as v,ku as y,mN as b,t as x,vN as S,wN as C,xN as w,yN as T}from"./api-IF2KQFNF.js";import{At as E,St as D,a as O,bt as k,dr as A,fr as j,i as M,n as N,o as P,s as F,vt as I,xt as L,yt as R}from"./index-DaLXKABQ.js";import{n as ee}from"./TimeRangePicker-BqClp5BN.js";import{t as z}from"./FilterBar-Bfu-khK5.js";import{t as B}from"./AdvancedFilter-DWYTua7e.js";import{t as V}from"./DataTableShell-Dc3I5mkG.js";var H=t(e(),1),U=n(),W={kind:`relative`,from:N,to:`now`},G=`__all__`,K=[{value:`action`,label:v()},{value:`realLabel`,label:r()},{value:`targetLabel`,label:y()},{value:`impersonated`,label:d()},{value:`resource`,label:s()},{value:`resourceId`,label:l()}];function q(){let e=j({from:`/settings/audit`}),t=A({from:`/settings/audit`}),n=e.q??``,r=e.action??G,s=e.impersonated??G,l=e.resource??G,d=M(e.from,e.to),v=(0,H.useMemo)(()=>F(e.adv),[e.adv]),{from:y,to:N}=ee(d),q=e=>void t({search:t=>({...t,q:e||void 0}),replace:!0}),J=e=>void t({search:t=>({...t,action:e===G?void 0:e})}),Y=e=>void t({search:t=>({...t,impersonated:e===G?void 0:e})}),X=e=>void t({search:t=>({...t,resource:e===G?void 0:e})}),Z=e=>void t({search:t=>({...t,...P(e)})}),Q=e=>void t({search:t=>({...t,adv:O(e)}),replace:!0}),$=a(x.admin.listAudit,{filter:{q:n||void 0,from:y,to:N,action:r===G?void 0:r,resource:l===G?void 0:l,impersonated:s===G?void 0:s===`yes`,advanced:v.length>0?v:void 0}}),te=(0,H.useMemo)(()=>{let e=new Set;for(let t of $??[])e.add(t.action);return[...e].sort()},[$]),ne=(0,H.useMemo)(()=>{let e=new Set;for(let t of $??[])t.resource&&e.add(t.resource);return[...e].sort()},[$]),re=n!==``||r!==G||s!==G||l!==G||v.length>0||d.kind!==`relative`||d.from!==W.from;function ie(){t({search:{},replace:!0})}return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`p`,{className:`oc-admin__hint`,children:[u(),` `,(0,U.jsx)(`span`,{className:`oc-filter__window`,children:o()})]}),(0,U.jsxs)(z,{q:n,onQChange:q,searchPlaceholder:c(),timeRange:d,onTimeRangeChange:Z,onReset:ie,canReset:re,children:[(0,U.jsxs)(I,{value:r,onValueChange:J,children:[(0,U.jsx)(L,{size:`sm`,className:`w-40`,children:(0,U.jsx)(D,{placeholder:p()})}),(0,U.jsxs)(R,{children:[(0,U.jsx)(k,{value:G,children:C()}),te.map(e=>(0,U.jsx)(k,{value:e,children:e},e))]})]}),(0,U.jsxs)(I,{value:s,onValueChange:Y,children:[(0,U.jsx)(L,{size:`sm`,className:`w-40`,children:(0,U.jsx)(D,{})}),(0,U.jsxs)(R,{children:[(0,U.jsx)(k,{value:G,children:i()}),(0,U.jsx)(k,{value:`yes`,children:f()}),(0,U.jsx)(k,{value:`no`,children:w()})]})]}),(0,U.jsxs)(I,{value:l,onValueChange:X,children:[(0,U.jsx)(L,{size:`sm`,className:`w-40`,children:(0,U.jsx)(D,{placeholder:h()})}),(0,U.jsxs)(R,{children:[(0,U.jsx)(k,{value:G,children:T()}),ne.map(e=>(0,U.jsx)(k,{value:e,children:e},e))]})]})]}),(0,U.jsx)(B,{fields:K,seed:v,onChange:Q}),(0,U.jsx)(V,{title:S(),rows:$,emptyHint:m(),columns:[{header:g(),cell:e=>E(e.at),sort:e=>e.at},{header:p(),cell:e=>e.action,sort:e=>e.action},{header:_(),cell:e=>e.realLabel,sort:e=>e.realLabel},{header:b(),cell:e=>e.targetLabel??`—`,sort:e=>e.targetLabel??null},{header:h(),cell:e=>e.resource?e.resource+(e.resourceId?` · ${e.resourceId.slice(0,8)}`:``):`—`,sort:e=>e.resource??null}]})]})}export{q as AuditTab};
@@ -1 +0,0 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$D as r,AO as i,BO as a,Bg as o,CO as s,CY as c,Ck as l,DO as u,Dk as d,E as f,EO as p,Ek as m,FO as h,GO as ee,Gg as g,HO as te,Hg as _,IO as ne,JD as v,Jg as y,Jl as b,Kg as re,LO as ie,Lg as ae,MO as oe,Mg as se,NO as ce,OO as le,PO as ue,QD as de,RO as fe,Rg as pe,SO as x,SY as me,Sk as he,TO as ge,UO as _e,Ug as ve,VO as ye,Va as be,Vg as xe,WO as Se,Wg as S,XD as Ce,Xl as we,YD as Te,Yg as Ee,Yl as De,ZD as Oe,Zl as ke,_O as Ae,_k as je,aO as Me,bO as Ne,bY as Pe,bk as Fe,cO as Ie,cs as Le,dO as Re,eO as ze,eu as Be,fO as Ve,gO as He,hO as Ue,iO as We,jO as Ge,kO as Ke,lO as qe,mO as Je,mk as Ye,nO as Xe,oO as Ze,pO as Qe,pk as $e,qD as C,qg as et,ql as tt,rO as nt,sO as w,t as T,tO as rt,uO as it,vO as at,vk as ot,wO as st,wk as ct,xO as lt,xk as ut,yO as dt,yk as ft,zO as pt,zg as mt}from"./api-IF2KQFNF.js";import{r as E}from"./dist-821wRD_K.js";import{t as ht}from"./chevrons-up-down-8nG-pF3_.js";import{i as gt,n as D,o as _t,r as vt,s as yt}from"./FieldLabel-BVUMb8MI.js";import{t as O}from"./button-DDPt-po9.js";import{$t as k,At as bt,Ct as xt,Dt as St,Jn as Ct,Jt as A,L as wt,Mt as Tt,Ot as Et,Pn as Dt,St as j,Tt as Ot,Yt as kt,ar as M,at as At,bt as N,cn as jt,dr as P,fr as Mt,ft as Nt,it as Pt,jt as F,kn as I,on as Ft,or as It,ot as Lt,sn as Rt,sr as L,st as zt,vt as R,wt as Bt,xt as z,yt as B}from"./index-DaLXKABQ.js";import{r as Vt}from"./locales-CPjguROj.js";import{a as Ht,i as V,n as Ut,o as H,r as U,t as Wt}from"./table-CnU0GqDN.js";import{t as Gt}from"./FilterBar-Bfu-khK5.js";import{c as Kt,i as qt,n as Jt,o as Yt,r as Xt,s as Zt,t as Qt}from"./compatView-CVibrgBK.js";import{t as W}from"./dispatchErrorInfo-CO5iC4yd.js";var $t=f(`refresh-cw`,[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]),en=f(`wifi-off`,[[`path`,{d:`M12 20h.01`,key:`zekei9`}],[`path`,{d:`M8.5 16.429a5 5 0 0 1 7 0`,key:`1bycff`}],[`path`,{d:`M5 12.859a10 10 0 0 1 5.17-2.69`,key:`1dl1wf`}],[`path`,{d:`M19 12.859a10 10 0 0 0-2.007-1.523`,key:`4k23kn`}],[`path`,{d:`M2 8.82a15 15 0 0 1 4.177-2.643`,key:`1grhjp`}],[`path`,{d:`M22 8.82a15 15 0 0 0-11.288-3.764`,key:`z3jwby`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),G=t(e(),1);function K(e){return e.filter(e=>e.state===`error`)}function tn(e){return e.reachable&&K(e.targets).length===0}function nn(e){return tn(e)?(e.unreachableInstances??[]).length>0?`gateways_unreachable`:`ok`:`error`}function rn(e){return e.state===`error`&&e.lastErrorCode!==null}function an(e){return!!e.lastDownstreamRejectCode}function on(e){return!!e.lastLocalRefusalCode}function sn(e){return rn(e)||an(e)||on(e)}function q(e){return e.kind??`openclaw`}function cn(e){return[...e].sort((e,t)=>e===`openclaw`?-1:t===`openclaw`?1:e.localeCompare(t))}function ln(e,t,n){let r=new Map;for(let e of t)e.instanceName&&r.set(e.instanceName,e.provider);for(let e of n)r.set(e.name,q(e));let i=e=>(e.instanceName?r.get(e.instanceName):void 0)??`openclaw`,a=new Set;for(let e of n)a.add(q(e));for(let e of t)a.add(e.provider);for(let t of e)a.add(i(t));return cn(a).map(r=>({key:r,connections:e.filter(e=>i(e)===r),compatTargets:t.filter(e=>e.provider===r),instances:n.filter(e=>q(e)===r)}))}function J(e){return e===`openclaw`?`OpenClaw`:e===`hermes`?`Hermes`:e.charAt(0).toUpperCase()+e.slice(1)}var Y=`__all__`,un={q:``,state:Y,instance:Y,version:Y},X={connected:0,error:1,idle:2};function dn(e){return e.q.trim()!==``||e.state!==`__all__`||e.instance!==`__all__`||e.version!==`__all__`}function fn(e,t){let n=t.q.trim().toLowerCase();return e.filter(e=>!(n&&!`${e.targetLabel} ${e.gatewayHost}`.toLowerCase().includes(n)||t.state!==`__all__`&&e.state!==t.state||t.instance!==`__all__`&&(e.instanceName??``)!==t.instance||t.version!==`__all__`&&(e.gatewayVersion??``)!==t.version))}function Z(e,t){return e.localeCompare(t,void 0,{numeric:!0,sensitivity:`base`})}function pn(e,t){return e===`version`?t.gatewayVersion===null:e===`lastOk`?t.lastOkAt===null:!1}function mn(e,t,n){switch(e){case`state`:return(X[t.state]??99)-(X[n.state]??99);case`instance`:return Z(t.instanceLabel??t.instanceName??``,n.instanceLabel??n.instanceName??``);case`host`:return Z(t.gatewayHost,n.gatewayHost);case`version`:{let e=t.gatewayVersion,r=n.gatewayVersion;return Zt(e,r)??Z(e,r)}case`lastOk`:return t.lastOkAt-n.lastOkAt;default:return Z(t.targetLabel,n.targetLabel)}}function hn(e,t){if(!t)return e;let n=t.dir===`asc`?1:-1;return[...e].sort((e,r)=>{let i=pn(t.key,e),a=pn(t.key,r);return i&&a?0:i?1:a?-1:n*mn(t.key,e,r)})}function gn(e){let t=new Set;for(let n of e)t.add(n.state);return[...t].sort((e,t)=>(X[e]??99)-(X[t]??99))}function _n(e){let t=new Map;for(let n of e)n.instanceName!==null&&(t.has(n.instanceName)||t.set(n.instanceName,n.instanceLabel??n.instanceName));return[...t.entries()].map(([e,t])=>({name:e,label:t})).sort((e,t)=>Z(e.label,t.label))}function vn(e){let t=new Set;for(let n of e)n.gatewayVersion!==null&&t.add(n.gatewayVersion);return[...t].sort((e,t)=>Zt(e,t)??Z(e,t))}var Q=n();function yn({connections:e,displayByInstance:t}){let[n,i]=(0,G.useState)(un),[a,o]=(0,G.useState)(null),s=(0,G.useMemo)(()=>e.map((e,n)=>({_id:`${e.key}:${e.canonical}/${e.agentId}:${n}`,targetLabel:`${e.canonical}/${e.agentId}`,state:e.state,instanceName:e.instanceName??null,instanceLabel:e.instanceName?t.get(e.instanceName)??e.instanceName:null,gatewayHost:e.gatewayHost,gatewayVersion:e.gatewayVersion??null,okCount:e.okCount,errorCount:e.errorCount+(e.downstreamRejectCount??0)+(e.localRefusalCount??0),attempts:e.attempts,lastOkAt:e.lastOkAt??null,lastErrorCode:e.lastErrorCode??null,lastErrorAt:e.lastErrorAt??null,lastDownstreamRejectCode:e.lastDownstreamRejectCode??null,lastDownstreamRejectAt:e.lastDownstreamRejectAt??null,lastLocalRefusalCode:e.lastLocalRefusalCode??null,lastLocalRefusalAt:e.lastLocalRefusalAt??null})),[e,t]),c=(0,G.useMemo)(()=>gn(s),[s]),l=(0,G.useMemo)(()=>_n(s),[s]),u=(0,G.useMemo)(()=>vn(s),[s]),d=(0,G.useMemo)(()=>hn(fn(s,n),a),[s,n,a]);function f(e){o(t=>t?.key===e?t.dir===`asc`?{key:e,dir:`desc`}:null:{key:e,dir:`asc`})}return e.length===0?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:Re()}):(0,Q.jsxs)(`div`,{className:`oc-conn`,children:[(0,Q.jsxs)(Gt,{q:n.q,onQChange:e=>i(t=>({...t,q:e})),searchPlaceholder:Ie(),onReset:()=>i(un),canReset:dn(n),children:[(0,Q.jsxs)(R,{value:n.state,onValueChange:e=>i(t=>({...t,state:e})),children:[(0,Q.jsx)(z,{size:`sm`,className:`w-36`,children:(0,Q.jsx)(j,{placeholder:Ze()})}),(0,Q.jsxs)(B,{children:[(0,Q.jsx)(N,{value:Y,children:w()}),c.map(e=>(0,Q.jsx)(N,{value:e,children:xn(e)},e))]})]}),(0,Q.jsxs)(R,{value:n.instance,onValueChange:e=>i(t=>({...t,instance:e})),children:[(0,Q.jsx)(z,{size:`sm`,className:`w-40`,children:(0,Q.jsx)(j,{placeholder:Me()})}),(0,Q.jsxs)(B,{children:[(0,Q.jsx)(N,{value:Y,children:w()}),l.map(e=>(0,Q.jsx)(N,{value:e.name,children:e.label},e.name))]})]}),(0,Q.jsxs)(R,{value:n.version,onValueChange:e=>i(t=>({...t,version:e})),children:[(0,Q.jsx)(z,{size:`sm`,className:`w-36`,children:(0,Q.jsx)(j,{placeholder:We()})}),(0,Q.jsxs)(B,{children:[(0,Q.jsx)(N,{value:Y,children:w()}),u.map(e=>(0,Q.jsx)(N,{value:e,children:e},e))]})]})]}),d.length===0?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:nt()}):(0,Q.jsxs)(Wt,{className:`oc-conn__table`,children:[(0,Q.jsx)(Ht,{children:(0,Q.jsxs)(H,{children:[(0,Q.jsx)($,{label:Xe(),sortKey:`target`,sort:a,onSort:f}),(0,Q.jsx)($,{label:rt(),sortKey:`state`,sort:a,onSort:f}),(0,Q.jsx)($,{label:ze(),sortKey:`instance`,sort:a,onSort:f}),(0,Q.jsx)($,{label:r(),sortKey:`host`,sort:a,onSort:f}),(0,Q.jsx)($,{label:de(),sortKey:`version`,sort:a,onSort:f}),(0,Q.jsx)(V,{children:Oe()}),(0,Q.jsx)($,{label:Ce(),sortKey:`lastOk`,sort:a,onSort:f})]})}),(0,Q.jsx)(Ut,{children:d.map(e=>(0,Q.jsx)(bn,{r:e},e._id))})]})]})}function $({label:e,sortKey:t,sort:n,onSort:r}){let i=n?.key===t,a=i?n.dir:null;return(0,Q.jsx)(V,{"aria-sort":i?a===`asc`?`ascending`:`descending`:`none`,children:(0,Q.jsxs)(`button`,{type:`button`,className:`oc-conn__sort`,onClick:()=>r(t),children:[e,i?a===`asc`?(0,Q.jsx)(It,{size:13,"aria-hidden":!0}):(0,Q.jsx)(E,{size:13,"aria-hidden":!0}):(0,Q.jsx)(ht,{size:13,"aria-hidden":!0,className:`oc-conn__sort-idle`})]})})}function bn({r:e}){let t=rn(e)?W(e.lastErrorCode):null,n=an(e)?W(e.lastDownstreamRejectCode):null,r=on(e)?W(e.lastLocalRefusalCode):null;return(0,Q.jsxs)(G.Fragment,{children:[(0,Q.jsxs)(H,{className:`oc-conn__row oc-conn__row--${e.state}`,children:[(0,Q.jsx)(U,{children:(0,Q.jsx)(`code`,{className:`oc-traces__mono`,children:e.targetLabel})}),(0,Q.jsx)(U,{children:(0,Q.jsx)(Sn,{state:e.state})}),(0,Q.jsx)(U,{children:e.instanceLabel?(0,Q.jsx)(`span`,{className:`oc-bridge-target__instance`,children:e.instanceLabel}):(0,Q.jsx)(`span`,{className:`oc-traces__muted`,children:`—`})}),(0,Q.jsx)(U,{children:(0,Q.jsx)(`span`,{className:`oc-bridge-target__host`,children:e.gatewayHost})}),(0,Q.jsx)(U,{children:e.gatewayVersion?(0,Q.jsx)(`span`,{className:`oc-bridge-target__version`,children:e.gatewayVersion}):(0,Q.jsx)(`span`,{className:`oc-traces__muted`,children:`—`})}),(0,Q.jsx)(U,{children:(0,Q.jsx)(`span`,{className:`oc-conn__stats`,children:it({ok:e.okCount,errors:e.errorCount,attempts:e.attempts})})}),(0,Q.jsx)(U,{children:e.lastOkAt?(0,Q.jsx)(`span`,{className:`oc-traces__mono`,children:F(e.lastOkAt)}):(0,Q.jsx)(`span`,{className:`oc-traces__muted`,children:`—`})})]}),sn(e)?(0,Q.jsx)(H,{className:`oc-conn__detail-row`,children:(0,Q.jsxs)(U,{colSpan:7,className:`oc-conn__detail-cell`,children:[t?(0,Q.jsxs)(`div`,{className:`oc-bridge-target__error`,children:[(0,Q.jsx)(`strong`,{children:t.label}),` `,(0,Q.jsx)(`code`,{className:`oc-traces__mono`,children:e.lastErrorCode}),e.lastErrorAt?` · ${F(e.lastErrorAt)}`:``,(0,Q.jsx)(`p`,{className:`oc-bridge-card__hint`,children:t.hint})]}):null,r?(0,Q.jsxs)(`div`,{className:`oc-bridge-target__downstream`,children:[be({label:r.label}),` `,(0,Q.jsx)(`code`,{className:`oc-traces__mono`,children:e.lastLocalRefusalCode}),e.lastLocalRefusalAt?` · ${F(e.lastLocalRefusalAt)}`:``,(0,Q.jsx)(`p`,{className:`oc-bridge-card__hint`,children:r.hint})]}):null,n?(0,Q.jsxs)(`div`,{className:`oc-bridge-target__downstream`,children:[qe({label:n.label}),` `,(0,Q.jsx)(`code`,{className:`oc-traces__mono`,children:e.lastDownstreamRejectCode}),e.lastDownstreamRejectAt?` · ${F(e.lastDownstreamRejectAt)}`:``]}):null]})}):null]})}function xn(e){return e===`connected`?Te():e===`error`?v():C()}function Sn({state:e}){return e===`connected`?(0,Q.jsx)(A,{variant:`secondary`,children:Te()}):e===`error`?(0,Q.jsx)(A,{variant:`destructive`,children:v()}):(0,Q.jsx)(A,{variant:`outline`,children:C()})}function Cn(){return c(T.bridgeHealth.getBridgeHealth,{})}function wn(){let e=Cn(),t=c(T.compat.getBridgeCompat,{}),n=c(T.me.getMe,{host:Nt})?.role===`admin`,r=c(T.admin.listInstances,n?{}:`skip`),a=c(T.agents.usageForInstances,n?{}:`skip`),o=P(),s=()=>void o({to:`/settings/anomalies`,search:{status:`open`}}),l=ln(e?e.targets:[],t?t.targets:[],r??[]),{section:u}=Mt({from:`/settings/bridge`}),d=P({from:`/settings/bridge`}),f=t?.compat??null,p=t===void 0?`loading`:t===null?`nodata`:`ready`,m=f!==null&&Xt(f,`hermes`)&&!l.some(e=>e.key===`hermes`);return(0,Q.jsxs)(`div`,{className:`oc-bridge`,children:[(0,Q.jsx)(Tn,{health:e,compat:t,onSeeAnomalies:s}),(0,Q.jsx)(`p`,{className:`oc-admin__hint oc-bridge__caption`,children:Ge()}),a&&a.length>0?(0,Q.jsxs)(`section`,{className:`oc-bridge__usage`,children:[(0,Q.jsx)(`h3`,{className:`oc-bridge__usage-title`,children:i()}),(0,Q.jsxs)(Wt,{children:[(0,Q.jsx)(Ht,{children:(0,Q.jsxs)(H,{children:[(0,Q.jsx)(V,{children:ke()}),(0,Q.jsx)(V,{children:we()}),(0,Q.jsx)(V,{children:De()}),(0,Q.jsx)(V,{children:b()}),(0,Q.jsx)(V,{children:tt()})]})}),(0,Q.jsx)(Ut,{children:a.flatMap(e=>{let t=wt(e.usage,Date.now());return t?t.windows.map((t,n)=>(0,Q.jsxs)(H,{children:[(0,Q.jsx)(U,{className:`font-medium`,children:n===0?e.instanceName:``}),(0,Q.jsx)(U,{children:t.provider}),(0,Q.jsx)(U,{children:t.label}),(0,Q.jsx)(U,{children:(0,Q.jsxs)(A,{variant:t.percentLeft<=10?`destructive`:t.percentLeft<=25?`outline`:`secondary`,children:[t.percentLeft,`%`]})}),(0,Q.jsx)(U,{className:`text-muted-foreground`,children:t.resetText??`—`})]},`${e.instanceName}:${t.provider}:${t.label}`)):[]})})]})]}):null,l.length>0?(0,Q.jsxs)(Pt,{value:l.some(e=>e.key===u)?u:l[0]?.key??`openclaw`,onValueChange:e=>void d({search:{section:e},replace:!0}),children:[(0,Q.jsx)(Lt,{className:`w-full`,children:l.map(e=>(0,Q.jsxs)(zt,{value:e.key,className:`flex-1 gap-1.5`,children:[(0,Q.jsx)(Dt,{size:13,"aria-hidden":!0}),J(e.key)]},e.key))}),l.map(e=>(0,Q.jsx)(At,{value:e.key,children:(0,Q.jsx)(En,{providerKey:e.key,connections:e.connections,instances:e.instances,manifest:f,compatStatus:p,compatReachable:t?.reachable??!0,protocol:e.key===`openclaw`?t?.protocol??null:null})},e.key))]}):null,m?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:se()}):null]})}function Tn({health:e,compat:t,onSeeAnomalies:n}){let r=t!=null&&t.buildVersion!=null&&t.bridgeVersion!=null&&t.buildVersion!==t.bridgeVersion,i=t?.buildRevision&&t.buildRevision!==`unknown`?t.buildRevision.slice(0,7):null,a=t&&t!==null?(0,Q.jsxs)(`span`,{className:`oc-bridge-card__ver`,children:[(0,Q.jsx)(`code`,{className:`oc-traces__mono`,children:Yt(t.bridgeVersion)}),i?(0,Q.jsxs)(Q.Fragment,{children:[` `,(0,Q.jsxs)(`code`,{className:`oc-traces__mono`,title:et(),children:[`(`,i,`)`]})]}):null,r?(0,Q.jsxs)(`strong`,{className:`oc-bridge-card__mismatch`,children:[` `,re({build:t.buildVersion??`?`})]}):null,` · `,g(),` `,(0,Q.jsx)(`code`,{className:`oc-traces__mono`,children:t.protocolVersion===null?S():String(t.protocolVersion)})]}):null;if(e===void 0)return(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:x()});if(e===null)return(0,Q.jsx)(`div`,{className:`oc-bridge-card oc-bridge-card--idle`,children:lt()});let o=K(e.targets),s=!e.reachable,c=nn(e),l=e.unreachableInstances??[],u=c===`ok`?`ok`:c===`gateways_unreachable`?`warn`:`error`,d=bt(e.checkedAt),f=e.startedAt==null?null:bt(e.startedAt);return(0,Q.jsxs)(`div`,{className:`oc-bridge-card oc-bridge-card--${u}`,children:[(0,Q.jsx)(`div`,{className:`oc-bridge-card__icon`,"aria-hidden":!0,children:c===`ok`?(0,Q.jsx)(M,{size:22}):s||c===`gateways_unreachable`?(0,Q.jsx)(en,{size:22}):(0,Q.jsx)(I,{size:22})}),(0,Q.jsxs)(`div`,{className:`oc-bridge-card__body`,children:[(0,Q.jsx)(`div`,{className:`oc-bridge-card__title`,children:c===`ok`?Ne():c===`gateways_unreachable`?He({count:l.length}):s?dt():at({count:o.length})}),(0,Q.jsxs)(`div`,{className:`oc-bridge-card__meta`,children:[(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)($t,{size:12,"aria-hidden":!0}),` `,Ae({time:d})]}),f?(0,Q.jsx)(`span`,{children:Je({time:f})}):null,a]}),c===`gateways_unreachable`?(0,Q.jsx)(`p`,{className:`oc-bridge-card__hint`,children:Ue({names:l.join(`, `)})}):null,s?(0,Q.jsx)(`p`,{className:`oc-bridge-card__hint`,children:W(e.lastError===`not_configured`?`NOT_CONFIGURED`:`BRIDGE_UNREACHABLE`).hint}):null]}),(0,Q.jsx)(`button`,{type:`button`,className:`oc-bridgebar__drill`,onClick:n,children:Qe()})]})}function En({providerKey:e,connections:t,instances:n,manifest:r,compatStatus:i,compatReachable:a,protocol:o}){let s=r?Kt(r,e):null,c=new Map;for(let e of n)c.set(e.name,e.displayName??e.name);let l=[],u=new Set;for(let n of t){if(!n.instanceName||u.has(n.instanceName))continue;u.add(n.instanceName);let t=n.gatewayVersion??null;l.push({instanceName:n.instanceName,displayName:c.get(n.instanceName)??n.instanceName,version:t,state:Jt(t,e,r)})}let d=Qt(l.map(e=>e.state)),[f,p]=(0,G.useState)(!1);return(0,Q.jsxs)(`section`,{className:`oc-bridge-provider`,children:[(0,Q.jsxs)(`header`,{className:`oc-bridge-provider__head`,children:[(0,Q.jsx)(Dt,{size:15,"aria-hidden":!0,className:`oc-bridge-provider__icon`}),(0,Q.jsx)(`span`,{className:`oc-bridge-provider__name`,children:J(e)}),d?(0,Q.jsx)(A,{variant:d===`beyond`||d===`defective`?`destructive`:`secondary`,children:qt(d)}):null]}),(0,Q.jsx)(`h4`,{className:`oc-bridge-provider__sub`,children:Ee()}),(0,Q.jsx)(On,{providerName:J(e),support:s,compatStatus:i,compatReachable:a,manifest:r,instanceRows:l}),o?(0,Q.jsx)(Dn,{protocol:o}):null,(0,Q.jsxs)(`button`,{type:`button`,className:`oc-bridge-provider__sub oc-bridge-provider__sub--toggle`,"aria-expanded":f,onClick:()=>p(e=>!e),children:[f?(0,Q.jsx)(E,{size:13,"aria-hidden":!0}):(0,Q.jsx)(L,{size:13,"aria-hidden":!0}),Ve({count:t.length})]}),f?(0,Q.jsx)(yn,{connections:t,displayByInstance:c}):null]})}function Dn({protocol:e}){let[t,n]=(0,G.useState)(!1),r=e.coverage,i=e.drift??[],a=(e.driftOverflow??0)+(e.driftTruncated??0);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`h4`,{className:`oc-bridge-provider__sub`,children:[Ke(),i.length>0?(0,Q.jsx)(A,{variant:`destructive`,children:u({count:i.length})}):a>0?(0,Q.jsx)(A,{variant:`destructive`,children:p()}):(0,Q.jsx)(A,{variant:`secondary`,children:le()})]}),(0,Q.jsxs)(`p`,{className:`oc-admin__hint`,children:[ge({version:e.vendoredVersion}),r?` · `+st({handled:r.handled,ignored:r.ignored,gaps:r.gaps}):null]}),a>0?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:Le({overflow:e.driftOverflow??0,truncated:e.driftTruncated??0})}):null,i.length>0?(0,Q.jsx)(`ul`,{className:`oc-bridge-protocol__list`,role:`list`,children:i.map(e=>(0,Q.jsxs)(`li`,{children:[(0,Q.jsx)(`code`,{className:`oc-traces__mono`,children:e.shape}),` × `,e.count]},e.shape))}):null,r&&r.gapList.length>0?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`button`,{type:`button`,className:`oc-bridge-provider__sub oc-bridge-provider__sub--toggle`,"aria-expanded":t,onClick:()=>n(e=>!e),children:[t?(0,Q.jsx)(E,{size:13,"aria-hidden":!0}):(0,Q.jsx)(L,{size:13,"aria-hidden":!0}),s({count:r.gapList.length})]}),t?(0,Q.jsx)(`ul`,{className:`oc-bridge-protocol__list`,role:`list`,children:r.gapList.map(e=>(0,Q.jsx)(`li`,{children:(0,Q.jsx)(`code`,{className:`oc-traces__mono`,children:e})},e))}):null]}):null]})}function On({support:e,compatStatus:t,compatReachable:n,manifest:r,instanceRows:i,providerName:a}){return t===`loading`?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:x()}):t===`nodata`?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:y()}):(0,Q.jsxs)(`div`,{className:`oc-compat`,children:[n?null:(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:ve()}),r===null?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:_()}):(0,Q.jsxs)(`div`,{className:`oc-compat__support`,children:[(0,Q.jsx)(`span`,{className:`oc-compat__label`,children:Be({provider:a})}),e&&e.range!==null?(0,Q.jsx)(`span`,{children:xe({min:e.range.min,max:e.range.maxValidated})}):(0,Q.jsx)(`span`,{children:S()}),e?(0,Q.jsx)(Mn,{versions:e.validatedVersions}):null]}),i.length===0?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:ae()}):(0,Q.jsx)(`div`,{className:`oc-compat__targets`,children:i.map(e=>(0,Q.jsxs)(`div`,{className:`oc-compat__target`,children:[(0,Q.jsx)(`span`,{className:`oc-compat__instance`,children:e.displayName}),(0,Q.jsx)(`code`,{className:`oc-traces__mono`,children:Yt(e.version)}),(0,Q.jsx)(A,{variant:e.state===`supported`?`secondary`:e.state===`beyond`||e.state===`defective`?`destructive`:`outline`,children:qt(e.state)})]},e.instanceName))})]})}function kn({instance:e,onClose:t}){return(0,Q.jsx)(xt,{open:!0,onOpenChange:e=>!e&&t(),children:(0,Q.jsxs)(Bt,{className:`oc-bridge-config-dialog`,onOpenAutoFocus:e=>e.preventDefault(),children:[(0,Q.jsxs)(St,{children:[(0,Q.jsx)(Et,{children:d({instance:e.displayName??e.name})}),(0,Q.jsx)(Ot,{children:m()})]}),(0,Q.jsx)(jn,{instance:e,onClose:t})]})})}function An({label:e,result:t}){return t?t.checked?(0,Q.jsxs)(`p`,{className:`oc-bridge-config__check-row `+(t.ok?`oc-bridge-config__check-row--ok`:`oc-bridge-config__check-row--err`),children:[t.ok?(0,Q.jsx)(M,{"aria-hidden":!0}):(0,Q.jsx)(I,{"aria-hidden":!0}),(0,Q.jsxs)(`span`,{children:[e,` — `,t.ok?h():t.detail]})]}):(0,Q.jsxs)(`p`,{className:`oc-bridge-config__check-row oc-bridge-config__check-row--skip`,children:[e,` — `,ue()]}):null}function jn({instance:e,onClose:t}){let n=me(T.admin.upsertInstanceConfig),r=Pe(T.bridge.validateMediaPaths),i=kt(),o=Vt(e.config?.contentLocale,void 0),[s,c]=(0,G.useState)(()=>gt(e.config??{},o)),[u,d]=(0,G.useState)(!1),[f,p]=(0,G.useState)(!1),[m,h]=(0,G.useState)(null),g=s.inboundMediaMode===`shared-fs`,_=s.mediaMode===`shared-fs`,v=g||_;async function y(){p(!0),h(null);try{h(await r({instanceName:e.name,inboundMediaMode:s.inboundMediaMode,mediaMode:s.mediaMode}))}catch(e){i.error(pt(),e)}finally{p(!1)}}async function b(){d(!0);try{let r=e.config??{};await n({instanceId:e._id,config:vt(s,r,o)}),t()}catch(e){i.error(ft(),e)}finally{d(!1)}}return(0,Q.jsx)(`div`,{className:`oc-bridge-config`,children:(0,Q.jsxs)(`div`,{className:`oc-bridge-config__form`,children:[(0,Q.jsxs)(`div`,{className:`oc-bridge-config__grid`,children:[(0,Q.jsxs)(`label`,{className:`oc-field`,children:[(0,Q.jsx)(D,{label:ct(),help:ot()}),(0,Q.jsxs)(R,{value:s.mediaMode,onValueChange:e=>c({...s,mediaMode:e}),children:[(0,Q.jsx)(z,{size:`sm`,className:`w-full`,children:(0,Q.jsx)(j,{})}),(0,Q.jsx)(B,{children:yt.map(e=>(0,Q.jsx)(N,{value:e,children:e},e))})]})]}),(0,Q.jsxs)(`label`,{className:`oc-field`,children:[(0,Q.jsx)(D,{label:l(),help:je()}),(0,Q.jsxs)(R,{value:s.inboundMediaMode,onValueChange:e=>c({...s,inboundMediaMode:e}),children:[(0,Q.jsx)(z,{size:`sm`,className:`w-full`,children:(0,Q.jsx)(j,{})}),(0,Q.jsx)(B,{children:_t.map(e=>(0,Q.jsx)(N,{value:e,children:e},e))})]})]}),(0,Q.jsxs)(`label`,{className:`oc-field`,children:[(0,Q.jsx)(D,{label:he(),help:Ye()}),(0,Q.jsx)(k,{type:`number`,min:1,max:4096,className:`w-full`,value:s.mediaMaxMb,onChange:e=>c({...s,mediaMaxMb:Math.trunc(Number(e.target.value)||0)})})]})]}),v&&(0,Q.jsxs)(`div`,{className:`oc-bridge-config__grid`,children:[g&&(0,Q.jsxs)(`label`,{className:`oc-field`,children:[(0,Q.jsx)(D,{label:ee(),help:Se()}),(0,Q.jsx)(k,{className:`w-full`,spellCheck:!1,value:s.inboundAgentMount,onChange:e=>c({...s,inboundAgentMount:e.target.value})})]}),_&&(0,Q.jsxs)(`label`,{className:`oc-field`,children:[(0,Q.jsx)(D,{label:_e(),help:te()}),(0,Q.jsx)(k,{className:`w-full`,spellCheck:!1,value:s.outboundAgentMount,onChange:e=>c({...s,outboundAgentMount:e.target.value})})]})]}),(0,Q.jsxs)(`label`,{className:`oc-field--row`,children:[(0,Q.jsx)(Tt,{checked:s.rehydration,onCheckedChange:e=>c({...s,rehydration:e===!0})}),(0,Q.jsx)(D,{label:ut(),help:$e()})]}),v&&m!==null&&(0,Q.jsx)(`div`,{className:`oc-bridge-config__check`,children:m.reachable?!m.inbound&&!m.outbound?(0,Q.jsxs)(`p`,{className:`oc-bridge-config__check-row oc-bridge-config__check-row--err`,children:[(0,Q.jsx)(I,{"aria-hidden":!0}),oe({reason:m.reason??`?`})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(An,{label:ie(),result:m.inbound}),(0,Q.jsx)(An,{label:ne(),result:m.outbound}),(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:fe()})]}):(0,Q.jsxs)(`p`,{className:`oc-bridge-config__check-row oc-bridge-config__check-row--err`,children:[(0,Q.jsx)(I,{"aria-hidden":!0}),ce()]})}),(0,Q.jsxs)(`div`,{className:`oc-bridge-config__actions`,children:[v&&(0,Q.jsxs)(O,{variant:`outline`,size:`sm`,onClick:()=>void y(),disabled:f,children:[f?(0,Q.jsx)(Ct,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,f?a():ye()]}),(0,Q.jsx)(O,{size:`sm`,onClick:()=>void b(),disabled:u,children:Fe()})]})]})})}function Mn({versions:e}){if(e.length===0)return null;let t=[...e].reverse();return(0,Q.jsxs)(Ft,{children:[(0,Q.jsx)(jt,{asChild:!0,children:(0,Q.jsxs)(`button`,{type:`button`,className:`oc-compat__versions-btn`,children:[e.length===1?o():mt({count:e.length}),(0,Q.jsx)(E,{size:13,"aria-hidden":!0})]})}),(0,Q.jsxs)(Rt,{className:`oc-compat__versions-pop`,align:`start`,children:[(0,Q.jsx)(`p`,{className:`oc-compat__versions-title`,children:pe()}),(0,Q.jsx)(`div`,{className:`oc-compat__versions-list`,children:t.map(e=>(0,Q.jsx)(A,{variant:`secondary`,children:e},e))})]})]})}export{wn as BridgeTab,kn as InstanceConfigDialog};
@@ -1 +0,0 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$g as r,$l as i,CY as a,Ct as o,P_ as s,Qg as c,SY as l,St as u,Tk as d,Tt as f,Xg as p,Zg as m,_p as h,_t as g,at as _,bY as v,bt as y,ct as b,dp as x,dt as S,e_ as C,et as ee,fp as te,ft as ne,gp as w,gt as T,hp as re,ht as E,hv as ie,i_ as ae,it as D,lt as oe,mp as O,mt as k,mv as se,n_ as ce,nt as le,ot as ue,pY as A,pp as de,pt as fe,r_ as j,rt as pe,st as me,t as M,t_ as N,tt as he,up as ge,ut as _e,vp as ve,vt as P,wt as F,xt as ye,xv as I,yp as be,yt as xe,yv as Se}from"./api-IF2KQFNF.js";import{t as Ce}from"./use_paginated_query-DHl8KBoi.js";import{t as L}from"./button-DDPt-po9.js";import{$t as R,Mt as z,St as B,bt as V,kn as we,nt as Te,rt as Ee,tt as H,vt as U,xt as W,yt as G}from"./index-DaLXKABQ.js";import{a as De}from"./compatView-CVibrgBK.js";/* empty css */var K=t(e(),1),Oe=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`];function ke(e){let t=typeof e==`object`&&e?e:{},n=t.defaults!==null&&typeof t.defaults==`object`?t.defaults:{},r=n.thinkingDefault??t.thinkingDefault,i=n.fastModeDefault??t.fastModeDefault;return{thinkingDefault:typeof r==`string`?r:null,fastModeDefault:typeof i==`boolean`?i:null}}var q=[`auto`,`hybrid`,`tool`,`off`];function Ae(e){switch(e){case`auto`:return u();case`hybrid`:return ye();case`tool`:return y();default:return xe()}}function J(e){return{injection:e.injection??`auto`,defaultSources:e.defaultSources,...e.config?{config:e.config}:{}}}function Y(e){return typeof e==`string`&&q.includes(e)}function X(e){return{injection:Y(e.injection)?e.injection:`auto`,sources:e.defaultSources.filter(t=>e.sources.some(e=>e.id===t))}}function Z(e,t){let n=new Set(e);return n.size===new Set(t).size&&t.every(e=>n.has(e))}function je(e,t,n){let r=n?e.defaultWriteRefused===`scope_refused`?k():Me(e)?D():null:E(),i=X(e),a=t.injection!==i.injection||!Z(t.sources,i.sources),o=new Set(e.sources.map(e=>e.id)),s=t.sources.length>0&&t.sources.length<=16&&t.sources.every(e=>o.has(e));return{readOnlyReason:r,dirty:a,valid:s,invalidReason:s?null:g()}}function Me(e){return(e.contract??1)<2&&e.ownAllowlist===!1}function Ne(e,t,n){let r=t.sources.includes(n)?t.sources.filter(e=>e!==n):[...t.sources,n];return{...t,sources:e.sources.map(e=>e.id).filter(e=>r.includes(e))}}function Q(e){return e.ok?null:e.code===`scope_refused`?k():e.code===`stale_default`?fe():e.code===`write_unknown`||e.code===`not_confirmed`?_e():e.code===`not_applied`?oe():e.code===`default_too_large`?le():e.code===`allowlist_too_large`?pe():e.code===`plugin_too_old`?D():e.code===`source_not_allowed`?_():e.code===`plugin_config_lag`?ue():e.code===`knowledge_unavailable`&&e.reason===`plugin_absent`?T():ne({code:e.code})}function Pe(e,t){let n=J(e),r=J(t);if(n.injection!==r.injection||!Z(n.defaultSources,r.defaultSources))return!0;let i=n.config,a=r.config;return i===void 0||a===void 0?i!==a:i.injection!==a.injection||!((e,t)=>e===null||t===null?e===t:e.length===t.length&&e.every((e,n)=>e===t[n]))(i.sources,a.sources)}var $=n();function Fe({instanceName:e,row:t,supported:n}){let r=v(M.knowledge.setAgentKnowledgeDefault),[i,a]=(0,K.useState)(t),[s,l]=(0,K.useState)(()=>X(t)),[u,d]=(0,K.useState)(`idle`),[f,p]=(0,K.useState)(null),[h,g]=(0,K.useState)(!1),_=e=>{a(e),l(X(e)),p(null)},y=Pe(i,t);(0,K.useEffect)(()=>{h&&y&&(g(!1),_(t))},[h,y]);let b=je(i,s,n),x=b.readOnlyReason===null;async function C(){d(`saving`),p(null);try{let n=Q(await r({instanceName:e,agentId:t.agentId,injection:s.injection,sources:s.sources,expected:J(i)}));p(n),d(n===null?`done`:`idle`),n===null&&g(!0)}catch(e){p(Q({ok:!1,code:String(e?.message??`error`).slice(0,60)})),d(`idle`)}}return(0,$.jsxs)(`div`,{className:`oc-cdefaults__row`,"data-knowledge-agent":t.agentId,children:[(0,$.jsx)(`span`,{className:`oc-cdefaults__label`,children:t.agentId}),(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`oc-cdefaults__inline`,children:(0,$.jsxs)(U,{value:s.injection,onValueChange:e=>{Y(e)&&l({...s,injection:e})},disabled:!x,children:[(0,$.jsx)(W,{className:`oc-cdefaults__select`,"aria-label":o(),children:(0,$.jsx)(B,{})}),(0,$.jsx)(G,{children:q.map(e=>(0,$.jsx)(V,{value:e,children:Ae(e)},e))})]})}),(0,$.jsx)(`span`,{className:`oc-cdefaults__label`,children:P()}),t.sources.map(e=>(0,$.jsxs)(`label`,{className:`oc-cdefaults__inline`,style:{cursor:x?`pointer`:`default`},title:e.description||void 0,children:[(0,$.jsx)(z,{checked:s.sources.includes(e.id),onCheckedChange:()=>l(Ne(t,s,e.id)),disabled:!x,"aria-label":e.label,"data-knowledge-default-source":e.id}),(0,$.jsx)(`span`,{children:e.label})]},e.id)),y&&!h?(0,$.jsxs)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:[he(),` `,(0,$.jsx)(L,{variant:`outline`,size:`sm`,onClick:()=>_(t),children:ee()})]}):null,t.overridesAllowed?null:(0,$.jsx)(`p`,{className:`oc-cdefaults__help`,children:S()}),x?(0,$.jsx)(`div`,{className:`oc-cdefaults__inline`,children:(0,$.jsx)(L,{size:`sm`,disabled:!b.dirty||!b.valid||u===`saving`,onClick:()=>void C(),children:u===`saving`?I():c()})}):(0,$.jsx)(`p`,{className:`oc-cdefaults__note`,children:b.readOnlyReason}),x&&b.dirty&&b.invalidReason!==null?(0,$.jsx)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:b.invalidReason}):null,u===`done`&&f===null?(0,$.jsx)(`p`,{className:`oc-admin__hint`,role:`status`,children:m()}):null,f===null?null:(0,$.jsx)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:f})]})]})}function Ie({instanceName:e}){let t=a(M.knowledge.knowledgeAdminInstance,{instanceName:e}),{results:n,status:r,loadMore:i}=Ce(M.knowledge.agentKnowledgePage,{instanceName:e},{initialNumItems:50});return t===void 0||t.provider!==`openclaw`||n.length===0&&r!==`CanLoadMore`?null:(0,$.jsxs)(`section`,{className:`oc-cdefaults__row`,"aria-label":f(),children:[(0,$.jsx)(`span`,{className:`oc-cdefaults__label`,children:f()}),(0,$.jsx)(`p`,{className:`oc-admin__hint`,children:F()}),t.supported?null:(0,$.jsx)(`p`,{className:`oc-cdefaults__note`,children:E()}),n.map(n=>(0,$.jsx)(Fe,{instanceName:e,row:n,supported:t.supported},n.agentId)),r===`CanLoadMore`||r===`LoadingMore`?(0,$.jsxs)(`div`,{className:`oc-cdefaults__inline`,children:[(0,$.jsx)(`p`,{className:`oc-admin__hint`,children:b({shown:n.length})}),(0,$.jsx)(L,{variant:`outline`,size:`sm`,disabled:r===`LoadingMore`,onClick:()=>i(50),"data-knowledge-load-more":!0,children:me()})]}):null]})}function Le({instance:e}){let t=l(M.admin.upsertInstanceConfig),n=a(M.agents.listAgentsForInstance,{instanceName:e.name}),r=typeof e.config?.converterAgentId==`string`?e.config.converterAgentId:``,[i,o]=(0,K.useState)(r),[s,u]=(0,K.useState)(`idle`);(0,K.useEffect)(()=>{o(r),u(`idle`)},[e._id,r]);let d=`__none__`,f=i!==r;async function h(){u(`saving`);try{let n={...e.config??{}};i===``||i===d?delete n.converterAgentId:n.converterAgentId=i,await t({instanceId:e._id,config:n}),u(`done`)}catch{u(`error`)}}let g=n?.agents??[];return(0,$.jsxs)(`div`,{className:`oc-cdefaults__row`,children:[(0,$.jsx)(`span`,{className:`oc-cdefaults__label`,children:w()}),(0,$.jsx)(`p`,{className:`oc-admin__hint`,children:re()}),(0,$.jsxs)(`div`,{className:`oc-cdefaults__inline`,children:[(0,$.jsxs)(U,{value:i===``?d:i,onValueChange:e=>o(e===d?``:e),children:[(0,$.jsx)(W,{className:`oc-cdefaults__select`,"aria-label":w(),children:(0,$.jsx)(B,{placeholder:O()})}),(0,$.jsxs)(G,{children:[(0,$.jsx)(V,{value:d,children:O()}),g.map(e=>(0,$.jsx)(V,{value:e.agentId,children:e.displayName?`${e.displayName} (${e.agentId})`:e.agentId},e.agentId))]})]}),(0,$.jsx)(L,{size:`sm`,disabled:!f||s===`saving`,onClick:()=>void h(),children:s===`saving`?I():c()})]}),s===`done`?(0,$.jsx)(`p`,{className:`oc-admin__hint`,role:`status`,children:m()}):null,s===`error`?(0,$.jsx)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:p()}):null]})}function Re({instance:e}){let t=l(M.admin.upsertInstanceConfig),n=e.config?.curationEnabled===!0,r=typeof e.config?.curationBudgetChars==`number`?e.config.curationBudgetChars:null,[i,a]=(0,K.useState)(n),[o,s]=(0,K.useState)(r===null?``:String(r)),[u,d]=(0,K.useState)(`idle`);(0,K.useEffect)(()=>{a(n),s(r===null?``:String(r)),d(`idle`)},[e._id,n,r]);let f=o.trim(),g=f===``?null:/^\d+$/.test(f)?Number.parseInt(f,10):NaN,_=!i||g===null||Number.isInteger(g)&&g>=4e3&&g<=6e4,v=i!==n||(g??null)!==r;async function y(){d(`saving`);try{let n={...e.config??{}};n.curationEnabled=i,!i||g===null||Number.isNaN(g)?delete n.curationBudgetChars:n.curationBudgetChars=g,await t({instanceId:e._id,config:n}),d(`done`)}catch{d(`error`)}}return(0,$.jsxs)(`div`,{className:`oc-cdefaults__row`,children:[(0,$.jsxs)(`label`,{className:`oc-cdefaults__inline`,style:{cursor:`pointer`},children:[(0,$.jsx)(z,{checked:i,onCheckedChange:e=>a(e===!0),"aria-label":h()}),(0,$.jsx)(`span`,{className:`oc-cdefaults__label`,children:h()})]}),(0,$.jsxs)(`div`,{className:`oc-cdefaults__inline`,children:[(0,$.jsx)(R,{type:`number`,min:4e3,max:6e4,step:1e3,placeholder:`20000`,value:o,onChange:e=>s(e.target.value),className:`oc-cdefaults__number`,"aria-invalid":!_,"aria-label":de(),disabled:!i}),(0,$.jsx)(L,{size:`sm`,disabled:!v||!_||u===`saving`,onClick:()=>void y(),children:u===`saving`?I():c()})]}),_?null:(0,$.jsx)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:te()}),u===`done`?(0,$.jsx)(`p`,{className:`oc-admin__hint`,role:`status`,children:m()}):null,u===`error`?(0,$.jsx)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:p()}):null,(0,$.jsx)(`p`,{className:`oc-cdefaults__help`,children:x()})]})}function ze({instance:e}){let t=l(M.admin.upsertInstanceConfig),n=typeof e.config?.summarizeThresholdChars==`number`?e.config.summarizeThresholdChars:null,[r,i]=(0,K.useState)(n===null?``:String(n)),[a,o]=(0,K.useState)(`idle`);(0,K.useEffect)(()=>{i(n===null?``:String(n)),o(`idle`)},[e._id,n]);let s=r.trim(),u=s===``?null:/^\d+$/.test(s)?Number.parseInt(s,10):NaN,d=u===null||Number.isInteger(u)&&u>=1e3&&u<=2e5,f=(u??null)!==n;async function h(){o(`saving`);try{let n={...e.config??{}};u===null?delete n.summarizeThresholdChars:n.summarizeThresholdChars=u,await t({instanceId:e._id,config:n}),o(`done`)}catch{o(`error`)}}return(0,$.jsxs)(`div`,{className:`oc-cdefaults__row`,children:[(0,$.jsx)(`span`,{className:`oc-cdefaults__label`,children:be()}),(0,$.jsxs)(`div`,{className:`oc-cdefaults__inline`,children:[(0,$.jsx)(R,{type:`number`,min:1e3,max:2e5,step:1e3,placeholder:`8000`,value:r,onChange:e=>i(e.target.value),className:`oc-cdefaults__number`,"aria-invalid":!d}),(0,$.jsx)(L,{size:`sm`,disabled:!f||!d||a===`saving`,onClick:()=>void h(),children:a===`saving`?I():c()})]}),d?null:(0,$.jsx)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:ge()}),a===`done`?(0,$.jsx)(`p`,{className:`oc-admin__hint`,role:`status`,children:m()}):null,a===`error`?(0,$.jsx)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:p()}):null,(0,$.jsx)(`p`,{className:`oc-cdefaults__help`,children:ve()})]})}function Be(){let e=v(M.agentFiles.getChatDefaults),[t,n]=(0,K.useState)({status:`loading`}),o=a(M.admin.listInstances,{}),[c,l]=(0,K.useState)(null);(0,K.useEffect)(()=>{!o||o.length===0||(!c||!o.some(e=>e.name===c))&&l(o[0].name)},[o,c]);let u=(o?.length??0)>1,f=o!==void 0&&o.length===0,p=a(M.compat.forInstance,c?{instanceName:c}:`skip`),m=c?Te(p,`configDefaults`):`loading`,h=m===`loading`?null:m.blocked,g=(0,K.useMemo)(()=>u&&c?{instanceName:c}:{},[u,c]),_=(0,K.useRef)(0),y=(0,K.useCallback)(async()=>{let t=++_.current;n({status:`loading`});try{let r=ke(await e(g));if(_.current!==t)return;n({status:`done`,current:r})}catch{if(_.current!==t)return;n({status:`error`})}},[e,g]);(0,K.useEffect)(()=>{h===!1&&(u&&!c||y())},[y,h,u,c]);let b=t.status===`done`?t.current:null,x=(0,K.useMemo)(()=>Oe.map(e=>({id:e,label:Ee(e)})),[]),S=(0,K.useMemo)(()=>[{id:`fast`,label:ie()},{id:`standard`,label:se()}],[]);return(0,$.jsxs)(`div`,{className:`oc-cdefaults`,children:[(0,$.jsx)(`p`,{className:`oc-admin__hint`,children:ae()}),u&&c?(0,$.jsxs)(`div`,{className:`oc-cdefaults__row`,children:[(0,$.jsx)(`span`,{className:`oc-cdefaults__label`,children:s()}),(0,$.jsxs)(U,{value:c,onValueChange:e=>l(e),children:[(0,$.jsx)(W,{size:`sm`,"aria-label":s(),children:(0,$.jsx)(B,{})}),(0,$.jsx)(G,{children:(o??[]).map(e=>(0,$.jsx)(V,{value:e.name,children:e.name},e.name))})]})]}):null,f?(0,$.jsx)(`p`,{className:`oc-admin__hint`,role:`status`,children:d()}):m===`loading`?(0,$.jsx)(`p`,{className:`oc-admin__hint`,children:A()}):m.blocked?(0,$.jsxs)(`p`,{className:`oc-compat__blocked`,role:`status`,children:[(0,$.jsx)(we,{size:14,"aria-hidden":!0}),` `,De(m.gatewayVersion,m.provider)]}):t.status===`loading`?(0,$.jsx)(`p`,{className:`oc-admin__hint`,children:A()}):t.status===`error`?(0,$.jsxs)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:[r(),` `,(0,$.jsx)(L,{variant:`outline`,size:`sm`,onClick:()=>void y(),children:Se()})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`oc-cdefaults__row`,children:[(0,$.jsx)(`span`,{className:`oc-cdefaults__label`,children:j()}),(0,$.jsx)(H,{field:`thinkingLevel`,options:x,value:b?.thinkingDefault??null,onChange:()=>{},disabled:!0,ariaLabel:j()}),(0,$.jsx)(`p`,{className:`oc-cdefaults__help`,children:ce()})]}),(0,$.jsxs)(`div`,{className:`oc-cdefaults__row`,children:[(0,$.jsx)(`span`,{className:`oc-cdefaults__label`,children:N()}),(0,$.jsx)(H,{field:`fastMode`,options:S,value:b===null||b.fastModeDefault===null?null:b.fastModeDefault?`fast`:`standard`,onChange:()=>{},disabled:!0,ariaLabel:N()}),(0,$.jsx)(`p`,{className:`oc-cdefaults__help`,children:C()})]}),(0,$.jsx)(`p`,{className:`oc-cdefaults__note`,children:i()})]}),(()=>{let e=o?.find(e=>e.name===(c??o[0]?.name));return e?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ze,{instance:e}),(0,$.jsx)(Re,{instance:e}),(0,$.jsx)(Le,{instance:e}),(0,$.jsx)(Ie,{instanceName:e.name})]}):null})()]})}export{Be as ChatDefaultsTab};
@@ -1 +0,0 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$F as r,$I as i,AI as a,BI as o,CI as s,CY as c,Cf as l,DI as u,EI as d,FI as f,GI as p,HI as ee,II as te,JI as m,KI as h,LI as ne,MI as re,NI as g,OI as ie,PI as _,QF as v,QI as y,RI as ae,SI as b,SY as x,TI as S,UI as C,VI as w,WI as T,XI as E,YI as D,ZI as O,_I as k,aI as A,bI as j,cI as M,dI as N,eI as P,eL as F,fI as I,gI as L,hI as R,iI as z,jI as B,kI as V,lI as H,mI as U,nI as W,oI as oe,pI as G,qI as K,rI as q,sI as se,t as J,tI as ce,uI as le,vI as ue,wI as de,xI as fe,xf as pe,yI as me,zI as he}from"./api-IF2KQFNF.js";import{t as ge}from"./button-DDPt-po9.js";import{At as _e,ct as Y}from"./index-DaLXKABQ.js";import{t as ve}from"./DataTableShell-Dc3I5mkG.js";var X=t(e(),1),Z=n(),ye={altered_words:()=>F(),incorrect:()=>i(),incoherence:()=>y(),formatting:()=>O(),latency:()=>E(),api_error:()=>D(),other:()=>m()},Q=e=>ye[e]?.()??e;function $({matches:e,sourceWasOpen:t}){return t?e===!0?(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill is-ok`,children:h()}):e===!1?(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill is-warn`,children:p()}):(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill`,children:`—`}):(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill`,children:K()})}function be({data:e,reference:t,closeReason:n}){let r=e.snapshot,i=x(J.feedback.respondToFeedback),[s,c]=(0,X.useState)(e.thread),[p,m]=(0,X.useState)(``),[h,v]=(0,X.useState)(!1);async function y(){let t=p.trim();if(!(!t||h)){v(!0);try{await i({feedbackId:e._id,text:t}),c(e=>[...e,{authorRole:`admin`,text:t,at:Date.now()}]),m(``)}finally{v(!1)}}}let b=[];try{b=r.contextJson?JSON.parse(r.contextJson):[]}catch{b=[]}return(0,Z.jsxs)(`div`,{className:`oc-fbadmin__detail`,children:[(0,Z.jsxs)(`div`,{className:`oc-fbadmin__row`,children:[(0,Z.jsx)($,{matches:r.displayedMatchesStored,sourceWasOpen:r.clientInfo?.sourceWasOpen??!1}),(0,Z.jsxs)(`span`,{className:`oc-fbadmin__meta`,children:[Q(e.category),` · `,r.messageRole,r.isRegeneration?` · ${T()}`:``,r.openclawModel?` · ${r.openclawModel}`:``,r.openclawRuntime?` (${r.openclawRuntime})`:``]}),t?(0,Z.jsx)(`code`,{className:`oc-fbadmin__ref`,style:{userSelect:`all`,marginLeft:`auto`},title:ue(),children:t}):null]}),e.comment?(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:C()}),(0,Z.jsx)(`p`,{className:`oc-fbadmin__comment`,children:e.comment})]}):null,n?(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:z()}),(0,Z.jsx)(`p`,{className:`oc-fbadmin__comment`,children:n})]}):null,(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:ee()}),s.length>0?(0,Z.jsx)(`div`,{className:`oc-fbadmin__thread`,children:s.map((e,t)=>(0,Z.jsxs)(`div`,{className:`oc-notif__msg oc-notif__msg--${e.authorRole}`,children:[(0,Z.jsx)(`span`,{className:`oc-notif__msg-who`,children:e.authorRole===`admin`?w():e.authorRole===`agent`?e.authorLabel??l():o()}),(0,Z.jsx)(`span`,{className:`oc-notif__msg-text`,children:e.text})]},t))}):(0,Z.jsx)(`p`,{className:`oc-fbadmin__meta`,children:he()}),(0,Z.jsx)(`textarea`,{className:`oc-feedback__textarea`,placeholder:ae(),value:p,maxLength:2e3,rows:3,onChange:e=>m(e.target.value.slice(0,2e3))}),(0,Z.jsx)(`div`,{className:`oc-fbadmin__row`,style:{justifyContent:`flex-end`},children:(0,Z.jsx)(ge,{size:`sm`,onClick:()=>void y(),disabled:!p.trim()||h,children:h?ne():te()})})]}),(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:f()}),(0,Z.jsx)(`pre`,{className:`oc-msg__source-pre`,children:r.messageText||_()})]}),r.clientInfo?.sourceWasOpen&&r.displayedText!==void 0?(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:g()}),(0,Z.jsx)(`pre`,{className:`oc-msg__source-pre`,children:r.displayedText||_()})]}):null,r.promptText?(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:re()}),(0,Z.jsx)(`pre`,{className:`oc-msg__source-pre`,children:r.promptText})]}):null,b.length>0?(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:B({count:r.contextCount??b.length,truncated:r.contextTruncated?a():``})}),(0,Z.jsx)(`div`,{className:`oc-fbadmin__ctx`,children:b.map((e,t)=>(0,Z.jsxs)(`div`,{className:`oc-fbadmin__ctx-turn`,children:[(0,Z.jsx)(`span`,{className:`oc-fbadmin__ctx-role`,children:e.role}),(0,Z.jsx)(`span`,{className:`oc-fbadmin__ctx-text`,children:e.text})]},t))})]}):null,r.outboxAvailable?(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:V()}),(0,Z.jsxs)(`pre`,{className:`oc-msg__source-pre`,children:[r.outboxText??``,r.outboxStatus?`\n[status: ${r.outboxStatus}]`:``]})]}):null,r.clientInfo?.extensionsDetected&&r.clientInfo.extensionsDetected.length>0?(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:ie()}),(0,Z.jsx)(`div`,{className:`oc-fbadmin__row`,children:r.clientInfo.extensionsDetected.map(e=>(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill is-warn`,children:e},e))})]}):null,(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:u()}),(0,Z.jsxs)(`p`,{className:`oc-fbadmin__env`,children:[[r.clientInfo?.language,r.clientInfo?.timezone,r.clientInfo?.theme?d({theme:r.clientInfo.theme}):null,r.runId?`run ${r.runId.slice(0,12)}…`:null].filter(Boolean).join(` · `)||`—`,r.clientInfo?.plugins&&r.clientInfo.plugins.length>0?(0,Z.jsxs)(`span`,{className:`oc-fbadmin__plugins`,children:[S(),` `,r.clientInfo.plugins.join(`, `),(0,Z.jsxs)(`span`,{className:`oc-fbadmin__note`,children:[` `,de()]})]}):null,r.clientInfo?.userAgent?(0,Z.jsx)(`span`,{className:`oc-fbadmin__ua`,children:r.clientInfo.userAgent}):null]})]})]})}function xe(){let e=c(J.feedback.listForAdmin,{}),t=x(J.feedback.readSnapshot),n=x(J.feedback.deleteFeedback),i=Y(),[a,o]=(0,X.useState)(null),[l,u]=(0,X.useState)({});async function d(e){if(a===e._id){o(null);return}if(!l[e._id]){let n=await t({feedbackId:e._id});u(t=>({...t,[e._id]:n}))}o(e._id)}async function f(e){await i({title:P(),description:r(),confirmLabel:v(),destructive:!0})&&(await n({feedbackId:e._id}),a===e._id&&o(null))}return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`p`,{className:`oc-admin__hint`,children:[s(),` `,(0,Z.jsx)(`strong`,{children:b()}),` `,fe()]}),(0,Z.jsx)(ve,{title:j(),rows:e,emptyHint:me(),isExpanded:e=>a===e._id&&!!l[e._id],renderExpanded:e=>l[e._id]?(0,Z.jsx)(be,{data:l[e._id],reference:e.reference,closeReason:e.userCloseReason}):null,columns:[{header:k(),cell:e=>_e(e.at),sort:e=>e.at},{header:L(),cell:e=>Q(e.category),sort:e=>Q(e.category)},{header:R(),cell:e=>e.messageRole===`user`?U():G(),sort:e=>e.messageRole},{header:I(),cell:e=>(e.reporterEmail||e.reporterName||`—`)+(e.impersonated&&e.realOperatorEmail?` ${N({operator:e.realOperatorEmail})}`:``),sort:e=>e.reporterEmail||e.reporterName||null},{header:le(),cell:e=>(0,Z.jsx)($,{matches:e.displayedMatchesStored,sourceWasOpen:e.sourceWasOpen}),sort:e=>e.displayedMatchesStored===!1?0:e.displayedMatchesStored===!0?1:2},{header:H(),cell:e=>e.hasComment?`✎`:`—`,sort:e=>+!!e.hasComment},{header:M(),cell:e=>e.userClosedAt==null?e.resolvedAt==null?e.answered?(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill is-ok`,children:se()}):(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill`,children:oe()}):(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill is-ok`,title:e.resolvedBy??void 0,children:pe()}):(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill is-closed`,children:A()}),sort:e=>e.userClosedAt==null?e.resolvedAt==null?+!!e.answered:2:3}],rowActions:e=>[{label:a===e._id?q():W(),onSelect:()=>void d(e)},{label:ce(),onSelect:()=>void f(e),variant:`destructive`}]})]})}export{xe as FeedbacksTab};
@@ -1 +0,0 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$q as ee,AJ as r,CJ as i,CY as a,DJ as te,Df as o,EJ as ne,Ef as re,MJ as ie,NJ as s,OJ as c,PJ as l,SJ as u,SY as d,TJ as ae,_J as f,aJ as oe,bJ as p,cJ as se,dJ as ce,eJ as le,fJ as ue,gJ as de,hJ as fe,hY as pe,iJ as me,jJ as m,kJ as he,lJ as ge,mJ as _e,nJ as ve,oJ as ye,pJ as be,pY as xe,rJ as Se,sJ as h,t as g,tJ as _,uJ as v,vJ as y,wB as b,wJ as x,xJ as S,yJ as C}from"./api-IF2KQFNF.js";import{t as w}from"./button-DDPt-po9.js";import{An as T,Bt as E,Gt as D,Ht as O,In as k,Jt as A,Kt as j,Mt as Ce,St as M,Ut as we,Vt as Te,Wt as Ee,Yt as De,an as Oe,bt as N,en as ke,nn as P,nr as F,qt as Ae,tn as je,tr as Me,vt as I,xt as L,yt as R}from"./index-DaLXKABQ.js";import{a as Ne,i as z,n as Pe,o as B,r as V,t as Fe}from"./table-CnU0GqDN.js";var H=t(e(),1),U=n(),W=`all`;function G(e){switch(e){case`image`:return i();case`audio`:return u();case`video`:return S();case`pdf`:return p();case`document`:return C();case`archive`:return y();default:return f()}}function K(){let[e,t]=(0,H.useState)(W),[n,i]=(0,H.useState)(W),[u,f]=(0,H.useState)(W),[p,y]=(0,H.useState)(W),[S,C]=(0,H.useState)(!1),[K,q]=(0,H.useState)(null),J=d(g.files.softDelete),Y=De();function Ie(){t(W),i(W),f(W),y(W)}async function Le(){let e=K;if(q(null),e)try{await J({fileId:e.id}),Y.success(ye())}catch(e){Y.error(oe(),e)}}let X=a(g.files.listMine,{direction:e===W?void 0:e,chatId:n===W?void 0:n,instanceName:u===W?void 0:u,category:p===W?void 0:p,includeAutoGenerated:S||void 0}),Re=(0,H.useMemo)(()=>new Intl.DateTimeFormat(pe(),{dateStyle:`medium`,timeStyle:`short`}),[]);if(X===void 0)return(0,U.jsx)(`p`,{className:`oc-admin__hint`,children:xe()});let{files:Z,facets:Q,truncated:ze,cap:Be}=X,$=e!==W||n!==W||u!==W||p!==W;return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`p`,{className:`oc-admin__hint`,children:l()}),(0,U.jsxs)(`div`,{className:`oc-files__filters`,style:{display:`flex`,flexWrap:`wrap`,gap:8,margin:`12px 0`},children:[(0,U.jsxs)(I,{value:e,onValueChange:t,children:[(0,U.jsx)(L,{size:`sm`,"aria-label":s(),children:(0,U.jsx)(M,{})}),(0,U.jsxs)(R,{children:[(0,U.jsx)(N,{value:W,children:ie()}),(0,U.jsx)(N,{value:`inbound`,children:m()}),(0,U.jsx)(N,{value:`outbound`,children:r()})]})]}),(0,U.jsxs)(I,{value:n,onValueChange:i,children:[(0,U.jsx)(L,{size:`sm`,"aria-label":he(),children:(0,U.jsx)(M,{})}),(0,U.jsxs)(R,{children:[(0,U.jsx)(N,{value:W,children:c()}),Q.chats.map(e=>(0,U.jsx)(N,{value:e.id,children:e.title},e.id))]})]}),Q.multiProvider?(0,U.jsxs)(I,{value:u,onValueChange:f,children:[(0,U.jsx)(L,{size:`sm`,"aria-label":te(),children:(0,U.jsx)(M,{})}),(0,U.jsxs)(R,{children:[(0,U.jsx)(N,{value:W,children:ne()}),Q.instances.map(e=>(0,U.jsx)(N,{value:e,children:e},e))]})]}):null,(0,U.jsxs)(I,{value:p,onValueChange:y,children:[(0,U.jsx)(L,{size:`sm`,"aria-label":ae(),children:(0,U.jsx)(M,{})}),(0,U.jsxs)(R,{children:[(0,U.jsx)(N,{value:W,children:x()}),Q.categories.map(e=>(0,U.jsx)(N,{value:e,children:G(e)},e))]})]}),(0,U.jsxs)(`label`,{className:`oc-files__autogen`,children:[(0,U.jsx)(Ce,{checked:S,onCheckedChange:e=>C(e===!0),"aria-label":o()}),(0,U.jsx)(`span`,{children:o()})]}),$?(0,U.jsxs)(w,{variant:`ghost`,size:`sm`,onClick:Ie,style:{display:`inline-flex`,alignItems:`center`,gap:4,marginLeft:`auto`},children:[(0,U.jsx)(k,{size:14,"aria-hidden":!0}),ge()]}):null]}),Z.length===0?(0,U.jsx)(`p`,{className:`oc-admin__hint`,children:$?le():_()}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(Fe,{children:[(0,U.jsx)(Ne,{children:(0,U.jsxs)(B,{children:[(0,U.jsx)(z,{children:de()}),(0,U.jsx)(z,{children:fe()}),(0,U.jsx)(z,{children:_e()}),(0,U.jsx)(z,{children:be()}),(0,U.jsx)(z,{children:ue()}),(0,U.jsx)(z,{className:`text-right`,children:ce()})]})}),(0,U.jsx)(Pe,{children:Z.map(e=>(0,U.jsxs)(B,{children:[(0,U.jsxs)(V,{className:`font-medium`,style:{maxWidth:280,overflow:`hidden`,textOverflow:`ellipsis`},title:e.filename,children:[e.filename,e.origin===`pasted`?(0,U.jsx)(A,{variant:`outline`,style:{marginLeft:6},children:re()}):null]}),(0,U.jsx)(V,{title:e.mimeType,children:G(e.category)}),(0,U.jsx)(V,{children:(0,U.jsx)(A,{variant:`secondary`,children:e.direction===`inbound`?m():r()})}),(0,U.jsx)(V,{style:{maxWidth:220,overflow:`hidden`,textOverflow:`ellipsis`},title:e.chatTitle,children:e.chatTitle}),(0,U.jsx)(V,{className:`whitespace-nowrap text-muted-foreground`,children:Re.format(e.createdAt)}),(0,U.jsx)(V,{className:`text-right`,children:(0,U.jsxs)(ke,{children:[(0,U.jsx)(Oe,{asChild:!0,children:(0,U.jsx)(w,{variant:`ghost`,size:`icon`,"aria-label":se(),children:(0,U.jsx)(Me,{size:16})})}),(0,U.jsxs)(je,{align:`end`,children:[e.url?(0,U.jsx)(P,{asChild:!0,children:(0,U.jsxs)(`a`,{href:e.url,download:e.filename,target:`_blank`,rel:`noopener noreferrer`,children:[(0,U.jsx)(F,{size:14}),v()]})}):(0,U.jsxs)(P,{disabled:!0,children:[(0,U.jsx)(F,{size:14}),ve()]}),(0,U.jsxs)(P,{variant:`destructive`,onSelect:()=>q({id:e._id,filename:e.filename}),children:[(0,U.jsx)(T,{size:14}),h()]})]})]})})]},e._id))})]}),ze?(0,U.jsx)(`p`,{className:`oc-admin__hint`,style:{marginTop:8},children:ee({cap:Be})}):null]}),(0,U.jsx)(E,{open:K!==null,onOpenChange:e=>!e&&q(null),children:(0,U.jsxs)(we,{children:[(0,U.jsxs)(j,{children:[(0,U.jsx)(Ae,{children:me()}),(0,U.jsx)(Ee,{children:Se()})]}),(0,U.jsxs)(D,{children:[(0,U.jsx)(O,{children:b()}),(0,U.jsx)(Te,{onClick:()=>void Le(),children:h()})]})]})})]})}export{K as FilesTab};
@@ -1 +0,0 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$v as r,$y as i,Ab as a,Bb as o,By as s,CY as c,Cb as l,Cy as u,Db as d,Dy as f,E as p,Eb as m,Ey as h,Fb as g,Fy as _,Gb as v,Gv as y,Gy as b,Hb as x,Hy as S,Ib as C,Iv as w,Iy as T,Jb as E,Jv as D,Jy as O,Kb as ee,Kv as k,Ky as te,Lb as ne,Lv as re,Ly as A,Mb as j,My as ie,Nb as ae,Ny as M,Ob as oe,Oy as N,Pb as se,Py as ce,Qv as P,Qy as le,Rb as F,Rv as ue,Ry as de,SY as I,Sb as fe,Sy as pe,Tb as me,Ty as he,Ub as ge,Uy as _e,Vb as ve,Vy as ye,Wb as be,Wy as xe,Xv as Se,Xy as Ce,Yb as we,Yv as Te,Yy as Ee,Zv as De,Zy as Oe,_b as ke,_y as Ae,ab as je,ay as Me,bb as L,by as Ne,cb as Pe,cy as Fe,db as R,dy as Ie,eb as Le,ey as Re,fb as ze,fy as Be,gy as Ve,hy as He,ib as Ue,iy as We,jb as Ge,kb as Ke,lb as qe,ly as Je,my as Ye,nb as Xe,ny as Ze,ob as Qe,oy as $e,pb as et,py as tt,qb as nt,qv as rt,qy as it,rb as at,ry as ot,sb as st,sy as ct,t as z,tb as lt,ty as ut,ub as dt,uy as ft,vb as pt,vy as mt,wb as ht,wy as gt,xb as _t,xy as vt,yb as yt,yy as bt,zb as xt,zv as St,zy as Ct}from"./api-IF2KQFNF.js";import{t as wt}from"./x-F4mR_Xu3.js";import{t as B}from"./button-DDPt-po9.js";import{$ as Tt,$t as V,Ct as Et,Dn as Dt,Dt as Ot,En as kt,G as At,J as H,Jt as U,K as jt,Mn as Mt,Mt as W,Nn as G,Ot as Nt,Pn as K,Q as Pt,St as Ft,Tt as It,W as q,X as Lt,Y as Rt,Yt as J,Z as zt,at as Bt,b as Vt,bt as Ht,cr as Ut,ct as Wt,et as Gt,ft as Kt,it as qt,jn as Y,ot as Jt,q as Yt,sr as Xt,st as Zt,vt as Qt,wt as $t,xt as en,yt as tn}from"./index-DaLXKABQ.js";import{t as nn}from"./FilterBar-Bfu-khK5.js";import{t as rn}from"./DataTableShell-Dc3I5mkG.js";import{t as X}from"./DetailChips-Cj0X9b5z.js";var an=p(`palette`,[[`path`,{d:`M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z`,key:`e79jfc`}],[`circle`,{cx:`13.5`,cy:`6.5`,r:`.5`,fill:`currentColor`,key:`1okk4w`}],[`circle`,{cx:`17.5`,cy:`10.5`,r:`.5`,fill:`currentColor`,key:`f64h9f`}],[`circle`,{cx:`6.5`,cy:`12.5`,r:`.5`,fill:`currentColor`,key:`qy21gx`}],[`circle`,{cx:`8.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`fotxhn`}]]),Z=t(e(),1),Q=n(),on={name:``,description:``};function sn(){let e=c(z.groups.listGroups,{}),t=c(z.me.getMe,{host:Kt})?.role===`admin`,n=I(z.groups.createGroup),r=I(z.groups.updateGroup),i=I(z.groups.deleteGroup),s=Wt(),l=J(),[u,d]=(0,Z.useState)(!1),[f,p]=(0,Z.useState)(null),[m,h]=(0,Z.useState)(on),[_,y]=(0,Z.useState)(null),[b,S]=(0,Z.useState)(``),w=(0,Z.useMemo)(()=>{if(!e)return e;let t=b.trim().toLowerCase();return t?e.filter(e=>e.name.toLowerCase().includes(t)||(e.description??``).toLowerCase().includes(t)||e.members.some(e=>e.label.toLowerCase().includes(t))||e.agents.some(e=>e.toLowerCase().includes(t))||e.charts.some(e=>e.name.toLowerCase().includes(t))):e},[e,b]);function T(){p(null),h(on),d(!0)}function D(e){p(e),h({name:e.name,description:e.description??``}),d(!0)}async function O(){try{f?await r({groupId:f._id,name:m.name,description:m.description}):await n({name:m.name,description:m.description||void 0}),h(on),p(null),d(!1)}catch(e){l.error(xe(),e)}}async function k(e){if(await s({title:a({name:e.name}),description:Ke(),confirmWord:e.name,confirmLabel:oe(),cancelLabel:C(),destructive:!0}))try{await i({groupId:e._id})}catch(e){l.error(_e(),e)}}return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:E()}),t?(0,Q.jsx)(pn,{}):null,(0,Q.jsx)(nn,{q:b,onQChange:S,onReset:()=>S(``),canReset:b!==``,searchPlaceholder:ve()}),(0,Q.jsx)(rn,{title:we(),rows:w,addLabel:nt(),onAdd:t?T:void 0,emptyHint:ee(),columns:[{header:v(),cell:e=>e.name,sort:e=>e.name},{header:be(),cell:e=>(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(X,{icon:(0,Q.jsx)(kt,{size:12,"aria-hidden":!0}),total:e.memberCount,items:e.members.map(e=>({label:e.label,marker:e.manager?(0,Q.jsx)(G,{size:11,"aria-hidden":!0}):null,highlight:e.manager}))}),e.pendingInviteCount>0?(0,Q.jsx)(U,{variant:`secondary`,children:ie({count:String(e.pendingInviteCount)})}):null]}),sort:e=>e.memberCount},{header:ge(),cell:e=>(0,Q.jsx)(X,{icon:(0,Q.jsx)(K,{size:12,"aria-hidden":!0}),total:e.agentCount,items:e.agents.map(e=>({label:e}))}),sort:e=>e.agentCount},{header:x(),cell:e=>(0,Q.jsx)(X,{icon:(0,Q.jsx)(an,{size:12,"aria-hidden":!0}),total:e.chartCount,items:e.charts.map(e=>({label:e.name,marker:e.isDefault?(0,Q.jsx)(Y,{size:11,fill:`currentColor`,"aria-hidden":!0}):null,highlight:e.isDefault}))}),sort:e=>e.chartCount}],rowActions:e=>[{label:o(),onSelect:()=>y({groupId:e._id,name:e.name})},...t?[{label:xt(),onSelect:()=>D(e)},{label:F(),variant:`destructive`,onSelect:()=>void k(e)}]:[]]}),(0,Q.jsx)(Vt,{open:u,onOpenChange:d,title:f?se():g(),description:ae(),canSubmit:!!m.name.trim(),onSubmit:O,submitLabel:ne(),children:(0,Q.jsxs)(`div`,{className:`oc-form`,children:[(0,Q.jsxs)(`label`,{className:`oc-field`,children:[(0,Q.jsx)(`span`,{className:`oc-field__label`,children:j()}),(0,Q.jsx)(V,{value:m.name,onChange:e=>h({...m,name:e.target.value})})]}),(0,Q.jsxs)(`label`,{className:`oc-field`,children:[(0,Q.jsx)(`span`,{className:`oc-field__label`,children:Ge()}),(0,Q.jsx)(V,{value:m.description,onChange:e=>h({...m,description:e.target.value})})]})]})}),(0,Q.jsx)(ln,{groupId:_?.groupId??null,groupName:_?.name??``,open:_!==null,onOpenChange:e=>{e||y(null)}})]})}var cn=8;function $({page:e,pageCount:t,onPage:n}){return t<=1?null:(0,Q.jsxs)(`div`,{className:`oc-access__pager`,children:[(0,Q.jsxs)(B,{type:`button`,variant:`ghost`,size:`sm`,disabled:e<=1,onClick:()=>n(e-1),children:[(0,Q.jsx)(Ut,{size:14,"aria-hidden":!0}),yt()]}),(0,Q.jsxs)(`span`,{className:`oc-access__pageinfo`,"aria-label":ke({page:e,pages:t}),children:[e,` / `,t]}),(0,Q.jsxs)(B,{type:`button`,variant:`ghost`,size:`sm`,disabled:e>=t,onClick:()=>n(e+1),children:[pt(),(0,Q.jsx)(Xt,{size:14,"aria-hidden":!0})]})]})}function ln({groupId:e,groupName:t,open:n,onOpenChange:r}){let i=c(z.groups.getGroup,n&&e?{groupId:e}:`skip`),a=i?.viewerIsAdmin===!0,o=c(z.groups.listAssignableInstances,n&&e?{groupId:e}:`skip`),f=c(z.groups.listAssignableUsers,n&&a?{}:`skip`),p=I(z.groups.addMember),h=I(z.groups.removeMember),g=I(z.groups.bulkSetMembers),_=I(z.groups.setGroupManager),v=J(),[y,b]=(0,Z.useState)(``),[x,C]=(0,Z.useState)(``),[w,T]=(0,Z.useState)(`members`),[E,D]=(0,Z.useState)(1),[ee,k]=(0,Z.useState)(null),[ne,re]=(0,Z.useState)(new Set),A=(0,Z.useRef)(null),j=(0,Z.useMemo)(()=>new Set((i?.members??[]).map(e=>e.userId)),[i]),ie=(0,Z.useMemo)(()=>new Set((i?.members??[]).filter(e=>e.manager).map(e=>e.userId)),[i]),ae=(0,Z.useMemo)(()=>new Set((i?.members??[]).filter(e=>e.restricted).map(e=>e.userId)),[i]),M=(0,Z.useMemo)(()=>new Set((i?.agents??[]).map(e=>q(e.instanceName,e.agentId))),[i]),oe=(0,Z.useMemo)(()=>{let e=(i?.agents??[]).find(e=>e.isDefault);return e?q(e.instanceName,e.agentId):null},[i]);(0,Z.useEffect)(()=>{b(``),C(``),T(`members`),D(1),k(null),A.current=null},[n,e]),(0,Z.useEffect)(()=>{D(1)},[y]),(0,Z.useEffect)(()=>{n&&i&&e&&A.current!==e&&(A.current=e,re(new Set((i.members??[]).map(e=>e.userId))))},[n,i,e]);let N=(0,Z.useMemo)(()=>f?Yt(f,y,ne):[],[f,y,ne]);async function se(t,n){if(e)try{n?await h({groupId:e,userId:t}):await p({groupId:e,userId:t})}catch(e){v.error(S(),H(e))}}async function ce(t,n){if(e)try{await _({groupId:e,userId:t,manager:!n})}catch(e){v.error(te(),e)}}let P=Tt(N,e=>j.has(e.userId)),le=N.filter(e=>j.has(e.userId)).length,F=zt(N,E,cn);async function ue(){if(!e||N.length===0)return;let t=N.map(e=>e.userId);try{await g({groupId:e,userIds:t,member:P!==`all`})}catch(e){v.error(S(),H(e))}}let de=(e,t)=>(0,Q.jsxs)(B,{type:`button`,variant:`ghost`,size:`sm`,className:`h-7`,"aria-label":u({user:t}),title:u({user:t}),onClick:()=>k({userId:e,label:t}),children:[(0,Q.jsx)(Mt,{size:13,"aria-hidden":!0}),gt()]});return(0,Q.jsx)(Et,{open:n,onOpenChange:r,children:(0,Q.jsxs)($t,{className:`oc-access`,children:[(0,Q.jsxs)(Ot,{children:[(0,Q.jsx)(Nt,{children:d({name:t})}),(0,Q.jsx)(It,{children:i&&!a?s():m()})]}),(0,Q.jsxs)(qt,{value:w,onValueChange:T,className:`oc-access__tabs`,children:[(0,Q.jsxs)(Jt,{className:`w-full`,children:[(0,Q.jsxs)(Zt,{value:`members`,className:`flex-1 gap-1.5`,children:[(0,Q.jsx)(kt,{size:13,"aria-hidden":!0}),me(),i?(0,Q.jsx)(U,{variant:`secondary`,className:`oc-access__tabcount`,children:j.size}):null]}),(0,Q.jsxs)(Zt,{value:`agents`,className:`flex-1 gap-1.5`,children:[(0,Q.jsx)(K,{size:13,"aria-hidden":!0}),l(),i?(0,Q.jsx)(U,{variant:`secondary`,className:`oc-access__tabcount`,children:M.size}):null]}),(0,Q.jsxs)(Zt,{value:`charts`,className:`flex-1 gap-1.5`,children:[(0,Q.jsx)(an,{size:13,"aria-hidden":!0}),at(),i?(0,Q.jsx)(U,{variant:`secondary`,className:`oc-access__tabcount`,children:i.chartCount}):null]})]}),(0,Q.jsx)(Bt,{value:`members`,children:i===void 0?(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:R()}):a?f===void 0?(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:R()}):f.length===0?(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:qe()}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(V,{value:y,onChange:e=>b(e.target.value),placeholder:ht(),className:`oc-access__search`}),N.length===0?(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:_t()}):(0,Q.jsxs)(Q.Fragment,{children:[N.length>1?(0,Q.jsxs)(`div`,{className:`oc-access__row oc-access__selectall`,children:[(0,Q.jsx)(W,{checked:P===`all`?!0:P===`some`?`indeterminate`:!1,onCheckedChange:()=>void ue(),"aria-label":L()}),(0,Q.jsx)(`span`,{className:`oc-access__label`,children:L()}),(0,Q.jsxs)(U,{variant:`outline`,className:`oc-access__count`,children:[le,` / `,N.length]})]}):null,(0,Q.jsx)(`div`,{className:`oc-access__list`,children:F.pageItems.map(e=>{let t=j.has(e.userId),n=Gt(e),r=ie.has(e.userId);return(0,Q.jsxs)(`div`,{className:`oc-access__row`,children:[(0,Q.jsx)(W,{checked:t,onCheckedChange:()=>void se(e.userId,t),"aria-label":et({user:n.primary})}),(0,Q.jsxs)(`span`,{className:`oc-access__who`,children:[(0,Q.jsx)(`span`,{className:`oc-access__label`,title:n.primary,children:n.primary}),n.secondary?(0,Q.jsx)(`span`,{className:`oc-access__sub`,title:n.secondary,children:n.secondary}):null]}),t&&ae.has(e.userId)?(0,Q.jsx)(U,{variant:`outline`,className:`oc-access__role`,children:pe()}):null,(0,Q.jsx)(U,{variant:`outline`,className:`oc-access__role`,children:Pt(e.role)}),t?de(e.userId,n.primary):null,(0,Q.jsx)(`span`,{className:`oc-access__mgrslot`,children:t?(0,Q.jsx)(B,{type:`button`,variant:`ghost`,size:`icon`,className:`shrink-0 oc-access__mgr${r?` oc-access__mgr--on`:``}`,"aria-pressed":r,"aria-label":r?it():O(),title:r?it():O(),onClick:()=>void ce(e.userId,r),children:(0,Q.jsx)(G,{size:15,"aria-hidden":!0})}):null})]},e._id)})}),(0,Q.jsx)($,{page:F.page,pageCount:F.pageCount,onPage:D})]})]}):e?(0,Q.jsx)(un,{groupId:e,members:i.members,agentsButton:de}):null}),(0,Q.jsxs)(Bt,{value:`agents`,children:[i&&!a?(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:tt()}):null,o===void 0?(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:R()}):o.length===0?(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:Pe()}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(V,{value:x,onChange:e=>C(e.target.value),placeholder:fe(),className:`oc-access__search`}),(0,Q.jsx)(`div`,{className:`oc-access__list`,children:o.map(t=>(0,Q.jsx)(fn,{groupId:e,instanceName:t.name,kind:t.kind??`openclaw`,assigned:M,defaultKey:oe,viewerIsAdmin:a,query:x},`${e}-${t._id}`))})]})]}),(0,Q.jsx)(Bt,{value:`charts`,children:(0,Q.jsx)(mn,{groupId:e})})]}),(0,Q.jsx)(dn,{groupId:e,member:ee,onOpenChange:e=>{e||k(null)}})]})})}function un({groupId:e,members:t,agentsButton:n}){let r=c(z.groupInvites.listGroupInviteRequests,{groupId:e}),i=I(z.groupInvites.requestGroupInvite),a=I(z.groups.removeMember),o=Wt(),s=J(),[l,u]=(0,Z.useState)(``),[d,p]=(0,Z.useState)(1),m=zt(t,d,cn);async function g(t){t.preventDefault();let n=l.trim();if(n)try{await i({groupId:e,email:n}),u(``),s.success(_())}catch(e){s.error(ce(),e)}}async function v(t,n){if(await o({title:N({user:n}),description:h({user:n}),confirmLabel:he(),cancelLabel:C(),destructive:!0}))try{await a({groupId:e,userId:t})}catch(e){s.error(S(),H(e))}}return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`form`,{className:`oc-access__invite`,onSubmit:e=>void g(e),children:[(0,Q.jsx)(V,{type:`email`,value:l,onChange:e=>u(e.target.value),placeholder:A(),"aria-label":Ct()}),(0,Q.jsxs)(B,{type:`submit`,size:`sm`,disabled:!l.trim(),children:[(0,Q.jsx)(Dt,{size:14,"aria-hidden":!0}),T()]})]}),(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:de()}),t.length===0?(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:vt()}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`oc-access__list`,children:m.pageItems.map(e=>(0,Q.jsxs)(`div`,{className:`oc-access__row`,children:[(0,Q.jsx)(`span`,{className:`oc-access__label`,title:e.label,children:e.label}),e.restricted?(0,Q.jsx)(U,{variant:`outline`,className:`oc-access__role`,children:pe()}):null,n(e.userId,e.label),(0,Q.jsx)(`span`,{className:`oc-access__mgrslot`,children:e.manager?(0,Q.jsx)(`span`,{className:`oc-access__mgr oc-access__mgr--on`,role:`img`,"aria-label":Ee(),title:Ee(),children:(0,Q.jsx)(G,{size:15,"aria-hidden":!0})}):null}),(0,Q.jsx)(B,{type:`button`,variant:`ghost`,size:`icon-sm`,disabled:e.manager||e.lastGroup,"aria-label":N({user:e.label}),title:e.manager?f():e.lastGroup?y():N({user:e.label}),onClick:()=>void v(e.userId,e.label),children:(0,Q.jsx)(wt,{size:14,"aria-hidden":!0})})]},e.userId))}),(0,Q.jsx)($,{page:m.page,pageCount:m.pageCount,onPage:p})]}),r!==void 0&&r.length>0?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`p`,{className:`oc-access__subhead`,children:M()}),(0,Q.jsx)(`div`,{className:`oc-access__list`,children:r.map(e=>(0,Q.jsxs)(`div`,{className:`oc-access__row`,children:[(0,Q.jsx)(`span`,{className:`oc-access__label`,title:e.email,children:e.email}),(0,Q.jsx)(U,{variant:e.status===`pending`?`secondary`:`outline`,className:`oc-access__role`,children:Rt(e.status)})]},e._id))})]}):null]})}function dn({groupId:e,member:t,onOpenChange:n}){let i=c(z.groups.getMemberAgentSettings,e&&t?{groupId:e,userId:t.userId}:`skip`),a=I(z.groups.setMemberAgents),o=I(z.groups.setMemberDefaultAgent),s=J();async function l(e){try{await e()}catch(e){s.error(k(),e)}}let u=i?.agents??[],d=new Map(u.map(e=>[q(e.instanceName,e.agentId),e])),f=[...d.keys()],p=new Set(u.filter(e=>e.allowed).map(e=>q(e.instanceName,e.agentId)));function m(n){if(!e||!t||!i)return;let r=Lt(f,p,i.restricted,n).map(e=>{let t=d.get(e);return{instanceName:t.instanceName,agentId:t.agentId}});l(()=>a({groupId:e,userId:t.userId,agents:r}))}return(0,Q.jsx)(Et,{open:t!==null,onOpenChange:n,children:(0,Q.jsxs)($t,{className:`oc-access`,children:[(0,Q.jsxs)(Ot,{children:[(0,Q.jsx)(Nt,{children:ut({user:t?.label??``})}),(0,Q.jsx)(It,{children:Re()})]}),i===void 0?(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:R()}):i===null||u.length===0?(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:rt()}):(0,Q.jsxs)(Q.Fragment,{children:[i.settable?null:(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:w()}),i.adminNarrowed?(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:St()}):null,i.restrictedByAdmin&&!i.viewerIsAdmin?(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:re()}):null,(0,Q.jsxs)(`div`,{className:`oc-access__row oc-access__selectall`,children:[(0,Q.jsx)(`span`,{className:`oc-access__label`,children:i.restricted?P():r()}),i.restricted?(0,Q.jsx)(B,{type:`button`,size:`sm`,variant:`outline`,disabled:!i.settable||i.restrictedByAdmin&&!i.viewerIsAdmin,onClick:()=>e&&t?void l(()=>a({groupId:e,userId:t.userId,agents:null})):void 0,children:De()}):null]}),(0,Q.jsx)(`div`,{className:`oc-access__list`,children:u.map(n=>{let r=q(n.instanceName,n.agentId),a=n.displayName??n.agentId;return(0,Q.jsxs)(`div`,{className:`oc-access__row`,children:[(0,Q.jsx)(W,{checked:n.allowed,disabled:!i.settable||i.restrictedByAdmin&&!i.viewerIsAdmin&&!n.allowed,onCheckedChange:()=>m(r),"aria-label":Se({name:a})}),(0,Q.jsx)(`span`,{className:`oc-access__label`,title:a,children:a}),n.limitedByAdmin?(0,Q.jsx)(U,{variant:`outline`,className:`oc-access__role`,children:ue()}):null,n.state===`deleted`?(0,Q.jsx)(U,{variant:`outline`,className:`oc-access__gone`,children:Ue()}):null,n.allowed?n.isMemberDefault?(0,Q.jsx)(B,{type:`button`,size:`icon-sm`,variant:`ghost`,className:`oc-access__fav`,disabled:!i.settable,"aria-label":Te(),title:Te(),onClick:()=>e&&t?void l(()=>o({groupId:e,userId:t.userId,agent:null})):void 0,children:(0,Q.jsx)(Y,{size:14,fill:`currentColor`})}):(0,Q.jsx)(B,{type:`button`,size:`icon-sm`,variant:`ghost`,className:`oc-access__setdefault`,disabled:!i.settable,"aria-label":D(),title:D(),onClick:()=>e&&t?void l(()=>o({groupId:e,userId:t.userId,agent:{instanceName:n.instanceName,agentId:n.agentId}})):void 0,children:(0,Q.jsx)(Y,{size:14})}):null]},r)})})]})]})})}function fn({groupId:e,instanceName:t,kind:n,assigned:r,defaultKey:i,viewerIsAdmin:a,query:o}){let s=c(z.groups.listAssignableAgents,e?{instanceName:t,groupId:e}:`skip`),l=I(z.groups.assignAgentToGroup),u=I(z.groups.removeAgentFromGroup),d=I(z.groups.bulkSetGroupAgents),f=I(z.groups.claimAgentForGroup),p=I(z.groups.setGroupDefaultAgent),m=J(),[h,g]=(0,Z.useState)(1);if((0,Z.useEffect)(()=>{g(1)},[o]),!e)return null;let _=jt(s?.agents??[],o),v=s?.discovery&&!s.discovery.lastPollOk,y=e=>At({assigned:r.has(q(t,e.agentId)),claimable:e.claimable,reservedForGroup:e.reservedForGroup,enabled:e.enabled,present:e.presentInLastOk!==!1},a),b=_.filter(e=>y(e)!==`claim`),x=_.filter(e=>y(e)===`claim`);if(o.trim()&&_.length===0)return null;let S=b.filter(e=>y(e)===`toggle`&&e.presentInLastOk!==!1&&e.enabled!==!1),C=Tt(S,e=>r.has(q(t,e.agentId))),w=zt(b,h,cn);async function T(n,r){try{r?await u({groupId:e,instanceName:t,agentId:n}):await l({groupId:e,instanceName:t,agentId:n})}catch(e){m.error(ye(),H(e))}}async function E(){if(S.length===0)return;let n=S.map(e=>e.agentId);try{await d({groupId:e,instanceName:t,agentIds:n,assigned:C!==`all`})}catch(e){m.error(ye(),H(e))}}async function D(n){try{await f({groupId:e,instanceName:t,agentId:n})}catch(e){m.error(Fe(),e)}}async function O(n){try{await p({groupId:e,agent:n===null?null:{instanceName:t,agentId:n}})}catch(e){m.error(Ze(),e)}}let ee=e=>e.reservedForGroup?(0,Q.jsx)(U,{variant:`outline`,className:`oc-access__role`,children:ct()}):e.reserved?(0,Q.jsx)(U,{variant:`outline`,className:`oc-access__role`,children:e.reservedGroupName===null?Me():$e({group:e.reservedGroupName})}):null;return(0,Q.jsxs)(`div`,{className:`oc-access__group`,children:[(0,Q.jsxs)(`div`,{className:`oc-access__instance`,children:[(0,Q.jsx)(K,{size:13,"aria-hidden":!0}),(0,Q.jsx)(`span`,{children:t}),(0,Q.jsx)(U,{variant:`outline`,className:`oc-access__kind`,children:n}),v?(0,Q.jsx)(U,{variant:`outline`,className:`oc-access__stale`,children:je()}):null]}),s===void 0?(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:dt()}):_.length===0?(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:v?Qe():st()}):(0,Q.jsxs)(Q.Fragment,{children:[S.length>1?(0,Q.jsxs)(`div`,{className:`oc-access__row oc-access__selectall`,children:[(0,Q.jsx)(W,{checked:C===`all`?!0:C===`some`?`indeterminate`:!1,onCheckedChange:()=>void E(),"aria-label":L()}),(0,Q.jsx)(`span`,{className:`oc-access__label`,children:L()})]}):null,w.pageItems.map(e=>{let n=q(t,e.agentId),a=r.has(n),o=e.presentInLastOk===!1,s=y(e)===`locked`;return(0,Q.jsxs)(`div`,{className:`oc-access__row${s?` is-disabled`:``}`,children:[(0,Q.jsx)(W,{checked:a,disabled:s&&!a,onCheckedChange:()=>void T(e.agentId,a),"aria-label":ze({name:e.displayName??e.agentId})}),(0,Q.jsxs)(`span`,{className:`oc-access__label`,title:e.displayName??e.agentId,children:[e.emoji?`${e.emoji} `:``,e.displayName??e.agentId]}),e.model?(0,Q.jsx)(`span`,{className:`oc-access__model`,children:e.model}):null,ee(e),o?(0,Q.jsx)(U,{variant:`outline`,className:`oc-access__gone`,children:Ue()}):null,a?i===n?(0,Q.jsx)(B,{type:`button`,size:`icon-sm`,variant:`ghost`,className:`oc-access__fav`,"aria-label":We(),title:We(),onClick:()=>void O(null),children:(0,Q.jsx)(Y,{size:14,fill:`currentColor`})}):(0,Q.jsx)(B,{type:`button`,size:`icon-sm`,variant:`ghost`,className:`oc-access__setdefault`,"aria-label":ot(),title:ot(),onClick:()=>void O(e.agentId),children:(0,Q.jsx)(Y,{size:14})}):null]},e.agentId)}),(0,Q.jsx)($,{page:w.page,pageCount:w.pageCount,onPage:g}),x.length>0?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`p`,{className:`oc-access__subhead`,children:Be()}),(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:Ie()}),x.map(e=>{let t=e.displayName??e.agentId;return(0,Q.jsxs)(`div`,{className:`oc-access__row`,children:[(0,Q.jsxs)(`span`,{className:`oc-access__label`,title:t,children:[e.emoji?`${e.emoji} `:``,t]}),e.model?(0,Q.jsx)(`span`,{className:`oc-access__model`,children:e.model}):null,(0,Q.jsx)(B,{type:`button`,size:`sm`,variant:`outline`,className:`h-7`,"aria-label":Je({name:t}),onClick:()=>void D(e.agentId),children:ft()})]},e.agentId)})]}):null]})]})}function pn(){let e=c(z.groupInvites.listPendingInviteRequests,{}),t=I(z.groupInvites.decideGroupInvite),n=J();if(e===void 0||e.length===0)return null;async function r(e,r){try{await t({requestId:e,approve:r})}catch(e){n.error(Ye(),e)}}return(0,Q.jsxs)(`section`,{className:`oc-invites`,"aria-label":Ne(),children:[(0,Q.jsxs)(`h3`,{className:`oc-invites__title`,children:[(0,Q.jsx)(Dt,{size:14,"aria-hidden":!0}),Ne(),(0,Q.jsx)(U,{variant:`secondary`,children:e.length})]}),(0,Q.jsx)(`div`,{className:`oc-access__list`,children:e.map(e=>(0,Q.jsxs)(`div`,{className:`oc-access__row`,children:[(0,Q.jsxs)(`span`,{className:`oc-access__who`,children:[(0,Q.jsx)(`span`,{className:`oc-access__label`,title:e.email,children:e.email}),(0,Q.jsxs)(`span`,{className:`oc-access__sub`,children:[e.groupName??`?`,` ·`,` `,bt({by:e.requestedBy})]})]}),e.account===`ready`?null:(0,Q.jsx)(U,{variant:`outline`,className:`oc-access__role`,children:e.account===`none`?Ve():He()}),(0,Q.jsx)(B,{type:`button`,size:`sm`,variant:`outline`,className:`h-7`,disabled:e.account!==`ready`,onClick:()=>void r(e._id,!0),children:mt()}),(0,Q.jsx)(B,{type:`button`,size:`sm`,variant:`ghost`,className:`h-7`,onClick:()=>void r(e._id,!1),children:Ae()})]},e._id))})]})}function mn({groupId:e}){let t=c(z.charts.listGroupChartSelection,e?{groupId:e}:`skip`),n=I(z.charts.assignChartToGroup),r=I(z.charts.removeChartFromGroup),a=I(z.charts.setGroupDefaultChart),o=I(z.charts.addChartToGroupPool),s=I(z.charts.removeChartFromGroupPool),l=J();if(!e)return null;if(t===void 0)return(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:R()});let{pool:u,addable:d,canManagePool:f}=t;if(u.length===0&&!f)return(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:Xe()});async function p(t,i){try{i?await r({groupId:e,chartKey:t}):await n({groupId:e,chartKey:t})}catch(e){l.error(b(),e)}}async function m(t){try{await a({groupId:e,chartKey:t})}catch(e){l.error(b(),e)}}async function h(t){try{await o({groupId:e,chartKey:t})}catch(e){l.error(b(),e)}}async function g(t){try{await s({groupId:e,chartKey:t})}catch(e){l.error(b(),e)}}return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`oc-access__list`,children:u.map(e=>(0,Q.jsxs)(`div`,{className:`oc-access__row`,children:[(0,Q.jsx)(W,{checked:e.selected,onCheckedChange:()=>void p(e.chartKey,e.selected),"aria-label":le({name:e.name})}),(0,Q.jsx)(`span`,{className:`oc-access__label`,title:e.name,children:e.name}),e.selected?e.isDefault?(0,Q.jsx)(`span`,{className:`oc-access__fav`,role:`img`,"aria-label":Oe(),title:Oe(),children:(0,Q.jsx)(Y,{size:14,fill:`currentColor`})}):(0,Q.jsx)(B,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>void m(e.chartKey),children:Ce()}):null,f?(0,Q.jsx)(B,{type:`button`,variant:`ghost`,size:`sm`,"aria-label":i({name:e.name}),title:i({name:e.name}),onClick:()=>void g(e.chartKey),children:(0,Q.jsx)(wt,{size:14,"aria-hidden":!0})}):null]},e.chartKey))}),f?d.length>0?(0,Q.jsxs)(Qt,{value:``,onValueChange:e=>void h(e),children:[(0,Q.jsx)(en,{size:`sm`,className:`oc-access__search`,children:(0,Q.jsx)(Ft,{placeholder:Le()})}),(0,Q.jsx)(tn,{children:d.map(e=>(0,Q.jsx)(Ht,{value:e.chartKey,children:e.name},e.chartKey))})]}):u.length===0?(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:lt()}):null:null]})}export{sn as GroupsTab};
@@ -1 +0,0 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$N as r,$P as i,$a as a,A as o,AN as s,AP as c,BN as l,BP as u,CF as d,CP as f,CY as p,D as m,DP as h,EP as g,F as _,FN as v,FP as y,Fp as b,Fv as x,GN as S,GP as C,HN as w,HP as T,IN as E,IP as ee,Ip as te,JN as ne,JP as re,KN as ie,KP as ae,LN as oe,LP as se,Lp as ce,M as le,MN as ue,MP as de,N as fe,NN as D,NP as pe,Nv as me,O as he,OP as ge,P as _e,PN as ve,PP as O,Pp as ye,Pv as be,QN as xe,QP as Se,Qa as Ce,RN as we,RP as Te,SF as Ee,SP as De,SY as k,TP as Oe,UN as ke,UP as Ae,VN as je,VP as Me,WN as Ne,WP as Pe,XN as Fe,XP as Ie,YN as Le,YP as Re,ZN as ze,ZP as Be,Za as Ve,_F as He,_P as Ue,aF as We,aP as A,ao as Ge,bF as Ke,bP as qe,bY as j,cF as Je,cP as Ye,cn as Xe,co as Ze,dF as Qe,dP as $e,dn as et,do as tt,eF as nt,eP as rt,eo as it,fF as at,fP as ot,fn as st,fo as ct,gF as lt,gP as ut,gk as dt,gn as ft,hF as pt,hP as mt,hk as ht,hn as gt,iF as _t,io as vt,iu as yt,j as bt,jN as xt,jP as St,k as Ct,kN as wt,kP as Tt,lF as Et,lP as Dt,ln as Ot,lo as kt,mF as At,mP as jt,mn as Mt,nF as Nt,nP as Pt,no as Ft,nu as It,oF as Lt,oP as Rt,oo as zt,pF as Bt,pP as Vt,pn as Ht,po as Ut,qN as Wt,qP as Gt,rF as Kt,rP as qt,ro as Jt,ru as Yt,sF as Xt,sP as Zt,sn as Qt,so as $t,t as M,tF as en,tP as tn,to as nn,uF as N,uP as P,un as rn,uo as an,vF as on,vH as F,vP as sn,wF as cn,wP as ln,xF as un,xP as dn,yF as fn,yH as I,yP as pn,zN as mn,zP as hn}from"./api-IF2KQFNF.js";import{a as gn,c as _n}from"./FieldLabel-BVUMb8MI.js";import{t as L}from"./button-DDPt-po9.js";import{$t as R,Ct as vn,Dt as yn,J as bn,Jt as z,Mt as B,Ot as V,St as H,Tt as U,Yt as W,b as xn,bt as G,cn as Sn,ct as Cn,on as wn,sn as Tn,vt as K,wt as En,xt as q,yt as J}from"./index-DaLXKABQ.js";import{t as Dn}from"./DataTableShell-Dc3I5mkG.js";import{InstanceConfigDialog as On}from"./BridgeTab-1RNCxXv2.js";var Y=t(e(),1),X=[`conversational`,`documentary`,`summarizer`,`curator`],kn=new Set(X),An=`conversational`;function jn(e){let t=new Set((e??[]).filter(e=>kn.has(e)));return t.size===0?[An]:X.filter(e=>t.has(e))}var Z=n(),Q={name:``,gatewayUrl:``,bridgeUrl:``,displayName:``,kind:`openclaw`,transport:`ws`,gatewayVersion:``,gatewayHttpUrl:``,authMode:`token`,personScopes:`capped`,identitySource:`canonical`,participantIdentity:`owner`,managePermissionModes:!1,systemIdentity:``,streamTransport:gn,widgetsEnabled:!0,widgetPromptConfirm:!1},Mn={openclaw:[`token`,`deviceIdentity`],hermes:[`apiKey`]};function Nn(e){return{name:e.name,gatewayUrl:e.gatewayUrl,bridgeUrl:e.bridgeUrl??``,displayName:e.displayName??``,kind:e.kind??`openclaw`,transport:e.transport??`ws`,gatewayVersion:e.gatewayVersion??``,gatewayHttpUrl:e.gatewayHttpUrl??``,authMode:e.authMode??`token`,personScopes:e.personScopes??`capped`,identitySource:e.identitySource??`canonical`,participantIdentity:e.participantIdentity??`owner`,managePermissionModes:e.managePermissionModes===!0,systemIdentity:e.systemIdentity??``,streamTransport:e.streamTransport??`reactive`,widgetsEnabled:e.config?.widgetsEnabled!==!1,widgetPromptConfirm:e.config?.widgetPromptConfirm===!0}}function Pn(){let e=p(M.admin.listInstances,{}),t=p(M.agents.listAllInstanceAgents,{}),n=k(M.admin.upsertInstance),r=k(M.widgets.setInstanceWidgets),s=k(M.admin.deleteInstance),c=W(),[l,u]=(0,Y.useState)(!1),[f,h]=(0,Y.useState)(Q),[g,v]=(0,Y.useState)(null),[y,b]=(0,Y.useState)(null),[x,S]=(0,Y.useState)(null),[C,w]=(0,Y.useState)(null);async function T(){try{let t=await n({instanceId:C??void 0,name:f.name,gatewayUrl:f.gatewayUrl,bridgeUrl:f.bridgeUrl||void 0,displayName:f.displayName||void 0,kind:f.kind,transport:f.kind===`hermes`?f.transport:void 0,gatewayVersion:f.gatewayVersion||void 0,gatewayHttpUrl:f.gatewayHttpUrl||void 0,...f.kind===`openclaw`?{authMode:f.authMode,personScopes:f.personScopes,identitySource:f.identitySource,participantIdentity:f.participantIdentity,managePermissionModes:f.managePermissionModes,systemIdentity:f.systemIdentity||void 0}:{},streamTransport:f.streamTransport}),i=C===null?null:e?.find(e=>e._id===C),a=i?.config?.widgetsEnabled!==!1,o=i?.config?.widgetPromptConfirm===!0;f.kind===`openclaw`&&(f.widgetsEnabled!==a||f.widgetPromptConfirm!==o)&&await r({instanceId:t,enabled:f.widgetsEnabled,promptConfirm:f.widgetPromptConfirm}),h(Q),w(null),u(!1)}catch(e){c.error(Ee(),e)}}return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`p`,{className:`oc-admin__hint`,children:[un(),(0,Z.jsx)(`strong`,{children:Ke()}),fn()]}),(0,Z.jsx)(Dn,{title:on(),rows:e,addLabel:He(),onAdd:()=>{w(null),h(Q),u(!0)},emptyHint:lt(),columns:[{header:pt(),cell:e=>e.name,sort:e=>e.name},{header:At(),cell:e=>(0,Z.jsx)(z,{variant:`outline`,children:e.kind??`openclaw`}),sort:e=>e.kind??`openclaw`},{header:Bt(),cell:e=>e.gatewayUrl,sort:e=>e.gatewayUrl},{header:at(),cell:e=>e.displayName??`—`,sort:e=>e.displayName??null},{header:cn(),cell:e=>{let n=(t?.[e.name]??[]).filter(e=>e.presentInLastOk!==!1&&e.enabled);if(n.length===0)return(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:`—`});let r=t=>e.defaultAgentId===t;return(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:[...n].sort((e,t)=>Number(r(t.agentId))-Number(r(e.agentId))).map(e=>(0,Z.jsxs)(z,{variant:r(e.agentId)?`default`:`outline`,title:r(e.agentId)?E():void 0,children:[e.emoji?`${e.emoji} `:``,e.displayName??e.agentId]},e.agentId))})}}],rowActions:e=>[{label:Je(),onSelect:()=>{w(e._id),h(Nn(e)),u(!0)}},{label:d(),onSelect:()=>v(e.name)},{label:Gt(),onSelect:()=>S(e)},{label:Qe(),onSelect:()=>b(e)},{label:N(),variant:`destructive`,onSelect:()=>void s({instanceId:e._id})}],bulkActions:[{label:N(),variant:`destructive`,onSelect:e=>e.forEach(e=>void s({instanceId:e}))}]}),(0,Z.jsx)(xn,{open:l,onOpenChange:u,title:C?Xt():Et(),description:We(),canSubmit:!!(f.name&&f.gatewayUrl),onSubmit:T,submitLabel:_t(),children:(0,Z.jsxs)(`div`,{className:`oc-form`,children:[(0,Z.jsxs)($,{label:Kt(),children:[(0,Z.jsx)(R,{value:f.name,disabled:C!==null,onChange:e=>h({...f,name:e.target.value})}),C?(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:Lt()}):null]}),(0,Z.jsx)($,{label:Nt(),children:(0,Z.jsxs)(K,{value:f.kind,onValueChange:e=>h({...f,kind:e}),children:[(0,Z.jsx)(q,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(H,{})}),(0,Z.jsxs)(J,{children:[(0,Z.jsx)(G,{value:`openclaw`,children:`OpenClaw`}),(0,Z.jsx)(G,{value:`hermes`,children:`Hermes`})]})]})}),f.kind===`hermes`?(0,Z.jsx)($,{label:yt(),children:(0,Z.jsxs)(K,{value:f.transport,onValueChange:e=>h({...f,transport:e}),children:[(0,Z.jsx)(q,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(H,{})}),(0,Z.jsxs)(J,{children:[(0,Z.jsx)(G,{value:`ws`,children:Yt()}),(0,Z.jsx)(G,{value:`rest`,children:It()})]})]})}):null,(0,Z.jsx)($,{label:en(),children:(0,Z.jsx)(R,{value:f.gatewayUrl,onChange:e=>h({...f,gatewayUrl:e.target.value})})}),(0,Z.jsx)($,{label:nt(),children:(0,Z.jsx)(R,{value:f.bridgeUrl,placeholder:i(),onChange:e=>h({...f,bridgeUrl:e.target.value})})}),(0,Z.jsx)($,{label:Se(),children:(0,Z.jsx)(R,{value:f.displayName,onChange:e=>h({...f,displayName:e.target.value})})}),(0,Z.jsxs)($,{label:dt(),children:[(0,Z.jsxs)(K,{value:f.streamTransport,onValueChange:e=>h({...f,streamTransport:e}),children:[(0,Z.jsx)(q,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(H,{})}),(0,Z.jsx)(J,{children:_n.map(e=>(0,Z.jsx)(G,{value:e,children:e},e))})]}),(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:ht()})]}),(0,Z.jsx)($,{label:Be(),children:(0,Z.jsx)(R,{value:f.gatewayVersion,placeholder:Ie(),onChange:e=>h({...f,gatewayVersion:e.target.value})})}),f.kind===`openclaw`?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)($,{label:Jt(),children:[(0,Z.jsxs)(K,{value:f.authMode,onValueChange:e=>h({...f,authMode:e}),children:[(0,Z.jsx)(q,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(H,{})}),(0,Z.jsxs)(J,{children:[(0,Z.jsx)(G,{value:`token`,children:Ft()}),(0,Z.jsx)(G,{value:`trusted-proxy`,children:nn()})]})]}),(0,Z.jsx)(`p`,{className:`oc-field__hint`,children:f.authMode===`trusted-proxy`?a():it()})]}),f.authMode===`trusted-proxy`?(0,Z.jsxs)($,{label:Ut(),children:[(0,Z.jsxs)(K,{value:f.personScopes,onValueChange:e=>h({...f,personScopes:e}),children:[(0,Z.jsx)(q,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(H,{})}),(0,Z.jsxs)(J,{children:[(0,Z.jsx)(G,{value:`capped`,children:ct()}),(0,Z.jsx)(G,{value:`full`,children:tt()})]})]}),(0,Z.jsx)(`p`,{className:`oc-field__hint`,children:f.personScopes===`full`?kt():an()})]}):null,f.authMode===`trusted-proxy`?(0,Z.jsxs)($,{label:Ze(),children:[(0,Z.jsxs)(K,{value:f.identitySource,onValueChange:e=>h({...f,identitySource:e}),children:[(0,Z.jsx)(q,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(H,{})}),(0,Z.jsxs)(J,{children:[(0,Z.jsx)(G,{value:`canonical`,children:$t()}),(0,Z.jsx)(G,{value:`email`,children:zt()})]})]}),(0,Z.jsx)(`p`,{className:`oc-field__hint`,children:f.identitySource===`email`?vt():Ge()})]}):null,f.authMode===`trusted-proxy`?(0,Z.jsxs)($,{label:ft(),children:[(0,Z.jsxs)(K,{value:f.participantIdentity,onValueChange:e=>h({...f,participantIdentity:e}),children:[(0,Z.jsx)(q,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(H,{})}),(0,Z.jsxs)(J,{children:[(0,Z.jsx)(G,{value:`owner`,children:gt()}),(0,Z.jsx)(G,{value:`self`,children:Mt()})]})]}),(0,Z.jsx)(`p`,{className:`oc-field__hint`,children:f.participantIdentity===`self`?Qt():Ht()})]}):null,f.kind===`openclaw`?(0,Z.jsxs)($,{label:st(),children:[(0,Z.jsxs)(K,{value:f.managePermissionModes?`on`:`off`,onValueChange:e=>h({...f,managePermissionModes:e===`on`}),children:[(0,Z.jsx)(q,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(H,{})}),(0,Z.jsxs)(J,{children:[(0,Z.jsx)(G,{value:`off`,children:et()}),(0,Z.jsx)(G,{value:`on`,children:rn()})]})]}),(0,Z.jsx)(`p`,{className:`oc-field__hint`,children:f.managePermissionModes?Xe():Ot()})]}):null,f.kind===`openclaw`?(0,Z.jsxs)($,{label:_(),children:[(0,Z.jsxs)(K,{value:f.widgetsEnabled?`on`:`off`,onValueChange:e=>h({...f,widgetsEnabled:e===`on`}),children:[(0,Z.jsx)(q,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(H,{})}),(0,Z.jsxs)(J,{children:[(0,Z.jsx)(G,{value:`on`,children:_e()}),(0,Z.jsx)(G,{value:`off`,children:fe()})]})]}),(0,Z.jsx)(`p`,{className:`oc-field__hint`,children:f.widgetsEnabled?le():bt()})]}):null,f.kind===`openclaw`&&f.widgetsEnabled?(0,Z.jsxs)($,{label:o(),children:[(0,Z.jsxs)(K,{value:f.widgetPromptConfirm?`on`:`off`,onValueChange:e=>h({...f,widgetPromptConfirm:e===`on`}),children:[(0,Z.jsx)(q,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(H,{})}),(0,Z.jsxs)(J,{children:[(0,Z.jsx)(G,{value:`off`,children:Ct()}),(0,Z.jsx)(G,{value:`on`,children:he()})]})]}),(0,Z.jsx)(`p`,{className:`oc-field__hint`,children:m()})]}):null,f.authMode===`trusted-proxy`?(0,Z.jsx)($,{label:Ce(),children:(0,Z.jsx)(R,{value:f.systemIdentity,placeholder:Ve(),onChange:e=>h({...f,systemIdentity:e.target.value})})}):null]}):null,(0,Z.jsx)($,{label:Re(),children:(0,Z.jsx)(R,{value:f.gatewayHttpUrl,placeholder:re(),onChange:e=>h({...f,gatewayHttpUrl:e.target.value})})})]})}),(0,Z.jsx)(Wn,{instanceName:g,open:g!==null,onOpenChange:e=>{e||v(null)}}),y?(0,Z.jsx)(On,{instance:y,onClose:()=>b(null)},y._id):null,x?(0,Z.jsx)(Fn,{instance:x,onClose:()=>S(null)},x._id):null]})}function Fn({instance:e,onClose:t}){let n=p(M.instanceSecrets.listInstanceSecretStatus,{}),r=Mn[e.kind??`openclaw`],i=(0,Y.useMemo)(()=>{let t={};for(let r of n??[])r.instanceId===e._id&&(t[r.field]=r.updatedAt);return t},[n,e._id]);return(0,Z.jsx)(vn,{open:!0,onOpenChange:e=>!e&&t(),children:(0,Z.jsxs)(En,{onOpenAutoFocus:e=>e.preventDefault(),children:[(0,Z.jsxs)(yn,{children:[(0,Z.jsx)(V,{children:ae({instance:e.displayName??e.name})}),(0,Z.jsx)(U,{children:C()})]}),(0,Z.jsx)(`div`,{className:`oc-form`,children:r.map(t=>(0,Z.jsx)(Rn,{instanceId:e._id,field:t,updatedAt:i[t]??null},t))}),(0,Z.jsx)(`div`,{className:`oc-bridgesecret`,children:(0,Z.jsx)(Ln,{instance:e})}),(0,Z.jsx)(In,{instance:e})]})})}function In({instance:e}){let t=j(M.instanceSync.forceInstanceSync),n=W(),[r,i]=(0,Y.useState)(!1);async function a(){if(!r){i(!0);try{switch((await t({instanceId:e._id})).status){case`synced`:n.success(Oe());break;case`no_agents`:n.success(f());break;case`no_bridge_url`:n.error(De());break;case`deploy_misconfigured`:n.error(dn());break;case`unauthorized`:n.error(pn());break;case`not_served`:n.error(sn());break;default:n.error(qe());break}}catch(e){n.error(ln(),e)}finally{i(!1)}}}return(0,Z.jsxs)(`div`,{className:`oc-form`,children:[(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:Ue()}),(0,Z.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,Z.jsx)(L,{size:`sm`,variant:`outline`,onClick:()=>void a(),disabled:r,children:r?g():h()})})]})}function Ln({instance:e}){let t=p(M.bridgeAuth.listBridgeAuthStatus,{}),n=j(M.bridgeAuth.mintBridgeSecret),r=k(M.bridgeAuth.revokeBridgeSecret),i=W(),[a,o]=(0,Y.useState)(!1),[s,c]=(0,Y.useState)(null),[l,d]=(0,Y.useState)(!1),f=(t??[]).find(t=>t.instanceId===e._id),m=f!==void 0;async function h(){if(!a){o(!0);try{c((await n({instanceId:e._id})).plaintext),d(!1)}catch(e){i.error(P(),e)}finally{o(!1)}}}async function g(){if(!a){o(!0);try{await r({instanceId:e._id}),c(null),i.success($e())}catch(e){i.error(P(),e)}finally{o(!1)}}}async function _(){if(s)try{await navigator.clipboard.writeText(s),d(!0)}catch{}}return(0,Z.jsxs)($,{label:ut(),children:[(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:mt()}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(z,{variant:m?`outline`:`secondary`,children:m?`${Me()} · ${f.prefix}…${f.lastFour}`:u()}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(L,{size:`sm`,onClick:()=>void h(),disabled:a,children:m?Vt():jt()}),m?(0,Z.jsx)(L,{size:`sm`,variant:`destructive`,onClick:()=>void g(),disabled:a,children:ot()}):null]})]}),s?(0,Z.jsxs)(`div`,{className:`oc-bridgesecret__reveal`,children:[(0,Z.jsx)(`p`,{className:`oc-sa__minted-warning`,children:Dt()}),(0,Z.jsxs)(`div`,{className:`oc-sa__minted-box`,children:[(0,Z.jsx)(`code`,{className:`oc-sa__minted-plain`,children:s}),(0,Z.jsx)(L,{variant:`outline`,size:`sm`,onClick:()=>void _(),children:l?I():F()})]}),(0,Z.jsx)(L,{size:`sm`,variant:`ghost`,onClick:()=>{c(null),d(!1)},children:Ye()})]}):null]})}function Rn({instanceId:e,field:t,updatedAt:n}){let r=j(M.instanceSecrets.setInstanceSecret),i=k(M.instanceSecrets.clearInstanceSecret),a=j(M.deviceIdentity.generateDeviceIdentity),o=W(),[s,l]=(0,Y.useState)(``),[d,f]=(0,Y.useState)(!1),[p,m]=(0,Y.useState)(null),[h,g]=(0,Y.useState)(!1),_=n!==null,v=t===`deviceIdentity`,b=t===`token`?Pe():t===`deviceIdentity`?Ae():T();async function x(){if(!(!s.trim()||d)){f(!0);try{await r({instanceId:e,field:t,plaintext:s}),l(``),m(null),g(!1),o.success(y())}catch(e){o.error(O(),e)}finally{f(!1)}}}async function S(){if(!d){f(!0);try{await i({instanceId:e,field:t}),m(null),g(!1),o.success(pe())}catch(e){o.error(O(),e)}finally{f(!1)}}}async function C(){if(!d){f(!0);try{m(await a({instanceId:e})),g(!1),o.success(c())}catch(e){o.error(ge(),e)}finally{f(!1)}}}let w=p?`openclaw devices approve ${p.id}`:``;async function E(){if(w)try{await navigator.clipboard.writeText(w),g(!0)}catch{}}return(0,Z.jsxs)($,{label:b,children:[v?(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:St()}):null,(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(z,{variant:_?`outline`:`secondary`,children:_?Me():u()}),(0,Z.jsx)(R,{type:`password`,autoComplete:`off`,className:`flex-1 min-w-32`,value:s,placeholder:_?Te():hn(),onChange:e=>l(e.target.value)}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(L,{size:`sm`,onClick:()=>void x(),disabled:d||s.trim().length===0,children:se()}),v?(0,Z.jsx)(L,{size:`sm`,variant:`outline`,onClick:()=>void C(),disabled:d,children:de()}):null,_?(0,Z.jsx)(L,{size:`sm`,variant:`destructive`,onClick:()=>void S(),disabled:d,children:ee()}):null]})]}),p?(0,Z.jsxs)(`div`,{className:`oc-bridgesecret__reveal`,children:[(0,Z.jsx)(`p`,{className:`text-sm font-medium`,children:c()}),(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:Tt()}),(0,Z.jsxs)(`div`,{className:`oc-sa__minted-box`,children:[(0,Z.jsx)(`code`,{className:`oc-sa__minted-plain`,children:w}),(0,Z.jsx)(L,{variant:`outline`,size:`sm`,onClick:()=>void E(),children:h?I():F()})]}),(0,Z.jsx)(L,{size:`sm`,variant:`ghost`,onClick:()=>{m(null),g(!1)},children:Ye()})]}):null]})}var zn={conversational:ze,documentary:Le,summarizer:ce,curator:b},Bn={conversational:Fe,documentary:ne,summarizer:te,curator:ye},Vn=e=>(zn[e]??(()=>e))(),Hn=e=>(Bn[e]??(()=>``))();function Un({agentId:e,types:t,onToggle:n}){return(0,Z.jsxs)(`div`,{className:`oc-agentcard__types`,children:[(0,Z.jsx)(`span`,{className:`oc-agentcard__types-label`,children:tn()}),t.map(e=>(0,Z.jsx)(z,{variant:`secondary`,className:`oc-agenttype__chip`,title:Hn(e),children:Vn(e)},e)),(0,Z.jsxs)(wn,{children:[(0,Z.jsx)(Sn,{asChild:!0,children:(0,Z.jsx)(L,{type:`button`,variant:`outline`,size:`sm`,className:`h-7`,children:rt()})}),(0,Z.jsxs)(Tn,{align:`start`,className:`oc-agenttypes-pop`,children:[(0,Z.jsx)(`p`,{className:`oc-agenttypes-pop__title`,children:r()}),(0,Z.jsx)(`p`,{className:`oc-agenttypes-pop__hint`,children:xe()}),(0,Z.jsx)(`div`,{className:`oc-agenttypes-pop__list`,children:X.map(r=>{let i=`agtype-${e}-${r}`;return(0,Z.jsxs)(`div`,{className:`oc-agenttypes-pop__item`,children:[(0,Z.jsx)(B,{id:i,checked:t.includes(r),onCheckedChange:()=>n(r)}),(0,Z.jsxs)(`label`,{htmlFor:i,className:`oc-agenttypes-pop__text`,children:[(0,Z.jsx)(`span`,{className:`oc-agenttypes-pop__name`,children:Vn(r)}),(0,Z.jsx)(`span`,{className:`oc-agenttypes-pop__desc`,children:Hn(r)})]})]},r)})})]})]})]})}function Wn({instanceName:e,open:t,onOpenChange:n}){let r=p(M.agents.listAgentsForInstance,t&&e?{instanceName:e}:`skip`),i=k(M.agents.setAgentEnabled).withOptimisticUpdate((e,{instanceName:t,agentId:n,enabled:r})=>{let i=e.getQuery(M.agents.listAgentsForInstance,{instanceName:t});i&&e.setQuery(M.agents.listAgentsForInstance,{instanceName:t},{...i,agents:i.agents.map(e=>e.agentId===n?{...e,enabled:r}:e)})}),a=k(M.agents.setInstanceDefaultAgent).withOptimisticUpdate((e,{instanceName:t,agentId:n})=>{let r=e.getQuery(M.agents.listAgentsForInstance,{instanceName:t});r&&e.setQuery(M.agents.listAgentsForInstance,{instanceName:t},{...r,defaultAgentId:n})}),o=k(M.agents.setAgentTypes).withOptimisticUpdate((e,{instanceName:t,agentId:n,types:r})=>{let i=e.getQuery(M.agents.listAgentsForInstance,{instanceName:t});if(!i)return;let a=jn(r);e.setQuery(M.agents.listAgentsForInstance,{instanceName:t},{...i,agents:i.agents.map(e=>e.agentId===n?{...e,types:a}:e)})}),c=k(M.agents.setAgentDescription).withOptimisticUpdate((e,{instanceName:t,agentId:n,description:r})=>{let i=e.getQuery(M.agents.listAgentsForInstance,{instanceName:t});if(!i)return;let a=r.trim();e.setQuery(M.agents.listAgentsForInstance,{instanceName:t},{...i,agents:i.agents.map(e=>e.agentId===n?{...e,description:a.length===0?null:a}:e)})}),u=k(M.agents.removeInstanceAgent),d=k(M.agents.setAgentReservation),f=p(M.groups.listGroupLabels,t?{}:`skip`),m=Cn(),h=W();async function g(t,n){if(e&&await m({title:ue({name:n}),description:xt(),confirmLabel:D()}))try{await d({instanceName:e,agentId:t,groupId:null})}catch(e){h.error(A(),bn(e))}}async function _(t,n,r){if(!e)return;let i=(f??[]).find(e=>e._id===r)?.name??`?`;if(await m({title:x({name:n,group:i}),description:be({group:i}),confirmLabel:me()}))try{await d({instanceName:e,agentId:t,groupId:r})}catch(e){h.error(A(),bn(e))}}async function y(t,n){if(e)try{await i({instanceName:e,agentId:t,enabled:n})}catch(e){h.error(A(),e)}}async function b(t){if(e)try{await a({instanceName:e,agentId:t})}catch(e){h.error(A(),e)}}async function C(t,n,r){if(!e)return;let i=r.includes(n)?r.filter(e=>e!==n):[...r,n];try{await o({instanceName:e,agentId:t,types:i})}catch(e){h.error(A(),e)}}async function T(t,n){if(e&&await m({title:S({name:n}),description:Ne(),confirmLabel:ke(),destructive:!0}))try{await u({instanceName:e,agentId:t}),h.success(w())}catch(e){h.error(A(),e)}}return(0,Z.jsx)(vn,{open:t,onOpenChange:n,children:(0,Z.jsxs)(En,{className:`oc-access`,children:[(0,Z.jsxs)(yn,{children:[(0,Z.jsx)(V,{children:Zt({name:e??``})}),(0,Z.jsx)(U,{children:Rt()})]}),r===void 0?(0,Z.jsx)(`p`,{className:`oc-access__hint`,children:je()}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`oc-access__poll`,children:r.discovery===null?l():r.discovery.lastPollOk?mn():we({error:r.discovery.error??`?`})}),r.agents.length===0?(0,Z.jsx)(`p`,{className:`oc-access__hint`,children:oe()}):(0,Z.jsx)(`div`,{className:`oc-access__list`,children:r.agents.map(t=>{let n=t.presentInLastOk===!1,i=r.defaultAgentId===t.agentId,a=t.displayName??t.agentId,o=t.types??[];return(0,Z.jsxs)(`div`,{className:`oc-agentcard`+(t.enabled?``:` oc-agentcard--off`),children:[(0,Z.jsxs)(`div`,{className:`oc-agentcard__head`,children:[(0,Z.jsx)(B,{checked:t.enabled,disabled:n,"aria-label":a,onCheckedChange:e=>void y(t.agentId,e===!0)}),(0,Z.jsxs)(`span`,{className:`oc-agentcard__name`,title:a,children:[t.emoji?`${t.emoji} `:``,a]}),t.model?(0,Z.jsx)(`span`,{className:`oc-access__model`,children:t.model}):null,t.reserved?(0,Z.jsx)(z,{variant:`outline`,children:t.reserved.groupName===null?ve():v({group:t.reserved.groupName})}):null,n?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(z,{variant:`outline`,className:`oc-access__gone`,children:wt()}),(0,Z.jsx)(L,{size:`sm`,variant:`ghost`,className:`h-7 text-destructive`,onClick:()=>void T(t.agentId,a),children:ie()})]}):i?(0,Z.jsx)(z,{variant:`default`,children:E()}):(0,Z.jsx)(L,{size:`sm`,variant:`outline`,className:`h-7`,disabled:!t.enabled||t.reserved!==null,onClick:()=>void b(t.agentId),children:Wt()})]}),t.reserved?(0,Z.jsxs)(`div`,{className:`oc-agentcard__head`,children:[(0,Z.jsx)(L,{size:`sm`,variant:`outline`,className:`h-7`,onClick:()=>void g(t.agentId,a),children:D()}),(0,Z.jsxs)(K,{value:``,onValueChange:e=>void _(t.agentId,a,e),children:[(0,Z.jsx)(q,{size:`sm`,className:`h-7`,children:(0,Z.jsx)(H,{placeholder:s()})}),(0,Z.jsx)(J,{children:(f??[]).filter(e=>e._id!==t.reserved?.groupId).map(e=>(0,Z.jsx)(G,{value:e._id,children:e.name},e._id))})]})]}):null,t.enabled?(0,Z.jsx)(Un,{agentId:t.agentId,types:o,onToggle:e=>void C(t.agentId,e,o)}):null,t.enabled?(0,Z.jsx)(Gn,{value:t.description??``,onSave:async n=>{if(e)try{await c({instanceName:e,agentId:t.agentId,description:n})}catch(e){h.error(A(),e)}}}):null]},t.agentId)})})]})]})})}function Gn({value:e,onSave:t}){let[n,r]=(0,Y.useState)(e);(0,Y.useEffect)(()=>{r(e)},[e]);let i=()=>{n.trim()!==e.trim()&&t(n)};return(0,Z.jsx)(R,{className:`oc-agentcard__desc`,value:n,maxLength:280,placeholder:qt(),"aria-label":Pt(),onChange:e=>r(e.target.value),onBlur:i,onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),i())}})}function $({label:e,children:t}){return(0,Z.jsxs)(`label`,{className:`oc-field`,children:[(0,Z.jsx)(`span`,{className:`oc-field__label`,children:e}),t]})}export{Pn as InstancesTab};
@@ -1 +0,0 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$m as r,CY as i,Qm as a,SY as o,Xm as s,Zm as c,aL as l,bY as u,cL as d,dL as f,eh as p,fL as m,hL as h,iL as g,ih as _,lL as v,mL as y,nL as b,nh as x,oL as S,pL as C,rL as w,rh as T,sL as E,t as D,th as O,uL as k}from"./api-IF2KQFNF.js";import{t as A}from"./button-DDPt-po9.js";import{$t as j,Jt as M,Mt as N}from"./index-DaLXKABQ.js";var P=t(e(),1),F=n();function I(){let e=i(D.integrations.status.status,{}),t=o(D.admin.setIntegrationConfig),[n,r]=(0,P.useState)(null);if((0,P.useEffect)(()=>{e&&n===null&&r(e.config)},[e,n]),!e||!n)return(0,F.jsx)(`p`,{className:`oc-admin__hint`,children:h()});let a=n,s=(e,t,n)=>r({...a,[e]:{...a[e],[t]:n}}),c=(e,n)=>void t({[e]:n});return(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`p`,{className:`oc-admin__hint`,children:[y(),` `,(0,F.jsx)(`strong`,{children:C()}),` `,m()]}),(0,F.jsxs)(L,{title:`Langfuse`,status:e.langfuse.configured?e.langfuse.enabled?(0,F.jsx)(M,{variant:`secondary`,children:f()}):(0,F.jsx)(M,{variant:`outline`,children:k()}):(0,F.jsx)(M,{variant:`outline`,children:v()}),note:d(),children:[(0,F.jsx)(R,{label:S(),children:(0,F.jsx)(j,{value:a.langfuse.host??``,placeholder:e.langfuse.effectiveHost,onChange:e=>s(`langfuse`,`host`,e.target.value),onBlur:()=>c(`langfuse`,{host:a.langfuse.host??``})})}),(0,F.jsx)(z,{label:b(),checked:a.langfuse.enabled??!0,onChange:e=>{s(`langfuse`,`enabled`,e),c(`langfuse`,{enabled:e})}})]}),(0,F.jsxs)(L,{title:`Opik`,status:e.opik.configured?e.opik.enabled?(0,F.jsx)(M,{variant:`secondary`,children:f()}):(0,F.jsx)(M,{variant:`outline`,children:k()}):(0,F.jsx)(M,{variant:`outline`,children:v()}),note:E(),children:[(0,F.jsx)(R,{label:l(),children:(0,F.jsx)(j,{value:a.opik.baseUrl??``,placeholder:e.opik.effectiveBaseUrl,onChange:e=>s(`opik`,`baseUrl`,e.target.value),onBlur:()=>c(`opik`,{baseUrl:a.opik.baseUrl??``})})}),(0,F.jsx)(R,{label:g(),children:(0,F.jsx)(j,{value:a.opik.workspace??``,placeholder:e.opik.effectiveWorkspace||w(),onChange:e=>s(`opik`,`workspace`,e.target.value),onBlur:()=>c(`opik`,{workspace:a.opik.workspace??``})})}),(0,F.jsx)(z,{label:b(),checked:a.opik.enabled??!0,onChange:e=>{s(`opik`,`enabled`,e),c(`opik`,{enabled:e})}})]}),(0,F.jsxs)(L,{title:`OpenTelemetry (OTLP)`,status:e.otlp.configured?e.otlp.enabled?(0,F.jsx)(M,{variant:`secondary`,children:f()}):(0,F.jsx)(M,{variant:`outline`,children:k()}):(0,F.jsx)(M,{variant:`outline`,children:_()}),note:T(),children:[(0,F.jsx)(R,{label:x(),children:(0,F.jsx)(j,{value:a.otlp.endpoint??``,placeholder:e.otlp.effectiveEndpoint||`https://otlp.example.com/v1/traces`,onChange:e=>s(`otlp`,`endpoint`,e.target.value),onBlur:()=>c(`otlp`,{endpoint:a.otlp.endpoint??``})})}),(0,F.jsx)(B,{headersSet:e.otlp.headersSet}),(0,F.jsx)(z,{label:b(),checked:a.otlp.enabled??!0,onChange:e=>{s(`otlp`,`enabled`,e),c(`otlp`,{enabled:e})}})]})]})}function L({title:e,status:t,note:n,children:r}){return(0,F.jsxs)(`section`,{className:`oc-int__section`,children:[(0,F.jsxs)(`div`,{className:`oc-int__section-head`,children:[(0,F.jsx)(`h3`,{className:`oc-uipa__h`,children:e}),t]}),n?(0,F.jsx)(`p`,{className:`oc-uipa__note`,children:n}):null,(0,F.jsx)(`div`,{className:`oc-int__fields`,children:r})]})}function R({label:e,children:t}){return(0,F.jsxs)(`label`,{className:`oc-int__field`,children:[(0,F.jsx)(`span`,{className:`oc-int__field-label`,children:e}),t]})}function z({label:e,checked:t,onChange:n}){return(0,F.jsxs)(`label`,{className:`oc-int__toggle`,children:[(0,F.jsx)(N,{checked:t,onCheckedChange:e=>n(e===!0)}),(0,F.jsx)(`span`,{children:e})]})}function B({headersSet:e}){let t=u(D.integrations.otlpSecret.setOtlpHeaders),n=o(D.integrations.otlpSecret.clearOtlpHeaders),[i,l]=(0,P.useState)(``),[d,f]=(0,P.useState)(null),[m,h]=(0,P.useState)(!1),g=async()=>{h(!0),f(null);try{await t({headersJson:i}),l(``)}catch(e){f(e instanceof Error?e.message:String(e))}finally{h(!1)}};return(0,F.jsxs)(R,{label:O(),children:[(0,F.jsx)(j,{value:i,placeholder:e?p():r(),onChange:e=>l(e.target.value)}),(0,F.jsxs)(`div`,{className:`oc-int__otlp-headers-actions`,children:[(0,F.jsx)(A,{size:`sm`,disabled:m||i.trim().length===0,onClick:()=>void g(),children:a()}),e?(0,F.jsx)(A,{variant:`ghost`,size:`sm`,disabled:m,onClick:()=>void n({}),children:c()}):null]}),d?(0,F.jsx)(`p`,{className:`oc-int__otlp-headers-error`,children:d}):null,(0,F.jsx)(`p`,{className:`oc-uipa__note`,children:s()})]})}export{I as IntegrationsTab};
@@ -1 +0,0 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$L as r,AD as i,CD as a,CY as o,DD as s,ED as c,HL as l,MD as u,ND as d,OD as f,QL as p,SD as m,TD as h,UL as g,XL as _,ZL as v,bD as ee,jD as te,kD as y,t as b,wD as x,wR as S,xD as C,yD as w}from"./api-IF2KQFNF.js";import{dr as T,fr as E,ft as D,i as ne,o as re,r as O}from"./index-DaLXKABQ.js";import{a as k,n as A,o as j,r as M,t as N}from"./card-K4Zt5gfO.js";import{n as P,t as F}from"./TimeRangePicker-BqClp5BN.js";var I=t(e(),1),L={API_CALLS:`api.calls`,API_ERRORS:`api.errors`,API_LATENCY_AVG_MS:`api.latency.avg_ms`,OPENCLAW_INGEST:`openclaw.ingest`,CHAT_SEND:`chat.send`,ASSISTANT_STREAM_ERRORS:`assistant.stream.errors`,ASSISTANT_ANNOUNCE_ERRORS:`assistant.announce.errors`,CONVEX_PROBE_LATENCY_AVG_MS:`convex.probe.latency.avg_ms`},R=Object.keys(L).length,z=n(),B=15,V=e=>String(Math.round(e));function H(){let e=o(b.me.getMe,{host:D})?.permissions?.includes(`traces.read`)??!1,t=o(b.deliveryTiming.listDeliverySessions,e?{}:`skip`),n=(0,I.useMemo)(()=>t?t.filter(e=>!e.active&&e.rollup!==null&&e.rollup.cP50!==null&&e.rollup.aP50!==null).slice(0,B).reverse().map(e=>({startedAt:e.startedAt,cP50:e.rollup?.cP50,aP50:e.rollup?.aP50})):[],[t]);return t===void 0?null:(0,z.jsxs)(`section`,{className:`oc-kpi__group`,children:[(0,z.jsx)(`h2`,{className:`oc-kpi__group-title`,children:S()}),(0,z.jsxs)(N,{children:[(0,z.jsxs)(k,{children:[(0,z.jsx)(j,{children:r()}),(0,z.jsx)(M,{children:v()})]}),(0,z.jsx)(A,{children:n.length<2?(0,z.jsx)(`p`,{className:`oc-admin__hint`,children:_()}):(0,z.jsx)(U,{series:n})})]})]})}function U({series:e}){let t=e.map(e=>e.cP50),n=e.map(e=>e.aP50),i=Math.max(1,...t,...n),a=t=>6+t*468/(e.length-1),o=e=>74-e*68/i,s=e=>e.map((e,t)=>`${t===0?`M`:`L`}${a(t).toFixed(1)},${o(e).toFixed(1)}`).join(` `),c=e[e.length-1];return(0,z.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,z.jsxs)(`div`,{className:`flex gap-3 text-xs text-muted-foreground`,children:[(0,z.jsxs)(`span`,{style:{color:`var(--primary)`},children:[l(),` p50 `,V(c.cP50),` `,p()]}),(0,z.jsxs)(`span`,{children:[g(),` p50 `,V(c.aP50),` `,p()]})]}),(0,z.jsxs)(`svg`,{viewBox:`0 0 480 80`,className:`h-20 w-full`,preserveAspectRatio:`none`,role:`img`,"aria-label":r(),children:[(0,z.jsx)(`path`,{d:s(n),fill:`none`,style:{stroke:`var(--muted-foreground)`},strokeWidth:1.5}),(0,z.jsx)(`path`,{d:s(t),fill:`none`,style:{stroke:`var(--primary)`},strokeWidth:1.5})]})]})}var W=[{metric:`api.calls`,label:d(),unit:`/h`,group:`API`,isError:!1},{metric:`api.errors`,label:u(),unit:`/h`,group:`API`,isError:!0},{metric:`api.latency.avg_ms`,label:te(),unit:`ms`,group:`API`,isError:!1},{metric:`openclaw.ingest`,label:i(),unit:`/h`,group:`OpenClaw`,isError:!1},{metric:`chat.send`,label:y(),unit:`/h`,group:`Chat`,isError:!1},{metric:L.ASSISTANT_STREAM_ERRORS,label:f(),unit:`/h`,group:`Assistant`,isError:!0},{metric:L.ASSISTANT_ANNOUNCE_ERRORS,label:s(),unit:`/h`,group:`Assistant`,isError:!0}],G=R,K=[`API`,`OpenClaw`,`Chat`,`Assistant`],q=1e3,J=36e5;function Y(e,t){let n=Math.max(1,Math.ceil((t-e)/J)),r=Math.min(n*G,q);return{rowLimit:r,buckets:Math.max(1,Math.floor(r/G))}}function ie(){let e=E({from:`/settings/kpi`}),t=T({from:`/settings/kpi`}),n=ne(e.from,e.to,O,`now`),r=e=>void t({search:t=>({...t,...re(e)})}),{from:i,to:s}=P(n),{rowLimit:l,buckets:u}=Y(i,s),d=o(b.kpi.listKpis,{limit:l,filter:{from:i,to:s}}),f=(0,I.useMemo)(()=>{let e=new Map;for(let t of d??[]){let n=e.get(t.metric)??[];n.push({bucket:t.bucket,value:t.value}),e.set(t.metric,n)}for(let[t,n]of e)n.sort((e,t)=>e.bucket<t.bucket?-1:+(e.bucket>t.bucket)),n.length>u&&e.set(t,n.slice(n.length-u));return e},[d,u]),p=(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`p`,{className:`oc-admin__hint`,children:[c(),` `,(0,z.jsx)(`span`,{className:`oc-filter__window`,children:h()})]}),(0,z.jsx)(ae,{value:n,onChange:r})]});return d===void 0?(0,z.jsxs)(z.Fragment,{children:[p,(0,z.jsx)(H,{}),(0,z.jsx)(`p`,{className:`oc-admin__hint`,children:x()})]}):d.length===0?(0,z.jsxs)(z.Fragment,{children:[p,(0,z.jsx)(H,{}),(0,z.jsx)(`p`,{className:`oc-admin__hint`,children:a()})]}):(0,z.jsxs)(z.Fragment,{children:[p,(0,z.jsx)(H,{}),K.map(e=>{let t=W.filter(t=>t.group===e);return t.some(e=>(f.get(e.metric)??[]).length>0)?(0,z.jsxs)(`section`,{className:`oc-kpi__group`,children:[(0,z.jsx)(`h2`,{className:`oc-kpi__group-title`,children:e}),(0,z.jsx)(`div`,{className:`oc-kpi__grid`,children:t.map(e=>(0,z.jsx)(oe,{config:e,series:f.get(e.metric)??[]},e.metric))})]},e):null})]})}function ae({value:e,onChange:t}){return(0,z.jsx)(`div`,{className:`oc-kpi__toolbar`,children:(0,z.jsx)(F,{value:e,onChange:t})})}function oe({config:e,series:t}){let n=t.length>0?t[t.length-1]:null,r=n?n.value:0;return(0,z.jsxs)(N,{size:`sm`,className:`oc-kpi__card`,children:[(0,z.jsxs)(k,{children:[(0,z.jsx)(j,{className:`oc-kpi__card-title`,children:e.label}),(0,z.jsx)(M,{className:`oc-kpi__card-metric`,children:(0,z.jsx)(`code`,{children:e.metric})})]}),(0,z.jsxs)(A,{className:`oc-kpi__card-body`,children:[(0,z.jsxs)(`div`,{className:`oc-kpi__value-row`,children:[(0,z.jsx)(`span`,{className:`oc-kpi__value`+(e.isError&&r>0?` oc-kpi__value--error`:``),children:Q(r)}),(0,z.jsx)(`span`,{className:`oc-kpi__unit`,children:e.unit})]}),(0,z.jsx)(ce,{series:t,isError:e.isError,unit:e.unit}),(0,z.jsxs)(`div`,{className:`oc-kpi__axis`,children:[n?(0,z.jsx)(`span`,{className:`oc-kpi__axis-latest`,children:m({value:$(n.bucket)})}):(0,z.jsx)(`span`,{className:`oc-kpi__muted`,children:C()}),(0,z.jsx)(`span`,{className:`oc-kpi__muted`,children:ee({count:t.length})})]})]})]})}var X=240,Z=48,se=1;function ce({series:e,isError:t,unit:n}){if(e.length===0)return(0,z.jsx)(`div`,{className:`oc-kpi__chart oc-kpi__chart--empty`,"aria-hidden":!0});let r=e.reduce((e,t)=>t.value>e?t.value:e,0),i=X/e.length,a=Math.max(i-se,1);return(0,z.jsx)(`svg`,{className:`oc-kpi__chart`,viewBox:`0 0 ${X} ${Z}`,preserveAspectRatio:`none`,role:`img`,"aria-label":w({max:Q(r),unit:n}),children:e.map((e,o)=>{let s=r>0?e.value/r*(Z-1):0,c=o*i,l=Z-s;return(0,z.jsx)(`rect`,{className:`oc-kpi__bar`+(t&&e.value>0?` oc-kpi__bar--error`:``),x:c,y:l,width:a,height:s,children:(0,z.jsxs)(`title`,{children:[$(e.bucket),` · `,Q(e.value),` `,n]})},e.bucket)})})}function Q(e){return Number.isFinite(e)?Math.abs(e)>=1e3?(e/1e3).toFixed(e%1e3==0?0:1)+`k`:String(e):`0`}function $(e){let t=new Date(`${e}:00:00Z`);return Number.isNaN(t.getTime())?e:`${String(t.getUTCDate()).padStart(2,`0`)}/${String(t.getUTCMonth()+1).padStart(2,`0`)} ${String(t.getUTCHours()).padStart(2,`0`)}h`}export{ie as KpiTab};
@@ -1 +0,0 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$J as r,$U as i,$s as a,BJ as o,BU as s,CY as c,FU as l,GJ as u,GU as d,HJ as f,HU as p,IJ as ee,IU as m,JJ as te,JU as h,KJ as g,KU as ne,LJ as re,LU as ie,MU as ae,NU as oe,PU as se,QJ as ce,QU as le,Qs as ue,RJ as de,RU as _,SY as v,UJ as fe,UU as pe,VJ as me,VU as he,WJ as y,WU as b,XJ as x,XU as S,YJ as C,YU as w,ZJ as T,ZU as E,Zs as D,_c as O,aW as k,aY as A,cW as j,cY as M,dW as N,eW as P,eY as F,ec as I,fW as L,fc as R,gW as ge,hW as _e,iF as ve,iW as ye,iY as be,ic as xe,jU as Se,lW as Ce,mW as we,nW as Te,nY as Ee,nc as De,oW as Oe,pW as ke,pY as Ae,qJ as je,qU as Me,r as z,rW as Ne,rY as Pe,rc as Fe,sW as Ie,t as B,tW as Le,tY as Re,tc as ze,uW as Be,vc as Ve,zJ as He,zU as Ue}from"./api-IF2KQFNF.js";import{t as V}from"./button-DDPt-po9.js";import{$t as H,H as We,Jt as U,Mt as W,Qt as Ge,St as Ke,Xt as qe,Yt as Je,Zt as Ye,bt as G,ft as K,t as Xe,vt as Ze,xt as Qe,yt as $e}from"./index-DaLXKABQ.js";import{t as et}from"./localePickerView-C2RmOS86.js";import{t as tt}from"./TimezoneCombobox-yZPA1ePa.js";var q=t(e(),1),J=n();function nt({className:e,checked:t,onCheckedChange:n,disabled:r,...i}){return(0,J.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":t,"data-state":t?`checked`:`unchecked`,disabled:r,onClick:()=>n(!t),className:z(`peer inline-flex h-5 w-9 shrink-0 items-center rounded-full border border-transparent transition-colors outline-none`,`focus-visible:ring-2 focus-visible:ring-ring/50`,`disabled:cursor-not-allowed disabled:opacity-50`,t?`bg-primary`:`bg-input`,e),...i,children:(0,J.jsx)(`span`,{className:z(`pointer-events-none block size-4 rounded-full bg-background shadow transition-transform`,t?`translate-x-[18px]`:`translate-x-[2px]`)})})}var Y=[{id:`messages`,label:()=>ge()},{id:`composer`,label:()=>_e()},{id:`sidebar`,label:()=>we()},{id:`notifications`,label:()=>E()},{id:`other`,label:()=>ke()}],X={showSource:{category:`messages`,label:()=>L(),help:()=>N()},showReport:{category:`messages`,label:()=>Be(),help:()=>Ce()},copyAssistant:{category:`messages`,label:()=>j()},copyUser:{category:`messages`,label:()=>Ie()},showDelete:{category:`messages`,label:()=>Oe()},showTools:{category:`messages`,label:()=>k(),help:()=>ye()},voiceInput:{category:`composer`,label:()=>Ne(),help:()=>Te()},showUsage:{category:`composer`,label:()=>Le(),help:()=>P()},autoReadAloud:{category:`composer`,label:()=>Ve(),help:()=>O()},showChatAge:{category:`sidebar`,label:()=>i(),help:()=>le()},notifSound:{category:`notifications`,label:()=>S(),help:()=>w()},notifSystem:{category:`notifications`,label:()=>h(),help:()=>Me()},replySound:{category:`notifications`,label:()=>ne(),help:()=>d()}};function Z(e){return e.toLowerCase().normalize(`NFD`).replace(/\p{Diacritic}/gu,``)}function Q(e,t){let n=Z(t.trim()),r=new Map(Y.map(e=>[e.id,e.label()])),i=new Map(Y.map(e=>[e.id,[]]));for(let t of e){let e=X[t],a=e?.category??`other`;n&&!Z(`${e?e.label():t} ${e?.help?e.help():``} ${t} ${r.get(a)??``}`).includes(n)||i.get(a).push(t)}return Y.map(e=>({id:e.id,label:r.get(e.id),keys:i.get(e.id)})).filter(e=>e.keys.length>0)}var rt=[`showSource`,`showReport`,`copyAssistant`,`copyUser`,`showDelete`,`showTools`,`voiceInput`,`showChatAge`,`showUsage`,`autoReadAloud`,`notifSound`,`notifSystem`,`replySound`],it={voiceInput:`voiceInput`};function at(e){return rt.includes(e)}function $(e){return e===`admin`}function ot(e){return e===!0?`on`:e===!1?`off`:`inherit`}function st(e){return e===`on`?!0:e===`off`?!1:null}function ct(e){return at(e)?it[e]:void 0}var lt={voiceInput:()=>l()};function ut({prefKey:e,ui:t}){let n=v(B.admin.setUiPrefDefault),r=v(B.admin.setFeatureEnabled),i=ct(e),a=i?lt[e]?.():void 0;return(0,J.jsxs)(`div`,{className:`oc-prefs__gov`,children:[(0,J.jsxs)(`div`,{className:`oc-prefs__gov-row`,children:[(0,J.jsx)(`span`,{className:`oc-prefs__gov-label`,children:Ue()}),(0,J.jsxs)(Ze,{value:ot(t.defaults[e]),onValueChange:t=>void n({key:e,value:st(t)}),children:[(0,J.jsx)(Qe,{size:`sm`,className:`w-36`,children:(0,J.jsx)(Ke,{})}),(0,J.jsxs)($e,{children:[(0,J.jsx)(G,{value:`on`,children:oe()}),(0,J.jsx)(G,{value:`off`,children:ae()}),(0,J.jsx)(G,{value:`inherit`,children:Se()})]})]}),i?(0,J.jsxs)(`span`,{className:`oc-prefs__gov-gate`,children:[(0,J.jsx)(W,{checked:t.featuresEnabled[i]===!0,onCheckedChange:e=>void r({key:i,enabled:e===!0}),"aria-label":_()}),_()]}):null]}),a?(0,J.jsx)(`span`,{className:`oc-prefs__gov-help`,children:a}):null]})}function dt({current:e,enabled:t}){let n=v(B.me.setDictationShortcut),[r,i]=(0,q.useState)(!1),[o,s]=(0,q.useState)(!1);return(0,q.useEffect)(()=>{if(!r)return;let e=e=>{if(e.preventDefault(),e.stopPropagation(),e.key===`Escape`){i(!1);return}let t=Ye(e);if(t===null){[`Shift`,`Control`,`Meta`,`Alt`].includes(e.key)||(s(!0),window.setTimeout(()=>s(!1),1800));return}i(!1),n({shortcut:t})};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[r,n]),(0,J.jsxs)(`div`,{className:`oc-prefs__row${t?``:` is-locked`}`,children:[(0,J.jsxs)(`div`,{className:`oc-prefs__info`,children:[(0,J.jsxs)(`span`,{className:`oc-prefs__label`,children:[xe(),e?(0,J.jsx)(U,{variant:`secondary`,children:Ge(e,qe())}):null]}),(0,J.jsx)(`span`,{className:`oc-prefs__help`,children:o?ze():r?De():Fe()})]}),(0,J.jsxs)(`div`,{className:`oc-prefs__ctl`,children:[e&&!r?(0,J.jsx)(`button`,{type:`button`,className:`oc-prefs__reset`,onClick:()=>void n({shortcut:null}),children:D()}):null,(0,J.jsx)(`button`,{type:`button`,className:`oc-prefs__reset`,disabled:!t,"aria-pressed":r,onClick:()=>i(e=>!e),children:r?ue():e?a():I()})]})]})}function ft(){let[e,t]=(0,q.useState)(``),[n,r]=(0,q.useState)(!1),i=c(B.me.getMe,{host:K}),a=i?.ui,o=$(i?.role)&&n,l=v(B.me.setUiPref).withOptimisticUpdate(We),u=(0,q.useMemo)(()=>a?Q(Object.keys(a.effective),e):[],[a,e]);return a?(0,J.jsxs)(`div`,{className:`oc-prefs-panel`,children:[$(i?.role)?(0,J.jsxs)(`label`,{className:`oc-prefs__gov-toggle`,children:[(0,J.jsx)(W,{checked:n,onCheckedChange:e=>r(e===!0),"aria-label":s()}),s()]}):null,o?(0,J.jsxs)(`div`,{className:`oc-prefs__gov-head`,children:[(0,J.jsx)(`p`,{children:ie()}),(0,J.jsx)(`p`,{children:m()}),(0,J.jsx)(`p`,{children:se()})]}):null,(0,J.jsx)(H,{value:e,onChange:e=>t(e.target.value),placeholder:b(),"aria-label":b(),className:`mb-2`}),u.length===0?(0,J.jsx)(`div`,{className:`oc-prefs__empty`,children:pe()}):(0,J.jsx)(`div`,{className:`oc-prefs`,children:u.map(e=>(0,J.jsxs)(`section`,{className:`oc-prefs__card`,children:[(0,J.jsx)(`h4`,{className:`oc-prefs__cat`,children:e.label}),e.keys.map(e=>{let t=X[e],n=t?t.label():e,r=t?.help?.(),i=a.locked[e],s=a.effective[e],c=a.userOverrides[e]!==void 0;return(0,J.jsxs)(`div`,{className:`oc-prefs__row${i?` is-locked`:``}`,children:[(0,J.jsxs)(`div`,{className:`oc-prefs__info`,children:[(0,J.jsxs)(`span`,{className:`oc-prefs__label`,children:[n,i?(0,J.jsx)(U,{variant:`outline`,children:p()}):c?(0,J.jsx)(U,{variant:`secondary`,children:R()}):null]}),r?(0,J.jsx)(`span`,{className:`oc-prefs__help`,children:r}):null]}),(0,J.jsxs)(`div`,{className:`oc-prefs__ctl`,children:[!i&&c?(0,J.jsx)(`button`,{type:`button`,className:`oc-prefs__reset`,onClick:()=>void l({key:e,value:null}),children:he()}):null,(0,J.jsx)(nt,{checked:s,disabled:i,onCheckedChange:t=>{e===`notifSystem`&&t&&typeof Notification<`u`&&Notification.permission==="default"&&Notification.requestPermission(),l({key:e,value:t})},"aria-label":n})]}),o?(0,J.jsx)(ut,{prefKey:e,ui:a}):null]},e)})]},e.id))}),(0,J.jsx)(dt,{current:i?.dictationShortcut??null,enabled:a.effective.voiceInput===!0})]}):(0,J.jsx)(`div`,{className:`oc-prefs__empty`,children:Ae()})}var pt={sm:()=>je(),md:()=>g(),lg:()=>u(),xl:()=>y(),"2xl":()=>fe(),"3xl":()=>f()};function mt(){let e=c(B.me.getMe,{host:K}),t=v(B.me.setLocale),n=v(B.me.setTimezone),i=v(B.me.setFontScale).withOptimisticUpdate((e,{scale:t})=>{let n=e.getQuery(B.me.getMe,{host:K});n&&e.setQuery(B.me.getMe,{host:K},{...n,fontScale:t,resolvedFontScale:t??`md`})}),a=v(B.me.setMyName),s=Je(),l=e?.locale??`default`,u=e?.name??``,[d,f]=(0,q.useState)(null),p=d??u,m=p.trim()!==u.trim();async function h(){try{await a({name:p}),f(null),s.success(Re())}catch(e){s.error(F(),e)}}return(0,J.jsxs)(`div`,{className:`oc-appearance`,children:[(0,J.jsxs)(`section`,{className:`oc-show__section`,children:[(0,J.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,J.jsx)(`h2`,{className:`oc-show__title`,children:A()}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:be()})]}),(0,J.jsxs)(`div`,{className:`oc-show__row`,children:[(0,J.jsx)(H,{className:`max-w-xs`,value:p,maxLength:120,placeholder:Pe(),onChange:e=>f(e.target.value),onKeyDown:e=>{e.key===`Enter`&&m&&(e.preventDefault(),h())}}),(0,J.jsx)(V,{size:`sm`,disabled:!m,onClick:()=>void h(),children:ve()})]}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:Ee()})]}),(0,J.jsxs)(`section`,{className:`oc-show__section`,children:[(0,J.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,J.jsx)(`h2`,{className:`oc-show__title`,children:r()}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:ce()})]}),(0,J.jsxs)(`div`,{className:`oc-show__row`,children:[et().map(e=>(0,J.jsx)(V,{variant:l===e.value?`default`:`outline`,size:`sm`,onClick:()=>void t({locale:e.value}),children:e.label},e.value)),(0,J.jsx)(V,{variant:l==="default"?`default`:`outline`,size:`sm`,onClick:()=>void t({locale:null}),children:M()})]}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:T()})]}),(0,J.jsxs)(`section`,{className:`oc-show__section`,children:[(0,J.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,J.jsx)(`h2`,{className:`oc-show__title`,children:me()}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:o()})]}),(0,J.jsxs)(`div`,{className:`oc-show__row`,children:[(0,J.jsx)(tt,{value:e?.timezone??``,onChange:e=>void n({timezone:e})}),(0,J.jsx)(V,{variant:e?.timezone===null||e?.timezone===void 0?`default`:`outline`,size:`sm`,onClick:()=>void n({timezone:null}),children:He()})]}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:de()})]}),(0,J.jsxs)(`section`,{className:`oc-show__section`,children:[(0,J.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,J.jsx)(`h2`,{className:`oc-show__title`,children:x()}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:C()})]}),(0,J.jsx)(`div`,{className:`oc-show__row`,children:Xe.map(t=>(0,J.jsx)(V,{variant:(e?.fontScale??`md`)===t?`default`:`outline`,size:`sm`,onClick:()=>void i({scale:t}),children:pt[t]()},t))}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:te()})]}),(0,J.jsxs)(`section`,{className:`oc-show__section`,children:[(0,J.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,J.jsx)(`h2`,{className:`oc-show__title`,children:re()}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:ee()})]}),(0,J.jsx)(ft,{})]})]})}export{mt as PreferencesTab};
@@ -1 +0,0 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$T as r,BE as i,CE as a,CY as o,DE as s,E as c,EE as l,FE as u,JT as d,KE as ee,LE as te,ME as f,NE as p,OE as m,PE as h,QT as g,SE as _,SY as v,TE as ne,To as re,UE as y,VE as ie,XE as b,XT as ae,YE as x,YT as oe,ZT as S,_E as se,bE as ce,cE as le,dE as C,eD as ue,eE as w,gE as de,hE as fe,iC as pe,iE as me,jE as he,kE as ge,lE as T,mE as E,nD as _e,nE as D,pE as ve,pT as O,pY as k,qE as ye,qT as A,t as j,tD as be,uE as xe,vE as Se,wE as Ce,wo as we,xE as M,yE as Te}from"./api-IF2KQFNF.js";import{r as Ee}from"./dist-821wRD_K.js";import{t as De}from"./list-9tuUpKq3.js";import{t as N}from"./button-DDPt-po9.js";import{$n as Oe,$t as P,A as ke,An as Ae,Bn as je,C as F,D as Me,E as Ne,Gn as Pe,I as Fe,Kn as Ie,M as Le,N as Re,O as ze,P as I,Qn as Be,S as Ve,T as He,Un as L,Vn as Ue,Xn as R,Yt as We,Zn as Ge,_ as Ke,_t as qe,an as Je,b as Ye,ct as Xe,d as Ze,dr as z,en as Qe,er as $e,f as et,fr as tt,g as nt,gt as B,h as rt,ht as V,in as it,j as H,k as at,lt as ot,mt as st,nn as U,p as ct,pr as W,pt as lt,rn as ut,sr as dt,tn as ft,tr as pt,v as G,w as K,x as q,y as mt,zn as ht}from"./index-DaLXKABQ.js";var gt=c(`columns-3`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}]]),_t=c(`folder-input`,[[`path`,{d:`M2 9V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-1`,key:`fm4g5t`}],[`path`,{d:`M2 13h10`,key:`pgb2dq`}],[`path`,{d:`m9 16 3-3-3-3`,key:`6m91ic`}]]),vt=c(`layout-grid`,[[`rect`,{width:`7`,height:`7`,x:`3`,y:`3`,rx:`1`,key:`1g98yp`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`3`,rx:`1`,key:`6d4xhi`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`14`,rx:`1`,key:`nxv5o0`}],[`rect`,{width:`7`,height:`7`,x:`3`,y:`14`,rx:`1`,key:`1bb6yr`}]]),J=c(`panel-left`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}]]),Y=t(e(),1),X=n();function yt({className:e}){return(0,X.jsx)(Je,{asChild:!0,children:(0,X.jsx)(N,{variant:`ghost`,size:`icon-xs`,"aria-label":w(),className:e,onClick:e=>e.stopPropagation(),onMouseDown:e=>e.stopPropagation(),onTouchStart:e=>e.stopPropagation(),onPointerDown:e=>e.stopPropagation(),children:(0,X.jsx)(pt,{})})})}function Z({folderId:e,name:t,color:n,currentParentId:a,className:s,onOpen:c}){let l=v(j.projects.renameProject),u=v(j.projects.setProjectColor),d=v(j.projects.moveProject),f=v(j.projects.deleteProject),p=v(j.projects.createProject),h=Xe(),g=rt(),_=ot(),[ne,re]=(0,Y.useState)(!1),[y,b]=(0,Y.useState)(t),[x,S]=(0,Y.useState)(!1),[se,ce]=(0,Y.useState)(!1),C=o(j.projects.projectTreeCount,se?{projectId:e}:`skip`);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(Qe,{onOpenChange:e=>e&&ce(!0),children:[(0,X.jsx)(yt,{className:s}),(0,X.jsxs)(ft,{align:`end`,className:`w-48`,onClick:e=>e.stopPropagation(),children:[(0,X.jsxs)(U,{onSelect:()=>c(),children:[(0,X.jsx)(Be,{}),` `,te()]}),(0,X.jsxs)(U,{onSelect:()=>{b(t),re(!0)},children:[(0,X.jsx)(Ue,{}),` `,r()]}),(0,X.jsxs)(U,{onSelect:()=>{requestAnimationFrame(async()=>{let t=await _({title:m(),label:_e(),placeholder:be(),confirmLabel:ue()});t&&await p({name:t,parentId:e})})},children:[(0,X.jsx)(Ge,{}),` `,m()]}),(0,X.jsxs)(U,{onSelect:()=>S(!0),children:[(0,X.jsx)(_t,{}),` `,xe()]}),(0,X.jsx)(ut,{children:ae()}),(0,X.jsxs)(`div`,{className:`oc-colorgrid`,onClick:e=>e.stopPropagation(),children:[(0,X.jsx)(`button`,{className:`oc-colorgrid__none`,onClick:()=>void u({projectId:e,color:null}),"aria-label":oe(),children:`✕`}),Ke.map(t=>(0,X.jsx)(`button`,{className:`oc-colorgrid__dot`+(n===t.value?` is-selected`:``),style:{background:t.hue},"aria-label":t.value,onClick:()=>void u({projectId:e,color:t.value})},t.value))]}),(0,X.jsx)(it,{}),(0,X.jsxs)(U,{variant:`destructive`,onSelect:()=>{requestAnimationFrame(async()=>{let n=C?.folders??0,r=C?.chats??0;await h({title:i({name:t}),description:ct({folders:n,chats:r,days:g}),confirmWord:D(),confirmLabel:ie(),destructive:!0})&&await f({projectId:e})})},children:[(0,X.jsx)(Ae,{}),` `,D()]})]})]}),(0,X.jsx)(Ye,{open:ne,onOpenChange:re,title:ee(),canSubmit:y.trim().length>0,onSubmit:async()=>{await l({projectId:e,name:y.trim()}),re(!1)},submitLabel:r(),children:(0,X.jsx)(P,{value:y,onChange:e=>b(e.target.value),autoFocus:!0})}),x?(0,X.jsx)(nt,{open:x,onOpenChange:S,title:le(),movingFolderId:e,currentId:a,onPick:t=>void d({projectId:e,parentId:t})}):null]})}function bt({chat:e,currentFolderId:t,className:n}){let i=v(j.chats.pinChat),a=v(j.chats.deleteChat),o=v(j.chats.renameChat),s=v(j.chats.setChatSidebar),c=v(j.chats.moveChatToProject),l=Xe(),ee=rt(),[te,f]=(0,Y.useState)(!1),[p,m]=(0,Y.useState)(e.title??``),[_,ne]=(0,Y.useState)(!1);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(Qe,{children:[(0,X.jsx)(yt,{className:n}),(0,X.jsxs)(ft,{align:`end`,className:`w-52`,onClick:e=>e.stopPropagation(),children:[(0,X.jsxs)(U,{onSelect:()=>{m(e.title??``),f(!0)},children:[(0,X.jsx)(Ue,{}),` `,r()]}),(0,X.jsxs)(U,{onSelect:()=>void i({chatId:e._id,pinned:!e.pinned}),children:[e.pinned?(0,X.jsx)(ht,{}):(0,X.jsx)(je,{}),e.pinned?g():S()]}),(0,X.jsxs)(U,{onSelect:()=>ne(!0),children:[(0,X.jsx)(_t,{}),` `,C()]}),e.pinned&&e.inSidebar?null:(0,X.jsxs)(U,{onSelect:()=>void s({chatId:e._id,hidden:e.inSidebar}),children:[e.inSidebar?(0,X.jsx)(L,{}):(0,X.jsx)(J,{}),e.inSidebar?h():u()]}),(0,X.jsx)(it,{}),(0,X.jsxs)(U,{variant:`destructive`,onSelect:()=>{requestAnimationFrame(async()=>{await l({title:d(),description:A({days:ee}),confirmLabel:D(),destructive:!0})&&await a({chatId:e._id})})},children:[(0,X.jsx)(Ae,{}),` `,D()]})]})]}),(0,X.jsx)(Ye,{open:te,onOpenChange:f,title:O(),canSubmit:p.trim().length>0,onSubmit:async()=>{await o({chatId:e._id,title:p.trim()}),f(!1)},submitLabel:r(),children:(0,X.jsx)(P,{value:p,onChange:e=>m(e.target.value),autoFocus:!0})}),_?(0,X.jsx)(nt,{open:_,onOpenChange:ne,title:T(),currentId:t,onPick:t=>void c({chatId:e._id,projectId:t})}):null]})}function xt(e,t){let n=t.trim().toLowerCase();return n===``?e:e.filter(e=>(e.title??``).toLowerCase().includes(n))}function St(e,t,n,r,i){let a=e.map(t),o=a.indexOf(i);if(o<0)return null;let s=a.indexOf(r);if(s>=0){let t=[...e],[r]=t.splice(s,1);t.splice(o,0,r);let i=t[o-1],a=t[o+1];return{prevKey:i===void 0?null:n(i),nextKey:a===void 0?null:n(a)}}let c=e[o-1];return{prevKey:c===void 0?null:n(c),nextKey:n(e[o])}}function Ct(e,t){let n=new Map(t.map(e=>[e.chatId,e.lastSeenAt])),r=new Set;for(let t of e){let e=n.get(t._id);e!==void 0&&t.lastAssistantAt!==null&&t.lastAssistantAt>e&&r.add(t._id)}return r}var wt=`oc.projpage.view`;function Tt(){let e=localStorage.getItem(wt);return e===`cards`||e===`list`?e:`columns`}var Q=e=>`into:${e}`,Et=e=>`col:${e??`null`}`,Dt=e=>`crumb:${e}`;function Ot(e){if(e.startsWith(`into:`))return e.slice(5);if(e.startsWith(`crumb:`))return e.slice(6);if(e.startsWith(`col:`)){let t=e.slice(4);return t===`null`?null:t}}function kt(){let{projectId:e}=W({from:`/project/$projectId`}),t=z(),n=o(j.projects.projectPage,{projectId:e});return(0,X.jsx)(`div`,{className:`oc-projpage`,children:n===void 0?(0,X.jsx)(`p`,{className:`oc-projpage__hint`,children:k()}):n===null?(0,X.jsxs)(`div`,{className:`oc-projpage__notfound`,children:[(0,X.jsx)(`h2`,{children:de()}),(0,X.jsx)(`p`,{className:`oc-projpage__hint`,children:fe()}),(0,X.jsx)(N,{variant:`outline`,onClick:()=>void t({to:`/`}),children:E()})]}):(0,X.jsx)(At,{page:n})})}function At({page:e}){let t=z(),n=Xe(),s=rt(),c=ot(),l=We(),u=v(j.projects.renameProject),d=v(j.projects.setProjectColor),te=v(j.projects.deleteProject),h=v(j.projects.createProject),g=v(j.projects.moveProject),_=v(j.projects.setProjectSidebar),y=v(j.chats.moveChatToProject),x=v(j.chats.reorderChat),S=v(j.projects.reorderProject),C=o(j.projects.projectTreeCount,{projectId:e.project._id}),[w,de]=(0,Y.useState)(Tt),fe=e=>{localStorage.setItem(wt,e),de(e)},T=o(j.projects.folderColumns,w===`columns`?{projectId:e.project._id}:`skip`),E=o(j.projects.projectTreeList,w===`list`?{projectId:e.project._id}:`skip`),{c:O}=tt({from:`/project/$projectId`}),k=o(j.projects.listProjects,{}),A=o(j.chatReads.myBusyChats,{}),M=(0,Y.useMemo)(()=>new Set(A??[]),[A]),{byChat:Ee}=qe(A??null),je=o(j.chatReads.myChatReads,{}),F=(0,Y.useMemo)(()=>Ct(e.chats,je??[]),[e.chats,je]),{startNewChat:I,picker:Be}=Ze(e=>void t({to:`/chat/$chatId`,params:{chatId:e}})),[L,et]=(0,Y.useState)(``),[B,H]=(0,Y.useState)(!1),[W,dt]=(0,Y.useState)(e.project.name),[G,ht]=(0,Y.useState)(!1),[J,yt]=(0,Y.useState)(``);(0,Y.useEffect)(()=>{let e=setTimeout(()=>yt(L.trim()),180);return()=>clearTimeout(e)},[L]);let Z=o(j.search.searchConversations,J.length>=2?{query:J,projectId:e.project._id}:`skip`),bt=Re(Le(Me,{activationConstraint:{distance:4}}),Le(ze,{activationConstraint:{delay:250,tolerance:8}})),Q=(0,Y.useRef)(!1),Et=()=>{Q.current=!0,setTimeout(()=>{Q.current=!1},0)},[Dt,kt]=(0,Y.useState)(null),At=t=>{if(t.startsWith(`chat:`)){let n=t.slice(5),r=e.chats.find(e=>e._id===n),i=T?.columns.flatMap(e=>e.chats).find(e=>e._id===n);return{kind:`chat`,label:(r??i)?.title||b()}}if(t.startsWith(`folder:`)){let e=t.slice(7);return{kind:`folder`,label:(k??[]).find(t=>t._id===e)?.name??``}}return null},Nt=e=>kt(At(String(e.active.id))),$=(0,Y.useCallback)(e=>{let t=String(e.active.id).startsWith(`folder:`),n=t=>({...e,droppableContainers:e.droppableContainers.filter(e=>String(e.id).startsWith(t))}),r=ke(n(`into:`));if(r.length>0){if(!t)return r;let n=r[0],i=e.droppableRects.get(n.id),a=e.pointerCoordinates?.y;if(i&&a!=null){let e=i.height*.3;if(a>i.top+e&&a<i.top+i.height-e)return r}}let i=ke(n(t?`folder:`:`chat:`));if(i.length>0)return i;let a=ke(n(`crumb:`));if(a.length>0)return a;let o=ke(n(`col:`));return o.length>0?o:at(n(t?`folder:`:`chat:`))},[]),It=t=>{if(w===`columns`){for(let e of T?.columns??[])if(e.chats.some(e=>e._id===t))return{list:e.chats,folderId:e.folderId};return null}if(w===`list`){let e=E?.chats.find(e=>e._id===t);return e?{list:E.chats.filter(t=>t.folderId===e.folderId),folderId:e.folderId}:null}return e.chats.some(e=>e._id===t)?{list:e.chats,folderId:e.project._id}:null},Lt=t=>{if(w===`columns`){for(let e of T?.columns??[])if(e.folders.some(e=>e._id===t))return{list:e.folders,parentId:e.folderId};return null}if(w===`list`){let e=E?.folders.find(e=>e._id===t);if(!e||!E)return null;let n=e.parentId??E.rootId;return{list:st(E.folders,e.parentId),parentId:n}}return e.children.some(e=>e._id===t)?{list:e.children,parentId:e.project._id}:null},zt=async e=>{kt(null),Et();let{active:t,over:n}=e;if(!n)return;let r=String(n.id),i=String(t.id),a=i.startsWith(`chat:`);try{let e=Ot(r);if(e!==void 0){if(a)await y({chatId:i.slice(5),projectId:e});else{let t=i.slice(7);if(t===e)return;if(!lt(k??[],t,e)){l.error(ge());return}await g({projectId:t,parentId:e})}return}if(a&&r.startsWith(`chat:`)){let e=i.slice(5),t=r.slice(5);if(e===t)return;let n=It(t);if(!n)return;n.list.some(t=>t._id===e)||await y({chatId:e,projectId:n.folderId});let a=St(n.list,e=>e._id,e=>e.sortKey,e,t);a&&await x({chatId:e,...a});return}if(!a&&r.startsWith(`folder:`)){let e=i.slice(7),t=r.slice(7);if(e===t)return;let n=Lt(t);if(!n)return;if(!n.list.some(t=>t._id===e)){if(!lt(k??[],e,n.parentId)){l.error(ge());return}await g({projectId:e,parentId:n.parentId})}let a=St(n.list,e=>e._id,e=>e.sortKey,e,t);a&&await S({projectId:e,...a});return}}catch{l.error(ge())}},[,Bt]=(0,Y.useState)(0);(0,Y.useEffect)(()=>{let e=window.setInterval(()=>Bt(e=>e+1),6e4);return()=>window.clearInterval(e)},[]);let Vt=Date.now(),Ht=mt(e.project),Ut=xt(e.chats,L),Wt=e.breadcrumb.slice(0,-1),Gt=e=>()=>{Q.current||e()};return(0,X.jsx)(V.Provider,{value:Ee,children:(0,X.jsxs)(He,{sensors:bt,collisionDetection:$,onDragStart:Nt,onDragEnd:zt,children:[(0,X.jsxs)(`div`,{className:`oc-projpage__body`,style:{"--proj-hue":Ht},children:[(0,X.jsxs)(`nav`,{className:`oc-projpage__crumbs`,"aria-label":ve(),children:[Wt.map(e=>(0,X.jsxs)(`span`,{className:`oc-projpage__crumb`,children:[(0,X.jsx)(jt,{folderId:e._id,children:(0,X.jsx)(`button`,{type:`button`,className:`oc-projpage__crumblink`,onClick:Gt(()=>void t({to:`/project/$projectId`,params:{projectId:e._id}})),children:e.name})}),(0,X.jsx)(`span`,{className:`oc-projpage__crumbsep`,"aria-hidden":!0,children:`›`})]},e._id)),(0,X.jsx)(`span`,{className:`oc-projpage__crumbcur`,children:e.project.name})]}),(0,X.jsxs)(`header`,{className:`oc-projpage__head`,children:[(0,X.jsx)(`span`,{className:`oc-projpage__dot`,"aria-hidden":!0}),(0,X.jsx)(`h1`,{className:`oc-projpage__title`,children:e.project.name}),e.project.sidebarHidden?(0,X.jsxs)(N,{variant:`ghost`,size:`sm`,className:`oc-projpage__hiddenbadge`,title:re(),onClick:()=>{_({projectId:e.project._id,hidden:!1})},children:[(0,X.jsx)($e,{"aria-hidden":!0}),(0,X.jsx)(`span`,{children:we()}),(0,X.jsx)(Oe,{"aria-hidden":!0})]}):null,(0,X.jsxs)(`div`,{className:`oc-projpage__actions`,children:[(0,X.jsxs)(`div`,{className:`oc-projpage__viewtoggle`,role:`group`,"aria-label":p(),children:[(0,X.jsx)(N,{variant:w===`cards`?`secondary`:`ghost`,size:`icon-sm`,"aria-label":p(),title:p(),"aria-pressed":w===`cards`,onClick:()=>fe(`cards`),children:(0,X.jsx)(vt,{})}),(0,X.jsx)(N,{variant:w===`columns`?`secondary`:`ghost`,size:`icon-sm`,"aria-label":f(),title:f(),"aria-pressed":w===`columns`,onClick:()=>fe(`columns`),children:(0,X.jsx)(gt,{})}),(0,X.jsx)(N,{variant:w===`list`?`secondary`:`ghost`,size:`icon-sm`,"aria-label":he(),title:he(),"aria-pressed":w===`list`,onClick:()=>fe(`list`),children:(0,X.jsx)(De,{})})]}),(0,X.jsxs)(N,{variant:`outline`,size:`sm`,onClick:()=>void I({projectId:e.project._id}),children:[(0,X.jsx)(Ie,{}),a()]}),(0,X.jsxs)(N,{variant:`outline`,size:`sm`,onClick:async()=>{let t=await c({title:m(),label:_e(),placeholder:be(),confirmLabel:ue()});t&&await h({name:t,parentId:e.project._id})},children:[(0,X.jsx)(Ge,{}),m()]}),(0,X.jsxs)(Qe,{children:[(0,X.jsx)(Je,{asChild:!0,children:(0,X.jsx)(N,{variant:`ghost`,size:`icon-sm`,"aria-label":ye(),children:(0,X.jsx)(pt,{})})}),(0,X.jsxs)(ft,{align:`end`,className:`w-48`,children:[(0,X.jsxs)(U,{onSelect:()=>{dt(e.project.name),H(!0)},children:[(0,X.jsx)(Ue,{}),` `,r()]}),(0,X.jsxs)(U,{onSelect:()=>ht(!0),children:[(0,X.jsx)(_t,{}),` `,xe()]}),(0,X.jsx)(ut,{children:ae()}),(0,X.jsxs)(`div`,{className:`oc-colorgrid`,children:[(0,X.jsx)(`button`,{className:`oc-colorgrid__none`,onClick:()=>void d({projectId:e.project._id,color:null}),"aria-label":oe(),children:`✕`}),Ke.map(t=>(0,X.jsx)(`button`,{className:`oc-colorgrid__dot`+(e.project.color===t.value?` is-selected`:``),style:{background:t.hue},"aria-label":t.value,onClick:()=>void d({projectId:e.project._id,color:t.value})},t.value))]}),(0,X.jsx)(it,{}),(0,X.jsxs)(U,{variant:`destructive`,onSelect:()=>{let r=e.project.parentId;requestAnimationFrame(async()=>{let a=C?.folders??0,o=C?.chats??0;await n({title:i({name:e.project.name}),description:ct({folders:a,chats:o,days:s}),confirmWord:D(),confirmLabel:ie(),destructive:!0})&&(await te({projectId:e.project._id}),t(r===null?{to:`/`}:{to:`/project/$projectId`,params:{projectId:r}}))})},children:[(0,X.jsx)(Ae,{}),` `,D()]})]})]})]})]}),w===`columns`?(0,X.jsx)(Rt,{data:T,currentId:e.project._id,busyIds:M,suppressClick:Q,locateChatId:O??null}):w===`list`?(0,X.jsx)(Ft,{data:E,busyIds:M,suppressClick:Q,locateChatId:O??null}):(0,X.jsxs)(X.Fragment,{children:[e.children.length>0?(0,X.jsxs)(`section`,{className:`oc-projpage__section`,children:[(0,X.jsx)(`h2`,{className:`oc-projpage__subtitle`,children:ne()}),(0,X.jsx)(`div`,{className:`oc-projpage__cards`,children:(0,X.jsx)(q,{items:e.children.map(e=>`folder:${e._id}`),strategy:Ve,children:e.children.map(t=>(0,X.jsx)(Mt,{child:t,parentId:e.project._id,now:Vt,suppressClick:Q},t._id))})})]}):null,(0,X.jsxs)(`section`,{className:`oc-projpage__section`,children:[(0,X.jsxs)(`div`,{className:`oc-projpage__convhead`,children:[(0,X.jsx)(`h2`,{className:`oc-projpage__subtitle`,children:Ce()}),e.chats.length>0?(0,X.jsx)(P,{value:L,onChange:e=>et(e.target.value),placeholder:ce(),className:`oc-projpage__filter`}):null]}),e.chats.length===0?(0,X.jsx)(`p`,{className:`oc-projpage__hint`,children:e.children.length===0?Se():se()}):Ut.length===0&&(Z??[]).length===0?(0,X.jsx)(`p`,{className:`oc-projpage__hint`,children:Te({term:L.trim()})}):(0,X.jsx)(`ul`,{className:`oc-projpage__chats`,children:(0,X.jsx)(q,{items:Ut.map(e=>`chat:${e._id}`),strategy:K,children:Ut.map(t=>(0,X.jsx)(Pt,{chat:t,currentFolderId:e.project._id,now:Vt,busy:M.has(t._id),unread:F.has(t._id),locate:t._id===O,suppressClick:Q},t._id))})})]}),J.length>=2&&Z!==void 0?(0,X.jsxs)(`section`,{className:`oc-projpage__section`,children:[(0,X.jsx)(`h2`,{className:`oc-projpage__subtitle`,children:me()}),Z.length===0?(0,X.jsx)(`p`,{className:`oc-projpage__hint`,children:Te({term:J})}):(0,X.jsx)(`ul`,{className:`oc-projpage__chats`,children:Z.map(e=>(0,X.jsx)(`li`,{className:`oc-projpage__chatrow`,children:(0,X.jsxs)(`button`,{type:`button`,className:`oc-projpage__chatbtn`,onClick:()=>{e.messageId&&J&&Fe(e.messageId,J),t({to:`/chat/$chatId`,params:{chatId:e.chatId},...e.messageId?{search:{m:e.messageId}}:{}})},children:[(0,X.jsx)(Pe,{size:13,"aria-hidden":!0,className:`oc-projpage__hitico`}),(0,X.jsxs)(`span`,{className:`oc-projpage__hitbody`,children:[(0,X.jsx)(`span`,{className:`oc-projpage__chattitle`,children:e.title||pe()}),e.projectPath&&e.projectPath.length>1?(0,X.jsx)(`span`,{className:`oc-projpage__hitpath`,children:e.projectPath.join(` › `)}):null,e.snippet?(0,X.jsx)(`span`,{className:`oc-projpage__hitsnippet`,children:e.snippet}):null]})]})},`${e.chatId}:${e.messageId??`t`}`))})]}):null]}),(0,X.jsx)(Ye,{open:B,onOpenChange:H,title:ee(),canSubmit:W.trim().length>0,onSubmit:async()=>{await u({projectId:e.project._id,name:W.trim()}),H(!1)},submitLabel:r(),children:(0,X.jsx)(P,{value:W,onChange:e=>dt(e.target.value),autoFocus:!0})}),G?(0,X.jsx)(nt,{open:G,onOpenChange:ht,title:le(),movingFolderId:e.project._id,currentId:e.project.parentId,onPick:t=>void g({projectId:e.project._id,parentId:t})}):null,Be]}),(0,X.jsx)(Ne,{children:Dt?(0,X.jsxs)(`div`,{className:`oc-projpage__dragghost`,children:[Dt.kind===`folder`?(0,X.jsx)(R,{size:13,"aria-hidden":!0}):(0,X.jsx)(Pe,{size:13,"aria-hidden":!0}),(0,X.jsx)(`span`,{children:Dt.label})]}):null})]})})}function jt({folderId:e,children:t}){let{setNodeRef:n,isOver:r}=H({id:Dt(e)});return(0,X.jsx)(`span`,{ref:n,className:r?`oc-projpage__cdrop is-over`:`oc-projpage__cdrop`,children:t})}function Mt({child:e,parentId:t,now:n,suppressClick:r}){let i=z(),a=F({id:`folder:${e._id}`}),o=H({id:Q(e._id)});return(0,X.jsxs)(`div`,{ref:e=>{a.setNodeRef(e),o.setNodeRef(e)},className:`oc-projpage__card`+(o.isOver?` is-over`:``)+(a.isDragging?` is-dragging`:``),style:{"--proj-hue":mt(e),transform:I.Transform.toString(a.transform),transition:a.transition},onClick:()=>{r.current||i({to:`/project/$projectId`,params:{projectId:e._id}})},onKeyDown:t=>{t.key===`Enter`&&i({to:`/project/$projectId`,params:{projectId:e._id}})},...a.listeners,...a.attributes,role:`link`,tabIndex:0,children:[(0,X.jsxs)(`span`,{className:`oc-projpage__cardhead`,children:[(0,X.jsx)(R,{size:15,"aria-hidden":!0,className:`oc-projpage__cardico`}),(0,X.jsx)(`span`,{className:`oc-projpage__cardname`,children:e.name}),(0,X.jsx)(Z,{folderId:e._id,name:e.name,color:e.color,currentParentId:t,className:`oc-projpage__cardmenu`,onOpen:()=>void i({to:`/project/$projectId`,params:{projectId:e._id}})})]}),(0,X.jsxs)(`span`,{className:`oc-projpage__cardmeta`,children:[e.folderCount>0?_({count:e.folderCount})+` · `:``,M({count:e.recursiveChatCount})]}),e.lastActivityAt===null?null:(0,X.jsx)(`span`,{className:`oc-projpage__cardage`,children:et(e.lastActivityAt,n)})]})}function Nt({chat:e}){let t=v(j.chats.setChatSidebar),n=e.inSidebar?h():u();return(0,X.jsx)(N,{variant:`ghost`,size:`icon-xs`,"aria-label":n,title:n,className:`oc-projpage__barbtn`+(e.inSidebar?` is-on`:``),disabled:e.pinned&&e.inSidebar,onClick:n=>{n.stopPropagation(),t({chatId:e._id,hidden:e.inSidebar})},children:e.inSidebar?(0,X.jsx)(L,{}):(0,X.jsx)(J,{})})}function Pt({chat:e,currentFolderId:t,now:n,busy:r,unread:i,locate:a,suppressClick:o}){let s=(0,Y.useContext)(V).get(e._id),c=z(),l=G(e.color),u=F({id:`chat:${e._id}`}),d=$(a);return(0,X.jsxs)(`li`,{ref:e=>{u.setNodeRef(e),d.current=e},className:`oc-projpage__chatrow`+(u.isDragging?` is-dragging`:``)+(a?` is-locate`:``),style:{transform:I.Transform.toString(u.transform),transition:u.transition},children:[(0,X.jsxs)(`button`,{type:`button`,className:`oc-projpage__chatbtn`,onClick:()=>{o.current||c({to:`/chat/$chatId`,params:{chatId:e._id}})},...u.listeners,...u.attributes,children:[l?(0,X.jsx)(`span`,{className:`oc-chatitem__dot`,style:{background:l}}):(0,X.jsx)(`span`,{className:`oc-chatitem__dot oc-chatitem__dot--empty`}),(0,X.jsx)(`span`,{className:`oc-projpage__chattitle`,children:e.title||b()}),e.pinned?(0,X.jsx)(je,{size:12,"aria-hidden":!0,className:`oc-projpage__chatpin`}):null,(0,X.jsx)(`span`,{className:`oc-projpage__chatage`,children:et(e.updatedAt,n)}),r?(0,X.jsx)(`span`,{className:B(s,x()).className,title:B(s,x()).label,"aria-label":B(s,x()).label}):null,i&&!r?(0,X.jsx)(`span`,{className:`oc-chatitem__unread`,title:y(),"aria-label":y()}):null]}),(0,X.jsx)(Nt,{chat:e}),(0,X.jsx)(bt,{chat:e,currentFolderId:t,className:`oc-projpage__chatmenu`})]})}function $(e){let t=(0,Y.useRef)(null);return(0,Y.useEffect)(()=>{e&&t.current&&t.current.scrollIntoView({block:`center`})},[e]),t}function Ft({data:e,busyIds:t,suppressClick:n,locateChatId:r}){let[i,a]=(0,Y.useState)(new Set),o=(0,Y.useMemo)(()=>{let t=new Map;for(let n of e?.chats??[]){let e=t.get(n.folderId);e===void 0?t.set(n.folderId,[n]):e.push(n)}return t},[e]);if(e===void 0)return(0,X.jsx)(`p`,{className:`oc-projpage__hint`,children:k()});if(e===null)return null;let s=e=>a(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),c=(a,l)=>{let u=o.get(a??e.rootId)??[],d=st(e.folders,a);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(q,{items:u.map(e=>`chat:${e._id}`),strategy:K,children:u.map(e=>(0,X.jsx)(Lt,{chat:e,depth:l,busy:t.has(e._id),locate:e._id===r,suppressClick:n},e._id))}),(0,X.jsx)(q,{items:d.map(e=>`folder:${e._id}`),strategy:K,children:d.map(t=>(0,X.jsx)(It,{folder:t,parentId:a??e.rootId,depth:l,folded:i.has(t._id),onToggle:()=>s(t._id),suppressClick:n,children:i.has(t._id)?null:c(t._id,l+1)},t._id))})]})};return(0,X.jsx)(`div`,{className:`oc-projpage__tree`,children:(o.get(e.rootId)??[]).length===0&&st(e.folders,null).length===0?(0,X.jsx)(`p`,{className:`oc-projpage__hint`,children:Se()}):c(null,0)})}function It({folder:e,parentId:t,depth:n,folded:r,onToggle:i,suppressClick:a,children:o}){let c=z(),u=F({id:`folder:${e._id}`}),d=H({id:Q(e._id)});return(0,X.jsxs)(`div`,{className:`oc-projpage__treegroup`,children:[(0,X.jsxs)(`div`,{ref:e=>{u.setNodeRef(e),d.setNodeRef(e)},className:`oc-projpage__treerow oc-projpage__treerow--folder`+(d.isOver?` is-over`:``)+(u.isDragging?` is-dragging`:``),style:{"--tree-depth":n,"--proj-hue":mt(e),transform:I.Transform.toString(u.transform),transition:u.transition},...u.listeners,...u.attributes,role:`button`,tabIndex:0,onClick:()=>{a.current||c({to:`/project/$projectId`,params:{projectId:e._id}})},onKeyDown:t=>{t.key===`Enter`&&c({to:`/project/$projectId`,params:{projectId:e._id}})},children:[(0,X.jsx)(`button`,{type:`button`,className:`oc-projpage__treechev`,"aria-label":r?s():l(),"aria-expanded":!r,onClick:e=>{e.stopPropagation(),!a.current&&i()},onMouseDown:e=>e.stopPropagation(),onTouchStart:e=>e.stopPropagation(),children:r?(0,X.jsx)(dt,{size:13}):(0,X.jsx)(Ee,{size:13})}),(0,X.jsx)(R,{size:13,"aria-hidden":!0,className:`oc-projpage__colico`}),(0,X.jsx)(`span`,{className:`oc-projpage__colname`,children:e.name}),(0,X.jsx)(Z,{folderId:e._id,name:e.name,color:e.color,currentParentId:t,className:`oc-projpage__treemenu`,onOpen:()=>void c({to:`/project/$projectId`,params:{projectId:e._id}})})]}),o]})}function Lt({chat:e,depth:t,busy:n,locate:r,suppressClick:i}){let a=(0,Y.useContext)(V).get(e._id),o=z(),s=F({id:`chat:${e._id}`}),c=$(r),l=G(e.color);return(0,X.jsxs)(`div`,{ref:e=>{s.setNodeRef(e),c.current=e},className:`oc-projpage__treerow oc-projpage__treerow--chat`+(s.isDragging?` is-dragging`:``)+(r?` is-locate`:``),style:{"--tree-depth":t,transform:I.Transform.toString(s.transform),transition:s.transition},children:[(0,X.jsxs)(`button`,{type:`button`,className:`oc-projpage__colchatbtn`,onClick:()=>{i.current||o({to:`/chat/$chatId`,params:{chatId:e._id}})},...s.listeners,...s.attributes,children:[l?(0,X.jsx)(`span`,{className:`oc-chatitem__dot`,style:{background:l}}):(0,X.jsx)(`span`,{className:`oc-chatitem__dot oc-chatitem__dot--empty`}),(0,X.jsx)(`span`,{className:`oc-projpage__colname`,children:e.title||b()}),n?(0,X.jsx)(`span`,{className:B(a,``).className,"aria-hidden":!0}):null]}),(0,X.jsx)(bt,{chat:e,currentFolderId:e.folderId,className:`oc-projpage__treemenu`}),(0,X.jsx)(Nt,{chat:e})]})}function Rt({data:e,currentId:t,busyIds:n,suppressClick:r,locateChatId:i}){let a=(0,Y.useRef)(null);return(0,Y.useEffect)(()=>{let e=a.current;e&&(e.scrollLeft=e.scrollWidth)},[e?.columns.length??0,t]),e===void 0?(0,X.jsx)(`p`,{className:`oc-projpage__hint`,children:k()}):(0,X.jsx)(`div`,{className:`oc-projpage__cols`,ref:a,children:e.columns.map((a,o)=>(0,X.jsx)(zt,{col:a,isLast:o===e.columns.length-1,currentId:t,busyIds:n,suppressClick:r,locateChatId:i},a.folderId??`root`))})}function zt({col:e,isLast:t,currentId:n,busyIds:r,suppressClick:i,locateChatId:a}){let o=z(),s=H({id:Et(e.folderId)});return(0,X.jsxs)(`div`,{ref:s.setNodeRef,className:`oc-projpage__col`+(s.isOver?` is-over`:``)+(t?` is-last`:``),children:[(0,X.jsx)(q,{items:e.folders.map(e=>`folder:${e._id}`),strategy:K,children:e.folders.map(t=>(0,X.jsx)(Bt,{folder:t,parentId:e.folderId,isCurrent:t._id===n,suppressClick:i,onOpen:()=>void o({to:`/project/$projectId`,params:{projectId:t._id}})},t._id))}),(0,X.jsx)(q,{items:e.chats.map(e=>`chat:${e._id}`),strategy:K,children:e.chats.map(t=>(0,X.jsx)(Vt,{chat:t,folderId:e.folderId,busy:r.has(t._id),locate:t._id===a,suppressClick:i,onOpen:()=>void o({to:`/chat/$chatId`,params:{chatId:t._id}})},t._id))}),e.folders.length===0&&e.chats.length===0?(0,X.jsx)(`p`,{className:`oc-projpage__colempty`,children:se()}):null]})}function Bt({folder:e,parentId:t,isCurrent:n,suppressClick:r,onOpen:i}){let a=F({id:`folder:${e._id}`}),o=H({id:Q(e._id)});return(0,X.jsxs)(`div`,{ref:e=>{a.setNodeRef(e),o.setNodeRef(e)},className:`oc-projpage__colentry oc-projpage__colentry--folder`+(e.selected||n?` is-selected`:``)+(o.isOver?` is-over`:``)+(a.isDragging?` is-dragging`:``),style:{"--proj-hue":mt(e),transform:I.Transform.toString(a.transform),transition:a.transition},onClick:()=>{r.current||i()},onKeyDown:e=>{e.key===`Enter`&&e.target===e.currentTarget&&i()},...a.listeners,...a.attributes,role:`button`,tabIndex:0,children:[(0,X.jsx)(R,{size:13,"aria-hidden":!0,className:`oc-projpage__colico`}),(0,X.jsx)(`span`,{className:`oc-projpage__colname`,children:e.name}),(0,X.jsx)(`span`,{className:`oc-projpage__colchev`,"aria-hidden":!0,children:`›`}),(0,X.jsx)(Z,{folderId:e._id,name:e.name,color:e.color,currentParentId:t,className:`oc-projpage__colmenu`,onOpen:i})]})}function Vt({chat:e,folderId:t,busy:n,locate:r,suppressClick:i,onOpen:a}){let o=(0,Y.useContext)(V).get(e._id),s=F({id:`chat:${e._id}`}),c=$(r),l=G(e.color);return(0,X.jsxs)(`div`,{ref:e=>{s.setNodeRef(e),c.current=e},className:`oc-projpage__colentry oc-projpage__colentry--chat`+(s.isDragging?` is-dragging`:``)+(r?` is-locate`:``),style:{transform:I.Transform.toString(s.transform),transition:s.transition},children:[(0,X.jsxs)(`button`,{type:`button`,className:`oc-projpage__colchatbtn`,onClick:()=>{i.current||a()},...s.listeners,...s.attributes,children:[l?(0,X.jsx)(`span`,{className:`oc-chatitem__dot`,style:{background:l}}):(0,X.jsx)(`span`,{className:`oc-chatitem__dot oc-chatitem__dot--empty`}),(0,X.jsx)(`span`,{className:`oc-projpage__colname`,children:e.title||b()}),n?(0,X.jsx)(`span`,{className:B(o,``).className,"aria-hidden":!0}):null]}),(0,X.jsx)(bt,{chat:e,currentFolderId:t,className:`oc-projpage__colmenu oc-projpage__colmenu--chat`}),(0,X.jsx)(Nt,{chat:e})]})}export{kt as ProjectPage};
@@ -1,4 +0,0 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$O as r,Bd as i,Bp as a,CY as o,Hp as s,Id as c,JO as l,Jd as u,Ld as d,QO as f,Rd as p,Rp as m,SY as h,Vp as g,XO as _,Xd as ee,YO as te,Yd as ne,ZO as v,ak as y,au as b,bk as x,ck as S,dk as C,ek as re,fk as w,ik as ie,lk as ae,nk as oe,ok as se,ou as T,qO as E,qd as D,rk as O,sk as k,su as A,t as j,tk as M,uk as N,xo as P,yk as F,zd as I,zp as L}from"./api-IF2KQFNF.js";import{i as R,n as z,r as B,t as V}from"./FieldLabel-BVUMb8MI.js";import{t as H}from"./button-DDPt-po9.js";import{Mt as U,St as W,Yt as G,bt as K,ft as ce,gn as le,hn as ue,mn as de,pn as q,vt as J,xt as Y,yt as X}from"./index-DaLXKABQ.js";import{r as Z,t as fe}from"./locales-CPjguROj.js";import{t as pe}from"./localePickerView-C2RmOS86.js";/* empty css */var Q=t(e(),1),$=n(),me={media_delivery:{label:k,help:se},documentary_fetch:{label:y,help:ie},inbound_files:{label:O,help:oe},history_summary:{label:s,help:g},file_curation:{label:ee,help:i},quote_reply:{label:ne,help:u}},he={outboundDir:`/home/node/.openclaw/media/outbound`,references:`- gdrive/1a2b3c4d5e6f7890abcd
2
- - gdrive/0f9e8d7c6b5a4321dcba`,files:`- /home/node/.openclaw/media/inbound/rapport.pdf (124800 o, application/pdf)`,previous_summary:`Projet Alpha : budget 40 000 EUR ; choix du serveur en cours.`,new_messages:`Utilisateur : Compare OVH et Scaleway.
3
- Assistant : Comparaison en cours.`,max_chars:`6000`,file_name:`MEMORY.md`,budget_chars:`20000`,feedback:`Trop de suppressions dans la section des liens, garde-les.`,content:`# Memory index
4
- - [Fait 1](fait-1.md) - note du projet`,excerpt:`Le classement propose trois dossiers : Clients, Fournisseurs, Interne.`},ge={outboundDir:te,references:l,files:E,previous_summary:a,new_messages:L,max_chars:m,file_name:I,budget_chars:p,feedback:d,content:c,excerpt:D};function _e(){let e=o(j.admin.listInstances,{}),[t,n]=(0,Q.useState)(null);if(e===void 0)return(0,$.jsx)(`div`,{className:`oc-settings__tab-loading`,"aria-busy":`true`});if(e.length===0)return(0,$.jsx)(`div`,{className:`oc-injtab`,children:(0,$.jsx)(`p`,{className:`oc-admin__hint`,children:re()})});let r=e.find(e=>e._id===t)??e[0];return(0,$.jsxs)(`div`,{className:`oc-injtab`,children:[(0,$.jsxs)(`div`,{className:`oc-injtab__head`,children:[(0,$.jsx)(z,{label:w(),help:C()}),(0,$.jsxs)(`label`,{className:`oc-injtab__picker`,children:[(0,$.jsx)(`span`,{children:M()}),(0,$.jsxs)(J,{value:r._id,onValueChange:e=>n(e),children:[(0,$.jsx)(Y,{size:`sm`,className:`min-w-44`,children:(0,$.jsx)(W,{})}),(0,$.jsx)(X,{children:e.map(e=>(0,$.jsx)(K,{value:e._id,children:e.displayName??e.name},e._id))})]})]})]}),(0,$.jsx)(ve,{instance:r},r._id)]})}function ve({instance:e}){let t=h(j.admin.upsertInstanceConfig),n=G(),r=o(j.me.getMe,{host:ce}),i=e.config??{},a=Z(e.config?.contentLocale,r?.defaultLocale??void 0),[s,c]=(0,Q.useState)(()=>R(i,a));(0,Q.useEffect)(()=>{c(R(i,a))},[a,e._id]);let[l,u]=(0,Q.useState)(!1),d=s.promptInjections,f=(e,t)=>c({...s,promptInjections:{...d,[e]:{...d[e],...t}}});async function p(){u(!0);try{await t({instanceId:e._id,config:B(s,i,a)})}catch(e){n.error(F(),e)}finally{u(!1)}}async function m(r){let i={...e.config??{}};r==="default"?delete i.contentLocale:i.contentLocale=r;try{await t({instanceId:e._id,config:i})}catch(e){n.error(F(),e)}}let g=e.config?.contentLocale??`default`,_=fe[Z(void 0,r?.defaultLocale??void 0)];return(0,$.jsxs)(`div`,{className:`oc-injtab__body`,children:[(0,$.jsxs)(`div`,{className:`oc-injtab__content-locale`,children:[(0,$.jsx)(`span`,{children:A()}),(0,$.jsxs)(J,{value:g,onValueChange:e=>void m(e),children:[(0,$.jsx)(Y,{size:`sm`,className:`min-w-44`,children:(0,$.jsx)(W,{})}),(0,$.jsxs)(X,{children:[(0,$.jsx)(K,{value:`default`,children:b({locale:_})}),pe().map(e=>(0,$.jsx)(K,{value:e.value,children:e.label},e.value))]})]}),(0,$.jsx)(`p`,{className:`oc-admin__hint`,children:T()})]}),de.map(e=>(0,$.jsx)(ye,{injKey:e,def:q[e],i18n:me[e],row:d[e]??{enabled:!0,template:q[e].defaultTemplate[a]},contentLocale:a,onChange:t=>f(e,t)},e)),(0,$.jsx)(`div`,{className:`oc-injtab__actions`,children:(0,$.jsx)(H,{size:`sm`,onClick:()=>void p(),disabled:l,children:x()})})]})}function ye({injKey:e,def:t,i18n:n,row:i,contentLocale:a,onChange:o}){let[s,c]=(0,Q.useState)(!1),l=i.template.trim()!==t.defaultTemplate[a],u=t.togglable&&!i.enabled,d=Object.fromEntries(t.placeholders.map(e=>[e,he[e]??`{${e}}`])),p=ue(e,i,a),m=p?le(p,d):``;return(0,$.jsxs)(`section`,{className:`oc-injcard`,children:[(0,$.jsxs)(`div`,{className:`oc-injcard__head`,children:[t.togglable?(0,$.jsxs)(`label`,{className:`oc-field--row`,children:[(0,$.jsx)(U,{checked:i.enabled,onCheckedChange:e=>o({enabled:e===!0})}),(0,$.jsx)(z,{label:n.label(),help:n.help()})]}):(0,$.jsx)(z,{label:n.label(),help:n.help()}),l&&(0,$.jsx)(`span`,{className:`oc-injection__badge`,children:ae()})]}),(0,$.jsx)(`textarea`,{className:`oc-injcard__text`,value:i.template,disabled:u,rows:8,spellCheck:!1,onChange:e=>o({template:e.target.value})}),(0,$.jsxs)(`div`,{className:`oc-injection__foot`,children:[(0,$.jsxs)(`div`,{className:`oc-injcard__phs`,children:[(0,$.jsx)(`span`,{className:`oc-injection__ph`,children:S()}),t.placeholders.map(e=>(0,$.jsxs)(`span`,{className:`oc-injcard__ph-chip`,children:[(0,$.jsx)(`code`,{children:`{${e}}`}),(0,$.jsx)(V,{text:(ge[e]??(()=>e))()})]},e))]}),(0,$.jsxs)(`div`,{className:`oc-injcard__btns`,children:[(0,$.jsx)(H,{variant:`ghost`,size:`sm`,onClick:()=>c(e=>!e),children:s?f():r()}),l&&(0,$.jsx)(H,{variant:`ghost`,size:`sm`,onClick:()=>o({template:t.defaultTemplate[a]}),children:N()})]})]}),s&&(0,$.jsx)(`div`,{className:`oc-injcard__preview`,children:m?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`pre`,{className:`oc-injcard__previewtext`,children:m}),(0,$.jsx)(`span`,{className:`oc-injection__ph`,children:v()}),t.pluralDefaultTemplate!==void 0&&!u?(0,$.jsx)(`span`,{className:`oc-injection__ph`,children:P()}):null]}):(0,$.jsx)(`span`,{className:`oc-injection__ph`,children:_()})})]})}export{_e as PromptInjectionsTab};
@@ -1 +0,0 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$M as r,AM as ee,BM as i,CM as te,CY as a,DM as o,EM as s,GM as c,HM as l,JM as u,KM as ne,LM as d,OM as re,QM as ie,RM as ae,SY as f,TM as p,UM as m,VM as h,WM as g,XM as _,YM as v,ZM as y,aN as b,bf as x,cN as S,dN as C,eN as w,fN as T,iN as E,jM as D,kM as O,lN as k,nN as A,oN as j,pN as M,qM as N,rN as P,sN as F,t as I,tN as L,uN as R,wM as oe,zM as z}from"./api-IF2KQFNF.js";import{t as B}from"./button-DDPt-po9.js";import{$t as V,Jt as H,Mt as U,Yt as W,b as G,ct as K,qn as q}from"./index-DaLXKABQ.js";import{t as J}from"./roleDescriptions-DBJFh3-K.js";var Y=t(e(),1),X=n(),Z=[{group:()=>M(),keys:[{key:`traces.read`,label:()=>S()},{key:`traces.read.content`,label:()=>F(),phi:!0},{key:`traces.write`,label:()=>j()}]},{group:()=>T(),keys:[{key:`kpi.read`,label:()=>S()},{key:`kpi.write`,label:()=>j()}]},{group:()=>C(),keys:[{key:`openclaw.query`,label:()=>b()},{key:`anomalies.read`,label:()=>E()},{key:`anomalies.report`,label:()=>P()}]},{group:()=>R(),keys:[{key:`chats.read`,label:()=>S()},{key:`selfheal`,label:()=>L()},{key:`media.repair`,label:()=>w()},{key:`feedback.respond`,label:()=>x()}]},{group:()=>k(),keys:[{key:`admin.manage`,label:()=>A()}]}],se=Z.flatMap(e=>e.keys.map(e=>e.key));function Q(e){return e.includes(`*`)}var $={key:``,name:``,description:``};function ce(){let e=a(I.apiKeys.listRoles,{}),t=f(I.apiKeys.createRole),n=f(I.apiKeys.ensureRolesSeeded),b=f(I.apiKeys.updateRolePermissions).withOptimisticUpdate((e,{roleId:t,permissions:n})=>{let r=e.getQuery(I.apiKeys.listRoles,{});r&&e.setQuery(I.apiKeys.listRoles,{},r.map(e=>e._id===t?{...e,permissions:n}:e))}),x=K(),S=W(),[C,w]=(0,Y.useState)(!1),[T,E]=(0,Y.useState)($),[k,A]=(0,Y.useState)(new Set);(0,Y.useEffect)(()=>{n({}).catch(e=>{S.error(ie(),e)})},[n,S]);let j=e??[];async function M(e,t){if(Q(e.permissions))return;if(e.builtin){await x({title:y({name:e.name}),description:_(),confirmLabel:v()});return}if(k.has(e._id))return;let n=e.permissions.includes(t)?e.permissions.filter(e=>e!==t):[...e.permissions,t];A(t=>new Set(t).add(e._id));try{await b({roleId:e._id,permissions:n})}catch(e){S.error(u(),e)}finally{A(t=>{let n=new Set(t);return n.delete(e._id),n})}}async function P(){try{await t({key:T.key,name:T.name,description:T.description||void 0,permissions:[]}),E($),w(!1)}catch(e){S.error(N(),e)}}let F=e===void 0,L=!F&&j.length===0;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`p`,{className:`oc-admin__hint`,children:[ne(),` `,(0,X.jsx)(`code`,{children:`admin`}),` `,c(),` `,(0,X.jsx)(`code`,{children:`traces.read.content`}),` `,g()]}),(0,X.jsxs)(`div`,{className:`oc-dt`,children:[(0,X.jsxs)(`div`,{className:`oc-dt__bar`,children:[(0,X.jsx)(`h2`,{className:`oc-dt__title`,children:m()}),(0,X.jsx)(`div`,{className:`oc-dt__bar-actions`,children:(0,X.jsx)(B,{size:`sm`,onClick:()=>{E($),w(!0)},children:l()})})]}),F?(0,X.jsx)(`p`,{className:`oc-admin__hint`,children:h()}):L?(0,X.jsx)(`p`,{className:`oc-admin__hint`,children:i()}):(0,X.jsx)(`div`,{className:`oc-matrix__scroll`,children:(0,X.jsxs)(`table`,{className:`oc-matrix`,children:[(0,X.jsxs)(`thead`,{children:[(0,X.jsxs)(`tr`,{children:[(0,X.jsx)(`th`,{className:`oc-matrix__corner`,rowSpan:2,children:z()}),Z.map(e=>(0,X.jsx)(`th`,{className:`oc-matrix__group`,colSpan:e.keys.length,children:e.group()},e.group()))]}),(0,X.jsx)(`tr`,{children:Z.flatMap(e=>e.keys.map(e=>(0,X.jsxs)(`th`,{className:`oc-matrix__perm`,title:e.phi?r({key:e.key}):e.key,children:[e.label(),e.phi?(0,X.jsx)(`span`,{className:`oc-matrix__phi`,children:` ⚠`}):null]},e.key)))})]}),(0,X.jsx)(`tbody`,{children:j.map(e=>{let t=Q(e.permissions),n=k.has(e._id);return(0,X.jsxs)(`tr`,{children:[(0,X.jsxs)(`th`,{className:`oc-matrix__rolecell`,children:[(0,X.jsxs)(`div`,{className:`oc-matrix__rolename`,children:[(0,X.jsx)(`span`,{children:e.name}),(0,X.jsx)(`code`,{className:`oc-matrix__rolekey`,children:e.key}),e.builtin?(0,X.jsxs)(H,{variant:`outline`,className:`gap-1`,children:[(0,X.jsx)(q,{}),` `,ae()]}):(0,X.jsx)(H,{variant:`secondary`,children:d()})]}),J(e)?(0,X.jsx)(`p`,{className:`oc-matrix__roledesc`,children:J(e)}):null]}),se.map(r=>(0,X.jsx)(`td`,{className:`oc-matrix__cell`,children:(0,X.jsx)(U,{checked:t||e.permissions.includes(r),disabled:t||n,"aria-label":`${e.key} · ${r}`,title:t?D():n?ee():r,onCheckedChange:()=>void M(e,r)})},r))]},e.key)})})]})})]}),(0,X.jsx)(G,{open:C,onOpenChange:w,title:O(),description:re(),canSubmit:!!(T.key&&T.name),onSubmit:P,submitLabel:o(),children:(0,X.jsxs)(`div`,{className:`oc-form`,children:[(0,X.jsxs)(`label`,{className:`oc-field`,children:[(0,X.jsx)(`span`,{className:`oc-field__label`,children:s()}),(0,X.jsx)(V,{value:T.key,placeholder:p(),onChange:e=>E({...T,key:e.target.value})})]}),(0,X.jsxs)(`label`,{className:`oc-field`,children:[(0,X.jsx)(`span`,{className:`oc-field__label`,children:oe()}),(0,X.jsx)(V,{value:T.name,onChange:e=>E({...T,name:e.target.value})})]}),(0,X.jsxs)(`label`,{className:`oc-field`,children:[(0,X.jsx)(`span`,{className:`oc-field__label`,children:te()}),(0,X.jsx)(V,{value:T.description,onChange:e=>E({...T,description:e.target.value})})]})]})})]})}export{ce as RolesTab};