@lacneu/atrium 0.101.0 → 0.101.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/dist/assets/AccessTab-Bqe1pBHg.js +1 -0
  2. package/dist/assets/{AdvancedFilter-DpruS-Ir.js → AdvancedFilter-CuU4dw1X.js} +1 -1
  3. package/dist/assets/AgentFilesTab-NYJs6TMu.js +3 -0
  4. package/dist/assets/AnomaliesTab-DFvqHv9o.js +1 -0
  5. package/dist/assets/AuditTab-DIcziIJX.js +1 -0
  6. package/dist/assets/BridgeTab-VqbKYXla.js +1 -0
  7. package/dist/assets/ChatDefaultsTab-DqMpmy5H.js +1 -0
  8. package/dist/assets/{DataTableShell-T9CE8psy.js → DataTableShell-D_c2Z76f.js} +1 -1
  9. package/dist/assets/DeletedChatsTab-DyxFfmef.js +1 -0
  10. package/dist/assets/{DetailChips-BZuGu-Sd.js → DetailChips-WBRxaQ82.js} +1 -1
  11. package/dist/assets/FeedbacksTab-DVut75TE.js +1 -0
  12. package/dist/assets/{FieldLabel-G1NrhA3P.js → FieldLabel-sEQ38rsG.js} +1 -1
  13. package/dist/assets/FilesTab-BFIgkWEG.js +1 -0
  14. package/dist/assets/{FilterBar-DEaGqML_.js → FilterBar-PBFn9z0b.js} +1 -1
  15. package/dist/assets/GroupsTab-C91UFNLH.js +1 -0
  16. package/dist/assets/InstancesTab-BviB2Jvn.js +1 -0
  17. package/dist/assets/IntegrationsTab-9qNfX7Ea.js +1 -0
  18. package/dist/assets/KpiTab-CvhpHsF6.js +1 -0
  19. package/dist/assets/PreferencesTab-xlq16eC5.js +1 -0
  20. package/dist/assets/ProjectPage-BtrFu_Lf.js +1 -0
  21. package/dist/assets/PromptInjectionsTab-B3TsPHrm.js +4 -0
  22. package/dist/assets/RolesTab-sL4whlaG.js +1 -0
  23. package/dist/assets/ScheduledTab-DTY4IM6C.js +1 -0
  24. package/dist/assets/ServiceAccountsTab-DKpSqt09.js +1 -0
  25. package/dist/assets/SubAgentReportsTab-gInAtOGP.js +1 -0
  26. package/dist/assets/ThemeShowroom-Df3xhHT5.js +1 -0
  27. package/dist/assets/{TimeRangePicker-BqRtJNXo.js → TimeRangePicker-D6jq73FP.js} +1 -1
  28. package/dist/assets/{TimezoneCombobox-Av0_ngam.js → TimezoneCombobox-6UndnvMs.js} +1 -1
  29. package/dist/assets/TracesTab-Bk5xfjiy.js +1 -0
  30. package/dist/assets/TrashTab-CdaRxOlx.js +1 -0
  31. package/dist/assets/UsersTab-CIwnujn2.js +1 -0
  32. package/dist/assets/VoiceTab-Baf3mBPU.js +1 -0
  33. package/dist/assets/{api-Bem2UcWi.js → api-Ca1H8N44.js} +5 -5
  34. package/dist/assets/{button-BFCjIMMp.js → button-BbEZKLza.js} +1 -1
  35. package/dist/assets/{card-8bracPwl.js → card-Du7JykLJ.js} +1 -1
  36. package/dist/assets/chevrons-up-down-DCwhEy5H.js +1 -0
  37. package/dist/assets/{compatView-MkBIUV01.js → compatView-BDU79WFh.js} +1 -1
  38. package/dist/assets/dispatchErrorInfo-CoXI4U8X.js +1 -0
  39. package/dist/assets/{dist-D8YXB9MB.js → dist-Bfmsr8JO.js} +1 -1
  40. package/dist/assets/{dist-Db4u8Wp3.js → dist-DkeZNw3H.js} +1 -1
  41. package/dist/assets/{dist-CWSfy8pV.js → dist-DuDAYkx5.js} +1 -1
  42. package/dist/assets/{dist-Dji1wB7H.js → dist-l5bFdBkH.js} +1 -1
  43. package/dist/assets/{highlighted-body-OFNGDK62-D-5jzxfh.js → highlighted-body-OFNGDK62-CGcdFk1N.js} +1 -1
  44. package/dist/assets/index-DEccjMsV.css +1 -0
  45. package/dist/assets/index-bizOs74t.js +447 -0
  46. package/dist/assets/{list-C2LRGszl.js → list-Bhy47ogH.js} +1 -1
  47. package/dist/assets/mermaid-GHXKKRXX-BRRFpPlu.js +1 -0
  48. package/dist/assets/{pdf-GYc7_t-j.js → pdf-CUEcMpJo.js} +1 -1
  49. package/dist/assets/roleDescriptions-DUp1v5cq.js +1 -0
  50. package/dist/assets/{table-DJmLrBXF.js → table-BrECCZpB.js} +1 -1
  51. package/dist/assets/trashPage-Cq944d0w.js +1 -0
  52. package/dist/assets/{use_paginated_query-DKNFqVML.js → use_paginated_query-C842MAhU.js} +1 -1
  53. package/dist/assets/x-BvlIg0Y4.js +1 -0
  54. package/dist/index.html +9 -9
  55. package/package.json +1 -1
  56. package/dist/assets/AccessTab-Bf09gC3N.js +0 -1
  57. package/dist/assets/AgentFilesTab-DA9nOFOo.js +0 -3
  58. package/dist/assets/AnomaliesTab-BcbYjkjq.js +0 -1
  59. package/dist/assets/AuditTab-DMuxXD5X.js +0 -1
  60. package/dist/assets/BridgeTab-DmDvMngQ.js +0 -1
  61. package/dist/assets/ChatDefaultsTab-BtY_GTBF.js +0 -1
  62. package/dist/assets/DeletedChatsTab-DefkjkJK.js +0 -1
  63. package/dist/assets/FeedbacksTab-BcmKMPN6.js +0 -1
  64. package/dist/assets/FilesTab-C1_6z-1C.js +0 -1
  65. package/dist/assets/GroupsTab-Dpdr5W7G.js +0 -1
  66. package/dist/assets/InstancesTab-GOgadzOY.js +0 -1
  67. package/dist/assets/IntegrationsTab-D13AdcGo.js +0 -1
  68. package/dist/assets/KpiTab-QqbOZBUq.js +0 -1
  69. package/dist/assets/PreferencesTab--HpDlOVu.js +0 -1
  70. package/dist/assets/ProjectPage-zturD6TC.js +0 -1
  71. package/dist/assets/PromptInjectionsTab-BzD_cYkw.js +0 -4
  72. package/dist/assets/RolesTab-BqV4tkdm.js +0 -1
  73. package/dist/assets/ScheduledTab-B4m9hAhs.js +0 -1
  74. package/dist/assets/ServiceAccountsTab-ChO7gQC2.js +0 -1
  75. package/dist/assets/SubAgentReportsTab-BBn0RWq7.js +0 -1
  76. package/dist/assets/ThemeShowroom-BCG97xSQ.js +0 -1
  77. package/dist/assets/TracesTab-q3Jr8_XA.js +0 -1
  78. package/dist/assets/TrashTab-BM01Jcv4.js +0 -1
  79. package/dist/assets/UsersTab-kGL0H-1n.js +0 -1
  80. package/dist/assets/VoiceTab-vTRcCcLF.js +0 -1
  81. package/dist/assets/chevrons-up-down-BDtwl2PG.js +0 -1
  82. package/dist/assets/dispatchErrorInfo-DbnBuqBy.js +0 -1
  83. package/dist/assets/index-BPPV9tVl.css +0 -1
  84. package/dist/assets/index-BfR5o8dt.js +0 -447
  85. package/dist/assets/mermaid-GHXKKRXX-CWFQTrjp.js +0 -1
  86. package/dist/assets/roleDescriptions-DbEx09YG.js +0 -1
  87. package/dist/assets/trashPage-BU5-lYpk.js +0 -1
  88. package/dist/assets/x-BttqqcAi.js +0 -1
