@lacneu/atrium 0.91.3 → 0.91.4

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 (58) hide show
  1. package/dist/assets/{AccessTab-B7Qb2-lZ.js → AccessTab-CtjTuJS1.js} +1 -1
  2. package/dist/assets/{AdvancedFilter-Bm0I1TOa.js → AdvancedFilter-BFXkHS7k.js} +1 -1
  3. package/dist/assets/{AgentFilesTab-CK7t36QE.js → AgentFilesTab-EIaok7Cs.js} +1 -1
  4. package/dist/assets/{AnomaliesTab-PBcXokbs.js → AnomaliesTab-D1h-Tspq.js} +1 -1
  5. package/dist/assets/{AuditTab-DVjMAHXs.js → AuditTab-CEji-XO8.js} +1 -1
  6. package/dist/assets/{BridgeTab-Dt95NA_7.js → BridgeTab-Bs8cvrzB.js} +1 -1
  7. package/dist/assets/{ChatDefaultsTab-DZ9ZL3EP.js → ChatDefaultsTab-B76_pV-a.js} +1 -1
  8. package/dist/assets/{DataTableShell-P8WPv8pJ.js → DataTableShell-7VOYauXM.js} +1 -1
  9. package/dist/assets/{DetailChips-Bb_1pD-w.js → DetailChips-DxxeU-mf.js} +1 -1
  10. package/dist/assets/{FeedbacksTab-B6sjorN_.js → FeedbacksTab-CQJddboV.js} +1 -1
  11. package/dist/assets/{FieldLabel-DaWvOVaq.js → FieldLabel-CZ-m3Yh8.js} +1 -1
  12. package/dist/assets/{FilesTab-CGrWd9d1.js → FilesTab-BLVuhYUu.js} +1 -1
  13. package/dist/assets/{FilterBar-BWsi04G_.js → FilterBar-B0W1nP3i.js} +1 -1
  14. package/dist/assets/{GroupsTab-6-wQE2Ui.js → GroupsTab-eCgjhSeI.js} +1 -1
  15. package/dist/assets/{InstancesTab-BWYzJd_a.js → InstancesTab-C9knJ9ku.js} +1 -1
  16. package/dist/assets/{IntegrationsTab-CK7DSB-M.js → IntegrationsTab-GG79wWrt.js} +1 -1
  17. package/dist/assets/{KpiTab-C54gwXNq.js → KpiTab-BVMR3rMZ.js} +1 -1
  18. package/dist/assets/{PreferencesTab-BBpLdx_-.js → PreferencesTab-DOEuFzay.js} +1 -1
  19. package/dist/assets/{ProjectPage-BUGdPdmU.js → ProjectPage-CVpssY-3.js} +1 -1
  20. package/dist/assets/{PromptInjectionsTab-BHJ0-ZWI.js → PromptInjectionsTab-Dbp3yLMc.js} +1 -1
  21. package/dist/assets/{RolesTab-YmvPDwpq.js → RolesTab-CFa0qonh.js} +1 -1
  22. package/dist/assets/{ScheduledTab-BZiFyTay.js → ScheduledTab-QgcyWf16.js} +1 -1
  23. package/dist/assets/{ServiceAccountsTab-MGyT4mVz.js → ServiceAccountsTab-X_bQzXIS.js} +1 -1
  24. package/dist/assets/{SubAgentReportsTab-UQMDNwEo.js → SubAgentReportsTab-Jf1zcgs0.js} +1 -1
  25. package/dist/assets/{ThemeShowroom-KiqSBvlh.js → ThemeShowroom-DCxA68bn.js} +1 -1
  26. package/dist/assets/{TimeRangePicker-BVCNIF4U.js → TimeRangePicker-BgJKavXM.js} +1 -1
  27. package/dist/assets/{TimezoneCombobox-BB280Bgg.js → TimezoneCombobox-BkDGMdB2.js} +1 -1
  28. package/dist/assets/{TracesTab-yAjObtOK.js → TracesTab-Bzw8y55N.js} +1 -1
  29. package/dist/assets/{TrashPage-DK0mKtzJ.js → TrashPage-YhpHdmVr.js} +1 -1
  30. package/dist/assets/{TrashTab-S6IkI4t6.js → TrashTab-BuQ50Qu2.js} +1 -1
  31. package/dist/assets/{UsersTab-DTvPti51.js → UsersTab-zHZZ8QUo.js} +1 -1
  32. package/dist/assets/{VoiceTab-CYJea2dn.js → VoiceTab-IEStNr9Y.js} +1 -1
  33. package/dist/assets/api-DcB3BxUc.js +44 -0
  34. package/dist/assets/{button-D0Pgjwxf.js → button-DgaBsJDX.js} +1 -1
  35. package/dist/assets/{card-BaftCgRb.js → card-DnOLp6jN.js} +1 -1
  36. package/dist/assets/chevrons-up-down-R0Y7ndDn.js +1 -0
  37. package/dist/assets/{compatView-qPB4mG-_.js → compatView-Cyz2oaDo.js} +1 -1
  38. package/dist/assets/{dispatchErrorInfo-Wn57FY4L.js → dispatchErrorInfo-ALhveHh9.js} +1 -1
  39. package/dist/assets/{dist-CeZTHwrs.js → dist-BFXL2p5c.js} +1 -1
  40. package/dist/assets/{dist-CH3gjR1_.js → dist-CYBhnY4b.js} +1 -1
  41. package/dist/assets/{dist-DAKYY4yE.js → dist-D96qX4Zd.js} +1 -1
  42. package/dist/assets/{dist-By4rZwo-.js → dist-DHnmL-lz.js} +1 -1
  43. package/dist/assets/{highlighted-body-OFNGDK62-D4p66OHE.js → highlighted-body-OFNGDK62-CJ8J6p8l.js} +1 -1
  44. package/dist/assets/{index-xhYNLD3V.js → index-Ds-ybIOh.js} +7 -7
  45. package/dist/assets/{list-Dx86Q3WV.js → list-CKshqcfm.js} +1 -1
  46. package/dist/assets/mermaid-GHXKKRXX-lChj9izi.js +1 -0
  47. package/dist/assets/{pdf-BW6qvf4R.js → pdf-DeAT0bfe.js} +1 -1
  48. package/dist/assets/roleDescriptions-DHMAPGYx.js +1 -0
  49. package/dist/assets/{table-DsK3yFpt.js → table-A3AeBsY1.js} +1 -1
  50. package/dist/assets/{use_paginated_query-JzX-Y80s.js → use_paginated_query-Dc9YWxua.js} +1 -1
  51. package/dist/assets/x-DJcI0sFP.js +1 -0
  52. package/dist/index.html +8 -8
  53. package/package.json +1 -1
  54. package/dist/assets/api-BiOKjOdr.js +0 -44
  55. package/dist/assets/chevrons-up-down-CogPekve.js +0 -1
  56. package/dist/assets/mermaid-GHXKKRXX-wpDfhXTf.js +0 -1
  57. package/dist/assets/roleDescriptions-DKA8gzL4.js +0 -1
  58. package/dist/assets/x-BXqaL85P.js +0 -1
