@lacneu/atrium 0.77.0 → 0.78.0

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 (38) hide show
  1. package/dist/assets/{AccessTab-BPl6RGWf.js → AccessTab-YOPTfk-I.js} +1 -1
  2. package/dist/assets/{AdvancedFilter-QHL1Jz1Z.js → AdvancedFilter-Bm1TIX9k.js} +1 -1
  3. package/dist/assets/{AgentFilesTab-CjesR_c6.js → AgentFilesTab-DRQkurXm.js} +1 -1
  4. package/dist/assets/{AnomaliesTab-yzNzDsXN.js → AnomaliesTab-Dq2dqog2.js} +1 -1
  5. package/dist/assets/{AuditTab-1rUI2z6b.js → AuditTab-Cntt5whu.js} +1 -1
  6. package/dist/assets/{BridgeTab-COQr-xZD.js → BridgeTab-DzV-2POL.js} +1 -1
  7. package/dist/assets/{ChatDefaultsTab-CM2Yd28v.js → ChatDefaultsTab-C0sMC9lx.js} +1 -1
  8. package/dist/assets/{DataTableShell-CW5udl6V.js → DataTableShell-DWXPn72S.js} +1 -1
  9. package/dist/assets/{DetailChips-Dlt_uEHU.js → DetailChips-D6mdBUOT.js} +1 -1
  10. package/dist/assets/{FeedbacksTab-Uzv7-Dj0.js → FeedbacksTab-CbdS0wvF.js} +1 -1
  11. package/dist/assets/{FieldLabel-Bbe-KIdW.js → FieldLabel-Bww3UDFn.js} +1 -1
  12. package/dist/assets/{FilesTab-fi7x53E6.js → FilesTab-gqJalvPX.js} +1 -1
  13. package/dist/assets/{FilterBar-BO7_dR0d.js → FilterBar-FHDxb3k3.js} +1 -1
  14. package/dist/assets/{GroupsTab-C2ErNAiu.js → GroupsTab-BA8yKOnN.js} +1 -1
  15. package/dist/assets/{InstancesTab-D3PbSRsE.js → InstancesTab-sdopggdY.js} +1 -1
  16. package/dist/assets/{IntegrationsTab-DsvIgPM9.js → IntegrationsTab-BFpswDLB.js} +1 -1
  17. package/dist/assets/{KpiTab-boTUKc3M.js → KpiTab-DwKThxZR.js} +1 -1
  18. package/dist/assets/{PreferencesTab-D1GB1DjD.js → PreferencesTab-C3J_i-eF.js} +1 -1
  19. package/dist/assets/{ProjectPage-BKOn9--c.js → ProjectPage-Dk_aI-j5.js} +1 -1
  20. package/dist/assets/{PromptInjectionsTab-CMynIw-2.js → PromptInjectionsTab-B_mdD-DZ.js} +1 -1
  21. package/dist/assets/{RolesTab-rU1yG45_.js → RolesTab-AEwrbrY4.js} +1 -1
  22. package/dist/assets/{ScheduledTab-D1E65eqQ.js → ScheduledTab-1EVZpEec.js} +1 -1
  23. package/dist/assets/{ServiceAccountsTab-DTW2ImlD.js → ServiceAccountsTab-CGQ1lSPD.js} +1 -1
  24. package/dist/assets/{SubAgentReportsTab-C9t7ObEO.js → SubAgentReportsTab-jYVPpy6r.js} +1 -1
  25. package/dist/assets/{ThemeShowroom-SQKNzsXc.js → ThemeShowroom-Ce00J53a.js} +1 -1
  26. package/dist/assets/{TimeRangePicker-Di0xhZgB.js → TimeRangePicker-BlRNLd96.js} +1 -1
  27. package/dist/assets/{TimezoneCombobox-eEhKbenA.js → TimezoneCombobox-UX7uQX62.js} +1 -1
  28. package/dist/assets/{TracesTab-C_EHq15B.js → TracesTab-h8arGKis.js} +1 -1
  29. package/dist/assets/{UsersTab-Dk5CxK1-.js → UsersTab-CuY3xwoe.js} +1 -1
  30. package/dist/assets/{VoiceTab-CkceCrfE.js → VoiceTab-D-J9M4a1.js} +1 -1
  31. package/dist/assets/{highlighted-body-OFNGDK62-kKNZy35t.js → highlighted-body-OFNGDK62-B8scDgZo.js} +1 -1
  32. package/dist/assets/{index-c5j0e823.js → index-Bc3aF-kJ.js} +33 -33
  33. package/dist/assets/mermaid-GHXKKRXX-BcADHOv7.js +1 -0
  34. package/dist/assets/{pdf-DWeO12dm.js → pdf-DKBRfoBb.js} +1 -1
  35. package/dist/assets/{tabs-Bmd8xvTL.js → tabs-DHs6yOVA.js} +1 -1
  36. package/dist/index.html +1 -1
  37. package/package.json +1 -1
  38. package/dist/assets/mermaid-GHXKKRXX-BZZjoNSF.js +0 -1