@@ -0,0 +1 @@
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{Ax as r,Dx as i,Ex as a,Fx as o,HX as s,Ix as c,Lx as l,MX as u,Mx as d,Nx as f,Ox as p,Px as m,Rx as h,Tx as g,jx as _,kx as v,t as y,zx as b}from"./api-Ca1H8N44.js";import{Jt as x,St as S,bt as C,vt as w,xt as T,yt as E}from"./index-bizOs74t.js";var D=t(e(),1);function O(e){return e===`user`?v():e===`all`?p():i({group:e.group})}function k(e){return e===`common`?a():e===`owner`?g():i({group:e.group})}var A=n();function j(e){return e.name||e.email||e.userId.slice(0,8)}function M(){let e=s(y.admin.listUsers,{}),[t,n]=(0,D.useState)(``),i=s(y.introspect.introspectUser,t?{userId:t}:`skip`);return(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`p`,{className:`oc-admin__hint`,children:b()}),(0,A.jsxs)(w,{value:t,onValueChange:n,children:[(0,A.jsx)(T,{size:`sm`,"aria-label":h(),children:(0,A.jsx)(S,{placeholder:h()})}),(0,A.jsx)(E,{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:l()}):i===void 0?(0,A.jsx)(`p`,{className:`oc-admin__hint`,children:u()}):(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:c()}),(0,A.jsxs)(`div`,{className:`oc-introspect__id`,children:[(0,A.jsx)(`strong`,{children:i.user.label}),(0,A.jsx)(x,{variant:`secondary`,children:i.role})]})]}),(0,A.jsxs)(`section`,{className:`oc-introspect__section`,children:[(0,A.jsx)(`h3`,{className:`oc-introspect__title`,children:o()}),i.groups.length===0?(0,A.jsx)(`p`,{className:`oc-admin__hint`,children:_()}):(0,A.jsx)(`div`,{className:`oc-introspect__chips`,children:i.groups.map(e=>(0,A.jsx)(x,{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:m()}),i.agents.length===0?(0,A.jsx)(`p`,{className:`oc-admin__hint`,children:_()}):(0,A.jsx)(`ul`,{className:`oc-introspect__list`,children:i.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)(x,{variant:`default`,children:r()}):null,(0,A.jsx)(x,{variant:`outline`,children:O(e.via)}),(0,A.jsx)(x,{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:f()}),i.charts.length===0?(0,A.jsx)(`p`,{className:`oc-admin__hint`,children:_()}):(0,A.jsx)(`ul`,{className:`oc-introspect__list`,children:i.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)(x,{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:d()}),i.permissions.length===0?(0,A.jsx)(`p`,{className:`oc-admin__hint`,children:_()}):(0,A.jsx)(`div`,{className:`oc-introspect__chips`,children:i.permissions.map(e=>(0,A.jsx)(x,{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{BC as r,GC as i,HC as a,UC as o,VC as s,WC as c,zC as l}from"./api-Bem2UcWi.js";import{r as u}from"./dist-D8YXB9MB.js";import{t as d}from"./x-BttqqcAi.js";import{t as f}from"./button-BFCjIMMp.js";import{$t as p,Ln as m,St as h,bt as g,vt as _,xt as v,yt as y}from"./index-BfR5o8dt.js";import{r as b}from"./TimeRangePicker-BqRtJNXo.js";var x=t(e(),1),S=n(),C=[{value:`eq`,label:`=`},{value:`neq`,label:`≠`},{value:`contains`,label:i()},{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 i=(0,x.useRef)(t),w=!!(i.current&&i.current.length>0),[D,O]=(0,x.useState)(w),[k,A]=(0,x.useState)(()=>w?E(i.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}),c(),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:o()}):(0,S.jsx)(`ul`,{className:`oc-advfilter__rows`,children:k.map(t=>(0,S.jsxs)(`li`,{className:`oc-advfilter__row`,children:[(0,S.jsxs)(_,{value:t.field||void 0,onValueChange:e=>M(t.id,{field:e}),children:[(0,S.jsx)(v,{size:`sm`,className:`w-40`,children:(0,S.jsx)(h,{placeholder:a()})}),(0,S.jsx)(y,{children:e.map(e=>(0,S.jsx)(g,{value:e.value,children:e.label},e.value))})]}),(0,S.jsxs)(_,{value:t.op,onValueChange:e=>M(t.id,{op:e}),children:[(0,S.jsx)(v,{size:`sm`,className:`w-28`,children:(0,S.jsx)(h,{})}),(0,S.jsx)(y,{children:C.map(e=>(0,S.jsx)(g,{value:e.value,children:e.label},e.value))})]}),(0,S.jsx)(p,{className:`oc-advfilter__value`,value:t.value,onChange:e=>M(t.id,{value:e.target.value}),placeholder:s()}),(0,S.jsx)(f,{variant:`ghost`,size:`icon-sm`,"aria-label":r(),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)(m,{}),l()]})]}):null]})}export{D as t};
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{aw as r,cw as i,iw as a,lw as o,ow as s,sw as c,uw as l}from"./api-Ca1H8N44.js";import{r as u}from"./dist-Bfmsr8JO.js";import{t as d}from"./x-BvlIg0Y4.js";import{t as f}from"./button-BbEZKLza.js";import{$t as p,Ln as m,St as h,bt as g,vt as _,xt as v,yt as y}from"./index-bizOs74t.js";import{r as b}from"./TimeRangePicker-D6jq73FP.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}),o(),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)(_,{value:t.field||void 0,onValueChange:e=>M(t.id,{field:e}),children:[(0,S.jsx)(v,{size:`sm`,className:`w-40`,children:(0,S.jsx)(h,{placeholder:c()})}),(0,S.jsx)(y,{children:e.map(e=>(0,S.jsx)(g,{value:e.value,children:e.label},e.value))})]}),(0,S.jsxs)(_,{value:t.op,onValueChange:e=>M(t.id,{op:e}),children:[(0,S.jsx)(v,{size:`sm`,className:`w-28`,children:(0,S.jsx)(h,{})}),(0,S.jsx)(y,{children:C.map(e=>(0,S.jsx)(g,{value:e.value,children:e.label},e.value))})]}),(0,S.jsx)(p,{className:`oc-advfilter__value`,value:t.value,onChange:e=>M(t.id,{value:e.target.value}),placeholder:s()}),(0,S.jsx)(f,{variant:`ghost`,size:`icon-sm`,"aria-label":r(),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)(m,{}),a()]})]}):null]})}export{D as t};
@@ -0,0 +1,3 @@
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$_ as r,Af as i,B_ as a,Bf as o,Df as s,Ef as c,F_ as l,Ff as u,G_ as d,Gf as f,HX as p,H_ as m,Hf as h,I_ as g,If as _,J_ as v,Jv as y,K_ as b,L_ as x,Lf as S,MX as C,Mf as w,Nf as T,Of as E,PX as D,Pf as O,Q_ as k,R_ as A,Rf as j,Tf as M,UV as N,U_ as ee,Uf as P,VX as F,V_ as I,Vf as L,W_ as R,Wf as z,X_ as te,Xv as B,Y_ as V,Z_ as ne,af as re,av as H,cf as ie,cv as U,ev as W,if as ae,iv as oe,jf as se,kf as ce,ks as le,lf as ue,lv as de,nv as fe,of as pe,ov as me,q_ as he,rf as ge,rv as _e,sf as ve,sv as ye,t as G,tv as be,uv as xe,zX as K,z_ as Se,zf as Ce}from"./api-Ca1H8N44.js";import{t as q}from"./button-BbEZKLza.js";import{Bt as we,Ct as Te,Dt as Ee,Gt as De,Ht as Oe,Jt as ke,Kt as Ae,Ot as je,St as Me,Tt as Ne,Ut as Pe,Vt as Fe,Wt as Ie,Yt as J,bt as Le,ft as Re,kn as Y,nt as ze,qt as Be,vt as Ve,wt as He,xt as Ue,yt as We}from"./index-bizOs74t.js";import{n as Ge,t as Ke}from"./curation-CQksaIbm.js";import{a as qe}from"./compatView-BDU79WFh.js";/* empty css */var X=t(e(),1),Je=2e4,Ye=6e4;function Xe(e){return typeof e!=`number`||e<=0?0:Math.round(e/Je*100)}function Ze(e){return e<=0?0:Math.round(e/Ye*100)}function Z(e,t){let n=(typeof e==`number`&&e>0?e:0)/1e3;return new Intl.NumberFormat(t,{minimumFractionDigits:1,maximumFractionDigits:1}).format(n)}function Qe(e){return e.reduce((e,t)=>e+(typeof t.size==`number`&&t.size>0?t.size:0),0)}var $e=3;function et(e,t){let n=new Map;for(let t of e.split(`
2
+ `))n.set(t,(n.get(t)??0)+1);for(let e of t.split(`
3
+ `))n.set(e,(n.get(e)??0)-1);let r=0,i=0,a=[],o=[];for(let[e,t]of n)t<0?(r+=-t,a.length<$e&&a.push(e)):t>0&&(i+=t,o.length<$e&&o.push(e));return{added:r,removed:i,sampleAdded:a,sampleRemoved:o}}function tt(e){return(e instanceof Error?e.message:String(e)).includes(`DASHBOARD_NOT_DEPLOYED`)}function nt(e){return e instanceof Error?e.message.includes(`conflict:`):String(e).includes(`conflict:`)}var Q=n(),$=e=>`${e.instanceName}::${e.agentId}`;function rt(){let e=p(G.me.getMe,{host:Re}),t=e?.role===`admin`,n=(e?.permissions??[]).includes(`bridge.read`),i=p(G.admin.listInstances,e!==void 0&&t?{}:`skip`),[a,s]=(0,X.useState)(null);(0,X.useEffect)(()=>{!t||!i||i.length===0||(!a||!i.some(e=>e.name===a))&&s(i[0].name)},[t,i,a]);let c=p(G.agents.listAgentsForInstance,t&&a?{instanceName:a}:`skip`),l=p(G.agents.listMyAgents,e!==void 0&&!t?{}:`skip`),u=(0,X.useMemo)(()=>{if(e!==void 0){if(t)return a===null||c===void 0?i!==void 0&&i.length===0?[]:void 0:c.agents.map(e=>({instanceName:a,agentId:e.agentId,label:`${e.emoji?`${e.emoji} `:``}${e.displayName??e.agentId}`}));if(l!==void 0)return l.map(e=>({instanceName:e.instanceName,agentId:e.agentId,label:`${e.emoji?`${e.emoji} `:``}${e.displayName??e.agentId}`}))}},[e,t,a,c,i,l]),[d,f]=(0,X.useState)(null);(0,X.useEffect)(()=>{!u||u.length===0||(!d||!u.some(e=>$(e)===d))&&f($(u[0]))},[u,d]);let m=u?.find(e=>$(e)===d)??null,g=K(G.agentFiles.listAgentFiles),[_,v]=(0,X.useState)({status:`idle`}),b=m?.instanceName??null,x=m?.agentId??null,S=p(G.compat.forInstance,n&&b!==null?{instanceName:b}:`skip`),w=n&&b!==null?ze(S,`agentFiles`):null,T=w===null?!1:w===`loading`?null:w.blocked,E=(0,X.useCallback)(async()=>{if(!(b===null||x===null)){v({status:`loading`});try{v({status:`done`,files:(await g({instanceName:b,agentId:x})).files})}catch(e){v({status:`error`,dashboardAbsent:tt(e)})}}},[g,b,x]);(0,X.useEffect)(()=>{T===!1&&E()},[E,T]);let[O,A]=(0,X.useState)(null),j=p(G.agentFileCuration.listCurations,t&&b!==null&&x!==null?{instanceName:b,agentId:x}:`skip`),M=p(G.agentFileCuration.curationSettings,t&&b!==null?{instanceName:b}:`skip`),N=K(G.agentFileCuration.requestCuration),[ee,P]=(0,X.useState)(null),[F,I]=(0,X.useState)(null),{toast:R}=J(),z=(0,X.useMemo)(()=>{let e=new Map;for(let t of j??[])e.has(t.name)||e.set(t.name,t);return e},[j]),te=(0,X.useCallback)(async e=>{if(!(b===null||x===null)){P(e);try{let t=await N({instanceName:b,agentId:x,name:e,trigger:`manual`});t.ok?R({title:h(),variant:`success`}):R({title:L({reason:t.reason??`unknown`}),variant:`error`})}catch{R({title:o(),variant:`error`})}finally{P(null)}}},[N,b,x,R]),B=D(),V=(0,X.useMemo)(()=>new Intl.NumberFormat(B,{maximumFractionDigits:0}),[B]);return e===void 0||u===void 0?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:C()}):(0,Q.jsxs)(`div`,{className:`oc-afiles`,children:[(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:xe()}),(0,Q.jsxs)(`div`,{className:`oc-afiles__picker`,children:[t&&(i?.length??0)>1?(0,Q.jsxs)(Ve,{value:a??``,onValueChange:e=>s(e),children:[(0,Q.jsx)(Ue,{size:`sm`,"aria-label":de(),children:(0,Q.jsx)(Me,{})}),(0,Q.jsx)(We,{children:(i??[]).map(e=>(0,Q.jsx)(Le,{value:e.name,children:e.name},e.name))})]}):null,u.length>0?(0,Q.jsxs)(Ve,{value:d??``,onValueChange:e=>f(e),children:[(0,Q.jsx)(Ue,{size:`sm`,"aria-label":U(),children:(0,Q.jsx)(Me,{})}),(0,Q.jsx)(We,{children:u.map(e=>(0,Q.jsx)(Le,{value:$(e),children:e.label},$(e)))})]}):(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:ye()})]}),m===null?null:w===`loading`?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:C()}):w!==null&&w.blocked?(0,Q.jsxs)(`p`,{className:`oc-compat__blocked`,role:`status`,children:[(0,Q.jsx)(Y,{size:14,"aria-hidden":!0}),` `,qe(w.gatewayVersion,w.provider)]}):_.status===`loading`||_.status===`idle`?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:C()}):_.status===`error`?(0,Q.jsxs)(`p`,{className:`oc-afiles__error`,role:`alert`,children:[_.dashboardAbsent?le():H(),` `,!_.dashboardAbsent&&(0,Q.jsx)(q,{variant:`outline`,size:`sm`,onClick:()=>void E(),children:y()})]}):_.files.length===0?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:me()}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`oc-afiles__list`,children:_.files.map(e=>{let n=Xe(e.size),i=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)(ke,{variant:`outline`,children:oe()}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`oc-afiles__size`,children:_e({size:Z(e.size,B)})}),(0,Q.jsx)(`span`,{className:`oc-afiles__gauge${i?` 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:fe({pct:V.format(n)})}),i?(0,Q.jsx)(Y,{size:14,className:`oc-afiles__warn`,"aria-label":be()}):(0,Q.jsx)(`span`,{className:`oc-afiles__warn-slot`,"aria-hidden":!0})]}),(0,Q.jsx)(q,{variant:`outline`,size:`sm`,className:`oc-afiles__open`,onClick:()=>A(e),children:t?r():k()}),t&&!e.missing?(0,Q.jsx)(it,{curatable:Ke.includes(e.name),size:e.size??0,budget:M?.budgetChars??null,enabled:M?.enabled??!1,curation:z.get(e.name)??null,inFlight:ee===e.name,onCurate:()=>void te(e.name),onReview:e=>I(e)}):null]},e.name)})}),(0,Q.jsx)(`p`,{className:`oc-afiles__budget`,children:W({used:Z(Qe(_.files),B),total:Z(Ye,B),pct:V.format(Ze(Qe(_.files)))})})]}),O&&m?(0,Q.jsx)(at,{instanceName:m.instanceName,agentId:m.agentId,name:O.name,isAdmin:t,onClose:()=>A(null),onSaved:()=>void E()}):null,F?(0,Q.jsx)(ot,{curationId:F,onClose:()=>I(null),onApplied:()=>{I(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)(q,{variant:`default`,size:`sm`,className:`oc-afiles__curate`,onClick:()=>s(i._id),children:z()}):a||i?.status===`dispatched`||i?.status===`applying`?(0,Q.jsx)(ke,{variant:`outline`,className:`oc-afiles__curate-status`,children:P()}):e&&r&&n!==null&&Ge(t,n)?(0,Q.jsx)(q,{variant:`outline`,size:`sm`,className:`oc-afiles__curate`,onClick:o,children:f()}):null}function at({instanceName:e,agentId:t,name:n,isAdmin:r,onClose:i,onSaved:o}){let s=K(G.agentFiles.getAgentFile),c=K(G.agentFiles.setAgentFile),u=J(),[f,p]=(0,X.useState)(null),[h,_]=(0,X.useState)(!1),[S,w]=(0,X.useState)(``),[T,E]=(0,X.useState)(!1),[O,k]=(0,X.useState)(!1),[j,M]=(0,X.useState)(!1),[P,F]=(0,X.useState)(!1),L=(0,X.useCallback)(async r=>{_(!1);try{let i=await s({instanceName:e,agentId:t,name:n});p({content:i.content,updatedAtMs:i.updatedAtMs}),r||w(i.content),M(!1)}catch{_(!0)}},[s,e,t,n]);(0,X.useEffect)(()=>{L(!1)},[L]);async function z(){if(f!==null){k(!0),F(!1);try{await c({instanceName:e,agentId:t,name:n,content:S,baseUpdatedAtMs:f.updatedAtMs??void 0}),u.success(d({name:n})),o(),await L(!1)}catch(e){nt(e)?M(!0):F(!0)}finally{k(!1)}}}let re=f!==null&&S!==f.content,H=(0,X.useMemo)(()=>f===null?null:et(f.content,S),[f,S]),ie=S.length>Je,U=D(),W=(0,X.useMemo)(()=>new Intl.NumberFormat(U),[U]);return(0,Q.jsx)(Te,{open:!0,onOpenChange:e=>!e&&i(),children:(0,Q.jsxs)(He,{className:`oc-afiles__editor`,children:[(0,Q.jsxs)(Ee,{children:[(0,Q.jsx)(je,{children:ne({name:n})}),(0,Q.jsxs)(Ne,{children:[te({agent:t,instance:e}),r?null:(0,Q.jsxs)(Q.Fragment,{children:[` · `,V()]})]})]}),h?(0,Q.jsxs)(`p`,{className:`oc-afiles__error`,role:`alert`,children:[ee(),` `,(0,Q.jsx)(q,{variant:`outline`,size:`sm`,onClick:()=>void L(!1),children:y()})]}):f===null?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:C()}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`textarea`,{className:`oc-afiles__source`,value:S,readOnly:!r,spellCheck:!1,onChange:e=>w(e.target.value),"aria-label":ne({name:n})}),(0,Q.jsx)(`p`,{className:`oc-afiles__hint`,children:v()}),j?(0,Q.jsxs)(`p`,{className:`oc-afiles__error`,role:`alert`,children:[m(),` `,(0,Q.jsx)(q,{variant:`outline`,size:`sm`,onClick:()=>void L(!0),children:I()})]}):null,P?(0,Q.jsx)(`p`,{className:`oc-afiles__error`,role:`alert`,children:R()}):null,(0,Q.jsxs)(`div`,{className:`oc-afiles__editor-foot`,children:[(0,Q.jsx)(`span`,{className:`oc-afiles__count${ie?` is-over`:``}`,children:he({count:W.format(S.length),max:W.format(Je)})}),r?(0,Q.jsx)(q,{size:`sm`,disabled:!re||O||j,onClick:()=>E(!0),children:O?B():b()}):null]})]}),(0,Q.jsx)(we,{open:T,onOpenChange:E,children:(0,Q.jsxs)(Pe,{children:[(0,Q.jsxs)(Ae,{children:[(0,Q.jsx)(Be,{children:a({name:n})}),(0,Q.jsx)(Ie,{children:Se({agent:t})})]}),H?(0,Q.jsxs)(`div`,{className:`oc-afiles__diff`,children:[(0,Q.jsx)(`p`,{className:`oc-afiles__diff-counts`,children:A({added:H.added,removed:H.removed})}),H.sampleAdded.length>0?(0,Q.jsxs)(`div`,{className:`oc-afiles__diff-block`,children:[(0,Q.jsx)(`span`,{className:`oc-afiles__diff-label`,children:x()}),H.sampleAdded.map((e,t)=>(0,Q.jsx)(`code`,{className:`oc-afiles__diff-line is-add`,children:e||` `},t))]}):null,H.sampleRemoved.length>0?(0,Q.jsxs)(`div`,{className:`oc-afiles__diff-block`,children:[(0,Q.jsx)(`span`,{className:`oc-afiles__diff-label`,children:g()}),H.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)(Oe,{children:N()}),(0,Q.jsx)(Fe,{onClick:()=>void z(),children:l()})]})]})})]})})}function ot({curationId:e,onClose:t,onApplied:n}){let r=p(G.agentFileCuration.getProposal,{curationId:e}),a=K(G.agentFileCuration.approveCuration),l=F(G.agentFileCuration.rejectCuration),{toast:d}=J(),[f,m]=(0,X.useState)(null),[h,g]=(0,X.useState)(!1),[v,y]=(0,X.useState)(``),b=D(),x=(0,X.useMemo)(()=>r?et(r.beforeContent,r.proposedContent):null,[r]);async function k(){m(`approve`);try{let t=await a({curationId:e});t.ok?(d({title:Ce(),variant:`success`}),n()):d({title:t.reason===`conflict`?S():_({reason:t.reason??`unknown`}),variant:`error`})}catch{d({title:o(),variant:`error`})}finally{m(null)}}async function A(n){m(`reject`);try{let r=v.trim();(await l({curationId:e,...r?{comment:r}:{},relaunch:n})).ok?d({title:n?ae():j(),variant:`success`}):d({title:T(),variant:`error`}),t()}catch{d({title:o(),variant:`error`})}finally{m(null)}}return(0,Q.jsx)(Te,{open:!0,onOpenChange:e=>e?void 0:t(),children:(0,Q.jsxs)(He,{className:`oc-afiles__review`,children:[(0,Q.jsxs)(Ee,{children:[(0,Q.jsx)(je,{children:r?u({name:r.name}):C()}),(0,Q.jsx)(Ne,{children:O()})]}),r===void 0?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:C()}):r===null?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:T()}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`p`,{className:`oc-afiles__review-sizes`,children:[w({before:Z(r.beforeSize,b),after:Z(r.proposedSize,b)}),r.overBudget?(0,Q.jsxs)(Q.Fragment,{children:[` `,(0,Q.jsx)(Y,{size:13,"aria-hidden":!0}),` `,se()]}):null]}),x?(0,Q.jsx)(`p`,{className:`oc-afiles__review-diff`,children:i({added:x.added,removed:x.removed})}):null,r.feedback?(0,Q.jsx)(`p`,{className:`oc-afiles__review-feedback`,children:ge({feedback:r.feedback})}):null,x&&x.sampleRemoved.length>0?(0,Q.jsxs)(`div`,{className:`oc-afiles__review-removed`,children:[(0,Q.jsx)(`p`,{className:`oc-afiles__review-label`,children:M()}),(0,Q.jsx)(`ul`,{children:x.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:ce()}),(0,Q.jsx)(`pre`,{className:`oc-afiles__review-pre`,children:r.proposedContent})]})]})]}),h?(0,Q.jsxs)(`div`,{className:`oc-afiles__reject-form`,children:[(0,Q.jsx)(`label`,{className:`oc-afiles__review-label`,htmlFor:`curation-reject-comment`,children:ue()}),(0,Q.jsx)(`textarea`,{id:`curation-reject-comment`,className:`oc-afiles__reject-textarea`,rows:3,placeholder:ie(),value:v,onChange:e=>y(e.target.value)}),(0,Q.jsxs)(`div`,{className:`oc-afiles__review-actions`,children:[(0,Q.jsx)(q,{variant:`ghost`,onClick:()=>g(!1),disabled:f!==null,children:ve()}),(0,Q.jsx)(q,{variant:`outline`,onClick:()=>void A(!1),disabled:f!==null,children:f===`reject`?B():pe()}),(0,Q.jsx)(q,{variant:`default`,onClick:()=>void A(!0),disabled:f!==null,children:f===`reject`?B():re()})]})]}):(0,Q.jsxs)(`div`,{className:`oc-afiles__review-actions`,children:[(0,Q.jsx)(q,{variant:`outline`,onClick:()=>g(!0),disabled:f!==null||r==null,children:E()}),(0,Q.jsx)(q,{variant:`default`,onClick:()=>void k(),disabled:f!==null||r==null,children:f===`approve`?B():s()})]})]})})}export{rt as AgentFilesTab};
@@ -0,0 +1 @@
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$M as r,AM as i,BM as a,DM as o,EM as s,FM as c,GM as l,HM as u,HX as d,IM as ee,JM as te,KM as ne,LM as re,MM as f,NM as p,OM as m,PM as h,QM as g,RM as ie,UM as ae,VM as oe,VX as se,WM as ce,XM as le,YM as ue,ZM as de,_N as fe,aN as pe,bN as _,cN as me,dN as he,eN as ge,fN as _e,gN as ve,hN as ye,iN as be,jM as v,kM as y,lN as xe,mN as Se,nN as Ce,oN as b,pN as x,qM as S,rN as C,sN as w,t as T,tN as E,uN as D,vN as O,xN as k,yN as A,zM as we}from"./api-Ca1H8N44.js";import{At as j,Ct as M,Dt as N,Jt as P,Ot as F,St as I,Yt as Te,bt as L,ct as Ee,dr as R,fr as De,ft as Oe,i as ke,o as Ae,vt as z,wt as B,xt as V,yt as H}from"./index-bizOs74t.js";import{n as je}from"./TimeRangePicker-D6jq73FP.js";import{t as Me}from"./FilterBar-PBFn9z0b.js";import{t as Ne}from"./DataTableShell-D_c2Z76f.js";import{t as U}from"./dispatchErrorInfo-CoXI4U8X.js";var W=t(e(),1),G=new Set([`openclaw.dispatch_failures`,`assistant.announce_errors`]),K=new Set([`assistant.cause.provider_auth_revoked`,`assistant.cause.provider_permission_denied`,`assistant.cause.provider_auth_failed`]);function q(e){let t=K.has(e.kind);if(!G.has(e.kind)&&!t||!e.evidence)return{};try{let n=JSON.parse(e.evidence);if(t){let e=Array.isArray(n.agents)?n.agents.filter(e=>typeof e==`string`):[],t=Array.isArray(n.providers)?n.providers.filter(e=>typeof e==`string`):[],r=e.length===1?e[0]:void 0;return{dominantCode:n.cause,sampleCorrelationId:n.sampleCorrelationId,context:{...r===void 0?{}:{agentId:r.slice(r.lastIndexOf(`/`)+1)},...t.length===1?{provider:t[0]}:{}}}}return{dominantCode:n.dominantCode,sampleCorrelationId:n.sampleCorrelationId}}catch{return{}}}var J=n(),Y=`__all__`,Pe=[{value:`open`},{value:`acknowledged`},{value:`resolved`}];function Fe(e){return e===`open`?k():e===`acknowledged`?_():A()}var Ie=[`info`,`warn`,`critical`],Le=[`detector`,`agent`,`user`],X={kind:`relative`,from:`now-30d`,to:`now`},Re=200,Z=`all`;function Q(){let e=De({from:`/settings/anomalies`}),t=R({from:`/settings/anomalies`}),n=e.q??``,i=e.status===Z?Y:e.status,o=e.severity??Y,s=e.kind??Y,[f,p]=(0,W.useState)(Y),m=ke(e.from,e.to),{from:_,to:v}=je(m),y=e=>void t({search:t=>({...t,q:e||void 0}),replace:!0}),k=e=>void t({search:t=>({...t,status:e===Y?Z:e})}),A=e=>void t({search:t=>({...t,severity:e===Y?void 0:e})}),M=e=>void t({search:t=>({...t,kind:e===Y?void 0:e})}),N=e=>void t({search:t=>({...t,...Ae(e)})}),F=Ee(),B=Te(),U=se(T.anomalies.resolveAnomaly),G=(d(T.me.getMe,{host:Oe})?.permissions??[]).includes(`admin.manage`),K=d(T.anomalies.listAnomalies,{limit:Re,filter:{q:n||void 0,from:_,to:v,anomalyStatus:i===Y?void 0:i,severity:o===Y?void 0:o,source:f===Y?void 0:f,kind:s===Y?void 0:s}}),q=(0,W.useMemo)(()=>{let e=new Set;for(let t of K??[])e.add(t.kind);return[...e].sort()},[K]),Q=n!==``||i!==`open`||o!==Y||f!==Y||s!==Y||m.kind!==`relative`||m.from!==X.from;function $(){p(Y),t({search:{status:`open`},replace:!0})}async function We(e){if(await F({title:O(),description:(0,J.jsxs)(J.Fragment,{children:[fe(),` `,(0,J.jsx)(`span`,{className:`font-mono`,children:e.kind}),` `,ve(),` `,(0,J.jsx)(`strong`,{children:ye()}),`.`,` `,Se()]}),confirmLabel:x()}))try{await U({anomalyId:e._id,status:`resolved`}),B.success(_e(),e.kind)}catch(e){B.error(he(),e)}}async function Ge(e){try{await U({anomalyId:e._id,status:`acknowledged`}),B.success(D(),e.kind)}catch(e){B.error(xe(),e)}}return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`p`,{className:`oc-admin__hint`,children:[me(),` `,(0,J.jsx)(`strong`,{children:w()}),` `,b(),` `,(0,J.jsx)(`strong`,{children:pe()}),` `,be(),` `,(0,J.jsx)(`strong`,{children:C()}),` `,Ce(),` `,(0,J.jsx)(`span`,{className:`oc-filter__window`,children:E()})]}),(0,J.jsxs)(Me,{q:n,onQChange:y,searchPlaceholder:ge(),timeRange:m,onTimeRangeChange:N,onReset:$,canReset:Q,children:[(0,J.jsxs)(z,{value:i,onValueChange:k,children:[(0,J.jsx)(V,{size:`sm`,className:`w-36`,children:(0,J.jsx)(I,{})}),(0,J.jsxs)(H,{children:[(0,J.jsx)(L,{value:Y,children:r()}),Pe.map(e=>(0,J.jsx)(L,{value:e.value,children:Fe(e.value)},e.value))]})]}),(0,J.jsxs)(z,{value:o,onValueChange:A,children:[(0,J.jsx)(V,{size:`sm`,className:`w-36`,children:(0,J.jsx)(I,{placeholder:g()})}),(0,J.jsxs)(H,{children:[(0,J.jsx)(L,{value:Y,children:te()}),Ie.map(e=>(0,J.jsx)(L,{value:e,children:e},e))]})]}),(0,J.jsxs)(z,{value:f,onValueChange:p,children:[(0,J.jsx)(V,{size:`sm`,className:`w-32`,children:(0,J.jsx)(I,{placeholder:S()})}),(0,J.jsxs)(H,{children:[(0,J.jsx)(L,{value:Y,children:ne()}),Le.map(e=>(0,J.jsx)(L,{value:e,children:e},e))]})]}),(0,J.jsxs)(z,{value:s,onValueChange:M,children:[(0,J.jsx)(V,{size:`sm`,className:`w-36`,children:(0,J.jsx)(I,{placeholder:l()})}),(0,J.jsxs)(H,{children:[(0,J.jsx)(L,{value:Y,children:ce()}),q.map(e=>(0,J.jsx)(L,{value:e,children:e},e))]})]})]}),(0,J.jsx)(Ne,{title:ae(),rows:K,emptyHint:i===`open`?u():oe(),rowActions:e=>G&&e.status===`open`?[{label:a(),onSelect:()=>void We(e)},{label:we(),onSelect:()=>void Ge(e)}]:[],columns:[{header:ie(),cell:e=>(0,J.jsx)(`span`,{className:`oc-traces__time`,children:j(e.at)}),sort:e=>e.at},{header:l(),cell:e=>(0,J.jsx)(`code`,{className:`oc-traces__mono`,children:e.kind}),sort:e=>e.kind},{header:de(),cell:e=>e.occurrenceCount!==null&&e.occurrenceCount>1?(0,J.jsx)(`span`,{className:`oc-traces__time`,title:e.firstAt===null?void 0:ue({when:j(e.firstAt)}),children:le({count:String(e.occurrenceCount)})}):(0,J.jsx)(`span`,{className:`oc-traces__time`,children:`—`}),sort:e=>e.occurrenceCount??0},{header:g(),cell:e=>(0,J.jsx)(Ve,{severity:e.severity}),sort:e=>e.severity===`critical`?2:+(e.severity===`warn`)},{header:re(),cell:e=>(0,J.jsx)(He,{status:e.status}),sort:e=>e.status===`resolved`?2:+(e.status===`acknowledged`)},{header:S(),cell:e=>(0,J.jsx)(P,{variant:`outline`,children:e.source}),sort:e=>e.source},{header:ee(),cell:e=>(0,J.jsxs)(`div`,{className:`oc-anomaly__msgcell`,children:[(0,J.jsx)(`span`,{className:`oc-anomaly__msg`,children:e.message}),(0,J.jsx)(Be,{row:e})]}),sort:e=>e.message},{header:c(),cell:e=>(0,J.jsx)(ze,{row:e}),sort:e=>e.evidence??null},{header:h(),cell:e=>e.correlationId?(0,J.jsx)(`code`,{className:`oc-traces__mono`,children:Ue(e.correlationId)}):(0,J.jsx)(`span`,{className:`oc-traces__muted`,children:`—`}),sort:e=>e.correlationId}]})]})}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 ze({row:e}){let t=R();if(e.kind===`subagent.failure`){let n=$(e);return(0,J.jsxs)(`div`,{className:`oc-anomaly__cause`,children:[(0,J.jsx)(`div`,{className:`oc-anomaly__cause-head`,children:[...new Set(n.errorCategories??[])].map(e=>(0,J.jsx)(`code`,{className:`oc-traces__mono`,children:e},e))}),e.correlationId?(0,J.jsxs)(`button`,{type:`button`,className:`oc-anomaly__drill`,onClick:()=>void t({to:`/settings/traces`,search:{q:e.correlationId,limit:100}}),children:[`↗ `,p()]}):null]})}let n=q(e);if(!n.dominantCode){let e=n.sampleCorrelationId;return e?(0,J.jsx)(`div`,{className:`oc-anomaly__cause`,children:(0,J.jsxs)(`button`,{type:`button`,className:`oc-anomaly__drill`,onClick:()=>void t({to:`/settings/traces`,search:{correlationId:e,limit:100}}),children:[`↗ `,p()]})}):(0,J.jsx)(`span`,{className:`oc-traces__muted`,children:`—`})}let r=U(n.dominantCode,n.context),i=n.sampleCorrelationId;return(0,J.jsxs)(`div`,{className:`oc-anomaly__cause`,children:[(0,J.jsxs)(`div`,{className:`oc-anomaly__cause-head`,children:[(0,J.jsx)(`span`,{className:`oc-anomaly__cause-label`,children:r.label}),(0,J.jsx)(`code`,{className:`oc-traces__mono`,children:n.dominantCode})]}),(0,J.jsx)(`p`,{className:`oc-anomaly__cause-hint`,children:r.hint}),i?(0,J.jsxs)(`button`,{type:`button`,className:`oc-anomaly__drill`,onClick:()=>void t({to:`/settings/traces`,search:{correlationId:i,limit:100}}),children:[`↗ `,p()]}):null]})}function Be({row:e}){let[t,n]=(0,W.useState)(!1),r=d(T.anomalies.getAnomalyAttachments,t?{anomalyId:e._id}:`skip`);return!e.attachments||e.attachments.length===0?null:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`button`,{type:`button`,className:`oc-anomaly__drill`,onClick:()=>n(!0),children:[f(),e.attachments.length>1?` (${e.attachments.length})`:``]}),(0,J.jsx)(M,{open:t,onOpenChange:n,children:(0,J.jsxs)(B,{className:`oc-anomaly__attachments-dialog`,children:[(0,J.jsx)(N,{children:(0,J.jsx)(F,{children:v()})}),r===void 0?(0,J.jsx)(`p`,{className:`oc-traces__muted`,children:i()}):r.length===0?(0,J.jsx)(`p`,{className:`oc-traces__muted`,children:y()}):(0,J.jsx)(`div`,{className:`oc-anomaly__attachments`,children:r.map(e=>(0,J.jsxs)(`section`,{className:`oc-anomaly__attachment`,children:[(0,J.jsx)(`h4`,{className:`oc-anomaly__attachment-name`,children:(0,J.jsx)(`code`,{className:`oc-traces__mono`,children:e.name})}),(0,J.jsx)(`pre`,{className:`oc-anomaly__attachment-content`,children:e.content})]},e.name))})]})})]})}function Ve({severity:e}){return(0,J.jsx)(`span`,{className:`oc-anomaly__sev oc-anomaly__sev--${e}`,children:e})}function He({status:e}){return e===`open`?(0,J.jsx)(P,{variant:`destructive`,children:m()}):e===`acknowledged`?(0,J.jsx)(P,{variant:`secondary`,children:o()}):(0,J.jsx)(P,{variant:`outline`,children:s()})}function Ue(e){return e.length>8?e.slice(0,8):e}export{Q as AnomaliesTab};
@@ -0,0 +1 @@
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$u as r,CP as i,DP as a,EP as o,HX as s,Ju as c,Qu as l,SP as u,TP as d,Xu as f,Yu as p,Zu as m,_P as h,bP as g,gP as _,hP as v,mP as y,pP as b,t as x,vP as S,wP as C,xP as w,yP as T}from"./api-Ca1H8N44.js";import{At as E,St as D,a as O,bt as k,dr as A,fr as j,i as M,n as N,o as P,s as F,vt as I,xt as L,yt as R}from"./index-bizOs74t.js";import{n as ee}from"./TimeRangePicker-D6jq73FP.js";import{t as z}from"./FilterBar-PBFn9z0b.js";import{t as B}from"./AdvancedFilter-CuU4dw1X.js";import{t as V}from"./DataTableShell-D_c2Z76f.js";var H=t(e(),1),U=n(),W={kind:`relative`,from:N,to:`now`},G=`__all__`,K=[{value:`action`,label:r()},{value:`realLabel`,label:l()},{value:`targetLabel`,label:m()},{value:`impersonated`,label:f()},{value:`resource`,label:p()},{value:`resourceId`,label:c()}];function q(){let e=j({from:`/settings/audit`}),t=A({from:`/settings/audit`}),n=e.q??``,r=e.action??G,c=e.impersonated??G,l=e.resource??G,f=M(e.from,e.to),p=(0,H.useMemo)(()=>F(e.adv),[e.adv]),{from:m,to:N}=ee(f),q=e=>void t({search:t=>({...t,q:e||void 0}),replace:!0}),J=e=>void t({search:t=>({...t,action:e===G?void 0:e})}),Y=e=>void t({search:t=>({...t,impersonated:e===G?void 0:e})}),X=e=>void t({search:t=>({...t,resource:e===G?void 0:e})}),Z=e=>void t({search:t=>({...t,...P(e)})}),Q=e=>void t({search:t=>({...t,adv:O(e)}),replace:!0}),$=s(x.admin.listAudit,{filter:{q:n||void 0,from:m,to:N,action:r===G?void 0:r,resource:l===G?void 0:l,impersonated:c===G?void 0:c===`yes`,advanced:p.length>0?p:void 0}}),te=(0,H.useMemo)(()=>{let e=new Set;for(let t of $??[])e.add(t.action);return[...e].sort()},[$]),ne=(0,H.useMemo)(()=>{let e=new Set;for(let t of $??[])t.resource&&e.add(t.resource);return[...e].sort()},[$]),re=n!==``||r!==G||c!==G||l!==G||p.length>0||f.kind!==`relative`||f.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:[a(),` `,(0,U.jsx)(`span`,{className:`oc-filter__window`,children:o()})]}),(0,U.jsxs)(z,{q:n,onQChange:q,searchPlaceholder:d(),timeRange:f,onTimeRangeChange:Z,onReset:ie,canReset:re,children:[(0,U.jsxs)(I,{value:r,onValueChange:J,children:[(0,U.jsx)(L,{size:`sm`,className:`w-40`,children:(0,U.jsx)(D,{placeholder:C()})}),(0,U.jsxs)(R,{children:[(0,U.jsx)(k,{value:G,children:i()}),te.map(e=>(0,U.jsx)(k,{value:e,children:e},e))]})]}),(0,U.jsxs)(I,{value:c,onValueChange:Y,children:[(0,U.jsx)(L,{size:`sm`,className:`w-40`,children:(0,U.jsx)(D,{})}),(0,U.jsxs)(R,{children:[(0,U.jsx)(k,{value:G,children:u()}),(0,U.jsx)(k,{value:`yes`,children:w()}),(0,U.jsx)(k,{value:`no`,children:g()})]})]}),(0,U.jsxs)(I,{value:l,onValueChange:X,children:[(0,U.jsx)(L,{size:`sm`,className:`w-40`,children:(0,U.jsx)(D,{placeholder:T()})}),(0,U.jsxs)(R,{children:[(0,U.jsx)(k,{value:G,children:S()}),ne.map(e=>(0,U.jsx)(k,{value:e,children:e},e))]})]})]}),(0,U.jsx)(B,{fields:K,seed:p,onChange:Q}),(0,U.jsx)(V,{title:h(),rows:$,emptyHint:_(),columns:[{header:v(),cell:e=>E(e.at),sort:e=>e.at},{header:C(),cell:e=>e.action,sort:e=>e.action},{header:y(),cell:e=>e.realLabel,sort:e=>e.realLabel},{header:b(),cell:e=>e.targetLabel??`—`,sort:e=>e.targetLabel??null},{header:T(),cell:e=>e.resource?e.resource+(e.resourceId?` · ${e.resourceId.slice(0,8)}`:``):`—`,sort:e=>e.resource??null}]})]})}export{q as AuditTab};
@@ -0,0 +1 @@
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$O as r,Ak as i,As as a,Bk as o,CA as s,C_ as c,Ck as l,Dk as u,E as d,Ek as f,Fk as p,GO as m,HX as h,Ik as ee,JO as g,KO as _,Lk as te,Mk as ne,Nk as re,Ok as ie,Pk as ae,QO as v,Rk as oe,SA as se,S_ as ce,Sk as le,Su as ue,Tk as de,UO as fe,VX as pe,Vk as me,WO as y,XO as he,YO as ge,ZO as _e,_A as ve,__ as ye,_k as be,_u as xe,ak as Se,bA as Ce,b_ as we,bk as Te,ck as Ee,dk as De,ek as Oe,f_ as ke,fk as Ae,gA as je,g_ as Me,gk as Ne,gu as Pe,hA as Fe,h_ as Ie,hk as Le,hu as Re,ik as ze,jk as Be,kk as Ve,lA as He,lk as Ue,mA as We,m_ as Ge,mk as Ke,nk as qe,o_ as Je,ok as Ye,oo as Xe,pA as Ze,p_ as Qe,pk as $e,qO as et,rk as b,sk as tt,t as x,tk as nt,uA as rt,uk as it,vA as at,v_ as ot,vk as S,vu as st,w_ as ct,wk as lt,x_ as ut,xk as dt,yA as ft,y_ as C,yk as pt,yu as mt,zX as ht,zk as gt}from"./api-Ca1H8N44.js";import{r as w}from"./dist-Bfmsr8JO.js";import{t as _t}from"./chevrons-up-down-DCwhEy5H.js";import{i as vt,n as T,o as yt,r as bt,s as xt}from"./FieldLabel-sEQ38rsG.js";import{t as E}from"./button-BbEZKLza.js";import{$t as D,At as O,Ct as St,Dt as Ct,Jn as wt,Jt as k,L as Tt,Mt as Et,Ot as Dt,Pn as A,St as j,Tt as Ot,Yt as kt,ar as M,at as At,bt as N,cn as jt,dr as P,fr as Mt,ft as Nt,it as Pt,jt as F,kn as I,on as Ft,or as It,ot as Lt,sn as Rt,sr as L,st as zt,vt as R,wt as Bt,xt as z,yt as B}from"./index-bizOs74t.js";import{r as Vt}from"./locales-CPjguROj.js";import{a as Ht,i as V,n as Ut,o as H,r as U,t as Wt}from"./table-BrECCZpB.js";import{t as Gt}from"./FilterBar-PBFn9z0b.js";import{c as Kt,i as qt,n as Jt,o as Yt,r as Xt,s as Zt,t as Qt}from"./compatView-BDU79WFh.js";import{t as W}from"./dispatchErrorInfo-CoXI4U8X.js";var $t=d(`refresh-cw`,[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]),en=d(`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 tn(e){return e.filter(e=>e.state===`error`)}function nn(e){return e.reachable&&tn(e.targets).length===0}function rn(e){return nn(e)?(e.unreachableInstances??[]).length>0?`gateways_unreachable`:`ok`:`error`}function an(e){return e.state===`error`&&e.lastErrorCode!==null}function on(e){return!!e.lastDownstreamRejectCode}function sn(e){return!!e.lastLocalRefusalCode}function cn(e){return an(e)||on(e)||sn(e)}function K(e){return e.kind??`openclaw`}function ln(e){return[...e].sort((e,t)=>e===`openclaw`?-1:t===`openclaw`?1:e.localeCompare(t))}function un(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 ln(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__`,dn={q:``,state:J,instance:J,version:J},Y={connected:0,error:1,idle:2};function fn(e){return e.q.trim()!==``||e.state!==`__all__`||e.instance!==`__all__`||e.version!==`__all__`}function pn(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 mn(e,t){return e===`version`?t.gatewayVersion===null:e===`lastOk`?t.lastOkAt===null:!1}function hn(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 Zt(e,r)??X(e,r)}case`lastOk`:return t.lastOkAt-n.lastOkAt;default:return X(t.targetLabel,n.targetLabel)}}function gn(e,t){if(!t)return e;let n=t.dir===`asc`?1:-1;return[...e].sort((e,r)=>{let i=mn(t.key,e),a=mn(t.key,r);return i&&a?0:i?1:a?-1:n*hn(t.key,e,r)})}function _n(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 vn(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 yn(e){let t=new Set;for(let n of e)n.gatewayVersion!==null&&t.add(n.gatewayVersion);return[...t].sort((e,t)=>Zt(e,t)??X(e,t))}var Z=n();function bn({connections:e,displayByInstance:t}){let[n,i]=(0,G.useState)(dn),[a,o]=(0,G.useState)(null),s=(0,G.useMemo)(()=>e.map((e,n)=>({_id:`${e.key}:${e.canonical}/${e.agentId}:${n}`,targetLabel:`${e.canonical}/${e.agentId}`,state:e.state,instanceName:e.instanceName??null,instanceLabel:e.instanceName?t.get(e.instanceName)??e.instanceName:null,gatewayHost:e.gatewayHost,gatewayVersion:e.gatewayVersion??null,okCount:e.okCount,errorCount:e.errorCount+(e.downstreamRejectCount??0)+(e.localRefusalCount??0),attempts:e.attempts,lastOkAt:e.lastOkAt??null,lastErrorCode:e.lastErrorCode??null,lastErrorAt:e.lastErrorAt??null,lastDownstreamRejectCode:e.lastDownstreamRejectCode??null,lastDownstreamRejectAt:e.lastDownstreamRejectAt??null,lastLocalRefusalCode:e.lastLocalRefusalCode??null,lastLocalRefusalAt:e.lastLocalRefusalAt??null})),[e,t]),c=(0,G.useMemo)(()=>_n(s),[s]),l=(0,G.useMemo)(()=>vn(s),[s]),u=(0,G.useMemo)(()=>yn(s),[s]),d=(0,G.useMemo)(()=>gn(pn(s,n),a),[s,n,a]);function f(e){o(t=>t?.key===e?t.dir===`asc`?{key:e,dir:`desc`}:null:{key:e,dir:`asc`})}return e.length===0?(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:tt()}):(0,Z.jsxs)(`div`,{className:`oc-conn`,children:[(0,Z.jsxs)(Gt,{q:n.q,onQChange:e=>i(t=>({...t,q:e})),searchPlaceholder:ze(),onReset:()=>i(dn),canReset:fn(n),children:[(0,Z.jsxs)(R,{value:n.state,onValueChange:e=>i(t=>({...t,state:e})),children:[(0,Z.jsx)(z,{size:`sm`,className:`w-36`,children:(0,Z.jsx)(j,{placeholder:qe()})}),(0,Z.jsxs)(B,{children:[(0,Z.jsx)(N,{value:J,children:b()}),c.map(e=>(0,Z.jsx)(N,{value:e,children:Sn(e)},e))]})]}),(0,Z.jsxs)(R,{value:n.instance,onValueChange:e=>i(t=>({...t,instance:e})),children:[(0,Z.jsx)(z,{size:`sm`,className:`w-40`,children:(0,Z.jsx)(j,{placeholder:nt()})}),(0,Z.jsxs)(B,{children:[(0,Z.jsx)(N,{value:J,children:b()}),l.map(e=>(0,Z.jsx)(N,{value:e.name,children:e.label},e.name))]})]}),(0,Z.jsxs)(R,{value:n.version,onValueChange:e=>i(t=>({...t,version:e})),children:[(0,Z.jsx)(z,{size:`sm`,className:`w-36`,children:(0,Z.jsx)(j,{placeholder:Oe()})}),(0,Z.jsxs)(B,{children:[(0,Z.jsx)(N,{value:J,children:b()}),u.map(e=>(0,Z.jsx)(N,{value:e,children:e},e))]})]})]}),d.length===0?(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:r()}):(0,Z.jsxs)(Wt,{className:`oc-conn__table`,children:[(0,Z.jsx)(Ht,{children:(0,Z.jsxs)(H,{children:[(0,Z.jsx)(Q,{label:v(),sortKey:`target`,sort:a,onSort:f}),(0,Z.jsx)(Q,{label:_e(),sortKey:`state`,sort:a,onSort:f}),(0,Z.jsx)(Q,{label:he(),sortKey:`instance`,sort:a,onSort:f}),(0,Z.jsx)(Q,{label:ge(),sortKey:`host`,sort:a,onSort:f}),(0,Z.jsx)(Q,{label:g(),sortKey:`version`,sort:a,onSort:f}),(0,Z.jsx)(V,{children:et()}),(0,Z.jsx)(Q,{label:_(),sortKey:`lastOk`,sort:a,onSort:f})]})}),(0,Z.jsx)(Ut,{children:d.map(e=>(0,Z.jsx)(xn,{r:e},e._id))})]})]})}function Q({label:e,sortKey:t,sort:n,onSort:r}){let i=n?.key===t,a=i?n.dir:null;return(0,Z.jsx)(V,{"aria-sort":i?a===`asc`?`ascending`:`descending`:`none`,children:(0,Z.jsxs)(`button`,{type:`button`,className:`oc-conn__sort`,onClick:()=>r(t),children:[e,i?a===`asc`?(0,Z.jsx)(It,{size:13,"aria-hidden":!0}):(0,Z.jsx)(w,{size:13,"aria-hidden":!0}):(0,Z.jsx)(_t,{size:13,"aria-hidden":!0,className:`oc-conn__sort-idle`})]})})}function xn({r:e}){let t=an(e)?W(e.lastErrorCode):null,n=on(e)?W(e.lastDownstreamRejectCode):null,r=sn(e)?W(e.lastLocalRefusalCode):null;return(0,Z.jsxs)(G.Fragment,{children:[(0,Z.jsxs)(H,{className:`oc-conn__row oc-conn__row--${e.state}`,children:[(0,Z.jsx)(U,{children:(0,Z.jsx)(`code`,{className:`oc-traces__mono`,children:e.targetLabel})}),(0,Z.jsx)(U,{children:(0,Z.jsx)(Cn,{state:e.state})}),(0,Z.jsx)(U,{children:e.instanceLabel?(0,Z.jsx)(`span`,{className:`oc-bridge-target__instance`,children:e.instanceLabel}):(0,Z.jsx)(`span`,{className:`oc-traces__muted`,children:`—`})}),(0,Z.jsx)(U,{children:(0,Z.jsx)(`span`,{className:`oc-bridge-target__host`,children:e.gatewayHost})}),(0,Z.jsx)(U,{children:e.gatewayVersion?(0,Z.jsx)(`span`,{className:`oc-bridge-target__version`,children:e.gatewayVersion}):(0,Z.jsx)(`span`,{className:`oc-traces__muted`,children:`—`})}),(0,Z.jsx)(U,{children:(0,Z.jsx)(`span`,{className:`oc-conn__stats`,children:Ye({ok:e.okCount,errors:e.errorCount,attempts:e.attempts})})}),(0,Z.jsx)(U,{children:e.lastOkAt?(0,Z.jsx)(`span`,{className:`oc-traces__mono`,children:F(e.lastOkAt)}):(0,Z.jsx)(`span`,{className:`oc-traces__muted`,children:`—`})})]}),cn(e)?(0,Z.jsx)(H,{className:`oc-conn__detail-row`,children:(0,Z.jsxs)(U,{colSpan:7,className:`oc-conn__detail-cell`,children:[t?(0,Z.jsxs)(`div`,{className:`oc-bridge-target__error`,children:[(0,Z.jsx)(`strong`,{children:t.label}),` `,(0,Z.jsx)(`code`,{className:`oc-traces__mono`,children:e.lastErrorCode}),e.lastErrorAt?` · ${F(e.lastErrorAt)}`:``,(0,Z.jsx)(`p`,{className:`oc-bridge-card__hint`,children:t.hint})]}):null,r?(0,Z.jsxs)(`div`,{className:`oc-bridge-target__downstream`,children:[Xe({label:r.label}),` `,(0,Z.jsx)(`code`,{className:`oc-traces__mono`,children:e.lastLocalRefusalCode}),e.lastLocalRefusalAt?` · ${F(e.lastLocalRefusalAt)}`:``,(0,Z.jsx)(`p`,{className:`oc-bridge-card__hint`,children:r.hint})]}):null,n?(0,Z.jsxs)(`div`,{className:`oc-bridge-target__downstream`,children:[Se({label:n.label}),` `,(0,Z.jsx)(`code`,{className:`oc-traces__mono`,children:e.lastDownstreamRejectCode}),e.lastDownstreamRejectAt?` · ${F(e.lastDownstreamRejectAt)}`:``]}):null]})}):null]})}function Sn(e){return e===`connected`?m():e===`error`?y():fe()}function Cn({state:e}){return e===`connected`?(0,Z.jsx)(k,{variant:`secondary`,children:m()}):e===`error`?(0,Z.jsx)(k,{variant:`destructive`,children:y()}):(0,Z.jsx)(k,{variant:`outline`,children:fe()})}function wn(){return h(x.bridgeHealth.getBridgeHealth,{})}function Tn(){let e=wn(),t=h(x.compat.getBridgeCompat,{}),n=h(x.me.getMe,{host:Nt})?.role===`admin`,r=h(x.admin.listInstances,n?{}:`skip`),i=h(x.agents.usageForInstances,n?{}:`skip`),a=P(),o=()=>void a({to:`/settings/anomalies`,search:{status:`open`}}),s=un(e?e.targets:[],t?t.targets:[],r??[]),{section:c}=Mt({from:`/settings/bridge`}),l=P({from:`/settings/bridge`}),d=t?.compat??null,p=t===void 0?`loading`:t===null?`nodata`:`ready`,m=d!==null&&Xt(d,`hermes`)&&!s.some(e=>e.key===`hermes`);return(0,Z.jsxs)(`div`,{className:`oc-bridge`,children:[(0,Z.jsx)(En,{health:e,compat:t,onSeeAnomalies:o}),(0,Z.jsx)(`p`,{className:`oc-admin__hint oc-bridge__caption`,children:u()}),i&&i.length>0?(0,Z.jsxs)(`section`,{className:`oc-bridge__usage`,children:[(0,Z.jsx)(`h3`,{className:`oc-bridge__usage-title`,children:f()}),(0,Z.jsxs)(Wt,{children:[(0,Z.jsx)(Ht,{children:(0,Z.jsxs)(H,{children:[(0,Z.jsx)(V,{children:mt()}),(0,Z.jsx)(V,{children:st()}),(0,Z.jsx)(V,{children:xe()}),(0,Z.jsx)(V,{children:Pe()}),(0,Z.jsx)(V,{children:Re()})]})}),(0,Z.jsx)(Ut,{children:i.flatMap(e=>{let t=Tt(e.usage,Date.now());return t?t.windows.map((t,n)=>(0,Z.jsxs)(H,{children:[(0,Z.jsx)(U,{className:`font-medium`,children:n===0?e.instanceName:``}),(0,Z.jsx)(U,{children:t.provider}),(0,Z.jsx)(U,{children:t.label}),(0,Z.jsx)(U,{children:(0,Z.jsxs)(k,{variant:t.percentLeft<=10?`destructive`:t.percentLeft<=25?`outline`:`secondary`,children:[t.percentLeft,`%`]})}),(0,Z.jsx)(U,{className:`text-muted-foreground`,children:t.resetText??`—`})]},`${e.instanceName}:${t.provider}:${t.label}`)):[]})})]})]}):null,s.length>0?(0,Z.jsxs)(Pt,{value:s.some(e=>e.key===c)?c:s[0]?.key??`openclaw`,onValueChange:e=>void l({search:{section:e},replace:!0}),children:[(0,Z.jsx)(Lt,{className:`w-full`,children:s.map(e=>(0,Z.jsxs)(zt,{value:e.key,className:`flex-1 gap-1.5`,children:[(0,Z.jsx)(A,{size:13,"aria-hidden":!0}),q(e.key)]},e.key))}),s.map(e=>(0,Z.jsx)(At,{value:e.key,children:(0,Z.jsx)(Dn,{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,Z.jsx)(`p`,{className:`oc-admin__hint`,children:Je()}):null]})}function En({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,Z.jsxs)(`span`,{className:`oc-bridge-card__ver`,children:[(0,Z.jsx)(`code`,{className:`oc-traces__mono`,children:Yt(t.bridgeVersion)}),i?(0,Z.jsxs)(Z.Fragment,{children:[` `,(0,Z.jsxs)(`code`,{className:`oc-traces__mono`,title:ce(),children:[`(`,i,`)`]})]}):null,r?(0,Z.jsxs)(`strong`,{className:`oc-bridge-card__mismatch`,children:[` `,ut({build:t.buildVersion??`?`})]}):null,` · `,we(),` `,(0,Z.jsx)(`code`,{className:`oc-traces__mono`,children:t.protocolVersion===null?C():String(t.protocolVersion)})]}):null;if(e===void 0)return(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:S()});if(e===null)return(0,Z.jsx)(`div`,{className:`oc-bridge-card oc-bridge-card--idle`,children:be()});let o=tn(e.targets),s=!e.reachable,c=rn(e),l=e.unreachableInstances??[],u=c===`ok`?`ok`:c===`gateways_unreachable`?`warn`:`error`,d=O(e.checkedAt),f=e.startedAt==null?null:O(e.startedAt);return(0,Z.jsxs)(`div`,{className:`oc-bridge-card oc-bridge-card--${u}`,children:[(0,Z.jsx)(`div`,{className:`oc-bridge-card__icon`,"aria-hidden":!0,children:c===`ok`?(0,Z.jsx)(M,{size:22}):s||c===`gateways_unreachable`?(0,Z.jsx)(en,{size:22}):(0,Z.jsx)(I,{size:22})}),(0,Z.jsxs)(`div`,{className:`oc-bridge-card__body`,children:[(0,Z.jsx)(`div`,{className:`oc-bridge-card__title`,children:c===`ok`?Ne():c===`gateways_unreachable`?Ae({count:l.length}):s?Le():Ke({count:o.length})}),(0,Z.jsxs)(`div`,{className:`oc-bridge-card__meta`,children:[(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)($t,{size:12,"aria-hidden":!0}),` `,$e({time:d})]}),f?(0,Z.jsx)(`span`,{children:it({time:f})}):null,a]}),c===`gateways_unreachable`?(0,Z.jsx)(`p`,{className:`oc-bridge-card__hint`,children:De({names:l.join(`, `)})}):null,s?(0,Z.jsx)(`p`,{className:`oc-bridge-card__hint`,children:W(e.lastError===`not_configured`?`NOT_CONFIGURED`:`BRIDGE_UNREACHABLE`).hint}):null]}),(0,Z.jsx)(`button`,{type:`button`,className:`oc-bridgebar__drill`,onClick:n,children:Ue()})]})}function Dn({providerKey:e,connections:t,instances:n,manifest:r,compatStatus:i,compatReachable:a,protocol:o}){let s=r?Kt(r,e):null,c=new Map;for(let e of n)c.set(e.name,e.displayName??e.name);let l=[],u=new Set;for(let n of t){if(!n.instanceName||u.has(n.instanceName))continue;u.add(n.instanceName);let t=n.gatewayVersion??null;l.push({instanceName:n.instanceName,displayName:c.get(n.instanceName)??n.instanceName,version:t,state:Jt(t,e,r)})}let d=Qt(l.map(e=>e.state)),[f,p]=(0,G.useState)(!1);return(0,Z.jsxs)(`section`,{className:`oc-bridge-provider`,children:[(0,Z.jsxs)(`header`,{className:`oc-bridge-provider__head`,children:[(0,Z.jsx)(A,{size:15,"aria-hidden":!0,className:`oc-bridge-provider__icon`}),(0,Z.jsx)(`span`,{className:`oc-bridge-provider__name`,children:q(e)}),d?(0,Z.jsx)(k,{variant:d===`beyond`||d===`defective`||d===`unsupported`?`destructive`:`secondary`,children:qt(d)}):null]}),(0,Z.jsx)(`h4`,{className:`oc-bridge-provider__sub`,children:ct()}),(0,Z.jsx)(kn,{providerName:q(e),support:s,compatStatus:i,compatReachable:a,manifest:r,instanceRows:l}),o?(0,Z.jsx)(On,{protocol:o}):null,(0,Z.jsxs)(`button`,{type:`button`,className:`oc-bridge-provider__sub oc-bridge-provider__sub--toggle`,"aria-expanded":f,onClick:()=>p(e=>!e),children:[f?(0,Z.jsx)(w,{size:13,"aria-hidden":!0}):(0,Z.jsx)(L,{size:13,"aria-hidden":!0}),Ee({count:t.length})]}),f?(0,Z.jsx)(bn,{connections:t,displayByInstance:c}):null]})}function On({protocol:e}){let[t,n]=(0,G.useState)(!1),r=e.coverage,i=e.drift??[],o=(e.driftOverflow??0)+(e.driftTruncated??0);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`h4`,{className:`oc-bridge-provider__sub`,children:[de(),i.length>0?(0,Z.jsx)(k,{variant:`destructive`,children:l({count:i.length})}):o>0?(0,Z.jsx)(k,{variant:`destructive`,children:le()}):(0,Z.jsx)(k,{variant:`secondary`,children:lt()})]}),(0,Z.jsxs)(`p`,{className:`oc-admin__hint`,children:[dt({version:e.vendoredVersion}),r?` · `+Te({handled:r.handled,ignored:r.ignored,gaps:r.gaps}):null]}),o>0?(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:a({overflow:e.driftOverflow??0,truncated:e.driftTruncated??0})}):null,i.length>0?(0,Z.jsx)(`ul`,{className:`oc-bridge-protocol__list`,role:`list`,children:i.map(e=>(0,Z.jsxs)(`li`,{children:[(0,Z.jsx)(`code`,{className:`oc-traces__mono`,children:e.shape}),` × `,e.count]},e.shape))}):null,r&&r.gapList.length>0?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`button`,{type:`button`,className:`oc-bridge-provider__sub oc-bridge-provider__sub--toggle`,"aria-expanded":t,onClick:()=>n(e=>!e),children:[t?(0,Z.jsx)(w,{size:13,"aria-hidden":!0}):(0,Z.jsx)(L,{size:13,"aria-hidden":!0}),pt({count:r.gapList.length})]}),t?(0,Z.jsx)(`ul`,{className:`oc-bridge-protocol__list`,role:`list`,children:r.gapList.map(e=>(0,Z.jsx)(`li`,{children:(0,Z.jsx)(`code`,{className:`oc-traces__mono`,children:e})},e))}):null]}):null]})}function kn({support:e,compatStatus:t,compatReachable:n,manifest:r,instanceRows:i,providerName:a}){return t===`loading`?(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:S()}):t===`nodata`?(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:c()}):(0,Z.jsxs)(`div`,{className:`oc-compat`,children:[n?null:(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:ot()}),r===null?(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:ye()}):(0,Z.jsxs)(`div`,{className:`oc-compat__support`,children:[(0,Z.jsx)(`span`,{className:`oc-compat__label`,children:ue({provider:a})}),e&&e.range!==null?(0,Z.jsx)(`span`,{children:Me({min:e.range.min,max:e.range.maxValidated})}):(0,Z.jsx)(`span`,{children:C()}),e?(0,Z.jsx)(Mn,{versions:e.validatedVersions}):null]}),i.length===0?(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:ke()}):(0,Z.jsx)(`div`,{className:`oc-compat__targets`,children:i.map(e=>(0,Z.jsxs)(`div`,{className:`oc-compat__target`,children:[(0,Z.jsx)(`span`,{className:`oc-compat__instance`,children:e.displayName}),(0,Z.jsx)(`code`,{className:`oc-traces__mono`,children:Yt(e.version)}),(0,Z.jsx)(k,{variant:e.state===`supported`?`secondary`:e.state===`beyond`||e.state===`defective`||e.state===`unsupported`?`destructive`:`outline`,children:qt(e.state)})]},e.instanceName))})]})}function An({instance:e,onClose:t}){return(0,Z.jsx)(St,{open:!0,onOpenChange:e=>!e&&t(),children:(0,Z.jsxs)(Bt,{className:`oc-bridge-config-dialog`,onOpenAutoFocus:e=>e.preventDefault(),children:[(0,Z.jsxs)(Ct,{children:[(0,Z.jsx)(Dt,{children:s({instance:e.displayName??e.name})}),(0,Z.jsx)(Ot,{children:se()})]}),(0,Z.jsx)(jn,{instance:e,onClose:t})]})})}function $({label:e,result:t}){return t?t.checked?(0,Z.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,Z.jsx)(M,{"aria-hidden":!0}):(0,Z.jsx)(I,{"aria-hidden":!0}),(0,Z.jsxs)(`span`,{children:[e,` — `,t.ok?Be():t.detail]})]}):(0,Z.jsxs)(`p`,{className:`oc-bridge-config__check-row oc-bridge-config__check-row--skip`,children:[e,` — `,i()]}):null}function jn({instance:e,onClose:t}){let n=pe(x.admin.upsertInstanceConfig),r=ht(x.bridge.validateMediaPaths),i=kt(),a=Vt(e.config?.contentLocale,void 0),[s,c]=(0,G.useState)(()=>vt(e.config??{},a)),[l,u]=(0,G.useState)(!1),[d,f]=(0,G.useState)(!1),[m,h]=(0,G.useState)(null),g=s.inboundMediaMode===`shared-fs`,_=s.mediaMode===`shared-fs`,v=g||_;async function se(){f(!0),h(null);try{h(await r({instanceName:e.name,inboundMediaMode:s.inboundMediaMode,mediaMode:s.mediaMode}))}catch(e){i.error(p(),e)}finally{f(!1)}}async function ce(){u(!0);try{let r=e.config??{};await n({instanceId:e._id,config:bt(s,r,a)}),t()}catch(e){i.error(Fe(),e)}finally{u(!1)}}return(0,Z.jsx)(`div`,{className:`oc-bridge-config`,children:(0,Z.jsxs)(`div`,{className:`oc-bridge-config__form`,children:[(0,Z.jsxs)(`div`,{className:`oc-bridge-config__grid`,children:[(0,Z.jsxs)(`label`,{className:`oc-field`,children:[(0,Z.jsx)(T,{label:Ce(),help:We()}),(0,Z.jsxs)(R,{value:s.mediaMode,onValueChange:e=>c({...s,mediaMode:e}),children:[(0,Z.jsx)(z,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(j,{})}),(0,Z.jsx)(B,{children:xt.map(e=>(0,Z.jsx)(N,{value:e,children:e},e))})]})]}),(0,Z.jsxs)(`label`,{className:`oc-field`,children:[(0,Z.jsx)(T,{label:ft(),help:Ze()}),(0,Z.jsxs)(R,{value:s.inboundMediaMode,onValueChange:e=>c({...s,inboundMediaMode:e}),children:[(0,Z.jsx)(z,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(j,{})}),(0,Z.jsx)(B,{children:yt.map(e=>(0,Z.jsx)(N,{value:e,children:e},e))})]})]}),(0,Z.jsxs)(`label`,{className:`oc-field`,children:[(0,Z.jsx)(T,{label:at(),help:rt()}),(0,Z.jsx)(D,{type:`number`,min:1,max:4096,className:`w-full`,value:s.mediaMaxMb,onChange:e=>c({...s,mediaMaxMb:Math.trunc(Number(e.target.value)||0)})})]})]}),v&&(0,Z.jsxs)(`div`,{className:`oc-bridge-config__grid`,children:[g&&(0,Z.jsxs)(`label`,{className:`oc-field`,children:[(0,Z.jsx)(T,{label:me(),help:o()}),(0,Z.jsx)(D,{className:`w-full`,spellCheck:!1,value:s.inboundAgentMount,onChange:e=>c({...s,inboundAgentMount:e.target.value})})]}),_&&(0,Z.jsxs)(`label`,{className:`oc-field`,children:[(0,Z.jsx)(T,{label:gt(),help:oe()}),(0,Z.jsx)(D,{className:`w-full`,spellCheck:!1,value:s.outboundAgentMount,onChange:e=>c({...s,outboundAgentMount:e.target.value})})]})]}),(0,Z.jsxs)(`label`,{className:`oc-field--row`,children:[(0,Z.jsx)(Et,{checked:s.rehydration,onCheckedChange:e=>c({...s,rehydration:e===!0})}),(0,Z.jsx)(T,{label:ve(),help:He()})]}),v&&m!==null&&(0,Z.jsx)(`div`,{className:`oc-bridge-config__check`,children:m.reachable?!m.inbound&&!m.outbound?(0,Z.jsxs)(`p`,{className:`oc-bridge-config__check-row oc-bridge-config__check-row--err`,children:[(0,Z.jsx)(I,{"aria-hidden":!0}),ie({reason:m.reason??`?`})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)($,{label:re(),result:m.inbound}),(0,Z.jsx)($,{label:ne(),result:m.outbound}),(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:ae()})]}):(0,Z.jsxs)(`p`,{className:`oc-bridge-config__check-row oc-bridge-config__check-row--err`,children:[(0,Z.jsx)(I,{"aria-hidden":!0}),Ve()]})}),(0,Z.jsxs)(`div`,{className:`oc-bridge-config__actions`,children:[v&&(0,Z.jsxs)(E,{variant:`outline`,size:`sm`,onClick:()=>void se(),disabled:d,children:[d?(0,Z.jsx)(wt,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,d?ee():te()]}),(0,Z.jsx)(E,{size:`sm`,onClick:()=>void ce(),disabled:l,children:je()})]})]})})}function Mn({versions:e}){if(e.length===0)return null;let t=[...e].reverse();return(0,Z.jsxs)(Ft,{children:[(0,Z.jsx)(jt,{asChild:!0,children:(0,Z.jsxs)(`button`,{type:`button`,className:`oc-compat__versions-btn`,children:[e.length===1?Ie():Ge({count:e.length}),(0,Z.jsx)(w,{size:13,"aria-hidden":!0})]})}),(0,Z.jsxs)(Rt,{className:`oc-compat__versions-pop`,align:`start`,children:[(0,Z.jsx)(`p`,{className:`oc-compat__versions-title`,children:Qe()}),(0,Z.jsx)(`div`,{className:`oc-compat__versions-list`,children:t.map(e=>(0,Z.jsx)(k,{variant:`secondary`,children:e},e))})]})]})}export{Tn as BridgeTab,An as InstanceConfigDialog};
@@ -0,0 +1 @@
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{A_ as r,At as i,Bp as a,Bt as o,Ct as s,D_ as c,Dt as l,E_ as u,Et as d,Ft as f,Gp as p,HX as m,Hp as h,Ht as g,It as _,Jv as v,Kp as y,Lt as ee,MX as b,M_ as x,Mt as S,N_ as te,Nt as C,O_ as ne,Ot as re,Pt as w,Rp as T,Rt as ie,St as ae,T_ as E,Tt as oe,Up as se,Ut as ce,Uv as le,VX as D,Vp as ue,Vt as de,Wp as O,Wt as k,Wv as fe,Xv as A,bt as pe,j_ as me,jt as he,k_ as ge,kt as _e,lv as j,qp as ve,t as M,wt as N,xA as P,xt as F,xu as ye,yt as be,zX as I,zp as xe,zt as Se}from"./api-Ca1H8N44.js";import{t as Ce}from"./use_paginated_query-C842MAhU.js";import{t as L}from"./button-BbEZKLza.js";import{$t as R,Mt as z,St as B,bt as V,kn as we,nt as Te,rt as Ee,tt as H,vt as U,xt as W,yt as G}from"./index-bizOs74t.js";import{a as De}from"./compatView-BDU79WFh.js";/* empty css */var K=t(e(),1),Oe=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`];function ke(e){let t=typeof e==`object`&&e?e:{},n=t.defaults!==null&&typeof t.defaults==`object`?t.defaults:{},r=n.thinkingDefault??t.thinkingDefault,i=n.fastModeDefault??t.fastModeDefault;return{thinkingDefault:typeof r==`string`?r:null,fastModeDefault:typeof i==`boolean`?i:null}}var q=[`auto`,`hybrid`,`tool`,`off`];function Ae(e){switch(e){case`auto`:return de();case`hybrid`:return o();case`tool`:return Se();default:return ie()}}function J(e){return{injection:e.injection??`auto`,defaultSources:e.defaultSources,...e.config?{config:e.config}:{}}}function Y(e){return typeof e==`string`&&q.includes(e)}function X(e){return{injection:Y(e.injection)?e.injection:`auto`,sources:e.defaultSources.filter(t=>e.sources.some(e=>e.id===t))}}function Z(e,t){let n=new Set(e);return n.size===new Set(t).size&&t.every(e=>n.has(e))}function je(e,t,n){let r=n?e.defaultWriteRefused===`scope_refused`?C():Me(e)?s():null:w(),i=X(e),a=t.injection!==i.injection||!Z(t.sources,i.sources),o=new Set(e.sources.map(e=>e.id)),c=t.sources.length>0&&t.sources.length<=16&&t.sources.every(e=>o.has(e));return{readOnlyReason:r,dirty:a,valid:c,invalidReason:c?null:_()}}function Me(e){return(e.contract??1)<2&&e.ownAllowlist===!1}function Ne(e,t,n){let r=t.sources.includes(n)?t.sources.filter(e=>e!==n):[...t.sources,n];return{...t,sources:e.sources.map(e=>e.id).filter(e=>r.includes(e))}}function Q(e){return e.ok?null:e.code===`scope_refused`?C():e.code===`stale_default`?S():e.code===`write_unknown`||e.code===`not_confirmed`?_e():e.code===`not_applied`?re():e.code===`default_too_large`?F():e.code===`allowlist_too_large`?ae():e.code===`plugin_too_old`?s():e.code===`source_not_allowed`?N():e.code===`plugin_config_lag`?oe():e.code===`knowledge_unavailable`&&e.reason===`plugin_absent`?f():he({code:e.code})}function Pe(e,t){let n=J(e),r=J(t);if(n.injection!==r.injection||!Z(n.defaultSources,r.defaultSources))return!0;let i=n.config,a=r.config;return i===void 0||a===void 0?i!==a:i.injection!==a.injection||!((e,t)=>e===null||t===null?e===t:e.length===t.length&&e.every((e,n)=>e===t[n]))(i.sources,a.sources)}var $=n();function Fe({instanceName:e,row:t,supported:n}){let r=I(M.knowledge.setAgentKnowledgeDefault),[a,o]=(0,K.useState)(t),[s,l]=(0,K.useState)(()=>X(t)),[d,f]=(0,K.useState)(`idle`),[p,m]=(0,K.useState)(null),[h,_]=(0,K.useState)(!1),v=e=>{o(e),l(X(e)),m(null)},y=Pe(a,t);(0,K.useEffect)(()=>{h&&y&&(_(!1),v(t))},[h,y]);let b=je(a,s,n),x=b.readOnlyReason===null;async function S(){f(`saving`),m(null);try{let n=Q(await r({instanceName:e,agentId:t.agentId,injection:s.injection,sources:s.sources,expected:J(a)}));m(n),f(n===null?`done`:`idle`),n===null&&_(!0)}catch(e){m(Q({ok:!1,code:String(e?.message??`error`).slice(0,60)})),f(`idle`)}}return(0,$.jsxs)(`div`,{className:`oc-cdefaults__row`,"data-knowledge-agent":t.agentId,children:[(0,$.jsx)(`span`,{className:`oc-cdefaults__label`,children:t.agentId}),(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`oc-cdefaults__inline`,children:(0,$.jsxs)(U,{value:s.injection,onValueChange:e=>{Y(e)&&l({...s,injection:e})},disabled:!x,children:[(0,$.jsx)(W,{className:`oc-cdefaults__select`,"aria-label":g(),children:(0,$.jsx)(B,{})}),(0,$.jsx)(G,{children:q.map(e=>(0,$.jsx)(V,{value:e,children:Ae(e)},e))})]})}),(0,$.jsx)(`span`,{className:`oc-cdefaults__label`,children:ee()}),t.sources.map(e=>(0,$.jsxs)(`label`,{className:`oc-cdefaults__inline`,style:{cursor:x?`pointer`:`default`},title:e.description||void 0,children:[(0,$.jsx)(z,{checked:s.sources.includes(e.id),onCheckedChange:()=>l(Ne(t,s,e.id)),disabled:!x,"aria-label":e.label,"data-knowledge-default-source":e.id}),(0,$.jsx)(`span`,{children:e.label})]},e.id)),y&&!h?(0,$.jsxs)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:[pe(),` `,(0,$.jsx)(L,{variant:`outline`,size:`sm`,onClick:()=>v(t),children:be()})]}):null,t.overridesAllowed?null:(0,$.jsx)(`p`,{className:`oc-cdefaults__help`,children:i()}),x?(0,$.jsx)(`div`,{className:`oc-cdefaults__inline`,children:(0,$.jsx)(L,{size:`sm`,disabled:!b.dirty||!b.valid||d===`saving`,onClick:()=>void S(),children:d===`saving`?A():c()})}):(0,$.jsx)(`p`,{className:`oc-cdefaults__note`,children:b.readOnlyReason}),x&&b.dirty&&b.invalidReason!==null?(0,$.jsx)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:b.invalidReason}):null,d===`done`&&p===null?(0,$.jsx)(`p`,{className:`oc-admin__hint`,role:`status`,children:u()}):null,p===null?null:(0,$.jsx)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:p})]})]})}function Ie({instanceName:e}){let t=m(M.knowledge.knowledgeAdminInstance,{instanceName:e}),{results:n,status:r,loadMore:i}=Ce(M.knowledge.agentKnowledgePage,{instanceName:e},{initialNumItems:50});return t===void 0||t.provider!==`openclaw`||n.length===0&&r!==`CanLoadMore`?null:(0,$.jsxs)(`section`,{className:`oc-cdefaults__row`,"aria-label":k(),children:[(0,$.jsx)(`span`,{className:`oc-cdefaults__label`,children:k()}),(0,$.jsx)(`p`,{className:`oc-admin__hint`,children:ce()}),t.supported?null:(0,$.jsx)(`p`,{className:`oc-cdefaults__note`,children:w()}),n.map(n=>(0,$.jsx)(Fe,{instanceName:e,row:n,supported:t.supported},n.agentId)),r===`CanLoadMore`||r===`LoadingMore`?(0,$.jsxs)(`div`,{className:`oc-cdefaults__inline`,children:[(0,$.jsx)(`p`,{className:`oc-admin__hint`,children:l({shown:n.length})}),(0,$.jsx)(L,{variant:`outline`,size:`sm`,disabled:r===`LoadingMore`,onClick:()=>i(50),"data-knowledge-load-more":!0,children:d()})]}):null]})}function Le({instance:e}){let t=D(M.admin.upsertInstanceConfig),n=m(M.agents.listAgentsForInstance,{instanceName:e.name}),r=typeof e.config?.converterAgentId==`string`?e.config.converterAgentId:``,[i,a]=(0,K.useState)(r),[o,s]=(0,K.useState)(`idle`);(0,K.useEffect)(()=>{a(r),s(`idle`)},[e._id,r]);let l=`__none__`,d=i!==r;async function f(){s(`saving`);try{let n={...e.config??{}};i===``||i===l?delete n.converterAgentId:n.converterAgentId=i,await t({instanceId:e._id,config:n}),s(`done`)}catch{s(`error`)}}let p=n?.agents??[];return(0,$.jsxs)(`div`,{className:`oc-cdefaults__row`,children:[(0,$.jsx)(`span`,{className:`oc-cdefaults__label`,children:O()}),(0,$.jsx)(`p`,{className:`oc-admin__hint`,children:se()}),(0,$.jsxs)(`div`,{className:`oc-cdefaults__inline`,children:[(0,$.jsxs)(U,{value:i===``?l:i,onValueChange:e=>a(e===l?``:e),children:[(0,$.jsx)(W,{className:`oc-cdefaults__select`,"aria-label":O(),children:(0,$.jsx)(B,{placeholder:h()})}),(0,$.jsxs)(G,{children:[(0,$.jsx)(V,{value:l,children:h()}),p.map(e=>(0,$.jsx)(V,{value:e.agentId,children:e.displayName?`${e.displayName} (${e.agentId})`:e.agentId},e.agentId))]})]}),(0,$.jsx)(L,{size:`sm`,disabled:!d||o===`saving`,onClick:()=>void f(),children:o===`saving`?A():c()})]}),o===`done`?(0,$.jsx)(`p`,{className:`oc-admin__hint`,role:`status`,children:u()}):null,o===`error`?(0,$.jsx)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:E()}):null]})}function Re({instance:e}){let t=D(M.admin.upsertInstanceConfig),n=e.config?.curationEnabled===!0,r=typeof e.config?.curationBudgetChars==`number`?e.config.curationBudgetChars:null,[i,o]=(0,K.useState)(n),[s,l]=(0,K.useState)(r===null?``:String(r)),[d,f]=(0,K.useState)(`idle`);(0,K.useEffect)(()=>{o(n),l(r===null?``:String(r)),f(`idle`)},[e._id,n,r]);let m=s.trim(),h=m===``?null:/^\d+$/.test(m)?Number.parseInt(m,10):NaN,g=!i||h===null||Number.isInteger(h)&&h>=4e3&&h<=6e4,_=i!==n||(h??null)!==r;async function v(){f(`saving`);try{let n={...e.config??{}};n.curationEnabled=i,!i||h===null||Number.isNaN(h)?delete n.curationBudgetChars:n.curationBudgetChars=h,await t({instanceId:e._id,config:n}),f(`done`)}catch{f(`error`)}}return(0,$.jsxs)(`div`,{className:`oc-cdefaults__row`,children:[(0,$.jsxs)(`label`,{className:`oc-cdefaults__inline`,style:{cursor:`pointer`},children:[(0,$.jsx)(z,{checked:i,onCheckedChange:e=>o(e===!0),"aria-label":p()}),(0,$.jsx)(`span`,{className:`oc-cdefaults__label`,children:p()})]}),(0,$.jsxs)(`div`,{className:`oc-cdefaults__inline`,children:[(0,$.jsx)(R,{type:`number`,min:4e3,max:6e4,step:1e3,placeholder:`20000`,value:s,onChange:e=>l(e.target.value),className:`oc-cdefaults__number`,"aria-invalid":!g,"aria-label":ue(),disabled:!i}),(0,$.jsx)(L,{size:`sm`,disabled:!_||!g||d===`saving`,onClick:()=>void v(),children:d===`saving`?A():c()})]}),g?null:(0,$.jsx)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:a()}),d===`done`?(0,$.jsx)(`p`,{className:`oc-admin__hint`,role:`status`,children:u()}):null,d===`error`?(0,$.jsx)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:E()}):null,(0,$.jsx)(`p`,{className:`oc-cdefaults__help`,children:xe()})]})}function ze({instance:e}){let t=D(M.admin.upsertInstanceConfig),n=typeof e.config?.summarizeThresholdChars==`number`?e.config.summarizeThresholdChars:null,[r,i]=(0,K.useState)(n===null?``:String(n)),[a,o]=(0,K.useState)(`idle`);(0,K.useEffect)(()=>{i(n===null?``:String(n)),o(`idle`)},[e._id,n]);let s=r.trim(),l=s===``?null:/^\d+$/.test(s)?Number.parseInt(s,10):NaN,d=l===null||Number.isInteger(l)&&l>=1e3&&l<=2e5,f=(l??null)!==n;async function p(){o(`saving`);try{let n={...e.config??{}};l===null?delete n.summarizeThresholdChars:n.summarizeThresholdChars=l,await t({instanceId:e._id,config:n}),o(`done`)}catch{o(`error`)}}return(0,$.jsxs)(`div`,{className:`oc-cdefaults__row`,children:[(0,$.jsx)(`span`,{className:`oc-cdefaults__label`,children:ve()}),(0,$.jsxs)(`div`,{className:`oc-cdefaults__inline`,children:[(0,$.jsx)(R,{type:`number`,min:1e3,max:2e5,step:1e3,placeholder:`8000`,value:r,onChange:e=>i(e.target.value),className:`oc-cdefaults__number`,"aria-invalid":!d}),(0,$.jsx)(L,{size:`sm`,disabled:!f||!d||a===`saving`,onClick:()=>void p(),children:a===`saving`?A():c()})]}),d?null:(0,$.jsx)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:T()}),a===`done`?(0,$.jsx)(`p`,{className:`oc-admin__hint`,role:`status`,children:u()}):null,a===`error`?(0,$.jsx)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:E()}):null,(0,$.jsx)(`p`,{className:`oc-cdefaults__help`,children:y()})]})}function Be(){let e=I(M.agentFiles.getChatDefaults),[t,n]=(0,K.useState)({status:`loading`}),i=m(M.admin.listInstances,{}),[a,o]=(0,K.useState)(null);(0,K.useEffect)(()=>{!i||i.length===0||(!a||!i.some(e=>e.name===a))&&o(i[0].name)},[i,a]);let s=(i?.length??0)>1,c=i!==void 0&&i.length===0,l=m(M.compat.forInstance,a?{instanceName:a}:`skip`),u=a?Te(l,`configDefaults`):`loading`,d=u===`loading`?null:u.blocked,f=(0,K.useMemo)(()=>s&&a?{instanceName:a}:{},[s,a]),p=(0,K.useRef)(0),h=(0,K.useCallback)(async()=>{let t=++p.current;n({status:`loading`});try{let r=ke(await e(f));if(p.current!==t)return;n({status:`done`,current:r})}catch{if(p.current!==t)return;n({status:`error`})}},[e,f]);(0,K.useEffect)(()=>{d===!1&&(s&&!a||h())},[h,d,s,a]);let g=t.status===`done`?t.current:null,_=(0,K.useMemo)(()=>Oe.map(e=>({id:e,label:Ee(e)})),[]),y=(0,K.useMemo)(()=>[{id:`fast`,label:fe()},{id:`standard`,label:le()}],[]);return(0,$.jsxs)(`div`,{className:`oc-cdefaults`,children:[(0,$.jsx)(`p`,{className:`oc-admin__hint`,children:te()}),s&&a?(0,$.jsxs)(`div`,{className:`oc-cdefaults__row`,children:[(0,$.jsx)(`span`,{className:`oc-cdefaults__label`,children:j()}),(0,$.jsxs)(U,{value:a,onValueChange:e=>o(e),children:[(0,$.jsx)(W,{size:`sm`,"aria-label":j(),children:(0,$.jsx)(B,{})}),(0,$.jsx)(G,{children:(i??[]).map(e=>(0,$.jsx)(V,{value:e.name,children:e.name},e.name))})]})]}):null,c?(0,$.jsx)(`p`,{className:`oc-admin__hint`,role:`status`,children:P()}):u===`loading`?(0,$.jsx)(`p`,{className:`oc-admin__hint`,children:b()}):u.blocked?(0,$.jsxs)(`p`,{className:`oc-compat__blocked`,role:`status`,children:[(0,$.jsx)(we,{size:14,"aria-hidden":!0}),` `,De(u.gatewayVersion,u.provider)]}):t.status===`loading`?(0,$.jsx)(`p`,{className:`oc-admin__hint`,children:b()}):t.status===`error`?(0,$.jsxs)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:[ne(),` `,(0,$.jsx)(L,{variant:`outline`,size:`sm`,onClick:()=>void h(),children:v()})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`oc-cdefaults__row`,children:[(0,$.jsx)(`span`,{className:`oc-cdefaults__label`,children:x()}),(0,$.jsx)(H,{field:`thinkingLevel`,options:_,value:g?.thinkingDefault??null,onChange:()=>{},disabled:!0,ariaLabel:x()}),(0,$.jsx)(`p`,{className:`oc-cdefaults__help`,children:me()})]}),(0,$.jsxs)(`div`,{className:`oc-cdefaults__row`,children:[(0,$.jsx)(`span`,{className:`oc-cdefaults__label`,children:r()}),(0,$.jsx)(H,{field:`fastMode`,options:y,value:g===null||g.fastModeDefault===null?null:g.fastModeDefault?`fast`:`standard`,onChange:()=>{},disabled:!0,ariaLabel:r()}),(0,$.jsx)(`p`,{className:`oc-cdefaults__help`,children:ge()})]}),(0,$.jsx)(`p`,{className:`oc-cdefaults__note`,children:ye()})]}),(()=>{let e=i?.find(e=>e.name===(a??i[0]?.name));return e?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ze,{instance:e}),(0,$.jsx)(Re,{instance:e}),(0,$.jsx)(Le,{instance:e}),(0,$.jsx)(Ie,{instanceName:e.name})]}):null})()]})}export{Be as ChatDefaultsTab};
@@ -1 +1 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$S as r,QS as i,ZS as a,eC as o,nC as s,rC as c,tC as l}from"./api-Bem2UcWi.js";import{r as u}from"./dist-D8YXB9MB.js";import{t as d}from"./chevrons-up-down-BDtwl2PG.js";import{t as f}from"./button-BFCjIMMp.js";import{An as p,Ln as m,Mt as h,an as g,en as _,in as v,nn as y,or as b,tn as x,tr as S}from"./index-BfR5o8dt.js";import{a as C,i as w,n as T,o as E,r as D,t as O}from"./table-DJmLrBXF.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=c(),bulkActions:F,emptyHint:I=s(),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)(f,{size:`sm`,variant:e.variant===`destructive`?`destructive`:`outline`,onClick:()=>{e.onSelect([...z]),B(new Set)},children:[e.variant===`destructive`?(0,M.jsx)(p,{}):null,e.label,` (`,z.size,`)`]},e.label)):null,N?(0,M.jsxs)(f,{size:`sm`,onClick:N,children:[(0,M.jsx)(m,{}),` `,P]}):null]})]}),t===void 0?(0,M.jsx)(`p`,{className:`oc-admin__hint`,children:l()}):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)(h,{"aria-label":o(),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":a({column:e.header}),children:[e.header,n?V.dir===`asc`?(0,M.jsx)(b,{className:`oc-dt__sort-icon`,"aria-hidden":!0}):(0,M.jsx)(u,{className:`oc-dt__sort-icon`,"aria-hidden":!0}):(0,M.jsx)(d,{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)??[],a=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)(h,{"aria-label":r(),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)(f,{variant:`ghost`,size:`icon-sm`,"aria-label":i(),className:`opacity-0 transition-opacity group-hover/row:opacity-100 group-focus-within/row:opacity-100 aria-expanded:opacity-100`,children:(0,M.jsx)(S,{})})}),(0,M.jsx)(x,{align:`end`,children:t.map((t,n)=>(0,M.jsxs)(`div`,{children:[t.variant===`destructive`&&n>0?(0,M.jsx)(v,{}):null,(0,M.jsx)(y,{variant:t.variant,onSelect:()=>t.onSelect(e),children:t.label})]},t.label))})]}):null}):null]}),a&&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{SC as r,_C as i,bC as a,gC as o,vC as s,xC as c,yC as l}from"./api-Ca1H8N44.js";import{r as u}from"./dist-Bfmsr8JO.js";import{t as d}from"./chevrons-up-down-DCwhEy5H.js";import{t as f}from"./button-BbEZKLza.js";import{An as p,Ln as m,Mt as h,an as g,en as _,in as v,nn as y,or as b,tn as x,tr as S}from"./index-bizOs74t.js";import{a as C,i as w,n as T,o as E,r as D,t as O}from"./table-BrECCZpB.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=r(),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)(f,{size:`sm`,variant:e.variant===`destructive`?`destructive`:`outline`,onClick:()=>{e.onSelect([...z]),B(new Set)},children:[e.variant===`destructive`?(0,M.jsx)(p,{}):null,e.label,` (`,z.size,`)`]},e.label)):null,N?(0,M.jsxs)(f,{size:`sm`,onClick:N,children:[(0,M.jsx)(m,{}),` `,P]}):null]})]}),t===void 0?(0,M.jsx)(`p`,{className:`oc-admin__hint`,children:a()}):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)(h,{"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)(b,{className:`oc-dt__sort-icon`,"aria-hidden":!0}):(0,M.jsx)(u,{className:`oc-dt__sort-icon`,"aria-hidden":!0}):(0,M.jsx)(d,{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)??[],r=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)(h,{"aria-label":s(),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)(f,{variant:`ghost`,size:`icon-sm`,"aria-label":i(),className:`opacity-0 transition-opacity group-hover/row:opacity-100 group-focus-within/row:opacity-100 aria-expanded:opacity-100`,children:(0,M.jsx)(S,{})})}),(0,M.jsx)(x,{align:`end`,children:t.map((t,n)=>(0,M.jsxs)(`div`,{children:[t.variant===`destructive`&&n>0?(0,M.jsx)(v,{}):null,(0,M.jsx)(y,{variant:t.variant,onSelect:()=>t.onSelect(e),children:t.label})]},t.label))})]}):null}):null]}),r&&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};
@@ -0,0 +1 @@
1
+ import{r as e}from"./bundle-mjs-C73ZY4La.js";import{HE as t,ME as n,NE as r,PE as i,VE as a,VX as o,mj as s,t as c}from"./api-Ca1H8N44.js";import{t as l}from"./use_paginated_query-C842MAhU.js";import{t as u}from"./button-BbEZKLza.js";import{ct as d,h as f}from"./index-bizOs74t.js";import{n as p,t as m}from"./trashPage-Cq944d0w.js";var h=e();function g(){let{results:e,status:g,loadMore:_}=l(c.trash.listMyTrash,{},{initialNumItems:50}),v=f(),y=o(c.trash.restoreChat),b=o(c.trash.purgeChat),x=o(c.trash.emptyTrash),S=d();return(0,h.jsxs)(`div`,{className:`oc-trash__body`,children:[(0,h.jsxs)(`div`,{className:`oc-trash__head`,children:[(0,h.jsx)(`p`,{className:`oc-trash__hint`,children:t({days:v})}),e.length>0?(0,h.jsx)(u,{variant:`destructive`,size:`sm`,onClick:async()=>{await S({title:r(),description:n(),confirmLabel:i(),destructive:!0})&&await x({})},children:i()}):null]}),g===`LoadingFirstPage`?(0,h.jsx)(`p`,{className:`oc-trash__hint`,children:s()}):e.length===0?(0,h.jsx)(`p`,{className:`oc-trash__empty`,children:a()}):(0,h.jsx)(m,{items:e,onRestore:e=>y({chatId:e}),onPurge:e=>b({chatId:e})}),(0,h.jsx)(p,{status:g,loadMore:_})]})}export{g as DeletedChatsTab};
@@ -1 +1 @@
1
- import{r as e}from"./bundle-mjs-C73ZY4La.js";import{Jt as t}from"./index-BfR5o8dt.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{Jt as t}from"./index-bizOs74t.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};
@@ -0,0 +1 @@
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$I as r,$L as i,AL as a,BL as o,CL as s,DL as c,EL as l,FL as u,GL as d,HL as f,HX as p,IL as ee,JL as m,KL as h,LL as te,ML as ne,NL as g,OL as _,PL as re,QI as v,QL as y,RL as ie,SL as b,TL as ae,UL as x,VL as S,VX as C,WL as w,XL as T,YL as E,Yf as D,ZI as O,ZL as k,Zf as A,_L as j,aL as M,bL as N,cL as P,dL as F,eL as I,fL as L,gL as R,hL as z,iL as B,jL as V,kL as H,lL as U,mL as W,nL as oe,oL as G,pL as K,qL as q,rL as se,sL as ce,t as J,tL as le,uL as ue,vL as de,wL as fe,xL as pe,yL as me,zL as he}from"./api-Ca1H8N44.js";import{t as ge}from"./button-BbEZKLza.js";import{At as _e,ct as Y}from"./index-bizOs74t.js";import{t as ve}from"./DataTableShell-D_c2Z76f.js";var X=t(e(),1),Z=n(),ye={altered_words:()=>i(),incorrect:()=>y(),incoherence:()=>k(),formatting:()=>T(),latency:()=>E(),api_error:()=>m(),other:()=>q()},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:w()}):(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill`,children:`—`}):(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill`,children:h()})}function be({data:e,reference:t,closeReason:n}){let r=e.snapshot,i=C(J.feedback.respondToFeedback),[d,p]=(0,X.useState)(e.thread),[m,h]=(0,X.useState)(``),[v,y]=(0,X.useState)(!1);async function b(){let t=m.trim();if(!(!t||v)){y(!0);try{await i({feedbackId:e._id,text:t}),p(e=>[...e,{authorRole:`admin`,text:t,at:Date.now()}]),h(``)}finally{y(!1)}}}let w=[];try{w=r.contextJson?JSON.parse(r.contextJson):[]}catch{w=[]}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?` · ${x()}`:``,r.openclawModel?` · ${r.openclawModel}`:``,r.openclawRuntime?` (${r.openclawRuntime})`:``]}),t?(0,Z.jsx)(`code`,{className:`oc-fbadmin__ref`,style:{userSelect:`all`,marginLeft:`auto`},title:j(),children:t}):null]}),e.comment?(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:f()}),(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:se()}),(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:S()}),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`?o():e.authorRole===`agent`?e.authorLabel??A():he()}),(0,Z.jsx)(`span`,{className:`oc-notif__msg-text`,children:e.text})]},t))}):(0,Z.jsx)(`p`,{className:`oc-fbadmin__meta`,children:ie()}),(0,Z.jsx)(`textarea`,{className:`oc-feedback__textarea`,placeholder:te(),value:m,maxLength:2e3,rows:3,onChange:e=>h(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 b(),disabled:!m.trim()||v,children:v?ee():u()})})]}),(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:re()}),(0,Z.jsx)(`pre`,{className:`oc-msg__source-pre`,children:r.messageText||g()})]}),r.clientInfo?.sourceWasOpen&&r.displayedText!==void 0?(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:ne()}),(0,Z.jsx)(`pre`,{className:`oc-msg__source-pre`,children:r.displayedText||g()})]}):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,w.length>0?(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:a({count:r.contextCount??w.length,truncated:r.contextTruncated?H():``})}),(0,Z.jsx)(`div`,{className:`oc-fbadmin__ctx`,children:w.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:_()}),(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:c()}),(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:l()}),(0,Z.jsxs)(`p`,{className:`oc-fbadmin__env`,children:[[r.clientInfo?.language,r.clientInfo?.timezone,r.clientInfo?.theme?ae({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:[fe(),` `,r.clientInfo.plugins.join(`, `),(0,Z.jsxs)(`span`,{className:`oc-fbadmin__note`,children:[` `,s()]})]}):null,r.clientInfo?.userAgent?(0,Z.jsx)(`span`,{className:`oc-fbadmin__ua`,children:r.clientInfo.userAgent}):null]})]})]})}function xe(){let e=p(J.feedback.listForAdmin,{}),t=C(J.feedback.readSnapshot),n=C(J.feedback.deleteFeedback),i=Y(),[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:r(),description:v(),confirmLabel:O(),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:[b(),` `,(0,Z.jsx)(`strong`,{children:pe()}),` `,N()]}),(0,Z.jsx)(ve,{title:me(),rows:e,emptyHint:de(),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:R(),cell:e=>_e(e.at),sort:e=>e.at},{header:z(),cell:e=>Q(e.category),sort:e=>Q(e.category)},{header:W(),cell:e=>e.messageRole===`user`?K():L(),sort:e=>e.messageRole},{header:F(),cell:e=>(e.reporterEmail||e.reporterName||`—`)+(e.impersonated&&e.realOperatorEmail?` ${ue({operator:e.realOperatorEmail})}`:``),sort:e=>e.reporterEmail||e.reporterName||null},{header:U(),cell:e=>(0,Z.jsx)($,{matches:e.displayedMatchesStored,sourceWasOpen:e.sourceWasOpen}),sort:e=>e.displayedMatchesStored===!1?0:e.displayedMatchesStored===!0?1:2},{header:P(),cell:e=>e.hasComment?`✎`:`—`,sort:e=>+!!e.hasComment},{header:ce(),cell:e=>e.userClosedAt==null?e.resolvedAt==null?e.answered?(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill is-ok`,children:G()}):(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill`,children:M()}):(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill is-ok`,title:e.resolvedBy??void 0,children:D()}):(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill is-closed`,children:B()}),sort:e=>e.userClosedAt==null?e.resolvedAt==null?+!!e.answered:2:3}],rowActions:e=>[{label:a===e._id?oe():le(),onSelect:()=>void l(e)},{label:I(),onSelect:()=>void u(e),variant:`destructive`}]})]})}export{xe as FeedbacksTab};
@@ -1 +1 @@
1
- import{r as e}from"./bundle-mjs-C73ZY4La.js";import{AX as t,E as n}from"./api-Bem2UcWi.js";import{B as r,R as i,V as a,mn as o,pn as s,z as c}from"./index-BfR5o8dt.js";import"./locales-CPjguROj.js";import"./curation-CQksaIbm.js";var l=n(`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`}]]),u=[`gateway-http`,`shared-fs`,`off`],d=[`inline`,`shared-fs`],f=[`reactive`,`sse`],p=`reactive`;t.object({mediaMode:t.optional(t.union(t.literal(`gateway-http`),t.literal(`shared-fs`),t.literal(`off`))),inboundMediaMode:t.optional(t.union(t.literal(`inline`),t.literal(`shared-fs`))),rehydration:t.optional(t.boolean()),mediaMaxMb:t.optional(t.number()),attachmentFixAttested:t.optional(t.boolean()),summarizeThresholdChars:t.optional(t.number()),curationEnabled:t.optional(t.boolean()),curationBudgetChars:t.optional(t.number()),converterAgentId:t.optional(t.string()),voiceEnabled:t.optional(t.boolean()),talkEnabled:t.optional(t.boolean()),widgetsEnabled:t.optional(t.boolean()),widgetPromptConfirm:t.optional(t.boolean()),voiceEngine:t.optional(t.union(t.literal(`browser`),t.literal(`gateway`))),voiceLang:t.optional(t.string()),voiceRate:t.optional(t.number()),voiceAutoRead:t.optional(t.boolean()),contentLocale:t.optional(t.string()),inboundAgentMount:t.optional(t.string()),outboundAgentMount:t.optional(t.string()),transcriptProjection:t.optional(t.union(t.literal(`off`),t.literal(`shadow`),t.literal(`on`))),promptInjections:t.optional(t.record(t.string(),t.object({enabled:t.optional(t.boolean()),template:t.optional(t.string())})))});var m={mediaMode:`gateway-http`,inboundMediaMode:`inline`,rehydration:!0,mediaMaxMb:1024,inboundAgentMount:`/home/node/.openclaw/media/inbound`,outboundAgentMount:`/home/node/.openclaw/media/outbound`};function h(e,t){let n={};for(let r of o){let i=e?.[r];n[r]={enabled:i?.enabled??!0,template:typeof i?.template==`string`&&i.template.length>0?i.template:s[r].defaultTemplate[t]}}return n}function g(e,t){let n={};for(let r of o){let i=s[r],a=e[r];if(!a)continue;let o={};i.togglable&&a.enabled===!1&&(o.enabled=!1);let c=a.template.trim();c.length>0&&c!==i.defaultTemplate[t]&&(o.template=c),(o.enabled!==void 0||o.template!==void 0)&&(n[r]=o)}return n}function _(e,t){return{mediaMode:e.mediaMode??m.mediaMode,inboundMediaMode:e.inboundMediaMode??m.inboundMediaMode,rehydration:e.rehydration??m.rehydration,mediaMaxMb:e.mediaMaxMb??m.mediaMaxMb,inboundAgentMount:e.inboundAgentMount??m.inboundAgentMount,outboundAgentMount:e.outboundAgentMount??m.outboundAgentMount,promptInjections:h(e.promptInjections,t)}}var v=[`attachmentFixAttested`,`summarizeThresholdChars`,`curationEnabled`,`curationBudgetChars`,`contentLocale`,`converterAgentId`,`voiceEnabled`,`talkEnabled`,`voiceEngine`,`voiceLang`,`voiceRate`,`voiceAutoRead`,`widgetsEnabled`,`widgetPromptConfirm`,`transcriptProjection`];function y(e,t,n){let r={},i=n=>{(e[n]!==m[n]||t[n]!==void 0)&&(r[n]=e[n])};i(`mediaMode`),i(`inboundMediaMode`),i(`rehydration`),i(`mediaMaxMb`),i(`inboundAgentMount`),i(`outboundAgentMount`);let a=g(e.promptInjections,n);Object.keys(a).length>0&&(r.promptInjections=a);let o=t;for(let e of v){let t=o[e];(typeof t==`number`||typeof t==`boolean`||typeof t==`string`)&&(r[e]=t)}return r}var b=e();function x({text:e}){return(0,b.jsx)(r,{delayDuration:150,children:(0,b.jsxs)(i,{children:[(0,b.jsx)(a,{asChild:!0,children:(0,b.jsx)(`button`,{type:`button`,className:`oc-field__help`,"aria-label":e,onClick:e=>e.preventDefault(),children:(0,b.jsx)(l,{"aria-hidden":!0})})}),(0,b.jsx)(c,{className:`max-w-xs text-pretty`,children:e})]})})}function S({label:e,help:t}){return(0,b.jsxs)(`span`,{className:`oc-field__label`,children:[e,(0,b.jsx)(x,{text:t})]})}export{p as a,f as c,_ as i,S as n,d as o,y as r,u as s,x as t};
1
+ import{r as e}from"./bundle-mjs-C73ZY4La.js";import{E as t,YX as n}from"./api-Ca1H8N44.js";import{B as r,R as i,V as a,mn as o,pn as s,z as c}from"./index-bizOs74t.js";import"./locales-CPjguROj.js";import"./curation-CQksaIbm.js";var l=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`}]]),u=[`gateway-http`,`shared-fs`,`off`],d=[`inline`,`shared-fs`],f=[`reactive`,`sse`],p=`reactive`;n.object({mediaMode:n.optional(n.union(n.literal(`gateway-http`),n.literal(`shared-fs`),n.literal(`off`))),inboundMediaMode:n.optional(n.union(n.literal(`inline`),n.literal(`shared-fs`))),rehydration:n.optional(n.boolean()),mediaMaxMb:n.optional(n.number()),attachmentFixAttested:n.optional(n.boolean()),summarizeThresholdChars:n.optional(n.number()),curationEnabled:n.optional(n.boolean()),curationBudgetChars:n.optional(n.number()),converterAgentId:n.optional(n.string()),voiceEnabled:n.optional(n.boolean()),talkEnabled:n.optional(n.boolean()),widgetsEnabled:n.optional(n.boolean()),widgetPromptConfirm:n.optional(n.boolean()),voiceEngine:n.optional(n.union(n.literal(`browser`),n.literal(`gateway`))),voiceLang:n.optional(n.string()),voiceRate:n.optional(n.number()),voiceAutoRead:n.optional(n.boolean()),contentLocale:n.optional(n.string()),inboundAgentMount:n.optional(n.string()),outboundAgentMount:n.optional(n.string()),transcriptProjection:n.optional(n.union(n.literal(`off`),n.literal(`shadow`),n.literal(`on`))),promptInjections:n.optional(n.record(n.string(),n.object({enabled:n.optional(n.boolean()),template:n.optional(n.string())})))});var m={mediaMode:`gateway-http`,inboundMediaMode:`inline`,rehydration:!0,mediaMaxMb:1024,inboundAgentMount:`/home/node/.openclaw/media/inbound`,outboundAgentMount:`/home/node/.openclaw/media/outbound`};function h(e,t){let n={};for(let r of o){let i=e?.[r];n[r]={enabled:i?.enabled??!0,template:typeof i?.template==`string`&&i.template.length>0?i.template:s[r].defaultTemplate[t]}}return n}function g(e,t){let n={};for(let r of o){let i=s[r],a=e[r];if(!a)continue;let o={};i.togglable&&a.enabled===!1&&(o.enabled=!1);let c=a.template.trim();c.length>0&&c!==i.defaultTemplate[t]&&(o.template=c),(o.enabled!==void 0||o.template!==void 0)&&(n[r]=o)}return n}function _(e,t){return{mediaMode:e.mediaMode??m.mediaMode,inboundMediaMode:e.inboundMediaMode??m.inboundMediaMode,rehydration:e.rehydration??m.rehydration,mediaMaxMb:e.mediaMaxMb??m.mediaMaxMb,inboundAgentMount:e.inboundAgentMount??m.inboundAgentMount,outboundAgentMount:e.outboundAgentMount??m.outboundAgentMount,promptInjections:h(e.promptInjections,t)}}var v=[`attachmentFixAttested`,`summarizeThresholdChars`,`curationEnabled`,`curationBudgetChars`,`contentLocale`,`converterAgentId`,`voiceEnabled`,`talkEnabled`,`voiceEngine`,`voiceLang`,`voiceRate`,`voiceAutoRead`,`widgetsEnabled`,`widgetPromptConfirm`,`transcriptProjection`];function y(e,t,n){let r={},i=n=>{(e[n]!==m[n]||t[n]!==void 0)&&(r[n]=e[n])};i(`mediaMode`),i(`inboundMediaMode`),i(`rehydration`),i(`mediaMaxMb`),i(`inboundAgentMount`),i(`outboundAgentMount`);let a=g(e.promptInjections,n);Object.keys(a).length>0&&(r.promptInjections=a);let o=t;for(let e of v){let t=o[e];(typeof t==`number`||typeof t==`boolean`||typeof t==`string`)&&(r[e]=t)}return r}var b=e();function x({text:e}){return(0,b.jsx)(r,{delayDuration:150,children:(0,b.jsxs)(i,{children:[(0,b.jsx)(a,{asChild:!0,children:(0,b.jsx)(`button`,{type:`button`,className:`oc-field__help`,"aria-label":e,onClick:e=>e.preventDefault(),children:(0,b.jsx)(l,{"aria-hidden":!0})})}),(0,b.jsx)(c,{className:`max-w-xs text-pretty`,children:e})]})})}function S({label:e,help:t}){return(0,b.jsxs)(`span`,{className:`oc-field__label`,children:[e,(0,b.jsx)(x,{text:t})]})}export{p as a,f as c,_ as i,S as n,d as o,y as r,u as s,x as t};
@@ -0,0 +1 @@
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$Y as r,AY as ee,BY as i,CY as a,DY as o,EY as s,FY as te,GY as ne,HX as re,HY as c,IY as l,JY as u,KY as d,LY as f,MX as p,MY as ie,NY as ae,OY as oe,PX as se,PY as ce,QY as le,RY as m,SY as ue,TY as de,UV as fe,UY as pe,VX as me,VY as h,WY as he,XY as g,YY as _,ZY as ge,bY as _e,ep as ve,jY as ye,kY as be,qY as xe,t as v,tp as y,vY as b,wY as x,xY as S,yY as C,zY as w}from"./api-Ca1H8N44.js";import{t as T}from"./button-BbEZKLza.js";import{An as E,Bt as D,Gt as O,Ht as k,In as A,Jt as j,Kt as M,Mt as Se,St as N,Ut as Ce,Vt as we,Wt as Te,Yt as Ee,an as De,bt as P,en as Oe,nn as F,nr as I,qt as ke,tn as Ae,tr as je,vt as L,xt as R,yt as z}from"./index-bizOs74t.js";import{a as Me,i as B,n as Ne,o as V,r as H,t as Pe}from"./table-BrECCZpB.js";var U=t(e(),1),W=n(),G=`all`;function K(e){switch(e){case`image`:return c();case`audio`:return h();case`video`:return i();case`pdf`:return w();case`document`:return m();case`archive`:return f();default:return l()}}function q(){let[e,t]=(0,U.useState)(G),[n,i]=(0,U.useState)(G),[c,l]=(0,U.useState)(G),[f,m]=(0,U.useState)(G),[h,w]=(0,U.useState)(!1),[q,J]=(0,U.useState)(null),Fe=me(v.files.softDelete),Y=Ee();function Ie(){t(G),i(G),l(G),m(G)}async function Le(){let e=q;if(J(null),e)try{await Fe({fileId:e.id}),Y.success(de())}catch(e){Y.error(x(),e)}}let X=re(v.files.listMine,{direction:e===G?void 0:e,chatId:n===G?void 0:n,instanceName:c===G?void 0:c,category:f===G?void 0:f,includeAutoGenerated:h||void 0}),Re=(0,U.useMemo)(()=>new Intl.DateTimeFormat(se(),{dateStyle:`medium`,timeStyle:`short`}),[]);if(X===void 0)return(0,W.jsx)(`p`,{className:`oc-admin__hint`,children:p()});let{files:Z,facets:Q,truncated:ze,cap:Be}=X,$=e!==G||n!==G||c!==G||f!==G;return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`p`,{className:`oc-admin__hint`,children:r()}),(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)(R,{size:`sm`,"aria-label":le(),children:(0,W.jsx)(N,{})}),(0,W.jsxs)(z,{children:[(0,W.jsx)(P,{value:G,children:ge()}),(0,W.jsx)(P,{value:`inbound`,children:g()}),(0,W.jsx)(P,{value:`outbound`,children:_()})]})]}),(0,W.jsxs)(L,{value:n,onValueChange:i,children:[(0,W.jsx)(R,{size:`sm`,"aria-label":u(),children:(0,W.jsx)(N,{})}),(0,W.jsxs)(z,{children:[(0,W.jsx)(P,{value:G,children:xe()}),Q.chats.map(e=>(0,W.jsx)(P,{value:e.id,children:e.title},e.id))]})]}),Q.multiProvider?(0,W.jsxs)(L,{value:c,onValueChange:l,children:[(0,W.jsx)(R,{size:`sm`,"aria-label":d(),children:(0,W.jsx)(N,{})}),(0,W.jsxs)(z,{children:[(0,W.jsx)(P,{value:G,children:ne()}),Q.instances.map(e=>(0,W.jsx)(P,{value:e,children:e},e))]})]}):null,(0,W.jsxs)(L,{value:f,onValueChange:m,children:[(0,W.jsx)(R,{size:`sm`,"aria-label":he(),children:(0,W.jsx)(N,{})}),(0,W.jsxs)(z,{children:[(0,W.jsx)(P,{value:G,children:pe()}),Q.categories.map(e=>(0,W.jsx)(P,{value:e,children:K(e)},e))]})]}),(0,W.jsxs)(`label`,{className:`oc-files__autogen`,children:[(0,W.jsx)(Se,{checked:h,onCheckedChange:e=>w(e===!0),"aria-label":y()}),(0,W.jsx)(`span`,{children:y()})]}),$?(0,W.jsxs)(T,{variant:`ghost`,size:`sm`,onClick:Ie,style:{display:`inline-flex`,alignItems:`center`,gap:4,marginLeft:`auto`},children:[(0,W.jsx)(A,{size:14,"aria-hidden":!0}),oe()]}):null]}),Z.length===0?(0,W.jsx)(`p`,{className:`oc-admin__hint`,children:$?C():_e()}):(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:te()}),(0,W.jsx)(B,{children:ce()}),(0,W.jsx)(B,{children:ae()}),(0,W.jsx)(B,{children:ie()}),(0,W.jsx)(B,{children:ye()}),(0,W.jsx)(B,{className:`text-right`,children:ee()})]})}),(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)(j,{variant:`outline`,style:{marginLeft:6},children:ve()}):null]}),(0,W.jsx)(H,{title:e.mimeType,children:K(e.category)}),(0,W.jsx)(H,{children:(0,W.jsx)(j,{variant:`secondary`,children:e.direction===`inbound`?g():_()})}),(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)(Oe,{children:[(0,W.jsx)(De,{asChild:!0,children:(0,W.jsx)(T,{variant:`ghost`,size:`icon`,"aria-label":o(),children:(0,W.jsx)(je,{size:16})})}),(0,W.jsxs)(Ae,{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)(I,{size:14}),be()]})}):(0,W.jsxs)(F,{disabled:!0,children:[(0,W.jsx)(I,{size:14}),S()]}),(0,W.jsxs)(F,{variant:`destructive`,onSelect:()=>J({id:e._id,filename:e.filename}),children:[(0,W.jsx)(E,{size:14}),s()]})]})]})})]},e._id))})]}),ze?(0,W.jsx)(`p`,{className:`oc-admin__hint`,style:{marginTop:8},children:b({cap:Be})}):null]}),(0,W.jsx)(D,{open:q!==null,onOpenChange:e=>!e&&J(null),children:(0,W.jsxs)(Ce,{children:[(0,W.jsxs)(M,{children:[(0,W.jsx)(ke,{children:a()}),(0,W.jsx)(Te,{children:ue()})]}),(0,W.jsxs)(O,{children:[(0,W.jsx)(k,{children:fe()}),(0,W.jsx)(we,{onClick:()=>void Le(),children:s()})]})]})})]})}export{q as FilesTab};
@@ -1 +1 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{aC as r,iC as i}from"./api-Bem2UcWi.js";import{t as a}from"./button-BFCjIMMp.js";import{$t as o,Fn as s,In as c}from"./index-BfR5o8dt.js";import{t as l}from"./TimeRangePicker-BqRtJNXo.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)(s,{className:`oc-filterbar__search-icon`,"aria-hidden":!0}),(0,d.jsx)(o,{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)(c,{}),i()]})]})}export{p as t};
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{CC as r,wC as i}from"./api-Ca1H8N44.js";import{t as a}from"./button-BbEZKLza.js";import{$t as o,Fn as s,In as c}from"./index-bizOs74t.js";import{t as l}from"./TimeRangePicker-D6jq73FP.js";var u=t(e(),1),d=n(),f=250;function p({q:e,onQChange:t,searchPlaceholder:n=i(),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)(s,{className:`oc-filterbar__search-icon`,"aria-hidden":!0}),(0,d.jsx)(o,{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)(c,{}),r()]})]})}export{p as t};
@@ -0,0 +1 @@
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$b as r,$y as i,Ab as a,Ay as o,Bb as s,By as c,Cb as l,Cx as u,Cy as d,Db as f,Dy as p,E as m,Eb as h,Ey as g,Fb as _,Fy as v,Gy as y,HX as b,Hb as x,Hy as S,Ib as C,Iy as ee,Jb as w,Jy as T,Kb as E,Ky as D,Lb as O,Ly as k,Mb as te,My as A,Nb as ne,Ny as j,Ob as M,Oy as re,Pb as ie,Py as N,Qb as ae,Qy as oe,Rb as se,Ry as ce,Sb as le,Sx as P,Sy as ue,Tb as de,Ty as F,Uy as fe,VX as I,Vb as L,Vy as pe,Wy as me,Xb as he,Xy as ge,Yb as R,Yy as _e,Zb as ve,Zy as ye,_b as z,_x as be,ax as xe,bb as B,bx as Se,by as Ce,cb as we,cx as Te,db as Ee,dx as De,dy as Oe,eb as ke,ex as Ae,fb as je,fx as Me,fy as Ne,gb as Pe,gx as Fe,hb as Ie,hx as Le,ix as Re,jb as ze,jy as Be,kb as Ve,ky as He,lb as Ue,lx as We,mb as Ge,mx as Ke,my as qe,nb as Je,nx as Ye,ox as Xe,pb as Ze,px as Qe,py as $e,qb as et,qy as tt,rb as nt,rx as rt,sb as it,sx as at,t as V,tb as ot,tx as st,ub as ct,ux as lt,vb as ut,vx as dt,wb as ft,wx as pt,wy as mt,xb as ht,xx as gt,xy as _t,yb as vt,yx as yt,zb as bt,zy as xt}from"./api-Ca1H8N44.js";import{t as St}from"./x-BvlIg0Y4.js";import{t as H}from"./button-BbEZKLza.js";import{$ as Ct,$t as U,Ct as wt,Dn as Tt,Dt as Et,En as Dt,G as Ot,J as W,Jt as G,K as kt,Mn as At,Mt as K,Nn as jt,Ot as Mt,Pn as Nt,Q as Pt,St as Ft,Tt as It,W as q,X as Lt,Y as Rt,Yt as J,Z as zt,at as Bt,b as Vt,bt as Ht,cr as Ut,ct as Wt,et as Gt,ft as Kt,it as qt,jn as Y,ot as Jt,q as Yt,sr as Xt,st as Zt,vt as Qt,wt as $t,xt as en,yt as tn}from"./index-bizOs74t.js";import{t as nn}from"./FilterBar-PBFn9z0b.js";import{t as rn}from"./DataTableShell-D_c2Z76f.js";import{t as X}from"./DetailChips-WBRxaQ82.js";var an=m(`palette`,[[`path`,{d:`M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z`,key:`e79jfc`}],[`circle`,{cx:`13.5`,cy:`6.5`,r:`.5`,fill:`currentColor`,key:`1okk4w`}],[`circle`,{cx:`17.5`,cy:`10.5`,r:`.5`,fill:`currentColor`,key:`f64h9f`}],[`circle`,{cx:`6.5`,cy:`12.5`,r:`.5`,fill:`currentColor`,key:`qy21gx`}],[`circle`,{cx:`8.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`fotxhn`}]]),Z=t(e(),1),Q=n(),on={name:``,description:``};function sn(){let e=b(V.groups.listGroups,{}),t=b(V.me.getMe,{host:Kt})?.role===`admin`,n=I(V.groups.createGroup),r=I(V.groups.updateGroup),i=I(V.groups.deleteGroup),a=Wt(),o=J(),[s,c]=(0,Z.useState)(!1),[l,d]=(0,Z.useState)(null),[f,p]=(0,Z.useState)(on),[m,h]=(0,Z.useState)(null),[g,_]=(0,Z.useState)(``),v=(0,Z.useMemo)(()=>{if(!e)return e;let t=g.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,g]);function y(){d(null),p(on),c(!0)}function x(e){d(e),p({name:e.name,description:e.description??``}),c(!0)}async function S(){try{l?await r({groupId:l._id,name:f.name,description:f.description}):await n({name:f.name,description:f.description||void 0}),p(on),d(null),c(!1)}catch(e){o.error(vt(),e)}}async function C(e){if(await a({title:xe({name:e.name}),description:Re(),confirmWord:e.name,confirmLabel:rt(),cancelLabel:De(),destructive:!0}))try{await i({groupId:e._id})}catch(e){o.error(ut(),e)}}return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:u()}),t?(0,Q.jsx)(pn,{}):null,(0,Q.jsx)(nn,{q:g,onQChange:_,onReset:()=>_(``),canReset:g!==``,searchPlaceholder:Fe()}),(0,Q.jsx)(rn,{title:pt(),rows:v,addLabel:P(),onAdd:t?y:void 0,emptyHint:gt(),columns:[{header:Se(),cell:e=>e.name,sort:e=>e.name},{header:yt(),cell:e=>(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(X,{icon:(0,Q.jsx)(Dt,{size:12,"aria-hidden":!0}),total:e.memberCount,items:e.members.map(e=>({label:e.label,marker:e.manager?(0,Q.jsx)(jt,{size:11,"aria-hidden":!0}):null,highlight:e.manager}))}),e.pendingInviteCount>0?(0,Q.jsx)(G,{variant:`secondary`,children:it({count:String(e.pendingInviteCount)})}):null]}),sort:e=>e.memberCount},{header:dt(),cell:e=>(0,Q.jsx)(X,{icon:(0,Q.jsx)(Nt,{size:12,"aria-hidden":!0}),total:e.agentCount,items:e.agents.map(e=>({label:e}))}),sort:e=>e.agentCount},{header:be(),cell:e=>(0,Q.jsx)(X,{icon:(0,Q.jsx)(an,{size:12,"aria-hidden":!0}),total:e.chartCount,items:e.charts.map(e=>({label:e.name,marker:e.isDefault?(0,Q.jsx)(Y,{size:11,fill:`currentColor`,"aria-hidden":!0}):null,highlight:e.isDefault}))}),sort:e=>e.chartCount}],rowActions:e=>[{label:Le(),onSelect:()=>h({groupId:e._id,name:e.name})},...t?[{label:Ke(),onSelect:()=>x(e)},{label:Qe(),variant:`destructive`,onSelect:()=>void C(e)}]:[]]}),(0,Q.jsx)(Vt,{open:s,onOpenChange:c,title:l?We():lt(),description:Te(),canSubmit:!!f.name.trim(),onSubmit:S,submitLabel:Me(),children:(0,Q.jsxs)(`div`,{className:`oc-form`,children:[(0,Q.jsxs)(`label`,{className:`oc-field`,children:[(0,Q.jsx)(`span`,{className:`oc-field__label`,children:at()}),(0,Q.jsx)(U,{value:f.name,onChange:e=>p({...f,name:e.target.value})})]}),(0,Q.jsxs)(`label`,{className:`oc-field`,children:[(0,Q.jsx)(`span`,{className:`oc-field__label`,children:Xe()}),(0,Q.jsx)(U,{value:f.description,onChange:e=>p({...f,description:e.target.value})})]})]})}),(0,Q.jsx)(ln,{groupId:m?.groupId??null,groupName:m?.name??``,open:m!==null,onOpenChange:e=>{e||h(null)}})]})}var cn=8;function $({page:e,pageCount:t,onPage:n}){return t<=1?null:(0,Q.jsxs)(`div`,{className:`oc-access__pager`,children:[(0,Q.jsxs)(H,{type:`button`,variant:`ghost`,size:`sm`,disabled:e<=1,onClick:()=>n(e-1),children:[(0,Q.jsx)(Ut,{size:14,"aria-hidden":!0}),w()]}),(0,Q.jsxs)(`span`,{className:`oc-access__pageinfo`,"aria-label":E({page:e,pages:t}),children:[e,` / `,t]}),(0,Q.jsxs)(H,{type:`button`,variant:`ghost`,size:`sm`,disabled:e>=t,onClick:()=>n(e+1),children:[et(),(0,Q.jsx)(Xt,{size:14,"aria-hidden":!0})]})]})}function ln({groupId:e,groupName:t,open:n,onOpenChange:a}){let o=b(V.groups.getGroup,n&&e?{groupId:e}:`skip`),c=o?.viewerIsAdmin===!0,u=b(V.groups.listAssignableInstances,n&&e?{groupId:e}:`skip`),d=b(V.groups.listAssignableUsers,n&&c?{}:`skip`),f=I(V.groups.addMember),p=I(V.groups.removeMember),m=I(V.groups.bulkSetMembers),h=I(V.groups.setGroupManager),g=J(),[_,v]=(0,Z.useState)(``),[y,C]=(0,Z.useState)(``),[ee,w]=(0,Z.useState)(`members`),[T,E]=(0,Z.useState)(1),[D,k]=(0,Z.useState)(null),[A,ne]=(0,Z.useState)(new Set),j=(0,Z.useRef)(null),M=(0,Z.useMemo)(()=>new Set((o?.members??[]).map(e=>e.userId)),[o]),re=(0,Z.useMemo)(()=>new Set((o?.members??[]).filter(e=>e.manager).map(e=>e.userId)),[o]),ie=(0,Z.useMemo)(()=>new Set((o?.members??[]).filter(e=>e.restricted).map(e=>e.userId)),[o]),N=(0,Z.useMemo)(()=>new Set((o?.agents??[]).map(e=>q(e.instanceName,e.agentId))),[o]),ce=(0,Z.useMemo)(()=>{let e=(o?.agents??[]).find(e=>e.isDefault);return e?q(e.instanceName,e.agentId):null},[o]);(0,Z.useEffect)(()=>{v(``),C(``),w(`members`),E(1),k(null),j.current=null},[n,e]),(0,Z.useEffect)(()=>{E(1)},[_]),(0,Z.useEffect)(()=>{n&&o&&e&&j.current!==e&&(j.current=e,ne(new Set((o.members??[]).map(e=>e.userId))))},[n,o,e]);let P=(0,Z.useMemo)(()=>d?Yt(d,_,A):[],[d,_,A]);async function ue(t,n){if(e)try{n?await p({groupId:e,userId:t}):await f({groupId:e,userId:t})}catch(e){g.error(z(),W(e))}}async function de(t,n){if(e)try{await h({groupId:e,userId:t,manager:!n})}catch(e){g.error(ht(),e)}}let F=Ct(P,e=>M.has(e.userId)),fe=P.filter(e=>M.has(e.userId)).length,L=zt(P,T,cn);async function pe(){if(!e||P.length===0)return;let t=P.map(e=>e.userId);try{await m({groupId:e,userIds:t,member:F!==`all`})}catch(e){g.error(z(),W(e))}}let me=(e,t)=>(0,Q.jsxs)(H,{type:`button`,variant:`ghost`,size:`sm`,className:`h-7`,"aria-label":oe({user:t}),title:oe({user:t}),onClick:()=>k({userId:e,label:t}),children:[(0,Q.jsx)(At,{size:13,"aria-hidden":!0}),i()]});return(0,Q.jsx)(wt,{open:n,onOpenChange:a,children:(0,Q.jsxs)($t,{className:`oc-access`,children:[(0,Q.jsxs)(Et,{children:[(0,Q.jsx)(Mt,{children:Ye({name:t})}),(0,Q.jsx)(It,{children:o&&!c?Ie():st()})]}),(0,Q.jsxs)(qt,{value:ee,onValueChange:w,className:`oc-access__tabs`,children:[(0,Q.jsxs)(Jt,{className:`w-full`,children:[(0,Q.jsxs)(Zt,{value:`members`,className:`flex-1 gap-1.5`,children:[(0,Q.jsx)(Dt,{size:13,"aria-hidden":!0}),Ae(),o?(0,Q.jsx)(G,{variant:`secondary`,className:`oc-access__tabcount`,children:M.size}):null]}),(0,Q.jsxs)(Zt,{value:`agents`,className:`flex-1 gap-1.5`,children:[(0,Q.jsx)(Nt,{size:13,"aria-hidden":!0}),ae(),o?(0,Q.jsx)(G,{variant:`secondary`,className:`oc-access__tabcount`,children:N.size}):null]}),(0,Q.jsxs)(Zt,{value:`charts`,className:`flex-1 gap-1.5`,children:[(0,Q.jsx)(an,{size:13,"aria-hidden":!0}),te(),o?(0,Q.jsx)(G,{variant:`secondary`,className:`oc-access__tabcount`,children:o.chartCount}):null]})]}),(0,Q.jsx)(Bt,{value:`members`,children:o===void 0?(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:s()}):c?d===void 0?(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:s()}):d.length===0?(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:se()}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(U,{value:_,onChange:e=>v(e.target.value),placeholder:r(),className:`oc-access__search`}),P.length===0?(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:he()}):(0,Q.jsxs)(Q.Fragment,{children:[P.length>1?(0,Q.jsxs)(`div`,{className:`oc-access__row oc-access__selectall`,children:[(0,Q.jsx)(K,{checked:F===`all`?!0:F===`some`?`indeterminate`:!1,onCheckedChange:()=>void pe(),"aria-label":R()}),(0,Q.jsx)(`span`,{className:`oc-access__label`,children:R()}),(0,Q.jsxs)(G,{variant:`outline`,className:`oc-access__count`,children:[fe,` / `,P.length]})]}):null,(0,Q.jsx)(`div`,{className:`oc-access__list`,children:L.pageItems.map(e=>{let t=M.has(e.userId),n=Gt(e),r=re.has(e.userId);return(0,Q.jsxs)(`div`,{className:`oc-access__row`,children:[(0,Q.jsx)(K,{checked:t,onCheckedChange:()=>void ue(e.userId,t),"aria-label":x({user:n.primary})}),(0,Q.jsxs)(`span`,{className:`oc-access__who`,children:[(0,Q.jsx)(`span`,{className:`oc-access__label`,title:n.primary,children:n.primary}),n.secondary?(0,Q.jsx)(`span`,{className:`oc-access__sub`,title:n.secondary,children:n.secondary}):null]}),t&&ie.has(e.userId)?(0,Q.jsx)(G,{variant:`outline`,className:`oc-access__role`,children:ye()}):null,(0,Q.jsx)(G,{variant:`outline`,className:`oc-access__role`,children:Pt(e.role)}),t?me(e.userId,n.primary):null,(0,Q.jsx)(`span`,{className:`oc-access__mgrslot`,children:t?(0,Q.jsx)(H,{type:`button`,variant:`ghost`,size:`icon`,className:`shrink-0 oc-access__mgr${r?` oc-access__mgr--on`:``}`,"aria-pressed":r,"aria-label":r?le():l(),title:r?le():l(),onClick:()=>void de(e.userId,r),children:(0,Q.jsx)(jt,{size:15,"aria-hidden":!0})}):null})]},e._id)})}),(0,Q.jsx)($,{page:L.page,pageCount:L.pageCount,onPage:E})]})]}):e?(0,Q.jsx)(un,{groupId:e,members:o.members,agentsButton:me}):null}),(0,Q.jsxs)(Bt,{value:`agents`,children:[o&&!c?(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:S()}):null,u===void 0?(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:s()}):u.length===0?(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:O()}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(U,{value:y,onChange:e=>C(e.target.value),placeholder:ve(),className:`oc-access__search`}),(0,Q.jsx)(`div`,{className:`oc-access__list`,children:u.map(t=>(0,Q.jsx)(fn,{groupId:e,instanceName:t.name,kind:t.kind??`openclaw`,assigned:N,defaultKey:ce,viewerIsAdmin:c,query:y},`${e}-${t._id}`))})]})]}),(0,Q.jsx)(Bt,{value:`charts`,children:(0,Q.jsx)(mn,{groupId:e})})]}),(0,Q.jsx)(dn,{groupId:e,member:D,onOpenChange:e=>{e||k(null)}})]})})}function un({groupId:e,members:t,agentsButton:n}){let r=b(V.groupInvites.listGroupInviteRequests,{groupId:e}),i=I(V.groupInvites.requestGroupInvite),a=I(V.groups.removeMember),o=Wt(),s=J(),[c,l]=(0,Z.useState)(``),[u,d]=(0,Z.useState)(1),f=zt(t,u,cn);async function p(t){t.preventDefault();let n=c.trim();if(n)try{await i({groupId:e,email:n}),l(``),s.success(ct())}catch(e){s.error(Ue(),e)}}async function m(t,n){if(await o({title:nt({user:n}),description:ot({user:n}),confirmLabel:ke(),cancelLabel:De(),destructive:!0}))try{await a({groupId:e,userId:t})}catch(e){s.error(z(),W(e))}}return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`form`,{className:`oc-access__invite`,onSubmit:e=>void p(e),children:[(0,Q.jsx)(U,{type:`email`,value:c,onChange:e=>l(e.target.value),placeholder:je(),"aria-label":Ge()}),(0,Q.jsxs)(H,{type:`submit`,size:`sm`,disabled:!c.trim(),children:[(0,Q.jsx)(Tt,{size:14,"aria-hidden":!0}),Ee()]})]}),(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:Ze()}),t.length===0?(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:ge()}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`oc-access__list`,children:f.pageItems.map(e=>(0,Q.jsxs)(`div`,{className:`oc-access__row`,children:[(0,Q.jsx)(`span`,{className:`oc-access__label`,title:e.label,children:e.label}),e.restricted?(0,Q.jsx)(G,{variant:`outline`,className:`oc-access__role`,children:ye()}):null,n(e.userId,e.label),(0,Q.jsx)(`span`,{className:`oc-access__mgrslot`,children:e.manager?(0,Q.jsx)(`span`,{className:`oc-access__mgr oc-access__mgr--on`,role:`img`,"aria-label":ft(),title:ft(),children:(0,Q.jsx)(jt,{size:15,"aria-hidden":!0})}):null}),(0,Q.jsx)(H,{type:`button`,variant:`ghost`,size:`icon-sm`,disabled:e.manager||e.lastGroup,"aria-label":nt({user:e.label}),title:e.manager?Je():e.lastGroup?Ce():nt({user:e.label}),onClick:()=>void m(e.userId,e.label),children:(0,Q.jsx)(St,{size:14,"aria-hidden":!0})})]},e.userId))}),(0,Q.jsx)($,{page:f.page,pageCount:f.pageCount,onPage:d})]}),r!==void 0&&r.length>0?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`p`,{className:`oc-access__subhead`,children:we()}),(0,Q.jsx)(`div`,{className:`oc-access__list`,children:r.map(e=>(0,Q.jsxs)(`div`,{className:`oc-access__row`,children:[(0,Q.jsx)(`span`,{className:`oc-access__label`,title:e.email,children:e.email}),(0,Q.jsx)(G,{variant:e.status===`pending`?`secondary`:`outline`,className:`oc-access__role`,children:Rt(e.status)})]},e._id))})]}):null]})}function dn({groupId:e,member:t,onOpenChange:n}){let r=b(V.groups.getMemberAgentSettings,e&&t?{groupId:e,userId:t.userId}:`skip`),i=I(V.groups.setMemberAgents),a=I(V.groups.setMemberDefaultAgent),c=J();async function l(e){try{await e()}catch(e){c.error(_t(),e)}}let u=r?.agents??[],f=new Map(u.map(e=>[q(e.instanceName,e.agentId),e])),m=[...f.keys()],h=new Set(u.filter(e=>e.allowed).map(e=>q(e.instanceName,e.agentId)));function _(n){if(!e||!t||!r)return;let a=Lt(m,h,r.restricted,n).map(e=>{let t=f.get(e);return{instanceName:t.instanceName,agentId:t.agentId}});l(()=>i({groupId:e,userId:t.userId,agents:a}))}return(0,Q.jsx)(wt,{open:t!==null,onOpenChange:n,children:(0,Q.jsxs)($t,{className:`oc-access`,children:[(0,Q.jsxs)(Et,{children:[(0,Q.jsx)(Mt,{children:o({user:t?.label??``})}),(0,Q.jsx)(It,{children:He()})]}),r===void 0?(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:s()}):r===null||u.length===0?(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:ue()}):(0,Q.jsxs)(Q.Fragment,{children:[r.settable?null:(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:Oe()}),r.adminNarrowed?(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:qe()}):null,r.restrictedByAdmin&&!r.viewerIsAdmin?(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:Ne()}):null,(0,Q.jsxs)(`div`,{className:`oc-access__row oc-access__selectall`,children:[(0,Q.jsx)(`span`,{className:`oc-access__label`,children:r.restricted?p():re()}),r.restricted?(0,Q.jsx)(H,{type:`button`,size:`sm`,variant:`outline`,disabled:!r.settable||r.restrictedByAdmin&&!r.viewerIsAdmin,onClick:()=>e&&t?void l(()=>i({groupId:e,userId:t.userId,agents:null})):void 0,children:g()}):null]}),(0,Q.jsx)(`div`,{className:`oc-access__list`,children:u.map(n=>{let i=q(n.instanceName,n.agentId),o=n.displayName??n.agentId;return(0,Q.jsxs)(`div`,{className:`oc-access__row`,children:[(0,Q.jsx)(K,{checked:n.allowed,disabled:!r.settable||r.restrictedByAdmin&&!r.viewerIsAdmin&&!n.allowed,onCheckedChange:()=>_(i),"aria-label":F({name:o})}),(0,Q.jsx)(`span`,{className:`oc-access__label`,title:o,children:o}),n.limitedByAdmin?(0,Q.jsx)(G,{variant:`outline`,className:`oc-access__role`,children:$e()}):null,n.state===`deleted`?(0,Q.jsx)(G,{variant:`outline`,className:`oc-access__gone`,children:ne()}):null,n.allowed?n.isMemberDefault?(0,Q.jsx)(H,{type:`button`,size:`icon-sm`,variant:`ghost`,className:`oc-access__fav`,disabled:!r.settable,"aria-label":mt(),title:mt(),onClick:()=>e&&t?void l(()=>a({groupId:e,userId:t.userId,agent:null})):void 0,children:(0,Q.jsx)(Y,{size:14,fill:`currentColor`})}):(0,Q.jsx)(H,{type:`button`,size:`icon-sm`,variant:`ghost`,className:`oc-access__setdefault`,disabled:!r.settable,"aria-label":d(),title:d(),onClick:()=>e&&t?void l(()=>a({groupId:e,userId:t.userId,agent:{instanceName:n.instanceName,agentId:n.agentId}})):void 0,children:(0,Q.jsx)(Y,{size:14})}):null]},i)})})]})]})})}function fn({groupId:e,instanceName:t,kind:n,assigned:r,defaultKey:i,viewerIsAdmin:a,query:o}){let s=b(V.groups.listAssignableAgents,e?{instanceName:t,groupId:e}:`skip`),l=I(V.groups.assignAgentToGroup),u=I(V.groups.removeAgentFromGroup),d=I(V.groups.bulkSetGroupAgents),f=I(V.groups.claimAgentForGroup),p=I(V.groups.setGroupDefaultAgent),m=J(),[h,g]=(0,Z.useState)(1);if((0,Z.useEffect)(()=>{g(1)},[o]),!e)return null;let y=kt(s?.agents??[],o),x=s?.discovery&&!s.discovery.lastPollOk,S=e=>Ot({assigned:r.has(q(t,e.agentId)),claimable:e.claimable,reservedForGroup:e.reservedForGroup,enabled:e.enabled,present:e.presentInLastOk!==!1},a),w=y.filter(e=>S(e)!==`claim`),T=y.filter(e=>S(e)===`claim`);if(o.trim()&&y.length===0)return null;let E=w.filter(e=>S(e)===`toggle`&&e.presentInLastOk!==!1&&e.enabled!==!1),D=Ct(E,e=>r.has(q(t,e.agentId))),O=zt(w,h,cn);async function te(n,r){try{r?await u({groupId:e,instanceName:t,agentId:n}):await l({groupId:e,instanceName:t,agentId:n})}catch(e){m.error(Pe(),W(e))}}async function M(){if(E.length===0)return;let n=E.map(e=>e.agentId);try{await d({groupId:e,instanceName:t,agentIds:n,assigned:D!==`all`})}catch(e){m.error(Pe(),W(e))}}async function re(n){try{await f({groupId:e,instanceName:t,agentId:n})}catch(e){m.error(k(),e)}}async function ae(n){try{await p({groupId:e,agent:n===null?null:{instanceName:t,agentId:n}})}catch(e){m.error(Be(),e)}}let oe=e=>e.reservedForGroup?(0,Q.jsx)(G,{variant:`outline`,className:`oc-access__role`,children:ee()}):e.reserved?(0,Q.jsx)(G,{variant:`outline`,className:`oc-access__role`,children:e.reservedGroupName===null?N():v({group:e.reservedGroupName})}):null;return(0,Q.jsxs)(`div`,{className:`oc-access__group`,children:[(0,Q.jsxs)(`div`,{className:`oc-access__instance`,children:[(0,Q.jsx)(Nt,{size:13,"aria-hidden":!0}),(0,Q.jsx)(`span`,{children:t}),(0,Q.jsx)(G,{variant:`outline`,className:`oc-access__kind`,children:n}),x?(0,Q.jsx)(G,{variant:`outline`,className:`oc-access__stale`,children:ie()}):null]}),s===void 0?(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:bt()}):y.length===0?(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:x?_():C()}):(0,Q.jsxs)(Q.Fragment,{children:[E.length>1?(0,Q.jsxs)(`div`,{className:`oc-access__row oc-access__selectall`,children:[(0,Q.jsx)(K,{checked:D===`all`?!0:D===`some`?`indeterminate`:!1,onCheckedChange:()=>void M(),"aria-label":R()}),(0,Q.jsx)(`span`,{className:`oc-access__label`,children:R()})]}):null,O.pageItems.map(e=>{let n=q(t,e.agentId),a=r.has(n),o=e.presentInLastOk===!1,s=S(e)===`locked`;return(0,Q.jsxs)(`div`,{className:`oc-access__row${s?` is-disabled`:``}`,children:[(0,Q.jsx)(K,{checked:a,disabled:s&&!a,onCheckedChange:()=>void te(e.agentId,a),"aria-label":L({name:e.displayName??e.agentId})}),(0,Q.jsxs)(`span`,{className:`oc-access__label`,title:e.displayName??e.agentId,children:[e.emoji?`${e.emoji} `:``,e.displayName??e.agentId]}),e.model?(0,Q.jsx)(`span`,{className:`oc-access__model`,children:e.model}):null,oe(e),o?(0,Q.jsx)(G,{variant:`outline`,className:`oc-access__gone`,children:ne()}):null,a?i===n?(0,Q.jsx)(H,{type:`button`,size:`icon-sm`,variant:`ghost`,className:`oc-access__fav`,"aria-label":j(),title:j(),onClick:()=>void ae(null),children:(0,Q.jsx)(Y,{size:14,fill:`currentColor`})}):(0,Q.jsx)(H,{type:`button`,size:`icon-sm`,variant:`ghost`,className:`oc-access__setdefault`,"aria-label":A(),title:A(),onClick:()=>void ae(e.agentId),children:(0,Q.jsx)(Y,{size:14})}):null]},e.agentId)}),(0,Q.jsx)($,{page:O.page,pageCount:O.pageCount,onPage:g}),T.length>0?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`p`,{className:`oc-access__subhead`,children:pe()}),(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:c()}),T.map(e=>{let t=e.displayName??e.agentId;return(0,Q.jsxs)(`div`,{className:`oc-access__row`,children:[(0,Q.jsxs)(`span`,{className:`oc-access__label`,title:t,children:[e.emoji?`${e.emoji} `:``,t]}),e.model?(0,Q.jsx)(`span`,{className:`oc-access__model`,children:e.model}):null,(0,Q.jsx)(H,{type:`button`,size:`sm`,variant:`outline`,className:`h-7`,"aria-label":ce({name:t}),onClick:()=>void re(e.agentId),children:xt()})]},e.agentId)})]}):null]})]})}function pn(){let e=b(V.groupInvites.listPendingInviteRequests,{}),t=I(V.groupInvites.decideGroupInvite),n=J();if(e===void 0||e.length===0)return null;async function r(e,r){try{await t({requestId:e,approve:r})}catch(e){n.error(fe(),e)}}return(0,Q.jsxs)(`section`,{className:`oc-invites`,"aria-label":_e(),children:[(0,Q.jsxs)(`h3`,{className:`oc-invites__title`,children:[(0,Q.jsx)(Tt,{size:14,"aria-hidden":!0}),_e(),(0,Q.jsx)(G,{variant:`secondary`,children:e.length})]}),(0,Q.jsx)(`div`,{className:`oc-access__list`,children:e.map(e=>(0,Q.jsxs)(`div`,{className:`oc-access__row`,children:[(0,Q.jsxs)(`span`,{className:`oc-access__who`,children:[(0,Q.jsx)(`span`,{className:`oc-access__label`,title:e.email,children:e.email}),(0,Q.jsxs)(`span`,{className:`oc-access__sub`,children:[e.groupName??`?`,` ·`,` `,T({by:e.requestedBy})]})]}),e.account===`ready`?null:(0,Q.jsx)(G,{variant:`outline`,className:`oc-access__role`,children:e.account===`none`?y():me()}),(0,Q.jsx)(H,{type:`button`,size:`sm`,variant:`outline`,className:`h-7`,disabled:e.account!==`ready`,onClick:()=>void r(e._id,!0),children:tt()}),(0,Q.jsx)(H,{type:`button`,size:`sm`,variant:`ghost`,className:`h-7`,onClick:()=>void r(e._id,!1),children:D()})]},e._id))})]})}function mn({groupId:e}){let t=b(V.charts.listGroupChartSelection,e?{groupId:e}:`skip`),n=I(V.charts.assignChartToGroup),r=I(V.charts.removeChartFromGroup),i=I(V.charts.setGroupDefaultChart),o=I(V.charts.addChartToGroupPool),c=I(V.charts.removeChartFromGroupPool),l=J();if(!e)return null;if(t===void 0)return(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:s()});let{pool:u,addable:d,canManagePool:p}=t;if(u.length===0&&!p)return(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:ze()});async function m(t,i){try{i?await r({groupId:e,chartKey:t}):await n({groupId:e,chartKey:t})}catch(e){l.error(B(),e)}}async function g(t){try{await i({groupId:e,chartKey:t})}catch(e){l.error(B(),e)}}async function _(t){try{await o({groupId:e,chartKey:t})}catch(e){l.error(B(),e)}}async function v(t){try{await c({groupId:e,chartKey:t})}catch(e){l.error(B(),e)}}return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`oc-access__list`,children:u.map(e=>(0,Q.jsxs)(`div`,{className:`oc-access__row`,children:[(0,Q.jsx)(K,{checked:e.selected,onCheckedChange:()=>void m(e.chartKey,e.selected),"aria-label":f({name:e.name})}),(0,Q.jsx)(`span`,{className:`oc-access__label`,title:e.name,children:e.name}),e.selected?e.isDefault?(0,Q.jsx)(`span`,{className:`oc-access__fav`,role:`img`,"aria-label":h(),title:h(),children:(0,Q.jsx)(Y,{size:14,fill:`currentColor`})}):(0,Q.jsx)(H,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>void g(e.chartKey),children:de()}):null,p?(0,Q.jsx)(H,{type:`button`,variant:`ghost`,size:`sm`,"aria-label":M({name:e.name}),title:M({name:e.name}),onClick:()=>void v(e.chartKey),children:(0,Q.jsx)(St,{size:14,"aria-hidden":!0})}):null]},e.chartKey))}),p?d.length>0?(0,Q.jsxs)(Qt,{value:``,onValueChange:e=>void _(e),children:[(0,Q.jsx)(en,{size:`sm`,className:`oc-access__search`,children:(0,Q.jsx)(Ft,{placeholder:Ve()})}),(0,Q.jsx)(tn,{children:d.map(e=>(0,Q.jsx)(Ht,{value:e.chartKey,children:e.name},e.chartKey))})]}):u.length===0?(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:a()}):null:null]})}export{sn as GroupsTab};
@@ -0,0 +1 @@
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$ as r,$F as i,$P as a,AF as o,AP as s,An as c,Ao as l,BF as u,BP as d,CF as f,CI as p,Co as m,DF as h,Dn as g,Do as _,EF as v,En as y,Eo as b,Eu as ee,FF as x,FP as S,Fn as te,Fo as C,GF as w,GP as T,HF as E,HP as D,HX as O,IF as k,IP as A,J as ne,JF as re,JP as ie,K as ae,KF as oe,KP as se,LF as ce,LP as le,LU as ue,MF as de,MP as j,Mn as fe,Mo as pe,NF as me,NP as he,Nn as ge,No as _e,OF as ve,OP as ye,On as be,Oo as xe,PF as Se,PP as Ce,Pn as we,Po as Te,Q as Ee,QF as De,QP as Oe,RF as ke,RP as Ae,RU as je,SF as Me,SI as Ne,So as Pe,TF as Fe,To as Ie,Tu as Le,UF as Re,UP as ze,VF as Be,VP as Ve,VX as M,WF as He,WP as Ue,X as We,XF as Ge,XP as Ke,Y as qe,YF as Je,YP as Ye,Z as Xe,ZF as Ze,ZP as Qe,_F as $e,_I as et,aF as tt,aI as nt,bF as rt,bI as it,bo as at,cF as ot,cI as st,cm as ct,cy as lt,dA as ut,dF as dt,dI as ft,dm as pt,eF as mt,eI as ht,et as gt,fA as _t,fF as vt,fI as yt,gF as bt,gI as xt,hF as St,hI as Ct,iF as N,iI as wt,jF as Tt,jP as Et,jn as Dt,jo as Ot,kF as kt,kP as At,kn as jt,ko as Mt,lF as P,lI as Nt,lm as Pt,ly as Ft,mF as It,mI as Lt,nF as Rt,nI as zt,oF as Bt,oI as Vt,pF as Ht,pI as Ut,q as Wt,qF as Gt,qP as Kt,rI as qt,sF as Jt,sI as Yt,t as F,tF as Xt,tI as Zt,uF as Qt,uI as $t,um as en,uy as tn,vF as nn,vI as rn,wF as an,wo as on,wu as sn,xF as cn,xI as ln,xo as un,yF as dn,yI as fn,yo as pn,zF as mn,zP as hn,zX as I}from"./api-Ca1H8N44.js";import{a as gn,c as _n}from"./FieldLabel-sEQ38rsG.js";import{t as L}from"./button-BbEZKLza.js";import{$t as R,Ct as vn,Dt as z,J as yn,Jt as B,Mt as V,Ot as H,St as U,Tt as bn,Yt as W,b as xn,bt as G,cn as Sn,ct as Cn,on as wn,sn as Tn,vt as K,wt as En,xt as q,yt as J}from"./index-bizOs74t.js";import{t as Dn}from"./DataTableShell-D_c2Z76f.js";import{InstanceConfigDialog as On}from"./BridgeTab-VqbKYXla.js";var Y=t(e(),1),X=[`conversational`,`documentary`,`summarizer`,`curator`],kn=new Set(X),An=`conversational`;function jn(e){let t=new Set((e??[]).filter(e=>kn.has(e)));return t.size===0?[An]:X.filter(e=>t.has(e))}var Z=n(),Q={name:``,gatewayUrl:``,bridgeUrl:``,displayName:``,kind:`openclaw`,transport:`ws`,gatewayVersion:``,gatewayHttpUrl:``,authMode:`token`,personScopes:`capped`,identitySource:`canonical`,participantIdentity:`owner`,managePermissionModes:!1,systemIdentity:``,streamTransport:gn,widgetsEnabled:!0,widgetPromptConfirm:!1},Mn={openclaw:[`token`,`deviceIdentity`],hermes:[`apiKey`]};function Nn(e){return{name:e.name,gatewayUrl:e.gatewayUrl,bridgeUrl:e.bridgeUrl??``,displayName:e.displayName??``,kind:e.kind??`openclaw`,transport:e.transport??`ws`,gatewayVersion:e.gatewayVersion??``,gatewayHttpUrl:e.gatewayHttpUrl??``,authMode:e.authMode??`token`,personScopes:e.personScopes??`capped`,identitySource:e.identitySource??`canonical`,participantIdentity:e.participantIdentity??`owner`,managePermissionModes:e.managePermissionModes===!0,systemIdentity:e.systemIdentity??``,streamTransport:e.streamTransport??`reactive`,widgetsEnabled:e.config?.widgetsEnabled!==!1,widgetPromptConfirm:e.config?.widgetPromptConfirm===!0}}function Pn(){let e=O(F.admin.listInstances,{}),t=O(F.agents.listAllInstanceAgents,{}),n=M(F.admin.upsertInstance),a=M(F.widgets.setInstanceWidgets),o=M(F.admin.deleteInstance),s=W(),[u,d]=(0,Y.useState)(!1),[f,h]=(0,Y.useState)(Q),[v,x]=(0,Y.useState)(null),[w,T]=(0,Y.useState)(null),[E,D]=(0,Y.useState)(null),[k,A]=(0,Y.useState)(null);async function ie(){try{let t=await n({instanceId:k??void 0,name:f.name,gatewayUrl:f.gatewayUrl,bridgeUrl:f.bridgeUrl||void 0,displayName:f.displayName||void 0,kind:f.kind,transport:f.kind===`hermes`?f.transport:void 0,gatewayVersion:f.gatewayVersion||void 0,gatewayHttpUrl:f.gatewayHttpUrl||void 0,...f.kind===`openclaw`?{authMode:f.authMode,personScopes:f.personScopes,identitySource:f.identitySource,participantIdentity:f.participantIdentity,managePermissionModes:f.managePermissionModes,systemIdentity:f.systemIdentity||void 0}:{},streamTransport:f.streamTransport}),r=k===null?null:e?.find(e=>e._id===k),i=r?.config?.widgetsEnabled!==!1,o=r?.config?.widgetPromptConfirm===!0;f.kind===`openclaw`&&(f.widgetsEnabled!==i||f.widgetPromptConfirm!==o)&&await a({instanceId:t,enabled:f.widgetsEnabled,promptConfirm:f.widgetPromptConfirm}),h(Q),A(null),d(!1)}catch(e){s.error(ln(),e)}}return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`p`,{className:`oc-admin__hint`,children:[it(),(0,Z.jsx)(`strong`,{children:fn()}),rn()]}),(0,Z.jsx)(Dn,{title:et(),rows:e,addLabel:xt(),onAdd:()=>{A(null),h(Q),d(!0)},emptyHint:Ct(),columns:[{header:Lt(),cell:e=>e.name,sort:e=>e.name},{header:Ut(),cell:e=>(0,Z.jsx)(B,{variant:`outline`,children:e.kind??`openclaw`}),sort:e=>e.kind??`openclaw`},{header:yt(),cell:e=>e.gatewayUrl,sort:e=>e.gatewayUrl},{header:ft(),cell:e=>e.displayName??`—`,sort:e=>e.displayName??null},{header:p(),cell:e=>{let n=(t?.[e.name]??[]).filter(e=>e.presentInLastOk!==!1&&e.enabled);if(n.length===0)return(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:`—`});let r=t=>e.defaultAgentId===t;return(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:[...n].sort((e,t)=>Number(r(t.agentId))-Number(r(e.agentId))).map(e=>(0,Z.jsxs)(B,{variant:r(e.agentId)?`default`:`outline`,title:r(e.agentId)?S():void 0,children:[e.emoji?`${e.emoji} `:``,e.displayName??e.agentId]},e.agentId))})}}],rowActions:e=>[{label:Yt(),onSelect:()=>{A(e._id),h(Nn(e)),d(!0)}},{label:Ne(),onSelect:()=>x(e.name)},{label:oe(),onSelect:()=>D(e)},{label:$t(),onSelect:()=>T(e)},{label:Nt(),variant:`destructive`,onSelect:()=>void o({instanceId:e._id})}],bulkActions:[{label:Nt(),variant:`destructive`,onSelect:e=>e.forEach(e=>void o({instanceId:e}))}]}),(0,Z.jsx)(xn,{open:u,onOpenChange:d,title:k?Vt():st(),description:wt(),canSubmit:!!(f.name&&f.gatewayUrl),onSubmit:ie,submitLabel:qt(),children:(0,Z.jsxs)(`div`,{className:`oc-form`,children:[(0,Z.jsxs)($,{label:zt(),children:[(0,Z.jsx)(R,{value:f.name,disabled:k!==null,onChange:e=>h({...f,name:e.target.value})}),k?(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:nt()}):null]}),(0,Z.jsx)($,{label:Zt(),children:(0,Z.jsxs)(K,{value:f.kind,onValueChange:e=>h({...f,kind:e}),children:[(0,Z.jsx)(q,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(U,{})}),(0,Z.jsxs)(J,{children:[(0,Z.jsx)(G,{value:`openclaw`,children:`OpenClaw`}),(0,Z.jsx)(G,{value:`hermes`,children:`Hermes`})]})]})}),f.kind===`hermes`?(0,Z.jsx)($,{label:ee(),children:(0,Z.jsxs)(K,{value:f.transport,onValueChange:e=>h({...f,transport:e}),children:[(0,Z.jsx)(q,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(U,{})}),(0,Z.jsxs)(J,{children:[(0,Z.jsx)(G,{value:`ws`,children:Le()}),(0,Z.jsx)(G,{value:`rest`,children:sn()})]})]})}):null,(0,Z.jsx)($,{label:ht(),children:(0,Z.jsx)(R,{value:f.gatewayUrl,onChange:e=>h({...f,gatewayUrl:e.target.value})})}),(0,Z.jsx)($,{label:i(),children:(0,Z.jsx)(R,{value:f.bridgeUrl,placeholder:De(),onChange:e=>h({...f,bridgeUrl:e.target.value})})}),(0,Z.jsx)($,{label:Ze(),children:(0,Z.jsx)(R,{value:f.displayName,onChange:e=>h({...f,displayName:e.target.value})})}),(0,Z.jsxs)($,{label:_t(),children:[(0,Z.jsxs)(K,{value:f.streamTransport,onValueChange:e=>h({...f,streamTransport:e}),children:[(0,Z.jsx)(q,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(U,{})}),(0,Z.jsx)(J,{children:_n.map(e=>(0,Z.jsx)(G,{value:e,children:e},e))})]}),(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:ut()})]}),(0,Z.jsx)($,{label:Ge(),children:(0,Z.jsx)(R,{value:f.gatewayVersion,placeholder:Je(),onChange:e=>h({...f,gatewayVersion:e.target.value})})}),f.kind===`openclaw`?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)($,{label:Ie(),children:[(0,Z.jsxs)(K,{value:f.authMode,onValueChange:e=>h({...f,authMode:e}),children:[(0,Z.jsx)(q,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(U,{})}),(0,Z.jsxs)(J,{children:[(0,Z.jsx)(G,{value:`token`,children:on()}),(0,Z.jsx)(G,{value:`trusted-proxy`,children:m()})]})]}),(0,Z.jsx)(`p`,{className:`oc-field__hint`,children:f.authMode===`trusted-proxy`?un():Pe()})]}),f.authMode===`trusted-proxy`?(0,Z.jsxs)($,{label:C(),children:[(0,Z.jsxs)(K,{value:f.personScopes,onValueChange:e=>h({...f,personScopes:e}),children:[(0,Z.jsx)(q,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(U,{})}),(0,Z.jsxs)(J,{children:[(0,Z.jsx)(G,{value:`capped`,children:Te()}),(0,Z.jsx)(G,{value:`full`,children:_e()})]})]}),(0,Z.jsx)(`p`,{className:`oc-field__hint`,children:f.personScopes===`full`?Ot():pe()})]}):null,f.authMode===`trusted-proxy`?(0,Z.jsxs)($,{label:l(),children:[(0,Z.jsxs)(K,{value:f.identitySource,onValueChange:e=>h({...f,identitySource:e}),children:[(0,Z.jsx)(q,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(U,{})}),(0,Z.jsxs)(J,{children:[(0,Z.jsx)(G,{value:`canonical`,children:Mt()}),(0,Z.jsx)(G,{value:`email`,children:xe()})]})]}),(0,Z.jsx)(`p`,{className:`oc-field__hint`,children:f.identitySource===`email`?b():_()})]}):null,f.authMode===`trusted-proxy`?(0,Z.jsxs)($,{label:te(),children:[(0,Z.jsxs)(K,{value:f.participantIdentity,onValueChange:e=>h({...f,participantIdentity:e}),children:[(0,Z.jsx)(q,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(U,{})}),(0,Z.jsxs)(J,{children:[(0,Z.jsx)(G,{value:`owner`,children:we()}),(0,Z.jsx)(G,{value:`self`,children:ge()})]})]}),(0,Z.jsx)(`p`,{className:`oc-field__hint`,children:f.participantIdentity===`self`?y():fe()})]}):null,f.kind===`openclaw`?(0,Z.jsxs)($,{label:Dt(),children:[(0,Z.jsxs)(K,{value:f.managePermissionModes?`on`:`off`,onValueChange:e=>h({...f,managePermissionModes:e===`on`}),children:[(0,Z.jsx)(q,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(U,{})}),(0,Z.jsxs)(J,{children:[(0,Z.jsx)(G,{value:`off`,children:c()}),(0,Z.jsx)(G,{value:`on`,children:jt()})]})]}),(0,Z.jsx)(`p`,{className:`oc-field__hint`,children:f.managePermissionModes?g():be()})]}):null,f.kind===`openclaw`?(0,Z.jsxs)($,{label:gt(),children:[(0,Z.jsxs)(K,{value:f.widgetsEnabled?`on`:`off`,onValueChange:e=>h({...f,widgetsEnabled:e===`on`}),children:[(0,Z.jsx)(q,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(U,{})}),(0,Z.jsxs)(J,{children:[(0,Z.jsx)(G,{value:`on`,children:r()}),(0,Z.jsx)(G,{value:`off`,children:Ee()})]})]}),(0,Z.jsx)(`p`,{className:`oc-field__hint`,children:f.widgetsEnabled?Xe():We()})]}):null,f.kind===`openclaw`&&f.widgetsEnabled?(0,Z.jsxs)($,{label:qe(),children:[(0,Z.jsxs)(K,{value:f.widgetPromptConfirm?`on`:`off`,onValueChange:e=>h({...f,widgetPromptConfirm:e===`on`}),children:[(0,Z.jsx)(q,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(U,{})}),(0,Z.jsxs)(J,{children:[(0,Z.jsx)(G,{value:`off`,children:ne()}),(0,Z.jsx)(G,{value:`on`,children:Wt()})]})]}),(0,Z.jsx)(`p`,{className:`oc-field__hint`,children:ae()})]}):null,f.authMode===`trusted-proxy`?(0,Z.jsx)($,{label:at(),children:(0,Z.jsx)(R,{value:f.systemIdentity,placeholder:pn(),onChange:e=>h({...f,systemIdentity:e.target.value})})}):null]}):null,(0,Z.jsx)($,{label:re(),children:(0,Z.jsx)(R,{value:f.gatewayHttpUrl,placeholder:Gt(),onChange:e=>h({...f,gatewayHttpUrl:e.target.value})})})]})}),(0,Z.jsx)(Wn,{instanceName:v,open:v!==null,onOpenChange:e=>{e||x(null)}}),w?(0,Z.jsx)(On,{instance:w,onClose:()=>T(null)},w._id):null,E?(0,Z.jsx)(Fn,{instance:E,onClose:()=>D(null)},E._id):null]})}function Fn({instance:e,onClose:t}){let n=O(F.instanceSecrets.listInstanceSecretStatus,{}),r=Mn[e.kind??`openclaw`],i=(0,Y.useMemo)(()=>{let t={};for(let r of n??[])r.instanceId===e._id&&(t[r.field]=r.updatedAt);return t},[n,e._id]);return(0,Z.jsx)(vn,{open:!0,onOpenChange:e=>!e&&t(),children:(0,Z.jsxs)(En,{onOpenAutoFocus:e=>e.preventDefault(),children:[(0,Z.jsxs)(z,{children:[(0,Z.jsx)(H,{children:w({instance:e.displayName??e.name})}),(0,Z.jsx)(bn,{children:He()})]}),(0,Z.jsx)(`div`,{className:`oc-form`,children:r.map(t=>(0,Z.jsx)(Rn,{instanceId:e._id,field:t,updatedAt:i[t]??null},t))}),(0,Z.jsx)(`div`,{className:`oc-bridgesecret`,children:(0,Z.jsx)(Ln,{instance:e})}),(0,Z.jsx)(In,{instance:e})]})})}function In({instance:e}){let t=I(F.instanceSync.forceInstanceSync),n=W(),[r,i]=(0,Y.useState)(!1);async function a(){if(!r){i(!0);try{switch((await t({instanceId:e._id})).status){case`synced`:n.success(an());break;case`no_agents`:n.success(Me());break;case`no_bridge_url`:n.error(cn());break;case`deploy_misconfigured`:n.error(rt());break;case`unauthorized`:n.error(nn());break;case`not_served`:n.error($e());break;default:n.error(dn());break}}catch(e){n.error(f(),e)}finally{i(!1)}}}return(0,Z.jsxs)(`div`,{className:`oc-form`,children:[(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:bt()}),(0,Z.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,Z.jsx)(L,{size:`sm`,variant:`outline`,onClick:()=>void a(),disabled:r,children:r?Fe():v()})})]})}function Ln({instance:e}){let t=O(F.bridgeAuth.listBridgeAuthStatus,{}),n=I(F.bridgeAuth.mintBridgeSecret),r=M(F.bridgeAuth.revokeBridgeSecret),i=W(),[a,o]=(0,Y.useState)(!1),[s,c]=(0,Y.useState)(null),[l,d]=(0,Y.useState)(!1),f=(t??[]).find(t=>t.instanceId===e._id),p=f!==void 0;async function m(){if(!a){o(!0);try{c((await n({instanceId:e._id})).plaintext),d(!1)}catch(e){i.error(P(),e)}finally{o(!1)}}}async function h(){if(!a){o(!0);try{await r({instanceId:e._id}),c(null),i.success(Qt())}catch(e){i.error(P(),e)}finally{o(!1)}}}async function g(){if(s)try{await navigator.clipboard.writeText(s),d(!0)}catch{}}return(0,Z.jsxs)($,{label:St(),children:[(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:It()}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(B,{variant:p?`outline`:`secondary`,children:p?`${u()} · ${f.prefix}…${f.lastFour}`:mn()}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(L,{size:`sm`,onClick:()=>void m(),disabled:a,children:p?vt():Ht()}),p?(0,Z.jsx)(L,{size:`sm`,variant:`destructive`,onClick:()=>void h(),disabled:a,children:dt()}):null]})]}),s?(0,Z.jsxs)(`div`,{className:`oc-bridgesecret__reveal`,children:[(0,Z.jsx)(`p`,{className:`oc-sa__minted-warning`,children:ot()}),(0,Z.jsxs)(`div`,{className:`oc-sa__minted-box`,children:[(0,Z.jsx)(`code`,{className:`oc-sa__minted-plain`,children:s}),(0,Z.jsx)(L,{variant:`outline`,size:`sm`,onClick:()=>void g(),children:l?je():ue()})]}),(0,Z.jsx)(L,{size:`sm`,variant:`ghost`,onClick:()=>{c(null),d(!1)},children:Jt()})]}):null]})}function Rn({instanceId:e,field:t,updatedAt:n}){let r=I(F.instanceSecrets.setInstanceSecret),i=M(F.instanceSecrets.clearInstanceSecret),a=I(F.deviceIdentity.generateDeviceIdentity),s=W(),[c,l]=(0,Y.useState)(``),[d,f]=(0,Y.useState)(!1),[p,m]=(0,Y.useState)(null),[g,_]=(0,Y.useState)(!1),v=n!==null,y=t===`deviceIdentity`,b=t===`token`?Re():t===`deviceIdentity`?E():Be();async function ee(){if(!(!c.trim()||d)){f(!0);try{await r({instanceId:e,field:t,plaintext:c}),l(``),m(null),_(!1),s.success(Se())}catch(e){s.error(me(),e)}finally{f(!1)}}}async function S(){if(!d){f(!0);try{await i({instanceId:e,field:t}),m(null),_(!1),s.success(de())}catch(e){s.error(me(),e)}finally{f(!1)}}}async function te(){if(!d){f(!0);try{m(await a({instanceId:e})),_(!1),s.success(kt())}catch(e){s.error(h(),e)}finally{f(!1)}}}let C=p?`openclaw devices approve ${p.id}`:``;async function w(){if(C)try{await navigator.clipboard.writeText(C),_(!0)}catch{}}return(0,Z.jsxs)($,{label:b,children:[y?(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:o()}):null,(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(B,{variant:v?`outline`:`secondary`,children:v?u():mn()}),(0,Z.jsx)(R,{type:`password`,autoComplete:`off`,className:`flex-1 min-w-32`,value:c,placeholder:v?ce():ke(),onChange:e=>l(e.target.value)}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(L,{size:`sm`,onClick:()=>void ee(),disabled:d||c.trim().length===0,children:k()}),y?(0,Z.jsx)(L,{size:`sm`,variant:`outline`,onClick:()=>void te(),disabled:d,children:Tt()}):null,v?(0,Z.jsx)(L,{size:`sm`,variant:`destructive`,onClick:()=>void S(),disabled:d,children:x()}):null]})]}),p?(0,Z.jsxs)(`div`,{className:`oc-bridgesecret__reveal`,children:[(0,Z.jsx)(`p`,{className:`text-sm font-medium`,children:kt()}),(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:ve()}),(0,Z.jsxs)(`div`,{className:`oc-sa__minted-box`,children:[(0,Z.jsx)(`code`,{className:`oc-sa__minted-plain`,children:C}),(0,Z.jsx)(L,{variant:`outline`,size:`sm`,onClick:()=>void w(),children:g?je():ue()})]}),(0,Z.jsx)(L,{size:`sm`,variant:`ghost`,onClick:()=>{m(null),_(!1)},children:Jt()})]}):null]})}var zn={conversational:Ke,documentary:ie,summarizer:pt,curator:Pt},Bn={conversational:Ye,documentary:Kt,summarizer:en,curator:ct},Vn=e=>(zn[e]??(()=>e))(),Hn=e=>(Bn[e]??(()=>``))();function Un({agentId:e,types:t,onToggle:n}){return(0,Z.jsxs)(`div`,{className:`oc-agentcard__types`,children:[(0,Z.jsx)(`span`,{className:`oc-agentcard__types-label`,children:mt()}),t.map(e=>(0,Z.jsx)(B,{variant:`secondary`,className:`oc-agenttype__chip`,title:Hn(e),children:Vn(e)},e)),(0,Z.jsxs)(wn,{children:[(0,Z.jsx)(Sn,{asChild:!0,children:(0,Z.jsx)(L,{type:`button`,variant:`outline`,size:`sm`,className:`h-7`,children:a()})}),(0,Z.jsxs)(Tn,{align:`start`,className:`oc-agenttypes-pop`,children:[(0,Z.jsx)(`p`,{className:`oc-agenttypes-pop__title`,children:Oe()}),(0,Z.jsx)(`p`,{className:`oc-agenttypes-pop__hint`,children:Qe()}),(0,Z.jsx)(`div`,{className:`oc-agenttypes-pop__list`,children:X.map(r=>{let i=`agtype-${e}-${r}`;return(0,Z.jsxs)(`div`,{className:`oc-agenttypes-pop__item`,children:[(0,Z.jsx)(V,{id:i,checked:t.includes(r),onCheckedChange:()=>n(r)}),(0,Z.jsxs)(`label`,{htmlFor:i,className:`oc-agenttypes-pop__text`,children:[(0,Z.jsx)(`span`,{className:`oc-agenttypes-pop__name`,children:Vn(r)}),(0,Z.jsx)(`span`,{className:`oc-agenttypes-pop__desc`,children:Hn(r)})]})]},r)})})]})]})]})}function Wn({instanceName:e,open:t,onOpenChange:n}){let r=O(F.agents.listAgentsForInstance,t&&e?{instanceName:e}:`skip`),i=M(F.agents.setAgentEnabled).withOptimisticUpdate((e,{instanceName:t,agentId:n,enabled:r})=>{let i=e.getQuery(F.agents.listAgentsForInstance,{instanceName:t});i&&e.setQuery(F.agents.listAgentsForInstance,{instanceName:t},{...i,agents:i.agents.map(e=>e.agentId===n?{...e,enabled:r}:e)})}),a=M(F.agents.setInstanceDefaultAgent).withOptimisticUpdate((e,{instanceName:t,agentId:n})=>{let r=e.getQuery(F.agents.listAgentsForInstance,{instanceName:t});r&&e.setQuery(F.agents.listAgentsForInstance,{instanceName:t},{...r,defaultAgentId:n})}),o=M(F.agents.setAgentTypes).withOptimisticUpdate((e,{instanceName:t,agentId:n,types:r})=>{let i=e.getQuery(F.agents.listAgentsForInstance,{instanceName:t});if(!i)return;let a=jn(r);e.setQuery(F.agents.listAgentsForInstance,{instanceName:t},{...i,agents:i.agents.map(e=>e.agentId===n?{...e,types:a}:e)})}),c=M(F.agents.setAgentDescription).withOptimisticUpdate((e,{instanceName:t,agentId:n,description:r})=>{let i=e.getQuery(F.agents.listAgentsForInstance,{instanceName:t});if(!i)return;let a=r.trim();e.setQuery(F.agents.listAgentsForInstance,{instanceName:t},{...i,agents:i.agents.map(e=>e.agentId===n?{...e,description:a.length===0?null:a}:e)})}),l=M(F.agents.removeInstanceAgent),u=M(F.agents.setAgentReservation),f=O(F.groups.listGroupLabels,t?{}:`skip`),p=Cn(),m=W();async function h(t,n){if(e&&await p({title:Et({name:n}),description:s(),confirmLabel:j()}))try{await u({instanceName:e,agentId:t,groupId:null})}catch(e){m.error(N(),yn(e))}}async function g(t,n,r){if(!e)return;let i=(f??[]).find(e=>e._id===r)?.name??`?`;if(await p({title:tn({name:n,group:i}),description:Ft({group:i}),confirmLabel:lt()}))try{await u({instanceName:e,agentId:t,groupId:r})}catch(e){m.error(N(),yn(e))}}async function _(t,n){if(e)try{await i({instanceName:e,agentId:t,enabled:n})}catch(e){m.error(N(),e)}}async function v(t){if(e)try{await a({instanceName:e,agentId:t})}catch(e){m.error(N(),e)}}async function y(t,n,r){if(!e)return;let i=r.includes(n)?r.filter(e=>e!==n):[...r,n];try{await o({instanceName:e,agentId:t,types:i})}catch(e){m.error(N(),e)}}async function b(t,n){if(e&&await p({title:Ue({name:n}),description:ze(),confirmLabel:D(),destructive:!0}))try{await l({instanceName:e,agentId:t}),m.success(Ve())}catch(e){m.error(N(),e)}}return(0,Z.jsx)(vn,{open:t,onOpenChange:n,children:(0,Z.jsxs)(En,{className:`oc-access`,children:[(0,Z.jsxs)(z,{children:[(0,Z.jsx)(H,{children:Bt({name:e??``})}),(0,Z.jsx)(bn,{children:tt()})]}),r===void 0?(0,Z.jsx)(`p`,{className:`oc-access__hint`,children:d()}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`oc-access__poll`,children:r.discovery===null?hn():r.discovery.lastPollOk?Ae():le({error:r.discovery.error??`?`})}),r.agents.length===0?(0,Z.jsx)(`p`,{className:`oc-access__hint`,children:A()}):(0,Z.jsx)(`div`,{className:`oc-access__list`,children:r.agents.map(t=>{let n=t.presentInLastOk===!1,i=r.defaultAgentId===t.agentId,a=t.displayName??t.agentId,o=t.types??[];return(0,Z.jsxs)(`div`,{className:`oc-agentcard`+(t.enabled?``:` oc-agentcard--off`),children:[(0,Z.jsxs)(`div`,{className:`oc-agentcard__head`,children:[(0,Z.jsx)(V,{checked:t.enabled,disabled:n,"aria-label":a,onCheckedChange:e=>void _(t.agentId,e===!0)}),(0,Z.jsxs)(`span`,{className:`oc-agentcard__name`,title:a,children:[t.emoji?`${t.emoji} `:``,a]}),t.model?(0,Z.jsx)(`span`,{className:`oc-access__model`,children:t.model}):null,t.reserved?(0,Z.jsx)(B,{variant:`outline`,children:t.reserved.groupName===null?he():Ce({group:t.reserved.groupName})}):null,n?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(B,{variant:`outline`,className:`oc-access__gone`,children:ye()}),(0,Z.jsx)(L,{size:`sm`,variant:`ghost`,className:`h-7 text-destructive`,onClick:()=>void b(t.agentId,a),children:T()})]}):i?(0,Z.jsx)(B,{variant:`default`,children:S()}):(0,Z.jsx)(L,{size:`sm`,variant:`outline`,className:`h-7`,disabled:!t.enabled||t.reserved!==null,onClick:()=>void v(t.agentId),children:se()})]}),t.reserved?(0,Z.jsxs)(`div`,{className:`oc-agentcard__head`,children:[(0,Z.jsx)(L,{size:`sm`,variant:`outline`,className:`h-7`,onClick:()=>void h(t.agentId,a),children:j()}),(0,Z.jsxs)(K,{value:``,onValueChange:e=>void g(t.agentId,a,e),children:[(0,Z.jsx)(q,{size:`sm`,className:`h-7`,children:(0,Z.jsx)(U,{placeholder:At()})}),(0,Z.jsx)(J,{children:(f??[]).filter(e=>e._id!==t.reserved?.groupId).map(e=>(0,Z.jsx)(G,{value:e._id,children:e.name},e._id))})]})]}):null,t.enabled?(0,Z.jsx)(Un,{agentId:t.agentId,types:o,onToggle:e=>void y(t.agentId,e,o)}):null,t.enabled?(0,Z.jsx)(Gn,{value:t.description??``,onSave:async n=>{if(e)try{await c({instanceName:e,agentId:t.agentId,description:n})}catch(e){m.error(N(),e)}}}):null]},t.agentId)})})]})]})})}function Gn({value:e,onSave:t}){let[n,r]=(0,Y.useState)(e);(0,Y.useEffect)(()=>{r(e)},[e]);let i=()=>{n.trim()!==e.trim()&&t(n)};return(0,Z.jsx)(R,{className:`oc-agentcard__desc`,value:n,maxLength:280,placeholder:Rt(),"aria-label":Xt(),onChange:e=>r(e.target.value),onBlur:i,onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),i())}})}function $({label:e,children:t}){return(0,Z.jsxs)(`label`,{className:`oc-field`,children:[(0,Z.jsx)(`span`,{className:`oc-field__label`,children:e}),t]})}export{Pn as InstancesTab};
@@ -0,0 +1 @@
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{Ah as r,Dh as i,Eh as a,HX as o,Mh as s,Oh as c,Th as l,VX as u,aR as d,cR as f,dR as p,fR as m,iR as h,jh as g,kh as _,lR as v,mR as y,nR as b,oR as x,pR as S,rR as C,sR as w,t as T,tR as E,uR as D,wh as O,zX as k}from"./api-Ca1H8N44.js";import{t as A}from"./button-BbEZKLza.js";import{$t as j,Jt as M,Mt as N}from"./index-bizOs74t.js";var P=t(e(),1),F=n();function I(){let e=o(T.integrations.status.status,{}),t=u(T.admin.setIntegrationConfig),[n,i]=(0,P.useState)(null);if((0,P.useEffect)(()=>{e&&n===null&&i(e.config)},[e,n]),!e||!n)return(0,F.jsx)(`p`,{className:`oc-admin__hint`,children:y()});let a=n,c=(e,t,n)=>i({...a,[e]:{...a[e],[t]:n}}),l=(e,n)=>void t({[e]:n});return(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`p`,{className:`oc-admin__hint`,children:[S(),` `,(0,F.jsx)(`strong`,{children:m()}),` `,p()]}),(0,F.jsxs)(L,{title:`Langfuse`,status:e.langfuse.configured?e.langfuse.enabled?(0,F.jsx)(M,{variant:`secondary`,children:D()}):(0,F.jsx)(M,{variant:`outline`,children:v()}):(0,F.jsx)(M,{variant:`outline`,children:f()}),note:w(),children:[(0,F.jsx)(R,{label:d(),children:(0,F.jsx)(j,{value:a.langfuse.host??``,placeholder:e.langfuse.effectiveHost,onChange:e=>c(`langfuse`,`host`,e.target.value),onBlur:()=>l(`langfuse`,{host:a.langfuse.host??``})})}),(0,F.jsx)(z,{label:E(),checked:a.langfuse.enabled??!0,onChange:e=>{c(`langfuse`,`enabled`,e),l(`langfuse`,{enabled:e})}})]}),(0,F.jsxs)(L,{title:`Opik`,status:e.opik.configured?e.opik.enabled?(0,F.jsx)(M,{variant:`secondary`,children:D()}):(0,F.jsx)(M,{variant:`outline`,children:v()}):(0,F.jsx)(M,{variant:`outline`,children:f()}),note:x(),children:[(0,F.jsx)(R,{label:h(),children:(0,F.jsx)(j,{value:a.opik.baseUrl??``,placeholder:e.opik.effectiveBaseUrl,onChange:e=>c(`opik`,`baseUrl`,e.target.value),onBlur:()=>l(`opik`,{baseUrl:a.opik.baseUrl??``})})}),(0,F.jsx)(R,{label:C(),children:(0,F.jsx)(j,{value:a.opik.workspace??``,placeholder:e.opik.effectiveWorkspace||b(),onChange:e=>c(`opik`,`workspace`,e.target.value),onBlur:()=>l(`opik`,{workspace:a.opik.workspace??``})})}),(0,F.jsx)(z,{label:E(),checked:a.opik.enabled??!0,onChange:e=>{c(`opik`,`enabled`,e),l(`opik`,{enabled:e})}})]}),(0,F.jsxs)(L,{title:`OpenTelemetry (OTLP)`,status:e.otlp.configured?e.otlp.enabled?(0,F.jsx)(M,{variant:`secondary`,children:D()}):(0,F.jsx)(M,{variant:`outline`,children:v()}):(0,F.jsx)(M,{variant:`outline`,children:s()}),note:g(),children:[(0,F.jsx)(R,{label:r(),children:(0,F.jsx)(j,{value:a.otlp.endpoint??``,placeholder:e.otlp.effectiveEndpoint||`https://otlp.example.com/v1/traces`,onChange:e=>c(`otlp`,`endpoint`,e.target.value),onBlur:()=>l(`otlp`,{endpoint:a.otlp.endpoint??``})})}),(0,F.jsx)(B,{headersSet:e.otlp.headersSet}),(0,F.jsx)(z,{label:E(),checked:a.otlp.enabled??!0,onChange:e=>{c(`otlp`,`enabled`,e),l(`otlp`,{enabled:e})}})]})]})}function L({title:e,status:t,note:n,children:r}){return(0,F.jsxs)(`section`,{className:`oc-int__section`,children:[(0,F.jsxs)(`div`,{className:`oc-int__section-head`,children:[(0,F.jsx)(`h3`,{className:`oc-uipa__h`,children:e}),t]}),n?(0,F.jsx)(`p`,{className:`oc-uipa__note`,children:n}):null,(0,F.jsx)(`div`,{className:`oc-int__fields`,children:r})]})}function R({label:e,children:t}){return(0,F.jsxs)(`label`,{className:`oc-int__field`,children:[(0,F.jsx)(`span`,{className:`oc-int__field-label`,children:e}),t]})}function z({label:e,checked:t,onChange:n}){return(0,F.jsxs)(`label`,{className:`oc-int__toggle`,children:[(0,F.jsx)(N,{checked:t,onCheckedChange:e=>n(e===!0)}),(0,F.jsx)(`span`,{children:e})]})}function B({headersSet:e}){let t=k(T.integrations.otlpSecret.setOtlpHeaders),n=u(T.integrations.otlpSecret.clearOtlpHeaders),[r,o]=(0,P.useState)(``),[s,d]=(0,P.useState)(null),[f,p]=(0,P.useState)(!1),m=async()=>{p(!0),d(null);try{await t({headersJson:r}),o(``)}catch(e){d(e instanceof Error?e.message:String(e))}finally{p(!1)}};return(0,F.jsxs)(R,{label:_(),children:[(0,F.jsx)(j,{value:r,placeholder:e?c():i(),onChange:e=>o(e.target.value)}),(0,F.jsxs)(`div`,{className:`oc-int__otlp-headers-actions`,children:[(0,F.jsx)(A,{size:`sm`,disabled:f||r.trim().length===0,onClick:()=>void m(),children:a()}),e?(0,F.jsx)(A,{variant:`ghost`,size:`sm`,disabled:f,onClick:()=>void n({}),children:l()}):null]}),s?(0,F.jsx)(`p`,{className:`oc-int__otlp-headers-error`,children:s}):null,(0,F.jsx)(`p`,{className:`oc-uipa__note`,children:O()})]})}export{I as IntegrationsTab};
@@ -0,0 +1 @@
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{CO as r,DO as i,EO as a,HX as o,Hz as s,OO as c,SO as l,TO as u,_O as d,_z as f,bO as p,gO as m,gz as h,hO as g,hz as ee,kO as te,mz as _,oz as v,sz as y,t as b,vO as x,wO as S,xO as C,yO as w}from"./api-Ca1H8N44.js";import{dr as T,fr as E,ft as D,i as ne,o as re,r as O}from"./index-bizOs74t.js";import{a as k,n as A,o as j,r as M,t as N}from"./card-Du7JykLJ.js";import{n as P,t as F}from"./TimeRangePicker-D6jq73FP.js";var I=t(e(),1),L={API_CALLS:`api.calls`,API_ERRORS:`api.errors`,API_LATENCY_AVG_MS:`api.latency.avg_ms`,OPENCLAW_INGEST:`openclaw.ingest`,CHAT_SEND:`chat.send`,ASSISTANT_STREAM_ERRORS:`assistant.stream.errors`,ASSISTANT_ANNOUNCE_ERRORS:`assistant.announce.errors`,CONVEX_PROBE_LATENCY_AVG_MS:`convex.probe.latency.avg_ms`},R=Object.keys(L).length,z=n(),B=15,V=e=>String(Math.round(e));function H(){let e=o(b.me.getMe,{host:D})?.permissions?.includes(`traces.read`)??!1,t=o(b.deliveryTiming.listDeliverySessions,e?{}:`skip`),n=(0,I.useMemo)(()=>t?t.filter(e=>!e.active&&e.rollup!==null&&e.rollup.cP50!==null&&e.rollup.aP50!==null).slice(0,B).reverse().map(e=>({startedAt:e.startedAt,cP50:e.rollup?.cP50,aP50:e.rollup?.aP50})):[],[t]);return t===void 0?null:(0,z.jsxs)(`section`,{className:`oc-kpi__group`,children:[(0,z.jsx)(`h2`,{className:`oc-kpi__group-title`,children:s()}),(0,z.jsxs)(N,{children:[(0,z.jsxs)(k,{children:[(0,z.jsx)(j,{children:f()}),(0,z.jsx)(M,{children:ee()})]}),(0,z.jsx)(A,{children:n.length<2?(0,z.jsx)(`p`,{className:`oc-admin__hint`,children:_()}):(0,z.jsx)(U,{series:n})})]})]})}function U({series:e}){let t=e.map(e=>e.cP50),n=e.map(e=>e.aP50),r=Math.max(1,...t,...n),i=t=>6+t*468/(e.length-1),a=e=>74-e*68/r,o=e=>e.map((e,t)=>`${t===0?`M`:`L`}${i(t).toFixed(1)},${a(e).toFixed(1)}`).join(` `),s=e[e.length-1];return(0,z.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,z.jsxs)(`div`,{className:`flex gap-3 text-xs text-muted-foreground`,children:[(0,z.jsxs)(`span`,{style:{color:`var(--primary)`},children:[v(),` p50 `,V(s.cP50),` `,h()]}),(0,z.jsxs)(`span`,{children:[y(),` p50 `,V(s.aP50),` `,h()]})]}),(0,z.jsxs)(`svg`,{viewBox:`0 0 480 80`,className:`h-20 w-full`,preserveAspectRatio:`none`,role:`img`,"aria-label":f(),children:[(0,z.jsx)(`path`,{d:o(n),fill:`none`,style:{stroke:`var(--muted-foreground)`},strokeWidth:1.5}),(0,z.jsx)(`path`,{d:o(t),fill:`none`,style:{stroke:`var(--primary)`},strokeWidth:1.5})]})]})}var W=[{metric:`api.calls`,label:te(),unit:`/h`,group:`API`,isError:!1},{metric:`api.errors`,label:c(),unit:`/h`,group:`API`,isError:!0},{metric:`api.latency.avg_ms`,label:i(),unit:`ms`,group:`API`,isError:!1},{metric:`openclaw.ingest`,label:a(),unit:`/h`,group:`OpenClaw`,isError:!1},{metric:`chat.send`,label:u(),unit:`/h`,group:`Chat`,isError:!1},{metric:L.ASSISTANT_STREAM_ERRORS,label:S(),unit:`/h`,group:`Assistant`,isError:!0},{metric:L.ASSISTANT_ANNOUNCE_ERRORS,label:r(),unit:`/h`,group:`Assistant`,isError:!0}],G=R,K=[`API`,`OpenClaw`,`Chat`,`Assistant`],q=1e3,J=36e5;function Y(e,t){let n=Math.max(1,Math.ceil((t-e)/J)),r=Math.min(n*G,q);return{rowLimit:r,buckets:Math.max(1,Math.floor(r/G))}}function ie(){let e=E({from:`/settings/kpi`}),t=T({from:`/settings/kpi`}),n=ne(e.from,e.to,O,`now`),r=e=>void t({search:t=>({...t,...re(e)})}),{from:i,to:a}=P(n),{rowLimit:s,buckets:c}=Y(i,a),u=o(b.kpi.listKpis,{limit:s,filter:{from:i,to:a}}),d=(0,I.useMemo)(()=>{let e=new Map;for(let t of u??[]){let n=e.get(t.metric)??[];n.push({bucket:t.bucket,value:t.value}),e.set(t.metric,n)}for(let[t,n]of e)n.sort((e,t)=>e.bucket<t.bucket?-1:+(e.bucket>t.bucket)),n.length>c&&e.set(t,n.slice(n.length-c));return e},[u,c]),f=(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`p`,{className:`oc-admin__hint`,children:[l(),` `,(0,z.jsx)(`span`,{className:`oc-filter__window`,children:C()})]}),(0,z.jsx)(ae,{value:n,onChange:r})]});return u===void 0?(0,z.jsxs)(z.Fragment,{children:[f,(0,z.jsx)(H,{}),(0,z.jsx)(`p`,{className:`oc-admin__hint`,children:p()})]}):u.length===0?(0,z.jsxs)(z.Fragment,{children:[f,(0,z.jsx)(H,{}),(0,z.jsx)(`p`,{className:`oc-admin__hint`,children:w()})]}):(0,z.jsxs)(z.Fragment,{children:[f,(0,z.jsx)(H,{}),K.map(e=>{let t=W.filter(t=>t.group===e);return t.some(e=>(d.get(e.metric)??[]).length>0)?(0,z.jsxs)(`section`,{className:`oc-kpi__group`,children:[(0,z.jsx)(`h2`,{className:`oc-kpi__group-title`,children:e}),(0,z.jsx)(`div`,{className:`oc-kpi__grid`,children:t.map(e=>(0,z.jsx)(oe,{config:e,series:d.get(e.metric)??[]},e.metric))})]},e):null})]})}function ae({value:e,onChange:t}){return(0,z.jsx)(`div`,{className:`oc-kpi__toolbar`,children:(0,z.jsx)(F,{value:e,onChange:t})})}function oe({config:e,series:t}){let n=t.length>0?t[t.length-1]:null,r=n?n.value:0;return(0,z.jsxs)(N,{size:`sm`,className:`oc-kpi__card`,children:[(0,z.jsxs)(k,{children:[(0,z.jsx)(j,{className:`oc-kpi__card-title`,children:e.label}),(0,z.jsx)(M,{className:`oc-kpi__card-metric`,children:(0,z.jsx)(`code`,{children:e.metric})})]}),(0,z.jsxs)(A,{className:`oc-kpi__card-body`,children:[(0,z.jsxs)(`div`,{className:`oc-kpi__value-row`,children:[(0,z.jsx)(`span`,{className:`oc-kpi__value`+(e.isError&&r>0?` oc-kpi__value--error`:``),children:Q(r)}),(0,z.jsx)(`span`,{className:`oc-kpi__unit`,children:e.unit})]}),(0,z.jsx)(ce,{series:t,isError:e.isError,unit:e.unit}),(0,z.jsxs)(`div`,{className:`oc-kpi__axis`,children:[n?(0,z.jsx)(`span`,{className:`oc-kpi__axis-latest`,children:x({value:$(n.bucket)})}):(0,z.jsx)(`span`,{className:`oc-kpi__muted`,children:d()}),(0,z.jsx)(`span`,{className:`oc-kpi__muted`,children:m({count:t.length})})]})]})]})}var X=240,Z=48,se=1;function ce({series:e,isError:t,unit:n}){if(e.length===0)return(0,z.jsx)(`div`,{className:`oc-kpi__chart oc-kpi__chart--empty`,"aria-hidden":!0});let r=e.reduce((e,t)=>t.value>e?t.value:e,0),i=X/e.length,a=Math.max(i-se,1);return(0,z.jsx)(`svg`,{className:`oc-kpi__chart`,viewBox:`0 0 ${X} ${Z}`,preserveAspectRatio:`none`,role:`img`,"aria-label":g({max:Q(r),unit:n}),children:e.map((e,o)=>{let s=r>0?e.value/r*(Z-1):0,c=o*i,l=Z-s;return(0,z.jsx)(`rect`,{className:`oc-kpi__bar`+(t&&e.value>0?` oc-kpi__bar--error`:``),x:c,y:l,width:a,height:s,children:(0,z.jsxs)(`title`,{children:[$(e.bucket),` · `,Q(e.value),` `,n]})},e.bucket)})})}function Q(e){return Number.isFinite(e)?Math.abs(e)>=1e3?(e/1e3).toFixed(e%1e3==0?0:1)+`k`:String(e):`0`}function $(e){let t=new Date(`${e}:00:00Z`);return Number.isNaN(t.getTime())?e:`${String(t.getUTCDate()).padStart(2,`0`)}/${String(t.getUTCMonth()+1).padStart(2,`0`)} ${String(t.getUTCHours()).padStart(2,`0`)}h`}export{ie as KpiTab};
@@ -0,0 +1 @@
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$W as r,AG as i,Bc as a,CG as o,CX as s,Cc as c,DG as l,DX as ee,EG as u,Ec as d,FG as f,HX as p,MG as m,MX as te,NG as h,OG as ne,PG as re,Pc as ie,QW as ae,SG as oe,SX as se,Sc as ce,TG as le,Tc as ue,VX as g,XW as de,ZW as fe,_G as pe,_X as me,aG as _,aX as he,bG as ge,bX as v,bc as y,cG as b,cX as x,dG as S,dX as C,eG as w,fG as T,fX as E,gG as D,gX as O,hG as k,hX as A,iG as j,iX as M,jG as N,kG as P,lG as F,lX as I,mG as L,mX as _e,nG as ve,nX as ye,oG as be,oX as xe,pG as Se,pX as Ce,r as R,rG as z,rI as we,rX as Te,sG as Ee,sX as De,t as B,tG as Oe,tX as ke,uG as Ae,uX as je,vG as Me,vX as Ne,wG as Pe,wX as Fe,wc as Ie,xG as Le,xX as Re,xc as ze,yG as Be,yX as Ve,yc as He,zc as Ue}from"./api-Ca1H8N44.js";import{t as V}from"./button-BbEZKLza.js";import{$t as H,H as We,Jt as U,Mt as W,Qt as Ge,St as Ke,Xt as qe,Yt as Je,Zt as Ye,bt as G,ft as K,t as Xe,vt as Ze,xt as Qe,yt as $e}from"./index-bizOs74t.js";import{t as et}from"./localePickerView-C2RmOS86.js";import{t as tt}from"./TimezoneCombobox-6UndnvMs.js";var q=t(e(),1),J=n();function nt({className:e,checked:t,onCheckedChange:n,disabled:r,...i}){return(0,J.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":t,"data-state":t?`checked`:`unchecked`,disabled:r,onClick:()=>n(!t),className:R(`peer inline-flex h-5 w-9 shrink-0 items-center rounded-full border border-transparent transition-colors outline-none`,`focus-visible:ring-2 focus-visible:ring-ring/50`,`disabled:cursor-not-allowed disabled:opacity-50`,t?`bg-primary`:`bg-input`,e),...i,children:(0,J.jsx)(`span`,{className:R(`pointer-events-none block size-4 rounded-full bg-background shadow transition-transform`,t?`translate-x-[18px]`:`translate-x-[2px]`)})})}var Y=[{id:`messages`,label:()=>f()},{id:`composer`,label:()=>re()},{id:`sidebar`,label:()=>h()},{id:`notifications`,label:()=>D()},{id:`other`,label:()=>m()}],X={showSource:{category:`messages`,label:()=>N(),help:()=>i()},showReport:{category:`messages`,label:()=>P(),help:()=>ne()},copyAssistant:{category:`messages`,label:()=>l()},copyUser:{category:`messages`,label:()=>u()},showDelete:{category:`messages`,label:()=>le()},showTools:{category:`messages`,label:()=>Pe(),help:()=>o()},voiceInput:{category:`composer`,label:()=>oe(),help:()=>Le()},showUsage:{category:`composer`,label:()=>ge(),help:()=>Be()},autoReadAloud:{category:`composer`,label:()=>a(),help:()=>Ue()},showChatAge:{category:`sidebar`,label:()=>Me(),help:()=>pe()},notifSound:{category:`notifications`,label:()=>k(),help:()=>L()},notifSystem:{category:`notifications`,label:()=>Se(),help:()=>T()},replySound:{category:`notifications`,label:()=>S(),help:()=>Ae()}};function Z(e){return e.toLowerCase().normalize(`NFD`).replace(/\p{Diacritic}/gu,``)}function Q(e,t){let n=Z(t.trim()),r=new Map(Y.map(e=>[e.id,e.label()])),i=new Map(Y.map(e=>[e.id,[]]));for(let t of e){let e=X[t],a=e?.category??`other`;n&&!Z(`${e?e.label():t} ${e?.help?e.help():``} ${t} ${r.get(a)??``}`).includes(n)||i.get(a).push(t)}return Y.map(e=>({id:e.id,label:r.get(e.id),keys:i.get(e.id)})).filter(e=>e.keys.length>0)}var rt=[`showSource`,`showReport`,`copyAssistant`,`copyUser`,`showDelete`,`showTools`,`voiceInput`,`showChatAge`,`showUsage`,`autoReadAloud`,`notifSound`,`notifSystem`,`replySound`],it={voiceInput:`voiceInput`};function at(e){return rt.includes(e)}function $(e){return e===`admin`}function ot(e){return e===!0?`on`:e===!1?`off`:`inherit`}function st(e){return e===`on`?!0:e===`off`?!1:null}function ct(e){return at(e)?it[e]:void 0}var lt={voiceInput:()=>w()};function ut({prefKey:e,ui:t}){let n=g(B.admin.setUiPrefDefault),r=g(B.admin.setFeatureEnabled),i=ct(e),a=i?lt[e]?.():void 0;return(0,J.jsxs)(`div`,{className:`oc-prefs__gov`,children:[(0,J.jsxs)(`div`,{className:`oc-prefs__gov-row`,children:[(0,J.jsx)(`span`,{className:`oc-prefs__gov-label`,children:j()}),(0,J.jsxs)(Ze,{value:ot(t.defaults[e]),onValueChange:t=>void n({key:e,value:st(t)}),children:[(0,J.jsx)(Qe,{size:`sm`,className:`w-36`,children:(0,J.jsx)(Ke,{})}),(0,J.jsxs)($e,{children:[(0,J.jsx)(G,{value:`on`,children:ae()}),(0,J.jsx)(G,{value:`off`,children:fe()}),(0,J.jsx)(G,{value:`inherit`,children:de()})]})]}),i?(0,J.jsxs)(`span`,{className:`oc-prefs__gov-gate`,children:[(0,J.jsx)(W,{checked:t.featuresEnabled[i]===!0,onCheckedChange:e=>void r({key:i,enabled:e===!0}),"aria-label":z()}),z()]}):null]}),a?(0,J.jsx)(`span`,{className:`oc-prefs__gov-help`,children:a}):null]})}function dt({current:e,enabled:t}){let n=g(B.me.setDictationShortcut),[r,i]=(0,q.useState)(!1),[a,o]=(0,q.useState)(!1);return(0,q.useEffect)(()=>{if(!r)return;let e=e=>{if(e.preventDefault(),e.stopPropagation(),e.key===`Escape`){i(!1);return}let t=Ye(e);if(t===null){[`Shift`,`Control`,`Meta`,`Alt`].includes(e.key)||(o(!0),window.setTimeout(()=>o(!1),1800));return}i(!1),n({shortcut:t})};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[r,n]),(0,J.jsxs)(`div`,{className:`oc-prefs__row${t?``:` is-locked`}`,children:[(0,J.jsxs)(`div`,{className:`oc-prefs__info`,children:[(0,J.jsxs)(`span`,{className:`oc-prefs__label`,children:[d(),e?(0,J.jsx)(U,{variant:`secondary`,children:Ge(e,qe())}):null]}),(0,J.jsx)(`span`,{className:`oc-prefs__help`,children:a?c():r?Ie():ue()})]}),(0,J.jsxs)(`div`,{className:`oc-prefs__ctl`,children:[e&&!r?(0,J.jsx)(`button`,{type:`button`,className:`oc-prefs__reset`,onClick:()=>void n({shortcut:null}),children:He()}):null,(0,J.jsx)(`button`,{type:`button`,className:`oc-prefs__reset`,disabled:!t,"aria-pressed":r,onClick:()=>i(e=>!e),children:r?y():e?ze():ce()})]})]})}function ft(){let[e,t]=(0,q.useState)(``),[n,i]=(0,q.useState)(!1),a=p(B.me.getMe,{host:K}),o=a?.ui,s=$(a?.role)&&n,c=g(B.me.setUiPref).withOptimisticUpdate(We),l=(0,q.useMemo)(()=>o?Q(Object.keys(o.effective),e):[],[o,e]);return o?(0,J.jsxs)(`div`,{className:`oc-prefs-panel`,children:[$(a?.role)?(0,J.jsxs)(`label`,{className:`oc-prefs__gov-toggle`,children:[(0,J.jsx)(W,{checked:n,onCheckedChange:e=>i(e===!0),"aria-label":_()}),_()]}):null,s?(0,J.jsxs)(`div`,{className:`oc-prefs__gov-head`,children:[(0,J.jsx)(`p`,{children:ve()}),(0,J.jsx)(`p`,{children:Oe()}),(0,J.jsx)(`p`,{children:r()})]}):null,(0,J.jsx)(H,{value:e,onChange:e=>t(e.target.value),placeholder:F(),"aria-label":F(),className:`mb-2`}),l.length===0?(0,J.jsx)(`div`,{className:`oc-prefs__empty`,children:b()}):(0,J.jsx)(`div`,{className:`oc-prefs`,children:l.map(e=>(0,J.jsxs)(`section`,{className:`oc-prefs__card`,children:[(0,J.jsx)(`h4`,{className:`oc-prefs__cat`,children:e.label}),e.keys.map(e=>{let t=X[e],n=t?t.label():e,r=t?.help?.(),i=o.locked[e],a=o.effective[e],l=o.userOverrides[e]!==void 0;return(0,J.jsxs)(`div`,{className:`oc-prefs__row${i?` is-locked`:``}`,children:[(0,J.jsxs)(`div`,{className:`oc-prefs__info`,children:[(0,J.jsxs)(`span`,{className:`oc-prefs__label`,children:[n,i?(0,J.jsx)(U,{variant:`outline`,children:Ee()}):l?(0,J.jsx)(U,{variant:`secondary`,children:ie()}):null]}),r?(0,J.jsx)(`span`,{className:`oc-prefs__help`,children:r}):null]}),(0,J.jsxs)(`div`,{className:`oc-prefs__ctl`,children:[!i&&l?(0,J.jsx)(`button`,{type:`button`,className:`oc-prefs__reset`,onClick:()=>void c({key:e,value:null}),children:be()}):null,(0,J.jsx)(nt,{checked:a,disabled:i,onCheckedChange:t=>{e===`notifSystem`&&t&&typeof Notification<`u`&&Notification.permission==="default"&&Notification.requestPermission(),c({key:e,value:t})},"aria-label":n})]}),s?(0,J.jsx)(ut,{prefKey:e,ui:o}):null]},e)})]},e.id))}),(0,J.jsx)(dt,{current:a?.dictationShortcut??null,enabled:o.effective.voiceInput===!0})]}):(0,J.jsx)(`div`,{className:`oc-prefs__empty`,children:te()})}var pt={sm:()=>E(),md:()=>C(),lg:()=>je(),xl:()=>I(),"2xl":()=>x(),"3xl":()=>De()};function mt(){let e=p(B.me.getMe,{host:K}),t=g(B.me.setLocale),n=g(B.me.setTimezone),r=g(B.me.setFontScale).withOptimisticUpdate((e,{scale:t})=>{let n=e.getQuery(B.me.getMe,{host:K});n&&e.setQuery(B.me.getMe,{host:K},{...n,fontScale:t,resolvedFontScale:t??`md`})}),i=g(B.me.setMyName),a=Je(),o=e?.locale??`default`,c=e?.name??``,[l,u]=(0,q.useState)(null),d=l??c,f=d.trim()!==c.trim();async function m(){try{await i({name:d}),u(null),a.success(v())}catch(e){a.error(Ve(),e)}}return(0,J.jsxs)(`div`,{className:`oc-appearance`,children:[(0,J.jsxs)(`section`,{className:`oc-show__section`,children:[(0,J.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,J.jsx)(`h2`,{className:`oc-show__title`,children:Fe()}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:s()})]}),(0,J.jsxs)(`div`,{className:`oc-show__row`,children:[(0,J.jsx)(H,{className:`max-w-xs`,value:d,maxLength:120,placeholder:se(),onChange:e=>u(e.target.value),onKeyDown:e=>{e.key===`Enter`&&f&&(e.preventDefault(),m())}}),(0,J.jsx)(V,{size:`sm`,disabled:!f,onClick:()=>void m(),children:we()})]}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:Re()})]}),(0,J.jsxs)(`section`,{className:`oc-show__section`,children:[(0,J.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,J.jsx)(`h2`,{className:`oc-show__title`,children:Ne()}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:me()})]}),(0,J.jsxs)(`div`,{className:`oc-show__row`,children:[et().map(e=>(0,J.jsx)(V,{variant:o===e.value?`default`:`outline`,size:`sm`,onClick:()=>void t({locale:e.value}),children:e.label},e.value)),(0,J.jsx)(V,{variant:o==="default"?`default`:`outline`,size:`sm`,onClick:()=>void t({locale:null}),children:ee()})]}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:O()})]}),(0,J.jsxs)(`section`,{className:`oc-show__section`,children:[(0,J.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,J.jsx)(`h2`,{className:`oc-show__title`,children:xe()}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:he()})]}),(0,J.jsxs)(`div`,{className:`oc-show__row`,children:[(0,J.jsx)(tt,{value:e?.timezone??``,onChange:e=>void n({timezone:e})}),(0,J.jsx)(V,{variant:e?.timezone===null||e?.timezone===void 0?`default`:`outline`,size:`sm`,onClick:()=>void n({timezone:null}),children:M()})]}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:Te()})]}),(0,J.jsxs)(`section`,{className:`oc-show__section`,children:[(0,J.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,J.jsx)(`h2`,{className:`oc-show__title`,children:A()}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:_e()})]}),(0,J.jsx)(`div`,{className:`oc-show__row`,children:Xe.map(t=>(0,J.jsx)(V,{variant:(e?.fontScale??`md`)===t?`default`:`outline`,size:`sm`,onClick:()=>void r({scale:t}),children:pt[t]()},t))}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:Ce()})]}),(0,J.jsxs)(`section`,{className:`oc-show__section`,children:[(0,J.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,J.jsx)(`h2`,{className:`oc-show__title`,children:ye()}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:ke()})]}),(0,J.jsx)(ft,{})]})]})}export{mt as PreferencesTab};
@@ -0,0 +1 @@
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{AD as r,CD as i,DD as a,E as o,GD as s,GE as c,HD as l,HX as u,ID as d,JE as f,KD as p,KE as m,Ko as h,LD as g,MX as _,ND as ee,OD as te,QD as ne,QE as v,SD as y,TD as re,UD as ie,UE as b,VX as x,WE as S,XD as ae,XE as C,YE as w,ZD as oe,_D as se,aD as ce,bD as le,dD as T,eD as ue,fD as de,gD as fe,hD as pe,iD as me,jD as E,kD as he,lD as ge,lE as D,mD as _e,oD as ve,pD as ye,qE as O,qo as be,sD as k,t as A,uD as j,vD as M,wD as N,xD as xe,yD as Se,zC as Ce,zD as P}from"./api-Ca1H8N44.js";import{r as we}from"./dist-Bfmsr8JO.js";import{t as Te}from"./list-Bhy47ogH.js";import{t as F}from"./button-BbEZKLza.js";import{$n as Ee,$t as De,A as Oe,An as ke,Bn as Ae,C as I,D as je,E as Me,Gn as Ne,I as Pe,Kn as Fe,M as Ie,N as Le,O as Re,P as L,Qn as ze,S as Be,T as Ve,Un as R,Vn as He,Xn as z,Yt as Ue,Zn as We,_ as Ge,_t as Ke,an as qe,b as Je,ct as Ye,d as Xe,dr as B,en as Ze,er as Qe,f as $e,fr as et,g as tt,gt as V,h as nt,ht as H,in as rt,j as U,k as it,lt as at,mt as ot,nn as W,p as st,pr as G,pt as ct,rn as lt,sr as ut,tn as dt,tr as ft,v as K,w as q,x as J,y as pt,zn as mt}from"./index-bizOs74t.js";var ht=o(`columns-3`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}]]),gt=o(`folder-input`,[[`path`,{d:`M2 9V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-1`,key:`fm4g5t`}],[`path`,{d:`M2 13h10`,key:`pgb2dq`}],[`path`,{d:`m9 16 3-3-3-3`,key:`6m91ic`}]]),_t=o(`layout-grid`,[[`rect`,{width:`7`,height:`7`,x:`3`,y:`3`,rx:`1`,key:`1g98yp`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`3`,rx:`1`,key:`6d4xhi`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`14`,rx:`1`,key:`nxv5o0`}],[`rect`,{width:`7`,height:`7`,x:`3`,y:`14`,rx:`1`,key:`1bb6yr`}]]),Y=o(`panel-left`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}]]),X=t(e(),1),Z=n();function vt({className:e}){return(0,Z.jsx)(qe,{asChild:!0,children:(0,Z.jsx)(F,{variant:`ghost`,size:`icon-xs`,"aria-label":C(),className:e,onClick:e=>e.stopPropagation(),onMouseDown:e=>e.stopPropagation(),onTouchStart:e=>e.stopPropagation(),onPointerDown:e=>e.stopPropagation(),children:(0,Z.jsx)(ft,{})})})}function Q({folderId:e,name:t,color:n,currentParentId:r,className:i,onOpen:a}){let o=x(A.projects.renameProject),s=x(A.projects.setProjectColor),f=x(A.projects.moveProject),p=x(A.projects.deleteProject),h=x(A.projects.createProject),_=Ye(),te=nt(),y=at(),[re,ie]=(0,X.useState)(!1),[b,S]=(0,X.useState)(t),[C,se]=(0,X.useState)(!1),[ce,le]=(0,X.useState)(!1),T=u(A.projects.projectTreeCount,ce?{projectId:e}:`skip`);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(Ze,{onOpenChange:e=>e&&le(!0),children:[(0,Z.jsx)(vt,{className:i}),(0,Z.jsxs)(dt,{align:`end`,className:`w-48`,onClick:e=>e.stopPropagation(),children:[(0,Z.jsxs)(W,{onSelect:()=>a(),children:[(0,Z.jsx)(ze,{}),` `,ee()]}),(0,Z.jsxs)(W,{onSelect:()=>{S(t),ie(!0)},children:[(0,Z.jsx)(He,{}),` `,w()]}),(0,Z.jsxs)(W,{onSelect:()=>{requestAnimationFrame(async()=>{let t=await y({title:N(),label:ne(),placeholder:oe(),confirmLabel:ae()});t&&await h({name:t,parentId:e})})},children:[(0,Z.jsx)(We,{}),` `,N()]}),(0,Z.jsxs)(W,{onSelect:()=>se(!0),children:[(0,Z.jsx)(gt,{}),` `,ve()]}),(0,Z.jsx)(lt,{children:m()}),(0,Z.jsxs)(`div`,{className:`oc-colorgrid`,onClick:e=>e.stopPropagation(),children:[(0,Z.jsx)(`button`,{className:`oc-colorgrid__none`,onClick:()=>void s({projectId:e,color:null}),"aria-label":c(),children:`✕`}),Ge.map(t=>(0,Z.jsx)(`button`,{className:`oc-colorgrid__dot`+(n===t.value?` is-selected`:``),style:{background:t.hue},"aria-label":t.value,onClick:()=>void s({projectId:e,color:t.value})},t.value))]}),(0,Z.jsx)(rt,{}),(0,Z.jsxs)(W,{variant:`destructive`,onSelect:()=>{requestAnimationFrame(async()=>{let n=T?.folders??0,r=T?.chats??0;await _({title:d({name:t}),description:st({folders:n,chats:r,days:te}),confirmWord:v(),confirmLabel:g(),destructive:!0})&&await p({projectId:e})})},children:[(0,Z.jsx)(ke,{}),` `,v()]})]})]}),(0,Z.jsx)(Je,{open:re,onOpenChange:ie,title:l(),canSubmit:b.trim().length>0,onSubmit:async()=>{await o({projectId:e,name:b.trim()}),ie(!1)},submitLabel:w(),children:(0,Z.jsx)(De,{value:b,onChange:e=>S(e.target.value),autoFocus:!0})}),C?(0,Z.jsx)(tt,{open:C,onOpenChange:se,title:me(),movingFolderId:e,currentId:r,onPick:t=>void f({projectId:e,parentId:t})}):null]})}function yt({chat:e,currentFolderId:t,className:n}){let i=x(A.chats.pinChat),a=x(A.chats.deleteChat),o=x(A.chats.renameChat),s=x(A.chats.setChatSidebar),c=x(A.chats.moveChatToProject),l=Ye(),u=nt(),[d,p]=(0,X.useState)(!1),[m,h]=(0,X.useState)(e.title??``),[g,_]=(0,X.useState)(!1);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(Ze,{children:[(0,Z.jsx)(vt,{className:n}),(0,Z.jsxs)(dt,{align:`end`,className:`w-52`,onClick:e=>e.stopPropagation(),children:[(0,Z.jsxs)(W,{onSelect:()=>{h(e.title??``),p(!0)},children:[(0,Z.jsx)(He,{}),` `,w()]}),(0,Z.jsxs)(W,{onSelect:()=>void i({chatId:e._id,pinned:!e.pinned}),children:[e.pinned?(0,Z.jsx)(mt,{}):(0,Z.jsx)(Ae,{}),e.pinned?f():O()]}),(0,Z.jsxs)(W,{onSelect:()=>_(!0),children:[(0,Z.jsx)(gt,{}),` `,k()]}),e.pinned&&e.inSidebar?null:(0,Z.jsxs)(W,{onSelect:()=>void s({chatId:e._id,hidden:e.inSidebar}),children:[e.inSidebar?(0,Z.jsx)(R,{}):(0,Z.jsx)(Y,{}),e.inSidebar?r():E()]}),(0,Z.jsx)(rt,{}),(0,Z.jsxs)(W,{variant:`destructive`,onSelect:()=>{requestAnimationFrame(async()=>{await l({title:S(),description:b({days:u}),confirmLabel:v(),destructive:!0})&&await a({chatId:e._id})})},children:[(0,Z.jsx)(ke,{}),` `,v()]})]})]}),(0,Z.jsx)(Je,{open:d,onOpenChange:p,title:D(),canSubmit:m.trim().length>0,onSubmit:async()=>{await o({chatId:e._id,title:m.trim()}),p(!1)},submitLabel:w(),children:(0,Z.jsx)(De,{value:m,onChange:e=>h(e.target.value),autoFocus:!0})}),g?(0,Z.jsx)(tt,{open:g,onOpenChange:_,title:ce(),currentId:t,onPick:t=>void c({chatId:e._id,projectId:t})}):null]})}function bt(e,t){let n=t.trim().toLowerCase();return n===``?e:e.filter(e=>(e.title??``).toLowerCase().includes(n))}function xt(e,t,n,r,i){let a=e.map(t),o=a.indexOf(i);if(o<0)return null;let s=a.indexOf(r);if(s>=0){let t=[...e],[r]=t.splice(s,1);t.splice(o,0,r);let i=t[o-1],a=t[o+1];return{prevKey:i===void 0?null:n(i),nextKey:a===void 0?null:n(a)}}let c=e[o-1];return{prevKey:c===void 0?null:n(c),nextKey:n(e[o])}}function St(e,t){let n=new Map(t.map(e=>[e.chatId,e.lastSeenAt])),r=new Set;for(let t of e){let e=n.get(t._id);e!==void 0&&t.lastAssistantAt!==null&&t.lastAssistantAt>e&&r.add(t._id)}return r}var Ct=`oc.projpage.view`;function wt(){let e=localStorage.getItem(Ct);return e===`cards`||e===`list`?e:`columns`}var $=e=>`into:${e}`,Tt=e=>`col:${e??`null`}`,Et=e=>`crumb:${e}`;function Dt(e){if(e.startsWith(`into:`))return e.slice(5);if(e.startsWith(`crumb:`))return e.slice(6);if(e.startsWith(`col:`)){let t=e.slice(4);return t===`null`?null:t}}function Ot(){let{projectId:e}=G({from:`/project/$projectId`}),t=B(),n=u(A.projects.projectPage,{projectId:e});return(0,Z.jsx)(`div`,{className:`oc-projpage`,children:n===void 0?(0,Z.jsx)(`p`,{className:`oc-projpage__hint`,children:_()}):n===null?(0,Z.jsxs)(`div`,{className:`oc-projpage__notfound`,children:[(0,Z.jsx)(`h2`,{children:de()}),(0,Z.jsx)(`p`,{className:`oc-projpage__hint`,children:T()}),(0,Z.jsx)(F,{variant:`outline`,onClick:()=>void t({to:`/`}),children:j()})]}):(0,Z.jsx)(kt,{page:n})})}function kt({page:e}){let t=B(),n=Ye(),r=nt(),i=at(),o=Ue(),s=x(A.projects.renameProject),f=x(A.projects.setProjectColor),_=x(A.projects.deleteProject),ee=x(A.projects.createProject),y=x(A.projects.moveProject),b=x(A.projects.setProjectSidebar),S=x(A.chats.moveChatToProject),C=x(A.chats.reorderChat),se=x(A.projects.reorderProject),ce=u(A.projects.projectTreeCount,{projectId:e.project._id}),[T,de]=(0,X.useState)(wt),E=e=>{localStorage.setItem(Ct,e),de(e)},D=u(A.projects.folderColumns,T===`columns`?{projectId:e.project._id}:`skip`),O=u(A.projects.projectTreeList,T===`list`?{projectId:e.project._id}:`skip`),{c:k}=et({from:`/project/$projectId`}),j=u(A.projects.listProjects,{}),M=u(A.chatReads.myBusyChats,{}),P=(0,X.useMemo)(()=>new Set(M??[]),[M]),{byChat:we}=Ke(M??null),Ae=u(A.chatReads.myChatReads,{}),I=(0,X.useMemo)(()=>St(e.chats,Ae??[]),[e.chats,Ae]),{startNewChat:L,picker:ze}=Xe(e=>void t({to:`/chat/$chatId`,params:{chatId:e}})),[R,$e]=(0,X.useState)(``),[V,U]=(0,X.useState)(!1),[G,ut]=(0,X.useState)(e.project.name),[K,mt]=(0,X.useState)(!1),[Y,vt]=(0,X.useState)(``);(0,X.useEffect)(()=>{let e=setTimeout(()=>vt(R.trim()),180);return()=>clearTimeout(e)},[R]);let Q=u(A.search.searchConversations,Y.length>=2?{query:Y,projectId:e.project._id}:`skip`),yt=Le(Ie(je,{activationConstraint:{distance:4}}),Ie(Re,{activationConstraint:{delay:250,tolerance:8}})),$=(0,X.useRef)(!1),Tt=()=>{$.current=!0,setTimeout(()=>{$.current=!1},0)},[Et,Ot]=(0,X.useState)(null),kt=t=>{if(t.startsWith(`chat:`)){let n=t.slice(5),r=e.chats.find(e=>e._id===n),i=D?.columns.flatMap(e=>e.chats).find(e=>e._id===n);return{kind:`chat`,label:(r??i)?.title||p()}}if(t.startsWith(`folder:`)){let e=t.slice(7);return{kind:`folder`,label:(j??[]).find(t=>t._id===e)?.name??``}}return null},Mt=e=>Ot(kt(String(e.active.id))),Pt=(0,X.useCallback)(e=>{let t=String(e.active.id).startsWith(`folder:`),n=t=>({...e,droppableContainers:e.droppableContainers.filter(e=>String(e.id).startsWith(t))}),r=Oe(n(`into:`));if(r.length>0){if(!t)return r;let n=r[0],i=e.droppableRects.get(n.id),a=e.pointerCoordinates?.y;if(i&&a!=null){let e=i.height*.3;if(a>i.top+e&&a<i.top+i.height-e)return r}}let i=Oe(n(t?`folder:`:`chat:`));if(i.length>0)return i;let a=Oe(n(`crumb:`));if(a.length>0)return a;let o=Oe(n(`col:`));return o.length>0?o:it(n(t?`folder:`:`chat:`))},[]),It=t=>{if(T===`columns`){for(let e of D?.columns??[])if(e.chats.some(e=>e._id===t))return{list:e.chats,folderId:e.folderId};return null}if(T===`list`){let e=O?.chats.find(e=>e._id===t);return e?{list:O.chats.filter(t=>t.folderId===e.folderId),folderId:e.folderId}:null}return e.chats.some(e=>e._id===t)?{list:e.chats,folderId:e.project._id}:null},Lt=t=>{if(T===`columns`){for(let e of D?.columns??[])if(e.folders.some(e=>e._id===t))return{list:e.folders,parentId:e.folderId};return null}if(T===`list`){let e=O?.folders.find(e=>e._id===t);if(!e||!O)return null;let n=e.parentId??O.rootId;return{list:ot(O.folders,e.parentId),parentId:n}}return e.children.some(e=>e._id===t)?{list:e.children,parentId:e.project._id}:null},zt=async e=>{Ot(null),Tt();let{active:t,over:n}=e;if(!n)return;let r=String(n.id),i=String(t.id),a=i.startsWith(`chat:`);try{let e=Dt(r);if(e!==void 0){if(a)await S({chatId:i.slice(5),projectId:e});else{let t=i.slice(7);if(t===e)return;if(!ct(j??[],t,e)){o.error(re());return}await y({projectId:t,parentId:e})}return}if(a&&r.startsWith(`chat:`)){let e=i.slice(5),t=r.slice(5);if(e===t)return;let n=It(t);if(!n)return;n.list.some(t=>t._id===e)||await S({chatId:e,projectId:n.folderId});let a=xt(n.list,e=>e._id,e=>e.sortKey,e,t);a&&await C({chatId:e,...a});return}if(!a&&r.startsWith(`folder:`)){let e=i.slice(7),t=r.slice(7);if(e===t)return;let n=Lt(t);if(!n)return;if(!n.list.some(t=>t._id===e)){if(!ct(j??[],e,n.parentId)){o.error(re());return}await y({projectId:e,parentId:n.parentId})}let a=xt(n.list,e=>e._id,e=>e.sortKey,e,t);a&&await se({projectId:e,...a});return}}catch{o.error(re())}},[,Bt]=(0,X.useState)(0);(0,X.useEffect)(()=>{let e=window.setInterval(()=>Bt(e=>e+1),6e4);return()=>window.clearInterval(e)},[]);let Vt=Date.now(),Ht=pt(e.project),Ut=bt(e.chats,R),Wt=e.breadcrumb.slice(0,-1),Gt=e=>()=>{$.current||e()};return(0,Z.jsx)(H.Provider,{value:we,children:(0,Z.jsxs)(Ve,{sensors:yt,collisionDetection:Pt,onDragStart:Mt,onDragEnd:zt,children:[(0,Z.jsxs)(`div`,{className:`oc-projpage__body`,style:{"--proj-hue":Ht},children:[(0,Z.jsxs)(`nav`,{className:`oc-projpage__crumbs`,"aria-label":ge(),children:[Wt.map(e=>(0,Z.jsxs)(`span`,{className:`oc-projpage__crumb`,children:[(0,Z.jsx)(At,{folderId:e._id,children:(0,Z.jsx)(`button`,{type:`button`,className:`oc-projpage__crumblink`,onClick:Gt(()=>void t({to:`/project/$projectId`,params:{projectId:e._id}})),children:e.name})}),(0,Z.jsx)(`span`,{className:`oc-projpage__crumbsep`,"aria-hidden":!0,children:`›`})]},e._id)),(0,Z.jsx)(`span`,{className:`oc-projpage__crumbcur`,children:e.project.name})]}),(0,Z.jsxs)(`header`,{className:`oc-projpage__head`,children:[(0,Z.jsx)(`span`,{className:`oc-projpage__dot`,"aria-hidden":!0}),(0,Z.jsx)(`h1`,{className:`oc-projpage__title`,children:e.project.name}),e.project.sidebarHidden?(0,Z.jsxs)(F,{variant:`ghost`,size:`sm`,className:`oc-projpage__hiddenbadge`,title:be(),onClick:()=>{b({projectId:e.project._id,hidden:!1})},children:[(0,Z.jsx)(Qe,{"aria-hidden":!0}),(0,Z.jsx)(`span`,{children:h()}),(0,Z.jsx)(Ee,{"aria-hidden":!0})]}):null,(0,Z.jsxs)(`div`,{className:`oc-projpage__actions`,children:[(0,Z.jsxs)(`div`,{className:`oc-projpage__viewtoggle`,role:`group`,"aria-label":he(),children:[(0,Z.jsx)(F,{variant:T===`cards`?`secondary`:`ghost`,size:`icon-sm`,"aria-label":he(),title:he(),"aria-pressed":T===`cards`,onClick:()=>E(`cards`),children:(0,Z.jsx)(_t,{})}),(0,Z.jsx)(F,{variant:T===`columns`?`secondary`:`ghost`,size:`icon-sm`,"aria-label":te(),title:te(),"aria-pressed":T===`columns`,onClick:()=>E(`columns`),children:(0,Z.jsx)(ht,{})}),(0,Z.jsx)(F,{variant:T===`list`?`secondary`:`ghost`,size:`icon-sm`,"aria-label":a(),title:a(),"aria-pressed":T===`list`,onClick:()=>E(`list`),children:(0,Z.jsx)(Te,{})})]}),(0,Z.jsxs)(F,{variant:`outline`,size:`sm`,onClick:()=>void L({projectId:e.project._id}),children:[(0,Z.jsx)(Fe,{}),Se()]}),(0,Z.jsxs)(F,{variant:`outline`,size:`sm`,onClick:async()=>{let t=await i({title:N(),label:ne(),placeholder:oe(),confirmLabel:ae()});t&&await ee({name:t,parentId:e.project._id})},children:[(0,Z.jsx)(We,{}),N()]}),(0,Z.jsxs)(Ze,{children:[(0,Z.jsx)(qe,{asChild:!0,children:(0,Z.jsx)(F,{variant:`ghost`,size:`icon-sm`,"aria-label":ie(),children:(0,Z.jsx)(ft,{})})}),(0,Z.jsxs)(dt,{align:`end`,className:`w-48`,children:[(0,Z.jsxs)(W,{onSelect:()=>{ut(e.project.name),U(!0)},children:[(0,Z.jsx)(He,{}),` `,w()]}),(0,Z.jsxs)(W,{onSelect:()=>mt(!0),children:[(0,Z.jsx)(gt,{}),` `,ve()]}),(0,Z.jsx)(lt,{children:m()}),(0,Z.jsxs)(`div`,{className:`oc-colorgrid`,children:[(0,Z.jsx)(`button`,{className:`oc-colorgrid__none`,onClick:()=>void f({projectId:e.project._id,color:null}),"aria-label":c(),children:`✕`}),Ge.map(t=>(0,Z.jsx)(`button`,{className:`oc-colorgrid__dot`+(e.project.color===t.value?` is-selected`:``),style:{background:t.hue},"aria-label":t.value,onClick:()=>void f({projectId:e.project._id,color:t.value})},t.value))]}),(0,Z.jsx)(rt,{}),(0,Z.jsxs)(W,{variant:`destructive`,onSelect:()=>{let i=e.project.parentId;requestAnimationFrame(async()=>{let a=ce?.folders??0,o=ce?.chats??0;await n({title:d({name:e.project.name}),description:st({folders:a,chats:o,days:r}),confirmWord:v(),confirmLabel:g(),destructive:!0})&&(await _({projectId:e.project._id}),t(i===null?{to:`/`}:{to:`/project/$projectId`,params:{projectId:i}}))})},children:[(0,Z.jsx)(ke,{}),` `,v()]})]})]})]})]}),T===`columns`?(0,Z.jsx)(Rt,{data:D,currentId:e.project._id,busyIds:P,suppressClick:$,locateChatId:k??null}):T===`list`?(0,Z.jsx)(Ft,{data:O,busyIds:P,suppressClick:$,locateChatId:k??null}):(0,Z.jsxs)(Z.Fragment,{children:[e.children.length>0?(0,Z.jsxs)(`section`,{className:`oc-projpage__section`,children:[(0,Z.jsx)(`h2`,{className:`oc-projpage__subtitle`,children:xe()}),(0,Z.jsx)(`div`,{className:`oc-projpage__cards`,children:(0,Z.jsx)(J,{items:e.children.map(e=>`folder:${e._id}`),strategy:Be,children:e.children.map(t=>(0,Z.jsx)(jt,{child:t,parentId:e.project._id,now:Vt,suppressClick:$},t._id))})})]}):null,(0,Z.jsxs)(`section`,{className:`oc-projpage__section`,children:[(0,Z.jsxs)(`div`,{className:`oc-projpage__convhead`,children:[(0,Z.jsx)(`h2`,{className:`oc-projpage__subtitle`,children:le()}),e.chats.length>0?(0,Z.jsx)(De,{value:R,onChange:e=>$e(e.target.value),placeholder:fe(),className:`oc-projpage__filter`}):null]}),e.chats.length===0?(0,Z.jsx)(`p`,{className:`oc-projpage__hint`,children:e.children.length===0?_e():ye()}):Ut.length===0&&(Q??[]).length===0?(0,Z.jsx)(`p`,{className:`oc-projpage__hint`,children:pe({term:R.trim()})}):(0,Z.jsx)(`ul`,{className:`oc-projpage__chats`,children:(0,Z.jsx)(J,{items:Ut.map(e=>`chat:${e._id}`),strategy:q,children:Ut.map(t=>(0,Z.jsx)(Nt,{chat:t,currentFolderId:e.project._id,now:Vt,busy:P.has(t._id),unread:I.has(t._id),locate:t._id===k,suppressClick:$},t._id))})})]}),Y.length>=2&&Q!==void 0?(0,Z.jsxs)(`section`,{className:`oc-projpage__section`,children:[(0,Z.jsx)(`h2`,{className:`oc-projpage__subtitle`,children:ue()}),Q.length===0?(0,Z.jsx)(`p`,{className:`oc-projpage__hint`,children:pe({term:Y})}):(0,Z.jsx)(`ul`,{className:`oc-projpage__chats`,children:Q.map(e=>(0,Z.jsx)(`li`,{className:`oc-projpage__chatrow`,children:(0,Z.jsxs)(`button`,{type:`button`,className:`oc-projpage__chatbtn`,onClick:()=>{e.messageId&&Y&&Pe(e.messageId,Y),t({to:`/chat/$chatId`,params:{chatId:e.chatId},...e.messageId?{search:{m:e.messageId}}:{}})},children:[(0,Z.jsx)(Ne,{size:13,"aria-hidden":!0,className:`oc-projpage__hitico`}),(0,Z.jsxs)(`span`,{className:`oc-projpage__hitbody`,children:[(0,Z.jsx)(`span`,{className:`oc-projpage__chattitle`,children:e.title||Ce()}),e.projectPath&&e.projectPath.length>1?(0,Z.jsx)(`span`,{className:`oc-projpage__hitpath`,children:e.projectPath.join(` › `)}):null,e.snippet?(0,Z.jsx)(`span`,{className:`oc-projpage__hitsnippet`,children:e.snippet}):null]})]})},`${e.chatId}:${e.messageId??`t`}`))})]}):null]}),(0,Z.jsx)(Je,{open:V,onOpenChange:U,title:l(),canSubmit:G.trim().length>0,onSubmit:async()=>{await s({projectId:e.project._id,name:G.trim()}),U(!1)},submitLabel:w(),children:(0,Z.jsx)(De,{value:G,onChange:e=>ut(e.target.value),autoFocus:!0})}),K?(0,Z.jsx)(tt,{open:K,onOpenChange:mt,title:me(),movingFolderId:e.project._id,currentId:e.project.parentId,onPick:t=>void y({projectId:e.project._id,parentId:t})}):null,ze]}),(0,Z.jsx)(Me,{children:Et?(0,Z.jsxs)(`div`,{className:`oc-projpage__dragghost`,children:[Et.kind===`folder`?(0,Z.jsx)(z,{size:13,"aria-hidden":!0}):(0,Z.jsx)(Ne,{size:13,"aria-hidden":!0}),(0,Z.jsx)(`span`,{children:Et.label})]}):null})]})})}function At({folderId:e,children:t}){let{setNodeRef:n,isOver:r}=U({id:Et(e)});return(0,Z.jsx)(`span`,{ref:n,className:r?`oc-projpage__cdrop is-over`:`oc-projpage__cdrop`,children:t})}function jt({child:e,parentId:t,now:n,suppressClick:r}){let i=B(),a=I({id:`folder:${e._id}`}),o=U({id:$(e._id)});return(0,Z.jsxs)(`div`,{ref:e=>{a.setNodeRef(e),o.setNodeRef(e)},className:`oc-projpage__card`+(o.isOver?` is-over`:``)+(a.isDragging?` is-dragging`:``),style:{"--proj-hue":pt(e),transform:L.Transform.toString(a.transform),transition:a.transition},onClick:()=>{r.current||i({to:`/project/$projectId`,params:{projectId:e._id}})},onKeyDown:t=>{t.key===`Enter`&&i({to:`/project/$projectId`,params:{projectId:e._id}})},...a.listeners,...a.attributes,role:`link`,tabIndex:0,children:[(0,Z.jsxs)(`span`,{className:`oc-projpage__cardhead`,children:[(0,Z.jsx)(z,{size:15,"aria-hidden":!0,className:`oc-projpage__cardico`}),(0,Z.jsx)(`span`,{className:`oc-projpage__cardname`,children:e.name}),(0,Z.jsx)(Q,{folderId:e._id,name:e.name,color:e.color,currentParentId:t,className:`oc-projpage__cardmenu`,onOpen:()=>void i({to:`/project/$projectId`,params:{projectId:e._id}})})]}),(0,Z.jsxs)(`span`,{className:`oc-projpage__cardmeta`,children:[e.folderCount>0?M({count:e.folderCount})+` · `:``,se({count:e.recursiveChatCount})]}),e.lastActivityAt===null?null:(0,Z.jsx)(`span`,{className:`oc-projpage__cardage`,children:$e(e.lastActivityAt,n)})]})}function Mt({chat:e}){let t=x(A.chats.setChatSidebar),n=e.inSidebar?r():E();return(0,Z.jsx)(F,{variant:`ghost`,size:`icon-xs`,"aria-label":n,title:n,className:`oc-projpage__barbtn`+(e.inSidebar?` is-on`:``),disabled:e.pinned&&e.inSidebar,onClick:n=>{n.stopPropagation(),t({chatId:e._id,hidden:e.inSidebar})},children:e.inSidebar?(0,Z.jsx)(R,{}):(0,Z.jsx)(Y,{})})}function Nt({chat:e,currentFolderId:t,now:n,busy:r,unread:i,locate:a,suppressClick:o}){let c=(0,X.useContext)(H).get(e._id),l=B(),u=K(e.color),d=I({id:`chat:${e._id}`}),f=Pt(a);return(0,Z.jsxs)(`li`,{ref:e=>{d.setNodeRef(e),f.current=e},className:`oc-projpage__chatrow`+(d.isDragging?` is-dragging`:``)+(a?` is-locate`:``),style:{transform:L.Transform.toString(d.transform),transition:d.transition},children:[(0,Z.jsxs)(`button`,{type:`button`,className:`oc-projpage__chatbtn`,onClick:()=>{o.current||l({to:`/chat/$chatId`,params:{chatId:e._id}})},...d.listeners,...d.attributes,children:[u?(0,Z.jsx)(`span`,{className:`oc-chatitem__dot`,style:{background:u}}):(0,Z.jsx)(`span`,{className:`oc-chatitem__dot oc-chatitem__dot--empty`}),(0,Z.jsx)(`span`,{className:`oc-projpage__chattitle`,children:e.title||p()}),e.pinned?(0,Z.jsx)(Ae,{size:12,"aria-hidden":!0,className:`oc-projpage__chatpin`}):null,(0,Z.jsx)(`span`,{className:`oc-projpage__chatage`,children:$e(e.updatedAt,n)}),r?(0,Z.jsx)(`span`,{className:V(c,s()).className,title:V(c,s()).label,"aria-label":V(c,s()).label}):null,i&&!r?(0,Z.jsx)(`span`,{className:`oc-chatitem__unread`,title:P(),"aria-label":P()}):null]}),(0,Z.jsx)(Mt,{chat:e}),(0,Z.jsx)(yt,{chat:e,currentFolderId:t,className:`oc-projpage__chatmenu`})]})}function Pt(e){let t=(0,X.useRef)(null);return(0,X.useEffect)(()=>{e&&t.current&&t.current.scrollIntoView({block:`center`})},[e]),t}function Ft({data:e,busyIds:t,suppressClick:n,locateChatId:r}){let[i,a]=(0,X.useState)(new Set),o=(0,X.useMemo)(()=>{let t=new Map;for(let n of e?.chats??[]){let e=t.get(n.folderId);e===void 0?t.set(n.folderId,[n]):e.push(n)}return t},[e]);if(e===void 0)return(0,Z.jsx)(`p`,{className:`oc-projpage__hint`,children:_()});if(e===null)return null;let s=e=>a(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),c=(a,l)=>{let u=o.get(a??e.rootId)??[],d=ot(e.folders,a);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(J,{items:u.map(e=>`chat:${e._id}`),strategy:q,children:u.map(e=>(0,Z.jsx)(Lt,{chat:e,depth:l,busy:t.has(e._id),locate:e._id===r,suppressClick:n},e._id))}),(0,Z.jsx)(J,{items:d.map(e=>`folder:${e._id}`),strategy:q,children:d.map(t=>(0,Z.jsx)(It,{folder:t,parentId:a??e.rootId,depth:l,folded:i.has(t._id),onToggle:()=>s(t._id),suppressClick:n,children:i.has(t._id)?null:c(t._id,l+1)},t._id))})]})};return(0,Z.jsx)(`div`,{className:`oc-projpage__tree`,children:(o.get(e.rootId)??[]).length===0&&ot(e.folders,null).length===0?(0,Z.jsx)(`p`,{className:`oc-projpage__hint`,children:_e()}):c(null,0)})}function It({folder:e,parentId:t,depth:n,folded:r,onToggle:a,suppressClick:o,children:s}){let c=B(),l=I({id:`folder:${e._id}`}),u=U({id:$(e._id)});return(0,Z.jsxs)(`div`,{className:`oc-projpage__treegroup`,children:[(0,Z.jsxs)(`div`,{ref:e=>{l.setNodeRef(e),u.setNodeRef(e)},className:`oc-projpage__treerow oc-projpage__treerow--folder`+(u.isOver?` is-over`:``)+(l.isDragging?` is-dragging`:``),style:{"--tree-depth":n,"--proj-hue":pt(e),transform:L.Transform.toString(l.transform),transition:l.transition},...l.listeners,...l.attributes,role:`button`,tabIndex:0,onClick:()=>{o.current||c({to:`/project/$projectId`,params:{projectId:e._id}})},onKeyDown:t=>{t.key===`Enter`&&c({to:`/project/$projectId`,params:{projectId:e._id}})},children:[(0,Z.jsx)(`button`,{type:`button`,className:`oc-projpage__treechev`,"aria-label":r?i():y(),"aria-expanded":!r,onClick:e=>{e.stopPropagation(),!o.current&&a()},onMouseDown:e=>e.stopPropagation(),onTouchStart:e=>e.stopPropagation(),children:r?(0,Z.jsx)(ut,{size:13}):(0,Z.jsx)(we,{size:13})}),(0,Z.jsx)(z,{size:13,"aria-hidden":!0,className:`oc-projpage__colico`}),(0,Z.jsx)(`span`,{className:`oc-projpage__colname`,children:e.name}),(0,Z.jsx)(Q,{folderId:e._id,name:e.name,color:e.color,currentParentId:t,className:`oc-projpage__treemenu`,onOpen:()=>void c({to:`/project/$projectId`,params:{projectId:e._id}})})]}),s]})}function Lt({chat:e,depth:t,busy:n,locate:r,suppressClick:i}){let a=(0,X.useContext)(H).get(e._id),o=B(),s=I({id:`chat:${e._id}`}),c=Pt(r),l=K(e.color);return(0,Z.jsxs)(`div`,{ref:e=>{s.setNodeRef(e),c.current=e},className:`oc-projpage__treerow oc-projpage__treerow--chat`+(s.isDragging?` is-dragging`:``)+(r?` is-locate`:``),style:{"--tree-depth":t,transform:L.Transform.toString(s.transform),transition:s.transition},children:[(0,Z.jsxs)(`button`,{type:`button`,className:`oc-projpage__colchatbtn`,onClick:()=>{i.current||o({to:`/chat/$chatId`,params:{chatId:e._id}})},...s.listeners,...s.attributes,children:[l?(0,Z.jsx)(`span`,{className:`oc-chatitem__dot`,style:{background:l}}):(0,Z.jsx)(`span`,{className:`oc-chatitem__dot oc-chatitem__dot--empty`}),(0,Z.jsx)(`span`,{className:`oc-projpage__colname`,children:e.title||p()}),n?(0,Z.jsx)(`span`,{className:V(a,``).className,"aria-hidden":!0}):null]}),(0,Z.jsx)(yt,{chat:e,currentFolderId:e.folderId,className:`oc-projpage__treemenu`}),(0,Z.jsx)(Mt,{chat:e})]})}function Rt({data:e,currentId:t,busyIds:n,suppressClick:r,locateChatId:i}){let a=(0,X.useRef)(null);return(0,X.useEffect)(()=>{let e=a.current;e&&(e.scrollLeft=e.scrollWidth)},[e?.columns.length??0,t]),e===void 0?(0,Z.jsx)(`p`,{className:`oc-projpage__hint`,children:_()}):(0,Z.jsx)(`div`,{className:`oc-projpage__cols`,ref:a,children:e.columns.map((a,o)=>(0,Z.jsx)(zt,{col:a,isLast:o===e.columns.length-1,currentId:t,busyIds:n,suppressClick:r,locateChatId:i},a.folderId??`root`))})}function zt({col:e,isLast:t,currentId:n,busyIds:r,suppressClick:i,locateChatId:a}){let o=B(),s=U({id:Tt(e.folderId)});return(0,Z.jsxs)(`div`,{ref:s.setNodeRef,className:`oc-projpage__col`+(s.isOver?` is-over`:``)+(t?` is-last`:``),children:[(0,Z.jsx)(J,{items:e.folders.map(e=>`folder:${e._id}`),strategy:q,children:e.folders.map(t=>(0,Z.jsx)(Bt,{folder:t,parentId:e.folderId,isCurrent:t._id===n,suppressClick:i,onOpen:()=>void o({to:`/project/$projectId`,params:{projectId:t._id}})},t._id))}),(0,Z.jsx)(J,{items:e.chats.map(e=>`chat:${e._id}`),strategy:q,children:e.chats.map(t=>(0,Z.jsx)(Vt,{chat:t,folderId:e.folderId,busy:r.has(t._id),locate:t._id===a,suppressClick:i,onOpen:()=>void o({to:`/chat/$chatId`,params:{chatId:t._id}})},t._id))}),e.folders.length===0&&e.chats.length===0?(0,Z.jsx)(`p`,{className:`oc-projpage__colempty`,children:ye()}):null]})}function Bt({folder:e,parentId:t,isCurrent:n,suppressClick:r,onOpen:i}){let a=I({id:`folder:${e._id}`}),o=U({id:$(e._id)});return(0,Z.jsxs)(`div`,{ref:e=>{a.setNodeRef(e),o.setNodeRef(e)},className:`oc-projpage__colentry oc-projpage__colentry--folder`+(e.selected||n?` is-selected`:``)+(o.isOver?` is-over`:``)+(a.isDragging?` is-dragging`:``),style:{"--proj-hue":pt(e),transform:L.Transform.toString(a.transform),transition:a.transition},onClick:()=>{r.current||i()},onKeyDown:e=>{e.key===`Enter`&&e.target===e.currentTarget&&i()},...a.listeners,...a.attributes,role:`button`,tabIndex:0,children:[(0,Z.jsx)(z,{size:13,"aria-hidden":!0,className:`oc-projpage__colico`}),(0,Z.jsx)(`span`,{className:`oc-projpage__colname`,children:e.name}),(0,Z.jsx)(`span`,{className:`oc-projpage__colchev`,"aria-hidden":!0,children:`›`}),(0,Z.jsx)(Q,{folderId:e._id,name:e.name,color:e.color,currentParentId:t,className:`oc-projpage__colmenu`,onOpen:i})]})}function Vt({chat:e,folderId:t,busy:n,locate:r,suppressClick:i,onOpen:a}){let o=(0,X.useContext)(H).get(e._id),s=I({id:`chat:${e._id}`}),c=Pt(r),l=K(e.color);return(0,Z.jsxs)(`div`,{ref:e=>{s.setNodeRef(e),c.current=e},className:`oc-projpage__colentry oc-projpage__colentry--chat`+(s.isDragging?` is-dragging`:``)+(r?` is-locate`:``),style:{transform:L.Transform.toString(s.transform),transition:s.transition},children:[(0,Z.jsxs)(`button`,{type:`button`,className:`oc-projpage__colchatbtn`,onClick:()=>{i.current||a()},...s.listeners,...s.attributes,children:[l?(0,Z.jsx)(`span`,{className:`oc-chatitem__dot`,style:{background:l}}):(0,Z.jsx)(`span`,{className:`oc-chatitem__dot oc-chatitem__dot--empty`}),(0,Z.jsx)(`span`,{className:`oc-projpage__colname`,children:e.title||p()}),n?(0,Z.jsx)(`span`,{className:V(o,``).className,"aria-hidden":!0}):null]}),(0,Z.jsx)(yt,{chat:e,currentFolderId:t,className:`oc-projpage__colmenu oc-projpage__colmenu--chat`}),(0,Z.jsx)(Mt,{chat:e})]})}export{Ot as ProjectPage};
@@ -0,0 +1,4 @@
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$k as r,Cf as i,Du as a,Gk as o,HX as s,Jk as c,Kk as l,Ou as u,Qk as d,Sf as f,Uk as p,Uo as m,VX as h,Wk as g,Xk as _,Yk as v,Zk as y,aA as ee,cA as te,df as ne,eA as b,ff as x,fm as S,gA as C,gm as w,hA as T,hm as E,iA as D,ku as re,mf as ie,mm as ae,nA as oe,oA as se,pf as O,pm as k,qk as A,rA as j,sA as M,t as N,tA as P,uf as F,wf as I,xf as L}from"./api-Ca1H8N44.js";import{i as R,n as z,r as B,t as V}from"./FieldLabel-sEQ38rsG.js";import{t as H}from"./button-BbEZKLza.js";import{Mt as ce,St as U,Yt as W,bt as G,ft as le,gn as ue,hn as de,mn as fe,pn as K,vt as q,xt as J,yt as Y}from"./index-bizOs74t.js";import{r as X,t as Z}from"./locales-CPjguROj.js";import{t as pe}from"./localePickerView-C2RmOS86.js";/* empty css */var Q=t(e(),1),$=n(),me={media_delivery:{label:j,help:oe},documentary_fetch:{label:P,help:b},inbound_files:{label:r,help:d},history_summary:{label:w,help:E},file_curation:{label:I,help:ie},quote_reply:{label:i,help:f}},he={outboundDir:`/home/node/.openclaw/media/outbound`,references:`- gdrive/1a2b3c4d5e6f7890abcd
2
+ - gdrive/0f9e8d7c6b5a4321dcba`,files:`- /home/node/.openclaw/media/inbound/rapport.pdf (124800 o, application/pdf)`,previous_summary:`Projet Alpha : budget 40 000 EUR ; choix du serveur en cours.`,new_messages:`Utilisateur : Compare OVH et Scaleway.
3
+ Assistant : Comparaison en cours.`,max_chars:`6000`,file_name:`MEMORY.md`,budget_chars:`20000`,feedback:`Trop de suppressions dans la section des liens, garde-les.`,content:`# Memory index
4
+ - [Fait 1](fait-1.md) - note du projet`,excerpt:`Le classement propose trois dossiers : Clients, Fournisseurs, Interne.`},ge={outboundDir:o,references:g,files:p,previous_summary:ae,new_messages:k,max_chars:S,file_name:O,budget_chars:x,feedback:ne,content:F,excerpt:L};function _e(){let e=s(N.admin.listInstances,{}),[t,n]=(0,Q.useState)(null);if(e===void 0)return(0,$.jsx)(`div`,{className:`oc-settings__tab-loading`,"aria-busy":`true`});if(e.length===0)return(0,$.jsx)(`div`,{className:`oc-injtab`,children:(0,$.jsx)(`p`,{className:`oc-admin__hint`,children:_()})});let r=e.find(e=>e._id===t)??e[0];return(0,$.jsxs)(`div`,{className:`oc-injtab`,children:[(0,$.jsxs)(`div`,{className:`oc-injtab__head`,children:[(0,$.jsx)(z,{label:te(),help:M()}),(0,$.jsxs)(`label`,{className:`oc-injtab__picker`,children:[(0,$.jsx)(`span`,{children:y()}),(0,$.jsxs)(q,{value:r._id,onValueChange:e=>n(e),children:[(0,$.jsx)(J,{size:`sm`,className:`min-w-44`,children:(0,$.jsx)(U,{})}),(0,$.jsx)(Y,{children:e.map(e=>(0,$.jsx)(G,{value:e._id,children:e.displayName??e.name},e._id))})]})]})]}),(0,$.jsx)(ve,{instance:r},r._id)]})}function ve({instance:e}){let t=h(N.admin.upsertInstanceConfig),n=W(),r=s(N.me.getMe,{host:le}),i=e.config??{},o=X(e.config?.contentLocale,r?.defaultLocale??void 0),[c,l]=(0,Q.useState)(()=>R(i,o));(0,Q.useEffect)(()=>{l(R(i,o))},[o,e._id]);let[d,f]=(0,Q.useState)(!1),p=c.promptInjections,m=(e,t)=>l({...c,promptInjections:{...p,[e]:{...p[e],...t}}});async function g(){f(!0);try{await t({instanceId:e._id,config:B(c,i,o)})}catch(e){n.error(T(),e)}finally{f(!1)}}async function _(r){let i={...e.config??{}};r==="default"?delete i.contentLocale:i.contentLocale=r;try{await t({instanceId:e._id,config:i})}catch(e){n.error(T(),e)}}let v=e.config?.contentLocale??`default`,y=Z[X(void 0,r?.defaultLocale??void 0)];return(0,$.jsxs)(`div`,{className:`oc-injtab__body`,children:[(0,$.jsxs)(`div`,{className:`oc-injtab__content-locale`,children:[(0,$.jsx)(`span`,{children:re()}),(0,$.jsxs)(q,{value:v,onValueChange:e=>void _(e),children:[(0,$.jsx)(J,{size:`sm`,className:`min-w-44`,children:(0,$.jsx)(U,{})}),(0,$.jsxs)(Y,{children:[(0,$.jsx)(G,{value:`default`,children:a({locale:y})}),pe().map(e=>(0,$.jsx)(G,{value:e.value,children:e.label},e.value))]})]}),(0,$.jsx)(`p`,{className:`oc-admin__hint`,children:u()})]}),fe.map(e=>(0,$.jsx)(ye,{injKey:e,def:K[e],i18n:me[e],row:p[e]??{enabled:!0,template:K[e].defaultTemplate[o]},contentLocale:o,onChange:t=>m(e,t)},e)),(0,$.jsx)(`div`,{className:`oc-injtab__actions`,children:(0,$.jsx)(H,{size:`sm`,onClick:()=>void g(),disabled:d,children:C()})})]})}function ye({injKey:e,def:t,i18n:n,row:r,contentLocale:i,onChange:a}){let[o,s]=(0,Q.useState)(!1),u=r.template.trim()!==t.defaultTemplate[i],d=t.togglable&&!r.enabled,f=Object.fromEntries(t.placeholders.map(e=>[e,he[e]??`{${e}}`])),p=de(e,r,i),h=p?ue(p,f):``;return(0,$.jsxs)(`section`,{className:`oc-injcard`,children:[(0,$.jsxs)(`div`,{className:`oc-injcard__head`,children:[t.togglable?(0,$.jsxs)(`label`,{className:`oc-field--row`,children:[(0,$.jsx)(ce,{checked:r.enabled,onCheckedChange:e=>a({enabled:e===!0})}),(0,$.jsx)(z,{label:n.label(),help:n.help()})]}):(0,$.jsx)(z,{label:n.label(),help:n.help()}),u&&(0,$.jsx)(`span`,{className:`oc-injection__badge`,children:ee()})]}),(0,$.jsx)(`textarea`,{className:`oc-injcard__text`,value:r.template,disabled:d,rows:8,spellCheck:!1,onChange:e=>a({template:e.target.value})}),(0,$.jsxs)(`div`,{className:`oc-injection__foot`,children:[(0,$.jsxs)(`div`,{className:`oc-injcard__phs`,children:[(0,$.jsx)(`span`,{className:`oc-injection__ph`,children:D()}),t.placeholders.map(e=>(0,$.jsxs)(`span`,{className:`oc-injcard__ph-chip`,children:[(0,$.jsx)(`code`,{children:`{${e}}`}),(0,$.jsx)(V,{text:(ge[e]??(()=>e))()})]},e))]}),(0,$.jsxs)(`div`,{className:`oc-injcard__btns`,children:[(0,$.jsx)(H,{variant:`ghost`,size:`sm`,onClick:()=>s(e=>!e),children:o?c():v()}),u&&(0,$.jsx)(H,{variant:`ghost`,size:`sm`,onClick:()=>a({template:t.defaultTemplate[i]}),children:se()})]})]}),o&&(0,$.jsx)(`div`,{className:`oc-injcard__preview`,children:h?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`pre`,{className:`oc-injcard__previewtext`,children:h}),(0,$.jsx)(`span`,{className:`oc-injection__ph`,children:A()}),t.pluralDefaultTemplate!==void 0&&!d?(0,$.jsx)(`span`,{className:`oc-injection__ph`,children:m()}):null]}):(0,$.jsx)(`span`,{className:`oc-injection__ph`,children:l()})})]})}export{_e as PromptInjectionsTab};