@@ -1 +1 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$N as r,$P as i,$a as a,A as o,AF as s,AP as c,BF as l,BP as u,BY as d,CF as f,CP as p,D as m,DF as h,DP as g,EF as _,EP as v,F as y,FF as b,FP as x,Fp as S,Fv as C,GP as w,HP as T,IF as ee,IH as E,IP as D,Ip as O,JN as k,JP as te,KN as ne,KP as re,LF as ie,LH as ae,LP as oe,Lp as se,M as ce,MF as le,MP as ue,Mk as de,N as fe,NF as pe,NP as me,Nk as he,Nv as ge,O as _e,OF as ve,OP as ye,P as be,PF as xe,PP as Se,Pp as Ce,Pv as we,QN as Te,QP as Ee,Qa as De,RF as Oe,RP as ke,RY as A,SF as Ae,SP as j,TF as je,TP as M,UP as Me,VF as Ne,VP as Pe,VY as N,WP as Fe,XN as P,XP as Ie,YN as Le,YP as Re,ZN as ze,ZP as Be,Za as Ve,_F as He,_P as Ue,aF as We,aP as Ge,ao as Ke,bF as qe,bP as Je,cF as Ye,cP as Xe,cn as Ze,co as Qe,dF as $e,dP as et,dn as tt,do as nt,eF as rt,eP as it,eo as at,fF as ot,fP as st,fn as ct,fo as lt,gF as ut,gP as dt,gn as ft,hF as pt,hP as mt,hn as ht,iF as gt,iP as _t,io as vt,iu as yt,j as bt,jF as xt,jP as St,k as Ct,kF as wt,kP as Tt,lF as Et,lP as Dt,ln as Ot,lo as kt,mF as At,mP as jt,mn as Mt,nF as Nt,nP as Pt,no as Ft,nu as It,oF as Lt,oP as Rt,oo as zt,pF as Bt,pP as Vt,pn as Ht,po as Ut,qN as Wt,qP as Gt,rF as F,rP as Kt,ro as qt,ru as Jt,sF as Yt,sP as Xt,sn as Zt,so as Qt,t as I,tF as $t,tP as en,to as tn,uF as nn,uP as rn,un as an,uo as on,vF as sn,vP as cn,wF as ln,wP as un,xF as dn,yF as fn,yP as pn,zF as mn,zP as hn}from"./api-BiOKjOdr.js";import{a as gn,c as _n}from"./FieldLabel-DaWvOVaq.js";import{t as L}from"./button-D0Pgjwxf.js";import{$t as R,Ct as z,Dt as B,J as V,Jt as H,Mt as vn,Ot as yn,St as U,Tt as bn,Yt as W,b as xn,bt as G,cn as Sn,ct as Cn,on as wn,sn as Tn,vt as K,wt as En,xt as q,yt as J}from"./index-xhYNLD3V.js";import{t as Dn}from"./DataTableShell-P8WPv8pJ.js";import{InstanceConfigDialog as On}from"./BridgeTab-Dt95NA_7.js";var Y=t(e(),1),X=[`conversational`,`documentary`,`summarizer`,`curator`],kn=new Set(X),An=`conversational`;function jn(e){let t=new Set((e??[]).filter(e=>kn.has(e)));return t.size===0?[An]:X.filter(e=>t.has(e))}var Z=n(),Q={name:``,gatewayUrl:``,bridgeUrl:``,displayName:``,kind:`openclaw`,transport:`ws`,gatewayVersion:``,gatewayHttpUrl:``,authMode:`token`,personScopes:`capped`,identitySource:`canonical`,participantIdentity:`owner`,managePermissionModes:!1,systemIdentity:``,streamTransport:gn,widgetsEnabled:!0,widgetPromptConfirm:!1},Mn={openclaw:[`token`,`deviceIdentity`],hermes:[`apiKey`]};function Nn(e){return{name:e.name,gatewayUrl:e.gatewayUrl,bridgeUrl:e.bridgeUrl??``,displayName:e.displayName??``,kind:e.kind??`openclaw`,transport:e.transport??`ws`,gatewayVersion:e.gatewayVersion??``,gatewayHttpUrl:e.gatewayHttpUrl??``,authMode:e.authMode??`token`,personScopes:e.personScopes??`capped`,identitySource:e.identitySource??`canonical`,participantIdentity:e.participantIdentity??`owner`,managePermissionModes:e.managePermissionModes===!0,systemIdentity:e.systemIdentity??``,streamTransport:e.streamTransport??`reactive`,widgetsEnabled:e.config?.widgetsEnabled!==!1,widgetPromptConfirm:e.config?.widgetPromptConfirm===!0}}function Pn(){let e=N(I.admin.listInstances,{}),t=N(I.agents.listAllInstanceAgents,{}),n=d(I.admin.upsertInstance),i=d(I.widgets.setInstanceWidgets),c=d(I.admin.deleteInstance),u=W(),[p,g]=(0,Y.useState)(!1),[v,x]=(0,Y.useState)(Q),[S,C]=(0,Y.useState)(null),[w,T]=(0,Y.useState)(null),[E,D]=(0,Y.useState)(null),[O,k]=(0,Y.useState)(null);async function te(){try{let t=await n({instanceId:O??void 0,name:v.name,gatewayUrl:v.gatewayUrl,bridgeUrl:v.bridgeUrl||void 0,displayName:v.displayName||void 0,kind:v.kind,transport:v.kind===`hermes`?v.transport:void 0,gatewayVersion:v.gatewayVersion||void 0,gatewayHttpUrl:v.gatewayHttpUrl||void 0,...v.kind===`openclaw`?{authMode:v.authMode,personScopes:v.personScopes,identitySource:v.identitySource,participantIdentity:v.participantIdentity,managePermissionModes:v.managePermissionModes,systemIdentity:v.systemIdentity||void 0}:{},streamTransport:v.streamTransport}),r=O===null?null:e?.find(e=>e._id===O),a=r?.config?.widgetsEnabled!==!1,o=r?.config?.widgetPromptConfirm===!0;v.kind===`openclaw`&&(v.widgetsEnabled!==a||v.widgetPromptConfirm!==o)&&await i({instanceId:t,enabled:v.widgetsEnabled,promptConfirm:v.widgetPromptConfirm}),x(Q),k(null),g(!1)}catch(e){u.error(mn(),e)}}return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`p`,{className:`oc-admin__hint`,children:[Oe(),(0,Z.jsx)(`strong`,{children:ie()}),ee()]}),(0,Z.jsx)(Dn,{title:b(),rows:e,addLabel:xe(),onAdd:()=>{k(null),x(Q),g(!0)},emptyHint:pe(),columns:[{header:le(),cell:e=>e.name,sort:e=>e.name},{header:xt(),cell:e=>(0,Z.jsx)(H,{variant:`outline`,children:e.kind??`openclaw`}),sort:e=>e.kind??`openclaw`},{header:s(),cell:e=>e.gatewayUrl,sort:e=>e.gatewayUrl},{header:wt(),cell:e=>e.displayName??`—`,sort:e=>e.displayName??null},{header:Ne(),cell:e=>{let n=(t?.[e.name]??[]).filter(e=>e.presentInLastOk!==!1&&e.enabled);if(n.length===0)return(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:`—`});let i=t=>e.defaultAgentId===t;return(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:[...n].sort((e,t)=>Number(i(t.agentId))-Number(i(e.agentId))).map(e=>(0,Z.jsxs)(H,{variant:i(e.agentId)?`default`:`outline`,title:i(e.agentId)?r():void 0,children:[e.emoji?`${e.emoji} `:``,e.displayName??e.agentId]},e.agentId))})}}],rowActions:e=>[{label:je(),onSelect:()=>{k(e._id),x(Nn(e)),g(!0)}},{label:l(),onSelect:()=>C(e.name)},{label:nn(),onSelect:()=>D(e)},{label:ve(),onSelect:()=>T(e)},{label:h(),variant:`destructive`,onSelect:()=>void c({instanceId:e._id})}],bulkActions:[{label:h(),variant:`destructive`,onSelect:e=>e.forEach(e=>void c({instanceId:e}))}]}),(0,Z.jsx)(xn,{open:p,onOpenChange:g,title:O?ln():_(),description:Ae(),canSubmit:!!(v.name&&v.gatewayUrl),onSubmit:te,submitLabel:dn(),children:(0,Z.jsxs)(`div`,{className:`oc-form`,children:[(0,Z.jsxs)($,{label:qe(),children:[(0,Z.jsx)(R,{value:v.name,disabled:O!==null,onChange:e=>x({...v,name:e.target.value})}),O?(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:f()}):null]}),(0,Z.jsx)($,{label:fn(),children:(0,Z.jsxs)(K,{value:v.kind,onValueChange:e=>x({...v,kind:e}),children:[(0,Z.jsx)(q,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(U,{})}),(0,Z.jsxs)(J,{children:[(0,Z.jsx)(G,{value:`openclaw`,children:`OpenClaw`}),(0,Z.jsx)(G,{value:`hermes`,children:`Hermes`})]})]})}),v.kind===`hermes`?(0,Z.jsx)($,{label:yt(),children:(0,Z.jsxs)(K,{value:v.transport,onValueChange:e=>x({...v,transport:e}),children:[(0,Z.jsx)(q,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(U,{})}),(0,Z.jsxs)(J,{children:[(0,Z.jsx)(G,{value:`ws`,children:Jt()}),(0,Z.jsx)(G,{value:`rest`,children:It()})]})]})}):null,(0,Z.jsx)($,{label:sn(),children:(0,Z.jsx)(R,{value:v.gatewayUrl,onChange:e=>x({...v,gatewayUrl:e.target.value})})}),(0,Z.jsx)($,{label:He(),children:(0,Z.jsx)(R,{value:v.bridgeUrl,placeholder:ut(),onChange:e=>x({...v,bridgeUrl:e.target.value})})}),(0,Z.jsx)($,{label:pt(),children:(0,Z.jsx)(R,{value:v.displayName,onChange:e=>x({...v,displayName:e.target.value})})}),(0,Z.jsxs)($,{label:he(),children:[(0,Z.jsxs)(K,{value:v.streamTransport,onValueChange:e=>x({...v,streamTransport:e}),children:[(0,Z.jsx)(q,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(U,{})}),(0,Z.jsx)(J,{children:_n.map(e=>(0,Z.jsx)(G,{value:e,children:e},e))})]}),(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:de()})]}),(0,Z.jsx)($,{label:At(),children:(0,Z.jsx)(R,{value:v.gatewayVersion,placeholder:Bt(),onChange:e=>x({...v,gatewayVersion:e.target.value})})}),v.kind===`openclaw`?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)($,{label:qt(),children:[(0,Z.jsxs)(K,{value:v.authMode,onValueChange:e=>x({...v,authMode:e}),children:[(0,Z.jsx)(q,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(U,{})}),(0,Z.jsxs)(J,{children:[(0,Z.jsx)(G,{value:`token`,children:Ft()}),(0,Z.jsx)(G,{value:`trusted-proxy`,children:tn()})]})]}),(0,Z.jsx)(`p`,{className:`oc-field__hint`,children:v.authMode===`trusted-proxy`?a():at()})]}),v.authMode===`trusted-proxy`?(0,Z.jsxs)($,{label:Ut(),children:[(0,Z.jsxs)(K,{value:v.personScopes,onValueChange:e=>x({...v,personScopes:e}),children:[(0,Z.jsx)(q,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(U,{})}),(0,Z.jsxs)(J,{children:[(0,Z.jsx)(G,{value:`capped`,children:lt()}),(0,Z.jsx)(G,{value:`full`,children:nt()})]})]}),(0,Z.jsx)(`p`,{className:`oc-field__hint`,children:v.personScopes===`full`?kt():on()})]}):null,v.authMode===`trusted-proxy`?(0,Z.jsxs)($,{label:Qe(),children:[(0,Z.jsxs)(K,{value:v.identitySource,onValueChange:e=>x({...v,identitySource:e}),children:[(0,Z.jsx)(q,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(U,{})}),(0,Z.jsxs)(J,{children:[(0,Z.jsx)(G,{value:`canonical`,children:Qt()}),(0,Z.jsx)(G,{value:`email`,children:zt()})]})]}),(0,Z.jsx)(`p`,{className:`oc-field__hint`,children:v.identitySource===`email`?vt():Ke()})]}):null,v.authMode===`trusted-proxy`?(0,Z.jsxs)($,{label:ft(),children:[(0,Z.jsxs)(K,{value:v.participantIdentity,onValueChange:e=>x({...v,participantIdentity:e}),children:[(0,Z.jsx)(q,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(U,{})}),(0,Z.jsxs)(J,{children:[(0,Z.jsx)(G,{value:`owner`,children:ht()}),(0,Z.jsx)(G,{value:`self`,children:Mt()})]})]}),(0,Z.jsx)(`p`,{className:`oc-field__hint`,children:v.participantIdentity===`self`?Zt():Ht()})]}):null,v.kind===`openclaw`?(0,Z.jsxs)($,{label:ct(),children:[(0,Z.jsxs)(K,{value:v.managePermissionModes?`on`:`off`,onValueChange:e=>x({...v,managePermissionModes:e===`on`}),children:[(0,Z.jsx)(q,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(U,{})}),(0,Z.jsxs)(J,{children:[(0,Z.jsx)(G,{value:`off`,children:tt()}),(0,Z.jsx)(G,{value:`on`,children:an()})]})]}),(0,Z.jsx)(`p`,{className:`oc-field__hint`,children:v.managePermissionModes?Ze():Ot()})]}):null,v.kind===`openclaw`?(0,Z.jsxs)($,{label:y(),children:[(0,Z.jsxs)(K,{value:v.widgetsEnabled?`on`:`off`,onValueChange:e=>x({...v,widgetsEnabled:e===`on`}),children:[(0,Z.jsx)(q,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(U,{})}),(0,Z.jsxs)(J,{children:[(0,Z.jsx)(G,{value:`on`,children:be()}),(0,Z.jsx)(G,{value:`off`,children:fe()})]})]}),(0,Z.jsx)(`p`,{className:`oc-field__hint`,children:v.widgetsEnabled?ce():bt()})]}):null,v.kind===`openclaw`&&v.widgetsEnabled?(0,Z.jsxs)($,{label:o(),children:[(0,Z.jsxs)(K,{value:v.widgetPromptConfirm?`on`:`off`,onValueChange:e=>x({...v,widgetPromptConfirm:e===`on`}),children:[(0,Z.jsx)(q,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(U,{})}),(0,Z.jsxs)(J,{children:[(0,Z.jsx)(G,{value:`off`,children:Ct()}),(0,Z.jsx)(G,{value:`on`,children:_e()})]})]}),(0,Z.jsx)(`p`,{className:`oc-field__hint`,children:m()})]}):null,v.authMode===`trusted-proxy`?(0,Z.jsx)($,{label:De(),children:(0,Z.jsx)(R,{value:v.systemIdentity,placeholder:Ve(),onChange:e=>x({...v,systemIdentity:e.target.value})})}):null]}):null,(0,Z.jsx)($,{label:ot(),children:(0,Z.jsx)(R,{value:v.gatewayHttpUrl,placeholder:$e(),onChange:e=>x({...v,gatewayHttpUrl:e.target.value})})})]})}),(0,Z.jsx)(Wn,{instanceName:S,open:S!==null,onOpenChange:e=>{e||C(null)}}),w?(0,Z.jsx)(On,{instance:w,onClose:()=>T(null)},w._id):null,E?(0,Z.jsx)(Fn,{instance:E,onClose:()=>D(null)},E._id):null]})}function Fn({instance:e,onClose:t}){let n=N(I.instanceSecrets.listInstanceSecretStatus,{}),r=Mn[e.kind??`openclaw`],i=(0,Y.useMemo)(()=>{let t={};for(let r of n??[])r.instanceId===e._id&&(t[r.field]=r.updatedAt);return t},[n,e._id]);return(0,Z.jsx)(z,{open:!0,onOpenChange:e=>!e&&t(),children:(0,Z.jsxs)(En,{onOpenAutoFocus:e=>e.preventDefault(),children:[(0,Z.jsxs)(B,{children:[(0,Z.jsx)(yn,{children:Et({instance:e.displayName??e.name})}),(0,Z.jsx)(bn,{children:Ye()})]}),(0,Z.jsx)(`div`,{className:`oc-form`,children:r.map(t=>(0,Z.jsx)(Rn,{instanceId:e._id,field:t,updatedAt:i[t]??null},t))}),(0,Z.jsx)(`div`,{className:`oc-bridgesecret`,children:(0,Z.jsx)(Ln,{instance:e})}),(0,Z.jsx)(In,{instance:e})]})})}function In({instance:e}){let t=A(I.instanceSync.forceInstanceSync),n=W(),[r,i]=(0,Y.useState)(!1);async function a(){if(!r){i(!0);try{switch((await t({instanceId:e._id})).status){case`synced`:n.success(T());break;case`no_agents`:n.success(u());break;case`no_bridge_url`:n.error(hn());break;case`deploy_misconfigured`:n.error(ke());break;case`unauthorized`:n.error(D());break;case`not_served`:n.error(x());break;default:n.error(oe());break}}catch(e){n.error(Pe(),e)}finally{i(!1)}}}return(0,Z.jsxs)(`div`,{className:`oc-form`,children:[(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:Se()}),(0,Z.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,Z.jsx)(L,{size:`sm`,variant:`outline`,onClick:()=>void a(),disabled:r,children:r?Me():Fe()})})]})}function Ln({instance:e}){let t=N(I.bridgeAuth.listBridgeAuthStatus,{}),n=A(I.bridgeAuth.mintBridgeSecret),r=d(I.bridgeAuth.revokeBridgeSecret),i=W(),[a,o]=(0,Y.useState)(!1),[s,l]=(0,Y.useState)(null),[u,f]=(0,Y.useState)(!1),p=(t??[]).find(t=>t.instanceId===e._id),m=p!==void 0;async function h(){if(!a){o(!0);try{l((await n({instanceId:e._id})).plaintext),f(!1)}catch(e){i.error(g(),e)}finally{o(!1)}}}async function _(){if(!a){o(!0);try{await r({instanceId:e._id}),l(null),i.success(ye())}catch(e){i.error(g(),e)}finally{o(!1)}}}async function y(){if(s)try{await navigator.clipboard.writeText(s),f(!0)}catch{}}return(0,Z.jsxs)($,{label:me(),children:[(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:ue()}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(H,{variant:m?`outline`:`secondary`,children:m?`${gt()} · ${p.prefix}…${p.lastFour}`:F()}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(L,{size:`sm`,onClick:()=>void h(),disabled:a,children:m?c():St()}),m?(0,Z.jsx)(L,{size:`sm`,variant:`destructive`,onClick:()=>void _(),disabled:a,children:Tt()}):null]})]}),s?(0,Z.jsxs)(`div`,{className:`oc-bridgesecret__reveal`,children:[(0,Z.jsx)(`p`,{className:`oc-sa__minted-warning`,children:v()}),(0,Z.jsxs)(`div`,{className:`oc-sa__minted-box`,children:[(0,Z.jsx)(`code`,{className:`oc-sa__minted-plain`,children:s}),(0,Z.jsx)(L,{variant:`outline`,size:`sm`,onClick:()=>void y(),children:u?ae():E()})]}),(0,Z.jsx)(L,{size:`sm`,variant:`ghost`,onClick:()=>{l(null),f(!1)},children:M()})]}):null]})}function Rn({instanceId:e,field:t,updatedAt:n}){let r=A(I.instanceSecrets.setInstanceSecret),a=d(I.instanceSecrets.clearInstanceSecret),o=A(I.deviceIdentity.generateDeviceIdentity),s=W(),[c,l]=(0,Y.useState)(``),[u,f]=(0,Y.useState)(!1),[p,m]=(0,Y.useState)(null),[h,g]=(0,Y.useState)(!1),_=n!==null,v=t===`deviceIdentity`,y=t===`token`?Yt():t===`deviceIdentity`?Lt():We();async function b(){if(!(!c.trim()||u)){f(!0);try{await r({instanceId:e,field:t,plaintext:c}),l(``),m(null),g(!1),s.success(Ee())}catch(e){s.error(Be(),e)}finally{f(!1)}}}async function x(){if(!u){f(!0);try{await a({instanceId:e,field:t}),m(null),g(!1),s.success(Ie())}catch(e){s.error(Be(),e)}finally{f(!1)}}}async function S(){if(!u){f(!0);try{m(await o({instanceId:e})),g(!1),s.success(Gt())}catch(e){s.error(w(),e)}finally{f(!1)}}}let C=p?`openclaw devices approve ${p.id}`:``;async function T(){if(C)try{await navigator.clipboard.writeText(C),g(!0)}catch{}}return(0,Z.jsxs)($,{label:y,children:[v?(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:te()}):null,(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(H,{variant:_?`outline`:`secondary`,children:_?gt():F()}),(0,Z.jsx)(R,{type:`password`,autoComplete:`off`,className:`flex-1 min-w-32`,value:c,placeholder:_?$t():Nt(),onChange:e=>l(e.target.value)}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(L,{size:`sm`,onClick:()=>void b(),disabled:u||c.trim().length===0,children:rt()}),v?(0,Z.jsx)(L,{size:`sm`,variant:`outline`,onClick:()=>void S(),disabled:u,children:Re()}):null,_?(0,Z.jsx)(L,{size:`sm`,variant:`destructive`,onClick:()=>void x(),disabled:u,children:i()}):null]})]}),p?(0,Z.jsxs)(`div`,{className:`oc-bridgesecret__reveal`,children:[(0,Z.jsx)(`p`,{className:`text-sm font-medium`,children:Gt()}),(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:re()}),(0,Z.jsxs)(`div`,{className:`oc-sa__minted-box`,children:[(0,Z.jsx)(`code`,{className:`oc-sa__minted-plain`,children:C}),(0,Z.jsx)(L,{variant:`outline`,size:`sm`,onClick:()=>void T(),children:h?ae():E()})]}),(0,Z.jsx)(L,{size:`sm`,variant:`ghost`,onClick:()=>{m(null),g(!1)},children:M()})]}):null]})}var zn={conversational:jt,documentary:st,summarizer:se,curator:S},Bn={conversational:Vt,documentary:et,summarizer:O,curator:Ce},Vn=e=>(zn[e]??(()=>e))(),Hn=e=>(Bn[e]??(()=>``))();function Un({agentId:e,types:t,onToggle:n}){return(0,Z.jsxs)(`div`,{className:`oc-agentcard__types`,children:[(0,Z.jsx)(`span`,{className:`oc-agentcard__types-label`,children:cn()}),t.map(e=>(0,Z.jsx)(H,{variant:`secondary`,className:`oc-agenttype__chip`,title:Hn(e),children:Vn(e)},e)),(0,Z.jsxs)(wn,{children:[(0,Z.jsx)(Sn,{asChild:!0,children:(0,Z.jsx)(L,{type:`button`,variant:`outline`,size:`sm`,className:`h-7`,children:Ue()})}),(0,Z.jsxs)(Tn,{align:`start`,className:`oc-agenttypes-pop`,children:[(0,Z.jsx)(`p`,{className:`oc-agenttypes-pop__title`,children:dt()}),(0,Z.jsx)(`p`,{className:`oc-agenttypes-pop__hint`,children:mt()}),(0,Z.jsx)(`div`,{className:`oc-agenttypes-pop__list`,children:X.map(r=>{let i=`agtype-${e}-${r}`;return(0,Z.jsxs)(`div`,{className:`oc-agenttypes-pop__item`,children:[(0,Z.jsx)(vn,{id:i,checked:t.includes(r),onCheckedChange:()=>n(r)}),(0,Z.jsxs)(`label`,{htmlFor:i,className:`oc-agenttypes-pop__text`,children:[(0,Z.jsx)(`span`,{className:`oc-agenttypes-pop__name`,children:Vn(r)}),(0,Z.jsx)(`span`,{className:`oc-agenttypes-pop__desc`,children:Hn(r)})]})]},r)})})]})]})]})}function Wn({instanceName:e,open:t,onOpenChange:n}){let i=N(I.agents.listAgentsForInstance,t&&e?{instanceName:e}:`skip`),a=d(I.agents.setAgentEnabled).withOptimisticUpdate((e,{instanceName:t,agentId:n,enabled:r})=>{let i=e.getQuery(I.agents.listAgentsForInstance,{instanceName:t});i&&e.setQuery(I.agents.listAgentsForInstance,{instanceName:t},{...i,agents:i.agents.map(e=>e.agentId===n?{...e,enabled:r}:e)})}),o=d(I.agents.setInstanceDefaultAgent).withOptimisticUpdate((e,{instanceName:t,agentId:n})=>{let r=e.getQuery(I.agents.listAgentsForInstance,{instanceName:t});r&&e.setQuery(I.agents.listAgentsForInstance,{instanceName:t},{...r,defaultAgentId:n})}),s=d(I.agents.setAgentTypes).withOptimisticUpdate((e,{instanceName:t,agentId:n,types:r})=>{let i=e.getQuery(I.agents.listAgentsForInstance,{instanceName:t});if(!i)return;let a=jn(r);e.setQuery(I.agents.listAgentsForInstance,{instanceName:t},{...i,agents:i.agents.map(e=>e.agentId===n?{...e,types:a}:e)})}),c=d(I.agents.setAgentDescription).withOptimisticUpdate((e,{instanceName:t,agentId:n,description:r})=>{let i=e.getQuery(I.agents.listAgentsForInstance,{instanceName:t});if(!i)return;let a=r.trim();e.setQuery(I.agents.listAgentsForInstance,{instanceName:t},{...i,agents:i.agents.map(e=>e.agentId===n?{...e,description:a.length===0?null:a}:e)})}),l=d(I.agents.removeInstanceAgent),u=d(I.agents.setAgentReservation),f=N(I.groups.listGroupLabels,t?{}:`skip`),m=Cn(),h=W();async function g(t,n){if(e&&await m({title:Le({name:n}),description:k(),confirmLabel:P()}))try{await u({instanceName:e,agentId:t,groupId:null})}catch(e){h.error(j(),V(e))}}async function _(t,n,r){if(!e)return;let i=(f??[]).find(e=>e._id===r)?.name??`?`;if(await m({title:C({name:n,group:i}),description:we({group:i}),confirmLabel:ge()}))try{await u({instanceName:e,agentId:t,groupId:r})}catch(e){h.error(j(),V(e))}}async function v(t,n){if(e)try{await a({instanceName:e,agentId:t,enabled:n})}catch(e){h.error(j(),e)}}async function y(t){if(e)try{await o({instanceName:e,agentId:t})}catch(e){h.error(j(),e)}}async function b(t,n,r){if(!e)return;let i=r.includes(n)?r.filter(e=>e!==n):[...r,n];try{await s({instanceName:e,agentId:t,types:i})}catch(e){h.error(j(),e)}}async function x(t,n){if(e&&await m({title:Xe({name:n}),description:Xt(),confirmLabel:Rt(),destructive:!0}))try{await l({instanceName:e,agentId:t}),h.success(Ge())}catch(e){h.error(j(),e)}}return(0,Z.jsx)(z,{open:t,onOpenChange:n,children:(0,Z.jsxs)(En,{className:`oc-access`,children:[(0,Z.jsxs)(B,{children:[(0,Z.jsx)(yn,{children:un({name:e??``})}),(0,Z.jsx)(bn,{children:p()})]}),i===void 0?(0,Z.jsx)(`p`,{className:`oc-access__hint`,children:_t()}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`oc-access__poll`,children:i.discovery===null?Kt():i.discovery.lastPollOk?Pt():en({error:i.discovery.error??`?`})}),i.agents.length===0?(0,Z.jsx)(`p`,{className:`oc-access__hint`,children:it()}):(0,Z.jsx)(`div`,{className:`oc-access__list`,children:i.agents.map(t=>{let n=t.presentInLastOk===!1,a=i.defaultAgentId===t.agentId,o=t.displayName??t.agentId,s=t.types??[];return(0,Z.jsxs)(`div`,{className:`oc-agentcard`+(t.enabled?``:` oc-agentcard--off`),children:[(0,Z.jsxs)(`div`,{className:`oc-agentcard__head`,children:[(0,Z.jsx)(vn,{checked:t.enabled,disabled:n,"aria-label":o,onCheckedChange:e=>void v(t.agentId,e===!0)}),(0,Z.jsxs)(`span`,{className:`oc-agentcard__name`,title:o,children:[t.emoji?`${t.emoji} `:``,o]}),t.model?(0,Z.jsx)(`span`,{className:`oc-access__model`,children:t.model}):null,t.reserved?(0,Z.jsx)(H,{variant:`outline`,children:t.reserved.groupName===null?ze():Te({group:t.reserved.groupName})}):null,n?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(H,{variant:`outline`,className:`oc-access__gone`,children:ne()}),(0,Z.jsx)(L,{size:`sm`,variant:`ghost`,className:`h-7 text-destructive`,onClick:()=>void x(t.agentId,o),children:Dt()})]}):a?(0,Z.jsx)(H,{variant:`default`,children:r()}):(0,Z.jsx)(L,{size:`sm`,variant:`outline`,className:`h-7`,disabled:!t.enabled||t.reserved!==null,onClick:()=>void y(t.agentId),children:rn()})]}),t.reserved?(0,Z.jsxs)(`div`,{className:`oc-agentcard__head`,children:[(0,Z.jsx)(L,{size:`sm`,variant:`outline`,className:`h-7`,onClick:()=>void g(t.agentId,o),children:P()}),(0,Z.jsxs)(K,{value:``,onValueChange:e=>void _(t.agentId,o,e),children:[(0,Z.jsx)(q,{size:`sm`,className:`h-7`,children:(0,Z.jsx)(U,{placeholder:Wt()})}),(0,Z.jsx)(J,{children:(f??[]).filter(e=>e._id!==t.reserved?.groupId).map(e=>(0,Z.jsx)(G,{value:e._id,children:e.name},e._id))})]})]}):null,t.enabled?(0,Z.jsx)(Un,{agentId:t.agentId,types:s,onToggle:e=>void b(t.agentId,e,s)}):null,t.enabled?(0,Z.jsx)(Gn,{value:t.description??``,onSave:async n=>{if(e)try{await c({instanceName:e,agentId:t.agentId,description:n})}catch(e){h.error(j(),e)}}}):null]},t.agentId)})})]})]})})}function Gn({value:e,onSave:t}){let[n,r]=(0,Y.useState)(e);(0,Y.useEffect)(()=>{r(e)},[e]);let i=()=>{n.trim()!==e.trim()&&t(n)};return(0,Z.jsx)(R,{className:`oc-agentcard__desc`,value:n,maxLength:280,placeholder:Je(),"aria-label":pn(),onChange:e=>r(e.target.value),onBlur:i,onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),i())}})}function $({label:e,children:t}){return(0,Z.jsxs)(`label`,{className:`oc-field`,children:[(0,Z.jsx)(`span`,{className:`oc-field__label`,children:e}),t]})}export{Pn as InstancesTab};
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$N as r,$P as i,$a as a,A as o,AF as s,AP as c,BF as l,BP as u,BY as d,CF as f,CP as p,D as m,DF as h,DP as g,EF as _,EP as v,F as y,FF as b,FP as x,Fp as S,Fv as C,GP as w,HP as T,IF as ee,IH as E,IP as D,Ip as O,JN as k,JP as te,KN as ne,KP as re,LF as ie,LH as ae,LP as oe,Lp as se,M as ce,MF as le,MP as ue,Mk as de,N as fe,NF as pe,NP as me,Nk as he,Nv as ge,O as _e,OF as ve,OP as ye,P as be,PF as xe,PP as Se,Pp as Ce,Pv as we,QN as Te,QP as Ee,Qa as De,RF as Oe,RP as ke,RY as A,SF as Ae,SP as j,TF as je,TP as M,UP as Me,VF as Ne,VP as Pe,VY as N,WP as Fe,XN as P,XP as Ie,YN as Le,YP as Re,ZN as ze,ZP as Be,Za as Ve,_F as He,_P as Ue,aF as We,aP as Ge,ao as Ke,bF as qe,bP as Je,cF as Ye,cP as Xe,cn as Ze,co as Qe,dF as $e,dP as et,dn as tt,do as nt,eF as rt,eP as it,eo as at,fF as ot,fP as st,fn as ct,fo as lt,gF as ut,gP as dt,gn as ft,hF as pt,hP as mt,hn as ht,iF as gt,iP as _t,io as vt,iu as yt,j as bt,jF as xt,jP as St,k as Ct,kF as wt,kP as Tt,lF as Et,lP as Dt,ln as Ot,lo as kt,mF as At,mP as jt,mn as Mt,nF as Nt,nP as Pt,no as Ft,nu as It,oF as Lt,oP as Rt,oo as zt,pF as Bt,pP as Vt,pn as Ht,po as Ut,qN as Wt,qP as Gt,rF as F,rP as Kt,ro as qt,ru as Jt,sF as Yt,sP as Xt,sn as Zt,so as Qt,t as I,tF as $t,tP as en,to as tn,uF as nn,uP as rn,un as an,uo as on,vF as sn,vP as cn,wF as ln,wP as un,xF as dn,yF as fn,yP as pn,zF as mn,zP as hn}from"./api-DcB3BxUc.js";import{a as gn,c as _n}from"./FieldLabel-CZ-m3Yh8.js";import{t as L}from"./button-DgaBsJDX.js";import{$t as R,Ct as z,Dt as B,J as V,Jt as H,Mt as vn,Ot as yn,St as U,Tt as bn,Yt as W,b as xn,bt as G,cn as Sn,ct as Cn,on as wn,sn as Tn,vt as K,wt as En,xt as q,yt as J}from"./index-Ds-ybIOh.js";import{t as Dn}from"./DataTableShell-7VOYauXM.js";import{InstanceConfigDialog as On}from"./BridgeTab-Bs8cvrzB.js";var Y=t(e(),1),X=[`conversational`,`documentary`,`summarizer`,`curator`],kn=new Set(X),An=`conversational`;function jn(e){let t=new Set((e??[]).filter(e=>kn.has(e)));return t.size===0?[An]:X.filter(e=>t.has(e))}var Z=n(),Q={name:``,gatewayUrl:``,bridgeUrl:``,displayName:``,kind:`openclaw`,transport:`ws`,gatewayVersion:``,gatewayHttpUrl:``,authMode:`token`,personScopes:`capped`,identitySource:`canonical`,participantIdentity:`owner`,managePermissionModes:!1,systemIdentity:``,streamTransport:gn,widgetsEnabled:!0,widgetPromptConfirm:!1},Mn={openclaw:[`token`,`deviceIdentity`],hermes:[`apiKey`]};function Nn(e){return{name:e.name,gatewayUrl:e.gatewayUrl,bridgeUrl:e.bridgeUrl??``,displayName:e.displayName??``,kind:e.kind??`openclaw`,transport:e.transport??`ws`,gatewayVersion:e.gatewayVersion??``,gatewayHttpUrl:e.gatewayHttpUrl??``,authMode:e.authMode??`token`,personScopes:e.personScopes??`capped`,identitySource:e.identitySource??`canonical`,participantIdentity:e.participantIdentity??`owner`,managePermissionModes:e.managePermissionModes===!0,systemIdentity:e.systemIdentity??``,streamTransport:e.streamTransport??`reactive`,widgetsEnabled:e.config?.widgetsEnabled!==!1,widgetPromptConfirm:e.config?.widgetPromptConfirm===!0}}function Pn(){let e=N(I.admin.listInstances,{}),t=N(I.agents.listAllInstanceAgents,{}),n=d(I.admin.upsertInstance),i=d(I.widgets.setInstanceWidgets),c=d(I.admin.deleteInstance),u=W(),[p,g]=(0,Y.useState)(!1),[v,x]=(0,Y.useState)(Q),[S,C]=(0,Y.useState)(null),[w,T]=(0,Y.useState)(null),[E,D]=(0,Y.useState)(null),[O,k]=(0,Y.useState)(null);async function te(){try{let t=await n({instanceId:O??void 0,name:v.name,gatewayUrl:v.gatewayUrl,bridgeUrl:v.bridgeUrl||void 0,displayName:v.displayName||void 0,kind:v.kind,transport:v.kind===`hermes`?v.transport:void 0,gatewayVersion:v.gatewayVersion||void 0,gatewayHttpUrl:v.gatewayHttpUrl||void 0,...v.kind===`openclaw`?{authMode:v.authMode,personScopes:v.personScopes,identitySource:v.identitySource,participantIdentity:v.participantIdentity,managePermissionModes:v.managePermissionModes,systemIdentity:v.systemIdentity||void 0}:{},streamTransport:v.streamTransport}),r=O===null?null:e?.find(e=>e._id===O),a=r?.config?.widgetsEnabled!==!1,o=r?.config?.widgetPromptConfirm===!0;v.kind===`openclaw`&&(v.widgetsEnabled!==a||v.widgetPromptConfirm!==o)&&await i({instanceId:t,enabled:v.widgetsEnabled,promptConfirm:v.widgetPromptConfirm}),x(Q),k(null),g(!1)}catch(e){u.error(mn(),e)}}return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`p`,{className:`oc-admin__hint`,children:[Oe(),(0,Z.jsx)(`strong`,{children:ie()}),ee()]}),(0,Z.jsx)(Dn,{title:b(),rows:e,addLabel:xe(),onAdd:()=>{k(null),x(Q),g(!0)},emptyHint:pe(),columns:[{header:le(),cell:e=>e.name,sort:e=>e.name},{header:xt(),cell:e=>(0,Z.jsx)(H,{variant:`outline`,children:e.kind??`openclaw`}),sort:e=>e.kind??`openclaw`},{header:s(),cell:e=>e.gatewayUrl,sort:e=>e.gatewayUrl},{header:wt(),cell:e=>e.displayName??`—`,sort:e=>e.displayName??null},{header:Ne(),cell:e=>{let n=(t?.[e.name]??[]).filter(e=>e.presentInLastOk!==!1&&e.enabled);if(n.length===0)return(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:`—`});let i=t=>e.defaultAgentId===t;return(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:[...n].sort((e,t)=>Number(i(t.agentId))-Number(i(e.agentId))).map(e=>(0,Z.jsxs)(H,{variant:i(e.agentId)?`default`:`outline`,title:i(e.agentId)?r():void 0,children:[e.emoji?`${e.emoji} `:``,e.displayName??e.agentId]},e.agentId))})}}],rowActions:e=>[{label:je(),onSelect:()=>{k(e._id),x(Nn(e)),g(!0)}},{label:l(),onSelect:()=>C(e.name)},{label:nn(),onSelect:()=>D(e)},{label:ve(),onSelect:()=>T(e)},{label:h(),variant:`destructive`,onSelect:()=>void c({instanceId:e._id})}],bulkActions:[{label:h(),variant:`destructive`,onSelect:e=>e.forEach(e=>void c({instanceId:e}))}]}),(0,Z.jsx)(xn,{open:p,onOpenChange:g,title:O?ln():_(),description:Ae(),canSubmit:!!(v.name&&v.gatewayUrl),onSubmit:te,submitLabel:dn(),children:(0,Z.jsxs)(`div`,{className:`oc-form`,children:[(0,Z.jsxs)($,{label:qe(),children:[(0,Z.jsx)(R,{value:v.name,disabled:O!==null,onChange:e=>x({...v,name:e.target.value})}),O?(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:f()}):null]}),(0,Z.jsx)($,{label:fn(),children:(0,Z.jsxs)(K,{value:v.kind,onValueChange:e=>x({...v,kind:e}),children:[(0,Z.jsx)(q,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(U,{})}),(0,Z.jsxs)(J,{children:[(0,Z.jsx)(G,{value:`openclaw`,children:`OpenClaw`}),(0,Z.jsx)(G,{value:`hermes`,children:`Hermes`})]})]})}),v.kind===`hermes`?(0,Z.jsx)($,{label:yt(),children:(0,Z.jsxs)(K,{value:v.transport,onValueChange:e=>x({...v,transport:e}),children:[(0,Z.jsx)(q,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(U,{})}),(0,Z.jsxs)(J,{children:[(0,Z.jsx)(G,{value:`ws`,children:Jt()}),(0,Z.jsx)(G,{value:`rest`,children:It()})]})]})}):null,(0,Z.jsx)($,{label:sn(),children:(0,Z.jsx)(R,{value:v.gatewayUrl,onChange:e=>x({...v,gatewayUrl:e.target.value})})}),(0,Z.jsx)($,{label:He(),children:(0,Z.jsx)(R,{value:v.bridgeUrl,placeholder:ut(),onChange:e=>x({...v,bridgeUrl:e.target.value})})}),(0,Z.jsx)($,{label:pt(),children:(0,Z.jsx)(R,{value:v.displayName,onChange:e=>x({...v,displayName:e.target.value})})}),(0,Z.jsxs)($,{label:he(),children:[(0,Z.jsxs)(K,{value:v.streamTransport,onValueChange:e=>x({...v,streamTransport:e}),children:[(0,Z.jsx)(q,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(U,{})}),(0,Z.jsx)(J,{children:_n.map(e=>(0,Z.jsx)(G,{value:e,children:e},e))})]}),(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:de()})]}),(0,Z.jsx)($,{label:At(),children:(0,Z.jsx)(R,{value:v.gatewayVersion,placeholder:Bt(),onChange:e=>x({...v,gatewayVersion:e.target.value})})}),v.kind===`openclaw`?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)($,{label:qt(),children:[(0,Z.jsxs)(K,{value:v.authMode,onValueChange:e=>x({...v,authMode:e}),children:[(0,Z.jsx)(q,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(U,{})}),(0,Z.jsxs)(J,{children:[(0,Z.jsx)(G,{value:`token`,children:Ft()}),(0,Z.jsx)(G,{value:`trusted-proxy`,children:tn()})]})]}),(0,Z.jsx)(`p`,{className:`oc-field__hint`,children:v.authMode===`trusted-proxy`?a():at()})]}),v.authMode===`trusted-proxy`?(0,Z.jsxs)($,{label:Ut(),children:[(0,Z.jsxs)(K,{value:v.personScopes,onValueChange:e=>x({...v,personScopes:e}),children:[(0,Z.jsx)(q,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(U,{})}),(0,Z.jsxs)(J,{children:[(0,Z.jsx)(G,{value:`capped`,children:lt()}),(0,Z.jsx)(G,{value:`full`,children:nt()})]})]}),(0,Z.jsx)(`p`,{className:`oc-field__hint`,children:v.personScopes===`full`?kt():on()})]}):null,v.authMode===`trusted-proxy`?(0,Z.jsxs)($,{label:Qe(),children:[(0,Z.jsxs)(K,{value:v.identitySource,onValueChange:e=>x({...v,identitySource:e}),children:[(0,Z.jsx)(q,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(U,{})}),(0,Z.jsxs)(J,{children:[(0,Z.jsx)(G,{value:`canonical`,children:Qt()}),(0,Z.jsx)(G,{value:`email`,children:zt()})]})]}),(0,Z.jsx)(`p`,{className:`oc-field__hint`,children:v.identitySource===`email`?vt():Ke()})]}):null,v.authMode===`trusted-proxy`?(0,Z.jsxs)($,{label:ft(),children:[(0,Z.jsxs)(K,{value:v.participantIdentity,onValueChange:e=>x({...v,participantIdentity:e}),children:[(0,Z.jsx)(q,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(U,{})}),(0,Z.jsxs)(J,{children:[(0,Z.jsx)(G,{value:`owner`,children:ht()}),(0,Z.jsx)(G,{value:`self`,children:Mt()})]})]}),(0,Z.jsx)(`p`,{className:`oc-field__hint`,children:v.participantIdentity===`self`?Zt():Ht()})]}):null,v.kind===`openclaw`?(0,Z.jsxs)($,{label:ct(),children:[(0,Z.jsxs)(K,{value:v.managePermissionModes?`on`:`off`,onValueChange:e=>x({...v,managePermissionModes:e===`on`}),children:[(0,Z.jsx)(q,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(U,{})}),(0,Z.jsxs)(J,{children:[(0,Z.jsx)(G,{value:`off`,children:tt()}),(0,Z.jsx)(G,{value:`on`,children:an()})]})]}),(0,Z.jsx)(`p`,{className:`oc-field__hint`,children:v.managePermissionModes?Ze():Ot()})]}):null,v.kind===`openclaw`?(0,Z.jsxs)($,{label:y(),children:[(0,Z.jsxs)(K,{value:v.widgetsEnabled?`on`:`off`,onValueChange:e=>x({...v,widgetsEnabled:e===`on`}),children:[(0,Z.jsx)(q,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(U,{})}),(0,Z.jsxs)(J,{children:[(0,Z.jsx)(G,{value:`on`,children:be()}),(0,Z.jsx)(G,{value:`off`,children:fe()})]})]}),(0,Z.jsx)(`p`,{className:`oc-field__hint`,children:v.widgetsEnabled?ce():bt()})]}):null,v.kind===`openclaw`&&v.widgetsEnabled?(0,Z.jsxs)($,{label:o(),children:[(0,Z.jsxs)(K,{value:v.widgetPromptConfirm?`on`:`off`,onValueChange:e=>x({...v,widgetPromptConfirm:e===`on`}),children:[(0,Z.jsx)(q,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(U,{})}),(0,Z.jsxs)(J,{children:[(0,Z.jsx)(G,{value:`off`,children:Ct()}),(0,Z.jsx)(G,{value:`on`,children:_e()})]})]}),(0,Z.jsx)(`p`,{className:`oc-field__hint`,children:m()})]}):null,v.authMode===`trusted-proxy`?(0,Z.jsx)($,{label:De(),children:(0,Z.jsx)(R,{value:v.systemIdentity,placeholder:Ve(),onChange:e=>x({...v,systemIdentity:e.target.value})})}):null]}):null,(0,Z.jsx)($,{label:ot(),children:(0,Z.jsx)(R,{value:v.gatewayHttpUrl,placeholder:$e(),onChange:e=>x({...v,gatewayHttpUrl:e.target.value})})})]})}),(0,Z.jsx)(Wn,{instanceName:S,open:S!==null,onOpenChange:e=>{e||C(null)}}),w?(0,Z.jsx)(On,{instance:w,onClose:()=>T(null)},w._id):null,E?(0,Z.jsx)(Fn,{instance:E,onClose:()=>D(null)},E._id):null]})}function Fn({instance:e,onClose:t}){let n=N(I.instanceSecrets.listInstanceSecretStatus,{}),r=Mn[e.kind??`openclaw`],i=(0,Y.useMemo)(()=>{let t={};for(let r of n??[])r.instanceId===e._id&&(t[r.field]=r.updatedAt);return t},[n,e._id]);return(0,Z.jsx)(z,{open:!0,onOpenChange:e=>!e&&t(),children:(0,Z.jsxs)(En,{onOpenAutoFocus:e=>e.preventDefault(),children:[(0,Z.jsxs)(B,{children:[(0,Z.jsx)(yn,{children:Et({instance:e.displayName??e.name})}),(0,Z.jsx)(bn,{children:Ye()})]}),(0,Z.jsx)(`div`,{className:`oc-form`,children:r.map(t=>(0,Z.jsx)(Rn,{instanceId:e._id,field:t,updatedAt:i[t]??null},t))}),(0,Z.jsx)(`div`,{className:`oc-bridgesecret`,children:(0,Z.jsx)(Ln,{instance:e})}),(0,Z.jsx)(In,{instance:e})]})})}function In({instance:e}){let t=A(I.instanceSync.forceInstanceSync),n=W(),[r,i]=(0,Y.useState)(!1);async function a(){if(!r){i(!0);try{switch((await t({instanceId:e._id})).status){case`synced`:n.success(T());break;case`no_agents`:n.success(u());break;case`no_bridge_url`:n.error(hn());break;case`deploy_misconfigured`:n.error(ke());break;case`unauthorized`:n.error(D());break;case`not_served`:n.error(x());break;default:n.error(oe());break}}catch(e){n.error(Pe(),e)}finally{i(!1)}}}return(0,Z.jsxs)(`div`,{className:`oc-form`,children:[(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:Se()}),(0,Z.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,Z.jsx)(L,{size:`sm`,variant:`outline`,onClick:()=>void a(),disabled:r,children:r?Me():Fe()})})]})}function Ln({instance:e}){let t=N(I.bridgeAuth.listBridgeAuthStatus,{}),n=A(I.bridgeAuth.mintBridgeSecret),r=d(I.bridgeAuth.revokeBridgeSecret),i=W(),[a,o]=(0,Y.useState)(!1),[s,l]=(0,Y.useState)(null),[u,f]=(0,Y.useState)(!1),p=(t??[]).find(t=>t.instanceId===e._id),m=p!==void 0;async function h(){if(!a){o(!0);try{l((await n({instanceId:e._id})).plaintext),f(!1)}catch(e){i.error(g(),e)}finally{o(!1)}}}async function _(){if(!a){o(!0);try{await r({instanceId:e._id}),l(null),i.success(ye())}catch(e){i.error(g(),e)}finally{o(!1)}}}async function y(){if(s)try{await navigator.clipboard.writeText(s),f(!0)}catch{}}return(0,Z.jsxs)($,{label:me(),children:[(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:ue()}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(H,{variant:m?`outline`:`secondary`,children:m?`${gt()} · ${p.prefix}…${p.lastFour}`:F()}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(L,{size:`sm`,onClick:()=>void h(),disabled:a,children:m?c():St()}),m?(0,Z.jsx)(L,{size:`sm`,variant:`destructive`,onClick:()=>void _(),disabled:a,children:Tt()}):null]})]}),s?(0,Z.jsxs)(`div`,{className:`oc-bridgesecret__reveal`,children:[(0,Z.jsx)(`p`,{className:`oc-sa__minted-warning`,children:v()}),(0,Z.jsxs)(`div`,{className:`oc-sa__minted-box`,children:[(0,Z.jsx)(`code`,{className:`oc-sa__minted-plain`,children:s}),(0,Z.jsx)(L,{variant:`outline`,size:`sm`,onClick:()=>void y(),children:u?ae():E()})]}),(0,Z.jsx)(L,{size:`sm`,variant:`ghost`,onClick:()=>{l(null),f(!1)},children:M()})]}):null]})}function Rn({instanceId:e,field:t,updatedAt:n}){let r=A(I.instanceSecrets.setInstanceSecret),a=d(I.instanceSecrets.clearInstanceSecret),o=A(I.deviceIdentity.generateDeviceIdentity),s=W(),[c,l]=(0,Y.useState)(``),[u,f]=(0,Y.useState)(!1),[p,m]=(0,Y.useState)(null),[h,g]=(0,Y.useState)(!1),_=n!==null,v=t===`deviceIdentity`,y=t===`token`?Yt():t===`deviceIdentity`?Lt():We();async function b(){if(!(!c.trim()||u)){f(!0);try{await r({instanceId:e,field:t,plaintext:c}),l(``),m(null),g(!1),s.success(Ee())}catch(e){s.error(Be(),e)}finally{f(!1)}}}async function x(){if(!u){f(!0);try{await a({instanceId:e,field:t}),m(null),g(!1),s.success(Ie())}catch(e){s.error(Be(),e)}finally{f(!1)}}}async function S(){if(!u){f(!0);try{m(await o({instanceId:e})),g(!1),s.success(Gt())}catch(e){s.error(w(),e)}finally{f(!1)}}}let C=p?`openclaw devices approve ${p.id}`:``;async function T(){if(C)try{await navigator.clipboard.writeText(C),g(!0)}catch{}}return(0,Z.jsxs)($,{label:y,children:[v?(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:te()}):null,(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(H,{variant:_?`outline`:`secondary`,children:_?gt():F()}),(0,Z.jsx)(R,{type:`password`,autoComplete:`off`,className:`flex-1 min-w-32`,value:c,placeholder:_?$t():Nt(),onChange:e=>l(e.target.value)}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(L,{size:`sm`,onClick:()=>void b(),disabled:u||c.trim().length===0,children:rt()}),v?(0,Z.jsx)(L,{size:`sm`,variant:`outline`,onClick:()=>void S(),disabled:u,children:Re()}):null,_?(0,Z.jsx)(L,{size:`sm`,variant:`destructive`,onClick:()=>void x(),disabled:u,children:i()}):null]})]}),p?(0,Z.jsxs)(`div`,{className:`oc-bridgesecret__reveal`,children:[(0,Z.jsx)(`p`,{className:`text-sm font-medium`,children:Gt()}),(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:re()}),(0,Z.jsxs)(`div`,{className:`oc-sa__minted-box`,children:[(0,Z.jsx)(`code`,{className:`oc-sa__minted-plain`,children:C}),(0,Z.jsx)(L,{variant:`outline`,size:`sm`,onClick:()=>void T(),children:h?ae():E()})]}),(0,Z.jsx)(L,{size:`sm`,variant:`ghost`,onClick:()=>{m(null),g(!1)},children:M()})]}):null]})}var zn={conversational:jt,documentary:st,summarizer:se,curator:S},Bn={conversational:Vt,documentary:et,summarizer:O,curator:Ce},Vn=e=>(zn[e]??(()=>e))(),Hn=e=>(Bn[e]??(()=>``))();function Un({agentId:e,types:t,onToggle:n}){return(0,Z.jsxs)(`div`,{className:`oc-agentcard__types`,children:[(0,Z.jsx)(`span`,{className:`oc-agentcard__types-label`,children:cn()}),t.map(e=>(0,Z.jsx)(H,{variant:`secondary`,className:`oc-agenttype__chip`,title:Hn(e),children:Vn(e)},e)),(0,Z.jsxs)(wn,{children:[(0,Z.jsx)(Sn,{asChild:!0,children:(0,Z.jsx)(L,{type:`button`,variant:`outline`,size:`sm`,className:`h-7`,children:Ue()})}),(0,Z.jsxs)(Tn,{align:`start`,className:`oc-agenttypes-pop`,children:[(0,Z.jsx)(`p`,{className:`oc-agenttypes-pop__title`,children:dt()}),(0,Z.jsx)(`p`,{className:`oc-agenttypes-pop__hint`,children:mt()}),(0,Z.jsx)(`div`,{className:`oc-agenttypes-pop__list`,children:X.map(r=>{let i=`agtype-${e}-${r}`;return(0,Z.jsxs)(`div`,{className:`oc-agenttypes-pop__item`,children:[(0,Z.jsx)(vn,{id:i,checked:t.includes(r),onCheckedChange:()=>n(r)}),(0,Z.jsxs)(`label`,{htmlFor:i,className:`oc-agenttypes-pop__text`,children:[(0,Z.jsx)(`span`,{className:`oc-agenttypes-pop__name`,children:Vn(r)}),(0,Z.jsx)(`span`,{className:`oc-agenttypes-pop__desc`,children:Hn(r)})]})]},r)})})]})]})]})}function Wn({instanceName:e,open:t,onOpenChange:n}){let i=N(I.agents.listAgentsForInstance,t&&e?{instanceName:e}:`skip`),a=d(I.agents.setAgentEnabled).withOptimisticUpdate((e,{instanceName:t,agentId:n,enabled:r})=>{let i=e.getQuery(I.agents.listAgentsForInstance,{instanceName:t});i&&e.setQuery(I.agents.listAgentsForInstance,{instanceName:t},{...i,agents:i.agents.map(e=>e.agentId===n?{...e,enabled:r}:e)})}),o=d(I.agents.setInstanceDefaultAgent).withOptimisticUpdate((e,{instanceName:t,agentId:n})=>{let r=e.getQuery(I.agents.listAgentsForInstance,{instanceName:t});r&&e.setQuery(I.agents.listAgentsForInstance,{instanceName:t},{...r,defaultAgentId:n})}),s=d(I.agents.setAgentTypes).withOptimisticUpdate((e,{instanceName:t,agentId:n,types:r})=>{let i=e.getQuery(I.agents.listAgentsForInstance,{instanceName:t});if(!i)return;let a=jn(r);e.setQuery(I.agents.listAgentsForInstance,{instanceName:t},{...i,agents:i.agents.map(e=>e.agentId===n?{...e,types:a}:e)})}),c=d(I.agents.setAgentDescription).withOptimisticUpdate((e,{instanceName:t,agentId:n,description:r})=>{let i=e.getQuery(I.agents.listAgentsForInstance,{instanceName:t});if(!i)return;let a=r.trim();e.setQuery(I.agents.listAgentsForInstance,{instanceName:t},{...i,agents:i.agents.map(e=>e.agentId===n?{...e,description:a.length===0?null:a}:e)})}),l=d(I.agents.removeInstanceAgent),u=d(I.agents.setAgentReservation),f=N(I.groups.listGroupLabels,t?{}:`skip`),m=Cn(),h=W();async function g(t,n){if(e&&await m({title:Le({name:n}),description:k(),confirmLabel:P()}))try{await u({instanceName:e,agentId:t,groupId:null})}catch(e){h.error(j(),V(e))}}async function _(t,n,r){if(!e)return;let i=(f??[]).find(e=>e._id===r)?.name??`?`;if(await m({title:C({name:n,group:i}),description:we({group:i}),confirmLabel:ge()}))try{await u({instanceName:e,agentId:t,groupId:r})}catch(e){h.error(j(),V(e))}}async function v(t,n){if(e)try{await a({instanceName:e,agentId:t,enabled:n})}catch(e){h.error(j(),e)}}async function y(t){if(e)try{await o({instanceName:e,agentId:t})}catch(e){h.error(j(),e)}}async function b(t,n,r){if(!e)return;let i=r.includes(n)?r.filter(e=>e!==n):[...r,n];try{await s({instanceName:e,agentId:t,types:i})}catch(e){h.error(j(),e)}}async function x(t,n){if(e&&await m({title:Xe({name:n}),description:Xt(),confirmLabel:Rt(),destructive:!0}))try{await l({instanceName:e,agentId:t}),h.success(Ge())}catch(e){h.error(j(),e)}}return(0,Z.jsx)(z,{open:t,onOpenChange:n,children:(0,Z.jsxs)(En,{className:`oc-access`,children:[(0,Z.jsxs)(B,{children:[(0,Z.jsx)(yn,{children:un({name:e??``})}),(0,Z.jsx)(bn,{children:p()})]}),i===void 0?(0,Z.jsx)(`p`,{className:`oc-access__hint`,children:_t()}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`oc-access__poll`,children:i.discovery===null?Kt():i.discovery.lastPollOk?Pt():en({error:i.discovery.error??`?`})}),i.agents.length===0?(0,Z.jsx)(`p`,{className:`oc-access__hint`,children:it()}):(0,Z.jsx)(`div`,{className:`oc-access__list`,children:i.agents.map(t=>{let n=t.presentInLastOk===!1,a=i.defaultAgentId===t.agentId,o=t.displayName??t.agentId,s=t.types??[];return(0,Z.jsxs)(`div`,{className:`oc-agentcard`+(t.enabled?``:` oc-agentcard--off`),children:[(0,Z.jsxs)(`div`,{className:`oc-agentcard__head`,children:[(0,Z.jsx)(vn,{checked:t.enabled,disabled:n,"aria-label":o,onCheckedChange:e=>void v(t.agentId,e===!0)}),(0,Z.jsxs)(`span`,{className:`oc-agentcard__name`,title:o,children:[t.emoji?`${t.emoji} `:``,o]}),t.model?(0,Z.jsx)(`span`,{className:`oc-access__model`,children:t.model}):null,t.reserved?(0,Z.jsx)(H,{variant:`outline`,children:t.reserved.groupName===null?ze():Te({group:t.reserved.groupName})}):null,n?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(H,{variant:`outline`,className:`oc-access__gone`,children:ne()}),(0,Z.jsx)(L,{size:`sm`,variant:`ghost`,className:`h-7 text-destructive`,onClick:()=>void x(t.agentId,o),children:Dt()})]}):a?(0,Z.jsx)(H,{variant:`default`,children:r()}):(0,Z.jsx)(L,{size:`sm`,variant:`outline`,className:`h-7`,disabled:!t.enabled||t.reserved!==null,onClick:()=>void y(t.agentId),children:rn()})]}),t.reserved?(0,Z.jsxs)(`div`,{className:`oc-agentcard__head`,children:[(0,Z.jsx)(L,{size:`sm`,variant:`outline`,className:`h-7`,onClick:()=>void g(t.agentId,o),children:P()}),(0,Z.jsxs)(K,{value:``,onValueChange:e=>void _(t.agentId,o,e),children:[(0,Z.jsx)(q,{size:`sm`,className:`h-7`,children:(0,Z.jsx)(U,{placeholder:Wt()})}),(0,Z.jsx)(J,{children:(f??[]).filter(e=>e._id!==t.reserved?.groupId).map(e=>(0,Z.jsx)(G,{value:e._id,children:e.name},e._id))})]})]}):null,t.enabled?(0,Z.jsx)(Un,{agentId:t.agentId,types:s,onToggle:e=>void b(t.agentId,e,s)}):null,t.enabled?(0,Z.jsx)(Gn,{value:t.description??``,onSave:async n=>{if(e)try{await c({instanceName:e,agentId:t.agentId,description:n})}catch(e){h.error(j(),e)}}}):null]},t.agentId)})})]})]})})}function Gn({value:e,onSave:t}){let[n,r]=(0,Y.useState)(e);(0,Y.useEffect)(()=>{r(e)},[e]);let i=()=>{n.trim()!==e.trim()&&t(n)};return(0,Z.jsx)(R,{className:`oc-agentcard__desc`,value:n,maxLength:280,placeholder:Je(),"aria-label":pn(),onChange:e=>r(e.target.value),onBlur:i,onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),i())}})}function $({label:e,children:t}){return(0,Z.jsxs)(`label`,{className:`oc-field`,children:[(0,Z.jsx)(`span`,{className:`oc-field__label`,children:e}),t]})}export{Pn as InstancesTab};
@@ -1 +1 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$m as r,AL as i,BY as a,CL as o,DL as s,EL as c,ML as l,OL as u,Qm as d,RY as f,SL as p,TL as m,VY as h,Xm as g,Zm as _,bL as v,eh as y,ih as b,jL as x,kL as S,nh as C,rh as w,t as T,th as E,wL as D,xL as O,yL as k}from"./api-BiOKjOdr.js";import{t as A}from"./button-D0Pgjwxf.js";import{$t as j,Jt as M,Mt as N}from"./index-xhYNLD3V.js";var P=t(e(),1),F=n();function I(){let e=h(T.integrations.status.status,{}),t=a(T.admin.setIntegrationConfig),[n,r]=(0,P.useState)(null);if((0,P.useEffect)(()=>{e&&n===null&&r(e.config)},[e,n]),!e||!n)return(0,F.jsx)(`p`,{className:`oc-admin__hint`,children:l()});let d=n,f=(e,t,n)=>r({...d,[e]:{...d[e],[t]:n}}),g=(e,n)=>void t({[e]:n});return(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`p`,{className:`oc-admin__hint`,children:[x(),` `,(0,F.jsx)(`strong`,{children:i()}),` `,S()]}),(0,F.jsxs)(L,{title:`Langfuse`,status:e.langfuse.configured?e.langfuse.enabled?(0,F.jsx)(M,{variant:`secondary`,children:u()}):(0,F.jsx)(M,{variant:`outline`,children:s()}):(0,F.jsx)(M,{variant:`outline`,children:c()}),note:m(),children:[(0,F.jsx)(R,{label:o(),children:(0,F.jsx)(j,{value:d.langfuse.host??``,placeholder:e.langfuse.effectiveHost,onChange:e=>f(`langfuse`,`host`,e.target.value),onBlur:()=>g(`langfuse`,{host:d.langfuse.host??``})})}),(0,F.jsx)(z,{label:k(),checked:d.langfuse.enabled??!0,onChange:e=>{f(`langfuse`,`enabled`,e),g(`langfuse`,{enabled:e})}})]}),(0,F.jsxs)(L,{title:`Opik`,status:e.opik.configured?e.opik.enabled?(0,F.jsx)(M,{variant:`secondary`,children:u()}):(0,F.jsx)(M,{variant:`outline`,children:s()}):(0,F.jsx)(M,{variant:`outline`,children:c()}),note:D(),children:[(0,F.jsx)(R,{label:p(),children:(0,F.jsx)(j,{value:d.opik.baseUrl??``,placeholder:e.opik.effectiveBaseUrl,onChange:e=>f(`opik`,`baseUrl`,e.target.value),onBlur:()=>g(`opik`,{baseUrl:d.opik.baseUrl??``})})}),(0,F.jsx)(R,{label:O(),children:(0,F.jsx)(j,{value:d.opik.workspace??``,placeholder:e.opik.effectiveWorkspace||v(),onChange:e=>f(`opik`,`workspace`,e.target.value),onBlur:()=>g(`opik`,{workspace:d.opik.workspace??``})})}),(0,F.jsx)(z,{label:k(),checked:d.opik.enabled??!0,onChange:e=>{f(`opik`,`enabled`,e),g(`opik`,{enabled:e})}})]}),(0,F.jsxs)(L,{title:`OpenTelemetry (OTLP)`,status:e.otlp.configured?e.otlp.enabled?(0,F.jsx)(M,{variant:`secondary`,children:u()}):(0,F.jsx)(M,{variant:`outline`,children:s()}):(0,F.jsx)(M,{variant:`outline`,children:b()}),note:w(),children:[(0,F.jsx)(R,{label:C(),children:(0,F.jsx)(j,{value:d.otlp.endpoint??``,placeholder:e.otlp.effectiveEndpoint||`https://otlp.example.com/v1/traces`,onChange:e=>f(`otlp`,`endpoint`,e.target.value),onBlur:()=>g(`otlp`,{endpoint:d.otlp.endpoint??``})})}),(0,F.jsx)(B,{headersSet:e.otlp.headersSet}),(0,F.jsx)(z,{label:k(),checked:d.otlp.enabled??!0,onChange:e=>{f(`otlp`,`enabled`,e),g(`otlp`,{enabled:e})}})]})]})}function L({title:e,status:t,note:n,children:r}){return(0,F.jsxs)(`section`,{className:`oc-int__section`,children:[(0,F.jsxs)(`div`,{className:`oc-int__section-head`,children:[(0,F.jsx)(`h3`,{className:`oc-uipa__h`,children:e}),t]}),n?(0,F.jsx)(`p`,{className:`oc-uipa__note`,children:n}):null,(0,F.jsx)(`div`,{className:`oc-int__fields`,children:r})]})}function R({label:e,children:t}){return(0,F.jsxs)(`label`,{className:`oc-int__field`,children:[(0,F.jsx)(`span`,{className:`oc-int__field-label`,children:e}),t]})}function z({label:e,checked:t,onChange:n}){return(0,F.jsxs)(`label`,{className:`oc-int__toggle`,children:[(0,F.jsx)(N,{checked:t,onCheckedChange:e=>n(e===!0)}),(0,F.jsx)(`span`,{children:e})]})}function B({headersSet:e}){let t=f(T.integrations.otlpSecret.setOtlpHeaders),n=a(T.integrations.otlpSecret.clearOtlpHeaders),[i,o]=(0,P.useState)(``),[s,c]=(0,P.useState)(null),[l,u]=(0,P.useState)(!1),p=async()=>{u(!0),c(null);try{await t({headersJson:i}),o(``)}catch(e){c(e instanceof Error?e.message:String(e))}finally{u(!1)}};return(0,F.jsxs)(R,{label:E(),children:[(0,F.jsx)(j,{value:i,placeholder:e?y():r(),onChange:e=>o(e.target.value)}),(0,F.jsxs)(`div`,{className:`oc-int__otlp-headers-actions`,children:[(0,F.jsx)(A,{size:`sm`,disabled:l||i.trim().length===0,onClick:()=>void p(),children:d()}),e?(0,F.jsx)(A,{variant:`ghost`,size:`sm`,disabled:l,onClick:()=>void n({}),children:_()}):null]}),s?(0,F.jsx)(`p`,{className:`oc-int__otlp-headers-error`,children:s}):null,(0,F.jsx)(`p`,{className:`oc-uipa__note`,children:g()})]})}export{I as IntegrationsTab};
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$m as r,AL as i,BY as a,CL as o,DL as s,EL as c,ML as l,OL as u,Qm as d,RY as f,SL as p,TL as m,VY as h,Xm as g,Zm as _,bL as v,eh as y,ih as b,jL as x,kL as S,nh as C,rh as w,t as T,th as E,wL as D,xL as O,yL as k}from"./api-DcB3BxUc.js";import{t as A}from"./button-DgaBsJDX.js";import{$t as j,Jt as M,Mt as N}from"./index-Ds-ybIOh.js";var P=t(e(),1),F=n();function I(){let e=h(T.integrations.status.status,{}),t=a(T.admin.setIntegrationConfig),[n,r]=(0,P.useState)(null);if((0,P.useEffect)(()=>{e&&n===null&&r(e.config)},[e,n]),!e||!n)return(0,F.jsx)(`p`,{className:`oc-admin__hint`,children:l()});let d=n,f=(e,t,n)=>r({...d,[e]:{...d[e],[t]:n}}),g=(e,n)=>void t({[e]:n});return(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`p`,{className:`oc-admin__hint`,children:[x(),` `,(0,F.jsx)(`strong`,{children:i()}),` `,S()]}),(0,F.jsxs)(L,{title:`Langfuse`,status:e.langfuse.configured?e.langfuse.enabled?(0,F.jsx)(M,{variant:`secondary`,children:u()}):(0,F.jsx)(M,{variant:`outline`,children:s()}):(0,F.jsx)(M,{variant:`outline`,children:c()}),note:m(),children:[(0,F.jsx)(R,{label:o(),children:(0,F.jsx)(j,{value:d.langfuse.host??``,placeholder:e.langfuse.effectiveHost,onChange:e=>f(`langfuse`,`host`,e.target.value),onBlur:()=>g(`langfuse`,{host:d.langfuse.host??``})})}),(0,F.jsx)(z,{label:k(),checked:d.langfuse.enabled??!0,onChange:e=>{f(`langfuse`,`enabled`,e),g(`langfuse`,{enabled:e})}})]}),(0,F.jsxs)(L,{title:`Opik`,status:e.opik.configured?e.opik.enabled?(0,F.jsx)(M,{variant:`secondary`,children:u()}):(0,F.jsx)(M,{variant:`outline`,children:s()}):(0,F.jsx)(M,{variant:`outline`,children:c()}),note:D(),children:[(0,F.jsx)(R,{label:p(),children:(0,F.jsx)(j,{value:d.opik.baseUrl??``,placeholder:e.opik.effectiveBaseUrl,onChange:e=>f(`opik`,`baseUrl`,e.target.value),onBlur:()=>g(`opik`,{baseUrl:d.opik.baseUrl??``})})}),(0,F.jsx)(R,{label:O(),children:(0,F.jsx)(j,{value:d.opik.workspace??``,placeholder:e.opik.effectiveWorkspace||v(),onChange:e=>f(`opik`,`workspace`,e.target.value),onBlur:()=>g(`opik`,{workspace:d.opik.workspace??``})})}),(0,F.jsx)(z,{label:k(),checked:d.opik.enabled??!0,onChange:e=>{f(`opik`,`enabled`,e),g(`opik`,{enabled:e})}})]}),(0,F.jsxs)(L,{title:`OpenTelemetry (OTLP)`,status:e.otlp.configured?e.otlp.enabled?(0,F.jsx)(M,{variant:`secondary`,children:u()}):(0,F.jsx)(M,{variant:`outline`,children:s()}):(0,F.jsx)(M,{variant:`outline`,children:b()}),note:w(),children:[(0,F.jsx)(R,{label:C(),children:(0,F.jsx)(j,{value:d.otlp.endpoint??``,placeholder:e.otlp.effectiveEndpoint||`https://otlp.example.com/v1/traces`,onChange:e=>f(`otlp`,`endpoint`,e.target.value),onBlur:()=>g(`otlp`,{endpoint:d.otlp.endpoint??``})})}),(0,F.jsx)(B,{headersSet:e.otlp.headersSet}),(0,F.jsx)(z,{label:k(),checked:d.otlp.enabled??!0,onChange:e=>{f(`otlp`,`enabled`,e),g(`otlp`,{enabled:e})}})]})]})}function L({title:e,status:t,note:n,children:r}){return(0,F.jsxs)(`section`,{className:`oc-int__section`,children:[(0,F.jsxs)(`div`,{className:`oc-int__section-head`,children:[(0,F.jsx)(`h3`,{className:`oc-uipa__h`,children:e}),t]}),n?(0,F.jsx)(`p`,{className:`oc-uipa__note`,children:n}):null,(0,F.jsx)(`div`,{className:`oc-int__fields`,children:r})]})}function R({label:e,children:t}){return(0,F.jsxs)(`label`,{className:`oc-int__field`,children:[(0,F.jsx)(`span`,{className:`oc-int__field-label`,children:e}),t]})}function z({label:e,checked:t,onChange:n}){return(0,F.jsxs)(`label`,{className:`oc-int__toggle`,children:[(0,F.jsx)(N,{checked:t,onCheckedChange:e=>n(e===!0)}),(0,F.jsx)(`span`,{children:e})]})}function B({headersSet:e}){let t=f(T.integrations.otlpSecret.setOtlpHeaders),n=a(T.integrations.otlpSecret.clearOtlpHeaders),[i,o]=(0,P.useState)(``),[s,c]=(0,P.useState)(null),[l,u]=(0,P.useState)(!1),p=async()=>{u(!0),c(null);try{await t({headersJson:i}),o(``)}catch(e){c(e instanceof Error?e.message:String(e))}finally{u(!1)}};return(0,F.jsxs)(R,{label:E(),children:[(0,F.jsx)(j,{value:i,placeholder:e?y():r(),onChange:e=>o(e.target.value)}),(0,F.jsxs)(`div`,{className:`oc-int__otlp-headers-actions`,children:[(0,F.jsx)(A,{size:`sm`,disabled:l||i.trim().length===0,onClick:()=>void p(),children:d()}),e?(0,F.jsx)(A,{variant:`ghost`,size:`sm`,disabled:l,onClick:()=>void n({}),children:_()}):null]}),s?(0,F.jsx)(`p`,{className:`oc-int__otlp-headers-error`,children:s}):null,(0,F.jsx)(`p`,{className:`oc-uipa__note`,children:g()})]})}export{I as IntegrationsTab};
@@ -1 +1 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{BD as r,GD as i,HD as a,HR as o,ID as s,JD as c,KD as l,LD as u,RD as d,UD as f,VD as p,VY as m,WD as h,XD as g,YD as _,_R as v,gR as y,hR as ee,mR as b,oR as x,qD as te,sR as S,t as C,zD as w}from"./api-BiOKjOdr.js";import{dr as T,fr as E,ft as D,i as O,o as ne,r as re}from"./index-xhYNLD3V.js";import{a as k,n as A,o as j,r as M,t as N}from"./card-BaftCgRb.js";import{n as P,t as F}from"./TimeRangePicker-BVCNIF4U.js";var I=t(e(),1),L={API_CALLS:`api.calls`,API_ERRORS:`api.errors`,API_LATENCY_AVG_MS:`api.latency.avg_ms`,OPENCLAW_INGEST:`openclaw.ingest`,CHAT_SEND:`chat.send`,ASSISTANT_STREAM_ERRORS:`assistant.stream.errors`,ASSISTANT_ANNOUNCE_ERRORS:`assistant.announce.errors`,CONVEX_PROBE_LATENCY_AVG_MS:`convex.probe.latency.avg_ms`},R=Object.keys(L).length,z=n(),B=15,V=e=>String(Math.round(e));function H(){let e=m(C.me.getMe,{host:D})?.permissions?.includes(`traces.read`)??!1,t=m(C.deliveryTiming.listDeliverySessions,e?{}:`skip`),n=(0,I.useMemo)(()=>t?t.filter(e=>!e.active&&e.rollup!==null&&e.rollup.cP50!==null&&e.rollup.aP50!==null).slice(0,B).reverse().map(e=>({startedAt:e.startedAt,cP50:e.rollup?.cP50,aP50:e.rollup?.aP50})):[],[t]);return t===void 0?null:(0,z.jsxs)(`section`,{className:`oc-kpi__group`,children:[(0,z.jsx)(`h2`,{className:`oc-kpi__group-title`,children:o()}),(0,z.jsxs)(N,{children:[(0,z.jsxs)(k,{children:[(0,z.jsx)(j,{children:v()}),(0,z.jsx)(M,{children:ee()})]}),(0,z.jsx)(A,{children:n.length<2?(0,z.jsx)(`p`,{className:`oc-admin__hint`,children:b()}):(0,z.jsx)(U,{series:n})})]})]})}function U({series:e}){let t=e.map(e=>e.cP50),n=e.map(e=>e.aP50),r=Math.max(1,...t,...n),i=t=>6+t*468/(e.length-1),a=e=>74-e*68/r,o=e=>e.map((e,t)=>`${t===0?`M`:`L`}${i(t).toFixed(1)},${a(e).toFixed(1)}`).join(` `),s=e[e.length-1];return(0,z.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,z.jsxs)(`div`,{className:`flex gap-3 text-xs text-muted-foreground`,children:[(0,z.jsxs)(`span`,{style:{color:`var(--primary)`},children:[x(),` p50 `,V(s.cP50),` `,y()]}),(0,z.jsxs)(`span`,{children:[S(),` p50 `,V(s.aP50),` `,y()]})]}),(0,z.jsxs)(`svg`,{viewBox:`0 0 480 80`,className:`h-20 w-full`,preserveAspectRatio:`none`,role:`img`,"aria-label":v(),children:[(0,z.jsx)(`path`,{d:o(n),fill:`none`,style:{stroke:`var(--muted-foreground)`},strokeWidth:1.5}),(0,z.jsx)(`path`,{d:o(t),fill:`none`,style:{stroke:`var(--primary)`},strokeWidth:1.5})]})]})}var W=[{metric:`api.calls`,label:g(),unit:`/h`,group:`API`,isError:!1},{metric:`api.errors`,label:_(),unit:`/h`,group:`API`,isError:!0},{metric:`api.latency.avg_ms`,label:c(),unit:`ms`,group:`API`,isError:!1},{metric:`openclaw.ingest`,label:te(),unit:`/h`,group:`OpenClaw`,isError:!1},{metric:`chat.send`,label:l(),unit:`/h`,group:`Chat`,isError:!1},{metric:L.ASSISTANT_STREAM_ERRORS,label:i(),unit:`/h`,group:`Assistant`,isError:!0},{metric:L.ASSISTANT_ANNOUNCE_ERRORS,label:h(),unit:`/h`,group:`Assistant`,isError:!0}],G=R,K=[`API`,`OpenClaw`,`Chat`,`Assistant`],q=1e3,J=36e5;function Y(e,t){let n=Math.max(1,Math.ceil((t-e)/J)),r=Math.min(n*G,q);return{rowLimit:r,buckets:Math.max(1,Math.floor(r/G))}}function ie(){let e=E({from:`/settings/kpi`}),t=T({from:`/settings/kpi`}),n=O(e.from,e.to,re,`now`),i=e=>void t({search:t=>({...t,...ne(e)})}),{from:o,to:s}=P(n),{rowLimit:c,buckets:l}=Y(o,s),u=m(C.kpi.listKpis,{limit:c,filter:{from:o,to:s}}),d=(0,I.useMemo)(()=>{let e=new Map;for(let t of u??[]){let n=e.get(t.metric)??[];n.push({bucket:t.bucket,value:t.value}),e.set(t.metric,n)}for(let[t,n]of e)n.sort((e,t)=>e.bucket<t.bucket?-1:+(e.bucket>t.bucket)),n.length>l&&e.set(t,n.slice(n.length-l));return e},[u,l]),h=(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`p`,{className:`oc-admin__hint`,children:[f(),` `,(0,z.jsx)(`span`,{className:`oc-filter__window`,children:a()})]}),(0,z.jsx)(ae,{value:n,onChange:i})]});return u===void 0?(0,z.jsxs)(z.Fragment,{children:[h,(0,z.jsx)(H,{}),(0,z.jsx)(`p`,{className:`oc-admin__hint`,children:p()})]}):u.length===0?(0,z.jsxs)(z.Fragment,{children:[h,(0,z.jsx)(H,{}),(0,z.jsx)(`p`,{className:`oc-admin__hint`,children:r()})]}):(0,z.jsxs)(z.Fragment,{children:[h,(0,z.jsx)(H,{}),K.map(e=>{let t=W.filter(t=>t.group===e);return t.some(e=>(d.get(e.metric)??[]).length>0)?(0,z.jsxs)(`section`,{className:`oc-kpi__group`,children:[(0,z.jsx)(`h2`,{className:`oc-kpi__group-title`,children:e}),(0,z.jsx)(`div`,{className:`oc-kpi__grid`,children:t.map(e=>(0,z.jsx)(oe,{config:e,series:d.get(e.metric)??[]},e.metric))})]},e):null})]})}function ae({value:e,onChange:t}){return(0,z.jsx)(`div`,{className:`oc-kpi__toolbar`,children:(0,z.jsx)(F,{value:e,onChange:t})})}function oe({config:e,series:t}){let n=t.length>0?t[t.length-1]:null,r=n?n.value:0;return(0,z.jsxs)(N,{size:`sm`,className:`oc-kpi__card`,children:[(0,z.jsxs)(k,{children:[(0,z.jsx)(j,{className:`oc-kpi__card-title`,children:e.label}),(0,z.jsx)(M,{className:`oc-kpi__card-metric`,children:(0,z.jsx)(`code`,{children:e.metric})})]}),(0,z.jsxs)(A,{className:`oc-kpi__card-body`,children:[(0,z.jsxs)(`div`,{className:`oc-kpi__value-row`,children:[(0,z.jsx)(`span`,{className:`oc-kpi__value`+(e.isError&&r>0?` oc-kpi__value--error`:``),children:Q(r)}),(0,z.jsx)(`span`,{className:`oc-kpi__unit`,children:e.unit})]}),(0,z.jsx)(ce,{series:t,isError:e.isError,unit:e.unit}),(0,z.jsxs)(`div`,{className:`oc-kpi__axis`,children:[n?(0,z.jsx)(`span`,{className:`oc-kpi__axis-latest`,children:w({value:$(n.bucket)})}):(0,z.jsx)(`span`,{className:`oc-kpi__muted`,children:d()}),(0,z.jsx)(`span`,{className:`oc-kpi__muted`,children:u({count:t.length})})]})]})]})}var X=240,Z=48,se=1;function ce({series:e,isError:t,unit:n}){if(e.length===0)return(0,z.jsx)(`div`,{className:`oc-kpi__chart oc-kpi__chart--empty`,"aria-hidden":!0});let r=e.reduce((e,t)=>t.value>e?t.value:e,0),i=X/e.length,a=Math.max(i-se,1);return(0,z.jsx)(`svg`,{className:`oc-kpi__chart`,viewBox:`0 0 ${X} ${Z}`,preserveAspectRatio:`none`,role:`img`,"aria-label":s({max:Q(r),unit:n}),children:e.map((e,o)=>{let s=r>0?e.value/r*(Z-1):0,c=o*i,l=Z-s;return(0,z.jsx)(`rect`,{className:`oc-kpi__bar`+(t&&e.value>0?` oc-kpi__bar--error`:``),x:c,y:l,width:a,height:s,children:(0,z.jsxs)(`title`,{children:[$(e.bucket),` · `,Q(e.value),` `,n]})},e.bucket)})})}function Q(e){return Number.isFinite(e)?Math.abs(e)>=1e3?(e/1e3).toFixed(e%1e3==0?0:1)+`k`:String(e):`0`}function $(e){let t=new Date(`${e}:00:00Z`);return Number.isNaN(t.getTime())?e:`${String(t.getUTCDate()).padStart(2,`0`)}/${String(t.getUTCMonth()+1).padStart(2,`0`)} ${String(t.getUTCHours()).padStart(2,`0`)}h`}export{ie as KpiTab};
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{BD as r,GD as i,HD as a,HR as o,ID as s,JD as c,KD as l,LD as u,RD as d,UD as f,VD as p,VY as m,WD as h,XD as g,YD as _,_R as v,gR as y,hR as ee,mR as b,oR as x,qD as te,sR as S,t as C,zD as w}from"./api-DcB3BxUc.js";import{dr as T,fr as E,ft as D,i as O,o as ne,r as re}from"./index-Ds-ybIOh.js";import{a as k,n as A,o as j,r as M,t as N}from"./card-DnOLp6jN.js";import{n as P,t as F}from"./TimeRangePicker-BgJKavXM.js";var I=t(e(),1),L={API_CALLS:`api.calls`,API_ERRORS:`api.errors`,API_LATENCY_AVG_MS:`api.latency.avg_ms`,OPENCLAW_INGEST:`openclaw.ingest`,CHAT_SEND:`chat.send`,ASSISTANT_STREAM_ERRORS:`assistant.stream.errors`,ASSISTANT_ANNOUNCE_ERRORS:`assistant.announce.errors`,CONVEX_PROBE_LATENCY_AVG_MS:`convex.probe.latency.avg_ms`},R=Object.keys(L).length,z=n(),B=15,V=e=>String(Math.round(e));function H(){let e=m(C.me.getMe,{host:D})?.permissions?.includes(`traces.read`)??!1,t=m(C.deliveryTiming.listDeliverySessions,e?{}:`skip`),n=(0,I.useMemo)(()=>t?t.filter(e=>!e.active&&e.rollup!==null&&e.rollup.cP50!==null&&e.rollup.aP50!==null).slice(0,B).reverse().map(e=>({startedAt:e.startedAt,cP50:e.rollup?.cP50,aP50:e.rollup?.aP50})):[],[t]);return t===void 0?null:(0,z.jsxs)(`section`,{className:`oc-kpi__group`,children:[(0,z.jsx)(`h2`,{className:`oc-kpi__group-title`,children:o()}),(0,z.jsxs)(N,{children:[(0,z.jsxs)(k,{children:[(0,z.jsx)(j,{children:v()}),(0,z.jsx)(M,{children:ee()})]}),(0,z.jsx)(A,{children:n.length<2?(0,z.jsx)(`p`,{className:`oc-admin__hint`,children:b()}):(0,z.jsx)(U,{series:n})})]})]})}function U({series:e}){let t=e.map(e=>e.cP50),n=e.map(e=>e.aP50),r=Math.max(1,...t,...n),i=t=>6+t*468/(e.length-1),a=e=>74-e*68/r,o=e=>e.map((e,t)=>`${t===0?`M`:`L`}${i(t).toFixed(1)},${a(e).toFixed(1)}`).join(` `),s=e[e.length-1];return(0,z.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,z.jsxs)(`div`,{className:`flex gap-3 text-xs text-muted-foreground`,children:[(0,z.jsxs)(`span`,{style:{color:`var(--primary)`},children:[x(),` p50 `,V(s.cP50),` `,y()]}),(0,z.jsxs)(`span`,{children:[S(),` p50 `,V(s.aP50),` `,y()]})]}),(0,z.jsxs)(`svg`,{viewBox:`0 0 480 80`,className:`h-20 w-full`,preserveAspectRatio:`none`,role:`img`,"aria-label":v(),children:[(0,z.jsx)(`path`,{d:o(n),fill:`none`,style:{stroke:`var(--muted-foreground)`},strokeWidth:1.5}),(0,z.jsx)(`path`,{d:o(t),fill:`none`,style:{stroke:`var(--primary)`},strokeWidth:1.5})]})]})}var W=[{metric:`api.calls`,label:g(),unit:`/h`,group:`API`,isError:!1},{metric:`api.errors`,label:_(),unit:`/h`,group:`API`,isError:!0},{metric:`api.latency.avg_ms`,label:c(),unit:`ms`,group:`API`,isError:!1},{metric:`openclaw.ingest`,label:te(),unit:`/h`,group:`OpenClaw`,isError:!1},{metric:`chat.send`,label:l(),unit:`/h`,group:`Chat`,isError:!1},{metric:L.ASSISTANT_STREAM_ERRORS,label:i(),unit:`/h`,group:`Assistant`,isError:!0},{metric:L.ASSISTANT_ANNOUNCE_ERRORS,label:h(),unit:`/h`,group:`Assistant`,isError:!0}],G=R,K=[`API`,`OpenClaw`,`Chat`,`Assistant`],q=1e3,J=36e5;function Y(e,t){let n=Math.max(1,Math.ceil((t-e)/J)),r=Math.min(n*G,q);return{rowLimit:r,buckets:Math.max(1,Math.floor(r/G))}}function ie(){let e=E({from:`/settings/kpi`}),t=T({from:`/settings/kpi`}),n=O(e.from,e.to,re,`now`),i=e=>void t({search:t=>({...t,...ne(e)})}),{from:o,to:s}=P(n),{rowLimit:c,buckets:l}=Y(o,s),u=m(C.kpi.listKpis,{limit:c,filter:{from:o,to:s}}),d=(0,I.useMemo)(()=>{let e=new Map;for(let t of u??[]){let n=e.get(t.metric)??[];n.push({bucket:t.bucket,value:t.value}),e.set(t.metric,n)}for(let[t,n]of e)n.sort((e,t)=>e.bucket<t.bucket?-1:+(e.bucket>t.bucket)),n.length>l&&e.set(t,n.slice(n.length-l));return e},[u,l]),h=(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`p`,{className:`oc-admin__hint`,children:[f(),` `,(0,z.jsx)(`span`,{className:`oc-filter__window`,children:a()})]}),(0,z.jsx)(ae,{value:n,onChange:i})]});return u===void 0?(0,z.jsxs)(z.Fragment,{children:[h,(0,z.jsx)(H,{}),(0,z.jsx)(`p`,{className:`oc-admin__hint`,children:p()})]}):u.length===0?(0,z.jsxs)(z.Fragment,{children:[h,(0,z.jsx)(H,{}),(0,z.jsx)(`p`,{className:`oc-admin__hint`,children:r()})]}):(0,z.jsxs)(z.Fragment,{children:[h,(0,z.jsx)(H,{}),K.map(e=>{let t=W.filter(t=>t.group===e);return t.some(e=>(d.get(e.metric)??[]).length>0)?(0,z.jsxs)(`section`,{className:`oc-kpi__group`,children:[(0,z.jsx)(`h2`,{className:`oc-kpi__group-title`,children:e}),(0,z.jsx)(`div`,{className:`oc-kpi__grid`,children:t.map(e=>(0,z.jsx)(oe,{config:e,series:d.get(e.metric)??[]},e.metric))})]},e):null})]})}function ae({value:e,onChange:t}){return(0,z.jsx)(`div`,{className:`oc-kpi__toolbar`,children:(0,z.jsx)(F,{value:e,onChange:t})})}function oe({config:e,series:t}){let n=t.length>0?t[t.length-1]:null,r=n?n.value:0;return(0,z.jsxs)(N,{size:`sm`,className:`oc-kpi__card`,children:[(0,z.jsxs)(k,{children:[(0,z.jsx)(j,{className:`oc-kpi__card-title`,children:e.label}),(0,z.jsx)(M,{className:`oc-kpi__card-metric`,children:(0,z.jsx)(`code`,{children:e.metric})})]}),(0,z.jsxs)(A,{className:`oc-kpi__card-body`,children:[(0,z.jsxs)(`div`,{className:`oc-kpi__value-row`,children:[(0,z.jsx)(`span`,{className:`oc-kpi__value`+(e.isError&&r>0?` oc-kpi__value--error`:``),children:Q(r)}),(0,z.jsx)(`span`,{className:`oc-kpi__unit`,children:e.unit})]}),(0,z.jsx)(ce,{series:t,isError:e.isError,unit:e.unit}),(0,z.jsxs)(`div`,{className:`oc-kpi__axis`,children:[n?(0,z.jsx)(`span`,{className:`oc-kpi__axis-latest`,children:w({value:$(n.bucket)})}):(0,z.jsx)(`span`,{className:`oc-kpi__muted`,children:d()}),(0,z.jsx)(`span`,{className:`oc-kpi__muted`,children:u({count:t.length})})]})]})]})}var X=240,Z=48,se=1;function ce({series:e,isError:t,unit:n}){if(e.length===0)return(0,z.jsx)(`div`,{className:`oc-kpi__chart oc-kpi__chart--empty`,"aria-hidden":!0});let r=e.reduce((e,t)=>t.value>e?t.value:e,0),i=X/e.length,a=Math.max(i-se,1);return(0,z.jsx)(`svg`,{className:`oc-kpi__chart`,viewBox:`0 0 ${X} ${Z}`,preserveAspectRatio:`none`,role:`img`,"aria-label":s({max:Q(r),unit:n}),children:e.map((e,o)=>{let s=r>0?e.value/r*(Z-1):0,c=o*i,l=Z-s;return(0,z.jsx)(`rect`,{className:`oc-kpi__bar`+(t&&e.value>0?` oc-kpi__bar--error`:``),x:c,y:l,width:a,height:s,children:(0,z.jsxs)(`title`,{children:[$(e.bucket),` · `,Q(e.value),` `,n]})},e.bucket)})})}function Q(e){return Number.isFinite(e)?Math.abs(e)>=1e3?(e/1e3).toFixed(e%1e3==0?0:1)+`k`:String(e):`0`}function $(e){let t=new Date(`${e}:00:00Z`);return Number.isNaN(t.getTime())?e:`${String(t.getUTCDate()).padStart(2,`0`)}/${String(t.getUTCMonth()+1).padStart(2,`0`)} ${String(t.getUTCHours()).padStart(2,`0`)}h`}export{ie as KpiTab};
@@ -1 +1 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$U as r,$s as i,AW as a,BY as o,CW as s,CY as c,DW as l,EW as u,EY as ee,MW as d,NW as f,OW as p,PW as m,QU as te,Qs as h,SW as ne,SY as re,TW as ie,VY as g,XU as ae,YU as oe,ZU as se,Zs as ce,_W as le,_Y as ue,_c as de,aW as fe,aY as pe,bW as me,bY as he,cW as _,cY as ge,dW as v,dY as y,eW as b,eY as x,ec as S,fW as C,fY as w,fc as T,gW as E,gY as D,hW as O,hY as k,iW as A,iY as j,ic as M,jW as N,jY as P,kW as F,lW as I,lY as L,mW as _e,mY as ve,nW as R,nY as ye,nc as be,oW as xe,oY as Se,pW as Ce,pY as we,r as z,rW as Te,rY as Ee,rc as De,sW as Oe,sY as ke,t as B,tW as Ae,tY as je,tc as Me,uW as Ne,uY as Pe,vW as Fe,vY as Ie,vc as Le,wW as Re,xF as ze,xW as Be,xY as Ve,yW as He,yY as Ue}from"./api-BiOKjOdr.js";import{t as V}from"./button-D0Pgjwxf.js";import{$t as H,H as We,Jt as U,Mt as W,Qt as Ge,St as Ke,Xt as qe,Yt as Je,Zt as Ye,bt as G,ft as K,t as Xe,vt as Ze,xt as Qe,yt as $e}from"./index-xhYNLD3V.js";import{t as et}from"./localePickerView-C2RmOS86.js";import{t as tt}from"./TimezoneCombobox-BB280Bgg.js";var q=t(e(),1),J=n();function nt({className:e,checked:t,onCheckedChange:n,disabled:r,...i}){return(0,J.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":t,"data-state":t?`checked`:`unchecked`,disabled:r,onClick:()=>n(!t),className:z(`peer inline-flex h-5 w-9 shrink-0 items-center rounded-full border border-transparent transition-colors outline-none`,`focus-visible:ring-2 focus-visible:ring-ring/50`,`disabled:cursor-not-allowed disabled:opacity-50`,t?`bg-primary`:`bg-input`,e),...i,children:(0,J.jsx)(`span`,{className:z(`pointer-events-none block size-4 rounded-full bg-background shadow transition-transform`,t?`translate-x-[18px]`:`translate-x-[2px]`)})})}var Y=[{id:`messages`,label:()=>m()},{id:`composer`,label:()=>f()},{id:`sidebar`,label:()=>d()},{id:`notifications`,label:()=>O()},{id:`other`,label:()=>N()}],X={showSource:{category:`messages`,label:()=>a(),help:()=>F()},showReport:{category:`messages`,label:()=>p(),help:()=>l()},copyAssistant:{category:`messages`,label:()=>u()},copyUser:{category:`messages`,label:()=>ie()},showDelete:{category:`messages`,label:()=>Re()},showTools:{category:`messages`,label:()=>s(),help:()=>ne()},voiceInput:{category:`composer`,label:()=>Be(),help:()=>me()},showUsage:{category:`composer`,label:()=>He(),help:()=>Fe()},autoReadAloud:{category:`composer`,label:()=>Le(),help:()=>de()},showChatAge:{category:`sidebar`,label:()=>le(),help:()=>E()},notifSound:{category:`notifications`,label:()=>_e(),help:()=>Ce()},notifSystem:{category:`notifications`,label:()=>C(),help:()=>v()},replySound:{category:`notifications`,label:()=>Ne(),help:()=>I()}};function Z(e){return e.toLowerCase().normalize(`NFD`).replace(/\p{Diacritic}/gu,``)}function Q(e,t){let n=Z(t.trim()),r=new Map(Y.map(e=>[e.id,e.label()])),i=new Map(Y.map(e=>[e.id,[]]));for(let t of e){let e=X[t],a=e?.category??`other`;n&&!Z(`${e?e.label():t} ${e?.help?e.help():``} ${t} ${r.get(a)??``}`).includes(n)||i.get(a).push(t)}return Y.map(e=>({id:e.id,label:r.get(e.id),keys:i.get(e.id)})).filter(e=>e.keys.length>0)}var rt=[`showSource`,`showReport`,`copyAssistant`,`copyUser`,`showDelete`,`showTools`,`voiceInput`,`showChatAge`,`showUsage`,`autoReadAloud`,`notifSound`,`notifSystem`,`replySound`],it={voiceInput:`voiceInput`};function at(e){return rt.includes(e)}function $(e){return e===`admin`}function ot(e){return e===!0?`on`:e===!1?`off`:`inherit`}function st(e){return e===`on`?!0:e===`off`?!1:null}function ct(e){return at(e)?it[e]:void 0}var lt={voiceInput:()=>r()};function ut({prefKey:e,ui:t}){let n=o(B.admin.setUiPrefDefault),r=o(B.admin.setFeatureEnabled),i=ct(e),a=i?lt[e]?.():void 0;return(0,J.jsxs)(`div`,{className:`oc-prefs__gov`,children:[(0,J.jsxs)(`div`,{className:`oc-prefs__gov-row`,children:[(0,J.jsx)(`span`,{className:`oc-prefs__gov-label`,children:Te()}),(0,J.jsxs)(Ze,{value:ot(t.defaults[e]),onValueChange:t=>void n({key:e,value:st(t)}),children:[(0,J.jsx)(Qe,{size:`sm`,className:`w-36`,children:(0,J.jsx)(Ke,{})}),(0,J.jsxs)($e,{children:[(0,J.jsx)(G,{value:`on`,children:se()}),(0,J.jsx)(G,{value:`off`,children:ae()}),(0,J.jsx)(G,{value:`inherit`,children:oe()})]})]}),i?(0,J.jsxs)(`span`,{className:`oc-prefs__gov-gate`,children:[(0,J.jsx)(W,{checked:t.featuresEnabled[i]===!0,onCheckedChange:e=>void r({key:i,enabled:e===!0}),"aria-label":R()}),R()]}):null]}),a?(0,J.jsx)(`span`,{className:`oc-prefs__gov-help`,children:a}):null]})}function dt({current:e,enabled:t}){let n=o(B.me.setDictationShortcut),[r,a]=(0,q.useState)(!1),[s,c]=(0,q.useState)(!1);return(0,q.useEffect)(()=>{if(!r)return;let e=e=>{if(e.preventDefault(),e.stopPropagation(),e.key===`Escape`){a(!1);return}let t=Ye(e);if(t===null){[`Shift`,`Control`,`Meta`,`Alt`].includes(e.key)||(c(!0),window.setTimeout(()=>c(!1),1800));return}a(!1),n({shortcut:t})};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[r,n]),(0,J.jsxs)(`div`,{className:`oc-prefs__row${t?``:` is-locked`}`,children:[(0,J.jsxs)(`div`,{className:`oc-prefs__info`,children:[(0,J.jsxs)(`span`,{className:`oc-prefs__label`,children:[M(),e?(0,J.jsx)(U,{variant:`secondary`,children:Ge(e,qe())}):null]}),(0,J.jsx)(`span`,{className:`oc-prefs__help`,children:s?Me():r?be():De()})]}),(0,J.jsxs)(`div`,{className:`oc-prefs__ctl`,children:[e&&!r?(0,J.jsx)(`button`,{type:`button`,className:`oc-prefs__reset`,onClick:()=>void n({shortcut:null}),children:ce()}):null,(0,J.jsx)(`button`,{type:`button`,className:`oc-prefs__reset`,disabled:!t,"aria-pressed":r,onClick:()=>a(e=>!e),children:r?h():e?i():S()})]})]})}function ft(){let[e,t]=(0,q.useState)(``),[n,r]=(0,q.useState)(!1),i=g(B.me.getMe,{host:K}),a=i?.ui,s=$(i?.role)&&n,c=o(B.me.setUiPref).withOptimisticUpdate(We),l=(0,q.useMemo)(()=>a?Q(Object.keys(a.effective),e):[],[a,e]);return a?(0,J.jsxs)(`div`,{className:`oc-prefs-panel`,children:[$(i?.role)?(0,J.jsxs)(`label`,{className:`oc-prefs__gov-toggle`,children:[(0,J.jsx)(W,{checked:n,onCheckedChange:e=>r(e===!0),"aria-label":A()}),A()]}):null,s?(0,J.jsxs)(`div`,{className:`oc-prefs__gov-head`,children:[(0,J.jsx)(`p`,{children:Ae()}),(0,J.jsx)(`p`,{children:b()}),(0,J.jsx)(`p`,{children:te()})]}):null,(0,J.jsx)(H,{value:e,onChange:e=>t(e.target.value),placeholder:_(),"aria-label":_(),className:`mb-2`}),l.length===0?(0,J.jsx)(`div`,{className:`oc-prefs__empty`,children:Oe()}):(0,J.jsx)(`div`,{className:`oc-prefs`,children:l.map(e=>(0,J.jsxs)(`section`,{className:`oc-prefs__card`,children:[(0,J.jsx)(`h4`,{className:`oc-prefs__cat`,children:e.label}),e.keys.map(e=>{let t=X[e],n=t?t.label():e,r=t?.help?.(),i=a.locked[e],o=a.effective[e],l=a.userOverrides[e]!==void 0;return(0,J.jsxs)(`div`,{className:`oc-prefs__row${i?` is-locked`:``}`,children:[(0,J.jsxs)(`div`,{className:`oc-prefs__info`,children:[(0,J.jsxs)(`span`,{className:`oc-prefs__label`,children:[n,i?(0,J.jsx)(U,{variant:`outline`,children:xe()}):l?(0,J.jsx)(U,{variant:`secondary`,children:T()}):null]}),r?(0,J.jsx)(`span`,{className:`oc-prefs__help`,children:r}):null]}),(0,J.jsxs)(`div`,{className:`oc-prefs__ctl`,children:[!i&&l?(0,J.jsx)(`button`,{type:`button`,className:`oc-prefs__reset`,onClick:()=>void c({key:e,value:null}),children:fe()}):null,(0,J.jsx)(nt,{checked:o,disabled:i,onCheckedChange:t=>{e===`notifSystem`&&t&&typeof Notification<`u`&&Notification.permission==="default"&&Notification.requestPermission(),c({key:e,value:t})},"aria-label":n})]}),s?(0,J.jsx)(ut,{prefKey:e,ui:a}):null]},e)})]},e.id))}),(0,J.jsx)(dt,{current:i?.dictationShortcut??null,enabled:a.effective.voiceInput===!0})]}):(0,J.jsx)(`div`,{className:`oc-prefs__empty`,children:P()})}var pt={sm:()=>y(),md:()=>Pe(),lg:()=>L(),xl:()=>ge(),"2xl":()=>ke(),"3xl":()=>Se()};function mt(){let e=g(B.me.getMe,{host:K}),t=o(B.me.setLocale),n=o(B.me.setTimezone),r=o(B.me.setFontScale).withOptimisticUpdate((e,{scale:t})=>{let n=e.getQuery(B.me.getMe,{host:K});n&&e.setQuery(B.me.getMe,{host:K},{...n,fontScale:t,resolvedFontScale:t??`md`})}),i=o(B.me.setMyName),a=Je(),s=e?.locale??`default`,l=e?.name??``,[u,d]=(0,q.useState)(null),f=u??l,p=f.trim()!==l.trim();async function m(){try{await i({name:f}),d(null),a.success(Ue())}catch(e){a.error(Ie(),e)}}return(0,J.jsxs)(`div`,{className:`oc-appearance`,children:[(0,J.jsxs)(`section`,{className:`oc-show__section`,children:[(0,J.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,J.jsx)(`h2`,{className:`oc-show__title`,children:c()}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:re()})]}),(0,J.jsxs)(`div`,{className:`oc-show__row`,children:[(0,J.jsx)(H,{className:`max-w-xs`,value:f,maxLength:120,placeholder:Ve(),onChange:e=>d(e.target.value),onKeyDown:e=>{e.key===`Enter`&&p&&(e.preventDefault(),m())}}),(0,J.jsx)(V,{size:`sm`,disabled:!p,onClick:()=>void m(),children:ze()})]}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:he()})]}),(0,J.jsxs)(`section`,{className:`oc-show__section`,children:[(0,J.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,J.jsx)(`h2`,{className:`oc-show__title`,children:ue()}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:D()})]}),(0,J.jsxs)(`div`,{className:`oc-show__row`,children:[et().map(e=>(0,J.jsx)(V,{variant:s===e.value?`default`:`outline`,size:`sm`,onClick:()=>void t({locale:e.value}),children:e.label},e.value)),(0,J.jsx)(V,{variant:s==="default"?`default`:`outline`,size:`sm`,onClick:()=>void t({locale:null}),children:ee()})]}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:k()})]}),(0,J.jsxs)(`section`,{className:`oc-show__section`,children:[(0,J.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,J.jsx)(`h2`,{className:`oc-show__title`,children:pe()}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:j()})]}),(0,J.jsxs)(`div`,{className:`oc-show__row`,children:[(0,J.jsx)(tt,{value:e?.timezone??``,onChange:e=>void n({timezone:e})}),(0,J.jsx)(V,{variant:e?.timezone===null||e?.timezone===void 0?`default`:`outline`,size:`sm`,onClick:()=>void n({timezone:null}),children:Ee()})]}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:ye()})]}),(0,J.jsxs)(`section`,{className:`oc-show__section`,children:[(0,J.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,J.jsx)(`h2`,{className:`oc-show__title`,children:ve()}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:we()})]}),(0,J.jsx)(`div`,{className:`oc-show__row`,children:Xe.map(t=>(0,J.jsx)(V,{variant:(e?.fontScale??`md`)===t?`default`:`outline`,size:`sm`,onClick:()=>void r({scale:t}),children:pt[t]()},t))}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:w()})]}),(0,J.jsxs)(`section`,{className:`oc-show__section`,children:[(0,J.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,J.jsx)(`h2`,{className:`oc-show__title`,children:je()}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:x()})]}),(0,J.jsx)(ft,{})]})]})}export{mt as PreferencesTab};
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$U as r,$s as i,AW as a,BY as o,CW as s,CY as c,DW as l,EW as u,EY as ee,MW as d,NW as f,OW as p,PW as m,QU as te,Qs as h,SW as ne,SY as re,TW as ie,VY as g,XU as ae,YU as oe,ZU as se,Zs as ce,_W as le,_Y as ue,_c as de,aW as fe,aY as pe,bW as me,bY as he,cW as _,cY as ge,dW as v,dY as y,eW as b,eY as x,ec as S,fW as C,fY as w,fc as T,gW as E,gY as D,hW as O,hY as k,iW as A,iY as j,ic as M,jW as N,jY as P,kW as F,lW as I,lY as L,mW as _e,mY as ve,nW as R,nY as ye,nc as be,oW as xe,oY as Se,pW as Ce,pY as we,r as z,rW as Te,rY as Ee,rc as De,sW as Oe,sY as ke,t as B,tW as Ae,tY as je,tc as Me,uW as Ne,uY as Pe,vW as Fe,vY as Ie,vc as Le,wW as Re,xF as ze,xW as Be,xY as Ve,yW as He,yY as Ue}from"./api-DcB3BxUc.js";import{t as V}from"./button-DgaBsJDX.js";import{$t as H,H as We,Jt as U,Mt as W,Qt as Ge,St as Ke,Xt as qe,Yt as Je,Zt as Ye,bt as G,ft as K,t as Xe,vt as Ze,xt as Qe,yt as $e}from"./index-Ds-ybIOh.js";import{t as et}from"./localePickerView-C2RmOS86.js";import{t as tt}from"./TimezoneCombobox-BkDGMdB2.js";var q=t(e(),1),J=n();function nt({className:e,checked:t,onCheckedChange:n,disabled:r,...i}){return(0,J.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":t,"data-state":t?`checked`:`unchecked`,disabled:r,onClick:()=>n(!t),className:z(`peer inline-flex h-5 w-9 shrink-0 items-center rounded-full border border-transparent transition-colors outline-none`,`focus-visible:ring-2 focus-visible:ring-ring/50`,`disabled:cursor-not-allowed disabled:opacity-50`,t?`bg-primary`:`bg-input`,e),...i,children:(0,J.jsx)(`span`,{className:z(`pointer-events-none block size-4 rounded-full bg-background shadow transition-transform`,t?`translate-x-[18px]`:`translate-x-[2px]`)})})}var Y=[{id:`messages`,label:()=>m()},{id:`composer`,label:()=>f()},{id:`sidebar`,label:()=>d()},{id:`notifications`,label:()=>O()},{id:`other`,label:()=>N()}],X={showSource:{category:`messages`,label:()=>a(),help:()=>F()},showReport:{category:`messages`,label:()=>p(),help:()=>l()},copyAssistant:{category:`messages`,label:()=>u()},copyUser:{category:`messages`,label:()=>ie()},showDelete:{category:`messages`,label:()=>Re()},showTools:{category:`messages`,label:()=>s(),help:()=>ne()},voiceInput:{category:`composer`,label:()=>Be(),help:()=>me()},showUsage:{category:`composer`,label:()=>He(),help:()=>Fe()},autoReadAloud:{category:`composer`,label:()=>Le(),help:()=>de()},showChatAge:{category:`sidebar`,label:()=>le(),help:()=>E()},notifSound:{category:`notifications`,label:()=>_e(),help:()=>Ce()},notifSystem:{category:`notifications`,label:()=>C(),help:()=>v()},replySound:{category:`notifications`,label:()=>Ne(),help:()=>I()}};function Z(e){return e.toLowerCase().normalize(`NFD`).replace(/\p{Diacritic}/gu,``)}function Q(e,t){let n=Z(t.trim()),r=new Map(Y.map(e=>[e.id,e.label()])),i=new Map(Y.map(e=>[e.id,[]]));for(let t of e){let e=X[t],a=e?.category??`other`;n&&!Z(`${e?e.label():t} ${e?.help?e.help():``} ${t} ${r.get(a)??``}`).includes(n)||i.get(a).push(t)}return Y.map(e=>({id:e.id,label:r.get(e.id),keys:i.get(e.id)})).filter(e=>e.keys.length>0)}var rt=[`showSource`,`showReport`,`copyAssistant`,`copyUser`,`showDelete`,`showTools`,`voiceInput`,`showChatAge`,`showUsage`,`autoReadAloud`,`notifSound`,`notifSystem`,`replySound`],it={voiceInput:`voiceInput`};function at(e){return rt.includes(e)}function $(e){return e===`admin`}function ot(e){return e===!0?`on`:e===!1?`off`:`inherit`}function st(e){return e===`on`?!0:e===`off`?!1:null}function ct(e){return at(e)?it[e]:void 0}var lt={voiceInput:()=>r()};function ut({prefKey:e,ui:t}){let n=o(B.admin.setUiPrefDefault),r=o(B.admin.setFeatureEnabled),i=ct(e),a=i?lt[e]?.():void 0;return(0,J.jsxs)(`div`,{className:`oc-prefs__gov`,children:[(0,J.jsxs)(`div`,{className:`oc-prefs__gov-row`,children:[(0,J.jsx)(`span`,{className:`oc-prefs__gov-label`,children:Te()}),(0,J.jsxs)(Ze,{value:ot(t.defaults[e]),onValueChange:t=>void n({key:e,value:st(t)}),children:[(0,J.jsx)(Qe,{size:`sm`,className:`w-36`,children:(0,J.jsx)(Ke,{})}),(0,J.jsxs)($e,{children:[(0,J.jsx)(G,{value:`on`,children:se()}),(0,J.jsx)(G,{value:`off`,children:ae()}),(0,J.jsx)(G,{value:`inherit`,children:oe()})]})]}),i?(0,J.jsxs)(`span`,{className:`oc-prefs__gov-gate`,children:[(0,J.jsx)(W,{checked:t.featuresEnabled[i]===!0,onCheckedChange:e=>void r({key:i,enabled:e===!0}),"aria-label":R()}),R()]}):null]}),a?(0,J.jsx)(`span`,{className:`oc-prefs__gov-help`,children:a}):null]})}function dt({current:e,enabled:t}){let n=o(B.me.setDictationShortcut),[r,a]=(0,q.useState)(!1),[s,c]=(0,q.useState)(!1);return(0,q.useEffect)(()=>{if(!r)return;let e=e=>{if(e.preventDefault(),e.stopPropagation(),e.key===`Escape`){a(!1);return}let t=Ye(e);if(t===null){[`Shift`,`Control`,`Meta`,`Alt`].includes(e.key)||(c(!0),window.setTimeout(()=>c(!1),1800));return}a(!1),n({shortcut:t})};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[r,n]),(0,J.jsxs)(`div`,{className:`oc-prefs__row${t?``:` is-locked`}`,children:[(0,J.jsxs)(`div`,{className:`oc-prefs__info`,children:[(0,J.jsxs)(`span`,{className:`oc-prefs__label`,children:[M(),e?(0,J.jsx)(U,{variant:`secondary`,children:Ge(e,qe())}):null]}),(0,J.jsx)(`span`,{className:`oc-prefs__help`,children:s?Me():r?be():De()})]}),(0,J.jsxs)(`div`,{className:`oc-prefs__ctl`,children:[e&&!r?(0,J.jsx)(`button`,{type:`button`,className:`oc-prefs__reset`,onClick:()=>void n({shortcut:null}),children:ce()}):null,(0,J.jsx)(`button`,{type:`button`,className:`oc-prefs__reset`,disabled:!t,"aria-pressed":r,onClick:()=>a(e=>!e),children:r?h():e?i():S()})]})]})}function ft(){let[e,t]=(0,q.useState)(``),[n,r]=(0,q.useState)(!1),i=g(B.me.getMe,{host:K}),a=i?.ui,s=$(i?.role)&&n,c=o(B.me.setUiPref).withOptimisticUpdate(We),l=(0,q.useMemo)(()=>a?Q(Object.keys(a.effective),e):[],[a,e]);return a?(0,J.jsxs)(`div`,{className:`oc-prefs-panel`,children:[$(i?.role)?(0,J.jsxs)(`label`,{className:`oc-prefs__gov-toggle`,children:[(0,J.jsx)(W,{checked:n,onCheckedChange:e=>r(e===!0),"aria-label":A()}),A()]}):null,s?(0,J.jsxs)(`div`,{className:`oc-prefs__gov-head`,children:[(0,J.jsx)(`p`,{children:Ae()}),(0,J.jsx)(`p`,{children:b()}),(0,J.jsx)(`p`,{children:te()})]}):null,(0,J.jsx)(H,{value:e,onChange:e=>t(e.target.value),placeholder:_(),"aria-label":_(),className:`mb-2`}),l.length===0?(0,J.jsx)(`div`,{className:`oc-prefs__empty`,children:Oe()}):(0,J.jsx)(`div`,{className:`oc-prefs`,children:l.map(e=>(0,J.jsxs)(`section`,{className:`oc-prefs__card`,children:[(0,J.jsx)(`h4`,{className:`oc-prefs__cat`,children:e.label}),e.keys.map(e=>{let t=X[e],n=t?t.label():e,r=t?.help?.(),i=a.locked[e],o=a.effective[e],l=a.userOverrides[e]!==void 0;return(0,J.jsxs)(`div`,{className:`oc-prefs__row${i?` is-locked`:``}`,children:[(0,J.jsxs)(`div`,{className:`oc-prefs__info`,children:[(0,J.jsxs)(`span`,{className:`oc-prefs__label`,children:[n,i?(0,J.jsx)(U,{variant:`outline`,children:xe()}):l?(0,J.jsx)(U,{variant:`secondary`,children:T()}):null]}),r?(0,J.jsx)(`span`,{className:`oc-prefs__help`,children:r}):null]}),(0,J.jsxs)(`div`,{className:`oc-prefs__ctl`,children:[!i&&l?(0,J.jsx)(`button`,{type:`button`,className:`oc-prefs__reset`,onClick:()=>void c({key:e,value:null}),children:fe()}):null,(0,J.jsx)(nt,{checked:o,disabled:i,onCheckedChange:t=>{e===`notifSystem`&&t&&typeof Notification<`u`&&Notification.permission==="default"&&Notification.requestPermission(),c({key:e,value:t})},"aria-label":n})]}),s?(0,J.jsx)(ut,{prefKey:e,ui:a}):null]},e)})]},e.id))}),(0,J.jsx)(dt,{current:i?.dictationShortcut??null,enabled:a.effective.voiceInput===!0})]}):(0,J.jsx)(`div`,{className:`oc-prefs__empty`,children:P()})}var pt={sm:()=>y(),md:()=>Pe(),lg:()=>L(),xl:()=>ge(),"2xl":()=>ke(),"3xl":()=>Se()};function mt(){let e=g(B.me.getMe,{host:K}),t=o(B.me.setLocale),n=o(B.me.setTimezone),r=o(B.me.setFontScale).withOptimisticUpdate((e,{scale:t})=>{let n=e.getQuery(B.me.getMe,{host:K});n&&e.setQuery(B.me.getMe,{host:K},{...n,fontScale:t,resolvedFontScale:t??`md`})}),i=o(B.me.setMyName),a=Je(),s=e?.locale??`default`,l=e?.name??``,[u,d]=(0,q.useState)(null),f=u??l,p=f.trim()!==l.trim();async function m(){try{await i({name:f}),d(null),a.success(Ue())}catch(e){a.error(Ie(),e)}}return(0,J.jsxs)(`div`,{className:`oc-appearance`,children:[(0,J.jsxs)(`section`,{className:`oc-show__section`,children:[(0,J.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,J.jsx)(`h2`,{className:`oc-show__title`,children:c()}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:re()})]}),(0,J.jsxs)(`div`,{className:`oc-show__row`,children:[(0,J.jsx)(H,{className:`max-w-xs`,value:f,maxLength:120,placeholder:Ve(),onChange:e=>d(e.target.value),onKeyDown:e=>{e.key===`Enter`&&p&&(e.preventDefault(),m())}}),(0,J.jsx)(V,{size:`sm`,disabled:!p,onClick:()=>void m(),children:ze()})]}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:he()})]}),(0,J.jsxs)(`section`,{className:`oc-show__section`,children:[(0,J.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,J.jsx)(`h2`,{className:`oc-show__title`,children:ue()}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:D()})]}),(0,J.jsxs)(`div`,{className:`oc-show__row`,children:[et().map(e=>(0,J.jsx)(V,{variant:s===e.value?`default`:`outline`,size:`sm`,onClick:()=>void t({locale:e.value}),children:e.label},e.value)),(0,J.jsx)(V,{variant:s==="default"?`default`:`outline`,size:`sm`,onClick:()=>void t({locale:null}),children:ee()})]}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:k()})]}),(0,J.jsxs)(`section`,{className:`oc-show__section`,children:[(0,J.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,J.jsx)(`h2`,{className:`oc-show__title`,children:pe()}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:j()})]}),(0,J.jsxs)(`div`,{className:`oc-show__row`,children:[(0,J.jsx)(tt,{value:e?.timezone??``,onChange:e=>void n({timezone:e})}),(0,J.jsx)(V,{variant:e?.timezone===null||e?.timezone===void 0?`default`:`outline`,size:`sm`,onClick:()=>void n({timezone:null}),children:Ee()})]}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:ye()})]}),(0,J.jsxs)(`section`,{className:`oc-show__section`,children:[(0,J.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,J.jsx)(`h2`,{className:`oc-show__title`,children:ve()}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:we()})]}),(0,J.jsx)(`div`,{className:`oc-show__row`,children:Xe.map(t=>(0,J.jsx)(V,{variant:(e?.fontScale??`md`)===t?`default`:`outline`,size:`sm`,onClick:()=>void r({scale:t}),children:pt[t]()},t))}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:w()})]}),(0,J.jsxs)(`section`,{className:`oc-show__section`,children:[(0,J.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,J.jsx)(`h2`,{className:`oc-show__title`,children:je()}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:x()})]}),(0,J.jsx)(ft,{})]})]})}export{mt as PreferencesTab};
@@ -1 +1 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{AE as r,AT as i,BE as a,BY as o,DE as s,E as c,EE as l,FE as u,GE as d,HE as ee,IE as te,JE as f,KE as p,LE as ne,ME as m,NE as h,OE as g,PE as _,QE as v,RE as y,TE as re,To as ie,UE as ae,VE as oe,VY as b,WE as se,XE as ce,YE as le,ZE as ue,_D as de,_E as fe,dE as pe,eD as x,fD as S,fE as me,gE as C,hE as w,iD as he,jE as T,jY as E,lD as ge,mE as D,oD as O,pD as _e,pE as ve,rD as ye,t as k,uC as be,uD as xe,uE as Se,vD as Ce,wo as we,xE as Te,yD as Ee,yE as A,zE as De}from"./api-BiOKjOdr.js";import{r as Oe}from"./dist-DAKYY4yE.js";import{t as ke}from"./list-Dx86Q3WV.js";import{t as j}from"./button-D0Pgjwxf.js";import{$n as Ae,$t as je,A as M,An as Me,Bn as N,C as P,D as Ne,E as Pe,Gn as Fe,I as Ie,Kn as Le,M as Re,N as ze,O as Be,P as F,Qn as Ve,S as He,T as Ue,Un as I,Vn as We,Xn as L,Yt as Ge,Zn as Ke,_ as qe,_t as Je,an as Ye,b as Xe,ct as Ze,d as Qe,dr as R,en as $e,er as et,f as tt,fr as nt,g as rt,gt as z,h as it,ht as B,in as at,j as V,k as ot,lt as st,mt as ct,nn as H,p as lt,pr as U,pt as ut,rn as dt,sr as ft,tn as pt,tr as mt,v as W,w as G,x as K,y as ht,zn as gt}from"./index-xhYNLD3V.js";var _t=c(`columns-3`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}]]),vt=c(`folder-input`,[[`path`,{d:`M2 9V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-1`,key:`fm4g5t`}],[`path`,{d:`M2 13h10`,key:`pgb2dq`}],[`path`,{d:`m9 16 3-3-3-3`,key:`6m91ic`}]]),yt=c(`layout-grid`,[[`rect`,{width:`7`,height:`7`,x:`3`,y:`3`,rx:`1`,key:`1g98yp`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`3`,rx:`1`,key:`6d4xhi`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`14`,rx:`1`,key:`nxv5o0`}],[`rect`,{width:`7`,height:`7`,x:`3`,y:`14`,rx:`1`,key:`1bb6yr`}]]),q=c(`panel-left`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}]]),J=t(e(),1),Y=n();function bt({className:e}){return(0,Y.jsx)(Ye,{asChild:!0,children:(0,Y.jsx)(j,{variant:`ghost`,size:`icon-xs`,"aria-label":fe(),className:e,onClick:e=>e.stopPropagation(),onMouseDown:e=>e.stopPropagation(),onTouchStart:e=>e.stopPropagation(),onPointerDown:e=>e.stopPropagation(),children:(0,Y.jsx)(mt,{})})})}function X({folderId:e,name:t,color:n,currentParentId:r,className:i,onOpen:a}){let c=o(k.projects.renameProject),l=o(k.projects.setProjectColor),u=o(k.projects.moveProject),ee=o(k.projects.deleteProject),te=o(k.projects.createProject),f=Ze(),p=it(),ne=st(),[m,h]=(0,J.useState)(!1),[g,_]=(0,J.useState)(t),[v,y]=(0,J.useState)(!1),[ie,ae]=(0,J.useState)(!1),oe=b(k.projects.projectTreeCount,ie?{projectId:e}:`skip`);return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)($e,{onOpenChange:e=>e&&ae(!0),children:[(0,Y.jsx)(bt,{className:i}),(0,Y.jsxs)(pt,{align:`end`,className:`w-48`,onClick:e=>e.stopPropagation(),children:[(0,Y.jsxs)(H,{onSelect:()=>a(),children:[(0,Y.jsx)(Ve,{}),` `,x()]}),(0,Y.jsxs)(H,{onSelect:()=>{_(t),h(!0)},children:[(0,Y.jsx)(We,{}),` `,C()]}),(0,Y.jsxs)(H,{onSelect:()=>{requestAnimationFrame(async()=>{let t=await ne({title:d(),label:Ee(),placeholder:Ce(),confirmLabel:de()});t&&await te({name:t,parentId:e})})},children:[(0,Y.jsx)(Ke,{}),` `,d()]}),(0,Y.jsxs)(H,{onSelect:()=>y(!0),children:[(0,Y.jsx)(vt,{}),` `,s()]}),(0,Y.jsx)(dt,{children:ve()}),(0,Y.jsxs)(`div`,{className:`oc-colorgrid`,onClick:e=>e.stopPropagation(),children:[(0,Y.jsx)(`button`,{className:`oc-colorgrid__none`,onClick:()=>void l({projectId:e,color:null}),"aria-label":me(),children:`✕`}),qe.map(t=>(0,Y.jsx)(`button`,{className:`oc-colorgrid__dot`+(n===t.value?` is-selected`:``),style:{background:t.hue},"aria-label":t.value,onClick:()=>void l({projectId:e,color:t.value})},t.value))]}),(0,Y.jsx)(at,{}),(0,Y.jsxs)(H,{variant:`destructive`,onSelect:()=>{requestAnimationFrame(async()=>{let n=oe?.folders??0,r=oe?.chats??0;await f({title:ye({name:t}),description:lt({folders:n,chats:r,days:p}),confirmWord:A(),confirmLabel:he(),destructive:!0})&&await ee({projectId:e})})},children:[(0,Y.jsx)(Me,{}),` `,A()]})]})]}),(0,Y.jsx)(Xe,{open:m,onOpenChange:h,title:ge(),canSubmit:g.trim().length>0,onSubmit:async()=>{await c({projectId:e,name:g.trim()}),h(!1)},submitLabel:C(),children:(0,Y.jsx)(je,{value:g,onChange:e=>_(e.target.value),autoFocus:!0})}),v?(0,Y.jsx)(rt,{open:v,onOpenChange:y,title:re(),movingFolderId:e,currentId:r,onPick:t=>void u({projectId:e,parentId:t})}):null]})}function xt({chat:e,currentFolderId:t,className:n}){let r=o(k.chats.pinChat),a=o(k.chats.deleteChat),s=o(k.chats.renameChat),c=o(k.chats.setChatSidebar),u=o(k.chats.moveChatToProject),d=Ze(),ee=it(),[te,f]=(0,J.useState)(!1),[p,ne]=(0,J.useState)(e.title??``),[m,h]=(0,J.useState)(!1);return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)($e,{children:[(0,Y.jsx)(bt,{className:n}),(0,Y.jsxs)(pt,{align:`end`,className:`w-52`,onClick:e=>e.stopPropagation(),children:[(0,Y.jsxs)(H,{onSelect:()=>{ne(e.title??``),f(!0)},children:[(0,Y.jsx)(We,{}),` `,C()]}),(0,Y.jsxs)(H,{onSelect:()=>void r({chatId:e._id,pinned:!e.pinned}),children:[e.pinned?(0,Y.jsx)(gt,{}):(0,Y.jsx)(N,{}),e.pinned?w():D()]}),(0,Y.jsxs)(H,{onSelect:()=>h(!0),children:[(0,Y.jsx)(vt,{}),` `,g()]}),e.pinned&&e.inSidebar?null:(0,Y.jsxs)(H,{onSelect:()=>void c({chatId:e._id,hidden:e.inSidebar}),children:[e.inSidebar?(0,Y.jsx)(I,{}):(0,Y.jsx)(q,{}),e.inSidebar?ue():v()]}),(0,Y.jsx)(at,{}),(0,Y.jsxs)(H,{variant:`destructive`,onSelect:()=>{requestAnimationFrame(async()=>{await d({title:pe(),description:Se({days:ee}),confirmLabel:A(),destructive:!0})&&await a({chatId:e._id})})},children:[(0,Y.jsx)(Me,{}),` `,A()]})]})]}),(0,Y.jsx)(Xe,{open:te,onOpenChange:f,title:i(),canSubmit:p.trim().length>0,onSubmit:async()=>{await s({chatId:e._id,title:p.trim()}),f(!1)},submitLabel:C(),children:(0,Y.jsx)(je,{value:p,onChange:e=>ne(e.target.value),autoFocus:!0})}),m?(0,Y.jsx)(rt,{open:m,onOpenChange:h,title:l(),currentId:t,onPick:t=>void u({chatId:e._id,projectId:t})}):null]})}function St(e,t){let n=t.trim().toLowerCase();return n===``?e:e.filter(e=>(e.title??``).toLowerCase().includes(n))}function Ct(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 wt(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 Tt=`oc.projpage.view`;function Et(){let e=localStorage.getItem(Tt);return e===`cards`||e===`list`?e:`columns`}var Z=e=>`into:${e}`,Dt=e=>`col:${e??`null`}`,Ot=e=>`crumb:${e}`;function kt(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 At(){let{projectId:e}=U({from:`/project/$projectId`}),t=R(),n=b(k.projects.projectPage,{projectId:e});return(0,Y.jsx)(`div`,{className:`oc-projpage`,children:n===void 0?(0,Y.jsx)(`p`,{className:`oc-projpage__hint`,children:E()}):n===null?(0,Y.jsxs)(`div`,{className:`oc-projpage__notfound`,children:[(0,Y.jsx)(`h2`,{children:h()}),(0,Y.jsx)(`p`,{className:`oc-projpage__hint`,children:m()}),(0,Y.jsx)(j,{variant:`outline`,onClick:()=>void t({to:`/`}),children:T()})]}):(0,Y.jsx)(jt,{page:n})})}function jt({page:e}){let t=R(),n=Ze(),i=it(),c=st(),l=Ge(),m=o(k.projects.renameProject),h=o(k.projects.setProjectColor),g=o(k.projects.deleteProject),v=o(k.projects.createProject),y=o(k.projects.moveProject),ae=o(k.projects.setProjectSidebar),se=o(k.chats.moveChatToProject),ue=o(k.chats.reorderChat),fe=o(k.projects.reorderProject),pe=b(k.projects.projectTreeCount,{projectId:e.project._id}),[x,S]=(0,J.useState)(Et),w=e=>{localStorage.setItem(Tt,e),S(e)},T=b(k.projects.folderColumns,x===`columns`?{projectId:e.project._id}:`skip`),E=b(k.projects.projectTreeList,x===`list`?{projectId:e.project._id}:`skip`),{c:D}=nt({from:`/project/$projectId`}),O=b(k.projects.listProjects,{}),Se=b(k.chatReads.myBusyChats,{}),De=(0,J.useMemo)(()=>new Set(Se??[]),[Se]),{byChat:Oe}=Je(Se??null),N=b(k.chatReads.myChatReads,{}),P=(0,J.useMemo)(()=>wt(e.chats,N??[]),[e.chats,N]),{startNewChat:F,picker:Ve}=Qe(e=>void t({to:`/chat/$chatId`,params:{chatId:e}})),[I,tt]=(0,J.useState)(``),[z,V]=(0,J.useState)(!1),[U,ft]=(0,J.useState)(e.project.name),[W,gt]=(0,J.useState)(!1),[q,bt]=(0,J.useState)(``);(0,J.useEffect)(()=>{let e=setTimeout(()=>bt(I.trim()),180);return()=>clearTimeout(e)},[I]);let X=b(k.search.searchConversations,q.length>=2?{query:q,projectId:e.project._id}:`skip`),xt=ze(Re(Ne,{activationConstraint:{distance:4}}),Re(Be,{activationConstraint:{delay:250,tolerance:8}})),Z=(0,J.useRef)(!1),Dt=()=>{Z.current=!0,setTimeout(()=>{Z.current=!1},0)},[Ot,At]=(0,J.useState)(null),jt=t=>{if(t.startsWith(`chat:`)){let n=t.slice(5),r=e.chats.find(e=>e._id===n),i=T?.columns.flatMap(e=>e.chats).find(e=>e._id===n);return{kind:`chat`,label:(r??i)?.title||_e()}}if(t.startsWith(`folder:`)){let e=t.slice(7);return{kind:`folder`,label:(O??[]).find(t=>t._id===e)?.name??``}}return null},Q=e=>At(jt(String(e.active.id))),$=(0,J.useCallback)(e=>{let t=String(e.active.id).startsWith(`folder:`),n=t=>({...e,droppableContainers:e.droppableContainers.filter(e=>String(e.id).startsWith(t))}),r=M(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=M(n(t?`folder:`:`chat:`));if(i.length>0)return i;let a=M(n(`crumb:`));if(a.length>0)return a;let o=M(n(`col:`));return o.length>0?o:ot(n(t?`folder:`:`chat:`))},[]),It=t=>{if(x===`columns`){for(let e of T?.columns??[])if(e.chats.some(e=>e._id===t))return{list:e.chats,folderId:e.folderId};return null}if(x===`list`){let e=E?.chats.find(e=>e._id===t);return e?{list:E.chats.filter(t=>t.folderId===e.folderId),folderId:e.folderId}:null}return e.chats.some(e=>e._id===t)?{list:e.chats,folderId:e.project._id}:null},Lt=t=>{if(x===`columns`){for(let e of T?.columns??[])if(e.folders.some(e=>e._id===t))return{list:e.folders,parentId:e.folderId};return null}if(x===`list`){let e=E?.folders.find(e=>e._id===t);if(!e||!E)return null;let n=e.parentId??E.rootId;return{list:ct(E.folders,e.parentId),parentId:n}}return e.children.some(e=>e._id===t)?{list:e.children,parentId:e.project._id}:null},zt=async e=>{At(null),Dt();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=kt(r);if(e!==void 0){if(a)await se({chatId:i.slice(5),projectId:e});else{let t=i.slice(7);if(t===e)return;if(!ut(O??[],t,e)){l.error(p());return}await y({projectId:t,parentId:e})}return}if(a&&r.startsWith(`chat:`)){let e=i.slice(5),t=r.slice(5);if(e===t)return;let n=It(t);if(!n)return;n.list.some(t=>t._id===e)||await se({chatId:e,projectId:n.folderId});let a=Ct(n.list,e=>e._id,e=>e.sortKey,e,t);a&&await ue({chatId:e,...a});return}if(!a&&r.startsWith(`folder:`)){let e=i.slice(7),t=r.slice(7);if(e===t)return;let n=Lt(t);if(!n)return;if(!n.list.some(t=>t._id===e)){if(!ut(O??[],e,n.parentId)){l.error(p());return}await y({projectId:e,parentId:n.parentId})}let a=Ct(n.list,e=>e._id,e=>e.sortKey,e,t);a&&await fe({projectId:e,...a});return}}catch{l.error(p())}},[,Bt]=(0,J.useState)(0);(0,J.useEffect)(()=>{let e=window.setInterval(()=>Bt(e=>e+1),6e4);return()=>window.clearInterval(e)},[]);let Vt=Date.now(),Ht=ht(e.project),Ut=St(e.chats,I),Wt=e.breadcrumb.slice(0,-1),Gt=e=>()=>{Z.current||e()};return(0,Y.jsx)(B.Provider,{value:Oe,children:(0,Y.jsxs)(Ue,{sensors:xt,collisionDetection:$,onDragStart:Q,onDragEnd:zt,children:[(0,Y.jsxs)(`div`,{className:`oc-projpage__body`,style:{"--proj-hue":Ht},children:[(0,Y.jsxs)(`nav`,{className:`oc-projpage__crumbs`,"aria-label":r(),children:[Wt.map(e=>(0,Y.jsxs)(`span`,{className:`oc-projpage__crumb`,children:[(0,Y.jsx)(Mt,{folderId:e._id,children:(0,Y.jsx)(`button`,{type:`button`,className:`oc-projpage__crumblink`,onClick:Gt(()=>void t({to:`/project/$projectId`,params:{projectId:e._id}})),children:e.name})}),(0,Y.jsx)(`span`,{className:`oc-projpage__crumbsep`,"aria-hidden":!0,children:`›`})]},e._id)),(0,Y.jsx)(`span`,{className:`oc-projpage__crumbcur`,children:e.project.name})]}),(0,Y.jsxs)(`header`,{className:`oc-projpage__head`,children:[(0,Y.jsx)(`span`,{className:`oc-projpage__dot`,"aria-hidden":!0}),(0,Y.jsx)(`h1`,{className:`oc-projpage__title`,children:e.project.name}),e.project.sidebarHidden?(0,Y.jsxs)(j,{variant:`ghost`,size:`sm`,className:`oc-projpage__hiddenbadge`,title:ie(),onClick:()=>{ae({projectId:e.project._id,hidden:!1})},children:[(0,Y.jsx)(et,{"aria-hidden":!0}),(0,Y.jsx)(`span`,{children:we()}),(0,Y.jsx)(Ae,{"aria-hidden":!0})]}):null,(0,Y.jsxs)(`div`,{className:`oc-projpage__actions`,children:[(0,Y.jsxs)(`div`,{className:`oc-projpage__viewtoggle`,role:`group`,"aria-label":ce(),children:[(0,Y.jsx)(j,{variant:x===`cards`?`secondary`:`ghost`,size:`icon-sm`,"aria-label":ce(),title:ce(),"aria-pressed":x===`cards`,onClick:()=>w(`cards`),children:(0,Y.jsx)(yt,{})}),(0,Y.jsx)(j,{variant:x===`columns`?`secondary`:`ghost`,size:`icon-sm`,"aria-label":le(),title:le(),"aria-pressed":x===`columns`,onClick:()=>w(`columns`),children:(0,Y.jsx)(_t,{})}),(0,Y.jsx)(j,{variant:x===`list`?`secondary`:`ghost`,size:`icon-sm`,"aria-label":f(),title:f(),"aria-pressed":x===`list`,onClick:()=>w(`list`),children:(0,Y.jsx)(ke,{})})]}),(0,Y.jsxs)(j,{variant:`outline`,size:`sm`,onClick:()=>void F({projectId:e.project._id}),children:[(0,Y.jsx)(Le,{}),a()]}),(0,Y.jsxs)(j,{variant:`outline`,size:`sm`,onClick:async()=>{let t=await c({title:d(),label:Ee(),placeholder:Ce(),confirmLabel:de()});t&&await v({name:t,parentId:e.project._id})},children:[(0,Y.jsx)(Ke,{}),d()]}),(0,Y.jsxs)($e,{children:[(0,Y.jsx)(Ye,{asChild:!0,children:(0,Y.jsx)(j,{variant:`ghost`,size:`icon-sm`,"aria-label":xe(),children:(0,Y.jsx)(mt,{})})}),(0,Y.jsxs)(pt,{align:`end`,className:`w-48`,children:[(0,Y.jsxs)(H,{onSelect:()=>{ft(e.project.name),V(!0)},children:[(0,Y.jsx)(We,{}),` `,C()]}),(0,Y.jsxs)(H,{onSelect:()=>gt(!0),children:[(0,Y.jsx)(vt,{}),` `,s()]}),(0,Y.jsx)(dt,{children:ve()}),(0,Y.jsxs)(`div`,{className:`oc-colorgrid`,children:[(0,Y.jsx)(`button`,{className:`oc-colorgrid__none`,onClick:()=>void h({projectId:e.project._id,color:null}),"aria-label":me(),children:`✕`}),qe.map(t=>(0,Y.jsx)(`button`,{className:`oc-colorgrid__dot`+(e.project.color===t.value?` is-selected`:``),style:{background:t.hue},"aria-label":t.value,onClick:()=>void h({projectId:e.project._id,color:t.value})},t.value))]}),(0,Y.jsx)(at,{}),(0,Y.jsxs)(H,{variant:`destructive`,onSelect:()=>{let r=e.project.parentId;requestAnimationFrame(async()=>{let a=pe?.folders??0,o=pe?.chats??0;await n({title:ye({name:e.project.name}),description:lt({folders:a,chats:o,days:i}),confirmWord:A(),confirmLabel:he(),destructive:!0})&&(await g({projectId:e.project._id}),t(r===null?{to:`/`}:{to:`/project/$projectId`,params:{projectId:r}}))})},children:[(0,Y.jsx)(Me,{}),` `,A()]})]})]})]})]}),x===`columns`?(0,Y.jsx)(Rt,{data:T,currentId:e.project._id,busyIds:De,suppressClick:Z,locateChatId:D??null}):x===`list`?(0,Y.jsx)(Ft,{data:E,busyIds:De,suppressClick:Z,locateChatId:D??null}):(0,Y.jsxs)(Y.Fragment,{children:[e.children.length>0?(0,Y.jsxs)(`section`,{className:`oc-projpage__section`,children:[(0,Y.jsx)(`h2`,{className:`oc-projpage__subtitle`,children:ee()}),(0,Y.jsx)(`div`,{className:`oc-projpage__cards`,children:(0,Y.jsx)(K,{items:e.children.map(e=>`folder:${e._id}`),strategy:He,children:e.children.map(t=>(0,Y.jsx)(Nt,{child:t,parentId:e.project._id,now:Vt,suppressClick:Z},t._id))})})]}):null,(0,Y.jsxs)(`section`,{className:`oc-projpage__section`,children:[(0,Y.jsxs)(`div`,{className:`oc-projpage__convhead`,children:[(0,Y.jsx)(`h2`,{className:`oc-projpage__subtitle`,children:oe()}),e.chats.length>0?(0,Y.jsx)(je,{value:I,onChange:e=>tt(e.target.value),placeholder:ne(),className:`oc-projpage__filter`}):null]}),e.chats.length===0?(0,Y.jsx)(`p`,{className:`oc-projpage__hint`,children:e.children.length===0?u():_()}):Ut.length===0&&(X??[]).length===0?(0,Y.jsx)(`p`,{className:`oc-projpage__hint`,children:te({term:I.trim()})}):(0,Y.jsx)(`ul`,{className:`oc-projpage__chats`,children:(0,Y.jsx)(K,{items:Ut.map(e=>`chat:${e._id}`),strategy:G,children:Ut.map(t=>(0,Y.jsx)(Pt,{chat:t,currentFolderId:e.project._id,now:Vt,busy:De.has(t._id),unread:P.has(t._id),locate:t._id===D,suppressClick:Z},t._id))})})]}),q.length>=2&&X!==void 0?(0,Y.jsxs)(`section`,{className:`oc-projpage__section`,children:[(0,Y.jsx)(`h2`,{className:`oc-projpage__subtitle`,children:Te()}),X.length===0?(0,Y.jsx)(`p`,{className:`oc-projpage__hint`,children:te({term:q})}):(0,Y.jsx)(`ul`,{className:`oc-projpage__chats`,children:X.map(e=>(0,Y.jsx)(`li`,{className:`oc-projpage__chatrow`,children:(0,Y.jsxs)(`button`,{type:`button`,className:`oc-projpage__chatbtn`,onClick:()=>{e.messageId&&q&&Ie(e.messageId,q),t({to:`/chat/$chatId`,params:{chatId:e.chatId},...e.messageId?{search:{m:e.messageId}}:{}})},children:[(0,Y.jsx)(Fe,{size:13,"aria-hidden":!0,className:`oc-projpage__hitico`}),(0,Y.jsxs)(`span`,{className:`oc-projpage__hitbody`,children:[(0,Y.jsx)(`span`,{className:`oc-projpage__chattitle`,children:e.title||be()}),e.projectPath&&e.projectPath.length>1?(0,Y.jsx)(`span`,{className:`oc-projpage__hitpath`,children:e.projectPath.join(` › `)}):null,e.snippet?(0,Y.jsx)(`span`,{className:`oc-projpage__hitsnippet`,children:e.snippet}):null]})]})},`${e.chatId}:${e.messageId??`t`}`))})]}):null]}),(0,Y.jsx)(Xe,{open:z,onOpenChange:V,title:ge(),canSubmit:U.trim().length>0,onSubmit:async()=>{await m({projectId:e.project._id,name:U.trim()}),V(!1)},submitLabel:C(),children:(0,Y.jsx)(je,{value:U,onChange:e=>ft(e.target.value),autoFocus:!0})}),W?(0,Y.jsx)(rt,{open:W,onOpenChange:gt,title:re(),movingFolderId:e.project._id,currentId:e.project.parentId,onPick:t=>void y({projectId:e.project._id,parentId:t})}):null,Ve]}),(0,Y.jsx)(Pe,{children:Ot?(0,Y.jsxs)(`div`,{className:`oc-projpage__dragghost`,children:[Ot.kind===`folder`?(0,Y.jsx)(L,{size:13,"aria-hidden":!0}):(0,Y.jsx)(Fe,{size:13,"aria-hidden":!0}),(0,Y.jsx)(`span`,{children:Ot.label})]}):null})]})})}function Mt({folderId:e,children:t}){let{setNodeRef:n,isOver:r}=V({id:Ot(e)});return(0,Y.jsx)(`span`,{ref:n,className:r?`oc-projpage__cdrop is-over`:`oc-projpage__cdrop`,children:t})}function Nt({child:e,parentId:t,now:n,suppressClick:r}){let i=R(),a=P({id:`folder:${e._id}`}),o=V({id:Z(e._id)});return(0,Y.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":ht(e),transform:F.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,Y.jsxs)(`span`,{className:`oc-projpage__cardhead`,children:[(0,Y.jsx)(L,{size:15,"aria-hidden":!0,className:`oc-projpage__cardico`}),(0,Y.jsx)(`span`,{className:`oc-projpage__cardname`,children:e.name}),(0,Y.jsx)(X,{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,Y.jsxs)(`span`,{className:`oc-projpage__cardmeta`,children:[e.folderCount>0?De({count:e.folderCount})+` · `:``,y({count:e.recursiveChatCount})]}),e.lastActivityAt===null?null:(0,Y.jsx)(`span`,{className:`oc-projpage__cardage`,children:tt(e.lastActivityAt,n)})]})}function Q({chat:e}){let t=o(k.chats.setChatSidebar),n=e.inSidebar?ue():v();return(0,Y.jsx)(j,{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,Y.jsx)(I,{}):(0,Y.jsx)(q,{})})}function Pt({chat:e,currentFolderId:t,now:n,busy:r,unread:i,locate:a,suppressClick:o}){let s=(0,J.useContext)(B).get(e._id),c=R(),l=W(e.color),u=P({id:`chat:${e._id}`}),d=$(a);return(0,Y.jsxs)(`li`,{ref:e=>{u.setNodeRef(e),d.current=e},className:`oc-projpage__chatrow`+(u.isDragging?` is-dragging`:``)+(a?` is-locate`:``),style:{transform:F.Transform.toString(u.transform),transition:u.transition},children:[(0,Y.jsxs)(`button`,{type:`button`,className:`oc-projpage__chatbtn`,onClick:()=>{o.current||c({to:`/chat/$chatId`,params:{chatId:e._id}})},...u.listeners,...u.attributes,children:[l?(0,Y.jsx)(`span`,{className:`oc-chatitem__dot`,style:{background:l}}):(0,Y.jsx)(`span`,{className:`oc-chatitem__dot oc-chatitem__dot--empty`}),(0,Y.jsx)(`span`,{className:`oc-projpage__chattitle`,children:e.title||_e()}),e.pinned?(0,Y.jsx)(N,{size:12,"aria-hidden":!0,className:`oc-projpage__chatpin`}):null,(0,Y.jsx)(`span`,{className:`oc-projpage__chatage`,children:tt(e.updatedAt,n)}),r?(0,Y.jsx)(`span`,{className:z(s,S()).className,title:z(s,S()).label,"aria-label":z(s,S()).label}):null,i&&!r?(0,Y.jsx)(`span`,{className:`oc-chatitem__unread`,title:O(),"aria-label":O()}):null]}),(0,Y.jsx)(Q,{chat:e}),(0,Y.jsx)(xt,{chat:e,currentFolderId:t,className:`oc-projpage__chatmenu`})]})}function $(e){let t=(0,J.useRef)(null);return(0,J.useEffect)(()=>{e&&t.current&&t.current.scrollIntoView({block:`center`})},[e]),t}function Ft({data:e,busyIds:t,suppressClick:n,locateChatId:r}){let[i,a]=(0,J.useState)(new Set),o=(0,J.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,Y.jsx)(`p`,{className:`oc-projpage__hint`,children:E()});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=ct(e.folders,a);return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(K,{items:u.map(e=>`chat:${e._id}`),strategy:G,children:u.map(e=>(0,Y.jsx)(Lt,{chat:e,depth:l,busy:t.has(e._id),locate:e._id===r,suppressClick:n},e._id))}),(0,Y.jsx)(K,{items:d.map(e=>`folder:${e._id}`),strategy:G,children:d.map(t=>(0,Y.jsx)(It,{folder:t,parentId:a??e.rootId,depth:l,folded:i.has(t._id),onToggle:()=>s(t._id),suppressClick:n,children:i.has(t._id)?null:c(t._id,l+1)},t._id))})]})};return(0,Y.jsx)(`div`,{className:`oc-projpage__tree`,children:(o.get(e.rootId)??[]).length===0&&ct(e.folders,null).length===0?(0,Y.jsx)(`p`,{className:`oc-projpage__hint`,children:u()}):c(null,0)})}function It({folder:e,parentId:t,depth:n,folded:r,onToggle:i,suppressClick:a,children:o}){let s=R(),c=P({id:`folder:${e._id}`}),l=V({id:Z(e._id)});return(0,Y.jsxs)(`div`,{className:`oc-projpage__treegroup`,children:[(0,Y.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":ht(e),transform:F.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,Y.jsx)(`button`,{type:`button`,className:`oc-projpage__treechev`,"aria-label":r?se():ae(),"aria-expanded":!r,onClick:e=>{e.stopPropagation(),!a.current&&i()},onMouseDown:e=>e.stopPropagation(),onTouchStart:e=>e.stopPropagation(),children:r?(0,Y.jsx)(ft,{size:13}):(0,Y.jsx)(Oe,{size:13})}),(0,Y.jsx)(L,{size:13,"aria-hidden":!0,className:`oc-projpage__colico`}),(0,Y.jsx)(`span`,{className:`oc-projpage__colname`,children:e.name}),(0,Y.jsx)(X,{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 Lt({chat:e,depth:t,busy:n,locate:r,suppressClick:i}){let a=(0,J.useContext)(B).get(e._id),o=R(),s=P({id:`chat:${e._id}`}),c=$(r),l=W(e.color);return(0,Y.jsxs)(`div`,{ref:e=>{s.setNodeRef(e),c.current=e},className:`oc-projpage__treerow oc-projpage__treerow--chat`+(s.isDragging?` is-dragging`:``)+(r?` is-locate`:``),style:{"--tree-depth":t,transform:F.Transform.toString(s.transform),transition:s.transition},children:[(0,Y.jsxs)(`button`,{type:`button`,className:`oc-projpage__colchatbtn`,onClick:()=>{i.current||o({to:`/chat/$chatId`,params:{chatId:e._id}})},...s.listeners,...s.attributes,children:[l?(0,Y.jsx)(`span`,{className:`oc-chatitem__dot`,style:{background:l}}):(0,Y.jsx)(`span`,{className:`oc-chatitem__dot oc-chatitem__dot--empty`}),(0,Y.jsx)(`span`,{className:`oc-projpage__colname`,children:e.title||_e()}),n?(0,Y.jsx)(`span`,{className:z(a,``).className,"aria-hidden":!0}):null]}),(0,Y.jsx)(xt,{chat:e,currentFolderId:e.folderId,className:`oc-projpage__treemenu`}),(0,Y.jsx)(Q,{chat:e})]})}function Rt({data:e,currentId:t,busyIds:n,suppressClick:r,locateChatId:i}){let a=(0,J.useRef)(null);return(0,J.useEffect)(()=>{let e=a.current;e&&(e.scrollLeft=e.scrollWidth)},[e?.columns.length??0,t]),e===void 0?(0,Y.jsx)(`p`,{className:`oc-projpage__hint`,children:E()}):(0,Y.jsx)(`div`,{className:`oc-projpage__cols`,ref:a,children:e.columns.map((a,o)=>(0,Y.jsx)(zt,{col:a,isLast:o===e.columns.length-1,currentId:t,busyIds:n,suppressClick:r,locateChatId:i},a.folderId??`root`))})}function zt({col:e,isLast:t,currentId:n,busyIds:r,suppressClick:i,locateChatId:a}){let o=R(),s=V({id:Dt(e.folderId)});return(0,Y.jsxs)(`div`,{ref:s.setNodeRef,className:`oc-projpage__col`+(s.isOver?` is-over`:``)+(t?` is-last`:``),children:[(0,Y.jsx)(K,{items:e.folders.map(e=>`folder:${e._id}`),strategy:G,children:e.folders.map(t=>(0,Y.jsx)(Bt,{folder:t,parentId:e.folderId,isCurrent:t._id===n,suppressClick:i,onOpen:()=>void o({to:`/project/$projectId`,params:{projectId:t._id}})},t._id))}),(0,Y.jsx)(K,{items:e.chats.map(e=>`chat:${e._id}`),strategy:G,children:e.chats.map(t=>(0,Y.jsx)(Vt,{chat:t,folderId:e.folderId,busy:r.has(t._id),locate:t._id===a,suppressClick:i,onOpen:()=>void o({to:`/chat/$chatId`,params:{chatId:t._id}})},t._id))}),e.folders.length===0&&e.chats.length===0?(0,Y.jsx)(`p`,{className:`oc-projpage__colempty`,children:_()}):null]})}function Bt({folder:e,parentId:t,isCurrent:n,suppressClick:r,onOpen:i}){let a=P({id:`folder:${e._id}`}),o=V({id:Z(e._id)});return(0,Y.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":ht(e),transform:F.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,Y.jsx)(L,{size:13,"aria-hidden":!0,className:`oc-projpage__colico`}),(0,Y.jsx)(`span`,{className:`oc-projpage__colname`,children:e.name}),(0,Y.jsx)(`span`,{className:`oc-projpage__colchev`,"aria-hidden":!0,children:`›`}),(0,Y.jsx)(X,{folderId:e._id,name:e.name,color:e.color,currentParentId:t,className:`oc-projpage__colmenu`,onOpen:i})]})}function Vt({chat:e,folderId:t,busy:n,locate:r,suppressClick:i,onOpen:a}){let o=(0,J.useContext)(B).get(e._id),s=P({id:`chat:${e._id}`}),c=$(r),l=W(e.color);return(0,Y.jsxs)(`div`,{ref:e=>{s.setNodeRef(e),c.current=e},className:`oc-projpage__colentry oc-projpage__colentry--chat`+(s.isDragging?` is-dragging`:``)+(r?` is-locate`:``),style:{transform:F.Transform.toString(s.transform),transition:s.transition},children:[(0,Y.jsxs)(`button`,{type:`button`,className:`oc-projpage__colchatbtn`,onClick:()=>{i.current||a()},...s.listeners,...s.attributes,children:[l?(0,Y.jsx)(`span`,{className:`oc-chatitem__dot`,style:{background:l}}):(0,Y.jsx)(`span`,{className:`oc-chatitem__dot oc-chatitem__dot--empty`}),(0,Y.jsx)(`span`,{className:`oc-projpage__colname`,children:e.title||_e()}),n?(0,Y.jsx)(`span`,{className:z(o,``).className,"aria-hidden":!0}):null]}),(0,Y.jsx)(xt,{chat:e,currentFolderId:t,className:`oc-projpage__colmenu oc-projpage__colmenu--chat`}),(0,Y.jsx)(Q,{chat:e})]})}export{At as ProjectPage};
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{AE as r,AT as i,BE as a,BY as o,DE as s,E as c,EE as l,FE as u,GE as d,HE as ee,IE as te,JE as f,KE as p,LE as ne,ME as m,NE as h,OE as g,PE as _,QE as v,RE as y,TE as re,To as ie,UE as ae,VE as oe,VY as b,WE as se,XE as ce,YE as le,ZE as ue,_D as de,_E as fe,dE as pe,eD as x,fD as S,fE as me,gE as C,hE as w,iD as he,jE as T,jY as E,lD as ge,mE as D,oD as O,pD as _e,pE as ve,rD as ye,t as k,uC as be,uD as xe,uE as Se,vD as Ce,wo as we,xE as Te,yD as Ee,yE as A,zE as De}from"./api-DcB3BxUc.js";import{r as Oe}from"./dist-D96qX4Zd.js";import{t as ke}from"./list-CKshqcfm.js";import{t as j}from"./button-DgaBsJDX.js";import{$n as Ae,$t as je,A as M,An as Me,Bn as N,C as P,D as Ne,E as Pe,Gn as Fe,I as Ie,Kn as Le,M as Re,N as ze,O as Be,P as F,Qn as Ve,S as He,T as Ue,Un as I,Vn as We,Xn as L,Yt as Ge,Zn as Ke,_ as qe,_t as Je,an as Ye,b as Xe,ct as Ze,d as Qe,dr as R,en as $e,er as et,f as tt,fr as nt,g as rt,gt as z,h as it,ht as B,in as at,j as V,k as ot,lt as st,mt as ct,nn as H,p as lt,pr as U,pt as ut,rn as dt,sr as ft,tn as pt,tr as mt,v as W,w as G,x as K,y as ht,zn as gt}from"./index-Ds-ybIOh.js";var _t=c(`columns-3`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}]]),vt=c(`folder-input`,[[`path`,{d:`M2 9V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-1`,key:`fm4g5t`}],[`path`,{d:`M2 13h10`,key:`pgb2dq`}],[`path`,{d:`m9 16 3-3-3-3`,key:`6m91ic`}]]),yt=c(`layout-grid`,[[`rect`,{width:`7`,height:`7`,x:`3`,y:`3`,rx:`1`,key:`1g98yp`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`3`,rx:`1`,key:`6d4xhi`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`14`,rx:`1`,key:`nxv5o0`}],[`rect`,{width:`7`,height:`7`,x:`3`,y:`14`,rx:`1`,key:`1bb6yr`}]]),q=c(`panel-left`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}]]),J=t(e(),1),Y=n();function bt({className:e}){return(0,Y.jsx)(Ye,{asChild:!0,children:(0,Y.jsx)(j,{variant:`ghost`,size:`icon-xs`,"aria-label":fe(),className:e,onClick:e=>e.stopPropagation(),onMouseDown:e=>e.stopPropagation(),onTouchStart:e=>e.stopPropagation(),onPointerDown:e=>e.stopPropagation(),children:(0,Y.jsx)(mt,{})})})}function X({folderId:e,name:t,color:n,currentParentId:r,className:i,onOpen:a}){let c=o(k.projects.renameProject),l=o(k.projects.setProjectColor),u=o(k.projects.moveProject),ee=o(k.projects.deleteProject),te=o(k.projects.createProject),f=Ze(),p=it(),ne=st(),[m,h]=(0,J.useState)(!1),[g,_]=(0,J.useState)(t),[v,y]=(0,J.useState)(!1),[ie,ae]=(0,J.useState)(!1),oe=b(k.projects.projectTreeCount,ie?{projectId:e}:`skip`);return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)($e,{onOpenChange:e=>e&&ae(!0),children:[(0,Y.jsx)(bt,{className:i}),(0,Y.jsxs)(pt,{align:`end`,className:`w-48`,onClick:e=>e.stopPropagation(),children:[(0,Y.jsxs)(H,{onSelect:()=>a(),children:[(0,Y.jsx)(Ve,{}),` `,x()]}),(0,Y.jsxs)(H,{onSelect:()=>{_(t),h(!0)},children:[(0,Y.jsx)(We,{}),` `,C()]}),(0,Y.jsxs)(H,{onSelect:()=>{requestAnimationFrame(async()=>{let t=await ne({title:d(),label:Ee(),placeholder:Ce(),confirmLabel:de()});t&&await te({name:t,parentId:e})})},children:[(0,Y.jsx)(Ke,{}),` `,d()]}),(0,Y.jsxs)(H,{onSelect:()=>y(!0),children:[(0,Y.jsx)(vt,{}),` `,s()]}),(0,Y.jsx)(dt,{children:ve()}),(0,Y.jsxs)(`div`,{className:`oc-colorgrid`,onClick:e=>e.stopPropagation(),children:[(0,Y.jsx)(`button`,{className:`oc-colorgrid__none`,onClick:()=>void l({projectId:e,color:null}),"aria-label":me(),children:`✕`}),qe.map(t=>(0,Y.jsx)(`button`,{className:`oc-colorgrid__dot`+(n===t.value?` is-selected`:``),style:{background:t.hue},"aria-label":t.value,onClick:()=>void l({projectId:e,color:t.value})},t.value))]}),(0,Y.jsx)(at,{}),(0,Y.jsxs)(H,{variant:`destructive`,onSelect:()=>{requestAnimationFrame(async()=>{let n=oe?.folders??0,r=oe?.chats??0;await f({title:ye({name:t}),description:lt({folders:n,chats:r,days:p}),confirmWord:A(),confirmLabel:he(),destructive:!0})&&await ee({projectId:e})})},children:[(0,Y.jsx)(Me,{}),` `,A()]})]})]}),(0,Y.jsx)(Xe,{open:m,onOpenChange:h,title:ge(),canSubmit:g.trim().length>0,onSubmit:async()=>{await c({projectId:e,name:g.trim()}),h(!1)},submitLabel:C(),children:(0,Y.jsx)(je,{value:g,onChange:e=>_(e.target.value),autoFocus:!0})}),v?(0,Y.jsx)(rt,{open:v,onOpenChange:y,title:re(),movingFolderId:e,currentId:r,onPick:t=>void u({projectId:e,parentId:t})}):null]})}function xt({chat:e,currentFolderId:t,className:n}){let r=o(k.chats.pinChat),a=o(k.chats.deleteChat),s=o(k.chats.renameChat),c=o(k.chats.setChatSidebar),u=o(k.chats.moveChatToProject),d=Ze(),ee=it(),[te,f]=(0,J.useState)(!1),[p,ne]=(0,J.useState)(e.title??``),[m,h]=(0,J.useState)(!1);return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)($e,{children:[(0,Y.jsx)(bt,{className:n}),(0,Y.jsxs)(pt,{align:`end`,className:`w-52`,onClick:e=>e.stopPropagation(),children:[(0,Y.jsxs)(H,{onSelect:()=>{ne(e.title??``),f(!0)},children:[(0,Y.jsx)(We,{}),` `,C()]}),(0,Y.jsxs)(H,{onSelect:()=>void r({chatId:e._id,pinned:!e.pinned}),children:[e.pinned?(0,Y.jsx)(gt,{}):(0,Y.jsx)(N,{}),e.pinned?w():D()]}),(0,Y.jsxs)(H,{onSelect:()=>h(!0),children:[(0,Y.jsx)(vt,{}),` `,g()]}),e.pinned&&e.inSidebar?null:(0,Y.jsxs)(H,{onSelect:()=>void c({chatId:e._id,hidden:e.inSidebar}),children:[e.inSidebar?(0,Y.jsx)(I,{}):(0,Y.jsx)(q,{}),e.inSidebar?ue():v()]}),(0,Y.jsx)(at,{}),(0,Y.jsxs)(H,{variant:`destructive`,onSelect:()=>{requestAnimationFrame(async()=>{await d({title:pe(),description:Se({days:ee}),confirmLabel:A(),destructive:!0})&&await a({chatId:e._id})})},children:[(0,Y.jsx)(Me,{}),` `,A()]})]})]}),(0,Y.jsx)(Xe,{open:te,onOpenChange:f,title:i(),canSubmit:p.trim().length>0,onSubmit:async()=>{await s({chatId:e._id,title:p.trim()}),f(!1)},submitLabel:C(),children:(0,Y.jsx)(je,{value:p,onChange:e=>ne(e.target.value),autoFocus:!0})}),m?(0,Y.jsx)(rt,{open:m,onOpenChange:h,title:l(),currentId:t,onPick:t=>void u({chatId:e._id,projectId:t})}):null]})}function St(e,t){let n=t.trim().toLowerCase();return n===``?e:e.filter(e=>(e.title??``).toLowerCase().includes(n))}function Ct(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 wt(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 Tt=`oc.projpage.view`;function Et(){let e=localStorage.getItem(Tt);return e===`cards`||e===`list`?e:`columns`}var Z=e=>`into:${e}`,Dt=e=>`col:${e??`null`}`,Ot=e=>`crumb:${e}`;function kt(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 At(){let{projectId:e}=U({from:`/project/$projectId`}),t=R(),n=b(k.projects.projectPage,{projectId:e});return(0,Y.jsx)(`div`,{className:`oc-projpage`,children:n===void 0?(0,Y.jsx)(`p`,{className:`oc-projpage__hint`,children:E()}):n===null?(0,Y.jsxs)(`div`,{className:`oc-projpage__notfound`,children:[(0,Y.jsx)(`h2`,{children:h()}),(0,Y.jsx)(`p`,{className:`oc-projpage__hint`,children:m()}),(0,Y.jsx)(j,{variant:`outline`,onClick:()=>void t({to:`/`}),children:T()})]}):(0,Y.jsx)(jt,{page:n})})}function jt({page:e}){let t=R(),n=Ze(),i=it(),c=st(),l=Ge(),m=o(k.projects.renameProject),h=o(k.projects.setProjectColor),g=o(k.projects.deleteProject),v=o(k.projects.createProject),y=o(k.projects.moveProject),ae=o(k.projects.setProjectSidebar),se=o(k.chats.moveChatToProject),ue=o(k.chats.reorderChat),fe=o(k.projects.reorderProject),pe=b(k.projects.projectTreeCount,{projectId:e.project._id}),[x,S]=(0,J.useState)(Et),w=e=>{localStorage.setItem(Tt,e),S(e)},T=b(k.projects.folderColumns,x===`columns`?{projectId:e.project._id}:`skip`),E=b(k.projects.projectTreeList,x===`list`?{projectId:e.project._id}:`skip`),{c:D}=nt({from:`/project/$projectId`}),O=b(k.projects.listProjects,{}),Se=b(k.chatReads.myBusyChats,{}),De=(0,J.useMemo)(()=>new Set(Se??[]),[Se]),{byChat:Oe}=Je(Se??null),N=b(k.chatReads.myChatReads,{}),P=(0,J.useMemo)(()=>wt(e.chats,N??[]),[e.chats,N]),{startNewChat:F,picker:Ve}=Qe(e=>void t({to:`/chat/$chatId`,params:{chatId:e}})),[I,tt]=(0,J.useState)(``),[z,V]=(0,J.useState)(!1),[U,ft]=(0,J.useState)(e.project.name),[W,gt]=(0,J.useState)(!1),[q,bt]=(0,J.useState)(``);(0,J.useEffect)(()=>{let e=setTimeout(()=>bt(I.trim()),180);return()=>clearTimeout(e)},[I]);let X=b(k.search.searchConversations,q.length>=2?{query:q,projectId:e.project._id}:`skip`),xt=ze(Re(Ne,{activationConstraint:{distance:4}}),Re(Be,{activationConstraint:{delay:250,tolerance:8}})),Z=(0,J.useRef)(!1),Dt=()=>{Z.current=!0,setTimeout(()=>{Z.current=!1},0)},[Ot,At]=(0,J.useState)(null),jt=t=>{if(t.startsWith(`chat:`)){let n=t.slice(5),r=e.chats.find(e=>e._id===n),i=T?.columns.flatMap(e=>e.chats).find(e=>e._id===n);return{kind:`chat`,label:(r??i)?.title||_e()}}if(t.startsWith(`folder:`)){let e=t.slice(7);return{kind:`folder`,label:(O??[]).find(t=>t._id===e)?.name??``}}return null},Q=e=>At(jt(String(e.active.id))),$=(0,J.useCallback)(e=>{let t=String(e.active.id).startsWith(`folder:`),n=t=>({...e,droppableContainers:e.droppableContainers.filter(e=>String(e.id).startsWith(t))}),r=M(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=M(n(t?`folder:`:`chat:`));if(i.length>0)return i;let a=M(n(`crumb:`));if(a.length>0)return a;let o=M(n(`col:`));return o.length>0?o:ot(n(t?`folder:`:`chat:`))},[]),It=t=>{if(x===`columns`){for(let e of T?.columns??[])if(e.chats.some(e=>e._id===t))return{list:e.chats,folderId:e.folderId};return null}if(x===`list`){let e=E?.chats.find(e=>e._id===t);return e?{list:E.chats.filter(t=>t.folderId===e.folderId),folderId:e.folderId}:null}return e.chats.some(e=>e._id===t)?{list:e.chats,folderId:e.project._id}:null},Lt=t=>{if(x===`columns`){for(let e of T?.columns??[])if(e.folders.some(e=>e._id===t))return{list:e.folders,parentId:e.folderId};return null}if(x===`list`){let e=E?.folders.find(e=>e._id===t);if(!e||!E)return null;let n=e.parentId??E.rootId;return{list:ct(E.folders,e.parentId),parentId:n}}return e.children.some(e=>e._id===t)?{list:e.children,parentId:e.project._id}:null},zt=async e=>{At(null),Dt();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=kt(r);if(e!==void 0){if(a)await se({chatId:i.slice(5),projectId:e});else{let t=i.slice(7);if(t===e)return;if(!ut(O??[],t,e)){l.error(p());return}await y({projectId:t,parentId:e})}return}if(a&&r.startsWith(`chat:`)){let e=i.slice(5),t=r.slice(5);if(e===t)return;let n=It(t);if(!n)return;n.list.some(t=>t._id===e)||await se({chatId:e,projectId:n.folderId});let a=Ct(n.list,e=>e._id,e=>e.sortKey,e,t);a&&await ue({chatId:e,...a});return}if(!a&&r.startsWith(`folder:`)){let e=i.slice(7),t=r.slice(7);if(e===t)return;let n=Lt(t);if(!n)return;if(!n.list.some(t=>t._id===e)){if(!ut(O??[],e,n.parentId)){l.error(p());return}await y({projectId:e,parentId:n.parentId})}let a=Ct(n.list,e=>e._id,e=>e.sortKey,e,t);a&&await fe({projectId:e,...a});return}}catch{l.error(p())}},[,Bt]=(0,J.useState)(0);(0,J.useEffect)(()=>{let e=window.setInterval(()=>Bt(e=>e+1),6e4);return()=>window.clearInterval(e)},[]);let Vt=Date.now(),Ht=ht(e.project),Ut=St(e.chats,I),Wt=e.breadcrumb.slice(0,-1),Gt=e=>()=>{Z.current||e()};return(0,Y.jsx)(B.Provider,{value:Oe,children:(0,Y.jsxs)(Ue,{sensors:xt,collisionDetection:$,onDragStart:Q,onDragEnd:zt,children:[(0,Y.jsxs)(`div`,{className:`oc-projpage__body`,style:{"--proj-hue":Ht},children:[(0,Y.jsxs)(`nav`,{className:`oc-projpage__crumbs`,"aria-label":r(),children:[Wt.map(e=>(0,Y.jsxs)(`span`,{className:`oc-projpage__crumb`,children:[(0,Y.jsx)(Mt,{folderId:e._id,children:(0,Y.jsx)(`button`,{type:`button`,className:`oc-projpage__crumblink`,onClick:Gt(()=>void t({to:`/project/$projectId`,params:{projectId:e._id}})),children:e.name})}),(0,Y.jsx)(`span`,{className:`oc-projpage__crumbsep`,"aria-hidden":!0,children:`›`})]},e._id)),(0,Y.jsx)(`span`,{className:`oc-projpage__crumbcur`,children:e.project.name})]}),(0,Y.jsxs)(`header`,{className:`oc-projpage__head`,children:[(0,Y.jsx)(`span`,{className:`oc-projpage__dot`,"aria-hidden":!0}),(0,Y.jsx)(`h1`,{className:`oc-projpage__title`,children:e.project.name}),e.project.sidebarHidden?(0,Y.jsxs)(j,{variant:`ghost`,size:`sm`,className:`oc-projpage__hiddenbadge`,title:ie(),onClick:()=>{ae({projectId:e.project._id,hidden:!1})},children:[(0,Y.jsx)(et,{"aria-hidden":!0}),(0,Y.jsx)(`span`,{children:we()}),(0,Y.jsx)(Ae,{"aria-hidden":!0})]}):null,(0,Y.jsxs)(`div`,{className:`oc-projpage__actions`,children:[(0,Y.jsxs)(`div`,{className:`oc-projpage__viewtoggle`,role:`group`,"aria-label":ce(),children:[(0,Y.jsx)(j,{variant:x===`cards`?`secondary`:`ghost`,size:`icon-sm`,"aria-label":ce(),title:ce(),"aria-pressed":x===`cards`,onClick:()=>w(`cards`),children:(0,Y.jsx)(yt,{})}),(0,Y.jsx)(j,{variant:x===`columns`?`secondary`:`ghost`,size:`icon-sm`,"aria-label":le(),title:le(),"aria-pressed":x===`columns`,onClick:()=>w(`columns`),children:(0,Y.jsx)(_t,{})}),(0,Y.jsx)(j,{variant:x===`list`?`secondary`:`ghost`,size:`icon-sm`,"aria-label":f(),title:f(),"aria-pressed":x===`list`,onClick:()=>w(`list`),children:(0,Y.jsx)(ke,{})})]}),(0,Y.jsxs)(j,{variant:`outline`,size:`sm`,onClick:()=>void F({projectId:e.project._id}),children:[(0,Y.jsx)(Le,{}),a()]}),(0,Y.jsxs)(j,{variant:`outline`,size:`sm`,onClick:async()=>{let t=await c({title:d(),label:Ee(),placeholder:Ce(),confirmLabel:de()});t&&await v({name:t,parentId:e.project._id})},children:[(0,Y.jsx)(Ke,{}),d()]}),(0,Y.jsxs)($e,{children:[(0,Y.jsx)(Ye,{asChild:!0,children:(0,Y.jsx)(j,{variant:`ghost`,size:`icon-sm`,"aria-label":xe(),children:(0,Y.jsx)(mt,{})})}),(0,Y.jsxs)(pt,{align:`end`,className:`w-48`,children:[(0,Y.jsxs)(H,{onSelect:()=>{ft(e.project.name),V(!0)},children:[(0,Y.jsx)(We,{}),` `,C()]}),(0,Y.jsxs)(H,{onSelect:()=>gt(!0),children:[(0,Y.jsx)(vt,{}),` `,s()]}),(0,Y.jsx)(dt,{children:ve()}),(0,Y.jsxs)(`div`,{className:`oc-colorgrid`,children:[(0,Y.jsx)(`button`,{className:`oc-colorgrid__none`,onClick:()=>void h({projectId:e.project._id,color:null}),"aria-label":me(),children:`✕`}),qe.map(t=>(0,Y.jsx)(`button`,{className:`oc-colorgrid__dot`+(e.project.color===t.value?` is-selected`:``),style:{background:t.hue},"aria-label":t.value,onClick:()=>void h({projectId:e.project._id,color:t.value})},t.value))]}),(0,Y.jsx)(at,{}),(0,Y.jsxs)(H,{variant:`destructive`,onSelect:()=>{let r=e.project.parentId;requestAnimationFrame(async()=>{let a=pe?.folders??0,o=pe?.chats??0;await n({title:ye({name:e.project.name}),description:lt({folders:a,chats:o,days:i}),confirmWord:A(),confirmLabel:he(),destructive:!0})&&(await g({projectId:e.project._id}),t(r===null?{to:`/`}:{to:`/project/$projectId`,params:{projectId:r}}))})},children:[(0,Y.jsx)(Me,{}),` `,A()]})]})]})]})]}),x===`columns`?(0,Y.jsx)(Rt,{data:T,currentId:e.project._id,busyIds:De,suppressClick:Z,locateChatId:D??null}):x===`list`?(0,Y.jsx)(Ft,{data:E,busyIds:De,suppressClick:Z,locateChatId:D??null}):(0,Y.jsxs)(Y.Fragment,{children:[e.children.length>0?(0,Y.jsxs)(`section`,{className:`oc-projpage__section`,children:[(0,Y.jsx)(`h2`,{className:`oc-projpage__subtitle`,children:ee()}),(0,Y.jsx)(`div`,{className:`oc-projpage__cards`,children:(0,Y.jsx)(K,{items:e.children.map(e=>`folder:${e._id}`),strategy:He,children:e.children.map(t=>(0,Y.jsx)(Nt,{child:t,parentId:e.project._id,now:Vt,suppressClick:Z},t._id))})})]}):null,(0,Y.jsxs)(`section`,{className:`oc-projpage__section`,children:[(0,Y.jsxs)(`div`,{className:`oc-projpage__convhead`,children:[(0,Y.jsx)(`h2`,{className:`oc-projpage__subtitle`,children:oe()}),e.chats.length>0?(0,Y.jsx)(je,{value:I,onChange:e=>tt(e.target.value),placeholder:ne(),className:`oc-projpage__filter`}):null]}),e.chats.length===0?(0,Y.jsx)(`p`,{className:`oc-projpage__hint`,children:e.children.length===0?u():_()}):Ut.length===0&&(X??[]).length===0?(0,Y.jsx)(`p`,{className:`oc-projpage__hint`,children:te({term:I.trim()})}):(0,Y.jsx)(`ul`,{className:`oc-projpage__chats`,children:(0,Y.jsx)(K,{items:Ut.map(e=>`chat:${e._id}`),strategy:G,children:Ut.map(t=>(0,Y.jsx)(Pt,{chat:t,currentFolderId:e.project._id,now:Vt,busy:De.has(t._id),unread:P.has(t._id),locate:t._id===D,suppressClick:Z},t._id))})})]}),q.length>=2&&X!==void 0?(0,Y.jsxs)(`section`,{className:`oc-projpage__section`,children:[(0,Y.jsx)(`h2`,{className:`oc-projpage__subtitle`,children:Te()}),X.length===0?(0,Y.jsx)(`p`,{className:`oc-projpage__hint`,children:te({term:q})}):(0,Y.jsx)(`ul`,{className:`oc-projpage__chats`,children:X.map(e=>(0,Y.jsx)(`li`,{className:`oc-projpage__chatrow`,children:(0,Y.jsxs)(`button`,{type:`button`,className:`oc-projpage__chatbtn`,onClick:()=>{e.messageId&&q&&Ie(e.messageId,q),t({to:`/chat/$chatId`,params:{chatId:e.chatId},...e.messageId?{search:{m:e.messageId}}:{}})},children:[(0,Y.jsx)(Fe,{size:13,"aria-hidden":!0,className:`oc-projpage__hitico`}),(0,Y.jsxs)(`span`,{className:`oc-projpage__hitbody`,children:[(0,Y.jsx)(`span`,{className:`oc-projpage__chattitle`,children:e.title||be()}),e.projectPath&&e.projectPath.length>1?(0,Y.jsx)(`span`,{className:`oc-projpage__hitpath`,children:e.projectPath.join(` › `)}):null,e.snippet?(0,Y.jsx)(`span`,{className:`oc-projpage__hitsnippet`,children:e.snippet}):null]})]})},`${e.chatId}:${e.messageId??`t`}`))})]}):null]}),(0,Y.jsx)(Xe,{open:z,onOpenChange:V,title:ge(),canSubmit:U.trim().length>0,onSubmit:async()=>{await m({projectId:e.project._id,name:U.trim()}),V(!1)},submitLabel:C(),children:(0,Y.jsx)(je,{value:U,onChange:e=>ft(e.target.value),autoFocus:!0})}),W?(0,Y.jsx)(rt,{open:W,onOpenChange:gt,title:re(),movingFolderId:e.project._id,currentId:e.project.parentId,onPick:t=>void y({projectId:e.project._id,parentId:t})}):null,Ve]}),(0,Y.jsx)(Pe,{children:Ot?(0,Y.jsxs)(`div`,{className:`oc-projpage__dragghost`,children:[Ot.kind===`folder`?(0,Y.jsx)(L,{size:13,"aria-hidden":!0}):(0,Y.jsx)(Fe,{size:13,"aria-hidden":!0}),(0,Y.jsx)(`span`,{children:Ot.label})]}):null})]})})}function Mt({folderId:e,children:t}){let{setNodeRef:n,isOver:r}=V({id:Ot(e)});return(0,Y.jsx)(`span`,{ref:n,className:r?`oc-projpage__cdrop is-over`:`oc-projpage__cdrop`,children:t})}function Nt({child:e,parentId:t,now:n,suppressClick:r}){let i=R(),a=P({id:`folder:${e._id}`}),o=V({id:Z(e._id)});return(0,Y.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":ht(e),transform:F.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,Y.jsxs)(`span`,{className:`oc-projpage__cardhead`,children:[(0,Y.jsx)(L,{size:15,"aria-hidden":!0,className:`oc-projpage__cardico`}),(0,Y.jsx)(`span`,{className:`oc-projpage__cardname`,children:e.name}),(0,Y.jsx)(X,{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,Y.jsxs)(`span`,{className:`oc-projpage__cardmeta`,children:[e.folderCount>0?De({count:e.folderCount})+` · `:``,y({count:e.recursiveChatCount})]}),e.lastActivityAt===null?null:(0,Y.jsx)(`span`,{className:`oc-projpage__cardage`,children:tt(e.lastActivityAt,n)})]})}function Q({chat:e}){let t=o(k.chats.setChatSidebar),n=e.inSidebar?ue():v();return(0,Y.jsx)(j,{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,Y.jsx)(I,{}):(0,Y.jsx)(q,{})})}function Pt({chat:e,currentFolderId:t,now:n,busy:r,unread:i,locate:a,suppressClick:o}){let s=(0,J.useContext)(B).get(e._id),c=R(),l=W(e.color),u=P({id:`chat:${e._id}`}),d=$(a);return(0,Y.jsxs)(`li`,{ref:e=>{u.setNodeRef(e),d.current=e},className:`oc-projpage__chatrow`+(u.isDragging?` is-dragging`:``)+(a?` is-locate`:``),style:{transform:F.Transform.toString(u.transform),transition:u.transition},children:[(0,Y.jsxs)(`button`,{type:`button`,className:`oc-projpage__chatbtn`,onClick:()=>{o.current||c({to:`/chat/$chatId`,params:{chatId:e._id}})},...u.listeners,...u.attributes,children:[l?(0,Y.jsx)(`span`,{className:`oc-chatitem__dot`,style:{background:l}}):(0,Y.jsx)(`span`,{className:`oc-chatitem__dot oc-chatitem__dot--empty`}),(0,Y.jsx)(`span`,{className:`oc-projpage__chattitle`,children:e.title||_e()}),e.pinned?(0,Y.jsx)(N,{size:12,"aria-hidden":!0,className:`oc-projpage__chatpin`}):null,(0,Y.jsx)(`span`,{className:`oc-projpage__chatage`,children:tt(e.updatedAt,n)}),r?(0,Y.jsx)(`span`,{className:z(s,S()).className,title:z(s,S()).label,"aria-label":z(s,S()).label}):null,i&&!r?(0,Y.jsx)(`span`,{className:`oc-chatitem__unread`,title:O(),"aria-label":O()}):null]}),(0,Y.jsx)(Q,{chat:e}),(0,Y.jsx)(xt,{chat:e,currentFolderId:t,className:`oc-projpage__chatmenu`})]})}function $(e){let t=(0,J.useRef)(null);return(0,J.useEffect)(()=>{e&&t.current&&t.current.scrollIntoView({block:`center`})},[e]),t}function Ft({data:e,busyIds:t,suppressClick:n,locateChatId:r}){let[i,a]=(0,J.useState)(new Set),o=(0,J.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,Y.jsx)(`p`,{className:`oc-projpage__hint`,children:E()});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=ct(e.folders,a);return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(K,{items:u.map(e=>`chat:${e._id}`),strategy:G,children:u.map(e=>(0,Y.jsx)(Lt,{chat:e,depth:l,busy:t.has(e._id),locate:e._id===r,suppressClick:n},e._id))}),(0,Y.jsx)(K,{items:d.map(e=>`folder:${e._id}`),strategy:G,children:d.map(t=>(0,Y.jsx)(It,{folder:t,parentId:a??e.rootId,depth:l,folded:i.has(t._id),onToggle:()=>s(t._id),suppressClick:n,children:i.has(t._id)?null:c(t._id,l+1)},t._id))})]})};return(0,Y.jsx)(`div`,{className:`oc-projpage__tree`,children:(o.get(e.rootId)??[]).length===0&&ct(e.folders,null).length===0?(0,Y.jsx)(`p`,{className:`oc-projpage__hint`,children:u()}):c(null,0)})}function It({folder:e,parentId:t,depth:n,folded:r,onToggle:i,suppressClick:a,children:o}){let s=R(),c=P({id:`folder:${e._id}`}),l=V({id:Z(e._id)});return(0,Y.jsxs)(`div`,{className:`oc-projpage__treegroup`,children:[(0,Y.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":ht(e),transform:F.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,Y.jsx)(`button`,{type:`button`,className:`oc-projpage__treechev`,"aria-label":r?se():ae(),"aria-expanded":!r,onClick:e=>{e.stopPropagation(),!a.current&&i()},onMouseDown:e=>e.stopPropagation(),onTouchStart:e=>e.stopPropagation(),children:r?(0,Y.jsx)(ft,{size:13}):(0,Y.jsx)(Oe,{size:13})}),(0,Y.jsx)(L,{size:13,"aria-hidden":!0,className:`oc-projpage__colico`}),(0,Y.jsx)(`span`,{className:`oc-projpage__colname`,children:e.name}),(0,Y.jsx)(X,{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 Lt({chat:e,depth:t,busy:n,locate:r,suppressClick:i}){let a=(0,J.useContext)(B).get(e._id),o=R(),s=P({id:`chat:${e._id}`}),c=$(r),l=W(e.color);return(0,Y.jsxs)(`div`,{ref:e=>{s.setNodeRef(e),c.current=e},className:`oc-projpage__treerow oc-projpage__treerow--chat`+(s.isDragging?` is-dragging`:``)+(r?` is-locate`:``),style:{"--tree-depth":t,transform:F.Transform.toString(s.transform),transition:s.transition},children:[(0,Y.jsxs)(`button`,{type:`button`,className:`oc-projpage__colchatbtn`,onClick:()=>{i.current||o({to:`/chat/$chatId`,params:{chatId:e._id}})},...s.listeners,...s.attributes,children:[l?(0,Y.jsx)(`span`,{className:`oc-chatitem__dot`,style:{background:l}}):(0,Y.jsx)(`span`,{className:`oc-chatitem__dot oc-chatitem__dot--empty`}),(0,Y.jsx)(`span`,{className:`oc-projpage__colname`,children:e.title||_e()}),n?(0,Y.jsx)(`span`,{className:z(a,``).className,"aria-hidden":!0}):null]}),(0,Y.jsx)(xt,{chat:e,currentFolderId:e.folderId,className:`oc-projpage__treemenu`}),(0,Y.jsx)(Q,{chat:e})]})}function Rt({data:e,currentId:t,busyIds:n,suppressClick:r,locateChatId:i}){let a=(0,J.useRef)(null);return(0,J.useEffect)(()=>{let e=a.current;e&&(e.scrollLeft=e.scrollWidth)},[e?.columns.length??0,t]),e===void 0?(0,Y.jsx)(`p`,{className:`oc-projpage__hint`,children:E()}):(0,Y.jsx)(`div`,{className:`oc-projpage__cols`,ref:a,children:e.columns.map((a,o)=>(0,Y.jsx)(zt,{col:a,isLast:o===e.columns.length-1,currentId:t,busyIds:n,suppressClick:r,locateChatId:i},a.folderId??`root`))})}function zt({col:e,isLast:t,currentId:n,busyIds:r,suppressClick:i,locateChatId:a}){let o=R(),s=V({id:Dt(e.folderId)});return(0,Y.jsxs)(`div`,{ref:s.setNodeRef,className:`oc-projpage__col`+(s.isOver?` is-over`:``)+(t?` is-last`:``),children:[(0,Y.jsx)(K,{items:e.folders.map(e=>`folder:${e._id}`),strategy:G,children:e.folders.map(t=>(0,Y.jsx)(Bt,{folder:t,parentId:e.folderId,isCurrent:t._id===n,suppressClick:i,onOpen:()=>void o({to:`/project/$projectId`,params:{projectId:t._id}})},t._id))}),(0,Y.jsx)(K,{items:e.chats.map(e=>`chat:${e._id}`),strategy:G,children:e.chats.map(t=>(0,Y.jsx)(Vt,{chat:t,folderId:e.folderId,busy:r.has(t._id),locate:t._id===a,suppressClick:i,onOpen:()=>void o({to:`/chat/$chatId`,params:{chatId:t._id}})},t._id))}),e.folders.length===0&&e.chats.length===0?(0,Y.jsx)(`p`,{className:`oc-projpage__colempty`,children:_()}):null]})}function Bt({folder:e,parentId:t,isCurrent:n,suppressClick:r,onOpen:i}){let a=P({id:`folder:${e._id}`}),o=V({id:Z(e._id)});return(0,Y.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":ht(e),transform:F.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,Y.jsx)(L,{size:13,"aria-hidden":!0,className:`oc-projpage__colico`}),(0,Y.jsx)(`span`,{className:`oc-projpage__colname`,children:e.name}),(0,Y.jsx)(`span`,{className:`oc-projpage__colchev`,"aria-hidden":!0,children:`›`}),(0,Y.jsx)(X,{folderId:e._id,name:e.name,color:e.color,currentParentId:t,className:`oc-projpage__colmenu`,onOpen:i})]})}function Vt({chat:e,folderId:t,busy:n,locate:r,suppressClick:i,onOpen:a}){let o=(0,J.useContext)(B).get(e._id),s=P({id:`chat:${e._id}`}),c=$(r),l=W(e.color);return(0,Y.jsxs)(`div`,{ref:e=>{s.setNodeRef(e),c.current=e},className:`oc-projpage__colentry oc-projpage__colentry--chat`+(s.isDragging?` is-dragging`:``)+(r?` is-locate`:``),style:{transform:F.Transform.toString(s.transform),transition:s.transition},children:[(0,Y.jsxs)(`button`,{type:`button`,className:`oc-projpage__colchatbtn`,onClick:()=>{i.current||a()},...s.listeners,...s.attributes,children:[l?(0,Y.jsx)(`span`,{className:`oc-chatitem__dot`,style:{background:l}}):(0,Y.jsx)(`span`,{className:`oc-chatitem__dot oc-chatitem__dot--empty`}),(0,Y.jsx)(`span`,{className:`oc-projpage__colname`,children:e.title||_e()}),n?(0,Y.jsx)(`span`,{className:z(o,``).className,"aria-hidden":!0}):null]}),(0,Y.jsx)(xt,{chat:e,currentFolderId:t,className:`oc-projpage__colmenu oc-projpage__colmenu--chat`}),(0,Y.jsx)(Q,{chat:e})]})}export{At as ProjectPage};
@@ -1,4 +1,4 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{BY as r,Bd as i,Bp as a,Ck as o,Dk as s,Ek as c,Hp as l,Id as u,Ik as d,Jd as f,Ld as p,Lk as m,Ok as h,Rd as g,Rp as _,Sk as v,Tk as ee,VY as y,Vp as te,Xd as ne,Yd as b,_k as x,au as S,bk as C,dk as w,fk as T,gk as re,hk as ie,kk as ae,mk as oe,ou as se,pk as ce,qd as E,su as D,t as O,uk as k,vk as A,wk as j,xk as M,xo as N,yk as P,zd as F,zp as I}from"./api-BiOKjOdr.js";import{i as L,n as R,r as z,t as B}from"./FieldLabel-DaWvOVaq.js";import{t as V}from"./button-D0Pgjwxf.js";import{Mt as H,St as U,Yt as W,bt as G,ft as le,gn as ue,hn as de,mn as fe,pn as K,vt as q,xt as J,yt as Y}from"./index-xhYNLD3V.js";import{r as X,t as Z}from"./locales-CPjguROj.js";import{t as pe}from"./localePickerView-C2RmOS86.js";/* empty css */var Q=t(e(),1),$=n(),me={media_delivery:{label:j,help:o},documentary_fetch:{label:v,help:M},inbound_files:{label:C,help:P},history_summary:{label:l,help:te},file_curation:{label:ne,help:i},quote_reply:{label:b,help:f}},he={outboundDir:`/home/node/.openclaw/media/outbound`,references:`- gdrive/1a2b3c4d5e6f7890abcd
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{BY as r,Bd as i,Bp as a,Ck as o,Dk as s,Ek as c,Hp as l,Id as u,Ik as d,Jd as f,Ld as p,Lk as m,Ok as h,Rd as g,Rp as _,Sk as v,Tk as ee,VY as y,Vp as te,Xd as ne,Yd as b,_k as x,au as S,bk as C,dk as w,fk as T,gk as re,hk as ie,kk as ae,mk as oe,ou as se,pk as ce,qd as E,su as D,t as O,uk as k,vk as A,wk as j,xk as M,xo as N,yk as P,zd as F,zp as I}from"./api-DcB3BxUc.js";import{i as L,n as R,r as z,t as B}from"./FieldLabel-CZ-m3Yh8.js";import{t as V}from"./button-DgaBsJDX.js";import{Mt as H,St as U,Yt as W,bt as G,ft as le,gn as ue,hn as de,mn as fe,pn as K,vt as q,xt as J,yt as Y}from"./index-Ds-ybIOh.js";import{r as X,t as Z}from"./locales-CPjguROj.js";import{t as pe}from"./localePickerView-C2RmOS86.js";/* empty css */var Q=t(e(),1),$=n(),me={media_delivery:{label:j,help:o},documentary_fetch:{label:v,help:M},inbound_files:{label:C,help:P},history_summary:{label:l,help:te},file_curation:{label:ne,help:i},quote_reply:{label:b,help:f}},he={outboundDir:`/home/node/.openclaw/media/outbound`,references:`- gdrive/1a2b3c4d5e6f7890abcd
2
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
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
4
  - [Fait 1](fait-1.md) - note du projet`,excerpt:`Le classement propose trois dossiers : Clients, Fournisseurs, Interne.`},ge={outboundDir:T,references:w,files:k,previous_summary:a,new_messages:I,max_chars:_,file_name:F,budget_chars:g,feedback:p,content:u,excerpt:E};function _e(){let e=y(O.admin.listInstances,{}),[t,n]=(0,Q.useState)(null);if(e===void 0)return(0,$.jsx)(`div`,{className:`oc-settings__tab-loading`,"aria-busy":`true`});if(e.length===0)return(0,$.jsx)(`div`,{className:`oc-injtab`,children:(0,$.jsx)(`p`,{className:`oc-admin__hint`,children:x()})});let r=e.find(e=>e._id===t)??e[0];return(0,$.jsxs)(`div`,{className:`oc-injtab`,children:[(0,$.jsxs)(`div`,{className:`oc-injtab__head`,children:[(0,$.jsx)(R,{label:ae(),help:h()}),(0,$.jsxs)(`label`,{className:`oc-injtab__picker`,children:[(0,$.jsx)(`span`,{children:A()}),(0,$.jsxs)(q,{value:r._id,onValueChange:e=>n(e),children:[(0,$.jsx)(J,{size:`sm`,className:`min-w-44`,children:(0,$.jsx)(U,{})}),(0,$.jsx)(Y,{children:e.map(e=>(0,$.jsx)(G,{value:e._id,children:e.displayName??e.name},e._id))})]})]})]}),(0,$.jsx)(ve,{instance:r},r._id)]})}function ve({instance:e}){let t=r(O.admin.upsertInstanceConfig),n=W(),i=y(O.me.getMe,{host:le}),a=e.config??{},o=X(e.config?.contentLocale,i?.defaultLocale??void 0),[s,c]=(0,Q.useState)(()=>L(a,o));(0,Q.useEffect)(()=>{c(L(a,o))},[o,e._id]);let[l,u]=(0,Q.useState)(!1),f=s.promptInjections,p=(e,t)=>c({...s,promptInjections:{...f,[e]:{...f[e],...t}}});async function h(){u(!0);try{await t({instanceId:e._id,config:z(s,a,o)})}catch(e){n.error(d(),e)}finally{u(!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(d(),e)}}let _=e.config?.contentLocale??`default`,v=Z[X(void 0,i?.defaultLocale??void 0)];return(0,$.jsxs)(`div`,{className:`oc-injtab__body`,children:[(0,$.jsxs)(`div`,{className:`oc-injtab__content-locale`,children:[(0,$.jsx)(`span`,{children:D()}),(0,$.jsxs)(q,{value:_,onValueChange:e=>void g(e),children:[(0,$.jsx)(J,{size:`sm`,className:`min-w-44`,children:(0,$.jsx)(U,{})}),(0,$.jsxs)(Y,{children:[(0,$.jsx)(G,{value:`default`,children:S({locale:v})}),pe().map(e=>(0,$.jsx)(G,{value:e.value,children:e.label},e.value))]})]}),(0,$.jsx)(`p`,{className:`oc-admin__hint`,children:se()})]}),fe.map(e=>(0,$.jsx)(ye,{injKey:e,def:K[e],i18n:me[e],row:f[e]??{enabled:!0,template:K[e].defaultTemplate[o]},contentLocale:o,onChange:t=>p(e,t)},e)),(0,$.jsx)(`div`,{className:`oc-injtab__actions`,children:(0,$.jsx)(V,{size:`sm`,onClick:()=>void h(),disabled:l,children:m()})})]})}function ye({injKey:e,def:t,i18n:n,row:r,contentLocale:i,onChange:a}){let[o,l]=(0,Q.useState)(!1),u=r.template.trim()!==t.defaultTemplate[i],d=t.togglable&&!r.enabled,f=Object.fromEntries(t.placeholders.map(e=>[e,he[e]??`{${e}}`])),p=de(e,r,i),m=p?ue(p,f):``;return(0,$.jsxs)(`section`,{className:`oc-injcard`,children:[(0,$.jsxs)(`div`,{className:`oc-injcard__head`,children:[t.togglable?(0,$.jsxs)(`label`,{className:`oc-field--row`,children:[(0,$.jsx)(H,{checked:r.enabled,onCheckedChange:e=>a({enabled:e===!0})}),(0,$.jsx)(R,{label:n.label(),help:n.help()})]}):(0,$.jsx)(R,{label:n.label(),help:n.help()}),u&&(0,$.jsx)(`span`,{className:`oc-injection__badge`,children:c()})]}),(0,$.jsx)(`textarea`,{className:`oc-injcard__text`,value:r.template,disabled:d,rows:8,spellCheck:!1,onChange:e=>a({template:e.target.value})}),(0,$.jsxs)(`div`,{className:`oc-injection__foot`,children:[(0,$.jsxs)(`div`,{className:`oc-injcard__phs`,children:[(0,$.jsx)(`span`,{className:`oc-injection__ph`,children:ee()}),t.placeholders.map(e=>(0,$.jsxs)(`span`,{className:`oc-injcard__ph-chip`,children:[(0,$.jsx)(`code`,{children:`{${e}}`}),(0,$.jsx)(B,{text:(ge[e]??(()=>e))()})]},e))]}),(0,$.jsxs)(`div`,{className:`oc-injcard__btns`,children:[(0,$.jsx)(V,{variant:`ghost`,size:`sm`,onClick:()=>l(e=>!e),children:o?ie():re()}),u&&(0,$.jsx)(V,{variant:`ghost`,size:`sm`,onClick:()=>a({template:t.defaultTemplate[i]}),children:s()})]})]}),o&&(0,$.jsx)(`div`,{className:`oc-injcard__preview`,children:m?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`pre`,{className:`oc-injcard__previewtext`,children:m}),(0,$.jsx)(`span`,{className:`oc-injection__ph`,children:oe()}),t.pluralDefaultTemplate!==void 0&&!d?(0,$.jsx)(`span`,{className:`oc-injection__ph`,children:N()}):null]}):(0,$.jsx)(`span`,{className:`oc-injection__ph`,children:ce()})})]})}export{_e as PromptInjectionsTab};
@@ -1 +1 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{AN as r,BM as i,BY as a,CN as o,DN as s,EN as c,GM as l,HM as ee,JM as u,KM as d,ON as f,SN as p,TN as m,UM as h,VM as te,VY as ne,WM as re,_N as g,aN as _,bN as v,bf as y,cN as b,dN as ie,eN as x,fN as ae,gN as oe,hN as S,iN as C,kN as w,lN as T,mN as E,nN as D,oN as O,pN as k,qM as A,rN as j,sN as M,t as N,tN as P,uN as F,vN as I,wN as L,xN as R,yN as z}from"./api-BiOKjOdr.js";import{t as B}from"./button-D0Pgjwxf.js";import{$t as V,Jt as H,Mt as U,Yt as W,b as G,ct as K,qn as q}from"./index-xhYNLD3V.js";import{t as J}from"./roleDescriptions-DKA8gzL4.js";var Y=t(e(),1),X=n(),Z=[{group:()=>r(),keys:[{key:`traces.read`,label:()=>m()},{key:`traces.read.content`,label:()=>L(),phi:!0},{key:`traces.write`,label:()=>o()}]},{group:()=>w(),keys:[{key:`kpi.read`,label:()=>m()},{key:`kpi.write`,label:()=>o()}]},{group:()=>f(),keys:[{key:`openclaw.query`,label:()=>p()},{key:`anomalies.read`,label:()=>R()},{key:`anomalies.report`,label:()=>v()}]},{group:()=>s(),keys:[{key:`chats.read`,label:()=>m()},{key:`selfheal`,label:()=>I()},{key:`media.repair`,label:()=>g()},{key:`feedback.respond`,label:()=>y()}]},{group:()=>c(),keys:[{key:`admin.manage`,label:()=>z()}]}],se=Z.flatMap(e=>e.keys.map(e=>e.key));function Q(e){return e.includes(`*`)}var $={key:``,name:``,description:``};function ce(){let e=ne(N.apiKeys.listRoles,{}),t=a(N.apiKeys.createRole),n=a(N.apiKeys.ensureRolesSeeded),r=a(N.apiKeys.updateRolePermissions).withOptimisticUpdate((e,{roleId:t,permissions:n})=>{let r=e.getQuery(N.apiKeys.listRoles,{});r&&e.setQuery(N.apiKeys.listRoles,{},r.map(e=>e._id===t?{...e,permissions:n}:e))}),o=K(),s=W(),[c,f]=(0,Y.useState)(!1),[p,m]=(0,Y.useState)($),[g,v]=(0,Y.useState)(new Set);(0,Y.useEffect)(()=>{n({}).catch(e=>{s.error(S(),e)})},[n,s]);let y=e??[];async function w(e,t){if(Q(e.permissions))return;if(e.builtin){await o({title:E({name:e.name}),description:k(),confirmLabel:ae()});return}if(g.has(e._id))return;let n=e.permissions.includes(t)?e.permissions.filter(e=>e!==t):[...e.permissions,t];v(t=>new Set(t).add(e._id));try{await r({roleId:e._id,permissions:n})}catch(e){s.error(ie(),e)}finally{v(t=>{let n=new Set(t);return n.delete(e._id),n})}}async function I(){try{await t({key:p.key,name:p.name,description:p.description||void 0,permissions:[]}),m($),f(!1)}catch(e){s.error(F(),e)}}let L=e===void 0,R=!L&&y.length===0;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`p`,{className:`oc-admin__hint`,children:[T(),` `,(0,X.jsx)(`code`,{children:`admin`}),` `,b(),` `,(0,X.jsx)(`code`,{children:`traces.read.content`}),` `,M()]}),(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:O()}),(0,X.jsx)(`div`,{className:`oc-dt__bar-actions`,children:(0,X.jsx)(B,{size:`sm`,onClick:()=>{m($),f(!0)},children:_()})})]}),L?(0,X.jsx)(`p`,{className:`oc-admin__hint`,children:C()}):R?(0,X.jsx)(`p`,{className:`oc-admin__hint`,children:j()}):(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:D()}),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?oe({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:y.map(e=>{let t=Q(e.permissions),n=g.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,{}),` `,P()]}):(0,X.jsx)(H,{variant:`secondary`,children:x()})]}),J(e)?(0,X.jsx)(`p`,{className:`oc-matrix__roledesc`,children:J(e)}):null]}),se.map(r=>(0,X.jsx)(`td`,{className:`oc-matrix__cell`,children:(0,X.jsx)(U,{checked:t||e.permissions.includes(r),disabled:t||n,"aria-label":`${e.key} · ${r}`,title:t?u():n?A():r,onCheckedChange:()=>void w(e,r)})},r))]},e.key)})})]})})]}),(0,X.jsx)(G,{open:c,onOpenChange:f,title:d(),description:l(),canSubmit:!!(p.key&&p.name),onSubmit:I,submitLabel:re(),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:h()}),(0,X.jsx)(V,{value:p.key,placeholder:ee(),onChange:e=>m({...p,key:e.target.value})})]}),(0,X.jsxs)(`label`,{className:`oc-field`,children:[(0,X.jsx)(`span`,{className:`oc-field__label`,children:te()}),(0,X.jsx)(V,{value:p.name,onChange:e=>m({...p,name:e.target.value})})]}),(0,X.jsxs)(`label`,{className:`oc-field`,children:[(0,X.jsx)(`span`,{className:`oc-field__label`,children:i()}),(0,X.jsx)(V,{value:p.description,onChange:e=>m({...p,description:e.target.value})})]})]})})]})}export{ce as RolesTab};
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{AN as r,BM as i,BY as a,CN as o,DN as s,EN as c,GM as l,HM as ee,JM as u,KM as d,ON as f,SN as p,TN as m,UM as h,VM as te,VY as ne,WM as re,_N as g,aN as _,bN as v,bf as y,cN as b,dN as ie,eN as x,fN as ae,gN as oe,hN as S,iN as C,kN as w,lN as T,mN as E,nN as D,oN as O,pN as k,qM as A,rN as j,sN as M,t as N,tN as P,uN as F,vN as I,wN as L,xN as R,yN as z}from"./api-DcB3BxUc.js";import{t as B}from"./button-DgaBsJDX.js";import{$t as V,Jt as H,Mt as U,Yt as W,b as G,ct as K,qn as q}from"./index-Ds-ybIOh.js";import{t as J}from"./roleDescriptions-DHMAPGYx.js";var Y=t(e(),1),X=n(),Z=[{group:()=>r(),keys:[{key:`traces.read`,label:()=>m()},{key:`traces.read.content`,label:()=>L(),phi:!0},{key:`traces.write`,label:()=>o()}]},{group:()=>w(),keys:[{key:`kpi.read`,label:()=>m()},{key:`kpi.write`,label:()=>o()}]},{group:()=>f(),keys:[{key:`openclaw.query`,label:()=>p()},{key:`anomalies.read`,label:()=>R()},{key:`anomalies.report`,label:()=>v()}]},{group:()=>s(),keys:[{key:`chats.read`,label:()=>m()},{key:`selfheal`,label:()=>I()},{key:`media.repair`,label:()=>g()},{key:`feedback.respond`,label:()=>y()}]},{group:()=>c(),keys:[{key:`admin.manage`,label:()=>z()}]}],se=Z.flatMap(e=>e.keys.map(e=>e.key));function Q(e){return e.includes(`*`)}var $={key:``,name:``,description:``};function ce(){let e=ne(N.apiKeys.listRoles,{}),t=a(N.apiKeys.createRole),n=a(N.apiKeys.ensureRolesSeeded),r=a(N.apiKeys.updateRolePermissions).withOptimisticUpdate((e,{roleId:t,permissions:n})=>{let r=e.getQuery(N.apiKeys.listRoles,{});r&&e.setQuery(N.apiKeys.listRoles,{},r.map(e=>e._id===t?{...e,permissions:n}:e))}),o=K(),s=W(),[c,f]=(0,Y.useState)(!1),[p,m]=(0,Y.useState)($),[g,v]=(0,Y.useState)(new Set);(0,Y.useEffect)(()=>{n({}).catch(e=>{s.error(S(),e)})},[n,s]);let y=e??[];async function w(e,t){if(Q(e.permissions))return;if(e.builtin){await o({title:E({name:e.name}),description:k(),confirmLabel:ae()});return}if(g.has(e._id))return;let n=e.permissions.includes(t)?e.permissions.filter(e=>e!==t):[...e.permissions,t];v(t=>new Set(t).add(e._id));try{await r({roleId:e._id,permissions:n})}catch(e){s.error(ie(),e)}finally{v(t=>{let n=new Set(t);return n.delete(e._id),n})}}async function I(){try{await t({key:p.key,name:p.name,description:p.description||void 0,permissions:[]}),m($),f(!1)}catch(e){s.error(F(),e)}}let L=e===void 0,R=!L&&y.length===0;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`p`,{className:`oc-admin__hint`,children:[T(),` `,(0,X.jsx)(`code`,{children:`admin`}),` `,b(),` `,(0,X.jsx)(`code`,{children:`traces.read.content`}),` `,M()]}),(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:O()}),(0,X.jsx)(`div`,{className:`oc-dt__bar-actions`,children:(0,X.jsx)(B,{size:`sm`,onClick:()=>{m($),f(!0)},children:_()})})]}),L?(0,X.jsx)(`p`,{className:`oc-admin__hint`,children:C()}):R?(0,X.jsx)(`p`,{className:`oc-admin__hint`,children:j()}):(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:D()}),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?oe({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:y.map(e=>{let t=Q(e.permissions),n=g.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,{}),` `,P()]}):(0,X.jsx)(H,{variant:`secondary`,children:x()})]}),J(e)?(0,X.jsx)(`p`,{className:`oc-matrix__roledesc`,children:J(e)}):null]}),se.map(r=>(0,X.jsx)(`td`,{className:`oc-matrix__cell`,children:(0,X.jsx)(U,{checked:t||e.permissions.includes(r),disabled:t||n,"aria-label":`${e.key} · ${r}`,title:t?u():n?A():r,onCheckedChange:()=>void w(e,r)})},r))]},e.key)})})]})})]}),(0,X.jsx)(G,{open:c,onOpenChange:f,title:d(),description:l(),canSubmit:!!(p.key&&p.name),onSubmit:I,submitLabel:re(),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:h()}),(0,X.jsx)(V,{value:p.key,placeholder:ee(),onChange:e=>m({...p,key:e.target.value})})]}),(0,X.jsxs)(`label`,{className:`oc-field`,children:[(0,X.jsx)(`span`,{className:`oc-field__label`,children:te()}),(0,X.jsx)(V,{value:p.name,onChange:e=>m({...p,name:e.target.value})})]}),(0,X.jsxs)(`label`,{className:`oc-field`,children:[(0,X.jsx)(`span`,{className:`oc-field__label`,children:i()}),(0,X.jsx)(V,{value:p.description,onChange:e=>m({...p,description:e.target.value})})]})]})})]})}export{ce as RolesTab};
@@ -1 +1 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$K as r,AK as i,Aq as a,BK as o,CK as s,Cq as c,DK as l,Dq as u,E as d,EK as ee,Eq as f,Fq as p,GK as m,HK as h,JK as g,KK as te,Mq as ne,NY as _,Nq as re,OK as ie,Oq as ae,Pq as oe,QK as v,RY as y,SK as se,Sq as ce,TK as le,Tq as ue,UK as de,VK as fe,VY as pe,WK as me,XK as b,YK as he,ZK as ge,_K as _e,_q as ve,aJ as ye,bK as be,bq as xe,cJ as Se,cq as Ce,dJ as we,dq as Te,eJ as Ee,eq as x,fJ as De,fq as Oe,gK as ke,hJ as Ae,hK as je,hq as Me,iJ as Ne,jY as Pe,jq as Fe,kK as Ie,lJ as Le,lq as Re,mJ as ze,mK as Be,mq as Ve,nJ as He,oJ as Ue,oq as We,pJ as Ge,pK as Ke,pq as qe,qK as Je,rJ as Ye,sJ as Xe,sK as Ze,sq as Qe,t as S,tJ as $e,tq as et,uJ as tt,uq as nt,vK as rt,wK as it,wq as at,xK as ot,xq as st,yK as ct}from"./api-BiOKjOdr.js";import{t as lt}from"./list-Dx86Q3WV.js";import{t as C}from"./button-D0Pgjwxf.js";import{$t as ut,An as dt,Bt as ft,Ct as pt,Dt as mt,Et as ht,Gt as gt,Hn as _t,Ht as vt,In as yt,Jn as bt,Jt as w,Kt as xt,Ot as St,Rn as Ct,Rt as wt,St as T,Tt,Ut as Et,Vn as Dt,Vt as Ot,Wt as kt,Yt as At,bt as E,cn as D,cr as O,ft as jt,on as k,qt as Mt,sn as A,sr as j,vt as M,wn as Nt,wt as Pt,xt as N,yt as P,zt as Ft}from"./index-xhYNLD3V.js";import{a as It,i as F,n as Lt,o as Rt,r as I,t as zt}from"./table-DsK3yFpt.js";import{t as Bt}from"./FilterBar-BWsi04G_.js";/* empty css */import{a as Vt,c as L,i as R,l as Ht,n as Ut,o as Wt,r as Gt,s as Kt,t as qt,u as z}from"./TimezoneCombobox-BB280Bgg.js";var Jt=d(`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`}]]),Yt=d(`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`}]]),B=t(e(),1),V=n();function H(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 Xt({value:e,onChange:t}){let n=Ht(e),i=(0,B.useMemo)(()=>new Date,[]),[a,o]=(0,B.useState)(()=>({year:n?.year??i.getFullYear(),month:n?.month??i.getMonth()})),[s,c]=(0,B.useState)(!1),l=(0,B.useMemo)(()=>H(_()),[]),u=(0,B.useMemo)(()=>new Intl.DateTimeFormat(_(),{month:`long`,year:`numeric`}),[]),d=(0,B.useMemo)(()=>new Intl.DateTimeFormat(_(),{dateStyle:`medium`,timeStyle:`short`}),[]),ee=L(a.year,a.month),f=n?.hour??9,p=n?.minute??0,m=(e,n,r,i,a)=>t(z(e,n,r,i,a)),h=(e,t,n)=>{o({year:e,month:t}),m(e,t,n,f,p)},g=e=>{let t=new Date(a.year,a.month+e,1);o({year:t.getFullYear(),month:t.getMonth()})},te=n===null?x():d.format(new Date(n.year,n.month,n.day,n.hour,n.minute));return(0,V.jsxs)(k,{modal:!0,open:s,onOpenChange:c,children:[(0,V.jsx)(D,{asChild:!0,children:(0,V.jsxs)(`button`,{type:`button`,className:`oc-dtp__trigger`,"aria-label":et(),children:[(0,V.jsx)(Jt,{size:14,"aria-hidden":!0,className:`oc-dtp__icon`}),(0,V.jsx)(`span`,{className:n===null?`oc-dtp__placeholder`:void 0,children:te})]})}),(0,V.jsxs)(A,{align:`start`,className:`oc-dtp__pop`,children:[(0,V.jsxs)(`div`,{className:`oc-dtp__head`,children:[(0,V.jsx)(`button`,{type:`button`,className:`oc-dtp__nav`,"aria-label":r(),onClick:()=>g(-1),children:(0,V.jsx)(O,{size:15,"aria-hidden":!0})}),(0,V.jsx)(`span`,{className:`oc-dtp__month`,children:u.format(new Date(a.year,a.month,1))}),(0,V.jsx)(`button`,{type:`button`,className:`oc-dtp__nav`,"aria-label":v(),onClick:()=>g(1),children:(0,V.jsx)(j,{size:15,"aria-hidden":!0})})]}),(0,V.jsxs)(`div`,{className:`oc-dtp__grid`,children:[l.map((e,t)=>(0,V.jsx)(`span`,{className:`oc-dtp__wd`,children:e},t)),ee.map((e,t)=>{let r=n!==null&&n.year===e.year&&n.month===e.month&&n.day===e.day,a=i.getFullYear()===e.year&&i.getMonth()===e.month&&i.getDate()===e.day;return(0,V.jsx)(`button`,{type:`button`,className:`oc-dtp__day`+(e.inMonth?``:` oc-dtp__day--out`)+(r?` oc-dtp__day--sel`:``)+(a&&!r?` oc-dtp__day--today`:``),onClick:()=>h(e.year,e.month,e.day),children:e.day},t)})]}),(0,V.jsxs)(`div`,{className:`oc-dtp__time`,children:[(0,V.jsxs)(M,{value:String(f),onValueChange:e=>m(a.year,a.month,n?.day??i.getDate(),Number(e),p),children:[(0,V.jsx)(N,{size:`sm`,"aria-label":ge(),children:(0,V.jsx)(T,{})}),(0,V.jsx)(P,{className:`oc-dtp__timeopts`,children:Array.from({length:24},(e,t)=>(0,V.jsx)(E,{value:String(t),children:String(t).padStart(2,`0`)},t))})]}),(0,V.jsx)(`span`,{className:`oc-dtp__colon`,children:`:`}),(0,V.jsxs)(M,{value:String(p),onValueChange:e=>m(a.year,a.month,n?.day??i.getDate(),f,Number(e)),children:[(0,V.jsx)(N,{size:`sm`,"aria-label":b(),children:(0,V.jsx)(T,{})}),(0,V.jsx)(P,{className:`oc-dtp__timeopts`,children:Array.from({length:60},(e,t)=>(0,V.jsx)(E,{value:String(t),children:String(t).padStart(2,`0`)},t))})]})]})]})]})}function U(e){let t=new Date(e),n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())}`}function Zt(e,t,n){let r=e=>String(e).padStart(2,`0`);return`${e}-${r(t+1)}-${r(n)}`}function Qt(e){let t=new Map;for(let n of e){let e=U(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 $t(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(Zt(t,n,a));i!==void 0&&i.length>0&&r.set(a,i.length)}return r}function en(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 tn(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 nn(e){return{startMs:new Date(e,0,1).getTime(),endMs:new Date(e+1,0,1).getTime()}}var W=3;function rn({events:e,mode:t,cursor:n,onModeChange:r,onCursorChange:i,onEventClick:a,footnote:o}){let s=_(),c=(0,B.useMemo)(()=>Qt(e),[e]),l=(0,B.useMemo)(()=>en(s),[s]),u=(0,B.useMemo)(()=>new Intl.DateTimeFormat(s,{month:`long`,year:`numeric`}),[s]),d=(0,B.useMemo)(()=>new Intl.DateTimeFormat(s,{month:`long`}),[s]),ee=(0,B.useMemo)(()=>new Intl.DateTimeFormat(s,{hour:`2-digit`,minute:`2-digit`}),[s]),f=new Date,p=e=>{if(t===`year`){i({year:n.year+e,month:n.month});return}let r=new Date(n.year,n.month+e,1);i({year:r.getFullYear(),month:r.getMonth()})},g=t===`year`?String(n.year):u.format(new Date(n.year,n.month,1));return(0,V.jsxs)(`div`,{className:`oc-cal`,children:[(0,V.jsxs)(`div`,{className:`oc-cal__head`,children:[(0,V.jsxs)(`div`,{className:`oc-cal__nav`,children:[(0,V.jsx)(C,{variant:`ghost`,size:`icon-sm`,"aria-label":de(),onClick:()=>p(-1),children:(0,V.jsx)(O,{})}),(0,V.jsx)(C,{variant:`ghost`,size:`icon-sm`,"aria-label":h(),onClick:()=>p(1),children:(0,V.jsx)(j,{})}),(0,V.jsx)(C,{variant:`ghost`,size:`sm`,onClick:()=>i({year:f.getFullYear(),month:f.getMonth()}),children:me()})]}),(0,V.jsx)(`span`,{className:`oc-cal__title`,children:g}),(0,V.jsxs)(`div`,{className:`oc-cal__modes`,role:`group`,children:[(0,V.jsx)(C,{variant:t===`month`?`secondary`:`ghost`,size:`sm`,"aria-pressed":t===`month`,onClick:()=>r(`month`),children:te()}),(0,V.jsx)(C,{variant:t===`year`?`secondary`:`ghost`,size:`sm`,"aria-pressed":t===`year`,onClick:()=>r(`year`),children:m()})]})]}),t===`month`?(0,V.jsx)(an,{cursor:n,byDay:c,weekdays:l,timeFmt:ee,now:f,onEventClick:a}):(0,V.jsx)(on,{year:n.year,byDay:c,monthShortFmt:d,now:f,onOpenMonth:e=>{i({year:n.year,month:e}),r(`month`)}}),o?(0,V.jsx)(`p`,{className:`oc-cal__footnote`,children:o}):null]})}function an({cursor:e,byDay:t,weekdays:n,timeFmt:r,now:i,onEventClick:a}){let o=L(e.year,e.month);return(0,V.jsxs)(`div`,{className:`oc-cal__month`,children:[n.map((e,t)=>(0,V.jsx)(`span`,{className:`oc-cal__wd`,children:e},t)),o.map((e,n)=>{let o=t.get(Zt(e.year,e.month,e.day))??[],s=i.getFullYear()===e.year&&i.getMonth()===e.month&&i.getDate()===e.day;return(0,V.jsxs)(`div`,{className:`oc-cal__day`+(e.inMonth?``:` oc-cal__day--out`)+(s?` oc-cal__day--today`:``),children:[(0,V.jsx)(`span`,{className:`oc-cal__daynum`,children:e.day}),o.slice(0,W).map(e=>(0,V.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,V.jsx)(`span`,{className:`oc-cal__evdot`,"aria-hidden":!0}),(0,V.jsx)(`span`,{className:`oc-cal__evtime`,children:r.format(e.atMs)}),(0,V.jsx)(`span`,{className:`oc-cal__evtitle`,children:e.title})]},e.id)),o.length>W?(0,V.jsx)(`span`,{className:`oc-cal__more`,children:fe({count:o.length-W})}):null]},n)})]})}function on({year:e,byDay:t,monthShortFmt:n,now:r,onOpenMonth:i}){return(0,V.jsx)(`div`,{className:`oc-cal__year`,children:Array.from({length:12},(a,o)=>{let s=$t(t,e,o),c=L(e,o);return(0,V.jsxs)(`button`,{type:`button`,className:`oc-cal__mini`,onClick:()=>i(o),children:[(0,V.jsx)(`span`,{className:`oc-cal__mininame`,children:n.format(new Date(e,o,1))}),(0,V.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,V.jsx)(`span`,{className:`oc-cal__minidot`+(e.inMonth?``:` is-out`)+(n===1?` has-one`:``)+(n>1?` has-many`:``)+(i?` is-today`:``)},t)})})]},o)})})}var sn={h:36e5,min:6e4,s:1e3,ms:1};function cn(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])*sn[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 G(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 K(e){let t=e.trim().split(/\s+/);if(t.length!==5)return null;let n=G(t[0],0,59),r=G(t[1],0,23),i=G(t[2],1,31),a=G(t[3],1,12),o=G(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 ln=new Map;function q(e){let t=ln.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 ln.set(e,n),n}function J(e,t){if(t!==null){let n=q(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 Y(e,t,n,r,i,a){if(a===null||q(a)===null)return new Date(e,t,n,r,i).getTime();let o=Date.UTC(e,t,n,r,i),s=e=>{let t=J(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 X(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=K(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=J(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=Y(s.y,s.mo,s.d,o,c,e.tz);t>=n&&t<r&&(a(t,!1),i++)}}o=Y(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 Z=`crons`;function un(e,t){return`${e}\u0000${t}`}function dn(e,t,n){let r=[],i=new Map;for(let a of e){let{job:e}=a;if(e.id===null)continue;let o=un(a.instanceName,e.id);i.set(o,a);let s=Wt(e)!==`active`,c=X(s?null:cn(e.schedule),e.nextRunAtMs,t,n);for(let t of c)r.push({id:`${o}:${t.atMs}`,sourceId:Z,itemId:o,atMs:t.atMs,title:e.name??e.id,muted:s,exact:t.exact})}return{events:r,byItemId:i}}var Q={minutes:6e4,hours:36e5,days:864e5};function $(e){return e?.data?.code??`unknown`}function fn({status:e}){switch(Kt(e)){case`ok`:return(0,V.jsx)(w,{variant:`secondary`,children:Ve()});case`error`:return(0,V.jsx)(w,{variant:`destructive`,children:Oe()});case`running`:return(0,V.jsx)(w,{variant:`outline`,children:Te()});case`other`:return(0,V.jsx)(w,{variant:`outline`,children:e});case`none`:return(0,V.jsx)(`span`,{className:`text-muted-foreground`,children:`—`})}}function pn(){let e=y(S.scheduled.listMyCrons),t=y(S.scheduled.getCronDetail),n=y(S.scheduled.listCronRuns),r=y(S.scheduled.updateCron),d=y(S.scheduled.removeCron),m=y(S.scheduled.runCronNow),h=At(),te=pe(S.me.getMe,{host:jt})?.timezone,[v,de]=(0,B.useState)(null),[fe,me]=(0,B.useState)(!1),[b,ge]=(0,B.useState)(!1),[x,et]=(0,B.useState)(null),[D,O]=(0,B.useState)(null),[k,A]=(0,B.useState)(null),[j,L]=(0,B.useState)(null),[Ht,Kt]=(0,B.useState)(!1),[z,H]=(0,B.useState)(Ut),[U,Zt]=(0,B.useState)(()=>new URLSearchParams(window.location.search).get(`job`)===null&&localStorage.getItem(`oc.sched.view`)===`calendar`?`calendar`:`list`),Qt=e=>{localStorage.setItem(`oc.sched.view`,e),Zt(e)},[$t,en]=(0,B.useState)(`month`),[W,an]=(0,B.useState)(()=>{let e=new Date;return{year:e.getFullYear(),month:e.getMonth()}}),on=(0,B.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,z)&&e.push({instanceName:t.instanceName,canEdit:n,job:r})}return e},[v,z]),sn=(0,B.useMemo)(()=>$t===`year`?nn(W.year):tn(W.year,W.month),[$t,W]),cn=(0,B.useMemo)(()=>dn(on,sn.startMs,sn.endMs),[on,sn]),G=e=>{let t=cn.byItemId.get(e.itemId);t===void 0||!t.canEdit||t.job.id===null||pn(t.instanceName,t.job)},K=(0,B.useCallback)(async()=>{me(!0),ge(!1);try{de(await e({}))}catch{ge(!0)}finally{me(!1)}},[e]);(0,B.useEffect)(()=>{K()},[K]);let ln=(0,B.useMemo)(()=>new URLSearchParams(window.location.search).get(`job`),[]),q=(0,B.useRef)(null);(0,B.useEffect)(()=>{v!==null&&q.current!==null&&q.current.scrollIntoView({block:`center`})},[v]);let J=(0,B.useMemo)(()=>new Intl.DateTimeFormat(_(),{dateStyle:`medium`,timeStyle:`short`}),[]),Y=async(e,t,n)=>{et(e);try{await t(),h.success(n),await K()}catch(e){h.toast({variant:`error`,title:ae({code:$(e)})})}finally{et(null)}},X=(0,B.useRef)(0),Z=(0,B.useRef)(0),un=async(e,t)=>{if(t.id===null)return;let r=++X.current;A({name:t.name??t.id,entries:null});try{let i=await n({instanceName:e,jobId:t.id,limit:20});if(r!==X.current)return;A({name:t.name??t.id,entries:i})}catch(e){if(r!==X.current)return;A(null),h.toast({variant:`error`,title:ae({code:$(e)})})}},pn=async(e,n)=>{if(n.id===null)return;let r=++Z.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%Q.days===0?(s=String(e/Q.days),c=`days`):e%Q.hours===0?(s=String(e/Q.hours),c=`hours`):(s=String(Math.max(1,Math.round(e/Q.minutes))),c=`minutes`))}if(r!==Z.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!==Z.current)return;L(null),h.toast({variant:`error`,title:ae({code:$(e)})})}},mn=async()=>{if(j===null)return;let e={};if(j.nameDirty&&j.name.trim()===``||j.messageDirty&&j.hasMessage&&j.message.trim()===``){h.toast({variant:`error`,title:Ke()});return}if(j.nameDirty&&j.name.trim()!==``&&(e.name=j.name.trim()),j.scheduleDirty){if(j.scheduleKind===`cron`&&j.cronExpr.trim()!==``)e.schedule={kind:`cron`,expr:j.cronExpr.trim(),...j.tz.trim()===``?{}:{tz:j.tz.trim()}};else if(j.scheduleKind===`every`){let t=Number(j.everyValue);Number.isFinite(t)&&t>=1&&(e.schedule={kind:`every`,everyMs:Math.round(t*Q[j.everyUnit])})}else if(j.scheduleKind===`at`&&j.at!==``){let t=Date.parse(j.at);Number.isFinite(t)&&(e.schedule={kind:`at`,at:new Date(t).toISOString()})}}if(j.scheduleDirty&&e.schedule===void 0){h.toast({variant:`error`,title:Be()});return}if(j.messageDirty&&j.hasMessage&&j.message.trim()!==``&&(e.message=j.message.trim()),Object.keys(e).length===0){L(null);return}let t=Z.current;Kt(!0);try{await r({instanceName:j.instanceName,jobId:j.jobId,patch:e}),h.success(l()),t===Z.current&&L(null),await K()}catch(e){h.toast({variant:`error`,title:ae({code:$(e)})})}finally{Kt(!1)}},hn=v?.reduce((e,t)=>e+t.jobs.length,0)??0;return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`div`,{style:{display:`flex`,alignItems:`flex-start`,gap:8,marginBottom:12},children:[(0,V.jsx)(`p`,{className:`oc-admin__hint`,style:{flex:1,margin:0},children:Ae()}),(0,V.jsxs)(`div`,{className:`oc-sched__viewtoggle`,role:`group`,"aria-label":he(),children:[(0,V.jsx)(C,{variant:U===`list`?`secondary`:`ghost`,size:`icon-sm`,"aria-label":g(),title:g(),"aria-pressed":U===`list`,onClick:()=>Qt(`list`),children:(0,V.jsx)(lt,{})}),(0,V.jsx)(C,{variant:U===`calendar`?`secondary`:`ghost`,size:`icon-sm`,"aria-label":Je(),title:Je(),"aria-pressed":U===`calendar`,onClick:()=>Qt(`calendar`),children:(0,V.jsx)(Jt,{})})]}),(0,V.jsxs)(C,{variant:`ghost`,size:`sm`,onClick:()=>void K(),disabled:fe,style:{display:`inline-flex`,alignItems:`center`,gap:4},children:[(0,V.jsx)(yt,{size:14,"aria-hidden":!0}),ze()]})]}),v!==null&&hn>0?(0,V.jsxs)(Bt,{q:z.q,onQChange:e=>H(t=>({...t,q:e})),searchPlaceholder:Re(),onReset:()=>H(Ut),canReset:Gt(z),children:[(0,V.jsxs)(M,{value:z.state,onValueChange:e=>H(t=>({...t,state:e})),children:[(0,V.jsx)(N,{size:`sm`,className:`w-40`,children:(0,V.jsx)(T,{})}),(0,V.jsxs)(P,{children:[(0,V.jsx)(E,{value:`all`,children:Ce()}),(0,V.jsx)(E,{value:`active`,children:$e()}),(0,V.jsx)(E,{value:`paused`,children:He()}),(0,V.jsx)(E,{value:`auto-disabled`,children:Ee()})]})]}),(0,V.jsxs)(M,{value:z.result,onValueChange:e=>H(t=>({...t,result:e})),children:[(0,V.jsx)(N,{size:`sm`,className:`w-40`,children:(0,V.jsx)(T,{})}),(0,V.jsxs)(P,{children:[(0,V.jsx)(E,{value:`all`,children:Qe()}),(0,V.jsx)(E,{value:`ok`,children:Ve()}),(0,V.jsx)(E,{value:`error`,children:Oe()}),(0,V.jsx)(E,{value:`running`,children:Te()}),(0,V.jsx)(E,{value:`none`,children:nt()})]})]})]}):null,v===null?(0,V.jsx)(`p`,{className:`oc-admin__hint`,"aria-busy":fe,children:b?Ge():Pe()}):U===`calendar`?(0,V.jsxs)(V.Fragment,{children:[b?(0,V.jsx)(`p`,{className:`oc-admin__hint`,children:Ge()}):null,v.length===0?(0,V.jsx)(`p`,{className:`oc-admin__hint`,children:De()}):(0,V.jsx)(rn,{events:cn.events,mode:$t,cursor:W,onModeChange:en,onCursorChange:an,onEventClick:G,footnote:o()})]}):(0,V.jsxs)(V.Fragment,{children:[b?(0,V.jsx)(`p`,{className:`oc-admin__hint`,children:Ge()}):null,v.length===0?(0,V.jsx)(`p`,{className:`oc-admin__hint`,children:De()}):null,v.map(e=>{let t=e.jobs.filter(e=>Vt(e,z)),n=Gt(z)&&e.jobs.length>0&&t.length===0;return(0,V.jsxs)(`section`,{style:{marginBottom:20},children:[v.length>1||e.error||!e.supported?(0,V.jsxs)(`h3`,{style:{display:`flex`,alignItems:`center`,gap:8,fontSize:`0.85rem`,fontWeight:600,margin:`0 0 6px`},children:[e.instanceName,(0,V.jsx)(w,{variant:`outline`,children:e.kind})]}):null,e.supported?e.error?(0,V.jsx)(`p`,{className:`oc-admin__hint`,children:tt({code:e.error})}):e.jobs.length===0?(0,V.jsx)(`p`,{className:`oc-admin__hint`,children:Le()}):n?(0,V.jsx)(`p`,{className:`oc-admin__hint`,children:We()}):(0,V.jsxs)(zt,{children:[(0,V.jsx)(It,{children:(0,V.jsxs)(Rt,{children:[(0,V.jsx)(F,{children:Se()}),(0,V.jsx)(F,{children:Xe()}),(0,V.jsx)(F,{children:Ue()}),(0,V.jsx)(F,{children:ye()}),(0,V.jsx)(F,{children:Ne()}),(0,V.jsx)(F,{children:Me()}),(0,V.jsx)(F,{children:i()})]})}),(0,V.jsx)(Lt,{children:t.map((t,n)=>{let i=`${e.instanceName}:${t.id??n}`,o=x===i,s=e.manageSupported,c=e.kind===`openclaw`&&s;return(0,V.jsxs)(Rt,{ref:t.id!==null&&t.id===ln?q:void 0,"data-state":t.id!==null&&t.id===ln?`selected`:void 0,children:[(0,V.jsx)(I,{className:`font-medium`,style:{maxWidth:280,overflow:`hidden`,textOverflow:`ellipsis`},title:t.name??void 0,children:t.name??Ye()}),(0,V.jsx)(I,{children:(0,V.jsx)(w,{variant:`secondary`,children:t.agentId})}),(0,V.jsxs)(I,{className:`whitespace-nowrap`,children:[(0,V.jsx)(`span`,{style:{fontFamily:`var(--font-mono, monospace)`},children:t.schedule??`—`}),(()=>{let e=wt(t.schedule),n=e===null?null:Ft(e);return n===null?null:(0,V.jsx)(`span`,{className:`text-muted-foreground`,style:{display:`block`,fontSize:`0.78rem`},children:n})})()]}),(0,V.jsx)(I,{className:`whitespace-nowrap text-muted-foreground`,children:t.nextRunAtMs===null?`—`:J.format(t.nextRunAtMs)}),(0,V.jsx)(I,{children:Wt(t)===`auto-disabled`?(0,V.jsx)(w,{variant:`destructive`,title:`${t.autoDisabledReason??``}${t.autoDisabledAtMs===null?``:` · ${J.format(t.autoDisabledAtMs)}`}`,children:Ee()}):Wt(t)===`active`?(0,V.jsx)(w,{variant:`secondary`,children:$e()}):Wt(t)===`paused`?(0,V.jsx)(w,{variant:`outline`,children:He()}):(0,V.jsx)(`span`,{className:`text-muted-foreground`,children:`—`})}),(0,V.jsxs)(I,{children:[(0,V.jsx)(fn,{status:t.lastRunStatus}),t.lastDelivered===!1?(0,V.jsx)(w,{variant:`destructive`,title:t.lastDeliveryError??p(),children:qe()}):null]}),(0,V.jsx)(I,{className:`whitespace-nowrap`,children:t.id===null?(0,V.jsx)(`span`,{className:`text-muted-foreground`,children:`—`}):o?(0,V.jsx)(bt,{size:14,className:`oc-actrow__spin`,"aria-hidden":!0}):(0,V.jsxs)(`span`,{className:`oc-cronactions`,children:[c?(0,V.jsx)(C,{variant:`ghost`,size:`icon-sm`,title:re(),"aria-label":re(),disabled:x!==null,onClick:()=>void Y(i,async()=>{let n=await m({instanceName:e.instanceName,jobId:t.id});if(n.ran!==!0&&n.runId===null)throw{data:{code:n.reason??`run_not_started`}}},u()),children:(0,V.jsx)(Nt,{size:14,"aria-hidden":!0})}):null,c&&t.enabled!==null?(0,V.jsx)(C,{variant:`ghost`,size:`icon-sm`,title:R(t)===`pause`?ne():Fe(),"aria-label":R(t)===`pause`?ne():Fe(),disabled:x!==null,onClick:()=>void Y(i,()=>r({instanceName:e.instanceName,jobId:t.id,patch:{enabled:R(t)===`resume`}}),R(t)===`pause`?f():ue()),children:R(t)===`pause`?(0,V.jsx)(_t,{size:14,"aria-hidden":!0}):(0,V.jsx)(Ct,{size:14,"aria-hidden":!0})}):null,c?(0,V.jsx)(C,{variant:`ghost`,size:`icon-sm`,title:Ie(),"aria-label":Ie(),disabled:x!==null,onClick:()=>void pn(e.instanceName,t),children:(0,V.jsx)(Dt,{size:14,"aria-hidden":!0})}):null,c?(0,V.jsx)(C,{variant:`ghost`,size:`icon-sm`,title:ie(),"aria-label":ie(),disabled:x!==null,onClick:()=>void un(e.instanceName,t),children:(0,V.jsx)(Yt,{size:14,"aria-hidden":!0})}):null,s?(0,V.jsx)(C,{variant:`ghost`,size:`icon-sm`,title:a(),"aria-label":a(),disabled:x!==null,onClick:()=>O({instanceName:e.instanceName,jobId:t.id,name:t.name??t.id}),children:(0,V.jsx)(dt,{size:14,"aria-hidden":!0})}):null]})})]},t.id??`${e.instanceName}-${n}`)})})]}):(0,V.jsx)(`p`,{className:`oc-admin__hint`,children:we()})]},e.instanceName)}),hn>0?(0,V.jsx)(`p`,{className:`oc-admin__hint`,style:{marginTop:4},children:Ze()}):null]}),(0,V.jsx)(ft,{open:D!==null,onOpenChange:e=>{e||O(null)},children:(0,V.jsxs)(Et,{children:[(0,V.jsxs)(xt,{children:[(0,V.jsx)(Mt,{children:c()}),(0,V.jsx)(kt,{children:ce({name:D?.name??``})})]}),(0,V.jsxs)(gt,{children:[(0,V.jsx)(vt,{children:st()}),(0,V.jsx)(Ot,{onClick:()=>{let e=D;O(null),e!==null&&Y(`${e.instanceName}:${e.jobId}`,()=>d({instanceName:e.instanceName,jobId:e.jobId}),at())},children:xe()})]})]})}),(0,V.jsx)(pt,{open:k!==null,onOpenChange:e=>{e||(X.current++,A(null))},children:(0,V.jsxs)(Pt,{style:{maxWidth:640},children:[(0,V.jsx)(mt,{children:(0,V.jsx)(St,{children:ee({name:k?.name??``})})}),k?.entries===null?(0,V.jsx)(`p`,{className:`oc-admin__hint`,children:Pe()}):k!==null&&k.entries.length===0?(0,V.jsx)(`p`,{className:`oc-admin__hint`,children:le()}):k===null?null:(0,V.jsx)(`div`,{className:`oc-cronpanel__runs`,style:{maxHeight:420,overflowY:`auto`},children:k.entries.map((e,t)=>(0,V.jsxs)(`div`,{className:`oc-cronpanel__run`,children:[(0,V.jsxs)(`div`,{className:`oc-cronpanel__run-head`,children:[(0,V.jsx)(fn,{status:e.status}),(0,V.jsx)(`span`,{children:typeof(e.runAtMs??e.ts)==`number`?J.format(e.runAtMs??e.ts):`—`}),typeof e.durationMs==`number`?(0,V.jsxs)(`span`,{className:`oc-cronpanel__run-dur`,children:[Math.round(e.durationMs/1e3),`s`]}):null]}),e.summary===null?null:(0,V.jsx)(`div`,{className:`oc-cronpanel__run-summary`,children:e.summary}),e.error===null?null:(0,V.jsx)(`div`,{className:`oc-cronpanel__run-error`,children:e.error}),e.delivered===!1?(0,V.jsxs)(`div`,{className:`oc-cronpanel__run-undelivered`,children:[ve({channel:e.deliveryChannel??`—`}),e.deliveryError===null?null:(0,V.jsx)(`span`,{className:`oc-cronpanel__plain`,children:e.deliveryError})]}):null]},t))})]})}),(0,V.jsx)(pt,{open:j!==null,onOpenChange:e=>{e||(Z.current++,L(null))},children:(0,V.jsxs)(Pt,{className:`oc-cronedit`,children:[(0,V.jsxs)(mt,{children:[(0,V.jsx)(St,{children:it()}),(0,V.jsx)(Tt,{children:s()})]}),j===null?null:j.loading?(0,V.jsx)(`p`,{className:`oc-admin__hint`,children:Pe()}):(0,V.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:12},children:[(0,V.jsxs)(`label`,{style:{display:`flex`,flexDirection:`column`,gap:4},children:[(0,V.jsx)(`span`,{className:`oc-admin__hint`,style:{margin:0},children:Se()}),(0,V.jsx)(ut,{value:j.name,maxLength:200,onChange:e=>L({...j,name:e.target.value,nameDirty:!0})})]}),(0,V.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:4},children:[(0,V.jsx)(`span`,{className:`oc-admin__hint`,style:{margin:0},children:se()}),(0,V.jsxs)(M,{value:j.scheduleKind,onValueChange:e=>L({...j,scheduleKind:e,scheduleDirty:!0}),children:[(0,V.jsx)(N,{children:(0,V.jsx)(T,{})}),(0,V.jsxs)(P,{children:[(0,V.jsx)(E,{value:`cron`,children:ot()}),(0,V.jsx)(E,{value:`every`,children:be()}),(0,V.jsx)(E,{value:`at`,children:ct()})]})]}),j.scheduleKind===`cron`?(0,V.jsxs)(`div`,{style:{display:`flex`,gap:8},children:[(0,V.jsx)(ut,{value:j.cronExpr,onChange:e=>L({...j,cronExpr:e.target.value,scheduleDirty:!0}),placeholder:`30 9 * * *`,style:{fontFamily:`var(--font-mono, monospace)`}}),(0,V.jsx)(qt,{value:j.tz,onChange:e=>L({...j,tz:e,scheduleDirty:!0}),fallbackTz:te??void 0})]}):j.scheduleKind===`every`?(0,V.jsxs)(`div`,{style:{display:`flex`,gap:8},children:[(0,V.jsx)(ut,{type:`number`,min:1,value:j.everyValue,onChange:e=>L({...j,everyValue:e.target.value,scheduleDirty:!0}),style:{maxWidth:120}}),(0,V.jsxs)(M,{value:j.everyUnit,onValueChange:e=>L({...j,everyUnit:e,scheduleDirty:!0}),children:[(0,V.jsx)(N,{style:{maxWidth:160},children:(0,V.jsx)(T,{})}),(0,V.jsxs)(P,{children:[(0,V.jsx)(E,{value:`minutes`,children:rt()}),(0,V.jsx)(E,{value:`hours`,children:_e()}),(0,V.jsx)(E,{value:`days`,children:ke()})]})]})]}):(0,V.jsx)(Xt,{value:j.at,onChange:e=>L({...j,at:e,scheduleDirty:!0})})]}),j.hasMessage?(0,V.jsxs)(`label`,{style:{display:`flex`,flexDirection:`column`,gap:4},children:[(0,V.jsx)(`span`,{className:`oc-admin__hint`,style:{margin:0},children:oe()}),(0,V.jsx)(`textarea`,{className:`oc-cronedit__textarea`,rows:4,value:j.message,onChange:e=>L({...j,message:e.target.value,messageDirty:!0})})]}):null]}),(0,V.jsxs)(ht,{children:[(0,V.jsx)(C,{variant:`ghost`,onClick:()=>L(null),children:st()}),(0,V.jsxs)(C,{onClick:()=>void mn(),disabled:j===null||j.loading||Ht,children:[Ht?(0,V.jsx)(bt,{size:14,className:`oc-actrow__spin`,"aria-hidden":!0}):null,je()]})]})]})})]})}export{pn as ScheduledTab};
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$K as r,AK as i,Aq as a,BK as o,CK as s,Cq as c,DK as l,Dq as u,E as d,EK as ee,Eq as f,Fq as p,GK as m,HK as h,JK as g,KK as te,Mq as ne,NY as _,Nq as re,OK as ie,Oq as ae,Pq as oe,QK as v,RY as y,SK as se,Sq as ce,TK as le,Tq as ue,UK as de,VK as fe,VY as pe,WK as me,XK as b,YK as he,ZK as ge,_K as _e,_q as ve,aJ as ye,bK as be,bq as xe,cJ as Se,cq as Ce,dJ as we,dq as Te,eJ as Ee,eq as x,fJ as De,fq as Oe,gK as ke,hJ as Ae,hK as je,hq as Me,iJ as Ne,jY as Pe,jq as Fe,kK as Ie,lJ as Le,lq as Re,mJ as ze,mK as Be,mq as Ve,nJ as He,oJ as Ue,oq as We,pJ as Ge,pK as Ke,pq as qe,qK as Je,rJ as Ye,sJ as Xe,sK as Ze,sq as Qe,t as S,tJ as $e,tq as et,uJ as tt,uq as nt,vK as rt,wK as it,wq as at,xK as ot,xq as st,yK as ct}from"./api-DcB3BxUc.js";import{t as lt}from"./list-CKshqcfm.js";import{t as C}from"./button-DgaBsJDX.js";import{$t as ut,An as dt,Bt as ft,Ct as pt,Dt as mt,Et as ht,Gt as gt,Hn as _t,Ht as vt,In as yt,Jn as bt,Jt as w,Kt as xt,Ot as St,Rn as Ct,Rt as wt,St as T,Tt,Ut as Et,Vn as Dt,Vt as Ot,Wt as kt,Yt as At,bt as E,cn as D,cr as O,ft as jt,on as k,qt as Mt,sn as A,sr as j,vt as M,wn as Nt,wt as Pt,xt as N,yt as P,zt as Ft}from"./index-Ds-ybIOh.js";import{a as It,i as F,n as Lt,o as Rt,r as I,t as zt}from"./table-A3AeBsY1.js";import{t as Bt}from"./FilterBar-B0W1nP3i.js";/* empty css */import{a as Vt,c as L,i as R,l as Ht,n as Ut,o as Wt,r as Gt,s as Kt,t as qt,u as z}from"./TimezoneCombobox-BkDGMdB2.js";var Jt=d(`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`}]]),Yt=d(`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`}]]),B=t(e(),1),V=n();function H(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 Xt({value:e,onChange:t}){let n=Ht(e),i=(0,B.useMemo)(()=>new Date,[]),[a,o]=(0,B.useState)(()=>({year:n?.year??i.getFullYear(),month:n?.month??i.getMonth()})),[s,c]=(0,B.useState)(!1),l=(0,B.useMemo)(()=>H(_()),[]),u=(0,B.useMemo)(()=>new Intl.DateTimeFormat(_(),{month:`long`,year:`numeric`}),[]),d=(0,B.useMemo)(()=>new Intl.DateTimeFormat(_(),{dateStyle:`medium`,timeStyle:`short`}),[]),ee=L(a.year,a.month),f=n?.hour??9,p=n?.minute??0,m=(e,n,r,i,a)=>t(z(e,n,r,i,a)),h=(e,t,n)=>{o({year:e,month:t}),m(e,t,n,f,p)},g=e=>{let t=new Date(a.year,a.month+e,1);o({year:t.getFullYear(),month:t.getMonth()})},te=n===null?x():d.format(new Date(n.year,n.month,n.day,n.hour,n.minute));return(0,V.jsxs)(k,{modal:!0,open:s,onOpenChange:c,children:[(0,V.jsx)(D,{asChild:!0,children:(0,V.jsxs)(`button`,{type:`button`,className:`oc-dtp__trigger`,"aria-label":et(),children:[(0,V.jsx)(Jt,{size:14,"aria-hidden":!0,className:`oc-dtp__icon`}),(0,V.jsx)(`span`,{className:n===null?`oc-dtp__placeholder`:void 0,children:te})]})}),(0,V.jsxs)(A,{align:`start`,className:`oc-dtp__pop`,children:[(0,V.jsxs)(`div`,{className:`oc-dtp__head`,children:[(0,V.jsx)(`button`,{type:`button`,className:`oc-dtp__nav`,"aria-label":r(),onClick:()=>g(-1),children:(0,V.jsx)(O,{size:15,"aria-hidden":!0})}),(0,V.jsx)(`span`,{className:`oc-dtp__month`,children:u.format(new Date(a.year,a.month,1))}),(0,V.jsx)(`button`,{type:`button`,className:`oc-dtp__nav`,"aria-label":v(),onClick:()=>g(1),children:(0,V.jsx)(j,{size:15,"aria-hidden":!0})})]}),(0,V.jsxs)(`div`,{className:`oc-dtp__grid`,children:[l.map((e,t)=>(0,V.jsx)(`span`,{className:`oc-dtp__wd`,children:e},t)),ee.map((e,t)=>{let r=n!==null&&n.year===e.year&&n.month===e.month&&n.day===e.day,a=i.getFullYear()===e.year&&i.getMonth()===e.month&&i.getDate()===e.day;return(0,V.jsx)(`button`,{type:`button`,className:`oc-dtp__day`+(e.inMonth?``:` oc-dtp__day--out`)+(r?` oc-dtp__day--sel`:``)+(a&&!r?` oc-dtp__day--today`:``),onClick:()=>h(e.year,e.month,e.day),children:e.day},t)})]}),(0,V.jsxs)(`div`,{className:`oc-dtp__time`,children:[(0,V.jsxs)(M,{value:String(f),onValueChange:e=>m(a.year,a.month,n?.day??i.getDate(),Number(e),p),children:[(0,V.jsx)(N,{size:`sm`,"aria-label":ge(),children:(0,V.jsx)(T,{})}),(0,V.jsx)(P,{className:`oc-dtp__timeopts`,children:Array.from({length:24},(e,t)=>(0,V.jsx)(E,{value:String(t),children:String(t).padStart(2,`0`)},t))})]}),(0,V.jsx)(`span`,{className:`oc-dtp__colon`,children:`:`}),(0,V.jsxs)(M,{value:String(p),onValueChange:e=>m(a.year,a.month,n?.day??i.getDate(),f,Number(e)),children:[(0,V.jsx)(N,{size:`sm`,"aria-label":b(),children:(0,V.jsx)(T,{})}),(0,V.jsx)(P,{className:`oc-dtp__timeopts`,children:Array.from({length:60},(e,t)=>(0,V.jsx)(E,{value:String(t),children:String(t).padStart(2,`0`)},t))})]})]})]})]})}function U(e){let t=new Date(e),n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())}`}function Zt(e,t,n){let r=e=>String(e).padStart(2,`0`);return`${e}-${r(t+1)}-${r(n)}`}function Qt(e){let t=new Map;for(let n of e){let e=U(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 $t(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(Zt(t,n,a));i!==void 0&&i.length>0&&r.set(a,i.length)}return r}function en(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 tn(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 nn(e){return{startMs:new Date(e,0,1).getTime(),endMs:new Date(e+1,0,1).getTime()}}var W=3;function rn({events:e,mode:t,cursor:n,onModeChange:r,onCursorChange:i,onEventClick:a,footnote:o}){let s=_(),c=(0,B.useMemo)(()=>Qt(e),[e]),l=(0,B.useMemo)(()=>en(s),[s]),u=(0,B.useMemo)(()=>new Intl.DateTimeFormat(s,{month:`long`,year:`numeric`}),[s]),d=(0,B.useMemo)(()=>new Intl.DateTimeFormat(s,{month:`long`}),[s]),ee=(0,B.useMemo)(()=>new Intl.DateTimeFormat(s,{hour:`2-digit`,minute:`2-digit`}),[s]),f=new Date,p=e=>{if(t===`year`){i({year:n.year+e,month:n.month});return}let r=new Date(n.year,n.month+e,1);i({year:r.getFullYear(),month:r.getMonth()})},g=t===`year`?String(n.year):u.format(new Date(n.year,n.month,1));return(0,V.jsxs)(`div`,{className:`oc-cal`,children:[(0,V.jsxs)(`div`,{className:`oc-cal__head`,children:[(0,V.jsxs)(`div`,{className:`oc-cal__nav`,children:[(0,V.jsx)(C,{variant:`ghost`,size:`icon-sm`,"aria-label":de(),onClick:()=>p(-1),children:(0,V.jsx)(O,{})}),(0,V.jsx)(C,{variant:`ghost`,size:`icon-sm`,"aria-label":h(),onClick:()=>p(1),children:(0,V.jsx)(j,{})}),(0,V.jsx)(C,{variant:`ghost`,size:`sm`,onClick:()=>i({year:f.getFullYear(),month:f.getMonth()}),children:me()})]}),(0,V.jsx)(`span`,{className:`oc-cal__title`,children:g}),(0,V.jsxs)(`div`,{className:`oc-cal__modes`,role:`group`,children:[(0,V.jsx)(C,{variant:t===`month`?`secondary`:`ghost`,size:`sm`,"aria-pressed":t===`month`,onClick:()=>r(`month`),children:te()}),(0,V.jsx)(C,{variant:t===`year`?`secondary`:`ghost`,size:`sm`,"aria-pressed":t===`year`,onClick:()=>r(`year`),children:m()})]})]}),t===`month`?(0,V.jsx)(an,{cursor:n,byDay:c,weekdays:l,timeFmt:ee,now:f,onEventClick:a}):(0,V.jsx)(on,{year:n.year,byDay:c,monthShortFmt:d,now:f,onOpenMonth:e=>{i({year:n.year,month:e}),r(`month`)}}),o?(0,V.jsx)(`p`,{className:`oc-cal__footnote`,children:o}):null]})}function an({cursor:e,byDay:t,weekdays:n,timeFmt:r,now:i,onEventClick:a}){let o=L(e.year,e.month);return(0,V.jsxs)(`div`,{className:`oc-cal__month`,children:[n.map((e,t)=>(0,V.jsx)(`span`,{className:`oc-cal__wd`,children:e},t)),o.map((e,n)=>{let o=t.get(Zt(e.year,e.month,e.day))??[],s=i.getFullYear()===e.year&&i.getMonth()===e.month&&i.getDate()===e.day;return(0,V.jsxs)(`div`,{className:`oc-cal__day`+(e.inMonth?``:` oc-cal__day--out`)+(s?` oc-cal__day--today`:``),children:[(0,V.jsx)(`span`,{className:`oc-cal__daynum`,children:e.day}),o.slice(0,W).map(e=>(0,V.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,V.jsx)(`span`,{className:`oc-cal__evdot`,"aria-hidden":!0}),(0,V.jsx)(`span`,{className:`oc-cal__evtime`,children:r.format(e.atMs)}),(0,V.jsx)(`span`,{className:`oc-cal__evtitle`,children:e.title})]},e.id)),o.length>W?(0,V.jsx)(`span`,{className:`oc-cal__more`,children:fe({count:o.length-W})}):null]},n)})]})}function on({year:e,byDay:t,monthShortFmt:n,now:r,onOpenMonth:i}){return(0,V.jsx)(`div`,{className:`oc-cal__year`,children:Array.from({length:12},(a,o)=>{let s=$t(t,e,o),c=L(e,o);return(0,V.jsxs)(`button`,{type:`button`,className:`oc-cal__mini`,onClick:()=>i(o),children:[(0,V.jsx)(`span`,{className:`oc-cal__mininame`,children:n.format(new Date(e,o,1))}),(0,V.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,V.jsx)(`span`,{className:`oc-cal__minidot`+(e.inMonth?``:` is-out`)+(n===1?` has-one`:``)+(n>1?` has-many`:``)+(i?` is-today`:``)},t)})})]},o)})})}var sn={h:36e5,min:6e4,s:1e3,ms:1};function cn(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])*sn[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 G(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 K(e){let t=e.trim().split(/\s+/);if(t.length!==5)return null;let n=G(t[0],0,59),r=G(t[1],0,23),i=G(t[2],1,31),a=G(t[3],1,12),o=G(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 ln=new Map;function q(e){let t=ln.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 ln.set(e,n),n}function J(e,t){if(t!==null){let n=q(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 Y(e,t,n,r,i,a){if(a===null||q(a)===null)return new Date(e,t,n,r,i).getTime();let o=Date.UTC(e,t,n,r,i),s=e=>{let t=J(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 X(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=K(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=J(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=Y(s.y,s.mo,s.d,o,c,e.tz);t>=n&&t<r&&(a(t,!1),i++)}}o=Y(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 Z=`crons`;function un(e,t){return`${e}\u0000${t}`}function dn(e,t,n){let r=[],i=new Map;for(let a of e){let{job:e}=a;if(e.id===null)continue;let o=un(a.instanceName,e.id);i.set(o,a);let s=Wt(e)!==`active`,c=X(s?null:cn(e.schedule),e.nextRunAtMs,t,n);for(let t of c)r.push({id:`${o}:${t.atMs}`,sourceId:Z,itemId:o,atMs:t.atMs,title:e.name??e.id,muted:s,exact:t.exact})}return{events:r,byItemId:i}}var Q={minutes:6e4,hours:36e5,days:864e5};function $(e){return e?.data?.code??`unknown`}function fn({status:e}){switch(Kt(e)){case`ok`:return(0,V.jsx)(w,{variant:`secondary`,children:Ve()});case`error`:return(0,V.jsx)(w,{variant:`destructive`,children:Oe()});case`running`:return(0,V.jsx)(w,{variant:`outline`,children:Te()});case`other`:return(0,V.jsx)(w,{variant:`outline`,children:e});case`none`:return(0,V.jsx)(`span`,{className:`text-muted-foreground`,children:`—`})}}function pn(){let e=y(S.scheduled.listMyCrons),t=y(S.scheduled.getCronDetail),n=y(S.scheduled.listCronRuns),r=y(S.scheduled.updateCron),d=y(S.scheduled.removeCron),m=y(S.scheduled.runCronNow),h=At(),te=pe(S.me.getMe,{host:jt})?.timezone,[v,de]=(0,B.useState)(null),[fe,me]=(0,B.useState)(!1),[b,ge]=(0,B.useState)(!1),[x,et]=(0,B.useState)(null),[D,O]=(0,B.useState)(null),[k,A]=(0,B.useState)(null),[j,L]=(0,B.useState)(null),[Ht,Kt]=(0,B.useState)(!1),[z,H]=(0,B.useState)(Ut),[U,Zt]=(0,B.useState)(()=>new URLSearchParams(window.location.search).get(`job`)===null&&localStorage.getItem(`oc.sched.view`)===`calendar`?`calendar`:`list`),Qt=e=>{localStorage.setItem(`oc.sched.view`,e),Zt(e)},[$t,en]=(0,B.useState)(`month`),[W,an]=(0,B.useState)(()=>{let e=new Date;return{year:e.getFullYear(),month:e.getMonth()}}),on=(0,B.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,z)&&e.push({instanceName:t.instanceName,canEdit:n,job:r})}return e},[v,z]),sn=(0,B.useMemo)(()=>$t===`year`?nn(W.year):tn(W.year,W.month),[$t,W]),cn=(0,B.useMemo)(()=>dn(on,sn.startMs,sn.endMs),[on,sn]),G=e=>{let t=cn.byItemId.get(e.itemId);t===void 0||!t.canEdit||t.job.id===null||pn(t.instanceName,t.job)},K=(0,B.useCallback)(async()=>{me(!0),ge(!1);try{de(await e({}))}catch{ge(!0)}finally{me(!1)}},[e]);(0,B.useEffect)(()=>{K()},[K]);let ln=(0,B.useMemo)(()=>new URLSearchParams(window.location.search).get(`job`),[]),q=(0,B.useRef)(null);(0,B.useEffect)(()=>{v!==null&&q.current!==null&&q.current.scrollIntoView({block:`center`})},[v]);let J=(0,B.useMemo)(()=>new Intl.DateTimeFormat(_(),{dateStyle:`medium`,timeStyle:`short`}),[]),Y=async(e,t,n)=>{et(e);try{await t(),h.success(n),await K()}catch(e){h.toast({variant:`error`,title:ae({code:$(e)})})}finally{et(null)}},X=(0,B.useRef)(0),Z=(0,B.useRef)(0),un=async(e,t)=>{if(t.id===null)return;let r=++X.current;A({name:t.name??t.id,entries:null});try{let i=await n({instanceName:e,jobId:t.id,limit:20});if(r!==X.current)return;A({name:t.name??t.id,entries:i})}catch(e){if(r!==X.current)return;A(null),h.toast({variant:`error`,title:ae({code:$(e)})})}},pn=async(e,n)=>{if(n.id===null)return;let r=++Z.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%Q.days===0?(s=String(e/Q.days),c=`days`):e%Q.hours===0?(s=String(e/Q.hours),c=`hours`):(s=String(Math.max(1,Math.round(e/Q.minutes))),c=`minutes`))}if(r!==Z.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!==Z.current)return;L(null),h.toast({variant:`error`,title:ae({code:$(e)})})}},mn=async()=>{if(j===null)return;let e={};if(j.nameDirty&&j.name.trim()===``||j.messageDirty&&j.hasMessage&&j.message.trim()===``){h.toast({variant:`error`,title:Ke()});return}if(j.nameDirty&&j.name.trim()!==``&&(e.name=j.name.trim()),j.scheduleDirty){if(j.scheduleKind===`cron`&&j.cronExpr.trim()!==``)e.schedule={kind:`cron`,expr:j.cronExpr.trim(),...j.tz.trim()===``?{}:{tz:j.tz.trim()}};else if(j.scheduleKind===`every`){let t=Number(j.everyValue);Number.isFinite(t)&&t>=1&&(e.schedule={kind:`every`,everyMs:Math.round(t*Q[j.everyUnit])})}else if(j.scheduleKind===`at`&&j.at!==``){let t=Date.parse(j.at);Number.isFinite(t)&&(e.schedule={kind:`at`,at:new Date(t).toISOString()})}}if(j.scheduleDirty&&e.schedule===void 0){h.toast({variant:`error`,title:Be()});return}if(j.messageDirty&&j.hasMessage&&j.message.trim()!==``&&(e.message=j.message.trim()),Object.keys(e).length===0){L(null);return}let t=Z.current;Kt(!0);try{await r({instanceName:j.instanceName,jobId:j.jobId,patch:e}),h.success(l()),t===Z.current&&L(null),await K()}catch(e){h.toast({variant:`error`,title:ae({code:$(e)})})}finally{Kt(!1)}},hn=v?.reduce((e,t)=>e+t.jobs.length,0)??0;return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`div`,{style:{display:`flex`,alignItems:`flex-start`,gap:8,marginBottom:12},children:[(0,V.jsx)(`p`,{className:`oc-admin__hint`,style:{flex:1,margin:0},children:Ae()}),(0,V.jsxs)(`div`,{className:`oc-sched__viewtoggle`,role:`group`,"aria-label":he(),children:[(0,V.jsx)(C,{variant:U===`list`?`secondary`:`ghost`,size:`icon-sm`,"aria-label":g(),title:g(),"aria-pressed":U===`list`,onClick:()=>Qt(`list`),children:(0,V.jsx)(lt,{})}),(0,V.jsx)(C,{variant:U===`calendar`?`secondary`:`ghost`,size:`icon-sm`,"aria-label":Je(),title:Je(),"aria-pressed":U===`calendar`,onClick:()=>Qt(`calendar`),children:(0,V.jsx)(Jt,{})})]}),(0,V.jsxs)(C,{variant:`ghost`,size:`sm`,onClick:()=>void K(),disabled:fe,style:{display:`inline-flex`,alignItems:`center`,gap:4},children:[(0,V.jsx)(yt,{size:14,"aria-hidden":!0}),ze()]})]}),v!==null&&hn>0?(0,V.jsxs)(Bt,{q:z.q,onQChange:e=>H(t=>({...t,q:e})),searchPlaceholder:Re(),onReset:()=>H(Ut),canReset:Gt(z),children:[(0,V.jsxs)(M,{value:z.state,onValueChange:e=>H(t=>({...t,state:e})),children:[(0,V.jsx)(N,{size:`sm`,className:`w-40`,children:(0,V.jsx)(T,{})}),(0,V.jsxs)(P,{children:[(0,V.jsx)(E,{value:`all`,children:Ce()}),(0,V.jsx)(E,{value:`active`,children:$e()}),(0,V.jsx)(E,{value:`paused`,children:He()}),(0,V.jsx)(E,{value:`auto-disabled`,children:Ee()})]})]}),(0,V.jsxs)(M,{value:z.result,onValueChange:e=>H(t=>({...t,result:e})),children:[(0,V.jsx)(N,{size:`sm`,className:`w-40`,children:(0,V.jsx)(T,{})}),(0,V.jsxs)(P,{children:[(0,V.jsx)(E,{value:`all`,children:Qe()}),(0,V.jsx)(E,{value:`ok`,children:Ve()}),(0,V.jsx)(E,{value:`error`,children:Oe()}),(0,V.jsx)(E,{value:`running`,children:Te()}),(0,V.jsx)(E,{value:`none`,children:nt()})]})]})]}):null,v===null?(0,V.jsx)(`p`,{className:`oc-admin__hint`,"aria-busy":fe,children:b?Ge():Pe()}):U===`calendar`?(0,V.jsxs)(V.Fragment,{children:[b?(0,V.jsx)(`p`,{className:`oc-admin__hint`,children:Ge()}):null,v.length===0?(0,V.jsx)(`p`,{className:`oc-admin__hint`,children:De()}):(0,V.jsx)(rn,{events:cn.events,mode:$t,cursor:W,onModeChange:en,onCursorChange:an,onEventClick:G,footnote:o()})]}):(0,V.jsxs)(V.Fragment,{children:[b?(0,V.jsx)(`p`,{className:`oc-admin__hint`,children:Ge()}):null,v.length===0?(0,V.jsx)(`p`,{className:`oc-admin__hint`,children:De()}):null,v.map(e=>{let t=e.jobs.filter(e=>Vt(e,z)),n=Gt(z)&&e.jobs.length>0&&t.length===0;return(0,V.jsxs)(`section`,{style:{marginBottom:20},children:[v.length>1||e.error||!e.supported?(0,V.jsxs)(`h3`,{style:{display:`flex`,alignItems:`center`,gap:8,fontSize:`0.85rem`,fontWeight:600,margin:`0 0 6px`},children:[e.instanceName,(0,V.jsx)(w,{variant:`outline`,children:e.kind})]}):null,e.supported?e.error?(0,V.jsx)(`p`,{className:`oc-admin__hint`,children:tt({code:e.error})}):e.jobs.length===0?(0,V.jsx)(`p`,{className:`oc-admin__hint`,children:Le()}):n?(0,V.jsx)(`p`,{className:`oc-admin__hint`,children:We()}):(0,V.jsxs)(zt,{children:[(0,V.jsx)(It,{children:(0,V.jsxs)(Rt,{children:[(0,V.jsx)(F,{children:Se()}),(0,V.jsx)(F,{children:Xe()}),(0,V.jsx)(F,{children:Ue()}),(0,V.jsx)(F,{children:ye()}),(0,V.jsx)(F,{children:Ne()}),(0,V.jsx)(F,{children:Me()}),(0,V.jsx)(F,{children:i()})]})}),(0,V.jsx)(Lt,{children:t.map((t,n)=>{let i=`${e.instanceName}:${t.id??n}`,o=x===i,s=e.manageSupported,c=e.kind===`openclaw`&&s;return(0,V.jsxs)(Rt,{ref:t.id!==null&&t.id===ln?q:void 0,"data-state":t.id!==null&&t.id===ln?`selected`:void 0,children:[(0,V.jsx)(I,{className:`font-medium`,style:{maxWidth:280,overflow:`hidden`,textOverflow:`ellipsis`},title:t.name??void 0,children:t.name??Ye()}),(0,V.jsx)(I,{children:(0,V.jsx)(w,{variant:`secondary`,children:t.agentId})}),(0,V.jsxs)(I,{className:`whitespace-nowrap`,children:[(0,V.jsx)(`span`,{style:{fontFamily:`var(--font-mono, monospace)`},children:t.schedule??`—`}),(()=>{let e=wt(t.schedule),n=e===null?null:Ft(e);return n===null?null:(0,V.jsx)(`span`,{className:`text-muted-foreground`,style:{display:`block`,fontSize:`0.78rem`},children:n})})()]}),(0,V.jsx)(I,{className:`whitespace-nowrap text-muted-foreground`,children:t.nextRunAtMs===null?`—`:J.format(t.nextRunAtMs)}),(0,V.jsx)(I,{children:Wt(t)===`auto-disabled`?(0,V.jsx)(w,{variant:`destructive`,title:`${t.autoDisabledReason??``}${t.autoDisabledAtMs===null?``:` · ${J.format(t.autoDisabledAtMs)}`}`,children:Ee()}):Wt(t)===`active`?(0,V.jsx)(w,{variant:`secondary`,children:$e()}):Wt(t)===`paused`?(0,V.jsx)(w,{variant:`outline`,children:He()}):(0,V.jsx)(`span`,{className:`text-muted-foreground`,children:`—`})}),(0,V.jsxs)(I,{children:[(0,V.jsx)(fn,{status:t.lastRunStatus}),t.lastDelivered===!1?(0,V.jsx)(w,{variant:`destructive`,title:t.lastDeliveryError??p(),children:qe()}):null]}),(0,V.jsx)(I,{className:`whitespace-nowrap`,children:t.id===null?(0,V.jsx)(`span`,{className:`text-muted-foreground`,children:`—`}):o?(0,V.jsx)(bt,{size:14,className:`oc-actrow__spin`,"aria-hidden":!0}):(0,V.jsxs)(`span`,{className:`oc-cronactions`,children:[c?(0,V.jsx)(C,{variant:`ghost`,size:`icon-sm`,title:re(),"aria-label":re(),disabled:x!==null,onClick:()=>void Y(i,async()=>{let n=await m({instanceName:e.instanceName,jobId:t.id});if(n.ran!==!0&&n.runId===null)throw{data:{code:n.reason??`run_not_started`}}},u()),children:(0,V.jsx)(Nt,{size:14,"aria-hidden":!0})}):null,c&&t.enabled!==null?(0,V.jsx)(C,{variant:`ghost`,size:`icon-sm`,title:R(t)===`pause`?ne():Fe(),"aria-label":R(t)===`pause`?ne():Fe(),disabled:x!==null,onClick:()=>void Y(i,()=>r({instanceName:e.instanceName,jobId:t.id,patch:{enabled:R(t)===`resume`}}),R(t)===`pause`?f():ue()),children:R(t)===`pause`?(0,V.jsx)(_t,{size:14,"aria-hidden":!0}):(0,V.jsx)(Ct,{size:14,"aria-hidden":!0})}):null,c?(0,V.jsx)(C,{variant:`ghost`,size:`icon-sm`,title:Ie(),"aria-label":Ie(),disabled:x!==null,onClick:()=>void pn(e.instanceName,t),children:(0,V.jsx)(Dt,{size:14,"aria-hidden":!0})}):null,c?(0,V.jsx)(C,{variant:`ghost`,size:`icon-sm`,title:ie(),"aria-label":ie(),disabled:x!==null,onClick:()=>void un(e.instanceName,t),children:(0,V.jsx)(Yt,{size:14,"aria-hidden":!0})}):null,s?(0,V.jsx)(C,{variant:`ghost`,size:`icon-sm`,title:a(),"aria-label":a(),disabled:x!==null,onClick:()=>O({instanceName:e.instanceName,jobId:t.id,name:t.name??t.id}),children:(0,V.jsx)(dt,{size:14,"aria-hidden":!0})}):null]})})]},t.id??`${e.instanceName}-${n}`)})})]}):(0,V.jsx)(`p`,{className:`oc-admin__hint`,children:we()})]},e.instanceName)}),hn>0?(0,V.jsx)(`p`,{className:`oc-admin__hint`,style:{marginTop:4},children:Ze()}):null]}),(0,V.jsx)(ft,{open:D!==null,onOpenChange:e=>{e||O(null)},children:(0,V.jsxs)(Et,{children:[(0,V.jsxs)(xt,{children:[(0,V.jsx)(Mt,{children:c()}),(0,V.jsx)(kt,{children:ce({name:D?.name??``})})]}),(0,V.jsxs)(gt,{children:[(0,V.jsx)(vt,{children:st()}),(0,V.jsx)(Ot,{onClick:()=>{let e=D;O(null),e!==null&&Y(`${e.instanceName}:${e.jobId}`,()=>d({instanceName:e.instanceName,jobId:e.jobId}),at())},children:xe()})]})]})}),(0,V.jsx)(pt,{open:k!==null,onOpenChange:e=>{e||(X.current++,A(null))},children:(0,V.jsxs)(Pt,{style:{maxWidth:640},children:[(0,V.jsx)(mt,{children:(0,V.jsx)(St,{children:ee({name:k?.name??``})})}),k?.entries===null?(0,V.jsx)(`p`,{className:`oc-admin__hint`,children:Pe()}):k!==null&&k.entries.length===0?(0,V.jsx)(`p`,{className:`oc-admin__hint`,children:le()}):k===null?null:(0,V.jsx)(`div`,{className:`oc-cronpanel__runs`,style:{maxHeight:420,overflowY:`auto`},children:k.entries.map((e,t)=>(0,V.jsxs)(`div`,{className:`oc-cronpanel__run`,children:[(0,V.jsxs)(`div`,{className:`oc-cronpanel__run-head`,children:[(0,V.jsx)(fn,{status:e.status}),(0,V.jsx)(`span`,{children:typeof(e.runAtMs??e.ts)==`number`?J.format(e.runAtMs??e.ts):`—`}),typeof e.durationMs==`number`?(0,V.jsxs)(`span`,{className:`oc-cronpanel__run-dur`,children:[Math.round(e.durationMs/1e3),`s`]}):null]}),e.summary===null?null:(0,V.jsx)(`div`,{className:`oc-cronpanel__run-summary`,children:e.summary}),e.error===null?null:(0,V.jsx)(`div`,{className:`oc-cronpanel__run-error`,children:e.error}),e.delivered===!1?(0,V.jsxs)(`div`,{className:`oc-cronpanel__run-undelivered`,children:[ve({channel:e.deliveryChannel??`—`}),e.deliveryError===null?null:(0,V.jsx)(`span`,{className:`oc-cronpanel__plain`,children:e.deliveryError})]}):null]},t))})]})}),(0,V.jsx)(pt,{open:j!==null,onOpenChange:e=>{e||(Z.current++,L(null))},children:(0,V.jsxs)(Pt,{className:`oc-cronedit`,children:[(0,V.jsxs)(mt,{children:[(0,V.jsx)(St,{children:it()}),(0,V.jsx)(Tt,{children:s()})]}),j===null?null:j.loading?(0,V.jsx)(`p`,{className:`oc-admin__hint`,children:Pe()}):(0,V.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:12},children:[(0,V.jsxs)(`label`,{style:{display:`flex`,flexDirection:`column`,gap:4},children:[(0,V.jsx)(`span`,{className:`oc-admin__hint`,style:{margin:0},children:Se()}),(0,V.jsx)(ut,{value:j.name,maxLength:200,onChange:e=>L({...j,name:e.target.value,nameDirty:!0})})]}),(0,V.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:4},children:[(0,V.jsx)(`span`,{className:`oc-admin__hint`,style:{margin:0},children:se()}),(0,V.jsxs)(M,{value:j.scheduleKind,onValueChange:e=>L({...j,scheduleKind:e,scheduleDirty:!0}),children:[(0,V.jsx)(N,{children:(0,V.jsx)(T,{})}),(0,V.jsxs)(P,{children:[(0,V.jsx)(E,{value:`cron`,children:ot()}),(0,V.jsx)(E,{value:`every`,children:be()}),(0,V.jsx)(E,{value:`at`,children:ct()})]})]}),j.scheduleKind===`cron`?(0,V.jsxs)(`div`,{style:{display:`flex`,gap:8},children:[(0,V.jsx)(ut,{value:j.cronExpr,onChange:e=>L({...j,cronExpr:e.target.value,scheduleDirty:!0}),placeholder:`30 9 * * *`,style:{fontFamily:`var(--font-mono, monospace)`}}),(0,V.jsx)(qt,{value:j.tz,onChange:e=>L({...j,tz:e,scheduleDirty:!0}),fallbackTz:te??void 0})]}):j.scheduleKind===`every`?(0,V.jsxs)(`div`,{style:{display:`flex`,gap:8},children:[(0,V.jsx)(ut,{type:`number`,min:1,value:j.everyValue,onChange:e=>L({...j,everyValue:e.target.value,scheduleDirty:!0}),style:{maxWidth:120}}),(0,V.jsxs)(M,{value:j.everyUnit,onValueChange:e=>L({...j,everyUnit:e,scheduleDirty:!0}),children:[(0,V.jsx)(N,{style:{maxWidth:160},children:(0,V.jsx)(T,{})}),(0,V.jsxs)(P,{children:[(0,V.jsx)(E,{value:`minutes`,children:rt()}),(0,V.jsx)(E,{value:`hours`,children:_e()}),(0,V.jsx)(E,{value:`days`,children:ke()})]})]})]}):(0,V.jsx)(Xt,{value:j.at,onChange:e=>L({...j,at:e,scheduleDirty:!0})})]}),j.hasMessage?(0,V.jsxs)(`label`,{style:{display:`flex`,flexDirection:`column`,gap:4},children:[(0,V.jsx)(`span`,{className:`oc-admin__hint`,style:{margin:0},children:oe()}),(0,V.jsx)(`textarea`,{className:`oc-cronedit__textarea`,rows:4,value:j.message,onChange:e=>L({...j,message:e.target.value,messageDirty:!0})})]}):null]}),(0,V.jsxs)(ht,{children:[(0,V.jsx)(C,{variant:`ghost`,onClick:()=>L(null),children:st()}),(0,V.jsxs)(C,{onClick:()=>void mn(),disabled:j===null||j.loading||Ht,children:[Ht?(0,V.jsx)(bt,{size:14,className:`oc-actrow__spin`,"aria-hidden":!0}):null,je()]})]})]})})]})}export{pn as ScheduledTab};