@lacneu/atrium 0.71.0 → 0.71.2

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 (74) hide show
  1. package/dist/assets/{AccessTab-UMUL3D9_.js → AccessTab-CDi-2yXo.js} +1 -1
  2. package/dist/assets/{AdvancedFilter-BWRt6Typ.js → AdvancedFilter-oNVoBmr5.js} +1 -1
  3. package/dist/assets/AgentFilesTab-YQT3_OHb.js +3 -0
  4. package/dist/assets/{AnomaliesTab-Bg2jWSsL.js → AnomaliesTab-BRIph00P.js} +1 -1
  5. package/dist/assets/{AuditTab-479r2EBG.js → AuditTab-CDR9vWDW.js} +1 -1
  6. package/dist/assets/BridgeTab-DeYPFNVq.js +1 -0
  7. package/dist/assets/{ChatDefaultsTab-dxsM8U7W.js → ChatDefaultsTab-V66EFWzF.js} +1 -1
  8. package/dist/assets/{DataTableShell-BkZGrlHw.js → DataTableShell-BbVvH8AP.js} +1 -1
  9. package/dist/assets/{DetailChips-Cxppydov.js → DetailChips-CEPfBJ3C.js} +1 -1
  10. package/dist/assets/FeedbacksTab-ShRJwRig.js +1 -0
  11. package/dist/assets/{FieldLabel-DhQrYKvK.js → FieldLabel-YPTLow_x.js} +2 -2
  12. package/dist/assets/FilesTab-DMUdEQ-m.js +1 -0
  13. package/dist/assets/{FilterBar-D9hGs8jl.js → FilterBar-BQxNZSAj.js} +1 -1
  14. package/dist/assets/GroupsTab-O4TXB1Ob.js +1 -0
  15. package/dist/assets/InstancesTab-Ct4hI8bm.js +1 -0
  16. package/dist/assets/{IntegrationsTab-CkmVHPuZ.js → IntegrationsTab-Ba2AWn_y.js} +1 -1
  17. package/dist/assets/{KpiTab-CvBV-wJx.js → KpiTab-DDTX8X_Y.js} +1 -1
  18. package/dist/assets/PreferencesTab-CxFocwvh.js +1 -0
  19. package/dist/assets/{ProjectPage-CshF4uwy.js → ProjectPage-DXNQdzDR.js} +1 -1
  20. package/dist/assets/PromptInjectionsTab-CFe9KSPE.js +4 -0
  21. package/dist/assets/RolesTab-DWLOWJub.js +1 -0
  22. package/dist/assets/ScheduledTab-KxaffW0K.js +1 -0
  23. package/dist/assets/ServiceAccountsTab-D2kskvcN.js +1 -0
  24. package/dist/assets/{SubAgentReportsTab-BfPtn3Pi.js → SubAgentReportsTab-Bu0h7qO-.js} +1 -1
  25. package/dist/assets/ThemeShowroom-Drc8NJ8v.js +1 -0
  26. package/dist/assets/{TimeRangePicker-C5oWQ1bV.js → TimeRangePicker-zbyQlb0G.js} +1 -1
  27. package/dist/assets/{TimezoneCombobox-B7uN-QtE.js → TimezoneCombobox-673xwoei.js} +1 -1
  28. package/dist/assets/{TracesTab-DX5Ukj6q.js → TracesTab-DKr7xXLx.js} +1 -1
  29. package/dist/assets/{UsersTab-C48pcSUL.js → UsersTab-CO_GLnNQ.js} +1 -1
  30. package/dist/assets/VoiceTab-i90LqIO5.js +1 -0
  31. package/dist/assets/api-BASu8PYC.js +44 -0
  32. package/dist/assets/{button-BfHR-QFa.js → button-_UzA03A_.js} +1 -1
  33. package/dist/assets/{card-BwaW6OwI.js → card-BoGX4FTX.js} +1 -1
  34. package/dist/assets/check-BVOFzT6U.js +1 -0
  35. package/dist/assets/chevron-up-BiXGHpx6.js +1 -0
  36. package/dist/assets/chevrons-up-down-DHCh-E-T.js +1 -0
  37. package/dist/assets/{compatView-CwwpnhPX.js → compatView-DscksmHU.js} +1 -1
  38. package/dist/assets/{dispatchErrorInfo-CCvKYpif.js → dispatchErrorInfo-Cevbg9ej.js} +1 -1
  39. package/dist/assets/{dist-Cx6m07oR.js → dist-Bn5IE_M3.js} +1 -1
  40. package/dist/assets/{dist-Crom-_jQ.js → dist-CtimXARj.js} +1 -1
  41. package/dist/assets/{dist-DRVwMsgp.js → dist-Df0myUvd.js} +1 -1
  42. package/dist/assets/{highlighted-body-OFNGDK62-BJm-kV50.js → highlighted-body-OFNGDK62-DYD_5B4x.js} +1 -1
  43. package/dist/assets/index-D02RwoOe.js +238 -0
  44. package/dist/assets/{index-wDJo5MTQ.css → index-SBwQs_kQ.css} +1 -1
  45. package/dist/assets/{list-15dfaZSm.js → list-Cfz6xpiH.js} +1 -1
  46. package/dist/assets/mermaid-GHXKKRXX-5UTQL7SN.js +1 -0
  47. package/dist/assets/{pdf-CSsqEHsB.js → pdf-DWIi2vJu.js} +1 -1
  48. package/dist/assets/roleDescriptions-s4fc4FW8.js +1 -0
  49. package/dist/assets/{table-D-GuJvnN.js → table-ChZTpaGw.js} +1 -1
  50. package/dist/assets/{tabs-BE-jtUDZ.js → tabs-DkJ2Ivbq.js} +1 -1
  51. package/dist/assets/x-C5QQoypN.js +1 -0
  52. package/dist/index.html +10 -10
  53. package/package.json +1 -1
  54. package/dist/assets/AgentFilesTab-CR4dAGYo.js +0 -3
  55. package/dist/assets/BridgeTab-CzwuBHcJ.js +0 -1
  56. package/dist/assets/FeedbacksTab-DxLZBUVQ.js +0 -1
  57. package/dist/assets/FilesTab-Ok13trrC.js +0 -1
  58. package/dist/assets/GroupsTab-D09Awaxx.js +0 -1
  59. package/dist/assets/InstancesTab-C8Dao1AT.js +0 -1
  60. package/dist/assets/PreferencesTab-CdcdmZMc.js +0 -1
  61. package/dist/assets/PromptInjectionsTab-Bq1gLlkn.js +0 -4
  62. package/dist/assets/RolesTab-CDk7My17.js +0 -1
  63. package/dist/assets/ScheduledTab-DFMuVqYC.js +0 -1
  64. package/dist/assets/ServiceAccountsTab-BdNyNnQx.js +0 -1
  65. package/dist/assets/ThemeShowroom-BsLmpgqu.js +0 -1
  66. package/dist/assets/VoiceTab-BCCTf5rI.js +0 -1
  67. package/dist/assets/api-BZGL-EQ1.js +0 -44
  68. package/dist/assets/check-DVHDMfix.js +0 -1
  69. package/dist/assets/chevron-up-DqJUIpVq.js +0 -1
  70. package/dist/assets/chevrons-up-down-m0rvjPTx.js +0 -1
  71. package/dist/assets/index-B8D00xNa.js +0 -238
  72. package/dist/assets/mermaid-GHXKKRXX-D6S_VQR4.js +0 -1
  73. package/dist/assets/roleDescriptions-lmkJgty3.js +0 -1
  74. package/dist/assets/x-DU13TyPG.js +0 -1