@@ -1 +1 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$T as r,AE as i,BE as a,BT as o,CE as s,CT as c,DE as l,DT as u,EE as d,ET as f,FE as p,FT as m,Fs as h,Fz as g,GE as _,GT as v,HE as ee,HT as y,IE as b,IT as x,Is as S,Iz as C,JE as te,JT as w,KE as ne,KT as T,LE as re,LT as E,Ls as ie,ME as ae,MT as oe,NE as se,NM as D,NT as ce,Nz as O,OE as le,OT as ue,PE as de,PM as fe,PT as pe,QT as me,RE as he,RT as ge,Rs as _e,SE as ve,ST as ye,TE as be,TT as xe,UE as Se,UT as Ce,VE as we,VT as Te,WE as Ee,WT as De,XE as Oe,XT as ke,Xb as Ae,YE as je,YT as Me,ZT as Ne,Zb as Pe,_E as Fe,_T as Ie,aE as Le,bE as Re,bT as ze,cE as Be,cT as Ve,ci as He,dE as Ue,dT as We,eE as Ge,fE as Ke,fT as qe,gE as Je,gT as Ye,hE as Xe,hT as Ze,iE as Qe,jE as $e,jT as k,kE as et,kT as tt,lE as nt,lT as rt,mE as it,mT as at,nE as A,oE as j,oi as ot,pE as M,pT as st,qE as ct,qT as lt,rE as ut,sE as dt,sT as ft,si as pt,t as N,tE as mt,uE as ht,uT as gt,vE as _t,vT as vt,wE as yt,wT as bt,xE as xt,xT as St,yE as Ct,yT as wt,zE as Tt,zT as Et}from"./api-Cpjr7qvl.js";import{a as Dt,c as Ot}from"./FieldLabel-Bbe-KIdW.js";import{t as P}from"./button-CbwCr9Pi.js";import{$ as F,Bt as kt,Dt as I,Et as L,Q as R,Rt as At,U as jt,X as z,Z as B,_ as Mt,at as V,et as H,jt as U,nt as W,ot as G,rt as K,tt as q,ut as J,zt as Nt}from"./index-c5j0e823.js";import{t as Pt}from"./DataTableShell-CW5udl6V.js";import{InstanceConfigDialog as Ft}from"./BridgeTab-COQr-xZD.js";var Y=t(e(),1),X=[`conversational`,`documentary`,`summarizer`,`curator`],It=new Set(X),Lt=`conversational`;function Rt(e){let t=new Set((e??[]).filter(e=>It.has(e)));return t.size===0?[Lt]:X.filter(e=>t.has(e))}var Z=n(),Q={name:``,gatewayUrl:``,bridgeUrl:``,displayName:``,kind:`openclaw`,transport:`ws`,gatewayVersion:``,gatewayHttpUrl:``,streamTransport:Dt},zt={openclaw:[`token`,`deviceIdentity`],hermes:[`apiKey`]};function Bt(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??``,streamTransport:e.streamTransport??`reactive`}}function Vt(){let e=C(N.admin.listInstances,{}),t=C(N.agents.listAllInstanceAgents,{}),n=g(N.admin.upsertInstance),r=g(N.admin.deleteInstance),o=I(),[c,u]=(0,Y.useState)(!1),[f,m]=(0,Y.useState)(Q),[h,v]=(0,Y.useState)(null),[y,x]=(0,Y.useState)(null),[S,w]=(0,Y.useState)(null),[T,E]=(0,Y.useState)(null);async function ie(){try{await n({instanceId:T??void 0,name:f.name,gatewayUrl:f.gatewayUrl,bridgeUrl:f.bridgeUrl||void 0,displayName:f.displayName||void 0,kind:f.kind,transport:f.kind===`hermes`?f.transport:void 0,gatewayVersion:f.gatewayVersion||void 0,gatewayHttpUrl:f.gatewayHttpUrl||void 0,streamTransport:f.streamTransport}),m(Q),E(null),u(!1)}catch(e){o.error(te(),e)}}return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`p`,{className:`oc-admin__hint`,children:[ct(),(0,Z.jsx)(`strong`,{children:ne()}),_()]}),(0,Z.jsx)(Pt,{title:Ee(),rows:e,addLabel:Se(),onAdd:()=>{E(null),m(Q),u(!0)},emptyHint:ee(),columns:[{header:we(),cell:e=>e.name,sort:e=>e.name},{header:a(),cell:e=>(0,Z.jsx)(L,{variant:`outline`,children:e.kind??`openclaw`}),sort:e=>e.kind??`openclaw`},{header:Tt(),cell:e=>e.gatewayUrl,sort:e=>e.gatewayUrl},{header:he(),cell:e=>e.displayName??`—`,sort:e=>e.displayName??null},{header:Oe(),cell:e=>{let n=(t?.[e.name]??[]).filter(e=>e.presentInLastOk!==!1&&e.enabled);if(n.length===0)return(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:`—`});let r=t=>e.defaultAgentId===t;return(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:[...n].sort((e,t)=>Number(r(t.agentId))-Number(r(e.agentId))).map(e=>(0,Z.jsxs)(L,{variant:r(e.agentId)?`default`:`outline`,title:r(e.agentId)?Ve():void 0,children:[e.emoji?`${e.emoji} `:``,e.displayName??e.agentId]},e.agentId))})}}],rowActions:e=>[{label:de(),onSelect:()=>{E(e._id),m(Bt(e)),u(!0)}},{label:je(),onSelect:()=>v(e.name)},{label:Ct(),onSelect:()=>w(e)},{label:re(),onSelect:()=>x(e)},{label:b(),variant:`destructive`,onSelect:()=>void r({instanceId:e._id})}],bulkActions:[{label:b(),variant:`destructive`,onSelect:e=>e.forEach(e=>void r({instanceId:e}))}]}),(0,Z.jsx)(Mt,{open:c,onOpenChange:u,title:T?se():p(),description:$e(),canSubmit:!!(f.name&&f.gatewayUrl),onSubmit:ie,submitLabel:i(),children:(0,Z.jsxs)(`div`,{className:`oc-form`,children:[(0,Z.jsxs)($,{label:et(),children:[(0,Z.jsx)(U,{value:f.name,disabled:T!==null,onChange:e=>m({...f,name:e.target.value})}),T?(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:ae()}):null]}),(0,Z.jsx)($,{label:le(),children:(0,Z.jsxs)(z,{value:f.kind,onValueChange:e=>m({...f,kind:e}),children:[(0,Z.jsx)(F,{size:`sm`,className:`w-40`,children:(0,Z.jsx)(H,{})}),(0,Z.jsxs)(B,{children:[(0,Z.jsx)(R,{value:`openclaw`,children:`OpenClaw`}),(0,Z.jsx)(R,{value:`hermes`,children:`Hermes`})]})]})}),f.kind===`hermes`?(0,Z.jsx)($,{label:He(),children:(0,Z.jsxs)(z,{value:f.transport,onValueChange:e=>m({...f,transport:e}),children:[(0,Z.jsx)(F,{size:`sm`,className:`w-56`,children:(0,Z.jsx)(H,{})}),(0,Z.jsxs)(B,{children:[(0,Z.jsx)(R,{value:`ws`,children:pt()}),(0,Z.jsx)(R,{value:`rest`,children:ot()})]})]})}):null,(0,Z.jsx)($,{label:l(),children:(0,Z.jsx)(U,{value:f.gatewayUrl,onChange:e=>m({...f,gatewayUrl:e.target.value})})}),(0,Z.jsx)($,{label:d(),children:(0,Z.jsx)(U,{value:f.bridgeUrl,placeholder:be(),onChange:e=>m({...f,bridgeUrl:e.target.value})})}),(0,Z.jsx)($,{label:yt(),children:(0,Z.jsx)(U,{value:f.displayName,onChange:e=>m({...f,displayName:e.target.value})})}),(0,Z.jsxs)($,{label:Pe(),children:[(0,Z.jsxs)(z,{value:f.streamTransport,onValueChange:e=>m({...f,streamTransport:e}),children:[(0,Z.jsx)(F,{size:`sm`,className:`w-40`,children:(0,Z.jsx)(H,{})}),(0,Z.jsx)(B,{children:Ot.map(e=>(0,Z.jsx)(R,{value:e,children:e},e))})]}),(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:Ae()})]}),(0,Z.jsx)($,{label:s(),children:(0,Z.jsx)(U,{value:f.gatewayVersion,placeholder:ve(),onChange:e=>m({...f,gatewayVersion:e.target.value})})}),(0,Z.jsx)($,{label:xt(),children:(0,Z.jsx)(U,{value:f.gatewayHttpUrl,placeholder:Re(),onChange:e=>m({...f,gatewayHttpUrl:e.target.value})})})]})}),(0,Z.jsx)(Zt,{instanceName:h,open:h!==null,onOpenChange:e=>{e||v(null)}}),y?(0,Z.jsx)(Ft,{instance:y,onClose:()=>x(null)},y._id):null,S?(0,Z.jsx)(Ht,{instance:S,onClose:()=>w(null)},S._id):null]})}function Ht({instance:e,onClose:t}){let n=C(N.instanceSecrets.listInstanceSecretStatus,{}),r=zt[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)(q,{open:!0,onOpenChange:e=>!e&&t(),children:(0,Z.jsxs)(W,{onOpenAutoFocus:e=>e.preventDefault(),children:[(0,Z.jsxs)(V,{children:[(0,Z.jsx)(G,{children:_t({instance:e.displayName??e.name})}),(0,Z.jsx)(K,{children:Fe()})]}),(0,Z.jsx)(`div`,{className:`oc-form`,children:r.map(t=>(0,Z.jsx)(Gt,{instanceId:e._id,field:t,updatedAt:i[t]??null},t))}),(0,Z.jsx)(`div`,{className:`oc-bridgesecret`,children:(0,Z.jsx)(Wt,{instance:e})}),(0,Z.jsx)(Ut,{instance:e})]})})}function Ut({instance:e}){let t=O(N.instanceSync.forceInstanceSync),n=I(),[i,a]=(0,Y.useState)(!1);async function o(){if(!i){a(!0);try{switch((await t({instanceId:e._id})).status){case`synced`:n.success(Ne());break;case`no_agents`:n.success(Me());break;case`no_bridge_url`:n.error(w());break;case`deploy_misconfigured`:n.error(lt());break;case`unauthorized`:n.error(v());break;case`not_served`:n.error(De());break;default:n.error(T());break}}catch(e){n.error(ke(),e)}finally{a(!1)}}}return(0,Z.jsxs)(`div`,{className:`oc-form`,children:[(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:Ce()}),(0,Z.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,Z.jsx)(P,{size:`sm`,variant:`outline`,onClick:()=>void o(),disabled:i,children:i?me():r()})})]})}function Wt({instance:e}){let t=C(N.bridgeAuth.listBridgeAuthStatus,{}),n=O(N.bridgeAuth.mintBridgeSecret),r=g(N.bridgeAuth.revokeBridgeSecret),i=I(),[a,s]=(0,Y.useState)(!1),[c,l]=(0,Y.useState)(null),[u,d]=(0,Y.useState)(!1),f=(t??[]).find(t=>t.instanceId===e._id),p=f!==void 0;async function h(){if(!a){s(!0);try{l((await n({instanceId:e._id})).plaintext),d(!1)}catch(e){i.error(x(),e)}finally{s(!1)}}}async function _(){if(!a){s(!0);try{await r({instanceId:e._id}),l(null),i.success(E())}catch(e){i.error(x(),e)}finally{s(!1)}}}async function v(){if(c)try{await navigator.clipboard.writeText(c),d(!0)}catch{}}return(0,Z.jsxs)($,{label:y(),children:[(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:Te()}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(L,{variant:p?`outline`:`secondary`,children:p?`${M()} · ${f.prefix}…${f.lastFour}`:Ke()}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(P,{size:`sm`,onClick:()=>void h(),disabled:a,children:p?Et():o()}),p?(0,Z.jsx)(P,{size:`sm`,variant:`destructive`,onClick:()=>void _(),disabled:a,children:ge()}):null]})]}),c?(0,Z.jsxs)(`div`,{className:`oc-bridgesecret__reveal`,children:[(0,Z.jsx)(`p`,{className:`oc-sa__minted-warning`,children:m()}),(0,Z.jsxs)(`div`,{className:`oc-sa__minted-box`,children:[(0,Z.jsx)(`code`,{className:`oc-sa__minted-plain`,children:c}),(0,Z.jsx)(P,{variant:`outline`,size:`sm`,onClick:()=>void v(),children:u?fe():D()})]}),(0,Z.jsx)(P,{size:`sm`,variant:`ghost`,onClick:()=>{l(null),d(!1)},children:pe()})]}):null]})}function Gt({instanceId:e,field:t,updatedAt:n}){let r=O(N.instanceSecrets.setInstanceSecret),i=g(N.instanceSecrets.clearInstanceSecret),a=O(N.deviceIdentity.generateDeviceIdentity),o=I(),[s,c]=(0,Y.useState)(``),[l,u]=(0,Y.useState)(!1),[d,f]=(0,Y.useState)(null),[p,m]=(0,Y.useState)(!1),h=n!==null,_=t===`deviceIdentity`,v=t===`token`?Je():t===`deviceIdentity`?Xe():it();async function ee(){if(!(!s.trim()||l)){u(!0);try{await r({instanceId:e,field:t,plaintext:s}),c(``),f(null),m(!1),o.success(dt())}catch(e){o.error(j(),e)}finally{u(!1)}}}async function y(){if(!l){u(!0);try{await i({instanceId:e,field:t}),f(null),m(!1),o.success(Le())}catch(e){o.error(j(),e)}finally{u(!1)}}}async function b(){if(!l){u(!0);try{f(await a({instanceId:e})),m(!1),o.success(A())}catch(e){o.error(Ge(),e)}finally{u(!1)}}}let x=d?`openclaw devices approve ${d.id}`:``;async function S(){if(x)try{await navigator.clipboard.writeText(x),m(!0)}catch{}}return(0,Z.jsxs)($,{label:v,children:[_?(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:ut()}):null,(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(L,{variant:h?`outline`:`secondary`,children:h?M():Ke()}),(0,Z.jsx)(U,{type:`password`,autoComplete:`off`,className:`flex-1 min-w-32`,value:s,placeholder:h?ht():Ue(),onChange:e=>c(e.target.value)}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(P,{size:`sm`,onClick:()=>void ee(),disabled:l||s.trim().length===0,children:nt()}),_?(0,Z.jsx)(P,{size:`sm`,variant:`outline`,onClick:()=>void b(),disabled:l,children:Qe()}):null,h?(0,Z.jsx)(P,{size:`sm`,variant:`destructive`,onClick:()=>void y(),disabled:l,children:Be()}):null]})]}),d?(0,Z.jsxs)(`div`,{className:`oc-bridgesecret__reveal`,children:[(0,Z.jsx)(`p`,{className:`text-sm font-medium`,children:A()}),(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:mt()}),(0,Z.jsxs)(`div`,{className:`oc-sa__minted-box`,children:[(0,Z.jsx)(`code`,{className:`oc-sa__minted-plain`,children:x}),(0,Z.jsx)(P,{variant:`outline`,size:`sm`,onClick:()=>void S(),children:p?fe():D()})]}),(0,Z.jsx)(P,{size:`sm`,variant:`ghost`,onClick:()=>{f(null),m(!1)},children:pe()})]}):null]})}var Kt={conversational:c,documentary:St,summarizer:_e,curator:S},qt={conversational:ye,documentary:ze,summarizer:ie,curator:h},Jt=e=>(Kt[e]??(()=>e))(),Yt=e=>(qt[e]??(()=>``))();function Xt({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:u()}),t.map(e=>(0,Z.jsx)(L,{variant:`secondary`,className:`oc-agenttype__chip`,title:Yt(e),children:Jt(e)},e)),(0,Z.jsxs)(At,{children:[(0,Z.jsx)(kt,{asChild:!0,children:(0,Z.jsx)(P,{type:`button`,variant:`outline`,size:`sm`,className:`h-7`,children:f()})}),(0,Z.jsxs)(Nt,{align:`start`,className:`oc-agenttypes-pop`,children:[(0,Z.jsx)(`p`,{className:`oc-agenttypes-pop__title`,children:xe()}),(0,Z.jsx)(`p`,{className:`oc-agenttypes-pop__hint`,children:bt()}),(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)(J,{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:Jt(r)}),(0,Z.jsx)(`span`,{className:`oc-agenttypes-pop__desc`,children:Yt(r)})]})]},r)})})]})]})]})}function Zt({instanceName:e,open:t,onOpenChange:n}){let r=C(N.agents.listAgentsForInstance,t&&e?{instanceName:e}:`skip`),i=g(N.agents.setAgentEnabled).withOptimisticUpdate((e,{instanceName:t,agentId:n,enabled:r})=>{let i=e.getQuery(N.agents.listAgentsForInstance,{instanceName:t});i&&e.setQuery(N.agents.listAgentsForInstance,{instanceName:t},{...i,agents:i.agents.map(e=>e.agentId===n?{...e,enabled:r}:e)})}),a=g(N.agents.setInstanceDefaultAgent).withOptimisticUpdate((e,{instanceName:t,agentId:n})=>{let r=e.getQuery(N.agents.listAgentsForInstance,{instanceName:t});r&&e.setQuery(N.agents.listAgentsForInstance,{instanceName:t},{...r,defaultAgentId:n})}),o=g(N.agents.setAgentTypes).withOptimisticUpdate((e,{instanceName:t,agentId:n,types:r})=>{let i=e.getQuery(N.agents.listAgentsForInstance,{instanceName:t});if(!i)return;let a=Rt(r);e.setQuery(N.agents.listAgentsForInstance,{instanceName:t},{...i,agents:i.agents.map(e=>e.agentId===n?{...e,types:a}:e)})}),s=g(N.agents.setAgentDescription).withOptimisticUpdate((e,{instanceName:t,agentId:n,description:r})=>{let i=e.getQuery(N.agents.listAgentsForInstance,{instanceName:t});if(!i)return;let a=r.trim();e.setQuery(N.agents.listAgentsForInstance,{instanceName:t},{...i,agents:i.agents.map(e=>e.agentId===n?{...e,description:a.length===0?null:a}:e)})}),c=g(N.agents.removeInstanceAgent),l=jt(),u=I();async function d(t,n){if(e)try{await i({instanceName:e,agentId:t,enabled:n})}catch(e){u.error(k(),e)}}async function f(t){if(e)try{await a({instanceName:e,agentId:t})}catch(e){u.error(k(),e)}}async function p(t,n,r){if(!e)return;let i=r.includes(n)?r.filter(e=>e!==n):[...r,n];try{await o({instanceName:e,agentId:t,types:i})}catch(e){u.error(k(),e)}}async function m(t,n){if(e&&await l({title:Ie({name:n}),description:Ye(),confirmLabel:Ze(),destructive:!0}))try{await c({instanceName:e,agentId:t}),u.success(at())}catch(e){u.error(k(),e)}}return(0,Z.jsx)(q,{open:t,onOpenChange:n,children:(0,Z.jsxs)(W,{className:`oc-access`,children:[(0,Z.jsxs)(V,{children:[(0,Z.jsx)(G,{children:ce({name:e??``})}),(0,Z.jsx)(K,{children:oe()})]}),r===void 0?(0,Z.jsx)(`p`,{className:`oc-access__hint`,children:st()}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`oc-access__poll`,children:r.discovery===null?qe():r.discovery.lastPollOk?We():gt({error:r.discovery.error??`?`})}),r.agents.length===0?(0,Z.jsx)(`p`,{className:`oc-access__hint`,children:rt()}):(0,Z.jsx)(`div`,{className:`oc-access__list`,children:r.agents.map(t=>{let n=t.presentInLastOk===!1,i=r.defaultAgentId===t.agentId,a=t.displayName??t.agentId,o=t.types??[];return(0,Z.jsxs)(`div`,{className:`oc-agentcard`+(t.enabled?``:` oc-agentcard--off`),children:[(0,Z.jsxs)(`div`,{className:`oc-agentcard__head`,children:[(0,Z.jsx)(J,{checked:t.enabled,disabled:n,"aria-label":a,onCheckedChange:e=>void d(t.agentId,e===!0)}),(0,Z.jsxs)(`span`,{className:`oc-agentcard__name`,title:a,children:[t.emoji?`${t.emoji} `:``,a]}),t.model?(0,Z.jsx)(`span`,{className:`oc-access__model`,children:t.model}):null,n?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(L,{variant:`outline`,className:`oc-access__gone`,children:ft()}),(0,Z.jsx)(P,{size:`sm`,variant:`ghost`,className:`h-7 text-destructive`,onClick:()=>void m(t.agentId,a),children:vt()})]}):i?(0,Z.jsx)(L,{variant:`default`,children:Ve()}):(0,Z.jsx)(P,{size:`sm`,variant:`outline`,className:`h-7`,disabled:!t.enabled,onClick:()=>void f(t.agentId),children:wt()})]}),t.enabled?(0,Z.jsx)(Xt,{agentId:t.agentId,types:o,onToggle:e=>void p(t.agentId,e,o)}):null,t.enabled?(0,Z.jsx)(Qt,{value:t.description??``,onSave:async n=>{if(e)try{await s({instanceName:e,agentId:t.agentId,description:n})}catch(e){u.error(k(),e)}}}):null]},t.agentId)})})]})]})})}function Qt({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)(U,{className:`oc-agentcard__desc`,value:n,maxLength:280,placeholder:tt(),"aria-label":ue(),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{Vt as InstancesTab};
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$T as r,AE as i,BE as a,BT as o,CE as s,CT as c,DE as l,DT as u,EE as d,ET as f,FE as p,FT as m,Fs as h,Fz as g,GE as _,GT as v,HE as ee,HT as y,IE as b,IT as x,Is as S,Iz as C,JE as te,JT as w,KE as ne,KT as T,LE as re,LT as E,Ls as ie,ME as ae,MT as oe,NE as se,NM as D,NT as ce,Nz as O,OE as le,OT as ue,PE as de,PM as fe,PT as pe,QT as me,RE as he,RT as ge,Rs as _e,SE as ve,ST as ye,TE as be,TT as xe,UE as Se,UT as Ce,VE as we,VT as Te,WE as Ee,WT as De,XE as Oe,XT as ke,Xb as Ae,YE as je,YT as Me,ZT as Ne,Zb as Pe,_E as Fe,_T as Ie,aE as Le,bE as Re,bT as ze,cE as Be,cT as Ve,ci as He,dE as Ue,dT as We,eE as Ge,fE as Ke,fT as qe,gE as Je,gT as Ye,hE as Xe,hT as Ze,iE as Qe,jE as $e,jT as k,kE as et,kT as tt,lE as nt,lT as rt,mE as it,mT as at,nE as A,oE as j,oi as ot,pE as M,pT as st,qE as ct,qT as lt,rE as ut,sE as dt,sT as ft,si as pt,t as N,tE as mt,uE as ht,uT as gt,vE as _t,vT as vt,wE as yt,wT as bt,xE as xt,xT as St,yE as Ct,yT as wt,zE as Tt,zT as Et}from"./api-Cpjr7qvl.js";import{a as Dt,c as Ot}from"./FieldLabel-Bww3UDFn.js";import{t as P}from"./button-CbwCr9Pi.js";import{$ as F,Bt as kt,Dt as I,Et as L,Q as R,Rt as At,U as jt,X as z,Z as B,_ as Mt,at as V,et as H,jt as U,nt as W,ot as G,rt as K,tt as q,ut as J,zt as Nt}from"./index-Bc3aF-kJ.js";import{t as Pt}from"./DataTableShell-DWXPn72S.js";import{InstanceConfigDialog as Ft}from"./BridgeTab-DzV-2POL.js";var Y=t(e(),1),X=[`conversational`,`documentary`,`summarizer`,`curator`],It=new Set(X),Lt=`conversational`;function Rt(e){let t=new Set((e??[]).filter(e=>It.has(e)));return t.size===0?[Lt]:X.filter(e=>t.has(e))}var Z=n(),Q={name:``,gatewayUrl:``,bridgeUrl:``,displayName:``,kind:`openclaw`,transport:`ws`,gatewayVersion:``,gatewayHttpUrl:``,streamTransport:Dt},zt={openclaw:[`token`,`deviceIdentity`],hermes:[`apiKey`]};function Bt(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??``,streamTransport:e.streamTransport??`reactive`}}function Vt(){let e=C(N.admin.listInstances,{}),t=C(N.agents.listAllInstanceAgents,{}),n=g(N.admin.upsertInstance),r=g(N.admin.deleteInstance),o=I(),[c,u]=(0,Y.useState)(!1),[f,m]=(0,Y.useState)(Q),[h,v]=(0,Y.useState)(null),[y,x]=(0,Y.useState)(null),[S,w]=(0,Y.useState)(null),[T,E]=(0,Y.useState)(null);async function ie(){try{await n({instanceId:T??void 0,name:f.name,gatewayUrl:f.gatewayUrl,bridgeUrl:f.bridgeUrl||void 0,displayName:f.displayName||void 0,kind:f.kind,transport:f.kind===`hermes`?f.transport:void 0,gatewayVersion:f.gatewayVersion||void 0,gatewayHttpUrl:f.gatewayHttpUrl||void 0,streamTransport:f.streamTransport}),m(Q),E(null),u(!1)}catch(e){o.error(te(),e)}}return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`p`,{className:`oc-admin__hint`,children:[ct(),(0,Z.jsx)(`strong`,{children:ne()}),_()]}),(0,Z.jsx)(Pt,{title:Ee(),rows:e,addLabel:Se(),onAdd:()=>{E(null),m(Q),u(!0)},emptyHint:ee(),columns:[{header:we(),cell:e=>e.name,sort:e=>e.name},{header:a(),cell:e=>(0,Z.jsx)(L,{variant:`outline`,children:e.kind??`openclaw`}),sort:e=>e.kind??`openclaw`},{header:Tt(),cell:e=>e.gatewayUrl,sort:e=>e.gatewayUrl},{header:he(),cell:e=>e.displayName??`—`,sort:e=>e.displayName??null},{header:Oe(),cell:e=>{let n=(t?.[e.name]??[]).filter(e=>e.presentInLastOk!==!1&&e.enabled);if(n.length===0)return(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:`—`});let r=t=>e.defaultAgentId===t;return(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:[...n].sort((e,t)=>Number(r(t.agentId))-Number(r(e.agentId))).map(e=>(0,Z.jsxs)(L,{variant:r(e.agentId)?`default`:`outline`,title:r(e.agentId)?Ve():void 0,children:[e.emoji?`${e.emoji} `:``,e.displayName??e.agentId]},e.agentId))})}}],rowActions:e=>[{label:de(),onSelect:()=>{E(e._id),m(Bt(e)),u(!0)}},{label:je(),onSelect:()=>v(e.name)},{label:Ct(),onSelect:()=>w(e)},{label:re(),onSelect:()=>x(e)},{label:b(),variant:`destructive`,onSelect:()=>void r({instanceId:e._id})}],bulkActions:[{label:b(),variant:`destructive`,onSelect:e=>e.forEach(e=>void r({instanceId:e}))}]}),(0,Z.jsx)(Mt,{open:c,onOpenChange:u,title:T?se():p(),description:$e(),canSubmit:!!(f.name&&f.gatewayUrl),onSubmit:ie,submitLabel:i(),children:(0,Z.jsxs)(`div`,{className:`oc-form`,children:[(0,Z.jsxs)($,{label:et(),children:[(0,Z.jsx)(U,{value:f.name,disabled:T!==null,onChange:e=>m({...f,name:e.target.value})}),T?(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:ae()}):null]}),(0,Z.jsx)($,{label:le(),children:(0,Z.jsxs)(z,{value:f.kind,onValueChange:e=>m({...f,kind:e}),children:[(0,Z.jsx)(F,{size:`sm`,className:`w-40`,children:(0,Z.jsx)(H,{})}),(0,Z.jsxs)(B,{children:[(0,Z.jsx)(R,{value:`openclaw`,children:`OpenClaw`}),(0,Z.jsx)(R,{value:`hermes`,children:`Hermes`})]})]})}),f.kind===`hermes`?(0,Z.jsx)($,{label:He(),children:(0,Z.jsxs)(z,{value:f.transport,onValueChange:e=>m({...f,transport:e}),children:[(0,Z.jsx)(F,{size:`sm`,className:`w-56`,children:(0,Z.jsx)(H,{})}),(0,Z.jsxs)(B,{children:[(0,Z.jsx)(R,{value:`ws`,children:pt()}),(0,Z.jsx)(R,{value:`rest`,children:ot()})]})]})}):null,(0,Z.jsx)($,{label:l(),children:(0,Z.jsx)(U,{value:f.gatewayUrl,onChange:e=>m({...f,gatewayUrl:e.target.value})})}),(0,Z.jsx)($,{label:d(),children:(0,Z.jsx)(U,{value:f.bridgeUrl,placeholder:be(),onChange:e=>m({...f,bridgeUrl:e.target.value})})}),(0,Z.jsx)($,{label:yt(),children:(0,Z.jsx)(U,{value:f.displayName,onChange:e=>m({...f,displayName:e.target.value})})}),(0,Z.jsxs)($,{label:Pe(),children:[(0,Z.jsxs)(z,{value:f.streamTransport,onValueChange:e=>m({...f,streamTransport:e}),children:[(0,Z.jsx)(F,{size:`sm`,className:`w-40`,children:(0,Z.jsx)(H,{})}),(0,Z.jsx)(B,{children:Ot.map(e=>(0,Z.jsx)(R,{value:e,children:e},e))})]}),(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:Ae()})]}),(0,Z.jsx)($,{label:s(),children:(0,Z.jsx)(U,{value:f.gatewayVersion,placeholder:ve(),onChange:e=>m({...f,gatewayVersion:e.target.value})})}),(0,Z.jsx)($,{label:xt(),children:(0,Z.jsx)(U,{value:f.gatewayHttpUrl,placeholder:Re(),onChange:e=>m({...f,gatewayHttpUrl:e.target.value})})})]})}),(0,Z.jsx)(Zt,{instanceName:h,open:h!==null,onOpenChange:e=>{e||v(null)}}),y?(0,Z.jsx)(Ft,{instance:y,onClose:()=>x(null)},y._id):null,S?(0,Z.jsx)(Ht,{instance:S,onClose:()=>w(null)},S._id):null]})}function Ht({instance:e,onClose:t}){let n=C(N.instanceSecrets.listInstanceSecretStatus,{}),r=zt[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)(q,{open:!0,onOpenChange:e=>!e&&t(),children:(0,Z.jsxs)(W,{onOpenAutoFocus:e=>e.preventDefault(),children:[(0,Z.jsxs)(V,{children:[(0,Z.jsx)(G,{children:_t({instance:e.displayName??e.name})}),(0,Z.jsx)(K,{children:Fe()})]}),(0,Z.jsx)(`div`,{className:`oc-form`,children:r.map(t=>(0,Z.jsx)(Gt,{instanceId:e._id,field:t,updatedAt:i[t]??null},t))}),(0,Z.jsx)(`div`,{className:`oc-bridgesecret`,children:(0,Z.jsx)(Wt,{instance:e})}),(0,Z.jsx)(Ut,{instance:e})]})})}function Ut({instance:e}){let t=O(N.instanceSync.forceInstanceSync),n=I(),[i,a]=(0,Y.useState)(!1);async function o(){if(!i){a(!0);try{switch((await t({instanceId:e._id})).status){case`synced`:n.success(Ne());break;case`no_agents`:n.success(Me());break;case`no_bridge_url`:n.error(w());break;case`deploy_misconfigured`:n.error(lt());break;case`unauthorized`:n.error(v());break;case`not_served`:n.error(De());break;default:n.error(T());break}}catch(e){n.error(ke(),e)}finally{a(!1)}}}return(0,Z.jsxs)(`div`,{className:`oc-form`,children:[(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:Ce()}),(0,Z.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,Z.jsx)(P,{size:`sm`,variant:`outline`,onClick:()=>void o(),disabled:i,children:i?me():r()})})]})}function Wt({instance:e}){let t=C(N.bridgeAuth.listBridgeAuthStatus,{}),n=O(N.bridgeAuth.mintBridgeSecret),r=g(N.bridgeAuth.revokeBridgeSecret),i=I(),[a,s]=(0,Y.useState)(!1),[c,l]=(0,Y.useState)(null),[u,d]=(0,Y.useState)(!1),f=(t??[]).find(t=>t.instanceId===e._id),p=f!==void 0;async function h(){if(!a){s(!0);try{l((await n({instanceId:e._id})).plaintext),d(!1)}catch(e){i.error(x(),e)}finally{s(!1)}}}async function _(){if(!a){s(!0);try{await r({instanceId:e._id}),l(null),i.success(E())}catch(e){i.error(x(),e)}finally{s(!1)}}}async function v(){if(c)try{await navigator.clipboard.writeText(c),d(!0)}catch{}}return(0,Z.jsxs)($,{label:y(),children:[(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:Te()}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(L,{variant:p?`outline`:`secondary`,children:p?`${M()} · ${f.prefix}…${f.lastFour}`:Ke()}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(P,{size:`sm`,onClick:()=>void h(),disabled:a,children:p?Et():o()}),p?(0,Z.jsx)(P,{size:`sm`,variant:`destructive`,onClick:()=>void _(),disabled:a,children:ge()}):null]})]}),c?(0,Z.jsxs)(`div`,{className:`oc-bridgesecret__reveal`,children:[(0,Z.jsx)(`p`,{className:`oc-sa__minted-warning`,children:m()}),(0,Z.jsxs)(`div`,{className:`oc-sa__minted-box`,children:[(0,Z.jsx)(`code`,{className:`oc-sa__minted-plain`,children:c}),(0,Z.jsx)(P,{variant:`outline`,size:`sm`,onClick:()=>void v(),children:u?fe():D()})]}),(0,Z.jsx)(P,{size:`sm`,variant:`ghost`,onClick:()=>{l(null),d(!1)},children:pe()})]}):null]})}function Gt({instanceId:e,field:t,updatedAt:n}){let r=O(N.instanceSecrets.setInstanceSecret),i=g(N.instanceSecrets.clearInstanceSecret),a=O(N.deviceIdentity.generateDeviceIdentity),o=I(),[s,c]=(0,Y.useState)(``),[l,u]=(0,Y.useState)(!1),[d,f]=(0,Y.useState)(null),[p,m]=(0,Y.useState)(!1),h=n!==null,_=t===`deviceIdentity`,v=t===`token`?Je():t===`deviceIdentity`?Xe():it();async function ee(){if(!(!s.trim()||l)){u(!0);try{await r({instanceId:e,field:t,plaintext:s}),c(``),f(null),m(!1),o.success(dt())}catch(e){o.error(j(),e)}finally{u(!1)}}}async function y(){if(!l){u(!0);try{await i({instanceId:e,field:t}),f(null),m(!1),o.success(Le())}catch(e){o.error(j(),e)}finally{u(!1)}}}async function b(){if(!l){u(!0);try{f(await a({instanceId:e})),m(!1),o.success(A())}catch(e){o.error(Ge(),e)}finally{u(!1)}}}let x=d?`openclaw devices approve ${d.id}`:``;async function S(){if(x)try{await navigator.clipboard.writeText(x),m(!0)}catch{}}return(0,Z.jsxs)($,{label:v,children:[_?(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:ut()}):null,(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(L,{variant:h?`outline`:`secondary`,children:h?M():Ke()}),(0,Z.jsx)(U,{type:`password`,autoComplete:`off`,className:`flex-1 min-w-32`,value:s,placeholder:h?ht():Ue(),onChange:e=>c(e.target.value)}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(P,{size:`sm`,onClick:()=>void ee(),disabled:l||s.trim().length===0,children:nt()}),_?(0,Z.jsx)(P,{size:`sm`,variant:`outline`,onClick:()=>void b(),disabled:l,children:Qe()}):null,h?(0,Z.jsx)(P,{size:`sm`,variant:`destructive`,onClick:()=>void y(),disabled:l,children:Be()}):null]})]}),d?(0,Z.jsxs)(`div`,{className:`oc-bridgesecret__reveal`,children:[(0,Z.jsx)(`p`,{className:`text-sm font-medium`,children:A()}),(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:mt()}),(0,Z.jsxs)(`div`,{className:`oc-sa__minted-box`,children:[(0,Z.jsx)(`code`,{className:`oc-sa__minted-plain`,children:x}),(0,Z.jsx)(P,{variant:`outline`,size:`sm`,onClick:()=>void S(),children:p?fe():D()})]}),(0,Z.jsx)(P,{size:`sm`,variant:`ghost`,onClick:()=>{f(null),m(!1)},children:pe()})]}):null]})}var Kt={conversational:c,documentary:St,summarizer:_e,curator:S},qt={conversational:ye,documentary:ze,summarizer:ie,curator:h},Jt=e=>(Kt[e]??(()=>e))(),Yt=e=>(qt[e]??(()=>``))();function Xt({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:u()}),t.map(e=>(0,Z.jsx)(L,{variant:`secondary`,className:`oc-agenttype__chip`,title:Yt(e),children:Jt(e)},e)),(0,Z.jsxs)(At,{children:[(0,Z.jsx)(kt,{asChild:!0,children:(0,Z.jsx)(P,{type:`button`,variant:`outline`,size:`sm`,className:`h-7`,children:f()})}),(0,Z.jsxs)(Nt,{align:`start`,className:`oc-agenttypes-pop`,children:[(0,Z.jsx)(`p`,{className:`oc-agenttypes-pop__title`,children:xe()}),(0,Z.jsx)(`p`,{className:`oc-agenttypes-pop__hint`,children:bt()}),(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)(J,{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:Jt(r)}),(0,Z.jsx)(`span`,{className:`oc-agenttypes-pop__desc`,children:Yt(r)})]})]},r)})})]})]})]})}function Zt({instanceName:e,open:t,onOpenChange:n}){let r=C(N.agents.listAgentsForInstance,t&&e?{instanceName:e}:`skip`),i=g(N.agents.setAgentEnabled).withOptimisticUpdate((e,{instanceName:t,agentId:n,enabled:r})=>{let i=e.getQuery(N.agents.listAgentsForInstance,{instanceName:t});i&&e.setQuery(N.agents.listAgentsForInstance,{instanceName:t},{...i,agents:i.agents.map(e=>e.agentId===n?{...e,enabled:r}:e)})}),a=g(N.agents.setInstanceDefaultAgent).withOptimisticUpdate((e,{instanceName:t,agentId:n})=>{let r=e.getQuery(N.agents.listAgentsForInstance,{instanceName:t});r&&e.setQuery(N.agents.listAgentsForInstance,{instanceName:t},{...r,defaultAgentId:n})}),o=g(N.agents.setAgentTypes).withOptimisticUpdate((e,{instanceName:t,agentId:n,types:r})=>{let i=e.getQuery(N.agents.listAgentsForInstance,{instanceName:t});if(!i)return;let a=Rt(r);e.setQuery(N.agents.listAgentsForInstance,{instanceName:t},{...i,agents:i.agents.map(e=>e.agentId===n?{...e,types:a}:e)})}),s=g(N.agents.setAgentDescription).withOptimisticUpdate((e,{instanceName:t,agentId:n,description:r})=>{let i=e.getQuery(N.agents.listAgentsForInstance,{instanceName:t});if(!i)return;let a=r.trim();e.setQuery(N.agents.listAgentsForInstance,{instanceName:t},{...i,agents:i.agents.map(e=>e.agentId===n?{...e,description:a.length===0?null:a}:e)})}),c=g(N.agents.removeInstanceAgent),l=jt(),u=I();async function d(t,n){if(e)try{await i({instanceName:e,agentId:t,enabled:n})}catch(e){u.error(k(),e)}}async function f(t){if(e)try{await a({instanceName:e,agentId:t})}catch(e){u.error(k(),e)}}async function p(t,n,r){if(!e)return;let i=r.includes(n)?r.filter(e=>e!==n):[...r,n];try{await o({instanceName:e,agentId:t,types:i})}catch(e){u.error(k(),e)}}async function m(t,n){if(e&&await l({title:Ie({name:n}),description:Ye(),confirmLabel:Ze(),destructive:!0}))try{await c({instanceName:e,agentId:t}),u.success(at())}catch(e){u.error(k(),e)}}return(0,Z.jsx)(q,{open:t,onOpenChange:n,children:(0,Z.jsxs)(W,{className:`oc-access`,children:[(0,Z.jsxs)(V,{children:[(0,Z.jsx)(G,{children:ce({name:e??``})}),(0,Z.jsx)(K,{children:oe()})]}),r===void 0?(0,Z.jsx)(`p`,{className:`oc-access__hint`,children:st()}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`oc-access__poll`,children:r.discovery===null?qe():r.discovery.lastPollOk?We():gt({error:r.discovery.error??`?`})}),r.agents.length===0?(0,Z.jsx)(`p`,{className:`oc-access__hint`,children:rt()}):(0,Z.jsx)(`div`,{className:`oc-access__list`,children:r.agents.map(t=>{let n=t.presentInLastOk===!1,i=r.defaultAgentId===t.agentId,a=t.displayName??t.agentId,o=t.types??[];return(0,Z.jsxs)(`div`,{className:`oc-agentcard`+(t.enabled?``:` oc-agentcard--off`),children:[(0,Z.jsxs)(`div`,{className:`oc-agentcard__head`,children:[(0,Z.jsx)(J,{checked:t.enabled,disabled:n,"aria-label":a,onCheckedChange:e=>void d(t.agentId,e===!0)}),(0,Z.jsxs)(`span`,{className:`oc-agentcard__name`,title:a,children:[t.emoji?`${t.emoji} `:``,a]}),t.model?(0,Z.jsx)(`span`,{className:`oc-access__model`,children:t.model}):null,n?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(L,{variant:`outline`,className:`oc-access__gone`,children:ft()}),(0,Z.jsx)(P,{size:`sm`,variant:`ghost`,className:`h-7 text-destructive`,onClick:()=>void m(t.agentId,a),children:vt()})]}):i?(0,Z.jsx)(L,{variant:`default`,children:Ve()}):(0,Z.jsx)(P,{size:`sm`,variant:`outline`,className:`h-7`,disabled:!t.enabled,onClick:()=>void f(t.agentId),children:wt()})]}),t.enabled?(0,Z.jsx)(Xt,{agentId:t.agentId,types:o,onToggle:e=>void p(t.agentId,e,o)}):null,t.enabled?(0,Z.jsx)(Qt,{value:t.description??``,onSave:async n=>{if(e)try{await s({instanceName:e,agentId:t.agentId,description:n})}catch(e){u.error(k(),e)}}}):null]},t.agentId)})})]})]})})}function Qt({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)(U,{className:`oc-agentcard__desc`,value:n,maxLength:280,placeholder:tt(),"aria-label":ue(),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{Vt as InstancesTab};
@@ -1 +1 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$c as r,AO as i,BO as a,FO as o,Fz as s,IO as c,Iz as l,LO as u,MO as d,NO as f,Nz as p,OO as m,PO as h,Qc as g,RO as _,VO as v,Zc as y,al as b,el as x,il as S,jO as C,kO as w,nl as T,rl as E,t as D,tl as O,zO as k}from"./api-Cpjr7qvl.js";import{t as A}from"./button-CbwCr9Pi.js";import{Et as j,jt as M,ut as N}from"./index-c5j0e823.js";var P=t(e(),1),F=n();function I(){let e=l(D.integrations.status.status,{}),t=s(D.admin.setIntegrationConfig),[n,r]=(0,P.useState)(null);if((0,P.useEffect)(()=>{e&&n===null&&r(e.config)},[e,n]),!e||!n)return(0,F.jsx)(`p`,{className:`oc-admin__hint`,children:v()});let p=n,g=(e,t,n)=>r({...p,[e]:{...p[e],[t]:n}}),y=(e,n)=>void t({[e]:n});return(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`p`,{className:`oc-admin__hint`,children:[a(),` `,(0,F.jsx)(`strong`,{children:k()}),` `,_()]}),(0,F.jsxs)(L,{title:`Langfuse`,status:e.langfuse.configured?e.langfuse.enabled?(0,F.jsx)(j,{variant:`secondary`,children:u()}):(0,F.jsx)(j,{variant:`outline`,children:c()}):(0,F.jsx)(j,{variant:`outline`,children:o()}),note:h(),children:[(0,F.jsx)(R,{label:d(),children:(0,F.jsx)(M,{value:p.langfuse.host??``,placeholder:e.langfuse.effectiveHost,onChange:e=>g(`langfuse`,`host`,e.target.value),onBlur:()=>y(`langfuse`,{host:p.langfuse.host??``})})}),(0,F.jsx)(z,{label:m(),checked:p.langfuse.enabled??!0,onChange:e=>{g(`langfuse`,`enabled`,e),y(`langfuse`,{enabled:e})}})]}),(0,F.jsxs)(L,{title:`Opik`,status:e.opik.configured?e.opik.enabled?(0,F.jsx)(j,{variant:`secondary`,children:u()}):(0,F.jsx)(j,{variant:`outline`,children:c()}):(0,F.jsx)(j,{variant:`outline`,children:o()}),note:f(),children:[(0,F.jsx)(R,{label:C(),children:(0,F.jsx)(M,{value:p.opik.baseUrl??``,placeholder:e.opik.effectiveBaseUrl,onChange:e=>g(`opik`,`baseUrl`,e.target.value),onBlur:()=>y(`opik`,{baseUrl:p.opik.baseUrl??``})})}),(0,F.jsx)(R,{label:i(),children:(0,F.jsx)(M,{value:p.opik.workspace??``,placeholder:e.opik.effectiveWorkspace||w(),onChange:e=>g(`opik`,`workspace`,e.target.value),onBlur:()=>y(`opik`,{workspace:p.opik.workspace??``})})}),(0,F.jsx)(z,{label:m(),checked:p.opik.enabled??!0,onChange:e=>{g(`opik`,`enabled`,e),y(`opik`,{enabled:e})}})]}),(0,F.jsxs)(L,{title:`OpenTelemetry (OTLP)`,status:e.otlp.configured?e.otlp.enabled?(0,F.jsx)(j,{variant:`secondary`,children:u()}):(0,F.jsx)(j,{variant:`outline`,children:c()}):(0,F.jsx)(j,{variant:`outline`,children:b()}),note:S(),children:[(0,F.jsx)(R,{label:E(),children:(0,F.jsx)(M,{value:p.otlp.endpoint??``,placeholder:e.otlp.effectiveEndpoint||`https://otlp.example.com/v1/traces`,onChange:e=>g(`otlp`,`endpoint`,e.target.value),onBlur:()=>y(`otlp`,{endpoint:p.otlp.endpoint??``})})}),(0,F.jsx)(B,{headersSet:e.otlp.headersSet}),(0,F.jsx)(z,{label:m(),checked:p.otlp.enabled??!0,onChange:e=>{g(`otlp`,`enabled`,e),y(`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=p(D.integrations.otlpSecret.setOtlpHeaders),n=s(D.integrations.otlpSecret.clearOtlpHeaders),[i,a]=(0,P.useState)(``),[o,c]=(0,P.useState)(null),[l,u]=(0,P.useState)(!1),d=async()=>{u(!0),c(null);try{await t({headersJson:i}),a(``)}catch(e){c(e instanceof Error?e.message:String(e))}finally{u(!1)}};return(0,F.jsxs)(R,{label:T(),children:[(0,F.jsx)(M,{value:i,placeholder:e?O():x(),onChange:e=>a(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 d(),children:r()}),e?(0,F.jsx)(A,{variant:`ghost`,size:`sm`,disabled:l,onClick:()=>void n({}),children:g()}):null]}),o?(0,F.jsx)(`p`,{className:`oc-int__otlp-headers-error`,children:o}):null,(0,F.jsx)(`p`,{className:`oc-uipa__note`,children:y()})]})}export{I as IntegrationsTab};
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$c as r,AO as i,BO as a,FO as o,Fz as s,IO as c,Iz as l,LO as u,MO as d,NO as f,Nz as p,OO as m,PO as h,Qc as g,RO as _,VO as v,Zc as y,al as b,el as x,il as S,jO as C,kO as w,nl as T,rl as E,t as D,tl as O,zO as k}from"./api-Cpjr7qvl.js";import{t as A}from"./button-CbwCr9Pi.js";import{Et as j,jt as M,ut as N}from"./index-Bc3aF-kJ.js";var P=t(e(),1),F=n();function I(){let e=l(D.integrations.status.status,{}),t=s(D.admin.setIntegrationConfig),[n,r]=(0,P.useState)(null);if((0,P.useEffect)(()=>{e&&n===null&&r(e.config)},[e,n]),!e||!n)return(0,F.jsx)(`p`,{className:`oc-admin__hint`,children:v()});let p=n,g=(e,t,n)=>r({...p,[e]:{...p[e],[t]:n}}),y=(e,n)=>void t({[e]:n});return(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`p`,{className:`oc-admin__hint`,children:[a(),` `,(0,F.jsx)(`strong`,{children:k()}),` `,_()]}),(0,F.jsxs)(L,{title:`Langfuse`,status:e.langfuse.configured?e.langfuse.enabled?(0,F.jsx)(j,{variant:`secondary`,children:u()}):(0,F.jsx)(j,{variant:`outline`,children:c()}):(0,F.jsx)(j,{variant:`outline`,children:o()}),note:h(),children:[(0,F.jsx)(R,{label:d(),children:(0,F.jsx)(M,{value:p.langfuse.host??``,placeholder:e.langfuse.effectiveHost,onChange:e=>g(`langfuse`,`host`,e.target.value),onBlur:()=>y(`langfuse`,{host:p.langfuse.host??``})})}),(0,F.jsx)(z,{label:m(),checked:p.langfuse.enabled??!0,onChange:e=>{g(`langfuse`,`enabled`,e),y(`langfuse`,{enabled:e})}})]}),(0,F.jsxs)(L,{title:`Opik`,status:e.opik.configured?e.opik.enabled?(0,F.jsx)(j,{variant:`secondary`,children:u()}):(0,F.jsx)(j,{variant:`outline`,children:c()}):(0,F.jsx)(j,{variant:`outline`,children:o()}),note:f(),children:[(0,F.jsx)(R,{label:C(),children:(0,F.jsx)(M,{value:p.opik.baseUrl??``,placeholder:e.opik.effectiveBaseUrl,onChange:e=>g(`opik`,`baseUrl`,e.target.value),onBlur:()=>y(`opik`,{baseUrl:p.opik.baseUrl??``})})}),(0,F.jsx)(R,{label:i(),children:(0,F.jsx)(M,{value:p.opik.workspace??``,placeholder:e.opik.effectiveWorkspace||w(),onChange:e=>g(`opik`,`workspace`,e.target.value),onBlur:()=>y(`opik`,{workspace:p.opik.workspace??``})})}),(0,F.jsx)(z,{label:m(),checked:p.opik.enabled??!0,onChange:e=>{g(`opik`,`enabled`,e),y(`opik`,{enabled:e})}})]}),(0,F.jsxs)(L,{title:`OpenTelemetry (OTLP)`,status:e.otlp.configured?e.otlp.enabled?(0,F.jsx)(j,{variant:`secondary`,children:u()}):(0,F.jsx)(j,{variant:`outline`,children:c()}):(0,F.jsx)(j,{variant:`outline`,children:b()}),note:S(),children:[(0,F.jsx)(R,{label:E(),children:(0,F.jsx)(M,{value:p.otlp.endpoint??``,placeholder:e.otlp.effectiveEndpoint||`https://otlp.example.com/v1/traces`,onChange:e=>g(`otlp`,`endpoint`,e.target.value),onBlur:()=>y(`otlp`,{endpoint:p.otlp.endpoint??``})})}),(0,F.jsx)(B,{headersSet:e.otlp.headersSet}),(0,F.jsx)(z,{label:m(),checked:p.otlp.enabled??!0,onChange:e=>{g(`otlp`,`enabled`,e),y(`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=p(D.integrations.otlpSecret.setOtlpHeaders),n=s(D.integrations.otlpSecret.clearOtlpHeaders),[i,a]=(0,P.useState)(``),[o,c]=(0,P.useState)(null),[l,u]=(0,P.useState)(!1),d=async()=>{u(!0),c(null);try{await t({headersJson:i}),a(``)}catch(e){c(e instanceof Error?e.message:String(e))}finally{u(!1)}};return(0,F.jsxs)(R,{label:T(),children:[(0,F.jsx)(M,{value:i,placeholder:e?O():x(),onChange:e=>a(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 d(),children:r()}),e?(0,F.jsx)(A,{variant:`ghost`,size:`sm`,disabled:l,onClick:()=>void n({}),children:g()}):null]}),o?(0,F.jsx)(`p`,{className:`oc-int__otlp-headers-error`,children:o}):null,(0,F.jsx)(`p`,{className:`oc-uipa__note`,children:y()})]})}export{I as IntegrationsTab};
@@ -1 +1 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{Ck as r,Iz as i,Sk as a,Yk as o,ay as s,cy as c,dy as l,ey as u,fy as d,iy as f,ly as p,mk as m,my as h,ny as g,oy as _,pk as ee,py as te,ry as ne,sy as v,t as y,ty as b,uy as x,wk as S,xk as C}from"./api-Cpjr7qvl.js";import{Gn as w,Wn as T,i as E,o as re,q as ie,r as D}from"./index-c5j0e823.js";import{a as O,n as k,o as A,r as j,t as M}from"./card-DpbKWI5H.js";import{n as N,t as P}from"./TimeRangePicker-Di0xhZgB.js";var F=t(e(),1),I={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`},L=Object.keys(I).length,R=n(),z=15,B=e=>String(Math.round(e));function V(){let e=i(y.me.getMe,{host:ie})?.permissions?.includes(`traces.read`)??!1,t=i(y.deliveryTiming.listDeliverySessions,e?{}:`skip`),n=(0,F.useMemo)(()=>t?t.filter(e=>!e.active&&e.rollup!==null&&e.rollup.cP50!==null&&e.rollup.aP50!==null).slice(0,z).reverse().map(e=>({startedAt:e.startedAt,cP50:e.rollup?.cP50,aP50:e.rollup?.aP50})):[],[t]);return t===void 0?null:(0,R.jsxs)(`section`,{className:`oc-kpi__group`,children:[(0,R.jsx)(`h2`,{className:`oc-kpi__group-title`,children:o()}),(0,R.jsxs)(M,{children:[(0,R.jsxs)(O,{children:[(0,R.jsx)(A,{children:S()}),(0,R.jsx)(j,{children:a()})]}),(0,R.jsx)(k,{children:n.length<2?(0,R.jsx)(`p`,{className:`oc-admin__hint`,children:C()}):(0,R.jsx)(H,{series:n})})]})]})}function H({series:e}){let t=e.map(e=>e.cP50),n=e.map(e=>e.aP50),i=Math.max(1,...t,...n),a=t=>6+t*468/(e.length-1),o=e=>74-e*68/i,s=e=>e.map((e,t)=>`${t===0?`M`:`L`}${a(t).toFixed(1)},${o(e).toFixed(1)}`).join(` `),c=e[e.length-1];return(0,R.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,R.jsxs)(`div`,{className:`flex gap-3 text-xs text-muted-foreground`,children:[(0,R.jsxs)(`span`,{style:{color:`var(--primary)`},children:[ee(),` p50 `,B(c.cP50),` `,r()]}),(0,R.jsxs)(`span`,{children:[m(),` p50 `,B(c.aP50),` `,r()]})]}),(0,R.jsxs)(`svg`,{viewBox:`0 0 480 80`,className:`h-20 w-full`,preserveAspectRatio:`none`,role:`img`,"aria-label":S(),children:[(0,R.jsx)(`path`,{d:s(n),fill:`none`,style:{stroke:`var(--muted-foreground)`},strokeWidth:1.5}),(0,R.jsx)(`path`,{d:s(t),fill:`none`,style:{stroke:`var(--primary)`},strokeWidth:1.5})]})]})}var U=[{metric:`api.calls`,label:h(),unit:`/h`,group:`API`,isError:!1},{metric:`api.errors`,label:te(),unit:`/h`,group:`API`,isError:!0},{metric:`api.latency.avg_ms`,label:d(),unit:`ms`,group:`API`,isError:!1},{metric:`openclaw.ingest`,label:l(),unit:`/h`,group:`OpenClaw`,isError:!1},{metric:`chat.send`,label:x(),unit:`/h`,group:`Chat`,isError:!1},{metric:I.ASSISTANT_STREAM_ERRORS,label:p(),unit:`/h`,group:`Assistant`,isError:!0},{metric:I.ASSISTANT_ANNOUNCE_ERRORS,label:c(),unit:`/h`,group:`Assistant`,isError:!0}],W=L,G=[`API`,`OpenClaw`,`Chat`,`Assistant`],K=1e3,q=36e5;function J(e,t){let n=Math.max(1,Math.ceil((t-e)/q)),r=Math.min(n*W,K);return{rowLimit:r,buckets:Math.max(1,Math.floor(r/W))}}function ae(){let e=w({from:`/settings/kpi`}),t=T({from:`/settings/kpi`}),n=E(e.from,e.to,D,`now`),r=e=>void t({search:t=>({...t,...re(e)})}),{from:a,to:o}=N(n),{rowLimit:c,buckets:l}=J(a,o),u=i(y.kpi.listKpis,{limit:c,filter:{from:a,to:o}}),d=(0,F.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]),p=(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`p`,{className:`oc-admin__hint`,children:[v(),` `,(0,R.jsx)(`span`,{className:`oc-filter__window`,children:_()})]}),(0,R.jsx)(Y,{value:n,onChange:r})]});return u===void 0?(0,R.jsxs)(R.Fragment,{children:[p,(0,R.jsx)(V,{}),(0,R.jsx)(`p`,{className:`oc-admin__hint`,children:s()})]}):u.length===0?(0,R.jsxs)(R.Fragment,{children:[p,(0,R.jsx)(V,{}),(0,R.jsx)(`p`,{className:`oc-admin__hint`,children:f()})]}):(0,R.jsxs)(R.Fragment,{children:[p,(0,R.jsx)(V,{}),G.map(e=>{let t=U.filter(t=>t.group===e);return t.some(e=>(d.get(e.metric)??[]).length>0)?(0,R.jsxs)(`section`,{className:`oc-kpi__group`,children:[(0,R.jsx)(`h2`,{className:`oc-kpi__group-title`,children:e}),(0,R.jsx)(`div`,{className:`oc-kpi__grid`,children:t.map(e=>(0,R.jsx)(oe,{config:e,series:d.get(e.metric)??[]},e.metric))})]},e):null})]})}function Y({value:e,onChange:t}){return(0,R.jsx)(`div`,{className:`oc-kpi__toolbar`,children:(0,R.jsx)(P,{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,R.jsxs)(M,{size:`sm`,className:`oc-kpi__card`,children:[(0,R.jsxs)(O,{children:[(0,R.jsx)(A,{className:`oc-kpi__card-title`,children:e.label}),(0,R.jsx)(j,{className:`oc-kpi__card-metric`,children:(0,R.jsx)(`code`,{children:e.metric})})]}),(0,R.jsxs)(k,{className:`oc-kpi__card-body`,children:[(0,R.jsxs)(`div`,{className:`oc-kpi__value-row`,children:[(0,R.jsx)(`span`,{className:`oc-kpi__value`+(e.isError&&r>0?` oc-kpi__value--error`:``),children:Q(r)}),(0,R.jsx)(`span`,{className:`oc-kpi__unit`,children:e.unit})]}),(0,R.jsx)(ce,{series:t,isError:e.isError,unit:e.unit}),(0,R.jsxs)(`div`,{className:`oc-kpi__axis`,children:[n?(0,R.jsx)(`span`,{className:`oc-kpi__axis-latest`,children:ne({value:$(n.bucket)})}):(0,R.jsx)(`span`,{className:`oc-kpi__muted`,children:g()}),(0,R.jsx)(`span`,{className:`oc-kpi__muted`,children:b({count:t.length})})]})]})]})}var X=240,Z=48,se=1;function ce({series:e,isError:t,unit:n}){if(e.length===0)return(0,R.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,R.jsx)(`svg`,{className:`oc-kpi__chart`,viewBox:`0 0 ${X} ${Z}`,preserveAspectRatio:`none`,role:`img`,"aria-label":u({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,R.jsx)(`rect`,{className:`oc-kpi__bar`+(t&&e.value>0?` oc-kpi__bar--error`:``),x:c,y:l,width:a,height:s,children:(0,R.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{ae as KpiTab};
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{Ck as r,Iz as i,Sk as a,Yk as o,ay as s,cy as c,dy as l,ey as u,fy as d,iy as f,ly as p,mk as m,my as h,ny as g,oy as _,pk as ee,py as te,ry as ne,sy as v,t as y,ty as b,uy as x,wk as S,xk as C}from"./api-Cpjr7qvl.js";import{Gn as w,Wn as T,i as E,o as re,q as ie,r as D}from"./index-Bc3aF-kJ.js";import{a as O,n as k,o as A,r as j,t as M}from"./card-DpbKWI5H.js";import{n as N,t as P}from"./TimeRangePicker-BlRNLd96.js";var F=t(e(),1),I={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`},L=Object.keys(I).length,R=n(),z=15,B=e=>String(Math.round(e));function V(){let e=i(y.me.getMe,{host:ie})?.permissions?.includes(`traces.read`)??!1,t=i(y.deliveryTiming.listDeliverySessions,e?{}:`skip`),n=(0,F.useMemo)(()=>t?t.filter(e=>!e.active&&e.rollup!==null&&e.rollup.cP50!==null&&e.rollup.aP50!==null).slice(0,z).reverse().map(e=>({startedAt:e.startedAt,cP50:e.rollup?.cP50,aP50:e.rollup?.aP50})):[],[t]);return t===void 0?null:(0,R.jsxs)(`section`,{className:`oc-kpi__group`,children:[(0,R.jsx)(`h2`,{className:`oc-kpi__group-title`,children:o()}),(0,R.jsxs)(M,{children:[(0,R.jsxs)(O,{children:[(0,R.jsx)(A,{children:S()}),(0,R.jsx)(j,{children:a()})]}),(0,R.jsx)(k,{children:n.length<2?(0,R.jsx)(`p`,{className:`oc-admin__hint`,children:C()}):(0,R.jsx)(H,{series:n})})]})]})}function H({series:e}){let t=e.map(e=>e.cP50),n=e.map(e=>e.aP50),i=Math.max(1,...t,...n),a=t=>6+t*468/(e.length-1),o=e=>74-e*68/i,s=e=>e.map((e,t)=>`${t===0?`M`:`L`}${a(t).toFixed(1)},${o(e).toFixed(1)}`).join(` `),c=e[e.length-1];return(0,R.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,R.jsxs)(`div`,{className:`flex gap-3 text-xs text-muted-foreground`,children:[(0,R.jsxs)(`span`,{style:{color:`var(--primary)`},children:[ee(),` p50 `,B(c.cP50),` `,r()]}),(0,R.jsxs)(`span`,{children:[m(),` p50 `,B(c.aP50),` `,r()]})]}),(0,R.jsxs)(`svg`,{viewBox:`0 0 480 80`,className:`h-20 w-full`,preserveAspectRatio:`none`,role:`img`,"aria-label":S(),children:[(0,R.jsx)(`path`,{d:s(n),fill:`none`,style:{stroke:`var(--muted-foreground)`},strokeWidth:1.5}),(0,R.jsx)(`path`,{d:s(t),fill:`none`,style:{stroke:`var(--primary)`},strokeWidth:1.5})]})]})}var U=[{metric:`api.calls`,label:h(),unit:`/h`,group:`API`,isError:!1},{metric:`api.errors`,label:te(),unit:`/h`,group:`API`,isError:!0},{metric:`api.latency.avg_ms`,label:d(),unit:`ms`,group:`API`,isError:!1},{metric:`openclaw.ingest`,label:l(),unit:`/h`,group:`OpenClaw`,isError:!1},{metric:`chat.send`,label:x(),unit:`/h`,group:`Chat`,isError:!1},{metric:I.ASSISTANT_STREAM_ERRORS,label:p(),unit:`/h`,group:`Assistant`,isError:!0},{metric:I.ASSISTANT_ANNOUNCE_ERRORS,label:c(),unit:`/h`,group:`Assistant`,isError:!0}],W=L,G=[`API`,`OpenClaw`,`Chat`,`Assistant`],K=1e3,q=36e5;function J(e,t){let n=Math.max(1,Math.ceil((t-e)/q)),r=Math.min(n*W,K);return{rowLimit:r,buckets:Math.max(1,Math.floor(r/W))}}function ae(){let e=w({from:`/settings/kpi`}),t=T({from:`/settings/kpi`}),n=E(e.from,e.to,D,`now`),r=e=>void t({search:t=>({...t,...re(e)})}),{from:a,to:o}=N(n),{rowLimit:c,buckets:l}=J(a,o),u=i(y.kpi.listKpis,{limit:c,filter:{from:a,to:o}}),d=(0,F.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]),p=(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`p`,{className:`oc-admin__hint`,children:[v(),` `,(0,R.jsx)(`span`,{className:`oc-filter__window`,children:_()})]}),(0,R.jsx)(Y,{value:n,onChange:r})]});return u===void 0?(0,R.jsxs)(R.Fragment,{children:[p,(0,R.jsx)(V,{}),(0,R.jsx)(`p`,{className:`oc-admin__hint`,children:s()})]}):u.length===0?(0,R.jsxs)(R.Fragment,{children:[p,(0,R.jsx)(V,{}),(0,R.jsx)(`p`,{className:`oc-admin__hint`,children:f()})]}):(0,R.jsxs)(R.Fragment,{children:[p,(0,R.jsx)(V,{}),G.map(e=>{let t=U.filter(t=>t.group===e);return t.some(e=>(d.get(e.metric)??[]).length>0)?(0,R.jsxs)(`section`,{className:`oc-kpi__group`,children:[(0,R.jsx)(`h2`,{className:`oc-kpi__group-title`,children:e}),(0,R.jsx)(`div`,{className:`oc-kpi__grid`,children:t.map(e=>(0,R.jsx)(oe,{config:e,series:d.get(e.metric)??[]},e.metric))})]},e):null})]})}function Y({value:e,onChange:t}){return(0,R.jsx)(`div`,{className:`oc-kpi__toolbar`,children:(0,R.jsx)(P,{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,R.jsxs)(M,{size:`sm`,className:`oc-kpi__card`,children:[(0,R.jsxs)(O,{children:[(0,R.jsx)(A,{className:`oc-kpi__card-title`,children:e.label}),(0,R.jsx)(j,{className:`oc-kpi__card-metric`,children:(0,R.jsx)(`code`,{children:e.metric})})]}),(0,R.jsxs)(k,{className:`oc-kpi__card-body`,children:[(0,R.jsxs)(`div`,{className:`oc-kpi__value-row`,children:[(0,R.jsx)(`span`,{className:`oc-kpi__value`+(e.isError&&r>0?` oc-kpi__value--error`:``),children:Q(r)}),(0,R.jsx)(`span`,{className:`oc-kpi__unit`,children:e.unit})]}),(0,R.jsx)(ce,{series:t,isError:e.isError,unit:e.unit}),(0,R.jsxs)(`div`,{className:`oc-kpi__axis`,children:[n?(0,R.jsx)(`span`,{className:`oc-kpi__axis-latest`,children:ne({value:$(n.bucket)})}):(0,R.jsx)(`span`,{className:`oc-kpi__muted`,children:g()}),(0,R.jsx)(`span`,{className:`oc-kpi__muted`,children:b({count:t.length})})]})]})]})}var X=240,Z=48,se=1;function ce({series:e,isError:t,unit:n}){if(e.length===0)return(0,R.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,R.jsx)(`svg`,{className:`oc-kpi__chart`,viewBox:`0 0 ${X} ${Z}`,preserveAspectRatio:`none`,role:`img`,"aria-label":u({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,R.jsx)(`rect`,{className:`oc-kpi__bar`+(t&&e.value>0?` oc-kpi__bar--error`:``),x:c,y:l,width:a,height:s,children:(0,R.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{ae as KpiTab};
@@ -1 +1 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$N as r,$R as i,AE as a,AP as o,CP as s,DP as c,Dz as l,EP as u,En as d,Fz as f,Iz as p,JN as m,KN as h,OP as g,QN as ee,QR as te,SP as ne,Sz as re,TP as ie,Tn as ae,XN as oe,XR as se,YN as ce,ZN as le,ZR as ue,_P as de,_z as fe,aP as _,an as pe,az as me,bP as he,bn as ge,cP as v,cn as y,cz as b,dP as x,dn as S,dz as C,eP as w,ez as T,fP as E,fn as D,fz as O,gP as k,gz as A,hP as j,hz as M,iP as N,iz as P,jP as F,kP as I,lP as L,ln as _e,lz as ve,mP as ye,mz as be,nP as xe,nz as Se,oP as Ce,on as we,oz as Te,pP as Ee,pz as De,qN as Oe,r as R,rP as ke,rz as Ae,sP as je,sn as Me,sz as Ne,t as z,tP as B,tz as Pe,uP as Fe,un as Ie,uz as Le,vP as Re,vz as ze,wP as Be,xP as Ve,yP as He,yz as Ue}from"./api-Cpjr7qvl.js";import{t as V}from"./button-CbwCr9Pi.js";import{$ as We,At as Ge,Dt as Ke,Et as H,Ot as qe,Q as U,V as Je,X as Ye,Z as Xe,et as Ze,jt as W,kt as Qe,q as G,t as $e,ut as K}from"./index-c5j0e823.js";import{t as et}from"./localePickerView-C2RmOS86.js";import{t as tt}from"./TimezoneCombobox-eEhKbenA.js";var q=t(e(),1),J=n();function nt({className:e,checked:t,onCheckedChange:n,disabled:r,...i}){return(0,J.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":t,"data-state":t?`checked`:`unchecked`,disabled:r,onClick:()=>n(!t),className:R(`peer inline-flex h-5 w-9 shrink-0 items-center rounded-full border border-transparent transition-colors outline-none`,`focus-visible:ring-2 focus-visible:ring-ring/50`,`disabled:cursor-not-allowed disabled:opacity-50`,t?`bg-primary`:`bg-input`,e),...i,children:(0,J.jsx)(`span`,{className:R(`pointer-events-none block size-4 rounded-full bg-background shadow transition-transform`,t?`translate-x-[18px]`:`translate-x-[2px]`)})})}var Y=[{id:`messages`,label:()=>F()},{id:`composer`,label:()=>o()},{id:`sidebar`,label:()=>I()},{id:`notifications`,label:()=>E()},{id:`other`,label:()=>g()}],X={showSource:{category:`messages`,label:()=>c(),help:()=>u()},showReport:{category:`messages`,label:()=>ie(),help:()=>Be()},copyAssistant:{category:`messages`,label:()=>s()},copyUser:{category:`messages`,label:()=>ne()},showDelete:{category:`messages`,label:()=>Ve()},showTools:{category:`messages`,label:()=>he(),help:()=>He()},voiceInput:{category:`composer`,label:()=>Re(),help:()=>de()},showUsage:{category:`composer`,label:()=>k(),help:()=>j()},autoReadAloud:{category:`composer`,label:()=>d(),help:()=>ae()},showChatAge:{category:`sidebar`,label:()=>ye(),help:()=>Ee()},notifSound:{category:`notifications`,label:()=>x(),help:()=>Fe()},notifSystem:{category:`notifications`,label:()=>L(),help:()=>v()},replySound:{category:`notifications`,label:()=>je(),help:()=>Ce()}};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:()=>oe()};function ut({prefKey:e,ui:t}){let n=f(z.admin.setUiPrefDefault),i=f(z.admin.setFeatureEnabled),a=ct(e),o=a?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:w()}),(0,J.jsxs)(Ye,{value:ot(t.defaults[e]),onValueChange:t=>void n({key:e,value:st(t)}),children:[(0,J.jsx)(We,{size:`sm`,className:`w-36`,children:(0,J.jsx)(Ze,{})}),(0,J.jsxs)(Xe,{children:[(0,J.jsx)(U,{value:`on`,children:m()}),(0,J.jsx)(U,{value:`off`,children:Oe()}),(0,J.jsx)(U,{value:`inherit`,children:h()})]})]}),a?(0,J.jsxs)(`span`,{className:`oc-prefs__gov-gate`,children:[(0,J.jsx)(K,{checked:t.featuresEnabled[a]===!0,onCheckedChange:e=>void i({key:a,enabled:e===!0}),"aria-label":r()}),r()]}):null]}),o?(0,J.jsx)(`span`,{className:`oc-prefs__gov-help`,children:o}):null]})}function dt({current:e,enabled:t}){let n=f(z.me.setDictationShortcut),[r,i]=(0,q.useState)(!1),[a,o]=(0,q.useState)(!1);return(0,q.useEffect)(()=>{if(!r)return;let e=e=>{if(e.preventDefault(),e.stopPropagation(),e.key===`Escape`){i(!1);return}let t=Qe(e);if(t===null){[`Shift`,`Control`,`Meta`,`Alt`].includes(e.key)||(o(!0),window.setTimeout(()=>o(!1),1800));return}i(!1),n({shortcut:t})};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[r,n]),(0,J.jsxs)(`div`,{className:`oc-prefs__row${t?``:` is-locked`}`,children:[(0,J.jsxs)(`div`,{className:`oc-prefs__info`,children:[(0,J.jsxs)(`span`,{className:`oc-prefs__label`,children:[D(),e?(0,J.jsx)(H,{variant:`secondary`,children:Ge(e,qe())}):null]}),(0,J.jsx)(`span`,{className:`oc-prefs__help`,children:a?_e():r?Ie():S()})]}),(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:pe()}):null,(0,J.jsx)(`button`,{type:`button`,className:`oc-prefs__reset`,disabled:!t,"aria-pressed":r,onClick:()=>i(e=>!e),children:r?we():e?Me():y()})]})]})}function ft(){let[e,t]=(0,q.useState)(``),[n,r]=(0,q.useState)(!1),i=p(z.me.getMe,{host:G}),a=i?.ui,o=$(i?.role)&&n,s=f(z.me.setUiPref).withOptimisticUpdate(Je),c=(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)(K,{checked:n,onCheckedChange:e=>r(e===!0),"aria-label":B()}),B()]}):null,o?(0,J.jsxs)(`div`,{className:`oc-prefs__gov-head`,children:[(0,J.jsx)(`p`,{children:ee()}),(0,J.jsx)(`p`,{children:le()}),(0,J.jsx)(`p`,{children:ce()})]}):null,(0,J.jsx)(W,{value:e,onChange:e=>t(e.target.value),placeholder:_(),"aria-label":_(),className:`mb-2`}),c.length===0?(0,J.jsx)(`div`,{className:`oc-prefs__empty`,children:N()}):(0,J.jsx)(`div`,{className:`oc-prefs`,children:c.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],c=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)(H,{variant:`outline`,children:ke()}):l?(0,J.jsx)(H,{variant:`secondary`,children:ge()}):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 s({key:e,value:null}),children:xe()}):null,(0,J.jsx)(nt,{checked:c,disabled:i,onCheckedChange:t=>{e===`notifSystem`&&t&&typeof Notification<`u`&&Notification.permission==="default"&&Notification.requestPermission(),s({key:e,value:t})},"aria-label":n})]}),o?(0,J.jsx)(ut,{prefKey:e,ui:a}):null]},e)})]},e.id))}),(0,J.jsx)(dt,{current:i?.dictationShortcut??null,enabled:a.effective.voiceInput===!0})]}):(0,J.jsx)(`div`,{className:`oc-prefs__empty`,children:l()})}var pt={sm:()=>Ne(),md:()=>Te(),lg:()=>me(),xl:()=>P(),"2xl":()=>Ae(),"3xl":()=>Se()};function mt(){let e=p(z.me.getMe,{host:G}),t=f(z.me.setLocale),n=f(z.me.setTimezone),r=f(z.me.setFontScale).withOptimisticUpdate((e,{scale:t})=>{let n=e.getQuery(z.me.getMe,{host:G});n&&e.setQuery(z.me.getMe,{host:G},{...n,fontScale:t,resolvedFontScale:t??`md`})}),o=f(z.me.setMyName),s=Ke(),c=e?.locale??`default`,l=e?.name??``,[u,d]=(0,q.useState)(null),m=u??l,h=m.trim()!==l.trim();async function g(){try{await o({name:m}),d(null),s.success(M())}catch(e){s.error(be(),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:Ue()}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:ze()})]}),(0,J.jsxs)(`div`,{className:`oc-show__row`,children:[(0,J.jsx)(W,{className:`max-w-xs`,value:m,maxLength:120,placeholder:fe(),onChange:e=>d(e.target.value),onKeyDown:e=>{e.key===`Enter`&&h&&(e.preventDefault(),g())}}),(0,J.jsx)(V,{size:`sm`,disabled:!h,onClick:()=>void g(),children:a()})]}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:A()})]}),(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:De()}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:O()})]}),(0,J.jsxs)(`div`,{className:`oc-show__row`,children:[et().map(e=>(0,J.jsx)(V,{variant:c===e.value?`default`:`outline`,size:`sm`,onClick:()=>void t({locale:e.value}),children:e.label},e.value)),(0,J.jsx)(V,{variant:c==="default"?`default`:`outline`,size:`sm`,onClick:()=>void t({locale:null}),children:re()})]}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:C()})]}),(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:T()})]}),(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:i()})]}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:te()})]}),(0,J.jsxs)(`section`,{className:`oc-show__section`,children:[(0,J.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,J.jsx)(`h2`,{className:`oc-show__title`,children:Le()}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:ve()})]}),(0,J.jsx)(`div`,{className:`oc-show__row`,children:$e.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:b()})]}),(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:se()})]}),(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{$N as r,$R as i,AE as a,AP as o,CP as s,DP as c,Dz as l,EP as u,En as d,Fz as f,Iz as p,JN as m,KN as h,OP as g,QN as ee,QR as te,SP as ne,Sz as re,TP as ie,Tn as ae,XN as oe,XR as se,YN as ce,ZN as le,ZR as ue,_P as de,_z as fe,aP as _,an as pe,az as me,bP as he,bn as ge,cP as v,cn as y,cz as b,dP as x,dn as S,dz as C,eP as w,ez as T,fP as E,fn as D,fz as O,gP as k,gz as A,hP as j,hz as M,iP as N,iz as P,jP as F,kP as I,lP as L,ln as _e,lz as ve,mP as ye,mz as be,nP as xe,nz as Se,oP as Ce,on as we,oz as Te,pP as Ee,pz as De,qN as Oe,r as R,rP as ke,rz as Ae,sP as je,sn as Me,sz as Ne,t as z,tP as B,tz as Pe,uP as Fe,un as Ie,uz as Le,vP as Re,vz as ze,wP as Be,xP as Ve,yP as He,yz as Ue}from"./api-Cpjr7qvl.js";import{t as V}from"./button-CbwCr9Pi.js";import{$ as We,At as Ge,Dt as Ke,Et as H,Ot as qe,Q as U,V as Je,X as Ye,Z as Xe,et as Ze,jt as W,kt as Qe,q as G,t as $e,ut as K}from"./index-Bc3aF-kJ.js";import{t as et}from"./localePickerView-C2RmOS86.js";import{t as tt}from"./TimezoneCombobox-UX7uQX62.js";var q=t(e(),1),J=n();function nt({className:e,checked:t,onCheckedChange:n,disabled:r,...i}){return(0,J.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":t,"data-state":t?`checked`:`unchecked`,disabled:r,onClick:()=>n(!t),className:R(`peer inline-flex h-5 w-9 shrink-0 items-center rounded-full border border-transparent transition-colors outline-none`,`focus-visible:ring-2 focus-visible:ring-ring/50`,`disabled:cursor-not-allowed disabled:opacity-50`,t?`bg-primary`:`bg-input`,e),...i,children:(0,J.jsx)(`span`,{className:R(`pointer-events-none block size-4 rounded-full bg-background shadow transition-transform`,t?`translate-x-[18px]`:`translate-x-[2px]`)})})}var Y=[{id:`messages`,label:()=>F()},{id:`composer`,label:()=>o()},{id:`sidebar`,label:()=>I()},{id:`notifications`,label:()=>E()},{id:`other`,label:()=>g()}],X={showSource:{category:`messages`,label:()=>c(),help:()=>u()},showReport:{category:`messages`,label:()=>ie(),help:()=>Be()},copyAssistant:{category:`messages`,label:()=>s()},copyUser:{category:`messages`,label:()=>ne()},showDelete:{category:`messages`,label:()=>Ve()},showTools:{category:`messages`,label:()=>he(),help:()=>He()},voiceInput:{category:`composer`,label:()=>Re(),help:()=>de()},showUsage:{category:`composer`,label:()=>k(),help:()=>j()},autoReadAloud:{category:`composer`,label:()=>d(),help:()=>ae()},showChatAge:{category:`sidebar`,label:()=>ye(),help:()=>Ee()},notifSound:{category:`notifications`,label:()=>x(),help:()=>Fe()},notifSystem:{category:`notifications`,label:()=>L(),help:()=>v()},replySound:{category:`notifications`,label:()=>je(),help:()=>Ce()}};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:()=>oe()};function ut({prefKey:e,ui:t}){let n=f(z.admin.setUiPrefDefault),i=f(z.admin.setFeatureEnabled),a=ct(e),o=a?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:w()}),(0,J.jsxs)(Ye,{value:ot(t.defaults[e]),onValueChange:t=>void n({key:e,value:st(t)}),children:[(0,J.jsx)(We,{size:`sm`,className:`w-36`,children:(0,J.jsx)(Ze,{})}),(0,J.jsxs)(Xe,{children:[(0,J.jsx)(U,{value:`on`,children:m()}),(0,J.jsx)(U,{value:`off`,children:Oe()}),(0,J.jsx)(U,{value:`inherit`,children:h()})]})]}),a?(0,J.jsxs)(`span`,{className:`oc-prefs__gov-gate`,children:[(0,J.jsx)(K,{checked:t.featuresEnabled[a]===!0,onCheckedChange:e=>void i({key:a,enabled:e===!0}),"aria-label":r()}),r()]}):null]}),o?(0,J.jsx)(`span`,{className:`oc-prefs__gov-help`,children:o}):null]})}function dt({current:e,enabled:t}){let n=f(z.me.setDictationShortcut),[r,i]=(0,q.useState)(!1),[a,o]=(0,q.useState)(!1);return(0,q.useEffect)(()=>{if(!r)return;let e=e=>{if(e.preventDefault(),e.stopPropagation(),e.key===`Escape`){i(!1);return}let t=Qe(e);if(t===null){[`Shift`,`Control`,`Meta`,`Alt`].includes(e.key)||(o(!0),window.setTimeout(()=>o(!1),1800));return}i(!1),n({shortcut:t})};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[r,n]),(0,J.jsxs)(`div`,{className:`oc-prefs__row${t?``:` is-locked`}`,children:[(0,J.jsxs)(`div`,{className:`oc-prefs__info`,children:[(0,J.jsxs)(`span`,{className:`oc-prefs__label`,children:[D(),e?(0,J.jsx)(H,{variant:`secondary`,children:Ge(e,qe())}):null]}),(0,J.jsx)(`span`,{className:`oc-prefs__help`,children:a?_e():r?Ie():S()})]}),(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:pe()}):null,(0,J.jsx)(`button`,{type:`button`,className:`oc-prefs__reset`,disabled:!t,"aria-pressed":r,onClick:()=>i(e=>!e),children:r?we():e?Me():y()})]})]})}function ft(){let[e,t]=(0,q.useState)(``),[n,r]=(0,q.useState)(!1),i=p(z.me.getMe,{host:G}),a=i?.ui,o=$(i?.role)&&n,s=f(z.me.setUiPref).withOptimisticUpdate(Je),c=(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)(K,{checked:n,onCheckedChange:e=>r(e===!0),"aria-label":B()}),B()]}):null,o?(0,J.jsxs)(`div`,{className:`oc-prefs__gov-head`,children:[(0,J.jsx)(`p`,{children:ee()}),(0,J.jsx)(`p`,{children:le()}),(0,J.jsx)(`p`,{children:ce()})]}):null,(0,J.jsx)(W,{value:e,onChange:e=>t(e.target.value),placeholder:_(),"aria-label":_(),className:`mb-2`}),c.length===0?(0,J.jsx)(`div`,{className:`oc-prefs__empty`,children:N()}):(0,J.jsx)(`div`,{className:`oc-prefs`,children:c.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],c=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)(H,{variant:`outline`,children:ke()}):l?(0,J.jsx)(H,{variant:`secondary`,children:ge()}):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 s({key:e,value:null}),children:xe()}):null,(0,J.jsx)(nt,{checked:c,disabled:i,onCheckedChange:t=>{e===`notifSystem`&&t&&typeof Notification<`u`&&Notification.permission==="default"&&Notification.requestPermission(),s({key:e,value:t})},"aria-label":n})]}),o?(0,J.jsx)(ut,{prefKey:e,ui:a}):null]},e)})]},e.id))}),(0,J.jsx)(dt,{current:i?.dictationShortcut??null,enabled:a.effective.voiceInput===!0})]}):(0,J.jsx)(`div`,{className:`oc-prefs__empty`,children:l()})}var pt={sm:()=>Ne(),md:()=>Te(),lg:()=>me(),xl:()=>P(),"2xl":()=>Ae(),"3xl":()=>Se()};function mt(){let e=p(z.me.getMe,{host:G}),t=f(z.me.setLocale),n=f(z.me.setTimezone),r=f(z.me.setFontScale).withOptimisticUpdate((e,{scale:t})=>{let n=e.getQuery(z.me.getMe,{host:G});n&&e.setQuery(z.me.getMe,{host:G},{...n,fontScale:t,resolvedFontScale:t??`md`})}),o=f(z.me.setMyName),s=Ke(),c=e?.locale??`default`,l=e?.name??``,[u,d]=(0,q.useState)(null),m=u??l,h=m.trim()!==l.trim();async function g(){try{await o({name:m}),d(null),s.success(M())}catch(e){s.error(be(),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:Ue()}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:ze()})]}),(0,J.jsxs)(`div`,{className:`oc-show__row`,children:[(0,J.jsx)(W,{className:`max-w-xs`,value:m,maxLength:120,placeholder:fe(),onChange:e=>d(e.target.value),onKeyDown:e=>{e.key===`Enter`&&h&&(e.preventDefault(),g())}}),(0,J.jsx)(V,{size:`sm`,disabled:!h,onClick:()=>void g(),children:a()})]}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:A()})]}),(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:De()}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:O()})]}),(0,J.jsxs)(`div`,{className:`oc-show__row`,children:[et().map(e=>(0,J.jsx)(V,{variant:c===e.value?`default`:`outline`,size:`sm`,onClick:()=>void t({locale:e.value}),children:e.label},e.value)),(0,J.jsx)(V,{variant:c==="default"?`default`:`outline`,size:`sm`,onClick:()=>void t({locale:null}),children:re()})]}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:C()})]}),(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:T()})]}),(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:i()})]}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:te()})]}),(0,J.jsxs)(`section`,{className:`oc-show__section`,children:[(0,J.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,J.jsx)(`h2`,{className:`oc-show__title`,children:Le()}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:ve()})]}),(0,J.jsx)(`div`,{className:`oc-show__row`,children:$e.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:b()})]}),(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:se()})]}),(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{$_ as r,A_ as i,Av as a,D as o,D_ as s,Dv as c,Dz as l,F_ as u,Fv as d,Fz as f,G_ as p,Hh as m,Iv as h,Iz as g,J_ as ee,K_ as te,L_ as _,Lv as ne,M_ as v,N as re,N_ as y,Ov as b,P as ie,P_ as x,Q_ as S,R_ as ae,Sv as oe,U_ as se,W_ as C,X_ as ce,Y_ as le,Z_ as w,av as ue,bv as de,cv as T,ev as fe,fv as pe,gv as me,hv as E,iv as he,j_ as ge,jv as D,k_ as O,lv as k,mv as _e,nv as A,ov as ve,pv as ye,rv as be,sv as xe,t as j,tv as Se,uv as Ce,vv as we,wv as M,xv as Te,yv as Ee,z_ as De}from"./api-Cpjr7qvl.js";import{t as Oe}from"./list-CIbMtiOp.js";import{t as N}from"./button-CbwCr9Pi.js";import{A as ke,An as Ae,C as je,Cn as Me,D as P,Dt as Ne,E as Pe,Ft as Fe,Gn as Ie,It as Le,J as Re,Kn as ze,Lt as Be,Mn as Ve,Mt as He,Nn as Ue,Nt as We,O as F,On as I,P as Ge,Pt as L,S as Ke,T as qe,U as Je,Vn as Ye,W as Xe,Wn as R,Y as Ze,_ as Qe,_n as z,b as B,d as $e,f as et,g as V,h as H,j as U,jn as tt,jt as W,k as nt,kn as rt,m as it,p as at,un as ot,v as G,vn as K,w as st,wn as ct,x as q,xn as J,y as lt,yn as ut,zn as dt}from"./index-c5j0e823.js";var ft=o(`columns-3`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}]]),pt=o(`folder-input`,[[`path`,{d:`M2 9V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-1`,key:`fm4g5t`}],[`path`,{d:`M2 13h10`,key:`pgb2dq`}],[`path`,{d:`m9 16 3-3-3-3`,key:`6m91ic`}]]),mt=o(`layout-grid`,[[`rect`,{width:`7`,height:`7`,x:`3`,y:`3`,rx:`1`,key:`1g98yp`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`3`,rx:`1`,key:`6d4xhi`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`14`,rx:`1`,key:`nxv5o0`}],[`rect`,{width:`7`,height:`7`,x:`3`,y:`14`,rx:`1`,key:`1bb6yr`}]]),Y=o(`panel-left`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}]]),X=t(e(),1),Z=n();function ht({className:e}){return(0,Z.jsx)(Be,{asChild:!0,children:(0,Z.jsx)(N,{variant:`ghost`,size:`icon-xs`,"aria-label":u(),className:e,onClick:e=>e.stopPropagation(),onMouseDown:e=>e.stopPropagation(),onTouchStart:e=>e.stopPropagation(),onPointerDown:e=>e.stopPropagation(),children:(0,Z.jsx)(Ue,{})})})}function Q({folderId:e,name:t,color:n,currentParentId:r,className:a,onOpen:o}){let s=f(j.projects.renameProject),l=f(j.projects.setProjectColor),u=f(j.projects.moveProject),m=f(j.projects.deleteProject),ee=f(j.projects.createProject),te=Je(),v=Xe(),[re,y]=(0,X.useState)(!1),[b,ie]=(0,X.useState)(t),[S,C]=(0,X.useState)(!1),[ce,le]=(0,X.useState)(!1),w=g(j.projects.projectTreeCount,ce?{projectId:e}:`skip`);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(He,{onOpenChange:e=>e&&le(!0),children:[(0,Z.jsx)(ht,{className:a}),(0,Z.jsxs)(We,{align:`end`,className:`w-48`,onClick:e=>e.stopPropagation(),children:[(0,Z.jsxs)(L,{onSelect:()=>o(),children:[(0,Z.jsx)(Ae,{}),` `,we()]}),(0,Z.jsxs)(L,{onSelect:()=>{ie(t),y(!0)},children:[(0,Z.jsx)(ut,{}),` `,x()]}),(0,Z.jsxs)(L,{onSelect:()=>{requestAnimationFrame(async()=>{let t=await v({title:k(),label:ne(),placeholder:h(),confirmLabel:d()});t&&await ee({name:t,parentId:e})})},children:[(0,Z.jsx)(rt,{}),` `,k()]}),(0,Z.jsxs)(L,{onSelect:()=>C(!0),children:[(0,Z.jsx)(pt,{}),` `,p()]}),(0,Z.jsx)(Fe,{children:ge()}),(0,Z.jsxs)(`div`,{className:`oc-colorgrid`,onClick:e=>e.stopPropagation(),children:[(0,Z.jsx)(`button`,{className:`oc-colorgrid__none`,onClick:()=>void l({projectId:e,color:null}),"aria-label":i(),children:`✕`}),it.map(t=>(0,Z.jsx)(`button`,{className:`oc-colorgrid__dot`+(n===t.value?` is-selected`:``),style:{background:t.hue},"aria-label":t.value,onClick:()=>void l({projectId:e,color:t.value})},t.value))]}),(0,Z.jsx)(Le,{}),(0,Z.jsxs)(L,{variant:`destructive`,onSelect:()=>{requestAnimationFrame(async()=>{let n=w?.folders??0,r=w?.chats??0;await te({title:Te({name:t}),description:n>0?Ee({folders:n,chats:r}):r>0?de({count:r}):ae(),confirmWord:_(),confirmLabel:oe(),destructive:!0})&&await m({projectId:e})})},children:[(0,Z.jsx)(ot,{}),` `,_()]})]})]}),(0,Z.jsx)(Qe,{open:re,onOpenChange:y,title:c(),canSubmit:b.trim().length>0,onSubmit:async()=>{await s({projectId:e,name:b.trim()}),y(!1)},submitLabel:x(),children:(0,Z.jsx)(W,{value:b,onChange:e=>ie(e.target.value),autoFocus:!0})}),S?(0,Z.jsx)(at,{open:S,onOpenChange:C,title:se(),movingFolderId:e,currentId:r,onPick:t=>void u({projectId:e,parentId:t})}):null]})}function gt({chat:e,currentFolderId:t,className:n}){let r=f(j.chats.pinChat),i=f(j.chats.deleteChat),a=f(j.chats.renameChat),o=f(j.chats.setChatSidebar),c=f(j.chats.moveChatToProject),l=Je(),[u,d]=(0,X.useState)(!1),[p,m]=(0,X.useState)(e.title??``),[h,g]=(0,X.useState)(!1);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(He,{children:[(0,Z.jsx)(ht,{className:n}),(0,Z.jsxs)(We,{align:`end`,className:`w-52`,onClick:e=>e.stopPropagation(),children:[(0,Z.jsxs)(L,{onSelect:()=>{m(e.title??``),d(!0)},children:[(0,Z.jsx)(ut,{}),` `,x()]}),(0,Z.jsxs)(L,{onSelect:()=>void r({chatId:e._id,pinned:!e.pinned}),children:[e.pinned?(0,Z.jsx)(z,{}):(0,Z.jsx)(K,{}),e.pinned?y():v()]}),(0,Z.jsxs)(L,{onSelect:()=>g(!0),children:[(0,Z.jsx)(pt,{}),` `,te()]}),e.pinned&&e.inSidebar?null:(0,Z.jsxs)(L,{onSelect:()=>void o({chatId:e._id,hidden:e.inSidebar}),children:[e.inSidebar?(0,Z.jsx)(J,{}):(0,Z.jsx)(Y,{}),e.inSidebar?E():me()]}),(0,Z.jsx)(Le,{}),(0,Z.jsxs)(L,{variant:`destructive`,onSelect:()=>{requestAnimationFrame(async()=>{await l({title:O(),description:ae(),confirmLabel:_(),destructive:!0})&&await i({chatId:e._id})})},children:[(0,Z.jsx)(ot,{}),` `,_()]})]})]}),(0,Z.jsx)(Qe,{open:u,onOpenChange:d,title:s(),canSubmit:p.trim().length>0,onSubmit:async()=>{await a({chatId:e._id,title:p.trim()}),d(!1)},submitLabel:x(),children:(0,Z.jsx)(W,{value:p,onChange:e=>m(e.target.value),autoFocus:!0})}),h?(0,Z.jsx)(at,{open:h,onOpenChange:g,title:C(),currentId:t,onPick:t=>void c({chatId:e._id,projectId:t})}):null]})}function _t(e,t){let n=t.trim().toLowerCase();return n===``?e:e.filter(e=>(e.title??``).toLowerCase().includes(n))}function vt(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 yt(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 bt=`oc.projpage.view`;function xt(){let e=localStorage.getItem(bt);return e===`cards`||e===`list`?e:`columns`}var $=e=>`into:${e}`,St=e=>`col:${e??`null`}`,Ct=e=>`crumb:${e}`;function wt(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 Tt(){let{projectId:e}=ze({from:`/project/$projectId`}),t=R(),n=g(j.projects.projectPage,{projectId:e});return(0,Z.jsx)(`div`,{className:`oc-projpage`,children:n===void 0?(0,Z.jsx)(`p`,{className:`oc-projpage__hint`,children:l()}):n===null?(0,Z.jsxs)(`div`,{className:`oc-projpage__notfound`,children:[(0,Z.jsx)(`h2`,{children:w()}),(0,Z.jsx)(`p`,{className:`oc-projpage__hint`,children:ce()}),(0,Z.jsx)(N,{variant:`outline`,onClick:()=>void t({to:`/`}),children:le()})]}):(0,Z.jsx)(Et,{page:n})})}function Et({page:e}){let t=R(),n=Je(),a=Xe(),o=Ne(),s=f(j.projects.renameProject),l=f(j.projects.setProjectColor),u=f(j.projects.deleteProject),te=f(j.projects.createProject),v=f(j.projects.moveProject),y=f(j.projects.setProjectSidebar),C=f(j.chats.moveChatToProject),ce=f(j.chats.reorderChat),le=f(j.projects.reorderProject),w=g(j.projects.projectTreeCount,{projectId:e.project._id}),[T,me]=(0,X.useState)(xt),E=e=>{localStorage.setItem(bt,e),me(e)},O=g(j.projects.folderColumns,T===`columns`?{projectId:e.project._id}:`skip`),A=g(j.projects.projectTreeList,T===`list`?{projectId:e.project._id}:`skip`),{c:be}=Ie({from:`/project/$projectId`}),xe=g(j.projects.listProjects,{}),we=g(j.chatReads.myBusyChats,{}),M=(0,X.useMemo)(()=>new Set(we??[]),[we]),Ae=g(j.chatReads.myChatReads,{}),ze=(0,X.useMemo)(()=>yt(e.chats,Ae??[]),[e.chats,Ae]),{startNewChat:F,picker:Ye}=$e(e=>void t({to:`/chat/$chatId`,params:{chatId:e}})),[z,B]=(0,X.useState)(``),[et,H]=(0,X.useState)(!1),[U,K]=(0,X.useState)(e.project.name),[J,dt]=(0,X.useState)(!1),[Y,ht]=(0,X.useState)(``);(0,X.useEffect)(()=>{let e=setTimeout(()=>ht(z.trim()),180);return()=>clearTimeout(e)},[z]);let Q=g(j.search.searchConversations,Y.length>=2?{query:Y,projectId:e.project._id}:`skip`),gt=ke(nt(st,{activationConstraint:{distance:4}}),nt(qe,{activationConstraint:{delay:250,tolerance:8}})),$=(0,X.useRef)(!1),St=()=>{$.current=!0,setTimeout(()=>{$.current=!1},0)},[Ct,Tt]=(0,X.useState)(null),Et=t=>{if(t.startsWith(`chat:`)){let n=t.slice(5),r=e.chats.find(e=>e._id===n),i=O?.columns.flatMap(e=>e.chats).find(e=>e._id===n);return{kind:`chat`,label:(r??i)?.title||D()}}if(t.startsWith(`folder:`)){let e=t.slice(7);return{kind:`folder`,label:(xe??[]).find(t=>t._id===e)?.name??``}}return null},kt=e=>Tt(Et(String(e.active.id))),jt=(0,X.useCallback)(e=>{let t=String(e.active.id).startsWith(`folder:`),n=t=>({...e,droppableContainers:e.droppableContainers.filter(e=>String(e.id).startsWith(t))}),r=P(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=P(n(t?`folder:`:`chat:`));if(i.length>0)return i;let a=P(n(`crumb:`));if(a.length>0)return a;let o=P(n(`col:`));return o.length>0?o:Pe(n(t?`folder:`:`chat:`))},[]),Nt=t=>{if(T===`columns`){for(let e of O?.columns??[])if(e.chats.some(e=>e._id===t))return{list:e.chats,folderId:e.folderId};return null}if(T===`list`){let e=A?.chats.find(e=>e._id===t);return e?{list:A.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},Pt=t=>{if(T===`columns`){for(let e of O?.columns??[])if(e.folders.some(e=>e._id===t))return{list:e.folders,parentId:e.folderId};return null}if(T===`list`){let e=A?.folders.find(e=>e._id===t);if(!e||!A)return null;let n=e.parentId??A.rootId;return{list:Ze(A.folders,e.parentId),parentId:n}}return e.children.some(e=>e._id===t)?{list:e.children,parentId:e.project._id}:null},It=async e=>{Tt(null),St();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=wt(r);if(e!==void 0){if(a)await C({chatId:i.slice(5),projectId:e});else{let t=i.slice(7);if(t===e)return;if(!Re(xe??[],t,e)){o.error(Ce());return}await v({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=Nt(t);if(!n)return;n.list.some(t=>t._id===e)||await C({chatId:e,projectId:n.folderId});let a=vt(n.list,e=>e._id,e=>e.sortKey,e,t);a&&await ce({chatId:e,...a});return}if(!a&&r.startsWith(`folder:`)){let e=i.slice(7),t=r.slice(7);if(e===t)return;let n=Pt(t);if(!n)return;if(!n.list.some(t=>t._id===e)){if(!Re(xe??[],e,n.parentId)){o.error(Ce());return}await v({projectId:e,parentId:n.parentId})}let a=vt(n.list,e=>e._id,e=>e.sortKey,e,t);a&&await le({projectId:e,...a});return}}catch{o.error(Ce())}},[,Lt]=(0,X.useState)(0);(0,X.useEffect)(()=>{let e=window.setInterval(()=>Lt(e=>e+1),6e4);return()=>window.clearInterval(e)},[]);let Rt=Date.now(),zt=V(e.project),Bt=_t(e.chats,z),Vt=e.breadcrumb.slice(0,-1),Ht=e=>()=>{$.current||e()};return(0,Z.jsxs)(Ke,{sensors:gt,collisionDetection:jt,onDragStart:kt,onDragEnd:It,children:[(0,Z.jsxs)(`div`,{className:`oc-projpage__body`,style:{"--proj-hue":zt},children:[(0,Z.jsxs)(`nav`,{className:`oc-projpage__crumbs`,"aria-label":ee(),children:[Vt.map(e=>(0,Z.jsxs)(`span`,{className:`oc-projpage__crumb`,children:[(0,Z.jsx)(Dt,{folderId:e._id,children:(0,Z.jsx)(`button`,{type:`button`,className:`oc-projpage__crumblink`,onClick:Ht(()=>void t({to:`/project/$projectId`,params:{projectId:e._id}})),children:e.name})}),(0,Z.jsx)(`span`,{className:`oc-projpage__crumbsep`,"aria-hidden":!0,children:`›`})]},e._id)),(0,Z.jsx)(`span`,{className:`oc-projpage__crumbcur`,children:e.project.name})]}),(0,Z.jsxs)(`header`,{className:`oc-projpage__head`,children:[(0,Z.jsx)(`span`,{className:`oc-projpage__dot`,"aria-hidden":!0}),(0,Z.jsx)(`h1`,{className:`oc-projpage__title`,children:e.project.name}),e.project.sidebarHidden?(0,Z.jsxs)(N,{variant:`ghost`,size:`sm`,className:`oc-projpage__hiddenbadge`,title:ie(),onClick:()=>{y({projectId:e.project._id,hidden:!1})},children:[(0,Z.jsx)(Ve,{"aria-hidden":!0}),(0,Z.jsx)(`span`,{children:re()}),(0,Z.jsx)(tt,{"aria-hidden":!0})]}):null,(0,Z.jsxs)(`div`,{className:`oc-projpage__actions`,children:[(0,Z.jsxs)(`div`,{className:`oc-projpage__viewtoggle`,role:`group`,"aria-label":_e(),children:[(0,Z.jsx)(N,{variant:T===`cards`?`secondary`:`ghost`,size:`icon-sm`,"aria-label":_e(),title:_e(),"aria-pressed":T===`cards`,onClick:()=>E(`cards`),children:(0,Z.jsx)(mt,{})}),(0,Z.jsx)(N,{variant:T===`columns`?`secondary`:`ghost`,size:`icon-sm`,"aria-label":ye(),title:ye(),"aria-pressed":T===`columns`,onClick:()=>E(`columns`),children:(0,Z.jsx)(ft,{})}),(0,Z.jsx)(N,{variant:T===`list`?`secondary`:`ghost`,size:`icon-sm`,"aria-label":pe(),title:pe(),"aria-pressed":T===`list`,onClick:()=>E(`list`),children:(0,Z.jsx)(Oe,{})})]}),(0,Z.jsxs)(N,{variant:`outline`,size:`sm`,onClick:()=>void F({projectId:e.project._id}),children:[(0,Z.jsx)(ct,{}),he()]}),(0,Z.jsxs)(N,{variant:`outline`,size:`sm`,onClick:async()=>{let t=await a({title:k(),label:ne(),placeholder:h(),confirmLabel:d()});t&&await te({name:t,parentId:e.project._id})},children:[(0,Z.jsx)(rt,{}),k()]}),(0,Z.jsxs)(He,{children:[(0,Z.jsx)(Be,{asChild:!0,children:(0,Z.jsx)(N,{variant:`ghost`,size:`icon-sm`,"aria-label":b(),children:(0,Z.jsx)(Ue,{})})}),(0,Z.jsxs)(We,{align:`end`,className:`w-48`,children:[(0,Z.jsxs)(L,{onSelect:()=>{K(e.project.name),H(!0)},children:[(0,Z.jsx)(ut,{}),` `,x()]}),(0,Z.jsxs)(L,{onSelect:()=>dt(!0),children:[(0,Z.jsx)(pt,{}),` `,p()]}),(0,Z.jsx)(Fe,{children:ge()}),(0,Z.jsxs)(`div`,{className:`oc-colorgrid`,children:[(0,Z.jsx)(`button`,{className:`oc-colorgrid__none`,onClick:()=>void l({projectId:e.project._id,color:null}),"aria-label":i(),children:`✕`}),it.map(t=>(0,Z.jsx)(`button`,{className:`oc-colorgrid__dot`+(e.project.color===t.value?` is-selected`:``),style:{background:t.hue},"aria-label":t.value,onClick:()=>void l({projectId:e.project._id,color:t.value})},t.value))]}),(0,Z.jsx)(Le,{}),(0,Z.jsxs)(L,{variant:`destructive`,onSelect:()=>{let r=e.project.parentId;requestAnimationFrame(async()=>{let i=w?.folders??0,a=w?.chats??0;await n({title:Te({name:e.project.name}),description:i>0?Ee({folders:i,chats:a}):a>0?de({count:a}):ae(),confirmWord:_(),confirmLabel:oe(),destructive:!0})&&(await u({projectId:e.project._id}),t(r===null?{to:`/`}:{to:`/project/$projectId`,params:{projectId:r}}))})},children:[(0,Z.jsx)(ot,{}),` `,_()]})]})]})]})]}),T===`columns`?(0,Z.jsx)(Ft,{data:O,currentId:e.project._id,busyIds:M,suppressClick:$,locateChatId:be??null}):T===`list`?(0,Z.jsx)(Mt,{data:A,busyIds:M,suppressClick:$,locateChatId:be??null}):(0,Z.jsxs)(Z.Fragment,{children:[e.children.length>0?(0,Z.jsxs)(`section`,{className:`oc-projpage__section`,children:[(0,Z.jsx)(`h2`,{className:`oc-projpage__subtitle`,children:ve()}),(0,Z.jsx)(`div`,{className:`oc-projpage__cards`,children:(0,Z.jsx)(G,{items:e.children.map(e=>`folder:${e._id}`),strategy:lt,children:e.children.map(t=>(0,Z.jsx)(Ot,{child:t,parentId:e.project._id,now:Rt,suppressClick:$},t._id))})})]}):null,(0,Z.jsxs)(`section`,{className:`oc-projpage__section`,children:[(0,Z.jsxs)(`div`,{className:`oc-projpage__convhead`,children:[(0,Z.jsx)(`h2`,{className:`oc-projpage__subtitle`,children:ue()}),e.chats.length>0?(0,Z.jsx)(W,{value:z,onChange:e=>B(e.target.value),placeholder:Se(),className:`oc-projpage__filter`}):null]}),e.chats.length===0?(0,Z.jsx)(`p`,{className:`oc-projpage__hint`,children:e.children.length===0?r():S()}):Bt.length===0&&(Q??[]).length===0?(0,Z.jsx)(`p`,{className:`oc-projpage__hint`,children:fe({term:z.trim()})}):(0,Z.jsx)(`ul`,{className:`oc-projpage__chats`,children:(0,Z.jsx)(G,{items:Bt.map(e=>`chat:${e._id}`),strategy:q,children:Bt.map(t=>(0,Z.jsx)(At,{chat:t,currentFolderId:e.project._id,now:Rt,busy:M.has(t._id),unread:ze.has(t._id),locate:t._id===be,suppressClick:$},t._id))})})]}),Y.length>=2&&Q!==void 0?(0,Z.jsxs)(`section`,{className:`oc-projpage__section`,children:[(0,Z.jsx)(`h2`,{className:`oc-projpage__subtitle`,children:De()}),Q.length===0?(0,Z.jsx)(`p`,{className:`oc-projpage__hint`,children:fe({term:Y})}):(0,Z.jsx)(`ul`,{className:`oc-projpage__chats`,children:Q.map(e=>(0,Z.jsx)(`li`,{className:`oc-projpage__chatrow`,children:(0,Z.jsxs)(`button`,{type:`button`,className:`oc-projpage__chatbtn`,onClick:()=>{e.messageId&&Y&&Ge(e.messageId,Y),t({to:`/chat/$chatId`,params:{chatId:e.chatId},...e.messageId?{search:{m:e.messageId}}:{}})},children:[(0,Z.jsx)(Me,{size:13,"aria-hidden":!0,className:`oc-projpage__hitico`}),(0,Z.jsxs)(`span`,{className:`oc-projpage__hitbody`,children:[(0,Z.jsx)(`span`,{className:`oc-projpage__chattitle`,children:e.title||m()}),e.projectPath&&e.projectPath.length>1?(0,Z.jsx)(`span`,{className:`oc-projpage__hitpath`,children:e.projectPath.join(` › `)}):null,e.snippet?(0,Z.jsx)(`span`,{className:`oc-projpage__hitsnippet`,children:e.snippet}):null]})]})},`${e.chatId}:${e.messageId??`t`}`))})]}):null]}),(0,Z.jsx)(Qe,{open:et,onOpenChange:H,title:c(),canSubmit:U.trim().length>0,onSubmit:async()=>{await s({projectId:e.project._id,name:U.trim()}),H(!1)},submitLabel:x(),children:(0,Z.jsx)(W,{value:U,onChange:e=>K(e.target.value),autoFocus:!0})}),J?(0,Z.jsx)(at,{open:J,onOpenChange:dt,title:se(),movingFolderId:e.project._id,currentId:e.project.parentId,onPick:t=>void v({projectId:e.project._id,parentId:t})}):null,Ye]}),(0,Z.jsx)(je,{children:Ct?(0,Z.jsxs)(`div`,{className:`oc-projpage__dragghost`,children:[Ct.kind===`folder`?(0,Z.jsx)(I,{size:13,"aria-hidden":!0}):(0,Z.jsx)(Me,{size:13,"aria-hidden":!0}),(0,Z.jsx)(`span`,{children:Ct.label})]}):null})]})}function Dt({folderId:e,children:t}){let{setNodeRef:n,isOver:r}=F({id:Ct(e)});return(0,Z.jsx)(`span`,{ref:n,className:r?`oc-projpage__cdrop is-over`:`oc-projpage__cdrop`,children:t})}function Ot({child:e,parentId:t,now:n,suppressClick:r}){let i=R(),a=B({id:`folder:${e._id}`}),o=F({id:$(e._id)});return(0,Z.jsxs)(`div`,{ref:e=>{a.setNodeRef(e),o.setNodeRef(e)},className:`oc-projpage__card`+(o.isOver?` is-over`:``)+(a.isDragging?` is-dragging`:``),style:{"--proj-hue":V(e),transform:U.Transform.toString(a.transform),transition:a.transition},onClick:()=>{r.current||i({to:`/project/$projectId`,params:{projectId:e._id}})},onKeyDown:t=>{t.key===`Enter`&&i({to:`/project/$projectId`,params:{projectId:e._id}})},...a.listeners,...a.attributes,role:`link`,tabIndex:0,children:[(0,Z.jsxs)(`span`,{className:`oc-projpage__cardhead`,children:[(0,Z.jsx)(I,{size:15,"aria-hidden":!0,className:`oc-projpage__cardico`}),(0,Z.jsx)(`span`,{className:`oc-projpage__cardname`,children:e.name}),(0,Z.jsx)(Q,{folderId:e._id,name:e.name,color:e.color,currentParentId:t,className:`oc-projpage__cardmenu`,onOpen:()=>void i({to:`/project/$projectId`,params:{projectId:e._id}})})]}),(0,Z.jsxs)(`span`,{className:`oc-projpage__cardmeta`,children:[e.folderCount>0?be({count:e.folderCount})+` · `:``,A({count:e.recursiveChatCount})]}),e.lastActivityAt===null?null:(0,Z.jsx)(`span`,{className:`oc-projpage__cardage`,children:et(e.lastActivityAt,n)})]})}function kt({chat:e}){let t=f(j.chats.setChatSidebar),n=e.inSidebar?E():me();return(0,Z.jsx)(N,{variant:`ghost`,size:`icon-xs`,"aria-label":n,title:n,className:`oc-projpage__barbtn`+(e.inSidebar?` is-on`:``),disabled:e.pinned&&e.inSidebar,onClick:n=>{n.stopPropagation(),t({chatId:e._id,hidden:e.inSidebar})},children:e.inSidebar?(0,Z.jsx)(J,{}):(0,Z.jsx)(Y,{})})}function At({chat:e,currentFolderId:t,now:n,busy:r,unread:i,locate:o,suppressClick:s}){let c=R(),l=H(e.color),u=B({id:`chat:${e._id}`}),d=jt(o);return(0,Z.jsxs)(`li`,{ref:e=>{u.setNodeRef(e),d.current=e},className:`oc-projpage__chatrow`+(u.isDragging?` is-dragging`:``)+(o?` is-locate`:``),style:{transform:U.Transform.toString(u.transform),transition:u.transition},children:[(0,Z.jsxs)(`button`,{type:`button`,className:`oc-projpage__chatbtn`,onClick:()=>{s.current||c({to:`/chat/$chatId`,params:{chatId:e._id}})},...u.listeners,...u.attributes,children:[l?(0,Z.jsx)(`span`,{className:`oc-chatitem__dot`,style:{background:l}}):(0,Z.jsx)(`span`,{className:`oc-chatitem__dot oc-chatitem__dot--empty`}),(0,Z.jsx)(`span`,{className:`oc-projpage__chattitle`,children:e.title||D()}),e.pinned?(0,Z.jsx)(K,{size:12,"aria-hidden":!0,className:`oc-projpage__chatpin`}):null,(0,Z.jsx)(`span`,{className:`oc-projpage__chatage`,children:et(e.updatedAt,n)}),r?(0,Z.jsx)(`span`,{className:`oc-chatitem__busy`,title:a(),"aria-label":a()}):null,i&&!r?(0,Z.jsx)(`span`,{className:`oc-chatitem__unread`,title:M(),"aria-label":M()}):null]}),(0,Z.jsx)(kt,{chat:e}),(0,Z.jsx)(gt,{chat:e,currentFolderId:t,className:`oc-projpage__chatmenu`})]})}function jt(e){let t=(0,X.useRef)(null);return(0,X.useEffect)(()=>{e&&t.current&&t.current.scrollIntoView({block:`center`})},[e]),t}function Mt({data:e,busyIds:t,suppressClick:n,locateChatId:i}){let[a,o]=(0,X.useState)(new Set),s=(0,X.useMemo)(()=>{let t=new Map;for(let n of e?.chats??[]){let e=t.get(n.folderId);e===void 0?t.set(n.folderId,[n]):e.push(n)}return t},[e]);if(e===void 0)return(0,Z.jsx)(`p`,{className:`oc-projpage__hint`,children:l()});if(e===null)return null;let c=e=>o(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),u=(r,o)=>{let l=s.get(r??e.rootId)??[],d=Ze(e.folders,r);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(G,{items:l.map(e=>`chat:${e._id}`),strategy:q,children:l.map(e=>(0,Z.jsx)(Pt,{chat:e,depth:o,busy:t.has(e._id),locate:e._id===i,suppressClick:n},e._id))}),(0,Z.jsx)(G,{items:d.map(e=>`folder:${e._id}`),strategy:q,children:d.map(t=>(0,Z.jsx)(Nt,{folder:t,parentId:r??e.rootId,depth:o,folded:a.has(t._id),onToggle:()=>c(t._id),suppressClick:n,children:a.has(t._id)?null:u(t._id,o+1)},t._id))})]})};return(0,Z.jsx)(`div`,{className:`oc-projpage__tree`,children:(s.get(e.rootId)??[]).length===0&&Ze(e.folders,null).length===0?(0,Z.jsx)(`p`,{className:`oc-projpage__hint`,children:r()}):u(null,0)})}function Nt({folder:e,parentId:t,depth:n,folded:r,onToggle:i,suppressClick:a,children:o}){let s=R(),c=B({id:`folder:${e._id}`}),l=F({id:$(e._id)});return(0,Z.jsxs)(`div`,{className:`oc-projpage__treegroup`,children:[(0,Z.jsxs)(`div`,{ref:e=>{c.setNodeRef(e),l.setNodeRef(e)},className:`oc-projpage__treerow oc-projpage__treerow--folder`+(l.isOver?` is-over`:``)+(c.isDragging?` is-dragging`:``),style:{"--tree-depth":n,"--proj-hue":V(e),transform:U.Transform.toString(c.transform),transition:c.transition},...c.listeners,...c.attributes,role:`button`,tabIndex:0,onClick:()=>{a.current||s({to:`/project/$projectId`,params:{projectId:e._id}})},onKeyDown:t=>{t.key===`Enter`&&s({to:`/project/$projectId`,params:{projectId:e._id}})},children:[(0,Z.jsx)(`button`,{type:`button`,className:`oc-projpage__treechev`,"aria-label":r?T():xe(),"aria-expanded":!r,onClick:e=>{e.stopPropagation(),!a.current&&i()},onMouseDown:e=>e.stopPropagation(),onTouchStart:e=>e.stopPropagation(),children:r?(0,Z.jsx)(dt,{size:13}):(0,Z.jsx)(Ye,{size:13})}),(0,Z.jsx)(I,{size:13,"aria-hidden":!0,className:`oc-projpage__colico`}),(0,Z.jsx)(`span`,{className:`oc-projpage__colname`,children:e.name}),(0,Z.jsx)(Q,{folderId:e._id,name:e.name,color:e.color,currentParentId:t,className:`oc-projpage__treemenu`,onOpen:()=>void s({to:`/project/$projectId`,params:{projectId:e._id}})})]}),o]})}function Pt({chat:e,depth:t,busy:n,locate:r,suppressClick:i}){let a=R(),o=B({id:`chat:${e._id}`}),s=jt(r),c=H(e.color);return(0,Z.jsxs)(`div`,{ref:e=>{o.setNodeRef(e),s.current=e},className:`oc-projpage__treerow oc-projpage__treerow--chat`+(o.isDragging?` is-dragging`:``)+(r?` is-locate`:``),style:{"--tree-depth":t,transform:U.Transform.toString(o.transform),transition:o.transition},children:[(0,Z.jsxs)(`button`,{type:`button`,className:`oc-projpage__colchatbtn`,onClick:()=>{i.current||a({to:`/chat/$chatId`,params:{chatId:e._id}})},...o.listeners,...o.attributes,children:[c?(0,Z.jsx)(`span`,{className:`oc-chatitem__dot`,style:{background:c}}):(0,Z.jsx)(`span`,{className:`oc-chatitem__dot oc-chatitem__dot--empty`}),(0,Z.jsx)(`span`,{className:`oc-projpage__colname`,children:e.title||D()}),n?(0,Z.jsx)(`span`,{className:`oc-chatitem__busy`,"aria-hidden":!0}):null]}),(0,Z.jsx)(gt,{chat:e,currentFolderId:e.folderId,className:`oc-projpage__treemenu`}),(0,Z.jsx)(kt,{chat:e})]})}function Ft({data:e,currentId:t,busyIds:n,suppressClick:r,locateChatId:i}){let a=(0,X.useRef)(null);return(0,X.useEffect)(()=>{let e=a.current;e&&(e.scrollLeft=e.scrollWidth)},[e?.columns.length??0,t]),e===void 0?(0,Z.jsx)(`p`,{className:`oc-projpage__hint`,children:l()}):(0,Z.jsx)(`div`,{className:`oc-projpage__cols`,ref:a,children:e.columns.map((a,o)=>(0,Z.jsx)(It,{col:a,isLast:o===e.columns.length-1,currentId:t,busyIds:n,suppressClick:r,locateChatId:i},a.folderId??`root`))})}function It({col:e,isLast:t,currentId:n,busyIds:r,suppressClick:i,locateChatId:a}){let o=R(),s=F({id:St(e.folderId)});return(0,Z.jsxs)(`div`,{ref:s.setNodeRef,className:`oc-projpage__col`+(s.isOver?` is-over`:``)+(t?` is-last`:``),children:[(0,Z.jsx)(G,{items:e.folders.map(e=>`folder:${e._id}`),strategy:q,children:e.folders.map(t=>(0,Z.jsx)(Lt,{folder:t,parentId:e.folderId,isCurrent:t._id===n,suppressClick:i,onOpen:()=>void o({to:`/project/$projectId`,params:{projectId:t._id}})},t._id))}),(0,Z.jsx)(G,{items:e.chats.map(e=>`chat:${e._id}`),strategy:q,children:e.chats.map(t=>(0,Z.jsx)(Rt,{chat:t,folderId:e.folderId,busy:r.has(t._id),locate:t._id===a,suppressClick:i,onOpen:()=>void o({to:`/chat/$chatId`,params:{chatId:t._id}})},t._id))}),e.folders.length===0&&e.chats.length===0?(0,Z.jsx)(`p`,{className:`oc-projpage__colempty`,children:S()}):null]})}function Lt({folder:e,parentId:t,isCurrent:n,suppressClick:r,onOpen:i}){let a=B({id:`folder:${e._id}`}),o=F({id:$(e._id)});return(0,Z.jsxs)(`div`,{ref:e=>{a.setNodeRef(e),o.setNodeRef(e)},className:`oc-projpage__colentry oc-projpage__colentry--folder`+(e.selected||n?` is-selected`:``)+(o.isOver?` is-over`:``)+(a.isDragging?` is-dragging`:``),style:{"--proj-hue":V(e),transform:U.Transform.toString(a.transform),transition:a.transition},onClick:()=>{r.current||i()},onKeyDown:e=>{e.key===`Enter`&&e.target===e.currentTarget&&i()},...a.listeners,...a.attributes,role:`button`,tabIndex:0,children:[(0,Z.jsx)(I,{size:13,"aria-hidden":!0,className:`oc-projpage__colico`}),(0,Z.jsx)(`span`,{className:`oc-projpage__colname`,children:e.name}),(0,Z.jsx)(`span`,{className:`oc-projpage__colchev`,"aria-hidden":!0,children:`›`}),(0,Z.jsx)(Q,{folderId:e._id,name:e.name,color:e.color,currentParentId:t,className:`oc-projpage__colmenu`,onOpen:i})]})}function Rt({chat:e,folderId:t,busy:n,locate:r,suppressClick:i,onOpen:a}){let o=B({id:`chat:${e._id}`}),s=jt(r),c=H(e.color);return(0,Z.jsxs)(`div`,{ref:e=>{o.setNodeRef(e),s.current=e},className:`oc-projpage__colentry oc-projpage__colentry--chat`+(o.isDragging?` is-dragging`:``)+(r?` is-locate`:``),style:{transform:U.Transform.toString(o.transform),transition:o.transition},children:[(0,Z.jsxs)(`button`,{type:`button`,className:`oc-projpage__colchatbtn`,onClick:()=>{i.current||a()},...o.listeners,...o.attributes,children:[c?(0,Z.jsx)(`span`,{className:`oc-chatitem__dot`,style:{background:c}}):(0,Z.jsx)(`span`,{className:`oc-chatitem__dot oc-chatitem__dot--empty`}),(0,Z.jsx)(`span`,{className:`oc-projpage__colname`,children:e.title||D()}),n?(0,Z.jsx)(`span`,{className:`oc-chatitem__busy`,"aria-hidden":!0}):null]}),(0,Z.jsx)(gt,{chat:e,currentFolderId:t,className:`oc-projpage__colmenu oc-projpage__colmenu--chat`}),(0,Z.jsx)(kt,{chat:e})]})}export{Tt as ProjectPage};
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$_ as r,A_ as i,Av as a,D as o,D_ as s,Dv as c,Dz as l,F_ as u,Fv as d,Fz as f,G_ as p,Hh as m,Iv as h,Iz as g,J_ as ee,K_ as te,L_ as _,Lv as ne,M_ as v,N as re,N_ as y,Ov as b,P as ie,P_ as x,Q_ as S,R_ as ae,Sv as oe,U_ as se,W_ as C,X_ as ce,Y_ as le,Z_ as w,av as ue,bv as de,cv as T,ev as fe,fv as pe,gv as me,hv as E,iv as he,j_ as ge,jv as D,k_ as O,lv as k,mv as _e,nv as A,ov as ve,pv as ye,rv as be,sv as xe,t as j,tv as Se,uv as Ce,vv as we,wv as M,xv as Te,yv as Ee,z_ as De}from"./api-Cpjr7qvl.js";import{t as Oe}from"./list-CIbMtiOp.js";import{t as N}from"./button-CbwCr9Pi.js";import{A as ke,An as Ae,C as je,Cn as Me,D as P,Dt as Ne,E as Pe,Ft as Fe,Gn as Ie,It as Le,J as Re,Kn as ze,Lt as Be,Mn as Ve,Mt as He,Nn as Ue,Nt as We,O as F,On as I,P as Ge,Pt as L,S as Ke,T as qe,U as Je,Vn as Ye,W as Xe,Wn as R,Y as Ze,_ as Qe,_n as z,b as B,d as $e,f as et,g as V,h as H,j as U,jn as tt,jt as W,k as nt,kn as rt,m as it,p as at,un as ot,v as G,vn as K,w as st,wn as ct,x as q,xn as J,y as lt,yn as ut,zn as dt}from"./index-Bc3aF-kJ.js";var ft=o(`columns-3`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}]]),pt=o(`folder-input`,[[`path`,{d:`M2 9V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-1`,key:`fm4g5t`}],[`path`,{d:`M2 13h10`,key:`pgb2dq`}],[`path`,{d:`m9 16 3-3-3-3`,key:`6m91ic`}]]),mt=o(`layout-grid`,[[`rect`,{width:`7`,height:`7`,x:`3`,y:`3`,rx:`1`,key:`1g98yp`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`3`,rx:`1`,key:`6d4xhi`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`14`,rx:`1`,key:`nxv5o0`}],[`rect`,{width:`7`,height:`7`,x:`3`,y:`14`,rx:`1`,key:`1bb6yr`}]]),Y=o(`panel-left`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}]]),X=t(e(),1),Z=n();function ht({className:e}){return(0,Z.jsx)(Be,{asChild:!0,children:(0,Z.jsx)(N,{variant:`ghost`,size:`icon-xs`,"aria-label":u(),className:e,onClick:e=>e.stopPropagation(),onMouseDown:e=>e.stopPropagation(),onTouchStart:e=>e.stopPropagation(),onPointerDown:e=>e.stopPropagation(),children:(0,Z.jsx)(Ue,{})})})}function Q({folderId:e,name:t,color:n,currentParentId:r,className:a,onOpen:o}){let s=f(j.projects.renameProject),l=f(j.projects.setProjectColor),u=f(j.projects.moveProject),m=f(j.projects.deleteProject),ee=f(j.projects.createProject),te=Je(),v=Xe(),[re,y]=(0,X.useState)(!1),[b,ie]=(0,X.useState)(t),[S,C]=(0,X.useState)(!1),[ce,le]=(0,X.useState)(!1),w=g(j.projects.projectTreeCount,ce?{projectId:e}:`skip`);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(He,{onOpenChange:e=>e&&le(!0),children:[(0,Z.jsx)(ht,{className:a}),(0,Z.jsxs)(We,{align:`end`,className:`w-48`,onClick:e=>e.stopPropagation(),children:[(0,Z.jsxs)(L,{onSelect:()=>o(),children:[(0,Z.jsx)(Ae,{}),` `,we()]}),(0,Z.jsxs)(L,{onSelect:()=>{ie(t),y(!0)},children:[(0,Z.jsx)(ut,{}),` `,x()]}),(0,Z.jsxs)(L,{onSelect:()=>{requestAnimationFrame(async()=>{let t=await v({title:k(),label:ne(),placeholder:h(),confirmLabel:d()});t&&await ee({name:t,parentId:e})})},children:[(0,Z.jsx)(rt,{}),` `,k()]}),(0,Z.jsxs)(L,{onSelect:()=>C(!0),children:[(0,Z.jsx)(pt,{}),` `,p()]}),(0,Z.jsx)(Fe,{children:ge()}),(0,Z.jsxs)(`div`,{className:`oc-colorgrid`,onClick:e=>e.stopPropagation(),children:[(0,Z.jsx)(`button`,{className:`oc-colorgrid__none`,onClick:()=>void l({projectId:e,color:null}),"aria-label":i(),children:`✕`}),it.map(t=>(0,Z.jsx)(`button`,{className:`oc-colorgrid__dot`+(n===t.value?` is-selected`:``),style:{background:t.hue},"aria-label":t.value,onClick:()=>void l({projectId:e,color:t.value})},t.value))]}),(0,Z.jsx)(Le,{}),(0,Z.jsxs)(L,{variant:`destructive`,onSelect:()=>{requestAnimationFrame(async()=>{let n=w?.folders??0,r=w?.chats??0;await te({title:Te({name:t}),description:n>0?Ee({folders:n,chats:r}):r>0?de({count:r}):ae(),confirmWord:_(),confirmLabel:oe(),destructive:!0})&&await m({projectId:e})})},children:[(0,Z.jsx)(ot,{}),` `,_()]})]})]}),(0,Z.jsx)(Qe,{open:re,onOpenChange:y,title:c(),canSubmit:b.trim().length>0,onSubmit:async()=>{await s({projectId:e,name:b.trim()}),y(!1)},submitLabel:x(),children:(0,Z.jsx)(W,{value:b,onChange:e=>ie(e.target.value),autoFocus:!0})}),S?(0,Z.jsx)(at,{open:S,onOpenChange:C,title:se(),movingFolderId:e,currentId:r,onPick:t=>void u({projectId:e,parentId:t})}):null]})}function gt({chat:e,currentFolderId:t,className:n}){let r=f(j.chats.pinChat),i=f(j.chats.deleteChat),a=f(j.chats.renameChat),o=f(j.chats.setChatSidebar),c=f(j.chats.moveChatToProject),l=Je(),[u,d]=(0,X.useState)(!1),[p,m]=(0,X.useState)(e.title??``),[h,g]=(0,X.useState)(!1);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(He,{children:[(0,Z.jsx)(ht,{className:n}),(0,Z.jsxs)(We,{align:`end`,className:`w-52`,onClick:e=>e.stopPropagation(),children:[(0,Z.jsxs)(L,{onSelect:()=>{m(e.title??``),d(!0)},children:[(0,Z.jsx)(ut,{}),` `,x()]}),(0,Z.jsxs)(L,{onSelect:()=>void r({chatId:e._id,pinned:!e.pinned}),children:[e.pinned?(0,Z.jsx)(z,{}):(0,Z.jsx)(K,{}),e.pinned?y():v()]}),(0,Z.jsxs)(L,{onSelect:()=>g(!0),children:[(0,Z.jsx)(pt,{}),` `,te()]}),e.pinned&&e.inSidebar?null:(0,Z.jsxs)(L,{onSelect:()=>void o({chatId:e._id,hidden:e.inSidebar}),children:[e.inSidebar?(0,Z.jsx)(J,{}):(0,Z.jsx)(Y,{}),e.inSidebar?E():me()]}),(0,Z.jsx)(Le,{}),(0,Z.jsxs)(L,{variant:`destructive`,onSelect:()=>{requestAnimationFrame(async()=>{await l({title:O(),description:ae(),confirmLabel:_(),destructive:!0})&&await i({chatId:e._id})})},children:[(0,Z.jsx)(ot,{}),` `,_()]})]})]}),(0,Z.jsx)(Qe,{open:u,onOpenChange:d,title:s(),canSubmit:p.trim().length>0,onSubmit:async()=>{await a({chatId:e._id,title:p.trim()}),d(!1)},submitLabel:x(),children:(0,Z.jsx)(W,{value:p,onChange:e=>m(e.target.value),autoFocus:!0})}),h?(0,Z.jsx)(at,{open:h,onOpenChange:g,title:C(),currentId:t,onPick:t=>void c({chatId:e._id,projectId:t})}):null]})}function _t(e,t){let n=t.trim().toLowerCase();return n===``?e:e.filter(e=>(e.title??``).toLowerCase().includes(n))}function vt(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 yt(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 bt=`oc.projpage.view`;function xt(){let e=localStorage.getItem(bt);return e===`cards`||e===`list`?e:`columns`}var $=e=>`into:${e}`,St=e=>`col:${e??`null`}`,Ct=e=>`crumb:${e}`;function wt(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 Tt(){let{projectId:e}=ze({from:`/project/$projectId`}),t=R(),n=g(j.projects.projectPage,{projectId:e});return(0,Z.jsx)(`div`,{className:`oc-projpage`,children:n===void 0?(0,Z.jsx)(`p`,{className:`oc-projpage__hint`,children:l()}):n===null?(0,Z.jsxs)(`div`,{className:`oc-projpage__notfound`,children:[(0,Z.jsx)(`h2`,{children:w()}),(0,Z.jsx)(`p`,{className:`oc-projpage__hint`,children:ce()}),(0,Z.jsx)(N,{variant:`outline`,onClick:()=>void t({to:`/`}),children:le()})]}):(0,Z.jsx)(Et,{page:n})})}function Et({page:e}){let t=R(),n=Je(),a=Xe(),o=Ne(),s=f(j.projects.renameProject),l=f(j.projects.setProjectColor),u=f(j.projects.deleteProject),te=f(j.projects.createProject),v=f(j.projects.moveProject),y=f(j.projects.setProjectSidebar),C=f(j.chats.moveChatToProject),ce=f(j.chats.reorderChat),le=f(j.projects.reorderProject),w=g(j.projects.projectTreeCount,{projectId:e.project._id}),[T,me]=(0,X.useState)(xt),E=e=>{localStorage.setItem(bt,e),me(e)},O=g(j.projects.folderColumns,T===`columns`?{projectId:e.project._id}:`skip`),A=g(j.projects.projectTreeList,T===`list`?{projectId:e.project._id}:`skip`),{c:be}=Ie({from:`/project/$projectId`}),xe=g(j.projects.listProjects,{}),we=g(j.chatReads.myBusyChats,{}),M=(0,X.useMemo)(()=>new Set(we??[]),[we]),Ae=g(j.chatReads.myChatReads,{}),ze=(0,X.useMemo)(()=>yt(e.chats,Ae??[]),[e.chats,Ae]),{startNewChat:F,picker:Ye}=$e(e=>void t({to:`/chat/$chatId`,params:{chatId:e}})),[z,B]=(0,X.useState)(``),[et,H]=(0,X.useState)(!1),[U,K]=(0,X.useState)(e.project.name),[J,dt]=(0,X.useState)(!1),[Y,ht]=(0,X.useState)(``);(0,X.useEffect)(()=>{let e=setTimeout(()=>ht(z.trim()),180);return()=>clearTimeout(e)},[z]);let Q=g(j.search.searchConversations,Y.length>=2?{query:Y,projectId:e.project._id}:`skip`),gt=ke(nt(st,{activationConstraint:{distance:4}}),nt(qe,{activationConstraint:{delay:250,tolerance:8}})),$=(0,X.useRef)(!1),St=()=>{$.current=!0,setTimeout(()=>{$.current=!1},0)},[Ct,Tt]=(0,X.useState)(null),Et=t=>{if(t.startsWith(`chat:`)){let n=t.slice(5),r=e.chats.find(e=>e._id===n),i=O?.columns.flatMap(e=>e.chats).find(e=>e._id===n);return{kind:`chat`,label:(r??i)?.title||D()}}if(t.startsWith(`folder:`)){let e=t.slice(7);return{kind:`folder`,label:(xe??[]).find(t=>t._id===e)?.name??``}}return null},kt=e=>Tt(Et(String(e.active.id))),jt=(0,X.useCallback)(e=>{let t=String(e.active.id).startsWith(`folder:`),n=t=>({...e,droppableContainers:e.droppableContainers.filter(e=>String(e.id).startsWith(t))}),r=P(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=P(n(t?`folder:`:`chat:`));if(i.length>0)return i;let a=P(n(`crumb:`));if(a.length>0)return a;let o=P(n(`col:`));return o.length>0?o:Pe(n(t?`folder:`:`chat:`))},[]),Nt=t=>{if(T===`columns`){for(let e of O?.columns??[])if(e.chats.some(e=>e._id===t))return{list:e.chats,folderId:e.folderId};return null}if(T===`list`){let e=A?.chats.find(e=>e._id===t);return e?{list:A.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},Pt=t=>{if(T===`columns`){for(let e of O?.columns??[])if(e.folders.some(e=>e._id===t))return{list:e.folders,parentId:e.folderId};return null}if(T===`list`){let e=A?.folders.find(e=>e._id===t);if(!e||!A)return null;let n=e.parentId??A.rootId;return{list:Ze(A.folders,e.parentId),parentId:n}}return e.children.some(e=>e._id===t)?{list:e.children,parentId:e.project._id}:null},It=async e=>{Tt(null),St();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=wt(r);if(e!==void 0){if(a)await C({chatId:i.slice(5),projectId:e});else{let t=i.slice(7);if(t===e)return;if(!Re(xe??[],t,e)){o.error(Ce());return}await v({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=Nt(t);if(!n)return;n.list.some(t=>t._id===e)||await C({chatId:e,projectId:n.folderId});let a=vt(n.list,e=>e._id,e=>e.sortKey,e,t);a&&await ce({chatId:e,...a});return}if(!a&&r.startsWith(`folder:`)){let e=i.slice(7),t=r.slice(7);if(e===t)return;let n=Pt(t);if(!n)return;if(!n.list.some(t=>t._id===e)){if(!Re(xe??[],e,n.parentId)){o.error(Ce());return}await v({projectId:e,parentId:n.parentId})}let a=vt(n.list,e=>e._id,e=>e.sortKey,e,t);a&&await le({projectId:e,...a});return}}catch{o.error(Ce())}},[,Lt]=(0,X.useState)(0);(0,X.useEffect)(()=>{let e=window.setInterval(()=>Lt(e=>e+1),6e4);return()=>window.clearInterval(e)},[]);let Rt=Date.now(),zt=V(e.project),Bt=_t(e.chats,z),Vt=e.breadcrumb.slice(0,-1),Ht=e=>()=>{$.current||e()};return(0,Z.jsxs)(Ke,{sensors:gt,collisionDetection:jt,onDragStart:kt,onDragEnd:It,children:[(0,Z.jsxs)(`div`,{className:`oc-projpage__body`,style:{"--proj-hue":zt},children:[(0,Z.jsxs)(`nav`,{className:`oc-projpage__crumbs`,"aria-label":ee(),children:[Vt.map(e=>(0,Z.jsxs)(`span`,{className:`oc-projpage__crumb`,children:[(0,Z.jsx)(Dt,{folderId:e._id,children:(0,Z.jsx)(`button`,{type:`button`,className:`oc-projpage__crumblink`,onClick:Ht(()=>void t({to:`/project/$projectId`,params:{projectId:e._id}})),children:e.name})}),(0,Z.jsx)(`span`,{className:`oc-projpage__crumbsep`,"aria-hidden":!0,children:`›`})]},e._id)),(0,Z.jsx)(`span`,{className:`oc-projpage__crumbcur`,children:e.project.name})]}),(0,Z.jsxs)(`header`,{className:`oc-projpage__head`,children:[(0,Z.jsx)(`span`,{className:`oc-projpage__dot`,"aria-hidden":!0}),(0,Z.jsx)(`h1`,{className:`oc-projpage__title`,children:e.project.name}),e.project.sidebarHidden?(0,Z.jsxs)(N,{variant:`ghost`,size:`sm`,className:`oc-projpage__hiddenbadge`,title:ie(),onClick:()=>{y({projectId:e.project._id,hidden:!1})},children:[(0,Z.jsx)(Ve,{"aria-hidden":!0}),(0,Z.jsx)(`span`,{children:re()}),(0,Z.jsx)(tt,{"aria-hidden":!0})]}):null,(0,Z.jsxs)(`div`,{className:`oc-projpage__actions`,children:[(0,Z.jsxs)(`div`,{className:`oc-projpage__viewtoggle`,role:`group`,"aria-label":_e(),children:[(0,Z.jsx)(N,{variant:T===`cards`?`secondary`:`ghost`,size:`icon-sm`,"aria-label":_e(),title:_e(),"aria-pressed":T===`cards`,onClick:()=>E(`cards`),children:(0,Z.jsx)(mt,{})}),(0,Z.jsx)(N,{variant:T===`columns`?`secondary`:`ghost`,size:`icon-sm`,"aria-label":ye(),title:ye(),"aria-pressed":T===`columns`,onClick:()=>E(`columns`),children:(0,Z.jsx)(ft,{})}),(0,Z.jsx)(N,{variant:T===`list`?`secondary`:`ghost`,size:`icon-sm`,"aria-label":pe(),title:pe(),"aria-pressed":T===`list`,onClick:()=>E(`list`),children:(0,Z.jsx)(Oe,{})})]}),(0,Z.jsxs)(N,{variant:`outline`,size:`sm`,onClick:()=>void F({projectId:e.project._id}),children:[(0,Z.jsx)(ct,{}),he()]}),(0,Z.jsxs)(N,{variant:`outline`,size:`sm`,onClick:async()=>{let t=await a({title:k(),label:ne(),placeholder:h(),confirmLabel:d()});t&&await te({name:t,parentId:e.project._id})},children:[(0,Z.jsx)(rt,{}),k()]}),(0,Z.jsxs)(He,{children:[(0,Z.jsx)(Be,{asChild:!0,children:(0,Z.jsx)(N,{variant:`ghost`,size:`icon-sm`,"aria-label":b(),children:(0,Z.jsx)(Ue,{})})}),(0,Z.jsxs)(We,{align:`end`,className:`w-48`,children:[(0,Z.jsxs)(L,{onSelect:()=>{K(e.project.name),H(!0)},children:[(0,Z.jsx)(ut,{}),` `,x()]}),(0,Z.jsxs)(L,{onSelect:()=>dt(!0),children:[(0,Z.jsx)(pt,{}),` `,p()]}),(0,Z.jsx)(Fe,{children:ge()}),(0,Z.jsxs)(`div`,{className:`oc-colorgrid`,children:[(0,Z.jsx)(`button`,{className:`oc-colorgrid__none`,onClick:()=>void l({projectId:e.project._id,color:null}),"aria-label":i(),children:`✕`}),it.map(t=>(0,Z.jsx)(`button`,{className:`oc-colorgrid__dot`+(e.project.color===t.value?` is-selected`:``),style:{background:t.hue},"aria-label":t.value,onClick:()=>void l({projectId:e.project._id,color:t.value})},t.value))]}),(0,Z.jsx)(Le,{}),(0,Z.jsxs)(L,{variant:`destructive`,onSelect:()=>{let r=e.project.parentId;requestAnimationFrame(async()=>{let i=w?.folders??0,a=w?.chats??0;await n({title:Te({name:e.project.name}),description:i>0?Ee({folders:i,chats:a}):a>0?de({count:a}):ae(),confirmWord:_(),confirmLabel:oe(),destructive:!0})&&(await u({projectId:e.project._id}),t(r===null?{to:`/`}:{to:`/project/$projectId`,params:{projectId:r}}))})},children:[(0,Z.jsx)(ot,{}),` `,_()]})]})]})]})]}),T===`columns`?(0,Z.jsx)(Ft,{data:O,currentId:e.project._id,busyIds:M,suppressClick:$,locateChatId:be??null}):T===`list`?(0,Z.jsx)(Mt,{data:A,busyIds:M,suppressClick:$,locateChatId:be??null}):(0,Z.jsxs)(Z.Fragment,{children:[e.children.length>0?(0,Z.jsxs)(`section`,{className:`oc-projpage__section`,children:[(0,Z.jsx)(`h2`,{className:`oc-projpage__subtitle`,children:ve()}),(0,Z.jsx)(`div`,{className:`oc-projpage__cards`,children:(0,Z.jsx)(G,{items:e.children.map(e=>`folder:${e._id}`),strategy:lt,children:e.children.map(t=>(0,Z.jsx)(Ot,{child:t,parentId:e.project._id,now:Rt,suppressClick:$},t._id))})})]}):null,(0,Z.jsxs)(`section`,{className:`oc-projpage__section`,children:[(0,Z.jsxs)(`div`,{className:`oc-projpage__convhead`,children:[(0,Z.jsx)(`h2`,{className:`oc-projpage__subtitle`,children:ue()}),e.chats.length>0?(0,Z.jsx)(W,{value:z,onChange:e=>B(e.target.value),placeholder:Se(),className:`oc-projpage__filter`}):null]}),e.chats.length===0?(0,Z.jsx)(`p`,{className:`oc-projpage__hint`,children:e.children.length===0?r():S()}):Bt.length===0&&(Q??[]).length===0?(0,Z.jsx)(`p`,{className:`oc-projpage__hint`,children:fe({term:z.trim()})}):(0,Z.jsx)(`ul`,{className:`oc-projpage__chats`,children:(0,Z.jsx)(G,{items:Bt.map(e=>`chat:${e._id}`),strategy:q,children:Bt.map(t=>(0,Z.jsx)(At,{chat:t,currentFolderId:e.project._id,now:Rt,busy:M.has(t._id),unread:ze.has(t._id),locate:t._id===be,suppressClick:$},t._id))})})]}),Y.length>=2&&Q!==void 0?(0,Z.jsxs)(`section`,{className:`oc-projpage__section`,children:[(0,Z.jsx)(`h2`,{className:`oc-projpage__subtitle`,children:De()}),Q.length===0?(0,Z.jsx)(`p`,{className:`oc-projpage__hint`,children:fe({term:Y})}):(0,Z.jsx)(`ul`,{className:`oc-projpage__chats`,children:Q.map(e=>(0,Z.jsx)(`li`,{className:`oc-projpage__chatrow`,children:(0,Z.jsxs)(`button`,{type:`button`,className:`oc-projpage__chatbtn`,onClick:()=>{e.messageId&&Y&&Ge(e.messageId,Y),t({to:`/chat/$chatId`,params:{chatId:e.chatId},...e.messageId?{search:{m:e.messageId}}:{}})},children:[(0,Z.jsx)(Me,{size:13,"aria-hidden":!0,className:`oc-projpage__hitico`}),(0,Z.jsxs)(`span`,{className:`oc-projpage__hitbody`,children:[(0,Z.jsx)(`span`,{className:`oc-projpage__chattitle`,children:e.title||m()}),e.projectPath&&e.projectPath.length>1?(0,Z.jsx)(`span`,{className:`oc-projpage__hitpath`,children:e.projectPath.join(` › `)}):null,e.snippet?(0,Z.jsx)(`span`,{className:`oc-projpage__hitsnippet`,children:e.snippet}):null]})]})},`${e.chatId}:${e.messageId??`t`}`))})]}):null]}),(0,Z.jsx)(Qe,{open:et,onOpenChange:H,title:c(),canSubmit:U.trim().length>0,onSubmit:async()=>{await s({projectId:e.project._id,name:U.trim()}),H(!1)},submitLabel:x(),children:(0,Z.jsx)(W,{value:U,onChange:e=>K(e.target.value),autoFocus:!0})}),J?(0,Z.jsx)(at,{open:J,onOpenChange:dt,title:se(),movingFolderId:e.project._id,currentId:e.project.parentId,onPick:t=>void v({projectId:e.project._id,parentId:t})}):null,Ye]}),(0,Z.jsx)(je,{children:Ct?(0,Z.jsxs)(`div`,{className:`oc-projpage__dragghost`,children:[Ct.kind===`folder`?(0,Z.jsx)(I,{size:13,"aria-hidden":!0}):(0,Z.jsx)(Me,{size:13,"aria-hidden":!0}),(0,Z.jsx)(`span`,{children:Ct.label})]}):null})]})}function Dt({folderId:e,children:t}){let{setNodeRef:n,isOver:r}=F({id:Ct(e)});return(0,Z.jsx)(`span`,{ref:n,className:r?`oc-projpage__cdrop is-over`:`oc-projpage__cdrop`,children:t})}function Ot({child:e,parentId:t,now:n,suppressClick:r}){let i=R(),a=B({id:`folder:${e._id}`}),o=F({id:$(e._id)});return(0,Z.jsxs)(`div`,{ref:e=>{a.setNodeRef(e),o.setNodeRef(e)},className:`oc-projpage__card`+(o.isOver?` is-over`:``)+(a.isDragging?` is-dragging`:``),style:{"--proj-hue":V(e),transform:U.Transform.toString(a.transform),transition:a.transition},onClick:()=>{r.current||i({to:`/project/$projectId`,params:{projectId:e._id}})},onKeyDown:t=>{t.key===`Enter`&&i({to:`/project/$projectId`,params:{projectId:e._id}})},...a.listeners,...a.attributes,role:`link`,tabIndex:0,children:[(0,Z.jsxs)(`span`,{className:`oc-projpage__cardhead`,children:[(0,Z.jsx)(I,{size:15,"aria-hidden":!0,className:`oc-projpage__cardico`}),(0,Z.jsx)(`span`,{className:`oc-projpage__cardname`,children:e.name}),(0,Z.jsx)(Q,{folderId:e._id,name:e.name,color:e.color,currentParentId:t,className:`oc-projpage__cardmenu`,onOpen:()=>void i({to:`/project/$projectId`,params:{projectId:e._id}})})]}),(0,Z.jsxs)(`span`,{className:`oc-projpage__cardmeta`,children:[e.folderCount>0?be({count:e.folderCount})+` · `:``,A({count:e.recursiveChatCount})]}),e.lastActivityAt===null?null:(0,Z.jsx)(`span`,{className:`oc-projpage__cardage`,children:et(e.lastActivityAt,n)})]})}function kt({chat:e}){let t=f(j.chats.setChatSidebar),n=e.inSidebar?E():me();return(0,Z.jsx)(N,{variant:`ghost`,size:`icon-xs`,"aria-label":n,title:n,className:`oc-projpage__barbtn`+(e.inSidebar?` is-on`:``),disabled:e.pinned&&e.inSidebar,onClick:n=>{n.stopPropagation(),t({chatId:e._id,hidden:e.inSidebar})},children:e.inSidebar?(0,Z.jsx)(J,{}):(0,Z.jsx)(Y,{})})}function At({chat:e,currentFolderId:t,now:n,busy:r,unread:i,locate:o,suppressClick:s}){let c=R(),l=H(e.color),u=B({id:`chat:${e._id}`}),d=jt(o);return(0,Z.jsxs)(`li`,{ref:e=>{u.setNodeRef(e),d.current=e},className:`oc-projpage__chatrow`+(u.isDragging?` is-dragging`:``)+(o?` is-locate`:``),style:{transform:U.Transform.toString(u.transform),transition:u.transition},children:[(0,Z.jsxs)(`button`,{type:`button`,className:`oc-projpage__chatbtn`,onClick:()=>{s.current||c({to:`/chat/$chatId`,params:{chatId:e._id}})},...u.listeners,...u.attributes,children:[l?(0,Z.jsx)(`span`,{className:`oc-chatitem__dot`,style:{background:l}}):(0,Z.jsx)(`span`,{className:`oc-chatitem__dot oc-chatitem__dot--empty`}),(0,Z.jsx)(`span`,{className:`oc-projpage__chattitle`,children:e.title||D()}),e.pinned?(0,Z.jsx)(K,{size:12,"aria-hidden":!0,className:`oc-projpage__chatpin`}):null,(0,Z.jsx)(`span`,{className:`oc-projpage__chatage`,children:et(e.updatedAt,n)}),r?(0,Z.jsx)(`span`,{className:`oc-chatitem__busy`,title:a(),"aria-label":a()}):null,i&&!r?(0,Z.jsx)(`span`,{className:`oc-chatitem__unread`,title:M(),"aria-label":M()}):null]}),(0,Z.jsx)(kt,{chat:e}),(0,Z.jsx)(gt,{chat:e,currentFolderId:t,className:`oc-projpage__chatmenu`})]})}function jt(e){let t=(0,X.useRef)(null);return(0,X.useEffect)(()=>{e&&t.current&&t.current.scrollIntoView({block:`center`})},[e]),t}function Mt({data:e,busyIds:t,suppressClick:n,locateChatId:i}){let[a,o]=(0,X.useState)(new Set),s=(0,X.useMemo)(()=>{let t=new Map;for(let n of e?.chats??[]){let e=t.get(n.folderId);e===void 0?t.set(n.folderId,[n]):e.push(n)}return t},[e]);if(e===void 0)return(0,Z.jsx)(`p`,{className:`oc-projpage__hint`,children:l()});if(e===null)return null;let c=e=>o(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),u=(r,o)=>{let l=s.get(r??e.rootId)??[],d=Ze(e.folders,r);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(G,{items:l.map(e=>`chat:${e._id}`),strategy:q,children:l.map(e=>(0,Z.jsx)(Pt,{chat:e,depth:o,busy:t.has(e._id),locate:e._id===i,suppressClick:n},e._id))}),(0,Z.jsx)(G,{items:d.map(e=>`folder:${e._id}`),strategy:q,children:d.map(t=>(0,Z.jsx)(Nt,{folder:t,parentId:r??e.rootId,depth:o,folded:a.has(t._id),onToggle:()=>c(t._id),suppressClick:n,children:a.has(t._id)?null:u(t._id,o+1)},t._id))})]})};return(0,Z.jsx)(`div`,{className:`oc-projpage__tree`,children:(s.get(e.rootId)??[]).length===0&&Ze(e.folders,null).length===0?(0,Z.jsx)(`p`,{className:`oc-projpage__hint`,children:r()}):u(null,0)})}function Nt({folder:e,parentId:t,depth:n,folded:r,onToggle:i,suppressClick:a,children:o}){let s=R(),c=B({id:`folder:${e._id}`}),l=F({id:$(e._id)});return(0,Z.jsxs)(`div`,{className:`oc-projpage__treegroup`,children:[(0,Z.jsxs)(`div`,{ref:e=>{c.setNodeRef(e),l.setNodeRef(e)},className:`oc-projpage__treerow oc-projpage__treerow--folder`+(l.isOver?` is-over`:``)+(c.isDragging?` is-dragging`:``),style:{"--tree-depth":n,"--proj-hue":V(e),transform:U.Transform.toString(c.transform),transition:c.transition},...c.listeners,...c.attributes,role:`button`,tabIndex:0,onClick:()=>{a.current||s({to:`/project/$projectId`,params:{projectId:e._id}})},onKeyDown:t=>{t.key===`Enter`&&s({to:`/project/$projectId`,params:{projectId:e._id}})},children:[(0,Z.jsx)(`button`,{type:`button`,className:`oc-projpage__treechev`,"aria-label":r?T():xe(),"aria-expanded":!r,onClick:e=>{e.stopPropagation(),!a.current&&i()},onMouseDown:e=>e.stopPropagation(),onTouchStart:e=>e.stopPropagation(),children:r?(0,Z.jsx)(dt,{size:13}):(0,Z.jsx)(Ye,{size:13})}),(0,Z.jsx)(I,{size:13,"aria-hidden":!0,className:`oc-projpage__colico`}),(0,Z.jsx)(`span`,{className:`oc-projpage__colname`,children:e.name}),(0,Z.jsx)(Q,{folderId:e._id,name:e.name,color:e.color,currentParentId:t,className:`oc-projpage__treemenu`,onOpen:()=>void s({to:`/project/$projectId`,params:{projectId:e._id}})})]}),o]})}function Pt({chat:e,depth:t,busy:n,locate:r,suppressClick:i}){let a=R(),o=B({id:`chat:${e._id}`}),s=jt(r),c=H(e.color);return(0,Z.jsxs)(`div`,{ref:e=>{o.setNodeRef(e),s.current=e},className:`oc-projpage__treerow oc-projpage__treerow--chat`+(o.isDragging?` is-dragging`:``)+(r?` is-locate`:``),style:{"--tree-depth":t,transform:U.Transform.toString(o.transform),transition:o.transition},children:[(0,Z.jsxs)(`button`,{type:`button`,className:`oc-projpage__colchatbtn`,onClick:()=>{i.current||a({to:`/chat/$chatId`,params:{chatId:e._id}})},...o.listeners,...o.attributes,children:[c?(0,Z.jsx)(`span`,{className:`oc-chatitem__dot`,style:{background:c}}):(0,Z.jsx)(`span`,{className:`oc-chatitem__dot oc-chatitem__dot--empty`}),(0,Z.jsx)(`span`,{className:`oc-projpage__colname`,children:e.title||D()}),n?(0,Z.jsx)(`span`,{className:`oc-chatitem__busy`,"aria-hidden":!0}):null]}),(0,Z.jsx)(gt,{chat:e,currentFolderId:e.folderId,className:`oc-projpage__treemenu`}),(0,Z.jsx)(kt,{chat:e})]})}function Ft({data:e,currentId:t,busyIds:n,suppressClick:r,locateChatId:i}){let a=(0,X.useRef)(null);return(0,X.useEffect)(()=>{let e=a.current;e&&(e.scrollLeft=e.scrollWidth)},[e?.columns.length??0,t]),e===void 0?(0,Z.jsx)(`p`,{className:`oc-projpage__hint`,children:l()}):(0,Z.jsx)(`div`,{className:`oc-projpage__cols`,ref:a,children:e.columns.map((a,o)=>(0,Z.jsx)(It,{col:a,isLast:o===e.columns.length-1,currentId:t,busyIds:n,suppressClick:r,locateChatId:i},a.folderId??`root`))})}function It({col:e,isLast:t,currentId:n,busyIds:r,suppressClick:i,locateChatId:a}){let o=R(),s=F({id:St(e.folderId)});return(0,Z.jsxs)(`div`,{ref:s.setNodeRef,className:`oc-projpage__col`+(s.isOver?` is-over`:``)+(t?` is-last`:``),children:[(0,Z.jsx)(G,{items:e.folders.map(e=>`folder:${e._id}`),strategy:q,children:e.folders.map(t=>(0,Z.jsx)(Lt,{folder:t,parentId:e.folderId,isCurrent:t._id===n,suppressClick:i,onOpen:()=>void o({to:`/project/$projectId`,params:{projectId:t._id}})},t._id))}),(0,Z.jsx)(G,{items:e.chats.map(e=>`chat:${e._id}`),strategy:q,children:e.chats.map(t=>(0,Z.jsx)(Rt,{chat:t,folderId:e.folderId,busy:r.has(t._id),locate:t._id===a,suppressClick:i,onOpen:()=>void o({to:`/chat/$chatId`,params:{chatId:t._id}})},t._id))}),e.folders.length===0&&e.chats.length===0?(0,Z.jsx)(`p`,{className:`oc-projpage__colempty`,children:S()}):null]})}function Lt({folder:e,parentId:t,isCurrent:n,suppressClick:r,onOpen:i}){let a=B({id:`folder:${e._id}`}),o=F({id:$(e._id)});return(0,Z.jsxs)(`div`,{ref:e=>{a.setNodeRef(e),o.setNodeRef(e)},className:`oc-projpage__colentry oc-projpage__colentry--folder`+(e.selected||n?` is-selected`:``)+(o.isOver?` is-over`:``)+(a.isDragging?` is-dragging`:``),style:{"--proj-hue":V(e),transform:U.Transform.toString(a.transform),transition:a.transition},onClick:()=>{r.current||i()},onKeyDown:e=>{e.key===`Enter`&&e.target===e.currentTarget&&i()},...a.listeners,...a.attributes,role:`button`,tabIndex:0,children:[(0,Z.jsx)(I,{size:13,"aria-hidden":!0,className:`oc-projpage__colico`}),(0,Z.jsx)(`span`,{className:`oc-projpage__colname`,children:e.name}),(0,Z.jsx)(`span`,{className:`oc-projpage__colchev`,"aria-hidden":!0,children:`›`}),(0,Z.jsx)(Q,{folderId:e._id,name:e.name,color:e.color,currentParentId:t,className:`oc-projpage__colmenu`,onOpen:i})]})}function Rt({chat:e,folderId:t,busy:n,locate:r,suppressClick:i,onOpen:a}){let o=B({id:`chat:${e._id}`}),s=jt(r),c=H(e.color);return(0,Z.jsxs)(`div`,{ref:e=>{o.setNodeRef(e),s.current=e},className:`oc-projpage__colentry oc-projpage__colentry--chat`+(o.isDragging?` is-dragging`:``)+(r?` is-locate`:``),style:{transform:U.Transform.toString(o.transform),transition:o.transition},children:[(0,Z.jsxs)(`button`,{type:`button`,className:`oc-projpage__colchatbtn`,onClick:()=>{i.current||a()},...o.listeners,...o.attributes,children:[c?(0,Z.jsx)(`span`,{className:`oc-chatitem__dot`,style:{background:c}}):(0,Z.jsx)(`span`,{className:`oc-chatitem__dot oc-chatitem__dot--empty`}),(0,Z.jsx)(`span`,{className:`oc-projpage__colname`,children:e.title||D()}),n?(0,Z.jsx)(`span`,{className:`oc-chatitem__busy`,"aria-hidden":!0}):null]}),(0,Z.jsx)(gt,{chat:e,currentFolderId:t,className:`oc-projpage__colmenu oc-projpage__colmenu--chat`}),(0,Z.jsx)(kt,{chat:e})]})}export{Tt as ProjectPage};
@@ -1,4 +1,4 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$a as r,A as i,Ab as a,Ba as o,Bb as s,Bs as c,Fb as l,Fz as u,Gb as d,Ha as f,Hb as p,Hs as m,Ib as h,Iz as g,Kb as _,Lb as ee,Mb as te,Nb as ne,Ob as re,Pb as ie,Qa as v,Rb as y,Ua as b,Ub as x,Us as S,Va as C,Vb as w,Vs as ae,Wb as oe,Xa as se,Za as ce,di as T,ex as E,jb as D,kb as O,li as k,qb as A,t as j,tx as M,ui as N,za as P,zb as F,zs as I}from"./api-Cpjr7qvl.js";import{i as L,n as R,r as z,t as B}from"./FieldLabel-Bbe-KIdW.js";import{t as V}from"./button-CbwCr9Pi.js";import{$ as H,Dt as U,Q as W,Qt as G,X as K,Xt as le,Yt as q,Z as J,Zt as ue,et as Y,q as de,ut as fe}from"./index-c5j0e823.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:p,help:w},documentary_fetch:{label:s,help:F},inbound_files:{label:y,help:ee},history_summary:{label:S,help:m},file_curation:{label:r,help:b},quote_reply:{label:v,help:ce}},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{$a as r,A as i,Ab as a,Ba as o,Bb as s,Bs as c,Fb as l,Fz as u,Gb as d,Ha as f,Hb as p,Hs as m,Ib as h,Iz as g,Kb as _,Lb as ee,Mb as te,Nb as ne,Ob as re,Pb as ie,Qa as v,Rb as y,Ua as b,Ub as x,Us as S,Va as C,Vb as w,Vs as ae,Wb as oe,Xa as se,Za as ce,di as T,ex as E,jb as D,kb as O,li as k,qb as A,t as j,tx as M,ui as N,za as P,zb as F,zs as I}from"./api-Cpjr7qvl.js";import{i as L,n as R,r as z,t as B}from"./FieldLabel-Bww3UDFn.js";import{t as V}from"./button-CbwCr9Pi.js";import{$ as H,Dt as U,Q as W,Qt as G,X as K,Xt as le,Yt as q,Z as J,Zt as ue,et as Y,q as de,ut as fe}from"./index-Bc3aF-kJ.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:p,help:w},documentary_fetch:{label:s,help:F},inbound_files:{label:y,help:ee},history_summary:{label:S,help:m},file_curation:{label:r,help:b},quote_reply:{label:v,help:ce}},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:a,references:O,files:re,previous_summary:ae,new_messages:c,max_chars:I,file_name:f,budget_chars:C,feedback:o,content:P,excerpt:se};function _e(){let e=g(j.admin.listInstances,{}),[t,n]=(0,Q.useState)(null);if(e===void 0)return(0,$.jsx)(`div`,{className:`oc-settings__tab-loading`,"aria-busy":`true`});if(e.length===0)return(0,$.jsx)(`div`,{className:`oc-injtab`,children:(0,$.jsx)(`p`,{className:`oc-admin__hint`,children:l()})});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:A(),help:_()}),(0,$.jsxs)(`label`,{className:`oc-injtab__picker`,children:[(0,$.jsx)(`span`,{children:h()}),(0,$.jsxs)(K,{value:r._id,onValueChange:e=>n(e),children:[(0,$.jsx)(H,{size:`sm`,className:`min-w-44`,children:(0,$.jsx)(Y,{})}),(0,$.jsx)(J,{children:e.map(e=>(0,$.jsx)(W,{value:e._id,children:e.displayName??e.name},e._id))})]})]})]}),(0,$.jsx)(ve,{instance:r},r._id)]})}function ve({instance:e}){let t=u(j.admin.upsertInstanceConfig),n=U(),r=g(j.me.getMe,{host:de}),i=e.config??{},a=X(e.config?.contentLocale,r?.defaultLocale??void 0),[o,s]=(0,Q.useState)(()=>L(i,a));(0,Q.useEffect)(()=>{s(L(i,a))},[a,e._id]);let[c,l]=(0,Q.useState)(!1),d=o.promptInjections,f=(e,t)=>s({...o,promptInjections:{...d,[e]:{...d[e],...t}}});async function p(){l(!0);try{await t({instanceId:e._id,config:z(o,i,a)})}catch(e){n.error(E(),e)}finally{l(!1)}}async function m(r){let i={...e.config??{}};r==="default"?delete i.contentLocale:i.contentLocale=r;try{await t({instanceId:e._id,config:i})}catch(e){n.error(E(),e)}}let h=e.config?.contentLocale??`default`,_=Z[X(void 0,r?.defaultLocale??void 0)];return(0,$.jsxs)(`div`,{className:`oc-injtab__body`,children:[(0,$.jsxs)(`div`,{className:`oc-injtab__content-locale`,children:[(0,$.jsx)(`span`,{children:T()}),(0,$.jsxs)(K,{value:h,onValueChange:e=>void m(e),children:[(0,$.jsx)(H,{size:`sm`,className:`min-w-44`,children:(0,$.jsx)(Y,{})}),(0,$.jsxs)(J,{children:[(0,$.jsx)(W,{value:`default`,children:k({locale:_})}),pe().map(e=>(0,$.jsx)(W,{value:e.value,children:e.label},e.value))]})]}),(0,$.jsx)(`p`,{className:`oc-admin__hint`,children:N()})]}),le.map(e=>(0,$.jsx)(ye,{injKey:e,def:q[e],i18n:me[e],row:d[e]??{enabled:!0,template:q[e].defaultTemplate[a]},contentLocale:a,onChange:t=>f(e,t)},e)),(0,$.jsx)(`div`,{className:`oc-injtab__actions`,children:(0,$.jsx)(V,{size:`sm`,onClick:()=>void p(),disabled:c,children:M()})})]})}function ye({injKey:e,def:t,i18n:n,row:r,contentLocale:a,onChange:o}){let[s,c]=(0,Q.useState)(!1),l=r.template.trim()!==t.defaultTemplate[a],u=t.togglable&&!r.enabled,f=Object.fromEntries(t.placeholders.map(e=>[e,he[e]??`{${e}}`])),p=ue(e,r,a),m=p?G(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)(fe,{checked:r.enabled,onCheckedChange:e=>o({enabled:e===!0})}),(0,$.jsx)(R,{label:n.label(),help:n.help()})]}):(0,$.jsx)(R,{label:n.label(),help:n.help()}),l&&(0,$.jsx)(`span`,{className:`oc-injection__badge`,children:oe()})]}),(0,$.jsx)(`textarea`,{className:`oc-injcard__text`,value:r.template,disabled:u,rows:8,spellCheck:!1,onChange:e=>o({template:e.target.value})}),(0,$.jsxs)(`div`,{className:`oc-injection__foot`,children:[(0,$.jsxs)(`div`,{className:`oc-injcard__phs`,children:[(0,$.jsx)(`span`,{className:`oc-injection__ph`,children:x()}),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:()=>c(e=>!e),children:s?ne():ie()}),l&&(0,$.jsx)(V,{variant:`ghost`,size:`sm`,onClick:()=>o({template:t.defaultTemplate[a]}),children:d()})]})]}),s&&(0,$.jsx)(`div`,{className:`oc-injcard__preview`,children:m?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`pre`,{className:`oc-injcard__previewtext`,children:m}),(0,$.jsx)(`span`,{className:`oc-injection__ph`,children:te()}),t.pluralDefaultTemplate!==void 0&&!u?(0,$.jsx)(`span`,{className:`oc-injection__ph`,children:i()}):null]}):(0,$.jsx)(`span`,{className:`oc-injection__ph`,children:D()})})]})}export{_e as PromptInjectionsTab};
@@ -1 +1 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{Aw as r,Bw as i,Co as a,Cw as ee,Dw as te,Ew as o,Fw as s,Fz as c,Gw as l,Hw as u,Iw as d,Iz as f,Lw as p,Mw as ne,Nw as m,Ow as h,Pw as g,Rw as _,Sw as v,Tw as y,Uw as b,Vw as x,Ww as S,_w as re,aw as ie,bw as ae,cw as C,gw as w,iw as T,jw as E,kw as D,lw as O,nw as k,ow as A,rw as j,sw as M,t as N,uw as P,vw as F,ww as I,xw as L,yw as R,zw as z}from"./api-Cpjr7qvl.js";import{t as B}from"./button-CbwCr9Pi.js";import{Dt as V,Et as H,Tn as U,U as W,_ as G,jt as K,ut as q}from"./index-c5j0e823.js";import{t as J}from"./roleDescriptions-CF4LmoIL.js";var Y=t(e(),1),X=n(),Z=[{group:()=>l(),keys:[{key:`traces.read`,label:()=>i()},{key:`traces.read.content`,label:()=>z(),phi:!0},{key:`traces.write`,label:()=>_()}]},{group:()=>S(),keys:[{key:`kpi.read`,label:()=>i()},{key:`kpi.write`,label:()=>_()}]},{group:()=>b(),keys:[{key:`openclaw.query`,label:()=>p()},{key:`anomalies.read`,label:()=>d()},{key:`anomalies.report`,label:()=>s()}]},{group:()=>u(),keys:[{key:`chats.read`,label:()=>i()},{key:`selfheal`,label:()=>m()},{key:`feedback.respond`,label:()=>a()}]},{group:()=>x(),keys:[{key:`admin.manage`,label:()=>g()}]}],oe=Z.flatMap(e=>e.keys.map(e=>e.key));function Q(e){return e.includes(`*`)}var $={key:``,name:``,description:``};function se(){let e=f(N.apiKeys.listRoles,{}),t=c(N.apiKeys.createRole),n=c(N.apiKeys.ensureRolesSeeded),i=c(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))}),a=W(),s=V(),[l,u]=(0,Y.useState)(!1),[d,p]=(0,Y.useState)($),[m,g]=(0,Y.useState)(new Set);(0,Y.useEffect)(()=>{n({}).catch(e=>{s.error(E(),e)})},[n,s]);let _=e??[];async function b(e,t){if(Q(e.permissions))return;if(e.builtin){await a({title:r({name:e.name}),description:D(),confirmLabel:h()});return}if(m.has(e._id))return;let n=e.permissions.includes(t)?e.permissions.filter(e=>e!==t):[...e.permissions,t];g(t=>new Set(t).add(e._id));try{await i({roleId:e._id,permissions:n})}catch(e){s.error(te(),e)}finally{g(t=>{let n=new Set(t);return n.delete(e._id),n})}}async function x(){try{await t({key:d.key,name:d.name,description:d.description||void 0,permissions:[]}),p($),u(!1)}catch(e){s.error(o(),e)}}let S=e===void 0,z=!S&&_.length===0;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`p`,{className:`oc-admin__hint`,children:[y(),` `,(0,X.jsx)(`code`,{children:`admin`}),` `,I(),` `,(0,X.jsx)(`code`,{children:`traces.read.content`}),` `,ee()]}),(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:v()}),(0,X.jsx)(`div`,{className:`oc-dt__bar-actions`,children:(0,X.jsx)(B,{size:`sm`,onClick:()=>{p($),u(!0)},children:L()})})]}),S?(0,X.jsx)(`p`,{className:`oc-admin__hint`,children:ae()}):z?(0,X.jsx)(`p`,{className:`oc-admin__hint`,children:R()}):(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:F()}),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?ne({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:_.map(e=>{let t=Q(e.permissions),n=m.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)(U,{}),` `,re()]}):(0,X.jsx)(H,{variant:`secondary`,children:w()})]}),J(e)?(0,X.jsx)(`p`,{className:`oc-matrix__roledesc`,children:J(e)}):null]}),oe.map(r=>(0,X.jsx)(`td`,{className:`oc-matrix__cell`,children:(0,X.jsx)(q,{checked:t||e.permissions.includes(r),disabled:t||n,"aria-label":`${e.key} · ${r}`,title:t?P():n?O():r,onCheckedChange:()=>void b(e,r)})},r))]},e.key)})})]})})]}),(0,X.jsx)(G,{open:l,onOpenChange:u,title:C(),description:M(),canSubmit:!!(d.key&&d.name),onSubmit:x,submitLabel:A(),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:ie()}),(0,X.jsx)(K,{value:d.key,placeholder:T(),onChange:e=>p({...d,key:e.target.value})})]}),(0,X.jsxs)(`label`,{className:`oc-field`,children:[(0,X.jsx)(`span`,{className:`oc-field__label`,children:j()}),(0,X.jsx)(K,{value:d.name,onChange:e=>p({...d,name:e.target.value})})]}),(0,X.jsxs)(`label`,{className:`oc-field`,children:[(0,X.jsx)(`span`,{className:`oc-field__label`,children:k()}),(0,X.jsx)(K,{value:d.description,onChange:e=>p({...d,description:e.target.value})})]})]})})]})}export{se as RolesTab};
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{Aw as r,Bw as i,Co as a,Cw as ee,Dw as te,Ew as o,Fw as s,Fz as c,Gw as l,Hw as u,Iw as d,Iz as f,Lw as p,Mw as ne,Nw as m,Ow as h,Pw as g,Rw as _,Sw as v,Tw as y,Uw as b,Vw as x,Ww as S,_w as re,aw as ie,bw as ae,cw as C,gw as w,iw as T,jw as E,kw as D,lw as O,nw as k,ow as A,rw as j,sw as M,t as N,uw as P,vw as F,ww as I,xw as L,yw as R,zw as z}from"./api-Cpjr7qvl.js";import{t as B}from"./button-CbwCr9Pi.js";import{Dt as V,Et as H,Tn as U,U as W,_ as G,jt as K,ut as q}from"./index-Bc3aF-kJ.js";import{t as J}from"./roleDescriptions-CF4LmoIL.js";var Y=t(e(),1),X=n(),Z=[{group:()=>l(),keys:[{key:`traces.read`,label:()=>i()},{key:`traces.read.content`,label:()=>z(),phi:!0},{key:`traces.write`,label:()=>_()}]},{group:()=>S(),keys:[{key:`kpi.read`,label:()=>i()},{key:`kpi.write`,label:()=>_()}]},{group:()=>b(),keys:[{key:`openclaw.query`,label:()=>p()},{key:`anomalies.read`,label:()=>d()},{key:`anomalies.report`,label:()=>s()}]},{group:()=>u(),keys:[{key:`chats.read`,label:()=>i()},{key:`selfheal`,label:()=>m()},{key:`feedback.respond`,label:()=>a()}]},{group:()=>x(),keys:[{key:`admin.manage`,label:()=>g()}]}],oe=Z.flatMap(e=>e.keys.map(e=>e.key));function Q(e){return e.includes(`*`)}var $={key:``,name:``,description:``};function se(){let e=f(N.apiKeys.listRoles,{}),t=c(N.apiKeys.createRole),n=c(N.apiKeys.ensureRolesSeeded),i=c(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))}),a=W(),s=V(),[l,u]=(0,Y.useState)(!1),[d,p]=(0,Y.useState)($),[m,g]=(0,Y.useState)(new Set);(0,Y.useEffect)(()=>{n({}).catch(e=>{s.error(E(),e)})},[n,s]);let _=e??[];async function b(e,t){if(Q(e.permissions))return;if(e.builtin){await a({title:r({name:e.name}),description:D(),confirmLabel:h()});return}if(m.has(e._id))return;let n=e.permissions.includes(t)?e.permissions.filter(e=>e!==t):[...e.permissions,t];g(t=>new Set(t).add(e._id));try{await i({roleId:e._id,permissions:n})}catch(e){s.error(te(),e)}finally{g(t=>{let n=new Set(t);return n.delete(e._id),n})}}async function x(){try{await t({key:d.key,name:d.name,description:d.description||void 0,permissions:[]}),p($),u(!1)}catch(e){s.error(o(),e)}}let S=e===void 0,z=!S&&_.length===0;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`p`,{className:`oc-admin__hint`,children:[y(),` `,(0,X.jsx)(`code`,{children:`admin`}),` `,I(),` `,(0,X.jsx)(`code`,{children:`traces.read.content`}),` `,ee()]}),(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:v()}),(0,X.jsx)(`div`,{className:`oc-dt__bar-actions`,children:(0,X.jsx)(B,{size:`sm`,onClick:()=>{p($),u(!0)},children:L()})})]}),S?(0,X.jsx)(`p`,{className:`oc-admin__hint`,children:ae()}):z?(0,X.jsx)(`p`,{className:`oc-admin__hint`,children:R()}):(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:F()}),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?ne({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:_.map(e=>{let t=Q(e.permissions),n=m.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)(U,{}),` `,re()]}):(0,X.jsx)(H,{variant:`secondary`,children:w()})]}),J(e)?(0,X.jsx)(`p`,{className:`oc-matrix__roledesc`,children:J(e)}):null]}),oe.map(r=>(0,X.jsx)(`td`,{className:`oc-matrix__cell`,children:(0,X.jsx)(q,{checked:t||e.permissions.includes(r),disabled:t||n,"aria-label":`${e.key} · ${r}`,title:t?P():n?O():r,onCheckedChange:()=>void b(e,r)})},r))]},e.key)})})]})})]}),(0,X.jsx)(G,{open:l,onOpenChange:u,title:C(),description:M(),canSubmit:!!(d.key&&d.name),onSubmit:x,submitLabel:A(),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:ie()}),(0,X.jsx)(K,{value:d.key,placeholder:T(),onChange:e=>p({...d,key:e.target.value})})]}),(0,X.jsxs)(`label`,{className:`oc-field`,children:[(0,X.jsx)(`span`,{className:`oc-field__label`,children:j()}),(0,X.jsx)(K,{value:d.name,onChange:e=>p({...d,name:e.target.value})})]}),(0,X.jsxs)(`label`,{className:`oc-field`,children:[(0,X.jsx)(`span`,{className:`oc-field__label`,children:k()}),(0,X.jsx)(K,{value:d.description,onChange:e=>p({...d,description:e.target.value})})]})]})})]})}export{se as RolesTab};
@@ -1 +1 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$L as r,AL as i,BI as a,CI as o,CL as s,D as c,DI as l,DL as u,Dz as d,EI as f,GI as p,HI as m,Iz as h,JI as g,KI as ee,LI as te,ML as ne,Nz as _,OL as re,QI as ie,QL as ae,RI as v,SI as oe,SL as se,TI as ce,TL as le,UI as ue,VI as de,WI as fe,XI as pe,XL as me,YI as y,ZI as he,ZL as ge,_I as _e,_L as ve,aL as ye,aR as be,bI as xe,bL as Se,cL as Ce,cR as we,dI as Te,dL as Ee,dR as De,eR as Oe,fI as ke,fL as Ae,gI as je,hI as Me,iI as Ne,iL as Pe,iR as Fe,jL as Ie,kL as Le,kz as b,lL as Re,lR as ze,mI as Be,mL as Ve,nR as He,oL as Ue,oR as We,pI as Ge,qI as x,rL as Ke,rR as qe,sL as Je,sR as Ye,t as S,tR as Xe,uI as Ze,uL as Qe,uR as $e,vI as et,vL as tt,wI as nt,wL as rt,xI as it,xL as at,yI as ot,yL as st,zI as ct}from"./api-Cpjr7qvl.js";import{t as lt}from"./list-CIbMtiOp.js";import{t as C}from"./button-CbwCr9Pi.js";import{$ as w,Bn as T,Bt as ut,Ct as dt,Dt as ft,En as pt,Et as E,Q as D,Rt as O,St as mt,Tt as ht,X as k,Z as A,_t as gt,at as _t,bn as vt,bt as yt,et as j,gn as bt,gt as xt,it as St,jt as Ct,mn as wt,nt as Tt,on as Et,ot as Dt,q as Ot,rt as kt,tt as At,un as jt,vt as Mt,wt as Nt,xt as Pt,yn as Ft,yt as It,zn as M,zt as N}from"./index-c5j0e823.js";import{a as Lt,i as P,n as Rt,o as zt,r as F,t as Bt}from"./table-CeTqDEfs.js";import{t as Vt}from"./FilterBar-BO7_dR0d.js";/* empty css */import{a as Ht,c as I,i as L,l as Ut,n as Wt,o as Gt,r as Kt,s as qt,t as Jt,u as R}from"./TimezoneCombobox-eEhKbenA.js";var Yt=c(`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`}]]),Xt=c(`history`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M12 7v5l4 2`,key:`1fdv2h`}]]),z=t(e(),1),B=n();function V(e){try{let t=new Intl.DateTimeFormat(e,{weekday:`narrow`});return Array.from({length:7},(e,n)=>t.format(new Date(2024,0,1+n)))}catch{return[`M`,`T`,`W`,`T`,`F`,`S`,`S`]}}function Zt({value:e,onChange:t}){let n=Ut(e),r=(0,z.useMemo)(()=>new Date,[]),[i,a]=(0,z.useState)(()=>({year:n?.year??r.getFullYear(),month:n?.month??r.getMonth()})),[o,s]=(0,z.useState)(!1),c=(0,z.useMemo)(()=>V(b()),[]),l=(0,z.useMemo)(()=>new Intl.DateTimeFormat(b(),{month:`long`,year:`numeric`}),[]),u=(0,z.useMemo)(()=>new Intl.DateTimeFormat(b(),{dateStyle:`medium`,timeStyle:`short`}),[]),d=I(i.year,i.month),f=n?.hour??9,p=n?.minute??0,m=(e,n,r,i,a)=>t(R(e,n,r,i,a)),h=(e,t,n)=>{a({year:e,month:t}),m(e,t,n,f,p)},ee=e=>{let t=new Date(i.year,i.month+e,1);a({year:t.getFullYear(),month:t.getMonth()})},te=n===null?he():u.format(new Date(n.year,n.month,n.day,n.hour,n.minute));return(0,B.jsxs)(O,{modal:!0,open:o,onOpenChange:s,children:[(0,B.jsx)(ut,{asChild:!0,children:(0,B.jsxs)(`button`,{type:`button`,className:`oc-dtp__trigger`,"aria-label":ie(),children:[(0,B.jsx)(Yt,{size:14,"aria-hidden":!0,className:`oc-dtp__icon`}),(0,B.jsx)(`span`,{className:n===null?`oc-dtp__placeholder`:void 0,children:te})]})}),(0,B.jsxs)(N,{align:`start`,className:`oc-dtp__pop`,children:[(0,B.jsxs)(`div`,{className:`oc-dtp__head`,children:[(0,B.jsx)(`button`,{type:`button`,className:`oc-dtp__nav`,"aria-label":pe(),onClick:()=>ee(-1),children:(0,B.jsx)(T,{size:15,"aria-hidden":!0})}),(0,B.jsx)(`span`,{className:`oc-dtp__month`,children:l.format(new Date(i.year,i.month,1))}),(0,B.jsx)(`button`,{type:`button`,className:`oc-dtp__nav`,"aria-label":y(),onClick:()=>ee(1),children:(0,B.jsx)(M,{size:15,"aria-hidden":!0})})]}),(0,B.jsxs)(`div`,{className:`oc-dtp__grid`,children:[c.map((e,t)=>(0,B.jsx)(`span`,{className:`oc-dtp__wd`,children:e},t)),d.map((e,t)=>{let i=n!==null&&n.year===e.year&&n.month===e.month&&n.day===e.day,a=r.getFullYear()===e.year&&r.getMonth()===e.month&&r.getDate()===e.day;return(0,B.jsx)(`button`,{type:`button`,className:`oc-dtp__day`+(e.inMonth?``:` oc-dtp__day--out`)+(i?` oc-dtp__day--sel`:``)+(a&&!i?` oc-dtp__day--today`:``),onClick:()=>h(e.year,e.month,e.day),children:e.day},t)})]}),(0,B.jsxs)(`div`,{className:`oc-dtp__time`,children:[(0,B.jsxs)(k,{value:String(f),onValueChange:e=>m(i.year,i.month,n?.day??r.getDate(),Number(e),p),children:[(0,B.jsx)(w,{size:`sm`,"aria-label":g(),children:(0,B.jsx)(j,{})}),(0,B.jsx)(A,{className:`oc-dtp__timeopts`,children:Array.from({length:24},(e,t)=>(0,B.jsx)(D,{value:String(t),children:String(t).padStart(2,`0`)},t))})]}),(0,B.jsx)(`span`,{className:`oc-dtp__colon`,children:`:`}),(0,B.jsxs)(k,{value:String(p),onValueChange:e=>m(i.year,i.month,n?.day??r.getDate(),f,Number(e)),children:[(0,B.jsx)(w,{size:`sm`,"aria-label":x(),children:(0,B.jsx)(j,{})}),(0,B.jsx)(A,{className:`oc-dtp__timeopts`,children:Array.from({length:60},(e,t)=>(0,B.jsx)(D,{value:String(t),children:String(t).padStart(2,`0`)},t))})]})]})]})]})}function H(e){let t=new Date(e),n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())}`}function Qt(e,t,n){let r=e=>String(e).padStart(2,`0`);return`${e}-${r(t+1)}-${r(n)}`}function $t(e){let t=new Map;for(let n of e){let e=H(n.atMs),r=t.get(e);r===void 0?t.set(e,[n]):r.push(n)}for(let e of t.values())e.sort((e,t)=>e.atMs-t.atMs);return t}function U(e,t,n){let r=new Map,i=new Date(t,n+1,0).getDate();for(let a=1;a<=i;a++){let i=e.get(Qt(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:o,footnote:s}){let c=b(),l=(0,z.useMemo)(()=>$t(e),[e]),u=(0,z.useMemo)(()=>en(c),[c]),d=(0,z.useMemo)(()=>new Intl.DateTimeFormat(c,{month:`long`,year:`numeric`}),[c]),f=(0,z.useMemo)(()=>new Intl.DateTimeFormat(c,{month:`long`}),[c]),p=(0,z.useMemo)(()=>new Intl.DateTimeFormat(c,{hour:`2-digit`,minute:`2-digit`}),[c]),h=new Date,g=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()})},ee=t===`year`?String(n.year):d.format(new Date(n.year,n.month,1));return(0,B.jsxs)(`div`,{className:`oc-cal`,children:[(0,B.jsxs)(`div`,{className:`oc-cal__head`,children:[(0,B.jsxs)(`div`,{className:`oc-cal__nav`,children:[(0,B.jsx)(C,{variant:`ghost`,size:`icon-sm`,"aria-label":a(),onClick:()=>g(-1),children:(0,B.jsx)(T,{})}),(0,B.jsx)(C,{variant:`ghost`,size:`icon-sm`,"aria-label":ct(),onClick:()=>g(1),children:(0,B.jsx)(M,{})}),(0,B.jsx)(C,{variant:`ghost`,size:`sm`,onClick:()=>i({year:h.getFullYear(),month:h.getMonth()}),children:de()})]}),(0,B.jsx)(`span`,{className:`oc-cal__title`,children:ee}),(0,B.jsxs)(`div`,{className:`oc-cal__modes`,role:`group`,children:[(0,B.jsx)(C,{variant:t===`month`?`secondary`:`ghost`,size:`sm`,"aria-pressed":t===`month`,onClick:()=>r(`month`),children:ue()}),(0,B.jsx)(C,{variant:t===`year`?`secondary`:`ghost`,size:`sm`,"aria-pressed":t===`year`,onClick:()=>r(`year`),children:m()})]})]}),t===`month`?(0,B.jsx)(an,{cursor:n,byDay:l,weekdays:u,timeFmt:p,now:h,onEventClick:o}):(0,B.jsx)(on,{year:n.year,byDay:l,monthShortFmt:f,now:h,onOpenMonth:e=>{i({year:n.year,month:e}),r(`month`)}}),s?(0,B.jsx)(`p`,{className:`oc-cal__footnote`,children:s}):null]})}function an({cursor:e,byDay:t,weekdays:n,timeFmt:r,now:i,onEventClick:a}){let o=I(e.year,e.month);return(0,B.jsxs)(`div`,{className:`oc-cal__month`,children:[n.map((e,t)=>(0,B.jsx)(`span`,{className:`oc-cal__wd`,children:e},t)),o.map((e,n)=>{let o=t.get(Qt(e.year,e.month,e.day))??[],s=i.getFullYear()===e.year&&i.getMonth()===e.month&&i.getDate()===e.day;return(0,B.jsxs)(`div`,{className:`oc-cal__day`+(e.inMonth?``:` oc-cal__day--out`)+(s?` oc-cal__day--today`:``),children:[(0,B.jsx)(`span`,{className:`oc-cal__daynum`,children:e.day}),o.slice(0,W).map(e=>(0,B.jsxs)(`button`,{type:`button`,className:`oc-cal__event`+(e.muted?` oc-cal__event--muted`:``)+(e.exact?` oc-cal__event--exact`:``),style:e.color?{"--cal-ev":e.color}:void 0,title:`${r.format(e.atMs)} ${e.title}`,onClick:a?()=>a(e):void 0,children:[(0,B.jsx)(`span`,{className:`oc-cal__evdot`,"aria-hidden":!0}),(0,B.jsx)(`span`,{className:`oc-cal__evtime`,children:r.format(e.atMs)}),(0,B.jsx)(`span`,{className:`oc-cal__evtitle`,children:e.title})]},e.id)),o.length>W?(0,B.jsx)(`span`,{className:`oc-cal__more`,children:v({count:o.length-W})}):null]},n)})]})}function on({year:e,byDay:t,monthShortFmt:n,now:r,onOpenMonth:i}){return(0,B.jsx)(`div`,{className:`oc-cal__year`,children:Array.from({length:12},(a,o)=>{let s=U(t,e,o),c=I(e,o);return(0,B.jsxs)(`button`,{type:`button`,className:`oc-cal__mini`,onClick:()=>i(o),children:[(0,B.jsx)(`span`,{className:`oc-cal__mininame`,children:n.format(new Date(e,o,1))}),(0,B.jsx)(`span`,{className:`oc-cal__minigrid`,"aria-hidden":!0,children:c.map((e,t)=>{let n=e.inMonth?s.get(e.day)??0:0,i=e.inMonth&&r.getFullYear()===e.year&&r.getMonth()===e.month&&r.getDate()===e.day;return(0,B.jsx)(`span`,{className:`oc-cal__minidot`+(e.inMonth?``:` is-out`)+(n===1?` has-one`:``)+(n>1?` has-many`:``)+(i?` is-today`:``)},t)})})]},o)})})}var 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 q=new Map;function J(e){let t=q.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 q.set(e,n),n}function Y(e,t){if(t!==null){let n=J(t);if(n!==null){let t={};for(let r of n.formatToParts(e))r.type!==`literal`&&(t[r.type]=Number(r.value));return{y:t.year,mo:t.month-1,d:t.day,h:t.hour===24?0:t.hour,mi:t.minute}}}let n=new Date(e);return{y:n.getFullYear(),mo:n.getMonth(),d:n.getDate(),h:n.getHours(),mi:n.getMinutes()}}function X(e,t,n,r,i,a){if(a===null||J(a)===null)return new Date(e,t,n,r,i).getTime();let o=Date.UTC(e,t,n,r,i),s=e=>{let t=Y(e,a);return Date.UTC(t.y,t.mo,t.d,t.h,t.mi)-e},c=s(o),l=o-c,u=s(l);return u!==c&&(l=o-u),l}function Z(e,t,n,r){let i=new Map,a=(e,t)=>{e<n||e>=r||i.set(e,t||(i.get(e)??!1))};if(e?.kind===`at`)a(e.atMs,!0);else if(e?.kind===`every`){if(t!==null){let i=e.everyMs,o=Math.ceil((n-t)/i);for(let e=t+o*i,n=0;e<r&&n<400;e+=i,n++)a(e,e===t)}}else if(e?.kind===`cron`){let t=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=Y(o,e.tz);if(t.months.has(s.mo+1)){let o=new Date(Date.UTC(s.y,s.mo,s.d)).getUTCDay(),c=t.dom.has(s.d),l=t.dow.has(o);if(t.domRestricted&&t.dowRestricted?c||l:c&&l)for(let o of t.hours)for(let c of t.minutes){if(i>=400)break;let t=X(s.y,s.mo,s.d,o,c,e.tz);t>=n&&t<r&&(a(t,!1),i++)}}o=X(s.y,s.mo,s.d,12,0,e.tz)+864e5}}}return t!==null&&a(t,!0),[...i.entries()].map(([e,t])=>({atMs:e,exact:t})).sort((e,t)=>e.atMs-t.atMs).slice(0,400)}var Q=`crons`;function ln(e,t){return`${e}\u0000${t}`}function un(e,t,n){let r=[],i=new Map;for(let a of e){let{job:e}=a;if(e.id===null)continue;let o=ln(a.instanceName,e.id);i.set(o,a);let s=Gt(e)!==`active`,c=Z(s?null:cn(e.schedule),e.nextRunAtMs,t,n);for(let t of c)r.push({id:`${o}:${t.atMs}`,sourceId:Q,itemId:o,atMs:t.atMs,title:e.name??e.id,muted:s,exact:t.exact})}return{events:r,byItemId:i}}var $={minutes:6e4,hours:36e5,days:864e5};function dn(e){return e?.data?.code??`unknown`}function fn({status:e}){switch(qt(e)){case`ok`:return(0,B.jsx)(E,{variant:`secondary`,children:Ee()});case`error`:return(0,B.jsx)(E,{variant:`destructive`,children:Re()});case`running`:return(0,B.jsx)(E,{variant:`outline`,children:Ce()});case`other`:return(0,B.jsx)(E,{variant:`outline`,children:e});case`none`:return(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:`—`})}}function pn(){let e=_(S.scheduled.listMyCrons),t=_(S.scheduled.getCronDetail),n=_(S.scheduled.listCronRuns),a=_(S.scheduled.updateCron),c=_(S.scheduled.removeCron),m=_(S.scheduled.runCronNow),g=ft(),ie=h(S.me.getMe,{host:Ot})?.timezone,[v,ue]=(0,z.useState)(null),[de,pe]=(0,z.useState)(!1),[y,he]=(0,z.useState)(!1),[x,ct]=(0,z.useState)(null),[T,ut]=(0,z.useState)(null),[O,M]=(0,z.useState)(null),[N,I]=(0,z.useState)(null),[Ut,qt]=(0,z.useState)(!1),[R,V]=(0,z.useState)(Wt),[H,Qt]=(0,z.useState)(()=>new URLSearchParams(window.location.search).get(`job`)===null&&localStorage.getItem(`oc.sched.view`)===`calendar`?`calendar`:`list`),$t=e=>{localStorage.setItem(`oc.sched.view`,e),Qt(e)},[U,en]=(0,z.useState)(`month`),[W,an]=(0,z.useState)(()=>{let e=new Date;return{year:e.getFullYear(),month:e.getMonth()}}),on=(0,z.useMemo)(()=>{let e=[];for(let t of v??[]){if(!t.supported||t.error!==null)continue;let n=t.kind===`openclaw`&&t.manageSupported;for(let r of t.jobs)Ht(r,R)&&e.push({instanceName:t.instanceName,canEdit:n,job:r})}return e},[v,R]),sn=(0,z.useMemo)(()=>U===`year`?nn(W.year):tn(W.year,W.month),[U,W]),cn=(0,z.useMemo)(()=>un(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,z.useCallback)(async()=>{pe(!0),he(!1);try{ue(await e({}))}catch{he(!0)}finally{pe(!1)}},[e]);(0,z.useEffect)(()=>{K()},[K]);let q=(0,z.useMemo)(()=>new URLSearchParams(window.location.search).get(`job`),[]),J=(0,z.useRef)(null);(0,z.useEffect)(()=>{v!==null&&J.current!==null&&J.current.scrollIntoView({block:`center`})},[v]);let Y=(0,z.useMemo)(()=>new Intl.DateTimeFormat(b(),{dateStyle:`medium`,timeStyle:`short`}),[]),X=async(e,t,n)=>{ct(e);try{await t(),g.success(n),await K()}catch(e){g.toast({variant:`error`,title:le({code:dn(e)})})}finally{ct(null)}},Z=(0,z.useRef)(0),Q=(0,z.useRef)(0),ln=async(e,t)=>{if(t.id===null)return;let r=++Z.current;M({name:t.name??t.id,entries:null});try{let i=await n({instanceName:e,jobId:t.id,limit:20});if(r!==Z.current)return;M({name:t.name??t.id,entries:i})}catch(e){if(r!==Z.current)return;M(null),g.toast({variant:`error`,title:le({code:dn(e)})})}},pn=async(e,n)=>{if(n.id===null)return;let r=++Q.current;I({instanceName:e,jobId:n.id,loading:!0,name:n.name??``,scheduleKind:`cron`,cronExpr:``,tz:``,everyValue:`1`,everyUnit:`hours`,at:``,message:``,hasMessage:!1,scheduleDirty:!1,messageDirty:!1,nameDirty:!1});try{let i=(await t({instanceName:e,jobId:n.id})).job,a=i.scheduleKind===`every`||i.scheduleKind===`at`?i.scheduleKind:`cron`,o=``;if(a===`at`&&i.scheduleExpr!==null){let e=Date.parse(i.scheduleExpr);Number.isFinite(e)&&(o=new Date(e-new Date(e).getTimezoneOffset()*6e4).toISOString().slice(0,16))}let s=`1`,c=`hours`;if(a===`every`&&i.scheduleExpr!==null){let e=Number(i.scheduleExpr);Number.isFinite(e)&&e>0&&(e%$.days===0?(s=String(e/$.days),c=`days`):e%$.hours===0?(s=String(e/$.hours),c=`hours`):(s=String(Math.max(1,Math.round(e/$.minutes))),c=`minutes`))}if(r!==Q.current)return;I(e=>e===null||e.jobId!==n.id?e:{...e,loading:!1,name:i.name??e.name,scheduleKind:a,cronExpr:a===`cron`?i.scheduleExpr??``:``,tz:i.tz??``,everyValue:s,everyUnit:c,at:o,message:i.message??``,hasMessage:i.message!==null&&!i.messageTruncated})}catch(e){if(r!==Q.current)return;I(null),g.toast({variant:`error`,title:le({code:dn(e)})})}},mn=async()=>{if(N===null)return;let e={};if(N.nameDirty&&N.name.trim()===``||N.messageDirty&&N.hasMessage&&N.message.trim()===``){g.toast({variant:`error`,title:Ze()});return}if(N.nameDirty&&N.name.trim()!==``&&(e.name=N.name.trim()),N.scheduleDirty){if(N.scheduleKind===`cron`&&N.cronExpr.trim()!==``)e.schedule={kind:`cron`,expr:N.cronExpr.trim(),...N.tz.trim()===``?{}:{tz:N.tz.trim()}};else if(N.scheduleKind===`every`){let t=Number(N.everyValue);Number.isFinite(t)&&t>=1&&(e.schedule={kind:`every`,everyMs:Math.round(t*$[N.everyUnit])})}else if(N.scheduleKind===`at`&&N.at!==``){let t=Date.parse(N.at);Number.isFinite(t)&&(e.schedule={kind:`at`,at:new Date(t).toISOString()})}}if(N.scheduleDirty&&e.schedule===void 0){g.toast({variant:`error`,title:Te()});return}if(N.messageDirty&&N.hasMessage&&N.message.trim()!==``&&(e.message=N.message.trim()),Object.keys(e).length===0){I(null);return}let t=Q.current;qt(!0);try{await a({instanceName:N.instanceName,jobId:N.jobId,patch:e}),g.success(nt()),t===Q.current&&I(null),await K()}catch(e){g.toast({variant:`error`,title:le({code:dn(e)})})}finally{qt(!1)}},hn=v?.reduce((e,t)=>e+t.jobs.length,0)??0;return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`div`,{style:{display:`flex`,alignItems:`flex-start`,gap:8,marginBottom:12},children:[(0,B.jsx)(`p`,{className:`oc-admin__hint`,style:{flex:1,margin:0},children:De()}),(0,B.jsxs)(`div`,{className:`oc-sched__viewtoggle`,role:`group`,"aria-label":ee(),children:[(0,B.jsx)(C,{variant:H===`list`?`secondary`:`ghost`,size:`icon-sm`,"aria-label":p(),title:p(),"aria-pressed":H===`list`,onClick:()=>$t(`list`),children:(0,B.jsx)(lt,{})}),(0,B.jsx)(C,{variant:H===`calendar`?`secondary`:`ghost`,size:`icon-sm`,"aria-label":fe(),title:fe(),"aria-pressed":H===`calendar`,onClick:()=>$t(`calendar`),children:(0,B.jsx)(Yt,{})})]}),(0,B.jsxs)(C,{variant:`ghost`,size:`sm`,onClick:()=>void K(),disabled:de,style:{display:`inline-flex`,alignItems:`center`,gap:4},children:[(0,B.jsx)(wt,{size:14,"aria-hidden":!0}),$e()]})]}),v!==null&&hn>0?(0,B.jsxs)(Vt,{q:R.q,onQChange:e=>V(t=>({...t,q:e})),searchPlaceholder:Ue(),onReset:()=>V(Wt),canReset:Kt(R),children:[(0,B.jsxs)(k,{value:R.state,onValueChange:e=>V(t=>({...t,state:e})),children:[(0,B.jsx)(w,{size:`sm`,className:`w-40`,children:(0,B.jsx)(j,{})}),(0,B.jsxs)(A,{children:[(0,B.jsx)(D,{value:`all`,children:ye()}),(0,B.jsx)(D,{value:`active`,children:ge()}),(0,B.jsx)(D,{value:`paused`,children:ae()}),(0,B.jsx)(D,{value:`auto-disabled`,children:me()})]})]}),(0,B.jsxs)(k,{value:R.result,onValueChange:e=>V(t=>({...t,result:e})),children:[(0,B.jsx)(w,{size:`sm`,className:`w-40`,children:(0,B.jsx)(j,{})}),(0,B.jsxs)(A,{children:[(0,B.jsx)(D,{value:`all`,children:Pe()}),(0,B.jsx)(D,{value:`ok`,children:Ee()}),(0,B.jsx)(D,{value:`error`,children:Re()}),(0,B.jsx)(D,{value:`running`,children:Ce()}),(0,B.jsx)(D,{value:`none`,children:Je()})]})]})]}):null,v===null?(0,B.jsx)(`p`,{className:`oc-admin__hint`,"aria-busy":de,children:y?ze():d()}):H===`calendar`?(0,B.jsxs)(B.Fragment,{children:[y?(0,B.jsx)(`p`,{className:`oc-admin__hint`,children:ze()}):null,v.length===0?(0,B.jsx)(`p`,{className:`oc-admin__hint`,children:we()}):(0,B.jsx)(rn,{events:cn.events,mode:U,cursor:W,onModeChange:en,onCursorChange:an,onEventClick:G,footnote:te()})]}):(0,B.jsxs)(B.Fragment,{children:[y?(0,B.jsx)(`p`,{className:`oc-admin__hint`,children:ze()}):null,v.length===0?(0,B.jsx)(`p`,{className:`oc-admin__hint`,children:we()}):null,v.map(e=>{let t=e.jobs.filter(e=>Ht(e,R)),n=Kt(R)&&e.jobs.length>0&&t.length===0;return(0,B.jsxs)(`section`,{style:{marginBottom:20},children:[v.length>1||e.error||!e.supported?(0,B.jsxs)(`h3`,{style:{display:`flex`,alignItems:`center`,gap:8,fontSize:`0.85rem`,fontWeight:600,margin:`0 0 6px`},children:[e.instanceName,(0,B.jsx)(E,{variant:`outline`,children:e.kind})]}):null,e.supported?e.error?(0,B.jsx)(`p`,{className:`oc-admin__hint`,children:We({code:e.error})}):e.jobs.length===0?(0,B.jsx)(`p`,{className:`oc-admin__hint`,children:be()}):n?(0,B.jsx)(`p`,{className:`oc-admin__hint`,children:Ke()}):(0,B.jsxs)(Bt,{children:[(0,B.jsx)(Lt,{children:(0,B.jsxs)(zt,{children:[(0,B.jsx)(P,{children:Fe()}),(0,B.jsx)(P,{children:qe()}),(0,B.jsx)(P,{children:He()}),(0,B.jsx)(P,{children:Xe()}),(0,B.jsx)(P,{children:Oe()}),(0,B.jsx)(P,{children:Ae()}),(0,B.jsx)(P,{children:l()})]})}),(0,B.jsx)(Rt,{children:t.map((t,n)=>{let o=`${e.instanceName}:${t.id??n}`,c=x===o,l=e.manageSupported,d=e.kind===`openclaw`&&l;return(0,B.jsxs)(zt,{ref:t.id!==null&&t.id===q?J:void 0,"data-state":t.id!==null&&t.id===q?`selected`:void 0,children:[(0,B.jsx)(F,{className:`font-medium`,style:{maxWidth:280,overflow:`hidden`,textOverflow:`ellipsis`},title:t.name??void 0,children:t.name??r()}),(0,B.jsx)(F,{children:(0,B.jsx)(E,{variant:`secondary`,children:t.agentId})}),(0,B.jsxs)(F,{className:`whitespace-nowrap`,children:[(0,B.jsx)(`span`,{style:{fontFamily:`var(--font-mono, monospace)`},children:t.schedule??`—`}),(()=>{let e=xt(t.schedule),n=e===null?null:gt(e);return n===null?null:(0,B.jsx)(`span`,{className:`text-muted-foreground`,style:{display:`block`,fontSize:`0.78rem`},children:n})})()]}),(0,B.jsx)(F,{className:`whitespace-nowrap text-muted-foreground`,children:t.nextRunAtMs===null?`—`:Y.format(t.nextRunAtMs)}),(0,B.jsx)(F,{children:Gt(t)===`auto-disabled`?(0,B.jsx)(E,{variant:`destructive`,title:`${t.autoDisabledReason??``}${t.autoDisabledAtMs===null?``:` · ${Y.format(t.autoDisabledAtMs)}`}`,children:me()}):Gt(t)===`active`?(0,B.jsx)(E,{variant:`secondary`,children:ge()}):Gt(t)===`paused`?(0,B.jsx)(E,{variant:`outline`,children:ae()}):(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:`—`})}),(0,B.jsxs)(F,{children:[(0,B.jsx)(fn,{status:t.lastRunStatus}),t.lastDelivered===!1?(0,B.jsx)(E,{variant:`destructive`,title:t.lastDeliveryError??ne(),children:Qe()}):null]}),(0,B.jsx)(F,{className:`whitespace-nowrap`,children:t.id===null?(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:`—`}):c?(0,B.jsx)(pt,{size:14,className:`oc-actrow__spin`,"aria-hidden":!0}):(0,B.jsxs)(`span`,{className:`oc-cronactions`,children:[d?(0,B.jsx)(C,{variant:`ghost`,size:`icon-sm`,title:i(),"aria-label":i(),disabled:x!==null,onClick:()=>void X(o,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`}}},rt()),children:(0,B.jsx)(Et,{size:14,"aria-hidden":!0})}):null,d&&t.enabled!==null?(0,B.jsx)(C,{variant:`ghost`,size:`icon-sm`,title:L(t)===`pause`?Le():re(),"aria-label":L(t)===`pause`?Le():re(),disabled:x!==null,onClick:()=>void X(o,()=>a({instanceName:e.instanceName,jobId:t.id,patch:{enabled:L(t)===`resume`}}),L(t)===`pause`?s():se()),children:L(t)===`pause`?(0,B.jsx)(vt,{size:14,"aria-hidden":!0}):(0,B.jsx)(bt,{size:14,"aria-hidden":!0})}):null,d?(0,B.jsx)(C,{variant:`ghost`,size:`icon-sm`,title:f(),"aria-label":f(),disabled:x!==null,onClick:()=>void pn(e.instanceName,t),children:(0,B.jsx)(Ft,{size:14,"aria-hidden":!0})}):null,d?(0,B.jsx)(C,{variant:`ghost`,size:`icon-sm`,title:ce(),"aria-label":ce(),disabled:x!==null,onClick:()=>void ln(e.instanceName,t),children:(0,B.jsx)(Xt,{size:14,"aria-hidden":!0})}):null,l?(0,B.jsx)(C,{variant:`ghost`,size:`icon-sm`,title:u(),"aria-label":u(),disabled:x!==null,onClick:()=>ut({instanceName:e.instanceName,jobId:t.id,name:t.name??t.id}),children:(0,B.jsx)(jt,{size:14,"aria-hidden":!0})}):null]})})]},t.id??`${e.instanceName}-${n}`)})})]}):(0,B.jsx)(`p`,{className:`oc-admin__hint`,children:Ye()})]},e.instanceName)}),hn>0?(0,B.jsx)(`p`,{className:`oc-admin__hint`,style:{marginTop:4},children:Ne()}):null]}),(0,B.jsx)(Mt,{open:T!==null,onOpenChange:e=>{e||ut(null)},children:(0,B.jsxs)(Pt,{children:[(0,B.jsxs)(Nt,{children:[(0,B.jsx)(ht,{children:Se()}),(0,B.jsx)(mt,{children:st({name:T?.name??``})})]}),(0,B.jsxs)(dt,{children:[(0,B.jsx)(yt,{children:tt()}),(0,B.jsx)(It,{onClick:()=>{let e=T;ut(null),e!==null&&X(`${e.instanceName}:${e.jobId}`,()=>c({instanceName:e.instanceName,jobId:e.jobId}),at())},children:ve()})]})]})}),(0,B.jsx)(At,{open:O!==null,onOpenChange:e=>{e||(Z.current++,M(null))},children:(0,B.jsxs)(Tt,{style:{maxWidth:640},children:[(0,B.jsx)(_t,{children:(0,B.jsx)(Dt,{children:o({name:O?.name??``})})}),O?.entries===null?(0,B.jsx)(`p`,{className:`oc-admin__hint`,children:d()}):O!==null&&O.entries.length===0?(0,B.jsx)(`p`,{className:`oc-admin__hint`,children:oe()}):O===null?null:(0,B.jsx)(`div`,{className:`oc-cronpanel__runs`,style:{maxHeight:420,overflowY:`auto`},children:O.entries.map((e,t)=>(0,B.jsxs)(`div`,{className:`oc-cronpanel__run`,children:[(0,B.jsxs)(`div`,{className:`oc-cronpanel__run-head`,children:[(0,B.jsx)(fn,{status:e.status}),(0,B.jsx)(`span`,{children:typeof(e.runAtMs??e.ts)==`number`?Y.format(e.runAtMs??e.ts):`—`}),typeof e.durationMs==`number`?(0,B.jsxs)(`span`,{className:`oc-cronpanel__run-dur`,children:[Math.round(e.durationMs/1e3),`s`]}):null]}),e.summary===null?null:(0,B.jsx)(`div`,{className:`oc-cronpanel__run-summary`,children:e.summary}),e.error===null?null:(0,B.jsx)(`div`,{className:`oc-cronpanel__run-error`,children:e.error}),e.delivered===!1?(0,B.jsxs)(`div`,{className:`oc-cronpanel__run-undelivered`,children:[Ve({channel:e.deliveryChannel??`—`}),e.deliveryError===null?null:(0,B.jsx)(`span`,{className:`oc-cronpanel__plain`,children:e.deliveryError})]}):null]},t))})]})}),(0,B.jsx)(At,{open:N!==null,onOpenChange:e=>{e||(Q.current++,I(null))},children:(0,B.jsxs)(Tt,{className:`oc-cronedit`,children:[(0,B.jsxs)(_t,{children:[(0,B.jsx)(Dt,{children:it()}),(0,B.jsx)(kt,{children:xe()})]}),N===null?null:N.loading?(0,B.jsx)(`p`,{className:`oc-admin__hint`,children:d()}):(0,B.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:12},children:[(0,B.jsxs)(`label`,{style:{display:`flex`,flexDirection:`column`,gap:4},children:[(0,B.jsx)(`span`,{className:`oc-admin__hint`,style:{margin:0},children:Fe()}),(0,B.jsx)(Ct,{value:N.name,maxLength:200,onChange:e=>I({...N,name:e.target.value,nameDirty:!0})})]}),(0,B.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:4},children:[(0,B.jsx)(`span`,{className:`oc-admin__hint`,style:{margin:0},children:ot()}),(0,B.jsxs)(k,{value:N.scheduleKind,onValueChange:e=>I({...N,scheduleKind:e,scheduleDirty:!0}),children:[(0,B.jsx)(w,{children:(0,B.jsx)(j,{})}),(0,B.jsxs)(A,{children:[(0,B.jsx)(D,{value:`cron`,children:et()}),(0,B.jsx)(D,{value:`every`,children:_e()}),(0,B.jsx)(D,{value:`at`,children:je()})]})]}),N.scheduleKind===`cron`?(0,B.jsxs)(`div`,{style:{display:`flex`,gap:8},children:[(0,B.jsx)(Ct,{value:N.cronExpr,onChange:e=>I({...N,cronExpr:e.target.value,scheduleDirty:!0}),placeholder:`30 9 * * *`,style:{fontFamily:`var(--font-mono, monospace)`}}),(0,B.jsx)(Jt,{value:N.tz,onChange:e=>I({...N,tz:e,scheduleDirty:!0}),fallbackTz:ie??void 0})]}):N.scheduleKind===`every`?(0,B.jsxs)(`div`,{style:{display:`flex`,gap:8},children:[(0,B.jsx)(Ct,{type:`number`,min:1,value:N.everyValue,onChange:e=>I({...N,everyValue:e.target.value,scheduleDirty:!0}),style:{maxWidth:120}}),(0,B.jsxs)(k,{value:N.everyUnit,onValueChange:e=>I({...N,everyUnit:e,scheduleDirty:!0}),children:[(0,B.jsx)(w,{style:{maxWidth:160},children:(0,B.jsx)(j,{})}),(0,B.jsxs)(A,{children:[(0,B.jsx)(D,{value:`minutes`,children:Me()}),(0,B.jsx)(D,{value:`hours`,children:Be()}),(0,B.jsx)(D,{value:`days`,children:Ge()})]})]})]}):(0,B.jsx)(Zt,{value:N.at,onChange:e=>I({...N,at:e,scheduleDirty:!0})})]}),N.hasMessage?(0,B.jsxs)(`label`,{style:{display:`flex`,flexDirection:`column`,gap:4},children:[(0,B.jsx)(`span`,{className:`oc-admin__hint`,style:{margin:0},children:Ie()}),(0,B.jsx)(`textarea`,{className:`oc-cronedit__textarea`,rows:4,value:N.message,onChange:e=>I({...N,message:e.target.value,messageDirty:!0})})]}):null]}),(0,B.jsxs)(St,{children:[(0,B.jsx)(C,{variant:`ghost`,onClick:()=>I(null),children:tt()}),(0,B.jsxs)(C,{onClick:()=>void mn(),disabled:N===null||N.loading||Ut,children:[Ut?(0,B.jsx)(pt,{size:14,className:`oc-actrow__spin`,"aria-hidden":!0}):null,ke()]})]})]})})]})}export{pn as ScheduledTab};
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$L as r,AL as i,BI as a,CI as o,CL as s,D as c,DI as l,DL as u,Dz as d,EI as f,GI as p,HI as m,Iz as h,JI as g,KI as ee,LI as te,ML as ne,Nz as _,OL as re,QI as ie,QL as ae,RI as v,SI as oe,SL as se,TI as ce,TL as le,UI as ue,VI as de,WI as fe,XI as pe,XL as me,YI as y,ZI as he,ZL as ge,_I as _e,_L as ve,aL as ye,aR as be,bI as xe,bL as Se,cL as Ce,cR as we,dI as Te,dL as Ee,dR as De,eR as Oe,fI as ke,fL as Ae,gI as je,hI as Me,iI as Ne,iL as Pe,iR as Fe,jL as Ie,kL as Le,kz as b,lL as Re,lR as ze,mI as Be,mL as Ve,nR as He,oL as Ue,oR as We,pI as Ge,qI as x,rL as Ke,rR as qe,sL as Je,sR as Ye,t as S,tR as Xe,uI as Ze,uL as Qe,uR as $e,vI as et,vL as tt,wI as nt,wL as rt,xI as it,xL as at,yI as ot,yL as st,zI as ct}from"./api-Cpjr7qvl.js";import{t as lt}from"./list-CIbMtiOp.js";import{t as C}from"./button-CbwCr9Pi.js";import{$ as w,Bn as T,Bt as ut,Ct as dt,Dt as ft,En as pt,Et as E,Q as D,Rt as O,St as mt,Tt as ht,X as k,Z as A,_t as gt,at as _t,bn as vt,bt as yt,et as j,gn as bt,gt as xt,it as St,jt as Ct,mn as wt,nt as Tt,on as Et,ot as Dt,q as Ot,rt as kt,tt as At,un as jt,vt as Mt,wt as Nt,xt as Pt,yn as Ft,yt as It,zn as M,zt as N}from"./index-Bc3aF-kJ.js";import{a as Lt,i as P,n as Rt,o as zt,r as F,t as Bt}from"./table-CeTqDEfs.js";import{t as Vt}from"./FilterBar-FHDxb3k3.js";/* empty css */import{a as Ht,c as I,i as L,l as Ut,n as Wt,o as Gt,r as Kt,s as qt,t as Jt,u as R}from"./TimezoneCombobox-UX7uQX62.js";var Yt=c(`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`}]]),Xt=c(`history`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M12 7v5l4 2`,key:`1fdv2h`}]]),z=t(e(),1),B=n();function V(e){try{let t=new Intl.DateTimeFormat(e,{weekday:`narrow`});return Array.from({length:7},(e,n)=>t.format(new Date(2024,0,1+n)))}catch{return[`M`,`T`,`W`,`T`,`F`,`S`,`S`]}}function Zt({value:e,onChange:t}){let n=Ut(e),r=(0,z.useMemo)(()=>new Date,[]),[i,a]=(0,z.useState)(()=>({year:n?.year??r.getFullYear(),month:n?.month??r.getMonth()})),[o,s]=(0,z.useState)(!1),c=(0,z.useMemo)(()=>V(b()),[]),l=(0,z.useMemo)(()=>new Intl.DateTimeFormat(b(),{month:`long`,year:`numeric`}),[]),u=(0,z.useMemo)(()=>new Intl.DateTimeFormat(b(),{dateStyle:`medium`,timeStyle:`short`}),[]),d=I(i.year,i.month),f=n?.hour??9,p=n?.minute??0,m=(e,n,r,i,a)=>t(R(e,n,r,i,a)),h=(e,t,n)=>{a({year:e,month:t}),m(e,t,n,f,p)},ee=e=>{let t=new Date(i.year,i.month+e,1);a({year:t.getFullYear(),month:t.getMonth()})},te=n===null?he():u.format(new Date(n.year,n.month,n.day,n.hour,n.minute));return(0,B.jsxs)(O,{modal:!0,open:o,onOpenChange:s,children:[(0,B.jsx)(ut,{asChild:!0,children:(0,B.jsxs)(`button`,{type:`button`,className:`oc-dtp__trigger`,"aria-label":ie(),children:[(0,B.jsx)(Yt,{size:14,"aria-hidden":!0,className:`oc-dtp__icon`}),(0,B.jsx)(`span`,{className:n===null?`oc-dtp__placeholder`:void 0,children:te})]})}),(0,B.jsxs)(N,{align:`start`,className:`oc-dtp__pop`,children:[(0,B.jsxs)(`div`,{className:`oc-dtp__head`,children:[(0,B.jsx)(`button`,{type:`button`,className:`oc-dtp__nav`,"aria-label":pe(),onClick:()=>ee(-1),children:(0,B.jsx)(T,{size:15,"aria-hidden":!0})}),(0,B.jsx)(`span`,{className:`oc-dtp__month`,children:l.format(new Date(i.year,i.month,1))}),(0,B.jsx)(`button`,{type:`button`,className:`oc-dtp__nav`,"aria-label":y(),onClick:()=>ee(1),children:(0,B.jsx)(M,{size:15,"aria-hidden":!0})})]}),(0,B.jsxs)(`div`,{className:`oc-dtp__grid`,children:[c.map((e,t)=>(0,B.jsx)(`span`,{className:`oc-dtp__wd`,children:e},t)),d.map((e,t)=>{let i=n!==null&&n.year===e.year&&n.month===e.month&&n.day===e.day,a=r.getFullYear()===e.year&&r.getMonth()===e.month&&r.getDate()===e.day;return(0,B.jsx)(`button`,{type:`button`,className:`oc-dtp__day`+(e.inMonth?``:` oc-dtp__day--out`)+(i?` oc-dtp__day--sel`:``)+(a&&!i?` oc-dtp__day--today`:``),onClick:()=>h(e.year,e.month,e.day),children:e.day},t)})]}),(0,B.jsxs)(`div`,{className:`oc-dtp__time`,children:[(0,B.jsxs)(k,{value:String(f),onValueChange:e=>m(i.year,i.month,n?.day??r.getDate(),Number(e),p),children:[(0,B.jsx)(w,{size:`sm`,"aria-label":g(),children:(0,B.jsx)(j,{})}),(0,B.jsx)(A,{className:`oc-dtp__timeopts`,children:Array.from({length:24},(e,t)=>(0,B.jsx)(D,{value:String(t),children:String(t).padStart(2,`0`)},t))})]}),(0,B.jsx)(`span`,{className:`oc-dtp__colon`,children:`:`}),(0,B.jsxs)(k,{value:String(p),onValueChange:e=>m(i.year,i.month,n?.day??r.getDate(),f,Number(e)),children:[(0,B.jsx)(w,{size:`sm`,"aria-label":x(),children:(0,B.jsx)(j,{})}),(0,B.jsx)(A,{className:`oc-dtp__timeopts`,children:Array.from({length:60},(e,t)=>(0,B.jsx)(D,{value:String(t),children:String(t).padStart(2,`0`)},t))})]})]})]})]})}function H(e){let t=new Date(e),n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())}`}function Qt(e,t,n){let r=e=>String(e).padStart(2,`0`);return`${e}-${r(t+1)}-${r(n)}`}function $t(e){let t=new Map;for(let n of e){let e=H(n.atMs),r=t.get(e);r===void 0?t.set(e,[n]):r.push(n)}for(let e of t.values())e.sort((e,t)=>e.atMs-t.atMs);return t}function U(e,t,n){let r=new Map,i=new Date(t,n+1,0).getDate();for(let a=1;a<=i;a++){let i=e.get(Qt(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:o,footnote:s}){let c=b(),l=(0,z.useMemo)(()=>$t(e),[e]),u=(0,z.useMemo)(()=>en(c),[c]),d=(0,z.useMemo)(()=>new Intl.DateTimeFormat(c,{month:`long`,year:`numeric`}),[c]),f=(0,z.useMemo)(()=>new Intl.DateTimeFormat(c,{month:`long`}),[c]),p=(0,z.useMemo)(()=>new Intl.DateTimeFormat(c,{hour:`2-digit`,minute:`2-digit`}),[c]),h=new Date,g=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()})},ee=t===`year`?String(n.year):d.format(new Date(n.year,n.month,1));return(0,B.jsxs)(`div`,{className:`oc-cal`,children:[(0,B.jsxs)(`div`,{className:`oc-cal__head`,children:[(0,B.jsxs)(`div`,{className:`oc-cal__nav`,children:[(0,B.jsx)(C,{variant:`ghost`,size:`icon-sm`,"aria-label":a(),onClick:()=>g(-1),children:(0,B.jsx)(T,{})}),(0,B.jsx)(C,{variant:`ghost`,size:`icon-sm`,"aria-label":ct(),onClick:()=>g(1),children:(0,B.jsx)(M,{})}),(0,B.jsx)(C,{variant:`ghost`,size:`sm`,onClick:()=>i({year:h.getFullYear(),month:h.getMonth()}),children:de()})]}),(0,B.jsx)(`span`,{className:`oc-cal__title`,children:ee}),(0,B.jsxs)(`div`,{className:`oc-cal__modes`,role:`group`,children:[(0,B.jsx)(C,{variant:t===`month`?`secondary`:`ghost`,size:`sm`,"aria-pressed":t===`month`,onClick:()=>r(`month`),children:ue()}),(0,B.jsx)(C,{variant:t===`year`?`secondary`:`ghost`,size:`sm`,"aria-pressed":t===`year`,onClick:()=>r(`year`),children:m()})]})]}),t===`month`?(0,B.jsx)(an,{cursor:n,byDay:l,weekdays:u,timeFmt:p,now:h,onEventClick:o}):(0,B.jsx)(on,{year:n.year,byDay:l,monthShortFmt:f,now:h,onOpenMonth:e=>{i({year:n.year,month:e}),r(`month`)}}),s?(0,B.jsx)(`p`,{className:`oc-cal__footnote`,children:s}):null]})}function an({cursor:e,byDay:t,weekdays:n,timeFmt:r,now:i,onEventClick:a}){let o=I(e.year,e.month);return(0,B.jsxs)(`div`,{className:`oc-cal__month`,children:[n.map((e,t)=>(0,B.jsx)(`span`,{className:`oc-cal__wd`,children:e},t)),o.map((e,n)=>{let o=t.get(Qt(e.year,e.month,e.day))??[],s=i.getFullYear()===e.year&&i.getMonth()===e.month&&i.getDate()===e.day;return(0,B.jsxs)(`div`,{className:`oc-cal__day`+(e.inMonth?``:` oc-cal__day--out`)+(s?` oc-cal__day--today`:``),children:[(0,B.jsx)(`span`,{className:`oc-cal__daynum`,children:e.day}),o.slice(0,W).map(e=>(0,B.jsxs)(`button`,{type:`button`,className:`oc-cal__event`+(e.muted?` oc-cal__event--muted`:``)+(e.exact?` oc-cal__event--exact`:``),style:e.color?{"--cal-ev":e.color}:void 0,title:`${r.format(e.atMs)} ${e.title}`,onClick:a?()=>a(e):void 0,children:[(0,B.jsx)(`span`,{className:`oc-cal__evdot`,"aria-hidden":!0}),(0,B.jsx)(`span`,{className:`oc-cal__evtime`,children:r.format(e.atMs)}),(0,B.jsx)(`span`,{className:`oc-cal__evtitle`,children:e.title})]},e.id)),o.length>W?(0,B.jsx)(`span`,{className:`oc-cal__more`,children:v({count:o.length-W})}):null]},n)})]})}function on({year:e,byDay:t,monthShortFmt:n,now:r,onOpenMonth:i}){return(0,B.jsx)(`div`,{className:`oc-cal__year`,children:Array.from({length:12},(a,o)=>{let s=U(t,e,o),c=I(e,o);return(0,B.jsxs)(`button`,{type:`button`,className:`oc-cal__mini`,onClick:()=>i(o),children:[(0,B.jsx)(`span`,{className:`oc-cal__mininame`,children:n.format(new Date(e,o,1))}),(0,B.jsx)(`span`,{className:`oc-cal__minigrid`,"aria-hidden":!0,children:c.map((e,t)=>{let n=e.inMonth?s.get(e.day)??0:0,i=e.inMonth&&r.getFullYear()===e.year&&r.getMonth()===e.month&&r.getDate()===e.day;return(0,B.jsx)(`span`,{className:`oc-cal__minidot`+(e.inMonth?``:` is-out`)+(n===1?` has-one`:``)+(n>1?` has-many`:``)+(i?` is-today`:``)},t)})})]},o)})})}var 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 q=new Map;function J(e){let t=q.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 q.set(e,n),n}function Y(e,t){if(t!==null){let n=J(t);if(n!==null){let t={};for(let r of n.formatToParts(e))r.type!==`literal`&&(t[r.type]=Number(r.value));return{y:t.year,mo:t.month-1,d:t.day,h:t.hour===24?0:t.hour,mi:t.minute}}}let n=new Date(e);return{y:n.getFullYear(),mo:n.getMonth(),d:n.getDate(),h:n.getHours(),mi:n.getMinutes()}}function X(e,t,n,r,i,a){if(a===null||J(a)===null)return new Date(e,t,n,r,i).getTime();let o=Date.UTC(e,t,n,r,i),s=e=>{let t=Y(e,a);return Date.UTC(t.y,t.mo,t.d,t.h,t.mi)-e},c=s(o),l=o-c,u=s(l);return u!==c&&(l=o-u),l}function Z(e,t,n,r){let i=new Map,a=(e,t)=>{e<n||e>=r||i.set(e,t||(i.get(e)??!1))};if(e?.kind===`at`)a(e.atMs,!0);else if(e?.kind===`every`){if(t!==null){let i=e.everyMs,o=Math.ceil((n-t)/i);for(let e=t+o*i,n=0;e<r&&n<400;e+=i,n++)a(e,e===t)}}else if(e?.kind===`cron`){let t=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=Y(o,e.tz);if(t.months.has(s.mo+1)){let o=new Date(Date.UTC(s.y,s.mo,s.d)).getUTCDay(),c=t.dom.has(s.d),l=t.dow.has(o);if(t.domRestricted&&t.dowRestricted?c||l:c&&l)for(let o of t.hours)for(let c of t.minutes){if(i>=400)break;let t=X(s.y,s.mo,s.d,o,c,e.tz);t>=n&&t<r&&(a(t,!1),i++)}}o=X(s.y,s.mo,s.d,12,0,e.tz)+864e5}}}return t!==null&&a(t,!0),[...i.entries()].map(([e,t])=>({atMs:e,exact:t})).sort((e,t)=>e.atMs-t.atMs).slice(0,400)}var Q=`crons`;function ln(e,t){return`${e}\u0000${t}`}function un(e,t,n){let r=[],i=new Map;for(let a of e){let{job:e}=a;if(e.id===null)continue;let o=ln(a.instanceName,e.id);i.set(o,a);let s=Gt(e)!==`active`,c=Z(s?null:cn(e.schedule),e.nextRunAtMs,t,n);for(let t of c)r.push({id:`${o}:${t.atMs}`,sourceId:Q,itemId:o,atMs:t.atMs,title:e.name??e.id,muted:s,exact:t.exact})}return{events:r,byItemId:i}}var $={minutes:6e4,hours:36e5,days:864e5};function dn(e){return e?.data?.code??`unknown`}function fn({status:e}){switch(qt(e)){case`ok`:return(0,B.jsx)(E,{variant:`secondary`,children:Ee()});case`error`:return(0,B.jsx)(E,{variant:`destructive`,children:Re()});case`running`:return(0,B.jsx)(E,{variant:`outline`,children:Ce()});case`other`:return(0,B.jsx)(E,{variant:`outline`,children:e});case`none`:return(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:`—`})}}function pn(){let e=_(S.scheduled.listMyCrons),t=_(S.scheduled.getCronDetail),n=_(S.scheduled.listCronRuns),a=_(S.scheduled.updateCron),c=_(S.scheduled.removeCron),m=_(S.scheduled.runCronNow),g=ft(),ie=h(S.me.getMe,{host:Ot})?.timezone,[v,ue]=(0,z.useState)(null),[de,pe]=(0,z.useState)(!1),[y,he]=(0,z.useState)(!1),[x,ct]=(0,z.useState)(null),[T,ut]=(0,z.useState)(null),[O,M]=(0,z.useState)(null),[N,I]=(0,z.useState)(null),[Ut,qt]=(0,z.useState)(!1),[R,V]=(0,z.useState)(Wt),[H,Qt]=(0,z.useState)(()=>new URLSearchParams(window.location.search).get(`job`)===null&&localStorage.getItem(`oc.sched.view`)===`calendar`?`calendar`:`list`),$t=e=>{localStorage.setItem(`oc.sched.view`,e),Qt(e)},[U,en]=(0,z.useState)(`month`),[W,an]=(0,z.useState)(()=>{let e=new Date;return{year:e.getFullYear(),month:e.getMonth()}}),on=(0,z.useMemo)(()=>{let e=[];for(let t of v??[]){if(!t.supported||t.error!==null)continue;let n=t.kind===`openclaw`&&t.manageSupported;for(let r of t.jobs)Ht(r,R)&&e.push({instanceName:t.instanceName,canEdit:n,job:r})}return e},[v,R]),sn=(0,z.useMemo)(()=>U===`year`?nn(W.year):tn(W.year,W.month),[U,W]),cn=(0,z.useMemo)(()=>un(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,z.useCallback)(async()=>{pe(!0),he(!1);try{ue(await e({}))}catch{he(!0)}finally{pe(!1)}},[e]);(0,z.useEffect)(()=>{K()},[K]);let q=(0,z.useMemo)(()=>new URLSearchParams(window.location.search).get(`job`),[]),J=(0,z.useRef)(null);(0,z.useEffect)(()=>{v!==null&&J.current!==null&&J.current.scrollIntoView({block:`center`})},[v]);let Y=(0,z.useMemo)(()=>new Intl.DateTimeFormat(b(),{dateStyle:`medium`,timeStyle:`short`}),[]),X=async(e,t,n)=>{ct(e);try{await t(),g.success(n),await K()}catch(e){g.toast({variant:`error`,title:le({code:dn(e)})})}finally{ct(null)}},Z=(0,z.useRef)(0),Q=(0,z.useRef)(0),ln=async(e,t)=>{if(t.id===null)return;let r=++Z.current;M({name:t.name??t.id,entries:null});try{let i=await n({instanceName:e,jobId:t.id,limit:20});if(r!==Z.current)return;M({name:t.name??t.id,entries:i})}catch(e){if(r!==Z.current)return;M(null),g.toast({variant:`error`,title:le({code:dn(e)})})}},pn=async(e,n)=>{if(n.id===null)return;let r=++Q.current;I({instanceName:e,jobId:n.id,loading:!0,name:n.name??``,scheduleKind:`cron`,cronExpr:``,tz:``,everyValue:`1`,everyUnit:`hours`,at:``,message:``,hasMessage:!1,scheduleDirty:!1,messageDirty:!1,nameDirty:!1});try{let i=(await t({instanceName:e,jobId:n.id})).job,a=i.scheduleKind===`every`||i.scheduleKind===`at`?i.scheduleKind:`cron`,o=``;if(a===`at`&&i.scheduleExpr!==null){let e=Date.parse(i.scheduleExpr);Number.isFinite(e)&&(o=new Date(e-new Date(e).getTimezoneOffset()*6e4).toISOString().slice(0,16))}let s=`1`,c=`hours`;if(a===`every`&&i.scheduleExpr!==null){let e=Number(i.scheduleExpr);Number.isFinite(e)&&e>0&&(e%$.days===0?(s=String(e/$.days),c=`days`):e%$.hours===0?(s=String(e/$.hours),c=`hours`):(s=String(Math.max(1,Math.round(e/$.minutes))),c=`minutes`))}if(r!==Q.current)return;I(e=>e===null||e.jobId!==n.id?e:{...e,loading:!1,name:i.name??e.name,scheduleKind:a,cronExpr:a===`cron`?i.scheduleExpr??``:``,tz:i.tz??``,everyValue:s,everyUnit:c,at:o,message:i.message??``,hasMessage:i.message!==null&&!i.messageTruncated})}catch(e){if(r!==Q.current)return;I(null),g.toast({variant:`error`,title:le({code:dn(e)})})}},mn=async()=>{if(N===null)return;let e={};if(N.nameDirty&&N.name.trim()===``||N.messageDirty&&N.hasMessage&&N.message.trim()===``){g.toast({variant:`error`,title:Ze()});return}if(N.nameDirty&&N.name.trim()!==``&&(e.name=N.name.trim()),N.scheduleDirty){if(N.scheduleKind===`cron`&&N.cronExpr.trim()!==``)e.schedule={kind:`cron`,expr:N.cronExpr.trim(),...N.tz.trim()===``?{}:{tz:N.tz.trim()}};else if(N.scheduleKind===`every`){let t=Number(N.everyValue);Number.isFinite(t)&&t>=1&&(e.schedule={kind:`every`,everyMs:Math.round(t*$[N.everyUnit])})}else if(N.scheduleKind===`at`&&N.at!==``){let t=Date.parse(N.at);Number.isFinite(t)&&(e.schedule={kind:`at`,at:new Date(t).toISOString()})}}if(N.scheduleDirty&&e.schedule===void 0){g.toast({variant:`error`,title:Te()});return}if(N.messageDirty&&N.hasMessage&&N.message.trim()!==``&&(e.message=N.message.trim()),Object.keys(e).length===0){I(null);return}let t=Q.current;qt(!0);try{await a({instanceName:N.instanceName,jobId:N.jobId,patch:e}),g.success(nt()),t===Q.current&&I(null),await K()}catch(e){g.toast({variant:`error`,title:le({code:dn(e)})})}finally{qt(!1)}},hn=v?.reduce((e,t)=>e+t.jobs.length,0)??0;return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`div`,{style:{display:`flex`,alignItems:`flex-start`,gap:8,marginBottom:12},children:[(0,B.jsx)(`p`,{className:`oc-admin__hint`,style:{flex:1,margin:0},children:De()}),(0,B.jsxs)(`div`,{className:`oc-sched__viewtoggle`,role:`group`,"aria-label":ee(),children:[(0,B.jsx)(C,{variant:H===`list`?`secondary`:`ghost`,size:`icon-sm`,"aria-label":p(),title:p(),"aria-pressed":H===`list`,onClick:()=>$t(`list`),children:(0,B.jsx)(lt,{})}),(0,B.jsx)(C,{variant:H===`calendar`?`secondary`:`ghost`,size:`icon-sm`,"aria-label":fe(),title:fe(),"aria-pressed":H===`calendar`,onClick:()=>$t(`calendar`),children:(0,B.jsx)(Yt,{})})]}),(0,B.jsxs)(C,{variant:`ghost`,size:`sm`,onClick:()=>void K(),disabled:de,style:{display:`inline-flex`,alignItems:`center`,gap:4},children:[(0,B.jsx)(wt,{size:14,"aria-hidden":!0}),$e()]})]}),v!==null&&hn>0?(0,B.jsxs)(Vt,{q:R.q,onQChange:e=>V(t=>({...t,q:e})),searchPlaceholder:Ue(),onReset:()=>V(Wt),canReset:Kt(R),children:[(0,B.jsxs)(k,{value:R.state,onValueChange:e=>V(t=>({...t,state:e})),children:[(0,B.jsx)(w,{size:`sm`,className:`w-40`,children:(0,B.jsx)(j,{})}),(0,B.jsxs)(A,{children:[(0,B.jsx)(D,{value:`all`,children:ye()}),(0,B.jsx)(D,{value:`active`,children:ge()}),(0,B.jsx)(D,{value:`paused`,children:ae()}),(0,B.jsx)(D,{value:`auto-disabled`,children:me()})]})]}),(0,B.jsxs)(k,{value:R.result,onValueChange:e=>V(t=>({...t,result:e})),children:[(0,B.jsx)(w,{size:`sm`,className:`w-40`,children:(0,B.jsx)(j,{})}),(0,B.jsxs)(A,{children:[(0,B.jsx)(D,{value:`all`,children:Pe()}),(0,B.jsx)(D,{value:`ok`,children:Ee()}),(0,B.jsx)(D,{value:`error`,children:Re()}),(0,B.jsx)(D,{value:`running`,children:Ce()}),(0,B.jsx)(D,{value:`none`,children:Je()})]})]})]}):null,v===null?(0,B.jsx)(`p`,{className:`oc-admin__hint`,"aria-busy":de,children:y?ze():d()}):H===`calendar`?(0,B.jsxs)(B.Fragment,{children:[y?(0,B.jsx)(`p`,{className:`oc-admin__hint`,children:ze()}):null,v.length===0?(0,B.jsx)(`p`,{className:`oc-admin__hint`,children:we()}):(0,B.jsx)(rn,{events:cn.events,mode:U,cursor:W,onModeChange:en,onCursorChange:an,onEventClick:G,footnote:te()})]}):(0,B.jsxs)(B.Fragment,{children:[y?(0,B.jsx)(`p`,{className:`oc-admin__hint`,children:ze()}):null,v.length===0?(0,B.jsx)(`p`,{className:`oc-admin__hint`,children:we()}):null,v.map(e=>{let t=e.jobs.filter(e=>Ht(e,R)),n=Kt(R)&&e.jobs.length>0&&t.length===0;return(0,B.jsxs)(`section`,{style:{marginBottom:20},children:[v.length>1||e.error||!e.supported?(0,B.jsxs)(`h3`,{style:{display:`flex`,alignItems:`center`,gap:8,fontSize:`0.85rem`,fontWeight:600,margin:`0 0 6px`},children:[e.instanceName,(0,B.jsx)(E,{variant:`outline`,children:e.kind})]}):null,e.supported?e.error?(0,B.jsx)(`p`,{className:`oc-admin__hint`,children:We({code:e.error})}):e.jobs.length===0?(0,B.jsx)(`p`,{className:`oc-admin__hint`,children:be()}):n?(0,B.jsx)(`p`,{className:`oc-admin__hint`,children:Ke()}):(0,B.jsxs)(Bt,{children:[(0,B.jsx)(Lt,{children:(0,B.jsxs)(zt,{children:[(0,B.jsx)(P,{children:Fe()}),(0,B.jsx)(P,{children:qe()}),(0,B.jsx)(P,{children:He()}),(0,B.jsx)(P,{children:Xe()}),(0,B.jsx)(P,{children:Oe()}),(0,B.jsx)(P,{children:Ae()}),(0,B.jsx)(P,{children:l()})]})}),(0,B.jsx)(Rt,{children:t.map((t,n)=>{let o=`${e.instanceName}:${t.id??n}`,c=x===o,l=e.manageSupported,d=e.kind===`openclaw`&&l;return(0,B.jsxs)(zt,{ref:t.id!==null&&t.id===q?J:void 0,"data-state":t.id!==null&&t.id===q?`selected`:void 0,children:[(0,B.jsx)(F,{className:`font-medium`,style:{maxWidth:280,overflow:`hidden`,textOverflow:`ellipsis`},title:t.name??void 0,children:t.name??r()}),(0,B.jsx)(F,{children:(0,B.jsx)(E,{variant:`secondary`,children:t.agentId})}),(0,B.jsxs)(F,{className:`whitespace-nowrap`,children:[(0,B.jsx)(`span`,{style:{fontFamily:`var(--font-mono, monospace)`},children:t.schedule??`—`}),(()=>{let e=xt(t.schedule),n=e===null?null:gt(e);return n===null?null:(0,B.jsx)(`span`,{className:`text-muted-foreground`,style:{display:`block`,fontSize:`0.78rem`},children:n})})()]}),(0,B.jsx)(F,{className:`whitespace-nowrap text-muted-foreground`,children:t.nextRunAtMs===null?`—`:Y.format(t.nextRunAtMs)}),(0,B.jsx)(F,{children:Gt(t)===`auto-disabled`?(0,B.jsx)(E,{variant:`destructive`,title:`${t.autoDisabledReason??``}${t.autoDisabledAtMs===null?``:` · ${Y.format(t.autoDisabledAtMs)}`}`,children:me()}):Gt(t)===`active`?(0,B.jsx)(E,{variant:`secondary`,children:ge()}):Gt(t)===`paused`?(0,B.jsx)(E,{variant:`outline`,children:ae()}):(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:`—`})}),(0,B.jsxs)(F,{children:[(0,B.jsx)(fn,{status:t.lastRunStatus}),t.lastDelivered===!1?(0,B.jsx)(E,{variant:`destructive`,title:t.lastDeliveryError??ne(),children:Qe()}):null]}),(0,B.jsx)(F,{className:`whitespace-nowrap`,children:t.id===null?(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:`—`}):c?(0,B.jsx)(pt,{size:14,className:`oc-actrow__spin`,"aria-hidden":!0}):(0,B.jsxs)(`span`,{className:`oc-cronactions`,children:[d?(0,B.jsx)(C,{variant:`ghost`,size:`icon-sm`,title:i(),"aria-label":i(),disabled:x!==null,onClick:()=>void X(o,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`}}},rt()),children:(0,B.jsx)(Et,{size:14,"aria-hidden":!0})}):null,d&&t.enabled!==null?(0,B.jsx)(C,{variant:`ghost`,size:`icon-sm`,title:L(t)===`pause`?Le():re(),"aria-label":L(t)===`pause`?Le():re(),disabled:x!==null,onClick:()=>void X(o,()=>a({instanceName:e.instanceName,jobId:t.id,patch:{enabled:L(t)===`resume`}}),L(t)===`pause`?s():se()),children:L(t)===`pause`?(0,B.jsx)(vt,{size:14,"aria-hidden":!0}):(0,B.jsx)(bt,{size:14,"aria-hidden":!0})}):null,d?(0,B.jsx)(C,{variant:`ghost`,size:`icon-sm`,title:f(),"aria-label":f(),disabled:x!==null,onClick:()=>void pn(e.instanceName,t),children:(0,B.jsx)(Ft,{size:14,"aria-hidden":!0})}):null,d?(0,B.jsx)(C,{variant:`ghost`,size:`icon-sm`,title:ce(),"aria-label":ce(),disabled:x!==null,onClick:()=>void ln(e.instanceName,t),children:(0,B.jsx)(Xt,{size:14,"aria-hidden":!0})}):null,l?(0,B.jsx)(C,{variant:`ghost`,size:`icon-sm`,title:u(),"aria-label":u(),disabled:x!==null,onClick:()=>ut({instanceName:e.instanceName,jobId:t.id,name:t.name??t.id}),children:(0,B.jsx)(jt,{size:14,"aria-hidden":!0})}):null]})})]},t.id??`${e.instanceName}-${n}`)})})]}):(0,B.jsx)(`p`,{className:`oc-admin__hint`,children:Ye()})]},e.instanceName)}),hn>0?(0,B.jsx)(`p`,{className:`oc-admin__hint`,style:{marginTop:4},children:Ne()}):null]}),(0,B.jsx)(Mt,{open:T!==null,onOpenChange:e=>{e||ut(null)},children:(0,B.jsxs)(Pt,{children:[(0,B.jsxs)(Nt,{children:[(0,B.jsx)(ht,{children:Se()}),(0,B.jsx)(mt,{children:st({name:T?.name??``})})]}),(0,B.jsxs)(dt,{children:[(0,B.jsx)(yt,{children:tt()}),(0,B.jsx)(It,{onClick:()=>{let e=T;ut(null),e!==null&&X(`${e.instanceName}:${e.jobId}`,()=>c({instanceName:e.instanceName,jobId:e.jobId}),at())},children:ve()})]})]})}),(0,B.jsx)(At,{open:O!==null,onOpenChange:e=>{e||(Z.current++,M(null))},children:(0,B.jsxs)(Tt,{style:{maxWidth:640},children:[(0,B.jsx)(_t,{children:(0,B.jsx)(Dt,{children:o({name:O?.name??``})})}),O?.entries===null?(0,B.jsx)(`p`,{className:`oc-admin__hint`,children:d()}):O!==null&&O.entries.length===0?(0,B.jsx)(`p`,{className:`oc-admin__hint`,children:oe()}):O===null?null:(0,B.jsx)(`div`,{className:`oc-cronpanel__runs`,style:{maxHeight:420,overflowY:`auto`},children:O.entries.map((e,t)=>(0,B.jsxs)(`div`,{className:`oc-cronpanel__run`,children:[(0,B.jsxs)(`div`,{className:`oc-cronpanel__run-head`,children:[(0,B.jsx)(fn,{status:e.status}),(0,B.jsx)(`span`,{children:typeof(e.runAtMs??e.ts)==`number`?Y.format(e.runAtMs??e.ts):`—`}),typeof e.durationMs==`number`?(0,B.jsxs)(`span`,{className:`oc-cronpanel__run-dur`,children:[Math.round(e.durationMs/1e3),`s`]}):null]}),e.summary===null?null:(0,B.jsx)(`div`,{className:`oc-cronpanel__run-summary`,children:e.summary}),e.error===null?null:(0,B.jsx)(`div`,{className:`oc-cronpanel__run-error`,children:e.error}),e.delivered===!1?(0,B.jsxs)(`div`,{className:`oc-cronpanel__run-undelivered`,children:[Ve({channel:e.deliveryChannel??`—`}),e.deliveryError===null?null:(0,B.jsx)(`span`,{className:`oc-cronpanel__plain`,children:e.deliveryError})]}):null]},t))})]})}),(0,B.jsx)(At,{open:N!==null,onOpenChange:e=>{e||(Q.current++,I(null))},children:(0,B.jsxs)(Tt,{className:`oc-cronedit`,children:[(0,B.jsxs)(_t,{children:[(0,B.jsx)(Dt,{children:it()}),(0,B.jsx)(kt,{children:xe()})]}),N===null?null:N.loading?(0,B.jsx)(`p`,{className:`oc-admin__hint`,children:d()}):(0,B.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:12},children:[(0,B.jsxs)(`label`,{style:{display:`flex`,flexDirection:`column`,gap:4},children:[(0,B.jsx)(`span`,{className:`oc-admin__hint`,style:{margin:0},children:Fe()}),(0,B.jsx)(Ct,{value:N.name,maxLength:200,onChange:e=>I({...N,name:e.target.value,nameDirty:!0})})]}),(0,B.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:4},children:[(0,B.jsx)(`span`,{className:`oc-admin__hint`,style:{margin:0},children:ot()}),(0,B.jsxs)(k,{value:N.scheduleKind,onValueChange:e=>I({...N,scheduleKind:e,scheduleDirty:!0}),children:[(0,B.jsx)(w,{children:(0,B.jsx)(j,{})}),(0,B.jsxs)(A,{children:[(0,B.jsx)(D,{value:`cron`,children:et()}),(0,B.jsx)(D,{value:`every`,children:_e()}),(0,B.jsx)(D,{value:`at`,children:je()})]})]}),N.scheduleKind===`cron`?(0,B.jsxs)(`div`,{style:{display:`flex`,gap:8},children:[(0,B.jsx)(Ct,{value:N.cronExpr,onChange:e=>I({...N,cronExpr:e.target.value,scheduleDirty:!0}),placeholder:`30 9 * * *`,style:{fontFamily:`var(--font-mono, monospace)`}}),(0,B.jsx)(Jt,{value:N.tz,onChange:e=>I({...N,tz:e,scheduleDirty:!0}),fallbackTz:ie??void 0})]}):N.scheduleKind===`every`?(0,B.jsxs)(`div`,{style:{display:`flex`,gap:8},children:[(0,B.jsx)(Ct,{type:`number`,min:1,value:N.everyValue,onChange:e=>I({...N,everyValue:e.target.value,scheduleDirty:!0}),style:{maxWidth:120}}),(0,B.jsxs)(k,{value:N.everyUnit,onValueChange:e=>I({...N,everyUnit:e,scheduleDirty:!0}),children:[(0,B.jsx)(w,{style:{maxWidth:160},children:(0,B.jsx)(j,{})}),(0,B.jsxs)(A,{children:[(0,B.jsx)(D,{value:`minutes`,children:Me()}),(0,B.jsx)(D,{value:`hours`,children:Be()}),(0,B.jsx)(D,{value:`days`,children:Ge()})]})]})]}):(0,B.jsx)(Zt,{value:N.at,onChange:e=>I({...N,at:e,scheduleDirty:!0})})]}),N.hasMessage?(0,B.jsxs)(`label`,{style:{display:`flex`,flexDirection:`column`,gap:4},children:[(0,B.jsx)(`span`,{className:`oc-admin__hint`,style:{margin:0},children:Ie()}),(0,B.jsx)(`textarea`,{className:`oc-cronedit__textarea`,rows:4,value:N.message,onChange:e=>I({...N,message:e.target.value,messageDirty:!0})})]}):null]}),(0,B.jsxs)(St,{children:[(0,B.jsx)(C,{variant:`ghost`,onClick:()=>I(null),children:tt()}),(0,B.jsxs)(C,{onClick:()=>void mn(),disabled:N===null||N.loading||Ut,children:[Ut?(0,B.jsx)(pt,{size:14,className:`oc-actrow__spin`,"aria-hidden":!0}):null,ke()]})]})]})})]})}export{pn as ScheduledTab};
@@ -1 +1 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$M as r,AM as i,AN as ee,BM as a,BN as o,CN as te,DM as s,DN as ne,EM as re,EN as ie,FM as c,FN as ae,Fz as l,GM as u,GN as oe,HM as d,HN as se,IM as f,IN as ce,Iz as p,JM as m,KM as h,LM as g,LN as le,MM as _,MN as ue,NM as v,NN as de,Nz as fe,OM as y,ON as pe,PM as b,PN as me,QM as he,RM as ge,RN as _e,SN as ve,TM as ye,TN as be,UM as x,UN as xe,VM as S,VN as Se,WM as C,WN as Ce,XM as we,YM as Te,ZM as Ee,_N as De,aN as Oe,bN as ke,cN as Ae,dN as je,eN as Me,fN as Ne,gN as Pe,hN as Fe,iN as Ie,jM as w,jN as Le,kM as T,kN as Re,lN as ze,mN as Be,nN as Ve,oN as He,pN as Ue,qM as E,rN as We,sN as Ge,t as D,tN as Ke,uN as qe,vN as Je,wN as Ye,xN as Xe,yN as Ze,zM as O,zN as k}from"./api-Cpjr7qvl.js";import{t as A}from"./button-CbwCr9Pi.js";import{$ as j,Dt as Qe,Et as M,Fn as N,Gn as $e,Hn as P,Q as F,U as et,Vn as tt,Wn as nt,X as I,Z as L,_ as rt,at as R,ct as z,et as B,it as V,jt as H,nt as U,ot as W,rt as it,st as at,tt as G,zn as ot}from"./index-c5j0e823.js";import{t as st}from"./FilterBar-BO7_dR0d.js";import{t as ct}from"./DataTableShell-CW5udl6V.js";import{t as lt}from"./roleDescriptions-CF4LmoIL.js";var K=t(e(),1),q=n(),J=[{value:`never`,label:()=>w(),days:null},{value:`30`,label:()=>i(),days:30},{value:`90`,label:()=>T(),days:90}],Y=720*60*60*1e3,X=`__all__`,Z={name:``,roleKey:``,description:``};function Q(){let e=$e({from:`/settings/serviceAccounts`}),t=nt({from:`/settings/serviceAccounts`}),n=e.q??``,i=e.status??X,[a,s]=(0,K.useState)(X),re=e=>void t({search:t=>({...t,q:e||void 0}),replace:!0}),c=e=>void t({search:t=>({...t,status:e===X?void 0:e})}),u=p(D.apiKeys.listServiceAccounts,{filter:{q:n||void 0,role:a===X?void 0:a,disabled:i===X?void 0:i===`disabled`}}),d=p(D.apiKeys.listKeys,{}),f=p(D.apiKeys.listRoles,{}),m=l(D.apiKeys.createServiceAccount),h=l(D.apiKeys.updateServiceAccount),g=l(D.apiKeys.deleteServiceAccount),_=fe(D.apiKeys.mintApiKey),v=l(D.apiKeys.revokeApiKey),y=et(),b=Qe(),ge=n!==``||a!==X||i!==X;function ye(){s(X),t({search:{},replace:!0})}let[x,S]=(0,K.useState)(!1),[C,w]=(0,K.useState)(Z),[T,E]=(0,K.useState)(null),[O,N]=(0,K.useState)(new Set),[P,R]=(0,K.useState)(null),z=(0,K.useRef)(!1),[V,U]=(0,K.useState)(new Set),[W,it]=(0,K.useState)({}),[at,G]=(0,K.useState)(null),Y=(0,K.useMemo)(()=>{let e=new Map;for(let t of d??[]){let n=e.get(t.serviceAccountId)??[];n.push(t),e.set(t.serviceAccountId,n)}return e},[d]);function Q(e){N(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}async function ft(){try{T?(await h({serviceAccountId:T,name:C.name,roleKey:C.roleKey,description:C.description}),b.success(ze())):await m({name:C.name,roleKey:C.roleKey,description:C.description||void 0}),w(Z),E(null),S(!1)}catch(e){b.error(T?qe():je(),e)}}function pt(e){w({name:e.name,roleKey:e.roleKey,description:e.description??``}),E(e._id),S(!0)}async function mt(e){if(z.current)return;z.current=!0;let t=W[e._id]??`never`,n=J.find(e=>e.value===t)?.days??null,r=n?Date.now()+n*24*60*60*1e3:void 0;R(e._id);try{let t=await _({serviceAccountId:e._id,expiresAt:r});G({accountName:e.name,plaintext:t.plaintext,prefix:t.prefix,lastFour:t.lastFour})}catch(e){b.error(Ae(),e)}finally{z.current=!1,R(null)}}async function $(e){if(await y({title:Ge(),description:(0,q.jsxs)(q.Fragment,{children:[He(),` `,(0,q.jsx)(`span`,{className:`font-mono`,children:e.name}),` `,Oe(),` `,(0,q.jsx)(`strong`,{children:Ie()}),` `,We()]}),confirmWord:e.name,confirmLabel:Ve(),destructive:!0}))try{await g({serviceAccountId:e._id}),b.success(Ke(),e.name)}catch(e){b.error(Me(),e)}}async function ht(e){if(await y({title:r(),description:(0,q.jsxs)(q.Fragment,{children:[he(),` `,(0,q.jsxs)(`span`,{className:`font-mono`,children:[e.prefix,`…`,e.lastFour]}),` `,Ee()]}),confirmLabel:we(),destructive:!0})&&!V.has(e._id)){U(t=>new Set(t).add(e._id));try{await v({keyId:e._id})}catch(e){b.error(Te(),e)}finally{U(t=>{let n=new Set(t);return n.delete(e._id),n})}}}return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`p`,{className:`oc-admin__hint`,children:oe()}),(0,q.jsxs)(st,{q:n,onQChange:re,searchPlaceholder:Ce(),onReset:ye,canReset:ge,children:[(0,q.jsxs)(I,{value:a,onValueChange:s,children:[(0,q.jsx)(j,{size:`sm`,className:`w-40`,children:(0,q.jsx)(B,{placeholder:xe()})}),(0,q.jsxs)(L,{children:[(0,q.jsx)(F,{value:X,children:se()}),(f??[]).map(e=>(0,q.jsx)(F,{value:e.key,children:e.key},e._id))]})]}),(0,q.jsxs)(I,{value:i,onValueChange:c,children:[(0,q.jsx)(j,{size:`sm`,className:`w-36`,children:(0,q.jsx)(B,{})}),(0,q.jsxs)(L,{children:[(0,q.jsx)(F,{value:X,children:Se()}),(0,q.jsx)(F,{value:`active`,children:o()}),(0,q.jsx)(F,{value:`disabled`,children:k()})]})]})]}),(0,q.jsx)(ct,{title:_e(),rows:u,addLabel:le(),onAdd:()=>{w(Z),E(null),S(!0)},emptyHint:ce(),isExpanded:e=>O.has(e._id),renderExpanded:e=>(0,q.jsx)(ut,{account:e,keys:Y.get(e._id)??[],onRevoke:ht,revoking:V}),rowActions:e=>[...(e.managedBy??null)===null?[{label:ue(),onSelect:()=>pt(e)},{label:ae(),onSelect:()=>void mt(e)}]:[],{label:O.has(e._id)?me():de(),onSelect:()=>Q(e._id)},...(e.managedBy??null)===null?[{label:Le(),variant:`destructive`,onSelect:()=>void $(e)}]:[]],columns:[{header:``,className:`w-8`,cell:e=>(0,q.jsx)(A,{variant:`ghost`,size:`icon-sm`,"aria-label":O.has(e._id)?ee():Re(),onClick:()=>Q(e._id),children:O.has(e._id)?(0,q.jsx)(tt,{}):(0,q.jsx)(ot,{})})},{header:pe(),sort:e=>e.name,cell:e=>(0,q.jsxs)(`div`,{className:`flex flex-col`,children:[(0,q.jsx)(`span`,{children:e.name}),e.description?(0,q.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:e.description}):null]})},{header:ne(),sort:e=>e.roleKey,cell:e=>(0,q.jsx)(M,{variant:`secondary`,children:e.roleKey})},{header:ie(),sort:e=>+!!e.disabled,cell:e=>e.disabled?(0,q.jsx)(M,{variant:`destructive`,children:k()}):(0,q.jsx)(M,{variant:`outline`,children:o()})},{header:be(),cell:e=>(0,q.jsxs)(I,{value:W[e._id]??`never`,onValueChange:t=>it(n=>({...n,[e._id]:t})),children:[(0,q.jsx)(j,{size:`sm`,className:`w-32`,children:(0,q.jsx)(B,{})}),(0,q.jsx)(L,{children:J.map(e=>(0,q.jsx)(F,{value:e.value,children:e.label()},e.value))})]})},{header:Ye(),sort:e=>(Y.get(e._id)??[]).filter(e=>!e.disabled).length,cell:e=>{let t=(Y.get(e._id)??[]).filter(e=>!e.disabled).length;return(0,q.jsx)(`span`,{className:`oc-sa__keycount`,children:P===e._id?te():ve({count:t})})}}]}),(0,q.jsx)(rt,{open:x,onOpenChange:e=>{S(e),e||E(null)},title:T?Xe():Je(),description:T?ke():De(),canSubmit:!!(C.name&&C.roleKey),onSubmit:ft,submitLabel:T?Ze():Pe(),children:(0,q.jsxs)(`div`,{className:`oc-form`,children:[(0,q.jsxs)(`label`,{className:`oc-field`,children:[(0,q.jsx)(`span`,{className:`oc-field__label`,children:Fe()}),(0,q.jsx)(H,{value:C.name,onChange:e=>w({...C,name:e.target.value})})]}),(0,q.jsxs)(`label`,{className:`oc-field`,children:[(0,q.jsx)(`span`,{className:`oc-field__label`,children:Be()}),(0,q.jsxs)(I,{value:C.roleKey||void 0,onValueChange:e=>w({...C,roleKey:e}),children:[(0,q.jsx)(j,{className:`w-full`,children:(0,q.jsx)(B,{placeholder:Ue()})}),(0,q.jsx)(L,{children:(f??[]).map(e=>(0,q.jsxs)(F,{value:e.key,children:[e.name,` (`,e.key,`)`]},e._id))})]}),(()=>{let e=(f??[]).find(e=>e.key===C.roleKey),t=e?lt(e):null;return t?(0,q.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:t}):null})()]}),(0,q.jsxs)(`label`,{className:`oc-field`,children:[(0,q.jsx)(`span`,{className:`oc-field__label`,children:Ne()}),(0,q.jsx)(H,{value:C.description,onChange:e=>w({...C,description:e.target.value})})]})]})}),(0,q.jsx)(dt,{minted:at,onClose:()=>G(null)})]})}function ut({account:e,keys:t,onRevoke:n,revoking:r}){return(0,q.jsxs)(`div`,{className:`oc-sa__keys`,children:[(0,q.jsxs)(`div`,{className:`oc-sa__keys-head`,children:[m(),` `,(0,q.jsx)(`span`,{className:`font-medium`,children:e.name})]}),t.length===0?(0,q.jsx)(`p`,{className:`oc-admin__hint`,children:E()}):(0,q.jsxs)(`table`,{className:`oc-sa__keytable`,children:[(0,q.jsx)(`thead`,{children:(0,q.jsxs)(`tr`,{children:[(0,q.jsx)(`th`,{children:h()}),(0,q.jsx)(`th`,{children:u()}),(0,q.jsx)(`th`,{children:C()}),(0,q.jsx)(`th`,{children:x()}),(0,q.jsx)(`th`,{children:d()}),(0,q.jsx)(`th`,{children:S()}),(0,q.jsx)(`th`,{})]})}),(0,q.jsx)(`tbody`,{children:t.map(t=>(0,q.jsxs)(`tr`,{children:[(0,q.jsx)(`td`,{children:(0,q.jsxs)(`code`,{className:`oc-sa__keyid`,children:[t.prefix,`…`,t.lastFour]})}),(0,q.jsx)(`td`,{children:(0,q.jsx)(M,{variant:`secondary`,children:e.roleKey})}),(0,q.jsx)(`td`,{children:z(t.createdAt)}),(0,q.jsx)(`td`,{className:ft(t.lastUsedAt)?`oc-sa__stale`:``,children:pt(t.lastUsedAt)}),(0,q.jsx)(`td`,{children:mt(t.expiresAt)}),(0,q.jsx)(`td`,{children:$(t)}),(0,q.jsx)(`td`,{className:`text-right`,children:!t.disabled&&(e.managedBy??null)===null?(0,q.jsx)(A,{variant:`destructive`,size:`sm`,disabled:r.has(t._id),onClick:()=>n(t),children:r.has(t._id)?a():O()}):null})]},t._id))})]})]})}function dt({minted:e,onClose:t}){let[n,r]=(0,K.useState)(!1);async function i(){if(e)try{await navigator.clipboard.writeText(e.plaintext),r(!0),window.setTimeout(()=>r(!1),2e3)}catch{}}return(0,q.jsx)(G,{open:e!==null,onOpenChange:e=>{e||(r(!1),t())},children:e?(0,q.jsxs)(U,{className:`max-w-lg`,showCloseButton:!1,onInteractOutside:e=>e.preventDefault(),onEscapeKeyDown:e=>e.preventDefault(),children:[(0,q.jsxs)(R,{children:[(0,q.jsx)(W,{children:ge()}),(0,q.jsx)(it,{children:g({name:e.accountName})})]}),(0,q.jsx)(`div`,{className:`oc-sa__minted-warning`,children:f()}),(0,q.jsxs)(`div`,{className:`oc-sa__minted-box`,children:[(0,q.jsx)(`code`,{className:`oc-sa__minted-plain`,children:e.plaintext}),(0,q.jsxs)(A,{variant:`outline`,size:`sm`,onClick:()=>void i(),"aria-label":c(),children:[n?(0,q.jsx)(P,{}):(0,q.jsx)(N,{}),n?b():v()]})]}),(0,q.jsx)(V,{children:(0,q.jsx)(A,{onClick:()=>{r(!1),t()},children:_()})})]}):null})}function ft(e){return e===null?!1:Date.now()-e>Y}function pt(e){return e===null?y():z(e)}function mt(e){return e===null?`—`:at(e)}function $(e){return e.disabled?(0,q.jsx)(M,{variant:`destructive`,children:s()}):e.expiresAt!==null&&e.expiresAt<Date.now()?(0,q.jsx)(M,{variant:`outline`,children:re()}):(0,q.jsx)(M,{variant:`outline`,children:ye()})}export{Q as ServiceAccountsTab};
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$M as r,AM as i,AN as ee,BM as a,BN as o,CN as te,DM as s,DN as ne,EM as re,EN as ie,FM as c,FN as ae,Fz as l,GM as u,GN as oe,HM as d,HN as se,IM as f,IN as ce,Iz as p,JM as m,KM as h,LM as g,LN as le,MM as _,MN as ue,NM as v,NN as de,Nz as fe,OM as y,ON as pe,PM as b,PN as me,QM as he,RM as ge,RN as _e,SN as ve,TM as ye,TN as be,UM as x,UN as xe,VM as S,VN as Se,WM as C,WN as Ce,XM as we,YM as Te,ZM as Ee,_N as De,aN as Oe,bN as ke,cN as Ae,dN as je,eN as Me,fN as Ne,gN as Pe,hN as Fe,iN as Ie,jM as w,jN as Le,kM as T,kN as Re,lN as ze,mN as Be,nN as Ve,oN as He,pN as Ue,qM as E,rN as We,sN as Ge,t as D,tN as Ke,uN as qe,vN as Je,wN as Ye,xN as Xe,yN as Ze,zM as O,zN as k}from"./api-Cpjr7qvl.js";import{t as A}from"./button-CbwCr9Pi.js";import{$ as j,Dt as Qe,Et as M,Fn as N,Gn as $e,Hn as P,Q as F,U as et,Vn as tt,Wn as nt,X as I,Z as L,_ as rt,at as R,ct as z,et as B,it as V,jt as H,nt as U,ot as W,rt as it,st as at,tt as G,zn as ot}from"./index-Bc3aF-kJ.js";import{t as st}from"./FilterBar-FHDxb3k3.js";import{t as ct}from"./DataTableShell-DWXPn72S.js";import{t as lt}from"./roleDescriptions-CF4LmoIL.js";var K=t(e(),1),q=n(),J=[{value:`never`,label:()=>w(),days:null},{value:`30`,label:()=>i(),days:30},{value:`90`,label:()=>T(),days:90}],Y=720*60*60*1e3,X=`__all__`,Z={name:``,roleKey:``,description:``};function Q(){let e=$e({from:`/settings/serviceAccounts`}),t=nt({from:`/settings/serviceAccounts`}),n=e.q??``,i=e.status??X,[a,s]=(0,K.useState)(X),re=e=>void t({search:t=>({...t,q:e||void 0}),replace:!0}),c=e=>void t({search:t=>({...t,status:e===X?void 0:e})}),u=p(D.apiKeys.listServiceAccounts,{filter:{q:n||void 0,role:a===X?void 0:a,disabled:i===X?void 0:i===`disabled`}}),d=p(D.apiKeys.listKeys,{}),f=p(D.apiKeys.listRoles,{}),m=l(D.apiKeys.createServiceAccount),h=l(D.apiKeys.updateServiceAccount),g=l(D.apiKeys.deleteServiceAccount),_=fe(D.apiKeys.mintApiKey),v=l(D.apiKeys.revokeApiKey),y=et(),b=Qe(),ge=n!==``||a!==X||i!==X;function ye(){s(X),t({search:{},replace:!0})}let[x,S]=(0,K.useState)(!1),[C,w]=(0,K.useState)(Z),[T,E]=(0,K.useState)(null),[O,N]=(0,K.useState)(new Set),[P,R]=(0,K.useState)(null),z=(0,K.useRef)(!1),[V,U]=(0,K.useState)(new Set),[W,it]=(0,K.useState)({}),[at,G]=(0,K.useState)(null),Y=(0,K.useMemo)(()=>{let e=new Map;for(let t of d??[]){let n=e.get(t.serviceAccountId)??[];n.push(t),e.set(t.serviceAccountId,n)}return e},[d]);function Q(e){N(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}async function ft(){try{T?(await h({serviceAccountId:T,name:C.name,roleKey:C.roleKey,description:C.description}),b.success(ze())):await m({name:C.name,roleKey:C.roleKey,description:C.description||void 0}),w(Z),E(null),S(!1)}catch(e){b.error(T?qe():je(),e)}}function pt(e){w({name:e.name,roleKey:e.roleKey,description:e.description??``}),E(e._id),S(!0)}async function mt(e){if(z.current)return;z.current=!0;let t=W[e._id]??`never`,n=J.find(e=>e.value===t)?.days??null,r=n?Date.now()+n*24*60*60*1e3:void 0;R(e._id);try{let t=await _({serviceAccountId:e._id,expiresAt:r});G({accountName:e.name,plaintext:t.plaintext,prefix:t.prefix,lastFour:t.lastFour})}catch(e){b.error(Ae(),e)}finally{z.current=!1,R(null)}}async function $(e){if(await y({title:Ge(),description:(0,q.jsxs)(q.Fragment,{children:[He(),` `,(0,q.jsx)(`span`,{className:`font-mono`,children:e.name}),` `,Oe(),` `,(0,q.jsx)(`strong`,{children:Ie()}),` `,We()]}),confirmWord:e.name,confirmLabel:Ve(),destructive:!0}))try{await g({serviceAccountId:e._id}),b.success(Ke(),e.name)}catch(e){b.error(Me(),e)}}async function ht(e){if(await y({title:r(),description:(0,q.jsxs)(q.Fragment,{children:[he(),` `,(0,q.jsxs)(`span`,{className:`font-mono`,children:[e.prefix,`…`,e.lastFour]}),` `,Ee()]}),confirmLabel:we(),destructive:!0})&&!V.has(e._id)){U(t=>new Set(t).add(e._id));try{await v({keyId:e._id})}catch(e){b.error(Te(),e)}finally{U(t=>{let n=new Set(t);return n.delete(e._id),n})}}}return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`p`,{className:`oc-admin__hint`,children:oe()}),(0,q.jsxs)(st,{q:n,onQChange:re,searchPlaceholder:Ce(),onReset:ye,canReset:ge,children:[(0,q.jsxs)(I,{value:a,onValueChange:s,children:[(0,q.jsx)(j,{size:`sm`,className:`w-40`,children:(0,q.jsx)(B,{placeholder:xe()})}),(0,q.jsxs)(L,{children:[(0,q.jsx)(F,{value:X,children:se()}),(f??[]).map(e=>(0,q.jsx)(F,{value:e.key,children:e.key},e._id))]})]}),(0,q.jsxs)(I,{value:i,onValueChange:c,children:[(0,q.jsx)(j,{size:`sm`,className:`w-36`,children:(0,q.jsx)(B,{})}),(0,q.jsxs)(L,{children:[(0,q.jsx)(F,{value:X,children:Se()}),(0,q.jsx)(F,{value:`active`,children:o()}),(0,q.jsx)(F,{value:`disabled`,children:k()})]})]})]}),(0,q.jsx)(ct,{title:_e(),rows:u,addLabel:le(),onAdd:()=>{w(Z),E(null),S(!0)},emptyHint:ce(),isExpanded:e=>O.has(e._id),renderExpanded:e=>(0,q.jsx)(ut,{account:e,keys:Y.get(e._id)??[],onRevoke:ht,revoking:V}),rowActions:e=>[...(e.managedBy??null)===null?[{label:ue(),onSelect:()=>pt(e)},{label:ae(),onSelect:()=>void mt(e)}]:[],{label:O.has(e._id)?me():de(),onSelect:()=>Q(e._id)},...(e.managedBy??null)===null?[{label:Le(),variant:`destructive`,onSelect:()=>void $(e)}]:[]],columns:[{header:``,className:`w-8`,cell:e=>(0,q.jsx)(A,{variant:`ghost`,size:`icon-sm`,"aria-label":O.has(e._id)?ee():Re(),onClick:()=>Q(e._id),children:O.has(e._id)?(0,q.jsx)(tt,{}):(0,q.jsx)(ot,{})})},{header:pe(),sort:e=>e.name,cell:e=>(0,q.jsxs)(`div`,{className:`flex flex-col`,children:[(0,q.jsx)(`span`,{children:e.name}),e.description?(0,q.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:e.description}):null]})},{header:ne(),sort:e=>e.roleKey,cell:e=>(0,q.jsx)(M,{variant:`secondary`,children:e.roleKey})},{header:ie(),sort:e=>+!!e.disabled,cell:e=>e.disabled?(0,q.jsx)(M,{variant:`destructive`,children:k()}):(0,q.jsx)(M,{variant:`outline`,children:o()})},{header:be(),cell:e=>(0,q.jsxs)(I,{value:W[e._id]??`never`,onValueChange:t=>it(n=>({...n,[e._id]:t})),children:[(0,q.jsx)(j,{size:`sm`,className:`w-32`,children:(0,q.jsx)(B,{})}),(0,q.jsx)(L,{children:J.map(e=>(0,q.jsx)(F,{value:e.value,children:e.label()},e.value))})]})},{header:Ye(),sort:e=>(Y.get(e._id)??[]).filter(e=>!e.disabled).length,cell:e=>{let t=(Y.get(e._id)??[]).filter(e=>!e.disabled).length;return(0,q.jsx)(`span`,{className:`oc-sa__keycount`,children:P===e._id?te():ve({count:t})})}}]}),(0,q.jsx)(rt,{open:x,onOpenChange:e=>{S(e),e||E(null)},title:T?Xe():Je(),description:T?ke():De(),canSubmit:!!(C.name&&C.roleKey),onSubmit:ft,submitLabel:T?Ze():Pe(),children:(0,q.jsxs)(`div`,{className:`oc-form`,children:[(0,q.jsxs)(`label`,{className:`oc-field`,children:[(0,q.jsx)(`span`,{className:`oc-field__label`,children:Fe()}),(0,q.jsx)(H,{value:C.name,onChange:e=>w({...C,name:e.target.value})})]}),(0,q.jsxs)(`label`,{className:`oc-field`,children:[(0,q.jsx)(`span`,{className:`oc-field__label`,children:Be()}),(0,q.jsxs)(I,{value:C.roleKey||void 0,onValueChange:e=>w({...C,roleKey:e}),children:[(0,q.jsx)(j,{className:`w-full`,children:(0,q.jsx)(B,{placeholder:Ue()})}),(0,q.jsx)(L,{children:(f??[]).map(e=>(0,q.jsxs)(F,{value:e.key,children:[e.name,` (`,e.key,`)`]},e._id))})]}),(()=>{let e=(f??[]).find(e=>e.key===C.roleKey),t=e?lt(e):null;return t?(0,q.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:t}):null})()]}),(0,q.jsxs)(`label`,{className:`oc-field`,children:[(0,q.jsx)(`span`,{className:`oc-field__label`,children:Ne()}),(0,q.jsx)(H,{value:C.description,onChange:e=>w({...C,description:e.target.value})})]})]})}),(0,q.jsx)(dt,{minted:at,onClose:()=>G(null)})]})}function ut({account:e,keys:t,onRevoke:n,revoking:r}){return(0,q.jsxs)(`div`,{className:`oc-sa__keys`,children:[(0,q.jsxs)(`div`,{className:`oc-sa__keys-head`,children:[m(),` `,(0,q.jsx)(`span`,{className:`font-medium`,children:e.name})]}),t.length===0?(0,q.jsx)(`p`,{className:`oc-admin__hint`,children:E()}):(0,q.jsxs)(`table`,{className:`oc-sa__keytable`,children:[(0,q.jsx)(`thead`,{children:(0,q.jsxs)(`tr`,{children:[(0,q.jsx)(`th`,{children:h()}),(0,q.jsx)(`th`,{children:u()}),(0,q.jsx)(`th`,{children:C()}),(0,q.jsx)(`th`,{children:x()}),(0,q.jsx)(`th`,{children:d()}),(0,q.jsx)(`th`,{children:S()}),(0,q.jsx)(`th`,{})]})}),(0,q.jsx)(`tbody`,{children:t.map(t=>(0,q.jsxs)(`tr`,{children:[(0,q.jsx)(`td`,{children:(0,q.jsxs)(`code`,{className:`oc-sa__keyid`,children:[t.prefix,`…`,t.lastFour]})}),(0,q.jsx)(`td`,{children:(0,q.jsx)(M,{variant:`secondary`,children:e.roleKey})}),(0,q.jsx)(`td`,{children:z(t.createdAt)}),(0,q.jsx)(`td`,{className:ft(t.lastUsedAt)?`oc-sa__stale`:``,children:pt(t.lastUsedAt)}),(0,q.jsx)(`td`,{children:mt(t.expiresAt)}),(0,q.jsx)(`td`,{children:$(t)}),(0,q.jsx)(`td`,{className:`text-right`,children:!t.disabled&&(e.managedBy??null)===null?(0,q.jsx)(A,{variant:`destructive`,size:`sm`,disabled:r.has(t._id),onClick:()=>n(t),children:r.has(t._id)?a():O()}):null})]},t._id))})]})]})}function dt({minted:e,onClose:t}){let[n,r]=(0,K.useState)(!1);async function i(){if(e)try{await navigator.clipboard.writeText(e.plaintext),r(!0),window.setTimeout(()=>r(!1),2e3)}catch{}}return(0,q.jsx)(G,{open:e!==null,onOpenChange:e=>{e||(r(!1),t())},children:e?(0,q.jsxs)(U,{className:`max-w-lg`,showCloseButton:!1,onInteractOutside:e=>e.preventDefault(),onEscapeKeyDown:e=>e.preventDefault(),children:[(0,q.jsxs)(R,{children:[(0,q.jsx)(W,{children:ge()}),(0,q.jsx)(it,{children:g({name:e.accountName})})]}),(0,q.jsx)(`div`,{className:`oc-sa__minted-warning`,children:f()}),(0,q.jsxs)(`div`,{className:`oc-sa__minted-box`,children:[(0,q.jsx)(`code`,{className:`oc-sa__minted-plain`,children:e.plaintext}),(0,q.jsxs)(A,{variant:`outline`,size:`sm`,onClick:()=>void i(),"aria-label":c(),children:[n?(0,q.jsx)(P,{}):(0,q.jsx)(N,{}),n?b():v()]})]}),(0,q.jsx)(V,{children:(0,q.jsx)(A,{onClick:()=>{r(!1),t()},children:_()})})]}):null})}function ft(e){return e===null?!1:Date.now()-e>Y}function pt(e){return e===null?y():z(e)}function mt(e){return e===null?`—`:at(e)}function $(e){return e.disabled?(0,q.jsx)(M,{variant:`destructive`,children:s()}):e.expiresAt!==null&&e.expiresAt<Date.now()?(0,q.jsx)(M,{variant:`outline`,children:re()}):(0,q.jsx)(M,{variant:`outline`,children:ye()})}export{Q as ServiceAccountsTab};