@lacneu/atrium 0.74.2 → 0.74.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 (39) hide show
  1. package/dist/assets/{AccessTab-DStk63ub.js → AccessTab-jEh3iYB7.js} +1 -1
  2. package/dist/assets/{AdvancedFilter-D9vv5fSO.js → AdvancedFilter-CddmHJ3w.js} +1 -1
  3. package/dist/assets/{AgentFilesTab-BtxlN1ws.js → AgentFilesTab-Bm4UCoem.js} +1 -1
  4. package/dist/assets/{AnomaliesTab-CI4tjmIN.js → AnomaliesTab-6y5Od0XI.js} +1 -1
  5. package/dist/assets/{AuditTab-D4uX3vAo.js → AuditTab-C2G5v_Qa.js} +1 -1
  6. package/dist/assets/{BridgeTab-oURsmznB.js → BridgeTab-CFlYnmQx.js} +1 -1
  7. package/dist/assets/{ChatDefaultsTab-Cv8YntGa.js → ChatDefaultsTab-CJicxQ2m.js} +1 -1
  8. package/dist/assets/{DataTableShell-D2PIAVAw.js → DataTableShell-CFPC-1m0.js} +1 -1
  9. package/dist/assets/{DetailChips-Z_U4y6U9.js → DetailChips-BzlFlRnK.js} +1 -1
  10. package/dist/assets/{FeedbacksTab-CVqv0gek.js → FeedbacksTab-TvLJvmvO.js} +1 -1
  11. package/dist/assets/{FieldLabel-DylbQ765.js → FieldLabel-DRaqrHBA.js} +1 -1
  12. package/dist/assets/{FilesTab-rfwATtRD.js → FilesTab-DpMD122m.js} +1 -1
  13. package/dist/assets/{FilterBar-D99V_QOK.js → FilterBar-DqZs9qry.js} +1 -1
  14. package/dist/assets/{GroupsTab-BjneoHMM.js → GroupsTab-D7Bedj8Y.js} +1 -1
  15. package/dist/assets/{InstancesTab-Bj3E0xRe.js → InstancesTab-ajTCr_rQ.js} +1 -1
  16. package/dist/assets/{IntegrationsTab-Bxx_tCDk.js → IntegrationsTab-dZwon69M.js} +1 -1
  17. package/dist/assets/{KpiTab-B6FjAeft.js → KpiTab-CI_vX795.js} +1 -1
  18. package/dist/assets/{PreferencesTab-DoFiqtFh.js → PreferencesTab-DiWwpvUZ.js} +1 -1
  19. package/dist/assets/{ProjectPage-VO-zERMD.js → ProjectPage-Bl3z7qKJ.js} +1 -1
  20. package/dist/assets/{PromptInjectionsTab-CC5UtKbU.js → PromptInjectionsTab-CVCzk8WZ.js} +1 -1
  21. package/dist/assets/{RolesTab-DIfAPBDN.js → RolesTab-Cwvh5UX7.js} +1 -1
  22. package/dist/assets/{ScheduledTab-CqTxkCOW.js → ScheduledTab-CSi-6T6L.js} +1 -1
  23. package/dist/assets/{ServiceAccountsTab-D1xuJN0i.js → ServiceAccountsTab-lWYGnbru.js} +1 -1
  24. package/dist/assets/{SubAgentReportsTab-BRQaHEfK.js → SubAgentReportsTab-DgywNtaI.js} +1 -1
  25. package/dist/assets/{ThemeShowroom-roD7KgSn.js → ThemeShowroom-D2G9Tsvs.js} +1 -1
  26. package/dist/assets/{TimeRangePicker-B-foA1-L.js → TimeRangePicker-4TbN0Xgb.js} +1 -1
  27. package/dist/assets/{TimezoneCombobox-C33f4gjg.js → TimezoneCombobox-CSGhMAXx.js} +1 -1
  28. package/dist/assets/{TracesTab-CMbFlcVv.js → TracesTab-B--i9MDN.js} +1 -1
  29. package/dist/assets/{UsersTab-tghO1HS0.js → UsersTab-ClI6-Y1a.js} +1 -1
  30. package/dist/assets/{VoiceTab-DuE2Wg3C.js → VoiceTab-DMhqIkTY.js} +1 -1
  31. package/dist/assets/{highlighted-body-OFNGDK62-D3zI5Iaq.js → highlighted-body-OFNGDK62-DB0iRCUQ.js} +1 -1
  32. package/dist/assets/{index-DtAFZhtv.js → index-B0ufU8aN.js} +6 -6
  33. package/dist/assets/{index-SBwQs_kQ.css → index-BrEi5y-K.css} +1 -1
  34. package/dist/assets/mermaid-GHXKKRXX-C4N2jMYZ.js +1 -0
  35. package/dist/assets/{pdf-BcmjxerI.js → pdf-9uj30gDA.js} +1 -1
  36. package/dist/assets/{tabs-Nve_dRxd.js → tabs-DbSY71M_.js} +1 -1
  37. package/dist/index.html +2 -2
  38. package/package.json +1 -1
  39. package/dist/assets/mermaid-GHXKKRXX-gnKwp22y.js +0 -1