@@ -1 +1 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$g as r,$m as i,A_ as a,B_ as o,Bg as s,C_ as c,D as l,E_ as u,GR as d,G_ as f,Gg as p,Hg as ee,IR as m,Jg as te,K_ as h,L_ as ne,Lg as g,M_ as re,O_ as ie,P_ as _,R_ as ae,S_ as v,T_ as y,Ug as b,V_ as x,Vg as oe,WR as S,Wg as C,Yg as se,__ as w,a_ as ce,b_ as T,c_ as le,d_ as ue,e_ as E,f_ as D,g_ as de,h_ as fe,i_ as pe,j_ as me,k_ as he,l_ as ge,m_ as _e,n_ as O,o_ as ve,p_ as k,q_ as ye,qg as A,s_ as be,t as j,t_ as xe,u_ as Se,v_ as M,w_ as Ce,y_ as N,zg as we}from"./api-BZGL-EQ1.js";import{r as Te}from"./dist-Cx6m07oR.js";import{t as Ee}from"./list-15dfaZSm.js";import{t as P}from"./button-BfHR-QFa.js";import{A as De,C as Oe,Cn as ke,D as F,Dt as Ae,E as je,En as Me,Fn as Ne,Ft as Pe,In as Fe,It as Ie,J as Le,Lt as Re,Mt as ze,Nt as Be,O as I,P as Ve,Pn as L,Pt as R,S as He,Sn as z,T as Ue,U as We,W as Ge,Y as Ke,_ as qe,_n as Je,b as B,d as Ye,dn as Xe,f as Ze,fn as V,g as H,h as U,hn as W,in as Qe,j as G,jn as $e,jt as K,k as et,m as tt,p as nt,pn as rt,v as q,vn as it,w as at,wn as J,x as Y,y as ot}from"./index-B8D00xNa.js";var st=l(`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`}]]),ct=l(`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`}]]),lt=l(`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`}]]),ut=l(`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 Q({className:e}){return(0,Z.jsx)(Re,{asChild:!0,children:(0,Z.jsx)(P,{variant:`ghost`,size:`icon-xs`,"aria-label":p(),className:e,onClick:e=>e.stopPropagation(),onMouseDown:e=>e.stopPropagation(),onTouchStart:e=>e.stopPropagation(),onPointerDown:e=>e.stopPropagation(),children:(0,Z.jsx)(Me,{})})})}function dt({folderId:e,name:t,color:n,currentParentId:i,className:o,onOpen:c}){let l=S(j.projects.renameProject),u=S(j.projects.setProjectColor),p=S(j.projects.moveProject),ee=S(j.projects.deleteProject),m=S(j.projects.createProject),g=We(),_=Ge(),[ae,v]=(0,X.useState)(!1),[y,b]=(0,X.useState)(t),[x,se]=(0,X.useState)(!1),[w,ce]=(0,X.useState)(!1),T=d(j.projects.projectTreeCount,w?{projectId:e}:`skip`);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(ze,{onOpenChange:e=>e&&ce(!0),children:[(0,Z.jsx)(Q,{className:o}),(0,Z.jsxs)(Be,{align:`end`,className:`w-48`,onClick:e=>e.stopPropagation(),children:[(0,Z.jsxs)(R,{onSelect:()=>c(),children:[(0,Z.jsx)(J,{}),` `,ie()]}),(0,Z.jsxs)(R,{onSelect:()=>{b(t),v(!0)},children:[(0,Z.jsx)(rt,{}),` `,C()]}),(0,Z.jsxs)(R,{onSelect:()=>{requestAnimationFrame(async()=>{let t=await _({title:N(),label:ye(),placeholder:h(),confirmLabel:f()});t&&await m({name:t,parentId:e})})},children:[(0,Z.jsx)(ke,{}),` `,N()]}),(0,Z.jsxs)(R,{onSelect:()=>se(!0),children:[(0,Z.jsx)(ct,{}),` `,xe()]}),(0,Z.jsx)(Pe,{children:oe()}),(0,Z.jsxs)(`div`,{className:`oc-colorgrid`,onClick:e=>e.stopPropagation(),children:[(0,Z.jsx)(`button`,{className:`oc-colorgrid__none`,onClick:()=>void u({projectId:e,color:null}),"aria-label":s(),children:`✕`}),tt.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 u({projectId:e,color:t.value})},t.value))]}),(0,Z.jsx)(Ie,{}),(0,Z.jsxs)(R,{variant:`destructive`,onSelect:()=>{requestAnimationFrame(async()=>{let n=T?.folders??0,r=T?.chats??0;await g({title:me({name:t}),description:n>0?he({folders:n,chats:r}):r>0?a({count:r}):te(),confirmWord:A(),confirmLabel:re(),destructive:!0})&&await ee({projectId:e})})},children:[(0,Z.jsx)(Qe,{}),` `,A()]})]})]}),(0,Z.jsx)(qe,{open:ae,onOpenChange:v,title:ne(),canSubmit:y.trim().length>0,onSubmit:async()=>{await l({projectId:e,name:y.trim()}),v(!1)},submitLabel:C(),children:(0,Z.jsx)(K,{value:y,onChange:e=>b(e.target.value),autoFocus:!0})}),x?(0,Z.jsx)(nt,{open:x,onOpenChange:se,title:r(),movingFolderId:e,currentId:i,onPick:t=>void p({projectId:e,parentId:t})}):null]})}function $({chat:e,currentFolderId:t,className:n}){let r=S(j.chats.pinChat),i=S(j.chats.deleteChat),a=S(j.chats.renameChat),o=S(j.chats.setChatSidebar),s=S(j.chats.moveChatToProject),c=We(),[l,d]=(0,X.useState)(!1),[f,p]=(0,X.useState)(e.title??``),[m,h]=(0,X.useState)(!1);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(ze,{children:[(0,Z.jsx)(Q,{className:n}),(0,Z.jsxs)(Be,{align:`end`,className:`w-52`,onClick:e=>e.stopPropagation(),children:[(0,Z.jsxs)(R,{onSelect:()=>{p(e.title??``),d(!0)},children:[(0,Z.jsx)(rt,{}),` `,C()]}),(0,Z.jsxs)(R,{onSelect:()=>void r({chatId:e._id,pinned:!e.pinned}),children:[e.pinned?(0,Z.jsx)(Xe,{}):(0,Z.jsx)(V,{}),e.pinned?b():ee()]}),(0,Z.jsxs)(R,{onSelect:()=>h(!0),children:[(0,Z.jsx)(ct,{}),` `,O()]}),e.pinned&&e.inSidebar?null:(0,Z.jsxs)(R,{onSelect:()=>void o({chatId:e._id,hidden:e.inSidebar}),children:[e.inSidebar?(0,Z.jsx)(W,{}):(0,Z.jsx)(ut,{}),e.inSidebar?y():u()]}),(0,Z.jsx)(Ie,{}),(0,Z.jsxs)(R,{variant:`destructive`,onSelect:()=>{requestAnimationFrame(async()=>{await c({title:we(),description:te(),confirmLabel:A(),destructive:!0})&&await i({chatId:e._id})})},children:[(0,Z.jsx)(Qe,{}),` `,A()]})]})]}),(0,Z.jsx)(qe,{open:l,onOpenChange:d,title:g(),canSubmit:f.trim().length>0,onSubmit:async()=>{await a({chatId:e._id,title:f.trim()}),d(!1)},submitLabel:C(),children:(0,Z.jsx)(K,{value:f,onChange:e=>p(e.target.value),autoFocus:!0})}),m?(0,Z.jsx)(nt,{open:m,onOpenChange:h,title:E(),currentId:t,onPick:t=>void s({chatId:e._id,projectId:t})}):null]})}function ft(e,t){let n=t.trim().toLowerCase();return n===``?e:e.filter(e=>(e.title??``).toLowerCase().includes(n))}function pt(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 mt(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 ht=`oc.projpage.view`;function gt(){let e=localStorage.getItem(ht);return e===`cards`||e===`list`?e:`columns`}var _t=e=>`into:${e}`,vt=e=>`col:${e??`null`}`,yt=e=>`crumb:${e}`;function bt(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 xt(){let{projectId:e}=Fe({from:`/project/$projectId`}),t=L(),n=d(j.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:m()}):n===null?(0,Z.jsxs)(`div`,{className:`oc-projpage__notfound`,children:[(0,Z.jsx)(`h2`,{children:be()}),(0,Z.jsx)(`p`,{className:`oc-projpage__hint`,children:ve()}),(0,Z.jsx)(P,{variant:`outline`,onClick:()=>void t({to:`/`}),children:ce()})]}):(0,Z.jsx)(St,{page:n})})}function St({page:e}){let t=L(),n=We(),o=Ge(),l=Ae(),u=S(j.projects.renameProject),p=S(j.projects.setProjectColor),ee=S(j.projects.deleteProject),m=S(j.projects.createProject),g=S(j.projects.moveProject),ie=S(j.chats.moveChatToProject),_=S(j.chats.reorderChat),y=S(j.projects.reorderProject),b=d(j.projects.projectTreeCount,{projectId:e.project._id}),[w,ce]=(0,X.useState)(gt),E=e=>{localStorage.setItem(ht,e),ce(e)},D=d(j.projects.folderColumns,w===`columns`?{projectId:e.project._id}:`skip`),O=d(j.projects.projectTreeList,w===`list`?{projectId:e.project._id}:`skip`),{c:ve}=Ne({from:`/project/$projectId`}),k=d(j.projects.listProjects,{}),be=d(j.chatReads.myBusyChats,{}),M=(0,X.useMemo)(()=>new Set(be??[]),[be]),we=d(j.chatReads.myChatReads,{}),Te=(0,X.useMemo)(()=>mt(e.chats,we??[]),[e.chats,we]),{startNewChat:Fe,picker:I}=Ye(e=>void t({to:`/chat/$chatId`,params:{chatId:e}})),[B,Xe]=(0,X.useState)(``),[Ze,V]=(0,X.useState)(!1),[U,W]=(0,X.useState)(e.project.name),[G,$e]=(0,X.useState)(!1),[J,ut]=(0,X.useState)(``);(0,X.useEffect)(()=>{let e=setTimeout(()=>ut(B.trim()),180);return()=>clearTimeout(e)},[B]);let Q=d(j.search.searchConversations,J.length>=2?{query:J,projectId:e.project._id}:`skip`),dt=De(et(at,{activationConstraint:{distance:4}}),et(Ue,{activationConstraint:{delay:250,tolerance:8}})),$=(0,X.useRef)(!1),_t=()=>{$.current=!0,setTimeout(()=>{$.current=!1},0)},[vt,yt]=(0,X.useState)(null),xt=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||x()}}if(t.startsWith(`folder:`)){let e=t.slice(7);return{kind:`folder`,label:(k??[]).find(t=>t._id===e)?.name??``}}return null},St=e=>yt(xt(String(e.active.id))),Tt=(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=F(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=F(n(t?`folder:`:`chat:`));if(i.length>0)return i;let a=F(n(`crumb:`));if(a.length>0)return a;let o=F(n(`col:`));return o.length>0?o:je(n(t?`folder:`:`chat:`))},[]),Dt=t=>{if(w===`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(w===`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},kt=t=>{if(w===`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(w===`list`){let e=O?.folders.find(e=>e._id===t);if(!e||!O)return null;let n=e.parentId??O.rootId;return{list:Ke(O.folders,e.parentId),parentId:n}}return e.children.some(e=>e._id===t)?{list:e.children,parentId:e.project._id}:null},At=async e=>{yt(null),_t();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=bt(r);if(e!==void 0){if(a)await ie({chatId:i.slice(5),projectId:e});else{let t=i.slice(7);if(t===e)return;if(!Le(k??[],t,e)){l.error(T());return}await g({projectId:t,parentId:e})}return}if(a&&r.startsWith(`chat:`)){let e=i.slice(5),t=r.slice(5);if(e===t)return;let n=Dt(t);if(!n)return;n.list.some(t=>t._id===e)||await ie({chatId:e,projectId:n.folderId});let a=pt(n.list,e=>e._id,e=>e.sortKey,e,t);a&&await _({chatId:e,...a});return}if(!a&&r.startsWith(`folder:`)){let e=i.slice(7),t=r.slice(7);if(e===t)return;let n=kt(t);if(!n)return;if(!n.list.some(t=>t._id===e)){if(!Le(k??[],e,n.parentId)){l.error(T());return}await g({projectId:e,parentId:n.parentId})}let a=pt(n.list,e=>e._id,e=>e.sortKey,e,t);a&&await y({projectId:e,...a});return}}catch{l.error(T())}},[,Mt]=(0,X.useState)(0);(0,X.useEffect)(()=>{let e=window.setInterval(()=>Mt(e=>e+1),6e4);return()=>window.clearInterval(e)},[]);let Nt=Date.now(),Pt=H(e.project),Ft=ft(e.chats,B),It=e.breadcrumb.slice(0,-1),Lt=e=>()=>{$.current||e()};return(0,Z.jsxs)(He,{sensors:dt,collisionDetection:Tt,onDragStart:St,onDragEnd:At,children:[(0,Z.jsxs)(`div`,{className:`oc-projpage__body`,style:{"--proj-hue":Pt},children:[(0,Z.jsxs)(`nav`,{className:`oc-projpage__crumbs`,"aria-label":pe(),children:[It.map(e=>(0,Z.jsxs)(`span`,{className:`oc-projpage__crumb`,children:[(0,Z.jsx)(Ct,{folderId:e._id,children:(0,Z.jsx)(`button`,{type:`button`,className:`oc-projpage__crumblink`,onClick:Lt(()=>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}),(0,Z.jsxs)(`div`,{className:`oc-projpage__actions`,children:[(0,Z.jsxs)(`div`,{className:`oc-projpage__viewtoggle`,role:`group`,"aria-label":Ce(),children:[(0,Z.jsx)(P,{variant:w===`cards`?`secondary`:`ghost`,size:`icon-sm`,"aria-label":Ce(),title:Ce(),"aria-pressed":w===`cards`,onClick:()=>E(`cards`),children:(0,Z.jsx)(lt,{})}),(0,Z.jsx)(P,{variant:w===`columns`?`secondary`:`ghost`,size:`icon-sm`,"aria-label":c(),title:c(),"aria-pressed":w===`columns`,onClick:()=>E(`columns`),children:(0,Z.jsx)(st,{})}),(0,Z.jsx)(P,{variant:w===`list`?`secondary`:`ghost`,size:`icon-sm`,"aria-label":v(),title:v(),"aria-pressed":w===`list`,onClick:()=>E(`list`),children:(0,Z.jsx)(Ee,{})})]}),(0,Z.jsxs)(P,{variant:`outline`,size:`sm`,onClick:()=>void Fe({projectId:e.project._id}),children:[(0,Z.jsx)(it,{}),_e()]}),(0,Z.jsxs)(P,{variant:`outline`,size:`sm`,onClick:async()=>{let t=await o({title:N(),label:ye(),placeholder:h(),confirmLabel:f()});t&&await m({name:t,parentId:e.project._id})},children:[(0,Z.jsx)(ke,{}),N()]}),(0,Z.jsxs)(ze,{children:[(0,Z.jsx)(Re,{asChild:!0,children:(0,Z.jsx)(P,{variant:`ghost`,size:`icon-sm`,"aria-label":ae(),children:(0,Z.jsx)(Me,{})})}),(0,Z.jsxs)(Be,{align:`end`,className:`w-48`,children:[(0,Z.jsxs)(R,{onSelect:()=>{W(e.project.name),V(!0)},children:[(0,Z.jsx)(rt,{}),` `,C()]}),(0,Z.jsxs)(R,{onSelect:()=>$e(!0),children:[(0,Z.jsx)(ct,{}),` `,xe()]}),(0,Z.jsx)(Pe,{children:oe()}),(0,Z.jsxs)(`div`,{className:`oc-colorgrid`,children:[(0,Z.jsx)(`button`,{className:`oc-colorgrid__none`,onClick:()=>void p({projectId:e.project._id,color:null}),"aria-label":s(),children:`✕`}),tt.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 p({projectId:e.project._id,color:t.value})},t.value))]}),(0,Z.jsx)(Ie,{}),(0,Z.jsxs)(R,{variant:`destructive`,onSelect:()=>{let r=e.project.parentId;requestAnimationFrame(async()=>{let i=b?.folders??0,o=b?.chats??0;await n({title:me({name:e.project.name}),description:i>0?he({folders:i,chats:o}):o>0?a({count:o}):te(),confirmWord:A(),confirmLabel:re(),destructive:!0})&&(await ee({projectId:e.project._id}),t(r===null?{to:`/`}:{to:`/project/$projectId`,params:{projectId:r}}))})},children:[(0,Z.jsx)(Qe,{}),` `,A()]})]})]})]})]}),w===`columns`?(0,Z.jsx)(jt,{data:D,currentId:e.project._id,busyIds:M,suppressClick:$,locateChatId:ve??null}):w===`list`?(0,Z.jsx)(Ot,{data:O,busyIds:M,suppressClick:$,locateChatId:ve??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:de()}),(0,Z.jsx)(`div`,{className:`oc-projpage__cards`,children:(0,Z.jsx)(q,{items:e.children.map(e=>`folder:${e._id}`),strategy:ot,children:e.children.map(t=>(0,Z.jsx)(wt,{child:t,parentId:e.project._id,now:Nt,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:fe()}),e.chats.length>0?(0,Z.jsx)(K,{value:B,onChange:e=>Xe(e.target.value),placeholder:ue(),className:`oc-projpage__filter`}):null]}),e.chats.length===0?(0,Z.jsx)(`p`,{className:`oc-projpage__hint`,children:e.children.length===0?ge():le()}):Ft.length===0&&(Q??[]).length===0?(0,Z.jsx)(`p`,{className:`oc-projpage__hint`,children:Se({term:B.trim()})}):(0,Z.jsx)(`ul`,{className:`oc-projpage__chats`,children:(0,Z.jsx)(q,{items:Ft.map(e=>`chat:${e._id}`),strategy:Y,children:Ft.map(t=>(0,Z.jsx)(Et,{chat:t,currentFolderId:e.project._id,now:Nt,busy:M.has(t._id),unread:Te.has(t._id),locate:t._id===ve,suppressClick:$},t._id))})})]}),J.length>=2&&Q!==void 0?(0,Z.jsxs)(`section`,{className:`oc-projpage__section`,children:[(0,Z.jsx)(`h2`,{className:`oc-projpage__subtitle`,children:se()}),Q.length===0?(0,Z.jsx)(`p`,{className:`oc-projpage__hint`,children:Se({term:J})}):(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&&J&&Ve(e.messageId,J),t({to:`/chat/$chatId`,params:{chatId:e.chatId},...e.messageId?{search:{m:e.messageId}}:{}})},children:[(0,Z.jsx)(Je,{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||i()}),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)(qe,{open:Ze,onOpenChange:V,title:ne(),canSubmit:U.trim().length>0,onSubmit:async()=>{await u({projectId:e.project._id,name:U.trim()}),V(!1)},submitLabel:C(),children:(0,Z.jsx)(K,{value:U,onChange:e=>W(e.target.value),autoFocus:!0})}),G?(0,Z.jsx)(nt,{open:G,onOpenChange:$e,title:r(),movingFolderId:e.project._id,currentId:e.project.parentId,onPick:t=>void g({projectId:e.project._id,parentId:t})}):null,I]}),(0,Z.jsx)(Oe,{children:vt?(0,Z.jsxs)(`div`,{className:`oc-projpage__dragghost`,children:[vt.kind===`folder`?(0,Z.jsx)(z,{size:13,"aria-hidden":!0}):(0,Z.jsx)(Je,{size:13,"aria-hidden":!0}),(0,Z.jsx)(`span`,{children:vt.label})]}):null})]})}function Ct({folderId:e,children:t}){let{setNodeRef:n,isOver:r}=I({id:yt(e)});return(0,Z.jsx)(`span`,{ref:n,className:r?`oc-projpage__cdrop is-over`:`oc-projpage__cdrop`,children:t})}function wt({child:e,parentId:t,now:n,suppressClick:r}){let i=L(),a=B({id:`folder:${e._id}`}),o=I({id:_t(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":H(e),transform:G.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)(dt,{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?k({count:e.folderCount})+` · `:``,D({count:e.recursiveChatCount})]}),e.lastActivityAt===null?null:(0,Z.jsx)(`span`,{className:`oc-projpage__cardage`,children:Ze(e.lastActivityAt,n)})]})}function Tt({chat:e}){let t=S(j.chats.setChatSidebar),n=e.inSidebar?y():u();return(0,Z.jsx)(P,{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)(W,{}):(0,Z.jsx)(ut,{})})}function Et({chat:e,currentFolderId:t,now:n,busy:r,unread:i,locate:a,suppressClick:s}){let c=L(),l=U(e.color),u=B({id:`chat:${e._id}`}),d=Dt(a);return(0,Z.jsxs)(`li`,{ref:e=>{u.setNodeRef(e),d.current=e},className:`oc-projpage__chatrow`+(u.isDragging?` is-dragging`:``)+(a?` is-locate`:``),style:{transform:G.Transform.toString(u.transform),transition:u.transition},children:[(0,Z.jsxs)(`button`,{type:`button`,className:`oc-projpage__chatbtn`,onClick:()=>{s.current||c({to:`/chat/$chatId`,params:{chatId:e._id}})},...u.listeners,...u.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__chattitle`,children:e.title||x()}),e.pinned?(0,Z.jsx)(V,{size:12,"aria-hidden":!0,className:`oc-projpage__chatpin`}):null,(0,Z.jsx)(`span`,{className:`oc-projpage__chatage`,children:Ze(e.updatedAt,n)}),r?(0,Z.jsx)(`span`,{className:`oc-chatitem__busy`,title:o(),"aria-label":o()}):null,i&&!r?(0,Z.jsx)(`span`,{className:`oc-chatitem__unread`,title:_(),"aria-label":_()}):null]}),(0,Z.jsx)(Tt,{chat:e}),(0,Z.jsx)($,{chat:e,currentFolderId:t,className:`oc-projpage__chatmenu`})]})}function Dt(e){let t=(0,X.useRef)(null);return(0,X.useEffect)(()=>{e&&t.current&&t.current.scrollIntoView({block:`center`})},[e]),t}function Ot({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:m()});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=Ke(e.folders,a);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(q,{items:u.map(e=>`chat:${e._id}`),strategy:Y,children:u.map(e=>(0,Z.jsx)(At,{chat:e,depth:l,busy:t.has(e._id),locate:e._id===r,suppressClick:n},e._id))}),(0,Z.jsx)(q,{items:d.map(e=>`folder:${e._id}`),strategy:Y,children:d.map(t=>(0,Z.jsx)(kt,{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&&Ke(e.folders,null).length===0?(0,Z.jsx)(`p`,{className:`oc-projpage__hint`,children:ge()}):c(null,0)})}function kt({folder:e,parentId:t,depth:n,folded:r,onToggle:i,suppressClick:a,children:o}){let s=L(),c=B({id:`folder:${e._id}`}),l=I({id:_t(e._id)});return(0,Z.jsxs)(`div`,{className:`oc-projpage__treegroup`,children:[(0,Z.jsxs)(`div`,{ref:e=>{c.setNodeRef(e),l.setNodeRef(e)},className:`oc-projpage__treerow oc-projpage__treerow--folder`+(l.isOver?` is-over`:``)+(c.isDragging?` is-dragging`:``),style:{"--tree-depth":n,"--proj-hue":H(e),transform:G.Transform.toString(c.transform),transition:c.transition},...c.listeners,...c.attributes,role:`button`,tabIndex:0,onClick:()=>{a.current||s({to:`/project/$projectId`,params:{projectId:e._id}})},onKeyDown:t=>{t.key===`Enter`&&s({to:`/project/$projectId`,params:{projectId:e._id}})},children:[(0,Z.jsx)(`button`,{type:`button`,className:`oc-projpage__treechev`,"aria-label":r?M():w(),"aria-expanded":!r,onClick:e=>{e.stopPropagation(),!a.current&&i()},onMouseDown:e=>e.stopPropagation(),onTouchStart:e=>e.stopPropagation(),children:r?(0,Z.jsx)($e,{size:13}):(0,Z.jsx)(Te,{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)(dt,{folderId:e._id,name:e.name,color:e.color,currentParentId:t,className:`oc-projpage__treemenu`,onOpen:()=>void s({to:`/project/$projectId`,params:{projectId:e._id}})})]}),o]})}function At({chat:e,depth:t,busy:n,locate:r,suppressClick:i}){let a=L(),o=B({id:`chat:${e._id}`}),s=Dt(r),c=U(e.color);return(0,Z.jsxs)(`div`,{ref:e=>{o.setNodeRef(e),s.current=e},className:`oc-projpage__treerow oc-projpage__treerow--chat`+(o.isDragging?` is-dragging`:``)+(r?` is-locate`:``),style:{"--tree-depth":t,transform:G.Transform.toString(o.transform),transition:o.transition},children:[(0,Z.jsxs)(`button`,{type:`button`,className:`oc-projpage__colchatbtn`,onClick:()=>{i.current||a({to:`/chat/$chatId`,params:{chatId:e._id}})},...o.listeners,...o.attributes,children:[c?(0,Z.jsx)(`span`,{className:`oc-chatitem__dot`,style:{background:c}}):(0,Z.jsx)(`span`,{className:`oc-chatitem__dot oc-chatitem__dot--empty`}),(0,Z.jsx)(`span`,{className:`oc-projpage__colname`,children:e.title||x()}),n?(0,Z.jsx)(`span`,{className:`oc-chatitem__busy`,"aria-hidden":!0}):null]}),(0,Z.jsx)($,{chat:e,currentFolderId:e.folderId,className:`oc-projpage__treemenu`}),(0,Z.jsx)(Tt,{chat:e})]})}function jt({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:m()}):(0,Z.jsx)(`div`,{className:`oc-projpage__cols`,ref:a,children:e.columns.map((a,o)=>(0,Z.jsx)(Mt,{col:a,isLast:o===e.columns.length-1,currentId:t,busyIds:n,suppressClick:r,locateChatId:i},a.folderId??`root`))})}function Mt({col:e,isLast:t,currentId:n,busyIds:r,suppressClick:i,locateChatId:a}){let o=L(),s=I({id:vt(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)(q,{items:e.folders.map(e=>`folder:${e._id}`),strategy:Y,children:e.folders.map(t=>(0,Z.jsx)(Nt,{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)(q,{items:e.chats.map(e=>`chat:${e._id}`),strategy:Y,children:e.chats.map(t=>(0,Z.jsx)(Pt,{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:le()}):null]})}function Nt({folder:e,parentId:t,isCurrent:n,suppressClick:r,onOpen:i}){let a=B({id:`folder:${e._id}`}),o=I({id:_t(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":H(e),transform:G.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)(dt,{folderId:e._id,name:e.name,color:e.color,currentParentId:t,className:`oc-projpage__colmenu`,onOpen:i})]})}function Pt({chat:e,folderId:t,busy:n,locate:r,suppressClick:i,onOpen:a}){let o=B({id:`chat:${e._id}`}),s=Dt(r),c=U(e.color);return(0,Z.jsxs)(`div`,{ref:e=>{o.setNodeRef(e),s.current=e},className:`oc-projpage__colentry oc-projpage__colentry--chat`+(o.isDragging?` is-dragging`:``)+(r?` is-locate`:``),style:{transform:G.Transform.toString(o.transform),transition:o.transition},children:[(0,Z.jsxs)(`button`,{type:`button`,className:`oc-projpage__colchatbtn`,onClick:()=>{i.current||a()},...o.listeners,...o.attributes,children:[c?(0,Z.jsx)(`span`,{className:`oc-chatitem__dot`,style:{background:c}}):(0,Z.jsx)(`span`,{className:`oc-chatitem__dot oc-chatitem__dot--empty`}),(0,Z.jsx)(`span`,{className:`oc-projpage__colname`,children:e.title||x()}),n?(0,Z.jsx)(`span`,{className:`oc-chatitem__busy`,"aria-hidden":!0}):null]}),(0,Z.jsx)($,{chat:e,currentFolderId:t,className:`oc-projpage__colmenu oc-projpage__colmenu--chat`}),(0,Z.jsx)(Tt,{chat:e})]})}export{xt as ProjectPage};
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$g as r,$m as i,A_ as a,B_ as o,Bg as s,C_ as c,D as l,E_ as u,GR as d,G_ as f,Gg as p,Hg as ee,Jg as te,KR as m,K_ as h,LR as g,L_ as ne,Lg as _,M_ as re,O_ as ie,P_ as v,R_ as ae,S_ as y,T_ as b,Ug as x,V_ as S,Vg as oe,Wg as C,Yg as se,__ as w,a_ as ce,b_ as T,c_ as le,d_ as ue,e_ as E,f_ as D,g_ as de,h_ as fe,i_ as pe,j_ as me,k_ as he,l_ as ge,m_ as _e,n_ as O,o_ as ve,p_ as k,q_ as ye,qg as A,s_ as be,t as j,t_ as xe,u_ as Se,v_ as M,w_ as Ce,y_ as N,zg as we}from"./api-BASu8PYC.js";import{r as Te}from"./dist-Bn5IE_M3.js";import{t as Ee}from"./list-Cfz6xpiH.js";import{t as P}from"./button-_UzA03A_.js";import{A as De,C as Oe,Cn as ke,D as F,Dt as Ae,E as je,En as Me,Fn as Ne,Ft as Pe,In as Fe,It as Ie,J as Le,Lt as Re,Mt as ze,Nt as Be,O as I,P as Ve,Pn as L,Pt as R,S as He,Sn as z,T as Ue,U as We,W as Ge,Y as Ke,_ as qe,_n as Je,b as B,d as Ye,dn as Xe,f as Ze,fn as V,g as H,h as U,hn as W,in as Qe,j as G,jn as $e,jt as K,k as et,m as tt,p as nt,pn as rt,v as q,vn as it,w as at,wn as J,x as Y,y as ot}from"./index-D02RwoOe.js";var st=l(`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`}]]),ct=l(`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`}]]),lt=l(`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`}]]),ut=l(`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 Q({className:e}){return(0,Z.jsx)(Re,{asChild:!0,children:(0,Z.jsx)(P,{variant:`ghost`,size:`icon-xs`,"aria-label":p(),className:e,onClick:e=>e.stopPropagation(),onMouseDown:e=>e.stopPropagation(),onTouchStart:e=>e.stopPropagation(),onPointerDown:e=>e.stopPropagation(),children:(0,Z.jsx)(Me,{})})})}function dt({folderId:e,name:t,color:n,currentParentId:i,className:o,onOpen:c}){let l=d(j.projects.renameProject),u=d(j.projects.setProjectColor),p=d(j.projects.moveProject),ee=d(j.projects.deleteProject),g=d(j.projects.createProject),_=We(),v=Ge(),[ae,y]=(0,X.useState)(!1),[b,x]=(0,X.useState)(t),[S,se]=(0,X.useState)(!1),[w,ce]=(0,X.useState)(!1),T=m(j.projects.projectTreeCount,w?{projectId:e}:`skip`);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(ze,{onOpenChange:e=>e&&ce(!0),children:[(0,Z.jsx)(Q,{className:o}),(0,Z.jsxs)(Be,{align:`end`,className:`w-48`,onClick:e=>e.stopPropagation(),children:[(0,Z.jsxs)(R,{onSelect:()=>c(),children:[(0,Z.jsx)(J,{}),` `,ie()]}),(0,Z.jsxs)(R,{onSelect:()=>{x(t),y(!0)},children:[(0,Z.jsx)(rt,{}),` `,C()]}),(0,Z.jsxs)(R,{onSelect:()=>{requestAnimationFrame(async()=>{let t=await v({title:N(),label:ye(),placeholder:h(),confirmLabel:f()});t&&await g({name:t,parentId:e})})},children:[(0,Z.jsx)(ke,{}),` `,N()]}),(0,Z.jsxs)(R,{onSelect:()=>se(!0),children:[(0,Z.jsx)(ct,{}),` `,xe()]}),(0,Z.jsx)(Pe,{children:oe()}),(0,Z.jsxs)(`div`,{className:`oc-colorgrid`,onClick:e=>e.stopPropagation(),children:[(0,Z.jsx)(`button`,{className:`oc-colorgrid__none`,onClick:()=>void u({projectId:e,color:null}),"aria-label":s(),children:`✕`}),tt.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 u({projectId:e,color:t.value})},t.value))]}),(0,Z.jsx)(Ie,{}),(0,Z.jsxs)(R,{variant:`destructive`,onSelect:()=>{requestAnimationFrame(async()=>{let n=T?.folders??0,r=T?.chats??0;await _({title:me({name:t}),description:n>0?he({folders:n,chats:r}):r>0?a({count:r}):te(),confirmWord:A(),confirmLabel:re(),destructive:!0})&&await ee({projectId:e})})},children:[(0,Z.jsx)(Qe,{}),` `,A()]})]})]}),(0,Z.jsx)(qe,{open:ae,onOpenChange:y,title:ne(),canSubmit:b.trim().length>0,onSubmit:async()=>{await l({projectId:e,name:b.trim()}),y(!1)},submitLabel:C(),children:(0,Z.jsx)(K,{value:b,onChange:e=>x(e.target.value),autoFocus:!0})}),S?(0,Z.jsx)(nt,{open:S,onOpenChange:se,title:r(),movingFolderId:e,currentId:i,onPick:t=>void p({projectId:e,parentId:t})}):null]})}function $({chat:e,currentFolderId:t,className:n}){let r=d(j.chats.pinChat),i=d(j.chats.deleteChat),a=d(j.chats.renameChat),o=d(j.chats.setChatSidebar),s=d(j.chats.moveChatToProject),c=We(),[l,f]=(0,X.useState)(!1),[p,m]=(0,X.useState)(e.title??``),[h,g]=(0,X.useState)(!1);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(ze,{children:[(0,Z.jsx)(Q,{className:n}),(0,Z.jsxs)(Be,{align:`end`,className:`w-52`,onClick:e=>e.stopPropagation(),children:[(0,Z.jsxs)(R,{onSelect:()=>{m(e.title??``),f(!0)},children:[(0,Z.jsx)(rt,{}),` `,C()]}),(0,Z.jsxs)(R,{onSelect:()=>void r({chatId:e._id,pinned:!e.pinned}),children:[e.pinned?(0,Z.jsx)(Xe,{}):(0,Z.jsx)(V,{}),e.pinned?x():ee()]}),(0,Z.jsxs)(R,{onSelect:()=>g(!0),children:[(0,Z.jsx)(ct,{}),` `,O()]}),e.pinned&&e.inSidebar?null:(0,Z.jsxs)(R,{onSelect:()=>void o({chatId:e._id,hidden:e.inSidebar}),children:[e.inSidebar?(0,Z.jsx)(W,{}):(0,Z.jsx)(ut,{}),e.inSidebar?b():u()]}),(0,Z.jsx)(Ie,{}),(0,Z.jsxs)(R,{variant:`destructive`,onSelect:()=>{requestAnimationFrame(async()=>{await c({title:we(),description:te(),confirmLabel:A(),destructive:!0})&&await i({chatId:e._id})})},children:[(0,Z.jsx)(Qe,{}),` `,A()]})]})]}),(0,Z.jsx)(qe,{open:l,onOpenChange:f,title:_(),canSubmit:p.trim().length>0,onSubmit:async()=>{await a({chatId:e._id,title:p.trim()}),f(!1)},submitLabel:C(),children:(0,Z.jsx)(K,{value:p,onChange:e=>m(e.target.value),autoFocus:!0})}),h?(0,Z.jsx)(nt,{open:h,onOpenChange:g,title:E(),currentId:t,onPick:t=>void s({chatId:e._id,projectId:t})}):null]})}function ft(e,t){let n=t.trim().toLowerCase();return n===``?e:e.filter(e=>(e.title??``).toLowerCase().includes(n))}function pt(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 mt(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 ht=`oc.projpage.view`;function gt(){let e=localStorage.getItem(ht);return e===`cards`||e===`list`?e:`columns`}var _t=e=>`into:${e}`,vt=e=>`col:${e??`null`}`,yt=e=>`crumb:${e}`;function bt(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 xt(){let{projectId:e}=Fe({from:`/project/$projectId`}),t=L(),n=m(j.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:g()}):n===null?(0,Z.jsxs)(`div`,{className:`oc-projpage__notfound`,children:[(0,Z.jsx)(`h2`,{children:be()}),(0,Z.jsx)(`p`,{className:`oc-projpage__hint`,children:ve()}),(0,Z.jsx)(P,{variant:`outline`,onClick:()=>void t({to:`/`}),children:ce()})]}):(0,Z.jsx)(St,{page:n})})}function St({page:e}){let t=L(),n=We(),o=Ge(),l=Ae(),u=d(j.projects.renameProject),p=d(j.projects.setProjectColor),ee=d(j.projects.deleteProject),g=d(j.projects.createProject),_=d(j.projects.moveProject),ie=d(j.chats.moveChatToProject),v=d(j.chats.reorderChat),b=d(j.projects.reorderProject),x=m(j.projects.projectTreeCount,{projectId:e.project._id}),[w,ce]=(0,X.useState)(gt),E=e=>{localStorage.setItem(ht,e),ce(e)},D=m(j.projects.folderColumns,w===`columns`?{projectId:e.project._id}:`skip`),O=m(j.projects.projectTreeList,w===`list`?{projectId:e.project._id}:`skip`),{c:ve}=Ne({from:`/project/$projectId`}),k=m(j.projects.listProjects,{}),be=m(j.chatReads.myBusyChats,{}),M=(0,X.useMemo)(()=>new Set(be??[]),[be]),we=m(j.chatReads.myChatReads,{}),Te=(0,X.useMemo)(()=>mt(e.chats,we??[]),[e.chats,we]),{startNewChat:Fe,picker:I}=Ye(e=>void t({to:`/chat/$chatId`,params:{chatId:e}})),[B,Xe]=(0,X.useState)(``),[Ze,V]=(0,X.useState)(!1),[U,W]=(0,X.useState)(e.project.name),[G,$e]=(0,X.useState)(!1),[J,ut]=(0,X.useState)(``);(0,X.useEffect)(()=>{let e=setTimeout(()=>ut(B.trim()),180);return()=>clearTimeout(e)},[B]);let Q=m(j.search.searchConversations,J.length>=2?{query:J,projectId:e.project._id}:`skip`),dt=De(et(at,{activationConstraint:{distance:4}}),et(Ue,{activationConstraint:{delay:250,tolerance:8}})),$=(0,X.useRef)(!1),_t=()=>{$.current=!0,setTimeout(()=>{$.current=!1},0)},[vt,yt]=(0,X.useState)(null),xt=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||S()}}if(t.startsWith(`folder:`)){let e=t.slice(7);return{kind:`folder`,label:(k??[]).find(t=>t._id===e)?.name??``}}return null},St=e=>yt(xt(String(e.active.id))),Tt=(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=F(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=F(n(t?`folder:`:`chat:`));if(i.length>0)return i;let a=F(n(`crumb:`));if(a.length>0)return a;let o=F(n(`col:`));return o.length>0?o:je(n(t?`folder:`:`chat:`))},[]),Dt=t=>{if(w===`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(w===`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},kt=t=>{if(w===`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(w===`list`){let e=O?.folders.find(e=>e._id===t);if(!e||!O)return null;let n=e.parentId??O.rootId;return{list:Ke(O.folders,e.parentId),parentId:n}}return e.children.some(e=>e._id===t)?{list:e.children,parentId:e.project._id}:null},At=async e=>{yt(null),_t();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=bt(r);if(e!==void 0){if(a)await ie({chatId:i.slice(5),projectId:e});else{let t=i.slice(7);if(t===e)return;if(!Le(k??[],t,e)){l.error(T());return}await _({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=Dt(t);if(!n)return;n.list.some(t=>t._id===e)||await ie({chatId:e,projectId:n.folderId});let a=pt(n.list,e=>e._id,e=>e.sortKey,e,t);a&&await v({chatId:e,...a});return}if(!a&&r.startsWith(`folder:`)){let e=i.slice(7),t=r.slice(7);if(e===t)return;let n=kt(t);if(!n)return;if(!n.list.some(t=>t._id===e)){if(!Le(k??[],e,n.parentId)){l.error(T());return}await _({projectId:e,parentId:n.parentId})}let a=pt(n.list,e=>e._id,e=>e.sortKey,e,t);a&&await b({projectId:e,...a});return}}catch{l.error(T())}},[,Mt]=(0,X.useState)(0);(0,X.useEffect)(()=>{let e=window.setInterval(()=>Mt(e=>e+1),6e4);return()=>window.clearInterval(e)},[]);let Nt=Date.now(),Pt=H(e.project),Ft=ft(e.chats,B),It=e.breadcrumb.slice(0,-1),Lt=e=>()=>{$.current||e()};return(0,Z.jsxs)(He,{sensors:dt,collisionDetection:Tt,onDragStart:St,onDragEnd:At,children:[(0,Z.jsxs)(`div`,{className:`oc-projpage__body`,style:{"--proj-hue":Pt},children:[(0,Z.jsxs)(`nav`,{className:`oc-projpage__crumbs`,"aria-label":pe(),children:[It.map(e=>(0,Z.jsxs)(`span`,{className:`oc-projpage__crumb`,children:[(0,Z.jsx)(Ct,{folderId:e._id,children:(0,Z.jsx)(`button`,{type:`button`,className:`oc-projpage__crumblink`,onClick:Lt(()=>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}),(0,Z.jsxs)(`div`,{className:`oc-projpage__actions`,children:[(0,Z.jsxs)(`div`,{className:`oc-projpage__viewtoggle`,role:`group`,"aria-label":Ce(),children:[(0,Z.jsx)(P,{variant:w===`cards`?`secondary`:`ghost`,size:`icon-sm`,"aria-label":Ce(),title:Ce(),"aria-pressed":w===`cards`,onClick:()=>E(`cards`),children:(0,Z.jsx)(lt,{})}),(0,Z.jsx)(P,{variant:w===`columns`?`secondary`:`ghost`,size:`icon-sm`,"aria-label":c(),title:c(),"aria-pressed":w===`columns`,onClick:()=>E(`columns`),children:(0,Z.jsx)(st,{})}),(0,Z.jsx)(P,{variant:w===`list`?`secondary`:`ghost`,size:`icon-sm`,"aria-label":y(),title:y(),"aria-pressed":w===`list`,onClick:()=>E(`list`),children:(0,Z.jsx)(Ee,{})})]}),(0,Z.jsxs)(P,{variant:`outline`,size:`sm`,onClick:()=>void Fe({projectId:e.project._id}),children:[(0,Z.jsx)(it,{}),_e()]}),(0,Z.jsxs)(P,{variant:`outline`,size:`sm`,onClick:async()=>{let t=await o({title:N(),label:ye(),placeholder:h(),confirmLabel:f()});t&&await g({name:t,parentId:e.project._id})},children:[(0,Z.jsx)(ke,{}),N()]}),(0,Z.jsxs)(ze,{children:[(0,Z.jsx)(Re,{asChild:!0,children:(0,Z.jsx)(P,{variant:`ghost`,size:`icon-sm`,"aria-label":ae(),children:(0,Z.jsx)(Me,{})})}),(0,Z.jsxs)(Be,{align:`end`,className:`w-48`,children:[(0,Z.jsxs)(R,{onSelect:()=>{W(e.project.name),V(!0)},children:[(0,Z.jsx)(rt,{}),` `,C()]}),(0,Z.jsxs)(R,{onSelect:()=>$e(!0),children:[(0,Z.jsx)(ct,{}),` `,xe()]}),(0,Z.jsx)(Pe,{children:oe()}),(0,Z.jsxs)(`div`,{className:`oc-colorgrid`,children:[(0,Z.jsx)(`button`,{className:`oc-colorgrid__none`,onClick:()=>void p({projectId:e.project._id,color:null}),"aria-label":s(),children:`✕`}),tt.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 p({projectId:e.project._id,color:t.value})},t.value))]}),(0,Z.jsx)(Ie,{}),(0,Z.jsxs)(R,{variant:`destructive`,onSelect:()=>{let r=e.project.parentId;requestAnimationFrame(async()=>{let i=x?.folders??0,o=x?.chats??0;await n({title:me({name:e.project.name}),description:i>0?he({folders:i,chats:o}):o>0?a({count:o}):te(),confirmWord:A(),confirmLabel:re(),destructive:!0})&&(await ee({projectId:e.project._id}),t(r===null?{to:`/`}:{to:`/project/$projectId`,params:{projectId:r}}))})},children:[(0,Z.jsx)(Qe,{}),` `,A()]})]})]})]})]}),w===`columns`?(0,Z.jsx)(jt,{data:D,currentId:e.project._id,busyIds:M,suppressClick:$,locateChatId:ve??null}):w===`list`?(0,Z.jsx)(Ot,{data:O,busyIds:M,suppressClick:$,locateChatId:ve??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:de()}),(0,Z.jsx)(`div`,{className:`oc-projpage__cards`,children:(0,Z.jsx)(q,{items:e.children.map(e=>`folder:${e._id}`),strategy:ot,children:e.children.map(t=>(0,Z.jsx)(wt,{child:t,parentId:e.project._id,now:Nt,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:fe()}),e.chats.length>0?(0,Z.jsx)(K,{value:B,onChange:e=>Xe(e.target.value),placeholder:ue(),className:`oc-projpage__filter`}):null]}),e.chats.length===0?(0,Z.jsx)(`p`,{className:`oc-projpage__hint`,children:e.children.length===0?ge():le()}):Ft.length===0&&(Q??[]).length===0?(0,Z.jsx)(`p`,{className:`oc-projpage__hint`,children:Se({term:B.trim()})}):(0,Z.jsx)(`ul`,{className:`oc-projpage__chats`,children:(0,Z.jsx)(q,{items:Ft.map(e=>`chat:${e._id}`),strategy:Y,children:Ft.map(t=>(0,Z.jsx)(Et,{chat:t,currentFolderId:e.project._id,now:Nt,busy:M.has(t._id),unread:Te.has(t._id),locate:t._id===ve,suppressClick:$},t._id))})})]}),J.length>=2&&Q!==void 0?(0,Z.jsxs)(`section`,{className:`oc-projpage__section`,children:[(0,Z.jsx)(`h2`,{className:`oc-projpage__subtitle`,children:se()}),Q.length===0?(0,Z.jsx)(`p`,{className:`oc-projpage__hint`,children:Se({term:J})}):(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&&J&&Ve(e.messageId,J),t({to:`/chat/$chatId`,params:{chatId:e.chatId},...e.messageId?{search:{m:e.messageId}}:{}})},children:[(0,Z.jsx)(Je,{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||i()}),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)(qe,{open:Ze,onOpenChange:V,title:ne(),canSubmit:U.trim().length>0,onSubmit:async()=>{await u({projectId:e.project._id,name:U.trim()}),V(!1)},submitLabel:C(),children:(0,Z.jsx)(K,{value:U,onChange:e=>W(e.target.value),autoFocus:!0})}),G?(0,Z.jsx)(nt,{open:G,onOpenChange:$e,title:r(),movingFolderId:e.project._id,currentId:e.project.parentId,onPick:t=>void _({projectId:e.project._id,parentId:t})}):null,I]}),(0,Z.jsx)(Oe,{children:vt?(0,Z.jsxs)(`div`,{className:`oc-projpage__dragghost`,children:[vt.kind===`folder`?(0,Z.jsx)(z,{size:13,"aria-hidden":!0}):(0,Z.jsx)(Je,{size:13,"aria-hidden":!0}),(0,Z.jsx)(`span`,{children:vt.label})]}):null})]})}function Ct({folderId:e,children:t}){let{setNodeRef:n,isOver:r}=I({id:yt(e)});return(0,Z.jsx)(`span`,{ref:n,className:r?`oc-projpage__cdrop is-over`:`oc-projpage__cdrop`,children:t})}function wt({child:e,parentId:t,now:n,suppressClick:r}){let i=L(),a=B({id:`folder:${e._id}`}),o=I({id:_t(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":H(e),transform:G.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)(dt,{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?k({count:e.folderCount})+` · `:``,D({count:e.recursiveChatCount})]}),e.lastActivityAt===null?null:(0,Z.jsx)(`span`,{className:`oc-projpage__cardage`,children:Ze(e.lastActivityAt,n)})]})}function Tt({chat:e}){let t=d(j.chats.setChatSidebar),n=e.inSidebar?b():u();return(0,Z.jsx)(P,{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)(W,{}):(0,Z.jsx)(ut,{})})}function Et({chat:e,currentFolderId:t,now:n,busy:r,unread:i,locate:a,suppressClick:s}){let c=L(),l=U(e.color),u=B({id:`chat:${e._id}`}),d=Dt(a);return(0,Z.jsxs)(`li`,{ref:e=>{u.setNodeRef(e),d.current=e},className:`oc-projpage__chatrow`+(u.isDragging?` is-dragging`:``)+(a?` is-locate`:``),style:{transform:G.Transform.toString(u.transform),transition:u.transition},children:[(0,Z.jsxs)(`button`,{type:`button`,className:`oc-projpage__chatbtn`,onClick:()=>{s.current||c({to:`/chat/$chatId`,params:{chatId:e._id}})},...u.listeners,...u.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__chattitle`,children:e.title||S()}),e.pinned?(0,Z.jsx)(V,{size:12,"aria-hidden":!0,className:`oc-projpage__chatpin`}):null,(0,Z.jsx)(`span`,{className:`oc-projpage__chatage`,children:Ze(e.updatedAt,n)}),r?(0,Z.jsx)(`span`,{className:`oc-chatitem__busy`,title:o(),"aria-label":o()}):null,i&&!r?(0,Z.jsx)(`span`,{className:`oc-chatitem__unread`,title:v(),"aria-label":v()}):null]}),(0,Z.jsx)(Tt,{chat:e}),(0,Z.jsx)($,{chat:e,currentFolderId:t,className:`oc-projpage__chatmenu`})]})}function Dt(e){let t=(0,X.useRef)(null);return(0,X.useEffect)(()=>{e&&t.current&&t.current.scrollIntoView({block:`center`})},[e]),t}function Ot({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:g()});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=Ke(e.folders,a);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(q,{items:u.map(e=>`chat:${e._id}`),strategy:Y,children:u.map(e=>(0,Z.jsx)(At,{chat:e,depth:l,busy:t.has(e._id),locate:e._id===r,suppressClick:n},e._id))}),(0,Z.jsx)(q,{items:d.map(e=>`folder:${e._id}`),strategy:Y,children:d.map(t=>(0,Z.jsx)(kt,{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&&Ke(e.folders,null).length===0?(0,Z.jsx)(`p`,{className:`oc-projpage__hint`,children:ge()}):c(null,0)})}function kt({folder:e,parentId:t,depth:n,folded:r,onToggle:i,suppressClick:a,children:o}){let s=L(),c=B({id:`folder:${e._id}`}),l=I({id:_t(e._id)});return(0,Z.jsxs)(`div`,{className:`oc-projpage__treegroup`,children:[(0,Z.jsxs)(`div`,{ref:e=>{c.setNodeRef(e),l.setNodeRef(e)},className:`oc-projpage__treerow oc-projpage__treerow--folder`+(l.isOver?` is-over`:``)+(c.isDragging?` is-dragging`:``),style:{"--tree-depth":n,"--proj-hue":H(e),transform:G.Transform.toString(c.transform),transition:c.transition},...c.listeners,...c.attributes,role:`button`,tabIndex:0,onClick:()=>{a.current||s({to:`/project/$projectId`,params:{projectId:e._id}})},onKeyDown:t=>{t.key===`Enter`&&s({to:`/project/$projectId`,params:{projectId:e._id}})},children:[(0,Z.jsx)(`button`,{type:`button`,className:`oc-projpage__treechev`,"aria-label":r?M():w(),"aria-expanded":!r,onClick:e=>{e.stopPropagation(),!a.current&&i()},onMouseDown:e=>e.stopPropagation(),onTouchStart:e=>e.stopPropagation(),children:r?(0,Z.jsx)($e,{size:13}):(0,Z.jsx)(Te,{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)(dt,{folderId:e._id,name:e.name,color:e.color,currentParentId:t,className:`oc-projpage__treemenu`,onOpen:()=>void s({to:`/project/$projectId`,params:{projectId:e._id}})})]}),o]})}function At({chat:e,depth:t,busy:n,locate:r,suppressClick:i}){let a=L(),o=B({id:`chat:${e._id}`}),s=Dt(r),c=U(e.color);return(0,Z.jsxs)(`div`,{ref:e=>{o.setNodeRef(e),s.current=e},className:`oc-projpage__treerow oc-projpage__treerow--chat`+(o.isDragging?` is-dragging`:``)+(r?` is-locate`:``),style:{"--tree-depth":t,transform:G.Transform.toString(o.transform),transition:o.transition},children:[(0,Z.jsxs)(`button`,{type:`button`,className:`oc-projpage__colchatbtn`,onClick:()=>{i.current||a({to:`/chat/$chatId`,params:{chatId:e._id}})},...o.listeners,...o.attributes,children:[c?(0,Z.jsx)(`span`,{className:`oc-chatitem__dot`,style:{background:c}}):(0,Z.jsx)(`span`,{className:`oc-chatitem__dot oc-chatitem__dot--empty`}),(0,Z.jsx)(`span`,{className:`oc-projpage__colname`,children:e.title||S()}),n?(0,Z.jsx)(`span`,{className:`oc-chatitem__busy`,"aria-hidden":!0}):null]}),(0,Z.jsx)($,{chat:e,currentFolderId:e.folderId,className:`oc-projpage__treemenu`}),(0,Z.jsx)(Tt,{chat:e})]})}function jt({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:g()}):(0,Z.jsx)(`div`,{className:`oc-projpage__cols`,ref:a,children:e.columns.map((a,o)=>(0,Z.jsx)(Mt,{col:a,isLast:o===e.columns.length-1,currentId:t,busyIds:n,suppressClick:r,locateChatId:i},a.folderId??`root`))})}function Mt({col:e,isLast:t,currentId:n,busyIds:r,suppressClick:i,locateChatId:a}){let o=L(),s=I({id:vt(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)(q,{items:e.folders.map(e=>`folder:${e._id}`),strategy:Y,children:e.folders.map(t=>(0,Z.jsx)(Nt,{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)(q,{items:e.chats.map(e=>`chat:${e._id}`),strategy:Y,children:e.chats.map(t=>(0,Z.jsx)(Pt,{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:le()}):null]})}function Nt({folder:e,parentId:t,isCurrent:n,suppressClick:r,onOpen:i}){let a=B({id:`folder:${e._id}`}),o=I({id:_t(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":H(e),transform:G.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)(dt,{folderId:e._id,name:e.name,color:e.color,currentParentId:t,className:`oc-projpage__colmenu`,onOpen:i})]})}function Pt({chat:e,folderId:t,busy:n,locate:r,suppressClick:i,onOpen:a}){let o=B({id:`chat:${e._id}`}),s=Dt(r),c=U(e.color);return(0,Z.jsxs)(`div`,{ref:e=>{o.setNodeRef(e),s.current=e},className:`oc-projpage__colentry oc-projpage__colentry--chat`+(o.isDragging?` is-dragging`:``)+(r?` is-locate`:``),style:{transform:G.Transform.toString(o.transform),transition:o.transition},children:[(0,Z.jsxs)(`button`,{type:`button`,className:`oc-projpage__colchatbtn`,onClick:()=>{i.current||a()},...o.listeners,...o.attributes,children:[c?(0,Z.jsx)(`span`,{className:`oc-chatitem__dot`,style:{background:c}}):(0,Z.jsx)(`span`,{className:`oc-chatitem__dot oc-chatitem__dot--empty`}),(0,Z.jsx)(`span`,{className:`oc-projpage__colname`,children:e.title||S()}),n?(0,Z.jsx)(`span`,{className:`oc-chatitem__busy`,"aria-hidden":!0}):null]}),(0,Z.jsx)($,{chat:e,currentFolderId:t,className:`oc-projpage__colmenu oc-projpage__colmenu--chat`}),(0,Z.jsx)(Tt,{chat:e})]})}export{xt as ProjectPage};
@@ -0,0 +1,4 @@
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$i as r,$o as i,$y as a,By as o,Cr as s,GR as c,Gy as l,Hy as u,Jy as d,KR as f,Ky as p,Ly as m,Qi as h,Qo as g,Qy as _,Ry as v,Sr as y,Uy as b,Vy as x,Wy as S,Xy as C,Yy as w,Zi as T,Zo as ee,Zy as te,ca as ne,da as re,ea as ie,eb as ae,es as oe,la as se,lb as E,nb as D,qy as O,t as k,ta as A,tb as j,ts as M,ua as N,ub as P,xr as F,zy as I}from"./api-BASu8PYC.js";import{d as L,f as R,i as z,l as B,n as V,r as ce,t as H,u as U}from"./FieldLabel-YPTLow_x.js";import{t as W}from"./button-_UzA03A_.js";import{$ as G,Dt as le,Q as K,X as q,Z as J,et as Y,q as ue,ut as de}from"./index-D02RwoOe.js";import{r as X,t as fe}from"./locales-CPjguROj.js";import{t as pe}from"./localePickerView-C2RmOS86.js";/* empty css */var Z=t(e(),1),Q=n(),$={media_delivery:{label:te,help:C},documentary_fetch:{label:w,help:d},inbound_files:{label:O,help:p},history_summary:{label:M,help:oe},file_curation:{label:re,help:A},quote_reply:{label:N,help:se}},me={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.`},he={outboundDir:I,references:v,files:m,previous_summary:i,new_messages:g,max_chars:ee,file_name:ie,budget_chars:r,feedback:h,content:T,excerpt:ne};function ge(){let e=f(k.admin.listInstances,{}),[t,n]=(0,Z.useState)(null);if(e===void 0)return(0,Q.jsx)(`div`,{className:`oc-settings__tab-loading`,"aria-busy":`true`});if(e.length===0)return(0,Q.jsx)(`div`,{className:`oc-injtab`,children:(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:S()})});let r=e.find(e=>e._id===t)??e[0];return(0,Q.jsxs)(`div`,{className:`oc-injtab`,children:[(0,Q.jsxs)(`div`,{className:`oc-injtab__head`,children:[(0,Q.jsx)(V,{label:D(),help:j()}),(0,Q.jsxs)(`label`,{className:`oc-injtab__picker`,children:[(0,Q.jsx)(`span`,{children:l()}),(0,Q.jsxs)(q,{value:r._id,onValueChange:e=>n(e),children:[(0,Q.jsx)(G,{size:`sm`,className:`min-w-44`,children:(0,Q.jsx)(Y,{})}),(0,Q.jsx)(J,{children:e.map(e=>(0,Q.jsx)(K,{value:e._id,children:e.displayName??e.name},e._id))})]})]})]}),(0,Q.jsx)(_e,{instance:r},r._id)]})}function _e({instance:e}){let t=c(k.admin.upsertInstanceConfig),n=le(),r=f(k.me.getMe,{host:ue}),i=e.config??{},a=X(e.config?.contentLocale,r?.defaultLocale??void 0),[o,l]=(0,Z.useState)(()=>z(i,a));(0,Z.useEffect)(()=>{l(z(i,a))},[a,e._id]);let[u,d]=(0,Z.useState)(!1),p=o.promptInjections,m=(e,t)=>l({...o,promptInjections:{...p,[e]:{...p[e],...t}}});async function h(){d(!0);try{await t({instanceId:e._id,config:ce(o,i,a)})}catch(e){n.error(E(),e)}finally{d(!1)}}async function g(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(E(),e)}}let _=e.config?.contentLocale??`default`,v=fe[X(void 0,r?.defaultLocale??void 0)];return(0,Q.jsxs)(`div`,{className:`oc-injtab__body`,children:[(0,Q.jsxs)(`div`,{className:`oc-injtab__content-locale`,children:[(0,Q.jsx)(`span`,{children:s()}),(0,Q.jsxs)(q,{value:_,onValueChange:e=>void g(e),children:[(0,Q.jsx)(G,{size:`sm`,className:`min-w-44`,children:(0,Q.jsx)(Y,{})}),(0,Q.jsxs)(J,{children:[(0,Q.jsx)(K,{value:`default`,children:F({locale:v})}),pe().map(e=>(0,Q.jsx)(K,{value:e.value,children:e.label},e.value))]})]}),(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:y()})]}),U.map(e=>(0,Q.jsx)(ve,{injKey:e,def:B[e],i18n:$[e],row:p[e]??{enabled:!0,template:B[e].defaultTemplate[a]},contentLocale:a,onChange:t=>m(e,t)},e)),(0,Q.jsx)(`div`,{className:`oc-injtab__actions`,children:(0,Q.jsx)(W,{size:`sm`,onClick:()=>void h(),disabled:u,children:P()})})]})}function ve({injKey:e,def:t,i18n:n,row:r,contentLocale:i,onChange:s}){let[c,l]=(0,Z.useState)(!1),d=r.template.trim()!==t.defaultTemplate[i],f=t.togglable&&!r.enabled,p=Object.fromEntries(t.placeholders.map(e=>[e,me[e]??`{${e}}`])),m=L(e,r,i),h=m?R(m,p):``;return(0,Q.jsxs)(`section`,{className:`oc-injcard`,children:[(0,Q.jsxs)(`div`,{className:`oc-injcard__head`,children:[t.togglable?(0,Q.jsxs)(`label`,{className:`oc-field--row`,children:[(0,Q.jsx)(de,{checked:r.enabled,onCheckedChange:e=>s({enabled:e===!0})}),(0,Q.jsx)(V,{label:n.label(),help:n.help()})]}):(0,Q.jsx)(V,{label:n.label(),help:n.help()}),d&&(0,Q.jsx)(`span`,{className:`oc-injection__badge`,children:a()})]}),(0,Q.jsx)(`textarea`,{className:`oc-injcard__text`,value:r.template,disabled:f,rows:8,spellCheck:!1,onChange:e=>s({template:e.target.value})}),(0,Q.jsxs)(`div`,{className:`oc-injection__foot`,children:[(0,Q.jsxs)(`div`,{className:`oc-injcard__phs`,children:[(0,Q.jsx)(`span`,{className:`oc-injection__ph`,children:_()}),t.placeholders.map(e=>(0,Q.jsxs)(`span`,{className:`oc-injcard__ph-chip`,children:[(0,Q.jsx)(`code`,{children:`{${e}}`}),(0,Q.jsx)(H,{text:(he[e]??(()=>e))()})]},e))]}),(0,Q.jsxs)(`div`,{className:`oc-injcard__btns`,children:[(0,Q.jsx)(W,{variant:`ghost`,size:`sm`,onClick:()=>l(e=>!e),children:c?u():b()}),d&&(0,Q.jsx)(W,{variant:`ghost`,size:`sm`,onClick:()=>s({template:t.defaultTemplate[i]}),children:ae()})]})]}),c&&(0,Q.jsx)(`div`,{className:`oc-injcard__preview`,children:h?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`pre`,{className:`oc-injcard__previewtext`,children:h}),(0,Q.jsx)(`span`,{className:`oc-injection__ph`,children:x()})]}):(0,Q.jsx)(`span`,{className:`oc-injection__ph`,children:o()})})]})}export{ge as PromptInjectionsTab};
@@ -0,0 +1 @@
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$C as r,AC as i,BC as ee,DC as a,EC as te,FC as ne,Fa as o,GC as s,GR as c,HC as re,IC as l,JC as u,KC as d,KR as f,LC as p,MC as m,NC as h,OC as g,PC as _,QC as v,RC as y,UC as b,VC as ie,WC as x,XC as S,YC as C,ZC as w,_C as T,bC as E,ew as D,fC as O,gC as k,hC as A,jC as j,kC as M,mC as N,pC as P,qC as F,t as I,tw as L,vC as R,yC as ae,zC as z}from"./api-BASu8PYC.js";import{t as B}from"./button-_UzA03A_.js";import{Dt as V,Et as H,U,_ as W,jt as G,ut as K,yn as q}from"./index-D02RwoOe.js";import{t as J}from"./roleDescriptions-s4fc4FW8.js";var Y=t(e(),1),X=n(),Z=[{group:()=>L(),keys:[{key:`traces.read`,label:()=>S()},{key:`traces.read.content`,label:()=>C(),phi:!0},{key:`traces.write`,label:()=>u()}]},{group:()=>D(),keys:[{key:`kpi.read`,label:()=>S()},{key:`kpi.write`,label:()=>u()}]},{group:()=>r(),keys:[{key:`openclaw.query`,label:()=>F()},{key:`anomalies.read`,label:()=>d()},{key:`anomalies.report`,label:()=>s()}]},{group:()=>v(),keys:[{key:`chats.read`,label:()=>S()},{key:`selfheal`,label:()=>b()},{key:`feedback.respond`,label:()=>o()}]},{group:()=>w(),keys:[{key:`admin.manage`,label:()=>x()}]}],oe=Z.flatMap(e=>e.keys.map(e=>e.key));function Q(e){return e.includes(`*`)}var $={key:``,name:``,description:``};function se(){let e=f(I.apiKeys.listRoles,{}),t=c(I.apiKeys.createRole),n=c(I.apiKeys.ensureRolesSeeded),r=c(I.apiKeys.updateRolePermissions).withOptimisticUpdate((e,{roleId:t,permissions:n})=>{let r=e.getQuery(I.apiKeys.listRoles,{});r&&e.setQuery(I.apiKeys.listRoles,{},r.map(e=>e._id===t?{...e,permissions:n}:e))}),o=U(),s=V(),[u,d]=(0,Y.useState)(!1),[v,b]=(0,Y.useState)($),[x,S]=(0,Y.useState)(new Set);(0,Y.useEffect)(()=>{n({}).catch(e=>{s.error(ie(),e)})},[n,s]);let C=e??[];async function w(e,t){if(Q(e.permissions))return;if(e.builtin){await o({title:ee({name:e.name}),description:z(),confirmLabel:y()});return}if(x.has(e._id))return;let n=e.permissions.includes(t)?e.permissions.filter(e=>e!==t):[...e.permissions,t];S(t=>new Set(t).add(e._id));try{await r({roleId:e._id,permissions:n})}catch(e){s.error(p(),e)}finally{S(t=>{let n=new Set(t);return n.delete(e._id),n})}}async function D(){try{await t({key:v.key,name:v.name,description:v.description||void 0,permissions:[]}),b($),d(!1)}catch(e){s.error(l(),e)}}let F=e===void 0,L=!F&&C.length===0;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`p`,{className:`oc-admin__hint`,children:[ne(),` `,(0,X.jsx)(`code`,{children:`admin`}),` `,_(),` `,(0,X.jsx)(`code`,{children:`traces.read.content`}),` `,h()]}),(0,X.jsxs)(`div`,{className:`oc-dt`,children:[(0,X.jsxs)(`div`,{className:`oc-dt__bar`,children:[(0,X.jsx)(`h2`,{className:`oc-dt__title`,children:m()}),(0,X.jsx)(`div`,{className:`oc-dt__bar-actions`,children:(0,X.jsx)(B,{size:`sm`,onClick:()=>{b($),d(!0)},children:j()})})]}),F?(0,X.jsx)(`p`,{className:`oc-admin__hint`,children:i()}):L?(0,X.jsx)(`p`,{className:`oc-admin__hint`,children:M()}):(0,X.jsx)(`div`,{className:`oc-matrix__scroll`,children:(0,X.jsxs)(`table`,{className:`oc-matrix`,children:[(0,X.jsxs)(`thead`,{children:[(0,X.jsxs)(`tr`,{children:[(0,X.jsx)(`th`,{className:`oc-matrix__corner`,rowSpan:2,children:g()}),Z.map(e=>(0,X.jsx)(`th`,{className:`oc-matrix__group`,colSpan:e.keys.length,children:e.group()},e.group()))]}),(0,X.jsx)(`tr`,{children:Z.flatMap(e=>e.keys.map(e=>(0,X.jsxs)(`th`,{className:`oc-matrix__perm`,title:e.phi?re({key:e.key}):e.key,children:[e.label(),e.phi?(0,X.jsx)(`span`,{className:`oc-matrix__phi`,children:` ⚠`}):null]},e.key)))})]}),(0,X.jsx)(`tbody`,{children:C.map(e=>{let t=Q(e.permissions),n=x.has(e._id);return(0,X.jsxs)(`tr`,{children:[(0,X.jsxs)(`th`,{className:`oc-matrix__rolecell`,children:[(0,X.jsxs)(`div`,{className:`oc-matrix__rolename`,children:[(0,X.jsx)(`span`,{children:e.name}),(0,X.jsx)(`code`,{className:`oc-matrix__rolekey`,children:e.key}),e.builtin?(0,X.jsxs)(H,{variant:`outline`,className:`gap-1`,children:[(0,X.jsx)(q,{}),` `,a()]}):(0,X.jsx)(H,{variant:`secondary`,children:te()})]}),J(e)?(0,X.jsx)(`p`,{className:`oc-matrix__roledesc`,children:J(e)}):null]}),oe.map(r=>(0,X.jsx)(`td`,{className:`oc-matrix__cell`,children:(0,X.jsx)(K,{checked:t||e.permissions.includes(r),disabled:t||n,"aria-label":`${e.key} · ${r}`,title:t?E():n?ae():r,onCheckedChange:()=>void w(e,r)})},r))]},e.key)})})]})})]}),(0,X.jsx)(W,{open:u,onOpenChange:d,title:R(),description:T(),canSubmit:!!(v.key&&v.name),onSubmit:D,submitLabel:k(),children:(0,X.jsxs)(`div`,{className:`oc-form`,children:[(0,X.jsxs)(`label`,{className:`oc-field`,children:[(0,X.jsx)(`span`,{className:`oc-field__label`,children:A()}),(0,X.jsx)(G,{value:v.key,placeholder:N(),onChange:e=>b({...v,key:e.target.value})})]}),(0,X.jsxs)(`label`,{className:`oc-field`,children:[(0,X.jsx)(`span`,{className:`oc-field__label`,children:P()}),(0,X.jsx)(G,{value:v.name,onChange:e=>b({...v,name:e.target.value})})]}),(0,X.jsxs)(`label`,{className:`oc-field`,children:[(0,X.jsx)(`span`,{className:`oc-field__label`,children:O()}),(0,X.jsx)(G,{value:v.description,onChange:e=>b({...v,description:e.target.value})})]})]})})]})}export{se as RolesTab};
@@ -0,0 +1 @@
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$F as r,AF as i,AI as a,BI as o,CF as s,CI as c,D as l,DF as u,EF as ee,FF as d,FI as f,HI as p,IF as m,II as h,JF as te,KR as ne,LF as re,LR as ie,MF as ae,MI as oe,NF as se,NI as ce,OF as le,OI as ue,PF as de,PI as fe,QF as pe,RF as me,RI as he,SF as ge,SI as _e,TF as ve,TI as ye,UI as be,UR as g,VI as xe,XF as _,YF as Se,ZF as v,_I as Ce,_L as we,aI as Te,bI as Ee,bL as De,cI as Oe,cL as ke,dL as Ae,eI as je,fL as Me,gI as Ne,gL as Pe,hF as Fe,hI as Ie,hL as Le,iI as y,jF as Re,jI as ze,kF as Be,kI as Ve,lI as He,lL as Ue,mI as We,mL as Ge,nI as Ke,oI as b,pL as qe,rI as Je,sI as Ye,sL as Xe,t as x,tI as Ze,uL as Qe,vI as $e,vL as et,wF as tt,xF as nt,xI as rt,xL as it,yI as at,yL as ot,zI as st,zR as S}from"./api-BASu8PYC.js";import{t as ct}from"./list-Cfz6xpiH.js";import{t as C}from"./button-_UzA03A_.js";import{$ as w,Bt as T,Ct as lt,Dt as ut,Et as E,Mn as D,Q as O,Rt as k,St as dt,Tt as ft,X as A,Z as j,_t as pt,at as mt,bn as ht,bt as gt,cn as _t,et as M,gt as vt,in as yt,it as bt,jn as N,jt as xt,mn as St,nt as Ct,ot as wt,pn as Tt,q as Et,rt as Dt,tn as Ot,tt as kt,un as At,vt as jt,wt as Mt,xt as Nt,yt as Pt,zt as P}from"./index-D02RwoOe.js";import{a as Ft,i as F,n as It,o as Lt,r as I,t as Rt}from"./table-ChZTpaGw.js";import{t as zt}from"./FilterBar-BQxNZSAj.js";/* empty css */import{a as L,c as Bt,i as Vt,l as Ht,n as Ut,o as Wt,r as Gt,s as R,t as Kt}from"./TimezoneCombobox-673xwoei.js";var qt=l(`calendar-days`,[[`path`,{d:`M8 2v4`,key:`1cmpym`}],[`path`,{d:`M16 2v4`,key:`4m81vk`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`4`,rx:`2`,key:`1hopcy`}],[`path`,{d:`M3 10h18`,key:`8toen8`}],[`path`,{d:`M8 14h.01`,key:`6423bh`}],[`path`,{d:`M12 14h.01`,key:`1etili`}],[`path`,{d:`M16 14h.01`,key:`1gbofw`}],[`path`,{d:`M8 18h.01`,key:`lrp35t`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}],[`path`,{d:`M16 18h.01`,key:`kzsmim`}]]),Jt=l(`history`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M12 7v5l4 2`,key:`1fdv2h`}]]),z=t(e(),1),B=n();function V(e){try{let t=new Intl.DateTimeFormat(e,{weekday:`narrow`});return Array.from({length:7},(e,n)=>t.format(new Date(2024,0,1+n)))}catch{return[`M`,`T`,`W`,`T`,`F`,`S`,`S`]}}function Yt({value:e,onChange:t}){let n=Bt(e),r=(0,z.useMemo)(()=>new Date,[]),[i,a]=(0,z.useState)(()=>({year:n?.year??r.getFullYear(),month:n?.month??r.getMonth()})),[o,s]=(0,z.useState)(!1),c=(0,z.useMemo)(()=>V(S()),[]),l=(0,z.useMemo)(()=>new Intl.DateTimeFormat(S(),{month:`long`,year:`numeric`}),[]),u=(0,z.useMemo)(()=>new Intl.DateTimeFormat(S(),{dateStyle:`medium`,timeStyle:`short`}),[]),ee=R(i.year,i.month),d=n?.hour??9,f=n?.minute??0,p=(e,n,r,i,a)=>t(Ht(e,n,r,i,a)),m=(e,t,n)=>{a({year:e,month:t}),p(e,t,n,d,f)},h=e=>{let t=new Date(i.year,i.month+e,1);a({year:t.getFullYear(),month:t.getMonth()})},te=n===null?Oe():u.format(new Date(n.year,n.month,n.day,n.hour,n.minute));return(0,B.jsxs)(k,{modal:!0,open:o,onOpenChange:s,children:[(0,B.jsx)(T,{asChild:!0,children:(0,B.jsxs)(`button`,{type:`button`,className:`oc-dtp__trigger`,"aria-label":He(),children:[(0,B.jsx)(qt,{size:14,"aria-hidden":!0,className:`oc-dtp__icon`}),(0,B.jsx)(`span`,{className:n===null?`oc-dtp__placeholder`:void 0,children:te})]})}),(0,B.jsxs)(P,{align:`start`,className:`oc-dtp__pop`,children:[(0,B.jsxs)(`div`,{className:`oc-dtp__head`,children:[(0,B.jsx)(`button`,{type:`button`,className:`oc-dtp__nav`,"aria-label":Ye(),onClick:()=>h(-1),children:(0,B.jsx)(D,{size:15,"aria-hidden":!0})}),(0,B.jsx)(`span`,{className:`oc-dtp__month`,children:l.format(new Date(i.year,i.month,1))}),(0,B.jsx)(`button`,{type:`button`,className:`oc-dtp__nav`,"aria-label":b(),onClick:()=>h(1),children:(0,B.jsx)(N,{size:15,"aria-hidden":!0})})]}),(0,B.jsxs)(`div`,{className:`oc-dtp__grid`,children:[c.map((e,t)=>(0,B.jsx)(`span`,{className:`oc-dtp__wd`,children:e},t)),ee.map((e,t)=>{let i=n!==null&&n.year===e.year&&n.month===e.month&&n.day===e.day,a=r.getFullYear()===e.year&&r.getMonth()===e.month&&r.getDate()===e.day;return(0,B.jsx)(`button`,{type:`button`,className:`oc-dtp__day`+(e.inMonth?``:` oc-dtp__day--out`)+(i?` oc-dtp__day--sel`:``)+(a&&!i?` oc-dtp__day--today`:``),onClick:()=>m(e.year,e.month,e.day),children:e.day},t)})]}),(0,B.jsxs)(`div`,{className:`oc-dtp__time`,children:[(0,B.jsxs)(A,{value:String(d),onValueChange:e=>p(i.year,i.month,n?.day??r.getDate(),Number(e),f),children:[(0,B.jsx)(w,{size:`sm`,"aria-label":Te(),children:(0,B.jsx)(M,{})}),(0,B.jsx)(j,{className:`oc-dtp__timeopts`,children:Array.from({length:24},(e,t)=>(0,B.jsx)(O,{value:String(t),children:String(t).padStart(2,`0`)},t))})]}),(0,B.jsx)(`span`,{className:`oc-dtp__colon`,children:`:`}),(0,B.jsxs)(A,{value:String(f),onValueChange:e=>p(i.year,i.month,n?.day??r.getDate(),d,Number(e)),children:[(0,B.jsx)(w,{size:`sm`,"aria-label":y(),children:(0,B.jsx)(M,{})}),(0,B.jsx)(j,{className:`oc-dtp__timeopts`,children:Array.from({length:60},(e,t)=>(0,B.jsx)(O,{value:String(t),children:String(t).padStart(2,`0`)},t))})]})]})]})]})}function H(e){let t=new Date(e),n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())}`}function Xt(e,t,n){let r=e=>String(e).padStart(2,`0`);return`${e}-${r(t+1)}-${r(n)}`}function Zt(e){let t=new Map;for(let n of e){let e=H(n.atMs),r=t.get(e);r===void 0?t.set(e,[n]):r.push(n)}for(let e of t.values())e.sort((e,t)=>e.atMs-t.atMs);return t}function U(e,t,n){let r=new Map,i=new Date(t,n+1,0).getDate();for(let a=1;a<=i;a++){let i=e.get(Xt(t,n,a));i!==void 0&&i.length>0&&r.set(a,i.length)}return r}function Qt(e){try{let t=new Intl.DateTimeFormat(e,{weekday:`narrow`});return Array.from({length:7},(e,n)=>t.format(new Date(2024,0,1+n)))}catch{return[`M`,`T`,`W`,`T`,`F`,`S`,`S`]}}function $t(e,t){let n=(new Date(e,t,1).getDay()+6)%7,r=new Date(e,t,1-n),i=new Date(r.getFullYear(),r.getMonth(),r.getDate()+42);return{startMs:r.getTime(),endMs:i.getTime()}}function en(e){return{startMs:new Date(e,0,1).getTime(),endMs:new Date(e+1,0,1).getTime()}}var W=3;function tn({events:e,mode:t,cursor:n,onModeChange:i,onCursorChange:a,onEventClick:o,footnote:s}){let c=S(),l=(0,z.useMemo)(()=>Zt(e),[e]),u=(0,z.useMemo)(()=>Qt(c),[c]),ee=(0,z.useMemo)(()=>new Intl.DateTimeFormat(c,{month:`long`,year:`numeric`}),[c]),d=(0,z.useMemo)(()=>new Intl.DateTimeFormat(c,{month:`long`}),[c]),f=(0,z.useMemo)(()=>new Intl.DateTimeFormat(c,{hour:`2-digit`,minute:`2-digit`}),[c]),p=new Date,m=e=>{if(t===`year`){a({year:n.year+e,month:n.month});return}let r=new Date(n.year,n.month+e,1);a({year:r.getFullYear(),month:r.getMonth()})},h=t===`year`?String(n.year):ee.format(new Date(n.year,n.month,1));return(0,B.jsxs)(`div`,{className:`oc-cal`,children:[(0,B.jsxs)(`div`,{className:`oc-cal__head`,children:[(0,B.jsxs)(`div`,{className:`oc-cal__nav`,children:[(0,B.jsx)(C,{variant:`ghost`,size:`icon-sm`,"aria-label":v(),onClick:()=>m(-1),children:(0,B.jsx)(D,{})}),(0,B.jsx)(C,{variant:`ghost`,size:`icon-sm`,"aria-label":_(),onClick:()=>m(1),children:(0,B.jsx)(N,{})}),(0,B.jsx)(C,{variant:`ghost`,size:`sm`,onClick:()=>a({year:p.getFullYear(),month:p.getMonth()}),children:pe()})]}),(0,B.jsx)(`span`,{className:`oc-cal__title`,children:h}),(0,B.jsxs)(`div`,{className:`oc-cal__modes`,role:`group`,children:[(0,B.jsx)(C,{variant:t===`month`?`secondary`:`ghost`,size:`sm`,"aria-pressed":t===`month`,onClick:()=>i(`month`),children:je()}),(0,B.jsx)(C,{variant:t===`year`?`secondary`:`ghost`,size:`sm`,"aria-pressed":t===`year`,onClick:()=>i(`year`),children:r()})]})]}),t===`month`?(0,B.jsx)(nn,{cursor:n,byDay:l,weekdays:u,timeFmt:f,now:p,onEventClick:o}):(0,B.jsx)(rn,{year:n.year,byDay:l,monthShortFmt:d,now:p,onOpenMonth:e=>{a({year:n.year,month:e}),i(`month`)}}),s?(0,B.jsx)(`p`,{className:`oc-cal__footnote`,children:s}):null]})}function nn({cursor:e,byDay:t,weekdays:n,timeFmt:r,now:i,onEventClick:a}){let o=R(e.year,e.month);return(0,B.jsxs)(`div`,{className:`oc-cal__month`,children:[n.map((e,t)=>(0,B.jsx)(`span`,{className:`oc-cal__wd`,children:e},t)),o.map((e,n)=>{let o=t.get(Xt(e.year,e.month,e.day))??[],s=i.getFullYear()===e.year&&i.getMonth()===e.month&&i.getDate()===e.day;return(0,B.jsxs)(`div`,{className:`oc-cal__day`+(e.inMonth?``:` oc-cal__day--out`)+(s?` oc-cal__day--today`:``),children:[(0,B.jsx)(`span`,{className:`oc-cal__daynum`,children:e.day}),o.slice(0,W).map(e=>(0,B.jsxs)(`button`,{type:`button`,className:`oc-cal__event`+(e.muted?` oc-cal__event--muted`:``)+(e.exact?` oc-cal__event--exact`:``),style:e.color?{"--cal-ev":e.color}:void 0,title:`${r.format(e.atMs)} ${e.title}`,onClick:a?()=>a(e):void 0,children:[(0,B.jsx)(`span`,{className:`oc-cal__evdot`,"aria-hidden":!0}),(0,B.jsx)(`span`,{className:`oc-cal__evtime`,children:r.format(e.atMs)}),(0,B.jsx)(`span`,{className:`oc-cal__evtitle`,children:e.title})]},e.id)),o.length>W?(0,B.jsx)(`span`,{className:`oc-cal__more`,children:Se({count:o.length-W})}):null]},n)})]})}function rn({year:e,byDay:t,monthShortFmt:n,now:r,onOpenMonth:i}){return(0,B.jsx)(`div`,{className:`oc-cal__year`,children:Array.from({length:12},(a,o)=>{let s=U(t,e,o),c=R(e,o);return(0,B.jsxs)(`button`,{type:`button`,className:`oc-cal__mini`,onClick:()=>i(o),children:[(0,B.jsx)(`span`,{className:`oc-cal__mininame`,children:n.format(new Date(e,o,1))}),(0,B.jsx)(`span`,{className:`oc-cal__minigrid`,"aria-hidden":!0,children:c.map((e,t)=>{let n=e.inMonth?s.get(e.day)??0:0,i=e.inMonth&&r.getFullYear()===e.year&&r.getMonth()===e.month&&r.getDate()===e.day;return(0,B.jsx)(`span`,{className:`oc-cal__minidot`+(e.inMonth?``:` is-out`)+(n===1?` has-one`:``)+(n>1?` has-many`:``)+(i?` is-today`:``)},t)})})]},o)})})}var G={h:36e5,min:6e4,s:1e3,ms:1};function an(e){if(e===null)return null;let t=e.trim(),n=/^every\s+(\d+(?:\.\d+)?)(h|min|s|ms)$/.exec(t);if(n!==null){let e=Number(n[1])*G[n[2]];return Number.isFinite(e)&&e>0?{kind:`every`,everyMs:e}:null}let r=/^(?:cron\s+)?([\d*,/-]+(?:\s+[\d*,/-]+){4})(?:\s*\(([^)]+)\))?$/.exec(t);if(r!==null)return{kind:`cron`,expr:r[1],tz:r[2]??null};let i=Date.parse(t);return Number.isFinite(i)?{kind:`at`,atMs:i}:null}function K(e,t,n){let r=new Set;for(let i of e.split(`,`)){let e=i,a=1,o=/^(.+)\/(\d{1,3})$/.exec(i);if(o!==null&&(e=o[1],a=Number(o[2]),a<1))return null;let s,c;if(e===`*`)s=t,c=n;else{let r=/^(\d{1,3})(?:-(\d{1,3}))?$/.exec(e);if(r===null||(s=Number(r[1]),c=r[2]===void 0?s:Number(r[2]),r[2]===void 0&&o!==null&&(c=n),s<t||c>n||s>c))return null}for(let e=s;e<=c;e+=a)r.add(e)}return r.size>0?[...r].sort((e,t)=>e-t):null}function q(e){let t=e.trim().split(/\s+/);if(t.length!==5)return null;let n=K(t[0],0,59),r=K(t[1],0,23),i=K(t[2],1,31),a=K(t[3],1,12),o=K(t[4],0,7);if(!n||!r||!i||!a||!o)return null;let s=new Set(o.map(e=>e%7));return{minutes:n,hours:r,dom:new Set(i),months:new Set(a),dow:s,domRestricted:t[2]!==`*`,dowRestricted:t[4]!==`*`}}var J=new Map;function Y(e){let t=J.get(e);if(t!==void 0)return t;let n=null;try{n=new Intl.DateTimeFormat(`en-US`,{timeZone:e,year:`numeric`,month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hour12:!1})}catch{n=null}return J.set(e,n),n}function on(e,t){if(t!==null){let n=Y(t);if(n!==null){let t={};for(let r of n.formatToParts(e))r.type!==`literal`&&(t[r.type]=Number(r.value));return{y:t.year,mo:t.month-1,d:t.day,h:t.hour===24?0:t.hour,mi:t.minute}}}let n=new Date(e);return{y:n.getFullYear(),mo:n.getMonth(),d:n.getDate(),h:n.getHours(),mi:n.getMinutes()}}function X(e,t,n,r,i,a){if(a===null||Y(a)===null)return new Date(e,t,n,r,i).getTime();let o=Date.UTC(e,t,n,r,i),s=e=>{let t=on(e,a);return Date.UTC(t.y,t.mo,t.d,t.h,t.mi)-e},c=s(o),l=o-c,u=s(l);return u!==c&&(l=o-u),l}function Z(e,t,n,r){let i=new Map,a=(e,t)=>{e<n||e>=r||i.set(e,t||(i.get(e)??!1))};if(e?.kind===`at`)a(e.atMs,!0);else if(e?.kind===`every`){if(t!==null){let i=e.everyMs,o=Math.ceil((n-t)/i);for(let e=t+o*i,n=0;e<r&&n<400;e+=i,n++)a(e,e===t)}}else if(e?.kind===`cron`){let t=q(e.expr);if(t!==null&&t.hours.length*t.minutes.length<=400){let i=0,o=n-864e5;for(;o<r+864e5&&i<400;){let s=on(o,e.tz);if(t.months.has(s.mo+1)){let o=new Date(Date.UTC(s.y,s.mo,s.d)).getUTCDay(),c=t.dom.has(s.d),l=t.dow.has(o);if(t.domRestricted&&t.dowRestricted?c||l:c&&l)for(let o of t.hours)for(let c of t.minutes){if(i>=400)break;let t=X(s.y,s.mo,s.d,o,c,e.tz);t>=n&&t<r&&(a(t,!1),i++)}}o=X(s.y,s.mo,s.d,12,0,e.tz)+864e5}}}return t!==null&&a(t,!0),[...i.entries()].map(([e,t])=>({atMs:e,exact:t})).sort((e,t)=>e.atMs-t.atMs).slice(0,400)}var Q=`crons`;function sn(e,t){return`${e}\u0000${t}`}function cn(e,t,n){let r=[],i=new Map;for(let a of e){let{job:e}=a;if(e.id===null)continue;let o=sn(a.instanceName,e.id);i.set(o,a);let s=Z(e.enabled===!1?null:an(e.schedule),e.nextRunAtMs,t,n);for(let t of s)r.push({id:`${o}:${t.atMs}`,sourceId:Q,itemId:o,atMs:t.atMs,title:e.name??e.id,muted:e.enabled===!1,exact:t.exact})}return{events:r,byItemId:i}}var $={minutes:6e4,hours:36e5,days:864e5};function ln(e){return e?.data?.code??`unknown`}function un({status:e}){switch(L(e)){case`ok`:return(0,B.jsx)(E,{variant:`secondary`,children:_e()});case`error`:return(0,B.jsx)(E,{variant:`destructive`,children:Ee()});case`running`:return(0,B.jsx)(E,{variant:`outline`,children:at()});case`other`:return(0,B.jsx)(E,{variant:`outline`,children:e});case`none`:return(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:`—`})}}function dn(){let e=g(x.scheduled.listMyCrons),t=g(x.scheduled.getCronDetail),n=g(x.scheduled.listCronRuns),r=g(x.scheduled.updateCron),l=g(x.scheduled.removeCron),pe=g(x.scheduled.runCronNow),_=ut(),Se=ne(x.me.getMe,{host:Et})?.timezone,[v,Te]=(0,z.useState)(null),[Oe,je]=(0,z.useState)(!1),[y,He]=(0,z.useState)(!1),[b,Ye]=(0,z.useState)(null),[T,D]=(0,z.useState)(null),[k,N]=(0,z.useState)(null),[P,L]=(0,z.useState)(null),[Bt,Ht]=(0,z.useState)(!1),[R,V]=(0,z.useState)(Ut),[H,Xt]=(0,z.useState)(()=>new URLSearchParams(window.location.search).get(`job`)===null&&localStorage.getItem(`oc.sched.view`)===`calendar`?`calendar`:`list`),Zt=e=>{localStorage.setItem(`oc.sched.view`,e),Xt(e)},[U,Qt]=(0,z.useState)(`month`),[W,nn]=(0,z.useState)(()=>{let e=new Date;return{year:e.getFullYear(),month:e.getMonth()}}),rn=(0,z.useMemo)(()=>{let e=[];for(let t of v??[]){if(!t.supported||t.error!==null)continue;let n=t.kind===`openclaw`&&t.manageSupported;for(let r of t.jobs)Vt(r,R)&&e.push({instanceName:t.instanceName,canEdit:n,job:r})}return e},[v,R]),G=(0,z.useMemo)(()=>U===`year`?en(W.year):$t(W.year,W.month),[U,W]),an=(0,z.useMemo)(()=>cn(rn,G.startMs,G.endMs),[rn,G]),K=e=>{let t=an.byItemId.get(e.itemId);t===void 0||!t.canEdit||t.job.id===null||dn(t.instanceName,t.job)},q=(0,z.useCallback)(async()=>{je(!0),He(!1);try{Te(await e({}))}catch{He(!0)}finally{je(!1)}},[e]);(0,z.useEffect)(()=>{q()},[q]);let J=(0,z.useMemo)(()=>new URLSearchParams(window.location.search).get(`job`),[]),Y=(0,z.useRef)(null);(0,z.useEffect)(()=>{v!==null&&Y.current!==null&&Y.current.scrollIntoView({block:`center`})},[v]);let on=(0,z.useMemo)(()=>new Intl.DateTimeFormat(S(),{dateStyle:`medium`,timeStyle:`short`}),[]),X=async(e,t,n)=>{Ye(e);try{await t(),_.success(n),await q()}catch(e){_.toast({variant:`error`,title:h({code:ln(e)})})}finally{Ye(null)}},Z=(0,z.useRef)(0),Q=(0,z.useRef)(0),sn=async(e,t)=>{if(t.id===null)return;let r=++Z.current;N({name:t.name??t.id,entries:null});try{let i=await n({instanceName:e,jobId:t.id,limit:20});if(r!==Z.current)return;N({name:t.name??t.id,entries:i})}catch(e){if(r!==Z.current)return;N(null),_.toast({variant:`error`,title:h({code:ln(e)})})}},dn=async(e,n)=>{if(n.id===null)return;let r=++Q.current;L({instanceName:e,jobId:n.id,loading:!0,name:n.name??``,scheduleKind:`cron`,cronExpr:``,tz:``,everyValue:`1`,everyUnit:`hours`,at:``,message:``,hasMessage:!1,scheduleDirty:!1,messageDirty:!1,nameDirty:!1});try{let i=(await t({instanceName:e,jobId:n.id})).job,a=i.scheduleKind===`every`||i.scheduleKind===`at`?i.scheduleKind:`cron`,o=``;if(a===`at`&&i.scheduleExpr!==null){let e=Date.parse(i.scheduleExpr);Number.isFinite(e)&&(o=new Date(e-new Date(e).getTimezoneOffset()*6e4).toISOString().slice(0,16))}let s=`1`,c=`hours`;if(a===`every`&&i.scheduleExpr!==null){let e=Number(i.scheduleExpr);Number.isFinite(e)&&e>0&&(e%$.days===0?(s=String(e/$.days),c=`days`):e%$.hours===0?(s=String(e/$.hours),c=`hours`):(s=String(Math.max(1,Math.round(e/$.minutes))),c=`minutes`))}if(r!==Q.current)return;L(e=>e===null||e.jobId!==n.id?e:{...e,loading:!1,name:i.name??e.name,scheduleKind:a,cronExpr:a===`cron`?i.scheduleExpr??``:``,tz:i.tz??``,everyValue:s,everyUnit:c,at:o,message:i.message??``,hasMessage:i.message!==null&&!i.messageTruncated})}catch(e){if(r!==Q.current)return;L(null),_.toast({variant:`error`,title:h({code:ln(e)})})}},fn=async()=>{if(P===null)return;let e={};if(P.nameDirty&&P.name.trim()===``||P.messageDirty&&P.hasMessage&&P.message.trim()===``){_.toast({variant:`error`,title:nt()});return}if(P.nameDirty&&P.name.trim()!==``&&(e.name=P.name.trim()),P.scheduleDirty){if(P.scheduleKind===`cron`&&P.cronExpr.trim()!==``)e.schedule={kind:`cron`,expr:P.cronExpr.trim(),...P.tz.trim()===``?{}:{tz:P.tz.trim()}};else if(P.scheduleKind===`every`){let t=Number(P.everyValue);Number.isFinite(t)&&t>=1&&(e.schedule={kind:`every`,everyMs:Math.round(t*$[P.everyUnit])})}else if(P.scheduleKind===`at`&&P.at!==``){let t=Date.parse(P.at);Number.isFinite(t)&&(e.schedule={kind:`at`,at:new Date(t).toISOString()})}}if(P.scheduleDirty&&e.schedule===void 0){_.toast({variant:`error`,title:ge()});return}if(P.messageDirty&&P.hasMessage&&P.message.trim()!==``&&(e.message=P.message.trim()),Object.keys(e).length===0){L(null);return}let t=Q.current;Ht(!0);try{await r({instanceName:P.instanceName,jobId:P.jobId,patch:e}),_.success(d()),t===Q.current&&L(null),await q()}catch(e){_.toast({variant:`error`,title:h({code:ln(e)})})}finally{Ht(!1)}},pn=v?.reduce((e,t)=>e+t.jobs.length,0)??0;return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`div`,{style:{display:`flex`,alignItems:`flex-start`,gap:8,marginBottom:12},children:[(0,B.jsx)(`p`,{className:`oc-admin__hint`,style:{flex:1,margin:0},children:it()}),(0,B.jsxs)(`div`,{className:`oc-sched__viewtoggle`,role:`group`,"aria-label":Je(),children:[(0,B.jsx)(C,{variant:H===`list`?`secondary`:`ghost`,size:`icon-sm`,"aria-label":Ke(),title:Ke(),"aria-pressed":H===`list`,onClick:()=>Zt(`list`),children:(0,B.jsx)(ct,{})}),(0,B.jsx)(C,{variant:H===`calendar`?`secondary`:`ghost`,size:`icon-sm`,"aria-label":Ze(),title:Ze(),"aria-pressed":H===`calendar`,onClick:()=>Zt(`calendar`),children:(0,B.jsx)(qt,{})})]}),(0,B.jsxs)(C,{variant:`ghost`,size:`sm`,onClick:()=>void q(),disabled:Oe,style:{display:`inline-flex`,alignItems:`center`,gap:4},children:[(0,B.jsx)(_t,{size:14,"aria-hidden":!0}),De()]})]}),v!==null&&pn>0?(0,B.jsxs)(zt,{q:R.q,onQChange:e=>V(t=>({...t,q:e})),searchPlaceholder:Ce(),onReset:()=>V(Ut),canReset:Gt(R),children:[(0,B.jsxs)(A,{value:R.state,onValueChange:e=>V(t=>({...t,state:e})),children:[(0,B.jsx)(w,{size:`sm`,className:`w-40`,children:(0,B.jsx)(M,{})}),(0,B.jsxs)(j,{children:[(0,B.jsx)(O,{value:`all`,children:Ne()}),(0,B.jsx)(O,{value:`active`,children:Xe()}),(0,B.jsx)(O,{value:`paused`,children:ke()})]})]}),(0,B.jsxs)(A,{value:R.result,onValueChange:e=>V(t=>({...t,result:e})),children:[(0,B.jsx)(w,{size:`sm`,className:`w-40`,children:(0,B.jsx)(M,{})}),(0,B.jsxs)(j,{children:[(0,B.jsx)(O,{value:`all`,children:Ie()}),(0,B.jsx)(O,{value:`ok`,children:_e()}),(0,B.jsx)(O,{value:`error`,children:Ee()}),(0,B.jsx)(O,{value:`running`,children:at()}),(0,B.jsx)(O,{value:`none`,children:$e()})]})]})]}):null,v===null?(0,B.jsx)(`p`,{className:`oc-admin__hint`,"aria-busy":Oe,children:y?ot():ie()}):H===`calendar`?(0,B.jsxs)(B.Fragment,{children:[y?(0,B.jsx)(`p`,{className:`oc-admin__hint`,children:ot()}):null,v.length===0?(0,B.jsx)(`p`,{className:`oc-admin__hint`,children:et()}):(0,B.jsx)(tn,{events:an.events,mode:U,cursor:W,onModeChange:Qt,onCursorChange:nn,onEventClick:K,footnote:te()})]}):(0,B.jsxs)(B.Fragment,{children:[y?(0,B.jsx)(`p`,{className:`oc-admin__hint`,children:ot()}):null,v.length===0?(0,B.jsx)(`p`,{className:`oc-admin__hint`,children:et()}):null,v.map(e=>{let t=e.jobs.filter(e=>Vt(e,R)),n=Gt(R)&&e.jobs.length>0&&t.length===0;return(0,B.jsxs)(`section`,{style:{marginBottom:20},children:[v.length>1||e.error||!e.supported?(0,B.jsxs)(`h3`,{style:{display:`flex`,alignItems:`center`,gap:8,fontSize:`0.85rem`,fontWeight:600,margin:`0 0 6px`},children:[e.instanceName,(0,B.jsx)(E,{variant:`outline`,children:e.kind})]}):null,e.supported?e.error?(0,B.jsx)(`p`,{className:`oc-admin__hint`,children:Pe({code:e.error})}):e.jobs.length===0?(0,B.jsx)(`p`,{className:`oc-admin__hint`,children:Le()}):n?(0,B.jsx)(`p`,{className:`oc-admin__hint`,children:We()}):(0,B.jsxs)(Rt,{children:[(0,B.jsx)(Ft,{children:(0,B.jsxs)(Lt,{children:[(0,B.jsx)(F,{children:Ge()}),(0,B.jsx)(F,{children:qe()}),(0,B.jsx)(F,{children:Me()}),(0,B.jsx)(F,{children:Ae()}),(0,B.jsx)(F,{children:Qe()}),(0,B.jsx)(F,{children:c()}),(0,B.jsx)(F,{children:me()})]})}),(0,B.jsx)(It,{children:t.map((t,n)=>{let i=`${e.instanceName}:${t.id??n}`,a=b===i,s=e.manageSupported,c=e.kind===`openclaw`&&s;return(0,B.jsxs)(Lt,{ref:t.id!==null&&t.id===J?Y:void 0,"data-state":t.id!==null&&t.id===J?`selected`:void 0,children:[(0,B.jsx)(I,{className:`font-medium`,style:{maxWidth:280,overflow:`hidden`,textOverflow:`ellipsis`},title:t.name??void 0,children:t.name??Ue()}),(0,B.jsx)(I,{children:(0,B.jsx)(E,{variant:`secondary`,children:t.agentId})}),(0,B.jsxs)(I,{className:`whitespace-nowrap`,children:[(0,B.jsx)(`span`,{style:{fontFamily:`var(--font-mono, monospace)`},children:t.schedule??`—`}),(()=>{let e=vt(t.schedule),n=e===null?null:pt(e);return n===null?null:(0,B.jsx)(`span`,{className:`text-muted-foreground`,style:{display:`block`,fontSize:`0.78rem`},children:n})})()]}),(0,B.jsx)(I,{className:`whitespace-nowrap text-muted-foreground`,children:t.nextRunAtMs===null?`—`:on.format(t.nextRunAtMs)}),(0,B.jsx)(I,{children:Wt(t.enabled)===`active`?(0,B.jsx)(E,{variant:`secondary`,children:Xe()}):Wt(t.enabled)===`paused`?(0,B.jsx)(E,{variant:`outline`,children:ke()}):(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:`—`})}),(0,B.jsxs)(I,{children:[(0,B.jsx)(un,{status:t.lastRunStatus}),t.lastDelivered===!1?(0,B.jsx)(E,{variant:`destructive`,title:t.lastDeliveryError??be(),children:rt()}):null]}),(0,B.jsx)(I,{className:`whitespace-nowrap`,children:t.id===null?(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:`—`}):a?(0,B.jsx)(ht,{size:14,className:`oc-actrow__spin`,"aria-hidden":!0}):(0,B.jsxs)(`span`,{className:`oc-cronactions`,children:[c?(0,B.jsx)(C,{variant:`ghost`,size:`icon-sm`,title:xe(),"aria-label":xe(),disabled:b!==null,onClick:()=>void X(i,async()=>{let n=await pe({instanceName:e.instanceName,jobId:t.id});if(n.ran!==!0&&n.runId===null)throw{data:{code:n.reason??`run_not_started`}}},f()),children:(0,B.jsx)(Ot,{size:14,"aria-hidden":!0})}):null,c&&t.enabled!==null?(0,B.jsx)(C,{variant:`ghost`,size:`icon-sm`,title:t.enabled?o():st(),"aria-label":t.enabled?o():st(),disabled:b!==null,onClick:()=>void X(i,()=>r({instanceName:e.instanceName,jobId:t.id,patch:{enabled:!t.enabled}}),t.enabled?fe():ce()),children:t.enabled?(0,B.jsx)(St,{size:14,"aria-hidden":!0}):(0,B.jsx)(At,{size:14,"aria-hidden":!0})}):null,c?(0,B.jsx)(C,{variant:`ghost`,size:`icon-sm`,title:re(),"aria-label":re(),disabled:b!==null,onClick:()=>void dn(e.instanceName,t),children:(0,B.jsx)(Tt,{size:14,"aria-hidden":!0})}):null,c?(0,B.jsx)(C,{variant:`ghost`,size:`icon-sm`,title:m(),"aria-label":m(),disabled:b!==null,onClick:()=>void sn(e.instanceName,t),children:(0,B.jsx)(Jt,{size:14,"aria-hidden":!0})}):null,s?(0,B.jsx)(C,{variant:`ghost`,size:`icon-sm`,title:he(),"aria-label":he(),disabled:b!==null,onClick:()=>D({instanceName:e.instanceName,jobId:t.id,name:t.name??t.id}),children:(0,B.jsx)(yt,{size:14,"aria-hidden":!0})}):null]})})]},t.id??`${e.instanceName}-${n}`)})})]}):(0,B.jsx)(`p`,{className:`oc-admin__hint`,children:we()})]},e.instanceName)}),pn>0?(0,B.jsx)(`p`,{className:`oc-admin__hint`,style:{marginTop:4},children:Fe()}):null]}),(0,B.jsx)(jt,{open:T!==null,onOpenChange:e=>{e||D(null)},children:(0,B.jsxs)(Nt,{children:[(0,B.jsxs)(Mt,{children:[(0,B.jsx)(ft,{children:ze()}),(0,B.jsx)(dt,{children:a({name:T?.name??``})})]}),(0,B.jsxs)(lt,{children:[(0,B.jsx)(gt,{children:Ve()}),(0,B.jsx)(Pt,{onClick:()=>{let e=T;D(null),e!==null&&X(`${e.instanceName}:${e.jobId}`,()=>l({instanceName:e.instanceName,jobId:e.jobId}),oe())},children:ue()})]})]})}),(0,B.jsx)(kt,{open:k!==null,onOpenChange:e=>{e||(Z.current++,N(null))},children:(0,B.jsxs)(Ct,{style:{maxWidth:640},children:[(0,B.jsx)(mt,{children:(0,B.jsx)(wt,{children:de({name:k?.name??``})})}),k?.entries===null?(0,B.jsx)(`p`,{className:`oc-admin__hint`,children:ie()}):k!==null&&k.entries.length===0?(0,B.jsx)(`p`,{className:`oc-admin__hint`,children:se()}):k===null?null:(0,B.jsx)(`div`,{className:`oc-cronpanel__runs`,style:{maxHeight:420,overflowY:`auto`},children:k.entries.map((e,t)=>(0,B.jsxs)(`div`,{className:`oc-cronpanel__run`,children:[(0,B.jsxs)(`div`,{className:`oc-cronpanel__run-head`,children:[(0,B.jsx)(un,{status:e.status}),(0,B.jsx)(`span`,{children:typeof(e.runAtMs??e.ts)==`number`?on.format(e.runAtMs??e.ts):`—`}),typeof e.durationMs==`number`?(0,B.jsxs)(`span`,{className:`oc-cronpanel__run-dur`,children:[Math.round(e.durationMs/1e3),`s`]}):null]}),e.summary===null?null:(0,B.jsx)(`div`,{className:`oc-cronpanel__run-summary`,children:e.summary}),e.error===null?null:(0,B.jsx)(`div`,{className:`oc-cronpanel__run-error`,children:e.error}),e.delivered===!1?(0,B.jsxs)(`div`,{className:`oc-cronpanel__run-undelivered`,children:[ye({channel:e.deliveryChannel??`—`}),e.deliveryError===null?null:(0,B.jsx)(`span`,{className:`oc-cronpanel__plain`,children:e.deliveryError})]}):null]},t))})]})}),(0,B.jsx)(kt,{open:P!==null,onOpenChange:e=>{e||(Q.current++,L(null))},children:(0,B.jsxs)(Ct,{className:`oc-cronedit`,children:[(0,B.jsxs)(mt,{children:[(0,B.jsx)(wt,{children:ae()}),(0,B.jsx)(Dt,{children:Re()})]}),P===null?null:P.loading?(0,B.jsx)(`p`,{className:`oc-admin__hint`,children:ie()}):(0,B.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:12},children:[(0,B.jsxs)(`label`,{style:{display:`flex`,flexDirection:`column`,gap:4},children:[(0,B.jsx)(`span`,{className:`oc-admin__hint`,style:{margin:0},children:Ge()}),(0,B.jsx)(xt,{value:P.name,maxLength:200,onChange:e=>L({...P,name:e.target.value,nameDirty:!0})})]}),(0,B.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:4},children:[(0,B.jsx)(`span`,{className:`oc-admin__hint`,style:{margin:0},children:i()}),(0,B.jsxs)(A,{value:P.scheduleKind,onValueChange:e=>L({...P,scheduleKind:e,scheduleDirty:!0}),children:[(0,B.jsx)(w,{children:(0,B.jsx)(M,{})}),(0,B.jsxs)(j,{children:[(0,B.jsx)(O,{value:`cron`,children:Be()}),(0,B.jsx)(O,{value:`every`,children:le()}),(0,B.jsx)(O,{value:`at`,children:u()})]})]}),P.scheduleKind===`cron`?(0,B.jsxs)(`div`,{style:{display:`flex`,gap:8},children:[(0,B.jsx)(xt,{value:P.cronExpr,onChange:e=>L({...P,cronExpr:e.target.value,scheduleDirty:!0}),placeholder:`30 9 * * *`,style:{fontFamily:`var(--font-mono, monospace)`}}),(0,B.jsx)(Kt,{value:P.tz,onChange:e=>L({...P,tz:e,scheduleDirty:!0}),fallbackTz:Se??void 0})]}):P.scheduleKind===`every`?(0,B.jsxs)(`div`,{style:{display:`flex`,gap:8},children:[(0,B.jsx)(xt,{type:`number`,min:1,value:P.everyValue,onChange:e=>L({...P,everyValue:e.target.value,scheduleDirty:!0}),style:{maxWidth:120}}),(0,B.jsxs)(A,{value:P.everyUnit,onValueChange:e=>L({...P,everyUnit:e,scheduleDirty:!0}),children:[(0,B.jsx)(w,{style:{maxWidth:160},children:(0,B.jsx)(M,{})}),(0,B.jsxs)(j,{children:[(0,B.jsx)(O,{value:`minutes`,children:ee()}),(0,B.jsx)(O,{value:`hours`,children:ve()}),(0,B.jsx)(O,{value:`days`,children:tt()})]})]})]}):(0,B.jsx)(Yt,{value:P.at,onChange:e=>L({...P,at:e,scheduleDirty:!0})})]}),P.hasMessage?(0,B.jsxs)(`label`,{style:{display:`flex`,flexDirection:`column`,gap:4},children:[(0,B.jsx)(`span`,{className:`oc-admin__hint`,style:{margin:0},children:p()}),(0,B.jsx)(`textarea`,{className:`oc-cronedit__textarea`,rows:4,value:P.message,onChange:e=>L({...P,message:e.target.value,messageDirty:!0})})]}):null]}),(0,B.jsxs)(bt,{children:[(0,B.jsx)(C,{variant:`ghost`,onClick:()=>L(null),children:Ve()}),(0,B.jsxs)(C,{onClick:()=>void fn(),disabled:P===null||P.loading||Bt,children:[Bt?(0,B.jsx)(ht,{size:14,className:`oc-actrow__spin`,"aria-hidden":!0}):null,s()]})]})]})})]})}export{dn as ScheduledTab};
@@ -0,0 +1 @@
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$M as r,$j as i,AM as ee,BM as te,Bj as a,CM as ne,DM as re,EM as ie,FM as ae,GM as oe,GR as o,Gj as s,HM as se,Hj as c,IM as ce,Ij as l,JM as le,Jj as u,KM as ue,KR as d,Kj as f,LM as de,Lj as p,MM as fe,NM as pe,OM as me,PM as he,QM as ge,Qj as m,RM as _e,Rj as ve,SM as ye,TM as be,UM as xe,UR as Se,Uj as Ce,VM as we,Vj as Te,WM as Ee,Wj as h,XM as g,Xj as _,YM as De,Yj as v,ZM as y,Zj as b,_M as Oe,aM as x,bM as ke,cM as Ae,dM as je,eM as S,eN as Me,fM as Ne,gM as Pe,hM as Fe,iM as C,jM as Ie,kM as Le,lM as Re,mM as ze,nM as w,nN as Be,oM as Ve,pM as He,qM as Ue,qj as T,rM as E,sM as We,t as D,tM as O,tN as Ge,uM as Ke,vM as qe,wM as Je,xM as Ye,yM as Xe,zM as Ze,zj as k}from"./api-BASu8PYC.js";import{t as A}from"./check-BVOFzT6U.js";import{r as Qe}from"./dist-Bn5IE_M3.js";import{t as j}from"./button-_UzA03A_.js";import{$ as M,Dt as $e,Et as N,Fn as et,On as P,Pn as tt,Q as F,U as nt,X as I,Z as L,_ as rt,at as R,ct as z,et as B,it as V,jn as it,jt as H,nt as U,ot as W,rt as at,st as G,tt as K}from"./index-D02RwoOe.js";import{t as ot}from"./FilterBar-BQxNZSAj.js";import{t as st}from"./DataTableShell-BbVvH8AP.js";import{t as ct}from"./roleDescriptions-s4fc4FW8.js";var q=t(e(),1),J=n(),lt=[{value:`never`,label:()=>c(),days:null},{value:`30`,label:()=>Te(),days:30},{value:`90`,label:()=>a(),days:90}],Y=720*60*60*1e3,X=`__all__`,Z={name:``,roleKey:``,description:``};function Q(){let e=et({from:`/settings/serviceAccounts`}),t=tt({from:`/settings/serviceAccounts`}),n=e.q??``,i=e.status??X,[a,s]=(0,q.useState)(X),c=e=>void t({search:t=>({...t,q:e||void 0}),replace:!0}),l=e=>void t({search:t=>({...t,status:e===X?void 0:e})}),u=d(D.apiKeys.listServiceAccounts,{filter:{q:n||void 0,role:a===X?void 0:a,disabled:i===X?void 0:i===`disabled`}}),f=d(D.apiKeys.listKeys,{}),p=d(D.apiKeys.listRoles,{}),m=o(D.apiKeys.createServiceAccount),ve=o(D.apiKeys.updateServiceAccount),Ce=o(D.apiKeys.deleteServiceAccount),Te=Se(D.apiKeys.mintApiKey),h=o(D.apiKeys.revokeApiKey),_=nt(),v=$e(),b=n!==``||a!==X||i!==X;function x(){s(X),t({search:{},replace:!0})}let[S,C]=(0,q.useState)(!1),[w,T]=(0,q.useState)(Z),[E,O]=(0,q.useState)(null),[k,A]=(0,q.useState)(new Set),[P,R]=(0,q.useState)(null),z=(0,q.useRef)(!1),[V,U]=(0,q.useState)(new Set),[W,at]=(0,q.useState)({}),[G,K]=(0,q.useState)(null),Y=(0,q.useMemo)(()=>{let e=new Map;for(let t of f??[]){let n=e.get(t.serviceAccountId)??[];n.push(t),e.set(t.serviceAccountId,n)}return e},[f]);function Q(e){A(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}async function ft(){try{E?(await ve({serviceAccountId:E,name:w.name,roleKey:w.roleKey,description:w.description}),v.success(ke())):await m({name:w.name,roleKey:w.roleKey,description:w.description||void 0}),T(Z),O(null),C(!1)}catch(e){v.error(E?Ye():ye(),e)}}function pt(e){T({name:e.name,roleKey:e.roleKey,description:e.description??``}),O(e._id),C(!0)}async function mt(e){if(z.current)return;z.current=!0;let t=W[e._id]??`never`,n=lt.find(e=>e.value===t)?.days??null,r=n?Date.now()+n*24*60*60*1e3:void 0;R(e._id);try{let t=await Te({serviceAccountId:e._id,expiresAt:r});K({accountName:e.name,plaintext:t.plaintext,prefix:t.prefix,lastFour:t.lastFour})}catch(e){v.error(Xe(),e)}finally{z.current=!1,R(null)}}async function $(e){if(await _({title:qe(),description:(0,J.jsxs)(J.Fragment,{children:[Oe(),` `,(0,J.jsx)(`span`,{className:`font-mono`,children:e.name}),` `,Pe(),` `,(0,J.jsx)(`strong`,{children:Fe()}),` `,ze()]}),confirmWord:e.name,confirmLabel:He(),destructive:!0}))try{await Ce({serviceAccountId:e._id}),v.success(Ne(),e.name)}catch(e){v.error(je(),e)}}async function ht(e){if(await _({title:Ke(),description:(0,J.jsxs)(J.Fragment,{children:[Re(),` `,(0,J.jsxs)(`span`,{className:`font-mono`,children:[e.prefix,`…`,e.lastFour]}),` `,Ae()]}),confirmLabel:We(),destructive:!0})&&!V.has(e._id)){U(t=>new Set(t).add(e._id));try{await h({keyId:e._id})}catch(e){v.error(Ve(),e)}finally{U(t=>{let n=new Set(t);return n.delete(e._id),n})}}}return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`p`,{className:`oc-admin__hint`,children:Be()}),(0,J.jsxs)(ot,{q:n,onQChange:c,searchPlaceholder:Ge(),onReset:x,canReset:b,children:[(0,J.jsxs)(I,{value:a,onValueChange:s,children:[(0,J.jsx)(M,{size:`sm`,className:`w-40`,children:(0,J.jsx)(B,{placeholder:Me()})}),(0,J.jsxs)(L,{children:[(0,J.jsx)(F,{value:X,children:r()}),(p??[]).map(e=>(0,J.jsx)(F,{value:e.key,children:e.key},e._id))]})]}),(0,J.jsxs)(I,{value:i,onValueChange:l,children:[(0,J.jsx)(M,{size:`sm`,className:`w-36`,children:(0,J.jsx)(B,{})}),(0,J.jsxs)(L,{children:[(0,J.jsx)(F,{value:X,children:ge()}),(0,J.jsx)(F,{value:`active`,children:y()}),(0,J.jsx)(F,{value:`disabled`,children:g()})]})]})]}),(0,J.jsx)(st,{title:De(),rows:u,addLabel:le(),onAdd:()=>{T(Z),O(null),C(!0)},emptyHint:Ue(),isExpanded:e=>k.has(e._id),renderExpanded:e=>(0,J.jsx)(ut,{account:e,keys:Y.get(e._id)??[],onRevoke:ht,revoking:V}),rowActions:e=>[{label:xe(),onSelect:()=>pt(e)},{label:ue(),onSelect:()=>void mt(e)},{label:k.has(e._id)?oe():Ee(),onSelect:()=>Q(e._id)},{label:se(),variant:`destructive`,onSelect:()=>void $(e)}],columns:[{header:``,className:`w-8`,cell:e=>(0,J.jsx)(j,{variant:`ghost`,size:`icon-sm`,"aria-label":k.has(e._id)?we():te(),onClick:()=>Q(e._id),children:k.has(e._id)?(0,J.jsx)(Qe,{}):(0,J.jsx)(it,{})})},{header:Ze(),sort:e=>e.name,cell:e=>(0,J.jsxs)(`div`,{className:`flex flex-col`,children:[(0,J.jsx)(`span`,{children:e.name}),e.description?(0,J.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:e.description}):null]})},{header:_e(),sort:e=>e.roleKey,cell:e=>(0,J.jsx)(N,{variant:`secondary`,children:e.roleKey})},{header:de(),sort:e=>+!!e.disabled,cell:e=>e.disabled?(0,J.jsx)(N,{variant:`destructive`,children:g()}):(0,J.jsx)(N,{variant:`outline`,children:y()})},{header:ce(),cell:e=>(0,J.jsxs)(I,{value:W[e._id]??`never`,onValueChange:t=>at(n=>({...n,[e._id]:t})),children:[(0,J.jsx)(M,{size:`sm`,className:`w-32`,children:(0,J.jsx)(B,{})}),(0,J.jsx)(L,{children:lt.map(e=>(0,J.jsx)(F,{value:e.value,children:e.label()},e.value))})]})},{header:ae(),sort:e=>(Y.get(e._id)??[]).filter(e=>!e.disabled).length,cell:e=>{let t=(Y.get(e._id)??[]).filter(e=>!e.disabled).length;return(0,J.jsx)(`span`,{className:`oc-sa__keycount`,children:P===e._id?he():pe({count:t})})}}]}),(0,J.jsx)(rt,{open:S,onOpenChange:e=>{C(e),e||O(null)},title:E?fe():Le(),description:E?Ie():me(),canSubmit:!!(w.name&&w.roleKey),onSubmit:ft,submitLabel:E?ee():re(),children:(0,J.jsxs)(`div`,{className:`oc-form`,children:[(0,J.jsxs)(`label`,{className:`oc-field`,children:[(0,J.jsx)(`span`,{className:`oc-field__label`,children:ie()}),(0,J.jsx)(H,{value:w.name,onChange:e=>T({...w,name:e.target.value})})]}),(0,J.jsxs)(`label`,{className:`oc-field`,children:[(0,J.jsx)(`span`,{className:`oc-field__label`,children:be()}),(0,J.jsxs)(I,{value:w.roleKey||void 0,onValueChange:e=>T({...w,roleKey:e}),children:[(0,J.jsx)(M,{className:`w-full`,children:(0,J.jsx)(B,{placeholder:Je()})}),(0,J.jsx)(L,{children:(p??[]).map(e=>(0,J.jsxs)(F,{value:e.key,children:[e.name,` (`,e.key,`)`]},e._id))})]}),(()=>{let e=(p??[]).find(e=>e.key===w.roleKey),t=e?ct(e):null;return t?(0,J.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:t}):null})()]}),(0,J.jsxs)(`label`,{className:`oc-field`,children:[(0,J.jsx)(`span`,{className:`oc-field__label`,children:ne()}),(0,J.jsx)(H,{value:w.description,onChange:e=>T({...w,description:e.target.value})})]})]})}),(0,J.jsx)(dt,{minted:G,onClose:()=>K(null)})]})}function ut({account:e,keys:t,onRevoke:n,revoking:r}){return(0,J.jsxs)(`div`,{className:`oc-sa__keys`,children:[(0,J.jsxs)(`div`,{className:`oc-sa__keys-head`,children:[x(),` `,(0,J.jsx)(`span`,{className:`font-medium`,children:e.name})]}),t.length===0?(0,J.jsx)(`p`,{className:`oc-admin__hint`,children:C()}):(0,J.jsxs)(`table`,{className:`oc-sa__keytable`,children:[(0,J.jsx)(`thead`,{children:(0,J.jsxs)(`tr`,{children:[(0,J.jsx)(`th`,{children:E()}),(0,J.jsx)(`th`,{children:w()}),(0,J.jsx)(`th`,{children:O()}),(0,J.jsx)(`th`,{children:S()}),(0,J.jsx)(`th`,{children:i()}),(0,J.jsx)(`th`,{children:m()}),(0,J.jsx)(`th`,{})]})}),(0,J.jsx)(`tbody`,{children:t.map(t=>(0,J.jsxs)(`tr`,{children:[(0,J.jsx)(`td`,{children:(0,J.jsxs)(`code`,{className:`oc-sa__keyid`,children:[t.prefix,`…`,t.lastFour]})}),(0,J.jsx)(`td`,{children:(0,J.jsx)(N,{variant:`secondary`,children:e.roleKey})}),(0,J.jsx)(`td`,{children:z(t.createdAt)}),(0,J.jsx)(`td`,{className:ft(t.lastUsedAt)?`oc-sa__stale`:``,children:pt(t.lastUsedAt)}),(0,J.jsx)(`td`,{children:mt(t.expiresAt)}),(0,J.jsx)(`td`,{children:$(t)}),(0,J.jsx)(`td`,{className:`text-right`,children:t.disabled?null:(0,J.jsx)(j,{variant:`destructive`,size:`sm`,disabled:r.has(t._id),onClick:()=>n(t),children:r.has(t._id)?b():_()})})]},t._id))})]})]})}function dt({minted:e,onClose:t}){let[n,r]=(0,q.useState)(!1);async function i(){if(e)try{await navigator.clipboard.writeText(e.plaintext),r(!0),window.setTimeout(()=>r(!1),2e3)}catch{}}return(0,J.jsx)(K,{open:e!==null,onOpenChange:e=>{e||(r(!1),t())},children:e?(0,J.jsxs)(U,{className:`max-w-lg`,showCloseButton:!1,onInteractOutside:e=>e.preventDefault(),onEscapeKeyDown:e=>e.preventDefault(),children:[(0,J.jsxs)(R,{children:[(0,J.jsx)(W,{children:v()}),(0,J.jsx)(at,{children:u({name:e.accountName})})]}),(0,J.jsx)(`div`,{className:`oc-sa__minted-warning`,children:T()}),(0,J.jsxs)(`div`,{className:`oc-sa__minted-box`,children:[(0,J.jsx)(`code`,{className:`oc-sa__minted-plain`,children:e.plaintext}),(0,J.jsxs)(j,{variant:`outline`,size:`sm`,onClick:()=>void i(),"aria-label":f(),children:[n?(0,J.jsx)(A,{}):(0,J.jsx)(P,{}),n?s():h()]})]}),(0,J.jsx)(V,{children:(0,J.jsx)(j,{onClick:()=>{r(!1),t()},children:Ce()})})]}):null})}function ft(e){return e===null?!1:Date.now()-e>Y}function pt(e){return e===null?k():z(e)}function mt(e){return e===null?`—`:G(e)}function $(e){return e.disabled?(0,J.jsx)(N,{variant:`destructive`,children:ve()}):e.expiresAt!==null&&e.expiresAt<Date.now()?(0,J.jsx)(N,{variant:`outline`,children:p()}):(0,J.jsx)(N,{variant:`outline`,children:l()})}export{Q as ServiceAccountsTab};
@@ -1 +1 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{As as r,Bs as i,Cs as a,Ds as o,Es as s,Fs as c,GR as l,Hs as u,Is as d,Ls as f,Ms as p,Ns as m,Os as h,Ps as g,Rs as _,Ss as v,Ts as y,Us as b,Vs as x,WR as S,Ws as C,_s as w,bs as T,cs as E,ds as D,fs as O,gs as k,hs as A,js as j,ks as M,ls as N,ms as P,os as F,ps as I,ss as ee,t as L,us as R,vs as z,ws as B,xs as V,ys as H,zs as U}from"./api-BZGL-EQ1.js";import{t as W}from"./button-BfHR-QFa.js";import{U as G,ct as K}from"./index-B8D00xNa.js";import{t as q}from"./DataTableShell-BkZGrlHw.js";var J=t(e(),1),Y=n(),X={hung:()=>o(),wrong_result:()=>s(),error:()=>y(),other:()=>B()},Z=e=>(e&&X[e]?.())??e??`—`;function Q(e){let t=e.slice(e.lastIndexOf(`:`)+1)||e;return t.length>12?`${t.slice(0,12)}…`:t}function $({data:e}){let t=e.snapshot,n=S(L.subAgentReports.respondToReport),[r,i]=(0,J.useState)(e.thread),[o,s]=(0,J.useState)(``),[c,l]=(0,J.useState)(!1);async function u(){let t=o.trim();if(!(!t||c)){l(!0);try{await n({reportId:e._id,text:t}),i(e=>[...e,{authorRole:`admin`,text:t,at:Date.now()}]),s(``)}finally{l(!1)}}}return(0,Y.jsxs)(`div`,{className:`oc-fbadmin__detail`,children:[(0,Y.jsx)(`div`,{className:`oc-fbadmin__row`,children:(0,Y.jsxs)(`span`,{className:`oc-fbadmin__meta`,children:[Z(e.category),` · `,a({failed:t.failedCount,total:t.totalCount}),t.openclawModel?` · ${t.openclawModel}`:``,t.openclawRuntime?` (${t.openclawRuntime})`:``]})}),e.comment?(0,Y.jsxs)(`section`,{children:[(0,Y.jsx)(`h4`,{className:`oc-fbadmin__h`,children:v()}),(0,Y.jsx)(`p`,{className:`oc-fbadmin__comment`,children:e.comment})]}):null,(0,Y.jsxs)(`section`,{children:[(0,Y.jsx)(`h4`,{className:`oc-fbadmin__h`,children:V()}),r.length>0?(0,Y.jsx)(`div`,{className:`oc-fbadmin__thread`,children:r.map((e,t)=>(0,Y.jsxs)(`div`,{className:`oc-notif__msg oc-notif__msg--${e.authorRole}`,children:[(0,Y.jsx)(`span`,{className:`oc-notif__msg-who`,children:e.authorRole===`admin`?T():H()}),(0,Y.jsx)(`span`,{className:`oc-notif__msg-text`,children:e.text})]},t))}):(0,Y.jsx)(`p`,{className:`oc-fbadmin__meta`,children:z()}),(0,Y.jsx)(`textarea`,{className:`oc-feedback__textarea`,placeholder:w(),value:o,maxLength:2e3,rows:3,onChange:e=>s(e.target.value.slice(0,2e3))}),(0,Y.jsx)(`div`,{className:`oc-fbadmin__row`,style:{justifyContent:`flex-end`},children:(0,Y.jsx)(W,{size:`sm`,onClick:()=>void u(),disabled:!o.trim()||c,children:c?A():k()})})]}),(0,Y.jsxs)(`section`,{children:[(0,Y.jsxs)(`h4`,{className:`oc-fbadmin__h`,children:[P({count:t.children.length}),t.childrenTruncated?` ${I()}`:``,t.textTruncated?` ${O()}`:``]}),(0,Y.jsx)(`div`,{className:`oc-fbadmin__ctx`,children:t.children.map((e,n)=>(0,Y.jsxs)(`div`,{className:`oc-fbadmin__ctx-turn`,children:[(0,Y.jsxs)(`span`,{className:`oc-fbadmin__ctx-role`,children:[(e.taskName?.trim()||Q(e.childSessionKey))+` · ${e.status}`,e.phase?` · ${e.phase}`:``,e.childSessionKey===t.flaggedChildSessionKey?` · ${D()}`:``]}),e.errorMessage?(0,Y.jsx)(`pre`,{className:`oc-msg__source-pre`,children:e.errorMessage}):null,e.resultText?(0,Y.jsx)(`pre`,{className:`oc-msg__source-pre`,children:e.resultText}):null]},n))})]}),t.parentText?(0,Y.jsxs)(`section`,{children:[(0,Y.jsx)(`h4`,{className:`oc-fbadmin__h`,children:R()}),(0,Y.jsx)(`pre`,{className:`oc-msg__source-pre`,children:t.parentText})]}):null,(0,Y.jsxs)(`section`,{children:[(0,Y.jsx)(`h4`,{className:`oc-fbadmin__h`,children:N()}),(0,Y.jsx)(`p`,{className:`oc-fbadmin__env`,children:[t.parentStatus?`status: ${t.parentStatus}`:null,t.parentErrorCode?`code: ${t.parentErrorCode}`:null,t.parentRunId?`run ${t.parentRunId.slice(0,12)}…`:null,e.correlationId?`corr ${e.correlationId.slice(0,16)}…`:null,t.openclawProvider].filter(Boolean).join(` · `)||`—`})]})]})}function te(){let e=l(L.subAgentReports.listForAdmin,{}),t=S(L.subAgentReports.readReport),n=S(L.subAgentReports.deleteReport),a=G(),[o,s]=(0,J.useState)(null),[v,y]=(0,J.useState)({});async function w(e){if(o===e._id){s(null);return}if(!v[e._id]){let n=await t({reportId:e._id});y(t=>({...t,[e._id]:n}))}s(e._id)}async function T(e){await a({title:E(),description:ee(),confirmLabel:F(),destructive:!0})&&(await n({reportId:e._id}),o===e._id&&s(null))}return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`p`,{className:`oc-admin__hint`,children:[u(),` `,(0,Y.jsx)(`strong`,{children:x()}),` `,i()]}),(0,Y.jsx)(q,{title:C(),rows:e,emptyHint:b(),isExpanded:e=>o===e._id&&!!v[e._id],renderExpanded:e=>v[e._id]?(0,Y.jsx)($,{data:v[e._id]}):null,columns:[{header:U(),cell:e=>K(e.at),sort:e=>e.at},{header:_(),cell:e=>Z(e.category),sort:e=>Z(e.category)},{header:f(),cell:e=>`${e.failedCount}/${e.totalCount}`,sort:e=>e.failedCount},{header:d(),cell:e=>(e.reporterEmail||e.reporterName||`—`)+(e.impersonated&&e.realOperatorEmail?` ${m({operator:e.realOperatorEmail})}`:``),sort:e=>e.reporterEmail||e.reporterName||null},{header:c(),cell:e=>e.hasComment?`✎`:`—`,sort:e=>+!!e.hasComment},{header:g(),cell:e=>e.answered?(0,Y.jsx)(`span`,{className:`oc-fbadmin__pill is-ok`,children:p()}):(0,Y.jsx)(`span`,{className:`oc-fbadmin__pill`,children:j()}),sort:e=>+!!e.answered}],rowActions:e=>[{label:o===e._id?M():r(),onSelect:()=>void w(e)},{label:h(),onSelect:()=>void T(e),variant:`destructive`}]})]})}export{te as SubAgentReportsTab};
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{As as r,Bs as i,Cs as a,Ds as o,Es as s,Fs as c,GR as l,Hs as u,Is as d,KR as f,Ls as p,Ms as m,Ns as h,Os as g,Ps as _,Rs as v,Ss as y,Ts as b,Us as x,Vs as S,Ws as C,_s as w,bs as T,cs as E,ds as D,fs as O,gs as k,hs as A,js as j,ks as M,ls as N,ms as P,os as F,ps as I,ss as ee,t as L,us as R,vs as z,ws as B,xs as V,ys as H,zs as U}from"./api-BASu8PYC.js";import{t as W}from"./button-_UzA03A_.js";import{U as G,ct as K}from"./index-D02RwoOe.js";import{t as q}from"./DataTableShell-BbVvH8AP.js";var J=t(e(),1),Y=n(),X={hung:()=>o(),wrong_result:()=>s(),error:()=>b(),other:()=>B()},Z=e=>(e&&X[e]?.())??e??`—`;function Q(e){let t=e.slice(e.lastIndexOf(`:`)+1)||e;return t.length>12?`${t.slice(0,12)}…`:t}function $({data:e}){let t=e.snapshot,n=l(L.subAgentReports.respondToReport),[r,i]=(0,J.useState)(e.thread),[o,s]=(0,J.useState)(``),[c,u]=(0,J.useState)(!1);async function d(){let t=o.trim();if(!(!t||c)){u(!0);try{await n({reportId:e._id,text:t}),i(e=>[...e,{authorRole:`admin`,text:t,at:Date.now()}]),s(``)}finally{u(!1)}}}return(0,Y.jsxs)(`div`,{className:`oc-fbadmin__detail`,children:[(0,Y.jsx)(`div`,{className:`oc-fbadmin__row`,children:(0,Y.jsxs)(`span`,{className:`oc-fbadmin__meta`,children:[Z(e.category),` · `,a({failed:t.failedCount,total:t.totalCount}),t.openclawModel?` · ${t.openclawModel}`:``,t.openclawRuntime?` (${t.openclawRuntime})`:``]})}),e.comment?(0,Y.jsxs)(`section`,{children:[(0,Y.jsx)(`h4`,{className:`oc-fbadmin__h`,children:y()}),(0,Y.jsx)(`p`,{className:`oc-fbadmin__comment`,children:e.comment})]}):null,(0,Y.jsxs)(`section`,{children:[(0,Y.jsx)(`h4`,{className:`oc-fbadmin__h`,children:V()}),r.length>0?(0,Y.jsx)(`div`,{className:`oc-fbadmin__thread`,children:r.map((e,t)=>(0,Y.jsxs)(`div`,{className:`oc-notif__msg oc-notif__msg--${e.authorRole}`,children:[(0,Y.jsx)(`span`,{className:`oc-notif__msg-who`,children:e.authorRole===`admin`?T():H()}),(0,Y.jsx)(`span`,{className:`oc-notif__msg-text`,children:e.text})]},t))}):(0,Y.jsx)(`p`,{className:`oc-fbadmin__meta`,children:z()}),(0,Y.jsx)(`textarea`,{className:`oc-feedback__textarea`,placeholder:w(),value:o,maxLength:2e3,rows:3,onChange:e=>s(e.target.value.slice(0,2e3))}),(0,Y.jsx)(`div`,{className:`oc-fbadmin__row`,style:{justifyContent:`flex-end`},children:(0,Y.jsx)(W,{size:`sm`,onClick:()=>void d(),disabled:!o.trim()||c,children:c?A():k()})})]}),(0,Y.jsxs)(`section`,{children:[(0,Y.jsxs)(`h4`,{className:`oc-fbadmin__h`,children:[P({count:t.children.length}),t.childrenTruncated?` ${I()}`:``,t.textTruncated?` ${O()}`:``]}),(0,Y.jsx)(`div`,{className:`oc-fbadmin__ctx`,children:t.children.map((e,n)=>(0,Y.jsxs)(`div`,{className:`oc-fbadmin__ctx-turn`,children:[(0,Y.jsxs)(`span`,{className:`oc-fbadmin__ctx-role`,children:[(e.taskName?.trim()||Q(e.childSessionKey))+` · ${e.status}`,e.phase?` · ${e.phase}`:``,e.childSessionKey===t.flaggedChildSessionKey?` · ${D()}`:``]}),e.errorMessage?(0,Y.jsx)(`pre`,{className:`oc-msg__source-pre`,children:e.errorMessage}):null,e.resultText?(0,Y.jsx)(`pre`,{className:`oc-msg__source-pre`,children:e.resultText}):null]},n))})]}),t.parentText?(0,Y.jsxs)(`section`,{children:[(0,Y.jsx)(`h4`,{className:`oc-fbadmin__h`,children:R()}),(0,Y.jsx)(`pre`,{className:`oc-msg__source-pre`,children:t.parentText})]}):null,(0,Y.jsxs)(`section`,{children:[(0,Y.jsx)(`h4`,{className:`oc-fbadmin__h`,children:N()}),(0,Y.jsx)(`p`,{className:`oc-fbadmin__env`,children:[t.parentStatus?`status: ${t.parentStatus}`:null,t.parentErrorCode?`code: ${t.parentErrorCode}`:null,t.parentRunId?`run ${t.parentRunId.slice(0,12)}…`:null,e.correlationId?`corr ${e.correlationId.slice(0,16)}…`:null,t.openclawProvider].filter(Boolean).join(` · `)||`—`})]})]})}function te(){let e=f(L.subAgentReports.listForAdmin,{}),t=l(L.subAgentReports.readReport),n=l(L.subAgentReports.deleteReport),a=G(),[o,s]=(0,J.useState)(null),[y,b]=(0,J.useState)({});async function w(e){if(o===e._id){s(null);return}if(!y[e._id]){let n=await t({reportId:e._id});b(t=>({...t,[e._id]:n}))}s(e._id)}async function T(e){await a({title:E(),description:ee(),confirmLabel:F(),destructive:!0})&&(await n({reportId:e._id}),o===e._id&&s(null))}return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`p`,{className:`oc-admin__hint`,children:[u(),` `,(0,Y.jsx)(`strong`,{children:S()}),` `,i()]}),(0,Y.jsx)(q,{title:C(),rows:e,emptyHint:x(),isExpanded:e=>o===e._id&&!!y[e._id],renderExpanded:e=>y[e._id]?(0,Y.jsx)($,{data:y[e._id]}):null,columns:[{header:U(),cell:e=>K(e.at),sort:e=>e.at},{header:v(),cell:e=>Z(e.category),sort:e=>Z(e.category)},{header:p(),cell:e=>`${e.failedCount}/${e.totalCount}`,sort:e=>e.failedCount},{header:d(),cell:e=>(e.reporterEmail||e.reporterName||`—`)+(e.impersonated&&e.realOperatorEmail?` ${h({operator:e.realOperatorEmail})}`:``),sort:e=>e.reporterEmail||e.reporterName||null},{header:c(),cell:e=>e.hasComment?`✎`:`—`,sort:e=>+!!e.hasComment},{header:_(),cell:e=>e.answered?(0,Y.jsx)(`span`,{className:`oc-fbadmin__pill is-ok`,children:m()}):(0,Y.jsx)(`span`,{className:`oc-fbadmin__pill`,children:j()}),sort:e=>+!!e.answered}],rowActions:e=>[{label:o===e._id?M():r(),onSelect:()=>void w(e)},{label:g(),onSelect:()=>void T(e),variant:`destructive`}]})]})}export{te as SubAgentReportsTab};
@@ -0,0 +1 @@
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$N as r,$P as i,AP as a,BP as o,CP as s,D as c,DP as l,EP as u,FP as d,FR as f,GN as p,GP as m,GR as h,HP as g,IP as _,JN as v,JP as y,KN as ee,KP as te,KR as b,LP as ne,MP as re,NP as ie,NR as ae,OP as x,PP as oe,PR as se,QN as ce,QP as le,RP as ue,SP as de,TP as fe,UN as pe,UP as me,UR as he,VP as ge,WN as _e,WP as ve,XN as ye,XP as be,YN as xe,YP as Se,ZN as S,ZP as Ce,_P as we,aF as Te,aP as Ee,as as C,bP as De,cF as Oe,cP as ke,dF as Ae,dP as je,eF as Me,eP as Ne,fP as Pe,gP as Fe,hP as Ie,iF as Le,iP as Re,is as w,jP as ze,kP as Be,lF as Ve,lP as T,mP as He,nF as Ue,nP as We,ns as Ge,oF as Ke,oP as qe,pP as Je,qN as E,qP as Ye,r as Xe,rF as Ze,rP as Qe,rs as $e,sF as et,sP as tt,t as D,tF as O,tP as nt,uF as rt,uP as it,vP as at,wP as ot,xP as st,yP as ct,zP as lt}from"./api-BASu8PYC.js";import{t as k}from"./check-BVOFzT6U.js";import{t as A}from"./x-C5QQoypN.js";import{t as j}from"./button-_UzA03A_.js";import{$ as M,Dn as ut,En as N,Et as P,Ft as dt,G as ft,It as F,K as pt,Lt as mt,Mt as ht,Nt as gt,Pt as I,Q as L,X as R,Z as z,et as B,jt as V,q as H,ut as U}from"./index-D02RwoOe.js";import{t as _t}from"./localePickerView-C2RmOS86.js";import{a as vt,i as yt,n as bt,o as xt,r as St,t as Ct}from"./card-BoGX4FTX.js";import{a as wt,i as W,n as Tt,o as G,r as K,t as Et}from"./table-ChZTpaGw.js";import{t as Dt}from"./TimeRangePicker-zbyQlb0G.js";import{t as Ot}from"./FilterBar-BQxNZSAj.js";import{t as kt}from"./AdvancedFilter-oNVoBmr5.js";var q=c(`upload`,[[`path`,{d:`M12 3v12`,key:`1x0j5s`}],[`path`,{d:`m17 8-5-5-5 5`,key:`7q97r8`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}]]),J=t(e(),1),At=.1,jt=[248,248,248],Mt=[24,24,24];function Nt(e,t,n){let r=t,i=n,a=-1,o=-1;for(let s=0;s<n;s++)for(let n=0;n<t;n++)e[(s*t+n)*4+3]>8&&(n<r&&(r=n),n>a&&(a=n),s<i&&(i=s),s>o&&(o=s));return a<0?null:{x:r,y:i,width:a-r+1,height:o-i+1}}function Pt(e,t,n){let r=t*n;if(r===0)return 0;let i=0;for(let t=3;t<e.length;t+=4)e[t]<=8&&i++;return i/r}function Y(e,t,n){return Pt(e,t,n)>=At}function Ft(e,t){for(let n=0;n<e.length;n+=4)e[n]=t[0],e[n+1]=t[1],e[n+2]=t[2]}function It(e){for(let t=0;t<e.length;t+=4)e[t]=255-e[t],e[t+1]=255-e[t+1],e[t+2]=255-e[t+2]}var Lt=12*1024*1024,Rt=480,zt=160,Bt=.92;async function Vt(e,t={}){if(!e.type.startsWith(`image/`))throw Error(Pe());if(e.size>Lt)throw Error(je());let{source:n,width:r,height:i,cleanup:a}=await Ht(e);try{let a=e.type===`image/svg+xml`,o=Math.min(Rt/r,zt/i,a?1/0:1),s=Math.max(1,Math.round(r*o)),c=Math.max(1,Math.round(i*o)),l=document.createElement(`canvas`);l.width=s,l.height=c;let u=l.getContext(`2d`);if(!u)throw Error(T());u.imageSmoothingEnabled=!0,u.imageSmoothingQuality=`high`,u.drawImage(n,0,0,s,c);let d=Nt(u.getImageData(0,0,s,c).data,s,c)??{x:0,y:0,width:s,height:c},f=document.createElement(`canvas`);f.width=d.width,f.height=d.height;let p=f.getContext(`2d`);if(!p)throw Error(T());if(p.drawImage(l,d.x,d.y,d.width,d.height,0,0,d.width,d.height),t.variantFor){let e=p.getImageData(0,0,d.width,d.height);Y(e.data,d.width,d.height)?Ft(e.data,t.variantFor===`dark`?jt:Mt):It(e.data),p.putImageData(e,0,0)}let m=Y(p.getImageData(0,0,d.width,d.height).data,d.width,d.height),h=await Wt(f,`image/webp`,Bt)??await Wt(f,`image/png`);if(!h)throw Error(ke());return{blob:h,hasAlpha:m}}finally{a()}}async function Ht(e){if(e.type===`image/svg+xml`)return Ut(e);if(typeof createImageBitmap==`function`)try{let t=await createImageBitmap(e);return{source:t,width:t.width,height:t.height,cleanup:()=>t.close()}}catch{}return Ut(e)}async function Ut(e){let t=URL.createObjectURL(e);try{let e=new Image;return e.decoding=`async`,await new Promise((n,r)=>{e.onload=()=>n(),e.onerror=()=>r(Error(it())),e.src=t}),{source:e,width:e.naturalWidth||300,height:e.naturalHeight||150,cleanup:()=>URL.revokeObjectURL(t)}}catch(e){throw URL.revokeObjectURL(t),e}}function Wt(e,t,n){return new Promise(r=>e.toBlob(e=>r(e),t,n))}var X=n();function Gt(e,t){let n=e.trim().replace(/[^A-Za-z0-9_.-]+/g,`-`).replace(/^-+|-+$/g,``)||`chart`,r=new Blob([JSON.stringify(t,null,2)],{type:`application/json`}),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=`${n}.chart.json`,document.body.appendChild(a),a.click(),a.remove(),URL.revokeObjectURL(i)}var Z=`__all__`,Kt={kind:`relative`,from:`now-24h`,to:`now`},qt=[{value:`status`,label:`Statut`},{value:`latencyMs`,label:`Latence (ms)`},{value:`route`,label:`Route`},{value:`roleKey`,label:`Rôle`},{value:`correlationId`,label:`Corrélation`}];function Q({title:e,description:t,children:n}){return(0,X.jsxs)(`section`,{className:`oc-show__section`,children:[(0,X.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,X.jsx)(`h2`,{className:`oc-show__title`,children:e}),t?(0,X.jsx)(`p`,{className:`oc-show__desc`,children:t}):null]}),(0,X.jsx)(`div`,{className:`oc-show__demo`,children:n})]})}function Jt(e){return e===`light`?f():e===`dark`?se():ae()}var Yt=[`primary`,`secondary`,`accent`,`muted`,`chart-1`,`chart-2`];function Xt({tokens:e,mode:t}){let n=e.colors[t];return(0,X.jsx)(`div`,{className:`oc-chart-swatches`,"aria-hidden":!0,children:Yt.map(e=>{let t=n[e];return(0,X.jsx)(`span`,{className:`oc-chart-swatch`,style:t?{background:t}:void 0},e)})})}function Zt({selected:e,title:t,subtitle:n,tokens:r,mode:i,onSelect:a,onExport:o}){return(0,X.jsxs)(`div`,{className:`oc-chart-card-wrap`,children:[(0,X.jsxs)(`button`,{type:`button`,className:Xe(`oc-chart-card`,e&&`oc-chart-card--selected`),"aria-pressed":e,onClick:a,children:[(0,X.jsxs)(`div`,{className:`oc-chart-card__head`,children:[(0,X.jsx)(`span`,{className:`oc-chart-card__title`,children:t}),e?(0,X.jsx)(k,{className:`size-4 text-primary`,"aria-hidden":!0}):null]}),r?(0,X.jsx)(Xt,{tokens:r,mode:i}):(0,X.jsx)(`div`,{className:`oc-chart-swatches oc-chart-swatches--native`,"aria-hidden":!0}),(0,X.jsx)(`div`,{className:`oc-chart-card__meta`,children:(0,X.jsx)(`span`,{className:`oc-chart-card__subtitle`,children:n})})]}),o?(0,X.jsx)(j,{type:`button`,variant:`ghost`,size:`icon`,className:`oc-chart-card__export`,onClick:o,"aria-label":C(),title:C(),children:(0,X.jsx)(ut,{className:`size-4`})}):null]})}function Qt({selectedKey:e,resolvedMode:t}){let n=b(D.charts.listMyCharts),r=h(D.charts.setMyChart);async function a(e){try{await r({name:e})}catch{}}return(0,X.jsxs)(`section`,{className:`oc-show__section`,children:[(0,X.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,X.jsx)(`h2`,{className:`oc-show__title`,children:Ze()}),(0,X.jsx)(`p`,{className:`oc-show__desc`,children:Ue()})]}),(0,X.jsxs)(`div`,{className:`oc-chart-grid`,children:[(0,X.jsx)(Zt,{selected:e===null,title:O(),subtitle:Me(),tokens:null,mode:t,onSelect:()=>void a(null)}),(n??[]).map(n=>{let r=n.via===`common`?i():n.via===`owner`?le():Ce({group:n.via.group});return(0,X.jsx)(Zt,{selected:e===n.key,title:n.name,subtitle:r,tokens:n.tokens,mode:t,onSelect:()=>void a(n.key),onExport:()=>Gt(n.name,n.tokens)},n.key)})]}),n!==void 0&&n.length===0?(0,X.jsx)(`p`,{className:`oc-show__desc`,children:be()}):null]})}function $t(){let e=h(D.charts.importChart),[t,n]=(0,J.useState)(``),[r,i]=(0,J.useState)(``),[o,s]=(0,J.useState)(null),[c,f]=(0,J.useState)(!1),[p,m]=(0,J.useState)(!1);async function g(e){let t=e.target.files?.[0];if(e.target.value=``,t){s(null),f(!1);try{i(await t.text())}catch{s(x())}}}async function v(){if(s(null),f(!1),t.trim()===``){s(u());return}let a;try{a=JSON.parse(r)}catch{s(x());return}m(!0);try{await e({name:t.trim(),tokens:a}),f(!0),n(``),i(``)}catch(e){s(e instanceof Error?e.message:String(e))}finally{m(!1)}}return(0,X.jsxs)(`section`,{className:`oc-show__section`,children:[(0,X.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,X.jsx)(`h2`,{className:`oc-show__title`,children:_()}),(0,X.jsx)(`p`,{className:`oc-show__desc`,children:d()})]}),(0,X.jsxs)(`div`,{className:`oc-chart-import`,children:[(0,X.jsxs)(`label`,{className:`oc-chart-import__field`,children:[(0,X.jsx)(`span`,{className:`oc-chart-import__label`,children:oe()}),(0,X.jsx)(V,{value:t,onChange:e=>n(e.target.value),placeholder:ie(),maxLength:60})]}),(0,X.jsxs)(`label`,{className:`oc-chart-import__field`,children:[(0,X.jsx)(`span`,{className:`oc-chart-import__label`,children:re()}),(0,X.jsx)(`textarea`,{className:`oc-chart-import__textarea`,value:r,onChange:e=>i(e.target.value),placeholder:ze(),rows:8,spellCheck:!1})]}),(0,X.jsxs)(`div`,{className:`oc-show__row`,children:[(0,X.jsx)(j,{variant:`outline`,size:`sm`,asChild:!0,children:(0,X.jsxs)(`label`,{className:`oc-chart-import__file`,children:[(0,X.jsx)(q,{className:`size-4`}),a(),(0,X.jsx)(`input`,{type:`file`,accept:`application/json,.json`,className:`oc-chart-import__file-input`,onChange:e=>void g(e)})]})}),(0,X.jsx)(j,{size:`sm`,disabled:p,onClick:()=>void v(),children:Be()})]}),o?(0,X.jsx)(`p`,{className:`oc-chart-import__error`,children:o}):null,c?(0,X.jsx)(`p`,{className:`oc-chart-import__ok`,children:l()}):null]})]})}function en({chart:e}){let t=he(D.charts.setChartLogo),n=h(D.charts.removeChartLogo),[r,i]=(0,J.useState)(!1),[a,o]=(0,J.useState)(null),s=t=>t===`light`?e.logoLightUrl:e.logoDarkUrl;async function c(n,r,a){if(e.chartId!==void 0){o(null),i(!0);try{let{blob:i,hasAlpha:o}=await Vt(r,a?{variantFor:a}:{}),s=await i.arrayBuffer();await t({chartId:e.chartId,bytes:s,mode:n,hasAlpha:o})}catch(e){o(e instanceof Error?e.message:String(e))}finally{i(!1)}}}async function l(e,t){let n=t.target.files?.[0];t.target.value=``,n&&await c(e,n)}async function u(t){if(e.chartId!==void 0){o(null),i(!0);try{await n({chartId:e.chartId,mode:t})}catch(e){o(e instanceof Error?e.message:String(e))}finally{i(!1)}}}async function d(e){let t=s(e===`light`?`dark`:`light`);if(t){o(null),i(!0);try{await c(e,await(await fetch(t)).blob(),e)}catch(e){o(e instanceof Error?e.message:String(e))}finally{i(!1)}}}function f({mode:e}){let t=s(e),n=s(e===`light`?`dark`:`light`);return(0,X.jsxs)(`div`,{className:`oc-chart-mine__logo-slot`,children:[(0,X.jsx)(`span`,{className:`oc-chart-mine__logo-mode`,children:e===`light`?ct():at()}),(0,X.jsx)(`span`,{className:`oc-chart-mine__logo-preview`,"data-mode":e,"data-empty":t?void 0:`1`,children:t?(0,X.jsx)(`img`,{src:t,alt:``}):null}),(0,X.jsx)(j,{variant:`outline`,size:`sm`,asChild:!0,children:(0,X.jsxs)(`label`,{className:`oc-chart-import__file`,children:[(0,X.jsx)(q,{className:`size-4`}),t?Fe():we(),(0,X.jsx)(`input`,{type:`file`,accept:`image/*`,className:`oc-chart-import__file-input`,onChange:t=>void l(e,t)})]})}),!t&&n?(0,X.jsx)(j,{variant:`ghost`,size:`sm`,disabled:r,onClick:()=>void d(e),children:He()}):null,t?(0,X.jsx)(j,{variant:`ghost`,size:`sm`,disabled:r,onClick:()=>void u(e),children:Ie()}):null]})}return(0,X.jsxs)(`div`,{className:`oc-chart-mine__logo`,children:[(0,X.jsx)(`span`,{className:`oc-chart-mine__groups-label`,children:De()}),(0,X.jsxs)(`div`,{className:`oc-chart-mine__logo-slots`,children:[(0,X.jsx)(f,{mode:`light`}),(0,X.jsx)(f,{mode:`dark`})]}),r?(0,X.jsx)(`span`,{className:`oc-show__desc`,children:Je()}):null,a?(0,X.jsx)(`p`,{className:`oc-chart-import__error`,children:a}):null]})}function tn({chart:e}){let t=b(D.me.getMe,{host:H}),n=h(D.charts.addChartDomain),r=h(D.charts.removeChartDomain),[i,a]=(0,J.useState)(``),[o,s]=(0,J.useState)(null),[c,l]=(0,J.useState)(!1);if(t?.role!==`admin`)return null;let u=e.domains??[];async function d(){let t=i.trim();if(t!==``){s(null),l(!0);try{await n({chartKey:e.key,domain:t}),a(``)}catch(e){s(e instanceof Error?e.message:String(e))}finally{l(!1)}}}async function f(t){s(null);try{await r({chartKey:e.key,domain:t})}catch{}}return(0,X.jsxs)(`div`,{className:`oc-chart-mine__domains`,children:[(0,X.jsx)(`span`,{className:`oc-chart-mine__groups-label`,children:tt()}),(0,X.jsxs)(`div`,{className:`oc-chart-mine__domains-body`,children:[(0,X.jsx)(`div`,{className:`oc-chart-avail__groups`,children:u.length===0?(0,X.jsx)(`span`,{className:`oc-show__desc`,children:Qe()}):u.map(e=>(0,X.jsxs)(P,{variant:`secondary`,className:`oc-chart-avail__chip`,children:[e,(0,X.jsx)(`button`,{type:`button`,className:`oc-chart-avail__chip-x`,"aria-label":We({domain:e}),onClick:()=>void f(e),children:(0,X.jsx)(A,{className:`size-3`})})]},e))}),(0,X.jsxs)(`div`,{className:`oc-show__row`,children:[(0,X.jsx)(V,{value:i,onChange:e=>a(e.target.value),placeholder:Ee(),className:`oc-chart-mine__domains-input`,onKeyDown:e=>{e.key===`Enter`&&d()}}),(0,X.jsx)(j,{variant:`outline`,size:`sm`,disabled:c,onClick:()=>void d(),children:Re()})]}),(0,X.jsx)(`span`,{className:`oc-show__desc`,children:qe()}),o?(0,X.jsx)(`p`,{className:`oc-chart-import__error`,children:o}):null]})]})}function $(e){let t={...e};return delete t.bpm,JSON.stringify(t,null,2)}function nn({chart:e}){let t=h(D.charts.updateChart),n=h(D.charts.deleteChart),[i,a]=(0,J.useState)(!1),[o,s]=(0,J.useState)(e.name),[c,l]=(0,J.useState)(()=>$(e.tokens)),[u,d]=(0,J.useState)(e.tokens.bpm??0),[f,p]=(0,J.useState)(null),[m,g]=(0,J.useState)(!1);function _(){s(e.name),l($(e.tokens)),d(e.tokens.bpm??0),p(null),a(!0)}async function v(){if(e.chartId===void 0)return;p(null);let n;try{n=JSON.parse(c)}catch{p(x());return}if(n&&typeof n==`object`&&!Array.isArray(n)){let e=n;u>0?e.bpm=u:delete e.bpm}g(!0);try{await t({chartId:e.chartId,name:o.trim(),tokens:n}),a(!1)}catch(e){p(e instanceof Error?e.message:String(e))}finally{g(!1)}}async function y(){if(e.chartId!==void 0&&window.confirm(S()))try{await n({chartId:e.chartId})}catch{}}return(0,X.jsxs)(`div`,{className:`oc-chart-mine__row`,children:[(0,X.jsxs)(`div`,{className:`oc-chart-mine__head`,children:[(0,X.jsx)(`span`,{className:`oc-chart-mine__name`,children:e.name}),(0,X.jsx)(`div`,{className:`oc-show__row`,children:i?null:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(j,{variant:`outline`,size:`sm`,onClick:_,children:de()}),(0,X.jsx)(j,{variant:`ghost`,size:`sm`,onClick:()=>void y(),children:st()})]})})]}),i?(0,X.jsxs)(`div`,{className:`oc-chart-mine__editor`,children:[(0,X.jsxs)(`label`,{className:`oc-chart-import__field`,children:[(0,X.jsx)(`span`,{className:`oc-chart-import__label`,children:r()}),(0,X.jsx)(V,{value:o,onChange:e=>s(e.target.value),maxLength:60})]}),(0,X.jsxs)(`div`,{className:`oc-chart-import__field`,children:[(0,X.jsx)(`span`,{className:`oc-chart-import__label`,children:w()}),(0,X.jsxs)(`div`,{className:`oc-chart-bpm`,children:[(0,X.jsx)(`input`,{type:`range`,className:`oc-chart-bpm__slider`,min:0,max:90,step:5,value:u,onChange:e=>d(Number(e.target.value)),"aria-label":w()}),(0,X.jsx)(`span`,{className:`oc-chart-bpm__value`,children:u===0?$e():`${u} BPM`})]}),(0,X.jsx)(`span`,{className:`oc-show__desc`,children:Ge()})]}),(0,X.jsxs)(`label`,{className:`oc-chart-import__field`,children:[(0,X.jsx)(`span`,{className:`oc-chart-import__label`,children:ce()}),(0,X.jsx)(`textarea`,{className:`oc-chart-import__textarea`,value:c,onChange:e=>l(e.target.value),rows:10,spellCheck:!1})]}),f?(0,X.jsx)(`p`,{className:`oc-chart-import__error`,children:f}):null,(0,X.jsxs)(`div`,{className:`oc-show__row`,children:[(0,X.jsx)(j,{size:`sm`,disabled:m,onClick:()=>void v(),children:nt()}),(0,X.jsx)(j,{variant:`ghost`,size:`sm`,onClick:()=>a(!1),children:Ne()})]})]}):null,(0,X.jsx)(en,{chart:e}),(0,X.jsx)(tn,{chart:e})]})}function rn(){let e=b(D.charts.listMyCharts),t=(e??[]).filter(e=>e.via===`owner`);return(0,X.jsxs)(`section`,{className:`oc-show__section`,children:[(0,X.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,X.jsx)(`h2`,{className:`oc-show__title`,children:fe()}),(0,X.jsx)(`p`,{className:`oc-show__desc`,children:ot()})]}),e!==void 0&&t.length===0?(0,X.jsx)(`p`,{className:`oc-show__desc`,children:s()}):(0,X.jsx)(`div`,{className:`oc-chart-mine-list`,children:t.map(e=>(0,X.jsx)(nn,{chart:e},e.key))})]})}function an({chart:e,groups:t}){let n=h(D.charts.addChartToGroupPool),r=h(D.charts.removeChartFromGroupPool),i=e.restrictedToGroups,a=e.poolGroups,s=new Set((a??[]).map(e=>e.groupId)),c=t.filter(e=>!s.has(e._id));async function l(t){try{await n({groupId:t,chartKey:e.key})}catch{}}async function u(t){try{await r({groupId:t,chartKey:e.key})}catch{}}return(0,X.jsxs)(`div`,{className:`oc-chart-avail`,children:[(0,X.jsxs)(`div`,{className:`oc-chart-avail__head`,children:[(0,X.jsx)(`span`,{className:`oc-chart-avail__name`,children:e.name}),(0,X.jsx)(P,{variant:i?`secondary`:`outline`,className:`oc-chart-avail__state`,children:i?g():e.kind===`custom`&&e.scope===`personal`?E():me()}),e.isGlobalDefault?(0,X.jsx)(P,{variant:`default`,children:ge()}):null]}),(0,X.jsxs)(`div`,{className:`oc-chart-avail__groups`,children:[(0,X.jsx)(`span`,{className:`oc-chart-mine__groups-label`,children:lt()}),(a??[]).map(e=>(0,X.jsxs)(P,{variant:`secondary`,className:`oc-chart-avail__chip`,children:[e.name,(0,X.jsx)(`button`,{type:`button`,className:`oc-chart-avail__chip-x`,"aria-label":ne({group:e.name}),onClick:()=>void u(e.groupId),children:(0,X.jsx)(A,{className:`size-3`})})]},e.groupId)),c.length>0?(0,X.jsxs)(R,{value:``,onValueChange:e=>void l(e),children:[(0,X.jsx)(M,{size:`sm`,className:`w-56`,children:(0,X.jsx)(B,{placeholder:ue()})}),(0,X.jsx)(z,{children:c.map(e=>(0,X.jsx)(L,{value:e._id,children:e.name},e._id))})]}):t.length===0?(0,X.jsx)(`span`,{className:`oc-show__desc`,children:o()}):null]})]})}function on({chart:e}){let t=h(D.charts.promoteChartToCommon),n=h(D.charts.deleteChart);async function r(){if(e.chartId!==void 0)try{await t({chartId:e.chartId})}catch{}}async function i(){if(e.chartId!==void 0&&window.confirm(S()))try{await n({chartId:e.chartId})}catch{}}return(0,X.jsxs)(`div`,{className:`oc-chart-avail`,children:[(0,X.jsxs)(`div`,{className:`oc-chart-avail__head`,children:[(0,X.jsx)(`span`,{className:`oc-chart-avail__name`,children:e.name}),(0,X.jsx)(P,{variant:e.scope===`common`?`outline`:`secondary`,children:e.scope===`common`?ee():E()}),e.ownerLabel?(0,X.jsx)(`span`,{className:`oc-show__desc`,children:v({owner:e.ownerLabel})}):null]}),(0,X.jsxs)(`div`,{className:`oc-show__row`,children:[e.scope===`personal`?(0,X.jsx)(j,{variant:`outline`,size:`sm`,onClick:()=>void r(),children:p()}):null,(0,X.jsx)(j,{variant:`ghost`,size:`sm`,onClick:()=>void i(),children:_e()})]})]})}function sn({defaultThemeMode:e,defaultLocale:t,defaultChartKey:n}){let r=h(D.admin.setDefaultThemeMode),i=h(D.admin.setDefaultLocale),a=h(D.charts.setDefaultChart),o=b(D.charts.listChartsAdmin),s=b(D.groups.listGroups,{}),c=e??`system`,l=t??`fr`;return(0,X.jsxs)(`div`,{className:`oc-appearance-admin`,children:[(0,X.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,X.jsx)(`h2`,{className:`oc-show__title`,children:Te()}),(0,X.jsx)(`p`,{className:`oc-show__desc`,children:Le()})]}),(0,X.jsxs)(`section`,{className:`oc-show__section`,children:[(0,X.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,X.jsx)(`h3`,{className:`oc-show__title`,children:Se()}),(0,X.jsx)(`p`,{className:`oc-show__desc`,children:y()})]}),(0,X.jsxs)(`div`,{className:`oc-show__row`,children:[(0,X.jsx)(j,{variant:n===null?`default`:`outline`,size:`sm`,onClick:()=>void a({name:null}),children:O()}),pt.map(e=>(0,X.jsx)(j,{variant:n===e.key?`default`:`outline`,size:`sm`,onClick:()=>void a({name:e.key}),children:e.name},e.key)),(o??[]).filter(e=>e.kind===`custom`&&e.scope===`common`).map(e=>(0,X.jsx)(j,{variant:n===e.key?`default`:`outline`,size:`sm`,onClick:()=>void a({name:e.key}),children:e.name},e.key))]})]}),(0,X.jsxs)(`section`,{className:`oc-show__section`,children:[(0,X.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,X.jsx)(`h3`,{className:`oc-show__title`,children:Ye()}),(0,X.jsx)(`p`,{className:`oc-show__desc`,children:te()})]}),(0,X.jsx)(`div`,{className:`oc-chart-avail-list`,children:(o??[]).filter(e=>!(e.kind===`custom`&&e.scope===`common`)).map(e=>(0,X.jsx)(an,{chart:e,groups:s??[]},e.key))})]}),(0,X.jsxs)(`section`,{className:`oc-show__section`,children:[(0,X.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,X.jsx)(`h3`,{className:`oc-show__title`,children:m()}),(0,X.jsx)(`p`,{className:`oc-show__desc`,children:ve()})]}),(0,X.jsx)(`div`,{className:`oc-chart-avail-list`,children:(o??[]).filter(e=>e.kind===`builtin`||e.scope===`common`).map(e=>(0,X.jsxs)(`div`,{className:`oc-chart-avail`,children:[(0,X.jsx)(`div`,{className:`oc-chart-avail__head`,children:(0,X.jsx)(`span`,{className:`oc-chart-avail__name`,children:e.name})}),(0,X.jsx)(tn,{chart:e})]},e.key))})]}),(0,X.jsxs)(`section`,{className:`oc-show__section`,children:[(0,X.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,X.jsx)(`h3`,{className:`oc-show__title`,children:ye()}),(0,X.jsx)(`p`,{className:`oc-show__desc`,children:xe()})]}),(()=>{let e=(o??[]).filter(e=>e.kind===`custom`);return e.length===0?(0,X.jsx)(`p`,{className:`oc-show__desc`,children:pe()}):(0,X.jsx)(`div`,{className:`oc-chart-avail-list`,children:e.map(e=>(0,X.jsx)(on,{chart:e},e.key))})})()]}),(0,X.jsxs)(`section`,{className:`oc-show__section`,children:[(0,X.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,X.jsx)(`h3`,{className:`oc-show__title`,children:Ae()}),(0,X.jsx)(`p`,{className:`oc-show__desc`,children:rt()})]}),(0,X.jsx)(`div`,{className:`oc-show__row`,children:[`light`,`dark`,`system`].map(e=>(0,X.jsx)(j,{variant:c===e?`default`:`outline`,size:`sm`,onClick:()=>void r({mode:e}),children:Jt(e)},e))})]}),(0,X.jsxs)(`section`,{className:`oc-show__section`,children:[(0,X.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,X.jsx)(`h3`,{className:`oc-show__title`,children:Ve()}),(0,X.jsx)(`p`,{className:`oc-show__desc`,children:Oe()})]}),(0,X.jsx)(`div`,{className:`oc-show__row`,children:_t().map(e=>(0,X.jsx)(j,{variant:l===e.value?`default`:`outline`,size:`sm`,onClick:()=>void i({locale:e.value}),children:e.label},e.value))}),(0,X.jsx)(`p`,{className:`oc-show__desc`,children:et()})]})]})}function cn(){let e=b(D.me.getMe,{host:H}),t=ft(e?.resolvedThemeMode);return(0,X.jsxs)(`div`,{className:`oc-appearance`,children:[(0,X.jsx)(Qt,{selectedKey:e?.chartKey??null,resolvedMode:t}),(0,X.jsx)($t,{}),(0,X.jsx)(rn,{}),e?.role===`admin`?(0,X.jsx)(sn,{defaultThemeMode:e.defaultThemeMode,defaultLocale:e.defaultLocale,defaultChartKey:e.defaultChartKey}):null]})}function ln(){let[e,t]=(0,J.useState)(!0),[n,r]=(0,J.useState)(`per-user`),[i,a]=(0,J.useState)(``),[o,s]=(0,J.useState)(Z),[c,l]=(0,J.useState)(Z),[u,d]=(0,J.useState)(Kt),f=i!==``||o!==Z||c!==Z;function p(){a(``),s(Z),l(Z),d(Kt)}return(0,X.jsxs)(`div`,{className:`oc-show`,children:[(0,X.jsx)(cn,{}),(0,X.jsxs)(`details`,{className:`oc-show__ref`,children:[(0,X.jsx)(`summary`,{className:`oc-show__title`,children:Ke()}),(0,X.jsxs)(Q,{title:`Buttons`,description:`Variants`,children:[(0,X.jsxs)(`div`,{className:`oc-show__row`,children:[(0,X.jsx)(j,{children:`Default`}),(0,X.jsx)(j,{variant:`secondary`,children:`Secondary`}),(0,X.jsx)(j,{variant:`outline`,children:`Outline`}),(0,X.jsx)(j,{variant:`ghost`,children:`Ghost`}),(0,X.jsx)(j,{variant:`destructive`,children:`Destructive`}),(0,X.jsx)(j,{variant:`link`,children:`Link`})]}),(0,X.jsxs)(`div`,{className:`oc-show__row`,children:[(0,X.jsx)(j,{size:`sm`,children:`Small`}),(0,X.jsx)(j,{children:`Default`}),(0,X.jsx)(j,{size:`lg`,children:`Large`}),(0,X.jsx)(j,{size:`icon`,"aria-label":`more`,children:(0,X.jsx)(N,{})}),(0,X.jsx)(j,{disabled:!0,children:`Disabled`})]})]}),(0,X.jsx)(Q,{title:`Badges`,children:(0,X.jsxs)(`div`,{className:`oc-show__row`,children:[(0,X.jsx)(P,{children:`Default`}),(0,X.jsx)(P,{variant:`secondary`,children:`Secondary`}),(0,X.jsx)(P,{variant:`outline`,children:`Outline`}),(0,X.jsx)(P,{variant:`destructive`,children:`Destructive`})]})}),(0,X.jsx)(Q,{title:`Inputs & selection`,children:(0,X.jsxs)(`div`,{className:`oc-show__row oc-show__row--col`,children:[(0,X.jsx)(V,{placeholder:`Text input…`}),(0,X.jsxs)(`div`,{className:`oc-show__row`,children:[(0,X.jsxs)(R,{value:n,onValueChange:r,children:[(0,X.jsx)(M,{className:`w-56`,children:(0,X.jsx)(B,{placeholder:`Select…`})}),(0,X.jsxs)(z,{children:[(0,X.jsx)(L,{value:`per-user`,children:`per-user (chacun son agent)`}),(0,X.jsx)(L,{value:`shared`,children:`shared (agent commun)`})]})]}),(0,X.jsxs)(`label`,{className:`oc-show__check`,children:[(0,X.jsx)(U,{checked:e,onCheckedChange:e=>t(!!e)}),`Checkbox`]})]})]})}),(0,X.jsx)(Q,{title:`Filtres & plage temporelle`,description:`Barre réutilisable (recherche debouncée + selects rapides à largeur auto + plage façon Grafana) et constructeur de filtre avancé. Câblée dans Users, Groups, Comptes de service, Traces, Anomalies, Audit et KPI.`,children:(0,X.jsxs)(`div`,{className:`oc-show__row oc-show__row--col`,children:[(0,X.jsxs)(Ot,{q:i,onQChange:a,searchPlaceholder:`Rechercher (kind, principal, rôle, route…)`,timeRange:u,onTimeRangeChange:d,onReset:p,canReset:f,children:[(0,X.jsxs)(R,{value:o,onValueChange:s,children:[(0,X.jsx)(M,{size:`sm`,children:(0,X.jsx)(B,{})}),(0,X.jsxs)(z,{children:[(0,X.jsx)(L,{value:Z,children:`Toutes directions`}),(0,X.jsx)(L,{value:`inbound`,children:`inbound`}),(0,X.jsx)(L,{value:`outbound`,children:`outbound`}),(0,X.jsx)(L,{value:`internal`,children:`internal`})]})]}),(0,X.jsxs)(R,{value:c,onValueChange:l,children:[(0,X.jsx)(M,{size:`sm`,children:(0,X.jsx)(B,{})}),(0,X.jsxs)(z,{children:[(0,X.jsx)(L,{value:Z,children:`Toutes sévérités`}),(0,X.jsx)(L,{value:`info`,children:`info`}),(0,X.jsx)(L,{value:`warn`,children:`warn`}),(0,X.jsx)(L,{value:`critical`,children:`critical`})]})]})]}),(0,X.jsx)(kt,{fields:qt,onChange:()=>{}}),(0,X.jsxs)(`div`,{className:`oc-show__row`,children:[(0,X.jsx)(`span`,{className:`oc-show__desc`,children:`Sélecteur de plage seul :`}),(0,X.jsx)(Dt,{value:u,onChange:d})]})]})}),(0,X.jsx)(Q,{title:`Dropdown menu`,description:`Row actions / kebab`,children:(0,X.jsxs)(ht,{children:[(0,X.jsx)(mt,{asChild:!0,children:(0,X.jsx)(j,{variant:`outline`,size:`icon`,"aria-label":`Open menu`,children:(0,X.jsx)(N,{})})}),(0,X.jsxs)(gt,{align:`start`,children:[(0,X.jsx)(dt,{children:`Actions`}),(0,X.jsx)(F,{}),(0,X.jsx)(I,{children:`Edit`}),(0,X.jsx)(I,{children:`Duplicate`}),(0,X.jsx)(F,{}),(0,X.jsx)(I,{variant:`destructive`,children:`Delete`})]})]})}),(0,X.jsx)(Q,{title:`Card`,children:(0,X.jsxs)(Ct,{className:`w-80`,children:[(0,X.jsxs)(vt,{children:[(0,X.jsx)(xt,{children:`Instance`}),(0,X.jsx)(St,{children:`Non-secret metadata only.`})]}),(0,X.jsx)(bt,{className:`text-sm text-muted-foreground`,children:`ws://gateway.example.org:18789`}),(0,X.jsxs)(yt,{className:`gap-2`,children:[(0,X.jsx)(j,{size:`sm`,children:`Save`}),(0,X.jsx)(j,{size:`sm`,variant:`ghost`,children:`Cancel`})]})]})}),(0,X.jsx)(Q,{title:`Table`,children:(0,X.jsxs)(Et,{children:[(0,X.jsx)(wt,{children:(0,X.jsxs)(G,{children:[(0,X.jsx)(W,{className:`w-8`,children:(0,X.jsx)(U,{"aria-label":`select all`})}),(0,X.jsx)(W,{children:`Name`}),(0,X.jsx)(W,{children:`Mode`}),(0,X.jsx)(W,{className:`text-right`,children:`Status`}),(0,X.jsx)(W,{className:`w-8`})]})}),(0,X.jsx)(Tt,{children:[{n:`admins`,m:`per-user`,s:`active`},{n:`family`,m:`shared`,s:`active`}].map(e=>(0,X.jsxs)(G,{children:[(0,X.jsx)(K,{children:(0,X.jsx)(U,{"aria-label":`select ${e.n}`})}),(0,X.jsx)(K,{className:`font-medium`,children:e.n}),(0,X.jsx)(K,{children:(0,X.jsx)(P,{variant:`secondary`,children:e.m})}),(0,X.jsx)(K,{className:`text-right`,children:(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-muted-foreground`,children:[(0,X.jsx)(k,{className:`size-3.5`}),` `,e.s]})}),(0,X.jsx)(K,{children:(0,X.jsx)(j,{variant:`ghost`,size:`icon`,"aria-label":`row actions`,children:(0,X.jsx)(N,{})})})]},e.n))})]})}),(0,X.jsx)(Q,{title:`App fragments`,description:`Chat-specific components`,children:(0,X.jsxs)(`div`,{className:`oc-show__row oc-show__row--col`,children:[(0,X.jsx)(`div`,{className:`oc-msg oc-msg--assistant`,children:(0,X.jsx)(`div`,{className:`oc-msg__body`,children:`Assistant message bubble.`})}),(0,X.jsx)(`div`,{className:`oc-tool oc-tool--completed`,children:(0,X.jsxs)(`div`,{className:`oc-tool__header`,children:[(0,X.jsx)(`span`,{className:`oc-tool__icon`,children:`✓`}),(0,X.jsx)(`span`,{className:`oc-tool__name`,children:`write-file`}),(0,X.jsx)(`span`,{className:`oc-tool__phase`,children:`completed`})]})}),(0,X.jsxs)(`div`,{className:`oc-run-status oc-run-status--streaming`,children:[(0,X.jsx)(`span`,{className:`oc-run-status__dot`}),(0,X.jsx)(`span`,{className:`oc-run-status__label`,children:`Running`})]})]})})]})]})}export{ln as ThemeShowroom};
@@ -1 +1 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{Av as r,Bi as i,Dv as a,Ev as o,Fv as s,Hi as c,Iv as l,Li as u,Mv as d,Nv as f,Ov as p,Pv as m,Ri as h,Tv as g,Ui as _,Vi as v,jv as y,kv as b,wv as x,zi as S}from"./api-BZGL-EQ1.js";import{t as C}from"./button-BfHR-QFa.js";import{Ht as w,Ut as T,Vt as E,Wt as D,ct as O,jt as k,kn as A,sn as j}from"./index-B8D00xNa.js";var M=t(e(),1),N={s:1e3,m:6e4,h:36e5,d:864e5,w:6048e5};function P(e,t){let n=e.trim();if(n===`now`)return t;let r=/^now-(\d+)([smhdw])$/.exec(n);if(r===null)return null;let i=Number(r[1]),a=N[r[2]];return!Number.isFinite(i)||a===void 0?null:t-i*a}function F(e,t=Date.now()){return e.kind===`absolute`?{from:e.from,to:e.to}:{from:P(e.from,t)??t-N.h,to:P(e.to,t)??t}}var I=[{label:l(),from:`now-5m`},{label:s(),from:`now-15m`},{label:m(),from:`now-30m`},{label:f(),from:`now-1h`},{label:d(),from:`now-3h`},{label:y(),from:`now-6h`},{label:r(),from:`now-12h`},{label:b(),from:`now-24h`},{label:p(),from:`now-2d`},{label:a(),from:`now-7d`},{label:o(),from:`now-30d`},{label:g(),from:`now-90d`},{label:x(),from:`now-520w`}];function L(e){return O(e,{day:`2-digit`,month:`2-digit`,hour:`2-digit`,minute:`2-digit`})}function R(e){if(e.kind===`relative`){let t=I.find(t=>t.from===e.from&&e.to===`now`);return t?t.label:`${e.from} → ${e.to}`}return`${L(e.from)} → ${L(e.to)}`}function z(e){let t=new Date(e),n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())}T${n(t.getHours())}:${n(t.getMinutes())}`}function B(e){if(e===``)return null;let t=new Date(e).getTime();return Number.isNaN(t)?null:t}function V(e){let t=e.trim();return t===`true`?!0:t===`false`?!1:t!==``&&Number.isFinite(Number(t))?Number(t):e}var H=n();function U(e){let[t,n]=(0,M.useState)(0);return(0,M.useEffect)(()=>{if(e.kind!==`relative`)return;let t=window.setInterval(()=>n(e=>e+1),3e4);return()=>window.clearInterval(t)},[e.kind]),(0,M.useMemo)(()=>{let{from:t,to:n}=F(e);return e.kind===`absolute`?{from:t,to:n}:{from:W(t),to:W(n)}},[e,t])}function W(e){return Math.floor(e/6e4)*6e4}function G({value:e,onChange:t}){let[n,r]=(0,M.useState)(!1),[a,o]=(0,M.useState)(``),s=F(e),[l,d]=(0,M.useState)(()=>z(s.from)),[f,p]=(0,M.useState)(()=>z(s.to));function m(t){if(t){let t=F(e);d(z(t.from)),p(z(t.to)),o(``)}r(t)}function g(e){t({kind:`relative`,from:e,to:`now`}),r(!1)}function y(){let e=B(l),n=B(f);e===null||n===null||(t({kind:`absolute`,from:e,to:n}),r(!1))}let b=(0,M.useMemo)(()=>{let e=a.trim().toLowerCase();return e===``?I:I.filter(t=>t.label.toLowerCase().includes(e)||t.from.toLowerCase().includes(e))},[a]),x=B(l)!==null&&B(f)!==null;return(0,H.jsxs)(T,{open:n,onOpenChange:m,children:[(0,H.jsx)(D,{asChild:!0,children:(0,H.jsxs)(C,{variant:`outline`,size:`sm`,className:`oc-timerange__trigger`,children:[(0,H.jsx)(A,{}),R(e)]})}),(0,H.jsx)(w,{children:(0,H.jsx)(E,{align:`end`,sideOffset:6,className:`oc-timerange__panel oc-overlay-layer rounded-lg border border-border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95`,children:(0,H.jsxs)(`div`,{className:`oc-timerange__cols`,children:[(0,H.jsxs)(`div`,{className:`oc-timerange__absolute`,children:[(0,H.jsx)(`div`,{className:`oc-timerange__section-title`,children:_()}),(0,H.jsxs)(`label`,{className:`oc-field`,children:[(0,H.jsx)(`span`,{className:`oc-field__label`,children:c()}),(0,H.jsx)(k,{type:`datetime-local`,value:l,onChange:e=>d(e.target.value)})]}),(0,H.jsxs)(`label`,{className:`oc-field`,children:[(0,H.jsx)(`span`,{className:`oc-field__label`,children:v()}),(0,H.jsx)(k,{type:`datetime-local`,value:f,onChange:e=>p(e.target.value)})]}),(0,H.jsx)(C,{size:`sm`,className:`oc-timerange__apply`,disabled:!x,onClick:y,children:i()})]}),(0,H.jsxs)(`div`,{className:`oc-timerange__relative`,children:[(0,H.jsxs)(`div`,{className:`oc-timerange__search`,children:[(0,H.jsx)(j,{className:`oc-timerange__search-icon`,"aria-hidden":!0}),(0,H.jsx)(k,{value:a,onChange:e=>o(e.target.value),placeholder:S(),"aria-label":h()})]}),(0,H.jsx)(`ul`,{className:`oc-timerange__list`,children:b.length===0?(0,H.jsx)(`li`,{className:`oc-timerange__empty`,children:u()}):b.map(t=>(0,H.jsx)(`li`,{children:(0,H.jsx)(`button`,{type:`button`,className:`oc-timerange__option`+(e.kind===`relative`&&e.from===t.from&&e.to===`now`?` is-active`:``),onClick:()=>g(t.from),children:t.label})},t.from))})]})]})})})]})}export{U as n,V as r,G as t};
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{Av as r,Bi as i,Dv as a,Ev as o,Fv as s,Hi as c,Iv as l,Li as u,Mv as d,Nv as f,Ov as p,Pv as m,Ri as h,Tv as g,Ui as _,Vi as v,jv as y,kv as b,wv as x,zi as S}from"./api-BASu8PYC.js";import{t as C}from"./button-_UzA03A_.js";import{Ht as w,Ut as T,Vt as E,Wt as D,ct as O,jt as k,kn as A,sn as j}from"./index-D02RwoOe.js";var M=t(e(),1),N={s:1e3,m:6e4,h:36e5,d:864e5,w:6048e5};function P(e,t){let n=e.trim();if(n===`now`)return t;let r=/^now-(\d+)([smhdw])$/.exec(n);if(r===null)return null;let i=Number(r[1]),a=N[r[2]];return!Number.isFinite(i)||a===void 0?null:t-i*a}function F(e,t=Date.now()){return e.kind===`absolute`?{from:e.from,to:e.to}:{from:P(e.from,t)??t-N.h,to:P(e.to,t)??t}}var I=[{label:l(),from:`now-5m`},{label:s(),from:`now-15m`},{label:m(),from:`now-30m`},{label:f(),from:`now-1h`},{label:d(),from:`now-3h`},{label:y(),from:`now-6h`},{label:r(),from:`now-12h`},{label:b(),from:`now-24h`},{label:p(),from:`now-2d`},{label:a(),from:`now-7d`},{label:o(),from:`now-30d`},{label:g(),from:`now-90d`},{label:x(),from:`now-520w`}];function L(e){return O(e,{day:`2-digit`,month:`2-digit`,hour:`2-digit`,minute:`2-digit`})}function R(e){if(e.kind===`relative`){let t=I.find(t=>t.from===e.from&&e.to===`now`);return t?t.label:`${e.from} → ${e.to}`}return`${L(e.from)} → ${L(e.to)}`}function z(e){let t=new Date(e),n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())}T${n(t.getHours())}:${n(t.getMinutes())}`}function B(e){if(e===``)return null;let t=new Date(e).getTime();return Number.isNaN(t)?null:t}function V(e){let t=e.trim();return t===`true`?!0:t===`false`?!1:t!==``&&Number.isFinite(Number(t))?Number(t):e}var H=n();function U(e){let[t,n]=(0,M.useState)(0);return(0,M.useEffect)(()=>{if(e.kind!==`relative`)return;let t=window.setInterval(()=>n(e=>e+1),3e4);return()=>window.clearInterval(t)},[e.kind]),(0,M.useMemo)(()=>{let{from:t,to:n}=F(e);return e.kind===`absolute`?{from:t,to:n}:{from:W(t),to:W(n)}},[e,t])}function W(e){return Math.floor(e/6e4)*6e4}function G({value:e,onChange:t}){let[n,r]=(0,M.useState)(!1),[a,o]=(0,M.useState)(``),s=F(e),[l,d]=(0,M.useState)(()=>z(s.from)),[f,p]=(0,M.useState)(()=>z(s.to));function m(t){if(t){let t=F(e);d(z(t.from)),p(z(t.to)),o(``)}r(t)}function g(e){t({kind:`relative`,from:e,to:`now`}),r(!1)}function y(){let e=B(l),n=B(f);e===null||n===null||(t({kind:`absolute`,from:e,to:n}),r(!1))}let b=(0,M.useMemo)(()=>{let e=a.trim().toLowerCase();return e===``?I:I.filter(t=>t.label.toLowerCase().includes(e)||t.from.toLowerCase().includes(e))},[a]),x=B(l)!==null&&B(f)!==null;return(0,H.jsxs)(T,{open:n,onOpenChange:m,children:[(0,H.jsx)(D,{asChild:!0,children:(0,H.jsxs)(C,{variant:`outline`,size:`sm`,className:`oc-timerange__trigger`,children:[(0,H.jsx)(A,{}),R(e)]})}),(0,H.jsx)(w,{children:(0,H.jsx)(E,{align:`end`,sideOffset:6,className:`oc-timerange__panel oc-overlay-layer rounded-lg border border-border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95`,children:(0,H.jsxs)(`div`,{className:`oc-timerange__cols`,children:[(0,H.jsxs)(`div`,{className:`oc-timerange__absolute`,children:[(0,H.jsx)(`div`,{className:`oc-timerange__section-title`,children:_()}),(0,H.jsxs)(`label`,{className:`oc-field`,children:[(0,H.jsx)(`span`,{className:`oc-field__label`,children:c()}),(0,H.jsx)(k,{type:`datetime-local`,value:l,onChange:e=>d(e.target.value)})]}),(0,H.jsxs)(`label`,{className:`oc-field`,children:[(0,H.jsx)(`span`,{className:`oc-field__label`,children:v()}),(0,H.jsx)(k,{type:`datetime-local`,value:f,onChange:e=>p(e.target.value)})]}),(0,H.jsx)(C,{size:`sm`,className:`oc-timerange__apply`,disabled:!x,onClick:y,children:i()})]}),(0,H.jsxs)(`div`,{className:`oc-timerange__relative`,children:[(0,H.jsxs)(`div`,{className:`oc-timerange__search`,children:[(0,H.jsx)(j,{className:`oc-timerange__search-icon`,"aria-hidden":!0}),(0,H.jsx)(k,{value:a,onChange:e=>o(e.target.value),placeholder:S(),"aria-label":h()})]}),(0,H.jsx)(`ul`,{className:`oc-timerange__list`,children:b.length===0?(0,H.jsx)(`li`,{className:`oc-timerange__empty`,children:u()}):b.map(t=>(0,H.jsx)(`li`,{children:(0,H.jsx)(`button`,{type:`button`,className:`oc-timerange__option`+(e.kind===`relative`&&e.from===t.from&&e.to===`now`?` is-active`:``),onClick:()=>g(t.from),children:t.label})},t.from))})]})]})})})]})}export{U as n,V as r,G as t};
@@ -1 +1 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{dI as r,fI as i,lI as a,uI as o}from"./api-BZGL-EQ1.js";import{t as s}from"./check-DVHDMfix.js";import{t as c}from"./chevrons-up-down-m0rvjPTx.js";import{Bt as l,Rt as u,jt as d,zt as f}from"./index-B8D00xNa.js";/* empty css */var p=t(e(),1);function m(e){if(e==null||e===``)return`none`;let t=e.trim().toLowerCase();return t===`ok`||t===`success`||t===`completed`?`ok`:t===`error`||t===`failed`||t===`failure`?`error`:t===`running`||t===`in_progress`||t===`pending`?`running`:`other`}function h(e){return e===!0?`active`:e===!1?`paused`:`unknown`}var g={q:``,state:`all`,result:`all`};function _(e){return e.q.trim()!==``||e.state!==`all`||e.result!==`all`}function v(e,t){let n=t.q.trim().toLowerCase();return!(n!==``&&!`${e.name??``} ${e.agentId}`.toLowerCase().includes(n)||t.state!==`all`&&h(e.enabled)!==t.state||t.result!==`all`&&m(e.lastRunStatus)!==t.result)}function y(){try{let e=Intl.supportedValuesOf;return typeof e==`function`?e(`timeZone`):[]}catch{return[]}}function b(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone??``}catch{return``}}function x(e,t,n=50,r){let i=e=>e.toLowerCase().replace(/[_/]+/g,` `),a=i(t.trim()),o=(a===``?e:e.filter(e=>i(e).includes(a))).slice(0,n);return r&&r!==``&&!o.includes(r)?[r,...o].slice(0,n):o}function S(e,t){let n=(new Date(e,t,1).getDay()+6)%7,r=new Date(e,t,1-n),i=[];for(let e=0;e<42;e++){let n=new Date(r.getFullYear(),r.getMonth(),r.getDate()+e);i.push({year:n.getFullYear(),month:n.getMonth(),day:n.getDate(),inMonth:n.getMonth()===t})}return i}function C(e,t,n,r,i){let a=(e,t=2)=>String(e).padStart(t,`0`);return`${a(e,4)}-${a(t+1)}-${a(n)}T${a(r)}:${a(i)}`}function w(e){let t=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})$/.exec(e);if(t===null)return null;let[,n,r,i,a,o]=t;return{year:Number(n),month:Number(r)-1,day:Number(i),hour:Number(a),minute:Number(o)}}var T=n();function E({value:e,onChange:t,className:n,fallbackTz:m}){let h=(0,p.useMemo)(()=>y(),[]),[g,_]=(0,p.useState)(!1),[v,S]=(0,p.useState)(``);if(h.length===0)return(0,T.jsx)(d,{value:e,onChange:e=>t(e.target.value),placeholder:m||b()||`America/Toronto`,className:n});let C=x(h,v,h.length,e||void 0),w=e===``?m||b()||a():e;return(0,T.jsxs)(u,{modal:!0,open:g,onOpenChange:e=>{_(e),e||S(``)},children:[(0,T.jsx)(l,{asChild:!0,children:(0,T.jsxs)(`button`,{type:`button`,className:`oc-tzcombo__trigger${n?` ${n}`:``}`,"aria-label":i(),children:[(0,T.jsx)(`span`,{className:`oc-tzcombo__value`,children:w}),(0,T.jsx)(c,{size:14,"aria-hidden":!0,className:`oc-tzcombo__chev`})]})}),(0,T.jsxs)(f,{align:`start`,className:`oc-tzcombo__pop p-0`,children:[(0,T.jsx)(d,{autoFocus:!0,value:v,onChange:e=>S(e.target.value),placeholder:r(),className:`oc-tzcombo__search`}),(0,T.jsx)(`div`,{className:`oc-tzcombo__list`,role:`listbox`,children:C.length===0?(0,T.jsx)(`p`,{className:`oc-tzcombo__empty`,children:o()}):C.map(n=>(0,T.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":n===e,className:`oc-tzcombo__opt`,onClick:()=>{t(n),_(!1),S(``)},children:[(0,T.jsx)(s,{size:13,"aria-hidden":!0,className:`oc-tzcombo__check`,style:{opacity:+(n===e)}}),(0,T.jsx)(`span`,{children:n})]},n))})]})]})}export{m as a,w as c,v as i,C as l,g as n,h as o,_ as r,S as s,E as t};
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{dI as r,fI as i,pI as a,uI as o}from"./api-BASu8PYC.js";import{t as s}from"./check-BVOFzT6U.js";import{t as c}from"./chevrons-up-down-DHCh-E-T.js";import{Bt as l,Rt as u,jt as d,zt as f}from"./index-D02RwoOe.js";/* empty css */var p=t(e(),1);function m(e){if(e==null||e===``)return`none`;let t=e.trim().toLowerCase();return t===`ok`||t===`success`||t===`completed`?`ok`:t===`error`||t===`failed`||t===`failure`?`error`:t===`running`||t===`in_progress`||t===`pending`?`running`:`other`}function h(e){return e===!0?`active`:e===!1?`paused`:`unknown`}var g={q:``,state:`all`,result:`all`};function _(e){return e.q.trim()!==``||e.state!==`all`||e.result!==`all`}function v(e,t){let n=t.q.trim().toLowerCase();return!(n!==``&&!`${e.name??``} ${e.agentId}`.toLowerCase().includes(n)||t.state!==`all`&&h(e.enabled)!==t.state||t.result!==`all`&&m(e.lastRunStatus)!==t.result)}function y(){try{let e=Intl.supportedValuesOf;return typeof e==`function`?e(`timeZone`):[]}catch{return[]}}function b(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone??``}catch{return``}}function x(e,t,n=50,r){let i=e=>e.toLowerCase().replace(/[_/]+/g,` `),a=i(t.trim()),o=(a===``?e:e.filter(e=>i(e).includes(a))).slice(0,n);return r&&r!==``&&!o.includes(r)?[r,...o].slice(0,n):o}function S(e,t){let n=(new Date(e,t,1).getDay()+6)%7,r=new Date(e,t,1-n),i=[];for(let e=0;e<42;e++){let n=new Date(r.getFullYear(),r.getMonth(),r.getDate()+e);i.push({year:n.getFullYear(),month:n.getMonth(),day:n.getDate(),inMonth:n.getMonth()===t})}return i}function C(e,t,n,r,i){let a=(e,t=2)=>String(e).padStart(t,`0`);return`${a(e,4)}-${a(t+1)}-${a(n)}T${a(r)}:${a(i)}`}function w(e){let t=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})$/.exec(e);if(t===null)return null;let[,n,r,i,a,o]=t;return{year:Number(n),month:Number(r)-1,day:Number(i),hour:Number(a),minute:Number(o)}}var T=n();function E({value:e,onChange:t,className:n,fallbackTz:m}){let h=(0,p.useMemo)(()=>y(),[]),[g,_]=(0,p.useState)(!1),[v,S]=(0,p.useState)(``);if(h.length===0)return(0,T.jsx)(d,{value:e,onChange:e=>t(e.target.value),placeholder:m||b()||`America/Toronto`,className:n});let C=x(h,v,h.length,e||void 0),w=e===``?m||b()||o():e;return(0,T.jsxs)(u,{modal:!0,open:g,onOpenChange:e=>{_(e),e||S(``)},children:[(0,T.jsx)(l,{asChild:!0,children:(0,T.jsxs)(`button`,{type:`button`,className:`oc-tzcombo__trigger${n?` ${n}`:``}`,"aria-label":a(),children:[(0,T.jsx)(`span`,{className:`oc-tzcombo__value`,children:w}),(0,T.jsx)(c,{size:14,"aria-hidden":!0,className:`oc-tzcombo__chev`})]})}),(0,T.jsxs)(f,{align:`start`,className:`oc-tzcombo__pop p-0`,children:[(0,T.jsx)(d,{autoFocus:!0,value:v,onChange:e=>S(e.target.value),placeholder:i(),className:`oc-tzcombo__search`}),(0,T.jsx)(`div`,{className:`oc-tzcombo__list`,role:`listbox`,children:C.length===0?(0,T.jsx)(`p`,{className:`oc-tzcombo__empty`,children:r()}):C.map(n=>(0,T.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":n===e,className:`oc-tzcombo__opt`,onClick:()=>{t(n),_(!1),S(``)},children:[(0,T.jsx)(s,{size:13,"aria-hidden":!0,className:`oc-tzcombo__check`,style:{opacity:+(n===e)}}),(0,T.jsx)(`span`,{children:n})]},n))})]})]})}export{m as a,w as c,v as i,C as l,g as n,h as o,_ as r,S as s,E as t};
@@ -1 +1 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$O as r,AO as i,Ax as a,BO as o,Br as s,Bx as c,CO as l,Cx as u,D as d,DO as f,Dx as p,EO as m,Ex as h,FO as g,Fx as _,GO as v,GR as y,HO as b,Hx as ee,IO as x,Ix as te,JO as S,KO as C,LO as w,Lx as ne,Mx as re,Nx as ie,OO as ae,Ox as oe,Px as se,QO as ce,RO as le,Rr as ue,Rx as de,SO as fe,Sx as pe,TO as T,Tx as me,UO as E,VO as D,Vx as he,WO as O,WR as k,XO as A,YO as j,ZO as M,_O as N,_x as ge,ak as _e,ax as ve,bO as P,bx as ye,cx as be,dx as xe,ek as F,fx as Se,gO as Ce,gx as we,hx as Te,ik as Ee,ix as De,jx as Oe,kO as ke,kx as Ae,lx as je,mx as Me,nk as Ne,ox as Pe,px as Fe,qO as I,rk as Ie,sx as Le,t as L,tk as Re,ux as ze,vO as Be,vx as Ve,wO as He,wx as Ue,xO as We,xx as Ge,yO as Ke,yx as qe,zO as Je,zr as Ye,zx as Xe}from"./api-BZGL-EQ1.js";import{t as Ze}from"./check-DVHDMfix.js";import{t as Qe}from"./x-DU13TyPG.js";import{i as R,n as z,r as $e,t as et}from"./tabs-BE-jtUDZ.js";import{t as B}from"./button-BfHR-QFa.js";import{$ as V,Et as H,Fn as tt,H as nt,On as rt,Pn as it,Q as U,Tn as at,X as W,Z as G,a as ot,at as st,ct as K,et as q,i as ct,lt,nt as ut,o as dt,ot as ft,q as pt,rt as mt,s as ht,tt as gt,xn as _t}from"./index-B8D00xNa.js";import{n as vt}from"./TimeRangePicker-C5oWQ1bV.js";import{t as yt}from"./FilterBar-D9hGs8jl.js";import{t as bt}from"./AdvancedFilter-BWRt6Typ.js";import{t as xt}from"./DataTableShell-BkZGrlHw.js";var St=d(`eye-off`,[[`path`,{d:`M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49`,key:`ct8e1f`}],[`path`,{d:`M14.084 14.158a3 3 0 0 1-4.242-4.242`,key:`151rxh`}],[`path`,{d:`M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143`,key:`13bj9a`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),Ct=d(`scroll-text`,[[`path`,{d:`M15 12h-5`,key:`r7krc0`}],[`path`,{d:`M15 8h-5`,key:`1khuty`}],[`path`,{d:`M19 17V5a2 2 0 0 0-2-2H4`,key:`zz82l3`}],[`path`,{d:`M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3`,key:`1ph1d7`}]]),J=t(e(),1),Y=n(),X={kind:`relative`,from:`now-520w`,to:`now`},Z=e=>e===null?`-`:String(Math.round(e));function wt(e){let t=e.indexOf(`:`);if(t<0)return e;let n=e.slice(0,t),r=e.slice(t+1);return n===`admin`?o():n===`agent`?`${Je()} - ${r}`:e}function Tt(){let e=y(L.me.getMe,{host:pt})?.role===`admin`,t=y(L.deliveryTiming.getDeliveryStatus,{}),n=k(L.deliveryTiming.startDeliveryRecord),r=k(L.deliveryTiming.stopDeliveryRecord),[i,a]=(0,J.useState)(!1),[o,s]=(0,J.useState)(!1),c=t?.recording??!1,l=async()=>{s(!0);try{c?await r({}):await n({})}finally{s(!1)}};return(0,Y.jsxs)(`section`,{className:`mb-4 flex flex-col gap-3 rounded-lg border border-border p-4`,children:[(0,Y.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h3`,{className:`text-sm font-semibold`,children:_e()}),(0,Y.jsx)(`p`,{className:`oc-admin__hint`,children:Ee()})]}),e?(0,Y.jsx)(B,{variant:c?`destructive`:`default`,size:`sm`,disabled:o||t===void 0,onClick:()=>void l(),children:c?Ne():Ie()}):null]}),c?(0,Y.jsxs)(`p`,{className:`flex items-center gap-2 text-sm`,children:[(0,Y.jsx)(H,{variant:`secondary`,children:Re()}),t?.startedAt?(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:F({time:lt(t.startedAt)})}):null]}):null,(0,Y.jsx)(`div`,{children:(0,Y.jsx)(B,{variant:`outline`,size:`sm`,onClick:()=>a(e=>!e),children:i?M():ce()})}),i?(0,Y.jsx)(Et,{isAdmin:e}):null]})}function Et({isAdmin:e}){let t=y(L.deliveryTiming.listDeliverySessions,{}),n=k(L.deliveryTiming.deleteDeliverySessions),[r,i]=(0,J.useState)(``),[a,o]=(0,J.useState)(`all`),[s,c]=(0,J.useState)(X),[l,u]=(0,J.useState)(null),{from:d,to:f}=vt(s),p=s.to===`now`?1/0:f,m=r.trim()!==``||a!==`all`||s!==X,h=()=>{i(``),o(`all`),c(X)},g=(0,J.useMemo)(()=>{if(t===void 0)return;let e=r.trim().toLowerCase();return t.filter(t=>(e===``||t.startedBy.toLowerCase().includes(e))&&(a===`all`||(a===`active`?t.active:!t.active))&&t.startedAt>=d&&t.startedAt<=p).map(e=>({...e,_id:e.sessionId}))},[t,r,a,d,p]),_=e=>{let t=new Set((g??[]).map(e=>e.sessionId)),r=e.filter(e=>t.has(e));r.length!==0&&(n({sessionIds:r}),l!==null&&r.includes(l)&&u(null))};return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Y.jsx)(yt,{q:r,onQChange:i,searchPlaceholder:j(),timeRange:s,onTimeRangeChange:c,onReset:h,canReset:m,children:(0,Y.jsxs)(W,{value:a,onValueChange:e=>o(e),children:[(0,Y.jsx)(V,{size:`sm`,className:`w-36`,children:(0,Y.jsx)(q,{})}),(0,Y.jsxs)(G,{children:[(0,Y.jsx)(U,{value:`all`,children:S()}),(0,Y.jsx)(U,{value:`active`,children:I()}),(0,Y.jsx)(U,{value:`stopped`,children:C()})]})]})}),(0,Y.jsx)(xt,{title:A(),rows:g,emptyHint:N(),columns:[{header:``,className:`w-8`,cell:e=>(0,Y.jsx)(B,{variant:`ghost`,size:`icon`,"aria-label":l===e.sessionId?w():le(),onClick:()=>u(t=>t===e.sessionId?null:e.sessionId),children:l===e.sessionId?(0,Y.jsx)(St,{size:15,"aria-hidden":!0}):(0,Y.jsx)(at,{size:15,"aria-hidden":!0})})},{header:v(),sort:e=>e.startedAt,cell:e=>(0,Y.jsx)(`span`,{className:`tabular-nums`,children:K(e.startedAt)})},{header:O(),sort:e=>e.stoppedAt,cell:e=>e.stoppedAt===null?(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:`-`}):(0,Y.jsx)(`span`,{className:`tabular-nums`,children:K(e.stoppedAt)})},{header:E(),sort:e=>e.count,cell:e=>(0,Y.jsx)(`span`,{className:`tabular-nums`,children:Z(e.count)})},{header:b(),sort:e=>e.startedBy,cell:e=>wt(e.startedBy)},{header:D(),sort:e=>e.active,cell:e=>e.active?(0,Y.jsx)(H,{variant:`secondary`,children:I()}):(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:C()})}],rowActions:e?e=>[{label:x(),variant:`destructive`,onSelect:()=>_([e.sessionId])}]:void 0,bulkActions:e?[{label:x(),variant:`destructive`,onSelect:e=>_(e)}]:void 0,isExpanded:e=>e.sessionId===l,renderExpanded:e=>(0,Y.jsx)(Dt,{sessionId:e.sessionId})})]})}function Dt({sessionId:e}){let t=y(L.deliveryTiming.getDeliveryReport,{sessionId:e}),[n,r]=(0,J.useState)(!1);return(0,Y.jsx)(Ot,{report:t,copied:n,onCopy:()=>{t&&navigator.clipboard?.writeText(nt(t)).then(()=>{r(!0),window.setTimeout(()=>r(!1),1200)}).catch(()=>{})}})}function Ot({report:e,copied:t,onCopy:n}){if(!e)return(0,Y.jsx)(`p`,{className:`oc-admin__hint`,children:g()});if(e.count===0||e.segments===null)return(0,Y.jsx)(`p`,{className:`oc-admin__hint`,children:r()});let i=e.segments,a=(e,t)=>(0,Y.jsxs)(`tr`,{className:`border-t border-border`,children:[(0,Y.jsx)(`td`,{className:`py-1`,children:e}),(0,Y.jsx)(`td`,{className:`py-1 text-right tabular-nums`,children:t.count}),(0,Y.jsxs)(`td`,{className:`py-1 text-right tabular-nums`,children:[Z(t.p50),` / `,Z(t.p95),` / `,Z(t.max)]})]});return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Y.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[e.count,` `,Ce()]}),(0,Y.jsxs)(B,{variant:`outline`,size:`sm`,onClick:n,children:[t?(0,Y.jsx)(Ze,{size:13,"aria-hidden":!0}):(0,Y.jsx)(rt,{size:13,"aria-hidden":!0}),t?Be():Ke()]})]}),(0,Y.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,Y.jsx)(`thead`,{children:(0,Y.jsxs)(`tr`,{className:`text-left text-muted-foreground`,children:[(0,Y.jsx)(`th`,{className:`py-1 font-medium`,children:ae()}),(0,Y.jsx)(`th`,{className:`py-1 text-right font-medium`,children:f()}),(0,Y.jsx)(`th`,{className:`py-1 text-right font-medium`,children:m()})]})}),(0,Y.jsxs)(`tbody`,{children:[a(T(),i.bridge),a(He(),i.A),a(l(),i.C)]})]}),(0,Y.jsx)(`p`,{className:`oc-admin__hint`,children:fe()}),e.truncated?(0,Y.jsx)(`p`,{className:`oc-admin__hint`,children:P()}):null,(0,Y.jsx)(`p`,{className:`oc-admin__hint`,children:We()})]})}var kt=[50,100,200,500],At=`all`,Q=`__all__`,jt=[`2xx`,`4xx`,`5xx`],Mt=[`user`,`service`,`system`],Nt=[`inbound`,`outbound`,`internal`],Pt={kind:`relative`,from:`now-30d`,to:`now`},Ft=[{value:`kind`,label:`kind`},{value:`status`,label:`status`},{value:`latencyMs`,label:s()},{value:`principalType`,label:Ye()},{value:`direction`,label:`direction`},{value:`roleKey`,label:ue()},{value:`route`,label:`route`},{value:`correlationId`,label:`correlationId`}];function It(){let e=tt({from:`/settings/traces`}),t=it({from:`/settings/traces`}),n=e.limit,r=e.kind,o=e.statusClass??Q,s=e.principalType??Q,l=e.direction??Q,d=e.roleKey??Q,f=e.q??``,m=ct(e.from,e.to),g=(0,J.useMemo)(()=>ht(e.adv),[e.adv]),{from:v,to:b}=vt(m),[x,S]=(0,J.useState)(null),[C,w]=(0,J.useState)(null),ae=e=>void t({search:t=>({...t,limit:e})}),ce=e=>void t({search:t=>({...t,kind:e})}),le=e=>void t({search:t=>({...t,q:e||void 0}),replace:!0}),ue=e=>void t({search:t=>({...t,statusClass:e===Q?void 0:e})}),fe=e=>void t({search:t=>({...t,principalType:e===Q?void 0:e})}),T=e=>void t({search:t=>({...t,direction:e===Q?void 0:e})}),E=e=>void t({search:t=>({...t,roleKey:e===Q?void 0:e})}),D=e=>void t({search:t=>({...t,...dt(e)})}),O=e=>void t({search:t=>({...t,adv:ot(e)}),replace:!0}),k=y(L.observability.listEvents,{limit:n}),A=y(L.observability.listEvents,{limit:n,kind:r===At?void 0:r,filter:{q:f||void 0,from:v,to:b,statusClass:o===Q?void 0:o,principalType:s===Q?void 0:s,direction:l===Q?void 0:l,roleKey:d===Q?void 0:d,advanced:g.length>0?g:void 0}}),j=(0,J.useMemo)(()=>{let e=new Set;for(let t of k??[])e.add(t.kind);return[...e].sort()},[k]),M=(0,J.useMemo)(()=>{let e=new Set;for(let t of k??[])t.roleKey&&e.add(t.roleKey);return[...e].sort()},[k]),N=f!==``||o!==Q||s!==Q||l!==Q||d!==Q||g.length>0||m.kind!==`relative`||m.from!==Pt.from;function _e(){t({search:{limit:100,kind:`all`},replace:!0})}let ve=x?k?.filter(e=>e.correlationId===x):A,P=e.section,F=e=>void t({search:t=>({...t,section:e}),replace:!0});return(0,Y.jsxs)(et,{value:P,onValueChange:e=>F(e),children:[(0,Y.jsxs)($e,{className:`w-full`,children:[(0,Y.jsxs)(R,{value:`latency`,className:`flex-1 gap-1.5`,children:[(0,Y.jsx)(_t,{size:13,"aria-hidden":!0}),i()]}),(0,Y.jsxs)(R,{value:`events`,className:`flex-1 gap-1.5`,children:[(0,Y.jsx)(Ct,{size:13,"aria-hidden":!0}),ke()]})]}),(0,Y.jsx)(z,{value:`latency`,children:(0,Y.jsx)(Tt,{})}),(0,Y.jsxs)(z,{value:`events`,className:`flex flex-col gap-3`,children:[(0,Y.jsxs)(`p`,{className:`oc-admin__hint`,children:[ee(),(0,Y.jsx)(`strong`,{children:he()}),c(),` `,(0,Y.jsx)(`span`,{className:`oc-filter__window`,children:Xe()})]}),(0,Y.jsxs)(yt,{q:f,onQChange:le,searchPlaceholder:de(),timeRange:m,onTimeRangeChange:D,onReset:_e,canReset:N,children:[(0,Y.jsxs)(W,{value:o,onValueChange:ue,children:[(0,Y.jsx)(V,{size:`sm`,className:`w-32`,children:(0,Y.jsx)(q,{placeholder:ne()})}),(0,Y.jsxs)(G,{children:[(0,Y.jsx)(U,{value:Q,children:te()}),jt.map(e=>(0,Y.jsx)(U,{value:e,children:e},e))]})]}),(0,Y.jsxs)(W,{value:s,onValueChange:fe,children:[(0,Y.jsx)(V,{size:`sm`,className:`w-32`,children:(0,Y.jsx)(q,{placeholder:_()})}),(0,Y.jsxs)(G,{children:[(0,Y.jsx)(U,{value:Q,children:se()}),Mt.map(e=>(0,Y.jsx)(U,{value:e,children:e},e))]})]}),(0,Y.jsxs)(W,{value:l,onValueChange:T,children:[(0,Y.jsx)(V,{size:`sm`,className:`w-32`,children:(0,Y.jsx)(q,{placeholder:ie()})}),(0,Y.jsxs)(G,{children:[(0,Y.jsx)(U,{value:Q,children:re()}),Nt.map(e=>(0,Y.jsx)(U,{value:e,children:e},e))]})]}),(0,Y.jsxs)(W,{value:d,onValueChange:E,children:[(0,Y.jsx)(V,{size:`sm`,className:`w-36`,children:(0,Y.jsx)(q,{placeholder:Oe()})}),(0,Y.jsxs)(G,{children:[(0,Y.jsx)(U,{value:Q,children:a()}),M.map(e=>(0,Y.jsx)(U,{value:e,children:e},e))]})]}),(0,Y.jsxs)(W,{value:r,onValueChange:ce,children:[(0,Y.jsx)(V,{size:`sm`,className:`w-44`,children:(0,Y.jsx)(q,{placeholder:Ae()})}),(0,Y.jsxs)(G,{children:[(0,Y.jsx)(U,{value:At,children:oe()}),j.map(e=>(0,Y.jsx)(U,{value:e,children:e},e))]})]}),(0,Y.jsxs)(W,{value:String(n),onValueChange:e=>ae(Number(e)),children:[(0,Y.jsx)(V,{size:`sm`,className:`w-28`,children:(0,Y.jsx)(q,{})}),(0,Y.jsx)(G,{children:kt.map(e=>(0,Y.jsx)(U,{value:String(e),children:p({count:e})},e))})]})]}),(0,Y.jsx)(bt,{fields:Ft,seed:g,onChange:O}),x?(0,Y.jsx)(`div`,{className:`oc-traces__followline`,children:(0,Y.jsxs)(`button`,{type:`button`,className:`oc-traces__chip`,onClick:()=>S(null),title:h(),children:[(0,Y.jsxs)(`span`,{className:`oc-traces__chip-label`,children:[me(),(0,Y.jsx)(`code`,{children:$(x)})]}),(0,Y.jsx)(Qe,{className:`oc-traces__chip-x`,"aria-hidden":!0}),(0,Y.jsx)(`span`,{className:`sr-only`,children:Ue()})]})}):null,(0,Y.jsx)(xt,{title:u(),rows:ve,emptyHint:x?pe():Ge(),columns:[{header:ye(),sort:e=>e.at,cell:e=>(0,Y.jsx)(`span`,{className:`oc-traces__time`,children:K(e.at)})},{header:qe(),sort:e=>e.kind,cell:e=>(0,Y.jsx)(H,{variant:`secondary`,children:e.kind})},{header:Ve(),sort:e=>Rt(e)??null,cell:e=>{let t=Rt(e);return t?(0,Y.jsxs)(`span`,{className:`oc-traces__fail`,title:t,children:[`✕ `,t]}):(0,Y.jsx)(`span`,{className:`oc-traces__ok`,"aria-label":ge(),children:`✓`})}},{header:we(),sort:e=>e.direction,cell:e=>e.direction?(0,Y.jsx)(H,{variant:`outline`,children:e.direction}):(0,Y.jsx)(`span`,{className:`oc-traces__muted`,children:`—`})},{header:Te(),sort:e=>e.principalType,cell:e=>(0,Y.jsxs)(`span`,{className:`oc-traces__principal`,children:[(0,Y.jsx)(H,{variant:`outline`,children:e.principalType}),e.principalId?(0,Y.jsx)(`code`,{className:`oc-traces__mono`,children:$(e.principalId)}):null]})},{header:Me(),sort:e=>e.roleKey,cell:e=>e.roleKey?(0,Y.jsx)(H,{variant:`secondary`,children:e.roleKey}):(0,Y.jsx)(`span`,{className:`oc-traces__muted`,children:`—`})},{header:Fe(),sort:e=>e.route,cell:e=>e.route?(0,Y.jsxs)(`span`,{className:`oc-traces__route`,children:[e.method?(0,Y.jsx)(`span`,{className:`oc-traces__method`,children:e.method}):null,(0,Y.jsx)(`code`,{className:`oc-traces__mono`,children:e.route})]}):(0,Y.jsx)(`span`,{className:`oc-traces__muted`,children:`—`})},{header:Se(),sort:e=>e.status,cell:e=>e.status===null?(0,Y.jsx)(`span`,{className:`oc-traces__muted`,children:`—`}):(0,Y.jsx)(`span`,{className:`oc-traces__status ${Lt(e.status)}`,children:e.status})},{header:xe(),sort:e=>e.latencyMs,cell:e=>e.latencyMs===null?(0,Y.jsx)(`span`,{className:`oc-traces__muted`,children:`—`}):(0,Y.jsxs)(`span`,{className:`oc-traces__mono`,children:[e.latencyMs,` ms`]})},{header:ze(),sort:e=>e.correlationId,cell:e=>e.correlationId?(0,Y.jsx)(`button`,{type:`button`,className:`oc-traces__corr`,title:je(),onClick:()=>S(e.correlationId),children:$(e.correlationId)}):(0,Y.jsx)(`span`,{className:`oc-traces__muted`,children:`—`})},{header:be(),sort:e=>+!!e.meta,cell:e=>e.meta?(0,Y.jsx)(B,{variant:`outline`,size:`sm`,onClick:()=>w(e),children:Le()}):(0,Y.jsx)(`span`,{className:`oc-traces__muted`,children:`—`})}]}),(0,Y.jsx)(zt,{row:C,onClose:()=>w(null)})]})]})}function Lt(e){return e>=500?`oc-traces__status--5xx`:e>=400?`oc-traces__status--4xx`:e>=200&&e<300?`oc-traces__status--2xx`:`oc-traces__status--other`}function $(e){return e.length>8?e.slice(0,8):e}function Rt(e){if(typeof e.status==`number`&&e.status>=400)return String(e.status);if(!e.meta)return null;try{let t=JSON.parse(e.meta);if(e.kind===`openclaw.dispatch`&&t.dispatchStatus===`failed`)return t.errorCode??`failed`;if(e.kind===`assistant.stream`&&t.phase===`finalize`&&(t.streamStatus===`error`||t.streamStatus===`aborted`))return t.streamStatus;if(e.kind===`openclaw.ingest.denied`)return`denied`}catch{}return null}function zt({row:e,onClose:t}){let n=(0,J.useMemo)(()=>{if(!e?.meta)return``;try{return JSON.stringify(JSON.parse(e.meta),null,2)}catch{return e.meta}},[e]);return(0,Y.jsx)(gt,{open:e!==null,onOpenChange:e=>{e||t()},children:e?(0,Y.jsxs)(ut,{className:`max-w-lg`,children:[(0,Y.jsxs)(st,{children:[(0,Y.jsxs)(ft,{className:`oc-traces__meta-title`,children:[Pe(),` `,(0,Y.jsx)(`code`,{children:e.kind}),(0,Y.jsx)(H,{variant:`outline`,children:ve()})]}),(0,Y.jsx)(mt,{children:De()})]}),(0,Y.jsx)(`pre`,{className:`oc-traces__meta-json`,children:n})]}):null})}export{It as TracesTab};
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$O as r,AO as i,Ax as a,BO as o,Br as s,Bx as c,CO as l,Cx as u,D as d,DO as f,Dx as p,EO as m,Ex as h,FO as g,Fx as _,GO as v,GR as y,HO as b,Hx as ee,IO as x,Ix as te,JO as S,KO as C,KR as w,LO as ne,Lx as re,Mx as ie,Nx as ae,OO as oe,Ox as se,Px as ce,QO as le,RO as ue,Rr as de,Rx as fe,SO as T,Sx as pe,TO as E,Tx as me,UO as D,VO as O,Vx as he,WO as k,XO as A,YO as j,ZO as M,_O as N,_x as ge,ak as _e,ax as ve,bO as P,bx as ye,cx as be,dx as xe,ek as F,fx as Se,gO as Ce,gx as we,hx as Te,ik as Ee,ix as De,jx as Oe,kO as ke,kx as Ae,lx as je,mx as Me,nk as Ne,ox as Pe,px as Fe,qO as I,rk as Ie,sx as Le,t as L,tk as Re,ux as ze,vO as Be,vx as Ve,wO as He,wx as Ue,xO as We,xx as Ge,yO as Ke,yx as qe,zO as Je,zr as Ye,zx as Xe}from"./api-BASu8PYC.js";import{t as Ze}from"./check-BVOFzT6U.js";import{t as Qe}from"./x-C5QQoypN.js";import{i as R,n as z,r as $e,t as et}from"./tabs-DkJ2Ivbq.js";import{t as B}from"./button-_UzA03A_.js";import{$ as V,Et as H,Fn as tt,H as nt,On as rt,Pn as it,Q as U,Tn as at,X as W,Z as G,a as ot,at as st,ct as K,et as q,i as ct,lt,nt as ut,o as dt,ot as ft,q as pt,rt as mt,s as ht,tt as gt,xn as _t}from"./index-D02RwoOe.js";import{n as vt}from"./TimeRangePicker-zbyQlb0G.js";import{t as yt}from"./FilterBar-BQxNZSAj.js";import{t as bt}from"./AdvancedFilter-oNVoBmr5.js";import{t as xt}from"./DataTableShell-BbVvH8AP.js";var St=d(`eye-off`,[[`path`,{d:`M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49`,key:`ct8e1f`}],[`path`,{d:`M14.084 14.158a3 3 0 0 1-4.242-4.242`,key:`151rxh`}],[`path`,{d:`M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143`,key:`13bj9a`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),Ct=d(`scroll-text`,[[`path`,{d:`M15 12h-5`,key:`r7krc0`}],[`path`,{d:`M15 8h-5`,key:`1khuty`}],[`path`,{d:`M19 17V5a2 2 0 0 0-2-2H4`,key:`zz82l3`}],[`path`,{d:`M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3`,key:`1ph1d7`}]]),J=t(e(),1),Y=n(),X={kind:`relative`,from:`now-520w`,to:`now`},Z=e=>e===null?`-`:String(Math.round(e));function wt(e){let t=e.indexOf(`:`);if(t<0)return e;let n=e.slice(0,t),r=e.slice(t+1);return n===`admin`?o():n===`agent`?`${Je()} - ${r}`:e}function Tt(){let e=w(L.me.getMe,{host:pt})?.role===`admin`,t=w(L.deliveryTiming.getDeliveryStatus,{}),n=y(L.deliveryTiming.startDeliveryRecord),r=y(L.deliveryTiming.stopDeliveryRecord),[i,a]=(0,J.useState)(!1),[o,s]=(0,J.useState)(!1),c=t?.recording??!1,l=async()=>{s(!0);try{c?await r({}):await n({})}finally{s(!1)}};return(0,Y.jsxs)(`section`,{className:`mb-4 flex flex-col gap-3 rounded-lg border border-border p-4`,children:[(0,Y.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h3`,{className:`text-sm font-semibold`,children:_e()}),(0,Y.jsx)(`p`,{className:`oc-admin__hint`,children:Ee()})]}),e?(0,Y.jsx)(B,{variant:c?`destructive`:`default`,size:`sm`,disabled:o||t===void 0,onClick:()=>void l(),children:c?Ne():Ie()}):null]}),c?(0,Y.jsxs)(`p`,{className:`flex items-center gap-2 text-sm`,children:[(0,Y.jsx)(H,{variant:`secondary`,children:Re()}),t?.startedAt?(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:F({time:lt(t.startedAt)})}):null]}):null,(0,Y.jsx)(`div`,{children:(0,Y.jsx)(B,{variant:`outline`,size:`sm`,onClick:()=>a(e=>!e),children:i?M():le()})}),i?(0,Y.jsx)(Et,{isAdmin:e}):null]})}function Et({isAdmin:e}){let t=w(L.deliveryTiming.listDeliverySessions,{}),n=y(L.deliveryTiming.deleteDeliverySessions),[r,i]=(0,J.useState)(``),[a,o]=(0,J.useState)(`all`),[s,c]=(0,J.useState)(X),[l,u]=(0,J.useState)(null),{from:d,to:f}=vt(s),p=s.to===`now`?1/0:f,m=r.trim()!==``||a!==`all`||s!==X,h=()=>{i(``),o(`all`),c(X)},g=(0,J.useMemo)(()=>{if(t===void 0)return;let e=r.trim().toLowerCase();return t.filter(t=>(e===``||t.startedBy.toLowerCase().includes(e))&&(a===`all`||(a===`active`?t.active:!t.active))&&t.startedAt>=d&&t.startedAt<=p).map(e=>({...e,_id:e.sessionId}))},[t,r,a,d,p]),_=e=>{let t=new Set((g??[]).map(e=>e.sessionId)),r=e.filter(e=>t.has(e));r.length!==0&&(n({sessionIds:r}),l!==null&&r.includes(l)&&u(null))};return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Y.jsx)(yt,{q:r,onQChange:i,searchPlaceholder:j(),timeRange:s,onTimeRangeChange:c,onReset:h,canReset:m,children:(0,Y.jsxs)(W,{value:a,onValueChange:e=>o(e),children:[(0,Y.jsx)(V,{size:`sm`,className:`w-36`,children:(0,Y.jsx)(q,{})}),(0,Y.jsxs)(G,{children:[(0,Y.jsx)(U,{value:`all`,children:S()}),(0,Y.jsx)(U,{value:`active`,children:I()}),(0,Y.jsx)(U,{value:`stopped`,children:C()})]})]})}),(0,Y.jsx)(xt,{title:A(),rows:g,emptyHint:N(),columns:[{header:``,className:`w-8`,cell:e=>(0,Y.jsx)(B,{variant:`ghost`,size:`icon`,"aria-label":l===e.sessionId?ne():ue(),onClick:()=>u(t=>t===e.sessionId?null:e.sessionId),children:l===e.sessionId?(0,Y.jsx)(St,{size:15,"aria-hidden":!0}):(0,Y.jsx)(at,{size:15,"aria-hidden":!0})})},{header:v(),sort:e=>e.startedAt,cell:e=>(0,Y.jsx)(`span`,{className:`tabular-nums`,children:K(e.startedAt)})},{header:k(),sort:e=>e.stoppedAt,cell:e=>e.stoppedAt===null?(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:`-`}):(0,Y.jsx)(`span`,{className:`tabular-nums`,children:K(e.stoppedAt)})},{header:D(),sort:e=>e.count,cell:e=>(0,Y.jsx)(`span`,{className:`tabular-nums`,children:Z(e.count)})},{header:b(),sort:e=>e.startedBy,cell:e=>wt(e.startedBy)},{header:O(),sort:e=>e.active,cell:e=>e.active?(0,Y.jsx)(H,{variant:`secondary`,children:I()}):(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:C()})}],rowActions:e?e=>[{label:x(),variant:`destructive`,onSelect:()=>_([e.sessionId])}]:void 0,bulkActions:e?[{label:x(),variant:`destructive`,onSelect:e=>_(e)}]:void 0,isExpanded:e=>e.sessionId===l,renderExpanded:e=>(0,Y.jsx)(Dt,{sessionId:e.sessionId})})]})}function Dt({sessionId:e}){let t=w(L.deliveryTiming.getDeliveryReport,{sessionId:e}),[n,r]=(0,J.useState)(!1);return(0,Y.jsx)(Ot,{report:t,copied:n,onCopy:()=>{t&&navigator.clipboard?.writeText(nt(t)).then(()=>{r(!0),window.setTimeout(()=>r(!1),1200)}).catch(()=>{})}})}function Ot({report:e,copied:t,onCopy:n}){if(!e)return(0,Y.jsx)(`p`,{className:`oc-admin__hint`,children:g()});if(e.count===0||e.segments===null)return(0,Y.jsx)(`p`,{className:`oc-admin__hint`,children:r()});let i=e.segments,a=(e,t)=>(0,Y.jsxs)(`tr`,{className:`border-t border-border`,children:[(0,Y.jsx)(`td`,{className:`py-1`,children:e}),(0,Y.jsx)(`td`,{className:`py-1 text-right tabular-nums`,children:t.count}),(0,Y.jsxs)(`td`,{className:`py-1 text-right tabular-nums`,children:[Z(t.p50),` / `,Z(t.p95),` / `,Z(t.max)]})]});return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Y.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[e.count,` `,Ce()]}),(0,Y.jsxs)(B,{variant:`outline`,size:`sm`,onClick:n,children:[t?(0,Y.jsx)(Ze,{size:13,"aria-hidden":!0}):(0,Y.jsx)(rt,{size:13,"aria-hidden":!0}),t?Be():Ke()]})]}),(0,Y.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,Y.jsx)(`thead`,{children:(0,Y.jsxs)(`tr`,{className:`text-left text-muted-foreground`,children:[(0,Y.jsx)(`th`,{className:`py-1 font-medium`,children:oe()}),(0,Y.jsx)(`th`,{className:`py-1 text-right font-medium`,children:f()}),(0,Y.jsx)(`th`,{className:`py-1 text-right font-medium`,children:m()})]})}),(0,Y.jsxs)(`tbody`,{children:[a(E(),i.bridge),a(He(),i.A),a(l(),i.C)]})]}),(0,Y.jsx)(`p`,{className:`oc-admin__hint`,children:T()}),e.truncated?(0,Y.jsx)(`p`,{className:`oc-admin__hint`,children:P()}):null,(0,Y.jsx)(`p`,{className:`oc-admin__hint`,children:We()})]})}var kt=[50,100,200,500],At=`all`,Q=`__all__`,jt=[`2xx`,`4xx`,`5xx`],Mt=[`user`,`service`,`system`],Nt=[`inbound`,`outbound`,`internal`],Pt={kind:`relative`,from:`now-30d`,to:`now`},Ft=[{value:`kind`,label:`kind`},{value:`status`,label:`status`},{value:`latencyMs`,label:s()},{value:`principalType`,label:Ye()},{value:`direction`,label:`direction`},{value:`roleKey`,label:de()},{value:`route`,label:`route`},{value:`correlationId`,label:`correlationId`}];function It(){let e=tt({from:`/settings/traces`}),t=it({from:`/settings/traces`}),n=e.limit,r=e.kind,o=e.statusClass??Q,s=e.principalType??Q,l=e.direction??Q,d=e.roleKey??Q,f=e.q??``,m=ct(e.from,e.to),g=(0,J.useMemo)(()=>ht(e.adv),[e.adv]),{from:v,to:y}=vt(m),[b,x]=(0,J.useState)(null),[S,C]=(0,J.useState)(null),ne=e=>void t({search:t=>({...t,limit:e})}),oe=e=>void t({search:t=>({...t,kind:e})}),le=e=>void t({search:t=>({...t,q:e||void 0}),replace:!0}),ue=e=>void t({search:t=>({...t,statusClass:e===Q?void 0:e})}),de=e=>void t({search:t=>({...t,principalType:e===Q?void 0:e})}),T=e=>void t({search:t=>({...t,direction:e===Q?void 0:e})}),E=e=>void t({search:t=>({...t,roleKey:e===Q?void 0:e})}),D=e=>void t({search:t=>({...t,...dt(e)})}),O=e=>void t({search:t=>({...t,adv:ot(e)}),replace:!0}),k=w(L.observability.listEvents,{limit:n}),A=w(L.observability.listEvents,{limit:n,kind:r===At?void 0:r,filter:{q:f||void 0,from:v,to:y,statusClass:o===Q?void 0:o,principalType:s===Q?void 0:s,direction:l===Q?void 0:l,roleKey:d===Q?void 0:d,advanced:g.length>0?g:void 0}}),j=(0,J.useMemo)(()=>{let e=new Set;for(let t of k??[])e.add(t.kind);return[...e].sort()},[k]),M=(0,J.useMemo)(()=>{let e=new Set;for(let t of k??[])t.roleKey&&e.add(t.roleKey);return[...e].sort()},[k]),N=f!==``||o!==Q||s!==Q||l!==Q||d!==Q||g.length>0||m.kind!==`relative`||m.from!==Pt.from;function _e(){t({search:{limit:100,kind:`all`},replace:!0})}let ve=b?k?.filter(e=>e.correlationId===b):A,P=e.section,F=e=>void t({search:t=>({...t,section:e}),replace:!0});return(0,Y.jsxs)(et,{value:P,onValueChange:e=>F(e),children:[(0,Y.jsxs)($e,{className:`w-full`,children:[(0,Y.jsxs)(R,{value:`latency`,className:`flex-1 gap-1.5`,children:[(0,Y.jsx)(_t,{size:13,"aria-hidden":!0}),i()]}),(0,Y.jsxs)(R,{value:`events`,className:`flex-1 gap-1.5`,children:[(0,Y.jsx)(Ct,{size:13,"aria-hidden":!0}),ke()]})]}),(0,Y.jsx)(z,{value:`latency`,children:(0,Y.jsx)(Tt,{})}),(0,Y.jsxs)(z,{value:`events`,className:`flex flex-col gap-3`,children:[(0,Y.jsxs)(`p`,{className:`oc-admin__hint`,children:[ee(),(0,Y.jsx)(`strong`,{children:he()}),c(),` `,(0,Y.jsx)(`span`,{className:`oc-filter__window`,children:Xe()})]}),(0,Y.jsxs)(yt,{q:f,onQChange:le,searchPlaceholder:fe(),timeRange:m,onTimeRangeChange:D,onReset:_e,canReset:N,children:[(0,Y.jsxs)(W,{value:o,onValueChange:ue,children:[(0,Y.jsx)(V,{size:`sm`,className:`w-32`,children:(0,Y.jsx)(q,{placeholder:re()})}),(0,Y.jsxs)(G,{children:[(0,Y.jsx)(U,{value:Q,children:te()}),jt.map(e=>(0,Y.jsx)(U,{value:e,children:e},e))]})]}),(0,Y.jsxs)(W,{value:s,onValueChange:de,children:[(0,Y.jsx)(V,{size:`sm`,className:`w-32`,children:(0,Y.jsx)(q,{placeholder:_()})}),(0,Y.jsxs)(G,{children:[(0,Y.jsx)(U,{value:Q,children:ce()}),Mt.map(e=>(0,Y.jsx)(U,{value:e,children:e},e))]})]}),(0,Y.jsxs)(W,{value:l,onValueChange:T,children:[(0,Y.jsx)(V,{size:`sm`,className:`w-32`,children:(0,Y.jsx)(q,{placeholder:ae()})}),(0,Y.jsxs)(G,{children:[(0,Y.jsx)(U,{value:Q,children:ie()}),Nt.map(e=>(0,Y.jsx)(U,{value:e,children:e},e))]})]}),(0,Y.jsxs)(W,{value:d,onValueChange:E,children:[(0,Y.jsx)(V,{size:`sm`,className:`w-36`,children:(0,Y.jsx)(q,{placeholder:Oe()})}),(0,Y.jsxs)(G,{children:[(0,Y.jsx)(U,{value:Q,children:a()}),M.map(e=>(0,Y.jsx)(U,{value:e,children:e},e))]})]}),(0,Y.jsxs)(W,{value:r,onValueChange:oe,children:[(0,Y.jsx)(V,{size:`sm`,className:`w-44`,children:(0,Y.jsx)(q,{placeholder:Ae()})}),(0,Y.jsxs)(G,{children:[(0,Y.jsx)(U,{value:At,children:se()}),j.map(e=>(0,Y.jsx)(U,{value:e,children:e},e))]})]}),(0,Y.jsxs)(W,{value:String(n),onValueChange:e=>ne(Number(e)),children:[(0,Y.jsx)(V,{size:`sm`,className:`w-28`,children:(0,Y.jsx)(q,{})}),(0,Y.jsx)(G,{children:kt.map(e=>(0,Y.jsx)(U,{value:String(e),children:p({count:e})},e))})]})]}),(0,Y.jsx)(bt,{fields:Ft,seed:g,onChange:O}),b?(0,Y.jsx)(`div`,{className:`oc-traces__followline`,children:(0,Y.jsxs)(`button`,{type:`button`,className:`oc-traces__chip`,onClick:()=>x(null),title:h(),children:[(0,Y.jsxs)(`span`,{className:`oc-traces__chip-label`,children:[me(),(0,Y.jsx)(`code`,{children:$(b)})]}),(0,Y.jsx)(Qe,{className:`oc-traces__chip-x`,"aria-hidden":!0}),(0,Y.jsx)(`span`,{className:`sr-only`,children:Ue()})]})}):null,(0,Y.jsx)(xt,{title:u(),rows:ve,emptyHint:b?pe():Ge(),columns:[{header:ye(),sort:e=>e.at,cell:e=>(0,Y.jsx)(`span`,{className:`oc-traces__time`,children:K(e.at)})},{header:qe(),sort:e=>e.kind,cell:e=>(0,Y.jsx)(H,{variant:`secondary`,children:e.kind})},{header:Ve(),sort:e=>Rt(e)??null,cell:e=>{let t=Rt(e);return t?(0,Y.jsxs)(`span`,{className:`oc-traces__fail`,title:t,children:[`✕ `,t]}):(0,Y.jsx)(`span`,{className:`oc-traces__ok`,"aria-label":ge(),children:`✓`})}},{header:we(),sort:e=>e.direction,cell:e=>e.direction?(0,Y.jsx)(H,{variant:`outline`,children:e.direction}):(0,Y.jsx)(`span`,{className:`oc-traces__muted`,children:`—`})},{header:Te(),sort:e=>e.principalType,cell:e=>(0,Y.jsxs)(`span`,{className:`oc-traces__principal`,children:[(0,Y.jsx)(H,{variant:`outline`,children:e.principalType}),e.principalId?(0,Y.jsx)(`code`,{className:`oc-traces__mono`,children:$(e.principalId)}):null]})},{header:Me(),sort:e=>e.roleKey,cell:e=>e.roleKey?(0,Y.jsx)(H,{variant:`secondary`,children:e.roleKey}):(0,Y.jsx)(`span`,{className:`oc-traces__muted`,children:`—`})},{header:Fe(),sort:e=>e.route,cell:e=>e.route?(0,Y.jsxs)(`span`,{className:`oc-traces__route`,children:[e.method?(0,Y.jsx)(`span`,{className:`oc-traces__method`,children:e.method}):null,(0,Y.jsx)(`code`,{className:`oc-traces__mono`,children:e.route})]}):(0,Y.jsx)(`span`,{className:`oc-traces__muted`,children:`—`})},{header:Se(),sort:e=>e.status,cell:e=>e.status===null?(0,Y.jsx)(`span`,{className:`oc-traces__muted`,children:`—`}):(0,Y.jsx)(`span`,{className:`oc-traces__status ${Lt(e.status)}`,children:e.status})},{header:xe(),sort:e=>e.latencyMs,cell:e=>e.latencyMs===null?(0,Y.jsx)(`span`,{className:`oc-traces__muted`,children:`—`}):(0,Y.jsxs)(`span`,{className:`oc-traces__mono`,children:[e.latencyMs,` ms`]})},{header:ze(),sort:e=>e.correlationId,cell:e=>e.correlationId?(0,Y.jsx)(`button`,{type:`button`,className:`oc-traces__corr`,title:je(),onClick:()=>x(e.correlationId),children:$(e.correlationId)}):(0,Y.jsx)(`span`,{className:`oc-traces__muted`,children:`—`})},{header:be(),sort:e=>+!!e.meta,cell:e=>e.meta?(0,Y.jsx)(B,{variant:`outline`,size:`sm`,onClick:()=>C(e),children:Le()}):(0,Y.jsx)(`span`,{className:`oc-traces__muted`,children:`—`})}]}),(0,Y.jsx)(zt,{row:S,onClose:()=>C(null)})]})]})}function Lt(e){return e>=500?`oc-traces__status--5xx`:e>=400?`oc-traces__status--4xx`:e>=200&&e<300?`oc-traces__status--2xx`:`oc-traces__status--other`}function $(e){return e.length>8?e.slice(0,8):e}function Rt(e){if(typeof e.status==`number`&&e.status>=400)return String(e.status);if(!e.meta)return null;try{let t=JSON.parse(e.meta);if(e.kind===`openclaw.dispatch`&&t.dispatchStatus===`failed`)return t.errorCode??`failed`;if(e.kind===`assistant.stream`&&t.phase===`finalize`&&(t.streamStatus===`error`||t.streamStatus===`aborted`))return t.streamStatus;if(e.kind===`openclaw.ingest.denied`)return`denied`}catch{}return null}function zt({row:e,onClose:t}){let n=(0,J.useMemo)(()=>{if(!e?.meta)return``;try{return JSON.stringify(JSON.parse(e.meta),null,2)}catch{return e.meta}},[e]);return(0,Y.jsx)(gt,{open:e!==null,onOpenChange:e=>{e||t()},children:e?(0,Y.jsxs)(ut,{className:`max-w-lg`,children:[(0,Y.jsxs)(st,{children:[(0,Y.jsxs)(ft,{className:`oc-traces__meta-title`,children:[Pe(),` `,(0,Y.jsx)(`code`,{children:e.kind}),(0,Y.jsx)(H,{variant:`outline`,children:ve()})]}),(0,Y.jsx)(mt,{children:De()})]}),(0,Y.jsx)(`pre`,{className:`oc-traces__meta-json`,children:n})]}):null})}export{It as TracesTab};
@@ -1 +1 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{AE as r,Ab as i,BT as a,CE as o,Cb as s,DE as c,Db as l,EE as u,Eb as d,GR as f,ME as p,NE as m,OE as h,Ob as g,SE as _,Sb as v,TE as ee,Tb as y,WR as b,_E as te,aE as ne,bE as x,bb as S,cE as re,dE as ie,df as C,fE as ae,ff as w,gE as oe,hE as T,jE as E,kE as D,kb as O,lE as se,mE as ce,oE as le,pE as ue,pf as k,sE as de,t as A,uE as fe,vE as pe,vb as j,wE as me,wb as M,xE as he,xb as N,yE as ge,yb as P}from"./api-BZGL-EQ1.js";import{t as F}from"./button-BfHR-QFa.js";import{$ as I,Dt as L,Et as R,Fn as _e,Ft as z,Lt as ve,Mt as ye,Nt as be,Pn as xe,Pt as Se,Q as B,U as Ce,W as we,X as V,Z as H,an as U,at as Te,c as W,et as G,l as Ee,nt as De,on as K,ot as Oe,q as ke,rt as Ae,tt as je,u as q,ut as J}from"./index-B8D00xNa.js";import{t as Y}from"./FilterBar-D9hGs8jl.js";import{t as Me}from"./DataTableShell-BkZGrlHw.js";import{t as Ne}from"./DetailChips-Cxppydov.js";var X=t(e(),1),Z=n();function Pe({profileId:e,userLabel:t,open:n,onOpenChange:r}){let a=f(A.agents.listAgentPoolForUser,n&&e?{profileId:e}:`skip`),o=f(A.agents.listUserAgents,n&&e?{profileId:e}:`skip`),c=new Set((o??[]).map(e=>`${e.instanceName}/${e.agentId}`)),u=(o??[]).find(e=>e.isDefault)??null,p=u?`${u.instanceName}/${u.agentId}`:null,m=new Set((a?.agents??[]).map(e=>`${e.instanceName}/${e.agentId}`)),h=[...(a?.agents??[]).map(e=>({...e,outOfPool:!1})),...(o??[]).filter(e=>!m.has(`${e.instanceName}/${e.agentId}`)).map(e=>({instanceName:e.instanceName,agentId:e.agentId,displayName:e.displayName,emoji:e.emoji,model:e.model,kind:e.kind,enabled:e.enabled,state:e.state,outOfPool:!0}))],_=new Map;for(let e of h){let t=_.get(e.instanceName)??[];t.push(e),_.set(e.instanceName,t)}return(0,Z.jsx)(je,{open:n,onOpenChange:r,children:(0,Z.jsxs)(De,{className:`oc-access`,children:[(0,Z.jsxs)(Te,{children:[(0,Z.jsx)(Oe,{children:i({user:t})}),(0,Z.jsx)(Ae,{children:O()})]}),a?(0,Z.jsx)(`p`,{className:`oc-access__hint`,children:a.inGroup?g():l()}):null,(0,Z.jsx)(`div`,{className:`oc-access__list`,children:a===void 0?(0,Z.jsx)(`p`,{className:`oc-access__hint`,children:d()}):h.length===0?(0,Z.jsx)(`p`,{className:`oc-access__hint`,children:s()}):[..._.entries()].map(([t,n])=>(0,Z.jsx)(Fe,{profileId:e,instanceName:t,kind:n[0].kind,agents:n,assigned:c,defaultKey:p},t))})]})})}function Fe({profileId:e,instanceName:t,kind:n,agents:r,assigned:i,defaultKey:a}){let o=b(A.agents.assignAgent),s=b(A.agents.removeAgent),c=b(A.agents.setDefaultAgent),l=L();if(!e)return null;async function u(n,r){try{r?await s({profileId:e,instanceName:t,agentId:n}):await o({profileId:e,instanceName:t,agentId:n})}catch(e){l.error(y(),e)}}async function d(n){try{await c({profileId:e,instanceName:t,agentId:n})}catch(e){l.error(M(),e)}}return(0,Z.jsxs)(`div`,{className:`oc-access__group`,children:[(0,Z.jsxs)(`div`,{className:`oc-access__instance`,children:[(0,Z.jsx)(K,{size:13,"aria-hidden":!0}),(0,Z.jsx)(`span`,{children:t}),(0,Z.jsx)(R,{variant:`outline`,className:`oc-access__kind`,children:n})]}),r.map(e=>{let n=`${t}/${e.agentId}`,r=i.has(n),o=a===n,s=e.state===`deleted`,c=!e.enabled;return(0,Z.jsxs)(`div`,{className:`oc-access__row${c?` is-disabled`:``}`,children:[(0,Z.jsx)(J,{checked:r,disabled:(s||c)&&!r,onCheckedChange:()=>void u(e.agentId,r),"aria-label":v({name:e.displayName??e.agentId})}),(0,Z.jsxs)(`span`,{className:`oc-access__label`,children:[e.emoji?`${e.emoji} `:``,e.displayName??e.agentId]}),e.model?(0,Z.jsx)(`span`,{className:`oc-access__model`,children:e.model}):null,s?(0,Z.jsx)(R,{variant:`outline`,className:`oc-access__gone`,children:N()}):null,e.outOfPool?(0,Z.jsx)(R,{variant:`outline`,className:`oc-access__gone`,children:S()}):null,r?o?(0,Z.jsx)(`span`,{className:`oc-access__fav`,role:`img`,"aria-label":P(),title:P(),children:(0,Z.jsx)(U,{size:14,fill:`currentColor`})}):(0,Z.jsx)(F,{type:`button`,size:`icon-sm`,variant:`ghost`,className:`oc-access__setdefault`,"aria-label":j(),title:j(),disabled:c,onClick:()=>void d(e.agentId),children:(0,Z.jsx)(U,{size:14})}):null]},e.agentId)})]})}var Q=`__all__`;function $(e){switch(e){case`pending`:return C();case`user`:return w();case`admin`:return k();default:return e}}function Ie({granted:e,onToggle:t}){let n=new Set(e),r=W.filter(e=>n.has(q[e])).length;return(0,Z.jsxs)(ye,{children:[(0,Z.jsx)(ve,{asChild:!0,children:(0,Z.jsx)(F,{variant:`outline`,size:`sm`,className:`h-8 w-36 justify-start font-normal`,children:r===0?m():p({count:r})})}),(0,Z.jsxs)(be,{align:`start`,className:`w-52`,children:[(0,Z.jsx)(z,{children:E()}),W.map(e=>{let r=q[e];return(0,Z.jsxs)(Se,{className:`gap-2`,onSelect:e=>{e.preventDefault(),t(r)},children:[(0,Z.jsx)(J,{checked:n.has(r),"aria-hidden":!0,tabIndex:-1,className:`pointer-events-none`}),(0,Z.jsx)(`span`,{children:Ee[e]()})]},e)})]})]})}function Le(){let e=_e({from:`/settings/users`}),t=xe({from:`/settings/users`}),n=e.q??``,i=e.role??Q,s=e=>void t({search:t=>({...t,q:e||void 0}),replace:!0}),l=e=>void t({search:t=>({...t,role:e===Q?void 0:e})}),d=f(A.admin.listUsers,{filter:{q:n||void 0,role:i===Q?void 0:i},withAgents:!0}),p=f(A.me.getMe,{host:ke}),m=b(A.admin.setRole),g=b(A.admin.setUserPermissions),v=b(A.admin.startImpersonation),y=b(A.admin.deleteUser),S=b(A.admin.setUserName),C=Ce(),w=we(),E=L(),[O,k]=(0,X.useState)(null),j=(0,X.useMemo)(()=>{let e=new Set([`pending`,`user`,`admin`]);for(let t of d??[])e.add(t.role);return[...e]},[d]),M=n!==``||i!==Q;function N(){t({search:{},replace:!0})}async function P(e){try{await m(e)}catch(e){E.error(r(),e)}}async function F(e){try{await g(e)}catch(e){E.error(D(),e)}}async function R(e){let t=e.email||e.name||e.canonical||e.userId.slice(0,8);if(await C({title:_(),description:he({user:t}),confirmWord:x(),confirmLabel:ge(),destructive:!0}))try{await y({profileId:e._id}),E.success(te({user:t}))}catch(e){E.error(pe(),e)}}async function z(e){let t=e.email||e.name||e.userId.slice(0,8),n=await w({title:T(),label:ce({user:t}),placeholder:ue(),defaultValue:e.name??``,confirmLabel:a()});if(n!==null)try{await S({profileId:e._id,name:n}),E.success(ae())}catch(e){E.error(ie(),e)}}return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Y,{q:n,onQChange:s,searchPlaceholder:h(),onReset:N,canReset:M,children:(0,Z.jsxs)(V,{value:i,onValueChange:l,children:[(0,Z.jsx)(I,{size:`sm`,className:`w-36`,children:(0,Z.jsx)(G,{})}),(0,Z.jsxs)(H,{children:[(0,Z.jsx)(B,{value:Q,children:c()}),j.map(e=>(0,Z.jsx)(B,{value:e,children:$(e)},e))]})]})}),(0,Z.jsx)(Me,{title:u(),rows:d,emptyHint:ee(),rowActions:e=>{let t=[{label:ne(),onSelect:()=>k({profileId:e._id,label:e.email||e.name||e.canonical||e.userId.slice(0,8)})},{label:oe(),onSelect:()=>void z(e)}];return e.userId!==p?.userId&&t.push({label:me(),onSelect:()=>void v({profileId:e._id})},{label:o(),variant:`destructive`,onSelect:()=>void R(e)}),t},columns:[{header:fe(),cell:e=>{let t=e.email||e.name||e.canonical||e.userId.slice(0,8),n=e.email&&e.name&&e.name!==e.email?e.name:null;return(0,Z.jsxs)(`div`,{className:`flex flex-col`,children:[(0,Z.jsx)(`span`,{children:t}),n?(0,Z.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:n}):null]})},sort:e=>e.email||e.name||e.canonical||e.userId},{header:se(),sort:e=>e.role===`admin`?2:+(e.role===`user`),cell:e=>(0,Z.jsxs)(V,{value:e.role,onValueChange:t=>void P({profileId:e._id,role:t}),children:[(0,Z.jsx)(I,{size:`sm`,className:`w-28`,children:(0,Z.jsx)(G,{})}),(0,Z.jsxs)(H,{children:[(0,Z.jsx)(B,{value:`pending`,children:$(`pending`)}),(0,Z.jsx)(B,{value:`user`,children:$(`user`)}),(0,Z.jsx)(B,{value:`admin`,children:$(`admin`)})]})]})},{header:re(),sort:e=>e.role===`admin`?9999:e.extraPermissions?.length??0,cell:e=>e.role===`admin`?(0,Z.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:de()}):(0,Z.jsx)(Ie,{granted:e.extraPermissions??[],onToggle:t=>{let n=new Set(e.extraPermissions??[]);n.has(t)?n.delete(t):n.add(t),F({profileId:e._id,permissions:[...n]})}})},{header:le(),cell:e=>(0,Z.jsx)(Ne,{icon:(0,Z.jsx)(K,{size:12,"aria-hidden":!0}),total:e.agentCount??0,items:e.agents.map(e=>({label:e}))}),sort:e=>e.agentCount??0}]}),(0,Z.jsx)(Pe,{profileId:O?.profileId??null,userLabel:O?.label??``,open:O!==null,onOpenChange:e=>{e||k(null)}})]})}export{Le as UsersTab};
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{AE as r,Ab as i,BT as a,CE as o,Cb as s,DE as c,Db as l,EE as u,Eb as d,GR as f,KR as p,ME as m,NE as h,OE as g,Ob as _,SE as ee,Sb as v,TE as te,Tb as y,_E as b,aE as x,bE as ne,bb as S,cE as re,dE as ie,df as C,fE as ae,ff as w,gE as T,hE as E,jE as D,kE as oe,kb as O,lE as se,mE as ce,oE as le,pE as ue,pf as k,sE as de,t as A,uE as fe,vE as pe,vb as j,wE as me,wb as M,xE as he,xb as N,yE as ge,yb as P}from"./api-BASu8PYC.js";import{t as F}from"./button-_UzA03A_.js";import{$ as I,Dt as L,Et as R,Fn as _e,Ft as z,Lt as ve,Mt as ye,Nt as be,Pn as xe,Pt as Se,Q as B,U as Ce,W as we,X as V,Z as H,an as U,at as Te,c as W,et as G,l as Ee,nt as De,on as K,ot as Oe,q as ke,rt as Ae,tt as je,u as q,ut as J}from"./index-D02RwoOe.js";import{t as Y}from"./FilterBar-BQxNZSAj.js";import{t as Me}from"./DataTableShell-BbVvH8AP.js";import{t as Ne}from"./DetailChips-CEPfBJ3C.js";var X=t(e(),1),Z=n();function Pe({profileId:e,userLabel:t,open:n,onOpenChange:r}){let a=p(A.agents.listAgentPoolForUser,n&&e?{profileId:e}:`skip`),o=p(A.agents.listUserAgents,n&&e?{profileId:e}:`skip`),c=new Set((o??[]).map(e=>`${e.instanceName}/${e.agentId}`)),u=(o??[]).find(e=>e.isDefault)??null,f=u?`${u.instanceName}/${u.agentId}`:null,m=new Set((a?.agents??[]).map(e=>`${e.instanceName}/${e.agentId}`)),h=[...(a?.agents??[]).map(e=>({...e,outOfPool:!1})),...(o??[]).filter(e=>!m.has(`${e.instanceName}/${e.agentId}`)).map(e=>({instanceName:e.instanceName,agentId:e.agentId,displayName:e.displayName,emoji:e.emoji,model:e.model,kind:e.kind,enabled:e.enabled,state:e.state,outOfPool:!0}))],g=new Map;for(let e of h){let t=g.get(e.instanceName)??[];t.push(e),g.set(e.instanceName,t)}return(0,Z.jsx)(je,{open:n,onOpenChange:r,children:(0,Z.jsxs)(De,{className:`oc-access`,children:[(0,Z.jsxs)(Te,{children:[(0,Z.jsx)(Oe,{children:i({user:t})}),(0,Z.jsx)(Ae,{children:O()})]}),a?(0,Z.jsx)(`p`,{className:`oc-access__hint`,children:a.inGroup?_():l()}):null,(0,Z.jsx)(`div`,{className:`oc-access__list`,children:a===void 0?(0,Z.jsx)(`p`,{className:`oc-access__hint`,children:d()}):h.length===0?(0,Z.jsx)(`p`,{className:`oc-access__hint`,children:s()}):[...g.entries()].map(([t,n])=>(0,Z.jsx)(Fe,{profileId:e,instanceName:t,kind:n[0].kind,agents:n,assigned:c,defaultKey:f},t))})]})})}function Fe({profileId:e,instanceName:t,kind:n,agents:r,assigned:i,defaultKey:a}){let o=f(A.agents.assignAgent),s=f(A.agents.removeAgent),c=f(A.agents.setDefaultAgent),l=L();if(!e)return null;async function u(n,r){try{r?await s({profileId:e,instanceName:t,agentId:n}):await o({profileId:e,instanceName:t,agentId:n})}catch(e){l.error(y(),e)}}async function d(n){try{await c({profileId:e,instanceName:t,agentId:n})}catch(e){l.error(M(),e)}}return(0,Z.jsxs)(`div`,{className:`oc-access__group`,children:[(0,Z.jsxs)(`div`,{className:`oc-access__instance`,children:[(0,Z.jsx)(K,{size:13,"aria-hidden":!0}),(0,Z.jsx)(`span`,{children:t}),(0,Z.jsx)(R,{variant:`outline`,className:`oc-access__kind`,children:n})]}),r.map(e=>{let n=`${t}/${e.agentId}`,r=i.has(n),o=a===n,s=e.state===`deleted`,c=!e.enabled;return(0,Z.jsxs)(`div`,{className:`oc-access__row${c?` is-disabled`:``}`,children:[(0,Z.jsx)(J,{checked:r,disabled:(s||c)&&!r,onCheckedChange:()=>void u(e.agentId,r),"aria-label":v({name:e.displayName??e.agentId})}),(0,Z.jsxs)(`span`,{className:`oc-access__label`,children:[e.emoji?`${e.emoji} `:``,e.displayName??e.agentId]}),e.model?(0,Z.jsx)(`span`,{className:`oc-access__model`,children:e.model}):null,s?(0,Z.jsx)(R,{variant:`outline`,className:`oc-access__gone`,children:N()}):null,e.outOfPool?(0,Z.jsx)(R,{variant:`outline`,className:`oc-access__gone`,children:S()}):null,r?o?(0,Z.jsx)(`span`,{className:`oc-access__fav`,role:`img`,"aria-label":P(),title:P(),children:(0,Z.jsx)(U,{size:14,fill:`currentColor`})}):(0,Z.jsx)(F,{type:`button`,size:`icon-sm`,variant:`ghost`,className:`oc-access__setdefault`,"aria-label":j(),title:j(),disabled:c,onClick:()=>void d(e.agentId),children:(0,Z.jsx)(U,{size:14})}):null]},e.agentId)})]})}var Q=`__all__`;function $(e){switch(e){case`pending`:return C();case`user`:return w();case`admin`:return k();default:return e}}function Ie({granted:e,onToggle:t}){let n=new Set(e),r=W.filter(e=>n.has(q[e])).length;return(0,Z.jsxs)(ye,{children:[(0,Z.jsx)(ve,{asChild:!0,children:(0,Z.jsx)(F,{variant:`outline`,size:`sm`,className:`h-8 w-36 justify-start font-normal`,children:r===0?h():m({count:r})})}),(0,Z.jsxs)(be,{align:`start`,className:`w-52`,children:[(0,Z.jsx)(z,{children:D()}),W.map(e=>{let r=q[e];return(0,Z.jsxs)(Se,{className:`gap-2`,onSelect:e=>{e.preventDefault(),t(r)},children:[(0,Z.jsx)(J,{checked:n.has(r),"aria-hidden":!0,tabIndex:-1,className:`pointer-events-none`}),(0,Z.jsx)(`span`,{children:Ee[e]()})]},e)})]})]})}function Le(){let e=_e({from:`/settings/users`}),t=xe({from:`/settings/users`}),n=e.q??``,i=e.role??Q,s=e=>void t({search:t=>({...t,q:e||void 0}),replace:!0}),l=e=>void t({search:t=>({...t,role:e===Q?void 0:e})}),d=p(A.admin.listUsers,{filter:{q:n||void 0,role:i===Q?void 0:i},withAgents:!0}),m=p(A.me.getMe,{host:ke}),h=f(A.admin.setRole),_=f(A.admin.setUserPermissions),v=f(A.admin.startImpersonation),y=f(A.admin.deleteUser),S=f(A.admin.setUserName),C=Ce(),w=we(),D=L(),[O,k]=(0,X.useState)(null),j=(0,X.useMemo)(()=>{let e=new Set([`pending`,`user`,`admin`]);for(let t of d??[])e.add(t.role);return[...e]},[d]),M=n!==``||i!==Q;function N(){t({search:{},replace:!0})}async function P(e){try{await h(e)}catch(e){D.error(r(),e)}}async function F(e){try{await _(e)}catch(e){D.error(oe(),e)}}async function R(e){let t=e.email||e.name||e.canonical||e.userId.slice(0,8);if(await C({title:ee(),description:he({user:t}),confirmWord:ne(),confirmLabel:ge(),destructive:!0}))try{await y({profileId:e._id}),D.success(b({user:t}))}catch(e){D.error(pe(),e)}}async function z(e){let t=e.email||e.name||e.userId.slice(0,8),n=await w({title:E(),label:ce({user:t}),placeholder:ue(),defaultValue:e.name??``,confirmLabel:a()});if(n!==null)try{await S({profileId:e._id,name:n}),D.success(ae())}catch(e){D.error(ie(),e)}}return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Y,{q:n,onQChange:s,searchPlaceholder:g(),onReset:N,canReset:M,children:(0,Z.jsxs)(V,{value:i,onValueChange:l,children:[(0,Z.jsx)(I,{size:`sm`,className:`w-36`,children:(0,Z.jsx)(G,{})}),(0,Z.jsxs)(H,{children:[(0,Z.jsx)(B,{value:Q,children:c()}),j.map(e=>(0,Z.jsx)(B,{value:e,children:$(e)},e))]})]})}),(0,Z.jsx)(Me,{title:u(),rows:d,emptyHint:te(),rowActions:e=>{let t=[{label:x(),onSelect:()=>k({profileId:e._id,label:e.email||e.name||e.canonical||e.userId.slice(0,8)})},{label:T(),onSelect:()=>void z(e)}];return e.userId!==m?.userId&&t.push({label:me(),onSelect:()=>void v({profileId:e._id})},{label:o(),variant:`destructive`,onSelect:()=>void R(e)}),t},columns:[{header:fe(),cell:e=>{let t=e.email||e.name||e.canonical||e.userId.slice(0,8),n=e.email&&e.name&&e.name!==e.email?e.name:null;return(0,Z.jsxs)(`div`,{className:`flex flex-col`,children:[(0,Z.jsx)(`span`,{children:t}),n?(0,Z.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:n}):null]})},sort:e=>e.email||e.name||e.canonical||e.userId},{header:se(),sort:e=>e.role===`admin`?2:+(e.role===`user`),cell:e=>(0,Z.jsxs)(V,{value:e.role,onValueChange:t=>void P({profileId:e._id,role:t}),children:[(0,Z.jsx)(I,{size:`sm`,className:`w-28`,children:(0,Z.jsx)(G,{})}),(0,Z.jsxs)(H,{children:[(0,Z.jsx)(B,{value:`pending`,children:$(`pending`)}),(0,Z.jsx)(B,{value:`user`,children:$(`user`)}),(0,Z.jsx)(B,{value:`admin`,children:$(`admin`)})]})]})},{header:re(),sort:e=>e.role===`admin`?9999:e.extraPermissions?.length??0,cell:e=>e.role===`admin`?(0,Z.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:de()}):(0,Z.jsx)(Ie,{granted:e.extraPermissions??[],onToggle:t=>{let n=new Set(e.extraPermissions??[]);n.has(t)?n.delete(t):n.add(t),F({profileId:e._id,permissions:[...n]})}})},{header:le(),cell:e=>(0,Z.jsx)(Ne,{icon:(0,Z.jsx)(K,{size:12,"aria-hidden":!0}),total:e.agentCount??0,items:e.agents.map(e=>({label:e}))}),sort:e=>e.agentCount??0}]}),(0,Z.jsx)(Pe,{profileId:O?.profileId??null,userLabel:O?.label??``,open:O!==null,onOpenChange:e=>{e||k(null)}})]})}export{Le as UsersTab};
@@ -0,0 +1 @@
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$n as r,At as i,Bn as a,Bt as o,Fn as s,Ft as c,GR as l,Gn as ee,Hn as u,Ht as d,In as f,It as p,Jn as m,KR as h,Kn as g,LD as _,LR as v,Ln as y,Nt as te,Ot as ne,Pt as re,Qn as b,Rn as x,Td as S,UR as ie,Un as C,Ut as w,Vn as T,Vt as ae,Wn as oe,Xn as se,Xt as ce,Yn as le,Zn as E,ar as ue,er as D,eu as de,gt as fe,ir as pe,jt as O,kt as me,nr as k,nu as A,qn as j,rr as M,t as N,tr as P,zR as F,zn as I,zt as L}from"./api-BASu8PYC.js";import{i as R,n as z,r as he,t as B}from"./tabs-DkJ2Ivbq.js";import{t as V}from"./button-_UzA03A_.js";import{$ as H,$t as U,Et as W,Fn as ge,Jt as _e,Nn as ve,Pn as ye,Q as G,Qt as K,X as q,Xt as be,Yt as xe,Z as J,Zt as Se,en as Ce,et as Y,gn as we,nn as Te,q as Ee,ut as X}from"./index-D02RwoOe.js";/* empty css */var Z=t(e(),1),Q=n(),De=[[`auto`,()=>b()],[`fr-FR`,()=>w()],[`en-US`,()=>d()],[`en-GB`,()=>ae()],[`de-DE`,()=>o()],[`es-ES`,()=>L()]],Oe=[[`0.75`,()=>se()],[`1`,()=>le()],[`1.25`,()=>m()],[`1.5`,()=>j()]],$=0;function ke({instance:e}){let t=l(N.admin.upsertInstanceConfig),n=e.config??{},a={enabled:n.voiceEnabled===!0,engine:n.voiceEngine===`gateway`?`gateway`:`browser`,lang:typeof n.voiceLang==`string`?n.voiceLang:`auto`,rate:typeof n.voiceRate==`number`?String(n.voiceRate):`1`,autoRead:n.voiceAutoRead===!0},[o,s]=(0,Z.useState)(a),[c,d]=(0,Z.useState)(`idle`),[f,p]=(0,Z.useState)(!1),[m,h]=(0,Z.useState)(!1),_=ie(N.voice.gatewayTtsPreview);(0,Z.useEffect)(()=>{s({enabled:n.voiceEnabled===!0,engine:n.voiceEngine===`gateway`?`gateway`:`browser`,lang:typeof n.voiceLang==`string`?n.voiceLang:`auto`,rate:typeof n.voiceRate==`number`?String(n.voiceRate):`1`,autoRead:n.voiceAutoRead===!0}),d(`idle`)},[e._id]);let v=o.enabled!==a.enabled||o.engine!==a.engine||o.lang!==a.lang||o.rate!==a.rate||o.autoRead!==a.autoRead;async function y(){d(`saving`);try{let n={...e.config??{}};n.voiceEnabled=o.enabled,o.engine===`gateway`?n.voiceEngine=`gateway`:delete n.voiceEngine,o.lang===`auto`?delete n.voiceLang:n.voiceLang=o.lang;let r=Number.parseFloat(o.rate);!Number.isFinite(r)||r===1?delete n.voiceRate:n.voiceRate=r,o.autoRead?n.voiceAutoRead=!0:delete n.voiceAutoRead,await t({instanceId:e._id,config:n}),d(`idle`)}catch{d(`error`)}}return(0,Q.jsxs)(`section`,{className:`oc-voice__card`,children:[(0,Q.jsxs)(`header`,{className:`oc-voice__cardhead`,children:[(0,Q.jsx)(`span`,{className:`oc-voice__instance`,children:e.name}),(0,Q.jsx)(W,{variant:`secondary`,children:e.kind===`hermes`?`Hermes`:`OpenClaw`})]}),(0,Q.jsxs)(`label`,{className:`oc-cdefaults__inline`,style:{cursor:`pointer`},children:[(0,Q.jsx)(X,{checked:o.enabled,onCheckedChange:e=>s({...o,enabled:e===!0}),"aria-label":D()}),(0,Q.jsx)(`span`,{className:`oc-cdefaults__label`,children:D()})]}),(0,Q.jsxs)(`div`,{className:`oc-voice__row`,children:[(0,Q.jsx)(`span`,{className:`oc-cdefaults__label`,children:O()}),(0,Q.jsxs)(q,{value:o.engine,onValueChange:e=>s({...o,engine:e}),disabled:!o.enabled,children:[(0,Q.jsx)(H,{size:`sm`,"aria-label":O(),children:(0,Q.jsx)(Y,{})}),(0,Q.jsxs)(J,{children:[(0,Q.jsx)(G,{value:`browser`,children:i()}),e.kind===`hermes`?null:(0,Q.jsx)(G,{value:`gateway`,children:me()})]})]})]}),o.engine===`gateway`?(0,Q.jsx)(`p`,{className:`oc-cdefaults__help`,children:ne()}):null,o.engine===`gateway`?null:(0,Q.jsxs)(`div`,{className:`oc-voice__row`,children:[(0,Q.jsx)(`span`,{className:`oc-cdefaults__label`,children:r()}),(0,Q.jsxs)(q,{value:o.lang,onValueChange:e=>s({...o,lang:e}),disabled:!o.enabled,children:[(0,Q.jsx)(H,{size:`sm`,"aria-label":r(),children:(0,Q.jsx)(Y,{})}),(0,Q.jsx)(J,{children:De.map(([e,t])=>(0,Q.jsx)(G,{value:e,children:t()},e))})]})]}),(0,Q.jsxs)(`div`,{className:`oc-voice__row`,children:[(0,Q.jsx)(`span`,{className:`oc-cdefaults__label`,children:E()}),(0,Q.jsxs)(q,{value:o.rate,onValueChange:e=>s({...o,rate:e}),disabled:!o.enabled,children:[(0,Q.jsx)(H,{size:`sm`,"aria-label":E(),children:(0,Q.jsx)(Y,{})}),(0,Q.jsx)(J,{children:Oe.map(([e,t])=>(0,Q.jsx)(G,{value:e,children:t()},e))})]})]}),o.engine===`gateway`?null:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`label`,{className:`oc-cdefaults__inline`,style:{cursor:`pointer`},children:[(0,Q.jsx)(X,{checked:o.autoRead,onCheckedChange:e=>s({...o,autoRead:e===!0}),disabled:!o.enabled,"aria-label":g()}),(0,Q.jsx)(`span`,{className:`oc-cdefaults__label`,children:g()})]}),(0,Q.jsx)(`p`,{className:`oc-cdefaults__help`,children:ee()})]}),(0,Q.jsxs)(`div`,{className:`oc-cdefaults__inline`,children:[(0,Q.jsx)(V,{size:`sm`,disabled:!v||c===`saving`,onClick:()=>void y(),children:c===`saving`?S():A()}),(0,Q.jsx)(V,{variant:`outline`,size:`sm`,disabled:!o.enabled||f,onClick:()=>{let t=Number.parseFloat(o.rate)||1,n=++$;if(h(!1),U(),K(),o.engine!==`gateway`){Se(u(),{lang:be(o.lang,F()),rate:t});return}p(!0),_({instanceName:e.name,text:u()}).then(({mime:e,audioBase64:r})=>{n===$&&xe(r,e,{rate:t})}).catch(()=>{n===$&&h(!0)}).finally(()=>p(!1))},children:f?S():oe()}),(0,Q.jsx)(V,{variant:`ghost`,size:`sm`,onClick:()=>{$++,p(!1),U(),K()},children:C()})]}),c===`error`||m?(0,Q.jsx)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:m?fe():de()}):null]})}function Ae({stt:e}){let t=h(N.me.getMe,{host:Ee}),n=l(N.admin.setFeatureEnabled),r=t?.ui?.featuresEnabled?.voiceInput===!0,i=t?.role===`admin`;return(0,Q.jsxs)(`section`,{className:`oc-voice__card`,children:[(0,Q.jsxs)(`header`,{className:`oc-voice__cardhead`,children:[(0,Q.jsx)(`span`,{className:`oc-voice__instance`,children:a()}),(0,Q.jsx)(W,{variant:e?`secondary`:`outline`,children:e?f():s()}),(0,Q.jsx)(W,{variant:r?`secondary`:`destructive`,children:r?c():re()})]}),i?(0,Q.jsxs)(`label`,{className:`oc-cdefaults__inline`,style:{cursor:`pointer`},children:[(0,Q.jsx)(X,{checked:r,onCheckedChange:e=>void n({key:`voiceInput`,enabled:e===!0}),"aria-label":p()}),(0,Q.jsx)(`span`,{className:`oc-cdefaults__label`,children:p()})]}):null,(0,Q.jsx)(`p`,{className:`oc-cdefaults__help`,children:I()})]})}function je(){let e=h(N.admin.listInstances,{}),t=(0,Z.useMemo)(()=>Ce(),[]),n=(0,Z.useMemo)(()=>_e(),[]),{section:r}=ge({from:`/settings/voice`}),i=ye({from:`/settings/voice`});return(0,Q.jsxs)(`div`,{className:`oc-admin__tab oc-voice`,children:[(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:ue()}),(0,Q.jsxs)(`div`,{className:`oc-voice__support`,children:[(0,Q.jsx)(W,{variant:t?`secondary`:`destructive`,children:t?pe():M()}),(0,Q.jsx)(W,{variant:n?`secondary`:`destructive`,children:n?k():P()})]}),(0,Q.jsxs)(B,{value:r,onValueChange:e=>void i({search:{section:e},replace:!0}),children:[(0,Q.jsxs)(he,{className:`w-full`,children:[(0,Q.jsxs)(R,{value:`readaloud`,className:`flex-1 gap-1.5`,children:[(0,Q.jsx)(Te,{size:13,"aria-hidden":!0}),te()]}),(0,Q.jsxs)(R,{value:`dictation`,className:`flex-1 gap-1.5`,children:[(0,Q.jsx)(we,{size:13,"aria-hidden":!0}),a()]}),(0,Q.jsxs)(R,{value:`talk`,className:`flex-1 gap-1.5`,children:[(0,Q.jsx)(ve,{size:13,"aria-hidden":!0}),x()]})]}),(0,Q.jsx)(z,{value:`readaloud`,children:e===void 0?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:v()}):e.length===0?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:T()}):e.map(e=>(0,Q.jsx)(ke,{instance:e},e._id))}),(0,Q.jsx)(z,{value:`dictation`,children:(0,Q.jsx)(Ae,{stt:n})}),(0,Q.jsxs)(z,{value:`talk`,children:[(0,Q.jsxs)(`section`,{className:`oc-voice__card`,children:[(0,Q.jsx)(`header`,{className:`oc-voice__cardhead`,children:(0,Q.jsx)(`span`,{className:`oc-voice__instance`,children:x()})}),(0,Q.jsx)(`p`,{className:`oc-cdefaults__help`,children:y()})]}),e===void 0?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:v()}):e.length===0?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:T()}):e.map(e=>(0,Q.jsx)(Me,{instance:e},e._id))]})]})]})}function Me({instance:e}){let t=l(N.admin.upsertInstanceConfig),n=e.config??{},r=n.talkEnabled===!0,i=e.kind===`hermes`;return(0,Q.jsxs)(`section`,{className:`oc-voice__card`,children:[(0,Q.jsxs)(`header`,{className:`oc-voice__cardhead`,children:[(0,Q.jsx)(`span`,{className:`oc-voice__instance`,children:e.name}),(0,Q.jsx)(W,{variant:`secondary`,children:i?`Hermes`:`OpenClaw`})]}),i?(0,Q.jsx)(`p`,{className:`oc-cdefaults__help`,children:ce()}):(0,Q.jsxs)(`label`,{className:`oc-cdefaults__inline`,style:{cursor:`pointer`},children:[(0,Q.jsx)(X,{checked:r,onCheckedChange:r=>{let i={...n};r===!0?i.talkEnabled=!0:delete i.talkEnabled,t({instanceId:e._id,config:i})},"aria-label":_()}),(0,Q.jsx)(`span`,{className:`oc-cdefaults__label`,children:_()})]})]})}export{je as VoiceTab};