@@ -1 +1 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{XR as r,_p as i,az as a,bp as o,cp as s,dp as c,fp as l,gp as u,hp as d,lp as f,mp as p,pp as m,sp as h,t as g,up as _,vp as v,xp as y,yp as b}from"./api-BDOBe_HI.js";import{$ as x,Et as S,Q as C,X as w,Z as T,et as E}from"./index-DtAFZhtv.js";var D=t(e(),1);function O(e){return e===`user`?c():e===`all`?_():f({group:e.group})}function k(e){return e===`common`?s():e===`owner`?h():f({group:e.group})}var A=n();function j(e){return e.name||e.email||e.userId.slice(0,8)}function M(){let e=a(g.admin.listUsers,{}),[t,n]=(0,D.useState)(``),s=a(g.introspect.introspectUser,t?{userId:t}:`skip`);return(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`p`,{className:`oc-admin__hint`,children:y()}),(0,A.jsxs)(w,{value:t,onValueChange:n,children:[(0,A.jsx)(x,{size:`sm`,"aria-label":o(),children:(0,A.jsx)(E,{placeholder:o()})}),(0,A.jsx)(T,{children:(e??[]).map(e=>(0,A.jsx)(C,{value:e.userId,children:j(e)},e._id))})]}),t===``?(0,A.jsx)(`p`,{className:`oc-admin__hint`,children:b()}):s===void 0?(0,A.jsx)(`p`,{className:`oc-admin__hint`,children:r()}):(0,A.jsxs)(`div`,{className:`oc-introspect`,children:[(0,A.jsxs)(`section`,{className:`oc-introspect__section`,children:[(0,A.jsx)(`h3`,{className:`oc-introspect__title`,children:v()}),(0,A.jsxs)(`div`,{className:`oc-introspect__id`,children:[(0,A.jsx)(`strong`,{children:s.user.label}),(0,A.jsx)(S,{variant:`secondary`,children:s.role})]})]}),(0,A.jsxs)(`section`,{className:`oc-introspect__section`,children:[(0,A.jsx)(`h3`,{className:`oc-introspect__title`,children:i()}),s.groups.length===0?(0,A.jsx)(`p`,{className:`oc-admin__hint`,children:m()}):(0,A.jsx)(`div`,{className:`oc-introspect__chips`,children:s.groups.map(e=>(0,A.jsx)(S,{variant:`secondary`,children:e.name},e.groupId))})]}),(0,A.jsxs)(`section`,{className:`oc-introspect__section`,children:[(0,A.jsx)(`h3`,{className:`oc-introspect__title`,children:u()}),s.agents.length===0?(0,A.jsx)(`p`,{className:`oc-admin__hint`,children:m()}):(0,A.jsx)(`ul`,{className:`oc-introspect__list`,children:s.agents.map(e=>(0,A.jsxs)(`li`,{className:`oc-introspect__row`,children:[(0,A.jsx)(`span`,{className:`oc-introspect__name`,children:e.displayName||e.agentId}),e.isDefault?(0,A.jsx)(S,{variant:`default`,children:l()}):null,(0,A.jsx)(S,{variant:`outline`,children:O(e.via)}),(0,A.jsx)(S,{variant:`secondary`,children:e.state})]},`${e.instanceName} ${e.agentId}`))})]}),(0,A.jsxs)(`section`,{className:`oc-introspect__section`,children:[(0,A.jsx)(`h3`,{className:`oc-introspect__title`,children:d()}),s.charts.length===0?(0,A.jsx)(`p`,{className:`oc-admin__hint`,children:m()}):(0,A.jsx)(`ul`,{className:`oc-introspect__list`,children:s.charts.map(e=>(0,A.jsxs)(`li`,{className:`oc-introspect__row`,children:[(0,A.jsx)(`span`,{className:`oc-introspect__name`,children:e.name}),(0,A.jsx)(S,{variant:`outline`,children:k(e.via)})]},e.key))})]}),(0,A.jsxs)(`section`,{className:`oc-introspect__section`,children:[(0,A.jsx)(`h3`,{className:`oc-introspect__title`,children:p()}),s.permissions.length===0?(0,A.jsx)(`p`,{className:`oc-admin__hint`,children:m()}):(0,A.jsx)(`div`,{className:`oc-introspect__chips`,children:s.permissions.map(e=>(0,A.jsx)(S,{variant:`secondary`,children:e},e))})]})]})]})}export{M as AccessTab};
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{XR as r,_p as i,az as a,bp as o,cp as s,dp as c,fp as l,gp as u,hp as d,lp as f,mp as p,pp as m,sp as h,t as g,up as _,vp as v,xp as y,yp as b}from"./api-BDOBe_HI.js";import{$ as x,Et as S,Q as C,X as w,Z as T,et as E}from"./index-B0ufU8aN.js";var D=t(e(),1);function O(e){return e===`user`?c():e===`all`?_():f({group:e.group})}function k(e){return e===`common`?s():e===`owner`?h():f({group:e.group})}var A=n();function j(e){return e.name||e.email||e.userId.slice(0,8)}function M(){let e=a(g.admin.listUsers,{}),[t,n]=(0,D.useState)(``),s=a(g.introspect.introspectUser,t?{userId:t}:`skip`);return(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`p`,{className:`oc-admin__hint`,children:y()}),(0,A.jsxs)(w,{value:t,onValueChange:n,children:[(0,A.jsx)(x,{size:`sm`,"aria-label":o(),children:(0,A.jsx)(E,{placeholder:o()})}),(0,A.jsx)(T,{children:(e??[]).map(e=>(0,A.jsx)(C,{value:e.userId,children:j(e)},e._id))})]}),t===``?(0,A.jsx)(`p`,{className:`oc-admin__hint`,children:b()}):s===void 0?(0,A.jsx)(`p`,{className:`oc-admin__hint`,children:r()}):(0,A.jsxs)(`div`,{className:`oc-introspect`,children:[(0,A.jsxs)(`section`,{className:`oc-introspect__section`,children:[(0,A.jsx)(`h3`,{className:`oc-introspect__title`,children:v()}),(0,A.jsxs)(`div`,{className:`oc-introspect__id`,children:[(0,A.jsx)(`strong`,{children:s.user.label}),(0,A.jsx)(S,{variant:`secondary`,children:s.role})]})]}),(0,A.jsxs)(`section`,{className:`oc-introspect__section`,children:[(0,A.jsx)(`h3`,{className:`oc-introspect__title`,children:i()}),s.groups.length===0?(0,A.jsx)(`p`,{className:`oc-admin__hint`,children:m()}):(0,A.jsx)(`div`,{className:`oc-introspect__chips`,children:s.groups.map(e=>(0,A.jsx)(S,{variant:`secondary`,children:e.name},e.groupId))})]}),(0,A.jsxs)(`section`,{className:`oc-introspect__section`,children:[(0,A.jsx)(`h3`,{className:`oc-introspect__title`,children:u()}),s.agents.length===0?(0,A.jsx)(`p`,{className:`oc-admin__hint`,children:m()}):(0,A.jsx)(`ul`,{className:`oc-introspect__list`,children:s.agents.map(e=>(0,A.jsxs)(`li`,{className:`oc-introspect__row`,children:[(0,A.jsx)(`span`,{className:`oc-introspect__name`,children:e.displayName||e.agentId}),e.isDefault?(0,A.jsx)(S,{variant:`default`,children:l()}):null,(0,A.jsx)(S,{variant:`outline`,children:O(e.via)}),(0,A.jsx)(S,{variant:`secondary`,children:e.state})]},`${e.instanceName} ${e.agentId}`))})]}),(0,A.jsxs)(`section`,{className:`oc-introspect__section`,children:[(0,A.jsx)(`h3`,{className:`oc-introspect__title`,children:d()}),s.charts.length===0?(0,A.jsx)(`p`,{className:`oc-admin__hint`,children:m()}):(0,A.jsx)(`ul`,{className:`oc-introspect__list`,children:s.charts.map(e=>(0,A.jsxs)(`li`,{className:`oc-introspect__row`,children:[(0,A.jsx)(`span`,{className:`oc-introspect__name`,children:e.name}),(0,A.jsx)(S,{variant:`outline`,children:k(e.via)})]},e.key))})]}),(0,A.jsxs)(`section`,{className:`oc-introspect__section`,children:[(0,A.jsx)(`h3`,{className:`oc-introspect__title`,children:p()}),s.permissions.length===0?(0,A.jsx)(`p`,{className:`oc-admin__hint`,children:m()}):(0,A.jsx)(`div`,{className:`oc-introspect__chips`,children:s.permissions.map(e=>(0,A.jsx)(S,{variant:`secondary`,children:e},e))})]})]})]})}export{M as AccessTab};
@@ -1 +1 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{Fh as r,Ih as i,Lh as a,Mh as o,Nh as s,Ph as c,Rh as l}from"./api-BDOBe_HI.js";import{r as u}from"./dist-Ct8KdJzy.js";import{t as d}from"./x-Bg1ECTqi.js";import{t as f}from"./button-BXoUycz-.js";import{$ as p,Q as m,X as h,Z as g,et as _,jt as v,ln as y}from"./index-DtAFZhtv.js";import{r as b}from"./TimeRangePicker-B-foA1-L.js";var x=t(e(),1),S=n(),C=[{value:`eq`,label:`=`},{value:`neq`,label:`≠`},{value:`contains`,label:l()},{value:`gt`,label:`>`},{value:`gte`,label:`≥`},{value:`lt`,label:`<`},{value:`lte`,label:`≤`}],w=1;function T(){return{id:w++,field:``,op:`eq`,value:``}}function E(e){return e.map(e=>({id:w++,field:e.field,op:e.op,value:String(e.value)}))}function D({fields:e,seed:t,onChange:n}){let l=(0,x.useRef)(t),w=!!(l.current&&l.current.length>0),[D,O]=(0,x.useState)(w),[k,A]=(0,x.useState)(()=>w?E(l.current):[]);function j(e){n(e.filter(e=>e.field!==``&&e.value!==``).map(e=>({field:e.field,op:e.op,value:b(e.value)})))}function M(e,t){let n=k.map(n=>n.id===e?{...n,...t}:n);A(n),j(n)}function N(){A(e=>[...e,T()])}function P(e){let t=k.filter(t=>t.id!==e);A(t),j(t)}let F=k.filter(e=>e.field!==``&&e.value!==``).length;return(0,S.jsxs)(`div`,{className:`oc-advfilter`,children:[(0,S.jsxs)(`button`,{type:`button`,className:`oc-advfilter__toggle`,"aria-expanded":D,onClick:()=>O(e=>!e),children:[(0,S.jsx)(u,{className:`oc-advfilter__chevron`+(D?` is-open`:``),"aria-hidden":!0}),a(),F>0?(0,S.jsx)(`span`,{className:`oc-advfilter__count`,children:F}):null]}),D?(0,S.jsxs)(`div`,{className:`oc-advfilter__body`,children:[k.length===0?(0,S.jsx)(`p`,{className:`oc-admin__hint`,children:i()}):(0,S.jsx)(`ul`,{className:`oc-advfilter__rows`,children:k.map(t=>(0,S.jsxs)(`li`,{className:`oc-advfilter__row`,children:[(0,S.jsxs)(h,{value:t.field||void 0,onValueChange:e=>M(t.id,{field:e}),children:[(0,S.jsx)(p,{size:`sm`,className:`w-40`,children:(0,S.jsx)(_,{placeholder:r()})}),(0,S.jsx)(g,{children:e.map(e=>(0,S.jsx)(m,{value:e.value,children:e.label},e.value))})]}),(0,S.jsxs)(h,{value:t.op,onValueChange:e=>M(t.id,{op:e}),children:[(0,S.jsx)(p,{size:`sm`,className:`w-28`,children:(0,S.jsx)(_,{})}),(0,S.jsx)(g,{children:C.map(e=>(0,S.jsx)(m,{value:e.value,children:e.label},e.value))})]}),(0,S.jsx)(v,{className:`oc-advfilter__value`,value:t.value,onChange:e=>M(t.id,{value:e.target.value}),placeholder:c()}),(0,S.jsx)(f,{variant:`ghost`,size:`icon-sm`,"aria-label":s(),onClick:()=>P(t.id),children:(0,S.jsx)(d,{})})]},t.id))}),(0,S.jsxs)(f,{variant:`outline`,size:`sm`,className:`oc-advfilter__add`,onClick:N,children:[(0,S.jsx)(y,{}),o()]})]}):null]})}export{D as t};
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{Fh as r,Ih as i,Lh as a,Mh as o,Nh as s,Ph as c,Rh as l}from"./api-BDOBe_HI.js";import{r as u}from"./dist-Ct8KdJzy.js";import{t as d}from"./x-Bg1ECTqi.js";import{t as f}from"./button-BXoUycz-.js";import{$ as p,Q as m,X as h,Z as g,et as _,jt as v,ln as y}from"./index-B0ufU8aN.js";import{r as b}from"./TimeRangePicker-4TbN0Xgb.js";var x=t(e(),1),S=n(),C=[{value:`eq`,label:`=`},{value:`neq`,label:`≠`},{value:`contains`,label:l()},{value:`gt`,label:`>`},{value:`gte`,label:`≥`},{value:`lt`,label:`<`},{value:`lte`,label:`≤`}],w=1;function T(){return{id:w++,field:``,op:`eq`,value:``}}function E(e){return e.map(e=>({id:w++,field:e.field,op:e.op,value:String(e.value)}))}function D({fields:e,seed:t,onChange:n}){let l=(0,x.useRef)(t),w=!!(l.current&&l.current.length>0),[D,O]=(0,x.useState)(w),[k,A]=(0,x.useState)(()=>w?E(l.current):[]);function j(e){n(e.filter(e=>e.field!==``&&e.value!==``).map(e=>({field:e.field,op:e.op,value:b(e.value)})))}function M(e,t){let n=k.map(n=>n.id===e?{...n,...t}:n);A(n),j(n)}function N(){A(e=>[...e,T()])}function P(e){let t=k.filter(t=>t.id!==e);A(t),j(t)}let F=k.filter(e=>e.field!==``&&e.value!==``).length;return(0,S.jsxs)(`div`,{className:`oc-advfilter`,children:[(0,S.jsxs)(`button`,{type:`button`,className:`oc-advfilter__toggle`,"aria-expanded":D,onClick:()=>O(e=>!e),children:[(0,S.jsx)(u,{className:`oc-advfilter__chevron`+(D?` is-open`:``),"aria-hidden":!0}),a(),F>0?(0,S.jsx)(`span`,{className:`oc-advfilter__count`,children:F}):null]}),D?(0,S.jsxs)(`div`,{className:`oc-advfilter__body`,children:[k.length===0?(0,S.jsx)(`p`,{className:`oc-admin__hint`,children:i()}):(0,S.jsx)(`ul`,{className:`oc-advfilter__rows`,children:k.map(t=>(0,S.jsxs)(`li`,{className:`oc-advfilter__row`,children:[(0,S.jsxs)(h,{value:t.field||void 0,onValueChange:e=>M(t.id,{field:e}),children:[(0,S.jsx)(p,{size:`sm`,className:`w-40`,children:(0,S.jsx)(_,{placeholder:r()})}),(0,S.jsx)(g,{children:e.map(e=>(0,S.jsx)(m,{value:e.value,children:e.label},e.value))})]}),(0,S.jsxs)(h,{value:t.op,onValueChange:e=>M(t.id,{op:e}),children:[(0,S.jsx)(p,{size:`sm`,className:`w-28`,children:(0,S.jsx)(_,{})}),(0,S.jsx)(g,{children:C.map(e=>(0,S.jsx)(m,{value:e.value,children:e.label},e.value))})]}),(0,S.jsx)(v,{className:`oc-advfilter__value`,value:t.value,onChange:e=>M(t.id,{value:e.target.value}),placeholder:c()}),(0,S.jsx)(f,{variant:`ghost`,size:`icon-sm`,"aria-label":s(),onClick:()=>P(t.id),children:(0,S.jsx)(d,{})})]},t.id))}),(0,S.jsxs)(f,{variant:`outline`,size:`sm`,className:`oc-advfilter__add`,onClick:N,children:[(0,S.jsx)(y,{}),o()]})]}):null]})}export{D as t};
@@ -1,3 +1,3 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$u as r,Aa as i,Au as a,Ba as o,Bu as s,Da as c,Du as l,Ea as u,Eu as d,Fa as f,Fu as p,Ga as m,Gu as h,H as g,Ha as _,Hu as v,Ia as y,Iu as b,Ju as ee,Ka as x,Ku as S,La as C,Ld as te,Lu as w,Ma as T,Mu as E,Na as D,Nu as O,Oa as k,Ou as A,Pa as j,Pu as ne,QR as re,Qu as M,Ra as N,Ru as P,Tu as F,Ua as ie,Uu as I,Va as L,Vu as R,Wa as z,Wu as ae,XR as B,Xu as oe,Yu as se,Zu as ce,aa as le,az as V,ca as ue,ia as H,iz as de,ja as fe,ju as pe,ka as me,ku as he,la as ge,nj as _e,nz as U,oa as ve,qu as ye,sa as be,t as W,ua as xe,wu as Se,za as Ce,zd as G,zu as we}from"./api-BDOBe_HI.js";import{t as K}from"./button-BXoUycz-.js";import{$ as Te,B as Ee,Ct as De,Dt as q,Et as Oe,Q as ke,St as Ae,Tt as je,X as Me,Z as Ne,at as Pe,bt as Fe,et as Ie,nt as Le,ot as Re,q as ze,rn as J,rt as Be,tt as Ve,vt as He,wt as Ue,xt as We,yt as Ge}from"./index-DtAFZhtv.js";import{n as Ke,t as qe}from"./curation-CQksaIbm.js";import{i as Je}from"./compatView-B2QN2HCH.js";/* empty css */var Y=t(e(),1),X=2e4,Ye=6e4;function Xe(e){return typeof e!=`number`||e<=0?0:Math.round(e/X*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(`
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$u as r,Aa as i,Au as a,Ba as o,Bu as s,Da as c,Du as l,Ea as u,Eu as d,Fa as f,Fu as p,Ga as m,Gu as h,H as g,Ha as _,Hu as v,Ia as y,Iu as b,Ju as ee,Ka as x,Ku as S,La as C,Ld as te,Lu as w,Ma as T,Mu as E,Na as D,Nu as O,Oa as k,Ou as A,Pa as j,Pu as ne,QR as re,Qu as M,Ra as N,Ru as P,Tu as F,Ua as ie,Uu as I,Va as L,Vu as R,Wa as z,Wu as ae,XR as B,Xu as oe,Yu as se,Zu as ce,aa as le,az as V,ca as ue,ia as H,iz as de,ja as fe,ju as pe,ka as me,ku as he,la as ge,nj as _e,nz as U,oa as ve,qu as ye,sa as be,t as W,ua as xe,wu as Se,za as Ce,zd as G,zu as we}from"./api-BDOBe_HI.js";import{t as K}from"./button-BXoUycz-.js";import{$ as Te,B as Ee,Ct as De,Dt as q,Et as Oe,Q as ke,St as Ae,Tt as je,X as Me,Z as Ne,at as Pe,bt as Fe,et as Ie,nt as Le,ot as Re,q as ze,rn as J,rt as Be,tt as Ve,vt as He,wt as Ue,xt as We,yt as Ge}from"./index-B0ufU8aN.js";import{n as Ke,t as qe}from"./curation-CQksaIbm.js";import{i as Je}from"./compatView-B2QN2HCH.js";/* empty css */var Y=t(e(),1),X=2e4,Ye=6e4;function Xe(e){return typeof e!=`number`||e<=0?0:Math.round(e/X*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
2
  `))n.set(t,(n.get(t)??0)+1);for(let e of t.split(`
3
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=V(W.me.getMe,{host:ze}),t=e?.role===`admin`,n=(e?.permissions??[]).includes(`bridge.read`),i=V(W.admin.listInstances,e!==void 0&&t?{}:`skip`),[a,o]=(0,Y.useState)(null);(0,Y.useEffect)(()=>{!t||!i||i.length===0||(!a||!i.some(e=>e.name===a))&&o(i[0].name)},[t,i,a]);let s=V(W.agents.listAgentsForInstance,t&&a?{instanceName:a}:`skip`),c=V(W.agents.listMyAgents,e!==void 0&&!t?{}:`skip`),l=(0,Y.useMemo)(()=>{if(e!==void 0){if(t)return a===null||s===void 0?i!==void 0&&i.length===0?[]:void 0:s.agents.map(e=>({instanceName:a,agentId:e.agentId,label:`${e.emoji?`${e.emoji} `:``}${e.displayName??e.agentId}`}));if(c!==void 0)return c.map(e=>({instanceName:e.instanceName,agentId:e.agentId,label:`${e.emoji?`${e.emoji} `:``}${e.displayName??e.agentId}`}))}},[e,t,a,s,i,c]),[u,d]=(0,Y.useState)(null);(0,Y.useEffect)(()=>{!l||l.length===0||(!u||!l.some(e=>$(e)===u))&&d($(l[0]))},[l,u]);let f=l?.find(e=>$(e)===u)??null,p=U(W.agentFiles.listAgentFiles),[m,y]=(0,Y.useState)({status:`idle`}),b=f?.instanceName??null,x=f?.agentId??null,C=V(W.compat.forInstance,n&&b!==null?{instanceName:b}:`skip`),w=n&&b!==null?Ee(C,`agentFiles`):null,T=w===null?!1:w===`loading`?null:w.blocked,E=(0,Y.useCallback)(async()=>{if(!(b===null||x===null)){y({status:`loading`});try{y({status:`done`,files:(await p({instanceName:b,agentId:x})).files})}catch(e){y({status:`error`,dashboardAbsent:tt(e)})}}},[p,b,x]);(0,Y.useEffect)(()=>{T===!1&&E()},[E,T]);let[D,O]=(0,Y.useState)(null),k=V(W.agentFileCuration.listCurations,t&&b!==null&&x!==null?{instanceName:b,agentId:x}:`skip`),A=V(W.agentFileCuration.curationSettings,t&&b!==null?{instanceName:b}:`skip`),j=U(W.agentFileCuration.requestCuration),[ne,N]=(0,Y.useState)(null),[P,F]=(0,Y.useState)(null),{toast:z}=q(),le=(0,Y.useMemo)(()=>{let e=new Map;for(let t of k??[])e.has(t.name)||e.set(t.name,t);return e},[k]),ue=(0,Y.useCallback)(async e=>{if(!(b===null||x===null)){N(e);try{let t=await j({instanceName:b,agentId:x,name:e,trigger:`manual`});t.ok?z({title:ie(),variant:`success`}):z({title:_({reason:t.reason??`unknown`}),variant:`error`})}catch{z({title:L(),variant:`error`})}finally{N(null)}}},[j,b,x,z]),H=re(),de=(0,Y.useMemo)(()=>new Intl.NumberFormat(H,{maximumFractionDigits:0}),[H]);return e===void 0||l===void 0?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:B()}):(0,Q.jsxs)(`div`,{className:`oc-afiles`,children:[(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:r()}),(0,Q.jsxs)(`div`,{className:`oc-afiles__picker`,children:[t&&(i?.length??0)>1?(0,Q.jsxs)(Me,{value:a??``,onValueChange:e=>o(e),children:[(0,Q.jsx)(Te,{size:`sm`,"aria-label":M(),children:(0,Q.jsx)(Ie,{})}),(0,Q.jsx)(Ne,{children:(i??[]).map(e=>(0,Q.jsx)(ke,{value:e.name,children:e.name},e.name))})]}):null,l.length>0?(0,Q.jsxs)(Me,{value:u??``,onValueChange:e=>d(e),children:[(0,Q.jsx)(Te,{size:`sm`,"aria-label":ce(),children:(0,Q.jsx)(Ie,{})}),(0,Q.jsx)(Ne,{children:l.map(e=>(0,Q.jsx)(ke,{value:$(e),children:e.label},$(e)))})]}):(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:oe()})]}),f===null?null:w===`loading`?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:B()}):w!==null&&w.blocked?(0,Q.jsxs)(`p`,{className:`oc-compat__blocked`,role:`status`,children:[(0,Q.jsx)(J,{size:14,"aria-hidden":!0}),` `,Je(w.gatewayVersion,w.provider)]}):m.status===`loading`||m.status===`idle`?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:B()}):m.status===`error`?(0,Q.jsxs)(`p`,{className:`oc-afiles__error`,role:`alert`,children:[m.dashboardAbsent?g():ee(),` `,!m.dashboardAbsent&&(0,Q.jsx)(K,{variant:`outline`,size:`sm`,onClick:()=>void E(),children:te()})]}):m.files.length===0?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:se()}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`oc-afiles__list`,children:m.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:ye()}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`oc-afiles__size`,children:S({size:Z(e.size,H)})}),(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:h({pct:de.format(n)})}),r?(0,Q.jsx)(J,{size:14,className:`oc-afiles__warn`,"aria-label":ae()}):(0,Q.jsx)(`span`,{className:`oc-afiles__warn-slot`,"aria-hidden":!0})]}),(0,Q.jsx)(K,{variant:`outline`,size:`sm`,className:`oc-afiles__open`,onClick:()=>O(e),children:t?v():R()}),t&&!e.missing?(0,Q.jsx)(it,{curatable:qe.includes(e.name),size:e.size??0,budget:A?.budgetChars??null,enabled:A?.enabled??!1,curation:le.get(e.name)??null,inFlight:ne===e.name,onCurate:()=>void ue(e.name),onReview:e=>F(e)}):null]},e.name)})}),(0,Q.jsx)(`p`,{className:`oc-afiles__budget`,children:I({used:Z(Qe(m.files),H),total:Z(Ye,H),pct:de.format(Ze(Qe(m.files)))})})]}),D&&f?(0,Q.jsx)(at,{instanceName:f.instanceName,agentId:f.agentId,name:D.name,isAdmin:t,onClose:()=>O(null),onSaved:()=>void E()}):null,P?(0,Q.jsx)(ot,{curationId:P,onClose:()=>F(null),onApplied:()=>{F(null),E()}}):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)(K,{variant:`default`,size:`sm`,className:`oc-afiles__curate`,onClick:()=>s(i._id),children:m()}):a||i?.status===`dispatched`||i?.status===`applying`?(0,Q.jsx)(Oe,{variant:`outline`,className:`oc-afiles__curate-status`,children:z()}):e&&r&&n!==null&&Ke(t,n)?(0,Q.jsx)(K,{variant:`outline`,size:`sm`,className:`oc-afiles__curate`,onClick:o,children:x()}):null}function at({instanceName:e,agentId:t,name:n,isAdmin:r,onClose:i,onSaved:o}){let c=U(W.agentFiles.getAgentFile),u=U(W.agentFiles.setAgentFile),f=q(),[m,h]=(0,Y.useState)(null),[g,_]=(0,Y.useState)(!1),[v,y]=(0,Y.useState)(``),[ee,x]=(0,Y.useState)(!1),[S,C]=(0,Y.useState)(!1),[T,D]=(0,Y.useState)(!1),[k,j]=(0,Y.useState)(!1),M=(0,Y.useCallback)(async r=>{_(!1);try{let i=await c({instanceName:e,agentId:t,name:n});h({content:i.content,updatedAtMs:i.updatedAtMs}),r||y(i.content),D(!1)}catch{_(!0)}},[c,e,t,n]);(0,Y.useEffect)(()=>{M(!1)},[M]);async function N(){if(m!==null){C(!0),j(!1);try{await u({instanceName:e,agentId:t,name:n,content:v,baseUpdatedAtMs:m.updatedAtMs??void 0}),f.success(ne({name:n})),o(),await M(!1)}catch(e){nt(e)?D(!0):j(!0)}finally{C(!1)}}}let ie=m!==null&&v!==m.content,I=(0,Y.useMemo)(()=>m===null?null:et(m.content,v),[m,v]),L=v.length>X,R=re(),z=(0,Y.useMemo)(()=>new Intl.NumberFormat(R),[R]);return(0,Q.jsx)(Ve,{open:!0,onOpenChange:e=>!e&&i(),children:(0,Q.jsxs)(Le,{className:`oc-afiles__editor`,children:[(0,Q.jsxs)(Pe,{children:[(0,Q.jsx)(Re,{children:s({name:n})}),(0,Q.jsxs)(Be,{children:[we({agent:t,instance:e}),r?null:(0,Q.jsxs)(Q.Fragment,{children:[` · `,P()]})]})]}),g?(0,Q.jsxs)(`p`,{className:`oc-afiles__error`,role:`alert`,children:[E(),` `,(0,Q.jsx)(K,{variant:`outline`,size:`sm`,onClick:()=>void M(!1),children:te()})]}):m===null?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:B()}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`textarea`,{className:`oc-afiles__source`,value:v,readOnly:!r,spellCheck:!1,onChange:e=>y(e.target.value),"aria-label":s({name:n})}),(0,Q.jsx)(`p`,{className:`oc-afiles__hint`,children:w()}),T?(0,Q.jsxs)(`p`,{className:`oc-afiles__error`,role:`alert`,children:[pe(),` `,(0,Q.jsx)(K,{variant:`outline`,size:`sm`,onClick:()=>void M(!0),children:a()})]}):null,k?(0,Q.jsx)(`p`,{className:`oc-afiles__error`,role:`alert`,children:O()}):null,(0,Q.jsxs)(`div`,{className:`oc-afiles__editor-foot`,children:[(0,Q.jsx)(`span`,{className:`oc-afiles__count${L?` is-over`:``}`,children:b({count:z.format(v.length),max:z.format(X)})}),r?(0,Q.jsx)(K,{size:`sm`,disabled:!ie||S||T,onClick:()=>x(!0),children:S?G():p()}):null]})]}),(0,Q.jsx)(He,{open:ee,onOpenChange:x,children:(0,Q.jsxs)(We,{children:[(0,Q.jsxs)(Ue,{children:[(0,Q.jsx)(je,{children:he({name:n})}),(0,Q.jsx)(Ae,{children:A({agent:t})})]}),I?(0,Q.jsxs)(`div`,{className:`oc-afiles__diff`,children:[(0,Q.jsx)(`p`,{className:`oc-afiles__diff-counts`,children:l({added:I.added,removed:I.removed})}),I.sampleAdded.length>0?(0,Q.jsxs)(`div`,{className:`oc-afiles__diff-block`,children:[(0,Q.jsx)(`span`,{className:`oc-afiles__diff-label`,children:d()}),I.sampleAdded.map((e,t)=>(0,Q.jsx)(`code`,{className:`oc-afiles__diff-line is-add`,children:e||` `},t))]}):null,I.sampleRemoved.length>0?(0,Q.jsxs)(`div`,{className:`oc-afiles__diff-block`,children:[(0,Q.jsx)(`span`,{className:`oc-afiles__diff-label`,children:F()}),I.sampleRemoved.map((e,t)=>(0,Q.jsx)(`code`,{className:`oc-afiles__diff-line is-del`,children:e||` `},t))]}):null]}):null,(0,Q.jsxs)(De,{children:[(0,Q.jsx)(Fe,{children:_e()}),(0,Q.jsx)(Ge,{onClick:()=>void N(),children:Se()})]})]})})]})})}function ot({curationId:e,onClose:t,onApplied:n}){let r=V(W.agentFileCuration.getProposal,{curationId:e}),a=U(W.agentFileCuration.approveCuration),s=de(W.agentFileCuration.rejectCuration),{toast:l}=q(),[d,p]=(0,Y.useState)(null),[m,h]=(0,Y.useState)(!1),[g,_]=(0,Y.useState)(``),v=re(),b=(0,Y.useMemo)(()=>r?et(r.beforeContent,r.proposedContent):null,[r]);async function ee(){p(`approve`);try{let t=await a({curationId:e});t.ok?(l({title:o(),variant:`success`}),n()):l({title:t.reason===`conflict`?N():C({reason:t.reason??`unknown`}),variant:`error`})}catch{l({title:L(),variant:`error`})}finally{p(null)}}async function x(n){p(`reject`);try{let r=g.trim();(await s({curationId:e,...r?{comment:r}:{},relaunch:n})).ok?l({title:n?le():Ce(),variant:`success`}):l({title:j(),variant:`error`}),t()}catch{l({title:L(),variant:`error`})}finally{p(null)}}return(0,Q.jsx)(Ve,{open:!0,onOpenChange:e=>e?void 0:t(),children:(0,Q.jsxs)(Le,{className:`oc-afiles__review`,children:[(0,Q.jsxs)(Pe,{children:[(0,Q.jsx)(Re,{children:r?y({name:r.name}):B()}),(0,Q.jsx)(Be,{children:f()})]}),r===void 0?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:B()}):r===null?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:j()}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`p`,{className:`oc-afiles__review-sizes`,children:[D({before:Z(r.beforeSize,v),after:Z(r.proposedSize,v)}),r.overBudget?(0,Q.jsxs)(Q.Fragment,{children:[` `,(0,Q.jsx)(J,{size:13,"aria-hidden":!0}),` `,T()]}):null]}),b?(0,Q.jsx)(`p`,{className:`oc-afiles__review-diff`,children:fe({added:b.added,removed:b.removed})}):null,r.feedback?(0,Q.jsx)(`p`,{className:`oc-afiles__review-feedback`,children:H({feedback:r.feedback})}):null,b&&b.sampleRemoved.length>0?(0,Q.jsxs)(`div`,{className:`oc-afiles__review-removed`,children:[(0,Q.jsx)(`p`,{className:`oc-afiles__review-label`,children:u()}),(0,Q.jsx)(`ul`,{children:b.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:c()}),(0,Q.jsx)(`pre`,{className:`oc-afiles__review-pre`,children:r.beforeContent})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`oc-afiles__review-label`,children:i()}),(0,Q.jsx)(`pre`,{className:`oc-afiles__review-pre`,children:r.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:xe()}),(0,Q.jsx)(`textarea`,{id:`curation-reject-comment`,className:`oc-afiles__reject-textarea`,rows:3,placeholder:ge(),value:g,onChange:e=>_(e.target.value)}),(0,Q.jsxs)(`div`,{className:`oc-afiles__review-actions`,children:[(0,Q.jsx)(K,{variant:`ghost`,onClick:()=>h(!1),disabled:d!==null,children:ue()}),(0,Q.jsx)(K,{variant:`outline`,onClick:()=>void x(!1),disabled:d!==null,children:d===`reject`?G():be()}),(0,Q.jsx)(K,{variant:`default`,onClick:()=>void x(!0),disabled:d!==null,children:d===`reject`?G():ve()})]})]}):(0,Q.jsxs)(`div`,{className:`oc-afiles__review-actions`,children:[(0,Q.jsx)(K,{variant:`outline`,onClick:()=>h(!0),disabled:d!==null||r==null,children:me()}),(0,Q.jsx)(K,{variant:`default`,onClick:()=>void ee(),disabled:d!==null||r==null,children:d===`approve`?G():k()})]})]})})}export{rt as AgentFilesTab};
@@ -1 +1 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$S as r,AS as i,BS as a,CC as o,FS as s,GS as ee,HS as te,IS as c,JS as l,KS as ne,LS as u,MS as d,NS as f,PS as p,QS as re,RS as ie,SC as ae,TC as m,US as oe,VS as se,WS as ce,XS as le,YS as h,ZS as g,_C as ue,aC as de,az as _,bC as fe,cC as pe,dC as me,eC as he,fC as ge,gC as _e,hC as ve,iC as ye,iz as be,jS as v,lC as xe,mC as Se,nC as y,oC as b,pC as x,qS as S,rC as C,sC as w,t as T,tC as E,uC as D,vC as O,wC as k,xC as A,yC as j,zS as Ce}from"./api-BDOBe_HI.js";import{$ as M,Dt as we,Et as N,Fn as Te,Pn as P,Q as F,U as Ee,X as I,Z as L,at as R,ct as z,et as B,i as V,nt as H,o as De,ot as U,q as Oe,tt as W}from"./index-DtAFZhtv.js";import{n as ke}from"./TimeRangePicker-B-foA1-L.js";import{t as Ae}from"./FilterBar-D99V_QOK.js";import{t as je}from"./DataTableShell-D2PIAVAw.js";import{t as G}from"./dispatchErrorInfo-CEC_I9Id.js";var K=t(e(),1),q=n(),J=`__all__`,Me=[{value:`open`},{value:`acknowledged`},{value:`resolved`}];function Ne(e){return e===`open`?m():e===`acknowledged`?k():o()}var Pe=[`info`,`warn`,`critical`],Fe=[`detector`,`agent`,`user`],Ie={kind:`relative`,from:`now-30d`,to:`now`},Le=200,Y=`all`;function X(){let e=Te({from:`/settings/anomalies`}),t=P({from:`/settings/anomalies`}),n=e.q??``,i=e.status===Y?J:e.status,o=e.severity??J,s=e.kind??J,[c,u]=(0,K.useState)(J),d=V(e.from,e.to),{from:f,to:p}=ke(d),m=e=>void t({search:t=>({...t,q:e||void 0}),replace:!0}),v=e=>void t({search:t=>({...t,status:e===J?Y:e})}),k=e=>void t({search:t=>({...t,severity:e===J?void 0:e})}),R=e=>void t({search:t=>({...t,kind:e===J?void 0:e})}),H=e=>void t({search:t=>({...t,...De(e)})}),U=Ee(),W=we(),G=be(T.anomalies.resolveAnomaly),X=(_(T.me.getMe,{host:Oe})?.permissions??[]).includes(`admin.manage`),Z=_(T.anomalies.listAnomalies,{limit:Le,filter:{q:n||void 0,from:f,to:p,anomalyStatus:i===J?void 0:i,severity:o===J?void 0:o,source:c===J?void 0:c,kind:s===J?void 0:s}}),Q=(0,K.useMemo)(()=>{let e=new Set;for(let t of Z??[])e.add(t.kind);return[...e].sort()},[Z]),$=n!==``||i!==`open`||o!==J||c!==J||s!==J||d.kind!==`relative`||d.from!==Ie.from;function Ue(){u(J),t({search:{status:`open`},replace:!0})}async function We(e){if(await U({title:ae(),description:(0,q.jsxs)(q.Fragment,{children:[A(),` `,(0,q.jsx)(`span`,{className:`font-mono`,children:e.kind}),` `,fe(),` `,(0,q.jsx)(`strong`,{children:j()}),`.`,` `,O()]}),confirmLabel:ue()}))try{await G({anomalyId:e._id,status:`resolved`}),W.success(_e(),e.kind)}catch(e){W.error(ve(),e)}}async function Ge(e){try{await G({anomalyId:e._id,status:`acknowledged`}),W.success(Se(),e.kind)}catch(e){W.error(x(),e)}}return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`p`,{className:`oc-admin__hint`,children:[ge(),` `,(0,q.jsx)(`strong`,{children:me()}),` `,D(),` `,(0,q.jsx)(`strong`,{children:xe()}),` `,pe(),` `,(0,q.jsx)(`strong`,{children:w()}),` `,b(),` `,(0,q.jsx)(`span`,{className:`oc-filter__window`,children:de()})]}),(0,q.jsxs)(Ae,{q:n,onQChange:m,searchPlaceholder:ye(),timeRange:d,onTimeRangeChange:H,onReset:Ue,canReset:$,children:[(0,q.jsxs)(I,{value:i,onValueChange:v,children:[(0,q.jsx)(M,{size:`sm`,className:`w-36`,children:(0,q.jsx)(B,{})}),(0,q.jsxs)(L,{children:[(0,q.jsx)(F,{value:J,children:C()}),Me.map(e=>(0,q.jsx)(F,{value:e.value,children:Ne(e.value)},e.value))]})]}),(0,q.jsxs)(I,{value:o,onValueChange:k,children:[(0,q.jsx)(M,{size:`sm`,className:`w-36`,children:(0,q.jsx)(B,{placeholder:y()})}),(0,q.jsxs)(L,{children:[(0,q.jsx)(F,{value:J,children:re()}),Pe.map(e=>(0,q.jsx)(F,{value:e,children:e},e))]})]}),(0,q.jsxs)(I,{value:c,onValueChange:u,children:[(0,q.jsx)(M,{size:`sm`,className:`w-32`,children:(0,q.jsx)(B,{placeholder:g()})}),(0,q.jsxs)(L,{children:[(0,q.jsx)(F,{value:J,children:le()}),Fe.map(e=>(0,q.jsx)(F,{value:e,children:e},e))]})]}),(0,q.jsxs)(I,{value:s,onValueChange:R,children:[(0,q.jsx)(M,{size:`sm`,className:`w-36`,children:(0,q.jsx)(B,{placeholder:h()})}),(0,q.jsxs)(L,{children:[(0,q.jsx)(F,{value:J,children:l()}),Q.map(e=>(0,q.jsx)(F,{value:e,children:e},e))]})]})]}),(0,q.jsx)(je,{title:S(),rows:Z,emptyHint:i===`open`?ne():ee(),rowActions:e=>X&&e.status===`open`?[{label:ce(),onSelect:()=>void We(e)},{label:oe(),onSelect:()=>void Ge(e)}]:[],columns:[{header:te(),cell:e=>(0,q.jsx)(`span`,{className:`oc-traces__time`,children:z(e.at)}),sort:e=>e.at},{header:h(),cell:e=>(0,q.jsx)(`code`,{className:`oc-traces__mono`,children:e.kind}),sort:e=>e.kind},{header:E(),cell:e=>e.occurrenceCount!==null&&e.occurrenceCount>1?(0,q.jsx)(`span`,{className:`oc-traces__time`,title:e.firstAt===null?void 0:r({when:z(e.firstAt)}),children:he({count:String(e.occurrenceCount)})}):(0,q.jsx)(`span`,{className:`oc-traces__time`,children:`—`}),sort:e=>e.occurrenceCount??0},{header:y(),cell:e=>(0,q.jsx)(Be,{severity:e.severity}),sort:e=>e.severity===`critical`?2:+(e.severity===`warn`)},{header:se(),cell:e=>(0,q.jsx)(Ve,{status:e.status}),sort:e=>e.status===`resolved`?2:+(e.status===`acknowledged`)},{header:g(),cell:e=>(0,q.jsx)(N,{variant:`outline`,children:e.source}),sort:e=>e.source},{header:a(),cell:e=>(0,q.jsxs)(`div`,{className:`oc-anomaly__msgcell`,children:[(0,q.jsx)(`span`,{className:`oc-anomaly__msg`,children:e.message}),(0,q.jsx)(ze,{row:e})]}),sort:e=>e.message},{header:Ce(),cell:e=>(0,q.jsx)(Re,{row:e}),sort:e=>e.evidence??null},{header:ie(),cell:e=>e.correlationId?(0,q.jsx)(`code`,{className:`oc-traces__mono`,children:He(e.correlationId)}):(0,q.jsx)(`span`,{className:`oc-traces__muted`,children:`—`}),sort:e=>e.correlationId}]})]})}var Z=new Set([`openclaw.dispatch_failures`,`assistant.announce_errors`]);function Q(e){if(!Z.has(e.kind)||!e.evidence)return{};try{let t=JSON.parse(e.evidence);return{dominantCode:t.dominantCode,sampleCorrelationId:t.sampleCorrelationId}}catch{return{}}}function $(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 Re({row:e}){let t=P();if(e.kind===`subagent.failure`){let n=$(e);return(0,q.jsxs)(`div`,{className:`oc-anomaly__cause`,children:[(0,q.jsx)(`div`,{className:`oc-anomaly__cause-head`,children:[...new Set(n.errorCategories??[])].map(e=>(0,q.jsx)(`code`,{className:`oc-traces__mono`,children:e},e))}),e.correlationId?(0,q.jsxs)(`button`,{type:`button`,className:`oc-anomaly__drill`,onClick:()=>void t({to:`/settings/traces`,search:{q:e.correlationId,limit:100}}),children:[`↗ `,u()]}):null]})}let n=Q(e);if(!n.dominantCode){let e=n.sampleCorrelationId;return e?(0,q.jsx)(`div`,{className:`oc-anomaly__cause`,children:(0,q.jsxs)(`button`,{type:`button`,className:`oc-anomaly__drill`,onClick:()=>void t({to:`/settings/traces`,search:{correlationId:e,limit:100}}),children:[`↗ `,u()]})}):(0,q.jsx)(`span`,{className:`oc-traces__muted`,children:`—`})}let r=G(n.dominantCode),i=n.sampleCorrelationId;return(0,q.jsxs)(`div`,{className:`oc-anomaly__cause`,children:[(0,q.jsxs)(`div`,{className:`oc-anomaly__cause-head`,children:[(0,q.jsx)(`span`,{className:`oc-anomaly__cause-label`,children:r.label}),(0,q.jsx)(`code`,{className:`oc-traces__mono`,children:n.dominantCode})]}),(0,q.jsx)(`p`,{className:`oc-anomaly__cause-hint`,children:r.hint}),i?(0,q.jsxs)(`button`,{type:`button`,className:`oc-anomaly__drill`,onClick:()=>void t({to:`/settings/traces`,search:{correlationId:i,limit:100}}),children:[`↗ `,u()]}):null]})}function ze({row:e}){let[t,n]=(0,K.useState)(!1),r=_(T.anomalies.getAnomalyAttachments,t?{anomalyId:e._id}:`skip`);return!e.attachments||e.attachments.length===0?null:(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`button`,{type:`button`,className:`oc-anomaly__drill`,onClick:()=>n(!0),children:[c(),e.attachments.length>1?` (${e.attachments.length})`:``]}),(0,q.jsx)(W,{open:t,onOpenChange:n,children:(0,q.jsxs)(H,{className:`oc-anomaly__attachments-dialog`,children:[(0,q.jsx)(R,{children:(0,q.jsx)(U,{children:s()})}),r===void 0?(0,q.jsx)(`p`,{className:`oc-traces__muted`,children:p()}):r.length===0?(0,q.jsx)(`p`,{className:`oc-traces__muted`,children:f()}):(0,q.jsx)(`div`,{className:`oc-anomaly__attachments`,children:r.map(e=>(0,q.jsxs)(`section`,{className:`oc-anomaly__attachment`,children:[(0,q.jsx)(`h4`,{className:`oc-anomaly__attachment-name`,children:(0,q.jsx)(`code`,{className:`oc-traces__mono`,children:e.name})}),(0,q.jsx)(`pre`,{className:`oc-anomaly__attachment-content`,children:e.content})]},e.name))})]})})]})}function Be({severity:e}){return(0,q.jsx)(`span`,{className:`oc-anomaly__sev oc-anomaly__sev--${e}`,children:e})}function Ve({status:e}){return e===`open`?(0,q.jsx)(N,{variant:`destructive`,children:d()}):e===`acknowledged`?(0,q.jsx)(N,{variant:`secondary`,children:v()}):(0,q.jsx)(N,{variant:`outline`,children:i()})}function He(e){return e.length>8?e.slice(0,8):e}export{X as AnomaliesTab};
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$S as r,AS as i,BS as a,CC as o,FS as s,GS as ee,HS as te,IS as c,JS as l,KS as ne,LS as u,MS as d,NS as f,PS as p,QS as re,RS as ie,SC as ae,TC as m,US as oe,VS as se,WS as ce,XS as le,YS as h,ZS as g,_C as ue,aC as de,az as _,bC as fe,cC as pe,dC as me,eC as he,fC as ge,gC as _e,hC as ve,iC as ye,iz as be,jS as v,lC as xe,mC as Se,nC as y,oC as b,pC as x,qS as S,rC as C,sC as w,t as T,tC as E,uC as D,vC as O,wC as k,xC as A,yC as j,zS as Ce}from"./api-BDOBe_HI.js";import{$ as M,Dt as we,Et as N,Fn as Te,Pn as P,Q as F,U as Ee,X as I,Z as L,at as R,ct as z,et as B,i as V,nt as H,o as De,ot as U,q as Oe,tt as W}from"./index-B0ufU8aN.js";import{n as ke}from"./TimeRangePicker-4TbN0Xgb.js";import{t as Ae}from"./FilterBar-DqZs9qry.js";import{t as je}from"./DataTableShell-CFPC-1m0.js";import{t as G}from"./dispatchErrorInfo-CEC_I9Id.js";var K=t(e(),1),q=n(),J=`__all__`,Me=[{value:`open`},{value:`acknowledged`},{value:`resolved`}];function Ne(e){return e===`open`?m():e===`acknowledged`?k():o()}var Pe=[`info`,`warn`,`critical`],Fe=[`detector`,`agent`,`user`],Ie={kind:`relative`,from:`now-30d`,to:`now`},Le=200,Y=`all`;function X(){let e=Te({from:`/settings/anomalies`}),t=P({from:`/settings/anomalies`}),n=e.q??``,i=e.status===Y?J:e.status,o=e.severity??J,s=e.kind??J,[c,u]=(0,K.useState)(J),d=V(e.from,e.to),{from:f,to:p}=ke(d),m=e=>void t({search:t=>({...t,q:e||void 0}),replace:!0}),v=e=>void t({search:t=>({...t,status:e===J?Y:e})}),k=e=>void t({search:t=>({...t,severity:e===J?void 0:e})}),R=e=>void t({search:t=>({...t,kind:e===J?void 0:e})}),H=e=>void t({search:t=>({...t,...De(e)})}),U=Ee(),W=we(),G=be(T.anomalies.resolveAnomaly),X=(_(T.me.getMe,{host:Oe})?.permissions??[]).includes(`admin.manage`),Z=_(T.anomalies.listAnomalies,{limit:Le,filter:{q:n||void 0,from:f,to:p,anomalyStatus:i===J?void 0:i,severity:o===J?void 0:o,source:c===J?void 0:c,kind:s===J?void 0:s}}),Q=(0,K.useMemo)(()=>{let e=new Set;for(let t of Z??[])e.add(t.kind);return[...e].sort()},[Z]),$=n!==``||i!==`open`||o!==J||c!==J||s!==J||d.kind!==`relative`||d.from!==Ie.from;function Ue(){u(J),t({search:{status:`open`},replace:!0})}async function We(e){if(await U({title:ae(),description:(0,q.jsxs)(q.Fragment,{children:[A(),` `,(0,q.jsx)(`span`,{className:`font-mono`,children:e.kind}),` `,fe(),` `,(0,q.jsx)(`strong`,{children:j()}),`.`,` `,O()]}),confirmLabel:ue()}))try{await G({anomalyId:e._id,status:`resolved`}),W.success(_e(),e.kind)}catch(e){W.error(ve(),e)}}async function Ge(e){try{await G({anomalyId:e._id,status:`acknowledged`}),W.success(Se(),e.kind)}catch(e){W.error(x(),e)}}return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`p`,{className:`oc-admin__hint`,children:[ge(),` `,(0,q.jsx)(`strong`,{children:me()}),` `,D(),` `,(0,q.jsx)(`strong`,{children:xe()}),` `,pe(),` `,(0,q.jsx)(`strong`,{children:w()}),` `,b(),` `,(0,q.jsx)(`span`,{className:`oc-filter__window`,children:de()})]}),(0,q.jsxs)(Ae,{q:n,onQChange:m,searchPlaceholder:ye(),timeRange:d,onTimeRangeChange:H,onReset:Ue,canReset:$,children:[(0,q.jsxs)(I,{value:i,onValueChange:v,children:[(0,q.jsx)(M,{size:`sm`,className:`w-36`,children:(0,q.jsx)(B,{})}),(0,q.jsxs)(L,{children:[(0,q.jsx)(F,{value:J,children:C()}),Me.map(e=>(0,q.jsx)(F,{value:e.value,children:Ne(e.value)},e.value))]})]}),(0,q.jsxs)(I,{value:o,onValueChange:k,children:[(0,q.jsx)(M,{size:`sm`,className:`w-36`,children:(0,q.jsx)(B,{placeholder:y()})}),(0,q.jsxs)(L,{children:[(0,q.jsx)(F,{value:J,children:re()}),Pe.map(e=>(0,q.jsx)(F,{value:e,children:e},e))]})]}),(0,q.jsxs)(I,{value:c,onValueChange:u,children:[(0,q.jsx)(M,{size:`sm`,className:`w-32`,children:(0,q.jsx)(B,{placeholder:g()})}),(0,q.jsxs)(L,{children:[(0,q.jsx)(F,{value:J,children:le()}),Fe.map(e=>(0,q.jsx)(F,{value:e,children:e},e))]})]}),(0,q.jsxs)(I,{value:s,onValueChange:R,children:[(0,q.jsx)(M,{size:`sm`,className:`w-36`,children:(0,q.jsx)(B,{placeholder:h()})}),(0,q.jsxs)(L,{children:[(0,q.jsx)(F,{value:J,children:l()}),Q.map(e=>(0,q.jsx)(F,{value:e,children:e},e))]})]})]}),(0,q.jsx)(je,{title:S(),rows:Z,emptyHint:i===`open`?ne():ee(),rowActions:e=>X&&e.status===`open`?[{label:ce(),onSelect:()=>void We(e)},{label:oe(),onSelect:()=>void Ge(e)}]:[],columns:[{header:te(),cell:e=>(0,q.jsx)(`span`,{className:`oc-traces__time`,children:z(e.at)}),sort:e=>e.at},{header:h(),cell:e=>(0,q.jsx)(`code`,{className:`oc-traces__mono`,children:e.kind}),sort:e=>e.kind},{header:E(),cell:e=>e.occurrenceCount!==null&&e.occurrenceCount>1?(0,q.jsx)(`span`,{className:`oc-traces__time`,title:e.firstAt===null?void 0:r({when:z(e.firstAt)}),children:he({count:String(e.occurrenceCount)})}):(0,q.jsx)(`span`,{className:`oc-traces__time`,children:`—`}),sort:e=>e.occurrenceCount??0},{header:y(),cell:e=>(0,q.jsx)(Be,{severity:e.severity}),sort:e=>e.severity===`critical`?2:+(e.severity===`warn`)},{header:se(),cell:e=>(0,q.jsx)(Ve,{status:e.status}),sort:e=>e.status===`resolved`?2:+(e.status===`acknowledged`)},{header:g(),cell:e=>(0,q.jsx)(N,{variant:`outline`,children:e.source}),sort:e=>e.source},{header:a(),cell:e=>(0,q.jsxs)(`div`,{className:`oc-anomaly__msgcell`,children:[(0,q.jsx)(`span`,{className:`oc-anomaly__msg`,children:e.message}),(0,q.jsx)(ze,{row:e})]}),sort:e=>e.message},{header:Ce(),cell:e=>(0,q.jsx)(Re,{row:e}),sort:e=>e.evidence??null},{header:ie(),cell:e=>e.correlationId?(0,q.jsx)(`code`,{className:`oc-traces__mono`,children:He(e.correlationId)}):(0,q.jsx)(`span`,{className:`oc-traces__muted`,children:`—`}),sort:e=>e.correlationId}]})]})}var Z=new Set([`openclaw.dispatch_failures`,`assistant.announce_errors`]);function Q(e){if(!Z.has(e.kind)||!e.evidence)return{};try{let t=JSON.parse(e.evidence);return{dominantCode:t.dominantCode,sampleCorrelationId:t.sampleCorrelationId}}catch{return{}}}function $(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 Re({row:e}){let t=P();if(e.kind===`subagent.failure`){let n=$(e);return(0,q.jsxs)(`div`,{className:`oc-anomaly__cause`,children:[(0,q.jsx)(`div`,{className:`oc-anomaly__cause-head`,children:[...new Set(n.errorCategories??[])].map(e=>(0,q.jsx)(`code`,{className:`oc-traces__mono`,children:e},e))}),e.correlationId?(0,q.jsxs)(`button`,{type:`button`,className:`oc-anomaly__drill`,onClick:()=>void t({to:`/settings/traces`,search:{q:e.correlationId,limit:100}}),children:[`↗ `,u()]}):null]})}let n=Q(e);if(!n.dominantCode){let e=n.sampleCorrelationId;return e?(0,q.jsx)(`div`,{className:`oc-anomaly__cause`,children:(0,q.jsxs)(`button`,{type:`button`,className:`oc-anomaly__drill`,onClick:()=>void t({to:`/settings/traces`,search:{correlationId:e,limit:100}}),children:[`↗ `,u()]})}):(0,q.jsx)(`span`,{className:`oc-traces__muted`,children:`—`})}let r=G(n.dominantCode),i=n.sampleCorrelationId;return(0,q.jsxs)(`div`,{className:`oc-anomaly__cause`,children:[(0,q.jsxs)(`div`,{className:`oc-anomaly__cause-head`,children:[(0,q.jsx)(`span`,{className:`oc-anomaly__cause-label`,children:r.label}),(0,q.jsx)(`code`,{className:`oc-traces__mono`,children:n.dominantCode})]}),(0,q.jsx)(`p`,{className:`oc-anomaly__cause-hint`,children:r.hint}),i?(0,q.jsxs)(`button`,{type:`button`,className:`oc-anomaly__drill`,onClick:()=>void t({to:`/settings/traces`,search:{correlationId:i,limit:100}}),children:[`↗ `,u()]}):null]})}function ze({row:e}){let[t,n]=(0,K.useState)(!1),r=_(T.anomalies.getAnomalyAttachments,t?{anomalyId:e._id}:`skip`);return!e.attachments||e.attachments.length===0?null:(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`button`,{type:`button`,className:`oc-anomaly__drill`,onClick:()=>n(!0),children:[c(),e.attachments.length>1?` (${e.attachments.length})`:``]}),(0,q.jsx)(W,{open:t,onOpenChange:n,children:(0,q.jsxs)(H,{className:`oc-anomaly__attachments-dialog`,children:[(0,q.jsx)(R,{children:(0,q.jsx)(U,{children:s()})}),r===void 0?(0,q.jsx)(`p`,{className:`oc-traces__muted`,children:p()}):r.length===0?(0,q.jsx)(`p`,{className:`oc-traces__muted`,children:f()}):(0,q.jsx)(`div`,{className:`oc-anomaly__attachments`,children:r.map(e=>(0,q.jsxs)(`section`,{className:`oc-anomaly__attachment`,children:[(0,q.jsx)(`h4`,{className:`oc-anomaly__attachment-name`,children:(0,q.jsx)(`code`,{className:`oc-traces__mono`,children:e.name})}),(0,q.jsx)(`pre`,{className:`oc-anomaly__attachment-content`,children:e.content})]},e.name))})]})})]})}function Be({severity:e}){return(0,q.jsx)(`span`,{className:`oc-anomaly__sev oc-anomaly__sev--${e}`,children:e})}function Ve({status:e}){return e===`open`?(0,q.jsx)(N,{variant:`destructive`,children:d()}):e===`acknowledged`?(0,q.jsx)(N,{variant:`secondary`,children:v()}):(0,q.jsx)(N,{variant:`outline`,children:i()})}function He(e){return e.length>8?e.slice(0,8):e}export{X as AnomaliesTab};
@@ -1 +1 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{Aw as r,Cw as i,Dw as a,Ew as o,Ow as s,Sw as c,Tw as l,_w as u,ai as d,az as f,bw as p,gw as m,ii as h,kw as g,ni as _,oi as v,ri as y,t as b,ti as x,vw as S,ww as C,xw as w,yw as T}from"./api-BDOBe_HI.js";import{$ as E,Fn as D,Pn as O,Q as k,X as A,Z as j,a as M,ct as N,et as P,i as F,n as I,o as L,s as R}from"./index-DtAFZhtv.js";import{n as ee}from"./TimeRangePicker-B-foA1-L.js";import{t as z}from"./FilterBar-D99V_QOK.js";import{t as B}from"./AdvancedFilter-D9vv5fSO.js";import{t as V}from"./DataTableShell-D2PIAVAw.js";var H=t(e(),1),U=n(),W={kind:`relative`,from:I,to:`now`},G=`__all__`,K=[{value:`action`,label:v()},{value:`realLabel`,label:d()},{value:`targetLabel`,label:h()},{value:`impersonated`,label:y()},{value:`resource`,label:_()},{value:`resourceId`,label:x()}];function q(){let e=D({from:`/settings/audit`}),t=O({from:`/settings/audit`}),n=e.q??``,d=e.action??G,h=e.impersonated??G,_=e.resource??G,v=F(e.from,e.to),y=(0,H.useMemo)(()=>R(e.adv),[e.adv]),{from:x,to:I}=ee(v),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,...L(e)})}),Q=e=>void t({search:t=>({...t,adv:M(e)}),replace:!0}),$=f(b.admin.listAudit,{filter:{q:n||void 0,from:x,to:I,action:d===G?void 0:d,resource:_===G?void 0:_,impersonated:h===G?void 0:h===`yes`,advanced:y.length>0?y: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!==``||d!==G||h!==G||_!==G||y.length>0||v.kind!==`relative`||v.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:[r(),` `,(0,U.jsx)(`span`,{className:`oc-filter__window`,children:g()})]}),(0,U.jsxs)(z,{q:n,onQChange:q,searchPlaceholder:s(),timeRange:v,onTimeRangeChange:Z,onReset:ie,canReset:re,children:[(0,U.jsxs)(A,{value:d,onValueChange:J,children:[(0,U.jsx)(E,{size:`sm`,className:`w-40`,children:(0,U.jsx)(P,{placeholder:a()})}),(0,U.jsxs)(j,{children:[(0,U.jsx)(k,{value:G,children:o()}),te.map(e=>(0,U.jsx)(k,{value:e,children:e},e))]})]}),(0,U.jsxs)(A,{value:h,onValueChange:Y,children:[(0,U.jsx)(E,{size:`sm`,className:`w-40`,children:(0,U.jsx)(P,{})}),(0,U.jsxs)(j,{children:[(0,U.jsx)(k,{value:G,children:l()}),(0,U.jsx)(k,{value:`yes`,children:C()}),(0,U.jsx)(k,{value:`no`,children:i()})]})]}),(0,U.jsxs)(A,{value:_,onValueChange:X,children:[(0,U.jsx)(E,{size:`sm`,className:`w-40`,children:(0,U.jsx)(P,{placeholder:c()})}),(0,U.jsxs)(j,{children:[(0,U.jsx)(k,{value:G,children:w()}),ne.map(e=>(0,U.jsx)(k,{value:e,children:e},e))]})]})]}),(0,U.jsx)(B,{fields:K,seed:y,onChange:Q}),(0,U.jsx)(V,{title:p(),rows:$,emptyHint:T(),columns:[{header:S(),cell:e=>N(e.at),sort:e=>e.at},{header:a(),cell:e=>e.action,sort:e=>e.action},{header:u(),cell:e=>e.realLabel,sort:e=>e.realLabel},{header:m(),cell:e=>e.targetLabel??`—`,sort:e=>e.targetLabel??null},{header:c(),cell:e=>e.resource?e.resource+(e.resourceId?` · ${e.resourceId.slice(0,8)}`:``):`—`,sort:e=>e.resource??null}]})]})}export{q as AuditTab};
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{Aw as r,Cw as i,Dw as a,Ew as o,Ow as s,Sw as c,Tw as l,_w as u,ai as d,az as f,bw as p,gw as m,ii as h,kw as g,ni as _,oi as v,ri as y,t as b,ti as x,vw as S,ww as C,xw as w,yw as T}from"./api-BDOBe_HI.js";import{$ as E,Fn as D,Pn as O,Q as k,X as A,Z as j,a as M,ct as N,et as P,i as F,n as I,o as L,s as R}from"./index-B0ufU8aN.js";import{n as ee}from"./TimeRangePicker-4TbN0Xgb.js";import{t as z}from"./FilterBar-DqZs9qry.js";import{t as B}from"./AdvancedFilter-CddmHJ3w.js";import{t as V}from"./DataTableShell-CFPC-1m0.js";var H=t(e(),1),U=n(),W={kind:`relative`,from:I,to:`now`},G=`__all__`,K=[{value:`action`,label:v()},{value:`realLabel`,label:d()},{value:`targetLabel`,label:h()},{value:`impersonated`,label:y()},{value:`resource`,label:_()},{value:`resourceId`,label:x()}];function q(){let e=D({from:`/settings/audit`}),t=O({from:`/settings/audit`}),n=e.q??``,d=e.action??G,h=e.impersonated??G,_=e.resource??G,v=F(e.from,e.to),y=(0,H.useMemo)(()=>R(e.adv),[e.adv]),{from:x,to:I}=ee(v),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,...L(e)})}),Q=e=>void t({search:t=>({...t,adv:M(e)}),replace:!0}),$=f(b.admin.listAudit,{filter:{q:n||void 0,from:x,to:I,action:d===G?void 0:d,resource:_===G?void 0:_,impersonated:h===G?void 0:h===`yes`,advanced:y.length>0?y: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!==``||d!==G||h!==G||_!==G||y.length>0||v.kind!==`relative`||v.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:[r(),` `,(0,U.jsx)(`span`,{className:`oc-filter__window`,children:g()})]}),(0,U.jsxs)(z,{q:n,onQChange:q,searchPlaceholder:s(),timeRange:v,onTimeRangeChange:Z,onReset:ie,canReset:re,children:[(0,U.jsxs)(A,{value:d,onValueChange:J,children:[(0,U.jsx)(E,{size:`sm`,className:`w-40`,children:(0,U.jsx)(P,{placeholder:a()})}),(0,U.jsxs)(j,{children:[(0,U.jsx)(k,{value:G,children:o()}),te.map(e=>(0,U.jsx)(k,{value:e,children:e},e))]})]}),(0,U.jsxs)(A,{value:h,onValueChange:Y,children:[(0,U.jsx)(E,{size:`sm`,className:`w-40`,children:(0,U.jsx)(P,{})}),(0,U.jsxs)(j,{children:[(0,U.jsx)(k,{value:G,children:l()}),(0,U.jsx)(k,{value:`yes`,children:C()}),(0,U.jsx)(k,{value:`no`,children:i()})]})]}),(0,U.jsxs)(A,{value:_,onValueChange:X,children:[(0,U.jsx)(E,{size:`sm`,className:`w-40`,children:(0,U.jsx)(P,{placeholder:c()})}),(0,U.jsxs)(j,{children:[(0,U.jsx)(k,{value:G,children:w()}),ne.map(e=>(0,U.jsx)(k,{value:e,children:e},e))]})]})]}),(0,U.jsx)(B,{fields:K,seed:y,onChange:Q}),(0,U.jsx)(V,{title:p(),rows:$,emptyHint:T(),columns:[{header:S(),cell:e=>N(e.at),sort:e=>e.at},{header:a(),cell:e=>e.action,sort:e=>e.action},{header:u(),cell:e=>e.realLabel,sort:e=>e.realLabel},{header:m(),cell:e=>e.targetLabel??`—`,sort:e=>e.targetLabel??null},{header:c(),cell:e=>e.resource?e.resource+(e.resourceId?` · ${e.resourceId.slice(0,8)}`:``):`—`,sort:e=>e.resource??null}]})]})}export{q as AuditTab};
@@ -1 +1 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$v as r,Ar as i,Ay as a,By as o,Cb as s,Cr as c,Cy as l,D as u,Db as d,Dr as f,Dy as p,Eb as m,Er as h,Ey as g,Fy as _,Gy as ee,Hy as te,Iy as v,Jy as ne,Ky as re,Ly as ie,Mb as y,My as ae,Ny as b,Ob as oe,Oy as se,Py as ce,Qv as le,Ry as ue,Sb as de,Sy as fe,Tb as pe,Tr as me,Ty as he,U as ge,Uy as _e,Vy as ve,Wy as ye,Xy as be,Yy as xe,Zl as Se,_y as Ce,au as we,ay as Te,az as x,by as Ee,cu as De,cy as Oe,du as ke,dy as Ae,ey as je,fu as Me,fy as S,gy as Ne,hy as Pe,iu as Fe,iy as Ie,iz as Le,jb as Re,jy as ze,kb as Be,ky as Ve,lu as He,ly as Ue,my as We,nu as Ge,ny as Ke,nz as qe,ou as Je,oy as Ye,pu as Xe,py as Ze,qy as Qe,ru as $e,ry as et,su as tt,sy as nt,t as C,tu as rt,ty as it,uu as at,uy as ot,vb as st,vy as ct,wb as lt,wr as ut,wy as dt,xy as ft,yb as pt,yy as mt,zy as ht}from"./api-BDOBe_HI.js";import{r as w}from"./dist-Ct8KdJzy.js";import{t as gt}from"./chevron-up-CHvHESC0.js";import{t as _t}from"./chevrons-up-down-DdxQzLW8.js";import{i as vt,n as T,o as yt,r as bt,s as xt}from"./FieldLabel-DylbQ765.js";import{i as St,n as Ct,r as wt,t as Tt}from"./tabs-Nve_dRxd.js";import{t as E}from"./button-BXoUycz-.js";import{$ as D,An as O,Bt as Et,Dt,Et as k,F as Ot,Fn as kt,Pn as At,Q as A,Rt as jt,X as j,Z as M,at as Mt,bn as Nt,ct as Pt,et as N,jn as Ft,jt as P,lt as F,nt as It,on as Lt,ot as Rt,q as zt,rn as I,rt as Bt,tt as Vt,ut as Ht,zt as Ut}from"./index-DtAFZhtv.js";import{r as Wt}from"./locales-CPjguROj.js";import{a as Gt,i as L,n as Kt,o as R,r as z,t as B}from"./table-Ql8c7BIW.js";import{t as qt}from"./FilterBar-D99V_QOK.js";import{a as V,n as Jt,o as H,r as U,s as Yt,t as Xt}from"./compatView-B2QN2HCH.js";import{t as W}from"./dispatchErrorInfo-CEC_I9Id.js";var Zt=u(`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`}]]),Qt=u(`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 $t(e){return e.filter(e=>e.state===`error`)}function en(e){return e.reachable&&$t(e.targets).length===0}function tn(e){return en(e)?(e.unreachableInstances??[]).length>0?`gateways_unreachable`:`ok`:`error`}function nn(e){return e.state===`error`&&e.lastErrorCode!==null}function rn(e){return!!e.lastDownstreamRejectCode}function K(e){return e.kind??`openclaw`}function an(e){return[...e].sort((e,t)=>e===`openclaw`?-1:t===`openclaw`?1:e.localeCompare(t))}function on(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,K(e));let i=e=>(e.instanceName?r.get(e.instanceName):void 0)??`openclaw`,a=new Set;for(let e of n)a.add(K(e));for(let e of t)a.add(e.provider);for(let t of e)a.add(i(t));return an(a).map(r=>({key:r,connections:e.filter(e=>i(e)===r),compatTargets:t.filter(e=>e.provider===r),instances:n.filter(e=>K(e)===r)}))}function q(e){return e===`openclaw`?`OpenClaw`:e===`hermes`?`Hermes`:e.charAt(0).toUpperCase()+e.slice(1)}var J=`__all__`,sn={q:``,state:J,instance:J,version:J},Y={connected:0,error:1,idle:2};function cn(e){return e.q.trim()!==``||e.state!==`__all__`||e.instance!==`__all__`||e.version!==`__all__`}function ln(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 X(e,t){return e.localeCompare(t,void 0,{numeric:!0,sensitivity:`base`})}function Z(e,t){return e===`version`?t.gatewayVersion===null:e===`lastOk`?t.lastOkAt===null:!1}function un(e,t,n){switch(e){case`state`:return(Y[t.state]??99)-(Y[n.state]??99);case`instance`:return X(t.instanceLabel??t.instanceName??``,n.instanceLabel??n.instanceName??``);case`host`:return X(t.gatewayHost,n.gatewayHost);case`version`:{let e=t.gatewayVersion,r=n.gatewayVersion;return H(e,r)??X(e,r)}case`lastOk`:return t.lastOkAt-n.lastOkAt;default:return X(t.targetLabel,n.targetLabel)}}function dn(e,t){if(!t)return e;let n=t.dir===`asc`?1:-1;return[...e].sort((e,r)=>{let i=Z(t.key,e),a=Z(t.key,r);return i&&a?0:i?1:a?-1:n*un(t.key,e,r)})}function fn(e){let t=new Set;for(let n of e)t.add(n.state);return[...t].sort((e,t)=>(Y[e]??99)-(Y[t]??99))}function pn(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)=>X(e.label,t.label))}function mn(e){let t=new Set;for(let n of e)n.gatewayVersion!==null&&t.add(n.gatewayVersion);return[...t].sort((e,t)=>H(e,t)??X(e,t))}var Q=n();function hn({connections:e,displayByInstance:t}){let[n,r]=(0,G.useState)(sn),[i,a]=(0,G.useState)(null),o=(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),attempts:e.attempts,lastOkAt:e.lastOkAt??null,lastErrorCode:e.lastErrorCode??null,lastErrorAt:e.lastErrorAt??null,lastDownstreamRejectCode:e.lastDownstreamRejectCode??null,lastDownstreamRejectAt:e.lastDownstreamRejectAt??null})),[e,t]),s=(0,G.useMemo)(()=>fn(o),[o]),c=(0,G.useMemo)(()=>pn(o),[o]),l=(0,G.useMemo)(()=>mn(o),[o]),u=(0,G.useMemo)(()=>dn(ln(o,n),i),[o,n,i]);function d(e){a(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:Ne()}):(0,Q.jsxs)(`div`,{className:`oc-conn`,children:[(0,Q.jsxs)(qt,{q:n.q,onQChange:e=>r(t=>({...t,q:e})),searchPlaceholder:Ze(),onReset:()=>r(sn),canReset:cn(n),children:[(0,Q.jsxs)(j,{value:n.state,onValueChange:e=>r(t=>({...t,state:e})),children:[(0,Q.jsx)(D,{size:`sm`,className:`w-36`,children:(0,Q.jsx)(N,{placeholder:Ae()})}),(0,Q.jsxs)(M,{children:[(0,Q.jsx)(A,{value:J,children:S()}),s.map(e=>(0,Q.jsx)(A,{value:e,children:_n(e)},e))]})]}),(0,Q.jsxs)(j,{value:n.instance,onValueChange:e=>r(t=>({...t,instance:e})),children:[(0,Q.jsx)(D,{size:`sm`,className:`w-40`,children:(0,Q.jsx)(N,{placeholder:ot()})}),(0,Q.jsxs)(M,{children:[(0,Q.jsx)(A,{value:J,children:S()}),c.map(e=>(0,Q.jsx)(A,{value:e.name,children:e.label},e.name))]})]}),(0,Q.jsxs)(j,{value:n.version,onValueChange:e=>r(t=>({...t,version:e})),children:[(0,Q.jsx)(D,{size:`sm`,className:`w-36`,children:(0,Q.jsx)(N,{placeholder:Ue()})}),(0,Q.jsxs)(M,{children:[(0,Q.jsx)(A,{value:J,children:S()}),l.map(e=>(0,Q.jsx)(A,{value:e,children:e},e))]})]})]}),u.length===0?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:Oe()}):(0,Q.jsxs)(B,{className:`oc-conn__table`,children:[(0,Q.jsx)(Gt,{children:(0,Q.jsxs)(R,{children:[(0,Q.jsx)($,{label:nt(),sortKey:`target`,sort:i,onSort:d}),(0,Q.jsx)($,{label:Ye(),sortKey:`state`,sort:i,onSort:d}),(0,Q.jsx)($,{label:Te(),sortKey:`instance`,sort:i,onSort:d}),(0,Q.jsx)($,{label:Ie(),sortKey:`host`,sort:i,onSort:d}),(0,Q.jsx)($,{label:et(),sortKey:`version`,sort:i,onSort:d}),(0,Q.jsx)(L,{children:Ke()}),(0,Q.jsx)($,{label:it(),sortKey:`lastOk`,sort:i,onSort:d})]})}),(0,Q.jsx)(Kt,{children:u.map(e=>(0,Q.jsx)(gn,{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)(L,{"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)(gt,{size:13,"aria-hidden":!0}):(0,Q.jsx)(w,{size:13,"aria-hidden":!0}):(0,Q.jsx)(_t,{size:13,"aria-hidden":!0,className:`oc-conn__sort-idle`})]})})}function gn({r:e}){let t=nn(e)?W(e.lastErrorCode):null,n=rn(e)?W(e.lastDownstreamRejectCode):null;return(0,Q.jsxs)(G.Fragment,{children:[(0,Q.jsxs)(R,{className:`oc-conn__row oc-conn__row--${e.state}`,children:[(0,Q.jsx)(z,{children:(0,Q.jsx)(`code`,{className:`oc-traces__mono`,children:e.targetLabel})}),(0,Q.jsx)(z,{children:(0,Q.jsx)(vn,{state:e.state})}),(0,Q.jsx)(z,{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)(z,{children:(0,Q.jsx)(`span`,{className:`oc-bridge-target__host`,children:e.gatewayHost})}),(0,Q.jsx)(z,{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)(z,{children:(0,Q.jsx)(`span`,{className:`oc-conn__stats`,children:Pe({ok:e.okCount,errors:e.errorCount,attempts:e.attempts})})}),(0,Q.jsx)(z,{children:e.lastOkAt?(0,Q.jsx)(`span`,{className:`oc-traces__mono`,children:F(e.lastOkAt)}):(0,Q.jsx)(`span`,{className:`oc-traces__muted`,children:`—`})})]}),t||n?(0,Q.jsx)(R,{className:`oc-conn__detail-row`,children:(0,Q.jsxs)(z,{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,n?(0,Q.jsxs)(`div`,{className:`oc-bridge-target__downstream`,children:[We({label:n.label}),` `,(0,Q.jsx)(`code`,{className:`oc-traces__mono`,children:e.lastDownstreamRejectCode}),e.lastDownstreamRejectAt?` · ${F(e.lastDownstreamRejectAt)}`:``]}):null]})}):null]})}function _n(e){return e===`connected`?je():e===`error`?r():le()}function vn({state:e}){return e===`connected`?(0,Q.jsx)(k,{variant:`secondary`,children:je()}):e===`error`?(0,Q.jsx)(k,{variant:`destructive`,children:r()}):(0,Q.jsx)(k,{variant:`outline`,children:le()})}function yn(){return x(C.bridgeHealth.getBridgeHealth,{})}function bn(){let e=yn(),t=x(C.compat.getBridgeCompat,{}),n=x(C.me.getMe,{host:zt})?.role===`admin`,r=x(C.admin.listInstances,n?{}:`skip`),i=x(C.agents.usageForInstances,n?{}:`skip`),a=At(),o=()=>void a({to:`/settings/anomalies`,search:{status:`open`}}),s=on(e?e.targets:[],t?t.targets:[],r??[]),{section:l}=kt({from:`/settings/bridge`}),u=At({from:`/settings/bridge`}),d=t?.compat??null,p=t===void 0?`loading`:t===null?`nodata`:`ready`,m=d!==null&&Jt(d,`hermes`)&&!s.some(e=>e.key===`hermes`);return(0,Q.jsxs)(`div`,{className:`oc-bridge`,children:[(0,Q.jsx)(xn,{health:e,compat:t,onSeeAnomalies:o}),(0,Q.jsx)(`p`,{className:`oc-admin__hint oc-bridge__caption`,children:v()}),i&&i.length>0?(0,Q.jsxs)(`section`,{className:`oc-bridge__usage`,children:[(0,Q.jsx)(`h3`,{className:`oc-bridge__usage-title`,children:_()}),(0,Q.jsxs)(B,{children:[(0,Q.jsx)(Gt,{children:(0,Q.jsxs)(R,{children:[(0,Q.jsx)(L,{children:f()}),(0,Q.jsx)(L,{children:h()}),(0,Q.jsx)(L,{children:me()}),(0,Q.jsx)(L,{children:ut()}),(0,Q.jsx)(L,{children:c()})]})}),(0,Q.jsx)(Kt,{children:i.flatMap(e=>{let t=Ot(e.usage,Date.now());return t?t.windows.map((t,n)=>(0,Q.jsxs)(R,{children:[(0,Q.jsx)(z,{className:`font-medium`,children:n===0?e.instanceName:``}),(0,Q.jsx)(z,{children:t.provider}),(0,Q.jsx)(z,{children:t.label}),(0,Q.jsx)(z,{children:(0,Q.jsxs)(k,{variant:t.percentLeft<=10?`destructive`:t.percentLeft<=25?`outline`:`secondary`,children:[t.percentLeft,`%`]})}),(0,Q.jsx)(z,{className:`text-muted-foreground`,children:t.resetText??`—`})]},`${e.instanceName}:${t.provider}:${t.label}`)):[]})})]})]}):null,s.length>0?(0,Q.jsxs)(Tt,{value:s.some(e=>e.key===l)?l:s[0]?.key??`openclaw`,onValueChange:e=>void u({search:{section:e},replace:!0}),children:[(0,Q.jsx)(wt,{className:`w-full`,children:s.map(e=>(0,Q.jsxs)(St,{value:e.key,className:`flex-1 gap-1.5`,children:[(0,Q.jsx)(Lt,{size:13,"aria-hidden":!0}),q(e.key)]},e.key))}),s.map(e=>(0,Q.jsx)(Ct,{value:e.key,children:(0,Q.jsx)(Sn,{providerKey:e.key,connections:e.connections,instances:e.instances,manifest:d,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 xn({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:V(t.bridgeVersion)}),i?(0,Q.jsxs)(Q.Fragment,{children:[` `,(0,Q.jsxs)(`code`,{className:`oc-traces__mono`,title:ke(),children:[`(`,i,`)`]})]}):null,r?(0,Q.jsxs)(`strong`,{className:`oc-bridge-card__mismatch`,children:[` `,at({build:t.buildVersion??`?`})]}):null,` · `,He(),` `,(0,Q.jsx)(`code`,{className:`oc-traces__mono`,children:t.protocolVersion===null?De():String(t.protocolVersion)})]}):null;if(e===void 0)return(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:p()});if(e===null)return(0,Q.jsx)(`div`,{className:`oc-bridge-card oc-bridge-card--idle`,children:g()});let o=$t(e.targets),s=!e.reachable,c=tn(e),u=e.unreachableInstances??[],d=c===`ok`?`ok`:c===`gateways_unreachable`?`warn`:`error`,f=Pt(e.checkedAt),m=e.startedAt==null?null:Pt(e.startedAt);return(0,Q.jsxs)(`div`,{className:`oc-bridge-card oc-bridge-card--${d}`,children:[(0,Q.jsx)(`div`,{className:`oc-bridge-card__icon`,"aria-hidden":!0,children:c===`ok`?(0,Q.jsx)(O,{size:22}):s||c===`gateways_unreachable`?(0,Q.jsx)(Qt,{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`?he():c===`gateways_unreachable`?ft({count:u.length}):s?dt():l({count:o.length})}),(0,Q.jsxs)(`div`,{className:`oc-bridge-card__meta`,children:[(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(Zt,{size:12,"aria-hidden":!0}),` `,fe({time:f})]}),m?(0,Q.jsx)(`span`,{children:mt({time:m})}):null,a]}),c===`gateways_unreachable`?(0,Q.jsx)(`p`,{className:`oc-bridge-card__hint`,children:Ee({names:u.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:ct()})]})}function Sn({providerKey:e,connections:t,instances:n,manifest:r,compatStatus:i,compatReachable:a,protocol:o}){let s=r?Yt(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:Xt(t,e,r)})}let d=l.map(e=>e.state),f=d.includes(`beyond`)?`beyond`:d.length>0&&d.every(e=>e===`supported`)?`supported`:null,[p,m]=(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)(Lt,{size:15,"aria-hidden":!0,className:`oc-bridge-provider__icon`}),(0,Q.jsx)(`span`,{className:`oc-bridge-provider__name`,children:q(e)}),f?(0,Q.jsx)(k,{variant:f===`beyond`?`destructive`:`secondary`,children:U(f)}):null]}),(0,Q.jsx)(`h4`,{className:`oc-bridge-provider__sub`,children:Xe()}),(0,Q.jsx)(wn,{providerName:q(e),support:s,compatStatus:i,compatReachable:a,manifest:r,instanceRows:l}),o?(0,Q.jsx)(Cn,{protocol:o}):null,(0,Q.jsxs)(`button`,{type:`button`,className:`oc-bridge-provider__sub oc-bridge-provider__sub--toggle`,"aria-expanded":p,onClick:()=>m(e=>!e),children:[p?(0,Q.jsx)(w,{size:13,"aria-hidden":!0}):(0,Q.jsx)(Ft,{size:13,"aria-hidden":!0}),Ce({count:t.length})]}),p?(0,Q.jsx)(hn,{connections:t,displayByInstance:c}):null]})}function Cn({protocol:e}){let[t,n]=(0,G.useState)(!1),r=e.coverage,i=e.drift??[],o=(e.driftOverflow??0)+(e.driftTruncated??0);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`h4`,{className:`oc-bridge-provider__sub`,children:[ce(),i.length>0?(0,Q.jsx)(k,{variant:`destructive`,children:ae({count:i.length})}):o>0?(0,Q.jsx)(k,{variant:`destructive`,children:ze()}):(0,Q.jsx)(k,{variant:`secondary`,children:b()})]}),(0,Q.jsxs)(`p`,{className:`oc-admin__hint`,children:[a({version:e.vendoredVersion}),r?` · `+Ve({handled:r.handled,ignored:r.ignored,gaps:r.gaps}):null]}),o>0?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:ge({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)(w,{size:13,"aria-hidden":!0}):(0,Q.jsx)(Ft,{size:13,"aria-hidden":!0}),se({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 wn({support:e,compatStatus:t,compatReachable:n,manifest:r,instanceRows:a,providerName:o}){return t===`loading`?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:p()}):t===`nodata`?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:Me()}):(0,Q.jsxs)(`div`,{className:`oc-compat`,children:[n?null:(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:tt()}),r===null?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:Je()}):(0,Q.jsxs)(`div`,{className:`oc-compat__support`,children:[(0,Q.jsx)(`span`,{className:`oc-compat__label`,children:i({provider:o})}),e&&e.range!==null?(0,Q.jsx)(`span`,{children:we({min:e.range.min,max:e.range.maxValidated})}):(0,Q.jsx)(`span`,{children:De()}),e?(0,Q.jsx)(On,{versions:e.validatedVersions}):null]}),a.length===0?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:rt()}):(0,Q.jsx)(`div`,{className:`oc-compat__targets`,children:a.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:V(e.version)}),(0,Q.jsx)(k,{variant:e.state===`supported`?`secondary`:e.state===`beyond`?`destructive`:`outline`,children:U(e.state)})]},e.instanceName))})]})}function Tn({instance:e,onClose:t}){return(0,Q.jsx)(Vt,{open:!0,onOpenChange:e=>!e&&t(),children:(0,Q.jsxs)(It,{className:`oc-bridge-config-dialog`,onOpenAutoFocus:e=>e.preventDefault(),children:[(0,Q.jsxs)(Mt,{children:[(0,Q.jsx)(Rt,{children:y({instance:e.displayName??e.name})}),(0,Q.jsx)(Bt,{children:Re()})]}),(0,Q.jsx)(Dn,{instance:e,onClose:t})]})})}function En({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)(O,{"aria-hidden":!0}):(0,Q.jsx)(I,{"aria-hidden":!0}),(0,Q.jsxs)(`span`,{children:[e,` — `,t.ok?o():t.detail]})]}):(0,Q.jsxs)(`p`,{className:`oc-bridge-config__check-row oc-bridge-config__check-row--skip`,children:[e,` — `,ht()]}):null}function Dn({instance:e,onClose:t}){let n=Le(C.admin.upsertInstanceConfig),r=qe(C.bridge.validateMediaPaths),i=Dt(),a=Wt(e.config?.contentLocale,void 0),[o,c]=(0,G.useState)(()=>vt(e.config??{},a)),[l,u]=(0,G.useState)(!1),[f,p]=(0,G.useState)(!1),[h,g]=(0,G.useState)(null),_=o.inboundMediaMode===`shared-fs`,v=o.mediaMode===`shared-fs`,y=_||v;async function ae(){p(!0),g(null);try{g(await r({instanceName:e.name,inboundMediaMode:o.inboundMediaMode,mediaMode:o.mediaMode}))}catch(e){i.error(ye(),e)}finally{p(!1)}}async function b(){u(!0);try{let r=e.config??{};await n({instanceId:e._id,config:bt(o,r,a)}),t()}catch(e){i.error(lt(),e)}finally{u(!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)(T,{label:Be(),help:s()}),(0,Q.jsxs)(j,{value:o.mediaMode,onValueChange:e=>c({...o,mediaMode:e}),children:[(0,Q.jsx)(D,{size:`sm`,className:`w-full`,children:(0,Q.jsx)(N,{})}),(0,Q.jsx)(M,{children:xt.map(e=>(0,Q.jsx)(A,{value:e,children:e},e))})]})]}),(0,Q.jsxs)(`label`,{className:`oc-field`,children:[(0,Q.jsx)(T,{label:oe(),help:de()}),(0,Q.jsxs)(j,{value:o.inboundMediaMode,onValueChange:e=>c({...o,inboundMediaMode:e}),children:[(0,Q.jsx)(D,{size:`sm`,className:`w-full`,children:(0,Q.jsx)(N,{})}),(0,Q.jsx)(M,{children:yt.map(e=>(0,Q.jsx)(A,{value:e,children:e},e))})]})]}),(0,Q.jsxs)(`label`,{className:`oc-field`,children:[(0,Q.jsx)(T,{label:d(),help:pt()}),(0,Q.jsx)(P,{type:`number`,min:1,max:4096,className:`w-full`,value:o.mediaMaxMb,onChange:e=>c({...o,mediaMaxMb:Math.trunc(Number(e.target.value)||0)})})]})]}),y&&(0,Q.jsxs)(`div`,{className:`oc-bridge-config__grid`,children:[_&&(0,Q.jsxs)(`label`,{className:`oc-field`,children:[(0,Q.jsx)(T,{label:be(),help:xe()}),(0,Q.jsx)(P,{className:`w-full`,spellCheck:!1,value:o.inboundAgentMount,onChange:e=>c({...o,inboundAgentMount:e.target.value})})]}),v&&(0,Q.jsxs)(`label`,{className:`oc-field`,children:[(0,Q.jsx)(T,{label:ne(),help:Qe()}),(0,Q.jsx)(P,{className:`w-full`,spellCheck:!1,value:o.outboundAgentMount,onChange:e=>c({...o,outboundAgentMount:e.target.value})})]})]}),(0,Q.jsxs)(`label`,{className:`oc-field--row`,children:[(0,Q.jsx)(Ht,{checked:o.rehydration,onCheckedChange:e=>c({...o,rehydration:e===!0})}),(0,Q.jsx)(T,{label:m(),help:st()})]}),y&&h!==null&&(0,Q.jsx)(`div`,{className:`oc-bridge-config__check`,children:h.reachable?!h.inbound&&!h.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}),ie({reason:h.reason??`?`})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(En,{label:te(),result:h.inbound}),(0,Q.jsx)(En,{label:ve(),result:h.outbound}),(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:_e()})]}):(0,Q.jsxs)(`p`,{className:`oc-bridge-config__check-row oc-bridge-config__check-row--err`,children:[(0,Q.jsx)(I,{"aria-hidden":!0}),ue()]})}),(0,Q.jsxs)(`div`,{className:`oc-bridge-config__actions`,children:[y&&(0,Q.jsxs)(E,{variant:`outline`,size:`sm`,onClick:()=>void ae(),disabled:f,children:[f?(0,Q.jsx)(Nt,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,f?ee():re()]}),(0,Q.jsx)(E,{size:`sm`,onClick:()=>void b(),disabled:l,children:pe()})]})]})})}function On({versions:e}){if(e.length===0)return null;let t=[...e].reverse();return(0,Q.jsxs)(jt,{children:[(0,Q.jsx)(Et,{asChild:!0,children:(0,Q.jsxs)(`button`,{type:`button`,className:`oc-compat__versions-btn`,children:[e.length===1?Fe():$e({count:e.length}),(0,Q.jsx)(w,{size:13,"aria-hidden":!0})]})}),(0,Q.jsxs)(Ut,{className:`oc-compat__versions-pop`,align:`start`,children:[(0,Q.jsx)(`p`,{className:`oc-compat__versions-title`,children:Ge()}),(0,Q.jsx)(`div`,{className:`oc-compat__versions-list`,children:t.map(e=>(0,Q.jsx)(k,{variant:`secondary`,children:e},e))})]})]})}export{bn as BridgeTab,Tn as InstanceConfigDialog};
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$v as r,Ar as i,Ay as a,By as o,Cb as s,Cr as c,Cy as l,D as u,Db as d,Dr as f,Dy as p,Eb as m,Er as h,Ey as g,Fy as _,Gy as ee,Hy as te,Iy as v,Jy as ne,Ky as re,Ly as ie,Mb as y,My as ae,Ny as b,Ob as oe,Oy as se,Py as ce,Qv as le,Ry as ue,Sb as de,Sy as fe,Tb as pe,Tr as me,Ty as he,U as ge,Uy as _e,Vy as ve,Wy as ye,Xy as be,Yy as xe,Zl as Se,_y as Ce,au as we,ay as Te,az as x,by as Ee,cu as De,cy as Oe,du as ke,dy as Ae,ey as je,fu as Me,fy as S,gy as Ne,hy as Pe,iu as Fe,iy as Ie,iz as Le,jb as Re,jy as ze,kb as Be,ky as Ve,lu as He,ly as Ue,my as We,nu as Ge,ny as Ke,nz as qe,ou as Je,oy as Ye,pu as Xe,py as Ze,qy as Qe,ru as $e,ry as et,su as tt,sy as nt,t as C,tu as rt,ty as it,uu as at,uy as ot,vb as st,vy as ct,wb as lt,wr as ut,wy as dt,xy as ft,yb as pt,yy as mt,zy as ht}from"./api-BDOBe_HI.js";import{r as w}from"./dist-Ct8KdJzy.js";import{t as gt}from"./chevron-up-CHvHESC0.js";import{t as _t}from"./chevrons-up-down-DdxQzLW8.js";import{i as vt,n as T,o as yt,r as bt,s as xt}from"./FieldLabel-DRaqrHBA.js";import{i as St,n as Ct,r as wt,t as Tt}from"./tabs-DbSY71M_.js";import{t as E}from"./button-BXoUycz-.js";import{$ as D,An as O,Bt as Et,Dt,Et as k,F as Ot,Fn as kt,Pn as At,Q as A,Rt as jt,X as j,Z as M,at as Mt,bn as Nt,ct as Pt,et as N,jn as Ft,jt as P,lt as F,nt as It,on as Lt,ot as Rt,q as zt,rn as I,rt as Bt,tt as Vt,ut as Ht,zt as Ut}from"./index-B0ufU8aN.js";import{r as Wt}from"./locales-CPjguROj.js";import{a as Gt,i as L,n as Kt,o as R,r as z,t as B}from"./table-Ql8c7BIW.js";import{t as qt}from"./FilterBar-DqZs9qry.js";import{a as V,n as Jt,o as H,r as U,s as Yt,t as Xt}from"./compatView-B2QN2HCH.js";import{t as W}from"./dispatchErrorInfo-CEC_I9Id.js";var Zt=u(`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`}]]),Qt=u(`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 $t(e){return e.filter(e=>e.state===`error`)}function en(e){return e.reachable&&$t(e.targets).length===0}function tn(e){return en(e)?(e.unreachableInstances??[]).length>0?`gateways_unreachable`:`ok`:`error`}function nn(e){return e.state===`error`&&e.lastErrorCode!==null}function rn(e){return!!e.lastDownstreamRejectCode}function K(e){return e.kind??`openclaw`}function an(e){return[...e].sort((e,t)=>e===`openclaw`?-1:t===`openclaw`?1:e.localeCompare(t))}function on(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,K(e));let i=e=>(e.instanceName?r.get(e.instanceName):void 0)??`openclaw`,a=new Set;for(let e of n)a.add(K(e));for(let e of t)a.add(e.provider);for(let t of e)a.add(i(t));return an(a).map(r=>({key:r,connections:e.filter(e=>i(e)===r),compatTargets:t.filter(e=>e.provider===r),instances:n.filter(e=>K(e)===r)}))}function q(e){return e===`openclaw`?`OpenClaw`:e===`hermes`?`Hermes`:e.charAt(0).toUpperCase()+e.slice(1)}var J=`__all__`,sn={q:``,state:J,instance:J,version:J},Y={connected:0,error:1,idle:2};function cn(e){return e.q.trim()!==``||e.state!==`__all__`||e.instance!==`__all__`||e.version!==`__all__`}function ln(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 X(e,t){return e.localeCompare(t,void 0,{numeric:!0,sensitivity:`base`})}function Z(e,t){return e===`version`?t.gatewayVersion===null:e===`lastOk`?t.lastOkAt===null:!1}function un(e,t,n){switch(e){case`state`:return(Y[t.state]??99)-(Y[n.state]??99);case`instance`:return X(t.instanceLabel??t.instanceName??``,n.instanceLabel??n.instanceName??``);case`host`:return X(t.gatewayHost,n.gatewayHost);case`version`:{let e=t.gatewayVersion,r=n.gatewayVersion;return H(e,r)??X(e,r)}case`lastOk`:return t.lastOkAt-n.lastOkAt;default:return X(t.targetLabel,n.targetLabel)}}function dn(e,t){if(!t)return e;let n=t.dir===`asc`?1:-1;return[...e].sort((e,r)=>{let i=Z(t.key,e),a=Z(t.key,r);return i&&a?0:i?1:a?-1:n*un(t.key,e,r)})}function fn(e){let t=new Set;for(let n of e)t.add(n.state);return[...t].sort((e,t)=>(Y[e]??99)-(Y[t]??99))}function pn(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)=>X(e.label,t.label))}function mn(e){let t=new Set;for(let n of e)n.gatewayVersion!==null&&t.add(n.gatewayVersion);return[...t].sort((e,t)=>H(e,t)??X(e,t))}var Q=n();function hn({connections:e,displayByInstance:t}){let[n,r]=(0,G.useState)(sn),[i,a]=(0,G.useState)(null),o=(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),attempts:e.attempts,lastOkAt:e.lastOkAt??null,lastErrorCode:e.lastErrorCode??null,lastErrorAt:e.lastErrorAt??null,lastDownstreamRejectCode:e.lastDownstreamRejectCode??null,lastDownstreamRejectAt:e.lastDownstreamRejectAt??null})),[e,t]),s=(0,G.useMemo)(()=>fn(o),[o]),c=(0,G.useMemo)(()=>pn(o),[o]),l=(0,G.useMemo)(()=>mn(o),[o]),u=(0,G.useMemo)(()=>dn(ln(o,n),i),[o,n,i]);function d(e){a(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:Ne()}):(0,Q.jsxs)(`div`,{className:`oc-conn`,children:[(0,Q.jsxs)(qt,{q:n.q,onQChange:e=>r(t=>({...t,q:e})),searchPlaceholder:Ze(),onReset:()=>r(sn),canReset:cn(n),children:[(0,Q.jsxs)(j,{value:n.state,onValueChange:e=>r(t=>({...t,state:e})),children:[(0,Q.jsx)(D,{size:`sm`,className:`w-36`,children:(0,Q.jsx)(N,{placeholder:Ae()})}),(0,Q.jsxs)(M,{children:[(0,Q.jsx)(A,{value:J,children:S()}),s.map(e=>(0,Q.jsx)(A,{value:e,children:_n(e)},e))]})]}),(0,Q.jsxs)(j,{value:n.instance,onValueChange:e=>r(t=>({...t,instance:e})),children:[(0,Q.jsx)(D,{size:`sm`,className:`w-40`,children:(0,Q.jsx)(N,{placeholder:ot()})}),(0,Q.jsxs)(M,{children:[(0,Q.jsx)(A,{value:J,children:S()}),c.map(e=>(0,Q.jsx)(A,{value:e.name,children:e.label},e.name))]})]}),(0,Q.jsxs)(j,{value:n.version,onValueChange:e=>r(t=>({...t,version:e})),children:[(0,Q.jsx)(D,{size:`sm`,className:`w-36`,children:(0,Q.jsx)(N,{placeholder:Ue()})}),(0,Q.jsxs)(M,{children:[(0,Q.jsx)(A,{value:J,children:S()}),l.map(e=>(0,Q.jsx)(A,{value:e,children:e},e))]})]})]}),u.length===0?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:Oe()}):(0,Q.jsxs)(B,{className:`oc-conn__table`,children:[(0,Q.jsx)(Gt,{children:(0,Q.jsxs)(R,{children:[(0,Q.jsx)($,{label:nt(),sortKey:`target`,sort:i,onSort:d}),(0,Q.jsx)($,{label:Ye(),sortKey:`state`,sort:i,onSort:d}),(0,Q.jsx)($,{label:Te(),sortKey:`instance`,sort:i,onSort:d}),(0,Q.jsx)($,{label:Ie(),sortKey:`host`,sort:i,onSort:d}),(0,Q.jsx)($,{label:et(),sortKey:`version`,sort:i,onSort:d}),(0,Q.jsx)(L,{children:Ke()}),(0,Q.jsx)($,{label:it(),sortKey:`lastOk`,sort:i,onSort:d})]})}),(0,Q.jsx)(Kt,{children:u.map(e=>(0,Q.jsx)(gn,{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)(L,{"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)(gt,{size:13,"aria-hidden":!0}):(0,Q.jsx)(w,{size:13,"aria-hidden":!0}):(0,Q.jsx)(_t,{size:13,"aria-hidden":!0,className:`oc-conn__sort-idle`})]})})}function gn({r:e}){let t=nn(e)?W(e.lastErrorCode):null,n=rn(e)?W(e.lastDownstreamRejectCode):null;return(0,Q.jsxs)(G.Fragment,{children:[(0,Q.jsxs)(R,{className:`oc-conn__row oc-conn__row--${e.state}`,children:[(0,Q.jsx)(z,{children:(0,Q.jsx)(`code`,{className:`oc-traces__mono`,children:e.targetLabel})}),(0,Q.jsx)(z,{children:(0,Q.jsx)(vn,{state:e.state})}),(0,Q.jsx)(z,{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)(z,{children:(0,Q.jsx)(`span`,{className:`oc-bridge-target__host`,children:e.gatewayHost})}),(0,Q.jsx)(z,{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)(z,{children:(0,Q.jsx)(`span`,{className:`oc-conn__stats`,children:Pe({ok:e.okCount,errors:e.errorCount,attempts:e.attempts})})}),(0,Q.jsx)(z,{children:e.lastOkAt?(0,Q.jsx)(`span`,{className:`oc-traces__mono`,children:F(e.lastOkAt)}):(0,Q.jsx)(`span`,{className:`oc-traces__muted`,children:`—`})})]}),t||n?(0,Q.jsx)(R,{className:`oc-conn__detail-row`,children:(0,Q.jsxs)(z,{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,n?(0,Q.jsxs)(`div`,{className:`oc-bridge-target__downstream`,children:[We({label:n.label}),` `,(0,Q.jsx)(`code`,{className:`oc-traces__mono`,children:e.lastDownstreamRejectCode}),e.lastDownstreamRejectAt?` · ${F(e.lastDownstreamRejectAt)}`:``]}):null]})}):null]})}function _n(e){return e===`connected`?je():e===`error`?r():le()}function vn({state:e}){return e===`connected`?(0,Q.jsx)(k,{variant:`secondary`,children:je()}):e===`error`?(0,Q.jsx)(k,{variant:`destructive`,children:r()}):(0,Q.jsx)(k,{variant:`outline`,children:le()})}function yn(){return x(C.bridgeHealth.getBridgeHealth,{})}function bn(){let e=yn(),t=x(C.compat.getBridgeCompat,{}),n=x(C.me.getMe,{host:zt})?.role===`admin`,r=x(C.admin.listInstances,n?{}:`skip`),i=x(C.agents.usageForInstances,n?{}:`skip`),a=At(),o=()=>void a({to:`/settings/anomalies`,search:{status:`open`}}),s=on(e?e.targets:[],t?t.targets:[],r??[]),{section:l}=kt({from:`/settings/bridge`}),u=At({from:`/settings/bridge`}),d=t?.compat??null,p=t===void 0?`loading`:t===null?`nodata`:`ready`,m=d!==null&&Jt(d,`hermes`)&&!s.some(e=>e.key===`hermes`);return(0,Q.jsxs)(`div`,{className:`oc-bridge`,children:[(0,Q.jsx)(xn,{health:e,compat:t,onSeeAnomalies:o}),(0,Q.jsx)(`p`,{className:`oc-admin__hint oc-bridge__caption`,children:v()}),i&&i.length>0?(0,Q.jsxs)(`section`,{className:`oc-bridge__usage`,children:[(0,Q.jsx)(`h3`,{className:`oc-bridge__usage-title`,children:_()}),(0,Q.jsxs)(B,{children:[(0,Q.jsx)(Gt,{children:(0,Q.jsxs)(R,{children:[(0,Q.jsx)(L,{children:f()}),(0,Q.jsx)(L,{children:h()}),(0,Q.jsx)(L,{children:me()}),(0,Q.jsx)(L,{children:ut()}),(0,Q.jsx)(L,{children:c()})]})}),(0,Q.jsx)(Kt,{children:i.flatMap(e=>{let t=Ot(e.usage,Date.now());return t?t.windows.map((t,n)=>(0,Q.jsxs)(R,{children:[(0,Q.jsx)(z,{className:`font-medium`,children:n===0?e.instanceName:``}),(0,Q.jsx)(z,{children:t.provider}),(0,Q.jsx)(z,{children:t.label}),(0,Q.jsx)(z,{children:(0,Q.jsxs)(k,{variant:t.percentLeft<=10?`destructive`:t.percentLeft<=25?`outline`:`secondary`,children:[t.percentLeft,`%`]})}),(0,Q.jsx)(z,{className:`text-muted-foreground`,children:t.resetText??`—`})]},`${e.instanceName}:${t.provider}:${t.label}`)):[]})})]})]}):null,s.length>0?(0,Q.jsxs)(Tt,{value:s.some(e=>e.key===l)?l:s[0]?.key??`openclaw`,onValueChange:e=>void u({search:{section:e},replace:!0}),children:[(0,Q.jsx)(wt,{className:`w-full`,children:s.map(e=>(0,Q.jsxs)(St,{value:e.key,className:`flex-1 gap-1.5`,children:[(0,Q.jsx)(Lt,{size:13,"aria-hidden":!0}),q(e.key)]},e.key))}),s.map(e=>(0,Q.jsx)(Ct,{value:e.key,children:(0,Q.jsx)(Sn,{providerKey:e.key,connections:e.connections,instances:e.instances,manifest:d,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 xn({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:V(t.bridgeVersion)}),i?(0,Q.jsxs)(Q.Fragment,{children:[` `,(0,Q.jsxs)(`code`,{className:`oc-traces__mono`,title:ke(),children:[`(`,i,`)`]})]}):null,r?(0,Q.jsxs)(`strong`,{className:`oc-bridge-card__mismatch`,children:[` `,at({build:t.buildVersion??`?`})]}):null,` · `,He(),` `,(0,Q.jsx)(`code`,{className:`oc-traces__mono`,children:t.protocolVersion===null?De():String(t.protocolVersion)})]}):null;if(e===void 0)return(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:p()});if(e===null)return(0,Q.jsx)(`div`,{className:`oc-bridge-card oc-bridge-card--idle`,children:g()});let o=$t(e.targets),s=!e.reachable,c=tn(e),u=e.unreachableInstances??[],d=c===`ok`?`ok`:c===`gateways_unreachable`?`warn`:`error`,f=Pt(e.checkedAt),m=e.startedAt==null?null:Pt(e.startedAt);return(0,Q.jsxs)(`div`,{className:`oc-bridge-card oc-bridge-card--${d}`,children:[(0,Q.jsx)(`div`,{className:`oc-bridge-card__icon`,"aria-hidden":!0,children:c===`ok`?(0,Q.jsx)(O,{size:22}):s||c===`gateways_unreachable`?(0,Q.jsx)(Qt,{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`?he():c===`gateways_unreachable`?ft({count:u.length}):s?dt():l({count:o.length})}),(0,Q.jsxs)(`div`,{className:`oc-bridge-card__meta`,children:[(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(Zt,{size:12,"aria-hidden":!0}),` `,fe({time:f})]}),m?(0,Q.jsx)(`span`,{children:mt({time:m})}):null,a]}),c===`gateways_unreachable`?(0,Q.jsx)(`p`,{className:`oc-bridge-card__hint`,children:Ee({names:u.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:ct()})]})}function Sn({providerKey:e,connections:t,instances:n,manifest:r,compatStatus:i,compatReachable:a,protocol:o}){let s=r?Yt(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:Xt(t,e,r)})}let d=l.map(e=>e.state),f=d.includes(`beyond`)?`beyond`:d.length>0&&d.every(e=>e===`supported`)?`supported`:null,[p,m]=(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)(Lt,{size:15,"aria-hidden":!0,className:`oc-bridge-provider__icon`}),(0,Q.jsx)(`span`,{className:`oc-bridge-provider__name`,children:q(e)}),f?(0,Q.jsx)(k,{variant:f===`beyond`?`destructive`:`secondary`,children:U(f)}):null]}),(0,Q.jsx)(`h4`,{className:`oc-bridge-provider__sub`,children:Xe()}),(0,Q.jsx)(wn,{providerName:q(e),support:s,compatStatus:i,compatReachable:a,manifest:r,instanceRows:l}),o?(0,Q.jsx)(Cn,{protocol:o}):null,(0,Q.jsxs)(`button`,{type:`button`,className:`oc-bridge-provider__sub oc-bridge-provider__sub--toggle`,"aria-expanded":p,onClick:()=>m(e=>!e),children:[p?(0,Q.jsx)(w,{size:13,"aria-hidden":!0}):(0,Q.jsx)(Ft,{size:13,"aria-hidden":!0}),Ce({count:t.length})]}),p?(0,Q.jsx)(hn,{connections:t,displayByInstance:c}):null]})}function Cn({protocol:e}){let[t,n]=(0,G.useState)(!1),r=e.coverage,i=e.drift??[],o=(e.driftOverflow??0)+(e.driftTruncated??0);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`h4`,{className:`oc-bridge-provider__sub`,children:[ce(),i.length>0?(0,Q.jsx)(k,{variant:`destructive`,children:ae({count:i.length})}):o>0?(0,Q.jsx)(k,{variant:`destructive`,children:ze()}):(0,Q.jsx)(k,{variant:`secondary`,children:b()})]}),(0,Q.jsxs)(`p`,{className:`oc-admin__hint`,children:[a({version:e.vendoredVersion}),r?` · `+Ve({handled:r.handled,ignored:r.ignored,gaps:r.gaps}):null]}),o>0?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:ge({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)(w,{size:13,"aria-hidden":!0}):(0,Q.jsx)(Ft,{size:13,"aria-hidden":!0}),se({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 wn({support:e,compatStatus:t,compatReachable:n,manifest:r,instanceRows:a,providerName:o}){return t===`loading`?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:p()}):t===`nodata`?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:Me()}):(0,Q.jsxs)(`div`,{className:`oc-compat`,children:[n?null:(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:tt()}),r===null?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:Je()}):(0,Q.jsxs)(`div`,{className:`oc-compat__support`,children:[(0,Q.jsx)(`span`,{className:`oc-compat__label`,children:i({provider:o})}),e&&e.range!==null?(0,Q.jsx)(`span`,{children:we({min:e.range.min,max:e.range.maxValidated})}):(0,Q.jsx)(`span`,{children:De()}),e?(0,Q.jsx)(On,{versions:e.validatedVersions}):null]}),a.length===0?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:rt()}):(0,Q.jsx)(`div`,{className:`oc-compat__targets`,children:a.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:V(e.version)}),(0,Q.jsx)(k,{variant:e.state===`supported`?`secondary`:e.state===`beyond`?`destructive`:`outline`,children:U(e.state)})]},e.instanceName))})]})}function Tn({instance:e,onClose:t}){return(0,Q.jsx)(Vt,{open:!0,onOpenChange:e=>!e&&t(),children:(0,Q.jsxs)(It,{className:`oc-bridge-config-dialog`,onOpenAutoFocus:e=>e.preventDefault(),children:[(0,Q.jsxs)(Mt,{children:[(0,Q.jsx)(Rt,{children:y({instance:e.displayName??e.name})}),(0,Q.jsx)(Bt,{children:Re()})]}),(0,Q.jsx)(Dn,{instance:e,onClose:t})]})})}function En({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)(O,{"aria-hidden":!0}):(0,Q.jsx)(I,{"aria-hidden":!0}),(0,Q.jsxs)(`span`,{children:[e,` — `,t.ok?o():t.detail]})]}):(0,Q.jsxs)(`p`,{className:`oc-bridge-config__check-row oc-bridge-config__check-row--skip`,children:[e,` — `,ht()]}):null}function Dn({instance:e,onClose:t}){let n=Le(C.admin.upsertInstanceConfig),r=qe(C.bridge.validateMediaPaths),i=Dt(),a=Wt(e.config?.contentLocale,void 0),[o,c]=(0,G.useState)(()=>vt(e.config??{},a)),[l,u]=(0,G.useState)(!1),[f,p]=(0,G.useState)(!1),[h,g]=(0,G.useState)(null),_=o.inboundMediaMode===`shared-fs`,v=o.mediaMode===`shared-fs`,y=_||v;async function ae(){p(!0),g(null);try{g(await r({instanceName:e.name,inboundMediaMode:o.inboundMediaMode,mediaMode:o.mediaMode}))}catch(e){i.error(ye(),e)}finally{p(!1)}}async function b(){u(!0);try{let r=e.config??{};await n({instanceId:e._id,config:bt(o,r,a)}),t()}catch(e){i.error(lt(),e)}finally{u(!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)(T,{label:Be(),help:s()}),(0,Q.jsxs)(j,{value:o.mediaMode,onValueChange:e=>c({...o,mediaMode:e}),children:[(0,Q.jsx)(D,{size:`sm`,className:`w-full`,children:(0,Q.jsx)(N,{})}),(0,Q.jsx)(M,{children:xt.map(e=>(0,Q.jsx)(A,{value:e,children:e},e))})]})]}),(0,Q.jsxs)(`label`,{className:`oc-field`,children:[(0,Q.jsx)(T,{label:oe(),help:de()}),(0,Q.jsxs)(j,{value:o.inboundMediaMode,onValueChange:e=>c({...o,inboundMediaMode:e}),children:[(0,Q.jsx)(D,{size:`sm`,className:`w-full`,children:(0,Q.jsx)(N,{})}),(0,Q.jsx)(M,{children:yt.map(e=>(0,Q.jsx)(A,{value:e,children:e},e))})]})]}),(0,Q.jsxs)(`label`,{className:`oc-field`,children:[(0,Q.jsx)(T,{label:d(),help:pt()}),(0,Q.jsx)(P,{type:`number`,min:1,max:4096,className:`w-full`,value:o.mediaMaxMb,onChange:e=>c({...o,mediaMaxMb:Math.trunc(Number(e.target.value)||0)})})]})]}),y&&(0,Q.jsxs)(`div`,{className:`oc-bridge-config__grid`,children:[_&&(0,Q.jsxs)(`label`,{className:`oc-field`,children:[(0,Q.jsx)(T,{label:be(),help:xe()}),(0,Q.jsx)(P,{className:`w-full`,spellCheck:!1,value:o.inboundAgentMount,onChange:e=>c({...o,inboundAgentMount:e.target.value})})]}),v&&(0,Q.jsxs)(`label`,{className:`oc-field`,children:[(0,Q.jsx)(T,{label:ne(),help:Qe()}),(0,Q.jsx)(P,{className:`w-full`,spellCheck:!1,value:o.outboundAgentMount,onChange:e=>c({...o,outboundAgentMount:e.target.value})})]})]}),(0,Q.jsxs)(`label`,{className:`oc-field--row`,children:[(0,Q.jsx)(Ht,{checked:o.rehydration,onCheckedChange:e=>c({...o,rehydration:e===!0})}),(0,Q.jsx)(T,{label:m(),help:st()})]}),y&&h!==null&&(0,Q.jsx)(`div`,{className:`oc-bridge-config__check`,children:h.reachable?!h.inbound&&!h.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}),ie({reason:h.reason??`?`})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(En,{label:te(),result:h.inbound}),(0,Q.jsx)(En,{label:ve(),result:h.outbound}),(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:_e()})]}):(0,Q.jsxs)(`p`,{className:`oc-bridge-config__check-row oc-bridge-config__check-row--err`,children:[(0,Q.jsx)(I,{"aria-hidden":!0}),ue()]})}),(0,Q.jsxs)(`div`,{className:`oc-bridge-config__actions`,children:[y&&(0,Q.jsxs)(E,{variant:`outline`,size:`sm`,onClick:()=>void ae(),disabled:f,children:[f?(0,Q.jsx)(Nt,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,f?ee():re()]}),(0,Q.jsx)(E,{size:`sm`,onClick:()=>void b(),disabled:l,children:pe()})]})]})})}function On({versions:e}){if(e.length===0)return null;let t=[...e].reverse();return(0,Q.jsxs)(jt,{children:[(0,Q.jsx)(Et,{asChild:!0,children:(0,Q.jsxs)(`button`,{type:`button`,className:`oc-compat__versions-btn`,children:[e.length===1?Fe():$e({count:e.length}),(0,Q.jsx)(w,{size:13,"aria-hidden":!0})]})}),(0,Q.jsxs)(Ut,{className:`oc-compat__versions-pop`,align:`start`,children:[(0,Q.jsx)(`p`,{className:`oc-compat__versions-title`,children:Ge()}),(0,Q.jsx)(`div`,{className:`oc-compat__versions-list`,children:t.map(e=>(0,Q.jsx)(k,{variant:`secondary`,children:e},e))})]})]})}export{bn as BridgeTab,Tn as InstanceConfigDialog};
@@ -1 +1 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{Ab as r,Bo as i,Go as a,Ho as o,Ko as s,Ld as c,Lo as l,Md as u,Nd as d,Qu as f,Ro as p,Su as m,Uo as h,Vo as g,Wo as _,XR as v,_u as y,az as b,bu as x,gu as S,hu as C,iz as w,kr as T,mu as E,nz as D,t as O,vu as k,xu as A,yu as j,zd as M,zo as N}from"./api-BDOBe_HI.js";import{t as P}from"./button-BXoUycz-.js";import{$ as F,B as I,M as L,N as R,Q as z,X as B,Z as V,et as H,jt as U,rn as W,ut as G}from"./index-DtAFZhtv.js";import{i as K}from"./compatView-B2QN2HCH.js";/* empty css */var q=t(e(),1),J=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`];function Y(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 X=n();function Z({instance:e}){let t=w(O.admin.upsertInstanceConfig),n=b(O.agents.listAgentsForInstance,{instanceName:e.name}),r=typeof e.config?.converterAgentId==`string`?e.config.converterAgentId:``,[i,a]=(0,q.useState)(r),[s,c]=(0,q.useState)(`idle`);(0,q.useEffect)(()=>{a(r),c(`idle`)},[e._id,r]);let l=`__none__`,u=i!==r;async function d(){c(`saving`);try{let n={...e.config??{}};i===``||i===l?delete n.converterAgentId:n.converterAgentId=i,await t({instanceId:e._id,config:n}),c(`done`)}catch{c(`error`)}}let f=n?.agents??[];return(0,X.jsxs)(`div`,{className:`oc-cdefaults__row`,children:[(0,X.jsx)(`span`,{className:`oc-cdefaults__label`,children:h()}),(0,X.jsx)(`p`,{className:`oc-admin__hint`,children:o()}),(0,X.jsxs)(`div`,{className:`oc-cdefaults__inline`,children:[(0,X.jsxs)(B,{value:i===``?l:i,onValueChange:e=>a(e===l?``:e),children:[(0,X.jsx)(F,{className:`oc-cdefaults__select`,"aria-label":h(),children:(0,X.jsx)(H,{placeholder:g()})}),(0,X.jsxs)(V,{children:[(0,X.jsx)(z,{value:l,children:g()}),f.map(e=>(0,X.jsx)(z,{value:e.agentId,children:e.displayName?`${e.displayName} (${e.agentId})`:e.agentId},e.agentId))]})]}),(0,X.jsx)(P,{size:`sm`,disabled:!u||s===`saving`,onClick:()=>void d(),children:s===`saving`?M():S()})]}),s===`done`?(0,X.jsx)(`p`,{className:`oc-admin__hint`,role:`status`,children:C()}):null,s===`error`?(0,X.jsx)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:E()}):null]})}function Q({instance:e}){let t=w(O.admin.upsertInstanceConfig),n=e.config?.curationEnabled===!0,r=typeof e.config?.curationBudgetChars==`number`?e.config.curationBudgetChars:null,[a,o]=(0,q.useState)(n),[s,c]=(0,q.useState)(r===null?``:String(r)),[l,u]=(0,q.useState)(`idle`);(0,q.useEffect)(()=>{o(n),c(r===null?``:String(r)),u(`idle`)},[e._id,n,r]);let d=s.trim(),f=d===``?null:/^\d+$/.test(d)?Number.parseInt(d,10):NaN,m=!a||f===null||Number.isInteger(f)&&f>=4e3&&f<=6e4,h=a!==n||(f??null)!==r;async function g(){u(`saving`);try{let n={...e.config??{}};n.curationEnabled=a,!a||f===null||Number.isNaN(f)?delete n.curationBudgetChars:n.curationBudgetChars=f,await t({instanceId:e._id,config:n}),u(`done`)}catch{u(`error`)}}return(0,X.jsxs)(`div`,{className:`oc-cdefaults__row`,children:[(0,X.jsxs)(`label`,{className:`oc-cdefaults__inline`,style:{cursor:`pointer`},children:[(0,X.jsx)(G,{checked:a,onCheckedChange:e=>o(e===!0),"aria-label":_()}),(0,X.jsx)(`span`,{className:`oc-cdefaults__label`,children:_()})]}),(0,X.jsxs)(`div`,{className:`oc-cdefaults__inline`,children:[(0,X.jsx)(U,{type:`number`,min:4e3,max:6e4,step:1e3,placeholder:`20000`,value:s,onChange:e=>c(e.target.value),className:`oc-cdefaults__number`,"aria-invalid":!m,"aria-label":i(),disabled:!a}),(0,X.jsx)(P,{size:`sm`,disabled:!h||!m||l===`saving`,onClick:()=>void g(),children:l===`saving`?M():S()})]}),m?null:(0,X.jsx)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:N()}),l===`done`?(0,X.jsx)(`p`,{className:`oc-admin__hint`,role:`status`,children:C()}):null,l===`error`?(0,X.jsx)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:E()}):null,(0,X.jsx)(`p`,{className:`oc-cdefaults__help`,children:p()})]})}function $({instance:e}){let t=w(O.admin.upsertInstanceConfig),n=typeof e.config?.summarizeThresholdChars==`number`?e.config.summarizeThresholdChars:null,[r,i]=(0,q.useState)(n===null?``:String(n)),[o,c]=(0,q.useState)(`idle`);(0,q.useEffect)(()=>{i(n===null?``:String(n)),c(`idle`)},[e._id,n]);let u=r.trim(),d=u===``?null:/^\d+$/.test(u)?Number.parseInt(u,10):NaN,f=d===null||Number.isInteger(d)&&d>=1e3&&d<=2e5,p=(d??null)!==n;async function m(){c(`saving`);try{let n={...e.config??{}};d===null?delete n.summarizeThresholdChars:n.summarizeThresholdChars=d,await t({instanceId:e._id,config:n}),c(`done`)}catch{c(`error`)}}return(0,X.jsxs)(`div`,{className:`oc-cdefaults__row`,children:[(0,X.jsx)(`span`,{className:`oc-cdefaults__label`,children:s()}),(0,X.jsxs)(`div`,{className:`oc-cdefaults__inline`,children:[(0,X.jsx)(U,{type:`number`,min:1e3,max:2e5,step:1e3,placeholder:`8000`,value:r,onChange:e=>i(e.target.value),className:`oc-cdefaults__number`,"aria-invalid":!f}),(0,X.jsx)(P,{size:`sm`,disabled:!p||!f||o===`saving`,onClick:()=>void m(),children:o===`saving`?M():S()})]}),f?null:(0,X.jsx)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:l()}),o===`done`?(0,X.jsx)(`p`,{className:`oc-admin__hint`,role:`status`,children:C()}):null,o===`error`?(0,X.jsx)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:E()}):null,(0,X.jsx)(`p`,{className:`oc-cdefaults__help`,children:a()})]})}function ee(){let e=D(O.agentFiles.getChatDefaults),[t,n]=(0,q.useState)({status:`loading`}),i=b(O.admin.listInstances,{}),[a,o]=(0,q.useState)(null);(0,q.useEffect)(()=>{!i||i.length===0||(!a||!i.some(e=>e.name===a))&&o(i[0].name)},[i,a]);let s=(i?.length??0)>1,l=i!==void 0&&i.length===0,p=b(O.compat.forInstance,a?{instanceName:a}:`skip`),h=a?I(p,`configDefaults`):`loading`,g=h===`loading`?null:h.blocked,_=(0,q.useMemo)(()=>s&&a?{instanceName:a}:{},[s,a]),S=(0,q.useRef)(0),C=(0,q.useCallback)(async()=>{let t=++S.current;n({status:`loading`});try{let r=Y(await e(_));if(S.current!==t)return;n({status:`done`,current:r})}catch{if(S.current!==t)return;n({status:`error`})}},[e,_]);(0,q.useEffect)(()=>{g===!1&&(s&&!a||C())},[C,g,s,a]);let w=t.status===`done`?t.current:null,E=(0,q.useMemo)(()=>J.map(e=>({id:e,label:R(e)})),[]),M=(0,q.useMemo)(()=>[{id:`fast`,label:d()},{id:`standard`,label:u()}],[]);return(0,X.jsxs)(`div`,{className:`oc-cdefaults`,children:[(0,X.jsx)(`p`,{className:`oc-admin__hint`,children:m()}),s&&a?(0,X.jsxs)(`div`,{className:`oc-cdefaults__row`,children:[(0,X.jsx)(`span`,{className:`oc-cdefaults__label`,children:f()}),(0,X.jsxs)(B,{value:a,onValueChange:e=>o(e),children:[(0,X.jsx)(F,{size:`sm`,"aria-label":f(),children:(0,X.jsx)(H,{})}),(0,X.jsx)(V,{children:(i??[]).map(e=>(0,X.jsx)(z,{value:e.name,children:e.name},e.name))})]})]}):null,l?(0,X.jsx)(`p`,{className:`oc-admin__hint`,role:`status`,children:r()}):h===`loading`?(0,X.jsx)(`p`,{className:`oc-admin__hint`,children:v()}):h.blocked?(0,X.jsxs)(`p`,{className:`oc-compat__blocked`,role:`status`,children:[(0,X.jsx)(W,{size:14,"aria-hidden":!0}),` `,K(h.gatewayVersion,h.provider)]}):t.status===`loading`?(0,X.jsx)(`p`,{className:`oc-admin__hint`,children:v()}):t.status===`error`?(0,X.jsxs)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:[y(),` `,(0,X.jsx)(P,{variant:`outline`,size:`sm`,onClick:()=>void C(),children:c()})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`oc-cdefaults__row`,children:[(0,X.jsx)(`span`,{className:`oc-cdefaults__label`,children:A()}),(0,X.jsx)(L,{options:E,value:w?.thinkingDefault??null,onChange:()=>{},disabled:!0}),(0,X.jsx)(`p`,{className:`oc-cdefaults__help`,children:x()})]}),(0,X.jsxs)(`div`,{className:`oc-cdefaults__row`,children:[(0,X.jsx)(`span`,{className:`oc-cdefaults__label`,children:j()}),(0,X.jsx)(L,{options:M,value:w===null||w.fastModeDefault===null?null:w.fastModeDefault?`fast`:`standard`,onChange:()=>{},disabled:!0}),(0,X.jsx)(`p`,{className:`oc-cdefaults__help`,children:k()})]}),(0,X.jsx)(`p`,{className:`oc-cdefaults__note`,children:T()})]}),(()=>{let e=i?.find(e=>e.name===(a??i[0]?.name));return e?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)($,{instance:e}),(0,X.jsx)(Q,{instance:e}),(0,X.jsx)(Z,{instance:e})]}):null})()]})}export{ee as ChatDefaultsTab};
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{Ab as r,Bo as i,Go as a,Ho as o,Ko as s,Ld as c,Lo as l,Md as u,Nd as d,Qu as f,Ro as p,Su as m,Uo as h,Vo as g,Wo as _,XR as v,_u as y,az as b,bu as x,gu as S,hu as C,iz as w,kr as T,mu as E,nz as D,t as O,vu as k,xu as A,yu as j,zd as M,zo as N}from"./api-BDOBe_HI.js";import{t as P}from"./button-BXoUycz-.js";import{$ as F,B as I,M as L,N as R,Q as z,X as B,Z as V,et as H,jt as U,rn as W,ut as G}from"./index-B0ufU8aN.js";import{i as K}from"./compatView-B2QN2HCH.js";/* empty css */var q=t(e(),1),J=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`];function Y(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 X=n();function Z({instance:e}){let t=w(O.admin.upsertInstanceConfig),n=b(O.agents.listAgentsForInstance,{instanceName:e.name}),r=typeof e.config?.converterAgentId==`string`?e.config.converterAgentId:``,[i,a]=(0,q.useState)(r),[s,c]=(0,q.useState)(`idle`);(0,q.useEffect)(()=>{a(r),c(`idle`)},[e._id,r]);let l=`__none__`,u=i!==r;async function d(){c(`saving`);try{let n={...e.config??{}};i===``||i===l?delete n.converterAgentId:n.converterAgentId=i,await t({instanceId:e._id,config:n}),c(`done`)}catch{c(`error`)}}let f=n?.agents??[];return(0,X.jsxs)(`div`,{className:`oc-cdefaults__row`,children:[(0,X.jsx)(`span`,{className:`oc-cdefaults__label`,children:h()}),(0,X.jsx)(`p`,{className:`oc-admin__hint`,children:o()}),(0,X.jsxs)(`div`,{className:`oc-cdefaults__inline`,children:[(0,X.jsxs)(B,{value:i===``?l:i,onValueChange:e=>a(e===l?``:e),children:[(0,X.jsx)(F,{className:`oc-cdefaults__select`,"aria-label":h(),children:(0,X.jsx)(H,{placeholder:g()})}),(0,X.jsxs)(V,{children:[(0,X.jsx)(z,{value:l,children:g()}),f.map(e=>(0,X.jsx)(z,{value:e.agentId,children:e.displayName?`${e.displayName} (${e.agentId})`:e.agentId},e.agentId))]})]}),(0,X.jsx)(P,{size:`sm`,disabled:!u||s===`saving`,onClick:()=>void d(),children:s===`saving`?M():S()})]}),s===`done`?(0,X.jsx)(`p`,{className:`oc-admin__hint`,role:`status`,children:C()}):null,s===`error`?(0,X.jsx)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:E()}):null]})}function Q({instance:e}){let t=w(O.admin.upsertInstanceConfig),n=e.config?.curationEnabled===!0,r=typeof e.config?.curationBudgetChars==`number`?e.config.curationBudgetChars:null,[a,o]=(0,q.useState)(n),[s,c]=(0,q.useState)(r===null?``:String(r)),[l,u]=(0,q.useState)(`idle`);(0,q.useEffect)(()=>{o(n),c(r===null?``:String(r)),u(`idle`)},[e._id,n,r]);let d=s.trim(),f=d===``?null:/^\d+$/.test(d)?Number.parseInt(d,10):NaN,m=!a||f===null||Number.isInteger(f)&&f>=4e3&&f<=6e4,h=a!==n||(f??null)!==r;async function g(){u(`saving`);try{let n={...e.config??{}};n.curationEnabled=a,!a||f===null||Number.isNaN(f)?delete n.curationBudgetChars:n.curationBudgetChars=f,await t({instanceId:e._id,config:n}),u(`done`)}catch{u(`error`)}}return(0,X.jsxs)(`div`,{className:`oc-cdefaults__row`,children:[(0,X.jsxs)(`label`,{className:`oc-cdefaults__inline`,style:{cursor:`pointer`},children:[(0,X.jsx)(G,{checked:a,onCheckedChange:e=>o(e===!0),"aria-label":_()}),(0,X.jsx)(`span`,{className:`oc-cdefaults__label`,children:_()})]}),(0,X.jsxs)(`div`,{className:`oc-cdefaults__inline`,children:[(0,X.jsx)(U,{type:`number`,min:4e3,max:6e4,step:1e3,placeholder:`20000`,value:s,onChange:e=>c(e.target.value),className:`oc-cdefaults__number`,"aria-invalid":!m,"aria-label":i(),disabled:!a}),(0,X.jsx)(P,{size:`sm`,disabled:!h||!m||l===`saving`,onClick:()=>void g(),children:l===`saving`?M():S()})]}),m?null:(0,X.jsx)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:N()}),l===`done`?(0,X.jsx)(`p`,{className:`oc-admin__hint`,role:`status`,children:C()}):null,l===`error`?(0,X.jsx)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:E()}):null,(0,X.jsx)(`p`,{className:`oc-cdefaults__help`,children:p()})]})}function $({instance:e}){let t=w(O.admin.upsertInstanceConfig),n=typeof e.config?.summarizeThresholdChars==`number`?e.config.summarizeThresholdChars:null,[r,i]=(0,q.useState)(n===null?``:String(n)),[o,c]=(0,q.useState)(`idle`);(0,q.useEffect)(()=>{i(n===null?``:String(n)),c(`idle`)},[e._id,n]);let u=r.trim(),d=u===``?null:/^\d+$/.test(u)?Number.parseInt(u,10):NaN,f=d===null||Number.isInteger(d)&&d>=1e3&&d<=2e5,p=(d??null)!==n;async function m(){c(`saving`);try{let n={...e.config??{}};d===null?delete n.summarizeThresholdChars:n.summarizeThresholdChars=d,await t({instanceId:e._id,config:n}),c(`done`)}catch{c(`error`)}}return(0,X.jsxs)(`div`,{className:`oc-cdefaults__row`,children:[(0,X.jsx)(`span`,{className:`oc-cdefaults__label`,children:s()}),(0,X.jsxs)(`div`,{className:`oc-cdefaults__inline`,children:[(0,X.jsx)(U,{type:`number`,min:1e3,max:2e5,step:1e3,placeholder:`8000`,value:r,onChange:e=>i(e.target.value),className:`oc-cdefaults__number`,"aria-invalid":!f}),(0,X.jsx)(P,{size:`sm`,disabled:!p||!f||o===`saving`,onClick:()=>void m(),children:o===`saving`?M():S()})]}),f?null:(0,X.jsx)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:l()}),o===`done`?(0,X.jsx)(`p`,{className:`oc-admin__hint`,role:`status`,children:C()}):null,o===`error`?(0,X.jsx)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:E()}):null,(0,X.jsx)(`p`,{className:`oc-cdefaults__help`,children:a()})]})}function ee(){let e=D(O.agentFiles.getChatDefaults),[t,n]=(0,q.useState)({status:`loading`}),i=b(O.admin.listInstances,{}),[a,o]=(0,q.useState)(null);(0,q.useEffect)(()=>{!i||i.length===0||(!a||!i.some(e=>e.name===a))&&o(i[0].name)},[i,a]);let s=(i?.length??0)>1,l=i!==void 0&&i.length===0,p=b(O.compat.forInstance,a?{instanceName:a}:`skip`),h=a?I(p,`configDefaults`):`loading`,g=h===`loading`?null:h.blocked,_=(0,q.useMemo)(()=>s&&a?{instanceName:a}:{},[s,a]),S=(0,q.useRef)(0),C=(0,q.useCallback)(async()=>{let t=++S.current;n({status:`loading`});try{let r=Y(await e(_));if(S.current!==t)return;n({status:`done`,current:r})}catch{if(S.current!==t)return;n({status:`error`})}},[e,_]);(0,q.useEffect)(()=>{g===!1&&(s&&!a||C())},[C,g,s,a]);let w=t.status===`done`?t.current:null,E=(0,q.useMemo)(()=>J.map(e=>({id:e,label:R(e)})),[]),M=(0,q.useMemo)(()=>[{id:`fast`,label:d()},{id:`standard`,label:u()}],[]);return(0,X.jsxs)(`div`,{className:`oc-cdefaults`,children:[(0,X.jsx)(`p`,{className:`oc-admin__hint`,children:m()}),s&&a?(0,X.jsxs)(`div`,{className:`oc-cdefaults__row`,children:[(0,X.jsx)(`span`,{className:`oc-cdefaults__label`,children:f()}),(0,X.jsxs)(B,{value:a,onValueChange:e=>o(e),children:[(0,X.jsx)(F,{size:`sm`,"aria-label":f(),children:(0,X.jsx)(H,{})}),(0,X.jsx)(V,{children:(i??[]).map(e=>(0,X.jsx)(z,{value:e.name,children:e.name},e.name))})]})]}):null,l?(0,X.jsx)(`p`,{className:`oc-admin__hint`,role:`status`,children:r()}):h===`loading`?(0,X.jsx)(`p`,{className:`oc-admin__hint`,children:v()}):h.blocked?(0,X.jsxs)(`p`,{className:`oc-compat__blocked`,role:`status`,children:[(0,X.jsx)(W,{size:14,"aria-hidden":!0}),` `,K(h.gatewayVersion,h.provider)]}):t.status===`loading`?(0,X.jsx)(`p`,{className:`oc-admin__hint`,children:v()}):t.status===`error`?(0,X.jsxs)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:[y(),` `,(0,X.jsx)(P,{variant:`outline`,size:`sm`,onClick:()=>void C(),children:c()})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`oc-cdefaults__row`,children:[(0,X.jsx)(`span`,{className:`oc-cdefaults__label`,children:A()}),(0,X.jsx)(L,{options:E,value:w?.thinkingDefault??null,onChange:()=>{},disabled:!0}),(0,X.jsx)(`p`,{className:`oc-cdefaults__help`,children:x()})]}),(0,X.jsxs)(`div`,{className:`oc-cdefaults__row`,children:[(0,X.jsx)(`span`,{className:`oc-cdefaults__label`,children:j()}),(0,X.jsx)(L,{options:M,value:w===null||w.fastModeDefault===null?null:w.fastModeDefault?`fast`:`standard`,onChange:()=>{},disabled:!0}),(0,X.jsx)(`p`,{className:`oc-cdefaults__help`,children:k()})]}),(0,X.jsx)(`p`,{className:`oc-cdefaults__note`,children:T()})]}),(()=>{let e=i?.find(e=>e.name===(a??i[0]?.name));return e?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)($,{instance:e}),(0,X.jsx)(Q,{instance:e}),(0,X.jsx)(Z,{instance:e})]}):null})()]})}export{ee as ChatDefaultsTab};
@@ -1 +1 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{Gm as r,Jm as i,Km as a,Wm as o,Xm as s,Ym as c,qm as l}from"./api-BDOBe_HI.js";import{r as u}from"./dist-Ct8KdJzy.js";import{t as d}from"./chevron-up-CHvHESC0.js";import{t as f}from"./chevrons-up-down-DdxQzLW8.js";import{t as p}from"./button-BXoUycz-.js";import{En as m,It as h,Lt as g,Mt as _,Nt as v,Pt as y,in as b,ln as x,ut as S}from"./index-DtAFZhtv.js";import{a as C,i as w,n as T,o as E,r as D,t as O}from"./table-Ql8c7BIW.js";var k=t(e(),1);function A(e,t){return typeof e==`number`&&typeof t==`number`?e-t:typeof e==`boolean`&&typeof t==`boolean`?!!e-+!!t:String(e).localeCompare(String(t),void 0,{numeric:!0,sensitivity:`base`})}function j(e,t,n){return[...e].sort((e,r)=>{let i=t(e),a=t(r),o=i==null,s=a==null;if(o||s)return o&&s?0:o?1:-1;let c=A(i,a);return n===`asc`?c:-c})}var M=n();function N({title:e,rows:t,columns:n,rowActions:A,onAdd:N,addLabel:P=s(),bulkActions:F,emptyHint:I=c(),isExpanded:L,renderExpanded:R}){let[z,B]=(0,k.useState)(new Set),[V,H]=(0,k.useState)(null),U=t??[],W=V?n[V.index]:void 0,G=V&&W?.sort?j(U,W.sort,V.dir):U;function K(e){H(t=>!t||t.index!==e?{index:e,dir:`asc`}:t.dir===`asc`?{index:e,dir:`desc`}:null)}let q=+!!F+n.length+ +!!A,J=U.length>0&&z.size===U.length,Y=z.size>0&&!J;function X(){B(J?new Set:new Set(U.map(e=>e._id)))}function Z(e){B(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}return(0,M.jsxs)(`div`,{className:`oc-dt`,children:[(0,M.jsxs)(`div`,{className:`oc-dt__bar`,children:[(0,M.jsx)(`h2`,{className:`oc-dt__title`,children:e}),(0,M.jsxs)(`div`,{className:`oc-dt__bar-actions`,children:[z.size>0&&F?F.map(e=>(0,M.jsxs)(p,{size:`sm`,variant:e.variant===`destructive`?`destructive`:`outline`,onClick:()=>{e.onSelect([...z]),B(new Set)},children:[e.variant===`destructive`?(0,M.jsx)(b,{}):null,e.label,` (`,z.size,`)`]},e.label)):null,N?(0,M.jsxs)(p,{size:`sm`,onClick:N,children:[(0,M.jsx)(x,{}),` `,P]}):null]})]}),t===void 0?(0,M.jsx)(`p`,{className:`oc-admin__hint`,children:i()}):U.length===0?(0,M.jsx)(`p`,{className:`oc-admin__hint`,children:I}):(0,M.jsxs)(O,{children:[(0,M.jsx)(C,{children:(0,M.jsxs)(E,{children:[F?(0,M.jsx)(w,{className:`w-8`,children:(0,M.jsx)(S,{"aria-label":l(),checked:J?!0:Y?`indeterminate`:!1,onCheckedChange:X})}):null,n.map((e,t)=>{let n=V?.index===t;return e.sort?(0,M.jsx)(w,{className:e.className,"aria-sort":n?V.dir===`asc`?`ascending`:`descending`:`none`,children:(0,M.jsxs)(`button`,{type:`button`,className:`oc-dt__sort`,onClick:()=>K(t),"aria-label":o({column:e.header}),children:[e.header,n?V.dir===`asc`?(0,M.jsx)(d,{className:`oc-dt__sort-icon`,"aria-hidden":!0}):(0,M.jsx)(u,{className:`oc-dt__sort-icon`,"aria-hidden":!0}):(0,M.jsx)(f,{className:`oc-dt__sort-icon oc-dt__sort-icon--idle`,"aria-hidden":!0})]})},e.header):(0,M.jsx)(w,{className:e.className,children:e.header},e.header)}),A?(0,M.jsx)(w,{className:`w-8`}):null]})}),(0,M.jsx)(T,{children:G.map(e=>{let t=A?.(e)??[],i=L?.(e)??!1;return(0,M.jsxs)(k.Fragment,{children:[(0,M.jsxs)(E,{className:`group/row`,children:[F?(0,M.jsx)(D,{children:(0,M.jsx)(S,{"aria-label":a(),checked:z.has(e._id),onCheckedChange:()=>Z(e._id)})}):null,n.map(t=>(0,M.jsx)(D,{className:t.className,children:t.cell(e)},t.header)),A?(0,M.jsx)(D,{children:t.length>0?(0,M.jsxs)(_,{children:[(0,M.jsx)(g,{asChild:!0,children:(0,M.jsx)(p,{variant:`ghost`,size:`icon-sm`,"aria-label":r(),className:`opacity-0 transition-opacity group-hover/row:opacity-100 group-focus-within/row:opacity-100 aria-expanded:opacity-100`,children:(0,M.jsx)(m,{})})}),(0,M.jsx)(v,{align:`end`,children:t.map((t,n)=>(0,M.jsxs)(`div`,{children:[t.variant===`destructive`&&n>0?(0,M.jsx)(h,{}):null,(0,M.jsx)(y,{variant:t.variant,onSelect:()=>t.onSelect(e),children:t.label})]},t.label))})]}):null}):null]}),i&&R?(0,M.jsx)(E,{className:`oc-dt__expansion`,children:(0,M.jsx)(D,{colSpan:q,className:`oc-dt__expansion-cell`,children:R(e)})}):null]},e._id)})})]})]})}export{N as t};
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{Gm as r,Jm as i,Km as a,Wm as o,Xm as s,Ym as c,qm as l}from"./api-BDOBe_HI.js";import{r as u}from"./dist-Ct8KdJzy.js";import{t as d}from"./chevron-up-CHvHESC0.js";import{t as f}from"./chevrons-up-down-DdxQzLW8.js";import{t as p}from"./button-BXoUycz-.js";import{En as m,It as h,Lt as g,Mt as _,Nt as v,Pt as y,in as b,ln as x,ut as S}from"./index-B0ufU8aN.js";import{a as C,i as w,n as T,o as E,r as D,t as O}from"./table-Ql8c7BIW.js";var k=t(e(),1);function A(e,t){return typeof e==`number`&&typeof t==`number`?e-t:typeof e==`boolean`&&typeof t==`boolean`?!!e-+!!t:String(e).localeCompare(String(t),void 0,{numeric:!0,sensitivity:`base`})}function j(e,t,n){return[...e].sort((e,r)=>{let i=t(e),a=t(r),o=i==null,s=a==null;if(o||s)return o&&s?0:o?1:-1;let c=A(i,a);return n===`asc`?c:-c})}var M=n();function N({title:e,rows:t,columns:n,rowActions:A,onAdd:N,addLabel:P=s(),bulkActions:F,emptyHint:I=c(),isExpanded:L,renderExpanded:R}){let[z,B]=(0,k.useState)(new Set),[V,H]=(0,k.useState)(null),U=t??[],W=V?n[V.index]:void 0,G=V&&W?.sort?j(U,W.sort,V.dir):U;function K(e){H(t=>!t||t.index!==e?{index:e,dir:`asc`}:t.dir===`asc`?{index:e,dir:`desc`}:null)}let q=+!!F+n.length+ +!!A,J=U.length>0&&z.size===U.length,Y=z.size>0&&!J;function X(){B(J?new Set:new Set(U.map(e=>e._id)))}function Z(e){B(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}return(0,M.jsxs)(`div`,{className:`oc-dt`,children:[(0,M.jsxs)(`div`,{className:`oc-dt__bar`,children:[(0,M.jsx)(`h2`,{className:`oc-dt__title`,children:e}),(0,M.jsxs)(`div`,{className:`oc-dt__bar-actions`,children:[z.size>0&&F?F.map(e=>(0,M.jsxs)(p,{size:`sm`,variant:e.variant===`destructive`?`destructive`:`outline`,onClick:()=>{e.onSelect([...z]),B(new Set)},children:[e.variant===`destructive`?(0,M.jsx)(b,{}):null,e.label,` (`,z.size,`)`]},e.label)):null,N?(0,M.jsxs)(p,{size:`sm`,onClick:N,children:[(0,M.jsx)(x,{}),` `,P]}):null]})]}),t===void 0?(0,M.jsx)(`p`,{className:`oc-admin__hint`,children:i()}):U.length===0?(0,M.jsx)(`p`,{className:`oc-admin__hint`,children:I}):(0,M.jsxs)(O,{children:[(0,M.jsx)(C,{children:(0,M.jsxs)(E,{children:[F?(0,M.jsx)(w,{className:`w-8`,children:(0,M.jsx)(S,{"aria-label":l(),checked:J?!0:Y?`indeterminate`:!1,onCheckedChange:X})}):null,n.map((e,t)=>{let n=V?.index===t;return e.sort?(0,M.jsx)(w,{className:e.className,"aria-sort":n?V.dir===`asc`?`ascending`:`descending`:`none`,children:(0,M.jsxs)(`button`,{type:`button`,className:`oc-dt__sort`,onClick:()=>K(t),"aria-label":o({column:e.header}),children:[e.header,n?V.dir===`asc`?(0,M.jsx)(d,{className:`oc-dt__sort-icon`,"aria-hidden":!0}):(0,M.jsx)(u,{className:`oc-dt__sort-icon`,"aria-hidden":!0}):(0,M.jsx)(f,{className:`oc-dt__sort-icon oc-dt__sort-icon--idle`,"aria-hidden":!0})]})},e.header):(0,M.jsx)(w,{className:e.className,children:e.header},e.header)}),A?(0,M.jsx)(w,{className:`w-8`}):null]})}),(0,M.jsx)(T,{children:G.map(e=>{let t=A?.(e)??[],i=L?.(e)??!1;return(0,M.jsxs)(k.Fragment,{children:[(0,M.jsxs)(E,{className:`group/row`,children:[F?(0,M.jsx)(D,{children:(0,M.jsx)(S,{"aria-label":a(),checked:z.has(e._id),onCheckedChange:()=>Z(e._id)})}):null,n.map(t=>(0,M.jsx)(D,{className:t.className,children:t.cell(e)},t.header)),A?(0,M.jsx)(D,{children:t.length>0?(0,M.jsxs)(_,{children:[(0,M.jsx)(g,{asChild:!0,children:(0,M.jsx)(p,{variant:`ghost`,size:`icon-sm`,"aria-label":r(),className:`opacity-0 transition-opacity group-hover/row:opacity-100 group-focus-within/row:opacity-100 aria-expanded:opacity-100`,children:(0,M.jsx)(m,{})})}),(0,M.jsx)(v,{align:`end`,children:t.map((t,n)=>(0,M.jsxs)(`div`,{children:[t.variant===`destructive`&&n>0?(0,M.jsx)(h,{}):null,(0,M.jsx)(y,{variant:t.variant,onSelect:()=>t.onSelect(e),children:t.label})]},t.label))})]}):null}):null]}),i&&R?(0,M.jsx)(E,{className:`oc-dt__expansion`,children:(0,M.jsx)(D,{colSpan:q,className:`oc-dt__expansion-cell`,children:R(e)})}):null]},e._id)})})]})]})}export{N as t};
@@ -1 +1 @@
1
- import{r as e}from"./bundle-mjs-C73ZY4La.js";import{Et as t}from"./index-DtAFZhtv.js";var n=e();function r({icon:e,total:r,items:i}){if(r===0)return(0,n.jsxs)(t,{variant:`outline`,className:`oc-group-chip oc-group-chip--empty gap-1`,children:[e,`0`]});let a=r-i.length;return(0,n.jsxs)(`div`,{className:`oc-group-detail`,children:[i.map((e,r)=>(0,n.jsxs)(t,{variant:e.highlight?`secondary`:`outline`,className:`oc-group-chip gap-1`,title:e.label,children:[e.marker,(0,n.jsx)(`span`,{className:`oc-group-chip__txt`,children:e.label})]},r)),a>0?(0,n.jsxs)(t,{variant:`outline`,className:`oc-group-chip`,children:[`+`,a]}):null]})}export{r as t};
1
+ import{r as e}from"./bundle-mjs-C73ZY4La.js";import{Et as t}from"./index-B0ufU8aN.js";var n=e();function r({icon:e,total:r,items:i}){if(r===0)return(0,n.jsxs)(t,{variant:`outline`,className:`oc-group-chip oc-group-chip--empty gap-1`,children:[e,`0`]});let a=r-i.length;return(0,n.jsxs)(`div`,{className:`oc-group-detail`,children:[i.map((e,r)=>(0,n.jsxs)(t,{variant:e.highlight?`secondary`:`outline`,className:`oc-group-chip gap-1`,title:e.label,children:[e.marker,(0,n.jsx)(`span`,{className:`oc-group-chip__txt`,children:e.label})]},r)),a>0?(0,n.jsxs)(t,{variant:`outline`,className:`oc-group-chip`,children:[`+`,a]}):null]})}export{r as t};
@@ -1 +1 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$E as r,AD as i,BD as a,CD as o,DD as s,ED as c,FD as l,GD as u,HD as d,ID as ee,JD as f,JE as p,KD as m,LD as h,MD as g,ND as _,OD as v,PD as te,QE as y,Qa as ne,RD as re,SD as ie,TD as ae,UD as b,VD as x,WD as S,XD as C,XE as w,Xa as T,YD as E,YE as D,ZE as O,_D as k,aD as A,az as j,bD as M,cD as N,dD as P,eD as F,fD as I,gD as L,hD as R,iD as z,iz as B,jD as V,kD as H,lD as U,mD as oe,nD as W,oD as G,pD as K,qD as q,rD as se,sD as ce,t as J,tD as le,uD as ue,vD as de,wD as fe,xD as pe,yD as me,zD as he}from"./api-BDOBe_HI.js";import{t as ge}from"./button-BXoUycz-.js";import{U as _e,ct as Y}from"./index-DtAFZhtv.js";import{t as ve}from"./DataTableShell-D2PIAVAw.js";var X=t(e(),1),Z=n(),ye={altered_words:()=>C(),incorrect:()=>E(),incoherence:()=>f(),formatting:()=>q(),latency:()=>m(),api_error:()=>u(),other:()=>S()},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:d()}):e===!1?(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill is-warn`,children:x()}):(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill`,children:`—`}):(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill`,children:b()})}function be({data:e,reference:t,closeReason:n}){let r=e.snapshot,u=B(J.feedback.respondToFeedback),[d,f]=(0,X.useState)(e.thread),[p,m]=(0,X.useState)(``),[y,b]=(0,X.useState)(!1);async function x(){let t=p.trim();if(!(!t||y)){b(!0);try{await u({feedbackId:e._id,text:t}),f(e=>[...e,{authorRole:`admin`,text:t,at:Date.now()}]),m(``)}finally{b(!1)}}}let S=[];try{S=r.contextJson?JSON.parse(r.contextJson):[]}catch{S=[]}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?` · ${a()}`:``,r.openclawModel?` · ${r.openclawModel}`:``,r.openclawRuntime?` (${r.openclawRuntime})`:``]}),t?(0,Z.jsx)(`code`,{className:`oc-fbadmin__ref`,style:{userSelect:`all`,marginLeft:`auto`},title:oe(),children:t}):null]}),e.comment?(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:he()}),(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:F()}),(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:re()}),d.length>0?(0,Z.jsx)(`div`,{className:`oc-fbadmin__thread`,children:d.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`?h():e.authorRole===`agent`?e.authorLabel??ne():ee()}),(0,Z.jsx)(`span`,{className:`oc-notif__msg-text`,children:e.text})]},t))}):(0,Z.jsx)(`p`,{className:`oc-fbadmin__meta`,children:l()}),(0,Z.jsx)(`textarea`,{className:`oc-feedback__textarea`,placeholder:te(),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 x(),disabled:!p.trim()||y,children:y?_():g()})})]}),(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:V()}),(0,Z.jsx)(`pre`,{className:`oc-msg__source-pre`,children:r.messageText||i()})]}),r.clientInfo?.sourceWasOpen&&r.displayedText!==void 0?(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:H()}),(0,Z.jsx)(`pre`,{className:`oc-msg__source-pre`,children:r.displayedText||i()})]}):null,r.promptText?(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:v()}),(0,Z.jsx)(`pre`,{className:`oc-msg__source-pre`,children:r.promptText})]}):null,S.length>0?(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:s({count:r.contextCount??S.length,truncated:r.contextTruncated?c():``})}),(0,Z.jsx)(`div`,{className:`oc-fbadmin__ctx`,children:S.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:ae()}),(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:fe()}),(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:o()}),(0,Z.jsxs)(`p`,{className:`oc-fbadmin__env`,children:[[r.clientInfo?.language,r.clientInfo?.timezone,r.clientInfo?.theme?ie({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:[pe(),` `,r.clientInfo.plugins.join(`, `),(0,Z.jsxs)(`span`,{className:`oc-fbadmin__note`,children:[` `,M()]})]}):null,r.clientInfo?.userAgent?(0,Z.jsx)(`span`,{className:`oc-fbadmin__ua`,children:r.clientInfo.userAgent}):null]})]})]})}function xe(){let e=j(J.feedback.listForAdmin,{}),t=B(J.feedback.readSnapshot),n=B(J.feedback.deleteFeedback),i=_e(),[a,o]=(0,X.useState)(null),[s,c]=(0,X.useState)({});async function l(e){if(a===e._id){o(null);return}if(!s[e._id]){let n=await t({feedbackId:e._id});c(t=>({...t,[e._id]:n}))}o(e._id)}async function u(e){await i({title:w(),description:D(),confirmLabel:p(),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:[me(),` `,(0,Z.jsx)(`strong`,{children:de()}),` `,k()]}),(0,Z.jsx)(ve,{title:L(),rows:e,emptyHint:R(),isExpanded:e=>a===e._id&&!!s[e._id],renderExpanded:e=>s[e._id]?(0,Z.jsx)(be,{data:s[e._id],reference:e.reference,closeReason:e.userCloseReason}):null,columns:[{header:K(),cell:e=>Y(e.at),sort:e=>e.at},{header:I(),cell:e=>Q(e.category),sort:e=>Q(e.category)},{header:P(),cell:e=>e.messageRole===`user`?ue():U(),sort:e=>e.messageRole},{header:N(),cell:e=>(e.reporterEmail||e.reporterName||`—`)+(e.impersonated&&e.realOperatorEmail?` ${ce({operator:e.realOperatorEmail})}`:``),sort:e=>e.reporterEmail||e.reporterName||null},{header:G(),cell:e=>(0,Z.jsx)($,{matches:e.displayedMatchesStored,sourceWasOpen:e.sourceWasOpen}),sort:e=>e.displayedMatchesStored===!1?0:e.displayedMatchesStored===!0?1:2},{header:A(),cell:e=>e.hasComment?`✎`:`—`,sort:e=>+!!e.hasComment},{header:z(),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:W()}):(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill is-ok`,title:e.resolvedBy??void 0,children:T()}):(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill is-closed`,children:le()}),sort:e=>e.userClosedAt==null?e.resolvedAt==null?+!!e.answered:2:3}],rowActions:e=>[{label:a===e._id?r():y(),onSelect:()=>void l(e)},{label:O(),onSelect:()=>void u(e),variant:`destructive`}]})]})}export{xe as FeedbacksTab};
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$E as r,AD as i,BD as a,CD as o,DD as s,ED as c,FD as l,GD as u,HD as d,ID as ee,JD as f,JE as p,KD as m,LD as h,MD as g,ND as _,OD as v,PD as te,QE as y,Qa as ne,RD as re,SD as ie,TD as ae,UD as b,VD as x,WD as S,XD as C,XE as w,Xa as T,YD as E,YE as D,ZE as O,_D as k,aD as A,az as j,bD as M,cD as N,dD as P,eD as F,fD as I,gD as L,hD as R,iD as z,iz as B,jD as V,kD as H,lD as U,mD as oe,nD as W,oD as G,pD as K,qD as q,rD as se,sD as ce,t as J,tD as le,uD as ue,vD as de,wD as fe,xD as pe,yD as me,zD as he}from"./api-BDOBe_HI.js";import{t as ge}from"./button-BXoUycz-.js";import{U as _e,ct as Y}from"./index-B0ufU8aN.js";import{t as ve}from"./DataTableShell-CFPC-1m0.js";var X=t(e(),1),Z=n(),ye={altered_words:()=>C(),incorrect:()=>E(),incoherence:()=>f(),formatting:()=>q(),latency:()=>m(),api_error:()=>u(),other:()=>S()},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:d()}):e===!1?(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill is-warn`,children:x()}):(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill`,children:`—`}):(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill`,children:b()})}function be({data:e,reference:t,closeReason:n}){let r=e.snapshot,u=B(J.feedback.respondToFeedback),[d,f]=(0,X.useState)(e.thread),[p,m]=(0,X.useState)(``),[y,b]=(0,X.useState)(!1);async function x(){let t=p.trim();if(!(!t||y)){b(!0);try{await u({feedbackId:e._id,text:t}),f(e=>[...e,{authorRole:`admin`,text:t,at:Date.now()}]),m(``)}finally{b(!1)}}}let S=[];try{S=r.contextJson?JSON.parse(r.contextJson):[]}catch{S=[]}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?` · ${a()}`:``,r.openclawModel?` · ${r.openclawModel}`:``,r.openclawRuntime?` (${r.openclawRuntime})`:``]}),t?(0,Z.jsx)(`code`,{className:`oc-fbadmin__ref`,style:{userSelect:`all`,marginLeft:`auto`},title:oe(),children:t}):null]}),e.comment?(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:he()}),(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:F()}),(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:re()}),d.length>0?(0,Z.jsx)(`div`,{className:`oc-fbadmin__thread`,children:d.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`?h():e.authorRole===`agent`?e.authorLabel??ne():ee()}),(0,Z.jsx)(`span`,{className:`oc-notif__msg-text`,children:e.text})]},t))}):(0,Z.jsx)(`p`,{className:`oc-fbadmin__meta`,children:l()}),(0,Z.jsx)(`textarea`,{className:`oc-feedback__textarea`,placeholder:te(),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 x(),disabled:!p.trim()||y,children:y?_():g()})})]}),(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:V()}),(0,Z.jsx)(`pre`,{className:`oc-msg__source-pre`,children:r.messageText||i()})]}),r.clientInfo?.sourceWasOpen&&r.displayedText!==void 0?(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:H()}),(0,Z.jsx)(`pre`,{className:`oc-msg__source-pre`,children:r.displayedText||i()})]}):null,r.promptText?(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:v()}),(0,Z.jsx)(`pre`,{className:`oc-msg__source-pre`,children:r.promptText})]}):null,S.length>0?(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:s({count:r.contextCount??S.length,truncated:r.contextTruncated?c():``})}),(0,Z.jsx)(`div`,{className:`oc-fbadmin__ctx`,children:S.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:ae()}),(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:fe()}),(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:o()}),(0,Z.jsxs)(`p`,{className:`oc-fbadmin__env`,children:[[r.clientInfo?.language,r.clientInfo?.timezone,r.clientInfo?.theme?ie({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:[pe(),` `,r.clientInfo.plugins.join(`, `),(0,Z.jsxs)(`span`,{className:`oc-fbadmin__note`,children:[` `,M()]})]}):null,r.clientInfo?.userAgent?(0,Z.jsx)(`span`,{className:`oc-fbadmin__ua`,children:r.clientInfo.userAgent}):null]})]})]})}function xe(){let e=j(J.feedback.listForAdmin,{}),t=B(J.feedback.readSnapshot),n=B(J.feedback.deleteFeedback),i=_e(),[a,o]=(0,X.useState)(null),[s,c]=(0,X.useState)({});async function l(e){if(a===e._id){o(null);return}if(!s[e._id]){let n=await t({feedbackId:e._id});c(t=>({...t,[e._id]:n}))}o(e._id)}async function u(e){await i({title:w(),description:D(),confirmLabel:p(),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:[me(),` `,(0,Z.jsx)(`strong`,{children:de()}),` `,k()]}),(0,Z.jsx)(ve,{title:L(),rows:e,emptyHint:R(),isExpanded:e=>a===e._id&&!!s[e._id],renderExpanded:e=>s[e._id]?(0,Z.jsx)(be,{data:s[e._id],reference:e.reference,closeReason:e.userCloseReason}):null,columns:[{header:K(),cell:e=>Y(e.at),sort:e=>e.at},{header:I(),cell:e=>Q(e.category),sort:e=>Q(e.category)},{header:P(),cell:e=>e.messageRole===`user`?ue():U(),sort:e=>e.messageRole},{header:N(),cell:e=>(e.reporterEmail||e.reporterName||`—`)+(e.impersonated&&e.realOperatorEmail?` ${ce({operator:e.realOperatorEmail})}`:``),sort:e=>e.reporterEmail||e.reporterName||null},{header:G(),cell:e=>(0,Z.jsx)($,{matches:e.displayedMatchesStored,sourceWasOpen:e.sourceWasOpen}),sort:e=>e.displayedMatchesStored===!1?0:e.displayedMatchesStored===!0?1:2},{header:A(),cell:e=>e.hasComment?`✎`:`—`,sort:e=>+!!e.hasComment},{header:z(),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:W()}):(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill is-ok`,title:e.resolvedBy??void 0,children:T()}):(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill is-closed`,children:le()}),sort:e=>e.userClosedAt==null?e.resolvedAt==null?+!!e.answered:2:3}],rowActions:e=>[{label:a===e._id?r():y(),onSelect:()=>void l(e)},{label:O(),onSelect:()=>void u(e),variant:`destructive`}]})]})}export{xe as FeedbacksTab};
@@ -1,4 +1,4 @@
1
- import{r as e}from"./bundle-mjs-C73ZY4La.js";import{D as t,fz as n}from"./api-BDOBe_HI.js";import{I as r,L as i,R as a,z as o}from"./index-DtAFZhtv.js";import"./locales-CPjguROj.js";import"./curation-CQksaIbm.js";var s=t(`circle-question-mark`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),c={media_delivery:{key:`media_delivery`,appliedIn:`bridge`,togglable:!0,placeholders:[`outboundDir`],defaultTemplate:{fr:`[LIVRAISON]
1
+ import{r as e}from"./bundle-mjs-C73ZY4La.js";import{D as t,fz as n}from"./api-BDOBe_HI.js";import{I as r,L as i,R as a,z as o}from"./index-B0ufU8aN.js";import"./locales-CPjguROj.js";import"./curation-CQksaIbm.js";var s=t(`circle-question-mark`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),c={media_delivery:{key:`media_delivery`,appliedIn:`bridge`,togglable:!0,placeholders:[`outboundDir`],defaultTemplate:{fr:`[LIVRAISON]
2
2
  Pour qu'un fichier que tu génères soit téléchargeable par l'utilisateur dans ce webchat : écris-le sous {outboundDir}/ puis ajoute, dans ta réponse finale, une ligne dédiée EXACTEMENT au format MEDIA:<chemin absolu du fichier>. N'utilise PAS de lien markdown vers un chemin local — il ne serait pas cliquable.`,en:`[DELIVERY]
3
3
  To make a file you generate downloadable by the user in this webchat: write it under {outboundDir}/ then add, in your final reply, a dedicated line EXACTLY in the format MEDIA:<absolute file path>. Do NOT use a markdown link to a local path — it would not be clickable.`}},documentary_fetch:{key:`documentary_fetch`,appliedIn:`convex`,togglable:!0,placeholders:[`references`],defaultTemplate:{fr:`Fournis les fichiers source téléchargeables correspondant EXACTEMENT à ces références de documents (un fichier par référence, nommé d'après la référence). Réponds uniquement avec les fichiers, sans commentaire :
4
4
  {references}`,en:`Provide the downloadable source files matching EXACTLY these document references (one file per reference, named after the reference). Reply only with the files, no commentary:
@@ -1 +1 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$L as r,BL as ee,GL as te,HL as ne,IL as re,JL as ie,KL as ae,LL as oe,QL as se,QR as i,RL as a,UL as o,VL as s,WL as c,XL as l,XR as u,YL as d,ZL as ce,_R as le,aR as f,az as ue,cR as de,dR as fe,eR as p,fR as pe,gR as me,hR as he,iR as m,iz as ge,lR as _e,mR as h,nR as g,nj as ve,no as _,oR as v,pR as y,qL as ye,rR as b,sR as x,t as S,tR as C,to as w,uR as T,zL as E}from"./api-BDOBe_HI.js";import{t as D}from"./button-BXoUycz-.js";import{$ as O,Ct as k,Dn as A,Dt as j,En as M,Et as N,Lt as P,Mt as be,Nt as xe,Pt as F,Q as I,St as Se,Tt as Ce,X as L,Z as R,bt as we,cn as Te,et as z,in as Ee,ut as De,vt as Oe,wt as ke,xt as Ae,yt as je}from"./index-DtAFZhtv.js";import{a as Me,i as B,n as Ne,o as V,r as H,t as Pe}from"./table-Ql8c7BIW.js";var U=t(e(),1),W=n(),G=`all`;function K(e){switch(e){case`image`:return v();case`audio`:return f();case`video`:return m();case`pdf`:return b();case`document`:return g();case`archive`:return C();default:return p()}}function q(){let[e,t]=(0,U.useState)(G),[n,f]=(0,U.useState)(G),[p,m]=(0,U.useState)(G),[g,v]=(0,U.useState)(G),[b,C]=(0,U.useState)(!1),[q,J]=(0,U.useState)(null),Fe=ge(S.files.softDelete),Y=j();function Ie(){t(G),f(G),m(G),v(G)}async function Le(){let e=q;if(J(null),e)try{await Fe({fileId:e.id}),Y.success(o())}catch(e){Y.error(ne(),e)}}let X=ue(S.files.listMine,{direction:e===G?void 0:e,chatId:n===G?void 0:n,instanceName:p===G?void 0:p,category:g===G?void 0:g,includeAutoGenerated:b||void 0}),Re=(0,U.useMemo)(()=>new Intl.DateTimeFormat(i(),{dateStyle:`medium`,timeStyle:`short`}),[]);if(X===void 0)return(0,W.jsx)(`p`,{className:`oc-admin__hint`,children:u()});let{files:Z,facets:Q,truncated:ze,cap:Be}=X,$=e!==G||n!==G||p!==G||g!==G;return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`p`,{className:`oc-admin__hint`,children:le()}),(0,W.jsxs)(`div`,{className:`oc-files__filters`,style:{display:`flex`,flexWrap:`wrap`,gap:8,margin:`12px 0`},children:[(0,W.jsxs)(L,{value:e,onValueChange:t,children:[(0,W.jsx)(O,{size:`sm`,"aria-label":me(),children:(0,W.jsx)(z,{})}),(0,W.jsxs)(R,{children:[(0,W.jsx)(I,{value:G,children:he()}),(0,W.jsx)(I,{value:`inbound`,children:h()}),(0,W.jsx)(I,{value:`outbound`,children:y()})]})]}),(0,W.jsxs)(L,{value:n,onValueChange:f,children:[(0,W.jsx)(O,{size:`sm`,"aria-label":pe(),children:(0,W.jsx)(z,{})}),(0,W.jsxs)(R,{children:[(0,W.jsx)(I,{value:G,children:fe()}),Q.chats.map(e=>(0,W.jsx)(I,{value:e.id,children:e.title},e.id))]})]}),Q.multiProvider?(0,W.jsxs)(L,{value:p,onValueChange:m,children:[(0,W.jsx)(O,{size:`sm`,"aria-label":T(),children:(0,W.jsx)(z,{})}),(0,W.jsxs)(R,{children:[(0,W.jsx)(I,{value:G,children:_e()}),Q.instances.map(e=>(0,W.jsx)(I,{value:e,children:e},e))]})]}):null,(0,W.jsxs)(L,{value:g,onValueChange:v,children:[(0,W.jsx)(O,{size:`sm`,"aria-label":de(),children:(0,W.jsx)(z,{})}),(0,W.jsxs)(R,{children:[(0,W.jsx)(I,{value:G,children:x()}),Q.categories.map(e=>(0,W.jsx)(I,{value:e,children:K(e)},e))]})]}),(0,W.jsxs)(`label`,{className:`oc-files__autogen`,children:[(0,W.jsx)(De,{checked:b,onCheckedChange:e=>C(e===!0),"aria-label":_()}),(0,W.jsx)(`span`,{children:_()})]}),$?(0,W.jsxs)(D,{variant:`ghost`,size:`sm`,onClick:Ie,style:{display:`inline-flex`,alignItems:`center`,gap:4,marginLeft:`auto`},children:[(0,W.jsx)(Te,{size:14,"aria-hidden":!0}),ae()]}):null]}),Z.length===0?(0,W.jsx)(`p`,{className:`oc-admin__hint`,children:$?oe():a()}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(Pe,{children:[(0,W.jsx)(Me,{children:(0,W.jsxs)(V,{children:[(0,W.jsx)(B,{children:r()}),(0,W.jsx)(B,{children:se()}),(0,W.jsx)(B,{children:ce()}),(0,W.jsx)(B,{children:l()}),(0,W.jsx)(B,{children:d()}),(0,W.jsx)(B,{className:`text-right`,children:ie()})]})}),(0,W.jsx)(Ne,{children:Z.map(e=>(0,W.jsxs)(V,{children:[(0,W.jsxs)(H,{className:`font-medium`,style:{maxWidth:280,overflow:`hidden`,textOverflow:`ellipsis`},title:e.filename,children:[e.filename,e.origin===`pasted`?(0,W.jsx)(N,{variant:`outline`,style:{marginLeft:6},children:w()}):null]}),(0,W.jsx)(H,{title:e.mimeType,children:K(e.category)}),(0,W.jsx)(H,{children:(0,W.jsx)(N,{variant:`secondary`,children:e.direction===`inbound`?h():y()})}),(0,W.jsx)(H,{style:{maxWidth:220,overflow:`hidden`,textOverflow:`ellipsis`},title:e.chatTitle,children:e.chatTitle}),(0,W.jsx)(H,{className:`whitespace-nowrap text-muted-foreground`,children:Re.format(e.createdAt)}),(0,W.jsx)(H,{className:`text-right`,children:(0,W.jsxs)(be,{children:[(0,W.jsx)(P,{asChild:!0,children:(0,W.jsx)(D,{variant:`ghost`,size:`icon`,"aria-label":te(),children:(0,W.jsx)(M,{size:16})})}),(0,W.jsxs)(xe,{align:`end`,children:[e.url?(0,W.jsx)(F,{asChild:!0,children:(0,W.jsxs)(`a`,{href:e.url,download:e.filename,target:`_blank`,rel:`noopener noreferrer`,children:[(0,W.jsx)(A,{size:14}),ye()]})}):(0,W.jsxs)(F,{disabled:!0,children:[(0,W.jsx)(A,{size:14}),E()]}),(0,W.jsxs)(F,{variant:`destructive`,onSelect:()=>J({id:e._id,filename:e.filename}),children:[(0,W.jsx)(Ee,{size:14}),c()]})]})]})})]},e._id))})]}),ze?(0,W.jsx)(`p`,{className:`oc-admin__hint`,style:{marginTop:8},children:re({cap:Be})}):null]}),(0,W.jsx)(Oe,{open:q!==null,onOpenChange:e=>!e&&J(null),children:(0,W.jsxs)(Ae,{children:[(0,W.jsxs)(ke,{children:[(0,W.jsx)(Ce,{children:s()}),(0,W.jsx)(Se,{children:ee()})]}),(0,W.jsxs)(k,{children:[(0,W.jsx)(we,{children:ve()}),(0,W.jsx)(je,{onClick:()=>void Le(),children:c()})]})]})})]})}export{q as FilesTab};
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$L as r,BL as ee,GL as te,HL as ne,IL as re,JL as ie,KL as ae,LL as oe,QL as se,QR as i,RL as a,UL as o,VL as s,WL as c,XL as l,XR as u,YL as d,ZL as ce,_R as le,aR as f,az as ue,cR as de,dR as fe,eR as p,fR as pe,gR as me,hR as he,iR as m,iz as ge,lR as _e,mR as h,nR as g,nj as ve,no as _,oR as v,pR as y,qL as ye,rR as b,sR as x,t as S,tR as C,to as w,uR as T,zL as E}from"./api-BDOBe_HI.js";import{t as D}from"./button-BXoUycz-.js";import{$ as O,Ct as k,Dn as A,Dt as j,En as M,Et as N,Lt as P,Mt as be,Nt as xe,Pt as F,Q as I,St as Se,Tt as Ce,X as L,Z as R,bt as we,cn as Te,et as z,in as Ee,ut as De,vt as Oe,wt as ke,xt as Ae,yt as je}from"./index-B0ufU8aN.js";import{a as Me,i as B,n as Ne,o as V,r as H,t as Pe}from"./table-Ql8c7BIW.js";var U=t(e(),1),W=n(),G=`all`;function K(e){switch(e){case`image`:return v();case`audio`:return f();case`video`:return m();case`pdf`:return b();case`document`:return g();case`archive`:return C();default:return p()}}function q(){let[e,t]=(0,U.useState)(G),[n,f]=(0,U.useState)(G),[p,m]=(0,U.useState)(G),[g,v]=(0,U.useState)(G),[b,C]=(0,U.useState)(!1),[q,J]=(0,U.useState)(null),Fe=ge(S.files.softDelete),Y=j();function Ie(){t(G),f(G),m(G),v(G)}async function Le(){let e=q;if(J(null),e)try{await Fe({fileId:e.id}),Y.success(o())}catch(e){Y.error(ne(),e)}}let X=ue(S.files.listMine,{direction:e===G?void 0:e,chatId:n===G?void 0:n,instanceName:p===G?void 0:p,category:g===G?void 0:g,includeAutoGenerated:b||void 0}),Re=(0,U.useMemo)(()=>new Intl.DateTimeFormat(i(),{dateStyle:`medium`,timeStyle:`short`}),[]);if(X===void 0)return(0,W.jsx)(`p`,{className:`oc-admin__hint`,children:u()});let{files:Z,facets:Q,truncated:ze,cap:Be}=X,$=e!==G||n!==G||p!==G||g!==G;return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`p`,{className:`oc-admin__hint`,children:le()}),(0,W.jsxs)(`div`,{className:`oc-files__filters`,style:{display:`flex`,flexWrap:`wrap`,gap:8,margin:`12px 0`},children:[(0,W.jsxs)(L,{value:e,onValueChange:t,children:[(0,W.jsx)(O,{size:`sm`,"aria-label":me(),children:(0,W.jsx)(z,{})}),(0,W.jsxs)(R,{children:[(0,W.jsx)(I,{value:G,children:he()}),(0,W.jsx)(I,{value:`inbound`,children:h()}),(0,W.jsx)(I,{value:`outbound`,children:y()})]})]}),(0,W.jsxs)(L,{value:n,onValueChange:f,children:[(0,W.jsx)(O,{size:`sm`,"aria-label":pe(),children:(0,W.jsx)(z,{})}),(0,W.jsxs)(R,{children:[(0,W.jsx)(I,{value:G,children:fe()}),Q.chats.map(e=>(0,W.jsx)(I,{value:e.id,children:e.title},e.id))]})]}),Q.multiProvider?(0,W.jsxs)(L,{value:p,onValueChange:m,children:[(0,W.jsx)(O,{size:`sm`,"aria-label":T(),children:(0,W.jsx)(z,{})}),(0,W.jsxs)(R,{children:[(0,W.jsx)(I,{value:G,children:_e()}),Q.instances.map(e=>(0,W.jsx)(I,{value:e,children:e},e))]})]}):null,(0,W.jsxs)(L,{value:g,onValueChange:v,children:[(0,W.jsx)(O,{size:`sm`,"aria-label":de(),children:(0,W.jsx)(z,{})}),(0,W.jsxs)(R,{children:[(0,W.jsx)(I,{value:G,children:x()}),Q.categories.map(e=>(0,W.jsx)(I,{value:e,children:K(e)},e))]})]}),(0,W.jsxs)(`label`,{className:`oc-files__autogen`,children:[(0,W.jsx)(De,{checked:b,onCheckedChange:e=>C(e===!0),"aria-label":_()}),(0,W.jsx)(`span`,{children:_()})]}),$?(0,W.jsxs)(D,{variant:`ghost`,size:`sm`,onClick:Ie,style:{display:`inline-flex`,alignItems:`center`,gap:4,marginLeft:`auto`},children:[(0,W.jsx)(Te,{size:14,"aria-hidden":!0}),ae()]}):null]}),Z.length===0?(0,W.jsx)(`p`,{className:`oc-admin__hint`,children:$?oe():a()}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(Pe,{children:[(0,W.jsx)(Me,{children:(0,W.jsxs)(V,{children:[(0,W.jsx)(B,{children:r()}),(0,W.jsx)(B,{children:se()}),(0,W.jsx)(B,{children:ce()}),(0,W.jsx)(B,{children:l()}),(0,W.jsx)(B,{children:d()}),(0,W.jsx)(B,{className:`text-right`,children:ie()})]})}),(0,W.jsx)(Ne,{children:Z.map(e=>(0,W.jsxs)(V,{children:[(0,W.jsxs)(H,{className:`font-medium`,style:{maxWidth:280,overflow:`hidden`,textOverflow:`ellipsis`},title:e.filename,children:[e.filename,e.origin===`pasted`?(0,W.jsx)(N,{variant:`outline`,style:{marginLeft:6},children:w()}):null]}),(0,W.jsx)(H,{title:e.mimeType,children:K(e.category)}),(0,W.jsx)(H,{children:(0,W.jsx)(N,{variant:`secondary`,children:e.direction===`inbound`?h():y()})}),(0,W.jsx)(H,{style:{maxWidth:220,overflow:`hidden`,textOverflow:`ellipsis`},title:e.chatTitle,children:e.chatTitle}),(0,W.jsx)(H,{className:`whitespace-nowrap text-muted-foreground`,children:Re.format(e.createdAt)}),(0,W.jsx)(H,{className:`text-right`,children:(0,W.jsxs)(be,{children:[(0,W.jsx)(P,{asChild:!0,children:(0,W.jsx)(D,{variant:`ghost`,size:`icon`,"aria-label":te(),children:(0,W.jsx)(M,{size:16})})}),(0,W.jsxs)(xe,{align:`end`,children:[e.url?(0,W.jsx)(F,{asChild:!0,children:(0,W.jsxs)(`a`,{href:e.url,download:e.filename,target:`_blank`,rel:`noopener noreferrer`,children:[(0,W.jsx)(A,{size:14}),ye()]})}):(0,W.jsxs)(F,{disabled:!0,children:[(0,W.jsx)(A,{size:14}),E()]}),(0,W.jsxs)(F,{variant:`destructive`,onSelect:()=>J({id:e._id,filename:e.filename}),children:[(0,W.jsx)(Ee,{size:14}),c()]})]})]})})]},e._id))})]}),ze?(0,W.jsx)(`p`,{className:`oc-admin__hint`,style:{marginTop:8},children:re({cap:Be})}):null]}),(0,W.jsx)(Oe,{open:q!==null,onOpenChange:e=>!e&&J(null),children:(0,W.jsxs)(Ae,{children:[(0,W.jsxs)(ke,{children:[(0,W.jsx)(Ce,{children:s()}),(0,W.jsx)(Se,{children:ee()})]}),(0,W.jsxs)(k,{children:[(0,W.jsx)(we,{children:ve()}),(0,W.jsx)(je,{onClick:()=>void Le(),children:c()})]})]})})]})}export{q as FilesTab};
@@ -1 +1 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{Qm as r,Zm as i}from"./api-BDOBe_HI.js";import{t as a}from"./button-BXoUycz-.js";import{cn as o,jt as s,sn as c}from"./index-DtAFZhtv.js";import{t as l}from"./TimeRangePicker-B-foA1-L.js";var u=t(e(),1),d=n(),f=250;function p({q:e,onQChange:t,searchPlaceholder:n=r(),children:p,timeRange:m,onTimeRangeChange:h,onReset:g,canReset:_=!0}){let[v,y]=(0,u.useState)(e);(0,u.useEffect)(()=>{y(e)},[e]);let b=(0,u.useRef)(null);function x(e){y(e),b.current!==null&&window.clearTimeout(b.current),b.current=window.setTimeout(()=>t(e),f)}(0,u.useEffect)(()=>()=>{b.current!==null&&window.clearTimeout(b.current)},[]);function S(){b.current!==null&&window.clearTimeout(b.current),g()}return(0,d.jsxs)(`div`,{className:`oc-filterbar`,children:[(0,d.jsxs)(`div`,{className:`oc-filterbar__search`,children:[(0,d.jsx)(c,{className:`oc-filterbar__search-icon`,"aria-hidden":!0}),(0,d.jsx)(s,{value:v,onChange:e=>x(e.target.value),placeholder:n,"aria-label":n})]}),p?(0,d.jsx)(`div`,{className:`oc-filterbar__quick`,children:p}):null,m&&h?(0,d.jsx)(l,{value:m,onChange:h}):null,(0,d.jsxs)(a,{variant:`ghost`,size:`sm`,className:`oc-filterbar__reset`,onClick:S,disabled:!_,children:[(0,d.jsx)(o,{}),i()]})]})}export{p as t};
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{Qm as r,Zm as i}from"./api-BDOBe_HI.js";import{t as a}from"./button-BXoUycz-.js";import{cn as o,jt as s,sn as c}from"./index-B0ufU8aN.js";import{t as l}from"./TimeRangePicker-4TbN0Xgb.js";var u=t(e(),1),d=n(),f=250;function p({q:e,onQChange:t,searchPlaceholder:n=r(),children:p,timeRange:m,onTimeRangeChange:h,onReset:g,canReset:_=!0}){let[v,y]=(0,u.useState)(e);(0,u.useEffect)(()=>{y(e)},[e]);let b=(0,u.useRef)(null);function x(e){y(e),b.current!==null&&window.clearTimeout(b.current),b.current=window.setTimeout(()=>t(e),f)}(0,u.useEffect)(()=>()=>{b.current!==null&&window.clearTimeout(b.current)},[]);function S(){b.current!==null&&window.clearTimeout(b.current),g()}return(0,d.jsxs)(`div`,{className:`oc-filterbar`,children:[(0,d.jsxs)(`div`,{className:`oc-filterbar__search`,children:[(0,d.jsx)(c,{className:`oc-filterbar__search-icon`,"aria-hidden":!0}),(0,d.jsx)(s,{value:v,onChange:e=>x(e.target.value),placeholder:n,"aria-label":n})]}),p?(0,d.jsx)(`div`,{className:`oc-filterbar__quick`,children:p}):null,m&&h?(0,d.jsx)(l,{value:m,onChange:h}):null,(0,d.jsxs)(a,{variant:`ghost`,size:`sm`,className:`oc-filterbar__reset`,onClick:S,disabled:!_,children:[(0,d.jsx)(o,{}),i()]})]})}export{p as t};
@@ -1 +1 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$d as r,$f as i,Af as a,Bf as o,Cf as s,D as c,Df as l,Ef as u,Ff as d,Gf as f,Hf as p,If as m,Jf as h,Kf as g,Lf as _,Mf as v,Nf as y,Of as b,Pf as x,Qd as S,Qf as ee,Rf as C,Sf as w,Tf as T,Uf as te,Vf as E,Wf as D,Xf as ne,Yf as O,Zd as k,Zf as re,_f as A,af as j,ap as M,az as N,bf as ie,cf as P,df as ae,ef as oe,ep as F,ff as se,gf as I,hf as ce,if as le,ip as ue,iz as L,jf as R,kf as de,lf as fe,mf as pe,nf as me,np as he,of as ge,op as _e,pf as ve,qf as ye,rf as be,rp as xe,sf as Se,t as z,tf as B,tp as Ce,uf as we,vf as Te,wf as Ee,xf as De,yf as Oe,zf as ke}from"./api-BDOBe_HI.js";import{t as Ae}from"./x-Bg1ECTqi.js";import{i as V,n as H,r as je,t as Me}from"./tabs-Nve_dRxd.js";import{t as U}from"./button-BXoUycz-.js";import{$ as Ne,Dt as W,Et as G,Mn as Pe,Q as Fe,U as Ie,X as Le,Z as Re,_ as ze,an as K,at as Be,et as Ve,jn as He,jt as q,nt as Ue,on as J,ot as We,q as Ge,rt as Ke,tt as qe,ut as Y}from"./index-DtAFZhtv.js";import{t as Je}from"./FilterBar-D99V_QOK.js";import{t as Ye}from"./DataTableShell-D2PIAVAw.js";import{t as X}from"./DetailChips-Z_U4y6U9.js";var Xe=c(`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=c(`shield-check`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),Ze=c(`users`,[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`path`,{d:`M16 3.128a4 4 0 0 1 0 7.744`,key:`16gr8j`}],[`path`,{d:`M22 21v-2a4 4 0 0 0-3-3.87`,key:`kshegd`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}]]),Q=t(e(),1);function Qe(e,t,n){let r=t.trim().toLowerCase();return[...r?e.filter(e=>[e.email,e.name,e.canonical].some(e=>e!=null&&e.toLowerCase().includes(r))):e.slice()].sort((e,t)=>!n.has(e.userId)-+!n.has(t.userId))}function $e(e,t){let n=e.filter(e=>e.source===`discovered`),r=t.trim().toLowerCase();return r?n.filter(e=>(e.displayName??e.agentId).toLowerCase().includes(r)||e.agentId.toLowerCase().includes(r)):n}function et(e){let t=e.name?.trim()??``,n=e.email?.trim()??``,r=e.canonical?.trim()||`u-${e.userId.slice(0,8)}`;return t?{primary:t,secondary:n||`@${r}`}:n?{primary:n,secondary:null}:{primary:`@${r}`,secondary:null}}function tt(e){switch(e){case`admin`:return l();case`user`:return u();case`pending`:return T();default:return e}}function nt(e,t){if(e.length===0)return`none`;let n=0;for(let r of e)t(r)&&n++;return n===0?`none`:n===e.length?`all`:`some`}function rt(e,t,n){let r=Math.max(1,Math.ceil(e.length/n)),i=Math.min(Math.max(1,Math.floor(t)),r),a=(i-1)*n;return{pageItems:e.slice(a,a+n),page:i,pageCount:r}}var $=n(),it={name:``,description:``};function at(){let e=N(z.groups.listGroups,{}),t=N(z.me.getMe,{host:Ge})?.role===`admin`,n=L(z.groups.createGroup),a=L(z.groups.updateGroup),s=L(z.groups.deleteGroup),c=Ie(),l=W(),[u,d]=(0,Q.useState)(!1),[m,_]=(0,Q.useState)(null),[v,y]=(0,Q.useState)(it),[b,x]=(0,Q.useState)(null),[S,C]=(0,Q.useState)(``),w=(0,Q.useMemo)(()=>{if(!e)return e;let t=S.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,S]);function T(){_(null),y(it),d(!0)}function k(e){_(e),y({name:e.name,description:e.description??``}),d(!0)}async function A(){try{m?await a({groupId:m._id,name:v.name,description:v.description}):await n({name:v.name,description:v.description||void 0}),y(it),_(null),d(!1)}catch(e){l.error(oe(),e)}}async function j(e){if(await c({title:E({name:e.name}),description:o(),confirmWord:e.name,confirmLabel:ke(),cancelLabel:ye(),destructive:!0}))try{await s({groupId:e._id})}catch(e){l.error(r(),e)}}return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{className:`oc-admin__hint`,children:M()}),(0,$.jsx)(Je,{q:S,onQChange:C,onReset:()=>C(``),canReset:S!==``,searchPlaceholder:ee()}),(0,$.jsx)(Ye,{title:_e(),rows:w,addLabel:ue(),onAdd:t?T:void 0,emptyHint:xe(),columns:[{header:he(),cell:e=>e.name,sort:e=>e.name},{header:Ce(),cell:e=>(0,$.jsx)(X,{icon:(0,$.jsx)(Ze,{size:12,"aria-hidden":!0}),total:e.memberCount,items:e.members.map(e=>({label:e.label,marker:e.manager?(0,$.jsx)(Z,{size:11,"aria-hidden":!0}):null,highlight:e.manager}))}),sort:e=>e.memberCount},{header:F(),cell:e=>(0,$.jsx)(X,{icon:(0,$.jsx)(J,{size:12,"aria-hidden":!0}),total:e.agentCount,items:e.agents.map(e=>({label:e}))}),sort:e=>e.agentCount},{header:i(),cell:e=>(0,$.jsx)(X,{icon:(0,$.jsx)(Xe,{size:12,"aria-hidden":!0}),total:e.chartCount,items:e.charts.map(e=>({label:e.name,marker:e.isDefault?(0,$.jsx)(K,{size:11,fill:`currentColor`,"aria-hidden":!0}):null,highlight:e.isDefault}))}),sort:e=>e.chartCount}],rowActions:e=>[{label:re(),onSelect:()=>x({groupId:e._id,name:e.name})},...t?[{label:ne(),onSelect:()=>k(e)},{label:O(),variant:`destructive`,onSelect:()=>void j(e)}]:[]]}),(0,$.jsx)(ze,{open:u,onOpenChange:d,title:m?f():g(),description:D(),canSubmit:!!v.name.trim(),onSubmit:A,submitLabel:h(),children:(0,$.jsxs)(`div`,{className:`oc-form`,children:[(0,$.jsxs)(`label`,{className:`oc-field`,children:[(0,$.jsx)(`span`,{className:`oc-field__label`,children:te()}),(0,$.jsx)(q,{value:v.name,onChange:e=>y({...v,name:e.target.value})})]}),(0,$.jsxs)(`label`,{className:`oc-field`,children:[(0,$.jsx)(`span`,{className:`oc-field__label`,children:p()}),(0,$.jsx)(q,{value:v.description,onChange:e=>y({...v,description:e.target.value})})]})]})}),(0,$.jsx)(ct,{groupId:b?.groupId??null,groupName:b?.name??``,open:b!==null,onOpenChange:e=>{e||x(null)}})]})}var ot=8;function st({page:e,pageCount:t,onPage:n}){return t<=1?null:(0,$.jsxs)(`div`,{className:`oc-access__pager`,children:[(0,$.jsxs)(U,{type:`button`,variant:`ghost`,size:`sm`,disabled:e<=1,onClick:()=>n(e-1),children:[(0,$.jsx)(Pe,{size:14,"aria-hidden":!0}),a()]}),(0,$.jsxs)(`span`,{className:`oc-access__pageinfo`,"aria-label":b({page:e,pages:t}),children:[e,` / `,t]}),(0,$.jsxs)(U,{type:`button`,variant:`ghost`,size:`sm`,disabled:e>=t,onClick:()=>n(e+1),children:[de(),(0,$.jsx)(He,{size:14,"aria-hidden":!0})]})]})}function ct({groupId:e,groupName:t,open:n,onOpenChange:r}){let i=N(z.groups.getGroup,n&&e?{groupId:e}:`skip`),a=N(z.groups.listAssignableInstances,n?{}:`skip`),o=N(z.groups.listAssignableUsers,n?{}:`skip`),s=L(z.groups.addMember),c=L(z.groups.removeMember),l=L(z.groups.bulkSetMembers),u=L(z.groups.setGroupManager),f=W(),[p,h]=(0,Q.useState)(``),[g,b]=(0,Q.useState)(``),[ee,T]=(0,Q.useState)(`members`),[te,E]=(0,Q.useState)(1),[D,ne]=(0,Q.useState)(new Set),O=(0,Q.useRef)(null),k=(0,Q.useMemo)(()=>new Set((i?.members??[]).map(e=>e.userId)),[i]),re=(0,Q.useMemo)(()=>new Set((i?.members??[]).filter(e=>e.manager).map(e=>e.userId)),[i]),A=i?.viewerIsAdmin===!0,M=(0,Q.useMemo)(()=>new Set((i?.agents??[]).map(e=>`${e.instanceName}/${e.agentId}`)),[i]);(0,Q.useEffect)(()=>{h(``),b(``),T(`members`),E(1),O.current=null},[n,e]),(0,Q.useEffect)(()=>{E(1)},[p]),(0,Q.useEffect)(()=>{n&&i&&e&&O.current!==e&&(O.current=e,ne(new Set((i.members??[]).map(e=>e.userId))))},[n,i,e]);let P=(0,Q.useMemo)(()=>o?Qe(o,p,D):[],[o,p,D]);async function ae(t,n){if(e)try{n?await c({groupId:e,userId:t}):await s({groupId:e,userId:t})}catch(e){f.error(S(),e)}}async function oe(t,n){if(e)try{await u({groupId:e,userId:t,manager:!n})}catch(e){f.error(me(),e)}}let F=nt(P,e=>k.has(e.userId)),se=P.filter(e=>k.has(e.userId)).length,I=rt(P,te,ot);async function ce(){if(!e||P.length===0)return;let t=P.map(e=>e.userId);try{await l({groupId:e,userIds:t,member:F!==`all`})}catch(e){f.error(S(),e)}}return(0,$.jsx)(qe,{open:n,onOpenChange:r,children:(0,$.jsxs)(Ue,{className:`oc-access`,children:[(0,$.jsxs)(Be,{children:[(0,$.jsx)(We,{children:C({name:t})}),(0,$.jsx)(Ke,{children:_()})]}),(0,$.jsxs)(Me,{value:ee,onValueChange:T,className:`oc-access__tabs`,children:[(0,$.jsxs)(je,{className:`w-full`,children:[(0,$.jsxs)(V,{value:`members`,className:`flex-1 gap-1.5`,children:[(0,$.jsx)(Ze,{size:13,"aria-hidden":!0}),m(),i?(0,$.jsx)(G,{variant:`secondary`,className:`oc-access__tabcount`,children:k.size}):null]}),(0,$.jsxs)(V,{value:`agents`,className:`flex-1 gap-1.5`,children:[(0,$.jsx)(J,{size:13,"aria-hidden":!0}),x(),i?(0,$.jsx)(G,{variant:`secondary`,className:`oc-access__tabcount`,children:M.size}):null]}),(0,$.jsxs)(V,{value:`charts`,className:`flex-1 gap-1.5`,children:[(0,$.jsx)(Xe,{size:13,"aria-hidden":!0}),ve(),i?(0,$.jsx)(G,{variant:`secondary`,className:`oc-access__tabcount`,children:i.chartCount}):null]})]}),(0,$.jsx)(H,{value:`members`,children:o===void 0||i===void 0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:w()}):o.length===0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:ie()}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(q,{value:p,onChange:e=>h(e.target.value),placeholder:d(),className:`oc-access__search`}),P.length===0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:v()}):(0,$.jsxs)($.Fragment,{children:[P.length>1?(0,$.jsxs)(`div`,{className:`oc-access__row oc-access__selectall`,children:[(0,$.jsx)(Y,{checked:F===`all`?!0:F===`some`?`indeterminate`:!1,onCheckedChange:()=>void ce(),"aria-label":R()}),(0,$.jsx)(`span`,{className:`oc-access__label`,children:R()}),(0,$.jsxs)(G,{variant:`outline`,className:`oc-access__count`,children:[se,` / `,P.length]})]}):null,(0,$.jsx)(`div`,{className:`oc-access__list`,children:I.pageItems.map(e=>{let t=k.has(e.userId),n=et(e),r=re.has(e.userId);return(0,$.jsxs)(`div`,{className:`oc-access__row`,children:[(0,$.jsx)(Y,{checked:t,onCheckedChange:()=>void ae(e.userId,t),"aria-label":Ee({user:n.primary})}),(0,$.jsxs)(`span`,{className:`oc-access__who`,children:[(0,$.jsx)(`span`,{className:`oc-access__label`,title:n.primary,children:n.primary}),n.secondary?(0,$.jsx)(`span`,{className:`oc-access__sub`,title:n.secondary,children:n.secondary}):null]}),(0,$.jsx)(G,{variant:`outline`,className:`oc-access__role`,children:tt(e.role)}),(0,$.jsx)(`span`,{className:`oc-access__mgrslot`,children:t&&A?(0,$.jsx)(U,{type:`button`,variant:`ghost`,size:`icon`,className:`shrink-0 oc-access__mgr${r?` oc-access__mgr--on`:``}`,"aria-pressed":r,"aria-label":r?be():le(),title:r?be():le(),onClick:()=>void oe(e.userId,r),children:(0,$.jsx)(Z,{size:15,"aria-hidden":!0})}):t&&r?(0,$.jsx)(`span`,{className:`oc-access__mgr oc-access__mgr--on`,role:`img`,"aria-label":j(),title:j(),children:(0,$.jsx)(Z,{size:15,"aria-hidden":!0})}):null})]},e._id)})}),(0,$.jsx)(st,{page:I.page,pageCount:I.pageCount,onPage:E})]})]})}),(0,$.jsx)(H,{value:`agents`,children:a===void 0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:w()}):a.length===0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:Oe()}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(q,{value:g,onChange:e=>b(e.target.value),placeholder:y(),className:`oc-access__search`}),(0,$.jsx)(`div`,{className:`oc-access__list`,children:a.map(t=>(0,$.jsx)(lt,{groupId:e,instanceName:t.name,kind:t.kind??`openclaw`,assigned:M,query:g},`${e}-${t._id}`))})]})}),(0,$.jsx)(H,{value:`charts`,children:(0,$.jsx)(ut,{groupId:e})})]})]})})}function lt({groupId:e,instanceName:t,kind:n,assigned:r,query:i}){let a=N(z.groups.listAssignableAgents,{instanceName:t}),o=L(z.groups.assignAgentToGroup),c=L(z.groups.removeAgentFromGroup),l=L(z.groups.bulkSetGroupAgents),u=W(),[d,f]=(0,Q.useState)(1);if((0,Q.useEffect)(()=>{f(1)},[i]),!e)return null;let p=$e(a?.agents??[],i),m=a?.discovery&&!a.discovery.lastPollOk;if(i.trim()&&p.length===0)return null;let h=p.filter(e=>e.presentInLastOk!==!1&&e.enabled!==!1),g=nt(h,e=>r.has(`${t}/${e.agentId}`)),_=rt(p,d,ot);async function v(n,r){try{r?await c({groupId:e,instanceName:t,agentId:n}):await o({groupId:e,instanceName:t,agentId:n})}catch(e){u.error(k(),e)}}async function y(){if(h.length===0)return;let n=h.map(e=>e.agentId);try{await l({groupId:e,instanceName:t,agentIds:n,assigned:g!==`all`})}catch(e){u.error(k(),e)}}return(0,$.jsxs)(`div`,{className:`oc-access__group`,children:[(0,$.jsxs)(`div`,{className:`oc-access__instance`,children:[(0,$.jsx)(J,{size:13,"aria-hidden":!0}),(0,$.jsx)(`span`,{children:t}),(0,$.jsx)(G,{variant:`outline`,className:`oc-access__kind`,children:n}),m?(0,$.jsx)(G,{variant:`outline`,className:`oc-access__stale`,children:I()}):null]}),a===void 0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:De()}):p.length===0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:m?A():Te()}):(0,$.jsxs)($.Fragment,{children:[h.length>1?(0,$.jsxs)(`div`,{className:`oc-access__row oc-access__selectall`,children:[(0,$.jsx)(Y,{checked:g===`all`?!0:g===`some`?`indeterminate`:!1,onCheckedChange:()=>void y(),"aria-label":R()}),(0,$.jsx)(`span`,{className:`oc-access__label`,children:R()})]}):null,_.pageItems.map(e=>{let n=`${t}/${e.agentId}`,i=r.has(n),a=e.presentInLastOk===!1,o=!e.enabled;return(0,$.jsxs)(`div`,{className:`oc-access__row${o?` is-disabled`:``}`,children:[(0,$.jsx)(Y,{checked:i,disabled:(a||o)&&!i,onCheckedChange:()=>void v(e.agentId,i),"aria-label":s({name:e.displayName??e.agentId})}),(0,$.jsxs)(`span`,{className:`oc-access__label`,title:e.displayName??e.agentId,children:[e.emoji?`${e.emoji} `:``,e.displayName??e.agentId]}),e.model?(0,$.jsx)(`span`,{className:`oc-access__model`,children:e.model}):null,e.isDefaultOnInstance?(0,$.jsx)(`span`,{className:`oc-access__fav`,role:`img`,"aria-label":pe(),title:pe(),children:(0,$.jsx)(K,{size:14,fill:`currentColor`})}):null,a?(0,$.jsx)(G,{variant:`outline`,className:`oc-access__gone`,children:ce()}):null]},e.agentId)}),(0,$.jsx)(st,{page:_.page,pageCount:_.pageCount,onPage:f})]})]})}function ut({groupId:e}){let t=N(z.charts.listGroupChartSelection,e?{groupId:e}:`skip`),n=L(z.charts.assignChartToGroup),r=L(z.charts.removeChartFromGroup),i=L(z.charts.setGroupDefaultChart),a=L(z.charts.addChartToGroupPool),o=L(z.charts.removeChartFromGroupPool),s=W();if(!e)return null;if(t===void 0)return(0,$.jsx)(`p`,{className:`oc-access__hint`,children:w()});let{pool:c,addable:l,canManagePool:u}=t;if(c.length===0&&!u)return(0,$.jsx)(`p`,{className:`oc-access__hint`,children:se()});async function d(t,i){try{i?await r({groupId:e,chartKey:t}):await n({groupId:e,chartKey:t})}catch(e){s.error(B(),e)}}async function f(t){try{await i({groupId:e,chartKey:t})}catch(e){s.error(B(),e)}}async function p(t){try{await a({groupId:e,chartKey:t})}catch(e){s.error(B(),e)}}async function m(t){try{await o({groupId:e,chartKey:t})}catch(e){s.error(B(),e)}}return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`oc-access__list`,children:c.map(e=>(0,$.jsxs)(`div`,{className:`oc-access__row`,children:[(0,$.jsx)(Y,{checked:e.selected,onCheckedChange:()=>void d(e.chartKey,e.selected),"aria-label":P({name:e.name})}),(0,$.jsx)(`span`,{className:`oc-access__label`,title:e.name,children:e.name}),e.selected?e.isDefault?(0,$.jsx)(`span`,{className:`oc-access__fav`,role:`img`,"aria-label":Se(),title:Se(),children:(0,$.jsx)(K,{size:14,fill:`currentColor`})}):(0,$.jsx)(U,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>void f(e.chartKey),children:ge()}):null,u?(0,$.jsx)(U,{type:`button`,variant:`ghost`,size:`sm`,"aria-label":fe({name:e.name}),title:fe({name:e.name}),onClick:()=>void m(e.chartKey),children:(0,$.jsx)(Ae,{size:14,"aria-hidden":!0})}):null]},e.chartKey))}),u?l.length>0?(0,$.jsxs)(Le,{value:``,onValueChange:e=>void p(e),children:[(0,$.jsx)(Ne,{size:`sm`,className:`oc-access__search`,children:(0,$.jsx)(Ve,{placeholder:we()})}),(0,$.jsx)(Re,{children:l.map(e=>(0,$.jsx)(Fe,{value:e.chartKey,children:e.name},e.chartKey))})]}):c.length===0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:ae()}):null:null]})}export{at as GroupsTab};
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$d as r,$f as i,Af as a,Bf as o,Cf as s,D as c,Df as l,Ef as u,Ff as d,Gf as f,Hf as p,If as m,Jf as h,Kf as g,Lf as _,Mf as v,Nf as y,Of as b,Pf as x,Qd as S,Qf as ee,Rf as C,Sf as w,Tf as T,Uf as te,Vf as E,Wf as D,Xf as ne,Yf as O,Zd as k,Zf as re,_f as A,af as j,ap as M,az as N,bf as ie,cf as P,df as ae,ef as oe,ep as F,ff as se,gf as I,hf as ce,if as le,ip as ue,iz as L,jf as R,kf as de,lf as fe,mf as pe,nf as me,np as he,of as ge,op as _e,pf as ve,qf as ye,rf as be,rp as xe,sf as Se,t as z,tf as B,tp as Ce,uf as we,vf as Te,wf as Ee,xf as De,yf as Oe,zf as ke}from"./api-BDOBe_HI.js";import{t as Ae}from"./x-Bg1ECTqi.js";import{i as V,n as H,r as je,t as Me}from"./tabs-DbSY71M_.js";import{t as U}from"./button-BXoUycz-.js";import{$ as Ne,Dt as W,Et as G,Mn as Pe,Q as Fe,U as Ie,X as Le,Z as Re,_ as ze,an as K,at as Be,et as Ve,jn as He,jt as q,nt as Ue,on as J,ot as We,q as Ge,rt as Ke,tt as qe,ut as Y}from"./index-B0ufU8aN.js";import{t as Je}from"./FilterBar-DqZs9qry.js";import{t as Ye}from"./DataTableShell-CFPC-1m0.js";import{t as X}from"./DetailChips-BzlFlRnK.js";var Xe=c(`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=c(`shield-check`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),Ze=c(`users`,[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`path`,{d:`M16 3.128a4 4 0 0 1 0 7.744`,key:`16gr8j`}],[`path`,{d:`M22 21v-2a4 4 0 0 0-3-3.87`,key:`kshegd`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}]]),Q=t(e(),1);function Qe(e,t,n){let r=t.trim().toLowerCase();return[...r?e.filter(e=>[e.email,e.name,e.canonical].some(e=>e!=null&&e.toLowerCase().includes(r))):e.slice()].sort((e,t)=>!n.has(e.userId)-+!n.has(t.userId))}function $e(e,t){let n=e.filter(e=>e.source===`discovered`),r=t.trim().toLowerCase();return r?n.filter(e=>(e.displayName??e.agentId).toLowerCase().includes(r)||e.agentId.toLowerCase().includes(r)):n}function et(e){let t=e.name?.trim()??``,n=e.email?.trim()??``,r=e.canonical?.trim()||`u-${e.userId.slice(0,8)}`;return t?{primary:t,secondary:n||`@${r}`}:n?{primary:n,secondary:null}:{primary:`@${r}`,secondary:null}}function tt(e){switch(e){case`admin`:return l();case`user`:return u();case`pending`:return T();default:return e}}function nt(e,t){if(e.length===0)return`none`;let n=0;for(let r of e)t(r)&&n++;return n===0?`none`:n===e.length?`all`:`some`}function rt(e,t,n){let r=Math.max(1,Math.ceil(e.length/n)),i=Math.min(Math.max(1,Math.floor(t)),r),a=(i-1)*n;return{pageItems:e.slice(a,a+n),page:i,pageCount:r}}var $=n(),it={name:``,description:``};function at(){let e=N(z.groups.listGroups,{}),t=N(z.me.getMe,{host:Ge})?.role===`admin`,n=L(z.groups.createGroup),a=L(z.groups.updateGroup),s=L(z.groups.deleteGroup),c=Ie(),l=W(),[u,d]=(0,Q.useState)(!1),[m,_]=(0,Q.useState)(null),[v,y]=(0,Q.useState)(it),[b,x]=(0,Q.useState)(null),[S,C]=(0,Q.useState)(``),w=(0,Q.useMemo)(()=>{if(!e)return e;let t=S.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,S]);function T(){_(null),y(it),d(!0)}function k(e){_(e),y({name:e.name,description:e.description??``}),d(!0)}async function A(){try{m?await a({groupId:m._id,name:v.name,description:v.description}):await n({name:v.name,description:v.description||void 0}),y(it),_(null),d(!1)}catch(e){l.error(oe(),e)}}async function j(e){if(await c({title:E({name:e.name}),description:o(),confirmWord:e.name,confirmLabel:ke(),cancelLabel:ye(),destructive:!0}))try{await s({groupId:e._id})}catch(e){l.error(r(),e)}}return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{className:`oc-admin__hint`,children:M()}),(0,$.jsx)(Je,{q:S,onQChange:C,onReset:()=>C(``),canReset:S!==``,searchPlaceholder:ee()}),(0,$.jsx)(Ye,{title:_e(),rows:w,addLabel:ue(),onAdd:t?T:void 0,emptyHint:xe(),columns:[{header:he(),cell:e=>e.name,sort:e=>e.name},{header:Ce(),cell:e=>(0,$.jsx)(X,{icon:(0,$.jsx)(Ze,{size:12,"aria-hidden":!0}),total:e.memberCount,items:e.members.map(e=>({label:e.label,marker:e.manager?(0,$.jsx)(Z,{size:11,"aria-hidden":!0}):null,highlight:e.manager}))}),sort:e=>e.memberCount},{header:F(),cell:e=>(0,$.jsx)(X,{icon:(0,$.jsx)(J,{size:12,"aria-hidden":!0}),total:e.agentCount,items:e.agents.map(e=>({label:e}))}),sort:e=>e.agentCount},{header:i(),cell:e=>(0,$.jsx)(X,{icon:(0,$.jsx)(Xe,{size:12,"aria-hidden":!0}),total:e.chartCount,items:e.charts.map(e=>({label:e.name,marker:e.isDefault?(0,$.jsx)(K,{size:11,fill:`currentColor`,"aria-hidden":!0}):null,highlight:e.isDefault}))}),sort:e=>e.chartCount}],rowActions:e=>[{label:re(),onSelect:()=>x({groupId:e._id,name:e.name})},...t?[{label:ne(),onSelect:()=>k(e)},{label:O(),variant:`destructive`,onSelect:()=>void j(e)}]:[]]}),(0,$.jsx)(ze,{open:u,onOpenChange:d,title:m?f():g(),description:D(),canSubmit:!!v.name.trim(),onSubmit:A,submitLabel:h(),children:(0,$.jsxs)(`div`,{className:`oc-form`,children:[(0,$.jsxs)(`label`,{className:`oc-field`,children:[(0,$.jsx)(`span`,{className:`oc-field__label`,children:te()}),(0,$.jsx)(q,{value:v.name,onChange:e=>y({...v,name:e.target.value})})]}),(0,$.jsxs)(`label`,{className:`oc-field`,children:[(0,$.jsx)(`span`,{className:`oc-field__label`,children:p()}),(0,$.jsx)(q,{value:v.description,onChange:e=>y({...v,description:e.target.value})})]})]})}),(0,$.jsx)(ct,{groupId:b?.groupId??null,groupName:b?.name??``,open:b!==null,onOpenChange:e=>{e||x(null)}})]})}var ot=8;function st({page:e,pageCount:t,onPage:n}){return t<=1?null:(0,$.jsxs)(`div`,{className:`oc-access__pager`,children:[(0,$.jsxs)(U,{type:`button`,variant:`ghost`,size:`sm`,disabled:e<=1,onClick:()=>n(e-1),children:[(0,$.jsx)(Pe,{size:14,"aria-hidden":!0}),a()]}),(0,$.jsxs)(`span`,{className:`oc-access__pageinfo`,"aria-label":b({page:e,pages:t}),children:[e,` / `,t]}),(0,$.jsxs)(U,{type:`button`,variant:`ghost`,size:`sm`,disabled:e>=t,onClick:()=>n(e+1),children:[de(),(0,$.jsx)(He,{size:14,"aria-hidden":!0})]})]})}function ct({groupId:e,groupName:t,open:n,onOpenChange:r}){let i=N(z.groups.getGroup,n&&e?{groupId:e}:`skip`),a=N(z.groups.listAssignableInstances,n?{}:`skip`),o=N(z.groups.listAssignableUsers,n?{}:`skip`),s=L(z.groups.addMember),c=L(z.groups.removeMember),l=L(z.groups.bulkSetMembers),u=L(z.groups.setGroupManager),f=W(),[p,h]=(0,Q.useState)(``),[g,b]=(0,Q.useState)(``),[ee,T]=(0,Q.useState)(`members`),[te,E]=(0,Q.useState)(1),[D,ne]=(0,Q.useState)(new Set),O=(0,Q.useRef)(null),k=(0,Q.useMemo)(()=>new Set((i?.members??[]).map(e=>e.userId)),[i]),re=(0,Q.useMemo)(()=>new Set((i?.members??[]).filter(e=>e.manager).map(e=>e.userId)),[i]),A=i?.viewerIsAdmin===!0,M=(0,Q.useMemo)(()=>new Set((i?.agents??[]).map(e=>`${e.instanceName}/${e.agentId}`)),[i]);(0,Q.useEffect)(()=>{h(``),b(``),T(`members`),E(1),O.current=null},[n,e]),(0,Q.useEffect)(()=>{E(1)},[p]),(0,Q.useEffect)(()=>{n&&i&&e&&O.current!==e&&(O.current=e,ne(new Set((i.members??[]).map(e=>e.userId))))},[n,i,e]);let P=(0,Q.useMemo)(()=>o?Qe(o,p,D):[],[o,p,D]);async function ae(t,n){if(e)try{n?await c({groupId:e,userId:t}):await s({groupId:e,userId:t})}catch(e){f.error(S(),e)}}async function oe(t,n){if(e)try{await u({groupId:e,userId:t,manager:!n})}catch(e){f.error(me(),e)}}let F=nt(P,e=>k.has(e.userId)),se=P.filter(e=>k.has(e.userId)).length,I=rt(P,te,ot);async function ce(){if(!e||P.length===0)return;let t=P.map(e=>e.userId);try{await l({groupId:e,userIds:t,member:F!==`all`})}catch(e){f.error(S(),e)}}return(0,$.jsx)(qe,{open:n,onOpenChange:r,children:(0,$.jsxs)(Ue,{className:`oc-access`,children:[(0,$.jsxs)(Be,{children:[(0,$.jsx)(We,{children:C({name:t})}),(0,$.jsx)(Ke,{children:_()})]}),(0,$.jsxs)(Me,{value:ee,onValueChange:T,className:`oc-access__tabs`,children:[(0,$.jsxs)(je,{className:`w-full`,children:[(0,$.jsxs)(V,{value:`members`,className:`flex-1 gap-1.5`,children:[(0,$.jsx)(Ze,{size:13,"aria-hidden":!0}),m(),i?(0,$.jsx)(G,{variant:`secondary`,className:`oc-access__tabcount`,children:k.size}):null]}),(0,$.jsxs)(V,{value:`agents`,className:`flex-1 gap-1.5`,children:[(0,$.jsx)(J,{size:13,"aria-hidden":!0}),x(),i?(0,$.jsx)(G,{variant:`secondary`,className:`oc-access__tabcount`,children:M.size}):null]}),(0,$.jsxs)(V,{value:`charts`,className:`flex-1 gap-1.5`,children:[(0,$.jsx)(Xe,{size:13,"aria-hidden":!0}),ve(),i?(0,$.jsx)(G,{variant:`secondary`,className:`oc-access__tabcount`,children:i.chartCount}):null]})]}),(0,$.jsx)(H,{value:`members`,children:o===void 0||i===void 0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:w()}):o.length===0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:ie()}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(q,{value:p,onChange:e=>h(e.target.value),placeholder:d(),className:`oc-access__search`}),P.length===0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:v()}):(0,$.jsxs)($.Fragment,{children:[P.length>1?(0,$.jsxs)(`div`,{className:`oc-access__row oc-access__selectall`,children:[(0,$.jsx)(Y,{checked:F===`all`?!0:F===`some`?`indeterminate`:!1,onCheckedChange:()=>void ce(),"aria-label":R()}),(0,$.jsx)(`span`,{className:`oc-access__label`,children:R()}),(0,$.jsxs)(G,{variant:`outline`,className:`oc-access__count`,children:[se,` / `,P.length]})]}):null,(0,$.jsx)(`div`,{className:`oc-access__list`,children:I.pageItems.map(e=>{let t=k.has(e.userId),n=et(e),r=re.has(e.userId);return(0,$.jsxs)(`div`,{className:`oc-access__row`,children:[(0,$.jsx)(Y,{checked:t,onCheckedChange:()=>void ae(e.userId,t),"aria-label":Ee({user:n.primary})}),(0,$.jsxs)(`span`,{className:`oc-access__who`,children:[(0,$.jsx)(`span`,{className:`oc-access__label`,title:n.primary,children:n.primary}),n.secondary?(0,$.jsx)(`span`,{className:`oc-access__sub`,title:n.secondary,children:n.secondary}):null]}),(0,$.jsx)(G,{variant:`outline`,className:`oc-access__role`,children:tt(e.role)}),(0,$.jsx)(`span`,{className:`oc-access__mgrslot`,children:t&&A?(0,$.jsx)(U,{type:`button`,variant:`ghost`,size:`icon`,className:`shrink-0 oc-access__mgr${r?` oc-access__mgr--on`:``}`,"aria-pressed":r,"aria-label":r?be():le(),title:r?be():le(),onClick:()=>void oe(e.userId,r),children:(0,$.jsx)(Z,{size:15,"aria-hidden":!0})}):t&&r?(0,$.jsx)(`span`,{className:`oc-access__mgr oc-access__mgr--on`,role:`img`,"aria-label":j(),title:j(),children:(0,$.jsx)(Z,{size:15,"aria-hidden":!0})}):null})]},e._id)})}),(0,$.jsx)(st,{page:I.page,pageCount:I.pageCount,onPage:E})]})]})}),(0,$.jsx)(H,{value:`agents`,children:a===void 0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:w()}):a.length===0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:Oe()}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(q,{value:g,onChange:e=>b(e.target.value),placeholder:y(),className:`oc-access__search`}),(0,$.jsx)(`div`,{className:`oc-access__list`,children:a.map(t=>(0,$.jsx)(lt,{groupId:e,instanceName:t.name,kind:t.kind??`openclaw`,assigned:M,query:g},`${e}-${t._id}`))})]})}),(0,$.jsx)(H,{value:`charts`,children:(0,$.jsx)(ut,{groupId:e})})]})]})})}function lt({groupId:e,instanceName:t,kind:n,assigned:r,query:i}){let a=N(z.groups.listAssignableAgents,{instanceName:t}),o=L(z.groups.assignAgentToGroup),c=L(z.groups.removeAgentFromGroup),l=L(z.groups.bulkSetGroupAgents),u=W(),[d,f]=(0,Q.useState)(1);if((0,Q.useEffect)(()=>{f(1)},[i]),!e)return null;let p=$e(a?.agents??[],i),m=a?.discovery&&!a.discovery.lastPollOk;if(i.trim()&&p.length===0)return null;let h=p.filter(e=>e.presentInLastOk!==!1&&e.enabled!==!1),g=nt(h,e=>r.has(`${t}/${e.agentId}`)),_=rt(p,d,ot);async function v(n,r){try{r?await c({groupId:e,instanceName:t,agentId:n}):await o({groupId:e,instanceName:t,agentId:n})}catch(e){u.error(k(),e)}}async function y(){if(h.length===0)return;let n=h.map(e=>e.agentId);try{await l({groupId:e,instanceName:t,agentIds:n,assigned:g!==`all`})}catch(e){u.error(k(),e)}}return(0,$.jsxs)(`div`,{className:`oc-access__group`,children:[(0,$.jsxs)(`div`,{className:`oc-access__instance`,children:[(0,$.jsx)(J,{size:13,"aria-hidden":!0}),(0,$.jsx)(`span`,{children:t}),(0,$.jsx)(G,{variant:`outline`,className:`oc-access__kind`,children:n}),m?(0,$.jsx)(G,{variant:`outline`,className:`oc-access__stale`,children:I()}):null]}),a===void 0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:De()}):p.length===0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:m?A():Te()}):(0,$.jsxs)($.Fragment,{children:[h.length>1?(0,$.jsxs)(`div`,{className:`oc-access__row oc-access__selectall`,children:[(0,$.jsx)(Y,{checked:g===`all`?!0:g===`some`?`indeterminate`:!1,onCheckedChange:()=>void y(),"aria-label":R()}),(0,$.jsx)(`span`,{className:`oc-access__label`,children:R()})]}):null,_.pageItems.map(e=>{let n=`${t}/${e.agentId}`,i=r.has(n),a=e.presentInLastOk===!1,o=!e.enabled;return(0,$.jsxs)(`div`,{className:`oc-access__row${o?` is-disabled`:``}`,children:[(0,$.jsx)(Y,{checked:i,disabled:(a||o)&&!i,onCheckedChange:()=>void v(e.agentId,i),"aria-label":s({name:e.displayName??e.agentId})}),(0,$.jsxs)(`span`,{className:`oc-access__label`,title:e.displayName??e.agentId,children:[e.emoji?`${e.emoji} `:``,e.displayName??e.agentId]}),e.model?(0,$.jsx)(`span`,{className:`oc-access__model`,children:e.model}):null,e.isDefaultOnInstance?(0,$.jsx)(`span`,{className:`oc-access__fav`,role:`img`,"aria-label":pe(),title:pe(),children:(0,$.jsx)(K,{size:14,fill:`currentColor`})}):null,a?(0,$.jsx)(G,{variant:`outline`,className:`oc-access__gone`,children:ce()}):null]},e.agentId)}),(0,$.jsx)(st,{page:_.page,pageCount:_.pageCount,onPage:f})]})]})}function ut({groupId:e}){let t=N(z.charts.listGroupChartSelection,e?{groupId:e}:`skip`),n=L(z.charts.assignChartToGroup),r=L(z.charts.removeChartFromGroup),i=L(z.charts.setGroupDefaultChart),a=L(z.charts.addChartToGroupPool),o=L(z.charts.removeChartFromGroupPool),s=W();if(!e)return null;if(t===void 0)return(0,$.jsx)(`p`,{className:`oc-access__hint`,children:w()});let{pool:c,addable:l,canManagePool:u}=t;if(c.length===0&&!u)return(0,$.jsx)(`p`,{className:`oc-access__hint`,children:se()});async function d(t,i){try{i?await r({groupId:e,chartKey:t}):await n({groupId:e,chartKey:t})}catch(e){s.error(B(),e)}}async function f(t){try{await i({groupId:e,chartKey:t})}catch(e){s.error(B(),e)}}async function p(t){try{await a({groupId:e,chartKey:t})}catch(e){s.error(B(),e)}}async function m(t){try{await o({groupId:e,chartKey:t})}catch(e){s.error(B(),e)}}return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`oc-access__list`,children:c.map(e=>(0,$.jsxs)(`div`,{className:`oc-access__row`,children:[(0,$.jsx)(Y,{checked:e.selected,onCheckedChange:()=>void d(e.chartKey,e.selected),"aria-label":P({name:e.name})}),(0,$.jsx)(`span`,{className:`oc-access__label`,title:e.name,children:e.name}),e.selected?e.isDefault?(0,$.jsx)(`span`,{className:`oc-access__fav`,role:`img`,"aria-label":Se(),title:Se(),children:(0,$.jsx)(K,{size:14,fill:`currentColor`})}):(0,$.jsx)(U,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>void f(e.chartKey),children:ge()}):null,u?(0,$.jsx)(U,{type:`button`,variant:`ghost`,size:`sm`,"aria-label":fe({name:e.name}),title:fe({name:e.name}),onClick:()=>void m(e.chartKey),children:(0,$.jsx)(Ae,{size:14,"aria-hidden":!0})}):null]},e.chartKey))}),u?l.length>0?(0,$.jsxs)(Le,{value:``,onValueChange:e=>void p(e),children:[(0,$.jsx)(Ne,{size:`sm`,className:`oc-access__search`,children:(0,$.jsx)(Ve,{placeholder:we()})}),(0,$.jsx)(Re,{children:l.map(e=>(0,$.jsx)(Fe,{value:e.chartKey,children:e.name},e.chartKey))})]}):c.length===0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:ae()}):null:null]})}export{at as GroupsTab};